Created
November 28, 2017 12:14
-
-
Save vertexvaar/7471c7a188b9cea96a6754b0af735829 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Accessor | |
{ | |
public static function getLinkedStaticPropertyIterator($class, $property): \Iterator | |
{ | |
return (\Closure::bind( | |
function () use ($class, $property) { | |
foreach ($class::${$property} as $logger) { | |
yield $logger; | |
} | |
}, | |
null, | |
$class | |
))(); | |
} | |
public static function getStaticProperty($class, $property) | |
{ | |
return (\Closure::bind( | |
function () use ($class, $property) { | |
return $class::${$property}; | |
}, | |
null, | |
$class | |
))(); | |
} | |
public static function &getLinkableStaticProperty($class, $property) | |
{ | |
$props = &(\Closure::bind( | |
function &() use ($class, $property) { | |
$props = &$class::${$property}; | |
return $props; | |
}, | |
null, | |
$class | |
))(); | |
return $props; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment