3 ms·
I'm not a fan of the void argument syntax. Wouldn't something like the code below work? We already do it with `strict_types=1`. <?php declare(strict_args=1);
by mklepaczewski 2y ago
I'm not a fan of the void argument syntax. Wouldn't something like the code below work? We already do it with `strict_types=1`.
<?php
declare(strict_args=1);
- tored 2y agoMark the function with an attribute to allow the old behavior. See link for similar use case. https://www.php.net/manual/en/class.allowdynamicproperties.php https://www.php.net/manual/en/class.allowdynamicproperties.p...
- mklepaczewski 2y agoYup, that's even better.
- p4bl0 2y agoThat's equivalent to my initial proposal, except that mine adds the information in the type signature of the function rather than in a decorator.
- tored 2y agoIf I understood your proposal correctly, to get the new behavior add an explicit stop to the function, my proposal add attribute to keep old behavior. Thus if understanding this right that would require to update every function signature to new behavior rather than marking a few functions to get the old behavior and automatically get the new better behavior of every other function for free.
- p4bl0 2y agoOh okay, you would do it in reverse. I strongly agree with that. But that means the new feature is opt-out rather than opt-in, and it may break some old code. Maybe it should be done in two-steps (opt-in + deprecation, then opt-out).
- tored 2y agoTypically you emit E_DEPRECATED for a full major version, then in the next major version you throw an error, e.g if it would land in PHP 9.0 then E_DEPRECATED for non-compliant functions and in PHP 10.0 start throwing errors.