Skip to content

Commit 4215d17

Browse files
authored
run dependency analysis (#218)
1 parent 8f85300 commit 4215d17

File tree

10 files changed

+64
-9
lines changed

10 files changed

+64
-9
lines changed

.github/workflows/code_analysis.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ jobs:
3232
name: 'Tests'
3333
run: vendor/bin/phpunit
3434

35+
-
36+
name: 'Composer Dependency Analysis'
37+
run: vendor/bin/composer-dependency-analyser
38+
3539
-
3640
name: 'Check Active Classes'
3741
run: vendor/bin/class-leak check src --ansi

composer-dependency-analyser.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,27 @@
55
use ShipMonk\ComposerDependencyAnalyser\Config\Configuration;
66
use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType;
77

8-
return (new Configuration())->addPathToScan(__DIR__ . '/src', false)
8+
return (new Configuration())
99
->addPathToExclude(__DIR__ . '/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture')
1010
->addPathToExclude(__DIR__ . '/tests/Rules/Enum/RequireUniqueEnumConstantRule/Fixture')
1111
->addPathToExclude(__DIR__ . '/tests/Rules/ForbiddenExtendOfNonAbstractClassRule/Fixture')
1212
->addPathToExclude(__DIR__ . '/tests/Rules/PHPUnit/NoTestMocksRule/Fixture')
1313

14+
// optional classes
15+
->ignoreUnknownClasses(['Symfony\Component\ExpressionLanguage\Expression'])
16+
1417
// already in phpstan/phpstan
1518
->ignoreErrorsOnPackage('nikic/php-parser', [ErrorType::DEV_DEPENDENCY_IN_PROD])
19+
->ignoreErrorsOnPackage('symfony/routing', [ErrorType::SHADOW_DEPENDENCY])
20+
->ignoreErrorsOnPackage('symfony/var-dumper', [ErrorType::SHADOW_DEPENDENCY])
21+
->ignoreErrorsOnPackage('symfony/service-contracts', [ErrorType::SHADOW_DEPENDENCY])
22+
->ignoreErrorsOnPackage('symfony/http-kernel', [ErrorType::SHADOW_DEPENDENCY])
23+
->ignoreErrorsOnPackage('symfony/event-dispatcher', [ErrorType::SHADOW_DEPENDENCY])
24+
->ignoreErrorsOnPackage('symfony/deprecation-contracts', [ErrorType::SHADOW_DEPENDENCY])
25+
->ignoreErrorsOnPackage('symfony/dependency-injection', [ErrorType::SHADOW_DEPENDENCY])
26+
->ignoreErrorsOnPackage('symfony/config', [ErrorType::SHADOW_DEPENDENCY])
1627

1728
// rule that runs on Rector rule only
1829
->ignoreErrorsOnPackage('rector/rector', [ErrorType::DEV_DEPENDENCY_IN_PROD])
1930

20-
->ignoreErrorsOnExtension('ext-ctype', [ErrorType::SHADOW_DEPENDENCY])
2131
->ignoreErrorsOnExtension('ext-simplexml', [ErrorType::SHADOW_DEPENDENCY]);
22-
23-
// ->ignoreErrorsOnPath('/Fixture/', [\ShipMonk\ComposerDependencyAnalyser\Config\ErrorType::UNKNOWN_CLASS]);

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
},
3838
"classmap": [
3939
"stubs"
40+
],
41+
"files": [
42+
"vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php"
4043
]
4144
},
4245
"config": {

src/Rules/PHPUnit/NoMockObjectAndRealObjectPropertyRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use PHPStan\Rules\Rule;
1414
use PHPStan\Rules\RuleError;
1515
use PHPStan\Rules\RuleErrorBuilder;
16-
use PHPUnit\Framework\MockObject\MockObject;
16+
use Symplify\PHPStanRules\Enum\ClassName;
1717
use Symplify\PHPStanRules\Enum\RuleIdentifier\PHPUnitRuleIdentifier;
1818

1919
/**
@@ -46,7 +46,7 @@ public function processNode(Node $node, Scope $scope): array
4646
continue;
4747
}
4848

49-
if ($type->toString() !== MockObject::class) {
49+
if ($type->toString() !== ClassName::MOCK_OBJECT_CLASS) {
5050
continue;
5151
}
5252

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Doctrine\ODM\MongoDB\Event;
4+
5+
class OnFlushEventArgs
6+
{
7+
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Doctrine\ORM;
4+
5+
class EntityManager implements EntityManagerInterface
6+
{
7+
public function getRepository(string $class): object
8+
{
9+
}
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\Form\Event;
4+
5+
class PostSubmitEvent
6+
{
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\Security\Http\Firewall;
4+
5+
abstract class AbstractListener
6+
{
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Symfony\Component\Security\Http\Firewall;
4+
5+
class UsernamePasswordFormAuthenticationListener
6+
{
7+
8+
}

tests/Rules/Symfony/NoListenerWithoutContractRule/Fixture/SkipAnotherSecurityListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Symplify\PHPStanRules\Tests\Rules\Symfony\NoListenerWithoutContractRule\Fixture;
44

5-
final class SkipAnotherSecurityListener extends
6-
\Symfony\Component\Security\Http\Firewall\UsernamePasswordFormAuthenticationListener
7-
{
5+
use Symfony\Component\Security\Http\Firewall\UsernamePasswordFormAuthenticationListener;
86

7+
final class SkipAnotherSecurityListener extends UsernamePasswordFormAuthenticationListener
8+
{
99
}

0 commit comments

Comments
 (0)