diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index d07acac..5e896c1 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -1,6 +1,9 @@ name: CI -on: [push] +on: + push: + pull_request: + workflow_dispatch: jobs: @@ -9,7 +12,7 @@ jobs: strategy: matrix: - php-versions: ['7.4', '8.2'] + php-versions: ['8.1', '8.4'] steps: - uses: actions/checkout@v2 diff --git a/composer.json b/composer.json index 8a26477..a783e68 100644 --- a/composer.json +++ b/composer.json @@ -20,13 +20,13 @@ } ], "require": { - "php": ">=7.1" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "8.5.*", + "phpunit/phpunit": "9.6.23", "psr/log": "1.0.*@dev", - "twig/twig": "3.7.*", - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "^1.10", + "twig/twig": "3.11.3" }, "bin": [ "bin/csscrush" diff --git a/lib/CssCrush/Crush.php b/lib/CssCrush/Crush.php index 230d607..0c1348e 100644 --- a/lib/CssCrush/Crush.php +++ b/lib/CssCrush/Crush.php @@ -97,7 +97,7 @@ public static function loadAssets() } } - public static function plugin($name = null, callable|null $callback = null) + public static function plugin($name = null, ?callable $callback = null) { static $plugins = []; diff --git a/lib/CssCrush/Fragment.php b/lib/CssCrush/Fragment.php index 563ee04..334a5ba 100644 --- a/lib/CssCrush/Fragment.php +++ b/lib/CssCrush/Fragment.php @@ -16,7 +16,7 @@ public function __construct($str, $options = []) $this->name = $options['name']; } - public function __invoke(array $args = null, $str = null) + public function __invoke(?array $args = null, $str = null) { $str = parent::__invoke($args); diff --git a/lib/CssCrush/Process.php b/lib/CssCrush/Process.php index 85d6968..06d8791 100644 --- a/lib/CssCrush/Process.php +++ b/lib/CssCrush/Process.php @@ -667,8 +667,8 @@ public function captureRules() preg_match($rulePatt, $this->string->raw, $ruleMatch, PREG_UNMATCHED_AS_NULL, $traceOffset); - $selector = trim($ruleMatch['selector'] ?? null); - $block = trim($ruleMatch['block_content'] ?? null); + $selector = trim($ruleMatch['selector'] ?? ''); + $block = trim($ruleMatch['block_content'] ?? ''); $replace = ''; // If rules are nested inside we set their parent property. @@ -688,12 +688,12 @@ public function captureRules() } } else { - $rule = new Rule($selector, $block, $ruleMatch['trace_token'] ?? null); + $rule = new Rule($selector, $block, $ruleMatch['trace_token'] ?? ''); } $replace = $tokens->add($rule, 'r', $rule->label) . $replace; - $this->string->splice($replace, $traceOffset, strlen($ruleMatch[0]) ?? null); + $this->string->splice($replace, $traceOffset, strlen($ruleMatch[0]) ?? ''); } // Flip, since we just captured rules in reverse order. diff --git a/lib/CssCrush/StringObject.php b/lib/CssCrush/StringObject.php index 999afc3..66a6a58 100644 --- a/lib/CssCrush/StringObject.php +++ b/lib/CssCrush/StringObject.php @@ -8,7 +8,7 @@ class StringObject { - public string|null $raw = null; + public ?string $raw = null; public function __construct($str) { diff --git a/lib/CssCrush/Template.php b/lib/CssCrush/Template.php index 653f558..a459c8b 100644 --- a/lib/CssCrush/Template.php +++ b/lib/CssCrush/Template.php @@ -60,7 +60,7 @@ public function __construct($str) $this->string = $templateFunctions->apply($str); } - public function __invoke(array $args = null, $str = null) + public function __invoke(?array $args = null, $str = null) { $str = isset($str) ? $str : $this->string; diff --git a/tests/unit/CssCrush/OptionsTest.php b/tests/unit/CssCrush/OptionsTest.php index c09655b..b140f78 100644 --- a/tests/unit/CssCrush/OptionsTest.php +++ b/tests/unit/CssCrush/OptionsTest.php @@ -83,7 +83,7 @@ public function testSourceMaps() csscrush_file($this->testFile, ['source_map' => true]); $source_map_contents = file_get_contents("$this->testFile.crush.css.map"); - $this->assertRegExp('~"version": ?3,~', $source_map_contents); + $this->assertMatchesRegularExpression('~"version": ?3,~', $source_map_contents); } public function testAdvancedMinify() diff --git a/tests/unit/CssCrush/TokensTest.php b/tests/unit/CssCrush/TokensTest.php index 2abc3e6..72a1ebc 100644 --- a/tests/unit/CssCrush/TokensTest.php +++ b/tests/unit/CssCrush/TokensTest.php @@ -32,7 +32,7 @@ public function test__construct() public function testCreateLabel() { $type = 's'; - $this->assertRegExp("~^\?{$type}[a-z0-9]+\?$~", $this->tokens->createLabel($type)); + $this->assertMatchesRegularExpression("~^\?{$type}[a-z0-9]+\?$~", $this->tokens->createLabel($type)); } public function testAdd() diff --git a/tests/unit/CssCrush/VersionTest.php b/tests/unit/CssCrush/VersionTest.php index 3f8fd31..aec0fae 100644 --- a/tests/unit/CssCrush/VersionTest.php +++ b/tests/unit/CssCrush/VersionTest.php @@ -36,7 +36,7 @@ public function testProperties() public function testGitDescribe() { if ($version = Version::gitDescribe()) { - $this->assertRegExp('~^ + $this->assertMatchesRegularExpression('~^ v \d+\. \d+\.