News for hackers. Stuff that matters.
Re:What I Like About PHP by claar on Tuesday December 09, 2014 @07:56PM (#8726972)
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.
Re:What I Like About PHP by wyager on Tuesday December 09, 2014 @08:13PM (#8727062)
>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).

Re:What I Like About PHP by Shish2k on Tuesday December 09, 2014 @09:00PM (#8727260)
> 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
Re:What I Like About PHP by Dewie on Tuesday December 09, 2014 @08:11PM (#8727050)
> 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)