mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
[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 <terabytesoftw@gmail.com> Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
This commit is contained in:

committed by
GitHub

parent
ac1a5af67b
commit
a292af13bf
@ -605,7 +605,7 @@ class Component extends BaseObject
|
|||||||
* @param string $name the event name
|
* @param string $name the event name
|
||||||
* @param Event|null $event the event instance. If not set, a default [[Event]] object will be created.
|
* @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();
|
$this->ensureBehaviors();
|
||||||
|
|
||||||
|
@ -785,7 +785,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
|||||||
* @throws InvalidConfigException when query is not initialized properly
|
* @throws InvalidConfigException when query is not initialized properly
|
||||||
* @see via()
|
* @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;
|
$modelClass = $this->primaryModel ? get_class($this->primaryModel) : $this->modelClass;
|
||||||
$relation = new self($modelClass, [
|
$relation = new self($modelClass, [
|
||||||
|
@ -97,7 +97,7 @@ interface ActiveQueryInterface extends QueryInterface
|
|||||||
* Its signature should be `function($query)`, where `$query` is the query to be customized.
|
* Its signature should be `function($query)`, where `$query` is the query to be customized.
|
||||||
* @return $this the relation object itself.
|
* @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.
|
* Finds the related records for the specified primary record.
|
||||||
|
@ -104,7 +104,7 @@ trait ActiveRelationTrait
|
|||||||
* Its signature should be `function($query)`, where `$query` is the query to be customized.
|
* Its signature should be `function($query)`, where `$query` is the query to be customized.
|
||||||
* @return $this the relation object itself.
|
* @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);
|
$relation = $this->primaryModel->getRelation($relationName);
|
||||||
$callableUsed = $callable !== null;
|
$callableUsed = $callable !== null;
|
||||||
|
@ -39,7 +39,7 @@ abstract class BaseMessage extends BaseObject implements MessageInterface
|
|||||||
* the "mailer" application component will be used instead.
|
* the "mailer" application component will be used instead.
|
||||||
* @return bool whether this message is sent successfully.
|
* @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) {
|
if ($mailer === null && $this->mailer === null) {
|
||||||
$mailer = Yii::$app->getMailer();
|
$mailer = Yii::$app->getMailer();
|
||||||
|
@ -209,7 +209,7 @@ interface MessageInterface
|
|||||||
* If null, the "mailer" application component will be used instead.
|
* If null, the "mailer" application component will be used instead.
|
||||||
* @return bool whether this message is sent successfully.
|
* @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.
|
* Returns string representation of this message.
|
||||||
|
@ -14,7 +14,7 @@ use yii\console\Request;
|
|||||||
|
|
||||||
class FakePhp71Controller extends Controller
|
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)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ class ContainerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
// Test optional unresolvable dependency.
|
// Test optional unresolvable dependency.
|
||||||
$closure = function (QuxInterface $test = null) {
|
$closure = function (?QuxInterface $test = null) {
|
||||||
return $test;
|
return $test;
|
||||||
};
|
};
|
||||||
$this->assertNull($container->invoke($closure));
|
$this->assertNull($container->invoke($closure));
|
||||||
|
@ -12,10 +12,10 @@ class Alpha extends BaseObject
|
|||||||
public $color = true;
|
public $color = true;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Beta $beta = null,
|
?Beta $beta = null,
|
||||||
QuxInterface $omega = null,
|
?QuxInterface $omega = null,
|
||||||
Unknown $unknown = null,
|
?Unknown $unknown = null,
|
||||||
AbstractColor $color = null
|
?AbstractColor $color = null
|
||||||
) {
|
) {
|
||||||
$this->beta = $beta;
|
$this->beta = $beta;
|
||||||
$this->omega = $omega;
|
$this->omega = $omega;
|
||||||
|
@ -21,7 +21,7 @@ class FakePhp71Controller extends Controller
|
|||||||
{
|
{
|
||||||
public $enableCsrfValidation = false;
|
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)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,11 @@ class FakePhp7Controller extends Controller
|
|||||||
{
|
{
|
||||||
public $enableCsrfValidation = false;
|
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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user