3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Test { public function foo(int $id = 1, string $str) {} public function bar(int $id = 1, string $str = '') {} } var_dump((string) new \ReflectionMethod(new Test(), 'foo')); var_dump((string) new \ReflectionMethod(new Test(), 'bar'));
Output for 8.0.27
Deprecated: Required parameter $str follows optional parameter $id in /in/Za9kK on line 4 string(171) "Method [ <user> public method foo ] { @@ /in/Za9kK 4 - 4 - Parameters [2] { Parameter #0 [ <required> int $id ] Parameter #1 [ <required> string $str ] } } " string(180) "Method [ <user> public method bar ] { @@ /in/Za9kK 5 - 5 - Parameters [2] { Parameter #0 [ <optional> int $id = 1 ] Parameter #1 [ <optional> string $str = '' ] } } "
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.34, 8.3.0 - 8.3.35
Deprecated: Optional parameter $id declared before required parameter $str is implicitly treated as a required parameter in /in/Za9kK on line 4 string(171) "Method [ <user> public method foo ] { @@ /in/Za9kK 4 - 4 - Parameters [2] { Parameter #0 [ <required> int $id ] Parameter #1 [ <required> string $str ] } } " string(180) "Method [ <user> public method bar ] { @@ /in/Za9kK 5 - 5 - Parameters [2] { Parameter #0 [ <optional> int $id = 1 ] Parameter #1 [ <optional> string $str = '' ] } } "
Output for 8.4.1 - 8.4.26, 8.5.0 - 8.5.11
Deprecated: Test::foo(): Optional parameter $id declared before required parameter $str is implicitly treated as a required parameter in /in/Za9kK on line 4 string(171) "Method [ <user> public method foo ] { @@ /in/Za9kK 4 - 4 - Parameters [2] { Parameter #0 [ <required> int $id ] Parameter #1 [ <required> string $str ] } } " string(180) "Method [ <user> public method bar ] { @@ /in/Za9kK 5 - 5 - Parameters [2] { Parameter #0 [ <optional> int $id = 1 ] Parameter #1 [ <optional> string $str = '' ] } } "

preferences:
28.77 ms | 1145 KiB | 10 Q