Skip to content

Commit

Permalink
Merge pull request #846 from driehle/upgrade-phpstan
Browse files Browse the repository at this point in the history
Upgrade PHPStan from 1.12 to 2.0
  • Loading branch information
driehle authored Dec 24, 2024
2 parents e2a43ac + b351993 commit 878f512
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 18 deletions.
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@
},
"require-dev": {
"doctrine/coding-standard": "^12.0.0",
"doctrine/mongodb-odm": "^2.5.0",
"doctrine/orm": "^2.13.4",
"jangregor/phpstan-prophecy": "^1.0.0",
"laminas/laminas-i18n": "^2.17.0",
"laminas/laminas-log": "^2.15.3",
"laminas/laminas-serializer": "^2.13.0",
"laminas/laminas-session": "^2.13.0",
"doctrine/mongodb-odm": "^2.7.1",
"doctrine/orm": "^2.20.1",
"jangregor/phpstan-prophecy": "^2",
"laminas/laminas-i18n": "^2.29.0",
"laminas/laminas-log": "^2.17.1",
"laminas/laminas-serializer": "^2.17.0",
"laminas/laminas-session": "^2.22.1",
"phpdocumentor/guides-cli": "^1.5.0",
"phpstan/phpstan": "^1.9.2",
"phpstan/phpstan-phpunit": "^1.3.0",
"phpstan/phpstan": "^2.0.4",
"phpstan/phpstan-phpunit": "^2.0.3",
"phpunit/phpunit": "^10.5.40",
"predis/predis": "^1.1.10"
},
Expand Down
6 changes: 5 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
parameters:
level: 6
checkGenericClassInNonGenericObjectType: false
treatPhpDocTypesAsCertain: false
paths:
- src
- tests
ignoreErrors:
-
identifier: missingType.generics
-
identifier: method.alreadyNarrowedType
-
message: '#internal(G|S)etItem\(\) has parameter \$(casToken|value) with no type specified#'
path: src/Cache/DoctrineCacheStorage.php
Expand Down
2 changes: 2 additions & 0 deletions src/Cache/DoctrineCacheStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function __construct($options, protected Cache $cache)

/**
* {@inheritDoc}
*
* @param-out bool $success
*/
protected function internalGetItem(&$normalizedKey, &$success = null, &$casToken = null)
{
Expand Down
6 changes: 1 addition & 5 deletions tests/Form/Element/ProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
use function array_shift;
use function func_get_args;

use const PHP_VERSION_ID;

/**
* Tests for the Collection pagination adapter
*
Expand Down Expand Up @@ -279,9 +277,7 @@ public function testExceptionThrownForNonCallableLabelGenerator(): void
'TypeError',
);
$this->expectExceptionMessage(
PHP_VERSION_ID >= 80000
? 'DoctrineModule\Form\Element\Proxy::setLabelGenerator(): Argument #1 ($callable) must be of type callable'
: 'Argument 1 passed to DoctrineModule\Form\Element\Proxy::setLabelGenerator() must be callable',
'DoctrineModule\Form\Element\Proxy::setLabelGenerator(): Argument #1 ($callable) must be of type callable',
);

$this->proxy->setOptions(['label_generator' => 'I throw an invalid type error']);
Expand Down
25 changes: 25 additions & 0 deletions tests/Persistence/ProvidesObjectManagerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace DoctrineModuleTest\Persistence;

use Doctrine\Persistence\ObjectManager;
use DoctrineModuleTest\Persistence\TestAsset\DummyObjectManagerProvider;
use PHPUnit\Framework\TestCase as BaseTestCase;

/**
* Test for {@see \DoctrineModule\Persistence\ProvidesObjectManager}
*/
class ProvidesObjectManagerTest extends BaseTestCase
{
public function testSetAndGetObjectManager(): void
{
$objectManager = $this->createMock(ObjectManager::class);
$dummy = new DummyObjectManagerProvider();
$dummy->setObjectManager($objectManager);
$retrieved = $dummy->getObjectManager();

$this->assertSame($objectManager, $retrieved);
}
}
12 changes: 12 additions & 0 deletions tests/Persistence/TestAsset/DummyObjectManagerProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace DoctrineModuleTest\Persistence\TestAsset;

use DoctrineModule\Persistence\ProvidesObjectManager;

class DummyObjectManagerProvider
{
use ProvidesObjectManager;
}
3 changes: 0 additions & 3 deletions tests/Service/DriverFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
use Laminas\ServiceManager\ServiceManager;
use PHPUnit\Framework\TestCase as BaseTestCase;

use function assert;

/**
* Base test case to be used when a service manager instance is required
*/
Expand Down Expand Up @@ -67,7 +65,6 @@ public function testCreateDriverChain(): void
$factory = new DriverFactory('testChainDriver');
$driver = $factory->__invoke($serviceManager, MappingDriverChain::class);
$this->assertInstanceOf(MappingDriverChain::class, $driver);
assert($driver instanceof MappingDriverChain);

$drivers = $driver->getDrivers();
$this->assertCount(1, $drivers);
Expand Down

0 comments on commit 878f512

Please sign in to comment.