diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml index ceb70666..c034a667 100644 --- a/.github/ISSUE_TEMPLATE/bug.yaml +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -51,8 +51,7 @@ body: label: "🐘 PHP Version" description: "What version of PHP are you running?" options: - - PHP 7.3.x - - PHP 7.4.x + - PHP 8.0 - Different version (specify in environment) validations: required: true diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..efa930a0 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,21 @@ +name: "CodeQL" + +on: [pull_request] +jobs: + lint: + name: CodeQL + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - run: git checkout HEAD^2 + + - name: Run CodeQL + run: | + docker run --rm -v $PWD:/app composer sh -c \ + "composer install --profile --ignore-platform-reqs && composer check" + \ No newline at end of file diff --git a/README.md b/README.md index ca0e3484..ac3fc084 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ $app->run($request, $response); ## System Requirements -Utopia Framework requires PHP 7.3 or later. We recommend using the latest PHP version whenever possible. +Utopia Framework requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible. ## More from Utopia diff --git a/composer.json b/composer.json old mode 100755 new mode 100644 index bc8a9a2d..3fb769b5 --- a/composer.json +++ b/composer.json @@ -10,14 +10,16 @@ }, "scripts": { "lint": "./vendor/bin/pint --test", - "format": "./vendor/bin/pint" + "format": "./vendor/bin/pint", + "check": "./vendor/bin/phpstan analyse -l 5 src tests" }, "require": { - "php": ">=8.0.0" + "php": ">=8.0" }, "require-dev": { "phpunit/phpunit": "^9.5.25", "vimeo/psalm": "4.27.0", - "laravel/pint": "^1.2" + "laravel/pint": "^1.2", + "phpstan/phpstan": "1.9.x-dev" } } diff --git a/composer.lock b/composer.lock index a2e54ba4..6f8a74f3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0d8902092178991e4a2f0a121a32c1ef", + "content-hash": "f89715e407bde4aecfdff0a0961815de", "packages": [], "packages-dev": [ { @@ -501,6 +501,49 @@ }, "time": "2019-12-04T15:06:13+00:00" }, + { + "name": "doctrine/deprecations", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/deprecations.git", + "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", + "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9", + "phpunit/phpunit": "^7.5|^8.5|^9.5", + "psr/log": "^1|^2|^3" + }, + "suggest": { + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", + "support": { + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/v1.0.0" + }, + "time": "2022-05-02T15:47:09+00:00" + }, { "name": "doctrine/instantiator", "version": "2.0.0", @@ -674,16 +717,16 @@ }, { "name": "laravel/pint", - "version": "v1.6.0", + "version": "v1.8.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "e48e3fadd7863d6b7d03464f5c4f211a828b890f" + "reference": "4b8f2ef22bfcddd1d163cfd282e3f42ee1a5cce2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/e48e3fadd7863d6b7d03464f5c4f211a828b890f", - "reference": "e48e3fadd7863d6b7d03464f5c4f211a828b890f", + "url": "https://api.github.com/repos/laravel/pint/zipball/4b8f2ef22bfcddd1d163cfd282e3f42ee1a5cce2", + "reference": "4b8f2ef22bfcddd1d163cfd282e3f42ee1a5cce2", "shasum": "" }, "require": { @@ -694,13 +737,13 @@ "php": "^8.1.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.14.4", - "illuminate/view": "^10.0.0", - "laravel-zero/framework": "^10.0.0", + "friendsofphp/php-cs-fixer": "^3.16.0", + "illuminate/view": "^10.5.1", + "laravel-zero/framework": "^10.0.2", "mockery/mockery": "^1.5.1", - "nunomaduro/larastan": "^2.4.0", + "nunomaduro/larastan": "^2.5.1", "nunomaduro/termwind": "^1.15.1", - "pestphp/pest": "^1.22.4" + "pestphp/pest": "^2.4.0" }, "bin": [ "builds/pint" @@ -736,20 +779,20 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2023-02-21T15:44:57+00:00" + "time": "2023-04-04T13:08:09+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.11.0", + "version": "1.11.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", "shasum": "" }, "require": { @@ -787,7 +830,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" }, "funding": [ { @@ -795,7 +838,7 @@ "type": "tidelift" } ], - "time": "2022-03-03T13:19:32+00:00" + "time": "2023-03-08T13:26:56+00:00" }, { "name": "netresearch/jsonmapper", @@ -850,16 +893,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.15.3", + "version": "v4.15.4", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "570e980a201d8ed0236b0a62ddf2c9cbb2034039" + "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/570e980a201d8ed0236b0a62ddf2c9cbb2034039", - "reference": "570e980a201d8ed0236b0a62ddf2c9cbb2034039", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6bb5176bc4af8bcb7d926f88718db9b96a2d4290", + "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290", "shasum": "" }, "require": { @@ -900,9 +943,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.3" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.4" }, - "time": "2023-01-16T22:05:37+00:00" + "time": "2023-03-05T19:49:14+00:00" }, { "name": "openlss/lib-array2xml", @@ -1180,24 +1223,27 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.6.2", + "version": "1.7.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d" + "reference": "dfc078e8af9c99210337325ff5aa152872c98714" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/48f445a408c131e38cab1c235aa6d2bb7a0bb20d", - "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/dfc078e8af9c99210337325ff5aa152872c98714", + "reference": "dfc078e8af9c99210337325ff5aa152872c98714", "shasum": "" }, "require": { + "doctrine/deprecations": "^1.0", "php": "^7.4 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" + "phpdocumentor/reflection-common": "^2.0", + "phpstan/phpdoc-parser": "^1.13" }, "require-dev": { "ext-tokenizer": "*", + "phpbench/phpbench": "^1.2", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.8", "phpstan/phpstan-phpunit": "^1.1", @@ -1229,22 +1275,126 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.2" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.1" + }, + "time": "2023-03-27T19:02:04+00:00" + }, + { + "name": "phpstan/phpdoc-parser", + "version": "1.18.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "882eabc9b6a12e25c27091a261397f9c8792e722" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/882eabc9b6a12e25c27091a261397f9c8792e722", + "reference": "882eabc9b6a12e25c27091a261397f9c8792e722", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^1.5", + "phpstan/phpstan-phpunit": "^1.1", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.5", + "symfony/process": "^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } }, - "time": "2022-10-14T12:47:21+00:00" + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.18.0" + }, + "time": "2023-04-06T07:26:43+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "1.9.x-dev", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "6c0217aa2b146c3e28474e8be3e87188fac55dac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6c0217aa2b146c3e28474e8be3e87188fac55dac", + "reference": "6c0217aa2b146c3e28474e8be3e87188fac55dac", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.9.x" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2023-02-18T15:01:46+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.25", + "version": "9.2.26", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "0e2b40518197a8c0d4b08bc34dfff1c99c508954" + "reference": "443bc6912c9bd5b409254a40f4b0f4ced7c80ea1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/0e2b40518197a8c0d4b08bc34dfff1c99c508954", - "reference": "0e2b40518197a8c0d4b08bc34dfff1c99c508954", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/443bc6912c9bd5b409254a40f4b0f4ced7c80ea1", + "reference": "443bc6912c9bd5b409254a40f4b0f4ced7c80ea1", "shasum": "" }, "require": { @@ -1266,8 +1416,8 @@ "phpunit/phpunit": "^9.3" }, "suggest": { - "ext-pcov": "*", - "ext-xdebug": "*" + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "type": "library", "extra": { @@ -1300,7 +1450,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.25" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.26" }, "funding": [ { @@ -1308,7 +1458,7 @@ "type": "github" } ], - "time": "2023-02-25T05:32:00+00:00" + "time": "2023-03-06T12:58:08+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1553,16 +1703,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.4", + "version": "9.6.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "9125ee085b6d95e78277dc07aa1f46f9e0607b8d" + "reference": "b65d59a059d3004a040c16a82e07bbdf6cfdd115" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9125ee085b6d95e78277dc07aa1f46f9e0607b8d", - "reference": "9125ee085b6d95e78277dc07aa1f46f9e0607b8d", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b65d59a059d3004a040c16a82e07bbdf6cfdd115", + "reference": "b65d59a059d3004a040c16a82e07bbdf6cfdd115", "shasum": "" }, "require": { @@ -1595,8 +1745,8 @@ "sebastian/version": "^3.0.2" }, "suggest": { - "ext-soap": "*", - "ext-xdebug": "*" + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "bin": [ "phpunit" @@ -1635,7 +1785,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.4" + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.6" }, "funding": [ { @@ -1651,7 +1802,7 @@ "type": "tidelift" } ], - "time": "2023-02-27T13:06:37+00:00" + "time": "2023-03-27T11:43:46+00:00" }, { "name": "psr/container", @@ -2722,16 +2873,16 @@ }, { "name": "symfony/console", - "version": "v6.2.5", + "version": "v6.2.8", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "3e294254f2191762c1d137aed4b94e966965e985" + "reference": "3582d68a64a86ec25240aaa521ec8bc2342b369b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/3e294254f2191762c1d137aed4b94e966965e985", - "reference": "3e294254f2191762c1d137aed4b94e966965e985", + "url": "https://api.github.com/repos/symfony/console/zipball/3582d68a64a86ec25240aaa521ec8bc2342b369b", + "reference": "3582d68a64a86ec25240aaa521ec8bc2342b369b", "shasum": "" }, "require": { @@ -2793,12 +2944,12 @@ "homepage": "https://symfony.com", "keywords": [ "cli", - "command line", + "command-line", "console", "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.2.5" + "source": "https://github.com/symfony/console/tree/v6.2.8" }, "funding": [ { @@ -2814,20 +2965,20 @@ "type": "tidelift" } ], - "time": "2023-01-01T08:38:09+00:00" + "time": "2023-03-29T21:42:15+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v3.2.0", + "version": "v3.2.1", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3" + "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/1ee04c65529dea5d8744774d474e7cbd2f1206d3", - "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", + "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", "shasum": "" }, "require": { @@ -2865,7 +3016,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.1" }, "funding": [ { @@ -2881,7 +3032,7 @@ "type": "tidelift" } ], - "time": "2022-11-25T10:21:52+00:00" + "time": "2023-03-01T10:25:55+00:00" }, { "name": "symfony/polyfill-ctype", @@ -3298,16 +3449,16 @@ }, { "name": "symfony/service-contracts", - "version": "v3.2.0", + "version": "v3.2.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75" + "reference": "a8c9cedf55f314f3a186041d19537303766df09a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/aac98028c69df04ee77eb69b96b86ee51fbf4b75", - "reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/a8c9cedf55f314f3a186041d19537303766df09a", + "reference": "a8c9cedf55f314f3a186041d19537303766df09a", "shasum": "" }, "require": { @@ -3363,7 +3514,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.2.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.2.1" }, "funding": [ { @@ -3379,20 +3530,20 @@ "type": "tidelift" } ], - "time": "2022-11-25T10:21:52+00:00" + "time": "2023-03-01T10:32:47+00:00" }, { "name": "symfony/string", - "version": "v6.2.5", + "version": "v6.2.8", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0" + "reference": "193e83bbd6617d6b2151c37fff10fa7168ebddef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0", - "reference": "b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0", + "url": "https://api.github.com/repos/symfony/string/zipball/193e83bbd6617d6b2151c37fff10fa7168ebddef", + "reference": "193e83bbd6617d6b2151c37fff10fa7168ebddef", "shasum": "" }, "require": { @@ -3449,7 +3600,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.2.5" + "source": "https://github.com/symfony/string/tree/v6.2.8" }, "funding": [ { @@ -3465,7 +3616,7 @@ "type": "tidelift" } ], - "time": "2023-01-01T08:38:09+00:00" + "time": "2023-03-20T16:06:02+00:00" }, { "name": "theseer/tokenizer", @@ -3736,11 +3887,13 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "phpstan/phpstan": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=8.0.0" + "php": ">=8.0" }, "platform-dev": [], "plugin-api-version": "2.3.0" diff --git a/src/App.php b/src/App.php index 244a0f47..ea5840df 100755 --- a/src/App.php +++ b/src/App.php @@ -711,7 +711,6 @@ public function run(Request $request, Response $response): static if (! self::$sorted) { foreach (self::$routes as $method => $list) { //adding route alias in $routes foreach ($list as $key => $route) { - /** @var Route $route */ foreach (array_keys($route->getAliases()) as $path) { self::$routes[$method][$path] = $route; } @@ -803,7 +802,6 @@ public function run(Request $request, Response $response): static * @param string $key * @param array $param * @param mixed $value - * @param array $resources * @return void * * @throws Exception diff --git a/src/Response.php b/src/Response.php index a3df3ffc..826a2b07 100755 --- a/src/Response.php +++ b/src/Response.php @@ -525,7 +525,8 @@ protected function end(string $content = null): void * Generate HTTP response output including the response header (+cookies) and body and prints them. * * @param string $body - * @param bool $last + * @param bool $end + * * @return void */ public function chunk(string $body = '', bool $end = false): void @@ -658,7 +659,6 @@ protected function appendCookies(): static * * @param string $url complete absolute URI for redirection as required by the internet standard RFC 2616 (HTTP 1.1) * @param int $statusCode valid HTTP status code - * @param null $exit * @return void * * @throws Exception diff --git a/src/Validator/IP.php b/src/Validator/IP.php index f7a66266..3a69dc13 100644 --- a/src/Validator/IP.php +++ b/src/Validator/IP.php @@ -82,7 +82,6 @@ public function isValid($value): bool default: return false; - break; } return false; diff --git a/src/Validator/Range.php b/src/Validator/Range.php index 8142f9a1..d0e7f20f 100755 --- a/src/Validator/Range.php +++ b/src/Validator/Range.php @@ -131,10 +131,10 @@ public function isValid(mixed $value): bool } break; case self::TYPE_FLOAT: - $value = $value + 0; - if (! is_float($value) && ! is_int($value)) { + if (! is_numeric($value) ) { return false; } + $value = $value + 0.0; break; default: return false; diff --git a/tests/AppTest.php b/tests/AppTest.php index 79bc9b91..98ba0b02 100755 --- a/tests/AppTest.php +++ b/tests/AppTest.php @@ -416,6 +416,8 @@ public function providerRouteMatching(): array */ public function testCanMatchRoute(string $method, string $path): void { + $expected = ''; + switch ($method) { case App::REQUEST_METHOD_GET: $expected = App::get($path); diff --git a/tests/Validator/ArrayListTest.php b/tests/Validator/ArrayListTest.php index d8bb23b5..ceab7932 100755 --- a/tests/Validator/ArrayListTest.php +++ b/tests/Validator/ArrayListTest.php @@ -9,7 +9,7 @@ class ArrayListTest extends TestCase public function testCanValidateTextValues(): void { $arrayList = new ArrayList(new Text(100)); - $this->assertTrue($arrayList->isArray(), true); + $this->assertTrue($arrayList->isArray(), 'true'); $this->assertTrue($arrayList->isValid([0 => 'string', 1 => 'string'])); $this->assertTrue($arrayList->isValid(['string', 'string'])); $this->assertFalse($arrayList->isValid(['string', 'string', 3])); @@ -23,7 +23,7 @@ public function testCanValidateNumericValues(): void { $arrayList = new ArrayList(new Numeric()); $this->assertTrue($arrayList->isValid([1, 2, 3])); - $this->assertFalse($arrayList->isValid(1, '2', 3)); + $this->assertFalse($arrayList->isValid(1)); $this->assertFalse($arrayList->isValid('string')); $this->assertEquals(\Utopia\Validator::TYPE_MIXED, $arrayList->getType()); $this->assertInstanceOf(Numeric::class, $arrayList->getValidator()); diff --git a/tests/Validator/DomainTest.php b/tests/Validator/DomainTest.php index 69c6beee..ca14a20e 100644 --- a/tests/Validator/DomainTest.php +++ b/tests/Validator/DomainTest.php @@ -17,21 +17,13 @@ class DomainTest extends TestCase { - /** - * @var Domain - */ - protected $domain = null; + protected Domain $domain; public function setUp(): void { $this->domain = new Domain(); } - public function tearDown(): void - { - $this->domain = null; - } - public function testIsValid() { // Assertions diff --git a/tests/Validator/HostTest.php b/tests/Validator/HostTest.php index f8f192d1..e9efd5ce 100644 --- a/tests/Validator/HostTest.php +++ b/tests/Validator/HostTest.php @@ -17,21 +17,13 @@ class HostTest extends TestCase { - /** - * @var Host - */ - protected $host = null; + protected Host $host; public function setUp():void { $this->host = new Host(['example.io', 'subdomain.example.test', 'localhost']); } - public function tearDown():void - { - $this->host = null; - } - public function testIsValid() { // Assertions diff --git a/tests/Validator/IPTest.php b/tests/Validator/IPTest.php index 1be8f78a..124be488 100644 --- a/tests/Validator/IPTest.php +++ b/tests/Validator/IPTest.php @@ -17,10 +17,7 @@ class IPTest extends TestCase { - public function tearDown():void - { - $this->validator = null; - } + protected IP $validator; public function testIsValidIP() { diff --git a/tests/e2e/ResponseTest.php b/tests/e2e/ResponseTest.php index 081b25ef..a2f684da 100644 --- a/tests/e2e/ResponseTest.php +++ b/tests/e2e/ResponseTest.php @@ -7,21 +7,13 @@ class ResponseTest extends TestCase { + protected Client $client; + public function setUp(): void { $this->client = new Client(); } - public function tearDown(): void - { - $this->client = null; - } - - /** - * @var Client - */ - protected $client; - public function testResponse() { $response = $this->client->call(Client::METHOD_GET, '/'); diff --git a/tests/e2e/server.php b/tests/e2e/server.php index 64db8d56..33cb9f00 100644 --- a/tests/e2e/server.php +++ b/tests/e2e/server.php @@ -20,8 +20,7 @@ App::get('/chunked') ->inject('response') - ->action(function ($response) { - /** @var Utopia/Response $response */ + ->action(function (Response $response) { foreach (['Hello ', 'World!'] as $key => $word) { $response->chunk($word, $key == 1); } @@ -29,8 +28,7 @@ App::get('/redirect') ->inject('response') - ->action(function ($response) { - /** @var Utopia/Response $response */ + ->action(function (Response $response) { $response->redirect('/'); });