Skip to content

Commit e6e728a

Browse files
committed
Bump to PHP 8.1 and drop deprecated code.
1 parent c1c4aaf commit e6e728a

12 files changed

Lines changed: 48 additions & 600 deletions

File tree

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ trim_trailing_whitespace = true
1212

1313
[*.yml]
1414
indent_size = 2
15+
16+
[*.neon]
17+
indent_style = tab

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
phpunit.xml.dist export-ignore
99
phpcs.xml.dist export-ignore
1010
.github export-ignore
11+
phpstan.neon export-ignore
12+
psalm.xml export-ignore

.github/workflows/ci.yml

Lines changed: 8 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -8,78 +8,14 @@ on:
88
branches:
99
- '*'
1010

11-
jobs:
12-
testsuite-linux:
13-
runs-on: ubuntu-18.04
14-
strategy:
15-
fail-fast: false
16-
matrix:
17-
php-version: ['5.6', '7.4', '8.0']
18-
prefer-lowest: ['']
19-
include:
20-
- php-version: '5.6'
21-
prefer-lowest: 'prefer-lowest'
22-
23-
steps:
24-
- uses: actions/checkout@v2
25-
26-
- name: Setup PHP
27-
uses: shivammathur/setup-php@v2
28-
with:
29-
coverage: none
30-
php-version: ${{ matrix.php-version }}
31-
extensions: mbstring, intl
32-
33-
- name: Get composer cache directory
34-
id: composer-cache
35-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
36-
37-
- name: Get date part for cache key
38-
id: key-date
39-
run: echo "::set-output name=date::$(date +'%Y-%m')"
40-
41-
- name: Cache composer dependencies
42-
uses: actions/cache@v1
43-
with:
44-
path: ${{ steps.composer-cache.outputs.dir }}
45-
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
46-
47-
- name: Composer install
48-
run: |
49-
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
50-
composer update --prefer-lowest --prefer-stable
51-
else
52-
composer install
53-
fi
11+
permissions:
12+
contents: read
5413

55-
- name: Run PHPUnit
56-
run: |
57-
if [[ ${{ matrix.php-version }} == '5.6' ]]; then
58-
vendor/bin/phpunit tests/php56/
59-
else
60-
vendor/bin/phpunit
61-
fi
14+
jobs:
15+
testsuite:
16+
uses: cakephp/.github/.github/workflows/testsuite-without-db.yml@5.x
17+
secrets: inherit
6218

6319
cs-stan:
64-
name: Coding Standard & Static Analysis
65-
runs-on: ubuntu-18.04
66-
67-
steps:
68-
- uses: actions/checkout@v2
69-
70-
- name: Setup PHP
71-
uses: shivammathur/setup-php@v2
72-
with:
73-
php-version: '7.4'
74-
extensions: mbstring, intl
75-
coverage: none
76-
tools: psalm:~4.1.0, cs2pr
77-
78-
- name: Composer Install
79-
run: composer install
80-
81-
- name: Run phpcs
82-
run: vendor/bin/phpcs --report=checkstyle src/ tests/ | cs2pr
83-
84-
- name: Run psalm
85-
run: psalm --output-format=github
20+
uses: cakephp/.github/.github/workflows/cs-stan.yml@5.x
21+
secrets: inherit

composer.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
}
1111
],
1212
"require": {
13-
"php": ">=5.6.0",
13+
"php": ">=8.1",
1414
"composer-plugin-api": "^1.0 || ^2.0"
1515
},
1616
"require-dev": {
17-
"cakephp/cakephp-codesniffer": "^3.3",
17+
"cakephp/cakephp-codesniffer": "5.x-dev",
1818
"composer/composer": "^2.0",
19-
"phpunit/phpunit": "^5.7 || ^6.5 || ^8.5 || ^9.3"
19+
"phpunit/phpunit": "^9.5.19"
2020
},
2121
"autoload": {
2222
"psr-4": {
@@ -25,15 +25,17 @@
2525
},
2626
"autoload-dev": {
2727
"psr-4": {
28-
"Cake\\Test\\TestCase\\Composer\\": "tests/TestCase/",
29-
"Cake\\Test\\TestCase\\Composer\\Php56\\": "tests/php56/TestCase/"
28+
"Cake\\Test\\TestCase\\Composer\\": "tests/TestCase/"
3029
}
3130
},
3231
"extra": {
3332
"class": "Cake\\Composer\\Plugin"
3433
},
3534
"config": {
36-
"sort-packages": true
35+
"sort-packages": true,
36+
"allow-plugins": {
37+
"dealerdirect/phpcodesniffer-composer-installer": true
38+
}
3739
},
3840
"prefer-stable": true
3941
}

phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
level: 6
3+
paths:
4+
- src/

psalm.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<psalm
3-
errorLevel="5"
3+
errorLevel="2"
44
resolveFromConfigFile="true"
55
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
66
xmlns="https://getpsalm.org/schema/config"
@@ -12,4 +12,9 @@
1212
<directory name="vendor" />
1313
</ignoreFiles>
1414
</projectFiles>
15+
16+
<issueHandlers>
17+
<MissingClosureReturnType errorLevel="info" />
18+
<MissingClosureParamType errorLevel="info" />
19+
</issueHandlers>
1520
</psalm>

src/Installer/PluginInstaller.php

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/Plugin.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
namespace Cake\Composer;
35

46
use Composer\Composer;
@@ -7,6 +9,7 @@
79
use Composer\Package\PackageInterface;
810
use Composer\Plugin\PluginInterface;
911
use Composer\Script\Event;
12+
use DirectoryIterator;
1013
use RuntimeException;
1114

1215
class Plugin implements PluginInterface, EventSubscriberInterface
@@ -51,7 +54,7 @@ public static function getSubscribedEvents()
5154
* @param \Composer\Script\Event $event Composer's event object.
5255
* @return void
5356
*/
54-
public function postAutoloadDump(Event $event)
57+
public function postAutoloadDump(Event $event): void
5558
{
5659
$composer = $event->getComposer();
5760
$config = $composer->getConfig();
@@ -78,16 +81,16 @@ public function postAutoloadDump(Event $event)
7881
* Add all composer packages of type `cakephp-plugin`, and all plugins located
7982
* in the plugins directory to a plugin-name indexed array of paths.
8083
*
81-
* @param \Composer\Package\PackageInterface[] $packages Array of \Composer\Package\PackageInterface objects.
82-
* @param array $pluginDirs The path to the plugins dir.
84+
* @param array<\Composer\Package\PackageInterface> $packages Array of \Composer\Package\PackageInterface objects.
85+
* @param array<string> $pluginDirs The path to the plugins dir.
8386
* @param string $vendorDir The path to the vendor dir.
84-
* @return array Plugin name indexed paths to plugins.
87+
* @return array<string, string> Plugin name indexed paths to plugins.
8588
*/
8689
public function findPlugins(
8790
array $packages,
8891
array $pluginDirs = ['plugins'],
89-
$vendorDir = 'vendor'
90-
) {
92+
string $vendorDir = 'vendor'
93+
): array {
9194
$plugins = [];
9295

9396
foreach ($packages as $package) {
@@ -103,7 +106,7 @@ public function findPlugins(
103106
foreach ($pluginDirs as $path) {
104107
$path = $this->getFullPath($path, $vendorDir);
105108
if (is_dir($path)) {
106-
$dir = new \DirectoryIterator($path);
109+
$dir = new DirectoryIterator($path);
107110
foreach ($dir as $info) {
108111
if (!$info->isDir() || $info->isDot()) {
109112
continue;
@@ -131,7 +134,7 @@ public function findPlugins(
131134
* @param string $vendorDir The path to the vendor dir.
132135
* @return string
133136
*/
134-
public function getFullPath($path, $vendorDir)
137+
public function getFullPath(string $path, string $vendorDir): string
135138
{
136139
if (preg_match('{^(?:/|[a-z]:|[a-z0-9.]+://)}i', $path)) {
137140
return rtrim($path, '/');
@@ -148,11 +151,11 @@ public function getFullPath($path, $vendorDir)
148151
* Rewrite the config file with a complete list of plugins.
149152
*
150153
* @param string $configFile The path to the config file.
151-
* @param array $plugins Array of plugins.
154+
* @param array<string, string> $plugins Array of plugins.
152155
* @param string|null $root The root directory. Defaults to a value generated from `$configFile`.
153156
* @return void
154157
*/
155-
public function writeConfigFile($configFile, array $plugins, $root = null)
158+
public function writeConfigFile(string $configFile, array $plugins, ?string $root = null): void
156159
{
157160
$root = $root ?: dirname(dirname($configFile));
158161

@@ -212,7 +215,7 @@ public function writeConfigFile($configFile, array $plugins, $root = null)
212215
* @param string $vendorDir Path to composer-vendor dir.
213216
* @return string Absolute file path.
214217
*/
215-
public function getConfigFilePath($vendorDir)
218+
public function getConfigFilePath(string $vendorDir): string
216219
{
217220
return $vendorDir . DIRECTORY_SEPARATOR . 'cakephp-plugins.php';
218221
}
@@ -224,10 +227,11 @@ public function getConfigFilePath($vendorDir)
224227
* @return string The package's primary namespace.
225228
* @throws \RuntimeException When the package's primary namespace cannot be determined.
226229
*/
227-
public function getPrimaryNamespace(PackageInterface $package)
230+
public function getPrimaryNamespace(PackageInterface $package): string
228231
{
229232
$primaryNs = null;
230233
$autoLoad = $package->getAutoload();
234+
/** @var array<string, string> $pathMap */
231235
foreach ($autoLoad as $type => $pathMap) {
232236
if ($type !== 'psr-4') {
233237
continue;
@@ -265,6 +269,6 @@ public function getPrimaryNamespace(PackageInterface $package)
265269
);
266270
}
267271

268-
return trim((string)$primaryNs, '\\');
272+
return trim($primaryNs, '\\');
269273
}
270274
}

tests/TestCase/Installer/PluginInstallerTest.php

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)