Req #62860 [Com]: Moar magic methods! __constructStatic(), __getStatic(), __setStatic(), __get
| From: | levim@php.net | Date: | Thu, 08 May 2014 18:04:46 +0000 |
| Subject: | Req #62860 [Com]: Moar magic methods! __constructStatic(), __getStatic(), __setStatic(), __get | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185728@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62860&edit=1
ID: 62860
Comment by: levim@php.net
Reported by: michaelduff2 at yahoo dot com
Summary: Moar magic methods! __constructStatic(),
__getStatic(), __setStatic(), __get
Status: Open
Type: Feature/Change Request
Package: *General Issues
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
This is at least related to bug 45002.
Previous Comments:
------------------------------------------------------------------------
[2012-09-12 03:35:35] laruence@php.net
<GoogleGuy> The fact that his code defies the point of using magic getters and
setters should have been a hint.
<GoogleGuy> __get and __set are meant for inaccessible variables.
------------------------------------------------------------------------
[2012-09-12 02:52:03] laruence@php.net
they are not dup...
------------------------------------------------------------------------
[2012-09-12 02:41:08] reeze@php.net
Duplicate to https://bugs.php.net/bug.php?id=45002 closed.
------------------------------------------------------------------------
[2012-09-05 15:12:01] matthew dot bonner at gmail dot com
Sorry in my last example there was a typo, and what I meant was:
I would like to add that being magic methods, it would be nice if they could do a little more magic,
ie:
class Classy {
public static $foo = 'foo';
public $bar = 'bar';
public static function __get ($propertyName) {
return self::$propertyName;
}
public function __get ($propertyName) {
return $this->$propertyName;
}
}
echo Classy::$foo; // outputs "foo"
$classy = new Classy;
echo $classy->bar; // outputs "bar"
------------------------------------------------------------------------
[2012-09-05 15:10:36] matthew dot bonner at gmail dot com
I would like to add that being magic methods, it would be nice if they could do a little more magic,
ie:
class Classy {
public static $foo = 'foo';
public $bar = 'bar';
public static function __get ($propertyName) {
return $this->$propertyName;
}
public function __get ($propertyName) {
return self::$propertyName;
}
}
echo Classy::$foo; // outputs "foo"
$classy = new Classy;
echo $classy->bar; // outputs "bar"
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=62860
--
Edit this bug report at https://bugs.php.net/bug.php?id=62860&edit=1