PHP Class Cascade\Config\Loader\ClassLoader\Resolver\ConstructorResolver

Author: Raphael Antonmattei ([email protected])
显示文件 Open project: theorchard/monolog-cascade Class Usage Examples

Protected Properties

Property Type Description
$constructorArgs ReflectionParameter[] Associative array of contructor args to resolve against
$reflected ReflectionClass Reflection class for which you want to resolve constructor options

Public Methods

Method Description
__construct ( ReflectionClass $reflected ) Contructor
getConstructorArgs ( ) : array Returns the contructor args as an associative array
getReflected ( ) : ReflectionClass Returns the reflected object
hashToArgsArray ( array $hashOfOptions ) : array Loops through constructor args and buid an ordered array of args using the option values passed in. We assume the passed in array has been resolved already.
initConstructorArgs ( ) Fetches constructor args (array of ReflectionParameter) from the reflected class and set them as an associative array
resolve ( array $options ) : array Resolve options against constructor args

Protected Methods

Method Description
configureOptions ( Symfony\Component\OptionsResolver\OptionsResolver $optionsResolver ) Configure options for the provided OptionResolver to match contructor args requirements

Method Details

__construct() public method

Contructor
public __construct ( ReflectionClass $reflected )
$reflected ReflectionClass Reflection class for which you want to resolve constructor options

configureOptions() protected method

Configure options for the provided OptionResolver to match contructor args requirements
protected configureOptions ( Symfony\Component\OptionsResolver\OptionsResolver $optionsResolver )
$optionsResolver Symfony\Component\OptionsResolver\OptionsResolver OptionResolver to configure

getConstructorArgs() public method

Returns the contructor args as an associative array
public getConstructorArgs ( ) : array
return array Contructor args

getReflected() public method

Returns the reflected object
public getReflected ( ) : ReflectionClass
return ReflectionClass

hashToArgsArray() public method

i.e. That the arg name has an entry in the option array.
public hashToArgsArray ( array $hashOfOptions ) : array
$hashOfOptions array Array of options
return array Array of ordered args

initConstructorArgs() public method

Convert the parameter names to camelCase for classes that have contructor params defined in snake_case for consistency with the options
public initConstructorArgs ( )

resolve() public method

Resolve options against constructor args
public resolve ( array $options ) : array
$options array Array of option values. Expected array looks like: array( 'someParam' => 'def', 'someOtherParam' => 'sdsad' )
return array Array of resolved ordered args

Property Details

$constructorArgs protected_oe property

Associative array of contructor args to resolve against
protected ReflectionParameter[] $constructorArgs
return ReflectionParameter[]

$reflected protected_oe property

Reflection class for which you want to resolve constructor options
protected ReflectionClass $reflected
return ReflectionClass