4 ms·
Most people complaining about PHP haven't actually used it in an enterprise environment. Using JetBrain's PhpStorm with a proper framework is simply not the PH
by claar 12y ago
Most people complaining about PHP haven't actually used it in an enterprise environment.
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:
class User {
function is(\Auth\Role $role) {}
}
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.
- Dewie 12y ago> 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).
- arenaninja 12y agoI 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)
- wyager 12y ago>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).
- Shish2k 12y ago> 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