2021-06-28 22:04 GMT+02:00, Rowan Tommins <rowan.coll...@gmail.com>: > On 28/06/2021 20:25, Olle Härstedt wrote: >> Usage (ignoring the pesky undefined constant warnings ><): > > > Unfortunately, you can't ignore those warnings; not least because > they're fatal errors in PHP 8, as they frankly should have been in PHP 3. > > You can use our current ugly callable syntax (strings and two-element > arrays); you can tackle the complexity of unifying functions with > constants, and methods with properties (as Levi explained in the other > thread); or you can add a dedicated callable syntax, which the PFA > proposal gets us with bells on.
Sorry for hijacking the thread, but are there no other alternatives, really? Just brainstorming: 1) Setting to silence the warning. Probably frowned upon, AND requires that functions/methods are case sensitive, which they are not right now. BUT, constants are always case sensitive since 7.3, so the risk of collision is not that high...? Assuming constants are by convention always UPPER_CASE, and functions either snake_case or camelCase. You can argue that the setting together with a CI to check cases would be reasonably safe. 2) Setting to silence the warning IF and only if argument expects a callable, like in array_map (won't work with a pipe() function, though, since pipe() would take any number of arguments and that can't be typed) 3) Silence the warning if you type-case explicitly, like in `pipe($start, (callable) htmlentities);`. Another alternative is `(fn)` as a type-cast. Not much better than `pipe($start, htmlentities(?))`, I guess. Just different style. 4) Silence the warning ONLY when it's the right-hand argument to pipe operator, like `$start |> str_len`. All stupid? -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php