Document decorator pattern support via ServiceProviderInterface::getExtensions() #396
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The DI container supports the decorator pattern through
ServiceProviderInterface::getExtensions(), but this wasn't documented.Changes
Example
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/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/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/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/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/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/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/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/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/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/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/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/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/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/05s4rE /usr/bin/composer install --no-interaction(http block)/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.