Skip to content

Commit

Permalink
Add support for PHP 8.3 and Laravel 11 (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiaanluca authored Feb 25, 2024
1 parent 846811e commit c9e845a
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 116 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
target-branch: "develop"
schedule:
interval: "monthly"
open-pull-requests-limit: 5
40 changes: 14 additions & 26 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
name: Check code
name: Run tests

on:
push:
pull_request:

jobs:

check:
name: Run checks - PHP ${{ matrix.php }} - ${{ matrix.dependency-version }}
test:
name: Run tests - PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
fail-fast: true
matrix:
php: [8.1, 8.2]
dependency-version: [prefer-lowest, prefer-stable]
os: [ubuntu-latest]
os: [ ubuntu-latest ]
php: [ 8.2, 8.3 ]
laravel: [ 10.*, 11.* ]
stability: [ prefer-lowest, prefer-stable ]

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Cache PHP dependencies
uses: actions/cache@v2
with:
path: '**/vendor'
key: ${{ runner.os }}-vendor-cache-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-vendor-cache-
- name: Cache Composer dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: composer-${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles('composer.json') }}
- name: Checkout code
uses: actions/checkout@v4

- name: Validate Composer configuration file
run: composer validate --strict
Expand All @@ -45,10 +31,12 @@ jobs:
coverage: none

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

- name: Run tests
run: vendor/bin/phpunit
5 changes: 5 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@
'ordered_imports' => [
'sort_algorithm' => 'alpha',
],
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
'no_unneeded_control_parentheses' => [
'statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield'],
],
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All Notable changes to `sebastiaanluca/laravel-boolean-dates` will be documented

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

## 8.0.0 (2024-02-25)

### Added

- Added support for PHP 8.3
- Added support for Laravel 11

### Removed

- Dropped support for PHP 8.1

## 7.0.1 (2023-02-06)

## 7.0.0 (2023-02-06)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ composer require sebastiaanluca/laravel-boolean-dates

**Set up your Eloquent model** by:

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

Expand Down
52 changes: 35 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@
}
],
"require": {
"php": "~8.1|~8.2",
"illuminate/database": "^10.0",
"illuminate/support": "^10.0"
"php": "~8.2|~8.3",
"illuminate/database": "^10.0|^11.0",
"illuminate/support": "^10.0|^11.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.14",
"phpunit/phpunit": "^9.6"
"friendsofphp/php-cs-fixer": "^3.50",
"laravel/pint": "^1.14",
"phpunit/phpunit": "^11.0.3",
"rector/rector": "^1.0.1",
"roave/security-advisories": "dev-latest"
},
"autoload": {
"psr-4": {
Expand All @@ -44,27 +47,42 @@
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"composer:validate": "@composer validate --strict --ansi",
"test": "vendor/bin/phpunit",
"lint": "PHP_CS_FIXER_IGNORE_ENV=true vendor/bin/php-cs-fixer fix --dry-run --diff --ansi",
"fix": "PHP_CS_FIXER_IGNORE_ENV=true vendor/bin/php-cs-fixer fix --ansi",
"check": [
"@composer:validate",
"@lint",
"@test"
"post-update-cmd": [
"@fix"
],

"validate:composer": "@composer validate --strict --ansi",
"pint:check": "@php vendor/bin/pint --test --ansi",
"pint": "@php vendor/bin/pint --ansi",
"rector:check": "@php vendor/bin/rector --dry-run --ansi",
"rector": "@php vendor/bin/rector --ansi",
"phpunit": "@php vendor/bin/phpunit --order-by=random",

"test": [
"@validate:composer",
"@pint:check",
"@rector:check",
"@phpunit"
],
"fix": [
"@pint",
"@rector"
],
"check:lowest": [

"test:lowest": [
"composer update --prefer-lowest --prefer-dist --no-interaction --ansi",
"@check"
"@test"
],
"check:stable": [
"test:stable": [
"composer update --prefer-stable --prefer-dist --no-interaction --ansi",
"@check"
"@test"
]
}
}
35 changes: 11 additions & 24 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
verbose="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Feature tests">
<directory>tests</directory>
</testsuite>
</testsuites>
<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">
<testsuites>
<testsuite name="Feature tests">
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
12 changes: 12 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"preset": "laravel",
"rules": {
"phpdoc_single_line_var_spacing": true,
"phpdoc_align": false,
"class_attributes_separation": {
"elements": {
"method": "one"
}
}
}
}
61 changes: 61 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\FuncCall\BoolvalToTypeCastRector;
use Rector\CodeQuality\Rector\FuncCall\FloatvalToTypeCastRector;
use Rector\CodeQuality\Rector\FuncCall\IntvalToTypeCastRector;
use Rector\CodeQuality\Rector\FuncCall\StrvalToTypeCastRector;
use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector;
use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
use Rector\Config\RectorConfig;
use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\Php82\Rector\Class_\ReadOnlyClassRector;
use Rector\PHPUnit\Set\PHPUnitSetList;

return RectorConfig::configure()
->withParallel()
->withPaths([
__DIR__.'/src',
__DIR__.'/tests',
])
->withImportNames(
importDocBlockNames: false,
removeUnusedImports: true,
)
->withPhpSets()
->withPreparedSets(
deadCode: true,
codingStyle: true,
typeDeclarations: true,
privatization: true,
earlyReturn: true,
strictBooleans: true,
)
->withSets([
PHPUnitSetList::PHPUNIT_80,
PHPUnitSetList::PHPUNIT_90,
PHPUnitSetList::PHPUNIT_100,
])
->withRules([
BoolvalToTypeCastRector::class,
FloatvalToTypeCastRector::class,
IntvalToTypeCastRector::class,
StrvalToTypeCastRector::class,
ReadOnlyClassRector::class,
ReadOnlyPropertyRector::class,
])
->withSkip([
ArraySpreadInsteadOfArrayMergeRector::class,
CatchExceptionNameMatchingTypeRector::class,
ChangeAndIfToEarlyReturnRector::class,
ChangeOrIfContinueToMultiContinueRector::class,
ClosureToArrowFunctionRector::class,
FirstClassCallableRector::class,
NewlineAfterStatementRector::class,
]);
Loading

0 comments on commit c9e845a

Please sign in to comment.