Skip to content

Commit 14aa2f6

Browse files
committed
fix: #140 Add PHPStan and update code to meet level 0
Adding one exception since it's not a quick-fix.
1 parent e9a793c commit 14aa2f6

6 files changed

Lines changed: 22 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/composer.lock
2+
/phpstan.neon
23
/vendor

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@
3737
"composer/composer": "^2.9",
3838
"phpunit/phpunit": "^9.5",
3939
"symfony/process": "^6",
40-
"dms/phpunit-arraysubset-asserts": "^0.5.0"
40+
"dms/phpunit-arraysubset-asserts": "^0.5.0",
41+
"phpstan/phpstan": "^2.1"
4142
},
4243
"scripts": {
44+
"phpstan": "phpstan",
4345
"test": [
4446
"phpunit ./tests --debug"
4547
]

phpstan-baseline.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Instantiated class Tuf\\Tests\\FixtureBuilder\\Fixture not found\.$#'
5+
identifier: class.notFound
6+
count: 1
7+
path: tests/FunctionalTestBase.php

phpstan.neon.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
4+
parameters:
5+
level: 0
6+
paths:
7+
- src
8+
- tests

src/ComposerFileStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ComposerFileStorage extends FileStorage
1414
/**
1515
* {@inheritDoc}
1616
*/
17-
public function __construct(string $basePath)
17+
final public function __construct(string $basePath)
1818
{
1919
(new Filesystem())->ensureDirectoryExists($basePath);
2020
parent::__construct($basePath);

tests/FunctionalTestBase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ protected function setUp(): void
4040
mkdir($this->workingDir . '/tuf', recursive: true);
4141

4242
// Make PHP-TUF's fixture builder available.
43+
// @TODO: Consider moving the fixture builder to its own library that
44+
// both php-tuf and composer-integration can pull in via require-dev.
4345
$loaders = ClassLoader::getRegisteredLoaders();
4446
reset($loaders)->addPsr4('Tuf\\Tests\\', key($loaders) . '/php-tuf/php-tuf/tests');
4547

0 commit comments

Comments
 (0)