Skip to content

Commit 2e18876

Browse files
committed
Rector/CS/CI cleanup
1 parent 5226fb3 commit 2e18876

17 files changed

+90
-33
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [ main ]
88

99
env:
10-
PHP_EXTENSIONS: intl pdo_sqlite
10+
PHP_EXTENSIONS: intl
1111

1212
jobs:
1313
test:
@@ -20,11 +20,14 @@ jobs:
2020
- php-version: '8.2'
2121
prefer-lowest: 'prefer-lowest'
2222

23-
container:
24-
image: thecodingmachine/php:${{ matrix.php-version }}-v5-cli
25-
options: --user root
26-
2723
steps:
24+
- name: Setup PHP
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php-version }}
28+
extensions: ${{ env.PHP_EXTENSIONS }}
29+
coverage: pcov
30+
2831
- name: Checkout code
2932
uses: actions/checkout@v4
3033

@@ -49,18 +52,27 @@ jobs:
4952
if: matrix.prefer-lowest == 'prefer-lowest'
5053
run: vendor/bin/validate-prefer-lowest -m
5154

55+
- name: Upload coverage reports to Codecov
56+
if: success() && matrix.php-version == '8.4'
57+
uses: codecov/codecov-action@v5
58+
with:
59+
token: ${{ secrets.CODECOV_TOKEN }}
60+
slug: josbeir/cakephp-uid
61+
5262
static-analysis:
5363
runs-on: ubuntu-latest
5464
if: github.event_name == 'push' || github.event_name == 'pull_request'
5565

56-
container:
57-
image: thecodingmachine/php:8.4-v5-cli
58-
options: --user root
59-
6066
steps:
6167
- name: Checkout code
6268
uses: actions/checkout@v4
6369

70+
- name: Setup PHP
71+
uses: shivammathur/setup-php@v2
72+
with:
73+
php-version: 8.4
74+
extensions: ${{ env.PHP_EXTENSIONS }}
75+
6476
- name: Install dependencies
6577
run: composer install --prefer-dist --no-interaction --no-progress
6678

@@ -69,3 +81,6 @@ jobs:
6981

7082
- name: Run PHPCS
7183
run: vendor/bin/phpcs
84+
85+
- name: Run Rector
86+
run: vendor/bin/rector process --dry-run

LICENSE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
3+
Copyright 2025
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
[![CI](https://github.com/josbeir/cakephp-uid/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/josbeir/cakephp-uid/actions/workflows/ci.yml)
2+
[![codecov](https://codecov.io/gh/josbeir/cakephp-uid/graph/badge.svg?token=CCX9UIFF28)](https://codecov.io/gh/josbeir/cakephp-uid)
23
[![PHPStan](https://img.shields.io/badge/PHPStan-level%208-brightgreen.svg?style=flat)](https://phpstan.org/)
34
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.2-8892BF.svg)](https://php.net/)
45
[![Packagist Downloads](https://img.shields.io/packagist/dt/josbeir/cakephp-uid)](https://packagist.org/packages/josbeir/cakephp-uid)
6+
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md)
57

68
# CakePHP UID Plugin
79

@@ -59,7 +61,7 @@ This plugin utilizes the [Symfony UID component](https://symfony.com/doc/current
5961

6062
## License
6163

62-
MIT
64+
[MIT](LICENSE.md)
6365

6466
## Contributing
6567

composer.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"cakephp/plugin-installer": "^2.0.1",
1919
"phpunit/phpunit": "^11.0 || ^12.0",
2020
"phpstan/phpstan": "^2.1",
21-
"cakephp/cakephp-codesniffer": "^5.2"
21+
"cakephp/cakephp-codesniffer": "^5.2",
22+
"rector/rector": "^2.1"
2223
},
2324
"license": "MIT",
2425
"minimum-stability": "stable",
@@ -45,12 +46,12 @@
4546
}
4647
},
4748
"scripts": {
48-
"lowest": "validate-prefer-lowest",
49+
"lowest": "validate-prefer-lowest",
4950
"test": "phpunit --colors=always",
50-
"test-coverage": "phpunit --log-junit tmp/coverage/unitreport.xml --coverage-html tmp/coverage --coverage-clover tmp/coverage/coverage.xml",
51-
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^2.0.0 && mv composer.backup composer.json",
52-
"stan-tests": "phpstan analyse -c tests/phpstan.neon",
53-
"cs-check": "phpcs --colors -p -s --extensions=php src/ tests/",
54-
"cs-fix": "phpcbf --colors -p -s --extensions=php src/ tests/"
51+
"test-coverage": "export XDEBUG_MODE=coverage; phpunit --log-junit tmp/coverage/unitreport.xml --coverage-html tmp/coverage --coverage-clover tmp/coverage/coverage.xml",
52+
"stan": "phpstan analyse",
53+
"cs-check": "phpcs --colors -p -s",
54+
"cs-fix": "phpcbf --colors -p -s",
55+
"rector": "rector --ansi"
5556
}
5657
}

rector.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector;
5+
use Rector\Config\RectorConfig;
6+
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
7+
use Rector\ValueObject\PhpVersion;
8+
9+
return RectorConfig::configure()
10+
->withPhpVersion(PhpVersion::PHP_83)
11+
->withPaths([
12+
__DIR__ . '/src',
13+
__DIR__ . '/tests',
14+
])
15+
->withSkip([
16+
DisallowedEmptyRuleFixerRector::class,
17+
SimplifyIfElseToTernaryRector::class,
18+
])
19+
->withImportNames(
20+
importNames: true,
21+
importDocBlockNames: false,
22+
importShortClasses: false,
23+
removeUnusedImports: true,
24+
)
25+
->withParallel()
26+
->withPreparedSets(
27+
deadCode: true,
28+
codeQuality: true,
29+
codingStyle: true,
30+
//naming: true,
31+
typeDeclarations: true,
32+
);

src/Database/Type/AbstractBinaryType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ abstract class AbstractBinaryType extends BaseType
2323
*
2424
* @param mixed $value The value to convert.
2525
* @param \Cake\Database\Driver $driver The driver instance to convert with.
26-
* @return mixed
2726
*/
2827
public function toDatabase(mixed $value, Driver $driver): mixed
2928
{
@@ -70,9 +69,11 @@ public function toPHP(mixed $value, Driver $driver): mixed
7069
if ($value === null) {
7170
return null;
7271
}
72+
7373
if (is_string($value)) {
7474
return $this->convertBinaryUidToString($value);
7575
}
76+
7677
if (is_resource($value)) {
7778
return $value;
7879
}

src/Database/Type/AbstractType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ abstract class AbstractType extends StringType
1616
*
1717
* @param mixed $value value to be converted to database equivalent
1818
* @param \Cake\Database\Driver $driver object from which database preferences and configuration will be extracted
19-
* @return string|null
2019
*/
2120
public function toDatabase(mixed $value, Driver $driver): ?string
2221
{

src/Database/Type/BinaryUlidType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function convertStringToBinaryUid(string $string): string
2929
/**
3030
* @inheritDoc
3131
*/
32-
public function generateUid(): string
32+
protected function generateUid(): string
3333
{
3434
return Ulid::generate();
3535
}

src/Database/Type/BinaryUuidV4Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function convertStringToBinaryUid(string $string): string
2929
/**
3030
* @inheritDoc
3131
*/
32-
public function generateUid(): string
32+
protected function generateUid(): string
3333
{
3434
return Uuid::v4()->toString();
3535
}

src/Database/Type/BinaryUuidV6Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function convertStringToBinaryUid(string $string): string
2929
/**
3030
* @inheritDoc
3131
*/
32-
public function generateUid(): string
32+
protected function generateUid(): string
3333
{
3434
return Uuid::v6()->toString();
3535
}

0 commit comments

Comments
 (0)