Skip to content

Commit

Permalink
Drop Psalm in favor of PHPStan
Browse files Browse the repository at this point in the history
As per the decision we made during the hackathon.
  • Loading branch information
greg0ire committed Dec 8, 2024
1 parent 33a9d71 commit d023b3a
Show file tree
Hide file tree
Showing 14 changed files with 828 additions and 107 deletions.
36 changes: 9 additions & 27 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,15 @@ on:
pull_request:
branches:
- "*.x"
paths:
- .github/workflows/static-analysis.yml
- composer.*
- config/**
- src/**
- phpstan*
- tests/StaticAnalysis/**
push:

jobs:
static-analysis-psalm:
name: "Static Analysis with Psalm"
runs-on: "ubuntu-20.04"

strategy:
matrix:
php-version:
- "8.2"

steps:
- name: "Checkout code"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"

- name: "Set minimum-stability to stable in Composer"
run: "composer config minimum-stability stable"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v3"

- name: "Run a static analysis with vimeo/psalm"
run: "vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc) --php-version=${{ matrix.php-version }}"
static-analysis:
uses: "doctrine/.github/.github/workflows/[email protected]"
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@
"require-dev": {
"doctrine/coding-standard": "^11.0",
"doctrine/data-fixtures": "^1.7",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^9.5.5",
"psalm/plugin-symfony": "^5.0",
"symfony/browser-kit": "^6.4 || ^7.0",
"symfony/form": "^6.4 || ^7.0",
"symfony/phpunit-bridge": "^6.4.1 || ^7.0.1",
"symfony/security-bundle": "^6.4 || ^7.0",
"symfony/stopwatch": "^6.4 || ^7.0",
"symfony/validator": "^6.4 || ^7.0",
"symfony/yaml": "^6.4 || ^7.0",
"vimeo/psalm": "^5.25"
"symfony/yaml": "^6.4 || ^7.0"
},
"conflict": {
"doctrine/data-fixtures": "<1.3"
Expand Down
799 changes: 799 additions & 0 deletions phpstan-baseline.neon

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
includes:
- phpstan-baseline.neon

parameters:
phpVersion: 80400
level: 7
paths:
- config
- src
- tests
34 changes: 0 additions & 34 deletions psalm-baseline.xml

This file was deleted.

23 changes: 0 additions & 23 deletions psalm.xml

This file was deleted.

2 changes: 0 additions & 2 deletions src/CacheWarmer/HydratorCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
* since this information is necessary to build the hydrators in the first place.
*
* @internal
*
* @psalm-suppress ContainerDependency
*/
class HydratorCacheWarmer implements CacheWarmerInterface
{
Expand Down
2 changes: 0 additions & 2 deletions src/CacheWarmer/PersistentCollectionCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
* since this information is necessary to build the persistent collections in the first place.
*
* @internal
*
* @psalm-suppress ContainerDependency
*/
class PersistentCollectionCacheWarmer implements CacheWarmerInterface
{
Expand Down
2 changes: 0 additions & 2 deletions src/CacheWarmer/ProxyCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
* since this information is necessary to build the proxies in the first place.
*
* @internal
*
* @psalm-suppress ContainerDependency
*/
class ProxyCacheWarmer implements CacheWarmerInterface
{
Expand Down
3 changes: 0 additions & 3 deletions src/DependencyInjection/DoctrineMongoDBExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ protected function loadConnections(array $connections, ContainerBuilder $contain

private function loadMessengerServices(ContainerBuilder $container, FileLoader $loader): void
{
/** @psalm-suppress UndefinedClass Optional dependency */
if (! interface_exists(MessageBusInterface::class) || ! class_exists(DoctrineClearEntityManagerWorkerSubscriber::class)) {
return;
}
Expand Down Expand Up @@ -568,8 +567,6 @@ public function getXsdValidationBasePath(): string
* Loads a cache driver.
*
* @throws InvalidArgumentException
*
* @psalm-suppress UndefinedClass this won't be necessary when removing metadata cache configuration
*/
protected function loadCacheDriver(string $cacheName, string $objectManagerName, array $cacheDriver, ContainerBuilder $container): string
{
Expand Down
14 changes: 7 additions & 7 deletions src/Repository/ContainerRepositoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public function __construct(private ContainerInterface $container)
}

/**
* @psalm-param class-string<T> $documentName
* @phpstan-param class-string<T> $documentName
*
* @psalm-return ObjectRepository<T>
* @phpstan-return ObjectRepository<T>
*
* @template T of object
*/
Expand Down Expand Up @@ -73,27 +73,27 @@ public function getRepository(DocumentManager $documentManager, string $document
}

/**
* @psalm-param ClassMetadata<T> $metadata
* @phpstan-param ClassMetadata<T> $metadata
*
* @psalm-return ObjectRepository<T>
* @phpstan-return ObjectRepository<T>
*
* @template T of object
*/
private function getOrCreateRepository(DocumentManager $documentManager, ClassMetadata $metadata): ObjectRepository
{
$repositoryHash = $metadata->getName() . spl_object_hash($documentManager);
if (isset($this->managedRepositories[$repositoryHash])) {
/** @psalm-var ObjectRepository<T> */
/** @phpstan-var ObjectRepository<T> */
return $this->managedRepositories[$repositoryHash];
}

if ($metadata->customRepositoryClassName) {
$repositoryClassName = $metadata->customRepositoryClassName;
} elseif ($metadata->isFile) {
/** @psalm-var class-string<GridFSRepository<T>> $repositoryClassName */
/** @phpstan-var class-string<GridFSRepository<T>> $repositoryClassName */
$repositoryClassName = $documentManager->getConfiguration()->getDefaultGridFSRepositoryClassName();
} else {
/** @psalm-var class-string<ObjectRepository<T>> $repositoryClassName */
/** @phpstan-var class-string<ObjectRepository<T>> $repositoryClassName */
$repositoryClassName = $documentManager->getConfiguration()->getDefaultDocumentRepositoryClassName();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Repository/ServiceRepositoryTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait ServiceRepositoryTrait
/**
* @param ManagerRegistry $registry The ManagerRegistry to use
* @param string $documentClass The class name of the entity this repository manages
* @psalm-param class-string<T> $documentClass
* @phpstan-param class-string<T> $documentClass
*/
public function __construct(ManagerRegistry $registry, string $documentClass)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ abstract class AbstractMongoDBExtensionTestCase extends TestCase
{
abstract protected function loadFromFile(ContainerBuilder $container, string $file): void;

/** @psalm-suppress UndefinedClass this won't be necessary when removing metadata cache configuration */
public function testDependencyInjectionConfigurationDefaults(): void
{
$container = $this->getContainer();
Expand Down Expand Up @@ -335,7 +334,6 @@ public function testDocumentManagerMetadataCacheDriverConfiguration(): void
$this->assertEquals(ApcuAdapter::class, $definition->getClass());
}

/** @psalm-suppress UndefinedClass this won't be necessary when removing metadata cache configuration */
public function testDocumentManagerMemcachedMetadataCacheDriverConfiguration(): void
{
$container = $this->getContainer();
Expand Down
1 change: 0 additions & 1 deletion tests/DependencyInjection/DoctrineMongoDBExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ public function testPublicServicesAndAliases(): void

public function testMessengerIntegration(): void
{
/** @psalm-suppress UndefinedClass Optional dependency */
if (! interface_exists(MessageBusInterface::class)) {
$this->markTestSkipped('Symfony Messenger component is not installed');
}
Expand Down

0 comments on commit d023b3a

Please sign in to comment.