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 #20133

Merged
merged 3 commits into from
Mar 26, 2024
Merged
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/console/FakePhp71Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{

}
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 @@ -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));
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/web/FakePhp71Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{

}
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)
public function actionAksi1(int $foo, ?float $bar = null, bool $true, bool $false)
{
}

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