Skip to content

Commit a292af1

Browse files
Ayeshterabytesoftwsamdark
authored
[PHP 8.4] Fixes for implicit nullability deprecation (#20133)
Fixes all issues that emit deprecation notices on PHP 8.4 for implicit nullable parameter type declarations. Related to #20128. See: - [RFC](https://wiki.php.net/rfc/deprecate-implicitly-nullable-types) - [PHP 8.4: Implicitly nullable parameter declarations deprecated](https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated) Co-authored-by: Wilmer Arambula <[email protected]> Co-authored-by: Alexander Makarov <[email protected]>
1 parent ac1a5af commit a292af1

File tree

11 files changed

+15
-15
lines changed

11 files changed

+15
-15
lines changed

framework/base/Component.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ public function off($name, $handler = null)
605605
* @param string $name the event name
606606
* @param Event|null $event the event instance. If not set, a default [[Event]] object will be created.
607607
*/
608-
public function trigger($name, Event $event = null)
608+
public function trigger($name, ?Event $event = null)
609609
{
610610
$this->ensureBehaviors();
611611

framework/db/ActiveQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ public function orOnCondition($condition, $params = [])
785785
* @throws InvalidConfigException when query is not initialized properly
786786
* @see via()
787787
*/
788-
public function viaTable($tableName, $link, callable $callable = null)
788+
public function viaTable($tableName, $link, ?callable $callable = null)
789789
{
790790
$modelClass = $this->primaryModel ? get_class($this->primaryModel) : $this->modelClass;
791791
$relation = new self($modelClass, [

framework/db/ActiveQueryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function with();
9797
* Its signature should be `function($query)`, where `$query` is the query to be customized.
9898
* @return $this the relation object itself.
9999
*/
100-
public function via($relationName, callable $callable = null);
100+
public function via($relationName, ?callable $callable = null);
101101

102102
/**
103103
* Finds the related records for the specified primary record.

framework/db/ActiveRelationTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function __clone()
104104
* Its signature should be `function($query)`, where `$query` is the query to be customized.
105105
* @return $this the relation object itself.
106106
*/
107-
public function via($relationName, callable $callable = null)
107+
public function via($relationName, ?callable $callable = null)
108108
{
109109
$relation = $this->primaryModel->getRelation($relationName);
110110
$callableUsed = $callable !== null;

framework/mail/BaseMessage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ abstract class BaseMessage extends BaseObject implements MessageInterface
3939
* the "mailer" application component will be used instead.
4040
* @return bool whether this message is sent successfully.
4141
*/
42-
public function send(MailerInterface $mailer = null)
42+
public function send(?MailerInterface $mailer = null)
4343
{
4444
if ($mailer === null && $this->mailer === null) {
4545
$mailer = Yii::$app->getMailer();

framework/mail/MessageInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function embedContent($content, array $options = []);
209209
* If null, the "mailer" application component will be used instead.
210210
* @return bool whether this message is sent successfully.
211211
*/
212-
public function send(MailerInterface $mailer = null);
212+
public function send(?MailerInterface $mailer = null);
213213

214214
/**
215215
* Returns string representation of this message.

tests/framework/console/FakePhp71Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
class FakePhp71Controller extends Controller
1616
{
17-
public function actionInjection($before, Request $request, $between, DummyService $dummyService, Post $post = null, $after)
17+
public function actionInjection($before, Request $request, $between, DummyService $dummyService, ?Post $post = null, $after)
1818
{
1919

2020
}

tests/framework/di/ContainerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public function testOptionalDependencies()
252252
{
253253
$container = new Container();
254254
// Test optional unresolvable dependency.
255-
$closure = function (QuxInterface $test = null) {
255+
$closure = function (?QuxInterface $test = null) {
256256
return $test;
257257
};
258258
$this->assertNull($container->invoke($closure));

tests/framework/di/stubs/Alpha.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ class Alpha extends BaseObject
1212
public $color = true;
1313

1414
public function __construct(
15-
Beta $beta = null,
16-
QuxInterface $omega = null,
17-
Unknown $unknown = null,
18-
AbstractColor $color = null
15+
?Beta $beta = null,
16+
?QuxInterface $omega = null,
17+
?Unknown $unknown = null,
18+
?AbstractColor $color = null
1919
) {
2020
$this->beta = $beta;
2121
$this->omega = $omega;

tests/framework/web/FakePhp71Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class FakePhp71Controller extends Controller
2121
{
2222
public $enableCsrfValidation = false;
2323

24-
public function actionInjection($before, Request $request, $between, VendorImage $vendorImage, Post $post = null, $after)
24+
public function actionInjection($before, Request $request, $between, VendorImage $vendorImage, ?Post $post = null, $after)
2525
{
2626

2727
}

0 commit comments

Comments
 (0)