2011-06-08 13 views
14

Todos los objetos en la jerarquía Reflection de PHP tienen un método de exportación estático. Puede usar esto para obtener una representación de cadena de una clase. Código algo como estoFormato de clase de reflexión exportada en PHP?

$c = new ReflectionClass('Mage_Core_Model_Abstract'); 
ReflectionClass::export($c) 

se hará eco de la siguiente vuelta

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] { 
     } 
    } 
    } 
} 

¿Qué es este formato? ¿Es solo algo arbitrario desarrollado por el equipo interno de PHP, o es este un formato conocido que puede ser analizado por otras herramientas de programación bien conocidas?

Para aclarar, sé qué es el reflejo y cómo usarlo. Lo que me interesa es este formato de "exportación", que parece diseñado deliberadamente pero NO es válido para PHP. ¿Es un formato estándar de CS/programación de algún tipo, o simplemente algo único para PHP?

+2

No tengo ni idea, pero mi apuesta sería que es un formato de salida interno. Al menos no esperaría la salida en un formato estandarizado, ya que 'export' es un método' abstracto' para la interfaz 'Reflector'. Pero tal vez solo soy yo ^^ –

+1

Estoy de acuerdo con Jurgen, no parece un formato estandarizado. Es cómo el equipo básico de PHP imagina un formato legible fácil de usar. –

Respuesta

2

Este formato es una representación de cómo el motor Zend tiene la clase almacenada una vez que la ha analizado, tiene la certeza de que no es PHP válida.