Skip to content

Commit

Permalink
raise phpstan level to 4
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Oct 31, 2023
1 parent 8c5fc74 commit 45c5b39
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
6 changes: 6 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
ignoreErrors:
-
message: "#^Offset 'fields' on array\\{\\} in isset\\(\\) does not exist\\.$#"
count: 2
path: tests/EventListener/DcaField/EncoreEntriesSelectFieldListenerTest.php
6 changes: 4 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -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
- vendor/phpstan/phpstan-symfony/extension.neon
- phpstan-baseline.neon
8 changes: 3 additions & 5 deletions src/Collection/EntryCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Contao\LayoutModel;
use HeimrichHannot\EncoreBundle\Exception\NoEntrypointsException;
use Psr\Cache\CacheItemPoolInterface;
use Psr\Cache\InvalidArgumentException;

class EntryCollection
{
Expand Down Expand Up @@ -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');

Expand All @@ -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));
}

Expand Down
18 changes: 6 additions & 12 deletions src/Command/PrepareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Migration/Version0100Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public function testOtherTable()

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

0 comments on commit 45c5b39

Please sign in to comment.