Skip to content

Commit

Permalink
(Changed) Update PHP workflow and dependencies for broader compatibil…
Browse files Browse the repository at this point in the history
…ity (#38)

* build(ci): Enable PHP 8.4 support and update dependencies

- Extend the CI test matrix in the GitHub Actions workflow to include PHP 8.4.
- Refresh development dependencies to the latest stable versions:
  - infection/infection: ^0.29.11
  - phpunit/phpunit: ^12.0.2
  - psalm/plugin-phpunit: ^0.19.2
- Standardise code formatting in rector.php and StringManipulation.php.

These changes ensure compatibility with the upcoming PHP 8.4 release,
enhancing both security and code consistency.

* test(data-providers): Add PHP 8 attributes alongside legacy annotations

- Introduce `#[DataProvider]` attributes while retaining the existing
  `@dataProvider` annotations in all PHPUnit test cases.
- Remove obsolete configurations and deprecated Composer scripts.
- Update dependency versions to support modern PHP syntax.

This update preserves backward compatibility while gradually adopting
modern PHP features.
  • Loading branch information
MarjovanLier authored Feb 11, 2025
1 parent 7afe02c commit e8deaca
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ["8.2", "8.3"]
php-versions: ["8.2", "8.3", "8.4"]

steps:
# This step checks out a copy of your repository.
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
# This step installs the project dependencies.
- name: Install dependencies
id: composer-install
run: composer install --prefer-dist --no-progress --no-suggest
run: composer install --prefer-dist --no-progress

# This step sets up Go environment for the job.
- name: Set up Go
Expand Down
23 changes: 11 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,19 @@
},
"require-dev": {
"enlightn/security-checker": ">=2.0",
"infection/infection": ">=0.27.10",
"laravel/pint": ">=1.14.0",
"phan/phan": ">=5.4.3",
"php-parallel-lint/php-parallel-lint": ">=1.3.2",
"infection/infection": ">=0.29.11",
"laravel/pint": ">=1.20.0",
"phan/phan": ">=5.4.5",
"php-parallel-lint/php-parallel-lint": ">=1.4.0",
"phpmd/phpmd": ">=2.15",
"phpstan/extension-installer": ">=1.3.1",
"phpstan/phpstan": ">=1.10.60",
"phpstan/phpstan-strict-rules": ">=1.5.2",
"phpunit/phpunit": ">=10.5.10|>=11.0.4",
"psalm/plugin-phpunit": ">=0.18.4",
"rector/rector": ">=1.0.2",
"roave/no-floaters": ">=1.11.0",
"phpstan/extension-installer": ">=1.4.3",
"phpstan/phpstan": ">=2.1.4",
"phpstan/phpstan-strict-rules": ">=2.0.3",
"phpunit/phpunit": ">=11.0.9|>=12.0.2",
"psalm/plugin-phpunit": ">=0.19.2",
"rector/rector": ">=2.0.9",
"roave/security-advisories": "dev-latest",
"vimeo/psalm": ">=5.23.0"
"vimeo/psalm": ">=6.5.1"
},
"scripts-descriptions": {
"test:code-style": "Check code for stylistic consistency.",
Expand Down
4 changes: 0 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
includes:
- ./vendor/roave/no-floaters/rules.neon

parameters:
level: max
phpVersion: 80200
checkMissingIterableValueType: true
treatPhpDocTypesAsCertain: false
tipsOfTheDay: false
reportWrongPhpDocTypeInVarTag: true
Expand Down
5 changes: 0 additions & 5 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,5 @@
</plugins>
<issueHandlers>
<MissingParamType errorLevel="error"/>
<UnusedClass>
<errorLevel type="suppress">
<directory name="tests"/>
</errorLevel>
</UnusedClass>
</issueHandlers>
</psalm>
4 changes: 2 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
SetList::PRIVATIZATION,
SetList::STRICT_BOOLEANS,
SetList::INSTANCEOF,
]
],
);

$rectorConfig->importNames();
Expand All @@ -68,6 +68,6 @@
$rectorConfig->skip(
[
FlipTypeControlToUseExclusiveTypeRector::class,
]
],
);
};
2 changes: 1 addition & 1 deletion src/StringManipulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public static function removeAccents(string $str): string
* @param string $subject The string within which the search and replacement are to be performed.
*
* @return string A string where every occurrence of each search value has been substituted with the corresponding
* replacement value.
* replacement value.
*
* @psalm-suppress PossiblyUnusedMethod,UnusedParam
*/
Expand Down
4 changes: 4 additions & 0 deletions tests/Unit/IsValidDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace MarjovanLier\StringManipulation\Tests\Unit;

use MarjovanLier\StringManipulation\StringManipulation;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -27,6 +28,7 @@ final class IsValidDateTest extends TestCase
* @psalm-return list{list{'2023-09-06 12:30:00', 'Y-m-d H:i:s'}, list{'06-09-2023', 'd-m-Y'}, list{'2023-09-06',
* 'Y-m-d'}, list{'2012-02-28', 'Y-m-d'}, list{'00:00:00', 'H:i:s'}, list{'23:59:59', 'H:i:s'},
* list{'29-02-2012', 'd-m-Y'}, list{'28-02-2023', 'd-m-Y'}, list{'2023-02-28', 'Y-m-d'}}
* @suppress PossiblyUnusedMethod
*/
public static function provideValidDates(): array
{
Expand Down Expand Up @@ -180,6 +182,7 @@ public static function provideInvalidDates(): array
/**
* @dataProvider provideValidDates
*/
#[DataProvider('provideValidDates')]
public function testValidDates(string $date, string $format): void
{
self::assertTrue(StringManipulation::isValidDate($date, $format));
Expand All @@ -189,6 +192,7 @@ public function testValidDates(string $date, string $format): void
/**
* @dataProvider provideInvalidDates
*/
#[DataProvider('provideInvalidDates')]
public function testInvalidDates(string $date, string $format): void
{
self::assertFalse(StringManipulation::isValidDate($date, $format));
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/IsValidHourTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace MarjovanLier\StringManipulation\Tests\Unit;

use MarjovanLier\StringManipulation\StringManipulation;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use ReflectionClass;

Expand Down Expand Up @@ -67,6 +68,7 @@ public static function provideHours(): array
*
* @dataProvider provideHours
*/
#[DataProvider('provideHours')]
public function testIsValidHour(int $hour, bool $expectedResult): void
{
$reflectionMethod = (new ReflectionClass(StringManipulation::class))->getMethod('isValidHour');
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/IsValidMinuteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace MarjovanLier\StringManipulation\Tests\Unit;

use MarjovanLier\StringManipulation\StringManipulation;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use ReflectionClass;

Expand Down Expand Up @@ -59,6 +60,7 @@ public static function provideMinutes(): array
*
* @dataProvider provideMinutes
*/
#[DataProvider('provideMinutes')]
public function testIsValidMinute(int $minute, bool $expectedResult): void
{
$reflectionMethod = (new ReflectionClass(StringManipulation::class))->getMethod('isValidMinute');
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/IsValidSecondTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace MarjovanLier\StringManipulation\Tests\Unit;

use MarjovanLier\StringManipulation\StringManipulation;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use ReflectionClass;

Expand Down Expand Up @@ -59,6 +60,7 @@ public static function provideSeconds(): array
*
* @dataProvider provideSeconds
*/
#[DataProvider('provideSeconds')]
public function testIsValidSecond(int $second, bool $expectedResult): void
{
$reflectionMethod = (new ReflectionClass(StringManipulation::class))->getMethod('isValidSecond');
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/IsValidTimePartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace MarjovanLier\StringManipulation\Tests\Unit;

use MarjovanLier\StringManipulation\StringManipulation;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use ReflectionClass;

Expand Down Expand Up @@ -100,6 +101,7 @@ public static function provideTimeParts(): array
*
* @dataProvider provideTimeParts
*/
#[DataProvider('provideTimeParts')]
public function testIsValidTimePart(array $timeParts, bool $expectedResult): void
{
$reflectionMethod = (new ReflectionClass(StringManipulation::class))->getMethod('isValidTimePart');
Expand Down
2 changes: 0 additions & 2 deletions tests/Unit/NameFixTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
*
* @covers \MarjovanLier\StringManipulation\StringManipulation::nameFix
*
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*
* This class is a test case for the nameFix function in the StringManipulation class.
* It tests the function with a variety of inputs.
*/
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/TrimTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace MarjovanLier\StringManipulation\Tests\Unit;

use MarjovanLier\StringManipulation\StringManipulation;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
Expand Down Expand Up @@ -69,6 +70,7 @@ public static function trimDataProvider(): array
/**
* @dataProvider trimDataProvider
*/
#[DataProvider('trimDataProvider')]
public function testTrim(string $input, string $characters, mixed $expected): void
{
self::assertEquals($expected, StringManipulation::trim($input, $characters));
Expand Down

0 comments on commit e8deaca

Please sign in to comment.