diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 84a03c743b95a..2e4e0447ede95 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -4,5 +4,7 @@ f4118e110a46de3ffb799e7d79bf15128d1646ea ae0a783425b80b78376488619bf9106e69193fa4 9c1e36257c4df0929179462d6b2bdd00453ac8aa 6ae74d38e3d20d0ffcc66c7c3d28767fab76bdfb -# Prefix all sprintf() calls 6ce530c5e90397d88e3a76a56db266c74d651584 +77bd236b8da064c90b19b84a35becfb3e43348db +d0bc10e7432901098fe50bcccad53f487978c33d +2e0c0d39bdc99712cc40b8a5b77e267150a92509 diff --git a/.gitattributes b/.gitattributes index c7aefa05ef8be..a619132d3516d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,7 +7,7 @@ /src/Symfony/Component/Translation/Bridge export-ignore /src/Symfony/Component/Emoji/Resources/data/* linguist-generated=true /src/Symfony/Component/Intl/Resources/data/*/* linguist-generated=true -/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/* linguist-generated=true -/src/Symfony/Component/JsonEncoder/Tests/Fixtures/decoder/* linguist-generated=true +/src/Symfony/Component/JsonStreamer/Tests/Fixtures/stream_writer/* linguist-generated=true +/src/Symfony/Component/JsonStreamer/Tests/Fixtures/stream_reader/* linguist-generated=true /src/Symfony/**/.github/workflows/close-pull-request.yml linguist-generated=true /src/Symfony/**/.github/PULL_REQUEST_TEMPLATE.md linguist-generated=true diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 3d21822287b6b..557eda9c29893 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,22 +1,25 @@ | Q | A | ------------- | --- -| Branch? | 7.3 for features / 6.4, 7.1, and 7.2 for bug fixes +| Branch? | 7.4 for features / 6.4, 7.2, or 7.3 for bug fixes | Bug fix? | yes/no -| New feature? | yes/no -| Deprecations? | yes/no -| Issues | Fix #... +| New feature? | yes/no +| Deprecations? | yes/no +| Issues | Fix #... | License | MIT diff --git a/.github/build-packages.php b/.github/build-packages.php index d69a3c8198ec0..4793b8483d7ed 100644 --- a/.github/build-packages.php +++ b/.github/build-packages.php @@ -1,5 +1,15 @@ '__unset' !== $v); + }, []); + + return $expandedVersions ?? []; +} + if (3 > $_SERVER['argc']) { echo "Usage: branch version dir1 dir2 ... dirN\n"; exit(1); @@ -52,11 +62,13 @@ $packages[$package->name][$package->version] = $package; - $versions = @file_get_contents('https://repo.packagist.org/p/'.$package->name.'.json') ?: sprintf('{"packages":{"%s":{"%s":%s}}}', $package->name, $package->version, file_get_contents($dir.'/composer.json')); - $versions = json_decode($versions)->packages->{$package->name}; + foreach (['.json', '~dev.json'] as $ext) { + $versions = @file_get_contents('https://repo.packagist.org/p2/'.$package->name.$ext) ?: '[]'; + $versions = json_decode($versions, true)['packages'][$package->name] ?? []; - foreach ($versions as $v => $package) { - $packages[$package->name] += [$v => $package]; + foreach (expandComposerMetadata($versions) as $p) { + $packages[$package->name] += [$p['version'] => $p]; + } } } diff --git a/.github/expected-missing-return-types.diff b/.github/expected-missing-return-types.diff index 30ac60ab98ad7..679740ed3a33c 100644 --- a/.github/expected-missing-return-types.diff +++ b/.github/expected-missing-return-types.diff @@ -48,7 +48,7 @@ diff --git a/src/Symfony/Component/BrowserKit/AbstractBrowser.php b/src/Symfony/ diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php --- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php -@@ -94,5 +94,5 @@ abstract class NodeDefinition implements NodeParentInterface +@@ -115,5 +115,5 @@ abstract class NodeDefinition implements NodeParentInterface * @return NodeParentInterface|NodeBuilder|self|ArrayNodeDefinition|VariableNodeDefinition */ - public function end(): NodeParentInterface @@ -58,21 +58,21 @@ diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php -@@ -163,5 +163,5 @@ class Command +@@ -201,5 +201,5 @@ class Command implements SignalableCommandInterface * @return void */ - protected function configure() + protected function configure(): void { } -@@ -195,5 +195,5 @@ class Command +@@ -233,5 +233,5 @@ class Command implements SignalableCommandInterface * @return void */ - protected function interact(InputInterface $input, OutputInterface $output) + protected function interact(InputInterface $input, OutputInterface $output): void { } -@@ -211,5 +211,5 @@ class Command +@@ -249,5 +249,5 @@ class Command implements SignalableCommandInterface * @return void */ - protected function initialize(InputInterface $input, OutputInterface $output) @@ -177,6 +177,23 @@ diff --git a/src/Symfony/Component/DependencyInjection/Extension/PrependExtensio - public function prepend(ContainerBuilder $container); + public function prepend(ContainerBuilder $container): void; } +diff --git a/src/Symfony/Component/Emoji/EmojiTransliterator.php b/src/Symfony/Component/Emoji/EmojiTransliterator.php +--- a/src/Symfony/Component/Emoji/EmojiTransliterator.php ++++ b/src/Symfony/Component/Emoji/EmojiTransliterator.php +@@ -88,5 +88,5 @@ final class EmojiTransliterator extends \Transliterator + */ + #[\ReturnTypeWillChange] +- public function getErrorCode(): int|false ++ public function getErrorCode(): int + { + return isset($this->transliterator) ? $this->transliterator->getErrorCode() : 0; +@@ -97,5 +97,5 @@ final class EmojiTransliterator extends \Transliterator + */ + #[\ReturnTypeWillChange] +- public function getErrorMessage(): string|false ++ public function getErrorMessage(): string + { + return isset($this->transliterator) ? $this->transliterator->getErrorMessage() : ''; diff --git a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php --- a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php +++ b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php @@ -457,14 +474,14 @@ diff --git a/src/Symfony/Component/HttpKernel/KernelInterface.php b/src/Symfony/ diff --git a/src/Symfony/Component/Routing/Loader/AttributeClassLoader.php b/src/Symfony/Component/Routing/Loader/AttributeClassLoader.php --- a/src/Symfony/Component/Routing/Loader/AttributeClassLoader.php +++ b/src/Symfony/Component/Routing/Loader/AttributeClassLoader.php -@@ -253,5 +253,5 @@ abstract class AttributeClassLoader implements LoaderInterface +@@ -277,5 +277,5 @@ abstract class AttributeClassLoader implements LoaderInterface * @return string */ - protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method) + protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method): string { $name = str_replace('\\', '_', $class->name).'_'.$method->name; -@@ -355,5 +355,5 @@ abstract class AttributeClassLoader implements LoaderInterface +@@ -379,5 +379,5 @@ abstract class AttributeClassLoader implements LoaderInterface * @return void */ - abstract protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $attr); @@ -561,7 +578,7 @@ diff --git a/src/Symfony/Component/Translation/Extractor/ExtractorInterface.php diff --git a/src/Symfony/Component/TypeInfo/Tests/Fixtures/DummyWithPhpDoc.php b/src/Symfony/Component/TypeInfo/Tests/Fixtures/DummyWithPhpDoc.php --- a/src/Symfony/Component/TypeInfo/Tests/Fixtures/DummyWithPhpDoc.php +++ b/src/Symfony/Component/TypeInfo/Tests/Fixtures/DummyWithPhpDoc.php -@@ -15,5 +15,5 @@ final class DummyWithPhpDoc +@@ -50,5 +50,5 @@ final class DummyWithPhpDoc * @return Dummy */ - public function getNextDummy(mixed $dummy): mixed @@ -593,23 +610,6 @@ diff --git a/src/Symfony/Component/VarDumper/Dumper/DataDumperInterface.php b/sr - public function dump(Data $data); + public function dump(Data $data): ?string; } -diff --git a/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php b/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php ---- a/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php -+++ b/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php -@@ -172,5 +172,5 @@ class ProxyHelperTest extends TestCase - { - yield 'not type hinted __unserialize method' => [new class { -- public function __unserialize($array) -+ public function __unserialize($array): void - { - } -@@ -192,5 +192,5 @@ class ProxyHelperTest extends TestCase - - yield 'type hinted __unserialize method' => [new class { -- public function __unserialize(array $array) -+ public function __unserialize(array $array): void - { - } diff --git a/src/Symfony/Contracts/Translation/LocaleAwareInterface.php b/src/Symfony/Contracts/Translation/LocaleAwareInterface.php --- a/src/Symfony/Contracts/Translation/LocaleAwareInterface.php +++ b/src/Symfony/Contracts/Translation/LocaleAwareInterface.php diff --git a/.github/get-modified-packages.php b/.github/get-modified-packages.php index 11478cbe935c0..24de414fdd266 100644 --- a/.github/get-modified-packages.php +++ b/.github/get-modified-packages.php @@ -22,7 +22,7 @@ function getPackageType(string $packageDir): string return match (true) { str_contains($packageDir, 'Symfony/Bridge/') => 'bridge', str_contains($packageDir, 'Symfony/Bundle/') => 'bundle', - preg_match('@Symfony/Component/[^/]+/Bridge/@', $packageDir) => 'component_bridge', + 1 === preg_match('@Symfony/Component/[^/]+/Bridge/@', $packageDir) => 'component_bridge', str_contains($packageDir, 'Symfony/Component/') => 'component', str_contains($packageDir, 'Symfony/Contracts/') => 'contract', str_ends_with($packageDir, 'Symfony/Contracts') => 'contracts', diff --git a/.github/patch-types.php b/.github/patch-types.php index fc6be71995397..9e4f12c6dfa76 100644 --- a/.github/patch-types.php +++ b/.github/patch-types.php @@ -53,8 +53,11 @@ case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/'): case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php81Dummy.php'): case false !== strpos($file, '/src/Symfony/Component/Runtime/Internal/ComposerPlugin.php'): + case false !== strpos($file, '/src/Symfony/Component/Security/Http/Tests/Fixtures/IsGrantedAttributeMethodsWithClosureController.php'): + case false !== strpos($file, '/src/Symfony/Component/Security/Http/Tests/Fixtures/IsGrantedAttributeWithClosureController.php'): case false !== strpos($file, '/src/Symfony/Component/Serializer/Tests/Fixtures/'): case false !== strpos($file, '/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectOuter.php'): + case false !== strpos($file, '/src/Symfony/Component/Validator/Tests/Constraints/Fixtures/WhenTestWithClosure.php'): case false !== strpos($file, '/src/Symfony/Component/Validator/Tests/Fixtures/NestedAttribute/Entity.php'): case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php'): case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionIntersectionTypeFixture.php'): diff --git a/.github/workflows/fabbot.yml b/.github/workflows/fabbot.yml new file mode 100644 index 0000000000000..a187b49ee6991 --- /dev/null +++ b/.github/workflows/fabbot.yml @@ -0,0 +1,15 @@ +name: CS + +on: + pull_request: + +permissions: + contents: read + +jobs: + call-fabbot: + name: Fabbot + uses: symfony-tools/fabbot/.github/workflows/fabbot.yml@main + with: + package: Symfony + check_license: true diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 0265b619c8be6..a2a3f8853882a 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -19,7 +19,7 @@ jobs: tests: name: Integration - runs-on: Ubuntu-20.04 + runs-on: ubuntu-24.04 strategy: matrix: @@ -81,6 +81,26 @@ jobs: REDIS_MASTER_HOST: redis REDIS_MASTER_SET: redis_sentinel REDIS_SENTINEL_QUORUM: 1 + redis-primary: + image: bitnami/redis:latest + ports: + - 16381:6379 + env: + ALLOW_EMPTY_PASSWORD: "yes" + REDIS_REPLICATION_MODE: "master" + options: >- + --name=redis-primary + redis-replica: + image: bitnami/redis:latest + ports: + - 16382:6379 + env: + ALLOW_EMPTY_PASSWORD: "yes" + REDIS_REPLICATION_MODE: "slave" + REDIS_MASTER_HOST: redis-primary + REDIS_MASTER_PORT_NUMBER: "6379" + options: >- + --name=redis-replica memcached: image: memcached:1.6.5 ports: @@ -152,7 +172,7 @@ jobs: run: | echo "::group::apt-get update" sudo wget -O - https://packages.couchbase.com/clients/c/repos/deb/couchbase.key | sudo apt-key add - - echo "deb https://packages.couchbase.com/clients/c/repos/deb/ubuntu2004 focal focal/main" | sudo tee /etc/apt/sources.list.d/couchbase.list + echo "deb https://packages.couchbase.com/clients/c/repos/deb/ubuntu2404 noble noble/main" | sudo tee /etc/apt/sources.list.d/couchbase.list sudo apt-get update echo "::endgroup::" @@ -239,6 +259,7 @@ jobs: REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005' REDIS_SENTINEL_HOSTS: 'unreachable-host:26379 localhost:26379 localhost:26379' REDIS_SENTINEL_SERVICE: redis_sentinel + REDIS_REPLICATION_HOSTS: 'localhost:16382 localhost:16381' MESSENGER_REDIS_DSN: redis://127.0.0.1:7006/messages MESSENGER_AMQP_DSN: amqp://localhost/%2f/messages MESSENGER_SQS_DSN: "sqs://localhost:4566/messages?sslmode=disable&poll_timeout=0.01" diff --git a/.github/workflows/intl-data-tests.yml b/.github/workflows/intl-data-tests.yml index a02bd73ac5b8f..193b3dd1df14d 100644 --- a/.github/workflows/intl-data-tests.yml +++ b/.github/workflows/intl-data-tests.yml @@ -36,7 +36,7 @@ permissions: jobs: tests: name: Intl/Emoji data - runs-on: Ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - name: Checkout diff --git a/.github/workflows/package-tests.yml b/.github/workflows/package-tests.yml index bc6f8eec683c7..55d1c82e3661a 100644 --- a/.github/workflows/package-tests.yml +++ b/.github/workflows/package-tests.yml @@ -11,7 +11,7 @@ permissions: jobs: verify: name: Verify Packages - runs-on: Ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/phpunit-bridge.yml b/.github/workflows/phpunit-bridge.yml index ef6b86be43e09..5de320ee91c0e 100644 --- a/.github/workflows/phpunit-bridge.yml +++ b/.github/workflows/phpunit-bridge.yml @@ -22,7 +22,7 @@ permissions: jobs: lint: name: Lint PhpUnitBridge - runs-on: Ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - name: Checkout @@ -35,4 +35,4 @@ jobs: php-version: "7.2" - name: Lint - run: find ./src/Symfony/Bridge/PhpUnit -name '*.php' | grep -v -e /Tests/ -e /Attribute/ -e /Extension/ -e /Metadata/ -e ForV7 -e ForV8 -e ForV9 -e ConstraintLogicTrait | parallel -j 4 php -l {} + run: find ./src/Symfony/Bridge/PhpUnit -name '*.php' | grep -v -e /Tests/ -e /Attribute/ -e /Extension/ -e /Metadata/ -e ForV7 -e ForV8 -e ForV9 -e ConstraintLogicTrait -e SymfonyExtension | parallel -j 4 php -l {} diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index a165d0c7dc126..33a5f58b44c6a 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -17,7 +17,7 @@ permissions: jobs: psalm: name: Psalm - runs-on: Ubuntu-20.04 + runs-on: ubuntu-24.04 env: php-version: '8.2' diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index c2929a461dfef..1033e761a2d0b 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -6,7 +6,7 @@ on: schedule: - cron: '34 4 * * 6' push: - branches: [ "7.3" ] + branches: [ "7.4" ] # Declare default permissions as read only. permissions: read-all @@ -14,7 +14,7 @@ permissions: read-all jobs: analysis: name: Scorecards analysis - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 permissions: # Needed to upload the results to code-scanning dashboard. security-events: write @@ -26,38 +26,45 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: "Run analysis" - uses: ossf/scorecard-action@3e15ea8318eee9b333819ec77a36aca8d39df13e # v1.1.1 + uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1 with: results_file: results.sarif results_format: sarif - # (Optional) Read-only PAT token. Uncomment the `repo_token` line below if: + # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: # - you want to enable the Branch-Protection check on a *public* repository, or - # - you are installing Scorecards on a *private* repository - # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. - # repo_token: ${{ secrets.SCORECARD_READ_TOKEN }} - - # Publish the results for public repositories to enable scorecard badges. For more details, see - # https://github.com/ossf/scorecard-action#publishing-results. - # For private repositories, `publish_results` will automatically be set to `false`, regardless - # of the value entered here. + # - you are installing Scorecard on a *private* repository + # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional. + # repo_token: ${{ secrets.SCORECARD_TOKEN }} + + # Public repositories: + # - Publish results to OpenSSF REST API for easy access by consumers + # - Allows the repository to include the Scorecard badge. + # - See https://github.com/ossf/scorecard-action#publishing-results. + # For private repositories: + # - `publish_results` will always be set to `false`, regardless + # of the value entered here. publish_results: true + # (Optional) Uncomment file_mode if you have a .gitattributes with files marked export-ignore + # file_mode: git + # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 with: name: SARIF file path: results.sarif retention-days: 5 - # Upload the results to GitHub's code scanning dashboard. + # Upload the results to GitHub's code scanning dashboard (optional). + # Commenting out will disable upload of results to your repo's Code Scanning dashboard - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26 + uses: github/codeql-action/upload-sarif@v3 with: sarif_file: results.sarif diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index d8d36c4e7e039..ca6b82974d22d 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -21,7 +21,7 @@ jobs: name: Unit Tests env: - extensions: amqp,apcu,igbinary,intl,mbstring,memcached,redis,relay + extensions: amqp,apcu,brotli,igbinary,intl,mbstring,memcached,redis,relay,zstd strategy: matrix: @@ -33,14 +33,13 @@ jobs: mode: low-deps - php: '8.3' - php: '8.4' - # brotli and zstd extensions are optional, when not present the commands will be used instead, - # we must test both scenarios - extensions: amqp,apcu,brotli,igbinary,intl,mbstring,memcached,redis,relay,zstd - php: '8.5' + # to be removed when ext-zstd is ready for PHP 8.5 + extensions: amqp,apcu,brotli,igbinary,intl,mbstring,memcached,redis,relay #mode: experimental fail-fast: false - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - name: Checkout @@ -76,7 +75,7 @@ jobs: ([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json" echo COLUMNS=120 >> $GITHUB_ENV - echo PHPUNIT="$(pwd)/phpunit --exclude-group tty,benchmark,intl-data,integration" >> $GITHUB_ENV + echo PHPUNIT="$(pwd)/phpunit --exclude-group tty,benchmark,intl-data,integration,transient" >> $GITHUB_ENV echo COMPOSER_UP='composer update --no-progress --ansi'$([[ "${{ matrix.mode }}" != low-deps ]] && echo ' --ignore-platform-req=php+') >> $GITHUB_ENV SYMFONY_VERSIONS=$(git ls-remote -q --heads | cut -f2 | grep -o '/[1-9][0-9]*\.[0-9].*' | sort -V) @@ -101,7 +100,7 @@ jobs: # Create local composer packages for each patched components and reference them in composer.json files when cross-testing components if [[ ! "${{ matrix.mode }}" = *-deps ]]; then - php .github/build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit + php .github/build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit else echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV cp composer.json composer.json.orig @@ -139,10 +138,6 @@ jobs: echo SYMFONY_REQUIRE=">=$([ '${{ matrix.mode }}' = low-deps ] && echo 5.4 || echo $SYMFONY_VERSION)" >> $GITHUB_ENV [[ "${{ matrix.mode }}" = *-deps ]] && mv composer.json.phpunit composer.json || true - if [[ "${{ matrix.mode }}" = low-deps ]]; then - echo SYMFONY_PHPUNIT_REQUIRE="nikic/php-parser:^4.18" >> $GITHUB_ENV - fi - - name: Install dependencies run: | echo "::group::composer update" @@ -221,7 +216,7 @@ jobs: export SYMFONY_REQUIRE=">=$SYMFONY_VERSION" git fetch --depth=2 origin $SYMFONY_VERSION git checkout -m FETCH_HEAD - PATCHED_COMPONENTS=$(echo "$PATCHED_COMPONENTS" | xargs dirname | xargs -n1 -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort || true) + PATCHED_COMPONENTS=$(echo "$PATCHED_COMPONENTS" | xargs dirname | xargs -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort || true) if [[ $PATCHED_COMPONENTS ]]; then echo "::group::install phpunit" ./phpunit install @@ -237,6 +232,12 @@ jobs: run: | script -e -c './phpunit --group tty' /dev/null + - name: Run AssetMapper without ext-brotli nor ext-zstd + if: "! matrix.mode" + run: | + sudo rm -f /etc/php/*/cli/conf.d/*-{brotli,zstd}.ini + ./phpunit src/Symfony/Component/AssetMapper + - name: Run tests with SIGCHLD enabled PHP if: "matrix.php == '8.2' && ! matrix.mode" run: | diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 62ab3e5e6a3aa..e0a663386beee 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -43,13 +43,15 @@ jobs: run: | $env:Path = 'c:\php;' + $env:Path mkdir c:\php && cd c:\php - iwr -outf php-8.2.0-Win32-vs16-x86.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php-8.2.0-Win32-vs16-x86.zip - 7z x php-8.2.0-Win32-vs16-x86.zip -y >nul + iwr -outf php.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php-8.2.0-Win32-vs16-x86.zip + 7z x php.zip -y >nul cd ext - iwr -outf php_apcu-5.1.22-8.2-ts-vs16-x86.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php_apcu-5.1.22-8.2-ts-vs16-x86.zip - 7z x php_apcu-5.1.22-8.2-ts-vs16-x86.zip -y >nul - iwr -outf php_redis-6.0.0-dev-8.2-ts-vs16-x86.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php_redis-6.0.0-dev-8.2-ts-vs16-x86.zip - 7z x php_redis-6.0.0-dev-8.2-ts-vs16-x86.zip -y >nul + iwr -outf php_apcu.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php_apcu-5.1.22-8.2-ts-vs16-x86.zip + 7z x php_apcu.zip -y >nul + iwr -outf php_igbinary.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php_igbinary-3.2.16-8.2-ts-vs16-x86.zip + 7z x php_igbinary.zip -y >nul + iwr -outf php_redis.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php_redis-6.0.0-dev-8.2-ts-vs16-x86.zip + 7z x php_redis.zip -y >nul cd .. Copy php.ini-development php.ini-min "memory_limit=-1" >> php.ini-min diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 3e3ec39dbfa17..d31af1aab2e20 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -13,14 +13,19 @@ exit(0); } -$fileHeaderComment = <<<'EOF' -This file is part of the Symfony package. +$fileHeaderParts = [ + <<<'EOF' + This file is part of the Symfony package. -(c) Fabien Potencier + (c) Fabien Potencier -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. -EOF; + EOF, + <<<'EOF' + + For the full copyright and license information, please view the LICENSE + file that was distributed with this source code. + EOF, +]; return (new PhpCsFixer\Config()) // @see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/7777 @@ -30,8 +35,18 @@ '@PHPUnit75Migration:risky' => true, '@Symfony' => true, '@Symfony:risky' => true, + 'phpdoc_var_annotation_correct_order' => true, 'protected_to_private' => false, - 'header_comment' => ['header' => $fileHeaderComment], + 'header_comment' => [ + 'header' => implode('', $fileHeaderParts), + 'validator' => implode('', [ + '/', + preg_quote($fileHeaderParts[0], '/'), + '(?P.*)??', + preg_quote($fileHeaderParts[1], '/'), + '/s', + ]), + ], ]) ->setRiskyAllowed(true) ->setFinder( diff --git a/CHANGELOG-7.2.md b/CHANGELOG-7.2.md index fbc5b88c33e11..d128815948827 100644 --- a/CHANGELOG-7.2.md +++ b/CHANGELOG-7.2.md @@ -7,6 +7,167 @@ in 7.2 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v7.2.0...v7.2.1 +* 7.2.8 (2025-06-28) + + * bug #60044 [Console] Table counts wrong column width when using colspan and `setColumnMaxWidth()` (vladimir-vv) + * bug #60042 [Console] Table counts wrong number of padding symbols in `renderCell()` method when cell contain unicode variant selector (vladimir-vv) + * bug #60594 [Cache] Fix using a `ChainAdapter` as an adapter for a pool (IndraGunawan) + * bug #60483 [HttpKernel] Fix `#[MapUploadedFile]` handling for optional file uploads (santysisi) + * bug #60413 [Serializer] Fix collect_denormalization_errors flag in defaultContext (dmbrson) + * bug #60820 [TypeInfo] Fix handling `ConstFetchNode` (norkunas) + * bug #60908 [Uid] Improve entropy of the increment for UUIDv7 (nicolas-grekas) + * bug #60914 [Console] Fix command option mode (InputOption::VALUE_REQUIRED) (gharlan) + * bug #60919 [VarDumper] Avoid deprecated call in PgSqlCaster (vrana) + * bug #60909 [TypeInfo] use an EOL-agnostic approach to parse class uses (xabbuh) + * bug #60888 [Intl] Fix locale validator when canonicalize is true (rdavaillaud) + * bug #60885 [Notifier] Update fake SMS transports to use contracts event dispatcher (paulferrett) + * bug #60859 [TwigBundle] fix preload unlinked class `BinaryOperatorExpressionParser` (Grummfy) + * bug #60772 [Mailer] [Transport] Send clone of `RawMessage` instance in `RoundRobinTransport` (jnoordsij) + * bug #60842 [DependencyInjection] Fix generating adapters of functional interfaces (nicolas-grekas) + * bug #60809 [Serializer] Fix `TraceableSerializer` when called from a callable inside `array_map` (OrestisZag) + * bug #60511 [Serializer] Add support for discriminator map in property normalizer (ruudk) + * bug #60780 [FrameworkBundle] Fix argument not provided to `add_bus_name_stamp_middleware` (maxbaldanza) + * bug #60826 [DependencyInjection] Fix inlining when public services are involved (nicolas-grekas) + * bug #60806 [HttpClient] Limit curl's connection cache size (nicolas-grekas) + * bug #60705 [FrameworkBundle] Fix allow `loose` as an email validation mode (rhel-eo) + * bug #60759 [Messenger] Fix float value for worker memory limit (ro0NL) + * bug #60785 [Security] Handle non-callable implementations of `FirewallListenerInterface` (MatTheCat) + * bug #60781 [DomCrawler] Allow selecting `button`s by their `value` (MatTheCat) + * bug #60775 [Validator] flip excluded properties with keys with Doctrine-style constraint config (xabbuh) + * bug #60774 [FrameworkBundle] Fixes getting a type error when the secret you are trying to reveal could not be decrypted (jack-worman) + * bug #60779 Silence E_DEPRECATED and E_USER_DEPRECATED (nicolas-grekas) + * bug #60502 [HttpCache] Hit the backend only once after waiting for the cache lock (mpdude) + * bug #60771 [Runtime] fix compatibility with Symfony 7.4 (xabbuh) + * bug #59910 [Form] Keep submitted values when `keep_as_list` option of collection type is enabled (kells) + * bug #60638 [Form] Fix `keep_as_list` when data is not an array (MatTheCat) + * bug #60691 [DependencyInjection] Fix `ServiceLocatorTagPass` indexes handling (MatTheCat) + * bug #60676 [Form] Fix handling the empty string in NumberToLocalizedStringTransformer (gnat42) + * bug #60694 [Intl] Add missing currency (NOK) localization (en_NO) (llupa) + * bug #60711 [Intl] Ensure data consistency between alpha and numeric codes (llupa) + * bug #60724 [VarDumper] Fix dumping LazyObjectState when using VarExporter v8 (nicolas-grekas) + * bug #60693 [FrameworkBundle] ensureKernelShutdown in tearDownAfterClass (cquintana92) + * bug #60564 [FrameworkBundle] ensureKernelShutdown in tearDownAfterClass (cquintana92) + * bug #60645 [PhpUnitBridge] Skip bootstrap for PHPUnit >=10 (HypeMC) + * bug #60655 [TypeInfo] Handle `key-of` and `value-of` types (mtarld) + * bug #60640 [Mailer] use STARTTLS for SMTP with MailerSend (xabbuh) + * bug #60648 [Yaml] fix support for years outside of the 32b range on x86 arch on PHP 8.4 (nicolas-grekas) + * bug #60616 skip interactive questions asked by Composer (xabbuh) + * bug #60584 [DependencyInjection] Make `YamlDumper` quote resolved env vars if necessary (MatTheCat) + * bug #60588 [Notifier][Clicksend] Fix lack of recipient in case DSN does not have optional LIST_ID param (alifanau) + * bug #60547 [HttpFoundation] Fixed 'Via' header regex (thecaliskan) + +* 7.2.7 (2025-05-29) + + * bug #60549 [Translation] Add intl-icu fallback for MessageCatalogue metadata (pontus-mp) + * bug #60571 [ErrorHandler] Do not transform file to link if it does not exist (lyrixx) + * bug #60494 [Messenger] fix: Add argument as integer (overexpOG) + * bug #60524 [Notifier] Fix Clicksend transport (BafS) + * bug #60478 [Validator] add missing `$extensions` and `$extensionsMessage` to the `Image` constraint (xabbuh) + * bug #60484 [PhpUnitBridge] Clean up mocked features only when ``@group`` is present (HypeMC) + * bug #60490 [PhpUnitBridge] set path to the PHPUnit autoload file (xabbuh) + * bug #60423 [DependencyInjection] Make `DefinitionErrorExceptionPass` consider `IGNORE_ON_UNINITIALIZED_REFERENCE` and `RUNTIME_EXCEPTION_ON_INVALID_REFERENCE` the same (MatTheCat) + * bug #60439 [FrameworkBundle] Fix declaring field-attr tags in xml config files (nicolas-grekas) + * bug #60428 [DependencyInjection] Fix missing binding for ServiceCollectionInterface when declaring a service subscriber (nicolas-grekas) + * bug #60421 [VarExporter] Fixed lazy-loading ghost objects generation with property hooks (cheack) + * bug #60266 [Security] Exclude remember_me from default login authenticators (santysisi) + * bug #60400 [Config] Fix generated comment for multiline "info" (GromNaN) + * bug #60260 [Serializer] Prevent `Cannot traverse an already closed generator` error by materializing Traversable input (santysisi) + * bug #60292 [HttpFoundation] Encode path in `X-Accel-Redirect` header (Athorcis) + * bug #58643 [SecurityBundle] Use Composer `InstalledVersions` to check if flex is installed (andyexeter) + * bug #60275 [DoctrineBridge] Fix UniqueEntityValidator Stringable identifiers (GiuseppeArcuti, wkania) + * bug #60293 [Messenger] fix asking users to select an option if `--force` option is used in `messenger:failed:retry` command (W0rma) + * bug #60379 [Security] Avoid failing when PersistentRememberMeHandler handles a malformed cookie (Seldaek) + * bug #60373 [FrameworkBundle] Ensure `Email` class exists before using it (Kocal) + * bug #60365 [FrameworkBundle] ensure that all supported e-mail validation modes can be configured (xabbuh) + * bug #60350 [Security][LoginLink] Throw `InvalidLoginLinkException` on invalid parameters (davidszkiba) + * bug #60340 [String] fix EmojiTransliterator return type compatibility with PHP 8.5 (xabbuh) + +* 7.2.6 (2025-05-02) + + * bug #60288 [VarExporter] dump default value for property hooks if present (xabbuh) + * bug #60267 [Contracts] Fix `ServiceMethodsSubscriberTrait` for nullable service (StevenRenaux) + * bug #60268 [Contracts] Fix `ServiceSubscriberTrait` for nullable service (StevenRenaux) + * bug #60256 [Mailer][Postmark] drop the `Date` header using the API transport (xabbuh) + * bug #60258 [VarExporter] Fix: Use correct closure call for property-specific logic in $notByRef (Hakayashii, denjas) + * bug #60269 [Notifier] [Discord] Fix value limits (norkunas) + * bug #60270 [Validator] [WordCount] Treat 0 as one character word and do not exclude it (sidz) + * bug #60248 [Messenger] Revert " Add call to `gc_collect_cycles()` after each message is handled" (jwage) + * bug #60236 [String] Support nexus -> nexuses pluralization (KorvinSzanto) + * bug #60238 [Lock] read (possible) error from Redis instance where evalSha() was called (xabbuh) + * bug #60194 [Workflow] Fix dispatch of entered event when the subject is already in this marking (lyrixx) + * bug #60174 [PhpUnitBridge] properly clean up mocked features after tests have run (xabbuh) + * bug #60172 [Cache] Fix invalidating on save failures with Array|ApcuAdapter (nicolas-grekas) + * bug #60122 [Cache] ArrayAdapter serialization exception clean $expiries (bastien-wink) + * bug #60167 [Cache] Fix proxying third party PSR-6 cache items (Dmitry Danilson) + * bug #60165 [HttpKernel] Do not ignore enum in controller arguments when it has an `#[Autowire]` attribute (ruudk) + * bug #60168 [Console] Correctly convert `SIGSYS` to its name (cs278) + * bug #60166 [Security] fix(security): fix OIDC user identifier (vincentchalamon) + * bug #60124 [Validator] : fix url validation when punycode is on tld but not on domain (joelwurtz) + * bug #60137 [Config] ResourceCheckerConfigCache metadata unserialize emits warning (Colin Michoudet) + * bug #60057 [Mailer] Fix `Trying to access array offset on value of type null` error by adding null checking (khushaalan) + * bug #60094 [DoctrineBridge] Fix support for entities that leverage native lazy objects (nicolas-grekas) + * bug #60094 [DoctrineBridge] Fix support for entities that leverage native lazy objects (nicolas-grekas) + +* 7.2.5 (2025-03-28) + + * bug #60054 [Form] Use duplicate_preferred_choices to set value of ChoiceType (aleho) + * bug #60026 [Serializer] Fix ObjectNormalizer default context with named serializers (HypeMC) + * bug #60030 [Cache][DoctrineBridge][HttpFoundation][Lock][Messenger] use `Table::addPrimaryKeyConstraint()` with Doctrine DBAL 4.3+ (xabbuh) + * bug #59844 [TypeInfo] Fix `isSatisfiedBy` not traversing type tree (mtarld) + * bug #59858 Update `JsDelivrEsmResolver::IMPORT_REGEX` to support dynamic imports (natepage) + * bug #60019 [HttpKernel] Fix `TraceableEventDispatcher` when the `Stopwatch` service has been reset (lyrixx) + * bug #59975 [HttpKernel] Only remove `E_WARNING` from error level during kernel init (fritzmg) + * bug #59988 [FrameworkBundle] Remove redundant `name` attribute from `default_context` (HypeMC) + * bug #59963 [TypeInfo] Fix ``@var`` tag reading for promoted properties (mtarld) + * bug #59949 [Process] Use a pipe for stderr in pty mode to avoid mixed output between stdout and stderr (joelwurtz) + * bug #59940 [Cache] Fix missing cache data in profiler (dcmbrs) + * bug #59965 [VarExporter] Fix support for hooks and asymmetric visibility (nicolas-grekas) + * bug #59924 Extract no type ``@param`` annotation with `PhpStanExtractor` (thomasdubuffet) + * bug #59908 [Messenger] Reduce keepalive request noise (ro0NL) + * bug #59874 [Console] fix progress bar messing output in section when there is an EOL (joelwurtz) + * bug #59888 [PhpUnitBridge] don't trigger "internal" deprecations for PHPUnit Stub objects (xabbuh) + * bug #59830 [Yaml] drop comments while lexing unquoted strings (xabbuh) + * bug #59884 [VarExporter] Fix support for asymmetric visibility (nicolas-grekas) + * bug #59881 [VarExporter] Fix support for abstract properties (nicolas-grekas) + * bug #59841 [Cache] fix cache data collector on late collect (dcmbrs) + +* 7.2.4 (2025-02-26) + + * bug #59198 [Messenger] Filter out non-consumable receivers when registering `ConsumeMessagesCommand` (wazum) + * bug #59781 [Mailer] fix multiple transports default injection (fkropfhamer) + * bug #59836 [Mailer][Postmark] Set CID for attachments when it exists (IssamRaouf) + * bug #59829 [FrameworkBundle] Disable the keys normalization of the CSRF form field attributes (sukei) + * bug #59840 Fix PHP warning in GetSetMethodNormalizer when a "set()" method is defined (Pepperoni1337) + * bug #59818 [TypeInfo] Fix create union with nullable type (mtarld) + * bug #59810 [DependencyInjection] Defer check for circular references instead of skipping them (biozshock) + * bug #59811 [Validator] Synchronize IBAN formats (alexandre-daubois) + * bug #59796 [Mime] use address for body at `PathHeader` (tinect) + * bug #59803 [Semaphore] allow redis cluster/sentinel dsn (smoench) + * bug #59779 [DomCrawler] Bug #43921 Check for null parent nodes in the case of orphaned branches (ttk) + * bug #59776 [WebProfilerBundle] fix rendering notifier message options (xabbuh) + * bug #59769 Enable `JSON_PRESERVE_ZERO_FRACTION` in `jsonRequest` method (raffaelecarelle) + * bug #59774 [TwigBridge] Fix compatibility with Twig 3.21 (alexandre-daubois) + * bug #59761 [VarExporter] Fix lazy objects with hooked properties (nicolas-grekas) + * bug #59763 [HttpClient] Don't send any default content-type when the body is empty (nicolas-grekas) + * bug #59747 [Translation] check empty notes (davidvancl) + * bug #59751 [Cache] Tests for Redis Replication with cache (DemigodCode) + * bug #59752 [BrowserKit] Fix submitting forms with empty file fields (nicolas-grekas) + * bug #59742 [Notifier] [BlueSky] Change the value returned as the message ID (javiereguiluz) + * bug #59033 [WebProfilerBundle] Fix interception for non conventional redirects (Huluti) + * bug #59713 [DependencyInjection] Do not preload functions (biozshock) + * bug #59723 [DependencyInjection] Fix cloned lazy services not sharing their dependencies when dumped with PhpDumper (pvandommelen) + * bug #59727 [HttpClient] Fix activity tracking leading to negative timeout errors (nicolas-grekas) + * bug #59728 [Form][FrameworkBundle] Use auto-configuration to make the default CSRF token id apply only to the app; not to bundles (nicolas-grekas) + * bug #59262 [DependencyInjection] Fix env default processor with scalar node (tBibaut) + * bug #59699 [Serializer] Handle default context in named Serializer (HypeMC) + * bug #59640 [Security] Return null instead of empty username to fix deprecation notice (phasdev) + * bug #59661 [Lock] Fix Predis error handling (HypeMC) + * bug #59596 [Mime] use `isRendered` method to ensure we can avoid rendering an email twice (walva) + * bug #59689 [HttpClient] Fix buffering AsyncResponse with no passthru (nicolas-grekas) + * bug #59654 [HttpClient] Fix uploading files > 2GB (nicolas-grekas) + * bug #59648 [HttpClient] Fix retrying requests with `Psr18Client` and NTLM connections (nicolas-grekas, ajgarlag) + * bug #59681 [TypeInfo] Fix promoted property phpdoc reading (mtarld) + * 7.2.3 (2025-01-29) * bug #58889 [Serializer] Handle default context in Serializer (Valmonzo) diff --git a/CHANGELOG-7.3.md b/CHANGELOG-7.3.md new file mode 100644 index 0000000000000..af46cc6a27d3a --- /dev/null +++ b/CHANGELOG-7.3.md @@ -0,0 +1,374 @@ +CHANGELOG for 7.3.x +=================== + +This changelog references the relevant changes (bug and security fixes) done +in 7.3 minor versions. + +To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash +To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v7.3.0...v7.3.1 + +* 7.3.2 (2025-07-31) + + * bug #61276 [DependencyInjection] Escape parameters before resolving env placeholders (MatTheCat) + * bug #61268 [Console] [Table] Fix unnecessary wrapping (schlndh) + * bug #61085 [Lock] Fix using fractional TTLs (manuelderuiter) + * bug #61271 [Messenger] disable detecting modified indexes with DBAL 4.3 (xabbuh) + * bug #61242 [Console] [Table] Fix invalid UTF-8 due to text wrapping (schlndh) + * bug #61234 [Cache] RedisTrait::doFetch should use pipeline with GET's instead of MGET for Relay\Cluster (dorrogeray) + * bug #61246 [VarDumper] Use unique identifier for `RequestContextProvider` (ToshY) + * bug #61261 [FrameworkBundle] Fix `lint:container --resolve-env-vars` (MatTheCat) + * bug #61080 [Console] Fix `TreeHelper::addChild` when providing a string (jtattevin) + * bug #60296 [Serializer] Handle invalid mapping type property type (KorvinSzanto) + * bug #58995 [Config] Do not generate unreachable configuration paths (bobvandevijver) + * bug #60867 [WebProfilerBundle] Fix missing indent on non php files opended in the profiler (phcorp) + * bug #61233 [ObjectMapper] skip reading uninitialized values (soyuka) + * bug #61199 [JsonPath] Fix parsing invalid Unicode codepoints (nicolas-grekas) + * bug #61223 [Mailer][Brevo] Update Webhook IPs (jarbey) + * bug #61201 [Console] Fix JSON description for negatable input flags (nicolas-grekas) + * bug #61220 [Cache] fix compatibility with different Relay versions (xabbuh) + * bug #61194 [Security] Fix added $token argument to UserCheckerInterface::checkPostAuth() (nicolas-grekas) + * bug #61146 [ObjectMapper] initialize lazy objects (soyuka) + * bug #61161 [Lock] Fallback to `eval` when `LOAD` fails due to missing script (santysisi) + * bug #61151 [ObjectMapper] update promoted properties w/ an object as target (soyuka) + * bug #61158 [FrameworkBundle] Add missing html5-allow-no-tld to XSD file (nicolas-grekas) + * bug #61144 [VarDumper] Fix dumping on systems that don't have a working iconv (nicolas-grekas) + * bug #60798 [JsonPath] Handle slice selector overflow (alexandre-daubois) + * bug #61138 [Console] fix profiler with overridden `run()` method (vinceAmstoutz) + * bug #61079 [Config] Fix support for attributes on class constants and enum cases (ruudk) + * bug #61131 [Validator] error if the fields option is missing for the Collection constraint (xabbuh) + * bug #61111 [Translation] fix support of `TranslatableInterface` in `IdentityTranslator` (VincentLanglet) + * bug #61117 [Validator] fix handling required options (xabbuh) + * bug #61121 [DependencyInjection] Fix proxying services defined with an abstract class and a factory (nicolas-grekas) + * bug #61120 [DoctrineBridge] Prevent idle connection listener from running on subrequest (a.dmitryuk, dmitryuk) + * bug #61106 Fix `@var` phpdoc (fabpot) + * bug #61091 [Lock] [MongoDB] Enforce readPreference=primary and writeConcern=majority (notrix) + * bug #61105 [FrameworkBundle] fix phpdoc in `MicroKernelTrait` (santysisi) + * bug #61014 [TypeInfo] Reuse `CollectionType::mergeCollectionValueTypes` for `ConstFetchNode` (norkunas) + * bug #61076 [ExpressionLanguage] Fix dumping of null safe operator (ivantsepp) + * bug #60856 [ObjectMapper] handle non existing property errors (soyuka) + * bug #60802 [JsonPath] Improve escape sequence validation in name selector (alexandre-daubois) + * bug #60741 [Scheduler] Fix `#[AsCronTask]` not passing arguments to command (Jan Pintr, jan-pintr) + * bug #61056 [Validator] Allow mixed root on `CompoundConstraintTestCase` validator (thePanz) + * bug #61028 [Serializer] Fix `readonly` property initialization from incorrect scope (santysisi) + * bug #61073 [VarExporter] Dump implicit-nullable types as explicit to prevent the corresponding deprecation (nicolas-grekas) + * bug #61062 [Brevo Mailer] Webhook IP Addresses have changed (richardhj) + * bug #61004 [TypeInfo] Fix imported-only alias resolving (mtarld) + * bug #60975 [Form] Fix precision loss when rounding large integers in `NumberToLocalizedStringTransformer` (OskarStark) + * bug #61001 [JsonStreamer] Fix nested generated foreach loops (mttsch) + * bug #61036 [ObjectMapper] Correctly manage constructor initialization (alanpoulain) + * bug #60953 [DoctrineBridge] Restore compatibility with Doctrine ODM (pepeh) + * bug #61020 [Doctrine][FrameworkBundle][Serializer][Validator] Increase minimum version of type-info component (mitelg) + * bug #61031 [HttpClient] return early if handle has been cleaned up before (xabbuh) + * bug #60998 [TwigBridge] fix command option mode (`InputOption::VALUE_REQUIRED`) (gharlan) + * bug #60961 [TypeInfo] Fix `Type::fromValue` with empty array (norkunas) + * bug #60956 [TypeInfo] Fix `Type::fromValue` incorrectly setting object type instead of enum (norkunas) + * bug #60958 [Serializer] remove return type from `AbstractObjectNormalizer::getAllowedAttributes()` (xabbuh) + * bug #60507 [Console][Messenger] Fix: Allow `UnrecoverableExceptionInterface` to bypass retry in `RunCommandMessageHandler` (santysisi) + +* 7.3.1 (2025-06-28) + + * bug #60044 [Console] Table counts wrong column width when using colspan and `setColumnMaxWidth()` (vladimir-vv) + * bug #60042 [Console] Table counts wrong number of padding symbols in `renderCell()` method when cell contain unicode variant selector (vladimir-vv) + * bug #60594 [Cache] Fix using a `ChainAdapter` as an adapter for a pool (IndraGunawan) + * bug #60483 [HttpKernel] Fix `#[MapUploadedFile]` handling for optional file uploads (santysisi) + * bug #60413 [Serializer] Fix collect_denormalization_errors flag in defaultContext (dmbrson) + * bug #60820 [TypeInfo] Fix handling `ConstFetchNode` (norkunas) + * bug #60908 [Uid] Improve entropy of the increment for UUIDv7 (nicolas-grekas) + * bug #60914 [Console] Fix command option mode (InputOption::VALUE_REQUIRED) (gharlan) + * bug #60919 [VarDumper] Avoid deprecated call in PgSqlCaster (vrana) + * bug #60909 [TypeInfo] use an EOL-agnostic approach to parse class uses (xabbuh) + * bug #60888 [Intl] Fix locale validator when canonicalize is true (rdavaillaud) + * bug #60885 [Notifier] Update fake SMS transports to use contracts event dispatcher (paulferrett) + * bug #60894 [FrameworkBundle] also deprecate the internal rate limiter factory alias (xabbuh) + * bug #60875 [HttpFoundation] Revert " Emit PHP warning when `Response::sendHeaders()` is called while output has already been sent" (nicolas-grekas) + * bug #60840 [Validator] Add missing HasNamedArguments to some constraints (jkgroupe) + * bug #60859 [TwigBundle] fix preload unlinked class `BinaryOperatorExpressionParser` (Grummfy) + * bug #60772 [Mailer] [Transport] Send clone of `RawMessage` instance in `RoundRobinTransport` (jnoordsij) + * bug #60842 [DependencyInjection] Fix generating adapters of functional interfaces (nicolas-grekas) + * bug #60809 [Serializer] Fix `TraceableSerializer` when called from a callable inside `array_map` (OrestisZag) + * bug #60831 [ObjectMapper] Fix parameter passed to class level transform (mttsch) + * bug #60511 [Serializer] Add support for discriminator map in property normalizer (ruudk) + * bug #60780 [FrameworkBundle] Fix argument not provided to `add_bus_name_stamp_middleware` (maxbaldanza) + * bug #60826 [DependencyInjection] Fix inlining when public services are involved (nicolas-grekas) + * bug #60806 [HttpClient] Limit curl's connection cache size (nicolas-grekas) + * bug #60699 [JsonPath] Improve compliance to the RFC test suite (alexandre-daubois) + * bug #60705 [FrameworkBundle] Fix allow `loose` as an email validation mode (rhel-eo) + * bug #60759 [Messenger] Fix float value for worker memory limit (ro0NL) + * bug #60785 [Security] Handle non-callable implementations of `FirewallListenerInterface` (MatTheCat) + * bug #60781 [DomCrawler] Allow selecting `button`s by their `value` (MatTheCat) + * bug #60775 [Validator] flip excluded properties with keys with Doctrine-style constraint config (xabbuh) + * bug #60774 [FrameworkBundle] Fixes getting a type error when the secret you are trying to reveal could not be decrypted (jack-worman) + * bug #60504 [JsonPath] Fix subexpression evaluation in filters (alexandre-daubois) + * bug #60779 Silence E_DEPRECATED and E_USER_DEPRECATED (nicolas-grekas) + * bug #60502 [HttpCache] Hit the backend only once after waiting for the cache lock (mpdude) + * bug #60771 [Runtime] fix compatibility with Symfony 7.4 (xabbuh) + * bug #60719 [JsonPath] Fix support for comma separated indices (alexandre-daubois) + * bug #59910 [Form] Keep submitted values when `keep_as_list` option of collection type is enabled (kells) + * bug #60638 [Form] Fix `keep_as_list` when data is not an array (MatTheCat) + * bug #60691 [DependencyInjection] Fix `ServiceLocatorTagPass` indexes handling (MatTheCat) + * bug #60676 [Form] Fix handling the empty string in NumberToLocalizedStringTransformer (gnat42) + * bug #60694 [Intl] Add missing currency (NOK) localization (en_NO) (llupa) + * bug #60681 [JsonPath] Better handling of unicode chars in expressions (alexandre-daubois) + * bug #60711 [Intl] Ensure data consistency between alpha and numeric codes (llupa) + * bug #60724 [VarDumper] Fix dumping LazyObjectState when using VarExporter v8 (nicolas-grekas) + * bug #60693 [FrameworkBundle] ensureKernelShutdown in tearDownAfterClass (cquintana92) + * bug #60688 [Security] Keep roles when serializing tokens (nicolas-grekas) + * bug #60668 [JsonPath] Always use brackets notation with `JsonPath::key()` (alexandre-daubois) + * bug #60641 [TypeInfo] Fix type alias resolving (mtarld) + * bug #60564 [FrameworkBundle] ensureKernelShutdown in tearDownAfterClass (cquintana92) + * bug #60632 [TypeInfo] Fix merging collection value types with union types (mtarld) + * bug #60645 [PhpUnitBridge] Skip bootstrap for PHPUnit >=10 (HypeMC) + * bug #60646 [FrameworkBundle] don't register `SchedulerTriggerNormalizer` without `symfony/serializer` (xabbuh) + * bug #60655 [TypeInfo] Handle `key-of` and `value-of` types (mtarld) + * bug #60640 [Mailer] use STARTTLS for SMTP with MailerSend (xabbuh) + * bug #60648 [Yaml] fix support for years outside of the 32b range on x86 arch on PHP 8.4 (nicolas-grekas) + * bug #60626 [Ldap] Fix `LdapUser::isEqualTo` (MatTheCat) + * bug #60625 [FrameworkBundle] set NamespacedPoolInterface alias to cache.app (IndraGunawan) + * bug #60607 [WebProfilerBundle] Fix toolbar with ajax requests not closing (HypeMC) + * bug #60606 [HttpKernel] Fix Symfony 7.3 end of maintenance date (axzx) + * bug #60616 skip interactive questions asked by Composer (xabbuh) + * bug #60617 [HttpKernel] pass log level instead of exception to resolve the logger (xabbuh) + * bug #60569 [HttpKernel] Do not superseed private cache-control when no-store is set (alexander-schranz) + * bug #60584 [DependencyInjection] Make `YamlDumper` quote resolved env vars if necessary (MatTheCat) + * bug #60588 [Notifier][Clicksend] Fix lack of recipient in case DSN does not have optional LIST_ID param (alifanau) + * bug #60547 [HttpFoundation] Fixed 'Via' header regex (thecaliskan) + +* 7.3.0 (2025-05-29) + + * bug #60549 [Translation] Add intl-icu fallback for MessageCatalogue metadata (pontus-mp) + * bug #60571 [ErrorHandler] Do not transform file to link if it does not exist (lyrixx) + * bug #60542 [Webhook] Fix controller service name (HypeMC) + +* 7.3.0-RC1 (2025-05-25) + + * bug #60529 [AssetMapper] Fix SequenceParser possible infinite loop (smnandre) + * bug #60532 [Routing] Fix inline default `null` (HypeMC) + * bug #60535 [DoctrineBridge] Fix resetting the manager when using native lazy objects (HypeMC) + * bug #60500 [PhpUnitBridge] Fix cleaning up mocked features with attributes (HypeMC) + * bug #60330 [FrameworkBundle] skip messenger deduplication middleware registration when no "default" lock is configured (lyrixx) + * bug #60494 [Messenger] fix: Add argument as integer (overexpOG) + * bug #60524 [Notifier] Fix Clicksend transport (BafS) + * bug #60479 [FrameworkBundle] object mapper service definition without form (soyuka) + * bug #60478 [Validator] add missing `$extensions` and `$extensionsMessage` to the `Image` constraint (xabbuh) + * bug #60491 [ObjectMapper] added earlier skip to allow if=false when using source mapping (maciekpaprocki) + * bug #60484 [PhpUnitBridge] Clean up mocked features only when ``@group`` is present (HypeMC) + * bug #60490 [PhpUnitBridge] set path to the PHPUnit autoload file (xabbuh) + * bug #60489 [FrameworkBundle] Fix activation strategy of traceable decorators (nicolas-grekas) + * feature #60475 [Validator] Revert Slug constraint (wouterj) + * feature #60105 [JsonPath] Add `JsonPathAssertionsTrait` and related constraints (alexandre-daubois) + * bug #60423 [DependencyInjection] Make `DefinitionErrorExceptionPass` consider `IGNORE_ON_UNINITIALIZED_REFERENCE` and `RUNTIME_EXCEPTION_ON_INVALID_REFERENCE` the same (MatTheCat) + * bug #60439 [FrameworkBundle] Fix declaring field-attr tags in xml config files (nicolas-grekas) + * bug #60428 [DependencyInjection] Fix missing binding for ServiceCollectionInterface when declaring a service subscriber (nicolas-grekas) + * bug #60426 [Validator] let the `SlugValidator` accept `AsciiSlugger` results (xabbuh) + * bug #60421 [VarExporter] Fixed lazy-loading ghost objects generation with property hooks (cheack) + * bug #60419 [SecurityBundle] normalize string values to a single ExposeSecurityLevel instance (xabbuh) + * bug #60266 [Security] Exclude remember_me from default login authenticators (santysisi) + * bug #60407 [Console] Invokable command `#[Option]` adjustments (kbond) + * bug #60400 [Config] Fix generated comment for multiline "info" (GromNaN) + * bug #60260 [Serializer] Prevent `Cannot traverse an already closed generator` error by materializing Traversable input (santysisi) + * bug #60292 [HttpFoundation] Encode path in `X-Accel-Redirect` header (Athorcis) + * bug #60401 Passing more than one Security attribute is not supported (santysisi) + +* 7.3.0-BETA2 (2025-05-10) + + * bug #58643 [SecurityBundle] Use Composer `InstalledVersions` to check if flex is installed (andyexeter) + * feature #54276 [Workflow] Add support for executing custom workflow definition validators during the container compilation (lyrixx) + * feature #52981 [FrameworkBundle] Make `ValidatorCacheWarmer` and `SerializeCacheWarmer` use `kernel.build_dir` instead of `kernel.cache_dir` (Okhoshi) + * feature #54384 [TwigBundle] Use `kernel.build_dir` to store the templates known at build time (Okhoshi) + * bug #60275 [DoctrineBridge] Fix UniqueEntityValidator Stringable identifiers (GiuseppeArcuti, wkania) + * feature #59602 [Console] `#[Option]` rules & restrictions (kbond) + * feature #60389 [Console] Add support for `SignalableCommandInterface` with invokable commands (HypeMC) + * bug #60293 [Messenger] fix asking users to select an option if `--force` option is used in `messenger:failed:retry` command (W0rma) + * bug #60392 [DependencyInjection][FrameworkBundle] Fix precedence of `App\Kernel` alias and ignore `container.excluded` tag on synthetic services (nicolas-grekas) + * bug #60379 [Security] Avoid failing when PersistentRememberMeHandler handles a malformed cookie (Seldaek) + * bug #60308 [Messenger] Fix integration with newer versions of Pheanstalk (HypeMC) + * bug #60373 [FrameworkBundle] Ensure `Email` class exists before using it (Kocal) + * bug #60365 [FrameworkBundle] ensure that all supported e-mail validation modes can be configured (xabbuh) + * bug #60350 [Security][LoginLink] Throw `InvalidLoginLinkException` on invalid parameters (davidszkiba) + * bug #60366 [Console] Set description as first parameter to `Argument` and `Option` attributes (alamirault) + * bug #60361 [Console] Ensure overriding `Command::execute()` keeps priority over `__invoke()` (GromNaN) + * feature #60028 [ObjectMapper] Condition to target a specific class (soyuka) + * feature #60344 [Console] Use kebab-case for auto-guessed input arguments/options names (chalasr) + * bug #60340 [String] fix EmojiTransliterator return type compatibility with PHP 8.5 (xabbuh) + * bug #60322 [FrameworkBundle] drop the limiters option for non-compound rater limiters (xabbuh) + +* 7.3.0-BETA1 (2025-05-02) + + * feature #60232 Add PHP config support for routing (fabpot) + * feature #60102 [HttpFoundation] Add `UriSigner::verify()` that throws named exceptions (kbond) + * feature #60222 [FrameworkBundle][HttpFoundation] Add Clock support for `UriSigner` (kbond) + * feature #60226 [Uid] Add component-specific exception classes (rela589n) + * feature #60163 [TwigBridge] Allow attachment name to be set for inline images (aleho) + * feature #60186 [DependencyInjection] Add "when" argument to #[AsAlias] (Zuruuh) + * feature #60195 [Workflow] Deprecate `Event::getWorkflow()` method (lyrixx) + * feature #60193 [Workflow] Add a link to mermaid.live from the profiler (lyrixx) + * feature #60188 [JsonPath] Add two utils methods to `JsonPath` builder (alexandre-daubois) + * feature #60018 [Messenger] Reset peak memory usage for each message (TimWolla) + * feature #60155 [FrameworkBundle][RateLimiter] compound rate limiter config (kbond) + * feature #60171 [FrameworkBundle][RateLimiter] deprecate `RateLimiterFactory` alias (kbond) + * feature #60139 [Runtime] Support extra dot-env files (natepage) + * feature #60140 Notifier mercure7.3 (ernie76) + * feature #59762 [Config] Add `NodeDefinition::docUrl()` (alexandre-daubois) + * feature #60099 [FrameworkBundle][RateLimiter] default `lock_factory` to `auto` (kbond) + * feature #60112 [DoctrineBridge] Improve exception message when `EntityValueResolver` gets no mapping information (MatTheCat) + * feature #60103 [Console] Mark `AsCommand` attribute as ``@final`` (Somrlik, GromNaN) + * feature #60069 [FrameworkBundle] Deprecate setting the `collect_serializer_data` to `false` (mtarld) + * feature #60087 [TypeInfo] add TypeFactoryTrait::arrayKey() (xabbuh) + * feature #42124 [Messenger] Add `$stamps` parameter to `HandleTrait::handle` (alexander-schranz) + * feature #58200 [Notifier] Deprecate sms77 Notifier bridge (MrYamous) + * feature #58380 [WebProfilerBundle] Update the logic that minimizes the toolbar (javiereguiluz) + * feature #60039 [TwigBridge] Collect all deprecations with `lint:twig` command (Fan2Shrek) + * feature #60081 [FrameworkBundle] Enable controller service with `#[Route]` attribute (GromNaN) + * feature #60076 [Console] Deprecate returning a non-int value from a `\Closure` function set via `Command::setCode()` (yceruto) + * feature #59655 [JsonPath] Add the component (alexandre-daubois) + * feature #58805 [TwigBridge][Validator] Add the Twig constraint and its validator (sfmok) + * feature #54275 [Messenger] [Amqp] Add default exchange support (ilyachase) + * feature #60052 [Mailer][TwigBridge] Revert "Add support for translatable objects" (kbond) + * feature #59967 [Mailer][TwigBridge] Add support for translatable subject (norkunas) + * feature #58654 [FrameworkBundle] Binding for Object Mapper component (soyuka) + * feature #60040 [Messenger] Use newer version of Beanstalkd bridge library (HypeMC) + * feature #52748 [TwigBundle] Enable `#[AsTwigFilter]`, `#[AsTwigFunction]` and `#[AsTwigTest]` attributes to configure runtime extensions (GromNaN) + * feature #59831 [Mailer][Mime] Refactor S/MIME encryption handling in `SMimeEncryptionListener` (Spomky) + * feature #59981 [TypeInfo] Add `ArrayShapeType::$sealed` (mtarld) + * feature #51741 [ObjectMapper] Object to Object mapper component (soyuka) + * feature #57309 [FrameworkBundle][HttpKernel] Allow configuring the logging channel per type of exceptions (Arkalo2) + * feature #60007 [Security] Add methods param in IsCsrfTokenValid attribute (Oviglo) + * feature #59900 [DoctrineBridge] add new `DatePointType` Doctrine type (garak) + * feature #59904 [Routing] Add alias in `{foo:bar}` syntax in route parameter (eltharin) + * feature #59978 [Messenger] Add `--class-filter` option to the `messenger:failed:remove` command (arnaud-deabreu) + * feature #60024 [Console] Add support for invokable commands in `LockableTrait` (yceruto) + * feature #59813 [Cache] Enable namespace-based invalidation by prefixing keys with backend-native namespace separators (nicolas-grekas) + * feature #59902 [PropertyInfo] Deprecate `Type` (mtarld, chalasr) + * feature #59890 [VarExporter] Leverage native lazy objects (nicolas-grekas) + * feature #54545 [DoctrineBridge] Add argument to `EntityValueResolver` to set type aliases (NanoSector) + * feature #60011 [DependencyInjection] Enable multiple attribute autoconfiguration callbacks on the same class (GromNaN) + * feature #60020 [FrameworkBundle] Make `ServicesResetter` autowirable (lyrixx) + * feature #59929 [RateLimiter] Add `CompoundRateLimiterFactory` (kbond) + * feature #59993 [Form] Add input with `string` value in `MoneyType` (StevenRenaux) + * feature #59987 [FrameworkBundle] Auto-exclude DI extensions, test cases, entities and messenger messages (nicolas-grekas) + * feature #59827 [TypeInfo] Add `ArrayShapeType` class (mtarld) + * feature #59909 [FrameworkBundle] Add `--method` option to `debug:router` command (santysisi) + * feature #59913 [DependencyInjection] Leverage native lazy objects for lazy services (nicolas-grekas) + * feature #53425 [Translation] Allow default parameters (Jean-Beru) + * feature #59464 [AssetMapper] Add `--dry-run` option on `importmap:require` command (chadyred) + * feature #59880 [Yaml] Add the `Yaml::DUMP_FORCE_DOUBLE_QUOTES_ON_VALUES` flag to enforce double quotes around string values (dkarlovi) + * feature #59922 [Routing] Add `MONGODB_ID` to requirement patterns (GromNaN) + * feature #59842 [TwigBridge] Add Twig `field_id()` form helper (Legendary4226) + * feature #59869 [Cache] Add support for `valkey:` / `valkeys:` schemes (nicolas-grekas) + * feature #59862 [Messenger] Allow to close the transport connection (andrew-demb) + * feature #59857 [Cache] Add `\Relay\Cluster` support (dorrogeray) + * feature #59863 [JsonEncoder] Rename the component to `JsonStreamer` (mtarld) + * feature #52749 [Serializer] Add discriminator map to debug commmand output (jschaedl) + * feature #59871 [Form] Add support for displaying nested options in `DebugCommand` (yceruto) + * feature #58769 [ErrorHandler] Add a command to dump static error pages (pyrech) + * feature #54932 [Security][SecurityBundle] OIDC discovery (vincentchalamon) + * feature #58485 [Validator] Add `filenameCharset` and `filenameCountUnit` options to `File` constraint (IssamRaouf) + * feature #59828 [Serializer] Add `defaultType` to `DiscriminatorMap` (alanpoulain) + * feature #59570 [Notifier][Webhook] Add Smsbox support (alanzarli) + * feature #50027 [Security] OAuth2 Introspection Endpoint (RFC7662) (Spomky) + * feature #57686 [Config] Allow using an enum FQCN with `EnumNode` (alexandre-daubois) + * feature #59588 [Console] Add a Tree Helper + multiple Styles (smnandre) + * feature #59618 [OptionsResolver] Deprecate defining nested options via `setDefault()` use `setOptions()` instead (yceruto) + * feature #59805 [Security] Improve DX of recent additions (nicolas-grekas) + * feature #59822 [Messenger] Add options to specify SQS queue attributes and tags (TrePe0) + * feature #59290 [JsonEncoder] Replace normalizers by value transformers (mtarld) + * feature #59800 [Validator] Add support for closures in `When` (alexandre-daubois) + * feature #59814 [Framework] Deprecate the `framework.validation.cache` config option (alexandre-daubois) + * feature #59804 [TypeInfo] Add type alias support (mtarld) + * feature #59150 [Security] Allow using a callable with `#[IsGranted]` (alexandre-daubois) + * feature #59789 [Notifier] [Bluesky] Return the record CID as additional info (javiereguiluz) + * feature #59526 [Messenger] [AMQP] Add TransportMessageIdStamp logic for AMQP (AurelienPillevesse) + * feature #59771 [Security] Add ability for voters to explain their vote (nicolas-grekas) + * feature #59768 [Messenger][Process] add `fromShellCommandline` to `RunProcessMessage` (Staormin) + * feature #59377 [Notifier] Add Matrix bridge (chii0815) + * feature #58488 [Serializer] Fix deserializing XML Attributes into string properties (Hanmac) + * feature #59657 [Console] Add markdown format to Table (amenk) + * feature #59274 [Validator] Allow Unique constraint validation on all elements (Jean-Beru) + * feature #59704 [DependencyInjection] Add `Definition::addExcludedTag()` and `ContainerBuilder::findExcludedServiceIds()` for auto-discovering value-objects (GromNaN) + * feature #49750 [FrameworkBundle] Allow to pass signals to `StopWorkerOnSignalsListener` in XML config and as plain strings (alexandre-daubois) + * feature #59479 [Mailer] [Smtp] Add DSN param to enforce TLS/STARTTLS (ssddanbrown) + * feature #59562 [Security] Support hashing the hashed password using crc32c when putting the user in the session (nicolas-grekas) + * feature #58501 [Mailer] Add configuration for dkim and smime signers (elias-playfinder, eliasfernandez) + * feature #52181 [Security] Ability to add roles in `form_login_ldap` by ldap group (Spomky) + * feature #59712 [DependencyInjection] Don't skip classes with private constructor when autodiscovering (nicolas-grekas) + * feature #50797 [FrameworkBundle][Validator] Add `framework.validation.disable_translation` option (alexandre-daubois) + * feature #49652 [Messenger] Add `bury_on_reject` option to Beanstalkd bridge (HypeMC) + * feature #51744 [Security] Add a normalization step for the user-identifier in firewalls (Spomky) + * feature #54141 [Messenger] Introduce `DeduplicateMiddleware` (VincentLanglet) + * feature #58546 [Scheduler] Add MessageHandler result to the `PostRunEvent` (bartholdbos) + * feature #58743 [HttpFoundation] Streamlining server event streaming (yceruto) + * feature #58939 [RateLimiter] Add `RateLimiterFactoryInterface` (alexandre-daubois) + * feature #58717 [HttpKernel] Support `Uid` in `#[MapQueryParameter]` (seb-jean) + * feature #59634 [Validator] Add support for the `otherwise` option in the `When` constraint (alexandre-daubois) + * feature #59670 [Serializer] Add `NumberNormalizer` (valtzu) + * feature #59679 [Scheduler] Normalize `TriggerInterface` as `string` (valtzu) + * feature #59641 [Serializer] register named normalizer & denormalizer aliases (mathroc) + * feature #59682 [Security] Deprecate UserInterface & TokenInterface's `eraseCredentials()` (chalasr, nicolas-grekas) + * feature #59667 [Notifier] [Bluesky] Allow to attach website preview card (ppoulpe) + * feature #58300 [Security][SecurityBundle] Show user account status errors (core23) + * feature #59630 [FrameworkBundle] Add support for info on `ArrayNodeDefinition::canBeEnabled()` and `ArrayNodeDefinition::canBeDisabled()` (alexandre-daubois) + * feature #59612 [Mailer] Add attachments support for Sweego Mailer Bridge (welcoMattic) + * feature #59302 [TypeInfo] Deprecate `CollectionType` as list and not as array (mtarld) + * feature #59481 [Notifier] Add SentMessage additional info (mRoca) + * feature #58819 [Routing] Allow aliases in `#[Route]` attribute (damienfern) + * feature #59004 [AssetMapper] Detect import with a sequence parser (smnandre) + * feature #59601 [Messenger] Add keepalive support (silasjoisten) + * feature #59536 [JsonEncoder] Allow to warm up object and list (mtarld) + * feature #59565 [Console] Deprecating Command getDefaultName and getDefaultDescription methods (yceruto) + * feature #59473 [Console] Add broader support for command "help" definition (yceruto) + * feature #54744 [Validator] deprecate the use of option arrays to configure validation constraints (xabbuh) + * feature #59493 [Console] Invokable command adjustments (yceruto) + * feature #59482 [Mailer] [Smtp] Add DSN option to make SocketStream bind to IPv4 (quilius) + * feature #57721 [Security][SecurityBundle] Add encryption support to OIDC tokens (Spomky) + * feature #58599 [Serializer] Add xml context option to ignore empty attributes (qdequippe) + * feature #59368 [TypeInfo] Add `TypeFactoryTrait::fromValue` method (mtarld) + * feature #59401 [JsonEncoder] Add `JsonEncodable` attribute (mtarld) + * feature #59123 [WebProfilerBundle] Extend web profiler listener & config for replace on ajax requests (chr-hertel) + * feature #59477 [Mailer][Notifier] Add and use `Dsn::getBooleanOption()` (OskarStark) + * feature #59474 [Console] Invokable command deprecations (yceruto) + * feature #59340 [Console] Add support for invokable commands and input attributes (yceruto) + * feature #59035 [VarDumper] Add casters for object-converted resources (alexandre-daubois) + * feature #59225 [FrameworkBundle] Always display service arguments & deprecate `--show-arguments` option for `debug:container` (Florian-Merle) + * feature #59384 [PhpUnitBridge] Enable configuring mock namespaces with attributes (HypeMC) + * feature #59370 [HttpClient] Allow using HTTP/3 with the `CurlHttpClient` (MatTheCat) + * feature #50334 [FrameworkBundle][PropertyInfo] Wire the `ConstructorExtractor` class (HypeMC) + * feature #59354 [OptionsResolver] Support union of types (VincentLanglet) + * feature #58542 [Validator] Add `Slug` constraint (raffaelecarelle) + * feature #59286 [Serializer] Deprecate the `CompiledClassMetadataFactory` (mtarld) + * feature #59257 [DependencyInjection] Support `@>` as a shorthand for `!service_closure` in YamlFileLoader (chx) + * feature #58545 [String] Add `AbstractString::pascal()` method (raffaelecarelle) + * feature #58559 [Validator] [DateTime] Add `format` to error messages (sauliusnord) + * feature #58564 [HttpKernel] Let Monolog handle the creation of log folder for improved readonly containers handling (shyim) + * feature #59360 [Messenger] Implement `KeepaliveReceiverInterface` in Redis bridge (HypeMC) + * feature #58698 [Mailer] Add AhaSend Bridge (farhadhf) + * feature #57632 [PropertyInfo] Add `PropertyDescriptionExtractorInterface` to `PhpStanExtractor` (mtarld) + * feature #58786 [Notifier] [Brevo][SMS] Brevo sms notifier add options (ikerib) + * feature #59273 [Messenger] Add `BeanstalkdPriorityStamp` to Beanstalkd bridge (HypeMC) + * feature #58761 [Mailer] [Amazon] Add support for custom headers in ses+api (StudioMaX) + * feature #54939 [Mailer] Add `retry_period` option for email transport (Sébastien Despont, fabpot) + * feature #59068 [HttpClient] Add IPv6 support to NativeHttpClient (dmitrii-baranov-tg) + * feature #59088 [DependencyInjection] Make `#[AsTaggedItem]` repeatable (alexandre-daubois) + * feature #59301 [Cache][HttpKernel] Add a `noStore` argument to the `#` attribute (smnandre) + * feature #59315 [Yaml] Add compact nested mapping support to `Dumper` (gr8b) + * feature #59325 [Config] Add `ifFalse()` (OskarStark) + * feature #58243 [Yaml] Add support for dumping `null` as an empty value by using the `Yaml::DUMP_NULL_AS_EMPTY` flag (alexandre-daubois) + * feature #59291 [TypeInfo] Add `accepts` method (mtarld) + * feature #59265 [Validator] Validate SVG ratio in Image validator (maximecolin) + * feature #59129 [SecurityBundle][TwigBridge] Add `is_granted_for_user()` function (natewiebe13) + * feature #59254 [JsonEncoder] Remove chunk size definition (mtarld) + * feature #59022 [HttpFoundation] Generate url-safe hashes for signed urls (valtzu) + * feature #59177 [JsonEncoder] Add native lazyghost support (mtarld) + * feature #59192 [PropertyInfo] Add non-*-int missing types for PhpStanExtractor (wuchen90) + * feature #58515 [FrameworkBundle][JsonEncoder] Wire services (mtarld) + * feature #59157 [HttpKernel] [MapQueryString] added key argument to MapQueryString attribute (feymo) + * feature #59154 [HttpFoundation] Support iterable of string in `StreamedResponse` (mtarld) + * feature #51718 [Serializer] [JsonEncoder] Introducing the component (mtarld) + * feature #58946 [Console] Add support of millisecondes for `formatTime` (SebLevDev) + * feature #48142 [Security][SecurityBundle] User authorization checker (natewiebe13) + * feature #59075 [Uid] Add ``@return` non-empty-string` annotations to `AbstractUid` and relevant functions (niravpateljoin) + * feature #59114 [ErrorHandler] support non-empty-string/non-empty-list when patching return types (xabbuh) + * feature #59020 [AssetMapper] add support for assets pre-compression (dunglas) + * feature #58651 [Mailer][Notifier] Add webhooks signature verification on Sweego bridges (welcoMattic) + * feature #59026 [VarDumper] Add caster for Socket instances (nicolas-grekas) + * feature #58989 [VarDumper] Add caster for `AddressInfo` objects (nicolas-grekas) + diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 8af7f51d72c7d..270f687f39032 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -11,9 +11,10 @@ The Symfony Connect username in parenthesis allows to get more information - Bernhard Schussek (bschussek) - Robin Chalas (chalas_r) - Tobias Schultze (tobion) - - Grégoire Pineau (lyrixx) - Alexandre Daubois (alexandre-daubois) + - Grégoire Pineau (lyrixx) - Thomas Calvet (fancyweb) + - Oskar Stark (oskarstark) - Christophe Coevoet (stof) - Wouter de Jong (wouterj) - Jordi Boggiano (seldaek) @@ -24,25 +25,25 @@ The Symfony Connect username in parenthesis allows to get more information - Ryan Weaver (weaverryan) - Jérémy DERUSSÉ (jderusse) - Jules Pietri (heah) - - Roland Franssen - - Oskar Stark (oskarstark) + - Yonel Ceruto (yonelceruto) - Johannes S (johannes) - Kris Wallsmith (kriswallsmith) - Jakub Zalas (jakubzalas) - - Yonel Ceruto (yonelceruto) - - Hugo Hamon (hhamon) - - Tobias Nyholm (tobias) - HypeMC (hypemc) - Jérôme Tamarelle (gromnan) + - Hugo Hamon (hhamon) + - Tobias Nyholm (tobias) - Antoine Lamirault (alamirault) - Samuel ROZE (sroze) - Pascal Borreli (pborreli) - Romain Neutron - - Joseph Bielawski (stloyd) - Kevin Bond (kbond) - - Drak (drak) + - Joseph Bielawski (stloyd) + - Matthias Schmidt - Abdellatif Ait boudad (aitboudad) + - Drak (drak) - Lukas Kahwe Smith (lsmith) + - Mathias Arlaud (mtarld) - Hamza Amrouche (simperfit) - Martin Hasoň (hason) - Jeremy Mikola (jmikola) @@ -51,3834 +52,6058 @@ The Symfony Connect username in parenthesis allows to get more information - Igor Wiedler - Jan Schädlich (jschaedl) - Mathieu Lechat (mat_the_cat) - - Mathias Arlaud (mtarld) + - Vincent Langlet (deviling) - Simon André (simonandre) - Matthias Pigulla (mpdude) - Gabriel Ostrolucký (gadelat) - - Vincent Langlet (deviling) - Jonathan Wage (jwage) + - Mathieu Santostefano (welcomattic) - Valentin Udaltsov (vudaltsov) - Grégoire Paris (greg0ire) - Alexandre Salomé (alexandresalome) - William DURAND - - ornicar - Dany Maillard (maidmaid) + - stealth35 ‏ (stealth35) - Eriksen Costa + - Gábor Egyed (1ed) - Diego Saint Esteben (dosten) - - stealth35 ‏ (stealth35) - Alexander Mols (asm89) - - Gábor Egyed (1ed) - Francis Besset (francisbesset) - - Mathieu Santostefano (welcomattic) - - Titouan Galopin (tgalopin) - Pierre du Plessis (pierredup) - - David Maicher (dmaicher) + - Titouan Galopin (tgalopin) - Tomasz Kowalczyk (thunderer) + - Alexander Schranz (alexander-schranz) + - David Maicher (dmaicher) - Bulat Shakirzyanov (avalanche123) - - Dariusz Ruminski + - Gary PEGEOT (gary-p) - Iltar van der Berg - Miha Vrhovnik (mvrhov) - - Gary PEGEOT (gary-p) - - Saša Stamenković (umpirsky) - - Alexander Schranz (alexander-schranz) - Allison Guilhem (a_guilhem) + - Saša Stamenković (umpirsky) - Mathieu Piot (mpiot) - Vasilij Duško (staff) - - Sarah Khalil (saro0h) - Laurent VOULLEMIER (lvo) + - Sarah Khalil (saro0h) - Konstantin Kudryashov (everzet) + - Tomas Norkūnas (norkunas) - Guilhem N (guilhemn) - Bilal Amarni (bamarni) + - Ruud Kamphuis (ruudk) - Eriksen Costa - - Florin Patan (florinpatan) - Vladimir Reznichenko (kalessil) - - Peter Rehm (rpet) + - Florin Patan (florinpatan) - Henrik Bjørnskov (henrikbjorn) + - Peter Rehm (rpet) + - matlec - David Buchmann (dbu) - - Ruud Kamphuis (ruudk) - - Andrej Hudec (pulzarraider) - Jáchym Toušek (enumag) - - Tomas Norkūnas (norkunas) - - Christian Raue + - Andrej Hudec (pulzarraider) - Eric Clemmons (ericclemmons) - - Denis (yethee) - - Alex Pott + - Hubert Lenoir (hubert_lenoir) + - Christian Raue + - Douglas Greenshields (shieldo) - Michel Weimerskirch (mweimerskirch) + - Alex Pott - Issei Murasawa (issei_m) - Arnout Boks (aboks) - - Douglas Greenshields (shieldo) - - Frank A. Fiebig (fafiebig) + - Denis (yethee) + - Antoine Makdessi (amakdessi) - Baldini + - Frank A. Fiebig (fafiebig) - Fran Moreno (franmomu) - - Hubert Lenoir (hubert_lenoir) - Charles Sarrazin (csarrazi) - Henrik Westphal (snc) - Dariusz Górecki (canni) - - Antoine Makdessi (amakdessi) - Ener-Getick + - Massimiliano Arione (garak) + - Santiago San Martin (santysisi) + - Joel Wurtz (brouznouf) - Graham Campbell (graham) + - Luis Cordova (cordoval) - Tugdual Saunier (tucksaun) + - Phil E. Taylor (philetaylor) - Lee McDermott - Brandon Turner - - Massimiliano Arione (garak) - - Luis Cordova (cordoval) - - Phil E. Taylor (philetaylor) - - Konstantin Myakshin (koc) - - Daniel Holmes (dholmes) - Julien Falque (julienfalque) - - Toni Uebernickel (havvg) - Bart van den Burg (burgov) - - Vasilij Dusko | CREATION + - Toni Uebernickel (havvg) - Jordan Alliot (jalliot) + - Vasilij Dusko | CREATION + - Konstantin Myakshin (koc) + - Daniel Holmes (dholmes) - Théo FIDRY - - Joel Wurtz (brouznouf) + - soyuka - John Wards (johnwards) - Yanick Witschi (toflar) - - Antoine Hérault (herzult) + - Valtteri R (valtzu) - Konstantin.Myakshin - - Jeroen Spee (jeroens) + - Antoine Hérault (herzult) - Arnaud Le Blanc (arnaud-lb) - - Sebastiaan Stok (sstok) + - Jeroen Spee (jeroens) + - Tac Tacelosky (tacman1123) - Maxime STEINHAUSSER + - Sebastiaan Stok (sstok) - Rokas Mikalkėnas (rokasm) - - Tac Tacelosky (tacman1123) + - Jacob Dreesen (jdreesen) + - Brice BERNARD (brikou) - gnito-org - - Tim Nagel (merk) - - Valtteri R (valtzu) - - Chris Wilkinson (thewilkybarkid) - Jérôme Vasseur (jvasseur) + - Chris Wilkinson (thewilkybarkid) - Peter Kokot (peterkokot) - - Brice BERNARD (brikou) - - Jacob Dreesen (jdreesen) + - Tim Nagel (merk) - Nicolas Philippe (nikophil) - - Martin Auswöger - - Michal Piotrowski - - marc.weistroff - Lars Strojny (lstrojny) - - lenar + - Michal Piotrowski - Vladimir Tsykun (vtsykun) - - Włodzimierz Gajda (gajdaw) + - marc.weistroff - Javier Spagnoletti (phansys) + - Włodzimierz Gajda (gajdaw) - Adrien Brault (adrienbrault) + - Florent Morselli (spomky_) - Florian Voutzinos (florianv) - - Teoh Han Hui (teohhanhui) - Przemysław Bogusz (przemyslaw-bogusz) - Colin Frei - - excelwebzone + - Teoh Han Hui (teohhanhui) + - Alexander Schwenn (xelaris) + - Fabien Pennequin (fabienpennequin) + - Gregor Harlan (gharlan) - Paráda József (paradajozsef) - Maximilian Beckers (maxbeckers) - - Baptiste Clavié (talus) - - Alexander Schwenn (xelaris) - Maxime Helias (maxhelias) - - Fabien Pennequin (fabienpennequin) - Dāvis Zālītis (k0d3r1s) - Gordon Franke (gimler) - - Malte Schlüter (maltemaltesich) - - jeremyFreeAgent (jeremyfreeagent) - - Michael Babker (mbabker) - - Alexis Lefebvre - - Christopher Hertel (chertel) + - Baptiste Clavié (talus) - Joshua Thijssen + - Michael Babker (mbabker) - Vasilij Dusko - Daniel Wehner (dawehner) - - Robert Schönthal (digitalkaoz) - - Smaine Milianni (ismail1432) + - jeremyFreeAgent (jeremyfreeagent) - Hugo Alliaume (kocal) + - Christopher Hertel (chertel) + - Malte Schlüter (maltemaltesich) + - Alexis Lefebvre - François-Xavier de Guillebon (de-gui_f) - - Andreas Schempp (aschempp) - - noniagriconomie - - Eric GELOEN (gelo) - - Gabriel Caruso + - OGAWA Katsuhiro (fivestar) - Stefano Sala (stefano.sala) - Ion Bazan (ionbazan) + - Gabriel Caruso + - Andreas Schempp (aschempp) - Niels Keurentjes (curry684) - - OGAWA Katsuhiro (fivestar) + - Smaine Milianni (ismail1432) - Jhonny Lidfors (jhonne) - - Juti Noppornpitak (shiroyuki) - - Gregor Harlan (gharlan) + - Eric GELOEN (gelo) + - Robert Schönthal (digitalkaoz) + - David Prévot (taffit) + - Guilherme Blanco (guilhermeblanco) - Anthony MARTIN - - Sebastian Hörl (blogsh) - - Tigran Azatyan (tigranazatyan) - - Florent Mata (fmata) + - Bob van de Vijver (bobvandevijver) + - Thomas Landauer (thomas-landauer) - Jonathan Scheiber (jmsche) + - Tigran Azatyan (tigranazatyan) - Daniel Gomes (danielcsgomes) - - Hidenori Goto (hidenorigoto) - - Thomas Landauer (thomas-landauer) + - Sebastian Hörl (blogsh) - Arnaud Kleinpeter (nanocom) - - Guilherme Blanco (guilhermeblanco) - - Saif Eddin Gmati (azjezz) - - Farhad Safarov (safarov) - - SpacePossum - - Richard van Laak (rvanlaak) - - Andreas Braun - - Pablo Godel (pgodel) - - Alessandro Chitolina (alekitto) - - Jan Rosier (rosier) + - Florent Mata (fmata) + - Hidenori Goto (hidenorigoto) + - Juti Noppornpitak (shiroyuki) - Rafael Dohms (rdohms) + - Alessandro Chitolina (alekitto) + - Pablo Godel (pgodel) - Roman Martinuk (a2a4) + - Antonio J. García Lagar (ajgarlag) + - Fritz Michael Gschwantner (fritzmg) + - Saif Eddin Gmati (azjezz) + - Richard van Laak (rvanlaak) - jwdeitch - - David Prévot (taffit) - - Florent Morselli (spomky_) - - Jérôme Parmentier (lctrs) - - Ahmed TAILOULOUTE (ahmedtai) - - Simon Berger - - soyuka - - Jérémy Derussé - - Matthieu Napoli (mnapoli) - - Bob van de Vijver (bobvandevijver) - - Tomas Votruba (tomas_votruba) - - Arman Hosseini (arman) - - Sokolov Evgeniy (ewgraf) + - Farhad Safarov (safarov) + - Jan Rosier (rosier) + - Kévin THERAGE (kevin_therage) - Andréia Bohner (andreia) + - Simon Berger - Tom Van Looy (tvlooy) - Vyacheslav Pavlov + - Matthieu Napoli (mnapoli) + - Sokolov Evgeniy (ewgraf) + - Stiven Llupa (sllupa) + - Jérôme Parmentier (lctrs) + - Tomas Votruba (tomas_votruba) + - Roland Franssen + - Jérémy Derussé + - Ben Davies (bendavies) - Albert Casademont (acasademont) + - Ahmed TAILOULOUTE (ahmedtai) + - Arman Hosseini (arman) - George Mponos (gmponos) - Richard Shank (iampersistent) - - Roland Franssen :) - - Romain Monteil (ker0x) - - Sergey (upyx) - - Marco Pivetta (ocramius) - - Antonio Pauletich (x-coder264) - - Vincent Touzet (vincenttouzet) - - Fabien Bourigault (fbourigault) - - Olivier Dolbeau (odolbeau) - - Rouven Weßling (realityking) - - Daniel Burger - - Ben Davies (bendavies) - - YaFou - - Guillaume (guill) - - Clemens Tolboom + - Gocha Ossinkine (ossinkine) - Oleg Voronkovich - - Helmer Aaviksoo + - Jonathan Ingram + - Daniel Burger + - Antonio Pauletich (x-coder264) - Alessandro Lai (jean85) - - 77web - - Gocha Ossinkine (ossinkine) - - Jesse Rushlow (geeshoe) - - Matthieu Ouellette-Vachon (maoueh) - Michał Pipa (michal.pipa) - - Dawid Nowak + - Matthieu Ouellette-Vachon (maoueh) - Philipp Wahala (hifi) + - Romain Monteil (ker0x) - Jannik Zschiesche + - Jesse Rushlow (geeshoe) + - Sergey (upyx) + - YaFou + - Dawid Nowak + - Olivier Dolbeau (odolbeau) + - Indra Gunawan (indragunawan) + - Fabien Bourigault (fbourigault) + - Guillaume (guill) + - GDIBass + - Samuel NELA (snela) + - Clemens Tolboom - Amal Raghav (kertz) - - Jonathan Ingram - - Artur Kotyrba + - Vincent Touzet (vincenttouzet) - Wouter J - Tyson Andre - - Fritz Michael Gschwantner (fritzmg) - - GDIBass - - Samuel NELA (snela) - - Baptiste Leduc (korbeil) - - Vincent AUBERT (vincent) + - Rouven Weßling (realityking) + - Marco Pivetta (ocramius) + - Artur Kotyrba + - 77web + - Arnaud PETITPAS (apetitpa) + - Quynh Xuan Nguyen (seriquynh) + - Anthony GRASSIOT (antograssiot) + - Mario A. Alvarez Garcia (nomack84) + - Daniel Espendiller - Nate Wiebe (natewiebe13) - - Michael Voříšek - - zairig imad (zairigimad) - - Colin O'Dell (colinodell) - - Sébastien Alfaiate (seb33300) - - James Halsall (jaitsu) - - Christian Scheb - Mikael Pajunen + - Alan Poulain (alanpoulain) + - Clément JOBEILI (dator) - Warnar Boekkooi (boekkooi) - Justin Hileman (bobthecow) - - Anthony GRASSIOT (antograssiot) - - Dmitrii Chekaliuk (lazyhammer) - - Clément JOBEILI (dator) - - Andreas Möller (localheinz) - Marek Štípek (maryo) - - Daniel Espendiller - - Arnaud PETITPAS (apetitpa) - - Michael Käfer (michael_kaefer) + - Thomas Rabaix (rande) + - Asis Pattisahusiwa + - wkania + - Dmitrii Chekaliuk (lazyhammer) + - Alex Hofbauer (alexhofbauer) + - Marko Kaznovac (kaznovac) + - Victor Bocharsky (bocharsky_bw) + - Chi-teck - Dorian Villet (gnutix) - - Martin Hujer (martinhujer) + - Colin O'Dell (colinodell) + - Andreas Möller (localheinz) + - Sébastien Alfaiate (seb33300) + - Vincent AUBERT (vincent) + - zairig imad (zairigimad) - Sergey Linnik (linniksa) - - Richard Miller - - Quynh Xuan Nguyen (seriquynh) - - Victor Bocharsky (bocharsky_bw) - - Asis Pattisahusiwa - - Aleksandar Jakovljevic (ajakov) - - Mario A. Alvarez Garcia (nomack84) - - Thomas Rabaix (rande) - - D (denderello) - DQNEO - - Chi-teck - - Marko Kaznovac (kaznovac) + - Martin Hujer (martinhujer) + - Michael Käfer (michael_kaefer) + - Michael Voříšek + - James Halsall (jaitsu) + - D (denderello) + - Larry Garfield (crell) + - Aleksandar Jakovljevic (ajakov) + - Richard Miller + - Christian Scheb + - Baptiste Leduc (korbeil) + - Stadly - Andre Rømcke (andrerom) - - Bram Leeda (bram123) - - Patrick Landolt (scube) - - Karoly Gossler (connorhu) - - Timo Bakx (timobakx) - - Giorgio Premi - - Ruben Gonzalez (rubenrua) + - Noel Guilbert (noel) + - Martin Schuhfuß (usefulthink) - Benjamin Dulau (dbenjamin) - - Markus Fasselt (digilist) + - Guilliam Xavier + - Giorgio Premi + - Quentin Devos + - apetitpa - Denis Brumann (dbrumann) - - mcfedr (mcfedr) - - Remon van de Kamp - - Mathieu Lemoine (lemoinem) - - Christian Schmidt - Andreas Hucks (meandmymonkey) - - Indra Gunawan (indragunawan) - - Noel Guilbert (noel) - - Bastien Jaillot (bastnic) - - Soner Sayakci - - Stadly - - Stepan Anchugov (kix) - - bronze1man - - matlec - - sun (sun) - - Larry Garfield (crell) + - Timo Bakx (timobakx) + - Mathieu Lemoine (lemoinem) + - Remon van de Kamp - Leo Feyer + - Markus Fasselt (digilist) + - Bram Leeda (bram123) - Nikolay Labinskiy (e-moe) - - Martin Schuhfuß (usefulthink) - - apetitpa - - Guilliam Xavier + - Bastien Jaillot (bastnic) + - bronze1man + - Filippo Tessarotto (slamdunk) + - mcfedr (mcfedr) + - Christian Schmidt + - Loick Piera (pyrech) - Pierre Minnieur (pminnieur) - - Dominique Bongiraud - - Stiven Llupa (sllupa) - - Hugo Monteiro (monteiro) - - Dmitrii Poddubnyi (karser) - - Julien Pauli - - Michael Lee (zerustech) - - Florian Lonqueu-Brochard (florianlb) - - Joe Bennett (kralos) - - Leszek Prabucki (l3l0) + - Ruben Gonzalez (rubenrua) + - Karoly Gossler (connorhu) + - Stepan Anchugov (kix) + - sun (sun) + - Patrick Landolt (scube) + - Sven Paulus (subsven) - Wojciech Kania + - Maciej Malarz (malarzm) + - Edi Modrić (emodric) + - jeff + - Arjen van der Meijden + - Julien Brochet + - Timothée Barray (tyx) + - Evert Harmeling (evertharmeling) - Thomas Lallement (raziel057) + - Michele Orselli (orso) + - Jérémie Augustin (jaugustin) - Yassine Guedidi (yguedidi) - - François Zaninotto (fzaninotto) - - Dustin Whittle (dustinwhittle) - - Timothée Barray (tyx) - - jeff - - John Kary (johnkary) - - Võ Xuân Tiến (tienvx) - - fd6130 (fdtvui) + - Maxime Veber (nek-) + - Marcel Beerta (mazen) + - henrikbjorn - Priyadi Iman Nurcahyo (priyadi) - - Alan Poulain (alanpoulain) - Oleg Andreyev (oleg.andreyev) - - Maciej Malarz (malarzm) - - Marcin Sikoń (marphi) - - Michele Orselli (orso) - - Sven Paulus (subsven) - - Peter Kruithof (pkruithof) - - Alex Hofbauer (alexhofbauer) - - Maxime Veber (nek-) - - Valentine Boineau (valentineboineau) - - Rui Marinho (ruimarinho) - - Filippo Tessarotto (slamdunk) - Jeroen Noten (jeroennoten) - - Possum - - Jérémie Augustin (jaugustin) - - Edi Modrić (emodric) - - Pascal Montoya - - Loick Piera (pyrech) - - Julien Brochet + - Dustin Whittle (dustinwhittle) + - Võ Xuân Tiến (tienvx) + - Peter Kruithof (pkruithof) + - Jonathan H. Wage + - Marcin Sikoń (marphi) + - Michael Lee (zerustech) + - Jan Sorgalla (jsor) - François Pluchino (francoispluchino) + - Dmitrii Poddubnyi (karser) + - Hugo Monteiro (monteiro) + - fd6130 (fdtvui) - Tristan Darricau (tristandsensio) - - Jan Sorgalla (jsor) - - henrikbjorn - - Marcel Beerta (mazen) - - Evert Harmeling (evertharmeling) + - Leszek Prabucki (l3l0) + - Valentine Boineau (valentineboineau) + - Joe Bennett (kralos) + - Florian Lonqueu-Brochard (florianlb) + - Rui Marinho (ruimarinho) - Mantis Development - - Hidde Wieringa (hiddewie) - - dFayet - - Rob Frawley 2nd (robfrawley) - - Renan (renanbr) - - Jonathan H. Wage - - Nikita Konstantinov (unkind) - - Dariusz + - John Kary (johnkary) + - François Zaninotto (fzaninotto) + - Pascal Montoya + - Félix Labrecque (woodspire) + - Alexander Kotynia (olden) - Daniel Gorgan - - Francois Zaninotto + - Joseph Rouff (rouffj) + - Jordan Samouh (jordansamouh) + - Iker Ibarguren (ikerib) + - Eugene Leonovich (rybakit) + - Lynn van der Berg (kjarli) + - Marc Weistroff (futurecat) + - Pierre-Yves Lebecq (pylebecq) - Daniel Tschinder + - David Badura (davidbadura) - Christian Schmidt - - Alexander Kotynia (olden) - - Elnur Abdurrakhimov (elnur) - - Manuel Reinhard (sprain) - - Zan Baldwin (zanbaldwin) - - Tim Goudriaan (codedmonkey) - - Antonio J. García Lagar (ajgarlag) - - BoShurik - - Quentin Devos - Adam Prager (padam87) - Benoît Burnichon (bburnichon) - - maxime.steinhausser - - Iker Ibarguren (ikerib) - Roman Ring (inori) + - Patrick McDougle (patrick-mcdougle) + - Uwe Jäger (uwej711) + - Thomas Adam + - Chekote + - Michaël Perrin (michael.perrin) - Xavier Montaña Carreras (xmontana) - - Arjen van der Meijden + - Arjen Brouwer (arjenjb) + - Xavier Perez + - Aurélien Pillevesse (aurelienpillevesse) + - BoShurik + - Philipp Cordes (corphi) + - Zan Baldwin (zanbaldwin) + - Rob Frawley 2nd (robfrawley) + - javaDeveloperKid + - Anderson Müller + - jdhoek + - Kyle + - Bob den Otter (bopp) + - Marvin Petker + - Hidde Wieringa (hiddewie) - Romaric Drigon (romaricdrigon) + - Manuel Reinhard (sprain) - Sylvain Fabre (sylfabre) - - Xavier Perez - - Arjen Brouwer (arjenjb) - - Artem Lopata - - Patrick McDougle (patrick-mcdougle) + - Adrian Rudnik (kreischweide) + - dFayet + - Sullivan SENECHAL (soullivaneuh) + - Nikita Konstantinov (unkind) + - Matthieu Lempereur (mryamous) - Arnt Gulbrandsen - Michel Roca (mroca) - - Marc Weistroff (futurecat) + - Renan (renanbr) + - Ray + - roman joly (eltharin) + - Benjamin Leveque (benji07) + - Emanuele Panzeri (thepanz) + - Jurica Vlahoviček (vjurica) + - maxime.steinhausser + - Dariusz Ruminski - Michał (bambucha15) - Danny Berger (dpb587) - Alif Rachmawadi - - Anton Chernikov (anton_ch1989) - - Pierre-Yves Lebecq (pylebecq) - - Benjamin Leveque (benji07) - - Jordan Samouh (jordansamouh) - - David Badura (davidbadura) - - Sullivan SENECHAL (soullivaneuh) - - Uwe Jäger (uwej711) - - javaDeveloperKid - - W0rma - - Lynn van der Berg (kjarli) - - Michaël Perrin (michael.perrin) - - Eugene Leonovich (rybakit) - - Joseph Rouff (rouffj) - - Félix Labrecque (woodspire) - - Marvin Petker - - GordonsLondon - - Ray - - Philipp Cordes (corphi) - - Chekote - - Thomas Adam - - Anderson Müller - - jdhoek - - Jurica Vlahoviček (vjurica) - - Bob den Otter (bopp) - Thomas Schulz (king2500) - - Kyle - - Dariusz Rumiński - - Philippe SEGATORI (tigitz) - - Frank de Jonge - - Andrii Bodnar - - Dane Powell - - Sebastien Morel (plopix) - - Christopher Davis (chrisguitarguy) - - Loïc Frémont (loic425) - - Matthieu Auger (matthieuauger) - - Sergey Belyshkin (sbelyshkin) - - Kévin THERAGE (kevin_therage) - - Herberto Graca - - Yoann RENARD (yrenard) - - Josip Kruslin (jkruslin) - - renanbr + - Francois Zaninotto + - GordonsLondon + - Tim Goudriaan (codedmonkey) + - Elnur Abdurrakhimov (elnur) + - Fabien S (bafs) + - Chris Smith (cs278) + - Anton Chernikov (anton_ch1989) + - Damien Alexandre (damienalexandre) + - jaugustin + - Marco Petersen (ocrampete16) + - Ismael Ambrosi (iambrosi) - Sébastien Lavoie (lavoiesl) - - Alex Rock (pierstoval) - - Aurélien Pillevesse (aurelienpillevesse) - - Matthieu Lempereur (mryamous) - - Wodor Wodorski - - Beau Simensen (simensen) - - Magnus Nordlander (magnusnordlander) - - Robert Kiss (kepten) + - corradogrimoldi + - Tiago Ribeiro (fixe) + - Pascal Luna (skalpa) + - Aurelijus Valeiša (aurelijus) + - Vilius Grigaliūnas - Alexandre Quercia (alquerci) - - Marcos Sánchez - - Emanuele Panzeri (thepanz) - - Zmey - - Kim Hemsø Rasmussen (kimhemsoe) + - Josip Kruslin (jkruslin) + - Manuel Kießling (manuelkiessling) + - Lee Rowlands + - Raphaël Geffroy (raphael-geffroy) + - Simon Podlipsky (simpod) + - a.dmitryuk + - Dominique Bongiraud + - Warxcell (warxcell) + - Wodor Wodorski + - realmfoo - Maximilian Reichel (phramz) - - Samaël Villette (samadu61) - - jaugustin - - Pascal Luna (skalpa) - - Wouter Van Hecke - Baptiste Lafontaine (magnetik) - - Michael Hirschler (mvhirsch) - - Michael Holm (hollo) - - Robert Meijers + - Christopher Davis (chrisguitarguy) + - Jack Worman (jworman) + - Alex Rock (pierstoval) + - Serkan Yildiz (srknyldz) - Blanchon Vincent (blanchonvincent) - - Cédric Anne - - Christian Schmidt - Ben Hakim - - Marco Petersen (ocrampete16) - - Bohan Yang (brentybh) - - Vilius Grigaliūnas - - Jordane VASPARD (elementaire) - - Chris Smith (cs278) - - Thomas Bisignani (toma) - - Florian Klein (docteurklein) - - Raphaël Geffroy (raphael-geffroy) - - Damien Alexandre (damienalexandre) - - Manuel Kießling (manuelkiessling) - - Alexey Kopytko (sanmai) - - Warxcell (warxcell) - - Atsuhiro KUBO (iteman) + - Sergey Belyshkin (sbelyshkin) + - Christian Schmidt + - Samaël Villette (samadu61) + - Bertrand Zuchuat (garfield-fr) - rudy onfroy (ronfroy) - - Serkan Yildiz (srknyldz) + - Marcos Sánchez + - Yoann RENARD (yrenard) + - Matthieu Auger (matthieuauger) - Andrew Moore (finewolf) - - Bertrand Zuchuat (garfield-fr) - - Marc Morera (mmoreram) - - Gabor Toth (tgabi333) - - realmfoo - - Joppe De Cuyper (joppedc) - - Fabien S (bafs) - - Simon Podlipsky (simpod) - Thomas Tourlourat (armetiz) - - Andrey Esaulov (andremaha) + - Philippe SEGATORI (tigitz) + - Herberto Graca + - Francesc Rosàs (frosas) + - Frank de Jonge + - Florian Klein (docteurklein) + - Joppe De Cuyper (joppedc) + - Cédric Anne + - Michael Hirschler (mvhirsch) + - Bohan Yang (brentybh) - Grégoire Passault (gregwar) + - SiD (plbsid) + - Raul Fraile (raulfraile) + - Jordane VASPARD (elementaire) + - Mathieu Rochette (mathroc) + - Wouter Van Hecke + - Kim Hemsø Rasmussen (kimhemsoe) + - Pavel Batanov (scaytrase) + - Alexey Kopytko (sanmai) - Jerzy Zawadzki (jzawadzki) - - Ismael Ambrosi (iambrosi) - - Craig Duncan (duncan3dc) - - Emmanuel BORGES + - Andrii Bodnar + - Michael Holm (hollo) - Karoly Negyesi (chx) - - Aurelijus Valeiša (aurelijus) - Jan Decavele (jandc) + - Andrey Esaulov (andremaha) + - Atsuhiro KUBO (iteman) + - Craig Duncan (duncan3dc) + - Emanuele Gaspari (inmarelibero) + - Robert Kiss (kepten) + - Magnus Nordlander (magnusnordlander) + - Dane Powell + - Emmanuel BORGES + - Benjamin Morel + - Marc Morera (mmoreram) + - Gabor Toth (tgabi333) + - Loïc Frémont (loic425) + - Pierre Ambroise (dotordu) + - janschoenherr + - Beau Simensen (simensen) + - Ivan Kurnosov - Gustavo Piltcher - - Lee Rowlands - Stepan Tanasiychuk (stfalcon) - - Ivan Kurnosov - - Tiago Ribeiro (fixe) - - Raul Fraile (raulfraile) - - Adrian Rudnik (kreischweide) - - Pavel Batanov (scaytrase) - - Francesc Rosàs (frosas) - - Bongiraud Dominique - - janschoenherr - - Emanuele Gaspari (inmarelibero) - - Artem (artemgenvald) - - Thierry T (lepiaf) - - Lorenz Schori - - Lukáš Holeczy (holicz) - - Jeremy Livingston (jeremylivingston) - - ivan - - SUMIDA, Ippei (ippey_s) + - Thomas Bisignani (toma) + - renanbr + - Sebastien Morel (plopix) + - Dimitri Gritsajuk (ottaviano) + - Rhodri Pugh (rodnaph) + - Dalibor Karlović + - Clara van Miert + - Eric Masoero (eric-masoero) - Urinbayev Shakhobiddin (shokhaa) + - Pavel Kirpitsov (pavel-kirpichyov) + - Joe Lencioni + - Pierre Rineau + - Pavel Volokitin (pvolok) + - ShinDarth + - Kirill chEbba Chebunin + - Jakub Kucharovic (jkucharovic) - Ahmed Raafat - Philippe Segatori - - Thibaut Cheymol (tcheymol) - - Erin Millard - - Matthew Lewinski (lewinski) - - Islam Israfilov (islam93) - - Ricard Clau (ricardclau) - - Roumen Damianoff - - Thomas Royer (cydonia7) - - Nicolas LEFEVRE (nicoweb) - - Asmir Mustafic (goetas) - - Mateusz Sip (mateusz_sip) - - Francesco Levorato - - Vitaliy Zakharov (zakharovvi) - - Tobias Sjösten (tobiassjosten) - - Gyula Sallai (salla) - - Hendrik Luup (hluup) - - Inal DJAFAR (inalgnu) - - C (dagardner) - - Martin Herndl (herndlm) - - Dmytro Borysovskyi (dmytr0) - - Johann Pardanaud - - Pierre Rineau - - Kai Dederichs - - Pavel Kirpitsov (pavel-kirpichyov) - - Artur Eshenbrener - - Harm van Tilborg (hvt) - - Thomas Perez (scullwm) - Gwendolen Lynch - - smoench - - Felix Labrecque - - mondrake (mondrake) + - Grzegorz (Greg) Zdanowski (kiler129) + - Thomas Perez (scullwm) - Yaroslav Kiliba + - Raffaele Carelle + - ivan + - Anthon Pang (robocoder) + - Vitalii Ekert (comrade42) + - Kieran Brahney + - Sanpi (sanpi) + - Lorenz Schori + - Alex (aik099) + - Thierry T (lepiaf) - FORT Pierre-Louis (plfort) - - Jan Böhmer - - Terje Bråten + - Hamza Makraz (makraz) + - Vladyslav Loboda - Gonzalo Vilaseca (gonzalovilaseca) - - Tarmo Leppänen (tarlepp) - - Jakub Kucharovic (jkucharovic) + - Diego Agulló (aeoris) - Daniel STANCU - - Kristen Gilden - - Robbert Klarenbeek (robbertkl) - - Hamza Makraz (makraz) - - Eric Masoero (eric-masoero) - - Vitalii Ekert (comrade42) - - Clara van Miert - - Haralan Dobrev (hkdobrev) - - hossein zolfi (ocean) - - Alexander Menshchikov - - Clément Gautier (clementgautier) - - roman joly (eltharin) - - James Gilliland (neclimdul) - - Sanpi (sanpi) - Eduardo Gulias (egulias) - - giulio de donato (liuggio) - - Ivan Mezinov - - ShinDarth - - Stéphane PY (steph_py) - - Cătălin Dan (dancatalin) - - Philipp Kräutli (pkraeutli) - - Rhodri Pugh (rodnaph) - - BrokenSourceCode - - Grzegorz (Greg) Zdanowski (kiler129) - - Dimitri Gritsajuk (ottaviano) - - Kirill chEbba Chebunin - - Pol Dellaiera (drupol) - - Alex (aik099) - - Kieran Brahney - - Fabien Villepinte - - SiD (plbsid) - - Greg Thornton (xdissent) - - Alex Bowers - - Kev - - kor3k kor3k (kor3k) - - Costin Bereveanu (schniper) - - Andrii Dembitskyi - - Gasan Guseynov (gassan) - - Marek Kalnik (marekkalnik) + - Vincent Chalamon - Vyacheslav Salakhutdinov (megazoll) - - Maksym Slesarenko (maksym_slesarenko) - - Marc Biorklund (mbiork) - - Hassan Amouhzi - - Tamas Szijarto - - Michele Locati - - Yannick Ihmels (ihmels) - - Pavel Volokitin (pvolok) - - Arthur de Moulins (4rthem) - - Matthias Althaus (althaus) - - Saif Eddin G - - Endre Fejes - - Tobias Naumann (tna) - - Mathieu Rochette (mathroc) - - Daniel Beyer - - Ivan Sarastov (isarastov) + - Cătălin Dan (dancatalin) - flack (flack) - - Shein Alexey - - Joe Lencioni - - Daniel Tschinder - - Diego Agulló (aeoris) + - Christophe L. (christophelau) + - Hassan Amouhzi + - Johann Pardanaud + - Kev + - Asmir Mustafic (goetas) + - Ivan Mezinov + - Pol Dellaiera (drupol) + - Islam Israfilov (islam93) - vladimir.reznichenko + - Nicolas LEFEVRE (nicoweb) + - smoench + - Issam Raouf (iraouf) + - Thomas Royer (cydonia7) + - Vadim Kharitonov (vadim) + - Clément Gautier (clementgautier) - Kai - - Alain Hippolyte (aloneh) - - Grenier Kévin (mcsky_biig) - - Xavier HAUSHERR - - Albert Jessurum (ajessu) - - Romain Pierre + - C (dagardner) + - BrokenSourceCode + - Endre Fejes - Laszlo Korte - - Alessandro Desantis + - Mateusz Sip (mateusz_sip) + - mondrake (mondrake) + - Tarmo Leppänen (tarlepp) + - Michele Locati + - Hendrik Luup (hluup) + - Pablo Lozano (arkadis) + - Greg Thornton (xdissent) + - James Gilliland (neclimdul) + - Felix Labrecque + - Ben Scott (bpscott) - hubert lecorche (hlecorche) - - Vladyslav Loboda + - Roumen Damianoff + - Alain Hippolyte (aloneh) + - Ricard Clau (ricardclau) + - Zmey + - Marc Biorklund (mbiork) + - Arthur de Moulins (4rthem) + - Jan Böhmer + - Albert Jessurum (ajessu) + - Maksym Slesarenko (maksym_slesarenko) + - Karel Souffriau - Marc Morales Valldepérez (kuert) - - Vadim Kharitonov (vadim) + - Tobias Naumann (tna) + - Terje Bråten + - Francesco Levorato + - Dmytro Borysovskyi (dmytr0) + - Matthias Althaus (althaus) + - Kristen Gilden + - SUMIDA, Ippei (ippey_s) - Oscar Cubo Medina (ocubom) - - Karel Souffriau - - Christophe L. (christophelau) - - a.dmitryuk - - Anthon Pang (robocoder) + - Valmonzo + - Grenier Kévin (mcsky_biig) + - Link1515 + - Ivan Sarastov (isarastov) + - kor3k kor3k (kor3k) + - Erin Millard + - Daniel Beyer + - Robbert Klarenbeek (robbertkl) + - Thibaut Cheymol (tcheymol) + - Yannick Ihmels (ihmels) + - Martin Herndl (herndlm) + - Haralan Dobrev (hkdobrev) + - Gasan Guseynov (gassan) + - Nathanael Noblet (gnat) + - Tobias Sjösten (tobiassjosten) + - Xavier HAUSHERR + - Fabien Villepinte + - Stéphane PY (steph_py) + - Matthew Lewinski (lewinski) + - Daniel Tschinder + - giulio de donato (liuggio) + - Harm van Tilborg (hvt) + - Alessandro Desantis + - Marek Kalnik (marekkalnik) + - Alex Bowers + - Vitaliy Zakharov (zakharovvi) + - Artem (artemgenvald) + - Costin Bereveanu (schniper) + - Inal DJAFAR (inalgnu) + - Jeremy Livingston (jeremylivingston) + - hossein zolfi (ocean) + - Shein Alexey + - Gyula Sallai (salla) + - Soner Sayakci + - Philipp Kräutli (pkraeutli) + - Lukáš Holeczy (holicz) - Julien Galenski (ruian) - - Ben Scott (bpscott) - - Shyim - - Pablo Lozano (arkadis) - - Brian King - - quentin neyrat (qneyrat) - - Chris Tanaskoski (devristo) - - Steffen Roßkamp - - Andrey Lebedev (alebedev) - - Alexandru Furculita (afurculita) - - Michel Salib (michelsalib) - - Ben Roberts (benr77) - - Ahmed Ghanem (ahmedghanem00) - - Valentin Jonovs - - geoffrey - - Quentin Dequippe (qdequippe) - - Benoit Galati (benoitgalati) + - Andrii Dembitskyi - Benjamin (yzalis) - - Jeanmonod David (jeanmonod) - - Webnet team (webnet) - - Tobias Bönner - - Nicolas Rigaud - - Ben Ramsey (ramsey) - - Berny Cantos (xphere81) + - Tri Pham (phamuyentri) + - Marcos Rezende (rezende79) + - Boris Vujicic (boris.vujicic) + - Marcin Chyłek (songoq) + - Chris Sedlmayr (catchamonkey) + - Anthony Ferrara + - Steffen Roßkamp + - nikos.sotiropoulos + - Restless-ET + - Jonas Elfering + - Matthias Krauser (mkrauser) + - Desjardins Jérôme (jewome62) + - Peter Bowyer (pbowyer) - Antonio Jose Cerezo (ajcerezo) - - Maelan LE BORGNE - - Thomas Talbot (ioni) - - Marcin Szepczynski (czepol) - - Lescot Edouard (idetox) - - Dennis Fridrich (dfridrich) - - Mohammad Emran Hasan (phpfour) + - Mathias STRASSER (roukmoute) - Florian Merle (florian-merle) - - Dmitriy Mamontov (mamontovdmitriy) - - Jan Schumann - - Matheo Daninos (mathdns) - - Neil Peyssard (nepey) - - Niklas Fiekas + - Fabrice Bernhard (fabriceb) + - Johan Vlaar (johjohan) + - Andrew Udvare (audvare) + - François Dume (franek) + - Robert-Jan de Dreu + - Michel Salib (michelsalib) + - simon chrzanowski (simonch) + - Jerzy Lekowski (jlekowski) + - Rob Bast + - William Arslett (warslett) + - Arnaud De Abreu (arnaud-deabreu) + - Evan S Kaufman (evanskaufman) + - Krzysztof Piasecki (krzysztek) + - Denis Gorbachev (starfall) + - Jérôme Vieilledent (lolautruche) + - Jannik Zschiesche - Mark Challoner (markchalloner) - - Raffaele Carelle - - Andreas Hennings - - Markus Bachmann (baachi) - - Gunnstein Lye (glye) - - Erkhembayar Gantulga (erheme318) - - Yi-Jyun Pan - - Sergey Melesh (sergex) - - Greg Anderson - - lancergr - - Benjamin Zaslavsky (tiriel) - - Tri Pham (phamuyentri) - - Angelov Dejan (angelov) - - Ivan Nikolaev (destillat) + - Brian King + - Jonas Flodén (flojon) + - Arkadius Stefanski (arkadius) - Gildas Quéméner (gquemener) - - Ioan Ovidiu Enache (ionutenache) - - Maxim Dovydenok (dovydenok-maxim) - - Laurent Masforné (heisenberg) - - Claude Khedhiri (ck-developer) - - Benjamin Georgeault (wedgesama) - - Desjardins Jérôme (jewome62) - - Arturs Vonda - - Matthew Smeets + - Benjamin Zaslavsky (tiriel) + - Trent Steel (trsteel88) + - Shakhobiddin + - Jakub Škvára (jskvara) + - Ilija Tovilo (ilijatovilo) + - Ben Roberts (benr77) + - Zbigniew Malcherczyk (ferror) + - Tobias Bönner + - Quentin Schuler (sukei) + - Matthieu Bontemps + - Lescot Edouard (idetox) - Toni Rudolf (toooni) + - Erik Trapman + - Kurt Thiemann + - Martin Kirilov (wucdbm) + - Grummfy (grummfy) + - Berny Cantos (xphere81) + - Marcin Michalski (marcinmichalski) + - Petr Duda (petrduda) + - Christoph Mewes (xrstf) + - Yi-Jyun Pan + - Markus Staab + - Ben Ramsey (ramsey) + - Alexandru Furculita (afurculita) - Stefan Gehrig (sgehrig) - - vagrant - - Matthias Krauser (mkrauser) - - Benjamin Cremer (bcremer) - - Maarten de Boer (mdeboer) - - Asier Illarramendi (doup) - - AKeeman (akeeman) - - Martijn Cuppens - - Restless-ET - - Vlad Gregurco (vgregurco) + - Disquedur + - Manuel de Ruiter (manuel) + - Miro Michalicka + - Hans Mackowiak + - Joachim Løvgaard (loevgaard) + - Angelov Dejan (angelov) + - Norbert Orzechowicz (norzechowicz) + - Neil Peyssard (nepey) + - quentin neyrat (qneyrat) + - Romain Gautier (mykiwi) + - Eugene Wissner + - Ivan Rey (ivanrey) + - Nate (frickenate) + - Roy Van Ginneken (rvanginneken) - Artem Stepin (astepin) - - Jérémy DECOOL (jdecool) - - Boris Vujicic (boris.vujicic) - - Dries Vints + - Sergio Santoro + - Thomas Talbot (ioni) + - Scott Arciszewski + - Arturs Vonda + - Ziumin + - Tobias Weichart + - Sander Toonen (xatoo) + - Niklas Fiekas + - battye + - Jérôme Macias (jeromemacias) + - Bhavinkumar Nakrani (bhavin4u) + - Matthijs van den Bos (matthijs) - Judicaël RUFFIEUX (axanagor) - - Chris Sedlmayr (catchamonkey) - DerManoMann - - Jérôme Tanghe (deuchnord) - - Mathias STRASSER (roukmoute) - - simon chrzanowski (simonch) - - Kamil Kokot (pamil) - - Seb Koelen - - Christoph Mewes (xrstf) - - Andrew M-Y (andr) - - Krasimir Bosilkov (kbosilkov) - - Marcin Michalski (marcinmichalski) - - Vitaliy Tverdokhlib (vitaliytv) + - W0rma + - Erkhembayar Gantulga (erheme318) + - Philipp Rieber (bicpi) - Ariel Ferrandini (aferrandini) - - BASAK Semih (itsemih) - - Dirk Pahl (dirkaholic) - - Cédric Lombardot (cedriclombardot) - - Jérémy REYNAUD (babeuloula) - - Faizan Akram Dar (faizanakram) - - Arkadius Stefanski (arkadius) - - Jonas Flodén (flojon) - - AnneKir - - Tobias Weichart - - Arnaud POINTET (oipnet) - - Tristan Pouliquen - - Miro Michalicka - - M. Vondano - - Dominik Zogg - - Maximilian Zumbansen + - Mohammad Emran Hasan (phpfour) + - Jérémy DECOOL (jdecool) + - Roman Anasal - Vadim Borodavko (javer) - - Tavo Nieves J (tavoniievez) - - Luc Vieillescazes (iamluc) - - Erik Saunier (snickers) - - François Dume (franek) - - Jerzy Lekowski (jlekowski) - - Raulnet + - Chad Sikorra (chadsikorra) + - Tom Klingenberg + - Benoit Galati (benoitgalati) + - Filip Procházka (fprochazka) + - Jérémy M (th3mouk) + - Jacek Jędrzejewski (jacek.jedrzejewski) + - AnneKir + - Maarten de Boer (mdeboer) - Petrisor Ciprian Daniel - - Oleksiy (alexndlm) - - William Arslett (warslett) - - Giso Stallenberg (gisostallenberg) - - Rob Bast - - Roberto Espinoza (respinoza) - - Marvin Feldmann (breyndotechse) - - Soufian EZ ZANTAR (soezz) - - Marek Zajac - - Adam Harvey + - Marcin Szepczynski (czepol) + - Yoshio HANAWA + - R. Achmad Dadang Nur Hidayanto (dadangnh) + - ReenExe - Klaus Silveira (klaussilveira) - - ilyes kooli (skafandri) - - Anton Bakai - - battye - - Nicolas Dousson - - Axel Guckelsberger (guite) - - Sam Fleming (sam_fleming) - - Alex Bakhturin - - Belhassen Bouchoucha (crownbackend) - - Patrick Reimers (preimers) - - Brayden Williams (redstar504) - - insekticid - - Jérémy M (th3mouk) - - Trent Steel (trsteel88) - - boombatower - Alireza Mirsepassi (alirezamirsepassi) - - Jérôme Macias (jeromemacias) - - Andrey Astakhov (aast) - - ReenExe - - Fabian Lange (codingfabian) - - kylekatarnls (kylekatarnls) - - Yoshio HANAWA - - Jan van Thoor (janvt) - - Joshua Nye - - Martin Kirilov (wucdbm) - - Koen Reiniers (koenre) - - Kurt Thiemann - - Nathan Dench (ndenc2) - - Gijs van Lammeren - - Sebastian Bergmann - - Nadim AL ABDOU (nadim) - - Matthew Grasmick - - Miroslav Šustek (sustmi) - - Pablo Díez (pablodip) - - Kevin McBride - - Sergio Santoro - - Jonas Elfering - - Philipp Rieber (bicpi) - - Dmitriy Derepko - - Manuel de Ruiter (manuel) - - Nathanael Noblet (gnat) - - nikos.sotiropoulos - - BENOIT POLASZEK (bpolaszek) - - Eduardo Oliveira (entering) - - Oleksii Zhurbytskyi - - Bilge - - Anatoly Pashin (b1rdex) + - Maxime Pinot (maximepinot) + - lancergr + - Ivan Nikolaev (destillat) + - Chris Tanaskoski (devristo) - Jonathan Johnson (jrjohnson) - - Eugene Wissner - - Ricardo Oliveira (ricardolotr) - - Roy Van Ginneken (rvanginneken) - - ondrowan - - Barry vd. Heuvel (barryvdh) - - Antonin CLAUZIER (0x346e3730) - - Chad Sikorra (chadsikorra) - - Evan S Kaufman (evanskaufman) - - mcben - - Jérôme Vieilledent (lolautruche) - - Roman Anasal - - Filip Procházka (fprochazka) - - Sergey Panteleev - - Jeroen Thora (bolle) - - Markus Lanthaler (lanthaler) + - Korvin Szanto + - Soufian EZ ZANTAR (soezz) - Gigino Chianese (sajito) - - Remi Collet - - Piotr Kugla (piku235) - - Vicent Soria Durá (vicentgodella) - - Michael Moravec - - Leevi Graham (leevigraham) - - Anthony Ferrara - - tim - - Ioan Negulescu - - Greg ORIOL - - Jakub Škvára (jskvara) - - Andrew Udvare (audvare) - - siganushka (siganushka) - - alexpods - - Adam Szaraniec - - Dariusz Ruminski - - Bahman Mehrdad (bahman) - - Pierre Ambroise (dotordu) - - Romain Gautier (mykiwi) - - Link1515 - - Matthieu Bontemps - - Erik Trapman + - Valentin Jonovs + - NickSdot + - Erik Saunier (snickers) + - Maximilian Ruta (deltachaos) + - Dmitriy Mamontov (mamontovdmitriy) + - Maxim Dovydenok (dovydenok-maxim) + - M. Vondano + - Mokhtar Tlili (sf-djuba) + - Asier Illarramendi (doup) + - Krasimir Bosilkov (kbosilkov) - De Cock Xavier (xdecock) - - Zbigniew Malcherczyk (ferror) - - Nicolas Dewez (nicolas_dewez) + - Zach Badgett (zachbadgett) + - Miroslav Šustek (sustmi) + - Joshua Nye + - Daniel Tiringer + - Dennis Fridrich (dfridrich) + - Greg ORIOL + - Tavo Nieves J (tavoniievez) + - Remi Collet + - Sam Fleming (sam_fleming) + - Axel Guckelsberger (guite) + - Pablo Díez (pablodip) + - Adam Harvey - Denis Kulichkin (onexhovia) - - Scott Arciszewski - - Xavier HAUSHERR - - Norbert Orzechowicz (norzechowicz) - - Robert-Jan de Dreu - - Fabrice Bernhard (fabriceb) - - Matthijs van den Bos (matthijs) - - Markus S. (staabm) - - PatNowak - - Bhavinkumar Nakrani (bhavin4u) - - Jaik Dean (jaikdean) - - Krzysztof Piasecki (krzysztek) - - Pavel Popov (metaer) - - Lenard Palko - - Nils Adermann (naderman) - - Tom Klingenberg - - Gábor Fási - - R. Achmad Dadang Nur Hidayanto (dadangnh) - - Nate (frickenate) - - Stefan Kruppa - - Jacek Jędrzejewski (jacek.jedrzejewski) - - Shakhobiddin - - Stefan Kruppa - - Joachim Løvgaard (loevgaard) - - sasezaki - - Dawid Pakuła (zulusx) - - Florian Rey (nervo) - - Peter Bowyer (pbowyer) + - Oleksii Zhurbytskyi + - Loïc Faugeron - Rodrigo Borrego Bernabé (rodrigobb) + - Nils Adermann (naderman) + - siganushka (siganushka) + - Ned Schwartz + - Oleksiy (alexndlm) + - Eduardo Oliveira (entering) + - Ryan + - Markus S. (staabm) - John Bafford (jbafford) + - mmokhi + - Michael Moravec + - Gábor Fási + - Dariusz Ruminski + - Dirk Pahl (dirkaholic) + - Ioan Negulescu + - Pavel Popov (metaer) + - Sergey Melesh (sergex) + - Aurélien Fredouelle + - BASAK Semih (itsemih) + - Fabian Lange (codingfabian) + - Dries Vints + - M. (mbontemps) + - lenar + - Laurent Masforné (heisenberg) - Emanuele Iannone - - Petr Duda (petrduda) - - Marcos Rezende (rezende79) - - Denis Gorbachev (starfall) - Martin Morávek (keeo) + - Jan Schumann + - Maelan LE BORGNE + - AKeeman (akeeman) + - Luc Vieillescazes (iamluc) + - Quentin Dequippe (qdequippe) + - Bernd Stellwag + - kylekatarnls (kylekatarnls) + - Matthew Grasmick + - Kevin McBride + - Nadim AL ABDOU (nadim) + - Kamil Kokot (pamil) + - Piotr Kugla (piku235) + - Koen Reiniers (koenre) + - Gunnstein Lye (glye) + - Vicent Soria Durá (vicentgodella) + - Roberto Espinoza (respinoza) + - Maximilian Zumbansen + - Lenard Palko + - Bilge + - Benjamin Georgeault (wedgesama) + - Belhassen Bouchoucha (crownbackend) + - ilyes kooli (skafandri) + - Jeanmonod David (jeanmonod) + - Andrew M-Y (andr) + - boombatower + - Patrick Reimers (preimers) + - Marek Zajac - Kevin Saliou (kbsali) - - Steven Surowiec (steves) - - Shawn Iwinski - - Dieter - - Samuele Lilli (doncallisto) + - Geoffrey Tran (geoff) + - Alex Bakhturin + - Guilherme Ferreira + - Forfarle (forfarle) + - Jan van Thoor (janvt) + - Vlad Gregurco (vgregurco) + - Sergey Panteleev + - Greg Anderson + - Matthew Smeets - Gawain Lynch (gawain) - - mmokhi - - Ryan - Alexander Deruwe (aderuwe) - - Dave Hulbert (dave1010) - - Ivan Rey (ivanrey) - - Johan Vlaar (johjohan) - - M. (mbontemps) - - Marcin Chyłek (songoq) - - Ned Schwartz - - Ziumin - - Daniel Tiringer - - Lenar Lõhmus - - Ilija Tovilo (ilijatovilo) - - Maxime Pinot (maximepinot) - - Sander Toonen (xatoo) - - Zach Badgett (zachbadgett) - - Loïc Faugeron - - Aurélien Fredouelle + - vagrant + - Barry vd. Heuvel (barryvdh) + - Markus Lanthaler (lanthaler) + - Ricardo Oliveira (ricardolotr) + - Nicolas Dewez (nicolas_dewez) + - Dawid Pakuła (zulusx) + - geoffrey + - Dave Hulbert (dave1010) + - Andrey Astakhov (aast) - Pavel Campr (pcampr) - - Andrii Dembitskyi - - Markus Staab - - Forfarle (forfarle) + - PHAS Developer - Johnny Robeson (johnny) - - Disquedur - - Benjamin Morel - - Guilherme Ferreira - - Geoffrey Tran (geoff) - - Jannik Zschiesche - - Bernd Stellwag + - Gijs van Lammeren + - Sebastian Bergmann + - Webnet team (webnet) + - Ahmed Ghanem (ahmedghanem00) + - Cédric Lombardot (cedriclombardot) + - Claude Khedhiri (ck-developer) + - BENOIT POLASZEK (bpolaszek) + - Steven Surowiec (steves) + - tim + - Dominik Zogg + - Florian Rey (nervo) + - Andreas Hennings + - Marvin Feldmann (breyndotechse) + - Stefan Kruppa + - Andrey Lebedev (alebedev) + - Arnaud POINTET (oipnet) + - Faizan Akram Dar (faizanakram) + - Martijn Cuppens + - Ioan Ovidiu Enache (ionutenache) + - Kevin van Sonsbeek (kevin_van_sonsbeek) + - Giso Stallenberg (gisostallenberg) + - Antonin CLAUZIER (0x346e3730) + - Anton Bakai + - PatNowak + - Matheo Daninos (mathdns) + - Markus Bachmann (baachi) + - Raulnet + - Vitaliy Tverdokhlib (vitaliytv) + - Christian Gripp (core23) + - Max Baldanza + - Steven RENAUX (steven_renaux) + - Adam Szaraniec + - Nathan Dench (ndenc2) + - Leevi Graham (leevigraham) + - Jaik Dean (jaikdean) + - Xavier HAUSHERR + - Samuele Lilli (doncallisto) + - Jérémy REYNAUD (babeuloula) + - Jeroen Thora (bolle) + - mcben + - Anatoly Pashin (b1rdex) + - Bahman Mehrdad (bahman) + - Nicolas Rigaud + - Brayden Williams (redstar504) + - Benjamin Cremer (bcremer) + - Shawn Iwinski + - sasezaki + - Jérôme Tanghe (deuchnord) + - Andy Palmer (andyexeter) - Jan Ole Behrens (deegital) - - wicliff wolda (wickedone) - - Mantas Var (mvar) - - Ramunas Pabreza (doobas) - - Yuriy Vilks (igrizzli) - - Terje Bråten - - Sebastian Krebs - - Piotr Stankowski - - Pierre-Emmanuel Tanguy (petanguy) - - Julien Maulny - - Gennadi Janzen - - johan Vlaar - - Paul Oms - - James Hemery - - wuchen90 - - PHAS Developer - - Wouter van der Loop (toppy-hennie) - - Ninos - - julien57 - - Mátyás Somfai (smatyas) - - MrMicky - - Bastien DURAND (deamon) - - Dmitry Simushev - - alcaeus - - Simon Leblanc (leblanc_simon) - - Fred Cox - - Simon DELICATA - - Thibault Buathier (gwemox) - - Julien Boudry + - Stefan Warman (warmans) + - Jay Klehr + - Eric COURTIAL + - Adrian Günter (adrianguenter) + - Mikhail Yurasov (mym) + - Brunet Laurent (lbrunet) + - Elan Ruusamäe (glen) + - louismariegaborit + - Mior Muhammad Zaki (crynobone) + - Denis Zunke (donalberto) - vitaliytv + - Ворожцов Максим (myks92) + - Gert de Pagter + - Arno Geurts + - Masterklavi + - Vincent CHALAMON - Franck RANAIVO-HARISOA (franckranaivo) - - Yi-Jyun Pan - - Egor Taranov - - Arnaud Frézet - - Philippe Segatori - - Jon Gotlin (jongotlin) - - Adrian Nguyen (vuphuong87) - - benjaminmal - - Roy de Vos Burchart - - Andrey Sevastianov - - Oleksandr Barabolia (oleksandrbarabolia) - - Khoo Yong Jun - - Christin Gruber (christingruber) - - Sebastian Blum - - Daniel González (daniel.gonzalez) - - Julien Turby - - Ricky Su (ricky) - - scyzoryck + - Christophe V. (cvergne) + - Zhuravlev Alexander (scif) + - Ian Jenkins (jenkoian) + - Shin Ohno (ganchiku) + - skmedix (skmedix) + - Johannes Klauss (cloppy) + - Reen Lokum + - Kay Wei + - Korvin Szanto + - Andreas Erhard (andaris) + - Mathias Brodala (mbrodala) + - Robert Gruendler (pulse00) + - Fabian Vogler (fabian) + - Tristan Roussel + - Sébastien Despont (bouillou) + - Florian Wolfsjaeger (flowolf) + - Matthieu Bontemps + - Alexandre Parent + - Sofien Naas + - Stéphan Kochen + - ampaze + - Ramunas Pabreza (doobas) + - Carlos Pereira De Amorim (epitre) + - DUPUCH (bdupuch) + - Benjamin Laugueux + - Rostyslav Kinash + - Jan Kramer - Kyle Evans (kevans91) - - Max Rath (drak3) - - Cristoforo Cervino (cristoforocervino) - - marie + - aegypius + - Adam + - Dennis Væversted (srnzitcom) + - Thomas Trautner (thomastr) + - Jesper Noordsij + - Ilia (aliance) + - nathanpage + - Cyril Pascal (paxal) + - Christophe Villeger (seragan) + - Damien Fa + - Dustin Dobervich (dustin10) + - Roger Guasch (rogerguasch) + - Sergey Zolotov (enleur) + - wanxiangchwng + - Arjan Keeman + - Wesley Lancel + - Oleksandr Barabolia (oleksandrbarabolia) + - 243083df + - Sherin Bloemendaal + - Jayson Xu (superjavason) + - Vitaliy Ryaboy (vitaliy) + - StefanoTarditi + - abdul malik ikhsan (samsonasik) + - grizlik + - Maxim Tugaev (tugmaks) + - Alexander Dmitryuk (coden1) + - Oliver Hoff + - Jordan Deitch + - Mike Meier (mykon) + - Derek ROTH + - Christian Stoller (naitsirch) - Stéphane Escandell (sescandell) - - Fractal Zombie - - James Johnston - - Noémi Salaün (noemi-salaun) - - Sinan Eldem (sineld) - - Gennady Telegin - - ampaze + - Sascha Dens (saschadens) + - Yuriy Vilks (igrizzli) + - Rustam Bakeev (nommyde) + - Quentin Dreyer (qkdreyer) + - Mátyás Somfai (smatyas) + - Michael Devery (mickadoo) + - RJ Garcia + - Ivan Kurnosov + - Benoît Merlet (trompette) + - Rimas Kudelis + - Pierrick VIGNAND (pierrick) + - Quentin de Longraye (quentinus95) + - Tony Tran + - Martijn Evers + - “Filip + - sl_toto (sl_toto) - Alexandre Dupuy (satchette) - Michel Hunziker - - Malte Blättermann - - Arnaud De Abreu (arnaud-deabreu) - - Simeon Kolev (simeon_kolev9) - - Joost van Driel (j92) - - Jonas Elfering - - Mihai Stancu + - Oriol Viñals + - Carl Casbolt (carlcasbolt) - Nahuel Cuesta (ncuesta) - - Chris Boden (cboden) - - EStyles (insidestyles) - - Christophe Villeger (seragan) - - Krystian Marcisz (simivar) - - Julien Fredon - - Xavier Leune (xleune) - - Hany el-Kerdany - - Wang Jingyu - - Baptiste CONTRERAS - - Åsmund Garfors - - Maxime Douailin - - Jean Pasdeloup - - Maxime COLIN (maximecolin) - - Lorenzo Millucci (lmillucci) - - Javier López (loalf) - - Reinier Kip - - Jérôme Tamarelle (jtamarelle-prismamedia) - - Emil Masiakowski - - Geoffrey Brier (geoffrey-brier) - - Sofien Naas - - Alexandre Parent - - Daniel Badura - - Brajk19 - - Roger Guasch (rogerguasch) - - DT Inier (gam6itko) - - Dustin Dobervich (dustin10) - - Luis Tacón (lutacon) - - Dmitrii Tarasov (dtarasov) - - dantleech - - Philipp Kolesnikov - - Jack Worman (jworman) - - Sebastian Marek (proofek) - - Carlos Pereira De Amorim (epitre) - - zenmate - - Andrii Popov (andrii-popov) - - David Fuhr - - Malte Müns - - Rodrigo Aguilera - - Vladimir Varlamov (iamvar) - - Aurimas Niekis (gcds) - - Vincent Chalamon - - Matthieu Calie (matth--) - - Sem Schidler (xvilo) - - Benjamin Schoch (bschoch) - - Martins Sipenko - - Guilherme Augusto Henschel - - Rostyslav Kinash - - Christophe V. (cvergne) - - Mardari Dorel (dorumd) - - Daisuke Ohata - - Vincent Simonin - - Pierrick VIGNAND (pierrick) - - Alex Bogomazov (alebo) - - aaa2000 (aaa2000) - - Andy Palmer (andyexeter) - - Andrew Neil Forster (krciga22) - - Stefan Warman (warmans) - - Tristan Maindron (tmaindron) - - Behnoush Norouzali (behnoush) - - Marko H. Tamminen (gzumba) - - Wesley Lancel - - Xavier Briand (xavierbriand) - - Ke WANG (yktd26) - - Ivo Bathke (ivoba) - - Lukas Mencl - - David Molineus - - Strate - - Anton A. Sumin - - Marko Petrovic - - alexandre.lassauge - - Israel J. Carberry - - Miquel Rodríguez Telep (mrtorrent) - - Tamás Nagy (t-bond) - - Sergey Kolodyazhnyy (skolodyazhnyy) + - Jeroen Fiege (fieg) + - Seb Koelen + - Dmitry Parnas (parnas) + - Jose Gonzalez + - AndrolGenhald + - Ruben Gonzalez (rubenruateltek) + - katario + - Michael Piecko (michael.piecko) + - Ana Raro + - Andrii Dembitskyi + - Edvin Hultberg + - Wouter van der Loop (toppy-hennie) + - Eric Abouaf (neyric) + - Marek Pietrzak (mheki) + - Pierre Vanliefland (pvanliefland) + - Alex Xandra Albert Sim + - Bastien THOMAS + - Ivan Menshykov + - Lorenzo Millucci (lmillucci) + - Daniel Alejandro Castro Arellano (lexcast) + - Simon Leblanc (leblanc_simon) + - Travis Carden (traviscarden) + - Simon Schick (simonsimcity) + - Matt Johnson (gdibass) + - Paweł Niedzielski (steveb) + - Sylvain BEISSIER (sylvain-beissier) + - radar3301 + - Oriol Viñals + - Christopher Hall (mythmakr) + - Cameron Porter + - Benjamin Grandfond (benjamin) - umpirski - - Quentin de Longraye (quentinus95) - - Chris Heng (gigablah) - - Mickaël Buliard (mbuliard) - - Jan Nedbal - - Cornel Cruceru (amne) - - Richard Bradley - - Jan Walther (janwalther) - - Ulumuddin Cahyadi Yunus (joenoez) - - rtek - - Mickaël Isaert (misaert) - - Adrien Jourdier (eclairia) - - Florian Pfitzer (marmelatze) - - Ivan Grigoriev (greedyivan) - Johann Saunier (prophet777) - - Kevin SCHNEKENBURGER - - Geordie - - Fabien Salles (blacked) - - Andreas Erhard (andaris) - - alexpozzi - - Michael Devery (mickadoo) - - Gregor Nathanael Meyer (spackmat) + - Hossein Bukhamsin + - frost-nzcr4 + - Rootie + - Matthew Davis (mdavis1982) + - Loïc Chardonnet + - Paulo Ribeiro (paulo) + - Mickaël Isaert (misaert) + - Fred Cox + - arai + - Wu (wu-agriconomie) + - Andrew Tchircoff (andrewtch) + - Matthieu Calie (matth--) + - Simon Watiau (simonwatiau) + - Julien DIDIER (juliendidier) + - Toni Peric (tperic) + - Vladimir Valikayev + - Maxime COLIN (maximecolin) + - Christian Sciberras (uuf6429) + - Christin Gruber (christingruber) + - Noah Heck (myesain) + - Davide Borsatto (davide.borsatto) + - Arturas Smorgun (asarturas) + - Josiah (josiah) + - Ian Irlen + - Tamas Szijarto + - Sebastian Grodzicki (sgrodzicki) + - Kien Nguyen - Antoine Corcy - - Ahmed Ashraf (ahmedash95) + - Sander De la Marche (sanderdlm) + - Dave Marshall (davedevelopment) + - Ondrej Exner + - Paul Kamer (pkamer) + - Gabrielle Langer + - Simo Heinonen (simoheinonen) + - Steve Grunwell + - Casper Valdemar Poulsen + - Sebastian Blum + - Simon Terrien (sterrien) + - Sergey Yastrebov + - COMBROUSE Dimitri + - Claudio Zizza + - alexpozzi + - Andrew Neil Forster (krciga22) + - Gábor Tóth + - Asier Etxebeste + - Jakub Kulhan (jakubkulhan) + - James Michael DuPont + - Wybren Koelmans (wybren_koelmans) + - den + - Pavlo Pelekh (pelekh) + - Baptiste Meyer (meyerbaptiste) + - Michał Jusięga + - Jan Nedbal + - stoccc + - Israel J. Carberry + - Dominik Ulrich + - Richard Quadling + - Harry Walter (haswalt) + - andrey1s + - Shahriar56 + - Jesper Skytte (greew) + - Alexandre parent + - Petar Obradović + - wicliff wolda (wickedone) - Gert Wijnalda (cinamo) + - _sir_kane (waly) + - Andrew Codispoti + - Roland Franssen :) + - Maksim Kotlyar (makasim) - Aurimas Niekis (aurimasniekis) - - Luca Saba (lucasaba) - - Sascha Grossenbacher (berdir) + - Tomasz Ignatiuk + - Cornel Cruceru (amne) + - yclian + - Youssef Benhssaien (moghreb) + - Anton A. Sumin + - Carlos Quintana + - Tristan Maindron (tmaindron) + - Marco Lipparini (liarco) + - SpacePossum + - Stéphane Delprat + - Achilles Kaloeridis (achilles) + - Besnik Br + - Florian Pfitzer (marmelatze) + - Thijs-jan Veldhuizen (tjveldhuizen) + - Benedikt Lenzen (demigodcode) + - Roy de Vos Burchart + - Volodymyr Panivko + - Xav` (xavismeh) + - Behnoush Norouzali (behnoush) + - Jordi Sala Morales (jsala) + - Jiri Barous - Guillaume Aveline - - Robin Lehrmann - - Szijarto Tamas - - Thomas P - - Stephan Vock (glaubinix) + - ouardisoft + - Delf Tonder (leberknecht) + - Simon (kosssi) + - Tamás Nagy (t-bond) + - Nicole Cordes (ichhabrecht) - Jaroslav Kuba - - Benjamin Zikarsky (bzikarsky) + - Malte Blättermann + - Raphaëll Roussel + - James Hudson (mrthehud) + - zenas1210 + - Johnson Page (jwpage) + - Vladimir Luchaninov (luchaninov) + - Andreas Braun + - Guillaume Verstraete + - Emil Masiakowski - Kristijan Kanalaš (kristijan_kanalas_infostud) - - Rodrigo Méndez (rodmen) - - sl_toto (sl_toto) - - Marek Pietrzak (mheki) - - “Filip - - Mickaël Andrieu (mickaelandrieu) - - Simon Watiau (simonwatiau) + - Stephan Vock (glaubinix) + - Loïc Beurlet + - Ryan Hendrickson + - benjaminmal + - Vitaliy Zhuk (zhukv) + - Marc Laporte + - Kristof Van Cauwenbergh (kristofvc) + - Stefano Degenkamp (steef) + - Luis Tacón (lutacon) - Ruben Jacobs (rubenj) - - Simon Schick (simonsimcity) - - Tristan Roussel - - NickSdot - - Niklas Keller - - Alexandre parent - - Cameron Porter - - Hossein Bukhamsin - - Oliver Hoff - - Christian Sciberras (uuf6429) + - Tony Malzhacker + - Nguyen Xuan Quynh + - marie + - Ondrej Machulda (ondram) + - Pedro Miguel Maymone de Resende (pedroresende) + - Max Rath (drak3) + - Tinjo Schöni + - Dmytro Boiko (eagle) + - Baptiste CONTRERAS + - Stephan Vierkant (svierkant) + - EStyles (insidestyles) + - Massimiliano Braglia (massimilianobraglia) + - Chris Jones (magikid) + - Gennady Telegin + - jochenvdv + - datibbaw + - julien57 + - Evan Shaw + - Jeremiasz Major + - Franco Traversaro (belinde) + - Douglas Hammond (wizhippo) + - Thibault Buathier (gwemox) - Thomas Nunninger - - origaminal + - Amr Ezzat (amrezzat) + - Jérôme Tamarelle (jtamarelle-prismamedia) - Matteo Beccati (matteobeccati) - - Renan Gonçalves (renan_saddam) - - Vitaliy Ryaboy (vitaliy) - - Kevin (oxfouzer) - - Paweł Wacławczyk (pwc) - - Oleg Zinchenko (cystbear) - - Baptiste Meyer (meyerbaptiste) - - Tales Santos (tsantos84) - - Tomasz Kusy - - Johannes Klauss (cloppy) - - Evan Villemez - - fzerorubigd - - Thomas Ploch - - Benjamin Grandfond (benjamin) - - Tiago Brito (blackmx) - - Gintautas Miselis (naktibalda) - - Richard van den Brand (ricbra) - - Toon Verwerft (veewee) - - develop - - flip111 - - Douglas Hammond (wizhippo) - - VJ - - RJ Garcia - - Adrien Lucas (adrienlucas) - - Jawira Portugal (jawira) - - Delf Tonder (leberknecht) - - Ondrej Exner - - Mark Sonnabaum - - Chris Jones (magikid) - - Massimiliano Braglia (massimilianobraglia) - - Thijs-jan Veldhuizen (tjveldhuizen) - - Richard Quadling - - James Hudson (mrthehud) - - Raphaëll Roussel - - Michael Lutz - - jochenvdv - - Oriol Viñals - - Reedy - - Arturas Smorgun (asarturas) - - Aleksandr Volochnev (exelenz) - - Robin van der Vleuten (robinvdvleuten) - - Grinbergs Reinis (shima5) - - Michael Piecko (michael.piecko) - - Toni Peric (tperic) - - yclian - - Nicolas DOUSSON - - radar3301 - - Aleksey Prilipko - - Jelle Raaijmakers (gmta) - - Andrew Berry - - Sylvain BEISSIER (sylvain-beissier) - - Wybren Koelmans (wybren_koelmans) - - Roberto Nygaard - - victor-prdh - - Davide Borsatto (davide.borsatto) - - Florian Hermann (fhermann) - - Vitaliy Zhuk (zhukv) - - zenas1210 - - Gert de Pagter - - Julien DIDIER (juliendidier) - - Ворожцов Максим (myks92) - - Dalibor Karlović + - Adrien Wilmet (adrienfr) + - Romanavr + - Lars Vierbergen (vierbergenlars) + - Richard Bradley + - Tim Düsterhus + - Grégoire Penverne (gpenverne) + - Reinier Kip + - Thibault Richard (t-richard) + - Geoffrey Brier (geoffrey-brier) + - Daisuke Ohata + - Adán Lobato (adanlobato) + - Jake (jakesoft) + - Julien Fredon + - Ivan Grigoriev (greedyivan) + - Oleg Zinchenko (cystbear) + - Benjamin Lebon + - Sébastien JEAN (sebastien76) + - Arnaud Frézet + - Julien Tattevin (jutattevin) + - Philipp Keck + - Robert Fischer (sandoba) + - Nikita Nefedov (nikita2206) + - Egor Taranov + - Martin (meckhardt) + - Matt Robinson (inanimatt) + - Andrew Hilobok (hilobok) + - Francis Turmel (fturmel) + - Kagan Balga (kagan-balga) + - Paul Oms + - Malte Müns + - Rodrigo Aguilera + - Aurimas Niekis (gcds) + - ywisax + - Fabien LUCAS (flucas2) + - Philippe Segatori + - michaelwilliams + - Benjamin Zikarsky (bzikarsky) + - Glodzienski + - Marcel Hernandez + - Johnny Peck (johnnypeck) + - Henry Snoek (snoek09) + - Rodrigo Méndez (rodmen) + - Simon Mönch + - Julien Maulny - Randy Geraads - - Kevin van Sonsbeek (kevin_van_sonsbeek) - - Simo Heinonen (simoheinonen) - - Jay Klehr - - Andreas Leathley (iquito) - - Vladimir Luchaninov (luchaninov) - - Sebastian Grodzicki (sgrodzicki) - - Mohamed Gamal - - Eric COURTIAL - - Xesxen - - Jeroen van den Enden (endroid) - - Arun Philip - - Pascal Helfenstein - - Jesper Skytte (greew) - - Petar Obradović - - Baldur Rensch (brensch) - - Carl Casbolt (carlcasbolt) - - Jiri Barous + - Cristoforo Cervino (cristoforocervino) + - Fabien Salles (blacked) + - Yosmany Garcia (yosmanyga) + - James Hemery + - Jean Pasdeloup + - James Johnston + - Fractal Zombie + - Gennadi Janzen - Vladyslav Petrovych - - Loïc Chardonnet - - Alex Xandra Albert Sim - - Sergey Yastrebov + - Richard Henkenjohann (richardhj) - Carson Full (carsonfull) - - Steve Grunwell - - Yuen-Chi Lian - - Mathias Brodala (mbrodala) - - Robert Fischer (sandoba) - - Tarjei Huse (tarjei) - - Travis Carden (traviscarden) - - mfettig - - Besnik Br - - Issam Raouf (iraouf) - - Simon Mönch - - Sherin Bloemendaal - - Jose Gonzalez - - Jonathan (jlslew) - - Claudio Zizza - - aegypius - - Ilia (aliance) - - Christian Stoller (naitsirch) - - Dave Marshall (davedevelopment) - - Jakub Kulhan (jakubkulhan) - - Paweł Niedzielski (steveb) - - Shaharia Azam - - avorobiev - - Gerben Oolbekkink - - Gladhon + - Felds Liscia (felds) + - Maximilian Bösing + - VJ + - Pierre Hennequart - Maximilian.Beckers - Alex Kalineskou - - Evan Shaw - - stoccc - - Grégoire Penverne (gpenverne) - - Venu - - Ryan Hendrickson - - Damien Fa - - Jonatan Männchen - - Dennis Hotson - - Andrew Tchircoff (andrewtch) - - Lars Vierbergen (vierbergenlars) - - Xav` (xavismeh) - - Barney Hanlon - - Thorry84 - - Romanavr - - michaelwilliams - - Alexandre Parent - - 1emming - - Eric Abouaf (neyric) - - Nykopol (nykopol) - - Thibault Richard (t-richard) - - Jordan Deitch - - Casper Valdemar Poulsen - - Guillaume Verstraete - - vladimir.panivko - - Oliver Hader - - Josiah (josiah) - - Dennis Væversted (srnzitcom) - - AndrolGenhald - - Asier Etxebeste - - Joschi Kuphal + - Matt Janssen + - Brajk19 - John Bohn (jbohn) - - Jason Tan (jt2k) - - Edvin Hultberg - - shubhalgupta - - Felds Liscia (felds) - - Benjamin Lebon - - Alexander Grimalovsky (flying) - - Andrew Hilobok (hilobok) - - Noah Heck (myesain) - - Christian Soronellas (theunic) - - Max Baldanza - - Volodymyr Panivko - - kick-the-bucket - - Thomas Durand - - fedor.f - - Yosmany Garcia (yosmanyga) - - Jeremiasz Major - - Jibé Barth (jibbarth) - - Trevor North + - hugovms + - Cyril Quintin (cyqui) + - Maksim Muruev + - Mardari Dorel (dorumd) + - Rafał Wrzeszcz (rafalwrzeszcz) + - Tarjei Huse (tarjei) + - aaa2000 (aaa2000) + - zenmate + - Robin Lehrmann + - Reedy + - Ricky Su (ricky) + - Terje Bråten + - Sebastian Marek (proofek) + - Simeon Kolev (simeon_kolev9) + - Andreas Leathley (iquito) + - Reyo Stallenberg (reyostallenberg) + - Martins Sipenko + - Geordie + - Gregor Nathanael Meyer (spackmat) + - Sem Schidler (xvilo) + - Sebastian Paczkowski (sebpacz) + - Simon Heimberg (simon_heimberg) - Degory Valentine - - izzyp - - Jeroen Fiege (fieg) - - Martin (meckhardt) - - Wu (wu-agriconomie) - - Marcel Hernandez - - Evan C + - Jon Gotlin (jongotlin) + - David Molineus + - Lukas Mencl + - Christian Soronellas (theunic) + - Jörn Lang + - Pedro Casado (pdr33n) + - Mickaël Andrieu (mickaelandrieu) + - shubhalgupta + - Benoît Bourgeois (bierdok) + - Jason Woods + - Sofiane HADDAG (sofhad) + - Geert De Deckere + - Julie Hourcade (juliehde) + - Patrick Dawkins (pjcdawkins) + - DT Inier (gam6itko) + - Tales Santos (tsantos84) - buffcode - - Glodzienski - - Natsuki Ikeguchi - - Krzysztof Łabuś (crozin) - - Xavier Lacot (xavier) - - Jon Dufresne - - possum - - Denis Zunke (donalberto) - - Adrien Roches (neirda24) - - Thomas Trautner (thomastr) - - _sir_kane (waly) - - Olivier Maisonneuve - - Gálik Pál - - Bálint Szekeres - - Andrei C. (moldman) - - Mike Meier (mykon) - - Pedro Miguel Maymone de Resende (pedroresende) + - Sinan Eldem (sineld) + - Daniel Cestari + - Balazs Csaba + - noniagriconomie + - Marcos Gómez Vilches (markitosgv) + - Philipp Kolesnikov + - Denis Charrier (brucewouaigne) + - Andreas Lutro (anlutro) + - Xavier Leune (xleune) + - Andrew Berry + - Sebastian Krebs + - Andrey Sevastianov + - mfettig + - Jean-Baptiste GOMOND (mjbgo) + - Mark Sonnabaum + - Bastien DURAND (deamon) + - Xavier Briand (xavierbriand) - stlrnz - - Masterklavi - - Adrien Wilmet (adrienfr) - - Franco Traversaro (belinde) - - Francis Turmel (fturmel) - - Kagan Balga (kagan-balga) - - Nikita Nefedov (nikita2206) - - Alex Bacart - - StefanoTarditi - - cgonzalez - - hugovms - - Ben + - Roberto Nygaard + - avorobiev + - Guilherme Augusto Henschel + - Michael Lutz + - fzerorubigd + - wuchen90 + - Jakub Podhorsky (podhy) + - Benjamin Schoch (bschoch) + - develop + - Niklas Keller + - Noémi Salaün (noemi-salaun) + - Vincent Simonin + - Pavol Tuka + - Sébastien Santoro (dereckson) + - Florent Destremau (florentdestremau) + - Alexander Grimalovsky (flying) + - Ana Raro + - Dhananjay Goratela + - Julien Turby + - Paweł Wacławczyk (pwc) + - Marko Petrovic + - mwsaz + - Åsmund Garfors + - Gerard van Helden (drm) + - Adrian Nguyen (vuphuong87) + - mweimerskirch + - bogdan + - Ilya Levin (ilyachase) + - Shaharia Azam + - Kevin SCHNEKENBURGER + - Daniel Badura + - Barney Hanlon + - Gerben Oolbekkink + - Nykopol (nykopol) + - Krzysztof Łabuś (crozin) + - Kuba Werłos (kuba) + - Andrei C. (moldman) + - Florent Viel (luxifer) + - Bozhidar Hristov + - vladimir.panivko + - Brad Jones + - Calin Mihai Pristavu - Vincent Composieux (eko) - - Cyril Pascal (paxal) - - Pedro Casado (pdr33n) - - Jayson Xu (superjavason) - - acoulton - - DemigodCode - - fago - Jan Prieser - - Maximilian Bösing - - Matt Johnson (gdibass) - - Zhuravlev Alexander (scif) - - Stefano Degenkamp (steef) - - James Michael DuPont - - Tinjo Schöni + - Lctrs + - Natsuki Ikeguchi + - Hany el-Kerdany + - MrMicky + - Oliver Hader + - Gintautas Miselis (naktibalda) + - Ivo Bathke (ivoba) + - Chris Heng (gigablah) + - johan Vlaar + - Ben + - Venu + - acoulton + - Mihai Stancu + - fedor.f + - Neil Ferreira + - Gálik Pál + - Nicolas Dousson + - Thomas Durand + - Dennis Hotson + - Jonatan Männchen + - Philipp Scheit (pscheit) + - Matthieu Mota (matthieumota) + - Artur Eshenbrener + - Hidde Boomsma (hboomsma) + - Marc Abramowitz + - Andrii Popov (andrii-popov) - Carlos Buenosvinos (carlosbuenosvinos) - - Christian Gripp (core23) - - Jake (jakesoft) - - Rustam Bakeev (nommyde) - - Vincent CHALAMON - - Ivan Kurnosov - - Christopher Hall (mythmakr) - - Patrick Dawkins (pjcdawkins) - - Paul Kamer (pkamer) - - Rafał Wrzeszcz (rafalwrzeszcz) - - Reyo Stallenberg (reyostallenberg) - - Nguyen Xuan Quynh - - Reen Lokum - - Dennis Langen (nijusan) - - Quentin Dreyer (qkdreyer) - - Francisco Alvarez (sormes) + - Gladhon + - Sergey Kolodyazhnyy (skolodyazhnyy) + - scyzoryck + - Jesper Noordsij + - Cosmin Sandu + - Thomas P + - Jason Tan (jt2k) + - David Marín Carreño (davefx) + - Alexander Li (aweelex) + - Morten Wulff (wulff) + - origaminal + - Xavier Lacot (xavier) + - Michael Roterman (wtfzdotnet) + - Mickaël Buliard (mbuliard) + - rtek + - Kieran - Martin Parsiegla (spea) - - Maxim Tugaev (tugmaks) - - ywisax - Manuel Alejandro Paz Cetina - - Denis Charrier (brucewouaigne) - - Youssef Benhssaien (moghreb) - - Mario Ramundo (rammar) - - Ivan + - Alexander Miehe + - Ahmed Ashraf (ahmedash95) + - flip111 + - Baldur Rensch (brensch) + - ToshY + - Sascha Grossenbacher (berdir) + - Joschi Kuphal + - Trevor North + - Pierre-Emmanuel Tanguy (petanguy) + - Dragos Protung (dragosprotung) + - Jonas Elfering + - Gustavo Falco (gfalco) + - Alex Bogomazov (alebo) + - Jan Walther (janwalther) + - Simon DELICATA + - Thibaut THOUEMENT (thibaut_thouement) + - Thiago Cordeiro (thiagocordeiro) + - Evan C + - Koen Kuipers (koku) + - Florian Hermann (fhermann) + - Kevin (oxfouzer) + - Alex Bacart + - Piotr Stankowski + - Arun Philip + - kick-the-bucket + - Morgan Auchede + - Chris Boden (cboden) + - Adrien Lucas (adrienlucas) - Nico Haase - - Philipp Scheit (pscheit) - - Pierre Vanliefland (pvanliefland) - - Roy Klutman (royklutman) - - Sofiane HADDAG (sofhad) - - Quentin Schuler (sukei) - - Antoine M - - frost-nzcr4 - - Shahriar56 - - Dhananjay Goratela - - Kien Nguyen - - Bozhidar Hristov - - Oriol Viñals - - arai - - Achilles Kaloeridis (achilles) - - Sébastien Despont (bouillou) + - Aleksandr Volochnev (exelenz) + - David Romaní + - Jonathan (jlslew) + - Grinbergs Reinis (shima5) + - Dennis Langen (nijusan) + - Patrick Allaert + - Ulumuddin Cahyadi Yunus (joenoez) + - Robin van der Vleuten (robinvdvleuten) + - Dmitrii Tarasov (dtarasov) + - Daniël Brekelmans (dbrekelmans) + - Luca Saba (lucasaba) + - Douglas Reith (douglas_reith) + - Daniel González (daniel.gonzalez) + - Krystian Marcisz (simivar) + - Adrien Jourdier (eclairia) + - Loïc Ovigne (oviglo) + - Francisco Alvarez (sormes) + - Bálint Szekeres + - Yi-Jyun Pan + - Vladimir Varlamov (iamvar) + - Olivier Maisonneuve + - Adrien Roches (neirda24) + - Bill Hance (billhance) + - Moshe Weitzman (weitzman) + - Thorry84 + - Toon Verwerft (veewee) + - Tiago Brito (blackmx) + - Mark Schmale (masch) + - Jacques MOATI (jmoati) + - David Fuhr + - Michiel Boeckaert (milio) + - DemigodCode + - Mario Ramundo (rammar) + - Alaattin Kahramanlar (alaattin) + - ornicar - Laurent Bassin (lbassin) + - Miquel Rodríguez Telep (mrtorrent) - Mouad ZIANI (mouadziani) - - Tomasz Ignatiuk - - andrey1s + - NanoSector + - Jon Dufresne + - Khoo Yong Jun + - Don Pinkster + - Ivan + - Mohamed Gamal + - Emil Einarsson + - Jibé Barth (jibbarth) + - Joost van Driel (j92) + - Evan Villemez + - Alex (garrett) + - Konstantin Grachev (grachevko) + - izzyp + - Jeroen van den Enden (endroid) + - Xesxen + - Tomasz Kusy + - Jelle Raaijmakers (gmta) + - Renan Gonçalves (renan_saddam) + - fago + - alexandre.lassauge + - Thomas Ploch + - Marko H. Tamminen (gzumba) + - Thomas Cochard (tcochard) + - Javier López (loalf) + - Pascal Helfenstein + - Richard van den Brand (ricbra) + - Ke WANG (yktd26) + - Roy Klutman (royklutman) - Abhoryo - - louismariegaborit - - Fabian Vogler (fabian) - - Korvin Szanto - - Stéphan Kochen - - Arjan Keeman - - Alaattin Kahramanlar (alaattin) - - Sergey Zolotov (enleur) - - Nicole Cordes (ichhabrecht) - - Maksim Kotlyar (makasim) - - Thibaut THOUEMENT (thibaut_thouement) - - Neil Ferreira - - Julie Hourcade (juliehde) - - Dmitry Parnas (parnas) - - Loïc Beurlet - - Ana Raro - - Ana Raro - - Tony Malzhacker - - Cosmin Sandu - - Andreas Lutro (anlutro) - - DUPUCH (bdupuch) - - Cyril Quintin (cyqui) - - Gerard van Helden (drm) - - Florent Destremau (florentdestremau) - - Florian Wolfsjaeger (flowolf) - - Johnny Peck (johnnypeck) - - Jordi Sala Morales (jsala) - - Sander De la Marche (sanderdlm) - - skmedix (skmedix) - - Loic Chardonnet - - Ivan Menshykov - - David Romaní - - Patrick Allaert - - Alexander Li (aweelex) - - Gustavo Falco (gfalco) - - Matt Robinson (inanimatt) - - Kristof Van Cauwenbergh (kristofvc) - - Marco Lipparini (liarco) - - Aleksey Podskrebyshev - - Calin Mihai Pristavu - - Gabrielle Langer - - Jörn Lang - - Adrian Günter (adrianguenter) - - Amr Ezzat (amrezzat) - - David Marín Carreño (davefx) - - Fabien LUCAS (flucas2) - - Alex (garrett) - - Konstantin Grachev (grachevko) - - Hidde Boomsma (hboomsma) - - Ondrej Machulda (ondram) - - Jason Woods - - mwsaz - - bogdan - - wanxiangchwng - - Geert De Deckere - - grizlik - - Derek ROTH - - Jeremy Benoist - - Ben Johnson - - Jan Kramer - - mweimerskirch - - Andrew Codispoti - - Benjamin Laugueux - - Lctrs - - Benoît Bourgeois (bierdok) - - Dmytro Boiko (eagle) - - Shin Ohno (ganchiku) - - Matthieu Mota (matthieumota) - - Jean-Baptiste GOMOND (mjbgo) - - Jakub Podhorsky (podhy) - - abdul malik ikhsan (samsonasik) - - Henry Snoek (snoek09) - - Morgan Auchede - - Christian Morgan - - Alexander Miehe - - Daniël Brekelmans (dbrekelmans) - - Simon (kosssi) - - Sascha Dens (saschadens) - - Simon Heimberg (simon_heimberg) - - Morten Wulff (wulff) - - Kieran - - Don Pinkster - - Maksim Muruev - - Emil Einarsson - - 243083df - - Thibault Duplessis - - katario - - Rimas Kudelis - - Marc Abramowitz - - Matthias Schmidt - - Martijn Evers - - Tony Tran - - Balazs Csaba - - Bill Hance (billhance) - - Douglas Reith (douglas_reith) - - Harry Walter (haswalt) - - Jacques MOATI (jmoati) - - Johnson Page (jwpage) - - Kuba Werłos (kuba) - - Ruben Gonzalez (rubenruateltek) - - Mokhtar Tlili (sf-djuba) - - Michael Roterman (wtfzdotnet) - - Philipp Keck - - Pavol Tuka - - Arno Geurts - - Adán Lobato (adanlobato) - - Ian Jenkins (jenkoian) - - Marcos Gómez Vilches (markitosgv) - - Matthew Davis (mdavis1982) - - Paulo Ribeiro (paulo) - - Marc Laporte - - Michał Jusięga - - Kay Wei - - Dominik Ulrich - - den - - Gábor Tóth - - ouardisoft - - Daniel Cestari - - Matt Janssen - - Stéphane Delprat - - Mior Muhammad Zaki (crynobone) - - Elan Ruusamäe (glen) - - Brunet Laurent (lbrunet) - - Florent Viel (luxifer) + - Maxime Douailin - Maks 3w (maks3w) - - Michiel Boeckaert (milio) - - Mikhail Yurasov (mym) - - Robert Gruendler (pulse00) - - Sebastian Paczkowski (sebpacz) - - Simon Terrien (sterrien) - - Stephan Vierkant (svierkant) - - Benoît Merlet (trompette) - - Brad Jones - - datibbaw - - Dragos Protung (dragosprotung) - - Koen Kuipers (koku) + - Mantas Var (mvar) + - Jawira Portugal (jawira) - Nicolas de Marqué (nicola) - - Thiago Cordeiro (thiagocordeiro) - - Matthieu Bontemps - - Ian Irlen - - Rootie - - Sébastien Santoro (dereckson) - - Daniel Alejandro Castro Arellano (lexcast) - - Vincent Chalamon - - Farhad Hedayatifard - - Alan ZARLI - - Thomas Jarrand - - Baptiste Leduc (bleduc) - - soyuka - - Piotr Zajac - - Patrick Kaufmann - - Ismail Özgün Turan (dadeather) - - Mickael Perraud - - Anton Dyshkant - - Rafael Villa Verde - - Zoran Makrevski (zmakrevski) - - Yann LUCAS (drixs6o9) - - Kirill Nesmeyanov (serafim) - - Reece Fowell (reecefowell) - - Muhammad Aakash - - Charly Goblet (_mocodo) - - Htun Htun Htet (ryanhhh91) - - Guillaume Gammelin - - Valérian Galliat - - Sorin Pop (sorinpop) - - d-ph - - Stewart Malik - - Renan Taranto (renan-taranto) - - Ninos Ego - - Samael tomas - - Stefan Graupner (efrane) - - Gemorroj (gemorroj) - - Adrien Chinour - - Jonas Claes - - Mateusz Żyła (plotkabytes) - - Rikijs Murgs - - WoutervanderLoop.nl - - Mihail Krasilnikov (krasilnikovm) - - Uladzimir Tsykun - - iamvar - - Amaury Leroux de Lens (amo__) - - Rene de Lima Barbosa (renedelima) - - Christian Jul Jensen - - Lukas Kaltenbach - - Alexandre GESLIN - - The Whole Life to Learn - - Pierre Tondereau - - Joel Lusavuvu (enigma97) + - Mara Blaga + - Rick Prent + - Alexander Onatskiy + - Bruno Ziegler (sfcoder) + - Tom Newby (tomnewbyau) + - skalpa + - danilovict2 + - Peter Bouwdewijn + - Daniil Gentili + - v.shevelev + - rvoisin + - Mario Young + - Tomáš Polívka (draczris) + - BenjaminBeck + - Konstantin Bogomolov + - Marco + - Jack Wright + - Ener-Getick + - Pablo Borowicz + - Boullé William (williamboulle) + - Ryan Rud + - Ondřej Frei + - Haritz + - Matthieu Prat + - Helmut Hummel (helhum) + - Mehdi Mabrouk (mehdidev) + - Bart Reunes (metalarend) + - Kamil Piwowarski (cyklista) + - Damon Jones (damon__jones) + - cilefen (cilefen) + - cthulhu + - Anne-Julia Seitz + - WaiSkats + - Stanislav Gamaiunov (happyproff) + - Rémi Leclerc + - Bermon Clément (chou666) + - Egor Gorbachev + - Citia (citia) + - Volker Killesreiter (ol0lll) + - Kamil Madejski (kmadejski) + - jack.thomas (jackthomasatl) + - Yasmany Cubela Medina (bitgandtter) + - Owen Gray (otis) + - Robert Gurau + - Colin Michoudet + - sebastian + - Ron Gähler (t-ronx) + - Guillermo Gisinger (t3chn0r) + - Sören Bernstein + - michael.kubovic + - Evgeny Anisiforov + - Jordi Llonch (jordillonch) + - julien_tempo1 (julien_tempo1) + - tarlepp + - Yoann Chocteau (kezaweb) + - Jeroen de Graaf + - Chris Shennan (chrisshennan) + - Abdouni Karim (abdounikarim) + - nietonfir + - Ikhsan Agustian + - raplider + - Michael Pohlers (mick_the_big) + - Franck Ranaivo-Harisoa + - Jeremiah VALERIE + - Minna N + - Aaron Somi + - Elías (eliasfernandez) + - kshida + - Vladislav Vlastovskiy (vlastv) - Valentin Barbu (jimie) - - Alex Vo (votanlean) - - Mikkel Paulson - - ergiegonzaga - - André Matthies - - kurozumi (kurozumi) - - Nicolas Lemoine - - Piergiuseppe Longo - - Kevin Auivinet - - Liverbool (liverbool) - - Valentin Nazarov - - Dalibor Karlović - - Aurélien MARTIN - - Malte Schlüter - - Jules Matsounga (hyoa) - - Yewhen Khoptynskyi (khoptynskyi) - - Nicolas Attard (nicolasattard) - - Jérôme Nadaud (jnadaud) - - Frank Naegler - - Sam Malone - - Damien Fernandes - - Ha Phan (haphan) - - Chris Jones (leek) - - neghmurken - - stefan.r - - xaav - - Jean-Christophe Cuvelier [Artack] - - Mahmoud Mostafa (mahmoud) - - Alexandre Tranchant (alexandre_t) - - Anthony Moutte - - Ahmed Abdou - - shreyadenny - - Daniel Iwaniec - - Thomas Ferney (thomasf) - - Pieter - - Louis-Proffit - - Dennis Tobar - - Michael Tibben - - Hallison Boaventura (hallisonboaventura) - - Mas Iting - - Billie Thompson - - Albion Bame (abame) - - Ganesh Chandrasekaran (gxc4795) - - Sander Marechal - - Ivan Nemets - - Grégoire Hébert (gregoirehebert) - - Franz Wilding (killerpoke) - - Ferenczi Krisztian (fchris82) - - Artyum Petrov - - Oleg Golovakhin (doc_tr) - - Guillaume Smolders (guillaumesmo) - - Icode4Food (icode4food) - - Radosław Benkel - - Bert ter Heide (bertterheide) - - Kevin Nadin (kevinjhappy) - - jean pasqualini (darkilliant) - - Iliya Miroslavov Iliev (i.miroslavov) - - Safonov Nikita (ns3777k) - - Ross Motley (rossmotley) - - ttomor - - Mei Gwilym (meigwilym) - - Michael H. Arieli - - Miloš Milutinović - - Jitendra Adhikari (adhocore) - - Nicolas Martin (cocorambo) - - Tom Panier (neemzy) - - Fred Cox - - luffy1727 - - Luciano Mammino (loige) - - LHommet Nicolas (nicolaslh) - - fabios - - eRIZ - - Sander Coolen (scoolen) - - Vic D'Elfant (vicdelfant) - - Amirreza Shafaat (amirrezashafaat) - - Laurent Clouet - - Adoni Pavlakis (adoni) - - Nicolas Le Goff (nlegoff) - - Maarten Nusteling (nusje2000) - - Anne-Sophie Bachelard - - Gordienko Vladislav - - Ahmed EBEN HASSINE (famas23) - - Marvin Butkereit - - Ben Oman - - Chris de Kok - - Eduard Bulava (nonanerz) - - Andreas Kleemann (andesk) - - Ilya Levin (ilyachase) - - Hubert Moreau (hmoreau) + - Roman Igoshin (masterro) + - Antal Áron (antalaron) + - John VanDeWeghe + - Jordan Hoff + - Aurelijus Rožėnas + - Beno!t POLASZEK + - hamza - Nicolas Appriou - - Silas Joisten (silasjoisten) - - Igor Timoshenko (igor.timoshenko) - - Pierre-Emmanuel CAPEL - - Manuele Menozzi - - “teerasak” - - Anton Babenko (antonbabenko) - - Irmantas Šiupšinskas (irmantas) + - vlechemin + - Janusz Jabłoński (yanoosh) + - Tayfun Aydin + - kaywalker + - joris de wit (jdewit) + - znerol + - Matthew Covey + - Nicolas Bondoux (nsbx) + - zors1 + - Tobias Genberg (lorceroth) + - Martijn Croonen + - Andy Stanberry + - Schvoy Norbert (schvoy) + - Ondřej Frei + - Luis Pabon (luispabon) + - Anthony Ferrara + - rchoquet + - Amine Yakoubi - Benoit Mallo - - Charles-Henri Bruyand - - Danilo Silva - - Giuseppe Campanelli - - Valentin - - pizzaminded - - Nicolas Valverde - - Konstantin S. M. Möllers (ksmmoellers) - - Ken Stanley - - ivan - - Zachary Tong (polyfractal) - - linh - - Oleg Krasavin (okwinza) + - Simon Bouland (bouland) + - Floran Brutel (notFloran) (floran) + - Christian Neff (secondtruth) + - povilas + - ollie harridge (ollietb) + - Courcier Marvin (helyakin) + - Radoslaw Kowalewski + - Abdelilah Jabri + - Ioana Hazsda (ioana-hazsda) + - MrNicodemuz + - demeritcowboy + - Marcus Stöhr (dafish) + - Fabien D. (fabd) + - Tristan Kretzer + - Jacek Wilczyński (jacekwilczynski) + - Alexandru Năstase + - Sergey Fedotov + - Konstantin Scheumann - Mario Blažek (marioblazek) - - Jure (zamzung) - - Michael Nelson - - Ashura - - Hryhorii Hrebiniuk - - Nsbx - - Eric Krona - - Alex Plekhanov - - johnstevenson - - hamza - - dantleech - - Kajetan Kołtuniak (kajtii) - - Sander Goossens (sandergo90) - - Rudy Onfroy - - Tero Alén (tero) - - DerManoMann - - Damien Fayet (rainst0rm) - - MatTheCat - - Guillaume Royer - - Erfan Bahramali - - Artem (digi) - - boite - - Silvio Ginter - - Peter Culka - - MGDSoft - - Abdiel Carrazana (abdielcs) - - joris - - Vadim Tyukov (vatson) - - Arman - - Gabi Udrescu - - Adamo Crespi (aerendir) - - David Wolter (davewww) - - Sortex - - chispita - - Wojciech Sznapka - - Emmanuel Dreyfus - - Luis Pabon (luispabon) + - pizzaminded + - Fraller Balázs (fracsi) + - Jorge Maiden (jorgemaiden) + - EdgarPE + - George Yiannoulopoulos + - Misha Klomp (mishaklomp) + - mlpo (mlpo) + - Oliver Hoff + - Olivier Scherler (oscherler) + - Marco Wansinck (mwansinck) + - mamazu + - Tomáš Korec (tomkorec) + - natechicago + - Geoff + - Marcel Pociot (mpociot) + - Camille Islasse + - Josef Hlavatý + - Jan Marek (janmarek) + - fh-github@fholzhauer.de + - Marek Víger (freezy) + - Vladimir Sazhin + - lol768 + - Andoni Larzabal (andonilarz) + - Alexandre Pavy + - Boris Betzholz + - mshavliuk - boulei_n - - Anna Filina (afilina) - - Gavin (gavin-markup) - - Ksaveras Šakys (xawiers) - - Shaun Simmons - - Ariel J. Birnbaum - - Yannick - - Patrick Luca Fazzi (ap3ir0n) - - Tim Lieberman - - Danijel Obradović - - Pablo Borowicz - - Ondřej Frei - - Bruno Rodrigues de Araujo (brunosinister) - - Máximo Cuadros (mcuadros) - - Jacek Wilczyński (jacekwilczynski) + - Kacper Gunia (cakper) + - djordy + - Adrian Olek (adrianolek) + - Stewart Malik + - Mark Pedron (markpedron) + - mikocevar + - Ibrahim Bougaoua + - Laurens Laman + - Hugo Fonseca (fonsecas72) + - Marc Duboc (icemad) + - Lesueurs Frédéric (fredlesueurs) + - Greg Szczotka (greg606) + - Attila Szeremi + - Pablo Ogando Ferreira + - Hoffmann András + - Adam Klvač + - Mei Gwilym (meigwilym) + - Victor Garcia + - Frankie Wittevrongel + - Plamen Mishev (pmishev) + - Olivier Laviale (olvlvl) + - Viacheslav Sychov + - Julien Pauli - Christoph Kappestein - - Camille Baronnet - - EXT - THERAGE Kevin - - tamirvs - - gauss - - julien.galenski - - Florian Guimier - - Maxime PINEAU - - Igor Kokhlov (verdet) - - Christian Neff (secondtruth) - - Chris Tiearney - - Oliver Hoff - - Minna N - - Ole Rößner (basster) - - andersmateusz - - Laurent Moreau - - Faton (notaf) - - Tom Houdmont - - tamar peled - - mark burdett - - Per Sandström (per) - - Goran Juric - - Laurent G. (laurentg) - - Jean-Baptiste Nahan - - Thomas Decaux - - Nicolas Macherey - - Asil Barkin Elik (asilelik) - - Bhujagendra Ishaya - - Guido Donnari - - Mert Simsek (mrtsmsk0) - - Lin Clark - - Christophe Meneses (c77men) - - Jeremy David (jeremy.david) - - Andrei O - - gr8b - - Michał Marcin Brzuchalski (brzuchal) - - Jordi Rejas - - Troy McCabe - - Ville Mattila - - gstapinato - - gr1ev0us - - Léo VINCENT - - mlazovla - - Alejandro Diaz Torres - - Bradley Zeggelaar - - Karl Shea - - Valentin - - Markus Baumer - - Max Beutel - - adnen chouibi - - Nathan Sepulveda - - Łukasz Chruściel (lchrusciel) - - Jan Vernieuwe (vernija) - - Antanas Arvasevicius - - Adam Kiss - - Pierre Dudoret - - Michal Trojanowski - - Thomas - - j.schmitt - - Georgi Georgiev - - Norbert Schultheisz - - Maximilian Berghoff (electricmaxxx) - - SOEDJEDE Felix (fsoedjede) - - Evgeny Anisiforov - - otsch - - TristanPouliquen - - Dominic Luidold + - Ivan Tse + - Menno Holtkamp + - Pierre Gasté (pierre_g) + - Quentin Favrie + - Matthias Derer + - Brian Freytag + - Lucas Matte + - Success Go + - fmarchalemisys + - Arend Hummeling + - Joseph FRANCLIN + - Oussama Elgoumri + - Andreas Forsblom (aforsblo) + - Mo Di (modi) + - Henne Van Och (hennevo) + - Muharrem Demirci (mdemirci) + - Peter Zwosta + - Nathan DIdier (icz) + - Babichev Maxim (rez1dent3) + - Markus Ramšak + - Andrew Zhilin (zhil) + - Andrew Carter (andrewcarteruk) + - fabi + - Rares Vlaseanu (raresvla) + - Ser5 + - vltrof + - Matteo Giachino (matteosister) + - Gregório Bonfante Borba (bonfante) + - ChrisC + - michal + - Michael Telgmann + - Jody Mickey (jwmickey) + - Ismo Vuorinen + - Thomas Hanke + - Sami Mussbach + - Jan Vernarsky + - Aarón Nieves Fernández + - Grégory Pelletier (ip512) + - Ahto Türkson + - Erfan Bahramali + - valmonzo + - Dmitry Danilson + - Juan Mrad + - Julien Moulin (lizjulien) + - Mauro Foti (skler) + - Ninos + - Markus Staab + - Daniel Strøm + - Michaël VEROUX + - Julia + - Kamil Szalewski (szal1k) - Piotr Antosik (antek88) - - Nacho Martin (nacmartin) - Thibaut Chieux - mwos - Aydin Hassan - - Volker Killesreiter (ol0lll) + - Thomas Baumgartner (shoplifter) + - Pablo Monterde Perez (plebs) + - Danil + - Valentin + - wetternest + - ffd000 + - Zlatoslav Desyatnikov + - Valouleloup + - Pathpat - Vedran Mihočinec (v-m-i) - - Rafał Treffler - - Sergey Novikov (s12v) - - creiner - - Jan Pintr - - ProgMiner - - Marcos Quesada (marcos_quesada) - - Matthew (mattvick) - - MARYNICH Mikhail (mmarynich-ext) - - Viktor Novikov (nowiko) - - Paul Mitchum (paul-m) - - Angel Koilov (po_taka) - - RevZer0 (rav) - - Yura Uvarov (zim32) - - Dan Finnie - - remieuronews - - Marek Binkowski - - Ken Marfilla (marfillaster) - - Max Grigorian (maxakawizard) - - allison guilhem - - benatespina (benatespina) - - Denis Kop - - Fabrice Locher - - Konstantin Chigakov - - Kamil Szalewski (szal1k) - - Jean-Guilhem Rouel (jean-gui) - - Yoann MOROCUTTI - - Ivan Yivoff - - EdgarPE - - jfcixmedia - - Dominic Tubach - - Martijn Evers - - Alexander Onatskiy - - Philipp Fritsche - - Léon Gersen - - tarlepp - - Dustin Wilson - - Benjamin Paap (benjaminpaap) - - Claus Due (namelesscoder) - - Christian - - Alexandru Patranescu - - Sébastien Lévêque (legenyes) - - ju1ius - - Denis Golubovskiy (bukashk0zzz) - - Arkadiusz Rzadkowolski (flies) - - Serge (nfx) - - Oksana Kozlova (oksanakozlova) - - Quentin Moreau (sheitak) - - Mikkel Paulson - - Michał Strzelecki - - Bert Ramakers - - Hans Mackowiak - - Hugo Fonseca (fonsecas72) - - Marc Duboc (icemad) - - uncaught + - Mathieu Ledru (matyo91) + - Willem Verspyck + - Mike Gladysch - Martynas Narbutas - Timothée BARRAY - - Nilmar Sanchez Muguercia - - Pierre LEJEUNE (darkanakin41) - - Bailey Parker - - curlycarla2004 - - Javier Ledezma - - Kevin Auvinet - - Antanas Arvasevicius - - Kris Kelly - - Eddie Abou-Jaoude (eddiejaoude) - - Haritz Iturbe (hizai) - - Nerijus Arlauskas (nercury) - - Stanislau Kviatkouski (7-zete-7) - - Rutger Hertogh - - Diego Sapriza - - Joan Cruz - - inspiran - - Alex Demchenko - - Richard van Velzen - - Cristobal Dabed - - Daniel Mecke (daniel_mecke) - - Matteo Giachino (matteosister) - - Serhii Polishchuk (spolischook) - - Tadas Gliaubicas (tadcka) - - Thanos Polymeneas (thanos) - - Atthaphon Urairat - - Benoit Garret - - HellFirePvP - - Maximilian Ruta (deltachaos) - - Jon Green (jontjs) - - Jakub Sacha - - Julius Kiekbusch - - Kamil Musial - - Lucas Bustamante - - Olaf Klischat - - orlovv - - Claude Dioudonnat - - Jonathan Hedstrom - - Peter Smeets (darkspartan) - - Julien Bianchi (jubianchi) - - Michael Dawart (mdawart) - - Robert Meijers - - Tijs Verkoyen - - James Sansbury - - Marcin Chwedziak - - Dan Kadera - - hjkl - - Dan Wilga - - Thijs Reijgersberg - - Florian Heller - - Oleksii Svitiashchuk - - Andrew Tch - - Alexander Cheprasov - - Tristan Bessoussa (sf_tristanb) - - Rodrigo Díez Villamuera (rodrigodiez) - - Brad Treloar - - pritasil - - Stephen Clouse - - e-ivanov - - Nathanaël Martel (nathanaelmartel) - - Nicolas Jourdan (nicolasjc) + - jack.shpartko + - Simon Asika + - Asrorbek Sultanov + - ondrowan + - Kevin Auivinet + - Nicolas Eeckeloo (neeckeloo) + - Blackfelix + - Vincent AMSTOUTZ (vincent_amstz) + - tsufeki + - tamcy + - Bruno BOUTAREL + - Xesau + - Ahmed EBEN HASSINE (famas23) + - Peter Breuls + - Chansig + - Roman Orlov + - Simon Ackermann + - Elías Fernández + - Jakub Simon + - Samael tomas + - Thibaut Arnoud (thibautarnoud) + - Jonas Hünig + - Mehrdad + - neghmurken + - stefan.r + - Kevin Jansen + - Danilo Silva + - Máximo Cuadros (mcuadros) + - Fabrice Locher + - Paweł Stasicki + - Kirill Saksin + - Mike Milano (mmilano) + - Sepehr Lajevardi + - uncaught - Benjamin Dos Santos - - Abderrahman DAIF (death_maker) - - Yann Rabiller (einenlum) - - GagnarTest (gagnartest) + - Clément Bertillon (skigun) - Jochen Bayer (jocl) - - Tomas Javaisis - - Constantine Shtompel - - VAN DER PUTTE Guillaume (guillaume_vdp) - - Patrick Carlo-Hickman - - Bruno MATEU - - Jeremy Bush - - Lucas Bäuerle - - Laurens Laman - - Thomason, James - - Dario Savella - - Gordienko Vladislav - - Joas Schilling - - Ener-Getick - - Markus Thielen - - Moza Bogdan (bogdan_moza) - - Viacheslav Sychov - - Nicolas Sauveur (baishu) - - Helmut Hummel (helhum) - - Matt Brunt - - Carlos Ortega Huetos - - Péter Buri (burci) - - Evgeny Efimov (edefimov) - - jack.thomas (jackthomasatl) - - John VanDeWeghe - - kaiwa - - Charles Sanquer (csanquer) - - Albert Ganiev (helios-ag) - - Neil Katin - - Oleg Mifle - - V1nicius00 - - David Otton - - Will Donohoe - - peter - - Tugba Celebioglu - - Jeroen de Boer + - Richard van Velzen + - Peter Culka + - Anamarija Papić (anamarijapapic) + - Staormin - Oleg Sedinkin (akeylimepie) - - Jérémy Jourdin (jjk801) - - BRAMILLE Sébastien (oktapodia) - - Loïc Ovigne (oviglo) - - Artem Kolesnikov (tyomo4ka) - - Markkus Millend - - Clément - - Gustavo Adrian - - Jorrit Schippers (jorrit) - - Yann (yann_eugone) - - Matthias Neid - - danilovict2 - - Yannick - - Kuzia - - spdionis - - maxime.perrimond - - rchoquet - - v.shevelev - - rvoisin - - gitlost - - Taras Girnyk - - cthulhu - - Andoni Larzabal (andonilarz) - - Dmitry Derepko - - Rémi Leclerc - - Jan Vernarsky - - Ionut Cioflan - - Sergio - - Jonas Hünig - - Mehrdad - - Amine Yakoubi - - Eduardo García Sanz (coma) - - Arend Hummeling - - Makdessi Alex - - Dmitrii Baranov - - fduch (fduch) - - Juan Miguel Besada Vidal (soutlink) - - Takashi Kanemoto (ttskch) - - Aleksei Lebedev - - dlorek - - Stuart Fyfe - - Jason Schilling (chapterjason) - - David de Boer (ddeboer) - - Eno Mullaraj (emullaraj) - - Guillem Fondin (guillemfondin) - - Nathan PAGE (nathix) - - Ryan Rogers - - Arnaud - - Klaus Purer - - Dmitrii Lozhkin - - Gilles Doge (gido) - - Marion Hurteau (marionleherisson) - - Oscar Esteve (oesteve) - - Sobhan Sharifi (50bhan) - - Peter Potrowl - - abulford - - Philipp Kretzschmar - - Jairo Pastor - - Ilya Vertakov - - Brooks Boyd - - Axel Venet - - Stephen - - Roger Webb - - Dmitriy Simushev - - Pawel Smolinski - - Yury (daffox) - - John Espiritu (johnillo) - - Tomasz (timitao) - - Nguyen Tuan Minh (tuanminhgp) - - Oxan van Leeuwen - - pkowalczyk - - dbrekelmans - - Mykola Zyk - - Soner Sayakci - - Max Voloshin (maxvoloshin) - - Nicolas Fabre (nfabre) - - Raul Rodriguez (raul782) - - Piet Steinhart - - mousezheng - - Radoslaw Kowalewski - - mshavliuk - - Rémy LESCALLIER - - MightyBranch - - Kacper Gunia (cakper) - - Derek Lambert (dlambert) - - Mark Pedron (markpedron) - - Peter Thompson (petert82) - - Victor Macko (victor_m) - - Ismail Turan - - error56 - - Felicitus - - Jorge Vahldick (jvahldick) - - Krzysztof Przybyszewski (kprzybyszewski) - - Vladimir Mantulo (mantulo) - - Boullé William (williamboulle) - - Jesper Noordsij - - Bart Baaten - - Frederic Godfrin - - Paul Matthews - - aim8604 - - Jakub Kisielewski - - Vacheslav Silyutin - - Aleksandr Dankovtsev - - Maciej Zgadzaj - - Juan Traverso - - David Legatt (dlegatt) - - Alain Flaus (halundra) - - Arthur Woimbée - - tsufeki - - Théo DELCEY - - Philipp Strube - - Wim Hendrikx - - Andrii Serdiuk (andreyserdjuk) - - Clement Herreman (clemherreman) - - dangkhoagms (dangkhoagms) - - Dan Ionut Dumitriu (danionut90) - - Evgeny (disparity) - - Floran Brutel (notFloran) (floran) - - Vladislav Rastrusny (fractalizer) - - Vlad Gapanovich (gapik) - - Alexander Kurilo (kamazee) - - nyro (nyro) - - Konstantin Bogomolov - - Marco - - Marc Torres - - Mark Spink - - gndk - - Alberto Aldegheri - - Dalibor Karlović - - Cesar Scur (cesarscur) - - Cyril Vermandé (cyve) - - Daniele Orru' (danydev) - - Raul Garcia Canet (juagarc4) - - Sagrario Meneses - - Dmitri Petmanson - - heccjj - - Alexandre Melard - - Rafał Toboła - - Dominik Schwind (dominikschwind) - - Stefano A. (stefano93) - - PierreRebeilleau - - AlbinoDrought - - Sergey Yuferev - - Monet Emilien - - voodooism - - Tobias Stöckler - - Mario Young - - martkop26 - - Raphaël Davaillaud - - Sander Hagen - - cilefen (cilefen) - - Prasetyo Wicaksono (jowy) - - Mo Di (modi) - - Victor Truhanovich (victor_truhanovich) - - Pablo Schläpfer - - Christian Rishøj - - Nikos Charalampidis - - Caligone - - Roromix - - Patrick Berenschot - - SuRiKmAn - - Xavier RENAUDIN - - rtek - - Christian Wahler (christian) - - Jelte Steijaert (jelte) - - Maxime AILLOUD (mailloud) - - David Négrier (moufmouf) - - Quique Porta (quiqueporta) - - Tobias Feijten (tobias93) - - mohammadreza honarkhah - - Jessica F Martinez - - paullallier - - Artem Oliinyk (artemoliynyk) - - Andrea Quintino (dirk39) - - Andreas Heigl (heiglandreas) - - Tomasz Szymczyk (karion) - - Peter Dietrich (xosofox) - - Alex Vasilchenko - - sez-open - - fruty - - ConneXNL - - Aharon Perkel - - matze - - Adam Wójs (awojs) - - Justin Reherman (jreherman) - - Rubén Calvo (rubencm) - - Abdul.Mohsen B. A. A - - Cédric Girard - - Peter Jaap Blaakmeer - - Robert Worgul - - Swen van Zanten - - Agustin Gomes - - pthompson - - Malaney J. Hill - - Patryk Kozłowski - - Alexandre Pavy - - Tim Ward - - Adiel Cristo (arcristo) - - Christian Flach (cmfcmf) - - Fabian Kropfhamer (fabiank) - - Jeffrey Cafferata (jcidnl) - - Junaid Farooq (junaidfarooq) - - Lars Ambrosius Wallenborn (larsborn) - - Pavel Starosek (octisher) - - Oriol Mangas Abellan (oriolman) - - Sebastian Göttschkes (sgoettschkes) - - Marcin Nowak - - Frankie Wittevrongel - - Tatsuya Tsuruoka - - Ross Tuck - - omniError - - Zander Baldwin - - László GÖRÖG - - djordy - - Kévin Gomez (kevin) - - Mihai Nica (redecs) - - Andrei Igna - - Adam Prickett - - azine - - Luke Towers - - Wojciech Zimoń - - Vladimir Melnik - - Anton Kroshilin - - Pierre Tachoire - - Dawid Sajdak - - Maxime THIRY - - Norman Soetbeer - - Ludek Stepan - - Benjamin BOUDIER - - Frederik Schwan - - Mark van den Berg - - Aaron Stephens (astephens) - - Craig Menning (cmenning) - - Balázs Benyó (duplabe) - - Erika Heidi Reinaldo (erikaheidi) - - William Thomson (gauss) - - Javier Espinosa (javespi) - - Marc J. Schmidt (marcjs) - - František Maša - - Sebastian Schwarz - - Flohw - - karolsojko - - Marco Jantke - - Saem Ghani - - Claudiu Cristea - - Zacharias Luiten - - Sebastian Utz - - Adrien Gallou (agallou) - - Andrea Sprega (asprega) - - Maks Rafalko (bornfree) - - Conrad Kleinespel (conradk) - - Clément LEFEBVRE (nemoneph) - - Viktor Bajraktar (njutn95) - - Walter Dal Mut (wdalmut) - - abluchet - - Ruud Arentsen - - Harald Tollefsen - - PabloKowalczyk - - Matthieu - - ZiYao54 - - Arend-Jan Tetteroo - - Albin Kerouaton - - Sébastien HOUZÉ - - sebastian - - Mbechezi Nawo - - wivaku - - Markus Reinhold - - Jingyu Wang - - steveYeah + - Guillaume Royer + - Kevin Decherf + - Kuzia + - Pavel Golovin (pgolovin) + - Ignacio Alveal + - bahram + - Ruud Seberechts + - ivelin vasilev + - Brian Graham (incognito) + - wallach-game - Asrorbek (asrorbek) - - Samy D (dinduks) - - Keri Henare (kerihenare) - - Andre Eckardt (korve) - - Cédric Lahouste (rapotor) - - Samuel Vogel (samuelvogel) - - Osayawe Ogbemudia Terry (terdia) - - Berat Doğan - - Christian Kolb - - Guillaume LECERF - - Alan Scott - - Juanmi Rodriguez Cerón - - twifty - - Andy Raines - - François Poguet - - Anthony Ferrara - - Geoffrey Pécro (gpekz) - - Klaas Cuvelier (kcuvelier) - - Flavien Knuchel (knuch) - - Mathieu TUDISCO (mathieutu) - - Dmytro Dzubenko - - Martijn Croonen - - Peter Ward - - markusu49 - - Steve Frécinaux - - Constantine Shtompel - - Jules Lamur - - Renato Mendes Figueiredo - - xdavidwu - - Benjamin RICHARD - - Raphaël Droz - - pdommelen - - Eric Stern - - ShiraNai7 - - Cedrick Oka - - Antal Áron (antalaron) - - Guillaume Sainthillier (guillaume-sainthillier) - - Ivan Pepelko (pepelko) - - Vašek Purchart (vasek-purchart) - - Janusz Jabłoński (yanoosh) - - Jens Hatlak - - Fleuv - - Tayfun Aydin - - Łukasz Makuch - - Arne Groskurth - - Ilya Chekalsky - - Ostrzyciel - - George Giannoulopoulos - - Thibault G - - Alexander Pasichnik (alex_brizzz) + - Gerrit Addiks + - Andrea Sprega (asprega) + - taiiiraaa + - Gunnar Lium (gunnarlium) + - Jakub Vrána + - Nil Borodulia - Felix Eymonot (hyanda) - - Luis Ramirez (luisdeimos) - - Ilia Sergunin (maranqz) - - Daniel Richter (richtermeister) - - Sandro Hopf (senaria) - - ChrisC + - Joshua Behrens (joshuabehrens) + - Jean-Christophe Cuvelier [Artack] + - Wouter Diesveld - André Laugks - - jack.shpartko - - Willem Verspyck - - Kim Laï Trinh - - Johan de Ruijter - - Jason Desrosiers - - m.chwedziak - - marbul - - Filippos Karailanidis - - Andreas Frömer - - Jeroen Bouwmans - - Bikal Basnet - - Philip Frank - - David Brooks - - Lance McNearney - - Illia Antypenko (aivus) - - Jelizaveta Lemeševa (broken_core) - - Dominik Ritter (dritter) - - Frank Neff (fneff) - - Volodymyr Kupriienko (greeflas) - - Ilya Biryukov (ibiryukov) - - Mathieu Ledru (matyo91) - - Roma (memphys) - - Jozef Môstka (mostkaj) - - Florian Caron (shalalalala) - - Serhiy Lunak (slunak) - - Wojciech Błoszyk (wbloszyk) - - Giorgio Premi - - Matthias Bilger - - abunch - - tamcy - - Lukas Naumann - - Mikko Pesari - - Krzysztof Pyrkosz + - Steffen Keuper + - Arthur Woimbée + - Ricardo de Vries (ricardodevries) + - Victor Truhanovich (victor_truhanovich) + - Patryk Kozłowski + - Arman + - Sema + - Imangazaliev Muhammad (imangazaliev) + - Jose Manuel Gonzalez (jgonzalez) + - alifanau + - tamirvs + - John Nickell (jrnickell) + - Claudiu Cristea + - Ayke Halder + - Thorsten Hallwas + - Brian Freytag + - Marco Pfeiffer + - Jonathan Poston - Aurélien Fontaine - - ncou - - Ian Carroll - - Dennis Fehr - - caponica - - jdcook - - 🦅KoNekoD - - Daniel Kay (danielkay-cp) - - Matt Daum (daum) - - Malcolm Fell (emarref) - Alberto Pirovano (geezmo) - - inwebo veritas (inwebo) + - RFreij - Pascal Woerde (pascalwoerde) - - Pete Mitchell (peterjmit) - - phuc vo (phucwan) - - Tom Corrigan (tomcorrigan) - - Luis Galeas - - Bogdan Scordaliu - - Martin Pärtel - - Daniel Rotter (danrot) - - Frédéric Bouchery (fbouchery) - - Jacek Kobus (jackks) - - Patrick Daley (padrig) - - Phillip Look (plook) - - Foxprodev - - Artfaith - - developer-av - - Max Summe - - Ema Panz - - Hugo Sales - - Dale.Nash - - DidierLmn - - Pedro Silva - - Chihiro Adachi (chihiro-adachi) - - Clément R. (clemrwan) - - Jeroen de Graaf - - Hossein Hosni - - Ulrik McArdle - - BiaDd - - Oleksii Bulba - - Ramon Cuñat - - mboultoureau - - Raphaëll Roussel - - Vitalii - - Tadcka - - Bárbara Luz - - Abudarham Yuval - - Beth Binkovitz - - adhamiamirhossein - - Maxim Semkin - - Gonzalo Míguez - - Jan Vernarsky - - BrokenSourceCode - - Fabian Haase - - roog - - parinz1234 - - seho-nl - - Romain Geissler - - Martin Auswöger - - Adrien Moiruad - - Viktoriia Zolotova - - Tomaz Ahlin - - Nasim - - Randel Palu - - Anamarija Papić (anamarijapapic) + - pkowalczyk + - Richard Čepas + - Yannick Vanhaeren (yvh) + - Mathieu TUDISCO (mathieutu) + - Andreas Frömer + - Sam Ward + - Hans N. Hjort + - Lance McNearney + - Junaid Farooq (junaidfarooq) + - takashiraki + - Rutger Hertogh + - Diego Sapriza + - excelwebzone + - Nikita Starshinov (biji) + - Rafał Treffler + - Sorin Pop (sorinpop) + - Valentin + - Yurun + - Matthew Donadio + - Sébastien Decrême (sebdec) + - Marc Torres + - Alex Nostadt + - Michael Squires + - Julian Krzefski + - Derek Stephen McLean + - Norman Soetbeer + - Jared Farrish + - Moritz Borgmann (mborgmann) + - Volker (skydiablo) + - Eduardo Conceição + - Pierre-Louis LAUNAY + - Arseny Razin + - Benjamin Rosenberger + - Michael Gwynne - AnotherSymfonyUser (arderyp) - - Marcus Stöhr (dafish) - - Daniel González Zaballos (dem3trio) - - Emmanuel Vella (emmanuel.vella) - - Giuseppe Petraroli (gpetraroli) - - Guillaume BRETOU (guiguiboy) - - Ibon Conesa (ibonkonesa) - - Yoann Chocteau (kezaweb) - - Nikita Popov (nikic) - - nuryagdy mustapayev (nueron) - - Carsten Nielsen (phreaknerd) - - Valérian Lepeule (vlepeule) - - Michael Olšavský - - Jay Severson - - Benny Born - - Vincent Vermeulen - - Stefan Moonen - - Emirald Mateli - - Robert - - Ivan Tse - - René Kerner - - Nathaniel Catchpole - - Jontsa - - Igor Plantaš - - upchuk - - Adrien Samson (adriensamson) - - Samuel Gordalina (gordalina) - - Maksym Romanowski (maxromanovsky) - - Nicolas Eeckeloo (neeckeloo) - - Andriy Prokopenko (sleepyboy) - - Dariusz Ruminski - - Starfox64 - - Ivo Valchev - - Thomas Hanke - - ffd000 + - Vitalii + - Christian Eikermann + - Rénald Casagraude (rcasagraude) + - Koray Zorluoglu + - Artem (digi) + - Ken Marfilla (marfillaster) + - Jelizaveta Lemeševa (broken_core) + - Jacek Kobus (jackks) + - AlberT + - David Courtey (david-crty) + - Martin Komischke + - Peter Potrowl + - Ilya Biryukov (ibiryukov) + - Alexander McCullagh (mccullagh) + - MGDSoft + - Yendric + - Curtis (ccorliss) + - chesteroni (chesteroni) + - Alan Scott + - Konrad Mohrfeldt + - Quentin Moreau (sheitak) + - Andrey Ryaguzov + - Ladislav Tánczos + - Louis-Proffit + - Michał Dąbrowski (defrag) + - “teerasak” + - Yannick Warnier (ywarnier) + - wivaku + - Peter van Dommelen + - Tim van Densen + - Dmitrii Lozhkin + - Charles Sanquer (csanquer) + - Sander Marechal + - Andrzej + - Cédric Lahouste (rapotor) + - Kevin Nadin (kevinjhappy) + - Raphael Davaillaud + - J Bruni + - Frederik Schwan + - Abdiel Carrazana (abdielcs) + - Gennadi Janzen + - SenTisso + - Manatsawin Hanmongkolchai + - Gunther Konig + - Pavel Witassek + - alanzarli + - vlakoff + - Gavin Staniforth + - alex + - MGatner + - Dalibor Karlović + - Paul Matthews + - Luis Muñoz + - kurozumi (kurozumi) + - Malte Schlüter + - Antoine Beyet + - Michal Gebauer + - Jakub Kisielewski + - steveYeah + - Lucas Bustamante + - Žan V. Dragan + - tomasz-kusy + - Nicolas Séverin + - Joel Marcey - Daniel Tschinder - - Arnaud CHASSEUX - - Zlatoslav Desyatnikov - - Wickex - - tuqqu - - Wojciech Gorczyca - - Ahmad Al-Naib - - Neagu Cristian-Doru (cristian-neagu) - - Mathieu Morlon (glutamatt) - - NIRAV MUKUNDBHAI PATEL (niravpatel919) - - Owen Gray (otis) - - Rafał Muszyński (rafmus90) - - Sébastien Decrême (sebdec) - - Timothy Anido (xanido) - - Robert-Jan de Dreu - - Mara Blaga - - Rick Prent - - skalpa - - Kai + - zolikonta + - Guillem Fondin (guillemfondin) + - Artem Kolesnikov (tyomo4ka) + - Gustavo Adrian + - André Laugks + - error56 + - darnel + - Dominic Tubach + - Andras Debreczeni + - sarah-eit + - jean pasqualini (darkilliant) + - Bart Baaten + - Gerhard Seidel (gseidel) + - René Landgrebe + - Daniel Bartoníček + - Vacheslav Silyutin + - Linas Ramanauskas + - joris + - Dan Kadera + - Roeland Jago Douma - Bartłomiej Zając - - Pieter Jordaan - - Tournoud (damientournoud) - - Michael Dowling (mtdowling) - - Karlos Presumido (oneko) - - Pierre Foresi (pforesi) - - Tony Vermeiren (tony) - - Bart Wach - - Jos Elstgeest - - Kirill Lazarev - - Thomas Counsell - - Joe - - BilgeXA - - mmokhi - - Serhii Smirnov - - Robert Queck - - Peter Bouwdewijn - - Kurt Thiemann - - Martins Eglitis - - Daniil Gentili - - Eduard Morcinek - - Wouter Diesveld - - Romain - - Matěj Humpál - - Kasper Hansen - - Nico Hiort af Ornäs - - Eddy - - Amine Matmati - - Kristen Gilden - - caalholm - - Nouhail AL FIDI (alfidi) - - Fabian Steiner (fabstei) - - Felipy Amorim (felipyamorim) - - Guillaume Loulier (guikingone) - - Michael Lively (mlivelyjr) - - Pierre Grimaud (pgrimaud) - - Abderrahim (phydev) - - Attila Bukor (r1pp3rj4ck) - - Thomas Boileau (tboileau) - - Alexander Janssen (tnajanssen) - - Thomas Chmielowiec (chmielot) - - Jānis Lukss - - simbera - - Julien BERNARD - - Michael Zangerle - - rkerner - - Alex Silcock - - Raphael Hardt - - Ivan Nemets - - Dave Long - - Qingshan Luo - - Michael Olšavský - - Ergie Gonzaga - - Matthew J Mucklo - - AnrDaemon - - SnakePin - - Matthew Covey - - Tristan Kretzer - - Adriaan Zonnenberg - - Charly Terrier (charlypoppins) - - Dcp (decap94) + - Jitendra Adhikari (adhocore) + - Giuseppe Arcuti + - Giorgio Premi + - Zacharias Luiten + - Dan Ionut Dumitriu (danionut90) + - Zuruuh - Emre Akinci (emre) - - Rachid Hammaoui (makmaoui) - - Chris Maiden (matason) - - psampaz (psampaz) - - Andrea Ruggiero (pupax) - - Stan Jansen (stanjan) - - Maxwell Vandervelde - - karstennilsen - - kaywalker + - Berat Doğan + - Julius Kiekbusch + - Ahmed HANNACHI (tiecoders) + - WoutervanderLoop.nl - Sebastian Ionescu - - Robert Kopera - - Pablo Ogando Ferreira - - Thomas Ploch - - Victor Prudhomme - - Simon Neidhold + - Patrizio Bekerle + - Tom Maguire + - David Szkiba + - Gilles Gauthier + - Malcolm Fell (emarref) + - Shaun Simmons + - Thomas Counsell + - Toro Hill + - aetxebeste + - Tomas Kmieliauskas + - Andrew Coulton + - Roberto Guido + - Mathieu Dewet (mdewet) + - Patrick Berenschot + - Jakub Sacha + - Arend Hummeling + - Juliano Petronetto + - Max Voloshin (maxvoloshin) + - Raul Rodriguez (raul782) + - Camille Baronnet + - David Soms + - Zakaria AMMOURA (zakariaamm) + - casdal - Wouter Ras - - Gil Hadad - - Valentin VALCIU - - Jeremiah VALERIE - - Alexandre Beaujour - - Franck Ranaivo-Harisoa - - Grégoire Rabasse - - Cas van Dongen - - Patrik Patie Gmitter - - George Yiannoulopoulos - - Yannick Snobbert - - Kevin Dew - - James Cowgill - - Žan V. Dragan - - sensio - - Julien Menth (cfjulien) - - Lyubomir Grozdanov (lubo13) - - Nicolas Schwartz (nicoschwartz) - - Tim Jabs (rubinum) - - Schvoy Norbert (schvoy) - - Stéphane Seng (stephaneseng) - - Peter Schultz - - Robert Korulczyk - - Jonathan Gough - - Benhssaein Youssef - - Benoit Leveque - - bill moll - - Benjamin Bender - - PaoRuby - - Holger Lösken - - Bizley - - Jared Farrish - - Yohann Tilotti - - karl.rixon - - raplider - - Konrad Mohrfeldt - - Lance Chen - - Ciaran McNulty (ciaranmcnulty) - - Dominik Piekarski (dompie) - - Andrew (drew) - - j4nr6n (j4nr6n) - - Rares Sebastian Moldovan (raresmldvn) - - Stelian Mocanita (stelian) - - Gautier Deuette - - dsech - - wallach-game - - Gilbertsoft - - tadas - - Bastien Picharles - - Kirk Madera - - Linas Ramanauskas - - mamazu - - Keith Maika - - izenin - - Mephistofeles - - Oleh Korneliuk - - Emmanuelpcg - - Rini Misini - - Attila Szeremi - - Evgeny Ruban - - Hoffmann András - - LubenZA - - Victor Garcia - - Juan Mrad - - Denis Yuzhanin + - Simon Neidhold + - Vincent Chalamon + - Nei Rauni Santos (nrauni) + - Radosław Benkel + - Laurent Clouet + - Ganesh Chandrasekaran (gxc4795) + - Sezil + - boite + - jersoe + - Loïc Vernet (coil) + - Péter Buri (burci) + - Frederic Godfrin + - Toby Griffiths (tog) + - Paul Le Corre + - Nico Müller (nicomllr) + - Yann Rabiller (einenlum) + - Marek Binkowski + - baron (bastien) + - Kevin Dew + - Pierre Sv (rrr63) + - Eno Mullaraj (emullaraj) + - Justin Rainbow (jrainbow) + - insekticid + - Sergey Novikov (s12v) + - Adam Bramley + - thecaliskan + - goohib + - Geoffrey Monte (numerogeek) - k-sahara - - Flavian Sierk - - Rik van der Heijden - - knezmilos13 - - Thomas Beaujean - - alireza - - Michael Bessolov - - sauliusnord - - Zdeněk Drahoš - - Dan Harper - - moldcraft - - Marcin Kruk - - Antoine Bellion (abellion) - - Ramon Kleiss (akathos) - - Alexey Buyanow (alexbuyanow) - - Antonio Peric-Mazar (antonioperic) - - César Suárez (csuarez) - - Bjorn Twachtmann (dotbjorn) - - Marek Víger (freezy) + - Matthieu + - jannick-holm + - Matthew Burns + - Daniel Bannert + - Ismail Faizi (kanafghan) + - Simon / Yami + - Maciej Paprocki (maciekpaprocki) + - Ross Tuck + - Arkadiusz Rzadkowolski (flies) + - Marcos Quesada (marcos_quesada) + - Shrey Puranik + - Axel Venet + - Kévin Gonella + - Ben Miller + - markusu49 + - Marin Bînzari (spartakusmd) + - Stefanos Psarras (stefanos) + - Roger Webb + - kwiateusz + - Ahmad El-Bardan + - mantulo + - Pavel Barton + - Christian Weiske + - Sjoerd Adema + - Kai Eichinger + - Philip Frank + - Peter Orosz (ill_logical) + - voodooism + - Troy McCabe - Goran (gog) - - Wahyu Kristianto (kristories) - - Tobias Genberg (lorceroth) - - Michael Simonson (mikes) - - Nicolas Badey (nico-b) - - Florent Blaison (orkin) - - Olivier Scherler (oscherler) - - Flo Gleixner (redflo) - - Romain Jacquart (romainjacquart) - - Shane Preece (shane) - - Stephan Wentz (temp) - - Johannes Goslar - - Mike Gladysch - - Geoff - - georaldc - - wusuopu - - Markus Staab - - Wouter de Wild - - Peter Potrowl - - povilas - - andreybolonin1989@gmail.com - - Gavin Staniforth - - bahram - - Alessandro Tagliapietra (alex88) - - Nikita Starshinov (biji) - - Alex Teterin (errogaht) - - Gunnar Lium (gunnarlium) - - Malte Wunsch (maltewunsch) - - Marie Minasyan (marie.minassyan) - - Pavel Stejskal (spajxo) - - Szymon Kamiński (szk) - - Tiago Garcia (tiagojsag) - - Artiom - - Jakub Simon - - TheMhv - - Eviljeks - - robin.de.croock - - Brandon Antonio Lorenzo + - upchuk + - Gyula Szucs + - Tomas Liubinas + - Lars Moelleken + - Dmitrii Baranov + - Nowfel2501 + - James Cowgill + - Ilya Bulakh + - Muhammad Aakash + - Mark Spink + - Alberto Aldegheri + - Oncle Tom + - Pieter Jordaan + - Christian Rishøj + - Daniel Iwaniec + - Thomas Dutrion (theocrite) + - Alexandre Jardin (alexandre.jardin) + - Christian + - Viktor Novikov (nowiko) + - Marcel Berteler + - Christoph Krapp + - Christopher Georg (sky-chris) + - Robert Meijers + - Olexandr Kalaidzhy + - Irmantas Šiupšinskas (irmantas) + - Alan Chen + - Cyril Vermandé (cyve) + - Adoni Pavlakis (adoni) + - Nicolas Le Goff (nlegoff) + - Tero Alén (tero) + - Anton Zagorskii + - Will Donohoe + - Rik van der Heijden + - Erwin Dirks + - Bastien Clément (bastienclement) + - Gerrit Drost + - Billie Thompson + - Kaipi Yann + - Tomanhez + - Konrad - Bouke Haarsma - - Boris Medvedev - - mlievertz - - Radosław Kowalewski - - Enrico Schultz - - tpetry - - Nikita Sklyarov - - JustDylan23 - - Juraj Surman - - Martin Eckhardt - - natechicago - - Victor - - Andreas Allacher - - Abdelilah Jabri - - Alexis - - Leonid Terentyev - - Sergei Gorjunov - - Jonathan Poston - - Adrian Olek (adrianolek) + - cay89 + - Dcp (decap94) + - Julien Bianchi (jubianchi) + - Cas + - William Pinaud (docfx) + - Jason Schilling (chapterjason) - Camille Dejoye (cdejoye) - - cybernet (cybernet2u) - - Jody Mickey (jwmickey) - - Przemysław Piechota (kibao) - - Martin Schophaus (m_schophaus_adcada) - - Martynas Sudintas (martiis) - - Anton Sukhachev (mrsuh) - - Pavlo Pelekh (pelekh) - - Stefan Kleff (stefanxl) - - Marcel Siegert - - ryunosuke - - Bruno BOUTAREL - - John Stevenson - - everyx - - Richard Heine - - Francisco Facioni (fran6co) - - Stanislav Gamaiunov (happyproff) - - Iwan van Staveren (istaveren) - - Alexander McCullagh (mccullagh) - - Paul L McNeely (mcneely) - - Povilas S. (povilas) - - Laurent Negre (raulnet) - - Sergey Fokin (tyraelqp) - - Victoria Quirante Ruiz (victoria) - - Evrard Boulou - - pborreli - - Ibrahim Bougaoua - - Boris Betzholz - - Eric Caron - - Arnau González - - GurvanVgx - - Jiri Falis - - 2manypeople - - Wing - - Thomas Bibb - - Stefan Koopmanschap - - George Sparrow - - Toro Hill - - Joni Halme - - Matt Farmer - - André Laugks - - catch - - aetxebeste - - Roberto Guido - - ElisDN - - roromix - - Vitali Tsyrkin - - Juga Paazmaya - - Alexandre Segura - - afaricamp - - Josef Cech - - riadh26 - - AntoineDly - - Konstantinos Alexiou - - Andrii Boiko - - Dilek Erkut - - mikocevar - - Harold Iedema - - WaiSkats - - Morimoto Ryosuke - - Ikhsan Agustian - - Benoit Lévêque (benoit_leveque) + - Verlhac Gaëtan (viviengaetan) + - Flavian Sierk + - klyk50 + - Walther Lalk + - Vincent Godé + - Michael + - Valentin + - Daniel Londero (dlondero) + - aim8604 + - ZiYao54 + - HellFirePvP + - Conrad Kleinespel (conradk) + - Silas Joisten (silasjoisten) + - Guillaume Lajarige (molkobain) + - Andrei Igna + - Thomas Ploch + - Kristen Gilden + - Simone Di Maulo (toretto460) + - luffy1727 + - Andrew Brown + - divinity76 + - Pavol Tuka + - Armando + - pdragun + - Tito Costa + - Vladislav Rastrusny (fractalizer) + - Vlad Gapanovich (gapik) + - Ilia Sergunin (maranqz) + - Daniel Richter (richtermeister) + - Kim Laï Trinh + - Tobias Weinert (tweini) + - Stanislau Kviatkouski (7-zete-7) + - Kovacs Nicolas + - Stano Turza + - cmfcmf + - Philipp + - Jonathan Gough + - Tom Hart + - Vyacheslav Slinko + - Antoine Leblanc + - Yann (yann_eugone) + - InbarAbraham + - Jason Desrosiers + - Stefan Kleff (stefanxl) + - Sander Goossens (sandergo90) + - Thomas Bibb + - Luis Ramirez (luisdeimos) + - Gerard + - Knallcharge + - Botond Dani (picur) + - Tom Corrigan (tomcorrigan) + - 🦅KoNekoD + - Lukas Naumann + - Vladimir Chernyshev (volch) + - Safonov Nikita (ns3777k) + - Leonid Terentyev + - Rene de Lima Barbosa (renedelima) + - Andrea Giuliano (shark) + - Brian Debuire + - Shane Preece (shane) + - Stephan Wentz (temp) + - amcastror + - Tristan Pouliquen + - Dan Patrick (mdpatrick) + - Ben Gamra Housseine (hbgamra) + - Darryl Hein (xmmedia) + - Trevor N. Suarez (rican7) + - Pierre-Olivier Vares (povares) + - Simon Paarlberg (blamh) + - Christian Wahler (christian) + - Jelte Steijaert (jelte) + - Klaus Purer + - Jean-Guilhem Rouel (jean-gui) + - Albin Kerouaton + - David de Boer (ddeboer) + - Dušan Kasan (dudo1904) + - j4nr6n (j4nr6n) + - remieuronews + - Roromix + - ivan + - Tom Panier (neemzy) + - Diego Aguiar (mollokhan) + - Steffen Persch (n3o77) + - Arkalo2 + - Krzysztof Pyrkosz + - ncou + - Ian Carroll + - Dennis Fehr + - Max Summe + - Ettore Del Negro + - Keri Henare (kerihenare) + - Andre Eckardt (korve) + - Dmitry Simushev - Bernat Llibre Martín (bernatllibre) - - Simon Bouland (bouland) - - Christoph König (chriskoenig) - - Dmytro Pigin (dotty) - - Abdouarrahmane FOUAD (fabdouarrahmane) - - Jakub Janata (janatjak) - - Jm Aribau (jmaribau) - - Matthew Foster (mfoster) - - Paul Seiffert (seiffert) - - Vasily Khayrulin (sirian) + - downace + - Robin Duval (robin-duval) + - pf + - elattariyassine + - Filipe Guerra + - Jean Ragouin + - Rikijs Murgs + - Benjamin Pick - Stas Soroka (stasyan) - Stefan Hüsges (tronsha) + - Pierre Geyer (ptheg) + - Dmitry Hordinky + - Aurimas Rimkus (patrikas) + - Théo DELCEY + - orlovv + - sal-car + - tadas - Jake Bishop (yakobeyak) - - Dan Blows - - popnikos - - Matt Wells - - Nicolas Appriou - - Javier Alfonso Bellota de Frutos - - stloyd - - Tito Costa - - Andreas - - Chris Tickner - - Andrew Coulton - - Ulugbek Miniyarov - - Jeremy Benoist - - Antoine Beyet - - Michal Gebauer - - René Landgrebe - - Phil Davis - - Thiago Melo - - Gleb Sidora - - David Stone - - Giorgio Premi - - Gerhard Seidel (gseidel) - - Jovan Perovic (jperovic) - - Pablo Maria Martelletti (pmartelletti) - - Sebastian Drewer-Gutland (sdg) - - Sander van der Vlugt (stranding) - - casdal - - Florian Bogey - - Waqas Ahmed - - Bert Hekman - - Luis Muñoz - - Matthew Donadio - - Kris Buist - - Houziaux mike - - Phobetor - - Eric Schildkamp - - Yoann MOROCUTTI - - d.huethorst - - Markus - - Zayan Goripov - - agaktr - - Janusz Mocek - - Johannes - - Mostafa - - kernig - - Thomas Chmielowiec - - shdev - - Andrey Ryaguzov - - Gennadi Janzen - - SenTisso - - Stefan - - Peter Bex - - Manatsawin Hanmongkolchai - - Gunther Konig - - Joe Springe - - Mickael GOETZ - - Tobias Speicher - - Jesper Noordsij - - DerStoffel - - Flinsch + - psampaz (psampaz) + - Jean-Baptiste Nahan + - Mert Simsek (mrtsmsk0) + - Kevin Verschaeve (keversc) + - Chris de Kok + - Albert Ganiev (helios-ag) + - Arnaud CHASSEUX + - GuillaumeVerdon + - Andrea Ruggiero (pupax) + - Rein Baarsma (solidwebcode) + - tante kinast (tante) + - Tim Strehle + - Sébastien COURJEAN + - Tischoi + - Ivan Pepelko (pepelko) + - Marvin Butkereit + - Andriy Prokopenko (sleepyboy) + - Sven Fabricius + - Jaymin G + - robmro27 + - Eric Stern + - Guillaume BRETOU (guiguiboy) + - Manuele Menozzi + - Grzegorz Łukaszewicz (newicz) + - Mark de Haan (markdehaan) + - Maxime Corteel (mcorteel) + - Mathieu MARCHOIS (mmar) + - Ernesto Domato + - Matheus Gontijo + - Abudarham Yuval + - Beth Binkovitz + - adhamiamirhossein + - Anthony Moutte + - mousezheng + - karolsojko + - Stan Jansen (stanjan) + - Paul L McNeely (mcneely) + - Soner Sayakci + - emilienbouard (neime) + - Aleksandr Dankovtsev - Maciej Schmidt - - botbotbot - tatankat - Cláudio Cesar - Sven Nolting - - Timon van der Vorm + - Lesnykh Ilia + - Shyim - nuncanada - - Thierry Marianne - - František Bereň - - G.R.Dalenoort - - Jeremiah VALERIE - - Mike Francis - - Nil Borodulia - - Adam Katz - - Almog Baku (almogbaku) - - Boris Grishenko (arczinosek) - - Arrakis (arrakis) - - Danil Khaliullin (bifidokk) - - Benjamin Schultz (bschultz) - - Christian Grasso (chris54721) - - Vladimir Khramtsov (chrome) - - Gerd Christian Kunze (derdu) - - Stephanie Trumtel (einahp) - - Denys Voronin (hurricane) - - Ionel Scutelnicu (ionelscutelnicu) - - Jordan de Laune (jdelaune) - - Juan Gonzalez Montes (juanwilde) - - Kamil Madejski (kmadejski) - - Mathieu Dewet (mdewet) - - none (nelexa) - - Nicolas Tallefourtané (nicolab) - - Botond Dani (picur) - - Rémi Faivre (rfv) - - Radek Wionczek (rwionczek) - - Nick Stemerdink - - Bernhard Rusch - - David Stone - - Vincent Bouzeran - - Grayson Koonce - - Ruben Jansen - - Wissame MEKHILEF - - Mihai Stancu - - shreypuranik - - NanoSector - - Thibaut Salanon - - Romain Dorgueil - - Christopher Parotat - - Andrey Helldar - - Dennis Haarbrink - - Daniel Kozák - - Urban Suppiger - - 蝦米 - - Julius Beckmann (h4cc) - - Julien JANVIER (jjanvier) - - Karim Cassam Chenaï (ka) - - Lorenzo Adinolfi (loru88) - - Marcello Mönkemeyer (marcello-moenkemeyer) - - Ahmed Shamim Hassan (me_shaon) - - Michal Kurzeja (mkurzeja) - - Nicolas Bastien (nicolas_bastien) - - Nikola Svitlica (thecelavi) - - Andrew Zhilin (zhil) - - Sjors Ottjes - - azjezz - - VojtaB - - Andy Stanberry - - Felix Marezki + - Neophy7e + - Emilien Escalle + - jwaguet + - Flinsch + - Maxime P + - Sean Templeton + - db306 + - Sylvain METAYER + - Steve Preston + - Omar Yepez (oyepez003) + - Przemysław Piechota (kibao) + - Ibon Conesa (ibonkonesa) + - Sergey Fokin (tyraelqp) + - Storkeus + - Pavel Stejskal (spajxo) + - ddegentesh + - DSeemiller + - Piet Steinhart + - Cesar Scur (cesarscur) + - Nikita Popov (nikic) + - nuryagdy mustapayev (nueron) + - Igor Plantaš + - Klaas Naaijkens + - Bojan + - Rafał + - Damien Fernandes + - Jan Pintr + - Starfox64 + - Florent Cailhol + - Dmitri Petmanson + - David Négrier (moufmouf) + - Ruben Jansen + - Reda DAOUDI + - Ruud Arentsen + - Saem Ghani + - Warwick + - Daniel Kolvik (dkvk) + - tsilefy + - Peter Gribanov + - Bart Brouwer (bartbrouwer) + - Anna Filina (afilina) + - Yannick + - Gabi Udrescu + - Enrico + - Adrien Foulon + - Sylvain Just + - andreybolonin1989@gmail.com + - Angel Koilov (po_taka) + - Andrew Tch + - david perez (davidpv) + - Duncan de Boer (farmer-duck) + - Harald Tollefsen + - PabloKowalczyk + - Dmytro Dzubenko + - Cedrick Oka + - Serhiy Lunak (slunak) + - Jeroen Bouwmans + - Shiro + - Łukasz Makuch + - Arne Groskurth + - pthompson + - georaldc + - Simon Müller (boscho) + - Steeve Titeca (stiteca) + - Simone Fumagalli (hpatoio) + - Peter Dietrich (xosofox) + - Cyrille Jouineau (tuxosaurus) + - Maxime Aknin (3m1x4m) + - Lauris Binde (laurisb) + - Albion Bame (abame) + - Eduardo García Sanz (coma) + - Tim Ward + - BiaDd + - Olatunbosun Egberinde + - Alexis Lefebvre + - Johannes + - Christian Flach (cmfcmf) + - Bogdan Rancichi (devck) + - Willem Mouwen + - Ikko Ashimine + - Alexandre GESLIN + - Dariusz Ruminski + - Eduard Morcinek + - ShiraNai7 + - RichardGuilland + - Mykola Zyk + - Grégoire Hébert (gregoirehebert) + - AbdElKader Bouadjadja + - Pavel Starosek (octisher) + - Emre YILMAZ + - Christian Kolb + - David Soria Parra + - changmin.keum + - Sébastien HOUZE + - popnikos + - Kasper Hansen + - Saem Ghani + - Szymon Kamiński (szk) + - Stefan Koopmanschap + - Tatsuya Tsuruoka + - omniError + - Stuart Fyfe + - TheMhv + - Benoit Garret + - Vincent LEFORT (vlefort) + - Valentin Nazarov + - fduch (fduch) + - Kris Buist + - Kevin Weber + - Juan Luis (juanlugb) + - Andrew (drew) + - Gautier Deuette + - Tito Miguel Costa (titomiguelcosta) + - andrey-tech + - Tobias Feijten (tobias93) + - Nicolas Badey (nico-b) + - Carl Julian Sauter + - Mikko Pesari + - jdcook + - Kenjy Thiébault (kthiebault) + - Yury (daffox) + - Markus Tacker + - Juan Miguel Besada Vidal (soutlink) + - samuel laulhau (lalop) + - Matt Drollette (mdrollette) + - Talha Zekeriya Durmuş + - Michal Forbak + - John Edmerson Pizarra + - Taylan Kasap + - Michael Orlitzky + - Juraj Surman + - heccjj + - Florian Guimier + - Laurent Bachelier (laurentb) + - Adam Monsen (meonkeys) + - Nathan PAGE (nathix) + - Florent Blaison (orkin) + - Andrei O + - Łukasz Chruściel (lchrusciel) + - Jordi Rejas + - mlievertz + - Takashi Kanemoto (ttskch) + - peter + - g123456789l + - Roman Tymoshyk (tymoshyk) - Normunds - Yuri Karaban + - Jan Hort + - Stephanie Trumtel (einahp) - Walter Doekes - - Johan - Thomas Rothe - - Edwin - - Troy Crawford - - Kirill Roskolii - - Jeroen van den Nieuwenhuisen - - nietonfir - - Andriy - - Taylor Otwell - - alefranz - - David Barratt - - Andrea Giannantonio - - Pavel.Batanov - - avi123 - - Pavel Prischepa - - Philip Dahlstrøm - - Pierre Schmitz - - Sami Mussbach - - qzylalala - - alsar - - downace - - Aarón Nieves Fernández - - Mikolaj Czajkowski - - Ahto Türkson - - Paweł Stasicki - - Ph3nol - - Kirill Saksin - - Shiro - - Reda DAOUDI - - Koalabaerchen - - michalmarcinkowski - - Warwick - - Chris - - Farid Jalilov - - Christiaan Wiesenekker - - Ariful Alam - - Florent Olivaud - - Foxprodev - - Eric Hertwig - - JakeFr - - Dmitry Hordinky - - Oliver Klee - - Niels Robin-Aubertin - - Simon Sargeant - - efeen - - Mikko Ala-Fossi - - Jan Christoph Beyer - - withbest - - Nicolas Pion - - Muhammed Akbulut - - Daniel Tiringer - - Xesau - - Koray Zorluoglu - - Roy-Orbison - - Aaron Somi - - kshida - - Yasmany Cubela Medina (bitgandtter) - - Michał Dąbrowski (defrag) + - Alessandra Lai + - timesince + - alangvazq + - Ernest Hymel + - Andrea Civita + - Kévin Gomez (kevin) + - Rafael Villa Verde + - Albert Bakker (babbert) + - Adamo Crespi (aerendir) + - Karim Miladi - Aryel Tupinamba (dfkimera) - - Hans Höchtl (hhoechtl) - - Simone Fumagalli (hpatoio) - - Brian Graham (incognito) - - Kevin Vergauwen (innocenzo) - - Alessio Baglio (ioalessio) - - Johannes Müller (johmue) - - Jordi Llonch (jordillonch) - - julien_tempo1 (julien_tempo1) - - Roman Igoshin (masterro) + - Julius (sakalys) + - Jörn Lang + - Alan ZARLI + - Bertalan Attila + - Abdouarrahmane FOUAD (fabdouarrahmane) + - Rowan Manning + - Jakub Janata (janatjak) + - Joeri Verdeyen (jverdeyen) + - Ruslan Zavacky (ruslanzavacky) + - Jakub Caban (lustmored) + - Stefano Cappellini (stefano_cappellini) + - Bruno MATEU + - Juanmi Rodriguez Cerón + - Joseph Maarek + - Alexander Menk + - Ville Mattila + - Buster Neece + - Adam + - Albert Prat + - Johannes + - Yuriy Potemkin + - Nicolás Alonso + - Roman Tyshyk + - LoginovIlya + - Hossein Hosni + - Emilie Lorenzo + - Alessandro Loffredo + - Seyedramin Banihashemi (ramin) + - Jakub Chábek + - Dmitriy Tkachenko (neka) + - Johannes + - Andre Johnson + - MaPePeR + - Andreas Streichardt + - jamogon + - david-binda + - rogamoore + - Christoph König (chriskoenig) + - Valérian Galliat + - Jeremy Bush + - Fred Cox + - Lucas Bäuerle + - Jeremy Benoist + - Frédéric G. Marand (fgm) + - rhel-eo + - Thijs Reijgersberg + - Vallel Blanco + - Yannick Bensacq (cibou) + - Sander Hagen + - Yevhen Sidelnyk + - Volodymyr Kupriienko (greeflas) + - Renato Mendes Figueiredo + - Andrew Clark (tqt_andrew_clark) + - Aaron Piotrowski (trowski) + - David Lumaye (tux1124) + - Arnaud Buathier (arnapou) + - czachor + - Johan + - Jörg Rühl + - Pierre LEJEUNE (darkanakin41) + - Guillaume Loulier (guikingone) + - Dmytro Pigin (dotty) + - Bailey Parker + - curlycarla2004 + - Daniele Orru' (danydev) + - Thomas BERTRAND (sevrahk) + - Dr. Gianluigi "Zane" Zanettini + - Tristan Bessoussa (sf_tristanb) + - Vladislav (simpson) + - ConneXNL + - Rémi Blaise + - Zander Baldwin + - izenin + - Lebnik + - Bohdan Pliachenko + - Francisco Facioni (fran6co) + - Markus + - agaktr + - Till Klampaeckel (till) - Nicholas Ruunu (nicholasruunu) - Pierre Rebeilleau (pierrereb) - - Milos Colakovic (project2481) - - Raphael de Almeida (raphaeldealmeida) - - Rénald Casagraude (rcasagraude) - - Robin Duval (robin-duval) - - Mohammad Ali Sarbanha (sarbanha) - - Sergii Dolgushev (sergii-swds) - - Steeve Titeca (stiteca) - - Thomas Citharel (tcit) - - Artem Lopata (bumz) - - Soha Jin - - alex - - Alex Niedre - - evgkord - - Roman Orlov - - Simon Ackermann - - Andreas Allacher - - VolCh - - Alexey Popkov - - Gijs Kunze - - Artyom Protaskin - - Steven Dubois - - Nathanael d. Noblet - - Yurun - - helmer - - ged15 - - Simon Asika - - CDR - - Daan van Renterghem - - Bálint Szekeres - - Boudry Julien - - amcastror - - Bram Van der Sype (brammm) - - Guile (guile) - - Mark Beech (jaybizzle) - - Julien Moulin (lizjulien) - - Raito Akehanareru (raito) - - Mauro Foti (skler) - - Thibaut Arnoud (thibautarnoud) - - Valmont Pehaut-Pietri (valmonzo) - - Yannick Warnier (ywarnier) - - Jörn Lang - - Kevin Decherf - - Paul LE CORRE - - Christian Weiske - - Maria Grazia Patteri - - klemens - - dened - - muchafm - - jpauli - - Dmitry Korotovsky - - Michael van Tricht - - ReScO - - Tim Strehle - - Sébastien COURJEAN - - cay89 - - Sam Ward - - Hans N. Hjort - - Marko Vušak - - Walther Lalk - - Adam - - Ivo - - vltrof - - Ismo Vuorinen - - Markus Staab - - Valentin - - Gerard - - Sören Bernstein - - michael.kubovic - - devel - - Iain Cambridge - - taiiiraaa - - Ali Tavafi - - gedrox - - Viet Pham - - Alan Bondarchuk - - Pchol - - Shamimul Alam - - Cyril HERRERA - - dropfen - - RAHUL K JHA - - Andrey Chernykh - - Edvinas Klovas - - Drew Butler - - Peter Breuls - - Kevin EMO - - Chansig - - Tischoi - - divinity76 - - vdauchy - - Andreas Hasenack - - J Bruni - - Alexey Prilipko - - vlakoff + - Hugo Posnic + - Nicolas Roudaire + - Barthold Bos + - Mathias Geat + - neodevcode + - Emmanuel Vella (emmanuel.vella) + - Oleksii Bulba + - Guillaume LECERF + - Raul Garcia Canet (juagarc4) + - Tobias Stöckler + - Dustin Wilson + - withbest + - Joe Springe + - Abdelhakim ABOULHAJ + - Pieter + - Kamil Musial + - Jeremiah VALERIE + - Aaron Stephens (astephens) + - Craig Menning (cmenning) + - Balázs Benyó (duplabe) + - Ema Panz + - Mauricio Lopez (diaspar) + - Ismail Asci (ismailasci) + - Rafał Muszyński (rafmus90) - Anthony Tenneriello - - thib92 - - Yiorgos Kalligeros - - Rudolf Ratusiński - - Bertalan Attila - - Arek Bochinski - - Rafael Tovar - - Amin Hosseini (aminh) - - AmsTaFF (amstaff) - - Simon Müller (boscho) - - Yannick Bensacq (cibou) - - Cyrille Bourgois (cyrilleb) - - Damien Vauchel (damien_vauchel) - - Dmitrii Fedorenko (dmifedorenko) - - William Pinaud (docfx) - - Frédéric G. Marand (fgm) + - Athorcis + - Thierry Marianne + - David Windell + - Frank Jogeleit + - Benny Born + - Arrilot + - Dan (dantleech) + - Makdessi Alex + - Mikkel Paulson + - Paul Ferrett + - Joachim Krempel (jkrempel) - Freek Van der Herten (freekmurze) - - Luca Genuzio (genuzio) - - Ben Gamra Housseine (hbgamra) + - Matthias Bilger + - Tom Kaminski + - Abdulkadir N. A. + - Emmanuel Dreyfus + - Ilya Vertakov + - Brooks Boyd + - Markus Klein + - Bruno Nogueira Nascimento Wowk + - Jan Emrich + - paullallier + - Artem Oliinyk (artemoliynyk) + - Andrea Quintino (dirk39) - Andrew Marcinkevičius (ifdattic) - - Ioana Hazsda (ioana-hazsda) - - Jan Marek (janmarek) - - Mark de Haan (markdehaan) - - Maxime Corteel (mcorteel) - - Dan Patrick (mdpatrick) - - Mathieu MARCHOIS (mmar) - - Nei Rauni Santos (nrauni) - - Geoffrey Monte (numerogeek) - - Martijn Boers (plebian) - - Plamen Mishev (pmishev) - - Pedro Magalhães (pmmaga) - - Rares Vlaseanu (raresvla) - - Trevor N. Suarez (rican7) - - Sergii Dolgushev (serhey) - - Clément Bertillon (skigun) - - Rein Baarsma (solidwebcode) - - tante kinast (tante) - - Stephen Lewis (tehanomalousone) - - Ahmed HANNACHI (tiecoders) - - Vincent LEFORT (vlefort) - - Walid BOUGHDIRI (walidboughdiri) - - Wim Molenberghs (wimm) - - Darryl Hein (xmmedia) - - Vladimir Sadicov (xtech) - - Marcel Berteler - - sdkawata - - Frederik Schmitt - - Peter van Dommelen - - Tim van Densen - - Andrzej - - Alexander Zogheb - - tomasz-kusy - - Rémi Blaise - - Nicolas Séverin - - patrickmaynard - - Houssem - - Joel Marcey - - zolikonta - - Daniel Bartoníček - - Michael Hüneburg - - David Christmann - - root - - pf - - Zoli Konta - - Vincent Chalnot - - Roeland Jago Douma - - Patrizio Bekerle - - Tom Maguire - - Mateusz Lerczak - - Tim Porter - - Richard Quadling - - Will Rowe - - Rainrider + - Neil Katin + - Oleg Mifle + - David Otton + - Andreas Heigl (heiglandreas) + - Dawid Nowak + - William Thomson (gauss) + - Phil Davis + - Alex Vasilchenko + - Brieuc Thomas + - developer-av + - Malte Wunsch (maltewunsch) + - Romain Geissler + - tamar peled + - Maxim Lovchikov + - Laurent G. (laurentg) + - John Espiritu (johnillo) + - dakur + - Wotre + - Alexandru Bucur + - Alexis BOYER + - Adrian Philipp + - James Michael DuPont + - DidierLmn + - Kasperki + - Javier Alfonso Bellota de Frutos + - Matthias Meyer + - carlos-ea + - Temuri Takalandze (abgeo) + - David Legatt (dlegatt) + - A. Pauly + - Nicolas A. Bérard-Nault + - Karolis Daužickas (kdauzickas) + - Bernard van der Esch (adeptofvoltron) + - Aleksejs Kovalovs (aleksejs1) + - Chris McGehee + - Tomasz (timitao) + - Giuseppe Petraroli (gpetraroli) + - Stéphane Seng (stephaneseng) + - Julien Manganne (juuuuuu) + - Matt Ketmo (mattketmo) + - Pierre Foresi (pforesi) + - karl.rixon + - Alexander Kurilo (kamazee) + - Claus Due (namelesscoder) + - Carsten Nielsen (phreaknerd) + - Valérian Lepeule (vlepeule) + - Stephen Lewis (tehanomalousone) + - Thanos Polymeneas (thanos) + - Sergey Stavichenko (sergey_stavichenko) + - Matej Žilák (teo_sk) + - satalaondrej + - Arek Bochinski + - Ostrzyciel + - George Giannoulopoulos + - VojtaB + - Vašek Purchart (vasek-purchart) + - Vic D'Elfant (vicdelfant) + - Amirreza Shafaat (amirrezashafaat) + - Michael Dowling (mtdowling) + - Iwan van Staveren (istaveren) + - Dominik Pesch (dombn) + - Julien BERNARD + - Drew Butler + - Luciano Mammino (loige) + - Tamás Szigeti + - DerStoffel + - Thomas Boileau (tboileau) + - Carlos Tasada + - tinect (tinect) + - Sebastian Göttschkes (sgoettschkes) + - mieszko4 + - Mamikon Arakelyan (mamikon) + - Oz (import) + - Bernhard Rusch + - David Stone + - Vincent Bouzeran + - Matt Farmer + - Benoit Lévêque (benoit_leveque) + - Mihai Nica (redecs) + - Nouhail AL FIDI (alfidi) + - Michael Lively (mlivelyjr) + - Jules Matsounga (hyoa) + - Bikal Basnet + - David Brooks + - Jiri Falis + - Kérian MONTES-MORIN (kerianmm) + - Tobias Speicher + - rewrit3 + - Peter Bex + - Ciaran McNulty (ciaranmcnulty) + - Dominik Piekarski (dompie) + - David Joos (djoos) + - Dennis Smink (dsmink) + - Sebastian Utz + - Emmanuelpcg + - Iain Cambridge + - Pierre Rineau + - Jochen Mandl + - Viet Pham + - Max Grigorian (maxakawizard) + - michalmarcinkowski + - cybernet (cybernet2u) + - Pierre Grimaud (pgrimaud) + - sez-open + - Robert Campbell + - Matt Lehner + - Helmut Januschka + - Hein Zaw Htet™ + - fruty + - Aharon Perkel + - Aleksandar Dimitrov (netbull) + - Pierre-Henry Soria 🌴 (pierrehenry) + - Alexis + - Michael Genereux + - Vincent Vermeulen + - Thomas Jarrand + - abunch + - Marek Šimeček (mssimi) + - Patrick Luca Fazzi (ap3ir0n) - David Zuelke - Adrian - Oliver Eglseder - - neFAST - - Peter Gribanov - - zcodes - - Pierre Rineau - - Florian Morello - - Maxim Lovchikov + - Marcin Chwedziak + - Mark Topper + - Xavier REN + - Faton (notaf) + - martijn + - Sergei Shitikov + - Jens Schulze + - Jessica F Martinez + - Tema Yud + - Kevin Meijer + - Juan Traverso + - Jonny Schmid (schmidjon) + - Christian Stocker + - Jon Green (jontjs) + - Alexander Janssen (tnajanssen) + - Vladimir Vasilev (bobahvas) + - Anton (bonio) + - spdionis + - Thibault G + - Victoria Quirante Ruiz (victoria) + - Evrard Boulou + - pborreli + - Constantine Shtompel + - pawel-lewtak + - Pierrick Charron + - Steve Müller + - Ferran Vidal + - Michael J + - Gary Houbre (thegarious) + - damaya + - Marc Bennewitz + - Pierre-Chanel Gauthier (kmecnin) + - Kirill Roskolii + - Gonzalo Míguez - adenkejawen - - Florent SEVESTRE (aniki-taicho) - - Ari Pringle (apringle) - - Dan Ordille (dordille) - - Jan Eichhorn (exeu) + - Dmitry (staratel) + - Flavien Knuchel (knuch) + - jonmldr + - Peter Ward + - andreyserdjuk + - martkop26 + - Alex Olmos (alexolmos) + - Andriy + - Taylor Otwell + - Cédric Girard + - Raphaël Davaillaud + - Martin Mandl (m2mtech) + - David Gorges (davidgorges) + - Gustavo Adrian + - Alexander Bauer (abauer) + - kaiwa + - Ian Littman (iansltx) + - chispita + - Wojciech Sznapka + - Nathan Sepulveda + - Olaf Klischat + - Jeffrey Cafferata (jcidnl) + - Iliya Miroslavov Iliev (i.miroslavov) + - Gert de Pagter + - Sergiy Sokolenko + - Karel Syrový + - Claas Augner + - Houziaux mike + - Ariel J. Birnbaum + - Angel Fernando Quiroz Campos (angelfqc) + - Charles-Henri Bruyand + - Giuseppe Campanelli + - Sam Anthony + - David Lima + - azine + - Bart Ruysseveldt + - Alexandre Tranchant (alexandre_t) + - Steve Marvell + - thib92 + - Thibaut Salanon + - Jan Vernarsky + - Rudolf Ratusiński + - Hans Höchtl (hhoechtl) + - Peter Thompson (petert82) + - Fabian Haase + - parinz1234 + - seho-nl + - Erika Heidi Reinaldo (erikaheidi) + - Yevgen Kovalienia + - James Sansbury + - Sam Malone + - Kai Dederichs + - Cantepie + - Derek Bonner + - Krzysztof Menżyk (krymen) + - Nicholas Byfleet (nickbyfleet) + - Pontus Mårdnäs + - Arkadiusz Kondas (itcraftsmanpl) + - Viktoriia Zolotova + - Abderrahim (phydev) + - Attila Bukor (r1pp3rj4ck) + - Mickael GOETZ + - Andreas + - Ulugbek Miniyarov + - neFAST + - Martynas Sudintas (martiis) - Georg Ringer (georgringer) - - Grégory Pelletier (ip512) + - Eric Caron + - Stefan Oderbolz + - Steve Frécinaux + - Rémy LESCALLIER + - Alexey Popkov + - qzylalala + - Ali Tavafi + - Tony Vermeiren (tony) + - Tom Houdmont + - es + - Wickex + - Ala Eddine Khefifi (nayzo) + - NothingWeAre + - goabonga + - Maciej Zgadzaj + - Alexandru Patranescu + - Derek Lambert (dlambert) + - Gabriel Birke + - Daniele Cesarini (ijanki) + - ju1ius + - gstapinato + - Matthias Neid + - Javier Espinosa (javespi) + - Ilia Lazarev (ilzrv) + - Klaas Cuvelier (kcuvelier) + - JustDylan23 + - Dennis Tobar + - Javan Eskander + - Gordienko Vladislav + - arduanov + - Lenar Lõhmus + - Guillaume Sainthillier (guillaume-sainthillier) + - MusikAnimal + - Richard Quadling + - Pete Mitchell (peterjmit) + - phuc vo (phucwan) + - Jm Aribau (jmaribau) + - Matthew Foster (mfoster) + - Paul Seiffert (seiffert) + - GurvanVgx + - marbul + - Abderrahman DAIF (death_maker) + - Robert Worgul + - Simon Frost + - Constantine Shtompel + - Diego Campoy + - Adrien Moiruad + - Swen van Zanten + - Marcus + - Gemorroj (gemorroj) + - Reece Fowell (reecefowell) + - Julien ARBEY + - Bert Ramakers + - Michael Bessolov + - mmokhi + - ProgMiner + - Ionel Scutelnicu (ionelscutelnicu) + - Signor Pedro + - Robin Kanters (anddarerobin) + - Jérémie Broutier + - Luis Galeas + - Bogdan Scordaliu + - Dominic Luidold + - Thomas Bibaut + - Wojciech Zimoń + - Nikita Sklyarov + - Benjamin Ellis + - Evgeniy Koval + - Rodrigo Díez Villamuera (rodrigodiez) + - Adria Lopez (adlpz) + - Malaney J. Hill + - Frank Naegler + - jfcixmedia + - Artem (nexim) + - Shamimul Alam + - xdavidwu + - Raphaël Droz + - François Poguet + - Nathaniel Catchpole + - Johan de Ruijter + - Tugba Celebioglu + - Matt Brunt + - Jon Cave + - Cyril HERRERA + - szymek + - Justin Reherman (jreherman) + - Abdul.Mohsen B. A. A + - nerdgod + - dropfen + - RAHUL K JHA + - DaikiOnodera + - The Whole Life to Learn + - Antoine (antoinela_adveris) + - Pawel Szczepanek (pauluz) + - Sebastian Busch (sebu) + - Christian López Espínola (penyaskito) + - Anton Kroshilin + - sabruss + - SnakePin + - Bram Tweedegolf (bram_tweedegolf) + - Norman Soetbeer + - Dave Heineman (dheineman) + - Benjamin Franzke + - Pierre Tachoire + - Oleg Golovakhin (doc_tr) + - andreabreu98 + - Viktor Bajraktar (njutn95) + - Maxime PINEAU + - Igor Kokhlov (verdet) + - Kevin Herrera (kherge) + - matze + - Peter Trebaticky + - Nicolas Fabre (nfabre) + - Jiří Bok + - Chris Jones (leek) + - Alexis MARQUIS + - Florian Cellier + - shreyadenny + - Adam Elsodaney (archfizz) + - Dionysis Arvanitis + - Vitali Tsyrkin + - Gabriel Moreira + - Josef Cech + - Enrico Schultz + - Xavier RENAUDIN - Johan Wilfer (johanwilfer) - - John Nickell (jrnickell) - - Martin Mayer (martin) - - Grzegorz Łukaszewicz (newicz) - - Nico Müller (nicomllr) - - Omar Yepez (oyepez003) - - Jonny Schmid (schmidjon) - - Toby Griffiths (tog) + - xaav + - Ruben Kruiswijk + - Cosmin-Romeo TANASE + - tuqqu + - Romain Jacquart (romainjacquart) + - Alex Vo (votanlean) + - hainey + - Arash Tabrizian (ghost098) + - vdauchy + - Dominik Hajduk (dominikalp) + - Marien Fressinaud + - Jesper Søndergaard Pedersen (zerrvox) + - Amaury Leroux de Lens (amo__) + - Kirill Lazarev + - Ivan Nemets + - Benhssaein Youssef + - gondo (gondo) + - Adrien Chinour + - eRIZ + - David Vancl + - Maxim Semkin + - Yoann MOROCUTTI + - Wim Godden (wimg) + - cgonzalez + - Mehdi Achour (machour) + - Alex Plekhanov + - Yorkie Chadwick (yorkie76) + - V1nicius00 + - Matteo Galli + - afaricamp + - Rudy Onfroy + - Thomas Chmielowiec + - Kélian Bousquet (kells) + - David Stone + - Waqas Ahmed + - Jorrit Schippers (jorrit) + - Karim Cassam Chenaï (ka) + - Denis Golubovskiy (bukashk0zzz) + - Fleuv + - Franz Liedke (franzliedke) + - Liverbool (liverbool) - Ashura - Götz Gottwald - - Alessandra Lai - - alangvazq - - Christoph Krapp - - Ernest Hymel - - Andrea Civita - - Nicolás Alonso - - Roman Tyshyk - - LoginovIlya - - andreyserdjuk + - Piotr Zajac - Nick Chiu - Thanh Trần - - Robert Campbell - - Matt Lehner - - carlos-ea - - Olexandr Kalaidzhy - - Helmut Januschka - - Jérémy Benoist - - Hein Zaw Htet™ - - Ruben Kruiswijk - - Cosmin-Romeo TANASE - - Ferran Vidal - - Michael J - - sal-car + - Gaylord Poillon (gaylord_p) + - Almog Baku (almogbaku) + - MightyBranch + - Rachid Hammaoui (makmaoui) + - Boris Grishenko (arczinosek) + - Ash014 + - Jérémy (libertjeremy) + - Alexandre Fiocre (demos77) + - drublic + - Patrik Patie Gmitter + - JuntaTom (juntatom) + - Serge (nfx) + - Geoffrey Pécro (gpekz) + - Andras Ratz + - Romain Dorgueil + - Karlos Presumido (oneko) + - Christopher Parotat + - Rafael Tovar + - Dennis Haarbrink + - Ahmed Shamim Hassan (me_shaon) + - oscartv + - JakeFr + - Oliver Klee + - Jules Lamur + - mark burdett + - mindaugasvcs + - Ksaveras Šakys (xawiers) + - Lin Clark + - RevZer0 (rav) + - JK Groupe + - Agustin Gomes + - Andreas Allacher + - Brad Treloar + - parhs + - jc + - Alexey Popkov + - soyuka + - dened + - Arnaud + - Marcel Siegert + - Gijs Kunze + - Antonio Mansilla + - Zan Baldwin (zanderbaldwin) + - BRAMILLE Sébastien (oktapodia) + - Vincent + - Jan Vernieuwe (vernija) + - maxime.perrimond + - Michael Dawart (mdawart) + - Vladimir Mantulo (mantulo) + - Wim Hendrikx + - Andrii Serdiuk (andreyserdjuk) + - PaoRuby + - Holger Lösken + - George Bateman + - riadh26 + - AntoineDly + - Damian Sromek + - Mark Ogilvie + - Jonathan Vollebregt + - Johannes Goslar + - allison guilhem + - Troy Crawford + - Arend-Jan Tetteroo + - Dan Finnie + - Philipp Kretzschmar + - Rafał Toboła + - Dominik Schwind (dominikschwind) + - Stefano A. (stefano93) + - Léo VINCENT + - mlazovla + - Alejandro Diaz Torres + - SuRiKmAn + - Jimmy Leger (redpanda) + - Damien Harper (damien.harper) + - Konstantin Chigakov + - qsz + - devel + - Rémi Faivre (rfv) + - Radek Wionczek (rwionczek) + - Alexander Pasichnik (alex_brizzz) + - Martijn Boers (plebian) + - Pchol + - Florent SEVESTRE (aniki-taicho) + - Sylvain Lorinet + - Jan Eichhorn (exeu) + - Konstantinos Alexiou + - Mikkel Paulson + - moldcraft + - Juan Ases García (ases) + - Gerben Wijnja + - Siragusa (asiragusa) + - Bradley Zeggelaar + - rtek + - Aaron Scherer (aequasi) + - Dan Blows + - Brandon Kelly (brandonkelly) + - Choong Wei Tjeng (choonge) + - Marcin Kruk + - Nicolas Bastien (nicolas_bastien) + - Artyum Petrov + - Thomason, James + - Walter Dal Mut (wdalmut) + - abluchet - youssef saoubou - - Joseph Maarek - - Alexander Menk - - Alex Pods + - Kousuke Ebihara (co3k) + - bch36 + - Taras Girnyk + - wiseguy1394 + - adam-mospan + - Harry Wiseman + - ADmad + - Łukasz Giza (destroyer) + - Vladimir Sadicov (xtech) + - 2manypeople + - Ramon Kleiss (akathos) + - Bizley + - Felicitus + - dangkhoagms (dangkhoagms) + - Jesper Noordsij + - Thiago Melo + - Gleb Sidora + - Jovan Perovic (jperovic) + - Alexandre Beaujour + - Oriol Mangas Abellan (oriolman) + - Joao Paulo V Martins (jpjoao) + - Carsten Eilers (fnc) + - Sébastien HOUZÉ + - Sebastian Landwehr (dword123) + - Adel ELHAIBA (eadel) + - Damián Nohales (eagleoneraptor) + - Sorin Gitlan (forapathy) + - Gerry Vandermaesen (gerryvdm) + - Per Sandström (per) + - Ionut Cioflan + - Yannick + - Adam Katz + - Julius Beckmann (h4cc) + - Adrien Samson (adriensamson) + - Hubert Moreau (hmoreau) + - Mantas Urnieža + - Lars Ambrosius Wallenborn (larsborn) + - Elliot Anderson (elliot) + - Bjorn Twachtmann (dotbjorn) - timaschew - - Jelle Kapitein - - Jochen Mandl - - elattariyassine - - Asrorbek Sultanov - - Marin Nicolae - - Gerrit Addiks - - Buster Neece - - Albert Prat - - Alessandro Loffredo - - Ian Phillips - - Carlos Tasada - - Remi Collet - - Haritz - - Matthieu Prat - - Brieuc Thomas - - zors1 + - Pablo Maria Martelletti (pmartelletti) + - temperatur + - Chris Tiearney + - Pierre Tondereau + - Wouter de Wild + - ElisDN + - Joe + - BilgeXA + - Roma (memphys) + - Yohan Giarelli (frequence-web) + - Gil Hadad + - Samy D (dinduks) + - Piers Warmers + - BrokenSourceCode + - llupa + - Patrick Daley (padrig) + - Phillip Look (plook) + - Oksana Kozlova (oksanakozlova) + - Emirald Mateli + - Julien JANVIER (jjanvier) + - Marcello Mönkemeyer (marcello-moenkemeyer) + - Rodolfo Ruiz + - Valery Maslov (coderberg) + - Darius Leskauskas (darles) + - Stefan Moonen + - Benedict Massolle (bemas) + - Guido Donnari + - Cedric BERTOLINI (alsciende) + - Sander van der Vlugt (stranding) + - iamvar + - Markus Baumer + - Jérôme Dumas + - Georgi Georgiev + - otsch + - Christophe Meneses (c77men) + - Jeremy David (jeremy.david) + - Maria Grazia Patteri + - muchafm + - Michael van Tricht + - Ronny (big-r) + - detinkin + - Loenix + - tourze + - Ahmed Abdulrahman + - Penny Leach + - Dan Wilga + - zorn + - Joris Garonian (grifx) + - Samuel Vogel (samuelvogel) + - Osayawe Ogbemudia Terry (terdia) + - Ferenczi Krisztian (fchris82) + - Guillaume Smolders (guillaumesmo) + - Benjamin Paap (benjaminpaap) + - Thomas Chmielowiec (chmielot) + - PatrickRedStar + - Jairo Pastor + - Fabian Kropfhamer (fabiank) + - Martin Pärtel + - Ulrik McArdle + - Hugo Sales + - G.R.Dalenoort + - Mike Francis + - Ivo Valchev + - Oxan van Leeuwen + - Michal Čihař + - Rosio (ben-rosio) + - Marie Minasyan (marie.minassyan) + - Anton Sukhachev (mrsuh) + - Antanas Arvasevicius + - Maxwell Vandervelde + - Kevin Mian Kraiker - Peter Simoncic - - lerminou - - Adam Bramley - - Ahmad El-Bardan - - mantulo - - pdragun - - Paul Le Corre - - Noel Light-Hilary - - Filipe Guerra - - Jean Ragouin - - Gerben Wijnja - - Emre YILMAZ - - Rowan Manning - - qsz - - Marcos Labad - - Per Modin - - David Windell - - Frank Jogeleit - - Ondřej Frei - - Gabriel Birke - - Derek Bonner - - martijn - - Jenne van der Meer - - annesosensio - - NothingWeAre - - Storkeus - - goabonga + - Wojciech Gorczyca + - Ahmad Al-Naib - Vladislav Iurciuc - - Alan Chen - - Anton Zagorskii - ging-dev - Maerlyn - - Robert Gurau - - Even André Fiskvik - - Agata - - dakur - - florian-michael-mast - - tourze - - Dario Guarracino - - sam-bee - - Vlad Dumitrache - - wetternest + - Neagu Cristian-Doru (cristian-neagu) + - Mathieu Morlon (glutamatt) + - DerManoMann + - Tyler Stroud + - Clemens Krack + - Adam Kiss + - scourgen hung (scourgen) + - Sander Coolen (scoolen) + - Jontsa + - Ángel Guzmán Maeso (shakaran) + - Victor Prudhomme + - Tomasz Szymczyk (karion) + - Nikos Charalampidis + - Caligone + - Peter Jaap Blaakmeer + - ibasaw + - Alexander Menk + - Philippe Degeeter (pdegeeter) + - Gerard Berengue Llobera (bere) + - Charly Goblet (_mocodo) + - Quique Porta (quiqueporta) + - Robert Korulczyk + - Bruno Baguette + - nyro (nyro) + - Peter Schultz + - Wissame MEKHILEF + - Mihai Stancu + - Koalabaerchen + - René Kerner + - Michael Olšavský + - Antanas Arvasevicius + - Eddie Abou-Jaoude (eddiejaoude) + - hjkl + - dlorek + - Jeroen De Dauw (jeroendedauw) + - Ivan Nemets + - Lukas Kaltenbach + - Remi Collet + - Benjamin RICHARD + - Zdeněk Drahoš + - Dariusz Czech + - fabios + - Maksym Romanowski (maxromanovsky) + - ReScO + - Ole Rößner (basster) + - brian978 + - Stelian Mocanita (stelian) + - Wing + - Javier Núñez Berrocoso (javiernuber) + - Eddy + - Chris Maiden (matason) + - Daniel Basten (axhm3a) + - omerida + - Rini Misini + - Maxime THIRY + - Victor + - tpetry + - Mikhail Prosalov (mprosalov) + - Mephistofeles + - Oleh Korneliuk + - everyx + - Richard Heine + - Frank Neff (fneff) + - Yann LUCAS (drixs6o9) + - Vasily Khayrulin (sirian) + - Povilas S. (povilas) + - Paweł Tomulik + - Eric J. Duran + - Anatol Belski + - Mahmoud Mostafa (mahmoud) + - Ben Oman + - Jay Severson + - Ramazan APAYDIN (rapaydin) + - Htun Htun Htet (ryanhhh91) + - Denis Yuzhanin + - wesign (inscrutable01) + - j0k (j0k) + - JG (jege) + - Farhad Hedayatifard + - Shaun Simmons + - PierreRebeilleau + - Sergii Dolgushev (serhey) + - Sebastian Schwarz + - Foxprodev + - Artfaith + - VAN DER PUTTE Guillaume (guillaume_vdp) + - Guillaume Gammelin + - Wolfgang Klinger (wolfgangklingerplan2net) + - Jeffrey Moelands (jeffreymoelands) + - Giovanni Albero (johntree) + - Nasim + - Tadcka + - Bárbara Luz + - Bastien Picharles + - Randel Palu + - Clément LEFEBVRE (nemoneph) + - Patrick Carlo-Hickman + - Timon van der Vorm + - Shude + - Vladislav Krupenkin (ideea) + - Pablo Schläpfer - Erik van Wingerden - - Valouleloup - - Pathpat - - Jaymin G - - robmro27 - - Vallel Blanco - - Alexis MARQUIS - - Ernesto Domato - - Matheus Gontijo - - Gerrit Drost - - Linnaea Von Lavia - - Andrew Brown - - Javan Eskander - - Lenar Lõhmus - - Cristian Gonzalez - - MusikAnimal - - AlberT - - hainey - - Juan M Martínez - - Gilles Gauthier - - Benjamin Franzke - - Pavinthan - - Sylvain METAYER - - ddebree - - Gyula Szucs - - Dmitriy - - Tomas Liubinas + - adnen chouibi + - Vladimir Pakhomchik + - Mickael Perraud + - Alex Silcock + - Frédéric Bouchery (fbouchery) + - Raphael Hardt + - Kurt Thiemann + - Linnaea Von Lavia + - Qingshan Luo + - Arrakis (arrakis) + - Andrey Helldar + - Danil Khaliullin (bifidokk) + - Saif Eddin G + - Michał Marcin Brzuchalski (brzuchal) + - Thomas Dubuffet (thomasdubuffet) + - Dominik Ritter (dritter) + - Paul Andrieux + - Ralf Kühnel (ralfkuehnel) + - Adam Prickett + - Luke Towers + - Alexandre Melard + - Brandon Antonio Lorenzo + - Nicolas + - Alex Demchenko + - Fabien + - Sergio Santoro + - Michael Simonson (mikes) + - Samuel Gordalina (gordalina) + - Bogdan + - Keith Maika + - Bram Van der Sype (brammm) + - Norbert Schultheisz + - Ross Motley (rossmotley) + - Jérôme Nadaud (jnadaud) + - Robert Meijers + - Thomas Beaujean + - František Maša + - Asil Barkin Elik (asilelik) + - alsar + - Nacho Martin (nacmartin) + - Miłosz Guglas (miloszowi) + - Rubén Calvo (rubencm) + - Bhujagendra Ishaya + - dinitrol + - Jens Hatlak + - Giorgio Premi + - Jos Elstgeest + - Artyom Protaskin + - Daniel Kozák + - Urban Suppiger + - Mikko Ala-Fossi + - Dawid Sajdak + - RENAUDIN Xavier (xorrox) + - alireza + - PLAZANET Pierre (pedrotroller) + - Daan van Renterghem + - Raito Akehanareru (raito) + - Valmont Pehaut-Pietri (valmonzo) + - misterx - Ivo Valchev - - Jan Hort - - Klaas Naaijkens - - Bojan - - Rafał - - Adria Lopez (adlpz) - - Adrien Peyre (adpeyre) - - Aaron Scherer (aequasi) - - Alexandre Jardin (alexandre.jardin) - - Bart Brouwer (bartbrouwer) - - baron (bastien) - - Bastien Clément (bastienclement) - - Rosio (ben-rosio) - - Simon Paarlberg (blamh) + - Michael Steininger - Masao Maeda (brtriver) - - Valery Maslov (coderberg) - - Damien Harper (damien.harper) - - Darius Leskauskas (darles) - - david perez (davidpv) - - David Joos (djoos) - - Denis Klementjev (dklementjev) - - Dominik Pesch (dombn) - - Dominik Hajduk (dominikalp) - - Tomáš Polívka (draczris) - - Dennis Smink (dsmink) - - Duncan de Boer (farmer-duck) - - Franz Liedke (franzliedke) - - Gaylord Poillon (gaylord_p) - - gondo (gondo) - - Joris Garonian (grifx) - - Grummfy (grummfy) - - Hadrien Cren (hcren) - - Gusakov Nikita (hell0w0rd) - - Halil Hakan Karabay (hhkrby) - - Oz (import) - - Jaap van Otterdijk (jaapio) - - Javier Núñez Berrocoso (javiernuber) - - Jelle Bekker (jbekker) - - Giovanni Albero (johntree) - - Jorge Martin (jorgemartind) - - Joeri Verdeyen (jverdeyen) - - Kevin Verschaeve (keversc) - - Kevin Herrera (kherge) - - Kubicki Kamil (kubik) - - Luis Ramón López López (lrlopez) - - Vladislav Nikolayev (luxemate) - - Martin Mandl (m2mtech) - - Mehdi Mabrouk (mehdidev) - - Bart Reunes (metalarend) - - Muriel (metalmumu) - - Michael Pohlers (mick_the_big) - - Misha Klomp (mishaklomp) - - mlpo (mlpo) - - Marcel Pociot (mpociot) - - Mikhail Prosalov (mprosalov) - - Ulrik Nielsen (mrbase) - - Marek Šimeček (mssimi) - - Dmitriy Tkachenko (neka) - - Cayetano Soriano Gallego (neoshadybeat) - - Artem (nexim) - - Nicolas ASSING (nicolasassing) - - Olivier Laviale (olvlvl) - - Pierre Gasté (pierre_g) - - Pablo Monterde Perez (plebs) - - Pierre-Olivier Vares (povares) - - Jimmy Leger (redpanda) - - Ronny López (ronnylt) - - Julius (sakalys) - - Sébastien JEAN (sebastien76) - - Dmitry (staratel) - - Marcin Szepczynski (szepczynski) - - Tito Miguel Costa (titomiguelcosta) - - Simone Di Maulo (toretto460) - - Cyrille Jouineau (tuxosaurus) - - Lajos Veres (vlajos) - - Vladimir Chernyshev (volch) - - Wim Godden (wimg) - - Yorkie Chadwick (yorkie76) - - Zakaria AMMOURA (zakariaamm) - - Maxime Aknin (3m1x4m) - - Pavel Barton - - Exploit.cz - - GuillaumeVerdon - - Marien Fressinaud + - Maxime AILLOUD (mailloud) + - Eric Krona + - Alex Teterin (errogaht) + - Sam Williams + - tirnanog06 + - Evgeny Z (meze) + - George Dietrich + - Benjamin Laugueux + - Stephen + - Stefan Kruppa + - Petr Jaroš (petajaros) + - Dylan + - ghazy ben ahmed + - Anton Dyshkant + - Michael Nelson + - gr8b + - Paul LE CORRE + - Yiorgos Kalligeros + - max - ureimers - akimsko - Youpie - - Jason Stephens - - srsbiz - - Taylan Kasap - - Michael Orlitzky - - Nicolas A. Bérard-Nault - - Quentin Favrie - - Matthias Derer - - Francois Martin - - vladyslavstartsev - - Saem Ghani - - Kévin - - Stefan Oderbolz - - valmonzo - - Tamás Szigeti - - Gabriel Moreira - - Alexey Popkov - - ChS - - toxxxa - - michal - - Jannik Zschiesche - - Alexis MARQUIS + - Moritz Kraft (userfriendly) + - Daniel Tiringer + - Javier Ledezma + - Steven Dubois + - Michel Bardelmeijer + - guangwu + - Ben Johnson + - Joas Schilling + - Bruno Rodrigues de Araujo (brunosinister) + - Martins Eglitis + - Grégoire Rabasse + - Cas van Dongen + - David Christmann + - stloyd + - Joel Lusavuvu (enigma97) + - Morimoto Ryosuke + - Mbechezi Nawo + - Moza Bogdan (bogdan_moza) + - Artem Lopata + - dantleech + - Andreas Allacher + - VolCh + - Clement Herreman (clemherreman) + - Aleksei Lebedev + - Roy-Orbison + - George Sparrow + - Chris Tickner + - Chris + - Farid Jalilov + - Christiaan Wiesenekker + - Evgeny (disparity) + - Jeremy Benoist + - Marko Vušak + - Igor Timoshenko (igor.timoshenko) + - Hryhorii Hrebiniuk + - Pierre-Emmanuel CAPEL + - Konstantin S. M. Möllers (ksmmoellers) + - Jordan de Laune (jdelaune) + - Wim Molenberghs (wimm) + - Zachary Tong (polyfractal) + - Boris Medvedev + - Radosław Kowalewski + - Hadrien Cren (hcren) + - Ha Phan (haphan) + - Daniel González Zaballos (dem3trio) + - Florian Morello + - Denis Klementjev (dklementjev) + - Ahmed Abdou + - Kirk Madera + - Andrey Chernykh + - Markus Reinhold + - AmsTaFF (amstaff) + - Pawel Smolinski + - EXT - THERAGE Kevin + - Ashura + - Martin Mayer (martin) + - Renan Taranto (renan-taranto) + - Victor Macko (victor_m) + - Wojciech Skorodecki + - Evert Jan Hakvoort + - Filippos Karailanidis + - Philipp Hoffmann (philipphoffmann) + - zcodes + - László GÖRÖG + - Nicolas Appriou + - alexpods + - Piergiuseppe Longo + - Nicolas Lemoine + - Christian Jul Jensen + - Michal Kurzeja (mkurzeja) + - Sergei Gorjunov + - victor-prdh + - Romain Pierre + - Dmitry Korotovsky + - Guile (guile) + - Wang Jingyu + - Mark Beech (jaybizzle) + - Vladislav Nikolayev (luxemate) + - Cristobal Dabed + - Patrick Kaufmann + - Gusakov Nikita (hell0w0rd) + - Andy Raines + - Aleksey Prilipko + - Dan Brown + - Marc Jauvin + - Halil Hakan Karabay (hhkrby) + - Jaap van Otterdijk (jaapio) + - Walid BOUGHDIRI (walidboughdiri) + - Frederik Schmitt - Joseph Deray - - Damian Sromek - - Ben - - Evgeniy Tetenchuk - - Sjoerd Adema - - Shrey Puranik - - Kai Eichinger - - Evgeniy Koval - - Lars Moelleken - - dasmfm - - Claas Augner - - Mathias Geat - - neodevcode - - Angel Fernando Quiroz Campos (angelfqc) - - Arnaud Buathier (arnapou) - - Curtis (ccorliss) - - chesteroni (chesteroni) - - Mauricio Lopez (diaspar) - - HADJEDJ Vincent (hadjedjvincent) - - Daniele Cesarini (ijanki) - - Ismail Asci (ismailasci) - - Jeffrey Moelands (jeffreymoelands) - - Jakub Caban (lustmored) + - mohammadreza honarkhah - Ondřej Mirtes (mirtes) - - Paulius Jarmalavičius (pjarmalavicius) - - Ramon Ornelas (ramonornela) - - Ricardo de Vries (ricardodevries) - - Ruslan Zavacky (ruslanzavacky) - - Stefano Cappellini (stefano_cappellini) - - Thomas Dutrion (theocrite) - - Till Klampaeckel (till) - - Tobias Weinert (tweini) - - Wotre - - goohib - - Tom Counsell - - Sepehr Lajevardi - - George Bateman + - Nardberjean + - Nick Stemerdink + - linh + - Muriel (metalmumu) - Xavier HAUSHERR - - Edwin Hageman - - Mantas Urnieža - - temperatur - - ToshY - - Paul Andrieux - - Sezil - - misterx - - Cas - - arend - - Vincent Godé + - Nicolas Schwartz (nicoschwartz) + - Simon Mönch + - Ludek Stepan + - Sergio + - Benjamin BOUDIER + - Bernd Matzner (bmatzner) + - Jelle Kapitein + - František Bereň + - Dmitriy Derepko + - Eduard Bulava (nonanerz) + - dantleech + - Marco Jantke + - Maks Rafalko (bornfree) + - Baptiste Leduc (bleduc) + - Tim Jabs (rubinum) + - LubenZA + - enomotodev + - CDR + - Joan Cruz + - Dale.Nash + - Jozef Môstka (mostkaj) + - botbotbot + - none (nelexa) + - Thomas Decaux + - florian-michael-mast + - Nicolas Tallefourtané (nicolab) + - Ph3nol + - simbera + - Ramon Ornelas (ramonornela) - helmi - - Michael Steininger - - Nardberjean - - Dylan - - ghazy ben ahmed - - Karolis + - Alessio Baglio (ioalessio) + - djama + - SOEDJEDE Felix (fsoedjede) + - avi123 + - Daniel Perez Pinazo (pitiflautico) + - Alexey Berezuev + - AlbinoDrought + - Vladimir Khramtsov (chrome) + - Wojciech Błoszyk (wbloszyk) + - Jure (zamzung) + - Dan Harper + - Juga Paazmaya + - Alexandre Segura + - Yura Uvarov (zim32) + - Charly Terrier (charlypoppins) + - sdkawata + - Lorenzo Adinolfi (loru88) + - Atthaphon Urairat + - d-ph + - David Wolter (davewww) + - Carlos Ortega Huetos + - Nicolas Martin (cocorambo) + - Tomaz Ahlin + - creiner + - Sebastian Drewer-Gutland (sdg) + - Bert Hekman + - Marc Lemay (flug) + - Peter van Dommelen + - Richard Trebichavský + - MARYNICH Mikhail (mmarynich-ext) + - Paul Mitchum (paul-m) + - Gabriel Solomon (gabrielsolomon) + - Marcin Nowak + - Noel Light-Hilary + - Ian Phillips + - Jelle Bekker (jbekker) + - Sébastien Lévêque (legenyes) + - Michał Strzelecki + - Christian Grasso (chris54721) + - Marcin Szepczynski (szepczynski) + - Gina Peter Banyard + - Miloš Milutinović - Myke79 - - jersoe - - Brian Debuire - - Eric Grimois - - Christian Schiffler - - Piers Warmers - - Sylvain Lorinet - - Pavol Tuka - - klyk50 - - jc - - BenjaminBeck - - Aurelijus Rožėnas - - Beno!t POLASZEK - - Armando - - Jordan Hoff - - znerol - - Christian Eikermann - - Sergei Shitikov - - Steffen Keuper - - Kai Eichinger - - Antonio Angelino - - Jens Schulze - - Tema Yud - - Matt Fields - - Olatunbosun Egberinde - - Johannes - - Andras Debreczeni - - Knallcharge - - Vladimir Sazhin - - Michel Bardelmeijer - - Tomas Kmieliauskas - - Ikko Ashimine - - Erwin Dirks - - Markus Ramšak - - Billie Thompson - - Philipp - - lol768 - - jamogon - - Vyacheslav Slinko - - Benjamin Laugueux - - guangwu - - Lane Shukhov - - Jakub Chábek - - William Pinaud (DocFX) - - Johannes - - Jörg Rühl - - George Dietrich - - jannick-holm + - Kris Kelly + - Kévin + - Alexis MARQUIS + - inwebo veritas (inwebo) - wesleyh - - Menno Holtkamp - - Ser5 + - Mark van den Berg + - Dennis Jaschinski (d.jaschinski) - Michael Hudson-Doyle - - Matthew Burns - - Daniel Bannert - - Karim Miladi - - Michael Genereux - - Greg Korba - - Camille Islasse - - patrick-mcdougle - - Tyler Stroud - - Dariusz Czech - - Clemens Krack - - Bruno Baguette - - Jack Wright - - MrNicodemuz - - Anonymous User - - demeritcowboy - - Paweł Tomulik - - Eric J. Duran - - Blackfelix - - Pavel Witassek - - Alexandru Bucur - - Alexis Lefebvre - - cmfcmf - - sarah-eit - - Michal Forbak - - CarolienBEER - - Drew Butler - - Alexey Berezuev - - pawel-lewtak - - Pierrick Charron - - Steve Müller - - omerida - - Andras Ratz - - andreabreu98 - - Marcus - - gechetspr - - brian978 + - Guillaume Aveline + - Nathanaël Martel (nathanaelmartel) + - Felix Marezki + - Evgeny Efimov (edefimov) + - Oleksii Svitiashchuk + - Adiel Cristo (arcristo) + - Matěj Humpál + - Nico Hiort af Ornäs + - Nguyen Tuan Minh (tuanminhgp) - Michael Schneider - n-aleha - - Richard Čepas - - Talha Zekeriya Durmuş - - Anatol Belski + - Alexander Cheprasov + - Alexandre Segura + - Jason Stephens + - Martin Schophaus (m_schophaus_adcada) + - Tijs Verkoyen + - Ivo + - Karl Shea + - Adam Wójs (awojs) + - eminjk + - Vivien + - Tournoud (damientournoud) + - Marcos Labad + - Per Modin - Javier - - Alexis BOYER - - bch36 - - Kaipi Yann - - wiseguy1394 - - adam-mospan - - AUDUL - - Steve Hyde - - AbdelatifAitBara - - nerdgod - - Sam Williams - - Ettore Del Negro - - Guillaume Aveline - - Adrian Philipp - - James Michael DuPont + - patrickmaynard + - Houssem + - Şəhriyar İmanov (shehriyari) + - Pascal Hofmann + - smokeybear87 + - Wahyu Kristianto (kristories) + - Benoit Leveque + - Benjamin Bender + - sauliusnord + - Erwan Nader (ernadoo) + - Anton Babenko (antonbabenko) + - Even André Fiskvik + - Maarten Nusteling (nusje2000) + - Gordienko Vladislav + - Sobhan Sharifi (50bhan) + - Vaidas Lažauskas + - Felipy Amorim (felipyamorim) + - ssilatel - Simone Ruggieri - - Markus Tacker - - Tomáš Votruba - - Kasperki + - wusuopu + - Peter Smeets (darkspartan) + - caalholm + - Kevin EMO + - karstennilsen + - Pavinthan + - Alain Flaus (halundra) + - Mihail Krasilnikov (krasilnikovm) + - Bart Wach + - Andrejs Leonovs + - Martijn Evers + - Pedro Magalhães (pmmaga) + - Nikola Svitlica (thecelavi) + - Alfonso Fernández García + - phc + - craigmarvelley + - Franz Wilding (killerpoke) + - Amin Hosseini (aminh) + - gr1ev0us + - Mateusz Lerczak + - Nicolas Pion + - Ariful Alam + - Florent Olivaud + - Mateusz Żyła (plotkabytes) + - Ismail Özgün Turan (dadeather) + - Foxprodev + - Jan Pintr + - Matthew (mattvick) + - gedrox - dima-gr - - Daniel Strøm - - Tammy D - - Rodolfo Ruiz - - tsilefy - - Enrico - - Adrien Foulon - - Sylvain Just - - Ryan Rud - - Ondrej Slinták - - Jérémie Broutier - - vlechemin - - Brian Corrigan - - Ladislav Tánczos - - Brian Freytag + - Kai Eichinger + - CarolienBEER + - Vincent Chalnot + - Denis Kop + - inspiran + - Alessandro Tagliapietra (alex88) + - Fabian Steiner (fabstei) + - gndk + - Uladzimir Tsykun + - Agata + - Adrien Gallou (agallou) + - Dario Guarracino + - Nerijus Arlauskas (nercury) + - Clément + - Jonas Claes + - AnrDaemon + - sam-bee + - Eric Hertwig + - Niels Robin-Aubertin + - Jorge Vahldick (jvahldick) + - Ryan Rogers + - Danijel Obradović + - Martin Auswöger + - Christian Morgan + - Anne-Sophie Bachelard + - Julien Sanchez (sumbobyboys) + - Simon Sargeant + - Edwin + - Víctor Mateo (victormateo) + - Vincent MOULENE (vints24) + - ChS + - robin.de.croock + - Michael Tibben + - Ahmad Mayahi (ahmadmayahi) + - johnstevenson + - Mohamed Karnichi (amiral) + - Julien Boudry + - Michael Hüneburg + - Jeroen de Boer + - Matthew J Mucklo + - Jannik Zschiesche + - Дмитрий Пацура + - Matthias Larisch + - Lance Chen + - Nicolas Attard (nicolasattard) + - Robert-Jan de Dreu + - ddebree + - Phobetor + - Eric Schildkamp + - Francois Martin + - HADJEDJ Vincent (hadjedjvincent) + - Karolis + - Jiri Korenek + - d.huethorst + - Lin Lu + - dsech + - Daniel Mecke (daniel_mecke) + - Ilya Chekalsky + - Pierre Dudoret + - Thomas + - Philipp Strube + - Michal Trojanowski + - Frank Schulze (xit) + - Artiom - Skorney - - Lucas Matte - - Success Go - - fmarchalemisys - - MGatner - - mieszko4 - - Steve Preston - - ibasaw - - Wojciech Skorodecki - - Kevin Frantz - - Neophy7e - - Evert Jan Hakvoort - - bokonet - - Arrilot - - andrey-tech - - David Ronchaud - - Chris McGehee - - Bastien THOMAS - - Shaun Simmons - - Pierre-Louis LAUNAY - - Arseny Razin - - A. Pauly - - djama - - Benjamin Rosenberger - - Vladyslav Startsev - - Michael Gwynne - - Eduardo Conceição - - changmin.keum - - Jon Cave - - Sébastien HOUZE - - Abdulkadir N. A. - - Markus Klein - - Adam Klvač - - Bruno Nogueira Nascimento Wowk - - Tomanhez - - satalaondrej - - Matthias Dötsch - - jonmldr - - Yevgen Kovalienia - - Lebnik - - Shude - - RTUnreal - - Richard Hodgson - - Sven Fabricius - - Antonio Mansilla - - Ondřej Führer - - Bogdan - - Sema - - Ayke Halder - - Thorsten Hallwas - - Brian Freytag - - Arend Hummeling - - Marco Pfeiffer - - Alex Nostadt - - Michael Squires - - Egor Gorbachev - - Julian Krzefski - - Derek Stephen McLean - - Norman Soetbeer - - zorn - - Yuriy Potemkin - - Emilie Lorenzo - - prudhomme victor - - enomotodev - - Vincent - - Benjamin Long - - Fabio Panaccione - - Kévin Gonella - - Ben Miller - - Peter Gribanov - - Matteo Galli - - Bart Ruysseveldt - - Ash014 - - Loenix - - kwiateusz - - Ilya Bulakh - - David Soria Parra - - Simon Frost - - Sergiy Sokolenko - - Cantepie - - detinkin - - Ahmed Abdulrahman - - dinitrol - - Penny Leach - - Kevin Mian Kraiker - - Yurii K - - Richard Trebichavský + - Cedric Kastner (nurtext) + - Antoine Bellion (abellion) + - Arnau González + - Benjamin Schultz (bschultz) + - Gerd Christian Kunze (derdu) + - 蝦米 + - klemens + - César Suárez (csuarez) + - Bert ter Heide (bertterheide) + - efeen + - Lane Shukhov + - Krzysztof Przybyszewski (kprzybyszewski) + - Matt Fields + - Lajos Veres (vlajos) + - toxxxa + - Stefan Graupner (efrane) + - Nsbx + - Amine Matmati + - patrick-mcdougle + - Pedro Silva + - Cyrille Bourgois (cyrilleb) + - Damien Vauchel (damien_vauchel) + - Eric Grimois + - Christian Schiffler + - Jan Christoph Beyer + - Muhammed Akbulut + - Nathanael d. Noblet + - root + - Ulrik Nielsen (mrbase) + - Ivan Tse + - Nicolas Macherey + - Ari Pringle (apringle) + - chillbram + - Will Rowe + - Andrii Boiko + - Dilek Erkut + - Harold Iedema + - Janusz Mocek + - Mostafa + - ergiegonzaga + - Mas Iting + - Nicolas Jourdan (nicolasjc) + - Serhii Polishchuk (spolischook) + - Orestis + - Flohw + - Evgeniy Tetenchuk + - Claude Dioudonnat + - MatTheCat + - Tim Porter + - Jérémy CROMBEZ (jeremy) + - Tomas Javaisis + - Thomas Ferney (thomasf) + - Ken Stanley + - vladyslavstartsev + - Tim Lieberman + - Paulius Jarmalavičius (pjarmalavicius) + - Jorge Martin (jorgemartind) + - Kubicki Kamil (kubik) + - Max Beutel + - benatespina (benatespina) + - Yohann Tilotti + - Oscar Esteve (oesteve) + - Romain + - Dave Long + - bill moll + - Marco Pfeiffer + - Milos Colakovic (project2481) + - Raphael de Almeida (raphaeldealmeida) + - Laurent Negre (raulnet) + - Adriaan Zonnenberg + - Brian Corrigan + - Mohammad Ali Sarbanha (sarbanha) + - GagnarTest (gagnartest) + - Zayan Goripov + - Martin Eckhardt + - André Matthies + - ttomor + - Gavin (gavin-markup) + - Evgeny Ruban + - Florian Bogey + - Soha Jin + - Alexander Zogheb - Rich Sage - - g123456789l - - Mark Ogilvie - - Jonathan Vollebregt - - oscartv - - DanSync - - Peter Zwosta - - Michal Čihař - - parhs - - Harry Wiseman - - Emilien Escalle - - jwaguet - - Diego Campoy - - Oncle Tom - - Sam Anthony - - Christian Stocker - - Oussama Elgoumri - - Gert de Pagter - - David Lima - - Steve Marvell - - Dawid Nowak - - Lesnykh Ilia - - Shyim - - sabruss - - darnel - - Nicolas - - Sergio Santoro - - tirnanog06 - - Andrejs Leonovs - - llupa - - Alfonso Fernández García - - phc - - Дмитрий Пацура - - Signor Pedro - - RFreij - - Matthias Larisch - - Maxime P - - Sean Templeton - - Willem Mouwen - - db306 - - Dr. Gianluigi "Zane" Zanettini - - Michaël VEROUX - - Julia - - Lin Lu - - arduanov - - Valmonzo - sualko - - Marc Bennewitz - - Fabien - - Martin Komischke - - Yendric - - ADmad - - Nicolas Roudaire - - Marc Jauvin - - Matthias Meyer - - Abdouni Karim (abdounikarim) - - Temuri Takalandze (abgeo) - - Bernard van der Esch (adeptofvoltron) - - Andreas Forsblom (aforsblo) - - Aleksejs Kovalovs (aleksejs1) - - Alex Olmos (alexolmos) - - Cedric BERTOLINI (alsciende) - - Robin Kanters (anddarerobin) - - Antoine (antoinela_adveris) - - Juan Ases García (ases) - - Siragusa (asiragusa) - - Daniel Basten (axhm3a) - - Albert Bakker (babbert) - - Benedict Massolle (bemas) - - Gerard Berengue Llobera (bere) - - Ronny (big-r) - - Bernd Matzner (bmatzner) - - Vladimir Vasilev (bobahvas) - - Anton (bonio) - - Bram Tweedegolf (bram_tweedegolf) - - Brandon Kelly (brandonkelly) - - Choong Wei Tjeng (choonge) - - Bermon Clément (chou666) - - Citia (citia) - - Kousuke Ebihara (co3k) - - Loïc Vernet (coil) - - Christoph Vincent Schaefer (cvschaefer) - - Kamil Piwowarski (cyklista) - - Damon Jones (damon__jones) - - David Courtey (david-crty) - - David Gorges (davidgorges) - - Alexandre Fiocre (demos77) - - Łukasz Giza (destroyer) - - Daniel Londero (dlondero) - - Dušan Kasan (dudo1904) - - Sebastian Landwehr (dword123) - - Adel ELHAIBA (eadel) - - Damián Nohales (eagleoneraptor) - - Elliot Anderson (elliot) - - Erwan Nader (ernadoo) - - Fabien D. (fabd) - - Carsten Eilers (fnc) - - Sorin Gitlan (forapathy) - - Fraller Balázs (fracsi) - - Lesueurs Frédéric (fredlesueurs) - - Yohan Giarelli (frequence-web) - - Gerry Vandermaesen (gerryvdm) - - Arash Tabrizian (ghost098) - - Greg Szczotka (greg606) - - Ian Littman (iansltx) - - Nathan DIdier (icz) - - Vladislav Krupenkin (ideea) - - Peter Orosz (ill_logical) - - Ilia Lazarev (ilzrv) - - Imangazaliev Muhammad (imangazaliev) - - wesign (inscrutable01) - - Arkadiusz Kondas (itcraftsmanpl) - - j0k (j0k) - - joris de wit (jdewit) - - JG (jege) - - Jérémy CROMBEZ (jeremy) - - Jose Manuel Gonzalez (jgonzalez) - - Joachim Krempel (jkrempel) - - Jorge Maiden (jorgemaiden) - - Joshua Behrens (joshuabehrens) - - Joao Paulo V Martins (jpjoao) - - Justin Rainbow (jrainbow) - - Juan Luis (juanlugb) - - JuntaTom (juntatom) - - Julien Manganne (juuuuuu) - - Ismail Faizi (kanafghan) - - Karolis Daužickas (kdauzickas) - - Kérian MONTES-MORIN (kerianmm) + - koyolgecen + - Rares Sebastian Moldovan (raresmldvn) + - Dan Ordille (dordille) + - Juan M Martínez + - Tammy D + - Kevin Frantz + - bokonet - Sébastien Armand (khepin) - - Pierre-Chanel Gauthier (kmecnin) - - Krzysztof Menżyk (krymen) - - Kenjy Thiébault (kthiebault) - - samuel laulhau (lalop) - - Laurent Bachelier (laurentb) - - Luís Cobucci (lcobucci) - - Jérémy (libertjeremy) - - Mehdi Achour (machour) - - Mamikon Arakelyan (mamikon) - - Mark Schmale (masch) - - Matt Ketmo (mattketmo) - - Moritz Borgmann (mborgmann) - - Matt Drollette (mdrollette) - - Adam Monsen (meonkeys) - - Mike Milano (mmilano) - - Guillaume Lajarige (molkobain) - - Diego Aguiar (mollokhan) - - Steffen Persch (n3o77) - - Ala Eddine Khefifi (nayzo) - - emilienbouard (neime) - - Nicholas Byfleet (nickbyfleet) - - Nicolas Bondoux (nsbx) - - Cedric Kastner (nurtext) - - ollie harridge (ollietb) - - Aurimas Rimkus (patrikas) - - Pawel Szczepanek (pauluz) - - Philippe Degeeter (pdegeeter) - - PLAZANET Pierre (pedrotroller) - - Christian López Espínola (penyaskito) - - Petr Jaroš (petajaros) - - Pavel Golovin (pgolovin) - - Philipp Hoffmann (philipphoffmann) - Alex Carol (picard89) - - Daniel Perez Pinazo (pitiflautico) - Igor Tarasov (polosatus) + - Matt Wells + - RTUnreal + - Helmer Aaviksoo + - Richard Hodgson + - Jeroen van den Nieuwenhuisen + - Dmitrii Fedorenko (dmifedorenko) + - Luca Genuzio (genuzio) + - Raphaëll Roussel + - Andreas Hasenack + - Oleg Krasavin (okwinza) + - Ismail Turan + - Yurii K + - Markkus Millend + - Gilles Doge (gido) + - Illia Antypenko (aivus) + - Kajetan Kołtuniak (kajtii) + - Serhii Smirnov + - Robert Queck + - gitlost + - Silvio Ginter + - ryunosuke + - Gilbertsoft + - Lyubomir Grozdanov (lubo13) - Maksym Pustynnikov (pustynnikov) - - Ralf Kühnel (ralfkuehnel) - - Seyedramin Banihashemi (ramin) - - Ramazan APAYDIN (rapaydin) - - Babichev Maxim (rez1dent3) - - scourgen hung (scourgen) - - Sebastian Busch (sebu) - - Sergey Stavichenko (sergey_stavichenko) - - André Filipe Gonçalves Neves (seven) - - Bruno Ziegler (sfcoder) - - Ángel Guzmán Maeso (shakaran) - - Andrea Giuliano (shark) - - Şəhriyar İmanov (shehriyari) - - Thomas Baumgartner (shoplifter) - - Schuyler Jager (sjager) - - Christopher Georg (sky-chris) - - Volker (skydiablo) - - Julien Sanchez (sumbobyboys) - - Ron Gähler (t-ronx) - - Guillermo Gisinger (t3chn0r) - - Tomáš Korec (tomkorec) - - Tom Newby (tomnewbyau) - - Andrew Clark (tqt_andrew_clark) - - Aaron Piotrowski (trowski) - - David Lumaye (tux1124) - - Roman Tymoshyk (tymoshyk) - - Moritz Kraft (userfriendly) - - Víctor Mateo (victormateo) - - Vincent MOULENE (vints24) - - Verlhac Gaëtan (viviengaetan) + - Markus Thielen + - Florian Heller + - Ronny López (ronnylt) + - Greg Korba + - Grayson Koonce + - Vladimir Melnik + - Sergii Dolgushev (sergii-swds) + - Thomas Citharel (tcit) + - Alex Niedre + - evgkord + - Valentin VALCIU + - Sortex + - julien.galenski + - Flo Gleixner (redflo) + - Jānis Lukss + - Haritz Iturbe (hizai) + - alefranz + - David Barratt + - Alan Bondarchuk + - Andrea Giannantonio + - Pavel.Batanov + - Michael Zangerle + - rkerner + - andersmateusz + - Laurent Moreau + - Marc J. Schmidt (marcjs) + - Prasetyo Wicaksono (jowy) + - Rainrider + - Chihiro Adachi (chihiro-adachi) + - Clément R. (clemrwan) + - j.schmitt + - Maximilian Berghoff (electricmaxxx) + - shreypuranik + - Edvinas Klovas + - Ondřej Führer + - kernig + - shdev + - Drew Butler + - Denys Voronin (hurricane) + - sensio + - Julien Menth (cfjulien) + - Nicolas Sauveur (baishu) + - pritasil + - Stephen Clouse + - e-ivanov + - Sven Scholz + - Peter Gribanov + - Yewhen Khoptynskyi (khoptynskyi) + - Johannes Müller (johmue) + - Juan Gonzalez Montes (juanwilde) + - Nicolas ASSING (nicolasassing) + - AUDUL + - Steve Hyde + - AbdelatifAitBara + - Antonio Angelino + - Florian Caron (shalalalala) + - Robert Kopera + - Jérémy Jourdin (jjk801) + - m.chwedziak + - Marion Hurteau (marionleherisson) + - roog + - abulford + - Daniel Rotter (danrot) + - jprivet-dev + - gechetspr + - Sergey Yuferev - David Grüner (vworldat) + - Monet Emilien + - Adrien Peyre (adpeyre) + - Timothy Anido (xanido) + - gauss + - twifty + - Tiago Garcia (tiagojsag) + - Pavel Prischepa + - Eviljeks + - Markus Staab + - Peter Potrowl + - Jonathan Hedstrom + - Billie Thompson + - Andreas Kleemann (andesk) + - Marin Nicolae + - ged15 + - Philip Dahlstrøm + - Pierre Schmitz + - Kevin Vergauwen (innocenzo) - Eugene Babushkin (warl) - Wouter Sioen (wouter_sioen) - - Xavier Amado (xamado) - - Jesper Søndergaard Pedersen (zerrvox) - - Florent Cailhol - - szymek + - Tadas Gliaubicas (tadcka) + - lerminou + - Vadim Tyukov (vatson) + - Daniel Kay (danielkay-cp) + - LHommet Nicolas (nicolaslh) + - Jenne van der Meer - Ryan Linnit - - Konrad - - Kovacs Nicolas - - eminjk - - craigmarvelley - - Stano Turza - - Antoine Leblanc - - drublic - - Andre Johnson - - MaPePeR - - Andreas Streichardt - - Alexandre Segura - - Marco Pfeiffer - - Vivien - - Pascal Hofmann - - david-binda - - smokeybear87 - - Gustavo Adrian - - damaya - - Kevin Weber - - Alexandru Năstase - - Carl Julian Sauter - - Dionysis Arvanitis - - Sergey Fedotov - - Konstantin Scheumann - - Michael - - fh-github@fholzhauer.de - - rogamoore - - AbdElKader Bouadjadja - - ddegentesh - - DSeemiller - - Jan Emrich - - Anne-Julia Seitz - - mindaugasvcs - - Mark Topper + - Goran Juric + - Alexey Buyanow (alexbuyanow) + - Cayetano Soriano Gallego (neoshadybeat) + - Luís Cobucci (lcobucci) + - Edwin Hageman + - dasmfm + - Nilmar Sanchez Muguercia + - Damien Fayet (rainst0rm) + - Dalibor Karlović + - Antonio Peric-Mazar (antonioperic) + - Nicolas Valverde + - Sagrario Meneses + - dbrekelmans + - Ramon Cuñat + - mboultoureau + - Ivan Yivoff + - Icode4Food (icode4food) + - Aurélien MARTIN + - Christoph Vincent Schaefer (cvschaefer) + - Luis Ramón López López (lrlopez) + - Sjors Ottjes + - David Ronchaud + - Tomáš Votruba + - Philipp Fritsche + - Matt Daum (daum) + - Léon Gersen + - Sandro Hopf (senaria) + - Benjamin Long + - Hallison Boaventura (hallisonboaventura) + - Fabio Panaccione + - André Filipe Gonçalves Neves (seven) + - Schuyler Jager (sjager) + - Dario Savella + - maxperei + - Zoran Makrevski (zmakrevski) + - Kirill Nesmeyanov (serafim) + - Vlad Dumitrache + - Xavier Amado (xamado) + - Bálint Szekeres + - Yoann MOROCUTTI + - NIRAV MUKUNDBHAI PATEL (niravpatel919) + - Adrien + - Mimi + - Arend Hummeling (arend) + - Leevi Graham + - Axel Barlet + - ahmetkun + - Victor DITTIERE (fuzip) + - Maksym Hubar (nrgone) + - Masaharu Suizu + - Luděk Uiberlay (ne0) + - Dominic Luechinger + - jsarracco + - Joppe de Cuyper + - yositani2002 + - David D. (comxd) + - Tristan Pouliquen (tristanpouliquen) + - Tim Herlaud + - Markus Tacker + - Marek Nocoń + - Wagner Nicolas (n1c01a5) + - Kevin T'Syen (noscope) + - Paweł Tekliński + - Marcus Stöhr + - Fabien Schurter + - Alexander Vorobiev (avorobiev) + - Vladyslav Riabchenko + - Aldo Zarza (azarzag) + - Jean-François Lépine (halleck45) + - Maarten de Keizer (maartendekeizer) + - Alexandre Gérault (alexandre-gerault) + - Tymoteusz Motylewski + - fdarre + - Григорий + - Zéfyx + - CaDJoU + - Julien Gidel + - Ivan Gantsev + - mervinmcdougall + - Jordan Aubert (jordanaubert) + - Danny Witting + - morrsky + - Nathan Vonnahme + - Nelson da Costa + - Jens Hassler + - Hylke + - Simon Schubert (simon-schubert) + - j00seph + - Ivan Nemets + - Kevin + - Filip Telążka + - Vladimir Jimenez + - Artur 'Wodor' Wielogorski + - Shamil Nunhuck (shamil) + - Shevelev Vladimir (shevelev_vladimir) + - Marc Straube + - Bart Heyrman + - Norman Soetbeer (battlerattle) + - Fabien Lasserre (fbnlsr) + - Hendrik Pilz (hendrikpilz) + - Krzysztof Ilnicki (poh) + - Michele Carino + - Charcosset Johnny + - Francesco Abeni + - Matthias Noback (mnoback) + - Talita Kocjan Zager (paxyknox) + - John Doe + - sgautier + - Michael Cullum (unknownbliss) + - belghiti idriss (belghiti) + - Sebastian G. (bestog) + - Valerio Colella + - Daniel Wendler + - Kacper Gunia + - Arne + - Rémy Issard + - hanneskaeufler + - Egor Ushakov (erop) + - jfhovinne + - Thomas P + - Jeroen + - Romain Biard (rbiard) + - Jonathan Holvey + - Grégory Quatannens (gscorpio) + - BETARI Amine (amine_ezpublish) + - Sorin Dumitrescu (sfdumi) + - Maxime Douailin + - Daniel Klein + - David Lumaye + - A goazil + - Grzegorz Dembowski (gdembowski) + - Dennis Bijsterveld (bijsterdee) + - Patrik Pacin + - Bartłomiej Zając (bzajac) + - jivot + - progga + - Thibaut Selingue + - Dukagjin Surdulli + - bouffard (shinmen33) + - Mathieu + - Jorick + - Patrik Csak + - Julien Humbert + - Rob Gagnon + - Nebojša Kamber + - Thomas Talbot + - Boolean Type (boolean_type) + - Urs Kobald (scopeli) + - Hari K T (harikt) + - Michael COULLERET (20uf) + - Timo Haberkern (thaberkern) + - Robert Koller (robob4him) + - Alexandru Furculita ♻ + - Hmache Abdellah + - concilioinvest + - Paweł Czyżewski + - Catalin Criste (catalin) + - Med Ghaith Sellami + - Catalin Minovici (catalin_minovici) + - Carlos Zuniga (charlieman) + - Christiaan Baartse (christiaan) + - Etshy + - E Demirtas + - antoinediligent + - Bob D'Ercole + - Erwann MEST (_kud) + - ipf + - Sebastian Blum (sebiblum) + - V. K. (cn007b) + - David Ward (roverwolf) + - MarvinBlstrli + - Dalius Kalvaitis (daliuskal) + - runephilosof-abtion + - iamdto (iamdto) + - Jeroen Seegers + - Nehal Gajjar + - jmangarret + - YummYume + - Leanna Pelham + - twisted1919 + - fbuchlak + - Ricardo Rentería + - Sven Petersen + - Derek Roth (derekroth) + - Geert Clerx + - fberthereau + - Franz Holzinger + - Julian Wagner + - Deepak Kumar + - Joe Hans Robles Martínez (joebuntu) + - Yoan Bernabeu + - Colin Poushay (poush) + - Vancoillie + - optior + - Pierre Maraître (balamung) + - Kerrial (kez) + - Lambert Beekhuis (lambertb) + - pamuche + - Bert Van de Casteele + - Daniel Kesselberg (kesselb) + - MarcomTeam + - gitomato + - Iqbal Malik (iqbal_malik89) + - Abdelilah Boudi (devsf3) + - Timotheus Israel (dieisraels) + - Mohameth + - Mark Brennand (activeingredient) + - Adrián Ríos (adridev) + - Kolja Zuelsdorf + - Alexandre GESLIN (rednaxe) + - Denis Brumann + - Francisco Corrales Morales + - Jason Bouffard (jpb0104) + - Katharina Floh (katharina-floh) + - Heaven31415 + - markspare + - Vincent Jousse + - jerzy-dudzic + - Rafael Gil (cybervoid) + - Davor Plehati (dplehati) + - Oussama GHAIEB (oussama_tn) + - Daniel Kozák + - atmosf3ar + - Clément Barbaza + - Christoph Grabenstein + - Benoit Jouhaud (bjouhaud) + - David + - matheo + - Andries van den Berg (ansien12) + - Christophe Deliens (cdeliens) + - Alexander O'Neill + - Jürgen + - Bruno Vitorino + - juliendidier + - Matt Janssen + - Alex Ghiban (drew7721) + - Cyril VERLOOP (cyrilverloop) + - Ivan Kosheliev (dfyz) + - Duane Gran (duanegran) + - Szymon Dudziak + - Turdaliev Nursultan (nurolopher) + - Louis-Arnaud + - Gonzalo Alonso (gonzakpo) + - Chase Noel (chasen) + - Nikolai Plath + - Krzysztof Nizioł + - Roman (grn-it) + - Andrey Tkachenko + - AntoineRoue + - Jules Lamur + - mocrates + - Andrei Petre + - Gabriel Bugeaud + - Rylix + - Arthur Hazebroucq + - Pim van Gurp + - Erik (erikroelofs) + - sebio + - Fayez Naccache (fnash) + - Frank Stelzer (frastel) + - Adam Prancz (praad) + - Josenilton Junior (zavarock) + - Benjamin Bourot + - jeanhadrien + - Gabriel Théron (g.theron) + - Simon Perdrisat (gagarine) + - Kristijan Stipić (stipic) + - Marie CHARLES (mariecharles) + - ABRAHAM Morgan + - Lucas Mlsna + - Marko Kunic (kunicmarko20) + - Csaba Maulis (senki) + - Simone Gentili (sensorario) + - Yoann B (yoann) + - mark2016 + - Halil Özgür + - Christopher + - Marichez Pierre (chtipepere) + - Anthony FACHAUX + - Tim Werdin + - Kévin LE LOUËR + - Ali Sunjaya + - Marvin Butkereit + - Barun + - Tristan Darricau + - Fanny Gautier + - Christophe Debruel (krike06) + - Yaroslav Kiliba + - Vladislav Lezhnev (livsi) + - Florian-B + - Daniel F. (ragtek) + - Wouter J + - tuanalumi + - ayacoo + - Olivier Revollat (o_revollat) + - javaDeveloperKid + - Syedi Hasan + - dawidpierzchalski + - Kevin Lot + - Andrea Cristaudo + - Baptiste Pottier (baptistepottier) + - Benoît WERY (benoitwery) + - Patrick Mota (ganon4) + - Reinier Butôt + - Arnaud Pflieger + - Nico + - Boris Sondagh (botris) + - Mickaël Bourgier (chapa) + - Robin Willig (dragonito) + - Aalaap Ghag (aalaap) + - Eric Poe (ericpoe) + - Giancarlos Salas (giansalex) + - xamgreen + - Michal Zuber + - Mark Smith (zfce) + - Thomas Botton (skeud) + - Théophile Helleboid - chtitux + - Omer Karadagli (omer) + - Tom Grandy + - Felix Schnabel + - Pierre Joye (pierre) + - Bastien70 + - Babar Al-Amin (babar) + - Benjamin D. (benito103e) + - Sherin Bloemendaal + - Krzysztof Daniel (krzysdan) + - Patryk Miedziaszczyk + - pbijl (pbijl) + - copilot-swe-agent[bot] + - Patrick Maynard + - Terje Bråten + - Philippe Gamache (philippegamache) + - Cyanat + - Lucas CHERIFI (kasifi) + - David Rolston (gizmola) + - Vadym (rvadym) + - Victor Melnik (gremlin) + - Grzegorz Balcewicz (gbalcewicz) + - Guillaume Sylvestre (gsylvestre) + - Sander Verkuil (sander-verkuil) + - Fabien (fabiencambournac) + - Florian Körner (koernerws) + - Stephan + - Michel Valdrighi (michelv) + - David Desberg + - New To Vaux + - Tajh Leitso (tajh) + - Roman Martinuk + - Greg Pluta + - Michał Wujas + - vindby23 + - Hugo Nicolas (jacquesdurand) + - SquareInnov + - Milan Pavkovic + - Sven Scholz + - DOEO + - Guillaume PARIS (gparis) + - Xavier Laviron (norival) + - Plamen + - Iv Po + - Greg Berger + - Carlos Sánchez (carlossg00) + - Issam KHADIRI (ikhadiri) + - Roger Webb (webb.roger) + - Tommy Quissens (quisse) + - Janko Diminic (jankod) + - Frédéric Lesueurs + - Matthieu Renard + - Jonas De Keukelaere + - Luc Hidalgo (luchidalgo) + - Julien Dubois + - Eugene Dounar + - Artur Butov (vuras) + - Ousmane NDIAYE + - Ondrej Vana (kachnitel) + - Marchegay (xaviermarcheay) + - Maxime Steinhausser + - sblaut + - Jonathan Lee (jclee2) + - Nico Th. Stolz (jeireff) + - Jose F. Calcerrada (jfcalcerrada) + - Jibé (jibe0123) + - Mickael GOETZ + - Muhammad Nasir Rahimi + - romain + - Brendan + - Rob + - Ka (Karim Cassam Chenaï) + - Sebastian Kuhlmann (zebba) + - Kélian Bousquet + - apiotrowski + - Pierre Maraitre + - Johan de Jager (dejagersh) + - Raphaël Geffroy + - Faizan Shaikh + - ondra + - Antonio Jesús + - Belgacem TLILI (belgacem) + - Jérémy Jarrié (gagnar) + - Savvas Alexandrou (savvasal) + - Peter + - Kirill Kotov + - Pieter Oliver + - Louis Racicot (lord_stan) + - Pol Romans (snamor) + - Reza Rabbani + - Poulette Christophe (totof6942) + - norfil + - Olivier Bacs (obax) + - Dorthe Luebbert (luebbert42) + - Vince (zhbzhb) + - Bogdan Olteanu + - Nurlan Alekberov + - Erlang Parasu (erlangparasu) + - Peter WONG + - Neal Brooks (nealio82) + - Aymeric Mayeux (aymdev) + - Kamil Pešek (kamil_pesek) + - seangallavan + - Nic Wortel (nicwortel) + - Patrick Bielen + - Ben Glassman (bglassman) + - Thomas Berends + - Philip Ardery + - David ALLIX (weba2lix) + - BorodinDemid + - Ana Cicconi + - Nassim LOUNADI + - Alexpts (alexpts) + - Valentin Silvestre (vasilvestre) + - Spomky + - vesselind + - Joseph Bielawski + - Yannick + - Nieck Moorman + - Igor + - James (acidjames) + - Gilles Taupenas + - Valentin GRAGLIA + - Florian + - Brian Gallagher + - Karin van den Berg + - Dhanushka Samarakoon + - Philipp Christen + - Jerome Gangneux + - Denis Brumann + - Russell Flynn (rooster) + - avanwieringen + - Jonczyk + - bpiepiora + - Tim Jabs + - Ben Thomas + - Krzysztof Lechowski (kshishkin) + - Danny Kopping (dannykopping) + - Corentin + - Angelo Melonas (angelomelonas) + - nasaralla + - zuhair-naqvi + - Serhii Polishchuk + - Lamari Alaa + - sander Haanstra (milosa) + - jean-marie leroux (jmleroux) + - skipton-io + - Thao Nguyen (thaowitkam) + - Lukáš Brzák (rapemer) + - Daniel Werner (powerdan) + - Adam Szaraniec (mimol) + - Thomas from api.video + - xelan + - Lorenzo Ruozzi (lruozzi9) + - Murilo Lobato (murilolobato) + - James Cryer (jrcryer) + - Jacob Dreesen + - Leonel Machava + - Nicolas Lœuillet (nicosomb) + - Vincent Chareunphol (devoji) + - Marijn Huizendveld + - Thomas Decaux (ebuildy) + - Lars + - Fred Jiles (fredjiles) + - Egidijus Girčys (egircys) + - Julian (c33s) + - Ryan Castle (ryancastle) + - Chad Meyers (nobodyfamous) + - Tim Stamp + - Emir Beganović (emirb) + - Henrik Christensen + - ipatiev + - sr972 + - xuni + - Edson Medina + - Roy Templeman + - Erison silva (eerison) + - Sarim Khan (gittu) + - Justin Liiper (liiper) + - asartalo + - Abdellatif Derbel (abdellatif) + - Xavier Coureau + - George Zankevich + - David Frerich + - Peter Majmesku + - Guillaume HARARI (guillaumeharari) + - Sven Zissner (svenzissner) + - KalleV + - Christopher Tatro + - Aurélien ADAM (aadam) + - Андрей + - Oliver Kossin + - Robert + - Damian Zabawa (dz) + - Tobias Schmidt (tobias-schmidt) + - Jakub Szcześniak (jakubszczesniak) + - JohnyProkie (john_prokie) + - Olivier Toussaint (cinquante) + - wouthoekstra - Romain - - Xavier REN - - Kevin Meijer - - max - - Alexander Bauer (abauer) - - Ahmad Mayahi (ahmadmayahi) - - Mohamed Karnichi (amiral) - - Andrew Carter (andrewcarteruk) - - Adam Elsodaney (archfizz) - - Gregório Bonfante Borba (bonfante) - - Bogdan Rancichi (devck) - - Daniel Kolvik (dkvk) - - Marc Lemay (flug) - - Gabriel Solomon (gabrielsolomon) - - Courcier Marvin (helyakin) - - Henne Van Och (hennevo) - - Jeroen De Dauw (jeroendedauw) - - Muharrem Demirci (mdemirci) - - Evgeny Z (meze) - - Aleksandar Dimitrov (netbull) - - Pierre-Henry Soria 🌴 (pierrehenry) - - Pierre Geyer (ptheg) - - Richard Henkenjohann (richardhj) - - Thomas BERTRAND (sevrahk) - - Vladislav (simpson) - - Marin Bînzari (spartakusmd) - - Stefanos Psarras (stefanos) - - Matej Žilák (teo_sk) - - Gary Houbre (thegarious) - - Vladislav Vlastovskiy (vlastv) - - RENAUDIN Xavier (xorrox) - - Yannick Vanhaeren (yvh) - - Zan Baldwin (zanderbaldwin) + - Eugene Wolfson + - Pierre Arnissolle (arnissolle) + - Jordan Lev + - Mathias STRASSER + - hidde.wieringa + - Georgiana Gligor (gbtekkie) + - Steve Winter + - pcky + - Parthasarathi GK + - asandjivy + - Dmitriy + - Glen Jaguin (gl3n) + - Danielle Suurlant (dsuurlant) + - Mitchel (mitch) + - Denis Rendler + - Vincent Brouté + - Kevin Boyd + - Terence Eden + - Peter + - chance garcia + - Robert Nagy + - I. Fournier + - Daan van Renterghem + - Adamo Crespi + - Christopher Vrooman + - Jevgenijus Andrijankinas + - Harry van der Valk + - pavemaksim + - aykin + - joelindix + - Freerich Bäthge (freerich) + - Lopton + - Marco Barberis + - Joshua Dickerson (groundup) + - Julio (gugli100) + - Dan Finnie + - Gaurish Sharma + - Luca Suriano (lucas05) + - de l'Hamaide + - Frank J. Gómez + - Jason McCallister (jasonmccallister) + - Oliver Adria + - Walkoss + - Grant Gaudet + - bdujon + - Simon BLUM (simonblum) + - Myystigri + - Sam Hudson + - Vitaliy Zurian + - Hector Hurtarte (hectorh30) + - oussama khachiai (geekdos) + - Chris Thompson (toot) + - michael schouman (metalmini) + - Hamza Hanafi + - Cesare + - rahul (rahul) + - van truong PHAN (vantruongphan) + - MohamedElKadaoui + - iqfoundry + - Lauri + - Paulius Masiliūnas (pauliuz) + - figaw + - Charly + - Kenan Kahrić (kahric) + - cancelledbit + - Quentin Boulard + - Josef Vitu + - Paul Coudeville + - Steve Wasiura + - Daniel Kucharski (inspiran) + - Denys Pasishnyi (dpcat237) + - Rafael Mello (merorafael) + - Franklin LIA + - autiquet axel + - Postal (postal) + - Kobe Vervoort (kobevervoort) + - Konrad pap (konrados) + - Tom Schwiha (tomschwiha) + - Sander Bol + - Marc Michot (eclae) + - Elliot + - Herbert Muehlburger + - Ben Glassman (benglass) + - Ashen one (berbadger) + - Jay Williams (jaywilliams) + - Jelmer Snoeck (jelmersnoeck) + - Joshua Morse (joshuamorse) + - Kevin Mark + - Florentin Garnier + - imam harir (luxferoo) + - Joachim Martin (michaoj) + - Pierre + - Florent DESPIERRES (fdespierres) + - Fabien Papet + - Alessandro Podo + - Thomas Miceli (tomus) + - srich387 + - Jeroen v.d. Gulik (jeroen) + - Dmitry Kolesnikov (kastaneda) + - Arnaud B (krevindiou) + - Mehmet Gökalp (mehgokalp) + - Martin Bens + - Hideki Okajima (okazy) + - Giuseppe Petraroli + - IamBeginnerC + - Yassine Hadj messaoud + - Daniel West (silverbackdan) + - Xavier Laviron + - Michel D'HOOGE (mdhooge) + - Son Tung PHAM + - Raggok + - Benoît + - marco-pm + - Yair Silbermintz (mrglass) + - Alex Wybraniec + - Paweł Farys + - Carlton Dickson (carltondickson) + - Piotr Grabski-Gradziński (piotrgradzinski) + - dellamowica + - Alan Farquharson + - Oliver Forral (intrepion) + - Jack Delin (jackdelin) + - Jean-Luc MATHIEU (jls2933) + - Maxime Morlet (maxicom) + - Rosemary Orchard + - Szilágyi Károly Bálint + - Ilya Bakhlin + - analogic + - William JEHANNE (william_jehanne) + - mhor (mhor) + - richardudovich + - Antonio de la Vega + - Volker Thiel + - Jean-Baptiste Delhommeau (jbdelhommeau) + - Jan Pieper + - Jonathan Cox + - Rick Burgess + - Oliver Davies (opdavies) + - Christian Weyand (weyandch) + - Francis Hilaire + - vgmaarten + - Stefan Topfstedt + - ousmane NDIAYE (ousmane) + - Pedro Piedade + - m_hikage + - Giulio De Donato + - Chris Bitler + - Laurent Marquet + - pathmissing + - Thomas Talbot + - Pierre-Yves Dick (pyrrah) + - Paulo Rodrigues Pinto (regularjack) + - Richard Perez (richardpq) + - Kristian Zondervan (krizon) + - Joel Doyle (oylex) + - Sylvain Lelièvre + - Michaël Perrin + - Chris Halbert + - temenb + - Raúl Continente (raulconti) + - Adil YASSINE ✌️ (sf2developer) + - Michiel Missotten (zenklys) + - ptrm04 + - Jeroen Deviaene + - Michael Lenahan + - Giacomo Moscardini + - Valantis Koutsoumpos + - Adam Duffield + - Pau Oliveras (poliveras) + - Shane Archer (sarcher) + - M#3 + - Julien (mewt) + - Guillaume Lasset + - kenjis (kenjis) + - damienleduc + - Carwyn Moore + - Иван + - Ozan Akman + - Benjamin Porquet + - Alex Oroshchuk + - Michael H + - Axel Vankrunkelsven + - Andrey Bolonin + - Leanna Pelham (leannapelham) + - Gauthier Gilles + - Ala Eddine khefifi + - MWJeff + - Kieran Black + - guesmiii + - nietonfir + - Hugo Locurcio + - Alessio Barnini + - Martijn Gastkemper (martijngastkemper) + - Martin Černý + - SamanShafigh + - Denis (ruff3d) + - Andrii Mishchenko (krlove) + - KULDIP PIPALIYA (kuldipem) + - Ronan Pozzi (treenity) + - Maciej Kosiarski + - CHARBONNIER (cyrus) + - Augustin Chateau (gus3000) + - Stefan Doorn (stefandoorn) + - Jonathan Finch + - Gianluca Farinelli (rshelter) + - Soltész Balázs + - Hugo Locurcio + - silver-dima + - matt smith (dr-matt-smith2) + - Pierre Joube (pierrejoube) + - Jeremiah Dodds + - MarkPedron + - Arnaud Lemercier + - Anani Ananiev + - Paweł Małolepszy (pmalolepszy) + - Fabian Becker + - Amitay Horwitz (amitayh) + - Manel Sellés (manelselles) + - Veltar + - Peter Bottenberg + - Nicola Pietroluongo + - Oliver Stark (oliver.stark) + - Pjotr Savitski + - Jean-David Daviet + - gnito-org + - Richard Hoar + - adursun + - Olivier Acmos (olivier_acmos) + - kolossa + - Thomas (razbounak) + - denniskoenigComparon + - Mathieu Capdeville + - ahinkle + - Reio Remma + - Zoltan Toth-Czifra + - Juan Riquelme + - Maciej Łebkowski (mlebkowski) + - Javad Adib + - Jonas Wouters + - Rick Ogden + - micter59 + - Tomáš Tibenský + - Vincent Terraillon (lou-terrailloune) + - Thibaut Leneveu + - andybeak + - Virginia Meijer + - Ante Crnogorac + - Florian Moser + - Sylvain + - David McKay + - clément larrieu + - Mike Bissett + - Epari Siva Kumar + - Matthias + - Andreas + - illusionOfParadise + - azielinski + - Michael Witten (micwit) + - r-ant-2468 + - Karsten Gohm (kasn) + - Kik Minev (kikminev) + - Fabian Spillner (fspillner) + - Jérôme Poskin (moinax) + - lacatoire + - Armen Mkrtchyan (iamtankist) + - Sylvester Saracevas (saracevas) + - Maximilien BERNARD (mb3rnard) + - Marius Büscher (mbuescher) + - niebaron + - Works Chan + - jordanjix + - Nico Hiort af Ornäs + - Alexandre Balmes (pocky) + - Caliendo Julien + - Matheus Pedroso + - Tony Tran (tony-tran) + - Morgan Thibert (o0morgan0ol) + - Levin + - Mark Deanil Vicente (dvincent3) + - Ilya Antipenko + - karzz + - Markus Frühauf + - Damien Carrier (mirakusan) + - Nassim + - Enzo Santamaria + - unknown + - Olivier Lechevalier + - Leny BERNARD + - Jon Eastman + - Sergey Belyshkin + - Cellophile + - Gaetan Rouseyrol + - scriptibus + - jpache + - dearaujoj + - Patrick PawseyVale + - lucchese-pd + - Philippe Villiers + - Marek Szymeczko + - Saidou GUEYE + - Pavel Bezdverniy + - Tamás Molnár (moltam) + - Mathias STRASSER + - Jace25 + - Sylvain Ferlac + - Kamil Breguła + - Marco + - Alden Weddleton (wnedla) + - Kevin + - Vladimir + - Ldiro + - JhonnyL + - James Seconde (secondejk) + - Kilian Riou (redheness) + - Nikita Nyatin + - David Baucum + - Carlos Jimenez (saphyel) + - Aleksandr Frolov (thephilosoft) + - GiveMeAllYourCats + - Matthew Thomas + - VladZernov + - damien-louis + - Raphael Michel + - HONORE HOUNWANOU (mercuryseries) + - Jérémy BLONDEAU (jblondeau2) + - Philippe Mine (dispositif) + - Marek Brieger (polmabri) + - Lluis Toyos (tolbier) + - Taiwo A (tiwiex) + - Tobias Olry (tolry) + - Chris Taylor + - Matthew Setter (settermjd) + - chapterjason + - Florian Cellier (kark) + - Andras Ratz (ghostika) + - Mart Kop + - Yakov Lipkovich + - Fabien Bourigault + - Ezequiel Esnaola + - Sam Korn + - Surfoo (surfoo) + - t.le-gacque + - Hex Titan (hextitan) + - Tsimafei Charniauski (varloc2000) + - Beno!t POLASZEK + - Florian Bastien (fbastien) + - rodmar35 + - Krzysztof Lament + - Euge Starr + - Steve + - Artur + - Robin Brisa + - Romain GRELET + - Vladimir Gavrylov + - radnan + - Robert Treacy (robwasripped) + - David Harding + - Kevin Wojniak + - hector prats (jovendigital) + - Yopai + - Alexander Kim + - Axel K. + - Christopher + - BooleanType + - Julien Deniau (jdeniau) + - Alex Luneburg + - Max Schindler (chucky2305) + - Norio Suzuki (suzuki) + - Tristan LE GACQUE (tristanlegacque) + - Scott + - Charles EDOU NZE + - mccullagh + - Stéphane HULARD (shulard) + - Simon Rolland (sim07) + - Simon Berton (simonberton11) + - Giovanni Gioffreda (tapeworm) + - Thierry Geindre (tgeindre) + - Eduardo Thomas Perez del Postigo (aruku) + - Marcus Schwarz + - Robert Parker (yamiko) + - Jan De Coster + - Rico Neitzel + - Alessio Pierobon (alepsys) + - Damien DE SOUSA (dades) + - Claudio Zizza + - zeggel + - Evgeniy Gavrilov + - Rémy Vuong (rvuong) + - Andrey Lukin (wtorsi) + - Yannick ROGER (yannickroger) + - Edoardo Rivello (erivello) + - Malte N (hice3000) + - Elias Van Ootegem + - Aurélien MARTIN + - fishbone1 + - Tomi Saarinen (tomis) + - Dries Vints + - Kilian Schrenk + - Andreas Larssen + - phiamo + - Gytis Šk + - Matt Kirwan + - royswale + - Egidijus Gircys + - Epskampie + - Markus Virtanen + - Ross Deane (rossdeane) + - Dimitri Labouesse + - Tyler King + - Darien Hager + - Mathieu Ducrot (mathieu-ducrot) + - Adam W (axzx) + - Francisco Calderón (fcalderon) + - marcagrio + - Quentin Brunet + - Kevin Archer (kevarch) + - adreeun + - E Ciotti + - Jeroen + - Vladimir Jimenez + - Iker Ibarguren + - Linus Karlsson + - Jason Johnstone + - ismail BASKIN + - Sergey Falinsky (falinsky) + - Florian Semm (floriansemm) + - Gabriel Pillet (tentacode) + - Pooyan Khanjankhani + - Jannes Drijkoningen (jannesd) + - Rick Kuipers + - moon-watcher + - Tim Krase + - Kendrick + - Bastien Picharles (kleinast) + - Tommi + - Andrew Cherabaev + - Alexandre Bertrand + - Alejandro García Rodríguez (alejgarciarodriguez) + - Alfonso Machado Benito (almacbe) + - Amine Matmati (aminemat) + - Nils Freigang (pueppiblue) + - Matthew Ratzke (flyboarder) + - samson daniel (samayo) + - SirRFI + - Tomasz Ducin (tkoomzaaskz) + - Raphaël Riehl + - MaharishiCanada + - GoT + - unknown + - Hans Allis (hansallis) + - Jorge Luis Betancourt (jorgelbg) + - James Mallison + - BT643 + - Ahmed Siouani (ahsio) + - Christian + - Giuseppe Attardi + - Favian Ioel Poputa (favianioel) + - Aleksander Cyrkulewski (martyshka) + - Katharina Störmer + - Maurice Svay (mauricesvay) + - Lorenzo Milesi (maxxer) + - Viacheslav Demianov (sdem) + - AntoJ (merguezzz) + - Sethunath K (sethunath) + - Woody Gilk (shadowhand) + - Shambhu Kumar (shambhu384) + - Open Orchestra (open-orchestra) + - Shiraz (zpine) + - Edgar Brunet + - Bram van Leur (bvleur) + - Jeff Zohrab + - CvekCoding + - Philippe Milot + - Leonard Simonse + - John Williams + - Gilles Gauthier + - Eöras + - lacpandore + - Emilio de la Torre (emiliodelatorrea) + - Terje Bråten + - Marcin Muszynski + - Romain Petit + - helmi dridi + - Marco Woehr + - Yuri Tkachenko (tamtamchik) + - Simon Van Accoleyen (simonvanacco) + - Slava Belokurski (slavchoo) + - Loïc Salanon + - LiVsI + - Marius Adam + - kempha + - Alexey Pyltsyn (lex111) + - jakumi + - Vico Dambeck + - Christophe Boucaut + - Nadim AL ABDOU + - Mateusz Anders + - Wanne Van Camp + - Anand (anandagra) + - Andrew D Battye (andrew_battye) + - Stefan Blanke (stedekay) + - Nicolae Astefanoaie (stelu26) + - Arnaud Lejosne + - Kris + - b0nd0 + - Damien + - larsborn + - Paris mikael (stood) + - Stanislav Zakharov (strannik) + - Carsten Blüm (bluem) + - Markus Mauksch + - Rhodri Pugh + - Fabien Bourigault + - Sven (svdv22) + - Atchia Mohammad Annas Yacoob (annas-atchia) + - Quentin Fahrner (renrhaf) + - Shaun Simmons (simshaun) + - zeroUno + - Mickaël + - jenyak + - Jan Richter + - z38 + - Xbird + - matthieudelmas + - Dirk Luijk (dirkluijk) + - Adam Lee Conlin (hades200082) + - Alexander Diebler + - Tom Egan + - Julien BENOIT + - Pierre-Emmanuel CAPEL (pecapel) + - Alex Coventry + - vihuarar + - Chloé B. + - Manuel Andreo Garcia + - runawaycoin + - lusavuvu + - Ali Yousefi (aliyousefi) + - Jan Schütze (dracoblue) + - Jasperator + - Oleg Zinchenko + - Edward Kim + - Sarah-eit + - sebgarwood-gl + - Émile PRÉVOT + - Rafa Couto + - Gabriel Theron + - Thierry Goettelmann + - Gennadi Janzen + - András Debreczeni + - Mustafa Ehsan Alokozay + - proArtex + - fplante + - Ruslan + - Nelu Buga + - Daniel Garzon (arko) + - Jan Grubenbecher + - Elbert van de Put + - cirrosol + - Houssem ZITOUN + - Michael Dwyer (kalifg) + - Fernando Aguirre Larios (ingaguirrel) + - Morf + - Jan Myszkier + - manseuk + - Philipp Bräutigam + - tikoutare + - Menachem Korf + - Stephan Dee + - Shamsi Babakhanov + - Charles Winebrinner + - Jeroen + - Marius-Liviu Balan (liv_romania) + - Micheal Cottingham (micheal) + - Michelle Sanver (michellesanver) + - S Berder + - Félix Fouillet + - Tobias Berchtold + - Mark Challoner + - Manuele Menozzi (mmenozzi) + - lajosthiel + - Robert Went (robwent) + - Micha Alt + - wkania + - EtienneHosman + - z38 + - Thibaud BARDIN (irvyne) + - Greg (kl3sk) + - Jean Pasdeloup + - Daniel Siepmann + - valepu + - laurent negre + - Mathias Geat (maffibk) + - Alex Brims (outspaced) + - Shawn Dellysse + - Souhail (souhail_5) + - Tom Nguyen + - Yngve Høiseth + - Manuel Transfeld + - Sacha Durand (sacha_durand) + - Francesco Tassi (ftassi) + - Frédéric Planté + - heddi.nabbisen + - Jalen + - Augustin Delaporte + - Hubert Moutot (youbs) + - Robert Brian Gottier + - Christoph Wieseke + - Travis Yang (oopsfrogs) + - Alireza Rahmani Khalili (alireza_rahmani) + - German Bortoli (germanaz0) + - e-weimann + - Greg Somers + - Martin Czerwinski + - Lee Jorgensen (profmoriarty) + - Erwan Richard (erichard) + - Damien Tournoud + - Aymen Bouchekoua (nightfox) + - Samuel Wicky + - Petr Kessler + - Florian Belhomme + - Pierre MORADEI + - Zac Sturgess (zsturgess) + - guiditoito + - Thomas Lemaire + - nicofrand + - Hossein Vakili + - Lacy (200ok) + - xavierkaitha94 + - Nicolas Potier (npotier) + - Dmitriy Fishman (fishmandev) + - Artem Henvald + - Kevin Warrington + - Peyman Mohamadpour + - linuxprocess + - Aaron Edmonds (aedmonds) + - Jérôme (ajie62) + - timo002 + - Xavier RIGAL + - Enache Codrut + - mismailzai + - Bartek Chmura + - Alex Normand + - Fouad + - Lucas Pussacq + - Alexandre HUON + - yanickj + - Christopher Moll + - Yannick (yannickdurden) + - Tom Maaswinkel (thedevilonline) + - Dmitry Vapelnik (dvapelnik) + - Fatih Ergüven (erguven) + - benti + - Petar Petković + - stormoPL + - rschillinger + - Bartosz Tomczak + - Felix Stein + - Manuel Agustín Ordóñez (manuel_agustin) + - Kevin Pires (takiin) + - Yoan Arnaudov (nacholibre) + - Rubén Rubio Barrera (rubenrubiob) + - Rick van Laarhoven (rvanlaarhoven) + - grelu + - Mickaël Blondeau (mickael-blondeau) + - Sasha Matejic (smatejic) + - Raphaël Davaillaud + - Dilantha Nanayakkara + - wazz42 + - Michael Phillips + - RickieL + - LEFLOCH Jean-François (katsenkatorz) + - abarke + - Benjamin Dos Santos + - Christopher Cardea + - ackerman + - RiffFred + - Guillaume Sarramegna + - Julian Mallett (jxmallett) + - Ian Gilfillan + - sakul95 + - Benjamin Clay (ternel) + - Kristof (jockri) + - Ahmed Lebbada (sidux) + - Bartek Nowotarski + - mimol91 + - Rick Pastoor + - Levi Durfee + - Julien Bonnier (jbonnier) + - Florian Blond (fblond) + - Willem Stuursma-Ruwen + - Théo FIDRY + - Jon Cave + - Marwâne (beamop) + - Pascal MONTOYA (pmontoya) + - Matt Trask (matthewtrask) + - Paul Rijke (parijke) + - Thijs Feryn + - Tim Jabs + - LucileDT + - Alexey Bakulin (bakulinav) + - Fabrice GARES (fabrice_g) + - Danny + - LICKEL Gaetan (cilaginept) + - Toni Conca (tonic) + - Attila Egyed (tsm) + - Johan de Jager + - Steve Clay (mrclay) + - Yann Klis + - Geert Eltink + - Martin Melka + - Marcin Sekalski + - Agustín Pacheco Di Santi + - Alexis Urien (axi35) + - partulaj + - Rami Dridi + - Ahmed Bouras + - Martijn Zijlstra + - Salah MEHARGA + - Marvin Hinz + - Andrey (quiss) + - Volodymyr Stelmakh + - Saad Tazi (saadtazi) + - OИUЯd da silva + - Zbigniew Czapran (zczapran) + - Navid Salehi (nvdsalehi) + - armin-github + - Therage Kevin + - Pierre Pélisset (ppelisset) + - Tarjei Huse (symfony_cloud) + - Xavier + - Malte Blättermann + - Lander Vanderstraeten + - Florian Moser + - Éric + - Clayton + - Wojciech Sznapka + - Ludovic REUS + - Ahmed Abdou (ahmedaraby) + - Cliff Odijk (cmodijk) + - Godfrey Laswai + - David + - Sakulbl + - Julien RAVIA + - Punt + - Josh Freeman (viion) + - antonioortegajr + - Michael Smith (michaelesmith) + - Etilawin + - venu (venu) + - Nicolas Dievart (youri) + - François MARTIN + - Ludwig Bayerl (lbayerl) + - fernandokarpinski + - R1n0x + - Idziak + - Diego Gullo (bizmate) + - Kanat Gailimov + - Stéphane P + - rogamoore + - Vivien Tedesco (vivient) + - Daniel (voodooprograms) + - WILLEMS Laurent (willemsl) + - Lenkov Michail (alchimik) + - Oleksandr Savchenko (asavchenko) + - Florian Rusch + - dcramble + - sebpacz + - Paweł Farys + - Pierre Bobiet + - Piotr Potrawiak + - Jorge Sepulveda + - broiniac + - Peter Hauke + - Fabian Freiburg + - Willem-Jan Zijderveld (wjzijderveld) + - Leonardo Losoviz (leoloso) + - Ricardo Peters (listerical) + - Justas Bieliauskas + - Alex-D (alexd) + - Christian Alexander Wolf + - Markus Weiland (advancingu) + - zulkris + - Dzamir + - Boris Shevchenko + - Sait KURT (deswa) + - ifiroth + - Walter Nuñez + - Patrik Gmitter (patie) + - Marius Balčytis + - Maximilian + - Zaid Rashwani (zrashwani) + - Pierre Galvez (shafan_dev) + - Ulrich Völkel (udev) + - Nebojša Kamber + - The Phrenologist (phreno) + - Stepan Mednikov + - Robin + - Gary Kovar + - Michel Chowanski (migo) + - KosticDusan4D + - Robin Gloster + - Bram de Smidt + - Evan Owens + - Filip Grzonkowski (grzonu) + - Qiangjun Ran (jungle) + - Liang Jin Chao (leunggamciu) + - Andrej Rypo + - Anthony Sterling (anthonysterling) + - Łukasz Bownik (arkasian) + - Ondřej Vodáček + - Goran Grbic (tpojka) + - Benjamin Lazarecki (benjaminlazarecki) + - Michael Klein (monbro) + - Jean Pasqualini + - sofany + - FindAPattern + - Tom Haskins-Vaughan + - Uri Goldshtein + - Vyacheslav Pavlov + - Pierre de Soos + - Johnny Peck + - Mario Young + - Fabien Bourigault + - Arnaud Salvucci (arnucci) + - xthiago (xthiago) + - Karel (xwb) + - vladyslavstartsev + - pavdovlatov + - Wojciech Kania + - ymc-sise + - DKravtsov + - Jeremy Emery + - Piotr Strugacz + - Luka Žitnik + - Jason Grimes + - saf (asd435) + - Mohd Shakir Zakaria (mohdshakir) + - Cangit + - TrueGit + - Tim Kuijsten + - Dennis Benkert + - Alexis Lefebvre + - Alex Theobold + - Jerome Guilbot (papy_danone) + - Daniël Brekelmans + - Adiel Cristo + - BrnvrlUoeey + - beachespecially + - Brendan Lawton + - Nikita + - M.Wiesner + - Daniel LIma (yourwebmaker) + - Yuriy Sergeev (youser) + - Eike Send + - Bruce Phillips + - Robin Cawser (robcaw) + - Alexandr Kalenyuk + - Brandon Mueller (fatmuemoo) + - Thomas BILLARD + - Ziad Jammal (ziadjammal) + - muxator + - babache + - zan-vseved + - manu-sparheld + - Maximilian Bosch + - richardmiller + - Oliver THEBAULT + - Arnaud + - Mario Alberto + - Bruno Casali + - Kevin de Heer + - fullbl + - Dorian Sarnowski (dorian) + - Viktor Linkin (adrenalinkin) + - Stephen Ostrow (isleshocky77) + - Ali Zahedi (aliz9271) + - Michel ANTOINE (antoin_m) + - Pavel Nemchenko (nemoipaha) + - Jose R. Prieto + - Chabbert Philippe (philippechab) + - Jérémie Samson (jsamson) + - scottwarren + - Romain Norberg + - Niels Vermaut (nielsvermaut) + - roga + - obsirdian + - Gus + - Tobias Sette + - Iulian Popa (iulyanp) + - AmalricBzh + - Alexander Dubovskoy + - hamzabas + - Leo + - sirprize + - VosKoen + - Danil Pyatnitsev (pyatnitsev) + - KaroDidi + - eric fernance (ericrobert) + - Timo Tewes + - yordandv + - mehlichmeyer + - Jens Pliester + - Szurovecz János + - Υоаnn B + - Francois CONTE + - Pouyan Azari + - Sylvain Combes (sylvaincombes) + - Christian Heinrich + - Dmitri Perunov + - Rick West + - Alihasana SHAIKALAUDDEEN + - makmaoui + - Cosmin Mihai Sandu (cosminsandu) + - Sergey Podgornyy (sergey_podgornyy) + - Marcel Serra Julià (serrajm) + - Andrea Bergamasco (vjandrea) + - Mrtn Schndlr + - Cassian Assael (crozet) + - Jacek Jędrzejewski + - Benjamin Sureau + - Konstantin (phrlog) + - Rodrigo Rigotti Mammano (rodrigorigotti) + - Cédric Spalvieri (skwi) + - Dmitry Vishin (wishmaster) + - Rutger + - Jose Diaz + - kohkimakimoto + - Tim Glabisch + - Jan + - Andreas Schönefeldt + - VelvetMirror + - Dorozhko Anton + - Jonathan Clark + - Giulio Lastra + - Ed Poulain + - wiese + - Stéphane Paul BENTZ (spbentz) + - Krap + - Stefan Grootscholten (stefan_grootscholten) + - Matthieu Braure (taliesin) + - Prakash Thapa (thapame) + - Valter Carneiro da Silva Junior (valterjrdev) + - Tyler Sommer (veonik) + - Archie Vasyatkin + - Brian + - Sven Luijten + - Slobodan Stanic + - Alexandre Mallet (woprrr) + - Frederik Schubert + - Stacy Horton + - Sébastien Lourseau + - Nathan Giesbrecht + - Sebastian Bergmann + - Alex Kyriakidis + - Kevin Papst + - Mynyx + - David Vigo + - Sam Jarrett + - Robert + - Pierre Spring + - andrecadete + - David Schmidt + - Art Matsak + - Dynèsh Hassanaly (dynesh) + - 6e0d0a + - Jan Klan (janklan) + - Jonathan + - Jamal Youssefi + - Volen Davidov + - Alfonso M. García Astorga (alfonsomga) + - José María Sanchidrián (sanmar) + - martin05 + - Noel + - Julien Dephix + - Lukas W + - beram (beram) + - Avindra Goolcharan + - Alaa AttyaMohamed (alaaattya) + - Mike Zukowsky + - Oliver Kossin + - Ignacio Aguirre + - Anthony Rey (sydney_o9) + - Florent + - Marko Mijailovic + - Colin DeCarlo (colindecarlo) + - Andrew Martynjuk (crayd) + - Doug Smith (dcsmith) + - wbob + - Daniele Ambrosino + - Zahir Saad Bouzid + - Lucas Nothnagel (scriptibus) + - Christian Oellers + - Guilherme Donato + - Nick Winfield + - Asma Drissi (adrissi) + - Daniel Santana + - Janusz Slota (janusz.slota) + - Szymon Skowroński (skowi) + - Thomas Le Duc (viper) + - Rob Meijer (robmeijer) + - revollat + - RisingSunLight + - Michaël Demeyer + - AdrianBorodziuk + - peaceant + - Mohsen + - Sudhakar Krishnan + - Michaël Perrin + - Gintautas + - guangle + - Denis Dudarev + - Jesús Miguel Benito Calzada (beni0888) + - Lauri + - Alex Salguero + - manoakys + - Roberto Lombi + - Arnaud VEBER (veberarnaud) + - Serge Velikanov + - Richard Miller + - Lucian Tugui (luciantugui) + - Mehdi Tazi (mehditazi9) + - Joe Mizzi (themizzi) + - Thomas Lomas (tomlomas) + - ioanok + - Kevin + - Kevin + - Christian Schaefer (caefer) + - Hugo Casabella (casahugo) + - Charles Pourcel (ch.pourcel) + - Alexey Rogachev + - Matthieu Danet (matthieu-tmk) + - Varun Agrawal (varunagw) + - Marc Wustrack (muffe) + - Laurent Marquet + - marcusesa + - Bart van Raaij (bartvanraaij) + - Kim Wüstkamp (kimwuestkamp) + - Chris McMacken (chrism) + - Pierre Trollé + - Piotr Stankowski + - Adam Boardman (boardyuk) + - Thomas Choquet (tchoquet) + - Adrien LUCAS + - Baptiste Fotia (zak39) + - Ruud Kamphuis + - Ivan Yivoff + - Paul Waring + - Jarek Ikaniewicz + - Mitchell + - Timon F. (timon) + - Denis-Florin Rendler + - alex00ds + - Jess + - Jochem Klaver + - David Paz (davidmpaz) + - tchap + - Dominik Pietrzak + - wadjeroudi + - Eliú Timaná + - Andrey Melnikov + - Vincent + - Michaël Mordefroy + - cvdwel + - Lucas Mlsna + - Titouan B + - IlhamiD + - Gyula Szabó (szabogyula) + - Joe Thielen + - Jake Bell + - Gilles Fabio + - Steve Nebes + - jms85 + - authentictech + - LavaSlider + - Sam Hudson + - Baptiste Langlade + - Chris Johnson + - Kris + - Jannik + - Jarosław Jakubowski (egger1991) + - Linas Merkevicius + - Nazar Mammedov + - pecapel + - Sylvain Blondeau + - Maelan LE BORGNE (maelanleborgne) + - jmsche + - danjamin + - Remi + - JakeFr + - Žilvinas Kuusas (kuusas) + - XitasoChris + - Andrii Sukhoi + - Happy (ha99ys) + - Kamil Kuzminski (qzminski) + - jdevinemt + - Cristiano Cattaneo (ccattaneo) + - kruglikov + - Kevin Raynel + - tmihalik + - Reza + - Nietono + - Angelo Galleja (ga.n) + - TavoNiievez + - Ionut Enache + - Conrad Pankoff + - Maxime Douailin + - Tomasz Tybulewicz (tybulewicz) + - Vlad Ghita (vghita) + - Ahmed El Moden + - Unlikenesses + - kirill-oficerov + - aliber4079 + - Bruno Vitorino + - Christoph Schmidt + - tabbi89 + - John Spaetzel + - Harald Leithner + - Jure Žitnik + - Gergely Pap + - Julien Janvier + - Jérémy LEHERPEUR (amenophis) + - Thomas Rudolph (holloway) + - Nik G (iiirxs) + - Francisco Javier Aceituno (javiacei) + - Jo Meuwis (jo_meuwis) + - Luca Lorenzini + - Joel Costa (joelrfcosta) + - lobodol (lobodol) + - LOUVEL Mathieu (louvelmathieu) + - Maikel Ortega Hernández (maikeloh) + - Sam Van der Borght (samvdb) + - Paulius Podolskis (wsuff) + - Léo + - berbeflo + - Dmytro Bazavluk + - Simon Epskamp + - Theo Tzaferis + - snroki + - Jalen Muller (jalenwasjere) + - Simon + - LesRouxDominerontLeMonde + - Michael Staatz + - Jade Xau + - Maxim Spivakovksy (lazyants) + - CJDennis + - Marcel Korpel + - Marko Kaznovac + - Mohammad + - Richard Tuin (rtuin) + - Gabriel Albuquerque + - Sven Liefgen + - Greg Berger + - Alex Soyer + - Josh Taylor (josher) + - Piotr Gołębiewski (loostro) + - Marcin Sękalski (senkal) + - Behram ÇELEN (behram) + - Dan Tormey (dstormey) + - Jacek (opcode) + - PululuK + - technetium + - Benjamin Laugueux + - kallard1 + - Yaroslav Yaremenko + - Maximilian Ruta + - Lucas Courot (lucascourot) + - Edwin + - ruslan-fidesio + - Clément + - miqrogroove + - Tobias Berge + - Julien Ferchaud (guns17) + - Pedro Junior (vjnrv) + - Gun5m0k3 + - Carl Schwan + - Claude Ramseyer (phenix789) + - Prathap + - entering + - Christian Kolb (liplex) + - Massimo Ruggirello + - Michael Petri (michaelpetri) + - norbert-n + - Wolfgang Weintritt (wolwe) + - Benoît Durand (bdurand) + - Robert Parker (yamiko_ninja) + - Dustin Meiner + - Cory Becker + - Jérémy Crapet + - Mohamed YOUNES (medunes) + - Stephen Clouse + - JT Smith + - Artem Ostretsov + - Nextpage + - Robert Podwika + - lbraconnier2 + - Panda INC (pandalowry) + - Daniel Santana + - DerStoffel + - elescot + - Tom Troyer + - Sébastien FUCHS + - Vilius Grigaliūnas + - M.Eng. René Schwarz + - Jorisros (jorisros) + - Daniel Parejo Muñoz (xdaizu) + - Mostefa Medjahed (mostefa) + - Crushnaut + - Daniele D'Angeli (erlangb) + - Richard Perez (riperez) + - Antonio Spinelli + - Ian Mustafa + - Andrey Shark (astery) + - Pavel Jurecka + - renepupil + - Sébastien Rogier (srogier) + - Yohann Durand (yohann-durand) + - Rafael Torres + - Ruben Petrosjan + - Michael Grinko + - David Negreira Rios (davidn) + - Jean-Philippe Dépigny + - Julien Chaumond (julien_c) + - Fabian Becker + - Maninder Singh (maninder) + - Mindaugas Liubinas (meandog) + - Mahdi Maghrooni + - Vimal Gorasiya + - Baptiste Langlade + - Alessandro Podo + - Michał Szczech (miisieq) + - Danilo Sanchi (danilo.sanchi) + - Matijn Woudt + - Michael Y Kopinsky (mkopinsky) + - Cadot.eu & Co. + - Matthieu Lempereur (matthieulempereur) + - Bruno Baguette (tournesol) + - Gabriel Birke (chiborg) + - Bill Surgenor + - Léo PLANUS + - Ian Kevin Irlen (kevinirlen) + - Nicolas GIRAUD (niconoe) + - Romain Card + - Ilya Bakhlin Lebedev + - Al-Saleh KEITA + - Stephan Savoundararadj (lkolndeep) + - Paweł Skotnicki (pskt) + - Robert Saylor (rsaylor) + - OrangeVinz (orangevinz) + - Mantas Varatiejus + - Josh Kalderimis + - Lee Boynton + - Richard Lynskey + - Clement Ridoret + - Dan Michael O. Heggø (danmichaelo) + - Laurens Laman (laulaman) + - Hamza Makraz + - alexsaalberg049 + - Dincho Todorov + - fridde + - timothymctim + - Guillaume Rossignol + - Linas Linartas (linas_linartas) + - Carlos Reig (statu) + - James Isaac + - Bruno Ferme Gasparin (bfgasparin) + - Thomas Ploch + - Felipe Martins + - René Backhaus + - Dawid Królak (taavit) + - Aurélien Thieriot + - Kane Menicou (kane-menicou) + - Severin J + - Steven + - Konstantin Tjuterev (kostiklv) + - Loïc Caillieux (loic.caillieux) + - Lyrkan + - A S M Sadiqul Islam (sadiq) + - Rudy Onfroy + - Slaven (sbacelic) + - jonasarts + - fb-erik + - Wil Moore (wilmoore) + - Mohammed Rhamnia (rmed19) + - Daniel Ancuta (whisller) + - tobiasoort + - Илья + - Al Bunch + - Julius (julius1) + - Paul Ferrett (paulf) + - Ronan Guilloux (ronan) + - NicolasPion + - Toni Peric + - Matěj Humpál + - Kwadz + - Luke Kysow + - Clément MICHELET (chiendelune) + - Julien "Nayte" Robic + - d.syph.3r + - Pavel Máca + - Michael Sheakoski + - Boissinot (pierreboissinotlephare) + - Grégory SURACI + - Vincent Le Biannic + - Darmen Amanbayev + - Unai Roldán (unairoldan) + - GNi33 + - Aikaterine Tsiboukas + - Hatem Ben (hatemben) + - Benjamin Hubert (gouaille) + - Korstiaan de Ridder (korstiaan) + - Dan Zera + - Denis Soriano (dsoriano) + - Jan Christoph Beyer + - Laurent Moreau (laulibrius) + - Robin Weller + - Benjamin Zaslavsky + - Nico Schoenmaker + - Baptiste Pizzighini (bpizzi) + - Łukasz Pior (piorek) + - Kevin Carmody (skinofstars) + - Peter Gasser + - PéCé + - Camille Jouan (ca-jou) + - Miguel Vilata (adder) + - Raistlfiren + - Kevin Wojniak + - Tobias Hermann + - Mohamed Ettaki TALBI (takman) + - Pavel Shirmanov (genzo) + - Rodrigo Capilé (rcapile) + - João Paulo Vieira da Silva + - Dennis de Best (monsteroreo) + - Andrii Volin (angy_v) + - Loïc Sapone (loic_sapone) + - Kostas Loupasakis (loupax) + - Max R + - Cosmic Mac + - Rémi Andrieux (pimolo) + - Sela + - Kane Menicou (kane_menicou) + - Eric Tucker + - Ross Cousens + - Nelson da Costa + - VisionPages + - Seikilos + - CodyFortenberry + - Andréas Hanss + - Florimond Manca + - oyerli + - Giovanni Toraldo + - Michaël Dieudonné + - ismail mezrani (imezrani) + - Christophe Meneses + - Mark (markchicobaby) + - Metfan (metfan) + - Christopher Hoult (choult) + - Clemens Krack (ckrack) + - George Pogosyan (gp) + - Vladimir Schmidt (morgen) + - Sebastián Poliak (sebastianlpdb) + - Tom Schuermans (tschuermans) + - Alexandr Podgorbunschih (apodgorbunschih) + - Daichi Kamemoto (yudoufu) + - Marc Verney + - Brandin Chiu + - TheSidSpears + - Abdellah EL GHAILANI (aelghailani) + - Mark Badolato (mbadolato) + - Kai (kai_dederichs) + - Ejamine + - Raul C + - Thomas Kappel + - Jarvis Stubblefield (ballisticpain) + - robert Parker + - ampt . (ampt) + - Dr. Balazs Zatik + - Milan (milan) + - Niklas + - Mykola Martynov (mykola) + - Nicolas Mugnier + - mohamed + - Daryl Gubler (dev88) + - Quentin ADADAIN + - michael kimsal (kimsal) + - Antoine Durieux (adurieux) + - Gasmi Mohamed (mohamed_gasmi) + - Christophe Willemsen (kwattro) + - Joel Clermont (jclermont) + - Brent Shaffer (bshaffer) + - ThomasGallet + - Phil Moorhouse (lazymanc) + - Pierre-Jean Leger + - unknown + - Ramzi Abdelaziz (ramzi_a) + - Davi Tavares Alexandre (davialexandre) + - Erdal G + - Luuk Scholten (lscholten) + - Bryan J. Agee + - Jérémy Jumeau (jeremyjumeau) + - Daniel Platt (hackzilla) + - ABOULHAJ Abdelhakim (hakim_aboulhaj) + - Hans Stevens (hansstevens) + - Maxime Cornet (elysion) + - Jason Aller (jraller) + - Carlos Granados + - Adoni Pavlakis + - ghertko + - Tim Hovius (timhovius) + - Jérôme Nadaud + - Cyril Mouttet (placid2000) + - Ladislav Kubes + - Sofien NAAS + - Inori + - vmarquez + - Patrick McAndrew (patrick) + - Kirill Baranov (u_mulder) + - Artur Weigandt + - artf + - Maxim (big-shark) + - Petru Szemereczki (hktr92) + - Jan Heller (jahller) + - Roger Llopart Pla (lumbendil) + - Damien Chedan (tcheud) + - Nuno Pereira (nunopereira) + - Romaxx + - Douglas Naphas + - Zairig Imad + - Foksler (foksler) + - AlexKa + - Prisacari Dmitrii + - Evgeniy Guseletov (dark) + - gertdepagter + - Mbechezi Mlanawo + - pgorod + - Robert Freigang (robertfausk) + - faissaloux + - Maxime Doutreluingne (maxdoutreluingne) + - Paweł Krynicki (kryniol) + - Pinchon Karim + - Arndt H. Ziegler + - matteopoile + - JHGitty + - Thierry Thuon + - Jean-Marie Lamodière (jmlamo) + - Dan Barrett (yesdevnull) + - iarro + - Nitaco + - Valentin Ferriere (choomz) + - Vadim Bondarenko + - ehibes + - Phil Wright- Christie (philwc) + - Jordi Freixa Serrabassa + - Kiel Goodman + - Constantin Ross + - Wojciech Międzybrodzki (wojciechem) + - Kristof Coomans (cyberwolf) + - Greg Box (gregfriedrice) + - Omar Brahimi (omarbrahimi) + - Luc + - guidokritz + - Timur Murtukov (murtukov) + - John Ballinger + - Bob van de Vijver + - Yosip Curiel (snake77se) + - Kevin R + - Lance Bailey + - Zamir Memmedov (zamir10) + - Joan Teixido (joanteixi) + - Mihail Kyosev (php_lamer) + - Andrei + - Nicolas Hart (nclshart) + - Daniel Degasperi (ddegasperi) + - Sascha Egerer + - Dmytro + - Jacob Tobiasz (jakubtobiasz) + - Ben Huebscher (huebs) + - fguimier + - mojzis + - Arnaud Thibaudet (kojiro) + - Damien Fayet + - Nicolas Clavaud (nclavaud) + - Florian CAVASIN + - Pedro Nofuentes (pedronofuentes) + - Andrianovah nirina randriamiamina (novah) + - Bart Vanderstukken (sneakyvv) + - Deng Zhi Cheng + - Gustavo Henrique Mascarenhas Machado + - Markus Thielen (mathielen) + - Adam Mikolaj (mausino) + - Javi H. Gil (javibilbo) + - Jacob Mather (jmather) + - Darien + - Thomas LEZY + - Stefan hr Berder + - Robin C + - Javier Espinoza + - Bill Israel + - mvanmeerbeck + - phoefnagel + - Guillaume MOREL + - Patrick Bußmann + - Ayyoub BOUMYA (aybbou) + - Jérémy Halin + - Aaron Baker + - Benj + - mbehboodian + - Rafał Mnich (rafalmnich-msales) + - Mathieu + - Julien EMMANUEL + - Janne Vuori (jimzalabim) + - Michał Kurcewicz (mkurc1) + - nencho nencho (nencho) + - Kai Eichinger (kai_eichinger) + - Matthew Loberg (mloberg) + - Ryszard Piotrowski (richardpi) + - Ludwig Ruderstaller (rufinus) + - Nuno Ferreira (nunojsferreira) + - Michael Sivolobov (astronomer) + - Joshua (suabahasa) + - Steven DUBOIS (stevenn) + - Hugo Seigle + - rayrigam + - piet + - Simon Riedmeier (simonsolutions) + - Koen van Wijnen (infotracer) + - Robin Delbaere (rdelbaere) + - Daniel Felix (danielfellix) + - Susheel Thapa + - Marco Polichetti + - Albert Moreno + - Pedro Gimenez + - Ahmed Raafat (luffy14) + - Jorick Pepin (jorick) + - Sebastian Klaus + - Massimo Giagnoni (mgiagnoni) + - Thibault Pelloquin (thibault_pelloquin) + - Mario Martinez (chichibek) + - Maik Penz + - Zsolt Javorszky (zsjavorszky) + - Aaron Valandra + - Slava Fomin II (s-fomin) + - Markus Tacker + - Andrei Chugunov + - Jan G. (jan) + - Dimitar + - Abdellah Ramadan (abdellahrk) + - Arthur Hazebroucq + - Wouter + - Jonathan Huteau (jonht) + - Jérémy CROMBEZ + - Marek Bartoš + - Pedro Cordeiro + - sparrowek + - Nikola Kuzmanović (nkuzman) + - Eirik Alfstad Johansen (nmeirik) + - stehled + - healdropper + - Steven Chen (squazic) + - Martin Ninov (martixy) + - Yves ASTIER + - harcod + - beejaz + - Brice Lalu (bricelalu) + - Alexandre Castelain (calex_92) + - Michal Landsman + - Alex Savkov + - Alistair (phiali) + - Clément Notin + - Erik Trapman + - Guillaume Ponty + - amelie le coz (amelielcz) + - decima + - alexmart + - Juan Manuel Fernandez (juanmf) + - Epskampie + - Daniele Orler + - Casey Heagerty + - kraksoft + - Vladimir Jimenez + - g@8vue.com + - Keefe Kwan (kkwan) + - rs + - Mbechezi Mlanawo + - Łukasz Korczewski + - Joe + - Thomas Choquet (chqthomas3) + - htmlshaman1 + - Ivan Zugec (zugec) + - Petr (rottenwood) + - ameotoko + - (H)eDoCode + - Abdelkader Bouadjadja (medinae) + - Игорь Дмитриевич Чунихин (6insanes) + - github-actions[bot] + - Alexander Marinov + - Manoj Kumar + - shkkmo + - Dan Abrey + - Emil Santi (emilius) + - Dean Clatworthy + - timglabisch + - yoye + - Edym Komlan BEDY (youngmustes) + - ArlingtonHouse + - Eduardo Gulias Davis + - Ali Arfeen + - kevin + - Arvydas K + - Calin Pristavu (calinpristavu) + - Maxime Nicole + - aziz benmallouk (aziz403) + - Andrius Ulinskas (andriusulins) + - David Zuelke (dzuelke) + - Brooks Van Buren (brooksvb) + - Michał (mleczakm) + - Tomas Nemeikšis (niumis) + - tamir van-spier (tamirvs) + - Travis Carden + - Valyaev Ilya (rumours86) + - Przemek Maszczynski + - Björn Fromme (bjo3rn) + - Pascal de Vink (pascaldevink) + - Moroine Bentefrit + - Markus Mauksch + - Dylan Delobel (dylandelobel) + - ubick + - Aurélien Morvan + - Daniel Karp + - Hyunmin Kim (kigguhholic) + - Marc Verney + - Thibault Gattolliat (crovitche) + - Cyril Lussiana + - Aurelijus Banelis (aurelijusb) + - Claudio Galdiolo + - Valentin GARET (vgaret) + - Guillermo Quinteros (guquinteros) + - Quentin Stoeckel (chteuchteu) + - Hugo Clergue + - Kevin Robatel (kevinrob) + - Janosch Oltmanns (janosch_oltmanns) + - Andrei Karpilin (karpilin) + - Kolyunya (kolyunya) + - Max R (maxr) + - PHAS Developer + - Cyril Krylatov + - Florent Destremau + - Marc Neuhaus (mneuhaus) + - Anton + - Arc Tod + - Clorr + - DanielEScherzer + - Exalyon + - Mikhail Kamarouski + - dpfaffenbauer + - Cristi Contiu (cristi-contiu) + - Tim + - Andy Truong + - pfleu + - Ivan Ternovtsiy + - Simon Daigre (simondgre) + - Matheo D + - Andy Dawson + - Rémi T'JAMPENS (tjamps) + - Danny van Wijk (dannyvw) + - Ellis Benjamin + - Jan Dorsman + - Nicolas Rigaud + - Adam + - matthieu88160 + - rklaver + - Daniel Haaker (dhaaker) + - burki94 + - Alexey Samara + - gong023 + - xaav + - Jay-Way + - lucbu + - Jordan Bradford + - Hocdoc + - Niklas Grießer + - Cullen Walsh + - Salavat Sitdikov (sitsalavat) + - Vincent Amstoutz + - Olena Kirichok + - Matthias Gutjahr (mattsches) + - Simon Appelt + - Thibault Miscoria (tmiscoria) + - Nik Spijkerman + - Florian VANHECKE + - Zombaya + - Zenobius + - adreeun + - Mark Fischer, Jr + - bram vogelaar (attachmentgenie) + - ThamiSadouk + - M E (ttc) + - Yassine Fikri (yassinefikri) + - Younes OUASSI (youassi) + - Chris8934 + - Quentin Thiaucourt (quentint) + - homersimpsons + - Benjamin Toussaint + - anton + - Tony Cosentino + - Kostya + - alexchuin + - Szyszewski + - Nils Silbernagel diff --git a/README.md b/README.md index d63c544916613..2ca0bfbb35f6f 100644 --- a/README.md +++ b/README.md @@ -17,20 +17,13 @@ Installation Sponsor ------- -Symfony 7.2 is [backed][27] by -- [Sulu][29] -- [Rector][30] +Symfony 7.3 is [backed][27] by +- [Les-Tilleuls.coop][29] -**Sulu** is the CMS for Symfony developers. It provides pre-built content-management -features while giving developers the freedom to build, deploy, and maintain custom -solutions using full-stack Symfony. Sulu is ideal for creating complex websites, -integrating external tools, and building custom-built solutions. - -**Rector** helps successful and growing companies to get the most of the code -they already have. Including upgrading to the latest Symfony LTS. They deliver -automated refactoring, reduce maintenance costs, speed up feature delivery, and -transform legacy code into a strategic asset. They can handle the dirty work, -so you can focus on the features. +**Les-Tilleuls.coop** is a team of 70+ Symfony experts who can help you design, develop and +fix your projects. They provide a wide range of professional services including development, +consulting, coaching, training and audits. They also are highly skilled in JS, Go and DevOps. +They are a worker cooperative! Help Symfony by [sponsoring][28] its development! @@ -96,5 +89,4 @@ and supported by [Symfony contributors][19]. [26]: https://symfony.com/book [27]: https://symfony.com/backers [28]: https://symfony.com/sponsor -[29]: https://sulu.io -[30]: https://getrector.com +[29]: https://les-tilleuls.coop diff --git a/UPGRADE-7.3.md b/UPGRADE-7.3.md index 3374fe253d464..5fa4d18677279 100644 --- a/UPGRADE-7.3.md +++ b/UPGRADE-7.3.md @@ -8,25 +8,186 @@ Read more about this in the [Symfony documentation](https://symfony.com/doc/7.3/ If you're upgrading from a version below 7.2, follow the [7.2 upgrade guide](UPGRADE-7.2.md) first. +Table of Contents +----------------- + +Bundles + + * [FrameworkBundle](#FrameworkBundle) + * [SecurityBundle](#SecurityBundle) + * [WebProfilerBundle](#WebProfilerBundle) + +Bridges + + * [DoctrineBridge](#DoctrineBridge) + +Components + + * [AssetMapper](#AssetMapper) + * [Console](#Console) + * [DependencyInjection](#DependencyInjection) + * [HttpFoundation](#HttpFoundation) + * [Ldap](#Ldap) + * [OptionsResolver](#OptionsResolver) + * [PropertyInfo](#PropertyInfo) + * [Security](#Security) + * [Notifier](#Notifier) + * [Serializer](#Serializer) + * [TypeInfo](#TypeInfo) + * [Validator](#Validator) + * [VarDumper](#VarDumper) + * [VarExporter](#VarExporter) + * [Workflow](#Workflow) + +AssetMapper +----------- + + * `ImportMapRequireCommand` now takes `projectDir` as a required third constructor argument + +Console +------- + + * Omitting parameter types or returning a non-integer value from a `\Closure` set via `Command::setCode()` method is deprecated + + Before: + + ```php + $command->setCode(function ($input, $output) { + // ... + }); + ``` + + After: + + ```php + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + + $command->setCode(function (InputInterface $input, OutputInterface $output): int { + // ... + + return 0; + }); + ``` + + * Deprecate methods `Command::getDefaultName()` and `Command::getDefaultDescription()` in favor of the `#[AsCommand]` attribute + * `#[AsCommand]` attribute is now marked as `@final`; you should use separate attributes to add more logic to commands + +DependencyInjection +------------------- + + * Deprecate `ContainerBuilder::getAutoconfiguredAttributes()` in favor of the `getAttributeAutoconfigurators()` method. + +DoctrineBridge +-------------- + + * Deprecate the `DoctrineExtractor::getTypes()` method, use `DoctrineExtractor::getType()` instead + +FrameworkBundle +--------------- + + * Not setting the `framework.property_info.with_constructor_extractor` option explicitly is deprecated + because its default value will change in version 8.0 + * Deprecate the `--show-arguments` option of the `container:debug` command, as arguments are now always shown + * Deprecate the `framework.validation.cache` config option + * Deprecate the `RateLimiterFactory` autowiring aliases, use `RateLimiterFactoryInterface` instead + * Deprecate setting the `framework.profiler.collect_serializer_data` config option to `false` + + When set to `true`, normalizers must be injected using the `NormalizerInterface`, and not using any concrete implementation. + + Before: + + ```php + public function __construct(ObjectNormalizer $normalizer) {} + ``` + + After: + + ```php + public function __construct(#[Autowire('@serializer.normalizer.object')] NormalizerInterface $normalizer) {} + ``` + + * The XML routing configuration files (`errors.xml` and `webhook.xml`) are + deprecated, use their PHP equivalent ones: + + Before: + + ```yaml + when@dev: + _errors: + resource: '@FrameworkBundle/Resources/config/routing/errors.xml' + prefix: /_error + + webhook: + resource: '@FrameworkBundle/Resources/config/routing/webhook.xml' + prefix: /webhook + ``` + + After: + + ```yaml + when@dev: + _errors: + resource: '@FrameworkBundle/Resources/config/routing/errors.php' + prefix: /_error + + webhook: + resource: '@FrameworkBundle/Resources/config/routing/webhook.php' + prefix: /webhook + ``` + +HttpFoundation +-------------- + + * `Request::getPreferredLanguage()` now favors a more preferred language above exactly matching a locale + Ldap ---- * Deprecate `LdapUser::eraseCredentials()` in favor of `__serialize()` +OptionsResolver +--------------- + + * Deprecate defining nested options via `setDefault()`, use `setOptions()` instead + + *Before* + ```php + $resolver->setDefault('option', function (OptionsResolver $resolver) { + // ... + }); + ``` + + *After* + ```php + $resolver->setOptions('option', function (OptionsResolver $resolver) { + // ... + }); + ``` + +PropertyInfo +------------ + + * Deprecate the `Type` class, use `Symfony\Component\TypeInfo\Type` class from `symfony/type-info` instead + * Deprecate the `PropertyTypeExtractorInterface::getTypes()` method, use `PropertyTypeExtractorInterface::getType()` instead + * Deprecate the `ConstructorArgumentTypeExtractorInterface::getTypesFromConstructor()` method, use `ConstructorArgumentTypeExtractorInterface::getTypeFromConstructor()` instead + Security -------- - * Deprecate `UserInterface::eraseCredentials()` and `TokenInterface::eraseCredentials()`, + * Deprecate `UserInterface::eraseCredentials()` and `TokenInterface::eraseCredentials()`; erase credentials e.g. using `__serialize()` instead - *Before* + Before: + ```php public function eraseCredentials(): void { } ``` - *After* + After: + ```php #[\Deprecated] public function eraseCredentials(): void @@ -43,48 +204,42 @@ Security } ``` -Console -------- - - * Omitting parameter types in callables configured via `Command::setCode` method is deprecated - - *Before* - ```php - $command->setCode(function ($input, $output) { - // ... - }); - ``` + * Add argument `$vote` to `VoterInterface::vote()` and to `Voter::voteOnAttribute()`; + it should be used to report the reason of a vote. E.g: - *After* ```php - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - - $command->setCode(function (InputInterface $input, OutputInterface $output) { - // ... - }); + protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token, ?Vote $vote = null): bool + { + $vote?->addReason('A brief explanation of why access is granted or denied, as appropriate.'); + } ``` - * Deprecate methods `Command::getDefaultName()` and `Command::getDefaultDescription()` in favor of the `#[AsCommand]` attribute - -FrameworkBundle ---------------- - - * Not setting the `framework.property_info.with_constructor_extractor` option explicitly is deprecated - because its default value will change in version 8.0 - * Deprecate the `--show-arguments` option of the `container:debug` command, as arguments are now always shown + * Add argument `$accessDecision` to `AccessDecisionManagerInterface::decide()` and `AuthorizationCheckerInterface::isGranted()`; + it should be used to report the reason of a decision, including all the related votes. + * Add discovery support to `OidcTokenHandler` and `OidcUserInfoTokenHandler` SecurityBundle -------------- * Deprecate the `security.hide_user_not_found` config option in favor of `security.expose_security_errors` +Notifier +-------- + + * Deprecate the `Sms77` transport, use `SevenIo` instead + Serializer ---------- * Deprecate the `CompiledClassMetadataFactory` and `CompiledClassMetadataCacheWarmer` classes +TypeInfo +-------- + + * Deprecate constructing a `CollectionType` instance as a list that is not an array + * Deprecate the third `$asList` argument of `TypeFactoryTrait::iterable()`, use `TypeFactoryTrait::list()` instead + Validator --------- @@ -119,6 +274,7 @@ Validator } } ``` + * Deprecate passing an array of options to the constructors of the constraint classes, pass each option as a dedicated argument instead Before: @@ -139,14 +295,122 @@ Validator ) ``` -TypeInfo --------- - - * Deprecate constructing a `CollectionType` instance as a list that is not an array - * Deprecate the third `$asList` argument of `TypeFactoryTrait::iterable()`, use `TypeFactoryTrait::list()` instead - VarDumper --------- * Deprecate `ResourceCaster::castCurl()`, `ResourceCaster::castGd()` and `ResourceCaster::castOpensslX509()` * Mark all casters as `@internal` + +VarExporter +----------- + + * Deprecate using `ProxyHelper::generateLazyProxy()` when native lazy proxies can be used - the method should be used to generate abstraction-based lazy decorators only + * Deprecate `LazyGhostTrait` and `LazyProxyTrait`, use native lazy objects instead + * Deprecate `ProxyHelper::generateLazyGhost()`, use native lazy objects instead + +WebProfilerBundle +----------------- + + * The XML routing configuration files (`profiler.xml` and `wdt.xml`) are + deprecated, use their PHP equivalent ones: + + Before: + + ```yaml + when@dev: + web_profiler_wdt: + resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml' + prefix: /_wdt + + web_profiler_profiler: + resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml' + prefix: /_profiler + ``` + + After: + + ```yaml + when@dev: + web_profiler_wdt: + resource: '@WebProfilerBundle/Resources/config/routing/wdt.php' + prefix: /_wdt + + web_profiler_profiler: + resource: '@WebProfilerBundle/Resources/config/routing/profiler.php + prefix: /_profiler + ``` + +Workflow +-------- + + * Deprecate `Event::getWorkflow()` method + + Before: + + ```php + use Symfony\Component\Workflow\Attribute\AsCompletedListener; + use Symfony\Component\Workflow\Event\CompletedEvent; + + class MyListener + { + #[AsCompletedListener('my_workflow', 'to_state2')] + public function terminateOrder(CompletedEvent $event): void + { + $subject = $event->getSubject(); + if ($event->getWorkflow()->can($subject, 'to_state3')) { + $event->getWorkflow()->apply($subject, 'to_state3'); + } + } + } + ``` + + After: + + ```php + use Symfony\Component\DependencyInjection\Attribute\Target; + use Symfony\Component\Workflow\Attribute\AsCompletedListener; + use Symfony\Component\Workflow\Event\CompletedEvent; + use Symfony\Component\Workflow\WorkflowInterface; + + class MyListener + { + public function __construct( + #[Target('your_workflow_name')] + private readonly WorkflowInterface $workflow, + ) { + } + + #[AsCompletedListener('your_workflow_name', 'to_state2')] + public function terminateOrder(CompletedEvent $event): void + { + $subject = $event->getSubject(); + if ($this->workflow->can($subject, 'to_state3')) { + $this->workflow->apply($subject, 'to_state3'); + } + } + } + ``` + + Or: + + ```php + use Symfony\Component\DependencyInjection\ServiceLocator; + use Symfony\Component\DependencyInjection\Attribute\AutowireLocator; + use Symfony\Component\Workflow\Attribute\AsTransitionListener; + use Symfony\Component\Workflow\Event\TransitionEvent; + + class GenericListener + { + public function __construct( + #[AutowireLocator('workflow', 'name')] + private ServiceLocator $workflows + ) { + } + + #[AsTransitionListener()] + public function doSomething(TransitionEvent $event): void + { + $workflow = $this->workflows->get($event->getWorkflowName()); + } + } + ``` diff --git a/composer.json b/composer.json index 263117fc8ddc4..20bcb49c4b782 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "psr/http-message": "^1.0|^2.0", "psr/link": "^1.1|^2.0", "psr/log": "^1|^2|^3", - "symfony/contracts": "^3.5", + "symfony/contracts": "^3.6", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-icu": "~1.0", @@ -83,7 +83,8 @@ "symfony/http-foundation": "self.version", "symfony/http-kernel": "self.version", "symfony/intl": "self.version", - "symfony/json-encoder": "self.version", + "symfony/json-path": "self.version", + "symfony/json-streamer": "self.version", "symfony/ldap": "self.version", "symfony/lock": "self.version", "symfony/mailer": "self.version", @@ -91,6 +92,7 @@ "symfony/mime": "self.version", "symfony/monolog-bridge": "self.version", "symfony/notifier": "self.version", + "symfony/object-mapper": "self.version", "symfony/options-resolver": "self.version", "symfony/password-hasher": "self.version", "symfony/process": "self.version", @@ -141,9 +143,9 @@ "league/uri": "^6.5|^7.0", "masterminds/html5": "^2.7.2", "monolog/monolog": "^3.0", - "nikic/php-parser": "^4.18|^5.0", + "nikic/php-parser": "^5.0", "nyholm/psr7": "^1.0", - "pda/pheanstalk": "^4.0", + "pda/pheanstalk": "^5.1|^7.0", "php-http/discovery": "^1.15", "php-http/httplug": "^1.0|^2.0", "phpdocumentor/reflection-docblock": "^5.2", @@ -157,9 +159,10 @@ "symfony/phpunit-bridge": "^6.4|^7.0", "symfony/runtime": "self.version", "symfony/security-acl": "~2.8|~3.0", - "twig/cssinliner-extra": "^2.12|^3", - "twig/inky-extra": "^2.12|^3", - "twig/markdown-extra": "^2.12|^3", + "symfony/webpack-encore-bundle": "^1.0|^2.0", + "twig/cssinliner-extra": "^3", + "twig/inky-extra": "^3", + "twig/markdown-extra": "^3", "web-token/jwt-library": "^3.3.2|^4.0" }, "conflict": { @@ -217,7 +220,7 @@ "url": "src/Symfony/Contracts", "options": { "versions": { - "symfony/contracts": "3.5.x-dev" + "symfony/contracts": "3.6.x-dev" } } }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 6909669ee14a8..27418b4002971 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -54,7 +54,7 @@ ./src/Symfony/Bridge/*/Tests ./src/Symfony/Component/*/Tests ./src/Symfony/Component/*/*/Tests - ./src/Symfony/Contract/*/Tests + ./src/Symfony/Contracts/*/Tests ./src/Symfony/Bundle/*/Tests ./src/Symfony/Bundle/*/Resources ./src/Symfony/Component/*/Resources diff --git a/psalm.xml b/psalm.xml index 54c7cb03e6c4b..a3dd6b8d5e191 100644 --- a/psalm.xml +++ b/psalm.xml @@ -10,6 +10,7 @@ findUnusedBaselineEntry="false" findUnusedCode="false" findUnusedIssueHandlerSuppression="false" + ensureOverrideAttribute="false" > diff --git a/src/Symfony/Bridge/Doctrine/ArgumentResolver/EntityValueResolver.php b/src/Symfony/Bridge/Doctrine/ArgumentResolver/EntityValueResolver.php index 7ddf3e72186d6..3e0b946d688e8 100644 --- a/src/Symfony/Bridge/Doctrine/ArgumentResolver/EntityValueResolver.php +++ b/src/Symfony/Bridge/Doctrine/ArgumentResolver/EntityValueResolver.php @@ -21,6 +21,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; +use Symfony\Component\HttpKernel\Exception\NearMissValueResolverException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** @@ -35,6 +36,8 @@ public function __construct( private ManagerRegistry $registry, private ?ExpressionLanguage $expressionLanguage = null, private MapEntity $defaults = new MapEntity(), + /** @var array */ + private readonly array $typeAliases = [], ) { } @@ -50,6 +53,9 @@ public function resolve(Request $request, ArgumentMetadata $argument): array if (!$options->class || $options->disabled) { return []; } + + $options->class = $this->typeAliases[$options->class] ?? $options->class; + if (!$manager = $this->getManager($options->objectManager, $options->class)) { return []; } @@ -63,7 +69,11 @@ public function resolve(Request $request, ArgumentMetadata $argument): array } elseif (false === $object = $this->find($manager, $request, $options, $argument)) { // find by criteria if (!$criteria = $this->getCriteria($request, $options, $manager, $argument)) { - return []; + if (!class_exists(NearMissValueResolverException::class)) { + return []; + } + + throw new NearMissValueResolverException(\sprintf('Cannot find mapping for "%s": declare one using either the #[MapEntity] attribute or mapped route parameters.', $options->class)); } try { $object = $manager->getRepository($options->class)->findOneBy($criteria); @@ -180,7 +190,7 @@ private function getCriteria(Request $request, MapEntity $options, ObjectManager return $criteria; } elseif (null === $mapping) { - trigger_deprecation('symfony/doctrine-bridge', '7.1', 'Relying on auto-mapping for Doctrine entities is deprecated for argument $%s of "%s": declare the identifier using either the #[MapEntity] attribute or mapped route parameters.', $argument->getName(), method_exists($argument, 'getControllerName') ? $argument->getControllerName() : 'n/a'); + trigger_deprecation('symfony/doctrine-bridge', '7.1', 'Relying on auto-mapping for Doctrine entities is deprecated for argument $%s of "%s": declare the mapping using either the #[MapEntity] attribute or mapped route parameters.', $argument->getName(), method_exists($argument, 'getControllerName') ? $argument->getControllerName() : 'n/a'); $mapping = $request->attributes->keys(); } diff --git a/src/Symfony/Bridge/Doctrine/Attribute/MapEntity.php b/src/Symfony/Bridge/Doctrine/Attribute/MapEntity.php index 73d73d58b23bb..c9d07ed389244 100644 --- a/src/Symfony/Bridge/Doctrine/Attribute/MapEntity.php +++ b/src/Symfony/Bridge/Doctrine/Attribute/MapEntity.php @@ -53,7 +53,7 @@ public function __construct( public function withDefaults(self $defaults, ?string $class): static { $clone = clone $this; - $clone->class ??= class_exists($class ?? '') ? $class : null; + $clone->class ??= class_exists($class ?? '') || interface_exists($class ?? '', false) ? $class : null; $clone->objectManager ??= $defaults->objectManager; $clone->expr ??= $defaults->expr; $clone->mapping ??= $defaults->mapping; diff --git a/src/Symfony/Bridge/Doctrine/CHANGELOG.md b/src/Symfony/Bridge/Doctrine/CHANGELOG.md index f1133dfefe9a6..961a0965d3431 100644 --- a/src/Symfony/Bridge/Doctrine/CHANGELOG.md +++ b/src/Symfony/Bridge/Doctrine/CHANGELOG.md @@ -1,6 +1,15 @@ CHANGELOG ========= +7.3 +--- + + * Reset the manager registry using native lazy objects when applicable + * Deprecate the `DoctrineExtractor::getTypes()` method, use `DoctrineExtractor::getType()` instead + * Add support for `Symfony\Component\Clock\DatePoint` as `DatePointType` Doctrine type + * Improve exception message when `EntityValueResolver` gets no mapping information + * Add type aliases support to `EntityValueResolver` + 7.2 --- diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php index 51118c6dfafa2..83d8a85aed96d 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php @@ -301,6 +301,7 @@ protected function loadCacheDriver(string $cacheName, string $objectManagerName, $cacheDef->addMethodCall('setMemcached', [new Reference($this->getObjectManagerElementName(\sprintf('%s_memcached_instance', $objectManagerName)))]); break; case 'redis': + case 'valkey': $redisClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.redis.class').'%'; $redisInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%'.$this->getObjectManagerElementName('cache.redis_instance.class').'%'; $redisHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%'.$this->getObjectManagerElementName('cache.redis_host').'%'; diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterDatePointTypePass.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterDatePointTypePass.php new file mode 100644 index 0000000000000..68474d94f2048 --- /dev/null +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterDatePointTypePass.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass; + +use Symfony\Bridge\Doctrine\Types\DatePointType; +use Symfony\Component\Clock\DatePoint; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; + +final class RegisterDatePointTypePass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container): void + { + if (!class_exists(DatePoint::class)) { + return; + } + + if (!$container->hasParameter('doctrine.dbal.connection_factory.types')) { + return; + } + + $types = $container->getParameter('doctrine.dbal.connection_factory.types'); + + $types['date_point'] ??= ['class' => DatePointType::class]; + + $container->setParameter('doctrine.dbal.connection_factory.types', $types); + } +} diff --git a/src/Symfony/Bridge/Doctrine/ManagerRegistry.php b/src/Symfony/Bridge/Doctrine/ManagerRegistry.php index 6a2c7a59542ef..fa4d88b99455d 100644 --- a/src/Symfony/Bridge/Doctrine/ManagerRegistry.php +++ b/src/Symfony/Bridge/Doctrine/ManagerRegistry.php @@ -45,31 +45,76 @@ protected function resetService($name): void return; } - if (!$manager instanceof LazyLoadingInterface) { - throw new \LogicException(\sprintf('Resetting a non-lazy manager service is not supported. Declare the "%s" service as lazy.', $name)); + if (\PHP_VERSION_ID < 80400) { + if (!$manager instanceof LazyLoadingInterface) { + throw new \LogicException(\sprintf('Resetting a non-lazy manager service is not supported. Declare the "%s" service as lazy.', $name)); + } + trigger_deprecation('symfony/doctrine-bridge', '7.3', 'Support for proxy-manager is deprecated.'); + + if ($manager instanceof GhostObjectInterface) { + throw new \LogicException('Resetting a lazy-ghost-object manager service is not supported.'); + } + $manager->setProxyInitializer(\Closure::bind( + function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) { + $name = $this->aliases[$name] ?? $name; + $wrappedInstance = match (true) { + isset($this->fileMap[$name]) => $this->load($this->fileMap[$name], false), + !$method = $this->methodMap[$name] ?? null => throw new \LogicException(\sprintf('The "%s" service is synthetic and cannot be reset.', $name)), + (new \ReflectionMethod($this, $method))->isStatic() => $this->{$method}($this, false), + default => $this->{$method}(false), + }; + $manager->setProxyInitializer(null); + + return true; + }, + $this->container, + Container::class + )); + + return; } - if ($manager instanceof GhostObjectInterface) { - throw new \LogicException('Resetting a lazy-ghost-object manager service is not supported.'); + + $r = new \ReflectionClass($manager); + + if ($r->isUninitializedLazyObject($manager)) { + return; } - $manager->setProxyInitializer(\Closure::bind( - function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) { - if (isset($this->aliases[$name])) { - $name = $this->aliases[$name]; - } - if (isset($this->fileMap[$name])) { - $wrappedInstance = $this->load($this->fileMap[$name], false); - } elseif ((new \ReflectionMethod($this, $this->methodMap[$name]))->isStatic()) { - $wrappedInstance = $this->{$this->methodMap[$name]}($this, false); - } else { - $wrappedInstance = $this->{$this->methodMap[$name]}(false); + + $asProxy = $r->initializeLazyObject($manager) !== $manager; + $initializer = \Closure::bind( + function ($manager) use ($name, $asProxy) { + $name = $this->aliases[$name] ?? $name; + if ($asProxy) { + $manager = false; } - $manager->setProxyInitializer(null); + $manager = match (true) { + isset($this->fileMap[$name]) => $this->load($this->fileMap[$name], $manager), + !$method = $this->methodMap[$name] ?? null => throw new \LogicException(\sprintf('The "%s" service is synthetic and cannot be reset.', $name)), + (new \ReflectionMethod($this, $method))->isStatic() => $this->{$method}($this, $manager), + default => $this->{$method}($manager), + }; - return true; + if ($asProxy) { + return $manager; + } }, $this->container, Container::class - )); + ); + + try { + if ($asProxy) { + $r->resetAsLazyProxy($manager, $initializer); + } else { + $r->resetAsLazyGhost($manager, $initializer); + } + } catch (\Error $e) { + if (__FILE__ !== $e->getFile()) { + throw $e; + } + + throw new \LogicException(\sprintf('Resetting a non-lazy manager service is not supported. Declare the "%s" service as lazy.', $name), 0, $e); + } } } diff --git a/src/Symfony/Bridge/Doctrine/Middleware/Debug/Driver.php b/src/Symfony/Bridge/Doctrine/Middleware/Debug/Driver.php index ea1ecfbd60b05..b6de4be534f7f 100644 --- a/src/Symfony/Bridge/Doctrine/Middleware/Debug/Driver.php +++ b/src/Symfony/Bridge/Doctrine/Middleware/Debug/Driver.php @@ -36,7 +36,7 @@ public function connect(array $params): ConnectionInterface { $connection = parent::connect($params); - if ('void' !== (string) (new \ReflectionMethod(DriverInterface\Connection::class, 'commit'))->getReturnType()) { + if ('void' !== (string) (new \ReflectionMethod(ConnectionInterface::class, 'commit'))->getReturnType()) { return new DBAL3\Connection( $connection, $this->debugDataHolder, diff --git a/src/Symfony/Bridge/Doctrine/Middleware/IdleConnection/Listener.php b/src/Symfony/Bridge/Doctrine/Middleware/IdleConnection/Listener.php index 11f7053c5f702..ad570821d7c76 100644 --- a/src/Symfony/Bridge/Doctrine/Middleware/IdleConnection/Listener.php +++ b/src/Symfony/Bridge/Doctrine/Middleware/IdleConnection/Listener.php @@ -14,6 +14,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\RequestEvent; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; final class Listener implements EventSubscriberInterface @@ -29,6 +30,9 @@ public function __construct( public function onKernelRequest(RequestEvent $event): void { + if (HttpKernelInterface::MAIN_REQUEST !== $event->getRequestType()) { + return; + } $timestamp = time(); foreach ($this->connectionExpiries as $name => $expiry) { diff --git a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php index 478fbfbe8e251..050b84acece96 100644 --- a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php +++ b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php @@ -161,8 +161,13 @@ public function getType(string $class, string $property, array $context = []): ? }; } + /** + * @deprecated since Symfony 7.3, use "getType" instead + */ public function getTypes(string $class, string $property, array $context = []): ?array { + trigger_deprecation('symfony/property-info', '7.3', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class); + if (null === $metadata = $this->getMetadata($class)) { return null; } diff --git a/src/Symfony/Bridge/Doctrine/SchemaListener/AbstractSchemaListener.php b/src/Symfony/Bridge/Doctrine/SchemaListener/AbstractSchemaListener.php index 6f3410313d00a..cfe07b37da493 100644 --- a/src/Symfony/Bridge/Doctrine/SchemaListener/AbstractSchemaListener.php +++ b/src/Symfony/Bridge/Doctrine/SchemaListener/AbstractSchemaListener.php @@ -13,6 +13,9 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Exception\TableNotFoundException; +use Doctrine\DBAL\Schema\Name\Identifier; +use Doctrine\DBAL\Schema\Name\UnqualifiedName; +use Doctrine\DBAL\Schema\PrimaryKeyConstraint; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs; @@ -30,7 +33,12 @@ protected function getIsSameDatabaseChecker(Connection $connection): \Closure $table->addColumn('id', Types::INTEGER) ->setAutoincrement(true) ->setNotnull(true); - $table->setPrimaryKey(['id']); + + if (class_exists(PrimaryKeyConstraint::class)) { + $table->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted('id'))], true)); + } else { + $table->setPrimaryKey(['id']); + } $schemaManager->createTable($table); diff --git a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php index 00c9e0d49e8cf..dd1b4b2e765b3 100644 --- a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php @@ -13,6 +13,9 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\ParameterType; +use Doctrine\DBAL\Schema\Name\Identifier; +use Doctrine\DBAL\Schema\Name\UnqualifiedName; +use Doctrine\DBAL\Schema\PrimaryKeyConstraint; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Types\Types; use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken; @@ -194,6 +197,11 @@ private function addTableToSchema(Schema $schema): void $table->addColumn('lastUsed', Types::DATETIME_IMMUTABLE); $table->addColumn('class', Types::STRING, ['length' => 100]); $table->addColumn('username', Types::STRING, ['length' => 200]); - $table->setPrimaryKey(['series']); + + if (class_exists(PrimaryKeyConstraint::class)) { + $table->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted('series'))], true)); + } else { + $table->setPrimaryKey(['series']); + } } } diff --git a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php index c6ddb921f1e21..78b962dfdbcae 100644 --- a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php @@ -100,6 +100,8 @@ public function refreshUser(UserInterface $user): UserInterface if ($refreshedUser instanceof Proxy && !$refreshedUser->__isInitialized()) { $refreshedUser->__load(); + } elseif (\PHP_VERSION_ID >= 80400 && ($r = new \ReflectionClass($refreshedUser))->isUninitializedLazyObject($refreshedUser)) { + $r->initializeLazyObject($refreshedUser); } return $refreshedUser; diff --git a/src/Symfony/Bridge/Doctrine/Tests/ArgumentResolver/EntityValueResolverTest.php b/src/Symfony/Bridge/Doctrine/Tests/ArgumentResolver/EntityValueResolverTest.php index 57195d8bad557..8207317803857 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/ArgumentResolver/EntityValueResolverTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/ArgumentResolver/EntityValueResolverTest.php @@ -24,6 +24,7 @@ use Symfony\Component\ExpressionLanguage\SyntaxError; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; +use Symfony\Component\HttpKernel\Exception\NearMissValueResolverException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class EntityValueResolverTest extends TestCase @@ -75,6 +76,11 @@ public function testResolveWithNoIdAndDataOptional() $request = new Request(); $argument = $this->createArgument(null, new MapEntity(), 'arg', true); + if (class_exists(NearMissValueResolverException::class)) { + $this->expectException(NearMissValueResolverException::class); + $this->expectExceptionMessage('Cannot find mapping for "stdClass": declare one using either the #[MapEntity] attribute or mapped route parameters.'); + } + $this->assertSame([], $resolver->resolve($request, $argument)); } @@ -94,6 +100,11 @@ public function testResolveWithStripNulls() $manager->expects($this->never()) ->method('getRepository'); + if (class_exists(NearMissValueResolverException::class)) { + $this->expectException(NearMissValueResolverException::class); + $this->expectExceptionMessage('Cannot find mapping for "stdClass": declare one using either the #[MapEntity] attribute or mapped route parameters.'); + } + $this->assertSame([], $resolver->resolve($request, $argument)); } @@ -125,6 +136,42 @@ public function testResolveWithId(string|int $id) $this->assertSame([$object], $resolver->resolve($request, $argument)); } + /** + * @dataProvider idsProvider + */ + public function testResolveWithIdAndTypeAlias(string|int $id) + { + $manager = $this->getMockBuilder(ObjectManager::class)->getMock(); + $registry = $this->createRegistry($manager); + $resolver = new EntityValueResolver( + $registry, + null, + new MapEntity(), + // Using \Throwable because it is an interface + ['Throwable' => 'stdClass'], + ); + + $request = new Request(); + $request->attributes->set('id', $id); + + $argument = $this->createArgument('Throwable', $mapEntity = new MapEntity(id: 'id')); + + $repository = $this->getMockBuilder(ObjectRepository::class)->getMock(); + $repository->expects($this->once()) + ->method('find') + ->with($id) + ->willReturn($object = new \stdClass()); + + $manager->expects($this->once()) + ->method('getRepository') + ->with('stdClass') + ->willReturn($repository); + + $this->assertSame([$object], $resolver->resolve($request, $argument)); + // Ensure the original MapEntity object was not updated + $this->assertNull($mapEntity->class); + } + public function testResolveWithNullId() { $manager = $this->createMock(ObjectManager::class); @@ -226,6 +273,11 @@ public function testResolveGuessOptional() $manager->expects($this->never())->method('getRepository'); + if (class_exists(NearMissValueResolverException::class)) { + $this->expectException(NearMissValueResolverException::class); + $this->expectExceptionMessage('Cannot find mapping for "stdClass": declare one using either the #[MapEntity] attribute or mapped route parameters.'); + } + $this->assertSame([], $resolver->resolve($request, $argument)); } @@ -494,7 +546,6 @@ private function createRegistry(?ObjectManager $manager = null): ManagerRegistry $registry->method('getManager')->willReturn($manager); } - return $registry; } } diff --git a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php index d41dd096a44c8..b64a1cc4475c6 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php @@ -246,7 +246,7 @@ private function createCollector(array $queries): DoctrineDataCollector ->getMock(); $connection->expects($this->any()) ->method('getDatabasePlatform') - ->willReturn(new MySqlPlatform()); + ->willReturn(new MySQLPlatform()); $registry = $this->createMock(ManagerRegistry::class); $registry diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterDatePointTypePassTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterDatePointTypePassTest.php new file mode 100644 index 0000000000000..3ded48d86cdd3 --- /dev/null +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterDatePointTypePassTest.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Doctrine\Tests\DependencyInjection\CompilerPass; + +use PHPUnit\Framework\TestCase; +use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterDatePointTypePass; +use Symfony\Bridge\Doctrine\Types\DatePointType; +use Symfony\Component\Clock\DatePoint; +use Symfony\Component\DependencyInjection\ContainerBuilder; + +class RegisterDatePointTypePassTest extends TestCase +{ + protected function setUp(): void + { + if (!class_exists(DatePoint::class)) { + self::markTestSkipped('The DatePoint class is not available.'); + } + } + + public function testRegistered() + { + $container = new ContainerBuilder(); + $container->setParameter('doctrine.dbal.connection_factory.types', ['foo' => 'bar']); + (new RegisterDatePointTypePass())->process($container); + + $expected = [ + 'foo' => 'bar', + 'date_point' => ['class' => DatePointType::class], + ]; + $this->assertSame($expected, $container->getParameter('doctrine.dbal.connection_factory.types')); + } +} diff --git a/src/Symfony/Bridge/Doctrine/Tests/DoctrineTestHelper.php b/src/Symfony/Bridge/Doctrine/Tests/DoctrineTestHelper.php index e8d36c892b942..d96416b287c65 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DoctrineTestHelper.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DoctrineTestHelper.php @@ -47,6 +47,10 @@ public static function createTestEntityManager(?Configuration $config = null): E $config ??= self::createTestConfiguration(); $eventManager = new EventManager(); + if (\PHP_VERSION_ID >= 80400 && method_exists($config, 'enableNativeLazyObjects')) { + $config->enableNativeLazyObjects(true); + } + return new EntityManager(DriverManager::getConnection($params, $config, $eventManager), $config, $eventManager); } @@ -54,9 +58,11 @@ public static function createTestConfiguration(): Configuration { $config = ORMSetup::createConfiguration(true); $config->setEntityNamespaces(['SymfonyTestsDoctrine' => 'Symfony\Bridge\Doctrine\Tests\Fixtures']); - $config->setAutoGenerateProxyClasses(true); - $config->setProxyDir(sys_get_temp_dir()); - $config->setProxyNamespace('SymfonyTests\Doctrine'); + if (\PHP_VERSION_ID < 80400 || !method_exists($config, 'enableNativeLazyObjects')) { + $config->setAutoGenerateProxyClasses(true); + $config->setProxyDir(sys_get_temp_dir()); + $config->setProxyNamespace('SymfonyTests\Doctrine'); + } $config->setMetadataDriverImpl(new AttributeDriver([__DIR__.'/../Tests/Fixtures' => 'Symfony\Bridge\Doctrine\Tests\Fixtures'], true)); $config->setSchemaManagerFactory(new DefaultSchemaManagerFactory()); $config->setLazyGhostObjectEnabled(true); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DummyManager.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DummyManager.php index 04e5a2acdd334..806ef032d8d5c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DummyManager.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DummyManager.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\Persistence\Mapping\ClassMetadata; @@ -11,6 +20,10 @@ class DummyManager implements ObjectManager { public $bar; + public function __construct() + { + } + public function find($className, $id): ?object { } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleAssociationToIntIdEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleAssociationToIntIdEntity.php index 94becf73b5795..0373417b2c8bb 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleAssociationToIntIdEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleAssociationToIntIdEntity.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\OneToOne; #[Entity] @@ -21,6 +22,7 @@ class SingleAssociationToIntIdEntity { public function __construct( #[Id, OneToOne(cascade: ['ALL'])] + #[JoinColumn(nullable: false)] protected SingleIntIdNoToStringEntity $entity, #[Column(nullable: true)] diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntity.php index 0970dea0669a9..3cebe3fe6e0a9 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntity.php @@ -16,7 +16,7 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; -#[Entity] +#[Entity(repositoryClass: SingleIntIdEntityRepository::class)] class SingleIntIdEntity { #[Column(type: Types::JSON, nullable: true)] diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntityRepository.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntityRepository.php new file mode 100644 index 0000000000000..597f264099328 --- /dev/null +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntityRepository.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Doctrine\Tests\Fixtures; + +use Doctrine\ORM\EntityRepository; + +class SingleIntIdEntityRepository extends EntityRepository +{ + public $result = null; + + public function findByCustom() + { + return $this->result; + } +} diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/UserUuidNameDto.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/UserUuidNameDto.php new file mode 100644 index 0000000000000..8c2c60d21ba85 --- /dev/null +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/UserUuidNameDto.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Doctrine\Tests\Fixtures; + +use Symfony\Component\Uid\Uuid; + +class UserUuidNameDto +{ + public function __construct( + public ?Uuid $id, + public ?string $fullName, + public ?string $address, + ) { + } +} diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/UserUuidNameEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/UserUuidNameEntity.php new file mode 100644 index 0000000000000..3ac3ead8d201a --- /dev/null +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/UserUuidNameEntity.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Doctrine\Tests\Fixtures; + +use Doctrine\ORM\Mapping\Column; +use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\Id; +use Symfony\Component\Uid\Uuid; + +#[Entity] +class UserUuidNameEntity +{ + public function __construct( + #[Id, Column] + public ?Uuid $id = null, + #[Column(unique: true)] + public ?string $fullName = null, + ) { + } +} diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php index a121b77ce7cc5..338363d0acf74 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php @@ -74,8 +74,7 @@ public function testTransformReadableCollection() 3 => 'bar', ]; - $collection = new class($array) implements ReadableCollection - { + $collection = new class($array) implements ReadableCollection { public function __construct(private readonly array $array) { } diff --git a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php index fa44ba0a00bbb..4803e6acaf0af 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php @@ -22,7 +22,7 @@ class ManagerRegistryTest extends TestCase { - public static function setUpBeforeClass(): void + public function testResetService() { $container = new ContainerBuilder(); @@ -32,10 +32,7 @@ public static function setUpBeforeClass(): void $dumper = new PhpDumper($container); eval('?>'.$dumper->dump(['class' => 'LazyServiceDoctrineBridgeContainer'])); - } - public function testResetService() - { $container = new \LazyServiceDoctrineBridgeContainer(); $registry = new TestManagerRegistry('name', [], ['defaultManager' => 'foo'], 'defaultConnection', 'defaultManager', 'proxyInterfaceName'); @@ -52,6 +49,63 @@ public function testResetService() $this->assertFalse(isset($foo->bar)); } + /** + * @requires PHP 8.4 + * + * @dataProvider provideResetServiceWithNativeLazyObjectsCases + */ + public function testResetServiceWithNativeLazyObjects(string $class) + { + $container = new $class(); + + $registry = new TestManagerRegistry( + 'irrelevant', + [], + ['defaultManager' => 'foo'], + 'irrelevant', + 'defaultManager', + 'irrelevant', + ); + $registry->setTestContainer($container); + + $foo = $container->get('foo'); + self::assertSame(DummyManager::class, $foo::class); + + $foo->bar = 123; + self::assertTrue(isset($foo->bar)); + + $registry->resetManager(); + + self::assertSame($foo, $container->get('foo')); + self::assertSame(DummyManager::class, $foo::class); + self::assertFalse(isset($foo->bar)); + } + + public static function provideResetServiceWithNativeLazyObjectsCases(): iterable + { + $container = new ContainerBuilder(); + + $container->register('foo', DummyManager::class)->setPublic(true); + $container->getDefinition('foo')->setLazy(true); + $container->compile(); + + $dumper = new PhpDumper($container); + + eval('?>'.$dumper->dump(['class' => 'NativeLazyServiceDoctrineBridgeContainer'])); + + yield ['NativeLazyServiceDoctrineBridgeContainer']; + + $dumps = $dumper->dump(['class' => 'NativeLazyServiceDoctrineBridgeContainerAsFiles', 'as_files' => true]); + + $lastDump = array_pop($dumps); + foreach (array_reverse($dumps) as $dump) { + eval('?>'.$dump); + } + eval('?>'.$lastDump); + + yield ['NativeLazyServiceDoctrineBridgeContainerAsFiles']; + } + /** * When performing an entity manager lazy service reset, the reset operations may re-use the container * to create a "fresh" service: when doing so, it can happen that the "fresh" service is itself a proxy. diff --git a/src/Symfony/Bridge/Doctrine/Tests/Middleware/IdleConnection/ListenerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Middleware/IdleConnection/ListenerTest.php index 099ab48777133..72fa7e068f67c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Middleware/IdleConnection/ListenerTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Middleware/IdleConnection/ListenerTest.php @@ -9,13 +9,14 @@ * file that was distributed with this source code. */ -namespace Middleware\IdleConnection; +namespace Symfony\Bridge\Doctrine\Tests\Middleware\IdleConnection; use Doctrine\DBAL\Connection as ConnectionInterface; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Middleware\IdleConnection\Listener; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\Event\RequestEvent; +use Symfony\Component\HttpKernel\HttpKernelInterface; class ListenerTest extends TestCase { @@ -34,10 +35,24 @@ public function testOnKernelRequest() ->willReturn($connectionOneMock); $listener = new Listener($connectionExpiries, $containerMock); + $event = $this->createMock(RequestEvent::class); + $event->method('getRequestType')->willReturn(HttpKernelInterface::MAIN_REQUEST); - $listener->onKernelRequest($this->createMock(RequestEvent::class)); + $listener->onKernelRequest($event); $this->assertArrayNotHasKey('connectionone', (array) $connectionExpiries); $this->assertArrayHasKey('connectiontwo', (array) $connectionExpiries); } + + public function testOnKernelRequestShouldSkipSubrequests() + { + self::expectNotToPerformAssertions(); + $arrayObj = $this->createMock(\ArrayObject::class); + $arrayObj->method('getIterator')->willThrowException(new \Exception('Invalid behavior')); + $listener = new Listener($arrayObj, $this->createMock(ContainerInterface::class)); + + $event = $this->createMock(RequestEvent::class); + $event->method('getRequestType')->willReturn(HttpKernelInterface::SUB_REQUEST); + $listener->onKernelRequest($event); + } } diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php index 7903da227e912..2a5f337f2b0df 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php @@ -30,6 +30,7 @@ use Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded; use Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\EnumInt; use Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\EnumString; +use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait; use Symfony\Component\PropertyInfo\Type as LegacyType; use Symfony\Component\TypeInfo\Type; @@ -38,12 +39,18 @@ */ class DoctrineExtractorTest extends TestCase { + use ExpectUserDeprecationMessageTrait; + private function createExtractor(): DoctrineExtractor { $config = ORMSetup::createConfiguration(true); $config->setMetadataDriverImpl(new AttributeDriver([__DIR__.'/../Tests/Fixtures' => 'Symfony\Bridge\Doctrine\Tests\Fixtures'], true)); $config->setSchemaManagerFactory(new DefaultSchemaManagerFactory()); - $config->setLazyGhostObjectEnabled(true); + if (\PHP_VERSION_ID >= 80400 && method_exists($config, 'enableNativeLazyObjects')) { + $config->enableNativeLazyObjects(true); + } else { + $config->setLazyGhostObjectEnabled(true); + } $eventManager = new EventManager(); $entityManager = new EntityManager(DriverManager::getConnection(['driver' => 'pdo_sqlite'], $config, $eventManager), $config, $eventManager); @@ -108,15 +115,24 @@ public function testTestGetPropertiesWithEmbedded() } /** + * @group legacy + * * @dataProvider legacyTypesProvider */ public function testExtractLegacy(string $property, ?array $type = null) { + $this->expectUserDeprecationMessage('Since symfony/property-info 7.3: The "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getTypes()" method is deprecated, use "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getType()" instead.'); + $this->assertEquals($type, $this->createExtractor()->getTypes(DoctrineDummy::class, $property, [])); } + /** + * @group legacy + */ public function testExtractWithEmbeddedLegacy() { + $this->expectUserDeprecationMessage('Since symfony/property-info 7.3: The "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getTypes()" method is deprecated, use "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getType()" instead.'); + $expectedTypes = [new LegacyType( LegacyType::BUILTIN_TYPE_OBJECT, false, @@ -132,8 +148,13 @@ public function testExtractWithEmbeddedLegacy() $this->assertEquals($expectedTypes, $actualTypes); } + /** + * @group legacy + */ public function testExtractEnumLegacy() { + $this->expectUserDeprecationMessage('Since symfony/property-info 7.3: The "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getTypes()" method is deprecated, use "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getType()" instead.'); + $this->assertEquals([new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, EnumString::class)], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumString', [])); $this->assertEquals([new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, EnumInt::class)], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumInt', [])); $this->assertNull($this->createExtractor()->getTypes(DoctrineEnum::class, 'enumStringArray', [])); @@ -141,6 +162,9 @@ public function testExtractEnumLegacy() $this->assertNull($this->createExtractor()->getTypes(DoctrineEnum::class, 'enumCustom', [])); } + /** + * @group legacy + */ public static function legacyTypesProvider(): array { // DBAL 4 has a special fallback strategy for BINGINT (int -> string) @@ -240,8 +264,13 @@ public function testGetPropertiesCatchException() $this->assertNull($this->createExtractor()->getProperties('Not\Exist')); } + /** + * @group legacy + */ public function testGetTypesCatchExceptionLegacy() { + $this->expectUserDeprecationMessage('Since symfony/property-info 7.3: The "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getTypes()" method is deprecated, use "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getType()" instead.'); + $this->assertNull($this->createExtractor()->getTypes('Not\Exist', 'baz')); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php index 93e9818f4383c..6619f911ae1e0 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php @@ -41,7 +41,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str throw new ConversionException(sprintf('Expected "%s", got "%s"', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\Foo', get_debug_type($value))); } - return $foo->bar; + return $value->bar; } public function convertToPHPValue($value, AbstractPlatform $platform): ?Foo diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index a89ac84a7a9c1..82bc79f072ecd 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Doctrine\Tests\Security\User; +use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Tools\SchemaTool; @@ -219,8 +220,13 @@ public function testRefreshedUserProxyIsLoaded() $provider = new EntityUserProvider($this->getManager($em), User::class); $refreshedUser = $provider->refreshUser($user); - $this->assertInstanceOf(Proxy::class, $refreshedUser); - $this->assertTrue($refreshedUser->__isInitialized()); + if (\PHP_VERSION_ID >= 80400 && method_exists(Configuration::class, 'enableNativeLazyObjects')) { + $this->assertFalse((new \ReflectionClass(User::class))->isUninitializedLazyObject($refreshedUser)); + $this->assertSame('user1', $refreshedUser->name); + } else { + $this->assertInstanceOf(Proxy::class, $refreshedUser); + $this->assertTrue($refreshedUser->__isInitialized()); + } } private function getManager($em, $name = null) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Types/DatePointTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Types/DatePointTypeTest.php new file mode 100644 index 0000000000000..84b265ed6502c --- /dev/null +++ b/src/Symfony/Bridge/Doctrine/Tests/Types/DatePointTypeTest.php @@ -0,0 +1,101 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Doctrine\Tests\Types; + +use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Platforms\PostgreSQLPlatform; +use Doctrine\DBAL\Types\Type; +use PHPUnit\Framework\TestCase; +use Symfony\Bridge\Doctrine\Types\DatePointType; +use Symfony\Component\Clock\DatePoint; + +final class DatePointTypeTest extends TestCase +{ + private DatePointType $type; + + public static function setUpBeforeClass(): void + { + $name = DatePointType::NAME; + if (Type::hasType($name)) { + Type::overrideType($name, DatePointType::class); + } else { + Type::addType($name, DatePointType::class); + } + } + + protected function setUp(): void + { + if (!class_exists(DatePoint::class)) { + self::markTestSkipped('The DatePoint class is not available.'); + } + $this->type = Type::getType(DatePointType::NAME); + } + + public function testDatePointConvertsToDatabaseValue() + { + $datePoint = new DatePoint('2025-03-03 12:13:14'); + + $expected = $datePoint->format('Y-m-d H:i:s'); + $actual = $this->type->convertToDatabaseValue($datePoint, new PostgreSQLPlatform()); + + $this->assertSame($expected, $actual); + } + + public function testDatePointConvertsToPHPValue() + { + $datePoint = new DatePoint(); + $actual = $this->type->convertToPHPValue($datePoint, self::getSqlitePlatform()); + + $this->assertSame($datePoint, $actual); + } + + public function testNullConvertsToPHPValue() + { + $actual = $this->type->convertToPHPValue(null, self::getSqlitePlatform()); + + $this->assertNull($actual); + } + + public function testDateTimeImmutableConvertsToPHPValue() + { + $format = 'Y-m-d H:i:s'; + $dateTime = new \DateTimeImmutable('2025-03-03 12:13:14'); + $actual = $this->type->convertToPHPValue($dateTime, self::getSqlitePlatform()); + $expected = DatePoint::createFromInterface($dateTime); + + $this->assertSame($expected->format($format), $actual->format($format)); + } + + public function testDatabaseValueConvertsToPHPValue() + { + $actual = $this->type->convertToPHPValue('2025-03-03 12:13:14', new PostgreSQLPlatform()); + + $this->assertInstanceOf(DatePoint::class, $actual); + $this->assertSame('2025-03-03 12:13:14', $actual->format('Y-m-d H:i:s')); + } + + public function testGetName() + { + $this->assertSame('date_point', $this->type->getName()); + } + + private static function getSqlitePlatform(): AbstractPlatform + { + if (interface_exists(Exception::class)) { + // DBAL 4+ + return new \Doctrine\DBAL\Platforms\SQLitePlatform(); + } + + return new \Doctrine\DBAL\Platforms\SqlitePlatform(); + } +} diff --git a/src/Symfony/Bridge/Doctrine/Tests/Types/UlidTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Types/UlidTypeTest.php index 15852c8a92b64..b490d94f4263f 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Types/UlidTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Types/UlidTypeTest.php @@ -11,11 +11,11 @@ namespace Symfony\Bridge\Doctrine\Tests\Types; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\MariaDBPlatform; use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\DBAL\Platforms\PostgreSQLPlatform; -use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\TestCase; @@ -23,12 +23,6 @@ use Symfony\Component\Uid\AbstractUid; use Symfony\Component\Uid\Ulid; -// DBAL 3 compatibility -class_exists('Doctrine\DBAL\Platforms\SqlitePlatform'); - -// DBAL 3 compatibility -class_exists('Doctrine\DBAL\Platforms\SqlitePlatform'); - final class UlidTypeTest extends TestCase { private const DUMMY_ULID = '01EEDQEK6ZAZE93J8KG5B4MBJC'; @@ -87,25 +81,25 @@ public function testNotSupportedTypeConversionForDatabaseValue() { $this->expectException(ConversionException::class); - $this->type->convertToDatabaseValue(new \stdClass(), new SQLitePlatform()); + $this->type->convertToDatabaseValue(new \stdClass(), self::getSqlitePlatform()); } public function testNullConversionForDatabaseValue() { - $this->assertNull($this->type->convertToDatabaseValue(null, new SQLitePlatform())); + $this->assertNull($this->type->convertToDatabaseValue(null, self::getSqlitePlatform())); } public function testUlidInterfaceConvertsToPHPValue() { $ulid = $this->createMock(AbstractUid::class); - $actual = $this->type->convertToPHPValue($ulid, new SQLitePlatform()); + $actual = $this->type->convertToPHPValue($ulid, self::getSqlitePlatform()); $this->assertSame($ulid, $actual); } public function testUlidConvertsToPHPValue() { - $ulid = $this->type->convertToPHPValue(self::DUMMY_ULID, new SQLitePlatform()); + $ulid = $this->type->convertToPHPValue(self::DUMMY_ULID, self::getSqlitePlatform()); $this->assertInstanceOf(Ulid::class, $ulid); $this->assertEquals(self::DUMMY_ULID, $ulid->__toString()); @@ -115,19 +109,19 @@ public function testInvalidUlidConversionForPHPValue() { $this->expectException(ConversionException::class); - $this->type->convertToPHPValue('abcdefg', new SQLitePlatform()); + $this->type->convertToPHPValue('abcdefg', self::getSqlitePlatform()); } public function testNullConversionForPHPValue() { - $this->assertNull($this->type->convertToPHPValue(null, new SQLitePlatform())); + $this->assertNull($this->type->convertToPHPValue(null, self::getSqlitePlatform())); } public function testReturnValueIfUlidForPHPValue() { $ulid = new Ulid(); - $this->assertSame($ulid, $this->type->convertToPHPValue($ulid, new SQLitePlatform())); + $this->assertSame($ulid, $this->type->convertToPHPValue($ulid, self::getSqlitePlatform())); } public function testGetName() @@ -146,13 +140,23 @@ public function testGetGuidTypeDeclarationSQL(AbstractPlatform $platform, string public static function provideSqlDeclarations(): \Generator { yield [new PostgreSQLPlatform(), 'UUID']; - yield [new SQLitePlatform(), 'BLOB']; + yield [self::getSqlitePlatform(), 'BLOB']; yield [new MySQLPlatform(), 'BINARY(16)']; yield [new MariaDBPlatform(), 'BINARY(16)']; } public function testRequiresSQLCommentHint() { - $this->assertTrue($this->type->requiresSQLCommentHint(new SQLitePlatform())); + $this->assertTrue($this->type->requiresSQLCommentHint(self::getSqlitePlatform())); + } + + private static function getSqlitePlatform(): AbstractPlatform + { + if (interface_exists(Exception::class)) { + // DBAL 4+ + return new \Doctrine\DBAL\Platforms\SQLitePlatform(); + } + + return new \Doctrine\DBAL\Platforms\SqlitePlatform(); } } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Types/UuidTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Types/UuidTypeTest.php index 8e4ab2937d05b..f26e43ffe66b3 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Types/UuidTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Types/UuidTypeTest.php @@ -11,11 +11,11 @@ namespace Symfony\Bridge\Doctrine\Tests\Types; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\MariaDBPlatform; use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\DBAL\Platforms\PostgreSQLPlatform; -use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\TestCase; @@ -92,25 +92,25 @@ public function testNotSupportedTypeConversionForDatabaseValue() { $this->expectException(ConversionException::class); - $this->type->convertToDatabaseValue(new \stdClass(), new SqlitePlatform()); + $this->type->convertToDatabaseValue(new \stdClass(), self::getSqlitePlatform()); } public function testNullConversionForDatabaseValue() { - $this->assertNull($this->type->convertToDatabaseValue(null, new SqlitePlatform())); + $this->assertNull($this->type->convertToDatabaseValue(null, self::getSqlitePlatform())); } public function testUuidInterfaceConvertsToPHPValue() { $uuid = $this->createMock(AbstractUid::class); - $actual = $this->type->convertToPHPValue($uuid, new SqlitePlatform()); + $actual = $this->type->convertToPHPValue($uuid, self::getSqlitePlatform()); $this->assertSame($uuid, $actual); } public function testUuidConvertsToPHPValue() { - $uuid = $this->type->convertToPHPValue(self::DUMMY_UUID, new SqlitePlatform()); + $uuid = $this->type->convertToPHPValue(self::DUMMY_UUID, self::getSqlitePlatform()); $this->assertInstanceOf(Uuid::class, $uuid); $this->assertEquals(self::DUMMY_UUID, $uuid->__toString()); @@ -120,19 +120,19 @@ public function testInvalidUuidConversionForPHPValue() { $this->expectException(ConversionException::class); - $this->type->convertToPHPValue('abcdefg', new SqlitePlatform()); + $this->type->convertToPHPValue('abcdefg', self::getSqlitePlatform()); } public function testNullConversionForPHPValue() { - $this->assertNull($this->type->convertToPHPValue(null, new SqlitePlatform())); + $this->assertNull($this->type->convertToPHPValue(null, self::getSqlitePlatform())); } public function testReturnValueIfUuidForPHPValue() { $uuid = Uuid::v4(); - $this->assertSame($uuid, $this->type->convertToPHPValue($uuid, new SqlitePlatform())); + $this->assertSame($uuid, $this->type->convertToPHPValue($uuid, self::getSqlitePlatform())); } public function testGetName() @@ -151,13 +151,23 @@ public function testGetGuidTypeDeclarationSQL(AbstractPlatform $platform, string public static function provideSqlDeclarations(): \Generator { yield [new PostgreSQLPlatform(), 'UUID']; - yield [new SqlitePlatform(), 'BLOB']; + yield [self::getSqlitePlatform(), 'BLOB']; yield [new MySQLPlatform(), 'BINARY(16)']; yield [new MariaDBPlatform(), 'BINARY(16)']; } public function testRequiresSQLCommentHint() { - $this->assertTrue($this->type->requiresSQLCommentHint(new SqlitePlatform())); + $this->assertTrue($this->type->requiresSQLCommentHint(self::getSqlitePlatform())); + } + + private static function getSqlitePlatform(): AbstractPlatform + { + if (interface_exists(Exception::class)) { + // DBAL 4+ + return new \Doctrine\DBAL\Platforms\SQLitePlatform(); + } + + return new \Doctrine\DBAL\Platforms\SqlitePlatform(); } } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index 0c1b17133edb5..4f93768cddf7c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -14,8 +14,6 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\EntityRepository; -use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ObjectManager; @@ -32,7 +30,6 @@ use Symfony\Bridge\Doctrine\Tests\Fixtures\Dto; use Symfony\Bridge\Doctrine\Tests\Fixtures\Employee; use Symfony\Bridge\Doctrine\Tests\Fixtures\HireAnEmployee; -use Symfony\Bridge\Doctrine\Tests\Fixtures\MockableRepository; use Symfony\Bridge\Doctrine\Tests\Fixtures\Person; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity; @@ -44,9 +41,12 @@ use Symfony\Bridge\Doctrine\Tests\Fixtures\UpdateCompositeIntIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\UpdateCompositeObjectNoToStringIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\UpdateEmployeeProfile; +use Symfony\Bridge\Doctrine\Tests\Fixtures\UserUuidNameDto; +use Symfony\Bridge\Doctrine\Tests\Fixtures\UserUuidNameEntity; use Symfony\Bridge\Doctrine\Tests\TestRepositoryFactory; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator; +use Symfony\Component\Uid\Uuid; use Symfony\Component\Validator\Exception\ConstraintDefinitionException; use Symfony\Component\Validator\Exception\UnexpectedValueException; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; @@ -98,53 +98,6 @@ protected function createRegistryMock($em = null) return $registry; } - protected function createRepositoryMock(string $className) - { - $repositoryMock = $this->getMockBuilder(MockableRepository::class) - ->disableOriginalConstructor() - ->onlyMethods(['find', 'findAll', 'findOneBy', 'findBy', 'getClassName', 'findByCustom']) - ->getMock(); - - $repositoryMock->method('getClassName') - ->willReturn($className); - - return $repositoryMock; - } - - protected function createEntityManagerMock($repositoryMock) - { - $em = $this->createMock(ObjectManager::class); - $em->expects($this->any()) - ->method('getRepository') - ->willReturn($repositoryMock) - ; - - $classMetadata = $this->createMock( - class_exists(ClassMetadataInfo::class) ? ClassMetadataInfo::class : ClassMetadata::class - ); - $classMetadata - ->method('getName') - ->willReturn($repositoryMock->getClassName()) - ; - $classMetadata - ->expects($this->any()) - ->method('hasField') - ->willReturn(true) - ; - $refl = $this->createMock(\ReflectionProperty::class); - $refl - ->method('getValue') - ->willReturn(true) - ; - $classMetadata->reflFields = ['name' => $refl]; - $em->expects($this->any()) - ->method('getClassMetadata') - ->willReturn($classMetadata) - ; - - return $em; - } - protected function createValidator(): UniqueEntityValidator { return new UniqueEntityValidator($this->registry); @@ -166,6 +119,7 @@ private function createSchema($em) $em->getClassMetadata(Employee::class), $em->getClassMetadata(CompositeObjectNoToStringIdEntity::class), $em->getClassMetadata(SingleIntIdStringWrapperNameEntity::class), + $em->getClassMetadata(UserUuidNameEntity::class), ]); } @@ -431,13 +385,7 @@ public function testValidateUniquenessWithValidCustomErrorPath() public function testValidateUniquenessUsingCustomRepositoryMethod() { - $repository = $this->createRepositoryMock(SingleIntIdEntity::class); - $repository->expects($this->once()) - ->method('findByCustom') - ->willReturn([]) - ; - $this->em = $this->createEntityManagerMock($repository); - $this->registry = $this->createRegistryMock($this->em); + $this->em->getRepository(SingleIntIdEntity::class)->result = []; $this->validator = $this->createValidator(); $this->validator->initialize($this->context); @@ -452,22 +400,12 @@ public function testValidateUniquenessWithUnrewoundArray() { $entity = new SingleIntIdEntity(1, 'foo'); - $repository = $this->createRepositoryMock(SingleIntIdEntity::class); - $repository->expects($this->once()) - ->method('findByCustom') - ->willReturnCallback( - function () use ($entity) { - $returnValue = [ - $entity, - ]; - next($returnValue); - - return $returnValue; - } - ) - ; - $this->em = $this->createEntityManagerMock($repository); - $this->registry = $this->createRegistryMock($this->em); + $returnValue = [ + $entity, + ]; + next($returnValue); + + $this->em->getRepository(SingleIntIdEntity::class)->result = $returnValue; $this->validator = $this->createValidator(); $this->validator->initialize($this->context); @@ -488,13 +426,7 @@ public function testValidateResultTypes($entity1, $result) repositoryMethod: 'findByCustom', ); - $repository = $this->createRepositoryMock($entity1::class); - $repository->expects($this->once()) - ->method('findByCustom') - ->willReturn($result) - ; - $this->em = $this->createEntityManagerMock($repository); - $this->registry = $this->createRegistryMock($this->em); + $this->em->getRepository(SingleIntIdEntity::class)->result = $result; $this->validator = $this->createValidator(); $this->validator->initialize($this->context); @@ -644,9 +576,6 @@ public function testAssociatedEntityReferencedByPrimaryKey() public function testValidateUniquenessWithArrayValue() { - $repository = $this->createRepositoryMock(SingleIntIdEntity::class); - $this->repositoryFactory->setRepository($this->em, SingleIntIdEntity::class, $repository); - $constraint = new UniqueEntity( message: 'myMessage', fields: ['phoneNumbers'], @@ -657,10 +586,7 @@ public function testValidateUniquenessWithArrayValue() $entity1 = new SingleIntIdEntity(1, 'foo'); $entity1->phoneNumbers[] = 123; - $repository->expects($this->once()) - ->method('findByCustom') - ->willReturn([$entity1]) - ; + $this->em->getRepository(SingleIntIdEntity::class)->result = $entity1; $this->em->persist($entity1); $this->em->flush(); @@ -710,8 +636,6 @@ public function testEntityManagerNullObject() // no "em" option set ); - $this->em = null; - $this->registry = $this->createRegistryMock($this->em); $this->validator = $this->createValidator(); $this->validator->initialize($this->context); @@ -725,14 +649,6 @@ public function testEntityManagerNullObject() public function testValidateUniquenessOnNullResult() { - $repository = $this->createRepositoryMock(SingleIntIdEntity::class); - $repository - ->method('find') - ->willReturn(null) - ; - - $this->em = $this->createEntityManagerMock($repository); - $this->registry = $this->createRegistryMock($this->em); $this->validator = $this->createValidator(); $this->validator->initialize($this->context); @@ -913,13 +829,7 @@ public function testValidateUniquenessWithEmptyIterator($entity, $result) repositoryMethod: 'findByCustom', ); - $repository = $this->createRepositoryMock($entity::class); - $repository->expects($this->once()) - ->method('findByCustom') - ->willReturn($result) - ; - $this->em = $this->createEntityManagerMock($repository); - $this->registry = $this->createRegistryMock($this->em); + $this->em->getRepository(SingleIntIdEntity::class)->result = $result; $this->validator = $this->createValidator(); $this->validator->initialize($this->context); @@ -1517,4 +1427,25 @@ public function testEntityManagerNullObjectWhenDTODoctrineStyle() $this->validator->validate($dto, $constraint); } + + public function testUuidIdentifierWithSameValueDifferentInstanceDoesNotCauseViolation() + { + $uuidString = 'ec562e21-1fc8-4e55-8de7-a42389ac75c5'; + $existingPerson = new UserUuidNameEntity(Uuid::fromString($uuidString), 'Foo Bar'); + $this->em->persist($existingPerson); + $this->em->flush(); + + $dto = new UserUuidNameDto(Uuid::fromString($uuidString), 'Foo Bar', ''); + + $constraint = new UniqueEntity( + fields: ['fullName'], + entityClass: UserUuidNameEntity::class, + identifierFieldNames: ['id'], + em: self::EM_NAME, + ); + + $this->validator->validate($dto, $constraint); + + $this->assertNoViolation(); + } } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php index ef304114be0c4..8b3494961d80b 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php @@ -210,7 +210,7 @@ public function testClassNoAutoMapping() $this->assertSame(AutoMappingStrategy::DISABLED, $classMetadata->getAutoMappingStrategy()); $maxLengthMetadata = $classMetadata->getPropertyMetadata('maxLength'); - $this->assertEmpty($maxLengthMetadata); + $this->assertSame([], $maxLengthMetadata); /** @var PropertyMetadata[] $autoMappingExplicitlyEnabledMetadata */ $autoMappingExplicitlyEnabledMetadata = $classMetadata->getPropertyMetadata('autoMappingExplicitlyEnabled'); diff --git a/src/Symfony/Bridge/Doctrine/Types/DatePointType.php b/src/Symfony/Bridge/Doctrine/Types/DatePointType.php new file mode 100644 index 0000000000000..565506f2b673e --- /dev/null +++ b/src/Symfony/Bridge/Doctrine/Types/DatePointType.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Doctrine\Types; + +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Types\DateTimeImmutableType; +use Symfony\Component\Clock\DatePoint; + +final class DatePointType extends DateTimeImmutableType +{ + public const NAME = 'date_point'; + + /** + * @param T $value + * + * @return (T is null ? null : DatePoint) + * + * @template T + */ + public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?DatePoint + { + if (null === $value || $value instanceof DatePoint) { + return $value; + } + + $value = parent::convertToPHPValue($value, $platform); + + return DatePoint::createFromInterface($value); + } + + public function getName(): string + { + return self::NAME; + } +} diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index 57dc44236e630..eb2e89b94dfb8 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -196,6 +196,12 @@ public function validate(mixed $value, Constraint $constraint): void foreach ($constraint->identifierFieldNames as $identifierFieldName) { $propertyValue = $this->getPropertyValue($entityClass, $identifierFieldName, current($result)); + if ($fieldValues[$identifierFieldName] instanceof \Stringable) { + $fieldValues[$identifierFieldName] = (string) $fieldValues[$identifierFieldName]; + } + if ($propertyValue instanceof \Stringable) { + $propertyValue = (string) $propertyValue; + } if ($fieldValues[$identifierFieldName] !== $propertyValue) { $entityMatched = false; break; @@ -287,9 +293,13 @@ private function getFieldValues(mixed $object, ClassMetadata $class, array $fiel throw new ConstraintDefinitionException(\sprintf('The field "%s" is not a property of class "%s".', $fieldName, $objectClass)); } - $fieldValues[$entityFieldName] = $isValueEntity && $object instanceof ($class->getName()) - ? $class->reflFields[$fieldName]->getValue($object) - : $this->getPropertyValue($objectClass, $fieldName, $object); + if ($isValueEntity && $object instanceof ($class->getName()) && property_exists($class, 'propertyAccessors')) { + $fieldValues[$entityFieldName] = $class->propertyAccessors[$fieldName]->getValue($object); + } elseif ($isValueEntity && $object instanceof ($class->getName())) { + $fieldValues[$entityFieldName] = $class->reflFields[$fieldName]->getValue($object); + } else { + $fieldValues[$entityFieldName] = $this->getPropertyValue($objectClass, $fieldName, $object); + } } return $fieldValues; diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 9d95a8af14ca7..bebf7276a99dc 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -39,7 +39,7 @@ "symfony/security-core": "^6.4|^7.0", "symfony/stopwatch": "^6.4|^7.0", "symfony/translation": "^6.4|^7.0", - "symfony/type-info": "^7.1", + "symfony/type-info": "^7.1.8", "symfony/uid": "^6.4|^7.0", "symfony/validator": "^6.4|^7.0", "symfony/var-dumper": "^6.4|^7.0", diff --git a/src/Symfony/Bridge/Monolog/Processor/ConsoleCommandProcessor.php b/src/Symfony/Bridge/Monolog/Processor/ConsoleCommandProcessor.php index 39f7d891cbd73..fddc605029bac 100644 --- a/src/Symfony/Bridge/Monolog/Processor/ConsoleCommandProcessor.php +++ b/src/Symfony/Bridge/Monolog/Processor/ConsoleCommandProcessor.php @@ -12,6 +12,7 @@ namespace Symfony\Bridge\Monolog\Processor; use Monolog\LogRecord; +use Monolog\ResettableInterface; use Symfony\Component\Console\ConsoleEvents; use Symfony\Component\Console\Event\ConsoleEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -22,7 +23,7 @@ * * @author Piotr Stankowski */ -final class ConsoleCommandProcessor implements EventSubscriberInterface, ResetInterface +final class ConsoleCommandProcessor implements EventSubscriberInterface, ResetInterface, ResettableInterface { private array $commandData; diff --git a/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php b/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php index 0fccd6f3b78d7..1df5aeffc235a 100644 --- a/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php +++ b/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php @@ -13,12 +13,13 @@ use Monolog\Level; use Monolog\LogRecord; +use Monolog\ResettableInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; use Symfony\Contracts\Service\ResetInterface; -class DebugProcessor implements DebugLoggerInterface, ResetInterface +class DebugProcessor implements DebugLoggerInterface, ResetInterface, ResettableInterface { private array $records = []; private array $errorCount = []; diff --git a/src/Symfony/Bridge/Monolog/Processor/RouteProcessor.php b/src/Symfony/Bridge/Monolog/Processor/RouteProcessor.php index e7a58045edb5d..85b50a39f88d9 100644 --- a/src/Symfony/Bridge/Monolog/Processor/RouteProcessor.php +++ b/src/Symfony/Bridge/Monolog/Processor/RouteProcessor.php @@ -12,6 +12,7 @@ namespace Symfony\Bridge\Monolog\Processor; use Monolog\LogRecord; +use Monolog\ResettableInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\HttpKernel\Event\RequestEvent; @@ -25,7 +26,7 @@ * * @final */ -class RouteProcessor implements EventSubscriberInterface, ResetInterface +class RouteProcessor implements EventSubscriberInterface, ResetInterface, ResettableInterface { private array $routeData = []; diff --git a/src/Symfony/Bridge/PhpUnit/CoverageListener.php b/src/Symfony/Bridge/PhpUnit/CoverageListener.php index 65d6aa9dc9dcc..f1a89ff8ee846 100644 --- a/src/Symfony/Bridge/PhpUnit/CoverageListener.php +++ b/src/Symfony/Bridge/PhpUnit/CoverageListener.php @@ -86,7 +86,9 @@ public function startTest(Test $test): void private function addCoversForClassToAnnotationCache(Test $test, array $covers): void { $r = new \ReflectionProperty(TestUtil::class, 'annotationCache'); - $r->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $r->setAccessible(true); + } $cache = $r->getValue(); $cache = array_replace_recursive($cache, [ @@ -103,7 +105,9 @@ private function addCoversForDocBlockInsideRegistry(Test $test, array $covers): $docBlock = Registry::getInstance()->forClassName(\get_class($test)); $symbolAnnotations = new \ReflectionProperty($docBlock, 'symbolAnnotations'); - $symbolAnnotations->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $symbolAnnotations->setAccessible(true); + } // Exclude internal classes; PHPUnit 9.1+ is picky about tests covering, say, a \RuntimeException $covers = array_filter($covers, function (string $class) { diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php index 822e9800bf0ea..061dfff756165 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php @@ -389,7 +389,9 @@ public function toString(): string { $exception = new \Exception($this->message); $reflection = new \ReflectionProperty($exception, 'trace'); - $reflection->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $reflection->setAccessible(true); + } $reflection->setValue($exception, $this->trace); return ($this->originatesFromAnObject() ? 'deprecation triggered by '.$this->originatingClass().'::'.$this->originatingMethod().":\n" : '') diff --git a/src/Symfony/Bridge/PhpUnit/Extension/DisableClockMockSubscriber.php b/src/Symfony/Bridge/PhpUnit/Extension/DisableClockMockSubscriber.php deleted file mode 100644 index 1de94db292656..0000000000000 --- a/src/Symfony/Bridge/PhpUnit/Extension/DisableClockMockSubscriber.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PhpUnit\Extension; - -use PHPUnit\Event\Code\TestMethod; -use PHPUnit\Event\Test\Finished; -use PHPUnit\Event\Test\FinishedSubscriber; -use PHPUnit\Metadata\Group; -use Symfony\Bridge\PhpUnit\Attribute\TimeSensitive; -use Symfony\Bridge\PhpUnit\ClockMock; -use Symfony\Bridge\PhpUnit\Metadata\AttributeReader; - -/** - * @internal - */ -class DisableClockMockSubscriber implements FinishedSubscriber -{ - public function __construct( - private AttributeReader $reader, - ) { - } - - public function notify(Finished $event): void - { - $test = $event->test(); - - if (!$test instanceof TestMethod) { - return; - } - - foreach ($test->metadata() as $metadata) { - if ($metadata instanceof Group && 'time-sensitive' === $metadata->groupName()) { - ClockMock::withClockMock(false); - break; - } - } - - if ($this->reader->forClassAndMethod($test->className(), $test->methodName(), TimeSensitive::class)) { - ClockMock::withClockMock(false); - } - } -} diff --git a/src/Symfony/Bridge/PhpUnit/Extension/DisableDnsMockSubscriber.php b/src/Symfony/Bridge/PhpUnit/Extension/DisableDnsMockSubscriber.php deleted file mode 100644 index 29cdbbf1835cf..0000000000000 --- a/src/Symfony/Bridge/PhpUnit/Extension/DisableDnsMockSubscriber.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PhpUnit\Extension; - -use PHPUnit\Event\Code\TestMethod; -use PHPUnit\Event\Test\Finished; -use PHPUnit\Event\Test\FinishedSubscriber; -use PHPUnit\Metadata\Group; -use Symfony\Bridge\PhpUnit\Attribute\DnsSensitive; -use Symfony\Bridge\PhpUnit\DnsMock; -use Symfony\Bridge\PhpUnit\Metadata\AttributeReader; - -/** - * @internal - */ -class DisableDnsMockSubscriber implements FinishedSubscriber -{ - public function __construct( - private AttributeReader $reader, - ) { - } - - public function notify(Finished $event): void - { - $test = $event->test(); - - if (!$test instanceof TestMethod) { - return; - } - - foreach ($test->metadata() as $metadata) { - if ($metadata instanceof Group && 'dns-sensitive' === $metadata->groupName()) { - DnsMock::withMockedHosts([]); - break; - } - } - - if ($this->reader->forClassAndMethod($test->className(), $test->methodName(), DnsSensitive::class)) { - DnsMock::withMockedHosts([]); - } - } -} diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 486d3bf155440..63c2fb5fba58c 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -357,7 +357,9 @@ private function willBeIsolated(TestCase $test): bool } $r = new \ReflectionProperty($test, 'runTestInSeparateProcess'); - $r->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $r->setAccessible(true); + } return $r->getValue($test) ?? false; } diff --git a/src/Symfony/Bridge/PhpUnit/SymfonyExtension.php b/src/Symfony/Bridge/PhpUnit/SymfonyExtension.php index a21e4626368b9..05ff99aa8aedc 100644 --- a/src/Symfony/Bridge/PhpUnit/SymfonyExtension.php +++ b/src/Symfony/Bridge/PhpUnit/SymfonyExtension.php @@ -11,12 +11,23 @@ namespace Symfony\Bridge\PhpUnit; +use PHPUnit\Event\Code\Test; +use PHPUnit\Event\Code\TestMethod; +use PHPUnit\Event\Test\BeforeTestMethodErrored; +use PHPUnit\Event\Test\BeforeTestMethodErroredSubscriber; +use PHPUnit\Event\Test\Errored; +use PHPUnit\Event\Test\ErroredSubscriber; +use PHPUnit\Event\Test\Finished; +use PHPUnit\Event\Test\FinishedSubscriber; +use PHPUnit\Event\Test\Skipped; +use PHPUnit\Event\Test\SkippedSubscriber; +use PHPUnit\Metadata\Group; use PHPUnit\Runner\Extension\Extension; use PHPUnit\Runner\Extension\Facade; use PHPUnit\Runner\Extension\ParameterCollection; use PHPUnit\TextUI\Configuration\Configuration; -use Symfony\Bridge\PhpUnit\Extension\DisableClockMockSubscriber; -use Symfony\Bridge\PhpUnit\Extension\DisableDnsMockSubscriber; +use Symfony\Bridge\PhpUnit\Attribute\DnsSensitive; +use Symfony\Bridge\PhpUnit\Attribute\TimeSensitive; use Symfony\Bridge\PhpUnit\Extension\EnableClockMockSubscriber; use Symfony\Bridge\PhpUnit\Extension\RegisterClockMockSubscriber; use Symfony\Bridge\PhpUnit\Extension\RegisterDnsMockSubscriber; @@ -41,7 +52,58 @@ public function bootstrap(Configuration $configuration, Facade $facade, Paramete $facade->registerSubscriber(new RegisterClockMockSubscriber($reader)); $facade->registerSubscriber(new EnableClockMockSubscriber($reader)); - $facade->registerSubscriber(new DisableClockMockSubscriber($reader)); + $facade->registerSubscriber(new class($reader) implements ErroredSubscriber { + public function __construct(private AttributeReader $reader) + { + } + + public function notify(Errored $event): void + { + SymfonyExtension::disableClockMock($event->test(), $this->reader); + SymfonyExtension::disableDnsMock($event->test(), $this->reader); + } + }); + $facade->registerSubscriber(new class($reader) implements FinishedSubscriber { + public function __construct(private AttributeReader $reader) + { + } + + public function notify(Finished $event): void + { + SymfonyExtension::disableClockMock($event->test(), $this->reader); + SymfonyExtension::disableDnsMock($event->test(), $this->reader); + } + }); + $facade->registerSubscriber(new class($reader) implements SkippedSubscriber { + public function __construct(private AttributeReader $reader) + { + } + + public function notify(Skipped $event): void + { + SymfonyExtension::disableClockMock($event->test(), $this->reader); + SymfonyExtension::disableDnsMock($event->test(), $this->reader); + } + }); + + if (interface_exists(BeforeTestMethodErroredSubscriber::class)) { + $facade->registerSubscriber(new class($reader) implements BeforeTestMethodErroredSubscriber { + public function __construct(private AttributeReader $reader) + { + } + + public function notify(BeforeTestMethodErrored $event): void + { + if (method_exists($event, 'test')) { + SymfonyExtension::disableClockMock($event->test(), $this->reader); + SymfonyExtension::disableDnsMock($event->test(), $this->reader); + } else { + ClockMock::withClockMock(false); + DnsMock::withMockedHosts([]); + } + } + }); + } if ($parameters->has('dns-mock-namespaces')) { foreach (explode(',', $parameters->get('dns-mock-namespaces')) as $namespace) { @@ -50,6 +112,43 @@ public function bootstrap(Configuration $configuration, Facade $facade, Paramete } $facade->registerSubscriber(new RegisterDnsMockSubscriber($reader)); - $facade->registerSubscriber(new DisableDnsMockSubscriber($reader)); + } + + /** + * @internal + */ + public static function disableClockMock(Test $test, AttributeReader $reader): void + { + if (self::hasGroup($test, 'time-sensitive', $reader, TimeSensitive::class)) { + ClockMock::withClockMock(false); + } + } + + /** + * @internal + */ + public static function disableDnsMock(Test $test, AttributeReader $reader): void + { + if (self::hasGroup($test, 'dns-sensitive', $reader, DnsSensitive::class)) { + DnsMock::withMockedHosts([]); + } + } + + /** + * @internal + */ + public static function hasGroup(Test $test, string $groupName, AttributeReader $reader, string $attribute): bool + { + if (!$test instanceof TestMethod) { + return false; + } + + foreach ($test->metadata() as $metadata) { + if ($metadata instanceof Group && $groupName === $metadata->groupName()) { + return true; + } + } + + return [] !== $reader->forClassAndMethod($test->className(), $test->methodName(), $attribute); } } diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php index 4c17a806b4281..2a7643a9d6d17 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php @@ -275,7 +275,9 @@ public static function setUpBeforeClass(): void $loader = require $v.'/autoload.php'; $reflection = new \ReflectionClass($loader); $prop = $reflection->getProperty('prefixDirsPsr4'); - $prop->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $prop->setAccessible(true); + } $currentValue = $prop->getValue($loader); self::$prefixDirsPsr4[] = [$prop, $loader, $currentValue]; $currentValue['Symfony\\Bridge\\PhpUnit\\'] = [realpath(__DIR__.'/../..')]; diff --git a/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/symfonyextension/tests/bootstrap.php b/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/symfonyextension/tests/bootstrap.php index 3616e5096c3b7..385e7ea7e51e4 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/symfonyextension/tests/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/symfonyextension/tests/bootstrap.php @@ -23,8 +23,6 @@ require __DIR__.'/../../../../SymfonyExtension.php'; require __DIR__.'/../../../../Attribute/DnsSensitive.php'; require __DIR__.'/../../../../Attribute/TimeSensitive.php'; -require __DIR__.'/../../../../Extension/DisableClockMockSubscriber.php'; -require __DIR__.'/../../../../Extension/DisableDnsMockSubscriber.php'; require __DIR__.'/../../../../Extension/EnableClockMockSubscriber.php'; require __DIR__.'/../../../../Extension/RegisterClockMockSubscriber.php'; require __DIR__.'/../../../../Extension/RegisterDnsMockSubscriber.php'; diff --git a/src/Symfony/Bridge/PhpUnit/Tests/Metadata/AttributeReaderTest.php b/src/Symfony/Bridge/PhpUnit/Tests/Metadata/AttributeReaderTest.php index 351a62a41bcba..b82a7acc16e4e 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/Metadata/AttributeReaderTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/Metadata/AttributeReaderTest.php @@ -71,7 +71,7 @@ public function testAttributesAreCached() $reader = new AttributeReader(); $cacheRef = new \ReflectionProperty(AttributeReader::class, 'cache'); - self::assertEmpty($cacheRef->getValue($reader)); + self::assertSame([], $cacheRef->getValue($reader)); $reader->forClass(FooBar::class, TimeSensitive::class); diff --git a/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtensionWithManualRegister.php b/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtensionWithManualRegister.php new file mode 100644 index 0000000000000..c02d6f1cf64ce --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Tests/SymfonyExtensionWithManualRegister.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Bridge\PhpUnit\ClockMock; +use Symfony\Bridge\PhpUnit\DnsMock; + +class SymfonyExtensionWithManualRegister extends TestCase +{ + public static function setUpBeforeClass(): void + { + ClockMock::register(self::class); + ClockMock::withClockMock(strtotime('2024-05-20 15:30:00')); + + DnsMock::register(self::class); + DnsMock::withMockedHosts([ + 'example.com' => [ + ['type' => 'A', 'ip' => '1.2.3.4'], + ], + ]); + } + + public static function tearDownAfterClass(): void + { + ClockMock::withClockMock(false); + DnsMock::withMockedHosts([]); + } + + public function testDate() + { + self::assertSame('2024-05-20 15:30:00', date('Y-m-d H:i:s')); + } + + public function testGetHostByName() + { + self::assertSame('1.2.3.4', gethostbyname('example.com')); + } + + public function testTime() + { + self::assertSame(1716219000, time()); + } + + public function testDnsGetRecord() + { + self::assertSame([[ + 'host' => 'example.com', + 'class' => 'IN', + 'ttl' => 1, + 'type' => 'A', + 'ip' => '1.2.3.4', + ]], dns_get_record('example.com')); + } +} diff --git a/src/Symfony/Bridge/PhpUnit/Tests/symfonyextension.phpt b/src/Symfony/Bridge/PhpUnit/Tests/symfonyextension.phpt index 933352f07eadc..dd26388e71fd6 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/symfonyextension.phpt +++ b/src/Symfony/Bridge/PhpUnit/Tests/symfonyextension.phpt @@ -5,6 +5,8 @@ if (!getenv('SYMFONY_PHPUNIT_VERSION') || version_compare(getenv('SYMFONY_PHPUNI --FILE-- 'composer.json', 'COMPOSER_VENDOR_DIR' => 'vendor', 'COMPOSER_BIN_DIR' => 'bin', + 'COMPOSER_NO_INTERACTION' => '1', 'SYMFONY_SIMPLE_PHPUNIT_BIN_DIR' => __DIR__, ]; @@ -234,10 +235,10 @@ @copy("$PHPUNIT_VERSION_DIR/phpunit.xsd", 'phpunit.xsd'); chdir("$PHPUNIT_VERSION_DIR"); if ($SYMFONY_PHPUNIT_REMOVE) { - $passthruOrFail("$COMPOSER remove --no-update --no-interaction ".$SYMFONY_PHPUNIT_REMOVE); + $passthruOrFail("$COMPOSER remove --no-update ".$SYMFONY_PHPUNIT_REMOVE); } if ($SYMFONY_PHPUNIT_REQUIRE) { - $passthruOrFail("$COMPOSER require --no-update --no-interaction ".$SYMFONY_PHPUNIT_REQUIRE); + $passthruOrFail("$COMPOSER require --no-update ".$SYMFONY_PHPUNIT_REQUIRE); } if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) { $passthruOrFail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); @@ -386,6 +387,10 @@ class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Bla $cmd .= '%2$s'; } +if (version_compare($PHPUNIT_VERSION, '11.0', '>=')) { + $GLOBALS['_composer_autoload_path'] = "$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/vendor/autoload.php"; +} + if ($components) { $skippedTests = $_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS'] ?? false; $runningProcs = []; @@ -462,7 +467,7 @@ class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Bla } } } elseif (!isset($argv[1]) || 'install' !== $argv[1] || file_exists('install')) { - if (!class_exists(\SymfonyExcludeListSimplePhpunit::class, false)) { + if (!class_exists(SymfonyExcludeListSimplePhpunit::class, false)) { class SymfonyExcludeListSimplePhpunit { } diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php index f11b7ab7f4945..24d593406c87a 100644 --- a/src/Symfony/Bridge/PhpUnit/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php @@ -14,14 +14,18 @@ use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; // Detect if we need to serialize deprecations to a file. -if (in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) { +if ( + // Skip if we're using PHPUnit >=10 + !class_exists(PHPUnit\Metadata\Metadata::class) + && in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE') +) { DeprecationErrorHandler::collectDeprecations($file); return; } // Detect if we're loaded by an actual run of phpunit -if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists(\PHPUnit\TextUI\Command::class, false)) { +if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists(PHPUnit\TextUI\Command::class, false)) { return; } @@ -46,6 +50,10 @@ } } -if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) { +if ( + // Skip if we're using PHPUnit >=10 + !class_exists(PHPUnit\Metadata\Metadata::class, false) + && 'disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER') +) { DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER')); } diff --git a/src/Symfony/Bridge/PhpUnit/composer.json b/src/Symfony/Bridge/PhpUnit/composer.json index 1283dfe33a9b0..de9101f796d73 100644 --- a/src/Symfony/Bridge/PhpUnit/composer.json +++ b/src/Symfony/Bridge/PhpUnit/composer.json @@ -2,7 +2,9 @@ "name": "symfony/phpunit-bridge", "type": "symfony-bridge", "description": "Provides utilities for PHPUnit, especially user deprecation notices management", - "keywords": [], + "keywords": [ + "testing" + ], "homepage": "https://symfony.com", "license": "MIT", "authors": [ diff --git a/src/Symfony/Bridge/Twig/CHANGELOG.md b/src/Symfony/Bridge/Twig/CHANGELOG.md index 156b29ab41905..d6d929cb50ed6 100644 --- a/src/Symfony/Bridge/Twig/CHANGELOG.md +++ b/src/Symfony/Bridge/Twig/CHANGELOG.md @@ -5,6 +5,10 @@ CHANGELOG --- * Add `is_granted_for_user()` Twig function + * Add `field_id()` Twig form helper function + * Add a `Twig` constraint that validates Twig templates + * Make `lint:twig` collect all deprecations instead of stopping at the first one + * Add `name` argument to `email.image` to override the attachment file name being set as the file path 7.2 --- diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index 5472095238a12..77bc2b08c8775 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -55,7 +55,7 @@ protected function configure(): void ->addOption('format', null, InputOption::VALUE_REQUIRED, \sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions()))) ->addOption('show-deprecations', null, InputOption::VALUE_NONE, 'Show deprecations as errors') ->addArgument('filename', InputArgument::IS_ARRAY, 'A file, a directory or "-" for reading from STDIN') - ->addOption('excludes', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Excluded directories', []) + ->addOption('excludes', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Excluded directories', []) ->setHelp(<<<'EOF' The %command.name% command lints a template and outputs to STDOUT the first encountered syntax error. @@ -89,7 +89,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->format = $input->getOption('format') ?? (GithubActionReporter::isGithubActionEnvironment() ? 'github' : 'txt'); if (['-'] === $filenames) { - return $this->display($input, $output, $io, [$this->validate(file_get_contents('php://stdin'), 'Standard Input')]); + return $this->display($input, $output, $io, [$this->validate(file_get_contents('php://stdin'), 'Standard Input', $showDeprecations)]); } if (!$filenames) { @@ -107,38 +107,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - if ($showDeprecations) { - $prevErrorHandler = set_error_handler(static function ($level, $message, $file, $line) use (&$prevErrorHandler) { - if (\E_USER_DEPRECATED === $level) { - $templateLine = 0; - if (preg_match('/ at line (\d+)[ .]/', $message, $matches)) { - $templateLine = $matches[1]; - } - - throw new Error($message, $templateLine); - } - - return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false; - }); - } - - try { - $filesInfo = $this->getFilesInfo($filenames); - } finally { - if ($showDeprecations) { - restore_error_handler(); - } - } - - return $this->display($input, $output, $io, $filesInfo); + return $this->display($input, $output, $io, $this->getFilesInfo($filenames, $showDeprecations)); } - private function getFilesInfo(array $filenames): array + private function getFilesInfo(array $filenames, bool $showDeprecations): array { $filesInfo = []; foreach ($filenames as $filename) { foreach ($this->findFiles($filename) as $file) { - $filesInfo[] = $this->validate(file_get_contents($file), $file); + $filesInfo[] = $this->validate(file_get_contents($file), $file, $showDeprecations); } } @@ -156,8 +133,26 @@ protected function findFiles(string $filename): iterable throw new RuntimeException(\sprintf('File or directory "%s" is not readable.', $filename)); } - private function validate(string $template, string $file): array + private function validate(string $template, string $file, bool $collectDeprecation): array { + $deprecations = []; + if ($collectDeprecation) { + $prevErrorHandler = set_error_handler(static function ($level, $message, $fileName, $line) use (&$prevErrorHandler, &$deprecations, $file) { + if (\E_USER_DEPRECATED === $level) { + $templateLine = 0; + if (preg_match('/ at line (\d+)[ .]/', $message, $matches)) { + $templateLine = $matches[1]; + } + + $deprecations[] = ['message' => $message, 'file' => $file, 'line' => $templateLine]; + + return true; + } + + return $prevErrorHandler ? $prevErrorHandler($level, $message, $fileName, $line) : false; + }); + } + $realLoader = $this->twig->getLoader(); try { $temporaryLoader = new ArrayLoader([$file => $template]); @@ -169,9 +164,13 @@ private function validate(string $template, string $file): array $this->twig->setLoader($realLoader); return ['template' => $template, 'file' => $file, 'line' => $e->getTemplateLine(), 'valid' => false, 'exception' => $e]; + } finally { + if ($collectDeprecation) { + restore_error_handler(); + } } - return ['template' => $template, 'file' => $file, 'valid' => true]; + return ['template' => $template, 'file' => $file, 'deprecations' => $deprecations, 'valid' => true]; } private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, array $files): int @@ -188,6 +187,11 @@ private function displayTxt(OutputInterface $output, SymfonyStyle $io, array $fi { $errors = 0; $githubReporter = $errorAsGithubAnnotations ? new GithubActionReporter($output) : null; + $deprecations = array_merge(...array_column($filesInfo, 'deprecations')); + + foreach ($deprecations as $deprecation) { + $this->renderDeprecation($io, $deprecation['line'], $deprecation['message'], $deprecation['file'], $githubReporter); + } foreach ($filesInfo as $info) { if ($info['valid'] && $output->isVerbose()) { @@ -204,7 +208,7 @@ private function displayTxt(OutputInterface $output, SymfonyStyle $io, array $fi $io->warning(\sprintf('%d Twig files have valid syntax and %d contain errors.', \count($filesInfo) - $errors, $errors)); } - return min($errors, 1); + return !$deprecations && !$errors ? 0 : 1; } private function displayJson(OutputInterface $output, array $filesInfo): int @@ -226,6 +230,19 @@ private function displayJson(OutputInterface $output, array $filesInfo): int return min($errors, 1); } + private function renderDeprecation(SymfonyStyle $output, int $line, string $message, string $file, ?GithubActionReporter $githubReporter): void + { + $githubReporter?->error($message, $file, $line <= 0 ? null : $line); + + if ($file) { + $output->text(\sprintf(' DEPRECATION in %s (line %s)', $file, $line)); + } else { + $output->text(\sprintf(' DEPRECATION (line %s)', $line)); + } + + $output->text(\sprintf(' >> %s ', $message)); + } + private function renderException(SymfonyStyle $output, string $template, Error $exception, ?string $file = null, ?GithubActionReporter $githubReporter = null): void { $line = $exception->getTemplateLine(); diff --git a/src/Symfony/Bridge/Twig/Extension/FormExtension.php b/src/Symfony/Bridge/Twig/Extension/FormExtension.php index ec552d7c622ef..62821fcd81045 100644 --- a/src/Symfony/Bridge/Twig/Extension/FormExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/FormExtension.php @@ -62,6 +62,7 @@ public function getFunctions(): array new TwigFunction('csrf_token', [FormRenderer::class, 'renderCsrfToken']), new TwigFunction('form_parent', 'Symfony\Bridge\Twig\Extension\twig_get_form_parent'), new TwigFunction('field_name', $this->getFieldName(...)), + new TwigFunction('field_id', $this->getFieldId(...)), new TwigFunction('field_value', $this->getFieldValue(...)), new TwigFunction('field_label', $this->getFieldLabel(...)), new TwigFunction('field_help', $this->getFieldHelp(...)), @@ -93,6 +94,11 @@ public function getFieldName(FormView $view): string return $view->vars['full_name']; } + public function getFieldId(FormView $view): string + { + return $view->vars['id']; + } + public function getFieldValue(FormView $view): string|array { return $view->vars['value']; @@ -155,7 +161,7 @@ private function createFieldChoicesList(iterable $choices, string|false|null $tr continue; } - /* @var ChoiceView $choice */ + /** @var ChoiceView $choice */ $translatableLabel = $this->createFieldTranslation($choice->label, $choice->labelTranslationParameters, $translationDomain); yield $translatableLabel => $choice->value; } diff --git a/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php b/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php index d019373074a93..e0bb242586371 100644 --- a/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php @@ -12,6 +12,7 @@ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\Security\Acl\Voter\FieldVote; +use Symfony\Component\Security\Core\Authorization\AccessDecision; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Authorization\UserAuthorizationCheckerInterface; use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException; @@ -30,11 +31,10 @@ final class SecurityExtension extends AbstractExtension public function __construct( private ?AuthorizationCheckerInterface $securityChecker = null, private ?ImpersonateUrlGenerator $impersonateUrlGenerator = null, - private ?UserAuthorizationCheckerInterface $userSecurityChecker = null, ) { } - public function isGranted(mixed $role, mixed $object = null, ?string $field = null): bool + public function isGranted(mixed $role, mixed $object = null, ?string $field = null, ?AccessDecision $accessDecision = null): bool { if (null === $this->securityChecker) { return false; @@ -49,16 +49,20 @@ public function isGranted(mixed $role, mixed $object = null, ?string $field = nu } try { - return $this->securityChecker->isGranted($role, $object); + return $this->securityChecker->isGranted($role, $object, $accessDecision); } catch (AuthenticationCredentialsNotFoundException) { return false; } } - public function isGrantedForUser(UserInterface $user, mixed $attribute, mixed $subject = null, ?string $field = null): bool + public function isGrantedForUser(UserInterface $user, mixed $attribute, mixed $subject = null, ?string $field = null, ?AccessDecision $accessDecision = null): bool { - if (!$this->userSecurityChecker) { - throw new \LogicException(\sprintf('An instance of "%s" must be provided to use "%s()".', UserAuthorizationCheckerInterface::class, __METHOD__)); + if (null === $this->securityChecker) { + return false; + } + + if (!$this->securityChecker instanceof UserAuthorizationCheckerInterface) { + throw new \LogicException(\sprintf('You cannot use "%s()" if the authorization checker doesn\'t implement "%s".%s', __METHOD__, UserAuthorizationCheckerInterface::class, interface_exists(UserAuthorizationCheckerInterface::class) ? ' Try upgrading the "symfony/security-core" package to v7.3 minimum.' : '')); } if (null !== $field) { @@ -69,7 +73,11 @@ public function isGrantedForUser(UserInterface $user, mixed $attribute, mixed $s $subject = new FieldVote($subject, $field); } - return $this->userSecurityChecker->isGrantedForUser($user, $attribute, $subject); + try { + return $this->securityChecker->isGrantedForUser($user, $attribute, $subject, $accessDecision); + } catch (AuthenticationCredentialsNotFoundException) { + return false; + } } public function getImpersonateExitUrl(?string $exitTo = null): string @@ -118,7 +126,7 @@ public function getFunctions(): array new TwigFunction('impersonation_path', $this->getImpersonatePath(...)), ]; - if ($this->userSecurityChecker) { + if ($this->securityChecker instanceof UserAuthorizationCheckerInterface) { $functions[] = new TwigFunction('is_granted_for_user', $this->isGrantedForUser(...)); } diff --git a/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php b/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php index 9eeb305aee36c..b06f0a8cedbe4 100644 --- a/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php @@ -44,7 +44,7 @@ public function getFunctions(): array /** * Adds a "Link" HTTP header. * - * @param string $rel The relation type (e.g. "preload", "prefetch", "prerender" or "dns-prefetch") + * @param string $rel The relation type (e.g. "preload", "prefetch", or "dns-prefetch") * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") * * @return string The relation URI @@ -115,7 +115,11 @@ public function prefetch(string $uri, array $attributes = []): string } /** - * Indicates to the client that it should prerender this resource . + * Indicates to the client that it should prerender this resource. + * + * This feature is deprecated and superseded by the Speculation Rules API. + * + * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/rel/prerender * * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") * diff --git a/src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php b/src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php index 2d308947f8498..68b3913eba367 100644 --- a/src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php +++ b/src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php @@ -100,7 +100,7 @@ public function markAsRendered(): void */ public function __serialize(): array { - return [$this->htmlTemplate, $this->textTemplate, $this->context, parent::__serialize(), $this->locale]; + return [$this->htmlTemplate, $this->textTemplate, $this->context, parent::__serialize(), $this->locale]; } /** diff --git a/src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php b/src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php index a327e94b3321e..1feedc20370bb 100644 --- a/src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php +++ b/src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php @@ -39,14 +39,16 @@ public function toName(): string * some Twig namespace for email images (e.g. '@email/images/logo.png'). * @param string|null $contentType The media type (i.e. MIME type) of the image file (e.g. 'image/png'). * Some email clients require this to display embedded images. + * @param string|null $name A custom file name that overrides the original name (filepath) of the image */ - public function image(string $image, ?string $contentType = null): string + public function image(string $image, ?string $contentType = null, ?string $name = null): string { $file = $this->twig->getLoader()->getSourceContext($image); $body = $file->getPath() ? new File($file->getPath()) : $file->getCode(); - $this->message->addPart((new DataPart($body, $image, $contentType))->asInline()); + $name = $name ?: $image; + $this->message->addPart((new DataPart($body, $name, $contentType))->asInline()); - return 'cid:'.$image; + return 'cid:'.$name; } /** diff --git a/src/Symfony/Bridge/Twig/Node/FormThemeNode.php b/src/Symfony/Bridge/Twig/Node/FormThemeNode.php index 9d9bce1e64fcf..4a73c5ba67f66 100644 --- a/src/Symfony/Bridge/Twig/Node/FormThemeNode.php +++ b/src/Symfony/Bridge/Twig/Node/FormThemeNode.php @@ -28,7 +28,7 @@ final class FormThemeNode extends Node public function __construct(Node $form, Node $resources, int $lineno, $only = false) { if (null === $only || \is_string($only)) { - trigger_deprecation('symfony/twig-bridge', '3.12', 'Passing a tag to %s() is deprecated.', __METHOD__); + trigger_deprecation('symfony/twig-bridge', '7.2', 'Passing a tag to %s() is deprecated.', __METHOD__); $only = \func_num_args() > 4 ? func_get_arg(4) : true; } elseif (!\is_bool($only)) { throw new \TypeError(\sprintf('Argument 4 passed to "%s()" must be a boolean, "%s" given.', __METHOD__, get_debug_type($only))); diff --git a/src/Symfony/Bridge/Twig/Node/TransNode.php b/src/Symfony/Bridge/Twig/Node/TransNode.php index 4064491f1e45a..c675db5610705 100644 --- a/src/Symfony/Bridge/Twig/Node/TransNode.php +++ b/src/Symfony/Bridge/Twig/Node/TransNode.php @@ -16,7 +16,6 @@ use Twig\Node\Expression\AbstractExpression; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\ConstantExpression; -use Twig\Node\Expression\NameExpression; use Twig\Node\Expression\Variable\ContextVariable; use Twig\Node\Node; use Twig\Node\TextNode; @@ -120,7 +119,7 @@ private function compileString(Node $body, ArrayExpression $vars, bool $ignoreSt if ('count' === $var && $this->hasNode('count')) { $vars->addElement($this->getNode('count'), $key); } else { - $varExpr = class_exists(ContextVariable::class) ? new ContextVariable($var, $body->getTemplateLine()) : new NameExpression($var, $body->getTemplateLine()); + $varExpr = new ContextVariable($var, $body->getTemplateLine()); $varExpr->setAttribute('ignore_strict_check', $ignoreStrictCheck); $vars->addElement($varExpr, $key); } diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php index 3b8196fae410e..938d6439fe16b 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php @@ -17,10 +17,8 @@ use Twig\Node\BlockNode; use Twig\Node\EmptyNode; use Twig\Node\Expression\ArrayExpression; -use Twig\Node\Expression\AssignNameExpression; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Expression\FilterExpression; -use Twig\Node\Expression\NameExpression; use Twig\Node\Expression\Variable\AssignContextVariable; use Twig\Node\Expression\Variable\ContextVariable; use Twig\Node\ModuleNode; @@ -60,17 +58,10 @@ public function enterNode(Node $node, Environment $env): Node $var = '__internal_trans_default_domain'.hash('xxh128', $templateName); - if (class_exists(Nodes::class)) { - $name = new AssignContextVariable($var, $node->getTemplateLine()); - $this->scope->set('domain', new ContextVariable($var, $node->getTemplateLine())); + $name = new AssignContextVariable($var, $node->getTemplateLine()); + $this->scope->set('domain', new ContextVariable($var, $node->getTemplateLine())); - return new SetNode(false, new Nodes([$name]), new Nodes([$node->getNode('expr')]), $node->getTemplateLine()); - } - - $name = new AssignNameExpression($var, $node->getTemplateLine()); - $this->scope->set('domain', new NameExpression($var, $node->getTemplateLine())); - - return new SetNode(false, new Node([$name]), new Node([$node->getNode('expr')]), $node->getTemplateLine()); + return new SetNode(false, new Nodes([$name]), new Nodes([$node->getNode('expr')]), $node->getTemplateLine()); } if (!$this->scope->has('domain')) { diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig index 1e421d5f9f5a9..537849faebaa4 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig @@ -89,7 +89,7 @@ {{- block('choice_widget_options') -}} {%- else -%} - + {%- endif -%} {% endfor %} {%- endblock choice_widget_options -%} diff --git a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php index 3b0b453d2e2fe..9e4e23a87e813 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php @@ -94,7 +94,20 @@ public function testLintFileWithReportedDeprecation() $ret = $tester->execute(['filename' => [$filename], '--show-deprecations' => true], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false]); $this->assertEquals(1, $ret, 'Returns 1 in case of error'); - $this->assertMatchesRegularExpression('/ERROR in \S+ \(line 1\)/', trim($tester->getDisplay())); + $this->assertMatchesRegularExpression('/DEPRECATION in \S+ \(line 1\)/', trim($tester->getDisplay())); + $this->assertStringContainsString('Filter "deprecated_filter" is deprecated', trim($tester->getDisplay())); + } + + public function testLintFileWithMultipleReportedDeprecation() + { + $tester = $this->createCommandTester(); + $filename = $this->createFile("{{ foo|deprecated_filter }}\n{{ bar|deprecated_filter }}"); + + $ret = $tester->execute(['filename' => [$filename], '--show-deprecations' => true], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false]); + + $this->assertEquals(1, $ret, 'Returns 1 in case of error'); + $this->assertMatchesRegularExpression('/DEPRECATION in \S+ \(line 1\)/', trim($tester->getDisplay())); + $this->assertMatchesRegularExpression('/DEPRECATION in \S+ \(line 2\)/', trim($tester->getDisplay())); $this->assertStringContainsString('Filter "deprecated_filter" is deprecated', trim($tester->getDisplay())); } @@ -160,11 +173,7 @@ private function createCommandTester(): CommandTester private function createCommand(): Command { $environment = new Environment(new FilesystemLoader(\dirname(__DIR__).'/Fixtures/templates/')); - if (class_exists(DeprecatedCallableInfo::class)) { - $options = ['deprecation_info' => new DeprecatedCallableInfo('foo/bar', '1.1')]; - } else { - $options = ['deprecated' => true]; - } + $options = ['deprecation_info' => new DeprecatedCallableInfo('foo/bar', '1.1')]; $environment->addFilter(new TwigFilter('deprecated_filter', fn ($v) => $v, $options)); $command = new LintCommand($environment); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractDivLayoutTestCase.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractDivLayoutTestCase.php index cfa2c5c6475cf..28e8997a12e9f 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractDivLayoutTestCase.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractDivLayoutTestCase.php @@ -870,6 +870,56 @@ public function testMultipleChoiceExpandedWithLabelsSetFalseByCallable() ); } + public function testSingleChoiceWithoutDuplicatePreferredIsSelected() + { + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&d', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c', 'Choice&D' => '&d'], + 'preferred_choices' => ['&b', '&d'], + 'duplicate_preferred_choices' => false, + 'multiple' => false, + 'expanded' => false, + ]); + + $this->assertWidgetMatchesXpath($form->createView(), ['separator' => '-- sep --'], + '/select + [@name="name"] + [ + ./option[@value="&d"][@selected="selected"] + /following-sibling::option[@disabled="disabled"][.="-- sep --"] + /following-sibling::option[@value="&a"][not(@selected)] + /following-sibling::option[@value="&c"][not(@selected)] + ] + [count(./option)=5] +' + ); + } + + public function testSingleChoiceWithoutDuplicateNotPreferredIsSelected() + { + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&d', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c', 'Choice&D' => '&d'], + 'preferred_choices' => ['&b', '&d'], + 'duplicate_preferred_choices' => true, + 'multiple' => false, + 'expanded' => false, + ]); + + $this->assertWidgetMatchesXpath($form->createView(), ['separator' => '-- sep --'], + '/select + [@name="name"] + [ + ./option[@value="&d"][not(@selected)] + /following-sibling::option[@disabled="disabled"][.="-- sep --"] + /following-sibling::option[@value="&a"][not(@selected)] + /following-sibling::option[@value="&b"][not(@selected)] + /following-sibling::option[@value="&c"][not(@selected)] + /following-sibling::option[@value="&d"][@selected="selected"] + ] + [count(./option)=7] +' + ); + } + public function testFormEndWithRest() { $view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractLayoutTestCase.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractLayoutTestCase.php index 5a541d7bd4124..2f7410d1f7591 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractLayoutTestCase.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractLayoutTestCase.php @@ -1592,7 +1592,7 @@ public function testDateErrorBubbling() $form->get('date')->addError(new FormError('[trans]Error![/trans]')); $view = $form->createView(); - $this->assertEmpty($this->renderErrors($view)); + $this->assertSame('', $this->renderErrors($view)); $this->assertNotEmpty($this->renderErrors($view['date'])); } @@ -2213,7 +2213,7 @@ public function testTimeErrorBubbling() $form->get('time')->addError(new FormError('[trans]Error![/trans]')); $view = $form->createView(); - $this->assertEmpty($this->renderErrors($view)); + $this->assertSame('', $this->renderErrors($view)); $this->assertNotEmpty($this->renderErrors($view['time'])); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php index 8fe455e5d5706..01817ce597c5d 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php @@ -142,6 +142,6 @@ public function testCustomDumper() 'Custom dumper should be used to dump data.' ); - $this->assertEmpty($output, 'Dumper output should be ignored.'); + $this->assertSame('', $output, 'Dumper output should be ignored.'); } } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubTranslator.php b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubTranslator.php index 4c6e672a9af2d..cbbc42b9d196e 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubTranslator.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubTranslator.php @@ -11,12 +11,19 @@ namespace Symfony\Bridge\Twig\Tests\Extension\Fixtures; +use Symfony\Contracts\Translation\TranslatableInterface; use Symfony\Contracts\Translation\TranslatorInterface; class StubTranslator implements TranslatorInterface { public function trans($id, array $parameters = [], $domain = null, $locale = null): string { + foreach ($parameters as $k => $v) { + if ($v instanceof TranslatableInterface) { + $parameters[$k] = $v->trans($this, $locale); + } + } + return '[trans]'.strtr($id, $parameters).'[/trans]'; } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionFieldHelpersTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionFieldHelpersTest.php index efedc871c3480..320b855140c7b 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionFieldHelpersTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionFieldHelpersTest.php @@ -119,6 +119,12 @@ public function testFieldName() $this->assertTrue($this->view->children['username']->isRendered()); } + public function testFieldId() + { + $this->assertSame('register_username', $this->rawExtension->getFieldId($this->view->children['username'])); + $this->assertSame('register_choice_multiple', $this->rawExtension->getFieldId($this->view->children['choice_multiple'])); + } + public function testFieldValue() { $this->assertSame('tgalopin', $this->rawExtension->getFieldValue($this->view->children['username'])); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/SecurityExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/SecurityExtensionTest.php index 2afa868f0364e..e0ca4dcbb6901 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/SecurityExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/SecurityExtensionTest.php @@ -15,12 +15,23 @@ use Symfony\Bridge\PhpUnit\ClassExistsMock; use Symfony\Bridge\Twig\Extension\SecurityExtension; use Symfony\Component\Security\Acl\Voter\FieldVote; +use Symfony\Component\Security\Core\Authorization\AccessDecision; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Authorization\UserAuthorizationCheckerInterface; use Symfony\Component\Security\Core\User\UserInterface; class SecurityExtensionTest extends TestCase { + public static function setUpBeforeClass(): void + { + ClassExistsMock::register(SecurityExtension::class); + } + + protected function tearDown(): void + { + ClassExistsMock::withMockedClasses([FieldVote::class => true]); + } + /** * @dataProvider provideObjectFieldAclCases */ @@ -39,17 +50,16 @@ public function testIsGrantedCreatesFieldVoteObjectWhenFieldNotNull($object, $fi public function testIsGrantedThrowsWhenFieldNotNullAndFieldVoteClassDoesNotExist() { - if (!class_exists(UserAuthorizationCheckerInterface::class)) { + if (!interface_exists(UserAuthorizationCheckerInterface::class)) { $this->markTestSkipped('This test requires symfony/security-core 7.3 or superior.'); } $securityChecker = $this->createMock(AuthorizationCheckerInterface::class); - ClassExistsMock::register(SecurityExtension::class); ClassExistsMock::withMockedClasses([FieldVote::class => false]); $this->expectException(\LogicException::class); - $this->expectExceptionMessageMatches('Passing a $field to the "is_granted()" function requires symfony/acl.'); + $this->expectExceptionMessage('Passing a $field to the "is_granted()" function requires symfony/acl.'); $securityExtension = new SecurityExtension($securityChecker); $securityExtension->isGranted('ROLE', 'object', 'bar'); @@ -60,49 +70,74 @@ public function testIsGrantedThrowsWhenFieldNotNullAndFieldVoteClassDoesNotExist */ public function testIsGrantedForUserCreatesFieldVoteObjectWhenFieldNotNull($object, $field, $expectedSubject) { - if (!class_exists(UserAuthorizationCheckerInterface::class)) { + if (!interface_exists(UserAuthorizationCheckerInterface::class)) { $this->markTestSkipped('This test requires symfony/security-core 7.3 or superior.'); } $user = $this->createMock(UserInterface::class); - $userSecurityChecker = $this->createMock(UserAuthorizationCheckerInterface::class); - $userSecurityChecker - ->expects($this->once()) - ->method('isGrantedForUser') - ->with($user, 'ROLE', $expectedSubject) - ->willReturn(true); + $securityChecker = $this->createMockAuthorizationChecker(); - $securityExtension = new SecurityExtension(null, null, $userSecurityChecker); + $securityExtension = new SecurityExtension($securityChecker); $this->assertTrue($securityExtension->isGrantedForUser($user, 'ROLE', $object, $field)); + $this->assertSame($user, $securityChecker->user); + $this->assertSame('ROLE', $securityChecker->attribute); + + if (null === $field) { + $this->assertSame($object, $securityChecker->subject); + } else { + $this->assertEquals($expectedSubject, $securityChecker->subject); + } + } + + public static function provideObjectFieldAclCases() + { + return [ + [null, null, null], + ['object', null, 'object'], + ['object', false, new FieldVote('object', false)], + ['object', 0, new FieldVote('object', 0)], + ['object', '', new FieldVote('object', '')], + ['object', 'field', new FieldVote('object', 'field')], + ]; } public function testIsGrantedForUserThrowsWhenFieldNotNullAndFieldVoteClassDoesNotExist() { - if (!class_exists(UserAuthorizationCheckerInterface::class)) { + if (!interface_exists(UserAuthorizationCheckerInterface::class)) { $this->markTestSkipped('This test requires symfony/security-core 7.3 or superior.'); } - $securityChecker = $this->createMock(UserAuthorizationCheckerInterface::class); + $securityChecker = $this->createMockAuthorizationChecker(); - ClassExistsMock::register(SecurityExtension::class); ClassExistsMock::withMockedClasses([FieldVote::class => false]); $this->expectException(\LogicException::class); - $this->expectExceptionMessageMatches('Passing a $field to the "is_granted_for_user()" function requires symfony/acl.'); + $this->expectExceptionMessage('Passing a $field to the "is_granted_for_user()" function requires symfony/acl.'); - $securityExtension = new SecurityExtension(null, null, $securityChecker); - $securityExtension->isGrantedForUser($this->createMock(UserInterface::class), 'object', 'bar'); + $securityExtension = new SecurityExtension($securityChecker); + $securityExtension->isGrantedForUser($this->createMock(UserInterface::class), 'ROLE', 'object', 'bar'); } - public static function provideObjectFieldAclCases() + private function createMockAuthorizationChecker(): AuthorizationCheckerInterface&UserAuthorizationCheckerInterface { - return [ - [null, null, null], - ['object', null, 'object'], - ['object', false, new FieldVote('object', false)], - ['object', 0, new FieldVote('object', 0)], - ['object', '', new FieldVote('object', '')], - ['object', 'field', new FieldVote('object', 'field')], - ]; + return new class implements AuthorizationCheckerInterface, UserAuthorizationCheckerInterface { + public UserInterface $user; + public mixed $attribute; + public mixed $subject; + + public function isGranted(mixed $attribute, mixed $subject = null, ?AccessDecision $accessDecision = null): bool + { + throw new \BadMethodCallException('This method should not be called.'); + } + + public function isGrantedForUser(UserInterface $user, mixed $attribute, mixed $subject = null, ?AccessDecision $accessDecision = null): bool + { + $this->user = $user; + $this->attribute = $attribute; + $this->subject = $subject; + + return true; + } + }; } } diff --git a/src/Symfony/Bridge/Twig/Tests/Fixtures/assets/images/logo1.png b/src/Symfony/Bridge/Twig/Tests/Fixtures/assets/images/logo1.png new file mode 100644 index 0000000000000..519ab7c691ba9 Binary files /dev/null and b/src/Symfony/Bridge/Twig/Tests/Fixtures/assets/images/logo1.png differ diff --git a/src/Symfony/Bridge/Twig/Tests/Fixtures/assets/images/logo2.png b/src/Symfony/Bridge/Twig/Tests/Fixtures/assets/images/logo2.png new file mode 120000 index 0000000000000..e9f523cbd5b31 --- /dev/null +++ b/src/Symfony/Bridge/Twig/Tests/Fixtures/assets/images/logo2.png @@ -0,0 +1 @@ +logo1.png \ No newline at end of file diff --git a/src/Symfony/Bridge/Twig/Tests/Fixtures/templates/email/attach.html.twig b/src/Symfony/Bridge/Twig/Tests/Fixtures/templates/email/attach.html.twig new file mode 100644 index 0000000000000..e70e32fbcb757 --- /dev/null +++ b/src/Symfony/Bridge/Twig/Tests/Fixtures/templates/email/attach.html.twig @@ -0,0 +1,3 @@ +

Attachments

+{{ email.attach('@assets/images/logo1.png') }} +{{ email.attach('@assets/images/logo2.png', name='image.png') }} diff --git a/src/Symfony/Bridge/Twig/Tests/Fixtures/templates/email/image.html.twig b/src/Symfony/Bridge/Twig/Tests/Fixtures/templates/email/image.html.twig new file mode 100644 index 0000000000000..074edf4c91b2f --- /dev/null +++ b/src/Symfony/Bridge/Twig/Tests/Fixtures/templates/email/image.html.twig @@ -0,0 +1,2 @@ + + diff --git a/src/Symfony/Bridge/Twig/Tests/Mime/WrappedTemplatedEmailTest.php b/src/Symfony/Bridge/Twig/Tests/Mime/WrappedTemplatedEmailTest.php new file mode 100644 index 0000000000000..428ebc93dc4ab --- /dev/null +++ b/src/Symfony/Bridge/Twig/Tests/Mime/WrappedTemplatedEmailTest.php @@ -0,0 +1,102 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Twig\Tests\Mime; + +use PHPUnit\Framework\TestCase; +use Symfony\Bridge\Twig\Mime\BodyRenderer; +use Symfony\Bridge\Twig\Mime\TemplatedEmail; +use Twig\Environment; +use Twig\Loader\FilesystemLoader; + +/** + * @author Alexander Hofbauer buildEmail('email/image.html.twig'); + $body = $email->toString(); + $contentId1 = $email->getAttachments()[0]->getContentId(); + $contentId2 = $email->getAttachments()[1]->getContentId(); + + $part1 = str_replace("\n", "\r\n", + << + Content-Type: image/png; name="$contentId1" + Content-Transfer-Encoding: base64 + Content-Disposition: inline; + name="$contentId1"; + filename="@assets/images/logo1.png" + + PART + ); + + $part2 = str_replace("\n", "\r\n", + << + Content-Type: image/png; name="$contentId2" + Content-Transfer-Encoding: base64 + Content-Disposition: inline; + name="$contentId2"; filename=image.png + + PART + ); + + self::assertStringContainsString('![](cid:@assets/images/logo1.png)![](cid:image.png)', $body); + self::assertStringContainsString($part1, $body); + self::assertStringContainsString($part2, $body); + } + + public function testEmailAttach() + { + $email = $this->buildEmail('email/attach.html.twig'); + $body = $email->toString(); + + $part1 = str_replace("\n", "\r\n", + <<from('a.hofbauer@fify.at') + ->htmlTemplate($template); + + $loader = new FilesystemLoader(\dirname(__DIR__).'/Fixtures/templates/'); + $loader->addPath(\dirname(__DIR__).'/Fixtures/assets', 'assets'); + + $environment = new Environment($loader); + $renderer = new BodyRenderer($environment); + $renderer->render($email); + + return $email; + } +} diff --git a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php index 6d584c89b44b3..33297ae4a35ba 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php @@ -16,9 +16,7 @@ use Twig\Compiler; use Twig\Environment; use Twig\Loader\LoaderInterface; -use Twig\Node\Expression\NameExpression; use Twig\Node\Expression\Variable\ContextVariable; -use Twig\Node\Node; use Twig\Node\Nodes; class DumpNodeTest extends TestCase @@ -73,15 +71,9 @@ public function testIndented() public function testOneVar() { - if (class_exists(Nodes::class)) { - $vars = new Nodes([ - new ContextVariable('foo', 7), - ]); - } else { - $vars = new Node([ - new NameExpression('foo', 7), - ]); - } + $vars = new Nodes([ + new ContextVariable('foo', 7), + ]); $node = new DumpNode('bar', $vars, 7); @@ -103,18 +95,10 @@ public function testOneVar() public function testMultiVars() { - if (class_exists(Nodes::class)) { - $vars = new Nodes([ - new ContextVariable('foo', 7), - new ContextVariable('bar', 7), - ]); - } else { - $vars = new Node([ - new NameExpression('foo', 7), - new NameExpression('bar', 7), - ]); - } - + $vars = new Nodes([ + new ContextVariable('foo', 7), + new ContextVariable('bar', 7), + ]); $node = new DumpNode('bar', $vars, 7); $env = new Environment($this->createMock(LoaderInterface::class)); diff --git a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php index f98b93da17e8a..e581ff284938e 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php @@ -21,9 +21,7 @@ use Twig\Loader\LoaderInterface; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\ConstantExpression; -use Twig\Node\Expression\NameExpression; use Twig\Node\Expression\Variable\ContextVariable; -use Twig\Node\Node; use Twig\Node\Nodes; class FormThemeTest extends TestCase @@ -32,18 +30,11 @@ class FormThemeTest extends TestCase public function testConstructor() { - $form = class_exists(ContextVariable::class) ? new ContextVariable('form', 0) : new NameExpression('form', 0); - if (class_exists(Nodes::class)) { - $resources = new Nodes([ - new ConstantExpression('tpl1', 0), - new ConstantExpression('tpl2', 0), - ]); - } else { - $resources = new Node([ - new ConstantExpression('tpl1', 0), - new ConstantExpression('tpl2', 0), - ]); - } + $form = new ContextVariable('form', 0); + $resources = new Nodes([ + new ConstantExpression('tpl1', 0), + new ConstantExpression('tpl2', 0), + ]); $node = new FormThemeNode($form, $resources, 0); @@ -54,7 +45,7 @@ public function testConstructor() public function testCompile() { - $form = class_exists(ContextVariable::class) ? new ContextVariable('form', 0) : new NameExpression('form', 0); + $form = new ContextVariable('form', 0); $resources = new ArrayExpression([ new ConstantExpression(1, 0), new ConstantExpression('tpl1', 0), diff --git a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php index ab9113acf5c57..0c0afbfa2a272 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php @@ -18,12 +18,9 @@ use Twig\Extension\CoreExtension; use Twig\Loader\LoaderInterface; use Twig\Node\Expression\ArrayExpression; -use Twig\Node\Expression\ConditionalExpression; use Twig\Node\Expression\ConstantExpression; -use Twig\Node\Expression\NameExpression; use Twig\Node\Expression\Ternary\ConditionalTernary; use Twig\Node\Expression\Variable\ContextVariable; -use Twig\Node\Node; use Twig\Node\Nodes; use Twig\TwigFunction; @@ -31,15 +28,9 @@ class SearchAndRenderBlockNodeTest extends TestCase { public function testCompileWidget() { - if (class_exists(Nodes::class)) { - $arguments = new Nodes([ - new ContextVariable('form', 0), - ]); - } else { - $arguments = new Node([ - new NameExpression('form', 0), - ]); - } + $arguments = new Nodes([ + new ContextVariable('form', 0), + ]); $node = new SearchAndRenderBlockNode(new TwigFunction('form_widget'), $arguments, 0); @@ -56,23 +47,13 @@ public function testCompileWidget() public function testCompileWidgetWithVariables() { - if (class_exists(Nodes::class)) { - $arguments = new Nodes([ - new ContextVariable('form', 0), - new ArrayExpression([ - new ConstantExpression('foo', 0), - new ConstantExpression('bar', 0), - ], 0), - ]); - } else { - $arguments = new Node([ - new NameExpression('form', 0), - new ArrayExpression([ - new ConstantExpression('foo', 0), - new ConstantExpression('bar', 0), - ], 0), - ]); - } + $arguments = new Nodes([ + new ContextVariable('form', 0), + new ArrayExpression([ + new ConstantExpression('foo', 0), + new ConstantExpression('bar', 0), + ], 0), + ]); $node = new SearchAndRenderBlockNode(new TwigFunction('form_widget'), $arguments, 0); @@ -89,17 +70,10 @@ public function testCompileWidgetWithVariables() public function testCompileLabelWithLabel() { - if (class_exists(Nodes::class)) { - $arguments = new Nodes([ - new ContextVariable('form', 0), - new ConstantExpression('my label', 0), - ]); - } else { - $arguments = new Node([ - new NameExpression('form', 0), - new ConstantExpression('my label', 0), - ]); - } + $arguments = new Nodes([ + new ContextVariable('form', 0), + new ConstantExpression('my label', 0), + ]); $node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0); @@ -116,17 +90,10 @@ public function testCompileLabelWithLabel() public function testCompileLabelWithNullLabel() { - if (class_exists(Nodes::class)) { - $arguments = new Nodes([ - new ContextVariable('form', 0), - new ConstantExpression(null, 0), - ]); - } else { - $arguments = new Node([ - new NameExpression('form', 0), - new ConstantExpression(null, 0), - ]); - } + $arguments = new Nodes([ + new ContextVariable('form', 0), + new ConstantExpression(null, 0), + ]); $node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0); @@ -145,17 +112,10 @@ public function testCompileLabelWithNullLabel() public function testCompileLabelWithEmptyStringLabel() { - if (class_exists(Nodes::class)) { - $arguments = new Nodes([ - new ContextVariable('form', 0), - new ConstantExpression('', 0), - ]); - } else { - $arguments = new Node([ - new NameExpression('form', 0), - new ConstantExpression('', 0), - ]); - } + $arguments = new Nodes([ + new ContextVariable('form', 0), + new ConstantExpression('', 0), + ]); $node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0); @@ -174,15 +134,9 @@ public function testCompileLabelWithEmptyStringLabel() public function testCompileLabelWithDefaultLabel() { - if (class_exists(Nodes::class)) { - $arguments = new Nodes([ - new ContextVariable('form', 0), - ]); - } else { - $arguments = new Node([ - new NameExpression('form', 0), - ]); - } + $arguments = new Nodes([ + new ContextVariable('form', 0), + ]); $node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0); @@ -199,25 +153,14 @@ public function testCompileLabelWithDefaultLabel() public function testCompileLabelWithAttributes() { - if (class_exists(Nodes::class)) { - $arguments = new Nodes([ - new ContextVariable('form', 0), - new ConstantExpression(null, 0), - new ArrayExpression([ - new ConstantExpression('foo', 0), - new ConstantExpression('bar', 0), - ], 0), - ]); - } else { - $arguments = new Node([ - new NameExpression('form', 0), - new ConstantExpression(null, 0), - new ArrayExpression([ - new ConstantExpression('foo', 0), - new ConstantExpression('bar', 0), - ], 0), - ]); - } + $arguments = new Nodes([ + new ContextVariable('form', 0), + new ConstantExpression(null, 0), + new ArrayExpression([ + new ConstantExpression('foo', 0), + new ConstantExpression('bar', 0), + ], 0), + ]); $node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0); @@ -237,29 +180,16 @@ public function testCompileLabelWithAttributes() public function testCompileLabelWithLabelAndAttributes() { - if (class_exists(Nodes::class)) { - $arguments = new Nodes([ - new ContextVariable('form', 0), - new ConstantExpression('value in argument', 0), - new ArrayExpression([ - new ConstantExpression('foo', 0), - new ConstantExpression('bar', 0), - new ConstantExpression('label', 0), - new ConstantExpression('value in attributes', 0), - ], 0), - ]); - } else { - $arguments = new Node([ - new NameExpression('form', 0), - new ConstantExpression('value in argument', 0), - new ArrayExpression([ - new ConstantExpression('foo', 0), - new ConstantExpression('bar', 0), - new ConstantExpression('label', 0), - new ConstantExpression('value in attributes', 0), - ], 0), - ]); - } + $arguments = new Nodes([ + new ContextVariable('form', 0), + new ConstantExpression('value in argument', 0), + new ArrayExpression([ + new ConstantExpression('foo', 0), + new ConstantExpression('bar', 0), + new ConstantExpression('label', 0), + new ConstantExpression('value in attributes', 0), + ], 0), + ]); $node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0); @@ -276,33 +206,17 @@ public function testCompileLabelWithLabelAndAttributes() public function testCompileLabelWithLabelThatEvaluatesToNull() { - if (class_exists(ConditionalTernary::class)) { - $conditional = new ConditionalTernary( - // if - new ConstantExpression(true, 0), - // then - new ConstantExpression(null, 0), - // else - new ConstantExpression(null, 0), - 0 - ); - } else { - $conditional = new ConditionalExpression( - // if - new ConstantExpression(true, 0), - // then - new ConstantExpression(null, 0), - // else - new ConstantExpression(null, 0), - 0 - ); - } - - if (class_exists(Nodes::class)) { - $arguments = new Nodes([new ContextVariable('form', 0), $conditional]); - } else { - $arguments = new Node([new NameExpression('form', 0), $conditional]); - } + $conditional = new ConditionalTernary( + // if + new ConstantExpression(true, 0), + // then + new ConstantExpression(null, 0), + // else + new ConstantExpression(null, 0), + 0 + ); + + $arguments = new Nodes([new ContextVariable('form', 0), $conditional]); $node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0); @@ -323,51 +237,26 @@ public function testCompileLabelWithLabelThatEvaluatesToNull() public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes() { - if (class_exists(ConditionalTernary::class)) { - $conditional = new ConditionalTernary( - // if - new ConstantExpression(true, 0), - // then - new ConstantExpression(null, 0), - // else - new ConstantExpression(null, 0), - 0 - ); - } else { - $conditional = new ConditionalExpression( - // if - new ConstantExpression(true, 0), - // then - new ConstantExpression(null, 0), - // else - new ConstantExpression(null, 0), - 0 - ); - } - - if (class_exists(Nodes::class)) { - $arguments = new Nodes([ - new ContextVariable('form', 0), - $conditional, - new ArrayExpression([ - new ConstantExpression('foo', 0), - new ConstantExpression('bar', 0), - new ConstantExpression('label', 0), - new ConstantExpression('value in attributes', 0), - ], 0), - ]); - } else { - $arguments = new Node([ - new NameExpression('form', 0), - $conditional, - new ArrayExpression([ - new ConstantExpression('foo', 0), - new ConstantExpression('bar', 0), - new ConstantExpression('label', 0), - new ConstantExpression('value in attributes', 0), - ], 0), - ]); - } + $conditional = new ConditionalTernary( + // if + new ConstantExpression(true, 0), + // then + new ConstantExpression(null, 0), + // else + new ConstantExpression(null, 0), + 0 + ); + + $arguments = new Nodes([ + new ContextVariable('form', 0), + $conditional, + new ArrayExpression([ + new ConstantExpression('foo', 0), + new ConstantExpression('bar', 0), + new ConstantExpression('label', 0), + new ConstantExpression('value in attributes', 0), + ], 0), + ]); $node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0); diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php index 24fa4d255a037..5a55a0c846bb8 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -16,7 +16,6 @@ use Twig\Compiler; use Twig\Environment; use Twig\Loader\LoaderInterface; -use Twig\Node\Expression\NameExpression; use Twig\Node\Expression\Variable\ContextVariable; use Twig\Node\TextNode; @@ -28,7 +27,7 @@ class TransNodeTest extends TestCase public function testCompileStrict() { $body = new TextNode('trans %var%', 0); - $vars = class_exists(ContextVariable::class) ? new ContextVariable('foo', 0) : new NameExpression('foo', 0); + $vars = new ContextVariable('foo', 0); $node = new TransNode($body, null, null, $vars); $env = new Environment($this->createMock(LoaderInterface::class), ['strict_variables' => true]); diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php index 2d52c4ea5d427..fc48beb6caba1 100644 --- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php @@ -18,7 +18,6 @@ use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Expression\FilterExpression; -use Twig\Node\Expression\NameExpression; use Twig\Node\Expression\Variable\ContextVariable; use Twig\Node\Node; use Twig\Node\Nodes; @@ -41,17 +40,10 @@ public function testMessageExtractionWithInvalidDomainNode() { $message = 'new key'; - if (class_exists(Nodes::class)) { - $n = new Nodes([ - new ArrayExpression([], 0), - new ContextVariable('variable', 0), - ]); - } else { - $n = new Node([ - new ArrayExpression([], 0), - new NameExpression('variable', 0), - ]); - } + $n = new Nodes([ + new ArrayExpression([], 0), + new ContextVariable('variable', 0), + ]); $node = new FilterExpression( new ConstantExpression($message, 0), diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php index a6910855e38b1..4a0f11b365944 100644 --- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php +++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php @@ -14,11 +14,11 @@ use Symfony\Bridge\Twig\Node\TransDefaultDomainNode; use Symfony\Bridge\Twig\Node\TransNode; use Twig\Node\BodyNode; +use Twig\Node\EmptyNode; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Expression\FilterExpression; use Twig\Node\ModuleNode; -use Twig\Node\Node; use Twig\Node\Nodes; use Twig\Source; use Twig\TwigFilter; @@ -30,10 +30,10 @@ public static function getModule($content) return new ModuleNode( new BodyNode([new ConstantExpression($content, 0)]), null, - new ArrayExpression([], 0), - new ArrayExpression([], 0), - new ArrayExpression([], 0), - null, + new EmptyNode(), + new EmptyNode(), + new EmptyNode(), + new EmptyNode(), new Source('', '') ); } @@ -47,16 +47,10 @@ public static function getTransFilter($message, $domain = null, $arguments = nul ] : []; } - if (class_exists(Nodes::class)) { - $args = new Nodes($arguments); - } else { - $args = new Node($arguments); - } - return new FilterExpression( new ConstantExpression($message, 0), new TwigFilter('trans'), - $args, + new Nodes($arguments), 0 ); } diff --git a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php index 4e8209ef33f6a..0c4bcdf62f89b 100644 --- a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php +++ b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php @@ -18,7 +18,6 @@ use Twig\Loader\LoaderInterface; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\ConstantExpression; -use Twig\Node\Expression\NameExpression; use Twig\Node\Expression\Variable\ContextVariable; use Twig\Parser; use Twig\Source; @@ -48,7 +47,7 @@ public static function getTestsForFormTheme() [ '{% form_theme form "tpl1" %}', new FormThemeNode( - class_exists(ContextVariable::class) ? new ContextVariable('form', 1) : new NameExpression('form', 1), + new ContextVariable('form', 1), new ArrayExpression([ new ConstantExpression(0, 1), new ConstantExpression('tpl1', 1), @@ -59,7 +58,7 @@ class_exists(ContextVariable::class) ? new ContextVariable('form', 1) : new Name [ '{% form_theme form "tpl1" "tpl2" %}', new FormThemeNode( - class_exists(ContextVariable::class) ? new ContextVariable('form', 1) : new NameExpression('form', 1), + new ContextVariable('form', 1), new ArrayExpression([ new ConstantExpression(0, 1), new ConstantExpression('tpl1', 1), @@ -72,7 +71,7 @@ class_exists(ContextVariable::class) ? new ContextVariable('form', 1) : new Name [ '{% form_theme form with "tpl1" %}', new FormThemeNode( - class_exists(ContextVariable::class) ? new ContextVariable('form', 1) : new NameExpression('form', 1), + new ContextVariable('form', 1), new ConstantExpression('tpl1', 1), 1 ), @@ -80,7 +79,7 @@ class_exists(ContextVariable::class) ? new ContextVariable('form', 1) : new Name [ '{% form_theme form with ["tpl1"] %}', new FormThemeNode( - class_exists(ContextVariable::class) ? new ContextVariable('form', 1) : new NameExpression('form', 1), + new ContextVariable('form', 1), new ArrayExpression([ new ConstantExpression(0, 1), new ConstantExpression('tpl1', 1), @@ -91,7 +90,7 @@ class_exists(ContextVariable::class) ? new ContextVariable('form', 1) : new Name [ '{% form_theme form with ["tpl1", "tpl2"] %}', new FormThemeNode( - class_exists(ContextVariable::class) ? new ContextVariable('form', 1) : new NameExpression('form', 1), + new ContextVariable('form', 1), new ArrayExpression([ new ConstantExpression(0, 1), new ConstantExpression('tpl1', 1), @@ -104,7 +103,7 @@ class_exists(ContextVariable::class) ? new ContextVariable('form', 1) : new Name [ '{% form_theme form with ["tpl1", "tpl2"] only %}', new FormThemeNode( - class_exists(ContextVariable::class) ? new ContextVariable('form', 1) : new NameExpression('form', 1), + new ContextVariable('form', 1), new ArrayExpression([ new ConstantExpression(0, 1), new ConstantExpression('tpl1', 1), diff --git a/src/Symfony/Component/Validator/Tests/Constraints/SlugTest.php b/src/Symfony/Bridge/Twig/Tests/Validator/Constraints/TwigTest.php similarity index 60% rename from src/Symfony/Component/Validator/Tests/Constraints/SlugTest.php rename to src/Symfony/Bridge/Twig/Tests/Validator/Constraints/TwigTest.php index a2c5b07d3f873..cac1b316cbeda 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/SlugTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Validator/Constraints/TwigTest.php @@ -9,39 +9,48 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Validator\Tests\Constraints; +namespace Symfony\Bridge\Twig\Tests\Validator\Constraints; use PHPUnit\Framework\TestCase; -use Symfony\Component\Validator\Constraints\Slug; +use Symfony\Bridge\Twig\Validator\Constraints\Twig; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\AttributeLoader; -class SlugTest extends TestCase +/** + * @author Mokhtar Tlili + */ +class TwigTest extends TestCase { public function testAttributes() { - $metadata = new ClassMetadata(SlugDummy::class); + $metadata = new ClassMetadata(TwigDummy::class); $loader = new AttributeLoader(); self::assertTrue($loader->loadClassMetadata($metadata)); [$bConstraint] = $metadata->properties['b']->getConstraints(); self::assertSame('myMessage', $bConstraint->message); - self::assertSame(['Default', 'SlugDummy'], $bConstraint->groups); + self::assertSame(['Default', 'TwigDummy'], $bConstraint->groups); [$cConstraint] = $metadata->properties['c']->getConstraints(); self::assertSame(['my_group'], $cConstraint->groups); self::assertSame('some attached data', $cConstraint->payload); + + [$dConstraint] = $metadata->properties['d']->getConstraints(); + self::assertFalse($dConstraint->skipDeprecations); } } -class SlugDummy +class TwigDummy { - #[Slug] + #[Twig] private $a; - #[Slug(message: 'myMessage')] + #[Twig(message: 'myMessage')] private $b; - #[Slug(groups: ['my_group'], payload: 'some attached data')] + #[Twig(groups: ['my_group'], payload: 'some attached data')] private $c; + + #[Twig(skipDeprecations: false)] + private $d; } diff --git a/src/Symfony/Bridge/Twig/Tests/Validator/Constraints/TwigValidatorTest.php b/src/Symfony/Bridge/Twig/Tests/Validator/Constraints/TwigValidatorTest.php new file mode 100644 index 0000000000000..da5597ad1f45f --- /dev/null +++ b/src/Symfony/Bridge/Twig/Tests/Validator/Constraints/TwigValidatorTest.php @@ -0,0 +1,126 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Twig\Tests\Validator\Constraints; + +use Symfony\Bridge\Twig\Validator\Constraints\Twig; +use Symfony\Bridge\Twig\Validator\Constraints\TwigValidator; +use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; +use Twig\DeprecatedCallableInfo; +use Twig\Environment; +use Twig\Loader\ArrayLoader; +use Twig\TwigFilter; + +/** + * @author Mokhtar Tlili + */ +class TwigValidatorTest extends ConstraintValidatorTestCase +{ + protected function createValidator(): TwigValidator + { + $environment = new Environment(new ArrayLoader()); + $environment->addFilter(new TwigFilter('humanize_filter', fn ($v) => $v)); + if (class_exists(DeprecatedCallableInfo::class)) { + $options = ['deprecation_info' => new DeprecatedCallableInfo('foo/bar', '1.1')]; + } else { + $options = ['deprecated' => true]; + } + + $environment->addFilter(new TwigFilter('deprecated_filter', fn ($v) => $v, $options)); + + return new TwigValidator($environment); + } + + /** + * @dataProvider getValidValues + */ + public function testTwigIsValid($value) + { + $this->validator->validate($value, new Twig()); + + $this->assertNoViolation(); + } + + /** + * @dataProvider getInvalidValues + */ + public function testInvalidValues($value, $message, $line) + { + $constraint = new Twig('myMessageTest'); + + $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessageTest') + ->setParameter('{{ error }}', $message) + ->setParameter('{{ line }}', $line) + ->setCode(Twig::INVALID_TWIG_ERROR) + ->assertRaised(); + } + + /** + * When deprecations are skipped by the validator, the testsuite reporter will catch them so we need to mark the test as legacy. + * + * @group legacy + */ + public function testTwigWithSkipDeprecation() + { + $constraint = new Twig(skipDeprecations: true); + + $this->validator->validate('{{ name|deprecated_filter }}', $constraint); + + $this->assertNoViolation(); + } + + public function testTwigWithoutSkipDeprecation() + { + $constraint = new Twig(skipDeprecations: false); + + $this->validator->validate('{{ name|deprecated_filter }}', $constraint); + + $line = 1; + $error = 'Twig Filter "deprecated_filter" is deprecated in at line 1 at line 1.'; + if (class_exists(DeprecatedCallableInfo::class)) { + $line = 0; + $error = 'Since foo/bar 1.1: Twig Filter "deprecated_filter" is deprecated.'; + } + $this->buildViolation($constraint->message) + ->setParameter('{{ error }}', $error) + ->setParameter('{{ line }}', $line) + ->setCode(Twig::INVALID_TWIG_ERROR) + ->assertRaised(); + } + + public static function getValidValues() + { + return [ + ['Hello {{ name }}'], + ['{% if condition %}Yes{% else %}No{% endif %}'], + ['{# Comment #}'], + ['Hello {{ "world"|upper }}'], + ['{% for i in 1..3 %}Item {{ i }}{% endfor %}'], + ['{{ name|humanize_filter }}'], + ]; + } + + public static function getInvalidValues() + { + return [ + // Invalid syntax example (missing end tag) + ['{% if condition %}Oops', 'Unexpected end of template at line 1.', 1], + // Another syntax error example (unclosed variable) + ['Hello {{ name', 'Unexpected token "end of template" ("end of print statement" expected) at line 1.', 1], + // Unknown filter error + ['Hello {{ name|unknown_filter }}', 'Unknown "unknown_filter" filter at line 1.', 1], + // Invalid variable syntax + ['Hello {{ .name }}', 'Unexpected token "operator" of value "." at line 1.', 1], + ]; + } +} diff --git a/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php index e671f9ba0b7dd..457edece240ba 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php @@ -14,6 +14,7 @@ use Symfony\Bridge\Twig\Node\DumpNode; use Twig\Node\Expression\Variable\LocalVariable; use Twig\Node\Node; +use Twig\Node\Nodes; use Twig\Token; use Twig\TokenParser\AbstractTokenParser; @@ -34,11 +35,24 @@ public function parse(Token $token): Node { $values = null; if (!$this->parser->getStream()->test(Token::BLOCK_END_TYPE)) { - $values = $this->parser->getExpressionParser()->parseMultitargetExpression(); + $values = $this->parseMultitargetExpression(); } $this->parser->getStream()->expect(Token::BLOCK_END_TYPE); - return new DumpNode(class_exists(LocalVariable::class) ? new LocalVariable(null, $token->getLine()) : $this->parser->getVarName(), $values, $token->getLine(), $this->getTag()); + return new DumpNode(new LocalVariable(null, $token->getLine()), $values, $token->getLine()); + } + + private function parseMultitargetExpression(): Node + { + $targets = []; + while (true) { + $targets[] = $this->parser->parseExpression(); + if (!$this->parser->getStream()->nextIf(Token::PUNCTUATION_TYPE, ',')) { + break; + } + } + + return new Nodes($targets); } public function getTag(): string diff --git a/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php index 413a8f51ed02f..347634bddb6de 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php @@ -29,12 +29,12 @@ public function parse(Token $token): Node $lineno = $token->getLine(); $stream = $this->parser->getStream(); - $form = $this->parser->getExpressionParser()->parseExpression(); + $form = $this->parser->parseExpression(); $only = false; if ($this->parser->getStream()->test(Token::NAME_TYPE, 'with')) { $this->parser->getStream()->next(); - $resources = $this->parser->getExpressionParser()->parseExpression(); + $resources = $this->parser->parseExpression(); if ($this->parser->getStream()->nextIf(Token::NAME_TYPE, 'only')) { $only = true; @@ -42,7 +42,7 @@ public function parse(Token $token): Node } else { $resources = new ArrayExpression([], $stream->getCurrent()->getLine()); do { - $resources->addElement($this->parser->getExpressionParser()->parseExpression()); + $resources->addElement($this->parser->parseExpression()); } while (!$stream->test(Token::BLOCK_END_TYPE)); } diff --git a/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php index ac6baa6d88fa8..ea0382bc6c874 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php @@ -12,7 +12,6 @@ namespace Symfony\Bridge\Twig\TokenParser; use Symfony\Bridge\Twig\Node\StopwatchNode; -use Twig\Node\Expression\AssignNameExpression; use Twig\Node\Expression\Variable\LocalVariable; use Twig\Node\Node; use Twig\Token; @@ -36,7 +35,7 @@ public function parse(Token $token): Node $stream = $this->parser->getStream(); // {% stopwatch 'bar' %} - $name = $this->parser->getExpressionParser()->parseExpression(); + $name = $this->parser->parseExpression(); $stream->expect(Token::BLOCK_END_TYPE); @@ -45,7 +44,7 @@ public function parse(Token $token): Node $stream->expect(Token::BLOCK_END_TYPE); if ($this->stopwatchIsAvailable) { - return new StopwatchNode($name, $body, class_exists(LocalVariable::class) ? new LocalVariable(null, $token->getLine()) : new AssignNameExpression($this->parser->getVarName(), $token->getLine()), $lineno, $this->getTag()); + return new StopwatchNode($name, $body, new LocalVariable(null, $token->getLine()), $lineno); } return $body; diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php index c6d850d07cbf7..b9eb5f5112577 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php @@ -25,11 +25,11 @@ final class TransDefaultDomainTokenParser extends AbstractTokenParser { public function parse(Token $token): Node { - $expr = $this->parser->getExpressionParser()->parseExpression(); + $expr = $this->parser->parseExpression(); $this->parser->getStream()->expect(Token::BLOCK_END_TYPE); - return new TransDefaultDomainNode($expr, $token->getLine(), $this->getTag()); + return new TransDefaultDomainNode($expr, $token->getLine()); } public function getTag(): string diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php index 67b92dd8d55fd..d4353742707d7 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php @@ -36,29 +36,30 @@ public function parse(Token $token): Node $vars = new ArrayExpression([], $lineno); $domain = null; $locale = null; + if (!$stream->test(Token::BLOCK_END_TYPE)) { if ($stream->test('count')) { // {% trans count 5 %} $stream->next(); - $count = $this->parser->getExpressionParser()->parseExpression(); + $count = $this->parser->parseExpression(); } if ($stream->test('with')) { // {% trans with vars %} $stream->next(); - $vars = $this->parser->getExpressionParser()->parseExpression(); + $vars = $this->parser->parseExpression(); } if ($stream->test('from')) { // {% trans from "messages" %} $stream->next(); - $domain = $this->parser->getExpressionParser()->parseExpression(); + $domain = $this->parser->parseExpression(); } if ($stream->test('into')) { // {% trans into "fr" %} $stream->next(); - $locale = $this->parser->getExpressionParser()->parseExpression(); + $locale = $this->parser->parseExpression(); } elseif (!$stream->test(Token::BLOCK_END_TYPE)) { throw new SyntaxError('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext()); } diff --git a/src/Symfony/Bridge/Twig/Validator/Constraints/Twig.php b/src/Symfony/Bridge/Twig/Validator/Constraints/Twig.php new file mode 100644 index 0000000000000..7cf050e87a32e --- /dev/null +++ b/src/Symfony/Bridge/Twig/Validator/Constraints/Twig.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Twig\Validator\Constraints; + +use Symfony\Component\Validator\Attribute\HasNamedArguments; +use Symfony\Component\Validator\Constraint; + +/** + * @author Mokhtar Tlili + */ +#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] +class Twig extends Constraint +{ + public const INVALID_TWIG_ERROR = 'e7fc55d5-e586-4cc1-924e-d27ee7fcd1b5'; + + protected const ERROR_NAMES = [ + self::INVALID_TWIG_ERROR => 'INVALID_TWIG_ERROR', + ]; + + #[HasNamedArguments] + public function __construct( + public string $message = 'This value is not a valid Twig template.', + public bool $skipDeprecations = true, + ?array $groups = null, + mixed $payload = null, + ) { + parent::__construct(null, $groups, $payload); + } +} diff --git a/src/Symfony/Bridge/Twig/Validator/Constraints/TwigValidator.php b/src/Symfony/Bridge/Twig/Validator/Constraints/TwigValidator.php new file mode 100644 index 0000000000000..3064341f3b10d --- /dev/null +++ b/src/Symfony/Bridge/Twig/Validator/Constraints/TwigValidator.php @@ -0,0 +1,85 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Twig\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; +use Symfony\Component\Validator\Exception\UnexpectedValueException; +use Twig\Environment; +use Twig\Error\Error; +use Twig\Loader\ArrayLoader; +use Twig\Source; + +/** + * @author Mokhtar Tlili + */ +class TwigValidator extends ConstraintValidator +{ + public function __construct(private Environment $twig) + { + } + + public function validate(mixed $value, Constraint $constraint): void + { + if (!$constraint instanceof Twig) { + throw new UnexpectedTypeException($constraint, Twig::class); + } + + if (null === $value || '' === $value) { + return; + } + + if (!\is_scalar($value) && !$value instanceof \Stringable) { + throw new UnexpectedValueException($value, 'string'); + } + + $value = (string) $value; + + $realLoader = $this->twig->getLoader(); + try { + $temporaryLoader = new ArrayLoader([$value]); + $this->twig->setLoader($temporaryLoader); + + if (!$constraint->skipDeprecations) { + $prevErrorHandler = set_error_handler(static function ($level, $message, $file, $line) use (&$prevErrorHandler) { + if (\E_USER_DEPRECATED !== $level) { + return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false; + } + + $templateLine = 0; + if (preg_match('/ at line (\d+)[ .]/', $message, $matches)) { + $templateLine = $matches[1]; + } + + throw new Error($message, $templateLine); + }); + } + + try { + $this->twig->parse($this->twig->tokenize(new Source($value, ''))); + } finally { + if (!$constraint->skipDeprecations) { + restore_error_handler(); + } + } + } catch (Error $e) { + $this->context->buildViolation($constraint->message) + ->setParameter('{{ error }}', $e->getMessage()) + ->setParameter('{{ line }}', $e->getTemplateLine()) + ->setCode(Twig::INVALID_TWIG_ERROR) + ->addViolation(); + } finally { + $this->twig->setLoader($realLoader); + } + } +} diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index ca751c3f54ae7..dd2e55d752dc1 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -19,7 +19,7 @@ "php": ">=8.2", "symfony/deprecation-contracts": "^2.5|^3", "symfony/translation-contracts": "^2.5|^3", - "twig/twig": "^3.12" + "twig/twig": "^3.21" }, "require-dev": { "egulias/email-validator": "^2.1.10|^3|^4", @@ -30,7 +30,7 @@ "symfony/dependency-injection": "^6.4|^7.0", "symfony/emoji": "^7.1", "symfony/finder": "^6.4|^7.0", - "symfony/form": "^6.4|^7.0", + "symfony/form": "^6.4.20|^7.2.5", "symfony/html-sanitizer": "^6.4|^7.0", "symfony/http-foundation": "^7.3", "symfony/http-kernel": "^6.4|^7.0", @@ -40,6 +40,7 @@ "symfony/property-info": "^6.4|^7.0", "symfony/routing": "^6.4|^7.0", "symfony/translation": "^6.4|^7.0", + "symfony/validator": "^6.4|^7.0", "symfony/yaml": "^6.4|^7.0", "symfony/security-acl": "^2.8|^3.0", "symfony/security-core": "^6.4|^7.0", @@ -51,9 +52,9 @@ "symfony/expression-language": "^6.4|^7.0", "symfony/web-link": "^6.4|^7.0", "symfony/workflow": "^6.4|^7.0", - "twig/cssinliner-extra": "^2.12|^3", - "twig/inky-extra": "^2.12|^3", - "twig/markdown-extra": "^2.12|^3" + "twig/cssinliner-extra": "^3", + "twig/inky-extra": "^3", + "twig/markdown-extra": "^3" }, "conflict": { "phpdocumentor/reflection-docblock": "<3.2.2", diff --git a/src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php index 4dbdc4c7abb81..a72034d98293a 100644 --- a/src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php @@ -26,7 +26,9 @@ public function getConfigTreeBuilder(): TreeBuilder $treeBuilder = new TreeBuilder('debug'); $rootNode = $treeBuilder->getRootNode(); - $rootNode->children() + $rootNode + ->docUrl('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/debug.html', 'symfony/debug-bundle') + ->children() ->integerNode('max_items') ->info('Max number of displayed items past the first level, -1 means no limit.') ->min(-1) diff --git a/src/Symfony/Bundle/DebugBundle/composer.json b/src/Symfony/Bundle/DebugBundle/composer.json index d00a4db6424c0..31b480091abdc 100644 --- a/src/Symfony/Bundle/DebugBundle/composer.json +++ b/src/Symfony/Bundle/DebugBundle/composer.json @@ -18,19 +18,16 @@ "require": { "php": ">=8.2", "ext-xml": "*", + "composer-runtime-api": ">=2.1", + "symfony/config": "^7.3", "symfony/dependency-injection": "^6.4|^7.0", "symfony/http-kernel": "^6.4|^7.0", "symfony/twig-bridge": "^6.4|^7.0", "symfony/var-dumper": "^6.4|^7.0" }, "require-dev": { - "symfony/config": "^6.4|^7.0", "symfony/web-profiler-bundle": "^6.4|^7.0" }, - "conflict": { - "symfony/config": "<6.4", - "symfony/dependency-injection": "<6.4" - }, "autoload": { "psr-4": { "Symfony\\Bundle\\DebugBundle\\": "" }, "exclude-from-classmap": [ diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index 55eeaf1fdc1f3..ce62c9cdf836b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -4,14 +4,58 @@ CHANGELOG 7.3 --- + * Add `errors.php` and `webhook.php` routing configuration files (use them instead of their XML equivalent) + + Before: + + ```yaml + when@dev: + _errors: + resource: '@FrameworkBundle/Resources/config/routing/errors.xml' + prefix: /_error + + webhook: + resource: '@FrameworkBundle/Resources/config/routing/webhook.xml' + prefix: /webhook + ``` + + After: + + ```yaml + when@dev: + _errors: + resource: '@FrameworkBundle/Resources/config/routing/errors.php' + prefix: /_error + + webhook: + resource: '@FrameworkBundle/Resources/config/routing/webhook.php' + prefix: /webhook + ``` + + * Add support for the ObjectMapper component * Add support for assets pre-compression * Rename `TranslationUpdateCommand` to `TranslationExtractCommand` - * Add JsonEncoder services and configuration + * Add JsonStreamer services and configuration * Add new `framework.property_info.with_constructor_extractor` option to allow enabling or disabling the constructor extractor integration * Deprecate the `--show-arguments` option of the `container:debug` command, as arguments are now always shown - * Add `RateLimiterFactoryInterface` as an alias of the `limiter` service + * Add autowiring alias for `RateLimiterFactoryInterface` * Add `framework.validation.disable_translation` option * Add support for signal plain name in the `messenger.stop_worker_on_signals` configuration + * Deprecate the `framework.validation.cache` option + * Add `--method` option to the `debug:router` command + * Auto-exclude DI extensions, test cases, entities and messenger messages + * Add DI alias from `ServicesResetterInterface` to `services_resetter` + * Add `methods` argument in `#[IsCsrfTokenValid]` attribute + * Allow configuring the logging channel per type of exceptions + * Enable service argument resolution on classes that use the `#[Route]` attribute, + the `#[AsController]` attribute is no longer required + * Deprecate setting the `framework.profiler.collect_serializer_data` config option to `false` + * Set `framework.rate_limiter.limiters.*.lock_factory` to `auto` by default + * Deprecate `RateLimiterFactory` autowiring aliases, use `RateLimiterFactoryInterface` instead + * Allow configuring compound rate limiters + * Make `ValidatorCacheWarmer` use `kernel.build_dir` instead of `cache_dir` + * Make `SerializeCacheWarmer` use `kernel.build_dir` instead of `cache_dir` + * Support executing custom workflow validators during container compilation 7.2 --- diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php index 46da4daaab4d1..fbf7083b70b28 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php @@ -41,6 +41,9 @@ public function __construct( protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter, ?string $buildDir = null): bool { + if (!$buildDir) { + return false; + } if (!$this->loaders) { return true; } diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php index 6ecaa4bd14d01..9c313f80a8662 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php @@ -41,6 +41,10 @@ public function __construct( protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter, ?string $buildDir = null): bool { + if (!$buildDir) { + return false; + } + $loaders = $this->validatorBuilder->getLoaders(); $metadataFactory = new LazyLoadingMetadataFactory(new LoaderChain($loaders), $arrayAdapter); diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php index 55c101e9c29e3..8d5f85ceea4ca 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php @@ -104,6 +104,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io->title( \sprintf('Current configuration for %s', $name === $extensionAlias ? \sprintf('extension with alias "%s"', $extensionAlias) : \sprintf('"%s"', $name)) ); + + if ($docUrl = $this->getDocUrl($extension, $container)) { + $io->comment(\sprintf('Documentation at %s', $docUrl)); + } } $io->writeln($this->convertToFormat([$extensionAlias => $config], $format)); @@ -269,4 +273,15 @@ private function getAvailableFormatOptions(): array { return ['txt', 'yaml', 'json']; } + + private function getDocUrl(ExtensionInterface $extension, ContainerBuilder $container): ?string + { + $configuration = $extension instanceof ConfigurationInterface ? $extension : $extension->getConfiguration($container->getExtensionConfig($extension->getAlias()), $container); + + return $configuration + ->getConfigTreeBuilder() + ->getRootNode() + ->getNode(true) + ->getAttribute('docUrl'); + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php index 7e5cd765fd2d3..3cb744d746cae 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php @@ -23,6 +23,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface; use Symfony\Component\Yaml\Yaml; /** @@ -123,6 +124,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $message .= \sprintf(' at path "%s"', $path); } + if ($docUrl = $this->getExtensionDocUrl($extension)) { + $message .= \sprintf(' (see %s)', $docUrl); + } + switch ($format) { case 'yaml': $io->writeln(\sprintf('# %s', $message)); @@ -182,4 +187,18 @@ private function getAvailableFormatOptions(): array { return ['yaml', 'xml']; } + + private function getExtensionDocUrl(ConfigurationInterface|ConfigurationExtensionInterface $extension): ?string + { + $kernel = $this->getApplication()->getKernel(); + $container = $this->getContainerBuilder($kernel); + + $configuration = $extension instanceof ConfigurationInterface ? $extension : $extension->getConfiguration($container->getExtensionConfig($extension->getAlias()), $container); + + return $configuration + ->getConfigTreeBuilder() + ->getRootNode() + ->getNode(true) + ->getAttribute('docUrl'); + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php index e794e88c48473..d71fd6810fd13 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php @@ -24,6 +24,7 @@ use Symfony\Component\DependencyInjection\Compiler\CheckTypeDeclarationsPass; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\Compiler\ResolveFactoryClassPass; +use Symfony\Component\DependencyInjection\Compiler\ResolveParameterPlaceHoldersPass; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; @@ -49,8 +50,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io = new SymfonyStyle($input, $output); $errorIo = $io->getErrorStyle(); + $resolveEnvVars = $input->getOption('resolve-env-vars'); + try { - $container = $this->getContainerBuilder(); + $container = $this->getContainerBuilder($resolveEnvVars); } catch (RuntimeException $e) { $errorIo->error($e->getMessage()); @@ -60,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $container->setParameter('container.build_time', time()); try { - $container->compile((bool) $input->getOption('resolve-env-vars')); + $container->compile($resolveEnvVars); } catch (InvalidArgumentException $e) { $errorIo->error($e->getMessage()); @@ -72,7 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - private function getContainerBuilder(): ContainerBuilder + private function getContainerBuilder(bool $resolveEnvVars): ContainerBuilder { if (isset($this->container)) { return $this->container; @@ -99,16 +102,22 @@ private function getContainerBuilder(): ContainerBuilder (new XmlFileLoader($container = new ContainerBuilder($parameterBag = new EnvPlaceholderParameterBag()), new FileLocator()))->load($kernelContainer->getParameter('debug.container.dump')); - $refl = new \ReflectionProperty($parameterBag, 'resolved'); - $refl->setValue($parameterBag, true); + if ($resolveEnvVars) { + $container->getCompilerPassConfig()->setOptimizationPasses([new ResolveParameterPlaceHoldersPass(), new ResolveFactoryClassPass()]); + } else { + $refl = new \ReflectionProperty($parameterBag, 'resolved'); + $refl->setValue($parameterBag, true); + + $container->getCompilerPassConfig()->setOptimizationPasses([new ResolveFactoryClassPass()]); + } $container->getCompilerPassConfig()->setBeforeOptimizationPasses([]); - $container->getCompilerPassConfig()->setOptimizationPasses([new ResolveFactoryClassPass()]); $container->getCompilerPassConfig()->setBeforeRemovingPasses([]); } $container->setParameter('container.build_hash', 'lint_container'); $container->setParameter('container.build_id', 'lint_container'); + $container->setParameter('container.runtime_mode', 'web=0'); $container->addCompilerPass(new CheckAliasValidityPass(), PassConfig::TYPE_BEFORE_REMOVING, -100); $container->addCompilerPass(new CheckTypeDeclarationsPass(true), PassConfig::TYPE_AFTER_REMOVING, -100); diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php index 13a6f75d01230..e543771150fc5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php @@ -55,6 +55,7 @@ protected function configure(): void new InputOption('show-aliases', null, InputOption::VALUE_NONE, 'Show aliases in overview'), new InputOption('format', null, InputOption::VALUE_REQUIRED, \sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), 'txt'), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw route(s)'), + new InputOption('method', null, InputOption::VALUE_REQUIRED, 'Filter by HTTP method', '', ['GET', 'POST', 'PUT', 'DELETE', 'PATCH']), ]) ->setHelp(<<<'EOF' The %command.name% displays the configured routes: @@ -76,6 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $name = $input->getArgument('name'); + $method = strtoupper($input->getOption('method')); $helper = new DescriptorHelper($this->fileLinkFormatter); $routes = $this->router->getRouteCollection(); $container = null; @@ -85,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($name) { $route = $routes->get($name); - $matchingRoutes = $this->findRouteNameContaining($name, $routes); + $matchingRoutes = $this->findRouteNameContaining($name, $routes, $method); if (!$input->isInteractive() && !$route && \count($matchingRoutes) > 1) { $helper->describe($io, $this->findRouteContaining($name, $routes), [ @@ -94,6 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'show_controllers' => $input->getOption('show-controllers'), 'show_aliases' => $input->getOption('show-aliases'), 'output' => $io, + 'method' => $method, ]); return 0; @@ -124,17 +127,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'show_aliases' => $input->getOption('show-aliases'), 'output' => $io, 'container' => $container, + 'method' => $method, ]); } return 0; } - private function findRouteNameContaining(string $name, RouteCollection $routes): array + private function findRouteNameContaining(string $name, RouteCollection $routes, string $method): array { $foundRoutesNames = []; foreach ($routes as $routeName => $route) { - if (false !== stripos($routeName, $name)) { + if (false !== stripos($routeName, $name) && (!$method || !$route->getMethods() || \in_array($method, $route->getMethods(), true))) { $foundRoutesNames[] = $routeName; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsGenerateKeysCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsGenerateKeysCommand.php index 66a752eac7e47..f721c786e42b1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsGenerateKeysCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsGenerateKeysCommand.php @@ -63,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $vault = $input->getOption('local') ? $this->localVault : $this->vault; if (null === $vault) { - $io->success('The local vault is disabled.'); + $io->error('The local vault is disabled.'); return 1; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsRemoveCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsRemoveCommand.php index 11660b00d778a..59bbe8211fa40 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsRemoveCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsRemoveCommand.php @@ -59,7 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $vault = $input->getOption('local') ? $this->localVault : $this->vault; if (null === $vault) { - $io->success('The local vault is disabled.'); + $io->error('The local vault is disabled.'); return 1; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsRevealCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsRevealCommand.php index 150186b1d37ba..c2110ee76f683 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsRevealCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsRevealCommand.php @@ -61,6 +61,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!\array_key_exists($name, $secrets)) { $io->error(\sprintf('The secret "%s" does not exist.', $name)); + return self::INVALID; + } elseif (null === $secrets[$name]) { + $io->error(\sprintf('The secret "%s" could not be decrypted.', $name)); + return self::INVALID; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php index 9cdfdae04cb37..a320130d5a6e7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php @@ -69,7 +69,7 @@ protected function configure(): void ->setDefinition([ new InputArgument('locale', InputArgument::REQUIRED, 'The locale'), new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages'), - new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'The messages domain'), + new InputOption('domain', null, InputOption::VALUE_REQUIRED, 'The messages domain'), new InputOption('only-missing', null, InputOption::VALUE_NONE, 'Display only missing messages'), new InputOption('only-unused', null, InputOption::VALUE_NONE, 'Display only unused messages'), new InputOption('all', null, InputOption::VALUE_NONE, 'Load messages from all registered bundles'), diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationExtractCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationExtractCommand.php index d7967bbe8cc85..c8e61b61a64a0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationExtractCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationExtractCommand.php @@ -72,15 +72,15 @@ protected function configure(): void ->setDefinition([ new InputArgument('locale', InputArgument::REQUIRED, 'The locale'), new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages'), - new InputOption('prefix', null, InputOption::VALUE_OPTIONAL, 'Override the default prefix', '__'), + new InputOption('prefix', null, InputOption::VALUE_REQUIRED, 'Override the default prefix', '__'), new InputOption('no-fill', null, InputOption::VALUE_NONE, 'Extract translation keys without filling in values'), - new InputOption('format', null, InputOption::VALUE_OPTIONAL, 'Override the default output format', 'xlf12'), + new InputOption('format', null, InputOption::VALUE_REQUIRED, 'Override the default output format', 'xlf12'), new InputOption('dump-messages', null, InputOption::VALUE_NONE, 'Should the messages be dumped in the console'), new InputOption('force', null, InputOption::VALUE_NONE, 'Should the extract be done'), new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'), - new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to extract'), - new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically'), - new InputOption('as-tree', null, InputOption::VALUE_OPTIONAL, 'Dump the messages as a tree-like structure: The given value defines the level where to switch to inline YAML'), + new InputOption('domain', null, InputOption::VALUE_REQUIRED, 'Specify the domain to extract'), + new InputOption('sort', null, InputOption::VALUE_REQUIRED, 'Return list of messages sorted alphabetically'), + new InputOption('as-tree', null, InputOption::VALUE_REQUIRED, 'Dump the messages as a tree-like structure: The given value defines the level where to switch to inline YAML'), ]) ->setHelp(<<<'EOF' The %command.name% command extracts translation strings from templates diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php index af5c3b10ac415..e76b742474a37 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php @@ -49,7 +49,7 @@ public function describe(OutputInterface $output, mixed $object, array $options } match (true) { - $object instanceof RouteCollection => $this->describeRouteCollection($object, $options), + $object instanceof RouteCollection => $this->describeRouteCollection($this->filterRoutesByHttpMethod($object, $options['method'] ?? ''), $options), $object instanceof Route => $this->describeRoute($object, $options), $object instanceof ParameterBag => $this->describeContainerParameters($object, $options), $object instanceof ContainerBuilder && !empty($options['env-vars']) => $this->describeContainerEnvVars($this->getContainerEnvVars($object), $options), @@ -360,4 +360,20 @@ protected function getServiceEdges(ContainerBuilder $container, string $serviceI return []; } } + + private function filterRoutesByHttpMethod(RouteCollection $routes, string $method): RouteCollection + { + if (!$method) { + return $routes; + } + $filteredRoutes = clone $routes; + + foreach ($filteredRoutes as $routeName => $route) { + if ($route->getMethods() && !\in_array($method, $route->getMethods(), true)) { + $filteredRoutes->remove($routeName); + } + } + + return $filteredRoutes; + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php index af453619b5ab8..de7395d5a83f7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php @@ -35,6 +35,7 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Symfony\Component\Security\Core\Authorization\AccessDecision; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\User\UserInterface; @@ -202,6 +203,21 @@ protected function isGranted(mixed $attribute, mixed $subject = null): bool return $this->container->get('security.authorization_checker')->isGranted($attribute, $subject); } + /** + * Checks if the attribute is granted against the current authentication token and optionally supplied subject. + */ + protected function getAccessDecision(mixed $attribute, mixed $subject = null): AccessDecision + { + if (!$this->container->has('security.authorization_checker')) { + throw new \LogicException('The SecurityBundle is not registered in your application. Try running "composer require symfony/security-bundle".'); + } + + $accessDecision = new AccessDecision(); + $accessDecision->isGranted = $this->container->get('security.authorization_checker')->isGranted($attribute, $subject, $accessDecision); + + return $accessDecision; + } + /** * Throws an exception unless the attribute is granted against the current authentication token and optionally * supplied subject. @@ -210,12 +226,24 @@ protected function isGranted(mixed $attribute, mixed $subject = null): bool */ protected function denyAccessUnlessGranted(mixed $attribute, mixed $subject = null, string $message = 'Access Denied.'): void { - if (!$this->isGranted($attribute, $subject)) { - $exception = $this->createAccessDeniedException($message); - $exception->setAttributes([$attribute]); - $exception->setSubject($subject); + if (class_exists(AccessDecision::class)) { + $accessDecision = $this->getAccessDecision($attribute, $subject); + $isGranted = $accessDecision->isGranted; + } else { + $accessDecision = null; + $isGranted = $this->isGranted($attribute, $subject); + } + + if (!$isGranted) { + $e = $this->createAccessDeniedException(3 > \func_num_args() && $accessDecision ? $accessDecision->getMessage() : $message); + $e->setAttributes([$attribute]); + $e->setSubject($subject); + + if ($accessDecision) { + $e->setAccessDecision($accessDecision); + } - throw $exception; + throw $e; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php index 5714f8fc2e6a5..53361e3127e34 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php @@ -53,8 +53,7 @@ class UnusedTagsPass implements CompilerPassInterface 'form.type_guesser', 'html_sanitizer', 'http_client.client', - 'json_encoder.denormalizer', - 'json_encoder.normalizer', + 'json_streamer.value_transformer', 'kernel.cache_clearer', 'kernel.cache_warmer', 'kernel.event_listener', @@ -107,6 +106,8 @@ class UnusedTagsPass implements CompilerPassInterface 'validator.group_provider', 'validator.initializer', 'workflow', + 'object_mapper.transform_callable', + 'object_mapper.condition_callable', ]; public function process(ContainerBuilder $container): void diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index f5279c419f094..d66a5c6fff8b6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -31,7 +31,7 @@ use Symfony\Component\HttpClient\HttpClient; use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\IpUtils; -use Symfony\Component\JsonEncoder\EncoderInterface; +use Symfony\Component\JsonStreamer\StreamWriterInterface; use Symfony\Component\Lock\Lock; use Symfony\Component\Lock\Store\SemaphoreStore; use Symfony\Component\Mailer\Mailer; @@ -51,6 +51,7 @@ use Symfony\Component\Validator\Validation; use Symfony\Component\Webhook\Controller\WebhookController; use Symfony\Component\WebLink\HttpHeaderSerializer; +use Symfony\Component\Workflow\Validator\DefinitionValidatorInterface; use Symfony\Component\Workflow\WorkflowEvents; /** @@ -75,6 +76,7 @@ public function getConfigTreeBuilder(): TreeBuilder $rootNode = $treeBuilder->getRootNode(); $rootNode + ->docUrl('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/framework.html', 'symfony/framework-bundle') ->beforeNormalization() ->ifTrue(fn ($v) => !isset($v['assets']) && isset($v['templating']) && class_exists(Package::class)) ->then(function ($v) { @@ -182,7 +184,7 @@ public function getConfigTreeBuilder(): TreeBuilder $this->addHtmlSanitizerSection($rootNode, $enableIfStandalone); $this->addWebhookSection($rootNode, $enableIfStandalone); $this->addRemoteEventSection($rootNode, $enableIfStandalone); - $this->addJsonEncoderSection($rootNode, $enableIfStandalone); + $this->addJsonStreamerSection($rootNode, $enableIfStandalone); return $treeBuilder; } @@ -253,6 +255,8 @@ private function addFormSection(ArrayNodeDefinition $rootNode, callable $enableI ->scalarNode('field_name')->defaultValue('_token')->end() ->arrayNode('field_attr') ->performNoDeepMerging() + ->normalizeKeys(false) + ->useAttributeAsKey('name') ->scalarPrototype()->end() ->defaultValue(['data-controller' => 'csrf-protection']) ->end() @@ -400,6 +404,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode): void ->useAttributeAsKey('name') ->prototype('array') ->fixXmlConfig('support') + ->fixXmlConfig('definition_validator') ->fixXmlConfig('place') ->fixXmlConfig('transition') ->fixXmlConfig('event_to_dispatch', 'events_to_dispatch') @@ -429,11 +434,28 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode): void ->prototype('scalar') ->cannotBeEmpty() ->validate() - ->ifTrue(fn ($v) => !class_exists($v) && !interface_exists($v, false)) + ->ifTrue(static fn ($v) => !class_exists($v) && !interface_exists($v, false)) ->thenInvalid('The supported class or interface "%s" does not exist.') ->end() ->end() ->end() + ->arrayNode('definition_validators') + ->prototype('scalar') + ->cannotBeEmpty() + ->validate() + ->ifTrue(static fn ($v) => !class_exists($v)) + ->thenInvalid('The validation class %s does not exist.') + ->end() + ->validate() + ->ifTrue(static fn ($v) => !is_a($v, DefinitionValidatorInterface::class, true)) + ->thenInvalid(\sprintf('The validation class %%s is not an instance of "%s".', DefinitionValidatorInterface::class)) + ->end() + ->validate() + ->ifTrue(static fn ($v) => 1 <= (new \ReflectionClass($v))->getConstructor()?->getNumberOfRequiredParameters()) + ->thenInvalid('The %s validation class constructor must not have any arguments.') + ->end() + ->end() + ->end() ->scalarNode('support_strategy') ->cannotBeEmpty() ->end() @@ -445,7 +467,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode): void ->variableNode('events_to_dispatch') ->defaultValue(null) ->validate() - ->ifTrue(function ($v) { + ->ifTrue(static function ($v) { if (null === $v) { return false; } @@ -472,14 +494,14 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode): void ->arrayNode('places') ->beforeNormalization() ->always() - ->then(function ($places) { + ->then(static function ($places) { if (!\is_array($places)) { throw new InvalidConfigurationException('The "places" option must be an array in workflow configuration.'); } // It's an indexed array of shape ['place1', 'place2'] if (isset($places[0]) && \is_string($places[0])) { - return array_map(function (string $place) { + return array_map(static function (string $place) { return ['name' => $place]; }, $places); } @@ -519,7 +541,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode): void ->arrayNode('transitions') ->beforeNormalization() ->always() - ->then(function ($transitions) { + ->then(static function ($transitions) { if (!\is_array($transitions)) { throw new InvalidConfigurationException('The "transitions" option must be an array in workflow configuration.'); } @@ -586,20 +608,20 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode): void ->end() ->end() ->validate() - ->ifTrue(function ($v) { + ->ifTrue(static function ($v) { return $v['supports'] && isset($v['support_strategy']); }) ->thenInvalid('"supports" and "support_strategy" cannot be used together.') ->end() ->validate() - ->ifTrue(function ($v) { + ->ifTrue(static function ($v) { return !$v['supports'] && !isset($v['support_strategy']); }) ->thenInvalid('"supports" or "support_strategy" should be configured.') ->end() ->beforeNormalization() ->always() - ->then(function ($values) { + ->then(static function ($values) { // Special case to deal with XML when the user wants an empty array if (\array_key_exists('event_to_dispatch', $values) && null === $values['event_to_dispatch']) { $values['events_to_dispatch'] = []; @@ -966,6 +988,7 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode, callable $e ->fixXmlConfig('fallback') ->fixXmlConfig('path') ->fixXmlConfig('provider') + ->fixXmlConfig('global') ->children() ->arrayNode('fallbacks') ->info('Defaults to the value of "default_locale".') @@ -1020,6 +1043,33 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode, callable $e ->end() ->defaultValue([]) ->end() + ->arrayNode('globals') + ->info('Global parameters.') + ->example(['app_version' => 3.14]) + ->normalizeKeys(false) + ->useAttributeAsKey('name') + ->arrayPrototype() + ->fixXmlConfig('parameter') + ->children() + ->variableNode('value')->end() + ->stringNode('message')->end() + ->arrayNode('parameters') + ->normalizeKeys(false) + ->useAttributeAsKey('name') + ->scalarPrototype()->end() + ->end() + ->stringNode('domain')->end() + ->end() + ->beforeNormalization() + ->ifTrue(static fn ($v) => !\is_array($v)) + ->then(static fn ($v) => ['value' => $v]) + ->end() + ->validate() + ->ifTrue(static fn ($v) => !(isset($v['value']) xor isset($v['message']))) + ->thenInvalid('The "globals" parameter should be either a string or an array with a "value" or a "message" key') + ->end() + ->end() + ->end() ->end() ->end() ->end() @@ -1034,7 +1084,9 @@ private function addValidationSection(ArrayNodeDefinition $rootNode, callable $e ->info('Validation configuration') ->{$enableIfStandalone('symfony/validator', Validation::class)}() ->children() - ->scalarNode('cache')->end() + ->scalarNode('cache') + ->setDeprecated('symfony/framework-bundle', '7.3', 'Setting the "%path%.%node%" configuration option is deprecated. It will be removed in version 8.0.') + ->end() ->booleanNode('enable_attributes')->{class_exists(FullStack::class) ? 'defaultFalse' : 'defaultTrue'}()->end() ->arrayNode('static_method') ->defaultValue(['loadValidatorMetadata']) @@ -1043,7 +1095,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode, callable $e ->validate()->castToArray()->end() ->end() ->scalarNode('translation_domain')->defaultValue('validators')->end() - ->enumNode('email_validation_mode')->values(['html5', 'loose', 'strict'])->defaultValue('html5')->end() + ->enumNode('email_validation_mode')->values(['html5', 'html5-allow-no-tld', 'strict', 'loose'])->defaultValue('html5')->end() ->arrayNode('mapping') ->addDefaultsIfNotSet() ->fixXmlConfig('path') @@ -1237,7 +1289,7 @@ private function addPropertyInfoSection(ArrayNodeDefinition $rootNode, callable ->then(function ($v) { $v['property_info']['with_constructor_extractor'] = false; - trigger_deprecation('symfony/framework-bundle', '7.3', 'Not setting the "with_constructor_extractor" option explicitly is deprecated because its default value will change in version 8.0.'); + trigger_deprecation('symfony/framework-bundle', '7.3', 'Not setting the "property_info.with_constructor_extractor" option explicitly is deprecated because its default value will change in version 8.0.'); return $v; }) @@ -1282,6 +1334,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode, callable $willBe ->scalarNode('directory')->defaultValue('%kernel.cache_dir%/pools/app')->end() ->scalarNode('default_psr6_provider')->end() ->scalarNode('default_redis_provider')->defaultValue('redis://localhost')->end() + ->scalarNode('default_valkey_provider')->defaultValue('valkey://localhost')->end() ->scalarNode('default_memcached_provider')->defaultValue('memcached://localhost')->end() ->scalarNode('default_doctrine_dbal_provider')->defaultValue('database_connection')->end() ->scalarNode('default_pdo_provider')->defaultValue($willBeAvailable('doctrine/dbal', Connection::class) && class_exists(DoctrineAdapter::class) ? 'database_connection' : null)->end() @@ -1426,6 +1479,10 @@ private function addExceptionsSection(ArrayNodeDefinition $rootNode): void ->end() ->defaultNull() ->end() + ->scalarNode('log_channel') + ->info('The channel of log message. Null to let Symfony decide.') + ->defaultNull() + ->end() ->end() ->end() ->end() @@ -2312,8 +2369,8 @@ private function addMailerSection(ArrayNodeDefinition $rootNode, callable $enabl ->canBeEnabled() ->info('S/MIME encrypter configuration') ->children() - ->scalarNode('certificate') - ->info('Path to certificate (in PEM format without the `file://` prefix)') + ->scalarNode('repository') + ->info('S/MIME certificate repository service. This service shall implement the `Symfony\Component\Mailer\EventListener\SmimeCertificateRepositoryInterface`.') ->defaultValue('') ->cannotBeEmpty() ->end() @@ -2468,7 +2525,7 @@ private function addRateLimiterSection(ArrayNodeDefinition $rootNode, callable $ ->children() ->scalarNode('lock_factory') ->info('The service ID of the lock factory used by this limiter (or null to disable locking).') - ->defaultValue('lock.factory') + ->defaultValue('auto') ->end() ->scalarNode('cache_pool') ->info('The cache pool to use for storing the current limiter state.') @@ -2481,7 +2538,12 @@ private function addRateLimiterSection(ArrayNodeDefinition $rootNode, callable $ ->enumNode('policy') ->info('The algorithm to be used by this limiter.') ->isRequired() - ->values(['fixed_window', 'token_bucket', 'sliding_window', 'no_limit']) + ->values(['fixed_window', 'token_bucket', 'sliding_window', 'compound', 'no_limit']) + ->end() + ->arrayNode('limiters') + ->info('The limiter names to use when using the "compound" policy.') + ->beforeNormalization()->castToArray()->end() + ->scalarPrototype()->end() ->end() ->integerNode('limit') ->info('The maximum allowed hits in a fixed interval or burst.') @@ -2500,8 +2562,8 @@ private function addRateLimiterSection(ArrayNodeDefinition $rootNode, callable $ ->end() ->end() ->validate() - ->ifTrue(fn ($v) => 'no_limit' !== $v['policy'] && !isset($v['limit'])) - ->thenInvalid('A limit must be provided when using a policy different than "no_limit".') + ->ifTrue(static fn ($v) => !\in_array($v['policy'], ['no_limit', 'compound']) && !isset($v['limit'])) + ->thenInvalid('A limit must be provided when using a policy different than "compound" or "no_limit".') ->end() ->end() ->end() @@ -2689,13 +2751,13 @@ private function addHtmlSanitizerSection(ArrayNodeDefinition $rootNode, callable ; } - private function addJsonEncoderSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone): void + private function addJsonStreamerSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone): void { $rootNode ->children() - ->arrayNode('json_encoder') - ->info('JSON encoder configuration') - ->{$enableIfStandalone('symfony/json-encoder', EncoderInterface::class)}() + ->arrayNode('json_streamer') + ->info('JSON streamer configuration') + ->{$enableIfStandalone('symfony/json-streamer', StreamWriterInterface::class)}() ->end() ->end() ; diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index bc1d623e75be9..0cf63bfea9fca 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -12,12 +12,16 @@ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection; use Composer\InstalledVersions; +use Doctrine\ORM\Mapping\Embeddable; +use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\MappedSuperclass; use Http\Client\HttpAsyncClient; use Http\Client\HttpClient; use phpDocumentor\Reflection\DocBlockFactoryInterface; use phpDocumentor\Reflection\Types\ContextFactory; use PhpParser\Parser; use PHPStan\PhpDocParser\Parser\PhpDocParser; +use PHPUnit\Framework\TestCase; use Psr\Cache\CacheItemPoolInterface; use Psr\Clock\ClockInterface as PsrClockInterface; use Psr\Container\ContainerInterface as PsrContainerInterface; @@ -55,8 +59,11 @@ use Symfony\Component\Console\Debug\CliRequest; use Symfony\Component\Console\Messenger\RunCommandMessageHandler; use Symfony\Component\DependencyInjection\Alias; +use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; +use Symfony\Component\DependencyInjection\Attribute\Target; use Symfony\Component\DependencyInjection\ChildDefinition; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -100,12 +107,12 @@ use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\HttpKernel\Log\DebugLoggerConfigurator; -use Symfony\Component\JsonEncoder\Attribute\JsonEncodable; -use Symfony\Component\JsonEncoder\Decode\Denormalizer\DenormalizerInterface as JsonEncoderDenormalizerInterface; -use Symfony\Component\JsonEncoder\DecoderInterface as JsonEncoderDecoderInterface; -use Symfony\Component\JsonEncoder\Encode\Normalizer\NormalizerInterface as JsonEncoderNormalizerInterface; -use Symfony\Component\JsonEncoder\EncoderInterface as JsonEncoderEncoderInterface; -use Symfony\Component\JsonEncoder\JsonEncoder; +use Symfony\Component\HttpKernel\Profiler\ProfilerStateChecker; +use Symfony\Component\JsonStreamer\Attribute\JsonStreamable; +use Symfony\Component\JsonStreamer\JsonStreamWriter; +use Symfony\Component\JsonStreamer\StreamReaderInterface; +use Symfony\Component\JsonStreamer\StreamWriterInterface; +use Symfony\Component\JsonStreamer\ValueTransformer\ValueTransformerInterface; use Symfony\Component\Lock\LockFactory; use Symfony\Component\Lock\LockInterface; use Symfony\Component\Lock\PersistingStoreInterface; @@ -118,8 +125,10 @@ use Symfony\Component\Mailer\EventListener\SmimeSignedMessageListener; use Symfony\Component\Mailer\Mailer; use Symfony\Component\Mercure\HubRegistry; +use Symfony\Component\Messenger\Attribute\AsMessage; use Symfony\Component\Messenger\Attribute\AsMessageHandler; use Symfony\Component\Messenger\Bridge as MessengerBridge; +use Symfony\Component\Messenger\EventListener\ResetMemoryUsageListener; use Symfony\Component\Messenger\Handler\BatchHandlerInterface; use Symfony\Component\Messenger\MessageBus; use Symfony\Component\Messenger\MessageBusInterface; @@ -139,6 +148,9 @@ use Symfony\Component\Notifier\Recipient\Recipient; use Symfony\Component\Notifier\TexterInterface; use Symfony\Component\Notifier\Transport\TransportFactoryInterface as NotifierTransportFactoryInterface; +use Symfony\Component\ObjectMapper\ConditionCallableInterface; +use Symfony\Component\ObjectMapper\ObjectMapperInterface; +use Symfony\Component\ObjectMapper\TransformCallableInterface; use Symfony\Component\Process\Messenger\RunProcessMessageHandler; use Symfony\Component\PropertyAccess\PropertyAccessor; use Symfony\Component\PropertyInfo\Extractor\ConstructorArgumentTypeExtractorInterface; @@ -150,11 +162,14 @@ use Symfony\Component\PropertyInfo\PropertyInitializableExtractorInterface; use Symfony\Component\PropertyInfo\PropertyListExtractorInterface; use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface; +use Symfony\Component\RateLimiter\CompoundRateLimiterFactory; use Symfony\Component\RateLimiter\LimiterInterface; use Symfony\Component\RateLimiter\RateLimiterFactory; +use Symfony\Component\RateLimiter\RateLimiterFactoryInterface; use Symfony\Component\RateLimiter\Storage\CacheStorage; use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer; use Symfony\Component\RemoteEvent\RemoteEvent; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Scheduler\Attribute\AsCronTask; use Symfony\Component\Scheduler\Attribute\AsPeriodicTask; use Symfony\Component\Scheduler\Attribute\AsSchedule; @@ -186,6 +201,7 @@ use Symfony\Component\Translation\Extractor\PhpAstExtractor; use Symfony\Component\Translation\LocaleSwitcher; use Symfony\Component\Translation\PseudoLocalizationTranslator; +use Symfony\Component\Translation\TranslatableMessage; use Symfony\Component\Translation\Translator; use Symfony\Component\TypeInfo\Type; use Symfony\Component\TypeInfo\TypeResolver\PhpDocAwareReflectionTypeResolver; @@ -193,6 +209,7 @@ use Symfony\Component\TypeInfo\TypeResolver\TypeResolverInterface; use Symfony\Component\Uid\Factory\UuidFactory; use Symfony\Component\Uid\UuidV4; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\ExpressionLanguageProvider; use Symfony\Component\Validator\ConstraintValidatorInterface; use Symfony\Component\Validator\GroupProviderInterface; @@ -207,6 +224,7 @@ use Symfony\Component\Yaml\Yaml; use Symfony\Contracts\Cache\CacheInterface; use Symfony\Contracts\Cache\CallbackInterface; +use Symfony\Contracts\Cache\NamespacedPoolInterface; use Symfony\Contracts\Cache\TagAwareCacheInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -285,6 +303,10 @@ public function load(array $configs, ContainerBuilder $container): void // Load Cache configuration first as it is used by other components $loader->load('cache.php'); + if (!interface_exists(NamespacedPoolInterface::class)) { + $container->removeAlias(NamespacedPoolInterface::class); + } + $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); @@ -409,7 +431,20 @@ public function load(array $configs, ContainerBuilder $container): void $this->registerPropertyAccessConfiguration($config['property_access'], $container, $loader); $this->registerSecretsConfiguration($config['secrets'], $container, $loader, $config['secret'] ?? null); - $container->getDefinition('exception_listener')->replaceArgument(3, $config['exceptions']); + $exceptionListener = $container->getDefinition('exception_listener'); + + $loggers = []; + foreach ($config['exceptions'] as $exception) { + if (!isset($exception['log_channel'])) { + continue; + } + $loggers[$exception['log_channel']] = new Reference('monolog.logger.'.$exception['log_channel'], ContainerInterface::NULL_ON_INVALID_REFERENCE); + } + + $exceptionListener + ->replaceArgument(3, $config['exceptions']) + ->setArgument(4, $loggers) + ; if ($this->readConfigEnabled('serializer', $container, $config['serializer'])) { if (!class_exists(Serializer::class)) { @@ -437,12 +472,12 @@ public function load(array $configs, ContainerBuilder $container): void $this->registerPropertyInfoConfiguration($config['property_info'], $container, $loader); } - if ($this->readConfigEnabled('json_encoder', $container, $config['json_encoder'])) { + if ($this->readConfigEnabled('json_streamer', $container, $config['json_streamer'])) { if (!$typeInfoEnabled) { - throw new LogicException('JsonEncoder support cannot be enabled as the TypeInfo component is not '.(interface_exists(TypeResolverInterface::class) ? 'enabled.' : 'installed. Try running "composer require symfony/type-info".')); + throw new LogicException('JsonStreamer support cannot be enabled as the TypeInfo component is not '.(interface_exists(TypeResolverInterface::class) ? 'enabled.' : 'installed. Try running "composer require symfony/type-info".')); } - $this->registerJsonEncoderConfiguration($config['json_encoder'], $container, $loader); + $this->registerJsonStreamerConfiguration($config['json_streamer'], $container, $loader); } if ($this->readConfigEnabled('lock', $container, $config['lock'])) { @@ -539,9 +574,9 @@ public function load(array $configs, ContainerBuilder $container): void $container->removeDefinition('console.command.scheduler_debug'); } - // messenger depends on validation being registered + // messenger depends on validation, and lock being registered if ($messengerEnabled) { - $this->registerMessengerConfiguration($config['messenger'], $container, $loader, $this->readConfigEnabled('validation', $container, $config['validation']), $this->readConfigEnabled('lock', $container, $config['lock'])); + $this->registerMessengerConfiguration($config['messenger'], $container, $loader, $this->readConfigEnabled('validation', $container, $config['validation']), $this->readConfigEnabled('lock', $container, $config['lock']) && ($config['lock']['resources']['default'] ?? false)); } else { $container->removeDefinition('console.command.messenger_consume_messages'); $container->removeDefinition('console.command.messenger_stats'); @@ -612,6 +647,14 @@ public function load(array $configs, ContainerBuilder $container): void $loader->load('mime_type.php'); } + if (ContainerBuilder::willBeAvailable('symfony/object-mapper', ObjectMapperInterface::class, ['symfony/framework-bundle'])) { + $loader->load('object_mapper.php'); + $container->registerForAutoconfiguration(TransformCallableInterface::class) + ->addTag('object_mapper.transform_callable'); + $container->registerForAutoconfiguration(ConditionCallableInterface::class) + ->addTag('object_mapper.condition_callable'); + } + $container->registerForAutoconfiguration(PackageInterface::class) ->addTag('assets.package'); $container->registerForAutoconfiguration(AssetCompilerInterface::class) @@ -644,7 +687,7 @@ public function load(array $configs, ContainerBuilder $container): void $container->registerForAutoconfiguration(DataCollectorInterface::class) ->addTag('data_collector'); $container->registerForAutoconfiguration(FormTypeInterface::class) - ->addTag('form.type'); + ->addTag('form.type', ['csrf_token_id' => '%.form.type_extension.csrf.token_id%']); $container->registerForAutoconfiguration(FormTypeGuesserInterface::class) ->addTag('form.type_guesser'); $container->registerForAutoconfiguration(FormTypeExtensionInterface::class) @@ -715,6 +758,9 @@ public function load(array $configs, ContainerBuilder $container): void $container->registerAttributeForAutoconfiguration(AsController::class, static function (ChildDefinition $definition, AsController $attribute): void { $definition->addTag('controller.service_arguments'); }); + $container->registerAttributeForAutoconfiguration(Route::class, static function (ChildDefinition $definition, Route $attribute, \ReflectionClass|\ReflectionMethod $reflection): void { + $definition->addTag('controller.service_arguments'); + }); $container->registerAttributeForAutoconfiguration(AsRemoteEventConsumer::class, static function (ChildDefinition $definition, AsRemoteEventConsumer $attribute): void { $definition->addTag('remote_event.consumer', ['consumer' => $attribute->name]); }); @@ -756,12 +802,36 @@ static function (ChildDefinition $definition, AsPeriodicTask|AsCronTask $attribu } ); } - $container->registerAttributeForAutoconfiguration(JsonEncodable::class, static function (ChildDefinition $definition, JsonEncodable $attribute): void { - $definition->addTag('json_encoder.encodable', [ + + $container->registerForAutoconfiguration(CompilerPassInterface::class) + ->addTag('container.excluded', ['source' => 'because it\'s a compiler pass']); + $container->registerForAutoconfiguration(Constraint::class) + ->addTag('container.excluded', ['source' => 'because it\'s a validation constraint']); + $container->registerForAutoconfiguration(TestCase::class) + ->addTag('container.excluded', ['source' => 'because it\'s a test case']); + $container->registerForAutoconfiguration(\UnitEnum::class) + ->addTag('container.excluded', ['source' => 'because it\'s an enum']); + $container->registerAttributeForAutoconfiguration(AsMessage::class, static function (ChildDefinition $definition) { + $definition->addTag('container.excluded', ['source' => 'because it\'s a messenger message']); + }); + $container->registerAttributeForAutoconfiguration(\Attribute::class, static function (ChildDefinition $definition) { + $definition->addTag('container.excluded', ['source' => 'because it\'s a PHP attribute']); + }); + $container->registerAttributeForAutoconfiguration(Entity::class, static function (ChildDefinition $definition) { + $definition->addTag('container.excluded', ['source' => 'because it\'s a Doctrine entity']); + }); + $container->registerAttributeForAutoconfiguration(Embeddable::class, static function (ChildDefinition $definition) { + $definition->addTag('container.excluded', ['source' => 'because it\'s a Doctrine embeddable']); + }); + $container->registerAttributeForAutoconfiguration(MappedSuperclass::class, static function (ChildDefinition $definition) { + $definition->addTag('container.excluded', ['source' => 'because it\'s a Doctrine mapped superclass']); + }); + + $container->registerAttributeForAutoconfiguration(JsonStreamable::class, static function (ChildDefinition $definition, JsonStreamable $attribute) { + $definition->addTag('json_streamer.streamable', [ 'object' => $attribute->asObject, 'list' => $attribute->asList, - ]); - $definition->addTag('container.excluded'); + ])->addTag('container.excluded', ['source' => 'because it\'s a streamable JSON']); }); if (!$container->getParameter('kernel.debug')) { @@ -769,7 +839,7 @@ static function (ChildDefinition $definition, AsPeriodicTask|AsCronTask $attribu $container->getDefinition('config_cache_factory')->setArguments([]); } - if (!$config['disallow_search_engine_index'] ?? false) { + if (!$config['disallow_search_engine_index']) { $container->removeDefinition('disallow_search_engine_index_response_listener'); } @@ -815,9 +885,7 @@ private function registerFormConfiguration(array $config, ContainerBuilder $cont $container->setParameter('form.type_extension.csrf.enabled', true); $container->setParameter('form.type_extension.csrf.field_name', $config['form']['csrf_protection']['field_name']); $container->setParameter('form.type_extension.csrf.field_attr', $config['form']['csrf_protection']['field_attr']); - - $container->getDefinition('form.type_extension.csrf') - ->replaceArgument(7, $config['form']['csrf_protection']['token_id']); + $container->setParameter('.form.type_extension.csrf.token_id', $config['form']['csrf_protection']['token_id']); } else { $container->setParameter('form.type_extension.csrf.enabled', false); } @@ -901,6 +969,11 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $ $loader->load('collectors.php'); $loader->load('cache_debug.php'); + if (!class_exists(ProfilerStateChecker::class)) { + $container->removeDefinition('profiler.state_checker'); + $container->removeDefinition('profiler.is_disabled_state_checker'); + } + if ($this->isInitializedConfigEnabled('form')) { $loader->load('form_debug.php'); } @@ -935,6 +1008,10 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $ $loader->load('notifier_debug.php'); } + if (false === $config['collect_serializer_data']) { + trigger_deprecation('symfony/framework-bundle', '7.3', 'Setting the "framework.profiler.collect_serializer_data" config option to "false" is deprecated.'); + } + if ($this->isInitializedConfigEnabled('serializer') && $config['collect_serializer_data']) { $loader->load('serializer_debug.php'); } @@ -1051,7 +1128,8 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $ } } $metadataStoreDefinition->replaceArgument(2, $transitionsMetadataDefinition); - $container->setDefinition(\sprintf('%s.metadata_store', $workflowId), $metadataStoreDefinition); + $metadataStoreId = \sprintf('%s.metadata_store', $workflowId); + $container->setDefinition($metadataStoreId, $metadataStoreDefinition); // Create places $places = array_column($workflow['places'], 'name'); @@ -1062,7 +1140,8 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $ $definitionDefinition->addArgument($places); $definitionDefinition->addArgument($transitions); $definitionDefinition->addArgument($initialMarking); - $definitionDefinition->addArgument(new Reference(\sprintf('%s.metadata_store', $workflowId))); + $definitionDefinition->addArgument(new Reference($metadataStoreId)); + $definitionDefinitionId = \sprintf('%s.definition', $workflowId); // Create MarkingStore $markingStoreDefinition = null; @@ -1076,14 +1155,26 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $ $markingStoreDefinition = new Reference($workflow['marking_store']['service']); } + // Validation + $workflow['definition_validators'][] = match ($workflow['type']) { + 'state_machine' => Workflow\Validator\StateMachineValidator::class, + 'workflow' => Workflow\Validator\WorkflowValidator::class, + default => throw new \LogicException(\sprintf('Invalid workflow type "%s".', $workflow['type'])), + }; + // Create Workflow $workflowDefinition = new ChildDefinition(\sprintf('%s.abstract', $type)); - $workflowDefinition->replaceArgument(0, new Reference(\sprintf('%s.definition', $workflowId))); + $workflowDefinition->replaceArgument(0, new Reference($definitionDefinitionId)); $workflowDefinition->replaceArgument(1, $markingStoreDefinition); $workflowDefinition->replaceArgument(3, $name); $workflowDefinition->replaceArgument(4, $workflow['events_to_dispatch']); - $workflowDefinition->addTag('workflow', ['name' => $name, 'metadata' => $workflow['metadata']]); + $workflowDefinition->addTag('workflow', [ + 'name' => $name, + 'metadata' => $workflow['metadata'], + 'definition_validators' => $workflow['definition_validators'], + 'definition_id' => $definitionDefinitionId, + ]); if ('workflow' === $type) { $workflowDefinition->addTag('workflow.workflow', ['name' => $name]); } elseif ('state_machine' === $type) { @@ -1092,21 +1183,10 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $ // Store to container $container->setDefinition($workflowId, $workflowDefinition); - $container->setDefinition(\sprintf('%s.definition', $workflowId), $definitionDefinition); + $container->setDefinition($definitionDefinitionId, $definitionDefinition); $container->registerAliasForArgument($workflowId, WorkflowInterface::class, $name.'.'.$type); $container->registerAliasForArgument($workflowId, WorkflowInterface::class, $name); - // Validate Workflow - if ('state_machine' === $workflow['type']) { - $validator = new Workflow\Validator\StateMachineValidator(); - } else { - $validator = new Workflow\Validator\WorkflowValidator(); - } - - $trs = array_map(fn (Reference $ref): Workflow\Transition => $container->get((string) $ref), $transitions); - $realDefinition = new Workflow\Definition($places, $trs, $initialMarking); - $validator->validate($realDefinition, $name); - // Add workflow to Registry if ($workflow['supports']) { foreach ($workflow['supports'] as $supportedClassName) { @@ -1617,6 +1697,10 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder $translator->replaceArgument(4, $options); } + foreach ($config['globals'] as $name => $global) { + $translator->addMethodCall('addGlobalParameter', [$name, $global['value'] ?? new Definition(TranslatableMessage::class, [$global['message'], $global['parameters'] ?? [], $global['domain'] ?? null])]); + } + if ($config['pseudo_localization']['enabled']) { $options = $config['pseudo_localization']; unset($options['enabled']); @@ -1690,10 +1774,6 @@ private function registerValidationConfiguration(array $config, ContainerBuilder throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".'); } - if (!isset($config['email_validation_mode'])) { - $config['email_validation_mode'] = 'loose'; - } - $loader->load('validator.php'); $validatorBuilder = $container->getDefinition('validator.builder'); @@ -2013,51 +2093,39 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder $container->setParameter('serializer.default_context', $defaultContext); } - if (!$container->hasDefinition('serializer.normalizer.object')) { - return; - } - - $arguments = $container->getDefinition('serializer.normalizer.object')->getArguments(); - $context = $arguments[6] ?? $defaultContext; - - if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) { - $context += ['circular_reference_handler' => new Reference($config['circular_reference_handler'])]; - $container->getDefinition('serializer.normalizer.object')->setArgument(5, null); + if ($config['circular_reference_handler'] ?? false) { + $container->setParameter('.serializer.circular_reference_handler', $config['circular_reference_handler']); } if ($config['max_depth_handler'] ?? false) { - $context += ['max_depth_handler' => new Reference($config['max_depth_handler'])]; + $container->setParameter('.serializer.max_depth_handler', $config['max_depth_handler']); } - $container->getDefinition('serializer.normalizer.object')->setArgument(6, $context); - $container->getDefinition('serializer.normalizer.property')->setArgument(5, $defaultContext); $container->setParameter('.serializer.named_serializers', $config['named_serializers'] ?? []); } - private function registerJsonEncoderConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void + private function registerJsonStreamerConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void { - if (!class_exists(JsonEncoder::class)) { - throw new LogicException('JsonEncoder support cannot be enabled as the JsonEncoder component is not installed. Try running "composer require symfony/json-encoder".'); + if (!class_exists(JsonStreamWriter::class)) { + throw new LogicException('JsonStreamer support cannot be enabled as the JsonStreamer component is not installed. Try running "composer require symfony/json-streamer".'); } - $container->registerForAutoconfiguration(JsonEncoderNormalizerInterface::class) - ->addTag('json_encoder.normalizer'); - $container->registerForAutoconfiguration(JsonEncoderDenormalizerInterface::class) - ->addTag('json_encoder.denormalizer'); + $container->registerForAutoconfiguration(ValueTransformerInterface::class) + ->addTag('json_streamer.value_transformer'); - $loader->load('json_encoder.php'); + $loader->load('json_streamer.php'); - $container->registerAliasForArgument('json_encoder.encoder', JsonEncoderEncoderInterface::class, 'json.encoder'); - $container->registerAliasForArgument('json_encoder.decoder', JsonEncoderDecoderInterface::class, 'json.decoder'); + $container->registerAliasForArgument('json_streamer.stream_writer', StreamWriterInterface::class, 'json.stream_writer'); + $container->registerAliasForArgument('json_streamer.stream_reader', StreamReaderInterface::class, 'json.stream_reader'); - $container->setParameter('.json_encoder.encoders_dir', '%kernel.cache_dir%/json_encoder/encoder'); - $container->setParameter('.json_encoder.decoders_dir', '%kernel.cache_dir%/json_encoder/decoder'); - $container->setParameter('.json_encoder.lazy_ghosts_dir', '%kernel.cache_dir%/json_encoder/lazy_ghost'); + $container->setParameter('.json_streamer.stream_writers_dir', '%kernel.cache_dir%/json_streamer/stream_writer'); + $container->setParameter('.json_streamer.stream_readers_dir', '%kernel.cache_dir%/json_streamer/stream_reader'); + $container->setParameter('.json_streamer.lazy_ghosts_dir', '%kernel.cache_dir%/json_streamer/lazy_ghost'); if (\PHP_VERSION_ID >= 80400) { - $container->removeDefinition('.json_encoder.cache_warmer.lazy_ghost'); + $container->removeDefinition('.json_streamer.cache_warmer.lazy_ghost'); } } @@ -2226,7 +2294,7 @@ private function registerSchedulerConfiguration(ContainerBuilder $container, Php } // BC layer Scheduler < 7.3 - if (!class_exists(SchedulerTriggerNormalizer::class)) { + if (!ContainerBuilder::willBeAvailable('symfony/serializer', DenormalizerInterface::class, ['symfony/framework-bundle', 'symfony/scheduler']) || !class_exists(SchedulerTriggerNormalizer::class)) { $container->removeDefinition('serializer.normalizer.scheduler_trigger'); } } @@ -2247,6 +2315,10 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder $container->removeDefinition('serializer.normalizer.flatten_exception'); } + if (!class_exists(ResetMemoryUsageListener::class)) { + $container->removeDefinition('messenger.listener.reset_memory_usage'); + } + if (ContainerBuilder::willBeAvailable('symfony/amqp-messenger', MessengerBridge\Amqp\Transport\AmqpTransportFactory::class, ['symfony/framework-bundle', 'symfony/messenger'])) { $container->getDefinition('messenger.transport.amqp.factory')->addTag('messenger.transport_factory'); } @@ -2300,16 +2372,18 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder $defaultMiddleware['after'][0]['arguments'] = [$bus['default_middleware']['allow_no_senders']]; $defaultMiddleware['after'][1]['arguments'] = [$bus['default_middleware']['allow_no_handlers']]; - // argument to add_bus_name_stamp_middleware - $defaultMiddleware['before'][0]['arguments'] = [$busId]; - $middleware = array_merge($defaultMiddleware['before'], $middleware, $defaultMiddleware['after']); } - foreach ($middleware as $middlewareItem) { + foreach ($middleware as $key => $middlewareItem) { if (!$validationEnabled && \in_array($middlewareItem['id'], ['validation', 'messenger.middleware.validation'], true)) { throw new LogicException('The Validation middleware is only available when the Validator component is installed and enabled. Try running "composer require symfony/validator".'); } + + // argument to add_bus_name_stamp_middleware + if ('add_bus_name_stamp_middleware' === $middlewareItem['id']) { + $middleware[$key]['arguments'] = [$busId]; + } } if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) { @@ -2366,13 +2440,17 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder $transportRateLimiterReferences = []; foreach ($config['transports'] as $name => $transport) { $serializerId = $transport['serializer'] ?? 'messenger.default_serializer'; + $tags = [ + 'alias' => $name, + 'is_failure_transport' => \in_array($name, $failureTransports, true), + ]; + if (str_starts_with($transport['dsn'], 'sync://')) { + $tags['is_consumable'] = false; + } $transportDefinition = (new Definition(TransportInterface::class)) ->setFactory([new Reference('messenger.transport_factory'), 'createTransport']) ->setArguments([$transport['dsn'], $transport['options'] + ['transport_name' => $name], new Reference($serializerId)]) - ->addTag('messenger.receiver', [ - 'alias' => $name, - 'is_failure_transport' => \in_array($name, $failureTransports, true), - ]) + ->addTag('messenger.receiver', $tags) ; $container->setDefinition($transportId = 'messenger.transport.'.$name, $transportDefinition); $senderAliases[$name] = $transportId; @@ -2502,7 +2580,7 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con // Inline any env vars referenced in the parameter $container->setParameter('cache.prefix.seed', $container->resolveEnvPlaceholders($container->getParameter('cache.prefix.seed'), true)); } - foreach (['psr6', 'redis', 'memcached', 'doctrine_dbal', 'pdo'] as $name) { + foreach (['psr6', 'redis', 'valkey', 'memcached', 'doctrine_dbal', 'pdo'] as $name) { if (isset($config[$name = 'default_'.$name.'_provider'])) { $container->setAlias('cache.'.$name, new Alias(CachePoolPass::getServiceProvider($container, $config[$name]), false)); } @@ -2514,12 +2592,13 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con 'tags' => false, ]; } + $redisTagAwareAdapters = [['cache.adapter.redis_tag_aware'], ['cache.adapter.valkey_tag_aware']]; foreach ($config['pools'] as $name => $pool) { $pool['adapters'] = $pool['adapters'] ?: ['cache.app']; - $isRedisTagAware = ['cache.adapter.redis_tag_aware'] === $pool['adapters']; + $isRedisTagAware = \in_array($pool['adapters'], $redisTagAwareAdapters, true); foreach ($pool['adapters'] as $provider => $adapter) { - if (($config['pools'][$adapter]['adapters'] ?? null) === ['cache.adapter.redis_tag_aware']) { + if (\in_array($config['pools'][$adapter]['adapters'] ?? null, $redisTagAwareAdapters, true)) { $isRedisTagAware = true; } elseif ($config['pools'][$adapter]['tags'] ?? false) { $pool['adapters'][$provider] = $adapter = '.'.$adapter.'.inner'; @@ -2570,6 +2649,10 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con $container->registerAliasForArgument($tagAwareId, TagAwareCacheInterface::class, $pool['name'] ?? $name); $container->registerAliasForArgument($name, CacheInterface::class, $pool['name'] ?? $name); $container->registerAliasForArgument($name, CacheItemPoolInterface::class, $pool['name'] ?? $name); + + if (interface_exists(NamespacedPoolInterface::class)) { + $container->registerAliasForArgument($name, NamespacedPoolInterface::class, $pool['name'] ?? $name); + } } $definition->setPublic($pool['public']); @@ -2776,7 +2859,6 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co } $transports = $config['dsn'] ? ['main' => $config['dsn']] : $config['transports']; $container->getDefinition('mailer.transports')->setArgument(0, $transports); - $container->getDefinition('mailer.default_transport')->setArgument(0, current($transports)); $mailer = $container->getDefinition('mailer.mailer'); if (false === $messageBus = $config['message_bus']) { @@ -2884,8 +2966,8 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co throw new LogicException('SMIME signed messages support cannot be enabled as this version of the Mailer component does not support it.'); } $smimeSigner = $container->getDefinition('mailer.smime_signer'); - $smimeSigner->setArgument(0, $config['smime_signer']['key']); - $smimeSigner->setArgument(1, $config['smime_signer']['certificate']); + $smimeSigner->setArgument(0, $config['smime_signer']['certificate']); + $smimeSigner->setArgument(1, $config['smime_signer']['key']); $smimeSigner->setArgument(2, $config['smime_signer']['passphrase']); $smimeSigner->setArgument(3, $config['smime_signer']['extra_certificates']); $smimeSigner->setArgument(4, $config['smime_signer']['sign_options']); @@ -2898,11 +2980,9 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co if (!class_exists(SmimeEncryptedMessageListener::class)) { throw new LogicException('S/MIME encrypted messages support cannot be enabled as this version of the Mailer component does not support it.'); } - $smimeDecrypter = $container->getDefinition('mailer.smime_encrypter'); - $smimeDecrypter->setArgument(0, $config['smime_encrypter']['certificate']); - $smimeDecrypter->setArgument(1, $config['smime_encrypter']['cipher']); + $container->setAlias('mailer.smime_encrypter.repository', $config['smime_encrypter']['repository']); + $container->setParameter('mailer.smime_encrypter.cipher', $config['smime_encrypter']['cipher']); } else { - $container->removeDefinition('mailer.smime_encrypter'); $container->removeDefinition('mailer.smime_encrypter.listener'); } @@ -3007,6 +3087,7 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $ NotifierBridge\Lox24\Lox24TransportFactory::class => 'notifier.transport_factory.lox24', NotifierBridge\Mailjet\MailjetTransportFactory::class => 'notifier.transport_factory.mailjet', NotifierBridge\Mastodon\MastodonTransportFactory::class => 'notifier.transport_factory.mastodon', + NotifierBridge\Matrix\MatrixTransportFactory::class => 'notifier.transport_factory.matrix', NotifierBridge\Mattermost\MattermostTransportFactory::class => 'notifier.transport_factory.mattermost', NotifierBridge\Mercure\MercureTransportFactory::class => 'notifier.transport_factory.mercure', NotifierBridge\MessageBird\MessageBirdTransportFactory::class => 'notifier.transport_factory.message-bird', @@ -3117,6 +3198,7 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $ $loader->load('notifier_webhook.php'); $webhookRequestParsers = [ + NotifierBridge\Smsbox\Webhook\SmsboxRequestParser::class => 'notifier.webhook.request_parser.smsbox', NotifierBridge\Sweego\Webhook\SweegoRequestParser::class => 'notifier.webhook.request_parser.sweego', NotifierBridge\Twilio\Webhook\TwilioRequestParser::class => 'notifier.webhook.request_parser.twilio', NotifierBridge\Vonage\Webhook\VonageRequestParser::class => 'notifier.webhook.request_parser.vonage', @@ -3169,13 +3251,30 @@ private function registerRateLimiterConfiguration(array $config, ContainerBuilde { $loader->load('rate_limiter.php'); + $limiters = []; + $compoundLimiters = []; + foreach ($config['limiters'] as $name => $limiterConfig) { + if ('compound' === $limiterConfig['policy']) { + $compoundLimiters[$name] = $limiterConfig; + + continue; + } + + unset($limiterConfig['limiters']); + + $limiters[] = $name; + // default configuration (when used by other DI extensions) $limiterConfig += ['lock_factory' => 'lock.factory', 'cache_pool' => 'cache.rate_limiter']; $limiter = $container->setDefinition($limiterId = 'limiter.'.$name, new ChildDefinition('limiter')) ->addTag('rate_limiter', ['name' => $name]); + if ('auto' === $limiterConfig['lock_factory']) { + $limiterConfig['lock_factory'] = $this->isInitializedConfigEnabled('lock') ? 'lock.factory' : null; + } + if (null !== $limiterConfig['lock_factory']) { if (!interface_exists(LockInterface::class)) { throw new LogicException(\sprintf('Rate limiter "%s" requires the Lock component to be installed. Try running "composer require symfony/lock".', $name)); @@ -3199,7 +3298,41 @@ private function registerRateLimiterConfiguration(array $config, ContainerBuilde $limiterConfig['id'] = $name; $limiter->replaceArgument(0, $limiterConfig); - $container->registerAliasForArgument($limiterId, RateLimiterFactory::class, $name.'.limiter'); + $factoryAlias = $container->registerAliasForArgument($limiterId, RateLimiterFactory::class, $name.'.limiter'); + + if (interface_exists(RateLimiterFactoryInterface::class)) { + $container->registerAliasForArgument($limiterId, RateLimiterFactoryInterface::class, $name.'.limiter'); + $factoryAlias->setDeprecated('symfony/framework-bundle', '7.3', \sprintf('The "%%alias_id%%" autowiring alias is deprecated and will be removed in 8.0, use "%s $%s" instead.', RateLimiterFactoryInterface::class, (new Target($name.'.limiter'))->getParsedName())); + $internalAliasId = \sprintf('.%s $%s.limiter', RateLimiterFactory::class, $name); + + if ($container->hasAlias($internalAliasId)) { + $container->getAlias($internalAliasId)->setDeprecated('symfony/framework-bundle', '7.3', \sprintf('The "%%alias_id%%" autowiring alias is deprecated and will be removed in 8.0, use "%s $%s" instead.', RateLimiterFactoryInterface::class, (new Target($name.'.limiter'))->getParsedName())); + } + } + } + + if ($compoundLimiters && !class_exists(CompoundRateLimiterFactory::class)) { + throw new LogicException('Configuring compound rate limiters is only available in symfony/rate-limiter 7.3+.'); + } + + foreach ($compoundLimiters as $name => $limiterConfig) { + if (!$limiterConfig['limiters']) { + throw new LogicException(\sprintf('Compound rate limiter "%s" requires at least one sub-limiter.', $name)); + } + + if (array_diff($limiterConfig['limiters'], $limiters)) { + throw new LogicException(\sprintf('Compound rate limiter "%s" requires at least one sub-limiter to be configured.', $name)); + } + + $container->register($limiterId = 'limiter.'.$name, CompoundRateLimiterFactory::class) + ->addTag('rate_limiter', ['name' => $name]) + ->addArgument(new IteratorArgument(array_map( + static fn (string $name) => new Reference('limiter.'.$name), + $limiterConfig['limiters'] + ))) + ; + + $container->registerAliasForArgument($limiterId, RateLimiterFactoryInterface::class, $name.'.limiter'); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php index 89d9744f514e4..300fe22fb37a9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle; +use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddDebugLogProcessorPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AssetsContextPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass; @@ -54,7 +55,7 @@ use Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass; use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\JsonEncoder\DependencyInjection\EncodablePass; +use Symfony\Component\JsonStreamer\DependencyInjection\StreamablePass; use Symfony\Component\Messenger\DependencyInjection\MessengerPass; use Symfony\Component\Mime\DependencyInjection\AddMimeTypeGuesserPass; use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoConstructorPass; @@ -77,6 +78,7 @@ use Symfony\Component\VarExporter\Internal\Registry; use Symfony\Component\Workflow\DependencyInjection\WorkflowDebugPass; use Symfony\Component\Workflow\DependencyInjection\WorkflowGuardListenerPass; +use Symfony\Component\Workflow\DependencyInjection\WorkflowValidatorPass; // Help opcache.preload discover always-needed symbols class_exists(ApcuAdapter::class); @@ -173,6 +175,7 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass(new CachePoolPrunerPass(), PassConfig::TYPE_AFTER_REMOVING); $this->addCompilerPassIfExists($container, FormPass::class); $this->addCompilerPassIfExists($container, WorkflowGuardListenerPass::class); + $this->addCompilerPassIfExists($container, WorkflowValidatorPass::class); $container->addCompilerPass(new ResettableServicePass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32); $container->addCompilerPass(new RegisterLocaleAwareServicesPass()); $container->addCompilerPass(new TestServiceContainerWeakRefPass(), PassConfig::TYPE_BEFORE_REMOVING, -32); @@ -189,7 +192,7 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass(new ErrorLoggerCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32); $container->addCompilerPass(new VirtualRequestStackPass()); $container->addCompilerPass(new TranslationUpdateCommandPass(), PassConfig::TYPE_BEFORE_REMOVING); - $this->addCompilerPassIfExists($container, EncodablePass::class); + $this->addCompilerPassIfExists($container, StreamablePass::class); if ($container->getParameter('kernel.debug')) { $container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 2); @@ -200,6 +203,14 @@ public function build(ContainerBuilder $container): void } } + /** + * @internal + */ + public static function considerProfilerEnabled(): bool + { + return !($GLOBALS['app'] ?? null) instanceof Application || empty($_GET) && \in_array('--profile', $_SERVER['argv'] ?? [], true); + } + private function addCompilerPassIfExists(ContainerBuilder $container, string $class, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0): void { $container->addResource(new ClassExistenceResource($class)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php b/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php index f40373a302b45..5d2ecf289b883 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php @@ -182,7 +182,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void } $file = (new \ReflectionObject($this))->getFileName(); - /* @var ContainerPhpFileLoader $kernelLoader */ + /** @var ContainerPhpFileLoader $kernelLoader */ $kernelLoader = $loader->getResolver()->resolve($file); $kernelLoader->setCurrentDir(\dirname($file)); $instanceof = &\Closure::bind(fn &() => $this->instanceof, $kernelLoader, $kernelLoader)(); @@ -208,7 +208,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void public function loadRoutes(LoaderInterface $loader): RouteCollection { $file = (new \ReflectionObject($this))->getFileName(); - /* @var RoutingPhpFileLoader $kernelLoader */ + /** @var RoutingPhpFileLoader $kernelLoader */ $kernelLoader = $loader->getResolver()->resolve($file, 'php'); $kernelLoader->setCurrentDir(\dirname($file)); $collection = new RouteCollection(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/asset_mapper.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/asset_mapper.php index c187558641079..eeb1ceb4f8962 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/asset_mapper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/asset_mapper.php @@ -232,6 +232,7 @@ ->args([ service('asset_mapper.importmap.manager'), service('asset_mapper.importmap.version_checker'), + param('kernel.project_dir'), ]) ->tag('console.command') diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.php index ad4dca42d3b78..ae9d426a498c6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.php @@ -28,6 +28,7 @@ use Symfony\Component\Cache\Messenger\EarlyExpirationHandler; use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer; use Symfony\Contracts\Cache\CacheInterface; +use Symfony\Contracts\Cache\NamespacedPoolInterface; use Symfony\Contracts\Cache\TagAwareCacheInterface; return static function (ContainerConfigurator $container) { @@ -140,6 +141,7 @@ 'reset' => 'reset', ]) ->tag('monolog.logger', ['channel' => 'cache']) + ->alias('cache.adapter.valkey', 'cache.adapter.redis') ->set('cache.adapter.redis_tag_aware', RedisTagAwareAdapter::class) ->abstract() @@ -156,6 +158,7 @@ 'reset' => 'reset', ]) ->tag('monolog.logger', ['channel' => 'cache']) + ->alias('cache.adapter.valkey_tag_aware', 'cache.adapter.redis_tag_aware') ->set('cache.adapter.memcached', MemcachedAdapter::class) ->abstract() @@ -248,6 +251,8 @@ ->alias(CacheInterface::class, 'cache.app') + ->alias(NamespacedPoolInterface::class, 'cache.app') + ->alias(TagAwareCacheInterface::class, 'cache.app.taggable') ; }; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.php index 7168caa4d05cd..7ef10bb522af0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.php @@ -44,6 +44,7 @@ use Symfony\Component\Console\EventListener\ErrorListener; use Symfony\Component\Console\Messenger\RunCommandMessageHandler; use Symfony\Component\Dotenv\Command\DebugCommand as DotenvDebugCommand; +use Symfony\Component\ErrorHandler\Command\ErrorDumpCommand; use Symfony\Component\Messenger\Command\ConsumeMessagesCommand; use Symfony\Component\Messenger\Command\DebugCommand as MessengerDebugCommand; use Symfony\Component\Messenger\Command\FailedMessagesRemoveCommand; @@ -59,6 +60,7 @@ use Symfony\Component\Translation\Command\TranslationPushCommand; use Symfony\Component\Translation\Command\XliffLintCommand; use Symfony\Component\Validator\Command\DebugCommand as ValidatorDebugCommand; +use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupInterface; return static function (ContainerConfigurator $container) { $container->services() @@ -385,6 +387,14 @@ ]) ->tag('console.command') + ->set('console.command.error_dumper', ErrorDumpCommand::class) + ->args([ + service('filesystem'), + service('error_renderer.html'), + service(EntrypointLookupInterface::class)->nullOnInvalid(), + ]) + ->tag('console.command') + ->set('console.messenger.application', Application::class) ->share(false) ->call('setAutoExit', [false]) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.php index 5c426653daeca..842f5b35b412a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.php @@ -25,6 +25,7 @@ service('debug.stopwatch'), service('logger')->nullOnInvalid(), service('.virtual_request_stack')->nullOnInvalid(), + service('profiler.is_disabled_state_checker')->nullOnInvalid(), ]) ->tag('monolog.logger', ['channel' => 'event']) ->tag('kernel.reset', ['method' => 'reset']) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form_csrf.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form_csrf.php index c63d087c864db..a86bb7c60fdcf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form_csrf.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form_csrf.php @@ -24,7 +24,7 @@ param('validator.translation_domain'), service('form.server_params'), param('form.type_extension.csrf.field_attr'), - abstract_arg('framework.form.csrf_protection.token_id'), + param('.form.type_extension.csrf.token_id'), ]) ->tag('form.type_extension') ; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/json_encoder.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/json_encoder.php deleted file mode 100644 index 67cb25d0aa13a..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/json_encoder.php +++ /dev/null @@ -1,126 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Loader\Configurator; - -use Symfony\Component\JsonEncoder\CacheWarmer\EncoderDecoderCacheWarmer; -use Symfony\Component\JsonEncoder\CacheWarmer\LazyGhostCacheWarmer; -use Symfony\Component\JsonEncoder\Decode\Denormalizer\DateTimeDenormalizer; -use Symfony\Component\JsonEncoder\Encode\Normalizer\DateTimeNormalizer; -use Symfony\Component\JsonEncoder\JsonDecoder; -use Symfony\Component\JsonEncoder\JsonEncoder; -use Symfony\Component\JsonEncoder\Mapping\Decode\AttributePropertyMetadataLoader as DecodeAttributePropertyMetadataLoader; -use Symfony\Component\JsonEncoder\Mapping\Decode\DateTimeTypePropertyMetadataLoader as DecodeDateTimeTypePropertyMetadataLoader; -use Symfony\Component\JsonEncoder\Mapping\Encode\AttributePropertyMetadataLoader as EncodeAttributePropertyMetadataLoader; -use Symfony\Component\JsonEncoder\Mapping\Encode\DateTimeTypePropertyMetadataLoader as EncodeDateTimeTypePropertyMetadataLoader; -use Symfony\Component\JsonEncoder\Mapping\GenericTypePropertyMetadataLoader; -use Symfony\Component\JsonEncoder\Mapping\PropertyMetadataLoader; - -return static function (ContainerConfigurator $container) { - $container->services() - // encoder/decoder - ->set('json_encoder.encoder', JsonEncoder::class) - ->args([ - tagged_locator('json_encoder.normalizer'), - service('json_encoder.encode.property_metadata_loader'), - param('.json_encoder.encoders_dir'), - ]) - ->set('json_encoder.decoder', JsonDecoder::class) - ->args([ - tagged_locator('json_encoder.denormalizer'), - service('json_encoder.decode.property_metadata_loader'), - param('.json_encoder.decoders_dir'), - param('.json_encoder.lazy_ghosts_dir'), - ]) - ->alias(JsonEncoder::class, 'json_encoder.encoder') - ->alias(JsonDecoder::class, 'json_encoder.decoder') - - // metadata - ->set('json_encoder.encode.property_metadata_loader', PropertyMetadataLoader::class) - ->args([ - service('type_info.resolver'), - ]) - ->set('.json_encoder.encode.property_metadata_loader.generic', GenericTypePropertyMetadataLoader::class) - ->decorate('json_encoder.encode.property_metadata_loader') - ->args([ - service('.inner'), - service('type_info.type_context_factory'), - ]) - ->set('.json_encoder.encode.property_metadata_loader.date_time', EncodeDateTimeTypePropertyMetadataLoader::class) - ->decorate('json_encoder.encode.property_metadata_loader') - ->args([ - service('.inner'), - ]) - ->set('.json_encoder.encode.property_metadata_loader.attribute', EncodeAttributePropertyMetadataLoader::class) - ->decorate('json_encoder.encode.property_metadata_loader') - ->args([ - service('.inner'), - tagged_locator('json_encoder.normalizer'), - service('type_info.resolver'), - ]) - - ->set('json_encoder.decode.property_metadata_loader', PropertyMetadataLoader::class) - ->args([ - service('type_info.resolver'), - ]) - ->set('.json_encoder.decode.property_metadata_loader.generic', GenericTypePropertyMetadataLoader::class) - ->decorate('json_encoder.decode.property_metadata_loader') - ->args([ - service('.inner'), - service('type_info.type_context_factory'), - ]) - ->set('.json_encoder.decode.property_metadata_loader.date_time', DecodeDateTimeTypePropertyMetadataLoader::class) - ->decorate('json_encoder.decode.property_metadata_loader') - ->args([ - service('.inner'), - ]) - ->set('.json_encoder.decode.property_metadata_loader.attribute', DecodeAttributePropertyMetadataLoader::class) - ->decorate('json_encoder.decode.property_metadata_loader') - ->args([ - service('.inner'), - tagged_locator('json_encoder.normalizer'), - service('type_info.resolver'), - ]) - - // normalizers/denormalizers - ->set('json_encoder.normalizer.date_time', DateTimeNormalizer::class) - ->tag('json_encoder.normalizer') - ->set('json_encoder.denormalizer.date_time', DateTimeDenormalizer::class) - ->args([ - false, - ]) - ->tag('json_encoder.denormalizer') - ->set('json_encoder.denormalizer.date_time_immutable', DateTimeDenormalizer::class) - ->args([ - true, - ]) - ->tag('json_encoder.denormalizer') - - // cache - ->set('.json_encoder.cache_warmer.encoder_decoder', EncoderDecoderCacheWarmer::class) - ->args([ - abstract_arg('encodable class names'), - service('json_encoder.encode.property_metadata_loader'), - service('json_encoder.decode.property_metadata_loader'), - param('.json_encoder.encoders_dir'), - param('.json_encoder.decoders_dir'), - service('logger')->ignoreOnInvalid(), - ]) - ->tag('kernel.cache_warmer') - - ->set('.json_encoder.cache_warmer.lazy_ghost', LazyGhostCacheWarmer::class) - ->args([ - abstract_arg('encodable class names'), - param('.json_encoder.lazy_ghosts_dir'), - ]) - ->tag('kernel.cache_warmer') - ; -}; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/json_streamer.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/json_streamer.php new file mode 100644 index 0000000000000..79fb25833e066 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/json_streamer.php @@ -0,0 +1,119 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Loader\Configurator; + +use Symfony\Component\JsonStreamer\CacheWarmer\LazyGhostCacheWarmer; +use Symfony\Component\JsonStreamer\CacheWarmer\StreamerCacheWarmer; +use Symfony\Component\JsonStreamer\JsonStreamReader; +use Symfony\Component\JsonStreamer\JsonStreamWriter; +use Symfony\Component\JsonStreamer\Mapping\GenericTypePropertyMetadataLoader; +use Symfony\Component\JsonStreamer\Mapping\PropertyMetadataLoader; +use Symfony\Component\JsonStreamer\Mapping\Read\AttributePropertyMetadataLoader as ReadAttributePropertyMetadataLoader; +use Symfony\Component\JsonStreamer\Mapping\Read\DateTimeTypePropertyMetadataLoader as ReadDateTimeTypePropertyMetadataLoader; +use Symfony\Component\JsonStreamer\Mapping\Write\AttributePropertyMetadataLoader as WriteAttributePropertyMetadataLoader; +use Symfony\Component\JsonStreamer\Mapping\Write\DateTimeTypePropertyMetadataLoader as WriteDateTimeTypePropertyMetadataLoader; +use Symfony\Component\JsonStreamer\ValueTransformer\DateTimeToStringValueTransformer; +use Symfony\Component\JsonStreamer\ValueTransformer\StringToDateTimeValueTransformer; + +return static function (ContainerConfigurator $container) { + $container->services() + // stream reader/writer + ->set('json_streamer.stream_writer', JsonStreamWriter::class) + ->args([ + tagged_locator('json_streamer.value_transformer'), + service('json_streamer.write.property_metadata_loader'), + param('.json_streamer.stream_writers_dir'), + ]) + ->set('json_streamer.stream_reader', JsonStreamReader::class) + ->args([ + tagged_locator('json_streamer.value_transformer'), + service('json_streamer.read.property_metadata_loader'), + param('.json_streamer.stream_readers_dir'), + param('.json_streamer.lazy_ghosts_dir'), + ]) + ->alias(JsonStreamWriter::class, 'json_streamer.stream_writer') + ->alias(JsonStreamReader::class, 'json_streamer.stream_reader') + + // metadata + ->set('json_streamer.write.property_metadata_loader', PropertyMetadataLoader::class) + ->args([ + service('type_info.resolver'), + ]) + ->set('.json_streamer.write.property_metadata_loader.generic', GenericTypePropertyMetadataLoader::class) + ->decorate('json_streamer.write.property_metadata_loader') + ->args([ + service('.inner'), + service('type_info.type_context_factory'), + ]) + ->set('.json_streamer.write.property_metadata_loader.date_time', WriteDateTimeTypePropertyMetadataLoader::class) + ->decorate('json_streamer.write.property_metadata_loader') + ->args([ + service('.inner'), + ]) + ->set('.json_streamer.write.property_metadata_loader.attribute', WriteAttributePropertyMetadataLoader::class) + ->decorate('json_streamer.write.property_metadata_loader') + ->args([ + service('.inner'), + tagged_locator('json_streamer.value_transformer'), + service('type_info.resolver'), + ]) + + ->set('json_streamer.read.property_metadata_loader', PropertyMetadataLoader::class) + ->args([ + service('type_info.resolver'), + ]) + ->set('.json_streamer.read.property_metadata_loader.generic', GenericTypePropertyMetadataLoader::class) + ->decorate('json_streamer.read.property_metadata_loader') + ->args([ + service('.inner'), + service('type_info.type_context_factory'), + ]) + ->set('.json_streamer.read.property_metadata_loader.date_time', ReadDateTimeTypePropertyMetadataLoader::class) + ->decorate('json_streamer.read.property_metadata_loader') + ->args([ + service('.inner'), + ]) + ->set('.json_streamer.read.property_metadata_loader.attribute', ReadAttributePropertyMetadataLoader::class) + ->decorate('json_streamer.read.property_metadata_loader') + ->args([ + service('.inner'), + tagged_locator('json_streamer.value_transformer'), + service('type_info.resolver'), + ]) + + // value transformers + ->set('json_streamer.value_transformer.date_time_to_string', DateTimeToStringValueTransformer::class) + ->tag('json_streamer.value_transformer') + + ->set('json_streamer.value_transformer.string_to_date_time', StringToDateTimeValueTransformer::class) + ->tag('json_streamer.value_transformer') + + // cache + ->set('.json_streamer.cache_warmer.streamer', StreamerCacheWarmer::class) + ->args([ + abstract_arg('streamable'), + service('json_streamer.write.property_metadata_loader'), + service('json_streamer.read.property_metadata_loader'), + param('.json_streamer.stream_writers_dir'), + param('.json_streamer.stream_readers_dir'), + service('logger')->ignoreOnInvalid(), + ]) + ->tag('kernel.cache_warmer') + + ->set('.json_streamer.cache_warmer.lazy_ghost', LazyGhostCacheWarmer::class) + ->args([ + abstract_arg('streamable class names'), + param('.json_streamer.lazy_ghosts_dir'), + ]) + ->tag('kernel.cache_warmer') + ; +}; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.php index 25b3fefdbfb00..43e7fb9a5e4cb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.php @@ -26,7 +26,6 @@ use Symfony\Component\Mailer\Transport\TransportInterface; use Symfony\Component\Mailer\Transport\Transports; use Symfony\Component\Mime\Crypto\DkimSigner; -use Symfony\Component\Mime\Crypto\SMimeEncrypter; use Symfony\Component\Mime\Crypto\SMimeSigner; return static function (ContainerConfigurator $container) { @@ -51,11 +50,7 @@ tagged_iterator('mailer.transport_factory'), ]) - ->set('mailer.default_transport', TransportInterface::class) - ->factory([service('mailer.transport_factory'), 'fromString']) - ->args([ - abstract_arg('env(MAILER_DSN)'), - ]) + ->alias('mailer.default_transport', 'mailer.transports') ->alias(TransportInterface::class, 'mailer.default_transport') ->set('mailer.messenger.message_handler', MessageHandler::class) @@ -95,22 +90,16 @@ ->set('mailer.smime_signer', SMimeSigner::class) ->args([ - abstract_arg('key'), abstract_arg('certificate'), + abstract_arg('key'), abstract_arg('passphrase'), abstract_arg('extraCertificates'), abstract_arg('signOptions'), ]) - ->set('mailer.smime_encrypter', SMimeEncrypter::class) - ->args([ - abstract_arg('certificate'), - abstract_arg('cipher'), - ]) - ->set('mailer.dkim_signer.listener', DkimSignedMessageListener::class) ->args([ - service(DkimSigner::class), + service('mailer.dkim_signer'), ]) ->tag('kernel.event_subscriber') @@ -122,7 +111,8 @@ ->set('mailer.smime_encrypter.listener', SmimeEncryptedMessageListener::class) ->args([ - service('mailer.smime_encrypter'), + service('mailer.smime_encrypter.repository'), + param('mailer.smime_encrypter.cipher'), ]) ->tag('kernel.event_subscriber') diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.php index 8798d5f2e5e3e..e02cd1ca34c0d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.php @@ -18,6 +18,7 @@ use Symfony\Component\Messenger\Bridge\Redis\Transport\RedisTransportFactory; use Symfony\Component\Messenger\EventListener\AddErrorDetailsStampListener; use Symfony\Component\Messenger\EventListener\DispatchPcntlSignalListener; +use Symfony\Component\Messenger\EventListener\ResetMemoryUsageListener; use Symfony\Component\Messenger\EventListener\ResetServicesListener; use Symfony\Component\Messenger\EventListener\SendFailedMessageForRetryListener; use Symfony\Component\Messenger\EventListener\SendFailedMessageToFailureTransportListener; @@ -218,6 +219,9 @@ service('services_resetter'), ]) + ->set('messenger.listener.reset_memory_usage', ResetMemoryUsageListener::class) + ->tag('kernel.event_subscriber') + ->set('messenger.routable_message_bus', RoutableMessageBus::class) ->args([ abstract_arg('message bus locator'), diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php index f28007decf81b..d1adcfc370395 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php @@ -36,6 +36,7 @@ 'line-notify' => Bridge\LineNotify\LineNotifyTransportFactory::class, 'linked-in' => Bridge\LinkedIn\LinkedInTransportFactory::class, 'mastodon' => Bridge\Mastodon\MastodonTransportFactory::class, + 'matrix' => Bridge\Matrix\MatrixTransportFactory::class, 'mattermost' => Bridge\Mattermost\MattermostTransportFactory::class, 'mercure' => Bridge\Mercure\MercureTransportFactory::class, 'microsoft-teams' => Bridge\MicrosoftTeams\MicrosoftTeamsTransportFactory::class, diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_webhook.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_webhook.php index 6447f41394679..0b30c33e25afa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_webhook.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_webhook.php @@ -11,12 +11,16 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; +use Symfony\Component\Notifier\Bridge\Smsbox\Webhook\SmsboxRequestParser; use Symfony\Component\Notifier\Bridge\Sweego\Webhook\SweegoRequestParser; use Symfony\Component\Notifier\Bridge\Twilio\Webhook\TwilioRequestParser; use Symfony\Component\Notifier\Bridge\Vonage\Webhook\VonageRequestParser; return static function (ContainerConfigurator $container) { $container->services() + ->set('notifier.webhook.request_parser.smsbox', SmsboxRequestParser::class) + ->alias(SmsboxRequestParser::class, 'notifier.webhook.request_parser.smsbox') + ->set('notifier.webhook.request_parser.sweego', SweegoRequestParser::class) ->alias(SweegoRequestParser::class, 'notifier.webhook.request_parser.sweego') diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/object_mapper.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/object_mapper.php new file mode 100644 index 0000000000000..8addad4da04fe --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/object_mapper.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Loader\Configurator; + +use Symfony\Component\ObjectMapper\Metadata\ObjectMapperMetadataFactoryInterface; +use Symfony\Component\ObjectMapper\Metadata\ReflectionObjectMapperMetadataFactory; +use Symfony\Component\ObjectMapper\ObjectMapper; +use Symfony\Component\ObjectMapper\ObjectMapperInterface; + +return static function (ContainerConfigurator $container) { + $container->services() + ->set('object_mapper.metadata_factory', ReflectionObjectMapperMetadataFactory::class) + ->alias(ObjectMapperMetadataFactoryInterface::class, 'object_mapper.metadata_factory') + + ->set('object_mapper', ObjectMapper::class) + ->args([ + service('object_mapper.metadata_factory'), + service('property_accessor')->ignoreOnInvalid(), + tagged_locator('object_mapper.transform_callable'), + tagged_locator('object_mapper.condition_callable'), + ]) + ->alias(ObjectMapperInterface::class, 'object_mapper') + ; +}; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php index 4ae34649b4aaf..a81c53a633461 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php @@ -12,10 +12,12 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; use Symfony\Bundle\FrameworkBundle\EventListener\ConsoleProfilerListener; +use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Component\HttpKernel\Debug\VirtualRequestStack; use Symfony\Component\HttpKernel\EventListener\ProfilerListener; use Symfony\Component\HttpKernel\Profiler\FileProfilerStorage; use Symfony\Component\HttpKernel\Profiler\Profiler; +use Symfony\Component\HttpKernel\Profiler\ProfilerStateChecker; return static function (ContainerConfigurator $container) { $container->services() @@ -56,5 +58,15 @@ ->set('.virtual_request_stack', VirtualRequestStack::class) ->args([service('request_stack')]) ->public() + + ->set('profiler.state_checker', ProfilerStateChecker::class) + ->args([ + service_locator(['profiler' => service('profiler')->ignoreOnUninitialized()]), + inline_service('bool')->factory([FrameworkBundle::class, 'considerProfilerEnabled']), + ]) + + ->set('profiler.is_disabled_state_checker', 'Closure') + ->factory(['Closure', 'fromCallable']) + ->args([[service('profiler.state_checker'), 'isProfilerDisabled']]) ; }; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/rate_limiter.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/rate_limiter.php index 90af4d7588f1d..727a1f6364456 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/rate_limiter.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/rate_limiter.php @@ -12,7 +12,6 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; use Symfony\Component\RateLimiter\RateLimiterFactory; -use Symfony\Component\RateLimiter\RateLimiterFactoryInterface; return static function (ContainerConfigurator $container) { $container->services() @@ -28,9 +27,4 @@ null, ]) ; - - if (interface_exists(RateLimiterFactoryInterface::class)) { - $container->services() - ->alias(RateLimiterFactoryInterface::class, 'limiter'); - } }; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/errors.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/errors.php new file mode 100644 index 0000000000000..36a46dee407ea --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/errors.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; +use Symfony\Component\Routing\Loader\XmlFileLoader; + +return function (RoutingConfigurator $routes): void { + foreach (debug_backtrace() as $trace) { + if (isset($trace['object']) && $trace['object'] instanceof XmlFileLoader && 'doImport' === $trace['function']) { + if (__DIR__ === dirname(realpath($trace['args'][3]))) { + trigger_deprecation('symfony/routing', '7.3', 'The "errors.xml" routing configuration file is deprecated, import "errors.php" instead.'); + + break; + } + } + } + + $routes->add('_preview_error', '/{code}.{_format}') + ->controller('error_controller::preview') + ->defaults(['_format' => 'html']) + ->requirements(['code' => '\d+']) + ; +}; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/errors.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/errors.xml index 13a9cc4076c79..f890aef1e3365 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/errors.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/errors.xml @@ -4,9 +4,5 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd"> - - error_controller::preview - html - \d+ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/webhook.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/webhook.php new file mode 100644 index 0000000000000..177606b26214e --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/webhook.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; +use Symfony\Component\Routing\Loader\XmlFileLoader; + +return function (RoutingConfigurator $routes): void { + foreach (debug_backtrace() as $trace) { + if (isset($trace['object']) && $trace['object'] instanceof XmlFileLoader && 'doImport' === $trace['function']) { + if (__DIR__ === dirname(realpath($trace['args'][3]))) { + trigger_deprecation('symfony/routing', '7.3', 'The "webhook.xml" routing configuration file is deprecated, import "webhook.php" instead.'); + + break; + } + } + } + + $routes->add('_webhook_controller', '/{type}') + ->controller('webhook.controller::handle') + ->requirements(['type' => '.+']) + ; +}; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/webhook.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/webhook.xml index dfa95cfac555e..8cb64ebb74fd7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/webhook.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/webhook.xml @@ -4,8 +4,5 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd"> - - webhook.controller::handle - .+ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index b47de331a4775..a8567aa3e717e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -46,7 +46,7 @@ - + @@ -80,7 +80,7 @@ - + @@ -256,6 +256,7 @@ + @@ -285,6 +286,24 @@ + + + + + + + + + + + + + + + + + + @@ -319,6 +338,7 @@ + @@ -430,6 +450,7 @@ + @@ -836,7 +857,7 @@ - + @@ -1041,7 +1062,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.php index 01b9a3eb0dd58..e0a256bbe3640 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.php @@ -56,7 +56,7 @@ return static function (ContainerConfigurator $container) { $container->parameters() - ->set('serializer.mapping.cache.file', '%kernel.cache_dir%/serialization.php') + ->set('serializer.mapping.cache.file', '%kernel.build_dir%/serialization.php') ; $container->services() @@ -130,7 +130,7 @@ service('property_info')->ignoreOnInvalid(), service('serializer.mapping.class_discriminator_resolver')->ignoreOnInvalid(), null, - null, + abstract_arg('default context, set in the SerializerPass'), service('property_info')->ignoreOnInvalid(), ]) ->tag('serializer.normalizer', ['built_in' => true, 'priority' => -1000]) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.php index e5a86d8f411f5..936867d542afb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.php @@ -42,6 +42,7 @@ use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate; use Symfony\Component\HttpKernel\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter; +use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetterInterface; use Symfony\Component\HttpKernel\EventListener\LocaleAwareListener; use Symfony\Component\HttpKernel\HttpCache\Store; use Symfony\Component\HttpKernel\HttpCache\StoreInterface; @@ -157,6 +158,9 @@ class_exists(WorkflowEvents::class) ? WorkflowEvents::ALIASES : [] ->set('uri_signer', UriSigner::class) ->args([ new Parameter('kernel.secret'), + '_hash', + '_expiration', + service('clock')->nullOnInvalid(), ]) ->lazy() ->alias(UriSigner::class, 'uri_signer') @@ -177,6 +181,7 @@ class_exists(WorkflowEvents::class) ? WorkflowEvents::ALIASES : [] ->set('services_resetter', ServicesResetter::class) ->public() + ->alias(ServicesResetterInterface::class, 'services_resetter') ->set('reverse_container', ReverseContainer::class) ->args([ diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.php index adde2de238e05..535b42edc1bc3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.php @@ -28,7 +28,7 @@ return static function (ContainerConfigurator $container) { $container->parameters() - ->set('validator.mapping.cache.file', param('kernel.cache_dir').'/validation.php'); + ->set('validator.mapping.cache.file', '%kernel.build_dir%/validation.php'); $validatorsDir = \dirname((new \ReflectionClass(EmailValidator::class))->getFileName()); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator_debug.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator_debug.php index e9fe441140742..b195aea2b57b0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator_debug.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator_debug.php @@ -20,6 +20,7 @@ ->decorate('validator', null, 255) ->args([ service('debug.validator.inner'), + service('profiler.is_disabled_state_checker')->nullOnInvalid(), ]) ->tag('kernel.reset', [ 'method' => 'reset', diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.php index 6f8358fb0c7b8..a4e975dac8749 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.php @@ -138,6 +138,7 @@ service('logger')->nullOnInvalid(), param('kernel.debug'), abstract_arg('an exceptions to log & status code mapping'), + abstract_arg('list of loggers by log_channel'), ]) ->tag('kernel.event_subscriber') ->tag('monolog.logger', ['channel' => 'request']) diff --git a/src/Symfony/Bundle/FrameworkBundle/Secrets/AbstractVault.php b/src/Symfony/Bundle/FrameworkBundle/Secrets/AbstractVault.php index 882ec78628839..788601d2e91ed 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Secrets/AbstractVault.php +++ b/src/Symfony/Bundle/FrameworkBundle/Secrets/AbstractVault.php @@ -31,6 +31,9 @@ abstract public function reveal(string $name): ?string; abstract public function remove(string $name): bool; + /** + * @return array + */ abstract public function list(bool $reveal = false): array; protected function validateName(string $name): void diff --git a/src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php b/src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php index 15952611ac1a1..3fab5f4e28525 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php +++ b/src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php @@ -89,13 +89,13 @@ public function list(bool $reveal = false): array foreach ($_ENV as $k => $v) { if ('' !== ($v ?? '') && preg_match('/^\w+$/D', $k)) { - $secrets[$k] = $reveal ? $v : null; + $secrets[$k] = \is_string($v) && $reveal ? $v : null; } } foreach ($_SERVER as $k => $v) { if ('' !== ($v ?? '') && preg_match('/^\w+$/D', $k)) { - $secrets[$k] = $reveal ? $v : null; + $secrets[$k] = \is_string($v) && $reveal ? $v : null; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php b/src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php index 9d22a822fb851..4a8afbab4ab98 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php @@ -14,10 +14,9 @@ use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Component\HttpClient\DataCollector\HttpClientDataCollector; -/* +/** * @author Mathieu Santostefano */ - trait HttpClientAssertionsTrait { public static function assertHttpClientRequest(string $expectedUrl, string $expectedMethod = 'GET', string|array|null $expectedBody = null, array $expectedHeaders = [], string $httpClientId = 'http_client'): void diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php index b2c2eb4d23089..87925f73c9b52 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php @@ -39,6 +39,14 @@ protected function tearDown(): void static::$booted = false; } + public static function tearDownAfterClass(): void + { + static::ensureKernelShutdown(); + static::$class = null; + static::$kernel = null; + static::$booted = false; + } + /** * @throws \RuntimeException * @throws \LogicException diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/NotificationAssertionsTrait.php b/src/Symfony/Bundle/FrameworkBundle/Test/NotificationAssertionsTrait.php index b68473561eb4d..2c4c5467d4ebd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/NotificationAssertionsTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/NotificationAssertionsTrait.php @@ -17,7 +17,7 @@ use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Test\Constraint as NotifierConstraint; -/* +/** * @author Smaïne Milianni */ trait NotificationAssertionsTrait diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php index 5feb0c8ec1bd7..f17aad0e3dc60 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php @@ -21,6 +21,23 @@ class SerializerCacheWarmerTest extends TestCase { + private PhpArrayAdapter $arrayPool; + + protected function tearDown(): void + { + parent::tearDown(); + + if (isset($this->arrayPool)) { + $this->arrayPool->clear(); + unset($this->arrayPool); + } + } + + private function getArrayPool(string $file): PhpArrayAdapter + { + return $this->arrayPool = new PhpArrayAdapter($file, new NullAdapter()); + } + /** * @dataProvider loaderProvider */ @@ -30,16 +47,57 @@ public function testWarmUp(array $loaders) @unlink($file); $warmer = new SerializerCacheWarmer($loaders, $file); - $warmer->warmUp(\dirname($file)); + $warmer->warmUp(\dirname($file), \dirname($file)); + + $this->assertFileExists($file); + + $arrayPool = $this->getArrayPool($file); + + $this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person')->isHit()); + $this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit()); + } + + /** + * @dataProvider loaderProvider + */ + public function testWarmUpAbsoluteFilePath(array $loaders) + { + $file = sys_get_temp_dir().'/0/cache-serializer.php'; + @unlink($file); + + $cacheDir = sys_get_temp_dir().'/1'; + + $warmer = new SerializerCacheWarmer($loaders, $file); + $warmer->warmUp($cacheDir, $cacheDir); $this->assertFileExists($file); + $this->assertFileDoesNotExist($cacheDir.'/cache-serializer.php'); - $arrayPool = new PhpArrayAdapter($file, new NullAdapter()); + $arrayPool = $this->getArrayPool($file); $this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person')->isHit()); $this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit()); } + /** + * @dataProvider loaderProvider + */ + public function testWarmUpWithoutBuildDir(array $loaders) + { + $file = sys_get_temp_dir().'/cache-serializer.php'; + @unlink($file); + + $warmer = new SerializerCacheWarmer($loaders, $file); + $warmer->warmUp(\dirname($file)); + + $this->assertFileDoesNotExist($file); + + $arrayPool = $this->getArrayPool($file); + + $this->assertFalse($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person')->isHit()); + $this->assertFalse($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit()); + } + public static function loaderProvider(): array { return [ @@ -66,7 +124,7 @@ public function testWarmUpWithoutLoader() @unlink($file); $warmer = new SerializerCacheWarmer([], $file); - $warmer->warmUp(\dirname($file)); + $warmer->warmUp(\dirname($file), \dirname($file)); $this->assertFileExists($file); } @@ -79,7 +137,10 @@ public function testClassAutoloadException() { $this->assertFalse(class_exists($mappedClass = 'AClassThatDoesNotExist_FWB_CacheWarmer_SerializerCacheWarmerTest', false)); - $warmer = new SerializerCacheWarmer([new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/does_not_exist.yaml')], tempnam(sys_get_temp_dir(), __FUNCTION__)); + $file = tempnam(sys_get_temp_dir(), __FUNCTION__); + @unlink($file); + + $warmer = new SerializerCacheWarmer([new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/does_not_exist.yaml')], $file); spl_autoload_register($classLoader = function ($class) use ($mappedClass) { if ($class === $mappedClass) { @@ -87,7 +148,8 @@ public function testClassAutoloadException() } }, true, true); - $warmer->warmUp('foo'); + $warmer->warmUp(\dirname($file), \dirname($file)); + $this->assertFileExists($file); spl_autoload_unregister($classLoader); } @@ -98,12 +160,12 @@ public function testClassAutoloadException() */ public function testClassAutoloadExceptionWithUnrelatedException() { - $this->expectException(\DomainException::class); - $this->expectExceptionMessage('This exception should not be caught by the warmer.'); - $this->assertFalse(class_exists($mappedClass = 'AClassThatDoesNotExist_FWB_CacheWarmer_SerializerCacheWarmerTest', false)); - $warmer = new SerializerCacheWarmer([new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/does_not_exist.yaml')], tempnam(sys_get_temp_dir(), __FUNCTION__)); + $file = tempnam(sys_get_temp_dir(), __FUNCTION__); + @unlink($file); + + $warmer = new SerializerCacheWarmer([new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/does_not_exist.yaml')], basename($file)); spl_autoload_register($classLoader = function ($class) use ($mappedClass) { if ($class === $mappedClass) { @@ -112,8 +174,17 @@ public function testClassAutoloadExceptionWithUnrelatedException() } }, true, true); - $warmer->warmUp('foo'); + $this->expectException(\DomainException::class); + $this->expectExceptionMessage('This exception should not be caught by the warmer.'); + + try { + $warmer->warmUp(\dirname($file), \dirname($file)); + } catch (\DomainException $e) { + $this->assertFileDoesNotExist($file); - spl_autoload_unregister($classLoader); + throw $e; + } finally { + spl_autoload_unregister($classLoader); + } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php index cc471e43fc685..01d70d3a19262 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php @@ -20,6 +20,23 @@ class ValidatorCacheWarmerTest extends TestCase { + private PhpArrayAdapter $arrayPool; + + protected function tearDown(): void + { + parent::tearDown(); + + if (isset($this->arrayPool)) { + $this->arrayPool->clear(); + unset($this->arrayPool); + } + } + + private function getArrayPool(string $file): PhpArrayAdapter + { + return $this->arrayPool = new PhpArrayAdapter($file, new NullAdapter()); + } + public function testWarmUp() { $validatorBuilder = new ValidatorBuilder(); @@ -32,16 +49,63 @@ public function testWarmUp() @unlink($file); $warmer = new ValidatorCacheWarmer($validatorBuilder, $file); - $warmer->warmUp(\dirname($file)); + $warmer->warmUp(\dirname($file), \dirname($file)); $this->assertFileExists($file); - $arrayPool = new PhpArrayAdapter($file, new NullAdapter()); + $arrayPool = $this->getArrayPool($file); $this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit()); $this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author')->isHit()); } + public function testWarmUpAbsoluteFilePath() + { + $validatorBuilder = new ValidatorBuilder(); + $validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml'); + $validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml'); + $validatorBuilder->addMethodMapping('loadValidatorMetadata'); + $validatorBuilder->enableAttributeMapping(); + + $file = sys_get_temp_dir().'/0/cache-validator.php'; + @unlink($file); + + $cacheDir = sys_get_temp_dir().'/1'; + + $warmer = new ValidatorCacheWarmer($validatorBuilder, $file); + $warmer->warmUp($cacheDir, $cacheDir); + + $this->assertFileExists($file); + $this->assertFileDoesNotExist($cacheDir.'/cache-validator.php'); + + $arrayPool = $this->getArrayPool($file); + + $this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit()); + $this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author')->isHit()); + } + + public function testWarmUpWithoutBuilDir() + { + $validatorBuilder = new ValidatorBuilder(); + $validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml'); + $validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml'); + $validatorBuilder->addMethodMapping('loadValidatorMetadata'); + $validatorBuilder->enableAttributeMapping(); + + $file = sys_get_temp_dir().'/cache-validator.php'; + @unlink($file); + + $warmer = new ValidatorCacheWarmer($validatorBuilder, $file); + $warmer->warmUp(\dirname($file)); + + $this->assertFileDoesNotExist($file); + + $arrayPool = $this->getArrayPool($file); + + $this->assertFalse($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit()); + $this->assertFalse($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author')->isHit()); + } + public function testWarmUpWithAnnotations() { $validatorBuilder = new ValidatorBuilder(); @@ -52,11 +116,11 @@ public function testWarmUpWithAnnotations() @unlink($file); $warmer = new ValidatorCacheWarmer($validatorBuilder, $file); - $warmer->warmUp(\dirname($file)); + $warmer->warmUp(\dirname($file), \dirname($file)); $this->assertFileExists($file); - $arrayPool = new PhpArrayAdapter($file, new NullAdapter()); + $arrayPool = $this->getArrayPool($file); $item = $arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Category'); $this->assertTrue($item->isHit()); @@ -72,7 +136,7 @@ public function testWarmUpWithoutLoader() @unlink($file); $warmer = new ValidatorCacheWarmer($validatorBuilder, $file); - $warmer->warmUp(\dirname($file)); + $warmer->warmUp(\dirname($file), \dirname($file)); $this->assertFileExists($file); } @@ -85,9 +149,12 @@ public function testClassAutoloadException() { $this->assertFalse(class_exists($mappedClass = 'AClassThatDoesNotExist_FWB_CacheWarmer_ValidatorCacheWarmerTest', false)); + $file = tempnam(sys_get_temp_dir(), __FUNCTION__); + @unlink($file); + $validatorBuilder = new ValidatorBuilder(); $validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/does_not_exist.yaml'); - $warmer = new ValidatorCacheWarmer($validatorBuilder, tempnam(sys_get_temp_dir(), __FUNCTION__)); + $warmer = new ValidatorCacheWarmer($validatorBuilder, $file); spl_autoload_register($classloader = function ($class) use ($mappedClass) { if ($class === $mappedClass) { @@ -95,7 +162,9 @@ public function testClassAutoloadException() } }, true, true); - $warmer->warmUp('foo'); + $warmer->warmUp(\dirname($file), \dirname($file)); + + $this->assertFileExists($file); spl_autoload_unregister($classloader); } @@ -106,14 +175,14 @@ public function testClassAutoloadException() */ public function testClassAutoloadExceptionWithUnrelatedException() { - $this->expectException(\DomainException::class); - $this->expectExceptionMessage('This exception should not be caught by the warmer.'); + $file = tempnam(sys_get_temp_dir(), __FUNCTION__); + @unlink($file); $this->assertFalse(class_exists($mappedClass = 'AClassThatDoesNotExist_FWB_CacheWarmer_ValidatorCacheWarmerTest', false)); $validatorBuilder = new ValidatorBuilder(); $validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/does_not_exist.yaml'); - $warmer = new ValidatorCacheWarmer($validatorBuilder, tempnam(sys_get_temp_dir(), __FUNCTION__)); + $warmer = new ValidatorCacheWarmer($validatorBuilder, basename($file)); spl_autoload_register($classLoader = function ($class) use ($mappedClass) { if ($class === $mappedClass) { @@ -122,8 +191,17 @@ public function testClassAutoloadExceptionWithUnrelatedException() } }, true, true); - $warmer->warmUp('foo'); + $this->expectException(\DomainException::class); + $this->expectExceptionMessage('This exception should not be caught by the warmer.'); + + try { + $warmer->warmUp(\dirname($file), \dirname($file)); + } catch (\DomainException $e) { + $this->assertFileDoesNotExist($file); - spl_autoload_unregister($classLoader); + throw $e; + } finally { + spl_autoload_unregister($classLoader); + } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsDecryptToLocalCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsDecryptToLocalCommandTest.php new file mode 100644 index 0000000000000..8a1c05d693750 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsDecryptToLocalCommandTest.php @@ -0,0 +1,95 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Command; + +use PHPUnit\Framework\TestCase; +use Symfony\Bundle\FrameworkBundle\Command\SecretsDecryptToLocalCommand; +use Symfony\Bundle\FrameworkBundle\Secrets\SodiumVault; +use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\Filesystem\Filesystem; + +/** + * @requires extension sodium + */ +class SecretsDecryptToLocalCommandTest extends TestCase +{ + private string $mainDir; + private string $localDir; + + protected function setUp(): void + { + $this->mainDir = sys_get_temp_dir().'/sf_secrets/main/'; + $this->localDir = sys_get_temp_dir().'/sf_secrets/local/'; + + $fs = new Filesystem(); + $fs->remove([$this->mainDir, $this->localDir]); + + $mainVault = new SodiumVault($this->mainDir); + $mainVault->generateKeys(); + $mainVault->seal('FOO_SECRET', 'super_secret_value'); + + $localVault = new SodiumVault($this->localDir); + $localVault->generateKeys(); + } + + protected function tearDown(): void + { + (new Filesystem())->remove([$this->mainDir, $this->localDir]); + } + + public function testSecretsAreDecryptedAndStoredInLocalVault() + { + $mainVault = new SodiumVault($this->mainDir); + $localVault = new SodiumVault($this->localDir); + $tester = new CommandTester(new SecretsDecryptToLocalCommand($mainVault, $localVault)); + + $this->assertSame(0, $tester->execute([])); + $this->assertStringContainsString('1 secret found in the vault.', $tester->getDisplay()); + $this->assertStringContainsString('Secret "FOO_SECRET" encrypted', $tester->getDisplay()); + + $this->assertArrayHasKey('FOO_SECRET', $localVault->list(true)); + $this->assertSame('super_secret_value', $localVault->reveal('FOO_SECRET')); + } + + public function testExistingLocalSecretsAreSkippedWithoutForce() + { + $mainVault = new SodiumVault($this->mainDir); + $localVault = new SodiumVault($this->localDir); + $localVault->seal('FOO_SECRET', 'old_value'); + $tester = new CommandTester(new SecretsDecryptToLocalCommand($mainVault, $localVault)); + + $this->assertSame(0, $tester->execute([])); + $this->assertStringContainsString('1 secret is already overridden in the local vault and will be skipped.', $tester->getDisplay()); + $this->assertSame('old_value', $localVault->reveal('FOO_SECRET')); + } + + public function testForceOptionOverridesLocalSecrets() + { + $mainVault = new SodiumVault($this->mainDir); + $localVault = new SodiumVault($this->localDir); + $localVault->seal('FOO_SECRET', 'old_value'); + $tester = new CommandTester(new SecretsDecryptToLocalCommand($mainVault, $localVault)); + + $this->assertSame(0, $tester->execute(['--force' => true])); + $this->assertStringContainsString('Secret "FOO_SECRET" encrypted', $tester->getDisplay()); + $this->assertSame('super_secret_value', $localVault->reveal('FOO_SECRET')); + } + + public function testFailsGracefullyWhenLocalVaultIsDisabled() + { + $mainVault = new SodiumVault($this->mainDir); + $tester = new CommandTester(new SecretsDecryptToLocalCommand($mainVault, null)); + + $this->assertSame(1, $tester->execute([])); + $this->assertStringContainsString('The local vault is disabled.', $tester->getDisplay()); + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsEncryptFromLocalCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsEncryptFromLocalCommandTest.php new file mode 100644 index 0000000000000..68926c175b8f7 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsEncryptFromLocalCommandTest.php @@ -0,0 +1,111 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Command; + +use PHPUnit\Framework\TestCase; +use Symfony\Bundle\FrameworkBundle\Command\SecretsEncryptFromLocalCommand; +use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault; +use Symfony\Bundle\FrameworkBundle\Secrets\SodiumVault; +use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\Filesystem\Filesystem; + +/** + * @requires extension sodium + */ +class SecretsEncryptFromLocalCommandTest extends TestCase +{ + private string $vaultDir; + private string $localVaultDir; + private Filesystem $fs; + + protected function setUp(): void + { + $this->vaultDir = sys_get_temp_dir().'/sf_secrets/vault_'.uniqid(); + $this->localVaultDir = sys_get_temp_dir().'/sf_secrets/local_'.uniqid(); + $this->fs = new Filesystem(); + $this->fs->remove([$this->vaultDir, $this->localVaultDir]); + } + + protected function tearDown(): void + { + $this->fs->remove([$this->vaultDir, $this->localVaultDir]); + } + + public function testFailsWhenLocalVaultIsDisabled() + { + $vault = $this->createMock(AbstractVault::class); + $command = new SecretsEncryptFromLocalCommand($vault, null); + $tester = new CommandTester($command); + + $this->assertSame(1, $tester->execute([])); + $this->assertStringContainsString('The local vault is disabled.', $tester->getDisplay()); + } + + public function testEncryptsLocalOverrides() + { + $vault = new SodiumVault($this->vaultDir); + $vault->generateKeys(); + + $localVault = new SodiumVault($this->localVaultDir); + $localVault->generateKeys(); + + $vault->seal('MY_SECRET', 'prod-value'); + $localVault->seal('MY_SECRET', 'local-value'); + + $command = new SecretsEncryptFromLocalCommand($vault, $localVault); + $tester = new CommandTester($command); + + $exitCode = $tester->execute([]); + $this->assertSame(0, $exitCode); + + $revealed = $vault->reveal('MY_SECRET'); + $this->assertSame('local-value', $revealed); + } + + public function testDoesNotSealIfSameValue() + { + $vault = new SodiumVault($this->vaultDir); + $vault->generateKeys(); + + $localVault = new SodiumVault($this->localVaultDir); + $localVault->generateKeys(); + + $vault->seal('SHARED_SECRET', 'same-value'); + $localVault->seal('SHARED_SECRET', 'same-value'); + + $command = new SecretsEncryptFromLocalCommand($vault, $localVault); + $tester = new CommandTester($command); + + $exitCode = $tester->execute([]); + $this->assertSame(0, $exitCode); + + $revealed = $vault->reveal('SHARED_SECRET'); + $this->assertSame('same-value', $revealed); + } + + public function testFailsIfLocalSecretIsMissing() + { + $vault = new SodiumVault($this->vaultDir); + $vault->generateKeys(); + + $localVault = new SodiumVault($this->localVaultDir); + $localVault->generateKeys(); + + $vault->seal('MISSING_IN_LOCAL', 'prod-only'); + + $command = new SecretsEncryptFromLocalCommand($vault, $localVault); + $tester = new CommandTester($command); + + $this->assertSame(1, $tester->execute([])); + $this->assertStringContainsString('Secret "MISSING_IN_LOCAL" not found', $tester->getDisplay()); + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsGenerateKeysCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsGenerateKeysCommandTest.php new file mode 100644 index 0000000000000..9574782bf2d49 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsGenerateKeysCommandTest.php @@ -0,0 +1,90 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Command; + +use PHPUnit\Framework\TestCase; +use Symfony\Bundle\FrameworkBundle\Command\SecretsGenerateKeysCommand; +use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault; +use Symfony\Bundle\FrameworkBundle\Secrets\SodiumVault; +use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\Filesystem\Filesystem; + +/** + * @requires extension sodium + */ +class SecretsGenerateKeysCommandTest extends TestCase +{ + private string $secretsDir; + private const ENC_KEY_FILE = 'test.encrypt.public.php'; + private const DEC_KEY_FILE = 'test.decrypt.private.php'; + + protected function setUp(): void + { + $this->secretsDir = sys_get_temp_dir().'/sf_secrets/test/'; + (new Filesystem())->remove($this->secretsDir); + } + + protected function tearDown(): void + { + (new Filesystem())->remove($this->secretsDir); + } + + public function testItGeneratesSodiumKeys() + { + $vault = new SodiumVault($this->secretsDir); + $tester = new CommandTester(new SecretsGenerateKeysCommand($vault)); + + $this->assertSame(0, $tester->execute([])); + $this->assertKeysExistAndReadable(); + } + + public function testItRotatesSodiumKeysWhenRequested() + { + $vault = new SodiumVault($this->secretsDir); + $tester = new CommandTester(new SecretsGenerateKeysCommand($vault)); + + $this->assertSame(0, $tester->execute(['--rotate' => true])); + $this->assertKeysExistAndReadable(); + } + + public function testItFailsGracefullyWhenLocalVaultIsDisabled() + { + $vault = $this->createMock(AbstractVault::class); + $tester = new CommandTester(new SecretsGenerateKeysCommand($vault)); + + $this->assertSame(1, $tester->execute(['--local' => true])); + $this->assertStringContainsString('The local vault is disabled.', $tester->getDisplay()); + } + + public function testFailsWhenKeysAlreadyExistAndRotateNotPassed() + { + $vault = new SodiumVault($this->secretsDir); + $vault->generateKeys(); + + $command = new SecretsGenerateKeysCommand($vault); + $tester = new CommandTester($command); + + $this->assertSame(1, $tester->execute([])); + $this->assertStringContainsString('Sodium keys already exist at', $tester->getDisplay()); + } + + private function assertKeysExistAndReadable(): void + { + $encPath = $this->secretsDir.'/'.self::ENC_KEY_FILE; + $decPath = $this->secretsDir.'/'.self::DEC_KEY_FILE; + + $this->assertFileExists($encPath, 'Encryption key file does not exist.'); + $this->assertFileExists($decPath, 'Decryption key file does not exist.'); + $this->assertNotFalse(@file_get_contents($encPath), 'Encryption key file is not readable.'); + $this->assertNotFalse(@file_get_contents($decPath), 'Decryption key file is not readable.'); + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRevealCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRevealCommandTest.php index 94643db2c92c5..d77d303d5c88b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRevealCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRevealCommandTest.php @@ -46,6 +46,19 @@ public function testInvalidName() $this->assertStringContainsString('The secret "undefinedKey" does not exist.', trim($tester->getDisplay(true))); } + public function testFailedDecrypt() + { + $vault = $this->createMock(AbstractVault::class); + $vault->method('list')->willReturn(['secretKey' => null]); + + $command = new SecretsRevealCommand($vault); + + $tester = new CommandTester($command); + $this->assertSame(Command::INVALID, $tester->execute(['name' => 'secretKey'])); + + $this->assertStringContainsString('The secret "secretKey" could not be decrypted.', trim($tester->getDisplay(true))); + } + /** * @backupGlobals enabled */ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php index 9afb5a2fd85f6..0b92a813c2d27 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php @@ -135,7 +135,11 @@ public function testRunOnlyWarnsOnUnregistrableCommand() $kernel ->method('getBundles') ->willReturn([$this->createBundleMock( - [(new Command('fine'))->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('fine'); })] + [(new Command('fine'))->setCode(function (InputInterface $input, OutputInterface $output): int { + $output->write('fine'); + + return 0; + })] )]); $kernel ->method('getContainer') @@ -163,7 +167,11 @@ public function testRegistrationErrorsAreDisplayedOnCommandNotFound() $kernel ->method('getBundles') ->willReturn([$this->createBundleMock( - [(new Command(null))->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('fine'); })] + [(new Command(null))->setCode(function (InputInterface $input, OutputInterface $output): int { + $output->write('fine'); + + return 0; + })] )]); $kernel ->method('getContainer') @@ -193,7 +201,11 @@ public function testRunOnlyWarnsOnUnregistrableCommandAtTheEnd() $kernel ->method('getBundles') ->willReturn([$this->createBundleMock( - [(new Command('fine'))->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('fine'); })] + [(new Command('fine'))->setCode(function (InputInterface $input, OutputInterface $output): int { + $output->write('fine'); + + return 0; + })] )]); $kernel ->method('getContainer') diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTestCase.php index 477bd1014f2e5..eb18fbcc75b79 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTestCase.php @@ -50,6 +50,21 @@ public static function getDescribeRouteCollectionTestData(): array return static::getDescriptionTestData(ObjectsProvider::getRouteCollections()); } + /** @dataProvider getDescribeRouteCollectionWithHttpMethodFilterTestData */ + public function testDescribeRouteCollectionWithHttpMethodFilter(string $httpMethod, RouteCollection $routes, $expectedDescription) + { + $this->assertDescription($expectedDescription, $routes, ['method' => $httpMethod]); + } + + public static function getDescribeRouteCollectionWithHttpMethodFilterTestData(): iterable + { + foreach (ObjectsProvider::getRouteCollectionsByHttpMethod() as $httpMethod => $routeCollection) { + foreach (static::getDescriptionTestData($routeCollection) as $testData) { + yield [$httpMethod, ...$testData]; + } + } + } + /** @dataProvider getDescribeRouteTestData */ public function testDescribeRoute(Route $route, $expectedDescription) { @@ -273,6 +288,7 @@ private function assertDescription($expectedDescription, $describedObject, array $options['is_debug'] = false; $options['raw_output'] = true; $options['raw_text'] = true; + $options['method'] ??= null; $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true); if ('txt' === $this->getFormat()) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php index 84adc4ac9bc45..8eb1c438601c2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php @@ -37,6 +37,38 @@ public static function getRouteCollections() return ['route_collection_1' => $collection1]; } + public static function getRouteCollectionsByHttpMethod(): array + { + $collection = new RouteCollection(); + foreach (self::getRoutes() as $name => $route) { + $collection->add($name, $route); + } + + // Clone the original collection and add a route without any specific method restrictions + $collectionWithRouteWithoutMethodRestriction = clone $collection; + $collectionWithRouteWithoutMethodRestriction->add( + 'route_3', + new RouteStub( + '/other/route', + [], + [], + ['opt1' => 'val1', 'opt2' => 'val2'], + 'localhost', + ['http', 'https'], + [], + ) + ); + + return [ + 'GET' => [ + 'route_collection_2' => $collectionWithRouteWithoutMethodRestriction, + ], + 'PUT' => [ + 'route_collection_3' => $collection, + ], + ]; + } + public static function getRoutes() { return [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php index 55a3639848c32..2024cb8f77082 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php @@ -40,7 +40,10 @@ use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; +use Symfony\Component\Security\Core\Authorization\AccessDecision; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; +use Symfony\Component\Security\Core\Authorization\Voter\Vote; +use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\User\InMemoryUser; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; @@ -233,7 +236,7 @@ public function testFile() $controller = $this->createController(); $controller->setContainer($container); - /* @var BinaryFileResponse $response */ + /** @var BinaryFileResponse $response */ $response = $controller->file(new File(__FILE__)); $this->assertInstanceOf(BinaryFileResponse::class, $response); $this->assertSame(200, $response->getStatusCode()); @@ -248,7 +251,7 @@ public function testFileAsInline() { $controller = $this->createController(); - /* @var BinaryFileResponse $response */ + /** @var BinaryFileResponse $response */ $response = $controller->file(new File(__FILE__), null, ResponseHeaderBag::DISPOSITION_INLINE); $this->assertInstanceOf(BinaryFileResponse::class, $response); @@ -264,7 +267,7 @@ public function testFileWithOwnFileName() { $controller = $this->createController(); - /* @var BinaryFileResponse $response */ + /** @var BinaryFileResponse $response */ $fileName = 'test.php'; $response = $controller->file(new File(__FILE__), $fileName); @@ -281,7 +284,7 @@ public function testFileWithOwnFileNameAsInline() { $controller = $this->createController(); - /* @var BinaryFileResponse $response */ + /** @var BinaryFileResponse $response */ $fileName = 'test.php'; $response = $controller->file(new File(__FILE__), $fileName, ResponseHeaderBag::DISPOSITION_INLINE); @@ -298,7 +301,7 @@ public function testFileFromPath() { $controller = $this->createController(); - /* @var BinaryFileResponse $response */ + /** @var BinaryFileResponse $response */ $response = $controller->file(__FILE__); $this->assertInstanceOf(BinaryFileResponse::class, $response); @@ -314,7 +317,7 @@ public function testFileFromPathWithCustomizedFileName() { $controller = $this->createController(); - /* @var BinaryFileResponse $response */ + /** @var BinaryFileResponse $response */ $response = $controller->file(__FILE__, 'test.php'); $this->assertInstanceOf(BinaryFileResponse::class, $response); @@ -352,7 +355,19 @@ public function testIsGranted() public function testdenyAccessUnlessGranted() { $authorizationChecker = $this->createMock(AuthorizationCheckerInterface::class); - $authorizationChecker->expects($this->once())->method('isGranted')->willReturn(false); + $authorizationChecker + ->expects($this->once()) + ->method('isGranted') + ->willReturnCallback(function ($attribute, $subject, ?AccessDecision $accessDecision = null) { + if (class_exists(AccessDecision::class)) { + $this->assertInstanceOf(AccessDecision::class, $accessDecision); + $accessDecision->votes[] = $vote = new Vote(); + $vote->result = VoterInterface::ACCESS_DENIED; + $vote->reasons[] = 'Why should I.'; + } + + return false; + }); $container = new Container(); $container->set('security.authorization_checker', $authorizationChecker); @@ -361,8 +376,17 @@ public function testdenyAccessUnlessGranted() $controller->setContainer($container); $this->expectException(AccessDeniedException::class); + $this->expectExceptionMessage('Access Denied.'.(class_exists(AccessDecision::class) ? ' Why should I.' : '')); - $controller->denyAccessUnlessGranted('foo'); + try { + $controller->denyAccessUnlessGranted('foo'); + } catch (AccessDeniedException $e) { + if (class_exists(AccessDecision::class)) { + $this->assertFalse($e->getAccessDecision()->isGranted); + } + + throw $e; + } } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php index 7c7398fd32331..ce14ca559f13e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php @@ -11,15 +11,15 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; +use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface as Psr11ContainerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Tests\Controller\ContainerControllerResolverTest; -class ControllerResolverTest extends ContainerControllerResolverTest +class ControllerResolverTest extends TestCase { public function testAbstractControllerGetsContainerWhenNotSet() { @@ -111,11 +111,6 @@ protected function createControllerResolver(?LoggerInterface $logger = null, ?Ps return new ControllerResolver($container, $logger); } - - protected function createMockParser() - { - return $this->createMock(ControllerNameParser::class); - } } class DummyController extends AbstractController diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index 607049274c7da..c8142e98ab1a7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -22,7 +22,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HtmlSanitizer\HtmlSanitizer; use Symfony\Component\HttpClient\HttpClient; -use Symfony\Component\JsonEncoder\JsonEncoder; +use Symfony\Component\JsonStreamer\JsonStreamWriter; use Symfony\Component\Lock\Store\SemaphoreStore; use Symfony\Component\Mailer\Mailer; use Symfony\Component\Messenger\MessageBusInterface; @@ -706,6 +706,22 @@ public function testSerializerJsonDetailedErrorMessagesNotSetByDefaultWithDebugD $this->assertSame([], $config['serializer']['default_context'] ?? []); } + public function testFormCsrfProtectionFieldAttrDoNotNormalizeKeys() + { + $processor = new Processor(); + $config = $processor->processConfiguration(new Configuration(false), [ + [ + 'form' => [ + 'csrf_protection' => [ + 'field_attr' => ['data-example-attr' => 'value'], + ], + ], + ], + ]); + + $this->assertSame(['data-example-attr' => 'value'], $config['form']['csrf_protection']['field_attr'] ?? []); + } + protected static function getBundleDefaultConfig() { return [ @@ -769,6 +785,7 @@ protected static function getBundleDefaultConfig() 'localizable_html_attributes' => [], ], 'providers' => [], + 'globals' => [], ], 'validation' => [ 'enabled' => !class_exists(FullStack::class), @@ -867,6 +884,7 @@ protected static function getBundleDefaultConfig() 'system' => 'cache.adapter.system', 'directory' => '%kernel.cache_dir%/pools/app', 'default_redis_provider' => 'redis://localhost', + 'default_valkey_provider' => 'valkey://localhost', 'default_memcached_provider' => 'memcached://localhost', 'default_doctrine_dbal_provider' => 'database_connection', 'default_pdo_provider' => ContainerBuilder::willBeAvailable('doctrine/dbal', Connection::class, ['symfony/framework-bundle']) && class_exists(DoctrineAdapter::class) ? 'database_connection' : null, @@ -941,7 +959,7 @@ class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphor ], 'smime_encrypter' => [ 'enabled' => false, - 'certificate' => '', + 'repository' => '', 'cipher' => null, ], ], @@ -993,8 +1011,8 @@ class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphor 'remote-event' => [ 'enabled' => !class_exists(FullStack::class) && class_exists(RemoteEvent::class), ], - 'json_encoder' => [ - 'enabled' => !class_exists(FullStack::class) && class_exists(JsonEncoder::class), + 'json_streamer' => [ + 'enabled' => !class_exists(FullStack::class) && class_exists(JsonStreamWriter::class), ], ]; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/Workflow/Validator/DefinitionValidator.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/Workflow/Validator/DefinitionValidator.php new file mode 100644 index 0000000000000..7244e927ca763 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/Workflow/Validator/DefinitionValidator.php @@ -0,0 +1,16 @@ +loadFromExtension('framework', [ + 'annotations' => false, + 'http_method_override' => false, + 'handle_all_throwables' => true, + 'php_errors' => ['log' => true], + 'csrf_protection' => [ + 'enabled' => true, + ], + 'form' => [ + 'csrf_protection' => [ + 'field-attr' => [ + 'data-foo' => 'bar', + 'data-bar' => 'baz', + ], + ], + ], + 'session' => [ + 'storage_factory_id' => 'session.storage.factory.native', + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/json_encoder.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/json_streamer.php similarity index 91% rename from src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/json_encoder.php rename to src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/json_streamer.php index 42204b2cbb1dd..844b72004d6a6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/json_encoder.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/json_streamer.php @@ -8,7 +8,7 @@ 'type_info' => [ 'enabled' => true, ], - 'json_encoder' => [ + 'json_streamer' => [ 'enabled' => true, ], ]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_bus_name_stamp.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_bus_name_stamp.php new file mode 100644 index 0000000000000..452594d452af8 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_bus_name_stamp.php @@ -0,0 +1,25 @@ +loadFromExtension('framework', [ + 'annotations' => false, + 'http_method_override' => false, + 'handle_all_throwables' => true, + 'php_errors' => ['log' => true], + 'lock' => false, + 'messenger' => [ + 'default_bus' => 'messenger.bus.commands', + 'buses' => [ + 'messenger.bus.commands' => [ + 'default_middleware' => false, + 'middleware' => [ + 'add_bus_name_stamp_middleware', + 'send_message', + 'handle_message', + ], + ], + 'messenger.bus.events' => [ + 'default_middleware' => true, + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_buses_without_deduplicate_middleware.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_buses_without_deduplicate_middleware.php index b8e7530bb3e01..fd4a008341cb4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_buses_without_deduplicate_middleware.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/messenger_multiple_buses_without_deduplicate_middleware.php @@ -5,6 +5,7 @@ 'http_method_override' => false, 'handle_all_throwables' => true, 'php_errors' => ['log' => true], + 'lock' => false, 'messenger' => [ 'default_bus' => 'messenger.bus.commands', 'buses' => [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler.php index faf76bbc76a8f..99e2a52cf611f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler.php @@ -7,6 +7,7 @@ 'php_errors' => ['log' => true], 'profiler' => [ 'enabled' => true, + 'collect_serializer_data' => true, ], 'serializer' => [ 'enabled' => true, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_globals.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_globals.php new file mode 100644 index 0000000000000..8ee438ff906d1 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_globals.php @@ -0,0 +1,15 @@ +loadFromExtension('framework', [ + 'annotations' => false, + 'http_method_override' => false, + 'handle_all_throwables' => true, + 'php_errors' => ['log' => true], + 'translator' => [ + 'globals' => [ + '%%app_name%%' => 'My application', + '{app_version}' => '1.2.3', + '{url}' => ['message' => 'url', 'parameters' => ['scheme' => 'https://'], 'domain' => 'global'], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler_collect_serializer_data.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_without_globals.php similarity index 56% rename from src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler_collect_serializer_data.php rename to src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_without_globals.php index 99e2a52cf611f..fcc65c9682650 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler_collect_serializer_data.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_without_globals.php @@ -5,11 +5,5 @@ 'http_method_override' => false, 'handle_all_throwables' => true, 'php_errors' => ['log' => true], - 'profiler' => [ - 'enabled' => true, - 'collect_serializer_data' => true, - ], - 'serializer' => [ - 'enabled' => true, - ], + 'translator' => ['globals' => []], ]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php index 118a627c7c05b..2c29b848901eb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php @@ -13,6 +13,9 @@ 'supports' => [ FrameworkExtensionTestCase::class, ], + 'definition_validators' => [ + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Fixtures\Workflow\Validator\DefinitionValidator::class, + ], 'initial_marking' => ['draft'], 'metadata' => [ 'title' => 'article workflow', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_sets_field_name.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_field_attr.xml similarity index 67% rename from src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_sets_field_name.xml rename to src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_field_attr.xml index 4a05e9d33294e..1889703bec2a9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_sets_field_name.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_field_attr.xml @@ -9,7 +9,13 @@ - + + + + bar + baz + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml index 23d325e61c7a4..07faf22ab2ef1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml @@ -46,6 +46,6 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/json_encoder.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/json_streamer.xml similarity index 93% rename from src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/json_encoder.xml rename to src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/json_streamer.xml index a20f98567581a..5c79cb8401642 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/json_encoder.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/json_streamer.xml @@ -9,6 +9,6 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_bus_name_stamp.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_bus_name_stamp.xml new file mode 100644 index 0000000000000..5e0b178510a17 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_bus_name_stamp.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_buses_without_deduplicate_middleware.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_buses_without_deduplicate_middleware.xml index dcf402e1a36ec..3f0d96249959e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_buses_without_deduplicate_middleware.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/messenger_multiple_buses_without_deduplicate_middleware.xml @@ -8,6 +8,7 @@ + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/profiler.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/profiler.xml index ffbff7f21e1bb..34d44d91ce1bd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/profiler.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/profiler.xml @@ -9,7 +9,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_under_form_sets_field_name.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_globals.xml similarity index 52% rename from src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_under_form_sets_field_name.xml rename to src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_globals.xml index 09ef0ee167eb4..017fd9393b85c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/form_csrf_under_form_sets_field_name.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_globals.xml @@ -6,10 +6,15 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - + - - + + My application + + + https:// + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/profiler_collect_serializer_data.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_without_globals.xml similarity index 73% rename from src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/profiler_collect_serializer_data.xml rename to src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_without_globals.xml index 34d44d91ce1bd..6c686bd30b210 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/profiler_collect_serializer_data.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/translator_without_globals.xml @@ -6,10 +6,9 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - + - - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml index 76b4f07a87a44..c5dae479d3d63 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml @@ -13,6 +13,7 @@ draft Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase + Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Fixtures\Workflow\Validator\DefinitionValidator diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_csrf_field_attr.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_csrf_field_attr.yml new file mode 100644 index 0000000000000..db519977548c4 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/form_csrf_field_attr.yml @@ -0,0 +1,16 @@ +framework: + annotations: false + http_method_override: false + handle_all_throwables: true + php_errors: + log: true + csrf_protection: + enabled: true + form: + csrf_protection: + enabled: true + field_attr: + data-foo: bar + data-bar: baz + session: + storage_factory_id: session.storage.factory.native diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml index 28c4336d93872..8a1a3834ba719 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml @@ -71,4 +71,4 @@ framework: formats: csv: ['text/csv', 'text/plain'] pdf: 'application/pdf' - json_encoder: ~ + json_streamer: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/json_encoder.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/json_streamer.yml similarity index 90% rename from src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/json_encoder.yml rename to src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/json_streamer.yml index e09f7c7d368b0..8873fea97a8ef 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/json_encoder.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/json_streamer.yml @@ -6,5 +6,5 @@ framework: log: true type_info: enabled: true - json_encoder: + json_streamer: enabled: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_bus_name_stamp.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_bus_name_stamp.yml new file mode 100644 index 0000000000000..79f8d7c87420b --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_bus_name_stamp.yml @@ -0,0 +1,18 @@ +framework: + annotations: false + http_method_override: false + handle_all_throwables: true + php_errors: + log: true + lock: false + messenger: + default_bus: messenger.bus.commands + buses: + messenger.bus.commands: + default_middleware: false + middleware: + - "add_bus_name_stamp_middleware" + - "send_message" + - "handle_message" + messenger.bus.events: + default_middleware: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_buses_without_deduplicate_middleware.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_buses_without_deduplicate_middleware.yml index f06d534a55ec2..38fca57379fcb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_buses_without_deduplicate_middleware.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/messenger_multiple_buses_without_deduplicate_middleware.yml @@ -4,6 +4,7 @@ framework: handle_all_throwables: true php_errors: log: true + lock: false messenger: default_bus: messenger.bus.commands buses: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/profiler.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/profiler.yml index 5c867fc8907db..2ccec1685c6b1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/profiler.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/profiler.yml @@ -6,5 +6,6 @@ framework: log: true profiler: enabled: true + collect_serializer_data: true serializer: enabled: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_globals.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_globals.yml new file mode 100644 index 0000000000000..ed42b676c8fd5 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_globals.yml @@ -0,0 +1,11 @@ +framework: + annotations: false + http_method_override: false + handle_all_throwables: true + php_errors: + log: true + translator: + globals: + '%%app_name%%': 'My application' + '{app_version}': '1.2.3' + '{url}': { message: 'url', parameters: { scheme: 'https://' }, domain: 'global' } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/profiler_collect_serializer_data.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_without_globals.yml similarity index 54% rename from src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/profiler_collect_serializer_data.yml rename to src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_without_globals.yml index 5fe74b290568a..dc7323868d762 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/profiler_collect_serializer_data.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/translator_without_globals.yml @@ -4,8 +4,5 @@ framework: handle_all_throwables: true php_errors: log: true - serializer: - enabled: true - profiler: - enabled: true - collect_serializer_data: true + translator: + globals: [] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml index a9b427d89408a..cac5f6f230f92 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml @@ -9,6 +9,8 @@ framework: type: workflow supports: - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase + definition_validators: + - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Fixtures\Workflow\Validator\DefinitionValidator initial_marking: [draft] metadata: title: article workflow diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php index a50070858608a..b5f5f1ef5dc95 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -15,6 +15,7 @@ use Psr\Log\LoggerAwareInterface; use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; +use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Fixtures\Workflow\Validator\DefinitionValidator; use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\FullStack; @@ -33,6 +34,7 @@ use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument; use Symfony\Component\DependencyInjection\ChildDefinition; +use Symfony\Component\DependencyInjection\Compiler\ResolveBindingsPass; use Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass; use Symfony\Component\DependencyInjection\Compiler\ResolveInstanceofConditionalsPass; use Symfony\Component\DependencyInjection\Compiler\ResolveTaggedIteratorArgumentPass; @@ -68,6 +70,7 @@ use Symfony\Component\Notifier\TexterInterface; use Symfony\Component\PropertyAccess\PropertyAccessor; use Symfony\Component\Security\Core\AuthenticationEvents; +use Symfony\Component\Serializer\DependencyInjection\SerializerPass; use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader; use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader; use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader; @@ -83,11 +86,13 @@ use Symfony\Component\Serializer\Serializer; use Symfony\Component\Translation\DependencyInjection\TranslatorPass; use Symfony\Component\Translation\LocaleSwitcher; +use Symfony\Component\Translation\TranslatableMessage; use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass; use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Webhook\Client\RequestParser; use Symfony\Component\Webhook\Controller\WebhookController; +use Symfony\Component\Workflow\DependencyInjection\WorkflowValidatorPass; use Symfony\Component\Workflow\Exception\InvalidDefinitionException; use Symfony\Component\Workflow\Metadata\InMemoryMetadataStore; use Symfony\Component\Workflow\WorkflowEvents; @@ -275,25 +280,20 @@ public function testDisabledProfiler() public function testProfilerCollectSerializerDataEnabled() { - $container = $this->createContainerFromFile('profiler_collect_serializer_data'); + $container = $this->createContainerFromFile('profiler'); $this->assertTrue($container->hasDefinition('profiler')); $this->assertTrue($container->hasDefinition('serializer.data_collector')); $this->assertTrue($container->hasDefinition('debug.serializer')); } - public function testProfilerCollectSerializerDataDefaultDisabled() - { - $container = $this->createContainerFromFile('profiler'); - - $this->assertTrue($container->hasDefinition('profiler')); - $this->assertFalse($container->hasDefinition('serializer.data_collector')); - $this->assertFalse($container->hasDefinition('debug.serializer')); - } - public function testWorkflows() { - $container = $this->createContainerFromFile('workflows'); + DefinitionValidator::$called = false; + + $container = $this->createContainerFromFile('workflows', compile: false); + $container->addCompilerPass(new WorkflowValidatorPass()); + $container->compile(); $this->assertTrue($container->hasDefinition('workflow.article'), 'Workflow is registered as a service'); $this->assertSame('workflow.abstract', $container->getDefinition('workflow.article')->getParent()); @@ -316,6 +316,7 @@ public function testWorkflows() ], $tags['workflow'][0]['metadata'] ?? null); $this->assertTrue($container->hasDefinition('workflow.article.definition'), 'Workflow definition is registered as a service'); + $this->assertTrue(DefinitionValidator::$called, 'DefinitionValidator is called'); $workflowDefinition = $container->getDefinition('workflow.article.definition'); @@ -409,7 +410,9 @@ public function testWorkflowAreValidated() { $this->expectException(InvalidDefinitionException::class); $this->expectExceptionMessage('A transition from a place/state must have an unique name. Multiple transitions named "go" from place/state "first" were found on StateMachine "my_workflow".'); - $this->createContainerFromFile('workflow_not_valid'); + $container = $this->createContainerFromFile('workflow_not_valid', compile: false); + $container->addCompilerPass(new WorkflowValidatorPass()); + $container->compile(); } public function testWorkflowCannotHaveBothSupportsAndSupportStrategy() @@ -614,21 +617,25 @@ public function testExceptionsConfig() ], array_keys($configuration)); $this->assertEqualsCanonicalizing([ + 'log_channel' => null, 'log_level' => 'info', 'status_code' => 422, ], $configuration[\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class]); $this->assertEqualsCanonicalizing([ + 'log_channel' => null, 'log_level' => 'info', 'status_code' => null, ], $configuration[\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class]); $this->assertEqualsCanonicalizing([ + 'log_channel' => null, 'log_level' => 'info', 'status_code' => null, ], $configuration[\Symfony\Component\HttpKernel\Exception\ConflictHttpException::class]); $this->assertEqualsCanonicalizing([ + 'log_channel' => null, 'log_level' => null, 'status_code' => 500, ], $configuration[\Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException::class]); @@ -796,7 +803,7 @@ public function testMessengerServicesRemovedWhenDisabled() \ARRAY_FILTER_USE_KEY ); - $this->assertEmpty($messengerDefinitions); + $this->assertSame([], $messengerDefinitions); $this->assertFalse($container->hasDefinition('console.command.messenger_consume_messages')); $this->assertFalse($container->hasDefinition('console.command.messenger_debug')); $this->assertFalse($container->hasDefinition('console.command.messenger_stop_workers')); @@ -1092,6 +1099,28 @@ public function testMessengerWithMultipleBusesWithoutDeduplicateMiddleware() $this->assertSame('messenger.bus.commands', (string) $container->getAlias('messenger.default_bus')); } + public function testMessengerWithAddBusNameStampMiddleware() + { + $container = $this->createContainerFromFile('messenger_bus_name_stamp'); + + $this->assertTrue($container->has('messenger.bus.commands')); + $this->assertEquals([ + ['id' => 'add_bus_name_stamp_middleware', 'arguments' => ['messenger.bus.commands']], + ['id' => 'send_message', 'arguments' => []], + ['id' => 'handle_message', 'arguments' => []], + ], $container->getParameter('messenger.bus.commands.middleware')); + $this->assertTrue($container->has('messenger.bus.events')); + $this->assertSame([], $container->getDefinition('messenger.bus.events')->getArgument(0)); + $this->assertEquals([ + ['id' => 'add_bus_name_stamp_middleware', 'arguments' => ['messenger.bus.events']], + ['id' => 'reject_redelivered_message_middleware'], + ['id' => 'dispatch_after_current_bus'], + ['id' => 'failed_message_processing_middleware'], + ['id' => 'send_message', 'arguments' => [true]], + ['id' => 'handle_message', 'arguments' => [false]], + ], $container->getParameter('messenger.bus.events.middleware')); + } + public function testMessengerWithMultipleBusesWithDeduplicateMiddleware() { if (!class_exists(DeduplicateMiddleware::class)) { @@ -1241,6 +1270,36 @@ public function testTranslatorCacheDirDisabled() $this->assertNull($options['cache_dir']); } + public function testTranslatorGlobals() + { + $container = $this->createContainerFromFile('translator_globals'); + + $calls = $container->getDefinition('translator.default')->getMethodCalls(); + + $this->assertCount(5, $calls); + $this->assertSame( + ['addGlobalParameter', ['%%app_name%%', 'My application']], + $calls[2], + ); + $this->assertSame( + ['addGlobalParameter', ['{app_version}', '1.2.3']], + $calls[3], + ); + $this->assertEquals( + ['addGlobalParameter', ['{url}', new Definition(TranslatableMessage::class, ['url', ['scheme' => 'https://'], 'global'])]], + $calls[4], + ); + } + + public function testTranslatorWithoutGlobals() + { + $container = $this->createContainerFromFile('translator_without_globals'); + + $calls = $container->getDefinition('translator.default')->getMethodCalls(); + + $this->assertCount(2, $calls); + } + public function testValidation() { $container = $this->createContainerFromFile('full'); @@ -1454,6 +1513,17 @@ public function testFormsCanBeEnabledWithoutCsrfProtection() $this->assertFalse($container->getParameter('form.type_extension.csrf.enabled')); } + public function testFormCsrfFieldAttr() + { + $container = $this->createContainerFromFile('form_csrf_field_attr'); + + $expected = [ + 'data-foo' => 'bar', + 'data-bar' => 'baz', + ]; + $this->assertSame($expected, $container->getParameter('form.type_extension.csrf.field_attr')); + } + public function testStopwatchEnabledWithDebugModeEnabled() { $container = $this->createContainerFromFile('default_config', [ @@ -1490,9 +1560,6 @@ public function testSerializerEnabled() $this->assertEquals(AttributeLoader::class, $argument[0]->getClass()); $this->assertEquals(new Reference('serializer.name_converter.camel_case_to_snake_case'), $container->getDefinition('serializer.name_converter.metadata_aware')->getArgument(1)); $this->assertEquals(new Reference('property_info', ContainerBuilder::IGNORE_ON_INVALID_REFERENCE), $container->getDefinition('serializer.normalizer.object')->getArgument(3)); - $this->assertArrayHasKey('circular_reference_handler', $container->getDefinition('serializer.normalizer.object')->getArgument(6)); - $this->assertArrayHasKey('max_depth_handler', $container->getDefinition('serializer.normalizer.object')->getArgument(6)); - $this->assertEquals($container->getDefinition('serializer.normalizer.object')->getArgument(6)['max_depth_handler'], new Reference('my.max.depth.handler')); } public function testSerializerWithoutTranslator() @@ -1590,13 +1657,22 @@ public function testJsonSerializableNormalizerRegistered() public function testObjectNormalizerRegistered() { - $container = $this->createContainerFromFile('full'); + $container = $this->createContainerFromFile('full', compile: false); + $container->addCompilerPass(new SerializerPass()); + $container->addCompilerPass(new ResolveBindingsPass()); + $container->compile(); $definition = $container->getDefinition('serializer.normalizer.object'); $tag = $definition->getTag('serializer.normalizer'); $this->assertEquals(ObjectNormalizer::class, $definition->getClass()); $this->assertEquals(-1000, $tag[0]['priority']); + + $this->assertEquals([ + 'enable_max_depth' => true, + 'circular_reference_handler' => new Reference('my.circular.reference.handler'), + 'max_depth_handler' => new Reference('my.max.depth.handler'), + ], $definition->getArgument(6)); } public function testConstraintViolationListNormalizerRegistered() @@ -1941,7 +2017,7 @@ public function testRemovesResourceCheckerConfigCacheFactoryArgumentOnlyIfNoDebu $container = $this->createContainer(['kernel.debug' => false]); (new FrameworkExtension())->load([['annotations' => false, 'http_method_override' => false, 'handle_all_throwables' => true, 'php_errors' => ['log' => true]]], $container); - $this->assertEmpty($container->getDefinition('config_cache_factory')->getArguments()); + $this->assertSame([], $container->getDefinition('config_cache_factory')->getArguments()); } public function testLoggerAwareRegistration() @@ -2156,8 +2232,7 @@ public function testMailer(string $configFile, array $expectedTransports, array $this->assertTrue($container->hasAlias('mailer')); $this->assertTrue($container->hasDefinition('mailer.transports')); $this->assertSame($expectedTransports, $container->getDefinition('mailer.transports')->getArgument(0)); - $this->assertTrue($container->hasDefinition('mailer.default_transport')); - $this->assertSame(current($expectedTransports), $container->getDefinition('mailer.default_transport')->getArgument(0)); + $this->assertTrue($container->hasAlias('mailer.default_transport')); $this->assertTrue($container->hasDefinition('mailer.envelope_listener')); $l = $container->getDefinition('mailer.envelope_listener'); $this->assertSame('sender@example.org', $l->getArgument(0)); @@ -2552,10 +2627,18 @@ public function testSemaphoreWithService() self::assertEquals(new Reference('my_service'), $storeDef->getArgument(0)); } - public function testJsonEncoderEnabled() + public function testJsonStreamerEnabled() { - $container = $this->createContainerFromFile('json_encoder'); - $this->assertTrue($container->has('json_encoder.encoder')); + $container = $this->createContainerFromFile('json_streamer'); + $this->assertTrue($container->has('json_streamer.stream_writer')); + } + + public function testObjectMapperEnabled() + { + $container = $this->createContainerFromClosure(function (ContainerBuilder $container) { + $container->loadFromExtension('framework', []); + }); + $this->assertTrue($container->has('object_mapper')); } protected function createContainer(array $data = []) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php index deac159b6f9b0..c4f67c2f12ebe 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php @@ -17,7 +17,13 @@ use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; +use Symfony\Component\RateLimiter\CompoundRateLimiterFactory; +use Symfony\Component\RateLimiter\RateLimiterFactoryInterface; +use Symfony\Component\Validator\Constraints\Email; +use Symfony\Component\Workflow\Definition; +use Symfony\Component\Workflow\DependencyInjection\WorkflowValidatorPass; use Symfony\Component\Workflow\Exception\InvalidDefinitionException; +use Symfony\Component\Workflow\Validator\DefinitionValidatorInterface; class PhpFrameworkExtensionTest extends FrameworkExtensionTestCase { @@ -99,7 +105,7 @@ public function testWorkflowValidationStateMachine() { $this->expectException(InvalidDefinitionException::class); $this->expectExceptionMessage('A transition from a place/state must have an unique name. Multiple transitions named "a_to_b" from place/state "a" were found on StateMachine "article".'); - $this->createContainerFromClosure(function ($container) { + $this->createContainerFromClosure(function (ContainerBuilder $container) { $container->loadFromExtension('framework', [ 'annotations' => false, 'http_method_override' => false, @@ -125,9 +131,57 @@ public function testWorkflowValidationStateMachine() ], ], ]); + $container->addCompilerPass(new WorkflowValidatorPass()); }); } + /** + * @dataProvider provideWorkflowValidationCustomTests + */ + public function testWorkflowValidationCustomBroken(string $class, string $message) + { + $this->expectException(InvalidConfigurationException::class); + $this->expectExceptionMessage($message); + $this->createContainerFromClosure(function ($container) use ($class) { + $container->loadFromExtension('framework', [ + 'annotations' => false, + 'http_method_override' => false, + 'handle_all_throwables' => true, + 'php_errors' => ['log' => true], + 'workflows' => [ + 'article' => [ + 'type' => 'state_machine', + 'supports' => [ + __CLASS__, + ], + 'places' => [ + 'a', + 'b', + ], + 'transitions' => [ + 'a_to_b' => [ + 'from' => ['a'], + 'to' => ['b'], + ], + ], + 'definition_validators' => [ + $class, + ], + ], + ], + ]); + }); + } + + public static function provideWorkflowValidationCustomTests() + { + yield ['classDoesNotExist', 'Invalid configuration for path "framework.workflows.workflows.article.definition_validators.0": The validation class "classDoesNotExist" does not exist.']; + + yield [\DateTime::class, 'Invalid configuration for path "framework.workflows.workflows.article.definition_validators.0": The validation class "DateTime" is not an instance of "Symfony\Component\Workflow\Validator\DefinitionValidatorInterface".']; + + yield [WorkflowValidatorWithConstructor::class, 'Invalid configuration for path "framework.workflows.workflows.article.definition_validators.0": The "Symfony\\\\Bundle\\\\FrameworkBundle\\\\Tests\\\\DependencyInjection\\\\WorkflowValidatorWithConstructor" validation class constructor must not have any arguments.']; + } + public function testWorkflowDefaultMarkingStoreDefinition() { $container = $this->createContainerFromClosure(function ($container) { @@ -188,7 +242,7 @@ public function testWorkflowDefaultMarkingStoreDefinition() $this->assertNull($argumentsB['index_1'], 'workflow_b marking_store argument is null'); } - public function testRateLimiterWithLockFactory() + public function testRateLimiterLockFactoryWithLockDisabled() { try { $this->createContainerFromClosure(function (ContainerBuilder $container) { @@ -199,7 +253,7 @@ public function testRateLimiterWithLockFactory() 'php_errors' => ['log' => true], 'lock' => false, 'rate_limiter' => [ - 'with_lock' => ['policy' => 'fixed_window', 'limit' => 10, 'interval' => '1 hour'], + 'with_lock' => ['policy' => 'fixed_window', 'limit' => 10, 'interval' => '1 hour', 'lock_factory' => 'lock.factory'], ], ]); }); @@ -208,7 +262,10 @@ public function testRateLimiterWithLockFactory() } catch (LogicException $e) { $this->assertEquals('Rate limiter "with_lock" requires the Lock component to be configured.', $e->getMessage()); } + } + public function testRateLimiterAutoLockFactoryWithLockEnabled() + { $container = $this->createContainerFromClosure(function (ContainerBuilder $container) { $container->loadFromExtension('framework', [ 'annotations' => false, @@ -226,13 +283,35 @@ public function testRateLimiterWithLockFactory() $this->assertEquals('lock.factory', (string) $withLock->getArgument(2)); } - public function testRateLimiterLockFactory() + public function testRateLimiterAutoLockFactoryWithLockDisabled() { $container = $this->createContainerFromClosure(function (ContainerBuilder $container) { $container->loadFromExtension('framework', [ 'annotations' => false, 'http_method_override' => false, 'handle_all_throwables' => true, + 'lock' => false, + 'php_errors' => ['log' => true], + 'rate_limiter' => [ + 'without_lock' => ['policy' => 'fixed_window', 'limit' => 10, 'interval' => '1 hour'], + ], + ]); + }); + + $this->expectException(OutOfBoundsException::class); + $this->expectExceptionMessageMatches('/^The argument "2" doesn\'t exist.*\.$/'); + + $container->getDefinition('limiter.without_lock')->getArgument(2); + } + + public function testRateLimiterDisableLockFactory() + { + $container = $this->createContainerFromClosure(function (ContainerBuilder $container) { + $container->loadFromExtension('framework', [ + 'annotations' => false, + 'http_method_override' => false, + 'handle_all_throwables' => true, + 'lock' => true, 'php_errors' => ['log' => true], 'rate_limiter' => [ 'without_lock' => ['policy' => 'fixed_window', 'limit' => 10, 'interval' => '1 hour', 'lock_factory' => null], @@ -265,4 +344,129 @@ public function testRateLimiterIsTagged() $this->assertSame('first', $container->getDefinition('limiter.first')->getTag('rate_limiter')[0]['name']); $this->assertSame('second', $container->getDefinition('limiter.second')->getTag('rate_limiter')[0]['name']); } + + public function testRateLimiterCompoundPolicy() + { + if (!class_exists(CompoundRateLimiterFactory::class)) { + $this->markTestSkipped('CompoundRateLimiterFactory is not available.'); + } + + $container = $this->createContainerFromClosure(function (ContainerBuilder $container) { + $container->loadFromExtension('framework', [ + 'annotations' => false, + 'http_method_override' => false, + 'handle_all_throwables' => true, + 'php_errors' => ['log' => true], + 'lock' => true, + 'rate_limiter' => [ + 'first' => ['policy' => 'fixed_window', 'limit' => 10, 'interval' => '1 hour'], + 'second' => ['policy' => 'sliding_window', 'limit' => 10, 'interval' => '1 hour'], + 'compound' => ['policy' => 'compound', 'limiters' => ['first', 'second']], + ], + ]); + }); + + $this->assertSame([ + 'policy' => 'fixed_window', + 'limit' => 10, + 'interval' => '1 hour', + 'id' => 'first', + ], $container->getDefinition('limiter.first')->getArgument(0)); + $this->assertSame([ + 'policy' => 'sliding_window', + 'limit' => 10, + 'interval' => '1 hour', + 'id' => 'second', + ], $container->getDefinition('limiter.second')->getArgument(0)); + + $definition = $container->getDefinition('limiter.compound'); + $this->assertSame(CompoundRateLimiterFactory::class, $definition->getClass()); + $this->assertEquals( + [ + 'limiter.first', + 'limiter.second', + ], + $definition->getArgument(0)->getValues() + ); + $this->assertSame('limiter.compound', (string) $container->getAlias(RateLimiterFactoryInterface::class.' $compoundLimiter')); + } + + public function testRateLimiterCompoundPolicyNoLimiters() + { + if (!class_exists(CompoundRateLimiterFactory::class)) { + $this->markTestSkipped('CompoundRateLimiterFactory is not available.'); + } + + $this->expectException(\LogicException::class); + $this->createContainerFromClosure(function ($container) { + $container->loadFromExtension('framework', [ + 'annotations' => false, + 'http_method_override' => false, + 'handle_all_throwables' => true, + 'php_errors' => ['log' => true], + 'rate_limiter' => [ + 'compound' => ['policy' => 'compound'], + ], + ]); + }); + } + + public function testRateLimiterCompoundPolicyInvalidLimiters() + { + if (!class_exists(CompoundRateLimiterFactory::class)) { + $this->markTestSkipped('CompoundRateLimiterFactory is not available.'); + } + + $this->expectException(\LogicException::class); + $this->createContainerFromClosure(function ($container) { + $container->loadFromExtension('framework', [ + 'annotations' => false, + 'http_method_override' => false, + 'handle_all_throwables' => true, + 'php_errors' => ['log' => true], + 'rate_limiter' => [ + 'compound' => ['policy' => 'compound', 'limiters' => ['invalid1', 'invalid2']], + ], + ]); + }); + } + + /** + * @dataProvider emailValidationModeProvider + */ + public function testValidatorEmailValidationMode(string $mode) + { + $this->expectNotToPerformAssertions(); + + $this->createContainerFromClosure(function (ContainerBuilder $container) use ($mode) { + $container->loadFromExtension('framework', [ + 'annotations' => false, + 'http_method_override' => false, + 'handle_all_throwables' => true, + 'php_errors' => ['log' => true], + 'validation' => [ + 'email_validation_mode' => $mode, + ], + ]); + }); + } + + public static function emailValidationModeProvider() + { + foreach (Email::VALIDATION_MODES as $mode) { + yield [$mode]; + } + yield ['loose']; + } +} + +class WorkflowValidatorWithConstructor implements DefinitionValidatorInterface +{ + public function __construct(bool $enabled) + { + } + + public function validate(Definition $definition, string $name): void + { + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_2.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_2.json new file mode 100644 index 0000000000000..8f5d2c743eb02 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_2.json @@ -0,0 +1,38 @@ +{ + "route_1": { + "path": "\/hello\/{name}", + "pathRegex": "#PATH_REGEX#", + "host": "localhost", + "hostRegex": "#HOST_REGEX#", + "scheme": "http|https", + "method": "GET|HEAD", + "class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub", + "defaults": { + "name": "Joseph" + }, + "requirements": { + "name": "[a-z]+" + }, + "options": { + "compiler_class": "Symfony\\Component\\Routing\\RouteCompiler", + "opt1": "val1", + "opt2": "val2" + } + }, + "route_3": { + "path": "\/other\/route", + "pathRegex": "#PATH_REGEX#", + "host": "localhost", + "hostRegex": "#HOST_REGEX#", + "scheme": "http|https", + "method": "ANY", + "class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub", + "defaults": [], + "requirements": "NO CUSTOM", + "options": { + "compiler_class": "Symfony\\Component\\Routing\\RouteCompiler", + "opt1": "val1", + "opt2": "val2" + } + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_2.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_2.md new file mode 100644 index 0000000000000..e1b11e4a499e2 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_2.md @@ -0,0 +1,37 @@ +route_1 +------- + +- Path: /hello/{name} +- Path Regex: #PATH_REGEX# +- Host: localhost +- Host Regex: #HOST_REGEX# +- Scheme: http|https +- Method: GET|HEAD +- Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub +- Defaults: + - `name`: Joseph +- Requirements: + - `name`: [a-z]+ +- Options: + - `compiler_class`: Symfony\Component\Routing\RouteCompiler + - `opt1`: val1 + - `opt2`: val2 + + +route_3 +------- + +- Path: /other/route +- Path Regex: #PATH_REGEX# +- Host: localhost +- Host Regex: #HOST_REGEX# +- Scheme: http|https +- Method: ANY +- Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub +- Defaults: NONE +- Requirements: NO CUSTOM +- Options: + - `compiler_class`: Symfony\Component\Routing\RouteCompiler + - `opt1`: val1 + - `opt2`: val2 + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_2.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_2.txt new file mode 100644 index 0000000000000..a9f9ee21b7497 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_2.txt @@ -0,0 +1,7 @@ + --------- ---------- ------------ ----------- --------------- +  Name   Method   Scheme   Host   Path  + --------- ---------- ------------ ----------- --------------- + route_1 GET|HEAD http|https localhost /hello/{name} + route_3 ANY http|https localhost /other/route + --------- ---------- ------------ ----------- --------------- + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_2.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_2.xml new file mode 100644 index 0000000000000..18c41deb79990 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_2.xml @@ -0,0 +1,33 @@ + + + + /hello/{name} + localhost + http + https + GET + HEAD + + Joseph + + + [a-z]+ + + + + + + + + + /other/route + localhost + http + https + + + + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_3.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_3.json new file mode 100644 index 0000000000000..cabc8e0a71955 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_3.json @@ -0,0 +1,19 @@ +{ + "route_2": { + "path": "\/name\/add", + "pathRegex": "#PATH_REGEX#", + "host": "localhost", + "hostRegex": "#HOST_REGEX#", + "scheme": "http|https", + "method": "PUT|POST", + "class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub", + "defaults": [], + "requirements": "NO CUSTOM", + "options": { + "compiler_class": "Symfony\\Component\\Routing\\RouteCompiler", + "opt1": "val1", + "opt2": "val2" + }, + "condition": "context.getMethod() in ['GET', 'HEAD', 'POST']" + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_3.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_3.md new file mode 100644 index 0000000000000..20fdabb958098 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_3.md @@ -0,0 +1,18 @@ +route_2 +------- + +- Path: /name/add +- Path Regex: #PATH_REGEX# +- Host: localhost +- Host Regex: #HOST_REGEX# +- Scheme: http|https +- Method: PUT|POST +- Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub +- Defaults: NONE +- Requirements: NO CUSTOM +- Options: + - `compiler_class`: Symfony\Component\Routing\RouteCompiler + - `opt1`: val1 + - `opt2`: val2 +- Condition: context.getMethod() in ['GET', 'HEAD', 'POST'] + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_3.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_3.txt new file mode 100644 index 0000000000000..8822b3c40793a --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_3.txt @@ -0,0 +1,6 @@ + --------- ---------- ------------ ----------- ----------- +  Name   Method   Scheme   Host   Path  + --------- ---------- ------------ ----------- ----------- + route_2 PUT|POST http|https localhost /name/add + --------- ---------- ------------ ----------- ----------- + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_3.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_3.xml new file mode 100644 index 0000000000000..57a05d4c10bd5 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_3.xml @@ -0,0 +1,17 @@ + + + + /name/add + localhost + http + https + PUT + POST + + + + + + context.getMethod() in ['GET', 'HEAD', 'POST'] + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Messenger/DummyCommand.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Messenger/DummyCommand.php new file mode 100644 index 0000000000000..c8f800850bee3 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Messenger/DummyCommand.php @@ -0,0 +1,30 @@ +addArgument('dummy-argument', InputArgument::OPTIONAL); + } + + public function execute(InputInterface $input, ?OutputInterface $output = null): int + { + self::$calls[__FUNCTION__][] = $input->getArgument('dummy-argument'); + + return Command::SUCCESS; + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/ObjectMapper/ObjectMapped.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/ObjectMapper/ObjectMapped.php new file mode 100644 index 0000000000000..17edc9dcef465 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/ObjectMapper/ObjectMapped.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ObjectMapper; + +final class ObjectMapped +{ + public string $a; +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/ObjectMapper/ObjectToBeMapped.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/ObjectMapper/ObjectToBeMapped.php new file mode 100644 index 0000000000000..fc5b7080ad11a --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/ObjectMapper/ObjectToBeMapped.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ObjectMapper; + +use Symfony\Component\ObjectMapper\Attribute\Map; + +#[Map(target: ObjectMapped::class)] +final class ObjectToBeMapped +{ + #[Map(transform: TransformCallable::class)] + public string $a = 'nottransformed'; +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/ObjectMapper/TransformCallable.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/ObjectMapper/TransformCallable.php new file mode 100644 index 0000000000000..3321e28d1ac67 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/ObjectMapper/TransformCallable.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ObjectMapper; + +use Symfony\Component\ObjectMapper\TransformCallableInterface; + +/** + * @implements TransformCallableInterface + */ +final class TransformCallable implements TransformCallableInterface +{ + public function __invoke(mixed $value, object $source, ?object $target): mixed + { + return 'transformed'; + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ApiAttributesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ApiAttributesTest.php index cf5c384ba2578..4848976aede71 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ApiAttributesTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ApiAttributesTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -34,7 +35,7 @@ public function testMapQueryString(string $uri, array $query, string $expectedRe if ($expectedResponse) { self::assertJsonStringEqualsJsonString($expectedResponse, $response->getContent()); } else { - self::assertEmpty($response->getContent()); + self::assertSame('', $response->getContent()); } self::assertSame($expectedStatusCode, $response->getStatusCode()); } @@ -216,15 +217,14 @@ public static function mapQueryStringProvider(): iterable /** * @dataProvider mapRequestPayloadProvider */ - public function testMapRequestPayload(string $uri, string $format, array $parameters, ?string $content, string $expectedResponse, int $expectedStatusCode) + public function testMapRequestPayload(string $uri, string $format, array $parameters, ?string $content, callable $responseAssertion, int $expectedStatusCode) { $client = self::createClient(['test_case' => 'ApiAttributesTest']); - [$acceptHeader, $assertion] = [ - 'html' => ['text/html', self::assertStringContainsString(...)], - 'json' => ['application/json', self::assertJsonStringEqualsJsonString(...)], - 'xml' => ['text/xml', self::assertXmlStringEqualsXmlString(...)], - 'dummy' => ['application/dummy', self::assertStringContainsString(...)], + $acceptHeader = [ + 'json' => 'application/json', + 'xml' => 'text/xml', + 'dummy' => 'application/dummy', ][$format]; $client->request( @@ -238,12 +238,7 @@ public function testMapRequestPayload(string $uri, string $format, array $parame $response = $client->getResponse(); $responseContent = $response->getContent(); - - if ($expectedResponse) { - $assertion($expectedResponse, $responseContent); - } else { - self::assertSame('', $responseContent); - } + $responseAssertion($responseContent); self::assertSame($expectedStatusCode, $response->getStatusCode()); } @@ -255,7 +250,9 @@ public static function mapRequestPayloadProvider(): iterable 'format' => 'json', 'parameters' => [], 'content' => '', - 'expectedResponse' => '', + 'responseAssertion' => static function (string $response) { + self::assertSame('', $response); + }, 'expectedStatusCode' => 204, ]; @@ -269,12 +266,16 @@ public static function mapRequestPayloadProvider(): iterable "approved": false } JSON, - 'expectedResponse' => <<<'JSON' - { - "comment": "Hello everyone!", - "approved": false - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJsonStringEqualsJsonString(<<<'JSON' + { + "comment": "Hello everyone!", + "approved": false + } + JSON, + $response + ); + }, 'expectedStatusCode' => 200, ]; @@ -288,12 +289,16 @@ public static function mapRequestPayloadProvider(): iterable true XML, - 'expectedResponse' => <<<'XML' - - Hello everyone! - 1 - - XML, + 'responseAssertion' => static function (string $response) { + self::assertXmlStringEqualsXmlString(<<<'XML' + + Hello everyone! + 1 + + XML, + $response + ); + }, 'expectedStatusCode' => 200, ]; @@ -302,12 +307,16 @@ public static function mapRequestPayloadProvider(): iterable 'format' => 'json', 'parameters' => ['comment' => 'Hello everyone!', 'approved' => '0'], 'content' => null, - 'expectedResponse' => <<<'JSON' - { - "comment": "Hello everyone!", - "approved": false - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJsonStringEqualsJsonString(<<<'JSON' + { + "comment": "Hello everyone!", + "approved": false + } + JSON, + $response + ); + }, 'expectedStatusCode' => 200, ]; @@ -321,14 +330,18 @@ public static function mapRequestPayloadProvider(): iterable "approved": false, } JSON, - 'expectedResponse' => <<<'JSON' - { - "type": "https:\/\/tools.ietf.org\/html\/rfc2616#section-10", - "title": "An error occurred", - "status": 400, - "detail": "Bad Request" - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJsonStringEqualsJsonString(<<<'JSON' + { + "type": "https:\/\/tools.ietf.org\/html\/rfc2616#section-10", + "title": "An error occurred", + "status": 400, + "detail": "Bad Request" + } + JSON, + $response + ); + }, 'expectedStatusCode' => 400, ]; @@ -337,7 +350,9 @@ public static function mapRequestPayloadProvider(): iterable 'format' => 'dummy', 'parameters' => [], 'content' => 'Hello', - 'expectedResponse' => '415 Unsupported Media Type', + 'responseAssertion' => static function (string $response) { + self::assertStringContainsString('415 Unsupported Media Type', $response); + }, 'expectedStatusCode' => 415, ]; @@ -351,24 +366,28 @@ public static function mapRequestPayloadProvider(): iterable "approved": "string instead of bool" } JSON, - 'expectedResponse' => <<<'JSON' - { - "type": "https:\/\/symfony.com\/errors\/validation", - "title": "Validation Failed", - "status": 422, - "detail": "approved: This value should be of type bool.", - "violations": [ - { - "propertyPath": "approved", - "title": "This value should be of type bool.", - "template": "This value should be of type {{ type }}.", - "parameters": { - "{{ type }}": "bool" + 'responseAssertion' => static function (string $response) { + self::assertJsonStringEqualsJsonString(<<<'JSON' + { + "type": "https:\/\/symfony.com\/errors\/validation", + "title": "Validation Failed", + "status": 422, + "detail": "approved: This value should be of type bool.", + "violations": [ + { + "propertyPath": "approved", + "title": "This value should be of type bool.", + "template": "This value should be of type {{ type }}.", + "parameters": { + "{{ type }}": "bool" + } } - } - ] - } - JSON, + ] + } + JSON, + $response + ); + }, 'expectedStatusCode' => 422, ]; @@ -382,36 +401,20 @@ public static function mapRequestPayloadProvider(): iterable "approved": true } JSON, - 'expectedResponse' => <<<'JSON' - { - "type": "https:\/\/symfony.com\/errors\/validation", - "title": "Validation Failed", - "status": 422, - "detail": "comment: This value should not be blank.\ncomment: This value is too short. It should have 10 characters or more.", - "violations": [ - { - "propertyPath": "comment", - "title": "This value should not be blank.", - "template": "This value should not be blank.", - "parameters": { - "{{ value }}": "\"\"" - }, - "type": "urn:uuid:c1051bb4-d103-4f74-8988-acbcafc7fdc3" - }, - { - "propertyPath": "comment", - "title": "This value is too short. It should have 10 characters or more.", - "template": "This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.", - "parameters": { - "{{ value }}": "\"\"", - "{{ limit }}": "10", - "{{ value_length }}": "0" - }, - "type": "urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45" - } - ] - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJson($response); + + $json = json_decode($response, true); + + self::assertSame('https://symfony.com/errors/validation', $json['type'] ?? null); + self::assertSame('Validation Failed', $json['title'] ?? null); + self::assertSame(422, $json['status'] ?? null); + self::assertSame("comment: This value should not be blank.\ncomment: This value is too short. It should have 10 characters or more.", $json['detail'] ?? null); + self::assertIsArray($json['violations'] ?? null); + self::assertCount(2, $json['violations']); + self::assertSame('urn:uuid:c1051bb4-d103-4f74-8988-acbcafc7fdc3', $json['violations'][0]['type'] ?? null); + self::assertSame('urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45', $json['violations'][1]['type'] ?? null); + }, 'expectedStatusCode' => 422, ]; @@ -425,26 +428,16 @@ public static function mapRequestPayloadProvider(): iterable false XML, - 'expectedResponse' => <<<'XML' - - - https://symfony.com/errors/validation - Validation Failed - 422 - comment: This value is too short. It should have 10 characters or more. - - comment - This value is too short. It should have 10 characters or more. - - - "H" - 10 - 1 - - urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45 - - - XML, + 'responseAssertion' => static function (string $response) { + $crawler = new Crawler($response); + + self::assertSame('https://symfony.com/errors/validation', $crawler->filterXPath('response/type')->text()); + self::assertSame('Validation Failed', $crawler->filterXPath('response/title')->text()); + self::assertSame('422', $crawler->filterXPath('response/status')->text()); + self::assertSame('comment: This value is too short. It should have 10 characters or more.', $crawler->filterXPath('response/detail')->text()); + self::assertCount(1, $crawler->filterXPath('response/violations')); + self::assertSame('urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45', $crawler->filterXPath('response/violations/type')->text()); + }, 'expectedStatusCode' => 422, ]; @@ -453,36 +446,20 @@ public static function mapRequestPayloadProvider(): iterable 'format' => 'json', 'parameters' => ['comment' => '', 'approved' => '1'], 'content' => null, - 'expectedResponse' => <<<'JSON' - { - "type": "https:\/\/symfony.com\/errors\/validation", - "title": "Validation Failed", - "status": 422, - "detail": "comment: This value should not be blank.\ncomment: This value is too short. It should have 10 characters or more.", - "violations": [ - { - "propertyPath": "comment", - "title": "This value should not be blank.", - "template": "This value should not be blank.", - "parameters": { - "{{ value }}": "\"\"" - }, - "type": "urn:uuid:c1051bb4-d103-4f74-8988-acbcafc7fdc3" - }, - { - "propertyPath": "comment", - "title": "This value is too short. It should have 10 characters or more.", - "template": "This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.", - "parameters": { - "{{ value }}": "\"\"", - "{{ limit }}": "10", - "{{ value_length }}": "0" - }, - "type": "urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45" - } - ] - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJson($response); + + $json = json_decode($response, true); + + self::assertSame('https://symfony.com/errors/validation', $json['type'] ?? null); + self::assertSame('Validation Failed', $json['title'] ?? null); + self::assertSame(422, $json['status'] ?? null); + self::assertSame("comment: This value should not be blank.\ncomment: This value is too short. It should have 10 characters or more.", $json['detail'] ?? null); + self::assertIsArray($json['violations'] ?? null); + self::assertCount(2, $json['violations']); + self::assertSame('urn:uuid:c1051bb4-d103-4f74-8988-acbcafc7fdc3', $json['violations'][0]['type'] ?? null); + self::assertSame('urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45', $json['violations'][1]['type'] ?? null); + }, 'expectedStatusCode' => 422, ]; @@ -491,12 +468,16 @@ public static function mapRequestPayloadProvider(): iterable 'format' => 'json', 'parameters' => [], 'content' => '', - 'expectedResponse' => <<<'JSON' - { - "comment": "Hello everyone!", - "approved": false - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJsonStringEqualsJsonString(<<<'JSON' + { + "comment": "Hello everyone!", + "approved": false + } + JSON, + $response + ); + }, 'expectedStatusCode' => 200, ]; @@ -510,12 +491,16 @@ public static function mapRequestPayloadProvider(): iterable "approved": false } JSON, - 'expectedResponse' => <<<'JSON' - { - "comment": "Hello everyone!", - "approved": false - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJsonStringEqualsJsonString(<<<'JSON' + { + "comment": "Hello everyone!", + "approved": false + } + JSON, + $response + ); + }, 'expectedStatusCode' => 200, ]; @@ -529,12 +514,16 @@ public static function mapRequestPayloadProvider(): iterable true XML, - 'expectedResponse' => <<<'XML' - - Hello everyone! - 1 - - XML, + 'responseAssertion' => static function (string $response) { + self::assertXmlStringEqualsXmlString(<<<'XML' + + Hello everyone! + 1 + + XML, + $response + ); + }, 'expectedStatusCode' => 200, ]; @@ -543,12 +532,16 @@ public static function mapRequestPayloadProvider(): iterable 'format' => 'json', 'parameters' => ['comment' => 'Hello everyone!', 'approved' => '0'], 'content' => null, - 'expectedResponse' => <<<'JSON' - { - "comment": "Hello everyone!", - "approved": false - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJsonStringEqualsJsonString(<<<'JSON' + { + "comment": "Hello everyone!", + "approved": false + } + JSON, + $response + ); + }, 'expectedStatusCode' => 200, ]; @@ -562,14 +555,18 @@ public static function mapRequestPayloadProvider(): iterable "approved": false, } JSON, - 'expectedResponse' => <<<'JSON' - { - "type": "https:\/\/tools.ietf.org\/html\/rfc2616#section-10", - "title": "An error occurred", - "status": 400, - "detail": "Bad Request" - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJsonStringEqualsJsonString(<<<'JSON' + { + "type": "https:\/\/tools.ietf.org\/html\/rfc2616#section-10", + "title": "An error occurred", + "status": 400, + "detail": "Bad Request" + } + JSON, + $response + ); + }, 'expectedStatusCode' => 400, ]; @@ -578,7 +575,9 @@ public static function mapRequestPayloadProvider(): iterable 'format' => 'dummy', 'parameters' => [], 'content' => 'Hello', - 'expectedResponse' => '415 Unsupported Media Type', + 'responseAssertion' => static function (string $response) { + self::assertStringContainsString('415 Unsupported Media Type', $response); + }, 'expectedStatusCode' => 415, ]; @@ -592,24 +591,19 @@ public static function mapRequestPayloadProvider(): iterable "approved": "string instead of bool" } JSON, - 'expectedResponse' => <<<'JSON' - { - "type": "https:\/\/symfony.com\/errors\/validation", - "title": "Validation Failed", - "status": 422, - "detail": "approved: This value should be of type bool.", - "violations": [ - { - "propertyPath": "approved", - "title": "This value should be of type bool.", - "template": "This value should be of type {{ type }}.", - "parameters": { - "{{ type }}": "bool" - } - } - ] - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJson($response); + + $json = json_decode($response, true); + + self::assertSame('https://symfony.com/errors/validation', $json['type'] ?? null); + self::assertSame('Validation Failed', $json['title'] ?? null); + self::assertSame(422, $json['status'] ?? null); + self::assertSame('approved: This value should be of type bool.', $json['detail'] ?? null); + self::assertIsArray($json['violations'] ?? null); + self::assertCount(1, $json['violations']); + self::assertSame('approved', $json['violations'][0]['propertyPath'] ?? null); +}, 'expectedStatusCode' => 422, ]; @@ -623,36 +617,20 @@ public static function mapRequestPayloadProvider(): iterable "approved": true } JSON, - 'expectedResponse' => <<<'JSON' - { - "type": "https:\/\/symfony.com\/errors\/validation", - "title": "Validation Failed", - "status": 422, - "detail": "comment: This value should not be blank.\ncomment: This value is too short. It should have 10 characters or more.", - "violations": [ - { - "propertyPath": "comment", - "title": "This value should not be blank.", - "template": "This value should not be blank.", - "parameters": { - "{{ value }}": "\"\"" - }, - "type": "urn:uuid:c1051bb4-d103-4f74-8988-acbcafc7fdc3" - }, - { - "propertyPath": "comment", - "title": "This value is too short. It should have 10 characters or more.", - "template": "This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.", - "parameters": { - "{{ value }}": "\"\"", - "{{ limit }}": "10", - "{{ value_length }}": "0" - }, - "type": "urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45" - } - ] - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJson($response); + + $json = json_decode($response, true); + + self::assertSame('https://symfony.com/errors/validation', $json['type'] ?? null); + self::assertSame('Validation Failed', $json['title'] ?? null); + self::assertSame(422, $json['status'] ?? null); + self::assertSame("comment: This value should not be blank.\ncomment: This value is too short. It should have 10 characters or more.", $json['detail'] ?? null); + self::assertIsArray($json['violations'] ?? null); + self::assertCount(2, $json['violations']); + self::assertSame('urn:uuid:c1051bb4-d103-4f74-8988-acbcafc7fdc3', $json['violations'][0]['type'] ?? null); + self::assertSame('urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45', $json['violations'][1]['type'] ?? null); + }, 'expectedStatusCode' => 422, ]; @@ -666,26 +644,16 @@ public static function mapRequestPayloadProvider(): iterable false XML, - 'expectedResponse' => <<<'XML' - - - https://symfony.com/errors/validation - Validation Failed - 422 - comment: This value is too short. It should have 10 characters or more. - - comment - This value is too short. It should have 10 characters or more. - - - "H" - 10 - 1 - - urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45 - - - XML, + 'responseAssertion' => static function (string $response) { + $crawler = new Crawler($response); + + self::assertSame('https://symfony.com/errors/validation', $crawler->filterXPath('response/type')->text()); + self::assertSame('Validation Failed', $crawler->filterXPath('response/title')->text()); + self::assertSame('422', $crawler->filterXPath('response/status')->text()); + self::assertSame('comment: This value is too short. It should have 10 characters or more.', $crawler->filterXPath('response/detail')->text()); + self::assertCount(1, $crawler->filterXPath('response/violations')); + self::assertSame('urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45', $crawler->filterXPath('response/violations/type')->text()); + }, 'expectedStatusCode' => 422, ]; @@ -694,56 +662,41 @@ public static function mapRequestPayloadProvider(): iterable 'format' => 'json', 'parameters' => ['comment' => '', 'approved' => '1'], 'content' => null, - 'expectedResponse' => <<<'JSON' - { - "type": "https:\/\/symfony.com\/errors\/validation", - "title": "Validation Failed", - "status": 422, - "detail": "comment: This value should not be blank.\ncomment: This value is too short. It should have 10 characters or more.", - "violations": [ - { - "propertyPath": "comment", - "title": "This value should not be blank.", - "template": "This value should not be blank.", - "parameters": { - "{{ value }}": "\"\"" - }, - "type": "urn:uuid:c1051bb4-d103-4f74-8988-acbcafc7fdc3" - }, - { - "propertyPath": "comment", - "title": "This value is too short. It should have 10 characters or more.", - "template": "This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.", - "parameters": { - "{{ value }}": "\"\"", - "{{ limit }}": "10", - "{{ value_length }}": "0" - }, - "type": "urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45" - } - ] - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJson($response); + + $json = json_decode($response, true); + + self::assertSame('https://symfony.com/errors/validation', $json['type'] ?? null); + self::assertSame('Validation Failed', $json['title'] ?? null); + self::assertSame(422, $json['status'] ?? null); + self::assertSame("comment: This value should not be blank.\ncomment: This value is too short. It should have 10 characters or more.", $json['detail'] ?? null); + self::assertIsArray($json['violations'] ?? null); + self::assertCount(2, $json['violations']); + self::assertSame('urn:uuid:c1051bb4-d103-4f74-8988-acbcafc7fdc3', $json['violations'][0]['type'] ?? null); + self::assertSame('urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45', $json['violations'][1]['type'] ?? null); + }, 'expectedStatusCode' => 422, ]; - $expectedStatusCode = 400; - $expectedResponse = <<<'JSON' - { - "type":"https:\/\/tools.ietf.org\/html\/rfc2616#section-10", - "title":"An error occurred", - "status":400, - "detail":"Bad Request" - } - JSON; - yield 'empty request mapping non-nullable attribute without default value' => [ 'uri' => '/map-request-to-non-nullable-attribute-without-default-value.json', 'format' => 'json', 'parameters' => [], 'content' => '', - 'expectedResponse' => $expectedResponse, - 'expectedStatusCode' => $expectedStatusCode, + 'responseAssertion' => static function (string $response) { + self::assertJsonStringEqualsJsonString(<<<'JSON' + { + "type":"https:\/\/tools.ietf.org\/html\/rfc2616#section-10", + "title":"An error occurred", + "status":400, + "detail":"Bad Request" + } + JSON, + $response + ); + }, + 'expectedStatusCode' => 400, ]; yield 'valid request with json content mapping non-nullable attribute without default value' => [ @@ -756,12 +709,16 @@ public static function mapRequestPayloadProvider(): iterable "approved": false } JSON, - 'expectedResponse' => <<<'JSON' - { - "comment": "Hello everyone!", - "approved": false - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJsonStringEqualsJsonString(<<<'JSON' + { + "comment": "Hello everyone!", + "approved": false + } + JSON, + $response + ); + }, 'expectedStatusCode' => 200, ]; @@ -775,12 +732,16 @@ public static function mapRequestPayloadProvider(): iterable true XML, - 'expectedResponse' => <<<'XML' - - Hello everyone! - 1 - - XML, + 'responseAssertion' => static function (string $response) { + self::assertXmlStringEqualsXmlString(<<<'XML' + + Hello everyone! + 1 + + XML, + $response + ); + }, 'expectedStatusCode' => 200, ]; @@ -789,12 +750,16 @@ public static function mapRequestPayloadProvider(): iterable 'format' => 'json', 'parameters' => ['comment' => 'Hello everyone!', 'approved' => '0'], 'content' => null, - 'expectedResponse' => <<<'JSON' - { - "comment": "Hello everyone!", - "approved": false - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJsonStringEqualsJsonString(<<<'JSON' + { + "comment": "Hello everyone!", + "approved": false + } + JSON, + $response + ); + }, 'expectedStatusCode' => 200, ]; @@ -808,14 +773,18 @@ public static function mapRequestPayloadProvider(): iterable "approved": false, } JSON, - 'expectedResponse' => <<<'JSON' - { - "type": "https:\/\/tools.ietf.org\/html\/rfc2616#section-10", - "title": "An error occurred", - "status": 400, - "detail": "Bad Request" - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJsonStringEqualsJsonString(<<<'JSON' + { + "type": "https:\/\/tools.ietf.org\/html\/rfc2616#section-10", + "title": "An error occurred", + "status": 400, + "detail": "Bad Request" + } + JSON, + $response + ); + }, 'expectedStatusCode' => 400, ]; @@ -824,7 +793,9 @@ public static function mapRequestPayloadProvider(): iterable 'format' => 'dummy', 'parameters' => [], 'content' => 'Hello', - 'expectedResponse' => '415 Unsupported Media Type', + 'responseAssertion' => static function (string $response) { + self::assertStringContainsString('415 Unsupported Media Type', $response); + }, 'expectedStatusCode' => 415, ]; @@ -838,24 +809,19 @@ public static function mapRequestPayloadProvider(): iterable "approved": "string instead of bool" } JSON, - 'expectedResponse' => <<<'JSON' - { - "type": "https:\/\/symfony.com\/errors\/validation", - "title": "Validation Failed", - "status": 422, - "detail": "approved: This value should be of type bool.", - "violations": [ - { - "propertyPath": "approved", - "title": "This value should be of type bool.", - "template": "This value should be of type {{ type }}.", - "parameters": { - "{{ type }}": "bool" - } - } - ] - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJson($response); + + $json = json_decode($response, true); + + self::assertSame('https://symfony.com/errors/validation', $json['type'] ?? null); + self::assertSame('Validation Failed', $json['title'] ?? null); + self::assertSame(422, $json['status'] ?? null); + self::assertSame('approved: This value should be of type bool.', $json['detail'] ?? null); + self::assertIsArray($json['violations'] ?? null); + self::assertCount(1, $json['violations']); + self::assertSame('approved', $json['violations'][0]['propertyPath'] ?? null); + }, 'expectedStatusCode' => 422, ]; @@ -869,36 +835,20 @@ public static function mapRequestPayloadProvider(): iterable "approved": true } JSON, - 'expectedResponse' => <<<'JSON' - { - "type": "https:\/\/symfony.com\/errors\/validation", - "title": "Validation Failed", - "status": 422, - "detail": "comment: This value should not be blank.\ncomment: This value is too short. It should have 10 characters or more.", - "violations": [ - { - "propertyPath": "comment", - "title": "This value should not be blank.", - "template": "This value should not be blank.", - "parameters": { - "{{ value }}": "\"\"" - }, - "type": "urn:uuid:c1051bb4-d103-4f74-8988-acbcafc7fdc3" - }, - { - "propertyPath": "comment", - "title": "This value is too short. It should have 10 characters or more.", - "template": "This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.", - "parameters": { - "{{ value }}": "\"\"", - "{{ limit }}": "10", - "{{ value_length }}": "0" - }, - "type": "urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45" - } - ] - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJson($response); + + $json = json_decode($response, true); + + self::assertSame('https://symfony.com/errors/validation', $json['type'] ?? null); + self::assertSame('Validation Failed', $json['title'] ?? null); + self::assertSame(422, $json['status'] ?? null); + self::assertSame("comment: This value should not be blank.\ncomment: This value is too short. It should have 10 characters or more.", $json['detail'] ?? null); + self::assertIsArray($json['violations'] ?? null); + self::assertCount(2, $json['violations']); + self::assertSame('urn:uuid:c1051bb4-d103-4f74-8988-acbcafc7fdc3', $json['violations'][0]['type'] ?? null); + self::assertSame('urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45', $json['violations'][1]['type'] ?? null); + }, 'expectedStatusCode' => 422, ]; @@ -912,26 +862,16 @@ public static function mapRequestPayloadProvider(): iterable false XML, - 'expectedResponse' => <<<'XML' - - - https://symfony.com/errors/validation - Validation Failed - 422 - comment: This value is too short. It should have 10 characters or more. - - comment - This value is too short. It should have 10 characters or more. - - - "H" - 10 - 1 - - urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45 - - - XML, + 'responseAssertion' => static function (string $response) { + $crawler = new Crawler($response); + + self::assertSame('https://symfony.com/errors/validation', $crawler->filterXPath('response/type')->text()); + self::assertSame('Validation Failed', $crawler->filterXPath('response/title')->text()); + self::assertSame('422', $crawler->filterXPath('response/status')->text()); + self::assertSame('comment: This value is too short. It should have 10 characters or more.', $crawler->filterXPath('response/detail')->text()); + self::assertCount(1, $crawler->filterXPath('response/violations')); + self::assertSame('urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45', $crawler->filterXPath('response/violations/type')->text()); + }, 'expectedStatusCode' => 422, ]; @@ -940,36 +880,20 @@ public static function mapRequestPayloadProvider(): iterable 'format' => 'json', 'parameters' => ['comment' => '', 'approved' => '1'], 'content' => null, - 'expectedResponse' => <<<'JSON' - { - "type": "https:\/\/symfony.com\/errors\/validation", - "title": "Validation Failed", - "status": 422, - "detail": "comment: This value should not be blank.\ncomment: This value is too short. It should have 10 characters or more.", - "violations": [ - { - "propertyPath": "comment", - "title": "This value should not be blank.", - "template": "This value should not be blank.", - "parameters": { - "{{ value }}": "\"\"" - }, - "type": "urn:uuid:c1051bb4-d103-4f74-8988-acbcafc7fdc3" - }, - { - "propertyPath": "comment", - "title": "This value is too short. It should have 10 characters or more.", - "template": "This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.", - "parameters": { - "{{ value }}": "\"\"", - "{{ limit }}": "10", - "{{ value_length }}": "0" - }, - "type": "urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45" - } - ] - } - JSON, + 'responseAssertion' => static function (string $response) { + self::assertJson($response); + + $json = json_decode($response, true); + + self::assertSame('https://symfony.com/errors/validation', $json['type'] ?? null); + self::assertSame('Validation Failed', $json['title'] ?? null); + self::assertSame(422, $json['status'] ?? null); + self::assertSame("comment: This value should not be blank.\ncomment: This value is too short. It should have 10 characters or more.", $json['detail'] ?? null); + self::assertIsArray($json['violations'] ?? null); + self::assertCount(2, $json['violations']); + self::assertSame('urn:uuid:c1051bb4-d103-4f74-8988-acbcafc7fdc3', $json['violations'][0]['type'] ?? null); + self::assertSame('urn:uuid:9ff3fdc4-b214-49db-8718-39c315e33d45', $json['violations'][1]['type'] ?? null); + }, 'expectedStatusCode' => 422, ]; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php index bd153963632e2..2c47121c147b5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php @@ -141,7 +141,7 @@ public function testParametersValuesAreFullyResolved(bool $debug) $this->assertStringContainsString('locale: en', $tester->getDisplay()); $this->assertStringContainsString('secret: test', $tester->getDisplay()); $this->assertStringContainsString('cookie_httponly: true', $tester->getDisplay()); - $this->assertStringContainsString('ide: '.$debug ? ($_ENV['SYMFONY_IDE'] ?? $_SERVER['SYMFONY_IDE'] ?? 'null') : 'null', $tester->getDisplay()); + $this->assertStringContainsString('ide: '.($debug ? ($_ENV['SYMFONY_IDE'] ?? $_SERVER['SYMFONY_IDE'] ?? 'null') : 'null'), $tester->getDisplay()); } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php index 8d3f15ba61680..d21d4d113d2e6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php @@ -53,7 +53,7 @@ public function testNoDebug() public function testNoDumpedXML() { - static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml', 'debug' => true, 'debug.container.dump' => false]); + static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'no_dump.yml', 'debug' => true]); $application = new Application(static::$kernel); $application->setAutoExit(false); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerLintCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerLintCommandTest.php new file mode 100644 index 0000000000000..f0b6b4bd57b07 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerLintCommandTest.php @@ -0,0 +1,56 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; + +use Symfony\Bundle\FrameworkBundle\Console\Application; +use Symfony\Component\Console\Tester\CommandTester; + +/** + * @group functional + */ +class ContainerLintCommandTest extends AbstractWebTestCase +{ + private Application $application; + + /** + * @dataProvider containerLintProvider + */ + public function testLintContainer(string $configFile, bool $resolveEnvVars, int $expectedExitCode, string $expectedOutput) + { + $kernel = static::createKernel([ + 'test_case' => 'ContainerLint', + 'root_config' => $configFile, + 'debug' => true, + ]); + $this->application = new Application($kernel); + + $tester = $this->createCommandTester(); + $exitCode = $tester->execute(['--resolve-env-vars' => $resolveEnvVars]); + + $this->assertSame($expectedExitCode, $exitCode); + $this->assertStringContainsString($expectedOutput, $tester->getDisplay()); + } + + public static function containerLintProvider(): array + { + return [ + ['escaped_percent.yml', false, 0, 'The container was linted successfully'], + ['missing_env_var.yml', false, 0, 'The container was linted successfully'], + ['missing_env_var.yml', true, 1, 'Environment variable not found: "BAR"'], + ]; + } + + private function createCommandTester(): CommandTester + { + return new CommandTester($this->application->get('lint:container')); + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/JsonEncoderTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/JsonEncoderTest.php deleted file mode 100644 index b5410e1e1127b..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/JsonEncoderTest.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; - -use Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonEncoder\Dto\Dummy; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\JsonEncoder\DecoderInterface; -use Symfony\Component\JsonEncoder\EncoderInterface; -use Symfony\Component\TypeInfo\Type; - -/** - * @author Mathias Arlaud - */ -class JsonEncoderTest extends AbstractWebTestCase -{ - protected function setUp(): void - { - static::bootKernel(['test_case' => 'JsonEncoder']); - } - - public function testEncode() - { - /** @var EncoderInterface $encoder */ - $encoder = static::getContainer()->get('json_encoder.encoder.alias'); - - $this->assertSame('{"@name":"DUMMY","range":"10..20"}', (string) $encoder->encode(new Dummy(), Type::object(Dummy::class))); - } - - public function testDecode() - { - /** @var DecoderInterface $decoder */ - $decoder = static::getContainer()->get('json_encoder.decoder.alias'); - - $expected = new Dummy(); - $expected->name = 'dummy'; - $expected->range = [0, 1]; - - $this->assertEquals($expected, $decoder->decode('{"@name": "DUMMY", "range": "0..1"}', Type::object(Dummy::class))); - } - - public function testWarmupEncodableClasses() - { - /** @var Filesystem $fs */ - $fs = static::getContainer()->get('filesystem'); - - $encodersDir = \sprintf('%s/json_encoder/encoder/', static::getContainer()->getParameter('kernel.cache_dir')); - - // clear already created encoders - if ($fs->exists($encodersDir)) { - $fs->remove($encodersDir); - } - - static::getContainer()->get('json_encoder.cache_warmer.encoder_decoder.alias')->warmUp(static::getContainer()->getParameter('kernel.cache_dir')); - - $this->assertFileExists($encodersDir); - $this->assertCount(2, glob($encodersDir.'/*')); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/JsonStreamerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/JsonStreamerTest.php new file mode 100644 index 0000000000000..9816015b4484e --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/JsonStreamerTest.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; + +use Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonStreamer\Dto\Dummy; +use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\JsonStreamer\StreamReaderInterface; +use Symfony\Component\JsonStreamer\StreamWriterInterface; +use Symfony\Component\TypeInfo\Type; + +/** + * @author Mathias Arlaud + */ +class JsonStreamerTest extends AbstractWebTestCase +{ + protected function setUp(): void + { + static::bootKernel(['test_case' => 'JsonStreamer']); + } + + public function testWrite() + { + /** @var StreamWriterInterface $writer */ + $writer = static::getContainer()->get('json_streamer.stream_writer.alias'); + + $this->assertSame('{"@name":"DUMMY","range":"10..20"}', (string) $writer->write(new Dummy(), Type::object(Dummy::class))); + } + + public function testRead() + { + /** @var StreamReaderInterface $reader */ + $reader = static::getContainer()->get('json_streamer.stream_reader.alias'); + + $expected = new Dummy(); + $expected->name = 'dummy'; + $expected->range = [0, 1]; + + $this->assertEquals($expected, $reader->read('{"@name": "DUMMY", "range": "0..1"}', Type::object(Dummy::class))); + } + + public function testWarmupStreamableClasses() + { + /** @var Filesystem $fs */ + $fs = static::getContainer()->get('filesystem'); + + $streamWritersDir = \sprintf('%s/json_streamer/stream_writer/', static::getContainer()->getParameter('kernel.cache_dir')); + + // clear already created stream writers + if ($fs->exists($streamWritersDir)) { + $fs->remove($streamWritersDir); + } + + static::getContainer()->get('json_streamer.cache_warmer.streamer.alias')->warmUp(static::getContainer()->getParameter('kernel.cache_dir')); + + $this->assertFileExists($streamWritersDir); + $this->assertCount(2, glob($streamWritersDir.'/*')); + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ObjectMapperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ObjectMapperTest.php new file mode 100644 index 0000000000000..e314ee1b029e5 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ObjectMapperTest.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; + +use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ObjectMapper\ObjectMapped; +use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ObjectMapper\ObjectToBeMapped; + +/** + * @author Kévin Dunglas + */ +class ObjectMapperTest extends AbstractWebTestCase +{ + public function testObjectMapper() + { + static::bootKernel(['test_case' => 'ObjectMapper']); + + /** @var Symfony\Component\ObjectMapper\ObjectMapperInterface */ + $objectMapper = static::getContainer()->get('object_mapper.alias'); + $mapped = $objectMapper->map(new ObjectToBeMapped()); + $this->assertSame($mapped->a, 'transformed'); + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SchedulerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SchedulerTest.php index 99776e8223e9d..537493a5580b6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SchedulerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SchedulerTest.php @@ -12,6 +12,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\BarMessage; +use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyCommand; use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummySchedule; use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyTask; use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\FooMessage; @@ -88,6 +89,29 @@ public function testAutoconfiguredScheduler() $this->assertSame([['5', 6], ['7', 8]], $calls['attributesOnMethod']); } + public function testAutoconfiguredSchedulerCommand() + { + $container = self::getContainer(); + $container->set('clock', $clock = new MockClock('2023-10-26T08:59:59Z')); + + $this->assertTrue($container->get('receivers')->has('scheduler_dummy_command')); + $this->assertInstanceOf(SchedulerTransport::class, $cron = $container->get('receivers')->get('scheduler_dummy_command')); + $bus = $container->get(MessageBusInterface::class); + + $getCalls = static function (float $sleep) use ($clock, $cron, $bus) { + DummyCommand::$calls = []; + $clock->sleep($sleep); + foreach ($cron->get() as $message) { + $bus->dispatch($message->with(new ReceivedStamp('scheduler_dummy_command'))); + } + + return DummyCommand::$calls; + }; + + $this->assertSame([], $getCalls(0)); + $this->assertSame(['execute' => [0 => null, 1 => 'test']], $getCalls(1)); + } + public function testSchedulerWithCustomTransport() { $container = self::getContainer(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDebug/no_dump.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDebug/no_dump.yml new file mode 100644 index 0000000000000..a9c709e9a6425 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDebug/no_dump.yml @@ -0,0 +1,5 @@ +imports: + - { resource: config.yml } + +parameters: + debug.container.dump: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonEncoder/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerLint/bundles.php similarity index 100% rename from src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonEncoder/bundles.php rename to src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerLint/bundles.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerLint/escaped_percent.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerLint/escaped_percent.yml new file mode 100644 index 0000000000000..f5554e116546c --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerLint/escaped_percent.yml @@ -0,0 +1,5 @@ +imports: + - { resource: ../config/default.yml } + +parameters: + percent: '%%foo%%' diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerLint/missing_env_var.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerLint/missing_env_var.yml new file mode 100644 index 0000000000000..33ac97df47c3d --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerLint/missing_env_var.yml @@ -0,0 +1,5 @@ +imports: + - { resource: ../config/default.yml } + +parameters: + foo: '%env(BAR)%' diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonEncoder/Dto/Dummy.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonEncoder/Dto/Dummy.php deleted file mode 100644 index 8610de049fa28..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonEncoder/Dto/Dummy.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonEncoder\Dto; - -use Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonEncoder\RangeNormalizer; -use Symfony\Component\JsonEncoder\Attribute\Denormalizer; -use Symfony\Component\JsonEncoder\Attribute\EncodedName; -use Symfony\Component\JsonEncoder\Attribute\JsonEncodable; -use Symfony\Component\JsonEncoder\Attribute\Normalizer; - -/** - * @author Mathias Arlaud - */ -#[JsonEncodable] -class Dummy -{ - #[EncodedName('@name')] - #[Normalizer('strtoupper')] - #[Denormalizer('strtolower')] - public string $name = 'dummy'; - - #[Normalizer(RangeNormalizer::class)] - #[Denormalizer(RangeNormalizer::class)] - public array $range = [10, 20]; -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonEncoder/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonEncoder/config.yml deleted file mode 100644 index 13b68adef54c5..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonEncoder/config.yml +++ /dev/null @@ -1,26 +0,0 @@ -imports: - - { resource: ../config/default.yml } - -framework: - http_method_override: false - type_info: ~ - json_encoder: ~ - -services: - _defaults: - autoconfigure: true - - json_encoder.encoder.alias: - alias: json_encoder.encoder - public: true - - json_encoder.decoder.alias: - alias: json_encoder.decoder - public: true - - json_encoder.cache_warmer.encoder_decoder.alias: - alias: .json_encoder.cache_warmer.encoder_decoder - public: true - - Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonEncoder\Dto\Dummy: ~ - Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonEncoder\RangeNormalizer: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonStreamer/Dto/Dummy.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonStreamer/Dto/Dummy.php new file mode 100644 index 0000000000000..d1f1ca67a2a9a --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonStreamer/Dto/Dummy.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonStreamer\Dto; + +use Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonStreamer\RangeToStringValueTransformer; +use Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonStreamer\StringToRangeValueTransformer; +use Symfony\Component\JsonStreamer\Attribute\JsonStreamable; +use Symfony\Component\JsonStreamer\Attribute\StreamedName; +use Symfony\Component\JsonStreamer\Attribute\ValueTransformer; + +/** + * @author Mathias Arlaud + */ +#[JsonStreamable] +class Dummy +{ + #[StreamedName('@name')] + #[ValueTransformer( + nativeToStream: 'strtoupper', + streamToNative: 'strtolower', + )] + public string $name = 'dummy'; + + #[ValueTransformer( + nativeToStream: RangeToStringValueTransformer::class, + streamToNative: StringToRangeValueTransformer::class, + )] + public array $range = [10, 20]; +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonStreamer/RangeToStringValueTransformer.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonStreamer/RangeToStringValueTransformer.php new file mode 100644 index 0000000000000..6d21f2d2f834e --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonStreamer/RangeToStringValueTransformer.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonStreamer; + +use Symfony\Component\JsonStreamer\ValueTransformer\ValueTransformerInterface; +use Symfony\Component\TypeInfo\Type; +use Symfony\Component\TypeInfo\Type\BuiltinType; + +/** + * @author Mathias Arlaud + */ +class RangeToStringValueTransformer implements ValueTransformerInterface +{ + public function transform(mixed $value, array $options = []): string + { + return $value[0].'..'.$value[1]; + } + + public static function getStreamValueType(): BuiltinType + { + return Type::string(); + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonEncoder/RangeNormalizer.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonStreamer/StringToRangeValueTransformer.php similarity index 50% rename from src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonEncoder/RangeNormalizer.php rename to src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonStreamer/StringToRangeValueTransformer.php index beb9e81888ce4..398beb2ffab1d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonEncoder/RangeNormalizer.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonStreamer/StringToRangeValueTransformer.php @@ -9,29 +9,23 @@ * file that was distributed with this source code. */ -namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonEncoder; +namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonStreamer; -use Symfony\Component\JsonEncoder\Decode\Denormalizer\DenormalizerInterface; -use Symfony\Component\JsonEncoder\Encode\Normalizer\NormalizerInterface; +use Symfony\Component\JsonStreamer\ValueTransformer\ValueTransformerInterface; use Symfony\Component\TypeInfo\Type; use Symfony\Component\TypeInfo\Type\BuiltinType; /** * @author Mathias Arlaud */ -class RangeNormalizer implements NormalizerInterface, DenormalizerInterface +class StringToRangeValueTransformer implements ValueTransformerInterface { - public function normalize(mixed $denormalized, array $options = []): string + public function transform(mixed $value, array $options = []): array { - return $denormalized[0].'..'.$denormalized[1]; + return array_map(static fn (string $v): int => (int) $v, explode('..', $value)); } - public function denormalize(mixed $normalized, array $options = []): array - { - return array_map(static fn (string $v): int => (int) $v, explode('..', $normalized)); - } - - public static function getNormalizedType(): BuiltinType + public static function getStreamValueType(): BuiltinType { return Type::string(); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonStreamer/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonStreamer/bundles.php new file mode 100644 index 0000000000000..15ff182c6fed5 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonStreamer/bundles.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Bundle\FrameworkBundle\FrameworkBundle; +use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; + +return [ + new FrameworkBundle(), + new TestBundle(), +]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonStreamer/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonStreamer/config.yml new file mode 100644 index 0000000000000..188869b8269f6 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/JsonStreamer/config.yml @@ -0,0 +1,27 @@ +imports: + - { resource: ../config/default.yml } + +framework: + http_method_override: false + type_info: ~ + json_streamer: ~ + +services: + _defaults: + autoconfigure: true + + json_streamer.stream_writer.alias: + alias: json_streamer.stream_writer + public: true + + json_streamer.stream_reader.alias: + alias: json_streamer.stream_reader + public: true + + json_streamer.cache_warmer.streamer.alias: + alias: .json_streamer.cache_warmer.streamer + public: true + + Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonStreamer\Dto\Dummy: ~ + Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonStreamer\StringToRangeValueTransformer: ~ + Symfony\Bundle\FrameworkBundle\Tests\Functional\app\JsonStreamer\RangeToStringValueTransformer: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ObjectMapper/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ObjectMapper/bundles.php new file mode 100644 index 0000000000000..13ab9fddee4a6 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ObjectMapper/bundles.php @@ -0,0 +1,16 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Bundle\FrameworkBundle\FrameworkBundle; + +return [ + new FrameworkBundle(), +]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ObjectMapper/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ObjectMapper/config.yml new file mode 100644 index 0000000000000..3e3bd8702c6f6 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ObjectMapper/config.yml @@ -0,0 +1,9 @@ +imports: + - { resource: ../config/default.yml } + +services: + object_mapper.alias: + alias: object_mapper + public: true + Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ObjectMapper\TransformCallable: + autoconfigure: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Scheduler/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Scheduler/config.yml index bd1cb6516b260..f5bc14ec46dc0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Scheduler/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Scheduler/config.yml @@ -16,6 +16,9 @@ services: Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyTaskWithCustomReceiver: autoconfigure: true + Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyCommand: + autoconfigure: true + clock: synthetic: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/framework.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/framework.yml index 1eaee513c899b..ac051614bdd55 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/framework.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/framework.yml @@ -18,6 +18,8 @@ framework: cookie_samesite: lax php_errors: log: true + profiler: + collect_serializer_data: true services: logger: { class: Psr\Log\NullLogger } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/KernelCommand.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/KernelCommand.php new file mode 100644 index 0000000000000..4c9a5d85adcc2 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/KernelCommand.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Kernel; + +use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Output\OutputInterface; + +#[AsCommand(name: 'kernel:hello')] +final class KernelCommand extends MinimalKernel +{ + public function __invoke(OutputInterface $output): int + { + $output->write('Hello Kernel!'); + + return 0; + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php index a9d2ae7209efe..159dd21eb2690 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php @@ -13,7 +13,10 @@ use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; -use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; +use Symfony\Bundle\FrameworkBundle\Console\Application; +use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\DependencyInjection\Loader\ClosureLoader; @@ -152,6 +155,23 @@ public function testSimpleKernel() $this->assertSame('Hello World!', $response->getContent()); } + public function testKernelCommand() + { + if (!property_exists(AsCommand::class, 'help')) { + $this->markTestSkipped('Invokable command no available.'); + } + + $kernel = $this->kernel = new KernelCommand('kernel_command'); + $application = new Application($kernel); + + $input = new ArrayInput(['command' => 'kernel:hello']); + $output = new BufferedOutput(); + + $this->assertTrue($application->has('kernel:hello')); + $this->assertSame(0, $application->doRun($input, $output)); + $this->assertSame('Hello Kernel!', $output->fetch()); + } + public function testDefaultKernel() { $kernel = $this->kernel = new DefaultKernel('test', false); @@ -165,27 +185,3 @@ public function testDefaultKernel() $this->assertSame('OK', $response->getContent()); } } - -abstract class MinimalKernel extends Kernel -{ - use MicroKernelTrait; - - private string $cacheDir; - - public function __construct(string $cacheDir) - { - parent::__construct('test', false); - - $this->cacheDir = sys_get_temp_dir().'/'.$cacheDir; - } - - public function getCacheDir(): string - { - return $this->cacheDir; - } - - public function getLogDir(): string - { - return $this->cacheDir; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MinimalKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MinimalKernel.php new file mode 100644 index 0000000000000..df2c97e6a0be8 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MinimalKernel.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Kernel; + +use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; +use Symfony\Component\HttpKernel\Kernel; + +abstract class MinimalKernel extends Kernel +{ + use MicroKernelTrait; + + private string $cacheDir; + + public function __construct(string $cacheDir) + { + parent::__construct('test', false); + + $this->cacheDir = sys_get_temp_dir().'/'.$cacheDir; + } + + public function getCacheDir(): string + { + return $this->cacheDir; + } + + public function getLogDir(): string + { + return $this->cacheDir; + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 03707eea39b5f..a00bac1c3a9b5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -23,7 +23,7 @@ "symfony/config": "^7.3", "symfony/dependency-injection": "^7.2", "symfony/deprecation-contracts": "^2.5|^3", - "symfony/error-handler": "^6.4|^7.0", + "symfony/error-handler": "^7.3", "symfony/event-dispatcher": "^6.4|^7.0", "symfony/http-foundation": "^7.3", "symfony/http-kernel": "^7.2", @@ -54,22 +54,23 @@ "symfony/messenger": "^6.4|^7.0", "symfony/mime": "^6.4|^7.0", "symfony/notifier": "^6.4|^7.0", + "symfony/object-mapper": "^v7.3.0-beta2", "symfony/process": "^6.4|^7.0", "symfony/rate-limiter": "^6.4|^7.0", "symfony/scheduler": "^6.4.4|^7.0.4", "symfony/security-bundle": "^6.4|^7.0", "symfony/semaphore": "^6.4|^7.0", - "symfony/serializer": "^7.1", + "symfony/serializer": "^7.2.5", "symfony/stopwatch": "^6.4|^7.0", "symfony/string": "^6.4|^7.0", - "symfony/translation": "^6.4.3|^7.0", + "symfony/translation": "^7.3", "symfony/twig-bundle": "^6.4|^7.0", - "symfony/type-info": "^7.1", + "symfony/type-info": "^7.1.8", "symfony/validator": "^6.4|^7.0", - "symfony/workflow": "^6.4|^7.0", + "symfony/workflow": "^7.3", "symfony/yaml": "^6.4|^7.0", "symfony/property-info": "^6.4|^7.0", - "symfony/json-encoder": "7.3.*", + "symfony/json-streamer": "7.3.*", "symfony/uid": "^6.4|^7.0", "symfony/web-link": "^6.4|^7.0", "symfony/webhook": "^7.2", @@ -88,26 +89,27 @@ "symfony/dom-crawler": "<6.4", "symfony/http-client": "<6.4", "symfony/form": "<6.4", - "symfony/json-encoder": ">=7.4", + "symfony/json-streamer": ">=7.4", "symfony/lock": "<6.4", "symfony/mailer": "<6.4", "symfony/messenger": "<6.4", "symfony/mime": "<6.4", + "symfony/object-mapper": ">=7.4", "symfony/property-info": "<6.4", "symfony/property-access": "<6.4", "symfony/runtime": "<6.4.13|>=7.0,<7.1.6", "symfony/scheduler": "<6.4.4|>=7.0.0,<7.0.4", "symfony/security-csrf": "<7.2", "symfony/security-core": "<6.4", - "symfony/serializer": "<7.1", + "symfony/serializer": "<7.2.5", "symfony/stopwatch": "<6.4", - "symfony/translation": "<6.4.3", + "symfony/translation": "<7.3", "symfony/twig-bridge": "<6.4", "symfony/twig-bundle": "<6.4", "symfony/validator": "<6.4", "symfony/web-profiler-bundle": "<6.4", "symfony/webhook": "<7.2", - "symfony/workflow": "<6.4" + "symfony/workflow": "<7.3.0-beta2" }, "autoload": { "psr-4": { "Symfony\\Bundle\\FrameworkBundle\\": "" }, diff --git a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md index 574a8910fcd9c..77aa957331bd1 100644 --- a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md @@ -9,6 +9,8 @@ CHANGELOG * Add `expose_security_errors` config option to display `AccountStatusException` * Deprecate the `security.hide_user_not_found` config option in favor of `security.expose_security_errors` * Add ability to fetch LDAP roles + * Add `OAuth2TokenHandlerFactory` for `AccessTokenFactory` + * Add discovery support to `OidcTokenHandler` and `OidcUserInfoTokenHandler` 7.2 --- diff --git a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php index f3c1cd1fe34af..aa6e8d9a4a8a7 100644 --- a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php +++ b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php @@ -138,6 +138,7 @@ public function collect(Request $request, Response $response, ?\Throwable $excep // collect voter details $decisionLog = $this->accessDecisionManager->getDecisionLog(); + foreach ($decisionLog as $key => $log) { $decisionLog[$key]['voter_details'] = []; foreach ($log['voterDetails'] as $voterDetail) { @@ -147,6 +148,7 @@ public function collect(Request $request, Response $response, ?\Throwable $excep 'class' => $classData, 'attributes' => $voterDetail['attributes'], // Only displayed for unanimous strategy 'vote' => $voterDetail['vote'], + 'reasons' => $voterDetail['reasons'] ?? [], ]; } unset($decisionLog[$key]['voterDetails']); diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php index 9854a1f047a7a..0a2d32c9f3f4d 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php @@ -55,9 +55,14 @@ public function getConfigTreeBuilder(): TreeBuilder $rootNode = $tb->getRootNode(); $rootNode + ->docUrl('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/security.html', 'symfony/security-bundle') ->beforeNormalization() ->always() ->then(function ($v) { + if (isset($v['hide_user_not_found']) && isset($v['expose_security_errors'])) { + throw new InvalidConfigurationException('You cannot use both "hide_user_not_found" and "expose_security_errors" at the same time.'); + } + if (isset($v['hide_user_not_found']) && !isset($v['expose_security_errors'])) { $v['expose_security_errors'] = $v['hide_user_not_found'] ? ExposeSecurityLevel::None : ExposeSecurityLevel::All; } @@ -75,7 +80,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->setDeprecated('symfony/security-bundle', '7.3', 'The "%node%" option is deprecated and will be removed in 8.0. Use the "expose_security_errors" option instead.') ->end() ->enumNode('expose_security_errors') - ->beforeNormalization()->ifString()->then(fn ($v) => ['value' => ExposeSecurityLevel::tryFrom($v)])->end() + ->beforeNormalization()->ifString()->then(fn ($v) => ExposeSecurityLevel::tryFrom($v))->end() ->values(ExposeSecurityLevel::cases()) ->defaultValue(ExposeSecurityLevel::None) ->end() diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/AccessToken/OAuth2TokenHandlerFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/AccessToken/OAuth2TokenHandlerFactory.php new file mode 100644 index 0000000000000..fb2a964358d22 --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/AccessToken/OAuth2TokenHandlerFactory.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\AccessToken; + +use Symfony\Component\Config\Definition\Builder\NodeBuilder; +use Symfony\Component\DependencyInjection\ChildDefinition; +use Symfony\Component\DependencyInjection\ContainerBuilder; + +/** + * Configures a token handler for an OAuth2 Token Introspection endpoint. + * + * @internal + */ +class OAuth2TokenHandlerFactory implements TokenHandlerFactoryInterface +{ + public function create(ContainerBuilder $container, string $id, array|string $config): void + { + $container->setDefinition($id, new ChildDefinition('security.access_token_handler.oauth2')); + } + + public function getKey(): string + { + return 'oauth2'; + } + + public function addConfiguration(NodeBuilder $node): void + { + $node->scalarNode($this->getKey())->end(); + } +} diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/AccessToken/OidcTokenHandlerFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/AccessToken/OidcTokenHandlerFactory.php index 0f5bc2895b6d4..de53d5e89bc26 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/AccessToken/OidcTokenHandlerFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/AccessToken/OidcTokenHandlerFactory.php @@ -17,6 +17,8 @@ use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\LogicException; +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Contracts\HttpClient\HttpClientInterface; /** * Configures a token handler for decoding and validating an OIDC token. @@ -38,9 +40,29 @@ public function create(ContainerBuilder $container, string $id, array|string $co $tokenHandlerDefinition->replaceArgument(0, (new ChildDefinition('security.access_token_handler.oidc.signature')) ->replaceArgument(0, $config['algorithms'])); + if (isset($config['discovery'])) { + if (!ContainerBuilder::willBeAvailable('symfony/http-client', HttpClientInterface::class, ['symfony/security-bundle'])) { + throw new LogicException('You cannot use the "oidc" token handler with "discovery" since the HttpClient component is not installed. Try running "composer require symfony/http-client".'); + } + + // disable JWKSet argument + $tokenHandlerDefinition->replaceArgument(1, null); + $tokenHandlerDefinition->addMethodCall( + 'enableDiscovery', + [ + new Reference($config['discovery']['cache']['id']), + (new ChildDefinition('security.access_token_handler.oidc_discovery.http_client')) + ->replaceArgument(0, ['base_uri' => $config['discovery']['base_uri']]), + "$id.oidc_configuration", + "$id.oidc_jwk_set", + ] + ); + + return; + } + $tokenHandlerDefinition->replaceArgument(1, (new ChildDefinition('security.access_token_handler.oidc.jwkset')) - ->replaceArgument(0, $config['keyset']) - ); + ->replaceArgument(0, $config['keyset'])); if ($config['encryption']['enabled']) { $algorithmManager = (new ChildDefinition('security.access_token_handler.oidc.encryption')) @@ -49,7 +71,7 @@ public function create(ContainerBuilder $container, string $id, array|string $co ->replaceArgument(0, $config['encryption']['keyset']); $tokenHandlerDefinition->addMethodCall( - 'enabledJweSupport', + 'enableJweSupport', [ $keyset, $algorithmManager, @@ -74,8 +96,8 @@ public function addConfiguration(NodeBuilder $node): void ->thenInvalid('You must set either "algorithm" or "algorithms".') ->end() ->validate() - ->ifTrue(static fn ($v) => !isset($v['key']) && !isset($v['keyset'])) - ->thenInvalid('You must set either "key" or "keyset".') + ->ifTrue(static fn ($v) => !isset($v['discovery']) && !isset($v['key']) && !isset($v['keyset'])) + ->thenInvalid('You must set either "discovery" or "key" or "keyset".') ->end() ->beforeNormalization() ->ifTrue(static fn ($v) => isset($v['algorithm']) && \is_string($v['algorithm'])) @@ -101,6 +123,25 @@ public function addConfiguration(NodeBuilder $node): void }) ->end() ->children() + ->arrayNode('discovery') + ->info('Enable the OIDC discovery.') + ->children() + ->scalarNode('base_uri') + ->info('Base URI of the OIDC server.') + ->isRequired() + ->cannotBeEmpty() + ->end() + ->arrayNode('cache') + ->children() + ->scalarNode('id') + ->info('Cache service id to use to cache the OIDC discovery configuration.') + ->isRequired() + ->cannotBeEmpty() + ->end() + ->end() + ->end() + ->end() + ->end() ->scalarNode('claim') ->info('Claim which contains the user identifier (e.g.: sub, email..).') ->defaultValue('sub') @@ -129,7 +170,6 @@ public function addConfiguration(NodeBuilder $node): void ->end() ->scalarNode('keyset') ->info('JSON-encoded JWKSet used to sign the token (must contain a list of valid public keys).') - ->isRequired() ->end() ->arrayNode('encryption') ->canBeEnabled() diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/AccessToken/OidcUserInfoTokenHandlerFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/AccessToken/OidcUserInfoTokenHandlerFactory.php index 3e30acabaf5dd..c6308ff342242 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/AccessToken/OidcUserInfoTokenHandlerFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/AccessToken/OidcUserInfoTokenHandlerFactory.php @@ -16,6 +16,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Reference; +use Symfony\Contracts\Cache\CacheInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; /** @@ -34,9 +35,23 @@ public function create(ContainerBuilder $container, string $id, array|string $co throw new LogicException('You cannot use the "oidc_user_info" token handler since the HttpClient component is not installed. Try running "composer require symfony/http-client".'); } - $container->setDefinition($id, new ChildDefinition('security.access_token_handler.oidc_user_info')) + $tokenHandlerDefinition = $container->setDefinition($id, new ChildDefinition('security.access_token_handler.oidc_user_info')) ->replaceArgument(0, $clientDefinition) ->replaceArgument(2, $config['claim']); + + if (isset($config['discovery'])) { + if (!ContainerBuilder::willBeAvailable('symfony/cache', CacheInterface::class, ['symfony/security-bundle'])) { + throw new LogicException('You cannot use the "oidc_user_info" token handler with "discovery" since the Cache component is not installed. Try running "composer require symfony/cache".'); + } + + $tokenHandlerDefinition->addMethodCall( + 'enableDiscovery', + [ + new Reference($config['discovery']['cache']['id']), + "$id.oidc_configuration", + ] + ); + } } public function getKey(): string @@ -55,10 +70,24 @@ public function addConfiguration(NodeBuilder $node): void ->end() ->children() ->scalarNode('base_uri') - ->info('Base URI of the userinfo endpoint on the OIDC server.') + ->info('Base URI of the userinfo endpoint on the OIDC server, or the OIDC server URI to use the discovery (require "discovery" to be configured).') ->isRequired() ->cannotBeEmpty() ->end() + ->arrayNode('discovery') + ->info('Enable the OIDC discovery.') + ->children() + ->arrayNode('cache') + ->children() + ->scalarNode('id') + ->info('Cache service id to use to cache the OIDC discovery configuration.') + ->isRequired() + ->cannotBeEmpty() + ->end() + ->end() + ->end() + ->end() + ->end() ->scalarNode('claim') ->info('Claim which contains the user identifier (e.g. sub, email, etc.).') ->defaultValue('sub') diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index dd1b8cdb490cc..1711964b3472f 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\SecurityBundle\DependencyInjection; +use Composer\InstalledVersions; use Symfony\Bridge\Twig\Extension\LogoutUrlExtension; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FirewallListenerFactoryInterface; @@ -62,7 +63,6 @@ use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticator; use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticatorManagerListener; use Symfony\Component\Security\Http\Event\CheckPassportEvent; -use Symfony\Flex\Command\InstallRecipesCommand; /** * SecurityExtension. @@ -93,7 +93,7 @@ public function prepend(ContainerBuilder $container): void public function load(array $configs, ContainerBuilder $container): void { if (!array_filter($configs)) { - $hint = class_exists(InstallRecipesCommand::class) ? 'Try running "composer symfony:recipes:install symfony/security-bundle".' : 'Please define your settings for the "security" config section.'; + $hint = class_exists(InstalledVersions::class) && InstalledVersions::isInstalled('symfony/flex') ? 'Try running "composer symfony:recipes:install symfony/security-bundle".' : 'Please define your settings for the "security" config section.'; throw new InvalidConfigurationException('The SecurityBundle is enabled but is not configured. '.$hint); } @@ -321,7 +321,7 @@ private function createFirewalls(array $config, ContainerBuilder $container): vo $authenticators[$name] = ServiceLocatorTagPass::register($container, $firewallAuthenticatorRefs); } $contextId = 'security.firewall.map.context.'.$name; - $isLazy = !$firewall['stateless'] && (!empty($firewall['anonymous']['lazy']) || $firewall['lazy']); + $isLazy = !$firewall['stateless'] && $firewall['lazy']; $context = new ChildDefinition($isLazy ? 'security.firewall.lazy_context' : 'security.firewall.context'); $context = $container->setDefinition($contextId, $context); $context @@ -683,7 +683,7 @@ private function getUserProvider(ContainerBuilder $container, string $id, array return $this->createMissingUserProvider($container, $id, $factoryKey); } - if ('remember_me' === $factoryKey || 'anonymous' === $factoryKey) { + if ('remember_me' === $factoryKey) { return 'security.user_providers'; } diff --git a/src/Symfony/Bundle/SecurityBundle/EventListener/VoteListener.php b/src/Symfony/Bundle/SecurityBundle/EventListener/VoteListener.php index 54eac4384542a..31e7efb83c35d 100644 --- a/src/Symfony/Bundle/SecurityBundle/EventListener/VoteListener.php +++ b/src/Symfony/Bundle/SecurityBundle/EventListener/VoteListener.php @@ -31,7 +31,7 @@ public function __construct( public function onVoterVote(VoteEvent $event): void { - $this->traceableAccessDecisionManager->addVoterVote($event->getVoter(), $event->getAttributes(), $event->getVote()); + $this->traceableAccessDecisionManager->addVoterVote($event->getVoter(), $event->getAttributes(), $event->getVote(), $event->getReasons()); } public static function getSubscribedEvents(): array diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security.php b/src/Symfony/Bundle/SecurityBundle/Resources/config/security.php index bd879973b49a3..7b08ebe5fa35d 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security.php +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security.php @@ -31,9 +31,9 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationChecker; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Authorization\ExpressionLanguage; -use Symfony\Component\Security\Core\Authorization\UserAuthorizationChecker; use Symfony\Component\Security\Core\Authorization\UserAuthorizationCheckerInterface; use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter; +use Symfony\Component\Security\Core\Authorization\Voter\ClosureVoter; use Symfony\Component\Security\Core\Authorization\Voter\ExpressionVoter; use Symfony\Component\Security\Core\Authorization\Voter\RoleHierarchyVoter; use Symfony\Component\Security\Core\Authorization\Voter\RoleVoter; @@ -68,12 +68,7 @@ service('security.access.decision_manager'), ]) ->alias(AuthorizationCheckerInterface::class, 'security.authorization_checker') - - ->set('security.user_authorization_checker', UserAuthorizationChecker::class) - ->args([ - service('security.access.decision_manager'), - ]) - ->alias(UserAuthorizationCheckerInterface::class, 'security.user_authorization_checker') + ->alias(UserAuthorizationCheckerInterface::class, 'security.authorization_checker') ->set('security.token_storage', UsageTrackingTokenStorage::class) ->args([ @@ -93,7 +88,7 @@ service_locator([ 'security.token_storage' => service('security.token_storage'), 'security.authorization_checker' => service('security.authorization_checker'), - 'security.user_authorization_checker' => service('security.user_authorization_checker'), + 'security.user_authorization_checker' => service('security.authorization_checker'), 'security.authenticator.managers_locator' => service('security.authenticator.managers_locator')->ignoreOnInvalid(), 'request_stack' => service('request_stack'), 'security.firewall.map' => service('security.firewall.map'), @@ -171,6 +166,12 @@ ]) ->tag('security.voter', ['priority' => 245]) + ->set('security.access.closure_voter', ClosureVoter::class) + ->args([ + service('security.authorization_checker'), + ]) + ->tag('security.voter', ['priority' => 245]) + ->set('security.impersonate_url_generator', ImpersonateUrlGenerator::class) ->args([ service('request_stack'), diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_authenticator_access_token.php b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_authenticator_access_token.php index d3d6f60850ffe..9099bad41c385 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_authenticator_access_token.php +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_authenticator_access_token.php @@ -36,6 +36,7 @@ use Symfony\Component\Security\Http\AccessToken\ChainAccessTokenExtractor; use Symfony\Component\Security\Http\AccessToken\FormEncodedBodyExtractor; use Symfony\Component\Security\Http\AccessToken\HeaderAccessTokenExtractor; +use Symfony\Component\Security\Http\AccessToken\OAuth2\Oauth2TokenHandler; use Symfony\Component\Security\Http\AccessToken\Oidc\OidcTokenHandler; use Symfony\Component\Security\Http\AccessToken\Oidc\OidcUserInfoTokenHandler; use Symfony\Component\Security\Http\AccessToken\QueryAccessTokenExtractor; @@ -91,6 +92,11 @@ service('clock'), ]) + ->set('security.access_token_handler.oidc_discovery.http_client', HttpClientInterface::class) + ->abstract() + ->factory([service('http_client'), 'withOptions']) + ->args([abstract_arg('http client options')]) + ->set('security.access_token_handler.oidc.jwk', JWK::class) ->abstract() ->deprecate('symfony/security-http', '7.1', 'The "%service_id%" service is deprecated. Please use "security.access_token_handler.oidc.jwkset" instead') @@ -186,5 +192,13 @@ ->set('security.access_token_handler.oidc.encryption.A256GCM', A256GCM::class) ->tag('security.access_token_handler.oidc.encryption_algorithm') + + // OAuth2 Introspection (RFC 7662) + ->set('security.access_token_handler.oauth2', Oauth2TokenHandler::class) + ->abstract() + ->args([ + service('http_client'), + service('logger')->nullOnInvalid(), + ]) ; }; diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_debug.php b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_debug.php index c98e3a6984672..76b4e31b1b5a8 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_debug.php +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_debug.php @@ -22,6 +22,7 @@ ->args([ service('debug.security.access.decision_manager.inner'), ]) + ->tag('kernel.reset', ['method' => 'reset', 'on_invalid' => 'ignore']) ->set('debug.security.voter.vote_listener', VoteListener::class) ->args([ diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_twig.php b/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_twig.php index 96a7a2833a443..05a74d086e820 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_twig.php +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_twig.php @@ -26,7 +26,6 @@ ->args([ service('security.authorization_checker')->ignoreOnInvalid(), service('security.impersonate_url_generator')->ignoreOnInvalid(), - service('security.user_authorization_checker')->ignoreOnInvalid(), ]) ->tag('twig.extension') ; diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig index 635d61e2dd2c8..f2706858e45cf 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig +++ b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig @@ -571,14 +571,19 @@ {% endif %} {% if voter_detail['vote'] == constant('Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface::ACCESS_GRANTED') %} - ACCESS GRANTED + GRANTED {% elseif voter_detail['vote'] == constant('Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface::ACCESS_ABSTAIN') %} - ACCESS ABSTAIN + ABSTAIN {% elseif voter_detail['vote'] == constant('Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface::ACCESS_DENIED') %} - ACCESS DENIED + DENIED {% else %} unknown ({{ voter_detail['vote'] }}) {% endif %} + {% if voter_detail['reasons'] is not empty %} + {% for voter_reason in voter_detail['reasons'] %} +
{{ voter_reason }} + {% endfor %} + {% endif %} {% endfor %} diff --git a/src/Symfony/Bundle/SecurityBundle/Security.php b/src/Symfony/Bundle/SecurityBundle/Security.php index 0cb23c7601b0b..2efbb67fc3de0 100644 --- a/src/Symfony/Bundle/SecurityBundle/Security.php +++ b/src/Symfony/Bundle/SecurityBundle/Security.php @@ -17,6 +17,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Authorization\AccessDecision; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Authorization\UserAuthorizationCheckerInterface; use Symfony\Component\Security\Core\Exception\LogicException; @@ -58,10 +59,21 @@ public function getUser(): ?UserInterface /** * Checks if the attributes are granted against the current authentication token and optionally supplied subject. */ - public function isGranted(mixed $attributes, mixed $subject = null): bool + public function isGranted(mixed $attributes, mixed $subject = null, ?AccessDecision $accessDecision = null): bool { return $this->container->get('security.authorization_checker') - ->isGranted($attributes, $subject); + ->isGranted($attributes, $subject, $accessDecision); + } + + /** + * Checks if the attribute is granted against the user and optionally supplied subject. + * + * This should be used over isGranted() when checking permissions against a user that is not currently logged in or while in a CLI context. + */ + public function isGrantedForUser(UserInterface $user, mixed $attribute, mixed $subject = null, ?AccessDecision $accessDecision = null): bool + { + return $this->container->get('security.user_authorization_checker') + ->isGrantedForUser($user, $attribute, $subject, $accessDecision); } public function getToken(): ?TokenInterface @@ -149,17 +161,6 @@ public function logout(bool $validateCsrfToken = true): ?Response return $logoutEvent->getResponse(); } - /** - * Checks if the attribute is granted against the user and optionally supplied subject. - * - * This should be used over isGranted() when checking permissions against a user that is not currently logged in or while in a CLI context. - */ - public function isGrantedForUser(UserInterface $user, mixed $attribute, mixed $subject = null): bool - { - return $this->container->get('security.user_authorization_checker') - ->isGrantedForUser($user, $attribute, $subject); - } - private function getAuthenticator(?string $authenticatorName, string $firewallName): AuthenticatorInterface { if (!isset($this->authenticators[$firewallName])) { @@ -170,8 +171,7 @@ private function getAuthenticator(?string $authenticatorName, string $firewallNa $firewallAuthenticatorLocator = $this->authenticators[$firewallName]; if (!$authenticatorName) { - $authenticatorIds = array_keys($firewallAuthenticatorLocator->getProvidedServices()); - + $authenticatorIds = array_filter(array_keys($firewallAuthenticatorLocator->getProvidedServices()), fn (string $authenticatorId) => $authenticatorId !== \sprintf('security.authenticator.remember_me.%s', $firewallName)); if (!$authenticatorIds) { throw new LogicException(\sprintf('No authenticator was found for the firewall "%s".', $firewallName)); } diff --git a/src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php b/src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php index 63648bd67510e..7263f4247959b 100644 --- a/src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php +++ b/src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php @@ -12,6 +12,7 @@ namespace Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Security\Http\Firewall\ExceptionListener; +use Symfony\Component\Security\Http\Firewall\FirewallListenerInterface; use Symfony\Component\Security\Http\Firewall\LogoutListener; /** @@ -23,7 +24,7 @@ class FirewallContext { /** - * @param iterable $listeners + * @param iterable $listeners */ public function __construct( private iterable $listeners, @@ -39,7 +40,7 @@ public function getConfig(): ?FirewallConfig } /** - * @return iterable + * @return iterable */ public function getListeners(): iterable { diff --git a/src/Symfony/Bundle/SecurityBundle/SecurityBundle.php b/src/Symfony/Bundle/SecurityBundle/SecurityBundle.php index 3247ff1276ffa..1433b5c90e001 100644 --- a/src/Symfony/Bundle/SecurityBundle/SecurityBundle.php +++ b/src/Symfony/Bundle/SecurityBundle/SecurityBundle.php @@ -24,6 +24,7 @@ use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\ReplaceDecoratedRememberMeHandlerPass; use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\SortFirewallListenersPass; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\AccessToken\CasTokenHandlerFactory; +use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\AccessToken\OAuth2TokenHandlerFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\AccessToken\OidcTokenHandlerFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\AccessToken\OidcUserInfoTokenHandlerFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\AccessToken\ServiceTokenHandlerFactory; @@ -80,6 +81,7 @@ public function build(ContainerBuilder $container): void new OidcUserInfoTokenHandlerFactory(), new OidcTokenHandlerFactory(), new CasTokenHandlerFactory(), + new OAuth2TokenHandlerFactory(), ])); $extension->addUserProviderFactory(new InMemoryFactory()); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Command/DebugFirewallCommandTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Command/DebugFirewallCommandTest.php new file mode 100644 index 0000000000000..673f0c434a4bc --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Command/DebugFirewallCommandTest.php @@ -0,0 +1,197 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\SecurityBundle\Tests\Command; + +use PHPUnit\Framework\TestCase; +use Symfony\Bundle\SecurityBundle\Command\DebugFirewallCommand; +use Symfony\Bundle\SecurityBundle\Security\FirewallConfig; +use Symfony\Bundle\SecurityBundle\Security\FirewallContext; +use Symfony\Bundle\SecurityBundle\Tests\Fixtures\DummyAuthenticator; +use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface; + +class DebugFirewallCommandTest extends TestCase +{ + public function testFirewallListOutputMatchesFixture() + { + $firewallNames = ['main', 'api']; + $contexts = $this->createMock(ContainerInterface::class); + $eventDispatchers = $this->createMock(ContainerInterface::class); + + $command = new DebugFirewallCommand($firewallNames, $contexts, $eventDispatchers, []); + $tester = new CommandTester($command); + + $this->assertSame(0, $tester->execute([])); + $this->assertStringContainsString('Firewalls', $tester->getDisplay()); + $this->assertStringContainsString('The following firewalls are defined:', $tester->getDisplay()); + $this->assertStringContainsString('* main', $tester->getDisplay()); + $this->assertStringContainsString('* api', $tester->getDisplay()); + $this->assertStringContainsString('To view details of a specific firewall', $tester->getDisplay()); + } + + public function testFirewallNotFoundDisplaysError() + { + $firewallNames = ['main', 'api']; + + $contexts = $this->createMock(ContainerInterface::class); + $contexts->method('has')->willReturn(false); + + $eventDispatchers = $this->createMock(ContainerInterface::class); + $authenticators = []; + + $command = new DebugFirewallCommand( + $firewallNames, + $contexts, + $eventDispatchers, + $authenticators + ); + + $tester = new CommandTester($command); + + $this->assertSame(1, $tester->execute(['name' => 'admin'])); + $this->assertStringContainsString('Firewall admin was not found.', $tester->getDisplay()); + $this->assertStringContainsString('Available firewalls are: main, api', $tester->getDisplay()); + } + + public function testFirewallMainOutputMatchesFixture() + { + $firewallNames = ['main']; + + $config = new FirewallConfig( + name: 'main', + userChecker: 'user_checker_service', + requestMatcher: null, + securityEnabled: true, + stateless: false, + provider: 'user_provider_service', + context: 'main', + entryPoint: 'entry_point_service', + accessDeniedHandler: 'access_denied_handler_service', + accessDeniedUrl: '/access-denied', + authenticators: [], + switchUser: null + ); + + $context = new FirewallContext([], config: $config); + + $contexts = $this->createMock(ContainerInterface::class); + $contexts->method('has')->willReturn(true); + $contexts->method('get')->willReturn($context); + + $eventDispatchers = $this->createMock(ContainerInterface::class); + $authenticator = new DummyAuthenticator(); + $authenticators = ['main' => [$authenticator]]; + + $command = new DebugFirewallCommand($firewallNames, $contexts, $eventDispatchers, $authenticators); + $tester = new CommandTester($command); + + $this->assertSame(0, $tester->execute(['name' => 'main', '--events' => true])); + $this->assertEquals($this->getFixtureOutput('firewall_main_output.txt'), trim(str_replace(\PHP_EOL, "\n", $tester->getDisplay()))); + } + + public function testFirewallWithEventsOutputMatchesFixture() + { + $firewallNames = ['main']; + + $config = new FirewallConfig( + name: 'main', + userChecker: 'user_checker_service', + context: 'main', + stateless: false, + provider: 'user_provider_service', + entryPoint: 'entry_point_service', + accessDeniedHandler: 'access_denied_handler_service', + accessDeniedUrl: '/access-denied', + ); + + $context = new FirewallContext([], config: $config); + + $contexts = $this->createMock(ContainerInterface::class); + $contexts->method('has')->willReturn(true); + $contexts->method('get')->willReturn($context); + + $dispatcher = $this->createMock(EventDispatcherInterface::class); + $listener = fn () => null; + $listenerTwo = fn (int $number) => $number * 2; + $dispatcher->method('getListeners')->willReturn([ + 'security.event' => [$listener, $listenerTwo], + ]); + $dispatcher->method('getListenerPriority')->willReturn(42); + + $eventDispatchers = $this->createMock(ContainerInterface::class); + $eventDispatchers->method('has')->willReturn(true); + $eventDispatchers->method('get')->willReturn($dispatcher); + + $authenticator = new DummyAuthenticator(); + $authenticatorTwo = new DummyAuthenticator(); + $authenticatorThree = new DummyAuthenticator(); + $authenticators = ['main' => [$authenticator, $authenticatorTwo], 'api' => [$authenticatorThree]]; + + $command = new DebugFirewallCommand($firewallNames, $contexts, $eventDispatchers, $authenticators); + $tester = new CommandTester($command); + + $this->assertSame(0, $tester->execute(['name' => 'main', '--events' => true])); + $this->assertEquals($this->getFixtureOutput('firewall_main_with_events_output.txt'), trim(str_replace(\PHP_EOL, "\n", $tester->getDisplay()))); + } + + public function testFirewallWithSwitchUserDisplaysSection() + { + $firewallNames = ['main']; + + $switchUserConfig = [ + 'parameter' => '_switch_user_test', + 'provider' => 'custom_provider_test', + 'role' => 'ROLE_ALLOWED_TO_SWITCH', + ]; + + $config = new FirewallConfig( + name: 'main', + userChecker: 'user_checker_service_test', + context: 'main', + stateless: false, + provider: 'user_provider_service_test', + entryPoint: 'entry_point_service_test', + accessDeniedHandler: 'access_denied_handler_service_test', + accessDeniedUrl: '/access-denied-test', + switchUser: $switchUserConfig, + ); + + $context = new FirewallContext([], config: $config); + + $contexts = $this->createMock(ContainerInterface::class); + $contexts->method('has')->willReturn(true); + $contexts->method('get')->willReturn($context); + + $eventDispatchers = $this->createMock(ContainerInterface::class); + $authenticator = new DummyAuthenticator(); + $authenticatorTwo = $this->createMock(AuthenticatorInterface::class); + $authenticators = ['main' => [$authenticator], 'api' => [$authenticatorTwo]]; + + $command = new DebugFirewallCommand( + $firewallNames, + $contexts, + $eventDispatchers, + $authenticators + ); + $tester = new CommandTester($command); + + $this->assertSame(0, $tester->execute(['name' => 'main'])); + $this->assertEquals($this->getFixtureOutput('firewall_main_with_switch_user.txt'), trim(str_replace(\PHP_EOL, "\n", $tester->getDisplay()))); + } + + private function getFixtureOutput(string $file): string + { + return trim(file_get_contents(__DIR__.'/../Fixtures/Descriptor/'.$file)); + } +} diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php index 21161d281eb92..5528c9b7a8fc7 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php @@ -28,6 +28,7 @@ use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager; use Symfony\Component\Security\Core\Authorization\Voter\TraceableVoter; +use Symfony\Component\Security\Core\Authorization\Voter\Vote; use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; use Symfony\Component\Security\Core\Role\RoleHierarchy; use Symfony\Component\Security\Core\User\InMemoryUser; @@ -53,7 +54,7 @@ public function testCollectWhenSecurityIsDisabled() $this->assertFalse($collector->supportsRoleHierarchy()); $this->assertCount(0, $collector->getRoles()); $this->assertCount(0, $collector->getInheritedRoles()); - $this->assertEmpty($collector->getUser()); + $this->assertSame('', $collector->getUser()); $this->assertNull($collector->getFirewall()); } @@ -72,7 +73,7 @@ public function testCollectWhenAuthenticationTokenIsNull() $this->assertTrue($collector->supportsRoleHierarchy()); $this->assertCount(0, $collector->getRoles()); $this->assertCount(0, $collector->getInheritedRoles()); - $this->assertEmpty($collector->getUser()); + $this->assertSame('', $collector->getUser()); $this->assertNull($collector->getFirewall()); } @@ -271,8 +272,8 @@ public function dispatch(object $event, ?string $eventName = null): object 'object' => new \stdClass(), 'result' => true, 'voter_details' => [ - ['class' => $voter1::class, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN], - ['class' => $voter2::class, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN], + ['class' => $voter1::class, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN, 'reasons' => []], + ['class' => $voter2::class, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN, 'reasons' => []], ], ]]; @@ -360,10 +361,10 @@ public function dispatch(object $event, ?string $eventName = null): object 'object' => new \stdClass(), 'result' => false, 'voter_details' => [ - ['class' => $voter1::class, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_DENIED], - ['class' => $voter1::class, 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_DENIED], - ['class' => $voter2::class, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_GRANTED], - ['class' => $voter2::class, 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_GRANTED], + ['class' => $voter1::class, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_DENIED, 'reasons' => []], + ['class' => $voter1::class, 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_DENIED, 'reasons' => []], + ['class' => $voter2::class, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_GRANTED, 'reasons' => []], + ['class' => $voter2::class, 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_GRANTED, 'reasons' => []], ], ], [ @@ -371,8 +372,8 @@ public function dispatch(object $event, ?string $eventName = null): object 'object' => new \stdClass(), 'result' => true, 'voter_details' => [ - ['class' => $voter1::class, 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED], - ['class' => $voter2::class, 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED], + ['class' => $voter1::class, 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED, 'reasons' => []], + ['class' => $voter2::class, 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED, 'reasons' => []], ], ], ]; @@ -424,7 +425,7 @@ public function testGetVotersIfAccessDecisionManagerHasNoVoters() $dataCollector->collect(new Request(), new Response()); - $this->assertEmpty($dataCollector->getVoters()); + $this->assertSame([], $dataCollector->getVoters()); } public static function provideRoles(): array @@ -461,7 +462,7 @@ private function getRoleHierarchy() final class DummyVoter implements VoterInterface { - public function vote(TokenInterface $token, mixed $subject, array $attributes): int + public function vote(TokenInterface $token, mixed $subject, array $attributes, ?Vote $vote = null): int { } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php index 6479e56a668e7..6904a21b18113 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php @@ -254,6 +254,9 @@ public static function provideHideUserNotFoundData(): iterable yield [['expose_security_errors' => ExposeSecurityLevel::None], ExposeSecurityLevel::None]; yield [['expose_security_errors' => ExposeSecurityLevel::AccountStatus], ExposeSecurityLevel::AccountStatus]; yield [['expose_security_errors' => ExposeSecurityLevel::All], ExposeSecurityLevel::All]; + yield [['expose_security_errors' => 'none'], ExposeSecurityLevel::None]; + yield [['expose_security_errors' => 'account_status'], ExposeSecurityLevel::AccountStatus]; + yield [['expose_security_errors' => 'all'], ExposeSecurityLevel::All]; } /** @@ -280,4 +283,18 @@ public static function provideHideUserNotFoundLegacyData(): iterable yield [['hide_user_not_found' => true], ExposeSecurityLevel::None, true]; yield [['hide_user_not_found' => false], ExposeSecurityLevel::All, false]; } + + public function testCannotUseHideUserNotFoundAndExposeSecurityErrorsAtTheSameTime() + { + $processor = new Processor(); + $configuration = new MainConfiguration([], []); + + $this->expectException(InvalidConfigurationException::class); + $this->expectExceptionMessage('You cannot use both "hide_user_not_found" and "expose_security_errors" at the same time.'); + + $processor->processConfiguration($configuration, [static::$minimalConfig + [ + 'hide_user_not_found' => true, + 'expose_security_errors' => ExposeSecurityLevel::None, + ]]); + } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AccessTokenFactoryTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AccessTokenFactoryTest.php index 2d59f0ae31496..88b782363dbf9 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AccessTokenFactoryTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AccessTokenFactoryTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\AccessToken\CasTokenHandlerFactory; +use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\AccessToken\OAuth2TokenHandlerFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\AccessToken\OidcTokenHandlerFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\AccessToken\OidcUserInfoTokenHandlerFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\AccessToken\ServiceTokenHandlerFactory; @@ -113,7 +114,7 @@ public function testInvalidOidcTokenHandlerConfigurationKeyMissing() $factory = new AccessTokenFactory($this->createTokenHandlerFactories()); $this->expectException(InvalidConfigurationException::class); - $this->expectExceptionMessage('The child config "keyset" under "access_token.token_handler.oidc" must be configured: JSON-encoded JWKSet used to sign the token (must contain a list of valid public keys).'); + $this->expectExceptionMessage('You must set either "discovery" or "key" or "keyset".'); $this->processConfig($config, $factory); } @@ -339,6 +340,58 @@ public function testInvalidOidcTokenHandlerConfigurationMissingAlgorithm() $this->processConfig($config, $factory); } + public function testOidcTokenHandlerConfigurationWithDiscovery() + { + $container = new ContainerBuilder(); + $jwkset = '{"keys":[{"kty":"EC","crv":"P-256","x":"FtgMtrsKDboRO-Zo0XC7tDJTATHVmwuf9GK409kkars","y":"rWDE0ERU2SfwGYCo1DWWdgFEbZ0MiAXLRBBOzBgs_jY","d":"4G7bRIiKih0qrFxc0dtvkHUll19tTyctoCR3eIbOrO0"},{"kty":"EC","crv":"P-256","x":"0QEAsI1wGI-dmYatdUZoWSRWggLEpyzopuhwk-YUnA4","y":"KYl-qyZ26HobuYwlQh-r0iHX61thfP82qqEku7i0woo","d":"iA_TV2zvftni_9aFAQwFO_9aypfJFCSpcCyevDvz220"}]}'; + $config = [ + 'token_handler' => [ + 'oidc' => [ + 'discovery' => [ + 'base_uri' => 'https://www.example.com/realms/demo/', + 'cache' => [ + 'id' => 'oidc_cache', + ], + ], + 'algorithms' => ['RS256', 'ES256'], + 'issuers' => ['https://www.example.com'], + 'audience' => 'audience', + ], + ], + ]; + + $factory = new AccessTokenFactory($this->createTokenHandlerFactories()); + $finalizedConfig = $this->processConfig($config, $factory); + + $factory->createAuthenticator($container, 'firewall1', $finalizedConfig, 'userprovider'); + + $this->assertTrue($container->hasDefinition('security.authenticator.access_token.firewall1')); + $this->assertTrue($container->hasDefinition('security.access_token_handler.firewall1')); + + $expectedArgs = [ + 'index_0' => (new ChildDefinition('security.access_token_handler.oidc.signature')) + ->replaceArgument(0, ['RS256', 'ES256']), + 'index_1' => null, + 'index_2' => 'audience', + 'index_3' => ['https://www.example.com'], + 'index_4' => 'sub', + ]; + $expectedCalls = [ + [ + 'enableDiscovery', + [ + new Reference('oidc_cache'), + (new ChildDefinition('security.access_token_handler.oidc_discovery.http_client')) + ->replaceArgument(0, ['base_uri' => 'https://www.example.com/realms/demo/']), + 'security.access_token_handler.firewall1.oidc_configuration', + 'security.access_token_handler.firewall1.oidc_jwk_set', + ], + ], + ]; + $this->assertEquals($expectedArgs, $container->getDefinition('security.access_token_handler.firewall1')->getArguments()); + $this->assertEquals($expectedCalls, $container->getDefinition('security.access_token_handler.firewall1')->getMethodCalls()); + } + public function testOidcUserInfoTokenHandlerConfigurationWithExistingClient() { $container = new ContainerBuilder(); @@ -406,6 +459,48 @@ public static function getOidcUserInfoConfiguration(): iterable yield ['https://www.example.com/realms/demo/protocol/openid-connect/userinfo']; } + public function testOidcUserInfoTokenHandlerConfigurationWithDiscovery() + { + $container = new ContainerBuilder(); + $config = [ + 'token_handler' => [ + 'oidc_user_info' => [ + 'discovery' => [ + 'cache' => [ + 'id' => 'oidc_cache', + ], + ], + 'base_uri' => 'https://www.example.com/realms/demo/protocol/openid-connect/userinfo', + ], + ], + ]; + + $factory = new AccessTokenFactory($this->createTokenHandlerFactories()); + $finalizedConfig = $this->processConfig($config, $factory); + + $factory->createAuthenticator($container, 'firewall1', $finalizedConfig, 'userprovider'); + + $this->assertTrue($container->hasDefinition('security.authenticator.access_token.firewall1')); + $this->assertTrue($container->hasDefinition('security.access_token_handler.firewall1')); + + $expectedArgs = [ + 'index_0' => (new ChildDefinition('security.access_token_handler.oidc_user_info.http_client')) + ->replaceArgument(0, ['base_uri' => 'https://www.example.com/realms/demo/protocol/openid-connect/userinfo']), + 'index_2' => 'sub', + ]; + $expectedCalls = [ + [ + 'enableDiscovery', + [ + new Reference('oidc_cache'), + 'security.access_token_handler.firewall1.oidc_configuration', + ], + ], + ]; + $this->assertEquals($expectedArgs, $container->getDefinition('security.access_token_handler.firewall1')->getArguments()); + $this->assertEquals($expectedCalls, $container->getDefinition('security.access_token_handler.firewall1')->getMethodCalls()); + } + public function testMultipleTokenHandlersSet() { $config = [ @@ -423,6 +518,22 @@ public function testMultipleTokenHandlersSet() $this->processConfig($config, $factory); } + public function testOAuth2TokenHandlerConfiguration() + { + $container = new ContainerBuilder(); + $config = [ + 'token_handler' => ['oauth2' => true], + ]; + + $factory = new AccessTokenFactory($this->createTokenHandlerFactories()); + $finalizedConfig = $this->processConfig($config, $factory); + + $factory->createAuthenticator($container, 'firewall1', $finalizedConfig, 'userprovider'); + + $this->assertTrue($container->hasDefinition('security.authenticator.access_token.firewall1')); + $this->assertTrue($container->hasDefinition('security.access_token_handler.firewall1')); + } + public function testNoTokenHandlerSet() { $this->expectException(InvalidConfigurationException::class); @@ -482,6 +593,7 @@ private function createTokenHandlerFactories(): array new OidcUserInfoTokenHandlerFactory(), new OidcTokenHandlerFactory(), new CasTokenHandlerFactory(), + new OAuth2TokenHandlerFactory(), ]; } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php index d0f3549ab8f09..8607e45a262e2 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php @@ -986,7 +986,7 @@ public function checkPreAuth(UserInterface $user): void { } - public function checkPostAuth(UserInterface $user): void + public function checkPostAuth(UserInterface $user, ?TokenInterface $token = null): void { } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Fixtures/Descriptor/firewall_main_output.txt b/src/Symfony/Bundle/SecurityBundle/Tests/Fixtures/Descriptor/firewall_main_output.txt new file mode 100644 index 0000000000000..d224162575d45 --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Fixtures/Descriptor/firewall_main_output.txt @@ -0,0 +1,30 @@ +Firewall "main" +=============== + + ----------------------- ------------------------------- + Option Value + ----------------------- ------------------------------- + Name main + Context main + Lazy No + Stateless No + User Checker user_checker_service + Provider user_provider_service + Entry Point entry_point_service + Access Denied URL /access-denied + Access Denied Handler access_denied_handler_service + ----------------------- ------------------------------- + +Event listeners for firewall "main" +=================================== + + No event dispatcher has been registered for this firewall. + +Authenticators for firewall "main" +================================== + + ----------------------------------------------------------------- + Classname + ----------------------------------------------------------------- + Symfony\Bundle\SecurityBundle\Tests\Fixtures\DummyAuthenticator + ----------------------------------------------------------------- diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Fixtures/Descriptor/firewall_main_with_events_output.txt b/src/Symfony/Bundle/SecurityBundle/Tests/Fixtures/Descriptor/firewall_main_with_events_output.txt new file mode 100644 index 0000000000000..2d02f34b8a017 --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Fixtures/Descriptor/firewall_main_with_events_output.txt @@ -0,0 +1,39 @@ +Firewall "main" +=============== + + ----------------------- ------------------------------- + Option Value + ----------------------- ------------------------------- + Name main + Context main + Lazy No + Stateless No + User Checker user_checker_service + Provider user_provider_service + Entry Point entry_point_service + Access Denied URL /access-denied + Access Denied Handler access_denied_handler_service + ----------------------- ------------------------------- + +Event listeners for firewall "main" +=================================== + +"security.event" event +---------------------- + + ------- ----------- ---------- + Order Callable Priority + ------- ----------- ---------- + #1 Closure() 42 + #2 Closure() 42 + ------- ----------- ---------- + +Authenticators for firewall "main" +================================== + + ----------------------------------------------------------------- + Classname + ----------------------------------------------------------------- + Symfony\Bundle\SecurityBundle\Tests\Fixtures\DummyAuthenticator + Symfony\Bundle\SecurityBundle\Tests\Fixtures\DummyAuthenticator + ----------------------------------------------------------------- diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Fixtures/Descriptor/firewall_main_with_switch_user.txt b/src/Symfony/Bundle/SecurityBundle/Tests/Fixtures/Descriptor/firewall_main_with_switch_user.txt new file mode 100644 index 0000000000000..4843b86f7e224 --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Fixtures/Descriptor/firewall_main_with_switch_user.txt @@ -0,0 +1,36 @@ +Firewall "main" +=============== + + ----------------------- ------------------------------------ + Option Value + ----------------------- ------------------------------------ + Name main + Context main + Lazy No + Stateless No + User Checker user_checker_service_test + Provider user_provider_service_test + Entry Point entry_point_service_test + Access Denied URL /access-denied-test + Access Denied Handler access_denied_handler_service_test + ----------------------- ------------------------------------ + +User switching +-------------- + + ----------- ------------------------ + Option Value + ----------- ------------------------ + Parameter _switch_user_test + Provider custom_provider_test + User Role ROLE_ALLOWED_TO_SWITCH + ----------- ------------------------ + +Authenticators for firewall "main" +================================== + + ----------------------------------------------------------------- + Classname + ----------------------------------------------------------------- + Symfony\Bundle\SecurityBundle\Tests\Fixtures\DummyAuthenticator + ----------------------------------------------------------------- diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Fixtures/DummyAuthenticator.php b/src/Symfony/Bundle/SecurityBundle/Tests/Fixtures/DummyAuthenticator.php new file mode 100644 index 0000000000000..8ac51a1e9df56 --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Fixtures/DummyAuthenticator.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\SecurityBundle\Tests\Fixtures; + +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Exception\AuthenticationException; +use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface; +use Symfony\Component\Security\Http\Authenticator\Passport\Passport; +use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface; + +class DummyAuthenticator implements AuthenticatorInterface +{ + public function supports(Request $request): ?bool + { + return null; + } + + public function authenticate(Request $request): Passport + { + } + + public function createToken(Passport $passport, string $firewallName): TokenInterface + { + } + + public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response + { + return null; + } + + public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response + { + return null; + } + + public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface + { + } +} diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AccessTokenTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AccessTokenTest.php index 0be67a56f55c9..75adf296110da 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AccessTokenTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AccessTokenTest.php @@ -353,9 +353,17 @@ public function testCustomUserLoader() /** * @dataProvider validAccessTokens + * + * @requires extension openssl */ - public function testOidcSuccess(string $token) + public function testOidcSuccess(callable $tokenFactory) { + try { + $token = $tokenFactory(); + } catch (\RuntimeException $e) { + $this->markTestSkipped($e->getMessage()); + } + $client = $this->createClient(['test_case' => 'AccessToken', 'root_config' => 'config_oidc.yml']); $client->request('GET', '/foo', [], [], ['HTTP_AUTHORIZATION' => \sprintf('Bearer %s', $token)]); $response = $client->getResponse(); @@ -367,9 +375,17 @@ public function testOidcSuccess(string $token) /** * @dataProvider invalidAccessTokens + * + * @requires extension openssl */ - public function testOidcFailure(string $token) + public function testOidcFailure(callable $tokenFactory) { + try { + $token = $tokenFactory(); + } catch (\RuntimeException $e) { + $this->markTestSkipped($e->getMessage()); + } + $client = $this->createClient(['test_case' => 'AccessToken', 'root_config' => 'config_oidc.yml']); $client->request('GET', '/foo', [], [], ['HTTP_AUTHORIZATION' => \sprintf('Bearer %s', $token)]); $response = $client->getResponse(); @@ -440,12 +456,10 @@ public static function validAccessTokens(): array 'sub' => 'e21bf182-1538-406e-8ccb-e25a17aba39f', 'username' => 'dunglas', ]; - $jws = self::createJws($claims); - $jwe = self::createJwe($jws); return [ - [$jws], - [$jwe], + [fn () => self::createJws($claims)], + [fn () => self::createJwe(self::createJws($claims))], ]; } @@ -466,14 +480,14 @@ public static function invalidAccessTokens(): array ]; return [ - [self::createJws([...$claims, 'aud' => 'Invalid Audience'])], - [self::createJws([...$claims, 'iss' => 'Invalid Issuer'])], - [self::createJws([...$claims, 'exp' => $time - 3600])], - [self::createJws([...$claims, 'nbf' => $time + 3600])], - [self::createJws([...$claims, 'iat' => $time + 3600])], - [self::createJws([...$claims, 'username' => 'Invalid Username'])], - [self::createJwe(self::createJws($claims), ['exp' => $time - 3600])], - [self::createJwe(self::createJws($claims), ['cty' => 'x-specific'])], + [fn () => self::createJws([...$claims, 'aud' => 'Invalid Audience'])], + [fn () => self::createJws([...$claims, 'iss' => 'Invalid Issuer'])], + [fn () => self::createJws([...$claims, 'exp' => $time - 3600])], + [fn () => self::createJws([...$claims, 'nbf' => $time + 3600])], + [fn () => self::createJws([...$claims, 'iat' => $time + 3600])], + [fn () => self::createJws([...$claims, 'username' => 'Invalid Username'])], + [fn () => self::createJwe(self::createJws($claims), ['exp' => $time - 3600])], + [fn () => self::createJwe(self::createJws($claims), ['cty' => 'x-specific'])], ]; } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AccessToken/config_oauth2.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AccessToken/config_oauth2.yml new file mode 100644 index 0000000000000..9e4f6cceae76b --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AccessToken/config_oauth2.yml @@ -0,0 +1,34 @@ +imports: + - { resource: ./../config/framework.yml } + +framework: + http_method_override: false + serializer: ~ + http_client: + scoped_clients: + oauth2.client: + scope: 'https://authorization-server\.example\.com' + headers: + Authorization: 'Basic Y2xpZW50OnBhc3N3b3Jk' + +security: + password_hashers: + Symfony\Component\Security\Core\User\InMemoryUser: plaintext + + providers: + in_memory: + memory: + users: + dunglas: { password: foo, roles: [ROLE_USER] } + + firewalls: + main: + pattern: ^/ + access_token: + token_handler: + oauth2: ~ + token_extractors: 'header' + realm: 'My API' + + access_control: + - { path: ^/foo, roles: ROLE_USER } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AccessToken/config_oidc.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AccessToken/config_oidc.yml index 94b46501544dd..a087604782bec 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AccessToken/config_oidc.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AccessToken/config_oidc.yml @@ -24,7 +24,7 @@ security: claim: 'username' audience: 'Symfony OIDC' issuers: [ 'https://www.example.com' ] - algorithm: 'ES256' + algorithms: [ 'ES256' ] # tip: use https://mkjwk.org/ to generate a JWK keyset: '{"keys":[{"kty":"EC","d":"iA_TV2zvftni_9aFAQwFO_9aypfJFCSpcCyevDvz220","crv":"P-256","x":"0QEAsI1wGI-dmYatdUZoWSRWggLEpyzopuhwk-YUnA4","y":"KYl-qyZ26HobuYwlQh-r0iHX61thfP82qqEku7i0woo"}]}' encryption: diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/config.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/config.yml index 9d6b4caee1707..31b0af34088a3 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/config.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/config.yml @@ -17,7 +17,9 @@ framework: cookie_samesite: lax php_errors: log: true - profiler: { only_exceptions: false } + profiler: + only_exceptions: false + collect_serializer_data: true services: logger: { class: Psr\Log\NullLogger } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml index c197fcaa4c25e..0f2e1344d0e71 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml @@ -18,7 +18,9 @@ framework: cookie_samesite: lax php_errors: log: true - profiler: { only_exceptions: false } + profiler: + only_exceptions: false + collect_serializer_data: true services: logger: { class: Psr\Log\NullLogger } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/SecurityTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/SecurityTest.php index d4b336b4eaa70..9a126ae328e08 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/SecurityTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/SecurityTest.php @@ -152,7 +152,10 @@ public function testLogin() $firewallAuthenticatorLocator ->expects($this->once()) ->method('getProvidedServices') - ->willReturn(['security.authenticator.custom.dev' => $authenticator]) + ->willReturn([ + 'security.authenticator.custom.dev' => $authenticator, + 'security.authenticator.remember_me.main' => $authenticator, + ]) ; $firewallAuthenticatorLocator ->expects($this->once()) @@ -252,6 +255,49 @@ public function testLoginWithoutRequestContext() $security->login($user); } + public function testLoginFailsWhenTooManyAuthenticatorsFound() + { + $request = new Request(); + $authenticator = $this->createMock(AuthenticatorInterface::class); + $requestStack = $this->createMock(RequestStack::class); + $firewallMap = $this->createMock(FirewallMap::class); + $firewall = new FirewallConfig('main', 'main'); + $userAuthenticator = $this->createMock(UserAuthenticatorInterface::class); + $user = $this->createMock(UserInterface::class); + $userChecker = $this->createMock(UserCheckerInterface::class); + + $container = $this->createMock(ContainerInterface::class); + $container + ->expects($this->atLeastOnce()) + ->method('get') + ->willReturnMap([ + ['request_stack', $requestStack], + ['security.firewall.map', $firewallMap], + ['security.authenticator.managers_locator', $this->createContainer('main', $userAuthenticator)], + ['security.user_checker_locator', $this->createContainer('main', $userChecker)], + ]) + ; + + $requestStack->expects($this->once())->method('getCurrentRequest')->willReturn($request); + $firewallMap->expects($this->once())->method('getFirewallConfig')->willReturn($firewall); + + $firewallAuthenticatorLocator = $this->createMock(ServiceProviderInterface::class); + $firewallAuthenticatorLocator + ->expects($this->once()) + ->method('getProvidedServices') + ->willReturn([ + 'security.authenticator.custom.main' => $authenticator, + 'security.authenticator.other.main' => $authenticator, + ]) + ; + + $security = new Security($container, ['main' => $firewallAuthenticatorLocator]); + + $this->expectException(\LogicException::class); + $this->expectExceptionMessage('Too many authenticators were found for the current firewall "main". You must provide an instance of "Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface" to login programmatically. The available authenticators for the firewall "main" are "security.authenticator.custom.main" ,"security.authenticator.other.main'); + $security->login($user); + } + public function testLogout() { $request = new Request(); diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index fa5cb52ff04b5..7459b0175b95f 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -20,7 +20,7 @@ "composer-runtime-api": ">=2.1", "ext-xml": "*", "symfony/clock": "^6.4|^7.0", - "symfony/config": "^6.4|^7.0", + "symfony/config": "^7.3", "symfony/dependency-injection": "^6.4.11|^7.1.4", "symfony/event-dispatcher": "^6.4|^7.0", "symfony/http-kernel": "^6.4|^7.0", diff --git a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md index 91722564d0bd1..40d5be350afe7 100644 --- a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md @@ -1,6 +1,15 @@ CHANGELOG ========= +7.3 +--- + + * Enable `#[AsTwigFilter]`, `#[AsTwigFunction]` and `#[AsTwigTest]` attributes + to configure extensions on runtime classes + * Add support for a `twig` validator + * Use `ChainCache` to store warmed-up cache in `kernel.build_dir` and runtime cache in `kernel.cache_dir` + * Make `TemplateCacheWarmer` use `kernel.build_dir` instead of `kernel.cache_dir` + 7.1 --- diff --git a/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php b/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php index 868dc076cfd9e..3bb89760f3a6f 100644 --- a/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php +++ b/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php @@ -14,6 +14,8 @@ use Psr\Container\ContainerInterface; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; use Symfony\Contracts\Service\ServiceSubscriberInterface; +use Twig\Cache\CacheInterface; +use Twig\Cache\NullCache; use Twig\Environment; use Twig\Error\Error; @@ -34,6 +36,7 @@ class TemplateCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInte public function __construct( private ContainerInterface $container, private iterable $iterator, + private ?CacheInterface $cache = null, ) { } @@ -41,19 +44,40 @@ public function warmUp(string $cacheDir, ?string $buildDir = null): array { $this->twig ??= $this->container->get('twig'); - foreach ($this->iterator as $template) { - try { - $this->twig->load($template); - } catch (Error) { + $originalCache = $this->twig->getCache(); + if ($originalCache instanceof NullCache) { + // There's no point to warm up a cache that won't be used afterward + return []; + } + + if (null !== $this->cache) { + if (!$buildDir) { /* - * Problem during compilation, give up for this template (e.g. syntax errors). - * Failing silently here allows to ignore templates that rely on functions that aren't available in - * the current environment. For example, the WebProfilerBundle shouldn't be available in the prod - * environment, but some templates that are never used in prod might rely on functions the bundle provides. - * As we can't detect which templates are "really" important, we try to load all of them and ignore - * errors. Error checks may be performed by calling the lint:twig command. + * The cache has already been warmup during the build of the container, when $buildDir was set. */ + return []; + } + // Swap the cache for the warmup as the Twig Environment has the ChainCache injected + $this->twig->setCache($this->cache); + } + + try { + foreach ($this->iterator as $template) { + try { + $this->twig->load($template); + } catch (Error) { + /* + * Problem during compilation, give up for this template (e.g. syntax errors). + * Failing silently here allows to ignore templates that rely on functions that aren't available in + * the current environment. For example, the WebProfilerBundle shouldn't be available in the prod + * environment, but some templates that are never used in prod might rely on functions the bundle provides. + * As we can't detect which templates are "really" important, we try to load all of them and ignore + * errors. Error checks may be performed by calling the lint:twig command. + */ + } } + } finally { + $this->twig->setCache($originalCache); } return []; diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/AttributeExtensionPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/AttributeExtensionPass.php new file mode 100644 index 0000000000000..354874866a0ae --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/AttributeExtensionPass.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\ChildDefinition; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Exception\LogicException; +use Twig\Attribute\AsTwigFilter; +use Twig\Attribute\AsTwigFunction; +use Twig\Attribute\AsTwigTest; +use Twig\Extension\AbstractExtension; +use Twig\Extension\AttributeExtension; +use Twig\Extension\ExtensionInterface; + +/** + * Register an instance of AttributeExtension for each service using the + * PHP attributes to declare Twig callables. + * + * @author Jérôme Tamarelle + * + * @internal + */ +final class AttributeExtensionPass implements CompilerPassInterface +{ + private const TAG = 'twig.attribute_extension'; + + public static function autoconfigureFromAttribute(ChildDefinition $definition, AsTwigFilter|AsTwigFunction|AsTwigTest $attribute, \ReflectionMethod $reflector): void + { + $class = $reflector->getDeclaringClass(); + if ($class->implementsInterface(ExtensionInterface::class)) { + if ($class->isSubclassOf(AbstractExtension::class)) { + throw new LogicException(\sprintf('The class "%s" cannot extend "%s" and use the "#[%s]" attribute on method "%s()", choose one or the other.', $class->name, AbstractExtension::class, $attribute::class, $reflector->name)); + } + throw new LogicException(\sprintf('The class "%s" cannot implement "%s" and use the "#[%s]" attribute on method "%s()", choose one or the other.', $class->name, ExtensionInterface::class, $attribute::class, $reflector->name)); + } + + $definition->addTag(self::TAG); + + // The service must be tagged as a runtime to call non-static methods + if (!$reflector->isStatic()) { + $definition->addTag('twig.runtime'); + } + } + + public function process(ContainerBuilder $container): void + { + foreach ($container->findTaggedServiceIds(self::TAG, true) as $id => $tags) { + $container->register('.twig.extension.'.$id, AttributeExtension::class) + ->setArguments([$container->getDefinition($id)->getClass()]) + ->addTag('twig.extension'); + } + } +} diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index 32a4bb318fea4..354e1a4e85a0a 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -32,7 +32,9 @@ public function getConfigTreeBuilder(): TreeBuilder $treeBuilder = new TreeBuilder('twig'); $rootNode = $treeBuilder->getRootNode(); - $rootNode->beforeNormalization() + $rootNode + ->docUrl('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/twig.html', 'symfony/twig-bundle') + ->beforeNormalization() ->ifTrue(fn ($v) => \is_array($v) && \array_key_exists('exception_controller', $v)) ->then(function ($v) { if (isset($v['exception_controller'])) { @@ -134,7 +136,7 @@ private function addTwigOptions(ArrayNodeDefinition $rootNode): void ->example('Twig\Template') ->cannotBeEmpty() ->end() - ->scalarNode('cache')->defaultValue('%kernel.cache_dir%/twig')->end() + ->scalarNode('cache')->defaultTrue()->end() ->scalarNode('charset')->defaultValue('%kernel.charset%')->end() ->booleanNode('debug')->defaultValue('%kernel.debug%')->end() ->booleanNode('strict_variables')->defaultValue('%kernel.debug%')->end() diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index a3563b2d0d0ec..ccd546b93ca70 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\TwigBundle\DependencyInjection; +use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\AttributeExtensionPass; use Symfony\Component\AssetMapper\AssetMapper; use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\Resource\FileExistenceResource; @@ -24,7 +25,11 @@ use Symfony\Component\Mailer\Mailer; use Symfony\Component\Translation\LocaleSwitcher; use Symfony\Component\Translation\Translator; +use Symfony\Component\Validator\Constraint; use Symfony\Contracts\Service\ResetInterface; +use Twig\Attribute\AsTwigFilter; +use Twig\Attribute\AsTwigFunction; +use Twig\Attribute\AsTwigTest; use Twig\Environment; use Twig\Extension\ExtensionInterface; use Twig\Extension\RuntimeExtensionInterface; @@ -65,6 +70,10 @@ public function load(array $configs, ContainerBuilder $container): void $container->removeDefinition('twig.translation.extractor'); } + if ($container::willBeAvailable('symfony/validator', Constraint::class, ['symfony/twig-bundle'])) { + $loader->load('validator.php'); + } + foreach ($configs as $key => $config) { if (isset($config['globals'])) { foreach ($config['globals'] as $name => $value) { @@ -158,6 +167,31 @@ public function load(array $configs, ContainerBuilder $container): void } } + if (true === $config['cache']) { + $autoReloadOrDefault = $container->getParameterBag()->resolveValue($config['auto_reload'] ?? $config['debug']); + $buildDir = $container->getParameter('kernel.build_dir'); + $cacheDir = $container->getParameter('kernel.cache_dir'); + + if ($autoReloadOrDefault || $cacheDir === $buildDir) { + $config['cache'] = '%kernel.cache_dir%/twig'; + } + } + + if (true === $config['cache']) { + $config['cache'] = new Reference('twig.template_cache.chain'); + } else { + $container->removeDefinition('twig.template_cache.chain'); + $container->removeDefinition('twig.template_cache.runtime_cache'); + $container->removeDefinition('twig.template_cache.readonly_cache'); + $container->removeDefinition('twig.template_cache.warmup_cache'); + + if (false === $config['cache']) { + $container->removeDefinition('twig.template_cache_warmer'); + } else { + $container->getDefinition('twig.template_cache_warmer')->replaceArgument(2, null); + } + } + if (isset($config['autoescape_service'])) { $config['autoescape'] = [new Reference($config['autoescape_service']), $config['autoescape_service_method'] ?? '__invoke']; } else { @@ -179,9 +213,9 @@ public function load(array $configs, ContainerBuilder $container): void $container->registerForAutoconfiguration(LoaderInterface::class)->addTag('twig.loader'); $container->registerForAutoconfiguration(RuntimeExtensionInterface::class)->addTag('twig.runtime'); - if (false === $config['cache']) { - $container->removeDefinition('twig.template_cache_warmer'); - } + $container->registerAttributeForAutoconfiguration(AsTwigFilter::class, AttributeExtensionPass::autoconfigureFromAttribute(...)); + $container->registerAttributeForAutoconfiguration(AsTwigFunction::class, AttributeExtensionPass::autoconfigureFromAttribute(...)); + $container->registerAttributeForAutoconfiguration(AsTwigTest::class, AttributeExtensionPass::autoconfigureFromAttribute(...)); } private function getBundleTemplatePaths(ContainerBuilder $container, array $config): array diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.php b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.php index 02631d28c39a4..3ea59d07fa469 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.php +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.php @@ -36,8 +36,11 @@ use Symfony\Bundle\TwigBundle\CacheWarmer\TemplateCacheWarmer; use Symfony\Bundle\TwigBundle\DependencyInjection\Configurator\EnvironmentConfigurator; use Symfony\Bundle\TwigBundle\TemplateIterator; +use Twig\Cache\ChainCache; use Twig\Cache\FilesystemCache; +use Twig\Cache\ReadOnlyFilesystemCache; use Twig\Environment; +use Twig\ExpressionParser\Infix\BinaryOperatorExpressionParser; use Twig\Extension\CoreExtension; use Twig\Extension\DebugExtension; use Twig\Extension\EscaperExtension; @@ -63,6 +66,7 @@ ->tag('container.preload', ['class' => EscaperExtension::class]) ->tag('container.preload', ['class' => OptimizerExtension::class]) ->tag('container.preload', ['class' => StagingExtension::class]) + ->tag('container.preload', ['class' => BinaryOperatorExpressionParser::class]) ->tag('container.preload', ['class' => ExtensionSet::class]) ->tag('container.preload', ['class' => Template::class]) ->tag('container.preload', ['class' => TemplateWrapper::class]) @@ -79,8 +83,24 @@ ->set('twig.template_iterator', TemplateIterator::class) ->args([service('kernel'), abstract_arg('Twig paths'), param('twig.default_path'), abstract_arg('File name pattern')]) + ->set('twig.template_cache.runtime_cache', FilesystemCache::class) + ->args([param('kernel.cache_dir').'/twig']) + + ->set('twig.template_cache.readonly_cache', ReadOnlyFilesystemCache::class) + ->args([param('kernel.build_dir').'/twig']) + + ->set('twig.template_cache.warmup_cache', FilesystemCache::class) + ->args([param('kernel.build_dir').'/twig']) + + ->set('twig.template_cache.chain', ChainCache::class) + ->args([[service('twig.template_cache.readonly_cache'), service('twig.template_cache.runtime_cache')]]) + ->set('twig.template_cache_warmer', TemplateCacheWarmer::class) - ->args([service(ContainerInterface::class), service('twig.template_iterator')]) + ->args([ + service(ContainerInterface::class), + service('twig.template_iterator'), + service('twig.template_cache.warmup_cache'), + ]) ->tag('kernel.cache_warmer') ->tag('container.service_subscriber', ['id' => 'twig']) diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/validator.php b/src/Symfony/Bundle/TwigBundle/Resources/config/validator.php new file mode 100644 index 0000000000000..1c0e8dd474ee6 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/validator.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Loader\Configurator; + +use Symfony\Bridge\Twig\Validator\Constraints\TwigValidator; + +return static function (ContainerConfigurator $container) { + $container->services() + ->set('twig.validator', TwigValidator::class) + ->args([service('twig')]) + ->tag('validator.constraint_validator') + ; +}; diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php index f87af5a1baba4..68c7f5a304218 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php @@ -10,8 +10,7 @@ 'pi' => 3.14, 'bad' => ['key' => 'foo'], ], - 'auto_reload' => true, - 'cache' => '/tmp', + 'auto_reload' => false, 'charset' => 'ISO-8859-1', 'debug' => true, 'strict_variables' => true, diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/no-cache.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/no-cache.php new file mode 100644 index 0000000000000..df1ae5c6bd63b --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/no-cache.php @@ -0,0 +1,5 @@ +loadFromExtension('twig', [ + 'cache' => false, +]); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/path-cache.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/path-cache.php new file mode 100644 index 0000000000000..f0701a57d8c88 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/path-cache.php @@ -0,0 +1,5 @@ +loadFromExtension('twig', [ + 'cache' => 'random-path', +]); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/prod-cache.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/prod-cache.php new file mode 100644 index 0000000000000..628854601a960 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/prod-cache.php @@ -0,0 +1,6 @@ +loadFromExtension('twig', [ + 'cache' => true, + 'auto_reload' => false, +]); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml index f1cf8985329d0..df02c9dc05f91 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml @@ -6,7 +6,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/twig https://symfony.com/schema/dic/twig/twig-1.0.xsd"> - + namespaced_path3 diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml index 528a466b0452c..3349e0d5fa744 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml @@ -6,7 +6,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/twig https://symfony.com/schema/dic/twig/twig-1.0.xsd"> - + MyBundle::form.html.twig @@qux diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/no-cache.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/no-cache.xml new file mode 100644 index 0000000000000..f6fa72c747893 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/no-cache.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/path-cache.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/path-cache.xml new file mode 100644 index 0000000000000..9caf2fc0452b0 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/path-cache.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/prod-cache.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/prod-cache.xml new file mode 100644 index 0000000000000..6ee9f38506252 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/prod-cache.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml index 6c249d378ff22..ab19cbf0bff8f 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml @@ -6,8 +6,7 @@ twig: baz: "@@qux" pi: 3.14 bad: {key: foo} - auto_reload: true - cache: /tmp + auto_reload: false charset: ISO-8859-1 debug: true strict_variables: true diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/no-cache.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/no-cache.yml new file mode 100644 index 0000000000000..c1e9f184bd336 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/no-cache.yml @@ -0,0 +1,2 @@ +twig: + cache: false diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/path-cache.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/path-cache.yml new file mode 100644 index 0000000000000..04e9d1dc61b06 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/path-cache.yml @@ -0,0 +1,2 @@ +twig: + cache: random-path diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/prod-cache.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/prod-cache.yml new file mode 100644 index 0000000000000..82a1dd9e100d3 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/prod-cache.yml @@ -0,0 +1,3 @@ +twig: + cache: true + auto_reload: false diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index ffe772a28861d..ddc489e783671 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -28,6 +28,7 @@ use Symfony\Component\Form\FormRenderer; use Symfony\Component\Mailer\Mailer; use Symfony\Component\Stopwatch\Stopwatch; +use Symfony\Component\Validator\Validator\ValidatorInterface; use Twig\Environment; class TwigExtensionTest extends TestCase @@ -54,14 +55,20 @@ public function testLoadEmptyConfiguration() if (class_exists(Mailer::class)) { $this->assertCount(2, $container->getDefinition('twig.mime_body_renderer')->getArguments()); } + + if (interface_exists(ValidatorInterface::class)) { + $this->assertTrue($container->hasDefinition('twig.validator')); + } else { + $this->assertFalse($container->hasDefinition('twig.validator')); + } } /** - * @dataProvider getFormats + * @dataProvider getFormatsAndBuildDir */ - public function testLoadFullConfiguration(string $format) + public function testLoadFullConfiguration(string $format, ?string $buildDir) { - $container = $this->createContainer(); + $container = $this->createContainer($buildDir); $container->registerExtension(new TwigExtension()); $this->loadFromFile($container, 'full', $format); $this->compileContainer($container); @@ -92,13 +99,64 @@ public function testLoadFullConfiguration(string $format) // Twig options $options = $container->getDefinition('twig')->getArgument(1); - $this->assertTrue($options['auto_reload'], '->load() sets the auto_reload option'); + $this->assertFalse($options['auto_reload'], '->load() sets the auto_reload option'); $this->assertSame('name', $options['autoescape'], '->load() sets the autoescape option'); $this->assertArrayNotHasKey('base_template_class', $options, '->load() does not set the base_template_class if none is provided'); - $this->assertEquals('/tmp', $options['cache'], '->load() sets the cache option'); $this->assertEquals('ISO-8859-1', $options['charset'], '->load() sets the charset option'); $this->assertTrue($options['debug'], '->load() sets the debug option'); $this->assertTrue($options['strict_variables'], '->load() sets the strict_variables option'); + $this->assertEquals(null !== $buildDir ? new Reference('twig.template_cache.chain') : '%kernel.cache_dir%/twig', $options['cache'], '->load() sets the cache option'); + } + + /** + * @dataProvider getFormatsAndBuildDir + */ + public function testLoadNoCacheConfiguration(string $format, ?string $buildDir) + { + $container = $this->createContainer($buildDir); + $container->registerExtension(new TwigExtension()); + $this->loadFromFile($container, 'no-cache', $format); + $this->compileContainer($container); + + $this->assertEquals(Environment::class, $container->getDefinition('twig')->getClass(), '->load() loads the twig.xml file'); + + // Twig options + $options = $container->getDefinition('twig')->getArgument(1); + $this->assertFalse($options['cache'], '->load() sets cache option to false'); + } + + /** + * @dataProvider getFormatsAndBuildDir + */ + public function testLoadPathCacheConfiguration(string $format, ?string $buildDir) + { + $container = $this->createContainer($buildDir); + $container->registerExtension(new TwigExtension()); + $this->loadFromFile($container, 'path-cache', $format); + $this->compileContainer($container); + + $this->assertEquals(Environment::class, $container->getDefinition('twig')->getClass(), '->load() loads the twig.xml file'); + + // Twig options + $options = $container->getDefinition('twig')->getArgument(1); + $this->assertSame('random-path', $options['cache'], '->load() sets cache option to string path'); + } + + /** + * @dataProvider getFormatsAndBuildDir + */ + public function testLoadProdCacheConfiguration(string $format, ?string $buildDir) + { + $container = $this->createContainer($buildDir); + $container->registerExtension(new TwigExtension()); + $this->loadFromFile($container, 'prod-cache', $format); + $this->compileContainer($container); + + $this->assertEquals(Environment::class, $container->getDefinition('twig')->getClass(), '->load() loads the twig.xml file'); + + // Twig options + $options = $container->getDefinition('twig')->getArgument(1); + $this->assertEquals(null !== $buildDir ? new Reference('twig.template_cache.chain') : '%kernel.cache_dir%/twig', $options['cache'], '->load() sets cache option to CacheChain reference'); } /** @@ -238,6 +296,18 @@ public static function getFormats(): array ]; } + public static function getFormatsAndBuildDir(): array + { + return [ + ['php', null], + ['php', __DIR__.'/build'], + ['yml', null], + ['yml', __DIR__.'/build'], + ['xml', null], + ['xml', __DIR__.'/build'], + ]; + } + /** * @dataProvider stopwatchExtensionAvailabilityProvider */ @@ -312,10 +382,11 @@ public function testCustomHtmlToTextConverterService(string $format) $this->assertEquals(new Reference('my_converter'), $bodyRenderer->getArgument('$converter')); } - private function createContainer(): ContainerBuilder + private function createContainer(?string $buildDir = null): ContainerBuilder { $container = new ContainerBuilder(new ParameterBag([ 'kernel.cache_dir' => __DIR__, + 'kernel.build_dir' => $buildDir ?? __DIR__, 'kernel.project_dir' => __DIR__, 'kernel.charset' => 'UTF-8', 'kernel.debug' => false, diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Functional/AttributeExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Functional/AttributeExtensionTest.php new file mode 100644 index 0000000000000..32db815b16a37 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/Functional/AttributeExtensionTest.php @@ -0,0 +1,167 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests\Functional; + +use PHPUnit\Framework\Attributes\After; +use PHPUnit\Framework\Attributes\Before; +use PHPUnit\Framework\Attributes\BeforeClass; +use Symfony\Bundle\FrameworkBundle\FrameworkBundle; +use Symfony\Bundle\TwigBundle\Tests\TestCase; +use Symfony\Bundle\TwigBundle\TwigBundle; +use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Exception\LogicException; +use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\HttpKernel\Kernel; +use Twig\Attribute\AsTwigFilter; +use Twig\Attribute\AsTwigFunction; +use Twig\Attribute\AsTwigTest; +use Twig\Environment; +use Twig\Error\RuntimeError; +use Twig\Extension\AbstractExtension; +use Twig\Extension\AttributeExtension; + +class AttributeExtensionTest extends TestCase +{ + /** @beforeClass */ + #[BeforeClass] + public static function assertTwigVersion(): void + { + if (!class_exists(AttributeExtension::class)) { + self::markTestSkipped('Twig 3.21 is required.'); + } + } + + public function testExtensionWithAttributes() + { + $kernel = new class extends AttributeExtensionKernel { + public function registerContainerConfiguration(LoaderInterface $loader): void + { + $loader->load(static function (ContainerBuilder $container) { + $container->setParameter('kernel.secret', 'secret'); + $container->register(StaticExtensionWithAttributes::class, StaticExtensionWithAttributes::class) + ->setAutoconfigured(true); + $container->register(RuntimeExtensionWithAttributes::class, RuntimeExtensionWithAttributes::class) + ->setArguments(['prefix_']) + ->setAutoconfigured(true); + + $container->setAlias('twig_test', 'twig')->setPublic(true); + }); + } + }; + + $kernel->boot(); + + /** @var Environment $twig */ + $twig = $kernel->getContainer()->get('twig_test'); + + self::assertInstanceOf(AttributeExtension::class, $twig->getExtension(StaticExtensionWithAttributes::class)); + self::assertInstanceOf(AttributeExtension::class, $twig->getExtension(RuntimeExtensionWithAttributes::class)); + self::assertInstanceOf(RuntimeExtensionWithAttributes::class, $twig->getRuntime(RuntimeExtensionWithAttributes::class)); + + self::expectException(RuntimeError::class); + $twig->getRuntime(StaticExtensionWithAttributes::class); + } + + public function testInvalidExtensionClass() + { + $kernel = new class extends AttributeExtensionKernel { + public function registerContainerConfiguration(LoaderInterface $loader): void + { + $loader->load(static function (ContainerBuilder $container) { + $container->register(InvalidExtensionWithAttributes::class, InvalidExtensionWithAttributes::class) + ->setAutoconfigured(true); + }); + } + }; + + $this->expectException(LogicException::class); + $this->expectExceptionMessage('The class "Symfony\Bundle\TwigBundle\Tests\Functional\InvalidExtensionWithAttributes" cannot extend "Twig\Extension\AbstractExtension" and use the "#[Twig\Attribute\AsTwigFilter]" attribute on method "funFilter()", choose one or the other.'); + + $kernel->boot(); + } + + /** + * @before + * + * @after + */ + #[Before, After] + protected function deleteTempDir() + { + if (file_exists($dir = sys_get_temp_dir().'/'.Kernel::VERSION.'/AttributeExtension')) { + (new Filesystem())->remove($dir); + } + } +} + +abstract class AttributeExtensionKernel extends Kernel +{ + public function __construct() + { + parent::__construct('test', true); + } + + public function registerBundles(): iterable + { + return [new FrameworkBundle(), new TwigBundle()]; + } + + public function getProjectDir(): string + { + return sys_get_temp_dir().'/'.Kernel::VERSION.'/AttributeExtension'; + } +} + +class StaticExtensionWithAttributes +{ + #[AsTwigFilter('foo')] + public static function fooFilter(string $value): string + { + return $value; + } + + #[AsTwigFunction('foo')] + public static function fooFunction(string $value): string + { + return $value; + } + + #[AsTwigTest('foo')] + public static function fooTest(bool $value): bool + { + return $value; + } +} + +class RuntimeExtensionWithAttributes +{ + public function __construct(private bool $prefix) + { + } + + #[AsTwigFilter('prefix_foo')] + #[AsTwigFunction('prefix_foo')] + public function prefix(string $value): string + { + return $this->prefix.$value; + } +} + +class InvalidExtensionWithAttributes extends AbstractExtension +{ + #[AsTwigFilter('fun')] + public function funFilter(): string + { + return 'fun'; + } +} diff --git a/src/Symfony/Bundle/TwigBundle/TwigBundle.php b/src/Symfony/Bundle/TwigBundle/TwigBundle.php index 5ff13b1bc8687..d9bc6078689b3 100644 --- a/src/Symfony/Bundle/TwigBundle/TwigBundle.php +++ b/src/Symfony/Bundle/TwigBundle/TwigBundle.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\TwigBundle; +use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\AttributeExtensionPass; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExtensionPass; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\RuntimeLoaderPass; use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigEnvironmentPass; @@ -33,6 +34,7 @@ public function build(ContainerBuilder $container): void // ExtensionPass must be run before the FragmentRendererPass as it adds tags that are processed later $container->addCompilerPass(new ExtensionPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10); + $container->addCompilerPass(new AttributeExtensionPass()); $container->addCompilerPass(new TwigEnvironmentPass()); $container->addCompilerPass(new TwigLoaderPass()); $container->addCompilerPass(new RuntimeLoaderPass(), PassConfig::TYPE_BEFORE_REMOVING); diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index f6e0e110cc686..221a7f471290e 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -18,9 +18,9 @@ "require": { "php": ">=8.2", "composer-runtime-api": ">=2.1", - "symfony/config": "^6.4|^7.0", + "symfony/config": "^7.3", "symfony/dependency-injection": "^6.4|^7.0", - "symfony/twig-bridge": "^6.4|^7.0", + "symfony/twig-bridge": "^7.3", "symfony/http-foundation": "^6.4|^7.0", "symfony/http-kernel": "^6.4|^7.0", "twig/twig": "^3.12" diff --git a/src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md b/src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md index 539d814d2a438..5e5e8db36e233 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md @@ -4,6 +4,34 @@ CHANGELOG 7.3 --- + * Add `profiler.php` and `wdt.php` routing configuration files (use them instead of their XML equivalent) + + Before: + + ```yaml + when@dev: + web_profiler_wdt: + resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml' + prefix: /_wdt + + web_profiler_profiler: + resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml' + prefix: /_profiler + ``` + + After: + + ```yaml + when@dev: + web_profiler_wdt: + resource: '@WebProfilerBundle/Resources/config/routing/wdt.php' + prefix: /_wdt + + web_profiler_profiler: + resource: '@WebProfilerBundle/Resources/config/routing/profiler.php + prefix: /_profiler + ``` + * Add `ajax_replace` option for replacing toolbar on AJAX requests 7.2 diff --git a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php index d9ca50a27af21..649bf459e8fed 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php @@ -31,7 +31,9 @@ public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('web_profiler'); - $treeBuilder->getRootNode() + $treeBuilder + ->getRootNode() + ->docUrl('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/web_profiler.html', 'symfony/web-profiler-bundle') ->children() ->arrayNode('toolbar') ->info('Profiler toolbar configuration') diff --git a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php index de7bb7b001ca0..2ad19250a39c6 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php +++ b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php @@ -104,7 +104,7 @@ public function onKernelResponse(ResponseEvent $event): void return; } - if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects && 'html' === $request->getRequestFormat()) { + if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects && 'html' === $request->getRequestFormat() && $response->headers->has('Location')) { if ($request->hasSession() && ($session = $request->getSession())->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) { // keep current flashes for one more request if using AutoExpireFlashBag $session->getFlashBag()->setAll($session->getFlashBag()->peekAll()); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Profiler/CodeExtension.php b/src/Symfony/Bundle/WebProfilerBundle/Profiler/CodeExtension.php index 332a5d6c3725e..299a1b02cf595 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Profiler/CodeExtension.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Profiler/CodeExtension.php @@ -16,7 +16,7 @@ use Twig\TwigFilter; /** - * Twig extension relate to PHP code and used by the profiler and the default exception templates. + * Twig extension related to PHP code and used by the profiler and the default exception templates. * * This extension should only be used for debugging tools code * that is never executed in a production environment. @@ -119,39 +119,85 @@ public function formatArgsAsText(array $args): string */ public function fileExcerpt(string $file, int $line, int $srcContext = 3): ?string { - if (is_file($file) && is_readable($file)) { - // highlight_file could throw warnings - // see https://bugs.php.net/25725 - $code = @highlight_file($file, true); - if (\PHP_VERSION_ID >= 80300) { - // remove main pre/code tags - $code = preg_replace('#^\s*(.*)\s*#s', '\\1', $code); - // split multiline span tags - $code = preg_replace_callback('#]++)>((?:[^<\\n]*+\\n)++[^<]*+)#', function ($m) { - return "".str_replace("\n", "\n", $m[2]).''; - }, $code); - $content = explode("\n", $code); - } else { - // remove main code/span tags - $code = preg_replace('#^\s*(.*)\s*#s', '\\1', $code); - // split multiline spans - $code = preg_replace_callback('#]++)>((?:[^<]*+
)++[^<]*+)
#', fn ($m) => "".str_replace('
', "

", $m[2]).'', $code); - $content = explode('
', $code); - } + if (!is_file($file) || !is_readable($file)) { + return null; + } + + $contents = file_get_contents($file); + + if (!str_contains($contents, ' $srcContext) { - $srcContext = \count($content); + $srcContext = \count($lines); } - for ($i = max($line - $srcContext, 1), $max = min($line + $srcContext, \count($content)); $i <= $max; ++$i) { - $lines[] = ''.self::fixCodeMarkup($content[$i - 1]).''; - } + return $this->formatFileExcerpt( + $this->extractExcerptLines($lines, $line, $srcContext), + $line, + $srcContext + ); + } - return '
    '.implode("\n", $lines).'
'; + // highlight_string could throw warnings + // see https://bugs.php.net/25725 + $code = @highlight_string($contents, true); + + if (\PHP_VERSION_ID >= 80300) { + // remove main pre/code tags + $code = preg_replace('#^\s*(.*)\s*#s', '\\1', $code); + // split multiline span tags + $code = preg_replace_callback( + '#]++)>((?:[^<\\n]*+\\n)++[^<]*+)#', + static fn (array $m): string => "".str_replace("\n", "\n", $m[2]).'', + $code + ); + $lines = explode("\n", $code); + } else { + // remove main code/span tags + $code = preg_replace('#^\s*(.*)\s*#s', '\\1', $code); + // split multiline spans + $code = preg_replace_callback( + '#]++)>((?:[^<]*+
)++[^<]*+)
#', + static fn (array $m): string => "".str_replace('
', "

", $m[2]).'', + $code + ); + $lines = explode('
', $code); } - return null; + if (0 > $srcContext) { + $srcContext = \count($lines); + } + + return $this->formatFileExcerpt( + array_map( + self::fixCodeMarkup(...), + $this->extractExcerptLines($lines, $line, $srcContext), + ), + $line, + $srcContext + ); + } + + private function extractExcerptLines(array $lines, int $selectedLine, int $srcContext): array + { + return \array_slice( + $lines, + max($selectedLine - $srcContext, 0), + min($srcContext * 2 + 1, \count($lines) - $selectedLine + $srcContext), + true + ); + } + + private function formatFileExcerpt(array $lines, int $selectedLine, int $srcContext): string + { + $start = max($selectedLine - $srcContext, 1); + + return "
    ".implode("\n", array_map( + static fn (string $line, int $num): string => '{$line}", + $lines, + array_keys($lines), + )).'
'; } /** @@ -241,7 +287,7 @@ protected static function fixCodeMarkup(string $line): string // missing tag at the end of line $opening = strpos($line, ''); - if (false !== $opening && (false === $closing || $closing > $opening)) { + if (false !== $opening && (false === $closing || $closing < $opening)) { $line .= ''; } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.php b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.php new file mode 100644 index 0000000000000..09e022be922b0 --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.php @@ -0,0 +1,62 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; +use Symfony\Component\Routing\Loader\XmlFileLoader; + +return function (RoutingConfigurator $routes): void { + foreach (debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT) as $trace) { + if (isset($trace['object']) && $trace['object'] instanceof XmlFileLoader && 'doImport' === $trace['function']) { + if (__DIR__ === dirname(realpath($trace['args'][3]))) { + trigger_deprecation('symfony/routing', '7.3', 'The "profiler.xml" routing configuration file is deprecated, import "profiler.php" instead.'); + + break; + } + } + } + + $routes->add('_profiler_home', '/') + ->controller('web_profiler.controller.profiler::homeAction') + ; + $routes->add('_profiler_search', '/search') + ->controller('web_profiler.controller.profiler::searchAction') + ; + $routes->add('_profiler_search_bar', '/search_bar') + ->controller('web_profiler.controller.profiler::searchBarAction') + ; + $routes->add('_profiler_phpinfo', '/phpinfo') + ->controller('web_profiler.controller.profiler::phpinfoAction') + ; + $routes->add('_profiler_xdebug', '/xdebug') + ->controller('web_profiler.controller.profiler::xdebugAction') + ; + $routes->add('_profiler_font', '/font/{fontName}.woff2') + ->controller('web_profiler.controller.profiler::fontAction') + ; + $routes->add('_profiler_search_results', '/{token}/search/results') + ->controller('web_profiler.controller.profiler::searchResultsAction') + ; + $routes->add('_profiler_open_file', '/open') + ->controller('web_profiler.controller.profiler::openAction') + ; + $routes->add('_profiler', '/{token}') + ->controller('web_profiler.controller.profiler::panelAction') + ; + $routes->add('_profiler_router', '/{token}/router') + ->controller('web_profiler.controller.router::panelAction') + ; + $routes->add('_profiler_exception', '/{token}/exception') + ->controller('web_profiler.controller.exception_panel::body') + ; + $routes->add('_profiler_exception_css', '/{token}/exception.css') + ->controller('web_profiler.controller.exception_panel::stylesheet') + ; +}; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml index 363b15d872b0c..8712f38774a74 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml @@ -4,52 +4,5 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd"> - - web_profiler.controller.profiler::homeAction - - - - web_profiler.controller.profiler::searchAction - - - - web_profiler.controller.profiler::searchBarAction - - - - web_profiler.controller.profiler::phpinfoAction - - - - web_profiler.controller.profiler::xdebugAction - - - - web_profiler.controller.profiler::fontAction - - - - web_profiler.controller.profiler::searchResultsAction - - - - web_profiler.controller.profiler::openAction - - - - web_profiler.controller.profiler::panelAction - - - - web_profiler.controller.router::panelAction - - - - web_profiler.controller.exception_panel::body - - - - web_profiler.controller.exception_panel::stylesheet - - + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/wdt.php b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/wdt.php new file mode 100644 index 0000000000000..d0383ee8fbef9 --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/wdt.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; +use Symfony\Component\Routing\Loader\XmlFileLoader; + +return function (RoutingConfigurator $routes): void { + foreach (debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT) as $trace) { + if (isset($trace['object']) && $trace['object'] instanceof XmlFileLoader && 'doImport' === $trace['function']) { + if (__DIR__ === dirname(realpath($trace['args'][3]))) { + trigger_deprecation('symfony/routing', '7.3', 'The "wdt.xml" routing configuration file is deprecated, import "wdt.php" instead.'); + + break; + } + } + } + + $routes->add('_wdt_stylesheet', '/styles') + ->controller('web_profiler.controller.profiler::toolbarStylesheetAction') + ; + $routes->add('_wdt', '/{token}') + ->controller('web_profiler.controller.profiler::toolbarAction') + ; +}; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/wdt.xml b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/wdt.xml index 9f45f1b7490ae..04bddb4f3a1b9 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/wdt.xml +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/wdt.xml @@ -4,11 +4,5 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd"> - - web_profiler.controller.profiler::toolbarStylesheetAction - - - - web_profiler.controller.profiler::toolbarAction - + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig index d0bc96868e8e6..217ad78f2b412 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig @@ -93,7 +93,7 @@ {{ loop.index }} {{ '%0.2f'|format((call.end - call.start) * 1000) }} ms - {{ call.name }}() + {{ call.name }}({{ call.namespace|default('') }}) {{ profiler_dump(call.value.result, maxDepth=2) }} {% endfor %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/notifier.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/notifier.html.twig index 9de8d216e6d1f..ed363f1d92fe2 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/notifier.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/notifier.html.twig @@ -151,7 +151,7 @@ {%- if message.getOptions() is null %} {{- '(empty)' }} {%- else %} - {{- message.getOptions()|json_encode(constant('JSON_PRETTY_PRINT')) }} + {{- message.getOptions().toArray()|json_encode(constant('JSON_PRETTY_PRINT')) }} {%- endif %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig index eeb8a06a88dee..53560cf306713 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig @@ -156,6 +156,27 @@ {% endblock messages %} {% endif %} + {% if collector.globalParameters|default([]) %} +

Global parameters

+ + + + + + + + + + {% for id, value in collector.globalParameters %} + + + + + {% endfor %} + +
Message IDValue
{{ id }}{{ profiler_dump(value) }}
+ {% endif %} + {% endblock %} {% macro render_table(messages, is_fallback) %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/workflow.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/workflow.html.twig index 6f09b36355056..dfe7beac0932f 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/workflow.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/workflow.html.twig @@ -137,20 +137,22 @@ {{ source('@WebProfiler/Script/Mermaid/mermaid-flowchart-v2.min.js') }} const isDarkMode = document.querySelector('body').classList.contains('theme-dark'); mermaid.initialize({ - flowchart: { useMaxWidth: false }, + flowchart: { + useMaxWidth: true, + }, securityLevel: 'loose', - 'theme': 'base', - 'themeVariables': { + theme: 'base', + themeVariables: { darkMode: isDarkMode, - 'fontFamily': 'var(--font-family-system)', - 'fontSize': 'var(--font-size-body)', + fontFamily: 'var(--font-family-system)', + fontSize: 'var(--font-size-body)', // the properties below don't support CSS variables - 'primaryColor': isDarkMode ? 'lightsteelblue' : 'aliceblue', - 'primaryTextColor': isDarkMode ? '#000' : '#000', - 'primaryBorderColor': isDarkMode ? 'steelblue' : 'lightsteelblue', - 'lineColor': isDarkMode ? '#939393' : '#d4d4d4', - 'secondaryColor': isDarkMode ? 'lightyellow' : 'lightyellow', - 'tertiaryColor': isDarkMode ? 'lightSalmon' : 'lightSalmon', + primaryColor: isDarkMode ? 'lightsteelblue' : 'aliceblue', + primaryTextColor: isDarkMode ? '#000' : '#000', + primaryBorderColor: isDarkMode ? 'steelblue' : 'lightsteelblue', + lineColor: isDarkMode ? '#939393' : '#d4d4d4', + secondaryColor: isDarkMode ? 'lightyellow' : 'lightyellow', + tertiaryColor: isDarkMode ? 'lightSalmon' : 'lightSalmon', } }); @@ -275,6 +277,7 @@ click {{ nodeId }} showNodeDetails{{ collector.hash(name) }} {% endfor %} + View on mermaid.live

Calls

diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig index b61fa5e9f138f..148b7638ad2eb 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig @@ -46,45 +46,11 @@ --sf-toolbar-green-900: #030404; } -.sf-minitoolbar { - --sf-toolbar-gray-800: #262626; - - background-color: var(--sf-toolbar-gray-800); - border-top-left-radius: 4px; - bottom: 0; - box-sizing: border-box; - display: none; - height: 36px; - padding: 6px; - position: fixed; - right: 0; - z-index: 99999; -} - -.sf-minitoolbar button { - background-color: transparent; - padding: 0; - border: none; -} -.sf-minitoolbar svg, -.sf-minitoolbar img { - --sf-toolbar-gray-200: #e5e5e5; - - color: var(--sf-toolbar-gray-200); - max-height: 24px; - max-width: 24px; - display: inline; -} - .sf-toolbar-clearer { clear: both; height: 36px; } -.sf-display-none { - display: none; -} - .sf-toolbarreset *:not(svg rect) { box-sizing: content-box; vertical-align: baseline; @@ -127,27 +93,52 @@ color: var(--sf-toolbar-gray-700); } -.sf-toolbarreset .hide-button { +.sf-toolbarreset .sf-toolbar-toggle-button { background: var(--sf-toolbar-gray-800); color: var(--sf-toolbar-gray-300); display: block; position: absolute; - top: 2px; + top: 1px; right: 0; width: 36px; - height: 34px; + height: 35px; cursor: pointer; text-align: center; border: none; margin: 0; padding: 0; + outline: none; } -.sf-toolbarreset .hide-button:hover { +.sf-toolbarreset .sf-toolbar-toggle-button:hover { background: var(--sf-toolbar-gray-700); } -.sf-toolbarreset .hide-button svg { - max-height: 18px; - margin-top: 1px; + +.sf-toolbar.sf-toolbar-closed .sf-toolbarreset .sf-toolbar-block { + display: none; +} +.sf-toolbar.sf-toolbar-closed .sf-toolbarreset .sf-toolbar-toggle-button { + top: -37px; +} + +.sf-toolbar .sf-toolbar-toggle-button i { + display: block; + height: 35px; + place-content: center; +} +.sf-toolbar.sf-toolbar-opened .sf-toolbar-toggle-button .sf-toolbar-icon-closed { + display: none; +} +.sf-toolbar.sf-toolbar-opened .sf-toolbar-toggle-button .sf-toolbar-icon-opened { + display: block; +} +.sf-toolbar.sf-toolbar-closed .sf-toolbar-toggle-button .sf-toolbar-icon-closed { + display: block; +} +.sf-toolbar.sf-toolbar-closed .sf-toolbar-toggle-button .sf-toolbar-icon-opened { + display: none; +} +.sf-toolbar.sf-toolbar-closed .sf-toolbarreset .sf-toolbar-toggle-button { + border-top: 2px solid var(--sf-toolbar-gray-800); } .sf-toolbar-block { diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig index 565ec39bfe2ef..b82f911c3ddc6 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig @@ -1,11 +1,4 @@ - -
- -
-
{% for name, template in templates %} {% if block('toolbar', template) is defined %} @@ -39,8 +32,8 @@
{% endif %} - - diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig index eaf9329aadde7..dd9527d24b0ab 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig @@ -1,4 +1,5 @@ -
+ +
{{ include('@WebProfiler/Profiler/toolbar.html.twig', { templates: { 'request': '@WebProfiler/Profiler/cancel.html.twig' @@ -143,7 +144,7 @@ var ajaxToolbarPanel = document.querySelector('.sf-toolbar-block-ajax'); if (requestStack.length) { - ajaxToolbarPanel.style.display = 'block'; + ajaxToolbarPanel.style.display = ''; } else { ajaxToolbarPanel.style.display = 'none'; } @@ -414,11 +415,7 @@ renderAjaxRequests: renderAjaxRequests, getSfwdt: function(token) { - if (!this.sfwdt) { - this.sfwdt = document.getElementById('sfwdt' + token); - } - - return this.sfwdt; + return document.getElementById('sfwdt' + token); }, load: function(selector, url, onSuccess, onError, options) { @@ -453,60 +450,32 @@ showToolbar: function(token) { var sfwdt = this.getSfwdt(token); - removeClass(sfwdt, 'sf-display-none'); - if (getPreference('toolbar/displayState') == 'none') { - document.getElementById('sfToolbarMainContent-' + token).style.display = 'none'; - document.getElementById('sfToolbarClearer-' + token).style.display = 'none'; - document.getElementById('sfMiniToolbar-' + token).style.display = 'block'; + if ('closed' === getPreference('toolbar/displayState')) { + addClass(sfwdt, 'sf-toolbar-closed'); + removeClass(sfwdt, 'sf-toolbar-opened'); } else { - document.getElementById('sfToolbarMainContent-' + token).style.display = 'block'; - document.getElementById('sfToolbarClearer-' + token).style.display = 'block'; - document.getElementById('sfMiniToolbar-' + token).style.display = 'none'; + addClass(sfwdt, 'sf-toolbar-opened'); + removeClass(sfwdt, 'sf-toolbar-closed'); } }, hideToolbar: function(token) { var sfwdt = this.getSfwdt(token); - addClass(sfwdt, 'sf-display-none'); + addClass(sfwdt, 'sf-toolbar-closed'); + removeClass(sfwdt, 'sf-toolbar-opened'); }, initToolbar: function(token) { this.showToolbar(token); - var hideButton = document.getElementById('sfToolbarHideButton-' + token); - var hideButtonSvg = hideButton.querySelector('svg'); - hideButtonSvg.setAttribute('aria-hidden', 'true'); - hideButtonSvg.setAttribute('focusable', 'false'); - addEventListener(hideButton, 'click', function (event) { - event.preventDefault(); - - var p = this.parentNode; - p.style.display = 'none'; - (p.previousElementSibling || p.previousSibling).style.display = 'none'; - document.getElementById('sfMiniToolbar-' + token).style.display = 'block'; - setPreference('toolbar/displayState', 'none'); - }); - - var showButton = document.getElementById('sfToolbarMiniToggler-' + token); - var showButtonSvg = showButton.querySelector('svg'); - showButtonSvg.setAttribute('aria-hidden', 'true'); - showButtonSvg.setAttribute('focusable', 'false'); - addEventListener(showButton, 'click', function (event) { + var toggleButton = document.querySelector(`#sfToolbarToggleButton-${token}`); + addEventListener(toggleButton, 'click', function (event) { event.preventDefault(); - var elem = this.parentNode; - if (elem.style.display == 'none') { - document.getElementById('sfToolbarMainContent-' + token).style.display = 'none'; - document.getElementById('sfToolbarClearer-' + token).style.display = 'none'; - elem.style.display = 'block'; - } else { - document.getElementById('sfToolbarMainContent-' + token).style.display = 'block'; - document.getElementById('sfToolbarClearer-' + token).style.display = 'block'; - elem.style.display = 'none' - } - - setPreference('toolbar/displayState', 'block'); + const newState = 'opened' === getPreference('toolbar/displayState') ? 'closed' : 'opened'; + setPreference('toolbar/displayState', newState); + 'opened' === newState ? Sfjs.showToolbar(token) : Sfjs.hideToolbar(token); }); }, @@ -655,3 +624,4 @@ Sfjs.loadToolbar('{{ token }}'); /*]]>*/ + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php index ff9bd096fb13f..981c85beed41f 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php @@ -63,6 +63,7 @@ public static function getInjectToolbarTests() public function testHtmlRedirectionIsIntercepted($statusCode) { $response = new Response('Some content', $statusCode); + $response->headers->set('Location', 'https://example.com/'); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response); @@ -76,6 +77,7 @@ public function testHtmlRedirectionIsIntercepted($statusCode) public function testNonHtmlRedirectionIsNotIntercepted() { $response = new Response('Some content', '301'); + $response->headers->set('Location', 'https://example.com/'); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new ResponseEvent($this->createMock(Kernel::class), new Request([], [], ['_format' => 'json']), HttpKernelInterface::MAIN_REQUEST, $response); @@ -139,6 +141,7 @@ public function testToolbarIsNotInjectedOnContentDispositionAttachment() public function testToolbarIsNotInjectedOnRedirection($statusCode) { $response = new Response('', $statusCode); + $response->headers->set('Location', 'https://example.com/'); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Fixtures/hello_world.json b/src/Symfony/Bundle/WebProfilerBundle/Tests/Fixtures/hello_world.json new file mode 100644 index 0000000000000..56cc557387321 --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Fixtures/hello_world.json @@ -0,0 +1,4 @@ +[ + "Hello", + "World!" +] diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Fixtures/hello_world.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Fixtures/hello_world.php new file mode 100644 index 0000000000000..4d7bf8fdf167e --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Fixtures/hello_world.php @@ -0,0 +1,4 @@ +import(__DIR__.'/../../Resources/config/routing/profiler.xml')->prefix('/_profiler'); - $routes->import(__DIR__.'/../../Resources/config/routing/wdt.xml')->prefix('/_wdt'); + $routes->import(__DIR__.'/../../Resources/config/routing/profiler.php')->prefix('/_profiler'); + $routes->import(__DIR__.'/../../Resources/config/routing/wdt.php')->prefix('/_wdt'); $routes->add('_', '/')->controller('kernel::homepageController'); } @@ -55,7 +55,7 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa 'http_method_override' => false, 'php_errors' => ['log' => true], 'secret' => 'foo-secret', - 'profiler' => ['only_exceptions' => false], + 'profiler' => ['only_exceptions' => false, 'collect_serializer_data' => true], 'session' => ['handler_id' => null, 'storage_factory_id' => 'session.storage.factory.mock_file', 'cookie-secure' => 'auto', 'cookie-samesite' => 'lax'], 'router' => ['utf8' => true], ]; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/CodeExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/CodeExtensionTest.php index 7cdedfe85ef68..314deea4b9550 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/CodeExtensionTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/CodeExtensionTest.php @@ -129,6 +129,101 @@ public function testFormatFileIntegration() $this->assertEquals($expected, $this->render($template)); } + /** + * @dataProvider fileExcerptIntegrationProvider + */ + public function testFileExcerptIntegration(string $expected, array $data) + { + $template = <<<'TWIG' +{{ file_path|file_excerpt(line, src_context) }} +TWIG; + $html = $this->render($template, $data); + + // highlight_file function output changed sing PHP 8.3 + // see https://github.com/php/php-src/blob/e2667f17bc24e3cd200bb3eda457f566f1f77f8f/UPGRADING#L239-L242 + if (\PHP_VERSION_ID < 80300) { + $html = str_replace(' ', ' ', $html); + } + + $html = html_entity_decode($html); + + $this->assertEquals($expected, $html); + } + + public static function fileExcerptIntegrationProvider() + { + $fixturesPath = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'; + + yield 'php file' => [ + 'expected' => <<<'HTML' +
  1. +
  2. +
  3. echo 'Hello';
  4. +
  5. echo 'World!';
  6. +
+HTML, + 'data' => [ + 'file_path' => $fixturesPath.\DIRECTORY_SEPARATOR.'hello_world.php', + 'line' => 0, + 'src_context' => 3, + ], + ]; + + yield 'php file with selected line and no source context' => [ + 'expected' => <<<'HTML' +
  1. +
  2. +
  3. echo 'Hello';
  4. +
  5. echo 'World!';
  6. +
+HTML, + 'data' => [ + 'file_path' => $fixturesPath.\DIRECTORY_SEPARATOR.'hello_world.php', + 'line' => 1, + 'src_context' => -1, + ], + ]; + + yield 'php file excerpt with selected line and custom source context' => [ + 'expected' => <<<'HTML' +
  1. echo 'Hello';
  2. +
  3. echo 'World!';
  4. +
+HTML, + 'data' => [ + 'file_path' => $fixturesPath.\DIRECTORY_SEPARATOR.'hello_world.php', + 'line' => 3, + 'src_context' => 1, + ], + ]; + + yield 'php file excerpt with out of bound selected line' => [ + 'expected' => <<<'HTML' +
    +HTML, + 'data' => [ + 'file_path' => $fixturesPath.\DIRECTORY_SEPARATOR.'hello_world.php', + 'line' => 100, + 'src_context' => 1, + ], + ]; + + yield 'json file' => [ + 'expected' => <<<'HTML' +
    1. [
    2. +
    3. "Hello",
    4. +
    5. "World!"
    6. +
    7. ]
    8. +
    +HTML, + 'data' => [ + 'file_path' => $fixturesPath.\DIRECTORY_SEPARATOR.'hello_world.json', + 'line' => 0, + 'src_context' => 3, + ], + ]; + } + public function testFormatFileFromTextIntegration() { $template = <<<'TWIG' diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json index ce94b4b62ebbb..00269dd279d45 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/composer.json +++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json @@ -17,7 +17,9 @@ ], "require": { "php": ">=8.2", - "symfony/config": "^6.4|^7.0", + "composer-runtime-api": ">=2.1", + "symfony/config": "^7.3", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/framework-bundle": "^6.4|^7.0", "symfony/http-kernel": "^6.4|^7.0", "symfony/routing": "^6.4|^7.0", @@ -34,7 +36,8 @@ "symfony/form": "<6.4", "symfony/mailer": "<6.4", "symfony/messenger": "<6.4", - "symfony/serializer": "<7.2" + "symfony/serializer": "<7.2", + "symfony/workflow": "<7.3" }, "autoload": { "psr-4": { "Symfony\\Bundle\\WebProfilerBundle\\": "" }, diff --git a/src/Symfony/Component/Asset/Tests/Context/NullContextTest.php b/src/Symfony/Component/Asset/Tests/Context/NullContextTest.php index 4623412f57952..b363eb5c61a17 100644 --- a/src/Symfony/Component/Asset/Tests/Context/NullContextTest.php +++ b/src/Symfony/Component/Asset/Tests/Context/NullContextTest.php @@ -20,7 +20,7 @@ public function testGetBasePath() { $nullContext = new NullContext(); - $this->assertEmpty($nullContext->getBasePath()); + $this->assertSame('', $nullContext->getBasePath()); } public function testIsSecure() diff --git a/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php b/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php index cd1f5609eb43b..4a7f555979ac7 100644 --- a/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php +++ b/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php @@ -22,7 +22,7 @@ public function testGetBasePathEmpty() { $requestStackContext = new RequestStackContext(new RequestStack()); - $this->assertEmpty($requestStackContext->getBasePath()); + $this->assertSame('', $requestStackContext->getBasePath()); } public function testGetBasePathSet() diff --git a/src/Symfony/Component/Asset/Tests/VersionStrategy/EmptyVersionStrategyTest.php b/src/Symfony/Component/Asset/Tests/VersionStrategy/EmptyVersionStrategyTest.php index 1728c2e99b4d4..f19d6470eae91 100644 --- a/src/Symfony/Component/Asset/Tests/VersionStrategy/EmptyVersionStrategyTest.php +++ b/src/Symfony/Component/Asset/Tests/VersionStrategy/EmptyVersionStrategyTest.php @@ -21,7 +21,7 @@ public function testGetVersion() $emptyVersionStrategy = new EmptyVersionStrategy(); $path = 'test-path'; - $this->assertEmpty($emptyVersionStrategy->getVersion($path)); + $this->assertSame('', $emptyVersionStrategy->getVersion($path)); } public function testApplyVersion() diff --git a/src/Symfony/Component/AssetMapper/CHANGELOG.md b/src/Symfony/Component/AssetMapper/CHANGELOG.md index dce7c57aad41e..93d622101c0c8 100644 --- a/src/Symfony/Component/AssetMapper/CHANGELOG.md +++ b/src/Symfony/Component/AssetMapper/CHANGELOG.md @@ -5,6 +5,8 @@ CHANGELOG --- * Add support for pre-compressing assets with Brotli, Zstandard, Zopfli, and gzip + * Add option `--dry-run` to `importmap:require` command + * `ImportMapRequireCommand` now takes `projectDir` as a required third constructor argument 7.2 --- diff --git a/src/Symfony/Component/AssetMapper/Command/ImportMapRequireCommand.php b/src/Symfony/Component/AssetMapper/Command/ImportMapRequireCommand.php index b3ccb1de2b96a..3a1efabc9cd7b 100644 --- a/src/Symfony/Component/AssetMapper/Command/ImportMapRequireCommand.php +++ b/src/Symfony/Component/AssetMapper/Command/ImportMapRequireCommand.php @@ -11,6 +11,7 @@ namespace Symfony\Component\AssetMapper\Command; +use Symfony\Component\AssetMapper\ImportMap\ImportMapEntries; use Symfony\Component\AssetMapper\ImportMap\ImportMapEntry; use Symfony\Component\AssetMapper\ImportMap\ImportMapManager; use Symfony\Component\AssetMapper\ImportMap\ImportMapVersionChecker; @@ -22,6 +23,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\Filesystem\Path; /** * @author Kévin Dunglas @@ -34,7 +36,12 @@ final class ImportMapRequireCommand extends Command public function __construct( private readonly ImportMapManager $importMapManager, private readonly ImportMapVersionChecker $importMapVersionChecker, + private readonly ?string $projectDir = null, ) { + if (null === $projectDir) { + trigger_deprecation('symfony/asset-mapper', '7.3', 'The "%s()" method will have a new `string $projectDir` argument in version 8.0, not defining it is deprecated.', __METHOD__); + } + parent::__construct(); } @@ -42,8 +49,9 @@ protected function configure(): void { $this ->addArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'The packages to add') - ->addOption('entrypoint', null, InputOption::VALUE_NONE, 'Make the package(s) an entrypoint?') + ->addOption('entrypoint', null, InputOption::VALUE_NONE, 'Make the packages an entrypoint?') ->addOption('path', null, InputOption::VALUE_REQUIRED, 'The local path where the package lives relative to the project root') + ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Simulate the installation of the packages') ->setHelp(<<<'EOT' The %command.name% command adds packages to importmap.php usually by finding a CDN URL for the given package and version. @@ -72,6 +80,11 @@ protected function configure(): void php %command.full_name% "any_module_name" --path=./assets/some_file.js +To simulate the installation, use the --dry-run option: + + php %command.full_name% "any_module_name" --dry-run -v + +When this option is enabled, this command does not perform any write operations to the filesystem. EOT ); } @@ -92,6 +105,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $path = $input->getOption('path'); } + if ($input->getOption('dry-run')) { + $io->writeln(['', '[DRY-RUN] No changes will apply to the importmap configuration.', '']); + } + $packages = []; foreach ($packageList as $packageName) { $parts = ImportMapManager::parsePackageName($packageName); @@ -110,21 +127,34 @@ protected function execute(InputInterface $input, OutputInterface $output): int ); } - $newPackages = $this->importMapManager->require($packages); + if ($input->getOption('dry-run')) { + $newPackages = $this->importMapManager->requirePackages($packages, new ImportMapEntries()); + } else { + $newPackages = $this->importMapManager->require($packages); + } $this->renderVersionProblems($this->importMapVersionChecker, $output); - if (1 === \count($newPackages)) { - $newPackage = $newPackages[0]; - $message = \sprintf('Package "%s" added to importmap.php', $newPackage->importName); + $newPackageNames = array_map(fn (ImportMapEntry $package): string => $package->importName, $newPackages); - $message .= '.'; + if (1 === \count($newPackages)) { + $messages = [\sprintf('Package "%s" added to importmap.php.', $newPackageNames[0])]; } else { - $names = array_map(fn (ImportMapEntry $package) => $package->importName, $newPackages); - $message = \sprintf('%d new items (%s) added to the importmap.php!', \count($newPackages), implode(', ', $names)); + $messages = [\sprintf('%d new items (%s) added to the importmap.php!', \count($newPackages), implode(', ', $newPackageNames))]; } - $messages = [$message]; + if ($io->isVerbose()) { + $io->table( + ['Package', 'Version', 'Path'], + array_map(fn (ImportMapEntry $package): array => [ + $package->importName, + $package->version ?? '-', + // BC layer for AssetMapper < 7.3 + // When `projectDir` is not null, we use the absolute path of the package + null !== $this->projectDir ? Path::makeRelative($package->path, $this->projectDir) : $package->path, + ], $newPackages), + ); + } if (1 === \count($newPackages)) { $messages[] = \sprintf('Use the new package normally by importing "%s".', $newPackages[0]->importName); @@ -132,6 +162,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io->success($messages); + if ($input->getOption('dry-run')) { + $io->writeln(['[DRY-RUN] No changes applied to the importmap configuration.', '']); + } + return Command::SUCCESS; } } diff --git a/src/Symfony/Component/AssetMapper/Compiler/Parser/JavascriptSequenceParser.php b/src/Symfony/Component/AssetMapper/Compiler/Parser/JavascriptSequenceParser.php index 943c0eea14f51..6980e661500c3 100644 --- a/src/Symfony/Component/AssetMapper/Compiler/Parser/JavascriptSequenceParser.php +++ b/src/Symfony/Component/AssetMapper/Compiler/Parser/JavascriptSequenceParser.php @@ -133,36 +133,36 @@ public function parseUntil(int $position): void continue; } - // Single-line string - if ('"' === $matchChar || "'" === $matchChar) { - if (false === $endPos = strpos($this->content, $matchChar, $matchPos + 1)) { - $this->endsWithSequence(self::STATE_STRING, $position); - - return; + if ('"' === $matchChar || "'" === $matchChar || '`' === $matchChar) { + $endPos = $matchPos + 1; + while (false !== $endPos = strpos($this->content, $matchChar, $endPos)) { + $backslashes = 0; + $i = $endPos - 1; + while ($i >= 0 && '\\' === $this->content[$i]) { + ++$backslashes; + --$i; + } + + if (0 === $backslashes % 2) { + break; + } + + ++$endPos; } - while (false !== $endPos && '\\' == $this->content[$endPos - 1]) { - $endPos = strpos($this->content, $matchChar, $endPos + 1); - } - - $this->cursor = min($endPos + 1, $position); - $this->setSequence(self::STATE_STRING, $endPos + 1); - continue; - } - // Multi-line string - if ('`' === $matchChar) { - if (false === $endPos = strpos($this->content, $matchChar, $matchPos + 1)) { + if (false === $endPos) { $this->endsWithSequence(self::STATE_STRING, $position); return; } - while (false !== $endPos && '\\' == $this->content[$endPos - 1]) { - $endPos = strpos($this->content, $matchChar, $endPos + 1); - } $this->cursor = min($endPos + 1, $position); $this->setSequence(self::STATE_STRING, $endPos + 1); + continue; } + + // Fallback + $this->cursor = $matchPos + 1; } } diff --git a/src/Symfony/Component/AssetMapper/ImportMap/ImportMapManager.php b/src/Symfony/Component/AssetMapper/ImportMap/ImportMapManager.php index 4a12a6a083728..00c265bc4635d 100644 --- a/src/Symfony/Component/AssetMapper/ImportMap/ImportMapManager.php +++ b/src/Symfony/Component/AssetMapper/ImportMap/ImportMapManager.php @@ -128,13 +128,15 @@ private function updateImportMapConfig(bool $update, array $packagesToRequire, a } /** + * @internal + * * Gets information about (and optionally downloads) the packages & updates the entries. * * Returns an array of the entries that were added. * * @param PackageRequireOptions[] $packagesToRequire */ - private function requirePackages(array $packagesToRequire, ImportMapEntries $importMapEntries): array + public function requirePackages(array $packagesToRequire, ImportMapEntries $importMapEntries): array { if (!$packagesToRequire) { return []; diff --git a/src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php b/src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php index f2e4da9b96b49..a707eb108349a 100644 --- a/src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php +++ b/src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php @@ -28,7 +28,7 @@ final class JsDelivrEsmResolver implements PackageResolverInterface public const URL_PATTERN_DIST = self::URL_PATTERN_DIST_CSS.'/+esm'; public const URL_PATTERN_ENTRYPOINT = 'https://data.jsdelivr.com/v1/packages/npm/%s@%s/entrypoints'; - public const IMPORT_REGEX = '#(?:import\s*(?:[\w$]+,)?(?:(?:\{[^}]*\}|[\w$]+|\*\s*as\s+[\w$]+)\s*\bfrom\s*)?|export\s*(?:\{[^}]*\}|\*)\s*from\s*)("/npm/((?:@[^/]+/)?[^@]+?)(?:@([^/]+))?((?:/[^/]+)*?)/\+esm")#'; + public const IMPORT_REGEX = '#(?:import\s*(?:[\w$]+,)?(?:(?:\{[^}]*\}|[\w$]+|\*\s*as\s+[\w$]+)\s*\bfrom\s*)?|export\s*(?:\{[^}]*\}|\*)\s*from\s*|await\simport\()("/npm/((?:@[^/]+/)?[^@]+?)(?:@([^/]+))?((?:/[^/]+)*?)/\+esm")(?:\)*)#'; private const ES_MODULE_SHIMS = 'es-module-shims'; @@ -184,6 +184,7 @@ public function downloadPackages(array $importMapEntries, ?callable $progressCal $errors = []; $contents = []; $extraFileResponses = []; + /** @var ImportMapEntry $entry */ foreach ($responses as $package => [$response, $entry]) { if (200 !== $response->getStatusCode()) { $errors[] = [$package, $response]; @@ -196,7 +197,6 @@ public function downloadPackages(array $importMapEntries, ?callable $progressCal $dependencies = []; $extraFiles = []; - /* @var ImportMapEntry $entry */ $contents[$package] = [ 'content' => $this->makeImportsBare($response->getContent(), $dependencies, $extraFiles, $entry->type, $entry->getPackagePathString()), 'dependencies' => $dependencies, diff --git a/src/Symfony/Component/AssetMapper/Tests/Command/ImportMapRequireCommandTest.php b/src/Symfony/Component/AssetMapper/Tests/Command/ImportMapRequireCommandTest.php new file mode 100644 index 0000000000000..fb410bafab2a4 --- /dev/null +++ b/src/Symfony/Component/AssetMapper/Tests/Command/ImportMapRequireCommandTest.php @@ -0,0 +1,218 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\AssetMapper\Tests\Command; + +use PHPUnit\Framework\Attributes\DataProvider; +use Symfony\Bundle\FrameworkBundle\Console\Application; +use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +use Symfony\Component\AssetMapper\Command\ImportMapRequireCommand; +use Symfony\Component\AssetMapper\ImportMap\ImportMapEntry; +use Symfony\Component\AssetMapper\ImportMap\ImportMapManager; +use Symfony\Component\AssetMapper\ImportMap\ImportMapType; +use Symfony\Component\AssetMapper\ImportMap\ImportMapVersionChecker; +use Symfony\Component\AssetMapper\Tests\Fixtures\ImportMapTestAppKernel; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Finder\Finder; + +class ImportMapRequireCommandTest extends KernelTestCase +{ + protected static function getKernelClass(): string + { + return ImportMapTestAppKernel::class; + } + + /** + * @dataProvider getRequirePackageTests + */ + public function testDryRunOptionToShowInformationBeforeApplyInstallation(int $verbosity, array $packageEntries, array $packagesToInstall, string $expected, ?string $path = null) + { + $importMapManager = $this->createMock(ImportMapManager::class); + $importMapManager + ->method('requirePackages') + ->willReturn($packageEntries) + ; + + $command = new ImportMapRequireCommand( + $importMapManager, + $this->createMock(ImportMapVersionChecker::class), + '/path/to/project/dir', + ); + + $args = [ + 'packages' => $packagesToInstall, + '--dry-run' => true, + ]; + if ($path) { + $args['--path'] = $path; + } + + $commandTester = new CommandTester($command); + $commandTester->execute($args, ['verbosity' => $verbosity]); + + $commandTester->assertCommandIsSuccessful(); + + $output = $commandTester->getDisplay(); + $this->assertEquals($this->trimBeginEndOfEachLine($expected), $this->trimBeginEndOfEachLine($output)); + } + + public static function getRequirePackageTests(): iterable + { + yield 'require package with dry run and normal verbosity options' => [ + OutputInterface::VERBOSITY_NORMAL, + [self::createRemoteEntry('bootstrap', '4.2.3', 'assets/vendor/bootstrap/bootstrap.js')], + ['bootstrap'], << [ + OutputInterface::VERBOSITY_VERBOSE, + [self::createRemoteEntry('bootstrap', '5.3.3', 'assets/vendor/bootstrap/bootstrap.js')], + ['bootstrap'], << [ + OutputInterface::VERBOSITY_VERBOSE, + [ImportMapEntry::createLocal('alice.js', ImportMapType::JS, 'assets/js/alice.js', false)], + ['alice.js'], << [ + OutputInterface::VERBOSITY_NORMAL, [ + self::createRemoteEntry('bootstrap', '5.3.3', 'assets/vendor/bootstrap/bootstrap.index.js'), + self::createRemoteEntry('lodash', '4.17.20', 'assets/vendor/lodash/lodash.index.js'), + ], + ['bootstrap lodash@4.17.21'], << [ + OutputInterface::VERBOSITY_VERBOSE, [ + self::createRemoteEntry('bootstrap', '5.3.3', 'assets/vendor/bootstrap/bootstrap.js'), + self::createRemoteEntry('lodash', '4.17.20', 'assets/vendor/lodash/lodash.index.js'), + ], + ['bootstrap lodash@4.17.21'], <<getProjectDir(); + + $fs = new Filesystem(); + $fs->mkdir($projectDir.'/public'); + + $fs->dumpFile($projectDir.'/public/assets/manifest.json', '{}'); + $fs->dumpFile($projectDir.'/public/assets/importmap.json', '{}'); + + $importMapManager = $this->createMock(ImportMapManager::class); + $importMapManager + ->expects($this->once()) + ->method('requirePackages') + ->willReturn([self::createRemoteEntry('bootstrap', '5.3.3', 'assets/vendor/bootstrap/bootstrap.index.js')]); + + self::getContainer()->set(ImportMapManager::class, $importMapManager); + + $application = new Application(self::$kernel); + $command = $application->find('importmap:require'); + + $importMapContentBefore = $fs->readFile($projectDir.'/importmap.php'); + $installedVendorBefore = $fs->readFile($projectDir.'/assets/vendor/installed.php'); + + $tester = new CommandTester($command); + $tester->execute(['packages' => ['bootstrap'], '--dry-run' => true]); + + $tester->assertCommandIsSuccessful(); + + $this->assertSame($importMapContentBefore, $fs->readFile($projectDir.'/importmap.php')); + $this->assertSame($installedVendorBefore, $fs->readFile($projectDir.'/assets/vendor/installed.php')); + + $this->assertSame('{}', $fs->readFile($projectDir.'/public/assets/manifest.json')); + $this->assertSame('{}', $fs->readFile($projectDir.'/public/assets/importmap.json')); + + $finder = new Finder(); + $finder->in($projectDir.'/public/assets')->files()->depth(0); + + $this->assertCount(2, $finder); // manifest.json + importmap.json + + $fs->remove($projectDir.'/public'); + $fs->remove($projectDir.'/var'); + + static::$kernel->shutdown(); + } + + private static function createRemoteEntry(string $importName, string $version, ?string $path = null): ImportMapEntry + { + return ImportMapEntry::createRemote($importName, ImportMapType::JS, path: $path, version: $version, packageModuleSpecifier: $importName, isEntrypoint: false); + } + + private function trimBeginEndOfEachLine(string $lines): string + { + return trim(implode("\n", array_map('trim', explode("\n", $lines)))); + } +} diff --git a/src/Symfony/Component/AssetMapper/Tests/Compiler/Parser/JavascriptSequenceParserTest.php b/src/Symfony/Component/AssetMapper/Tests/Compiler/Parser/JavascriptSequenceParserTest.php index cd9c88ff72593..794b7bbf61d94 100644 --- a/src/Symfony/Component/AssetMapper/Tests/Compiler/Parser/JavascriptSequenceParserTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/Compiler/Parser/JavascriptSequenceParserTest.php @@ -230,5 +230,10 @@ public static function provideStringCases(): iterable 3, false, ]; + yield 'after unclosed string' => [ + '"hello', + 6, + true, + ]; } } diff --git a/src/Symfony/Component/AssetMapper/Tests/Fixtures/AssetMapperTestAppKernel.php b/src/Symfony/Component/AssetMapper/Tests/Fixtures/AssetMapperTestAppKernel.php index 48958274572d3..426e97b810cfd 100644 --- a/src/Symfony/Component/AssetMapper/Tests/Fixtures/AssetMapperTestAppKernel.php +++ b/src/Symfony/Component/AssetMapper/Tests/Fixtures/AssetMapperTestAppKernel.php @@ -44,7 +44,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void 'assets' => null, 'asset_mapper' => [ 'paths' => ['dir1', 'dir2', 'non_ascii', 'assets'], - 'public_prefix' => 'assets' + 'public_prefix' => 'assets', ], 'test' => true, ]); diff --git a/src/Symfony/Component/AssetMapper/Tests/Fixtures/ImportMapTestAppKernel.php b/src/Symfony/Component/AssetMapper/Tests/Fixtures/ImportMapTestAppKernel.php new file mode 100644 index 0000000000000..42d4b65d2af6a --- /dev/null +++ b/src/Symfony/Component/AssetMapper/Tests/Fixtures/ImportMapTestAppKernel.php @@ -0,0 +1,56 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\AssetMapper\Tests\Fixtures; + +use Psr\Log\NullLogger; +use Symfony\Bundle\FrameworkBundle\FrameworkBundle; +use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpKernel\Kernel; + +class ImportMapTestAppKernel extends Kernel +{ + public function registerBundles(): iterable + { + return [ + new FrameworkBundle(), + ]; + } + + public function getProjectDir(): string + { + return __DIR__; + } + + public function registerContainerConfiguration(LoaderInterface $loader): void + { + $loader->load(static function (ContainerBuilder $container) { + $container->loadFromExtension('framework', [ + 'annotations' => false, + 'http_method_override' => false, + 'handle_all_throwables' => true, + 'php_errors' => ['log' => true], + 'http_client' => true, + 'assets' => null, + 'asset_mapper' => [ + 'paths' => ['assets'], + ], + 'test' => true, + ]); + }); + } + + protected function build(ContainerBuilder $container): void + { + $container->register('logger', NullLogger::class); + } +} diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapManagerTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapManagerTest.php index c2805f937de8b..e6084fc7c1e87 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapManagerTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapManagerTest.php @@ -248,7 +248,7 @@ public function testUpdateAll() ->method('resolvePackages') ->with($this->callback(function ($packages) { $this->assertInstanceOf(PackageRequireOptions::class, $packages[0]); - /* @var PackageRequireOptions[] $packages */ + /** @var PackageRequireOptions[] $packages */ $this->assertCount(2, $packages); $this->assertSame('lodash', $packages[0]->packageModuleSpecifier); diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php index a83ecf0ae5f43..ffb153fe54366 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php @@ -693,6 +693,13 @@ public static function provideImportRegex(): iterable ['jquery', '3.7.0'], ], ]; + + yield 'dynamic import with path' => [ + 'return(await import("/npm/@datadog/browser-rum@6.3.0/esm/boot/startRecording.js/+esm")).startRecording', + [ + ['@datadog/browser-rum/esm/boot/startRecording.js', '6.3.0'], + ], + ]; } private static function createRemoteEntry(string $importName, string $version, ImportMapType $type = ImportMapType::JS, ?string $packageSpecifier = null): ImportMapEntry diff --git a/src/Symfony/Component/BrowserKit/AbstractBrowser.php b/src/Symfony/Component/BrowserKit/AbstractBrowser.php index 9257ef561b05e..68cc417e41a0f 100644 --- a/src/Symfony/Component/BrowserKit/AbstractBrowser.php +++ b/src/Symfony/Component/BrowserKit/AbstractBrowser.php @@ -163,7 +163,7 @@ public function xmlHttpRequest(string $method, string $uri, array $parameters = */ public function jsonRequest(string $method, string $uri, array $parameters = [], array $server = [], bool $changeHistory = true): Crawler { - $content = json_encode($parameters); + $content = json_encode($parameters, \JSON_PRESERVE_ZERO_FRACTION); $this->setServerParameter('CONTENT_TYPE', 'application/json'); $this->setServerParameter('HTTP_ACCEPT', 'application/json'); @@ -461,10 +461,10 @@ abstract protected function doRequest(object $request); /** * Returns the script to execute when the request must be insulated. * - * @psalm-param TRequest $request - * * @param object $request An origin request instance * + * @psalm-param TRequest $request + * * @return string * * @throws LogicException When this abstract class is not implemented diff --git a/src/Symfony/Component/BrowserKit/HttpBrowser.php b/src/Symfony/Component/BrowserKit/HttpBrowser.php index c143a69e28fd4..4f044421e00e9 100644 --- a/src/Symfony/Component/BrowserKit/HttpBrowser.php +++ b/src/Symfony/Component/BrowserKit/HttpBrowser.php @@ -145,10 +145,15 @@ private function getUploadedFiles(array $files): array } if (!isset($file['tmp_name'])) { $uploadedFiles[$name] = $this->getUploadedFiles($file); + continue; } - if (isset($file['tmp_name'])) { - $uploadedFiles[$name] = DataPart::fromPath($file['tmp_name'], $file['name']); + + if ('' === $file['tmp_name']) { + $uploadedFiles[$name] = new DataPart('', ''); + continue; } + + $uploadedFiles[$name] = DataPart::fromPath($file['tmp_name'], $file['name']); } return $uploadedFiles; diff --git a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php index ca822e245d6ef..dd7f8e4615f24 100644 --- a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php @@ -68,12 +68,12 @@ public function testXmlHttpRequest() public function testJsonRequest() { $client = $this->getBrowser(); - $client->jsonRequest('GET', 'http://example.com/', ['param' => 1], [], true); + $client->jsonRequest('GET', 'http://example.com/', ['param' => 1, 'float' => 10.0], [], true); $this->assertSame('application/json', $client->getRequest()->getServer()['CONTENT_TYPE']); $this->assertSame('application/json', $client->getRequest()->getServer()['HTTP_ACCEPT']); $this->assertFalse($client->getServerParameter('CONTENT_TYPE', false)); $this->assertFalse($client->getServerParameter('HTTP_ACCEPT', false)); - $this->assertSame('{"param":1}', $client->getRequest()->getContent()); + $this->assertSame('{"param":1,"float":10.0}', $client->getRequest()->getContent()); } public function testGetRequestWithIpAsHttpHost() @@ -642,10 +642,10 @@ public function testFollowRedirectDropPostMethod() $client->request('POST', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content); $this->assertSame('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect with POST method on response code: '.$code.'.'); - $this->assertEmpty($client->getRequest()->getParameters(), '->followRedirect() drops parameters with POST method on response code: '.$code.'.'); - $this->assertEmpty($client->getRequest()->getFiles(), '->followRedirect() drops files with POST method on response code: '.$code.'.'); + $this->assertSame([], $client->getRequest()->getParameters(), '->followRedirect() drops parameters with POST method on response code: '.$code.'.'); + $this->assertSame([], $client->getRequest()->getFiles(), '->followRedirect() drops files with POST method on response code: '.$code.'.'); $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->followRedirect() keeps $_SERVER with POST method on response code: '.$code.'.'); - $this->assertEmpty($client->getRequest()->getContent(), '->followRedirect() drops content with POST method on response code: '.$code.'.'); + $this->assertNull($client->getRequest()->getContent(), '->followRedirect() drops content with POST method on response code: '.$code.'.'); $this->assertSame('GET', $client->getRequest()->getMethod(), '->followRedirect() drops request method to GET on response code: '.$code.'.'); } } diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php index 2f0ebaf6a77d1..2e456b82f2e9f 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php @@ -247,6 +247,6 @@ public function testCookieWithWildcardDomain() $cookieJar->set(new Cookie('foo', 'bar', null, '/', '.example.com')); $this->assertEquals(['foo' => 'bar'], $cookieJar->allValues('http://www.example.com')); - $this->assertEmpty($cookieJar->allValues('http://wwwexample.com')); + $this->assertSame([], $cookieJar->allValues('http://wwwexample.com')); } } diff --git a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php index e1f19b16ce814..3a2547d89f488 100644 --- a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php @@ -14,6 +14,8 @@ use Symfony\Component\BrowserKit\CookieJar; use Symfony\Component\BrowserKit\History; use Symfony\Component\BrowserKit\HttpBrowser; +use Symfony\Component\HttpClient\MockHttpClient; +use Symfony\Component\HttpClient\Response\MockResponse; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -208,6 +210,37 @@ public static function forwardSlashesRequestPathProvider() ]; } + public function testEmptyUpload() + { + $client = new MockHttpClient(function ($method, $url, $options) { + $this->assertSame('POST', $method); + $this->assertSame('http://localhost/', $url); + $this->assertStringStartsWith('Content-Type: multipart/form-data; boundary=', $options['normalized_headers']['content-type'][0]); + + $body = ''; + while ('' !== $data = $options['body'](1024)) { + $body .= $data; + } + + $expected = <<assertStringMatchesFormat($expected, $body); + + return new MockResponse(); + }); + + $browser = new HttpBrowser($client); + $browser->request('POST', '/', [], ['file' => ['tmp_name' => '', 'name' => 'file']]); + } + private function uploadFile(string $data): string { $path = tempnam(sys_get_temp_dir(), 'http'); diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index c03868da12535..2b4bc8b22440f 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -19,11 +19,12 @@ use Symfony\Component\Cache\Traits\AbstractAdapterTrait; use Symfony\Component\Cache\Traits\ContractsTrait; use Symfony\Contracts\Cache\CacheInterface; +use Symfony\Contracts\Cache\NamespacedPoolInterface; /** * @author Nicolas Grekas */ -abstract class AbstractAdapter implements AdapterInterface, CacheInterface, LoggerAwareInterface, ResettableInterface +abstract class AbstractAdapter implements AdapterInterface, CacheInterface, NamespacedPoolInterface, LoggerAwareInterface, ResettableInterface { use AbstractAdapterTrait; use ContractsTrait; @@ -37,7 +38,19 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg protected function __construct(string $namespace = '', int $defaultLifetime = 0) { - $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).static::NS_SEPARATOR; + if ('' !== $namespace) { + if (str_contains($namespace, static::NS_SEPARATOR)) { + if (str_contains($namespace, static::NS_SEPARATOR.static::NS_SEPARATOR)) { + throw new InvalidArgumentException(\sprintf('Cache namespace "%s" contains empty sub-namespace.', $namespace)); + } + CacheItem::validateKey(str_replace(static::NS_SEPARATOR, '', $namespace)); + } else { + CacheItem::validateKey($namespace); + } + $this->namespace = $namespace.static::NS_SEPARATOR; + } + $this->rootNamespace = $this->namespace; + $this->defaultLifetime = $defaultLifetime; if (null !== $this->maxIdLength && \strlen($namespace) > $this->maxIdLength - 24) { throw new InvalidArgumentException(\sprintf('Namespace must be %d chars max, %d given ("%s").', $this->maxIdLength - 24, \strlen($namespace), $namespace)); @@ -111,14 +124,14 @@ public static function createSystemCache(string $namespace, int $defaultLifetime public static function createConnection(#[\SensitiveParameter] string $dsn, array $options = []): mixed { - if (str_starts_with($dsn, 'redis:') || str_starts_with($dsn, 'rediss:')) { + if (str_starts_with($dsn, 'redis:') || str_starts_with($dsn, 'rediss:') || str_starts_with($dsn, 'valkey:') || str_starts_with($dsn, 'valkeys:')) { return RedisAdapter::createConnection($dsn, $options); } if (str_starts_with($dsn, 'memcached:')) { return MemcachedAdapter::createConnection($dsn, $options); } if (str_starts_with($dsn, 'couchbase:')) { - if (class_exists('CouchbaseBucket') && CouchbaseBucketAdapter::isSupported()) { + if (class_exists(\CouchbaseBucket::class) && CouchbaseBucketAdapter::isSupported()) { return CouchbaseBucketAdapter::createConnection($dsn, $options); } @@ -128,7 +141,7 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra return PdoAdapter::createConnection($dsn, $options); } - throw new InvalidArgumentException('Unsupported DSN: it does not start with "redis[s]:", "memcached:", "couchbase:", "mysql:", "oci:", "pgsql:", "sqlsrv:" nor "sqlite:".'); + throw new InvalidArgumentException('Unsupported DSN: it does not start with "redis[s]:", "valkey[s]:", "memcached:", "couchbase:", "mysql:", "oci:", "pgsql:", "sqlsrv:" nor "sqlite:".'); } public function commit(): bool @@ -159,7 +172,7 @@ public function commit(): bool $v = $values[$id]; $type = get_debug_type($v); $message = \sprintf('Failed to save key "{key}" of type %s%s', $type, $e instanceof \Exception ? ': '.$e->getMessage() : '.'); - CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e instanceof \Exception ? $e : null, 'cache-adapter' => get_debug_type($this)]); + CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->rootNamespace)), 'exception' => $e instanceof \Exception ? $e : null, 'cache-adapter' => get_debug_type($this)]); } } else { foreach ($values as $id => $v) { @@ -182,7 +195,7 @@ public function commit(): bool $ok = false; $type = get_debug_type($v); $message = \sprintf('Failed to save key "{key}" of type %s%s', $type, $e instanceof \Exception ? ': '.$e->getMessage() : '.'); - CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e instanceof \Exception ? $e : null, 'cache-adapter' => get_debug_type($this)]); + CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->rootNamespace)), 'exception' => $e instanceof \Exception ? $e : null, 'cache-adapter' => get_debug_type($this)]); } } diff --git a/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php index 822c30f09bdbd..23db2b6eb8c8a 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php @@ -17,6 +17,7 @@ use Symfony\Component\Cache\ResettableInterface; use Symfony\Component\Cache\Traits\AbstractAdapterTrait; use Symfony\Component\Cache\Traits\ContractsTrait; +use Symfony\Contracts\Cache\NamespacedPoolInterface; use Symfony\Contracts\Cache\TagAwareCacheInterface; /** @@ -30,16 +31,33 @@ * * @internal */ -abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterface, LoggerAwareInterface, ResettableInterface +abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterface, AdapterInterface, NamespacedPoolInterface, LoggerAwareInterface, ResettableInterface { use AbstractAdapterTrait; use ContractsTrait; + /** + * @internal + */ + protected const NS_SEPARATOR = ':'; + private const TAGS_PREFIX = "\1tags\1"; protected function __construct(string $namespace = '', int $defaultLifetime = 0) { - $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).':'; + if ('' !== $namespace) { + if (str_contains($namespace, static::NS_SEPARATOR)) { + if (str_contains($namespace, static::NS_SEPARATOR.static::NS_SEPARATOR)) { + throw new InvalidArgumentException(\sprintf('Cache namespace "%s" contains empty sub-namespace.', $namespace)); + } + CacheItem::validateKey(str_replace(static::NS_SEPARATOR, '', $namespace)); + } else { + CacheItem::validateKey($namespace); + } + $this->namespace = $namespace.static::NS_SEPARATOR; + } + $this->rootNamespace = $this->namespace; + $this->defaultLifetime = $defaultLifetime; if (null !== $this->maxIdLength && \strlen($namespace) > $this->maxIdLength - 24) { throw new InvalidArgumentException(\sprintf('Namespace must be %d chars max, %d given ("%s").', $this->maxIdLength - 24, \strlen($namespace), $namespace)); @@ -70,7 +88,7 @@ static function ($key, $value, $isHit) { CacheItem::class ); self::$mergeByLifetime ??= \Closure::bind( - static function ($deferred, &$expiredIds, $getId, $tagPrefix, $defaultLifetime) { + static function ($deferred, &$expiredIds, $getId, $tagPrefix, $defaultLifetime, $rootNamespace) { $byLifetime = []; $now = microtime(true); $expiredIds = []; @@ -102,10 +120,10 @@ static function ($deferred, &$expiredIds, $getId, $tagPrefix, $defaultLifetime) $value['tag-operations'] = ['add' => [], 'remove' => []]; $oldTags = $item->metadata[CacheItem::METADATA_TAGS] ?? []; foreach (array_diff_key($value['tags'], $oldTags) as $addedTag) { - $value['tag-operations']['add'][] = $getId($tagPrefix.$addedTag); + $value['tag-operations']['add'][] = $getId($tagPrefix.$addedTag, $rootNamespace); } foreach (array_diff_key($oldTags, $value['tags']) as $removedTag) { - $value['tag-operations']['remove'][] = $getId($tagPrefix.$removedTag); + $value['tag-operations']['remove'][] = $getId($tagPrefix.$removedTag, $rootNamespace); } $value['tags'] = array_keys($value['tags']); @@ -168,7 +186,7 @@ protected function doDeleteYieldTags(array $ids): iterable public function commit(): bool { $ok = true; - $byLifetime = (self::$mergeByLifetime)($this->deferred, $expiredIds, $this->getId(...), self::TAGS_PREFIX, $this->defaultLifetime); + $byLifetime = (self::$mergeByLifetime)($this->deferred, $expiredIds, $this->getId(...), self::TAGS_PREFIX, $this->defaultLifetime, $this->rootNamespace); $retry = $this->deferred = []; if ($expiredIds) { @@ -195,7 +213,7 @@ public function commit(): bool $v = $values[$id]; $type = get_debug_type($v); $message = \sprintf('Failed to save key "{key}" of type %s%s', $type, $e instanceof \Exception ? ': '.$e->getMessage() : '.'); - CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e instanceof \Exception ? $e : null, 'cache-adapter' => get_debug_type($this)]); + CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->rootNamespace)), 'exception' => $e instanceof \Exception ? $e : null, 'cache-adapter' => get_debug_type($this)]); } } else { foreach ($values as $id => $v) { @@ -219,7 +237,7 @@ public function commit(): bool $ok = false; $type = get_debug_type($v); $message = \sprintf('Failed to save key "{key}" of type %s%s', $type, $e instanceof \Exception ? ': '.$e->getMessage() : '.'); - CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e instanceof \Exception ? $e : null, 'cache-adapter' => get_debug_type($this)]); + CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->rootNamespace)), 'exception' => $e instanceof \Exception ? $e : null, 'cache-adapter' => get_debug_type($this)]); } } @@ -244,7 +262,7 @@ public function deleteItems(array $keys): bool try { foreach ($this->doDeleteYieldTags(array_values($ids)) as $id => $tags) { foreach ($tags as $tag) { - $tagData[$this->getId(self::TAGS_PREFIX.$tag)][] = $id; + $tagData[$this->getId(self::TAGS_PREFIX.$tag, $this->rootNamespace)][] = $id; } } } catch (\Exception) { @@ -283,7 +301,7 @@ public function invalidateTags(array $tags): bool $tagIds = []; foreach (array_unique($tags) as $tag) { - $tagIds[] = $this->getId(self::TAGS_PREFIX.$tag); + $tagIds[] = $this->getId(self::TAGS_PREFIX.$tag, $this->rootNamespace); } try { diff --git a/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php b/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php index ddb7210057df8..b234909fdadff 100644 --- a/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php @@ -98,19 +98,10 @@ protected function doSave(array $values, int $lifetime): array|bool return $failed; } - try { - if (false === $failures = apcu_store($values, null, $lifetime)) { - $failures = $values; - } - - return array_keys($failures); - } catch (\Throwable $e) { - if (1 === \count($values)) { - // Workaround https://github.com/krakjoe/apcu/issues/170 - apcu_delete(array_key_first($values)); - } - - throw $e; + if (false === $failures = apcu_store($values, null, $lifetime)) { + $failures = $values; } + + return array_keys($failures); } } diff --git a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php index 7b92387742894..c9ee94ee9c922 100644 --- a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php @@ -19,6 +19,7 @@ use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\ResettableInterface; use Symfony\Contracts\Cache\CacheInterface; +use Symfony\Contracts\Cache\NamespacedPoolInterface; /** * An in-memory cache storage. @@ -27,13 +28,14 @@ * * @author Nicolas Grekas */ -class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInterface, ResettableInterface +class ArrayAdapter implements AdapterInterface, CacheInterface, NamespacedPoolInterface, LoggerAwareInterface, ResettableInterface { use LoggerAwareTrait; private array $values = []; private array $tags = []; private array $expiries = []; + private array $subPools = []; private static \Closure $createCacheItem; @@ -226,16 +228,38 @@ public function clear(string $prefix = ''): bool } } - if ($this->values) { - return true; - } + return true; + } + + foreach ($this->subPools as $pool) { + $pool->clear(); } - $this->values = $this->tags = $this->expiries = []; + $this->subPools = $this->values = $this->tags = $this->expiries = []; return true; } + public function withSubNamespace(string $namespace): static + { + CacheItem::validateKey($namespace); + + $subPools = $this->subPools; + + if (isset($subPools[$namespace])) { + return $subPools[$namespace]; + } + + $this->subPools = []; + $clone = clone $this; + $clone->clear(); + + $subPools[$namespace] = $clone; + $this->subPools = $subPools; + + return $clone; + } + /** * Returns all cached values, with cache miss as null. */ @@ -263,6 +287,13 @@ public function reset(): void $this->clear(); } + public function __clone() + { + foreach ($this->subPools as $i => $pool) { + $this->subPools[$i] = clone $pool; + } + } + private function generateItems(array $keys, float $now, \Closure $f): \Generator { foreach ($keys as $i => $key) { @@ -307,7 +338,9 @@ private function freeze($value, string $key): string|int|float|bool|array|\UnitE try { $serialized = serialize($value); } catch (\Exception $e) { - unset($this->values[$key], $this->tags[$key]); + if (!isset($this->expiries[$key])) { + unset($this->values[$key]); + } $type = get_debug_type($value); $message = \sprintf('Failed to save key "{key}" of type %s: %s', $type, $e->getMessage()); CacheItem::log($this->logger, $message, ['key' => $key, 'exception' => $e, 'cache-adapter' => get_debug_type($this)]); diff --git a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php index 09fcfdcc07b88..c27faeb111617 100644 --- a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php @@ -14,11 +14,13 @@ use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\CacheItem; +use Symfony\Component\Cache\Exception\BadMethodCallException; use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; use Symfony\Component\Cache\Traits\ContractsTrait; use Symfony\Contracts\Cache\CacheInterface; +use Symfony\Contracts\Cache\NamespacedPoolInterface; use Symfony\Contracts\Service\ResetInterface; /** @@ -29,7 +31,7 @@ * * @author Kévin Dunglas */ -class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterface, ResettableInterface +class ChainAdapter implements AdapterInterface, CacheInterface, NamespacedPoolInterface, PruneableInterface, ResettableInterface { use ContractsTrait; @@ -280,6 +282,23 @@ public function prune(): bool return $pruned; } + public function withSubNamespace(string $namespace): static + { + $clone = clone $this; + $adapters = []; + + foreach ($this->adapters as $adapter) { + if (!$adapter instanceof NamespacedPoolInterface) { + throw new BadMethodCallException('All adapters must implement NamespacedPoolInterface to support namespaces.'); + } + + $adapters[] = $adapter->withSubNamespace($namespace); + } + $clone->adapters = $adapters; + + return $clone; + } + public function reset(): void { foreach ($this->adapters as $adapter) { diff --git a/src/Symfony/Component/Cache/Adapter/DoctrineDbalAdapter.php b/src/Symfony/Component/Cache/Adapter/DoctrineDbalAdapter.php index c69c777c993e7..8e52dfee240a0 100644 --- a/src/Symfony/Component/Cache/Adapter/DoctrineDbalAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/DoctrineDbalAdapter.php @@ -19,6 +19,9 @@ use Doctrine\DBAL\Exception\TableNotFoundException; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory; +use Doctrine\DBAL\Schema\Name\Identifier; +use Doctrine\DBAL\Schema\Name\UnqualifiedName; +use Doctrine\DBAL\Schema\PrimaryKeyConstraint; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Tools\DsnParser; use Symfony\Component\Cache\Exception\InvalidArgumentException; @@ -335,17 +338,17 @@ protected function doSave(array $values, int $lifetime): array|bool /** * @internal */ - protected function getId(mixed $key): string + protected function getId(mixed $key, ?string $namespace = null): string { if ('pgsql' !== $this->platformName ??= $this->getPlatformName()) { - return parent::getId($key); + return parent::getId($key, $namespace); } if (str_contains($key, "\0") || str_contains($key, '%') || !preg_match('//u', $key)) { $key = rawurlencode($key); } - return parent::getId($key); + return parent::getId($key, $namespace); } private function getPlatformName(): string @@ -356,9 +359,16 @@ private function getPlatformName(): string $platform = $this->conn->getDatabasePlatform(); + if (interface_exists(DBALException::class)) { + // DBAL 4+ + $sqlitePlatformClass = 'Doctrine\DBAL\Platforms\SQLitePlatform'; + } else { + $sqlitePlatformClass = 'Doctrine\DBAL\Platforms\SqlitePlatform'; + } + return $this->platformName = match (true) { $platform instanceof \Doctrine\DBAL\Platforms\AbstractMySQLPlatform => 'mysql', - $platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform => 'sqlite', + $platform instanceof $sqlitePlatformClass => 'sqlite', $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform => 'pgsql', $platform instanceof \Doctrine\DBAL\Platforms\OraclePlatform => 'oci', $platform instanceof \Doctrine\DBAL\Platforms\SQLServerPlatform => 'sqlsrv', @@ -378,6 +388,11 @@ private function addTableToSchema(Schema $schema): void $table->addColumn($this->dataCol, 'blob', ['length' => 16777215]); $table->addColumn($this->lifetimeCol, 'integer', ['unsigned' => true, 'notnull' => false]); $table->addColumn($this->timeCol, 'integer', ['unsigned' => true]); - $table->setPrimaryKey([$this->idCol]); + + if (class_exists(PrimaryKeyConstraint::class)) { + $table->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted($this->idCol))], true)); + } else { + $table->setPrimaryKey([$this->idCol]); + } } } diff --git a/src/Symfony/Component/Cache/Adapter/NullAdapter.php b/src/Symfony/Component/Cache/Adapter/NullAdapter.php index d5d2ef6b40d03..35553ea15f89a 100644 --- a/src/Symfony/Component/Cache/Adapter/NullAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/NullAdapter.php @@ -14,11 +14,12 @@ use Psr\Cache\CacheItemInterface; use Symfony\Component\Cache\CacheItem; use Symfony\Contracts\Cache\CacheInterface; +use Symfony\Contracts\Cache\NamespacedPoolInterface; /** * @author Titouan Galopin */ -class NullAdapter implements AdapterInterface, CacheInterface +class NullAdapter implements AdapterInterface, CacheInterface, NamespacedPoolInterface { private static \Closure $createCacheItem; @@ -94,6 +95,11 @@ public function delete(string $key): bool return $this->deleteItem($key); } + public function withSubNamespace(string $namespace): static + { + return clone $this; + } + private function generateItems(array $keys): \Generator { $f = self::$createCacheItem; diff --git a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php index 525e2c6db6020..7d6cb2dfcb6d1 100644 --- a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php @@ -348,17 +348,17 @@ protected function doSave(array $values, int $lifetime): array|bool /** * @internal */ - protected function getId(mixed $key): string + protected function getId(mixed $key, ?string $namespace = null): string { if ('pgsql' !== $this->getDriver()) { - return parent::getId($key); + return parent::getId($key, $namespace); } if (str_contains($key, "\0") || str_contains($key, '%') || !preg_match('//u', $key)) { $key = rawurlencode($key); } - return parent::getId($key); + return parent::getId($key, $namespace); } private function getConnection(): \PDO diff --git a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php index 5621226069bb1..d692dbf3d5c15 100644 --- a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php @@ -19,11 +19,12 @@ use Symfony\Component\Cache\Traits\ContractsTrait; use Symfony\Component\Cache\Traits\ProxyTrait; use Symfony\Contracts\Cache\CacheInterface; +use Symfony\Contracts\Cache\NamespacedPoolInterface; /** * @author Nicolas Grekas */ -class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterface, ResettableInterface +class ProxyAdapter implements AdapterInterface, NamespacedPoolInterface, CacheInterface, PruneableInterface, ResettableInterface { use ContractsTrait; use ProxyTrait; @@ -38,12 +39,17 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa public function __construct(CacheItemPoolInterface $pool, string $namespace = '', int $defaultLifetime = 0) { - $this->pool = $pool; - $this->poolHash = spl_object_hash($pool); if ('' !== $namespace) { - \assert('' !== CacheItem::validateKey($namespace)); - $this->namespace = $namespace; + if ($pool instanceof NamespacedPoolInterface) { + $pool = $pool->withSubNamespace($namespace); + $this->namespace = $namespace = ''; + } else { + \assert('' !== CacheItem::validateKey($namespace)); + $this->namespace = $namespace; + } } + $this->pool = $pool; + $this->poolHash = spl_object_hash($pool); $this->namespaceLen = \strlen($namespace); $this->defaultLifetime = $defaultLifetime; self::$createCacheItem ??= \Closure::bind( @@ -158,6 +164,20 @@ public function commit(): bool return $this->pool->commit(); } + public function withSubNamespace(string $namespace): static + { + $clone = clone $this; + + if ($clone->pool instanceof NamespacedPoolInterface) { + $clone->pool = $clone->pool->withSubNamespace($namespace); + } else { + $clone->namespace .= CacheItem::validateKey($namespace); + $clone->namespaceLen = \strlen($clone->namespace); + } + + return $clone; + } + private function doSave(CacheItemInterface $item, string $method): bool { if (!$item instanceof CacheItem) { diff --git a/src/Symfony/Component/Cache/Adapter/RedisAdapter.php b/src/Symfony/Component/Cache/Adapter/RedisAdapter.php index e33f2f65fc927..f31f0d7def5f2 100644 --- a/src/Symfony/Component/Cache/Adapter/RedisAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/RedisAdapter.php @@ -18,7 +18,7 @@ class RedisAdapter extends AbstractAdapter { use RedisTrait; - public function __construct(\Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|\Relay\Relay $redis, string $namespace = '', int $defaultLifetime = 0, ?MarshallerInterface $marshaller = null) + public function __construct(\Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|\Relay\Relay|\Relay\Cluster $redis, string $namespace = '', int $defaultLifetime = 0, ?MarshallerInterface $marshaller = null) { $this->init($redis, $namespace, $defaultLifetime, $marshaller); } diff --git a/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php index 7b282375ce7fd..779c4d91f855e 100644 --- a/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php @@ -60,7 +60,7 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter private string $redisEvictionPolicy; public function __construct( - \Redis|Relay|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis, + \Redis|Relay|\Relay\Cluster|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis, private string $namespace = '', int $defaultLifetime = 0, ?MarshallerInterface $marshaller = null, @@ -69,7 +69,7 @@ public function __construct( throw new InvalidArgumentException(\sprintf('Unsupported Predis cluster connection: only "%s" is, "%s" given.', PredisCluster::class, get_debug_type($redis->getConnection()))); } - $isRelay = $redis instanceof Relay; + $isRelay = $redis instanceof Relay || $redis instanceof \Relay\Cluster; if ($isRelay || \defined('Redis::OPT_COMPRESSION') && \in_array($redis::class, [\Redis::class, \RedisArray::class, \RedisCluster::class], true)) { $compression = $redis->getOption($isRelay ? Relay::OPT_COMPRESSION : \Redis::OPT_COMPRESSION); @@ -159,7 +159,7 @@ protected function doDeleteYieldTags(array $ids): iterable foreach ($results as $id => $result) { if ($result instanceof \RedisException || $result instanceof \Relay\Exception || $result instanceof ErrorInterface) { - CacheItem::log($this->logger, 'Failed to delete key "{key}": '.$result->getMessage(), ['key' => substr($id, \strlen($this->namespace)), 'exception' => $result]); + CacheItem::log($this->logger, 'Failed to delete key "{key}": '.$result->getMessage(), ['key' => substr($id, \strlen($this->rootNamespace)), 'exception' => $result]); continue; } @@ -225,7 +225,7 @@ protected function doInvalidate(array $tagIds): bool $results = $this->pipeline(function () use ($tagIds, $lua) { if ($this->redis instanceof \Predis\ClientInterface) { $prefix = $this->redis->getOptions()->prefix ? $this->redis->getOptions()->prefix->getPrefix() : ''; - } elseif (\is_array($prefix = $this->redis->getOption($this->redis instanceof Relay ? Relay::OPT_PREFIX : \Redis::OPT_PREFIX) ?? '')) { + } elseif (\is_array($prefix = $this->redis->getOption(($this->redis instanceof Relay || $this->redis instanceof \Relay\Cluster) ? Relay::OPT_PREFIX : \Redis::OPT_PREFIX) ?? '')) { $prefix = current($prefix); } diff --git a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php index 53c989047ff63..70927cf4e5b8a 100644 --- a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php @@ -16,9 +16,11 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use Symfony\Component\Cache\CacheItem; +use Symfony\Component\Cache\Exception\BadMethodCallException; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; use Symfony\Component\Cache\Traits\ContractsTrait; +use Symfony\Contracts\Cache\NamespacedPoolInterface; use Symfony\Contracts\Cache\TagAwareCacheInterface; /** @@ -33,7 +35,7 @@ * @author Nicolas Grekas * @author Sergey Belyshkin */ -class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterface, PruneableInterface, ResettableInterface, LoggerAwareInterface +class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterface, NamespacedPoolInterface, PruneableInterface, ResettableInterface, LoggerAwareInterface { use ContractsTrait; use LoggerAwareTrait; @@ -277,6 +279,23 @@ public function commit(): bool return $ok; } + /** + * @throws BadMethodCallException When the item pool is not a NamespacedPoolInterface + */ + public function withSubNamespace(string $namespace): static + { + if (!$this->pool instanceof NamespacedPoolInterface) { + throw new BadMethodCallException(\sprintf('Cannot call "%s::withSubNamespace()": this class doesn\'t implement "%s".', get_debug_type($this->pool), NamespacedPoolInterface::class)); + } + + $knownTagVersions = &$this->knownTagVersions; // ensures clones share the same array + $clone = clone $this; + $clone->deferred = []; + $clone->pool = $this->pool->withSubNamespace($namespace); + + return $clone; + } + public function prune(): bool { return $this->pool instanceof PruneableInterface && $this->pool->prune(); diff --git a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php index 8fe6cf3764806..3e1bf2bf7a9a9 100644 --- a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php @@ -13,9 +13,11 @@ use Psr\Cache\CacheItemInterface; use Symfony\Component\Cache\CacheItem; +use Symfony\Component\Cache\Exception\BadMethodCallException; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; use Symfony\Contracts\Cache\CacheInterface; +use Symfony\Contracts\Cache\NamespacedPoolInterface; use Symfony\Contracts\Service\ResetInterface; /** @@ -25,19 +27,27 @@ * @author Tobias Nyholm * @author Nicolas Grekas */ -class TraceableAdapter implements AdapterInterface, CacheInterface, PruneableInterface, ResettableInterface +class TraceableAdapter implements AdapterInterface, CacheInterface, NamespacedPoolInterface, PruneableInterface, ResettableInterface { + private string $namespace = ''; private array $calls = []; public function __construct( protected AdapterInterface $pool, + protected readonly ?\Closure $disabled = null, ) { } + /** + * @throws BadMethodCallException When the item pool is not a CacheInterface + */ public function get(string $key, callable $callback, ?float $beta = null, ?array &$metadata = null): mixed { if (!$this->pool instanceof CacheInterface) { - throw new \BadMethodCallException(\sprintf('Cannot call "%s::get()": this class doesn\'t implement "%s".', get_debug_type($this->pool), CacheInterface::class)); + throw new BadMethodCallException(\sprintf('Cannot call "%s::get()": this class doesn\'t implement "%s".', get_debug_type($this->pool), CacheInterface::class)); + } + if ($this->disabled?->__invoke()) { + return $this->pool->get($key, $callback, $beta, $metadata); } $isHit = true; @@ -65,6 +75,9 @@ public function get(string $key, callable $callback, ?float $beta = null, ?array public function getItem(mixed $key): CacheItem { + if ($this->disabled?->__invoke()) { + return $this->pool->getItem($key); + } $event = $this->start(__FUNCTION__); try { $item = $this->pool->getItem($key); @@ -82,6 +95,9 @@ public function getItem(mixed $key): CacheItem public function hasItem(mixed $key): bool { + if ($this->disabled?->__invoke()) { + return $this->pool->hasItem($key); + } $event = $this->start(__FUNCTION__); try { return $event->result[$key] = $this->pool->hasItem($key); @@ -92,6 +108,9 @@ public function hasItem(mixed $key): bool public function deleteItem(mixed $key): bool { + if ($this->disabled?->__invoke()) { + return $this->pool->deleteItem($key); + } $event = $this->start(__FUNCTION__); try { return $event->result[$key] = $this->pool->deleteItem($key); @@ -102,6 +121,9 @@ public function deleteItem(mixed $key): bool public function save(CacheItemInterface $item): bool { + if ($this->disabled?->__invoke()) { + return $this->pool->save($item); + } $event = $this->start(__FUNCTION__); try { return $event->result[$item->getKey()] = $this->pool->save($item); @@ -112,6 +134,9 @@ public function save(CacheItemInterface $item): bool public function saveDeferred(CacheItemInterface $item): bool { + if ($this->disabled?->__invoke()) { + return $this->pool->saveDeferred($item); + } $event = $this->start(__FUNCTION__); try { return $event->result[$item->getKey()] = $this->pool->saveDeferred($item); @@ -122,6 +147,9 @@ public function saveDeferred(CacheItemInterface $item): bool public function getItems(array $keys = []): iterable { + if ($this->disabled?->__invoke()) { + return $this->pool->getItems($keys); + } $event = $this->start(__FUNCTION__); try { $result = $this->pool->getItems($keys); @@ -145,6 +173,9 @@ public function getItems(array $keys = []): iterable public function clear(string $prefix = ''): bool { + if ($this->disabled?->__invoke()) { + return $this->pool->clear($prefix); + } $event = $this->start(__FUNCTION__); try { if ($this->pool instanceof AdapterInterface) { @@ -159,6 +190,9 @@ public function clear(string $prefix = ''): bool public function deleteItems(array $keys): bool { + if ($this->disabled?->__invoke()) { + return $this->pool->deleteItems($keys); + } $event = $this->start(__FUNCTION__); $event->result['keys'] = $keys; try { @@ -170,6 +204,9 @@ public function deleteItems(array $keys): bool public function commit(): bool { + if ($this->disabled?->__invoke()) { + return $this->pool->commit(); + } $event = $this->start(__FUNCTION__); try { return $event->result = $this->pool->commit(); @@ -183,6 +220,9 @@ public function prune(): bool if (!$this->pool instanceof PruneableInterface) { return false; } + if ($this->disabled?->__invoke()) { + return $this->pool->prune(); + } $event = $this->start(__FUNCTION__); try { return $event->result = $this->pool->prune(); @@ -202,6 +242,9 @@ public function reset(): void public function delete(string $key): bool { + if ($this->disabled?->__invoke()) { + return $this->pool->deleteItem($key); + } $event = $this->start(__FUNCTION__); try { return $event->result[$key] = $this->pool->deleteItem($key); @@ -225,11 +268,29 @@ public function getPool(): AdapterInterface return $this->pool; } + /** + * @throws BadMethodCallException When the item pool is not a NamespacedPoolInterface + */ + public function withSubNamespace(string $namespace): static + { + if (!$this->pool instanceof NamespacedPoolInterface) { + throw new BadMethodCallException(\sprintf('Cannot call "%s::withSubNamespace()": this class doesn\'t implement "%s".', get_debug_type($this->pool), NamespacedPoolInterface::class)); + } + + $calls = &$this->calls; // ensures clones share the same array + $clone = clone $this; + $clone->namespace .= CacheItem::validateKey($namespace).':'; + $clone->pool = $this->pool->withSubNamespace($namespace); + + return $clone; + } + protected function start(string $name): TraceableAdapterEvent { $this->calls[] = $event = new TraceableAdapterEvent(); $event->name = $name; $event->start = microtime(true); + $event->namespace = $this->namespace; return $event; } @@ -246,4 +307,5 @@ class TraceableAdapterEvent public array|bool $result; public int $hits = 0; public int $misses = 0; + public string $namespace; } diff --git a/src/Symfony/Component/Cache/Adapter/TraceableTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TraceableTagAwareAdapter.php index c85d199e49cb6..bde27c68a740f 100644 --- a/src/Symfony/Component/Cache/Adapter/TraceableTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TraceableTagAwareAdapter.php @@ -18,13 +18,16 @@ */ class TraceableTagAwareAdapter extends TraceableAdapter implements TagAwareAdapterInterface, TagAwareCacheInterface { - public function __construct(TagAwareAdapterInterface $pool) + public function __construct(TagAwareAdapterInterface $pool, ?\Closure $disabled = null) { - parent::__construct($pool); + parent::__construct($pool, $disabled); } public function invalidateTags(array $tags): bool { + if ($this->disabled?->__invoke()) { + return $this->pool->invalidateTags($tags); + } $event = $this->start(__FUNCTION__); try { return $event->result = $this->pool->invalidateTags($tags); diff --git a/src/Symfony/Component/Cache/CHANGELOG.md b/src/Symfony/Component/Cache/CHANGELOG.md index 038915c46ff54..d7b18246802dd 100644 --- a/src/Symfony/Component/Cache/CHANGELOG.md +++ b/src/Symfony/Component/Cache/CHANGELOG.md @@ -1,6 +1,14 @@ CHANGELOG ========= +7.3 +--- + + * Add support for `\Relay\Cluster` in `RedisAdapter` + * Add support for `valkey:` / `valkeys:` schemes + * Add support for namespace-based invalidation + * Rename options "redis_cluster" and "redis_sentinel" to "cluster" and "sentinel" respectively + 7.2 --- diff --git a/src/Symfony/Component/Cache/CacheItem.php b/src/Symfony/Component/Cache/CacheItem.php index ec2c0c5c470d6..4ce8e0cd1948a 100644 --- a/src/Symfony/Component/Cache/CacheItem.php +++ b/src/Symfony/Component/Cache/CacheItem.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache; +use Psr\Cache\CacheItemInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\Exception\LogicException; @@ -30,7 +31,7 @@ final class CacheItem implements ItemInterface protected float|int|null $expiry = null; protected array $metadata = []; protected array $newMetadata = []; - protected ?ItemInterface $innerItem = null; + protected ?CacheItemInterface $innerItem = null; protected ?string $poolHash = null; protected bool $isTaggable = false; diff --git a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php index b9bcdaf132572..22a5a0391673f 100644 --- a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php +++ b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php @@ -38,15 +38,7 @@ public function addInstance(string $name, TraceableAdapter $instance): void public function collect(Request $request, Response $response, ?\Throwable $exception = null): void { - $empty = ['calls' => [], 'adapters' => [], 'config' => [], 'options' => [], 'statistics' => []]; - $this->data = ['instances' => $empty, 'total' => $empty]; - foreach ($this->instances as $name => $instance) { - $this->data['instances']['calls'][$name] = $instance->getCalls(); - $this->data['instances']['adapters'][$name] = get_debug_type($instance->getPool()); - } - - $this->data['instances']['statistics'] = $this->calculateStatistics(); - $this->data['total']['statistics'] = $this->calculateTotalStatistics(); + $this->lateCollect(); } public function reset(): void @@ -59,6 +51,15 @@ public function reset(): void public function lateCollect(): void { + $empty = ['calls' => [], 'adapters' => [], 'config' => [], 'options' => [], 'statistics' => []]; + $this->data = ['instances' => $empty, 'total' => $empty]; + foreach ($this->instances as $name => $instance) { + $this->data['instances']['calls'][$name] = $instance->getCalls(); + $this->data['instances']['adapters'][$name] = get_debug_type($instance->getPool()); + } + + $this->data['instances']['statistics'] = $this->calculateStatistics(); + $this->data['total']['statistics'] = $this->calculateTotalStatistics(); $this->data['instances']['calls'] = $this->cloneVar($this->data['instances']['calls']); } diff --git a/src/Symfony/Component/Cache/DependencyInjection/CacheCollectorPass.php b/src/Symfony/Component/Cache/DependencyInjection/CacheCollectorPass.php index ed957406dafbe..0b8d6aed569dc 100644 --- a/src/Symfony/Component/Cache/DependencyInjection/CacheCollectorPass.php +++ b/src/Symfony/Component/Cache/DependencyInjection/CacheCollectorPass.php @@ -52,7 +52,7 @@ private function addToCollector(string $id, string $name, ContainerBuilder $cont if (!$definition->isPublic() || !$definition->isPrivate()) { $recorder->setPublic($definition->isPublic()); } - $recorder->setArguments([new Reference($innerId = $id.'.recorder_inner')]); + $recorder->setArguments([new Reference($innerId = $id.'.recorder_inner'), new Reference('profiler.is_disabled_state_checker', ContainerBuilder::IGNORE_ON_INVALID_REFERENCE)]); foreach ($definition->getMethodCalls() as [$method, $args]) { if ('setCallbackWrapper' !== $method || !$args[0] instanceof Definition || !($args[0]->getArguments()[2] ?? null) instanceof Definition) { diff --git a/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php b/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php index b4d77fd74a7a6..1a8576477c801 100644 --- a/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php +++ b/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php @@ -55,9 +55,11 @@ public function process(ContainerBuilder $container): void continue; } $class = $adapter->getClass(); + $providers = $adapter->getArguments(); while ($adapter instanceof ChildDefinition) { $adapter = $container->findDefinition($adapter->getParent()); $class = $class ?: $adapter->getClass(); + $providers += $adapter->getArguments(); if ($t = $adapter->getTag('cache.pool')) { $tags[0] += $t[0]; } @@ -87,7 +89,7 @@ public function process(ContainerBuilder $container): void if (ChainAdapter::class === $class) { $adapters = []; - foreach ($adapter->getArgument(0) as $provider => $adapter) { + foreach ($providers['index_0'] ?? $providers[0] as $provider => $adapter) { if ($adapter instanceof ChildDefinition) { $chainedPool = $adapter; } else { diff --git a/src/Symfony/Component/Cache/Exception/BadMethodCallException.php b/src/Symfony/Component/Cache/Exception/BadMethodCallException.php new file mode 100644 index 0000000000000..d81f9d26464a9 --- /dev/null +++ b/src/Symfony/Component/Cache/Exception/BadMethodCallException.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Exception; + +use Psr\Cache\CacheException as Psr6CacheInterface; +use Psr\SimpleCache\CacheException as SimpleCacheInterface; + +if (interface_exists(SimpleCacheInterface::class)) { + class BadMethodCallException extends \BadMethodCallException implements Psr6CacheInterface, SimpleCacheInterface + { + } +} else { + class BadMethodCallException extends \BadMethodCallException implements Psr6CacheInterface + { + } +} diff --git a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTestCase.php b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTestCase.php index c83365cc73f35..c139cc9774eb2 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTestCase.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTestCase.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Cache\CacheItemPoolInterface; +use Relay\Cluster as RelayCluster; use Relay\Relay; use Symfony\Component\Cache\Adapter\RedisAdapter; @@ -23,7 +24,7 @@ abstract class AbstractRedisAdapterTestCase extends AdapterTestCase 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', ]; - protected static \Redis|Relay|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis; + protected static \Redis|Relay|RelayCluster|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis; public function createCachePool(int $defaultLifetime = 0, ?string $testMethod = null): CacheItemPoolInterface { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php b/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php index da430296bcdcf..896ca94a1425b 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php @@ -18,6 +18,7 @@ use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\PruneableInterface; use Symfony\Contracts\Cache\CallbackInterface; +use Symfony\Contracts\Cache\NamespacedPoolInterface; abstract class AdapterTestCase extends CachePoolTest { @@ -350,6 +351,50 @@ public function testNumericKeysWorkAfterMemoryLeakPrevention() $this->assertEquals('value-50', $cache->getItem((string) 50)->get()); } + + public function testErrorsDontInvalidate() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + + $cache = $this->createCachePool(0, __FUNCTION__); + + $item = $cache->getItem('foo'); + $this->assertTrue($cache->save($item->set('bar'))); + $this->assertTrue($cache->hasItem('foo')); + + $item->set(static fn () => null); + $this->assertFalse($cache->save($item)); + $this->assertSame('bar', $cache->getItem('foo')->get()); + } + + public function testNamespaces() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + + $cache = $this->createCachePool(0, __FUNCTION__); + + $this->assertInstanceOf(NamespacedPoolInterface::class, $cache); + + $derived = $cache->withSubNamespace('derived'); + + $item = $derived->getItem('foo'); + $derived->save($item->set('Foo')); + + $this->assertFalse($cache->getItem('foo')->isHit()); + + $item = $cache->getItem('bar'); + $cache->save($item->set('Bar')); + + $this->assertFalse($derived->getItem('bar')->isHit()); + $this->assertTrue($cache->getItem('bar')->isHit()); + + $derived = $cache->withSubNamespace('derived'); + $this->assertTrue($derived->getItem('foo')->isHit()); + } } class NotUnserializable diff --git a/src/Symfony/Component/Cache/Tests/Adapter/DoctrineDbalAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/DoctrineDbalAdapterTest.php index 79752f39b00c5..db20b0f330dc3 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/DoctrineDbalAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/DoctrineDbalAdapterTest.php @@ -117,7 +117,7 @@ public function testConfigureSchemaTableExists() $adapter = new DoctrineDbalAdapter($connection); $adapter->configureSchema($schema, $connection, fn () => true); $table = $schema->getTable('cache_items'); - $this->assertEmpty($table->getColumns(), 'The table was not overwritten'); + $this->assertSame([], $table->getColumns(), 'The table was not overwritten'); } /** diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php index 5bbe4d1d7be13..0c856e6f5770c 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php @@ -42,6 +42,7 @@ class PhpArrayAdapterTest extends AdapterTestCase 'testSaveDeferredWhenChangingValues' => 'PhpArrayAdapter is read-only.', 'testSaveDeferredOverwrite' => 'PhpArrayAdapter is read-only.', 'testIsHitDeferred' => 'PhpArrayAdapter is read-only.', + 'testErrorsDontInvalidate' => 'PhpArrayAdapter is read-only.', 'testExpiresAt' => 'PhpArrayAdapter does not support expiration.', 'testExpiresAtWithNull' => 'PhpArrayAdapter does not support expiration.', @@ -57,6 +58,8 @@ class PhpArrayAdapterTest extends AdapterTestCase 'testDefaultLifeTime' => 'PhpArrayAdapter does not allow configuring a default lifetime.', 'testPrune' => 'PhpArrayAdapter just proxies', + + 'testNamespaces' => 'PhpArrayAdapter does not support namespaces.', ]; protected static string $file; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php index d20ffd554f90a..0f92aee451506 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php @@ -28,6 +28,8 @@ class PhpArrayAdapterWithFallbackTest extends AdapterTestCase 'testDeleteItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testDeleteItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testPrune' => 'PhpArrayAdapter just proxies', + + 'testNamespaces' => 'PhpArrayAdapter does not support namespaces.', ]; protected static string $file; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php index 5fdd35cafb68c..730bde7195fb1 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php @@ -36,17 +36,24 @@ public function testCreateConnection() $this->assertInstanceOf(StreamConnection::class, $connection); $redisHost = explode(':', $redisHost); + $connectionParameters = $connection->getParameters()->toArray(); + $params = [ 'scheme' => 'tcp', 'host' => $redisHost[0], 'port' => (int) ($redisHost[1] ?? 6379), - 'persistent' => 0, + 'persistent' => false, 'timeout' => 3, 'read_write_timeout' => 0, 'tcp_nodelay' => true, 'database' => '1', ]; - $this->assertSame($params, $connection->getParameters()->toArray()); + + if (isset($connectionParameters['conn_uid'])) { + $params['conn_uid'] = $connectionParameters['conn_uid']; // if present, the value cannot be predicted + } + + $this->assertSame($params, $connectionParameters); } public function testCreateSslConnection() @@ -60,18 +67,25 @@ public function testCreateSslConnection() $this->assertInstanceOf(StreamConnection::class, $connection); $redisHost = explode(':', $redisHost); + $connectionParameters = $connection->getParameters()->toArray(); + $params = [ 'scheme' => 'tls', 'host' => $redisHost[0], 'port' => (int) ($redisHost[1] ?? 6379), 'ssl' => ['verify_peer' => '0'], - 'persistent' => 0, + 'persistent' => false, 'timeout' => 3, 'read_write_timeout' => 0, 'tcp_nodelay' => true, 'database' => '1', ]; - $this->assertSame($params, $connection->getParameters()->toArray()); + + if (isset($connectionParameters['conn_uid'])) { + $params['conn_uid'] = $connectionParameters['conn_uid']; // if present, the value cannot be predicted + } + + $this->assertSame($params, $connectionParameters); } public function testAclUserPasswordAuth() diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php new file mode 100644 index 0000000000000..cda92af8c7a6c --- /dev/null +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Symfony\Component\Cache\Adapter\RedisAdapter; + +/** + * @group integration + */ +class PredisRedisReplicationAdapterTest extends AbstractRedisAdapterTestCase +{ + public static function setUpBeforeClass(): void + { + if (!$hosts = getenv('REDIS_REPLICATION_HOSTS')) { + self::markTestSkipped('REDIS_REPLICATION_HOSTS env var is not defined.'); + } + + self::$redis = RedisAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).'][role]=master', ['replication' => 'predis', 'class' => \Predis\Client::class, 'prefix' => 'prefix_']); + } +} diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php new file mode 100644 index 0000000000000..b9877234a05af --- /dev/null +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +/** + * @group integration + */ +class PredisReplicationAdapterTest extends AbstractRedisAdapterTestCase +{ + public static function setUpBeforeClass(): void + { + parent::setUpBeforeClass(); + + if (!$hosts = getenv('REDIS_REPLICATION_HOSTS')) { + self::markTestSkipped('REDIS_REPLICATION_HOSTS env var is not defined.'); + } + + $hosts = explode(' ', getenv('REDIS_REPLICATION_HOSTS')); + $lastArrayKey = array_key_last($hosts); + $hostTable = []; + foreach ($hosts as $key => $host) { + $hostInformation = array_combine(['host', 'port'], explode(':', $host)); + if ($lastArrayKey === $key) { + $hostInformation['role'] = 'master'; + } + $hostTable[] = $hostInformation; + } + + self::$redis = new \Predis\Client($hostTable, ['replication' => 'predis', 'prefix' => 'prefix_']); + } +} diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php index 6dc13b8194f8d..9103eec59622d 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php @@ -32,15 +32,15 @@ public static function setUpBeforeClass(): void self::markTestSkipped('REDIS_SENTINEL_SERVICE env var is not defined.'); } - self::$redis = AbstractAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).']&timeout=0&retry_interval=0&read_timeout=0', ['redis_sentinel' => $service, 'prefix' => 'prefix_']); + self::$redis = AbstractAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).']&timeout=0&retry_interval=0&read_timeout=0', ['sentinel' => $service, 'prefix' => 'prefix_']); } public function testInvalidDSNHasBothClusterAndSentinel() { - $dsn = 'redis:?host[redis1]&host[redis2]&host[redis3]&redis_cluster=1&redis_sentinel=mymaster'; + $dsn = 'redis:?host[redis1]&host[redis2]&host[redis3]&cluster=1&sentinel=mymaster'; $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Cannot use both "redis_cluster" and "redis_sentinel" at the same time.'); + $this->expectExceptionMessage('Cannot use both "cluster" and "sentinel" at the same time.'); RedisAdapter::createConnection($dsn); } @@ -51,6 +51,6 @@ public function testExceptionMessageWhenFailingToRetrieveMasterInformation() $dsn = 'redis:?host['.str_replace(' ', ']&host[', $hosts).']'; $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Failed to retrieve master information from sentinel "invalid-masterset-name".'); - AbstractAdapter::createConnection($dsn, ['redis_sentinel' => 'invalid-masterset-name']); + AbstractAdapter::createConnection($dsn, ['sentinel' => 'invalid-masterset-name']); } } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareRelayClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareRelayClusterAdapterTest.php new file mode 100644 index 0000000000000..4939d2dfe1466 --- /dev/null +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareRelayClusterAdapterTest.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Psr\Cache\CacheItemPoolInterface; +use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; +use Symfony\Component\Cache\Traits\RelayClusterProxy; + +/** + * @requires extension relay + * + * @group integration + */ +class RedisTagAwareRelayClusterAdapterTest extends RelayClusterAdapterTest +{ + use TagAwareTestTrait; + + protected function setUp(): void + { + parent::setUp(); + $this->skippedTests['testTagItemExpiry'] = 'Testing expiration slows down the test suite'; + } + + public function createCachePool(int $defaultLifetime = 0, ?string $testMethod = null): CacheItemPoolInterface + { + $this->assertInstanceOf(RelayClusterProxy::class, self::$redis); + $adapter = new RedisTagAwareAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime); + + return $adapter; + } +} diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RelayClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RelayClusterAdapterTest.php new file mode 100644 index 0000000000000..56363f8204345 --- /dev/null +++ b/src/Symfony/Component/Cache/Tests/Adapter/RelayClusterAdapterTest.php @@ -0,0 +1,68 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Psr\Cache\CacheItemPoolInterface; +use Relay\Cluster as RelayCluster; +use Relay\Relay; +use Symfony\Component\Cache\Adapter\AbstractAdapter; +use Symfony\Component\Cache\Adapter\RedisAdapter; +use Symfony\Component\Cache\Exception\InvalidArgumentException; +use Symfony\Component\Cache\Traits\RelayClusterProxy; + +/** + * @requires extension relay + * + * @group integration + */ +class RelayClusterAdapterTest extends AbstractRedisAdapterTestCase +{ + public static function setUpBeforeClass(): void + { + if (!class_exists(RelayCluster::class)) { + self::markTestSkipped('The Relay\Cluster class is required.'); + } + if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) { + self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.'); + } + + self::$redis = AbstractAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).']', ['lazy' => true, 'redis_cluster' => true, 'class' => RelayCluster::class]); + self::$redis->setOption(Relay::OPT_PREFIX, 'prefix_'); + } + + public function createCachePool(int $defaultLifetime = 0, ?string $testMethod = null): CacheItemPoolInterface + { + $this->assertInstanceOf(RelayClusterProxy::class, self::$redis); + $adapter = new RedisAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime); + + return $adapter; + } + + /** + * @dataProvider provideFailedCreateConnection + */ + public function testFailedCreateConnection(string $dsn) + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Relay cluster connection failed:'); + RedisAdapter::createConnection($dsn); + } + + public static function provideFailedCreateConnection(): array + { + return [ + ['redis://localhost:1234?redis_cluster=1&class=Relay\Cluster'], + ['redis://foo@localhost?redis_cluster=1&class=Relay\Cluster'], + ['redis://localhost/123?redis_cluster=1&class=Relay\Cluster'], + ]; + } +} diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareTestTrait.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareTestTrait.php index 8ec1297ea24e4..9894ba00982db 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareTestTrait.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareTestTrait.php @@ -183,4 +183,27 @@ public function testRefreshAfterExpires() $cacheItem = $pool->getItem('test'); $this->assertTrue($cacheItem->isHit()); } + + public function testNamespacesAndTags() + { + $pool = $this->createCachePool(); + $pool->clear(); + + $item = $pool->getItem('foo'); + $item->tag('baz'); + $pool->save($item); + + $derived = $pool->withSubNamespace('derived'); + $item = $derived->getItem('bar'); + $item->tag('baz'); + $derived->save($item); + + $this->assertTrue($pool->getItem('foo')->isHit()); + $this->assertTrue($derived->getItem('bar')->isHit()); + + $pool->invalidateTags(['baz']); + + $this->assertFalse($pool->getItem('foo')->isHit()); + $this->assertFalse($derived->getItem('bar')->isHit()); + } } diff --git a/src/Symfony/Component/Cache/Tests/DataCollector/CacheDataCollectorTest.php b/src/Symfony/Component/Cache/Tests/DataCollector/CacheDataCollectorTest.php index bb102363cf758..e2cebc77f1015 100644 --- a/src/Symfony/Component/Cache/Tests/DataCollector/CacheDataCollectorTest.php +++ b/src/Symfony/Component/Cache/Tests/DataCollector/CacheDataCollectorTest.php @@ -17,6 +17,7 @@ use Symfony\Component\Cache\DataCollector\CacheDataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\VarDumper\Cloner\Data; class CacheDataCollectorTest extends TestCase { @@ -104,6 +105,27 @@ public function testCollectBeforeEnd() $this->assertSame(1, $stats[self::INSTANCE_NAME]['misses'], 'misses'); } + public function testLateCollect() + { + $adapter = new TraceableAdapter(new NullAdapter()); + + $collector = new CacheDataCollector(); + $collector->addInstance(self::INSTANCE_NAME, $adapter); + + $adapter->get('foo', function () use ($collector) { + $collector->lateCollect(); + + return 123; + }); + + $stats = $collector->getStatistics(); + $this->assertGreaterThan(0, $stats[self::INSTANCE_NAME]['time']); + $this->assertEquals(0, $stats[self::INSTANCE_NAME]['hits'], 'hits'); + $this->assertEquals(1, $stats[self::INSTANCE_NAME]['misses'], 'misses'); + $this->assertEquals(1, $stats[self::INSTANCE_NAME]['calls'], 'calls'); + $this->assertInstanceOf(Data::class, $collector->getCalls()); + } + private function getCacheDataCollectorStatisticsFromEvents(array $traceableAdapterEvents) { $traceableAdapterMock = $this->createMock(TraceableAdapter::class); diff --git a/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php b/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php index ef64d1932da8f..6527cceff47f7 100644 --- a/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php +++ b/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php @@ -209,7 +209,8 @@ public function testChainAdapterPool() $container->register('cache.adapter.apcu', ApcuAdapter::class) ->setArguments([null, 0, null]) ->addTag('cache.pool'); - $container->register('cache.chain', ChainAdapter::class) + $container->register('cache.adapter.chain', ChainAdapter::class); + $container->setDefinition('cache.chain', new ChildDefinition('cache.adapter.chain')) ->addArgument(['cache.adapter.array', 'cache.adapter.apcu']) ->addTag('cache.pool'); $container->setDefinition('cache.app', new ChildDefinition('cache.chain')) @@ -224,7 +225,7 @@ public function testChainAdapterPool() $this->assertSame('cache.chain', $appCachePool->getParent()); $chainCachePool = $container->getDefinition('cache.chain'); - $this->assertNotInstanceOf(ChildDefinition::class, $chainCachePool); + $this->assertInstanceOf(ChildDefinition::class, $chainCachePool); $this->assertCount(2, $chainCachePool->getArgument(0)); $this->assertInstanceOf(ChildDefinition::class, $chainCachePool->getArgument(0)[0]); $this->assertSame('cache.adapter.array', $chainCachePool->getArgument(0)[0]->getParent()); diff --git a/src/Symfony/Component/Cache/Tests/Psr16CacheProxyTest.php b/src/Symfony/Component/Cache/Tests/Psr16CacheProxyTest.php index c3d2d8d59f444..fa771cf92207f 100644 --- a/src/Symfony/Component/Cache/Tests/Psr16CacheProxyTest.php +++ b/src/Symfony/Component/Cache/Tests/Psr16CacheProxyTest.php @@ -45,12 +45,12 @@ public function createSimpleCache(int $defaultLifetime = 0): CacheInterface public function testProxy() { $pool = new ArrayAdapter(); - $cache = new Psr16Cache(new ProxyAdapter($pool, 'my-namespace.')); + $cache = new Psr16Cache(new ProxyAdapter($pool, 'my-namespace')); $this->assertNull($cache->get('some-key')); $this->assertTrue($cache->set('some-other-key', 'value')); - $item = $pool->getItem('my-namespace.some-other-key', 'value'); + $item = $pool->withSubNamespace('my-namespace')->getItem('some-other-key', 'value'); $this->assertTrue($item->isHit()); $this->assertSame('value', $item->get()); } diff --git a/src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php b/src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php index 0be4060227faa..162ac495e8d35 100644 --- a/src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php +++ b/src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php @@ -12,10 +12,11 @@ namespace Symfony\Component\Cache\Tests\Traits; use PHPUnit\Framework\TestCase; +use Relay\Cluster as RelayCluster; use Relay\Relay; use Symfony\Component\Cache\Traits\RedisProxyTrait; +use Symfony\Component\Cache\Traits\RelayClusterProxy; use Symfony\Component\Cache\Traits\RelayProxy; -use Symfony\Component\VarExporter\LazyProxyTrait; use Symfony\Component\VarExporter\ProxyHelper; class RedisProxiesTest extends TestCase @@ -35,7 +36,7 @@ public function testRedisProxy($class) $methods = []; foreach ((new \ReflectionClass(\sprintf('Symfony\Component\Cache\Traits\\%s%dProxy', $class, $version)))->getMethods() as $method) { - if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name)) { + if ('reset' === $method->name || method_exists(RedisProxyTrait::class, $method->name)) { continue; } $return = '__construct' === $method->name || $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return '; @@ -87,12 +88,12 @@ public function testRelayProxy() $expectedMethods = []; foreach ((new \ReflectionClass(RelayProxy::class))->getMethods() as $method) { - if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name) || $method->isStatic()) { + if ('reset' === $method->name || method_exists(RedisProxyTrait::class, $method->name) || $method->isInternal()) { continue; } $return = '__construct' === $method->name || $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return '; - $expectedMethods[$method->name] = "\n ".ProxyHelper::exportSignature($method, false, $args)."\n".<<name] = "\n ".ProxyHelper::exportSignature($method, true, $args)."\n".<<initializeLazyObject()->{$method->name}({$args}); } @@ -101,6 +102,53 @@ public function testRelayProxy() } foreach ((new \ReflectionClass(Relay::class))->getMethods() as $method) { + if ('__destruct' === $method->name || 'reset' === $method->name || $method->isStatic()) { + continue; + } + $return = '__construct' === $method->name || $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return '; + $methods[$method->name] = "\n ".ProxyHelper::exportSignature($method, false, $args)."\n".<<initializeLazyObject()->{$method->name}({$args}); + } + + EOPHP; + } + + uksort($methods, 'strnatcmp'); + $proxy .= implode('', $methods)."}\n"; + + uksort($expectedMethods, 'strnatcmp'); + $expectedProxy .= implode('', $expectedMethods)."}\n"; + + $this->assertEquals($expectedProxy, $proxy); + } + + /** + * @requires extension relay + */ + public function testRelayClusterProxy() + { + $proxy = file_get_contents(\dirname(__DIR__, 2).'/Traits/RelayClusterProxy.php'); + $proxy = substr($proxy, 0, 2 + strpos($proxy, '}')); + $expectedProxy = $proxy; + $methods = []; + $expectedMethods = []; + + foreach ((new \ReflectionClass(RelayClusterProxy::class))->getMethods() as $method) { + if ('reset' === $method->name || method_exists(RedisProxyTrait::class, $method->name) || $method->isStatic()) { + continue; + } + + $return = '__construct' === $method->name || $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return '; + $expectedMethods[$method->name] = "\n ".ProxyHelper::exportSignature($method, false, $args)."\n".<<initializeLazyObject()->{$method->name}({$args}); + } + + EOPHP; + } + + foreach ((new \ReflectionClass(RelayCluster::class))->getMethods() as $method) { if ('reset' === $method->name || method_exists(RedisProxyTrait::class, $method->name) || $method->isStatic()) { continue; } diff --git a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php index 6a716743ffc94..ac8dc97a23c34 100644 --- a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php +++ b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php @@ -35,6 +35,7 @@ trait AbstractAdapterTrait */ private static \Closure $mergeByLifetime; + private readonly string $rootNamespace; private string $namespace = ''; private int $defaultLifetime; private string $namespaceVersion = ''; @@ -106,15 +107,16 @@ public function clear(string $prefix = ''): bool { $this->deferred = []; if ($cleared = $this->versioningIsEnabled) { + $rootNamespace = $this->rootNamespace ??= $this->namespace; if ('' === $namespaceVersionToClear = $this->namespaceVersion) { - foreach ($this->doFetch([static::NS_SEPARATOR.$this->namespace]) as $v) { + foreach ($this->doFetch([static::NS_SEPARATOR.$rootNamespace]) as $v) { $namespaceVersionToClear = $v; } } - $namespaceToClear = $this->namespace.$namespaceVersionToClear; + $namespaceToClear = $rootNamespace.$namespaceVersionToClear; $namespaceVersion = self::formatNamespaceVersion(mt_rand()); try { - $e = $this->doSave([static::NS_SEPARATOR.$this->namespace => $namespaceVersion], 0); + $e = $this->doSave([static::NS_SEPARATOR.$rootNamespace => $namespaceVersion], 0); } catch (\Exception $e) { } if (true !== $e && [] !== $e) { @@ -247,6 +249,16 @@ public function saveDeferred(CacheItemInterface $item): bool return true; } + public function withSubNamespace(string $namespace): static + { + $this->rootNamespace ??= $this->namespace; + + $clone = clone $this; + $clone->namespace .= CacheItem::validateKey($namespace).static::NS_SEPARATOR; + + return $clone; + } + /** * Enables/disables versioning of items. * @@ -318,19 +330,24 @@ private function generateItems(iterable $items, array &$keys): \Generator /** * @internal */ - protected function getId(mixed $key): string + protected function getId(mixed $key, ?string $namespace = null): string { - if ($this->versioningIsEnabled && '' === $this->namespaceVersion) { + $namespace ??= $this->namespace; + + if ('' !== $this->namespaceVersion) { + $namespace .= $this->namespaceVersion; + } elseif ($this->versioningIsEnabled) { + $rootNamespace = $this->rootNamespace ??= $this->namespace; $this->ids = []; $this->namespaceVersion = '1'.static::NS_SEPARATOR; try { - foreach ($this->doFetch([static::NS_SEPARATOR.$this->namespace]) as $v) { + foreach ($this->doFetch([static::NS_SEPARATOR.$rootNamespace]) as $v) { $this->namespaceVersion = $v; } $e = true; if ('1'.static::NS_SEPARATOR === $this->namespaceVersion) { $this->namespaceVersion = self::formatNamespaceVersion(time()); - $e = $this->doSave([static::NS_SEPARATOR.$this->namespace => $this->namespaceVersion], 0); + $e = $this->doSave([static::NS_SEPARATOR.$rootNamespace => $this->namespaceVersion], 0); } } catch (\Exception $e) { } @@ -338,25 +355,34 @@ protected function getId(mixed $key): string $message = 'Failed to save the new namespace'.($e instanceof \Exception ? ': '.$e->getMessage() : '.'); CacheItem::log($this->logger, $message, ['exception' => $e instanceof \Exception ? $e : null, 'cache-adapter' => get_debug_type($this)]); } + + $namespace .= $this->namespaceVersion; } if (\is_string($key) && isset($this->ids[$key])) { - return $this->namespace.$this->namespaceVersion.$this->ids[$key]; - } - \assert('' !== CacheItem::validateKey($key)); - $this->ids[$key] = $key; + $id = $this->ids[$key]; + } else { + \assert('' !== CacheItem::validateKey($key)); + $this->ids[$key] = $key; - if (\count($this->ids) > 1000) { - $this->ids = \array_slice($this->ids, 500, null, true); // stop memory leak if there are many keys - } + if (\count($this->ids) > 1000) { + $this->ids = \array_slice($this->ids, 500, null, true); // stop memory leak if there are many keys + } + + if (null === $this->maxIdLength) { + return $namespace.$key; + } + if (\strlen($id = $namespace.$key) <= $this->maxIdLength) { + return $id; + } - if (null === $this->maxIdLength) { - return $this->namespace.$this->namespaceVersion.$key; - } - if (\strlen($id = $this->namespace.$this->namespaceVersion.$key) > $this->maxIdLength) { // Use xxh128 to favor speed over security, which is not an issue here $this->ids[$key] = $id = substr_replace(base64_encode(hash('xxh128', $key, true)), static::NS_SEPARATOR, -(\strlen($this->namespaceVersion) + 2)); - $id = $this->namespace.$this->namespaceVersion.$id; + } + $id = $namespace.$id; + + if (null !== $this->maxIdLength && \strlen($id) > $this->maxIdLength) { + return base64_encode(hash('xxh128', $id, true)); } return $id; diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index 87c689209fac6..827a4cd0720b2 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -17,8 +17,10 @@ use Predis\Connection\Aggregate\ReplicationInterface; use Predis\Connection\Cluster\ClusterInterface as Predis2ClusterInterface; use Predis\Connection\Cluster\RedisCluster as Predis2RedisCluster; +use Predis\Connection\Replication\ReplicationInterface as Predis2ReplicationInterface; use Predis\Response\ErrorInterface; use Predis\Response\Status; +use Relay\Cluster as RelayCluster; use Relay\Relay; use Relay\Sentinel; use Symfony\Component\Cache\Exception\CacheException; @@ -36,23 +38,25 @@ trait RedisTrait { private static array $defaultConnectionOptions = [ 'class' => null, - 'persistent' => 0, + 'persistent' => false, 'persistent_id' => null, 'timeout' => 30, 'read_timeout' => 0, 'retry_interval' => 0, 'tcp_keepalive' => 0, 'lazy' => null, - 'redis_cluster' => false, - 'redis_sentinel' => null, + 'cluster' => false, + 'cluster_command_timeout' => 0, + 'cluster_relay_context' => [], + 'sentinel' => null, 'dbindex' => 0, 'failover' => 'none', 'ssl' => null, // see https://php.net/context.ssl ]; - private \Redis|Relay|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis; + private \Redis|Relay|RelayCluster|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis; private MarshallerInterface $marshaller; - private function init(\Redis|Relay|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis, string $namespace, int $defaultLifetime, ?MarshallerInterface $marshaller): void + private function init(\Redis|Relay|RelayCluster|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis, string $namespace, int $defaultLifetime, ?MarshallerInterface $marshaller): void { parent::__construct($namespace, $defaultLifetime); @@ -84,15 +88,15 @@ private function init(\Redis|Relay|\RedisArray|\RedisCluster|\Predis\ClientInter * * @throws InvalidArgumentException when the DSN is invalid */ - public static function createConnection(#[\SensitiveParameter] string $dsn, array $options = []): \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|Relay + public static function createConnection(#[\SensitiveParameter] string $dsn, array $options = []): \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|Relay|RelayCluster { - if (str_starts_with($dsn, 'redis:')) { - $scheme = 'redis'; - } elseif (str_starts_with($dsn, 'rediss:')) { - $scheme = 'rediss'; - } else { - throw new InvalidArgumentException('Invalid Redis DSN: it does not start with "redis[s]:".'); - } + $scheme = match (true) { + str_starts_with($dsn, 'redis:') => 'redis', + str_starts_with($dsn, 'rediss:') => 'rediss', + str_starts_with($dsn, 'valkey:') => 'valkey', + str_starts_with($dsn, 'valkeys:') => 'valkeys', + default => throw new InvalidArgumentException('Invalid Redis DSN: it does not start with "redis[s]:" nor "valkey[s]:".'), + }; if (!\extension_loaded('redis') && !class_exists(\Predis\Client::class)) { throw new CacheException('Cannot find the "redis" extension nor the "predis/predis" package.'); @@ -120,7 +124,7 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra $query = $hosts = []; - $tls = 'rediss' === $scheme; + $tls = 'rediss' === $scheme || 'valkeys' === $scheme; $tcpScheme = $tls ? 'tls' : 'tcp'; if (isset($params['query'])) { @@ -173,28 +177,42 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra $params += $query + $options + self::$defaultConnectionOptions; - if (isset($params['redis_sentinel']) && isset($params['sentinel_master'])) { - throw new InvalidArgumentException('Cannot use both "redis_sentinel" and "sentinel_master" at the same time.'); + $aliases = [ + 'sentinel_master' => 'sentinel', + 'redis_sentinel' => 'sentinel', + 'redis_cluster' => 'cluster', + ]; + foreach ($aliases as $alias => $key) { + $params[$key] = match (true) { + \array_key_exists($key, $query) => $query[$key], + \array_key_exists($alias, $query) => $query[$alias], + \array_key_exists($key, $options) => $options[$key], + \array_key_exists($alias, $options) => $options[$alias], + default => $params[$key], + }; } - $params['redis_sentinel'] ??= $params['sentinel_master'] ?? null; - - if (isset($params['redis_sentinel']) && !class_exists(\Predis\Client::class) && !class_exists(\RedisSentinel::class) && !class_exists(Sentinel::class)) { + if (isset($params['sentinel']) && !class_exists(\Predis\Client::class) && !class_exists(\RedisSentinel::class) && !class_exists(Sentinel::class)) { throw new CacheException('Redis Sentinel support requires one of: "predis/predis", "ext-redis >= 5.2", "ext-relay".'); } - if (isset($params['lazy'])) { - $params['lazy'] = filter_var($params['lazy'], \FILTER_VALIDATE_BOOLEAN); + foreach (['lazy', 'persistent', 'cluster'] as $option) { + if (!\is_bool($params[$option] ?? false)) { + $params[$option] = filter_var($params[$option], \FILTER_VALIDATE_BOOLEAN); + } } - $params['redis_cluster'] = filter_var($params['redis_cluster'], \FILTER_VALIDATE_BOOLEAN); - if ($params['redis_cluster'] && isset($params['redis_sentinel'])) { - throw new InvalidArgumentException('Cannot use both "redis_cluster" and "redis_sentinel" at the same time.'); + if ($params['cluster'] && isset($params['sentinel'])) { + throw new InvalidArgumentException('Cannot use both "cluster" and "sentinel" at the same time.'); } $class = $params['class'] ?? match (true) { - $params['redis_cluster'] => \extension_loaded('redis') ? \RedisCluster::class : \Predis\Client::class, - isset($params['redis_sentinel']) => match (true) { + $params['cluster'] => match (true) { + \extension_loaded('redis') => \RedisCluster::class, + \extension_loaded('relay') => RelayCluster::class, + default => \Predis\Client::class, + }, + isset($params['sentinel']) => match (true) { \extension_loaded('redis') => \Redis::class, \extension_loaded('relay') => Relay::class, default => \Predis\Client::class, @@ -205,7 +223,7 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra default => \Predis\Client::class, }; - if (isset($params['redis_sentinel']) && !is_a($class, \Predis\Client::class, true) && !class_exists(\RedisSentinel::class) && !class_exists(Sentinel::class)) { + if (isset($params['sentinel']) && !is_a($class, \Predis\Client::class, true) && !class_exists(\RedisSentinel::class) && !class_exists(Sentinel::class)) { throw new CacheException(\sprintf('Cannot use Redis Sentinel: class "%s" does not extend "Predis\Client" and neither ext-redis >= 5.2 nor ext-relay have been found.', $class)); } @@ -229,7 +247,7 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra $host = 'tls://'.$host; } - if (!isset($params['redis_sentinel'])) { + if (!isset($params['sentinel'])) { break; } @@ -255,36 +273,21 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra $sentinel = @new $sentinelClass($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...$extra); } - if ($address = @$sentinel->getMasterAddrByName($params['redis_sentinel'])) { + if ($address = @$sentinel->getMasterAddrByName($params['sentinel'])) { [$host, $port] = $address; } } catch (\RedisException|\Relay\Exception $redisException) { } } while (++$hostIndex < \count($hosts) && !$address); - if (isset($params['redis_sentinel']) && !$address) { - throw new InvalidArgumentException(\sprintf('Failed to retrieve master information from sentinel "%s".', $params['redis_sentinel']), previous: $redisException ?? null); + if (isset($params['sentinel']) && !$address) { + throw new InvalidArgumentException(\sprintf('Failed to retrieve master information from sentinel "%s".', $params['sentinel']), previous: $redisException ?? null); } try { $extra = [ - 'stream' => $params['ssl'] ?? null, + 'stream' => self::filterSslOptions($params['ssl'] ?? []) ?: null, ]; - $booleanStreamOptions = [ - 'allow_self_signed', - 'capture_peer_cert', - 'capture_peer_cert_chain', - 'disable_compression', - 'SNI_enabled', - 'verify_peer', - 'verify_peer_name', - ]; - - foreach ($extra['stream'] ?? [] as $streamOption => $value) { - if (\in_array($streamOption, $booleanStreamOptions, true) && \is_string($value)) { - $extra['stream'][$streamOption] = filter_var($value, \FILTER_VALIDATE_BOOL); - } - } if (isset($params['auth'])) { $extra['auth'] = $params['auth']; @@ -347,6 +350,59 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra if (0 < $params['tcp_keepalive'] && (!$isRedisExt || \defined('Redis::OPT_TCP_KEEPALIVE'))) { $redis->setOption($isRedisExt ? \Redis::OPT_TCP_KEEPALIVE : Relay::OPT_TCP_KEEPALIVE, $params['tcp_keepalive']); } + } elseif (is_a($class, RelayCluster::class, true)) { + if (version_compare(phpversion('relay'), '0.10.0', '<')) { + throw new InvalidArgumentException('Using RelayCluster is supported from ext-relay 0.10.0 or higher.'); + } + + $initializer = static function () use ($class, $params, $hosts) { + foreach ($hosts as $i => $host) { + $hosts[$i] = match ($host['scheme']) { + 'tcp' => $host['host'].':'.$host['port'], + 'tls' => 'tls://'.$host['host'].':'.$host['port'], + default => $host['path'], + }; + } + + try { + $context = $params['cluster_relay_context']; + $context['stream'] = self::filterSslOptions($params['ssl'] ?? []) ?: null; + + foreach ($context as $name => $value) { + match ($name) { + 'use-cache', 'client-tracking', 'throw-on-error', 'client-invalidations', 'reply-literal', 'persistent', + => $context[$name] = filter_var($value, \FILTER_VALIDATE_BOOLEAN), + 'max-retries', 'serializer', 'compression', 'compression-level', + => $context[$name] = filter_var($value, \FILTER_VALIDATE_INT), + default => null, + }; + } + + $relayCluster = new $class( + name: null, + seeds: $hosts, + connect_timeout: $params['timeout'], + command_timeout: $params['cluster_command_timeout'], + persistent: $params['persistent'], + auth: $params['auth'] ?? null, + context: $context, + ); + } catch (\Relay\Exception $e) { + throw new InvalidArgumentException('Relay cluster connection failed: '.$e->getMessage()); + } + + if (0 < $params['tcp_keepalive']) { + $relayCluster->setOption(Relay::OPT_TCP_KEEPALIVE, $params['tcp_keepalive']); + } + + if (0 < $params['read_timeout']) { + $relayCluster->setOption(Relay::OPT_READ_TIMEOUT, $params['read_timeout']); + } + + return $relayCluster; + }; + + $redis = $params['lazy'] ? RelayClusterProxy::createLazyProxy($initializer) : $initializer(); } elseif (is_a($class, \RedisCluster::class, true)) { $initializer = static function () use ($isRedisExt, $class, $params, $hosts) { foreach ($hosts as $i => $host) { @@ -358,7 +414,7 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra } try { - $redis = new $class(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) $params['persistent'], $params['auth'] ?? '', ...\defined('Redis::SCAN_PREFIX') ? [$params['ssl'] ?? null] : []); + $redis = new $class(null, $hosts, $params['timeout'], $params['read_timeout'], $params['persistent'], $params['auth'] ?? '', ...\defined('Redis::SCAN_PREFIX') ? [$params['ssl'] ?? null] : []); } catch (\RedisClusterException $e) { throw new InvalidArgumentException('Redis connection failed: '.$e->getMessage()); } @@ -378,11 +434,14 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra $redis = $params['lazy'] ? RedisClusterProxy::createLazyProxy($initializer) : $initializer(); } elseif (is_a($class, \Predis\ClientInterface::class, true)) { - if ($params['redis_cluster']) { + if ($params['cluster']) { $params['cluster'] = 'redis'; - } elseif (isset($params['redis_sentinel'])) { + } else { + unset($params['cluster']); + } + if (isset($params['sentinel'])) { $params['replication'] = 'sentinel'; - $params['service'] = $params['redis_sentinel']; + $params['service'] = $params['sentinel']; } $params += ['parameters' => []]; $params['parameters'] += [ @@ -410,7 +469,7 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra } } - if (1 === \count($hosts) && !($params['redis_cluster'] || $params['redis_sentinel'])) { + if (1 === \count($hosts) && !isset($params['cluster']) & !isset($params['sentinel'])) { $hosts = $hosts[0]; } elseif (\in_array($params['failover'], ['slaves', 'distribute'], true) && !isset($params['replication'])) { $params['replication'] = true; @@ -418,8 +477,8 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra } $params['exceptions'] = false; - $redis = new $class($hosts, array_diff_key($params, self::$defaultConnectionOptions)); - if (isset($params['redis_sentinel'])) { + $redis = new $class($hosts, array_diff_key($params, array_diff_key(self::$defaultConnectionOptions, ['cluster' => null]))); + if (isset($params['sentinel'])) { $redis->getConnection()->setSentinelTimeout($params['timeout']); } } elseif (class_exists($class, false)) { @@ -439,7 +498,7 @@ protected function doFetch(array $ids): iterable $result = []; - if ($this->redis instanceof \Predis\ClientInterface && ($this->redis->getConnection() instanceof ClusterInterface || $this->redis->getConnection() instanceof Predis2ClusterInterface)) { + if (($this->redis instanceof \Predis\ClientInterface && ($this->redis->getConnection() instanceof ClusterInterface || $this->redis->getConnection() instanceof Predis2ClusterInterface)) || $this->redis instanceof RelayCluster) { $values = $this->pipeline(function () use ($ids) { foreach ($ids as $id) { yield 'get' => [$id]; @@ -477,11 +536,47 @@ protected function doClear(string $namespace): bool } $cleared = true; + + if ($this->redis instanceof RelayCluster) { + $prefix = Relay::SCAN_PREFIX & $this->redis->getOption(Relay::OPT_SCAN) ? '' : $this->redis->getOption(Relay::OPT_PREFIX); + $prefixLen = \strlen($prefix); + $pattern = $prefix.$namespace.'*'; + foreach ($this->redis->_masters() as $ipAndPort) { + $address = implode(':', $ipAndPort); + $cursor = null; + do { + $keys = $this->redis->scan($cursor, $address, $pattern, 1000); + if (isset($keys[1]) && \is_array($keys[1])) { + $cursor = $keys[0]; + $keys = $keys[1]; + } + + if ($keys) { + if ($prefixLen) { + foreach ($keys as $i => $key) { + $keys[$i] = substr($key, $prefixLen); + } + } + $this->doDelete($keys); + } + } while ($cursor); + } + + return $cleared; + } + $hosts = $this->getHosts(); $host = reset($hosts); - if ($host instanceof \Predis\Client && $host->getConnection() instanceof ReplicationInterface) { - // Predis supports info command only on the master in replication environments - $hosts = [$host->getClientFor('master')]; + if ($host instanceof \Predis\Client) { + $connection = $host->getConnection(); + + if ($connection instanceof ReplicationInterface) { + $hosts = [$host->getClientFor('master')]; + } elseif ($connection instanceof Predis2ReplicationInterface) { + $connection->switchToMaster(); + + $hosts = [$host]; + } } foreach ($hosts as $host) { @@ -597,8 +692,9 @@ private function pipeline(\Closure $generator, ?object $redis = null): \Generato $ids = []; $redis ??= $this->redis; - if ($redis instanceof \RedisCluster || ($redis instanceof \Predis\ClientInterface && ($redis->getConnection() instanceof RedisCluster || $redis->getConnection() instanceof Predis2RedisCluster))) { + if ($redis instanceof \RedisCluster || $redis instanceof RelayCluster || ($redis instanceof \Predis\ClientInterface && ($redis->getConnection() instanceof RedisCluster || $redis->getConnection() instanceof Predis2RedisCluster))) { // phpredis & predis don't support pipelining with RedisCluster + // \Relay\Cluster does not support multi with pipeline mode // see https://github.com/phpredis/phpredis/blob/develop/cluster.markdown#pipelining // see https://github.com/nrk/predis/issues/267#issuecomment-123781423 $results = []; @@ -679,4 +775,17 @@ private function getHosts(): array return $hosts; } + + private static function filterSslOptions(array $options): array + { + foreach ($options as $name => $value) { + match ($name) { + 'allow_self_signed', 'capture_peer_cert', 'capture_peer_cert_chain', 'disable_compression', 'SNI_enabled', 'verify_peer', 'verify_peer_name', + => $options[$name] = filter_var($value, \FILTER_VALIDATE_BOOLEAN), + default => null, + }; + } + + return $options; + } } diff --git a/src/Symfony/Component/Cache/Traits/Relay/BgsaveTrait.php b/src/Symfony/Component/Cache/Traits/Relay/BgsaveTrait.php new file mode 100644 index 0000000000000..f5cddcb85225f --- /dev/null +++ b/src/Symfony/Component/Cache/Traits/Relay/BgsaveTrait.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Traits\Relay; + +if (version_compare(phpversion('relay'), '0.11', '>=')) { + /** + * @internal + */ + trait BgsaveTrait + { + public function bgsave($arg = null): \Relay\Relay|bool + { + return $this->initializeLazyObject()->bgsave(...\func_get_args()); + } + } +} else { + /** + * @internal + */ + trait BgsaveTrait + { + public function bgsave($schedule = false): \Relay\Relay|bool + { + return $this->initializeLazyObject()->bgsave(...\func_get_args()); + } + } +} diff --git a/src/Symfony/Component/Cache/Traits/Relay/FtTrait.php b/src/Symfony/Component/Cache/Traits/Relay/FtTrait.php new file mode 100644 index 0000000000000..8accd79386cbc --- /dev/null +++ b/src/Symfony/Component/Cache/Traits/Relay/FtTrait.php @@ -0,0 +1,132 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Traits\Relay; + +if (version_compare(phpversion('relay'), '0.9.0', '>=')) { + /** + * @internal + */ + trait FtTrait + { + public function ftAggregate($index, $query, $options = null): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->ftAggregate(...\func_get_args()); + } + + public function ftAliasAdd($index, $alias): \Relay\Relay|bool + { + return $this->initializeLazyObject()->ftAliasAdd(...\func_get_args()); + } + + public function ftAliasDel($alias): \Relay\Relay|bool + { + return $this->initializeLazyObject()->ftAliasDel(...\func_get_args()); + } + + public function ftAliasUpdate($index, $alias): \Relay\Relay|bool + { + return $this->initializeLazyObject()->ftAliasUpdate(...\func_get_args()); + } + + public function ftAlter($index, $schema, $skipinitialscan = false): \Relay\Relay|bool + { + return $this->initializeLazyObject()->ftAlter(...\func_get_args()); + } + + public function ftConfig($operation, $option, $value = null): \Relay\Relay|array|bool + { + return $this->initializeLazyObject()->ftConfig(...\func_get_args()); + } + + public function ftCreate($index, $schema, $options = null): \Relay\Relay|bool + { + return $this->initializeLazyObject()->ftCreate(...\func_get_args()); + } + + public function ftCursor($operation, $index, $cursor, $options = null): \Relay\Relay|array|bool + { + return $this->initializeLazyObject()->ftCursor(...\func_get_args()); + } + + public function ftDictAdd($dict, $term, ...$other_terms): \Relay\Relay|false|int + { + return $this->initializeLazyObject()->ftDictAdd(...\func_get_args()); + } + + public function ftDictDel($dict, $term, ...$other_terms): \Relay\Relay|false|int + { + return $this->initializeLazyObject()->ftDictDel(...\func_get_args()); + } + + public function ftDictDump($dict): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->ftDictDump(...\func_get_args()); + } + + public function ftDropIndex($index, $dd = false): \Relay\Relay|bool + { + return $this->initializeLazyObject()->ftDropIndex(...\func_get_args()); + } + + public function ftExplain($index, $query, $dialect = 0): \Relay\Relay|false|string + { + return $this->initializeLazyObject()->ftExplain(...\func_get_args()); + } + + public function ftExplainCli($index, $query, $dialect = 0): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->ftExplainCli(...\func_get_args()); + } + + public function ftInfo($index): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->ftInfo(...\func_get_args()); + } + + public function ftProfile($index, $command, $query, $limited = false): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->ftProfile(...\func_get_args()); + } + + public function ftSearch($index, $query, $options = null): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->ftSearch(...\func_get_args()); + } + + public function ftSpellCheck($index, $query, $options = null): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->ftSpellCheck(...\func_get_args()); + } + + public function ftSynDump($index): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->ftSynDump(...\func_get_args()); + } + + public function ftSynUpdate($index, $synonym, $term_or_terms, $skipinitialscan = false): \Relay\Relay|bool + { + return $this->initializeLazyObject()->ftSynUpdate(...\func_get_args()); + } + + public function ftTagVals($index, $tag): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->ftTagVals(...\func_get_args()); + } + } +} else { + /** + * @internal + */ + trait FtTrait + { + } +} diff --git a/src/Symfony/Component/Cache/Traits/Relay/GetWithMetaTrait.php b/src/Symfony/Component/Cache/Traits/Relay/GetWithMetaTrait.php new file mode 100644 index 0000000000000..79a75ede54ee8 --- /dev/null +++ b/src/Symfony/Component/Cache/Traits/Relay/GetWithMetaTrait.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Traits\Relay; + +if (version_compare(phpversion('relay'), '0.10.1', '>=')) { + /** + * @internal + */ + trait GetWithMetaTrait + { + public function getWithMeta($key): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->getWithMeta(...\func_get_args()); + } + } +} else { + /** + * @internal + */ + trait GetWithMetaTrait + { + } +} diff --git a/src/Symfony/Component/Cache/Traits/Relay/IsTrackedTrait.php b/src/Symfony/Component/Cache/Traits/Relay/IsTrackedTrait.php new file mode 100644 index 0000000000000..28520802959bb --- /dev/null +++ b/src/Symfony/Component/Cache/Traits/Relay/IsTrackedTrait.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Traits\Relay; + +if (version_compare(phpversion('relay'), '0.11.1', '>=')) { + /** + * @internal + */ + trait IsTrackedTrait + { + public function isTracked($key): bool + { + return $this->initializeLazyObject()->isTracked(...\func_get_args()); + } + } +} else { + /** + * @internal + */ + trait IsTrackedTrait + { + } +} diff --git a/src/Symfony/Component/Cache/Traits/Relay/Relay11Trait.php b/src/Symfony/Component/Cache/Traits/Relay/Relay11Trait.php new file mode 100644 index 0000000000000..eeeeb456c330e --- /dev/null +++ b/src/Symfony/Component/Cache/Traits/Relay/Relay11Trait.php @@ -0,0 +1,132 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Traits\Relay; + +if (version_compare(phpversion('relay'), '0.11.0', '>=')) { + /** + * @internal + */ + trait Relay11Trait + { + public function cmsIncrBy($key, $field, $value, ...$fields_and_falues): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->cmsIncrBy(...\func_get_args()); + } + + public function cmsInfo($key): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->cmsInfo(...\func_get_args()); + } + + public function cmsInitByDim($key, $width, $depth): \Relay\Relay|bool + { + return $this->initializeLazyObject()->cmsInitByDim(...\func_get_args()); + } + + public function cmsInitByProb($key, $error, $probability): \Relay\Relay|bool + { + return $this->initializeLazyObject()->cmsInitByProb(...\func_get_args()); + } + + public function cmsMerge($dstkey, $keys, $weights = []): \Relay\Relay|bool + { + return $this->initializeLazyObject()->cmsMerge(...\func_get_args()); + } + + public function cmsQuery($key, ...$fields): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->cmsQuery(...\func_get_args()); + } + + public function commandlog($subcmd, ...$args): \Relay\Relay|array|bool|int + { + return $this->initializeLazyObject()->commandlog(...\func_get_args()); + } + + public function hexpire($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->hexpire(...\func_get_args()); + } + + public function hexpireat($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->hexpireat(...\func_get_args()); + } + + public function hexpiretime($hash, $fields): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->hexpiretime(...\func_get_args()); + } + + public function hgetdel($key, $fields): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->hgetdel(...\func_get_args()); + } + + public function hgetex($hash, $fields, $expiry = null): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->hgetex(...\func_get_args()); + } + + public function hpersist($hash, $fields): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->hpersist(...\func_get_args()); + } + + public function hpexpire($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->hpexpire(...\func_get_args()); + } + + public function hpexpireat($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->hpexpireat(...\func_get_args()); + } + + public function hpexpiretime($hash, $fields): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->hpexpiretime(...\func_get_args()); + } + + public function hpttl($hash, $fields): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->hpttl(...\func_get_args()); + } + + public function hsetex($key, $fields, $expiry = null): \Relay\Relay|false|int + { + return $this->initializeLazyObject()->hsetex(...\func_get_args()); + } + + public function httl($hash, $fields): \Relay\Relay|array|false + { + return $this->initializeLazyObject()->httl(...\func_get_args()); + } + + public function serverName(): false|string + { + return $this->initializeLazyObject()->serverName(...\func_get_args()); + } + + public function serverVersion(): false|string + { + return $this->initializeLazyObject()->serverVersion(...\func_get_args()); + } + } +} else { + /** + * @internal + */ + trait Relay11Trait + { + } +} diff --git a/src/Symfony/Component/Cache/Traits/Relay/SwapdbTrait.php b/src/Symfony/Component/Cache/Traits/Relay/SwapdbTrait.php new file mode 100644 index 0000000000000..46cb2fec81d29 --- /dev/null +++ b/src/Symfony/Component/Cache/Traits/Relay/SwapdbTrait.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Traits\Relay; + +if (version_compare(phpversion('relay'), '0.9.0', '>=')) { + /** + * @internal + */ + trait SwapdbTrait + { + public function swapdb($index1, $index2): \Relay\Relay|bool + { + return $this->initializeLazyObject()->swapdb(...\func_get_args()); + } + } +} else { + /** + * @internal + */ + trait SwapdbTrait + { + } +} diff --git a/src/Symfony/Component/Cache/Traits/RelayClusterProxy.php b/src/Symfony/Component/Cache/Traits/RelayClusterProxy.php new file mode 100644 index 0000000000000..af524c8008131 --- /dev/null +++ b/src/Symfony/Component/Cache/Traits/RelayClusterProxy.php @@ -0,0 +1,1204 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Traits; + +use Relay\Cluster; +use Relay\Relay; +use Symfony\Component\VarExporter\LazyObjectInterface; +use Symfony\Contracts\Service\ResetInterface; + +// Help opcache.preload discover always-needed symbols +class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); + +/** + * @internal + */ +class RelayClusterProxy extends Cluster implements ResetInterface, LazyObjectInterface +{ + use RedisProxyTrait { + resetLazyObject as reset; + } + + public function __construct( + ?string $name, + ?array $seeds = null, + int|float $connect_timeout = 0, + int|float $command_timeout = 0, + bool $persistent = false, + #[\SensitiveParameter] mixed $auth = null, + ?array $context = null, + ) { + $this->initializeLazyObject()->__construct(...\func_get_args()); + } + + public function close(): bool + { + return $this->initializeLazyObject()->close(...\func_get_args()); + } + + public function listen(?callable $callback): bool + { + return $this->initializeLazyObject()->listen(...\func_get_args()); + } + + public function onFlushed(?callable $callback): bool + { + return $this->initializeLazyObject()->onFlushed(...\func_get_args()); + } + + public function onInvalidated(?callable $callback, ?string $pattern = null): bool + { + return $this->initializeLazyObject()->onInvalidated(...\func_get_args()); + } + + public function dispatchEvents(): false|int + { + return $this->initializeLazyObject()->dispatchEvents(...\func_get_args()); + } + + public function dump(mixed $key): Cluster|string|false + { + return $this->initializeLazyObject()->dump(...\func_get_args()); + } + + public function getOption(int $option): mixed + { + return $this->initializeLazyObject()->getOption(...\func_get_args()); + } + + public function setOption(int $option, mixed $value): bool + { + return $this->initializeLazyObject()->setOption(...\func_get_args()); + } + + public function getTransferredBytes(): array|false + { + return $this->initializeLazyObject()->getTransferredBytes(...\func_get_args()); + } + + public function getrange(mixed $key, int $start, int $end): Cluster|string|false + { + return $this->initializeLazyObject()->getrange(...\func_get_args()); + } + + public function addIgnorePatterns(string ...$pattern): int + { + return $this->initializeLazyObject()->addIgnorePatterns(...\func_get_args()); + } + + public function addAllowPatterns(string ...$pattern): int + { + return $this->initializeLazyObject()->addAllowPatterns(...\func_get_args()); + } + + public function _serialize(mixed $value): string + { + return $this->initializeLazyObject()->_serialize(...\func_get_args()); + } + + public function _unserialize(string $value): mixed + { + return $this->initializeLazyObject()->_unserialize(...\func_get_args()); + } + + public function _compress(string $value): string + { + return $this->initializeLazyObject()->_compress(...\func_get_args()); + } + + public function _uncompress(string $value): string + { + return $this->initializeLazyObject()->_uncompress(...\func_get_args()); + } + + public function _pack(mixed $value): string + { + return $this->initializeLazyObject()->_pack(...\func_get_args()); + } + + public function _unpack(string $value): mixed + { + return $this->initializeLazyObject()->_unpack(...\func_get_args()); + } + + public function _prefix(mixed $value): string + { + return $this->initializeLazyObject()->_prefix(...\func_get_args()); + } + + public function getLastError(): ?string + { + return $this->initializeLazyObject()->getLastError(...\func_get_args()); + } + + public function clearLastError(): bool + { + return $this->initializeLazyObject()->clearLastError(...\func_get_args()); + } + + public function clearTransferredBytes(): bool + { + return $this->initializeLazyObject()->clearTransferredBytes(...\func_get_args()); + } + + public function endpointId(): array|false + { + return $this->initializeLazyObject()->endpointId(...\func_get_args()); + } + + public function rawCommand(array|string $key_or_address, string $cmd, mixed ...$args): mixed + { + return $this->initializeLazyObject()->rawCommand(...\func_get_args()); + } + + public function cluster(array|string $key_or_address, string $operation, mixed ...$args): mixed + { + return $this->initializeLazyObject()->cluster(...\func_get_args()); + } + + public function info(array|string $key_or_address, string ...$sections): Cluster|array|false + { + return $this->initializeLazyObject()->info(...\func_get_args()); + } + + public function flushdb(array|string $key_or_address, ?bool $sync = null): Cluster|bool + { + return $this->initializeLazyObject()->flushdb(...\func_get_args()); + } + + public function flushall(array|string $key_or_address, ?bool $sync = null): Cluster|bool + { + return $this->initializeLazyObject()->flushall(...\func_get_args()); + } + + public function dbsize(array|string $key_or_address): Cluster|int|false + { + return $this->initializeLazyObject()->dbsize(...\func_get_args()); + } + + public function waitaof(array|string $key_or_address, int $numlocal, int $numremote, int $timeout): Relay|array|false + { + return $this->initializeLazyObject()->waitaof(...\func_get_args()); + } + + public function restore(mixed $key, int $ttl, string $value, ?array $options = null): Cluster|bool + { + return $this->initializeLazyObject()->restore(...\func_get_args()); + } + + public function echo(array|string $key_or_address, string $message): Cluster|string|false + { + return $this->initializeLazyObject()->echo(...\func_get_args()); + } + + public function ping(array|string $key_or_address, ?string $message = null): Cluster|bool|string + { + return $this->initializeLazyObject()->ping(...\func_get_args()); + } + + public function idleTime(): int + { + return $this->initializeLazyObject()->idleTime(...\func_get_args()); + } + + public function randomkey(array|string $key_or_address): Cluster|bool|string + { + return $this->initializeLazyObject()->randomkey(...\func_get_args()); + } + + public function time(array|string $key_or_address): Cluster|array|false + { + return $this->initializeLazyObject()->time(...\func_get_args()); + } + + public function bgrewriteaof(array|string $key_or_address): Cluster|bool + { + return $this->initializeLazyObject()->bgrewriteaof(...\func_get_args()); + } + + public function lastsave(array|string $key_or_address): Cluster|false|int + { + return $this->initializeLazyObject()->lastsave(...\func_get_args()); + } + + public function lcs(mixed $key1, mixed $key2, ?array $options = null): mixed + { + return $this->initializeLazyObject()->lcs(...\func_get_args()); + } + + public function bgsave(array|string $key_or_address, bool $schedule = false): Cluster|bool + { + return $this->initializeLazyObject()->bgsave(...\func_get_args()); + } + + public function save(array|string $key_or_address): Cluster|bool + { + return $this->initializeLazyObject()->save(...\func_get_args()); + } + + public function role(array|string $key_or_address): Cluster|array|false + { + return $this->initializeLazyObject()->role(...\func_get_args()); + } + + public function ttl(mixed $key): Cluster|false|int + { + return $this->initializeLazyObject()->ttl(...\func_get_args()); + } + + public function pttl(mixed $key): Cluster|false|int + { + return $this->initializeLazyObject()->pttl(...\func_get_args()); + } + + public function exists(mixed ...$keys): Cluster|bool|int + { + return $this->initializeLazyObject()->exists(...\func_get_args()); + } + + public function eval(mixed $script, array $args = [], int $num_keys = 0): mixed + { + return $this->initializeLazyObject()->eval(...\func_get_args()); + } + + public function eval_ro(mixed $script, array $args = [], int $num_keys = 0): mixed + { + return $this->initializeLazyObject()->eval_ro(...\func_get_args()); + } + + public function evalsha(string $sha, array $args = [], int $num_keys = 0): mixed + { + return $this->initializeLazyObject()->evalsha(...\func_get_args()); + } + + public function evalsha_ro(string $sha, array $args = [], int $num_keys = 0): mixed + { + return $this->initializeLazyObject()->evalsha_ro(...\func_get_args()); + } + + public function client(array|string $key_or_address, string $operation, mixed ...$args): mixed + { + return $this->initializeLazyObject()->client(...\func_get_args()); + } + + public function geoadd(mixed $key, float $lng, float $lat, string $member, mixed ...$other_triples_and_options): Cluster|false|int + { + return $this->initializeLazyObject()->geoadd(...\func_get_args()); + } + + public function geodist(mixed $key, string $src, string $dst, ?string $unit = null): Cluster|float|false + { + return $this->initializeLazyObject()->geodist(...\func_get_args()); + } + + public function geohash(mixed $key, string $member, string ...$other_members): Cluster|array|false + { + return $this->initializeLazyObject()->geohash(...\func_get_args()); + } + + public function georadius(mixed $key, float $lng, float $lat, float $radius, string $unit, array $options = []): mixed + { + return $this->initializeLazyObject()->georadius(...\func_get_args()); + } + + public function georadiusbymember(mixed $key, string $member, float $radius, string $unit, array $options = []): mixed + { + return $this->initializeLazyObject()->georadiusbymember(...\func_get_args()); + } + + public function georadiusbymember_ro(mixed $key, string $member, float $radius, string $unit, array $options = []): mixed + { + return $this->initializeLazyObject()->georadiusbymember_ro(...\func_get_args()); + } + + public function georadius_ro(mixed $key, float $lng, float $lat, float $radius, string $unit, array $options = []): mixed + { + return $this->initializeLazyObject()->georadius_ro(...\func_get_args()); + } + + public function geosearchstore(mixed $dstkey, mixed $srckey, array|string $position, array|int|float $shape, string $unit, array $options = []): Cluster|false|int + { + return $this->initializeLazyObject()->geosearchstore(...\func_get_args()); + } + + public function geosearch(mixed $key, array|string $position, array|int|float $shape, string $unit, array $options = []): Cluster|array|false + { + return $this->initializeLazyObject()->geosearch(...\func_get_args()); + } + + public function get(mixed $key): mixed + { + return $this->initializeLazyObject()->get(...\func_get_args()); + } + + public function getset(mixed $key, mixed $value): mixed + { + return $this->initializeLazyObject()->getset(...\func_get_args()); + } + + public function setrange(mixed $key, int $start, mixed $value): Cluster|false|int + { + return $this->initializeLazyObject()->setrange(...\func_get_args()); + } + + public function getbit(mixed $key, int $pos): Cluster|false|int + { + return $this->initializeLazyObject()->getbit(...\func_get_args()); + } + + public function bitcount(mixed $key, int $start = 0, int $end = -1, bool $by_bit = false): Cluster|false|int + { + return $this->initializeLazyObject()->bitcount(...\func_get_args()); + } + + public function config(array|string $key_or_address, string $operation, mixed ...$args): mixed + { + return $this->initializeLazyObject()->config(...\func_get_args()); + } + + public function command(mixed ...$args): Cluster|array|false|int + { + return $this->initializeLazyObject()->command(...\func_get_args()); + } + + public function bitop(string $operation, string $dstkey, string $srckey, string ...$other_keys): Cluster|false|int + { + return $this->initializeLazyObject()->bitop(...\func_get_args()); + } + + public function bitpos(mixed $key, int $bit, ?int $start = null, ?int $end = null, bool $by_bit = false): Cluster|false|int + { + return $this->initializeLazyObject()->bitpos(...\func_get_args()); + } + + public function blmove(mixed $srckey, mixed $dstkey, string $srcpos, string $dstpos, float $timeout): Cluster|string|false|null + { + return $this->initializeLazyObject()->blmove(...\func_get_args()); + } + + public function lmove(mixed $srckey, mixed $dstkey, string $srcpos, string $dstpos): Cluster|string|false|null + { + return $this->initializeLazyObject()->lmove(...\func_get_args()); + } + + public function setbit(mixed $key, int $pos, int $value): Cluster|false|int + { + return $this->initializeLazyObject()->setbit(...\func_get_args()); + } + + public function acl(array|string $key_or_address, string $operation, string ...$args): mixed + { + return $this->initializeLazyObject()->acl(...\func_get_args()); + } + + public function append(mixed $key, mixed $value): Cluster|false|int + { + return $this->initializeLazyObject()->append(...\func_get_args()); + } + + public function set(mixed $key, mixed $value, mixed $options = null): Cluster|string|bool + { + return $this->initializeLazyObject()->set(...\func_get_args()); + } + + public function getex(mixed $key, ?array $options = null): mixed + { + return $this->initializeLazyObject()->getex(...\func_get_args()); + } + + public function setex(mixed $key, int $seconds, mixed $value): Cluster|bool + { + return $this->initializeLazyObject()->setex(...\func_get_args()); + } + + public function pfadd(mixed $key, array $elements): Cluster|false|int + { + return $this->initializeLazyObject()->pfadd(...\func_get_args()); + } + + public function pfcount(mixed $key): Cluster|int|false + { + return $this->initializeLazyObject()->pfcount(...\func_get_args()); + } + + public function pfmerge(string $dstkey, array $srckeys): Cluster|bool + { + return $this->initializeLazyObject()->pfmerge(...\func_get_args()); + } + + public function psetex(mixed $key, int $milliseconds, mixed $value): Cluster|bool + { + return $this->initializeLazyObject()->psetex(...\func_get_args()); + } + + public function publish(string $channel, string $message): Cluster|false|int + { + return $this->initializeLazyObject()->publish(...\func_get_args()); + } + + public function pubsub(array|string $key_or_address, string $operation, mixed ...$args): mixed + { + return $this->initializeLazyObject()->pubsub(...\func_get_args()); + } + + public function setnx(mixed $key, mixed $value): Cluster|bool + { + return $this->initializeLazyObject()->setnx(...\func_get_args()); + } + + public function mget(array $keys): Cluster|array|false + { + return $this->initializeLazyObject()->mget(...\func_get_args()); + } + + public function mset(array $kvals): Cluster|array|bool + { + return $this->initializeLazyObject()->mset(...\func_get_args()); + } + + public function msetnx(array $kvals): Cluster|array|bool + { + return $this->initializeLazyObject()->msetnx(...\func_get_args()); + } + + public function rename(mixed $key, mixed $newkey): Cluster|bool + { + return $this->initializeLazyObject()->rename(...\func_get_args()); + } + + public function renamenx(mixed $key, mixed $newkey): Cluster|bool + { + return $this->initializeLazyObject()->renamenx(...\func_get_args()); + } + + public function del(mixed ...$keys): Cluster|bool|int + { + return $this->initializeLazyObject()->del(...\func_get_args()); + } + + public function unlink(mixed ...$keys): Cluster|false|int + { + return $this->initializeLazyObject()->unlink(...\func_get_args()); + } + + public function expire(mixed $key, int $seconds, ?string $mode = null): Cluster|bool + { + return $this->initializeLazyObject()->expire(...\func_get_args()); + } + + public function pexpire(mixed $key, int $milliseconds): Cluster|bool + { + return $this->initializeLazyObject()->pexpire(...\func_get_args()); + } + + public function expireat(mixed $key, int $timestamp): Cluster|bool + { + return $this->initializeLazyObject()->expireat(...\func_get_args()); + } + + public function expiretime(mixed $key): Cluster|false|int + { + return $this->initializeLazyObject()->expiretime(...\func_get_args()); + } + + public function pexpireat(mixed $key, int $timestamp_ms): Cluster|bool + { + return $this->initializeLazyObject()->pexpireat(...\func_get_args()); + } + + public static function flushMemory(?string $endpointId = null, ?int $db = null): bool + { + return Cluster::flushMemory(...\func_get_args()); + } + + public function pexpiretime(mixed $key): Cluster|false|int + { + return $this->initializeLazyObject()->pexpiretime(...\func_get_args()); + } + + public function persist(mixed $key): Cluster|bool + { + return $this->initializeLazyObject()->persist(...\func_get_args()); + } + + public function type(mixed $key): Cluster|bool|int|string + { + return $this->initializeLazyObject()->type(...\func_get_args()); + } + + public function lrange(mixed $key, int $start, int $stop): Cluster|array|false + { + return $this->initializeLazyObject()->lrange(...\func_get_args()); + } + + public function lpush(mixed $key, mixed $member, mixed ...$members): Cluster|false|int + { + return $this->initializeLazyObject()->lpush(...\func_get_args()); + } + + public function rpush(mixed $key, mixed $member, mixed ...$members): Cluster|false|int + { + return $this->initializeLazyObject()->rpush(...\func_get_args()); + } + + public function lpushx(mixed $key, mixed $member, mixed ...$members): Cluster|false|int + { + return $this->initializeLazyObject()->lpushx(...\func_get_args()); + } + + public function rpushx(mixed $key, mixed $member, mixed ...$members): Cluster|false|int + { + return $this->initializeLazyObject()->rpushx(...\func_get_args()); + } + + public function lset(mixed $key, int $index, mixed $member): Cluster|bool + { + return $this->initializeLazyObject()->lset(...\func_get_args()); + } + + public function lpop(mixed $key, int $count = 1): mixed + { + return $this->initializeLazyObject()->lpop(...\func_get_args()); + } + + public function lpos(mixed $key, mixed $value, ?array $options = null): mixed + { + return $this->initializeLazyObject()->lpos(...\func_get_args()); + } + + public function rpop(mixed $key, int $count = 1): mixed + { + return $this->initializeLazyObject()->rpop(...\func_get_args()); + } + + public function rpoplpush(mixed $srckey, mixed $dstkey): mixed + { + return $this->initializeLazyObject()->rpoplpush(...\func_get_args()); + } + + public function brpoplpush(mixed $srckey, mixed $dstkey, float $timeout): mixed + { + return $this->initializeLazyObject()->brpoplpush(...\func_get_args()); + } + + public function blpop(string|array $key, string|float $timeout_or_key, mixed ...$extra_args): Cluster|array|false|null + { + return $this->initializeLazyObject()->blpop(...\func_get_args()); + } + + public function blmpop(float $timeout, array $keys, string $from, int $count = 1): mixed + { + return $this->initializeLazyObject()->blmpop(...\func_get_args()); + } + + public function bzmpop(float $timeout, array $keys, string $from, int $count = 1): Cluster|array|false|null + { + return $this->initializeLazyObject()->bzmpop(...\func_get_args()); + } + + public function lmpop(array $keys, string $from, int $count = 1): mixed + { + return $this->initializeLazyObject()->lmpop(...\func_get_args()); + } + + public function zmpop(array $keys, string $from, int $count = 1): Cluster|array|false|null + { + return $this->initializeLazyObject()->zmpop(...\func_get_args()); + } + + public function brpop(string|array $key, string|float $timeout_or_key, mixed ...$extra_args): Cluster|array|false|null + { + return $this->initializeLazyObject()->brpop(...\func_get_args()); + } + + public function bzpopmax(string|array $key, string|float $timeout_or_key, mixed ...$extra_args): Cluster|array|false|null + { + return $this->initializeLazyObject()->bzpopmax(...\func_get_args()); + } + + public function bzpopmin(string|array $key, string|float $timeout_or_key, mixed ...$extra_args): Cluster|array|false|null + { + return $this->initializeLazyObject()->bzpopmin(...\func_get_args()); + } + + public function object(string $op, mixed $key): mixed + { + return $this->initializeLazyObject()->object(...\func_get_args()); + } + + public function geopos(mixed $key, mixed ...$members): Cluster|array|false + { + return $this->initializeLazyObject()->geopos(...\func_get_args()); + } + + public function lrem(mixed $key, mixed $member, int $count = 0): Cluster|false|int + { + return $this->initializeLazyObject()->lrem(...\func_get_args()); + } + + public function lindex(mixed $key, int $index): mixed + { + return $this->initializeLazyObject()->lindex(...\func_get_args()); + } + + public function linsert(mixed $key, string $op, mixed $pivot, mixed $element): Cluster|false|int + { + return $this->initializeLazyObject()->linsert(...\func_get_args()); + } + + public function ltrim(mixed $key, int $start, int $end): Cluster|bool + { + return $this->initializeLazyObject()->ltrim(...\func_get_args()); + } + + public static function maxMemory(): int + { + return Cluster::maxMemory(); + } + + public function hget(mixed $key, mixed $member): mixed + { + return $this->initializeLazyObject()->hget(...\func_get_args()); + } + + public function hstrlen(mixed $key, mixed $member): Cluster|false|int + { + return $this->initializeLazyObject()->hstrlen(...\func_get_args()); + } + + public function hgetall(mixed $key): Cluster|array|false + { + return $this->initializeLazyObject()->hgetall(...\func_get_args()); + } + + public function hkeys(mixed $key): Cluster|array|false + { + return $this->initializeLazyObject()->hkeys(...\func_get_args()); + } + + public function hvals(mixed $key): Cluster|array|false + { + return $this->initializeLazyObject()->hvals(...\func_get_args()); + } + + public function hmget(mixed $key, array $members): Cluster|array|false + { + return $this->initializeLazyObject()->hmget(...\func_get_args()); + } + + public function hmset(mixed $key, array $members): Cluster|bool + { + return $this->initializeLazyObject()->hmset(...\func_get_args()); + } + + public function hexists(mixed $key, mixed $member): Cluster|bool + { + return $this->initializeLazyObject()->hexists(...\func_get_args()); + } + + public function hrandfield(mixed $key, ?array $options = null): Cluster|array|string|false + { + return $this->initializeLazyObject()->hrandfield(...\func_get_args()); + } + + public function hsetnx(mixed $key, mixed $member, mixed $value): Cluster|bool + { + return $this->initializeLazyObject()->hsetnx(...\func_get_args()); + } + + public function hset(mixed $key, mixed ...$keys_and_vals): Cluster|int|false + { + return $this->initializeLazyObject()->hset(...\func_get_args()); + } + + public function hdel(mixed $key, mixed $member, mixed ...$members): Cluster|false|int + { + return $this->initializeLazyObject()->hdel(...\func_get_args()); + } + + public function hincrby(mixed $key, mixed $member, int $value): Cluster|false|int + { + return $this->initializeLazyObject()->hincrby(...\func_get_args()); + } + + public function hincrbyfloat(mixed $key, mixed $member, float $value): Cluster|bool|float + { + return $this->initializeLazyObject()->hincrbyfloat(...\func_get_args()); + } + + public function incr(mixed $key, int $by = 1): Cluster|false|int + { + return $this->initializeLazyObject()->incr(...\func_get_args()); + } + + public function decr(mixed $key, int $by = 1): Cluster|false|int + { + return $this->initializeLazyObject()->decr(...\func_get_args()); + } + + public function incrby(mixed $key, int $value): Cluster|false|int + { + return $this->initializeLazyObject()->incrby(...\func_get_args()); + } + + public function decrby(mixed $key, int $value): Cluster|false|int + { + return $this->initializeLazyObject()->decrby(...\func_get_args()); + } + + public function incrbyfloat(mixed $key, float $value): Cluster|false|float + { + return $this->initializeLazyObject()->incrbyfloat(...\func_get_args()); + } + + public function sdiff(mixed $key, mixed ...$other_keys): Cluster|array|false + { + return $this->initializeLazyObject()->sdiff(...\func_get_args()); + } + + public function sdiffstore(mixed $key, mixed ...$other_keys): Cluster|false|int + { + return $this->initializeLazyObject()->sdiffstore(...\func_get_args()); + } + + public function sinter(mixed $key, mixed ...$other_keys): Cluster|array|false + { + return $this->initializeLazyObject()->sinter(...\func_get_args()); + } + + public function sintercard(array $keys, int $limit = -1): Cluster|false|int + { + return $this->initializeLazyObject()->sintercard(...\func_get_args()); + } + + public function sinterstore(mixed $key, mixed ...$other_keys): Cluster|false|int + { + return $this->initializeLazyObject()->sinterstore(...\func_get_args()); + } + + public function sunion(mixed $key, mixed ...$other_keys): Cluster|array|false + { + return $this->initializeLazyObject()->sunion(...\func_get_args()); + } + + public function sunionstore(mixed $key, mixed ...$other_keys): Cluster|false|int + { + return $this->initializeLazyObject()->sunionstore(...\func_get_args()); + } + + public function subscribe(array $channels, callable $callback): bool + { + return $this->initializeLazyObject()->subscribe(...\func_get_args()); + } + + public function unsubscribe(array $channels = []): bool + { + return $this->initializeLazyObject()->unsubscribe(...\func_get_args()); + } + + public function psubscribe(array $patterns, callable $callback): bool + { + return $this->initializeLazyObject()->psubscribe(...\func_get_args()); + } + + public function punsubscribe(array $patterns = []): bool + { + return $this->initializeLazyObject()->punsubscribe(...\func_get_args()); + } + + public function ssubscribe(array $channels, callable $callback): bool + { + return $this->initializeLazyObject()->ssubscribe(...\func_get_args()); + } + + public function sunsubscribe(array $channels = []): bool + { + return $this->initializeLazyObject()->sunsubscribe(...\func_get_args()); + } + + public function touch(array|string $key_or_array, mixed ...$more_keys): Cluster|false|int + { + return $this->initializeLazyObject()->touch(...\func_get_args()); + } + + public function multi(int $mode = Relay::MULTI): Cluster|bool + { + return $this->initializeLazyObject()->multi(...\func_get_args()); + } + + public function exec(): array|false + { + return $this->initializeLazyObject()->exec(...\func_get_args()); + } + + public function watch(mixed $key, mixed ...$other_keys): Cluster|bool + { + return $this->initializeLazyObject()->watch(...\func_get_args()); + } + + public function unwatch(): Cluster|bool + { + return $this->initializeLazyObject()->unwatch(...\func_get_args()); + } + + public function discard(): bool + { + return $this->initializeLazyObject()->discard(...\func_get_args()); + } + + public function getMode(bool $masked = false): int + { + return $this->initializeLazyObject()->getMode(...\func_get_args()); + } + + public function scan(mixed &$iterator, array|string $key_or_address, mixed $match = null, int $count = 0, ?string $type = null): array|false + { + return $this->initializeLazyObject()->scan($iterator, ...\array_slice(\func_get_args(), 1)); + } + + public function hscan(mixed $key, mixed &$iterator, mixed $match = null, int $count = 0): array|false + { + return $this->initializeLazyObject()->hscan($key, $iterator, ...\array_slice(\func_get_args(), 2)); + } + + public function sscan(mixed $key, mixed &$iterator, mixed $match = null, int $count = 0): array|false + { + return $this->initializeLazyObject()->sscan($key, $iterator, ...\array_slice(\func_get_args(), 2)); + } + + public function zscan(mixed $key, mixed &$iterator, mixed $match = null, int $count = 0): array|false + { + return $this->initializeLazyObject()->zscan($key, $iterator, ...\array_slice(\func_get_args(), 2)); + } + + public function zscore(mixed $key, mixed $member): Cluster|float|false + { + return $this->initializeLazyObject()->zscore(...\func_get_args()); + } + + public function keys(mixed $pattern): Cluster|array|false + { + return $this->initializeLazyObject()->keys(...\func_get_args()); + } + + public function slowlog(array|string $key_or_address, string $operation, mixed ...$args): Cluster|array|bool|int + { + return $this->initializeLazyObject()->slowlog(...\func_get_args()); + } + + public function xadd(mixed $key, string $id, array $values, int $maxlen = 0, bool $approx = false, bool $nomkstream = false): Cluster|string|false + { + return $this->initializeLazyObject()->xadd(...\func_get_args()); + } + + public function smembers(mixed $key): Cluster|array|false + { + return $this->initializeLazyObject()->smembers(...\func_get_args()); + } + + public function sismember(mixed $key, mixed $member): Cluster|bool + { + return $this->initializeLazyObject()->sismember(...\func_get_args()); + } + + public function smismember(mixed $key, mixed ...$members): Cluster|array|false + { + return $this->initializeLazyObject()->smismember(...\func_get_args()); + } + + public function srem(mixed $key, mixed $member, mixed ...$members): Cluster|false|int + { + return $this->initializeLazyObject()->srem(...\func_get_args()); + } + + public function sadd(mixed $key, mixed $member, mixed ...$members): Cluster|false|int + { + return $this->initializeLazyObject()->sadd(...\func_get_args()); + } + + public function sort(mixed $key, array $options = []): Cluster|array|false|int + { + return $this->initializeLazyObject()->sort(...\func_get_args()); + } + + public function sort_ro(mixed $key, array $options = []): Cluster|array|false|int + { + return $this->initializeLazyObject()->sort_ro(...\func_get_args()); + } + + public function smove(mixed $srckey, mixed $dstkey, mixed $member): Cluster|bool + { + return $this->initializeLazyObject()->smove(...\func_get_args()); + } + + public function spop(mixed $key, int $count = 1): mixed + { + return $this->initializeLazyObject()->spop(...\func_get_args()); + } + + public function srandmember(mixed $key, int $count = 1): mixed + { + return $this->initializeLazyObject()->srandmember(...\func_get_args()); + } + + public function scard(mixed $key): Cluster|false|int + { + return $this->initializeLazyObject()->scard(...\func_get_args()); + } + + public function script(array|string $key_or_address, string $operation, string ...$args): mixed + { + return $this->initializeLazyObject()->script(...\func_get_args()); + } + + public function strlen(mixed $key): Cluster|false|int + { + return $this->initializeLazyObject()->strlen(...\func_get_args()); + } + + public function hlen(mixed $key): Cluster|false|int + { + return $this->initializeLazyObject()->hlen(...\func_get_args()); + } + + public function llen(mixed $key): Cluster|false|int + { + return $this->initializeLazyObject()->llen(...\func_get_args()); + } + + public function xack(mixed $key, string $group, array $ids): Cluster|false|int + { + return $this->initializeLazyObject()->xack(...\func_get_args()); + } + + public function xclaim(mixed $key, string $group, string $consumer, int $min_idle, array $ids, array $options): Cluster|array|bool + { + return $this->initializeLazyObject()->xclaim(...\func_get_args()); + } + + public function xautoclaim(mixed $key, string $group, string $consumer, int $min_idle, string $start, int $count = -1, bool $justid = false): Cluster|array|bool + { + return $this->initializeLazyObject()->xautoclaim(...\func_get_args()); + } + + public function xlen(mixed $key): Cluster|false|int + { + return $this->initializeLazyObject()->xlen(...\func_get_args()); + } + + public function xgroup(string $operation, mixed $key = null, ?string $group = null, ?string $id_or_consumer = null, bool $mkstream = false, int $entries_read = -2): mixed + { + return $this->initializeLazyObject()->xgroup(...\func_get_args()); + } + + public function xdel(mixed $key, array $ids): Cluster|false|int + { + return $this->initializeLazyObject()->xdel(...\func_get_args()); + } + + public function xinfo(string $operation, ?string $arg1 = null, ?string $arg2 = null, int $count = -1): mixed + { + return $this->initializeLazyObject()->xinfo(...\func_get_args()); + } + + public function xpending(mixed $key, string $group, ?string $start = null, ?string $end = null, int $count = -1, ?string $consumer = null, int $idle = 0): Cluster|array|false + { + return $this->initializeLazyObject()->xpending(...\func_get_args()); + } + + public function xrange(mixed $key, string $start, string $end, int $count = -1): Cluster|array|false + { + return $this->initializeLazyObject()->xrange(...\func_get_args()); + } + + public function xread(array $streams, int $count = -1, int $block = -1): Cluster|array|bool|null + { + return $this->initializeLazyObject()->xread(...\func_get_args()); + } + + public function xreadgroup(mixed $key, string $consumer, array $streams, int $count = 1, int $block = 1): Cluster|array|bool|null + { + return $this->initializeLazyObject()->xreadgroup(...\func_get_args()); + } + + public function xrevrange(mixed $key, string $end, string $start, int $count = -1): Cluster|array|bool + { + return $this->initializeLazyObject()->xrevrange(...\func_get_args()); + } + + public function xtrim(mixed $key, string $threshold, bool $approx = false, bool $minid = false, int $limit = -1): Cluster|false|int + { + return $this->initializeLazyObject()->xtrim(...\func_get_args()); + } + + public function zadd(mixed $key, mixed ...$args): mixed + { + return $this->initializeLazyObject()->zadd(...\func_get_args()); + } + + public function zrandmember(mixed $key, ?array $options = null): mixed + { + return $this->initializeLazyObject()->zrandmember(...\func_get_args()); + } + + public function zrange(mixed $key, string $start, string $end, mixed $options = null): Cluster|array|false + { + return $this->initializeLazyObject()->zrange(...\func_get_args()); + } + + public function zrevrange(mixed $key, int $start, int $end, mixed $options = null): Cluster|array|false + { + return $this->initializeLazyObject()->zrevrange(...\func_get_args()); + } + + public function zrangebyscore(mixed $key, mixed $start, mixed $end, mixed $options = null): Cluster|array|false + { + return $this->initializeLazyObject()->zrangebyscore(...\func_get_args()); + } + + public function zrevrangebyscore(mixed $key, mixed $start, mixed $end, mixed $options = null): Cluster|array|false + { + return $this->initializeLazyObject()->zrevrangebyscore(...\func_get_args()); + } + + public function zrevrank(mixed $key, mixed $rank, bool $withscore = false): Cluster|array|int|false + { + return $this->initializeLazyObject()->zrevrank(...\func_get_args()); + } + + public function zrangestore(mixed $dstkey, mixed $srckey, mixed $start, mixed $end, mixed $options = null): Cluster|false|int + { + return $this->initializeLazyObject()->zrangestore(...\func_get_args()); + } + + public function zrank(mixed $key, mixed $rank, bool $withscore = false): Cluster|array|int|false + { + return $this->initializeLazyObject()->zrank(...\func_get_args()); + } + + public function zrangebylex(mixed $key, mixed $min, mixed $max, int $offset = -1, int $count = -1): Cluster|array|false + { + return $this->initializeLazyObject()->zrangebylex(...\func_get_args()); + } + + public function zrevrangebylex(mixed $key, mixed $max, mixed $min, int $offset = -1, int $count = -1): Cluster|array|false + { + return $this->initializeLazyObject()->zrevrangebylex(...\func_get_args()); + } + + public function zrem(mixed $key, mixed ...$args): Cluster|false|int + { + return $this->initializeLazyObject()->zrem(...\func_get_args()); + } + + public function zremrangebylex(mixed $key, mixed $min, mixed $max): Cluster|false|int + { + return $this->initializeLazyObject()->zremrangebylex(...\func_get_args()); + } + + public function zremrangebyrank(mixed $key, int $start, int $end): Cluster|false|int + { + return $this->initializeLazyObject()->zremrangebyrank(...\func_get_args()); + } + + public function zremrangebyscore(mixed $key, mixed $min, mixed $max): Cluster|false|int + { + return $this->initializeLazyObject()->zremrangebyscore(...\func_get_args()); + } + + public function zcard(mixed $key): Cluster|false|int + { + return $this->initializeLazyObject()->zcard(...\func_get_args()); + } + + public function zcount(mixed $key, mixed $min, mixed $max): Cluster|false|int + { + return $this->initializeLazyObject()->zcount(...\func_get_args()); + } + + public function zdiff(array $keys, ?array $options = null): Cluster|array|false + { + return $this->initializeLazyObject()->zdiff(...\func_get_args()); + } + + public function zdiffstore(mixed $dstkey, array $keys): Cluster|false|int + { + return $this->initializeLazyObject()->zdiffstore(...\func_get_args()); + } + + public function zincrby(mixed $key, float $score, mixed $member): Cluster|false|float + { + return $this->initializeLazyObject()->zincrby(...\func_get_args()); + } + + public function zlexcount(mixed $key, mixed $min, mixed $max): Cluster|false|int + { + return $this->initializeLazyObject()->zlexcount(...\func_get_args()); + } + + public function zmscore(mixed $key, mixed ...$members): Cluster|array|false + { + return $this->initializeLazyObject()->zmscore(...\func_get_args()); + } + + public function zinter(array $keys, ?array $weights = null, mixed $options = null): Cluster|array|false + { + return $this->initializeLazyObject()->zinter(...\func_get_args()); + } + + public function zintercard(array $keys, int $limit = -1): Cluster|false|int + { + return $this->initializeLazyObject()->zintercard(...\func_get_args()); + } + + public function zinterstore(mixed $dstkey, array $keys, ?array $weights = null, mixed $options = null): Cluster|false|int + { + return $this->initializeLazyObject()->zinterstore(...\func_get_args()); + } + + public function zunion(array $keys, ?array $weights = null, mixed $options = null): Cluster|array|false + { + return $this->initializeLazyObject()->zunion(...\func_get_args()); + } + + public function zunionstore(mixed $dstkey, array $keys, ?array $weights = null, mixed $options = null): Cluster|false|int + { + return $this->initializeLazyObject()->zunionstore(...\func_get_args()); + } + + public function zpopmin(mixed $key, int $count = 1): Cluster|array|false + { + return $this->initializeLazyObject()->zpopmin(...\func_get_args()); + } + + public function zpopmax(mixed $key, int $count = 1): Cluster|array|false + { + return $this->initializeLazyObject()->zpopmax(...\func_get_args()); + } + + public function _getKeys(): array|false + { + return $this->initializeLazyObject()->_getKeys(...\func_get_args()); + } + + public function _masters(): array + { + return $this->initializeLazyObject()->_masters(...\func_get_args()); + } + + public function copy(mixed $srckey, mixed $dstkey, ?array $options = null): Cluster|bool + { + return $this->initializeLazyObject()->copy(...\func_get_args()); + } +} diff --git a/src/Symfony/Component/Cache/Traits/RelayProxy.php b/src/Symfony/Component/Cache/Traits/RelayProxy.php index e0ca8873a0182..43b8956771749 100644 --- a/src/Symfony/Component/Cache/Traits/RelayProxy.php +++ b/src/Symfony/Component/Cache/Traits/RelayProxy.php @@ -11,13 +11,19 @@ namespace Symfony\Component\Cache\Traits; +use Symfony\Component\Cache\Traits\Relay\BgsaveTrait; use Symfony\Component\Cache\Traits\Relay\CopyTrait; +use Symfony\Component\Cache\Traits\Relay\FtTrait; use Symfony\Component\Cache\Traits\Relay\GeosearchTrait; use Symfony\Component\Cache\Traits\Relay\GetrangeTrait; +use Symfony\Component\Cache\Traits\Relay\GetWithMetaTrait; use Symfony\Component\Cache\Traits\Relay\HsetTrait; +use Symfony\Component\Cache\Traits\Relay\IsTrackedTrait; use Symfony\Component\Cache\Traits\Relay\MoveTrait; use Symfony\Component\Cache\Traits\Relay\NullableReturnTrait; use Symfony\Component\Cache\Traits\Relay\PfcountTrait; +use Symfony\Component\Cache\Traits\Relay\Relay11Trait; +use Symfony\Component\Cache\Traits\Relay\SwapdbTrait; use Symfony\Component\VarExporter\LazyObjectInterface; use Symfony\Contracts\Service\ResetInterface; @@ -31,10 +37,14 @@ class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); */ class RelayProxy extends \Relay\Relay implements ResetInterface, LazyObjectInterface { + use BgsaveTrait; use CopyTrait; + use FtTrait; use GeosearchTrait; use GetrangeTrait; + use GetWithMetaTrait; use HsetTrait; + use IsTrackedTrait; use MoveTrait; use NullableReturnTrait; use PfcountTrait; @@ -42,6 +52,8 @@ class RelayProxy extends \Relay\Relay implements ResetInterface, LazyObjectInter resetLazyObject as reset; } use RelayProxyTrait; + use Relay11Trait; + use SwapdbTrait; public function __construct($host = null, $port = 6379, $connect_timeout = 0.0, $command_timeout = 0.0, #[\SensitiveParameter] $context = [], $database = 0) { @@ -338,11 +350,6 @@ public function lcs($key1, $key2, $options = null): mixed return $this->initializeLazyObject()->lcs(...\func_get_args()); } - public function bgsave($schedule = false): \Relay\Relay|bool - { - return $this->initializeLazyObject()->bgsave(...\func_get_args()); - } - public function save(): \Relay\Relay|bool { return $this->initializeLazyObject()->save(...\func_get_args()); diff --git a/src/Symfony/Component/Cache/composer.json b/src/Symfony/Component/Cache/composer.json index bdb461be8c9e2..c89d667288286 100644 --- a/src/Symfony/Component/Cache/composer.json +++ b/src/Symfony/Component/Cache/composer.json @@ -24,7 +24,7 @@ "php": ">=8.2", "psr/cache": "^2.0|^3.0", "psr/log": "^1.1|^2|^3", - "symfony/cache-contracts": "^2.5|^3", + "symfony/cache-contracts": "^3.6", "symfony/deprecation-contracts": "^2.5|^3.0", "symfony/service-contracts": "^2.5|^3", "symfony/var-exporter": "^6.4|^7.0" diff --git a/src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php b/src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php index 08e91c2d11105..d7689901600ba 100644 --- a/src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php +++ b/src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php @@ -126,10 +126,13 @@ private function handleArrayNode(ArrayNode $node, ClassBuilder $class, string $n $class->addRequire($childClass); $this->classes[] = $childClass; + $nodeTypes = $this->getParameterTypes($node); + $paramType = $this->getParamType($nodeTypes); + $hasNormalizationClosures = $this->hasNormalizationClosures($node); $comment = $this->getComment($node); - if ($hasNormalizationClosures) { - $comment = \sprintf(" * @template TValue\n * @param TValue \$value\n%s", $comment); + if ($hasNormalizationClosures && 'array' !== $paramType) { + $comment = \sprintf(" * @template TValue of %s\n * @param TValue \$value\n%s", $paramType, $comment); $comment .= \sprintf(' * @return %s|$this'."\n", $childClass->getFqcn()); $comment .= \sprintf(' * @psalm-return (TValue is array ? %s : static)'."\n ", $childClass->getFqcn()); } @@ -141,8 +144,7 @@ private function handleArrayNode(ArrayNode $node, ClassBuilder $class, string $n $node->getName(), $this->getType($childClass->getFqcn(), $hasNormalizationClosures) ); - $nodeTypes = $this->getParameterTypes($node); - $body = $hasNormalizationClosures ? ' + $body = $hasNormalizationClosures && 'array' !== $paramType ? ' COMMENTpublic function NAME(PARAM_TYPE $value = []): CLASS|static { if (!\is_array($value)) { @@ -177,7 +179,7 @@ private function handleArrayNode(ArrayNode $node, ClassBuilder $class, string $n 'COMMENT' => $comment, 'PROPERTY' => $property->getName(), 'CLASS' => $childClass->getFqcn(), - 'PARAM_TYPE' => \in_array('mixed', $nodeTypes, true) ? 'mixed' : implode('|', $nodeTypes), + 'PARAM_TYPE' => $paramType, ]); $this->buildNode($node, $childClass, $this->getSubNamespace($childClass)); @@ -217,10 +219,11 @@ private function handlePrototypedArrayNode(PrototypedArrayNode $node, ClassBuild $nodeParameterTypes = $this->getParameterTypes($node); $prototypeParameterTypes = $this->getParameterTypes($prototype); + $noKey = null === $key = $node->getKeyAttribute(); if (!$prototype instanceof ArrayNode || ($prototype instanceof PrototypedArrayNode && $prototype->getPrototype() instanceof ScalarNode)) { $class->addUse(ParamConfigurator::class); $property = $class->addProperty($node->getName()); - if (null === $key = $node->getKeyAttribute()) { + if ($noKey) { // This is an array of values; don't use singular name $nodeTypesWithoutArray = array_filter($nodeParameterTypes, static fn ($type) => 'array' !== $type); $body = ' @@ -241,7 +244,7 @@ public function NAME(PARAM_TYPE $value): static 'PROPERTY' => $property->getName(), 'PROTOTYPE_TYPE' => implode('|', $prototypeParameterTypes), 'EXTRA_TYPE' => $nodeTypesWithoutArray ? '|'.implode('|', $nodeTypesWithoutArray) : '', - 'PARAM_TYPE' => \in_array('mixed', $nodeParameterTypes, true) ? 'mixed' : 'ParamConfigurator|'.implode('|', $nodeParameterTypes), + 'PARAM_TYPE' => $this->getParamType($nodeParameterTypes, true), ]); } else { $body = ' @@ -258,7 +261,7 @@ public function NAME(string $VAR, TYPE $VALUE): static $class->addMethod($methodName, $body, [ 'PROPERTY' => $property->getName(), - 'TYPE' => \in_array('mixed', $prototypeParameterTypes, true) ? 'mixed' : 'ParamConfigurator|'.implode('|', $prototypeParameterTypes), + 'TYPE' => $this->getParamType($prototypeParameterTypes, true), 'VAR' => '' === $key ? 'key' : $key, 'VALUE' => 'value' === $key ? 'data' : 'value', ]); @@ -279,9 +282,11 @@ public function NAME(string $VAR, TYPE $VALUE): static $this->getType($childClass->getFqcn().'[]', $hasNormalizationClosures) ); + $paramType = $this->getParamType($noKey ? $nodeParameterTypes : $prototypeParameterTypes); + $comment = $this->getComment($node); - if ($hasNormalizationClosures) { - $comment = \sprintf(" * @template TValue\n * @param TValue \$value\n%s", $comment); + if ($hasNormalizationClosures && 'array' !== $paramType) { + $comment = \sprintf(" * @template TValue of %s\n * @param TValue \$value\n%s", $paramType, $comment); $comment .= \sprintf(' * @return %s|$this'."\n", $childClass->getFqcn()); $comment .= \sprintf(' * @psalm-return (TValue is array ? %s : static)'."\n ", $childClass->getFqcn()); } @@ -289,8 +294,8 @@ public function NAME(string $VAR, TYPE $VALUE): static $comment = "/**\n$comment*/\n"; } - if (null === $key = $node->getKeyAttribute()) { - $body = $hasNormalizationClosures ? ' + if ($noKey) { + $body = $hasNormalizationClosures && 'array' !== $paramType ? ' COMMENTpublic function NAME(PARAM_TYPE $value = []): CLASS|static { $this->_usedProperties[\'PROPERTY\'] = true; @@ -312,10 +317,10 @@ public function NAME(string $VAR, TYPE $VALUE): static 'COMMENT' => $comment, 'PROPERTY' => $property->getName(), 'CLASS' => $childClass->getFqcn(), - 'PARAM_TYPE' => \in_array('mixed', $nodeParameterTypes, true) ? 'mixed' : implode('|', $nodeParameterTypes), + 'PARAM_TYPE' => $paramType, ]); } else { - $body = $hasNormalizationClosures ? ' + $body = $hasNormalizationClosures && 'array' !== $paramType ? ' COMMENTpublic function NAME(string $VAR, PARAM_TYPE $VALUE = []): CLASS|static { if (!\is_array($VALUE)) { @@ -351,7 +356,7 @@ public function NAME(string $VAR, TYPE $VALUE): static 'CLASS' => $childClass->getFqcn(), 'VAR' => '' === $key ? 'key' : $key, 'VALUE' => 'value' === $key ? 'data' : 'value', - 'PARAM_TYPE' => \in_array('mixed', $prototypeParameterTypes, true) ? 'mixed' : implode('|', $prototypeParameterTypes), + 'PARAM_TYPE' => $paramType, ]); } @@ -412,39 +417,39 @@ private function getComment(BaseNode $node): string { $comment = ''; if ('' !== $info = (string) $node->getInfo()) { - $comment .= ' * '.$info."\n"; + $comment .= $info."\n"; } if (!$node instanceof ArrayNode) { foreach ((array) ($node->getExample() ?? []) as $example) { - $comment .= ' * @example '.$example."\n"; + $comment .= '@example '.$example."\n"; } if ('' !== $default = $node->getDefaultValue()) { - $comment .= ' * @default '.(null === $default ? 'null' : var_export($default, true))."\n"; + $comment .= '@default '.(null === $default ? 'null' : var_export($default, true))."\n"; } if ($node instanceof EnumNode) { - $comment .= \sprintf(' * @param ParamConfigurator|%s $value', implode('|', array_unique(array_map(fn ($a) => !$a instanceof \UnitEnum ? var_export($a, true) : '\\'.ltrim(var_export($a, true), '\\'), $node->getValues()))))."\n"; + $comment .= \sprintf('@param ParamConfigurator|%s $value', implode('|', array_unique(array_map(fn ($a) => !$a instanceof \UnitEnum ? var_export($a, true) : '\\'.ltrim(var_export($a, true), '\\'), $node->getValues()))))."\n"; } else { $parameterTypes = $this->getParameterTypes($node); - $comment .= ' * @param ParamConfigurator|'.implode('|', $parameterTypes).' $value'."\n"; + $comment .= '@param ParamConfigurator|'.implode('|', $parameterTypes).' $value'."\n"; } } else { foreach ((array) ($node->getExample() ?? []) as $example) { - $comment .= ' * @example '.json_encode($example)."\n"; + $comment .= '@example '.json_encode($example)."\n"; } if ($node->hasDefaultValue() && [] != $default = $node->getDefaultValue()) { - $comment .= ' * @default '.json_encode($default)."\n"; + $comment .= '@default '.json_encode($default)."\n"; } } if ($node->isDeprecated()) { - $comment .= ' * @deprecated '.$node->getDeprecation($node->getName(), $node->getParent()->getName())['message']."\n"; + $comment .= '@deprecated '.$node->getDeprecation($node->getName(), $node->getParent()->getName())['message']."\n"; } - return $comment; + return $comment ? ' * '.str_replace("\n", "\n * ", rtrim($comment, "\n"))."\n" : ''; } /** @@ -596,4 +601,9 @@ private function getType(string $classType, bool $hasNormalizationClosures): str { return $classType.($hasNormalizationClosures ? '|scalar' : ''); } + + private function getParamType(array $types, bool $withParamConfigurator = false): string + { + return \in_array('mixed', $types, true) ? 'mixed' : ($withParamConfigurator ? 'ParamConfigurator|' : '').implode('|', $types); + } } diff --git a/src/Symfony/Component/Config/CHANGELOG.md b/src/Symfony/Component/Config/CHANGELOG.md index 577fbbca53645..6ee63f82c72ff 100644 --- a/src/Symfony/Component/Config/CHANGELOG.md +++ b/src/Symfony/Component/Config/CHANGELOG.md @@ -6,6 +6,8 @@ CHANGELOG * Add `ExprBuilder::ifFalse()` * Add support for info on `ArrayNodeDefinition::canBeEnabled()` and `ArrayNodeDefinition::canBeDisabled()` + * Allow using an enum FQCN with `EnumNode` + * Add `NodeDefinition::docUrl()` 7.2 --- diff --git a/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php index 99f31812331c1..a020c5f278ee9 100644 --- a/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php @@ -21,6 +21,7 @@ class EnumNodeDefinition extends ScalarNodeDefinition { private array $values; + private string $enumFqcn; /** * @return $this @@ -36,6 +37,22 @@ public function values(array $values): static return $this; } + /** + * @param class-string<\UnitEnum> $enumFqcn + * + * @return $this + */ + public function enumFqcn(string $enumFqcn): static + { + if (!enum_exists($enumFqcn)) { + throw new \InvalidArgumentException(\sprintf('The enum class "%s" does not exist.', $enumFqcn)); + } + + $this->enumFqcn = $enumFqcn; + + return $this; + } + /** * Instantiate a Node. * @@ -43,10 +60,14 @@ public function values(array $values): static */ protected function instantiateNode(): EnumNode { - if (!isset($this->values)) { - throw new \RuntimeException('You must call ->values() on enum nodes.'); + if (!isset($this->values) && !isset($this->enumFqcn)) { + throw new \RuntimeException('You must call either ->values() or ->enumFqcn() on enum nodes.'); + } + + if (isset($this->values) && isset($this->enumFqcn)) { + throw new \RuntimeException('You must call either ->values() or ->enumFqcn() on enum nodes but not both.'); } - return new EnumNode($this->name, $this->parent, $this->values, $this->pathSeparator); + return new EnumNode($this->name, $this->parent, $this->values ?? [], $this->pathSeparator, $this->enumFqcn ?? null); } } diff --git a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php index ae8bf17143c8b..624e22d5cbfaa 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php @@ -76,7 +76,7 @@ public function ifTrue(?\Closure $closure = null): static */ public function ifFalse(?\Closure $closure = null): static { - $this->ifPart = $closure ?? static fn ($v) => false === $v; + $this->ifPart = $closure ? static fn ($v) => !$closure($v) : static fn ($v) => false === $v; $this->allowedTypes = self::TYPE_ANY; return $this; diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php index 54e976e246ec6..fdfbdabd29ad0 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Config\Definition\Builder; +use Composer\InstalledVersions; use Symfony\Component\Config\Definition\BaseNode; use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException; use Symfony\Component\Config\Definition\NodeInterface; @@ -76,6 +77,26 @@ public function example(string|array $example): static return $this->attribute('example', $example); } + /** + * Sets the documentation URI, as usually put in the "@see" tag of a doc block. This + * can either be a URL or a file path. You can use the placeholders {package}, + * {version:major} and {version:minor} in the URI. + * + * @return $this + */ + public function docUrl(string $uri, ?string $package = null): static + { + if ($package) { + preg_match('/^(\d+)\.(\d+)\.(\d+)/', InstalledVersions::getVersion($package) ?? '', $m); + } + + return $this->attribute('docUrl', strtr($uri, [ + '{package}' => $package ?? '', + '{version:major}' => $m[1] ?? '', + '{version:minor}' => $m[2] ?? '', + ])); + } + /** * Sets an attribute on the node. * diff --git a/src/Symfony/Component/Config/Definition/EnumNode.php b/src/Symfony/Component/Config/Definition/EnumNode.php index b253406c8f874..401bb48fc6ed4 100644 --- a/src/Symfony/Component/Config/Definition/EnumNode.php +++ b/src/Symfony/Component/Config/Definition/EnumNode.php @@ -21,13 +21,30 @@ class EnumNode extends ScalarNode { private array $values; + private ?string $enumFqcn = null; - public function __construct(?string $name, ?NodeInterface $parent = null, array $values = [], string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR) + /** + * @param class-string<\UnitEnum>|null $enumFqcn + */ + public function __construct(?string $name, ?NodeInterface $parent = null, array $values = [], string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR, ?string $enumFqcn = null) { - if (!$values) { + if (!$values && !$enumFqcn) { throw new \InvalidArgumentException('$values must contain at least one element.'); } + if ($values && $enumFqcn) { + throw new \InvalidArgumentException('$values or $enumFqcn cannot be both set.'); + } + + if (null !== $enumFqcn) { + if (!enum_exists($enumFqcn)) { + throw new \InvalidArgumentException(\sprintf('The "%s" enum does not exist.', $enumFqcn)); + } + + $values = $enumFqcn::cases(); + $this->enumFqcn = $enumFqcn; + } + foreach ($values as $value) { if (null === $value || \is_scalar($value)) { continue; @@ -51,11 +68,20 @@ public function getValues(): array return $this->values; } + public function getEnumFqcn(): ?string + { + return $this->enumFqcn; + } + /** * @internal */ public function getPermissibleValues(string $separator): string { + if (is_subclass_of($this->enumFqcn, \BackedEnum::class)) { + return implode($separator, array_column($this->enumFqcn::cases(), 'value')); + } + return implode($separator, array_unique(array_map(static function (mixed $value): string { if (!$value instanceof \UnitEnum) { return json_encode($value); @@ -78,13 +104,55 @@ protected function finalizeValue(mixed $value): mixed { $value = parent::finalizeValue($value); - if (!\in_array($value, $this->values, true)) { - $ex = new InvalidConfigurationException(\sprintf('The value %s is not allowed for path "%s". Permissible values: %s', json_encode($value), $this->getPath(), $this->getPermissibleValues(', '))); - $ex->setPath($this->getPath()); + if (!$this->enumFqcn) { + if (!\in_array($value, $this->values, true)) { + throw $this->createInvalidValueException($value); + } - throw $ex; + return $value; } - return $value; + if ($value instanceof $this->enumFqcn) { + return $value; + } + + if (!is_subclass_of($this->enumFqcn, \BackedEnum::class)) { + // value is not an instance of the enum, and the enum is not + // backed, meaning no cast is possible + throw $this->createInvalidValueException($value); + } + + if ($value instanceof \UnitEnum && !$value instanceof $this->enumFqcn) { + throw new InvalidConfigurationException(\sprintf('The value should be part of the "%s" enum, got a value from the "%s" enum.', $this->enumFqcn, get_debug_type($value))); + } + + if (!\is_string($value) && !\is_int($value)) { + throw new InvalidConfigurationException(\sprintf('Only strings and integers can be cast to a case of the "%s" enum, got value of type "%s".', $this->enumFqcn, get_debug_type($value))); + } + + try { + return $this->enumFqcn::from($value); + } catch (\TypeError|\ValueError) { + throw $this->createInvalidValueException($value); + } + } + + private function createInvalidValueException(mixed $value): InvalidConfigurationException + { + $displayValue = match (true) { + \is_int($value) => $value, + \is_string($value) => \sprintf('"%s"', $value), + default => \sprintf('of type "%s"', get_debug_type($value)), + }; + + $message = \sprintf('The value %s is not allowed for path "%s". Permissible values: %s.', $displayValue, $this->getPath(), $this->getPermissibleValues(', ')); + if ($this->enumFqcn) { + $message = substr_replace($message, \sprintf(' (cases of the "%s" enum)', $this->enumFqcn), -1, 0); + } + + $e = new InvalidConfigurationException($message); + $e->setPath($this->getPath()); + + return $e; } } diff --git a/src/Symfony/Component/Config/FileLocatorInterface.php b/src/Symfony/Component/Config/FileLocatorInterface.php index 87cecf47729bb..24bc70964a510 100644 --- a/src/Symfony/Component/Config/FileLocatorInterface.php +++ b/src/Symfony/Component/Config/FileLocatorInterface.php @@ -27,10 +27,10 @@ interface FileLocatorInterface * * @return string|string[] The full path to the file or an array of file paths * + * @psalm-return ($first is true ? string : string[]) + * * @throws \InvalidArgumentException If $name is empty * @throws FileLocatorFileNotFoundException If a file is not found - * - * @psalm-return ($first is true ? string : string[]) */ public function locate(string $name, ?string $currentPath = null, bool $first = true): string|array; } diff --git a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php index e039329ca9770..5bf026639c8bf 100644 --- a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php +++ b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php @@ -122,7 +122,7 @@ private function generateSignature(\ReflectionClass $class): iterable yield print_r($attributes, true); $attributes = []; - yield $class->getDocComment(); + yield $class->getDocComment() ?: ''; yield (int) $class->isFinal(); yield (int) $class->isAbstract(); @@ -134,6 +134,14 @@ private function generateSignature(\ReflectionClass $class): iterable yield print_r($class->getConstants(), true); } + foreach ($class->getReflectionConstants() as $constant) { + foreach ($constant->getAttributes() as $a) { + $attributes[] = [$a->getName(), (string) $a]; + } + yield $constant->name.print_r($attributes, true); + $attributes = []; + } + if (!$class->isInterface()) { $defaults = $class->getDefaultProperties(); @@ -144,7 +152,7 @@ private function generateSignature(\ReflectionClass $class): iterable yield print_r($attributes, true); $attributes = []; - yield $p->getDocComment(); + yield $p->getDocComment() ?: ''; yield $p->isDefault() ? '' : ''; yield $p->isPublic() ? 'public' : 'protected'; yield $p->isStatic() ? 'static' : ''; diff --git a/src/Symfony/Component/Config/ResourceCheckerConfigCache.php b/src/Symfony/Component/Config/ResourceCheckerConfigCache.php index 5e2cc1f3c75c0..955aee7e575ad 100644 --- a/src/Symfony/Component/Config/ResourceCheckerConfigCache.php +++ b/src/Symfony/Component/Config/ResourceCheckerConfigCache.php @@ -127,7 +127,7 @@ public function write(string $content, ?array $metadata = null): void $ser = preg_replace_callback('/;O:(\d+):"/', static fn ($m) => ';O:'.(9 + $m[1]).':"Tracking\\', $ser); $ser = preg_replace_callback('/s:(\d+):"\0[^\0]++\0/', static fn ($m) => 's:'.($m[1] - \strlen($m[0]) + 6).':"', $ser); - $ser = unserialize($ser); + $ser = unserialize($ser, ['allowed_classes' => false]); $ser = @json_encode($ser, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE) ?: []; $ser = str_replace('"__PHP_Incomplete_Class_Name":"Tracking\\\\', '"@type":"', $ser); $ser = \sprintf('{"resources":%s}', $ser); diff --git a/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues.config.php b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues.config.php new file mode 100644 index 0000000000000..642345ca5dd63 --- /dev/null +++ b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues.config.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Config\ArrayValuesConfig; + +return static function (ArrayValuesConfig $config) { + $config->transports('foo')->dsn('bar'); + $config->transports('bar', ['dsn' => 'foobar']); + + $config->errorPages()->withTrace(false); +}; diff --git a/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues.output.php b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues.output.php new file mode 100644 index 0000000000000..ab56d53a2f562 --- /dev/null +++ b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues.output.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +return [ + 'transports' => [ + 'foo' => [ + 'dsn' => 'bar', + ], + 'bar' => [ + 'dsn' => 'foobar', + ], + ], + 'error_pages' => [ + 'with_trace' => false, + ] +]; diff --git a/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues.php b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues.php new file mode 100644 index 0000000000000..457e78a1f7118 --- /dev/null +++ b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues.php @@ -0,0 +1,42 @@ +getRootNode(); + $rootNode + ->children() + ->arrayNode('transports') + ->normalizeKeys(false) + ->useAttributeAsKey('name') + ->arrayPrototype() + ->beforeNormalization() + ->ifString() + ->then(function (string $dsn) { + return ['dsn' => $dsn]; + }) + ->end() + ->fixXmlConfig('option') + ->children() + ->scalarNode('dsn')->end() + ->end() + ->end() + ->end() + ->arrayNode('error_pages') + ->canBeEnabled() + ->children() + ->booleanNode('with_trace')->end() + ->end() + ->end() + ->end(); + + return $tb; + } +} diff --git a/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues/Symfony/Config/ArrayValues/ErrorPagesConfig.php b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues/Symfony/Config/ArrayValues/ErrorPagesConfig.php new file mode 100644 index 0000000000000..36ccb016dc6d9 --- /dev/null +++ b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues/Symfony/Config/ArrayValues/ErrorPagesConfig.php @@ -0,0 +1,75 @@ +_usedProperties['enabled'] = true; + $this->enabled = $value; + + return $this; + } + + /** + * @default null + * @param ParamConfigurator|bool $value + * @return $this + */ + public function withTrace($value): static + { + $this->_usedProperties['withTrace'] = true; + $this->withTrace = $value; + + return $this; + } + + public function __construct(array $value = []) + { + if (array_key_exists('enabled', $value)) { + $this->_usedProperties['enabled'] = true; + $this->enabled = $value['enabled']; + unset($value['enabled']); + } + + if (array_key_exists('with_trace', $value)) { + $this->_usedProperties['withTrace'] = true; + $this->withTrace = $value['with_trace']; + unset($value['with_trace']); + } + + if ([] !== $value) { + throw new InvalidConfigurationException(sprintf('The following keys are not supported by "%s": ', __CLASS__).implode(', ', array_keys($value))); + } + } + + public function toArray(): array + { + $output = []; + if (isset($this->_usedProperties['enabled'])) { + $output['enabled'] = $this->enabled; + } + if (isset($this->_usedProperties['withTrace'])) { + $output['with_trace'] = $this->withTrace; + } + + return $output; + } + +} diff --git a/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues/Symfony/Config/ArrayValues/TransportsConfig.php b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues/Symfony/Config/ArrayValues/TransportsConfig.php new file mode 100644 index 0000000000000..c1ad5437834f8 --- /dev/null +++ b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues/Symfony/Config/ArrayValues/TransportsConfig.php @@ -0,0 +1,52 @@ +_usedProperties['dsn'] = true; + $this->dsn = $value; + + return $this; + } + + public function __construct(array $value = []) + { + if (array_key_exists('dsn', $value)) { + $this->_usedProperties['dsn'] = true; + $this->dsn = $value['dsn']; + unset($value['dsn']); + } + + if ([] !== $value) { + throw new InvalidConfigurationException(sprintf('The following keys are not supported by "%s": ', __CLASS__).implode(', ', array_keys($value))); + } + } + + public function toArray(): array + { + $output = []; + if (isset($this->_usedProperties['dsn'])) { + $output['dsn'] = $this->dsn; + } + + return $output; + } + +} diff --git a/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues/Symfony/Config/ArrayValuesConfig.php b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues/Symfony/Config/ArrayValuesConfig.php new file mode 100644 index 0000000000000..818a14fcbcd9b --- /dev/null +++ b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ArrayValues/Symfony/Config/ArrayValuesConfig.php @@ -0,0 +1,96 @@ +_usedProperties['transports'] = true; + $this->transports[$name] = $value; + + return $this; + } + + if (!isset($this->transports[$name]) || !$this->transports[$name] instanceof \Symfony\Config\ArrayValues\TransportsConfig) { + $this->_usedProperties['transports'] = true; + $this->transports[$name] = new \Symfony\Config\ArrayValues\TransportsConfig($value); + } elseif (1 < \func_num_args()) { + throw new InvalidConfigurationException('The node created by "transports()" has already been initialized. You cannot pass values the second time you call transports().'); + } + + return $this->transports[$name]; + } + + /** + * @default {"enabled":false} + */ + public function errorPages(array $value = []): \Symfony\Config\ArrayValues\ErrorPagesConfig + { + if (null === $this->errorPages) { + $this->_usedProperties['errorPages'] = true; + $this->errorPages = new \Symfony\Config\ArrayValues\ErrorPagesConfig($value); + } elseif (0 < \func_num_args()) { + throw new InvalidConfigurationException('The node created by "errorPages()" has already been initialized. You cannot pass values the second time you call errorPages().'); + } + + return $this->errorPages; + } + + public function getExtensionAlias(): string + { + return 'array_values'; + } + + public function __construct(array $value = []) + { + if (array_key_exists('transports', $value)) { + $this->_usedProperties['transports'] = true; + $this->transports = array_map(fn ($v) => \is_array($v) ? new \Symfony\Config\ArrayValues\TransportsConfig($v) : $v, $value['transports']); + unset($value['transports']); + } + + if (array_key_exists('error_pages', $value)) { + $this->_usedProperties['errorPages'] = true; + $this->errorPages = \is_array($value['error_pages']) ? new \Symfony\Config\ArrayValues\ErrorPagesConfig($value['error_pages']) : $value['error_pages']; + unset($value['error_pages']); + } + + if ([] !== $value) { + throw new InvalidConfigurationException(sprintf('The following keys are not supported by "%s": ', __CLASS__).implode(', ', array_keys($value))); + } + } + + public function toArray(): array + { + $output = []; + if (isset($this->_usedProperties['transports'])) { + $output['transports'] = array_map(fn ($v) => $v instanceof \Symfony\Config\ArrayValues\TransportsConfig ? $v->toArray() : $v, $this->transports); + } + if (isset($this->_usedProperties['errorPages'])) { + $output['error_pages'] = $this->errorPages instanceof \Symfony\Config\ArrayValues\ErrorPagesConfig ? $this->errorPages->toArray() : $this->errorPages; + } + + return $output; + } + +} diff --git a/src/Symfony/Component/Config/Tests/Builder/Fixtures/NodeInitialValues.php b/src/Symfony/Component/Config/Tests/Builder/Fixtures/NodeInitialValues.php index 153af57be9b5b..5c1259c20edd8 100644 --- a/src/Symfony/Component/Config/Tests/Builder/Fixtures/NodeInitialValues.php +++ b/src/Symfony/Component/Config/Tests/Builder/Fixtures/NodeInitialValues.php @@ -38,7 +38,13 @@ public function getConfigTreeBuilder(): TreeBuilder ->arrayPrototype() ->fixXmlConfig('option') ->children() - ->scalarNode('dsn')->end() + ->scalarNode('dsn') + ->info(<<<'INFO' + The DSN to use. This is a required option. + The info is used to describe the DSN, + it can be multi-line. + INFO) + ->end() ->scalarNode('serializer')->defaultNull()->end() ->arrayNode('options') ->normalizeKeys(false) diff --git a/src/Symfony/Component/Config/Tests/Builder/Fixtures/NodeInitialValues/Symfony/Config/NodeInitialValues/Messenger/TransportsConfig.php b/src/Symfony/Component/Config/Tests/Builder/Fixtures/NodeInitialValues/Symfony/Config/NodeInitialValues/Messenger/TransportsConfig.php index b9d8b48db3556..6a98166eccc94 100644 --- a/src/Symfony/Component/Config/Tests/Builder/Fixtures/NodeInitialValues/Symfony/Config/NodeInitialValues/Messenger/TransportsConfig.php +++ b/src/Symfony/Component/Config/Tests/Builder/Fixtures/NodeInitialValues/Symfony/Config/NodeInitialValues/Messenger/TransportsConfig.php @@ -16,6 +16,9 @@ class TransportsConfig private $_usedProperties = []; /** + * The DSN to use. This is a required option. + * The info is used to describe the DSN, + * it can be multi-line. * @default null * @param ParamConfigurator|mixed $value * @return $this diff --git a/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes.config.php b/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes.config.php index fd4c0ce5f2cfa..39ae3a144e4f1 100644 --- a/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes.config.php +++ b/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes.config.php @@ -14,6 +14,8 @@ return static function (PrimitiveTypesConfig $config) { $config->booleanNode(true); $config->enumNode('foo'); + $config->fqcnEnumNode('bar'); + $config->fqcnUnitEnumNode(\Symfony\Component\Config\Tests\Fixtures\TestEnum::Bar); $config->floatNode(47.11); $config->integerNode(1337); $config->scalarNode('foobar'); diff --git a/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes.output.php b/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes.output.php index 867e387dbf3c2..377590b687a64 100644 --- a/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes.output.php +++ b/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes.output.php @@ -12,6 +12,8 @@ return [ 'boolean_node' => true, 'enum_node' => 'foo', + 'fqcn_enum_node' => 'bar', + 'fqcn_unit_enum_node' => \Symfony\Component\Config\Tests\Fixtures\TestEnum::Bar, 'float_node' => 47.11, 'integer_node' => 1337, 'scalar_node' => 'foobar', diff --git a/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes.php b/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes.php index 6b0dbd72fc921..35d3400d152d6 100644 --- a/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes.php +++ b/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes.php @@ -13,6 +13,7 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; +use Symfony\Component\Config\Tests\Fixtures\StringBackedTestEnum; use Symfony\Component\Config\Tests\Fixtures\TestEnum; class PrimitiveTypes implements ConfigurationInterface @@ -25,6 +26,8 @@ public function getConfigTreeBuilder(): TreeBuilder ->children() ->booleanNode('boolean_node')->end() ->enumNode('enum_node')->values(['foo', 'bar', 'baz', TestEnum::Bar])->end() + ->enumNode('fqcn_enum_node')->enumFqcn(StringBackedTestEnum::class)->end() + ->enumNode('fqcn_unit_enum_node')->enumFqcn(TestEnum::class)->end() ->floatNode('float_node')->end() ->integerNode('integer_node')->end() ->scalarNode('scalar_node')->end() diff --git a/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes/Symfony/Config/PrimitiveTypesConfig.php b/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes/Symfony/Config/PrimitiveTypesConfig.php index b34e0413b8a23..4208b97dde1bc 100644 --- a/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes/Symfony/Config/PrimitiveTypesConfig.php +++ b/src/Symfony/Component/Config/Tests/Builder/Fixtures/PrimitiveTypes/Symfony/Config/PrimitiveTypesConfig.php @@ -12,6 +12,8 @@ class PrimitiveTypesConfig implements \Symfony\Component\Config\Builder\ConfigBu { private $booleanNode; private $enumNode; + private $fqcnEnumNode; + private $fqcnUnitEnumNode; private $floatNode; private $integerNode; private $scalarNode; @@ -44,6 +46,32 @@ public function enumNode($value): static return $this; } + /** + * @default null + * @param ParamConfigurator|\Symfony\Component\Config\Tests\Fixtures\StringBackedTestEnum::Foo|\Symfony\Component\Config\Tests\Fixtures\StringBackedTestEnum::Bar $value + * @return $this + */ + public function fqcnEnumNode($value): static + { + $this->_usedProperties['fqcnEnumNode'] = true; + $this->fqcnEnumNode = $value; + + return $this; + } + + /** + * @default null + * @param ParamConfigurator|\Symfony\Component\Config\Tests\Fixtures\TestEnum::Foo|\Symfony\Component\Config\Tests\Fixtures\TestEnum::Bar|\Symfony\Component\Config\Tests\Fixtures\TestEnum::Ccc $value + * @return $this + */ + public function fqcnUnitEnumNode($value): static + { + $this->_usedProperties['fqcnUnitEnumNode'] = true; + $this->fqcnUnitEnumNode = $value; + + return $this; + } + /** * @default null * @param ParamConfigurator|float $value @@ -115,6 +143,18 @@ public function __construct(array $value = []) unset($value['enum_node']); } + if (array_key_exists('fqcn_enum_node', $value)) { + $this->_usedProperties['fqcnEnumNode'] = true; + $this->fqcnEnumNode = $value['fqcn_enum_node']; + unset($value['fqcn_enum_node']); + } + + if (array_key_exists('fqcn_unit_enum_node', $value)) { + $this->_usedProperties['fqcnUnitEnumNode'] = true; + $this->fqcnUnitEnumNode = $value['fqcn_unit_enum_node']; + unset($value['fqcn_unit_enum_node']); + } + if (array_key_exists('float_node', $value)) { $this->_usedProperties['floatNode'] = true; $this->floatNode = $value['float_node']; @@ -153,6 +193,12 @@ public function toArray(): array if (isset($this->_usedProperties['enumNode'])) { $output['enum_node'] = $this->enumNode; } + if (isset($this->_usedProperties['fqcnEnumNode'])) { + $output['fqcn_enum_node'] = $this->fqcnEnumNode; + } + if (isset($this->_usedProperties['fqcnUnitEnumNode'])) { + $output['fqcn_unit_enum_node'] = $this->fqcnUnitEnumNode; + } if (isset($this->_usedProperties['floatNode'])) { $output['float_node'] = $this->floatNode; } diff --git a/src/Symfony/Component/Config/Tests/Builder/Fixtures/ScalarNormalizedTypes/Symfony/Config/ScalarNormalizedTypes/NestedConfig.php b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ScalarNormalizedTypes/Symfony/Config/ScalarNormalizedTypes/NestedConfig.php index 2cc1fb3275e78..2b3f19e87fb6f 100644 --- a/src/Symfony/Component/Config/Tests/Builder/Fixtures/ScalarNormalizedTypes/Symfony/Config/ScalarNormalizedTypes/NestedConfig.php +++ b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ScalarNormalizedTypes/Symfony/Config/ScalarNormalizedTypes/NestedConfig.php @@ -17,7 +17,7 @@ class NestedConfig private $_usedProperties = []; /** - * @template TValue + * @template TValue of mixed * @param TValue $value * @default {"enabled":null} * @return \Symfony\Config\ScalarNormalizedTypes\Nested\NestedObjectConfig|$this @@ -43,7 +43,7 @@ public function nestedObject(mixed $value = []): \Symfony\Config\ScalarNormalize } /** - * @template TValue + * @template TValue of mixed * @param TValue $value * @return \Symfony\Config\ScalarNormalizedTypes\Nested\NestedListObjectConfig|$this * @psalm-return (TValue is array ? \Symfony\Config\ScalarNormalizedTypes\Nested\NestedListObjectConfig : static) diff --git a/src/Symfony/Component/Config/Tests/Builder/Fixtures/ScalarNormalizedTypes/Symfony/Config/ScalarNormalizedTypesConfig.php b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ScalarNormalizedTypes/Symfony/Config/ScalarNormalizedTypesConfig.php index 1794ede72e18c..66107b8f19730 100644 --- a/src/Symfony/Component/Config/Tests/Builder/Fixtures/ScalarNormalizedTypes/Symfony/Config/ScalarNormalizedTypesConfig.php +++ b/src/Symfony/Component/Config/Tests/Builder/Fixtures/ScalarNormalizedTypes/Symfony/Config/ScalarNormalizedTypesConfig.php @@ -48,7 +48,7 @@ public function keyedArray(string $name, ParamConfigurator|string|array $value): } /** - * @template TValue + * @template TValue of mixed * @param TValue $value * @default {"enabled":null} * @return \Symfony\Config\ScalarNormalizedTypes\ObjectConfig|$this @@ -74,7 +74,7 @@ public function object(mixed $value = []): \Symfony\Config\ScalarNormalizedTypes } /** - * @template TValue + * @template TValue of mixed * @param TValue $value * @return \Symfony\Config\ScalarNormalizedTypes\ListObjectConfig|$this * @psalm-return (TValue is array ? \Symfony\Config\ScalarNormalizedTypes\ListObjectConfig : static) @@ -92,7 +92,7 @@ public function listObject(mixed $value = []): \Symfony\Config\ScalarNormalizedT } /** - * @template TValue + * @template TValue of mixed * @param TValue $value * @return \Symfony\Config\ScalarNormalizedTypes\KeyedListObjectConfig|$this * @psalm-return (TValue is array ? \Symfony\Config\ScalarNormalizedTypes\KeyedListObjectConfig : static) diff --git a/src/Symfony/Component/Config/Tests/Builder/GeneratedConfigTest.php b/src/Symfony/Component/Config/Tests/Builder/GeneratedConfigTest.php index 680010f00fc3c..856bcf279575e 100644 --- a/src/Symfony/Component/Config/Tests/Builder/GeneratedConfigTest.php +++ b/src/Symfony/Component/Config/Tests/Builder/GeneratedConfigTest.php @@ -58,6 +58,7 @@ public static function fixtureNames() 'AddToList' => 'add_to_list', 'NodeInitialValues' => 'node_initial_values', 'ArrayExtraKeys' => 'array_extra_keys', + 'ArrayValues' => 'array_values', ]; foreach ($array as $name => $alias) { @@ -159,10 +160,12 @@ public function testSetExtraKeyMethodIsNotGeneratedWhenAllowExtraKeysIsFalse() */ private function generateConfigBuilder(string $configurationClass, ?string &$outputDir = null) { - $outputDir = tempnam(sys_get_temp_dir(), 'sf_config_builder_'); - unlink($outputDir); - mkdir($outputDir); - $this->tempDir[] = $outputDir; + if (null === $outputDir) { + $outputDir = tempnam(sys_get_temp_dir(), 'sf_config_builder_'); + unlink($outputDir); + mkdir($outputDir); + $this->tempDir[] = $outputDir; + } $configuration = new $configurationClass(); $rootNode = $configuration->getConfigTreeBuilder()->buildTree(); @@ -193,6 +196,8 @@ private function assertDirectorySame($expected, $current) } $currentFiles[substr($file->getPathname(), \strlen($current))] = $file->getPathname(); } + ksort($expectedFiles); + ksort($currentFiles); $this->assertSame(array_keys($expectedFiles), array_keys($currentFiles)); foreach ($expectedFiles as $fileName => $filePath) { diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php index c75841afe9439..6ede6c4e9b9bc 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php @@ -13,6 +13,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\EnumNodeDefinition; +use Symfony\Component\Config\Tests\Fixtures\StringBackedTestEnum; +use Symfony\Component\Config\Tests\Fixtures\TestEnum; class EnumNodeDefinitionTest extends TestCase { @@ -25,14 +27,34 @@ public function testWithOneValue() $this->assertEquals(['foo'], $node->getValues()); } + public function testWithUnitEnumFqcn() + { + $def = new EnumNodeDefinition('foo'); + $def->enumFqcn(TestEnum::class); + + $node = $def->getNode(); + $this->assertEquals(TestEnum::class, $node->getEnumFqcn()); + } + public function testNoValuesPassed() { $this->expectException(\RuntimeException::class); - $this->expectExceptionMessage('You must call ->values() on enum nodes.'); + $this->expectExceptionMessage('You must call either ->values() or ->enumFqcn() on enum nodes.'); $def = new EnumNodeDefinition('foo'); $def->getNode(); } + public function testBothValuesAndEnumFqcnPassed() + { + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('You must call either ->values() or ->enumFqcn() on enum nodes but not both.'); + $def = new EnumNodeDefinition('foo'); + $def->values([123]) + ->enumFqcn(StringBackedTestEnum::class); + + $def->getNode(); + } + public function testWithNoValues() { $this->expectException(\InvalidArgumentException::class); diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php index c8700fda9734b..d1447376e270c 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php @@ -42,11 +42,23 @@ public function testIfTrueExpression() ->end(); $this->assertFinalizedValueIs('new_value', $test); + $test = $this->getTestBuilder() + ->ifTrue(fn () => 1) + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('new_value', $test); + $test = $this->getTestBuilder() ->ifTrue(fn () => false) ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('value', $test); + + $test = $this->getTestBuilder() + ->ifTrue(fn () => 0) + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('value', $test); } public function testIfFalseExpression() @@ -58,16 +70,28 @@ public function testIfFalseExpression() $this->assertFinalizedValueIs('new_value', $test, ['key' => false]); $test = $this->getTestBuilder() - ->ifFalse(fn () => true) + ->ifFalse(fn ($v) => 'value' === $v) ->then($this->returnClosure('new_value')) ->end(); - $this->assertFinalizedValueIs('new_value', $test); + $this->assertFinalizedValueIs('value', $test); $test = $this->getTestBuilder() - ->ifFalse(fn () => false) + ->ifFalse(fn ($v) => 1) ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('value', $test); + + $test = $this->getTestBuilder() + ->ifFalse(fn ($v) => 'other_value' === $v) + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('new_value', $test); + + $test = $this->getTestBuilder() + ->ifFalse(fn ($v) => 0) + ->then($this->returnClosure('new_value')) + ->end(); + $this->assertFinalizedValueIs('new_value', $test); } public function testIfStringExpression() diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/NodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/NodeDefinitionTest.php index 68c1ddff00d91..baa4518006bb6 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/NodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/NodeDefinitionTest.php @@ -35,4 +35,35 @@ public function testSetPathSeparatorChangesChildren() $parentNode->setPathSeparator('/'); } + + public function testDocUrl() + { + $node = new ArrayNodeDefinition('node'); + $node->docUrl('https://example.com/doc/{package}/{version:major}.{version:minor}', 'phpunit/phpunit'); + + $r = new \ReflectionObject($node); + $p = $r->getProperty('attributes'); + + $this->assertMatchesRegularExpression('~^https://example.com/doc/phpunit/phpunit/\d+\.\d+$~', $p->getValue($node)['docUrl']); + } + + public function testDocUrlWithoutPackage() + { + $node = new ArrayNodeDefinition('node'); + $node->docUrl('https://example.com/doc/empty{version:major}.empty{version:minor}'); + + $r = new \ReflectionObject($node); + $p = $r->getProperty('attributes'); + + $this->assertSame('https://example.com/doc/empty.empty', $p->getValue($node)['docUrl']); + } + + public function testUnknownPackageThrowsException() + { + $this->expectException(\OutOfBoundsException::class); + $this->expectExceptionMessage('Package "phpunit/invalid" is not installed'); + + $node = new ArrayNodeDefinition('node'); + $node->docUrl('https://example.com/doc/{package}/{version:major}.{version:minor}', 'phpunit/invalid'); + } } diff --git a/src/Symfony/Component/Config/Tests/Definition/Dumper/XmlReferenceDumperTest.php b/src/Symfony/Component/Config/Tests/Definition/Dumper/XmlReferenceDumperTest.php index 84d9f596c1892..a2e5ba6f089b7 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Dumper/XmlReferenceDumperTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Dumper/XmlReferenceDumperTest.php @@ -42,6 +42,8 @@ private function getConfigurationAsString() + + diff --git a/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php b/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php index cb33603f6cbb0..534372bc6eace 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php @@ -103,6 +103,8 @@ private function getConfigurationAsString(): string node_with_a_looong_name: ~ enum_with_default: this # One of "this"; "that" enum: ~ # One of "this"; "that"; Symfony\Component\Config\Tests\Fixtures\TestEnum::Ccc + enum_with_class: ~ # One of foo; bar + unit_enum_with_class: ~ # One of Symfony\Component\Config\Tests\Fixtures\TestEnum::Foo; Symfony\Component\Config\Tests\Fixtures\TestEnum::Bar; Symfony\Component\Config\Tests\Fixtures\TestEnum::Ccc # some info array: diff --git a/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php index 48bfc4895d1a4..6bfbfdfd4c113 100644 --- a/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php @@ -14,6 +14,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\EnumNode; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; +use Symfony\Component\Config\Tests\Fixtures\IntegerBackedTestEnum; +use Symfony\Component\Config\Tests\Fixtures\StringBackedTestEnum; +use Symfony\Component\Config\Tests\Fixtures\StringBackedTestEnum2; use Symfony\Component\Config\Tests\Fixtures\TestEnum; use Symfony\Component\Config\Tests\Fixtures\TestEnum2; @@ -33,6 +36,20 @@ public function testConstructionWithNoValues() new EnumNode('foo', null, []); } + public function testConstructionWithBothValuesAndEnumFqcn() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('$values or $enumFqcn cannot be both set.'); + new EnumNode('foo', null, [1, 2], enumFqcn: StringBackedTestEnum::class); + } + + public function testConstructionWithInvlaidEnumFqcn() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('The "Symfony\Component\Config\Tests\Definition\InvalidEnum" enum does not exist.'); + new EnumNode('foo', null, enumFqcn: InvalidEnum::class); + } + public function testConstructionWithOneValue() { $node = new EnumNode('foo', null, ['foo']); @@ -61,6 +78,111 @@ public function testFinalizeWithInvalidValue() $node->finalize('foobar'); } + public function testFinalizeUnitEnumFqcnWithInvalidValue() + { + $node = new EnumNode('foo', null, enumFqcn: TestEnum::class); + + $this->expectException(InvalidConfigurationException::class); + $this->expectExceptionMessage('The value "foobar" is not allowed for path "foo". Permissible values: Symfony\Component\Config\Tests\Fixtures\TestEnum::Foo, Symfony\Component\Config\Tests\Fixtures\TestEnum::Bar, Symfony\Component\Config\Tests\Fixtures\TestEnum::Ccc (cases of the "Symfony\Component\Config\Tests\Fixtures\TestEnum" enum)'); + + $node->finalize('foobar'); + } + + public function testFinalizeWithStringEnumFqcn() + { + $node = new EnumNode('foo', null, enumFqcn: StringBackedTestEnum::class); + + $this->assertSame(StringBackedTestEnum::Foo, $node->finalize(StringBackedTestEnum::Foo)); + } + + public function testFinalizeWithIntegerEnumFqcn() + { + $node = new EnumNode('foo', null, enumFqcn: IntegerBackedTestEnum::class); + + $this->assertSame(IntegerBackedTestEnum::One, $node->finalize(IntegerBackedTestEnum::One)); + } + + public function testFinalizeWithUnitEnumFqcn() + { + $node = new EnumNode('foo', null, enumFqcn: TestEnum::class); + + $this->assertSame(TestEnum::Foo, $node->finalize(TestEnum::Foo)); + } + + public function testFinalizeAnotherEnumWithEnumFqcn() + { + $node = new EnumNode('foo', null, enumFqcn: StringBackedTestEnum::class); + + $this->expectException(InvalidConfigurationException::class); + $this->expectExceptionMessage('The value should be part of the "Symfony\Component\Config\Tests\Fixtures\StringBackedTestEnum" enum, got a value from the "Symfony\Component\Config\Tests\Fixtures\StringBackedTestEnum2" enum.'); + + $node->finalize(StringBackedTestEnum2::Foo); + } + + public function testFinalizeWithEnumFqcnWorksWithPlainString() + { + $node = new EnumNode('foo', null, enumFqcn: StringBackedTestEnum::class); + + $this->assertSame(StringBackedTestEnum::Foo, $node->finalize('foo')); + } + + public function testFinalizeWithEnumFqcnWorksWithInteger() + { + $node = new EnumNode('foo', null, enumFqcn: IntegerBackedTestEnum::class); + + $this->assertSame(IntegerBackedTestEnum::One, $node->finalize(1)); + } + + public function testFinalizeWithStringEnumFqcnWithWrongCase() + { + $node = new EnumNode('foo', null, enumFqcn: StringBackedTestEnum::class); + + $this->expectException(InvalidConfigurationException::class); + $this->expectExceptionMessage('The value "qux" is not allowed for path "foo". Permissible values: foo, bar (cases of the "Symfony\Component\Config\Tests\Fixtures\StringBackedTestEnum" enum)'); + + $node->finalize('qux'); + } + + public function testFinalizeWithStringEnumFqcnWithIntegerCase() + { + $node = new EnumNode('foo', null, enumFqcn: StringBackedTestEnum::class); + + $this->expectException(InvalidConfigurationException::class); + $this->expectExceptionMessage('The value 1 is not allowed for path "foo". Permissible values: foo, bar (cases of the "Symfony\Component\Config\Tests\Fixtures\StringBackedTestEnum" enum).'); + + $node->finalize(1); + } + + public function testFinalizeWithIntegerEnumFqcnWithWrongCase() + { + $node = new EnumNode('foo', null, enumFqcn: IntegerBackedTestEnum::class); + + $this->expectException(InvalidConfigurationException::class); + $this->expectExceptionMessage('The value 3 is not allowed for path "foo". Permissible values: 1, 2 (cases of the "Symfony\Component\Config\Tests\Fixtures\IntegerBackedTestEnum" enum).'); + + $node->finalize(3); + } + + public function testFinalizeWithIntegerEnumFqcnWithStringCase() + { + $node = new EnumNode('foo', null, enumFqcn: IntegerBackedTestEnum::class); + + $this->expectException(InvalidConfigurationException::class); + $this->expectExceptionMessage('The value "my string" is not allowed for path "foo". Permissible values: 1, 2 (cases of the "Symfony\Component\Config\Tests\Fixtures\IntegerBackedTestEnum" enum).'); + + $node->finalize('my string'); + } + + public function testFinalizeWithEnumFqcnWithWrongType() + { + $node = new EnumNode('foo', null, enumFqcn: StringBackedTestEnum::class); + + $this->expectException(InvalidConfigurationException::class); + $this->expectExceptionMessage('Only strings and integers can be cast to a case of the "Symfony\Component\Config\Tests\Fixtures\StringBackedTestEnum" enum, got value of type "bool".'); + + $node->finalize(true); + } + public function testWithPlaceHolderWithValidValue() { $node = new EnumNode('cookie_samesite', null, ['lax', 'strict', 'none']); diff --git a/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php index f1868a04a1509..f33a79ff0477e 100644 --- a/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php @@ -24,7 +24,7 @@ public function testGetDefaultValueReturnsAnEmptyArrayForPrototypes() $node = new PrototypedArrayNode('root'); $prototype = new ArrayNode(null, $node); $node->setPrototype($prototype); - $this->assertEmpty($node->getDefaultValue()); + $this->assertSame([], $node->getDefaultValue()); } public function testGetDefaultValueReturnsDefaultValueForPrototypes() diff --git a/src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php b/src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php index 9f62a684a38fa..ef5256bb2d8a0 100644 --- a/src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php +++ b/src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php @@ -13,6 +13,7 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; +use Symfony\Component\Config\Tests\Fixtures\StringBackedTestEnum; use Symfony\Component\Config\Tests\Fixtures\TestEnum; class ExampleConfiguration implements ConfigurationInterface @@ -40,6 +41,8 @@ public function getConfigTreeBuilder(): TreeBuilder ->scalarNode('node_with_a_looong_name')->end() ->enumNode('enum_with_default')->values(['this', 'that'])->defaultValue('this')->end() ->enumNode('enum')->values(['this', 'that', TestEnum::Ccc])->end() + ->enumNode('enum_with_class')->enumFqcn(StringBackedTestEnum::class)->end() + ->enumNode('unit_enum_with_class')->enumFqcn(TestEnum::class)->end() ->arrayNode('array') ->info('some info') ->canBeUnset() diff --git a/src/Symfony/Component/Config/Tests/Fixtures/IntegerBackedTestEnum.php b/src/Symfony/Component/Config/Tests/Fixtures/IntegerBackedTestEnum.php new file mode 100644 index 0000000000000..50246352ddeac --- /dev/null +++ b/src/Symfony/Component/Config/Tests/Fixtures/IntegerBackedTestEnum.php @@ -0,0 +1,9 @@ +assertTrue($res->isFresh(0)); } + + public function testEnum() + { + $res = new ReflectionClassResource($enum = new \ReflectionClass(SomeEnum::class)); + $r = new \ReflectionClass(ReflectionClassResource::class); + $generateSignature = $r->getMethod('generateSignature')->getClosure($res); + $actual = implode("\n", iterator_to_array($generateSignature($enum))); + $this->assertStringContainsString('UnitEnum', $actual); + $this->assertStringContainsString('TestAttribute', $actual); + $this->assertStringContainsString('Beta', $actual); + } + + public function testBackedEnum() + { + $res = new ReflectionClassResource($enum = new \ReflectionClass(SomeBackedEnum::class)); + $r = new \ReflectionClass(ReflectionClassResource::class); + $generateSignature = $r->getMethod('generateSignature')->getClosure($res); + $actual = implode("\n", iterator_to_array($generateSignature($enum))); + $this->assertStringContainsString('UnitEnum', $actual); + $this->assertStringContainsString('BackedEnum', $actual); + $this->assertStringContainsString('TestAttribute', $actual); + $this->assertStringContainsString('Beta', $actual); + $this->assertStringContainsString('beta', $actual); + } } interface DummyInterface @@ -225,3 +249,19 @@ class TestServiceWithStaticProperty { public static object $initializedObject; } + +enum SomeEnum +{ + case Alpha; + + #[TestAttribute] + case Beta; +} + +enum SomeBackedEnum: string +{ + case Alpha = 'alpha'; + + #[TestAttribute] + case Beta = 'beta'; +} diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 78d885d2597a9..f0e0a303ee905 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -17,7 +17,6 @@ use Symfony\Component\Console\Command\HelpCommand; use Symfony\Component\Console\Command\LazyCommand; use Symfony\Component\Console\Command\ListCommand; -use Symfony\Component\Console\Command\SignalableCommandInterface; use Symfony\Component\Console\CommandLoader\CommandLoaderInterface; use Symfony\Component\Console\Completion\CompletionInput; use Symfony\Component\Console\Completion\CompletionSuggestions; @@ -1005,8 +1004,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI } } - $commandSignals = $command instanceof SignalableCommandInterface ? $command->getSubscribedSignals() : []; - if ($commandSignals || $this->dispatcher && $this->signalsToDispatchEvent) { + if (($commandSignals = $command->getSubscribedSignals()) || $this->dispatcher && $this->signalsToDispatchEvent) { $signalRegistry = $this->getSignalRegistry(); if (Terminal::hasSttyAvailable()) { @@ -1277,7 +1275,7 @@ private function splitStringByWidth(string $string, int $width): array foreach (preg_split('//u', $m[0]) as $char) { // test if $char could be appended to current line - if (mb_strwidth($line.$char, 'utf8') <= $width) { + if (Helper::width($line.$char) <= $width) { $line .= $char; continue; } diff --git a/src/Symfony/Component/Console/Attribute/Argument.php b/src/Symfony/Component/Console/Attribute/Argument.php index 099d49676e033..e6a94d2f10e4c 100644 --- a/src/Symfony/Component/Console/Attribute/Argument.php +++ b/src/Symfony/Component/Console/Attribute/Argument.php @@ -16,6 +16,7 @@ use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\String\UnicodeString; #[\Attribute(\Attribute::TARGET_PARAMETER)] class Argument @@ -25,6 +26,7 @@ class Argument private string|bool|int|float|array|null $default = null; private array|\Closure $suggestedValues; private ?int $mode = null; + private string $function = ''; /** * Represents a console command definition. @@ -34,8 +36,8 @@ class Argument * @param array|callable(CompletionInput):list $suggestedValues The values used for input completion */ public function __construct( - public string $name = '', public string $description = '', + public string $name = '', array|callable $suggestedValues = [], ) { $this->suggestedValues = \is_callable($suggestedValues) ? $suggestedValues(...) : $suggestedValues; @@ -51,21 +53,27 @@ public static function tryFrom(\ReflectionParameter $parameter): ?self return null; } + if (($function = $parameter->getDeclaringFunction()) instanceof \ReflectionMethod) { + $self->function = $function->class.'::'.$function->name; + } else { + $self->function = $function->name; + } + $type = $parameter->getType(); $name = $parameter->getName(); if (!$type instanceof \ReflectionNamedType) { - throw new LogicException(\sprintf('The parameter "$%s" must have a named type. Untyped, Union or Intersection types are not supported for command arguments.', $name)); + throw new LogicException(\sprintf('The parameter "$%s" of "%s()" must have a named type. Untyped, Union or Intersection types are not supported for command arguments.', $name, $self->function)); } $parameterTypeName = $type->getName(); if (!\in_array($parameterTypeName, self::ALLOWED_TYPES, true)) { - throw new LogicException(\sprintf('The type "%s" of parameter "$%s" is not supported as a command argument. Only "%s" types are allowed.', $parameterTypeName, $name, implode('", "', self::ALLOWED_TYPES))); + throw new LogicException(\sprintf('The type "%s" on parameter "$%s" of "%s()" is not supported as a command argument. Only "%s" types are allowed.', $parameterTypeName, $name, $self->function, implode('", "', self::ALLOWED_TYPES))); } if (!$self->name) { - $self->name = $name; + $self->name = (new UnicodeString($name))->kebab(); } $self->default = $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null; diff --git a/src/Symfony/Component/Console/Attribute/AsCommand.php b/src/Symfony/Component/Console/Attribute/AsCommand.php index 2147e71510436..767d46ebb7ff1 100644 --- a/src/Symfony/Component/Console/Attribute/AsCommand.php +++ b/src/Symfony/Component/Console/Attribute/AsCommand.php @@ -13,6 +13,8 @@ /** * Service tag to autoconfigure commands. + * + * @final since Symfony 7.3 */ #[\Attribute(\Attribute::TARGET_CLASS)] class AsCommand diff --git a/src/Symfony/Component/Console/Attribute/Option.php b/src/Symfony/Component/Console/Attribute/Option.php index 02002a5ad1256..788353463a2ca 100644 --- a/src/Symfony/Component/Console/Attribute/Option.php +++ b/src/Symfony/Component/Console/Attribute/Option.php @@ -16,17 +16,20 @@ use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\String\UnicodeString; #[\Attribute(\Attribute::TARGET_PARAMETER)] class Option { private const ALLOWED_TYPES = ['string', 'bool', 'int', 'float', 'array']; + private const ALLOWED_UNION_TYPES = ['bool|string', 'bool|int', 'bool|float']; private string|bool|int|float|array|null $default = null; private array|\Closure $suggestedValues; private ?int $mode = null; private string $typeName = ''; private bool $allowNull = false; + private string $function = ''; /** * Represents a console command --option definition. @@ -37,9 +40,9 @@ class Option * @param array|callable(CompletionInput):list $suggestedValues The values used for input completion */ public function __construct( + public string $description = '', public string $name = '', public array|string|null $shortcut = null, - public string $description = '', array|callable $suggestedValues = [], ) { $this->suggestedValues = \is_callable($suggestedValues) ? $suggestedValues(...) : $suggestedValues; @@ -55,40 +58,57 @@ public static function tryFrom(\ReflectionParameter $parameter): ?self return null; } - $type = $parameter->getType(); + if (($function = $parameter->getDeclaringFunction()) instanceof \ReflectionMethod) { + $self->function = $function->class.'::'.$function->name; + } else { + $self->function = $function->name; + } + $name = $parameter->getName(); + $type = $parameter->getType(); + + if (!$parameter->isDefaultValueAvailable()) { + throw new LogicException(\sprintf('The option parameter "$%s" of "%s()" must declare a default value.', $name, $self->function)); + } + + if (!$self->name) { + $self->name = (new UnicodeString($name))->kebab(); + } + + $self->default = $parameter->getDefaultValue(); + $self->allowNull = $parameter->allowsNull(); + + if ($type instanceof \ReflectionUnionType) { + return $self->handleUnion($type); + } if (!$type instanceof \ReflectionNamedType) { - throw new LogicException(\sprintf('The parameter "$%s" must have a named type. Untyped, Union or Intersection types are not supported for command options.', $name)); + throw new LogicException(\sprintf('The parameter "$%s" of "%s()" must have a named type. Untyped or Intersection types are not supported for command options.', $name, $self->function)); } $self->typeName = $type->getName(); if (!\in_array($self->typeName, self::ALLOWED_TYPES, true)) { - throw new LogicException(\sprintf('The type "%s" of parameter "$%s" is not supported as a command option. Only "%s" types are allowed.', $self->typeName, $name, implode('", "', self::ALLOWED_TYPES))); + throw new LogicException(\sprintf('The type "%s" on parameter "$%s" of "%s()" is not supported as a command option. Only "%s" types are allowed.', $self->typeName, $name, $self->function, implode('", "', self::ALLOWED_TYPES))); } - if (!$parameter->isDefaultValueAvailable()) { - throw new LogicException(\sprintf('The option parameter "$%s" must declare a default value.', $name)); + if ('bool' === $self->typeName && $self->allowNull && \in_array($self->default, [true, false], true)) { + throw new LogicException(\sprintf('The option parameter "$%s" of "%s()" must not be nullable when it has a default boolean value.', $name, $self->function)); } - if (!$self->name) { - $self->name = $name; + if ($self->allowNull && null !== $self->default) { + throw new LogicException(\sprintf('The option parameter "$%s" of "%s()" must either be not-nullable or have a default of null.', $name, $self->function)); } - $self->default = $parameter->getDefaultValue(); - $self->allowNull = $parameter->allowsNull(); - if ('bool' === $self->typeName) { $self->mode = InputOption::VALUE_NONE; if (false !== $self->default) { $self->mode |= InputOption::VALUE_NEGATABLE; } + } elseif ('array' === $self->typeName) { + $self->mode = InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY; } else { - $self->mode = $self->allowNull ? InputOption::VALUE_OPTIONAL : InputOption::VALUE_REQUIRED; - if ('array' === $self->typeName) { - $self->mode |= InputOption::VALUE_IS_ARRAY; - } + $self->mode = InputOption::VALUE_REQUIRED; } if (\is_array($self->suggestedValues) && !\is_callable($self->suggestedValues) && 2 === \count($self->suggestedValues) && ($instance = $parameter->getDeclaringFunction()->getClosureThis()) && $instance::class === $self->suggestedValues[0] && \is_callable([$instance, $self->suggestedValues[1]])) { @@ -116,6 +136,14 @@ public function resolveValue(InputInterface $input): mixed { $value = $input->getOption($this->name); + if (null === $value && \in_array($this->typeName, self::ALLOWED_UNION_TYPES, true)) { + return true; + } + + if ('array' === $this->typeName && $this->allowNull && [] === $value) { + return null; + } + if ('bool' !== $this->typeName) { return $value; } @@ -126,4 +154,28 @@ public function resolveValue(InputInterface $input): mixed return $value ?? $this->default; } + + private function handleUnion(\ReflectionUnionType $type): self + { + $types = array_map( + static fn (\ReflectionType $t) => $t instanceof \ReflectionNamedType ? $t->getName() : null, + $type->getTypes(), + ); + + sort($types); + + $this->typeName = implode('|', array_filter($types)); + + if (!\in_array($this->typeName, self::ALLOWED_UNION_TYPES, true)) { + throw new LogicException(\sprintf('The union type for parameter "$%s" of "%s()" is not supported as a command option. Only "%s" types are allowed.', $this->name, $this->function, implode('", "', self::ALLOWED_UNION_TYPES))); + } + + if (false !== $this->default) { + throw new LogicException(\sprintf('The option parameter "$%s" of "%s()" must have a default value of false.', $this->name, $this->function)); + } + + $this->mode = InputOption::VALUE_OPTIONAL; + + return $this; + } } diff --git a/src/Symfony/Component/Console/CHANGELOG.md b/src/Symfony/Component/Console/CHANGELOG.md index fc2b64bf156bb..9f3ae3d7d2326 100644 --- a/src/Symfony/Component/Console/CHANGELOG.md +++ b/src/Symfony/Component/Console/CHANGELOG.md @@ -4,10 +4,17 @@ CHANGELOG 7.3 --- + * Add `TreeHelper` and `TreeStyle` to display tree-like structures + * Add `SymfonyStyle::createTree()` * Add support for invokable commands and add `#[Argument]` and `#[Option]` attributes to define input arguments and options * Deprecate not declaring the parameter type in callable commands defined through `setCode` method * Add support for help definition via `AsCommand` attribute * Deprecate methods `Command::getDefaultName()` and `Command::getDefaultDescription()` in favor of the `#[AsCommand]` attribute + * Add support for Markdown format in `Table` + * Add support for `LockableTrait` in invokable commands + * Deprecate returning a non-integer value from a `\Closure` function set via `Command::setCode()` + * Mark `#[AsCommand]` attribute as `@final` + * Add support for `SignalableCommandInterface` with invokable commands 7.2 --- diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 5e30eb5fa8390..72a10cf7603c4 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -32,7 +32,7 @@ * * @author Fabien Potencier */ -class Command +class Command implements SignalableCommandInterface { // see https://tldp.org/LDP/abs/html/exitcodes.html public const SUCCESS = 0; @@ -134,7 +134,7 @@ public function __construct(?string $name = null) $this->setHelp($attribute?->help ?? ''); } - if (\is_callable($this)) { + if (\is_callable($this) && self::class === (new \ReflectionMethod($this, 'execute'))->getDeclaringClass()->name) { $this->code = new InvokableCommand($this, $this(...)); } @@ -347,7 +347,7 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti */ public function setCode(callable $code): static { - $this->code = new InvokableCommand($this, $code, triggerDeprecations: true); + $this->code = new InvokableCommand($this, $code); return $this; } @@ -674,6 +674,16 @@ public function getHelper(string $name): HelperInterface return $this->helperSet->get($name); } + public function getSubscribedSignals(): array + { + return $this->code?->getSubscribedSignals() ?? []; + } + + public function handleSignal(int $signal, int|false $previousExitCode = 0): int|false + { + return $this->code?->handleSignal($signal, $previousExitCode) ?? false; + } + /** * Validates a command name. * diff --git a/src/Symfony/Component/Console/Command/InvokableCommand.php b/src/Symfony/Component/Console/Command/InvokableCommand.php index 2b3c41501111f..72ff407c81fdf 100644 --- a/src/Symfony/Component/Console/Command/InvokableCommand.php +++ b/src/Symfony/Component/Console/Command/InvokableCommand.php @@ -28,17 +28,19 @@ * * @internal */ -class InvokableCommand +class InvokableCommand implements SignalableCommandInterface { private readonly \Closure $code; + private readonly ?SignalableCommandInterface $signalableCommand; private readonly \ReflectionFunction $reflection; + private bool $triggerDeprecations = false; public function __construct( private readonly Command $command, callable $code, - private readonly bool $triggerDeprecations = false, ) { $this->code = $this->getClosure($code); + $this->signalableCommand = $code instanceof SignalableCommandInterface ? $code : null; $this->reflection = new \ReflectionFunction($this->code); } @@ -49,17 +51,17 @@ public function __invoke(InputInterface $input, OutputInterface $output): int { $statusCode = ($this->code)(...$this->getParameters($input, $output)); - if (null !== $statusCode && !\is_int($statusCode)) { + if (!\is_int($statusCode)) { if ($this->triggerDeprecations) { trigger_deprecation('symfony/console', '7.3', \sprintf('Returning a non-integer value from the command "%s" is deprecated and will throw an exception in Symfony 8.0.', $this->command->getName())); return 0; } - throw new LogicException(\sprintf('The command "%s" must return either void or an integer value in the "%s" method, but "%s" was returned.', $this->command->getName(), $this->reflection->getName(), get_debug_type($statusCode))); + throw new \TypeError(\sprintf('The command "%s" must return an integer value in the "%s" method, but "%s" was returned.', $this->command->getName(), $this->reflection->getName(), get_debug_type($statusCode))); } - return $statusCode ?? 0; + return $statusCode; } /** @@ -85,6 +87,8 @@ private function getClosure(callable $code): \Closure return $code(...); } + $this->triggerDeprecations = true; + if (null !== (new \ReflectionFunction($code))->getClosureThis()) { return $code; } @@ -140,4 +144,14 @@ private function getParameters(InputInterface $input, OutputInterface $output): return $parameters ?: [$input, $output]; } + + public function getSubscribedSignals(): array + { + return $this->signalableCommand?->getSubscribedSignals() ?? []; + } + + public function handleSignal(int $signal, int|false $previousExitCode = 0): int|false + { + return $this->signalableCommand?->handleSignal($signal, $previousExitCode) ?? false; + } } diff --git a/src/Symfony/Component/Console/Command/LockableTrait.php b/src/Symfony/Component/Console/Command/LockableTrait.php index f0001cc52d772..b7abd2fdc5892 100644 --- a/src/Symfony/Component/Console/Command/LockableTrait.php +++ b/src/Symfony/Component/Console/Command/LockableTrait.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Command; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Lock\LockFactory; use Symfony\Component\Lock\LockInterface; @@ -48,10 +49,20 @@ private function lock(?string $name = null, bool $blocking = false): bool $store = new FlockStore(); } - $this->lockFactory = (new LockFactory($store)); + $this->lockFactory = new LockFactory($store); } - $this->lock = $this->lockFactory->createLock($name ?: $this->getName()); + if (!$name) { + if ($this instanceof Command) { + $name = $this->getName(); + } elseif ($attribute = (new \ReflectionClass($this::class))->getAttributes(AsCommand::class)) { + $name = $attribute[0]->newInstance()->name; + } else { + throw new LogicException(\sprintf('Lock name missing: provide it via "%s()", #[AsCommand] attribute, or by extending Command class.', __METHOD__)); + } + } + + $this->lock = $this->lockFactory->createLock($name); if (!$this->lock->acquire($blocking)) { $this->lock = null; diff --git a/src/Symfony/Component/Console/Command/TraceableCommand.php b/src/Symfony/Component/Console/Command/TraceableCommand.php index 659798e651c46..ed11cc29f872b 100644 --- a/src/Symfony/Component/Console/Command/TraceableCommand.php +++ b/src/Symfony/Component/Console/Command/TraceableCommand.php @@ -27,7 +27,7 @@ * * @author Jules Pietri */ -final class TraceableCommand extends Command implements SignalableCommandInterface +final class TraceableCommand extends Command { public readonly Command $command; public int $exitCode; @@ -89,15 +89,11 @@ public function __call(string $name, array $arguments): mixed public function getSubscribedSignals(): array { - return $this->command instanceof SignalableCommandInterface ? $this->command->getSubscribedSignals() : []; + return $this->command->getSubscribedSignals(); } public function handleSignal(int $signal, int|false $previousExitCode = 0): int|false { - if (!$this->command instanceof SignalableCommandInterface) { - return false; - } - $event = $this->stopwatch->start($this->getName().'.handle_signal'); $exit = $this->command->handleSignal($signal, $previousExitCode); @@ -296,7 +292,7 @@ public function run(InputInterface $input, OutputInterface $output): int $event = $this->stopwatch->start($this->getName(), 'command'); try { - $this->exitCode = parent::run($input, $output); + $this->exitCode = $this->command->run($input, $output); } finally { $event->stop(); diff --git a/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php b/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php index a90fb8f04606e..562627f4b6114 100644 --- a/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php +++ b/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php @@ -39,7 +39,6 @@ public function process(ContainerBuilder $container): void foreach ($commandServices as $id => $tags) { $definition = $container->getDefinition($id); - $definition->addTag('container.no_preload'); $class = $container->getParameterBag()->resolveValue($definition->getClass()); if (!$r = $container->getReflectionClass($class)) { @@ -58,6 +57,8 @@ public function process(ContainerBuilder $container): void $invokableRef = null; } + $definition->addTag('container.no_preload'); + /** @var AsCommand|null $attribute */ $attribute = ($r->getAttributes(AsCommand::class)[0] ?? null)?->newInstance(); diff --git a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php index 956303709645f..9a8e696cd4135 100644 --- a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php @@ -108,7 +108,7 @@ private function getInputOptionData(InputOption $option, bool $negated = false): 'is_value_required' => false, 'is_multiple' => false, 'description' => 'Negate the "--'.$option->getName().'" option', - 'default' => false, + 'default' => null === $option->getDefault() ? null : !$option->getDefault(), ] : [ 'name' => '--'.$option->getName(), 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '', diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index 3c8c287e8375f..c72728b27de57 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Console\Formatter; use Symfony\Component\Console\Exception\InvalidArgumentException; +use Symfony\Component\Console\Helper\Helper; use function Symfony\Component\String\b; @@ -136,9 +137,11 @@ public function formatAndWrap(?string $message, int $width): string continue; } + // convert byte position to character position. + $pos = Helper::length(substr($message, 0, $pos)); // add the text up to the next tag - $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset), $output, $width, $currentLineLength); - $offset = $pos + \strlen($text); + $output .= $this->applyCurrentStyle(Helper::substr($message, $offset, $pos - $offset), $output, $width, $currentLineLength); + $offset = $pos + Helper::length($text); // opening tag? if ($open = '/' !== $text[1]) { @@ -159,7 +162,7 @@ public function formatAndWrap(?string $message, int $width): string } } - $output .= $this->applyCurrentStyle(substr($message, $offset), $output, $width, $currentLineLength); + $output .= $this->applyCurrentStyle(Helper::substr($message, $offset), $output, $width, $currentLineLength); return strtr($output, ["\0" => '\\', '\\<' => '<', '\\>' => '>']); } @@ -226,8 +229,18 @@ private function applyCurrentStyle(string $text, string $current, int $width, in } if ($currentLineLength) { - $prefix = substr($text, 0, $i = $width - $currentLineLength)."\n"; - $text = substr($text, $i); + $lines = explode("\n", $text, 2); + $prefix = Helper::substr($lines[0], 0, $i = $width - $currentLineLength)."\n"; + $text = Helper::substr($lines[0], $i); + + if (isset($lines[1])) { + // $prefix may contain the full first line in which the \n is already a part of $prefix. + if ('' !== $text) { + $text .= "\n"; + } + + $text .= $lines[1]; + } } else { $prefix = ''; } @@ -242,8 +255,8 @@ private function applyCurrentStyle(string $text, string $current, int $width, in $lines = explode("\n", $text); - foreach ($lines as $line) { - $currentLineLength += \strlen($line); + foreach ($lines as $i => $line) { + $currentLineLength = 0 === $i ? $currentLineLength + Helper::length($line) : Helper::length($line); if ($width <= $currentLineLength) { $currentLineLength = 0; } @@ -262,6 +275,6 @@ private function addLineBreaks(string $text, int $width): string { $encoding = mb_detect_encoding($text, null, true) ?: 'UTF-8'; - return b($text)->toCodePointString($encoding)->wordwrap($width, "\n", true)->toByteString($encoding); + return b($text)->toUnicodeString($encoding)->wordwrap($width, "\n", true)->toByteString($encoding); } } diff --git a/src/Symfony/Component/Console/Helper/Helper.php b/src/Symfony/Component/Console/Helper/Helper.php index ddb2e93035432..46e7e2f58308d 100644 --- a/src/Symfony/Component/Console/Helper/Helper.php +++ b/src/Symfony/Component/Console/Helper/Helper.php @@ -42,7 +42,9 @@ public static function width(?string $string): int $string ??= ''; if (preg_match('//u', $string)) { - return (new UnicodeString($string))->width(false); + $string = preg_replace('/[\p{Cc}\x7F]++/u', '', $string, -1, $count); + + return (new UnicodeString($string))->width(false) + $count; } if (false === $encoding = mb_detect_encoding($string, null, true)) { @@ -78,6 +80,10 @@ public static function substr(?string $string, int $from, ?int $length = null): { $string ??= ''; + if (preg_match('//u', $string)) { + return (new UnicodeString($string))->slice($from, $length); + } + if (false === $encoding = mb_detect_encoding($string, null, true)) { return substr($string, $from, $length); } diff --git a/src/Symfony/Component/Console/Helper/ProgressBar.php b/src/Symfony/Component/Console/Helper/ProgressBar.php index 49e34d8d8c9e8..dc3605ad2fee0 100644 --- a/src/Symfony/Component/Console/Helper/ProgressBar.php +++ b/src/Symfony/Component/Console/Helper/ProgressBar.php @@ -513,12 +513,21 @@ private function overwrite(string $message): void if ($this->output instanceof ConsoleSectionOutput) { $messageLines = explode("\n", $this->previousMessage); $lineCount = \count($messageLines); + + $lastLineWithoutDecoration = Helper::removeDecoration($this->output->getFormatter(), end($messageLines) ?? ''); + + // When the last previous line is empty (without formatting) it is already cleared by the section output, so we don't need to clear it again + if ('' === $lastLineWithoutDecoration) { + --$lineCount; + } + foreach ($messageLines as $messageLine) { $messageLineLength = Helper::width(Helper::removeDecoration($this->output->getFormatter(), $messageLine)); if ($messageLineLength > $this->terminal->getWidth()) { $lineCount += floor($messageLineLength / $this->terminal->getWidth()); } } + $this->output->clear($lineCount); } else { $lineCount = substr_count($this->previousMessage, "\n"); diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index 9ff73d2cc371a..8c3d0a521ef23 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -417,7 +417,7 @@ public function render(): void continue; } - if ($isHeader && !$isHeaderSeparatorRendered) { + if ($isHeader && !$isHeaderSeparatorRendered && $this->style->displayOutsideBorder()) { $this->renderRowSeparator( self::SEPARATOR_TOP, $hasTitle ? $this->headerTitle : null, @@ -449,7 +449,10 @@ public function render(): void } } } - $this->renderRowSeparator(self::SEPARATOR_BOTTOM, $this->footerTitle, $this->style->getFooterTitleFormat()); + + if ($this->getStyle()->displayOutsideBorder()) { + $this->renderRowSeparator(self::SEPARATOR_BOTTOM, $this->footerTitle, $this->style->getFooterTitleFormat()); + } $this->cleanup(); $this->rendered = true; @@ -558,10 +561,7 @@ private function renderCell(array $row, int $column, string $cellFormat): string } // str_pad won't work properly with multi-byte strings, we need to fix the padding - if (false !== $encoding = mb_detect_encoding($cell, null, true)) { - $width += \strlen($cell) - mb_strwidth($cell, $encoding); - } - + $width += \strlen($cell) - Helper::width($cell) - substr_count($cell, "\0"); $style = $this->getColumnStyle($column); if ($cell instanceof TableSeparator) { @@ -626,8 +626,48 @@ private function buildTableRows(array $rows): TableRows foreach ($rows[$rowKey] as $column => $cell) { $colspan = $cell instanceof TableCell ? $cell->getColspan() : 1; - if (isset($this->columnMaxWidths[$column]) && Helper::width(Helper::removeDecoration($formatter, $cell)) > $this->columnMaxWidths[$column]) { - $cell = $formatter->formatAndWrap($cell, $this->columnMaxWidths[$column] * $colspan); + $minWrappedWidth = 0; + $widthApplied = []; + $lengthColumnBorder = $this->getColumnSeparatorWidth() + Helper::width($this->style->getCellRowContentFormat()) - 2; + for ($i = $column; $i < ($column + $colspan); ++$i) { + if (isset($this->columnMaxWidths[$i])) { + $minWrappedWidth += $this->columnMaxWidths[$i]; + $widthApplied[] = ['type' => 'max', 'column' => $i]; + } elseif (($this->columnWidths[$i] ?? 0) > 0 && $colspan > 1) { + $minWrappedWidth += $this->columnWidths[$i]; + $widthApplied[] = ['type' => 'min', 'column' => $i]; + } + } + if (1 === \count($widthApplied)) { + if ($colspan > 1) { + $minWrappedWidth *= $colspan; // previous logic + } + } elseif (\count($widthApplied) > 1) { + $minWrappedWidth += (\count($widthApplied) - 1) * $lengthColumnBorder; + } + + $cellWidth = Helper::width(Helper::removeDecoration($formatter, $cell)); + if ($minWrappedWidth && $cellWidth > $minWrappedWidth) { + $cell = $formatter->formatAndWrap($cell, $minWrappedWidth); + } + // update minimal columnWidths for spanned columns + if ($colspan > 1 && $minWrappedWidth > 0) { + $columnsMinWidthProcessed = []; + $cellWidth = min($cellWidth, $minWrappedWidth); + foreach ($widthApplied as $item) { + if ('max' === $item['type'] && $cellWidth >= $this->columnMaxWidths[$item['column']]) { + $minWidthColumn = $this->columnMaxWidths[$item['column']]; + $this->columnWidths[$item['column']] = $minWidthColumn; + $columnsMinWidthProcessed[$item['column']] = true; + $cellWidth -= $minWidthColumn + $lengthColumnBorder; + } + } + for ($i = $column; $i < ($column + $colspan); ++$i) { + if (isset($columnsMinWidthProcessed[$i])) { + continue; + } + $this->columnWidths[$i] = $cellWidth + $lengthColumnBorder; + } } if (!str_contains($cell ?? '', "\n")) { continue; @@ -868,6 +908,12 @@ private function cleanup(): void */ private static function initStyles(): array { + $markdown = new TableStyle(); + $markdown + ->setDefaultCrossingChar('|') + ->setDisplayOutsideBorder(false) + ; + $borderless = new TableStyle(); $borderless ->setHorizontalBorderChars('=') @@ -905,6 +951,7 @@ private static function initStyles(): array return [ 'default' => new TableStyle(), + 'markdown' => $markdown, 'borderless' => $borderless, 'compact' => $compact, 'symfony-style-guide' => $styleGuide, diff --git a/src/Symfony/Component/Console/Helper/TableStyle.php b/src/Symfony/Component/Console/Helper/TableStyle.php index be956c109edf5..74ac589256834 100644 --- a/src/Symfony/Component/Console/Helper/TableStyle.php +++ b/src/Symfony/Component/Console/Helper/TableStyle.php @@ -46,6 +46,7 @@ class TableStyle private string $cellRowFormat = '%s'; private string $cellRowContentFormat = ' %s '; private string $borderFormat = '%s'; + private bool $displayOutsideBorder = true; private int $padType = \STR_PAD_RIGHT; /** @@ -359,4 +360,16 @@ public function setFooterTitleFormat(string $format): static return $this; } + + public function setDisplayOutsideBorder($displayOutSideBorder): static + { + $this->displayOutsideBorder = $displayOutSideBorder; + + return $this; + } + + public function displayOutsideBorder(): bool + { + return $this->displayOutsideBorder; + } } diff --git a/src/Symfony/Component/Console/Helper/TreeHelper.php b/src/Symfony/Component/Console/Helper/TreeHelper.php new file mode 100644 index 0000000000000..561cd6ccb0320 --- /dev/null +++ b/src/Symfony/Component/Console/Helper/TreeHelper.php @@ -0,0 +1,111 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Helper; + +use Symfony\Component\Console\Output\OutputInterface; + +/** + * The TreeHelper class provides methods to display tree-like structures. + * + * @author Simon André + * + * @implements \RecursiveIterator + */ +final class TreeHelper implements \RecursiveIterator +{ + /** + * @var \Iterator + */ + private \Iterator $children; + + private function __construct( + private readonly OutputInterface $output, + private readonly TreeNode $node, + private readonly TreeStyle $style, + ) { + $this->children = new \IteratorIterator($this->node->getChildren()); + $this->children->rewind(); + } + + public static function createTree(OutputInterface $output, string|TreeNode|null $root = null, iterable $values = [], ?TreeStyle $style = null): self + { + $node = $root instanceof TreeNode ? $root : new TreeNode($root ?? ''); + + return new self($output, TreeNode::fromValues($values, $node), $style ?? TreeStyle::default()); + } + + public function current(): TreeNode + { + return $this->children->current(); + } + + public function key(): int + { + return $this->children->key(); + } + + public function next(): void + { + $this->children->next(); + } + + public function rewind(): void + { + $this->children->rewind(); + } + + public function valid(): bool + { + return $this->children->valid(); + } + + public function hasChildren(): bool + { + if (null === $current = $this->current()) { + return false; + } + + foreach ($current->getChildren() as $child) { + return true; + } + + return false; + } + + public function getChildren(): \RecursiveIterator + { + return new self($this->output, $this->current(), $this->style); + } + + /** + * Recursively renders the tree to the output, applying the tree style. + */ + public function render(): void + { + $treeIterator = new \RecursiveTreeIterator($this); + + $this->style->applyPrefixes($treeIterator); + + $this->output->writeln($this->node->getValue()); + + $visited = new \SplObjectStorage(); + foreach ($treeIterator as $node) { + $currentNode = $node instanceof TreeNode ? $node : $treeIterator->getInnerIterator()->current(); + if ($visited->contains($currentNode)) { + throw new \LogicException(\sprintf('Cycle detected at node: "%s".', $currentNode->getValue())); + } + $visited->attach($currentNode); + + $this->output->writeln($node); + } + } +} diff --git a/src/Symfony/Component/Console/Helper/TreeNode.php b/src/Symfony/Component/Console/Helper/TreeNode.php new file mode 100644 index 0000000000000..8c35266c12a2a --- /dev/null +++ b/src/Symfony/Component/Console/Helper/TreeNode.php @@ -0,0 +1,105 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Helper; + +/** + * @implements \IteratorAggregate + * + * @author Simon André + */ +final class TreeNode implements \Countable, \IteratorAggregate +{ + /** + * @var array + */ + private array $children = []; + + public function __construct( + private readonly string $value = '', + iterable $children = [], + ) { + foreach ($children as $child) { + $this->addChild($child); + } + } + + public static function fromValues(iterable $nodes, ?self $node = null): self + { + $node ??= new self(); + foreach ($nodes as $key => $value) { + if (is_iterable($value)) { + $child = new self($key); + self::fromValues($value, $child); + $node->addChild($child); + } elseif ($value instanceof self) { + $node->addChild($value); + } else { + $node->addChild(new self($value)); + } + } + + return $node; + } + + public function getValue(): string + { + return $this->value; + } + + public function addChild(self|string|callable $node): self + { + if (\is_string($node)) { + $node = new self($node); + } + + $this->children[] = $node; + + return $this; + } + + /** + * @return \Traversable + */ + public function getChildren(): \Traversable + { + foreach ($this->children as $child) { + if (\is_callable($child)) { + yield from $child(); + } elseif ($child instanceof self) { + yield $child; + } + } + } + + /** + * @return \Traversable + */ + public function getIterator(): \Traversable + { + return $this->getChildren(); + } + + public function count(): int + { + $count = 0; + foreach ($this->getChildren() as $child) { + ++$count; + } + + return $count; + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/src/Symfony/Component/Console/Helper/TreeStyle.php b/src/Symfony/Component/Console/Helper/TreeStyle.php new file mode 100644 index 0000000000000..21cc04b3c05e8 --- /dev/null +++ b/src/Symfony/Component/Console/Helper/TreeStyle.php @@ -0,0 +1,78 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Helper; + +/** + * Configures the output of the Tree helper. + * + * @author Simon André + */ +final class TreeStyle +{ + public function __construct( + private readonly string $prefixEndHasNext, + private readonly string $prefixEndLast, + private readonly string $prefixLeft, + private readonly string $prefixMidHasNext, + private readonly string $prefixMidLast, + private readonly string $prefixRight, + ) { + } + + public static function box(): self + { + return new self('┃╸ ', '┗╸ ', '', '┃ ', ' ', ''); + } + + public static function boxDouble(): self + { + return new self('╠═ ', '╚═ ', '', '║ ', ' ', ''); + } + + public static function compact(): self + { + return new self('├ ', '└ ', '', '│ ', ' ', ''); + } + + public static function default(): self + { + return new self('├── ', '└── ', '', '│ ', ' ', ''); + } + + public static function light(): self + { + return new self('|-- ', '`-- ', '', '| ', ' ', ''); + } + + public static function minimal(): self + { + return new self('. ', '. ', '', '. ', ' ', ''); + } + + public static function rounded(): self + { + return new self('├─ ', '╰─ ', '', '│ ', ' ', ''); + } + + /** + * @internal + */ + public function applyPrefixes(\RecursiveTreeIterator $iterator): void + { + $iterator->setPrefixPart(\RecursiveTreeIterator::PREFIX_LEFT, $this->prefixLeft); + $iterator->setPrefixPart(\RecursiveTreeIterator::PREFIX_MID_HAS_NEXT, $this->prefixMidHasNext); + $iterator->setPrefixPart(\RecursiveTreeIterator::PREFIX_MID_LAST, $this->prefixMidLast); + $iterator->setPrefixPart(\RecursiveTreeIterator::PREFIX_END_HAS_NEXT, $this->prefixEndHasNext); + $iterator->setPrefixPart(\RecursiveTreeIterator::PREFIX_END_LAST, $this->prefixEndLast); + $iterator->setPrefixPart(\RecursiveTreeIterator::PREFIX_RIGHT, $this->prefixRight); + } +} diff --git a/src/Symfony/Component/Console/Messenger/RunCommandMessageHandler.php b/src/Symfony/Component/Console/Messenger/RunCommandMessageHandler.php index 0fdf7d01724ac..df5f48af09b92 100644 --- a/src/Symfony/Component/Console/Messenger/RunCommandMessageHandler.php +++ b/src/Symfony/Component/Console/Messenger/RunCommandMessageHandler.php @@ -16,6 +16,8 @@ use Symfony\Component\Console\Exception\RunCommandFailedException; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\BufferedOutput; +use Symfony\Component\Messenger\Exception\RecoverableExceptionInterface; +use Symfony\Component\Messenger\Exception\UnrecoverableExceptionInterface; /** * @author Kevin Bond @@ -36,6 +38,8 @@ public function __invoke(RunCommandMessage $message): RunCommandContext try { $exitCode = $this->application->run($input, $output); + } catch (UnrecoverableExceptionInterface|RecoverableExceptionInterface $e) { + throw $e; } catch (\Throwable $e) { throw new RunCommandFailedException($e, new RunCommandContext($message, Command::FAILURE, $output->fetch())); } diff --git a/src/Symfony/Component/Console/SignalRegistry/SignalMap.php b/src/Symfony/Component/Console/SignalRegistry/SignalMap.php index de419bda79821..2f9aa67c156db 100644 --- a/src/Symfony/Component/Console/SignalRegistry/SignalMap.php +++ b/src/Symfony/Component/Console/SignalRegistry/SignalMap.php @@ -27,7 +27,7 @@ public static function getSignalName(int $signal): ?string if (!isset(self::$map)) { $r = new \ReflectionExtension('pcntl'); $c = $r->getConstants(); - $map = array_filter($c, fn ($k) => str_starts_with($k, 'SIG') && !str_starts_with($k, 'SIG_'), \ARRAY_FILTER_USE_KEY); + $map = array_filter($c, fn ($k) => str_starts_with($k, 'SIG') && !str_starts_with($k, 'SIG_') && 'SIGBABY' !== $k, \ARRAY_FILTER_USE_KEY); self::$map = array_flip($map); } diff --git a/src/Symfony/Component/Console/Style/SymfonyStyle.php b/src/Symfony/Component/Console/Style/SymfonyStyle.php index 4cf62cdba2cd3..d0788e88df663 100644 --- a/src/Symfony/Component/Console/Style/SymfonyStyle.php +++ b/src/Symfony/Component/Console/Style/SymfonyStyle.php @@ -21,6 +21,9 @@ use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Helper\TableCell; use Symfony\Component\Console\Helper\TableSeparator; +use Symfony\Component\Console\Helper\TreeHelper; +use Symfony\Component\Console\Helper\TreeNode; +use Symfony\Component\Console\Helper\TreeStyle; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\ConsoleSectionOutput; @@ -369,6 +372,24 @@ private function getProgressBar(): ProgressBar ?? throw new RuntimeException('The ProgressBar is not started.'); } + /** + * @param iterable $nodes + */ + public function tree(iterable $nodes, string $root = ''): void + { + $this->createTree($nodes, $root)->render(); + } + + /** + * @param iterable $nodes + */ + public function createTree(iterable $nodes, string $root = ''): TreeHelper + { + $output = $this->output instanceof ConsoleOutputInterface ? $this->output->section() : $this->output; + + return TreeHelper::createTree($output, $root, $nodes, TreeStyle::default()); + } + private function autoPrependBlock(): void { $chars = substr(str_replace(\PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2); diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 7549a1d8af5a0..268f8ba501a9e 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -196,8 +196,10 @@ public function testRegister() public function testRegisterAmbiguous() { - $code = function (InputInterface $input, OutputInterface $output) { + $code = function (InputInterface $input, OutputInterface $output): int { $output->writeln('It works!'); + + return 0; }; $application = new Application(); @@ -291,7 +293,7 @@ public function testSilentHelp() $tester = new ApplicationTester($application); $tester->run(['-h' => true, '-q' => true], ['decorated' => false]); - $this->assertEmpty($tester->getDisplay(true)); + $this->assertSame('', $tester->getDisplay(true)); } public function testGetInvalidCommand() @@ -1275,7 +1277,9 @@ public function testAddingOptionWithDuplicateShortcut() ->register('foo') ->setAliases(['f']) ->setDefinition([new InputOption('survey', 'e', InputOption::VALUE_REQUIRED, 'My option with a shortcut.')]) - ->setCode(function (InputInterface $input, OutputInterface $output) {}) + ->setCode(function (InputInterface $input, OutputInterface $output): int { + return 0; + }) ; $input = new ArrayInput(['command' => 'foo']); @@ -1298,7 +1302,9 @@ public function testAddingAlreadySetDefinitionElementData($def) $application ->register('foo') ->setDefinition([$def]) - ->setCode(function (InputInterface $input, OutputInterface $output) {}) + ->setCode(function (InputInterface $input, OutputInterface $output): int { + return 0; + }) ; $input = new ArrayInput(['command' => 'foo']); @@ -1435,8 +1441,10 @@ public function testRunWithDispatcher() $application->setAutoExit(false); $application->setDispatcher($this->getDispatcher()); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output): int { $output->write('foo.'); + + return 0; }); $tester = new ApplicationTester($application); @@ -1491,8 +1499,10 @@ public function testRunDispatchesAllEventsWithExceptionInListener() $application->setDispatcher($dispatcher); $application->setAutoExit(false); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output): int { $output->write('foo.'); + + return 0; }); $tester = new ApplicationTester($application); @@ -1559,8 +1569,10 @@ public function testRunAllowsErrorListenersToSilenceTheException() $application->setDispatcher($dispatcher); $application->setAutoExit(false); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output): int { $output->write('foo.'); + + return 0; }); $tester = new ApplicationTester($application); @@ -1671,8 +1683,10 @@ public function testRunWithDispatcherSkippingCommand() $application->setDispatcher($this->getDispatcher(true)); $application->setAutoExit(false); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output): int { $output->write('foo.'); + + return 0; }); $tester = new ApplicationTester($application); @@ -1698,8 +1712,10 @@ public function testRunWithDispatcherAccessingInputOptions() $application->setDispatcher($dispatcher); $application->setAutoExit(false); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output): int { $output->write('foo.'); + + return 0; }); $tester = new ApplicationTester($application); @@ -1728,8 +1744,10 @@ public function testRunWithDispatcherAddingInputOptions() $application->setDispatcher($dispatcher); $application->setAutoExit(false); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output): int { $output->write('foo.'); + + return 0; }); $tester = new ApplicationTester($application); @@ -1858,12 +1876,12 @@ public function testFindAlternativesDoesNotLoadSameNamespaceCommandsOnExactMatch 'foo:bar' => function () use (&$loaded) { $loaded['foo:bar'] = true; - return (new Command('foo:bar'))->setCode(function () {}); + return (new Command('foo:bar'))->setCode(function (): int { return 0; }); }, 'foo' => function () use (&$loaded) { $loaded['foo'] = true; - return (new Command('foo'))->setCode(function () {}); + return (new Command('foo'))->setCode(function (): int { return 0; }); }, ])); @@ -1934,8 +1952,10 @@ public function testThrowingErrorListener() $application->setAutoExit(false); $application->setCatchExceptions(false); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output): int { $output->write('foo.'); + + return 0; }); $tester = new ApplicationTester($application); @@ -2235,6 +2255,41 @@ public function testSignalableRestoresStty() $this->assertSame($previousSttyMode, $sttyMode); } + /** + * @requires extension pcntl + */ + public function testSignalableInvokableCommand() + { + $command = new Command(); + $command->setName('signal-invokable'); + $command->setCode($invokable = new class implements SignalableCommandInterface { + use SignalableInvokableCommandTrait; + }); + + $application = $this->createSignalableApplication($command, null); + $application->setSignalsToDispatchEvent(\SIGUSR1); + + $this->assertSame(1, $application->run(new ArrayInput(['signal-invokable']))); + $this->assertTrue($invokable->signaled); + } + + /** + * @requires extension pcntl + */ + public function testSignalableInvokableCommandThatExtendsBaseCommand() + { + $command = new class extends Command implements SignalableCommandInterface { + use SignalableInvokableCommandTrait; + }; + $command->setName('signal-invokable'); + + $application = $this->createSignalableApplication($command, null); + $application->setSignalsToDispatchEvent(\SIGUSR1); + + $this->assertSame(1, $application->run(new ArrayInput(['signal-invokable']))); + $this->assertTrue($command->signaled); + } + /** * @requires extension pcntl */ @@ -2494,7 +2549,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } #[AsCommand(name: 'signal')] -class SignableCommand extends BaseSignableCommand implements SignalableCommandInterface +class SignableCommand extends BaseSignableCommand { public function getSubscribedSignals(): array { @@ -2511,7 +2566,7 @@ public function handleSignal(int $signal, int|false $previousExitCode = 0): int| } #[AsCommand(name: 'signal')] -class TerminatableCommand extends BaseSignableCommand implements SignalableCommandInterface +class TerminatableCommand extends BaseSignableCommand { public function getSubscribedSignals(): array { @@ -2528,7 +2583,7 @@ public function handleSignal(int $signal, int|false $previousExitCode = 0): int| } #[AsCommand(name: 'signal')] -class TerminatableWithEventCommand extends Command implements SignalableCommandInterface, EventSubscriberInterface +class TerminatableWithEventCommand extends Command implements EventSubscriberInterface { private bool $shouldContinue = true; private OutputInterface $output; @@ -2595,8 +2650,39 @@ public static function getSubscribedEvents(): array } } +trait SignalableInvokableCommandTrait +{ + public bool $signaled = false; + + public function __invoke(): int + { + posix_kill(posix_getpid(), \SIGUSR1); + + for ($i = 0; $i < 1000; ++$i) { + usleep(100); + if ($this->signaled) { + return 1; + } + } + + return 0; + } + + public function getSubscribedSignals(): array + { + return SignalRegistry::isSupported() ? [\SIGUSR1] : []; + } + + public function handleSignal(int $signal, int|false $previousExitCode = 0): int|false + { + $this->signaled = true; + + return false; + } +} + #[AsCommand(name: 'alarm')] -class AlarmableCommand extends BaseSignableCommand implements SignalableCommandInterface +class AlarmableCommand extends BaseSignableCommand { public function __construct(private int $alarmInterval) { diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index e417b0656e9d9..0db3572fc3476 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -12,12 +12,13 @@ namespace Symfony\Component\Console\Tests\Command; use PHPUnit\Framework\TestCase; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; +use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait; use Symfony\Component\Console\Application; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Exception\InvalidOptionException; use Symfony\Component\Console\Helper\FormatterHelper; +use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputInterface; @@ -29,7 +30,7 @@ class CommandTest extends TestCase { - use ExpectDeprecationTrait; + use ExpectUserDeprecationMessageTrait; protected static string $fixturesPath; @@ -350,8 +351,10 @@ public function testRunWithProcessTitle() public function testSetCode() { $command = new \TestCommand(); - $ret = $command->setCode(function (InputInterface $input, OutputInterface $output) { + $ret = $command->setCode(function (InputInterface $input, OutputInterface $output): int { $output->writeln('from the code...'); + + return 0; }); $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); $tester = new CommandTester($command); @@ -396,8 +399,10 @@ public function testSetCodeWithStaticClosure() private static function createClosure() { - return function (InputInterface $input, OutputInterface $output) { + return function (InputInterface $input, OutputInterface $output): int { $output->writeln(isset($this) ? 'bound' : 'not bound'); + + return 0; }; } @@ -411,16 +416,20 @@ public function testSetCodeWithNonClosureCallable() $this->assertEquals('interact called'.\PHP_EOL.'from the code...'.\PHP_EOL, $tester->getDisplay()); } - public function callableMethodCommand(InputInterface $input, OutputInterface $output) + public function callableMethodCommand(InputInterface $input, OutputInterface $output): int { $output->writeln('from the code...'); + + return 0; } public function testSetCodeWithStaticAnonymousFunction() { $command = new \TestCommand(); - $command->setCode(static function (InputInterface $input, OutputInterface $output) { + $command->setCode(static function (InputInterface $input, OutputInterface $output): int { $output->writeln(isset($this) ? 'bound' : 'not bound'); + + return 0; }); $tester = new CommandTester($command); $tester->execute([]); @@ -444,8 +453,8 @@ public function testCommandAttribute() */ public function testCommandAttributeWithDeprecatedMethods() { - $this->expectDeprecation('Since symfony/console 7.3: Method "Symfony\Component\Console\Command\Command::getDefaultName()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.'); - $this->expectDeprecation('Since symfony/console 7.3: Method "Symfony\Component\Console\Command\Command::getDefaultDescription()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.'); + $this->expectUserDeprecationMessage('Since symfony/console 7.3: Method "Symfony\Component\Console\Command\Command::getDefaultName()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.'); + $this->expectUserDeprecationMessage('Since symfony/console 7.3: Method "Symfony\Component\Console\Command\Command::getDefaultDescription()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.'); $this->assertSame('|foo|f', Php8Command::getDefaultName()); $this->assertSame('desc', Php8Command::getDefaultDescription()); @@ -464,8 +473,8 @@ public function testAttributeOverridesProperty() */ public function testAttributeOverridesPropertyWithDeprecatedMethods() { - $this->expectDeprecation('Since symfony/console 7.3: Method "Symfony\Component\Console\Command\Command::getDefaultName()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.'); - $this->expectDeprecation('Since symfony/console 7.3: Method "Symfony\Component\Console\Command\Command::getDefaultDescription()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.'); + $this->expectUserDeprecationMessage('Since symfony/console 7.3: Method "Symfony\Component\Console\Command\Command::getDefaultName()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.'); + $this->expectUserDeprecationMessage('Since symfony/console 7.3: Method "Symfony\Component\Console\Command\Command::getDefaultDescription()" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.'); $this->assertSame('my:command', MyAnnotatedCommand::getDefaultName()); $this->assertSame('This is a command I wrote all by myself', MyAnnotatedCommand::getDefaultDescription()); @@ -490,19 +499,33 @@ public function testDefaultCommand() */ public function testDeprecatedMethods() { - $this->expectDeprecation('Since symfony/console 7.3: Overriding "Command::getDefaultName()" in "Symfony\Component\Console\Tests\Command\FooCommand" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.'); - $this->expectDeprecation('Since symfony/console 7.3: Overriding "Command::getDefaultDescription()" in "Symfony\Component\Console\Tests\Command\FooCommand" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.'); + $this->expectUserDeprecationMessage('Since symfony/console 7.3: Overriding "Command::getDefaultName()" in "Symfony\Component\Console\Tests\Command\FooCommand" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.'); + $this->expectUserDeprecationMessage('Since symfony/console 7.3: Overriding "Command::getDefaultDescription()" in "Symfony\Component\Console\Tests\Command\FooCommand" is deprecated and will be removed in Symfony 8.0, use the #[AsCommand] attribute instead.'); new FooCommand(); } + + /** + * @group legacy + */ + public function testDeprecatedNonIntegerReturnTypeFromClosureCode() + { + $this->expectUserDeprecationMessage('Since symfony/console 7.3: Returning a non-integer value from the command "foo" is deprecated and will throw an exception in Symfony 8.0.'); + + $command = new Command('foo'); + $command->setCode(function () {}); + $command->run(new ArrayInput([]), new NullOutput()); + } } // In order to get an unbound closure, we should create it outside a class // scope. function createClosure() { - return function (InputInterface $input, OutputInterface $output) { + return function (InputInterface $input, OutputInterface $output): int { $output->writeln($this instanceof Command ? 'bound to the command' : 'not bound to the command'); + + return 0; }; } diff --git a/src/Symfony/Component/Console/Tests/Command/InvokableCommandTest.php b/src/Symfony/Component/Console/Tests/Command/InvokableCommandTest.php index 3633c865971d5..9fc40809a3d2f 100644 --- a/src/Symfony/Component/Console/Tests/Command/InvokableCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/InvokableCommandTest.php @@ -21,7 +21,9 @@ use Symfony\Component\Console\Exception\InvalidOptionException; use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\NullOutput; +use Symfony\Component\Console\Output\OutputInterface; class InvokableCommandTest extends TestCase { @@ -29,24 +31,26 @@ public function testCommandInputArgumentDefinition() { $command = new Command('foo'); $command->setCode(function ( - #[Argument(name: 'first-name')] string $name, + #[Argument(name: 'very-first-name')] string $name, #[Argument] ?string $firstName, #[Argument] string $lastName = '', #[Argument(description: 'Short argument description')] string $bio = '', #[Argument(suggestedValues: [self::class, 'getSuggestedRoles'])] array $roles = ['ROLE_USER'], - ) {}); + ): int { + return 0; + }); - $nameInputArgument = $command->getDefinition()->getArgument('first-name'); - self::assertSame('first-name', $nameInputArgument->getName()); + $nameInputArgument = $command->getDefinition()->getArgument('very-first-name'); + self::assertSame('very-first-name', $nameInputArgument->getName()); self::assertTrue($nameInputArgument->isRequired()); - $lastNameInputArgument = $command->getDefinition()->getArgument('firstName'); - self::assertSame('firstName', $lastNameInputArgument->getName()); + $lastNameInputArgument = $command->getDefinition()->getArgument('first-name'); + self::assertSame('first-name', $lastNameInputArgument->getName()); self::assertFalse($lastNameInputArgument->isRequired()); self::assertNull($lastNameInputArgument->getDefault()); - $lastNameInputArgument = $command->getDefinition()->getArgument('lastName'); - self::assertSame('lastName', $lastNameInputArgument->getName()); + $lastNameInputArgument = $command->getDefinition()->getArgument('last-name'); + self::assertSame('last-name', $lastNameInputArgument->getName()); self::assertFalse($lastNameInputArgument->isRequired()); self::assertSame('', $lastNameInputArgument->getDefault()); @@ -75,12 +79,16 @@ public function testCommandInputOptionDefinition() #[Option(shortcut: 'v')] bool $verbose = false, #[Option(description: 'User groups')] array $groups = [], #[Option(suggestedValues: [self::class, 'getSuggestedRoles'])] array $roles = ['ROLE_USER'], - ) {}); + #[Option] string|bool $opt = false, + ): int { + return 0; + }); $timeoutInputOption = $command->getDefinition()->getOption('idle'); self::assertSame('idle', $timeoutInputOption->getName()); self::assertNull($timeoutInputOption->getShortcut()); - self::assertTrue($timeoutInputOption->isValueOptional()); + self::assertTrue($timeoutInputOption->isValueRequired()); + self::assertFalse($timeoutInputOption->isValueOptional()); self::assertFalse($timeoutInputOption->isNegatable()); self::assertNull($timeoutInputOption->getDefault()); @@ -114,6 +122,14 @@ public function testCommandInputOptionDefinition() self::assertTrue($rolesInputOption->hasCompletion()); $rolesInputOption->complete(new CompletionInput(), $suggestions = new CompletionSuggestions()); self::assertSame(['ROLE_ADMIN', 'ROLE_USER'], array_map(static fn (Suggestion $s) => $s->getValue(), $suggestions->getValueSuggestions())); + + $optInputOption = $command->getDefinition()->getOption('opt'); + self::assertSame('opt', $optInputOption->getName()); + self::assertNull($optInputOption->getShortcut()); + self::assertFalse($optInputOption->isValueRequired()); + self::assertTrue($optInputOption->isValueOptional()); + self::assertFalse($optInputOption->isNegatable()); + self::assertFalse($optInputOption->getDefault()); } public function testInvalidArgumentType() @@ -122,7 +138,6 @@ public function testInvalidArgumentType() $command->setCode(function (#[Argument] object $any) {}); $this->expectException(LogicException::class); - $this->expectExceptionMessage('The type "object" of parameter "$any" is not supported as a command argument. Only "string", "bool", "int", "float", "array" types are allowed.'); $command->getDefinition(); } @@ -130,14 +145,69 @@ public function testInvalidArgumentType() public function testInvalidOptionType() { $command = new Command('foo'); - $command->setCode(function (#[Option] object $any) {}); + $command->setCode(function (#[Option] ?object $any = null) {}); $this->expectException(LogicException::class); - $this->expectExceptionMessage('The type "object" of parameter "$any" is not supported as a command option. Only "string", "bool", "int", "float", "array" types are allowed.'); $command->getDefinition(); } + public function testExecuteHasPriorityOverInvokeMethod() + { + $command = new class extends Command { + public string $called; + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $this->called = __FUNCTION__; + + return 0; + } + + public function __invoke(): int + { + $this->called = __FUNCTION__; + + return 0; + } + }; + + $command->run(new ArrayInput([]), new NullOutput()); + $this->assertSame('execute', $command->called); + } + + public function testCallInvokeMethodWhenExtendingCommandClass() + { + $command = new class extends Command { + public string $called; + + public function __invoke(): int + { + $this->called = __FUNCTION__; + + return 0; + } + }; + + $command->run(new ArrayInput([]), new NullOutput()); + $this->assertSame('__invoke', $command->called); + } + + public function testInvalidReturnType() + { + $command = new Command('foo'); + $command->setCode(new class { + public function __invoke() + { + } + }); + + $this->expectException(\TypeError::class); + $this->expectExceptionMessage('The command "foo" must return an integer value in the "__invoke" method, but "null" was returned.'); + + $command->run(new ArrayInput([]), new NullOutput()); + } + /** * @dataProvider provideInputArguments */ @@ -149,11 +219,13 @@ public function testInputArguments(array $parameters, array $expected) #[Argument] ?string $b, #[Argument] string $c = '', #[Argument] array $d = [], - ) use ($expected) { + ) use ($expected): int { $this->assertSame($expected[0], $a); $this->assertSame($expected[1], $b); $this->assertSame($expected[2], $c); $this->assertSame($expected[3], $d); + + return 0; }); $command->run(new ArrayInput($parameters), new NullOutput()); @@ -176,10 +248,12 @@ public function testBinaryInputOptions(array $parameters, array $expected) #[Option] bool $a = true, #[Option] bool $b = false, #[Option] ?bool $c = null, - ) use ($expected) { + ) use ($expected): int { $this->assertSame($expected[0], $a); $this->assertSame($expected[1], $b); $this->assertSame($expected[2], $c); + + return 0; }); $command->run(new ArrayInput($parameters), new NullOutput()); @@ -199,13 +273,33 @@ public function testNonBinaryInputOptions(array $parameters, array $expected) { $command = new Command('foo'); $command->setCode(function ( - #[Option] ?string $a = null, - #[Option] ?string $b = 'b', - #[Option] ?array $c = [], - ) use ($expected) { + #[Option] string $a = '', + #[Option] array $b = [], + #[Option] array $c = ['a', 'b'], + #[Option] bool|string $d = false, + #[Option] ?string $e = null, + #[Option] ?array $f = null, + #[Option] int $g = 0, + #[Option] ?int $h = null, + #[Option] float $i = 0.0, + #[Option] ?float $j = null, + #[Option] bool|int $k = false, + #[Option] bool|float $l = false, + ) use ($expected): int { $this->assertSame($expected[0], $a); $this->assertSame($expected[1], $b); $this->assertSame($expected[2], $c); + $this->assertSame($expected[3], $d); + $this->assertSame($expected[4], $e); + $this->assertSame($expected[5], $f); + $this->assertSame($expected[6], $g); + $this->assertSame($expected[7], $h); + $this->assertSame($expected[8], $i); + $this->assertSame($expected[9], $j); + $this->assertSame($expected[10], $k); + $this->assertSame($expected[11], $l); + + return 0; }); $command->run(new ArrayInput($parameters), new NullOutput()); @@ -213,22 +307,64 @@ public function testNonBinaryInputOptions(array $parameters, array $expected) public static function provideNonBinaryInputOptions(): \Generator { - yield 'defaults' => [[], [null, 'b', []]]; - yield 'with-value' => [['--a' => 'x', '--b' => 'y', '--c' => ['z']], ['x', 'y', ['z']]]; - yield 'without-value' => [['--a' => null, '--b' => null, '--c' => null], [null, null, null]]; + yield 'defaults' => [ + [], + ['', [], ['a', 'b'], false, null, null, 0, null, 0.0, null, false, false], + ]; + yield 'with-value' => [ + ['--a' => 'x', '--b' => ['z'], '--c' => ['c', 'd'], '--d' => 'v', '--e' => 'w', '--f' => ['q'], '--g' => 1, '--h' => 2, '--i' => 3.1, '--j' => 4.2, '--k' => 5, '--l' => 6.3], + ['x', ['z'], ['c', 'd'], 'v', 'w', ['q'], 1, 2, 3.1, 4.2, 5, 6.3], + ]; + yield 'without-value' => [ + ['--d' => null, '--k' => null, '--l' => null], + ['', [], ['a', 'b'], true, null, null, 0, null, 0.0, null, true, true], + ]; } - public function testInvalidOptionDefinition() + /** + * @dataProvider provideInvalidOptionDefinitions + */ + public function testInvalidOptionDefinition(callable $code) { $command = new Command('foo'); - $command->setCode(function (#[Option] string $a) {}); + $command->setCode($code); $this->expectException(LogicException::class); - $this->expectExceptionMessage('The option parameter "$a" must declare a default value.'); $command->getDefinition(); } + public static function provideInvalidOptionDefinitions(): \Generator + { + yield 'no-default' => [ + function (#[Option] string $a) {}, + ]; + yield 'nullable-bool-default-true' => [ + function (#[Option] ?bool $a = true) {}, + ]; + yield 'nullable-bool-default-false' => [ + function (#[Option] ?bool $a = false) {}, + ]; + yield 'invalid-union-type' => [ + function (#[Option] array|bool $a = false) {}, + ]; + yield 'union-type-cannot-allow-null' => [ + function (#[Option] string|bool|null $a = null) {}, + ]; + yield 'union-type-default-true' => [ + function (#[Option] string|bool $a = true) {}, + ]; + yield 'union-type-default-string' => [ + function (#[Option] string|bool $a = 'foo') {}, + ]; + yield 'nullable-string-not-null-default' => [ + function (#[Option] ?string $a = 'foo') {}, + ]; + yield 'nullable-array-not-null-default' => [ + function (#[Option] ?array $a = []) {}, + ]; + } + public function testInvalidRequiredValueOptionEvenWithDefault() { $command = new Command('foo'); diff --git a/src/Symfony/Component/Console/Tests/Command/LockableTraitTest.php b/src/Symfony/Component/Console/Tests/Command/LockableTraitTest.php index 0268d9681e5c5..3000906d7aab7 100644 --- a/src/Symfony/Component/Console/Tests/Command/LockableTraitTest.php +++ b/src/Symfony/Component/Console/Tests/Command/LockableTraitTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Console\Tests\Command; use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Lock\LockFactory; use Symfony\Component\Lock\SharedLockInterface; @@ -28,6 +29,7 @@ public static function setUpBeforeClass(): void require_once self::$fixturesPath.'/FooLockCommand.php'; require_once self::$fixturesPath.'/FooLock2Command.php'; require_once self::$fixturesPath.'/FooLock3Command.php'; + require_once self::$fixturesPath.'/FooLock4InvokableCommand.php'; } public function testLockIsReleased() @@ -80,4 +82,25 @@ public function testCustomLockFactoryIsUsed() $lockFactory->expects(static::once())->method('createLock')->willReturn($lock); $this->assertSame(1, $tester->execute([])); } + + public function testLockInvokableCommandReturnsFalseIfAlreadyLockedByAnotherCommand() + { + $command = new Command('foo:lock4'); + $command->setCode(new \FooLock4InvokableCommand()); + + if (SemaphoreStore::isSupported()) { + $store = new SemaphoreStore(); + } else { + $store = new FlockStore(); + } + + $lock = (new LockFactory($store))->createLock($command->getName()); + $lock->acquire(); + + $tester = new CommandTester($command); + $this->assertSame(Command::FAILURE, $tester->execute([])); + + $lock->release(); + $this->assertSame(Command::SUCCESS, $tester->execute([])); + } } diff --git a/src/Symfony/Component/Console/Tests/Command/TraceableCommandTest.php b/src/Symfony/Component/Console/Tests/Command/TraceableCommandTest.php new file mode 100644 index 0000000000000..1bf709f8bce0e --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Command/TraceableCommandTest.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Command; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\TraceableCommand; +use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\Console\Tests\Fixtures\LoopExampleCommand; +use Symfony\Component\Stopwatch\Stopwatch; + +class TraceableCommandTest extends TestCase +{ + private Application $application; + + protected function setUp(): void + { + $this->application = new Application(); + $this->application->add(new LoopExampleCommand()); + } + + public function testRunIsOverriddenWithoutProfile() + { + $command = $this->application->find('app:loop:example'); + $commandTester = new CommandTester($command); + $commandTester->execute([]); + $commandTester->assertCommandIsSuccessful(); + + $output = $commandTester->getDisplay(); + $this->assertLoopOutputCorrectness($output); + } + + public function testRunIsNotOverriddenWithProfile() + { + // Simulate the bug environment by wrapping + // our command in TraceableCommand, which is what Symfony does + // when you use the --profile option. + $command = new LoopExampleCommand(); + $traceableCommand = new TraceableCommand($command, new Stopwatch()); + + $this->application->add($traceableCommand); + + $commandTester = new CommandTester($traceableCommand); + $commandTester->execute([]); + $commandTester->assertCommandIsSuccessful(); + + $output = $commandTester->getDisplay(); + $this->assertLoopOutputCorrectness($output); + } + + public function assertLoopOutputCorrectness(string $output) + { + $completeChar = '\\' !== \DIRECTORY_SEPARATOR ? '▓' : '='; + self::assertMatchesRegularExpression('~3/3\s+\['.$completeChar.'+]\s+100%~u', $output); + self::assertStringContainsString('Loop finished.', $output); + self::assertEquals(3, substr_count($output, 'Hello world')); + } +} diff --git a/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php b/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php index 8a0c1e6b2bbf5..9ac660100ea0d 100644 --- a/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php +++ b/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php @@ -15,6 +15,7 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\LazyCommand; +use Symfony\Component\Console\Command\SignalableCommandInterface; use Symfony\Component\Console\CommandLoader\ContainerCommandLoader; use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass; use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; @@ -325,6 +326,27 @@ public function testProcessInvokableCommand() self::assertSame('The command description', $command->getDescription()); self::assertSame('The %command.name% command help content.', $command->getHelp()); } + + public function testProcessInvokableSignalableCommand() + { + $container = new ContainerBuilder(); + $container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING); + + $definition = new Definition(InvokableSignalableCommand::class); + $definition->addTag('console.command', [ + 'command' => 'invokable-signalable', + 'description' => 'The command description', + 'help' => 'The %command.name% command help content.', + ]); + $container->setDefinition('invokable_signalable_command', $definition); + + $container->compile(); + $command = $container->get('console.command_loader')->get('invokable-signalable'); + + self::assertTrue($container->has('invokable_signalable_command.command')); + self::assertSame('The command description', $command->getDescription()); + self::assertSame('The %command.name% command help content.', $command->getHelp()); + } } class MyCommand extends Command @@ -361,3 +383,21 @@ public function __invoke(): void { } } + +#[AsCommand(name: 'invokable-signalable', description: 'Just testing', help: 'The %command.name% help content.')] +class InvokableSignalableCommand implements SignalableCommandInterface +{ + public function __invoke(): void + { + } + + public function getSubscribedSignals(): array + { + return []; + } + + public function handleSignal(int $signal, false|int $previousExitCode = 0): int|false + { + return false; + } +} diff --git a/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php b/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php index 399bd8f2368db..914ed35970c7c 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php @@ -36,10 +36,9 @@ private function normalizeOutputRecursively($output) return array_map($this->normalizeOutputRecursively(...), $output); } - if (null === $output) { - return null; - } - - return parent::normalizeOutput($output); + return match ($output) { + null, true, false => $output, + default => parent::normalizeOutput($output), + }; } } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/AbstractLoopCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/AbstractLoopCommand.php new file mode 100644 index 0000000000000..c3715067ebcb3 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/AbstractLoopCommand.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Fixtures; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; + +abstract class AbstractLoopCommand extends Command +{ + public function run(InputInterface $input, OutputInterface $output): int + { + $io = new SymfonyStyle($input, $output); + $contexts = [1, 2, 3]; + $io->progressStart(count($contexts)); + $code = self::SUCCESS; + + foreach ($contexts as $ignored) { + $io->progressAdvance(); + try { + parent::run($input, $output); + } catch (\Throwable) { + $code = self::FAILURE; + } + } + $io->progressFinish(); + $output->writeln("\nLoop finished."); + + return $code; + } +} diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooLock4InvokableCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/FooLock4InvokableCommand.php new file mode 100644 index 0000000000000..7309234fa15ea --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooLock4InvokableCommand.php @@ -0,0 +1,22 @@ +lock()) { + return Command::FAILURE; + } + + $this->release(); + + return Command::SUCCESS; + } +} diff --git a/src/Symfony/Component/Console/Tests/Fixtures/LoopExampleCommand.php b/src/Symfony/Component/Console/Tests/Fixtures/LoopExampleCommand.php new file mode 100644 index 0000000000000..d9eeb4db97f67 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/LoopExampleCommand.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Fixtures; + +use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +#[AsCommand('app:loop:example')] +class LoopExampleCommand extends AbstractLoopCommand +{ + protected function execute(InputInterface $input, OutputInterface $output): int + { + $output->writeln(' Hello world'); + + return Command::SUCCESS; + } +} diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_0.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_0.php index 8fe7c07712888..86095576c52c5 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_0.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_0.php @@ -5,7 +5,9 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure has single blank line at start when using block element -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->caution('Lorem ipsum dolor sit amet'); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_1.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_1.php index e5c700d60eb56..c72a3b3908338 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_1.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_1.php @@ -5,9 +5,11 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure has single blank line between titles and blocks -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->title('Title'); $output->warning('Lorem ipsum dolor sit amet'); $output->title('Title'); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_10.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_10.php index 3111873ddde6c..c9bc1e30a0ec9 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_10.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_10.php @@ -5,7 +5,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure that all lines are aligned to the begin of the first line in a very long line block -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->block( 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum', @@ -14,4 +14,6 @@ 'X ', true ); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php index 3ed897def42ce..838b66707b9b5 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php @@ -5,8 +5,10 @@ use Symfony\Component\Console\Style\SymfonyStyle; // ensure long words are properly wrapped in blocks -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $word = 'Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon'; $sfStyle = new SymfonyStyle($input, $output); $sfStyle->block($word, 'CUSTOM', 'fg=white;bg=blue', ' § ', false); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php index 8c458ae764dc3..24d64df8d9f62 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_12.php @@ -5,9 +5,11 @@ use Symfony\Component\Console\Style\SymfonyStyle; // ensure that all lines are aligned to the begin of the first one and start with '//' in a very long line comment -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->comment( 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum' ); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_13.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_13.php index 9bcc68f69e2c5..4d079977046b0 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_13.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_13.php @@ -5,10 +5,12 @@ use Symfony\Component\Console\Style\SymfonyStyle; // ensure that nested tags have no effect on the color of the '//' prefix -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output->setDecorated(true); $output = new SymfonyStyle($input, $output); $output->comment( 'Árvíztűrőtükörfúrógép 🎼 Lorem ipsum dolor sit 💕 amet, consectetur adipisicing elit, sed do eiusmod tempor incididu labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum' ); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_14.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_14.php index a893a48bf248f..b079e4c5df11c 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_14.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_14.php @@ -5,7 +5,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; // ensure that block() behaves properly with a prefix and without type -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->block( 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum', @@ -14,4 +14,6 @@ '$ ', true ); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_15.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_15.php index 68402cd408a2d..664a1938b51ab 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_15.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_15.php @@ -5,10 +5,12 @@ use Symfony\Component\Console\Style\SymfonyStyle; // ensure that block() behaves properly with a type and without prefix -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->block( 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum', 'TEST' ); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_16.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_16.php index 66e8179638821..2b7bba0595ef6 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_16.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_16.php @@ -5,11 +5,13 @@ use Symfony\Component\Console\Style\SymfonyStyle; // ensure that block() output is properly formatted (even padding lines) -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output->setDecorated(true); $output = new SymfonyStyle($input, $output); $output->success( 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum', 'TEST' ); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php index 311e6b3928478..399a5a06f86e3 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_17.php @@ -5,9 +5,11 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure symfony style helper methods handle trailing backslashes properly when decorating user texts -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->title('Title ending with \\'); $output->section('Section ending with \\'); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_18.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_18.php index d4afa45cf37c4..383615a34e666 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_18.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_18.php @@ -5,7 +5,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->definitionList( @@ -15,4 +15,6 @@ new TableSeparator(), ['foo2' => 'bar2'] ); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_19.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_19.php index e25a7ef295f45..3e57f66ca2050 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_19.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_19.php @@ -5,7 +5,9 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure formatting tables when using multiple headers with TableCell -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->horizontalTable(['a', 'b', 'c', 'd'], [[1, 2, 3], [4, 5], [7, 8, 9]]); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_2.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_2.php index a16ad505d2bc4..5bba34f36b125 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_2.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_2.php @@ -5,7 +5,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure has single blank line between blocks -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->warning('Warning'); $output->caution('Caution'); @@ -14,4 +14,6 @@ $output->note('Note'); $output->info('Info'); $output->block('Custom block', 'CUSTOM', 'fg=white;bg=green', 'X ', true); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php index 6b47969eeeba6..3bdd5d5cf5b1e 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php @@ -5,9 +5,11 @@ use Symfony\Component\Console\Style\SymfonyStyle; // Ensure that closing tag is applied once -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output->setDecorated(true); $output = new SymfonyStyle($input, $output); $output->write('do you want something'); $output->writeln('?'); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_21.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_21.php index 8460e7ececf37..3faf7c7a0e6db 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_21.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_21.php @@ -5,9 +5,11 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure texts with emojis don't make longer lines than expected -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->success('Lorem ipsum dolor sit amet'); $output->success('Lorem ipsum dolor sit amet with one emoji 🎉'); $output->success('Lorem ipsum dolor sit amet with so many of them 👩‍🌾👩‍🌾👩‍🌾👩‍🌾👩‍🌾'); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_22.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_22.php index 1070394a89726..3ec61081b1126 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_22.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_22.php @@ -5,7 +5,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; // ensure that nested tags have no effect on the color of the '//' prefix -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output->setDecorated(true); $output = new SymfonyStyle($input, $output); $output->block( @@ -16,4 +16,6 @@ false, false ); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_23.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_23.php index e6228fe0ba423..618de55ce3778 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_23.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_23.php @@ -4,7 +4,9 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->text('Hello'); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_3.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_3.php index 99253a6c08a83..b6a3cd27c56de 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_3.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_3.php @@ -5,8 +5,10 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure has single blank line between two titles -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->title('First title'); $output->title('Second title'); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4.php index b2f3d99546afb..d196735c14f93 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4.php @@ -5,7 +5,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure has single blank line after any text and a title -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->write('Lorem ipsum dolor sit amet'); @@ -31,4 +31,6 @@ $output->writeln('Lorem ipsum dolor sit amet'); $output->newLine(2); //Should append an extra blank line $output->title('Fifth title'); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4_with_iterators.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4_with_iterators.php index 3b215c7f2c5a6..24de2cab3e25d 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4_with_iterators.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4_with_iterators.php @@ -5,7 +5,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure has single blank line after any text and a title -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->write('Lorem ipsum dolor sit amet'); @@ -31,4 +31,6 @@ $output->writeln('Lorem ipsum dolor sit amet'); $output->newLine(2); //Should append an extra blank line $output->title('Fifth title'); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_5.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_5.php index 6fba5737fce39..6fab6823374a8 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_5.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_5.php @@ -5,7 +5,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure has proper line ending before outputting a text block like with SymfonyStyle::listing() or SymfonyStyle::text() -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->writeln('Lorem ipsum dolor sit amet'); @@ -34,4 +34,6 @@ 'Lorem ipsum dolor sit amet', 'consectetur adipiscing elit', ]); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_6.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_6.php index 3278f6ea05b12..cef96d5d92a9b 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_6.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_6.php @@ -5,7 +5,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure has proper blank line after text block when using a block like with SymfonyStyle::success -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->listing([ @@ -13,4 +13,6 @@ 'consectetur adipiscing elit', ]); $output->success('Lorem ipsum dolor sit amet'); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_7.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_7.php index 037c6ab6b3fe5..f4f673c17793e 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_7.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_7.php @@ -5,11 +5,13 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure questions do not output anything when input is non-interactive -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->title('Title'); $output->askHidden('Hidden question'); $output->choice('Choice question with default', ['choice1', 'choice2'], 'choice1'); $output->confirm('Confirmation with yes default', true); $output->text('Duis aute irure dolor in reprehenderit in voluptate velit esse'); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_8.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_8.php index fe9d484d252b3..8566654510506 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_8.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_8.php @@ -6,7 +6,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure formatting tables when using multiple headers with TableCell -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $headers = [ [new TableCell('Main table title', ['colspan' => 3])], ['ISBN', 'Title', 'Author'], @@ -23,4 +23,6 @@ $output = new SymfonyStyle($input, $output); $output->table($headers, $rows); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_9.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_9.php index 73af4ae1e2614..77dd8d0878747 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_9.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_9.php @@ -5,7 +5,9 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure that all lines are aligned to the begin of the first line in a multi-line block -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $output->block(['Custom block', 'Second custom block line'], 'CUSTOM', 'fg=white;bg=green', 'X ', true); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/interactive_command_1.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/interactive_command_1.php index 3c9c744050185..7855f9dcd2a9d 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/interactive_command_1.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/interactive_command_1.php @@ -5,7 +5,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; //Ensure that questions have the expected outputs -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $output = new SymfonyStyle($input, $output); $stream = fopen('php://memory', 'r+', false); @@ -16,4 +16,6 @@ $output->ask('What\'s your name?'); $output->ask('How are you?'); $output->ask('Where do you come from?'); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/progress/command_progress_iterate.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/progress/command_progress_iterate.php index 6487bc3b1fbb2..3744c9b22bddd 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/progress/command_progress_iterate.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/progress/command_progress_iterate.php @@ -5,7 +5,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; // progressIterate -return function (InputInterface $input, OutputInterface $output) { +return function (InputInterface $input, OutputInterface $output): int { $style = new SymfonyStyle($input, $output); foreach ($style->progressIterate(\range(1, 10)) as $step) { @@ -13,4 +13,6 @@ } $style->writeln('end of progressbar'); + + return 0; }; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_2.json b/src/Symfony/Component/Console/Tests/Fixtures/application_2.json index 4a6f411f55c48..c0e66444e9b15 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_2.json +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_2.json @@ -94,7 +94,7 @@ "is_value_required": false, "is_multiple": false, "description": "Do not ask any interactive question", - "default": false + "default": null }, "shell": { "name": "--shell", @@ -224,7 +224,7 @@ "is_value_required": false, "is_multiple": false, "description": "Do not ask any interactive question", - "default": false + "default": null }, "debug": { "name": "--debug", @@ -345,7 +345,7 @@ "is_value_required": false, "is_multiple": false, "description": "Do not ask any interactive question", - "default": false + "default": null } } } @@ -457,7 +457,7 @@ "is_value_required": false, "is_multiple": false, "description": "Do not ask any interactive question", - "default": false + "default": null }, "short": { "name": "--short", @@ -554,7 +554,7 @@ "is_value_required": false, "is_multiple": false, "description": "Do not ask any interactive question", - "default": false + "default": null } } } @@ -659,7 +659,7 @@ "is_value_required": false, "is_multiple": false, "description": "Do not ask any interactive question", - "default": false + "default": null } } } @@ -745,7 +745,7 @@ "is_value_required": false, "is_multiple": false, "description": "Do not ask any interactive question", - "default": false + "default": null } } } @@ -833,7 +833,7 @@ "is_value_required": false, "is_multiple": false, "description": "Do not ask any interactive question", - "default": false + "default": null } } } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_signalable.php b/src/Symfony/Component/Console/Tests/Fixtures/application_signalable.php index 978406637aadf..cc1bae6acdf7f 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_signalable.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_signalable.php @@ -1,6 +1,5 @@ setCode(function(InputInterface $input, OutputInterface $output) { + ->setCode(function(InputInterface $input, OutputInterface $output): int { $this->getHelper('question') ->ask($input, $output, new ChoiceQuestion('😊', ['y'])); diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php index 477f1bdf6bd70..489108bd55ec4 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php @@ -177,7 +177,7 @@ public function testInlineStyleOptions(string $tag, ?string $expected = null, ?s $expected = $tag.$input.''; $this->assertSame($expected, $formatter->format($expected)); } else { - /* @var OutputFormatterStyle $result */ + /** @var OutputFormatterStyle $result */ $this->assertInstanceOf(OutputFormatterStyle::class, $result); $this->assertSame($expected, $formatter->format($tag.$input.'')); $this->assertSame($expected, $formatter->format($tag.$input.'')); @@ -365,6 +365,15 @@ public function testFormatAndWrap() $this->assertSame("Lore\nm \e[37;41mip\e[39;49m\n\e[37;41msum\e[39;49m \ndolo\nr \e[32msi\e[39m\n\e[32mt\e[39m am\net", $formatter->formatAndWrap('Lorem ipsum dolor sit amet', 4)); $this->assertSame("Lorem \e[37;41mip\e[39;49m\n\e[37;41msum\e[39;49m dolo\nr \e[32msit\e[39m am\net", $formatter->formatAndWrap('Lorem ipsum dolor sit amet', 8)); $this->assertSame("Lorem \e[37;41mipsum\e[39;49m dolor \e[32m\e[39m\n\e[32msit\e[39m, \e[37;41mamet\e[39;49m et \e[32mlauda\e[39m\n\e[32mntium\e[39m architecto", $formatter->formatAndWrap('Lorem ipsum dolor sit, amet et laudantium architecto', 18)); + $this->assertSame("\e[37;41mnon-empty-array\e[39;49m\e[37;41m\e[39;49m given.\n🪪 argument.type", $formatter->formatAndWrap("non-empty-array given.\n🪪 argument.type", 38)); + $this->assertSame("Usuário {{user_name}} não é válid\no.", $formatter->formatAndWrap('Usuário {{user_name}} não é válido.', 50)); + $this->assertSame("foo\e[37;41mb\e[39;49m\n\e[37;41mar\e[39;49mbaz", $formatter->formatAndWrap("foob\narbaz", 7)); + $this->assertSame("foo\e[37;41mbar\e[39;49mbaz\nnewline", $formatter->formatAndWrap("foobarbaz\nnewline", 11)); + $this->assertSame("foobarbaz\n\e[37;41mnewline\e[39;49m", $formatter->formatAndWrap("foobarbaz\nnewline", 11)); + $this->assertSame("foobar\e[37;41mbaz\e[39;49m\n\e[37;41mnewline\e[39;49m", $formatter->formatAndWrap("foobarbaz\nnewline", 11)); + $this->assertSame("foobar\e[37;41mbazne\e[39;49m\n\e[37;41mwline\e[39;49m", $formatter->formatAndWrap("foobarbazne\nwline", 11)); + $this->assertSame("foobar\e[37;41mbazne\e[39;49m\n\e[37;41mw\e[39;49m\n\e[37;41mline\e[39;49m", $formatter->formatAndWrap("foobarbaznew\nline", 11)); + $this->assertSame("\e[37;41m👩‍🌾\e[39;49m", $formatter->formatAndWrap('👩‍🌾', 1)); $formatter = new OutputFormatter(); @@ -376,6 +385,15 @@ public function testFormatAndWrap() $this->assertSame("Â rèälly\nlöng tîtlè\nthät cöüld\nnèêd\nmúltîplê\nlínès", $formatter->formatAndWrap('Â rèälly löng tîtlè thät cöüld nèêd múltîplê línès', 10)); $this->assertSame("Â rèälly\nlöng tîtlè\nthät cöüld\nnèêd\nmúltîplê\n línès", $formatter->formatAndWrap("Â rèälly löng tîtlè thät cöüld nèêd múltîplê\n línès", 10)); $this->assertSame('', $formatter->formatAndWrap(null, 5)); + $this->assertSame("non-empty-array given.\n🪪 argument.type", $formatter->formatAndWrap("non-empty-array given.\n🪪 argument.type", 38)); + $this->assertSame("Usuário {{user_name}} não é válid\no.", $formatter->formatAndWrap('Usuário {{user_name}} não é válido.', 50)); + $this->assertSame("foob\narbaz", $formatter->formatAndWrap("foob\narbaz", 7)); + $this->assertSame("foobarbaz\nnewline", $formatter->formatAndWrap("foobarbaz\nnewline", 11)); + $this->assertSame("foobarbaz\nnewline", $formatter->formatAndWrap("foobarbaz\nnewline", 11)); + $this->assertSame("foobarbaz\nnewline", $formatter->formatAndWrap("foobarbaz\nnewline", 11)); + $this->assertSame("foobarbazne\nwline", $formatter->formatAndWrap("foobarbazne\nwline", 11)); + $this->assertSame("foobarbazne\nw\nline", $formatter->formatAndWrap("foobarbaznew\nline", 11)); + $this->assertSame('👩‍🌾', $formatter->formatAndWrap('👩‍🌾', 1)); } } diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php index 4e41ba69f680b..c0278cc330462 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php @@ -416,6 +416,81 @@ public function testOverwriteWithSectionOutput() ); } + public function testOverwriteWithSectionOutputAndEol() + { + $sections = []; + $stream = $this->getOutputStream(true); + $output = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter()); + + $bar = new ProgressBar($output, 50, 0); + $bar->setFormat('[%bar%] %percent:3s%%'.\PHP_EOL.'%message%'.\PHP_EOL); + $bar->setMessage(''); + $bar->start(); + $bar->display(); + $bar->setMessage('Doing something...'); + $bar->advance(); + $bar->setMessage('Doing something foo...'); + $bar->advance(); + + rewind($output->getStream()); + $this->assertEquals(escapeshellcmd( + '[>---------------------------] 0%'.\PHP_EOL.\PHP_EOL. + "\x1b[2A\x1b[0J".'[>---------------------------] 2%'.\PHP_EOL.'Doing something...'.\PHP_EOL. + "\x1b[2A\x1b[0J".'[=>--------------------------] 4%'.\PHP_EOL.'Doing something foo...'.\PHP_EOL), + escapeshellcmd(stream_get_contents($output->getStream())) + ); + } + + public function testOverwriteWithSectionOutputAndEolWithEmptyMessage() + { + $sections = []; + $stream = $this->getOutputStream(true); + $output = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter()); + + $bar = new ProgressBar($output, 50, 0); + $bar->setFormat('[%bar%] %percent:3s%%'.\PHP_EOL.'%message%'); + $bar->setMessage('Start'); + $bar->start(); + $bar->display(); + $bar->setMessage(''); + $bar->advance(); + $bar->setMessage('Doing something...'); + $bar->advance(); + + rewind($output->getStream()); + $this->assertEquals(escapeshellcmd( + '[>---------------------------] 0%'.\PHP_EOL.'Start'.\PHP_EOL. + "\x1b[2A\x1b[0J".'[>---------------------------] 2%'.\PHP_EOL. + "\x1b[1A\x1b[0J".'[=>--------------------------] 4%'.\PHP_EOL.'Doing something...'.\PHP_EOL), + escapeshellcmd(stream_get_contents($output->getStream())) + ); + } + + public function testOverwriteWithSectionOutputAndEolWithEmptyMessageComment() + { + $sections = []; + $stream = $this->getOutputStream(true); + $output = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter()); + + $bar = new ProgressBar($output, 50, 0); + $bar->setFormat('[%bar%] %percent:3s%%'.\PHP_EOL.'%message%'); + $bar->setMessage('Start'); + $bar->start(); + $bar->display(); + $bar->setMessage(''); + $bar->advance(); + $bar->setMessage('Doing something...'); + $bar->advance(); + + rewind($output->getStream()); + $this->assertEquals(escapeshellcmd( + '[>---------------------------] 0%'.\PHP_EOL."\x1b[33mStart\x1b[39m".\PHP_EOL. + "\x1b[2A\x1b[0J".'[>---------------------------] 2%'.\PHP_EOL. + "\x1b[1A\x1b[0J".'[=>--------------------------] 4%'.\PHP_EOL."\x1b[33mDoing something...\x1b[39m".\PHP_EOL), + escapeshellcmd(stream_get_contents($output->getStream())) + ); + } + public function testOverwriteWithAnsiSectionOutput() { // output has 43 visible characters plus 2 invisible ANSI characters diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index dbbf66e02ce10..0e91dd85b199e 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -777,7 +777,7 @@ public function testQuestionValidatorRepeatsThePrompt() $application = new Application(); $application->setAutoExit(false); $application->register('question') - ->setCode(function (InputInterface $input, OutputInterface $output) use (&$tries) { + ->setCode(function (InputInterface $input, OutputInterface $output) use (&$tries): int { $question = new Question('This is a promptable question'); $question->setValidator(function ($value) use (&$tries) { ++$tries; diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index 646c6baca8de1..eb85364dae5fb 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -112,6 +112,20 @@ public static function renderProvider() | 80-902734-1-6 | And Then There Were None | Agatha Christie | +---------------+--------------------------+------------------+ +TABLE, + ], + [ + ['ISBN', 'Title', 'Author'], + $books, + 'markdown', + <<<'TABLE' +| ISBN | Title | Author | +|---------------|--------------------------|------------------| +| 99921-58-10-7 | Divine Comedy | Dante Alighieri | +| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | +| 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | +| 80-902734-1-6 | And Then There Were None | Agatha Christie | + TABLE, ], [ @@ -1294,9 +1308,9 @@ public static function renderSetTitle() 'footer', 'default', <<<'TABLE' -+---------------+---- Multiline ++---------------+--- Multiline header -here -+------------------+ +here +------------------+ | ISBN | Title | Author | +---------------+--------------------------+------------------+ | 99921-58-10-7 | Divine Comedy | Dante Alighieri | @@ -1576,17 +1590,17 @@ public function testWithColspanAndMaxWith() $expected = <<
    getOutputContent($output) ); } + + public function testGithubIssue60038WidthOfCellWithEmoji() + { + $table = (new Table($output = $this->getOutputStream())) + ->setHeaderTitle('Test Title') + ->setHeaders(['Title', 'Author']) + ->setRows([ + ['🎭 💫 ☯ Divine Comedy', 'Dante Alighieri'], + // the snowflake (e2 9d 84 ef b8 8f) has a variant selector + ['👑 ❄️ 🗡 Game of Thrones', 'George R.R. Martin'], + // the snowflake in text style (e2 9d 84 ef b8 8e) has a variant selector + ['❄︎❄︎❄︎ snowflake in text style ❄︎❄︎❄︎', ''], + ['And a very long line to show difference in previous lines', ''], + ]) + ; + $table->render(); + + $this->assertSame(<<
    getOutputContent($output) + ); + } } diff --git a/src/Symfony/Component/Console/Tests/Helper/TreeHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/TreeHelperTest.php new file mode 100644 index 0000000000000..5d1399b27aef7 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Helper/TreeHelperTest.php @@ -0,0 +1,364 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Helper; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Helper\TreeHelper; +use Symfony\Component\Console\Helper\TreeNode; +use Symfony\Component\Console\Helper\TreeStyle; +use Symfony\Component\Console\Output\BufferedOutput; + +class TreeHelperTest extends TestCase +{ + public function testRenderWithoutNode() + { + $output = new BufferedOutput(); + $tree = TreeHelper::createTree($output); + + $tree->render(); + $this->assertSame(\PHP_EOL, $output->fetch()); + } + + public function testRenderSingleNode() + { + $rootNode = new TreeNode('Root'); + $output = new BufferedOutput(); + $tree = TreeHelper::createTree($output, $rootNode); + + $tree->render(); + $this->assertSame("Root\n", self::normalizeLineBreaks($output->fetch())); + } + + public function testRenderTwoLevelTree() + { + $rootNode = new TreeNode('Root'); + $child1 = new TreeNode('Child 1'); + $child2 = new TreeNode('Child 2'); + + $rootNode->addChild($child1); + $rootNode->addChild($child2); + + $output = new BufferedOutput(); + $tree = TreeHelper::createTree($output, $rootNode); + + $tree->render(); + $this->assertSame(<<fetch()))); + } + + public function testRenderThreeLevelTree() + { + $rootNode = new TreeNode('Root'); + $child1 = new TreeNode('Child 1'); + $child2 = new TreeNode('Child 2'); + $subChild1 = new TreeNode('SubChild 1'); + + $child1->addChild($subChild1); + $rootNode->addChild($child1); + $rootNode->addChild($child2); + + $output = new BufferedOutput(); + $tree = TreeHelper::createTree($output, $rootNode); + + $tree->render(); + $this->assertSame(<<fetch()))); + } + + public function testRenderMultiLevelTree() + { + $rootNode = new TreeNode('Root'); + $child1 = new TreeNode('Child 1'); + $child2 = new TreeNode('Child 2'); + $subChild1 = new TreeNode('SubChild 1'); + $subChild2 = new TreeNode('SubChild 2'); + $subSubChild1 = new TreeNode('SubSubChild 1'); + + $subChild1->addChild($subSubChild1); + $child1->addChild($subChild1); + $child1->addChild($subChild2); + $rootNode->addChild($child1); + $rootNode->addChild($child2); + + $output = new BufferedOutput(); + $tree = TreeHelper::createTree($output, $rootNode); + + $tree->render(); + $this->assertSame(<<fetch()))); + } + + public function testRenderSingleNodeTree() + { + $rootNode = new TreeNode('Root'); + $output = new BufferedOutput(); + $tree = TreeHelper::createTree($output, $rootNode); + + $tree->render(); + $this->assertSame(<<fetch()))); + } + + public function testRenderEmptyTree() + { + $rootNode = new TreeNode('Root'); + $output = new BufferedOutput(); + $tree = TreeHelper::createTree($output, $rootNode); + + $tree->render(); + $this->assertSame(<<fetch()))); + } + + public function testRenderDeeplyNestedTree() + { + $rootNode = new TreeNode('Root'); + $current = $rootNode; + for ($i = 1; $i <= 10; ++$i) { + $child = new TreeNode("Level $i"); + $current->addChild($child); + $current = $child; + } + + $style = new TreeStyle(...[ + '└── ', + '└── ', + '', + ' ', + ' ', + '', + ]); + + $output = new BufferedOutput(); + $tree = TreeHelper::createTree($output, $rootNode, [], $style); + + $tree->render(); + $this->assertSame(<<fetch()))); + } + + public function testRenderNodeWithMultipleChildren() + { + $rootNode = new TreeNode('Root'); + $child1 = new TreeNode('Child 1'); + $child2 = new TreeNode('Child 2'); + $child3 = new TreeNode('Child 3'); + + $rootNode->addChild($child1); + $rootNode->addChild($child2); + $rootNode->addChild($child3); + + $output = new BufferedOutput(); + $tree = TreeHelper::createTree($output, $rootNode); + + $tree->render(); + $this->assertSame(<<fetch()))); + } + + public function testRenderNodeWithMultipleChildrenWithStringConversion() + { + $rootNode = new TreeNode('Root'); + + $rootNode->addChild('Child 1'); + $rootNode->addChild('Child 2'); + $rootNode->addChild('Child 3'); + + $output = new BufferedOutput(); + $tree = TreeHelper::createTree($output, $rootNode); + + $tree->render(); + $this->assertSame(<<fetch()))); + } + + public function testRenderTreeWithDuplicateNodeNames() + { + $rootNode = new TreeNode('Root'); + $child1 = new TreeNode('Child'); + $child2 = new TreeNode('Child'); + $subChild1 = new TreeNode('Child'); + + $child1->addChild($subChild1); + $rootNode->addChild($child1); + $rootNode->addChild($child2); + + $output = new BufferedOutput(); + $tree = TreeHelper::createTree($output, $rootNode); + + $tree->render(); + $this->assertSame(<<fetch()))); + } + + public function testRenderTreeWithComplexNodeNames() + { + $rootNode = new TreeNode('Root'); + $child1 = new TreeNode('Child 1 (special)'); + $child2 = new TreeNode('Child_2@#$'); + $subChild1 = new TreeNode('Node with spaces'); + + $child1->addChild($subChild1); + $rootNode->addChild($child1); + $rootNode->addChild($child2); + + $output = new BufferedOutput(); + $tree = TreeHelper::createTree($output, $rootNode); + + $tree->render(); + $this->assertSame(<<fetch()))); + } + + public function testRenderTreeWithCycle() + { + $rootNode = new TreeNode('Root'); + $child1 = new TreeNode('Child 1'); + $child2 = new TreeNode('Child 2'); + + $child1->addChild($child2); + // Create a cycle voluntarily + $child2->addChild($child1); + + $rootNode->addChild($child1); + + $output = new BufferedOutput(); + $tree = TreeHelper::createTree($output, $rootNode); + + $this->expectException(\LogicException::class); + $tree->render(); + } + + public function testRenderWideTree() + { + $rootNode = new TreeNode('Root'); + for ($i = 1; $i <= 100; ++$i) { + $rootNode->addChild(new TreeNode("Child $i")); + } + + $output = new BufferedOutput(); + + $tree = TreeHelper::createTree($output, $rootNode); + $tree->render(); + + $lines = explode("\n", self::normalizeLineBreaks(trim($output->fetch()))); + $this->assertCount(101, $lines); + $this->assertSame('Root', $lines[0]); + $this->assertSame('└── Child 100', end($lines)); + } + + public function testCreateWithRoot() + { + $output = new BufferedOutput(); + $array = ['child1', 'child2']; + + $tree = TreeHelper::createTree($output, 'root', $array); + + $tree->render(); + $this->assertSame(<<fetch()))); + } + + public function testCreateWithNestedArray() + { + $output = new BufferedOutput(); + $array = ['child1', 'child2' => ['child2.1', 'child2.2' => ['child2.2.1']], 'child3']; + + $tree = TreeHelper::createTree($output, 'root', $array); + + $tree->render(); + $this->assertSame(<<fetch()))); + } + + public function testCreateWithoutRoot() + { + $output = new BufferedOutput(); + $array = ['child1', 'child2']; + + $tree = TreeHelper::createTree($output, null, $array); + + $tree->render(); + $this->assertSame(<<fetch()))); + } + + public function testCreateWithEmptyArray() + { + $output = new BufferedOutput(); + $array = []; + + $tree = TreeHelper::createTree($output, null, $array); + + $tree->render(); + $this->assertSame('', self::normalizeLineBreaks(trim($output->fetch()))); + } + + private static function normalizeLineBreaks($text) + { + return str_replace(\PHP_EOL, "\n", $text); + } +} diff --git a/src/Symfony/Component/Console/Tests/Helper/TreeNodeTest.php b/src/Symfony/Component/Console/Tests/Helper/TreeNodeTest.php new file mode 100644 index 0000000000000..0e80da3bd069c --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Helper/TreeNodeTest.php @@ -0,0 +1,86 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Helper; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Helper\TreeNode; + +class TreeNodeTest extends TestCase +{ + public function testNodeInitialization() + { + $node = new TreeNode('Root'); + $this->assertSame('Root', $node->getValue()); + $this->assertSame(0, iterator_count($node->getChildren())); + } + + public function testAddingChildren() + { + $root = new TreeNode('Root'); + $child = new TreeNode('Child'); + + $root->addChild($child); + + $this->assertSame(1, iterator_count($root->getChildren())); + $this->assertSame($child, iterator_to_array($root->getChildren())[0]); + } + + public function testAddingChildrenAsString() + { + $root = new TreeNode('Root'); + + $root->addChild('Child 1'); + $root->addChild('Child 2'); + + $this->assertSame(2, iterator_count($root->getChildren())); + + $children = iterator_to_array($root->getChildren()); + + $this->assertSame(0, iterator_count($children[0]->getChildren())); + $this->assertSame(0, iterator_count($children[1]->getChildren())); + + $this->assertSame('Child 1', $children[0]->getValue()); + $this->assertSame('Child 2', $children[1]->getValue()); + } + + public function testAddingChildrenWithGenerators() + { + $root = new TreeNode('Root'); + + $root->addChild(function () { + yield new TreeNode('Generated Child 1'); + yield new TreeNode('Generated Child 2'); + }); + + $this->assertSame(2, iterator_count($root->getChildren())); + + $children = iterator_to_array($root->getChildren()); + + $this->assertSame('Generated Child 1', $children[0]->getValue()); + $this->assertSame('Generated Child 2', $children[1]->getValue()); + } + + public function testRecursiveStructure() + { + $root = new TreeNode('Root'); + $child1 = new TreeNode('Child 1'); + $child2 = new TreeNode('Child 2'); + $leaf1 = new TreeNode('Leaf 1'); + + $child1->addChild($leaf1); + $root->addChild($child1); + $root->addChild($child2); + + $this->assertSame(2, iterator_count($root->getChildren())); + $this->assertSame($leaf1, iterator_to_array($child1->getChildren())[0]); + } +} diff --git a/src/Symfony/Component/Console/Tests/Helper/TreeStyleTest.php b/src/Symfony/Component/Console/Tests/Helper/TreeStyleTest.php new file mode 100644 index 0000000000000..7f5bfedd38b5c --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Helper/TreeStyleTest.php @@ -0,0 +1,231 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Helper; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Helper\TreeHelper; +use Symfony\Component\Console\Helper\TreeNode; +use Symfony\Component\Console\Helper\TreeStyle; +use Symfony\Component\Console\Output\BufferedOutput; +use Symfony\Component\Console\Output\OutputInterface; + +class TreeStyleTest extends TestCase +{ + public function testDefaultStyle() + { + $output = new BufferedOutput(); + $tree = self::createTree($output); + + $tree->render(); + + $this->assertSame(<<fetch()))); + } + + public function testBoxStyle() + { + $output = new BufferedOutput(); + $this->createTree($output, TreeStyle::box())->render(); + + $this->assertSame(<<fetch()))); + } + + public function testBoxDoubleStyle() + { + $output = new BufferedOutput(); + $this->createTree($output, TreeStyle::boxDouble())->render(); + + $this->assertSame(<<fetch()))); + } + + public function testCompactStyle() + { + $output = new BufferedOutput(); + $this->createTree($output, TreeStyle::compact())->render(); + + $this->assertSame(<<<'TREE' +root +├ A +│ ├ A1 +│ └ A2 +│ └ A2.1 +│ ├ A2.1.1 +│ └ A2.1.2 +├ B +│ ├ B1 +│ │ ├ B11 +│ │ └ B12 +│ └ B2 +└ C +TREE, self::normalizeLineBreaks(trim($output->fetch()))); + } + + public function testLightStyle() + { + $output = new BufferedOutput(); + $this->createTree($output, TreeStyle::light())->render(); + + $this->assertSame(<<<'TREE' +root +|-- A +| |-- A1 +| `-- A2 +| `-- A2.1 +| |-- A2.1.1 +| `-- A2.1.2 +|-- B +| |-- B1 +| | |-- B11 +| | `-- B12 +| `-- B2 +`-- C +TREE, self::normalizeLineBreaks(trim($output->fetch()))); + } + + public function testMinimalStyle() + { + $output = new BufferedOutput(); + $this->createTree($output, TreeStyle::minimal())->render(); + + $this->assertSame(<<<'TREE' +root +. A +. . A1 +. . A2 +. . A2.1 +. . A2.1.1 +. . A2.1.2 +. B +. . B1 +. . . B11 +. . . B12 +. . B2 +. C +TREE, self::normalizeLineBreaks(trim($output->fetch()))); + } + + public function testRoundedStyle() + { + $output = new BufferedOutput(); + $this->createTree($output, TreeStyle::rounded())->render(); + + $this->assertSame(<<<'TREE' +root +├─ A +│ ├─ A1 +│ ╰─ A2 +│ ╰─ A2.1 +│ ├─ A2.1.1 +│ ╰─ A2.1.2 +├─ B +│ ├─ B1 +│ │ ├─ B11 +│ │ ╰─ B12 +│ ╰─ B2 +╰─ C +TREE, self::normalizeLineBreaks(trim($output->fetch()))); + } + + public function testCustomPrefix() + { + $style = new TreeStyle('A ', 'B ', 'C ', 'D ', 'E ', 'F '); + $output = new BufferedOutput(); + self::createTree($output, $style)->render(); + + $this->assertSame(<<<'TREE' +root +C A F A +C D A F A1 +C D B F A2 +C D E B F A2.1 +C D E E A F A2.1.1 +C D E E B F A2.1.2 +C A F B +C D A F B1 +C D D A F B11 +C D D B F B12 +C D B F B2 +C B F C +TREE, self::normalizeLineBreaks(trim($output->fetch()))); + } + + private static function createTree(OutputInterface $output, ?TreeStyle $style = null): TreeHelper + { + $root = new TreeNode('root'); + $root + ->addChild((new TreeNode('A')) + ->addChild(new TreeNode('A1')) + ->addChild((new TreeNode('A2')) + ->addChild((new TreeNode('A2.1')) + ->addChild(new TreeNode('A2.1.1')) + ->addChild(new TreeNode('A2.1.2')) + ) + ) + ) + ->addChild((new TreeNode('B')) + ->addChild((new TreeNode('B1')) + ->addChild(new TreeNode('B11')) + ->addChild(new TreeNode('B12')) + ) + ->addChild(new TreeNode('B2')) + ) + ->addChild(new TreeNode('C')); + + return TreeHelper::createTree($output, $root, [], $style); + } + + private static function normalizeLineBreaks($text) + { + return str_replace(\PHP_EOL, "\n", $text); + } +} diff --git a/src/Symfony/Component/Console/Tests/Messenger/RunCommandMessageHandlerTest.php b/src/Symfony/Component/Console/Tests/Messenger/RunCommandMessageHandlerTest.php index 58b33d5659b96..8984923741640 100644 --- a/src/Symfony/Component/Console/Tests/Messenger/RunCommandMessageHandlerTest.php +++ b/src/Symfony/Component/Console/Tests/Messenger/RunCommandMessageHandlerTest.php @@ -20,6 +20,10 @@ use Symfony\Component\Console\Messenger\RunCommandMessage; use Symfony\Component\Console\Messenger\RunCommandMessageHandler; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Messenger\Exception\RecoverableExceptionInterface; +use Symfony\Component\Messenger\Exception\RecoverableMessageHandlingException; +use Symfony\Component\Messenger\Exception\UnrecoverableExceptionInterface; +use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException; /** * @author Kevin Bond @@ -81,6 +85,38 @@ public function testThrowOnNonSuccess() $this->fail('Exception not thrown.'); } + public function testExecutesCommandThatThrownUnrecoverableException() + { + $handler = new RunCommandMessageHandler($this->createApplicationWithCommand()); + + try { + $handler(new RunCommandMessage('test:command --throw-unrecoverable')); + } catch (UnrecoverableExceptionInterface $e) { + $this->assertSame('Unrecoverable exception message', $e->getMessage()); + $this->assertNull($e->getPrevious()); + + return; + } + + $this->fail('Exception not thrown.'); + } + + public function testExecutesCommandThatThrownRecoverableException() + { + $handler = new RunCommandMessageHandler($this->createApplicationWithCommand()); + + try { + $handler(new RunCommandMessage('test:command --throw-recoverable')); + } catch (RecoverableExceptionInterface $e) { + $this->assertSame('Recoverable exception message', $e->getMessage()); + $this->assertNull($e->getPrevious()); + + return; + } + + $this->fail('Exception not thrown.'); + } + private function createApplicationWithCommand(): Application { $application = new Application(); @@ -92,6 +128,8 @@ public function configure(): void $this ->setName('test:command') ->addOption('throw') + ->addOption('throw-unrecoverable') + ->addOption('throw-recoverable') ->addOption('exit', null, InputOption::VALUE_REQUIRED, 0) ; } @@ -100,6 +138,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $output->write('some message'); + if ($input->getOption('throw-unrecoverable')) { + throw new UnrecoverableMessageHandlingException('Unrecoverable exception message'); + } + + if ($input->getOption('throw-recoverable')) { + throw new RecoverableMessageHandlingException('Recoverable exception message'); + } + if ($input->getOption('throw')) { throw new \RuntimeException('exception message'); } diff --git a/src/Symfony/Component/Console/Tests/SignalRegistry/SignalMapTest.php b/src/Symfony/Component/Console/Tests/SignalRegistry/SignalMapTest.php index 887c5d7af01c5..3a0c49bb01e21 100644 --- a/src/Symfony/Component/Console/Tests/SignalRegistry/SignalMapTest.php +++ b/src/Symfony/Component/Console/Tests/SignalRegistry/SignalMapTest.php @@ -18,14 +18,13 @@ class SignalMapTest extends TestCase { /** * @requires extension pcntl - * - * @testWith [2, "SIGINT"] - * [9, "SIGKILL"] - * [15, "SIGTERM"] */ - public function testSignalExists(int $signal, string $expected) + public function testSignalExists() { - $this->assertSame($expected, SignalMap::getSignalName($signal)); + $this->assertSame('SIGINT', SignalMap::getSignalName(\SIGINT)); + $this->assertSame('SIGKILL', SignalMap::getSignalName(\SIGKILL)); + $this->assertSame('SIGTERM', SignalMap::getSignalName(\SIGTERM)); + $this->assertSame('SIGSYS', SignalMap::getSignalName(\SIGSYS)); } public function testSignalDoesNotExist() diff --git a/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php b/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php index 0b40c7c3f972e..a3b7ae406c236 100644 --- a/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php +++ b/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php @@ -15,9 +15,11 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Exception\RuntimeException; use Symfony\Component\Console\Formatter\OutputFormatter; +use Symfony\Component\Console\Helper\TreeHelper; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\Input; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\ConsoleSectionOutput; use Symfony\Component\Console\Output\NullOutput; @@ -154,6 +156,99 @@ public function testCreateTableWithoutConsoleOutput() $style->createTable()->appendRow(['row']); } + public function testCreateTree() + { + $output = $this->createMock(OutputInterface::class); + $output + ->method('getFormatter') + ->willReturn(new OutputFormatter()); + + $style = new SymfonyStyle($this->createMock(InputInterface::class), $output); + + $tree = $style->createTree([]); + $this->assertInstanceOf(TreeHelper::class, $tree); + } + + public function testTree() + { + $input = $this->createMock(InputInterface::class); + $output = new BufferedOutput(); + $style = new SymfonyStyle($input, $output); + + $tree = $style->createTree(['A', 'B' => ['B1' => ['B11', 'B12'], 'B2'], 'C'], 'root'); + $tree->render(); + + $this->assertSame(<<fetch()))); + } + + public function testCreateTreeWithArray() + { + $input = $this->createMock(InputInterface::class); + $output = new BufferedOutput(); + $style = new SymfonyStyle($input, $output); + + $tree = $style->createTree(['A', 'B' => ['B1' => ['B11', 'B12'], 'B2'], 'C'], 'root'); + $tree->render(); + + $this->assertSame($tree = <<fetch()))); + } + + public function testCreateTreeWithIterable() + { + $input = $this->createMock(InputInterface::class); + $output = new BufferedOutput(); + $style = new SymfonyStyle($input, $output); + + $tree = $style->createTree(new \ArrayIterator(['A', 'B' => ['B1' => ['B11', 'B12'], 'B2'], 'C']), 'root'); + $tree->render(); + + $this->assertSame(<<fetch()))); + } + + public function testCreateTreeWithConsoleOutput() + { + $input = $this->createMock(InputInterface::class); + $output = $this->createMock(ConsoleOutputInterface::class); + $output + ->method('getFormatter') + ->willReturn(new OutputFormatter()); + $output + ->expects($this->once()) + ->method('section') + ->willReturn($this->createMock(ConsoleSectionOutput::class)); + + $style = new SymfonyStyle($input, $output); + + $style->createTree([]); + } + public function testGetErrorStyleUsesTheCurrentOutputIfNoErrorOutputIsAvailable() { $output = $this->createMock(OutputInterface::class); @@ -219,4 +314,9 @@ public function testAskAndClearExpectFullSectionCleared() escapeshellcmd(stream_get_contents($output->getStream())) ); } + + private static function normalizeLineBreaks($text) + { + return str_replace(\PHP_EOL, "\n", $text); + } } diff --git a/src/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php b/src/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php index f990e94ccac00..843f2eac7fd12 100644 --- a/src/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php +++ b/src/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php @@ -31,8 +31,10 @@ protected function setUp(): void $this->application->setAutoExit(false); $this->application->register('foo') ->addArgument('foo') - ->setCode(function (OutputInterface $output) { + ->setCode(function (OutputInterface $output): int { $output->writeln('foo'); + + return 0; }) ; @@ -67,11 +69,13 @@ public function testSetInputs() { $application = new Application(); $application->setAutoExit(false); - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output): int { $helper = new QuestionHelper(); $helper->ask($input, $output, new Question('Q1')); $helper->ask($input, $output, new Question('Q2')); $helper->ask($input, $output, new Question('Q3')); + + return 0; }); $tester = new ApplicationTester($application); @@ -93,8 +97,10 @@ public function testErrorOutput() $application->setAutoExit(false); $application->register('foo') ->addArgument('foo') - ->setCode(function (OutputInterface $output) { + ->setCode(function (OutputInterface $output): int { $output->getErrorOutput()->write('foo'); + + return 0; }) ; diff --git a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php index 2e5329f8490f6..cfdebe4d88da8 100644 --- a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php +++ b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php @@ -34,7 +34,11 @@ protected function setUp(): void $this->command = new Command('foo'); $this->command->addArgument('command'); $this->command->addArgument('foo'); - $this->command->setCode(function (OutputInterface $output) { $output->writeln('foo'); }); + $this->command->setCode(function (OutputInterface $output): int { + $output->writeln('foo'); + + return 0; + }); $this->tester = new CommandTester($this->command); $this->tester->execute(['foo' => 'bar'], ['interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE]); @@ -94,7 +98,11 @@ public function testCommandFromApplication() $application->setAutoExit(false); $command = new Command('foo'); - $command->setCode(function (OutputInterface $output) { $output->writeln('foo'); }); + $command->setCode(function (OutputInterface $output): int { + $output->writeln('foo'); + + return 0; + }); $application->add($command); @@ -114,11 +122,13 @@ public function testCommandWithInputs() $command = new Command('foo'); $command->setHelperSet(new HelperSet([new QuestionHelper()])); - $command->setCode(function (InputInterface $input, OutputInterface $output) use ($questions, $command) { + $command->setCode(function (InputInterface $input, OutputInterface $output) use ($questions, $command): int { $helper = $command->getHelper('question'); $helper->ask($input, $output, new Question($questions[0])); $helper->ask($input, $output, new Question($questions[1])); $helper->ask($input, $output, new Question($questions[2])); + + return 0; }); $tester = new CommandTester($command); @@ -139,11 +149,13 @@ public function testCommandWithDefaultInputs() $command = new Command('foo'); $command->setHelperSet(new HelperSet([new QuestionHelper()])); - $command->setCode(function (InputInterface $input, OutputInterface $output) use ($questions, $command) { + $command->setCode(function (InputInterface $input, OutputInterface $output) use ($questions, $command): int { $helper = $command->getHelper('question'); $helper->ask($input, $output, new Question($questions[0], 'Bobby')); $helper->ask($input, $output, new Question($questions[1], 'Fine')); $helper->ask($input, $output, new Question($questions[2], 'France')); + + return 0; }); $tester = new CommandTester($command); @@ -164,12 +176,14 @@ public function testCommandWithWrongInputsNumber() $command = new Command('foo'); $command->setHelperSet(new HelperSet([new QuestionHelper()])); - $command->setCode(function (InputInterface $input, OutputInterface $output) use ($questions, $command) { + $command->setCode(function (InputInterface $input, OutputInterface $output) use ($questions, $command): int { $helper = $command->getHelper('question'); $helper->ask($input, $output, new ChoiceQuestion('choice', ['a', 'b'])); $helper->ask($input, $output, new Question($questions[0])); $helper->ask($input, $output, new Question($questions[1])); $helper->ask($input, $output, new Question($questions[2])); + + return 0; }); $tester = new CommandTester($command); @@ -191,12 +205,14 @@ public function testCommandWithQuestionsButNoInputs() $command = new Command('foo'); $command->setHelperSet(new HelperSet([new QuestionHelper()])); - $command->setCode(function (InputInterface $input, OutputInterface $output) use ($questions, $command) { + $command->setCode(function (InputInterface $input, OutputInterface $output) use ($questions, $command): int { $helper = $command->getHelper('question'); $helper->ask($input, $output, new ChoiceQuestion('choice', ['a', 'b'])); $helper->ask($input, $output, new Question($questions[0])); $helper->ask($input, $output, new Question($questions[1])); $helper->ask($input, $output, new Question($questions[2])); + + return 0; }); $tester = new CommandTester($command); @@ -216,11 +232,13 @@ public function testSymfonyStyleCommandWithInputs() ]; $command = new Command('foo'); - $command->setCode(function (InputInterface $input, OutputInterface $output) use ($questions) { + $command->setCode(function (InputInterface $input, OutputInterface $output) use ($questions): int { $io = new SymfonyStyle($input, $output); $io->ask($questions[0]); $io->ask($questions[1]); $io->ask($questions[2]); + + return 0; }); $tester = new CommandTester($command); @@ -235,8 +253,10 @@ public function testErrorOutput() $command = new Command('foo'); $command->addArgument('command'); $command->addArgument('foo'); - $command->setCode(function (OutputInterface $output) { + $command->setCode(function (OutputInterface $output): int { $output->getErrorOutput()->write('foo'); + + return 0; }); $tester = new CommandTester($command); diff --git a/src/Symfony/Component/Console/Tests/phpt/alarm/command_exit.phpt b/src/Symfony/Component/Console/Tests/phpt/alarm/command_exit.phpt index d3015ad9dbcf6..c2cf3edc7d1c0 100644 --- a/src/Symfony/Component/Console/Tests/phpt/alarm/command_exit.phpt +++ b/src/Symfony/Component/Console/Tests/phpt/alarm/command_exit.phpt @@ -7,7 +7,6 @@ Test command that exits use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Command\SignalableCommandInterface; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -19,7 +18,7 @@ while (!file_exists($vendor.'/vendor')) { } require $vendor.'/vendor/autoload.php'; -class MyCommand extends Command implements SignalableCommandInterface +class MyCommand extends Command { protected function initialize(InputInterface $input, OutputInterface $output): void { diff --git a/src/Symfony/Component/Console/Tests/phpt/signal/command_exit.phpt b/src/Symfony/Component/Console/Tests/phpt/signal/command_exit.phpt index 379476189d4b4..e14f80c47afee 100644 --- a/src/Symfony/Component/Console/Tests/phpt/signal/command_exit.phpt +++ b/src/Symfony/Component/Console/Tests/phpt/signal/command_exit.phpt @@ -7,7 +7,6 @@ Test command that exits use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Command\SignalableCommandInterface; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -19,7 +18,7 @@ while (!file_exists($vendor.'/vendor')) { } require $vendor.'/vendor/autoload.php'; -class MyCommand extends Command implements SignalableCommandInterface +class MyCommand extends Command { protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/Symfony/Component/Console/Tests/phpt/uses_stdin_as_interactive_input.phpt b/src/Symfony/Component/Console/Tests/phpt/uses_stdin_as_interactive_input.phpt index 3f329cc73f805..fedb64b61a5a0 100644 --- a/src/Symfony/Component/Console/Tests/phpt/uses_stdin_as_interactive_input.phpt +++ b/src/Symfony/Component/Console/Tests/phpt/uses_stdin_as_interactive_input.phpt @@ -17,9 +17,11 @@ require $vendor.'/vendor/autoload.php'; (new Application()) ->register('app') - ->setCode(function(InputInterface $input, OutputInterface $output) { + ->setCode(function(InputInterface $input, OutputInterface $output): int { $output->writeln((new QuestionHelper())->ask($input, $output, new Question('Foo?', 'foo'))); $output->writeln((new QuestionHelper())->ask($input, $output, new Question('Bar?', 'bar'))); + + return 0; }) ->getApplication() ->setDefaultCommand('app', true) diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index 083036d5cf654..65d69913aa218 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -20,7 +20,7 @@ "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-mbstring": "~1.0", "symfony/service-contracts": "^2.5|^3", - "symfony/string": "^6.4|^7.0" + "symfony/string": "^7.2" }, "require-dev": { "symfony/config": "^6.4|^7.0", diff --git a/src/Symfony/Component/DependencyInjection/Argument/LazyClosure.php b/src/Symfony/Component/DependencyInjection/Argument/LazyClosure.php index 7a677ebbd4e20..3dcc34e4fb61b 100644 --- a/src/Symfony/Component/DependencyInjection/Argument/LazyClosure.php +++ b/src/Symfony/Component/DependencyInjection/Argument/LazyClosure.php @@ -12,7 +12,6 @@ namespace Symfony\Component\DependencyInjection\Argument; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Reference; @@ -40,22 +39,22 @@ public function __get(mixed $name): mixed } if (isset($this->initializer)) { - $this->service = ($this->initializer)(); + if (\is_string($service = ($this->initializer)())) { + $service = (new \ReflectionClass($service))->newInstanceWithoutConstructor(); + } + $this->service = $service; unset($this->initializer); } return $this->service; } - public static function getCode(string $initializer, array $callable, Definition $definition, ContainerBuilder $container, ?string $id): string + public static function getCode(string $initializer, array $callable, string $class, ContainerBuilder $container, ?string $id): string { $method = $callable[1]; - $asClosure = 'Closure' === ($definition->getClass() ?: 'Closure'); - if ($asClosure) { + if ($asClosure = 'Closure' === $class) { $class = ($callable[0] instanceof Reference ? $container->findDefinition($callable[0]) : $callable[0])->getClass(); - } else { - $class = $definition->getClass(); } $r = $container->getReflectionClass($class); diff --git a/src/Symfony/Component/DependencyInjection/Attribute/AsAlias.php b/src/Symfony/Component/DependencyInjection/Attribute/AsAlias.php index 2f03e5fcdf4e2..0839afa48ff44 100644 --- a/src/Symfony/Component/DependencyInjection/Attribute/AsAlias.php +++ b/src/Symfony/Component/DependencyInjection/Attribute/AsAlias.php @@ -20,12 +20,20 @@ final class AsAlias { /** - * @param string|null $id The id of the alias - * @param bool $public Whether to declare the alias public + * @var list + */ + public array $when = []; + + /** + * @param string|null $id The id of the alias + * @param bool $public Whether to declare the alias public + * @param string|list $when The environments under which the class will be registered as a service (i.e. "dev", "test", "prod") */ public function __construct( public ?string $id = null, public bool $public = false, + string|array $when = [], ) { + $this->when = (array) $when; } } diff --git a/src/Symfony/Component/DependencyInjection/Attribute/AsTaggedItem.php b/src/Symfony/Component/DependencyInjection/Attribute/AsTaggedItem.php index cc3306c739638..de751213acad5 100644 --- a/src/Symfony/Component/DependencyInjection/Attribute/AsTaggedItem.php +++ b/src/Symfony/Component/DependencyInjection/Attribute/AsTaggedItem.php @@ -20,8 +20,8 @@ class AsTaggedItem { /** - * @param string|null $index The property or method to use to index the item in the locator - * @param int|null $priority The priority of the item; the higher the number, the earlier the tagged service will be located in the locator + * @param string|null $index The property or method to use to index the item in the iterator/locator + * @param int|null $priority The priority of the item; the higher the number, the earlier the tagged service will be located in the iterator/locator */ public function __construct( public ?string $index = null, diff --git a/src/Symfony/Component/DependencyInjection/Attribute/Autoconfigure.php b/src/Symfony/Component/DependencyInjection/Attribute/Autoconfigure.php index dc2c84ca29a5e..06513fd903e01 100644 --- a/src/Symfony/Component/DependencyInjection/Attribute/Autoconfigure.php +++ b/src/Symfony/Component/DependencyInjection/Attribute/Autoconfigure.php @@ -28,7 +28,7 @@ class Autoconfigure * @param bool|null $shared Whether to declare the service as shared * @param bool|null $autowire Whether to declare the service as autowired * @param array|null $properties The properties to define when creating the service - * @param array|string|null $configurator A PHP function, reference or an array containing a class/Reference and a method to call after the service is fully initialized + * @param array{string, string}|string|null $configurator A PHP function, reference or an array containing a class/reference and a method to call after the service is fully initialized * @param string|null $constructor The public static method to use to instantiate the service */ public function __construct( diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md index d24bb13c9bea3..df3486a9dc867 100644 --- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md +++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md @@ -7,6 +7,11 @@ CHANGELOG * Make `#[AsTaggedItem]` repeatable * Support `@>` as a shorthand for `!service_closure` in yaml files * Don't skip classes with private constructor when autodiscovering + * Add `Definition::addResourceTag()` and `ContainerBuilder::findTaggedResourceIds()` + for auto-configuration of classes excluded from the service container + * Accept multiple auto-configuration callbacks for the same attribute class + * Leverage native lazy objects when possible for lazy services + * Add `when` argument to `#[AsAlias]` 7.2 --- diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AttributeAutoconfigurationPass.php b/src/Symfony/Component/DependencyInjection/Compiler/AttributeAutoconfigurationPass.php index 9c3b98eaba3c5..bbf341913e4d8 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AttributeAutoconfigurationPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AttributeAutoconfigurationPass.php @@ -31,49 +31,51 @@ final class AttributeAutoconfigurationPass extends AbstractRecursivePass public function process(ContainerBuilder $container): void { - if (!$container->getAutoconfiguredAttributes()) { + if (!$container->getAttributeAutoconfigurators()) { return; } - foreach ($container->getAutoconfiguredAttributes() as $attributeName => $callable) { - $callableReflector = new \ReflectionFunction($callable(...)); - if ($callableReflector->getNumberOfParameters() <= 2) { - $this->classAttributeConfigurators[$attributeName] = $callable; - continue; - } + foreach ($container->getAttributeAutoconfigurators() as $attributeName => $callables) { + foreach ($callables as $callable) { + $callableReflector = new \ReflectionFunction($callable(...)); + if ($callableReflector->getNumberOfParameters() <= 2) { + $this->classAttributeConfigurators[$attributeName][] = $callable; + continue; + } - $reflectorParameter = $callableReflector->getParameters()[2]; - $parameterType = $reflectorParameter->getType(); - $types = []; - if ($parameterType instanceof \ReflectionUnionType) { - foreach ($parameterType->getTypes() as $type) { - $types[] = $type->getName(); + $reflectorParameter = $callableReflector->getParameters()[2]; + $parameterType = $reflectorParameter->getType(); + $types = []; + if ($parameterType instanceof \ReflectionUnionType) { + foreach ($parameterType->getTypes() as $type) { + $types[] = $type->getName(); + } + } elseif ($parameterType instanceof \ReflectionNamedType) { + $types[] = $parameterType->getName(); + } else { + throw new LogicException(\sprintf('Argument "$%s" of attribute autoconfigurator should have a type, use one or more of "\ReflectionClass|\ReflectionMethod|\ReflectionProperty|\ReflectionParameter|\Reflector" in "%s" on line "%d".', $reflectorParameter->getName(), $callableReflector->getFileName(), $callableReflector->getStartLine())); } - } elseif ($parameterType instanceof \ReflectionNamedType) { - $types[] = $parameterType->getName(); - } else { - throw new LogicException(\sprintf('Argument "$%s" of attribute autoconfigurator should have a type, use one or more of "\ReflectionClass|\ReflectionMethod|\ReflectionProperty|\ReflectionParameter|\Reflector" in "%s" on line "%d".', $reflectorParameter->getName(), $callableReflector->getFileName(), $callableReflector->getStartLine())); - } - try { - $attributeReflector = new \ReflectionClass($attributeName); - } catch (\ReflectionException) { - continue; - } + try { + $attributeReflector = new \ReflectionClass($attributeName); + } catch (\ReflectionException) { + continue; + } - $targets = $attributeReflector->getAttributes(\Attribute::class)[0] ?? 0; - $targets = $targets ? $targets->getArguments()[0] ?? -1 : 0; + $targets = $attributeReflector->getAttributes(\Attribute::class)[0] ?? 0; + $targets = $targets ? $targets->getArguments()[0] ?? -1 : 0; - foreach (['class', 'method', 'property', 'parameter'] as $symbol) { - if (['Reflector'] !== $types) { - if (!\in_array('Reflection'.ucfirst($symbol), $types, true)) { - continue; - } - if (!($targets & \constant('Attribute::TARGET_'.strtoupper($symbol)))) { - throw new LogicException(\sprintf('Invalid type "Reflection%s" on argument "$%s": attribute "%s" cannot target a '.$symbol.' in "%s" on line "%d".', ucfirst($symbol), $reflectorParameter->getName(), $attributeName, $callableReflector->getFileName(), $callableReflector->getStartLine())); + foreach (['class', 'method', 'property', 'parameter'] as $symbol) { + if (['Reflector'] !== $types) { + if (!\in_array('Reflection'.ucfirst($symbol), $types, true)) { + continue; + } + if (!($targets & \constant('Attribute::TARGET_'.strtoupper($symbol)))) { + throw new LogicException(\sprintf('Invalid type "Reflection%s" on argument "$%s": attribute "%s" cannot target a '.$symbol.' in "%s" on line "%d".', ucfirst($symbol), $reflectorParameter->getName(), $attributeName, $callableReflector->getFileName(), $callableReflector->getStartLine())); + } } + $this->{$symbol.'AttributeConfigurators'}[$attributeName][] = $callable; } - $this->{$symbol.'AttributeConfigurators'}[$attributeName] = $callable; } } @@ -94,13 +96,7 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed $instanceof = $value->getInstanceofConditionals(); $conditionals = $instanceof[$classReflector->getName()] ?? new ChildDefinition(''); - if ($this->classAttributeConfigurators) { - foreach ($classReflector->getAttributes() as $attribute) { - if ($configurator = $this->findConfigurator($this->classAttributeConfigurators, $attribute->getName())) { - $configurator($conditionals, $attribute->newInstance(), $classReflector); - } - } - } + $this->callConfigurators($this->classAttributeConfigurators, $conditionals, $classReflector); if ($this->parameterAttributeConfigurators) { try { @@ -111,11 +107,7 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed if ($constructorReflector) { foreach ($constructorReflector->getParameters() as $parameterReflector) { - foreach ($parameterReflector->getAttributes() as $attribute) { - if ($configurator = $this->findConfigurator($this->parameterAttributeConfigurators, $attribute->getName())) { - $configurator($conditionals, $attribute->newInstance(), $parameterReflector); - } - } + $this->callConfigurators($this->parameterAttributeConfigurators, $conditionals, $parameterReflector); } } } @@ -126,22 +118,10 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed continue; } - if ($this->methodAttributeConfigurators) { - foreach ($methodReflector->getAttributes() as $attribute) { - if ($configurator = $this->findConfigurator($this->methodAttributeConfigurators, $attribute->getName())) { - $configurator($conditionals, $attribute->newInstance(), $methodReflector); - } - } - } + $this->callConfigurators($this->methodAttributeConfigurators, $conditionals, $methodReflector); - if ($this->parameterAttributeConfigurators) { - foreach ($methodReflector->getParameters() as $parameterReflector) { - foreach ($parameterReflector->getAttributes() as $attribute) { - if ($configurator = $this->findConfigurator($this->parameterAttributeConfigurators, $attribute->getName())) { - $configurator($conditionals, $attribute->newInstance(), $parameterReflector); - } - } - } + foreach ($methodReflector->getParameters() as $parameterReflector) { + $this->callConfigurators($this->parameterAttributeConfigurators, $conditionals, $parameterReflector); } } } @@ -152,11 +132,7 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed continue; } - foreach ($propertyReflector->getAttributes() as $attribute) { - if ($configurator = $this->findConfigurator($this->propertyAttributeConfigurators, $attribute->getName())) { - $configurator($conditionals, $attribute->newInstance(), $propertyReflector); - } - } + $this->callConfigurators($this->propertyAttributeConfigurators, $conditionals, $propertyReflector); } } @@ -168,19 +144,37 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed return parent::processValue($value, $isRoot); } + /** + * Call all the configurators for the given attribute. + * + * @param array $configurators + */ + private function callConfigurators(array &$configurators, ChildDefinition $conditionals, \ReflectionClass|\ReflectionMethod|\ReflectionParameter|\ReflectionProperty $reflector): void + { + if (!$configurators) { + return; + } + + foreach ($reflector->getAttributes() as $attribute) { + foreach ($this->findConfigurators($configurators, $attribute->getName()) as $configurator) { + $configurator($conditionals, $attribute->newInstance(), $reflector); + } + } + } + /** * Find the first configurator for the given attribute name, looking up the class hierarchy. */ - private function findConfigurator(array &$configurators, string $attributeName): ?callable + private function findConfigurators(array &$configurators, string $attributeName): array { if (\array_key_exists($attributeName, $configurators)) { return $configurators[$attributeName]; } if (class_exists($attributeName) && $parent = get_parent_class($attributeName)) { - return $configurators[$attributeName] = self::findConfigurator($configurators, $parent); + return $configurators[$attributeName] = $this->findConfigurators($configurators, $parent); } - return $configurators[$attributeName] = null; + return $configurators[$attributeName] = []; } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php index 9b43d6e64aad5..8a7c11383ff01 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php @@ -28,6 +28,7 @@ class CheckCircularReferencesPass implements CompilerPassInterface { private array $currentPath; private array $checkedNodes; + private array $checkedLazyNodes; /** * Checks the ContainerBuilder object for circular references. @@ -57,22 +58,36 @@ private function checkOutEdges(array $edges): void $node = $edge->getDestNode(); $id = $node->getId(); - if (empty($this->checkedNodes[$id])) { - // Don't check circular references for lazy edges - if (!$node->getValue() || (!$edge->isLazy() && !$edge->isWeak())) { - $searchKey = array_search($id, $this->currentPath); - $this->currentPath[] = $id; + if (!empty($this->checkedNodes[$id])) { + continue; + } + + $isLeaf = (bool) $node->getValue(); + $isConcrete = !$edge->isLazy() && !$edge->isWeak(); + + // Skip already checked lazy services if they are still lazy. Will not gain any new information. + if (!empty($this->checkedLazyNodes[$id]) && (!$isLeaf || !$isConcrete)) { + continue; + } - if (false !== $searchKey) { - throw new ServiceCircularReferenceException($id, \array_slice($this->currentPath, $searchKey)); - } + // Process concrete references, otherwise defer check circular references for lazy edges. + if (!$isLeaf || $isConcrete) { + $searchKey = array_search($id, $this->currentPath); + $this->currentPath[] = $id; - $this->checkOutEdges($node->getOutEdges()); + if (false !== $searchKey) { + throw new ServiceCircularReferenceException($id, \array_slice($this->currentPath, $searchKey)); } + $this->checkOutEdges($node->getOutEdges()); + $this->checkedNodes[$id] = true; - array_pop($this->currentPath); + unset($this->checkedLazyNodes[$id]); + } else { + $this->checkedLazyNodes[$id] = true; } + + array_pop($this->currentPath); } } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/DefinitionErrorExceptionPass.php b/src/Symfony/Component/DependencyInjection/Compiler/DefinitionErrorExceptionPass.php index 26ab135b1a99c..2d6ad689443e8 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/DefinitionErrorExceptionPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/DefinitionErrorExceptionPass.php @@ -62,7 +62,10 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed } if ($value instanceof Reference && $this->currentId !== $targetId = (string) $value) { - if (ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior()) { + if ( + ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior() + || ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $value->getInvalidBehavior() + ) { $this->sourceReferences[$targetId][$this->currentId] ??= true; } else { $this->sourceReferences[$targetId][$this->currentId] = false; diff --git a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php index ddea146fd9e87..52af43f606256 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php @@ -69,6 +69,9 @@ public function process(ContainerBuilder $container): void if (!$this->graph->hasNode($id)) { continue; } + if ($definition->isPublic()) { + $this->connectedIds[$id] = true; + } foreach ($this->graph->getNode($id)->getOutEdges() as $edge) { if (isset($notInlinedIds[$edge->getSourceNode()->getId()])) { $this->currentId = $id; @@ -188,17 +191,13 @@ private function isInlineableDefinition(string $id, Definition $definition): boo return true; } - if ($definition->isPublic()) { + if ($definition->isPublic() + || $this->currentId === $id + || !$this->graph->hasNode($id) + ) { return false; } - if (!$this->graph->hasNode($id)) { - return true; - } - - if ($this->currentId === $id) { - return false; - } $this->connectedIds[$id] = true; $srcIds = []; @@ -223,6 +222,8 @@ private function isInlineableDefinition(string $id, Definition $definition): boo return false; } - return $this->container->getDefinition($srcId)->isShared(); + $srcDefinition = $this->container->getDefinition($srcId); + + return $srcDefinition->isShared() && !$srcDefinition->isLazy(); } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php b/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php index 4befef860a66e..8c6b5b582770d 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php @@ -88,8 +88,7 @@ private function findAndSortTaggedServices(string|TaggedIteratorArgument $tagNam if (null === $index && null === $defaultIndex && $defaultPriorityMethod && $reflector) { $defaultIndex = PriorityTaggedServiceUtil::getDefault($serviceId, $reflector, $defaultIndexMethod ?? 'getDefaultName', $tagName, $indexAttribute, $checkTaggedItem); } - $decorated = $definition->getTag('container.decorator')[0]['id'] ?? null; - $index = $index ?? $defaultIndex ?? $defaultIndex = $decorated ?? $serviceId; + $index ??= $defaultIndex ??= $definition->getTag('container.decorator')[0]['id'] ?? $serviceId; $services[] = [$priority, ++$i, $index, $serviceId, $class]; } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php b/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php index 87470c39894e4..89b822bc53b44 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php @@ -20,6 +20,7 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\TypedReference; use Symfony\Contracts\Service\Attribute\SubscribedService; +use Symfony\Contracts\Service\ServiceCollectionInterface; use Symfony\Contracts\Service\ServiceProviderInterface; use Symfony\Contracts\Service\ServiceSubscriberInterface; @@ -134,6 +135,7 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed $value->setBindings([ PsrContainerInterface::class => new BoundArgument($locatorRef, false), ServiceProviderInterface::class => new BoundArgument($locatorRef, false), + ServiceCollectionInterface::class => new BoundArgument($locatorRef, false), ] + $value->getBindings()); return parent::processValue($value); diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php index 90d4569c42bc4..8b0a804dc0d21 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php @@ -149,6 +149,11 @@ private function processDefinition(ContainerBuilder $container, string $id, Defi ->setAbstract(true); } + if ($definition->isSynthetic()) { + // Ignore container.excluded tag on synthetic services + $definition->clearTag('container.excluded'); + } + return $definition; } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php index 81c14ac5cc4d0..eedc0f484243c 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php @@ -54,17 +54,41 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed $value->setClass(ServiceLocator::class); } - $services = $value->getArguments()[0] ?? null; + $values = $value->getArguments()[0] ?? null; + $services = []; - if ($services instanceof TaggedIteratorArgument) { - $services = $this->findAndSortTaggedServices($services, $this->container); - } - - if (!\is_array($services)) { + if ($values instanceof TaggedIteratorArgument) { + foreach ($this->findAndSortTaggedServices($values, $this->container) as $k => $v) { + $services[$k] = new ServiceClosureArgument($v); + } + } elseif (!\is_array($values)) { throw new InvalidArgumentException(\sprintf('Invalid definition for service "%s": an array of references is expected as first argument when the "container.service_locator" tag is set.', $this->currentId)); + } else { + $i = 0; + + foreach ($values as $k => $v) { + if ($v instanceof ServiceClosureArgument) { + $services[$k] = $v; + continue; + } + + if ($i === $k) { + if ($v instanceof Reference) { + $k = (string) $v; + } + ++$i; + } elseif (\is_int($k)) { + $i = null; + } + + $services[$k] = new ServiceClosureArgument($v); + } + if (\count($services) === $i) { + ksort($services); + } } - $value->setArgument(0, self::map($services)); + $value->setArgument(0, $services); $id = '.service_locator.'.ContainerBuilder::hash($value); @@ -83,8 +107,12 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed public static function register(ContainerBuilder $container, array $map, ?string $callerId = null): Reference { + foreach ($map as $k => $v) { + $map[$k] = new ServiceClosureArgument($v); + } + $locator = (new Definition(ServiceLocator::class)) - ->addArgument(self::map($map)) + ->addArgument($map) ->addTag('container.service_locator'); if (null !== $callerId && $container->hasDefinition($callerId)) { @@ -109,29 +137,4 @@ public static function register(ContainerBuilder $container, array $map, ?string return new Reference($id); } - - public static function map(array $services): array - { - $i = 0; - - foreach ($services as $k => $v) { - if ($v instanceof ServiceClosureArgument) { - continue; - } - - if ($i === $k) { - if ($v instanceof Reference) { - unset($services[$k]); - $k = (string) $v; - } - ++$i; - } elseif (\is_int($k)) { - $i = null; - } - - $services[$k] = new ServiceClosureArgument($v); - } - - return $services; - } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php index 783080c09edc7..b656cf8d455e8 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php @@ -46,17 +46,8 @@ public function process(ContainerBuilder $container): void $defaultBag = new ParameterBag($resolvingBag->all()); $envTypes = $resolvingBag->getProvidedTypes(); foreach ($resolvingBag->getEnvPlaceholders() + $resolvingBag->getUnusedEnvPlaceholders() as $env => $placeholders) { - $values = []; - if (false === $i = strpos($env, ':')) { - $default = $defaultBag->has("env($env)") ? $defaultBag->get("env($env)") : self::TYPE_FIXTURES['string']; - $defaultType = null !== $default ? get_debug_type($default) : 'string'; - $values[$defaultType] = $default; - } else { - $prefix = substr($env, 0, $i); - foreach ($envTypes[$prefix] ?? ['string'] as $type) { - $values[$type] = self::TYPE_FIXTURES[$type] ?? null; - } - } + $values = $this->getPlaceholderValues($env, $defaultBag, $envTypes); + foreach ($placeholders as $placeholder) { BaseNode::setPlaceholder($placeholder, $values); } @@ -97,4 +88,50 @@ public function getExtensionConfig(): array $this->extensionConfig = []; } } + + /** + * @param array> $envTypes + * + * @return array + */ + private function getPlaceholderValues(string $env, ParameterBag $defaultBag, array $envTypes): array + { + if (false === $i = strpos($env, ':')) { + [$default, $defaultType] = $this->getParameterDefaultAndDefaultType("env($env)", $defaultBag); + + return [$defaultType => $default]; + } + + $prefix = substr($env, 0, $i); + if ('default' === $prefix) { + $parts = explode(':', $env); + array_shift($parts); // Remove 'default' prefix + $parameter = array_shift($parts); // Retrieve and remove parameter + + [$defaultParameter, $defaultParameterType] = $this->getParameterDefaultAndDefaultType($parameter, $defaultBag); + + return [ + $defaultParameterType => $defaultParameter, + ...$this->getPlaceholderValues(implode(':', $parts), $defaultBag, $envTypes), + ]; + } + + $values = []; + foreach ($envTypes[$prefix] ?? ['string'] as $type) { + $values[$type] = self::TYPE_FIXTURES[$type] ?? null; + } + + return $values; + } + + /** + * @return array{0: string, 1: string} + */ + private function getParameterDefaultAndDefaultType(string $name, ParameterBag $defaultBag): array + { + $default = $defaultBag->has($name) ? $defaultBag->get($name) : self::TYPE_FIXTURES['string']; + $defaultType = null !== $default ? get_debug_type($default) : 'string'; + + return [$default, $defaultType]; + } } diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 7389ca6310447..4d1765154e249 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -129,7 +129,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface private array $autoconfiguredInstanceof = []; /** - * @var array + * @var array */ private array $autoconfiguredAttributes = []; @@ -717,12 +717,11 @@ public function merge(self $container): void $this->autoconfiguredInstanceof[$interface] = $childDefinition; } - foreach ($container->getAutoconfiguredAttributes() as $attribute => $configurator) { - if (isset($this->autoconfiguredAttributes[$attribute])) { - throw new InvalidArgumentException(\sprintf('"%s" has already been autoconfigured and merge() does not support merging autoconfiguration for the same attribute.', $attribute)); - } - - $this->autoconfiguredAttributes[$attribute] = $configurator; + foreach ($container->getAttributeAutoconfigurators() as $attribute => $configurators) { + $this->autoconfiguredAttributes[$attribute] = array_merge( + $this->autoconfiguredAttributes[$attribute] ?? [], + $configurators) + ; } } @@ -791,10 +790,11 @@ public function parameterCannotBeEmpty(string $name, string $message): void * * The parameter bag is frozen; * * Extension loading is disabled. * - * @param bool $resolveEnvPlaceholders Whether %env()% parameters should be resolved using the current - * env vars or be replaced by uniquely identifiable placeholders. - * Set to "true" when you want to use the current ContainerBuilder - * directly, keep to "false" when the container is dumped instead. + * @param bool $resolveEnvPlaceholders Whether %env()% parameters should be resolved at build time using + * the current env var values (true), or be resolved at runtime based + * on the environment (false). In general, this should be set to "true" + * when you want to use the current ContainerBuilder directly, and to + * "false" when the container is dumped instead. */ public function compile(bool $resolveEnvPlaceholders = false): void { @@ -823,7 +823,7 @@ public function compile(bool $resolveEnvPlaceholders = false): void if ($bag instanceof EnvPlaceholderParameterBag) { if ($resolveEnvPlaceholders) { - $this->parameterBag = new ParameterBag($this->resolveEnvPlaceholders($bag->all(), true)); + $this->parameterBag = new ParameterBag($this->resolveEnvPlaceholders($this->escapeParameters($bag->all()), true)); } $this->envPlaceholders = $bag->getEnvPlaceholders(); @@ -1109,14 +1109,15 @@ private function createService(Definition $definition, array &$inlineServices, b } if (\is_array($callable) && ( - $callable[0] instanceof Reference + 'Closure' !== $class + || $callable[0] instanceof Reference || $callable[0] instanceof Definition && !isset($inlineServices[spl_object_hash($callable[0])]) )) { $initializer = function () use ($callable, &$inlineServices) { return $this->doResolveServices($callable[0], $inlineServices); }; - $proxy = eval('return '.LazyClosure::getCode('$initializer', $callable, $definition, $this, $id).';'); + $proxy = eval('return '.LazyClosure::getCode('$initializer', $callable, $class, $this, $id).';'); $this->shareService($definition, $proxy, $id, $inlineServices); return $proxy; @@ -1173,7 +1174,7 @@ private function createService(Definition $definition, array &$inlineServices, b if (!$definition->isDeprecated() && \is_array($factory) && \is_string($factory[0])) { $r = new \ReflectionClass($factory[0]); - if (0 < strpos($r->getDocComment(), "\n * @deprecated ")) { + if (0 < strpos($r->getDocComment() ?: '', "\n * @deprecated ")) { trigger_deprecation('', '', 'The "%s" service relies on the deprecated "%s" factory class. It should either be deprecated or its factory upgraded.', $id, $r->name); } } @@ -1190,7 +1191,7 @@ private function createService(Definition $definition, array &$inlineServices, b $service = $r->getConstructor() ? $r->newInstanceArgs($arguments) : $r->newInstance(); } - if (!$definition->isDeprecated() && 0 < strpos($r->getDocComment(), "\n * @deprecated ")) { + if (!$definition->isDeprecated() && 0 < strpos($r->getDocComment() ?: '', "\n * @deprecated ")) { trigger_deprecation('', '', 'The "%s" service relies on the deprecated "%s" class. It should either be deprecated or its implementation upgraded.', $id, $r->name); } } @@ -1351,6 +1352,38 @@ public function findTaggedServiceIds(string $name, bool $throwOnAbstract = false return $tags; } + /** + * Returns service ids for a given tag, asserting they have the "container.excluded" tag. + * + * Example: + * + * $container->register('foo')->addResourceTag('my.tag', ['hello' => 'world']) + * + * $serviceIds = $container->findTaggedResourceIds('my.tag'); + * foreach ($serviceIds as $serviceId => $tags) { + * foreach ($tags as $tag) { + * echo $tag['hello']; + * } + * } + * + * @return array An array of tags with the tagged service as key, holding a list of attribute arrays + */ + public function findTaggedResourceIds(string $tagName): array + { + $this->usedTags[] = $tagName; + $tags = []; + foreach ($this->getDefinitions() as $id => $definition) { + if ($definition->hasTag($tagName)) { + if (!$definition->hasTag('container.excluded')) { + throw new InvalidArgumentException(\sprintf('The resource "%s" tagged "%s" is missing the "container.excluded" tag.', $id, $tagName)); + } + $tags[$id] = $definition->getTag($tagName); + } + } + + return $tags; + } + /** * Returns all tags the defined services use. * @@ -1416,7 +1449,7 @@ public function registerForAutoconfiguration(string $interface): ChildDefinition */ public function registerAttributeForAutoconfiguration(string $attributeClass, callable $configurator): void { - $this->autoconfiguredAttributes[$attributeClass] = $configurator; + $this->autoconfiguredAttributes[$attributeClass][] = $configurator; } /** @@ -1457,9 +1490,30 @@ public function getAutoconfiguredInstanceof(): array } /** - * @return array + * @return array + * + * @deprecated Use {@see getAttributeAutoconfigurators()} instead */ public function getAutoconfiguredAttributes(): array + { + trigger_deprecation('symfony/dependency-injection', '7.3', 'The "%s()" method is deprecated, use "getAttributeAutoconfigurators()" instead.', __METHOD__); + + $autoconfiguredAttributes = []; + foreach ($this->autoconfiguredAttributes as $attribute => $configurators) { + if (\count($configurators) > 1) { + throw new LogicException(\sprintf('The "%s" attribute has %d configurators. Use "getAttributeAutoconfigurators()" to get all of them.', $attribute, \count($configurators))); + } + + $autoconfiguredAttributes[$attribute] = $configurators[0]; + } + + return $autoconfiguredAttributes; + } + + /** + * @return array + */ + public function getAttributeAutoconfigurators(): array { return $this->autoconfiguredAttributes; } @@ -1775,4 +1829,18 @@ private function inVendors(string $path): bool return $this->pathsInVendor[$path] = false; } + + private function escapeParameters(array $parameters): array + { + $params = []; + foreach ($parameters as $k => $v) { + $params[$k] = match (true) { + \is_array($v) => $this->escapeParameters($v), + \is_string($v) => str_replace('%', '%%', $v), + default => $v, + }; + } + + return $params; + } } diff --git a/src/Symfony/Component/DependencyInjection/ContainerInterface.php b/src/Symfony/Component/DependencyInjection/ContainerInterface.php index 39fd080c336c3..6d6f6d3bf0bfe 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerInterface.php +++ b/src/Symfony/Component/DependencyInjection/ContainerInterface.php @@ -33,11 +33,13 @@ interface ContainerInterface extends PsrContainerInterface public function set(string $id, ?object $service): void; /** + * @template C of object * @template B of self::*_REFERENCE * - * @param B $invalidBehavior + * @param string|class-string $id + * @param B $invalidBehavior * - * @psalm-return (B is self::EXCEPTION_ON_INVALID_REFERENCE|self::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE ? object : object|null) + * @return ($id is class-string ? (B is 0|1 ? C|object : C|object|null) : (B is 0|1 ? object : object|null)) * * @throws ServiceCircularReferenceException When a circular reference is detected * @throws ServiceNotFoundException When the service is not defined diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 0abdc5d560cda..61cc0b9d6785c 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -455,6 +455,20 @@ public function addTag(string $name, array $attributes = []): static return $this; } + /** + * Adds a "resource" tag to the definition and marks it as excluded. + * + * These definitions should be processed using {@see ContainerBuilder::findTaggedResourceIds()} + * + * @return $this + */ + public function addResourceTag(string $name, array $attributes = []): static + { + return $this->addTag($name, $attributes) + ->addTag('container.excluded', ['source' => \sprintf('by tag "%s"', $name)]) + ->setAbstract(true); + } + /** * Whether this definition has a tag with the given name. */ diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 37793a1ee02a8..fb2d45f9268ce 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -338,7 +338,7 @@ class %s extends {$options['class']} EOF; foreach ($this->preload as $class) { - if (!$class || str_contains($class, '$') || \in_array($class, ['int', 'float', 'string', 'bool', 'resource', 'object', 'array', 'null', 'callable', 'iterable', 'mixed', 'void'], true)) { + if (!$class || str_contains($class, '$') || \in_array($class, ['int', 'float', 'string', 'bool', 'resource', 'object', 'array', 'null', 'callable', 'iterable', 'mixed', 'void', 'never'], true)) { continue; } if (!(class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false)) || (new \ReflectionClass($class))->isUserDefined()) { @@ -527,7 +527,7 @@ private function collectLineage(string $class, array &$lineage): void return; } $file = $r->getFileName(); - if (str_ends_with($file, ') : eval()\'d code')) { + if ($file && str_ends_with($file, ') : eval()\'d code')) { $file = substr($file, 0, strrpos($file, '(', -17)); } if (!$file || $this->doExport($file) === $exportedFile = $this->export($file)) { @@ -574,12 +574,13 @@ private function generateProxyClasses(): array continue; } do { - $file = $r->getFileName(); - if (str_ends_with($file, ') : eval()\'d code')) { - $file = substr($file, 0, strrpos($file, '(', -17)); - } - if (is_file($file)) { - $this->container->addResource(new FileResource($file)); + if ($file = $r->getFileName()) { + if (str_ends_with($file, ') : eval()\'d code')) { + $file = substr($file, 0, strrpos($file, '(', -17)); + } + if (is_file($file)) { + $this->container->addResource(new FileResource($file)); + } } $r = $r->getParentClass() ?: null; } while ($r?->isUserDefined()); @@ -831,8 +832,7 @@ private function addService(string $id, Definition $definition): array if ($class = $definition->getClass()) { $class = $class instanceof Parameter ? '%'.$class.'%' : $this->container->resolveEnvPlaceholders($class); $return[] = \sprintf(str_starts_with($class, '%') ? '@return object A %1$s instance' : '@return \%s', ltrim($class, '\\')); - } elseif ($definition->getFactory()) { - $factory = $definition->getFactory(); + } elseif ($factory = $definition->getFactory()) { if (\is_string($factory) && !str_starts_with($factory, '@=')) { $return[] = \sprintf('@return object An instance returned by %s()', $factory); } elseif (\is_array($factory) && (\is_string($factory[0]) || $factory[0] instanceof Definition || $factory[0] instanceof Reference)) { @@ -1152,9 +1152,7 @@ private function addNewInstance(Definition $definition, string $return = '', ?st $arguments[] = (\is_string($i) ? $i.': ' : '').$this->dumpValue($value); } - if (null !== $definition->getFactory()) { - $callable = $definition->getFactory(); - + if ($callable = $definition->getFactory()) { if ('current' === $callable && [0] === array_keys($definition->getArguments()) && \is_array($value) && [0] === array_keys($value)) { return $return.$this->dumpValue($value[0]).$tail; } @@ -1187,13 +1185,13 @@ private function addNewInstance(Definition $definition, string $return = '', ?st throw new RuntimeException(\sprintf('Cannot dump definition because of invalid factory method (%s).', $callable[1] ?: 'n/a')); } - if (['...'] === $arguments && ($definition->isLazy() || 'Closure' !== ($definition->getClass() ?? 'Closure')) && ( + if (['...'] === $arguments && ('Closure' !== ($class = $definition->getClass() ?: 'Closure') || $definition->isLazy() && ( $callable[0] instanceof Reference || ($callable[0] instanceof Definition && !$this->definitionVariables->contains($callable[0])) - )) { + ))) { $initializer = 'fn () => '.$this->dumpValue($callable[0]); - return $return.LazyClosure::getCode($initializer, $callable, $definition, $this->container, $id).$tail; + return $return.LazyClosure::getCode($initializer, $callable, $class, $this->container, $id).$tail; } if ($callable[0] instanceof Reference @@ -2197,6 +2195,12 @@ private function isSingleUsePrivateNode(ServiceReferenceGraphNode $node): bool if ($edge->isLazy() || !$value instanceof Definition || !$value->isShared()) { return false; } + + // When the source node is a proxy or ghost, it will construct its references only when the node itself is initialized. + // Since the node can be cloned before being fully initialized, we do not know how often its references are used. + if ($this->getProxyDumper()->isProxyCandidate($value)) { + return false; + } $ids[$edge->getSourceNode()->getId()] = true; } @@ -2305,7 +2309,6 @@ private function getAutoloadFile(): ?string private function getClasses(Definition $definition, string $id): array { $classes = []; - $resolve = $this->container->getParameterBag()->resolveValue(...); while ($definition instanceof Definition) { foreach ($definition->getTag($this->preloadTags[0]) as $tag) { @@ -2317,24 +2320,24 @@ private function getClasses(Definition $definition, string $id): array } if ($class = $definition->getClass()) { - $classes[] = trim($resolve($class), '\\'); + $classes[] = trim($class, '\\'); } $factory = $definition->getFactory(); + if (\is_string($factory) && !str_starts_with($factory, '@=') && str_contains($factory, '::')) { + $factory = explode('::', $factory); + } + if (!\is_array($factory)) { - $factory = [$factory]; + $definition = $factory; + continue; } - if (\is_string($factory[0])) { - $factory[0] = $resolve($factory[0]); + $definition = $factory[0] ?? null; - if (false !== $i = strrpos($factory[0], '::')) { - $factory[0] = substr($factory[0], 0, $i); - } + if (\is_string($definition)) { $classes[] = trim($factory[0], '\\'); } - - $definition = $factory[0]; } return $classes; diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index ec115500bb0cf..d79e7b90408b2 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -50,18 +50,18 @@ public function dump(array $options = []): string $this->dumper ??= new YmlDumper(); - return $this->container->resolveEnvPlaceholders($this->addParameters()."\n".$this->addServices()); + return $this->addParameters()."\n".$this->addServices(); } private function addService(string $id, Definition $definition): string { - $code = " $id:\n"; + $code = " {$this->dumper->dump($id)}:\n"; if ($class = $definition->getClass()) { if (str_starts_with($class, '\\')) { $class = substr($class, 1); } - $code .= \sprintf(" class: %s\n", $this->dumper->dump($class)); + $code .= \sprintf(" class: %s\n", $this->dumper->dump($this->container->resolveEnvPlaceholders($class))); } if (!$definition->isPrivate()) { @@ -87,7 +87,7 @@ private function addService(string $id, Definition $definition): string } if ($definition->getFile()) { - $code .= \sprintf(" file: %s\n", $this->dumper->dump($definition->getFile())); + $code .= \sprintf(" file: %s\n", $this->dumper->dump($this->container->resolveEnvPlaceholders($definition->getFile()))); } if ($definition->isSynthetic()) { @@ -238,7 +238,7 @@ private function dumpCallable(mixed $callable): mixed } } - return $callable; + return $this->container->resolveEnvPlaceholders($callable); } /** @@ -299,7 +299,7 @@ private function dumpValue(mixed $value): mixed if (\is_array($value)) { $code = []; foreach ($value as $k => $v) { - $code[$k] = $this->dumpValue($v); + $code[$this->container->resolveEnvPlaceholders($k)] = $this->dumpValue($v); } return $code; @@ -319,7 +319,7 @@ private function dumpValue(mixed $value): mixed throw new RuntimeException(\sprintf('Unable to dump a service container if a parameter is an object or a resource, got "%s".', get_debug_type($value))); } - return $value; + return $this->container->resolveEnvPlaceholders($value); } private function getServiceCall(string $id, ?Reference $reference = null): string @@ -359,7 +359,7 @@ private function prepareParameters(array $parameters, bool $escape = true): arra $filtered[$key] = $value; } - return $escape ? $this->escape($filtered) : $filtered; + return $escape ? $this->container->resolveEnvPlaceholders($this->escape($filtered)) : $filtered; } private function escape(array $arguments): array diff --git a/src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/LazyServiceInstantiator.php b/src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/LazyServiceInstantiator.php index f5e7dead566b9..10748256261e0 100644 --- a/src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/LazyServiceInstantiator.php +++ b/src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/LazyServiceInstantiator.php @@ -29,10 +29,19 @@ public function instantiateProxy(ContainerInterface $container, Definition $defi throw new InvalidArgumentException(\sprintf('Cannot instantiate lazy proxy for service "%s".', $id)); } - if (!class_exists($proxyClass = $dumper->getProxyClass($definition, $asGhostObject), false)) { + if (\PHP_VERSION_ID >= 80400 && $asGhostObject) { + return (new \ReflectionClass($definition->getClass()))->newLazyGhost(static function ($ghost) use ($realInstantiator) { $realInstantiator($ghost); }); + } + + $class = null; + if (!class_exists($proxyClass = $dumper->getProxyClass($definition, $asGhostObject, $class), false)) { eval($dumper->getProxyCode($definition, $id)); } - return $asGhostObject ? $proxyClass::createLazyGhost($realInstantiator) : $proxyClass::createLazyProxy($realInstantiator); + if ($definition->getClass() === $proxyClass) { + return $class->newLazyProxy($realInstantiator); + } + + return \PHP_VERSION_ID < 80400 && $asGhostObject ? $proxyClass::createLazyGhost($realInstantiator) : $proxyClass::createLazyProxy($realInstantiator); } } diff --git a/src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/LazyServiceDumper.php b/src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/LazyServiceDumper.php index b335fa37857e1..c534630e36ec8 100644 --- a/src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/LazyServiceDumper.php +++ b/src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/LazyServiceDumper.php @@ -56,9 +56,21 @@ public function isProxyCandidate(Definition $definition, ?bool &$asGhostObject = } } + if (\PHP_VERSION_ID < 80400) { + try { + $asGhostObject = (bool) ProxyHelper::generateLazyGhost(new \ReflectionClass($class)); + } catch (LogicException) { + } + + return true; + } + try { - $asGhostObject = (bool) ProxyHelper::generateLazyGhost(new \ReflectionClass($class)); - } catch (LogicException) { + $asGhostObject = (bool) (new \ReflectionClass($class))->newLazyGhost(static fn () => null); + } catch (\Error $e) { + if (__FILE__ !== $e->getFile()) { + throw $e; + } } return true; @@ -76,6 +88,16 @@ public function getProxyFactoryCode(Definition $definition, string $id, string $ $proxyClass = $this->getProxyClass($definition, $asGhostObject); if (!$asGhostObject) { + if ($definition->getClass() === $proxyClass) { + return <<newLazyProxy(static fn () => $factoryCode); + } + + + EOF; + } + return <<createProxy('$proxyClass', static fn () => \\$proxyClass::createLazyProxy(static fn () => $factoryCode)); @@ -85,11 +107,23 @@ public function getProxyFactoryCode(Definition $definition, string $id, string $ EOF; } - $factoryCode = \sprintf('static fn ($proxy) => %s', $factoryCode); + if (\PHP_VERSION_ID < 80400) { + $factoryCode = \sprintf('static fn ($proxy) => %s', $factoryCode); + + return <<createProxy('$proxyClass', static fn () => \\$proxyClass::createLazyGhost($factoryCode)); + } + + + EOF; + } + + $factoryCode = \sprintf('static function ($proxy) use ($container) { %s; }', $factoryCode); return <<createProxy('$proxyClass', static fn () => \\$proxyClass::createLazyGhost($factoryCode)); + $instantiation new \ReflectionClass('$proxyClass')->newLazyGhost($factoryCode); } @@ -104,12 +138,21 @@ public function getProxyCode(Definition $definition, ?string $id = null): string $proxyClass = $this->getProxyClass($definition, $asGhostObject, $class); if ($asGhostObject) { + if (\PHP_VERSION_ID >= 80400) { + return ''; + } + try { return ($class?->isReadOnly() ? 'readonly ' : '').'class '.$proxyClass.ProxyHelper::generateLazyGhost($class); } catch (LogicException $e) { throw new InvalidArgumentException(\sprintf('Cannot generate lazy ghost for service "%s".', $id ?? $definition->getClass()), 0, $e); } } + + if ($definition->getClass() === $proxyClass) { + return ''; + } + $interfaces = []; if ($definition->hasTag('proxy')) { @@ -144,8 +187,28 @@ public function getProxyClass(Definition $definition, bool $asGhostObject, ?\Ref $class = 'object' !== $definition->getClass() ? $definition->getClass() : 'stdClass'; $class = new \ReflectionClass($class); - return preg_replace('/^.*\\\\/', '', $definition->getClass()) - .($asGhostObject ? 'Ghost' : 'Proxy') + if (\PHP_VERSION_ID < 80400) { + return preg_replace('/^.*\\\\/', '', $definition->getClass()) + .($asGhostObject ? 'Ghost' : 'Proxy') + .ucfirst(substr(hash('xxh128', $this->salt.'+'.$class->name.'+'.serialize($definition->getTag('proxy'))), -7)); + } + + if ($asGhostObject) { + return $class->name; + } + + if (!$definition->hasTag('proxy') && !$class->isAbstract()) { + $parent = $class; + do { + $extendsInternalClass = $parent->isInternal(); + } while (!$extendsInternalClass && $parent = $parent->getParentClass()); + + if (!$extendsInternalClass) { + return $class->name; + } + } + + return preg_replace('/^.*\\\\/', '', $definition->getClass()).'Proxy' .ucfirst(substr(hash('xxh128', $this->salt.'+'.$class->name.'+'.serialize($definition->getTag('proxy'))), -7)); } } diff --git a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php index 9e17bc424a2a9..bc38767bcb546 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php @@ -224,10 +224,14 @@ public function registerClasses(Definition $prototype, string $namespace, string if (null === $alias) { throw new LogicException(\sprintf('Alias cannot be automatically determined for class "%s". If you have used the #[AsAlias] attribute with a class implementing multiple interfaces, add the interface you want to alias to the first parameter of #[AsAlias].', $class)); } - if (isset($this->aliases[$alias])) { - throw new LogicException(\sprintf('The "%s" alias has already been defined with the #[AsAlias] attribute in "%s".', $alias, $this->aliases[$alias])); + + if (!$attribute->when || \in_array($this->env, $attribute->when, true)) { + if (isset($this->aliases[$alias])) { + throw new LogicException(\sprintf('The "%s" alias has already been defined with the #[AsAlias] attribute in "%s".', $alias, $this->aliases[$alias])); + } + + $this->aliases[$alias] = new Alias($class, $public); } - $this->aliases[$alias] = new Alias($class, $public); } } diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index f596980663f15..eed874cd9f6b5 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -339,7 +339,11 @@ private function parseDefinition(\DOMElement $service, string $file, Definition } foreach ($this->getChildren($service, 'call') as $call) { - $definition->addMethodCall($call->getAttribute('method'), $this->getArgumentsAsPhp($call, 'argument', $file), XmlUtils::phpize($call->getAttribute('returns-clone'))); + $definition->addMethodCall( + $call->getAttribute('method'), + $this->getArgumentsAsPhp($call, 'argument', $file), + XmlUtils::phpize($call->getAttribute('returns-clone')) ?: false + ); } $tags = $this->getChildren($service, 'tag'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Argument/LazyClosureTest.php b/src/Symfony/Component/DependencyInjection/Tests/Argument/LazyClosureTest.php index 428227d19e2bc..e1b5c2a90f2ed 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Argument/LazyClosureTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Argument/LazyClosureTest.php @@ -33,7 +33,7 @@ public function testThrowsWhenNotUsingInterface() $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Cannot create adapter for service "foo" because "Symfony\Component\DependencyInjection\Tests\Argument\LazyClosureTest" is not an interface.'); - LazyClosure::getCode('foo', [new \stdClass(), 'bar'], new Definition(self::class), new ContainerBuilder(), 'foo'); + LazyClosure::getCode('foo', [new \stdClass(), 'bar'], self::class, new ContainerBuilder(), 'foo'); } public function testThrowsOnNonFunctionalInterface() @@ -41,7 +41,7 @@ public function testThrowsOnNonFunctionalInterface() $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Cannot create adapter for service "foo" because interface "Symfony\Component\DependencyInjection\Tests\Argument\NonFunctionalInterface" doesn\'t have exactly one method.'); - LazyClosure::getCode('foo', [new \stdClass(), 'bar'], new Definition(NonFunctionalInterface::class), new ContainerBuilder(), 'foo'); + LazyClosure::getCode('foo', [new \stdClass(), 'bar'], NonFunctionalInterface::class, new ContainerBuilder(), 'foo'); } public function testThrowsOnUnknownMethodInInterface() @@ -49,7 +49,7 @@ public function testThrowsOnUnknownMethodInInterface() $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Cannot create lazy closure for service "bar" because its corresponding callable is invalid.'); - LazyClosure::getCode('bar', [new Definition(FunctionalInterface::class), 'bar'], new Definition(\Closure::class), new ContainerBuilder(), 'bar'); + LazyClosure::getCode('bar', [new Definition(FunctionalInterface::class), 'bar'], \Closure::class, new ContainerBuilder(), 'bar'); } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php index c9bcb10878bec..20a0a7b5a8d5a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php @@ -13,9 +13,12 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; +use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; +use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument; use Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass; use Symfony\Component\DependencyInjection\Compiler\CheckCircularReferencesPass; use Symfony\Component\DependencyInjection\Compiler\Compiler; +use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; use Symfony\Component\DependencyInjection\Reference; @@ -126,6 +129,21 @@ public function testProcessIgnoresLazyServices() $this->addToAssertionCount(1); } + public function testProcessDefersLazyServices() + { + $container = new ContainerBuilder(); + + $container->register('a')->addArgument(new ServiceLocatorArgument(new TaggedIteratorArgument('tag', needsIndexes: true))); + $container->register('b')->addArgument(new Reference('c'))->addTag('tag'); + $container->register('c')->addArgument(new Reference('b')); + + (new ServiceLocatorTagPass())->process($container); + + $this->expectException(ServiceCircularReferenceException::class); + + $this->process($container); + } + public function testProcessIgnoresIteratorArguments() { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php index 48ed32df6d63d..9858a10e75b10 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php @@ -197,7 +197,7 @@ public function testProcessMovesTagsFromDecoratedDefinitionToDecoratingDefinitio $this->process($container); - $this->assertEmpty($container->getDefinition('baz.inner')->getTags()); + $this->assertSame([], $container->getDefinition('baz.inner')->getTags()); $this->assertEquals(['bar' => ['attr' => 'baz'], 'foobar' => ['attr' => 'bar'], 'container.decorator' => [['id' => 'foo', 'inner' => 'baz.inner']]], $container->getDefinition('baz')->getTags()); } @@ -220,7 +220,7 @@ public function testProcessMovesTagsFromDecoratedDefinitionToDecoratingDefinitio $this->process($container); - $this->assertEmpty($container->getDefinition('deco1')->getTags()); + $this->assertSame([], $container->getDefinition('deco1')->getTags()); $this->assertEquals(['bar' => ['attr' => 'baz'], 'container.decorator' => [['id' => 'foo', 'inner' => 'deco1.inner']]], $container->getDefinition('deco2')->getTags()); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DefinitionErrorExceptionPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DefinitionErrorExceptionPassTest.php index 9ab5c27fcf763..5ed7be315114a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DefinitionErrorExceptionPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DefinitionErrorExceptionPassTest.php @@ -64,6 +64,9 @@ public function testSkipNestedErrors() $container->register('foo', 'stdClass') ->addArgument(new Reference('bar', ContainerBuilder::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE)); + $container->register('baz', 'stdClass') + ->addArgument(new Reference('bar', ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE)); + $pass = new DefinitionErrorExceptionPass(); $pass->process($container); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/PassConfigTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/PassConfigTest.php index 8001c54010284..66718b7bb08c0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/PassConfigTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/PassConfigTest.php @@ -45,10 +45,10 @@ public function testPassOrderingWithoutPasses() $config->setOptimizationPasses([]); $config->setRemovingPasses([]); - $this->assertEmpty($config->getBeforeOptimizationPasses()); - $this->assertEmpty($config->getAfterRemovingPasses()); - $this->assertEmpty($config->getBeforeRemovingPasses()); - $this->assertEmpty($config->getOptimizationPasses()); - $this->assertEmpty($config->getRemovingPasses()); + $this->assertSame([], $config->getBeforeOptimizationPasses()); + $this->assertSame([], $config->getAfterRemovingPasses()); + $this->assertSame([], $config->getBeforeRemovingPasses()); + $this->assertSame([], $config->getOptimizationPasses()); + $this->assertSame([], $config->getRemovingPasses()); } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInstanceofConditionalsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInstanceofConditionalsPassTest.php index 78fc261ee290e..b4e50d39f2eae 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInstanceofConditionalsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInstanceofConditionalsPassTest.php @@ -39,7 +39,7 @@ public function testProcess() $parent = '.instanceof.'.parent::class.'.0.foo'; $def = $container->getDefinition('foo'); - $this->assertEmpty($def->getInstanceofConditionals()); + $this->assertSame([], $def->getInstanceofConditionals()); $this->assertInstanceOf(ChildDefinition::class, $def); $this->assertTrue($def->isAutowired()); $this->assertSame($parent, $def->getParent()); @@ -266,10 +266,10 @@ public function testMergeReset() $abstract = $container->getDefinition('.abstract.instanceof.bar'); - $this->assertEmpty($abstract->getArguments()); - $this->assertEmpty($abstract->getMethodCalls()); + $this->assertSame([], $abstract->getArguments()); + $this->assertSame([], $abstract->getMethodCalls()); $this->assertNull($abstract->getDecoratedService()); - $this->assertEmpty($abstract->getTags()); + $this->assertSame([], $abstract->getTags()); $this->assertTrue($abstract->isAbstract()); } @@ -376,6 +376,21 @@ public function testDecoratorsKeepBehaviorDescribingTags() ], $container->getDefinition('decorator')->getTags()); $this->assertFalse($container->hasParameter('container.behavior_describing_tags')); } + + public function testSyntheticService() + { + $container = new ContainerBuilder(); + $container->register('kernel', \stdClass::class) + ->setInstanceofConditionals([ + \stdClass::class => (new ChildDefinition('')) + ->addTag('container.excluded'), + ]) + ->setSynthetic(true); + + (new ResolveInstanceofConditionalsPass())->process($container); + + $this->assertSame([], $container->getDefinition('kernel')->getTags()); + } } class DecoratorWithBehavior implements ResetInterface, ResourceCheckerInterface, ServiceSubscriberInterface diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php index 812b47c7a6f1f..9a93067756d50 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php @@ -86,6 +86,26 @@ public function testProcessValue() $this->assertSame(CustomDefinition::class, \get_class($locator('inlines.service'))); } + public function testServiceListIsOrdered() + { + $container = new ContainerBuilder(); + + $container->register('bar', CustomDefinition::class); + $container->register('baz', CustomDefinition::class); + + $container->register('foo', ServiceLocator::class) + ->setArguments([[ + new Reference('baz'), + new Reference('bar'), + ]]) + ->addTag('container.service_locator') + ; + + (new ServiceLocatorTagPass())->process($container); + + $this->assertSame(['bar', 'baz'], array_keys($container->getDefinition('foo')->getArgument(0))); + } + public function testServiceWithKeyOverwritesPreviousInheritedKey() { $container = new ContainerBuilder(); @@ -170,6 +190,27 @@ public function testTaggedServices() $this->assertSame(TestDefinition2::class, $locator('baz')::class); } + public function testTaggedServicesKeysAreKept() + { + $container = new ContainerBuilder(); + + $container->register('bar', TestDefinition1::class)->addTag('test_tag', ['index' => 0]); + $container->register('baz', TestDefinition2::class)->addTag('test_tag', ['index' => 1]); + + $container->register('foo', ServiceLocator::class) + ->setArguments([new TaggedIteratorArgument('test_tag', 'index', null, true)]) + ->addTag('container.service_locator') + ; + + (new ServiceLocatorTagPass())->process($container); + + /** @var ServiceLocator $locator */ + $locator = $container->get('foo'); + + $this->assertSame(TestDefinition1::class, $locator(0)::class); + $this->assertSame(TestDefinition2::class, $locator(1)::class); + } + public function testIndexedByServiceIdWithDecoration() { $container = new ContainerBuilder(); @@ -201,15 +242,33 @@ public function testIndexedByServiceIdWithDecoration() static::assertInstanceOf(DecoratedService::class, $locator->get(Service::class)); } - public function testDefinitionOrderIsTheSame() + public function testServicesKeysAreKept() { $container = new ContainerBuilder(); $container->register('service-1'); $container->register('service-2'); + $container->register('service-3'); $locator = ServiceLocatorTagPass::register($container, [ - new Reference('service-2'), new Reference('service-1'), + 'service-2' => new Reference('service-2'), + 'foo' => new Reference('service-3'), + ]); + $locator = $container->getDefinition($locator); + $factories = $locator->getArguments()[0]; + + static::assertSame([0, 'service-2', 'foo'], array_keys($factories)); + } + + public function testDefinitionOrderIsTheSame() + { + $container = new ContainerBuilder(); + $container->register('service-1'); + $container->register('service-2'); + + $locator = ServiceLocatorTagPass::register($container, [ + 'service-2' => new Reference('service-2'), + 'service-1' => new Reference('service-1'), ]); $locator = $container->getDefinition($locator); $factories = $locator->getArguments()[0]; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php index 8c5c4cc32323e..17ef87c3fffad 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php @@ -73,6 +73,36 @@ public function testDefaultEnvWithoutPrefixIsValidatedInConfig() $this->doProcess($container); } + public function testDefaultProcessorWithScalarNode() + { + $container = new ContainerBuilder(); + $container->setParameter('parameter_int', 12134); + $container->setParameter('env(FLOATISH)', 4.2); + $container->registerExtension($ext = new EnvExtension()); + $container->prependExtensionConfig('env_extension', $expected = [ + 'scalar_node' => '%env(default:parameter_int:FLOATISH)%', + ]); + + $this->doProcess($container); + $this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig())); + } + + public function testDefaultProcessorAndAnotherProcessorWithScalarNode() + { + $this->expectException(InvalidTypeException::class); + $this->expectExceptionMessageMatches('/^Invalid type for path "env_extension\.scalar_node"\. Expected one of "bool", "int", "float", "string", but got one of "int", "array"\.$/'); + + $container = new ContainerBuilder(); + $container->setParameter('parameter_int', 12134); + $container->setParameter('env(JSON)', '{ "foo": "bar" }'); + $container->registerExtension($ext = new EnvExtension()); + $container->prependExtensionConfig('env_extension', [ + 'scalar_node' => '%env(default:parameter_int:json:JSON)%', + ]); + + $this->doProcess($container); + } + public function testEnvsAreValidatedInConfigWithInvalidPlaceholder() { $this->expectException(InvalidTypeException::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 544303bbe859a..dc33ddc418c20 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -25,6 +25,7 @@ use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\Argument\RewindableGenerator; use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; +use Symfony\Component\DependencyInjection\Attribute\AsTaggedItem; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\PassConfig; @@ -34,6 +35,7 @@ use Symfony\Component\DependencyInjection\Exception\BadMethodCallException; use Symfony\Component\DependencyInjection\Exception\EnvNotFoundException; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; +use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException; use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; @@ -48,6 +50,7 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\DependencyInjection\Tests\Compiler\Foo; +use Symfony\Component\DependencyInjection\Tests\Compiler\MyCallable; use Symfony\Component\DependencyInjection\Tests\Compiler\SingleMethodInterface; use Symfony\Component\DependencyInjection\Tests\Compiler\Wither; use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass; @@ -530,6 +533,19 @@ public function testClosureProxy() $this->assertInstanceOf(Foo::class, $container->get('closure_proxy')->theMethod()); } + public function testClosureProxyWithStaticMethod() + { + $container = new ContainerBuilder(); + $container->register('closure_proxy', SingleMethodInterface::class) + ->setPublic('true') + ->setFactory(['Closure', 'fromCallable']) + ->setArguments([[MyCallable::class, 'theMethodImpl']]); + $container->compile(); + + $this->assertInstanceOf(SingleMethodInterface::class, $container->get('closure_proxy')); + $this->assertSame(124, $container->get('closure_proxy')->theMethod()); + } + public function testCreateServiceClass() { $builder = new ContainerBuilder(); @@ -829,6 +845,36 @@ public function testMergeThrowsExceptionForDuplicateAutomaticInstanceofDefinitio $container->merge($config); } + public function testMergeAttributeAutoconfiguration() + { + $container = new ContainerBuilder(); + $container->registerAttributeForAutoconfiguration(AsTaggedItem::class, $c1 = static function (Definition $definition) {}); + $config = new ContainerBuilder(); + $config->registerAttributeForAutoconfiguration(AsTaggedItem::class, $c2 = function (Definition $definition) {}); + + $container->merge($config); + $this->assertSame([AsTaggedItem::class => [$c1, $c2]], $container->getAttributeAutoconfigurators()); + } + + /** + * @group legacy + */ + public function testGetAutoconfiguredAttributes() + { + $container = new ContainerBuilder(); + $container->registerAttributeForAutoconfiguration(AsTaggedItem::class, $c = static function () {}); + + $this->expectUserDeprecationMessage('Since symfony/dependency-injection 7.3: The "Symfony\Component\DependencyInjection\ContainerBuilder::getAutoconfiguredAttributes()" method is deprecated, use "getAttributeAutoconfigurators()" instead.'); + $configurators = $container->getAutoconfiguredAttributes(); + $this->assertSame($c, $configurators[AsTaggedItem::class]); + + // Method call fails with more than one configurator for a given attribute + $container->registerAttributeForAutoconfiguration(AsTaggedItem::class, $c = static function () {}); + + $this->expectException(LogicException::class); + $container->getAutoconfiguredAttributes(); + } + public function testResolveEnvValues() { $_ENV['DUMMY_ENV_VAR'] = 'du%%y'; @@ -878,6 +924,7 @@ public function testCompileWithResolveEnv() $container->setParameter('bar', '%% %env(DUMMY_ENV_VAR)% %env(DUMMY_SERVER_VAR)% %env(HTTP_DUMMY_VAR)%'); $container->setParameter('foo', '%env(FOO)%'); $container->setParameter('baz', '%foo%'); + $container->setParameter('qux', '%%quux%%'); $container->setParameter('env(HTTP_DUMMY_VAR)', '123'); $container->register('teatime', 'stdClass') ->setProperty('foo', '%env(DUMMY_ENV_VAR)%') @@ -1062,20 +1109,18 @@ public function testMergeLogicException() $container->merge(new ContainerBuilder()); } - public function testfindTaggedServiceIds() + public function testFindTaggedServiceIds() { $builder = new ContainerBuilder(); - $builder - ->register('foo', 'Bar\FooClass') + $builder->register('foo', 'Bar\FooClass') + ->setAbstract(true) ->addTag('foo', ['foo' => 'foo']) ->addTag('bar', ['bar' => 'bar']) - ->addTag('foo', ['foofoo' => 'foofoo']) - ; - $builder - ->register('bar', 'Bar\FooClass') + ->addTag('foo', ['foofoo' => 'foofoo']); + $builder->register('bar', 'Bar\FooClass') ->addTag('foo') - ->addTag('container.excluded') - ; + ->addTag('container.excluded'); + $this->assertEquals([ 'foo' => [ ['foo' => 'foo'], @@ -1085,6 +1130,45 @@ public function testfindTaggedServiceIds() $this->assertEquals([], $builder->findTaggedServiceIds('foobar'), '->findTaggedServiceIds() returns an empty array if there is annotated services'); } + public function testFindTaggedServiceIdsThrowsWhenAbstract() + { + $builder = new ContainerBuilder(); + $builder->register('foo', 'Bar\FooClass') + ->setAbstract(true) + ->addTag('foo', ['foo' => 'foo']); + + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('The service "foo" tagged "foo" must not be abstract.'); + $builder->findTaggedServiceIds('foo', true); + } + + public function testFindTaggedResourceIds() + { + $builder = new ContainerBuilder(); + $builder->register('myservice', 'Bar\FooClass') + ->addTag('foo', ['foo' => 'foo']) + ->addTag('bar', ['bar' => 'bar']) + ->addTag('foo', ['foofoo' => 'foofoo']) + ->addResourceTag('container.excluded'); + + $expected = ['myservice' => [['foo' => 'foo'], ['foofoo' => 'foofoo']]]; + $this->assertSame($expected, $builder->findTaggedResourceIds('foo')); + $this->assertSame([], $builder->findTaggedResourceIds('foofoo')); + } + + public function testFindTaggedResourceIdsThrowsWhenNotExcluded() + { + $builder = new ContainerBuilder(); + $builder->register('myservice', 'Bar\FooClass') + ->addTag('foo', ['foo' => 'foo']) + ->addTag('bar', ['bar' => 'bar']) + ->addTag('foo', ['foofoo' => 'foofoo']); + + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('The resource "myservice" tagged "foo" is missing the "container.excluded" tag.'); + $builder->findTaggedResourceIds('foo'); + } + public function testFindUnusedTags() { $builder = new ContainerBuilder(); @@ -1113,7 +1197,7 @@ public function testAddObjectResource() $container->setResourceTracking(false); $container->addObjectResource(new \BarClass()); - $this->assertEmpty($container->getResources(), 'No resources get registered without resource tracking'); + $this->assertSame([], $container->getResources(), 'No resources get registered without resource tracking'); $container->setResourceTracking(true); $container->addObjectResource(new \BarClass()); @@ -1122,7 +1206,7 @@ public function testAddObjectResource() $this->assertCount(1, $resources); - /* @var FileResource $resource */ + /** @var FileResource $resource */ $resource = end($resources); $this->assertInstanceOf(FileResource::class, $resource); @@ -1136,7 +1220,7 @@ public function testGetReflectionClass() $container->setResourceTracking(false); $r1 = $container->getReflectionClass('BarClass'); - $this->assertEmpty($container->getResources(), 'No resources get registered without resource tracking'); + $this->assertSame([], $container->getResources(), 'No resources get registered without resource tracking'); $container->setResourceTracking(true); $r2 = $container->getReflectionClass('BarClass'); @@ -1176,7 +1260,7 @@ public function testCompilesClassDefinitionsOfLazyServices() { $container = new ContainerBuilder(); - $this->assertEmpty($container->getResources(), 'No resources get registered without resource tracking'); + $this->assertSame([], $container->getResources(), 'No resources get registered without resource tracking'); $container->register('foo', 'BarClass')->setPublic(true); $container->getDefinition('foo')->setLazy(true); @@ -1335,7 +1419,7 @@ public function testExtensionConfig() $container = new ContainerBuilder(); $configs = $container->getExtensionConfig('foo'); - $this->assertEmpty($configs); + $this->assertSame([], $configs); $first = ['foo' => 'bar']; $container->prependExtensionConfig('foo', $first); @@ -1882,8 +1966,12 @@ public function testLazyWither() $container->compile(); $wither = $container->get('wither'); + if (\PHP_VERSION_ID >= 80400) { + $this->assertTrue((new \ReflectionClass($wither))->isUninitializedLazyObject($wither)); + } else { + $this->assertTrue($wither->resetLazyObject()); + } $this->assertInstanceOf(Foo::class, $wither->foo); - $this->assertTrue($wither->resetLazyObject()); $this->assertInstanceOf(Wither::class, $wither->withFoo1($wither->foo)); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php index 3a7c3a98002ca..459e566d22661 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php @@ -258,6 +258,16 @@ public function testTags() ], $def->getTags(), '->getTags() returns all tags'); } + public function testAddResourceTag() + { + $def = new Definition('stdClass'); + $def->addResourceTag('foo', ['bar' => true]); + + $this->assertSame([['bar' => true]], $def->getTag('foo')); + $this->assertTrue($def->isAbstract()); + $this->assertSame([['source' => 'by tag "foo"']], $def->getTag('container.excluded')); + } + public function testSetArgument() { $def = new Definition('stdClass'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 5523c147e049b..f9302e818c3a7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -56,6 +56,8 @@ use Symfony\Component\DependencyInjection\Tests\Compiler\SingleMethodInterface; use Symfony\Component\DependencyInjection\Tests\Compiler\Wither; use Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition; +use Symfony\Component\DependencyInjection\Tests\Fixtures\DependencyContainer; +use Symfony\Component\DependencyInjection\Tests\Fixtures\DependencyContainerInterface; use Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithEnumAttribute; use Symfony\Component\DependencyInjection\Tests\Fixtures\FooUnitEnum; use Symfony\Component\DependencyInjection\Tests\Fixtures\FooWithAbstractArgument; @@ -338,7 +340,7 @@ public function testDumpAsFilesWithLazyFactoriesInlined() if ('\\' === \DIRECTORY_SEPARATOR) { $dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump); } - $this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services9_lazy_inlined_factories.txt', $dump); + $this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/'.(\PHP_VERSION_ID < 80400 ? 'legacy_' : '').'services9_lazy_inlined_factories.txt', $dump); } public function testServicesWithAnonymousFactories() @@ -792,7 +794,7 @@ public function testNonSharedLazy() 'inline_class_loader' => false, ]); $this->assertStringEqualsFile( - self::$fixturesPath.'/php/services_non_shared_lazy_public.php', + self::$fixturesPath.'/php/'.(\PHP_VERSION_ID < 80400 ? 'legacy_' : '').'services_non_shared_lazy_public.php', '\\' === \DIRECTORY_SEPARATOR ? str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump) : $dump ); eval('?>'.$dump); @@ -800,10 +802,18 @@ public function testNonSharedLazy() $container = new \Symfony_DI_PhpDumper_Service_Non_Shared_Lazy(); $foo1 = $container->get('foo'); - $this->assertTrue($foo1->resetLazyObject()); + if (\PHP_VERSION_ID >= 80400) { + $this->assertTrue((new \ReflectionClass($foo1))->isUninitializedLazyObject($foo1)); + } else { + $this->assertTrue($foo1->resetLazyObject()); + } $foo2 = $container->get('foo'); - $this->assertTrue($foo2->resetLazyObject()); + if (\PHP_VERSION_ID >= 80400) { + $this->assertTrue((new \ReflectionClass($foo2))->isUninitializedLazyObject($foo2)); + } else { + $this->assertTrue($foo2->resetLazyObject()); + } $this->assertNotSame($foo1, $foo2); } @@ -830,7 +840,7 @@ public function testNonSharedLazyAsFiles() $stringDump = print_r($dumps, true); $this->assertStringMatchesFormatFile( - self::$fixturesPath.'/php/services_non_shared_lazy_as_files.txt', + self::$fixturesPath.'/php/'.(\PHP_VERSION_ID < 80400 ? 'legacy_' : '').'services_non_shared_lazy_as_files.txt', '\\' === \DIRECTORY_SEPARATOR ? str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $stringDump) : $stringDump ); @@ -842,10 +852,18 @@ public function testNonSharedLazyAsFiles() $container = eval('?>'.$lastDump); $foo1 = $container->get('non_shared_foo'); - $this->assertTrue($foo1->resetLazyObject()); + if (\PHP_VERSION_ID >= 80400) { + $this->assertTrue((new \ReflectionClass($foo1))->isUninitializedLazyObject($foo1)); + } else { + $this->assertTrue($foo1->resetLazyObject()); + } $foo2 = $container->get('non_shared_foo'); - $this->assertTrue($foo2->resetLazyObject()); + if (\PHP_VERSION_ID >= 80400) { + $this->assertTrue((new \ReflectionClass($foo2))->isUninitializedLazyObject($foo2)); + } else { + $this->assertTrue($foo2->resetLazyObject()); + } $this->assertNotSame($foo1, $foo2); } @@ -867,7 +885,7 @@ public function testNonSharedLazyDefinitionReferences(bool $asGhostObject) $dumper->setProxyDumper(new \DummyProxyDumper()); } - $this->assertStringEqualsFile(self::$fixturesPath.'/php/services_non_shared_lazy'.($asGhostObject ? '_ghost' : '').'.php', $dumper->dump()); + $this->assertStringEqualsFile(self::$fixturesPath.'/php/'.(\PHP_VERSION_ID < 80400 ? 'legacy_' : '').'services_non_shared_lazy'.($asGhostObject ? '_ghost' : '').'.php', $dumper->dump()); } public function testNonSharedDuplicates() @@ -940,7 +958,7 @@ public function testDedupLazyProxy() $dumper = new PhpDumper($container); - $this->assertStringEqualsFile(self::$fixturesPath.'/php/services_dedup_lazy.php', $dumper->dump()); + $this->assertStringEqualsFile(self::$fixturesPath.'/php/'.(\PHP_VERSION_ID < 80400 ? 'legacy_' : '').'services_dedup_lazy.php', $dumper->dump()); } public function testLazyArgumentProvideGenerator() @@ -984,7 +1002,7 @@ public function testLazyArgumentProvideGenerator() } } - $this->assertEmpty(iterator_to_array($lazyContext->lazyEmptyValues)); + $this->assertSame([], iterator_to_array($lazyContext->lazyEmptyValues)); } public function testNormalizedId() @@ -1605,14 +1623,18 @@ public function testLazyWither() $container->compile(); $dumper = new PhpDumper($container); $dump = $dumper->dump(['class' => 'Symfony_DI_PhpDumper_Service_Wither_Lazy']); - $this->assertStringEqualsFile(self::$fixturesPath.'/php/services_wither_lazy.php', $dump); + $this->assertStringEqualsFile(self::$fixturesPath.'/php/'.(\PHP_VERSION_ID < 80400 ? 'legacy_' : '').'services_wither_lazy.php', $dump); eval('?>'.$dump); $container = new \Symfony_DI_PhpDumper_Service_Wither_Lazy(); $wither = $container->get('wither'); + if (\PHP_VERSION_ID >= 80400) { + $this->assertTrue((new \ReflectionClass($wither))->isUninitializedLazyObject($wither)); + } else { + $this->assertTrue($wither->resetLazyObject()); + } $this->assertInstanceOf(Foo::class, $wither->foo); - $this->assertTrue($wither->resetLazyObject()); } public function testLazyWitherNonShared() @@ -1630,18 +1652,26 @@ public function testLazyWitherNonShared() $container->compile(); $dumper = new PhpDumper($container); $dump = $dumper->dump(['class' => 'Symfony_DI_PhpDumper_Service_Wither_Lazy_Non_Shared']); - $this->assertStringEqualsFile(self::$fixturesPath.'/php/services_wither_lazy_non_shared.php', $dump); + $this->assertStringEqualsFile(self::$fixturesPath.'/php/'.(\PHP_VERSION_ID < 80400 ? 'legacy_' : '').'services_wither_lazy_non_shared.php', $dump); eval('?>'.$dump); $container = new \Symfony_DI_PhpDumper_Service_Wither_Lazy_Non_Shared(); $wither1 = $container->get('wither'); + if (\PHP_VERSION_ID >= 80400) { + $this->assertTrue((new \ReflectionClass($wither1))->isUninitializedLazyObject($wither1)); + } else { + $this->assertTrue($wither1->resetLazyObject()); + } $this->assertInstanceOf(Foo::class, $wither1->foo); - $this->assertTrue($wither1->resetLazyObject()); $wither2 = $container->get('wither'); + if (\PHP_VERSION_ID >= 80400) { + $this->assertTrue((new \ReflectionClass($wither2))->isUninitializedLazyObject($wither2)); + } else { + $this->assertTrue($wither2->resetLazyObject()); + } $this->assertInstanceOf(Foo::class, $wither2->foo); - $this->assertTrue($wither2->resetLazyObject()); $this->assertNotSame($wither1, $wither2); } @@ -1668,6 +1698,59 @@ public function testWitherWithStaticReturnType() $this->assertInstanceOf(Foo::class, $wither->foo); } + public function testCloningLazyGhostWithDependency() + { + $container = new ContainerBuilder(); + $container->register('dependency', \stdClass::class); + $container->register(DependencyContainer::class) + ->addArgument(new Reference('dependency')) + ->setLazy(true) + ->setPublic(true); + + $container->compile(); + $dumper = new PhpDumper($container); + $dump = $dumper->dump(['class' => 'Symfony_DI_PhpDumper_Service_CloningLazyGhostWithDependency']); + eval('?>'.$dump); + + $container = new \Symfony_DI_PhpDumper_Service_CloningLazyGhostWithDependency(); + + $bar = $container->get(DependencyContainer::class); + $this->assertInstanceOf(DependencyContainer::class, $bar); + + $first_clone = clone $bar; + $second_clone = clone $bar; + + $this->assertSame($first_clone->dependency, $second_clone->dependency); + } + + public function testCloningProxyWithDependency() + { + $container = new ContainerBuilder(); + $container->register('dependency', \stdClass::class); + $container->register(DependencyContainer::class) + ->addArgument(new Reference('dependency')) + ->setLazy(true) + ->addTag('proxy', [ + 'interface' => DependencyContainerInterface::class, + ]) + ->setPublic(true); + + $container->compile(); + $dumper = new PhpDumper($container); + $dump = $dumper->dump(['class' => 'Symfony_DI_PhpDumper_Service_CloningProxyWithDependency']); + eval('?>'.$dump); + + $container = new \Symfony_DI_PhpDumper_Service_CloningProxyWithDependency(); + + $bar = $container->get(DependencyContainer::class); + $this->assertInstanceOf(DependencyContainerInterface::class, $bar); + + $first_clone = clone $bar; + $second_clone = clone $bar; + + $this->assertSame($first_clone->getDependency(), $second_clone->getDependency()); + } + public function testCurrentFactoryInlining() { $container = new ContainerBuilder(); @@ -1794,7 +1877,7 @@ public function testClosureProxy() { $container = new ContainerBuilder(); $container->register('closure_proxy', SingleMethodInterface::class) - ->setPublic('true') + ->setPublic(true) ->setFactory(['Closure', 'fromCallable']) ->setArguments([[new Reference('foo'), 'cloneFoo']]) ->setLazy(true); @@ -1816,12 +1899,12 @@ public function testClosure() { $container = new ContainerBuilder(); $container->register('closure', 'Closure') - ->setPublic('true') + ->setPublic(true) ->setFactory(['Closure', 'fromCallable']) ->setArguments([new Reference('bar')]); $container->register('bar', 'stdClass'); $container->register('closure_of_service_closure', 'Closure') - ->setPublic('true') + ->setPublic(true) ->setFactory(['Closure', 'fromCallable']) ->setArguments([new ServiceClosureArgument(new Reference('bar2'))]); $container->register('bar2', 'stdClass'); @@ -1835,15 +1918,15 @@ public function testAutowireClosure() { $container = new ContainerBuilder(); $container->register('foo', Foo::class) - ->setPublic('true'); + ->setPublic(true); $container->register('my_callable', MyCallable::class) - ->setPublic('true'); + ->setPublic(true); $container->register('baz', \Closure::class) ->setFactory(['Closure', 'fromCallable']) ->setArguments(['var_dump']) - ->setPublic('true'); + ->setPublic(true); $container->register('bar', LazyClosureConsumer::class) - ->setPublic('true') + ->setPublic(true) ->setAutowired(true); $container->compile(); $dumper = new PhpDumper($container); @@ -1869,12 +1952,12 @@ public function testLazyClosure() { $container = new ContainerBuilder(); $container->register('closure1', 'Closure') - ->setPublic('true') + ->setPublic(true) ->setFactory(['Closure', 'fromCallable']) ->setLazy(true) ->setArguments([[new Reference('foo'), 'cloneFoo']]); $container->register('closure2', 'Closure') - ->setPublic('true') + ->setPublic(true) ->setFactory(['Closure', 'fromCallable']) ->setLazy(true) ->setArguments([[new Reference('foo_void'), '__invoke']]); @@ -1908,30 +1991,36 @@ public function testLazyAutowireAttribute() { $container = new ContainerBuilder(); $container->register('foo', Foo::class) - ->setPublic('true'); + ->setPublic(true); $container->setAlias(Foo::class, 'foo'); $container->register('bar', LazyServiceConsumer::class) - ->setPublic('true') + ->setPublic(true) ->setAutowired(true); $container->compile(); $dumper = new PhpDumper($container); - $this->assertStringEqualsFile(self::$fixturesPath.'/php/lazy_autowire_attribute.php', $dumper->dump(['class' => 'Symfony_DI_PhpDumper_Test_Lazy_Autowire_Attribute'])); + $this->assertStringEqualsFile(self::$fixturesPath.'/php/'.(\PHP_VERSION_ID < 80400 ? 'legacy_' : '').'lazy_autowire_attribute.php', $dumper->dump(['class' => 'Symfony_DI_PhpDumper_Test_Lazy_Autowire_Attribute'])); - require self::$fixturesPath.'/php/lazy_autowire_attribute.php'; + require self::$fixturesPath.'/php/'.(\PHP_VERSION_ID < 80400 ? 'legacy_' : '').'lazy_autowire_attribute.php'; $container = new \Symfony_DI_PhpDumper_Test_Lazy_Autowire_Attribute(); $this->assertInstanceOf(Foo::class, $container->get('bar')->foo); - $this->assertInstanceOf(LazyObjectInterface::class, $container->get('bar')->foo); - $this->assertSame($container->get('foo'), $container->get('bar')->foo->initializeLazyObject()); + if (\PHP_VERSION_ID >= 80400) { + $r = new \ReflectionClass(Foo::class); + $this->assertTrue($r->isUninitializedLazyObject($container->get('bar')->foo)); + $this->assertSame($container->get('foo'), $r->initializeLazyObject($container->get('bar')->foo)); + } else { + $this->assertInstanceOf(LazyObjectInterface::class, $container->get('bar')->foo); + $this->assertSame($container->get('foo'), $container->get('bar')->foo->initializeLazyObject()); + } } public function testLazyAutowireAttributeWithIntersection() { $container = new ContainerBuilder(); $container->register('foo', AAndIInterfaceConsumer::class) - ->setPublic('true') + ->setPublic(true) ->setAutowired(true); $container->compile(); @@ -1947,7 +2036,11 @@ public function testLazyAutowireAttributeWithIntersection() $dumper = new PhpDumper($container); - $this->assertStringEqualsFile(self::$fixturesPath.'/php/lazy_autowire_attribute_with_intersection.php', $dumper->dump()); + if (\PHP_VERSION_ID >= 80400) { + $this->assertStringEqualsFile(self::$fixturesPath.'/php/lazy_autowire_attribute_with_intersection.php', $dumper->dump()); + } else { + $this->assertStringEqualsFile(self::$fixturesPath.'/php/legacy_lazy_autowire_attribute_with_intersection.php', $dumper->dump()); + } } public function testCallableAdapterConsumer() @@ -1955,7 +2048,7 @@ public function testCallableAdapterConsumer() $container = new ContainerBuilder(); $container->register('foo', Foo::class); $container->register('bar', CallableAdapterConsumer::class) - ->setPublic('true') + ->setPublic(true) ->setAutowired(true); $container->compile(); $dumper = new PhpDumper($container); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php index f9ff3fff786a3..3a21d7aa9a9c5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php @@ -215,6 +215,26 @@ public function testDumpNonScalarTags() $this->assertEquals(file_get_contents(self::$fixturesPath.'/yaml/services_with_array_tags.yml'), $dumper->dump()); } + public function testDumpResolvedEnvPlaceholders() + { + $container = new ContainerBuilder(); + $container->setParameter('%env(PARAMETER_NAME)%', '%env(PARAMETER_VALUE)%'); + $container + ->register('service', '%env(SERVICE_CLASS)%') + ->setFile('%env(SERVICE_FILE)%') + ->addArgument('%env(SERVICE_ARGUMENT)%') + ->setProperty('%env(SERVICE_PROPERTY_NAME)%', '%env(SERVICE_PROPERTY_VALUE)%') + ->addMethodCall('%env(SERVICE_METHOD_NAME)%', ['%env(SERVICE_METHOD_ARGUMENT)%']) + ->setFactory('%env(SERVICE_FACTORY)%') + ->setConfigurator('%env(SERVICE_CONFIGURATOR)%') + ->setPublic(true) + ; + $container->compile(); + $dumper = new YamlDumper($container); + + $this->assertEquals(file_get_contents(self::$fixturesPath.'/yaml/container_with_env_placeholders.yml'), $dumper->dump()); + } + private function assertEqualYamlStructure(string $expected, string $yaml, string $message = '') { $parser = new Parser(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/AbstractSayClass.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/AbstractSayClass.php new file mode 100644 index 0000000000000..f59aa1bf4a8d6 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/AbstractSayClass.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Fixtures; + +abstract class AbstractSayClass +{ + abstract public function say(): string; +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/DependencyContainer.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/DependencyContainer.php new file mode 100644 index 0000000000000..5e222bdf060be --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/DependencyContainer.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Fixtures; + +class DependencyContainer implements DependencyContainerInterface +{ + public function __construct( + public mixed $dependency, + ) { + } + + public function getDependency(): mixed + { + return $this->dependency; + } +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/DependencyContainerInterface.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/DependencyContainerInterface.php new file mode 100644 index 0000000000000..ed109cad78dcd --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/DependencyContainerInterface.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Fixtures; + +interface DependencyContainerInterface +{ + public function getDependency(): mixed; +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/PrototypeAsAlias/WithAsAliasBothEnv.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/PrototypeAsAlias/WithAsAliasBothEnv.php new file mode 100644 index 0000000000000..252842be35ff2 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/PrototypeAsAlias/WithAsAliasBothEnv.php @@ -0,0 +1,10 @@ + 'foo'], constructor: 'create')] class StaticConstructorAutoconfigure diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/child.expected.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/child.expected.yml index 44dbbd571b788..97380f388ca2a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/child.expected.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/child.expected.yml @@ -11,7 +11,9 @@ services: - container.decorator: { id: bar, inner: b } file: file.php lazy: true - arguments: [!service { class: Class1 }] + arguments: ['@b'] + b: + class: Class1 bar: alias: foo public: true diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/from_callable.expected.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/from_callable.expected.yml index d4dbbbadd48bf..1ab1643af1b48 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/from_callable.expected.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/from_callable.expected.yml @@ -8,5 +8,7 @@ services: class: stdClass public: true lazy: true - arguments: [[!service { class: stdClass }, do]] + arguments: [['@bar', do]] factory: [Closure, fromCallable] + bar: + class: stdClass diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php index 7349cb1a076d8..9e07d0283e396 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php @@ -14,6 +14,7 @@ class Foo { public static int $counter = 0; + public int $foo = 0; #[Required] public function cloneFoo(?\stdClass $bar = null): static @@ -461,6 +462,11 @@ class MyCallable public function __invoke(): void { } + + public static function theMethodImpl(): int + { + return 124; + } } class MyInlineService diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo_lazy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo_lazy.php index 1caad4b2077d1..e150e09e4badf 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo_lazy.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo_lazy.php @@ -4,4 +4,5 @@ class FooLazyClass { + public int $foo = 0; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure_proxy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure_proxy.php index 2bef92604d3a9..eaf303c7d068c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure_proxy.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure_proxy.php @@ -55,6 +55,6 @@ protected function createProxy($class, \Closure $factory) */ protected static function getClosureProxyService($container, $lazyLoad = true) { - return $container->services['closure_proxy'] = new class(fn () => new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo()) extends \Symfony\Component\DependencyInjection\Argument\LazyClosure implements \Symfony\Component\DependencyInjection\Tests\Compiler\SingleMethodInterface { public function theMethod() { return $this->service->cloneFoo(...\func_get_args()); } }; + return $container->services['closure_proxy'] = new class(fn () => ($container->privates['foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo())) extends \Symfony\Component\DependencyInjection\Argument\LazyClosure implements \Symfony\Component\DependencyInjection\Tests\Compiler\SingleMethodInterface { public function theMethod() { return $this->service->cloneFoo(...\func_get_args()); } }; } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute.php index 4f596a2b90597..97388c0efe57e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute.php @@ -77,21 +77,9 @@ protected static function getFooService($container) protected static function getFoo2Service($container, $lazyLoad = true) { if (true === $lazyLoad) { - return $container->privates['.lazy.Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo'] = $container->createProxy('FooProxyCd8d23a', static fn () => \FooProxyCd8d23a::createLazyProxy(static fn () => self::getFoo2Service($container, false))); + return $container->privates['.lazy.Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo'] = new \ReflectionClass('Symfony\Component\DependencyInjection\Tests\Compiler\Foo')->newLazyProxy(static fn () => self::getFoo2Service($container, false)); } return ($container->services['foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo()); } } - -class FooProxyCd8d23a extends \Symfony\Component\DependencyInjection\Tests\Compiler\Foo implements \Symfony\Component\VarExporter\LazyObjectInterface -{ - use \Symfony\Component\VarExporter\LazyProxyTrait; - - private const LAZY_OBJECT_PROPERTY_SCOPES = []; -} - -// Help opcache.preload discover always-needed symbols -class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); -class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); -class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute_with_intersection.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute_with_intersection.php index fcf66ad12157b..15cab6e1d19de 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute_with_intersection.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_autowire_attribute_with_intersection.php @@ -74,21 +74,16 @@ protected static function get_Lazy_Foo_QFdMZVKService($container, $lazyLoad = tr class objectProxy1fd6daa implements \Symfony\Component\DependencyInjection\Tests\Compiler\AInterface, \Symfony\Component\DependencyInjection\Tests\Compiler\IInterface, \Symfony\Component\VarExporter\LazyObjectInterface { - use \Symfony\Component\VarExporter\LazyProxyTrait; + use \Symfony\Component\VarExporter\Internal\LazyDecoratorTrait; private const LAZY_OBJECT_PROPERTY_SCOPES = []; public function initializeLazyObject(): \Symfony\Component\DependencyInjection\Tests\Compiler\AInterface&\Symfony\Component\DependencyInjection\Tests\Compiler\IInterface { - if ($state = $this->lazyObjectState ?? null) { - return $state->realInstance ??= ($state->initializer)(); - } - - return $this; + return $this->lazyObjectState->realInstance; } } // Help opcache.preload discover always-needed symbols class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); -class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_closure.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_closure.php index 0af28f2650147..2bf27779df041 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_closure.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_closure.php @@ -57,7 +57,7 @@ protected function createProxy($class, \Closure $factory) */ protected static function getClosure1Service($container, $lazyLoad = true) { - return $container->services['closure1'] = (new class(fn () => new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo()) extends \Symfony\Component\DependencyInjection\Argument\LazyClosure { public function cloneFoo(?\stdClass $bar = null): \Symfony\Component\DependencyInjection\Tests\Compiler\Foo { return $this->service->cloneFoo(...\func_get_args()); } })->cloneFoo(...); + return $container->services['closure1'] = (new class(fn () => ($container->privates['foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo())) extends \Symfony\Component\DependencyInjection\Argument\LazyClosure { public function cloneFoo(?\stdClass $bar = null): \Symfony\Component\DependencyInjection\Tests\Compiler\Foo { return $this->service->cloneFoo(...\func_get_args()); } })->cloneFoo(...); } /** @@ -67,6 +67,6 @@ protected static function getClosure1Service($container, $lazyLoad = true) */ protected static function getClosure2Service($container, $lazyLoad = true) { - return $container->services['closure2'] = (new class(fn () => new \Symfony\Component\DependencyInjection\Tests\Compiler\FooVoid()) extends \Symfony\Component\DependencyInjection\Argument\LazyClosure { public function __invoke(string $name): void { $this->service->__invoke(...\func_get_args()); } })->__invoke(...); + return $container->services['closure2'] = (new class(fn () => ($container->privates['foo_void'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\FooVoid())) extends \Symfony\Component\DependencyInjection\Argument\LazyClosure { public function __invoke(string $name): void { $this->service->__invoke(...\func_get_args()); } })->__invoke(...); } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_lazy_autowire_attribute.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_lazy_autowire_attribute.php new file mode 100644 index 0000000000000..6cf1c86a52ade --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_lazy_autowire_attribute.php @@ -0,0 +1,99 @@ +services = $this->privates = []; + $this->methodMap = [ + 'bar' => 'getBarService', + 'foo' => 'getFooService', + ]; + + $this->aliases = []; + } + + public function compile(): void + { + throw new LogicException('You cannot compile a dumped container that was already compiled.'); + } + + public function isCompiled(): bool + { + return true; + } + + public function getRemovedIds(): array + { + return [ + 'Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo' => true, + ]; + } + + protected function createProxy($class, \Closure $factory) + { + return $factory(); + } + + /** + * Gets the public 'bar' shared autowired service. + * + * @return \Symfony\Component\DependencyInjection\Tests\Dumper\LazyServiceConsumer + */ + protected static function getBarService($container) + { + return $container->services['bar'] = new \Symfony\Component\DependencyInjection\Tests\Dumper\LazyServiceConsumer(($container->privates['.lazy.Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo'] ?? self::getFoo2Service($container))); + } + + /** + * Gets the public 'foo' shared service. + * + * @return \Symfony\Component\DependencyInjection\Tests\Compiler\Foo + */ + protected static function getFooService($container) + { + return $container->services['foo'] = new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo(); + } + + /** + * Gets the private '.lazy.Symfony\Component\DependencyInjection\Tests\Compiler\Foo' shared service. + * + * @return \Symfony\Component\DependencyInjection\Tests\Compiler\Foo + */ + protected static function getFoo2Service($container, $lazyLoad = true) + { + if (true === $lazyLoad) { + return $container->privates['.lazy.Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo'] = $container->createProxy('FooProxyCd8d23a', static fn () => \FooProxyCd8d23a::createLazyProxy(static fn () => self::getFoo2Service($container, false))); + } + + return ($container->services['foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo()); + } +} + +class FooProxyCd8d23a extends \Symfony\Component\DependencyInjection\Tests\Compiler\Foo implements \Symfony\Component\VarExporter\LazyObjectInterface +{ + use \Symfony\Component\VarExporter\LazyProxyTrait; + + private const LAZY_OBJECT_PROPERTY_SCOPES = [ + 'foo' => [parent::class, 'foo', null, 4], + ]; +} + +// Help opcache.preload discover always-needed symbols +class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_lazy_autowire_attribute_with_intersection.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_lazy_autowire_attribute_with_intersection.php new file mode 100644 index 0000000000000..fcf66ad12157b --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_lazy_autowire_attribute_with_intersection.php @@ -0,0 +1,94 @@ +services = $this->privates = []; + $this->methodMap = [ + 'foo' => 'getFooService', + ]; + + $this->aliases = []; + } + + public function compile(): void + { + throw new LogicException('You cannot compile a dumped container that was already compiled.'); + } + + public function isCompiled(): bool + { + return true; + } + + protected function createProxy($class, \Closure $factory) + { + return $factory(); + } + + /** + * Gets the public 'foo' shared autowired service. + * + * @return \Symfony\Component\DependencyInjection\Tests\Compiler\AAndIInterfaceConsumer + */ + protected static function getFooService($container) + { + $a = ($container->privates['.lazy.foo.qFdMZVK'] ?? self::get_Lazy_Foo_QFdMZVKService($container)); + + if (isset($container->services['foo'])) { + return $container->services['foo']; + } + + return $container->services['foo'] = new \Symfony\Component\DependencyInjection\Tests\Compiler\AAndIInterfaceConsumer($a); + } + + /** + * Gets the private '.lazy.foo.qFdMZVK' shared service. + * + * @return \object + */ + protected static function get_Lazy_Foo_QFdMZVKService($container, $lazyLoad = true) + { + if (true === $lazyLoad) { + return $container->privates['.lazy.foo.qFdMZVK'] = $container->createProxy('objectProxy1fd6daa', static fn () => \objectProxy1fd6daa::createLazyProxy(static fn () => self::get_Lazy_Foo_QFdMZVKService($container, false))); + } + + return ($container->services['foo'] ?? self::getFooService($container)); + } +} + +class objectProxy1fd6daa implements \Symfony\Component\DependencyInjection\Tests\Compiler\AInterface, \Symfony\Component\DependencyInjection\Tests\Compiler\IInterface, \Symfony\Component\VarExporter\LazyObjectInterface +{ + use \Symfony\Component\VarExporter\LazyProxyTrait; + + private const LAZY_OBJECT_PROPERTY_SCOPES = []; + + public function initializeLazyObject(): \Symfony\Component\DependencyInjection\Tests\Compiler\AInterface&\Symfony\Component\DependencyInjection\Tests\Compiler\IInterface + { + if ($state = $this->lazyObjectState ?? null) { + return $state->realInstance ??= ($state->initializer)(); + } + + return $this; + } +} + +// Help opcache.preload discover always-needed symbols +class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services9_lazy_inlined_factories.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services9_lazy_inlined_factories.txt new file mode 100644 index 0000000000000..f945fdd50069b --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services9_lazy_inlined_factories.txt @@ -0,0 +1,196 @@ +Array +( + [Container%s/proxy-classes.php] => targetDir.''.'/Fixtures/includes/foo.php'; + +class FooClassGhost1728205 extends \Bar\FooClass implements \Symfony\Component\VarExporter\LazyObjectInterface +%A + +if (!\class_exists('FooClassGhost1728205', false)) { + \class_alias(__NAMESPACE__.'\\FooClassGhost1728205', 'FooClassGhost1728205', false); +} + + [Container%s/ProjectServiceContainer.php] => targetDir = \dirname($containerDir); + $this->parameters = $this->getDefaultParameters(); + + $this->services = $this->privates = []; + $this->methodMap = [ + 'lazy_foo' => 'getLazyFooService', + ]; + + $this->aliases = []; + + $this->privates['service_container'] = static function ($container) { + include_once __DIR__.'/proxy-classes.php'; + }; + } + + public function compile(): void + { + throw new LogicException('You cannot compile a dumped container that was already compiled.'); + } + + public function isCompiled(): bool + { + return true; + } + + protected function createProxy($class, \Closure $factory) + { + return $factory(); + } + + /** + * Gets the public 'lazy_foo' shared service. + * + * @return \Bar\FooClass + */ + protected static function getLazyFooService($container, $lazyLoad = true) + { + if (true === $lazyLoad) { + return $container->services['lazy_foo'] = $container->createProxy('FooClassGhost1728205', static fn () => \FooClassGhost1728205::createLazyGhost(static fn ($proxy) => self::getLazyFooService($container, $proxy))); + } + + include_once $container->targetDir.''.'/Fixtures/includes/foo_lazy.php'; + + return ($lazyLoad->__construct(new \Bar\FooLazyClass()) && false ?: $lazyLoad); + } + + public function getParameter(string $name): array|bool|string|int|float|\UnitEnum|null + { + if (isset($this->buildParameters[$name])) { + return $this->buildParameters[$name]; + } + + if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) { + throw new ParameterNotFoundException($name); + } + + if (isset($this->loadedDynamicParameters[$name])) { + $value = $this->loadedDynamicParameters[$name] ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name); + } else { + $value = $this->parameters[$name]; + } + + return $value; + } + + public function hasParameter(string $name): bool + { + if (isset($this->buildParameters[$name])) { + return true; + } + + return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters); + } + + public function setParameter(string $name, $value): void + { + throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); + } + + public function getParameterBag(): ParameterBagInterface + { + if (!isset($this->parameterBag)) { + $parameters = $this->parameters; + foreach ($this->loadedDynamicParameters as $name => $loaded) { + $parameters[$name] = $loaded ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name); + } + foreach ($this->buildParameters as $name => $value) { + $parameters[$name] = $value; + } + $this->parameterBag = new FrozenParameterBag($parameters, []); + } + + return $this->parameterBag; + } + + private $loadedDynamicParameters = []; + private $dynamicParameters = []; + + private function getDynamicParameter(string $name) + { + throw new ParameterNotFoundException($name); + } + + protected function getDefaultParameters(): array + { + return [ + 'lazy_foo_class' => 'Bar\\FooClass', + 'container.dumper.inline_factories' => true, + 'container.dumper.inline_class_loader' => true, + ]; + } +} + + [ProjectServiceContainer.preload.php] => = 7.4 when preloading is desired + +use Symfony\Component\DependencyInjection\Dumper\Preloader; + +if (in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) { + return; +} + +require dirname(__DIR__, %d).'%svendor/autoload.php'; +(require __DIR__.'/ProjectServiceContainer.php')->set(\Container%s\ProjectServiceContainer::class, null); + +$classes = []; +$classes[] = 'Bar\FooClass'; +$classes[] = 'Bar\FooLazyClass'; +$classes[] = 'Symfony\Component\DependencyInjection\ContainerInterface'; + +$preloaded = Preloader::preload($classes); + + [ProjectServiceContainer.php] => '%s', + 'container.build_id' => '%s', + 'container.build_time' => 1563381341, + 'container.runtime_mode' => \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? 'web=0' : 'web=1', +], __DIR__.\DIRECTORY_SEPARATOR.'Container%s'); + +) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_dedup_lazy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_dedup_lazy.php new file mode 100644 index 0000000000000..60add492ba1cd --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_dedup_lazy.php @@ -0,0 +1,126 @@ +services = $this->privates = []; + $this->methodMap = [ + 'bar' => 'getBarService', + 'baz' => 'getBazService', + 'buz' => 'getBuzService', + 'foo' => 'getFooService', + ]; + + $this->aliases = []; + } + + public function compile(): void + { + throw new LogicException('You cannot compile a dumped container that was already compiled.'); + } + + public function isCompiled(): bool + { + return true; + } + + protected function createProxy($class, \Closure $factory) + { + return $factory(); + } + + /** + * Gets the public 'bar' shared service. + * + * @return \stdClass + */ + protected static function getBarService($container, $lazyLoad = true) + { + if (true === $lazyLoad) { + return $container->services['bar'] = $container->createProxy('stdClassGhostAa01f12', static fn () => \stdClassGhostAa01f12::createLazyGhost(static fn ($proxy) => self::getBarService($container, $proxy))); + } + + return $lazyLoad; + } + + /** + * Gets the public 'baz' shared service. + * + * @return \stdClass + */ + protected static function getBazService($container, $lazyLoad = true) + { + if (true === $lazyLoad) { + return $container->services['baz'] = $container->createProxy('stdClassProxyAa01f12', static fn () => \stdClassProxyAa01f12::createLazyProxy(static fn () => self::getBazService($container, false))); + } + + return \foo_bar(); + } + + /** + * Gets the public 'buz' shared service. + * + * @return \stdClass + */ + protected static function getBuzService($container, $lazyLoad = true) + { + if (true === $lazyLoad) { + return $container->services['buz'] = $container->createProxy('stdClassProxyAa01f12', static fn () => \stdClassProxyAa01f12::createLazyProxy(static fn () => self::getBuzService($container, false))); + } + + return \foo_bar(); + } + + /** + * Gets the public 'foo' shared service. + * + * @return \stdClass + */ + protected static function getFooService($container, $lazyLoad = true) + { + if (true === $lazyLoad) { + return $container->services['foo'] = $container->createProxy('stdClassGhostAa01f12', static fn () => \stdClassGhostAa01f12::createLazyGhost(static fn ($proxy) => self::getFooService($container, $proxy))); + } + + return $lazyLoad; + } +} + +class stdClassGhostAa01f12 extends \stdClass implements \Symfony\Component\VarExporter\LazyObjectInterface +{ + use \Symfony\Component\VarExporter\LazyGhostTrait; + + private const LAZY_OBJECT_PROPERTY_SCOPES = []; +} + +// Help opcache.preload discover always-needed symbols +class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); + +class stdClassProxyAa01f12 extends \stdClass implements \Symfony\Component\VarExporter\LazyObjectInterface +{ + use \Symfony\Component\VarExporter\LazyProxyTrait; + + private const LAZY_OBJECT_PROPERTY_SCOPES = []; +} + +// Help opcache.preload discover always-needed symbols +class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_non_shared_lazy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_non_shared_lazy.php new file mode 100644 index 0000000000000..f584bef6b97cc --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_non_shared_lazy.php @@ -0,0 +1,76 @@ +services = $this->privates = []; + $this->methodMap = [ + 'bar' => 'getBarService', + ]; + + $this->aliases = []; + } + + public function compile(): void + { + throw new LogicException('You cannot compile a dumped container that was already compiled.'); + } + + public function isCompiled(): bool + { + return true; + } + + public function getRemovedIds(): array + { + return [ + 'foo' => true, + ]; + } + + protected function createProxy($class, \Closure $factory) + { + return $factory(); + } + + /** + * Gets the public 'bar' shared service. + * + * @return \stdClass + */ + protected static function getBarService($container) + { + return $container->services['bar'] = new \stdClass((isset($container->factories['service_container']['foo']) ? $container->factories['service_container']['foo']($container) : self::getFooService($container))); + } + + /** + * Gets the private 'foo' service. + * + * @return \stdClass + */ + protected static function getFooService($container, $lazyLoad = true) + { + $container->factories['service_container']['foo'] ??= self::getFooService(...); + + // lazy factory for stdClass + + return new \stdClass(); + } +} + +// proxy code for stdClass diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_non_shared_lazy_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_non_shared_lazy_as_files.txt new file mode 100644 index 0000000000000..d52dd5a7b82ac --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_non_shared_lazy_as_files.txt @@ -0,0 +1,173 @@ +Array +( + [Container%s/getNonSharedFooService.php] => factories['non_shared_foo'] ??= fn () => self::do($container); + + if (true === $lazyLoad) { + return $container->createProxy('FooLazyClassGhost%s', static fn () => \FooLazyClassGhost%s::createLazyGhost(static fn ($proxy) => self::do($container, $proxy))); + } + + static $include = true; + + if ($include) { + include_once '%sfoo_lazy.php'; + + $include = false; + } + + return $lazyLoad; + } +} + + [Container%s/FooLazyClassGhost%s.php] => [parent::class, 'foo', null, 4], + ]; +} + +// Help opcache.preload discover always-needed symbols +class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); + +if (!\class_exists('FooLazyClassGhost%s', false)) { + \class_alias(__NAMESPACE__.'\\FooLazyClassGhost%s', 'FooLazyClassGhost%s', false); +} + + [Container%s/Symfony_DI_PhpDumper_Service_Non_Shared_Lazy_As_File.php] => services = $this->privates = []; + $this->fileMap = [ + 'non_shared_foo' => 'getNonSharedFooService', + ]; + + $this->aliases = []; + } + + public function compile(): void + { + throw new LogicException('You cannot compile a dumped container that was already compiled.'); + } + + public function isCompiled(): bool + { + return true; + } + + protected function load($file, $lazyLoad = true): mixed + { + if (class_exists($class = __NAMESPACE__.'\\'.$file, false)) { + return $class::do($this, $lazyLoad); + } + + if ('.' === $file[-4]) { + $class = substr($class, 0, -4); + } else { + $file .= '.php'; + } + + $service = require $this->containerDir.\DIRECTORY_SEPARATOR.$file; + + return class_exists($class, false) ? $class::do($this, $lazyLoad) : $service; + } + + protected function createProxy($class, \Closure $factory) + { + class_exists($class, false) || require __DIR__.'/'.$class.'.php'; + + return $factory(); + } +} + + [Symfony_DI_PhpDumper_Service_Non_Shared_Lazy_As_File.preload.php] => = 7.4 when preloading is desired + +use Symfony\Component\DependencyInjection\Dumper\Preloader; + +if (in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) { + return; +} + +require '%svendor/autoload.php'; +(require __DIR__.'/Symfony_DI_PhpDumper_Service_Non_Shared_Lazy_As_File.php')->set(\Container%s\Symfony_DI_PhpDumper_Service_Non_Shared_Lazy_As_File::class, null); +require __DIR__.'/Container%s/FooLazyClassGhost%s.php'; +require __DIR__.'/Container%s/getNonSharedFooService.php'; + +$classes = []; +$classes[] = 'Bar\FooLazyClass'; +$classes[] = 'Symfony\Component\DependencyInjection\ContainerInterface'; + +$preloaded = Preloader::preload($classes); + + [Symfony_DI_PhpDumper_Service_Non_Shared_Lazy_As_File.php] => '%s', + 'container.build_id' => '%s', + 'container.build_time' => %d, + 'container.runtime_mode' => \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? 'web=0' : 'web=1', +], __DIR__.\DIRECTORY_SEPARATOR.'Container%s'); + +) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_non_shared_lazy_ghost.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_non_shared_lazy_ghost.php new file mode 100644 index 0000000000000..b03463295309e --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_non_shared_lazy_ghost.php @@ -0,0 +1,88 @@ +services = $this->privates = []; + $this->methodMap = [ + 'bar' => 'getBarService', + ]; + + $this->aliases = []; + } + + public function compile(): void + { + throw new LogicException('You cannot compile a dumped container that was already compiled.'); + } + + public function isCompiled(): bool + { + return true; + } + + public function getRemovedIds(): array + { + return [ + 'foo' => true, + ]; + } + + protected function createProxy($class, \Closure $factory) + { + return $factory(); + } + + /** + * Gets the public 'bar' shared service. + * + * @return \stdClass + */ + protected static function getBarService($container) + { + return $container->services['bar'] = new \stdClass((isset($container->factories['service_container']['foo']) ? $container->factories['service_container']['foo']($container) : self::getFooService($container))); + } + + /** + * Gets the private 'foo' service. + * + * @return \stdClass + */ + protected static function getFooService($container, $lazyLoad = true) + { + $container->factories['service_container']['foo'] ??= self::getFooService(...); + + if (true === $lazyLoad) { + return $container->createProxy('stdClassGhostAa01f12', static fn () => \stdClassGhostAa01f12::createLazyGhost(static fn ($proxy) => self::getFooService($container, $proxy))); + } + + return $lazyLoad; + } +} + +class stdClassGhostAa01f12 extends \stdClass implements \Symfony\Component\VarExporter\LazyObjectInterface +{ + use \Symfony\Component\VarExporter\LazyGhostTrait; + + private const LAZY_OBJECT_PROPERTY_SCOPES = []; +} + +// Help opcache.preload discover always-needed symbols +class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_non_shared_lazy_public.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_non_shared_lazy_public.php new file mode 100644 index 0000000000000..0841cf192ef59 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_non_shared_lazy_public.php @@ -0,0 +1,81 @@ +services = $this->privates = []; + $this->methodMap = [ + 'foo' => 'getFooService', + ]; + + $this->aliases = []; + } + + public function compile(): void + { + throw new LogicException('You cannot compile a dumped container that was already compiled.'); + } + + public function isCompiled(): bool + { + return true; + } + + protected function createProxy($class, \Closure $factory) + { + return $factory(); + } + + /** + * Gets the public 'foo' service. + * + * @return \Bar\FooLazyClass + */ + protected static function getFooService($container, $lazyLoad = true) + { + $container->factories['foo'] ??= fn () => self::getFooService($container); + + if (true === $lazyLoad) { + return $container->createProxy('FooLazyClassGhost82ad1a4', static fn () => \FooLazyClassGhost82ad1a4::createLazyGhost(static fn ($proxy) => self::getFooService($container, $proxy))); + } + + static $include = true; + + if ($include) { + include_once __DIR__.'/Fixtures/includes/foo_lazy.php'; + + $include = false; + } + + return $lazyLoad; + } +} + +class FooLazyClassGhost82ad1a4 extends \Bar\FooLazyClass implements \Symfony\Component\VarExporter\LazyObjectInterface +{ + use \Symfony\Component\VarExporter\LazyGhostTrait; + + private const LAZY_OBJECT_PROPERTY_SCOPES = [ + 'foo' => [parent::class, 'foo', null, 4], + ]; +} + +// Help opcache.preload discover always-needed symbols +class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_wither_lazy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_wither_lazy.php new file mode 100644 index 0000000000000..b9e9164573672 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_wither_lazy.php @@ -0,0 +1,86 @@ +services = $this->privates = []; + $this->methodMap = [ + 'wither' => 'getWitherService', + ]; + + $this->aliases = []; + } + + public function compile(): void + { + throw new LogicException('You cannot compile a dumped container that was already compiled.'); + } + + public function isCompiled(): bool + { + return true; + } + + public function getRemovedIds(): array + { + return [ + 'Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo' => true, + ]; + } + + protected function createProxy($class, \Closure $factory) + { + return $factory(); + } + + /** + * Gets the public 'wither' shared autowired service. + * + * @return \Symfony\Component\DependencyInjection\Tests\Compiler\Wither + */ + protected static function getWitherService($container, $lazyLoad = true) + { + if (true === $lazyLoad) { + return $container->services['wither'] = $container->createProxy('WitherProxy1991f2a', static fn () => \WitherProxy1991f2a::createLazyProxy(static fn () => self::getWitherService($container, false))); + } + + $instance = new \Symfony\Component\DependencyInjection\Tests\Compiler\Wither(); + + $a = ($container->privates['Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo()); + + $instance = $instance->withFoo1($a); + $instance = $instance->withFoo2($a); + $instance->setFoo($a); + + return $instance; + } +} + +class WitherProxy1991f2a extends \Symfony\Component\DependencyInjection\Tests\Compiler\Wither implements \Symfony\Component\VarExporter\LazyObjectInterface +{ + use \Symfony\Component\VarExporter\LazyProxyTrait; + + private const LAZY_OBJECT_PROPERTY_SCOPES = [ + 'foo' => [parent::class, 'foo', null, 4], + ]; +} + +// Help opcache.preload discover always-needed symbols +class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_wither_lazy_non_shared.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_wither_lazy_non_shared.php new file mode 100644 index 0000000000000..d70588f655329 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/legacy_services_wither_lazy_non_shared.php @@ -0,0 +1,88 @@ +services = $this->privates = []; + $this->methodMap = [ + 'wither' => 'getWitherService', + ]; + + $this->aliases = []; + } + + public function compile(): void + { + throw new LogicException('You cannot compile a dumped container that was already compiled.'); + } + + public function isCompiled(): bool + { + return true; + } + + public function getRemovedIds(): array + { + return [ + 'Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo' => true, + ]; + } + + protected function createProxy($class, \Closure $factory) + { + return $factory(); + } + + /** + * Gets the public 'wither' autowired service. + * + * @return \Symfony\Component\DependencyInjection\Tests\Compiler\Wither + */ + protected static function getWitherService($container, $lazyLoad = true) + { + $container->factories['wither'] ??= fn () => self::getWitherService($container); + + if (true === $lazyLoad) { + return $container->createProxy('WitherProxyE94fdba', static fn () => \WitherProxyE94fdba::createLazyProxy(static fn () => self::getWitherService($container, false))); + } + + $instance = new \Symfony\Component\DependencyInjection\Tests\Compiler\Wither(); + + $a = ($container->privates['Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo()); + + $instance = $instance->withFoo1($a); + $instance = $instance->withFoo2($a); + $instance->setFoo($a); + + return $instance; + } +} + +class WitherProxyE94fdba extends \Symfony\Component\DependencyInjection\Tests\Compiler\Wither implements \Symfony\Component\VarExporter\LazyObjectInterface +{ + use \Symfony\Component\VarExporter\LazyProxyTrait; + + private const LAZY_OBJECT_PROPERTY_SCOPES = [ + 'foo' => [parent::class, 'foo', null, 4], + ]; +} + +// Help opcache.preload discover always-needed symbols +class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); +class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt index f945fdd50069b..9e6a3865f3605 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt @@ -1,18 +1,5 @@ Array ( - [Container%s/proxy-classes.php] => targetDir.''.'/Fixtures/includes/foo.php'; - -class FooClassGhost1728205 extends \Bar\FooClass implements \Symfony\Component\VarExporter\LazyObjectInterface -%A - -if (!\class_exists('FooClassGhost1728205', false)) { - \class_alias(__NAMESPACE__.'\\FooClassGhost1728205', 'FooClassGhost1728205', false); -} - [Container%s/ProjectServiceContainer.php] => aliases = []; - - $this->privates['service_container'] = static function ($container) { - include_once __DIR__.'/proxy-classes.php'; - }; } public function compile(): void @@ -74,9 +57,10 @@ class ProjectServiceContainer extends Container protected static function getLazyFooService($container, $lazyLoad = true) { if (true === $lazyLoad) { - return $container->services['lazy_foo'] = $container->createProxy('FooClassGhost1728205', static fn () => \FooClassGhost1728205::createLazyGhost(static fn ($proxy) => self::getLazyFooService($container, $proxy))); + return $container->services['lazy_foo'] = new \ReflectionClass('Bar\FooClass')->newLazyGhost(static function ($proxy) use ($container) { self::getLazyFooService($container, $proxy); }); } + include_once $container->targetDir.''.'/Fixtures/includes/foo.php'; include_once $container->targetDir.''.'/Fixtures/includes/foo_lazy.php'; return ($lazyLoad->__construct(new \Bar\FooLazyClass()) && false ?: $lazyLoad); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php index 0a9c519c8e69c..0c234ac3934c3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php @@ -373,15 +373,13 @@ protected static function getManager2Service($container) */ protected static function getManager3Service($container, $lazyLoad = true) { - $a = ($container->services['listener3'] ?? self::getListener3Service($container)); + $a = ($container->privates['connection3'] ?? self::getConnection3Service($container)); if (isset($container->services['manager3'])) { return $container->services['manager3']; } - $b = new \stdClass(); - $b->listener = [$a]; - return $container->services['manager3'] = new \stdClass($b); + return $container->services['manager3'] = new \stdClass($a); } /** @@ -481,6 +479,34 @@ protected static function getBar6Service($container) return $container->privates['bar6'] = new \stdClass($a); } + /** + * Gets the private 'connection3' shared service. + * + * @return \stdClass + */ + protected static function getConnection3Service($container) + { + $container->privates['connection3'] = $instance = new \stdClass(); + + $instance->listener = [($container->services['listener3'] ?? self::getListener3Service($container))]; + + return $instance; + } + + /** + * Gets the private 'connection4' shared service. + * + * @return \stdClass + */ + protected static function getConnection4Service($container) + { + $container->privates['connection4'] = $instance = new \stdClass(); + + $instance->listener = [($container->services['listener4'] ?? self::getListener4Service($container))]; + + return $instance; + } + /** * Gets the private 'doctrine.listener' shared service. * @@ -572,13 +598,13 @@ protected static function getMailerInline_TransportFactory_AmazonService($contai */ protected static function getManager4Service($container, $lazyLoad = true) { - $a = new \stdClass(); + $a = ($container->privates['connection4'] ?? self::getConnection4Service($container)); - $container->privates['manager4'] = $instance = new \stdClass($a); - - $a->listener = [($container->services['listener4'] ?? self::getListener4Service($container))]; + if (isset($container->privates['manager4'])) { + return $container->privates['manager4']; + } - return $instance; + return $container->privates['manager4'] = new \stdClass($a); } /** diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php index 2250e860264dc..ae283e556a0da 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php @@ -259,7 +259,7 @@ protected static function getDispatcher2Service($container, $lazyLoad = true) { $container->services['dispatcher2'] = $instance = new \stdClass(); - $instance->subscriber2 = new \stdClass(($container->services['manager2'] ?? self::getManager2Service($container))); + $instance->subscriber2 = ($container->privates['subscriber2'] ?? self::getSubscriber2Service($container)); return $instance; } @@ -820,4 +820,20 @@ protected static function getManager4Service($container, $lazyLoad = true) return $container->privates['manager4'] = new \stdClass($a); } + + /** + * Gets the private 'subscriber2' shared service. + * + * @return \stdClass + */ + protected static function getSubscriber2Service($container) + { + $a = ($container->services['manager2'] ?? self::getManager2Service($container)); + + if (isset($container->privates['subscriber2'])) { + return $container->privates['subscriber2']; + } + + return $container->privates['subscriber2'] = new \stdClass($a); + } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy.php index 60add492ba1cd..2c6142d0e73d5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy.php @@ -52,7 +52,7 @@ protected function createProxy($class, \Closure $factory) protected static function getBarService($container, $lazyLoad = true) { if (true === $lazyLoad) { - return $container->services['bar'] = $container->createProxy('stdClassGhostAa01f12', static fn () => \stdClassGhostAa01f12::createLazyGhost(static fn ($proxy) => self::getBarService($container, $proxy))); + return $container->services['bar'] = new \ReflectionClass('stdClass')->newLazyGhost(static function ($proxy) use ($container) { self::getBarService($container, $proxy); }); } return $lazyLoad; @@ -94,28 +94,16 @@ protected static function getBuzService($container, $lazyLoad = true) protected static function getFooService($container, $lazyLoad = true) { if (true === $lazyLoad) { - return $container->services['foo'] = $container->createProxy('stdClassGhostAa01f12', static fn () => \stdClassGhostAa01f12::createLazyGhost(static fn ($proxy) => self::getFooService($container, $proxy))); + return $container->services['foo'] = new \ReflectionClass('stdClass')->newLazyGhost(static function ($proxy) use ($container) { self::getFooService($container, $proxy); }); } return $lazyLoad; } } -class stdClassGhostAa01f12 extends \stdClass implements \Symfony\Component\VarExporter\LazyObjectInterface -{ - use \Symfony\Component\VarExporter\LazyGhostTrait; - - private const LAZY_OBJECT_PROPERTY_SCOPES = []; -} - -// Help opcache.preload discover always-needed symbols -class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); -class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); -class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); - class stdClassProxyAa01f12 extends \stdClass implements \Symfony\Component\VarExporter\LazyObjectInterface { - use \Symfony\Component\VarExporter\LazyProxyTrait; + use \Symfony\Component\VarExporter\Internal\LazyDecoratorTrait; private const LAZY_OBJECT_PROPERTY_SCOPES = []; } @@ -123,4 +111,3 @@ class stdClassProxyAa01f12 extends \stdClass implements \Symfony\Component\VarEx // Help opcache.preload discover always-needed symbols class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); -class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt index 488895d7c1b6e..69a47220cba88 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt @@ -23,7 +23,7 @@ class getNonSharedFooService extends Symfony_DI_PhpDumper_Service_Non_Shared_Laz $container->factories['non_shared_foo'] ??= fn () => self::do($container); if (true === $lazyLoad) { - return $container->createProxy('FooLazyClassGhost%s', static fn () => \FooLazyClassGhost%s::createLazyGhost(static fn ($proxy) => self::do($container, $proxy))); + return new \ReflectionClass('Bar\FooLazyClass')->newLazyGhost(static function ($proxy) use ($container) { self::do($container, $proxy); }); } static $include = true; @@ -38,26 +38,6 @@ class getNonSharedFooService extends Symfony_DI_PhpDumper_Service_Non_Shared_Laz } } - [Container%s/FooLazyClassGhost%s.php] => set(\Container%s\Symfony_DI_PhpDumper_Service_Non_Shared_Lazy_As_File::class, null); -require __DIR__.'/Container%s/FooLazyClassGhost%s.php'; require __DIR__.'/Container%s/getNonSharedFooService.php'; $classes = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_ghost.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_ghost.php index b03463295309e..281baf61514b2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_ghost.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_ghost.php @@ -68,21 +68,9 @@ protected static function getFooService($container, $lazyLoad = true) $container->factories['service_container']['foo'] ??= self::getFooService(...); if (true === $lazyLoad) { - return $container->createProxy('stdClassGhostAa01f12', static fn () => \stdClassGhostAa01f12::createLazyGhost(static fn ($proxy) => self::getFooService($container, $proxy))); + return new \ReflectionClass('stdClass')->newLazyGhost(static function ($proxy) use ($container) { self::getFooService($container, $proxy); }); } return $lazyLoad; } } - -class stdClassGhostAa01f12 extends \stdClass implements \Symfony\Component\VarExporter\LazyObjectInterface -{ - use \Symfony\Component\VarExporter\LazyGhostTrait; - - private const LAZY_OBJECT_PROPERTY_SCOPES = []; -} - -// Help opcache.preload discover always-needed symbols -class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); -class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); -class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_public.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_public.php index 7f870f886abcb..93b7ee3ed685b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_public.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_public.php @@ -51,7 +51,7 @@ protected static function getFooService($container, $lazyLoad = true) $container->factories['foo'] ??= fn () => self::getFooService($container); if (true === $lazyLoad) { - return $container->createProxy('FooLazyClassGhost82ad1a4', static fn () => \FooLazyClassGhost82ad1a4::createLazyGhost(static fn ($proxy) => self::getFooService($container, $proxy))); + return new \ReflectionClass('Bar\FooLazyClass')->newLazyGhost(static function ($proxy) use ($container) { self::getFooService($container, $proxy); }); } static $include = true; @@ -65,15 +65,3 @@ protected static function getFooService($container, $lazyLoad = true) return $lazyLoad; } } - -class FooLazyClassGhost82ad1a4 extends \Bar\FooLazyClass implements \Symfony\Component\VarExporter\LazyObjectInterface -{ - use \Symfony\Component\VarExporter\LazyGhostTrait; - - private const LAZY_OBJECT_PROPERTY_SCOPES = []; -} - -// Help opcache.preload discover always-needed symbols -class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); -class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); -class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy.php index b2940c88569f4..76031f1cae33a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy.php @@ -56,12 +56,12 @@ protected function createProxy($class, \Closure $factory) protected static function getWitherService($container, $lazyLoad = true) { if (true === $lazyLoad) { - return $container->services['wither'] = $container->createProxy('WitherProxy1991f2a', static fn () => \WitherProxy1991f2a::createLazyProxy(static fn () => self::getWitherService($container, false))); + return $container->services['wither'] = new \ReflectionClass('Symfony\Component\DependencyInjection\Tests\Compiler\Wither')->newLazyProxy(static fn () => self::getWitherService($container, false)); } $instance = new \Symfony\Component\DependencyInjection\Tests\Compiler\Wither(); - $a = new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo(); + $a = ($container->privates['Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo()); $instance = $instance->withFoo1($a); $instance = $instance->withFoo2($a); @@ -70,17 +70,3 @@ protected static function getWitherService($container, $lazyLoad = true) return $instance; } } - -class WitherProxy1991f2a extends \Symfony\Component\DependencyInjection\Tests\Compiler\Wither implements \Symfony\Component\VarExporter\LazyObjectInterface -{ - use \Symfony\Component\VarExporter\LazyProxyTrait; - - private const LAZY_OBJECT_PROPERTY_SCOPES = [ - 'foo' => [parent::class, 'foo', null], - ]; -} - -// Help opcache.preload discover always-needed symbols -class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); -class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); -class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy_non_shared.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy_non_shared.php index 0df7e0c98e274..640955a7e555b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy_non_shared.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy_non_shared.php @@ -58,7 +58,7 @@ protected static function getWitherService($container, $lazyLoad = true) $container->factories['wither'] ??= fn () => self::getWitherService($container); if (true === $lazyLoad) { - return $container->createProxy('WitherProxyE94fdba', static fn () => \WitherProxyE94fdba::createLazyProxy(static fn () => self::getWitherService($container, false))); + return new \ReflectionClass('Symfony\Component\DependencyInjection\Tests\Compiler\Wither')->newLazyProxy(static fn () => self::getWitherService($container, false)); } $instance = new \Symfony\Component\DependencyInjection\Tests\Compiler\Wither(); @@ -72,17 +72,3 @@ protected static function getWitherService($container, $lazyLoad = true) return $instance; } } - -class WitherProxyE94fdba extends \Symfony\Component\DependencyInjection\Tests\Compiler\Wither implements \Symfony\Component\VarExporter\LazyObjectInterface -{ - use \Symfony\Component\VarExporter\LazyProxyTrait; - - private const LAZY_OBJECT_PROPERTY_SCOPES = [ - 'foo' => [parent::class, 'foo', null], - ]; -} - -// Help opcache.preload discover always-needed symbols -class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); -class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); -class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/container_with_env_placeholders.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/container_with_env_placeholders.yml new file mode 100644 index 0000000000000..46c91130faecd --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/container_with_env_placeholders.yml @@ -0,0 +1,19 @@ +parameters: + '%env(PARAMETER_NAME)%': '%env(PARAMETER_VALUE)%' + +services: + service_container: + class: Symfony\Component\DependencyInjection\ContainerInterface + public: true + synthetic: true + service: + class: '%env(SERVICE_CLASS)%' + public: true + file: '%env(SERVICE_FILE)%' + arguments: ['%env(SERVICE_ARGUMENT)%'] + properties: { '%env(SERVICE_PROPERTY_NAME)%': '%env(SERVICE_PROPERTY_VALUE)%' } + calls: + - ['%env(SERVICE_METHOD_NAME)%', ['%env(SERVICE_METHOD_ARGUMENT)%']] + + factory: '%env(SERVICE_FACTORY)%' + configurator: '%env(SERVICE_CONFIGURATOR)%' diff --git a/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/LazyServiceInstantiatorTest.php b/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/LazyServiceInstantiatorTest.php new file mode 100644 index 0000000000000..359b9824bd270 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/LazyServiceInstantiatorTest.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\LazyProxy\Instantiator; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\LazyServiceInstantiator; +use Symfony\Component\DependencyInjection\Tests\Fixtures\AbstractSayClass; + +class LazyServiceInstantiatorTest extends TestCase +{ + public function testInstantiateAbstractClassProxy() + { + $instantiator = new LazyServiceInstantiator(); + $instance = new class extends AbstractSayClass { + public int $calls = 0; + + public function say(): string + { + ++$this->calls; + + return 'Hello from the abstract class!'; + } + }; + + $definition = (new Definition(AbstractSayClass::class)) + ->setLazy(true); + + $proxy = $instantiator->instantiateProxy(new Container(), $definition, 'foo', fn () => $instance); + + $this->assertSame(0, $instance->calls); + $this->assertSame('Hello from the abstract class!', $proxy->say()); + $this->assertSame(1, $instance->calls); + } +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/PhpDumper/LazyServiceDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/PhpDumper/LazyServiceDumperTest.php index 467972a882c78..1d5e9b6bf2dcf 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/PhpDumper/LazyServiceDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/PhpDumper/LazyServiceDumperTest.php @@ -16,6 +16,7 @@ use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\LazyServiceDumper; +use Symfony\Component\DependencyInjection\Tests\Fixtures\AbstractSayClass; use Symfony\Component\DependencyInjection\Tests\Fixtures\ReadOnlyClass; class LazyServiceDumperTest extends TestCase @@ -40,6 +41,16 @@ public function testFinalClassInterface() $this->assertStringContainsString('function get(', $dumper->getProxyCode($definition)); } + public function testAbstractClass() + { + $dumper = new LazyServiceDumper(); + $definition = (new Definition(AbstractSayClass::class)) + ->setLazy(true); + + $this->assertTrue($dumper->isProxyCandidate($definition)); + $this->assertNotSame(AbstractSayClass::class, $dumper->getProxyClass($definition, false)); + } + public function testInvalidClass() { $dumper = new LazyServiceDumper(); @@ -63,7 +74,7 @@ public function testReadonlyClass() $definition = (new Definition(ReadOnlyClass::class))->setLazy(true); $this->assertTrue($dumper->isProxyCandidate($definition)); - $this->assertStringContainsString('readonly class ReadOnlyClassGhost', $dumper->getProxyCode($definition)); + $this->assertStringContainsString(\PHP_VERSION_ID >= 80400 ? '' : 'readonly class ReadOnlyClassGhost', $dumper->getProxyCode($definition)); } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php index a43b4c5a1a05b..0ad1b363cf6bf 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php @@ -39,9 +39,12 @@ use Symfony\Component\DependencyInjection\Tests\Fixtures\PrototypeAsAlias\AliasBarInterface; use Symfony\Component\DependencyInjection\Tests\Fixtures\PrototypeAsAlias\AliasFooInterface; use Symfony\Component\DependencyInjection\Tests\Fixtures\PrototypeAsAlias\WithAsAlias; +use Symfony\Component\DependencyInjection\Tests\Fixtures\PrototypeAsAlias\WithAsAliasBothEnv; +use Symfony\Component\DependencyInjection\Tests\Fixtures\PrototypeAsAlias\WithAsAliasDevEnv; use Symfony\Component\DependencyInjection\Tests\Fixtures\PrototypeAsAlias\WithAsAliasIdMultipleInterface; use Symfony\Component\DependencyInjection\Tests\Fixtures\PrototypeAsAlias\WithAsAliasInterface; use Symfony\Component\DependencyInjection\Tests\Fixtures\PrototypeAsAlias\WithAsAliasMultiple; +use Symfony\Component\DependencyInjection\Tests\Fixtures\PrototypeAsAlias\WithAsAliasProdEnv; use Symfony\Component\DependencyInjection\Tests\Fixtures\Utils\NotAService; class FileLoaderTest extends TestCase @@ -349,10 +352,10 @@ public function testRegisterThrowsWithBothWhenAndNotWhenAttribute() /** * @dataProvider provideResourcesWithAsAliasAttributes */ - public function testRegisterClassesWithAsAlias(string $resource, array $expectedAliases) + public function testRegisterClassesWithAsAlias(string $resource, array $expectedAliases, ?string $env = null) { $container = new ContainerBuilder(); - $loader = new TestFileLoader($container, new FileLocator(self::$fixturesPath.'/Fixtures')); + $loader = new TestFileLoader($container, new FileLocator(self::$fixturesPath.'/Fixtures'), $env); $loader->registerClasses( (new Definition())->setAutoconfigured(true), 'Symfony\Component\DependencyInjection\Tests\Fixtures\PrototypeAsAlias\\', @@ -374,6 +377,15 @@ public static function provideResourcesWithAsAliasAttributes(): iterable AliasBarInterface::class => new Alias(WithAsAliasIdMultipleInterface::class), AliasFooInterface::class => new Alias(WithAsAliasIdMultipleInterface::class), ]]; + yield 'Dev-env specific' => ['PrototypeAsAlias/WithAsAlias*Env.php', [ + AliasFooInterface::class => new Alias(WithAsAliasDevEnv::class), + AliasBarInterface::class => new Alias(WithAsAliasBothEnv::class), + ], 'dev']; + yield 'Prod-env specific' => ['PrototypeAsAlias/WithAsAlias*Env.php', [ + AliasFooInterface::class => new Alias(WithAsAliasProdEnv::class), + AliasBarInterface::class => new Alias(WithAsAliasBothEnv::class), + ], 'prod']; + yield 'Test-env specific' => ['PrototypeAsAlias/WithAsAlias*Env.php', [], 'test']; } /** diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 97866064f0fa3..54900e4c3e146 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -850,7 +850,7 @@ public function testAnonymousServicesInInstanceof() $anonymous = $container->getDefinition((string) $args['foo']); $this->assertEquals('Anonymous', $anonymous->getClass()); $this->assertFalse($anonymous->isPublic()); - $this->assertEmpty($anonymous->getInstanceofConditionals()); + $this->assertSame([], $anonymous->getInstanceofConditionals()); $this->assertFalse($container->has('Bar')); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php index ee0af9ff37dfc..b6779b450743c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php @@ -66,7 +66,7 @@ public function testMergeWhereFirstBagIsEmptyWillWork() // initialize placeholder only in second bag $secondBag->get($parameter); - $this->assertEmpty($firstBag->getEnvPlaceholders()); + $this->assertSame([], $firstBag->getEnvPlaceholders()); $firstBag->mergeEnvPlaceholders($secondBag); $mergedPlaceholders = $firstBag->getEnvPlaceholders(); diff --git a/src/Symfony/Component/DependencyInjection/composer.json b/src/Symfony/Component/DependencyInjection/composer.json index b5fda9bdeb990..460751088f451 100644 --- a/src/Symfony/Component/DependencyInjection/composer.json +++ b/src/Symfony/Component/DependencyInjection/composer.json @@ -20,7 +20,7 @@ "psr/container": "^1.1|^2.0", "symfony/deprecation-contracts": "^2.5|^3", "symfony/service-contracts": "^3.5", - "symfony/var-exporter": "^6.4|^7.0" + "symfony/var-exporter": "^6.4.20|^7.2.5" }, "require-dev": { "symfony/yaml": "^6.4|^7.0", diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 23da2edc43867..7550da83d4fdb 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -411,7 +411,7 @@ public function closest(string $selector): ?self $domNode = $this->getNode(0); - while (\XML_ELEMENT_NODE === $domNode->nodeType) { + while (null !== $domNode && \XML_ELEMENT_NODE === $domNode->nodeType) { $node = $this->createSubCrawler($domNode); if ($node->matches($selector)) { return $node; @@ -747,12 +747,12 @@ public function selectImage(string $value): static } /** - * Selects a button by name or alt value for images. + * Selects a button by its text content, id, value, name or alt attribute. */ public function selectButton(string $value): static { return $this->filterRelativeXPath( - \sprintf('descendant-or-self::input[((contains(%1$s, "submit") or contains(%1$s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %2$s)) or (contains(%1$s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %2$s)) or @id=%3$s or @name=%3$s] | descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %2$s) or @id=%3$s or @name=%3$s]', 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")', static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value)) + \sprintf('descendant-or-self::input[((contains(%1$s, "submit") or contains(%1$s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %2$s)) or (contains(%1$s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %2$s)) or @id=%3$s or @name=%3$s] | descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %2$s) or contains(concat(\' \', normalize-space(string(@value)), \' \'), %2$s) or @id=%3$s or @name=%3$s]', 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")', static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value)) ); } diff --git a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php index 97b16b9fe6073..53169efcab8e5 100644 --- a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php +++ b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php @@ -452,10 +452,10 @@ public function testFilterXpathComplexQueries() $this->assertCount(0, $crawler->filterXPath('/body')); $this->assertCount(1, $crawler->filterXPath('./body')); $this->assertCount(1, $crawler->filterXPath('.//body')); - $this->assertCount(5, $crawler->filterXPath('.//input')); + $this->assertCount(6, $crawler->filterXPath('.//input')); $this->assertCount(4, $crawler->filterXPath('//form')->filterXPath('//button | //input')); $this->assertCount(1, $crawler->filterXPath('body')); - $this->assertCount(6, $crawler->filterXPath('//button | //input')); + $this->assertCount(8, $crawler->filterXPath('//button | //input')); $this->assertCount(1, $crawler->filterXPath('//body')); $this->assertCount(1, $crawler->filterXPath('descendant-or-self::body')); $this->assertCount(1, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('./div'), 'A child selection finds only the current div'); @@ -723,16 +723,23 @@ public function testSelectButton() $this->assertNotSame($crawler, $crawler->selectButton('FooValue'), '->selectButton() returns a new instance of a crawler'); $this->assertInstanceOf(Crawler::class, $crawler->selectButton('FooValue'), '->selectButton() returns a new instance of a crawler'); - $this->assertEquals(1, $crawler->selectButton('FooValue')->count(), '->selectButton() selects buttons'); - $this->assertEquals(1, $crawler->selectButton('FooName')->count(), '->selectButton() selects buttons'); - $this->assertEquals(1, $crawler->selectButton('FooId')->count(), '->selectButton() selects buttons'); + $this->assertCount(1, $crawler->selectButton('FooValue'), '->selectButton() selects type-submit inputs by value'); + $this->assertCount(1, $crawler->selectButton('FooName'), '->selectButton() selects type-submit inputs by name'); + $this->assertCount(1, $crawler->selectButton('FooId'), '->selectButton() selects type-submit inputs by id'); - $this->assertEquals(1, $crawler->selectButton('BarValue')->count(), '->selectButton() selects buttons'); - $this->assertEquals(1, $crawler->selectButton('BarName')->count(), '->selectButton() selects buttons'); - $this->assertEquals(1, $crawler->selectButton('BarId')->count(), '->selectButton() selects buttons'); + $this->assertCount(1, $crawler->selectButton('BarValue'), '->selectButton() selects type-button inputs by value'); + $this->assertCount(1, $crawler->selectButton('BarName'), '->selectButton() selects type-button inputs by name'); + $this->assertCount(1, $crawler->selectButton('BarId'), '->selectButton() selects type-button inputs by id'); - $this->assertEquals(1, $crawler->selectButton('FooBarValue')->count(), '->selectButton() selects buttons with form attribute too'); - $this->assertEquals(1, $crawler->selectButton('FooBarName')->count(), '->selectButton() selects buttons with form attribute too'); + $this->assertCount(1, $crawler->selectButton('ImageAlt'), '->selectButton() selects type-image inputs by alt'); + + $this->assertCount(1, $crawler->selectButton('ButtonValue'), '->selectButton() selects buttons by value'); + $this->assertCount(1, $crawler->selectButton('ButtonName'), '->selectButton() selects buttons by name'); + $this->assertCount(1, $crawler->selectButton('ButtonId'), '->selectButton() selects buttons by id'); + $this->assertCount(1, $crawler->selectButton('ButtonText'), '->selectButton() selects buttons by text content'); + + $this->assertCount(1, $crawler->selectButton('FooBarValue'), '->selectButton() selects buttons with form attribute too'); + $this->assertCount(1, $crawler->selectButton('FooBarName'), '->selectButton() selects buttons with form attribute too'); } public function testSelectButtonWithSingleQuotesInNameAttribute() @@ -1031,6 +1038,29 @@ public function testClosest() $this->assertNull($notFound); } + public function testClosestWithOrphanedNode() + { + $html = <<<'HTML' + + +
    +
    +
    + + +HTML; + + $crawler = $this->createCrawler($this->getDoctype().$html); + $foo = $crawler->filter('#foo'); + + $fooNode = $foo->getNode(0); + + $fooNode->parentNode->replaceChild($fooNode->ownerDocument->createElement('ol'), $fooNode); + + $body = $foo->closest('body'); + $this->assertNull($body); + } + public function testOuterHtml() { $html = <<<'HTML' @@ -1299,6 +1329,9 @@ public function createTestCrawler($uri = null) + + +