Bug #69228 [Com]: late-static-bindings can not check self-property or static-property

[email protected] ("inefedor at gmail dot com")
Newsgroups php.standards
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=69228&edit=1

 ID:                 69228
 Comment by:         inefedor at gmail dot com
 Reported by:        gpgkd906 at gmail dot com
 Summary:            late-static-bindings can not check self-property or
                     static-property
 Status:             Open
 Type:               Bug
 Package:            PHP Language Specification
 Operating System:   win8
 PHP Version:        5.6.6
 Block user comment: N
 Private report:     N

 New Comment:

This is expected behavior, $set wasn't changed at the moment of calling app2::add() hence you get bool(true) because both app::$set and app2::$set are empty arrays (note that array comparison semantics with `===` are not the same as for objects).


Previous Comments:
------------------------------------------------------------------------
[2015-03-12 07:51:38] gpgkd906 at gmail dot com

Description:
------------
---
From manual page: http://www.php.net/language.oop5.late-static-bindings
---

late-static-bindings is usually worked wonderful for me, bug when I try to find a property is defined by parent-class or child-class, I find it could not check the property is defined by self-class or static-class;


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

class app {

    static protected $set = [];

    static public function add($key)
    {
        var_dump(static::$set === self::$set);        
        static::$set[] = $key;
        var_dump(self::$set);
    }

    static public function get()
    {
        return static::$set;
    }
}

class app2 extends app {
    static protected $set = [];
}

class app3 extends app {
    static protected $set = [];    
}


app2::add("app2");

var_dump(app3::get());

Expected result:
----------------
bool(false)
array(0) {
}
array(0) {
}

Actual result:
--------------
bool(true)
array(0) {
}
array(0) {
}


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



--
Edit this bug report at https://bugs.php.net/bug.php?id=69228&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.