php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69228 late-static-bindings can not check self-property or static-property
Submitted: 2015-03-12 07:51 UTC Modified: 2015-03-22 04:22 UTC
From: gpgkd906 at gmail dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.6.6 OS: win8
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gpgkd906 at gmail dot com
New email:
PHP Version: OS:

 

 [2015-03-12 07:51 UTC] 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) {
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-12 08:51 UTC] inefedor at gmail dot com
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).
 [2015-03-12 09:49 UTC] requinix@php.net
-Status: Open +Status: Feedback -Package: PHP Language Specification +Package: Scripting Engine problem
 [2015-03-12 09:49 UTC] requinix@php.net
@gpgkd906, I feel like you're trying to report a different bug than the one @inefedor just correctly explained away. Maybe your repro script isn't completely accurate?
 [2015-03-22 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 02 10:01:30 2024 UTC