Skip to content

Commit

Permalink
fix phpstan error
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Oct 29, 2023
1 parent d21a0b5 commit 926ad6a
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 91 deletions.
5 changes: 0 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,5 @@ parameters:
- Contao\Model
- Contao\Template
- PHPUnit\Framework\MockObject\MockObject
ignoreErrors:
- message: '#^Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition\:\:getChildNodeDefinitions\(\)\.$#'
path: tests/DependencyInjection/ConfigurationTest.php
- message: '#^Call to an undefined method Symfony\\Component\\Config\\Definition\\NodeInterface\:\:getChildren\(\)\.$#'
path: tests/DependencyInjection/ConfigurationTest.php
includes:
- vendor/phpstan/phpstan-symfony/extension.neon
4 changes: 2 additions & 2 deletions src/Collection/ConfigurationCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function __construct(ExtensionCollection $extensionCollection)
* - array: (bool) Return entrypoints as array[] instead as EncoreEntry[]
*
* @param array{
* array: bool
* } $options
* array?: bool
* } $options
* @return array|EncoreEntry[]|array[]
*/
public function getJsEntries(array $options = []): array
Expand Down
67 changes: 0 additions & 67 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,73 +47,6 @@ public function getConfigTreeBuilder()
->end()
->end()
;

return $treeBuilder;
}

/**
* @todo Remove in version 2.0
*/
public function addLegacyNode()
{
$treeBuilder = new TreeBuilder('encore');
$node = $treeBuilder->getRootNode();
$node
->addDefaultsIfNotSet()
->setDeprecated('Configs within encore key are deprecated and will be removed in next major version.')
->children()
->arrayNode('entries')
->arrayPrototype()
->children()
->scalarNode('name')
->isRequired()
->cannotBeEmpty()
->end()
->scalarNode('file')
->isRequired()
->cannotBeEmpty()
->end()
->booleanNode('requiresCss')->end()
->booleanNode('head')->end()
->end()
->end()
->end()
->arrayNode('templates')
->addDefaultsIfNotSet()
->children()
->arrayNode('imports')
->arrayPrototype()
->children()
->scalarNode('name')
->isRequired()
->cannotBeEmpty()
->end()
->scalarNode('template')
->isRequired()
->cannotBeEmpty()
->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('legacy')
->addDefaultsIfNotSet()
->children()
->arrayNode('js')
->scalarPrototype()->end()
->end()
->arrayNode('jquery')
->scalarPrototype()->end()
->end()
->arrayNode('css')
->scalarPrototype()->end()
->end()
->end()
->end()
->end()
;

return $node;
}
}
17 changes: 0 additions & 17 deletions src/DependencyInjection/EncoreConfigCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use const HeimrichHannot\UtilsBundle\Choice\AbstractChoice;

class EncoreConfigCompilerPass implements CompilerPassInterface
{
Expand All @@ -29,21 +28,5 @@ public function process(ContainerBuilder $container)
foreach ($container->findTaggedServiceIds('huh.encore.extension') as $id => $tags) {
$collectionDefinition->addMethodCall('addExtension', [new Reference($id)]);
}

$this->removeLegacyServices($container);
}

private function removeLegacyServices(ContainerBuilder $container)
{
if (!class_exists(AbstractChoice::class)) {

if ($container->has('huh.encore.choice.entry')) {
$container->removeDefinition('huh.encore.choice.entry');
}

if ($container->has('huh.encore.choice.imports_template')) {
$container->removeDefinition('huh.encore.choice.imports_template');
}
}
}
}
1 change: 1 addition & 0 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function testGetConfigTreeBuilder()
$configuration = new Configuration();
$treeBuilder = $configuration->getConfigTreeBuilder();
$this->assertInstanceOf(TreeBuilder::class, $treeBuilder);
/** @phpstan-ignore-next-line */
$this->assertCount(2, $treeBuilder->getRootNode()->getChildNodeDefinitions());

$tree = $treeBuilder->buildTree();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ public function testOtherTable()

public function testDefault()
{
/** @phpstan */
$GLOBALS['TL_DCA']['tl_test'] = [];
EncoreEntriesSelectField::register('tl_test');
$instance = $this->createTestInstance();
$instance->onLoadDataContainer('tl_test');

static::assertTrue(isset($GLOBALS['TL_DCA']['tl_test']['fields']));
static::assertArrayHasKey('fields', $GLOBALS['TL_DCA']['tl_test']);
static::assertArrayHasKey('encoreEntries', $GLOBALS['TL_DCA']['tl_test']['fields']);
static::assertArrayHasKey('entry', $GLOBALS['TL_DCA']['tl_test']['fields']['encoreEntries']['eval']['multiColumnEditor']['fields']);
Expand All @@ -43,6 +45,7 @@ public function testActiveCheckbox()
$instance = $this->createTestInstance();
$instance->onLoadDataContainer('tl_test');

static::assertTrue(isset($GLOBALS['TL_DCA']['tl_test']['fields']));
static::assertArrayHasKey('fields', $GLOBALS['TL_DCA']['tl_test']);
static::assertArrayHasKey('encoreEntries', $GLOBALS['TL_DCA']['tl_test']['fields']);
static::assertArrayHasKey('entry', $GLOBALS['TL_DCA']['tl_test']['fields']['encoreEntries']['eval']['multiColumnEditor']['fields']);
Expand Down

0 comments on commit 926ad6a

Please sign in to comment.