diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bc87aa6273b..28d450cc51e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ on: env: # All versions should be declared here - PHALCON_VERSION: 5.0.0beta1 + PHALCON_VERSION: 5.0.0beta2 ZEPHIR_PARSER_VERSION: 1.4.2 ZEPHIR_VERSION: 0.15.0 PSR_VERSION: 1.1.0 diff --git a/BACKERS.md b/BACKERS.md index e8348242117..7fd571dfe2b 100644 --- a/BACKERS.md +++ b/BACKERS.md @@ -114,7 +114,6 @@ Thanks for the support - diff --git a/CHANGELOG-5.0.md b/CHANGELOG-5.0.md index 048a68956fb..da479408472 100644 --- a/CHANGELOG-5.0.md +++ b/CHANGELOG-5.0.md @@ -1,3 +1,15 @@ +# [5.0.0beta2](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0beta1) (xxxx-xx-xx) + +## Fixed +- `Phalcon\Mvc\View\Engine\Volt\Compiler::functionCall()` to check for container presence before checking the `tag` service [#15842](https://github.com/phalcon/cphalcon/issues/15842) +- `Phalcon\Di\FactoryDefault()` to set `assets` and `tag` as shared services [#15847](https://github.com/phalcon/cphalcon/issues/15847) +- `Phalcon\Forms\Element\AbstractElement::getLocalTagFactory()` to return the tagFactory from itself, the form, the DI or a new instance [#15847](https://github.com/phalcon/cphalcon/issues/15847) +- Changed references to `sha1` with `hash("sha256", $data)` to ensure that there are no collisions from the hashing algorithm [#15844](https://github.com/phalcon/cphalcon/issues/15844) +- Changed `Phalcon\Support\Helper\Str\Camelize` to accept a third boolean parameter indicating whether the result will have the first letter capitalized or not [#15850](https://github.com/phalcon/cphalcon/issues/15850) + +## Added +- Added `Phalcon\Support\Helper\Str\KebabCase`, `Phalcon\Support\Helper\Str\PascalCase` and `Phalcon\Support\Helper\Str\SnakeCase` helpers [#15850](https://github.com/phalcon/cphalcon/issues/15850) + # [5.0.0beta1](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0beta1) (2021-12-24) ## Changed diff --git a/composer.json b/composer.json index 70fb414dae2..5b6ffc84f3c 100644 --- a/composer.json +++ b/composer.json @@ -59,7 +59,7 @@ "codeception/module-filesystem": "^1.0.0", "codeception/module-phalcon5": "^1.0.0", "codeception/module-redis": "^1.0.0", - "friendsofphp/php-cs-fixer": "~2.0", + "friendsofphp/php-cs-fixer": "~3.0", "mustache/mustache": "^2.12", "phalcon/ide-stubs": "^4.1", "phpunit/phpunit": "^8.5", diff --git a/composer.lock b/composer.lock index 9b6b9f8841c..61f793e12e6 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": "3f52bb040eef106d12d167c91802fe8b", + "content-hash": "7ca430ec5b6c9c0043cf56f68ec1872e", "packages": [], "packages-dev": [ { @@ -238,23 +238,23 @@ }, { "name": "codeception/codeception", - "version": "4.1.24", + "version": "4.1.27", "source": { "type": "git", "url": "https://github.com/Codeception/Codeception.git", - "reference": "1fc3a8f4d6cf7350e1b69afd136708cfffc89e9e" + "reference": "2d9a11e6f487e3bcc17e22b7552fb6a10cec5c7c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Codeception/zipball/1fc3a8f4d6cf7350e1b69afd136708cfffc89e9e", - "reference": "1fc3a8f4d6cf7350e1b69afd136708cfffc89e9e", + "url": "https://api.github.com/repos/Codeception/Codeception/zipball/2d9a11e6f487e3bcc17e22b7552fb6a10cec5c7c", + "reference": "2d9a11e6f487e3bcc17e22b7552fb6a10cec5c7c", "shasum": "" }, "require": { "behat/gherkin": "^4.4.0", - "codeception/lib-asserts": "^1.0", + "codeception/lib-asserts": "^1.0 | 2.0.*@dev", "codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.1.1 | ^9.0", - "codeception/stub": "^2.0 | ^3.0", + "codeception/stub": "^2.0 | ^3.0 | ^4.0", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", @@ -267,11 +267,11 @@ "symfony/yaml": ">=2.7 <6.0" }, "require-dev": { - "codeception/module-asserts": "1.*@dev", - "codeception/module-cli": "1.*@dev", - "codeception/module-db": "1.*@dev", - "codeception/module-filesystem": "1.*@dev", - "codeception/module-phpbrowser": "1.*@dev", + "codeception/module-asserts": "^1.0 | 2.0.*@dev", + "codeception/module-cli": "^1.0 | 2.0.*@dev", + "codeception/module-db": "^1.0 | 2.0.*@dev", + "codeception/module-filesystem": "^1.0 | 2.0.*@dev", + "codeception/module-phpbrowser": "^1.0 | 2.0.*@dev", "codeception/specify": "~0.3", "codeception/util-universalframework": "*@dev", "monolog/monolog": "~1.8", @@ -324,7 +324,7 @@ ], "support": { "issues": "https://github.com/Codeception/Codeception/issues", - "source": "https://github.com/Codeception/Codeception/tree/4.1.24" + "source": "https://github.com/Codeception/Codeception/tree/4.1.27" }, "funding": [ { @@ -332,7 +332,7 @@ "type": "open_collective" } ], - "time": "2021-12-16T12:57:06+00:00" + "time": "2021-12-22T06:40:46+00:00" }, { "name": "codeception/lib-asserts", @@ -930,21 +930,25 @@ }, { "name": "codeception/stub", - "version": "3.7.0", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/Codeception/Stub.git", - "reference": "468dd5fe659f131fc997f5196aad87512f9b1304" + "reference": "4c9cf3e19bd5f064e08e7f3ba6be651c218dc6ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Stub/zipball/468dd5fe659f131fc997f5196aad87512f9b1304", - "reference": "468dd5fe659f131fc997f5196aad87512f9b1304", + "url": "https://api.github.com/repos/Codeception/Stub/zipball/4c9cf3e19bd5f064e08e7f3ba6be651c218dc6ae", + "reference": "4c9cf3e19bd5f064e08e7f3ba6be651c218dc6ae", "shasum": "" }, "require": { + "php": "^7.4 | ^8.0", "phpunit/phpunit": "^8.4 | ^9.0" }, + "require-dev": { + "consolidation/robo": "^3.0" + }, "type": "library", "autoload": { "psr-4": { @@ -958,9 +962,9 @@ "description": "Flexible Stub wrapper for PHPUnit's Mock Builder", "support": { "issues": "https://github.com/Codeception/Stub/issues", - "source": "https://github.com/Codeception/Stub/tree/3.7.0" + "source": "https://github.com/Codeception/Stub/tree/4.0.0" }, - "time": "2020-07-03T15:54:43+00:00" + "time": "2021-12-07T14:39:17+00:00" }, { "name": "composer/package-versions-deprecated", @@ -1614,85 +1618,65 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v2.19.3", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "75ac86f33fab4714ea5a39a396784d83ae3b5ed8" + "reference": "47177af1cfb9dab5d1cc4daf91b7179c2efe7fad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/75ac86f33fab4714ea5a39a396784d83ae3b5ed8", - "reference": "75ac86f33fab4714ea5a39a396784d83ae3b5ed8", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/47177af1cfb9dab5d1cc4daf91b7179c2efe7fad", + "reference": "47177af1cfb9dab5d1cc4daf91b7179c2efe7fad", "shasum": "" }, "require": { - "composer/semver": "^1.4 || ^2.0 || ^3.0", - "composer/xdebug-handler": "^1.2 || ^2.0", - "doctrine/annotations": "^1.2", + "composer/semver": "^3.2", + "composer/xdebug-handler": "^2.0", + "doctrine/annotations": "^1.12", "ext-json": "*", "ext-tokenizer": "*", - "php": "^5.6 || ^7.0 || ^8.0", - "php-cs-fixer/diff": "^1.3", - "symfony/console": "^3.4.43 || ^4.1.6 || ^5.0", - "symfony/event-dispatcher": "^3.0 || ^4.0 || ^5.0", - "symfony/filesystem": "^3.0 || ^4.0 || ^5.0", - "symfony/finder": "^3.0 || ^4.0 || ^5.0", - "symfony/options-resolver": "^3.0 || ^4.0 || ^5.0", - "symfony/polyfill-php70": "^1.0", - "symfony/polyfill-php72": "^1.4", - "symfony/process": "^3.0 || ^4.0 || ^5.0", - "symfony/stopwatch": "^3.0 || ^4.0 || ^5.0" + "php": "^7.2.5 || ^8.0", + "php-cs-fixer/diff": "^2.0", + "symfony/console": "^4.4.20 || ^5.1.3 || ^6.0", + "symfony/event-dispatcher": "^4.4.20 || ^5.0 || ^6.0", + "symfony/filesystem": "^4.4.20 || ^5.0 || ^6.0", + "symfony/finder": "^4.4.20 || ^5.0 || ^6.0", + "symfony/options-resolver": "^4.4.20 || ^5.0 || ^6.0", + "symfony/polyfill-mbstring": "^1.23", + "symfony/polyfill-php80": "^1.23", + "symfony/polyfill-php81": "^1.23", + "symfony/process": "^4.4.20 || ^5.0 || ^6.0", + "symfony/stopwatch": "^4.4.20 || ^5.0 || ^6.0" }, "require-dev": { - "justinrainbow/json-schema": "^5.0", - "keradus/cli-executor": "^1.4", - "mikey179/vfsstream": "^1.6", - "php-coveralls/php-coveralls": "^2.4.2", - "php-cs-fixer/accessible-object": "^1.0", + "justinrainbow/json-schema": "^5.2", + "keradus/cli-executor": "^1.5", + "mikey179/vfsstream": "^1.6.8", + "php-coveralls/php-coveralls": "^2.5.2", + "php-cs-fixer/accessible-object": "^1.1", "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1", + "phpspec/prophecy": "^1.15", "phpspec/prophecy-phpunit": "^1.1 || ^2.0", - "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.13 || ^9.5", + "phpunit/phpunit": "^8.5.21 || ^9.5", "phpunitgoodpractices/polyfill": "^1.5", "phpunitgoodpractices/traits": "^1.9.1", - "sanmai/phpunit-legacy-adapter": "^6.4 || ^8.2.1", - "symfony/phpunit-bridge": "^5.2.1", - "symfony/yaml": "^3.0 || ^4.0 || ^5.0" + "symfony/phpunit-bridge": "^5.2.4 || ^6.0", + "symfony/yaml": "^4.4.20 || ^5.0 || ^6.0" }, "suggest": { "ext-dom": "For handling output formats in XML", - "ext-mbstring": "For handling non-UTF8 characters.", - "php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.", - "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.", - "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible." + "ext-mbstring": "For handling non-UTF8 characters." }, "bin": [ "php-cs-fixer" ], "type": "application", - "extra": { - "branch-alias": { - "dev-master": "2.19-dev" - } - }, "autoload": { "psr-4": { "PhpCsFixer\\": "src/" - }, - "classmap": [ - "tests/Test/AbstractFixerTestCase.php", - "tests/Test/AbstractIntegrationCaseFactory.php", - "tests/Test/AbstractIntegrationTestCase.php", - "tests/Test/Assert/AssertTokensTrait.php", - "tests/Test/IntegrationCase.php", - "tests/Test/IntegrationCaseFactory.php", - "tests/Test/IntegrationCaseFactoryInterface.php", - "tests/Test/InternalIntegrationCaseFactory.php", - "tests/Test/IsIdenticalConstraint.php", - "tests/Test/TokensWithObservedTransformers.php", - "tests/TestCase.php" - ] + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1711,7 +1695,7 @@ "description": "A tool to automatically fix PHP code style", "support": { "issues": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues", - "source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v2.19.3" + "source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v3.4.0" }, "funding": [ { @@ -1719,7 +1703,7 @@ "type": "github" } ], - "time": "2021-11-15T17:17:55+00:00" + "time": "2021-12-11T16:25:08+00:00" }, { "name": "guzzlehttp/guzzle", @@ -2492,16 +2476,16 @@ }, { "name": "php-cs-fixer/diff", - "version": "v1.3.1", + "version": "v2.0.2", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/diff.git", - "reference": "dbd31aeb251639ac0b9e7e29405c1441907f5759" + "reference": "29dc0d507e838c4580d018bd8b5cb412474f7ec3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/dbd31aeb251639ac0b9e7e29405c1441907f5759", - "reference": "dbd31aeb251639ac0b9e7e29405c1441907f5759", + "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/29dc0d507e838c4580d018bd8b5cb412474f7ec3", + "reference": "29dc0d507e838c4580d018bd8b5cb412474f7ec3", "shasum": "" }, "require": { @@ -2529,21 +2513,18 @@ { "name": "Kore Nordmann", "email": "mail@kore-nordmann.de" - }, - { - "name": "SpacePossum" } ], - "description": "sebastian/diff v2 backport support for PHP5.6", + "description": "sebastian/diff v3 backport support for PHP 5.6+", "homepage": "https://github.com/PHP-CS-Fixer", "keywords": [ "diff" ], "support": { "issues": "https://github.com/PHP-CS-Fixer/diff/issues", - "source": "https://github.com/PHP-CS-Fixer/diff/tree/v1.3.1" + "source": "https://github.com/PHP-CS-Fixer/diff/tree/v2.0.2" }, - "time": "2020-10-14T08:39:05+00:00" + "time": "2020-10-14T08:32:19+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -3071,16 +3052,16 @@ }, { "name": "phpunit/phpunit", - "version": "8.5.21", + "version": "8.5.22", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "50a58a60b85947b0bee4c8ecfe0f4bbdcf20e984" + "reference": "ddd05b9d844260353895a3b950a9258126c11503" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/50a58a60b85947b0bee4c8ecfe0f4bbdcf20e984", - "reference": "50a58a60b85947b0bee4c8ecfe0f4bbdcf20e984", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ddd05b9d844260353895a3b950a9258126c11503", + "reference": "ddd05b9d844260353895a3b950a9258126c11503", "shasum": "" }, "require": { @@ -3152,11 +3133,11 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.21" + "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.22" }, "funding": [ { - "url": "https://phpunit.de/donate.html", + "url": "https://phpunit.de/sponsors.html", "type": "custom" }, { @@ -3164,7 +3145,7 @@ "type": "github" } ], - "time": "2021-09-25T07:37:20+00:00" + "time": "2021-12-25T06:58:09+00:00" }, { "name": "predis/predis", @@ -4420,16 +4401,16 @@ }, { "name": "symfony/browser-kit", - "version": "v5.4.0", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "d250db364a35ba5d60626b2a6f10f2eaf2073bde" + "reference": "1fb93b0aab42392aa0a742db205173b49afaf80f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/d250db364a35ba5d60626b2a6f10f2eaf2073bde", - "reference": "d250db364a35ba5d60626b2a6f10f2eaf2073bde", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/1fb93b0aab42392aa0a742db205173b49afaf80f", + "reference": "1fb93b0aab42392aa0a742db205173b49afaf80f", "shasum": "" }, "require": { @@ -4472,7 +4453,7 @@ "description": "Simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/browser-kit/tree/v5.4.0" + "source": "https://github.com/symfony/browser-kit/tree/v5.4.2" }, "funding": [ { @@ -4488,20 +4469,20 @@ "type": "tidelift" } ], - "time": "2021-10-26T22:29:18+00:00" + "time": "2021-12-16T21:58:21+00:00" }, { "name": "symfony/console", - "version": "v5.4.1", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "9130e1a0fc93cb0faadca4ee917171bd2ca9e5f4" + "reference": "a2c6b7ced2eb7799a35375fb9022519282b5405e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/9130e1a0fc93cb0faadca4ee917171bd2ca9e5f4", - "reference": "9130e1a0fc93cb0faadca4ee917171bd2ca9e5f4", + "url": "https://api.github.com/repos/symfony/console/zipball/a2c6b7ced2eb7799a35375fb9022519282b5405e", + "reference": "a2c6b7ced2eb7799a35375fb9022519282b5405e", "shasum": "" }, "require": { @@ -4571,7 +4552,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.1" + "source": "https://github.com/symfony/console/tree/v5.4.2" }, "funding": [ { @@ -4587,20 +4568,20 @@ "type": "tidelift" } ], - "time": "2021-12-09T11:22:43+00:00" + "time": "2021-12-20T16:11:12+00:00" }, { "name": "symfony/css-selector", - "version": "v5.4.0", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "44b933f98bb4b5220d10bed9ce5662f8c2d13dcc" + "reference": "cfcbee910e159df402603502fe387e8b677c22fd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/44b933f98bb4b5220d10bed9ce5662f8c2d13dcc", - "reference": "44b933f98bb4b5220d10bed9ce5662f8c2d13dcc", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/cfcbee910e159df402603502fe387e8b677c22fd", + "reference": "cfcbee910e159df402603502fe387e8b677c22fd", "shasum": "" }, "require": { @@ -4637,7 +4618,7 @@ "description": "Converts CSS selectors to XPath expressions", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/css-selector/tree/v5.4.0" + "source": "https://github.com/symfony/css-selector/tree/v5.4.2" }, "funding": [ { @@ -4653,7 +4634,7 @@ "type": "tidelift" } ], - "time": "2021-09-09T08:06:01+00:00" + "time": "2021-12-16T21:58:21+00:00" }, { "name": "symfony/deprecation-contracts", @@ -4724,16 +4705,16 @@ }, { "name": "symfony/dom-crawler", - "version": "v5.4.0", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "5b06626e940a3ad54e573511d64d4e00dc8d0fd8" + "reference": "bb3bc3699779fc6d9646270789026a7e2cec7ec7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/5b06626e940a3ad54e573511d64d4e00dc8d0fd8", - "reference": "5b06626e940a3ad54e573511d64d4e00dc8d0fd8", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/bb3bc3699779fc6d9646270789026a7e2cec7ec7", + "reference": "bb3bc3699779fc6d9646270789026a7e2cec7ec7", "shasum": "" }, "require": { @@ -4779,7 +4760,7 @@ "description": "Eases DOM navigation for HTML and XML documents", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dom-crawler/tree/v5.4.0" + "source": "https://github.com/symfony/dom-crawler/tree/v5.4.2" }, "funding": [ { @@ -4795,7 +4776,7 @@ "type": "tidelift" } ], - "time": "2021-11-23T10:19:22+00:00" + "time": "2021-12-28T17:15:56+00:00" }, { "name": "symfony/event-dispatcher", @@ -5027,16 +5008,16 @@ }, { "name": "symfony/finder", - "version": "v5.4.0", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "d2f29dac98e96a98be467627bd49c2efb1bc2590" + "reference": "e77046c252be48c48a40816187ed527703c8f76c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/d2f29dac98e96a98be467627bd49c2efb1bc2590", - "reference": "d2f29dac98e96a98be467627bd49c2efb1bc2590", + "url": "https://api.github.com/repos/symfony/finder/zipball/e77046c252be48c48a40816187ed527703c8f76c", + "reference": "e77046c252be48c48a40816187ed527703c8f76c", "shasum": "" }, "require": { @@ -5070,7 +5051,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v5.4.0" + "source": "https://github.com/symfony/finder/tree/v5.4.2" }, "funding": [ { @@ -5086,7 +5067,7 @@ "type": "tidelift" } ], - "time": "2021-11-28T15:25:38+00:00" + "time": "2021-12-15T11:06:13+00:00" }, { "name": "symfony/options-resolver", @@ -5482,85 +5463,17 @@ "time": "2021-05-27T12:26:48+00:00" }, { - "name": "symfony/polyfill-php70", - "version": "v1.20.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "5f03a781d984aae42cebd18e7912fa80f02ee644" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/5f03a781d984aae42cebd18e7912fa80f02ee644", - "reference": "5f03a781d984aae42cebd18e7912fa80f02ee644", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "metapackage", - "extra": { - "branch-alias": { - "dev-main": "1.20-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php70/tree/v1.20.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-23T14:02:19+00:00" - }, - { - "name": "symfony/polyfill-php72", + "name": "symfony/polyfill-php73", "version": "v1.23.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "9a142215a36a3888e30d0a9eeea9766764e96976" + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/9a142215a36a3888e30d0a9eeea9766764e96976", - "reference": "9a142215a36a3888e30d0a9eeea9766764e96976", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fba8933c384d6476ab14fb7b8526e5287ca7e010", + "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010", "shasum": "" }, "require": { @@ -5578,10 +5491,13 @@ }, "autoload": { "psr-4": { - "Symfony\\Polyfill\\Php72\\": "" + "Symfony\\Polyfill\\Php73\\": "" }, "files": [ "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" ] }, "notification-url": "https://packagist.org/downloads/", @@ -5598,7 +5514,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", @@ -5607,7 +5523,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.23.0" }, "funding": [ { @@ -5623,20 +5539,20 @@ "type": "tidelift" } ], - "time": "2021-05-27T09:17:38+00:00" + "time": "2021-02-19T12:13:01+00:00" }, { - "name": "symfony/polyfill-php73", - "version": "v1.23.0", + "name": "symfony/polyfill-php80", + "version": "v1.23.1", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010" + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fba8933c384d6476ab14fb7b8526e5287ca7e010", - "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", "shasum": "" }, "require": { @@ -5654,7 +5570,7 @@ }, "autoload": { "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" + "Symfony\\Polyfill\\Php80\\": "" }, "files": [ "bootstrap.php" @@ -5668,6 +5584,10 @@ "MIT" ], "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, { "name": "Nicolas Grekas", "email": "p@tchwork.com" @@ -5677,7 +5597,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", @@ -5686,7 +5606,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" }, "funding": [ { @@ -5702,20 +5622,20 @@ "type": "tidelift" } ], - "time": "2021-02-19T12:13:01+00:00" + "time": "2021-07-28T13:41:28+00:00" }, { - "name": "symfony/polyfill-php80", - "version": "v1.23.1", + "name": "symfony/polyfill-php81", + "version": "v1.23.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "e66119f3de95efc359483f810c4c3e6436279436" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", - "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/e66119f3de95efc359483f810c4c3e6436279436", + "reference": "e66119f3de95efc359483f810c4c3e6436279436", "shasum": "" }, "require": { @@ -5733,7 +5653,7 @@ }, "autoload": { "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" + "Symfony\\Polyfill\\Php81\\": "" }, "files": [ "bootstrap.php" @@ -5747,10 +5667,6 @@ "MIT" ], "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, { "name": "Nicolas Grekas", "email": "p@tchwork.com" @@ -5760,7 +5676,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", @@ -5769,7 +5685,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.23.0" }, "funding": [ { @@ -5785,20 +5701,20 @@ "type": "tidelift" } ], - "time": "2021-07-28T13:41:28+00:00" + "time": "2021-05-21T13:25:03+00:00" }, { "name": "symfony/process", - "version": "v5.4.0", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "5be20b3830f726e019162b26223110c8f47cf274" + "reference": "2b3ba8722c4aaf3e88011be5e7f48710088fb5e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/5be20b3830f726e019162b26223110c8f47cf274", - "reference": "5be20b3830f726e019162b26223110c8f47cf274", + "url": "https://api.github.com/repos/symfony/process/zipball/2b3ba8722c4aaf3e88011be5e7f48710088fb5e4", + "reference": "2b3ba8722c4aaf3e88011be5e7f48710088fb5e4", "shasum": "" }, "require": { @@ -5831,7 +5747,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.4.0" + "source": "https://github.com/symfony/process/tree/v5.4.2" }, "funding": [ { @@ -5847,7 +5763,7 @@ "type": "tidelift" } ], - "time": "2021-11-28T15:25:38+00:00" + "time": "2021-12-27T21:01:00+00:00" }, { "name": "symfony/service-contracts", @@ -5996,16 +5912,16 @@ }, { "name": "symfony/string", - "version": "v5.4.0", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "9ffaaba53c61ba75a3c7a3a779051d1e9ec4fd2d" + "reference": "e6a5d5ecf6589c5247d18e0e74e30b11dfd51a3d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/9ffaaba53c61ba75a3c7a3a779051d1e9ec4fd2d", - "reference": "9ffaaba53c61ba75a3c7a3a779051d1e9ec4fd2d", + "url": "https://api.github.com/repos/symfony/string/zipball/e6a5d5ecf6589c5247d18e0e74e30b11dfd51a3d", + "reference": "e6a5d5ecf6589c5247d18e0e74e30b11dfd51a3d", "shasum": "" }, "require": { @@ -6062,7 +5978,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.0" + "source": "https://github.com/symfony/string/tree/v5.4.2" }, "funding": [ { @@ -6078,20 +5994,20 @@ "type": "tidelift" } ], - "time": "2021-11-24T10:02:00+00:00" + "time": "2021-12-16T21:52:00+00:00" }, { "name": "symfony/yaml", - "version": "v5.4.0", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "034ccc0994f1ae3f7499fa5b1f2e75d5e7a94efc" + "reference": "b9eb163846a61bb32dfc147f7859e274fab38b58" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/034ccc0994f1ae3f7499fa5b1f2e75d5e7a94efc", - "reference": "034ccc0994f1ae3f7499fa5b1f2e75d5e7a94efc", + "url": "https://api.github.com/repos/symfony/yaml/zipball/b9eb163846a61bb32dfc147f7859e274fab38b58", + "reference": "b9eb163846a61bb32dfc147f7859e274fab38b58", "shasum": "" }, "require": { @@ -6137,7 +6053,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v5.4.0" + "source": "https://github.com/symfony/yaml/tree/v5.4.2" }, "funding": [ { @@ -6153,7 +6069,7 @@ "type": "tidelift" } ], - "time": "2021-11-28T15:25:38+00:00" + "time": "2021-12-16T21:58:21+00:00" }, { "name": "theseer/tokenizer", @@ -6285,16 +6201,16 @@ }, { "name": "vimeo/psalm", - "version": "v4.15.0", + "version": "4.16.1", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "a1b5e489e6fcebe40cb804793d964e99fc347820" + "reference": "aa7e400908833b10c0333861f86cd48c510b60eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/a1b5e489e6fcebe40cb804793d964e99fc347820", - "reference": "a1b5e489e6fcebe40cb804793d964e99fc347820", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/aa7e400908833b10c0333861f86cd48c510b60eb", + "reference": "aa7e400908833b10c0333861f86cd48c510b60eb", "shasum": "" }, "require": { @@ -6385,9 +6301,9 @@ ], "support": { "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/v4.15.0" + "source": "https://github.com/vimeo/psalm/tree/4.16.1" }, - "time": "2021-12-07T11:25:29+00:00" + "time": "2021-12-26T08:17:05+00:00" }, { "name": "vlucas/phpdotenv", diff --git a/config.json b/config.json index 94156f88f00..1b2d377b623 100644 --- a/config.json +++ b/config.json @@ -3,7 +3,7 @@ "name": "phalcon", "description": "Phalcon is a full stack PHP framework, delivered as a PHP extension, offering lower resource consumption and high performance.", "author": "Phalcon Team and contributors", - "version": "5.0.0beta1", + "version": "5.0.0beta2", "verbose": false, "stubs": { "path": "ide\/%version%\/%namespace%\/", diff --git a/package.xml b/package.xml index 84bf6074dd9..dbc9ab15534 100644 --- a/package.xml +++ b/package.xml @@ -25,8 +25,8 @@ 2021-11-16 - 5.0.0beta1 - 5.0.0beta1 + 5.0.0beta2 + 5.0.0beta2 beta @@ -36,54 +36,6 @@ Full changelog can be found at: https://github.com/phalcon/cphalcon/blob/master/CHANGELOG-5.0.md - ## Changed - - Marked as deprecated: - - `Phalcon\Mvc\Model::existsBelongsTo()` - - `Phalcon\Mvc\Model::existsHasMany()` - - `Phalcon\Mvc\Model::existsHasOne()` - - `Phalcon\Mvc\Model::existsHasOneThrough()` - - `Phalcon\Mvc\Model::existsHasManyToMany()` - - `Phalcon\Translate\Adapter\Csv::exists()` - - `Phalcon\Translate\Adapter\Gettext::exists()` - - `Phalcon\Translate\Adapter\NativeArray::exists()` [#15785](https://github.com/phalcon/cphalcon/issues/15785) - - Moved `Phalcon\Container` to `Phalcon\Container\Container` [#15796](https://github.com/phalcon/cphalcon/issues/15796) - - Changed the `Phalcon\Support\Collection::get()` to return the default value if the key does not exist or the value is `null` to mirror the behavior of v3. [#15370](https://github.com/phalcon/cphalcon/issues/15370) - - Moved `Phalcon\Registry` to `Phalcon\Support\Registry` [#15802](https://github.com/phalcon/cphalcon/issues/15802) - - Moved `Phalcon\Url` to `Phalcon\Mvc\Url` [#15798](https://github.com/phalcon/cphalcon/issues/15798) - - Moved `Phalcon\Loader` to `Phalcon\Autoload\Loader` [#15797](https://github.com/phalcon/cphalcon/issues/15797) - - Changes to `Phalcon\Autoload\Loader`: - - Renamed `registerClasses()` to `setClasses()` - - Renamed `registerDirectories()` to `setDirectories()` - - Renamed `registertExtensions()` to `setExtensions()` - - Renamed `registertFiles()` to `setFiles()` - - Renamed `registertNamespaces()` to `setNamespaces()` [#15797](https://github.com/phalcon/cphalcon/issues/15797) - - Moved `Phalcon\Di` to `Phalcon\Di\Di` [#15799](https://github.com/phalcon/cphalcon/issues/15799) - - Removed references to `Phalcon\Tag` from the framework in favor of `Phalcon\Html\TagFactory` [#15801](https://github.com/phalcon/cphalcon/issues/15801) - - `Phalcon\Forms\Form` requires a `Phalcon\Html\TagFactory` to be set before it can render elements [#15801](https://github.com/phalcon/cphalcon/issues/15801) - - `Phalcon\Di\FactoryDefault` will now return a `Phalcon\Html\TagFactory` for the `tag` service [#15801](https://github.com/phalcon/cphalcon/issues/15801) - - ## Fixed - - `Phalcon\Logger\LoggerFactory::load()` to correctly use the key of the adapters array as the name of the adapter [#15831](https://github.com/phalcon/cphalcon/issues/15831) - - ## Added - - Added: - - `Phalcon\Mvc\Model::hasBelongsTo()` - - `Phalcon\Mvc\Model::hasHasMany()` - - `Phalcon\Mvc\Model::hasHasOne()` - - `Phalcon\Mvc\Model::hasHasOneThrough()` - - `Phalcon\Mvc\Model::hasHasManyToMany()` - - `Phalcon\Translate\Adapter\Csv::has()` - - `Phalcon\Translate\Adapter\Gettext::has()` - - `Phalcon\Translate\Adapter\NativeArray::has()` [#15785](https://github.com/phalcon/cphalcon/issues/15785) - - Added `filter`, `camelize`, `dynamic` and `uncamelize` in `Phalcon\Support\HelperFactory` [#15805](https://github.com/phalcon/cphalcon/issues/15805) - - Added `Phalcon\Autoload\Loader::getDebug()` to collect debugging information from the loader (enabled from the constructor) [#15797](https://github.com/phalcon/cphalcon/issues/15797) - - ## Fixed - - Fixed `Phalcon\Dispatcher\Dispatcher::setParams()` not updating local params during `dispatch()` loop [#15603](https://github.com/phalcon/cphalcon/issues/15603) - - Fixed related records auto-save with `belongsTo()` relation [#15148](https://github.com/phalcon/cphalcon/issues/15148) - - ## Removed - - Removed `Phalcon\Exception`; replaced by `\Exception` [#15800](https://github.com/phalcon/cphalcon/issues/15800) diff --git a/phalcon/Assets/Asset.zep b/phalcon/Assets/Asset.zep index 236694c25e9..36fc80f561b 100644 --- a/phalcon/Assets/Asset.zep +++ b/phalcon/Assets/Asset.zep @@ -121,7 +121,7 @@ class Asset implements AssetInterface let key = this->getType() . ":" . this->getPath(); - return sha1(key); + return hash("sha256", key); } /** diff --git a/phalcon/Assets/Inline.zep b/phalcon/Assets/Inline.zep index 2059afe1842..8ca5ed6ad14 100644 --- a/phalcon/Assets/Inline.zep +++ b/phalcon/Assets/Inline.zep @@ -59,7 +59,7 @@ class $Inline implements AssetInterface let key = this->getType() . ":" . this->getContent(); - return sha1(key); + return hash("sha256", key); } /** diff --git a/phalcon/Autoload/Loader.zep b/phalcon/Autoload/Loader.zep index 3af96b5a3fd..0482e0743a4 100644 --- a/phalcon/Autoload/Loader.zep +++ b/phalcon/Autoload/Loader.zep @@ -91,7 +91,7 @@ class Loader extends AbstractEventsAware */ public function __construct(bool isDebug = false) { - let this->extensions[sha1("php")] = "php", + let this->extensions[hash("sha256", "php")] = "php", this->isDebug = isDebug; } @@ -119,7 +119,7 @@ class Loader extends AbstractEventsAware */ public function addDirectory(string directory) -> { - let this->directories[sha1(directory)] = directory; + let this->directories[hash("sha256", directory)] = directory; return this; } @@ -133,7 +133,7 @@ class Loader extends AbstractEventsAware */ public function addExtension(string extension) -> { - let this->extensions[sha1(extension)] = extension; + let this->extensions[hash("sha256", extension)] = extension; return this; } @@ -147,7 +147,7 @@ class Loader extends AbstractEventsAware */ public function addFile(string file) -> { - let this->files[sha1(file)] = file; + let this->files[hash("sha256", file)] = file; return this; } @@ -409,7 +409,7 @@ class Loader extends AbstractEventsAware if (!merge) { let this->extensions = [], - this->extensions[sha1("php")] = "php"; + this->extensions[hash("sha256", "php")] = "php"; } for extension in extensions { @@ -737,7 +737,7 @@ class Loader extends AbstractEventsAware for directory in directories { let directory = rtrim(directory, dirSeparator) . dirSeparator; - let results[sha1(directory)] = directory; + let results[hash("sha256", directory)] = directory; } return results; diff --git a/phalcon/Di/FactoryDefault.zep b/phalcon/Di/FactoryDefault.zep index 7487a8961b3..cb19a0a7de7 100644 --- a/phalcon/Di/FactoryDefault.zep +++ b/phalcon/Di/FactoryDefault.zep @@ -33,6 +33,18 @@ class FactoryDefault extends \Phalcon\Di\Di let this->services = [ "annotations" : new Service("Phalcon\\Annotations\\Adapter\\Memory", true), + "assets" : new Service( + [ + "className" : "Phalcon\\Assets\\Manager", + "arguments" : [ + [ + "type" : "service", + "name" : "tag" + ] + ] + ], + true + ), "crypt" : new Service("Phalcon\\Encryption\\Crypt", true), "cookies" : new Service("Phalcon\\Http\\Response\\Cookies", true), "dispatcher" : new Service("Phalcon\\Mvc\\Dispatcher", true), @@ -48,34 +60,46 @@ class FactoryDefault extends \Phalcon\Di\Di "response" : new Service("Phalcon\\Http\\Response", true), "router" : new Service("Phalcon\\Mvc\\Router", true), "security" : new Service("Phalcon\\Encryption\\Security", true), + "tag" : new Service( + [ + "className" : "Phalcon\\Html\\TagFactory", + "arguments" : [ + [ + "type" : "service", + "name" : "escaper" + ] + ] + ], + true + ), "transactionManager" : new Service("Phalcon\\Mvc\\Model\\Transaction\\Manager", true), "url" : new Service("Phalcon\\Mvc\\Url", true) ]; - this->set( - "assets", - [ - "className" : "Phalcon\\Assets\\Manager", - "arguments" : [ - [ - "type" : "service", - "name" : "tag" - ] - ] - ] - ); - - this->set( - "tag", - [ - "className" : "Phalcon\\Html\\TagFactory", - "arguments" : [ - [ - "type" : "service", - "name" : "escaper" - ] - ] - ] - ); +// this->setShared( +// "assets", +// [ +// "className" : "Phalcon\\Assets\\Manager", +// "arguments" : [ +// [ +// "type" : "service", +// "name" : "tag" +// ] +// ] +// ] +// ); +// +// this->setShared( +// "tag", +// [ +// "className" : "Phalcon\\Html\\TagFactory", +// "arguments" : [ +// [ +// "type" : "service", +// "name" : "escaper" +// ] +// ] +// ] +// ); } } diff --git a/phalcon/Forms/Element/AbstractElement.zep b/phalcon/Forms/Element/AbstractElement.zep index f8ad7eb0079..003871ec6e1 100644 --- a/phalcon/Forms/Element/AbstractElement.zep +++ b/phalcon/Forms/Element/AbstractElement.zep @@ -11,9 +11,12 @@ namespace Phalcon\Forms\Element; use InvalidArgumentException; +use Phalcon\Di\DiInterface; +use Phalcon\Di\Di; use Phalcon\Filter\Validation\ValidatorInterface; use Phalcon\Forms\Form; use Phalcon\Forms\Exception; +use Phalcon\Html\Escaper; use Phalcon\Html\TagFactory; use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; @@ -517,10 +520,45 @@ abstract class AbstractElement implements ElementInterface */ protected function getLocalTagFactory() -> { + var container, escaper, tagFactory; + + let tagFactory = null; + if unlikely empty this->tagFactory { - throw new Exception( - "The TagFactory must be set for this element to render" - ); + /** + * Check the form for the TagFactory + */ + if this->form !== null { + let tagFactory = this->form->getTagFactory(); + } + + /** + * Check the DI container + */ + if tagFactory === null { + let container = Di::getDefault(); + + if likely true === container->has("tag") { + let tagFactory = container->getShared("tag"); + } + } + + /** + * All failed, create a new TagFactory + */ + if tagFactory === null { + let container = Di::getDefault(); + + if likely true === container->has("escaper") { + let escaper = container->getShared("escaper"); + } else { + let escaper = new Escaper(); + } + + let tagFactory = new TagFactory(escaper); + } + + let this->tagFactory = tagFactory; } return this->tagFactory; diff --git a/phalcon/Mvc/View/Engine/Volt/Compiler.zep b/phalcon/Mvc/View/Engine/Volt/Compiler.zep index 7438f34ae8c..d8f5cbbdfcf 100644 --- a/phalcon/Mvc/View/Engine/Volt/Compiler.zep +++ b/phalcon/Mvc/View/Engine/Volt/Compiler.zep @@ -233,7 +233,7 @@ class Compiler implements InjectionAwareInterface * Services registered in the dependency injector container are * available always */ - if typeof this->container == "object" && this->container->has(variable) { + if this->container !== null && this->container->has(variable) { let exprCode .= "$this->" . variable; } else { let exprCode .= "$" . variable; @@ -1878,7 +1878,7 @@ class Compiler implements InjectionAwareInterface /** * These are for the TagFactory */ - if true === this->container->has("tag") { + if this->container !== null && true === this->container->has("tag") { let tagService = this->container->get("tag"); if true === tagService->has(name) { return "$this->tag->" . name . "(" . arguments . ")"; diff --git a/phalcon/Support/Helper/Str/Camelize.zep b/phalcon/Support/Helper/Str/Camelize.zep index 8eb28939c5c..c8b222d4433 100644 --- a/phalcon/Support/Helper/Str/Camelize.zep +++ b/phalcon/Support/Helper/Str/Camelize.zep @@ -11,42 +11,30 @@ namespace Phalcon\Support\Helper\Str; /** - * Converts strings to camelize style + * Converts strings to upperCamelCase or lowerCamelCase */ -class Camelize +class Camelize extends PascalCase { /** * @param string $text * @param string|null $delimiters + * @param bool $lowerFirst * * @return string */ public function __invoke( string text, - string delimiters = null + string delimiters = null, + bool lowerFirst = false ) -> string { - var delims, exploded, output; + var result; - if !delimiters { - let delims = "_-"; - } else { - let delims = delimiters; - } - - let exploded = preg_split( - "/[" . delims . "]+/", - text, - -1, - PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY - ); + let result = parent::__invoke(text, delimiters); - let output = array_map( - function (element) { - return ucfirst(mb_strtolower(element)); - }, - exploded - ); + if (lowerFirst === true) { + let result = lcfirst(result); + } - return implode("", output); + return result; } } diff --git a/phalcon/Support/Helper/Str/KebabCase.zep b/phalcon/Support/Helper/Str/KebabCase.zep new file mode 100644 index 00000000000..ccb6151d597 --- /dev/null +++ b/phalcon/Support/Helper/Str/KebabCase.zep @@ -0,0 +1,34 @@ + +/** + * This file is part of the Phalcon. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Phalcon\Support\Helper\Str; + +/** + * Converts strings to kebab-case style + */ +class KebabCase extends PascalCase +{ + /** + * @param string $text + * @param string|null $delimiters + * + * @return string + */ + public function __invoke( + string text, + string delimiters = null + ) -> string { + var output; + + let output = this->processArray(text, delimiters); + + return implode("_", output); + } +} diff --git a/phalcon/Support/Helper/Str/PascalCase.zep b/phalcon/Support/Helper/Str/PascalCase.zep new file mode 100644 index 00000000000..027f1009c09 --- /dev/null +++ b/phalcon/Support/Helper/Str/PascalCase.zep @@ -0,0 +1,75 @@ + +/** + * This file is part of the Phalcon. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Phalcon\Support\Helper\Str; + +/** + * Converts strings to PascalCase style + */ +class PascalCase +{ + /** + * @param string $text + * @param string|null $delimiters + * + * @return string + */ + public function __invoke( + string text, + string delimiters = null + ) -> string { + var exploded, output; + + let exploded = this->processArray(text, delimiters); + + let output = array_map( + function (element) { + return ucfirst(mb_strtolower(element)); + }, + exploded + ); + + return implode("", output); + } + + /** + * @param string $text + * @param string|null $delimiters + * + * @return array + */ + protected function processArray(string text, string delimiters = null) -> array + { + var result; + + if delimiters === null { + let delimiters = "-_"; + } + + /** + * Escape the `-` if it exists so that it does not get interpreted + * as a range. First remove any escaping for the `-` if present and then + * add it again - just to be on the safe side + */ + if strpos(delimiters, "\\-") !== false || strpos(delimiters, "-") !== false { + let delimiters = str_replace(["\\-", "-"], ["", ""], delimiters), + delimiters = "-" . $delimiters; + } + + let result = preg_split( + "/[" . delimiters . "]+/", + text, + -1, + PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY + ); + + return (false === result) ? [] : result; + } +} diff --git a/phalcon/Support/Helper/Str/SnakeCase.zep b/phalcon/Support/Helper/Str/SnakeCase.zep new file mode 100644 index 00000000000..126b6642dc3 --- /dev/null +++ b/phalcon/Support/Helper/Str/SnakeCase.zep @@ -0,0 +1,34 @@ + +/** + * This file is part of the Phalcon. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Phalcon\Support\Helper\Str; + +/** + * Converts strings to snake_case style + */ +class SnakeCase extends PascalCase +{ + /** + * @param string $text + * @param string|null $delimiters + * + * @return string + */ + public function __invoke( + string text, + string delimiters = null + ) -> string { + var output; + + let output = this->processArray(text, delimiters); + + return implode("-", output); + } +} diff --git a/phalcon/Support/HelperFactory.zep b/phalcon/Support/HelperFactory.zep index 4684cef8920..b5eb9bdcf9c 100644 --- a/phalcon/Support/HelperFactory.zep +++ b/phalcon/Support/HelperFactory.zep @@ -40,6 +40,7 @@ use Phalcon\Factory\AbstractFactory; * @method string decode(string $data, bool $associative = false, int $depth = 512, int $options = 0) * @method string encode($data, int $options = 0, int $depth = 512) * @method bool between(int $value, int $start, int $end) + * @method string camelize(string $text, string $delimiters = null, bool $lowerFirst = false) * @method string concat(string $delimiter, string $first, string $second, string ...$arguments) * @method int countVowels(string $text) * @method string decapitalize(string $text, bool $upperRest = false, string $encoding = 'UTF-8') @@ -56,14 +57,18 @@ use Phalcon\Factory\AbstractFactory; * @method bool isLower(string $text, string $encoding = 'UTF-8') * @method bool isPalindrome(string $text) * @method bool isUpper(string $text, string $encoding = 'UTF-8') + * @method string kebabCase(string $text, string $delimiters = null) * @method int len(string $text, string $encoding = 'UTF-8') * @method string lower(string $text, string $encoding = 'UTF-8') + * @method string pascalCase(string $text, string $delimiters = null) * @method string prefix($text, string $prefix) * @method string random(int $type = 0, int $length = 8) * @method string reduceSlashes(string $text) * @method bool startsWith(string $haystack, string $needle, bool $ignoreCase = true) + * @method string snakeCase(string $text, string $delimiters = null) * @method string suffix($text, string $suffix) * @method string ucwords(string $text, string $encoding = 'UTF-8') + * @method string uncamelize(string $text, string $delimiters = '_') * @method string underscore(string $text) * @method string upper(string $text, string $encoding = 'UTF-8') */ @@ -167,11 +172,14 @@ class HelperFactory extends AbstractFactory "isLower" : "Phalcon\\Support\\Helper\\Str\\IsLower", "isPalindrome" : "Phalcon\\Support\\Helper\\Str\\IsPalindrome", "isUpper" : "Phalcon\\Support\\Helper\\Str\\IsUpper", + "kebabCase" : "Phalcon\\Support\\Helper\\Str\\KebabCase", "len" : "Phalcon\\Support\\Helper\\Str\\Len", "lower" : "Phalcon\\Support\\Helper\\Str\\Lower", + "pascalCase" : "Phalcon\\Support\\Helper\\Str\\PascalCase", "prefix" : "Phalcon\\Support\\Helper\\Str\\Prefix", "random" : "Phalcon\\Support\\Helper\\Str\\Random", "reduceSlashes" : "Phalcon\\Support\\Helper\\Str\\ReduceSlashes", + "snakeCase" : "Phalcon\\Support\\Helper\\Str\\SnakeCase", "startsWith" : "Phalcon\\Support\\Helper\\Str\\StartsWith", "suffix" : "Phalcon\\Support\\Helper\\Str\\Suffix", "ucwords" : "Phalcon\\Support\\Helper\\Str\\Ucwords", diff --git a/phalcon/Support/Version.zep b/phalcon/Support/Version.zep index 28780f22d69..6b8d7b1abe4 100644 --- a/phalcon/Support/Version.zep +++ b/phalcon/Support/Version.zep @@ -77,7 +77,7 @@ class Version */ protected function getVersion() -> array { - return [5, 0, 0, 1, 7]; + return [5, 0, 0, 2, 2]; } /** diff --git a/tests/integration/Forms/Element/GetSetTagFactoryCest.php b/tests/integration/Forms/Element/GetSetTagFactoryCest.php new file mode 100644 index 00000000000..a87b1dddb4c --- /dev/null +++ b/tests/integration/Forms/Element/GetSetTagFactoryCest.php @@ -0,0 +1,134 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\Tests\Integration\Forms\Element; + +use IntegrationTester; +use Phalcon\Di\Di; +use Phalcon\Forms\Element\Text; +use Phalcon\Forms\Form; +use Phalcon\Html\Escaper; +use Phalcon\Html\TagFactory; +use Phalcon\Tests\Fixtures\Traits\DiTrait; + +use function spl_object_hash; +use function sprintf; +use function uniqid; + +class GetSetTagFactoryCest +{ + use DiTrait; + + /** + * Tests Phalcon\Forms\Element :: getTagFactory()/setTagFactory() + * + * @author Phalcon Team + * @since 2021-12-30 + */ + public function formsElementGetSetTagFactory(IntegrationTester $I) + { + $I->wantToTest('Forms\Element - getTagFactory()/setTagFactory()'); + + $escaper = new Escaper(); + $tagFactoryOne = new TagFactory($escaper); + + $name = uniqid(); + $element = new Text($name); + + /** + * Initial + */ + $actual = $element->getTagFactory(); + $I->assertNull($actual); + + $element->setTagFactory($tagFactoryOne); + + $expected = $tagFactoryOne; + $actual = $element->getTagFactory(); + $I->assertSame($expected, $actual); + } + + /** + * Tests Phalcon\Forms\Element :: getTagFactory()/setTagFactory() - from Element + * + * @author Phalcon Team + * @since 2021-12-30 + */ + public function formsElementGetSetTagFactoryFromElement(IntegrationTester $I) + { + $I->wantToTest('Forms\Element - getTagFactory()/setTagFactory() - from Element'); + + $escaper = new Escaper(); + $tagFactoryOne = new TagFactory($escaper); + + $form = new Form(); + $form->setTagFactory($tagFactoryOne); + + $name = uniqid(); + $element = new Text($name); + + /** + * Initial + */ + $actual = $element->getTagFactory(); + $I->assertNull($actual); + + $element->setForm($form); + + $expected = sprintf('', $name, $name); + $actual = $element->render(); + $I->assertSame($expected, $actual); + + /** + * From form + */ + $expected = $tagFactoryOne; + $actual = $element->getTagFactory(); + $I->assertSame($expected, $actual); + } + + /** + * Tests Phalcon\Forms\Element :: getTagFactory()/setTagFactory() - from DI + * + * @author Phalcon Team + * @since 2021-12-30 + */ + public function formsElementGetSetTagFactoryFromDi(IntegrationTester $I) + { + $I->wantToTest('Forms\Element - getTagFactory()/setTagFactory() - from Di'); + + $this->setNewFactoryDefault(); + + $tagFactoryOne = $this->container->get("tag"); + + $name = uniqid(); + $element = new Text($name); + + /** + * Initial + */ + $actual = $element->getTagFactory(); + $I->assertNull($actual); + + /** + * From DI + */ + $expected = sprintf('', $name, $name); + $actual = $element->render(); + $I->assertSame($expected, $actual); + + $expected = $tagFactoryOne; + $actual = $element->getTagFactory(); + $I->assertSame($expected, $actual); + } +} diff --git a/tests/integration/Forms/Form/GetSetTagFactoryCest.php b/tests/integration/Forms/Form/GetSetTagFactoryCest.php new file mode 100644 index 00000000000..eeb32c8591b --- /dev/null +++ b/tests/integration/Forms/Form/GetSetTagFactoryCest.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\Tests\Integration\Forms\Form; + +use IntegrationTester; +use Phalcon\Forms\Element\Text; +use Phalcon\Forms\Form; +use Phalcon\Html\Escaper; +use Phalcon\Html\TagFactory; +use Phalcon\Tests\Fixtures\Traits\DiTrait; + +class GetSetTagFactoryCest +{ + /** + * Tests Phalcon\Forms\Form :: getTagFactory()/setTagFactory() + * + * @author Phalcon Team + * @since 2021-12-30 + */ + public function formsFormGetSetTagFactory(IntegrationTester $I) + { + $I->wantToTest('Forms\Form - getTagFactory()/setTagFactory()'); + + $escaper = new Escaper(); + $tagFactoryOne = new TagFactory($escaper); + + $form = new Form(); + + /** + * Initial + */ + $actual = $form->getTagFactory(); + $I->assertNull($actual); + + $form->setTagFactory($tagFactoryOne); + + $expected = $tagFactoryOne; + $actual = $form->getTagFactory(); + $I->assertSame($expected, $actual); + } +} diff --git a/tests/integration/Mvc/View/Engine/Volt/CallMacroCest.php b/tests/integration/Mvc/View/Engine/Volt/CallMacroCest.php index dbb865c0291..ff2ab283134 100644 --- a/tests/integration/Mvc/View/Engine/Volt/CallMacroCest.php +++ b/tests/integration/Mvc/View/Engine/Volt/CallMacroCest.php @@ -14,21 +14,45 @@ namespace Phalcon\Tests\Integration\Mvc\View\Engine\Volt; use IntegrationTester; +use Phalcon\Mvc\View\Engine\Volt\Compiler; -/** - * Class CallMacroCest - */ class CallMacroCest { /** - * Tests Phalcon\Mvc\View\Engine\Volt :: callMacro() + * Tests Phalcon\Mvc\View\Engine\Volt :: callMacro() - PHP function * * @author Phalcon Team - * @since 2018-11-13 + * @since 2021-12-28 + * @issue https://github.com/phalcon/cphalcon/issues/15842 */ - public function mvcViewEngineVoltCallMacro(IntegrationTester $I) + public function mvcViewEngineVoltCallMacroPhpFunction(IntegrationTester $I) { - $I->wantToTest('Mvc\View\Engine\Volt - callMacro()'); - $I->skipTest('Need implementation'); + $I->wantToTest('Mvc\View\Engine\Volt - callMacro() - php function'); + + $compiler = new Compiler(); + + $expected = "callMacro(" + . "'str_replace', ['a', 'b', 'aabb']) ?>"; + $actual = $compiler->compileString('{{ str_replace("a", "b", "aabb") }}'); + $I->assertEquals($expected, $actual); + } + + /** + * Tests Phalcon\Mvc\View\Engine\Volt :: callMacro() - PHP function + * + * @author Phalcon Team + * @since 2021-12-28 + * @issue https://github.com/phalcon/cphalcon/issues/15842 + */ + public function mvcViewEngineVoltCallMacroPhpFunctionDoesNotExist(IntegrationTester $I) + { + $I->wantToTest('Mvc\View\Engine\Volt - callMacro() - php function does not exist'); + + $compiler = new Compiler(); + + $expected = "callMacro(" + . "'myfunction', ['a']) ?>"; + $actual = $compiler->compileString('{{ myfunction("a") }}'); + $I->assertEquals($expected, $actual); } } diff --git a/tests/integration/Mvc/View/Engine/Volt/Extensions/PhpCest.php b/tests/integration/Mvc/View/Engine/Volt/Extensions/PhpCest.php new file mode 100755 index 00000000000..75486eb21ba --- /dev/null +++ b/tests/integration/Mvc/View/Engine/Volt/Extensions/PhpCest.php @@ -0,0 +1,56 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\Tests\Integration\Mvc\View\Engine\Volt\Extensions; + +use IntegrationTester; +use Phalcon\Mvc\View\Engine\Volt\Compiler; + +class PhpCest +{ + /** + * Tests Phalcon\Mvc\View\Engine\Volt\Extensions :: php() + * + * @author Phalcon Team + * @since 2021-12-28 + */ + public function mvcViewEngineVoltExtensionsPhp(IntegrationTester $I) + { + $I->wantToTest('Mvc\View\Engine\Volt\Extensions - php'); + + $compiler = new Compiler(); + + $expected = "callMacro(" + . "'str_replace', ['a', 'b', 'aabb']) ?>"; + $actual = $compiler->compileString('{{ str_replace("a", "b", "aabb") }}'); + $I->assertEquals($expected, $actual); + } + + /** + * Tests Phalcon\Mvc\View\Engine\Volt\Extensions :: does not exist + * + * @author Phalcon Team + * @since 2021-12-28 + */ + public function mvcViewEngineVoltExtensionsDoesNotExist(IntegrationTester $I) + { + $I->wantToTest('Mvc\View\Engine\Volt\Extensions - does not exist'); + + $compiler = new Compiler(); + + $expected = "callMacro(" + . "'myfunction', ['a']) ?>"; + $actual = $compiler->compileString('{{ myfunction("a") }}'); + $I->assertEquals($expected, $actual); + } +} diff --git a/tests/unit/Assets/Asset/Css/GetAssetKeyCest.php b/tests/unit/Assets/Asset/Css/GetAssetKeyCest.php index 9fbbc055494..5cde16e31b0 100644 --- a/tests/unit/Assets/Asset/Css/GetAssetKeyCest.php +++ b/tests/unit/Assets/Asset/Css/GetAssetKeyCest.php @@ -16,6 +16,8 @@ use Phalcon\Assets\Asset\Css; use UnitTester; +use function hash; + /** * Class GetAssetKeyCest * @@ -38,7 +40,7 @@ public function assetsAssetCssGetAssetKey(UnitTester $I) $path = 'css/docs.css'; $asset = new Css($path); - $assetKey = sha1('css:' . $path); + $assetKey = hash("sha256", 'css:' . $path); $actual = $asset->getAssetKey(); $I->assertEquals($assetKey, $actual); diff --git a/tests/unit/Assets/Asset/GetAssetKeyCest.php b/tests/unit/Assets/Asset/GetAssetKeyCest.php index 62cb70d795b..a6e28a174c2 100644 --- a/tests/unit/Assets/Asset/GetAssetKeyCest.php +++ b/tests/unit/Assets/Asset/GetAssetKeyCest.php @@ -17,6 +17,8 @@ use Phalcon\Assets\Asset; use UnitTester; +use function hash; + /** * Class GetAssetKeyCest * @@ -41,7 +43,7 @@ public function assetsAssetGetAssetKey(UnitTester $I, Example $example) $asset = new Asset($example['type'], $example['path']); - $assetKey = sha1($example['type'] . ':' . $example['path']); + $assetKey = hash("sha256", $example['type'] . ':' . $example['path']); $actual = $asset->getAssetKey(); $I->assertEquals($assetKey, $actual); } diff --git a/tests/unit/Assets/Asset/Js/GetAssetKeyCest.php b/tests/unit/Assets/Asset/Js/GetAssetKeyCest.php index 79b8bf81d6f..b57a1704665 100644 --- a/tests/unit/Assets/Asset/Js/GetAssetKeyCest.php +++ b/tests/unit/Assets/Asset/Js/GetAssetKeyCest.php @@ -16,6 +16,8 @@ use Phalcon\Assets\Asset\Js; use UnitTester; +use function hash; + /** * Class GetAssetKeyCest * @@ -37,7 +39,7 @@ public function assetsAssetJsGetAssetKey(UnitTester $I) $path = 'js/jquery.js'; $asset = new Js($path); - $expected = sha1('js:' . $path); + $expected = hash("sha256", 'js:' . $path); $actual = $asset->getAssetKey(); $I->assertEquals($expected, $actual); diff --git a/tests/unit/Assets/Collection/AddInlineCssCest.php b/tests/unit/Assets/Collection/AddInlineCssCest.php index 7d0db107345..5b3f5f23d79 100644 --- a/tests/unit/Assets/Collection/AddInlineCssCest.php +++ b/tests/unit/Assets/Collection/AddInlineCssCest.php @@ -14,7 +14,6 @@ namespace Phalcon\Tests\Unit\Assets\Collection; use Phalcon\Assets\Collection; -use Phalcon\Assets\Inline\Css; use UnitTester; /** diff --git a/tests/unit/Assets/Collection/AddInlineJsCest.php b/tests/unit/Assets/Collection/AddInlineJsCest.php index 2e14e4b61f2..a7027c725af 100644 --- a/tests/unit/Assets/Collection/AddInlineJsCest.php +++ b/tests/unit/Assets/Collection/AddInlineJsCest.php @@ -14,7 +14,6 @@ namespace Phalcon\Tests\Unit\Assets\Collection; use Phalcon\Assets\Collection; -use Phalcon\Assets\Inline\Js; use UnitTester; /** diff --git a/tests/unit/Assets/Collection/GetRealTargetPathCest.php b/tests/unit/Assets/Collection/GetRealTargetPathCest.php index b4b349dcb06..b686d9018ef 100644 --- a/tests/unit/Assets/Collection/GetRealTargetPathCest.php +++ b/tests/unit/Assets/Collection/GetRealTargetPathCest.php @@ -65,7 +65,7 @@ public function assetsCollectionGetRealTargetPathFileDoesNotExist(UnitTester $I) $I->markTestSkipped('Need to fix Windows new lines...'); } - $collection = Stub::make( + $collection = Stub::make( Collection::class, [ 'phpFileExists' => false, diff --git a/tests/unit/Assets/Inline/Css/GetAssetKeyCest.php b/tests/unit/Assets/Inline/Css/GetAssetKeyCest.php index 35784c10c97..a4bbe53dd74 100644 --- a/tests/unit/Assets/Inline/Css/GetAssetKeyCest.php +++ b/tests/unit/Assets/Inline/Css/GetAssetKeyCest.php @@ -16,6 +16,8 @@ use Phalcon\Assets\Inline\Css; use UnitTester; +use function hash; + /** * Class GetAssetKeyCest * @@ -38,7 +40,7 @@ public function assetsInlineCssGetAssetKey(UnitTester $I) $content = 'p {color: #000099}'; $asset = new Css($content); - $expected = sha1('css:' . $content); + $expected = hash("sha256", 'css:' . $content); $actual = $asset->getAssetKey(); $I->assertEquals($expected, $actual); } diff --git a/tests/unit/Assets/Inline/GetAssetKeyCest.php b/tests/unit/Assets/Inline/GetAssetKeyCest.php index 343eb27fb17..32990490705 100644 --- a/tests/unit/Assets/Inline/GetAssetKeyCest.php +++ b/tests/unit/Assets/Inline/GetAssetKeyCest.php @@ -17,6 +17,8 @@ use Phalcon\Assets\Inline; use UnitTester; +use function hash; + class GetAssetKeyCest { /** @@ -36,7 +38,8 @@ public function assetsInlineGetAssetKey(UnitTester $I, Example $example) $example['content'] ); - $expected = sha1( + $expected = hash( + "sha256", $example['type'] . ':' . $example['content'] ); diff --git a/tests/unit/Assets/Inline/Js/GetAssetKeyCest.php b/tests/unit/Assets/Inline/Js/GetAssetKeyCest.php index b3063bf1f0a..0532bee59de 100644 --- a/tests/unit/Assets/Inline/Js/GetAssetKeyCest.php +++ b/tests/unit/Assets/Inline/Js/GetAssetKeyCest.php @@ -16,6 +16,8 @@ use Phalcon\Assets\Inline\Js; use UnitTester; +use function hash; + /** * Class GetAssetKeyCest * @@ -38,7 +40,7 @@ public function assetsInlineJsGetAssetKey(UnitTester $I) $content = ''; $asset = new Js($content); - $expected = sha1('js:' . $content); + $expected = hash("sha256", 'js:' . $content); $actual = $asset->getAssetKey(); $I->assertEquals($expected, $actual); } diff --git a/tests/unit/Assets/Manager/AddJsCest.php b/tests/unit/Assets/Manager/AddJsCest.php index 034c128677e..0c8e026d5c5 100644 --- a/tests/unit/Assets/Manager/AddJsCest.php +++ b/tests/unit/Assets/Manager/AddJsCest.php @@ -107,11 +107,11 @@ public function assetsManagerAddJsVersioning(UnitTester $I) $expected = sprintf( "%s" . PHP_EOL . "%s" . PHP_EOL . "%s" . PHP_EOL, "", + . "src=\"{$pathData}assets/assets-version-1.js?ver=1.0.0\">", "", + . "src=\"{$pathData}assets/assets-version-2.js?ver=2.0.0\">", "" + . "src=\"{$pathData}assets/assets-version-3.js\">" ); $I->assertEquals($expected, $manager->outputJs()); diff --git a/tests/unit/Assets/Manager/OutputCssCest.php b/tests/unit/Assets/Manager/OutputCssCest.php index f6e8bcd4737..f419f0b00c1 100644 --- a/tests/unit/Assets/Manager/OutputCssCest.php +++ b/tests/unit/Assets/Manager/OutputCssCest.php @@ -22,7 +22,6 @@ use Phalcon\Tests\Fixtures\Traits\DiTrait; use UnitTester; -use function cacheDir; use function outputDir; class OutputCssCest diff --git a/tests/unit/Assets/Manager/OutputJsCest.php b/tests/unit/Assets/Manager/OutputJsCest.php index 7b3238ca6ae..a91bf2aa916 100644 --- a/tests/unit/Assets/Manager/OutputJsCest.php +++ b/tests/unit/Assets/Manager/OutputJsCest.php @@ -120,9 +120,9 @@ public function assetsManagerOutputJsBasic(UnitTester $I) $manager->useImplicitOutput(false); $manager->collection('js') - ->addJs(dataDir('assets/assets/jquery.js'), false, false) - ->setTargetPath(outputDir('tests/assets/combined.js')) - ->setTargetUri('production/combined.js') + ->addJs(dataDir('assets/assets/jquery.js'), false, false) + ->setTargetPath(outputDir('tests/assets/combined.js')) + ->setTargetUri('production/combined.js') ; $expected = sprintf( @@ -149,10 +149,10 @@ public function assetsManagerOutputJsEnabledJoin(UnitTester $I) $manager->useImplicitOutput(false); $manager->collection('js') - ->addJs(dataDir('assets/assets/jquery.js'), false, false) - ->setTargetPath(outputDir('tests/assets/combined.js')) - ->setTargetUri('production/combined.js') - ->join(true) + ->addJs(dataDir('assets/assets/jquery.js'), false, false) + ->setTargetPath(outputDir('tests/assets/combined.js')) + ->setTargetUri('production/combined.js') + ->join(true) ; $expected = sprintf( @@ -254,9 +254,9 @@ public function assetsManagerOutputJsMixedResources(UnitTester $I) $expectedJS = sprintf( "%s" . PHP_EOL . "%s" . PHP_EOL, '', + . 'src="http:://cdn.example.com/js/script1.js">', '' + . 'src="http:://cdn.example.com/js/script2.js">' ); $I->assertEquals($expectedJS, $manager->outputJs('header')); @@ -303,7 +303,7 @@ public function assetsManagerOutputJsTargetLocal(UnitTester $I) $I->assertEquals( '' . PHP_EOL, + . 'src="//phalcon.io/js/jquery.js">' . PHP_EOL, $manager->outputJs('js') ); diff --git a/tests/unit/Autoload/Loader/GetAddSetDirectoriesCest.php b/tests/unit/Autoload/Loader/GetAddSetDirectoriesCest.php index 42ac7ea5c87..1fa8301bd51 100644 --- a/tests/unit/Autoload/Loader/GetAddSetDirectoriesCest.php +++ b/tests/unit/Autoload/Loader/GetAddSetDirectoriesCest.php @@ -17,6 +17,8 @@ use Phalcon\Tests\Fixtures\Traits\LoaderTrait; use UnitTester; +use function hash; + class GetAddSetDirectoriesCest { use LoaderTrait; @@ -46,7 +48,7 @@ public function autoloaderLoaderGetAddSetDirectories(UnitTester $I) '/phalcon/public/css', ] ); - $expected = [sha1('/phalcon/public/css') => '/phalcon/public/css']; + $expected = [hash("sha256", '/phalcon/public/css') => '/phalcon/public/css']; $actual = $loader->getDirectories(); $I->assertEquals($expected, $actual); @@ -66,8 +68,8 @@ public function autoloaderLoaderGetAddSetDirectories(UnitTester $I) ; $expected = [ - sha1('/phalcon/public/css') => '/phalcon/public/css', - sha1('/phalcon/public/js') => '/phalcon/public/js', + hash("sha256", '/phalcon/public/css') => '/phalcon/public/css', + hash("sha256", '/phalcon/public/js') => '/phalcon/public/js', ]; $actual = $loader->getDirectories(); $I->assertEquals($expected, $actual); diff --git a/tests/unit/Autoload/Loader/GetAddSetExtensionsCest.php b/tests/unit/Autoload/Loader/GetAddSetExtensionsCest.php index 55317b3348c..9b5bdf175e2 100644 --- a/tests/unit/Autoload/Loader/GetAddSetExtensionsCest.php +++ b/tests/unit/Autoload/Loader/GetAddSetExtensionsCest.php @@ -17,7 +17,7 @@ use Phalcon\Tests\Fixtures\Traits\LoaderTrait; use UnitTester; -use function sha1; +use function hash; class GetAddSetExtensionsCest { @@ -38,7 +38,7 @@ public function autoloaderLoaderGetAddSetExtensions(UnitTester $I) $loader = new Loader(); - $expected = [sha1('php') => 'php']; + $expected = [hash("sha256", 'php') => 'php']; $actual = $loader->getExtensions(); $I->assertEquals($expected, $actual); @@ -51,8 +51,8 @@ public function autoloaderLoaderGetAddSetExtensions(UnitTester $I) ); $expected = [ - sha1('php') => 'php', - sha1('inc') => 'inc', + hash("sha256", 'php') => 'php', + hash("sha256", 'inc') => 'inc', ]; $actual = $loader->getExtensions(); $I->assertEquals($expected, $actual); @@ -61,7 +61,7 @@ public function autoloaderLoaderGetAddSetExtensions(UnitTester $I) * Clear */ $loader->setExtensions([]); - $expected = [sha1('php') => 'php']; + $expected = [hash("sha256", 'php') => 'php']; $actual = $loader->getExtensions(); $I->assertEquals($expected, $actual); @@ -72,9 +72,9 @@ public function autoloaderLoaderGetAddSetExtensions(UnitTester $I) ->addExtension('inc') ; $expected = [ - sha1('php') => 'php', - sha1('inc') => 'inc', - sha1('phpt') => 'phpt', + hash("sha256", 'php') => 'php', + hash("sha256", 'inc') => 'inc', + hash("sha256", 'phpt') => 'phpt', ]; $actual = $loader->getExtensions(); $I->assertEquals($expected, $actual); diff --git a/tests/unit/Autoload/Loader/GetAddSetFilesCest.php b/tests/unit/Autoload/Loader/GetAddSetFilesCest.php index 3ca82bd242a..960caff435e 100644 --- a/tests/unit/Autoload/Loader/GetAddSetFilesCest.php +++ b/tests/unit/Autoload/Loader/GetAddSetFilesCest.php @@ -17,6 +17,8 @@ use Phalcon\Tests\Fixtures\Traits\LoaderTrait; use UnitTester; +use function hash; + class GetAddSetFilesCest { use LoaderTrait; @@ -46,7 +48,7 @@ public function autoloaderLoaderGetAddSetFiles(UnitTester $I) 'classOne.php', ] ); - $expected = [sha1('classOne.php') => 'classOne.php']; + $expected = [hash("sha256", 'classOne.php') => 'classOne.php']; $actual = $loader->getFiles(); $I->assertEquals($expected, $actual); @@ -66,8 +68,8 @@ public function autoloaderLoaderGetAddSetFiles(UnitTester $I) ; $expected = [ - sha1('classOne.php') => 'classOne.php', - sha1('classTwo.php') => 'classTwo.php', + hash("sha256", 'classOne.php') => 'classOne.php', + hash("sha256", 'classTwo.php') => 'classTwo.php', ]; $actual = $loader->getFiles(); $I->assertEquals($expected, $actual); diff --git a/tests/unit/Autoload/Loader/GetAddSetNamespacesCest.php b/tests/unit/Autoload/Loader/GetAddSetNamespacesCest.php index f53aabeb69f..9f23ce4056a 100644 --- a/tests/unit/Autoload/Loader/GetAddSetNamespacesCest.php +++ b/tests/unit/Autoload/Loader/GetAddSetNamespacesCest.php @@ -18,7 +18,7 @@ use Phalcon\Tests\Fixtures\Traits\LoaderTrait; use UnitTester; -use function sha1; +use function hash; class GetAddSetNamespacesCest { @@ -60,11 +60,11 @@ public function autoloaderLoaderGetAddSetNamespaces(UnitTester $I) $expected = [ 'Phalcon\Loader\\' => [ - sha1('/path/to/loader/') => '/path/to/loader/', + hash("sha256", '/path/to/loader/') => '/path/to/loader/', ], 'Phalcon\Provider\\' => [ - sha1('/path/to/provider/source/') => '/path/to/provider/source/', - sha1('/path/to/provider/target/') => '/path/to/provider/target/', + hash("sha256", '/path/to/provider/source/') => '/path/to/provider/source/', + hash("sha256", '/path/to/provider/target/') => '/path/to/provider/target/', ], ]; $actual = $loader->getNamespaces(); @@ -99,11 +99,11 @@ public function autoloaderLoaderGetAddSetNamespaces(UnitTester $I) $expected = [ 'Phalcon\Loader\\' => [ - sha1('/path/to/loader/') => '/path/to/loader/', + hash("sha256", '/path/to/loader/') => '/path/to/loader/', ], 'Phalcon\Provider\\' => [ - sha1('/path/to/provider/source/') => '/path/to/provider/source/', - sha1('/path/to/provider/target/') => '/path/to/provider/target/', + hash("sha256", '/path/to/provider/source/') => '/path/to/provider/source/', + hash("sha256", '/path/to/provider/target/') => '/path/to/provider/target/', ], ]; $actual = $loader->getNamespaces(); @@ -140,9 +140,9 @@ public function autoloaderLoaderGetAddSetNamespaces(UnitTester $I) $expected = [ 'Phalcon\Loader\\' => [ - sha1('/path/to/provider/target/') => '/path/to/provider/target/', - sha1('/path/to/loader/') => '/path/to/loader/', - sha1('/path/to/provider/source/') => '/path/to/provider/source/', + hash("sha256", '/path/to/provider/target/') => '/path/to/provider/target/', + hash("sha256", '/path/to/loader/') => '/path/to/loader/', + hash("sha256", '/path/to/provider/source/') => '/path/to/provider/source/', ], ]; $actual = $loader->getNamespaces(); diff --git a/tests/unit/Autoload/Loader/GetSetEventsManagerCest.php b/tests/unit/Autoload/Loader/GetSetEventsManagerCest.php index 22d561c42d4..e93b39686b5 100644 --- a/tests/unit/Autoload/Loader/GetSetEventsManagerCest.php +++ b/tests/unit/Autoload/Loader/GetSetEventsManagerCest.php @@ -13,8 +13,8 @@ namespace Phalcon\Tests\Unit\Autoload\Loader; -use Phalcon\Events\Manager; use Phalcon\Autoload\Loader; +use Phalcon\Events\Manager; use UnitTester; class GetSetEventsManagerCest diff --git a/tests/unit/Autoload/Loader/RegisterUnregisterCest.php b/tests/unit/Autoload/Loader/RegisterUnregisterCest.php index 361e6ea02c4..83befdbe106 100644 --- a/tests/unit/Autoload/Loader/RegisterUnregisterCest.php +++ b/tests/unit/Autoload/Loader/RegisterUnregisterCest.php @@ -63,6 +63,10 @@ public function autoloaderLoaderEvents(UnitTester $I) { $I->wantToTest('Autoload\Loader - events'); + if (PHP_OS_FAMILY === 'Windows') { + $I->markTestSkipped('Need to fix Windows new lines...'); + } + $trace = []; $loader = new Loader(); $manager = new Manager(); diff --git a/tests/unit/Di/AttemptCest.php b/tests/unit/Di/AttemptCest.php index 198ebb25e57..6aec4a2f188 100644 --- a/tests/unit/Di/AttemptCest.php +++ b/tests/unit/Di/AttemptCest.php @@ -30,8 +30,6 @@ class AttemptCest * * @param UnitTester $I * - * @param UnitTester $I - * * @author Phalcon Team * @since 2019-09-09 */ diff --git a/tests/unit/Di/ConstructCest.php b/tests/unit/Di/ConstructCest.php index 0eaa0f5e67f..eadbb577367 100644 --- a/tests/unit/Di/ConstructCest.php +++ b/tests/unit/Di/ConstructCest.php @@ -28,8 +28,6 @@ class ConstructCest * * @param UnitTester $I * - * @param UnitTester $I - * * @author Phalcon Team * @since 2019-09-09 */ diff --git a/tests/unit/Di/GetCest.php b/tests/unit/Di/GetCest.php index 48be0212644..b0800d70b55 100644 --- a/tests/unit/Di/GetCest.php +++ b/tests/unit/Di/GetCest.php @@ -34,8 +34,6 @@ class GetCest * * @param UnitTester $I * - * @param UnitTester $I - * * @author Phalcon Team * @since 2019-09-09 */ diff --git a/tests/unit/Encryption/Security/CheckTokenCest.php b/tests/unit/Encryption/Security/CheckTokenCest.php index b42f0066ecb..f3de4becdbc 100644 --- a/tests/unit/Encryption/Security/CheckTokenCest.php +++ b/tests/unit/Encryption/Security/CheckTokenCest.php @@ -108,6 +108,9 @@ public function securityCheckTokenWithRequest(UnitTester $I) $I->wantToTest('Security - checkToken() - with Request'); $I->skipTest("Enable when Request is ready"); + $store = $_POST ?? []; + $_POST = []; + /** @var Manager $session */ $session = $this->container->getShared('session'); $session->start(); diff --git a/tests/unit/Encryption/Security/GetRandomCest.php b/tests/unit/Encryption/Security/GetRandomCest.php index 8aed1c03961..cdfa5dbb6c2 100644 --- a/tests/unit/Encryption/Security/GetRandomCest.php +++ b/tests/unit/Encryption/Security/GetRandomCest.php @@ -13,8 +13,8 @@ namespace Phalcon\Tests\Unit\Encryption\Security; -use Phalcon\Encryption\Security\Random; use Phalcon\Encryption\Security; +use Phalcon\Encryption\Security\Random; use UnitTester; class GetRandomCest diff --git a/tests/unit/Html/Attributes/ConstructCest.php b/tests/unit/Html/Attributes/ConstructCest.php index 32d474dd233..c88b1d5b082 100644 --- a/tests/unit/Html/Attributes/ConstructCest.php +++ b/tests/unit/Html/Attributes/ConstructCest.php @@ -13,8 +13,8 @@ namespace Phalcon\Tests\Unit\Html\Attributes; -use Phalcon\Support\Collection; use Phalcon\Html\Attributes; +use Phalcon\Support\Collection; use UnitTester; class ConstructCest diff --git a/tests/unit/Html/Escaper/AttributesCest.php b/tests/unit/Html/Escaper/AttributesCest.php index 5adee154940..3a9c85839c3 100644 --- a/tests/unit/Html/Escaper/AttributesCest.php +++ b/tests/unit/Html/Escaper/AttributesCest.php @@ -41,7 +41,7 @@ public function escaperAttributes(UnitTester $I, Example $example) $escaper = new Escaper(); - $text = $example['text']; + $text = $example['text']; $flags = $example['htmlQuoteType']; $escaper->setHtmlQuoteType($flags); @@ -50,7 +50,7 @@ public function escaperAttributes(UnitTester $I, Example $example) $actual = $escaper->attributes($text); $I->assertEquals($expected, $actual); - $actual = $escaper->escapeHtmlAttr($text); + $actual = $escaper->escapeHtmlAttr($text); $I->assertEquals($expected, $actual); } diff --git a/tests/unit/Html/Escaper/HtmlCest.php b/tests/unit/Html/Escaper/HtmlCest.php index f4686590b2e..ac401afeb1a 100644 --- a/tests/unit/Html/Escaper/HtmlCest.php +++ b/tests/unit/Html/Escaper/HtmlCest.php @@ -30,7 +30,7 @@ public function escaperHtml(UnitTester $I) { $I->wantToTest('Escaper - html()'); - $escaper = new Escaper(); + $escaper = new Escaper(); $expected = '<h1></h1>'; $actual = $escaper->html('

'); diff --git a/tests/unit/Html/Escaper/UrlCest.php b/tests/unit/Html/Escaper/UrlCest.php index 4d61213abcd..ad2334d27c2 100644 --- a/tests/unit/Html/Escaper/UrlCest.php +++ b/tests/unit/Html/Escaper/UrlCest.php @@ -36,7 +36,7 @@ public function escaperUrl(UnitTester $I) $actual = $escaper->url('http://phalcon.io/a.php?c=d&e=f'); $I->assertEquals($expected, $actual); - $actual = $escaper->escapeUrl('http://phalcon.io/a.php?c=d&e=f'); + $actual = $escaper->escapeUrl('http://phalcon.io/a.php?c=d&e=f'); $I->assertEquals($expected, $actual); } } diff --git a/tests/unit/Html/EscaperFactory/NewInstanceCest.php b/tests/unit/Html/EscaperFactory/NewInstanceCest.php index ca92125d1f1..64e286712b2 100644 --- a/tests/unit/Html/EscaperFactory/NewInstanceCest.php +++ b/tests/unit/Html/EscaperFactory/NewInstanceCest.php @@ -14,8 +14,8 @@ namespace Phalcon\Tests\Unit\Html\EscaperFactory; use Phalcon\Html\Escaper; -use Phalcon\Html\EscaperFactory; use Phalcon\Html\Escaper\EscaperInterface; +use Phalcon\Html\EscaperFactory; use UnitTester; /** diff --git a/tests/unit/Html/TagFactory/UnderscoreCallCest.php b/tests/unit/Html/TagFactory/UnderscoreCallCest.php index 114617535fa..b4ae161e1be 100644 --- a/tests/unit/Html/TagFactory/UnderscoreCallCest.php +++ b/tests/unit/Html/TagFactory/UnderscoreCallCest.php @@ -14,8 +14,6 @@ namespace Phalcon\Tests\Unit\Html\TagFactory; use Phalcon\Html\Escaper; -use Phalcon\Html\Helper\Anchor; -use Phalcon\Html\Helper\Base; use Phalcon\Html\TagFactory; use UnitTester; @@ -36,7 +34,7 @@ public function filterTagFactoryUnderscoreCall(UnitTester $I) $factory = new TagFactory($escaper); $expected = ''; - $actual = $factory->body(); + $actual = $factory->body(); $I->assertEquals($expected, $actual); } } diff --git a/tests/unit/Logger/Logger/LevelsCest.php b/tests/unit/Logger/Logger/LevelsCest.php index 1057c7e51f2..5f6afc37a3f 100644 --- a/tests/unit/Logger/Logger/LevelsCest.php +++ b/tests/unit/Logger/Logger/LevelsCest.php @@ -36,8 +36,8 @@ class LevelsCest * @param UnitTester $I * @param Example $example * - * @author Phalcon Team - * @since 2020-09-09 + * @author Phalcon Team + * @since 2020-09-09 */ public function loggerAlert(UnitTester $I, Example $example) { @@ -46,15 +46,17 @@ public function loggerAlert(UnitTester $I, Example $example) $level = $example[0]; $fileName = $I->getNewFileName('log', 'log'); $fileName = logsDir($fileName); - $adapter = new Stream($fileName); - $logger = new Logger('my-logger', ['one' => $adapter]); + $adapter = new Stream($fileName); + $logger = new Logger('my-logger', ['one' => $adapter]); $logString = 'Hello'; $logTime = date('c'); $logger->{$level}($logString); - $logger->getAdapter('one')->close(); + $logger->getAdapter('one') + ->close() + ; $I->amInPath(logsDir()); $I->openFile($fileName); @@ -81,7 +83,8 @@ public function loggerAlert(UnitTester $I, Example $example) $date = end($matches); $logDateTime = new DateTime($date); $dateTimeAfterLog = new DateTime($logTime); - $nInterval = $logDateTime->diff($dateTimeAfterLog)->format('%s'); + $nInterval = $logDateTime->diff($dateTimeAfterLog) + ->format('%s'); $nSecondThreshold = 60; $I->assertLessThan($nSecondThreshold, $nInterval); diff --git a/tests/unit/Logger/Logger/LogCest.php b/tests/unit/Logger/Logger/LogCest.php index 15542d51687..3026f21bfa6 100644 --- a/tests/unit/Logger/Logger/LogCest.php +++ b/tests/unit/Logger/Logger/LogCest.php @@ -14,7 +14,6 @@ namespace Phalcon\Tests\Unit\Logger\Logger; use Phalcon\Logger\Adapter\Stream; -use Phalcon\Logger\Adapter\Syslog; use Phalcon\Logger\Logger; use UnitTester; diff --git a/tests/unit/Support/Debug/Dump/ConstructCest.php b/tests/unit/Support/Debug/Dump/ConstructCest.php index 5ae0251205b..9799e191708 100644 --- a/tests/unit/Support/Debug/Dump/ConstructCest.php +++ b/tests/unit/Support/Debug/Dump/ConstructCest.php @@ -17,11 +17,8 @@ use Phalcon\Tests\Fixtures\Support\Dump\ClassProperties; use UnitTester; -/** - * Class ConstructCest - * - * @package Phalcon\Tests\Unit\Support\Debug\Dump - */ +use const PHP_OS_FAMILY; + class ConstructCest { /** @@ -36,9 +33,12 @@ class ConstructCest */ public function supportDebugDumpConstructDump(UnitTester $I) { - $I->skipTest("Needs a review"); $I->wantToTest('Debug\Dump - __construct() - dump properties'); + if (PHP_OS_FAMILY === 'Windows') { + $I->markTestSkipped('Need to fix Windows new lines...'); + } + $patient = new ClassProperties(); $dump = new Dump([], true); diff --git a/tests/unit/Support/Helper/Arr/FilterCest.php b/tests/unit/Support/Helper/Arr/FilterCest.php index 6ec82c39bad..1fb4b5994b6 100644 --- a/tests/unit/Support/Helper/Arr/FilterCest.php +++ b/tests/unit/Support/Helper/Arr/FilterCest.php @@ -45,11 +45,11 @@ public function supportHelperArrFilter(UnitTester $I) ]; $expected = [ - 1 => 1, - 3 => 3, - 5 => 5, - 7 => 7, - 9 => 9, + 1 => 1, + 3 => 3, + 5 => 5, + 7 => 7, + 9 => 9, ]; $actual = $object->__invoke( $collection, diff --git a/tests/unit/Support/Helper/Str/CamelizeCest.php b/tests/unit/Support/Helper/Str/CamelizeCest.php index 0c44f434eb4..4349849f685 100644 --- a/tests/unit/Support/Helper/Str/CamelizeCest.php +++ b/tests/unit/Support/Helper/Str/CamelizeCest.php @@ -17,11 +17,6 @@ use Phalcon\Support\Helper\Str\Camelize; use UnitTester; -/** - * Class CamelizeCest - * - * @package Phalcon\Tests\Unit\Support\Helper\Str - */ class CamelizeCest { /** @@ -43,8 +38,9 @@ public function supportHelperStrCamelize(UnitTester $I, Example $example) $value = $example[0]; $expected = $example[1]; $delimiter = $example[2]; + $lowercase = $example[3]; - $actual = $object($value, $delimiter); + $actual = $object($value, $delimiter, $lowercase); $I->assertEquals($expected, $actual); } @@ -54,26 +50,32 @@ public function supportHelperStrCamelize(UnitTester $I, Example $example) private function getSources(): array { return [ - ['camelize', 'Camelize', null], - ['CameLiZe', 'Camelize', null], - ['cAmeLize', 'Camelize', null], - ['123camelize', '123camelize', null], - ['c_a_m_e_l_i_z_e', 'CAMELIZE', null], - ['Camelize', 'Camelize', null], - ['camel_ize', 'CamelIze', null], - ['CameLize', 'Camelize', null], - ['c_a-m_e-l_i-z_e', 'CAMELIZE', null], - ['came_li_ze', 'CameLiZe', null], - ['=_camelize', '=Camelize', '_'], - ['camelize', 'Camelize', '_'], - ['came_li_ze', 'CameLiZe', '_'], - ['came#li#ze', 'CameLiZe', '#'], - ['came li ze', 'CameLiZe', ' '], - ['came.li^ze', 'CameLiZe', '.^'], - ['c_a-m_e-l_i-z_e', 'CAMELIZE', '-_'], - ['came.li.ze', 'CameLiZe', '.'], - ['came-li-ze', 'CameLiZe', '-'], - ['c+a+m+e+l+i+z+e', 'CAMELIZE', '+'], + ['camelize', 'Camelize', null, false], + ['CameLiZe', 'Camelize', null, false], + ['cAmeLize', 'Camelize', null, false], + ['123camelize', '123camelize', null, false], + ['c_a_m_e_l_i_z_e', 'CAMELIZE', null, false], + ['Camelize', 'Camelize', null, false], + ['camel_ize', 'CamelIze', null, false], + ['CameLize', 'Camelize', null, false], + ['c_a-m_e-l_i-z_e', 'CAMELIZE', null, false], + ['came_li_ze', 'CameLiZe', null, false], + ['=_camelize', '=Camelize', '_', false], + ['camelize', 'Camelize', '_', false], + ['came_li_ze', 'CameLiZe', '_', false], + ['came#li#ze', 'CameLiZe', '#', false], + ['came li ze', 'CameLiZe', ' ', false], + ['came.li^ze', 'CameLiZe', '.^', false], + ['c_a-m_e-l_i-z_e', 'CAMELIZE', '-_', false], + ['came.li.ze', 'CameLiZe', '.', false], + ['came-li-ze', 'CameLiZe', '-', false], + ['c+a+m+e+l+i+z+e', 'CAMELIZE', '+', false], + ['customer-session', 'CustomerSession', null, false], + ['customer Session', 'CustomerSession', ' -_', false], + ['customer-Session', 'CustomerSession', ' -_', false], + ['customer-session', 'customerSession', null, true], + ['customer Session', 'customerSession', ' -_', true], + ['customer-Session', 'customerSession', ' -_', true], ]; } } diff --git a/tests/unit/Support/Helper/Str/DirSeparatorCest.php b/tests/unit/Support/Helper/Str/DirSeparatorCest.php index 65ba2c51827..1ab70f4b149 100644 --- a/tests/unit/Support/Helper/Str/DirSeparatorCest.php +++ b/tests/unit/Support/Helper/Str/DirSeparatorCest.php @@ -16,8 +16,6 @@ use Phalcon\Support\Helper\Str\DirSeparator; use UnitTester; -use const DIRECTORY_SEPARATOR; -use const PHP_OS; use const PHP_OS_FAMILY; /** diff --git a/tests/unit/Support/Helper/Str/KebabCaseCest.php b/tests/unit/Support/Helper/Str/KebabCaseCest.php new file mode 100644 index 00000000000..129242177c6 --- /dev/null +++ b/tests/unit/Support/Helper/Str/KebabCaseCest.php @@ -0,0 +1,78 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\Tests\Unit\Support\Helper\Str; + +use Codeception\Example; +use Phalcon\Support\Helper\Str\KebabCase; +use Phalcon\Support\Helper\Str\SnakeCase; +use UnitTester; + +class KebabCaseCest +{ + /** + * Tests Phalcon\Support\Helper\Str :: kebabCase() + * + * @dataProvider getSources + * + * @param UnitTester $I + * @param Example $example + * + * @author Phalcon Team + * @since 2022-01-02 + */ + public function supportHelperStrKebabCase(UnitTester $I, Example $example) + { + $I->wantToTest('Support\Helper\Str - kebabCase() - ' . $example[0]); + + $object = new KebabCase(); + $value = $example[0]; + $expected = $example[1]; + $delimiter = $example[2]; + + $actual = $object($value, $delimiter); + $I->assertEquals($expected, $actual); + } + + /** + * @return array + */ + private function getSources(): array + { + return [ + ['Camelize', 'Camelize', null], + ['CameLiZe', 'CameLiZe', null], + ['Camelize', 'Camelize', null], + ['123camelize', '123camelize', null], + ['c_a_m_e_l_i_z_e', 'c_a_m_e_l_i_z_e', null], + ['Camelize', 'Camelize', null], + ['camel_ize', 'camel_ize', null], + ['CameLize', 'CameLize', null], + ['c_a-m_e-l_i-z_e', 'c_a_m_e_l_i_z_e', null], + ['came_li_ze', 'came_li_ze', null], + ['=_camelize', '=_camelize', '_'], + ['camelize', 'camelize', '_'], + ['came_li_ze', 'came_li_ze', '_'], + ['came#li#ze', 'came_li_ze', '#'], + ['came li ze', 'came_li_ze', ' '], + ['came.li^ze', 'came_li_ze', '.^'], + ['c_a-m_e-l_i-z_e', 'c_a_m_e_l_i_z_e', '-_'], + ['came.li.ze', 'came_li_ze', '.'], + ['came-li-ze', 'came_li_ze', '-'], + ['c+a+m+e+l+i+z+e', 'c_a_m_e_l_i_z_e', '+'], + ['customer-session', 'customer_session', null], + ['customer Session', 'customer_Session', ' -_'], + ['customer-Session', 'customer_Session', ' -_'], + ]; + } +} diff --git a/tests/unit/Support/Helper/Str/PascalCaseCest.php b/tests/unit/Support/Helper/Str/PascalCaseCest.php new file mode 100644 index 00000000000..aea5c7fe38c --- /dev/null +++ b/tests/unit/Support/Helper/Str/PascalCaseCest.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\Tests\Unit\Support\Helper\Str; + +use Codeception\Example; +use Phalcon\Support\Helper\Str\PascalCase; +use UnitTester; + +class PascalCaseCest +{ + /** + * Tests Phalcon\Support\Helper\Str :: pascalCase() + * + * @dataProvider getSources + * + * @param UnitTester $I + * @param Example $example + * + * @author Phalcon Team + * @since 2022-01-02 + */ + public function supportHelperStrPascalCase(UnitTester $I, Example $example) + { + $I->wantToTest('Support\Helper\Str - pascalCase() - ' . $example[0]); + + $object = new PascalCase(); + $value = $example[0]; + $expected = $example[1]; + $delimiter = $example[2]; + + $actual = $object($value, $delimiter); + $I->assertEquals($expected, $actual); + } + + /** + * @return array + */ + private function getSources(): array + { + return [ + ['camelize', 'Camelize', null], + ['CameLiZe', 'Camelize', null], + ['cAmeLize', 'Camelize', null], + ['123camelize', '123camelize', null], + ['c_a_m_e_l_i_z_e', 'CAMELIZE', null], + ['Camelize', 'Camelize', null], + ['camel_ize', 'CamelIze', null], + ['CameLize', 'Camelize', null], + ['c_a-m_e-l_i-z_e', 'CAMELIZE', null], + ['came_li_ze', 'CameLiZe', null], + ['=_camelize', '=Camelize', '_'], + ['camelize', 'Camelize', '_'], + ['came_li_ze', 'CameLiZe', '_'], + ['came#li#ze', 'CameLiZe', '#'], + ['came li ze', 'CameLiZe', ' '], + ['came.li^ze', 'CameLiZe', '.^'], + ['c_a-m_e-l_i-z_e', 'CAMELIZE', '-_'], + ['came.li.ze', 'CameLiZe', '.'], + ['came-li-ze', 'CameLiZe', '-'], + ['c+a+m+e+l+i+z+e', 'CAMELIZE', '+'], + ['customer-session', 'CustomerSession', null], + ['customer Session', 'CustomerSession', ' -_'], + ['customer-Session', 'CustomerSession', ' -_'], + ]; + } +} diff --git a/tests/unit/Support/Helper/Str/SnakeCaseCest.php b/tests/unit/Support/Helper/Str/SnakeCaseCest.php new file mode 100644 index 00000000000..e0191a3f058 --- /dev/null +++ b/tests/unit/Support/Helper/Str/SnakeCaseCest.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\Tests\Unit\Support\Helper\Str; + +use Codeception\Example; +use Phalcon\Support\Helper\Str\SnakeCase; +use UnitTester; + +class SnakeCaseCest +{ + /** + * Tests Phalcon\Support\Helper\Str :: snakeCase() + * + * @dataProvider getSources + * + * @param UnitTester $I + * @param Example $example + * + * @author Phalcon Team + * @since 2022-01-02 + */ + public function supportHelperStrSnakeCase(UnitTester $I, Example $example) + { + $I->wantToTest('Support\Helper\Str - snakeCase() - ' . $example[0]); + + $object = new SnakeCase(); + $value = $example[0]; + $expected = $example[1]; + $delimiter = $example[2]; + + $actual = $object($value, $delimiter); + $I->assertEquals($expected, $actual); + } + + /** + * @return array + */ + private function getSources(): array + { + return [ + ['Camelize', 'Camelize', null], + ['CameLiZe', 'CameLiZe', null], + ['Camelize', 'Camelize', null], + ['123camelize', '123camelize', null], + ['c_a_m_e_l_i_z_e', 'c-a-m-e-l-i-z-e', null], + ['Camelize', 'Camelize', null], + ['camel_ize', 'camel-ize', null], + ['CameLize', 'CameLize', null], + ['c_a-m_e-l_i-z_e', 'c-a-m-e-l-i-z-e', null], + ['came_li_ze', 'came-li-ze', null], + ['=_camelize', '=-camelize', '_'], + ['camelize', 'camelize', '_'], + ['came_li_ze', 'came-li-ze', '_'], + ['came#li#ze', 'came-li-ze', '#'], + ['came li ze', 'came-li-ze', ' '], + ['came.li^ze', 'came-li-ze', '.^'], + ['c_a-m_e-l_i-z_e', 'c-a-m-e-l-i-z-e', '-_'], + ['came.li.ze', 'came-li-ze', '.'], + ['came-li-ze', 'came-li-ze', '-'], + ['c+a+m+e+l+i+z+e', 'c-a-m-e-l-i-z-e', '+'], + ['customer-session', 'customer-session', null], + ['customer Session', 'customer-Session', ' -_'], + ['customer-Session', 'customer-Session', ' -_'], + ]; + } +} diff --git a/tests/unit/Support/HelperFactory/NewInstanceCest.php b/tests/unit/Support/HelperFactory/NewInstanceCest.php index f8cc90becc3..ca99c3e7bc4 100644 --- a/tests/unit/Support/HelperFactory/NewInstanceCest.php +++ b/tests/unit/Support/HelperFactory/NewInstanceCest.php @@ -60,11 +60,14 @@ use Phalcon\Support\Helper\Str\IsLower; use Phalcon\Support\Helper\Str\IsPalindrome; use Phalcon\Support\Helper\Str\IsUpper; +use Phalcon\Support\Helper\Str\KebabCase; use Phalcon\Support\Helper\Str\Len; use Phalcon\Support\Helper\Str\Lower; +use Phalcon\Support\Helper\Str\PascalCase; use Phalcon\Support\Helper\Str\Prefix; use Phalcon\Support\Helper\Str\Random; use Phalcon\Support\Helper\Str\ReduceSlashes; +use Phalcon\Support\Helper\Str\SnakeCase; use Phalcon\Support\Helper\Str\StartsWith; use Phalcon\Support\Helper\Str\Suffix; use Phalcon\Support\Helper\Str\Ucwords; @@ -172,9 +175,11 @@ private function getExamples(): array ["isLower", IsLower::class], ["isPalindrome", IsPalindrome::class], ["isUpper", IsUpper::class], + ["kebabCase", KebabCase::class], ["len", Len::class], ["lower", Lower::class], ["prefix", Prefix::class], + ["pascalCase", PascalCase::class], ["random", Random::class], ["reduceSlashes", ReduceSlashes::class], ["startsWith", StartsWith::class],