From: michaelduff2 at yahoo dot com
Operating system:
PHP version: Irrelevant
Package: *General Issues
Bug Type: Feature/Change Request
Bug description:Moar magic methods! __constructStatic(), __getStatic(),
__setStatic(), __get
Description:
------------
__constructStatic() - executed automatically on class definition
__getStatic() - executed when ClassName::$inaccessible_property is fetched
__setStatic() - executed when ClassName::$inaccessible_property is
modified
The particular use case I have for this is self-loading configuration
registry singletons:
<?php7
namespace Company;
class Config
{
protected static $settings;
function __constructStatic($property)
{
static::$settings = parse_ini_file('config.ini');
}
function __getStatic($property)
{
return static::$settings[$property];
}
}
echo Config::$DB_USER;
?>
Currently, I accomplish this with __callStatic() which needs the extra
open-close parenthesis. Ideally, we could get rid of the '$' too, but that
would need some __getConst() magic, which is just madness.
--
Edit bug report at https://bugs.php.net/bug.php?id=62860&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=62860&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=62860&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=62860&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=62860&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=62860&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=62860&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=62860&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=62860&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=62860&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=62860&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=62860&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=62860&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=62860&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=62860&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=62860&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62860&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=62860&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=62860&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=62860&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=62860&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=62860&r=mysqlcfg