Re: Does Scope-Resolution Operator Always Follow 'parent'?
| From: | David Harkness | Date: | Mon, 11 Mar 2013 17:18:41 +0000 |
| Subject: | Re: Does Scope-Resolution Operator Always Follow 'parent'? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-320464@lists.php.net to get a copy of this message | ||
Hi Eric,
On Sun, Mar 10, 2013 at 8:21 PM, Eric James Michael Ritz <
lobbyjones@gmail.com> wrote:
> I have a question about the
parent keyword: is there any valid
> situation where it can appear without the :: operator
> following?
>
I wouldn't have thought it possible, but I just found one case with PHP 5.4
where it can appear as the keyword without a trailing "::". Apparently you
can use it to instantiate the parent class just as you can with "new self".
class Foo { }
class Bar extends Foo {
public function foo() {
return new parent;
}
}
I think you'll be safe if you can highlight it only when preceded by "new"
or followed by "::".
David