-
-
Notifications
You must be signed in to change notification settings - Fork 946
Description
Feature request
PHP's built in functions/interfaces are out of control of developers control and they can not be typehinted always as PHPStan would like. Since they are built in PHP and already known, PHPStan could automatically detect them and assign them the proper signature/return type.
Notable examples are the Countable, Serializable or ArrayAccess interface.
Those interfaces do not allow typed signatures.
See https://phpstan.org/r/dfc30878-f677-438c-81a7-fb7878c1d6ea
A possible solution is to add dockblocks as in https://phpstan.org/r/06340f55-9d3c-4f37-8c5f-b20b08dea869 ... but this feels as asking the user to do extra work just for the sake of it.
But since they are know... as example:
count()should always return an integer.serialize()should always return a stringunserialzie()accepts a string and is void
__toString on the other hand works nice
ArrayAccess interfaces are a bit more tricky, but keys are always scalars..