Skip to content

Commit 632c227

Browse files
author
Влaдислaв Новиков
committed
Fix: addressed MR comments — fixed Psalm issues and re-ran PHP-CS-Fixer
1 parent b951626 commit 632c227

15 files changed

Lines changed: 49 additions & 66 deletions

File tree

.github/workflows/cs.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
name: PHP-CS-Fixer Check
1+
on:
2+
push:
3+
branches:
4+
- '*'
25

3-
on: [push, pull_request]
6+
name: Fix Code Style
47

58
jobs:
6-
phpcsfixer:
7-
runs-on: ubuntu-latest
8-
9-
steps:
10-
- uses: actions/checkout@v3
11-
12-
- name: Setup PHP
13-
uses: shivammathur/setup-php@v2
14-
with:
15-
php-version: '8.1'
16-
17-
- name: Install dependencies
18-
run: composer install --no-progress --no-suggest --prefer-dist
19-
20-
- name: Run PHP-CS-Fixer dry run
21-
run: |
22-
vendor/bin/php-cs-fixer fix --dry-run -v --diff
9+
cs-fix:
10+
permissions:
11+
contents: write
12+
uses: spiral/gh-actions/.github/workflows/cs-fix.yml@master

.github/workflows/phpunit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ jobs:
1313
os: >-
1414
['ubuntu-latest']
1515
php: >-
16-
['8.1', '8.2', '8.3']
16+
['8.1', '8.2', '8.3', '8.4']
1717
stability: >-
1818
['prefer-lowest', 'prefer-stable']

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ docs
1010
vendor
1111
node_modules
1212
.php-cs-fixer.cache
13-
/runtime/php-cs-fixer.cache
13+
/runtime

.php-cs-fixer.dist.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66

77
require_once 'vendor/autoload.php';
88

9+
910
return Builder::create()
1011
->include(__DIR__ . '/src')
1112
->include(__FILE__)
12-
->build();
13+
->build()->setRules([
14+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
15+
'fully_qualified_strict_types' => true,
16+
'no_unused_imports' => true,
17+
]);

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
[![Total Downloads](https://poser.pugx.org/roadrunner-php/version-checker/downloads)](https://packagist.org/roadrunner-php/version-checker/phpunit)
99
<a href="https://discord.gg/8bZsjYhVVk"><img src="https://img.shields.io/badge/discord-chat-magenta.svg"></a>
1010

11-
## Requirements
12-
13-
Make sure that your server is configured with following PHP version and extensions:
14-
15-
- PHP 8.1+
16-
1711
## Installation
1812

1913
You can install the package via composer:

composer.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
"symfony/process": "^5.4 || ^6.0 || ^7.0"
1616
},
1717
"require-dev": {
18-
"friendsofphp/php-cs-fixer": "^3.8",
1918
"phpcompatibility/php-compatibility": "^9.3",
2019
"phpunit/phpunit": "^9.6 || ^10.0",
2120
"spiral/code-style": "^2.2",
22-
"vimeo/psalm": "^5.9"
21+
"vimeo/psalm": "^6.0"
2322
},
2423
"autoload": {
2524
"psr-4": {
@@ -34,7 +33,6 @@
3433
"scripts": {
3534
"test": "vendor/bin/phpunit",
3635
"psalm": "vendor/bin/psalm --config=psalm.xml ./src",
37-
"cs": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -vvv --dry-run --using-cache=no",
3836
"cs:diff": "php-cs-fixer fix --dry-run -v --diff",
3937
"cs:fix": "php-cs-fixer fix -v"
4038
},

psalm.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,4 @@
1313
<directory name="vendor" />
1414
</ignoreFiles>
1515
</projectFiles>
16-
<issueHandlers>
17-
<UndefinedAttributeClass>
18-
<errorLevel type="suppress">
19-
<referencedClass name="JetBrains\PhpStorm\ExpectedValues" />
20-
</errorLevel>
21-
</UndefinedAttributeClass>
22-
</issueHandlers>
2316
</psalm>

src/Composer/Package.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,34 @@ final class Package implements PackageInterface
1111
{
1212
/**
1313
* @param non-empty-string $packageName
14-
* @return non-empty-string[]
14+
*
15+
* @return string[]
16+
*
17+
* @psalm-return list<non-empty-string>
1518
*/
19+
#[\Override]
1620
public function getRequiredVersions(string $packageName): array
1721
{
1822
$versions = [];
1923
foreach (InstalledVersions::getInstalledPackages() as $package) {
2024
$path = InstalledVersions::getInstallPath($package);
2125
if ($path !== null && \file_exists($path . '/composer.json')) {
2226
/** @var array{require?: array<non-empty-string, non-empty-string>} $composerJson */
23-
$composerJson = \json_decode(\file_get_contents($path . '/composer.json'), true);
27+
$fileContent = \file_get_contents($path . '/composer.json');
28+
/** @var array<string, mixed>|null $composerJson */
29+
$composerJson = $fileContent === false ? null : \json_decode($fileContent, true);
30+
31+
if (isset($composerJson['require'][$packageName])) {
32+
/** @var mixed $rawPackage */
33+
$rawPackage = $composerJson['require'][$packageName];
34+
35+
if (is_string($rawPackage) && strlen($rawPackage) > 0) {
36+
assert($rawPackage !== '');
2437

25-
if (
26-
isset($composerJson['require'][$packageName]) &&
27-
$this->isSupportedVersion($composerJson['require'][$packageName])
28-
) {
29-
$versions[] = $this->getMinVersion($composerJson['require'][$packageName]);
38+
if ($this->isSupportedVersion($rawPackage)) {
39+
$versions[] = $this->getMinVersion($rawPackage);
40+
}
41+
}
3042
}
3143
}
3244
}

src/Environment/Native.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public function __construct(
1515
/**
1616
* @param non-empty-string $name
1717
*/
18+
#[\Override]
1819
public function get(string $name, mixed $default = null): mixed
1920
{
2021
return $this->values[$name] ?? $default;

src/Exception/UnsupportedVersionException.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,4 @@ public function __construct(
1818
) {
1919
parent::__construct($message);
2020
}
21-
22-
/**
23-
* @return non-empty-string
24-
*/
25-
public function getInstalledVersion(): string
26-
{
27-
return $this->installed;
28-
}
29-
30-
/**
31-
* @return non-empty-string
32-
*/
33-
public function getRequestedVersion(): string
34-
{
35-
return $this->requested;
36-
}
3721
}

0 commit comments

Comments
 (0)