Skip to content

Commit cda58ca

Browse files
Removes psalm as dev dependency and use it as a phar (#450)
* uses psalm as phar and bump it to version 6 * fixes new errors detected by psalm * update phpunit.xml configuration from 7 to 9
1 parent d4a6463 commit cda58ca

File tree

14 files changed

+67
-29
lines changed

14 files changed

+67
-29
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
run: PHP_CS_FIXER_IGNORE_ENV=1 ./bin/php-cs-fixer fix --dry-run -v
4747

4848
- name: Static Analysis
49-
run: ./bin/psalm
49+
run: ./bin/psalm.phar
5050

5151
- name: Test
5252
run: ./bin/phpunit -d memory_limit=-1 --coverage-clover clover.xml

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
/web
77
/bin/
88
!/bin/box.phar
9+
!/bin/psalm.phar
910
phparkitect.phar
1011
composer.lock
1112
.php-version
1213
composer.phar
14+
.phpunit.cache/

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ csfix: ## it launches cs fix
3636
bin/php-cs-fixer fix -v
3737

3838
psalm: ## it launches psalm
39-
bin/psalm
39+
bin/psalm.phar
4040

4141
build: ## it launches all the build
4242
composer install

bin/psalm.phar

12.1 MB
Binary file not shown.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"require-dev": {
3838
"roave/security-advisories": "dev-master",
3939
"symfony/var-dumper": "^3.0|^4.0|^5.0|^6.0|^7.0",
40-
"vimeo/psalm": "^4.6",
4140
"phpunit/phpunit": "^7.5|^9.0|^10.0",
4241
"mikey179/vfsstream": "^1.6",
4342
"phpspec/prophecy": "^1.10",
@@ -55,7 +54,8 @@
5554
}
5655
},
5756
"config": {
58-
"bin-dir": "bin"
57+
"bin-dir": "bin",
58+
"sort-packages": true
5959
},
6060
"bin": [
6161
"bin-stub/phparkitect"

phpunit.xml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
5-
beStrictAboutCoversAnnotation="true"
5+
cacheResultFile=".phpunit.cache/test-results"
6+
executionOrder="depends,defects"
7+
forceCoversAnnotation="false"
8+
beStrictAboutCoversAnnotation="false"
69
beStrictAboutOutputDuringTests="true"
710
beStrictAboutTodoAnnotatedTests="true"
11+
convertDeprecationsToExceptions="true"
12+
failOnRisky="false"
13+
failOnWarning="true"
814
verbose="true">
9-
1015
<testsuites>
1116
<testsuite name="default">
1217
<directory>tests</directory>
1318
</testsuite>
1419
</testsuites>
1520

16-
<filter>
17-
<whitelist processUncoveredFilesFromWhitelist="true">
21+
<coverage cacheDirectory=".phpunit.cache/code-coverage"
22+
processUncoveredFiles="true">
23+
<include>
1824
<directory suffix=".php">src</directory>
19-
</whitelist>
20-
</filter>
25+
</include>
26+
</coverage>
2127
</phpunit>

psalm.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xmlns="https://getpsalm.org/schema/config"
66
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
7-
7+
findUnusedCode="false"
8+
findUnusedBaselineEntry="false"
89
allowStringToStandInForClass="true"
910
>
1011
<projectFiles>

src/Analyzer/ClassDescription.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace Arkitect\Analyzer;
@@ -46,6 +47,7 @@ class ClassDescription
4647
* @param list<FullyQualifiedClassName> $interfaces
4748
* @param ?FullyQualifiedClassName $extends
4849
* @param list<FullyQualifiedClassName> $attributes
50+
* @param list<string> $docBlock
4951
*/
5052
public function __construct(
5153
FullyQualifiedClassName $FQCN,

src/Analyzer/FileVisitor.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace Arkitect\Analyzer;
@@ -30,7 +31,7 @@ public function enterNode(Node $node): void
3031

3132
foreach ($node->implements as $interface) {
3233
$this->classDescriptionBuilder
33-
->addInterface($interface->toString(), $interface->getLine());
34+
->addInterface($interface->toString(), $interface->getLine());
3435
}
3536

3637
if (!$node->isAnonymous() && null !== $node->extends) {
@@ -76,7 +77,8 @@ public function enterNode(Node $node): void
7677
*
7778
* @see FileVisitorTest::test_it_should_return_errors_for_const_outside_namespace
7879
*/
79-
if ($node instanceof Node\Expr\ClassConstFetch
80+
if (
81+
$node instanceof Node\Expr\ClassConstFetch
8082
&& method_exists($node->class, 'toString')
8183
) {
8284
if ($this->isSelfOrStaticOrParent($node->class->toString())) {
@@ -93,7 +95,8 @@ public function enterNode(Node $node): void
9395
*
9496
* @see FileVisitorTest::test_should_returns_all_dependencies
9597
*/
96-
if ($node instanceof Node\Expr\StaticCall
98+
if (
99+
$node instanceof Node\Expr\StaticCall
97100
&& method_exists($node->class, 'toString')
98101
) {
99102
if ($this->isSelfOrStaticOrParent($node->class->toString())) {
@@ -104,7 +107,8 @@ public function enterNode(Node $node): void
104107
->addDependency(new ClassDependency($node->class->toString(), $node->getLine()));
105108
}
106109

107-
if ($node instanceof Node\Expr\Instanceof_
110+
if (
111+
$node instanceof Node\Expr\Instanceof_
108112
&& method_exists($node->class, 'toString')
109113
) {
110114
if ($this->isSelfOrStaticOrParent($node->class->toString())) {
@@ -114,11 +118,13 @@ public function enterNode(Node $node): void
114118
->addDependency(new ClassDependency($node->class->toString(), $node->getLine()));
115119
}
116120

117-
if ($node instanceof Node\Expr\New_
121+
if (
122+
$node instanceof Node\Expr\New_
118123
&& !($node->class instanceof Node\Expr\Variable)
119124
) {
120-
if ((method_exists($node->class, 'isAnonymous') && $node->class->isAnonymous())
121-
|| !method_exists($node->class, 'toString')) {
125+
if ((method_exists($node->class, 'isAnonymous') && true === $node->class->isAnonymous())
126+
|| !method_exists($node->class, 'toString')
127+
) {
122128
return;
123129
}
124130

@@ -215,7 +221,7 @@ public function enterNode(Node $node): void
215221
$returnType = $node->returnType;
216222
if ($returnType instanceof Node\Name\FullyQualified) {
217223
$this->classDescriptionBuilder
218-
->addDependency(new ClassDependency($returnType->toString(), $returnType->getLine()));
224+
->addDependency(new ClassDependency($returnType->toString(), $returnType->getLine()));
219225
}
220226
}
221227
}
@@ -271,7 +277,7 @@ private function addParamDependency(Node\Param $node): void
271277
$type = $nullableType->type;
272278
}
273279

274-
if (method_exists($type, 'isSpecialClassName') && $type->isSpecialClassName()) {
280+
if (method_exists($type, 'isSpecialClassName') && true === $type->isSpecialClassName()) {
275281
return;
276282
}
277283

src/CLI/Command/Check.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9797
$startTime = microtime(true);
9898

9999
try {
100-
$verbose = $input->getOption('verbose');
101-
$stopOnFailure = $input->getOption(self::STOP_ON_FAILURE_PARAM);
102-
$useBaseline = $input->getOption(self::USE_BASELINE_PARAM);
103-
$skipBaseline = $input->getOption(self::SKIP_BASELINE_PARAM);
104-
$ignoreBaselineLinenumbers = $input->getOption(self::IGNORE_BASELINE_LINENUMBERS_PARAM);
100+
$verbose = (bool) $input->getOption('verbose');
101+
$stopOnFailure = (bool) $input->getOption(self::STOP_ON_FAILURE_PARAM);
102+
$useBaseline = (string) $input->getOption(self::USE_BASELINE_PARAM);
103+
$skipBaseline = (bool) $input->getOption(self::SKIP_BASELINE_PARAM);
104+
$ignoreBaselineLinenumbers = (bool) $input->getOption(self::IGNORE_BASELINE_LINENUMBERS_PARAM);
105105

106106
if (true !== $skipBaseline && !$useBaseline && file_exists(self::DEFAULT_BASELINE_FILENAME)) {
107107
$useBaseline = self::DEFAULT_BASELINE_FILENAME;

0 commit comments

Comments
 (0)