Re: Does Scope-Resolution Operator Always Follow 'parent'?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Eric,

On Sun, Mar 10, 2013 at 8:21 PM, Eric James Michael Ritz <
lobbyjones@xxxxxxxxx> 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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux