src/ReflectionTrait.php
protected function getProperties(&$object, $filter = 256 | 512 | 1024)
    {
        $properties = (new ReflectionClass($object))->getProperties($filter);

        //Removes properties added by PHPUnit, if the object is a mock
        $properties = $object instanceof MockObject ? array_filter($properties, function ($property) {
            return !string_starts_with($property->getName(), '__phpunit');
        }) : $properties;

        $values = array_map(function ($property) use ($object) {
            $property->setAccessible(true);

            return $property->getValue($object);
        }, $properties);

        return array_combine(objects_map($properties, 'getName'), $values);
    }
protected function getProperties(&$object, $filter = 256 | 512 | 1024)
    {
        $properties = (new ReflectionClass($object))->getProperties($filter);

        //Removes properties added by PHPUnit, if the object is a mock
        $properties = $object instanceof MockObject ? array_filter($properties, function ($property) {
            return !string_starts_with($property->getName(), '__phpunit');
        }) : $properties;

        $values = array_map(function ($property) use ($object) {
            $property->setAccessible(true);

            return $property->getValue($object);
        }, $properties);

        return array_combine(objects_map($properties, 'getName'), $values);
    }
protected function getProperties ( & $ object , $ filter = 256 | 512 | 1024 ) { $ properties = ( new ReflectionClass ( $ object ) ) -> getProperties ( $ filter ) ; //Removes properties added by PHPUnit, if the object is a mock $ properties = $ object instanceof MockObject ? array_filter ( $ properties , function ( $ property ) { return ! string_starts_with ( $ property -> getName ( ) , '__phpunit' ) ; } ) : $ properties ; $ values = array_map ( function ( $ property ) use ( $ object ) { $ property -> setAccessible ( true ) ; return $ property -> getValue ( $ object ) ; } , $ properties ) ; return array_combine ( objects_map ( $ properties , 'getName' ) , $ values ) ; }
Gets all properties as array with property names as keys.

If the object is a mock, it removes the properties added by PHPUnit.
@param object $object Object from which to get properties
@param int $filter The optional filter, for filtering desired property
types. It's configured using `ReflectionProperty` constants, and
default is public, protected and private properties
@return array Property names as keys and property values as values
@link http://php.net/manual/en/class.reflectionproperty.php#reflectionproperty.constants.modifiers
@since 1.1.4
Gets all properties as array with property names as keys .