Closed linjialiang closed 5 years ago
Now that I can only disable these three features, the PHP framework looks normal
@Gert-dev
Scalar types can not be aliased in PHP 7. An integer must be declared with int
. PHP 7 will interpret integer
as a class or interface name. [1.]
Docblockr is at fault here for not following the PHP spec. You can change this behavior in Docblockr by setting short_primitives = true
[2.]
Here is some code that tests the differences between int and integer. https://ideone.com/sxDV1o
All right, docblockr is a relatively simple change to a single code, mainly because PHP framework annotations are integer
There was an issue about this long ago on Docblockr's repo. https://github.com/nikhilkalige/docblockr/issues/153
Just set short_primitives = true
and then you don't have to worry about anymore.
I don't know which PHP framework you are talking about. If they are using integer
then they are wrong. All annotations and type hints should use the short forms; bool, int, and float. Everything else is invalid and will only cause problems.
Even PHP itself is wrong. The error message Argument 1 passed to Thing::doStuffWithInteger() must be an instance of integer, integer given
should be Argument 1 passed to Thing::doStuffWithInteger() must be an instance of integer, int given
. Nobody has gotten around to implementing the correct semantics in the PHP interpreter. The phrase must be an instance of integer, integer given
is just too confusing.
Ok, I will give feedback to the framework author
@linjialiang I've also replied in #454, please don't create duplicate issues, though.
@infomaniac50 is right: integer
is a name that predates PHP 7 type hints and should probably be avoided in new code. Thanks for following this up for me, by the way!