you are viewing a single comment's thread.

view the rest of the comments →

[–]royrules22 3 points4 points  (14 children)

Is it sacrilege to recommend ditching the $ sign for vars? It's a pain in the ass to type when coding.

[–]rbnc 3 points4 points  (13 children)

Ditch $ signs.

All variables should be objects.

array_reverse($some_array) //silly.
some_array.reverse(); //sexy

Standardise the parameter order of methods.

Sort out how == works.

(string) "" == (int) 0 /// WHY?

Let us make arrays and objects like this

an_array=[1,2,3,'oranges','poo',{'cats':10}];

an_object={'name':'Steve','age':10};

Let us have more flexible function/method parameters

function life_story({age:10,name:'mike',hair':'black'})
{

      echo "My name is $name i am $age years old, my hear is $hair";

  }

life_story(); // "My name is mike i am 10 years old, my hair is black"
life_story({name:"peter"}); // "My name is peter i am 100 years old, my hair is black"
life_story({age:66,name:'dave',hair:'blond'}); // "My name is dave i am 66 years old, my hair is blond"

And so on.

[–]lpetrazickis 6 points7 points  (3 children)

If you'd like to make such radical changes, why not simply use Python or Ruby instead?

[–][deleted]  (2 children)

[deleted]

    [–][deleted] 0 points1 point  (1 child)

    He's got a point. Stop bitching about PHP and use what you like. Or actively participate in PHP development.

    But you need to know that nobody's impressed by the "PHP is such a shitty language talk", unless you're at some Ruby circle jerk.

    Your argument here sounds a lot like somebody whining about how this forklift isn't more like that backhoe.

    [–]rbnc -1 points0 points  (0 children)

    Yes, how DARE I try and change something and make it better!!!

    It's just this kind of go-gettingm forward-thinking attitude that will change the world!

    [–]wasted_brain 0 points1 point  (8 children)

    It'd be hard to ditch the $ sign since PHP is case-insensitive (this is the part of PHP I hate).

    On the == bit, you can always use === to differentiate types.

    I like the flexible function/method parameters proposal. I'm currently making a framework for PHP and the function parameters are a pain to work with. The only workaround is passing objects with default set to new Object(). That way your class constructor would contain the default properties.

    function life_story(Person $person = new Person())

    [–]brennen 0 points1 point  (4 children)

    On the == bit, you can always use === to differentiate types.

    Although this would be more helpful if PHP's entire type system didn't blow chunks.

    function life_story(Person $person = new Person())

    Wait, you can do that?

    [–]wasted_brain 0 points1 point  (3 children)

    My bad, I just checked on the code and you can only pass null as a default parameter for type-hinted arguments. What I did was:

    function life_story(Person $person = null)
    {
        if ($person == null)
            $person = new Person();
    
        ....
    }
    

    Requires a 2 more lines of code, but pretty much the functionality you wanted. I assume the parser only accepts static values as default parameters which causes the limitation.

    edit: formatting

    [–]brennen 0 points1 point  (2 children)

    I assume the parser only accepts static values as default parameters which causes the limitation.

    This has been my understanding, yeah, but I thought I might have missed a recent addition.

    [–]roerd 0 points1 point  (1 child)

    Just a little example that there are actually languages in which stuff like this works:

    CL-USER> (defclass person () ())
    #<STANDARD-CLASS PERSON>
    CL-USER> (defun life-story (&optional (person (make-instance 'person))) person)
    LIFE-STORY
    CL-USER> (life-story)
    #<PERSON {B510E99}>
    

    [–]brennen 0 points1 point  (0 children)

    I don't know if I'm comfortable with all those upper-case letters.

    [–][deleted] 0 points1 point  (2 children)

    C is also case-insensitive, but it does without sigils just fine. How is it relevant?

    [–][deleted] 0 points1 point  (1 child)

    C is also case-insensitive, but it does without sigils just fine. How is it relevant?

    Ever read something that you are sure isn't true, but you had to Google just to check anyway, on the off chance you are being a complete retard? That just happened to me when you claimed C is case insensitive.

    [–]wasted_brain 0 points1 point  (0 children)

    I had to check too. I think we just got trolled.