ReflectionExtractor
in package
implements
PropertyListExtractorInterface, PropertyTypeExtractorInterface, PropertyAccessExtractorInterface, PropertyInitializableExtractorInterface, PropertyReadInfoExtractorInterface, PropertyWriteInfoExtractorInterface, ConstructorArgumentTypeExtractorInterface
Extracts data using the reflection API.
Tags
Table of Contents
Interfaces
- PropertyListExtractorInterface
- Extracts the list of properties available for the given class.
- PropertyTypeExtractorInterface
- Type Extractor Interface.
- PropertyAccessExtractorInterface
- Guesses if the property can be accessed or mutated.
- PropertyInitializableExtractorInterface
- Guesses if the property can be initialized through the constructor.
- PropertyReadInfoExtractorInterface
- Extract read information for the property of a class.
- PropertyWriteInfoExtractorInterface
- Extract write information for the property of a class.
- ConstructorArgumentTypeExtractorInterface
Constants
- ALLOW_MAGIC_CALL = 1 << 2
- ALLOW_MAGIC_GET = 1 << 0
- ALLOW_MAGIC_SET = 1 << 1
- ALLOW_PRIVATE = 1
- ALLOW_PROTECTED = 2
- ALLOW_PUBLIC = 4
- DISALLOW_MAGIC_METHODS = 0
- MAP_TYPES = ['integer' => \Symfony\Component\PropertyInfo\Type::BUILTIN_TYPE_INT, 'boolean' => \Symfony\Component\PropertyInfo\Type::BUILTIN_TYPE_BOOL, 'double' => \Symfony\Component\PropertyInfo\Type::BUILTIN_TYPE_FLOAT]
Properties
- $accessorPrefixes : mixed
- $arrayMutatorPrefixes : mixed
- $arrayMutatorPrefixesFirst : mixed
- $arrayMutatorPrefixesLast : mixed
- $enableConstructorExtraction : mixed
- $inflector : mixed
- $magicMethodsFlags : mixed
- $methodReflectionFlags : mixed
- $mutatorPrefixes : mixed
- $propertyReflectionFlags : mixed
Methods
- __construct() : mixed
- getProperties() : array<string|int, string>|null
- Gets the list of properties available for the given class.
- getReadInfo() : PropertyReadInfo|null
- Get read information object for a given property of a class.
- getTypes() : array<string|int, Type>|null
- Gets types of a property.
- getTypesFromConstructor() : array<string|int, mixed>|null
- {@inheritdoc}
- getWriteInfo() : PropertyWriteInfo|null
- Get write information object for a given property of a class.
- isInitializable() : bool|null
- Is the property initializable? Returns true if a constructor's parameter matches the given property name.
- isReadable() : bool|null
- Is the property readable?
- isWritable() : bool|null
- Is the property writable?
- camelize() : string
- Camelizes a given string.
- extractFromAccessor() : array<string|int, Type>|null
- Tries to extract type information from accessors.
- extractFromConstructor() : array<string|int, Type>|null
- Tries to extract type information from constructor.
- extractFromMutator() : array<string|int, Type>|null
- extractFromPropertyDeclaration() : array<string|int, mixed>|null
- extractFromReflectionType() : array<string|int, mixed>
- findAdderAndRemover() : array<string|int, mixed>
- Searches for add and remove methods.
- getAccessorMethod() : array<string|int, mixed>|null
- Gets the accessor method.
- getMethodsFlags() : int
- Return allowed reflection method flags.
- getMutatorMethod() : array<string|int, mixed>|null
- Returns an array with a the instance of \ReflectionMethod as first key and the prefix of the method as second or null if not found.
- getPropertyFlags() : int
- Return allowed reflection property flags.
- getPropertyName() : string|null
- getReadVisiblityForMethod() : string
- getReadVisiblityForProperty() : string
- getReflectionParameterFromConstructor() : ReflectionParameter|null
- getWriteVisiblityForMethod() : string
- getWriteVisiblityForProperty() : string
- isAllowedProperty() : bool
- isMethodAccessible() : array<string|int, mixed>
- Returns whether a method is public and has the number of required parameters and errors.
- isNullableProperty() : bool
- resolveTypeName() : string
Constants
ALLOW_MAGIC_CALL
public
int
ALLOW_MAGIC_CALL
= 1 << 2
Allow magic __call methods
ALLOW_MAGIC_GET
public
int
ALLOW_MAGIC_GET
= 1 << 0
Allow magic __get methods
ALLOW_MAGIC_SET
public
int
ALLOW_MAGIC_SET
= 1 << 1
Allow magic __set methods
ALLOW_PRIVATE
public
mixed
ALLOW_PRIVATE
= 1
ALLOW_PROTECTED
public
mixed
ALLOW_PROTECTED
= 2
ALLOW_PUBLIC
public
mixed
ALLOW_PUBLIC
= 4
DISALLOW_MAGIC_METHODS
public
int
DISALLOW_MAGIC_METHODS
= 0
Allow none of the magic methods
MAP_TYPES
private
mixed
MAP_TYPES
= ['integer' => \Symfony\Component\PropertyInfo\Type::BUILTIN_TYPE_INT, 'boolean' => \Symfony\Component\PropertyInfo\Type::BUILTIN_TYPE_BOOL, 'double' => \Symfony\Component\PropertyInfo\Type::BUILTIN_TYPE_FLOAT]
Properties
$accessorPrefixes
private
mixed
$accessorPrefixes
$arrayMutatorPrefixes
private
mixed
$arrayMutatorPrefixes
$arrayMutatorPrefixesFirst
private
mixed
$arrayMutatorPrefixesFirst
$arrayMutatorPrefixesLast
private
mixed
$arrayMutatorPrefixesLast
$enableConstructorExtraction
private
mixed
$enableConstructorExtraction
$inflector
private
mixed
$inflector
$magicMethodsFlags
private
mixed
$magicMethodsFlags
$methodReflectionFlags
private
mixed
$methodReflectionFlags
$mutatorPrefixes
private
mixed
$mutatorPrefixes
$propertyReflectionFlags
private
mixed
$propertyReflectionFlags
Methods
__construct()
public
__construct([array<string|int, string>|null $mutatorPrefixes = null ][, array<string|int, string>|null $accessorPrefixes = null ][, array<string|int, string>|null $arrayMutatorPrefixes = null ][, bool $enableConstructorExtraction = true ][, int $accessFlags = self::ALLOW_PUBLIC ][, InflectorInterface $inflector = null ][, int $magicMethodsFlags = self::ALLOW_MAGIC_GET | self::ALLOW_MAGIC_SET ]) : mixed
Parameters
- $mutatorPrefixes : array<string|int, string>|null = null
- $accessorPrefixes : array<string|int, string>|null = null
- $arrayMutatorPrefixes : array<string|int, string>|null = null
- $enableConstructorExtraction : bool = true
- $accessFlags : int = self::ALLOW_PUBLIC
- $inflector : InflectorInterface = null
- $magicMethodsFlags : int = self::ALLOW_MAGIC_GET | self::ALLOW_MAGIC_SET
getProperties()
Gets the list of properties available for the given class.
public
getProperties(string $class[, array<string|int, mixed> $context = [] ]) : array<string|int, string>|null
Parameters
- $class : string
- $context : array<string|int, mixed> = []
Return values
array<string|int, string>|nullgetReadInfo()
Get read information object for a given property of a class.
public
getReadInfo(string $class, string $property[, array<string|int, mixed> $context = [] ]) : PropertyReadInfo|null
Parameters
- $class : string
- $property : string
- $context : array<string|int, mixed> = []
Return values
PropertyReadInfo|nullgetTypes()
Gets types of a property.
public
getTypes(string $class, string $property[, array<string|int, mixed> $context = [] ]) : array<string|int, Type>|null
Parameters
- $class : string
- $property : string
- $context : array<string|int, mixed> = []
Return values
array<string|int, Type>|nullgetTypesFromConstructor()
{@inheritdoc}
public
getTypesFromConstructor(string $class, string $property) : array<string|int, mixed>|null
Parameters
- $class : string
- $property : string
Return values
array<string|int, mixed>|nullgetWriteInfo()
Get write information object for a given property of a class.
public
getWriteInfo(string $class, string $property[, array<string|int, mixed> $context = [] ]) : PropertyWriteInfo|null
Parameters
- $class : string
- $property : string
- $context : array<string|int, mixed> = []
Return values
PropertyWriteInfo|nullisInitializable()
Is the property initializable? Returns true if a constructor's parameter matches the given property name.
public
isInitializable(string $class, string $property[, array<string|int, mixed> $context = [] ]) : bool|null
Parameters
- $class : string
- $property : string
- $context : array<string|int, mixed> = []
Return values
bool|nullisReadable()
Is the property readable?
public
isReadable(string $class, string $property[, array<string|int, mixed> $context = [] ]) : bool|null
Parameters
- $class : string
- $property : string
- $context : array<string|int, mixed> = []
Return values
bool|nullisWritable()
Is the property writable?
public
isWritable(string $class, string $property[, array<string|int, mixed> $context = [] ]) : bool|null
Parameters
- $class : string
- $property : string
- $context : array<string|int, mixed> = []
Return values
bool|nullcamelize()
Camelizes a given string.
private
camelize(string $string) : string
Parameters
- $string : string
Return values
stringextractFromAccessor()
Tries to extract type information from accessors.
private
extractFromAccessor(string $class, string $property) : array<string|int, Type>|null
Parameters
- $class : string
- $property : string
Return values
array<string|int, Type>|nullextractFromConstructor()
Tries to extract type information from constructor.
private
extractFromConstructor(string $class, string $property) : array<string|int, Type>|null
Parameters
- $class : string
- $property : string
Return values
array<string|int, Type>|nullextractFromMutator()
private
extractFromMutator(string $class, string $property) : array<string|int, Type>|null
Parameters
- $class : string
- $property : string
Return values
array<string|int, Type>|nullextractFromPropertyDeclaration()
private
extractFromPropertyDeclaration(string $class, string $property) : array<string|int, mixed>|null
Parameters
- $class : string
- $property : string
Return values
array<string|int, mixed>|nullextractFromReflectionType()
private
extractFromReflectionType(ReflectionType $reflectionType, ReflectionClass $declaringClass) : array<string|int, mixed>
Parameters
- $reflectionType : ReflectionType
- $declaringClass : ReflectionClass
Return values
array<string|int, mixed>findAdderAndRemover()
Searches for add and remove methods.
private
findAdderAndRemover(ReflectionClass $reflClass, array<string|int, mixed> $singulars) : array<string|int, mixed>
Parameters
- $reflClass : ReflectionClass
-
The reflection class for the given object
- $singulars : array<string|int, mixed>
-
The singular form of the property name or null
Return values
array<string|int, mixed> —An array containing the adder and remover when found and errors
getAccessorMethod()
Gets the accessor method.
private
getAccessorMethod(string $class, string $property) : array<string|int, mixed>|null
Returns an array with a the instance of \ReflectionMethod as first key and the prefix of the method as second or null if not found.
Parameters
- $class : string
- $property : string
Return values
array<string|int, mixed>|nullgetMethodsFlags()
Return allowed reflection method flags.
private
getMethodsFlags(int $accessFlags) : int
Parameters
- $accessFlags : int
Return values
intgetMutatorMethod()
Returns an array with a the instance of \ReflectionMethod as first key and the prefix of the method as second or null if not found.
private
getMutatorMethod(string $class, string $property) : array<string|int, mixed>|null
Parameters
- $class : string
- $property : string
Return values
array<string|int, mixed>|nullgetPropertyFlags()
Return allowed reflection property flags.
private
getPropertyFlags(int $accessFlags) : int
Parameters
- $accessFlags : int
Return values
intgetPropertyName()
private
getPropertyName(string $methodName, array<string|int, mixed> $reflectionProperties) : string|null
Parameters
- $methodName : string
- $reflectionProperties : array<string|int, mixed>
Return values
string|nullgetReadVisiblityForMethod()
private
getReadVisiblityForMethod(ReflectionMethod $reflectionMethod) : string
Parameters
- $reflectionMethod : ReflectionMethod
Return values
stringgetReadVisiblityForProperty()
private
getReadVisiblityForProperty(ReflectionProperty $reflectionProperty) : string
Parameters
- $reflectionProperty : ReflectionProperty
Return values
stringgetReflectionParameterFromConstructor()
private
getReflectionParameterFromConstructor(string $property, ReflectionMethod $reflectionConstructor) : ReflectionParameter|null
Parameters
- $property : string
- $reflectionConstructor : ReflectionMethod
Return values
ReflectionParameter|nullgetWriteVisiblityForMethod()
private
getWriteVisiblityForMethod(ReflectionMethod $reflectionMethod) : string
Parameters
- $reflectionMethod : ReflectionMethod
Return values
stringgetWriteVisiblityForProperty()
private
getWriteVisiblityForProperty(ReflectionProperty $reflectionProperty) : string
Parameters
- $reflectionProperty : ReflectionProperty
Return values
stringisAllowedProperty()
private
isAllowedProperty(string $class, string $property[, bool $writeAccessRequired = false ]) : bool
Parameters
- $class : string
- $property : string
- $writeAccessRequired : bool = false
Return values
boolisMethodAccessible()
Returns whether a method is public and has the number of required parameters and errors.
private
isMethodAccessible(ReflectionClass $class, string $methodName, int $parameters) : array<string|int, mixed>
Parameters
- $class : ReflectionClass
- $methodName : string
- $parameters : int
Return values
array<string|int, mixed>isNullableProperty()
private
isNullableProperty(string $class, string $property) : bool
Parameters
- $class : string
- $property : string
Return values
boolresolveTypeName()
private
resolveTypeName(string $name, ReflectionClass $declaringClass) : string
Parameters
- $name : string
- $declaringClass : ReflectionClass