Skip to content

Commit

Permalink
Raise the minimum PHP version to 8.1 (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored Dec 9, 2024
1 parent 04920a9 commit 239dcad
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0']
['8.1']
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
['8.0', '8.1', '8.2', '8.3']
['8.1', '8.2', '8.3']
2 changes: 1 addition & 1 deletion .github/workflows/composer-require-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0', '8.1', '8.2', '8.3']
['8.1', '8.2', '8.3']
8 changes: 0 additions & 8 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,3 @@ jobs:
['ubuntu-latest']
php: >-
['8.1', '8.2', '8.3']
psalm80:
uses: yiisoft/actions/.github/workflows/psalm.yml@master
with:
psalm-config: psalm80.xml
os: >-
['ubuntu-latest']
php: >-
['8.0']
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ composer.phar
# Mac DS_Store Files
.DS_Store

# phpunit itself is not needed
phpunit.phar
# local phpunit config
# PhpUnit
/phpunit.phar
/phpunit.xml
# phpunit cache
.phpunit.result.cache
/.phpunit.cache
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Chg #132: Move `di-web` configuration to `di` and allow to set publisher via parameters (@Gerych1984)
- Bug #123: `AssetManager` load empty `AssetBundle` when register wrong namespace bundle (@terabytesoftw)
- Enh #119, #129: Add debug collector for `yiisoft/yii-debug` (@xepozz, @vjik)
- Enh #148: Raise the minimum PHP version to 8.1 and minor refactoring (@vjik)

## 4.0.0 February 13, 2023

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ It helps resolve dependencies and get lists of files ready for generating HTML `

## Requirements

- PHP 8.0 or higher.
- PHP 8.1 or higher.
- `mbstring` PHP extension.

## Installation
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-mbstring": "*",
"psr/log": "^1.1|^2.0|^3.0",
"yiisoft/aliases": "^1.1|^2.0|^3.0",
"yiisoft/files": "^2.0",
"yiisoft/json": "^1.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.3",
"phpunit/phpunit": "^9.5",
"rector/rector": "^1.0",
"roave/infection-static-analysis-plugin": "^1.25|^1.31",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.20",
"yiisoft/di": "^1.2",
"maglnet/composer-require-checker": "^4.7",
"phpunit/phpunit": "^10.5",
"rector/rector": "^1.2",
"roave/infection-static-analysis-plugin": "^1.35",
"spatie/phpunit-watcher": "^1.24",
"vimeo/psalm": "^5.26",
"yiisoft/di": "^1.3",
"yiisoft/test-support": "^3.0",
"yiisoft/yii-debug": "dev-master|dev-php80"
"yiisoft/yii-debug": "dev-master"
},
"autoload": {
"psr-4": {
Expand Down
26 changes: 14 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
requireCoverageMetadata="false"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
executionOrder="random"
failOnRisky="true"
failOnWarning="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
executionOrder="random"
resolveDependencies="true">
colors="true"
displayDetailsOnPhpunitDeprecations="true"
>
<php>
<ini name="error_reporting" value="-1"/>
</php>
Expand All @@ -21,9 +23,9 @@
</testsuite>
</testsuites>

<coverage>
<source>
<include>
<directory>./src</directory>
<directory suffix=".php">./src</directory>
</include>
</coverage>
</source>
</phpunit>
19 changes: 0 additions & 19 deletions psalm80.xml

This file was deleted.

6 changes: 3 additions & 3 deletions src/AssetConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ final class AssetConverter implements AssetConverterInterface
* @psalm-param array<string, array{0:string,1:string}> $commands
*/
public function __construct(
private Aliases $aliases,
private LoggerInterface $logger,
private readonly Aliases $aliases,
private readonly LoggerInterface $logger,
array $commands = [],
private bool $forceConvert = false
private bool $forceConvert = false,
) {
$this->commands = array_merge($this->commands, $commands);
}
Expand Down
2 changes: 1 addition & 1 deletion src/AssetLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final class AssetLoader implements AssetLoaderInterface
* @param string|null $baseUrl The base URL that can be used to access the asset files. See {@see withBaseUrl()}.
*/
public function __construct(
private Aliases $aliases,
private readonly Aliases $aliases,
private bool $appendTimestamp = false,
private array $assetMap = [],
private ?string $basePath = null,
Expand Down
2 changes: 1 addition & 1 deletion src/AssetManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ final class AssetManager
public function __construct(
Aliases $aliases,
private AssetLoaderInterface $loader,
private array $allowedBundleNames = [],
private readonly array $allowedBundleNames = [],
private array $customizedBundles = []
) {
$this->registrar = new AssetRegistrar($aliases, $this->loader);
Expand Down
6 changes: 3 additions & 3 deletions src/AssetPublisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Yiisoft\Files\FileHelper;
use Yiisoft\Files\PathMatcher\PathMatcherInterface;

use function array_key_exists;
use function crc32;
use function dirname;
use function file_exists;
Expand Down Expand Up @@ -60,9 +61,9 @@ final class AssetPublisher implements AssetPublisherInterface
* @param bool $linkAssets Whether to use symbolic link to publish asset files. See {@see withLinkAssets()}.
*/
public function __construct(
private Aliases $aliases,
private readonly Aliases $aliases,
private bool $forceCopy = false,

Check warning on line 65 in src/AssetPublisher.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "FalseValue": --- Original +++ New @@ @@ * directory. See {@see withForceCopy()}. * @param bool $linkAssets Whether to use symbolic link to publish asset files. See {@see withLinkAssets()}. */ - public function __construct(private readonly Aliases $aliases, private bool $forceCopy = false, private bool $linkAssets = false) + public function __construct(private readonly Aliases $aliases, private bool $forceCopy = true, private bool $linkAssets = false) { } public function publish(AssetBundle $bundle) : array
private bool $linkAssets = false
private bool $linkAssets = false,
) {
}

Expand Down Expand Up @@ -283,7 +284,6 @@ private function publishBundleDirectory(AssetBundle $bundle): array
];
foreach (['afterCopy', 'beforeCopy', 'filter', 'recursive'] as $key) {
if (array_key_exists($key, $bundle->publishOptions)) {
/** @psalm-suppress MixedAssignment */
$publishOptions[$key] = $bundle->publishOptions[$key];
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Debug/AssetLoaderInterfaceProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
final class AssetLoaderInterfaceProxy implements AssetLoaderInterface
{
public function __construct(
private AssetLoaderInterface $assetLoader,
private AssetCollector $assetCollector
private readonly AssetLoaderInterface $assetLoader,
private readonly AssetCollector $assetCollector,
) {
}

Expand Down
5 changes: 3 additions & 2 deletions src/Exporter/JsonAssetExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ final class JsonAssetExporter implements AssetExporterInterface
/**
* @param string $targetFile The full path to the target JSON file.
*/
public function __construct(private string $targetFile)
{
public function __construct(
private readonly string $targetFile,
) {
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/Exporter/WebpackAssetExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ final class WebpackAssetExporter implements AssetExporterInterface
/**
* @param string $targetFile The full path to the target JavaScript file.
*/
public function __construct(private string $targetFile)
{
public function __construct(
private readonly string $targetFile,
) {
}

/**
Expand Down
19 changes: 7 additions & 12 deletions tests/AssetManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Yiisoft\Assets\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use RecursiveDirectoryIterator;
use RuntimeException;
use Yiisoft\Aliases\Aliases;
Expand Down Expand Up @@ -243,7 +244,7 @@ public function testAssetManagerWithCustomizedBundles(): void
);
}

public function positionProvider(): array
public static function positionProvider(): array
{
return [
[1, true],
Expand All @@ -255,9 +256,7 @@ public function positionProvider(): array
];
}

/**
* @dataProvider positionProvider
*/
#[DataProvider('positionProvider')]
public function testPositionDependency(int $pos, bool $jqAlreadyRegistered): void
{
$manager = new AssetManager($this->aliases, $this->loader, [], [
Expand Down Expand Up @@ -291,7 +290,7 @@ public function testPositionDependency(int $pos, bool $jqAlreadyRegistered): voi
$this->assertEquals($pos, $manager->getJsFiles()['/files/jsFile.js'][1]);
}

public function dataJsPositionDependencyConflict(): array
public static function dataJsPositionDependencyConflict(): array
{
return [
[1, true],
Expand All @@ -301,9 +300,7 @@ public function dataJsPositionDependencyConflict(): array
];
}

/**
* @dataProvider dataJsPositionDependencyConflict
*/
#[DataProvider('dataJsPositionDependencyConflict')]
public function testJsPositionDependencyConflict(int $pos, bool $jQueryAlreadyRegistered): void
{
$jQueryAsset = JqueryAsset::class;
Expand All @@ -328,7 +325,7 @@ public function testJsPositionDependencyConflict(int $pos, bool $jQueryAlreadyRe
: $manager->register(PositionAsset::class);
}

public function dataCssPositionDependencyConflict(): array
public static function dataCssPositionDependencyConflict(): array
{
return [
[1, true],
Expand All @@ -338,9 +335,7 @@ public function dataCssPositionDependencyConflict(): array
];
}

/**
* @dataProvider dataCssPositionDependencyConflict
*/
#[DataProvider('dataCssPositionDependencyConflict')]
public function testCssPositionDependencyConflict(int $pos, bool $oneAlreadyRegistered): void
{
$oneAsset = OneAsset::class;
Expand Down

0 comments on commit 239dcad

Please sign in to comment.