Skip to content

Commit 89f3511

Browse files
committed
PHPStan level 5
1 parent cb0ccc6 commit 89f3511

File tree

15 files changed

+368
-212
lines changed

15 files changed

+368
-212
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: "Continuous Integration"
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 0 * * *'
8+
9+
jobs:
10+
phpunit:
11+
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
fail-fast: true
16+
matrix:
17+
php: [8.0, 8.1]
18+
stability: [prefer-stable]
19+
20+
name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v2
25+
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: ${{ matrix.php }}
30+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, memcached
31+
tools: composer:v2
32+
coverage: none
33+
34+
- name: Setup Memcached
35+
uses: niden/actions-memcached@v7
36+
37+
- name: Install dependencies
38+
uses: nick-invision/retry@v1
39+
with:
40+
timeout_minutes: 5
41+
max_attempts: 5
42+
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
43+
44+
- name: Execute tests
45+
run: vendor/bin/phpunit --verbose
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "Static Analysis"
2+
3+
on:
4+
push:
5+
paths:
6+
- .github/workflows/static-analysis.yml
7+
- composer.*
8+
- phpstan.neon.dist
9+
- src/**
10+
- tests/**
11+
12+
pull_request:
13+
paths:
14+
- .github/workflows/static-analysis.yml
15+
- composer.*
16+
- phpstan.neon.dist
17+
- src/**
18+
- tests/**
19+
20+
schedule:
21+
- cron: '0 0 * * *'
22+
23+
jobs:
24+
static-analysis-phpstan:
25+
name: "Static Analysis with PHPStan"
26+
runs-on: ubuntu-latest
27+
28+
strategy:
29+
matrix:
30+
php-version:
31+
- "8.1"
32+
33+
steps:
34+
- name: "Checkout code"
35+
uses: "actions/checkout@v2"
36+
37+
- name: "Install PHP"
38+
uses: "shivammathur/setup-php@v2"
39+
with:
40+
coverage: "none"
41+
php-version: "${{ matrix.php-version }}"
42+
tools: "cs2pr"
43+
44+
- name: "Install dependencies with Composer"
45+
uses: "ramsey/composer-install@v1"
46+
47+
- name: "Run a static analysis with phpstan/phpstan"
48+
run: "vendor/bin/phpstan --error-format=checkstyle | cs2pr"

.styleci.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
11
preset: laravel
2-
3-
enabled:
4-
- align_double_arrow
5-
- align_equals
6-
7-
disabled:
8-
- concat_without_spaces
9-
- unalign_equals

.travis.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
- Added Laravel 9 specific support
66
- Bump major version to match with the framework
77
- Move `maatwebsite/excel` to suggest. #139
8-
- [BC] Rename ReadOnly to ReadOnlyField
8+
- Add phpstan static analysis
9+
- Add tests

composer.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717
"require": {
1818
"php": "^8.0.2",
1919
"yajra/laravel-datatables-oracle": "10.*",
20-
"yajra/laravel-datatables-html": "3.*|4.*",
20+
"yajra/laravel-datatables-html": "9.*",
2121
"illuminate/console": "*"
2222
},
2323
"require-dev": {
24-
"mockery/mockery": "^1.1",
25-
"phpunit/phpunit": "^7.3"
24+
"maatwebsite/excel": "^3.1.40",
25+
"nunomaduro/larastan": "^2.1",
26+
"orchestra/testbench": "^7.3",
27+
"rap2hpoutre/fast-excel": "^3.2",
28+
"barryvdh/laravel-snappy": "^1.0"
2629
},
2730
"autoload": {
2831
"psr-4": {
@@ -31,7 +34,7 @@
3134
},
3235
"autoload-dev": {
3336
"psr-4": {
34-
"Yajra\\DataTables\\Tests\\": "tests/"
37+
"Yajra\\DataTables\\Buttons\\Tests\\": "tests/"
3538
}
3639
},
3740
"extra": {

phpstan.neon.dist

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
includes:
2+
- ./vendor/nunomaduro/larastan/extension.neon
3+
4+
parameters:
5+
6+
paths:
7+
- src
8+
9+
level: 5
10+
11+
ignoreErrors:
12+
- '#Unsafe usage of new static\(\).#'
13+
14+
excludePaths:
15+
16+
checkMissingIterableValueType: false
17+
18+
checkGenericClassInNonGenericObjectType: false

src/ButtonsServiceProvider.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class ButtonsServiceProvider extends ServiceProvider
1515
*
1616
* @return void
1717
*/
18-
public function boot()
18+
public function boot(): void
1919
{
20-
$this->loadViewsFrom(__DIR__ . '/resources/views', 'datatables');
20+
$this->loadViewsFrom(__DIR__.'/resources/views', 'datatables');
2121

2222
$this->publishAssets();
2323

@@ -30,15 +30,15 @@ public function boot()
3030
protected function publishAssets()
3131
{
3232
$this->publishes([
33-
__DIR__ . '/config/config.php' => config_path('datatables-buttons.php'),
33+
__DIR__.'/config/config.php' => config_path('datatables-buttons.php'),
3434
], 'datatables-buttons');
3535

3636
$this->publishes([
37-
__DIR__ . '/resources/assets/buttons.server-side.js' => public_path('vendor/datatables/buttons.server-side.js'),
37+
__DIR__.'/resources/assets/buttons.server-side.js' => public_path('vendor/datatables/buttons.server-side.js'),
3838
], 'datatables-buttons');
3939

4040
$this->publishes([
41-
__DIR__ . '/resources/views' => base_path('/resources/views/vendor/datatables'),
41+
__DIR__.'/resources/views' => base_path('/resources/views/vendor/datatables'),
4242
], 'datatables-buttons');
4343
}
4444

@@ -57,9 +57,9 @@ protected function registerCommands()
5757
*
5858
* @return void
5959
*/
60-
public function register()
60+
public function register(): void
6161
{
62-
$this->mergeConfigFrom(__DIR__ . '/config/config.php', 'datatables-buttons');
62+
$this->mergeConfigFrom(__DIR__.'/config/config.php', 'datatables-buttons');
6363

6464
$this->app->register(HtmlServiceProvider::class);
6565

src/Generators/DataTablesHtmlCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class DataTablesHtmlCommand extends DataTablesMakeCommand
3838
*
3939
* @param string $name
4040
* @return string
41+
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
4142
*/
4243
protected function buildClass($name)
4344
{
@@ -59,7 +60,7 @@ protected function buildClass($name)
5960
*
6061
* @return string
6162
*/
62-
protected function getStub()
63+
protected function getStub(): string
6364
{
6465
$config = $this->laravel['config'];
6566

@@ -74,7 +75,7 @@ protected function getStub()
7475
* @param string $name
7576
* @return string
7677
*/
77-
protected function qualifyClass($name)
78+
protected function qualifyClass($name): string
7879
{
7980
$rootNamespace = $this->laravel->getNamespace();
8081

0 commit comments

Comments
 (0)