diff --git a/framework/base/Component.php b/framework/base/Component.php index fb4805df0ce..f2eb9bf05c1 100644 --- a/framework/base/Component.php +++ b/framework/base/Component.php @@ -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(); diff --git a/framework/db/ActiveQuery.php b/framework/db/ActiveQuery.php index 2153e7db155..8f5fc9903e1 100644 --- a/framework/db/ActiveQuery.php +++ b/framework/db/ActiveQuery.php @@ -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, [ diff --git a/framework/db/ActiveQueryInterface.php b/framework/db/ActiveQueryInterface.php index ec53af2d4bc..f15e49eb008 100644 --- a/framework/db/ActiveQueryInterface.php +++ b/framework/db/ActiveQueryInterface.php @@ -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. diff --git a/framework/db/ActiveRelationTrait.php b/framework/db/ActiveRelationTrait.php index 7e01e25fd99..467203e8a9f 100644 --- a/framework/db/ActiveRelationTrait.php +++ b/framework/db/ActiveRelationTrait.php @@ -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; diff --git a/framework/mail/BaseMessage.php b/framework/mail/BaseMessage.php index ca53dac10c9..30940994499 100644 --- a/framework/mail/BaseMessage.php +++ b/framework/mail/BaseMessage.php @@ -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(); diff --git a/framework/mail/MessageInterface.php b/framework/mail/MessageInterface.php index 091dce5faa7..e4c62a2d528 100644 --- a/framework/mail/MessageInterface.php +++ b/framework/mail/MessageInterface.php @@ -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. diff --git a/tests/framework/console/FakePhp71Controller.php b/tests/framework/console/FakePhp71Controller.php index dbed836f8d1..cc23ae60299 100644 --- a/tests/framework/console/FakePhp71Controller.php +++ b/tests/framework/console/FakePhp71Controller.php @@ -14,7 +14,7 @@ class FakePhp71Controller extends Controller { - public function actionInjection($before, Request $request, $between, DummyService $dummyService, Post $post = null, $after) + public function actionInjection($before, Request $request, $between, DummyService $dummyService, ?Post $post = null, $after) { } diff --git a/tests/framework/di/ContainerTest.php b/tests/framework/di/ContainerTest.php index ba62b598b73..2555f43c2d6 100644 --- a/tests/framework/di/ContainerTest.php +++ b/tests/framework/di/ContainerTest.php @@ -252,7 +252,7 @@ public function testOptionalDependencies() { $container = new Container(); // Test optional unresolvable dependency. - $closure = function (QuxInterface $test = null) { + $closure = function (?QuxInterface $test = null) { return $test; }; $this->assertNull($container->invoke($closure)); diff --git a/tests/framework/di/stubs/Alpha.php b/tests/framework/di/stubs/Alpha.php index 151d2f109bb..a5af3ffed78 100644 --- a/tests/framework/di/stubs/Alpha.php +++ b/tests/framework/di/stubs/Alpha.php @@ -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; diff --git a/tests/framework/web/FakePhp71Controller.php b/tests/framework/web/FakePhp71Controller.php index d8aa0e406c5..f84214c6e8d 100644 --- a/tests/framework/web/FakePhp71Controller.php +++ b/tests/framework/web/FakePhp71Controller.php @@ -21,7 +21,7 @@ class FakePhp71Controller extends Controller { public $enableCsrfValidation = false; - public function actionInjection($before, Request $request, $between, VendorImage $vendorImage, Post $post = null, $after) + public function actionInjection($before, Request $request, $between, VendorImage $vendorImage, ?Post $post = null, $after) { } diff --git a/tests/framework/web/FakePhp7Controller.php b/tests/framework/web/FakePhp7Controller.php index 4d267a85e15..381ba3e0ee3 100644 --- a/tests/framework/web/FakePhp7Controller.php +++ b/tests/framework/web/FakePhp7Controller.php @@ -17,11 +17,11 @@ class FakePhp7Controller extends Controller { public $enableCsrfValidation = false; - public function actionAksi1(int $foo, float $bar = null, bool $true, bool $false) + public function actionAksi1(int $foo, ?float $bar = null, bool $true, bool $false) { } - public function actionStringy(string $foo = null) + public function actionStringy(?string $foo = null) { } }