ReflectionExtractor
in package
implements
PropertyListExtractorInterface, PropertyTypeExtractorInterface, PropertyAccessExtractorInterface, PropertyInitializableExtractorInterface
Extracts data using the reflection API.
Tags
Interfaces, Classes, Traits and Enums
- 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.
Table of Contents
- ALLOW_PRIVATE = 1
- ALLOW_PROTECTED = 2
- ALLOW_PUBLIC = 4
- 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]
- $accessFlags : mixed
- $accessorPrefixes : mixed
- $arrayMutatorPrefixes : mixed
- $arrayMutatorPrefixesFirst : mixed
- $arrayMutatorPrefixesLast : mixed
- $enableConstructorExtraction : mixed
- $mutatorPrefixes : mixed
- __construct() : mixed
- getProperties() : array<string|int, string>|null
- Gets the list of properties available for the given class.
- getTypes() : array<string|int, Type>|null
- Gets types of a property.
- 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?
- 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>
- getAccessorMethod() : array<string|int, mixed>|null
- Gets the accessor method.
- 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.
- getPropertyName() : string|null
- isAllowedProperty() : bool
- isNullableProperty() : bool
- resolveTypeName() : string
Constants
ALLOW_PRIVATE
public
mixed
ALLOW_PRIVATE
= 1
ALLOW_PROTECTED
public
mixed
ALLOW_PROTECTED
= 2
ALLOW_PUBLIC
public
mixed
ALLOW_PUBLIC
= 4
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
$accessFlags
private
mixed
$accessFlags
$accessorPrefixes
private
mixed
$accessorPrefixes
$arrayMutatorPrefixes
private
mixed
$arrayMutatorPrefixes
$arrayMutatorPrefixesFirst
private
mixed
$arrayMutatorPrefixesFirst
$arrayMutatorPrefixesLast
private
mixed
$arrayMutatorPrefixesLast
$enableConstructorExtraction
private
mixed
$enableConstructorExtraction
$mutatorPrefixes
private
mixed
$mutatorPrefixes
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 ]) : 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
Return values
mixed —getProperties()
Gets the list of properties available for the given class.
public
getProperties(mixed $class[, array<string|int, mixed> $context = [] ]) : array<string|int, string>|null
Parameters
- $class : mixed
- $context : array<string|int, mixed> = []
Return values
array<string|int, string>|null —getTypes()
Gets types of a property.
public
getTypes(mixed $class, mixed $property[, array<string|int, mixed> $context = [] ]) : array<string|int, Type>|null
Parameters
- $class : mixed
- $property : mixed
- $context : array<string|int, mixed> = []
Return values
array<string|int, Type>|null —isInitializable()
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|null —isReadable()
Is the property readable?
public
isReadable(mixed $class, mixed $property[, array<string|int, mixed> $context = [] ]) : bool|null
Parameters
- $class : mixed
- $property : mixed
- $context : array<string|int, mixed> = []
Return values
bool|null —isWritable()
Is the property writable?
public
isWritable(mixed $class, mixed $property[, array<string|int, mixed> $context = [] ]) : bool|null
Parameters
- $class : mixed
- $property : mixed
- $context : array<string|int, mixed> = []
Return values
bool|null —extractFromAccessor()
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>|null —extractFromConstructor()
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>|null —extractFromMutator()
private
extractFromMutator(string $class, string $property) : array<string|int, Type>|null
Parameters
- $class : string
- $property : string
Return values
array<string|int, Type>|null —extractFromPropertyDeclaration()
private
extractFromPropertyDeclaration(string $class, string $property) : array<string|int, mixed>|null
Parameters
- $class : string
- $property : string
Return values
array<string|int, mixed>|null —extractFromReflectionType()
private
extractFromReflectionType(ReflectionType $reflectionType, ReflectionClass $declaringClass) : array<string|int, mixed>
Parameters
- $reflectionType : ReflectionType
- $declaringClass : ReflectionClass
Return values
array<string|int, mixed> —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>|null —getMutatorMethod()
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>|null —getPropertyName()
private
getPropertyName(string $methodName, array<string|int, mixed> $reflectionProperties) : string|null
Parameters
- $methodName : string
- $reflectionProperties : array<string|int, mixed>
Return values
string|null —isAllowedProperty()
private
isAllowedProperty(string $class, string $property) : bool
Parameters
- $class : string
- $property : string
Return values
bool —isNullableProperty()
private
isNullableProperty(string $class, string $property) : bool
Parameters
- $class : string
- $property : string
Return values
bool —resolveTypeName()
private
resolveTypeName(string $name, ReflectionClass $declaringClass) : string
Parameters
- $name : string
- $declaringClass : ReflectionClass