Skip to content

Commit ed20138

Browse files
authored
Merge pull request #2 from phug-php/fix/lint-jobs
Update lint jobs
2 parents 623bfb7 + 7e814ca commit ed20138

23 files changed

Lines changed: 89 additions & 59 deletions

.github/workflows/coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
if: steps.composer-cache.outputs.cache-hit != 'true'
4242
run: |
4343
composer config version 1.9.0
44+
composer remove --no-update --dev phan/phan friendsofphp/php-cs-fixer nette/utils phpmd/phpmd phpstan/phpstan squizlabs/php_codesniffer vimeo/psalm
4445
composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress ${{ matrix.php >= 8.1 && '--ignore-platform-req=php' || '' }}
4546
4647
- name: Prepare git config

.github/workflows/phan.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ jobs:
3838
3939
- name: Install dependencies
4040
if: steps.composer-cache.outputs.cache-hit != 'true'
41-
run: composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress
41+
run: |
42+
composer remove --no-update --dev phpunit/phpunit friendsofphp/php-cs-fixer nette/utils phpmd/phpmd phpstan/phpstan squizlabs/php_codesniffer vimeo/psalm
43+
composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress
4244
4345
- name: Check style with Phan
4446
run: composer run-script phan

.github/workflows/phpcs.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ jobs:
3232
uses: actions/cache@v4
3333
with:
3434
path: vendor
35-
key: style-${{ runner.os }}-${{ matrix.setup }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
35+
key: cs-${{ runner.os }}-${{ matrix.setup }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
3636
restore-keys: |
37-
style-${{ runner.os }}-${{ matrix.setup }}-${{ matrix.php }}-
37+
cs-${{ runner.os }}-${{ matrix.setup }}-${{ matrix.php }}-
3838
3939
- name: Install dependencies
4040
if: steps.composer-cache.outputs.cache-hit != 'true'
41-
run: composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress
41+
run: |
42+
composer remove --no-update --dev phpunit/phpunit phan/phan friendsofphp/php-cs-fixer nette/utils phpmd/phpmd phpstan/phpstan vimeo/psalm
43+
composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress
4244
4345
- name: Check style with PHPCS
4446
run: composer run-script phpcs

.github/workflows/phpcsf.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ jobs:
3232
uses: actions/cache@v4
3333
with:
3434
path: vendor
35-
key: style-${{ runner.os }}-${{ matrix.setup }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
35+
key: csf-${{ runner.os }}-${{ matrix.setup }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
3636
restore-keys: |
37-
style-${{ runner.os }}-${{ matrix.setup }}-${{ matrix.php }}-
37+
csf-${{ runner.os }}-${{ matrix.setup }}-${{ matrix.php }}-
3838
3939
- name: Install dependencies
4040
if: steps.composer-cache.outputs.cache-hit != 'true'
41-
run: composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress
41+
run: |
42+
composer remove --no-update --dev phpunit/phpunit phan/phan nette/utils phpmd/phpmd phpstan/phpstan squizlabs/php_codesniffer vimeo/psalm
43+
composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress
4244
4345
- name: Check style with phpcsf
4446
run: composer run-script phpcsf

.github/workflows/phpmd.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ jobs:
3838
3939
- name: Install dependencies
4040
if: steps.composer-cache.outputs.cache-hit != 'true'
41-
run: composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress
41+
run: |
42+
composer remove --no-update --dev phpunit/phpunit phan/phan friendsofphp/php-cs-fixer nette/utils phpstan/phpstan squizlabs/php_codesniffer vimeo/psalm
43+
composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress
4244
4345
- name: Check style with phpmd
4446
run: composer run-script phpmd

.github/workflows/psalm.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
php: ['8.2']
16+
php: ['8.4']
1717
setup: ['stable']
1818

1919
name: PHP ${{ matrix.php }} - ${{ matrix.setup }}
@@ -38,9 +38,8 @@ jobs:
3838
3939
- name: Install dependencies
4040
if: steps.composer-cache.outputs.cache-hit != 'true'
41-
# tests/use-fork.php because of https://github.com/vimeo/psalm/issues/8957
4241
run: |
43-
php tests/use-fork.php vimeo/psalm 5.14.2 https://github.com/kylekatarnls/psalm.git fix/datetime-inheritance-5.x
42+
composer remove --no-update --dev phan/phan phpunit/phpunit friendsofphp/php-cs-fixer nette/utils phpmd/phpmd phpstan/phpstan squizlabs/php_codesniffer
4443
composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress
4544
4645
- name: Check style with psalm

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
if: steps.composer-cache.outputs.cache-hit != 'true'
4646
run: |
4747
composer config version 1.9.0
48+
composer remove --no-update --dev phan/phan friendsofphp/php-cs-fixer nette/utils phpmd/phpmd phpstan/phpstan squizlabs/php_codesniffer vimeo/psalm
4849
composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress ${{ matrix.php >= 8.1 && '--ignore-platform-req=php' || '' }} --no-interaction
4950
5051
- name: Prepare git config

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
},
2828
"require-dev": {
2929
"friendsofphp/php-cs-fixer": "^2.15.0 || ^3.23.0",
30-
"nette/utils": "^3.2.10",
30+
"nette/utils": "^3.2.10 || ^4.1.3",
3131
"phan/phan": "^3.2.10 || ^5.4.2",
3232
"phpunit/phpunit": "^8.5.52 || ^9.6.34",
3333
"phpmd/phpmd": "^2.13.0",
3434
"phpstan/phpstan": "^0.11.15 || ^1.10.29",
3535
"squizlabs/php_codesniffer": "^3.7.2",
36-
"vimeo/psalm": "^4.30.0 || ^5.14.1"
36+
"vimeo/psalm": "^4.30.0 || ^5.14.1 || ^6.15.1"
3737
},
3838
"autoload": {
3939
"psr-4": {

psalm.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
<InternalProperty errorLevel="info" />
3333
<InternalClass errorLevel="info" />
3434

35+
<ClassMustBeFinal errorLevel="info" />
36+
<MissingOverrideAttribute errorLevel="info" />
37+
3538
<MissingClosureReturnType errorLevel="info" />
3639
<MissingReturnType errorLevel="info" />
3740
<MissingPropertyType errorLevel="info" />

src/Phug/Split/Command/Analyze.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Phug\Split\Command;
44

55
use Phug\Split;
6+
use Phug\Split\UnableToListDirectoryItems;
67
use SimpleCli\SimpleCli;
78
use Traversable;
89

@@ -66,7 +67,7 @@ protected function calculatePackagesTree(Split $cli): bool
6667
return $cli->error('Root project directory should contains a '.$this->composerFile.' file.');
6768
}
6869

69-
$data = (array) json_decode(file_get_contents($this->composerFile), true);
70+
$data = (array) json_decode((string) file_get_contents($this->composerFile), true);
7071
$vendorDirectory = ($data['config'] ?? [])['vendor-dir'] ?? 'vendor';
7172

7273
$cli->writeLine((string) $data['name']);
@@ -93,7 +94,7 @@ protected function getPackages(): iterable
9394

9495
protected function dumpPackagesTree(Split $cli, iterable $packages, int $level = 0): bool
9596
{
96-
$count = is_countable($packages) ? count($packages) : INF;
97+
$count = is_countable($packages) ? count($packages) : 0;
9798

9899
foreach ($packages as $index => $package) {
99100
$symbol = $index === $count - 1 ? '' : '';
@@ -106,7 +107,13 @@ protected function dumpPackagesTree(Split $cli, iterable $packages, int $level =
106107

107108
protected function mapDirectories(string $directory, callable $callback): iterable
108109
{
109-
foreach (scandir($directory) as $element) {
110+
$elements = scandir($directory);
111+
112+
if ($elements === false) {
113+
throw new UnableToListDirectoryItems($directory);
114+
}
115+
116+
foreach ($elements as $element) {
110117
if (substr($element, 0, 1) === '.') {
111118
continue;
112119
}
@@ -141,7 +148,7 @@ protected function scanDirectories(string $directory): iterable
141148
$composerPath = $directory.DIRECTORY_SEPARATOR.$this->composerFile;
142149

143150
if (file_exists($composerPath)) {
144-
$data = json_decode(file_get_contents($composerPath), true);
151+
$data = json_decode((string) file_get_contents($composerPath), true);
145152
$mainPackage = $this->getPackage($directory, $data);
146153
}
147154

0 commit comments

Comments
 (0)