CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 6.0 API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 6.0
      • 6.0
      • 5.4
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • AttributeResolver
    • Cache
    • Collection
    • Command
    • Console
    • Container
      • Argument
      • Attribute
      • Definition
      • Exception
      • Inflector
      • ServiceProvider
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Lock
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Class ReflectionContainer

Namespace: Cake\Container

Property Summary

  • $cache protected
    array
  • $container protected
    Cake\Container\ContainerInterface|null

Method Summary

  • __construct() public
  • call() public
  • get() public
  • getContainer() abstract public
  • getNew() public

    Get a new instance, bypassing the cache.

  • has() public

    Returns true if the container can return an entry for the given identifier. Returns false otherwise.

    has($id) returning true does not mean that get($id) will not throw an exception. It does however mean that get($id) will not throw a NotFoundExceptionInterface.

  • reflectArguments() public
  • resolveArgumentFromAttribute() protected

    Attempt to resolve a parameter's value from one of its PHP attributes.

  • resolveArguments() public
  • resolveContextualArgumentFromAttribute() protected

    Attempt to resolve a parameter's value from a contextual PHP attribute.

    Contextual attributes receive the parameter being resolved alongside the container, enabling resolution by parameter name/type. Attributes not implementing {@see ContextualAttributeInterface} return false here and fall through to {@see resolveArgumentFromAttribute()}.

    The container is deliberately passed as an argument instead of using {@see ContainerAwareInterface}: with a standalone ReflectionContainer there is no parent container to inject, while the resolving instance itself always satisfies the PSR interface expected here.

  • setContainer() public

Method Detail

__construct() ¶ public

__construct(bool $cacheResolutions = false)
Parameters
bool $cacheResolutions optional

call() ¶ public

call(callable|string $callable, array $args = []): mixed
Parameters
callable|string $callable
array $args optional
Returns
mixed
Throws
Psr\Container\ContainerExceptionInterface

Psr\Container\NotFoundExceptionInterface

ReflectionException

get() ¶ public

get(string $id, array $args = [])
Parameters
string $id
array $args optional

getContainer() ¶ abstract public

getContainer(): Cake\Container\ContainerInterface
Returns
Cake\Container\ContainerInterface

getNew() ¶ public

getNew(string $id, array<string, mixed> $args = []): mixed

Get a new instance, bypassing the cache.

Parameters
string $id
array<string, mixed> $args optional
Returns
mixed

has() ¶ public

has(string $id): bool

Returns true if the container can return an entry for the given identifier. Returns false otherwise.

has($id) returning true does not mean that get($id) will not throw an exception. It does however mean that get($id) will not throw a NotFoundExceptionInterface.

Parameters
string $id
Returns
bool

reflectArguments() ¶ public

reflectArguments(ReflectionFunctionAbstract $method, array $args = []): array
Parameters
ReflectionFunctionAbstract $method
array $args optional
Returns
array

resolveArgumentFromAttribute() ¶ protected

resolveArgumentFromAttribute(ReflectionAttribute<object> $attribute): Cake\Container\Argument\LiteralArgumentInterface|false

Attempt to resolve a parameter's value from one of its PHP attributes.

Parameters
ReflectionAttribute<object> $attribute

The attribute to attempt to resolve.

Returns
Cake\Container\Argument\LiteralArgumentInterface|false

resolveArguments() ¶ public

resolveArguments(array<Cake\Container\Argument\ArgumentInterface> $arguments): array
Parameters
array<Cake\Container\Argument\ArgumentInterface> $arguments
Returns
array

resolveContextualArgumentFromAttribute() ¶ protected

resolveContextualArgumentFromAttribute(ReflectionAttribute<object> $attribute, ReflectionParameter $parameter): Cake\Container\Argument\LiteralArgumentInterface|false

Attempt to resolve a parameter's value from a contextual PHP attribute.

Contextual attributes receive the parameter being resolved alongside the container, enabling resolution by parameter name/type. Attributes not implementing {@see ContextualAttributeInterface} return false here and fall through to {@see resolveArgumentFromAttribute()}.

The container is deliberately passed as an argument instead of using {@see ContainerAwareInterface}: with a standalone ReflectionContainer there is no parent container to inject, while the resolving instance itself always satisfies the PSR interface expected here.

Parameters
ReflectionAttribute<object> $attribute

The attribute to attempt to resolve.

ReflectionParameter $parameter

The parameter being resolved.

Returns
Cake\Container\Argument\LiteralArgumentInterface|false

setContainer() ¶ public

setContainer(Cake\Container\ContainerInterface $container): ContainerAwareInterface
Parameters
Cake\Container\ContainerInterface $container
Returns
ContainerAwareInterface

Property Detail

$cache ¶ protected

Type
array

$container ¶ protected

Type
Cake\Container\ContainerInterface|null
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs