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:
@@ -289,7 +289,7 @@ public function escapeUrl($string)
* @return string
* @since 101.0.0
*/
- public function encodeUrlParam($string)
+ public function encodeUrlParam(string $string)
{
return $this->getEscaper()->escapeUrl($string);
}
@@ -328,7 +328,7 @@ function ($matches) {
* @return string
* @since 101.0.0
*/
- public function escapeCss($string)
+ public function escapeCss(string $string)
{
return $this->getEscaper()->escapeCss($string);
}
The SVC failure was failing:
Level | Target/Location | Code/Reason
-- | -- | --
MAJOR | Magento\Framework\Escaper::encodeUrlParam/lib/internal/Magento/Framework/Escaper.php:292 | V085 [public] Method parameter typing added.
MAJOR | Magento\Framework\Escaper::escapeCss/lib/internal/Magento/Framework/Escaper.php:331 | V085 [public] Method parameter typing added.

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
- ✔ w/o strict types, pass string https://3v4l.org/IBGCK
<?php
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');

- ✔with strict types, pass string https://3v4l.org/eFu0n
<?php
declare(strict_types=1);
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');

- ✔ w/o strict types, pass int https://3v4l.org/KDom7
<?php
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);

- ✔with strict types, pass int https://3v4l.org/cGn61
<?php
declare(strict_types=1);
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
<?php
class A
{
public function encodeUrlParam(string $string): string
{
echo $string;
}
}
class extendedA extends A
{
public function encodeUrlParam($string)
{
echo $string;
}
}
$a = new extendedA();
$a->encodeUrlParam('test');

Progress: done