From 59e01e9d809e637b926a8f81e32e557fd07ca576 Mon Sep 17 00:00:00 2001 From: SychO9 Date: Sat, 9 Apr 2022 13:43:24 +0100 Subject: [PATCH 1/4] fix: php 8.1 deprecations --- src/{ReadOnly.php => ReadOnlyException.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/{ReadOnly.php => ReadOnlyException.php} (85%) diff --git a/src/ReadOnly.php b/src/ReadOnlyException.php similarity index 85% rename from src/ReadOnly.php rename to src/ReadOnlyException.php index 0ae526a..1a02d7f 100644 --- a/src/ReadOnly.php +++ b/src/ReadOnlyException.php @@ -13,6 +13,6 @@ * * @link https://github.com/axypro/errors/blob/master/doc/errors.md documentation */ -interface ReadOnly extends Forbidden +interface ReadOnlyException extends Forbidden { } From 648c2745bd486e5b834f48957bfafbf6daea4be7 Mon Sep 17 00:00:00 2001 From: SychO9 Date: Sat, 9 Apr 2022 13:43:36 +0100 Subject: [PATCH 2/4] chore: reorganize --- .editorconfig | 19 +++++++++++++++++++ composer.json | 22 ++++++++++++++++++---- cs.sh | 3 --- index.php | 24 ------------------------ phpmd.sh | 11 ----------- phpunit.xml.dist | 26 +++++++++++++------------- src/ContainerReadOnly.php | 2 +- src/PropertyReadOnly.php | 2 +- tests/ContainerReadOnlyTest.php | 2 +- tests/PropertyReadOnlyTest.php | 2 +- tests/bootstrap.php | 11 ----------- unit.sh | 3 --- 12 files changed, 54 insertions(+), 73 deletions(-) create mode 100644 .editorconfig delete mode 100755 cs.sh delete mode 100644 index.php delete mode 100755 phpmd.sh delete mode 100644 tests/bootstrap.php delete mode 100755 unit.sh diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a61a3ab --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 2 + +[*.{diff,md}] +trim_trailing_whitespace = false + +[*.{php,xml,json}] +indent_size = 4 diff --git a/composer.json b/composer.json index d328dec..c06568c 100644 --- a/composer.json +++ b/composer.json @@ -15,21 +15,35 @@ } ], "require": { - "php": ">=7.1", + "php": ">=7.3", "axy/backtrace": "~2.0.0" }, "require-dev": { - "phpunit/phpunit": "^7.5", + "phpunit/phpunit": "^9.0", "squizlabs/php_codesniffer": "^3.4", "phpmd/phpmd": "^2.6" }, "autoload": { "psr-4": { - "axy\\errors\\": "src", - "axy\\errors\\tests\\": "tests" + "axy\\errors\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "axy\\errors\\tests\\": "tests/" + } + }, + "scripts": { + "test": "phpunit -c phpunit.xml.dist", + "md": "phpmd --exclude vendor . text phpmd.xml.dist", + "cs": "phpcs --standard=PSR2 --encoding=utf-8 --ignore=vendor ." + }, "archive": { "exclude": ["/tests/*", "/doc/*", "/cs.sh", "/phpmd.sh", "/*.xml.dist", "/CHANGELOG.md"] + }, + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } } } diff --git a/cs.sh b/cs.sh deleted file mode 100755 index ceb3cf1..0000000 --- a/cs.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./vendor/bin/phpcs "$@" diff --git a/index.php b/index.php deleted file mode 100644 index efffb3e..0000000 --- a/index.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @license https://raw.github.com/axypro/errors/master/LICENSE MIT - * @link https://github.com/axypro/errors repository - * @link https://github.com/axypro/errors/blob/master/README.md documentation - * @link https://packagist.org/packages/axy/errors composer - * @uses PHP7.1+ - */ - -declare(strict_types=1); - -namespace axy\errors; - -use LogicException; - -if (!is_file(__DIR__.'/vendor/autoload.php')) { - throw new LogicException('Please: composer install'); -} - -require_once(__DIR__.'/vendor/autoload.php'); diff --git a/phpmd.sh b/phpmd.sh deleted file mode 100755 index 386ee36..0000000 --- a/phpmd.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env sh - -cmd="./vendor/bin/phpmd --exclude vendor" -args="text phpmd.xml.dist" - -if [ "$#" -ne 0 ]; then -${cmd} "$@" ${args} -else -${cmd} . ${args} -fi - diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 73c541c..c81f508 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,8 @@ - - - - ./tests/ - - - - - ./src - - + + + ./src + + + + + ./tests/ + + diff --git a/src/ContainerReadOnly.php b/src/ContainerReadOnly.php index 3a7c459..333b11f 100644 --- a/src/ContainerReadOnly.php +++ b/src/ContainerReadOnly.php @@ -15,7 +15,7 @@ * * @link https://github.com/axypro/errors/blob/master/doc/classes/ContainerReadOnly.md documentation */ -class ContainerReadOnly extends Logic implements ReadOnly +class ContainerReadOnly extends Logic implements ReadOnlyException { /** * {@inheritdoc} diff --git a/src/PropertyReadOnly.php b/src/PropertyReadOnly.php index dfc7905..30bf8de 100644 --- a/src/PropertyReadOnly.php +++ b/src/PropertyReadOnly.php @@ -15,7 +15,7 @@ * * @link https://github.com/axypro/errors/blob/master/doc/classes/PropertyReadOnly.md documentation */ -class PropertyReadOnly extends Logic implements ReadOnly +class PropertyReadOnly extends Logic implements ReadOnlyException { /** * {@inheritdoc} diff --git a/tests/ContainerReadOnlyTest.php b/tests/ContainerReadOnlyTest.php index aecafb5..c93bb42 100644 --- a/tests/ContainerReadOnlyTest.php +++ b/tests/ContainerReadOnlyTest.php @@ -29,7 +29,7 @@ public function testCreate(): void $this->assertInstanceOf('axy\errors\Error', $e); $this->assertInstanceOf('axy\errors\Logic', $e); $this->assertInstanceOf('axy\errors\Forbidden', $e); - $this->assertInstanceOf('axy\errors\ReadOnly', $e); + $this->assertInstanceOf('axy\errors\ReadOnlyException', $e); $this->assertSame('Cont', $e->getContainer()); $this->assertSame($previous, $e->getPrevious()); $this->assertSame('Cont is read-only', $e->getMessage()); diff --git a/tests/PropertyReadOnlyTest.php b/tests/PropertyReadOnlyTest.php index 92f6c0b..9f3c252 100644 --- a/tests/PropertyReadOnlyTest.php +++ b/tests/PropertyReadOnlyTest.php @@ -30,7 +30,7 @@ public function testCreate(): void $this->assertInstanceOf('axy\errors\Error', $e); $this->assertInstanceOf('axy\errors\Logic', $e); $this->assertInstanceOf('axy\errors\Forbidden', $e); - $this->assertInstanceOf('axy\errors\ReadOnly', $e); + $this->assertInstanceOf('axy\errors\ReadOnlyException', $e); $this->assertSame('Cont', $e->getContainer()); $this->assertSame('prop', $e->getKey()); $this->assertSame($previous, $e->getPrevious()); diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index e5ee10b..0000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,11 +0,0 @@ - - */ - -declare(strict_types=1); - -namespace axy\errors\tests; - -require(__DIR__.'/../index.php'); diff --git a/unit.sh b/unit.sh deleted file mode 100755 index 007729d..0000000 --- a/unit.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./vendor/bin/phpunit "$@" From 43016f3461a28416fe0f949210ed844a4bdbc9ad Mon Sep 17 00:00:00 2001 From: SychO9 Date: Sat, 9 Apr 2022 22:52:42 +0100 Subject: [PATCH 3/4] chore: remove local dev temporary config --- composer.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/composer.json b/composer.json index c06568c..ec370d8 100644 --- a/composer.json +++ b/composer.json @@ -40,10 +40,5 @@ }, "archive": { "exclude": ["/tests/*", "/doc/*", "/cs.sh", "/phpmd.sh", "/*.xml.dist", "/CHANGELOG.md"] - }, - "extra": { - "branch-alias": { - "dev-main": "1.x-dev" - } } } From c4f2f3120e935d573ea628375ff357a2bb203b65 Mon Sep 17 00:00:00 2001 From: SychO9 Date: Sat, 9 Apr 2022 22:55:32 +0100 Subject: [PATCH 4/4] chore: restore initial package test files --- .travis.yml | 7 ++++--- cs.sh | 3 +++ phpmd.sh | 10 ++++++++++ unit.sh | 3 +++ 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 cs.sh create mode 100644 phpmd.sh create mode 100644 unit.sh diff --git a/.travis.yml b/.travis.yml index e816287..d663d75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,11 @@ language: php matrix: include: - - php: 7.1 - env: CHECKS=yes - - php: 7.2 - php: 7.3 + env: CHECKS=yes + - php: 7.4 + - php: 8.0 + - php: 8.1 sudo: false diff --git a/cs.sh b/cs.sh new file mode 100644 index 0000000..ceb3cf1 --- /dev/null +++ b/cs.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +./vendor/bin/phpcs "$@" diff --git a/phpmd.sh b/phpmd.sh new file mode 100644 index 0000000..ecc3767 --- /dev/null +++ b/phpmd.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +cmd="./vendor/bin/phpmd --exclude vendor" +args="text phpmd.xml.dist" + +if [ "$#" -ne 0 ]; then +${cmd} "$@" ${args} +else +${cmd} . ${args} +fi diff --git a/unit.sh b/unit.sh new file mode 100644 index 0000000..007729d --- /dev/null +++ b/unit.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +./vendor/bin/phpunit "$@"