From 05f699a907fa4ed28c9d561f3dca77ec193c8374 Mon Sep 17 00:00:00 2001 From: Rafael Dohms Date: Wed, 13 May 2020 18:33:57 +0200 Subject: [PATCH 1/4] Update Deps and PHP to 7.4 Drop support for PHP 5.3 and anything below 7.4. And move all dependencies to modern versions for a good bit of housecleaning. --- composer.json | 26 +- composer.lock | 1937 ++++++++++++++--- phpunit.xml | 21 +- tests/DMS/Filter/FilterTest.php | 29 +- tests/DMS/Filter/Filters/AlnumTest.php | 8 +- tests/DMS/Filter/Filters/AlphaTest.php | 8 +- tests/DMS/Filter/Filters/BooleanTest.php | 8 +- tests/DMS/Filter/Filters/CallbackTest.php | 65 +- tests/DMS/Filter/Filters/DigitsTest.php | 10 +- tests/DMS/Filter/Filters/FloatTest.php | 8 +- tests/DMS/Filter/Filters/HtmlEntitiesTest.php | 8 +- tests/DMS/Filter/Filters/IntTest.php | 8 +- .../Filters/Loader/FilterLoaderTest.php | 10 +- tests/DMS/Filter/Filters/PregReplaceTest.php | 8 +- .../DMS/Filter/Filters/StripNewlinesTest.php | 8 +- tests/DMS/Filter/Filters/StripTagsTest.php | 8 +- tests/DMS/Filter/Filters/ToLowerTest.php | 12 +- tests/DMS/Filter/Filters/ToUpperTest.php | 12 +- tests/DMS/Filter/Filters/TrimTest.php | 8 +- tests/DMS/Filter/Filters/ZendTest.php | 7 +- .../Mapping/ClassMetadataFactoryTest.php | 8 +- tests/DMS/Filter/Rules/CallbackTest.php | 7 +- tests/DMS/Filter/Rules/RuleTest.php | 26 +- tests/DMS/Tests/FilterTestCase.php | 7 +- 24 files changed, 1768 insertions(+), 489 deletions(-) diff --git a/composer.json b/composer.json index 0e19838..85f089a 100644 --- a/composer.json +++ b/composer.json @@ -14,30 +14,22 @@ ], "require": { - "php": "^5.3.2 || ^7.0", + "php": "^7.4", "doctrine/annotations": "~1.1" }, + "require-dev": { + "doctrine/cache": "~1.3", + "phpunit/phpunit": "^9", + "laminas/laminas-filter": "^2.9" + }, "autoload": { "psr-0": { "DMS": ["src","tests"] } }, - - "require-dev": { - "phpunit/phpunit": "~3.7", - "doctrine/cache": "~1.3", - "zendframework/zend-filter": "^2.0.3" - }, - + "suggest": { - "zendframework/zend-filter": "Use Zend Filters via DMS Filter" - }, - - "repositories": [ - { - "type": "composer", - "url": "https://packages.zendframework.com/" - } - ] + "laminas/laminas-filter": "Use Laminas Filters via DMS Filter" + } } diff --git a/composer.lock b/composer.lock index 6d4f9d3..5864709 100644 --- a/composer.lock +++ b/composer.lock @@ -1,43 +1,43 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "hash": "abb987eb72310f03b2ce5ea363edc099", - "content-hash": "e236739287e67bb687329a15f8b806bb", + "content-hash": "a6b0efd28bc38cc7a4f76e38a9bee782", "packages": [ { "name": "doctrine/annotations", - "version": "v1.2.7", + "version": "1.10.2", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535" + "reference": "b9d758e831c70751155c698c2f7df4665314a1cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/f25c8aab83e0c3e976fd7d19875f198ccf2f7535", - "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/b9d758e831c70751155c698c2f7df4665314a1cb", + "reference": "b9d758e831c70751155c698c2f7df4665314a1cb", "shasum": "" }, "require": { "doctrine/lexer": "1.*", - "php": ">=5.3.2" + "ext-tokenizer": "*", + "php": "^7.1" }, "require-dev": { "doctrine/cache": "1.*", - "phpunit/phpunit": "4.*" + "phpunit/phpunit": "^7.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "1.9.x-dev" } }, "autoload": { - "psr-0": { - "Doctrine\\Common\\Annotations\\": "lib/" + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" } }, "notification-url": "https://packagist.org/downloads/", @@ -45,6 +45,10 @@ "MIT" ], "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, { "name": "Roman Borschel", "email": "roman@code-factory.org" @@ -53,10 +57,6 @@ "name": "Benjamin Eberlei", "email": "kontakt@beberlei.de" }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, { "name": "Jonathan Wage", "email": "jonwage@gmail.com" @@ -73,34 +73,39 @@ "docblock", "parser" ], - "time": "2015-08-31 12:32:49" + "time": "2020-04-20T09:18:32+00:00" }, { "name": "doctrine/lexer", - "version": "v1.0.1", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/lexer.git", - "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" + "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", - "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", + "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", "shasum": "" }, "require": { - "php": ">=5.3.2" + "php": "^7.2" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "phpstan/phpstan": "^0.11.8", + "phpunit/phpunit": "^8.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { - "psr-0": { - "Doctrine\\Common\\Lexer\\": "lib/" + "psr-4": { + "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" } }, "notification-url": "https://packagist.org/downloads/", @@ -108,58 +113,66 @@ "MIT" ], "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, { "name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com" }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, { "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com" } ], - "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", - "homepage": "http://www.doctrine-project.org", + "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "https://www.doctrine-project.org/projects/lexer.html", "keywords": [ + "annotations", + "docblock", "lexer", - "parser" + "parser", + "php" ], - "time": "2014-09-09 13:34:57" + "time": "2019-10-30T14:39:59+00:00" } ], "packages-dev": [ { "name": "doctrine/cache", - "version": "v1.6.0", + "version": "1.10.0", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6" + "reference": "382e7f4db9a12dc6c19431743a2b096041bcdd62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/f8af318d14bdb0eff0336795b428b547bd39ccb6", - "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6", + "url": "https://api.github.com/repos/doctrine/cache/zipball/382e7f4db9a12dc6c19431743a2b096041bcdd62", + "reference": "382e7f4db9a12dc6c19431743a2b096041bcdd62", "shasum": "" }, "require": { - "php": "~5.5|~7.0" + "php": "~7.1" }, "conflict": { "doctrine/common": ">2.2,<2.4" }, "require-dev": { - "phpunit/phpunit": "~4.8|~5.0", - "predis/predis": "~1.0", - "satooshi/php-coveralls": "~0.6" + "alcaeus/mongo-php-adapter": "^1.1", + "doctrine/coding-standard": "^6.0", + "mongodb/mongodb": "^1.1", + "phpunit/phpunit": "^7.0", + "predis/predis": "~1.0" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.9.x-dev" } }, "autoload": { @@ -172,6 +185,10 @@ "MIT" ], "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, { "name": "Roman Borschel", "email": "roman@code-factory.org" @@ -180,10 +197,6 @@ "name": "Benjamin Eberlei", "email": "kontakt@beberlei.de" }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, { "name": "Jonathan Wage", "email": "jonwage@gmail.com" @@ -193,40 +206,46 @@ "email": "schmittjoh@gmail.com" } ], - "description": "Caching library offering an object-oriented API for many cache backends", - "homepage": "http://www.doctrine-project.org", + "description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.", + "homepage": "https://www.doctrine-project.org/projects/cache.html", "keywords": [ + "abstraction", + "apcu", "cache", - "caching" + "caching", + "couchdb", + "memcached", + "php", + "redis", + "xcache" ], - "time": "2015-12-31 16:37:02" + "time": "2019-11-29T15:36:20+00:00" }, { - "name": "phpunit/php-code-coverage", - "version": "1.2.18", + "name": "doctrine/instantiator", + "version": "1.3.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b" + "url": "https://github.com/doctrine/instantiator.git", + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b", - "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", "shasum": "" }, "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": ">=1.3.0@stable", - "phpunit/php-text-template": ">=1.2.0@stable", - "phpunit/php-token-stream": ">=1.1.3,<1.3.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "3.7.*@dev" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.0.5" + "doctrine/coding-standard": "^6.0", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { @@ -235,364 +254,434 @@ } }, "autoload": { - "classmap": [ - "PHP/" - ] + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" } ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", "keywords": [ - "coverage", - "testing", - "xunit" + "constructor", + "instantiate" ], - "time": "2014-09-02 10:13:14" + "time": "2019-10-21T16:45:58+00:00" }, { - "name": "phpunit/php-file-iterator", - "version": "1.4.1", + "name": "laminas/laminas-filter", + "version": "2.9.4", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" + "url": "https://github.com/laminas/laminas-filter.git", + "reference": "3c4476e772a062cef7531c6793377ae585d89c82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", + "url": "https://api.github.com/repos/laminas/laminas-filter/zipball/3c4476e772a062cef7531c6793377ae585d89c82", + "reference": "3c4476e772a062cef7531c6793377ae585d89c82", "shasum": "" }, "require": { - "php": ">=5.3.3" + "laminas/laminas-stdlib": "^2.7.7 || ^3.1", + "laminas/laminas-zendframework-bridge": "^1.0", + "php": "^5.6 || ^7.0" + }, + "conflict": { + "laminas/laminas-validator": "<2.10.1" + }, + "replace": { + "zendframework/zend-filter": "^2.9.2" + }, + "require-dev": { + "laminas/laminas-coding-standard": "~1.0.0", + "laminas/laminas-crypt": "^3.2.1", + "laminas/laminas-servicemanager": "^2.7.8 || ^3.3", + "laminas/laminas-uri": "^2.6", + "pear/archive_tar": "^1.4.3", + "phpunit/phpunit": "^5.7.23 || ^6.4.3", + "psr/http-factory": "^1.0" + }, + "suggest": { + "laminas/laminas-crypt": "Laminas\\Crypt component, for encryption filters", + "laminas/laminas-i18n": "Laminas\\I18n component for filters depending on i18n functionality", + "laminas/laminas-servicemanager": "Laminas\\ServiceManager component, for using the filter chain functionality", + "laminas/laminas-uri": "Laminas\\Uri component, for the UriNormalize filter", + "psr/http-factory-implementation": "psr/http-factory-implementation, for creating file upload instances when consuming PSR-7 in file upload filters" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "2.9.x-dev", + "dev-develop": "2.10.x-dev" + }, + "laminas": { + "component": "Laminas\\Filter", + "config-provider": "Laminas\\Filter\\ConfigProvider" } }, "autoload": { - "classmap": [ - "src/" - ] + "psr-4": { + "Laminas\\Filter\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "description": "Programmatically filter and normalize data and files", + "homepage": "https://laminas.dev", "keywords": [ - "filesystem", - "iterator" + "filter", + "laminas" ], - "time": "2015-06-21 13:08:43" + "time": "2020-03-29T12:41:29+00:00" }, { - "name": "phpunit/php-text-template", - "version": "1.2.1", + "name": "laminas/laminas-stdlib", + "version": "3.2.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + "url": "https://github.com/laminas/laminas-stdlib.git", + "reference": "2b18347625a2f06a1a485acfbc870f699dbe51c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/2b18347625a2f06a1a485acfbc870f699dbe51c6", + "reference": "2b18347625a2f06a1a485acfbc870f699dbe51c6", "shasum": "" }, "require": { - "php": ">=5.3.3" + "laminas/laminas-zendframework-bridge": "^1.0", + "php": "^5.6 || ^7.0" + }, + "replace": { + "zendframework/zend-stdlib": "self.version" + }, + "require-dev": { + "laminas/laminas-coding-standard": "~1.0.0", + "phpbench/phpbench": "^0.13", + "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.2" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2.x-dev", + "dev-develop": "3.3.x-dev" + } + }, "autoload": { - "classmap": [ - "src/" - ] + "psr-4": { + "Laminas\\Stdlib\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "description": "SPL extensions, array utilities, error handlers, and more", + "homepage": "https://laminas.dev", + "keywords": [ + "laminas", + "stdlib" + ], + "time": "2019-12-31T17:51:15+00:00" + }, + { + "name": "laminas/laminas-zendframework-bridge", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-zendframework-bridge.git", + "reference": "bfbbdb6c998d50dbf69d2187cb78a5f1fa36e1e9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/bfbbdb6c998d50dbf69d2187cb78a5f1fa36e1e9", + "reference": "bfbbdb6c998d50dbf69d2187cb78a5f1fa36e1e9", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev", + "dev-develop": "1.1.x-dev" + }, + "laminas": { + "module": "Laminas\\ZendFrameworkBridge" + } + }, + "autoload": { + "files": [ + "src/autoload.php" + ], + "psr-4": { + "Laminas\\ZendFrameworkBridge\\": "src//" } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "description": "Alias legacy ZF class names to Laminas Project equivalents.", "keywords": [ - "template" + "ZendFramework", + "autoloading", + "laminas", + "zf" ], - "time": "2015-06-21 13:50:34" + "time": "2020-04-03T16:01:00+00:00" }, { - "name": "phpunit/php-timer", - "version": "1.0.7", + "name": "myclabs/deep-copy", + "version": "1.9.5", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b" + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef", + "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" }, "type": "library", "autoload": { - "classmap": [ - "src/" + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } + "MIT" ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", + "description": "Create deep copies (clones) of your objects", "keywords": [ - "timer" + "clone", + "copy", + "duplicate", + "object", + "object graph" ], - "time": "2015-06-21 08:01:12" + "time": "2020-01-17T21:11:47+00:00" }, { - "name": "phpunit/php-token-stream", - "version": "1.2.2", + "name": "phar-io/manifest", + "version": "1.0.3", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32" + "url": "https://github.com/phar-io/manifest.git", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32", - "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", "shasum": "" }, "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" + "ext-dom": "*", + "ext-phar": "*", + "phar-io/version": "^2.0", + "php": "^5.6 || ^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { "classmap": [ - "PHP/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "email": "sebastian@phpunit.de", + "role": "Developer" } ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2014-03-03 05:10:30" + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "time": "2018-07-08T19:23:20+00:00" }, { - "name": "phpunit/phpunit", - "version": "3.7.38", + "name": "phar-io/version", + "version": "2.0.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6" + "url": "https://github.com/phar-io/version.git", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/38709dc22d519a3d1be46849868aa2ddf822bcf6", - "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6", + "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", "shasum": "" }, "require": { - "ext-ctype": "*", - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpunit/php-code-coverage": "~1.2", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.1", - "phpunit/php-timer": "~1.0", - "phpunit/phpunit-mock-objects": "~1.2", - "symfony/yaml": "~2.0" - }, - "require-dev": { - "pear-pear.php.net/pear": "1.9.4" + "php": "^5.6 || ^7.0" }, - "suggest": { - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "composer/bin/phpunit" - ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.7.x-dev" - } - }, "autoload": { "classmap": [ - "PHPUnit/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "", - "../../symfony/yaml/" - ], "license": [ "BSD-3-Clause" ], "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de", - "role": "lead" + "role": "Developer" } ], - "description": "The PHP Unit Testing framework.", - "homepage": "http://www.phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2014-10-17 09:04:17" + "description": "Library for handling version information and constraints", + "time": "2018-07-08T19:19:57+00:00" }, { - "name": "phpunit/phpunit-mock-objects", - "version": "1.2.3", + "name": "phpdocumentor/reflection-common", + "version": "2.1.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875" + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875", - "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/6568f4687e5b41b054365f9ae03fcb1ed5f2069b", + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b", "shasum": "" }, "require": { - "php": ">=5.3.3", - "phpunit/php-text-template": ">=1.1.1@stable" - }, - "suggest": { - "ext-soap": "*" + "php": ">=7.1" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, "autoload": { - "classmap": [ - "PHPUnit/" - ] + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" } ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", "keywords": [ - "mock", - "xunit" + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" ], - "time": "2013-01-13 10:24:48" + "time": "2020-04-27T09:25:28+00:00" }, { - "name": "symfony/yaml", - "version": "v2.8.2", + "name": "phpdocumentor/reflection-docblock", + "version": "5.1.0", "source": { "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "34c8a4b51e751e7ea869b8262f883d008a2b81b8" + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/34c8a4b51e751e7ea869b8262f883d008a2b81b8", - "reference": "34c8a4b51e751e7ea869b8262f883d008a2b81b8", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", + "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", "shasum": "" }, "require": { - "php": ">=5.3.9" + "ext-filter": "^7.1", + "php": "^7.2", + "phpdocumentor/reflection-common": "^2.0", + "phpdocumentor/type-resolver": "^1.0", + "webmozart/assert": "^1" + }, + "require-dev": { + "doctrine/instantiator": "^1", + "mockery/mockery": "^1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.8-dev" + "dev-master": "5.x-dev" } }, "autoload": { "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "phpDocumentor\\Reflection\\": "src" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -600,128 +689,1334 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Mike van Riel", + "email": "me@mikevanriel.com" }, { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" } ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2016-01-13 10:28:07" + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2020-02-22T12:28:44+00:00" }, { - "name": "zendframework/zend-filter", - "version": "2.6.1", + "name": "phpdocumentor/type-resolver", + "version": "1.1.0", "source": { "type": "git", - "url": "https://github.com/zendframework/zend-filter.git", - "reference": "81078bee5529cfd7444c262b658e9f276b8f7af2" + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "7462d5f123dfc080dfdf26897032a6513644fc95" }, "dist": { "type": "zip", - "url": "https://packages.zendframework.com/composer/zendframework-zend-filter-2.6.1-bace94.zip", - "reference": "81078bee5529cfd7444c262b658e9f276b8f7af2", - "shasum": "d7a5a8264d158a6f472b2264dca363cdee7b652f" + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/7462d5f123dfc080dfdf26897032a6513644fc95", + "reference": "7462d5f123dfc080dfdf26897032a6513644fc95", + "shasum": "" }, "require": { - "php": "^5.5 || ^7.0", - "zendframework/zend-stdlib": "^2.7 || ^3.0" + "php": "^7.2", + "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "fabpot/php-cs-fixer": "1.7.*", - "pear/archive_tar": "^1.4", - "phpunit/phpunit": "~4.0", - "zendframework/zend-crypt": "^2.6", - "zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3", - "zendframework/zend-uri": "^2.5" - }, - "suggest": { - "zendframework/zend-crypt": "Zend\\Crypt component, for encryption filters", - "zendframework/zend-i18n": "Zend\\I18n component for filters depending on i18n functionality", - "zendframework/zend-servicemanager": "Zend\\ServiceManager component, for using the filter chain functionality", - "zendframework/zend-uri": "Zend\\Uri component, for the UriNormalize filter" + "ext-tokenizer": "^7.2", + "mockery/mockery": "~1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev", - "dev-develop": "2.7-dev" + "dev-master": "1.x-dev" } }, "autoload": { "psr-4": { - "Zend\\Filter\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "ZendTest\\Filter\\": "test/" + "phpDocumentor\\Reflection\\": "src" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], - "description": "provides a set of commonly needed data filters", - "homepage": "https://github.com/zendframework/zend-filter", - "keywords": [ - "filter", - "zf2" + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } ], - "time": "2016-02-08 18:02:37" + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "time": "2020-02-18T18:59:58+00:00" }, { - "name": "zendframework/zend-stdlib", - "version": "3.0.0", + "name": "phpspec/prophecy", + "version": "v1.10.3", "source": { "type": "git", - "url": "https://github.com/zendframework/zend-stdlib.git", - "reference": "86682d6607fe914577dab5388b95ef51ae18aa06" + "url": "https://github.com/phpspec/prophecy.git", + "reference": "451c3cd1418cf640de218914901e51b064abb093" }, "dist": { "type": "zip", - "url": "https://packages.zendframework.com/composer/zendframework-zend-stdlib-3.0.0-7f518e.zip", - "reference": "86682d6607fe914577dab5388b95ef51ae18aa06", - "shasum": "c813780712e2f3dc4cd28995c9c2b05a519de5c3" + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", + "reference": "451c3cd1418cf640de218914901e51b064abb093", + "shasum": "" }, "require": { - "php": "^5.5 || ^7.0" + "doctrine/instantiator": "^1.0.2", + "php": "^5.3|^7.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", + "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" }, "require-dev": { - "athletic/athletic": "~0.1", - "fabpot/php-cs-fixer": "1.7.*", - "phpunit/phpunit": "~4.0" + "phpspec/phpspec": "^2.5 || ^3.2", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev", - "dev-develop": "3.1-dev" + "dev-master": "1.10.x-dev" } }, "autoload": { "psr-4": { - "Zend\\Stdlib\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "ZendTest\\Stdlib\\": "test/", - "ZendBench\\Stdlib\\": "benchmark/" + "Prophecy\\": "src/Prophecy" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2020-03-05T15:02:03+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "8.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "31e94ccc084025d6abee0585df533eb3a792b96a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/31e94ccc084025d6abee0585df533eb3a792b96a", + "reference": "31e94ccc084025d6abee0585df533eb3a792b96a", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^7.3", + "phpunit/php-file-iterator": "^3.0", + "phpunit/php-text-template": "^2.0", + "phpunit/php-token-stream": "^4.0", + "sebastian/code-unit-reverse-lookup": "^2.0", + "sebastian/environment": "^5.0", + "sebastian/version": "^3.0", + "theseer/tokenizer": "^1.1.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "suggest": { + "ext-pcov": "*", + "ext-xdebug": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "8.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2020-02-19T13:41:19+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "4ac5b3e13df14829daa60a2eb4fdd2f2b7d33cf4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/4ac5b3e13df14829daa60a2eb4fdd2f2b7d33cf4", + "reference": "4ac5b3e13df14829daa60a2eb4fdd2f2b7d33cf4", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2020-04-18T05:02:12+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "7579d5a1ba7f3ac11c80004d205877911315ae7a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/7579d5a1ba7f3ac11c80004d205877911315ae7a", + "reference": "7579d5a1ba7f3ac11c80004d205877911315ae7a", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.0" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "time": "2020-02-07T06:06:11+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "526dc996cc0ebdfa428cd2dfccd79b7b53fee346" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/526dc996cc0ebdfa428cd2dfccd79b7b53fee346", + "reference": "526dc996cc0ebdfa428cd2dfccd79b7b53fee346", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2020-02-01T07:43:44+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "3.1.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "dc9368fae6ef2ffa57eba80a7410bcef81df6258" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/dc9368fae6ef2ffa57eba80a7410bcef81df6258", + "reference": "dc9368fae6ef2ffa57eba80a7410bcef81df6258", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2020-04-20T06:00:37+00:00" + }, + { + "name": "phpunit/php-token-stream", + "version": "4.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "cdc0db5aed8fbfaf475fbd95bfd7bab83c7a779c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/cdc0db5aed8fbfaf475fbd95bfd7bab83c7a779c", + "reference": "cdc0db5aed8fbfaf475fbd95bfd7bab83c7a779c", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": "^7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2020-05-06T09:56:31+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "9.1.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "2d7080c622cf7884992e7c3cf87853877bae8ff4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2d7080c622cf7884992e7c3cf87853877bae8ff4", + "reference": "2d7080c622cf7884992e7c3cf87853877bae8ff4", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.2.0", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.9.1", + "phar-io/manifest": "^1.0.3", + "phar-io/version": "^2.0.1", + "php": "^7.3", + "phpspec/prophecy": "^1.8.1", + "phpunit/php-code-coverage": "^8.0.1", + "phpunit/php-file-iterator": "^3.0", + "phpunit/php-invoker": "^3.0", + "phpunit/php-text-template": "^2.0", + "phpunit/php-timer": "^3.1.4", + "sebastian/code-unit": "^1.0.2", + "sebastian/comparator": "^4.0", + "sebastian/diff": "^4.0", + "sebastian/environment": "^5.0.1", + "sebastian/exporter": "^4.0", + "sebastian/global-state": "^4.0", + "sebastian/object-enumerator": "^4.0", + "sebastian/resource-operations": "^3.0", + "sebastian/type": "^2.0", + "sebastian/version": "^3.0" + }, + "require-dev": { + "ext-pdo": "*", + "phpspec/prophecy-phpunit": "^2.0" + }, + "suggest": { + "ext-soap": "*", + "ext-xdebug": "*" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ], + "files": [ + "src/Framework/Assert/Functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2020-04-30T06:32:53+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "ac958085bc19fcd1d36425c781ef4cbb5b06e2a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/ac958085bc19fcd1d36425c781ef4cbb5b06e2a5", + "reference": "ac958085bc19fcd1d36425c781ef4cbb5b06e2a5", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "time": "2020-04-30T05:58:10+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "5b5dbe0044085ac41df47e79d34911a15b96d82e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5b5dbe0044085ac41df47e79d34911a15b96d82e", + "reference": "5b5dbe0044085ac41df47e79d34911a15b96d82e", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "time": "2020-02-07T06:20:13+00:00" + }, + { + "name": "sebastian/comparator", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "85b3435da967696ed618ff745f32be3ff4a2b8e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/85b3435da967696ed618ff745f32be3ff4a2b8e8", + "reference": "85b3435da967696ed618ff745f32be3ff4a2b8e8", + "shasum": "" + }, + "require": { + "php": "^7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2020-02-07T06:08:51+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "3e523c576f29dacecff309f35e4cc5a5c168e78a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3e523c576f29dacecff309f35e4cc5a5c168e78a", + "reference": "3e523c576f29dacecff309f35e4cc5a5c168e78a", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "time": "2020-05-08T05:01:12+00:00" + }, + { + "name": "sebastian/environment", + "version": "5.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "c753f04d68cd489b6973cf9b4e505e191af3b05c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/c753f04d68cd489b6973cf9b4e505e191af3b05c", + "reference": "c753f04d68cd489b6973cf9b4e505e191af3b05c", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2020-04-14T13:36:52+00:00" + }, + { + "name": "sebastian/exporter", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "80c26562e964016538f832f305b2286e1ec29566" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/80c26562e964016538f832f305b2286e1ec29566", + "reference": "80c26562e964016538f832f305b2286e1ec29566", + "shasum": "" + }, + "require": { + "php": "^7.3", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2020-02-07T06:10:52+00:00" + }, + { + "name": "sebastian/global-state", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "bdb1e7c79e592b8c82cb1699be3c8743119b8a72" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bdb1e7c79e592b8c82cb1699be3c8743119b8a72", + "reference": "bdb1e7c79e592b8c82cb1699be3c8743119b8a72", + "shasum": "" + }, + "require": { + "php": "^7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^9.0" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2020-02-07T06:11:37+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "e67516b175550abad905dc952f43285957ef4363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/e67516b175550abad905dc952f43285957ef4363", + "reference": "e67516b175550abad905dc952f43285957ef4363", + "shasum": "" + }, + "require": { + "php": "^7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "time": "2020-02-07T06:12:23+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "f4fd0835cabb0d4a6546d9fe291e5740037aa1e7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/f4fd0835cabb0d4a6546d9fe291e5740037aa1e7", + "reference": "f4fd0835cabb0d4a6546d9fe291e5740037aa1e7", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "time": "2020-02-07T06:19:40+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "cdd86616411fc3062368b720b0425de10bd3d579" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cdd86616411fc3062368b720b0425de10bd3d579", + "reference": "cdd86616411fc3062368b720b0425de10bd3d579", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2020-02-07T06:18:20+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "8c98bf0dfa1f9256d0468b9803a1e1df31b6fa98" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/8c98bf0dfa1f9256d0468b9803a1e1df31b6fa98", + "reference": "8c98bf0dfa1f9256d0468b9803a1e1df31b6fa98", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2020-02-07T06:13:02+00:00" + }, + { + "name": "sebastian/type", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "9e8f42f740afdea51f5f4e8cec2035580e797ee1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/9e8f42f740afdea51f5f4e8cec2035580e797ee1", + "reference": "9e8f42f740afdea51f5f4e8cec2035580e797ee1", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "time": "2020-02-07T06:13:43+00:00" + }, + { + "name": "sebastian/version", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "0411bde656dce64202b39c2f4473993a9081d39e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/0411bde656dce64202b39c2f4473993a9081d39e", + "reference": "0411bde656dce64202b39c2f4473993a9081d39e", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2020-01-21T06:36:37+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.17.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e94c8b1bbe2bc77507a1056cdb06451c75b427f9", + "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2020-05-12T16:14:59+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "time": "2019-06-13T22:48:21+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6", + "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "vimeo/psalm": "<3.9.1" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.36 || ^7.5.13" + }, + "type": "library", + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } ], - "description": " ", - "homepage": "https://github.com/zendframework/zend-stdlib", + "description": "Assertions to validate method input/output with nice error messages.", "keywords": [ - "stdlib", - "zf2" + "assert", + "check", + "validate" ], - "time": "2016-02-03 16:53:37" + "time": "2020-04-18T12:12:48+00:00" } ], "aliases": [], @@ -730,7 +2025,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^5.3.2 || ^7.0" + "php": "^7.4" }, "platform-dev": [] } diff --git a/phpunit.xml b/phpunit.xml index 83ec053..8a7c83b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,6 +1,15 @@ - - - + + + tests/DMS @@ -11,14 +20,10 @@ src/DMS - - tests - vendor - - + diff --git a/tests/DMS/Filter/FilterTest.php b/tests/DMS/Filter/FilterTest.php index 2ac1d0b..c414f29 100644 --- a/tests/DMS/Filter/FilterTest.php +++ b/tests/DMS/Filter/FilterTest.php @@ -13,14 +13,14 @@ class FilterTest extends FilterTestCase */ protected $filter; - public function setUp() + public function setUp(): void { parent::setUp(); $this->filter = new Filter($this->buildMetadataFactory(), new FilterLoader()); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -40,8 +40,8 @@ public function testFilter() $this->assertEquals($classClone->nickname, $class->nickname); $this->assertNotEquals($classClone->description, $class->description); - $this->assertNotContains(" Newton"; @@ -44,7 +37,7 @@ public function testFilter() $this->assertStringNotContainsString("

", $class->description); } - public function testFilterWithParent() + public function testFilterWithParent(): void { $class = new Dummy\Classes\ChildAnnotatedClass(); $class->name = "Sir Isaac Newton"; @@ -66,7 +59,7 @@ public function testFilterWithParent() $this->assertStringNotContainsString(" ", $class->surname); } - public function testFilterProperty() + public function testFilterProperty(): void { $class = new Dummy\Classes\AnnotatedClass(); $class->name = "Sir Isaac Newton"; @@ -83,7 +76,7 @@ public function testFilterProperty() $this->assertStringNotContainsString("

", $class->description); } - public function testFilterValue() + public function testFilterValue(): void { $value = "this is a string

with tags

and malformed"; @@ -95,11 +88,11 @@ public function testFilterValue() $this->assertStringNotContainsString('

', $filtered); } - public function testFilterValueWithArray() + public function testFilterValueWithArray(): void { $value = "this is a string

with tags

and\n malformed"; - $filters = array(new Rules\StripTags(), new Rules\StripNewlines()); + $filters = [new Rules\StripTags(), new Rules\StripNewlines()]; $filtered = $this->filter->filterValue($value, $filters); $this->assertNotEquals($value, $filtered); @@ -109,14 +102,14 @@ public function testFilterValueWithArray() $this->assertStringNotContainsString('\n', $filtered); } - public function testNotFailOnNull() + public function testNotFailOnNull(): void { $this->expectNotToPerformAssertions(); $this->filter->filterEntity(null); } - public function testGetMetadataFactory() + public function testGetMetadataFactory(): void { - $this->assertInstanceOf('DMS\Filter\Mapping\ClassMetadataFactory', $this->filter->getMetadataFactory()); + $this->assertInstanceOf(ClassMetadataFactory::class, $this->filter->getMetadataFactory()); } } diff --git a/tests/DMS/Filter/Filters/AlnumTest.php b/tests/DMS/Filter/Filters/AlnumTest.php index 4600b86..147ee70 100644 --- a/tests/DMS/Filter/Filters/AlnumTest.php +++ b/tests/DMS/Filter/Filters/AlnumTest.php @@ -4,30 +4,28 @@ use DMS\Tests\FilterTestCase; use DMS\Filter\Rules\Alnum as AlnumRule; +use ReflectionProperty; class AlnumTest extends FilterTestCase { - public function setUp(): void -{ - parent::setUp(); - } - - public function tearDown(): void -{ - parent::tearDown(); - } - /** * @dataProvider provideForRule + * + * @param $options + * @param $value + * @param $expectedResult + * @param null $unicodeSetting + * + * @throws \ReflectionException */ - public function testRule($options, $value, $expectedResult, $unicodeSetting = null) + public function testRule($options, $value, $expectedResult, $unicodeSetting = null): void { $rule = new AlnumRule($options); $filter = new Alnum(); if ($unicodeSetting !== null) { - $property = new \ReflectionProperty($filter, 'unicodeEnabled'); + $property = new ReflectionProperty($filter, 'unicodeEnabled'); $property->setAccessible(true); $property->setValue($filter, $unicodeSetting); } @@ -37,25 +35,25 @@ public function testRule($options, $value, $expectedResult, $unicodeSetting = nu $this->assertEquals($expectedResult, $result); } - public function provideForRule() + public function provideForRule(): array { - return array( - array(false, "My Text", "MyText", true), - array(false, "My Text", "MyText", false), - array(true, "My Text", "My Text", true), - array(true, "My Text", "My Text", false), - array(true, "My Text!", "My Text", true), - array(true, "My Text!", "My Text", false), - array(true, "My Text21!", "My Text21", true), - array(true, "My Text21!", "My Text21", false), - array(true, "João Sorrisão", "João Sorrisão", true), - array(true, "João Sorrisão", "Joo Sorriso", false), - array(true, "GRΣΣK", "GRΣΣK", true), - array(true, "GRΣΣK", "GRK", false), - array(true, "Helgi Þormar Þorbjörnsson", "Helgi Þormar Þorbjörnsson", true), - array(true, "Helgi Þormar Þorbjörnsson", "Helgi ormar orbjrnsson", false), - array(true, "Helgi Þormar!@#$&*( )(*&%$#@Þorbjörnsson", "Helgi Þormar Þorbjörnsson", true), - array(true, "Helgi Þormar!@#$&*( )(*&%$#@Þorbjörnsson", "Helgi ormar orbjrnsson", false), - ); + return [ + [false, "My Text", "MyText", true], + [false, "My Text", "MyText", false], + [true, "My Text", "My Text", true], + [true, "My Text", "My Text", false], + [true, "My Text!", "My Text", true], + [true, "My Text!", "My Text", false], + [true, "My Text21!", "My Text21", true], + [true, "My Text21!", "My Text21", false], + [true, "João Sorrisão", "João Sorrisão", true], + [true, "João Sorrisão", "Joo Sorriso", false], + [true, "GRΣΣK", "GRΣΣK", true], + [true, "GRΣΣK", "GRK", false], + [true, "Helgi Þormar Þorbjörnsson", "Helgi Þormar Þorbjörnsson", true], + [true, "Helgi Þormar Þorbjörnsson", "Helgi ormar orbjrnsson", false], + [true, "Helgi Þormar!@#$&*( )(*&%$#@Þorbjörnsson", "Helgi Þormar Þorbjörnsson", true], + [true, "Helgi Þormar!@#$&*( )(*&%$#@Þorbjörnsson", "Helgi ormar orbjrnsson", false], + ]; } } diff --git a/tests/DMS/Filter/Filters/AlphaTest.php b/tests/DMS/Filter/Filters/AlphaTest.php index fb987e9..eef5af2 100644 --- a/tests/DMS/Filter/Filters/AlphaTest.php +++ b/tests/DMS/Filter/Filters/AlphaTest.php @@ -4,30 +4,28 @@ use DMS\Tests\FilterTestCase; use DMS\Filter\Rules\Alpha as AlphaRule; +use ReflectionProperty; class AlphaTest extends FilterTestCase { - public function setUp(): void -{ - parent::setUp(); - } - - public function tearDown(): void -{ - parent::tearDown(); - } - /** * @dataProvider provideForRule + * + * @param $options + * @param $value + * @param $expectedResult + * @param null $unicodeSetting + * + * @throws \ReflectionException */ - public function testRule($options, $value, $expectedResult, $unicodeSetting = null) + public function testRule($options, $value, $expectedResult, $unicodeSetting = null): void { $rule = new AlphaRule($options); $filter = new Alpha(); if ($unicodeSetting !== null) { - $property = new \ReflectionProperty($filter, 'unicodeEnabled'); + $property = new ReflectionProperty($filter, 'unicodeEnabled'); $property->setAccessible(true); $property->setValue($filter, $unicodeSetting); } @@ -37,23 +35,23 @@ public function testRule($options, $value, $expectedResult, $unicodeSetting = nu $this->assertEquals($expectedResult, $result); } - public function provideForRule() + public function provideForRule(): array { - return array( - array(false, "My Text", "MyText", true), - array(false, "My Text", "MyText", false), - array(true, "My Text", "My Text", true), - array(true, "My Text", "My Text", false), - array(true, "My Text!", "My Text", true), - array(true, "My Text!", "My Text", false), - array(true, "My Text21!", "My Text", true), - array(true, "My Text21!", "My Text", false), - array(true, "João 2Sorrisão", "João Sorrisão", true), - array(true, "João 2Sorrisão", "Joo Sorriso", false), - array(true, "Helgi Þormar Þorbjörnsson", "Helgi Þormar Þorbjörnsson", true), - array(true, "Helgi Þormar Þorbjörnsson", "Helgi ormar orbjrnsson", false), - array(true, "Helgi Þormar!@#$&*( )(*&%$#@Þorbjörnsson", "Helgi Þormar Þorbjörnsson", true), - array(true, "Helgi Þormar!@#$&*( )(*&%$#@Þorbjörnsson", "Helgi ormar orbjrnsson", false), - ); + return [ + [false, "My Text", "MyText", true], + [false, "My Text", "MyText", false], + [true, "My Text", "My Text", true], + [true, "My Text", "My Text", false], + [true, "My Text!", "My Text", true], + [true, "My Text!", "My Text", false], + [true, "My Text21!", "My Text", true], + [true, "My Text21!", "My Text", false], + [true, "João 2Sorrisão", "João Sorrisão", true], + [true, "João 2Sorrisão", "Joo Sorriso", false], + [true, "Helgi Þormar Þorbjörnsson", "Helgi Þormar Þorbjörnsson", true], + [true, "Helgi Þormar Þorbjörnsson", "Helgi ormar orbjrnsson", false], + [true, "Helgi Þormar!@#$&*( )(*&%$#@Þorbjörnsson", "Helgi Þormar Þorbjörnsson", true], + [true, "Helgi Þormar!@#$&*( )(*&%$#@Þorbjörnsson", "Helgi ormar orbjrnsson", false], + ]; } } diff --git a/tests/DMS/Filter/Filters/BooleanTest.php b/tests/DMS/Filter/Filters/BooleanTest.php index 8013a1e..a5aa79b 100644 --- a/tests/DMS/Filter/Filters/BooleanTest.php +++ b/tests/DMS/Filter/Filters/BooleanTest.php @@ -8,20 +8,14 @@ class BooleanTest extends FilterTestCase { - public function setUp(): void -{ - parent::setUp(); - } - - public function tearDown(): void -{ - parent::tearDown(); - } - /** * @dataProvider provideForRule + * + * @param $options + * @param $value + * @param $expectedResult */ - public function testRule($options, $value, $expectedResult) + public function testRule($options, $value, $expectedResult): void { $rule = new BooleanRule($options); $filter = new BooleanScalar(); @@ -31,15 +25,15 @@ public function testRule($options, $value, $expectedResult) $this->assertEquals($expectedResult, $result); } - public function provideForRule() + public function provideForRule(): array { - return array( - array(null, "My Text", true), - array(null, "", false), - array(null, null, false), - array(null, 21.9, true), - array(null, 21, true), - array(null, 0, false), - ); + return [ + [null, "My Text", true], + [null, "", false], + [null, null, false], + [null, 21.9, true], + [null, 21, true], + [null, 0, false], + ]; } } diff --git a/tests/DMS/Filter/Filters/CallbackTest.php b/tests/DMS/Filter/Filters/CallbackTest.php index 06cd819..cf356da 100644 --- a/tests/DMS/Filter/Filters/CallbackTest.php +++ b/tests/DMS/Filter/Filters/CallbackTest.php @@ -12,12 +12,12 @@ class CallbackTest extends FilterTestCase { /** - * @var CallbackRule | MockObject + * @var CallbackRule|MockObject */ protected $rule; /** - * @var \DMS\Filter\Filters\Callback + * @var Callback */ protected $filter; @@ -44,7 +44,7 @@ public function testRuleWithObjectMethod(): void $this->assertEquals('called_back', $result); } - public function testRuleWithObjectMethodInvalid() + public function testRuleWithObjectMethodInvalid(): void { $this->expectException(InvalidCallbackException::class); $this->rule->expects($this->once())->method('getInputType')->willReturn( @@ -58,7 +58,7 @@ public function testRuleWithObjectMethodInvalid() $this->filter->apply($this->rule, 'value'); } - public function testRuleWithObjectMethodButNoObject() + public function testRuleWithObjectMethodButNoObject(): void { $this->expectException(FilterException::class); $this->rule->expects($this->once())->method('getInputType')->willReturn( @@ -69,44 +69,44 @@ public function testRuleWithObjectMethodButNoObject() $this->filter->apply($this->rule, 'value'); } - public function testRuleWithCallable() + public function testRuleWithCallable(): void { $this->rule->expects($this->once())->method('getInputType')->willReturn( CallbackRule::CALLABLE_TYPE ); - $this->rule->callback = array(AnnotatedClass::class, 'anotherCallback'); + $this->rule->callback = [AnnotatedClass::class, 'anotherCallback']; $result = $this->filter->apply($this->rule, 'value'); $this->assertEquals('called_back', $result); } - public function testRuleWithNonStaticCallable() + public function testRuleWithNonStaticCallable(): void { $this->rule->expects($this->once())->method('getInputType')->willReturn( CallbackRule::CALLABLE_TYPE ); - $this->rule->callback = array(new AnnotatedClass(), 'callbackMethod'); + $this->rule->callback = [new AnnotatedClass(), 'callbackMethod']; $result = $this->filter->apply($this->rule, 'value'); $this->assertEquals('called_back', $result); } - public function testRuleWithCallableInvalid() + public function testRuleWithCallableInvalid(): void { $this->expectException(InvalidCallbackException::class); $this->rule->expects($this->once())->method('getInputType')->willReturn( CallbackRule::CALLABLE_TYPE ); - $this->rule->callback = array(AnnotatedClass::class, 'callbackMissingMethod'); + $this->rule->callback = [AnnotatedClass::class, 'callbackMissingMethod']; $result = $this->filter->apply($this->rule, 'value'); } - public function testRuleWithClosure() + public function testRuleWithClosure(): void { - $closure = function ($value) { + $closure = static function ($value) { return 'called_back'; }; @@ -120,7 +120,7 @@ public function testRuleWithClosure() $this->assertEquals('called_back', $result); } - public function testRuleWithNonClosure() + public function testRuleWithNonClosure(): void { $this->expectException(InvalidCallbackException::class); $this->rule->expects($this->once())->method('getInputType')->willReturn( diff --git a/tests/DMS/Filter/Filters/DigitsTest.php b/tests/DMS/Filter/Filters/DigitsTest.php index 99e6f90..ed7aabe 100644 --- a/tests/DMS/Filter/Filters/DigitsTest.php +++ b/tests/DMS/Filter/Filters/DigitsTest.php @@ -4,30 +4,28 @@ use DMS\Tests\FilterTestCase; use DMS\Filter\Rules\Digits as DigitsRule; +use ReflectionProperty; class DigitsTest extends FilterTestCase { - public function setUp(): void -{ - parent::setUp(); - } - - public function tearDown(): void -{ - parent::tearDown(); - } - /** * @dataProvider provideForRule + * + * @param $options + * @param $value + * @param $expectedResult + * @param null $unicodeSetting + * + * @throws \ReflectionException */ - public function testRule($options, $value, $expectedResult, $unicodeSetting = null) + public function testRule($options, $value, $expectedResult, $unicodeSetting = null): void { $rule = new DigitsRule($options); $filter = new Digits(); if ($unicodeSetting !== null) { - $property = new \ReflectionProperty($filter, 'unicodeEnabled'); + $property = new ReflectionProperty($filter, 'unicodeEnabled'); $property->setAccessible(true); $property->setValue($filter, $unicodeSetting); } @@ -37,21 +35,21 @@ public function testRule($options, $value, $expectedResult, $unicodeSetting = nu $this->assertEquals($expectedResult, $result); } - public function provideForRule() + public function provideForRule(): array { - return array( - array(false, "My Text", ""), - array(false, "001 t55", "00155"), - array(true, "My 23 dogs", " 23 "), - array(false, "My 23 dogs", "23"), - array(true, "233 055", "233 055", true), - array(true, "233 055", "233 055", false), - array(true, "233 t055s", "233 055"), - array(true, "My Text21!", " 21"), //TODO verify this. - array(true, "João Sorrisão", " ", true), - array(true, "João Sorrisão", " ", false), - array(true, "001Helgi Þormar Þorbjörnsson", "001 ", true), - array(true, "001Helgi Þormar Þorbjörnsson", "001 ", false), - ); + return [ + [false, "My Text", ""], + [false, "001 t55", "00155"], + [true, "My 23 dogs", " 23 "], + [false, "My 23 dogs", "23"], + [true, "233 055", "233 055", true], + [true, "233 055", "233 055", false], + [true, "233 t055s", "233 055"], + [true, "My Text21!", " 21"], //TODO verify this. + [true, "João Sorrisão", " ", true], + [true, "João Sorrisão", " ", false], + [true, "001Helgi Þormar Þorbjörnsson", "001 ", true], + [true, "001Helgi Þormar Þorbjörnsson", "001 ", false], + ]; } } diff --git a/tests/DMS/Filter/Filters/FloatTest.php b/tests/DMS/Filter/Filters/FloatTest.php index cf93b86..2391f00 100644 --- a/tests/DMS/Filter/Filters/FloatTest.php +++ b/tests/DMS/Filter/Filters/FloatTest.php @@ -8,20 +8,14 @@ class FloatTest extends FilterTestCase { - public function setUp(): void -{ - parent::setUp(); - } - - public function tearDown(): void -{ - parent::tearDown(); - } - /** * @dataProvider provideForRule + * + * @param $options + * @param $value + * @param $expectedResult */ - public function testRule($options, $value, $expectedResult) + public function testRule($options, $value, $expectedResult): void { $rule = new FloatRule($options); $filter = new FloatScalar(); @@ -31,13 +25,13 @@ public function testRule($options, $value, $expectedResult) $this->assertEquals($expectedResult, $result); } - public function provideForRule() + public function provideForRule(): array { - return array( - array(null, "My Text", 0.0), - array(null, "21", 21.0), - array(null, "21.2", 21.2), - array(null, 21.9, 21.9), - ); + return [ + [null, "My Text", 0.0], + [null, "21", 21.0], + [null, "21.2", 21.2], + [null, 21.9, 21.9], + ]; } } diff --git a/tests/DMS/Filter/Filters/HtmlEntitiesTest.php b/tests/DMS/Filter/Filters/HtmlEntitiesTest.php index aa4577d..e9bd660 100644 --- a/tests/DMS/Filter/Filters/HtmlEntitiesTest.php +++ b/tests/DMS/Filter/Filters/HtmlEntitiesTest.php @@ -8,20 +8,14 @@ class HtmlEntitiesTest extends FilterTestCase { - public function setUp(): void -{ - parent::setUp(); - } - - public function tearDown(): void -{ - parent::tearDown(); - } - /** * @dataProvider provideForRule + * + * @param $options + * @param $value + * @param $expectedResult */ - public function testRule($options, $value, $expectedResult) + public function testRule($options, $value, $expectedResult): void { $rule = new HtmlEntitiesRule($options); $filter = new HtmlEntities(); @@ -31,15 +25,15 @@ public function testRule($options, $value, $expectedResult) $this->assertEquals($expectedResult, $result); } - public function provideForRule() + public function provideForRule(): array { - return array( - array(array(), "This is some téxt &", "This is some téxt &"), - array(array(), "This & is a &", "This &amp; is a &"), - array(array('doubleEncode' => false), "This & is a &", "This & is a &"), - array(array('flags' => ENT_IGNORE), "With '\" quotes", "With '\" quotes"), - array(array(), "With '\" quotes", "With '" quotes"), - array(array('flags' => ENT_QUOTES), "With '\" quotes", "With '" quotes"), - ); + return [ + [[], "This is some téxt &", "This is some téxt &"], + [[], "This & is a &", "This &amp; is a &"], + [['doubleEncode' => false], "This & is a &", "This & is a &"], + [['flags' => ENT_IGNORE], "With '\" quotes", "With '\" quotes"], + [[], "With '\" quotes", "With '" quotes"], + [['flags' => ENT_QUOTES], "With '\" quotes", "With '" quotes"], + ]; } } diff --git a/tests/DMS/Filter/Filters/IntTest.php b/tests/DMS/Filter/Filters/IntTest.php index e866704..e52ba05 100644 --- a/tests/DMS/Filter/Filters/IntTest.php +++ b/tests/DMS/Filter/Filters/IntTest.php @@ -8,20 +8,14 @@ class IntTest extends FilterTestCase { - public function setUp(): void -{ - parent::setUp(); - } - - public function tearDown(): void -{ - parent::tearDown(); - } - /** * @dataProvider provideForRule + * + * @param $options + * @param $value + * @param $expectedResult */ - public function testRule($options, $value, $expectedResult) + public function testRule($options, $value, $expectedResult): void { $rule = new IntRule($options); $filter = new IntScalar(); @@ -31,15 +25,15 @@ public function testRule($options, $value, $expectedResult) $this->assertEquals($expectedResult, $result); } - public function provideForRule() + public function provideForRule(): array { - return array( - array(null, "My Text", 0), - array(null, true, 1), - array(null, "21", 21), - array(null, "21.2", 21), - array(null, "21.9", 21), - array(null, 21.9, 21), - ); + return [ + [null, "My Text", 0], + [null, true, 1], + [null, "21", 21], + [null, "21.2", 21], + [null, "21.9", 21], + [null, 21.9, 21], + ]; } } diff --git a/tests/DMS/Filter/Filters/Loader/FilterLoaderTest.php b/tests/DMS/Filter/Filters/Loader/FilterLoaderTest.php index 0a70e7c..b7b3171 100644 --- a/tests/DMS/Filter/Filters/Loader/FilterLoaderTest.php +++ b/tests/DMS/Filter/Filters/Loader/FilterLoaderTest.php @@ -5,13 +5,11 @@ use DMS\Filter\Rules\StripTags; use DMS\Tests\Dummy\Rules\NoOptionsRule; use DMS\Tests\FilterTestCase; +use UnexpectedValueException; class FilterLoaderTest extends FilterTestCase { - /** - * @var FilterLoader - */ - protected $loader; + protected FilterLoaderInterface $loader; public function setUp(): void { @@ -20,11 +18,6 @@ public function setUp(): void $this->loader = new FilterLoader(); } - public function tearDown(): void -{ - parent::tearDown(); - } - /** * @param $rule * @param $return @@ -32,20 +25,20 @@ public function tearDown(): void * * @dataProvider provideForGetFilter */ - public function testGetFilterForRule($rule, $return, $expectException) + public function testGetFilterForRule($rule, $return, $expectException): void { if ($expectException) { - $this->expectException(\UnexpectedValueException::class); + $this->expectException(UnexpectedValueException::class); } $this->assertEquals($return, $this->loader->getFilterForRule($rule)); } - public function provideForGetFilter() + public function provideForGetFilter(): array { - return array( - array(new StripTags(), new \DMS\Filter\Filters\StripTags(), false), - array(new NoOptionsRule(), new \DMS\Filter\Filters\StripTags(), true), - ); + return [ + [new StripTags(), new \DMS\Filter\Filters\StripTags(), false], + [new NoOptionsRule(), new \DMS\Filter\Filters\StripTags(), true], + ]; } } diff --git a/tests/DMS/Filter/Filters/PregReplaceTest.php b/tests/DMS/Filter/Filters/PregReplaceTest.php index 5d70df8..f9849f6 100644 --- a/tests/DMS/Filter/Filters/PregReplaceTest.php +++ b/tests/DMS/Filter/Filters/PregReplaceTest.php @@ -8,20 +8,14 @@ class PregReplaceTest extends FilterTestCase { - public function setUp(): void -{ - parent::setUp(); - } - - public function tearDown(): void -{ - parent::tearDown(); - } - /** * @dataProvider provideForRule + * + * @param $options + * @param $value + * @param $expectedResult */ - public function testRule($options, $value, $expectedResult) + public function testRule($options, $value, $expectedResult): void { $rule = new PregReplaceRule($options); $filter = new PregReplace(); @@ -31,13 +25,13 @@ public function testRule($options, $value, $expectedResult) $this->assertEquals($expectedResult, $result); } - public function provideForRule() + public function provideForRule(): array { - return array( - array(array('regexp' => '/(old )/'), "the crazy old fox", "the crazy fox"), - array(array('regexp' => '/(old)/', 'replacement' => 'new'), "the crazy old fox", "the crazy new fox"), - array(array('regexp' => '/([0-9]*)/'), "this is day 21", "this is day "), - array(array('regexp' => '/(style=\"[^\"]*\")/'), "", "
"), - ); + return [ + [['regexp' => '/(old )/'], "the crazy old fox", "the crazy fox"], + [['regexp' => '/(old)/', 'replacement' => 'new'], "the crazy old fox", "the crazy new fox"], + [['regexp' => '/([0-9]*)/'], "this is day 21", "this is day "], + [['regexp' => '/(style=\"[^\"]*\")/'], "
", "
"], + ]; } } diff --git a/tests/DMS/Filter/Filters/StripNewlinesTest.php b/tests/DMS/Filter/Filters/StripNewlinesTest.php index ea166e2..20852dc 100644 --- a/tests/DMS/Filter/Filters/StripNewlinesTest.php +++ b/tests/DMS/Filter/Filters/StripNewlinesTest.php @@ -8,20 +8,14 @@ class StripNewlinesTest extends FilterTestCase { - public function setUp(): void -{ - parent::setUp(); - } - - public function tearDown(): void -{ - parent::tearDown(); - } - /** * @dataProvider provideForRule + * + * @param $options + * @param $value + * @param $expectedResult */ - public function testRule($options, $value, $expectedResult) + public function testRule($options, $value, $expectedResult): void { $rule = new StripNewLinesRule($options); $filter = new StripNewlines(); @@ -31,14 +25,16 @@ public function testRule($options, $value, $expectedResult) $this->assertEquals($expectedResult, $result); } - public function provideForRule() + public function provideForRule(): array { - return array( - array(null, "My \n Text", "My Text"), - array(null, "My \n\r Text", "My Text"), - array(null, "My \r\n Text", "My Text"), - array(null, "My -Text", "MyText"), - ); + return [ + [null, "My \n Text", "My Text"], + [null, "My \n\r Text", "My Text"], + [null, "My \r\n Text", "My Text"], + [ + null, "My +Text", "MyText" + ], + ]; } } diff --git a/tests/DMS/Filter/Filters/StripTagsTest.php b/tests/DMS/Filter/Filters/StripTagsTest.php index 7643128..82fb800 100644 --- a/tests/DMS/Filter/Filters/StripTagsTest.php +++ b/tests/DMS/Filter/Filters/StripTagsTest.php @@ -8,20 +8,14 @@ class StripTagsTest extends FilterTestCase { - public function setUp(): void -{ - parent::setUp(); - } - - public function tearDown(): void -{ - parent::tearDown(); - } - /** * @dataProvider provideForRule + * + * @param $options + * @param $value + * @param $expectedResult */ - public function testRule($options, $value, $expectedResult) + public function testRule($options, $value, $expectedResult): void { $rule = new StripTagsRule($options); $filter = new StripTags(); @@ -31,14 +25,14 @@ public function testRule($options, $value, $expectedResult) $this->assertEquals($expectedResult, $result); } - public function provideForRule() + public function provideForRule(): array { - return array( - array(array(), "my text", "my text"), - array(array(), "my < not an html tag> text", "my < not an html tag> text"), - array(array(), "in this case a < 2 a > 3;", "in this case a < 2 a > 3;"), - array(array('allowed' => "

"), "

my text

", "

my text

"), - array("

", "

my text

", "

my text

"), - ); + return [ + [[], "my text", "my text"], + [[], "my < not an html tag> text", "my < not an html tag> text"], + [[], "in this case a < 2 a > 3;", "in this case a < 2 a > 3;"], + [['allowed' => "

"], "

my text

", "

my text

"], + ["

", "

my text

", "

my text

"], + ]; } } diff --git a/tests/DMS/Filter/Filters/ToLowerTest.php b/tests/DMS/Filter/Filters/ToLowerTest.php index 52f5156..ce09410 100644 --- a/tests/DMS/Filter/Filters/ToLowerTest.php +++ b/tests/DMS/Filter/Filters/ToLowerTest.php @@ -2,26 +2,22 @@ namespace DMS\Filter\Filters; +use DMS\Filter\Exception\FilterException; use DMS\Tests\FilterTestCase; use DMS\Filter\Rules\ToLower as ToLowerRule; class ToLowerTest extends FilterTestCase { - public function setUp(): void -{ - parent::setUp(); - } - - public function tearDown(): void -{ - parent::tearDown(); - } - /** * @dataProvider provideForRule + * + * @param $options + * @param $value + * @param $expectedResult + * @param $useEncoding */ - public function testRule($options, $value, $expectedResult, $useEncoding) + public function testRule($options, $value, $expectedResult, $useEncoding): void { if ($useEncoding && !function_exists('mb_strtolower')) { $this->markTestSkipped('mbstring extension not enabled'); @@ -35,28 +31,28 @@ public function testRule($options, $value, $expectedResult, $useEncoding) $this->assertEquals($expectedResult, $result); } - public function testInvalidEncoding() + public function testInvalidEncoding(): void { - $this->expectException(\DMS\Filter\Exception\FilterException::class); + $this->expectException(FilterException::class); if (! function_exists('mb_strtolower')) { $this->markTestSkipped('mbstring extension not enabled'); } - $rule = new ToLowerRule(array('encoding' => 'invalid')); + $rule = new ToLowerRule(['encoding' => 'invalid']); $filter = new ToLower(); $result = $filter->apply($rule, 'x'); } - public function provideForRule() + public function provideForRule(): array { - return array( - array(array('encoding' => 'utf-8'), "MY TEXT", "my text", true), - array(array('encoding' => 'utf-8'), "MY Ã TEXT", "my ã text", true), - array(array('encoding' => 'utf-8'), "MY Á TEXT", "my á text", true), - array('utf-8', "MY Á TEXT", "my á text", true), - array(array(), "MY TEXT", "my text", false ), - array(array(), "MY TEXT", "my text", false ), - ); + return [ + [['encoding' => 'utf-8'], "MY TEXT", "my text", true], + [['encoding' => 'utf-8'], "MY Ã TEXT", "my ã text", true], + [['encoding' => 'utf-8'], "MY Á TEXT", "my á text", true], + ['utf-8', "MY Á TEXT", "my á text", true], + [[], "MY TEXT", "my text", false], + [[], "MY TEXT", "my text", false], + ]; } } diff --git a/tests/DMS/Filter/Filters/ToUpperTest.php b/tests/DMS/Filter/Filters/ToUpperTest.php index 497ddcb..44c2392 100644 --- a/tests/DMS/Filter/Filters/ToUpperTest.php +++ b/tests/DMS/Filter/Filters/ToUpperTest.php @@ -2,26 +2,22 @@ namespace DMS\Filter\Filters; +use DMS\Filter\Exception\FilterException; use DMS\Tests\FilterTestCase; use DMS\Filter\Rules\ToUpper as ToUpperRule; class ToUpperTest extends FilterTestCase { - public function setUp(): void -{ - parent::setUp(); - } - - public function tearDown(): void -{ - parent::tearDown(); - } - /** * @dataProvider provideForRule + * + * @param $options + * @param $value + * @param $expectedResult + * @param $useEncoding */ - public function testRule($options, $value, $expectedResult, $useEncoding) + public function testRule($options, $value, $expectedResult, $useEncoding): void { if ($useEncoding && !function_exists('mb_strtoupper')) { $this->markTestSkipped('mbstring extension not enabled'); @@ -35,28 +31,28 @@ public function testRule($options, $value, $expectedResult, $useEncoding) $this->assertEquals($expectedResult, $result); } - public function testInvalidEncoding() + public function testInvalidEncoding(): void { - $this->expectException(\DMS\Filter\Exception\FilterException::class); + $this->expectException(FilterException::class); if (! function_exists('mb_strtoupper')) { $this->markTestSkipped('mbstring extension not enabled'); } - $rule = new ToUpperRule(array('encoding' => 'invalid')); + $rule = new ToUpperRule(['encoding' => 'invalid']); $filter = new ToUpper(); $result = $filter->apply($rule, 'x'); } - public function provideForRule() + public function provideForRule(): array { - return array( - array(array('encoding' => 'utf-8'), "my text", "MY TEXT", true), - array(array('encoding' => 'utf-8'), "my ã text", "MY Ã TEXT", true), - array(array('encoding' => 'utf-8'), "my á text", "MY Á TEXT", true), - array('utf-8', "my á text", "MY Á TEXT", true), - array(array(), "my text", "MY TEXT", false ), - array(array(), "my text", "MY TEXT", false ), - ); + return [ + [['encoding' => 'utf-8'], "my text", "MY TEXT", true], + [['encoding' => 'utf-8'], "my ã text", "MY Ã TEXT", true], + [['encoding' => 'utf-8'], "my á text", "MY Á TEXT", true], + ['utf-8', "my á text", "MY Á TEXT", true], + [[], "my text", "MY TEXT", false], + [[], "my text", "MY TEXT", false], + ]; } } diff --git a/tests/DMS/Filter/Filters/TrimTest.php b/tests/DMS/Filter/Filters/TrimTest.php index bb86820..4abbbdd 100644 --- a/tests/DMS/Filter/Filters/TrimTest.php +++ b/tests/DMS/Filter/Filters/TrimTest.php @@ -8,20 +8,14 @@ class TrimTest extends FilterTestCase { - public function setUp(): void -{ - parent::setUp(); - } - - public function tearDown(): void -{ - parent::tearDown(); - } - /** * @dataProvider provideForRule + * + * @param $options + * @param $value + * @param $expectedResult */ - public function testRule($options, $value, $expectedResult) + public function testRule($options, $value, $expectedResult): void { $rule = new TrimRule($options); $filter = new Trim(); @@ -31,15 +25,15 @@ public function testRule($options, $value, $expectedResult) $this->assertEquals($expectedResult, $result); } - public function provideForRule() + public function provideForRule(): array { - return array( - array(array(), " my text", "my text"), - array(array(), " my text ", "my text"), - array(array(), "my text ", "my text"), - array(array('charlist' => "\\"), "\my text", "my text"), - array("\\", "\my text", "my text"), - array("x", "xmy textx", "my text"), - ); + return [ + [[], " my text", "my text"], + [[], " my text ", "my text"], + [[], "my text ", "my text"], + [['charlist' => "\\"], "\my text", "my text"], + ["\\", "\my text", "my text"], + ["x", "xmy textx", "my text"], + ]; } } diff --git a/tests/DMS/Filter/Filters/ZendTest.php b/tests/DMS/Filter/Filters/ZendTest.php index 7845386..6ffa693 100644 --- a/tests/DMS/Filter/Filters/ZendTest.php +++ b/tests/DMS/Filter/Filters/ZendTest.php @@ -10,23 +10,23 @@ class ZendTest extends FilterTestCase { - public function testFilterShortname() + public function testFilterShortname(): void { - $rule = $this->buildRule('Boolean', array('casting' => false)); + $rule = $this->buildRule('Boolean', ['casting' => false]); $filter = new Zend(); $filter->apply($rule, '0'); $this->expectNotToPerformAssertions(); } - public function testFilterFullname() + public function testFilterFullname(): void { - $rule = $this->buildRule('Zend\Filter\Boolean', array('casting' => false)); + $rule = $this->buildRule('Zend\Filter\Boolean', ['casting' => false]); $filter = new Zend(); $filter->apply($rule, '0'); $this->expectNotToPerformAssertions(); } - public function testInvalidFilter() + public function testInvalidFilter(): void { $this->expectException(InvalidZendFilterException::class); $rule = $this->buildRule('MissingFilter'); @@ -34,13 +34,13 @@ public function testInvalidFilter() $filter->apply($rule, '0'); } - protected function buildRule($class, $options = array()) + protected function buildRule($class, $options = []): ZendRule { return new ZendRule( - array( + [ 'class' => $class, 'zendOptions' => $options, - ) + ] ); } } diff --git a/tests/DMS/Filter/Mapping/ClassMetadataFactoryTest.php b/tests/DMS/Filter/Mapping/ClassMetadataFactoryTest.php index fa12ddb..faeb2aa 100644 --- a/tests/DMS/Filter/Mapping/ClassMetadataFactoryTest.php +++ b/tests/DMS/Filter/Mapping/ClassMetadataFactoryTest.php @@ -2,8 +2,12 @@ namespace DMS\Filter\Mapping; +use DMS\Filter\Mapping\Loader\AnnotationLoader; use DMS\Tests\FilterTestCase; +use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Cache\ArrayCache; +use DMS\Tests\Dummy\Classes\AnnotatedClass; +use DMS\Filter\Mapping\ClassMetadataInterface; class ClassMetadataFactoryTest extends FilterTestCase { @@ -11,7 +15,7 @@ class ClassMetadataFactoryTest extends FilterTestCase /** * @var ClassMetadataFactory */ - protected $factory; + protected ClassMetadataFactory $factory; public function setUp(): void { @@ -20,40 +24,36 @@ public function setUp(): void $this->factory = $this->buildMetadataFactory(); } - public function tearDown(): void -{ - parent::tearDown(); - } - - public function testGetClassMetadata() + public function testGetClassMetadata(): void { - $metadata = $this->factory->getClassMetadata('DMS\Tests\Dummy\Classes\AnnotatedClass'); + $metadata = $this->factory->getClassMetadata(AnnotatedClass::class); - $this->assertInstanceOf('DMS\Filter\Mapping\ClassMetadataInterface', $metadata); + $this->assertInstanceOf(ClassMetadataInterface::class, $metadata); } - public function testParsedMetadataFromFactory() + public function testParsedMetadataFromFactory(): void { - $metadata = $this->factory->getClassMetadata('DMS\Tests\Dummy\Classes\AnnotatedClass'); + $metadata = $this->factory->getClassMetadata(AnnotatedClass::class); - $metadataReparsed = $this->factory->getClassMetadata('DMS\Tests\Dummy\Classes\AnnotatedClass'); + $metadataReparsed = $this->factory->getClassMetadata(AnnotatedClass::class); $this->assertSame($metadata, $metadataReparsed); } - public function testCachedMetadataFromFactory() + public function testCachedMetadataFromFactory(): void { $cache = new ArrayCache(); + $reader = new AnnotationReader(); + $loader = new AnnotationLoader($reader); + $this->factory = new ClassMetadataFactory($loader, $cache); - $this->factory = new ClassMetadataFactory($this->loader, $cache); - - $metadata = $this->factory->getClassMetadata('DMS\Tests\Dummy\Classes\AnnotatedClass'); + $metadata = $this->factory->getClassMetadata(AnnotatedClass::class); - $this->assertTrue($cache->contains(ltrim('DMS\Tests\Dummy\Classes\AnnotatedClass', '\\'))); + $this->assertTrue($cache->contains(ltrim(AnnotatedClass::class, '\\'))); //Get new Factory to retrieve from cache - $this->factory = new ClassMetadataFactory($this->loader, $cache); - $metadataCached = $this->factory->getClassMetadata('DMS\Tests\Dummy\Classes\AnnotatedClass'); + $this->factory = new ClassMetadataFactory($loader, $cache); + $metadataCached = $this->factory->getClassMetadata(AnnotatedClass::class); $this->assertEquals($metadata, $metadataCached); } diff --git a/tests/DMS/Filter/Rules/CallbackTest.php b/tests/DMS/Filter/Rules/CallbackTest.php index d6139fe..07cbc35 100644 --- a/tests/DMS/Filter/Rules/CallbackTest.php +++ b/tests/DMS/Filter/Rules/CallbackTest.php @@ -6,6 +6,7 @@ use DMS\Tests\Dummy\Classes\AnnotatedClass; use DMS\Tests\FilterTestCase; use DMS\Filter\Exception\InvalidCallbackException; +use stdClass; class CallbackTest extends FilterTestCase { @@ -17,7 +18,7 @@ class CallbackTest extends FilterTestCase * * @dataProvider provideInputs */ - public function testGetInputType($input, $expectedOutput, $expectException) + public function testGetInputType($input, $expectedOutput, $expectException): void { if ($expectException) { $this->expectException(InvalidCallbackException::class); @@ -28,21 +29,19 @@ public function testGetInputType($input, $expectedOutput, $expectException) $this->assertEquals($expectedOutput, $rule->getInputType()); } - public function provideInputs() + public function provideInputs(): array { - $closure = function ($v) { - return; - }; - - return array( - array('objMethod', Callback::SELF_METHOD_TYPE, false), - array(array(AnnotatedClass::class, 'anotherCallback'), Callback::CALLABLE_TYPE, false), - array(array(AnnotatedClass::class, 'missingCallback'), null, true), - array(array(new AnnotatedClass(), 'callbackMethod'), Callback::CALLABLE_TYPE, false), - array('strlen', Callback::CALLABLE_TYPE, false), - array($closure, Callback::CLOSURE_TYPE, false), - array(1, null, true), - array(new \stdClass(), null, true), - ); + $closure = static function ($v) {}; + + return [ + ['objMethod', Callback::SELF_METHOD_TYPE, false], + [[AnnotatedClass::class, 'anotherCallback'], Callback::CALLABLE_TYPE, false], + [[AnnotatedClass::class, 'missingCallback'], null, true], + [[new AnnotatedClass(), 'callbackMethod'], Callback::CALLABLE_TYPE, false], + ['strlen', Callback::CALLABLE_TYPE, false], + [$closure, Callback::CLOSURE_TYPE, false], + [1, null, true], + [new stdClass(), null, true], + ]; } } diff --git a/tests/DMS/Filter/Rules/RuleTest.php b/tests/DMS/Filter/Rules/RuleTest.php index 8c405f5..e85b57e 100644 --- a/tests/DMS/Filter/Rules/RuleTest.php +++ b/tests/DMS/Filter/Rules/RuleTest.php @@ -11,78 +11,69 @@ use DMS\Tests\Dummy\Rules\NoOptionsRule; use DMS\Tests\Dummy\Rules\RequiredOptionsRule; use DMS\Tests\FilterTestCase; +use DMS\Filter\Rules\Rule; class RuleTest extends FilterTestCase { - public function setUp(): void -{ - parent::setUp(); - } - - public function tearDown(): void -{ - parent::tearDown(); - } - - public function testConstructorHappyPath() + public function testConstructorHappyPath(): void { $rule = new NoOptionsRule(); - $this->assertInstanceOf('DMS\Filter\Rules\Rule', $rule); + $this->assertInstanceOf(Rule::class, $rule); } - public function testConstructorDefaultOption() + public function testConstructorDefaultOption(): void { $rule = new DefaultOptionRule('value'); - $this->assertInstanceOf('DMS\Filter\Rules\Rule', $rule); + $this->assertInstanceOf(Rule::class, $rule); } - public function testConstructorDefaultOptionInArray() + public function testConstructorDefaultOptionInArray(): void { - $rule = new DefaultOptionRule(array('value' => 'optionvalue')); + $rule = new DefaultOptionRule(['value' => 'optionvalue']); - $this->assertInstanceOf('DMS\Filter\Rules\Rule', $rule); + $this->assertInstanceOf(Rule::class, $rule); } - public function testConstructorHappyPathWithRequired() + public function testConstructorHappyPathWithRequired(): void { - $rule = new RequiredOptionsRule(array('config' => 'value', 'path' => '/path/to/')); + $rule = new RequiredOptionsRule(['config' => 'value', 'path' => '/path/to/']); - $this->assertInstanceOf('DMS\Filter\Rules\Rule', $rule); + $this->assertInstanceOf(Rule::class, $rule); } - public function testConstructorNoDefinedDefaultOption() + public function testConstructorNoDefinedDefaultOption(): void { $this->expectException(RuleDefinitionException::class); $rule = new NoOptionsRule('value'); - $this->assertInstanceOf('DMS\Filter\Rules\Rule', $rule); + $this->assertInstanceOf(Rule::class, $rule); } - public function testConstructorInvalidOption() + public function testConstructorInvalidOption(): void { $this->expectException(InvalidOptionsException::class); - $rule = new MultipleOptionsRule(array('invalid' => 'option')); + $rule = new MultipleOptionsRule(['invalid' => 'option']); } - public function testConstructorInvalidDefaultOption() + public function testConstructorInvalidDefaultOption(): void { $this->expectException(InvalidOptionsException::class); $rule = new InvalidDefaultOptionRule('value'); } - public function testConstructorMissingOption() + public function testConstructorMissingOption(): void { $this->expectException(MissingOptionsException::class); - $rule = new RequiredOptionsRule(array('config' => 'option')); + $rule = new RequiredOptionsRule(['config' => 'option']); } - public function testOptionExceptionInformation() + public function testOptionExceptionInformation(): void { try { - $rule = new MultipleOptionsRule(array('invalid' => 'option')); + $rule = new MultipleOptionsRule(['invalid' => 'option']); } catch (InvalidOptionsException $e) { $this->assertIsArray($e->getOptions()); diff --git a/tests/DMS/Tests/Dummy/Classes/AnnotatedClass.php b/tests/DMS/Tests/Dummy/Classes/AnnotatedClass.php index 2e3f640..fc23190 100644 --- a/tests/DMS/Tests/Dummy/Classes/AnnotatedClass.php +++ b/tests/DMS/Tests/Dummy/Classes/AnnotatedClass.php @@ -11,51 +11,51 @@ class AnnotatedClass * * @var string */ - public $name; + public string $name; /** * @Filter\StripTags() * * @var string */ - public $nickname; + public string $nickname; /** * @Filter\StripTags("") * * @var string */ - public $description; + public string $description; /** * @var string * @Filter\Callback("callbackMethod") */ - public $callback; + public ?string $callback = null; /** * @var string * @Filter\Callback({"DMS\Tests\Dummy\Classes\AnnotatedClass", "anotherCallback"}) */ - public $callback2; + public ?string $callback2 = null; /** * @var string * @Filter\Zend("StringToLower") */ - public $zend; + public ?string $zend = null; /** * @var string * @Filter\Zend(class="Boolean", zendOptions={"casting"=false}) */ - public $zendalternate; + public ?string $zendalternate = null; /** * @param $value * @return string */ - public function callbackMethod($value) + public function callbackMethod($value): string { return 'called_back'; } @@ -64,7 +64,7 @@ public function callbackMethod($value) * @param $value * @return string */ - public static function anotherCallback($value) + public static function anotherCallback($value): string { return 'called_back'; } diff --git a/tests/DMS/Tests/Dummy/Classes/ChildAnnotatedClass.php b/tests/DMS/Tests/Dummy/Classes/ChildAnnotatedClass.php index cd0754a..9a005c2 100644 --- a/tests/DMS/Tests/Dummy/Classes/ChildAnnotatedClass.php +++ b/tests/DMS/Tests/Dummy/Classes/ChildAnnotatedClass.php @@ -11,5 +11,5 @@ class ChildAnnotatedClass extends AnnotatedClass implements AnnotatedInterface * * @var string */ - public $surname; + public string $surname; } diff --git a/tests/DMS/Tests/Dummy/Rules/DefaultOptionRule.php b/tests/DMS/Tests/Dummy/Rules/DefaultOptionRule.php index b9d532a..eb40e50 100644 --- a/tests/DMS/Tests/Dummy/Rules/DefaultOptionRule.php +++ b/tests/DMS/Tests/Dummy/Rules/DefaultOptionRule.php @@ -6,6 +6,9 @@ class DefaultOptionRule extends Rule { + /** + * @var mixed + */ public $config; public function applyFilter($value) @@ -13,7 +16,7 @@ public function applyFilter($value) return $value; } - public function getDefaultOption() + public function getDefaultOption(): ?string { return 'config'; } diff --git a/tests/DMS/Tests/Dummy/Rules/InvalidDefaultOptionRule.php b/tests/DMS/Tests/Dummy/Rules/InvalidDefaultOptionRule.php index 88b18e8..594ac80 100644 --- a/tests/DMS/Tests/Dummy/Rules/InvalidDefaultOptionRule.php +++ b/tests/DMS/Tests/Dummy/Rules/InvalidDefaultOptionRule.php @@ -6,6 +6,9 @@ class InvalidDefaultOptionRule extends Rule { + /** + * @var mixed + */ public $config; public function applyFilter($value) @@ -13,7 +16,7 @@ public function applyFilter($value) return $value; } - public function getDefaultOption() + public function getDefaultOption(): ?string { return 'path'; } diff --git a/tests/DMS/Tests/Dummy/Rules/MultipleOptionsRule.php b/tests/DMS/Tests/Dummy/Rules/MultipleOptionsRule.php index be87a1c..bc873f9 100644 --- a/tests/DMS/Tests/Dummy/Rules/MultipleOptionsRule.php +++ b/tests/DMS/Tests/Dummy/Rules/MultipleOptionsRule.php @@ -7,10 +7,19 @@ class MultipleOptionsRule extends Rule { + /** + * @var mixed + */ public $config; - public $path; - public $url; + public string $path; + public string $url; + + /** + * @param mixed $value + * + * @return mixed + */ public function applyFilter($value) { return $value; diff --git a/tests/DMS/Tests/Dummy/Rules/RequiredOptionsRule.php b/tests/DMS/Tests/Dummy/Rules/RequiredOptionsRule.php index de5cc5e..3046352 100644 --- a/tests/DMS/Tests/Dummy/Rules/RequiredOptionsRule.php +++ b/tests/DMS/Tests/Dummy/Rules/RequiredOptionsRule.php @@ -6,22 +6,33 @@ class RequiredOptionsRule extends Rule { + /** + * @var mixed + */ public $config; - public $path; - public $url; + public string $path; + public string $url; + /** + * @param mixed $value + * + * @return mixed + */ public function applyFilter($value) { return $value; } - public function getDefaultOption() + public function getDefaultOption(): ?string { return 'config'; } - public function getRequiredOptions() + /** + * {@inheritDoc} + */ + public function getRequiredOptions(): array { - return array('config', 'path'); + return ['config', 'path']; } } diff --git a/tests/DMS/Tests/FilterTestCase.php b/tests/DMS/Tests/FilterTestCase.php index 12ea9be..58149c8 100644 --- a/tests/DMS/Tests/FilterTestCase.php +++ b/tests/DMS/Tests/FilterTestCase.php @@ -3,12 +3,17 @@ namespace DMS\Tests; use DMS\Filter\Mapping; +use DMS\Filter\Mapping\ClassMetadataFactory; use Doctrine\Common\Annotations; use PHPUnit\Framework\TestCase; class FilterTestCase extends TestCase { - protected $loader; + public function __construct(?string $name = null, array $data = [], $dataName = '') + { + parent::__construct($name, $data, $dataName); + $this->buildMetadataFactory(); + } public function setUp(): void { @@ -20,15 +25,12 @@ public function tearDown(): void parent::tearDown(); } - protected function buildMetadataFactory() + protected function buildMetadataFactory(): ClassMetadataFactory { $reader = new Annotations\AnnotationReader(); $loader = new Mapping\Loader\AnnotationLoader($reader); - $this->loader = $loader; - - $metadataFactory = new Mapping\ClassMetadataFactory($loader); - return $metadataFactory; + return new ClassMetadataFactory($loader); } } From 471b8e1fcfb7da3eb6720c6cd3158de8a8aa498f Mon Sep 17 00:00:00 2001 From: Rafael Dohms Date: Sat, 23 May 2020 14:49:46 +0200 Subject: [PATCH 3/4] Coding Standard bump --- composer.json | 3 +- composer.lock | 276 ++++++++++++++++++- phpcs.xml.dist | 9 + src/DMS/Filter/Filters/Callback.php | 4 +- src/DMS/Filter/Filters/ObjectAwareFilter.php | 2 +- 5 files changed, 289 insertions(+), 5 deletions(-) create mode 100644 phpcs.xml.dist diff --git a/composer.json b/composer.json index a606bb3..732dc0d 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,8 @@ "require": { "php": "^7.4", - "doctrine/annotations": "~1.1" + "doctrine/annotations": "~1.1", + "doctrine/coding-standard": "^7" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 5864709..28e7c2a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,74 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a6b0efd28bc38cc7a4f76e38a9bee782", + "content-hash": "ed48aad82d21330c16813188427fb8ae", "packages": [ + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.5.0", + "source": { + "type": "git", + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "e749410375ff6fb7a040a68878c656c2e610b132" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/e749410375ff6fb7a040a68878c656c2e610b132", + "reference": "e749410375ff6fb7a040a68878c656c2e610b132", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0", + "php": "^5.3|^7", + "squizlabs/php_codesniffer": "^2|^3" + }, + "require-dev": { + "composer/composer": "*", + "phpcompatibility/php-compatibility": "^9.0", + "sensiolabs/security-checker": "^4.1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "time": "2018-10-26T13:21:45+00:00" + }, { "name": "doctrine/annotations", "version": "1.10.2", @@ -75,6 +141,67 @@ ], "time": "2020-04-20T09:18:32+00:00" }, + { + "name": "doctrine/coding-standard", + "version": "7.0.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/coding-standard.git", + "reference": "d8a60ec4da68025c42795b714f66e277dd3e11de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/d8a60ec4da68025c42795b714f66e277dd3e11de", + "reference": "d8a60ec4da68025c42795b714f66e277dd3e11de", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", + "php": "^7.2", + "slevomat/coding-standard": "^6.0", + "squizlabs/php_codesniffer": "^3.5.3" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "7.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Sniffs\\": "lib/Doctrine/Sniffs" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Steve Müller", + "email": "st.mueller@dzh-online.de" + } + ], + "description": "The Doctrine Coding Standard is a set of PHPCS rules applied to all Doctrine projects.", + "homepage": "https://www.doctrine-project.org/projects/coding-standard.html", + "keywords": [ + "checks", + "code", + "coding", + "cs", + "doctrine", + "rules", + "sniffer", + "sniffs", + "standard", + "style" + ], + "time": "2019-12-11T07:59:21+00:00" + }, { "name": "doctrine/lexer", "version": "1.2.0", @@ -136,6 +263,153 @@ "php" ], "time": "2019-10-30T14:39:59+00:00" + }, + { + "name": "phpstan/phpdoc-parser", + "version": "0.4.4", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "d8d9d4645379e677466d407034436bb155b11c65" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/d8d9d4645379e677466d407034436bb155b11c65", + "reference": "d8d9d4645379e677466d407034436bb155b11c65", + "shasum": "" + }, + "require": { + "php": "~7.1" + }, + "require-dev": { + "consistence/coding-standard": "^3.5", + "ergebnis/composer-normalize": "^2.0.2", + "jakub-onderka/php-parallel-lint": "^0.9.2", + "phing/phing": "^2.16.0", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12.19", + "phpstan/phpstan-strict-rules": "^0.12", + "phpunit/phpunit": "^6.3", + "slevomat/coding-standard": "^4.7.2", + "symfony/process": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.4-dev" + } + }, + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "time": "2020-04-13T16:28:46+00:00" + }, + { + "name": "slevomat/coding-standard", + "version": "6.3.6", + "source": { + "type": "git", + "url": "https://github.com/slevomat/coding-standard.git", + "reference": "7876032a4f55acf2de2cf3cd538feaf98a8a0fee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/7876032a4f55acf2de2cf3cd538feaf98a8a0fee", + "reference": "7876032a4f55acf2de2cf3cd538feaf98a8a0fee", + "shasum": "" + }, + "require": { + "php": "^7.1", + "phpstan/phpdoc-parser": "0.4.0 - 0.4.4", + "squizlabs/php_codesniffer": "^3.5.5" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "0.6.2", + "phing/phing": "2.16.3", + "php-parallel-lint/php-parallel-lint": "1.2.0", + "phpstan/phpstan": "0.12.19", + "phpstan/phpstan-deprecation-rules": "0.12.2", + "phpstan/phpstan-phpunit": "0.12.8", + "phpstan/phpstan-strict-rules": "0.12.2", + "phpunit/phpunit": "7.5.20|8.5.2|9.1.2" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "6.x-dev" + } + }, + "autoload": { + "psr-4": { + "SlevomatCodingStandard\\": "SlevomatCodingStandard" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "time": "2020-05-22T15:11:14+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.5.5", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/73e2e7f57d958e7228fce50dc0c61f58f017f9f6", + "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2020-04-17T01:09:41+00:00" } ], "packages-dev": [ diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..bfa3f19 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/DMS/Filter/Filters/Callback.php b/src/DMS/Filter/Filters/Callback.php index d88d8ab..7aad44c 100644 --- a/src/DMS/Filter/Filters/Callback.php +++ b/src/DMS/Filter/Filters/Callback.php @@ -17,7 +17,7 @@ class Callback extends BaseFilter implements ObjectAwareFilter { /** - * @var object | null + * @var object|null */ protected ?object $currentObject = null; @@ -34,7 +34,7 @@ public function setCurrentObject($object): void /** * Retrieves the current Object to be used * - * @return object | null + * @return object|null */ public function getCurrentObject() { diff --git a/src/DMS/Filter/Filters/ObjectAwareFilter.php b/src/DMS/Filter/Filters/ObjectAwareFilter.php index 164e6bb..3e268d3 100644 --- a/src/DMS/Filter/Filters/ObjectAwareFilter.php +++ b/src/DMS/Filter/Filters/ObjectAwareFilter.php @@ -22,7 +22,7 @@ public function setCurrentObject($object); /** * Retrieves the current Object to be used * - * @return object | null + * @return object|null */ public function getCurrentObject(); } From edca4f6c34c275f4bd27bb33b03464b87c8ed6c6 Mon Sep 17 00:00:00 2001 From: Rafael Dohms Date: Mon, 25 May 2020 21:48:49 +0200 Subject: [PATCH 4/4] Apply coding standard Use doctrine's coding standard with a couple changes. --- composer.json | 6 +- composer.lock | 498 +++++++++--------- phpcs.xml.dist | 6 +- src/DMS/Filter/Exception/FilterException.php | 6 +- .../Exception/InvalidCallbackException.php | 2 + .../Exception/InvalidOptionsException.php | 6 +- .../Exception/InvalidZendFilterException.php | 2 + .../Exception/MissingOptionsException.php | 6 +- .../Exception/RuleDefinitionException.php | 6 +- .../Filter/Exception/RuleOptionsException.php | 19 +- src/DMS/Filter/Filter.php | 55 +- src/DMS/Filter/FilterInterface.php | 19 +- src/DMS/Filter/Filters/Alnum.php | 7 +- src/DMS/Filter/Filters/Alpha.php | 7 +- src/DMS/Filter/Filters/BaseFilter.php | 6 +- src/DMS/Filter/Filters/BooleanScalar.php | 7 +- src/DMS/Filter/Filters/Callback.php | 51 +- src/DMS/Filter/Filters/Digits.php | 7 +- src/DMS/Filter/Filters/FloatScalar.php | 7 +- src/DMS/Filter/Filters/HtmlEntities.php | 7 +- src/DMS/Filter/Filters/IntScalar.php | 5 +- .../Filter/Filters/Loader/FilterLoader.php | 23 +- .../Filters/Loader/FilterLoaderInterface.php | 10 +- src/DMS/Filter/Filters/ObjectAwareFilter.php | 11 +- src/DMS/Filter/Filters/PregReplace.php | 7 +- src/DMS/Filter/Filters/RegExp.php | 19 +- src/DMS/Filter/Filters/StripNewlines.php | 6 +- src/DMS/Filter/Filters/StripTags.php | 6 +- src/DMS/Filter/Filters/ToLower.php | 23 +- src/DMS/Filter/Filters/ToUpper.php | 30 +- src/DMS/Filter/Filters/Trim.php | 6 +- src/DMS/Filter/Filters/Zend.php | 21 +- src/DMS/Filter/Mapping/ClassMetadata.php | 37 +- .../Filter/Mapping/ClassMetadataFactory.php | 60 +-- .../Mapping/ClassMetadataFactoryInterface.php | 10 +- .../Filter/Mapping/ClassMetadataInterface.php | 31 +- .../Mapping/Loader/AnnotationLoader.php | 27 +- .../Filter/Mapping/Loader/LoaderInterface.php | 9 +- src/DMS/Filter/ObjectWalker.php | 47 +- src/DMS/Filter/Rules/Alnum.php | 13 +- src/DMS/Filter/Rules/Alpha.php | 13 +- src/DMS/Filter/Rules/BooleanScalar.php | 5 +- src/DMS/Filter/Rules/Callback.php | 23 +- src/DMS/Filter/Rules/Digits.php | 13 +- src/DMS/Filter/Rules/FloatScalar.php | 5 +- src/DMS/Filter/Rules/HtmlEntities.php | 16 +- src/DMS/Filter/Rules/IntScalar.php | 5 +- src/DMS/Filter/Rules/PregReplace.php | 17 +- src/DMS/Filter/Rules/RegExp.php | 9 +- src/DMS/Filter/Rules/Rule.php | 67 +-- src/DMS/Filter/Rules/StripNewlines.php | 5 +- src/DMS/Filter/Rules/StripTags.php | 12 +- src/DMS/Filter/Rules/ToLower.php | 12 +- src/DMS/Filter/Rules/ToUpper.php | 12 +- src/DMS/Filter/Rules/Trim.php | 12 +- src/DMS/Filter/Rules/Zend.php | 12 +- 56 files changed, 595 insertions(+), 774 deletions(-) diff --git a/composer.json b/composer.json index 732dc0d..34a59fd 100644 --- a/composer.json +++ b/composer.json @@ -15,14 +15,14 @@ "require": { "php": "^7.4", - "doctrine/annotations": "~1.1", - "doctrine/coding-standard": "^7" + "doctrine/annotations": "~1.1" }, "require-dev": { "doctrine/cache": "~1.3", "phpunit/phpunit": "^9", - "laminas/laminas-filter": "^2.9" + "laminas/laminas-filter": "^2.9", + "doctrine/coding-standard": "^7.0" }, "autoload": { "psr-0": { diff --git a/composer.lock b/composer.lock index 28e7c2a..da7f872 100644 --- a/composer.lock +++ b/composer.lock @@ -4,74 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ed48aad82d21330c16813188427fb8ae", + "content-hash": "4a5b5d1d6416984ded756b0c0e76ce57", "packages": [ - { - "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.5.0", - "source": { - "type": "git", - "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "e749410375ff6fb7a040a68878c656c2e610b132" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/e749410375ff6fb7a040a68878c656c2e610b132", - "reference": "e749410375ff6fb7a040a68878c656c2e610b132", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0", - "php": "^5.3|^7", - "squizlabs/php_codesniffer": "^2|^3" - }, - "require-dev": { - "composer/composer": "*", - "phpcompatibility/php-compatibility": "^9.0", - "sensiolabs/security-checker": "^4.1.0" - }, - "type": "composer-plugin", - "extra": { - "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" - }, - "autoload": { - "psr-4": { - "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Franck Nijhof", - "email": "franck.nijhof@dealerdirect.com", - "homepage": "http://www.frenck.nl", - "role": "Developer / IT Manager" - } - ], - "description": "PHP_CodeSniffer Standards Composer Installer Plugin", - "homepage": "http://www.dealerdirect.com", - "keywords": [ - "PHPCodeSniffer", - "PHP_CodeSniffer", - "code quality", - "codesniffer", - "composer", - "installer", - "phpcs", - "plugin", - "qa", - "quality", - "standard", - "standards", - "style guide", - "stylecheck", - "tests" - ], - "time": "2018-10-26T13:21:45+00:00" - }, { "name": "doctrine/annotations", "version": "1.10.2", @@ -141,67 +75,6 @@ ], "time": "2020-04-20T09:18:32+00:00" }, - { - "name": "doctrine/coding-standard", - "version": "7.0.2", - "source": { - "type": "git", - "url": "https://github.com/doctrine/coding-standard.git", - "reference": "d8a60ec4da68025c42795b714f66e277dd3e11de" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/d8a60ec4da68025c42795b714f66e277dd3e11de", - "reference": "d8a60ec4da68025c42795b714f66e277dd3e11de", - "shasum": "" - }, - "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", - "php": "^7.2", - "slevomat/coding-standard": "^6.0", - "squizlabs/php_codesniffer": "^3.5.3" - }, - "type": "phpcodesniffer-standard", - "extra": { - "branch-alias": { - "dev-master": "7.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Sniffs\\": "lib/Doctrine/Sniffs" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Steve Müller", - "email": "st.mueller@dzh-online.de" - } - ], - "description": "The Doctrine Coding Standard is a set of PHPCS rules applied to all Doctrine projects.", - "homepage": "https://www.doctrine-project.org/projects/coding-standard.html", - "keywords": [ - "checks", - "code", - "coding", - "cs", - "doctrine", - "rules", - "sniffer", - "sniffs", - "standard", - "style" - ], - "time": "2019-12-11T07:59:21+00:00" - }, { "name": "doctrine/lexer", "version": "1.2.0", @@ -263,156 +136,75 @@ "php" ], "time": "2019-10-30T14:39:59+00:00" - }, - { - "name": "phpstan/phpdoc-parser", - "version": "0.4.4", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "d8d9d4645379e677466d407034436bb155b11c65" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/d8d9d4645379e677466d407034436bb155b11c65", - "reference": "d8d9d4645379e677466d407034436bb155b11c65", - "shasum": "" - }, - "require": { - "php": "~7.1" - }, - "require-dev": { - "consistence/coding-standard": "^3.5", - "ergebnis/composer-normalize": "^2.0.2", - "jakub-onderka/php-parallel-lint": "^0.9.2", - "phing/phing": "^2.16.0", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12.19", - "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/phpunit": "^6.3", - "slevomat/coding-standard": "^4.7.2", - "symfony/process": "^4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.4-dev" - } - }, - "autoload": { - "psr-4": { - "PHPStan\\PhpDocParser\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPDoc parser with support for nullable, intersection and generic types", - "time": "2020-04-13T16:28:46+00:00" - }, + } + ], + "packages-dev": [ { - "name": "slevomat/coding-standard", - "version": "6.3.6", + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.5.0", "source": { "type": "git", - "url": "https://github.com/slevomat/coding-standard.git", - "reference": "7876032a4f55acf2de2cf3cd538feaf98a8a0fee" + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "e749410375ff6fb7a040a68878c656c2e610b132" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/7876032a4f55acf2de2cf3cd538feaf98a8a0fee", - "reference": "7876032a4f55acf2de2cf3cd538feaf98a8a0fee", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/e749410375ff6fb7a040a68878c656c2e610b132", + "reference": "e749410375ff6fb7a040a68878c656c2e610b132", "shasum": "" }, "require": { - "php": "^7.1", - "phpstan/phpdoc-parser": "0.4.0 - 0.4.4", - "squizlabs/php_codesniffer": "^3.5.5" + "composer-plugin-api": "^1.0", + "php": "^5.3|^7", + "squizlabs/php_codesniffer": "^2|^3" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "0.6.2", - "phing/phing": "2.16.3", - "php-parallel-lint/php-parallel-lint": "1.2.0", - "phpstan/phpstan": "0.12.19", - "phpstan/phpstan-deprecation-rules": "0.12.2", - "phpstan/phpstan-phpunit": "0.12.8", - "phpstan/phpstan-strict-rules": "0.12.2", - "phpunit/phpunit": "7.5.20|8.5.2|9.1.2" + "composer/composer": "*", + "phpcompatibility/php-compatibility": "^9.0", + "sensiolabs/security-checker": "^4.1.0" }, - "type": "phpcodesniffer-standard", + "type": "composer-plugin", "extra": { - "branch-alias": { - "dev-master": "6.x-dev" - } + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" }, "autoload": { "psr-4": { - "SlevomatCodingStandard\\": "SlevomatCodingStandard" + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", - "time": "2020-05-22T15:11:14+00:00" - }, - { - "name": "squizlabs/php_codesniffer", - "version": "3.5.5", - "source": { - "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/73e2e7f57d958e7228fce50dc0c61f58f017f9f6", - "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" - }, - "bin": [ - "bin/phpcs", - "bin/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], "authors": [ { - "name": "Greg Sherwood", - "role": "lead" + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" } ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", "phpcs", - "standards" + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" ], - "time": "2020-04-17T01:09:41+00:00" - } - ], - "packages-dev": [ + "time": "2018-10-26T13:21:45+00:00" + }, { "name": "doctrine/cache", "version": "1.10.0", @@ -495,6 +287,67 @@ ], "time": "2019-11-29T15:36:20+00:00" }, + { + "name": "doctrine/coding-standard", + "version": "7.0.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/coding-standard.git", + "reference": "d8a60ec4da68025c42795b714f66e277dd3e11de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/d8a60ec4da68025c42795b714f66e277dd3e11de", + "reference": "d8a60ec4da68025c42795b714f66e277dd3e11de", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", + "php": "^7.2", + "slevomat/coding-standard": "^6.0", + "squizlabs/php_codesniffer": "^3.5.3" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "7.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Sniffs\\": "lib/Doctrine/Sniffs" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Steve Müller", + "email": "st.mueller@dzh-online.de" + } + ], + "description": "The Doctrine Coding Standard is a set of PHPCS rules applied to all Doctrine projects.", + "homepage": "https://www.doctrine-project.org/projects/coding-standard.html", + "keywords": [ + "checks", + "code", + "coding", + "cs", + "doctrine", + "rules", + "sniffer", + "sniffs", + "standard", + "style" + ], + "time": "2019-12-11T07:59:21+00:00" + }, { "name": "doctrine/instantiator", "version": "1.3.0", @@ -1083,6 +936,55 @@ ], "time": "2020-03-05T15:02:03+00:00" }, + { + "name": "phpstan/phpdoc-parser", + "version": "0.4.4", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "d8d9d4645379e677466d407034436bb155b11c65" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/d8d9d4645379e677466d407034436bb155b11c65", + "reference": "d8d9d4645379e677466d407034436bb155b11c65", + "shasum": "" + }, + "require": { + "php": "~7.1" + }, + "require-dev": { + "consistence/coding-standard": "^3.5", + "ergebnis/composer-normalize": "^2.0.2", + "jakub-onderka/php-parallel-lint": "^0.9.2", + "phing/phing": "^2.16.0", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12.19", + "phpstan/phpstan-strict-rules": "^0.12", + "phpunit/phpunit": "^6.3", + "slevomat/coding-standard": "^4.7.2", + "symfony/process": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.4-dev" + } + }, + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "time": "2020-04-13T16:28:46+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "8.0.1", @@ -2146,6 +2048,104 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2020-01-21T06:36:37+00:00" }, + { + "name": "slevomat/coding-standard", + "version": "6.3.6", + "source": { + "type": "git", + "url": "https://github.com/slevomat/coding-standard.git", + "reference": "7876032a4f55acf2de2cf3cd538feaf98a8a0fee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/7876032a4f55acf2de2cf3cd538feaf98a8a0fee", + "reference": "7876032a4f55acf2de2cf3cd538feaf98a8a0fee", + "shasum": "" + }, + "require": { + "php": "^7.1", + "phpstan/phpdoc-parser": "0.4.0 - 0.4.4", + "squizlabs/php_codesniffer": "^3.5.5" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "0.6.2", + "phing/phing": "2.16.3", + "php-parallel-lint/php-parallel-lint": "1.2.0", + "phpstan/phpstan": "0.12.19", + "phpstan/phpstan-deprecation-rules": "0.12.2", + "phpstan/phpstan-phpunit": "0.12.8", + "phpstan/phpstan-strict-rules": "0.12.2", + "phpunit/phpunit": "7.5.20|8.5.2|9.1.2" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "6.x-dev" + } + }, + "autoload": { + "psr-4": { + "SlevomatCodingStandard\\": "SlevomatCodingStandard" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "time": "2020-05-22T15:11:14+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.5.5", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/73e2e7f57d958e7228fce50dc0c61f58f017f9f6", + "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2020-04-17T01:09:41+00:00" + }, { "name": "symfony/polyfill-ctype", "version": "v1.17.0", diff --git a/phpcs.xml.dist b/phpcs.xml.dist index bfa3f19..de7c5ac 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -5,5 +5,9 @@ - + + + + + diff --git a/src/DMS/Filter/Exception/FilterException.php b/src/DMS/Filter/Exception/FilterException.php index 58d73a0..e19c3c2 100644 --- a/src/DMS/Filter/Exception/FilterException.php +++ b/src/DMS/Filter/Exception/FilterException.php @@ -1,15 +1,13 @@ options; } diff --git a/src/DMS/Filter/Filter.php b/src/DMS/Filter/Filter.php index f969029..0cc8b1b 100644 --- a/src/DMS/Filter/Filter.php +++ b/src/DMS/Filter/Filter.php @@ -1,45 +1,32 @@ metadataFactory = $metadataFactory; $this->filterLoader = $filterLoader; @@ -48,7 +35,7 @@ public function __construct(Mapping\ClassMetadataFactory $metadataFactory, $filt /** * {@inheritDoc} */ - public function filterEntity($object): void + public function filterEntity($object) : void { $this->walkObject($object); } @@ -56,7 +43,7 @@ public function filterEntity($object): void /** * {@inheritDoc} */ - public function filterProperty($object, $property): void + public function filterProperty($object, $property) : void { $this->walkObject($object, $property); } @@ -68,16 +55,14 @@ public function filterValue($value, $rule) { if ($rule instanceof Rules\Rule) { $filter = $this->filterLoader->getFilterForRule($rule); + return $filter->apply($rule, $value); } return $this->walkRuleChain($value, $rule); } - /** - * {@inheritDoc} - */ - public function getMetadataFactory(): ClassMetadataFactoryInterface + public function getMetadataFactory() : ClassMetadataFactoryInterface { return $this->metadataFactory; } @@ -86,13 +71,10 @@ public function getMetadataFactory(): ClassMetadataFactoryInterface * Iterates over annotated properties in an object filtering the selected * values * - * @param object $object - * @param string $limitProperty - * - * @throws \ReflectionException - * @throws \ReflectionException + * @throws ReflectionException + * @throws ReflectionException */ - protected function walkObject($object, $limitProperty = null): void + protected function walkObject(?object $object, ?string $limitProperty = null) : void { if ($object === null) { return; @@ -104,7 +86,7 @@ protected function walkObject($object, $limitProperty = null): void $walker = new ObjectWalker($object, $this->filterLoader); //Get all filtered properties or limit with selected - $properties = ($limitProperty !== null) ? [$limitProperty] : $metadata->getFilteredProperties(); + $properties = $limitProperty !== null ? [$limitProperty] : $metadata->getFilteredProperties(); //Iterate over properties with filters foreach ($properties as $property) { @@ -115,15 +97,16 @@ protected function walkObject($object, $limitProperty = null): void /** * Iterates over an array of filters applying all to the value * - * @param mixed $value - * @param array $rules + * @param mixed $value + * @param Rule[] $rules + * * @return mixed */ - protected function walkRuleChain($value, $rules) + protected function walkRuleChain($value, array $rules) { foreach ($rules as $rule) { $filter = $this->filterLoader->getFilterForRule($rule); - $value = $filter->apply($rule, $value); + $value = $filter->apply($rule, $value); } return $value; diff --git a/src/DMS/Filter/FilterInterface.php b/src/DMS/Filter/FilterInterface.php index e53d6ab..2eabf76 100644 --- a/src/DMS/Filter/FilterInterface.php +++ b/src/DMS/Filter/FilterInterface.php @@ -1,14 +1,14 @@ allowWhitespace)? " ":""; + $whitespaceChar = $rule->allowWhitespace? ' ':''; $rule->unicodePattern = '/[^\p{L}\p{N}' . $whitespaceChar . ']/u'; $rule->pattern = '/[^a-zA-Z0-9' . $whitespaceChar . ']/'; diff --git a/src/DMS/Filter/Filters/Alpha.php b/src/DMS/Filter/Filters/Alpha.php index acb95e9..1746e44 100644 --- a/src/DMS/Filter/Filters/Alpha.php +++ b/src/DMS/Filter/Filters/Alpha.php @@ -1,14 +1,13 @@ allowWhitespace)? " ":""; + $whitespaceChar = $rule->allowWhitespace? ' ':''; $rule->unicodePattern = '/[^\p{L}' . $whitespaceChar . ']/u'; $rule->pattern = '/[^a-zA-Z' . $whitespaceChar . ']/'; diff --git a/src/DMS/Filter/Filters/BaseFilter.php b/src/DMS/Filter/Filters/BaseFilter.php index 711da81..c23a509 100644 --- a/src/DMS/Filter/Filters/BaseFilter.php +++ b/src/DMS/Filter/Filters/BaseFilter.php @@ -1,4 +1,7 @@ currentObject = $object; } /** * Retrieves the current Object to be used - * - * @return object|null */ - public function getCurrentObject() + public function getCurrentObject() : ?object { return $this->currentObject; } @@ -54,32 +51,32 @@ public function apply(Rule $rule, $value) $type = $rule->getInputType(); - if ($type == CallbackRule::SELF_METHOD_TYPE) { + if ($type === CallbackRule::SELF_METHOD_TYPE) { return $this->useObjectMethod($rule->callback, $value); } - if ($type == CallbackRule::CALLABLE_TYPE) { + if ($type === CallbackRule::CALLABLE_TYPE) { return $this->useCallable($rule->callback, $value); } - if ($type == CallbackRule::CLOSURE_TYPE) { + if ($type === CallbackRule::CLOSURE_TYPE) { return $this->useClosure($rule->callback, $value); } - throw new InvalidCallbackException("Unsupported callback provided, failed to filter property"); + throw new InvalidCallbackException('Unsupported callback provided, failed to filter property'); } /** * Filters by executing a method in the object * - * @param string $method * @param mixed $value * * @return mixed - *@throws InvalidCallbackException + * + * @throws InvalidCallbackException * @throws FilterException */ - protected function useObjectMethod($method, $value) + protected function useObjectMethod(string $method, $value) { $currentObject = $this->getCurrentObject(); @@ -105,32 +102,34 @@ protected function useObjectMethod($method, $value) /** * Filters using a callable. * - * @param callable $callable - * @param mixed $value + * @param mixed $value + * @param string[]|callable $callable * * @return mixed + * * @throws InvalidCallbackException */ protected function useCallable($callable, $value) { if (! is_callable($callable, false, $input)) { - throw new InvalidCallbackException("The callable $input could not be resolved."); + throw new InvalidCallbackException(sprintf('The callable %s could not be resolved.', $input)); } return call_user_func($callable, $value); } /** - * @param Closure $closure - * @param mixed $value + * @param mixed $value + * @param string|Closure $closure * * @return mixed - *@throws InvalidCallbackException + * + * @throws InvalidCallbackException */ protected function useClosure($closure, $value) { if (! $closure instanceof Closure) { - throw new InvalidCallbackException("CallbackFilter: the provided closure is invalid"); + throw new InvalidCallbackException('CallbackFilter: the provided closure is invalid'); } return $closure($value); diff --git a/src/DMS/Filter/Filters/Digits.php b/src/DMS/Filter/Filters/Digits.php index 8a1c22c..a1d602f 100644 --- a/src/DMS/Filter/Filters/Digits.php +++ b/src/DMS/Filter/Filters/Digits.php @@ -1,14 +1,13 @@ allowWhitespace)? " ":""; + $whitespaceChar = $rule->allowWhitespace? ' ':''; $rule->unicodePattern = '/[^\p{N}' . $whitespaceChar . ']/'; $rule->pattern = '/[^0-9' . $whitespaceChar . ']/'; diff --git a/src/DMS/Filter/Filters/FloatScalar.php b/src/DMS/Filter/Filters/FloatScalar.php index 86a2e59..56b96bf 100644 --- a/src/DMS/Filter/Filters/FloatScalar.php +++ b/src/DMS/Filter/Filters/FloatScalar.php @@ -1,15 +1,16 @@ getFilter(); if (class_exists($filterIdentifier)) { - return new $filterIdentifier; + return new $filterIdentifier(); } - $error = "Unable to locate filter for: $filterIdentifier defined in " . get_class($rule); + $error = sprintf('Unable to locate filter for: %s defined in %s', $filterIdentifier, get_class($rule)); + throw new UnexpectedValueException($error); } } diff --git a/src/DMS/Filter/Filters/Loader/FilterLoaderInterface.php b/src/DMS/Filter/Filters/Loader/FilterLoaderInterface.php index 2e47e18..5cf140d 100644 --- a/src/DMS/Filter/Filters/Loader/FilterLoaderInterface.php +++ b/src/DMS/Filter/Filters/Loader/FilterLoaderInterface.php @@ -1,4 +1,7 @@ checkUnicodeSupport() && $rule->unicodePattern !== null) + $pattern = $this->checkUnicodeSupport() && $rule->unicodePattern !== null ? $rule->unicodePattern : $rule->pattern; @@ -38,12 +37,12 @@ public function apply(Rule $rule, $value) /** * Verifies that Regular Expression functions support unicode - * @return boolean */ - public function checkUnicodeSupport(): bool + public function checkUnicodeSupport() : bool { - if (null === static::$unicodeEnabled) { - static::$unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false; + if (static::$unicodeEnabled === null) { + //phpcs:disable SlevomatCodingStandard.ControlStructures.UselessTernaryOperator.UselessTernaryOperator + static::$unicodeEnabled = @preg_match('/\pL/u', 'a') ? true : false; } return static::$unicodeEnabled; diff --git a/src/DMS/Filter/Filters/StripNewlines.php b/src/DMS/Filter/Filters/StripNewlines.php index 84aa6a9..172e3c5 100644 --- a/src/DMS/Filter/Filters/StripNewlines.php +++ b/src/DMS/Filter/Filters/StripNewlines.php @@ -1,14 +1,14 @@ encoding === null) { return false; @@ -49,9 +50,9 @@ public function useEncoding($rule): bool $encodings = array_map('strtolower', mb_list_encodings()); - if (!in_array(strtolower($rule->encoding), $encodings)) { + if (! in_array(strtolower($rule->encoding), $encodings)) { throw new FilterException( - "mbstring does not support the '".$rule->encoding."' encoding" + "mbstring does not support the '" . $rule->encoding . "' encoding" ); } diff --git a/src/DMS/Filter/Filters/ToUpper.php b/src/DMS/Filter/Filters/ToUpper.php index 224e16d..1755af5 100644 --- a/src/DMS/Filter/Filters/ToUpper.php +++ b/src/DMS/Filter/Filters/ToUpper.php @@ -1,15 +1,21 @@ encoding === null) { return false; } - if (!function_exists('mb_strtoupper')) { + if (! function_exists('mb_strtoupper')) { throw new FilterException( - 'mbstring is required to use ToLower with an encoding.'); + 'mbstring is required to use ToLower with an encoding.' + ); } $this->encoding = (string) $rule->encoding; - $encodings = array_map('strtolower', mb_list_encodings()); + $encodings = array_map('strtolower', mb_list_encodings()); - if (!in_array(strtolower($rule->encoding), $encodings)) { + if (! in_array(strtolower($rule->encoding), $encodings)) { throw new FilterException( - "mbstring does not support the '".$rule->encoding."' encoding" + "mbstring does not support the '" . $rule->encoding . "' encoding" ); } diff --git a/src/DMS/Filter/Filters/Trim.php b/src/DMS/Filter/Filters/Trim.php index a460785..f88fb72 100644 --- a/src/DMS/Filter/Filters/Trim.php +++ b/src/DMS/Filter/Filters/Trim.php @@ -1,14 +1,14 @@ className = $class; } @@ -38,7 +34,7 @@ public function __construct($class) /** * {@inheritDoc} */ - public function getFilteredProperties(): array + public function getFilteredProperties() : array { return array_keys($this->filteredProperties); } @@ -46,7 +42,7 @@ public function getFilteredProperties(): array /** * {@inheritDoc} */ - public function getPropertyRules($property): ?array + public function getPropertyRules($property) : ?array { if (! isset($this->filteredProperties[$property])) { return null; @@ -55,10 +51,7 @@ public function getPropertyRules($property): ?array return $this->filteredProperties[$property]['rules']; } - /** - * {@inheritDoc} - */ - public function mergeRules(ClassMetadataInterface $metadata): void + public function mergeRules(ClassMetadataInterface $metadata) : void { foreach ($metadata->getFilteredProperties() as $property) { foreach ($metadata->getPropertyRules($property) as $rule) { @@ -70,28 +63,26 @@ public function mergeRules(ClassMetadataInterface $metadata): void /** * {@inheritDoc} */ - public function addPropertyRule($property, Rule $rule): void + public function addPropertyRule($property, Rule $rule) : void { - if (!isset($this->filteredProperties[$property])) { + if (! isset($this->filteredProperties[$property])) { $this->filteredProperties[$property] = ['rules' => []]; } $this->filteredProperties[$property]['rules'][] = $rule; } - /** - * {@inheritDoc} - */ - public function getClassName(): string + public function getClassName() : string { return $this->className; } /** * {@inheritDoc} + * * @throws ReflectionException */ - public function getReflectionClass(): ReflectionClass + public function getReflectionClass() : ReflectionClass { return new ReflectionClass($this->getClassName()); } diff --git a/src/DMS/Filter/Mapping/ClassMetadataFactory.php b/src/DMS/Filter/Mapping/ClassMetadataFactory.php index 56e8b14..c6c368f 100644 --- a/src/DMS/Filter/Mapping/ClassMetadataFactory.php +++ b/src/DMS/Filter/Mapping/ClassMetadataFactory.php @@ -1,49 +1,38 @@ loader = $loader; - $this->cache = $cache; + $this->cache = $cache; } /** * {@inheritDoc} */ - public function getClassMetadata($class): ClassMetadataInterface + public function getClassMetadata($class) : ClassMetadataInterface { $class = ltrim($class, '\\'); @@ -55,6 +44,7 @@ public function getClassMetadata($class): ClassMetadataInterface //Check Cache for it if ($this->cache !== null && $this->cache->contains($class)) { $this->setParsedClass($class, $this->cache->fetch($class)); + return $this->getParsedClass($class); } @@ -64,11 +54,8 @@ public function getClassMetadata($class): ClassMetadataInterface /** * Reads class metadata for a new and unparsed class - * - * @param string $class - * @return ClassMetadataInterface */ - private function parseClassMetadata($class) + private function parseClassMetadata(string $class) : ClassMetadataInterface { $metadata = new ClassMetadata($class); @@ -91,22 +78,16 @@ private function parseClassMetadata($class) /** * Checks if a class has already been parsed - * - * @param string $class - * @return boolean */ - private function isParsed($class): bool + private function isParsed(string $class) : bool { return isset($this->parsedClasses[$class]); } /** * Retrieves data from a class already parsed - * - * @param string $class - * @return ClassMetadataInterface */ - private function getParsedClass($class): ?ClassMetadataInterface + private function getParsedClass(string $class) : ?ClassMetadataInterface { if (! $this->isParsed($class)) { return null; @@ -117,11 +98,8 @@ private function getParsedClass($class): ?ClassMetadataInterface /** * Stores data from a parsed class - * - * @param string $class - * @param ClassMetadataInterface $metadata */ - private function setParsedClass($class, ClassMetadataInterface $metadata): void + private function setParsedClass(string $class, ClassMetadataInterface $metadata) : void { $this->parsedClasses[$class] = $metadata; } @@ -129,25 +107,23 @@ private function setParsedClass($class, ClassMetadataInterface $metadata): void /** * Checks if the class being parsed has a parent and cascades parsing * to its parent - * - * @param ClassMetadataInterface $metadata */ - protected function loadParentMetadata(ClassMetadataInterface $metadata): void + protected function loadParentMetadata(ClassMetadataInterface $metadata) : void { $parent = $metadata->getReflectionClass()->getParentClass(); - if ($parent) { - $metadata->mergeRules($this->getClassMetadata($parent->getName())); + if (! $parent) { + return; } + + $metadata->mergeRules($this->getClassMetadata($parent->getName())); } /** * Checks if the object has interfaces and cascades parsing of annotatiosn * to all the interfaces - * - * @param ClassMetadataInterface $metadata */ - protected function loadInterfaceMetadata(ClassMetadataInterface $metadata): void + protected function loadInterfaceMetadata(ClassMetadataInterface $metadata) : void { foreach ($metadata->getReflectionClass()->getInterfaces() as $interface) { $metadata->mergeRules($this->getClassMetadata($interface->getName())); diff --git a/src/DMS/Filter/Mapping/ClassMetadataFactoryInterface.php b/src/DMS/Filter/Mapping/ClassMetadataFactoryInterface.php index 456b638..67c8762 100644 --- a/src/DMS/Filter/Mapping/ClassMetadataFactoryInterface.php +++ b/src/DMS/Filter/Mapping/ClassMetadataFactoryInterface.php @@ -1,20 +1,16 @@ getReflectionClass(); @@ -57,22 +48,18 @@ public function loadClassMetadata(ClassMetadataInterface $metadata): bool /** * Reads annotations for a selected property in the class - * - * @param ReflectionProperty $property - * @param ClassMetadataInterface $metadata */ - private function readProperty(ReflectionProperty $property, ClassMetadataInterface $metadata): void + private function readProperty(ReflectionProperty $property, ClassMetadataInterface $metadata) : void { // Skip if this property is not from this class if ($property->getDeclaringClass()->getName() - != $metadata->getClassName() + !== $metadata->getClassName() ) { return; } //Iterate over all annotations foreach ($this->reader->getPropertyAnnotations($property) as $rule) { - //Skip is its not a rule if (! $rule instanceof Rules\Rule) { continue; diff --git a/src/DMS/Filter/Mapping/Loader/LoaderInterface.php b/src/DMS/Filter/Mapping/Loader/LoaderInterface.php index 1b45617..f5348f1 100644 --- a/src/DMS/Filter/Mapping/Loader/LoaderInterface.php +++ b/src/DMS/Filter/Mapping/Loader/LoaderInterface.php @@ -1,14 +1,13 @@ object = $object; $this->reflClass = new ReflectionClass($object); @@ -52,12 +40,11 @@ public function __construct($object, $filterLoader) /** * Applies the selected rules to a property in the object * - * @param string $property - * @param array $filterRules + * @param Rule[] $filterRules * * @throws ReflectionException */ - public function applyFilterRules($property, $filterRules = []): void + public function applyFilterRules(string $property, array $filterRules = []) : void { foreach ($filterRules as $rule) { $this->applyFilterRule($property, $rule); @@ -67,16 +54,13 @@ public function applyFilterRules($property, $filterRules = []): void /** * Applies a Filtering Rule to a property * - * @param string $property - * @param Rules\Rule $filterRule - * * @throws UnexpectedValueException * @throws ReflectionException */ - public function applyFilterRule($property, Rules\Rule $filterRule): void + public function applyFilterRule(string $property, Rules\Rule $filterRule) : void { if ($this->filterLoader === null) { - throw new UnexpectedValueException("A FilterLoader must be provided"); + throw new UnexpectedValueException('A FilterLoader must be provided'); } $value = $this->getPropertyValue($property); @@ -95,13 +79,12 @@ public function applyFilterRule($property, Rules\Rule $filterRule): void /** * Retrieves the value of the property, overcoming visibility problems * - * @param string $propertyName - * * @return mixed + * * @throws ReflectionException * @throws ReflectionException */ - private function getPropertyValue($propertyName) + private function getPropertyValue(string $propertyName) { return $this->getAccessibleReflectionProperty($propertyName) ->getValue($this->object); @@ -110,13 +93,12 @@ private function getPropertyValue($propertyName) /** * Overrides the value of a property, overcoming visibility problems * - * @param string $propertyName - * @param mixed $value + * @param mixed $value * * @throws ReflectionException * @throws ReflectionException */ - private function setPropertyValue($propertyName, $value): void + private function setPropertyValue(string $propertyName, $value) : void { $this->getAccessibleReflectionProperty($propertyName) ->setValue($this->object, $value); @@ -125,13 +107,10 @@ private function setPropertyValue($propertyName, $value): void /** * Retrieves a property from the object and makes it visible * - * @param string $propertyName - * - * @return ReflectionProperty * @throws ReflectionException * @throws ReflectionException */ - private function getAccessibleReflectionProperty($propertyName): ReflectionProperty + private function getAccessibleReflectionProperty(string $propertyName) : ReflectionProperty { $property = $this->reflClass->getProperty($propertyName); $property->setAccessible(true); diff --git a/src/DMS/Filter/Rules/Alnum.php b/src/DMS/Filter/Rules/Alnum.php index 9c9a38d..8b77e9c 100644 --- a/src/DMS/Filter/Rules/Alnum.php +++ b/src/DMS/Filter/Rules/Alnum.php @@ -1,29 +1,22 @@ callback instanceof Closure: return self::CLOSURE_TYPE; - case is_callable($this->callback, false): return self::CALLABLE_TYPE; - case is_string($this->callback): return self::SELF_METHOD_TYPE; } diff --git a/src/DMS/Filter/Rules/Digits.php b/src/DMS/Filter/Rules/Digits.php index 6e5d7ca..3c0d295 100644 --- a/src/DMS/Filter/Rules/Digits.php +++ b/src/DMS/Filter/Rules/Digits.php @@ -1,29 +1,22 @@ invalidOptions), - get_class($this) + static::class ), $result->invalidOptions ); @@ -52,7 +59,7 @@ public function __construct($options = null) sprintf( 'The options "%s" must be set for rule %s', implode('", "', array_keys($result->missingOptions)), - get_class($this) + static::class ), array_keys($result->missingOptions) ); @@ -64,9 +71,8 @@ public function __construct($options = null) * for the parsing process * * @param mixed $options - * @return stdClass */ - private function parseOptions($options): stdClass + private function parseOptions($options) : stdClass { $parseResult = new stdClass(); $parseResult->invalidOptions = []; @@ -80,13 +86,14 @@ private function parseOptions($options): stdClass //Parse Option Array if ($this->isNonEmptyMap($options)) { $this->parseOptionsArray($options, $parseResult); + return $parseResult; } - //Parse Single Value if ($options !== []) { $this->parseSingleOption($options, $parseResult); + return $parseResult; } @@ -96,10 +103,9 @@ private function parseOptions($options): stdClass /** * Parses Options in the array format * - * @param array $options - * @param stdClass $result + * @param mixed[] $options */ - private function parseOptionsArray($options, stdClass $result): void + private function parseOptionsArray(array $options, stdClass $result) : void { foreach ($options as $option => $value) { if (! property_exists($this, $option)) { @@ -116,24 +122,25 @@ private function parseOptionsArray($options, stdClass $result): void /** * Parses single option received * - * @param string|array $options - * @param stdClass $result + * @param string|mixed[] $options + * * @throws RuleDefinitionException */ - private function parseSingleOption($options, stdClass $result): void + private function parseSingleOption($options, stdClass $result) : void { $option = $this->getDefaultOption(); //No Default set, unsure what to do - if (null === $option) { + if ($option === null) { throw new RuleDefinitionException( - sprintf('No default option is configured for rule %s', get_class($this)) + sprintf('No default option is configured for rule %s', static::class) ); } //Default option points to invalid one if (! property_exists($this, $option)) { $result->invalidOptions[] = $option; + return; } @@ -147,10 +154,11 @@ private function parseSingleOption($options, stdClass $result): void * * Override this method if you want to define required options. * - * @return array * @see __construct() + * + * @return string[] */ - public function getRequiredOptions(): array + public function getRequiredOptions() : array { return []; } @@ -160,10 +168,9 @@ public function getRequiredOptions(): array * * Override this method to define a default option. * - * @return string|null * @see __construct() */ - public function getDefaultOption(): ?string + public function getDefaultOption() : ?string { return null; } @@ -172,12 +179,10 @@ public function getDefaultOption(): ?string * Retrieves the Filter class that is responsible for executing this filter * It may also be a service name. By default it loads a class with the * same name from the Filters namespace. - * - * @return string */ - public function getFilter(): string + public function getFilter() : string { - return str_replace('Rules', 'Filters', get_class($this)); + return str_replace('Rules', 'Filters', static::class); } /** @@ -185,24 +190,22 @@ public function getFilter(): string * * @param mixed $options * - * @return array|mixed + * @return mixed[]|mixed */ private function extractFromValueOption($options) { - if (is_array($options) && count($options) === 1 && isset($options['value'])) { $options = $options['value']; } + return $options; } /** * @param mixed $options - * - * @return bool */ - private function isNonEmptyMap($options): bool + private function isNonEmptyMap($options) : bool { return is_array($options) && count($options) > 0 && is_string(key($options)); -} + } } diff --git a/src/DMS/Filter/Rules/StripNewlines.php b/src/DMS/Filter/Rules/StripNewlines.php index 2e6b228..bf84afc 100644 --- a/src/DMS/Filter/Rules/StripNewlines.php +++ b/src/DMS/Filter/Rules/StripNewlines.php @@ -1,13 +1,12 @@ - * - * @var string */ public ?string $allowed = null; - /** - * {@inheritDoc} - */ - public function getDefaultOption(): ?string + public function getDefaultOption() : ?string { return 'allowed'; } diff --git a/src/DMS/Filter/Rules/ToLower.php b/src/DMS/Filter/Rules/ToLower.php index c49db9f..551b834 100644 --- a/src/DMS/Filter/Rules/ToLower.php +++ b/src/DMS/Filter/Rules/ToLower.php @@ -1,28 +1,22 @@