Documentation

ReflectionExtractor
in package
implements PropertyListExtractorInterface, PropertyTypeExtractorInterface, PropertyAccessExtractorInterface, PropertyInitializableExtractorInterface, PropertyReadInfoExtractorInterface, PropertyWriteInfoExtractorInterface, ConstructorArgumentTypeExtractorInterface

Extracts data using the reflection API.

Tags
author

Kévin Dunglas dunglas@gmail.com

final

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

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

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>|null

getReadInfo()

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|null

getTypes()

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>|null

getTypesFromConstructor()

{@inheritdoc}

public getTypesFromConstructor(string $class, string $property) : array<string|int, mixed>|null
Parameters
$class : string
$property : string
Return values
array<string|int, mixed>|null

getWriteInfo()

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|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(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

isWritable()

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|null

camelize()

Camelizes a given string.

private camelize(string $string) : string
Parameters
$string : string
Return values
string

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>

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>|null

getMethodsFlags()

Return allowed reflection method flags.

private getMethodsFlags(int $accessFlags) : int
Parameters
$accessFlags : int
Return values
int

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

getPropertyFlags()

Return allowed reflection property flags.

private getPropertyFlags(int $accessFlags) : int
Parameters
$accessFlags : int
Return values
int

getPropertyName()

private getPropertyName(string $methodName, array<string|int, mixed> $reflectionProperties) : string|null
Parameters
$methodName : string
$reflectionProperties : array<string|int, mixed>
Return values
string|null

getReadVisiblityForMethod()

private getReadVisiblityForMethod(ReflectionMethod $reflectionMethod) : string
Parameters
$reflectionMethod : ReflectionMethod
Return values
string

getReadVisiblityForProperty()

private getReadVisiblityForProperty(ReflectionProperty $reflectionProperty) : string
Parameters
$reflectionProperty : ReflectionProperty
Return values
string

getReflectionParameterFromConstructor()

private getReflectionParameterFromConstructor(string $property, ReflectionMethod $reflectionConstructor) : ReflectionParameter|null
Parameters
$property : string
$reflectionConstructor : ReflectionMethod
Return values
ReflectionParameter|null

getWriteVisiblityForMethod()

private getWriteVisiblityForMethod(ReflectionMethod $reflectionMethod) : string
Parameters
$reflectionMethod : ReflectionMethod
Return values
string

getWriteVisiblityForProperty()

private getWriteVisiblityForProperty(ReflectionProperty $reflectionProperty) : string
Parameters
$reflectionProperty : ReflectionProperty
Return values
string

isAllowedProperty()

private isAllowedProperty(string $class, string $property[, bool $writeAccessRequired = false ]) : bool
Parameters
$class : string
$property : string
$writeAccessRequired : bool = false
Return values
bool

isMethodAccessible()

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
bool

resolveTypeName()

private resolveTypeName(string $name, ReflectionClass $declaringClass) : string
Parameters
$name : string
$declaringClass : ReflectionClass
Return values
string

        
On this page

Search results