Menu

## AttributeBasedAutowiring
in package
implements DefinitionSource, Autowiring

AttributeBasedAutowiring.php : 29

Provides DI definitions by reading PHP 8 attributes such as #[Inject] and #[Injectable].

This source automatically includes the reflection source.

##### Tags

author

  Matthieu Napoli matthieu@mnapoli.fr

### Table of Contents

#### Interfaces

DefinitionSource
  Source of definitions for entries of the container.
Autowiring
  Source of definitions for entries of the container.

#### Methods

autowire() : ObjectDefinition|null
  Autowire the given definition.
getDefinition() : ObjectDefinition|null
  Returns the DI definition for the entry name.
getDefinitions() : array<string, Definition>
  Autowiring cannot guess all existing definitions.
getMethodInjection() : MethodInjection|null
getMethodParameter() : string|null
readInjectableAttribute() : void
readMethods() : void
  Browse the object's methods looking for annotated methods.
readProperties() : void
  Browse the class properties looking for annotated properties.
readProperty() : void

### Methods

#### autowire()

AttributeBasedAutowiring.php : 34

Autowire the given definition.

`public autowire(string $name[, ObjectDefinition|null $definition = null ]) : ObjectDefinition|null`

##### Parameters

$name : string
$definition : ObjectDefinition|null = null

##### Tags

throws
  InvalidAttribute

##### Return values

ObjectDefinition|null

#### getDefinition()

AttributeBasedAutowiring.php : 61

Returns the DI definition for the entry name.

`public getDefinition(string $name) : ObjectDefinition|null`

##### Parameters

$name : string

##### Tags

throws
  InvalidAttribute
throws
  InvalidArgumentException

  The class doesn't exist

##### Return values

ObjectDefinition|null

#### getDefinitions()

AttributeBasedAutowiring.php : 69

Autowiring cannot guess all existing definitions.

`public getDefinitions() : array<string, Definition>`

##### Return values

array<string, Definition> —

Definitions indexed by their name.

#### getMethodInjection()

AttributeBasedAutowiring.php : 172
`private getMethodInjection(ReflectionMethod $method) : MethodInjection|null`

##### Parameters

$method : ReflectionMethod

##### Return values

MethodInjection|null

#### getMethodParameter()

AttributeBasedAutowiring.php : 207
`private getMethodParameter(int $parameterIndex, ReflectionParameter $parameter, array<string|int, mixed> $annotationParameters) : string|null`

##### Parameters

$parameterIndex : int
$parameter : ReflectionParameter
$annotationParameters : array<string|int, mixed>

##### Return values

string|null —

Entry name or null if not found.

#### readInjectableAttribute()

AttributeBasedAutowiring.php : 243
`private readInjectableAttribute(ReflectionClass $class, ObjectDefinition $definition) : void`

##### Parameters

$class : ReflectionClass
$definition : ObjectDefinition

##### Tags

throws
  InvalidAttribute

#### readMethods()

AttributeBasedAutowiring.php : 150

Browse the object's methods looking for annotated methods.

`private readMethods(ReflectionClass $class, ObjectDefinition $objectDefinition) : void`

##### Parameters

$class : ReflectionClass
$objectDefinition : ObjectDefinition

#### readProperties()

AttributeBasedAutowiring.php : 77

Browse the class properties looking for annotated properties.

`private readProperties(ReflectionClass $class, ObjectDefinition $definition) : void`

##### Parameters

$class : ReflectionClass
$definition : ObjectDefinition

#### readProperty()

AttributeBasedAutowiring.php : 95
`private readProperty(ReflectionProperty $property, ObjectDefinition $definition[, string|null $classname = null ]) : void`

##### Parameters

$property : ReflectionProperty
$definition : ObjectDefinition
$classname : string|null = null

##### Tags

throws
  InvalidAttribute

## Search results