for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace micmania1\config\Transformer;
use ReflectionClass;
use ReflectionProperty;
class PrivateStaticTransformer implements TransformerInterface
{
/**
* @var array
*/
protected $classes = [];
* @var int
protected $sort = 0;
* @param array $classes
public function __construct(array $classes, $sort = 0)
$this->classes = $classes;
$this->sort = $sort;
}
* This loops through each class and fetches the private static config for each class.
public function transform()
$config = [];
foreach($this->classes as $class) {
$config = array_merge($this->getClassConfig($class), $config);
return [$this->sort => $config];
* This is responsible for introspecting a given class and returning an
* array continaing all of its private statics
*
* @param string $class
* @return string[]
protected function getClassConfig($class)
// Autoload the class if it exists
if(!class_exists($class)) {
return [];
/** @var \ReflectionProperty[] **/
$props = (new ReflectionClass($class))
->getProperties(ReflectionProperty::IS_STATIC | ReflectionProperty::IS_PRIVATE);
$classConfig = [];
foreach($props as $prop) {
$prop->setAccessible(true);
$classConfig[$prop->getName()] = $prop->getValue();
return $classConfig;