Skip to content

Commit acb4438

Browse files
committed
Update tooling and add rector to CI
1 parent 6b70c27 commit acb4438

6 files changed

Lines changed: 65 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,20 @@ jobs:
4444
matrix:
4545
php:
4646
- version: "8.0"
47-
phpunit: "9"
47+
phpunit: "9"
48+
args: ""
4849
- version: "8.1"
4950
phpunit: "10"
51+
args: ""
5052
- version: "8.2"
5153
phpunit: "10"
54+
args: ""
5255
- version: "8.3"
53-
phpunit: "10"
56+
phpunit: "11"
57+
args: ""
5458
- version: "8.4"
55-
phpunit: "10"
59+
phpunit: "12"
60+
args: --display-deprecations --display-phpunit-deprecations
5661

5762
name: "Test: PHP ${{ matrix.php.version }}"
5863

@@ -74,4 +79,21 @@ jobs:
7479
version: "${{ matrix.php.phpunit }}"
7580
php_version: "${{ matrix.php.version }}"
7681
php_extensions: xdebug
77-
args: --coverage-text
82+
args: "--coverage-text ${{ matrix.php.args }}"
83+
84+
rector:
85+
runs-on: ubuntu-latest
86+
name: Rector
87+
88+
steps:
89+
- uses: actions/checkout@v5
90+
- name: Cache Composer dependencies
91+
uses: actions/cache@v4
92+
with:
93+
path: /tmp/composer-cache
94+
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
95+
- uses: php-actions/composer@v6
96+
with:
97+
php_version: "8.4"
98+
- name: Check compatibility
99+
run: composer rector

.phive/phars.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="phpunit" version="^10.0 || ^11.0" installed="11.5.42" location="./tools/phpunit" copy="true"/>
3+
<phar name="phpunit" version="^10.0 || ^11.0 || ^12.0" installed="12.4.2" location="./tools/phpunit" copy="true"/>
44
<phar name="psalm" version="^6.4.0" installed="6.13.1" location="./tools/psalm" copy="true"/>
55
<phar name="phpcpd" version="^6.0.0" installed="6.0.3" location="./tools/phpcpd" copy="true"/>
66
</phive>

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nerou/large-array-buffer",
3-
"version": "1.2.0",
3+
"description": "Handle arrays with huge cardinality but small items with ease",
44
"type": "library",
55
"license": "MIT",
66
"authors": [
@@ -22,6 +22,7 @@
2222
"php": ">=8.0"
2323
},
2424
"require-dev": {
25+
"rector/rector": "^2.0",
2526
"squizlabs/php_codesniffer": "^4.0"
2627
},
2728
"prefer-stable": true,
@@ -45,11 +46,13 @@
4546
"psalm": "./tools/psalm --no-diff --use-baseline=psalm.baseline.xml --php-version=8.0",
4647
"psalm-stats": "./tools/psalm --no-diff --use-baseline=psalm.baseline.xml --php-version=8.0 --stats | grep -v 100",
4748
"update-psalm-baseline": "./tools/psalm --no-diff --set-baseline=psalm.baseline.xml",
49+
"rector": "./vendor/bin/rector process --dry-run",
4850
"tests": [
4951
"@phpcs",
5052
"@phpunit",
5153
"@phpcpd",
52-
"@psalm"
54+
"@psalm",
55+
"@rector"
5356
]
5457
},
5558
"scripts-descriptions": {
@@ -60,6 +63,7 @@
6063
"psalm": "Runs static analysis.",
6164
"psalm-stats": "Print files with unsafe types based on psalm.",
6265
"update-psalm-baseline": "Updates baseline for psalm. CAUTION should not be run as a regular procedure!",
66+
"rector": "Runs PHP compatibility checks and code smell analysis.",
6367
"tests": "Runs all available tests."
6468
}
6569
}

rector.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use Rector\Config\RectorConfig;
5+
use Rector\ValueObject\PhpVersion;
6+
use Rector\Set\ValueObject\LevelSetList;
7+
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->paths([
11+
__DIR__.'/src',
12+
__DIR__.'/test'
13+
]);
14+
15+
$rectorConfig->phpVersion(PhpVersion::PHP_85);
16+
17+
$rectorConfig->sets([
18+
LevelSetList::UP_TO_PHP_80
19+
]);
20+
21+
$rectorConfig->skip([
22+
ClassPropertyAssignToConstructorPromotionRector::class
23+
]);
24+
};

test/ArrayBufferTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace LargeArrayBuffer\Tests;
55

66
use PHPUnit\Framework\TestCase;
7+
use PHPUnit\Framework\Attributes\DataProvider;
78
use LargeArrayBuffer\ArrayBuffer;
89

910
/**
@@ -22,7 +23,7 @@ public static function provideTestData(): array {
2223
/**
2324
* @dataProvider provideTestData
2425
*/
25-
//#[DataProvider('provideTestData')]
26+
#[DataProvider('provideTestData')]
2627
public function testBuffer(int $items, int $threshold): void {
2728
$o = new \stdClass();
2829
$o->foo = 'hello world!'.PHP_EOL;

test/LargeArrayBufferTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use LargeArrayBuffer\LargeArrayBuffer;
77
use PHPUnit\Framework\TestCase;
8+
use PHPUnit\Framework\Attributes\DataProvider;
89

910
/**
1011
* @author Andreas Wahlen
@@ -58,7 +59,7 @@ public static function provideConfig(): \Generator {
5859
/**
5960
* @dataProvider provideConfig
6061
*/
61-
//#[DataProvider('provideConfig')]
62+
#[DataProvider('provideConfig')]
6263
public function testReadWrite(int $serializer, int $compression): void {
6364
$o = self::getObject();
6465
$buf = new LargeArrayBuffer(serializer: $serializer, compression: $compression);
@@ -71,7 +72,7 @@ public function testReadWrite(int $serializer, int $compression): void {
7172
/**
7273
* @dataProvider provideConfig
7374
*/
74-
//#[DataProvider('provideConfig')]
75+
#[DataProvider('provideConfig')]
7576
public function testLoop(int $serializer, int $compression): void {
7677
$count = 1500;
7778
$buf = new LargeArrayBuffer(serializer: $serializer, compression: $compression);
@@ -116,6 +117,7 @@ public static function provideItems(): array {
116117
/**
117118
* @dataProvider provideItems
118119
*/
120+
#[DataProvider('provideItems')]
119121
public function testToArray(array $items): void {
120122
$buf = new LargeArrayBuffer();
121123
foreach($items as $item){
@@ -127,6 +129,7 @@ public function testToArray(array $items): void {
127129
/**
128130
* @dataProvider provideItems
129131
*/
132+
#[DataProvider('provideItems')]
130133
public function testToFixedArray(array $items): void {
131134
$buf = new LargeArrayBuffer();
132135
foreach($items as $item){
@@ -138,6 +141,7 @@ public function testToFixedArray(array $items): void {
138141
/**
139142
* @dataProvider provideItems
140143
*/
144+
#[DataProvider('provideItems')]
141145
public function testToGenerator(array $items): void {
142146
$buf = new LargeArrayBuffer();
143147
foreach($items as $item){

0 commit comments

Comments
 (0)