>If something other than an Auth\Role object is passed in, a runtime exception occurs.
This is not impressive. Even most popular super-weakly-typed languages support runtime exceptions for type errors.
>Better yet, PhpStorm will check the types in real-time and underline type errors immediately.
This feature is frequently called "static typing". Many languages have this (and not just as some IDE extension).
> One of my favorite features is type enforcement
... that's a feature that pretty much every other language either already has (and does better), or explicitly does something different (but better) :S
Specifically, every other langage that I know of with type checking support has type checking for classes and primitives. PHP, not so much:
function test(integer $z) {
print $z + 1;
}
test(42);
PHP Catchable fatal error: Argument 1 passed to test()
must be an instance of integer, integer given> If something other than an Auth\Role object is passed in, a runtime exception occurs.
I think that would be called strong typing (as opposed to type enforcement).
Re:What I Like About PHP
by arenaninja on Tuesday December 09, 2014 @08:16PM
(#8727087)
I think they called it type checking when it was introduced, I would wager to avoid it being confused with strong typing because in PHP you cannot typecheck primitives (as of 5.6)
Using JetBrain's PhpStorm with a proper framework is simply not the PHP of 10 years ago.
One of my favorite features is type enforcement; consider the following code:
If something other than an Auth\Role object is passed in, a runtime exception occurs. Better yet, PhpStorm will check the types in real-time and underline type errors immediately.