summaryrefslogtreecommitdiff
path: root/vendor/chillerlan/php-settings-container
diff options
context:
space:
mode:
authorChih-Hsuan Yen <[email protected]>2022-07-02 22:01:51 +0800
committerAndrew Dolgov <[email protected]>2022-07-12 22:23:48 +0300
commit4b6161892000cb2b8392dce92a9cf2cabdf2d20e (patch)
tree5cad602010e4d13e1a48d6b922d4768c0893ac8b /vendor/chillerlan/php-settings-container
parentd9861038bcc3cb2f38c7153bdca7d5ab89597afa (diff)
Update php-qrcode and php-settings-container for PHP 8.1
By running the following command after updating composer.json ``` composer update chillerlan/php-qrcode chillerlan/php-settings-container ``` This change fixes a deprecation warning from Preferences -> Personal data / Authentication -> Authenticator (OTP). ``` Return type of chillerlan\Settings\SettingsContainerAbstract::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 1. vendor/chillerlan/php-settings-container/src/SettingsContainerAbstract.php(19): ttrss_error_handler(Return type of chillerlan\Settings\SettingsContainerAbstract::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice, vendor/chillerlan/php-settings-container/src/SettingsContainerAbstract.php) 2. vendor/composer/ClassLoader.php(571): include(/usr/share/webapps/tt-rss/vendor/chillerlan/php-settings-container/src/SettingsContainerAbstract.php) 3. vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile(/usr/share/webapps/tt-rss/vendor/composer/../chillerlan/php-settings-container/src/SettingsContainerAbstract.php) 4. vendor/chillerlan/php-qrcode/src/QROptions.php(59): loadClass(chillerlan\Settings\SettingsContainerAbstract) 5. vendor/composer/ClassLoader.php(571): include(/usr/share/webapps/tt-rss/vendor/chillerlan/php-qrcode/src/QROptions.php) 6. vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile(/usr/share/webapps/tt-rss/vendor/composer/../chillerlan/php-qrcode/src/QROptions.php) 7. vendor/chillerlan/php-qrcode/src/QRCode.php(113): loadClass(chillerlan\QRCode\QROptions) 8. classes/pref/prefs.php(958): __construct() 9. classes/pref/prefs.php(469): _get_otp_qrcode_img() 10. classes/pref/prefs.php(541): index_auth_2fa() 11. backend.php(136): index_auth() ``` The issue is fixed in php-settings-container 2.1.1 [1] Here I use the latest php-qrcode version for another PHP 8.1 fix [2]. [1] https://github.com/chillerlan/php-settings-container/commit/68bc5019c8b38956c83906431ef879668366b036#diff-359c7f7a6d32d9935951e1b0742eb116fb654f4a932c8d40328bb5dcab2fa111L162 [2] https://github.com/chillerlan/php-qrcode/issues/97
Diffstat (limited to 'vendor/chillerlan/php-settings-container')
-rw-r--r--vendor/chillerlan/php-settings-container/.github/FUNDING.yml2
-rw-r--r--vendor/chillerlan/php-settings-container/.github/workflows/tests.yml107
-rw-r--r--vendor/chillerlan/php-settings-container/.gitignore6
-rw-r--r--vendor/chillerlan/php-settings-container/.phan/config.php54
-rw-r--r--vendor/chillerlan/php-settings-container/.scrutinizer.yml9
-rw-r--r--vendor/chillerlan/php-settings-container/.travis.yml18
-rw-r--r--vendor/chillerlan/php-settings-container/README.md42
-rw-r--r--vendor/chillerlan/php-settings-container/composer.json18
-rw-r--r--vendor/chillerlan/php-settings-container/docs/Readme.md13
-rw-r--r--vendor/chillerlan/php-settings-container/examples/advanced.php15
-rw-r--r--vendor/chillerlan/php-settings-container/examples/simple.php1
-rw-r--r--vendor/chillerlan/php-settings-container/phpdoc.xml20
-rw-r--r--vendor/chillerlan/php-settings-container/phpmd.xml35
-rw-r--r--vendor/chillerlan/php-settings-container/phpunit.xml44
-rw-r--r--vendor/chillerlan/php-settings-container/src/SettingsContainerAbstract.php45
-rw-r--r--vendor/chillerlan/php-settings-container/src/SettingsContainerInterface.php32
-rw-r--r--vendor/chillerlan/php-settings-container/tests/ContainerTest.php78
-rw-r--r--vendor/chillerlan/php-settings-container/tests/TestContainer.php4
-rw-r--r--vendor/chillerlan/php-settings-container/tests/TestOptionsTrait.php22
19 files changed, 348 insertions, 217 deletions
diff --git a/vendor/chillerlan/php-settings-container/.github/FUNDING.yml b/vendor/chillerlan/php-settings-container/.github/FUNDING.yml
new file mode 100644
index 000000000..16a077f52
--- /dev/null
+++ b/vendor/chillerlan/php-settings-container/.github/FUNDING.yml
@@ -0,0 +1,2 @@
+ko_fi: codemasher
+custom: "https://www.paypal.com/donate?hosted_button_id=WLYUNAT9ZTJZ4"
diff --git a/vendor/chillerlan/php-settings-container/.github/workflows/tests.yml b/vendor/chillerlan/php-settings-container/.github/workflows/tests.yml
new file mode 100644
index 000000000..e52681849
--- /dev/null
+++ b/vendor/chillerlan/php-settings-container/.github/workflows/tests.yml
@@ -0,0 +1,107 @@
+# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
+# https://github.com/sebastianbergmann/phpunit/blob/master/.github/workflows/ci.yml
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+ branches:
+ - main
+
+
+name: "CI"
+
+jobs:
+
+ static-code-analysis:
+ name: "Static Code Analysis"
+
+ runs-on: ubuntu-latest
+
+ env:
+ PHAN_ALLOW_XDEBUG: 0
+ PHAN_DISABLE_XDEBUG_WARN: 1
+
+ steps:
+ - name: "Checkout"
+ uses: actions/checkout@v2
+
+ - name: "Install PHP"
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: "7.4"
+ tools: pecl
+ coverage: none
+ extensions: ast, json
+
+ - name: "Update dependencies with composer"
+ run: composer update --no-interaction --no-ansi --no-progress --no-suggest
+
+ - name: "Run phan"
+ run: php vendor/bin/phan
+
+ build-docs:
+ name: "Build and publish Docs"
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: "Checkout sources"
+ uses: actions/checkout@v2
+
+ - name: "Install PHP"
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: "7.4"
+ coverage: none
+ tools: phpDocumentor
+ extensions: json
+
+ - name: "Build Docs"
+ run: phpdoc --config=phpdoc.xml
+
+ - name: "Publish Docs to gh-pages"
+ uses: JamesIves/[email protected]
+ with:
+ branch: gh-pages
+ folder: docs
+ clean: true
+
+ tests:
+ name: "Unit Tests"
+
+ runs-on: ${{ matrix.os }}
+
+ strategy:
+ fail-fast: false
+ matrix:
+ os:
+ - ubuntu-latest
+ - windows-latest
+ php-version:
+ - "7.4"
+ - "8.0"
+ - "8.1"
+
+ steps:
+ - name: "Checkout"
+ uses: actions/checkout@v2
+
+ - name: "Install PHP with extensions"
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php-version }}
+ coverage: pcov
+ extensions: json
+
+ - name: "Install dependencies with composer"
+ run: composer update --no-ansi --no-interaction --no-progress --no-suggest
+
+ - name: "Run tests with phpunit"
+ run: php vendor/phpunit/phpunit/phpunit --configuration=phpunit.xml
+
+ - name: "Send code coverage report to Codecov.io"
+ uses: codecov/codecov-action@v1
+ with:
+ token: ${{ secrets.CODECOV_TOKEN }}
diff --git a/vendor/chillerlan/php-settings-container/.gitignore b/vendor/chillerlan/php-settings-container/.gitignore
index e313cba45..142dd453a 100644
--- a/vendor/chillerlan/php-settings-container/.gitignore
+++ b/vendor/chillerlan/php-settings-container/.gitignore
@@ -1,4 +1,4 @@
-.idea
-.vendor
+/.build
+/.idea
+/vendor
composer.lock
-*.phpunit.result.cache
diff --git a/vendor/chillerlan/php-settings-container/.phan/config.php b/vendor/chillerlan/php-settings-container/.phan/config.php
new file mode 100644
index 000000000..468bd9983
--- /dev/null
+++ b/vendor/chillerlan/php-settings-container/.phan/config.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * This configuration will be read and overlaid on top of the
+ * default configuration. Command-line arguments will be applied
+ * after this file is read.
+ */
+return [
+ // Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`,
+ // `'7.4'`, `null`.
+ // If this is set to `null`,
+ // then Phan assumes the PHP version which is closest to the minor version
+ // of the php executable used to execute Phan.
+ //
+ // Note that the **only** effect of choosing `'5.6'` is to infer
+ // that functions removed in php 7.0 exist.
+ // (See `backward_compatibility_checks` for additional options)
+ 'target_php_version' => '7.4',
+
+ // A list of directories that should be parsed for class and
+ // method information. After excluding the directories
+ // defined in exclude_analysis_directory_list, the remaining
+ // files will be statically analyzed for errors.
+ //
+ // Thus, both first-party and third-party code being used by
+ // your application should be included in this list.
+ 'directory_list' => [
+ 'examples',
+ 'src',
+ 'tests',
+ 'vendor',
+ ],
+
+ // A regex used to match every file name that you want to
+ // exclude from parsing. Actual value will exclude every
+ // "test", "tests", "Test" and "Tests" folders found in
+ // "vendor/" directory.
+ 'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@',
+
+ // A directory list that defines files that will be excluded
+ // from static analysis, but whose class and method
+ // information should be included.
+ //
+ // Generally, you'll want to include the directories for
+ // third-party code (such as "vendor/") in this list.
+ //
+ // n.b.: If you'd like to parse but not analyze 3rd
+ // party code, directories containing that code
+ // should be added to both the `directory_list`
+ // and `exclude_analysis_directory_list` arrays.
+ 'exclude_analysis_directory_list' => [
+ 'tests',
+ 'vendor',
+ ],
+];
diff --git a/vendor/chillerlan/php-settings-container/.scrutinizer.yml b/vendor/chillerlan/php-settings-container/.scrutinizer.yml
index 7fdd2a4dc..daeb475f4 100644
--- a/vendor/chillerlan/php-settings-container/.scrutinizer.yml
+++ b/vendor/chillerlan/php-settings-container/.scrutinizer.yml
@@ -1,3 +1,12 @@
+build:
+ nodes:
+ analysis:
+ tests:
+ override:
+ - php-scrutinizer-run
+ environment:
+ php: 8.0.0
+
filter:
excluded_paths:
- examples/*
diff --git a/vendor/chillerlan/php-settings-container/.travis.yml b/vendor/chillerlan/php-settings-container/.travis.yml
deleted file mode 100644
index c2ad210ed..000000000
--- a/vendor/chillerlan/php-settings-container/.travis.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-language: php
-
-matrix:
- include:
- - php: 7.2
- - php: 7.3
- - php: 7.4
- - php: 8.0
- - php: nightly
- allow_failures:
- - php: nightly
-
-
-before_script: travis_retry composer install --no-interaction --prefer-source
-
-script: vendor/bin/phpunit --configuration phpunit.xml --coverage-clover clover.xml
-
-after_script: bash <(curl -s https://codecov.io/bash)
diff --git a/vendor/chillerlan/php-settings-container/README.md b/vendor/chillerlan/php-settings-container/README.md
index f3bb26c5e..b5fd4ad27 100644
--- a/vendor/chillerlan/php-settings-container/README.md
+++ b/vendor/chillerlan/php-settings-container/README.md
@@ -1,52 +1,46 @@
# chillerlan/php-settings-container
-A container class for immutable settings objects. Not a DI container. PHP 7.2+
-- [`SettingsContainerInterface`](https://github.com/chillerlan/php-settings-container/blob/master/src/SettingsContainerInterface.php) provides immutable properties with magic getter & setter and some fancy
+A container class for immutable settings objects. Not a DI container. PHP 7.4+
+- [`SettingsContainerInterface`](https://github.com/chillerlan/php-settings-container/blob/main/src/SettingsContainerInterface.php) provides immutable properties with magic getter & setter and some fancy - decouple configuration logic from your application!
+[![PHP Version Support][php-badge]][php]
[![version][packagist-badge]][packagist]
[![license][license-badge]][license]
-[![Travis][travis-badge]][travis]
[![Coverage][coverage-badge]][coverage]
[![Scrunitizer][scrutinizer-badge]][scrutinizer]
[![Packagist downloads][downloads-badge]][downloads]
-[![PayPal donate][donate-badge]][donate]
+[![Continuous Integration][gh-action-badge]][gh-action]
-[packagist-badge]: https://img.shields.io/packagist/v/chillerlan/php-settings-container.svg?style=flat-square
+[php-badge]: https://img.shields.io/packagist/php-v/chillerlan/php-settings-container?logo=php&color=8892BF
+[php]: https://www.php.net/supported-versions.php
+[packagist-badge]: https://img.shields.io/packagist/v/chillerlan/php-settings-container.svg?logo=packagist
[packagist]: https://packagist.org/packages/chillerlan/php-settings-container
-[license-badge]: https://img.shields.io/github/license/chillerlan/php-settings-container.svg?style=flat-square
-[license]: https://github.com/chillerlan/php-settings-container/blob/master/LICENSE
-[travis-badge]: https://img.shields.io/travis/chillerlan/php-settings-container.svg?style=flat-square
-[travis]: https://travis-ci.org/chillerlan/php-settings-container
-[coverage-badge]: https://img.shields.io/codecov/c/github/chillerlan/php-settings-container.svg?style=flat-square
+[license-badge]: https://img.shields.io/github/license/chillerlan/php-settings-container.svg
+[license]: https://github.com/chillerlan/php-settings-container/blob/main/LICENSE
+[coverage-badge]: https://img.shields.io/codecov/c/github/chillerlan/php-settings-container.svg?logo=codecov
[coverage]: https://codecov.io/github/chillerlan/php-settings-container
-[scrutinizer-badge]: https://img.shields.io/scrutinizer/g/chillerlan/php-settings-container.svg?style=flat-square
+[scrutinizer-badge]: https://img.shields.io/scrutinizer/g/chillerlan/php-settings-container.svg?logo=scrutinizer
[scrutinizer]: https://scrutinizer-ci.com/g/chillerlan/php-settings-container
-[downloads-badge]: https://img.shields.io/packagist/dt/chillerlan/php-settings-container.svg?style=flat-square
+[downloads-badge]: https://img.shields.io/packagist/dt/chillerlan/php-settings-container.svg?logo=packagist
[downloads]: https://packagist.org/packages/chillerlan/php-settings-container/stats
-[donate-badge]: https://img.shields.io/badge/donate-paypal-ff33aa.svg?style=flat-square
-[donate]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WLYUNAT9ZTJZ4
+[gh-action-badge]: https://github.com/chillerlan/php-settings-container/workflows/CI/badge.svg
+[gh-action]: https://github.com/chillerlan/php-settings-container/actions?query=workflow%3A%22CI%22
## Documentation
### Installation
**requires [composer](https://getcomposer.org)**
-*composer.json* (note: replace `dev-master` with a version boundary)
+*composer.json* (note: replace `dev-main` with a [version constraint](https://getcomposer.org/doc/articles/versions.md#writing-version-constraints), e.g. `^2.1` - see [releases](https://github.com/chillerlan/php-settings-container/releases) for valid versions)
```json
{
"require": {
- "php": "^7.2",
- "chillerlan/php-settings-container": "^1.0"
+ "php": "^7.4",
+ "chillerlan/php-settings-container": "dev-main"
}
}
```
-### Manual installation
-Download the desired version of the package from [master](https://github.com/chillerlan/php-settings-container/archive/master.zip) or
-[release](https://github.com/chillerlan/php-settings-container/releases) and extract the contents to your project folder. After that:
-- run `composer install` to install the required dependencies and generate `/vendor/autoload.php`.
-- if you use a custom autoloader, point the namespace `chillerlan\Settings` to the folder `src` of the package
-
Profit!
## Usage
@@ -140,7 +134,7 @@ var_dump($container->what); // -> md5 hash of "some value"
### API
-#### [`SettingsContainerAbstract`](https://github.com/chillerlan/php-settings-container/blob/master/src/SettingsContainerAbstract.php)
+#### [`SettingsContainerAbstract`](https://github.com/chillerlan/php-settings-container/blob/main/src/SettingsContainerAbstract.php)
method | return | info
-------- | ---- | -----------
diff --git a/vendor/chillerlan/php-settings-container/composer.json b/vendor/chillerlan/php-settings-container/composer.json
index 4464e6e8a..1d89b6c41 100644
--- a/vendor/chillerlan/php-settings-container/composer.json
+++ b/vendor/chillerlan/php-settings-container/composer.json
@@ -1,12 +1,12 @@
{
"name": "chillerlan/php-settings-container",
- "description": "A container class for immutable settings objects. Not a DI container. PHP 7.2+",
+ "description": "A container class for immutable settings objects. Not a DI container. PHP 7.4+",
"homepage": "https://github.com/chillerlan/php-settings-container",
"license": "MIT",
"type": "library",
"minimum-stability": "stable",
"keywords": [
- "php7", "helper", "container", "settings"
+ "php7", "helper", "container", "settings", "configuration"
],
"authors": [
{
@@ -20,11 +20,12 @@
"source": "https://github.com/chillerlan/php-settings-container"
},
"require": {
- "php": "^7.2 || ^8.0",
+ "php": "^7.4 || ^8.0",
"ext-json": "*"
},
"require-dev": {
- "phpunit/phpunit": "^8.4"
+ "phan/phan": "^5.3",
+ "phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
@@ -36,5 +37,14 @@
"chillerlan\\SettingsTest\\": "tests/",
"chillerlan\\SettingsExamples\\": "examples/"
}
+ },
+ "scripts": {
+ "phpunit": "@php vendor/bin/phpunit",
+ "phan": "@php vendor/bin/phan"
+ },
+ "config": {
+ "lock": false,
+ "sort-packages": true,
+ "platform-check": true
}
}
diff --git a/vendor/chillerlan/php-settings-container/docs/Readme.md b/vendor/chillerlan/php-settings-container/docs/Readme.md
new file mode 100644
index 000000000..7749a1e7f
--- /dev/null
+++ b/vendor/chillerlan/php-settings-container/docs/Readme.md
@@ -0,0 +1,13 @@
+# Auto generated API documentation
+
+The API documentation can be auto generated with [phpDocumentor](https://www.phpdoc.org/).
+There is an [online version available](https://chillerlan.github.io/php-settings-container/) via the [gh-pages branch](https://github.com/chillerlan/php-settings-container/tree/gh-pages) that is [automatically deployed](https://github.com/chillerlan/php-settings-container/deployments) on each push to main.
+
+Locally created docs will appear in this directory. If you'd like to create local docs, please follow these steps:
+
+- [download phpDocumentor](https://github.com/phpDocumentor/phpDocumentor/releases) v3+ as .phar archive
+- run it in the repository root directory:
+ - on Windows `c:\path\to\php.exe c:\path\to\phpDocumentor.phar --config=phpdoc.xml`
+ - on Linux just `php /path/to/phpDocumentor.phar --config=phpdoc.xml`
+- open [index.html](./index.html) in a browser
+- profit!
diff --git a/vendor/chillerlan/php-settings-container/examples/advanced.php b/vendor/chillerlan/php-settings-container/examples/advanced.php
index 1030b0a29..f11642c83 100644
--- a/vendor/chillerlan/php-settings-container/examples/advanced.php
+++ b/vendor/chillerlan/php-settings-container/examples/advanced.php
@@ -1,6 +1,5 @@
<?php
/**
- * @filesource advanced.php
* @created 28.08.2018
* @author smiley <[email protected]>
* @copyright 2018 smiley
@@ -15,7 +14,7 @@ require_once __DIR__.'/../vendor/autoload.php';
// from library #1
trait SomeOptions{
- protected $foo;
+ protected string $foo = '';
// this method will be called in SettingsContainerAbstract::__construct() after the properties have been set
protected function SomeOptions(){
@@ -26,7 +25,7 @@ trait SomeOptions{
// from library #2
trait MoreOptions{
- protected $bar = 'whatever'; // provide default values
+ protected string $bar = 'whatever'; // provide default values
}
$commonOptions = [
@@ -37,10 +36,16 @@ $commonOptions = [
];
// now plug the several library options together to a single object
-/** @var \chillerlan\Settings\SettingsContainerInterface $container */
-$container = new class ($commonOptions) extends SettingsContainerAbstract{
+
+/**
+ * @property string $foo
+ * @property string $bar
+ */
+class MySettings extends SettingsContainerAbstract{
use SomeOptions, MoreOptions; // ...
};
+$container = new MySettings($commonOptions);
+
var_dump($container->foo); // -> WHATEVER (constructor ran strtoupper on the value)
var_dump($container->bar); // -> nothing
diff --git a/vendor/chillerlan/php-settings-container/examples/simple.php b/vendor/chillerlan/php-settings-container/examples/simple.php
index d8d81095b..acdbe4cb3 100644
--- a/vendor/chillerlan/php-settings-container/examples/simple.php
+++ b/vendor/chillerlan/php-settings-container/examples/simple.php
@@ -1,6 +1,5 @@
<?php
/**
- * @filesource simple.php
* @created 28.08.2018
* @author smiley <[email protected]>
* @copyright 2018 smiley
diff --git a/vendor/chillerlan/php-settings-container/phpdoc.xml b/vendor/chillerlan/php-settings-container/phpdoc.xml
new file mode 100644
index 000000000..d440f1d8a
--- /dev/null
+++ b/vendor/chillerlan/php-settings-container/phpdoc.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<phpdoc>
+ <parser>
+ <target>docs</target>
+ <encoding>utf8</encoding>
+ <markers>
+ <item>TODO</item>
+ </markers>
+ </parser>
+ <transformer>
+ <target>docs</target>
+ </transformer>
+ <files>
+ <directory>src</directory>
+ <directory>tests</directory>
+ </files>
+ <transformations>
+ <template name="responsive-twig"/>
+ </transformations>
+</phpdoc>
diff --git a/vendor/chillerlan/php-settings-container/phpmd.xml b/vendor/chillerlan/php-settings-container/phpmd.xml
deleted file mode 100644
index 3ba7e11b7..000000000
--- a/vendor/chillerlan/php-settings-container/phpmd.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0"?>
-<ruleset name="codemasher/php-settings-container PMD ruleset"
- xmlns="http://pmd.sf.net/ruleset/1.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
- xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
- <description>codemasher/php-settings-container PMD ruleset</description>
- <exclude-pattern>*/examples/*</exclude-pattern>
- <exclude-pattern>*/tests/*</exclude-pattern>
- <exclude-pattern>*/vendor/*</exclude-pattern>
- <rule ref="rulesets/cleancode.xml">
- <exclude name="BooleanArgumentFlag"/>
- </rule>
- <rule ref="rulesets/codesize.xml/CyclomaticComplexity">
- <priority>1</priority>
- <properties>
- <property name="maximum" value="150" />
- </properties>
- </rule>
- <rule ref="rulesets/controversial.xml">
- <exclude name="CamelCaseMethodName"/>
- <exclude name="CamelCasePropertyName"/>
- <exclude name="CamelCaseParameterName"/>
- <exclude name="CamelCaseVariableName"/>
- </rule>
- <rule ref="rulesets/design.xml">
- </rule>
- <rule ref="rulesets/naming.xml">
- <exclude name="LongVariable"/>
- <exclude name="ShortVariable"/>
- </rule>
- <rule ref="rulesets/unusedcode.xml">
- <exclude name="UnusedFormalParameter"/>
- </rule>
-</ruleset>
diff --git a/vendor/chillerlan/php-settings-container/phpunit.xml b/vendor/chillerlan/php-settings-container/phpunit.xml
index bb05d1289..9271a1bb1 100644
--- a/vendor/chillerlan/php-settings-container/phpunit.xml
+++ b/vendor/chillerlan/php-settings-container/phpunit.xml
@@ -1,22 +1,26 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<phpunit backupGlobals="false"
- backupStaticAttributes="false"
- bootstrap="vendor/autoload.php"
- colors="true"
- convertErrorsToExceptions="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
- processIsolation="false"
- stopOnFailure="false"
+<?xml version="1.0"?>
+<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
+ bootstrap="vendor/autoload.php"
+ cacheResultFile=".build/phpunit.result.cache"
+ colors="true"
+ verbose="true"
>
- <filter>
- <whitelist processUncoveredFilesFromWhitelist="true">
- <directory suffix=".php">./src</directory>
- </whitelist>
- </filter>
- <testsuites>
- <testsuite name="php-settings-container test suite">
- <directory suffix=".php">./tests/</directory>
- </testsuite>
- </testsuites>
+ <coverage processUncoveredFiles="true">
+ <include>
+ <directory suffix=".php">./src</directory>
+ </include>
+ <report>
+ <clover outputFile=".build/coverage/clover.xml"/>
+ <xml outputDirectory=".build/coverage/coverage-xml"/>
+ </report>
+ </coverage>
+ <testsuites>
+ <testsuite name="php-settings-container test suite">
+ <directory suffix=".php">./tests/</directory>
+ </testsuite>
+ </testsuites>
+ <logging>
+ <junit outputFile=".build/logs/junit.xml"/>
+ </logging>
</phpunit>
diff --git a/vendor/chillerlan/php-settings-container/src/SettingsContainerAbstract.php b/vendor/chillerlan/php-settings-container/src/SettingsContainerAbstract.php
index 1ccc1a0e2..f643f73d0 100644
--- a/vendor/chillerlan/php-settings-container/src/SettingsContainerAbstract.php
+++ b/vendor/chillerlan/php-settings-container/src/SettingsContainerAbstract.php
@@ -2,9 +2,7 @@
/**
* Class SettingsContainerAbstract
*
- * @filesource SettingsContainerAbstract.php
* @created 28.08.2018
- * @package chillerlan\Settings
* @author Smiley <[email protected]>
* @copyright 2018 Smiley
* @license MIT
@@ -12,16 +10,15 @@
namespace chillerlan\Settings;
-use Exception, ReflectionClass, ReflectionProperty;
+use ReflectionClass, ReflectionProperty;
-use function call_user_func, call_user_func_array, get_object_vars, json_decode, json_encode, method_exists, property_exists;
+use function get_object_vars, json_decode, json_encode, method_exists, property_exists;
+use const JSON_THROW_ON_ERROR;
abstract class SettingsContainerAbstract implements SettingsContainerInterface{
/**
* SettingsContainerAbstract constructor.
- *
- * @param iterable|null $properties
*/
public function __construct(iterable $properties = null){
@@ -35,8 +32,6 @@ abstract class SettingsContainerAbstract implements SettingsContainerInterface{
/**
* calls a method with trait name as replacement constructor for each used trait
* (remember pre-php5 classname constructors? yeah, basically this.)
- *
- * @return void
*/
protected function construct():void{
$traits = (new ReflectionClass($this))->getTraits();
@@ -45,7 +40,7 @@ abstract class SettingsContainerAbstract implements SettingsContainerInterface{
$method = $trait->getShortName();
if(method_exists($this, $method)){
- call_user_func([$this, $method]);
+ $this->{$method}();
}
}
@@ -56,16 +51,17 @@ abstract class SettingsContainerAbstract implements SettingsContainerInterface{
*/
public function __get(string $property){
- if(property_exists($this, $property) && !$this->isPrivate($property)){
+ if(!property_exists($this, $property) || $this->isPrivate($property)){
+ return null;
+ }
- if(method_exists($this, 'get_'.$property)){
- return call_user_func([$this, 'get_'.$property]);
- }
+ $method = 'get_'.$property;
- return $this->{$property};
+ if(method_exists($this, $method)){
+ return $this->{$method}();
}
- return null;
+ return $this->{$property};
}
/**
@@ -77,8 +73,10 @@ abstract class SettingsContainerAbstract implements SettingsContainerInterface{
return;
}
- if(method_exists($this, 'set_'.$property)){
- call_user_func_array([$this, 'set_'.$property], [$value]);
+ $method = 'set_'.$property;
+
+ if(method_exists($this, $method)){
+ $this->{$method}($value);
return;
}
@@ -95,10 +93,6 @@ abstract class SettingsContainerAbstract implements SettingsContainerInterface{
/**
* @internal Checks if a property is private
- *
- * @param string $property
- *
- * @return bool
*/
protected function isPrivate(string $property):bool{
return (new ReflectionProperty($this, $property))->isPrivate();
@@ -152,12 +146,7 @@ abstract class SettingsContainerAbstract implements SettingsContainerInterface{
* @inheritdoc
*/
public function fromJSON(string $json):SettingsContainerInterface{
-
- $data = json_decode($json, true); // as of PHP 7.3: JSON_THROW_ON_ERROR
-
- if($data === false || $data === null){
- throw new Exception('error while decoding JSON');
- }
+ $data = json_decode($json, true, 512, JSON_THROW_ON_ERROR);
return $this->fromIterable($data);
}
@@ -165,7 +154,7 @@ abstract class SettingsContainerAbstract implements SettingsContainerInterface{
/**
* @inheritdoc
*/
- public function jsonSerialize(){
+ public function jsonSerialize():array{
return $this->toArray();
}
diff --git a/vendor/chillerlan/php-settings-container/src/SettingsContainerInterface.php b/vendor/chillerlan/php-settings-container/src/SettingsContainerInterface.php
index 59cef6232..ddacccd29 100644
--- a/vendor/chillerlan/php-settings-container/src/SettingsContainerInterface.php
+++ b/vendor/chillerlan/php-settings-container/src/SettingsContainerInterface.php
@@ -2,9 +2,7 @@
/**
* Interface SettingsContainerInterface
*
- * @filesource SettingsContainerInterface.php
* @created 28.08.2018
- * @package chillerlan\Settings
* @author Smiley <[email protected]>
* @copyright 2018 Smiley
* @license MIT
@@ -22,9 +20,7 @@ interface SettingsContainerInterface extends JsonSerializable{
/**
* Retrieve the value of $property
*
- * @param string $property
- *
- * @return mixed
+ * @return mixed|null
*/
public function __get(string $property);
@@ -33,69 +29,43 @@ interface SettingsContainerInterface extends JsonSerializable{
*
* @param string $property
* @param mixed $value
- *
- * @return void
*/
public function __set(string $property, $value):void;
/**
* Checks if $property is set (aka. not null), excluding private properties
- *
- * @param string $property
- *
- * @return bool
*/
public function __isset(string $property):bool;
/**
* Unsets $property while avoiding private and non-existing properties
- *
- * @param string $property
- *
- * @return void
*/
public function __unset(string $property):void;
/**
* @see SettingsContainerInterface::toJSON()
- *
- * @return string
*/
public function __toString():string;
/**
* Returns an array representation of the settings object
- *
- * @return array
*/
public function toArray():array;
/**
* Sets properties from a given iterable
- *
- * @param iterable $properties
- *
- * @return \chillerlan\Settings\SettingsContainerInterface
*/
public function fromIterable(iterable $properties):SettingsContainerInterface;
/**
* Returns a JSON representation of the settings object
* @see \json_encode()
- *
- * @param int|null $jsonOptions
- *
- * @return string
*/
public function toJSON(int $jsonOptions = null):string;
/**
* Sets properties from a given JSON string
*
- * @param string $json
- *
- * @return \chillerlan\Settings\SettingsContainerInterface
- *
* @throws \Exception
* @throws \JsonException
*/
diff --git a/vendor/chillerlan/php-settings-container/tests/ContainerTest.php b/vendor/chillerlan/php-settings-container/tests/ContainerTest.php
index ddae538f3..8fca7c3e8 100644
--- a/vendor/chillerlan/php-settings-container/tests/ContainerTest.php
+++ b/vendor/chillerlan/php-settings-container/tests/ContainerTest.php
@@ -2,9 +2,7 @@
/**
* Class ContainerTraitTest
*
- * @filesource ContainerTraitTest.php
* @created 28.08.2018
- * @package chillerlan\SettingsTest
* @author Smiley <[email protected]>
* @copyright 2018 Smiley
* @license MIT
@@ -13,74 +11,86 @@
namespace chillerlan\SettingsTest;
use PHPUnit\Framework\TestCase;
-use Exception, TypeError;
+use JsonException, TypeError;
+use function sha1;
-class ContainerTraitTest extends TestCase{
+class ContainerTest extends TestCase{
public function testConstruct(){
$container = new TestContainer([
'test1' => 'test1',
- 'test2' => 'test2',
+ 'test2' => true,
'test3' => 'test3',
'test4' => 'test4',
]);
- $this->assertSame('test1', $container->test1);
- $this->assertSame('test2', $container->test2);
- $this->assertNull($container->test3);
- $this->assertSame('test4', $container->test4);
+ $this::assertSame('test1', $container->test1);
+ $this::assertSame(true, $container->test2);
+ $this::assertNull($container->test3);
+ $this::assertSame('test4', $container->test4);
- $this->assertSame('success', $container->testConstruct);
+ $this::assertSame('success', $container->testConstruct);
}
public function testGet(){
$container = new TestContainer;
- $this->assertSame('foo', $container->test1);
- $this->assertNull($container->test2);
- $this->assertNull($container->test3);
- $this->assertNull($container->test4);
- $this->assertNull($container->foo);
+ $this::assertSame('foo', $container->test1);
+ $this::assertNull($container->test2);
+ $this::assertNull($container->test3);
+ $this::assertNull($container->test4);
+ $this::assertNull($container->foo);
// isset test
- $this->assertTrue(isset($container->test1));
- $this->assertFalse(isset($container->test2));
- $this->assertFalse(isset($container->test3));
- $this->assertFalse(isset($container->test4));
- $this->assertFalse(isset($container->foo));
+ $this::assertTrue(isset($container->test1));
+ $this::assertFalse(isset($container->test2));
+ $this::assertFalse(isset($container->test3));
+ $this::assertFalse(isset($container->test4));
+ $this::assertFalse(isset($container->foo));
// custom getter
$container->test6 = 'foo';
- $this->assertSame(sha1('foo'), $container->test6);
+ $this::assertSame(sha1('foo'), $container->test6);
// nullable/isset test
$container->test6 = null;
- $this->assertFalse(isset($container->test6));
- $this->assertSame('null', $container->test6);
+ $this::assertFalse(isset($container->test6));
+ $this::assertSame('null', $container->test6);
}
public function testSet(){
$container = new TestContainer;
$container->test1 = 'bar';
- $container->test2 = 'what';
+ $container->test2 = false;
$container->test3 = 'nope';
- $this->assertSame('bar', $container->test1);
- $this->assertSame('what', $container->test2);
- $this->assertNull($container->test3);
+ $this::assertSame('bar', $container->test1);
+ $this::assertSame(false, $container->test2);
+ $this::assertNull($container->test3);
// unset
unset($container->test1);
- $this->assertFalse(isset($container->test1));
+ $this::assertFalse(isset($container->test1));
// custom setter
$container->test5 = 'bar';
- $this->assertSame('bar_test5', $container->test5);
+ $this::assertSame('bar_test5', $container->test5);
}
public function testToArray(){
- $container = new TestContainer(['test1' => 'no', 'test2' => true, 'testConstruct' => 'success']);
+ $container = new TestContainer([
+ 'test1' => 'no',
+ 'test2' => true,
+ 'testConstruct' => 'success',
+ ]);
- $this->assertSame(['test1' => 'no', 'test2' => true, 'testConstruct' => 'success', 'test4' => null, 'test5' => null, 'test6' => null], $container->toArray());
+ $this::assertSame([
+ 'test1' => 'no',
+ 'test2' => true,
+ 'testConstruct' => 'success',
+ 'test4' => null,
+ 'test5' => null,
+ 'test6' => null
+ ], $container->toArray());
}
public function testToJSON(){
@@ -88,12 +98,12 @@ class ContainerTraitTest extends TestCase{
$expected = '{"test1":"no","test2":true,"testConstruct":"success","test4":null,"test5":null,"test6":null}';
- $this->assertSame($expected, $container->toJSON());
- $this->assertSame($expected, (string)$container);
+ $this::assertSame($expected, $container->toJSON());
+ $this::assertSame($expected, (string)$container);
}
public function testFromJsonException(){
- $this->expectException(Exception::class);
+ $this->expectException(JsonException::class);
(new TestContainer)->fromJSON('-');
}
diff --git a/vendor/chillerlan/php-settings-container/tests/TestContainer.php b/vendor/chillerlan/php-settings-container/tests/TestContainer.php
index a35f75277..a83f4bef3 100644
--- a/vendor/chillerlan/php-settings-container/tests/TestContainer.php
+++ b/vendor/chillerlan/php-settings-container/tests/TestContainer.php
@@ -2,9 +2,7 @@
/**
* Class TestContainer
*
- * @filesource TestContainer.php
* @created 28.08.2018
- * @package chillerlan\SettingsTest
* @author Smiley <[email protected]>
* @copyright 2018 Smiley
* @license MIT
@@ -25,5 +23,5 @@ use chillerlan\Settings\SettingsContainerAbstract;
class TestContainer extends SettingsContainerAbstract{
use TestOptionsTrait;
- private $test3 = 'what';
+ private string $test3 = 'what';
}
diff --git a/vendor/chillerlan/php-settings-container/tests/TestOptionsTrait.php b/vendor/chillerlan/php-settings-container/tests/TestOptionsTrait.php
index 261f533ac..c8c628b5b 100644
--- a/vendor/chillerlan/php-settings-container/tests/TestOptionsTrait.php
+++ b/vendor/chillerlan/php-settings-container/tests/TestOptionsTrait.php
@@ -2,9 +2,7 @@
/**
* Trait TestOptionsTrait
*
- * @filesource TestOptionsTrait.php
* @created 28.08.2018
- * @package chillerlan\SettingsTest
* @author smiley <[email protected]>
* @copyright 2018 smiley
* @license MIT
@@ -12,29 +10,31 @@
namespace chillerlan\SettingsTest;
+use function sha1;
+
trait TestOptionsTrait{
- protected $test1 = 'foo';
+ protected string $test1 = 'foo';
- protected $test2;
+ protected ?bool $test2 = null;
- protected $testConstruct;
+ protected string $testConstruct;
- protected $test4;
+ protected ?string $test4 = null;
- protected $test5;
+ protected ?string $test5 = null;
- protected $test6;
+ protected ?string $test6 = null;
- protected function TestOptionsTrait(){
+ protected function TestOptionsTrait():void{
$this->testConstruct = 'success';
}
- protected function set_test5($value){
+ protected function set_test5($value):void{
$this->test5 = $value.'_test5';
}
- protected function get_test6(){
+ protected function get_test6():string{
return $this->test6 === null
? 'null'
: sha1($this->test6);