diff --git a/CHANGELOG-5.0.md b/CHANGELOG-5.0.md index 82ada652bd5..3a323fe1bca 100644 --- a/CHANGELOG-5.0.md +++ b/CHANGELOG-5.0.md @@ -2,35 +2,45 @@ ## [5.4.0](https://github.com/phalcon/cphalcon/releases/tag/v5.3.1) (xxxx-xx-xx) +### Changed + + +### Added + +- Added the ability to define interpolator characters for the `Phalcon\Logger\Formatter\Line` [#16430](https://github.com/phalcon/cphalcon/issues/16430) + ### Fixed -- Model Annotation strategy did not work with empty_string [#16426] (https://github.com/phalcon/cphalcon/issues/16426) -- View::reset() sets content to null instead of default empty string [#16437] (https://github.com/phalcon/cphalcon/issues/16437) + +- Model Annotation strategy did not work with empty_string [#16426](https://github.com/phalcon/cphalcon/issues/16426) +- View::reset() sets content to null instead of default empty string [#16437](https://github.com/phalcon/cphalcon/issues/16437) - Fixed `Phalcon\Filter\Validation\Validator\Size\*` validators to correctly detect the size of uploaded files [#16390](https://github.com/phalcon/cphalcon/issues/16390) +### Removed ## [5.3.1](https://github.com/phalcon/cphalcon/releases/tag/v5.3.1) (2023-09-12) ### Fixed + - Fixed infinite save loop in `Phalcon\Mvc\Model::save()` [#16395](https://github.com/phalcon/cphalcon/issues/16395) - Fixed undefined column with columnMap and model caching [#16420](https://github.com/phalcon/cphalcon/issues/16420) - Fixed memory leak in `Phalcon\Mvc\Router::handle()` [#16431](https://github.com/phalcon/cphalcon/pull/16431) ## [5.3.0](https://github.com/phalcon/cphalcon/releases/tag/v5.3.0) (2023-08-15) +### Changed + +- Refactored `Phalcon\Mvc\Model::doLowUpdate` and `Phalcon\Mvc\Model::postSaveRelatedRecords` for better code logic and a clearer separation of behaviour, although it lead to partially repeated code. [#16391](https://github.com/phalcon/cphalcon/issues/16391) +- Cleaned `Phalcon\Mvc\Model\Metadata::initialize` [#16393](https://github.com/phalcon/cphalcon/issues/16393) + ### Added - Added `Phalcon\Mvc\Model::appendMessagedFrom` for code consistency and to add messages from another model [#16391](https://github.com/phalcon/cphalcon/issues/16391) - Added `Phalcon\Autoload\Loader::isRegistered` for debugging purposes [#16391](https://github.com/phalcon/cphalcon/issues/16391) -- Added `Phalcon\Mvc\Model\Metadata::initializeMetadata` [#16393] (https://github.com/phalcon/cphalcon/issues/16393) -- Added `Phalcon\Mvc\Model\Metadata::getMetaDataUniqueKey` [#16393] (https://github.com/phalcon/cphalcon/issues/16393) -- Added `Phalcon\Mvc\Model\Metadata::getColumnMapUniqueKey` [#16393] (https://github.com/phalcon/cphalcon/issues/16393) +- Added `Phalcon\Mvc\Model\Metadata::initializeMetadata` [#16393](https://github.com/phalcon/cphalcon/issues/16393) +- Added `Phalcon\Mvc\Model\Metadata::getMetaDataUniqueKey` [#16393](https://github.com/phalcon/cphalcon/issues/16393) +- Added `Phalcon\Mvc\Model\Metadata::getColumnMapUniqueKey` [#16393](https://github.com/phalcon/cphalcon/issues/16393) - Added `Phalcon\Encryption\Security\JWT\Builder::addHeader()` to allow adding custom headers [#16396](https://github.com/phalcon/cphalcon/issues/16396) -### Changed - -- Refactored `Phalcon\Mvc\Model::doLowUpdate` and `Phalcon\Mvc\Model::postSaveRelatedRecords` for better code logic and a clearer separation of behaviour, although it lead to partially repeated code. [#16391](https://github.com/phalcon/cphalcon/issues/16391) -- Cleaned `Phalcon\Mvc\Model\Metadata::initialize` [#16393] (https://github.com/phalcon/cphalcon/issues/16393) - ### Fixed - Parse multipart/form-data from PUT request [#16271](https://github.com/phalcon/cphalcon/issues/16271) @@ -47,8 +57,13 @@ ## [5.2.3](https://github.com/phalcon/cphalcon/releases/tag/v5.2.3) (2023-07-26) +### Added + +- Added `getAdapter()` in `Phalcon\Mvc\Model\Metadata` to retrieve the internal cache adapter if necessary. [#16244](https://github.com/phalcon/cphalcon/issues/16244) +- Added `Phalcon\Storage\Adapter\Weak` implemented with WeakReference has a cache/retrieval solution for objects not yet collected by the Garbage Collection. [#16372](https://github.com/phalcon/cphalcon/issues/16372) + ### Fixed - + - Tried to reproduce the behavior described in #16244 but had no success. [#16244](https://github.com/phalcon/cphalcon/issues/16244) - Extended `Phalcon\Di\Injectable` from `stdClass` to remove the deprecation warning (dynamic properties) for PHP 8.2 [#16308](https://github.com/phalcon/cphalcon/issues/16308) - Corrected the return type of `Phalcon\Mvc\View::getVar()` so that stubs can be accurate. [#16276](https://github.com/phalcon/cphalcon/issues/16276) @@ -56,11 +71,6 @@ - Changed the `Phalcon\Support\Helper\Json\*` classes to clear up `json_last_error()` before doing any conversions. [#15608](https://github.com/phalcon/cphalcon/issues/15608) - Fixed `Phalcon\Http\Request::getJsonRawBody` to protect from empty body [#16373](https://github.com/phalcon/cphalcon/issues/16373) -### Added - -- Added `getAdapter()` in `Phalcon\Mvc\Model\Metadata` to retrieve the internal cache adapter if necessary. [#16244](https://github.com/phalcon/cphalcon/issues/16244) -- Added `Phalcon\Storage\Adapter\Weak` implemented with WeakReference has a cache/retrieval solution for objects not yet collected by the Garbage Collection. [#16372](https://github.com/phalcon/cphalcon/issues/16372) - ## [5.2.2](https://github.com/phalcon/cphalcon/releases/tag/v5.2.2) (2023-06-18) ### Fixed @@ -78,14 +88,14 @@ ## [5.2.0](https://github.com/phalcon/cphalcon/releases/tag/v5.2.0) (2023-02-26) -### Fixed - -- Fixed `Phalcon\Html\Helper\Title::prepend` to correctly prepend text in subsequent calls [#16283](https://github.com/phalcon/cphalcon/issues/16283) - ### Added - + - Added support for PHP 8.2 [#15973](https://github.com/phalcon/cphalcon/issues/15973) +### Fixed + +- Fixed `Phalcon\Html\Helper\Title::prepend` to correctly prepend text in subsequent calls [#16283](https://github.com/phalcon/cphalcon/issues/16283) + ## [5.1.4](https://github.com/phalcon/cphalcon/releases/tag/v5.1.4) (2023-01-10) ### Fixed @@ -102,7 +112,7 @@ ## [5.1.2](https://github.com/phalcon/cphalcon/releases/tag/v5.1.2) (2022-10-30) ### Fixed -- + - Fixed `Phalcon\Support\Debug` to correctly calculate the documents URL for the hyperlinks [#16223](https://github.com/phalcon/cphalcon/issues/16223) - Fixed `Phalcon\Html\TagFactory` docblock for autocompletion (https://github.com/phalcon/cphalcon/commit/0129658f3ac468dcc5294d401403e166302a8069) - Fixed `Phalcon\Db\Profiler` by correctly calculating the seconds (reapplied changes) [#15822](https://github.com/phalcon/cphalcon/issues/15822) @@ -117,18 +127,18 @@ ## [5.1.0](https://github.com/phalcon/cphalcon/releases/tag/v5.1.0) (2022-11-01) -### Fixed - -- Fixed `Phalcon\Mvc\View\Engine\Volt\Compiler::isTagFactory` to correctly detect a `TagFactory` object without throwing an error [#16097](https://github.com/phalcon/cphalcon/issues/16097) -- Fixed default values for `Phalcon\Cli`, `Phalcon\Dispatcher` and `Phalcon\Application` components to ensure not `null` values are passed to methods [#16186](https://github.com/phalcon/cphalcon/issues/16186) -- Fixed `Phalcon\Form::clear` to correctly clear the elements and not recurse [#15956](https://github.com/phalcon/cphalcon/issues/15956) - ### Added - Added `Phalcon\Http\Request::getPatch()` to get a value from a PATCH request [#16188](https://github.com/phalcon/cphalcon/issues/16188) - Added `Phalcon\Http\Request::getFilteredPatch()` to get a value filtered from a PATCH request [#16188](https://github.com/phalcon/cphalcon/issues/16188) - Added `Phalcon\Http\Request::hasPatch()` to check if a value exist in a PATCH request [#16188](https://github.com/phalcon/cphalcon/issues/16188) +### Fixed + +- Fixed `Phalcon\Mvc\View\Engine\Volt\Compiler::isTagFactory` to correctly detect a `TagFactory` object without throwing an error [#16097](https://github.com/phalcon/cphalcon/issues/16097) +- Fixed default values for `Phalcon\Cli`, `Phalcon\Dispatcher` and `Phalcon\Application` components to ensure not `null` values are passed to methods [#16186](https://github.com/phalcon/cphalcon/issues/16186) +- Fixed `Phalcon\Form::clear` to correctly clear the elements and not recurse [#15956](https://github.com/phalcon/cphalcon/issues/15956) + ## [5.0.5](https://github.com/phalcon/cphalcon/releases/tag/v5.0.5) (2022-10-24) ### Fixed @@ -169,14 +179,14 @@ # [5.0.1](https://github.com/phalcon/cphalcon/releases/tag/v5.0.1) (2022-09-23) -### Fixed - -- Fixed `Phalcon\Encryption\Security\JWT\Token\Token::validate()` to correctly call validator methods [#16115](https://github.com/phalcon/cphalcon/issues/16115) - ### Added - Added `Phalcon\Encryption\Security\JWT\Validator::get()` and `Phalcon\Encryption\Security\JWT\Validator::set()` for validation data [#16115](https://github.com/phalcon/cphalcon/issues/16115) +### Fixed + +- Fixed `Phalcon\Encryption\Security\JWT\Token\Token::validate()` to correctly call validator methods [#16115](https://github.com/phalcon/cphalcon/issues/16115) + ## [5.0.0](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0) (2022-09-22) ### Changed @@ -186,6 +196,12 @@ - Changed return types to `array` in `Phalcon\Annotations\Reflection` class methods [#16106](https://github.com/phalcon/cphalcon/issues/16106) - Changed `Phalcon\Html\Escaper::attributes()` to also accept an array of attributes [#16108](https://github.com/phalcon/cphalcon/issues/16108) +### Added + +- Added `Phalcon\Encryption\Security\JWT\Token::validate()` to validate a token's claims [#16094](https://github.com/phalcon/cphalcon/issues/16094) +- Added `Phalcon\Encryption\Security\JWT\Token::verify()` to verify a token's signature [#16094](https://github.com/phalcon/cphalcon/issues/16094) +- Added `Phalcon\Encryption\Security\JWT\Validator::getErrors()` to return any errors with the validation as an array [#16094](https://github.com/phalcon/cphalcon/issues/16094) + ### Fixed - Fixed and improved return type of `object` & `?object` [#16023](https://github.com/phalcon/cphalcon/issues/16023) @@ -195,12 +211,6 @@ - Fixed segmentation fault on Reflection of `Phalcon\Mvc\Model` class [#16080](https://github.com/phalcon/cphalcon/issues/16080) - Fixed segmentation fault on Reflection [#16096](https://github.com/phalcon/cphalcon/issues/16096) -### Added - -- Added `Phalcon\Encryption\Security\JWT\Token::validate()` to validate a token's claims [#16094](https://github.com/phalcon/cphalcon/issues/16094) -- Added `Phalcon\Encryption\Security\JWT\Token::verify()` to verify a token's signature [#16094](https://github.com/phalcon/cphalcon/issues/16094) -- Added `Phalcon\Encryption\Security\JWT\Validator::getErrors()` to return any errors with the validation as an array [#16094](https://github.com/phalcon/cphalcon/issues/16094) - ## [5.0.0rc4](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0RC4) (2022-08-08) ### Fixed @@ -228,6 +238,12 @@ ## [5.0.0rc3](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0RC3) (2022-07-12) +### Added + +- Added support for `webp` images for `Phalcon\Image\Adapter\Gd` [#15977](https://github.com/phalcon/cphalcon/issues/15977) +- Added `Phalcon\Mvc\Model\ManagerInterface::getBuilder()` to return the existing builder (created by `createBuilder()`) [#15966](https://github.com/phalcon/cphalcon/issues/15966) +- Added `Phalcon\Mvc\Model\Manager::getBuilder()` to return the existing builder (created by `createBuilder()`) [#15966](https://github.com/phalcon/cphalcon/issues/15966) + ### Fixed - Fixed `Phalcon\Tag::textArea()` to check if the value is `null` before calling `htmlspecialchars` [#15992](https://github.com/phalcon/cphalcon/issues/15992) @@ -247,25 +263,19 @@ - Fixed `Phalcon\Dispatcher\AbstractDispatcher::setModuleName()` to accept `null` [#15997](https://github.com/phalcon/cphalcon/issues/15997) - Fixed `Phalcon\Dispatcher\AbstractDispatcher::getModuleName()` to also return `null` [#15997](https://github.com/phalcon/cphalcon/issues/15997) -### Added - -- Added support for `webp` images for `Phalcon\Image\Adapter\Gd` [#15977](https://github.com/phalcon/cphalcon/issues/15977) -- Added `Phalcon\Mvc\Model\ManagerInterface::getBuilder()` to return the existing builder (created by `createBuilder()`) [#15966](https://github.com/phalcon/cphalcon/issues/15966) -- Added `Phalcon\Mvc\Model\Manager::getBuilder()` to return the existing builder (created by `createBuilder()`) [#15966](https://github.com/phalcon/cphalcon/issues/15966) - ## [5.0.0rc2](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0RC2) (2022-06-09) ### Changed - Changed the `StringVal` filter to now use `htmlspecialchars()` [#15978](https://github.com/phalcon/cphalcon/issues/15978) -### Fixed +### Added -- Fixed `Phalcon\Http\Response::getQualityHeader()` to check if the server variable is `null` before performing `preg_split` [#15984](https://github.com/phalcon/cphalcon/issues/15984) +- Added `StringValLegacy` filter using `filter_var()` for PHP < 8.1 [#15978](https://github.com/phalcon/cphalcon/issues/15978) -### Added +### Fixed -- Added `StringValLegacy` filter using `filter_var()` for PHP < 8.1 [#15978](https://github.com/phalcon/cphalcon/issues/15978) +- Fixed `Phalcon\Http\Response::getQualityHeader()` to check if the server variable is `null` before performing `preg_split` [#15984](https://github.com/phalcon/cphalcon/issues/15984) ## [5.0.0rc1](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0RC1) (2022-05-31) @@ -276,11 +286,6 @@ - Changed `Phalcon\Cache\Cache` to no longer depend on PSR interfaces [#15927](https://github.com/phalcon/cphalcon/issues/15927) - Changed `Phalcon\Html\Link` to no longer depend on PSR interfaces [#15930](https://github.com/phalcon/cphalcon/issues/15930) -### Fixed - -- Fixed `Phalcon\Html\Helper\Input\Numeric` to produce correct elements [#15896](https://github.com/phalcon/cphalcon/issues/15896) -- Fixed `Phalcon\Storage\Adapter\*` to correctly store `null` values [#15904](https://github.com/phalcon/cphalcon/issues/15904) - ### Added - Added `Phalcon\Encryption\Crypt::isValidDecryptLength($input)` to allow checking for the length of the decryption string [#15879](https://github.com/phalcon/cphalcon/issues/15879) @@ -309,6 +314,11 @@ - `Phalcon\Html\Link\AbstractLinkProvider` to be used in the link class but also the proxy-psr13 repo [#15930](https://github.com/phalcon/cphalcon/issues/15930) - Added `Phalcon\Translate\Adapter\Csv::toArray()` and `Phalcon\Translate\Adapter\NativeArray::toArray()` to return the translation array back [#15902](https://github.com/phalcon/cphalcon/issues/15902) +### Fixed + +- Fixed `Phalcon\Html\Helper\Input\Numeric` to produce correct elements [#15896](https://github.com/phalcon/cphalcon/issues/15896) +- Fixed `Phalcon\Storage\Adapter\*` to correctly store `null` values [#15904](https://github.com/phalcon/cphalcon/issues/15904) + ### Removed - Removed `Phalcon\Container\Container` and moved its contents to the `proxy-psr11` repo [#15928](https://github.com/phalcon/cphalcon/issues/15928) @@ -321,6 +331,10 @@ - Renamed `Phalcon\Db\Result\Pdo` to `Phalcon\Db\Result\PdoResult` to avoid collisions with `\PDO` [#15874](https://github.com/phalcon/cphalcon/issues/15854) - Moved `Phalcon\Validation` to `Phalcon\Filter\Validation` +### Added + +- Added `Phalcon\Html\Helper\Title:setSeparator` to allow setting the separator independently [#15866](https://github.com/phalcon/cphalcon/issues/15866) + ### Fixed - Fixed `Phalcon\Logger\AbstractAdapter::getFormattedItem()` to not add `PHP_EOL` at the end of the message and added it to the `Phalcon\Logger\Adapter\Stream` [#14547](https://github.com/phalcon/cphalcon/issues/14547) @@ -339,11 +353,11 @@ - Fixed `Phalcon\Mvc\Model\Manager::addHasOneThrough()` parameter `options` array by default [#15971](https://github.com/phalcon/cphalcon/issues/15971) - Fixed `Phalcon\Mvc\Model\Manager::addBelongsTo()` parameter `options` array by default [#15971](https://github.com/phalcon/cphalcon/issues/15971) -### Added +## [5.0.0beta2](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0beta2) (2022-01-06) -- Added `Phalcon\Html\Helper\Title:setSeparator` to allow setting the separator independently [#15866](https://github.com/phalcon/cphalcon/issues/15866) +### Added -## [5.0.0beta2](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0beta2) (2022-01-06) +- 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) ### Fixed @@ -353,10 +367,6 @@ - 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 @@ -386,10 +396,6 @@ - `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: @@ -406,6 +412,7 @@ ### 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) - 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) diff --git a/phalcon/Logger/Formatter/AbstractFormatter.zep b/phalcon/Logger/Formatter/AbstractFormatter.zep index 5bb2d0612db..3fa169bb6b9 100644 --- a/phalcon/Logger/Formatter/AbstractFormatter.zep +++ b/phalcon/Logger/Formatter/AbstractFormatter.zep @@ -27,13 +27,29 @@ abstract class AbstractFormatter extends AbstractStr implements FormatterInterfa protected dateFormat = "c"; /** - * Return the default date format - * + * @var string + */ + protected interpolatorLeft = "%"; + + /** + * @var string + */ + protected interpolatorRight = "%"; + + /** * @return string */ public function getDateFormat() -> string { - return this->dateFormat; + return $this->dateFormat; + } + + /** + * @param string $format + */ + public function setDateFormat(string $format) -> void + { + let this->dateFormat = $format; } /** @@ -49,14 +65,20 @@ abstract class AbstractFormatter extends AbstractStr implements FormatterInterfa } /** - * Set the default date format + * @param Item $item + * @param string $message * - * @param string $format - * - * @return void + * @return string */ - public function setDateFormat(string format) -> void - { - let this->dateFormat = format; + protected function getInterpolatedMessage( + item, + string message + ) -> string { + return $this->toInterpolate( + message, + item->getContext(), + this->interpolatorLeft, + this->interpolatorRight + ); } } diff --git a/phalcon/Logger/Formatter/Json.zep b/phalcon/Logger/Formatter/Json.zep index d6b9ab78e76..9b605c69669 100644 --- a/phalcon/Logger/Formatter/Json.zep +++ b/phalcon/Logger/Formatter/Json.zep @@ -22,10 +22,17 @@ class Json extends AbstractFormatter * Json constructor. * * @param string $dateFormat + * @param string $interpolatorLeft + * @param string $interpolatorRight */ - public function __construct(string dateFormat = "c") - { - let this->dateFormat = dateFormat; + public function __construct( + string dateFormat = "c", + string interpolatorLeft = "%", + string interpolatorRight = "%" + ) { + let this->dateFormat = dateFormat; + let this->interpolatorLeft = interpolatorLeft; + let this->interpolatorRight = interpolatorRight; } /** @@ -40,6 +47,7 @@ class Json extends AbstractFormatter { var message, options; + let message = $this->getInterpolatedMessage($item, $item->getMessage()); let options = JSON_HEX_TAG + JSON_HEX_APOS + JSON_HEX_AMP @@ -47,11 +55,6 @@ class Json extends AbstractFormatter + JSON_UNESCAPED_SLASHES + JSON_THROW_ON_ERROR; - let message = this->toInterpolate( - item->getMessage(), - item->getContext() - ); - return json_encode( [ "level" : item->getLevelName(), diff --git a/phalcon/Logger/Formatter/Line.zep b/phalcon/Logger/Formatter/Line.zep index b0fd06c34df..0d474e8c409 100644 --- a/phalcon/Logger/Formatter/Line.zep +++ b/phalcon/Logger/Formatter/Line.zep @@ -30,13 +30,19 @@ class Line extends AbstractFormatter * * @param string $format * @param string $dateFormat + * @param string $interpolatorLeft + * @param string $interpolatorRight */ public function __construct( string format = "[%date%][%level%] %message%", - string dateFormat = "c" + string dateFormat = "c", + string interpolatorLeft = "%", + string interpolatorRight = "%" ) { - let this->format = format, - this->dateFormat = dateFormat; + let this->format = format; + let this->dateFormat = dateFormat; + let this->interpolatorLeft = interpolatorLeft; + let this->interpolatorRight = interpolatorRight; } /** @@ -54,13 +60,13 @@ class Line extends AbstractFormatter let message = strtr( this->format, [ - "%date%" : this->getFormattedDate(item), - "%level%" : item->getLevelName(), - "%message%" : item->getMessage() + this->interpolatorLeft . "date" . this->interpolatorRight : this->getFormattedDate(item), + this->interpolatorLeft . "level" . this->interpolatorRight : item->getLevelName(), + this->interpolatorLeft . "message" . this->interpolatorRight : item->getMessage() ] ); - return this->toInterpolate(message, item->getContext()); + return this->getInterpolatedMessage(item, message); } /** diff --git a/tests/_data/fixtures/Http/PhpStream.php b/tests/_data/fixtures/Http/PhpStream.php index eb0a7741873..763f1ccee38 100644 --- a/tests/_data/fixtures/Http/PhpStream.php +++ b/tests/_data/fixtures/Http/PhpStream.php @@ -36,6 +36,9 @@ class PhpStream */ protected $data = ''; + /** + * Constructor + */ public function __construct() { if (file_exists($this->getBufferFilename())) { @@ -48,26 +51,21 @@ public function __construct() $this->length = strlen($this->data); } - protected function getBufferFilename(): string - { - return codecept_output_dir('tests/stream/php_input.txt'); - } - - public function stream_open($path, $mode, $options, &$opened_path) + public function stream_close() { - return true; } - public function stream_close() + public function stream_eof() { + return ($this->index >= $this->length); } - public function stream_stat() + public function stream_flush() { - return []; + return true; } - public function stream_flush() + public function stream_open($path, $mode, $options, &$opened_path) { return true; } @@ -89,11 +87,6 @@ public function stream_read($count) return $data; } - public function stream_eof() - { - return ($this->index >= $this->length); - } - public function stream_seek($offset, $whence) { if (null === $this->length) { @@ -133,6 +126,17 @@ public function stream_seek($offset, $whence) } } + public function stream_stat() + { + return []; + } + + public function stream_tell() + { + return $this->index; + } + + public function stream_write($data) { return file_put_contents( @@ -153,4 +157,9 @@ public function unlink() $this->index = 0; $this->length = 0; } + + protected function getBufferFilename(): string + { + return codecept_output_dir('tests/stream/php_input.txt'); + } } diff --git a/tests/cli/Cli/Router/HandleCest.php b/tests/cli/Cli/Router/HandleCest.php index b6a62c5fb14..2f97762dcce 100644 --- a/tests/cli/Cli/Router/HandleCest.php +++ b/tests/cli/Cli/Router/HandleCest.php @@ -64,101 +64,10 @@ public function cliRouterHandleRouter(CliTester $I, Example $example) Route::reset(); $router = new Router(); - - $router->add( - ' ', - [ - 'module' => 'devtools', - 'task' => 'main', - 'action' => 'hello', - ] - ); - - $router->add( - 'system :task a :action :params', - [ - 'task' => 1, - 'action' => 2, - 'params' => 3, - ] - ); - - $router->add( - '([a-z]{2}) :task', - [ - 'task' => 2, - 'action' => 'index', - 'language' => 1, - ] - ); - - $router->add( - 'admin :task :action :int', - [ - 'module' => 'admin', - 'task' => 1, - 'action' => 2, - 'id' => 3, - ] - ); - - $router->add( - 'posts ([0-9]{4}) ([0-9]{2}) ([0-9]{2}) :params', - [ - 'task' => 'posts', - 'action' => 'show', - 'year' => 1, - 'month' => 2, - 'day' => 3, - 'params' => 4, - ] - ); - - $router->add( - 'manual ([a-z]{2}) ([a-z\.]+)\.txt', - [ - 'task' => 'manual', - 'action' => 'show', - 'language' => 1, - 'file' => 2, - ] - ); - - $router->add( - 'named-manual {language:([a-z]{2})} {file:[a-z\.]+}\.txt', - [ - 'task' => 'manual', - 'action' => 'show', - ] - ); - - $router->add( - 'very static route', - [ - 'task' => 'static', - 'action' => 'route', - ] - ); - - $router->add( - "feed {lang:[a-z]+} blog {blog:[a-z\-]+}\.{type:[a-z\-]+}", - 'Feed::get' - ); - - $router->add( - "posts {year:[0-9]+} s {title:[a-z\-]+}", - 'Posts::show' - ); - - $router->add( - 'posts delete {id}', - 'Posts::delete' - ); - - $router->add( - "show {id:video([0-9]+)} {title:[a-z\-]+}", - 'Videos::show' - ); + $routes = $this->setupRoutes('router'); + foreach ($routes as $pattern => $parameters) { + $router->add($pattern, $parameters); + } $this->assertParameters($I, $router, $example); } @@ -186,107 +95,16 @@ public function cliRouterHandleRouterParams(CliTester $I, Example $example) * @return void * @throws Exception */ - public function testDelimiter(CliTester $I, Example $example) + public function cliRouterHandleRouterDelimiter(CliTester $I, Example $example) { Route::reset(); Route::delimiter('/'); $router = new Router(); - - $router->add( - '/', - [ - 'module' => 'devtools', - 'task' => 'main', - 'action' => 'hello', - ] - ); - - $router->add( - '/system/:task/a/:action/:params', - [ - 'task' => 1, - 'action' => 2, - 'params' => 3, - ] - ); - - $router->add( - '/([a-z]{2})/:task', - [ - 'task' => 2, - 'action' => 'index', - 'language' => 1, - ] - ); - - $router->add( - '/admin/:task/:action/:int', - [ - 'module' => 'admin', - 'task' => 1, - 'action' => 2, - 'id' => 3, - ] - ); - - $router->add( - '/posts/([0-9]{4})/([0-9]{2})/([0-9]{2})/:params', - [ - 'task' => 'posts', - 'action' => 'show', - 'year' => 1, - 'month' => 2, - 'day' => 3, - 'params' => 4, - ] - ); - - $router->add( - '/manual/([a-z]{2})/([a-z\.]+)\.txt', - [ - 'task' => 'manual', - 'action' => 'show', - 'language' => 1, - 'file' => 2, - ] - ); - - $router->add( - '/named-manual/{language:([a-z]{2})}/{file:[a-z\.]+}\.txt', - [ - 'task' => 'manual', - 'action' => 'show', - ] - ); - - $router->add( - '/very/static/route', - [ - 'task' => 'static', - 'action' => 'route', - ] - ); - - $router->add( - "/feed/{lang:[a-z]+}/blog/{blog:[a-z\-]+}\.{type:[a-z\-]+}", - 'Feed::get' - ); - - $router->add( - "/posts/{year:[0-9]+}/s/{title:[a-z\-]+}", - 'Posts::show' - ); - - $router->add( - '/posts/delete/{id}', - 'Posts::delete' - ); - - $router->add( - "/show/{id:video([0-9]+)}/{title:[a-z\-]+}", - 'Videos::show' - ); + $routes = $this->setupRoutes('delimiter'); + foreach ($routes as $pattern => $parameters) { + $router->add($pattern, $parameters); + } $this->assertParameters($I, $router, $example); } @@ -743,4 +561,111 @@ private function getExamplesDelimiter(): array ], ]; } + + private function setupRoutes(string $test): array + { + $routes = [ + 'router' => [ + ' ' => [ + 'module' => 'devtools', + 'task' => 'main', + 'action' => 'hello', + ], + 'system :task a :action :params' => [ + 'task' => 1, + 'action' => 2, + 'params' => 3, + ], + '([a-z]{2}) :task' => [ + 'task' => 2, + 'action' => 'index', + 'language' => 1, + ], + 'admin :task :action :int' => [ + 'module' => 'admin', + 'task' => 1, + 'action' => 2, + 'id' => 3, + ], + 'posts ([0-9]{4}) ([0-9]{2}) ([0-9]{2}) :params' => [ + 'task' => 'posts', + 'action' => 'show', + 'year' => 1, + 'month' => 2, + 'day' => 3, + 'params' => 4, + ], + 'manual ([a-z]{2}) ([a-z\.]+)\.txt' => [ + 'task' => 'manual', + 'action' => 'show', + 'language' => 1, + 'file' => 2, + ], + 'named-manual {language:([a-z]{2})} {file:[a-z\.]+}\.txt' => [ + 'task' => 'manual', + 'action' => 'show', + ], + 'very static route' => [ + 'task' => 'static', + 'action' => 'route', + ], + "feed {lang:[a-z]+} blog {blog:[a-z\-]+}\.{type:[a-z\-]+}" => 'Feed::get', + "posts {year:[0-9]+} s {title:[a-z\-]+}" => 'Posts::show', + 'posts delete {id}' => 'Posts::delete', + "show {id:video([0-9]+)} {title:[a-z\-]+}" => 'Videos::show', + ], + 'delimiter' => [ + '/' => [ + 'module' => 'devtools', + 'task' => 'main', + 'action' => 'hello', + ], + '/system/:task/a/:action/:params' => [ + 'task' => 1, + 'action' => 2, + 'params' => 3, + ], + '/([a-z]{2})/:task' => [ + 'task' => 2, + 'action' => 'index', + 'language' => 1, + ], + '/admin/:task/:action/:int' => [ + 'module' => 'admin', + 'task' => 1, + 'action' => 2, + 'id' => 3, + ], + '/posts/([0-9]{4})/([0-9]{2})/([0-9]{2})/:params' => [ + 'task' => 'posts', + 'action' => 'show', + 'year' => 1, + 'month' => 2, + 'day' => 3, + 'params' => 4, + ], + '/manual/([a-z]{2})/([a-z\.]+)\.txt' => [ + 'task' => 'manual', + 'action' => 'show', + 'language' => 1, + 'file' => 2, + ], + '/named-manual/{language:([a-z]{2})}/{file:[a-z\.]+}\.txt' => [ + 'task' => 'manual', + 'action' => 'show', + ], + '/very/static/route' => [ + 'task' => 'static', + 'action' => 'route', + ], + "/feed/{lang:[a-z]+}/blog/{blog:[a-z\-]+}\.{type:[a-z\-]+}" => 'Feed::get', + "/posts/{year:[0-9]+}/s/{title:[a-z\-]+}" => 'Posts::show', + '/posts/delete/{id}' => 'Posts::delete', + "/show/{id:video([0-9]+)}/{title:[a-z\-]+}" => 'Videos::show', + + ], + ]; + + return $routes[$test] ?? []; + } } diff --git a/tests/cli/Di/FactoryDefault/Cli/ConstructCest.php b/tests/cli/Di/FactoryDefault/Cli/ConstructCest.php index 92feffbf263..19149a28edd 100644 --- a/tests/cli/Di/FactoryDefault/Cli/ConstructCest.php +++ b/tests/cli/Di/FactoryDefault/Cli/ConstructCest.php @@ -15,22 +15,13 @@ use CliTester; use Codeception\Example; -use Phalcon\Annotations\Adapter\Memory as AnnotationsMemory; -use Phalcon\Cli\Dispatcher; -use Phalcon\Cli\Router; use Phalcon\Di\FactoryDefault\Cli; -use Phalcon\Html\Escaper; -use Phalcon\Events\Manager as EventsManager; -use Phalcon\Filter\Filter; -use Phalcon\Html\TagFactory; -use Phalcon\Mvc\Model\Manager as ModelsManager; -use Phalcon\Mvc\Model\MetaData\Memory; -use Phalcon\Mvc\Model\Transaction\Manager; -use Phalcon\Encryption\Security; -use Phalcon\Support\HelperFactory; +use Phalcon\Tests\Fixtures\Traits\CliTrait; class ConstructCest { + use CliTrait; + /** * Tests Phalcon\Di\FactoryDefault\Cli :: __construct() * @@ -73,58 +64,4 @@ public function diFactoryDefaultCliConstructServices(CliTester $I, Example $exam $actual = $container->get($example['service'], $params); $I->assertInstanceOf($class, $actual); } - - private function getServices(): array - { - return [ - [ - 'service' => 'annotations', - 'class' => AnnotationsMemory::class, - ], - [ - 'service' => 'dispatcher', - 'class' => Dispatcher::class, - ], - [ - 'service' => 'escaper', - 'class' => Escaper::class, - ], - [ - 'service' => 'eventsManager', - 'class' => EventsManager::class, - ], - [ - 'service' => 'filter', - 'class' => Filter::class, - ], - [ - 'service' => 'helper', - 'class' => HelperFactory::class, - ], - [ - 'service' => 'modelsManager', - 'class' => ModelsManager::class, - ], - [ - 'service' => 'modelsMetadata', - 'class' => Memory::class, - ], - [ - 'service' => 'router', - 'class' => Router::class, - ], - [ - 'service' => 'security', - 'class' => Security::class, - ], - [ - 'service' => 'tag', - 'class' => TagFactory::class, - ], - [ - 'service' => 'transactionManager', - 'class' => Manager::class, - ], - ]; - } } diff --git a/tests/cli/Di/FactoryDefault/Cli/GetCest.php b/tests/cli/Di/FactoryDefault/Cli/GetCest.php index b8385940012..eeecee331e3 100644 --- a/tests/cli/Di/FactoryDefault/Cli/GetCest.php +++ b/tests/cli/Di/FactoryDefault/Cli/GetCest.php @@ -41,7 +41,7 @@ public function diFactorydefaultCliGet(CliTester $I) $I->assertFalse($actual->isShared()); // get escaper service - $actual = $di->get('escaper'); + $actual = $di->get('escaper'); $expected = new Escaper(); $I->assertInstanceOf(Escaper::class, $actual); diff --git a/tests/cli/Di/FactoryDefault/Cli/GetInternalEventsManagerCest.php b/tests/cli/Di/FactoryDefault/Cli/GetInternalEventsManagerCest.php index dfaa3e3bd31..3607eb95e06 100644 --- a/tests/cli/Di/FactoryDefault/Cli/GetInternalEventsManagerCest.php +++ b/tests/cli/Di/FactoryDefault/Cli/GetInternalEventsManagerCest.php @@ -37,7 +37,7 @@ public function diFactorydefaultCliGetInternalEventsManager(CliTester $I) $di->setInternalEventsManager(new Manager()); - $class = ManagerInterface::class; + $class = ManagerInterface::class; $actual = $di->getInternalEventsManager(); $I->assertInstanceOf($class, $actual); } diff --git a/tests/cli/Di/FactoryDefault/Cli/GetDefaultCest.php b/tests/cli/Di/FactoryDefault/Cli/GetSetDefaultResetCest.php similarity index 51% rename from tests/cli/Di/FactoryDefault/Cli/GetDefaultCest.php rename to tests/cli/Di/FactoryDefault/Cli/GetSetDefaultResetCest.php index cac24e0da5a..a00324c5104 100644 --- a/tests/cli/Di/FactoryDefault/Cli/GetDefaultCest.php +++ b/tests/cli/Di/FactoryDefault/Cli/GetSetDefaultResetCest.php @@ -16,31 +16,42 @@ use CliTester; use Phalcon\Di\FactoryDefault\Cli as Di; -class GetDefaultCest +use function spl_object_hash; + +class GetSetDefaultResetCest { /** - * Tests Phalcon\Di\FactoryDefault\Cli :: getDefault() + * Tests Phalcon\Di\FactoryDefault\Cli :: getDefault()/setDefault()/reset() * * @author Phalcon Team * @since 2018-11-13 */ public function diFactorydefaultCliGetDefault(CliTester $I) { - $I->wantToTest('Di\FactoryDefault\Cli - getDefault()'); + $I->wantToTest('Di\FactoryDefault\Cli - getDefault()/setDefault()/reset()'); // there is a DI container $I->assertInstanceOf(Di::class, Di::getDefault()); - $di = Di::getDefault(); + $container = Di::getDefault(); // delete it Di::reset(); - $I->assertNull(Di::getDefault()); + // Get a new container + $new = Di::getDefault(); + + $I->assertNull($new); // set it again - Di::setDefault($di); + Di::setDefault($container); - $I->assertInstanceOf(Di::class, Di::getDefault()); + $class = Di::class; + $actual = Di::getDefault(); + $I->assertInstanceOf($class, $actual); + + $containerHash = spl_object_hash($container); + $currentHash = spl_object_hash($actual); + $I->assertSame($containerHash, $currentHash); } } diff --git a/tests/cli/Di/FactoryDefault/Cli/GetSharedCest.php b/tests/cli/Di/FactoryDefault/Cli/GetSharedCest.php index 302117cf31f..18f0d4d81d9 100644 --- a/tests/cli/Di/FactoryDefault/Cli/GetSharedCest.php +++ b/tests/cli/Di/FactoryDefault/Cli/GetSharedCest.php @@ -14,8 +14,8 @@ namespace Phalcon\Tests\Cli\Di\FactoryDefault\Cli; use CliTester; -use Phalcon\Encryption\Crypt; use Phalcon\Di\FactoryDefault\Cli as Di; +use Phalcon\Encryption\Crypt; use Phalcon\Html\Escaper; class GetSharedCest diff --git a/tests/cli/Di/FactoryDefault/Cli/OffsetSetCest.php b/tests/cli/Di/FactoryDefault/Cli/OffsetSetCest.php index 9572b2cb7c2..acc00e93c15 100644 --- a/tests/cli/Di/FactoryDefault/Cli/OffsetSetCest.php +++ b/tests/cli/Di/FactoryDefault/Cli/OffsetSetCest.php @@ -14,8 +14,8 @@ namespace Phalcon\Tests\Cli\Di\FactoryDefault\Cli; use CliTester; -use Phalcon\Encryption\Crypt; use Phalcon\Di\FactoryDefault\Cli as Di; +use Phalcon\Encryption\Crypt; use Phalcon\Html\Escaper; class OffsetSetCest diff --git a/tests/cli/Di/FactoryDefault/Cli/ResetCest.php b/tests/cli/Di/FactoryDefault/Cli/ResetCest.php deleted file mode 100644 index 8d58ed1523d..00000000000 --- a/tests/cli/Di/FactoryDefault/Cli/ResetCest.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * 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\Cli\Di\FactoryDefault\Cli; - -use CliTester; -use Phalcon\Di\FactoryDefault\Cli as Di; - -class ResetCest -{ - /** - * Tests Phalcon\Di\FactoryDefault\Cli :: reset() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function diFactorydefaultCliReset(CliTester $I) - { - $I->wantToTest('Di\FactoryDefault\Cli - reset()'); - - // there is a DI container - $I->assertInstanceOf(Di::class, Di::getDefault()); - - $di = Di::getDefault(); - - // delete it - Di::reset(); - - $I->assertNull(Di::getDefault()); - - // set it again - Di::setDefault($di); - - $I->assertInstanceOf(Di::class, Di::getDefault()); - } -} diff --git a/tests/cli/Di/FactoryDefault/Cli/SetCest.php b/tests/cli/Di/FactoryDefault/Cli/SetCest.php index 3abe83a05a9..7f8804e63aa 100644 --- a/tests/cli/Di/FactoryDefault/Cli/SetCest.php +++ b/tests/cli/Di/FactoryDefault/Cli/SetCest.php @@ -14,8 +14,8 @@ namespace Phalcon\Tests\Cli\Di\FactoryDefault\Cli; use CliTester; -use Phalcon\Encryption\Crypt; use Phalcon\Di\FactoryDefault\Cli as Di; +use Phalcon\Encryption\Crypt; use Phalcon\Html\Escaper; class SetCest diff --git a/tests/cli/Di/FactoryDefault/Cli/SetDefaultCest.php b/tests/cli/Di/FactoryDefault/Cli/SetDefaultCest.php deleted file mode 100644 index a1f10e62279..00000000000 --- a/tests/cli/Di/FactoryDefault/Cli/SetDefaultCest.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * 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\Cli\Di\FactoryDefault\Cli; - -use CliTester; -use Phalcon\Di\FactoryDefault\Cli as Di; - -class SetDefaultCest -{ - /** - * Tests Phalcon\Di\FactoryDefault\Cli :: setDefault() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function diFactorydefaultCliSetDefault(CliTester $I) - { - $I->wantToTest('Di\FactoryDefault\Cli - setDefault()'); - - // there is a DI container - $I->assertInstanceOf(Di::class, Di::getDefault()); - - $di = Di::getDefault(); - - // delete it - Di::reset(); - - $I->assertNull(Di::getDefault()); - - // set it again - Di::setDefault($di); - - $I->assertInstanceOf(Di::class, Di::getDefault()); - } -} diff --git a/tests/unit/Acl/Adapter/Memory/AddComponentAccessCest.php b/tests/unit/Acl/Adapter/Memory/AddComponentAccessCest.php index 2262b2f4805..bfe2c61536f 100644 --- a/tests/unit/Acl/Adapter/Memory/AddComponentAccessCest.php +++ b/tests/unit/Acl/Adapter/Memory/AddComponentAccessCest.php @@ -84,7 +84,7 @@ public function aclAdapterMemoryAddComponentAccessWrongAccessList(UnitTester $I) $I->expectThrowable( new Exception('Invalid value for the accessList'), function () { - $acl = new Memory(); + $acl = new Memory(); $post = new Component('Post'); $acl->addComponent($post, ['update']); diff --git a/tests/unit/Acl/Adapter/Memory/AddInheritCest.php b/tests/unit/Acl/Adapter/Memory/AddInheritCest.php index bc048ace411..b8989817d9d 100644 --- a/tests/unit/Acl/Adapter/Memory/AddInheritCest.php +++ b/tests/unit/Acl/Adapter/Memory/AddInheritCest.php @@ -150,7 +150,8 @@ function () { } /** - * Tests Phalcon\Acl\Adapter\Memory :: addInherit() - infinite loop exception + * Tests Phalcon\Acl\Adapter\Memory :: addInherit() - infinite loop + * exception * * @param UnitTester $I * diff --git a/tests/unit/Acl/Adapter/Memory/GetActiveFunctionCest.php b/tests/unit/Acl/Adapter/Memory/GetActiveFunctionCest.php index 98ec54c1102..275790b6682 100644 --- a/tests/unit/Acl/Adapter/Memory/GetActiveFunctionCest.php +++ b/tests/unit/Acl/Adapter/Memory/GetActiveFunctionCest.php @@ -63,7 +63,7 @@ public function aclAdapterMemoryGetActiveFunction(UnitTester $I) $returnedFunction = $acl->getActiveFunction(); - $class = Closure::class; + $class = Closure::class; $actual = $returnedFunction; $I->assertInstanceOf($class, $actual); diff --git a/tests/unit/Acl/Adapter/Memory/IsAllowedCest.php b/tests/unit/Acl/Adapter/Memory/IsAllowedCest.php index 521beb38771..b142b3ee06b 100644 --- a/tests/unit/Acl/Adapter/Memory/IsAllowedCest.php +++ b/tests/unit/Acl/Adapter/Memory/IsAllowedCest.php @@ -128,7 +128,10 @@ public function aclAdapterMemoryIsAllowedSameClass(UnitTester $I) 'Admin', 'User', ['update'], - function (TestRoleComponentAware $admin, TestRoleComponentAware $user) { + function ( + TestRoleComponentAware $admin, + TestRoleComponentAware $user + ) { return $admin->getUser() == $user->getUser(); } ); @@ -182,8 +185,9 @@ function () { * @author Phalcon Team * @since 2021-09-27 */ - public function aclAdapterMemoryIsAllowedFunctionMoreParameters(UnitTester $I) - { + public function aclAdapterMemoryIsAllowedFunctionMoreParameters( + UnitTester $I + ) { $I->wantToTest('Acl\Adapter\Memory - isAllowed() - more parameters'); $errorMessage = "Number of parameters in array is higher than the " @@ -239,16 +243,19 @@ function ($parameter) { * @author Phalcon Team * @since 2019-06-16 */ - public function aclAdapterMemoryIsAllowedFunctionNotEnoughParameters(UnitTester $I) - { - $I->wantToTest('Acl\Adapter\Memory - isAllowed() - not enough parameters'); + public function aclAdapterMemoryIsAllowedFunctionNotEnoughParameters( + UnitTester $I + ) { + $I->wantToTest( + 'Acl\Adapter\Memory - isAllowed() - not enough parameters' + ); $I->expectThrowable( new AclException( "You did not provide all necessary parameters for the " . "defined function when checking if 'Members' can 'update' for 'Post'." ), - function () use ($I) { + function () { $acl = new Memory(); $acl->setDefaultAction(Enum::ALLOW); @@ -335,7 +342,9 @@ function () { */ public function aclAdapterMemoryIsAllowedFireEventFalse(UnitTester $I) { - $I->wantToTest('Acl\Adapter\Memory - isAllowed() - fireEvent returns false'); + $I->wantToTest( + 'Acl\Adapter\Memory - isAllowed() - fireEvent returns false' + ); $acl = Stub::make( Memory::class, @@ -362,7 +371,9 @@ public function aclAdapterMemoryIsAllowedFireEventFalse(UnitTester $I) */ public function aclAdapterMemoryIsAllowedDocumentationExample(UnitTester $I) { - $I->wantToTest('Acl\Adapter\Memory - isAllowed() - documentation example'); + $I->wantToTest( + 'Acl\Adapter\Memory - isAllowed() - documentation example' + ); $acl = new Memory(); diff --git a/tests/unit/Acl/Component/ToStringCest.php b/tests/unit/Acl/Component/ToStringCest.php index 22a556cd410..fbe187896ba 100644 --- a/tests/unit/Acl/Component/ToStringCest.php +++ b/tests/unit/Acl/Component/ToStringCest.php @@ -38,6 +38,6 @@ public function aclComponentToString(UnitTester $I) $component = new Component('Customers'); $I->assertSame('Customers', $component->__toString()); - $I->assertSame('Customers', (string) $component); + $I->assertSame('Customers', (string)$component); } } diff --git a/tests/unit/Acl/Role/ToStringCest.php b/tests/unit/Acl/Role/ToStringCest.php index ae1ef60b5e5..ac94a5429bc 100644 --- a/tests/unit/Acl/Role/ToStringCest.php +++ b/tests/unit/Acl/Role/ToStringCest.php @@ -38,6 +38,6 @@ public function aclRoleToString(UnitTester $I) $role = new Role('Administrator'); $I->assertSame('Administrator', $role->__toString()); - $I->assertSame('Administrator', (string) $role); + $I->assertSame('Administrator', (string)$role); } } diff --git a/tests/unit/Annotations/ReflectionCest.php b/tests/unit/Annotations/ReflectionCest.php index 6aa95e85869..17aeac7e65e 100644 --- a/tests/unit/Annotations/ReflectionCest.php +++ b/tests/unit/Annotations/ReflectionCest.php @@ -22,7 +22,7 @@ class ReflectionCest /** * Executed before each test. * - * @param UnitTester $I + * @param UnitTester $I */ protected function _before(UnitTester $I) { @@ -32,7 +32,7 @@ protected function _before(UnitTester $I) /** * Tests parsing class annotations * - * @param UnitTester $I + * @param UnitTester $I * * @author Phalcon Team * @since 2016-01-26 diff --git a/tests/unit/Assets/Manager/GetSetCest.php b/tests/unit/Assets/Manager/GetSetCest.php index 4d90cdaea3e..8bfff9e0af5 100644 --- a/tests/unit/Assets/Manager/GetSetCest.php +++ b/tests/unit/Assets/Manager/GetSetCest.php @@ -34,7 +34,7 @@ public function assetsManagerGetSet(UnitTester $I) { $I->wantToTest('Assets\Manager - get()/set()'); - $manager = new Manager(new TagFactory(new Escaper())); + $manager = new Manager(new TagFactory(new Escaper())); $collection = new Collection(); $manager->set('hangout', $collection); diff --git a/tests/unit/Config/Adapter/Grouped/ConstructCest.php b/tests/unit/Config/Adapter/Grouped/ConstructCest.php index b29751522a4..873c58182f4 100644 --- a/tests/unit/Config/Adapter/Grouped/ConstructCest.php +++ b/tests/unit/Config/Adapter/Grouped/ConstructCest.php @@ -48,7 +48,7 @@ public function configAdapterGroupedConstructComplexInstance(UnitTester $I) $config = [ dataDir('assets/config/config.php'), [ - 'adapter' => 'json', + 'adapter' => 'json', 'filePath' => dataDir('assets/config/config.json'), ], [ diff --git a/tests/unit/Config/Adapter/Ini/ConstructCest.php b/tests/unit/Config/Adapter/Ini/ConstructCest.php index 4f80eb38fed..b2c9c3bb8f9 100644 --- a/tests/unit/Config/Adapter/Ini/ConstructCest.php +++ b/tests/unit/Config/Adapter/Ini/ConstructCest.php @@ -43,7 +43,7 @@ public function configAdapterIniConstruct(UnitTester $I) $this->config['database']['num6'] = true; $this->config['database']['num7'] = null; $this->config['database']['num8'] = 123; - $this->config['database']['num9'] = (float) 123.45; + $this->config['database']['num9'] = (float)123.45; $config = $this->getConfig('Ini'); diff --git a/tests/unit/Config/Config/ConfigCest.php b/tests/unit/Config/Config/ConfigCest.php index 5698184e92a..8fcdee1f7d8 100644 --- a/tests/unit/Config/Config/ConfigCest.php +++ b/tests/unit/Config/Config/ConfigCest.php @@ -107,7 +107,7 @@ public function configConfigConfigInsensitive(UnitTester $I) ], 'other' => [1, 2, 3, 4], ]; - $config = new Config($settings, false); + $config = new Config($settings, false); /** @var Config $database */ $database = $config->get('database'); diff --git a/tests/unit/Config/Config/GetCest.php b/tests/unit/Config/Config/GetCest.php index 0433409692b..d7267189a6d 100644 --- a/tests/unit/Config/Config/GetCest.php +++ b/tests/unit/Config/Config/GetCest.php @@ -49,7 +49,8 @@ public function configGet(UnitTester $I) $expected = $this->config['database']['adapter']; $actual = $config->get('database') - ->get('adapter'); + ->get('adapter') + ; $I->assertSame($expected, $actual); } } diff --git a/tests/unit/Config/Config/MergeCest.php b/tests/unit/Config/Config/MergeCest.php index d7579641e52..f6586b7c88b 100644 --- a/tests/unit/Config/Config/MergeCest.php +++ b/tests/unit/Config/Config/MergeCest.php @@ -69,7 +69,8 @@ public function configMergeConfigCases(UnitTester $I, Example $example) */ $expected = $example['expected']; $actual = $source->merge($target) - ->toArray(); + ->toArray() + ; $I->assertSame($expected, $actual); /** @@ -78,7 +79,8 @@ public function configMergeConfigCases(UnitTester $I, Example $example) $expected = $example['expected']; $target = $example['target']; $actual = $source->merge($target) - ->toArray(); + ->toArray() + ; $I->assertSame($expected, $actual); } @@ -94,7 +96,7 @@ public function configMergeExceptions(UnitTester $I) $config = new Config( [ - 'my' => 'config' + 'my' => 'config', ] ); @@ -355,22 +357,22 @@ private function getExamples(): array 'test' => 123, 'empty' => [], 'nonEmpty' => [ - 5 => 'test' - ] + 5 => 'test', + ], ], 'target' => [ 'empty' => [ - 3 => 'toEmpty' + 3 => 'toEmpty', ], ], 'expected' => [ 'test' => 123, 'empty' => [ - 3 => 'toEmpty' + 3 => 'toEmpty', ], 'nonEmpty' => [ - 5 => 'test' - ] + 5 => 'test', + ], ], ], [ @@ -379,12 +381,12 @@ private function getExamples(): array 'test' => 123, 'empty' => [], 'nonEmpty' => [ - 5 => 'test' - ] + 5 => 'test', + ], ], 'target' => [ 'nonEmpty' => [ - 3 => 'toNonEmpty' + 3 => 'toNonEmpty', ], ], 'expected' => [ @@ -392,8 +394,8 @@ private function getExamples(): array 'empty' => [], 'nonEmpty' => [ 5 => 'test', - 3 => 'toNonEmpty' - ] + 3 => 'toNonEmpty', + ], ], ], ]; diff --git a/tests/unit/Config/ConfigFactory/LoadCest.php b/tests/unit/Config/ConfigFactory/LoadCest.php index 5780a36ec0f..cfbdfe9aa6a 100644 --- a/tests/unit/Config/ConfigFactory/LoadCest.php +++ b/tests/unit/Config/ConfigFactory/LoadCest.php @@ -64,8 +64,10 @@ public function configFactoryLoadConfig(UnitTester $I) $I->assertInstanceOf($class, $ini); /** @var Ini $ini */ - $ini = (new ConfigFactory())->load($ini->get('config') - ->toArray()); + $ini = (new ConfigFactory())->load( + $ini->get('config') + ->toArray() + ); $I->assertInstanceOf($class, $ini); } diff --git a/tests/unit/Di/FactoryDefault/ConstructCest.php b/tests/unit/Di/FactoryDefault/ConstructCest.php index 0fde3286c68..517f45323cc 100644 --- a/tests/unit/Di/FactoryDefault/ConstructCest.php +++ b/tests/unit/Di/FactoryDefault/ConstructCest.php @@ -16,15 +16,15 @@ use Codeception\Example; use Phalcon\Annotations\Adapter\Memory as MemoryAnnotations; use Phalcon\Assets\Manager as ManagerAssets; +use Phalcon\Di\FactoryDefault; use Phalcon\Encryption\Crypt; use Phalcon\Encryption\Security; -use Phalcon\Di\FactoryDefault; -use Phalcon\Html\Escaper; -use Phalcon\Html\TagFactory; use Phalcon\Events\Manager as ManagerEvents; use Phalcon\Filter\Filter; use Phalcon\Flash\Direct; use Phalcon\Flash\Session; +use Phalcon\Html\Escaper; +use Phalcon\Html\TagFactory; use Phalcon\Http\Request; use Phalcon\Http\Response; use Phalcon\Http\Response\Cookies; @@ -33,8 +33,8 @@ use Phalcon\Mvc\Model\MetaData\Memory; use Phalcon\Mvc\Model\Transaction\Manager; use Phalcon\Mvc\Router; -use Phalcon\Support\HelperFactory; use Phalcon\Mvc\Url; +use Phalcon\Support\HelperFactory; use UnitTester; class ConstructCest diff --git a/tests/unit/Di/GetDICest.php b/tests/unit/Di/GetDICest.php index 43e4397fa93..8e93fe4eb34 100644 --- a/tests/unit/Di/GetDICest.php +++ b/tests/unit/Di/GetDICest.php @@ -56,9 +56,9 @@ public function diInjectableGetDIContainer(UnitTester $I) */ $std = $ic->std; - $className = get_class($ic); + $className = get_class($ic); $reflection = new ReflectionClass($className); - $prop = $reflection->getProperty('container'); + $prop = $reflection->getProperty('container'); $prop->setAccessible(true); $I->assertSame($di, $prop->getValue($ic)); @@ -82,7 +82,7 @@ public function diInjectableGetDIOtherContainer(UnitTester $I) Di::reset(); - $di = new Di(); + $di = new Di(); $other = new Di(); $other->set('std', function () { return new stdClass(); @@ -99,7 +99,7 @@ public function diInjectableGetDIOtherContainer(UnitTester $I) */ $std = $ic->std; - $className = get_class($ic); + $className = get_class($ic); $reflection = new ReflectionClass($className); $prop = $reflection->getProperty('container'); diff --git a/tests/unit/Di/GetServiceCest.php b/tests/unit/Di/GetServiceCest.php index 5044413c5be..9de5cc7920f 100644 --- a/tests/unit/Di/GetServiceCest.php +++ b/tests/unit/Di/GetServiceCest.php @@ -44,7 +44,7 @@ public function diGetService(UnitTester $I) $container = new Di(); // set a service and get it to check - $class = Service::class; + $class = Service::class; $actual = $container->set('escaper', Escaper::class); $I->assertInstanceOf($class, $actual); diff --git a/tests/unit/Di/Injectable/UnderscoreGetCest.php b/tests/unit/Di/Injectable/UnderscoreGetCest.php index b3821b45016..99fd3d9adc9 100644 --- a/tests/unit/Di/Injectable/UnderscoreGetCest.php +++ b/tests/unit/Di/Injectable/UnderscoreGetCest.php @@ -49,7 +49,7 @@ public function diInjectableUnderscoreGetIsset(UnitTester $I) $actual = $component->getDI(); $I->assertSame($container, $actual); - $class = stdClass::class; + $class = stdClass::class; $actual = $component->std; $I->assertInstanceOf($class, $actual); diff --git a/tests/unit/Di/OffsetGetCest.php b/tests/unit/Di/OffsetGetCest.php index 131d1103a84..3b7d40ce069 100644 --- a/tests/unit/Di/OffsetGetCest.php +++ b/tests/unit/Di/OffsetGetCest.php @@ -43,7 +43,7 @@ public function diOffsetGet(UnitTester $I) $container->set('escaper', Escaper::class); - $class = Escaper::class; + $class = Escaper::class; $actual = $container->offsetGet('escaper'); $I->assertInstanceOf($class, $actual); diff --git a/tests/unit/Di/SetCest.php b/tests/unit/Di/SetCest.php index 90360d688f5..3c0d2db8058 100644 --- a/tests/unit/Di/SetCest.php +++ b/tests/unit/Di/SetCest.php @@ -127,7 +127,7 @@ private function getExamples(): array 'string', 'escaper', Escaper::class, - Escaper::class + Escaper::class, ], [ 'anonymous', @@ -135,7 +135,7 @@ private function getExamples(): array function () { return new Escaper(); }, - Escaper::class + Escaper::class, ], [ 'array', @@ -143,7 +143,7 @@ function () { [ 'className' => Escaper::class, ], - Escaper::class + Escaper::class, ], ]; } diff --git a/tests/unit/Dispatcher/GetSetEventsManagerCest.php b/tests/unit/Dispatcher/GetSetEventsManagerCest.php index e18481ccbb2..6f81ab0c49c 100644 --- a/tests/unit/Dispatcher/GetSetEventsManagerCest.php +++ b/tests/unit/Dispatcher/GetSetEventsManagerCest.php @@ -37,7 +37,7 @@ public function dispatcherGetSetEventsManager(UnitTester $I) $actual = $dispatcher->getEventsManager(); $I->assertSame($manager, $actual); - $class = Manager::class; + $class = Manager::class; $I->assertInstanceOf($class, $actual); } } diff --git a/tests/unit/Dispatcher/GetSetHandlerSuffixCest.php b/tests/unit/Dispatcher/GetSetHandlerSuffixCest.php index 94a796c6d02..db7cce1fa44 100644 --- a/tests/unit/Dispatcher/GetSetHandlerSuffixCest.php +++ b/tests/unit/Dispatcher/GetSetHandlerSuffixCest.php @@ -31,7 +31,7 @@ public function dispatcherGetSetHandlerSuffix(UnitTester $I) $dispatcher = new Dispatcher(); $expected = 'Controller'; - $actual = $dispatcher->getHandlerSuffix(); + $actual = $dispatcher->getHandlerSuffix(); $I->assertSame($expected, $actual); $dispatcher->setHandlerSuffix('two'); diff --git a/tests/unit/Dispatcher/GetSetParamsCest.php b/tests/unit/Dispatcher/GetSetParamsCest.php index 3ca4df35fb3..1249fceafd9 100644 --- a/tests/unit/Dispatcher/GetSetParamsCest.php +++ b/tests/unit/Dispatcher/GetSetParamsCest.php @@ -69,7 +69,7 @@ public function dispatcherGetParamsKeptBetweenCalls(UnitTester $I) $actual = $dispatcher->getParams(); $I->assertEmpty($actual); - $params = [ + $params = [ "trace" => [], ]; $dispatcher->setParams($params); diff --git a/tests/unit/Encryption/Crypt/DecryptBase64Cest.php b/tests/unit/Encryption/Crypt/DecryptBase64Cest.php index d98afb18361..98359f8627e 100644 --- a/tests/unit/Encryption/Crypt/DecryptBase64Cest.php +++ b/tests/unit/Encryption/Crypt/DecryptBase64Cest.php @@ -93,9 +93,9 @@ public function encryptionCryptDecryptBase64DecryptSignedString(UnitTester $I) ->setKey('secret') ; - $expected = 'le text'; + $expected = 'le text'; $encrypted = $crypt->encryptBase64($expected); - $actual = $crypt->decryptBase64($encrypted); + $actual = $crypt->decryptBase64($encrypted); $I->assertSame($expected, $actual); } diff --git a/tests/unit/Encryption/Crypt/IsValidDecryptLengthCest.php b/tests/unit/Encryption/Crypt/IsValidDecryptLengthCest.php index 5be12198a0a..0c42c3c34a0 100644 --- a/tests/unit/Encryption/Crypt/IsValidDecryptLengthCest.php +++ b/tests/unit/Encryption/Crypt/IsValidDecryptLengthCest.php @@ -36,7 +36,7 @@ public function encryptionCryptGetSetKey(UnitTester $I) $crypt = new Crypt(); $crypt->setKey('1234'); - $input = uniqid(); + $input = uniqid(); $encrypted = $crypt->encrypt($input); $actual = $crypt->isValidDecryptLength($encrypted); diff --git a/tests/unit/Encryption/Security/JWT/Builder/GetTokenCest.php b/tests/unit/Encryption/Security/JWT/Builder/GetTokenCest.php index 065375ffe44..d6f390340e7 100644 --- a/tests/unit/Encryption/Security/JWT/Builder/GetTokenCest.php +++ b/tests/unit/Encryption/Security/JWT/Builder/GetTokenCest.php @@ -65,9 +65,9 @@ public function encryptionSecurityJWTBuilderGetTokenException(UnitTester $I) 'Invalid passphrase (empty)' ), function () { - $signer = new Hmac(); + $signer = new Hmac(); $builder = new Builder($signer); - $token = $builder->getToken(); + $token = $builder->getToken(); } ); } diff --git a/tests/unit/Encryption/Security/JWT/Token/Parser/ParseCest.php b/tests/unit/Encryption/Security/JWT/Token/Parser/ParseCest.php index ba2ce20ac64..2018ae720b5 100644 --- a/tests/unit/Encryption/Security/JWT/Token/Parser/ParseCest.php +++ b/tests/unit/Encryption/Security/JWT/Token/Parser/ParseCest.php @@ -66,14 +66,23 @@ public function encryptionSecurityJWTTokenParserParse(UnitTester $I) $I->assertTrue($claims->has('sub')); $I->assertSame(['my-audience'], $claims->get('aud')); - $I->assertSame($token->getClaims() - ->get('exp'), $claims->get('exp')); + $I->assertSame( + $token->getClaims() + ->get('exp'), + $claims->get('exp') + ); $I->assertSame('PH-JWT', $claims->get('jti')); - $I->assertSame($token->getClaims() - ->get('iat'), $claims->get('iat')); + $I->assertSame( + $token->getClaims() + ->get('iat'), + $claims->get('iat') + ); $I->assertSame('Phalcon JWT', $claims->get('iss')); - $I->assertSame($token->getClaims() - ->get('nbf'), $claims->get('nbf')); + $I->assertSame( + $token->getClaims() + ->get('nbf'), + $claims->get('nbf') + ); $I->assertSame('Mary had a little lamb', $claims->get('sub')); } @@ -116,14 +125,23 @@ public function encryptionSecurityJWTTokenParserParseNoSignature(UnitTester $I) $I->assertTrue($claims->has('sub')); $I->assertSame(['my-audience'], $claims->get('aud')); - $I->assertSame($token->getClaims() - ->get('exp'), $claims->get('exp')); + $I->assertSame( + $token->getClaims() + ->get('exp'), + $claims->get('exp') + ); $I->assertSame('PH-JWT', $claims->get('jti')); - $I->assertSame($token->getClaims() - ->get('iat'), $claims->get('iat')); + $I->assertSame( + $token->getClaims() + ->get('iat'), + $claims->get('iat') + ); $I->assertSame('Phalcon JWT', $claims->get('iss')); - $I->assertSame($token->getClaims() - ->get('nbf'), $claims->get('nbf')); + $I->assertSame( + $token->getClaims() + ->get('nbf'), + $claims->get('nbf') + ); $I->assertSame('Mary had a little lamb', $claims->get('sub')); $I->assertEmpty($signature->getEncoded()); @@ -175,14 +193,23 @@ public function encryptionSecurityJWTTokenParserParseAudNotAnArray(UnitTester $I $I->assertTrue($claims->has('sub')); $I->assertSame(['my-audience'], $claims->get('aud')); - $I->assertSame($token->getClaims() - ->get('exp'), $claims->get('exp')); + $I->assertSame( + $token->getClaims() + ->get('exp'), + $claims->get('exp') + ); $I->assertSame('PH-JWT', $claims->get('jti')); - $I->assertSame($token->getClaims() - ->get('iat'), $claims->get('iat')); + $I->assertSame( + $token->getClaims() + ->get('iat'), + $claims->get('iat') + ); $I->assertSame('Phalcon JWT', $claims->get('iss')); - $I->assertSame($token->getClaims() - ->get('nbf'), $claims->get('nbf')); + $I->assertSame( + $token->getClaims() + ->get('nbf'), + $claims->get('nbf') + ); $I->assertSame('Mary had a little lamb', $claims->get('sub')); } diff --git a/tests/unit/Encryption/Security/JWT/Token/Token/VerifyCest.php b/tests/unit/Encryption/Security/JWT/Token/Token/VerifyCest.php index 204cffb2877..10eb7ba1d47 100644 --- a/tests/unit/Encryption/Security/JWT/Token/Token/VerifyCest.php +++ b/tests/unit/Encryption/Security/JWT/Token/Token/VerifyCest.php @@ -14,8 +14,6 @@ use Codeception\Stub; use Phalcon\Encryption\Security\JWT\Builder; use Phalcon\Encryption\Security\JWT\Signer\Hmac; -use Phalcon\Encryption\Security\JWT\Token\Enum; -use Phalcon\Encryption\Security\JWT\Validator; use UnitTester; class VerifyCest @@ -88,7 +86,7 @@ public function encryptionSecurityJWTTokenTokenVerifyWrongAlgo(UnitTester $I) ->getToken() ; - $signer = Stub::make( + $signer = Stub::make( Hmac::class, [ 'getAlgHeader' => 'xyz', diff --git a/tests/unit/Events/Manager/DetachAllCest.php b/tests/unit/Events/Manager/DetachAllCest.php index 90bb55dc381..8dfa9e08868 100644 --- a/tests/unit/Events/Manager/DetachAllCest.php +++ b/tests/unit/Events/Manager/DetachAllCest.php @@ -60,9 +60,9 @@ public function eventsManagerDetachAllWithType(UnitTester $I) { $I->wantToTest('Events\Manager - detachAll() - with type'); - $uploadType = 'some:upload'; + $uploadType = 'some:upload'; $downloadType = 'some:download'; - $manager = new Manager(); + $manager = new Manager(); $manager->attach( $uploadType, function () { diff --git a/tests/unit/Filter/SanitizeCest.php b/tests/unit/Filter/SanitizeCest.php index 458c57a549d..7b5d2632a34 100644 --- a/tests/unit/Filter/SanitizeCest.php +++ b/tests/unit/Filter/SanitizeCest.php @@ -48,7 +48,7 @@ public function filterSanitize(UnitTester $I, Example $example) 'Filter\Sanitize\* = %s - %s : "%s"', $class, $label, - (is_array($source) ? implode(":", $source) : (string) $source) + (is_array($source) ? implode(":", $source) : (string)$source) ) ); diff --git a/tests/unit/Flash/Direct/OutputCest.php b/tests/unit/Flash/Direct/OutputCest.php index 083353d8ae8..5863f260226 100644 --- a/tests/unit/Flash/Direct/OutputCest.php +++ b/tests/unit/Flash/Direct/OutputCest.php @@ -18,7 +18,6 @@ use Phalcon\Html\Escaper; use UnitTester; -use function MongoDB\BSON\toRelaxedExtendedJSON; use function ob_end_clean; use function ob_get_contents; use function ob_start; diff --git a/tests/unit/Flash/Session/OutputCest.php b/tests/unit/Flash/Session/OutputCest.php index c5e1db0d18a..b7c7b2f66a3 100644 --- a/tests/unit/Flash/Session/OutputCest.php +++ b/tests/unit/Flash/Session/OutputCest.php @@ -128,7 +128,7 @@ public function flashSessionOutputWithCustomTemplate(UnitTester $I) $flash = new Session(); $flash->setDI($this->container); - $message1 = uniqid('m-'); + $message1 = uniqid('m-'); $customTemplate = "