Skip to content

Commit c9e845a

Browse files
Add support for PHP 8.3 and Laravel 11 (#2)
1 parent 846811e commit c9e845a

10 files changed

+175
-116
lines changed

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
target-branch: "develop"
6+
schedule:
7+
interval: "monthly"
8+
open-pull-requests-limit: 5

.github/workflows/test.yml

+14-26
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,24 @@
1-
name: Check code
1+
name: Run tests
22

33
on:
44
push:
55
pull_request:
66

77
jobs:
8-
9-
check:
10-
name: Run checks - PHP ${{ matrix.php }} - ${{ matrix.dependency-version }}
8+
test:
9+
name: Run tests - PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
1110
runs-on: ${{ matrix.os }}
1211
strategy:
13-
fail-fast: false
12+
fail-fast: true
1413
matrix:
15-
php: [8.1, 8.2]
16-
dependency-version: [prefer-lowest, prefer-stable]
17-
os: [ubuntu-latest]
14+
os: [ ubuntu-latest ]
15+
php: [ 8.2, 8.3 ]
16+
laravel: [ 10.*, 11.* ]
17+
stability: [ prefer-lowest, prefer-stable ]
1818

1919
steps:
20-
- name: Check out code
21-
uses: actions/checkout@v2
22-
23-
- name: Cache PHP dependencies
24-
uses: actions/cache@v2
25-
with:
26-
path: '**/vendor'
27-
key: ${{ runner.os }}-vendor-cache-${{ hashFiles('**/composer.lock') }}
28-
restore-keys: |
29-
${{ runner.os }}-vendor-cache-
30-
31-
- name: Cache Composer dependencies
32-
uses: actions/cache@v2
33-
with:
34-
path: ~/.composer/cache/files
35-
key: composer-${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles('composer.json') }}
20+
- name: Checkout code
21+
uses: actions/checkout@v4
3622

3723
- name: Validate Composer configuration file
3824
run: composer validate --strict
@@ -45,10 +31,12 @@ jobs:
4531
coverage: none
4632

4733
- name: Install dependencies
48-
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-progress --optimize-autoloader
34+
run: |
35+
composer require "illuminate/database:${{ matrix.laravel }}" "illuminate/support:${{ matrix.laravel }}" --no-interaction --no-update
36+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
4937
5038
- name: Lint code
51-
run: PHP_CS_FIXER_IGNORE_ENV=true vendor/bin/php-cs-fixer fix --dry-run --diff
39+
run: vendor/bin/pint --test
5240

5341
- name: Run tests
5442
run: vendor/bin/phpunit

.php-cs-fixer.dist.php

+5
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@
214214
'ordered_imports' => [
215215
'sort_algorithm' => 'alpha',
216216
],
217+
'global_namespace_import' => [
218+
'import_classes' => true,
219+
'import_constants' => true,
220+
'import_functions' => true,
221+
],
217222
'no_unneeded_control_parentheses' => [
218223
'statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield'],
219224
],

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ All Notable changes to `sebastiaanluca/laravel-boolean-dates` will be documented
44

55
Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
66

7+
## 8.0.0 (2024-02-25)
8+
9+
### Added
10+
11+
- Added support for PHP 8.3
12+
- Added support for Laravel 11
13+
14+
### Removed
15+
16+
- Dropped support for PHP 8.1
17+
718
## 7.0.1 (2023-02-06)
819

920
## 7.0.0 (2023-02-06)

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ composer require sebastiaanluca/laravel-boolean-dates
7272

7373
**Set up your Eloquent model** by:
7474

75-
1. Adding your datetime columns to `$casts`
75+
1. Adding your datetime columns to the `$casts` property or `casts()` method
7676
2. Adding the boolean attributes to `$appends`
7777
3. Creating attribute accessors and mutators for each field
7878

composer.json

+35-17
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@
2525
}
2626
],
2727
"require": {
28-
"php": "~8.1|~8.2",
29-
"illuminate/database": "^10.0",
30-
"illuminate/support": "^10.0"
28+
"php": "~8.2|~8.3",
29+
"illuminate/database": "^10.0|^11.0",
30+
"illuminate/support": "^10.0|^11.0"
3131
},
3232
"require-dev": {
33-
"friendsofphp/php-cs-fixer": "^3.14",
34-
"phpunit/phpunit": "^9.6"
33+
"friendsofphp/php-cs-fixer": "^3.50",
34+
"laravel/pint": "^1.14",
35+
"phpunit/phpunit": "^11.0.3",
36+
"rector/rector": "^1.0.1",
37+
"roave/security-advisories": "dev-latest"
3538
},
3639
"autoload": {
3740
"psr-4": {
@@ -44,27 +47,42 @@
4447
}
4548
},
4649
"config": {
50+
"optimize-autoloader": true,
51+
"preferred-install": "dist",
4752
"sort-packages": true
4853
},
4954
"minimum-stability": "dev",
5055
"prefer-stable": true,
5156
"scripts": {
52-
"composer:validate": "@composer validate --strict --ansi",
53-
"test": "vendor/bin/phpunit",
54-
"lint": "PHP_CS_FIXER_IGNORE_ENV=true vendor/bin/php-cs-fixer fix --dry-run --diff --ansi",
55-
"fix": "PHP_CS_FIXER_IGNORE_ENV=true vendor/bin/php-cs-fixer fix --ansi",
56-
"check": [
57-
"@composer:validate",
58-
"@lint",
59-
"@test"
57+
"post-update-cmd": [
58+
"@fix"
59+
],
60+
61+
"validate:composer": "@composer validate --strict --ansi",
62+
"pint:check": "@php vendor/bin/pint --test --ansi",
63+
"pint": "@php vendor/bin/pint --ansi",
64+
"rector:check": "@php vendor/bin/rector --dry-run --ansi",
65+
"rector": "@php vendor/bin/rector --ansi",
66+
"phpunit": "@php vendor/bin/phpunit --order-by=random",
67+
68+
"test": [
69+
"@validate:composer",
70+
"@pint:check",
71+
"@rector:check",
72+
"@phpunit"
73+
],
74+
"fix": [
75+
"@pint",
76+
"@rector"
6077
],
61-
"check:lowest": [
78+
79+
"test:lowest": [
6280
"composer update --prefer-lowest --prefer-dist --no-interaction --ansi",
63-
"@check"
81+
"@test"
6482
],
65-
"check:stable": [
83+
"test:stable": [
6684
"composer update --prefer-stable --prefer-dist --no-interaction --ansi",
67-
"@check"
85+
"@test"
6886
]
6987
}
7088
}

phpunit.xml.dist

+11-24
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
backupGlobals="false"
4-
backupStaticAttributes="false"
5-
bootstrap="vendor/autoload.php"
6-
colors="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
processIsolation="false"
11-
stopOnFailure="false"
12-
verbose="true"
13-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
14-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
15-
>
16-
<coverage>
17-
<include>
18-
<directory suffix=".php">src/</directory>
19-
</include>
20-
</coverage>
21-
<testsuites>
22-
<testsuite name="Feature tests">
23-
<directory>tests</directory>
24-
</testsuite>
25-
</testsuites>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3+
<testsuites>
4+
<testsuite name="Feature tests">
5+
<directory>tests</directory>
6+
</testsuite>
7+
</testsuites>
8+
<source>
9+
<include>
10+
<directory suffix=".php">src/</directory>
11+
</include>
12+
</source>
2613
</phpunit>

pint.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"preset": "laravel",
3+
"rules": {
4+
"phpdoc_single_line_var_spacing": true,
5+
"phpdoc_align": false,
6+
"class_attributes_separation": {
7+
"elements": {
8+
"method": "one"
9+
}
10+
}
11+
}
12+
}

rector.php

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\CodeQuality\Rector\FuncCall\BoolvalToTypeCastRector;
6+
use Rector\CodeQuality\Rector\FuncCall\FloatvalToTypeCastRector;
7+
use Rector\CodeQuality\Rector\FuncCall\IntvalToTypeCastRector;
8+
use Rector\CodeQuality\Rector\FuncCall\StrvalToTypeCastRector;
9+
use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector;
10+
use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
11+
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
12+
use Rector\Config\RectorConfig;
13+
use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector;
14+
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
15+
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
16+
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
17+
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
18+
use Rector\Php82\Rector\Class_\ReadOnlyClassRector;
19+
use Rector\PHPUnit\Set\PHPUnitSetList;
20+
21+
return RectorConfig::configure()
22+
->withParallel()
23+
->withPaths([
24+
__DIR__.'/src',
25+
__DIR__.'/tests',
26+
])
27+
->withImportNames(
28+
importDocBlockNames: false,
29+
removeUnusedImports: true,
30+
)
31+
->withPhpSets()
32+
->withPreparedSets(
33+
deadCode: true,
34+
codingStyle: true,
35+
typeDeclarations: true,
36+
privatization: true,
37+
earlyReturn: true,
38+
strictBooleans: true,
39+
)
40+
->withSets([
41+
PHPUnitSetList::PHPUNIT_80,
42+
PHPUnitSetList::PHPUNIT_90,
43+
PHPUnitSetList::PHPUNIT_100,
44+
])
45+
->withRules([
46+
BoolvalToTypeCastRector::class,
47+
FloatvalToTypeCastRector::class,
48+
IntvalToTypeCastRector::class,
49+
StrvalToTypeCastRector::class,
50+
ReadOnlyClassRector::class,
51+
ReadOnlyPropertyRector::class,
52+
])
53+
->withSkip([
54+
ArraySpreadInsteadOfArrayMergeRector::class,
55+
CatchExceptionNameMatchingTypeRector::class,
56+
ChangeAndIfToEarlyReturnRector::class,
57+
ChangeOrIfContinueToMultiContinueRector::class,
58+
ClosureToArrowFunctionRector::class,
59+
FirstClassCallableRector::class,
60+
NewlineAfterStatementRector::class,
61+
]);

0 commit comments

Comments
 (0)