Skip to content

Commit 8689ab0

Browse files
authored
Update actions (#20)
* remove styleci * add phpcs action * add phpstan action * fix phpstan * remove support to php74 * remove support to Laravel 8
1 parent 218fbbc commit 8689ab0

File tree

17 files changed

+163
-48
lines changed

17 files changed

+163
-48
lines changed

.github/workflows/phpstan.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: phpstan
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
phpstan:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Setup PHP
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: 8.1
21+
22+
- name: Cache Composer packages
23+
id: composer-cache
24+
uses: actions/cache@v3
25+
with:
26+
path: vendor
27+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
28+
restore-keys: |
29+
${{ runner.os }}-php-
30+
- name: Install dependencies
31+
if: steps.composer-cache.outputs.cache-hit != 'true'
32+
run: |
33+
composer install
34+
composer dump
35+
- name: Run analyse phpstan
36+
run: vendor/bin/phpstan analyse --error-format github

.github/workflows/style-fix.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: style-fix
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
jobs:
8+
style:
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Setup PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: '8.1'
19+
coverage: xdebug
20+
21+
- name: Cache Composer packages
22+
id: composer-cache
23+
uses: actions/cache@v3
24+
with:
25+
path: vendor
26+
key: ${{ runner.os }}-php-8.1-${{ hashFiles('**/composer.lock') }}
27+
restore-keys: |
28+
${{ runner.os }}-php--8.1
29+
30+
- name: Install dependencies
31+
if: steps.composer-cache.outputs.cache-hit != 'true'
32+
run: |
33+
composer install
34+
composer dump
35+
36+
- name: Fix styles
37+
run: vendor/bin/php-cs-fixer fix
38+
- uses: EndBug/add-and-commit@v9
39+
40+
- name: Run style
41+
run: vendor/bin/php-cs-fixer fix --dry-run --diff --format junit

.github/workflows/tests.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@ name: tests
33
on: [push, pull_request]
44

55
jobs:
6-
run-tests-l8:
6+
run-tests:
77
runs-on: ubuntu-latest
88
strategy:
99
fail-fast: false
1010
matrix:
1111
php: [8.2, 8.1, 8.0]
12-
laravel: [8.*, 9.*]
12+
laravel: [9.*]
1313
dependency-version: [prefer-stable]
1414
include:
1515
- laravel: 9.*
1616
testbench: 7.*
17-
- laravel: 8.*
18-
testbench: 6.*
1917

2018
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
2119

@@ -27,12 +25,13 @@ jobs:
2725
uses: shivammathur/setup-php@v2
2826
with:
2927
php-version: ${{ matrix.php }}
30-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, exif
28+
extensions: pdo, sqlite, pdo_sqlite
3129
coverage: none
3230

3331
- name: Install dependencies
3432
run: |
3533
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
3634
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
35+
3736
- name: Execute tests
3837
run: vendor/bin/phpunit

.php-cs-fixer.dist.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
$finder = Symfony\Component\Finder\Finder::create()
4+
->in([
5+
__DIR__.'/src',
6+
__DIR__.'/tests',
7+
])
8+
->name('*.php')
9+
->notName('*.blade.php')
10+
->ignoreDotFiles(true)
11+
->ignoreVCS(true);
12+
13+
return (new PhpCsFixer\Config())
14+
->setRules([
15+
'@PSR12' => true,
16+
'array_syntax' => ['syntax' => 'short'],
17+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
18+
'no_unused_imports' => true,
19+
'not_operator_with_successor_space' => true,
20+
'trailing_comma_in_multiline' => true,
21+
'phpdoc_scalar' => true,
22+
'unary_operator_spaces' => true,
23+
'binary_operator_spaces' => true,
24+
'blank_line_before_statement' => [
25+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
26+
],
27+
'phpdoc_single_line_var_spacing' => true,
28+
'phpdoc_var_without_name' => true,
29+
'class_attributes_separation' => [
30+
'elements' => [
31+
'method' => 'one',
32+
],
33+
],
34+
'method_argument_space' => [
35+
'on_multiline' => 'ensure_fully_multiline',
36+
'keep_multiple_spaces_after_comma' => true,
37+
],
38+
'single_trait_insert_per_statement' => true,
39+
'php_unit_method_casing' => ['case' => 'snake_case'],
40+
])
41+
->setFinder($finder);

.php_cs

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

.styleci.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
![tests](https://github.com/cesargb/laravel-cascade-delete/workflows/tests/badge.svg)
2-
[![StyleCI](https://github.styleci.io/repos/144183283/shield?branch=master)](https://github.styleci.io/repos/144183283)
1+
[![tests](https://github.com/cesargb/laravel-cascade-delete/actions/workflows/tests.yml/badge.svg)](https://github.com/cesargb/laravel-cascade-delete/actions/workflows/tests.yml)
32
[![Quality Score](https://img.shields.io/scrutinizer/g/cesargb/laravel-cascade-delete.svg?style=flat-square)](https://scrutinizer-ci.com/g/cesargb/laravel-cascade-delete)
43
[![Total Downloads](https://img.shields.io/packagist/dt/cesargb/laravel-cascade-delete.svg?style=flat-square)](https://packagist.org/packages/cesargb/laravel-cascade-delete)
54

composer.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Cascading eliminations implemented in polymorphic relationships for the Laravel apps",
44
"keywords": [
55
"laravel",
6-
"elocuent",
6+
"eloquent",
77
"cascade",
88
"delete",
99
"polymorphic",
@@ -12,16 +12,18 @@
1212
],
1313
"type": "library",
1414
"require": {
15-
"php": "^7.4|^8.0",
16-
"illuminate/console": "^8.0|^9.0",
17-
"illuminate/database": "^8.0|^9.0",
18-
"illuminate/events": "^8.0|^9.0",
19-
"illuminate/support": "^8.0|^9.0"
15+
"php": "^8.0",
16+
"illuminate/console": "^9.0",
17+
"illuminate/database": "^9.0",
18+
"illuminate/events": "^9.0",
19+
"illuminate/support": "^9.0"
2020
},
2121
"require-dev": {
2222
"phpunit/phpunit": "^9.0",
23-
"orchestra/testbench": "^6.0|^7.0",
24-
"laravel/legacy-factories": "^1.0.4"
23+
"orchestra/testbench": "^7.0",
24+
"laravel/legacy-factories": "^1.0.4",
25+
"friendsofphp/php-cs-fixer": "^3.13",
26+
"nunomaduro/larastan": "^2.3"
2527
},
2628
"autoload": {
2729
"psr-4": {

phpstan.neon.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
includes:
2+
- ./vendor/nunomaduro/larastan/extension.neon
3+
4+
parameters:
5+
paths:
6+
- src
7+
- tests
8+
level: 5

src/Morph.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ protected function getStructureMorphRelation(Relation $relation): array
137137
} elseif ($relation instanceof MorphToMany) {
138138
$table = $relation->getTable();
139139
$fieldId = $relation->getForeignPivotKeyName();
140+
} else {
141+
throw new \Exception('Invalid morph relation');
140142
}
141143

142144
return [$table, $fieldType, $fieldId];
@@ -168,6 +170,10 @@ class_uses($class)
168170
*/
169171
protected function getValidMorphRelationsFromModel($model)
170172
{
173+
if (! method_exists($model, 'getCascadeDeleteMorph')) {
174+
return [];
175+
}
176+
171177
return array_filter(
172178
array_map(
173179
function ($methodName) use ($model) {
@@ -191,7 +197,7 @@ function ($relation) {
191197
protected function methodReturnedMorphRelation($model, $methodName)
192198
{
193199
if (! method_exists($model, $methodName)) {
194-
return;
200+
return false;
195201
}
196202

197203
$relation = $model->$methodName();
@@ -213,7 +219,6 @@ protected function isMorphRelation($relation)
213219
/**
214220
* Load models with Cascade Delete.
215221
*
216-
* @param array|string $path
217222
* @return void
218223
*/
219224
protected function load()

0 commit comments

Comments
 (0)