Every Object in PHP's Reflection hierarchy has a static export method. You can can use this to get a string representation of a class. Code something like this
$c = new ReflectionClass('Mage_Core_Model_Abstract');
ReflectionClass::export($c)
will echo the following back
Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
- Constants [3] {
Constant [ integer IS_IMPLICIT_ABSTRACT ] { 16 }
Constant [ integer IS_EXPLICIT_ABSTRACT ] { 32 }
Constant [ integer IS_FINAL ] { 64 }
}
- Static properties [0] {
}
- Static methods [1] {
Method [ <internal:Reflection> static public method export ] {
- Parameters [2] {
Parameter #0 [ <required> $argument ]
Parameter #1 [ <optional> $return ]
}
}
}
- Properties [1] {
Property [ <default> public $name ]
}
- Methods [43] {
Method [ <internal:Reflection> final private method __clone ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection, ctor> public method __construct ] {
- Parameters [1] {
Parameter #0 [ <required> $argument ]
}
}
Method [ <internal:Reflection> public method __toString ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method getName ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method isInternal ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method isUserDefined ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method isInstantiable ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method getFileName ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method getStartLine ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method getEndLine ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method getDocComment ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method getConstructor ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method hasMethod ] {
- Parameters [1] {
Parameter #0 [ <required> $name ]
}
}
Method [ <internal:Reflection> public method getMethod ] {
- Parameters [1] {
Parameter #0 [ <required> $name ]
}
}
Method [ <internal:Reflection> public method getMethods ] {
- Parameters [1] {
Parameter #0 [ <optional> $filter ]
}
}
Method [ <internal:Reflection> public method hasProperty ] {
- Parameters [1] {
Parameter #0 [ <required> $name ]
}
}
Method [ <internal:Reflection> public method getProperty ] {
- Parameters [1] {
Parameter #0 [ <required> $name ]
}
}
Method [ <internal:Reflection> public method getProperties ] {
- Parameters [1] {
Parameter #0 [ <optional> $filter ]
}
}
Method [ <internal:Reflection> public method hasConstant ] {
- Parameters [1] {
Parameter #0 [ <required> $name ]
}
}
Method [ <internal:Reflection> public method getConstants ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method getConstant ] {
- Parameters [1] {
Parameter #0 [ <required> $name ]
}
}
Method [ <internal:Reflection> public method getInterfaces ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method getInterfaceNames ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method isInterface ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method isAbstract ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method isFinal ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method getModifiers ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method isInstance ] {
- Parameters [1] {
Parameter #0 [ <required> $object ]
}
}
Method [ <internal:Reflection> public method newInstance ] {
- Parameters [1] {
Parameter #0 [ <required> $args ]
}
}
Method [ <internal:Reflection> public method newInstanceArgs ] {
- Parameters [1] {
Parameter #0 [ <optional> array $args ]
}
}
Method [ <internal:Reflection> public method getParentClass ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method isSubclassOf ] {
- Parameters [1] {
Parameter #0 [ <required> $class ]
}
}
Method [ <internal:Reflection> public method getStaticProperties ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method getStaticPropertyValue ] {
- Parameters [2] {
Parameter #0 [ <required> $name ]
Parameter #1 [ <optional> $default ]
}
}
Method [ <internal:Reflection> public method setStaticPropertyValue ] {
- Parameters [2] {
Parameter #0 [ <required> $name ]
Parameter #1 [ <required> $value ]
}
}
Method [ <internal:Reflection> public method getDefaultProperties ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method isIterateable ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method implementsInterface ] {
- Parameters [1] {
Parameter #0 [ <required> $interface ]
}
}
Method [ <internal:Reflection> public method getExtension ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method getExtensionName ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method inNamespace ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method getNamespaceName ] {
- Parameters [0] {
}
}
Method [ <internal:Reflection> public method getShortName ] {
- Parameters [0] {
}
}
}
}
What is this format? If is just something arbitrary developed by the internal PHP team, or is this a known format that can be parsed by other well known programming tools?
To clarify, I know what reflection is and how to use it. What I'm curious about is this "export" format, which appears deliberately designed but is NOT valid PHP. Is it a standard CS/programming format of some kind, or just something one off for PHP?
The ReflectionClass::getProperties() function is an inbuilt function in PHP which is used to return an array of the reflected properties. Syntax: ReflectionClass::getProperties($filter) : array. Parameters: This function accepts a parameter filter which helps to remove some of the reflected properties.
The term “reflection” in software development means that a program knows its own structure at runtime and can also modify it. This capability is also referred to as “introspection”. In the PHP area, reflection is used to ensure type safety in the program code.
The Reflection::getShortName() function is an inbuilt function in PHP which is used to return the short name of the specified class, the part without the namespace.
This format is a representation of how the Zend engine has the class stored once it has parsed it, you are correct that it is not valid PHP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With