Re: Apply strict_types to internal functions
| From: | Saki Takamachi | Date: | Wed, 30 Aug 2023 10:13:39 +0000 |
| Subject: | Re: Apply strict_types to internal functions | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120957@lists.php.net to get a copy of this message | ||
I accidentally wrote the name in Japanese and it looks weird, so I'll resend it, sorry.
I also skimmed over past discussions.
I've found that having full control over
strict_types globally is not a good idea.
This is because it can break the behavior of many libraries, and developers don't always
respond appropriately to this fix.
So I came up with the following idea.
Allows a new value of 2 for strict_types.
However, since magic numbers make the code difficult to read, I thought it would be a good idea to
also provide strings that can serve as constants and aliases.
This could provide new options to users while safely maintaining backwards compatibility.
example:
```
// weak
declare(strict_types=0);
declare(strict_types='weak');
declare(strict_types=STRICT_TYPE_MODE_WEAK);
// strict
declare(strict_types=1);
declare(strict_types='strict');
declare(strict_types=STRICT_TYPE_MODE_STRICT);
// strict with internal func
declare(strict_types=2);
declare(strict_types='strict_with_internal_func');
declare(strict_types=STRICT_TYPE_MODE_WITH_INTERNAL_FUNC);
```
I need more time to come up with a better name.
Saki