diff --git a/fixtures/Bridge/Symfony/Application/config_property_access_disabled.yml b/fixtures/Bridge/Symfony/Application/config_property_access_disabled.yml new file mode 100644 index 000000000..301e490e1 --- /dev/null +++ b/fixtures/Bridge/Symfony/Application/config_property_access_disabled.yml @@ -0,0 +1,23 @@ +# +# This file is part of the Alice package. +# +# (c) Nelmio +# +# For the full copyright and license information, please view the LICENSE +# file that was distributed with this source code. +# + +framework: + annotations: + enabled: false + secret: NelmioAliceBundleSecret + serializer: + enabled: true + router: + resource: ~ + strict_requirements: '%kernel.debug%' + utf8: true + test: ~ + session: + enabled: false + property_access: false diff --git a/fixtures/Definition/Flag/MutableFlag.php b/fixtures/Definition/Flag/MutableFlag.php index c5ef8220b..e39218287 100644 --- a/fixtures/Definition/Flag/MutableFlag.php +++ b/fixtures/Definition/Flag/MutableFlag.php @@ -22,9 +22,6 @@ class MutableFlag implements FlagInterface */ private $stringValue; - /** - * @var - */ private $object; public function __construct(string $stringValue, $object) @@ -32,7 +29,7 @@ public function __construct(string $stringValue, $object) $this->stringValue = $stringValue; $this->object = $object; } - + public function __toString(): string { return $this->stringValue; diff --git a/src/Bridge/Symfony/DependencyInjection/Compiler/CheckBundleDependenciesPass.php b/src/Bridge/Symfony/DependencyInjection/Compiler/CheckBundleDependenciesPass.php new file mode 100644 index 000000000..700010ad5 --- /dev/null +++ b/src/Bridge/Symfony/DependencyInjection/Compiler/CheckBundleDependenciesPass.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Nelmio\Alice\Bridge\Symfony\DependencyInjection\Compiler; + +use LogicException; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; + +class CheckBundleDependenciesPass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container): void + { + if (!$container->has('property_accessor')) { + throw new LogicException('NelmioAliceBundle requires framework_bundle.property_access to be enabled.'); + } + } +} diff --git a/src/Bridge/Symfony/NelmioAliceBundle.php b/src/Bridge/Symfony/NelmioAliceBundle.php index ea08a180a..2d7bc8640 100644 --- a/src/Bridge/Symfony/NelmioAliceBundle.php +++ b/src/Bridge/Symfony/NelmioAliceBundle.php @@ -13,6 +13,7 @@ namespace Nelmio\Alice\Bridge\Symfony; +use Nelmio\Alice\Bridge\Symfony\DependencyInjection\Compiler\CheckBundleDependenciesPass; use Nelmio\Alice\Bridge\Symfony\DependencyInjection\Compiler\RegisterFakerProvidersPass; use Nelmio\Alice\Bridge\Symfony\DependencyInjection\Compiler\RegisterTagServicesPass; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -24,6 +25,7 @@ public function build(ContainerBuilder $container): void { parent::build($container); + $container->addCompilerPass(new CheckBundleDependenciesPass()); $container->addCompilerPass(new RegisterFakerProvidersPass()); $container->addCompilerPass( new RegisterTagServicesPass( diff --git a/tests/Bridge/Symfony/DependencyInjection/CheckBundleDependenciesPassTest.php b/tests/Bridge/Symfony/DependencyInjection/CheckBundleDependenciesPassTest.php new file mode 100644 index 000000000..c4b7f6ca5 --- /dev/null +++ b/tests/Bridge/Symfony/DependencyInjection/CheckBundleDependenciesPassTest.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Nelmio\Alice\Bridge\Symfony\DependencyInjection; + +use LogicException; +use Nelmio\Alice\Symfony\KernelFactory; +use PHPUnit\Framework\TestCase; + +/** + * @coversNothing + * + * @group integration + */ +class CheckBundleDependenciesPassTest extends TestCase +{ + public function testPropertyAccessDisabled(): void + { + static::expectException(LogicException::class); + static::expectExceptionMessage('NelmioAliceBundle requires framework_bundle.property_access to be enabled.'); + + $kernel = KernelFactory::createKernel( + __DIR__.'/../../../../fixtures/Bridge/Symfony/Application/config_property_access_disabled.yml', + ); + $kernel->boot(); + } +} diff --git a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/UniqueValueDenormalizerTest.php b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/UniqueValueDenormalizerTest.php index 6c43b5dba..bb5e841bf 100644 --- a/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/UniqueValueDenormalizerTest.php +++ b/tests/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/UniqueValueDenormalizerTest.php @@ -116,7 +116,6 @@ public function testIfParsedValueIsDynamicArrayThenUniqueFlagAppliesToItsElement /** @var DynamicArrayValue $result */ static::assertEquals(10, $result->getQuantifier()); static::assertInstanceOf(UniqueValue::class, $result->getElement()); - // @phpstan-ignore-next-line static::assertStringStartsWith('Dummy#', $result->getElement()->getId()); static::assertEquals('parsed_value', $result->getElement()->getValue()); }