Skip to content

Conversation

Copy link

Copilot AI commented Dec 25, 2025

The DI container supports the decorator pattern through ServiceProviderInterface::getExtensions(), but this wasn't documented.

Changes

  • Explicitly state decorator pattern support in the service providers section
  • Add dedicated subsection with complete decorator example showing how to wrap a mailer service with logging

Example

class MailerDecoratorProvider implements ServiceProviderInterface 
{
    public function getExtensions(): array 
    {
        return [
            MailerInterface::class => static function (ContainerInterface $container, MailerInterface $mailer) {
                return new LoggingMailerDecorator($mailer, $container->get(LoggerInterface::class));
            }
        ];
    }
}

The extension receives the original service instance and returns a decorator wrapping it with additional functionality—enabling cross-cutting concerns like logging, caching, or monitoring without modifying the original implementation.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/Seldaek/jsonlint/zipball/1748aaf847fc731cfad7725aec413ee46f0cc3a2
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/azjezz/psl/zipball/15153a64c9824335ce11654522e7d88de762d39e
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/bamarni/composer-bin-plugin/zipball/e7ef9e012667327516c24e5fad9903a3bc91389d
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/clue/reactphp-term/zipball/00f297dc597eaee2ebf98af8f27cca5d21d60fa3
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/clue/reactphp-utf8/zipball/d5cd04d39cb5457aa5df830b7c4b301d2694217e
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/doctrine/annotations/zipball/901c2ee5d26eb64ff43c47976e114bf00843acf7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/doctrine/lexer/zipball/31ad66abc0fc9e1a1f2d9bc6a42668d2fbbcd6dd
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/igorw/evenement/zipball/0a16b0d71ab13284339abb99d9d2bd813640efbc
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/jolicode/php-os-helper/zipball/1622ad8bbcab98e62b5c041397e8519f10d90e29
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/maglnet/ComposerRequireChecker/zipball/ac5c3593fac690c9a186c0d9b1b753fc18d04854
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rCDWCc /usr/bin/composer install --no-interaction --no-dev /home/REDACTED/.cagit --global bash git rev-�� bc3b649fa281254c2c770^{commit}' --verify c104e503^{commit} zer.git --global /usr/local/sbin/--mirror git (http block)
  • https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/phpbench/container/zipball/0c7b2d36c1ea53fe27302fb8873ded7172047196
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/phpbench/phpbench/zipball/b641dde59d969ea42eed70a39f9b51950bc96878
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/reactphp/event-loop/zipball/ba276bda6083df7e0050fd9b33f66ad7a4ac747a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/reactphp/stream/zipball/1e5b0acb8fe55143b5b426817155190eb6f5b18d
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/revoltphp/event-loop/zipball/b6fc06dce8e9b523c9946138fa5e62181934f91c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/exporter/zipball/0735b90f4da94969541dac1da743446e276defa6
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/global-state/zipball/987bafff24ecc4c9ac418cab1145b96dd6e9cbd9
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/202d0e344a580d7f7d04b3fafce6933e59dae906
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/24ed13d98130f0e7122df55d06c5c4942a577957
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/47e34210757a2f37a97dcd207d032e1b01e64c7a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/462699a16464c3944eefc02ebdd77882bd3925bf
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c51fa83a5d8f43f1402e3f32a005e6262244ef17
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/console/zipball/6d9f0fbf2ec2e9785880096e3abd0ca0c88b506e
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/filesystem/zipball/d551b38811096d0be9c4691d406991b47c0c630a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/finder/zipball/340b9ed7320570f319028a2cbec46d40535e94bd
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/options-resolver/zipball/b38026df55197f9e39a44f3215788edf83187b80
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/process/zipball/7ca8dc2d0dcf4882658313aba8be5d9fd01026c8
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/service-contracts/zipball/45112560a3ba2d715666a509a0bc9521d10b6c43
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/string/zipball/d50e862cb0a0e0886f73ca1f31b865efbb795003
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/thephpleague/container/zipball/041c52d266763887fff2256fb5dc9392d808f8f3
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/webmozarts/glob/zipball/8a2842112d6916e61e0e15e316465b611f3abc17
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/yiisoft/definitions/zipball/efba764905b89b549e2b5a7a72f50a79b3d5b0cc
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rCDWCc /usr/bin/composer install --no-interaction --no-dev /home/REDACTED/.cagit --global bash git rev-�� bc3b649fa281254c2c770^{commit}' --verify c104e503^{commit} zer.git --global /usr/local/sbin/--mirror git (http block)
  • https://api.github.com/repos/yiisoft/friendly-exception/zipball/c6c36fd60a0b4f1514882d2ce8395f54352ec967
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rCDWCc /usr/bin/composer install --no-interaction --no-dev /home/REDACTED/.cagit --global bash git rev-�� bc3b649fa281254c2c770^{commit}' --verify c104e503^{commit} zer.git --global /usr/local/sbin/--mirror git (http block)
  • https://api.github.com/repos/yiisoft/test-support/zipball/2be91b4db0239c00e7502fb6dc9f4ded0ea18f06
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Declare decorators are supported and provide an example</issue_title>
<issue_description>### Description

Decorators are currently achieved through ServiceProviderInterface::getExtensions(). We need to explicitly mention that this allows implementing the decorator pattern.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Declare decorators are supported and provide an example Document decorator pattern support via ServiceProviderInterface::getExtensions() Dec 25, 2025
Copilot AI requested a review from samdark December 25, 2025 12:32
@samdark samdark marked this pull request as ready for review December 25, 2025 16:15
@samdark samdark requested review from a team and Copilot December 25, 2025 16:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR documents the DI container's support for the decorator pattern through ServiceProviderInterface::getExtensions(), which was previously an undocumented feature.

Key changes:

  • Added explicit statement about decorator pattern support in the service providers section
  • Created a dedicated subsection with a complete decorator example showing how to wrap a mailer service with logging functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@samdark samdark added the type:docs Documentation label Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:docs Documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Declare decorators are supported and provide an example

2 participants