Req #67347 [Opn]: Access to static class properties inconsistent

From: Date: Tue, 27 May 2014 19:45:40 +0000
Subject: Req #67347 [Opn]: Access to static class properties inconsistent
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185939@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67347&edit=1

 ID:                 67347
 User updated by:    fleshgrinder at gmx dot at
 Reported by:        fleshgrinder at gmx dot at
 Summary:            Access to static class properties inconsistent
 Status:             Open
 Type:               Feature/Change Request
 Package:            *General Issues
 Operating System:   Debian Wheezy
 PHP Version:        5.6.0beta3
 Block user comment: N
 Private report:     N

 New Comment:

Note that the following works:

$bar = new Bar();
$foo = $bar->foo;
echo $foo::$foo;  // Prints 'foo'


Previous Comments:
------------------------------------------------------------------------
[2014-05-27 19:42:53] fleshgrinder at gmx dot at

Description:
------------
Accessing static properties is inconsistent and doesn't make much sense.

Test script:
---------------
class Foo {

  public static $foo = "foo";

}

class Bar {

  public $foo;

  public function __construct() {
    $this->foo = new Foo();
  }

}


Expected result:
----------------
Either $foo::$foo to result in some kind of ERROR or WARNING or $bar->foo::$foo has to work as
well. Otherwise it's not consistent.

Actual result:
--------------
$foo = new Foo();

echo $foo::$foo; // Works and prints 'foo'
echo $foo->foo;  // STRICT WARNING
echo $foo->$foo; // FATAL ERROR

$bar = new Bar();

echo $bar->foo::$foo; // PARSE ERROR
echo $bar->foo->foo;  // STRICT WARNING
echo $bar->foo->$foo; // FATAL ERROR


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



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


Thread (4 messages)

« previous php.bugs (#185939) next »