Skip to content

Commit 9f7ea0b

Browse files
authored
Merge pull request #33 from yajra/laravel-12
feat: Laravel 12, pint and rector
2 parents 94141d0 + b13f9c9 commit 9f7ea0b

11 files changed

+127
-101
lines changed

Diff for: .github/workflows/continuous-integration.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: "Continuous Integration"
22

33
on:
44
push:
5+
branches:
6+
- master
7+
- 11.x
58
pull_request:
69
schedule:
710
- cron: '0 0 * * *'
@@ -14,14 +17,14 @@ jobs:
1417
strategy:
1518
fail-fast: true
1619
matrix:
17-
php: [8.2, 8.3]
20+
php: [8.2, 8.3, 8.4]
1821
stability: [prefer-stable]
1922

2023
name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
2124

2225
steps:
2326
- name: Checkout code
24-
uses: actions/checkout@v2
27+
uses: actions/checkout@v4
2528

2629
- name: Setup PHP
2730
uses: shivammathur/setup-php@v2
@@ -39,7 +42,7 @@ jobs:
3942
with:
4043
timeout_minutes: 5
4144
max_attempts: 5
42-
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
45+
command: COMPOSER_ROOT_VERSION=dev-master composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
4346

4447
- name: Execute tests
4548
run: vendor/bin/phpunit

Diff for: .github/workflows/pint.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,22 @@ on:
77
jobs:
88
phplint:
99
runs-on: ubuntu-latest
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
1015
steps:
1116
- uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.head_ref }}
19+
1220
- name: "laravel-pint"
13-
uses: aglipanci/laravel-pint-action@2.0.0
21+
uses: aglipanci/laravel-pint-action@latest
1422
with:
1523
preset: laravel
1624
verboseMode: true
25+
1726
- uses: stefanzweifel/git-auto-commit-action@v5
1827
with:
1928
commit_message: "fix: pint"
20-

Diff for: .github/workflows/static-analysis.yml

+15-12
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,33 @@ on:
2222

2323
jobs:
2424
static-analysis-phpstan:
25+
2526
name: "Static Analysis with PHPStan"
2627
runs-on: ubuntu-latest
2728

2829
strategy:
30+
fail-fast: true
2931
matrix:
30-
php: [8.2, 8.3]
32+
php: [8.2, 8.3, 8.4]
33+
stability: [prefer-stable]
3134

3235
steps:
33-
- name: "Checkout code"
34-
uses: "actions/checkout@v4"
36+
- name: Checkout code
37+
uses: actions/checkout@v4
3538

36-
- name: "Install PHP"
37-
uses: "shivammathur/setup-php@v2"
39+
- name: Setup PHP
40+
uses: shivammathur/setup-php@v2
3841
with:
39-
coverage: "none"
40-
php-version: "${{ matrix.php-version }}"
41-
tools: "cs2pr"
42+
php-version: ${{ matrix.php }}
43+
tools: composer:v2
44+
coverage: none
4245

4346
- name: Install dependencies
44-
uses: nick-fields/retry@v2
47+
uses: nick-invision/retry@v1
4548
with:
4649
timeout_minutes: 5
4750
max_attempts: 5
48-
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
51+
command: COMPOSER_ROOT_VERSION=dev-master composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
4952

50-
- name: Execute type checking
51-
run: vendor/bin/phpstan --configuration="phpstan.neon.dist"
53+
- name: "Run a static analysis with phpstan/phpstan"
54+
run: "vendor/bin/phpstan --error-format=table"

Diff for: .styleci.yml

-1
This file was deleted.

Diff for: CHANGELOG.md

+4-17
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,8 @@
22

33
## Changelog
44

5-
### v11.0.0 - 2024-03-14
5+
### v12.0.0 - 2025-02-26
66

7-
- Add support for Laravel 11
8-
9-
### v10.0.0 - 2023-02-07
10-
11-
- Add support for Laravel 10
12-
13-
### v9.1.0 - 2022-06-20
14-
15-
- Update league/fractal to latest version #30
16-
17-
### v9.0.0 - 2022-05-07
18-
19-
- Add support for Laravel 9
20-
- Fix https://github.com/yajra/laravel-datatables-fractal/issues/27
21-
- Add phpstan static analysis
22-
- Bump major version to match with the framework
7+
- Add support for Laravel 12
8+
- Add Laravel Pint
9+
- Add Rector

Diff for: README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Laravel DataTables Fractal Plugin
22

3-
[![Laravel 11.x](https://img.shields.io/badge/Laravel-11.x-orange.svg)](http://laravel.com)
3+
[![Laravel 12.x](https://img.shields.io/badge/Laravel-12.x-orange.svg)](http://laravel.com)
44
[![Latest Stable Version](https://img.shields.io/packagist/v/yajra/laravel-datatables-fractal.svg)](https://packagist.org/packages/yajra/laravel-datatables-fractal)
5-
[![Build Status](https://travis-ci.org/yajra/laravel-datatables-fractal.svg?branch=master)](https://travis-ci.org/yajra/laravel-datatables-fractal)
5+
[![Continuous Integration](https://github.com/yajra/laravel-datatables-fractal/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/yajra/laravel-datatables-fractal/actions/workflows/continuous-integration.yml)
66
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yajra/laravel-datatables-fractal/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yajra/laravel-datatables-fractal/?branch=master)
77
[![Total Downloads](https://img.shields.io/packagist/dt/yajra/laravel-datatables-fractal.svg)](https://packagist.org/packages/yajra/laravel-datatables-fractal)
88
[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://packagist.org/packages/yajra/laravel-datatables-fractal)
@@ -12,7 +12,7 @@ This package is a plugin of [Laravel DataTables](https://github.com/yajra/larave
1212
## Requirements
1313

1414
- [PHP >= 8.2](http://php.net/)
15-
- [Laravel 11.x](https://github.com/laravel/framework)
15+
- [Laravel 12.x](https://github.com/laravel/framework)
1616
- [Laravel DataTables](https://github.com/yajra/laravel-datatables)
1717

1818
## Documentations
@@ -27,10 +27,11 @@ This package is a plugin of [Laravel DataTables](https://github.com/yajra/larave
2727
| 9.x | 9.x |
2828
| 10.x | 10.x |
2929
| 11.x | 11.x |
30+
| 12.x | 12.x |
3031

3132
## Quick Installation
3233

33-
`composer require yajra/laravel-datatables-fractal:^11.0`
34+
`composer require yajra/laravel-datatables-fractal:^12.0`
3435

3536
### Register Service Provider (Optional on Laravel 5.5+)
3637

Diff for: composer.json

+59-45
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,62 @@
11
{
2-
"name": "yajra/laravel-datatables-fractal",
3-
"description": "Laravel DataTables Fractal Plugin.",
4-
"keywords": [
5-
"laravel",
6-
"datatables",
7-
"fractal",
8-
"api"
9-
],
10-
"license": "MIT",
11-
"authors": [
12-
{
13-
"name": "Arjay Angeles",
14-
"email": "[email protected]"
15-
}
16-
],
17-
"require": {
18-
"php": "^8.2",
19-
"yajra/laravel-datatables-oracle": "^11.0",
20-
"league/fractal": "^0.20.1"
21-
},
22-
"require-dev": {
23-
"nunomaduro/larastan": "^2.9.2",
24-
"orchestra/testbench": "^9"
25-
},
26-
"autoload": {
27-
"psr-4": {
28-
"Yajra\\DataTables\\": "src/"
29-
}
30-
},
31-
"autoload-dev": {
32-
"psr-4": {
33-
"Yajra\\DataTables\\Fractal\\Tests\\": "tests/"
34-
}
35-
},
36-
"extra": {
37-
"branch-alias": {
38-
"dev-master": "11.x-dev"
2+
"name": "yajra/laravel-datatables-fractal",
3+
"description": "Laravel DataTables Fractal Plugin.",
4+
"keywords": [
5+
"laravel",
6+
"datatables",
7+
"fractal",
8+
"api"
9+
],
10+
"license": "MIT",
11+
"authors": [
12+
{
13+
"name": "Arjay Angeles",
14+
"email": "[email protected]"
15+
}
16+
],
17+
"require": {
18+
"php": "^8.2",
19+
"yajra/laravel-datatables-oracle": "^12",
20+
"league/fractal": "^0.20.1"
3921
},
40-
"laravel": {
41-
"providers": [
42-
"Yajra\\DataTables\\FractalServiceProvider"
43-
]
44-
}
45-
},
46-
"minimum-stability": "dev",
47-
"prefer-stable": true
22+
"require-dev": {
23+
"larastan/larastan": "^3.1",
24+
"orchestra/testbench": "^10",
25+
"laravel/pint": "^1.21",
26+
"rector/rector": "^2.0"
27+
},
28+
"autoload": {
29+
"psr-4": {
30+
"Yajra\\DataTables\\": "src/"
31+
}
32+
},
33+
"autoload-dev": {
34+
"psr-4": {
35+
"Yajra\\DataTables\\Fractal\\Tests\\": "tests/"
36+
}
37+
},
38+
"extra": {
39+
"branch-alias": {
40+
"dev-master": "12.x-dev"
41+
},
42+
"laravel": {
43+
"providers": [
44+
"Yajra\\DataTables\\FractalServiceProvider"
45+
]
46+
}
47+
},
48+
"scripts": {
49+
"test": "./vendor/bin/phpunit",
50+
"pint": "./vendor/bin/pint",
51+
"rector": "./vendor/bin/rector",
52+
"stan": "./vendor/bin/phpstan analyse --memory-limit=2G --ansi --no-progress --no-interaction --configuration=phpstan.neon.dist",
53+
"pr": [
54+
"@pint",
55+
"@rector",
56+
"@stan",
57+
"@test"
58+
]
59+
},
60+
"minimum-stability": "dev",
61+
"prefer-stable": true
4862
}

Diff for: phpstan.neon.dist

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
includes:
2-
- ./vendor/nunomaduro/larastan/extension.neon
2+
- ./vendor/larastan/larastan/extension.neon
33

44
parameters:
55

@@ -9,11 +9,7 @@ parameters:
99
level: 5
1010

1111
ignoreErrors:
12-
- '#Access to an undefined property Yajra\\DataTables\\FractalServiceProvider::\$transformer.#'
13-
- '#Access to an undefined property Yajra\\DataTables\\FractalServiceProvider::\$serializer.#'
12+
- identifier: function.alreadyNarrowedType
1413

1514
excludePaths:
1615

17-
checkMissingIterableValueType: false
18-
19-
checkGenericClassInNonGenericObjectType: false

Diff for: rector.php

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Set\ValueObject\LevelSetList;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->paths([
11+
__DIR__.'/config',
12+
__DIR__.'/src',
13+
]);
14+
15+
// register a single rule
16+
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
17+
18+
// define sets of rules
19+
$rectorConfig->sets([
20+
LevelSetList::UP_TO_PHP_82,
21+
]);
22+
};

Diff for: src/FractalServiceProvider.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ public function register(): void
7878
return $fractal;
7979
});
8080

81-
$this->app->singleton('datatables.transformer', function () {
82-
return new FractalTransformer($this->app->make('datatables.fractal'));
83-
});
81+
$this->app->singleton('datatables.transformer', fn () => new FractalTransformer($this->app->make('datatables.fractal')));
8482

8583
$this->commands([
8684
TransformerMakeCommand::class,

Diff for: src/Transformers/FractalTransformer.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,10 @@
1111

1212
class FractalTransformer
1313
{
14-
protected Manager $fractal;
15-
1614
/**
1715
* FractalTransformer constructor.
1816
*/
19-
public function __construct(Manager $fractal)
20-
{
21-
$this->fractal = $fractal;
22-
}
17+
public function __construct(protected Manager $fractal) {}
2318

2419
/**
2520
* Transform output using the given transformer and serializer.
@@ -65,7 +60,7 @@ protected function createSerializer(SerializerAbstract|string $serializer): Seri
6560
return $serializer;
6661
}
6762

68-
return new $serializer();
63+
return new $serializer;
6964
}
7065

7166
/**
@@ -79,6 +74,6 @@ protected function createTransformer(Closure|string|TransformerAbstract $transfo
7974
return $transformer;
8075
}
8176

82-
return new $transformer();
77+
return new $transformer;
8378
}
8479
}

0 commit comments

Comments
 (0)