Copied!

Automatically configures classes and dependencies.

Sets up an automatic registration for classes when requested through
Pimple by looking up the class's constructor and arguments.

CloneableInstantiable
Methods
public Pimple\Container::__construct(array $values = [])
 

Instantiates the container.

Objects and parameters can be passed as argument to the constructor.

  • param array $values The parameters or objects
public autoRegister( $class) : ?string
 

Returns a factory function for the passed class.

The returned factory method looks up arguments and uses pimple to get an
instance of those types to pass them during construction.

public extend( $id, $callable)
 

Overridden to see if the class can be auto-registered first before
calling Pimple\Container::extend

  • param string $id
  • param callable $callable
  • return callable the wrapped $callable
public Pimple\Container::factory( $callable)
 

Marks a callable as being a factory service.

  • param callable $callable A service definition to be used as a factory
  • return callable The passed callable
  • throws \ExpectedInvokableException Service definition has to be a closure or an invokable object
public Pimple\Container::keys()
 

Returns all defined value names.

  • return array An array of value names
public offsetExists( $id) : bool
 

Overridden to see if the class can be auto-registered and return true if
it can.

public offsetGet( $id)
 

Overridden to see if the class can be auto-registered and return an
instance if it can.

  • param string | int $id
  • throws \UnknownIdentifierException
  • attribute ReturnTypeWillChange
public Pimple\Container::offsetSet( $id, $value)
 

Sets a parameter or an object.

Objects must be defined as Closures.

Allowing any PHP callable leads to difficult to debug problems
as function names (strings) are callable (creating a function with
the same name as an existing parameter would break your container).

  • param string $id The unique identifier for the parameter or object
  • param mixed $value The value of the parameter or a closure to define an object
  • return void
  • throws \FrozenServiceException Prevent override of a frozen service
  • attribute ReturnTypeWillChange
public Pimple\Container::offsetUnset( $id)
 

Unsets a parameter or an object.

  • param string $id The unique identifier for the parameter or object
  • return void
  • attribute ReturnTypeWillChange
public Pimple\Container::protect( $callable)
 

Protects a callable from being interpreted as a service.

This is useful when you want to store a callable as a parameter.

  • param callable $callable A callable to protect from being evaluated
  • return callable The passed callable
  • throws \ExpectedInvokableException Service definition has to be a closure or an invokable object
public Pimple\Container::raw( $id)
 

Gets a parameter or the closure defining an object.

  • param string $id The unique identifier for the parameter or object
  • return mixed The value of the parameter or the closure defining an object
  • throws \UnknownIdentifierException If the identifier is not defined
public Pimple\Container::register(Pimple\ServiceProviderInterface $provider, array $values = [])
 

Registers a service provider.

  • param array $values An array of values that customizes the provider
  • return static
Methods
private getParameterClass(ReflectionParameter $param) : ?string
 

Looks up the type of the passed ReflectionParameter and returns it as a
fully qualified class name as expected by the class's auto registration.

Null is returned for built-in types.

© 2023 Bruce Wells
Search Namespaces \ Classes
Configuration