On 09/12/2021 05:22, André Hänsel wrote:
If I try the same thing in PHP 8.0 I get a Deprecated warning and if I try
it in PHP 8.1 I get something that I don't understand:
https://3v4l.org/cg4DA


There are two diagnostics showing in 8.1, the deprecation on the declaration, and a fatal error on the call.

What's happened is that given your signature:

> function blah($foo = "deffoo", $bar) { ... }

PHP has decided it doesn't make sense, and re-interpreted it as this:

> function blah($foo, $bar) { ... }

Then when you try to call it:

> blah(bar: "1");

You're missing the now-mandatory parameter $foo, so you get a fatal error.


I'm not sure exactly why this behaviour has changed, and can't see any mention in the Release or Migration pages in the manual. It's not a *huge* break, because named params have only existed since 8.0, but it is technically a breaking change in a minor version.

The only relevant discussion I've found is this, where Nikita is I think hinting at the new behaviour: https://externals.io/message/114007#114026


Regards,

--
Rowan Tommins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to