Closed ihor-sviziev closed 3 years ago
Hi @ihor-sviziev. Thank you for your report. To help us process this issue please make sure that you provided sufficient information.
Please, add a comment to assign the issue: @magento I am working on this
As we discussed with @sivaschenko in Slack - ✔ that works fine for the client code, in case if the class class doesn't have any inheritance and *strict types not declared in the client code: https://3v4l.org/NBiQU
<?php
class A
{
public function encodeUrlParam(string $string)
{
echo $string;
}
}
$a = new A();
$a->encodeUrlParam(1);
❌ that doesn't for the client code, in case if the class doesn't have any inheritance and declared strict types in the client code: https://3v4l.org/3ovqX
<?php
declare(strict_types=1);
class A
{
public function encodeUrlParam(string $string)
{
echo $string;
}
}
$a = new A();
$a->encodeUrlParam(1);
Hi,
This is a follow-up on the https://github.com/magento/magento2/pull/33353#issuecomment-874976048.
While working on https://github.com/magento/magento2/pull/33353, there were added following changes:
The SVC failure was failing:
Basically, adding argument type shouldn't introduce any breaking changes since PHP 7.2 (thanks to https://wiki.php.net/rfc/parameter-no-type-variance).
Examples:
Here are two examples that works fine
class A { public function encodeUrlParam(string $string) { echo $string;
} }
class extendedA extends A { public function encodeUrlParam($string) { echo $string; } }
$a = new extendedA(); $a->encodeUrlParam('test');
class A { public function encodeUrlParam(string $string) { echo $string;
} }
class extendedA extends A { public function encodeUrlParam($string) { echo $string; } }
$a = new extendedA(); $a->encodeUrlParam(1);
:exclamation: ❌ Note: it doesn't work like that for return types https://3v4l.org/ti9uU