diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae51e66..a384886 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] + php-versions: ['7.2', '7.3', '7.4', '8.0'] steps: - name: Checkout uses: actions/checkout@v2 @@ -74,7 +74,7 @@ jobs: run: vendor/bin/phpunit tests/System/; continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8] - name: Running static analysis - run: vendor/bin/phpstan analyse -l 5 bin/ src/ tests/ public/; + run: vendor/bin/phpstan analyse -c phpstan.neon; continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8] - name: Running PHPMD run: vendor/bin/phpmd src/ text config/PHPMD/rules.xml; diff --git a/composer.json b/composer.json index ae3260f..aa324da 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "source": "https://github.com/phpList/core" }, "require": { - "php": "^7.0|^8.0", + "php": "^7.2|^8.0", "doctrine/orm": "^2.5.0", "doctrine/common": "^2.6.0", "doctrine/doctrine-bundle": "^1.8.0", @@ -43,7 +43,7 @@ "symfony/dependency-injection": "^3.4.37", "symfony/config": "^3.4.37", "symfony/yaml": "^3.4.37", - "jms/serializer-bundle": "^2.3", + "jms/serializer-bundle": "^3.8.0", "sensio/framework-extra-bundle": "^5.1.0", "sensio/distribution-bundle": "^5.0.6" }, @@ -53,8 +53,8 @@ "phpunit/dbunit": "^3.0.0", "guzzlehttp/guzzle": "^6.3.0", "squizlabs/php_codesniffer": "^3.2.0", - "phpstan/phpstan": "^0.7.0", - "nette/caching": "^2.5.0 || ^3.0.0", + "phpstan/phpstan": "^0.7.0|0.12.57", + "nette/caching": "^2.5.0|^3.0.0", "nikic/php-parser": "^3.1.0", "phpmd/phpmd": "^2.6.0", "composer/composer": "^1.6.0", diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..d85773d --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,10 @@ +parameters: + level: 5 + paths: + - bin + - src + - tests + - public + ignoreErrors: + - '#Cannot call method (?:willReturn|shouldBeCalledOnce|shouldNotBeCalled|shouldBeCalled|shouldNotHaveBeenCalled)\(\) on .*\.#' + - '#Call to an undefined method [a-zA-Z0-9\\_]+::willReturn\(\)#' \ No newline at end of file diff --git a/src/Core/Bootstrap.php b/src/Core/Bootstrap.php index 11931aa..42a1517 100644 --- a/src/Core/Bootstrap.php +++ b/src/Core/Bootstrap.php @@ -75,7 +75,7 @@ protected function __clone() public static function getInstance(): Bootstrap { if (self::$instance === null) { - self::$instance = new static(); + self::$instance = new self; } return self::$instance; diff --git a/src/TestingSupport/Traits/DatabaseTestTrait.php b/src/TestingSupport/Traits/DatabaseTestTrait.php index 47f2999..ca6a74b 100644 --- a/src/TestingSupport/Traits/DatabaseTestTrait.php +++ b/src/TestingSupport/Traits/DatabaseTestTrait.php @@ -80,7 +80,7 @@ protected function initializeDatabaseTester() { $this->dataSet = new CsvDataSet(); - $this->databaseTester = null; + unset($this->databaseTester); $this->getDatabaseTester()->setSetUpOperation($this->getSetUpOperation()); } @@ -98,7 +98,7 @@ protected function tearDownDatabaseTest() // Destroy the tester after the test is run to keep DB connections // from piling up. - $this->databaseTester = null; + unset($this->databaseTester); Bootstrap::purgeInstance(); } diff --git a/tests/Integration/Domain/Repository/Messaging/SubscriberListRepositoryTest.php b/tests/Integration/Domain/Repository/Messaging/SubscriberListRepositoryTest.php index d8fa30f..f038bf4 100644 --- a/tests/Integration/Domain/Repository/Messaging/SubscriberListRepositoryTest.php +++ b/tests/Integration/Domain/Repository/Messaging/SubscriberListRepositoryTest.php @@ -230,8 +230,8 @@ public function findsAssociatedSubscriptions() $this->getDataSet()->addTable(static::SUBSCRIPTION_TABLE_NAME, __DIR__ . '/../Fixtures/Subscription.csv'); $this->applyDatabaseChanges(); - /** @var SubscriberList $model */ $id = 2; + /** @var SubscriberList $model */ $model = $this->subject->find($id); $subscriptions = $model->getSubscriptions(); @@ -253,8 +253,8 @@ public function findsAssociatedSubscribers() $this->getDataSet()->addTable(static::SUBSCRIPTION_TABLE_NAME, __DIR__ . '/../Fixtures/Subscription.csv'); $this->applyDatabaseChanges(); - /** @var SubscriberList $model */ $id = 2; + /** @var SubscriberList $model */ $model = $this->subject->find($id); $subscribers = $model->getSubscribers(); @@ -276,8 +276,8 @@ public function removeAlsoRemovesAssociatedSubscriptions() $initialNumberOfSubscriptions = count($this->subscriptionRepository->findAll()); - /** @var SubscriberList $model */ $id = 2; + /** @var SubscriberList $model */ $model = $this->subject->find($id); $numberOfAssociatedSubscriptions = count($model->getSubscriptions()); diff --git a/tests/Integration/Domain/Repository/Subscription/SubscriberRepositoryTest.php b/tests/Integration/Domain/Repository/Subscription/SubscriberRepositoryTest.php index ee810e0..77580d0 100644 --- a/tests/Integration/Domain/Repository/Subscription/SubscriberRepositoryTest.php +++ b/tests/Integration/Domain/Repository/Subscription/SubscriberRepositoryTest.php @@ -237,8 +237,8 @@ public function findsAssociatedSubscriptions() $this->getDataSet()->addTable(static::SUBSCRIPTION_TABLE_NAME, __DIR__ . '/../Fixtures/Subscription.csv'); $this->applyDatabaseChanges(); - /** @var Subscriber $model */ $id = 1; + /** @var Subscriber $model */ $model = $this->subject->find($id); $subscriptions = $model->getSubscriptions(); @@ -260,8 +260,8 @@ public function findsAssociatedSubscribedLists() $this->getDataSet()->addTable(static::SUBSCRIPTION_TABLE_NAME, __DIR__ . '/../Fixtures/Subscription.csv'); $this->applyDatabaseChanges(); - /** @var Subscriber $model */ $id = 1; + /** @var Subscriber $model */ $model = $this->subject->find($id); $subscribedLists = $model->getSubscribedLists(); @@ -283,8 +283,8 @@ public function removeAlsoRemovesAssociatedSubscriptions() $initialNumberOfSubscriptions = count($this->subscriptionRepository->findAll()); - /** @var Subscriber $model */ $id = 2; + /** @var Subscriber $model */ $model = $this->subject->find($id); $numberOfAssociatedSubscriptions = count($model->getSubscriptions()); diff --git a/tests/Unit/Composer/ModuleFinderTest.php b/tests/Unit/Composer/ModuleFinderTest.php index 75fd252..64069e5 100644 --- a/tests/Unit/Composer/ModuleFinderTest.php +++ b/tests/Unit/Composer/ModuleFinderTest.php @@ -79,6 +79,7 @@ public function modulesWithoutBundlesDataProvider(): array */ private function buildMockPackagesWithModuleConfiguration(array $extrasSets): array { + /** @var PackageInterface[][] $moduleSets */ $moduleSets = []; foreach ($extrasSets as $packageName => $extrasSet) { $moduleSet = $this->buildSingleMockPackageWithModuleConfiguration($extrasSet); @@ -108,9 +109,9 @@ private function buildSingleMockPackageWithModuleConfiguration(array $extrasSet) * @param array $extras * @param string $packageName * - * @return PackageInterface|ProphecySubjectInterface + * @return ProphecySubjectInterface */ - private function buildPackageProphecyWithExtras(array $extras, string $packageName): PackageInterface + private function buildPackageProphecyWithExtras(array $extras, string $packageName): ProphecySubjectInterface { /** @var PackageInterface|ObjectProphecy $packageProphecy */ $packageProphecy = $this->prophesize(PackageInterface::class); diff --git a/tests/Unit/Composer/PackageRepositoryTest.php b/tests/Unit/Composer/PackageRepositoryTest.php index 29e532b..c05e359 100644 --- a/tests/Unit/Composer/PackageRepositoryTest.php +++ b/tests/Unit/Composer/PackageRepositoryTest.php @@ -36,7 +36,7 @@ class PackageRepositoryTest extends TestCase private $composer = null; /** - * @var WritableRepositoryInterface|ProphecySubjectInterface + * @var WritableRepositoryInterface|ObjectProphecy */ private $localRepositoryProphecy = null; @@ -111,7 +111,7 @@ public function findAllExcludesDuplicates() /** @var PackageInterface|ObjectProphecy $dependencyAliasProphecy */ $dependencyAliasProphecy = $this->prophesize(PackageInterface::class); $dependencyAliasProphecy->getName()->willReturn($packageName); - /** @var PackageInterface|ProphecySubjectInterface $dependency1 */ + /** @var PackageInterface|ProphecySubjectInterface $dependencyAlias */ $dependencyAlias = $dependencyAliasProphecy->reveal(); $this->localRepositoryProphecy->getPackages()->willReturn([$dependency, $dependencyAlias]);