diff --git a/.scrutinizer.yml b/.scrutinizer.yml index af821242..6f731023 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,4 +1,12 @@ --- +build: + nodes: + analysis: + project_setup: + override: true + tests: + override: [php-scrutinizer-run] + filter: excluded_paths: [vendor/*, app/*, web/*, Behat/*, spec/*, features/*] diff --git a/Behat/Context/AdminContext.php b/Behat/Context/AdminContext.php index dbcef3db..b6e9caf2 100644 --- a/Behat/Context/AdminContext.php +++ b/Behat/Context/AdminContext.php @@ -161,6 +161,6 @@ public function castWordToNumber(string $word): int private function getAdminManager(): ManagerInterface { - return $this->getContainer()->get('admin.manager'); + return $this->getContainer()->get('test.admin.manager'); } } diff --git a/Behat/Context/FiltersContext.php b/Behat/Context/FiltersContext.php index 7777d97f..a91ffda5 100644 --- a/Behat/Context/FiltersContext.php +++ b/Behat/Context/FiltersContext.php @@ -246,7 +246,7 @@ private function getDataSource(AdminListElement $adminElement) private function clearDataSource(AdminListElement $element): void { - $this->getContainer()->get('datasource.factory')->clearDataSource($element->getId()); + $this->getContainer()->get('test.datasource.factory')->clearDataSource($element->getId()); } private function getFiltersElement(): Filters diff --git a/Behat/Context/ResourceContext.php b/Behat/Context/ResourceContext.php index 097b51f1..7acb99f4 100644 --- a/Behat/Context/ResourceContext.php +++ b/Behat/Context/ResourceContext.php @@ -13,6 +13,7 @@ use Behat\Gherkin\Node\TableNode; use Behat\Symfony2Extension\Context\KernelAwareContext; +use FSi\Bundle\ResourceRepositoryBundle\Repository\MapBuilder; use SensioLabs\Behat\PageObjectExtension\Context\PageObjectContext; use Symfony\Component\HttpKernel\KernelInterface; @@ -37,16 +38,12 @@ public function setKernel(KernelInterface $kernel): void public function thereAreFollowingResourcesAddedToResourceMap(TableNode $resources) { foreach ($resources->getHash() as $resource) { - expect($this->kernel->getContainer() - ->get('fsi_resource_repository.map_builder') - ->hasResource($resource['Key']))->toBe(true); + expect($this->getResourceMapBuilder()->hasResource($resource['Key']))->toBe(true); if (isset($resource['Type'])) { - expect($this->kernel->getContainer() - ->get('fsi_resource_repository.map_builder') - ->getResource($resource['Key']))->toBeAnInstanceOf( - sprintf('FSi\Bundle\ResourceRepositoryBundle\Repository\Resource\Type\%sType', ucfirst($resource['Type'])) - ); + expect($this->getResourceMapBuilder()->getResource($resource['Key']))->toBeAnInstanceOf( + sprintf('FSi\Bundle\ResourceRepositoryBundle\Repository\Resource\Type\%sType', ucfirst($resource['Type'])) + ); } } } @@ -66,4 +63,9 @@ public function iShouldSeeFormFieldWithValue($value) { expect($this->getElement('Form')->findField('Content')->getValue())->toBe($value); } + + private function getResourceMapBuilder(): MapBuilder + { + return $this->kernel->getContainer()->get('test.fsi_resource_repository.map_builder'); + } } diff --git a/DependencyInjection/Compiler/AdminElementPass.php b/DependencyInjection/Compiler/AdminElementPass.php index 0274c92e..d0274d3a 100644 --- a/DependencyInjection/Compiler/AdminElementPass.php +++ b/DependencyInjection/Compiler/AdminElementPass.php @@ -20,7 +20,7 @@ class AdminElementPass implements CompilerPassInterface public function process(ContainerBuilder $container): void { if (!$container->hasDefinition('admin.manager') - || !$container->has('admin.manager.visitor.element_collection') + || !$container->hasDefinition('admin.manager.visitor.element_collection') ) { return; } @@ -28,7 +28,7 @@ public function process(ContainerBuilder $container): void $elements = []; $elementServices = $container->findTaggedServiceIds('admin.element'); foreach (array_keys($elementServices) as $id) { - $elements[] = new Reference($id); + $elements[] = new Reference((string) $id); } $container->findDefinition('admin.manager.visitor.element_collection') diff --git a/Doctrine/Admin/ElementImpl.php b/Doctrine/Admin/ElementImpl.php index 04957d78..9a1a53e7 100644 --- a/Doctrine/Admin/ElementImpl.php +++ b/Doctrine/Admin/ElementImpl.php @@ -23,6 +23,8 @@ trait ElementImpl */ protected $registry; + abstract public function getClassName(): string; + public function setManagerRegistry(ManagerRegistry $registry): void { $this->registry = $registry; diff --git a/EventListener/MainMenuListener.php b/EventListener/MainMenuListener.php index b14a19be..9301d2fb 100644 --- a/EventListener/MainMenuListener.php +++ b/EventListener/MainMenuListener.php @@ -38,7 +38,14 @@ public function __construct(ManagerInterface $manager, string $configFilePath) public function createMainMenu(MenuEvent $event): Item { - $config = $this->yaml->parse(file_get_contents($this->configFilePath), true, true); + if (defined('Symfony\Component\Yaml\Yaml::PARSE_OBJECT')) { + $config = $this->yaml->parse( + file_get_contents($this->configFilePath), + Yaml::PARSE_OBJECT | Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE + ); + } else { + $config = $this->yaml->parse(file_get_contents($this->configFilePath), true, true); + } if (!isset($config['menu'])) { throw new InvalidYamlStructureException( diff --git a/FSiAdminBundle.php b/FSiAdminBundle.php index a9a04421..9aebe6f2 100644 --- a/FSiAdminBundle.php +++ b/FSiAdminBundle.php @@ -35,7 +35,7 @@ public function build(ContainerBuilder $container): void new AnnotationReader(), new AdminClassFinder() )); - $container->addCompilerPass(new AdminElementPass(), PassConfig::TYPE_REMOVE); + $container->addCompilerPass(new AdminElementPass()); $container->addCompilerPass(new KnpMenuBuilderPass()); $container->addCompilerPass(new ResourceRepositoryPass()); $container->addCompilerPass(new ManagerVisitorPass()); diff --git a/Resources/config/services.xml b/Resources/config/services.xml index 7a5a7879..063e0f46 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -77,7 +77,7 @@ - + @@ -101,7 +101,7 @@ %admin.templates.resource% - + %admin.templates.index_page% diff --git a/composer.json b/composer.json index 27e29943..3349025f 100644 --- a/composer.json +++ b/composer.json @@ -20,22 +20,22 @@ ], "require": { "php": ">=7.1", - "symfony/framework-bundle" : "^2.4|^3.0", - "symfony/form" : "^2.3|^3.0", - "symfony/intl" : "^2.6|^3.0", - "symfony/asset": "^2.7|^3.0", - "symfony/options-resolver": "^2.6|^3.0", - "symfony/expression-language": "^2.6|^3.0", - "symfony/http-foundation": "^2.6|^3.0", - "symfony/dependency-injection": "^2.6.2|^3.0", - "symfony/validator": "^2.3|^3.0", - "symfony/proxy-manager-bridge": "^2.3|^3.0", - "symfony/doctrine-bridge": "^2.3|^3.0", - "symfony/twig-bridge": "^2.6|^3.0", - "symfony/translation": "^2.4|^3.0", - "symfony/templating": "^2.4|^3.0", - "sensio/framework-extra-bundle": "^3.0", - "symfony/twig-bundle": "^2.3|^3.0", + "symfony/framework-bundle" : "^2.4|^3.0|^4.0", + "symfony/form" : "^2.3|^3.0|^4.0", + "symfony/intl" : "^2.6|^3.0|^4.0", + "symfony/asset": "^2.7|^3.0|^4.0", + "symfony/options-resolver": "^2.6|^3.0|^4.0", + "symfony/expression-language": "^2.6|^3.0|^4.0", + "symfony/http-foundation": "^2.6|^3.0|^4.0", + "symfony/dependency-injection": "^2.6.2|^3.0|^4.0", + "symfony/validator": "^2.3|^3.0|^4.0", + "symfony/proxy-manager-bridge": "^2.3|^3.0|^4.0", + "symfony/doctrine-bridge": "^2.3|^3.0|^4.0", + "symfony/twig-bridge": "^2.6|^3.0|^4.0", + "symfony/translation": "^2.4|^3.0|^4.0", + "symfony/templating": "^2.4|^3.0|^4.0", + "sensio/framework-extra-bundle": "^3.0|^4.0", + "symfony/twig-bundle": "^2.3|^3.0|^4.0", "fsi/datagrid-bundle" : "^1.2|^2.0@dev", "fsi/datasource-bundle": "^2.0@dev", "knplabs/knp-menu-bundle": "^2.0", @@ -44,10 +44,10 @@ "ocramius/proxy-manager": "^2.1" }, "require-dev": { - "symfony/class-loader": "^2.3|^3.0", - "symfony/monolog-bundle": "^2.3|^3.0", - "symfony/yaml": "^2.7.1|^3.0", - "symfony/var-dumper": "^2.6|^3.0", + "symfony/class-loader": "^2.3|^3.0|^4.0", + "symfony/monolog-bundle": "^2.3|^3.0|^4.0", + "symfony/yaml": "^2.7.1|^3.0|^4.0", + "symfony/var-dumper": "^2.6|^3.0|^4.0", "ext-pdo_sqlite": "*", "fsi/resource-repository-bundle": "^1.1.5|^2.0@dev", "fsi/datagrid": "^1.3|^2.0@dev", diff --git a/features/fixtures/project/app/config/config.yml b/features/fixtures/project/app/config/config.yml index 0be8a706..f12c5b49 100644 --- a/features/fixtures/project/app/config/config.yml +++ b/features/fixtures/project/app/config/config.yml @@ -19,9 +19,9 @@ doctrine: driver: pdo_sqlite user: admin charset: UTF8 - path: %kernel.root_dir%/data.sqlite + path: "%kernel.root_dir%/data.sqlite" orm: - auto_generate_proxy_classes: %kernel.debug% + auto_generate_proxy_classes: "%kernel.debug%" auto_mapping: true fsi_resource_repository: @@ -41,4 +41,4 @@ monolog: type: stream path: "%kernel.logs_dir%/%kernel.environment%.log" level: debug - channels: [!event] \ No newline at end of file + channels: ["!event"] diff --git a/features/fixtures/project/src/FSi/FixturesBundle/Resources/config/services.xml b/features/fixtures/project/src/FSi/FixturesBundle/Resources/config/services.xml index 6896c8e1..ccc7af72 100644 --- a/features/fixtures/project/src/FSi/FixturesBundle/Resources/config/services.xml +++ b/features/fixtures/project/src/FSi/FixturesBundle/Resources/config/services.xml @@ -75,11 +75,15 @@ - + + + + + diff --git a/spec/FSi/Bundle/AdminBundle/Admin/CRUD/Context/BatchElementContextSpec.php b/spec/FSi/Bundle/AdminBundle/Admin/CRUD/Context/BatchElementContextSpec.php index 5a7e6aa6..99735e8f 100644 --- a/spec/FSi/Bundle/AdminBundle/Admin/CRUD/Context/BatchElementContextSpec.php +++ b/spec/FSi/Bundle/AdminBundle/Admin/CRUD/Context/BatchElementContextSpec.php @@ -76,7 +76,7 @@ function it_return_response_from_handler( ->shouldReturnAnInstanceOf(Response::class); } - public function getMatchers() + public function getMatchers(): array { return [ 'haveKeyInArray' => function($subject, $key) { diff --git a/spec/FSi/Bundle/AdminBundle/Admin/CRUD/Context/FormElementContextSpec.php b/spec/FSi/Bundle/AdminBundle/Admin/CRUD/Context/FormElementContextSpec.php index c6938546..8a80515b 100644 --- a/spec/FSi/Bundle/AdminBundle/Admin/CRUD/Context/FormElementContextSpec.php +++ b/spec/FSi/Bundle/AdminBundle/Admin/CRUD/Context/FormElementContextSpec.php @@ -88,7 +88,7 @@ function it_throws_exception_when_adding_is_not_allowed( $this->shouldThrow(NotFoundHttpException::class)->during('handleRequest', [$request]); } - public function getMatchers() + public function getMatchers(): array { return [ 'haveKeyInArray' => function($subject, $key) { diff --git a/spec/FSi/Bundle/AdminBundle/Admin/CRUD/Context/ListElementContextSpec.php b/spec/FSi/Bundle/AdminBundle/Admin/CRUD/Context/ListElementContextSpec.php index 70d14a09..d6c778a0 100644 --- a/spec/FSi/Bundle/AdminBundle/Admin/CRUD/Context/ListElementContextSpec.php +++ b/spec/FSi/Bundle/AdminBundle/Admin/CRUD/Context/ListElementContextSpec.php @@ -12,6 +12,7 @@ use FSi\Bundle\AdminBundle\Admin\Context\Request\HandlerInterface; use FSi\Bundle\AdminBundle\Admin\CRUD\ListElement; use FSi\Component\DataGrid\DataGridInterface; +use FSi\Component\DataGrid\DataGridViewInterface; use FSi\Component\DataSource\DataSourceInterface; use PhpSpec\ObjectBehavior; use Prophecy\Argument; @@ -26,10 +27,12 @@ function let( ListElement $element, DataSourceInterface $datasource, DataGridInterface $datagrid, + DataGridViewInterface $datagridView, HandlerInterface $handler ) { $this->beConstructedWith([$handler], 'default_list'); $element->createDataGrid()->willReturn($datagrid); + $datagrid->createView()->willReturn($datagridView); $element->createDataSource()->willReturn($datasource); $this->setElement($element); } @@ -82,7 +85,7 @@ function it_return_response_from_handler( ->shouldReturnAnInstanceOf(Response::class); } - public function getMatchers() + public function getMatchers(): array { return [ 'haveKeyInArray' => function($subject, $key) { diff --git a/spec/FSi/Bundle/AdminBundle/Admin/Display/Context/DisplayContextSpec.php b/spec/FSi/Bundle/AdminBundle/Admin/Display/Context/DisplayContextSpec.php index 0ae7a253..0d114642 100644 --- a/spec/FSi/Bundle/AdminBundle/Admin/Display/Context/DisplayContextSpec.php +++ b/spec/FSi/Bundle/AdminBundle/Admin/Display/Context/DisplayContextSpec.php @@ -88,7 +88,7 @@ function it_returns_response_from_handler(HandlerInterface $handler, Request $re ->shouldReturnAnInstanceOf(Response::class); } - public function getMatchers() + public function getMatchers(): array { return [ 'haveKeyInArray' => function($subject, $key) { diff --git a/spec/FSi/Bundle/AdminBundle/Admin/ResourceRepository/Context/ResourceRepositoryContextSpec.php b/spec/FSi/Bundle/AdminBundle/Admin/ResourceRepository/Context/ResourceRepositoryContextSpec.php index 2b2bf887..df55fb1e 100644 --- a/spec/FSi/Bundle/AdminBundle/Admin/ResourceRepository/Context/ResourceRepositoryContextSpec.php +++ b/spec/FSi/Bundle/AdminBundle/Admin/ResourceRepository/Context/ResourceRepositoryContextSpec.php @@ -86,7 +86,7 @@ function it_return_response_from_handler( ->shouldReturnAnInstanceOf(Response::class); } - public function getMatchers() + public function getMatchers(): array { return [ 'haveKeyInArray' => function($subject, $key) { diff --git a/spec/FSi/Bundle/AdminBundle/Display/PropertyAccessDisplaySpec.php b/spec/FSi/Bundle/AdminBundle/Display/PropertyAccessDisplaySpec.php index 4b2a804f..c5d6eeef 100644 --- a/spec/FSi/Bundle/AdminBundle/Display/PropertyAccessDisplaySpec.php +++ b/spec/FSi/Bundle/AdminBundle/Display/PropertyAccessDisplaySpec.php @@ -50,7 +50,7 @@ function it_creates_display_view_with_decorated_values() $this->getData()->shouldHaveProperty($now->format('Y-m-d'), 'Date'); } - public function getMatchers() + public function getMatchers(): array { return [ 'haveProperty' => function($subject, $value, $label) { diff --git a/spec/FSi/Bundle/AdminBundle/Display/SimpleDisplaySpec.php b/spec/FSi/Bundle/AdminBundle/Display/SimpleDisplaySpec.php index efd0513e..e13d08b9 100644 --- a/spec/FSi/Bundle/AdminBundle/Display/SimpleDisplaySpec.php +++ b/spec/FSi/Bundle/AdminBundle/Display/SimpleDisplaySpec.php @@ -21,7 +21,7 @@ function it_creates_data_for_object() $this->getData()->shouldHaveProperty('Piotr', 'First Name'); } - public function getMatchers() + public function getMatchers(): array { return [ 'haveProperty' => function($subject, $value, $label) { diff --git a/spec/FSi/Bundle/AdminBundle/EventListener/MainMenuListenerSpec.php b/spec/FSi/Bundle/AdminBundle/EventListener/MainMenuListenerSpec.php index 6b5fbb6d..2a491e78 100644 --- a/spec/FSi/Bundle/AdminBundle/EventListener/MainMenuListenerSpec.php +++ b/spec/FSi/Bundle/AdminBundle/EventListener/MainMenuListenerSpec.php @@ -60,7 +60,7 @@ function it_build_menu() $offerItem->getOption('elements')[1]->getId()->shouldReturn('product'); } - public function getMatchers() + public function getMatchers(): array { return [ 'haveItem' => function(Item $menu, $itemName, $elementId = false) { diff --git a/spec/FSi/Bundle/AdminBundle/FSiAdminBundleSpec.php b/spec/FSi/Bundle/AdminBundle/FSiAdminBundleSpec.php index 2b60021c..1c133ba7 100644 --- a/spec/FSi/Bundle/AdminBundle/FSiAdminBundleSpec.php +++ b/spec/FSi/Bundle/AdminBundle/FSiAdminBundleSpec.php @@ -33,10 +33,8 @@ function it_add_compiler_pass(ContainerBuilder $builder) { $builder->addCompilerPass(Argument::type(AdminAnnotatedElementPass::class)) ->shouldBeCalled(); - $builder->addCompilerPass( - Argument::type(AdminElementPass::class), - PassConfig::TYPE_REMOVE - )->shouldBeCalled(); + $builder->addCompilerPass(Argument::type(AdminElementPass::class)) + ->shouldBeCalled(); $builder->addCompilerPass(Argument::type(KnpMenuBuilderPass::class)) ->shouldBeCalled(); $builder->addCompilerPass(Argument::type(ResourceRepositoryPass::class))