diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..a0a9f7f --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,6 @@ +parameters: + ignoreErrors: + - + message: "#^Offset 'fields' on array\\{\\} in isset\\(\\) does not exist\\.$#" + count: 2 + path: tests/EventListener/DcaField/EncoreEntriesSelectFieldListenerTest.php diff --git a/phpstan.neon b/phpstan.neon index 2586bc7..e630b1c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,12 +1,14 @@ parameters: - level: 3 + level: 4 paths: - src - tests + - contao universalObjectCratesClasses: - Contao\LayoutModel - Contao\Model - Contao\Template - PHPUnit\Framework\MockObject\MockObject includes: - - vendor/phpstan/phpstan-symfony/extension.neon \ No newline at end of file + - vendor/phpstan/phpstan-symfony/extension.neon + - phpstan-baseline.neon \ No newline at end of file diff --git a/src/Collection/EntryCollection.php b/src/Collection/EntryCollection.php index 6971cb7..0fc91c4 100644 --- a/src/Collection/EntryCollection.php +++ b/src/Collection/EntryCollection.php @@ -11,6 +11,7 @@ use Contao\LayoutModel; use HeimrichHannot\EncoreBundle\Exception\NoEntrypointsException; use Psr\Cache\CacheItemPoolInterface; +use Psr\Cache\InvalidArgumentException; class EntryCollection { @@ -86,13 +87,10 @@ private function mergeEntries(array $entrypointJsonFiles, array $bundleConfigEnt return $bundleConfigEntries; } - /** - * @throws NoEntrypointsException - */ private function parseEntrypoints(string $entrypointsJson): array { $cached = null; - if ($this->cache && $this->useCache) { + if ($this->useCache) { // '_default' is the default cache key for single encore builds $cached = $this->cache->getItem('_default'); @@ -117,7 +115,7 @@ private function parseEntrypoints(string $entrypointsJson): array throw new NoEntrypointsException(sprintf('There is no "entrypoints" key in "%s"', $entrypointsJson)); } - if ($this->useCache && null !== $cached && !$cached->isHit()) { + if ($this->useCache) { $this->cache->save($cached->set($entriesData)); } diff --git a/src/Command/PrepareCommand.php b/src/Command/PrepareCommand.php index 32b934c..0696b0d 100644 --- a/src/Command/PrepareCommand.php +++ b/src/Command/PrepareCommand.php @@ -29,21 +29,15 @@ class PrepareCommand extends Command protected static $defaultDescription = 'Does the necessary preparation for contao encore bundle. Needs to be called after changes to bundle encore entries.'; private SymfonyStyle $io; - private CacheItemPoolInterface $encoreCache; - private KernelInterface $kernel; - private array $bundleConfig; - private Environment $twig; - private ExtensionCollection $extensionCollection; - public function __construct(CacheItemPoolInterface $encoreCache, KernelInterface $kernel, array $bundleConfig, Environment $twig, ExtensionCollection $extensionCollection) - { + public function __construct( + private CacheItemPoolInterface $encoreCache, + private KernelInterface $kernel, + private Environment $twig, + private ExtensionCollection $extensionCollection + ) { parent::__construct(); - $this->encoreCache = $encoreCache; - $this->kernel = $kernel; - $this->bundleConfig = $bundleConfig; - $this->twig = $twig; - $this->extensionCollection = $extensionCollection; } /** diff --git a/src/Migration/Version0100Migration.php b/src/Migration/Version0100Migration.php index 0cc6d12..8e02387 100644 --- a/src/Migration/Version0100Migration.php +++ b/src/Migration/Version0100Migration.php @@ -85,7 +85,7 @@ public function run(): MigrationResult continue; } - if (!'root' === $page->type) { + if ('root' !== $page->type) { $rootPage = PageModel::findByPk($page->rootId); if (!$rootPage) { continue; diff --git a/tests/EventListener/DcaField/EncoreEntriesSelectFieldListenerTest.php b/tests/EventListener/DcaField/EncoreEntriesSelectFieldListenerTest.php index 1ba4721..77753b2 100644 --- a/tests/EventListener/DcaField/EncoreEntriesSelectFieldListenerTest.php +++ b/tests/EventListener/DcaField/EncoreEntriesSelectFieldListenerTest.php @@ -25,7 +25,6 @@ public function testOtherTable() public function testDefault() { - /** @phpstan */ $GLOBALS['TL_DCA']['tl_test'] = []; EncoreEntriesSelectField::register('tl_test'); $instance = $this->createTestInstance();