Re: [PHP] Does Scope-Resolution Operator Always Follow 'parent'?
[email protected] (David Harkness)
| Newsgroups | php.general |
|---|---|
| Message-ID | <CAO8qQLnvNw39wySVgcc1BnN2BqKRCqb7wSWrfex4MGZW2PLyQQ@mail.gmail.com> |
Hi Eric, On Sun, Mar 10, 2013 at 8:21 PM, Eric James Michael Ritz < [email protected]> 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