Skip to content

Commit c63ec02

Browse files
authored
Merge pull request #32 from yajra/L11
feat: Laravel 11
2 parents 765198d + 0eeec19 commit c63ec02

File tree

12 files changed

+81
-81
lines changed

12 files changed

+81
-81
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: true
1616
matrix:
17-
php: [8.1, 8.2]
17+
php: [8.2, 8.3]
1818
stability: [prefer-stable]
1919

2020
name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
@@ -42,4 +42,4 @@ jobs:
4242
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
4343

4444
- name: Execute tests
45-
run: vendor/bin/phpunit --verbose
45+
run: vendor/bin/phpunit
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Lock Closed Issues
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *"
6+
7+
permissions:
8+
issues: write
9+
10+
jobs:
11+
action:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: dessant/lock-threads@v3
15+
with:
16+
github-token: ${{ secrets.GITHUB_TOKEN }}
17+
issue-inactive-days: "14"
18+
#issue-comment: |
19+
# This issue has been locked since it has been closed for more than 14 days.
20+
issue-lock-reason: ""
21+
process-only: "issues"

.github/workflows/pint.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: PHP Linting
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
jobs:
8+
phplint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: "laravel-pint"
13+
uses: aglipanci/laravel-pint-action@2.0.0
14+
with:
15+
preset: laravel
16+
verboseMode: true
17+
- uses: stefanzweifel/git-auto-commit-action@v5
18+
with:
19+
commit_message: "fix: pint"
20+

.github/workflows/static-analysis.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ jobs:
2727

2828
strategy:
2929
matrix:
30-
php-version:
31-
- "8.1"
30+
php: [8.2, 8.3]
3231

3332
steps:
3433
- name: "Checkout code"
35-
uses: "actions/checkout@v2"
34+
uses: "actions/checkout@v4"
3635

3736
- name: "Install PHP"
3837
uses: "shivammathur/setup-php@v2"
@@ -41,8 +40,12 @@ jobs:
4140
php-version: "${{ matrix.php-version }}"
4241
tools: "cs2pr"
4342

44-
- name: "Install dependencies with Composer"
45-
uses: "ramsey/composer-install@v1"
43+
- name: Install dependencies
44+
uses: nick-fields/retry@v2
45+
with:
46+
timeout_minutes: 5
47+
max_attempts: 5
48+
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
4649

47-
- name: "Run a static analysis with phpstan/phpstan"
48-
run: "vendor/bin/phpstan --error-format=checkstyle | cs2pr"
50+
- name: Execute type checking
51+
run: vendor/bin/phpstan --configuration="phpstan.neon.dist"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/vendor
22
/coverage
3+
/.phpunit.cache
34
composer.phar
45
composer.lock

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
}
1616
],
1717
"require": {
18-
"php": "^8.1",
19-
"yajra/laravel-datatables-oracle": "^10.0",
18+
"php": "^8.2",
19+
"yajra/laravel-datatables-oracle": "^11.0",
2020
"league/fractal": "^0.20.1"
2121
},
2222
"require-dev": {
23-
"nunomaduro/larastan": "^2.4",
24-
"orchestra/testbench": "^7.21"
23+
"nunomaduro/larastan": "^2.9.2",
24+
"orchestra/testbench": "^9"
2525
},
2626
"autoload": {
2727
"psr-4": {
@@ -35,7 +35,7 @@
3535
},
3636
"extra": {
3737
"branch-alias": {
38-
"dev-master": "10.0-dev"
38+
"dev-master": "11.x-dev"
3939
},
4040
"laravel": {
4141
"providers": [

phpunit.xml.dist

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
4-
bootstrap="vendor/autoload.php"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
11-
>
12-
<testsuites>
13-
<testsuite name="Package Test Suite">
14-
<directory suffix=".php">./tests/</directory>
15-
</testsuite>
16-
</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="Package Test Suite">
5+
<directory suffix="Test.php">./tests/</directory>
6+
</testsuite>
7+
</testsuites>
178
</phpunit>

src/Commands/TransformerMakeCommand.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class TransformerMakeCommand extends GeneratorCommand
3535
*
3636
* @param string $stub Contents of the stub
3737
* @param string $name The class name
38-
* @return string
3938
*/
4039
protected function replaceClass($stub, $name): string
4140
{
@@ -53,8 +52,6 @@ protected function replaceClass($stub, $name): string
5352

5453
/**
5554
* Get the stub file for the generator.
56-
*
57-
* @return string
5855
*/
5956
protected function getStub(): string
6057
{
@@ -67,7 +64,6 @@ protected function getStub(): string
6764
* Get the default namespace for the class.
6865
*
6966
* @param string $rootNamespace The root namespace
70-
* @return string
7167
*/
7268
protected function getDefaultNamespace($rootNamespace): string
7369
{
@@ -78,7 +74,6 @@ protected function getDefaultNamespace($rootNamespace): string
7874
* Get the destination class path.
7975
*
8076
* @param string $name Name of the class with namespace
81-
* @return string
8277
*/
8378
protected function getPath($name): string
8479
{

src/FractalServiceProvider.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,8 @@
1010

1111
class FractalServiceProvider extends ServiceProvider
1212
{
13-
/**
14-
* Indicates if loading of the provider is deferred.
15-
*
16-
* @var bool
17-
*/
18-
protected bool $defer = false;
19-
2013
/**
2114
* Bootstrap the application events.
22-
*
23-
* @return void
2415
*/
2516
public function boot(): void
2617
{
@@ -32,8 +23,6 @@ public function boot(): void
3223

3324
/**
3425
* Publish datatables assets.
35-
*
36-
* @return void
3726
*/
3827
protected function publishAssets(): void
3928
{
@@ -46,8 +35,6 @@ protected function publishAssets(): void
4635

4736
/**
4837
* Register DataTables macro methods.
49-
*
50-
* @return void
5138
*/
5239
protected function registerMacro(): void
5340
{
@@ -72,8 +59,6 @@ protected function registerMacro(): void
7259

7360
/**
7461
* Register the service provider.
75-
*
76-
* @return void
7762
*/
7863
public function register(): void
7964
{
@@ -104,8 +89,6 @@ public function register(): void
10489

10590
/**
10691
* Get the services provided by the provider.
107-
*
108-
* @return array
10992
*/
11093
public function provides(): array
11194
{

src/Transformers/FractalTransformer.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,10 @@
1111

1212
class FractalTransformer
1313
{
14-
/**
15-
* @var \League\Fractal\Manager
16-
*/
1714
protected Manager $fractal;
1815

1916
/**
2017
* FractalTransformer constructor.
21-
*
22-
* @param \League\Fractal\Manager $fractal
2318
*/
2419
public function __construct(Manager $fractal)
2520
{
@@ -28,16 +23,11 @@ public function __construct(Manager $fractal)
2823

2924
/**
3025
* Transform output using the given transformer and serializer.
31-
*
32-
* @param array|\Illuminate\Support\Collection $output
33-
* @param iterable $transformer
34-
* @param SerializerAbstract|null $serializer
35-
* @return array
3626
*/
3727
public function transform(
3828
array|LaravelCollection $output,
3929
iterable $transformer,
40-
SerializerAbstract $serializer = null
30+
?SerializerAbstract $serializer = null
4131
): array {
4232
if ($serializer !== null) {
4333
$this->fractal->setSerializer($this->createSerializer($serializer));
@@ -68,7 +58,6 @@ function ($item_collector, $item_transformed) {
6858
* Get or create transformer serializer instance.
6959
*
7060
* @param class-string|SerializerAbstract $serializer
71-
* @return \League\Fractal\Serializer\SerializerAbstract
7261
*/
7362
protected function createSerializer(SerializerAbstract|string $serializer): SerializerAbstract
7463
{
@@ -83,7 +72,6 @@ protected function createSerializer(SerializerAbstract|string $serializer): Seri
8372
* Get or create transformer instance.
8473
*
8574
* @param \Closure|class-string|TransformerAbstract $transformer
86-
* @return \Closure|\League\Fractal\TransformerAbstract
8775
*/
8876
protected function createTransformer(Closure|string|TransformerAbstract $transformer): Closure|TransformerAbstract
8977
{

tests/FractalTest.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
namespace Yajra\DataTables\Fractal\Tests;
44

55
use Illuminate\Foundation\Testing\DatabaseTransactions;
6+
use PHPUnit\Framework\Attributes\Test;
7+
use Yajra\DataTables\Facades\DataTables;
68
use Yajra\DataTables\Fractal\Tests\Models\User;
79
use Yajra\DataTables\Fractal\Tests\Transformers\UserTransformer;
810

911
class FractalTest extends TestCase
1012
{
1113
use DatabaseTransactions;
1214

13-
/** @test */
15+
#[Test]
1416
public function it_can_transform_response()
1517
{
1618
$json = $this->getAjax('/users');
@@ -25,7 +27,7 @@ public function it_can_transform_response()
2527
$this->assertIsString($json['data'][0]['name']);
2628
}
2729

28-
/** @test */
30+
#[Test]
2931
public function it_works_with_closure()
3032
{
3133
$json = $this->getAjax('/closure');
@@ -45,20 +47,20 @@ protected function setUp(): void
4547
parent::setUp();
4648

4749
$this->app['router']->get('/users', function () {
48-
return datatables()->eloquent(User::query())
49-
->setTransformer(UserTransformer::class)
50-
->toJson();
50+
return DataTables::eloquent(User::query())
51+
->setTransformer(UserTransformer::class)
52+
->toJson();
5153
});
5254

5355
$this->app['router']->get('/closure', function () {
54-
return datatables()->eloquent(User::query())
55-
->setTransformer(function (User $user) {
56-
return [
57-
'id' => (int) $user->id,
58-
'name' => $user->name,
59-
];
60-
})
61-
->toJson();
56+
return DataTables::eloquent(User::query())
57+
->setTransformer(function (User $user) {
58+
return [
59+
'id' => (int) $user->id,
60+
'name' => $user->name,
61+
];
62+
})
63+
->toJson();
6264
});
6365
}
6466
}

tests/Transformers/UserTransformer.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77

88
class UserTransformer extends TransformerAbstract
99
{
10-
/**
11-
* @param \Yajra\DataTables\Fractal\Tests\Models\User $user
12-
* @return array
13-
*/
1410
public function transform(User $user): array
1511
{
1612
return [

0 commit comments

Comments
 (0)