Bug #70997 [Opn->Csd]: When using parentClass:: instead of parent::, static context changed.

From: Date: Mon, 30 Nov 2015 13:54:52 +0000
Subject: Bug #70997 [Opn->Csd]: When using parentClass:: instead of parent::, static context changed.
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-12895@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70997&edit=1

 ID:                 70997
 Updated by:         dmitry@php.net
 Reported by:        arjen at parse dot nl
 Summary:            When using parentClass:: instead of parent::, static
                     context changed.
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            Documentation problem
 Operating System:   Linux
 PHP Version:        7.0.0RC8
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=25c5d185fcece7620f4b1790fd705999757f3b2f
Log: Fixed bug #70997 (When using parentClass:: instead of parent::, static context changed)


Previous Comments:
------------------------------------------------------------------------
[2015-11-30 10:51:17] laruence@php.net

I think this is not a bug, but a improvement, as you already call explicit A::test, which means, you
are expecting A's scope ..

so, change to document problem.

thanks

------------------------------------------------------------------------
[2015-11-30 09:29:17] arjen at parse dot nl

Description:
------------
Compared to 5.x. Behaviour of LSB (?) changed, bug or not documented?
I cannot find anything about this subtle change in the 7.0 migration guide
(http://php.net/manual/en/migration70.incompatible.php) nor in the 7.0 NEWS file.

See https://3v4l.org/edVna

I know it's easy to fix in the codebase, but it would be nice if this changed is documented
when intended or original behavior restored.

Test script:
---------------
<?php

class A {
    const TEST = false;
    
    public function test()
    {
        var_dump(static::TEST);
    }
}

class B extends A {
    const TEST = true;
    
    public function test()
    {
        A::test();
    }
}

$b = new B;
$b->test();

Expected result:
----------------
bool(true)

Actual result:
--------------
bool(false)


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70997&edit=1


Thread (2 messages)

« previous php.doc.bugs (#12895) next »