Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP 8.4] Fixes for implicit nullability deprecation #20128

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion framework/base/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ public function off($name, $handler = null)
* @param string $name the event name
* @param Event|null $event the event instance. If not set, a default [[Event]] object will be created.
*/
public function trigger($name, Event $event = null)
public function trigger($name, ?Event $event = null)
{
$this->ensureBehaviors();

Expand Down
2 changes: 1 addition & 1 deletion framework/db/ActiveQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ public function orOnCondition($condition, $params = [])
* @throws InvalidConfigException when query is not initialized properly
* @see via()
*/
public function viaTable($tableName, $link, callable $callable = null)
public function viaTable($tableName, $link, ?callable $callable = null)
{
$modelClass = $this->primaryModel ? get_class($this->primaryModel) : $this->modelClass;
$relation = new self($modelClass, [
Expand Down
2 changes: 1 addition & 1 deletion framework/db/ActiveQueryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function with();
* Its signature should be `function($query)`, where `$query` is the query to be customized.
* @return $this the relation object itself.
*/
public function via($relationName, callable $callable = null);
public function via($relationName, ?callable $callable = null);

/**
* Finds the related records for the specified primary record.
Expand Down
2 changes: 1 addition & 1 deletion framework/db/ActiveRelationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function __clone()
* Its signature should be `function($query)`, where `$query` is the query to be customized.
* @return $this the relation object itself.
*/
public function via($relationName, callable $callable = null)
public function via($relationName, ?callable $callable = null)
{
$relation = $this->primaryModel->getRelation($relationName);
$callableUsed = $callable !== null;
Expand Down
2 changes: 1 addition & 1 deletion framework/mail/BaseMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class BaseMessage extends BaseObject implements MessageInterface
* the "mailer" application component will be used instead.
* @return bool whether this message is sent successfully.
*/
public function send(MailerInterface $mailer = null)
public function send(?MailerInterface $mailer = null)
{
if ($mailer === null && $this->mailer === null) {
$mailer = Yii::$app->getMailer();
Expand Down
2 changes: 1 addition & 1 deletion framework/mail/MessageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function embedContent($content, array $options = []);
* If null, the "mailer" application component will be used instead.
* @return bool whether this message is sent successfully.
*/
public function send(MailerInterface $mailer = null);
public function send(?MailerInterface $mailer = null);

/**
* Returns string representation of this message.
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/base/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testRunAction(): void
public function testCreateInlineAction(
string $controllerClass,
string $actionId,
string $expectedActionMethod = null
?string $expectedActionMethod = null
): void {
$this->mockApplication();
/** @var Controller $controller */
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/behaviors/AttributeBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function testPreserveNonEmptyValues(
string $aliasExpected,
bool $preserveNonEmptyValues,
string $name,
string $alias = null
?string $alias = null
): void {
$model = new ActiveRecordWithAttributeBehavior();
$model->attributeBehavior->preserveNonEmptyValues = $preserveNonEmptyValues;
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/behaviors/AttributesBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function testPreserveNonEmptyValues(
string $aliasExpected,
bool $preserveNonEmptyValues,
string $name,
string $alias = null
?string $alias = null
): void {
$model = new ActiveRecordWithAttributesBehavior();
$model->attributesBehavior->preserveNonEmptyValues = $preserveNonEmptyValues;
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/console/FakePhp71Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function actionInjection(
Request $request,
$between,
DummyService $dummyService,
Post $post = null,
?Post $post = null,
$after
): void {
}
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/console/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static function provider(): array
* @param array $expected The expected result.
* @param array|null $expectedException The expected exception.
*/
public function testResolve(array $params, array $expected, array $expectedException = null): void
public function testResolve(array $params, array $expected, ?array $expectedException = null): void
{
if (isset($expectedException)) {
$this->expectException($expectedException[0]);
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/di/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function testOptionalDependencies(): void
{
$container = new Container();
// Test optional unresolvable dependency.
$closure = fn(QuxInterface $test = null) => $test;
$closure = fn(?QuxInterface $test = null) => $test;
$this->assertNull($container->invoke($closure));
}

Expand Down
8 changes: 4 additions & 4 deletions tests/framework/di/stubs/Alpha.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class Alpha extends BaseObject
public $color = true;

public function __construct(
Beta $beta = null,
QuxInterface $omega = null,
Unknown $unknown = null,
AbstractColor $color = null
?Beta $beta = null,
?QuxInterface $omega = null,
?Unknown $unknown = null,
?AbstractColor $color = null
) {
$this->beta = $beta;
$this->omega = $omega;
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/filters/AccessRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function mockRequest(string $method = 'GET'): Request
return $request;
}

protected function mockUser(string $userid = null): User
protected function mockUser(?string $userid = null): User
{
$user = new User([
'identityClass' => UserIdentity::class,
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/helpers/HtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1641,7 +1641,7 @@ function ($model): void {
/**
* @dataProvider errorSummaryDataProvider
*/
public function testErrorSummary(string $value, array $options, string $expectedHtml, \Closure $beforeValidate = null): void
public function testErrorSummary(string $value, array $options, string $expectedHtml, ?\Closure $beforeValidate = null): void
{
$model = new HtmlTestModel();
$model->name = $value;
Expand Down
4 changes: 2 additions & 2 deletions tests/framework/i18n/FormatterDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ public static function dateInputs()
* @param mixed $value
* @param mixed|null $expectedException
*/
public function testIntlDateInput(string|bool $expected, string $value, string $expectedException = null): void
public function testIntlDateInput(string|bool $expected, string $value, ?string $expectedException = null): void
{
$this->testDateInput($expected, $value, $expectedException);
}
Expand All @@ -564,7 +564,7 @@ public function testIntlDateInput(string|bool $expected, string $value, string $
* @param mixed $value
* @param mixed|null $expectedException
*/
public function testDateInput(string|bool $expected, string $value, string $expectedException = null): void
public function testDateInput(string|bool $expected, string $value, ?string $expectedException = null): void
{
if ($expectedException !== null) {
$this->expectException($expectedException);
Expand Down
4 changes: 2 additions & 2 deletions tests/framework/rest/IndexActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public function testPrepareSearchQueryAttribute(): void
public function testPrepareDataProviderWithPaginationAndSorting(
\yii\data\Pagination|bool|array $pagination,
\yii\data\Sort|bool|array $sort,
int $expectedPaginationPageSize = null,
int $expectedPaginationDefaultPageSize = null,
?int $expectedPaginationPageSize = null,
?int $expectedPaginationDefaultPageSize = null,
array $expectedSortOrders = [],
?array $expectedSortDefaultOrder = null
): void {
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/web/AssetBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public static function registerFileDataProvider()
* @param string|bool $appendTimestamp
* @param string|null $webAlias
*/
public function testRegisterFileAppendTimestamp(string $type, string $path, bool $appendTimestamp, string $expected, string $webAlias = null): void
public function testRegisterFileAppendTimestamp(string $type, string $path, bool $appendTimestamp, string $expected, ?string $webAlias = null): void
{
$originalAlias = Yii::getAlias('@web');
if ($webAlias === null) {
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/web/FakePhp71Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function actionInjection(
Request $request,
$between,
VendorImage $vendorImage,
Post $post = null,
?Post $post = null,
$after
): void {
}
Expand Down
4 changes: 2 additions & 2 deletions tests/framework/web/FakePhp7Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class FakePhp7Controller extends Controller
{
public $enableCsrfValidation = false;

public function actionAksi1(int $foo, float $bar = null, bool $true, bool $false): void
public function actionAksi1(int $foo, ?float $bar = null, bool $true, bool $false): void
{
}

public function actionStringy(string $foo = null): void
public function actionStringy(?string $foo = null): void
{
}
}
Loading