Skip to content

Commit

Permalink
chore: prep for Laravel 11
Browse files Browse the repository at this point in the history
  • Loading branch information
yajra committed Mar 14, 2024
1 parent 765198d commit c2ff5c7
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 62 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.1, 8.2]
php: [8.2, 8.3]
stability: [prefer-stable]

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

- name: Execute tests
run: vendor/bin/phpunit --verbose
run: vendor/bin/phpunit
21 changes: 21 additions & 0 deletions .github/workflows/lock-closed-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lock Closed Issues

on:
schedule:
- cron: "0 0 * * *"

permissions:
issues: write

jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
issue-inactive-days: "14"
#issue-comment: |
# This issue has been locked since it has been closed for more than 14 days.
issue-lock-reason: ""
process-only: "issues"
20 changes: 20 additions & 0 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: PHP Linting
on:
pull_request:
push:
branches:
- master
jobs:
phplint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "laravel-pint"
uses: aglipanci/[email protected]
with:
preset: laravel
verboseMode: true
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "fix: pint"

17 changes: 10 additions & 7 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ jobs:

strategy:
matrix:
php-version:
- "8.1"
php: [8.2, 8.3]

steps:
- name: "Checkout code"
uses: "actions/checkout@v2"
uses: "actions/checkout@v4"

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

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
- name: Install dependencies
uses: nick-fields/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan --error-format=checkstyle | cs2pr"
- name: Execute type checking
run: vendor/bin/phpstan --configuration="phpstan.neon.dist"
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
}
],
"require": {
"php": "^8.1",
"yajra/laravel-datatables-oracle": "^10.0",
"php": "^8.2",
"yajra/laravel-datatables-oracle": "^11.0",
"league/fractal": "^0.20.1"
},
"require-dev": {
"nunomaduro/larastan": "^2.4",
"orchestra/testbench": "^7.21"
"nunomaduro/larastan": "^2.9.2",
"orchestra/testbench": "^9"
},
"autoload": {
"psr-4": {
Expand All @@ -35,7 +35,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "10.0-dev"
"dev-master": "11.x-dev"
},
"laravel": {
"providers": [
Expand Down
5 changes: 0 additions & 5 deletions src/Commands/TransformerMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class TransformerMakeCommand extends GeneratorCommand
*
* @param string $stub Contents of the stub
* @param string $name The class name
* @return string
*/
protected function replaceClass($stub, $name): string
{
Expand All @@ -53,8 +52,6 @@ protected function replaceClass($stub, $name): string

/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub(): string
{
Expand All @@ -67,7 +64,6 @@ protected function getStub(): string
* Get the default namespace for the class.
*
* @param string $rootNamespace The root namespace
* @return string
*/
protected function getDefaultNamespace($rootNamespace): string
{
Expand All @@ -78,7 +74,6 @@ protected function getDefaultNamespace($rootNamespace): string
* Get the destination class path.
*
* @param string $name Name of the class with namespace
* @return string
*/
protected function getPath($name): string
{
Expand Down
17 changes: 0 additions & 17 deletions src/FractalServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,8 @@

class FractalServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected bool $defer = false;

/**
* Bootstrap the application events.
*
* @return void
*/
public function boot(): void
{
Expand All @@ -32,8 +23,6 @@ public function boot(): void

/**
* Publish datatables assets.
*
* @return void
*/
protected function publishAssets(): void
{
Expand All @@ -46,8 +35,6 @@ protected function publishAssets(): void

/**
* Register DataTables macro methods.
*
* @return void
*/
protected function registerMacro(): void
{
Expand All @@ -72,8 +59,6 @@ protected function registerMacro(): void

/**
* Register the service provider.
*
* @return void
*/
public function register(): void
{
Expand Down Expand Up @@ -104,8 +89,6 @@ public function register(): void

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides(): array
{
Expand Down
14 changes: 1 addition & 13 deletions src/Transformers/FractalTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@

class FractalTransformer
{
/**
* @var \League\Fractal\Manager
*/
protected Manager $fractal;

/**
* FractalTransformer constructor.
*
* @param \League\Fractal\Manager $fractal
*/
public function __construct(Manager $fractal)
{
Expand All @@ -28,16 +23,11 @@ public function __construct(Manager $fractal)

/**
* Transform output using the given transformer and serializer.
*
* @param array|\Illuminate\Support\Collection $output
* @param iterable $transformer
* @param SerializerAbstract|null $serializer
* @return array
*/
public function transform(
array|LaravelCollection $output,
iterable $transformer,
SerializerAbstract $serializer = null
?SerializerAbstract $serializer = null
): array {
if ($serializer !== null) {
$this->fractal->setSerializer($this->createSerializer($serializer));
Expand Down Expand Up @@ -68,7 +58,6 @@ function ($item_collector, $item_transformed) {
* Get or create transformer serializer instance.
*
* @param class-string|SerializerAbstract $serializer
* @return \League\Fractal\Serializer\SerializerAbstract
*/
protected function createSerializer(SerializerAbstract|string $serializer): SerializerAbstract
{
Expand All @@ -83,7 +72,6 @@ protected function createSerializer(SerializerAbstract|string $serializer): Seri
* Get or create transformer instance.
*
* @param \Closure|class-string|TransformerAbstract $transformer
* @return \Closure|\League\Fractal\TransformerAbstract
*/
protected function createTransformer(Closure|string|TransformerAbstract $transformer): Closure|TransformerAbstract
{
Expand Down
18 changes: 9 additions & 9 deletions tests/FractalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ protected function setUp(): void

$this->app['router']->get('/users', function () {
return datatables()->eloquent(User::query())
->setTransformer(UserTransformer::class)
->toJson();
->setTransformer(UserTransformer::class)
->toJson();
});

$this->app['router']->get('/closure', function () {
return datatables()->eloquent(User::query())
->setTransformer(function (User $user) {
return [
'id' => (int) $user->id,
'name' => $user->name,
];
})
->toJson();
->setTransformer(function (User $user) {
return [
'id' => (int) $user->id,
'name' => $user->name,
];
})
->toJson();
});
}
}
4 changes: 0 additions & 4 deletions tests/Transformers/UserTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@

class UserTransformer extends TransformerAbstract
{
/**
* @param \Yajra\DataTables\Fractal\Tests\Models\User $user
* @return array
*/
public function transform(User $user): array
{
return [
Expand Down

0 comments on commit c2ff5c7

Please sign in to comment.