Skip to content

Commit 6f7e12f

Browse files
committed
Laravel 10, namespace change, GitHub actions
1 parent 148c5d0 commit 6f7e12f

20 files changed

+225
-141
lines changed

.gitattributes

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
/phpunit.xml export-ignore
33
/phpunit.xml.old export-ignore
44
/phpcs.xml export-ignore
5-
/phpcs.xml export-ignore
65
/docker export-ignore
7-
/.travis.yml export-ignore
8-
/.styleci.yml export-ignore
9-
/.php_cs export-ignore
10-
/.editorconfig export-ignore
6+
/.php-cs-fixer.php export-ignore
7+
/.editorconfig export-ignore
118
/.gitattributes export-ignore
129
/.gitignore export-ignore
13-
/vendor export-ignore
10+
/.github export-ignore
1411
/coverage export-ignore
12+
/.phpunit.cache export-ignore

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/lint.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Lint
2+
3+
on: [ push ]
4+
5+
jobs:
6+
lint_with_php_cs_fixer:
7+
name: Lint code with PHP-CS-Fixer
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
12+
- name: Install dependencies
13+
uses: php-actions/composer@v6
14+
with:
15+
command: install
16+
only_args: -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-reqs
17+
php_version: 8.1
18+
19+
- name: Run PHP-CS-Fixer
20+
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --dry-run
21+
22+
lint_with_phpcs:
23+
name: Lint code with PHP CodeSniffer
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v3
27+
28+
- name: Install dependencies
29+
uses: php-actions/composer@v6
30+
with:
31+
command: install
32+
only_args: -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-reqs
33+
php_version: 8.1
34+
35+
- name: Run PHP CodeSniffer
36+
run: vendor/bin/phpcs --extensions=php

.github/workflows/unittests.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Unit Test
2+
3+
on: [ push ]
4+
5+
jobs:
6+
PHPUnit:
7+
strategy:
8+
matrix:
9+
include:
10+
# Laravel 10.*
11+
- php: 8.1
12+
laravel: 10.*
13+
testbench: 8.*
14+
composer-flag: '--prefer-stable'
15+
- php: 8.2
16+
laravel: 10.*
17+
testbench: 8.*
18+
composer-flag: '--prefer-stable'
19+
- php: 8.1
20+
laravel: 10.*
21+
testbench: 8.*
22+
composer-flag: '--prefer-lowest'
23+
- php: 8.2
24+
laravel: 10.*
25+
testbench: 8.*
26+
composer-flag: '--prefer-lowest'
27+
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- uses: actions/checkout@v3
32+
33+
- name: Setup PHP
34+
uses: shivammathur/setup-php@v2
35+
with:
36+
php-version: ${{ matrix.php }}
37+
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
38+
coverage: xdebug
39+
40+
- name: Install dependencies
41+
run: composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
42+
43+
- name: Update dependencies
44+
run: composer update ${{ matrix.composer-flag }} --prefer-dist --no-interaction
45+
46+
- name: Run PHPUnit
47+
run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml
48+
49+
- name: Upload coverage reports to Codecov
50+
uses: codecov/codecov-action@v3

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
.Spotlight-V100
1111
.Trashes
1212
ehthumbs.db
13-
Thumbs.db
1413

1514
# Custom #
1615
######################
16+
Thumbs.db
1717
vendor
1818
coverage
1919
composer.lock
20+
.php_cs.cache
2021
.php-cs-fixer.cache
2122
.phpunit.result.cache
23+
.phpunit.cache

.php-cs-fixer.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
<?php
22

33
return (new PhpCsFixer\Config())
4-
->setRiskyAllowed(false)
4+
->setRiskyAllowed(true)
55
->setRules([
6-
'@Symfony' => true,
6+
'@PSR12' => true,
7+
'@PSR12:risky' => true,
8+
'array_syntax' => ['syntax' => 'short'],
9+
'concat_space' => ['spacing' => 'one'],
10+
'declare_strict_types' => true,
11+
'modernize_types_casting' => true,
12+
'void_return' => true,
713
])
814
->setUsingCache(true)
915
->setFinder(
1016
PhpCsFixer\Finder::create()
1117
->in(__DIR__.'/src')
18+
->in(__DIR__.'/tests')
1219
)
13-
;
20+
;

.styleci.yml

-1
This file was deleted.

.travis.yml

-51
This file was deleted.

README.md

+17-10
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
[![Latest Version on Packagist](https://img.shields.io/packagist/v/korridor/laravel-has-many-sync?style=flat-square)](https://packagist.org/packages/korridor/laravel-has-many-sync)
44
[![License](https://img.shields.io/packagist/l/korridor/laravel-has-many-sync?style=flat-square)](license.md)
5+
[![GitHub Workflow Lint](https://img.shields.io/github/actions/workflow/status/korridor/laravel-has-many-sync/lint.yml?label=lint&style=flat-square)](https://github.com/korridor/laravel-has-many-sync/actions/workflows/lint.yml)
6+
[![GitHub Workflow Tests](https://img.shields.io/github/actions/workflow/status/korridor/laravel-has-many-sync/unittests.yml?label=tests&style=flat-square)](https://github.com/korridor/laravel-has-many-sync/actions/workflows/unittests.yml)
57
[![Codecov](https://img.shields.io/codecov/c/github/korridor/laravel-has-many-sync?style=flat-square)](https://codecov.io/gh/korridor/laravel-has-many-sync)
6-
[![TravisCI](https://img.shields.io/travis/korridor/laravel-has-many-sync?style=flat-square)](https://travis-ci.org/korridor/laravel-has-many-sync)
7-
[![StyleCI](https://styleci.io/repos/202400425/shield)](https://styleci.io/repos/202400425)
8-
9-
**Note: This package is a fork of [alfa6661/laravel-hasmany-sync](https://github.com/alfa6661/laravel-hasmany-sync). I already added tests and I plan to add more feature in the future.**
108

119
Allow sync method for Laravel Has Many Relationship.
1210

@@ -18,14 +16,19 @@ You can install the package via composer with following command:
1816
composer require korridor/laravel-has-many-sync
1917
```
2018

19+
If you want to use this package with older Laravel/PHP version please install the 1.* version.
20+
21+
```bash
22+
composer require korridor/laravel-has-many-merged "^1"
23+
```
24+
25+
**Warning: The 1.\* versions use a different namespace!**
26+
2127
### Requirements
2228

2329
This package is tested for the following Laravel and PHP versions:
2430

25-
- 9.* (PHP 8.0, 8.1)
26-
- 8.* (PHP 7.4, 8.0, 8.1)
27-
- 7.* (PHP 7.2, 7.3, 7.4)
28-
- 6.* (PHP 7.2, 7.3)
31+
- 10.* (PHP 8.1, 8.2)
2932

3033
## Usage
3134

@@ -35,9 +38,9 @@ This package is tested for the following Laravel and PHP versions:
3538
class Customer extends Model
3639
{
3740
/**
38-
* @return \Illuminate\Database\Eloquent\Relations\HasMany
41+
* @return HasMany<CustomerContact>
3942
*/
40-
public function contacts()
43+
public function contacts(): HasMany
4144
{
4245
return $this->hasMany(CustomerContact::class);
4346
}
@@ -130,6 +133,10 @@ The `composer test-coverage` command runs all tests with phpunit and creates a c
130133
The `composer fix` command formats the code with [php-cs-fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer).
131134
The `composer lint` command checks the code with [phpcs](https://github.com/squizlabs/PHP_CodeSniffer).
132135

136+
## Credits
137+
138+
This package is a fork of [alfa6661/laravel-hasmany-sync](https://github.com/alfa6661/laravel-hasmany-sync).
139+
133140
## License
134141

135142
This package is licensed under the MIT License (MIT). Please see [license file](license.md) for more information.

composer.json

+15-12
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^7.1|^8",
20-
"illuminate/database": "^5.8|6.*|7.*|8.*|9.*",
21-
"illuminate/support": "^5.8|6.*|7.*|8.*|9.*"
19+
"php": ">=8.1",
20+
"illuminate/database": "^10",
21+
"illuminate/support": "^10"
2222
},
2323
"require-dev": {
24-
"orchestra/testbench": "^3.8|^4.0|^5.0|^6.0|^7",
25-
"phpunit/phpunit": "^7.0|^8.0|^9.0",
26-
"friendsofphp/php-cs-fixer": "^2.16|^3",
24+
"orchestra/testbench": "^8",
25+
"phpunit/phpunit": "^10.0",
26+
"friendsofphp/php-cs-fixer": "^3",
2727
"squizlabs/php_codesniffer": "^3.5"
2828
},
2929
"minimum-stability": "stable",
3030
"autoload": {
3131
"psr-4": {
32-
"Alfa6661\\EloquentHasManySync\\": "src"
32+
"Korridor\\LaravelHasManySync\\": "src"
3333
}
3434
},
3535
"autoload-dev": {
@@ -40,15 +40,18 @@
4040
"extra": {
4141
"laravel": {
4242
"providers": [
43-
"Alfa6661\\EloquentHasManySync\\ServiceProvider"
43+
"Korridor\\LaravelHasManySync\\ServiceProvider"
4444
]
4545
}
4646
},
4747
"scripts": {
48-
"test": "vendor/bin/phpunit",
49-
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
50-
"fix": "./vendor/bin/php-cs-fixer fix",
51-
"lint": "./vendor/bin/phpcs --extensions=php"
48+
"test": "@php vendor/bin/phpunit",
49+
"test-coverage": [
50+
"@putenv XDEBUG_MODE=coverage",
51+
"@php vendor/bin/phpunit --coverage-html coverage"
52+
],
53+
"fix": "@php ./vendor/bin/php-cs-fixer fix",
54+
"lint": "@php ./vendor/bin/phpcs --extensions=php"
5255
},
5356
"config": {
5457
"sort-packages": true

docker/Dockerfile

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
FROM php:7.4-cli
1+
FROM php:8.1-cli
22

3-
RUN apt-get update && apt-get install -y \
4-
zlib1g-dev \
5-
libzip-dev
3+
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
64

7-
RUN docker-php-ext-install zip
8-
9-
RUN pecl install xdebug-2.8.1 \
10-
&& docker-php-ext-enable xdebug
5+
RUN chmod +x /usr/local/bin/install-php-extensions && \
6+
install-php-extensions zip xdebug
117

128
# Install composer and add its bin to the PATH.
139
RUN curl -s http://getcomposer.org/installer | php && \

phpcs.xml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
<?xml version="1.0"?>
22
<ruleset name="ASH2">
33
<description>The ASH2 coding standard.</description>
4-
<rule ref="PSR2">
4+
<rule ref="PSR12">
5+
<properties>
6+
<property name="lineLimit" value="150"/>
7+
</properties>
58
</rule>
69

710
<file>src/</file>
11+
<file>tests/</file>
812
</ruleset>

phpunit.xml

+3-6
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
bootstrap="vendor/autoload.php"
44
backupGlobals="false"
5-
backupStaticAttributes="false"
65
colors="true"
7-
verbose="true"
8-
convertErrorsToExceptions="true"
9-
convertNoticesToExceptions="true"
10-
convertWarningsToExceptions="true"
116
processIsolation="false"
127
stopOnFailure="false"
13-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
8+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
9+
cacheDirectory=".phpunit.cache"
10+
backupStaticProperties="false">
1411
<coverage>
1512
<include>
1613
<directory suffix=".php">src/</directory>

0 commit comments

Comments
 (0)