DEV Community

Discussion on: How PHP Type Declarations Actually Work

Collapse
 
robdwaller profile image
Rob Waller

Yes what the manual says is sort of right on parameter types. If you don't declare strict types then the calling code will fall back to type coercion and not impose the parameter types defined in the required file. But if it can't coerce to the defined parameter type the code will still fail.

I've updated the associated GitHub library to highlight this point. github.com/RobDWaller/type-declara...

The article itself though is still technically correct it's just it is focused on return types and the fact you can't trust what you receive from a method without strict types imposed. I should maybe have stressed this point more.

I agree though that PHP Types aren't ideal but do believe they still have value when used correctly, you just have to impose strict types everywhere. 😂