Re: Dropping requirement for `function` keyword for methods in classes/interfaces/etc
| From: | Nikita Nefedov | Date: | Wed, 20 Feb 2013 12:24:18 +0000 |
| Subject: | Re: Dropping requirement for `function` keyword for methods in classes/interfaces/etc | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-66025@lists.php.net to get a copy of this message | ||
On Wed, 20 Feb 2013 08:02:36 -0000, Sanford Whiteman <swhitemanlistens-software@cypressintegrated.com> wrote:
While I'm thinking about this (though I should leave it alone): who's
to say that PHP won't some day get inner classes? By deciding the
"default" inner member of a class will be a function, you're choosing
the one that has a global/procedural equivalent where the short syntax
won't work, instead of leaving the concept unused for the possible
future when:
class myClass {
mySomething { // is equivalent to class mySomething {
(Yes, you could say mySomething(...) { } is a public function and
mySomething { } is an innner class, but you get the idea.)
-- S.
Classes always should be declared with class keyword, because there could be ambiguity whether it's class, interface or trait.
Also, I will say it again: as Sara noted, we *really* shouldn't let users define methods without any modifiers, like this: class Foo { asd() { echo "this is parse error"; } }