diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2d059851..1cb5cf24 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,21 +1,26 @@ -name: main +name: Stubs code validation + on: pull_request: push: + jobs: build: runs-on: ubuntu-latest + strategy: matrix: - php-versions: [7.3, 7.4] + php-versions: [7.4, 8.0] + steps: - uses: actions/checkout@v2 + - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, zip, psr - tools: prestissimo + - name: Get Composer Cache Directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" @@ -25,9 +30,13 @@ jobs: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - - name: composer install - run: composer install --no-interaction --no-ansi --no-progress --no-suggest + + - run: composer install --no-interaction --no-ansi --no-progress + - name: run psalm + if: always() run: vendor/bin/psalm + - name: run phpcs + if: always() run: vendor/bin/phpcs diff --git a/README.md b/README.md index ad9917f2..e86a5de9 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,12 @@ -# Phalcon IDE Stubs v4 +# Phalcon IDE Stubs -This repo provide the most complete Phalcon Framework stubs which enables autocompletion in modern IDEs. +This repo provides the most complete Phalcon Framework stubs which enables autocompletion in modern IDEs. ## Installing via Composer -1. Install Composer in a common location or in your project: - ```bash - curl -s http://getcomposer.org/installer | php - ``` - -2. Install via composer: - ```bash - composer require --dev phalcon/ide-stubs - ``` - -3. Setup your IDE. +```bash +composer require --dev phalcon/ide-stubs +``` ## Installing via Git @@ -41,4 +33,3 @@ Support us with a monthly donation and help us continue our activities. [[Become ## License Phalcon IDE Stubs is open-sourced software licensed under the New BSD License. © Phalcon Framework Team and contributors. - diff --git a/composer.json b/composer.json index 06b08cfb..c68cdbd6 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "forum": "https://forum.phalcon.io/" }, "require": { - "php": ">=7.2.0" + "php": ">=7.4" }, "require-dev": { "squizlabs/php_codesniffer": "3.*", diff --git a/composer.lock b/composer.lock index 6c61c5c9..53cca273 100644 --- a/composer.lock +++ b/composer.lock @@ -4,21 +4,21 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "810d9bc61ae4fe5487f474ce57be9d2b", + "content-hash": "7d008907c09cfa7e75a685aad7e3dc66", "packages": [], "packages-dev": [ { "name": "amphp/amp", - "version": "v2.5.1", + "version": "v2.5.2", "source": { "type": "git", "url": "https://github.com/amphp/amp.git", - "reference": "ecdc3c476b3ccff02f8e5d5bcc04f7ccfd18751c" + "reference": "efca2b32a7580087adb8aabbff6be1dc1bb924a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/amp/zipball/ecdc3c476b3ccff02f8e5d5bcc04f7ccfd18751c", - "reference": "ecdc3c476b3ccff02f8e5d5bcc04f7ccfd18751c", + "url": "https://api.github.com/repos/amphp/amp/zipball/efca2b32a7580087adb8aabbff6be1dc1bb924a9", + "reference": "efca2b32a7580087adb8aabbff6be1dc1bb924a9", "shasum": "" }, "require": { @@ -86,7 +86,7 @@ "support": { "irc": "irc://irc.freenode.org/amphp", "issues": "https://github.com/amphp/amp/issues", - "source": "https://github.com/amphp/amp/tree/v2.5.1" + "source": "https://github.com/amphp/amp/tree/v2.5.2" }, "funding": [ { @@ -94,20 +94,20 @@ "type": "github" } ], - "time": "2020-11-03T16:23:45+00:00" + "time": "2021-01-10T17:06:37+00:00" }, { "name": "amphp/byte-stream", - "version": "v1.8.0", + "version": "v1.8.1", "source": { "type": "git", "url": "https://github.com/amphp/byte-stream.git", - "reference": "f0c20cf598a958ba2aa8c6e5a71c697d652c7088" + "reference": "acbd8002b3536485c997c4e019206b3f10ca15bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/byte-stream/zipball/f0c20cf598a958ba2aa8c6e5a71c697d652c7088", - "reference": "f0c20cf598a958ba2aa8c6e5a71c697d652c7088", + "url": "https://api.github.com/repos/amphp/byte-stream/zipball/acbd8002b3536485c997c4e019206b3f10ca15bd", + "reference": "acbd8002b3536485c997c4e019206b3f10ca15bd", "shasum": "" }, "require": { @@ -163,22 +163,28 @@ "support": { "irc": "irc://irc.freenode.org/amphp", "issues": "https://github.com/amphp/byte-stream/issues", - "source": "https://github.com/amphp/byte-stream/tree/master" + "source": "https://github.com/amphp/byte-stream/tree/v1.8.1" }, - "time": "2020-06-29T18:35:05+00:00" + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2021-03-30T17:13:30+00:00" }, { "name": "composer/package-versions-deprecated", - "version": "1.11.99.1", + "version": "1.11.99.2", "source": { "type": "git", "url": "https://github.com/composer/package-versions-deprecated.git", - "reference": "7413f0b55a051e89485c5cb9f765fe24bb02a7b6" + "reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/7413f0b55a051e89485c5cb9f765fe24bb02a7b6", - "reference": "7413f0b55a051e89485c5cb9f765fe24bb02a7b6", + "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/c6522afe5540d5fc46675043d3ed5a45a740b27c", + "reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c", "shasum": "" }, "require": { @@ -222,7 +228,7 @@ "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", "support": { "issues": "https://github.com/composer/package-versions-deprecated/issues", - "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.1" + "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.2" }, "funding": [ { @@ -238,27 +244,27 @@ "type": "tidelift" } ], - "time": "2020-11-11T10:22:58+00:00" + "time": "2021-05-24T07:46:03+00:00" }, { "name": "composer/semver", - "version": "3.2.3", + "version": "3.2.5", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "bcf1cc72150023e1c3dca4a353296b4c83deea41" + "reference": "31f3ea725711245195f62e54ffa402d8ef2fdba9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/bcf1cc72150023e1c3dca4a353296b4c83deea41", - "reference": "bcf1cc72150023e1c3dca4a353296b4c83deea41", + "url": "https://api.github.com/repos/composer/semver/zipball/31f3ea725711245195f62e54ffa402d8ef2fdba9", + "reference": "31f3ea725711245195f62e54ffa402d8ef2fdba9", "shasum": "" }, "require": { "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "phpstan/phpstan": "^0.12.19", + "phpstan/phpstan": "^0.12.54", "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", @@ -303,7 +309,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.2.3" + "source": "https://github.com/composer/semver/tree/3.2.5" }, "funding": [ { @@ -319,20 +325,20 @@ "type": "tidelift" } ], - "time": "2020-11-12T11:25:27+00:00" + "time": "2021-05-24T12:41:47+00:00" }, { "name": "composer/xdebug-handler", - "version": "1.4.4", + "version": "1.4.6", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "6e076a124f7ee146f2487554a94b6a19a74887ba" + "reference": "f27e06cd9675801df441b3656569b328e04aa37c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6e076a124f7ee146f2487554a94b6a19a74887ba", - "reference": "6e076a124f7ee146f2487554a94b6a19a74887ba", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f27e06cd9675801df441b3656569b328e04aa37c", + "reference": "f27e06cd9675801df441b3656569b328e04aa37c", "shasum": "" }, "require": { @@ -340,7 +346,8 @@ "psr/log": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" + "phpstan/phpstan": "^0.12.55", + "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", "autoload": { @@ -366,7 +373,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/1.4.4" + "source": "https://github.com/composer/xdebug-handler/tree/1.4.6" }, "funding": [ { @@ -382,7 +389,7 @@ "type": "tidelift" } ], - "time": "2020-10-24T12:39:10+00:00" + "time": "2021-03-25T17:01:18+00:00" }, { "name": "dnoegel/php-xdg-base-dir", @@ -423,25 +430,25 @@ }, { "name": "felixfbecker/advanced-json-rpc", - "version": "v3.1.1", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/felixfbecker/php-advanced-json-rpc.git", - "reference": "0ed363f8de17d284d479ec813c9ad3f6834b5c40" + "reference": "06f0b06043c7438959dbdeed8bb3f699a19be22e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/0ed363f8de17d284d479ec813c9ad3f6834b5c40", - "reference": "0ed363f8de17d284d479ec813c9ad3f6834b5c40", + "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/06f0b06043c7438959dbdeed8bb3f699a19be22e", + "reference": "06f0b06043c7438959dbdeed8bb3f699a19be22e", "shasum": "" }, "require": { "netresearch/jsonmapper": "^1.0 || ^2.0", - "php": ">=7.0", - "phpdocumentor/reflection-docblock": "^4.0.0 || ^5.0.0" + "php": "^7.1 || ^8.0", + "phpdocumentor/reflection-docblock": "^4.3.4 || ^5.0.0" }, "require-dev": { - "phpunit/phpunit": "^6.0.0" + "phpunit/phpunit": "^7.0 || ^8.0" }, "type": "library", "autoload": { @@ -462,22 +469,22 @@ "description": "A more advanced JSONRPC implementation", "support": { "issues": "https://github.com/felixfbecker/php-advanced-json-rpc/issues", - "source": "https://github.com/felixfbecker/php-advanced-json-rpc/tree/master" + "source": "https://github.com/felixfbecker/php-advanced-json-rpc/tree/v3.2.0" }, - "time": "2020-03-11T15:21:41+00:00" + "time": "2021-01-10T17:48:47+00:00" }, { "name": "felixfbecker/language-server-protocol", - "version": "v1.5.0", + "version": "1.5.1", "source": { "type": "git", "url": "https://github.com/felixfbecker/php-language-server-protocol.git", - "reference": "85e83cacd2ed573238678c6875f8f0d7ec699541" + "reference": "9d846d1f5cf101deee7a61c8ba7caa0a975cd730" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/85e83cacd2ed573238678c6875f8f0d7ec699541", - "reference": "85e83cacd2ed573238678c6875f8f0d7ec699541", + "url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/9d846d1f5cf101deee7a61c8ba7caa0a975cd730", + "reference": "9d846d1f5cf101deee7a61c8ba7caa0a975cd730", "shasum": "" }, "require": { @@ -518,9 +525,9 @@ ], "support": { "issues": "https://github.com/felixfbecker/php-language-server-protocol/issues", - "source": "https://github.com/felixfbecker/php-language-server-protocol/tree/v1.5.0" + "source": "https://github.com/felixfbecker/php-language-server-protocol/tree/1.5.1" }, - "time": "2020-10-23T13:55:30+00:00" + "time": "2021-02-22T14:02:09+00:00" }, { "name": "netresearch/jsonmapper", @@ -575,16 +582,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.10.2", + "version": "v4.10.5", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "658f1be311a230e0907f5dfe0213742aff0596de" + "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/658f1be311a230e0907f5dfe0213742aff0596de", - "reference": "658f1be311a230e0907f5dfe0213742aff0596de", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4432ba399e47c66624bc73c8c0f811e5c109576f", + "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f", "shasum": "" }, "require": { @@ -625,9 +632,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.10.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.10.5" }, - "time": "2020-09-26T10:30:38+00:00" + "time": "2021-05-03T19:11:20+00:00" }, { "name": "openlss/lib-array2xml", @@ -842,27 +849,22 @@ }, { "name": "psr/container", - "version": "1.0.0", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=7.2.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -875,7 +877,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common Container Interface (PHP FIG PSR-11)", @@ -889,22 +891,22 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/master" + "source": "https://github.com/php-fig/container/tree/1.1.1" }, - "time": "2017-02-14T16:28:37+00:00" + "time": "2021-03-05T17:36:06+00:00" }, { "name": "psr/log", - "version": "1.1.3", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", "shasum": "" }, "require": { @@ -928,7 +930,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for logging libraries", @@ -939,9 +941,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.3" + "source": "https://github.com/php-fig/log/tree/1.1.4" }, - "time": "2020-03-23T09:12:05+00:00" + "time": "2021-05-03T11:20:27+00:00" }, { "name": "sebastian/diff", @@ -1011,16 +1013,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.5.8", + "version": "3.6.0", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "9d583721a7157ee997f235f327de038e7ea6dac4" + "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4", - "reference": "9d583721a7157ee997f235f327de038e7ea6dac4", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625", + "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625", "shasum": "" }, "require": { @@ -1063,24 +1065,25 @@ "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2020-10-23T02:01:07+00:00" + "time": "2021-04-09T00:54:41+00:00" }, { "name": "symfony/console", - "version": "v5.1.8", + "version": "v5.3.0", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "e0b2c29c0fa6a69089209bbe8fcff4df2a313d0e" + "reference": "058553870f7809087fa80fa734704a21b9bcaeb2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/e0b2c29c0fa6a69089209bbe8fcff4df2a313d0e", - "reference": "e0b2c29c0fa6a69089209bbe8fcff4df2a313d0e", + "url": "https://api.github.com/repos/symfony/console/zipball/058553870f7809087fa80fa734704a21b9bcaeb2", + "reference": "058553870f7809087fa80fa734704a21b9bcaeb2", "shasum": "" }, "require": { "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php73": "^1.8", "symfony/polyfill-php80": "^1.15", @@ -1135,10 +1138,83 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Console Component", + "description": "Eases the creation of beautiful and testable command line interfaces", + "homepage": "https://symfony.com", + "keywords": [ + "cli", + "command line", + "console", + "terminal" + ], + "support": { + "source": "https://github.com/symfony/console/tree/v5.3.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": "2021-05-26T17:43:10+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "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": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/console/tree/v5.1.8" + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0" }, "funding": [ { @@ -1154,20 +1230,20 @@ "type": "tidelift" } ], - "time": "2020-10-24T12:01:57+00:00" + "time": "2021-03-23T23:28:01+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.20.0", + "version": "v1.23.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41" + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f4ba089a5b6366e453971d3aad5fe8e897b37f41", - "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", "shasum": "" }, "require": { @@ -1179,7 +1255,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.23-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1217,7 +1293,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" }, "funding": [ { @@ -1233,20 +1309,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-02-19T12:13:01+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.20.0", + "version": "v1.23.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "c7cf3f858ec7d70b89559d6e6eb1f7c2517d479c" + "reference": "24b72c6baa32c746a4d0840147c9715e42bb68ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/c7cf3f858ec7d70b89559d6e6eb1f7c2517d479c", - "reference": "c7cf3f858ec7d70b89559d6e6eb1f7c2517d479c", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/24b72c6baa32c746a4d0840147c9715e42bb68ab", + "reference": "24b72c6baa32c746a4d0840147c9715e42bb68ab", "shasum": "" }, "require": { @@ -1258,7 +1334,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.23-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1298,7 +1374,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.0" }, "funding": [ { @@ -1314,20 +1390,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-05-27T09:17:38+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.20.0", + "version": "v1.23.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "727d1096295d807c309fb01a851577302394c897" + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/727d1096295d807c309fb01a851577302394c897", - "reference": "727d1096295d807c309fb01a851577302394c897", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8", + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8", "shasum": "" }, "require": { @@ -1339,7 +1415,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.23-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1382,7 +1458,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0" }, "funding": [ { @@ -1398,20 +1474,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-02-19T12:13:01+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.20.0", + "version": "v1.23.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "39d483bdf39be819deabf04ec872eb0b2410b531" + "reference": "2df51500adbaebdc4c38dea4c89a2e131c45c8a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/39d483bdf39be819deabf04ec872eb0b2410b531", - "reference": "39d483bdf39be819deabf04ec872eb0b2410b531", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2df51500adbaebdc4c38dea4c89a2e131c45c8a1", + "reference": "2df51500adbaebdc4c38dea4c89a2e131c45c8a1", "shasum": "" }, "require": { @@ -1423,7 +1499,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.23-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1462,7 +1538,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.0" }, "funding": [ { @@ -1478,20 +1554,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-05-27T09:27:20+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.20.0", + "version": "v1.23.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "8ff431c517be11c78c48a39a66d37431e26a6bed" + "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/8ff431c517be11c78c48a39a66d37431e26a6bed", - "reference": "8ff431c517be11c78c48a39a66d37431e26a6bed", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fba8933c384d6476ab14fb7b8526e5287ca7e010", + "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010", "shasum": "" }, "require": { @@ -1500,7 +1576,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.23-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1541,7 +1617,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.23.0" }, "funding": [ { @@ -1557,20 +1633,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-02-19T12:13:01+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.20.0", + "version": "v1.23.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "e70aa8b064c5b72d3df2abd5ab1e90464ad009de" + "reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/e70aa8b064c5b72d3df2abd5ab1e90464ad009de", - "reference": "e70aa8b064c5b72d3df2abd5ab1e90464ad009de", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/eca0bf41ed421bed1b57c4958bab16aa86b757d0", + "reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0", "shasum": "" }, "require": { @@ -1579,7 +1655,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.23-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1624,7 +1700,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.0" }, "funding": [ { @@ -1640,25 +1716,25 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-02-19T12:13:01+00:00" }, { "name": "symfony/service-contracts", - "version": "v2.2.0", + "version": "v2.4.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1" + "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/d15da7ba4957ffb8f1747218be9e1a121fd298a1", - "reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb", + "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb", "shasum": "" }, "require": { "php": ">=7.2.5", - "psr/container": "^1.0" + "psr/container": "^1.1" }, "suggest": { "symfony/service-implementation": "" @@ -1666,7 +1742,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-main": "2.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -1703,7 +1779,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/master" + "source": "https://github.com/symfony/service-contracts/tree/v2.4.0" }, "funding": [ { @@ -1719,20 +1795,20 @@ "type": "tidelift" } ], - "time": "2020-09-07T11:33:47+00:00" + "time": "2021-04-01T10:43:52+00:00" }, { "name": "symfony/string", - "version": "v5.1.8", + "version": "v5.3.0", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "a97573e960303db71be0dd8fda9be3bca5e0feea" + "reference": "a9a0f8b6aafc5d2d1c116dcccd1573a95153515b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/a97573e960303db71be0dd8fda9be3bca5e0feea", - "reference": "a97573e960303db71be0dd8fda9be3bca5e0feea", + "url": "https://api.github.com/repos/symfony/string/zipball/a9a0f8b6aafc5d2d1c116dcccd1573a95153515b", + "reference": "a9a0f8b6aafc5d2d1c116dcccd1573a95153515b", "shasum": "" }, "require": { @@ -1775,7 +1851,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony String component", + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", "homepage": "https://symfony.com", "keywords": [ "grapheme", @@ -1786,7 +1862,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.1.8" + "source": "https://github.com/symfony/string/tree/v5.3.0" }, "funding": [ { @@ -1802,7 +1878,7 @@ "type": "tidelift" } ], - "time": "2020-10-24T12:01:57+00:00" + "time": "2021-05-26T17:43:10+00:00" }, { "name": "vimeo/psalm", @@ -1913,12 +1989,12 @@ "version": "1.9.1", "source": { "type": "git", - "url": "https://github.com/webmozart/assert.git", + "url": "https://github.com/webmozarts/assert.git", "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", "shasum": "" }, @@ -1956,33 +2032,32 @@ "validate" ], "support": { - "issues": "https://github.com/webmozart/assert/issues", - "source": "https://github.com/webmozart/assert/tree/master" + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.9.1" }, "time": "2020-07-08T17:02:28+00:00" }, { "name": "webmozart/glob", - "version": "4.1.0", + "version": "4.3.0", "source": { "type": "git", - "url": "https://github.com/webmozart/glob.git", - "reference": "3cbf63d4973cf9d780b93d2da8eec7e4a9e63bbe" + "url": "https://github.com/webmozarts/glob.git", + "reference": "06358fafde0f32edb4513f4fd88fe113a40c90ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/glob/zipball/3cbf63d4973cf9d780b93d2da8eec7e4a9e63bbe", - "reference": "3cbf63d4973cf9d780b93d2da8eec7e4a9e63bbe", + "url": "https://api.github.com/repos/webmozarts/glob/zipball/06358fafde0f32edb4513f4fd88fe113a40c90ee", + "reference": "06358fafde0f32edb4513f4fd88fe113a40c90ee", "shasum": "" }, "require": { - "php": "^5.3.3|^7.0", + "php": "^7.3 || ^8.0.0", "webmozart/path-util": "^2.2" }, "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1", - "symfony/filesystem": "^2.5" + "phpunit/phpunit": "^8.0", + "symfony/filesystem": "^5.1" }, "type": "library", "extra": { @@ -2007,10 +2082,10 @@ ], "description": "A PHP implementation of Ant's glob.", "support": { - "issues": "https://github.com/webmozart/glob/issues", - "source": "https://github.com/webmozart/glob/tree/master" + "issues": "https://github.com/webmozarts/glob/issues", + "source": "https://github.com/webmozarts/glob/tree/4.3.0" }, - "time": "2015-12-29T11:14:33+00:00" + "time": "2021-01-21T06:17:15+00:00" }, { "name": "webmozart/path-util", @@ -2069,8 +2144,8 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.2.0" + "php": ">=7.4" }, "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.1.0" } diff --git a/src/Phalcon/Acl/Adapter/AbstractAdapter.php b/src/Acl/Adapter/AbstractAdapter.php similarity index 92% rename from src/Phalcon/Acl/Adapter/AbstractAdapter.php rename to src/Acl/Adapter/AbstractAdapter.php index cf73bf0b..e3eeeedd 100644 --- a/src/Phalcon/Acl/Adapter/AbstractAdapter.php +++ b/src/Acl/Adapter/AbstractAdapter.php @@ -102,9 +102,9 @@ public function getDefaultAction(): int /** * Returns the internal event manager * - * @return ManagerInterface + * @return ManagerInterface|null */ - public function getEventsManager(): ManagerInterface + public function getEventsManager(): ?ManagerInterface { } @@ -114,7 +114,7 @@ public function getEventsManager(): ManagerInterface * @param int $defaultAccess * @return void */ - public function setDefaultAction(int $defaultAccess) + public function setDefaultAction(int $defaultAccess): void { } @@ -124,7 +124,7 @@ public function setDefaultAction(int $defaultAccess) * @param \Phalcon\Events\ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): void { } } diff --git a/src/Phalcon/Acl/Adapter/AdapterInterface.php b/src/Acl/Adapter/AdapterInterface.php similarity index 92% rename from src/Phalcon/Acl/Adapter/AdapterInterface.php rename to src/Acl/Adapter/AdapterInterface.php index 93231786..15e35855 100644 --- a/src/Phalcon/Acl/Adapter/AdapterInterface.php +++ b/src/Acl/Adapter/AdapterInterface.php @@ -19,10 +19,10 @@ interface AdapterInterface * Do a role inherit from another existing role * * @param string $roleName - * @param mixed $roleToInherit + * @param mixed $roleToInherits * @return bool */ - public function addInherit(string $roleName, $roleToInherit): bool; + public function addInherit(string $roleName, $roleToInherits): bool; /** * Adds a role to the ACL list. Second parameter lets to inherit access data @@ -40,11 +40,11 @@ public function addRole($role, $accessInherits = null): bool; * Access names can be a particular action, by example * search, update, delete, etc or a list of them * - * @param mixed $componentObject + * @param mixed $componentValue * @param mixed $accessList * @return bool */ - public function addComponent($componentObject, $accessList): bool; + public function addComponent($componentValue, $accessList): bool; /** * Adds access to components @@ -64,7 +64,7 @@ public function addComponentAccess(string $componentName, $accessList): bool; * @param mixed $func * @return void */ - public function allow(string $roleName, string $componentName, $access, $func = null); + public function allow(string $roleName, string $componentName, $access, $func = null): void; /** * Deny access to a role on a component @@ -75,7 +75,7 @@ public function allow(string $roleName, string $componentName, $access, $func = * @param mixed $func * @return void */ - public function deny(string $roleName, string $componentName, $access, $func = null); + public function deny(string $roleName, string $componentName, $access, $func = null): void; /** * Removes an access from a component @@ -84,7 +84,7 @@ public function deny(string $roleName, string $componentName, $access, $func = n * @param mixed $accessList * @return void */ - public function dropComponentAccess(string $componentName, $accessList); + public function dropComponentAccess(string $componentName, $accessList): void; /** * Returns the access which the list is checking if some role can access it @@ -171,7 +171,7 @@ public function isRole(string $roleName): bool; * @param int $defaultAccess * @return void */ - public function setDefaultAction(int $defaultAccess); + public function setDefaultAction(int $defaultAccess): void; /** * Sets the default access level (Phalcon\Acl\Enum::ALLOW or Phalcon\Acl\Enum::DENY) @@ -181,5 +181,5 @@ public function setDefaultAction(int $defaultAccess); * @param int $defaultAccess * @return void */ - public function setNoArgumentsDefaultAction(int $defaultAccess); + public function setNoArgumentsDefaultAction(int $defaultAccess): void; } diff --git a/src/Phalcon/Acl/Adapter/Memory.php b/src/Acl/Adapter/Memory.php similarity index 98% rename from src/Phalcon/Acl/Adapter/Memory.php rename to src/Acl/Adapter/Memory.php index c29cd66b..5be2a10f 100644 --- a/src/Phalcon/Acl/Adapter/Memory.php +++ b/src/Acl/Adapter/Memory.php @@ -307,7 +307,7 @@ public function addRole($role, $accessInherits = null): bool * @param mixed $func * @return void */ - public function allow(string $roleName, string $componentName, $access, $func = null) + public function allow(string $roleName, string $componentName, $access, $func = null): void { } @@ -334,7 +334,7 @@ public function allow(string $roleName, string $componentName, $access, $func = * @param mixed $func * @return void */ - public function deny(string $roleName, string $componentName, $access, $func = null) + public function deny(string $roleName, string $componentName, $access, $func = null): void { } @@ -345,7 +345,7 @@ public function deny(string $roleName, string $componentName, $access, $func = n * @param mixed $accessList * @return void */ - public function dropComponentAccess(string $componentName, $accessList) + public function dropComponentAccess(string $componentName, $accessList): void { } @@ -426,7 +426,7 @@ public function isComponent(string $componentName): bool * @param int $defaultAccess * @return void */ - public function setNoArgumentsDefaultAction(int $defaultAccess) + public function setNoArgumentsDefaultAction(int $defaultAccess): void { } @@ -440,7 +440,7 @@ public function setNoArgumentsDefaultAction(int $defaultAccess) * @param mixed $func * @return void */ - private function allowOrDeny(string $roleName, string $componentName, $access, $action, $func = null) + private function allowOrDeny(string $roleName, string $componentName, $access, $action, $func = null): void { } diff --git a/src/Phalcon/Acl/Component.php b/src/Acl/Component.php similarity index 100% rename from src/Phalcon/Acl/Component.php rename to src/Acl/Component.php diff --git a/src/Phalcon/Acl/ComponentAware.php b/src/Acl/ComponentAware.php similarity index 100% rename from src/Phalcon/Acl/ComponentAware.php rename to src/Acl/ComponentAware.php diff --git a/src/Phalcon/Acl/ComponentInterface.php b/src/Acl/ComponentInterface.php similarity index 100% rename from src/Phalcon/Acl/ComponentInterface.php rename to src/Acl/ComponentInterface.php diff --git a/src/Phalcon/Acl/Enum.php b/src/Acl/Enum.php similarity index 100% rename from src/Phalcon/Acl/Enum.php rename to src/Acl/Enum.php diff --git a/src/Phalcon/Acl/Exception.php b/src/Acl/Exception.php similarity index 100% rename from src/Phalcon/Acl/Exception.php rename to src/Acl/Exception.php diff --git a/src/Phalcon/Acl/Role.php b/src/Acl/Role.php similarity index 100% rename from src/Phalcon/Acl/Role.php rename to src/Acl/Role.php diff --git a/src/Phalcon/Acl/RoleAware.php b/src/Acl/RoleAware.php similarity index 100% rename from src/Phalcon/Acl/RoleAware.php rename to src/Acl/RoleAware.php diff --git a/src/Phalcon/Acl/RoleInterface.php b/src/Acl/RoleInterface.php similarity index 100% rename from src/Phalcon/Acl/RoleInterface.php rename to src/Acl/RoleInterface.php diff --git a/src/Phalcon/Annotations/Adapter/AbstractAdapter.php b/src/Annotations/Adapter/AbstractAdapter.php similarity index 98% rename from src/Phalcon/Annotations/Adapter/AbstractAdapter.php rename to src/Annotations/Adapter/AbstractAdapter.php index 97373f18..52306733 100644 --- a/src/Phalcon/Annotations/Adapter/AbstractAdapter.php +++ b/src/Annotations/Adapter/AbstractAdapter.php @@ -22,7 +22,7 @@ abstract class AbstractAdapter implements \Phalcon\Annotations\Adapter\AdapterIn /** * @var array */ - protected $annotations = array(); + protected $annotations = []; /** * @var Reader diff --git a/src/Phalcon/Annotations/Adapter/AdapterInterface.php b/src/Annotations/Adapter/AdapterInterface.php similarity index 100% rename from src/Phalcon/Annotations/Adapter/AdapterInterface.php rename to src/Annotations/Adapter/AdapterInterface.php diff --git a/src/Phalcon/Annotations/Adapter/Apcu.php b/src/Annotations/Adapter/Apcu.php similarity index 91% rename from src/Phalcon/Annotations/Adapter/Apcu.php rename to src/Annotations/Adapter/Apcu.php index 7b9bea29..0834f9d8 100644 --- a/src/Phalcon/Annotations/Adapter/Apcu.php +++ b/src/Annotations/Adapter/Apcu.php @@ -39,7 +39,7 @@ class Apcu extends \Phalcon\Annotations\Adapter\AbstractAdapter * * Phalcon\Annotations\Adapter\Apcu constructor */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } @@ -47,7 +47,7 @@ public function __construct(array $options = array()) * Reads parsed annotations from APCu * * @param string $key - * @return bool|\Phalcon\Annotations\Reflection + * @return 0|Reflection */ public function read(string $key) { diff --git a/src/Phalcon/Annotations/Adapter/Memory.php b/src/Annotations/Adapter/Memory.php similarity index 89% rename from src/Phalcon/Annotations/Adapter/Memory.php rename to src/Annotations/Adapter/Memory.php index 99130421..da87d80f 100644 --- a/src/Phalcon/Annotations/Adapter/Memory.php +++ b/src/Annotations/Adapter/Memory.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Annotations\Adapter; -use Phalcon\Annotations\Reflection; - /** * Stores the parsed annotations in memory. This adapter is the suitable * development/testing @@ -27,7 +25,7 @@ class Memory extends \Phalcon\Annotations\Adapter\AbstractAdapter * Reads parsed annotations from memory * * @param string $key - * @return bool|\Phalcon\Annotations\Reflection + * @return 0|Reflection */ public function read(string $key) { @@ -40,7 +38,7 @@ public function read(string $key) * @param \Phalcon\Annotations\Reflection $data * @return void */ - public function write(string $key, \Phalcon\Annotations\Reflection $data) + public function write(string $key, \Phalcon\Annotations\Reflection $data): void { } } diff --git a/src/Phalcon/Annotations/Adapter/Stream.php b/src/Annotations/Adapter/Stream.php similarity index 84% rename from src/Phalcon/Annotations/Adapter/Stream.php rename to src/Annotations/Adapter/Stream.php index e2140f32..3d4ec6b9 100644 --- a/src/Phalcon/Annotations/Adapter/Stream.php +++ b/src/Annotations/Adapter/Stream.php @@ -9,10 +9,6 @@ */ namespace Phalcon\Annotations\Adapter; -use Phalcon\Annotations\Reflection; -use Phalcon\Annotations\Exception; -use RuntimeException; - /** * Stores the parsed annotations in files. This adapter is suitable for production * @@ -41,7 +37,7 @@ class Stream extends \Phalcon\Annotations\Adapter\AbstractAdapter * * Phalcon\Annotations\Adapter\Stream constructor */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } @@ -49,7 +45,7 @@ public function __construct(array $options = array()) * Reads parsed annotations from files * * @param string $key - * @return bool|int|\Phalcon\Annotations\Reflection + * @return 0|1|Reflection */ public function read(string $key) { @@ -62,7 +58,7 @@ public function read(string $key) * @param \Phalcon\Annotations\Reflection $data * @return void */ - public function write(string $key, \Phalcon\Annotations\Reflection $data) + public function write(string $key, \Phalcon\Annotations\Reflection $data): void { } } diff --git a/src/Phalcon/Annotations/Annotation.php b/src/Annotations/Annotation.php similarity index 96% rename from src/Phalcon/Annotations/Annotation.php rename to src/Annotations/Annotation.php index 5f7602c2..d4479f46 100644 --- a/src/Phalcon/Annotations/Annotation.php +++ b/src/Annotations/Annotation.php @@ -19,14 +19,14 @@ class Annotation * * @var array */ - protected $arguments = array(); + protected $arguments = []; /** * Annotation ExprArguments * * @var array */ - protected $exprArguments = array(); + protected $exprArguments = []; /** * Annotation Name diff --git a/src/Phalcon/Annotations/AnnotationsFactory.php b/src/Annotations/AnnotationsFactory.php similarity index 86% rename from src/Phalcon/Annotations/AnnotationsFactory.php rename to src/Annotations/AnnotationsFactory.php index 0ede1c60..d59549d6 100644 --- a/src/Phalcon/Annotations/AnnotationsFactory.php +++ b/src/Annotations/AnnotationsFactory.php @@ -18,12 +18,15 @@ class AnnotationsFactory extends AbstractFactory { + protected $exception = 'Phalcon\\\\Annotations\\\\Exception'; + + /** * AdapterFactory constructor. * * @param array $services */ - public function __construct(array $services = array()) + public function __construct(array $services = []) { } @@ -55,7 +58,7 @@ public function load($config) * @param string $name * @return AdapterInterface */ - public function newInstance(string $name, array $options = array()): AdapterInterface + public function newInstance(string $name, array $options = []): AdapterInterface { } diff --git a/src/Phalcon/Annotations/Collection.php b/src/Annotations/Collection.php similarity index 94% rename from src/Phalcon/Annotations/Collection.php rename to src/Annotations/Collection.php index de4b4d50..510f836e 100644 --- a/src/Phalcon/Annotations/Collection.php +++ b/src/Annotations/Collection.php @@ -44,7 +44,7 @@ class Collection implements \Iterator, \Countable * * @param array $reflectionData */ - public function __construct(array $reflectionData = array()) + public function __construct(array $reflectionData = []) { } @@ -60,7 +60,7 @@ public function count(): int /** * Returns the current annotation in the iterator * - * @return bool|Annotation + * @return 0|Annotation */ public function current() { @@ -119,7 +119,7 @@ public function key(): int * * @return void */ - public function next() + public function next(): void { } @@ -128,7 +128,7 @@ public function next() * * @return void */ - public function rewind() + public function rewind(): void { } diff --git a/src/Phalcon/Annotations/Exception.php b/src/Annotations/Exception.php similarity index 100% rename from src/Phalcon/Annotations/Exception.php rename to src/Annotations/Exception.php diff --git a/src/Phalcon/Annotations/Reader.php b/src/Annotations/Reader.php similarity index 97% rename from src/Phalcon/Annotations/Reader.php rename to src/Annotations/Reader.php index 21eeb9d4..ddccab04 100644 --- a/src/Phalcon/Annotations/Reader.php +++ b/src/Annotations/Reader.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Annotations; -use ReflectionClass; - /** * Parses docblocks returning an array with the found annotations */ diff --git a/src/Phalcon/Annotations/ReaderInterface.php b/src/Annotations/ReaderInterface.php similarity index 100% rename from src/Phalcon/Annotations/ReaderInterface.php rename to src/Annotations/ReaderInterface.php diff --git a/src/Phalcon/Annotations/Reflection.php b/src/Annotations/Reflection.php similarity index 84% rename from src/Phalcon/Annotations/Reflection.php rename to src/Annotations/Reflection.php index f1285b35..cfccdc0b 100644 --- a/src/Phalcon/Annotations/Reflection.php +++ b/src/Annotations/Reflection.php @@ -29,19 +29,28 @@ */ class Reflection { - + /** + * @var array + * TODO: Make always array + */ protected $classAnnotations; - + /** + * @var array + * TODO: Make always array + */ protected $methodAnnotations; - + /** + * @var array + * TODO: Make always array + */ protected $propertyAnnotations; /** * @var array */ - protected $reflectionData; + protected $reflectionData = []; /** @@ -49,14 +58,14 @@ class Reflection * * @param array $reflectionData */ - public function __construct(array $reflectionData = array()) + public function __construct(array $reflectionData = []) { } /** * Returns the annotations found in the class docblock * - * @return bool|Collection + * @return 0|Collection */ public function getClassAnnotations() { diff --git a/src/Phalcon/Application/AbstractApplication.php b/src/Application/AbstractApplication.php similarity index 86% rename from src/Phalcon/Application/AbstractApplication.php rename to src/Application/AbstractApplication.php index 1c1ccdd1..aeb78742 100644 --- a/src/Phalcon/Application/AbstractApplication.php +++ b/src/Application/AbstractApplication.php @@ -19,24 +19,24 @@ abstract class AbstractApplication extends Injectable implements \Phalcon\Events\EventsAwareInterface { /** - * @var DiInterface + * @var DiInterface|null */ - protected $container; + protected $container = null; /** - * @var string + * @var string|null */ - protected $defaultModule; + protected $defaultModule = null; /** - * @var null | ManagerInterface + * @var ManagerInterface|null */ - protected $eventsManager; + protected $eventsManager = null; /** * @var array */ - protected $modules = array(); + protected $modules = []; /** @@ -60,18 +60,17 @@ public function getDefaultModule(): string /** * Returns the internal event manager * - * @return ManagerInterface + * @return ManagerInterface|null */ - public function getEventsManager(): ManagerInterface + public function getEventsManager(): ?ManagerInterface { } /** * Gets the module definition registered in the application via module name * - * @param string $name - * - * @return array + * @param string $name * + * @return array|mixed */ public function getModule(string $name): array { @@ -128,7 +127,7 @@ public function setDefaultModule(string $defaultModule): AbstractApplication * @param \Phalcon\Events\ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): void { } } diff --git a/src/Phalcon/Application/Exception.php b/src/Application/Exception.php similarity index 100% rename from src/Phalcon/Application/Exception.php rename to src/Application/Exception.php diff --git a/src/Phalcon/Assets/Asset.php b/src/Assets/Asset.php similarity index 97% rename from src/Phalcon/Assets/Asset.php rename to src/Assets/Asset.php index 59669813..c1597f7f 100644 --- a/src/Phalcon/Assets/Asset.php +++ b/src/Assets/Asset.php @@ -163,7 +163,7 @@ public function setVersion(string $version) * @param string $version * @param bool $autoVersion */ - public function __construct(string $type, string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) + public function __construct(string $type, string $path, bool $local = true, bool $filter = true, array $attributes = [], string $version = null, bool $autoVersion = false) { } diff --git a/src/Phalcon/Assets/Asset/Css.php b/src/Assets/Asset/Css.php similarity index 86% rename from src/Phalcon/Assets/Asset/Css.php rename to src/Assets/Asset/Css.php index a730da27..7e066b1a 100644 --- a/src/Phalcon/Assets/Asset/Css.php +++ b/src/Assets/Asset/Css.php @@ -25,7 +25,7 @@ class Css extends \Phalcon\Assets\Asset * @param string $version * @param bool $autoVersion */ - public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) + public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = [], string $version = null, bool $autoVersion = false) { } } diff --git a/src/Phalcon/Assets/Asset/Js.php b/src/Assets/Asset/Js.php similarity index 86% rename from src/Phalcon/Assets/Asset/Js.php rename to src/Assets/Asset/Js.php index 7de3a9e8..2dacee46 100644 --- a/src/Phalcon/Assets/Asset/Js.php +++ b/src/Assets/Asset/Js.php @@ -25,7 +25,7 @@ class Js extends \Phalcon\Assets\Asset * @param string $version * @param bool $autoVersion */ - public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) + public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = [], string $version = null, bool $autoVersion = false) { } } diff --git a/src/Phalcon/Assets/AssetInterface.php b/src/Assets/AssetInterface.php similarity index 100% rename from src/Phalcon/Assets/AssetInterface.php rename to src/Assets/AssetInterface.php diff --git a/src/Phalcon/Assets/Collection.php b/src/Assets/Collection.php similarity index 97% rename from src/Phalcon/Assets/Collection.php rename to src/Assets/Collection.php index c202bc09..11e5bacc 100644 --- a/src/Phalcon/Assets/Collection.php +++ b/src/Assets/Collection.php @@ -17,12 +17,12 @@ class Collection implements \Countable, \Iterator /** * @var array */ - protected $assets = array(); + protected $assets = []; /** * @var array */ - protected $attributes = array(); + protected $attributes = []; /** * Should version be determined from file modification time @@ -34,12 +34,12 @@ class Collection implements \Countable, \Iterator /** * @var array */ - protected $codes = array(); + protected $codes = []; /** * @var array */ - protected $filters = array(); + protected $filters = []; /** * @var array @@ -381,7 +381,7 @@ public function key(): int * * @return void */ - public function next() + public function next(): void { } @@ -390,7 +390,7 @@ public function next() * * @return void */ - public function rewind() + public function rewind(): void { } diff --git a/src/Phalcon/Assets/Exception.php b/src/Assets/Exception.php similarity index 100% rename from src/Phalcon/Assets/Exception.php rename to src/Assets/Exception.php diff --git a/src/Phalcon/Assets/FilterInterface.php b/src/Assets/FilterInterface.php similarity index 100% rename from src/Phalcon/Assets/FilterInterface.php rename to src/Assets/FilterInterface.php diff --git a/src/Phalcon/Assets/Filters/Cssmin.php b/src/Assets/Filters/Cssmin.php similarity index 100% rename from src/Phalcon/Assets/Filters/Cssmin.php rename to src/Assets/Filters/Cssmin.php diff --git a/src/Phalcon/Assets/Filters/Jsmin.php b/src/Assets/Filters/Jsmin.php similarity index 100% rename from src/Phalcon/Assets/Filters/Jsmin.php rename to src/Assets/Filters/Jsmin.php diff --git a/src/Phalcon/Assets/Filters/None.php b/src/Assets/Filters/None.php similarity index 94% rename from src/Phalcon/Assets/Filters/None.php rename to src/Assets/Filters/None.php index ba7c59c9..a5e19df9 100644 --- a/src/Phalcon/Assets/Filters/None.php +++ b/src/Assets/Filters/None.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Assets\Filters; -use Phalcon\Assets\FilterInterface; - /** * Returns the content without make any modification to the original source */ diff --git a/src/Phalcon/Assets/Inline.php b/src/Assets/Inline.php similarity index 97% rename from src/Phalcon/Assets/Inline.php rename to src/Assets/Inline.php index 8a76055b..d6fd08d2 100644 --- a/src/Phalcon/Assets/Inline.php +++ b/src/Assets/Inline.php @@ -75,7 +75,7 @@ public function getType(): string * @param bool $filter * @param array $attributes */ - public function __construct(string $type, string $content, bool $filter = true, array $attributes = array()) + public function __construct(string $type, string $content, bool $filter = true, array $attributes = []) { } diff --git a/src/Phalcon/Assets/Inline/Css.php b/src/Assets/Inline/Css.php similarity index 100% rename from src/Phalcon/Assets/Inline/Css.php rename to src/Assets/Inline/Css.php diff --git a/src/Phalcon/Assets/Inline/Js.php b/src/Assets/Inline/Js.php similarity index 100% rename from src/Phalcon/Assets/Inline/Js.php rename to src/Assets/Inline/Js.php diff --git a/src/Phalcon/Assets/Manager.php b/src/Assets/Manager.php similarity index 92% rename from src/Phalcon/Assets/Manager.php rename to src/Assets/Manager.php index 8507aaab..f56a6aa5 100644 --- a/src/Phalcon/Assets/Manager.php +++ b/src/Assets/Manager.php @@ -9,12 +9,6 @@ */ namespace Phalcon\Assets; -use Phalcon\Tag; -use Phalcon\Assets\Asset\Js as AssetJs; -use Phalcon\Assets\Asset\Css as AssetCss; -use Phalcon\Assets\Inline\Css as InlineCss; -use Phalcon\Assets\Inline\Js as InlineJs; -use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; /** @@ -24,15 +18,17 @@ */ class Manager extends AbstractInjectionAware { - - protected $collections; + /** + * @var array + */ + protected $collections = []; /** * Options configure * * @var array */ - protected $options; + protected $options = []; /** * @var bool @@ -45,7 +41,7 @@ class Manager extends AbstractInjectionAware * * @param array $options */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } @@ -94,12 +90,12 @@ public function addAssetByType(string $type, Asset $asset): Manager * @param string $path * @param mixed $local * @param bool $filter - * @param mixed $attributes + * @param array $attributes * @param string $version * @param bool $autoVersion * @return Manager */ - public function addCss(string $path, $local = true, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Manager + public function addCss(string $path, $local = true, bool $filter = true, array $attributes = [], string $version = null, bool $autoVersion = false): Manager { } @@ -159,12 +155,12 @@ public function addInlineJs(string $content, $filter = true, $attributes = null) * @param string $path * @param mixed $local * @param bool $filter - * @param mixed $attributes + * @param array $attributes * @param string $version * @param bool $autoVersion * @return Manager */ - public function addJs(string $path, $local = true, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Manager + public function addJs(string $path, $local = true, bool $filter = true, array $attributes = [], string $version = null, bool $autoVersion = false): Manager { } @@ -259,7 +255,7 @@ public function getOptions(): array /** * Traverses a collection calling the callback to generate its HTML * - * @param callback $callback + * @param Collection $callback * @param string $type * @param Collection $collection * @return string|null diff --git a/src/Phalcon/Cache.php b/src/Cache.php similarity index 97% rename from src/Phalcon/Cache.php rename to src/Cache.php index cf660ec4..8bd70919 100644 --- a/src/Phalcon/Cache.php +++ b/src/Cache.php @@ -157,10 +157,10 @@ public function setMultiple($values, $ttl = null): bool /** * Checks the key. If it contains invalid characters an exception is thrown * - * @param mixed $key + * @param string $key * @return void */ - protected function checkKey($key) + protected function checkKey(string $key): void { } @@ -170,7 +170,7 @@ protected function checkKey($key) * @param mixed $keys * @return void */ - protected function checkKeys($keys) + protected function checkKeys($keys): void { } } diff --git a/src/Phalcon/Cache/Adapter/AdapterInterface.php b/src/Cache/Adapter/AdapterInterface.php similarity index 100% rename from src/Phalcon/Cache/Adapter/AdapterInterface.php rename to src/Cache/Adapter/AdapterInterface.php diff --git a/src/Phalcon/Cache/Adapter/Apcu.php b/src/Cache/Adapter/Apcu.php similarity index 100% rename from src/Phalcon/Cache/Adapter/Apcu.php rename to src/Cache/Adapter/Apcu.php diff --git a/src/Phalcon/Cache/Adapter/Libmemcached.php b/src/Cache/Adapter/Libmemcached.php similarity index 87% rename from src/Phalcon/Cache/Adapter/Libmemcached.php rename to src/Cache/Adapter/Libmemcached.php index a00deb4a..43526134 100644 --- a/src/Phalcon/Cache/Adapter/Libmemcached.php +++ b/src/Cache/Adapter/Libmemcached.php @@ -10,7 +10,6 @@ namespace Phalcon\Cache\Adapter; use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; -use Phalcon\Storage\Adapter\Libmemcached as StorageLibmemcached; /** * Libmemcached adapter diff --git a/src/Phalcon/Cache/Adapter/Memory.php b/src/Cache/Adapter/Memory.php similarity index 89% rename from src/Phalcon/Cache/Adapter/Memory.php rename to src/Cache/Adapter/Memory.php index 41619081..4cbe2d5e 100644 --- a/src/Phalcon/Cache/Adapter/Memory.php +++ b/src/Cache/Adapter/Memory.php @@ -10,7 +10,6 @@ namespace Phalcon\Cache\Adapter; use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; -use Phalcon\Storage\Adapter\Memory as StorageMemory; /** * Memory adapter diff --git a/src/Phalcon/Cache/Adapter/Redis.php b/src/Cache/Adapter/Redis.php similarity index 89% rename from src/Phalcon/Cache/Adapter/Redis.php rename to src/Cache/Adapter/Redis.php index f9551cec..c3c8ce7a 100644 --- a/src/Phalcon/Cache/Adapter/Redis.php +++ b/src/Cache/Adapter/Redis.php @@ -10,7 +10,6 @@ namespace Phalcon\Cache\Adapter; use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; -use Phalcon\Storage\Adapter\Redis as StorageRedis; /** * Redis adapter diff --git a/src/Phalcon/Cache/Adapter/Stream.php b/src/Cache/Adapter/Stream.php similarity index 89% rename from src/Phalcon/Cache/Adapter/Stream.php rename to src/Cache/Adapter/Stream.php index 376e7a73..7002ae87 100644 --- a/src/Phalcon/Cache/Adapter/Stream.php +++ b/src/Cache/Adapter/Stream.php @@ -10,7 +10,6 @@ namespace Phalcon\Cache\Adapter; use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; -use Phalcon\Storage\Adapter\Stream as StorageStream; /** * Stream adapter diff --git a/src/Phalcon/Cache/AdapterFactory.php b/src/Cache/AdapterFactory.php similarity index 89% rename from src/Phalcon/Cache/AdapterFactory.php rename to src/Cache/AdapterFactory.php index 794a10d7..89530b91 100644 --- a/src/Phalcon/Cache/AdapterFactory.php +++ b/src/Cache/AdapterFactory.php @@ -18,6 +18,9 @@ */ class AdapterFactory extends AbstractFactory { + + protected $exception = 'Phalcon\\\\Cache\\\\Exception\\\\Exception'; + /** * @var SerializerFactory */ @@ -30,7 +33,7 @@ class AdapterFactory extends AbstractFactory * @param \Phalcon\Storage\SerializerFactory $factory * @param array $services */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $services = array()) + public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $services = []) { } @@ -60,7 +63,7 @@ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, * @param string $name * @return AdapterInterface */ - public function newInstance(string $name, array $options = array()): AdapterInterface + public function newInstance(string $name, array $options = []): AdapterInterface { } diff --git a/src/Phalcon/Cache/CacheFactory.php b/src/Cache/CacheFactory.php similarity index 96% rename from src/Phalcon/Cache/CacheFactory.php rename to src/Cache/CacheFactory.php index ad026d3d..2991470d 100644 --- a/src/Phalcon/Cache/CacheFactory.php +++ b/src/Cache/CacheFactory.php @@ -91,7 +91,7 @@ public function load($config) * @param string $name * @return CacheInterface */ - public function newInstance(string $name, array $options = array()): CacheInterface + public function newInstance(string $name, array $options = []): CacheInterface { } } diff --git a/src/Phalcon/Cache/Exception/Exception.php b/src/Cache/Exception/Exception.php similarity index 100% rename from src/Phalcon/Cache/Exception/Exception.php rename to src/Cache/Exception/Exception.php diff --git a/src/Phalcon/Cache/Exception/InvalidArgumentException.php b/src/Cache/Exception/InvalidArgumentException.php similarity index 100% rename from src/Phalcon/Cache/Exception/InvalidArgumentException.php rename to src/Cache/Exception/InvalidArgumentException.php diff --git a/src/Phalcon/Cli/Console.php b/src/Cli/Console.php similarity index 93% rename from src/Phalcon/Cli/Console.php rename to src/Cli/Console.php index b0b15ca9..89cff154 100644 --- a/src/Phalcon/Cli/Console.php +++ b/src/Cli/Console.php @@ -19,12 +19,12 @@ class Console extends AbstractApplication /** * @var array */ - protected $arguments = array(); + protected $arguments = []; /** * @var array */ - protected $options = array(); + protected $options = []; /** diff --git a/src/Phalcon/Cli/Console/Exception.php b/src/Cli/Console/Exception.php similarity index 100% rename from src/Phalcon/Cli/Console/Exception.php rename to src/Cli/Console/Exception.php diff --git a/src/Phalcon/Cli/Dispatcher.php b/src/Cli/Dispatcher.php similarity index 91% rename from src/Phalcon/Cli/Dispatcher.php rename to src/Cli/Dispatcher.php index aa31c964..8db05566 100644 --- a/src/Phalcon/Cli/Dispatcher.php +++ b/src/Cli/Dispatcher.php @@ -33,9 +33,7 @@ */ class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Cli\DispatcherInterface { - /** - * @var string - */ + protected $defaultHandler = 'main'; /** @@ -51,7 +49,7 @@ class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phal /** * @var array */ - protected $options = array(); + protected $options = []; /** @@ -62,7 +60,7 @@ class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phal * @param array $params * @return mixed */ - public function callActionMethod($handler, string $actionMethod, array $params = array()) + public function callActionMethod($handler, string $actionMethod, array $params = []) { } @@ -139,7 +137,7 @@ public function hasOption($option): bool * @param string $taskName * @return void */ - public function setDefaultTask(string $taskName) + public function setDefaultTask(string $taskName): void { } @@ -149,7 +147,7 @@ public function setDefaultTask(string $taskName) * @param array $options * @return void */ - public function setOptions(array $options) + public function setOptions(array $options): void { } @@ -159,7 +157,7 @@ public function setOptions(array $options) * @param string $taskName * @return void */ - public function setTaskName(string $taskName) + public function setTaskName(string $taskName): void { } @@ -169,7 +167,7 @@ public function setTaskName(string $taskName) * @param string $taskSuffix * @return void */ - public function setTaskSuffix(string $taskSuffix) + public function setTaskSuffix(string $taskSuffix): void { } diff --git a/src/Phalcon/Cli/Dispatcher/Exception.php b/src/Cli/Dispatcher/Exception.php similarity index 100% rename from src/Phalcon/Cli/Dispatcher/Exception.php rename to src/Cli/Dispatcher/Exception.php diff --git a/src/Phalcon/Cli/DispatcherInterface.php b/src/Cli/DispatcherInterface.php similarity index 87% rename from src/Phalcon/Cli/DispatcherInterface.php rename to src/Cli/DispatcherInterface.php index f4f6c0f5..cfb2bce1 100644 --- a/src/Phalcon/Cli/DispatcherInterface.php +++ b/src/Cli/DispatcherInterface.php @@ -58,7 +58,7 @@ public function getTaskSuffix(): string; * @param string $taskName * @return void */ - public function setDefaultTask(string $taskName); + public function setDefaultTask(string $taskName): void; /** * Set the options to be dispatched @@ -66,7 +66,7 @@ public function setDefaultTask(string $taskName); * @param array $options * @return void */ - public function setOptions(array $options); + public function setOptions(array $options): void; /** * Sets the task name to be dispatched @@ -74,7 +74,7 @@ public function setOptions(array $options); * @param string $taskName * @return void */ - public function setTaskName(string $taskName); + public function setTaskName(string $taskName): void; /** * Sets the default task suffix @@ -82,5 +82,5 @@ public function setTaskName(string $taskName); * @param string $taskSuffix * @return void */ - public function setTaskSuffix(string $taskSuffix); + public function setTaskSuffix(string $taskSuffix): void; } diff --git a/src/Phalcon/Cli/Router.php b/src/Cli/Router.php similarity index 84% rename from src/Phalcon/Cli/Router.php rename to src/Cli/Router.php index 40f62fe8..7af3790b 100644 --- a/src/Phalcon/Cli/Router.php +++ b/src/Cli/Router.php @@ -34,44 +34,65 @@ */ class Router extends AbstractInjectionAware { + /** + * @var string|null + */ + protected $action = null; - protected $action; - - + /** + * @var string|null + */ protected $defaultAction = null; - + /** + * @var string|null + */ protected $defaultModule = null; /** * @var array */ - protected $defaultParams = array(); - + protected $defaultParams = []; + /** + * @var string|null + */ protected $defaultTask = null; + /** + * @var RouteInterface|null + */ + protected $matchedRoute = null; - protected $matchedRoute; - - - protected $matches; - + /** + * @var array|null + * TODO: make always array + */ + protected $matches = null; - protected $module; + /** + * @var string|null + */ + protected $module = null; /** * @var array */ - protected $params = array(); - - - protected $routes; - + protected $params = []; - protected $task; + /** + * @var array + */ + protected $routes = []; + /** + * @var string|null + */ + protected $task = null; + /** + * @var bool + */ protected $wasMatched = false; @@ -148,7 +169,7 @@ public function getParams(): array * Returns a route object by its id * * @param int $id - * @return bool|\Phalcon\Cli\Router\RouteInterface + * @return 0|RouteInterface */ public function getRouteById($id) { @@ -158,7 +179,7 @@ public function getRouteById($id) * Returns a route object by its name * * @param string $name - * @return bool|\Phalcon\Cli\Router\RouteInterface + * @return 0|RouteInterface */ public function getRouteByName(string $name) { @@ -236,7 +257,7 @@ public function setDefaults(array $defaults): Router * @param string $taskName * @return void */ - public function setDefaultTask(string $taskName) + public function setDefaultTask(string $taskName): void { } diff --git a/src/Phalcon/Cli/Router/Exception.php b/src/Cli/Router/Exception.php similarity index 100% rename from src/Phalcon/Cli/Router/Exception.php rename to src/Cli/Router/Exception.php diff --git a/src/Phalcon/Cli/Router/Route.php b/src/Cli/Router/Route.php similarity index 82% rename from src/Phalcon/Cli/Router/Route.php rename to src/Cli/Router/Route.php index eb98027e..dcd68635 100644 --- a/src/Phalcon/Cli/Router/Route.php +++ b/src/Cli/Router/Route.php @@ -17,37 +17,59 @@ class Route implements \Phalcon\Cli\Router\RouteInterface const DEFAULT_DELIMITER = ' '; + /** + * @var mixed|null + */ + protected $beforeMatch = null; - protected $beforeMatch; - - - protected $compiledPattern; - - - protected $converters; + /** + * @var string|null + */ + protected $compiledPattern = null; + /** + * @var array + */ + protected $converters = []; + /** + * @var string + */ protected $delimiter; - + /** + * @var string + */ protected static $delimiterPath = self::DEFAULT_DELIMITER; + /** + * @var string|null + */ + protected $description = null; - protected $description; - - + /** + * @var string + */ protected $id; + /** + * @var string|null + */ + protected $name = null; - protected $name; - - - protected $paths; - + /** + * @var array + */ + protected $paths = []; + /** + * @var string + */ protected $pattern; - + /** + * @var int|string + */ protected static $uniqueId = 0; @@ -64,7 +86,7 @@ public function __construct(string $pattern, $paths = null) * The developer can implement any arbitrary conditions here * If the callback returns false the route is treated as not matched * - * @param callback $callback + * @param mixed $callback * @return RouteInterface */ public function beforeMatch($callback): RouteInterface @@ -100,7 +122,7 @@ public function convert(string $name, $converter): RouteInterface * @param string $delimiter * @return void */ - public static function delimiter(string $delimiter = null) + public static function delimiter(string $delimiter = null): void { } @@ -207,11 +229,11 @@ public function getRouteId(): string /** * Reconfigure the route adding a new pattern and a set of paths * - * @param array|string $paths * @param string $pattern + * @param array|string|null $paths * * @return void */ - public function reConfigure(string $pattern, $paths = null) + public function reConfigure(string $pattern, $paths = null): void { } @@ -220,7 +242,7 @@ public function reConfigure(string $pattern, $paths = null) * * @return void */ - public static function reset() + public static function reset(): void { } diff --git a/src/Phalcon/Cli/Router/RouteInterface.php b/src/Cli/Router/RouteInterface.php similarity index 93% rename from src/Phalcon/Cli/Router/RouteInterface.php rename to src/Cli/Router/RouteInterface.php index de7f9f28..4ab323af 100644 --- a/src/Phalcon/Cli/Router/RouteInterface.php +++ b/src/Cli/Router/RouteInterface.php @@ -91,17 +91,17 @@ public function getRouteId(): string; * Reconfigure the route adding a new pattern and a set of paths * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return void */ - public function reConfigure(string $pattern, $paths = null); + public function reConfigure(string $pattern, $paths = null): void; /** * Resets the internal route id generator * * @return void */ - public static function reset(); + public static function reset(): void; /** * Sets the route's description diff --git a/src/Phalcon/Cli/RouterInterface.php b/src/Cli/RouterInterface.php similarity index 91% rename from src/Phalcon/Cli/RouterInterface.php rename to src/Cli/RouterInterface.php index 29f56fa8..bd585b98 100644 --- a/src/Phalcon/Cli/RouterInterface.php +++ b/src/Cli/RouterInterface.php @@ -104,7 +104,7 @@ public function handle($arguments = null); * @param string $actionName * @return void */ - public function setDefaultAction(string $actionName); + public function setDefaultAction(string $actionName): void; /** * Sets the name of the default module @@ -112,7 +112,7 @@ public function setDefaultAction(string $actionName); * @param string $moduleName * @return void */ - public function setDefaultModule(string $moduleName); + public function setDefaultModule(string $moduleName): void; /** * Sets an array of default paths @@ -120,7 +120,7 @@ public function setDefaultModule(string $moduleName); * @param array $defaults * @return void */ - public function setDefaults(array $defaults); + public function setDefaults(array $defaults): void; /** * Sets the default task name @@ -128,7 +128,7 @@ public function setDefaults(array $defaults); * @param string $taskName * @return void */ - public function setDefaultTask(string $taskName); + public function setDefaultTask(string $taskName): void; /** * Check if the router matches any of the defined routes diff --git a/src/Phalcon/Cli/Task.php b/src/Cli/Task.php similarity index 92% rename from src/Phalcon/Cli/Task.php rename to src/Cli/Task.php index 1e918278..11e0369b 100644 --- a/src/Phalcon/Cli/Task.php +++ b/src/Cli/Task.php @@ -38,7 +38,9 @@ */ class Task extends Injectable implements \Phalcon\Cli\TaskInterface, \Phalcon\Events\EventsAwareInterface { - + /** + * @var ManagerInterface + */ protected $eventsManager; @@ -52,7 +54,7 @@ final public function __construct() /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface|null + * @return ManagerInterface|null */ public function getEventsManager(): ?ManagerInterface { @@ -64,7 +66,7 @@ public function getEventsManager(): ?ManagerInterface * @param \Phalcon\Events\ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): void { } } diff --git a/src/Phalcon/Cli/TaskInterface.php b/src/Cli/TaskInterface.php similarity index 100% rename from src/Phalcon/Cli/TaskInterface.php rename to src/Cli/TaskInterface.php diff --git a/src/Phalcon/Collection.php b/src/Collection.php similarity index 89% rename from src/Phalcon/Collection.php rename to src/Collection.php index 43d92fb6..eab41a5c 100644 --- a/src/Phalcon/Collection.php +++ b/src/Collection.php @@ -28,7 +28,7 @@ class Collection implements \ArrayAccess, \Phalcon\Collection\CollectionInterfac /** * @var array */ - protected $data = array(); + protected $data = []; /** * @var bool @@ -38,7 +38,7 @@ class Collection implements \ArrayAccess, \Phalcon\Collection\CollectionInterfac /** * @var array */ - protected $lowerKeys = array(); + protected $lowerKeys = []; /** @@ -47,7 +47,7 @@ class Collection implements \ArrayAccess, \Phalcon\Collection\CollectionInterfac * @param array $data * @param bool $insensitive */ - public function __construct(array $data = array(), bool $insensitive = true) + public function __construct(array $data = [], bool $insensitive = true) { } @@ -78,7 +78,7 @@ public function __isset(string $element): bool * @param mixed $value * @return void */ - public function __set(string $element, $value) + public function __set(string $element, $value): void { } @@ -88,7 +88,7 @@ public function __set(string $element, $value) * @param string $element * @return void */ - public function __unset(string $element) + public function __unset(string $element): void { } @@ -97,7 +97,7 @@ public function __unset(string $element) * * @return void */ - public function clear() + public function clear(): void { } @@ -163,7 +163,7 @@ public function has(string $element): bool * @param array $data * @return void */ - public function init(array $data = array()) + public function init(array $data = []): void { } @@ -206,7 +206,7 @@ public function offsetGet($element) * @param mixed $value * @return void */ - public function offsetSet($element, $value) + public function offsetSet($element, $value): void { } @@ -217,7 +217,7 @@ public function offsetSet($element, $value) * @param mixed $element * @return void */ - public function offsetUnset($element) + public function offsetUnset($element): void { } @@ -227,7 +227,7 @@ public function offsetUnset($element) * @param string $element * @return void */ - public function remove(string $element) + public function remove(string $element): void { } @@ -238,7 +238,7 @@ public function remove(string $element) * @param mixed $value * @return void */ - public function set(string $element, $value) + public function set(string $element, $value): void { } @@ -285,7 +285,7 @@ public function toJson(int $options = 79): string * @param mixed $serialized * @return void */ - public function unserialize($serialized) + public function unserialize($serialized): void { } @@ -296,7 +296,7 @@ public function unserialize($serialized) * @param mixed $value * @return void */ - protected function setData(string $element, $value) + protected function setData(string $element, $value): void { } } diff --git a/src/Phalcon/Collection/CollectionInterface.php b/src/Collection/CollectionInterface.php similarity index 85% rename from src/Phalcon/Collection/CollectionInterface.php rename to src/Collection/CollectionInterface.php index 73c7554f..219152a0 100644 --- a/src/Phalcon/Collection/CollectionInterface.php +++ b/src/Collection/CollectionInterface.php @@ -34,18 +34,18 @@ public function __isset(string $element): bool; * @param mixed $value * @return void */ - public function __set(string $element, $value); + public function __set(string $element, $value): void; /** * @param string $element * @return void */ - public function __unset(string $element); + public function __unset(string $element): void; /** * @return void */ - public function clear(); + public function clear(): void; /** * @param string $element @@ -76,20 +76,20 @@ public function has(string $element): bool; * @param array $data * @return void */ - public function init(array $data = array()); + public function init(array $data = []): void; /** * @param string $element * @return void */ - public function remove(string $element); + public function remove(string $element): void; /** * @param string $element * @param mixed $value * @return void */ - public function set(string $element, $value); + public function set(string $element, $value): void; /** * @return array diff --git a/src/Phalcon/Collection/Exception.php b/src/Collection/Exception.php similarity index 100% rename from src/Phalcon/Collection/Exception.php rename to src/Collection/Exception.php diff --git a/src/Phalcon/Collection/ReadOnly.php b/src/Collection/ReadOnly.php similarity index 86% rename from src/Phalcon/Collection/ReadOnly.php rename to src/Collection/ReadOnly.php index 28ca4011..c75e5eaa 100644 --- a/src/Phalcon/Collection/ReadOnly.php +++ b/src/Collection/ReadOnly.php @@ -23,7 +23,7 @@ class ReadOnly extends Collection * @param string $element * @return void */ - public function remove(string $element) + public function remove(string $element): void { } @@ -34,7 +34,7 @@ public function remove(string $element) * @param mixed $value * @return void */ - public function set(string $element, $value) + public function set(string $element, $value): void { } } diff --git a/src/Phalcon/Config.php b/src/Config.php similarity index 97% rename from src/Phalcon/Config.php rename to src/Config.php index e5ba14d7..05fb7938 100644 --- a/src/Phalcon/Config.php +++ b/src/Config.php @@ -42,7 +42,7 @@ class Config extends Collection implements \Phalcon\Config\ConfigInterface const DEFAULT_PATH_DELIMITER = '.'; /** - * @var string + * @var string|null */ protected $pathDelimiter = null; @@ -137,7 +137,7 @@ final protected function internalMerge(array $source, array $target): array * @param mixed $value * @return void */ - protected function setData($element, $value) + protected function setData($element, $value): void { } } diff --git a/src/Phalcon/Config/Adapter/Grouped.php b/src/Config/Adapter/Grouped.php similarity index 100% rename from src/Phalcon/Config/Adapter/Grouped.php rename to src/Config/Adapter/Grouped.php diff --git a/src/Phalcon/Config/Adapter/Ini.php b/src/Config/Adapter/Ini.php similarity index 97% rename from src/Phalcon/Config/Adapter/Ini.php rename to src/Config/Adapter/Ini.php index 2d94f022..0aa25da0 100644 --- a/src/Phalcon/Config/Adapter/Ini.php +++ b/src/Config/Adapter/Ini.php @@ -71,7 +71,7 @@ public function __construct(string $filePath, $mode = null) * implementation. * * @param mixed $ini - * @return bool|null|double|int|string + * @return bool|double|int|string|null */ protected function cast($ini) { diff --git a/src/Phalcon/Config/Adapter/Json.php b/src/Config/Adapter/Json.php similarity index 95% rename from src/Phalcon/Config/Adapter/Json.php rename to src/Config/Adapter/Json.php index f3595078..4c4b1e3f 100644 --- a/src/Phalcon/Config/Adapter/Json.php +++ b/src/Config/Adapter/Json.php @@ -10,7 +10,6 @@ namespace Phalcon\Config\Adapter; use Phalcon\Config; -use Phalcon\Helper\Json as JsonHelper; /** * Reads JSON files and converts them to Phalcon\Config objects. diff --git a/src/Phalcon/Config/Adapter/Php.php b/src/Config/Adapter/Php.php similarity index 100% rename from src/Phalcon/Config/Adapter/Php.php rename to src/Config/Adapter/Php.php diff --git a/src/Phalcon/Config/Adapter/Yaml.php b/src/Config/Adapter/Yaml.php similarity index 97% rename from src/Phalcon/Config/Adapter/Yaml.php rename to src/Config/Adapter/Yaml.php index 07961a2c..b4713fba 100644 --- a/src/Phalcon/Config/Adapter/Yaml.php +++ b/src/Config/Adapter/Yaml.php @@ -10,7 +10,6 @@ namespace Phalcon\Config\Adapter; use Phalcon\Config; -use Phalcon\Config\Exception; /** * Reads YAML files and converts them to Phalcon\Config objects. diff --git a/src/Phalcon/Config/ConfigFactory.php b/src/Config/ConfigFactory.php similarity index 93% rename from src/Phalcon/Config/ConfigFactory.php rename to src/Config/ConfigFactory.php index b8f6d661..01f9a0d5 100644 --- a/src/Phalcon/Config/ConfigFactory.php +++ b/src/Config/ConfigFactory.php @@ -29,12 +29,15 @@ class ConfigFactory extends AbstractFactory { + protected $exception = 'Phalcon\\\\Config\\\\Exception'; + + /** * ConfigFactory constructor. * * @param array $services */ - public function __construct(array $services = array()) + public function __construct(array $services = []) { } diff --git a/src/Phalcon/Config/ConfigInterface.php b/src/Config/ConfigInterface.php similarity index 100% rename from src/Phalcon/Config/ConfigInterface.php rename to src/Config/ConfigInterface.php diff --git a/src/Phalcon/Config/Exception.php b/src/Config/Exception.php similarity index 100% rename from src/Phalcon/Config/Exception.php rename to src/Config/Exception.php diff --git a/src/Phalcon/Container.php b/src/Container.php similarity index 100% rename from src/Phalcon/Container.php rename to src/Container.php diff --git a/src/Phalcon/Crypt.php b/src/Crypt.php similarity index 98% rename from src/Phalcon/Crypt.php rename to src/Crypt.php index ecc21978..5ff78964 100644 --- a/src/Phalcon/Crypt.php +++ b/src/Crypt.php @@ -347,7 +347,7 @@ public function useSigning(bool $useSigning): CryptInterface * @param string $cipher * @return void */ - protected function assertCipherIsAvailable(string $cipher) + protected function assertCipherIsAvailable(string $cipher): void { } @@ -357,7 +357,7 @@ protected function assertCipherIsAvailable(string $cipher) * @param string $hashAlgo * @return void */ - protected function assertHashAlgorithmAvailable(string $hashAlgo) + protected function assertHashAlgorithmAvailable(string $hashAlgo): void { } @@ -376,7 +376,7 @@ protected function getIvLength(string $cipher): int * * @return void */ - protected function initializeAvailableCiphers() + protected function initializeAvailableCiphers(): void { } diff --git a/src/Phalcon/Crypt/CryptInterface.php b/src/Crypt/CryptInterface.php similarity index 100% rename from src/Phalcon/Crypt/CryptInterface.php rename to src/Crypt/CryptInterface.php diff --git a/src/Phalcon/Crypt/Exception.php b/src/Crypt/Exception.php similarity index 100% rename from src/Phalcon/Crypt/Exception.php rename to src/Crypt/Exception.php diff --git a/src/Phalcon/Crypt/Mismatch.php b/src/Crypt/Mismatch.php similarity index 100% rename from src/Phalcon/Crypt/Mismatch.php rename to src/Crypt/Mismatch.php diff --git a/src/Phalcon/DataMapper/Pdo/Connection.php b/src/DataMapper/Pdo/Connection.php similarity index 86% rename from src/Phalcon/DataMapper/Pdo/Connection.php rename to src/DataMapper/Pdo/Connection.php index d03e7147..ce22f087 100644 --- a/src/Phalcon/DataMapper/Pdo/Connection.php +++ b/src/DataMapper/Pdo/Connection.php @@ -25,7 +25,7 @@ class Connection extends AbstractConnection /** * @var array */ - protected $arguments = array(); + protected $arguments = []; /** @@ -41,7 +41,7 @@ class Connection extends AbstractConnection * @param array $queries * @param ProfilerInterface $profiler */ - public function __construct(string $dsn, string $username = null, string $password = null, array $options = array(), array $queries = array(), \Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface $profiler = null) + public function __construct(string $dsn, string $username = null, string $password = null, array $options = [], array $queries = [], \Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface $profiler = null) { } @@ -59,7 +59,7 @@ public function __debugInfo(): array * * @return void */ - public function connect() + public function connect(): void { } @@ -68,7 +68,7 @@ public function connect() * * @return void */ - public function disconnect() + public function disconnect(): void { } } diff --git a/src/Phalcon/DataMapper/Pdo/Connection/AbstractConnection.php b/src/DataMapper/Pdo/Connection/AbstractConnection.php similarity index 93% rename from src/Phalcon/DataMapper/Pdo/Connection/AbstractConnection.php rename to src/DataMapper/Pdo/Connection/AbstractConnection.php index 49779664..84e98270 100644 --- a/src/Phalcon/DataMapper/Pdo/Connection/AbstractConnection.php +++ b/src/DataMapper/Pdo/Connection/AbstractConnection.php @@ -23,7 +23,7 @@ abstract class AbstractConnection implements \Phalcon\DataMapper\Pdo\Connection\ConnectionInterface { /** - * @var PDO + * @var \PDO */ protected $pdo; @@ -72,14 +72,14 @@ public function commit(): bool * * @return void */ - abstract public function connect(); + abstract public function connect(): void; /** * Disconnects from the database. * * @return void */ - abstract public function disconnect(); + abstract public function disconnect(): void; /** * Gets the most recent error code. @@ -119,7 +119,7 @@ public function exec(string $statement): int * * @return int */ - public function fetchAffected(string $statement, array $values = array()): int + public function fetchAffected(string $statement, array $values = []): int { } @@ -132,7 +132,7 @@ public function fetchAffected(string $statement, array $values = array()): int * * @return array */ - public function fetchAll(string $statement, array $values = array()): array + public function fetchAll(string $statement, array $values = []): array { } @@ -150,7 +150,7 @@ public function fetchAll(string $statement, array $values = array()): array * * @return array */ - public function fetchAssoc(string $statement, array $values = array()): array + public function fetchAssoc(string $statement, array $values = []): array { } @@ -163,7 +163,7 @@ public function fetchAssoc(string $statement, array $values = array()): array * * @return array */ - public function fetchColumn(string $statement, array $values = array(), int $column = 0): array + public function fetchColumn(string $statement, array $values = [], int $column = 0): array { } @@ -178,7 +178,7 @@ public function fetchColumn(string $statement, array $values = array(), int $col * * @return array */ - public function fetchGroup(string $statement, array $values = array(), int $flags = \PDO::FETCH_ASSOC): array + public function fetchGroup(string $statement, array $values = [], int $flags = \PDO::FETCH_ASSOC): array { } @@ -199,7 +199,7 @@ public function fetchGroup(string $statement, array $values = array(), int $flag * @return object * @param string $className */ - public function fetchObject(string $statement, array $values = array(), string $className = 'stdClass', array $arguments = array()) + public function fetchObject(string $statement, array $values = [], string $className = 'stdClass', array $arguments = []) { } @@ -221,7 +221,7 @@ public function fetchObject(string $statement, array $values = array(), string $ * @return array * @param string $className */ - public function fetchObjects(string $statement, array $values = array(), string $className = 'stdClass', array $arguments = array()): array + public function fetchObjects(string $statement, array $values = [], string $className = 'stdClass', array $arguments = []): array { } @@ -233,7 +233,7 @@ public function fetchObjects(string $statement, array $values = array(), string * * @return array */ - public function fetchOne(string $statement, array $values = array()): array + public function fetchOne(string $statement, array $values = []): array { } @@ -246,7 +246,7 @@ public function fetchOne(string $statement, array $values = array()): array * * @return array */ - public function fetchPairs(string $statement, array $values = array()): array + public function fetchPairs(string $statement, array $values = []): array { } @@ -258,7 +258,7 @@ public function fetchPairs(string $statement, array $values = array()): array * * @return mixed */ - public function fetchValue(string $statement, array $values = array()) + public function fetchValue(string $statement, array $values = []) { } @@ -363,7 +363,7 @@ public function lastInsertId(string $name = null): string * * @return \PDOStatement */ - public function perform(string $statement, array $values = array()): \PDOStatement + public function perform(string $statement, array $values = []): \PDOStatement { } @@ -373,9 +373,9 @@ public function perform(string $statement, array $values = array()): \PDOStateme * @param string $statement * @param array $options * - * @return PDOStatement|false + * @return \PDOStatement|false */ - public function prepare(string $statement, array $options = array()) + public function prepare(string $statement, array $options = []) { } @@ -386,7 +386,7 @@ public function prepare(string $statement, array $options = array()) * @param string $statement * @param mixed ...$fetch * - * @return PDOStatement|false + * @return \PDOStatement|false */ public function query(string $statement) { @@ -441,12 +441,11 @@ public function setProfiler(\Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface $ * Bind a value using the proper PDO::PARAM_ type. * * @param \PDOStatement $statement - * @param mixed $name - * @param mixed $arguments - * + * @param mixed $name + * @param mixed $arguments * @return void */ - protected function performBind(\PDOStatement $statement, $name, $arguments) + protected function performBind(\PDOStatement $statement, $name, $arguments): void { } @@ -460,7 +459,7 @@ protected function performBind(\PDOStatement $statement, $name, $arguments) * * @return array */ - protected function fetchData(string $method, array $arguments, string $statement, array $values = array()): array + protected function fetchData(string $method, array $arguments, string $statement, array $values = []): array { } } diff --git a/src/Phalcon/DataMapper/Pdo/Connection/ConnectionInterface.php b/src/DataMapper/Pdo/Connection/ConnectionInterface.php similarity index 92% rename from src/Phalcon/DataMapper/Pdo/Connection/ConnectionInterface.php rename to src/DataMapper/Pdo/Connection/ConnectionInterface.php index 9eb95478..4059fad6 100644 --- a/src/Phalcon/DataMapper/Pdo/Connection/ConnectionInterface.php +++ b/src/DataMapper/Pdo/Connection/ConnectionInterface.php @@ -30,14 +30,14 @@ interface ConnectionInterface extends \Phalcon\DataMapper\Pdo\Connection\PdoInte * * @return void */ - public function connect(); + public function connect(): void; /** * Disconnects from the database. * * @return void */ - public function disconnect(); + public function disconnect(): void; /** * Performs a statement and returns the number of affected rows. @@ -47,7 +47,7 @@ public function disconnect(); * * @return int */ - public function fetchAffected(string $statement, array $values = array()): int; + public function fetchAffected(string $statement, array $values = []): int; /** * Fetches a sequential array of rows from the database; the rows are @@ -58,7 +58,7 @@ public function fetchAffected(string $statement, array $values = array()): int; * * @return array */ - public function fetchAll(string $statement, array $values = array()): array; + public function fetchAll(string $statement, array $values = []): array; /** * Fetches an associative array of rows from the database; the rows are @@ -74,7 +74,7 @@ public function fetchAll(string $statement, array $values = array()): array; * * @return array */ - public function fetchAssoc(string $statement, array $values = array()): array; + public function fetchAssoc(string $statement, array $values = []): array; /** * Fetches a column of rows as a sequential array (default first one). @@ -85,7 +85,7 @@ public function fetchAssoc(string $statement, array $values = array()): array; * * @return array */ - public function fetchColumn(string $statement, array $values = array(), int $column = 0): array; + public function fetchColumn(string $statement, array $values = [], int $column = 0): array; /** * Fetches multiple from the database as an associative array. The first @@ -98,7 +98,7 @@ public function fetchColumn(string $statement, array $values = array(), int $col * * @return array */ - public function fetchGroup(string $statement, array $values = array(), int $flags = \PDO::FETCH_ASSOC): array; + public function fetchGroup(string $statement, array $values = [], int $flags = \PDO::FETCH_ASSOC): array; /** * Fetches one row from the database as an object where the column values @@ -117,7 +117,7 @@ public function fetchGroup(string $statement, array $values = array(), int $flag * @return object * @param string $className */ - public function fetchObject(string $statement, array $values = array(), string $className = 'stdClass', array $arguments = array()); + public function fetchObject(string $statement, array $values = [], string $className = 'stdClass', array $arguments = []); /** * Fetches a sequential array of rows from the database; the rows are @@ -137,7 +137,7 @@ public function fetchObject(string $statement, array $values = array(), string $ * @return array * @param string $className */ - public function fetchObjects(string $statement, array $values = array(), string $className = 'stdClass', array $arguments = array()): array; + public function fetchObjects(string $statement, array $values = [], string $className = 'stdClass', array $arguments = []): array; /** * Fetches one row from the database as an associative array. @@ -147,7 +147,7 @@ public function fetchObjects(string $statement, array $values = array(), string * * @return array */ - public function fetchOne(string $statement, array $values = array()): array; + public function fetchOne(string $statement, array $values = []): array; /** * Fetches an associative array of rows as key-value pairs (first column is @@ -158,7 +158,7 @@ public function fetchOne(string $statement, array $values = array()): array; * * @return array */ - public function fetchPairs(string $statement, array $values = array()): array; + public function fetchPairs(string $statement, array $values = []): array; /** * Fetches the very first value (i.e., first column of the first row). @@ -168,7 +168,7 @@ public function fetchPairs(string $statement, array $values = array()): array; * * @return mixed */ - public function fetchValue(string $statement, array $values = array()); + public function fetchValue(string $statement, array $values = []); /** * Return the inner PDO (if any) @@ -202,7 +202,7 @@ public function isConnected(): bool; * * @return \PDOStatement */ - public function perform(string $statement, array $values = array()): \PDOStatement; + public function perform(string $statement, array $values = []): \PDOStatement; /** * Sets the Profiler instance. diff --git a/src/Phalcon/DataMapper/Pdo/Connection/Decorated.php b/src/DataMapper/Pdo/Connection/Decorated.php similarity index 89% rename from src/Phalcon/DataMapper/Pdo/Connection/Decorated.php rename to src/DataMapper/Pdo/Connection/Decorated.php index 80a2fb1d..5556dac0 100644 --- a/src/Phalcon/DataMapper/Pdo/Connection/Decorated.php +++ b/src/DataMapper/Pdo/Connection/Decorated.php @@ -19,13 +19,15 @@ class Decorated extends \Phalcon\DataMapper\Pdo\Connection\AbstractConnection { /** + * * Constructor. * * This overrides the parent so that it can take an existing PDO instance * and decorate it with the extended methods. * - * @param \PDO $pdo + * @param \PDO $pdo * @param ProfilerInterface|null $profiler + * */ public function __construct(\PDO $pdo, \Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface $profiler = null) { @@ -36,7 +38,7 @@ public function __construct(\PDO $pdo, \Phalcon\DataMapper\Pdo\Profiler\Profiler * * @return void */ - public function connect() + public function connect(): void { } @@ -46,7 +48,7 @@ public function connect() * @throws CannotDisconnect * @return void */ - public function disconnect() + public function disconnect(): void { } } diff --git a/src/Phalcon/DataMapper/Pdo/Connection/PdoInterface.php b/src/DataMapper/Pdo/Connection/PdoInterface.php similarity index 97% rename from src/Phalcon/DataMapper/Pdo/Connection/PdoInterface.php rename to src/DataMapper/Pdo/Connection/PdoInterface.php index 8786e986..0f3ec143 100644 --- a/src/Phalcon/DataMapper/Pdo/Connection/PdoInterface.php +++ b/src/DataMapper/Pdo/Connection/PdoInterface.php @@ -96,9 +96,9 @@ public function lastInsertId(string $name = null): string; * @param string $statement * @param array $options * - * @return PDOStatement|false + * @return \PDOStatement|false */ - public function prepare(string $statement, array $options = array()); + public function prepare(string $statement, array $options = []); /** * Queries the database and returns a PDOStatement. If the profiler is @@ -107,7 +107,7 @@ public function prepare(string $statement, array $options = array()); * @param string $statement * @param mixed ...$fetch * - * @return PDOStatement|false + * @return \PDOStatement|false */ public function query(string $statement); diff --git a/src/Phalcon/DataMapper/Pdo/ConnectionLocator.php b/src/DataMapper/Pdo/ConnectionLocator.php similarity index 95% rename from src/Phalcon/DataMapper/Pdo/ConnectionLocator.php rename to src/DataMapper/Pdo/ConnectionLocator.php index 996a785a..e4f1e740 100644 --- a/src/Phalcon/DataMapper/Pdo/ConnectionLocator.php +++ b/src/DataMapper/Pdo/ConnectionLocator.php @@ -33,21 +33,21 @@ class ConnectionLocator implements \Phalcon\DataMapper\Pdo\ConnectionLocatorInte * * @var array */ - protected $read = array(); + protected $read = []; /** * A registry of Connection "write" factories/instances. * * @var array */ - protected $write = array(); + protected $write = []; /** * A collection of resolved instances * * @var array */ - private $instances = array(); + private $instances = []; /** @@ -57,7 +57,7 @@ class ConnectionLocator implements \Phalcon\DataMapper\Pdo\ConnectionLocatorInte * @param array $read * @param array $write */ - public function __construct(\Phalcon\DataMapper\Pdo\Connection\ConnectionInterface $master, array $read = array(), array $write = array()) + public function __construct(\Phalcon\DataMapper\Pdo\Connection\ConnectionInterface $master, array $read = [], array $write = []) { } diff --git a/src/Phalcon/DataMapper/Pdo/ConnectionLocatorInterface.php b/src/DataMapper/Pdo/ConnectionLocatorInterface.php similarity index 100% rename from src/Phalcon/DataMapper/Pdo/ConnectionLocatorInterface.php rename to src/DataMapper/Pdo/ConnectionLocatorInterface.php diff --git a/src/Phalcon/DataMapper/Pdo/Exception/CannotDisconnect.php b/src/DataMapper/Pdo/Exception/CannotDisconnect.php similarity index 100% rename from src/Phalcon/DataMapper/Pdo/Exception/CannotDisconnect.php rename to src/DataMapper/Pdo/Exception/CannotDisconnect.php diff --git a/src/Phalcon/DataMapper/Pdo/Exception/ConnectionNotFound.php b/src/DataMapper/Pdo/Exception/ConnectionNotFound.php similarity index 100% rename from src/Phalcon/DataMapper/Pdo/Exception/ConnectionNotFound.php rename to src/DataMapper/Pdo/Exception/ConnectionNotFound.php diff --git a/src/Phalcon/DataMapper/Pdo/Exception/Exception.php b/src/DataMapper/Pdo/Exception/Exception.php similarity index 100% rename from src/Phalcon/DataMapper/Pdo/Exception/Exception.php rename to src/DataMapper/Pdo/Exception/Exception.php diff --git a/src/DataMapper/Pdo/Profiler/MemoryLogger.php b/src/DataMapper/Pdo/Profiler/MemoryLogger.php new file mode 100644 index 00000000..2f1254cd --- /dev/null +++ b/src/DataMapper/Pdo/Profiler/MemoryLogger.php @@ -0,0 +1,110 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\DataMapper\Pdo\Profiler; + +use Psr\Log\AbstractLogger; + +/** + * A naive memory-based logger. + * + * @property array $messages + */ +class MemoryLogger extends AbstractLogger +{ + /** + * @var array + */ + protected $messages = []; + + + /** + * Returns the logged messages. + * + * @return array + */ + public function getMessages(): array + { + } + + /** + * @param string $message + * @param mixed[] $context + */ + public function emergency($message, array $context = []) + { + } + + /** + * @param string $message + * @param mixed[] $context + */ + public function alert($message, array $context = []) + { + } + + /** + * @param string $message + * @param mixed[] $context + */ + public function critical($message, array $context = []) + { + } + + /** + * @param string $message + * @param mixed[] $context + */ + public function error($message, array $context = []) + { + } + + /** + * @param string $message + * @param mixed[] $context + */ + public function warning($message, array $context = []) + { + } + + /** + * @param string $message + * @param mixed[] $context + */ + public function notice($message, array $context = []) + { + } + + /** + * @param string $message + * @param mixed[] $context + */ + public function info($message, array $context = []) + { + } + + /** + * @param string $message + * @param mixed[] $context + */ + public function debug($message, array $context = []) + { + } + + /** + * Logs a message. + * + * @param mixed $level + * @param string $message + * @param array $context + */ + public function log($level, $message, array $context = []) + { + } +} diff --git a/src/Phalcon/DataMapper/Pdo/Profiler/Profiler.php b/src/DataMapper/Pdo/Profiler/Profiler.php similarity index 96% rename from src/Phalcon/DataMapper/Pdo/Profiler/Profiler.php rename to src/DataMapper/Pdo/Profiler/Profiler.php index dc301a36..cb81f890 100644 --- a/src/Phalcon/DataMapper/Pdo/Profiler/Profiler.php +++ b/src/DataMapper/Pdo/Profiler/Profiler.php @@ -30,7 +30,7 @@ class Profiler implements \Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface /** * @var array */ - protected $context = array(); + protected $context = []; /** * @var string @@ -64,7 +64,7 @@ public function __construct(\Psr\Log\LoggerInterface $logger = null) * @param array $values * @return void */ - public function finish(string $statement = null, array $values = array()) + public function finish(string $statement = null, array $values = []): void { } @@ -143,7 +143,7 @@ public function setLogLevel(string $logLevel): ProfilerInterface * @param string $method * @return void */ - public function start(string $method) + public function start(string $method): void { } } diff --git a/src/Phalcon/DataMapper/Pdo/Profiler/ProfilerInterface.php b/src/DataMapper/Pdo/Profiler/ProfilerInterface.php similarity index 96% rename from src/Phalcon/DataMapper/Pdo/Profiler/ProfilerInterface.php rename to src/DataMapper/Pdo/Profiler/ProfilerInterface.php index c480eaa4..52e1b077 100644 --- a/src/Phalcon/DataMapper/Pdo/Profiler/ProfilerInterface.php +++ b/src/DataMapper/Pdo/Profiler/ProfilerInterface.php @@ -24,7 +24,7 @@ interface ProfilerInterface * @param array $values * @return void */ - public function finish(string $statement = null, array $values = array()); + public function finish(string $statement = null, array $values = []): void; /** * Returns the underlying logger instance. @@ -88,5 +88,5 @@ public function setLogLevel(string $logLevel): ProfilerInterface; * @param string $method * @return void */ - public function start(string $method); + public function start(string $method): void; } diff --git a/src/Phalcon/DataMapper/Query/AbstractConditions.php b/src/DataMapper/Query/AbstractConditions.php similarity index 96% rename from src/Phalcon/DataMapper/Query/AbstractConditions.php rename to src/DataMapper/Query/AbstractConditions.php index 10b49d17..b2be43f1 100644 --- a/src/Phalcon/DataMapper/Query/AbstractConditions.php +++ b/src/DataMapper/Query/AbstractConditions.php @@ -119,7 +119,7 @@ public function whereEquals(array $columnsValues): AbstractConditions * @param int $type * @return void */ - protected function addCondition(string $store, string $andor, string $condition, $value = null, int $type = -1) + protected function addCondition(string $store, string $andor, string $condition, $value = null, int $type = -1): void { } @@ -190,7 +190,7 @@ protected function buildLimitSqlsrv(): string * @param int $type * @return void */ - protected function appendCondition(string $store, string $condition, $value = null, int $type = -1) + protected function appendCondition(string $store, string $condition, $value = null, int $type = -1): void { } @@ -201,7 +201,7 @@ protected function appendCondition(string $store, string $condition, $value = nu * @param array|string $data * @return void */ - protected function processValue(string $store, $data) + protected function processValue(string $store, $data): void { } } diff --git a/src/Phalcon/DataMapper/Query/AbstractQuery.php b/src/DataMapper/Query/AbstractQuery.php similarity index 95% rename from src/Phalcon/DataMapper/Query/AbstractQuery.php rename to src/DataMapper/Query/AbstractQuery.php index 480e2258..369a6d10 100644 --- a/src/Phalcon/DataMapper/Query/AbstractQuery.php +++ b/src/DataMapper/Query/AbstractQuery.php @@ -33,7 +33,7 @@ abstract class AbstractQuery /** * @var array */ - protected $store = array(); + protected $store = []; /** @@ -101,7 +101,7 @@ abstract public function getStatement(): string; /** * Performs a statement in the connection * - * @return PDOStatement + * @return \PDOStatement */ public function perform() { @@ -114,7 +114,7 @@ public function perform() * @param bool $enable * @return void */ - public function setFlag(string $flag, bool $enable = true) + public function setFlag(string $flag, bool $enable = true): void { } diff --git a/src/Phalcon/DataMapper/Query/Bind.php b/src/DataMapper/Query/Bind.php similarity index 91% rename from src/Phalcon/DataMapper/Query/Bind.php rename to src/DataMapper/Query/Bind.php index 7eba8ebe..bd4639a3 100644 --- a/src/Phalcon/DataMapper/Query/Bind.php +++ b/src/DataMapper/Query/Bind.php @@ -25,7 +25,7 @@ class Bind /** * @var array */ - protected $store = array(); + protected $store = []; /** @@ -44,7 +44,7 @@ public function bindInline($value, int $type = -1): string * @param string $key * @return void */ - public function remove(string $key) + public function remove(string $key): void { } @@ -56,7 +56,7 @@ public function remove(string $key) * @param int $type * @return void */ - public function setValue(string $key, $value, int $type = -1) + public function setValue(string $key, $value, int $type = -1): void { } @@ -67,7 +67,7 @@ public function setValue(string $key, $value, int $type = -1) * @param int $type * @return void */ - public function setValues(array $values, int $type = -1) + public function setValues(array $values, int $type = -1): void { } diff --git a/src/Phalcon/DataMapper/Query/Delete.php b/src/DataMapper/Query/Delete.php similarity index 93% rename from src/Phalcon/DataMapper/Query/Delete.php rename to src/DataMapper/Query/Delete.php index eac8b3a2..342353cf 100644 --- a/src/Phalcon/DataMapper/Query/Delete.php +++ b/src/DataMapper/Query/Delete.php @@ -42,9 +42,9 @@ public function __construct(\Phalcon\DataMapper\Pdo\Connection $connection, Bind * * @param string $table * - * @return self + * @return Delete */ - public function from(string $table): self + public function from(string $table): Delete { } @@ -71,7 +71,7 @@ public function getStatement(): string * * @return void */ - public function reset() + public function reset(): void { } } diff --git a/src/Phalcon/DataMapper/Query/Insert.php b/src/DataMapper/Query/Insert.php similarity index 93% rename from src/Phalcon/DataMapper/Query/Insert.php rename to src/DataMapper/Query/Insert.php index 79fbfc79..e940e363 100644 --- a/src/Phalcon/DataMapper/Query/Insert.php +++ b/src/DataMapper/Query/Insert.php @@ -31,12 +31,12 @@ public function __construct(\Phalcon\DataMapper\Pdo\Connection $connection, Bind * Sets a column for the `INSERT` query * * @param string $column + * + * @return Insert * @param mixed $value * @param int $type - * - * @return self */ - public function column(string $column, $value = null, int $type = -1): self + public function column(string $column, $value = null, int $type = -1): Insert { } @@ -45,9 +45,9 @@ public function column(string $column, $value = null, int $type = -1): self * * @param array $columns * - * @return self + * @return Insert */ - public function columns(array $columns): self + public function columns(array $columns): Insert { } @@ -96,7 +96,7 @@ public function returning(array $columns): Insert * * @return void */ - public function reset() + public function reset(): void { } diff --git a/src/Phalcon/DataMapper/Query/QueryFactory.php b/src/DataMapper/Query/QueryFactory.php similarity index 100% rename from src/Phalcon/DataMapper/Query/QueryFactory.php rename to src/DataMapper/Query/QueryFactory.php diff --git a/src/Phalcon/DataMapper/Query/Select.php b/src/DataMapper/Query/Select.php similarity index 99% rename from src/Phalcon/DataMapper/Query/Select.php rename to src/DataMapper/Query/Select.php index 11314c2a..41cac29e 100644 --- a/src/Phalcon/DataMapper/Query/Select.php +++ b/src/DataMapper/Query/Select.php @@ -120,8 +120,6 @@ public function appendJoin(string $condition, $value = null, int $type = -1): Se * @param string ...$column * * @return Select - * @param string ...$column - * */ public function columns(): Select { diff --git a/src/Phalcon/DataMapper/Query/Update.php b/src/DataMapper/Query/Update.php similarity index 93% rename from src/Phalcon/DataMapper/Query/Update.php rename to src/DataMapper/Query/Update.php index da93ea5f..52c9ece5 100644 --- a/src/Phalcon/DataMapper/Query/Update.php +++ b/src/DataMapper/Query/Update.php @@ -31,12 +31,12 @@ public function __construct(\Phalcon\DataMapper\Pdo\Connection $connection, Bind * Sets a column for the `UPDATE` query * * @param string $column + * + * @return Update * @param mixed $value * @param int $type - * - * @return self */ - public function column(string $column, $value = null, int $type = -1): self + public function column(string $column, $value = null, int $type = -1): Update { } @@ -45,9 +45,9 @@ public function column(string $column, $value = null, int $type = -1): self * * @param array $columns * - * @return self + * @return Update */ - public function columns(array $columns): self + public function columns(array $columns): Update { } @@ -94,7 +94,7 @@ public function returning(array $columns): Update * * @return void */ - public function reset() + public function reset(): void { } diff --git a/src/Phalcon/Db/AbstractDb.php b/src/Db/AbstractDb.php similarity index 96% rename from src/Phalcon/Db/AbstractDb.php rename to src/Db/AbstractDb.php index 7ee0ca46..7e985097 100644 --- a/src/Phalcon/Db/AbstractDb.php +++ b/src/Db/AbstractDb.php @@ -61,7 +61,7 @@ abstract class AbstractDb * @param array $options * @return void */ - public static function setup(array $options) + public static function setup(array $options): void { } } diff --git a/src/Phalcon/Db/Adapter/AbstractAdapter.php b/src/Db/Adapter/AbstractAdapter.php similarity index 95% rename from src/Phalcon/Db/Adapter/AbstractAdapter.php rename to src/Db/Adapter/AbstractAdapter.php index f7a14462..92a9bec1 100644 --- a/src/Phalcon/Db/Adapter/AbstractAdapter.php +++ b/src/Db/Adapter/AbstractAdapter.php @@ -21,23 +21,29 @@ abstract class AbstractAdapter implements \Phalcon\Db\Adapter\AdapterInterface, { /** * Connection ID + * + * @var int */ protected static $connectionConsecutive = 0; /** * Active connection ID * - * @var long + * @var int */ protected $connectionId; /** * Descriptor used to connect to a database + * + * @var array */ - protected $descriptor = array(); + protected $descriptor = []; /** * Dialect instance + * + * @var object */ protected $dialect; @@ -51,9 +57,9 @@ abstract class AbstractAdapter implements \Phalcon\Db\Adapter\AdapterInterface, /** * Event Manager * - * @var ManagerInterface + * @var ManagerInterface|null */ - protected $eventsManager; + protected $eventsManager = null; /** * The real SQL statement - what was executed @@ -67,7 +73,7 @@ abstract class AbstractAdapter implements \Phalcon\Db\Adapter\AdapterInterface, * * @var array */ - protected $sqlBindTypes; + protected $sqlBindTypes = []; /** * Active SQL Statement @@ -85,11 +91,15 @@ abstract class AbstractAdapter implements \Phalcon\Db\Adapter\AdapterInterface, /** * Current transaction level + * + * @var int */ protected $transactionLevel = 0; /** * Whether the database supports transactions with save points + * + * @var bool */ protected $transactionsWithSavepoints = false; @@ -243,13 +253,13 @@ public function createView(string $viewName, array $definition, string $schemaNa * DELETE FROM `robots` WHERE `id` = 101 * ``` * - * @param mixed $table - * @param mixed $whereCondition - * @param mixed $placeholders - * @param mixed $dataTypes + * @param array|string $table + * @param string|null $whereCondition + * @param array $placeholders + * @param array $dataTypes * * @return bool */ - public function delete($table, $whereCondition = null, $placeholders = null, $dataTypes = null): bool + public function delete($table, string $whereCondition = null, array $placeholders = [], array $dataTypes = []): bool { } @@ -410,11 +420,11 @@ public function escapeIdentifier($identifier): string * * @param string $sqlQuery * @param int $fetchMode - * @param mixed $bindParams - * @param mixed $bindTypes + * @param array $bindParams + * @param array $bindTypes * @return array */ - public function fetchAll(string $sqlQuery, int $fetchMode = Enum::FETCH_ASSOC, $bindParams = null, $bindTypes = null): array + public function fetchAll(string $sqlQuery, int $fetchMode = Enum::FETCH_ASSOC, array $bindParams = [], array $bindTypes = []): array { } @@ -439,7 +449,7 @@ public function fetchAll(string $sqlQuery, int $fetchMode = Enum::FETCH_ASSOC, $ * @param mixed $column * @return string|bool */ - public function fetchColumn(string $sqlQuery, array $placeholders = array(), $column = 0) + public function fetchColumn(string $sqlQuery, array $placeholders = [], $column = 0) { } @@ -461,11 +471,11 @@ public function fetchColumn(string $sqlQuery, array $placeholders = array(), $co * * @param string $sqlQuery * @param mixed $fetchMode - * @param mixed $bindParams - * @param mixed $bindTypes + * @param array $bindParams + * @param array $bindTypes * @return array */ - public function fetchOne(string $sqlQuery, $fetchMode = Enum::FETCH_ASSOC, $bindParams = null, $bindTypes = null): array + public function fetchOne(string $sqlQuery, $fetchMode = Enum::FETCH_ASSOC, array $bindParams = [], array $bindTypes = []): array { } @@ -581,9 +591,9 @@ public function getDialect(): DialectInterface /** * Returns the internal event manager * - * @return ManagerInterface + * @return ManagerInterface|null */ - public function getEventsManager(): ManagerInterface + public function getEventsManager(): ?ManagerInterface { } @@ -769,7 +779,7 @@ public function rollbackSavepoint(string $name): bool * @param \Phalcon\Events\ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): void { } diff --git a/src/Phalcon/Db/Adapter/AdapterInterface.php b/src/Db/Adapter/AdapterInterface.php similarity index 94% rename from src/Phalcon/Db/Adapter/AdapterInterface.php rename to src/Db/Adapter/AdapterInterface.php index b789e7e0..d1caea10 100644 --- a/src/Phalcon/Db/Adapter/AdapterInterface.php +++ b/src/Db/Adapter/AdapterInterface.php @@ -11,6 +11,7 @@ use Phalcon\Db\DialectInterface; use Phalcon\Db\RawValue; +use Phalcon\Db\ResultInterface; /** * Interface for Phalcon\Db adapters @@ -130,13 +131,13 @@ public function createView(string $viewName, array $definition, string $schemaNa /** * Deletes data from a table using custom RDBMS SQL syntax * - * @param mixed $table - * @param mixed $whereCondition - * @param mixed $placeholders - * @param mixed $dataTypes + * @param array|string $table + * @param string|null $whereCondition + * @param array $placeholders + * @param array $dataTypes * * @return bool */ - public function delete($table, $whereCondition = null, $placeholders = null, $dataTypes = null): bool; + public function delete($table, string $whereCondition = null, array $placeholders = [], array $dataTypes = []): bool; /** * Returns an array of Phalcon\Db\Column objects describing a table @@ -246,21 +247,22 @@ public function escapeString(string $str): string; * return any rows * * @param string $sqlStatement - * @param mixed $placeholders - * @param mixed $dataTypes + * @param array $bindParams + * @param array $bindTypes * @return bool */ - public function execute(string $sqlStatement, $placeholders = null, $dataTypes = null): bool; + public function execute(string $sqlStatement, array $bindParams = [], array $bindTypes = []): bool; /** * Dumps the complete result of a query into an array * * @param string $sqlQuery * @param int $fetchMode - * @param mixed $placeholders + * @param array $bindParams + * @param array $bindTypes * @return array */ - public function fetchAll(string $sqlQuery, int $fetchMode = 2, $placeholders = null): array; + public function fetchAll(string $sqlQuery, int $fetchMode = 2, array $bindParams = [], array $bindTypes = []): array; /** * Returns the n'th field of first row in a SQL query result @@ -283,17 +285,18 @@ public function fetchAll(string $sqlQuery, int $fetchMode = 2, $placeholders = n * @param mixed $column * @return string|bool */ - public function fetchColumn(string $sqlQuery, array $placeholders = array(), $column = 0); + public function fetchColumn(string $sqlQuery, array $placeholders = [], $column = 0); /** * Returns the first row in a SQL query result * * @param string $sqlQuery * @param int $fetchMode - * @param mixed $placeholders + * @param array $bindParams + * @param array $bindTypes * @return array */ - public function fetchOne(string $sqlQuery, int $fetchMode = 2, $placeholders = null): array; + public function fetchOne(string $sqlQuery, int $fetchMode = 2, array $bindParams = [], array $bindTypes = []): array; /** * Returns a SQL modified with a FOR UPDATE clause @@ -526,11 +529,11 @@ public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ * rows * * @param string $sqlStatement - * @param mixed $placeholders - * @param mixed $dataTypes - * @return bool|\Phalcon\Db\ResultInterface + * @param array $bindParams + * @param array $bindTypes + * @return bool|ResultInterface */ - public function query(string $sqlStatement, $placeholders = null, $dataTypes = null); + public function query(string $sqlStatement, array $bindParams = [], array $bindTypes = []); /** * Releases given savepoint diff --git a/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php b/src/Db/Adapter/Pdo/AbstractPdo.php similarity index 90% rename from src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php rename to src/Db/Adapter/Pdo/AbstractPdo.php index bdcee566..bf80fdab 100644 --- a/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php +++ b/src/Db/Adapter/Pdo/AbstractPdo.php @@ -10,6 +10,7 @@ namespace Phalcon\Db\Adapter\Pdo; use Phalcon\Db\Adapter\AbstractAdapter; +use Phalcon\Db\ResultInterface; /** * Phalcon\Db\Adapter\Pdo is the Phalcon\Db that internally uses PDO to connect @@ -33,8 +34,10 @@ abstract class AbstractPdo extends AbstractAdapter { /** * Last affected rows + * + * @var int */ - protected $affectedRows; + protected $affectedRows = 0; /** * PDO Handler @@ -47,7 +50,17 @@ abstract class AbstractPdo extends AbstractAdapter /** * Constructor for Phalcon\Db\Adapter\Pdo * - * @param array $descriptor + * @param array $descriptor = [ + * 'host' => 'localhost', + * 'port' => '3306', + * 'dbname' => 'blog', + * 'username' => 'sigma' + * 'password' => 'secret' + * 'dialectClass' => null, + * 'options' => [], + * 'dsn' => null, + * 'charset' => 'utf8mb4' + * ] */ public function __construct(array $descriptor) { @@ -150,7 +163,7 @@ public function connect(array $descriptor = null): bool * @param array $params * @return array */ - public function convertBoundParams(string $sql, array $params = array()): array + public function convertBoundParams(string $sql, array $params = []): array { } @@ -190,11 +203,11 @@ public function escapeString(string $str): string * ``` * * @param string $sqlStatement - * @param mixed $bindParams - * @param mixed $bindTypes + * @param array $bindParams + * @param array $bindTypes * @return bool */ - public function execute(string $sqlStatement, $bindParams = null, $bindTypes = null): bool + public function execute(string $sqlStatement, array $bindParams = [], array $bindTypes = []): bool { } @@ -349,11 +362,11 @@ public function prepare(string $sqlStatement): \PDOStatement * ``` * * @param string $sqlStatement - * @param mixed $bindParams - * @param mixed $bindTypes - * @return bool|\Phalcon\Db\ResultInterface + * @param array $bindParams + * @param array $bindTypes + * @return bool|ResultInterface */ - public function query(string $sqlStatement, $bindParams = null, $bindTypes = null) + public function query(string $sqlStatement, array $bindParams = [], array $bindTypes = []) { } @@ -382,7 +395,7 @@ abstract protected function getDsnDefaults(): array; * @param array $parameters * @return void */ - protected function prepareRealSql(string $statement, array $parameters) + protected function prepareRealSql(string $statement, array $parameters): void { } } diff --git a/src/Phalcon/Db/Adapter/Pdo/Mysql.php b/src/Db/Adapter/Pdo/Mysql.php similarity index 100% rename from src/Phalcon/Db/Adapter/Pdo/Mysql.php rename to src/Db/Adapter/Pdo/Mysql.php diff --git a/src/Phalcon/Db/Adapter/Pdo/Postgresql.php b/src/Db/Adapter/Pdo/Postgresql.php similarity index 100% rename from src/Phalcon/Db/Adapter/Pdo/Postgresql.php rename to src/Db/Adapter/Pdo/Postgresql.php diff --git a/src/Phalcon/Db/Adapter/Pdo/Sqlite.php b/src/Db/Adapter/Pdo/Sqlite.php similarity index 100% rename from src/Phalcon/Db/Adapter/Pdo/Sqlite.php rename to src/Db/Adapter/Pdo/Sqlite.php diff --git a/src/Phalcon/Db/Adapter/PdoFactory.php b/src/Db/Adapter/PdoFactory.php similarity index 88% rename from src/Phalcon/Db/Adapter/PdoFactory.php rename to src/Db/Adapter/PdoFactory.php index fb41d198..eadc67ff 100644 --- a/src/Phalcon/Db/Adapter/PdoFactory.php +++ b/src/Db/Adapter/PdoFactory.php @@ -22,12 +22,15 @@ class PdoFactory extends AbstractFactory { + protected $exception = 'Phalcon\\\\Db\\\\Exception'; + + /** * Constructor * * @param array $services */ - public function __construct(array $services = array()) + public function __construct(array $services = []) { } @@ -61,7 +64,7 @@ public function load($config): AdapterInterface * @param array $options * @return AdapterInterface */ - public function newInstance(string $name, array $options = array()): AdapterInterface + public function newInstance(string $name, array $options = []): AdapterInterface { } diff --git a/src/Phalcon/Db/Column.php b/src/Db/Column.php similarity index 94% rename from src/Phalcon/Db/Column.php rename to src/Db/Column.php index 4bb01d30..f0d7af80 100644 --- a/src/Phalcon/Db/Column.php +++ b/src/Db/Column.php @@ -80,6 +80,11 @@ class Column implements \Phalcon\Db\ColumnInterface */ const TYPE_BIT = 19; + /** + * Binary abstract data type + */ + const TYPE_BINARY = 26; + /** * Blob abstract data type */ @@ -200,6 +205,11 @@ class Column implements \Phalcon\Db\ColumnInterface */ const TYPE_TINYTEXT = 25; + /** + * Varbinary abstract data type + */ + const TYPE_VARBINARY = 27; + /** * Varchar abstract data type */ @@ -210,7 +220,7 @@ class Column implements \Phalcon\Db\ColumnInterface * * @var string|null */ - protected $after; + protected $after = null; /** * Column is autoIncrement? @@ -221,11 +231,15 @@ class Column implements \Phalcon\Db\ColumnInterface /** * Bind Type + * + * @var int */ protected $bindType = 2; /** * Default column value + * + * @var mixed|null */ protected $_default = null; @@ -238,6 +252,8 @@ class Column implements \Phalcon\Db\ColumnInterface /** * The column have some numeric type? + * + * @var bool */ protected $isNumeric = false; @@ -251,7 +267,7 @@ class Column implements \Phalcon\Db\ColumnInterface /** * Column's comment * - * @var string + * @var string|null */ protected $comment = null; @@ -266,6 +282,8 @@ class Column implements \Phalcon\Db\ColumnInterface /** * Column is part of the primary key? + * + * @var bool */ protected $primary = false; @@ -279,7 +297,7 @@ class Column implements \Phalcon\Db\ColumnInterface /** * Integer column size * - * @var int | string + * @var int|string */ protected $size = 0; @@ -314,6 +332,8 @@ class Column implements \Phalcon\Db\ColumnInterface /** * Default column value + * + * @return mixed|null */ public function getDefault() { @@ -331,9 +351,9 @@ public function getName(): string /** * Column's comment * - * @return string + * @return string|null */ - public function getComment(): string + public function getComment(): ?string { } diff --git a/src/Phalcon/Db/ColumnInterface.php b/src/Db/ColumnInterface.php similarity index 100% rename from src/Phalcon/Db/ColumnInterface.php rename to src/Db/ColumnInterface.php diff --git a/src/Phalcon/Db/Dialect.php b/src/Db/Dialect.php similarity index 78% rename from src/Phalcon/Db/Dialect.php rename to src/Db/Dialect.php index 63bd2a63..6ba589c1 100644 --- a/src/Phalcon/Db/Dialect.php +++ b/src/Db/Dialect.php @@ -15,11 +15,15 @@ */ abstract class Dialect implements \Phalcon\Db\DialectInterface { - + /** + * @var string + */ protected $escapeChar; - - protected $customFunctions; + /** + * @var array + */ + protected $customFunctions = []; /** @@ -84,10 +88,10 @@ public function forUpdate(string $sqlQuery): string * * @param array $columnList * @param string $escapeChar - * @param mixed $bindCounts + * @param array $bindCounts * @return string */ - final public function getColumnList(array $columnList, string $escapeChar = null, $bindCounts = null): string + final public function getColumnList(array $columnList, string $escapeChar = null, array $bindCounts = []): string { } @@ -103,12 +107,12 @@ public function getCustomFunctions(): array /** * Resolve Column expressions * - * @param mixed $column - * @param string $escapeChar - * @param mixed $bindCounts + * @param array|string $column + * @param string|null $escapeChar + * @param array $bindCounts * * @return string */ - final public function getSqlColumn($column, string $escapeChar = null, $bindCounts = null): string + final public function getSqlColumn($column, string $escapeChar = null, array $bindCounts = []): string { } @@ -117,10 +121,10 @@ final public function getSqlColumn($column, string $escapeChar = null, $bindCoun * * @param array $expression * @param string $escapeChar - * @param mixed $bindCounts + * @param array $bindCounts * @return string */ - public function getSqlExpression(array $expression, string $escapeChar = null, $bindCounts = null): string + public function getSqlExpression(array $expression, string $escapeChar = null, array $bindCounts = []): string { } @@ -275,11 +279,11 @@ final protected function getSqlExpressionAll(array $expression, string $escapeCh * Resolve binary operations expressions * * @param array $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param string|null $escapeChar + * @param array $bindCounts * * @return string */ - final protected function getSqlExpressionBinaryOperations(array $expression, string $escapeChar = null, $bindCounts = null): string + final protected function getSqlExpressionBinaryOperations(array $expression, string $escapeChar = null, array $bindCounts = []): string { } @@ -287,11 +291,11 @@ final protected function getSqlExpressionBinaryOperations(array $expression, str * Resolve CASE expressions * * @param array $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param string|null $escapeChar + * @param array $bindCounts * * @return string */ - final protected function getSqlExpressionCase(array $expression, string $escapeChar = null, $bindCounts = null): string + final protected function getSqlExpressionCase(array $expression, string $escapeChar = null, array $bindCounts = []): string { } @@ -299,11 +303,11 @@ final protected function getSqlExpressionCase(array $expression, string $escapeC * Resolve CAST of values * * @param array $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param string|null $escapeChar + * @param array $bindCounts * * @return string */ - final protected function getSqlExpressionCastValue(array $expression, string $escapeChar = null, $bindCounts = null): string + final protected function getSqlExpressionCastValue(array $expression, string $escapeChar = null, array $bindCounts = []): string { } @@ -311,11 +315,11 @@ final protected function getSqlExpressionCastValue(array $expression, string $es * Resolve CONVERT of values encodings * * @param array $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param string|null $escapeChar + * @param array $bindCounts * * @return string */ - final protected function getSqlExpressionConvertValue(array $expression, string $escapeChar = null, $bindCounts = null): string + final protected function getSqlExpressionConvertValue(array $expression, string $escapeChar = null, array $bindCounts = []): string { } @@ -334,23 +338,23 @@ final protected function getSqlExpressionFrom($expression, string $escapeChar = * Resolve function calls * * @param array $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param string|null $escapeChar + * @param array $bindCounts * * @return string */ - final protected function getSqlExpressionFunctionCall(array $expression, string $escapeChar = null, $bindCounts): string + final protected function getSqlExpressionFunctionCall(array $expression, string $escapeChar = null, array $bindCounts = []): string { } /** * Resolve a GROUP BY clause * - * @param mixed $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param array|string $expression + * @param string|null $escapeChar + * @param array $bindCounts * * @return string */ - final protected function getSqlExpressionGroupBy($expression, string $escapeChar = null, $bindCounts = null): string + final protected function getSqlExpressionGroupBy($expression, string $escapeChar = null, array $bindCounts = []): string { } @@ -358,35 +362,35 @@ final protected function getSqlExpressionGroupBy($expression, string $escapeChar * Resolve a HAVING clause * * @param array $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param string|null $escapeChar + * @param array $bindCounts * * @return string */ - final protected function getSqlExpressionHaving(array $expression, string $escapeChar = null, $bindCounts = null): string + final protected function getSqlExpressionHaving(array $expression, string $escapeChar = null, array $bindCounts = []): string { } /** * Resolve a JOINs clause * - * @param mixed $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param array|string $expression + * @param string|null $escapeChar + * @param array $bindCounts * * @return string */ - final protected function getSqlExpressionJoins($expression, string $escapeChar = null, $bindCounts = null): string + final protected function getSqlExpressionJoins($expression, string $escapeChar = null, array $bindCounts = []): string { } /** * Resolve a LIMIT clause * - * @param mixed $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param array|string $expression + * @param string|null $escapeChar + * @param array $bindCounts * * @return string */ - final protected function getSqlExpressionLimit($expression, string $escapeChar = null, $bindCounts = null): string + final protected function getSqlExpressionLimit($expression, string $escapeChar = null, array $bindCounts = []): string { } @@ -394,11 +398,11 @@ final protected function getSqlExpressionLimit($expression, string $escapeChar = * Resolve Lists * * @param array $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param string|null $escapeChar + * @param array $bindCounts * * @return string */ - final protected function getSqlExpressionList(array $expression, string $escapeChar = null, $bindCounts = null): string + final protected function getSqlExpressionList(array $expression, string $escapeChar = null, array $bindCounts = []): string { } @@ -406,23 +410,23 @@ final protected function getSqlExpressionList(array $expression, string $escapeC * Resolve object expressions * * @param array $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param string|null $escapeChar + * @param array $bindCounts * * @return string */ - final protected function getSqlExpressionObject(array $expression, string $escapeChar = null, $bindCounts = null): string + final protected function getSqlExpressionObject(array $expression, string $escapeChar = null, array $bindCounts = []): string { } /** * Resolve an ORDER BY clause * - * @param mixed $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param array|string $expression + * @param string|null $escapeChar + * @param array $bindCounts * * @return string */ - final protected function getSqlExpressionOrderBy($expression, string $escapeChar = null, $bindCounts = null): string + final protected function getSqlExpressionOrderBy($expression, string $escapeChar = null, array $bindCounts = []): string { } @@ -441,11 +445,11 @@ final protected function getSqlExpressionQualified(array $expression, string $es * Resolve Column expressions * * @param array $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param string|null $escapeChar + * @param array $bindCounts * @return string */ - final protected function getSqlExpressionScalar(array $expression, string $escapeChar = null, $bindCounts = null): string + final protected function getSqlExpressionScalar(array $expression, string $escapeChar = null, array $bindCounts = []): string { } @@ -453,23 +457,23 @@ final protected function getSqlExpressionScalar(array $expression, string $escap * Resolve unary operations expressions * * @param array $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param string|null $escapeChar + * @param array $bindCounts * * @return string */ - final protected function getSqlExpressionUnaryOperations(array $expression, string $escapeChar = null, $bindCounts = null): string + final protected function getSqlExpressionUnaryOperations(array $expression, string $escapeChar = null, array $bindCounts = []): string { } /** * Resolve a WHERE clause * - * @param mixed $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param array|string $expression + * @param string|null $escapeChar + * @param array $bindCounts * * @return string */ - final protected function getSqlExpressionWhere($expression, string $escapeChar = null, $bindCounts = null): string + final protected function getSqlExpressionWhere($expression, string $escapeChar = null, array $bindCounts = []): string { } diff --git a/src/Phalcon/Db/Dialect/Mysql.php b/src/Db/Dialect/Mysql.php similarity index 100% rename from src/Phalcon/Db/Dialect/Mysql.php rename to src/Db/Dialect/Mysql.php diff --git a/src/Phalcon/Db/Dialect/Postgresql.php b/src/Db/Dialect/Postgresql.php similarity index 100% rename from src/Phalcon/Db/Dialect/Postgresql.php rename to src/Db/Dialect/Postgresql.php diff --git a/src/Phalcon/Db/Dialect/Sqlite.php b/src/Db/Dialect/Sqlite.php similarity index 100% rename from src/Phalcon/Db/Dialect/Sqlite.php rename to src/Db/Dialect/Sqlite.php diff --git a/src/Phalcon/Db/DialectInterface.php b/src/Db/DialectInterface.php similarity index 99% rename from src/Phalcon/Db/DialectInterface.php rename to src/Db/DialectInterface.php index fa6b3057..cc1c2bd2 100644 --- a/src/Phalcon/Db/DialectInterface.php +++ b/src/Db/DialectInterface.php @@ -205,10 +205,10 @@ public function getCustomFunctions(): array; * * @param array $expression * @param string $escapeChar - * @param mixed $bindCounts + * @param array $bindCounts * @return string */ - public function getSqlExpression(array $expression, string $escapeChar = null, $bindCounts = null): string; + public function getSqlExpression(array $expression, string $escapeChar = null, array $bindCounts = []): string; /** * Generates the SQL for LIMIT clause diff --git a/src/Phalcon/Db/Enum.php b/src/Db/Enum.php similarity index 100% rename from src/Phalcon/Db/Enum.php rename to src/Db/Enum.php diff --git a/src/Phalcon/Db/Exception.php b/src/Db/Exception.php similarity index 100% rename from src/Phalcon/Db/Exception.php rename to src/Db/Exception.php diff --git a/src/Phalcon/Db/Index.php b/src/Db/Index.php similarity index 100% rename from src/Phalcon/Db/Index.php rename to src/Db/Index.php diff --git a/src/Phalcon/Db/IndexInterface.php b/src/Db/IndexInterface.php similarity index 100% rename from src/Phalcon/Db/IndexInterface.php rename to src/Db/IndexInterface.php diff --git a/src/Phalcon/Db/Profiler.php b/src/Db/Profiler.php similarity index 94% rename from src/Phalcon/Db/Profiler.php rename to src/Db/Profiler.php index 5aee40ff..aeb82f65 100644 --- a/src/Phalcon/Db/Profiler.php +++ b/src/Db/Profiler.php @@ -64,16 +64,16 @@ class Profiler { /** - * Active Phalcon\Db\Profiler\Item + * Active Item * - * @var Phalcon\Db\Profiler\Item + * @var Item */ protected $activeProfile; /** - * All the Phalcon\Db\Profiler\Item in the active profile + * All the Items in the active profile * - * @var \Phalcon\Db\Profiler\Item[] + * @var Item[] */ protected $allProfiles; diff --git a/src/Phalcon/Db/Profiler/Item.php b/src/Db/Profiler/Item.php similarity index 100% rename from src/Phalcon/Db/Profiler/Item.php rename to src/Db/Profiler/Item.php diff --git a/src/Phalcon/Db/RawValue.php b/src/Db/RawValue.php similarity index 100% rename from src/Phalcon/Db/RawValue.php rename to src/Db/RawValue.php diff --git a/src/Phalcon/Db/Reference.php b/src/Db/Reference.php similarity index 100% rename from src/Phalcon/Db/Reference.php rename to src/Db/Reference.php diff --git a/src/Phalcon/Db/ReferenceInterface.php b/src/Db/ReferenceInterface.php similarity index 100% rename from src/Phalcon/Db/ReferenceInterface.php rename to src/Db/ReferenceInterface.php diff --git a/src/Phalcon/Db/Result/Pdo.php b/src/Db/Result/Pdo.php similarity index 91% rename from src/Phalcon/Db/Result/Pdo.php rename to src/Db/Result/Pdo.php index c4c95ecb..860aa319 100644 --- a/src/Phalcon/Db/Result/Pdo.php +++ b/src/Db/Result/Pdo.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Db\Result; +use Phalcon\Db\Adapter\AdapterInterface; use Phalcon\Db\Enum; /** @@ -28,17 +29,25 @@ */ class Pdo implements \Phalcon\Db\ResultInterface { + /** + * @var array + */ + protected $bindParams = []; - protected $bindParams; - - - protected $bindTypes; - + /** + * @var array + */ + protected $bindTypes = []; + /** + * @var AdapterInterface + */ protected $connection; /** * Active fetch mode + * + * @var int */ protected $fetchMode = Enum::FETCH_OBJ; @@ -49,14 +58,21 @@ class Pdo implements \Phalcon\Db\ResultInterface */ protected $pdoStatement; - + /** + * @var mixed + * TODO: Check if this property is used + */ protected $result; - + /** + * @var bool + */ protected $rowCount = false; - - protected $sqlStatement; + /** + * @var string|null + */ + protected $sqlStatement = null; /** @@ -88,11 +104,10 @@ public function __construct(\Phalcon\Db\Adapter\AdapterInterface $connection, \P * $row = $result->fetch(); * ``` * - * @param int $number - * + * @param int $number * * @return void */ - public function dataSeek(int $number) + public function dataSeek(int $number): void { } diff --git a/src/Phalcon/Db/ResultInterface.php b/src/Db/ResultInterface.php similarity index 100% rename from src/Phalcon/Db/ResultInterface.php rename to src/Db/ResultInterface.php diff --git a/src/Phalcon/Di.php b/src/Di.php similarity index 93% rename from src/Phalcon/Di.php rename to src/Di.php index 0c6a96d9..cda593b1 100644 --- a/src/Phalcon/Di.php +++ b/src/Di.php @@ -58,24 +58,26 @@ class Di implements \Phalcon\Di\DiInterface * * @var ServiceInterface[] */ - protected $services = array(); + protected $services = []; /** * List of shared instances + * + * @var array */ - protected $sharedInstances = array(); + protected $sharedInstances = []; /** * Events Manager * - * @var ManagerInterface | null + * @var ManagerInterface|null */ - protected $eventsManager; + protected $eventsManager = null; /** * Latest DI build * - * @var DiInterface | null + * @var DiInterface|null */ protected static $_default; @@ -94,7 +96,7 @@ public function __construct() * @param array $arguments * @return mixed|null */ - public function __call(string $method, array $arguments = array()) + public function __call(string $method, array $arguments = []) { } @@ -106,7 +108,7 @@ public function __call(string $method, array $arguments = array()) * @param string $name * @param mixed $definition * @param bool $shared - * @return bool|\Phalcon\Di\ServiceInterface + * @return 0|ServiceInterface */ public function attempt(string $name, $definition, bool $shared = false) { @@ -126,7 +128,7 @@ public function get(string $name, $parameters = null) /** * Return the latest DI created * - * @return \Phalcon\Di\DiInterface|null + * @return DiInterface|null */ public static function getDefault(): ?DiInterface { @@ -135,7 +137,7 @@ public static function getDefault(): ?DiInterface /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface|null + * @return ManagerInterface|null */ public function getInternalEventsManager(): ?ManagerInterface { @@ -188,7 +190,7 @@ public function getShared(string $name, $parameters = null) * @param \Phalcon\Config\ConfigInterface $config * @return void */ - protected function loadFromConfig(\Phalcon\Config\ConfigInterface $config) + protected function loadFromConfig(\Phalcon\Config\ConfigInterface $config): void { } @@ -226,7 +228,7 @@ protected function loadFromConfig(\Phalcon\Config\ConfigInterface $config) * @param string $filePath * @return void */ - public function loadFromPhp(string $filePath) + public function loadFromPhp(string $filePath): void { } @@ -266,7 +268,7 @@ public function loadFromPhp(string $filePath) * @param array $callbacks * @return void */ - public function loadFromYaml(string $filePath, array $callbacks = null) + public function loadFromYaml(string $filePath, array $callbacks = null): void { } @@ -315,7 +317,7 @@ public function offsetExists($name): bool * @param mixed $definition * @return void */ - public function offsetSet($name, $definition) + public function offsetSet($name, $definition): void { } @@ -325,7 +327,7 @@ public function offsetSet($name, $definition) * @param mixed $name * @return void */ - public function offsetUnset($name) + public function offsetUnset($name): void { } @@ -353,7 +355,7 @@ public function offsetUnset($name) * @param \Phalcon\Di\ServiceProviderInterface $provider * @return void */ - public function register(\Phalcon\Di\ServiceProviderInterface $provider) + public function register(\Phalcon\Di\ServiceProviderInterface $provider): void { } @@ -364,7 +366,7 @@ public function register(\Phalcon\Di\ServiceProviderInterface $provider) * @param string $name * @return void */ - public function remove(string $name) + public function remove(string $name): void { } @@ -373,7 +375,7 @@ public function remove(string $name) * * @return void */ - public static function reset() + public static function reset(): void { } @@ -396,7 +398,7 @@ public function set(string $name, $definition, bool $shared = false): ServiceInt * @param \Phalcon\Di\DiInterface $container * @return void */ - public static function setDefault(\Phalcon\Di\DiInterface $container) + public static function setDefault(\Phalcon\Di\DiInterface $container): void { } diff --git a/src/Phalcon/Di/AbstractInjectionAware.php b/src/Di/AbstractInjectionAware.php similarity index 93% rename from src/Phalcon/Di/AbstractInjectionAware.php rename to src/Di/AbstractInjectionAware.php index d9f43b71..1284aca8 100644 --- a/src/Phalcon/Di/AbstractInjectionAware.php +++ b/src/Di/AbstractInjectionAware.php @@ -37,7 +37,7 @@ public function getDI(): DiInterface * @param DiInterface $container * @return void */ - public function setDI(DiInterface $container) + public function setDI(DiInterface $container): void { } } diff --git a/src/Phalcon/Di/DiInterface.php b/src/Di/DiInterface.php similarity index 94% rename from src/Phalcon/Di/DiInterface.php rename to src/Di/DiInterface.php index 4a6baa72..1483068d 100644 --- a/src/Phalcon/Di/DiInterface.php +++ b/src/Di/DiInterface.php @@ -23,7 +23,7 @@ interface DiInterface extends \ArrayAccess * @param mixed $definition * @param string $name * @param bool $shared - * @return bool|ServiceInterface + * @return 0|ServiceInterface */ public function attempt(string $name, $definition, bool $shared = false); @@ -89,14 +89,14 @@ public function has(string $name): bool; * @param string $name * @return void */ - public function remove(string $name); + public function remove(string $name): void; /** * Resets the internal default DI * * @return void */ - public static function reset(); + public static function reset(): void; /** * Registers a service in the services container @@ -115,7 +115,7 @@ public function set(string $name, $definition, bool $shared = false): ServiceInt * @param DiInterface $container * @return void */ - public static function setDefault(DiInterface $container); + public static function setDefault(DiInterface $container): void; /** * Sets a service using a raw Phalcon\Di\Service definition diff --git a/src/Phalcon/Di/Exception.php b/src/Di/Exception.php similarity index 100% rename from src/Phalcon/Di/Exception.php rename to src/Di/Exception.php diff --git a/src/Phalcon/Di/Exception/ServiceResolutionException.php b/src/Di/Exception/ServiceResolutionException.php similarity index 100% rename from src/Phalcon/Di/Exception/ServiceResolutionException.php rename to src/Di/Exception/ServiceResolutionException.php diff --git a/src/Phalcon/Di/FactoryDefault.php b/src/Di/FactoryDefault.php similarity index 100% rename from src/Phalcon/Di/FactoryDefault.php rename to src/Di/FactoryDefault.php diff --git a/src/Phalcon/Di/FactoryDefault/Cli.php b/src/Di/FactoryDefault/Cli.php similarity index 100% rename from src/Phalcon/Di/FactoryDefault/Cli.php rename to src/Di/FactoryDefault/Cli.php diff --git a/src/Phalcon/Di/Injectable.php b/src/Di/Injectable.php similarity index 95% rename from src/Phalcon/Di/Injectable.php rename to src/Di/Injectable.php index 6fab0c01..616e4240 100644 --- a/src/Phalcon/Di/Injectable.php +++ b/src/Di/Injectable.php @@ -45,9 +45,9 @@ abstract class Injectable implements \Phalcon\Di\InjectionAwareInterface /** * Dependency Injector * - * @var DiInterface + * @var DiInterface|null */ - protected $container; + protected $container = null; /** @@ -85,7 +85,7 @@ public function getDI(): DiInterface * @param DiInterface $container * @return void */ - public function setDI(DiInterface $container) + public function setDI(DiInterface $container): void { } } diff --git a/src/Phalcon/Di/InjectionAwareInterface.php b/src/Di/InjectionAwareInterface.php similarity index 92% rename from src/Phalcon/Di/InjectionAwareInterface.php rename to src/Di/InjectionAwareInterface.php index 97b68a27..ea9f32a3 100644 --- a/src/Phalcon/Di/InjectionAwareInterface.php +++ b/src/Di/InjectionAwareInterface.php @@ -22,7 +22,7 @@ interface InjectionAwareInterface * @param DiInterface $container * @return void */ - public function setDI(DiInterface $container); + public function setDI(DiInterface $container): void; /** * Returns the internal dependency injector diff --git a/src/Phalcon/Di/Service.php b/src/Di/Service.php similarity index 89% rename from src/Phalcon/Di/Service.php rename to src/Di/Service.php index f3db7b4a..c324dd75 100644 --- a/src/Phalcon/Di/Service.php +++ b/src/Di/Service.php @@ -23,7 +23,9 @@ */ class Service implements \Phalcon\Di\ServiceInterface { - + /** + * @var mixed + */ protected $definition; /** @@ -36,8 +38,10 @@ class Service implements \Phalcon\Di\ServiceInterface */ protected $shared = false; - - protected $sharedInstance; + /** + * @var mixed|null + */ + protected $sharedInstance = null; /** @@ -104,7 +108,7 @@ public function resolve($parameters = null, DiInterface $container = null) * @param mixed $definition * @return void */ - public function setDefinition($definition) + public function setDefinition($definition): void { } @@ -125,7 +129,7 @@ public function setParameter(int $position, array $parameter): ServiceInterface * @param bool $shared * @return void */ - public function setShared(bool $shared) + public function setShared(bool $shared): void { } @@ -135,7 +139,7 @@ public function setShared(bool $shared) * @param mixed $sharedInstance * @return void */ - public function setSharedInstance($sharedInstance) + public function setSharedInstance($sharedInstance): void { } } diff --git a/src/Phalcon/Di/Service/Builder.php b/src/Di/Service/Builder.php similarity index 100% rename from src/Phalcon/Di/Service/Builder.php rename to src/Di/Service/Builder.php diff --git a/src/Phalcon/Di/ServiceInterface.php b/src/Di/ServiceInterface.php similarity index 100% rename from src/Phalcon/Di/ServiceInterface.php rename to src/Di/ServiceInterface.php diff --git a/src/Phalcon/Di/ServiceProviderInterface.php b/src/Di/ServiceProviderInterface.php similarity index 94% rename from src/Phalcon/Di/ServiceProviderInterface.php rename to src/Di/ServiceProviderInterface.php index 497bac34..ba7e8226 100644 --- a/src/Phalcon/Di/ServiceProviderInterface.php +++ b/src/Di/ServiceProviderInterface.php @@ -42,5 +42,5 @@ interface ServiceProviderInterface * @param DiInterface $di * @return void */ - public function register(DiInterface $di); + public function register(DiInterface $di): void; } diff --git a/src/Phalcon/Dispatcher/AbstractDispatcher.php b/src/Dispatcher/AbstractDispatcher.php similarity index 80% rename from src/Phalcon/Dispatcher/AbstractDispatcher.php rename to src/Dispatcher/AbstractDispatcher.php index 9e150933..f1a172d1 100644 --- a/src/Phalcon/Dispatcher/AbstractDispatcher.php +++ b/src/Dispatcher/AbstractDispatcher.php @@ -20,15 +20,19 @@ */ abstract class AbstractDispatcher extends AbstractInjectionAware implements \Phalcon\Dispatcher\DispatcherInterface, \Phalcon\Events\EventsAwareInterface { - - protected $activeHandler; + /** + * @var object|null + */ + protected $activeHandler = null; /** * @var array */ - protected $activeMethodMap = array(); - + protected $activeMethodMap = []; + /** + * @var string|null + */ protected $actionName = null; /** @@ -39,25 +43,31 @@ abstract class AbstractDispatcher extends AbstractInjectionAware implements \Pha /** * @var array */ - protected $camelCaseMap = array(); + protected $camelCaseMap = []; /** * @var string */ protected $defaultAction = ''; - + /** + * @var string|null + */ protected $defaultNamespace = null; - + /** + * @var string|null + */ protected $defaultHandler = null; /** * @var array */ - protected $handlerHashes = array(); - + protected $handlerHashes = []; + /** + * @var string|null + */ protected $handlerName = null; /** @@ -65,8 +75,10 @@ abstract class AbstractDispatcher extends AbstractInjectionAware implements \Pha */ protected $handlerSuffix = ''; - - protected $eventsManager; + /** + * @var ManagerInterface|null + */ + protected $eventsManager = null; /** * @var bool @@ -83,10 +95,14 @@ abstract class AbstractDispatcher extends AbstractInjectionAware implements \Pha */ protected $isControllerInitialize = false; - + /** + * @var mixed|null + */ protected $lastHandler = null; - + /** + * @var BinderInterface|null + */ protected $modelBinder = null; /** @@ -94,27 +110,39 @@ abstract class AbstractDispatcher extends AbstractInjectionAware implements \Pha */ protected $modelBinding = false; - + /** + * @var string|null + */ protected $moduleName = null; - + /** + * @var string|null + */ protected $namespaceName = null; /** * @var array */ - protected $params = array(); - + protected $params = []; + /** + * @var string|null + */ protected $previousActionName = null; - + /** + * @var string|null + */ protected $previousHandlerName = null; - + /** + * @var string|null + */ protected $previousNamespaceName = null; - + /** + * @var string|null + */ protected $returnedValue = null; @@ -123,7 +151,7 @@ abstract class AbstractDispatcher extends AbstractInjectionAware implements \Pha * @param string $actionMethod * @param array $params */ - public function callActionMethod($handler, string $actionMethod, array $params = array()) + public function callActionMethod($handler, string $actionMethod, array $params = []) { } @@ -131,7 +159,9 @@ public function callActionMethod($handler, string $actionMethod, array $params = * Process the results of the router by calling into the appropriate * controller action(s) including any routing data or injected parameters. * - * @return bool + * @return mixed Returns the dispatched handler class (the Controller for Mvc dispatching or a Task + * for CLI dispatching) or false if an exception occurred and the operation was + * stopped by returning false in the exception handler. * * @throws \Exception if any uncaught or unhandled exception occurs during the dispatcher process. */ @@ -155,7 +185,7 @@ public function dispatch(): bool * @param array $forward * @return void */ - public function forward(array $forward) + public function forward(array $forward): void { } @@ -218,9 +248,9 @@ public function getDefaultNamespace(): string /** * Returns the internal event manager * - * @return ManagerInterface + * @return ManagerInterface|null */ - public function getEventsManager(): ManagerInterface + public function getEventsManager(): ?ManagerInterface { } @@ -236,7 +266,7 @@ public function getHandlerSuffix(): string /** * Gets model binder * - * @return \Phalcon\Mvc\Model\BinderInterface|null + * @return BinderInterface|null */ public function getModelBinder(): ?BinderInterface { @@ -307,7 +337,7 @@ public function isFinished(): bool * @param string $actionName * @return void */ - public function setActionName(string $actionName) + public function setActionName(string $actionName): void { } @@ -317,7 +347,7 @@ public function setActionName(string $actionName) * @param string $actionName * @return void */ - public function setDefaultAction(string $actionName) + public function setDefaultAction(string $actionName): void { } @@ -327,7 +357,7 @@ public function setDefaultAction(string $actionName) * @param string $namespaceName * @return void */ - public function setDefaultNamespace(string $namespaceName) + public function setDefaultNamespace(string $namespaceName): void { } @@ -347,7 +377,7 @@ public function getHandlerClass(): string * @param mixed $value * @return void */ - public function setParam($param, $value) + public function setParam($param, $value): void { } @@ -357,7 +387,7 @@ public function setParam($param, $value) * @param array $params * @return void */ - public function setParams(array $params) + public function setParams(array $params): void { } @@ -367,7 +397,7 @@ public function setParams(array $params) * @param mixed $value * @return void */ - public function setReturnedValue($value) + public function setReturnedValue($value): void { } @@ -377,7 +407,7 @@ public function setReturnedValue($value) * @param string $actionSuffix * @return void */ - public function setActionSuffix(string $actionSuffix) + public function setActionSuffix(string $actionSuffix): void { } @@ -387,7 +417,7 @@ public function setActionSuffix(string $actionSuffix) * @param \Phalcon\Events\ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): void { } @@ -397,7 +427,7 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager * @param string $handlerSuffix * @return void */ - public function setHandlerSuffix(string $handlerSuffix) + public function setHandlerSuffix(string $handlerSuffix): void { } @@ -434,7 +464,7 @@ public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, * @param string $moduleName * @return void */ - public function setModuleName(string $moduleName) + public function setModuleName(string $moduleName): void { } @@ -444,7 +474,7 @@ public function setModuleName(string $moduleName) * @param string $namespaceName * @return void */ - public function setNamespaceName(string $namespaceName) + public function setNamespaceName(string $namespaceName): void { } @@ -471,7 +501,7 @@ public function wasForwarded(): bool * * @return void */ - protected function resolveEmptyProperties() + protected function resolveEmptyProperties(): void { } diff --git a/src/Phalcon/Dispatcher/DispatcherInterface.php b/src/Dispatcher/DispatcherInterface.php similarity index 84% rename from src/Phalcon/Dispatcher/DispatcherInterface.php rename to src/Dispatcher/DispatcherInterface.php index 9014950b..2a2b5a83 100644 --- a/src/Phalcon/Dispatcher/DispatcherInterface.php +++ b/src/Dispatcher/DispatcherInterface.php @@ -18,7 +18,7 @@ interface DispatcherInterface /** * Dispatches a handle action taking into account the routing parameters * - * @return bool + * @return mixed */ public function dispatch(): bool; @@ -28,7 +28,7 @@ public function dispatch(): bool; * @param array $forward * @return void */ - public function forward(array $forward); + public function forward(array $forward): void; /** * Gets last dispatched action name @@ -96,7 +96,7 @@ public function isFinished(): bool; * @param string $actionName * @return void */ - public function setActionName(string $actionName); + public function setActionName(string $actionName): void; /** * Sets the default action suffix @@ -104,7 +104,7 @@ public function setActionName(string $actionName); * @param string $actionSuffix * @return void */ - public function setActionSuffix(string $actionSuffix); + public function setActionSuffix(string $actionSuffix): void; /** * Sets the default action name @@ -112,7 +112,7 @@ public function setActionSuffix(string $actionSuffix); * @param string $actionName * @return void */ - public function setDefaultAction(string $actionName); + public function setDefaultAction(string $actionName): void; /** * Sets the default namespace @@ -120,7 +120,7 @@ public function setDefaultAction(string $actionName); * @param string $defaultNamespace * @return void */ - public function setDefaultNamespace(string $defaultNamespace); + public function setDefaultNamespace(string $defaultNamespace): void; /** * Sets the default suffix for the handler @@ -128,7 +128,7 @@ public function setDefaultNamespace(string $defaultNamespace); * @param string $handlerSuffix * @return void */ - public function setHandlerSuffix(string $handlerSuffix); + public function setHandlerSuffix(string $handlerSuffix): void; /** * Sets the module name which the application belongs to @@ -136,7 +136,7 @@ public function setHandlerSuffix(string $handlerSuffix); * @param string $moduleName * @return void */ - public function setModuleName(string $moduleName); + public function setModuleName(string $moduleName): void; /** * Sets the namespace which the controller belongs to @@ -144,7 +144,7 @@ public function setModuleName(string $moduleName); * @param string $namespaceName * @return void */ - public function setNamespaceName(string $namespaceName); + public function setNamespaceName(string $namespaceName): void; /** * Set a param by its name or numeric index @@ -153,7 +153,7 @@ public function setNamespaceName(string $namespaceName); * @param mixed $param * @return void */ - public function setParam($param, $value); + public function setParam($param, $value): void; /** * Sets action params to be dispatched @@ -161,5 +161,5 @@ public function setParam($param, $value); * @param array $params * @return void */ - public function setParams(array $params); + public function setParams(array $params): void; } diff --git a/src/Phalcon/Dispatcher/Exception.php b/src/Dispatcher/Exception.php similarity index 100% rename from src/Phalcon/Dispatcher/Exception.php rename to src/Dispatcher/Exception.php diff --git a/src/Phalcon/Domain/Payload/Payload.php b/src/Domain/Payload/Payload.php similarity index 100% rename from src/Phalcon/Domain/Payload/Payload.php rename to src/Domain/Payload/Payload.php diff --git a/src/Phalcon/Domain/Payload/PayloadFactory.php b/src/Domain/Payload/PayloadFactory.php similarity index 100% rename from src/Phalcon/Domain/Payload/PayloadFactory.php rename to src/Domain/Payload/PayloadFactory.php diff --git a/src/Phalcon/Domain/Payload/PayloadInterface.php b/src/Domain/Payload/PayloadInterface.php similarity index 100% rename from src/Phalcon/Domain/Payload/PayloadInterface.php rename to src/Domain/Payload/PayloadInterface.php diff --git a/src/Phalcon/Domain/Payload/ReadableInterface.php b/src/Domain/Payload/ReadableInterface.php similarity index 100% rename from src/Phalcon/Domain/Payload/ReadableInterface.php rename to src/Domain/Payload/ReadableInterface.php diff --git a/src/Phalcon/Domain/Payload/Status.php b/src/Domain/Payload/Status.php similarity index 100% rename from src/Phalcon/Domain/Payload/Status.php rename to src/Domain/Payload/Status.php diff --git a/src/Phalcon/Domain/Payload/WriteableInterface.php b/src/Domain/Payload/WriteableInterface.php similarity index 100% rename from src/Phalcon/Domain/Payload/WriteableInterface.php rename to src/Domain/Payload/WriteableInterface.php diff --git a/src/Phalcon/Escaper.php b/src/Escaper.php similarity index 96% rename from src/Phalcon/Escaper.php rename to src/Escaper.php index 571b6ef1..f7b06430 100644 --- a/src/Phalcon/Escaper.php +++ b/src/Escaper.php @@ -188,7 +188,7 @@ final public function normalizeEncoding(string $str): string * @param bool $doubleEncode * @return void */ - public function setDoubleEncode(bool $doubleEncode) + public function setDoubleEncode(bool $doubleEncode): void { } @@ -202,7 +202,7 @@ public function setDoubleEncode(bool $doubleEncode) * @param string $encoding * @return void */ - public function setEncoding(string $encoding) + public function setEncoding(string $encoding): void { } @@ -230,7 +230,7 @@ public function setFlags(int $flags): Escaper * @param int $flags * @return void */ - public function setHtmlQuoteType(int $flags) + public function setHtmlQuoteType(int $flags): void { } diff --git a/src/Phalcon/Escaper/EscaperInterface.php b/src/Escaper/EscaperInterface.php similarity index 93% rename from src/Phalcon/Escaper/EscaperInterface.php rename to src/Escaper/EscaperInterface.php index 09e2ba21..be336a5b 100644 --- a/src/Phalcon/Escaper/EscaperInterface.php +++ b/src/Escaper/EscaperInterface.php @@ -70,7 +70,7 @@ public function getEncoding(): string; * @param string $encoding * @return void */ - public function setEncoding(string $encoding); + public function setEncoding(string $encoding): void; /** * Sets the HTML quoting type for htmlspecialchars @@ -78,5 +78,5 @@ public function setEncoding(string $encoding); * @param int $quoteType * @return void */ - public function setHtmlQuoteType(int $quoteType); + public function setHtmlQuoteType(int $quoteType): void; } diff --git a/src/Phalcon/Escaper/Exception.php b/src/Escaper/Exception.php similarity index 100% rename from src/Phalcon/Escaper/Exception.php rename to src/Escaper/Exception.php diff --git a/src/Phalcon/Events/Event.php b/src/Events/Event.php similarity index 100% rename from src/Phalcon/Events/Event.php rename to src/Events/Event.php diff --git a/src/Phalcon/Events/EventInterface.php b/src/Events/EventInterface.php similarity index 100% rename from src/Phalcon/Events/EventInterface.php rename to src/Events/EventInterface.php diff --git a/src/Phalcon/Events/EventsAwareInterface.php b/src/Events/EventsAwareInterface.php similarity index 98% rename from src/Phalcon/Events/EventsAwareInterface.php rename to src/Events/EventsAwareInterface.php index 1504e5d6..de8c85c0 100644 --- a/src/Phalcon/Events/EventsAwareInterface.php +++ b/src/Events/EventsAwareInterface.php @@ -31,5 +31,5 @@ public function getEventsManager(): ?ManagerInterface; * @param ManagerInterface $eventsManager * @return void */ - public function setEventsManager(ManagerInterface $eventsManager); + public function setEventsManager(ManagerInterface $eventsManager): void; } diff --git a/src/Phalcon/Events/Exception.php b/src/Events/Exception.php similarity index 100% rename from src/Phalcon/Events/Exception.php rename to src/Events/Exception.php diff --git a/src/Phalcon/Events/Manager.php b/src/Events/Manager.php similarity index 90% rename from src/Phalcon/Events/Manager.php rename to src/Events/Manager.php index 7b63dde3..881cc9d4 100644 --- a/src/Phalcon/Events/Manager.php +++ b/src/Events/Manager.php @@ -9,9 +9,6 @@ */ namespace Phalcon\Events; -use Closure; -use SplPriorityQueue; - /** * Phalcon\Events\Manager * @@ -35,11 +32,15 @@ class Manager implements \Phalcon\Events\ManagerInterface */ protected $enablePriorities = false; + /** + * @var array + */ + protected $events = []; - protected $events = null; - - - protected $responses; + /** + * @var array + */ + protected $responses = []; /** @@ -50,7 +51,7 @@ class Manager implements \Phalcon\Events\ManagerInterface * @param int $priority * @return void */ - public function attach(string $eventType, $handler, int $priority = self::DEFAULT_PRIORITY) + public function attach(string $eventType, $handler, int $priority = self::DEFAULT_PRIORITY): void { } @@ -70,7 +71,7 @@ public function arePrioritiesEnabled(): bool * @param bool $collect * @return void */ - public function collectResponses(bool $collect) + public function collectResponses(bool $collect): void { } @@ -81,7 +82,7 @@ public function collectResponses(bool $collect) * @param string $eventType * @return void */ - public function detach(string $eventType, $handler) + public function detach(string $eventType, $handler): void { } @@ -91,7 +92,7 @@ public function detach(string $eventType, $handler) * @param string $type * @return void */ - public function detachAll(string $type = null) + public function detachAll(string $type = null): void { } @@ -109,7 +110,7 @@ public function detachAll(string $type = null) * @param bool $enablePriorities * @return void */ - public function enablePriorities(bool $enablePriorities) + public function enablePriorities(bool $enablePriorities): void { } diff --git a/src/Phalcon/Events/ManagerInterface.php b/src/Events/ManagerInterface.php similarity index 89% rename from src/Phalcon/Events/ManagerInterface.php rename to src/Events/ManagerInterface.php index b9a9d50d..188fd42e 100644 --- a/src/Phalcon/Events/ManagerInterface.php +++ b/src/Events/ManagerInterface.php @@ -24,7 +24,7 @@ interface ManagerInterface * @param string $eventType * @return void */ - public function attach(string $eventType, $handler); + public function attach(string $eventType, $handler): void; /** * Detach the listener from the events manager @@ -33,7 +33,7 @@ public function attach(string $eventType, $handler); * @param string $eventType * @return void */ - public function detach(string $eventType, $handler); + public function detach(string $eventType, $handler): void; /** * Removes all events from the EventsManager @@ -41,7 +41,7 @@ public function detach(string $eventType, $handler); * @param string $type * @return void */ - public function detachAll(string $type = null); + public function detachAll(string $type = null): void; /** * Fires an event in the events manager causing the active listeners to be diff --git a/src/Phalcon/Exception.php b/src/Exception.php similarity index 100% rename from src/Phalcon/Exception.php rename to src/Exception.php diff --git a/src/Phalcon/Factory/AbstractFactory.php b/src/Factory/AbstractFactory.php similarity index 74% rename from src/Phalcon/Factory/AbstractFactory.php rename to src/Factory/AbstractFactory.php index 2f604c31..f4ef9bc0 100644 --- a/src/Phalcon/Factory/AbstractFactory.php +++ b/src/Factory/AbstractFactory.php @@ -19,15 +19,20 @@ */ abstract class AbstractFactory { + /** + * @var string + */ + protected $exception = 'Phalcon\\\\Exception'; + /** * @var array */ - protected $mapper = array(); + protected $mapper = []; /** * @var array */ - protected $services = array(); + protected $services = []; /** @@ -63,7 +68,17 @@ protected function getService(string $name) * @param array $services * @return void */ - protected function init(array $services = array()) + protected function init(array $services = []): void + { + } + + /** + * Returns the exception object for the child class + * + * @param string $message + * @return \Exception + */ + protected function getException(string $message): \Exception { } } diff --git a/src/Phalcon/Factory/Exception.php b/src/Factory/Exception.php similarity index 100% rename from src/Phalcon/Factory/Exception.php rename to src/Factory/Exception.php diff --git a/src/Phalcon/Filter.php b/src/Filter.php similarity index 90% rename from src/Phalcon/Filter.php rename to src/Filter.php index 7982bcc1..a5705cc2 100644 --- a/src/Phalcon/Filter.php +++ b/src/Filter.php @@ -80,12 +80,12 @@ class Filter implements \Phalcon\Filter\FilterInterface /** * @var array */ - protected $mapper = array(); + protected $mapper = []; /** * @var array */ - protected $services = array(); + protected $services = []; /** @@ -94,7 +94,7 @@ class Filter implements \Phalcon\Filter\FilterInterface * * @param array $mapper */ - public function __construct(array $mapper = array()) + public function __construct(array $mapper = []) { } @@ -138,7 +138,7 @@ public function sanitize($value, $sanitizers, bool $noRecursive = false) * @param callable $service * @return void */ - public function set(string $name, $service) + public function set(string $name, $service): void { } @@ -148,7 +148,7 @@ public function set(string $name, $service) * @param array $mapper * @return void */ - protected function init(array $mapper) + protected function init(array $mapper): void { } @@ -160,7 +160,7 @@ protected function init(array $mapper) * @param array $sanitizerParams * @return array */ - private function processArrayValues(array $values, string $sanitizerName, array $sanitizerParams = array()): array + private function processArrayValues(array $values, string $sanitizerName, array $sanitizerParams = []): array { } @@ -172,7 +172,7 @@ private function processArrayValues(array $values, string $sanitizerName, array * @param array $sanitizerParams * @return mixed */ - private function sanitizer($value, string $sanitizerName, array $sanitizerParams = array()) + private function sanitizer($value, string $sanitizerName, array $sanitizerParams = []) { } } diff --git a/src/Phalcon/Filter/Exception.php b/src/Filter/Exception.php similarity index 100% rename from src/Phalcon/Filter/Exception.php rename to src/Filter/Exception.php diff --git a/src/Phalcon/Filter/FilterFactory.php b/src/Filter/FilterFactory.php similarity index 100% rename from src/Phalcon/Filter/FilterFactory.php rename to src/Filter/FilterFactory.php diff --git a/src/Phalcon/Filter/FilterInterface.php b/src/Filter/FilterInterface.php similarity index 100% rename from src/Phalcon/Filter/FilterInterface.php rename to src/Filter/FilterInterface.php diff --git a/src/Phalcon/Filter/Sanitize/AbsInt.php b/src/Filter/Sanitize/AbsInt.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/AbsInt.php rename to src/Filter/Sanitize/AbsInt.php diff --git a/src/Phalcon/Filter/Sanitize/Alnum.php b/src/Filter/Sanitize/Alnum.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/Alnum.php rename to src/Filter/Sanitize/Alnum.php diff --git a/src/Phalcon/Filter/Sanitize/Alpha.php b/src/Filter/Sanitize/Alpha.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/Alpha.php rename to src/Filter/Sanitize/Alpha.php diff --git a/src/Phalcon/Filter/Sanitize/BoolVal.php b/src/Filter/Sanitize/BoolVal.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/BoolVal.php rename to src/Filter/Sanitize/BoolVal.php diff --git a/src/Phalcon/Filter/Sanitize/Email.php b/src/Filter/Sanitize/Email.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/Email.php rename to src/Filter/Sanitize/Email.php diff --git a/src/Phalcon/Filter/Sanitize/FloatVal.php b/src/Filter/Sanitize/FloatVal.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/FloatVal.php rename to src/Filter/Sanitize/FloatVal.php diff --git a/src/Phalcon/Filter/Sanitize/IntVal.php b/src/Filter/Sanitize/IntVal.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/IntVal.php rename to src/Filter/Sanitize/IntVal.php diff --git a/src/Phalcon/Filter/Sanitize/Lower.php b/src/Filter/Sanitize/Lower.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/Lower.php rename to src/Filter/Sanitize/Lower.php diff --git a/src/Phalcon/Filter/Sanitize/LowerFirst.php b/src/Filter/Sanitize/LowerFirst.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/LowerFirst.php rename to src/Filter/Sanitize/LowerFirst.php diff --git a/src/Phalcon/Filter/Sanitize/Regex.php b/src/Filter/Sanitize/Regex.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/Regex.php rename to src/Filter/Sanitize/Regex.php diff --git a/src/Phalcon/Filter/Sanitize/Remove.php b/src/Filter/Sanitize/Remove.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/Remove.php rename to src/Filter/Sanitize/Remove.php diff --git a/src/Phalcon/Filter/Sanitize/Replace.php b/src/Filter/Sanitize/Replace.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/Replace.php rename to src/Filter/Sanitize/Replace.php diff --git a/src/Phalcon/Filter/Sanitize/Special.php b/src/Filter/Sanitize/Special.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/Special.php rename to src/Filter/Sanitize/Special.php diff --git a/src/Phalcon/Filter/Sanitize/SpecialFull.php b/src/Filter/Sanitize/SpecialFull.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/SpecialFull.php rename to src/Filter/Sanitize/SpecialFull.php diff --git a/src/Phalcon/Filter/Sanitize/StringVal.php b/src/Filter/Sanitize/StringVal.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/StringVal.php rename to src/Filter/Sanitize/StringVal.php diff --git a/src/Phalcon/Filter/Sanitize/Striptags.php b/src/Filter/Sanitize/Striptags.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/Striptags.php rename to src/Filter/Sanitize/Striptags.php diff --git a/src/Phalcon/Filter/Sanitize/Trim.php b/src/Filter/Sanitize/Trim.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/Trim.php rename to src/Filter/Sanitize/Trim.php diff --git a/src/Phalcon/Filter/Sanitize/Upper.php b/src/Filter/Sanitize/Upper.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/Upper.php rename to src/Filter/Sanitize/Upper.php diff --git a/src/Phalcon/Filter/Sanitize/UpperFirst.php b/src/Filter/Sanitize/UpperFirst.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/UpperFirst.php rename to src/Filter/Sanitize/UpperFirst.php diff --git a/src/Phalcon/Filter/Sanitize/UpperWords.php b/src/Filter/Sanitize/UpperWords.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/UpperWords.php rename to src/Filter/Sanitize/UpperWords.php diff --git a/src/Phalcon/Filter/Sanitize/Url.php b/src/Filter/Sanitize/Url.php similarity index 100% rename from src/Phalcon/Filter/Sanitize/Url.php rename to src/Filter/Sanitize/Url.php diff --git a/src/Phalcon/Flash/AbstractFlash.php b/src/Flash/AbstractFlash.php similarity index 98% rename from src/Phalcon/Flash/AbstractFlash.php rename to src/Flash/AbstractFlash.php index ba47a1f3..843c4bd9 100644 --- a/src/Phalcon/Flash/AbstractFlash.php +++ b/src/Flash/AbstractFlash.php @@ -37,7 +37,7 @@ abstract class AbstractFlash extends AbstractInjectionAware implements \Phalcon\ /** * @var array */ - protected $cssClasses = array(); + protected $cssClasses = []; /** * @var string @@ -57,7 +57,7 @@ abstract class AbstractFlash extends AbstractInjectionAware implements \Phalcon\ /** * @var array */ - protected $messages = array(); + protected $messages = []; /** * @var SessionInterface | null @@ -101,7 +101,7 @@ public function __construct(\Phalcon\Escaper\EscaperInterface $escaper = null, \ * * @return void */ - public function clear() + public function clear(): void { } diff --git a/src/Phalcon/Flash/Direct.php b/src/Flash/Direct.php similarity index 93% rename from src/Phalcon/Flash/Direct.php rename to src/Flash/Direct.php index 2031665f..59e69d9f 100644 --- a/src/Phalcon/Flash/Direct.php +++ b/src/Flash/Direct.php @@ -33,7 +33,7 @@ public function message(string $type, $message): ?string * @param bool $remove * @return void */ - public function output(bool $remove = true) + public function output(bool $remove = true): void { } } diff --git a/src/Phalcon/Flash/Exception.php b/src/Flash/Exception.php similarity index 100% rename from src/Phalcon/Flash/Exception.php rename to src/Flash/Exception.php diff --git a/src/Phalcon/Flash/FlashInterface.php b/src/Flash/FlashInterface.php similarity index 100% rename from src/Phalcon/Flash/FlashInterface.php rename to src/Flash/FlashInterface.php diff --git a/src/Phalcon/Flash/Session.php b/src/Flash/Session.php similarity index 85% rename from src/Phalcon/Flash/Session.php rename to src/Flash/Session.php index d57c0c51..35a3036c 100644 --- a/src/Phalcon/Flash/Session.php +++ b/src/Flash/Session.php @@ -9,7 +9,6 @@ */ namespace Phalcon\Flash; -use Phalcon\Di\DiInterface; use Phalcon\Session\ManagerInterface; /** @@ -25,15 +24,16 @@ class Session extends \Phalcon\Flash\AbstractFlash * * @return void */ - public function clear() + public function clear(): void { } /** * Returns the messages in the session flasher * - * @param mixed $type + * @param string|null $type * @param bool $remove + * * @return array */ public function getMessages($type = null, bool $remove = true): array @@ -43,7 +43,8 @@ public function getMessages($type = null, bool $remove = true): array /** * Checks whether there are messages * - * @param mixed $type + * @param string|null $type + * * @return bool */ public function has($type = null): bool @@ -54,10 +55,10 @@ public function has($type = null): bool * Adds a message to the session flasher * * @return null|string|void - * @param string $type + * @param mixed $type * @param string $message */ - public function message(string $type, string $message): ?string + public function message($type, string $message): ?string { } @@ -67,15 +68,16 @@ public function message(string $type, string $message): ?string * @param bool $remove * @return void */ - public function output(bool $remove = true) + public function output(bool $remove = true): void { } /** * Returns the messages stored in session * - * @param bool $remove - * @param mixed $type + * @param bool $remove + * @param string|null $type + * * @return array */ protected function getSessionMessages(bool $remove, $type = null): array diff --git a/src/Phalcon/Forms/Element/AbstractElement.php b/src/Forms/Element/AbstractElement.php similarity index 90% rename from src/Phalcon/Forms/Element/AbstractElement.php rename to src/Forms/Element/AbstractElement.php index f9397385..4fdca846 100644 --- a/src/Phalcon/Forms/Element/AbstractElement.php +++ b/src/Forms/Element/AbstractElement.php @@ -17,34 +17,50 @@ */ abstract class AbstractElement implements \Phalcon\Forms\Element\ElementInterface { + /** + * @var array + */ + protected $attributes = []; - protected $attributes; - - - protected $filters; - - - protected $form; - + /** + * @var array + */ + protected $filters = []; - protected $label; + /** + * @var Form|null + */ + protected $form = null; + /** + * @var string|null + */ + protected $label = null; + /** + * @var Messages + */ protected $messages; - + /** + * @var string + */ protected $name; - - protected $options; - /** * @var array */ - protected $validators = array(); + protected $options = []; + /** + * @var array + */ + protected $validators = []; - protected $value; + /** + * @var mixed|null + */ + protected $value = null; /** @@ -53,7 +69,7 @@ abstract class AbstractElement implements \Phalcon\Forms\Element\ElementInterfac * @param string $name Attribute name (value of 'name' attribute of HTML element) * @param array $attributes Additional HTML element attributes */ - public function __construct(string $name, array $attributes = array()) + public function __construct(string $name, array $attributes = []) { } @@ -89,10 +105,8 @@ public function addValidator(\Phalcon\Validation\ValidatorInterface $validator): /** * Adds a group of validators * - * @param \Phalcon\Validation\ValidatorInterface[] validators + * @param \Phalcon\Validation\ValidatorInterface[] $validators * @param bool $merge - * @param array $validators - * @param \Phalcon\Validation\ValidatorInterface [] validators * @return ElementInterface */ public function addValidators(array $validators, bool $merge = true): ElementInterface @@ -246,7 +260,7 @@ public function hasMessages(): bool * @param array $attributes * @return string */ - public function label(array $attributes = array()): string + public function label(array $attributes = []): string { } @@ -258,7 +272,7 @@ public function label(array $attributes = array()): string * @param bool $useChecked * @return array */ - public function prepareAttributes(array $attributes = array(), bool $useChecked = false): array + public function prepareAttributes(array $attributes = [], bool $useChecked = false): array { } diff --git a/src/Phalcon/Forms/Element/Check.php b/src/Forms/Element/Check.php similarity index 89% rename from src/Phalcon/Forms/Element/Check.php rename to src/Forms/Element/Check.php index 3a0a77d0..9142911e 100644 --- a/src/Phalcon/Forms/Element/Check.php +++ b/src/Forms/Element/Check.php @@ -23,7 +23,7 @@ class Check extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string + public function render(array $attributes = []): string { } } diff --git a/src/Phalcon/Forms/Element/Date.php b/src/Forms/Element/Date.php similarity index 88% rename from src/Phalcon/Forms/Element/Date.php rename to src/Forms/Element/Date.php index fc2cc229..f01dede3 100644 --- a/src/Phalcon/Forms/Element/Date.php +++ b/src/Forms/Element/Date.php @@ -21,7 +21,7 @@ class Date extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string + public function render(array $attributes = []): string { } } diff --git a/src/Phalcon/Forms/Element/ElementInterface.php b/src/Forms/Element/ElementInterface.php similarity index 94% rename from src/Phalcon/Forms/Element/ElementInterface.php rename to src/Forms/Element/ElementInterface.php index ec77a1d4..60473d50 100644 --- a/src/Phalcon/Forms/Element/ElementInterface.php +++ b/src/Forms/Element/ElementInterface.php @@ -37,10 +37,8 @@ public function addValidator(\Phalcon\Validation\ValidatorInterface $validator): /** * Adds a group of validators * - * @param \Phalcon\Validation\ValidatorInterface[] - * @param array $validators - * @param bool $merge - * @param \Phalcon\Validation\ValidatorInterface [] + * @param \Phalcon\Validation\ValidatorInterface[] $validators + * @param bool $merge * * @return ElementInterface */ public function addValidators(array $validators, bool $merge = true): ElementInterface; @@ -171,7 +169,7 @@ public function label(): string; * @param bool $useChecked * @return array */ - public function prepareAttributes(array $attributes = array(), bool $useChecked = false): array; + public function prepareAttributes(array $attributes = [], bool $useChecked = false): array; /** * Renders the element widget @@ -179,7 +177,7 @@ public function prepareAttributes(array $attributes = array(), bool $useChecked * @param array $attributes * @return string */ - public function render(array $attributes = array()): string; + public function render(array $attributes = []): string; /** * Sets a default attribute for the element diff --git a/src/Phalcon/Forms/Element/Email.php b/src/Forms/Element/Email.php similarity index 89% rename from src/Phalcon/Forms/Element/Email.php rename to src/Forms/Element/Email.php index dcd634f4..a3d57ead 100644 --- a/src/Phalcon/Forms/Element/Email.php +++ b/src/Forms/Element/Email.php @@ -23,7 +23,7 @@ class Email extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string + public function render(array $attributes = []): string { } } diff --git a/src/Phalcon/Forms/Element/File.php b/src/Forms/Element/File.php similarity index 88% rename from src/Phalcon/Forms/Element/File.php rename to src/Forms/Element/File.php index 4210ffd3..9e5151b9 100644 --- a/src/Phalcon/Forms/Element/File.php +++ b/src/Forms/Element/File.php @@ -21,7 +21,7 @@ class File extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string + public function render(array $attributes = []): string { } } diff --git a/src/Phalcon/Forms/Element/Hidden.php b/src/Forms/Element/Hidden.php similarity index 89% rename from src/Phalcon/Forms/Element/Hidden.php rename to src/Forms/Element/Hidden.php index 212274f9..8f8c7ec5 100644 --- a/src/Phalcon/Forms/Element/Hidden.php +++ b/src/Forms/Element/Hidden.php @@ -23,7 +23,7 @@ class Hidden extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string + public function render(array $attributes = []): string { } } diff --git a/src/Phalcon/Forms/Element/Numeric.php b/src/Forms/Element/Numeric.php similarity index 87% rename from src/Phalcon/Forms/Element/Numeric.php rename to src/Forms/Element/Numeric.php index eaa76856..f3969abd 100644 --- a/src/Phalcon/Forms/Element/Numeric.php +++ b/src/Forms/Element/Numeric.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Forms\Element; -use Phalcon\Tag; - /** * Phalcon\Forms\Element\Numeric * @@ -25,7 +23,7 @@ class Numeric extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string + public function render(array $attributes = []): string { } } diff --git a/src/Phalcon/Forms/Element/Password.php b/src/Forms/Element/Password.php similarity index 87% rename from src/Phalcon/Forms/Element/Password.php rename to src/Forms/Element/Password.php index 99f283ab..d208a2fe 100644 --- a/src/Phalcon/Forms/Element/Password.php +++ b/src/Forms/Element/Password.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Forms\Element; -use Phalcon\Tag; - /** * Phalcon\Forms\Element\Password * @@ -25,7 +23,7 @@ class Password extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string + public function render(array $attributes = []): string { } } diff --git a/src/Phalcon/Forms/Element/Radio.php b/src/Forms/Element/Radio.php similarity index 87% rename from src/Phalcon/Forms/Element/Radio.php rename to src/Forms/Element/Radio.php index 727c138f..a538f718 100644 --- a/src/Phalcon/Forms/Element/Radio.php +++ b/src/Forms/Element/Radio.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Forms\Element; -use Phalcon\Tag; - /** * Phalcon\Forms\Element\Radio * @@ -25,7 +23,7 @@ class Radio extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string + public function render(array $attributes = []): string { } } diff --git a/src/Phalcon/Forms/Element/Select.php b/src/Forms/Element/Select.php similarity index 84% rename from src/Phalcon/Forms/Element/Select.php rename to src/Forms/Element/Select.php index fb9b323e..8a0e1ffd 100644 --- a/src/Phalcon/Forms/Element/Select.php +++ b/src/Forms/Element/Select.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Forms\Element; -use Phalcon\Tag\Select as SelectTag; - /** * Phalcon\Forms\Element\Select * @@ -18,8 +16,10 @@ */ class Select extends \Phalcon\Forms\Element\AbstractElement { - - protected $optionsValues; + /** + * @var object|array|null + */ + protected $optionsValues = null; /** @@ -29,7 +29,7 @@ class Select extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @param string $name */ - public function __construct(string $name, $options = null, $attributes = null) + public function __construct(string $name, $options = null, array $attributes = []) { } @@ -58,7 +58,7 @@ public function getOptions() * @param array $attributes * @return string */ - public function render(array $attributes = array()): string + public function render(array $attributes = []): string { } diff --git a/src/Phalcon/Forms/Element/Submit.php b/src/Forms/Element/Submit.php similarity index 86% rename from src/Phalcon/Forms/Element/Submit.php rename to src/Forms/Element/Submit.php index 7b4052fa..95444354 100644 --- a/src/Phalcon/Forms/Element/Submit.php +++ b/src/Forms/Element/Submit.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Forms\Element; -use Phalcon\Tag; - /** * Component INPUT[type=submit] for forms */ @@ -23,7 +21,7 @@ class Submit extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string + public function render(array $attributes = []): string { } } diff --git a/src/Phalcon/Forms/Element/Text.php b/src/Forms/Element/Text.php similarity index 86% rename from src/Phalcon/Forms/Element/Text.php rename to src/Forms/Element/Text.php index ff3a434d..03bb1f93 100644 --- a/src/Phalcon/Forms/Element/Text.php +++ b/src/Forms/Element/Text.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Forms\Element; -use Phalcon\Tag; - /** * Phalcon\Forms\Element\Text * @@ -25,7 +23,7 @@ class Text extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string + public function render(array $attributes = []): string { } } diff --git a/src/Phalcon/Forms/Element/TextArea.php b/src/Forms/Element/TextArea.php similarity index 85% rename from src/Phalcon/Forms/Element/TextArea.php rename to src/Forms/Element/TextArea.php index f7885541..f8679dbd 100644 --- a/src/Phalcon/Forms/Element/TextArea.php +++ b/src/Forms/Element/TextArea.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Forms\Element; -use Phalcon\Tag; - /** * Component TEXTAREA for forms */ @@ -23,7 +21,7 @@ class TextArea extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string + public function render(array $attributes = []): string { } } diff --git a/src/Phalcon/Forms/Exception.php b/src/Forms/Exception.php similarity index 100% rename from src/Phalcon/Forms/Exception.php rename to src/Forms/Exception.php diff --git a/src/Phalcon/Forms/Form.php b/src/Forms/Form.php similarity index 88% rename from src/Phalcon/Forms/Form.php rename to src/Forms/Form.php index 6d8bffe9..732f53dc 100644 --- a/src/Phalcon/Forms/Form.php +++ b/src/Forms/Form.php @@ -14,6 +14,7 @@ use Phalcon\Html\Attributes; use Phalcon\Html\Attributes\AttributesInterface; use Phalcon\Messages\Messages; +use Phalcon\Validation\ValidationInterface; /** * This component allows to build forms using an object-oriented interface @@ -21,33 +22,49 @@ class Form extends Injectable implements \Countable, \Iterator, \Phalcon\Html\Attributes\AttributesInterface { /** - * @var Attributes | null + * @var AttributesInterface|null */ protected $attributes = null; + /** + * @var array + */ + protected $data = []; - protected $data; - - - protected $elements = array(); - - - protected $elementsIndexed; - - - protected $entity; - - - protected $messages; + /** + * @var array + */ + protected $elements = []; + /** + * @var array + */ + protected $elementsIndexed = []; - protected $position; + /** + * @var object|null + */ + protected $entity = null; + /** + * @var Messages|array|null + */ + protected $messages = null; - protected $options; + /** + * @var int + */ + protected $position = 0; + /** + * @var array + */ + protected $options = []; - protected $validation; + /** + * @var ValidationInterface|null + */ + protected $validation = null; /** @@ -57,7 +74,9 @@ public function setValidation($validation) { } - + /** + * @return ValidationInterface|null + */ public function getValidation() { } @@ -68,7 +87,7 @@ public function getValidation() * @param mixed $entity * @param array $userOptions */ - public function __construct($entity = null, array $userOptions = array()) + public function __construct($entity = null, array $userOptions = []) { } @@ -118,7 +137,7 @@ public function count(): int /** * Returns the current element in the iterator * - * @return bool|\Phalcon\Forms\Element\ElementInterface + * @return 0|ElementInterface */ public function current() { @@ -193,7 +212,7 @@ public function getLabel(string $name): string * } * ``` * - * @return array|\Phalcon\Messages\Messages + * @return 0|Messages */ public function getMessages() { @@ -295,7 +314,7 @@ public function label(string $name, array $attributes = null): string * * @return void */ - public function next() + public function next(): void { } @@ -306,7 +325,7 @@ public function next() * @param array $attributes * @return string */ - public function render(string $name, array $attributes = array()): string + public function render(string $name, array $attributes = []): string { } @@ -325,7 +344,7 @@ public function remove(string $name): bool * * @return void */ - public function rewind() + public function rewind(): void { } diff --git a/src/Phalcon/Forms/Manager.php b/src/Forms/Manager.php similarity index 94% rename from src/Phalcon/Forms/Manager.php rename to src/Forms/Manager.php index 89f01681..930e8e43 100644 --- a/src/Phalcon/Forms/Manager.php +++ b/src/Forms/Manager.php @@ -14,8 +14,10 @@ */ class Manager { - - protected $forms = array(); + /** + * @var array + */ + protected $forms = []; /** diff --git a/src/Phalcon/Helper/Arr.php b/src/Helper/Arr.php similarity index 100% rename from src/Phalcon/Helper/Arr.php rename to src/Helper/Arr.php diff --git a/src/Phalcon/Helper/Base64.php b/src/Helper/Base64.php similarity index 100% rename from src/Phalcon/Helper/Base64.php rename to src/Helper/Base64.php diff --git a/src/Phalcon/Helper/Exception.php b/src/Helper/Exception.php similarity index 100% rename from src/Phalcon/Helper/Exception.php rename to src/Helper/Exception.php diff --git a/src/Phalcon/Helper/Fs.php b/src/Helper/Fs.php similarity index 100% rename from src/Phalcon/Helper/Fs.php rename to src/Helper/Fs.php diff --git a/src/Phalcon/Helper/Json.php b/src/Helper/Json.php similarity index 97% rename from src/Phalcon/Helper/Json.php rename to src/Helper/Json.php index ae0a6bc8..3ee32285 100644 --- a/src/Phalcon/Helper/Json.php +++ b/src/Helper/Json.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Helper; -use InvalidArgumentException; - /** * This class offers a wrapper for JSON methods to serialize and unserialize */ @@ -67,10 +65,9 @@ final public static function decode(string $data, bool $associative = false, int * @param int $options Bitmask of JSON decode options. * @param int $depth Recursion depth. * - * @return string + * @return mixed * * @throws \InvalidArgumentException if the JSON cannot be encoded. - * * @link http://www.php.net/manual/en/function.json-encode.php */ final public static function encode($data, int $options = 0, int $depth = 512): string diff --git a/src/Phalcon/Helper/Number.php b/src/Helper/Number.php similarity index 100% rename from src/Phalcon/Helper/Number.php rename to src/Helper/Number.php diff --git a/src/Phalcon/Helper/Str.php b/src/Helper/Str.php similarity index 99% rename from src/Phalcon/Helper/Str.php rename to src/Helper/Str.php index b71db150..6dc027d3 100644 --- a/src/Phalcon/Helper/Str.php +++ b/src/Helper/Str.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Helper; -use RuntimeException; - /** * This class offers quick string functions throughout the framework */ @@ -77,8 +75,6 @@ final public static function camelize(string $text, $delimiter = null): string * @param string ...N * * @return string - * @param string ...N - * */ final public static function concat(): string { diff --git a/src/Phalcon/Html/Attributes.php b/src/Html/Attributes.php similarity index 100% rename from src/Phalcon/Html/Attributes.php rename to src/Html/Attributes.php diff --git a/src/Phalcon/Html/Attributes/AttributesInterface.php b/src/Html/Attributes/AttributesInterface.php similarity index 100% rename from src/Phalcon/Html/Attributes/AttributesInterface.php rename to src/Html/Attributes/AttributesInterface.php diff --git a/src/Phalcon/Html/Attributes/RenderInterface.php b/src/Html/Attributes/RenderInterface.php similarity index 100% rename from src/Phalcon/Html/Attributes/RenderInterface.php rename to src/Html/Attributes/RenderInterface.php diff --git a/src/Phalcon/Html/Breadcrumbs.php b/src/Html/Breadcrumbs.php similarity index 95% rename from src/Phalcon/Html/Breadcrumbs.php rename to src/Html/Breadcrumbs.php index dae1eeb7..706593c8 100644 --- a/src/Phalcon/Html/Breadcrumbs.php +++ b/src/Html/Breadcrumbs.php @@ -23,7 +23,7 @@ class Breadcrumbs * * @var array */ - private $elements = array(); + private $elements = []; /** * Crumb separator @@ -86,7 +86,7 @@ public function add(string $label, string $link = ''): Breadcrumbs * * @return void */ - public function clear() + public function clear(): void { } @@ -103,7 +103,7 @@ public function clear() * @param string $link * @return void */ - public function remove(string $link) + public function remove(string $link): void { } diff --git a/src/Phalcon/Html/Exception.php b/src/Html/Exception.php similarity index 100% rename from src/Phalcon/Html/Exception.php rename to src/Html/Exception.php diff --git a/src/Phalcon/Html/Helper/AbstractHelper.php b/src/Html/Helper/AbstractHelper.php similarity index 95% rename from src/Phalcon/Html/Helper/AbstractHelper.php rename to src/Html/Helper/AbstractHelper.php index 9a2ed4c9..61a64086 100644 --- a/src/Phalcon/Html/Helper/AbstractHelper.php +++ b/src/Html/Helper/AbstractHelper.php @@ -118,7 +118,7 @@ protected function renderAttributes(array $attributes): string * @return string * @throws Exception */ - protected function renderElement(string $tag, array $attributes = array()): string + protected function renderElement(string $tag, array $attributes = []): string { } @@ -133,7 +133,7 @@ protected function renderElement(string $tag, array $attributes = array()): stri * @return string * @throws Exception */ - protected function renderFullElement(string $tag, string $text, array $attributes = array(), bool $raw = false): string + protected function renderFullElement(string $tag, string $text, array $attributes = [], bool $raw = false): string { } @@ -146,7 +146,7 @@ protected function renderFullElement(string $tag, string $text, array $attribute * * @return string */ - protected function renderTag(string $tag, array $attributes = array(), string $close = ''): string + protected function renderTag(string $tag, array $attributes = [], string $close = ''): string { } @@ -158,7 +158,7 @@ protected function renderTag(string $tag, array $attributes = array(), string $c * * @return string */ - protected function selfClose(string $tag, array $attributes = array()): string + protected function selfClose(string $tag, array $attributes = []): string { } } diff --git a/src/Phalcon/Html/Helper/AbstractList.php b/src/Html/Helper/AbstractList.php similarity index 89% rename from src/Phalcon/Html/Helper/AbstractList.php rename to src/Html/Helper/AbstractList.php index 5a2c130d..c6ab107d 100644 --- a/src/Phalcon/Html/Helper/AbstractList.php +++ b/src/Html/Helper/AbstractList.php @@ -19,7 +19,7 @@ abstract class AbstractList extends \Phalcon\Html\Helper\AbstractHelper /** * @var array */ - protected $attributes = array(); + protected $attributes = []; /** * @var string @@ -29,7 +29,7 @@ abstract class AbstractList extends \Phalcon\Html\Helper\AbstractHelper /** * @var array */ - protected $store = array(); + protected $store = []; /** @@ -39,7 +39,7 @@ abstract class AbstractList extends \Phalcon\Html\Helper\AbstractHelper * * @return AbstractList */ - public function __invoke(string $indent = null, string $delimiter = null, array $attributes = array()): AbstractList + public function __invoke(string $indent = null, string $delimiter = null, array $attributes = []): AbstractList { } diff --git a/src/Phalcon/Html/Helper/AbstractSeries.php b/src/Html/Helper/AbstractSeries.php similarity index 93% rename from src/Phalcon/Html/Helper/AbstractSeries.php rename to src/Html/Helper/AbstractSeries.php index 6cb0be53..c39df702 100644 --- a/src/Phalcon/Html/Helper/AbstractSeries.php +++ b/src/Html/Helper/AbstractSeries.php @@ -17,12 +17,12 @@ abstract class AbstractSeries extends \Phalcon\Html\Helper\AbstractHelper /** * @var array */ - protected $attributes = array(); + protected $attributes = []; /** * @var array */ - protected $store = array(); + protected $store = []; /** diff --git a/src/Phalcon/Html/Helper/Anchor.php b/src/Html/Helper/Anchor.php similarity index 94% rename from src/Phalcon/Html/Helper/Anchor.php rename to src/Html/Helper/Anchor.php index 2744eb77..43698e2e 100644 --- a/src/Phalcon/Html/Helper/Anchor.php +++ b/src/Html/Helper/Anchor.php @@ -28,7 +28,7 @@ class Anchor extends \Phalcon\Html\Helper\AbstractHelper * @return string * @throws Exception */ - public function __invoke(string $href, string $text, array $attributes = array(), bool $raw = false): string + public function __invoke(string $href, string $text, array $attributes = [], bool $raw = false): string { } diff --git a/src/Phalcon/Html/Helper/Base.php b/src/Html/Helper/Base.php similarity index 96% rename from src/Phalcon/Html/Helper/Base.php rename to src/Html/Helper/Base.php index 4fb37ce4..1a78c430 100644 --- a/src/Phalcon/Html/Helper/Base.php +++ b/src/Html/Helper/Base.php @@ -26,7 +26,7 @@ class Base extends \Phalcon\Html\Helper\AbstractHelper * @return string * @throws Exception */ - public function __invoke(string $href = null, array $attributes = array()): string + public function __invoke(string $href = null, array $attributes = []): string { } } diff --git a/src/Phalcon/Html/Helper/Body.php b/src/Html/Helper/Body.php similarity index 88% rename from src/Phalcon/Html/Helper/Body.php rename to src/Html/Helper/Body.php index afe351eb..f18eaf0e 100644 --- a/src/Phalcon/Html/Helper/Body.php +++ b/src/Html/Helper/Body.php @@ -25,7 +25,7 @@ class Body extends \Phalcon\Html\Helper\AbstractHelper * @return string * @throws Exception */ - public function __invoke(array $attributes = array()): string + public function __invoke(array $attributes = []): string { } } diff --git a/src/Phalcon/Html/Helper/Button.php b/src/Html/Helper/Button.php similarity index 85% rename from src/Phalcon/Html/Helper/Button.php rename to src/Html/Helper/Button.php index 4b89f603..ff246f4c 100644 --- a/src/Phalcon/Html/Helper/Button.php +++ b/src/Html/Helper/Button.php @@ -27,7 +27,7 @@ class Button extends \Phalcon\Html\Helper\AbstractHelper * @return string * @throws Exception */ - public function __invoke(string $text, array $attributes = array(), bool $raw = false): string + public function __invoke(string $text, array $attributes = [], bool $raw = false): string { } } diff --git a/src/Phalcon/Html/Helper/Close.php b/src/Html/Helper/Close.php similarity index 100% rename from src/Phalcon/Html/Helper/Close.php rename to src/Html/Helper/Close.php diff --git a/src/Phalcon/Html/Helper/Element.php b/src/Html/Helper/Element.php similarity index 93% rename from src/Phalcon/Html/Helper/Element.php rename to src/Html/Helper/Element.php index 34889c3a..327d0d76 100644 --- a/src/Phalcon/Html/Helper/Element.php +++ b/src/Html/Helper/Element.php @@ -28,7 +28,7 @@ class Element extends \Phalcon\Html\Helper\AbstractHelper * @return string * @throws Exception */ - public function __invoke(string $tag, string $text, array $attributes = array(), bool $raw = false): string + public function __invoke(string $tag, string $text, array $attributes = [], bool $raw = false): string { } } diff --git a/src/Phalcon/Html/Helper/Form.php b/src/Html/Helper/Form.php similarity index 88% rename from src/Phalcon/Html/Helper/Form.php rename to src/Html/Helper/Form.php index 465e41eb..852e65e4 100644 --- a/src/Phalcon/Html/Helper/Form.php +++ b/src/Html/Helper/Form.php @@ -25,7 +25,7 @@ class Form extends \Phalcon\Html\Helper\AbstractHelper * @return string * @throws Exception */ - public function __invoke(array $attributes = array()): string + public function __invoke(array $attributes = []): string { } } diff --git a/src/Phalcon/Html/Helper/Img.php b/src/Html/Helper/Img.php similarity index 87% rename from src/Phalcon/Html/Helper/Img.php rename to src/Html/Helper/Img.php index 6c0b710f..43cfa6e3 100644 --- a/src/Phalcon/Html/Helper/Img.php +++ b/src/Html/Helper/Img.php @@ -26,7 +26,7 @@ class Img extends \Phalcon\Html\Helper\AbstractHelper * @return string * @throws Exception */ - public function __invoke(string $src, array $attributes = array()): string + public function __invoke(string $src, array $attributes = []): string { } } diff --git a/src/Phalcon/Html/Helper/Input/AbstractInput.php b/src/Html/Helper/Input/AbstractInput.php similarity index 93% rename from src/Phalcon/Html/Helper/Input/AbstractInput.php rename to src/Html/Helper/Input/AbstractInput.php index 7c744170..31dced3b 100644 --- a/src/Phalcon/Html/Helper/Input/AbstractInput.php +++ b/src/Html/Helper/Input/AbstractInput.php @@ -28,7 +28,7 @@ abstract class AbstractInput extends AbstractHelper /** * @var array */ - protected $attributes = array(); + protected $attributes = []; /** @@ -38,7 +38,7 @@ abstract class AbstractInput extends AbstractHelper * * @return AbstractInput */ - public function __invoke(string $name, string $value = null, array $attributes = array()): AbstractInput + public function __invoke(string $name, string $value = null, array $attributes = []): AbstractInput { } diff --git a/src/Phalcon/Html/Helper/Input/Checkbox.php b/src/Html/Helper/Input/Checkbox.php similarity index 90% rename from src/Phalcon/Html/Helper/Input/Checkbox.php rename to src/Html/Helper/Input/Checkbox.php index abd05731..c319dace 100644 --- a/src/Phalcon/Html/Helper/Input/Checkbox.php +++ b/src/Html/Helper/Input/Checkbox.php @@ -21,7 +21,7 @@ class Checkbox extends \Phalcon\Html\Helper\Input\AbstractInput /** * @var array */ - protected $label = array(); + protected $label = []; /** * @var string @@ -54,7 +54,7 @@ public function __toString() * * @return Checkbox */ - public function label(array $attributes = array()): Checkbox + public function label(array $attributes = []): Checkbox { } @@ -63,7 +63,7 @@ public function label(array $attributes = array()): Checkbox * * @return void */ - private function processChecked() + private function processChecked(): void { } diff --git a/src/Phalcon/Html/Helper/Input/Color.php b/src/Html/Helper/Input/Color.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Color.php rename to src/Html/Helper/Input/Color.php diff --git a/src/Phalcon/Html/Helper/Input/Date.php b/src/Html/Helper/Input/Date.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Date.php rename to src/Html/Helper/Input/Date.php diff --git a/src/Phalcon/Html/Helper/Input/DateTime.php b/src/Html/Helper/Input/DateTime.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/DateTime.php rename to src/Html/Helper/Input/DateTime.php diff --git a/src/Phalcon/Html/Helper/Input/DateTimeLocal.php b/src/Html/Helper/Input/DateTimeLocal.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/DateTimeLocal.php rename to src/Html/Helper/Input/DateTimeLocal.php diff --git a/src/Phalcon/Html/Helper/Input/Email.php b/src/Html/Helper/Input/Email.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Email.php rename to src/Html/Helper/Input/Email.php diff --git a/src/Phalcon/Html/Helper/Input/File.php b/src/Html/Helper/Input/File.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/File.php rename to src/Html/Helper/Input/File.php diff --git a/src/Phalcon/Html/Helper/Input/Hidden.php b/src/Html/Helper/Input/Hidden.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Hidden.php rename to src/Html/Helper/Input/Hidden.php diff --git a/src/Phalcon/Html/Helper/Input/Image.php b/src/Html/Helper/Input/Image.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Image.php rename to src/Html/Helper/Input/Image.php diff --git a/src/Phalcon/Html/Helper/Input/Input.php b/src/Html/Helper/Input/Input.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Input.php rename to src/Html/Helper/Input/Input.php diff --git a/src/Phalcon/Html/Helper/Input/Month.php b/src/Html/Helper/Input/Month.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Month.php rename to src/Html/Helper/Input/Month.php diff --git a/src/Phalcon/Html/Helper/Input/Numeric.php b/src/Html/Helper/Input/Numeric.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Numeric.php rename to src/Html/Helper/Input/Numeric.php diff --git a/src/Phalcon/Html/Helper/Input/Password.php b/src/Html/Helper/Input/Password.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Password.php rename to src/Html/Helper/Input/Password.php diff --git a/src/Phalcon/Html/Helper/Input/Radio.php b/src/Html/Helper/Input/Radio.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Radio.php rename to src/Html/Helper/Input/Radio.php diff --git a/src/Phalcon/Html/Helper/Input/Range.php b/src/Html/Helper/Input/Range.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Range.php rename to src/Html/Helper/Input/Range.php diff --git a/src/Phalcon/Html/Helper/Input/Search.php b/src/Html/Helper/Input/Search.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Search.php rename to src/Html/Helper/Input/Search.php diff --git a/src/Phalcon/Html/Helper/Input/Select.php b/src/Html/Helper/Input/Select.php similarity index 94% rename from src/Phalcon/Html/Helper/Input/Select.php rename to src/Html/Helper/Input/Select.php index 559c416e..6b65b7a2 100644 --- a/src/Phalcon/Html/Helper/Input/Select.php +++ b/src/Html/Helper/Input/Select.php @@ -46,7 +46,7 @@ class Select extends AbstractList * * @return Select */ - public function add(string $text, string $value = null, array $attributes = array(), bool $raw = false): Select + public function add(string $text, string $value = null, array $attributes = [], bool $raw = false): Select { } @@ -60,7 +60,7 @@ public function add(string $text, string $value = null, array $attributes = arra * * @return Select */ - public function addPlaceholder(string $text, $value = null, array $attributes = array(), bool $raw = false): Select + public function addPlaceholder(string $text, $value = null, array $attributes = [], bool $raw = false): Select { } @@ -72,7 +72,7 @@ public function addPlaceholder(string $text, $value = null, array $attributes = * * @return Select */ - public function optGroup(string $label = null, array $attributes = array()): Select + public function optGroup(string $label = null, array $attributes = []): Select { } diff --git a/src/Phalcon/Html/Helper/Input/Submit.php b/src/Html/Helper/Input/Submit.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Submit.php rename to src/Html/Helper/Input/Submit.php diff --git a/src/Phalcon/Html/Helper/Input/Tel.php b/src/Html/Helper/Input/Tel.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Tel.php rename to src/Html/Helper/Input/Tel.php diff --git a/src/Phalcon/Html/Helper/Input/Text.php b/src/Html/Helper/Input/Text.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Text.php rename to src/Html/Helper/Input/Text.php diff --git a/src/Phalcon/Html/Helper/Input/Textarea.php b/src/Html/Helper/Input/Textarea.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Textarea.php rename to src/Html/Helper/Input/Textarea.php diff --git a/src/Phalcon/Html/Helper/Input/Time.php b/src/Html/Helper/Input/Time.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Time.php rename to src/Html/Helper/Input/Time.php diff --git a/src/Phalcon/Html/Helper/Input/Url.php b/src/Html/Helper/Input/Url.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Url.php rename to src/Html/Helper/Input/Url.php diff --git a/src/Phalcon/Html/Helper/Input/Week.php b/src/Html/Helper/Input/Week.php similarity index 100% rename from src/Phalcon/Html/Helper/Input/Week.php rename to src/Html/Helper/Input/Week.php diff --git a/src/Phalcon/Html/Helper/Label.php b/src/Html/Helper/Label.php similarity index 88% rename from src/Phalcon/Html/Helper/Label.php rename to src/Html/Helper/Label.php index d19be5f2..44e748df 100644 --- a/src/Phalcon/Html/Helper/Label.php +++ b/src/Html/Helper/Label.php @@ -25,7 +25,7 @@ class Label extends \Phalcon\Html\Helper\AbstractHelper * @return string * @throws Exception */ - public function __invoke(array $attributes = array()): string + public function __invoke(array $attributes = []): string { } } diff --git a/src/Phalcon/Html/Helper/Link.php b/src/Html/Helper/Link.php similarity index 100% rename from src/Phalcon/Html/Helper/Link.php rename to src/Html/Helper/Link.php diff --git a/src/Phalcon/Html/Helper/Meta.php b/src/Html/Helper/Meta.php similarity index 96% rename from src/Phalcon/Html/Helper/Meta.php rename to src/Html/Helper/Meta.php index c14124aa..5a15311c 100644 --- a/src/Phalcon/Html/Helper/Meta.php +++ b/src/Html/Helper/Meta.php @@ -24,7 +24,7 @@ class Meta extends \Phalcon\Html\Helper\AbstractSeries * * @return Meta */ - public function add(array $attributes = array()): Meta + public function add(array $attributes = []): Meta { } diff --git a/src/Phalcon/Html/Helper/Ol.php b/src/Html/Helper/Ol.php similarity index 83% rename from src/Phalcon/Html/Helper/Ol.php rename to src/Html/Helper/Ol.php index e1aa04df..2d114e0e 100644 --- a/src/Phalcon/Html/Helper/Ol.php +++ b/src/Html/Helper/Ol.php @@ -22,10 +22,9 @@ class Ol extends \Phalcon\Html\Helper\AbstractList * @param array $attributes * @param bool $raw * - * @return $this * @return AbstractList */ - public function add(string $text, array $attributes = array(), bool $raw = false): AbstractList + public function add(string $text, array $attributes = [], bool $raw = false): AbstractList { } diff --git a/src/Phalcon/Html/Helper/Script.php b/src/Html/Helper/Script.php similarity index 84% rename from src/Phalcon/Html/Helper/Script.php rename to src/Html/Helper/Script.php index 5ce0b700..37894340 100644 --- a/src/Phalcon/Html/Helper/Script.php +++ b/src/Html/Helper/Script.php @@ -18,12 +18,12 @@ class Script extends \Phalcon\Html\Helper\Style /** * Returns the necessary attributes * - * @param string $src + * @param string $href * @param array $attributes * * @return array */ - protected function getAttributes(string $src, array $attributes): array + protected function getAttributes(string $href, array $attributes): array { } diff --git a/src/Phalcon/Html/Helper/Style.php b/src/Html/Helper/Style.php similarity index 93% rename from src/Phalcon/Html/Helper/Style.php rename to src/Html/Helper/Style.php index a6e6576a..05adc85e 100644 --- a/src/Phalcon/Html/Helper/Style.php +++ b/src/Html/Helper/Style.php @@ -26,7 +26,7 @@ class Style extends \Phalcon\Html\Helper\AbstractSeries * @return $this * @throws Exception */ - public function add(string $href, array $attributes = array()) + public function add(string $href, array $attributes = []) { } diff --git a/src/Phalcon/Html/Helper/Title.php b/src/Html/Helper/Title.php similarity index 96% rename from src/Phalcon/Html/Helper/Title.php rename to src/Html/Helper/Title.php index ab903ad6..f33fa42b 100644 --- a/src/Phalcon/Html/Helper/Title.php +++ b/src/Html/Helper/Title.php @@ -26,12 +26,12 @@ class Title extends \Phalcon\Html\Helper\AbstractHelper /** * @var array */ - protected $append = array(); + protected $append = []; /** * @var array */ - protected $prepend = array(); + protected $prepend = []; /** * @var string diff --git a/src/Phalcon/Html/Helper/Ul.php b/src/Html/Helper/Ul.php similarity index 100% rename from src/Phalcon/Html/Helper/Ul.php rename to src/Html/Helper/Ul.php diff --git a/src/Phalcon/Html/Link/EvolvableLink.php b/src/Html/Link/EvolvableLink.php similarity index 100% rename from src/Phalcon/Html/Link/EvolvableLink.php rename to src/Html/Link/EvolvableLink.php diff --git a/src/Phalcon/Html/Link/EvolvableLinkProvider.php b/src/Html/Link/EvolvableLinkProvider.php similarity index 100% rename from src/Phalcon/Html/Link/EvolvableLinkProvider.php rename to src/Html/Link/EvolvableLinkProvider.php diff --git a/src/Phalcon/Html/Link/Link.php b/src/Html/Link/Link.php similarity index 98% rename from src/Phalcon/Html/Link/Link.php rename to src/Html/Link/Link.php index 73162bf8..ff1acb1b 100644 --- a/src/Phalcon/Html/Link/Link.php +++ b/src/Html/Link/Link.php @@ -51,7 +51,7 @@ class Link implements \Psr\Link\LinkInterface * @param string $href * @param array $attributes */ - public function __construct(string $rel = '', string $href = '', array $attributes = array()) + public function __construct(string $rel = '', string $href = '', array $attributes = []) { } diff --git a/src/Phalcon/Html/Link/LinkProvider.php b/src/Html/Link/LinkProvider.php similarity index 89% rename from src/Phalcon/Html/Link/LinkProvider.php rename to src/Html/Link/LinkProvider.php index a7829ba5..9d5d2088 100644 --- a/src/Phalcon/Html/Link/LinkProvider.php +++ b/src/Html/Link/LinkProvider.php @@ -13,8 +13,6 @@ use Psr\Link\LinkProviderInterface; /** - * Class Phalcon\Http\Link\LinkProvider - * * @property LinkInterface[] links */ class LinkProvider implements \Psr\Link\LinkProviderInterface @@ -22,7 +20,7 @@ class LinkProvider implements \Psr\Link\LinkProviderInterface /** * @var LinkInterface[] */ - protected $links = array(); + protected $links = []; /** @@ -30,7 +28,7 @@ class LinkProvider implements \Psr\Link\LinkProviderInterface * * @param array $links */ - public function __construct(array $links = array()) + public function __construct(array $links = []) { } @@ -54,7 +52,7 @@ public function getLinks() * with that relationship are available, an empty array or \Traversable * MUST be returned. * - * @return LinkInterface[]|Traversable + * @return LinkInterface[]|\Traversable * @param mixed $rel */ public function getLinksByRel($rel) diff --git a/src/Phalcon/Html/Link/Serializer/Header.php b/src/Html/Link/Serializer/Header.php similarity index 100% rename from src/Phalcon/Html/Link/Serializer/Header.php rename to src/Html/Link/Serializer/Header.php diff --git a/src/Phalcon/Html/Link/Serializer/SerializerInterface.php b/src/Html/Link/Serializer/SerializerInterface.php similarity index 100% rename from src/Phalcon/Html/Link/Serializer/SerializerInterface.php rename to src/Html/Link/Serializer/SerializerInterface.php diff --git a/src/Phalcon/Html/TagFactory.php b/src/Html/TagFactory.php similarity index 91% rename from src/Phalcon/Html/TagFactory.php rename to src/Html/TagFactory.php index a492e0de..41c3e20a 100644 --- a/src/Phalcon/Html/TagFactory.php +++ b/src/Html/TagFactory.php @@ -9,7 +9,6 @@ */ namespace Phalcon\Html; -use Phalcon\Escaper; use Phalcon\Escaper\EscaperInterface; use Phalcon\Factory\AbstractFactory; @@ -18,6 +17,9 @@ */ class TagFactory extends AbstractFactory { + + protected $exception = 'Phalcon\\\\Html\\\\Exception'; + /** * @var EscaperInterface */ @@ -30,7 +32,7 @@ class TagFactory extends AbstractFactory * @param \Phalcon\Escaper\EscaperInterface $escaper * @param array $services */ - public function __construct(\Phalcon\Escaper\EscaperInterface $escaper, array $services = array()) + public function __construct(\Phalcon\Escaper\EscaperInterface $escaper, array $services = []) { } diff --git a/src/Phalcon/Http/Cookie.php b/src/Http/Cookie.php similarity index 95% rename from src/Phalcon/Http/Cookie.php rename to src/Http/Cookie.php index 9009f6c9..ddbf8bbc 100644 --- a/src/Phalcon/Http/Cookie.php +++ b/src/Http/Cookie.php @@ -10,6 +10,7 @@ namespace Phalcon\Http; use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Filter\FilterInterface; use Phalcon\Http\Cookie\CookieInterface; /** @@ -27,8 +28,10 @@ class Cookie extends AbstractInjectionAware implements \Phalcon\Http\Cookie\Cook */ protected $expire; - - protected $filter; + /** + * @var FilterInterface|null + */ + protected $filter = null; /** * @var bool @@ -43,7 +46,7 @@ class Cookie extends AbstractInjectionAware implements \Phalcon\Http\Cookie\Cook /** * @var array */ - protected $options = array(); + protected $options = []; /** * @var string @@ -63,7 +66,7 @@ class Cookie extends AbstractInjectionAware implements \Phalcon\Http\Cookie\Cook /** * @var bool */ - protected $secure; + protected $secure = true; /** * The cookie's sign key. @@ -78,9 +81,9 @@ class Cookie extends AbstractInjectionAware implements \Phalcon\Http\Cookie\Cook protected $useEncryption = false; /** - * @var mixed + * @var mixed|null */ - protected $value; + protected $value = null; /** @@ -95,7 +98,7 @@ class Cookie extends AbstractInjectionAware implements \Phalcon\Http\Cookie\Cook * @param bool $httpOnly * @param array $options */ - public function __construct(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = false, array $options = array()) + public function __construct(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null, array $options = []) { } @@ -327,7 +330,7 @@ public function useEncryption(bool $useEncryption): CookieInterface * @param string $signKey * @return void */ - protected function assertSignKeyIsLongEnough(string $signKey) + protected function assertSignKeyIsLongEnough(string $signKey): void { } } diff --git a/src/Phalcon/Http/Cookie/CookieInterface.php b/src/Http/Cookie/CookieInterface.php similarity index 100% rename from src/Phalcon/Http/Cookie/CookieInterface.php rename to src/Http/Cookie/CookieInterface.php diff --git a/src/Phalcon/Http/Cookie/Exception.php b/src/Http/Cookie/Exception.php similarity index 100% rename from src/Phalcon/Http/Cookie/Exception.php rename to src/Http/Cookie/Exception.php diff --git a/src/Phalcon/Http/Message/AbstractCommon.php b/src/Http/Message/AbstractCommon.php similarity index 93% rename from src/Phalcon/Http/Message/AbstractCommon.php rename to src/Http/Message/AbstractCommon.php index 020e9e42..86123f61 100644 --- a/src/Phalcon/Http/Message/AbstractCommon.php +++ b/src/Http/Message/AbstractCommon.php @@ -33,7 +33,7 @@ final protected function cloneInstance($element, string $property) * @param mixed $element * @return void */ - final protected function checkStringParameter($element) + final protected function checkStringParameter($element): void { } diff --git a/src/Phalcon/Http/Message/AbstractMessage.php b/src/Http/Message/AbstractMessage.php similarity index 97% rename from src/Phalcon/Http/Message/AbstractMessage.php rename to src/Http/Message/AbstractMessage.php index 1aea59bc..a3657dd5 100644 --- a/src/Phalcon/Http/Message/AbstractMessage.php +++ b/src/Http/Message/AbstractMessage.php @@ -181,9 +181,6 @@ public function hasHeader($name): bool * @param string|string[] $value * * @return static - * @param mixed $value - * @param string|string [] $value - * */ public function withAddedHeader($name, $value) { @@ -225,9 +222,6 @@ public function withBody(\Psr\Http\Message\StreamInterface $body) * @return static * @throws InvalidArgumentException for invalid header names or values. * - * @param mixed $value - * @param string|string [] $value - * */ public function withHeader($name, $value) { @@ -288,7 +282,7 @@ final protected function checkHeaderHost(\Phalcon\Collection\CollectionInterface * @param mixed $name * @return void */ - final protected function checkHeaderName($name) + final protected function checkHeaderName($name): void { } @@ -339,7 +333,7 @@ final protected function checkHeaderName($name) * @param mixed $value * @return void */ - final protected function checkHeaderValue($value) + final protected function checkHeaderValue($value): void { } diff --git a/src/Phalcon/Http/Message/AbstractRequest.php b/src/Http/Message/AbstractRequest.php similarity index 100% rename from src/Phalcon/Http/Message/AbstractRequest.php rename to src/Http/Message/AbstractRequest.php diff --git a/src/Phalcon/Http/Message/Exception/InvalidArgumentException.php b/src/Http/Message/Exception/InvalidArgumentException.php similarity index 100% rename from src/Phalcon/Http/Message/Exception/InvalidArgumentException.php rename to src/Http/Message/Exception/InvalidArgumentException.php diff --git a/src/Phalcon/Http/Message/Request.php b/src/Http/Message/Request.php similarity index 86% rename from src/Phalcon/Http/Message/Request.php rename to src/Http/Message/Request.php index ec21b4b3..ed6eac3a 100644 --- a/src/Phalcon/Http/Message/Request.php +++ b/src/Http/Message/Request.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Http\Message; -use Phalcon\Http\Message\Stream\Input; -use Phalcon\Http\Message\AbstractRequest; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UriInterface; @@ -29,7 +27,7 @@ final class Request extends AbstractRequest implements \Psr\Http\Message\Request * @param StreamInterface|resource|string $body * @param array $headers */ - public function __construct(string $method = 'GET', $uri = null, $body = 'php://memory', $headers = array()) + public function __construct(string $method = 'GET', $uri = null, $body = 'php://memory', $headers = []) { } } diff --git a/src/Phalcon/Http/Message/RequestFactory.php b/src/Http/Message/RequestFactory.php similarity index 100% rename from src/Phalcon/Http/Message/RequestFactory.php rename to src/Http/Message/RequestFactory.php index 10fa956d..b7bd65e4 100644 --- a/src/Phalcon/Http/Message/RequestFactory.php +++ b/src/Http/Message/RequestFactory.php @@ -9,8 +9,8 @@ */ namespace Phalcon\Http\Message; -use Psr\Http\Message\RequestInterface; use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\RequestInterface; use Psr\Http\Message\UriInterface; /** diff --git a/src/Phalcon/Http/Message/Response.php b/src/Http/Message/Response.php similarity index 92% rename from src/Phalcon/Http/Message/Response.php rename to src/Http/Message/Response.php index 9e83ecee..f33d0e78 100644 --- a/src/Phalcon/Http/Message/Response.php +++ b/src/Http/Message/Response.php @@ -9,9 +9,6 @@ */ namespace Phalcon\Http\Message; -use Phalcon\Helper\Number; -use Phalcon\Http\Message\AbstractMessage; -use Phalcon\Http\Message\Exception\InvalidArgumentException; use Psr\Http\Message\ResponseInterface; /** @@ -82,7 +79,7 @@ public function getStatusCode(): int * @param int $code * @param array $headers */ - public function __construct($body = 'php://memory', int $code = 200, array $headers = array()) + public function __construct($body = 'php://memory', int $code = 200, array $headers = []) { } @@ -126,7 +123,7 @@ protected function getPhrases(): array * @param mixed $phrase * @return void */ - protected function processCode($code, $phrase = '') + protected function processCode($code, $phrase = ''): void { } @@ -136,7 +133,7 @@ protected function processCode($code, $phrase = '') * @param mixed $code * @return void */ - private function checkCodeType($code) + private function checkCodeType($code): void { } @@ -146,7 +143,7 @@ private function checkCodeType($code) * @param int $code * @return void */ - private function checkCodeValue(int $code) + private function checkCodeValue(int $code): void { } } diff --git a/src/Phalcon/Http/Message/ResponseFactory.php b/src/Http/Message/ResponseFactory.php similarity index 100% rename from src/Phalcon/Http/Message/ResponseFactory.php rename to src/Http/Message/ResponseFactory.php index 44d9504c..7491c31a 100644 --- a/src/Phalcon/Http/Message/ResponseFactory.php +++ b/src/Http/Message/ResponseFactory.php @@ -9,8 +9,8 @@ */ namespace Phalcon\Http\Message; -use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseFactoryInterface; +use Psr\Http\Message\ResponseInterface; /** * PSR-17 ResponseFactory diff --git a/src/Phalcon/Http/Message/ServerRequest.php b/src/Http/Message/ServerRequest.php similarity index 96% rename from src/Phalcon/Http/Message/ServerRequest.php rename to src/Http/Message/ServerRequest.php index f605b1dd..d84e0e99 100644 --- a/src/Phalcon/Http/Message/ServerRequest.php +++ b/src/Http/Message/ServerRequest.php @@ -12,7 +12,6 @@ use Phalcon\Collection; use Phalcon\Collection\CollectionInterface; use Phalcon\Http\Message\Exception\InvalidArgumentException; -use Phalcon\Http\Message\Stream\Input; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UploadedFileInterface; @@ -38,7 +37,7 @@ final class ServerRequest extends \Phalcon\Http\Message\AbstractRequest implemen * * @var array */ - protected $cookieParams = array(); + protected $cookieParams = []; /** * Retrieve any parameters provided in the request body. @@ -68,7 +67,7 @@ final class ServerRequest extends \Phalcon\Http\Message\AbstractRequest implemen * * @var array */ - protected $queryParams = array(); + protected $queryParams = []; /** * Retrieve server parameters. @@ -79,7 +78,7 @@ final class ServerRequest extends \Phalcon\Http\Message\AbstractRequest implemen * * @var array */ - protected $serverParams = array(); + protected $serverParams = []; /** * Retrieve normalized file upload data. @@ -92,7 +91,7 @@ final class ServerRequest extends \Phalcon\Http\Message\AbstractRequest implemen * * @var array */ - protected $uploadedFiles = array(); + protected $uploadedFiles = []; /** @@ -185,7 +184,7 @@ public function getUploadedFiles(): array * @param null|array|object $parsedBody * @param string $protocol */ - public function __construct(string $method = 'GET', $uri = null, array $serverParams = array(), $body = 'php://input', $headers = array(), array $cookies = array(), array $queryParams = array(), array $uploadFiles = array(), $parsedBody = null, string $protocol = '1.1') + public function __construct(string $method = 'GET', $uri = null, array $serverParams = [], $body = 'php://input', $headers = [], array $cookies = [], array $queryParams = [], array $uploadFiles = [], $parsedBody = null, string $protocol = '1.1') { } @@ -363,7 +362,7 @@ public function withoutAttribute($name): ServerRequest * @param array $files * @return void */ - private function checkUploadedFiles(array $files) + private function checkUploadedFiles(array $files): void { } } diff --git a/src/Phalcon/Http/Message/ServerRequestFactory.php b/src/Http/Message/ServerRequestFactory.php similarity index 98% rename from src/Phalcon/Http/Message/ServerRequestFactory.php rename to src/Http/Message/ServerRequestFactory.php index 395c96f5..bfe9d935 100644 --- a/src/Phalcon/Http/Message/ServerRequestFactory.php +++ b/src/Http/Message/ServerRequestFactory.php @@ -9,14 +9,12 @@ */ namespace Phalcon\Http\Message; -use Phalcon\Collection; use Phalcon\Collection\CollectionInterface; -use Phalcon\Helper\Arr; use Phalcon\Http\Message\Exception\InvalidArgumentException; use Psr\Http\Message\ServerRequestFactoryInterface; use Psr\Http\Message\ServerRequestInterface; -use Psr\Http\Message\UriInterface; use Psr\Http\Message\UploadedFileInterface; +use Psr\Http\Message\UriInterface; /** * PSR-17 ServerRequestFactory @@ -45,7 +43,7 @@ class ServerRequestFactory implements \Psr\Http\Message\ServerRequestFactoryInte * * @return ServerRequestInterface */ - public function createServerRequest(string $method, $uri, array $serverParams = array()): ServerRequestInterface + public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface { } diff --git a/src/Phalcon/Http/Message/Stream.php b/src/Http/Message/Stream.php similarity index 91% rename from src/Phalcon/Http/Message/Stream.php rename to src/Http/Message/Stream.php index 285e05ba..16e6b507 100644 --- a/src/Phalcon/Http/Message/Stream.php +++ b/src/Http/Message/Stream.php @@ -9,10 +9,7 @@ */ namespace Phalcon\Http\Message; -use Phalcon\Helper\Arr; -use Exception; use Psr\Http\Message\StreamInterface; -use RuntimeException; /** * PSR-7 Stream @@ -70,7 +67,7 @@ public function __toString(): string * * @return void */ - public function close() + public function close(): void { } @@ -120,7 +117,7 @@ public function getMetadata($key = null) /** * Get the size of the stream if known. * - * @return null|int + * @return int|null */ public function getSize(): ?int { @@ -172,7 +169,7 @@ public function read($length): string * * @return void */ - public function rewind() + public function rewind(): void { } @@ -183,7 +180,7 @@ public function rewind() * @param int $whence * @return void */ - public function seek($offset, $whence = 0) + public function seek($offset, $whence = 0): void { } @@ -194,7 +191,7 @@ public function seek($offset, $whence = 0) * @param string $mode * @return void */ - public function setStream($stream, string $mode = 'rb') + public function setStream($stream, string $mode = 'rb'): void { } @@ -223,7 +220,7 @@ public function write($data): int * * @return void */ - private function checkHandle() + private function checkHandle(): void { } @@ -232,7 +229,7 @@ private function checkHandle() * * @return void */ - private function checkReadable() + private function checkReadable(): void { } @@ -241,7 +238,7 @@ private function checkReadable() * * @return void */ - private function checkSeekable() + private function checkSeekable(): void { } @@ -250,7 +247,7 @@ private function checkSeekable() * * @return void */ - private function checkWritable() + private function checkWritable(): void { } } diff --git a/src/Phalcon/Http/Message/Stream/Input.php b/src/Http/Message/Stream/Input.php similarity index 94% rename from src/Phalcon/Http/Message/Stream/Input.php rename to src/Http/Message/Stream/Input.php index 2e3f6696..842c8721 100644 --- a/src/Phalcon/Http/Message/Stream/Input.php +++ b/src/Http/Message/Stream/Input.php @@ -59,11 +59,9 @@ public function __toString(): string /** * Returns the remaining contents in a string * - * @throws RuntimeException if unable to read. - * @throws RuntimeException if error occurs while reading. - * * @param int $length * + * @throws \RuntimeException If unable to read or if error occurs while reading. * @return string */ public function getContents(int $length = -1): string diff --git a/src/Phalcon/Http/Message/Stream/Memory.php b/src/Http/Message/Stream/Memory.php similarity index 100% rename from src/Phalcon/Http/Message/Stream/Memory.php rename to src/Http/Message/Stream/Memory.php diff --git a/src/Phalcon/Http/Message/Stream/Temp.php b/src/Http/Message/Stream/Temp.php similarity index 100% rename from src/Phalcon/Http/Message/Stream/Temp.php rename to src/Http/Message/Stream/Temp.php diff --git a/src/Phalcon/Http/Message/StreamFactory.php b/src/Http/Message/StreamFactory.php similarity index 96% rename from src/Phalcon/Http/Message/StreamFactory.php rename to src/Http/Message/StreamFactory.php index 9a1c4b9f..f8401d0d 100644 --- a/src/Phalcon/Http/Message/StreamFactory.php +++ b/src/Http/Message/StreamFactory.php @@ -9,7 +9,6 @@ */ namespace Phalcon\Http\Message; -use Phalcon\Http\Message\Exception\InvalidArgumentException; use Psr\Http\Message\StreamFactoryInterface; use Psr\Http\Message\StreamInterface; diff --git a/src/Phalcon/Http/Message/UploadedFile.php b/src/Http/Message/UploadedFile.php similarity index 96% rename from src/Phalcon/Http/Message/UploadedFile.php rename to src/Http/Message/UploadedFile.php index 89c07508..0f32dcac 100644 --- a/src/Phalcon/Http/Message/UploadedFile.php +++ b/src/Http/Message/UploadedFile.php @@ -9,9 +9,6 @@ */ namespace Phalcon\Http\Message; -use Phalcon\Helper\Number; -use Phalcon\Helper\Arr; -use Phalcon\Helper\Str; use Phalcon\Http\Message\Exception\InvalidArgumentException; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UploadedFileInterface; @@ -229,7 +226,7 @@ public function getStream() * the second or subsequent call to the method. * @return void */ - public function moveTo($targetPath) + public function moveTo($targetPath): void { } @@ -239,7 +236,7 @@ public function moveTo($targetPath) * @param int $error * @return void */ - private function checkError(int $error) + private function checkError(int $error): void { } @@ -250,7 +247,7 @@ private function checkError(int $error) * @param int $error * @return void */ - private function checkStream($stream, int $error) + private function checkStream($stream, int $error): void { } @@ -271,7 +268,7 @@ private function getErrorDescription(int $error): string * @param string $targetPath * @return void */ - private function storeFile(string $targetPath) + private function storeFile(string $targetPath): void { } } diff --git a/src/Phalcon/Http/Message/UploadedFileFactory.php b/src/Http/Message/UploadedFileFactory.php similarity index 100% rename from src/Phalcon/Http/Message/UploadedFileFactory.php rename to src/Http/Message/UploadedFileFactory.php index a8c31f4e..e01d2ad4 100644 --- a/src/Phalcon/Http/Message/UploadedFileFactory.php +++ b/src/Http/Message/UploadedFileFactory.php @@ -10,8 +10,8 @@ namespace Phalcon\Http\Message; use Psr\Http\Message\StreamInterface; -use Psr\Http\Message\UploadedFileInterface; use Psr\Http\Message\UploadedFileFactoryInterface; +use Psr\Http\Message\UploadedFileInterface; /** * PSR-17 UploadedFileFactory diff --git a/src/Phalcon/Http/Message/Uri.php b/src/Http/Message/Uri.php similarity index 96% rename from src/Phalcon/Http/Message/Uri.php rename to src/Http/Message/Uri.php index d6154af1..ee465196 100644 --- a/src/Phalcon/Http/Message/Uri.php +++ b/src/Http/Message/Uri.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Http\Message; -use Phalcon\Helper\Arr; -use Phalcon\Helper\Str; use Phalcon\Http\Message\Exception\InvalidArgumentException; use Psr\Http\Message\UriInterface; @@ -22,7 +20,7 @@ final class Uri extends \Phalcon\Http\Message\AbstractCommon implements \Psr\Htt /** * Returns the fragment of the URL * - * @return string + * @var string */ protected $fragment = ''; @@ -36,7 +34,7 @@ final class Uri extends \Phalcon\Http\Message\AbstractCommon implements \Psr\Htt * * @see http://tools.ietf.org/html/rfc3986#section-3.2.2 * - * @return string + * @var string */ protected $host = ''; @@ -48,7 +46,7 @@ final class Uri extends \Phalcon\Http\Message\AbstractCommon implements \Psr\Htt /** * Returns the path of the URL * - * @return string + * @var string */ protected $path = ''; @@ -65,14 +63,14 @@ final class Uri extends \Phalcon\Http\Message\AbstractCommon implements \Psr\Htt * If no port is present, but a scheme is present, this method MAY return * the standard port for that scheme, but SHOULD return null. * - * @return int|null + * @var int|null */ protected $port = null; /** * Returns the query of the URL * - * @return string + * @var string */ protected $query = ''; @@ -89,7 +87,7 @@ final class Uri extends \Phalcon\Http\Message\AbstractCommon implements \Psr\Htt * * @see https://tools.ietf.org/html/rfc3986#section-3.1 * - * @return string + * @var string */ protected $scheme = 'https'; @@ -101,8 +99,10 @@ final class Uri extends \Phalcon\Http\Message\AbstractCommon implements \Psr\Htt /** * Returns the fragment of the URL + * + * @return string */ - public function getFragment() + public function getFragment(): string { } @@ -113,15 +113,19 @@ public function getFragment() * * The value returned MUST be normalized to lowercase, per RFC 3986 * Section 3.2.2. + * + * @return string */ - public function getHost() + public function getHost(): string { } /** * Returns the path of the URL + * + * @return string */ - public function getPath() + public function getPath(): string { } @@ -137,15 +141,19 @@ public function getPath() * * If no port is present, but a scheme is present, this method MAY return * the standard port for that scheme, but SHOULD return null. + * + * @return int|null */ - public function getPort() + public function getPort(): ?int { } /** * Returns the query of the URL + * + * @return string */ - public function getQuery() + public function getQuery(): string { } @@ -159,8 +167,10 @@ public function getQuery() * * The trailing ":" character is not part of the scheme and MUST NOT be * added. + * + * @return string */ - public function getScheme() + public function getScheme(): string { } @@ -424,9 +434,9 @@ private function filterPath(string $path): string * * @param int|null $port * - * @return int + * @return int|null */ - private function filterPort($port): int + private function filterPort($port): ?int { } diff --git a/src/Phalcon/Http/Message/UriFactory.php b/src/Http/Message/UriFactory.php similarity index 100% rename from src/Phalcon/Http/Message/UriFactory.php rename to src/Http/Message/UriFactory.php diff --git a/src/Phalcon/Http/Request.php b/src/Http/Request.php similarity index 98% rename from src/Phalcon/Http/Request.php rename to src/Http/Request.php index eb9b47f8..8df8ad66 100644 --- a/src/Phalcon/Http/Request.php +++ b/src/Http/Request.php @@ -9,16 +9,8 @@ */ namespace Phalcon\Http; -use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; -use Phalcon\Events\ManagerInterface; use Phalcon\Filter\FilterInterface; -use Phalcon\Helper\Json; -use Phalcon\Http\Request\File; -use Phalcon\Http\Request\FileInterface; -use Phalcon\Http\Request\Exception; -use UnexpectedValueException; -use stdClass; /** * Encapsulates request information for easy and secure access from application @@ -48,8 +40,10 @@ */ class Request extends AbstractInjectionAware implements \Phalcon\Http\RequestInterface { - - private $filterService; + /** + * @var FilterInterface|null + */ + private $filterService = null; /** * @var bool @@ -59,13 +53,17 @@ class Request extends AbstractInjectionAware implements \Phalcon\Http\RequestInt /** * @var array */ - private $queryFilters = array(); - - - private $putCache; + private $queryFilters = []; + /** + * @var array|null + */ + private $putCache = null; - private $rawBody; + /** + * @var string + */ + private $rawBody = ''; /** * @var bool @@ -783,7 +781,7 @@ public function numFiles(bool $onlySuccessful = false): int * @param array $scope * @return RequestInterface */ - public function setParameterFilters(string $name, array $filters = array(), array $scope = array()): RequestInterface + public function setParameterFilters(string $name, array $filters = [], array $scope = []): RequestInterface { } diff --git a/src/Phalcon/Http/Request/Exception.php b/src/Http/Request/Exception.php similarity index 100% rename from src/Phalcon/Http/Request/Exception.php rename to src/Http/Request/Exception.php diff --git a/src/Phalcon/Http/Request/File.php b/src/Http/Request/File.php similarity index 90% rename from src/Phalcon/Http/Request/File.php rename to src/Http/Request/File.php index eb3c6500..370b45c5 100644 --- a/src/Phalcon/Http/Request/File.php +++ b/src/Http/Request/File.php @@ -37,7 +37,7 @@ class File implements \Phalcon\Http\Request\FileInterface /** * @var string|null */ - protected $error; + protected $error = null; /** * @var string @@ -47,21 +47,31 @@ class File implements \Phalcon\Http\Request\FileInterface /** * @var string|null */ - protected $key; - + protected $key = null; + /** + * @var string + */ protected $name; - + /** + * @var string + */ protected $realType; + /** + * @var int + */ + protected $size = 0; - protected $size; - - - protected $tmp; - + /** + * @var string|null + */ + protected $tmp = null; + /** + * @var string + */ protected $type; diff --git a/src/Phalcon/Http/Request/FileInterface.php b/src/Http/Request/FileInterface.php similarity index 100% rename from src/Phalcon/Http/Request/FileInterface.php rename to src/Http/Request/FileInterface.php diff --git a/src/Phalcon/Http/RequestInterface.php b/src/Http/RequestInterface.php similarity index 99% rename from src/Phalcon/Http/RequestInterface.php rename to src/Http/RequestInterface.php index 87afbfac..44d54fd1 100644 --- a/src/Phalcon/Http/RequestInterface.php +++ b/src/Http/RequestInterface.php @@ -9,9 +9,6 @@ */ namespace Phalcon\Http; -use Phalcon\Http\Request\FileInterface; -use stdClass; - /** * Interface for Phalcon\Http\Request */ diff --git a/src/Phalcon/Http/Response.php b/src/Http/Response.php similarity index 93% rename from src/Phalcon/Http/Response.php rename to src/Http/Response.php index 101de485..a5faf918 100644 --- a/src/Phalcon/Http/Response.php +++ b/src/Http/Response.php @@ -9,21 +9,11 @@ */ namespace Phalcon\Http; -use DateTime; -use DateTimeZone; -use Phalcon\Di; use Phalcon\Di\DiInterface; -use Phalcon\Helper\Fs; -use Phalcon\Helper\Json; -use Phalcon\Http\Response\Exception; -use Phalcon\Http\Response\HeadersInterface; +use Phalcon\Events\ManagerInterface; use Phalcon\Http\Response\CookiesInterface; -use Phalcon\Url\UrlInterface; -use Phalcon\Mvc\ViewInterface; use Phalcon\Http\Response\Headers; -use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Events\EventsAwareInterface; -use Phalcon\Events\ManagerInterface; +use Phalcon\Http\Response\HeadersInterface; /** * Part of the HTTP cycle is return responses to the clients. @@ -41,22 +31,34 @@ */ class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface { + /** + * @var DiInterface|null + */ + protected $container = null; - protected $container; - - - protected $content; - - - protected $cookies; - - - protected $eventsManager; + /** + * @var string|null + */ + protected $content = null; + /** + * @var CookiesInterface|null + */ + protected $cookies = null; - protected $file; + /** + * @var ManagerInterface|null + */ + protected $eventsManager = null; + /** + * @var string|null + */ + protected $file = null; + /** + * @var Headers + */ protected $headers; /** @@ -64,8 +66,10 @@ class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\Injection */ protected $sent = false; - - protected $statusCodes; + /** + * @var array + */ + protected $statusCodes = []; /** @@ -119,9 +123,9 @@ public function getDI(): DiInterface /** * Returns the internal event manager * - * @return ManagerInterface + * @return ManagerInterface|null */ - public function getEventsManager(): ManagerInterface + public function getEventsManager(): ?ManagerInterface { } @@ -255,7 +259,7 @@ public function sendCookies(): ResponseInterface /** * Sends headers to the client * - * @return bool|ResponseInterface + * @return 0|ResponseInterface */ public function sendHeaders() { @@ -335,7 +339,7 @@ public function setCookies(\Phalcon\Http\Response\CookiesInterface $cookies): Re * @param \Phalcon\Di\DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(\Phalcon\Di\DiInterface $container): void { } @@ -379,7 +383,7 @@ public function setExpires(\DateTime $datetime): ResponseInterface * @param \Phalcon\Events\ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): void { } diff --git a/src/Phalcon/Http/Response/Cookies.php b/src/Http/Response/Cookies.php similarity index 92% rename from src/Phalcon/Http/Response/Cookies.php rename to src/Http/Response/Cookies.php index 65e8d588..1a8fb021 100644 --- a/src/Phalcon/Http/Response/Cookies.php +++ b/src/Http/Response/Cookies.php @@ -62,10 +62,19 @@ */ class Cookies extends AbstractInjectionAware implements \Phalcon\Http\Response\CookiesInterface { + /** + * @var array + */ + protected $cookies = []; - protected $cookies = array(); - + /** + * @var bool + */ + protected $isSent = false; + /** + * @var bool + */ protected $registered = false; /** @@ -75,7 +84,9 @@ class Cookies extends AbstractInjectionAware implements \Phalcon\Http\Response\C */ protected $signKey = null; - + /** + * @var bool + */ protected $useEncryption = true; @@ -130,6 +141,15 @@ public function has(string $name): bool { } + /** + * Returns if the headers have already been sent + * + * @return bool + */ + public function isSent(): bool + { + } + /** * Returns if the bag is automatically encrypting/decrypting cookies * @@ -187,7 +207,7 @@ public function send(): bool * @param array $options * @return CookiesInterface */ - public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null, array $options = array()): CookiesInterface + public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null, array $options = []): CookiesInterface { } diff --git a/src/Phalcon/Http/Response/CookiesInterface.php b/src/Http/Response/CookiesInterface.php similarity index 96% rename from src/Phalcon/Http/Response/CookiesInterface.php rename to src/Http/Response/CookiesInterface.php index 03442829..149931cb 100644 --- a/src/Phalcon/Http/Response/CookiesInterface.php +++ b/src/Http/Response/CookiesInterface.php @@ -78,7 +78,7 @@ public function send(): bool; * @param array $options * @return CookiesInterface */ - public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null, array $options = array()): CookiesInterface; + public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null, array $options = []): CookiesInterface; /** * Set if cookies in the bag must be automatically encrypted/decrypted diff --git a/src/Phalcon/Http/Response/Exception.php b/src/Http/Response/Exception.php similarity index 100% rename from src/Phalcon/Http/Response/Exception.php rename to src/Http/Response/Exception.php diff --git a/src/Phalcon/Http/Response/Headers.php b/src/Http/Response/Headers.php similarity index 87% rename from src/Phalcon/Http/Response/Headers.php rename to src/Http/Response/Headers.php index dc91141d..b4dbfc17 100644 --- a/src/Phalcon/Http/Response/Headers.php +++ b/src/Http/Response/Headers.php @@ -16,8 +16,15 @@ */ class Headers implements \Phalcon\Http\Response\HeadersInterface { + /** + * @var array + */ + protected $headers = []; - protected $headers = array(); + /** + * @var bool + */ + protected $isSent = false; /** @@ -40,6 +47,15 @@ public function has(string $name): bool { } + /** + * Returns if the headers have already been sent + * + * @return bool + */ + public function isSent(): bool + { + } + /** * Removes a header to be sent at the end of the request * diff --git a/src/Phalcon/Http/Response/HeadersInterface.php b/src/Http/Response/HeadersInterface.php similarity index 100% rename from src/Phalcon/Http/Response/HeadersInterface.php rename to src/Http/Response/HeadersInterface.php diff --git a/src/Phalcon/Http/ResponseInterface.php b/src/Http/ResponseInterface.php similarity index 98% rename from src/Phalcon/Http/ResponseInterface.php rename to src/Http/ResponseInterface.php index 89e14993..07e1e700 100644 --- a/src/Phalcon/Http/ResponseInterface.php +++ b/src/Http/ResponseInterface.php @@ -9,7 +9,6 @@ */ namespace Phalcon\Http; -use DateTime; use Phalcon\Http\Response\HeadersInterface; /** @@ -189,7 +188,7 @@ public function sendCookies(): ResponseInterface; /** * Sends headers to the client * - * @return bool|ResponseInterface + * @return 0|ResponseInterface */ public function sendHeaders(); } diff --git a/src/Phalcon/Http/Server/AbstractMiddleware.php b/src/Http/Server/AbstractMiddleware.php similarity index 100% rename from src/Phalcon/Http/Server/AbstractMiddleware.php rename to src/Http/Server/AbstractMiddleware.php diff --git a/src/Phalcon/Http/Server/AbstractRequestHandler.php b/src/Http/Server/AbstractRequestHandler.php similarity index 100% rename from src/Phalcon/Http/Server/AbstractRequestHandler.php rename to src/Http/Server/AbstractRequestHandler.php diff --git a/src/Phalcon/Image/Adapter/AbstractAdapter.php b/src/Image/Adapter/AbstractAdapter.php similarity index 95% rename from src/Phalcon/Image/Adapter/AbstractAdapter.php rename to src/Image/Adapter/AbstractAdapter.php index 24633d97..859c10d9 100644 --- a/src/Phalcon/Image/Adapter/AbstractAdapter.php +++ b/src/Image/Adapter/AbstractAdapter.php @@ -18,10 +18,14 @@ */ abstract class AbstractAdapter implements \Phalcon\Image\Adapter\AdapterInterface { - + /** + * @var bool + */ protected static $checked = false; - + /** + * @var string + */ protected $file; /** @@ -31,8 +35,10 @@ abstract class AbstractAdapter implements \Phalcon\Image\Adapter\AdapterInterfac */ protected $height; - - protected $image; + /** + * @var object|null + */ + protected $image = null; /** * Image mime type @@ -41,7 +47,9 @@ abstract class AbstractAdapter implements \Phalcon\Image\Adapter\AdapterInterfac */ protected $mime; - + /** + * @var string + */ protected $realpath; /** @@ -70,7 +78,9 @@ public function getHeight(): int { } - + /** + * @return object|null + */ public function getImage() { } @@ -84,8 +94,10 @@ public function getMime(): string { } - - public function getRealpath() + /** + * @return string + */ + public function getRealpath(): string { } diff --git a/src/Phalcon/Image/Adapter/AdapterInterface.php b/src/Image/Adapter/AdapterInterface.php similarity index 100% rename from src/Phalcon/Image/Adapter/AdapterInterface.php rename to src/Image/Adapter/AdapterInterface.php diff --git a/src/Phalcon/Image/Adapter/Gd.php b/src/Image/Adapter/Gd.php similarity index 99% rename from src/Phalcon/Image/Adapter/Gd.php rename to src/Image/Adapter/Gd.php index 719b860b..772b0590 100644 --- a/src/Phalcon/Image/Adapter/Gd.php +++ b/src/Image/Adapter/Gd.php @@ -19,7 +19,9 @@ */ class Gd extends \Phalcon\Image\Adapter\AbstractAdapter { - + /** + * @var bool + */ protected static $checked = false; diff --git a/src/Phalcon/Image/Adapter/Imagick.php b/src/Image/Adapter/Imagick.php similarity index 83% rename from src/Phalcon/Image/Adapter/Imagick.php rename to src/Image/Adapter/Imagick.php index 8991ffb6..6b4e31db 100644 --- a/src/Phalcon/Image/Adapter/Imagick.php +++ b/src/Image/Adapter/Imagick.php @@ -21,16 +21,19 @@ * * if ($image->save()) { * echo "success"; - * * } * ``` */ class Imagick extends \Phalcon\Image\Adapter\AbstractAdapter { - + /** + * @var bool + */ protected static $checked = false; - + /** + * @var int + */ protected static $version = 0; @@ -76,8 +79,9 @@ public function getInternalImInstance(): \Imagick * @link http://php.net/manual/ru/imagick.constants.php#imagick.constants.resourcetypes * @param int $type * @param int $limit + * @return void */ - public function setResourceLimit(int $type, int $limit) + public function setResourceLimit(int $type, int $limit): void { } @@ -88,8 +92,9 @@ public function setResourceLimit(int $type, int $limit) * @param int $g * @param int $b * @param int $opacity + * @return void */ - protected function processBackground(int $r, int $g, int $b, int $opacity) + protected function processBackground(int $r, int $g, int $b, int $opacity): void { } @@ -97,8 +102,9 @@ protected function processBackground(int $r, int $g, int $b, int $opacity) * Blur image * * @param int $radius Blur radius + * @return void */ - protected function processBlur(int $radius) + protected function processBlur(int $radius): void { } @@ -109,8 +115,9 @@ protected function processBlur(int $radius) * @param int $height * @param int $offsetX * @param int $offsetY + * @return void */ - protected function processCrop(int $width, int $height, int $offsetX, int $offsetY) + protected function processCrop(int $width, int $height, int $offsetX, int $offsetY): void { } @@ -118,8 +125,9 @@ protected function processCrop(int $width, int $height, int $offsetX, int $offse * Execute a flip. * * @param int $direction + * @return void */ - protected function processFlip(int $direction) + protected function processFlip(int $direction): void { } @@ -131,8 +139,9 @@ protected function processFlip(int $direction) * @param int $height new height * @param int $deltaX How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. + * @return void */ - protected function processLiquidRescale(int $width, int $height, int $deltaX, int $rigidity) + protected function processLiquidRescale(int $width, int $height, int $deltaX, int $rigidity): void { } @@ -140,8 +149,9 @@ protected function processLiquidRescale(int $width, int $height, int $deltaX, in * Composite one image onto another * * @param AdapterInterface $image + * @return void */ - protected function processMask(AdapterInterface $image) + protected function processMask(AdapterInterface $image): void { } @@ -149,8 +159,9 @@ protected function processMask(AdapterInterface $image) * Pixelate image * * @param int $amount amount to pixelate + * @return void */ - protected function processPixelate(int $amount) + protected function processPixelate(int $amount): void { } @@ -160,8 +171,9 @@ protected function processPixelate(int $amount) * @param int $height * @param int $opacity * @param bool $fadeIn + * @return void */ - protected function processReflection(int $height, int $opacity, bool $fadeIn) + protected function processReflection(int $height, int $opacity, bool $fadeIn): void { } @@ -181,8 +193,9 @@ protected function processRender(string $extension, int $quality): string * * @param int $width * @param int $height + * @return void */ - protected function processResize(int $width, int $height) + protected function processResize(int $width, int $height): void { } @@ -190,8 +203,9 @@ protected function processResize(int $width, int $height) * Execute a rotation. * * @param int $degrees + * @return void */ - protected function processRotate(int $degrees) + protected function processRotate(int $degrees): void { } @@ -200,8 +214,9 @@ protected function processRotate(int $degrees) * * @param string $file * @param int $quality + * @return void */ - protected function processSave(string $file, int $quality) + protected function processSave(string $file, int $quality): void { } diff --git a/src/Phalcon/Image/Enum.php b/src/Image/Enum.php similarity index 100% rename from src/Phalcon/Image/Enum.php rename to src/Image/Enum.php diff --git a/src/Phalcon/Image/Exception.php b/src/Image/Exception.php similarity index 100% rename from src/Phalcon/Image/Exception.php rename to src/Image/Exception.php diff --git a/src/Phalcon/Image/ImageFactory.php b/src/Image/ImageFactory.php similarity index 91% rename from src/Phalcon/Image/ImageFactory.php rename to src/Image/ImageFactory.php index efe9c7c0..bcbd6d45 100644 --- a/src/Phalcon/Image/ImageFactory.php +++ b/src/Image/ImageFactory.php @@ -18,12 +18,15 @@ class ImageFactory extends AbstractFactory { + protected $exception = 'Phalcon\\\\Image\\\\Exception'; + + /** * TagFactory constructor. * * @param array $services */ - public function __construct(array $services = array()) + public function __construct(array $services = []) { } diff --git a/src/Phalcon/Kernel.php b/src/Kernel.php similarity index 100% rename from src/Phalcon/Kernel.php rename to src/Kernel.php diff --git a/src/Phalcon/Loader.php b/src/Loader.php similarity index 92% rename from src/Phalcon/Loader.php rename to src/Loader.php index bbc1a30b..1031fe99 100644 --- a/src/Phalcon/Loader.php +++ b/src/Loader.php @@ -9,9 +9,7 @@ */ namespace Phalcon; -use Phalcon\Loader\Exception; use Phalcon\Events\ManagerInterface; -use Phalcon\Events\EventsAwareInterface; /** * This component helps to load your project classes automatically based on some @@ -41,44 +39,50 @@ */ class Loader implements \Phalcon\Events\EventsAwareInterface { - + /** + * @var string|null + */ protected $checkedPath = null; /** * @var array */ - protected $classes = array(); + protected $classes = []; /** * @var array */ - protected $directories = array(); - + protected $directories = []; + /** + * @var ManagerInterface|null + */ protected $eventsManager = null; /** * @var array */ - protected $extensions = array('php'); - + protected $extensions = ['php']; + /** + * @var string + */ protected $fileCheckingCallback = 'is_file'; /** * @var array */ - protected $files = array(); + protected $files = []; /** - * @var bool + * @var string|null */ protected $foundPath = null; /** * @var array */ - protected $namespaces = array(); + protected $namespaces = []; /** * @var bool @@ -126,9 +130,9 @@ public function getDirs(): array /** * Returns the internal event manager * - * @return ManagerInterface + * @return ManagerInterface|null */ - public function getEventsManager(): ManagerInterface + public function getEventsManager(): ?ManagerInterface { } @@ -173,7 +177,7 @@ public function getNamespaces(): array * * @return void */ - public function loadFiles() + public function loadFiles(): void { } @@ -238,7 +242,7 @@ public function registerNamespaces(array $namespaces, bool $merge = false): Load * @param \Phalcon\Events\ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): void { } diff --git a/src/Phalcon/Loader/Exception.php b/src/Loader/Exception.php similarity index 100% rename from src/Phalcon/Loader/Exception.php rename to src/Loader/Exception.php diff --git a/src/Phalcon/Logger.php b/src/Logger.php similarity index 87% rename from src/Phalcon/Logger.php rename to src/Logger.php index fe36aa37..6cf6a417 100644 --- a/src/Phalcon/Logger.php +++ b/src/Logger.php @@ -9,9 +9,8 @@ */ namespace Phalcon; -use Psr\Log\LoggerInterface; +use DateTimeZone; use Phalcon\Logger\Adapter\AdapterInterface; -use Phalcon\Logger\Item; use Phalcon\Logger\Exception; /** @@ -81,7 +80,14 @@ class Logger implements \Psr\Log\LoggerInterface * * @var AdapterInterface[] */ - protected $adapters = array(); + protected $adapters = []; + + /** + * The excluded adapters for this log process + * + * @var AdapterInterface[] + */ + protected $excluded = []; /** * Minimum log level for the logger @@ -96,11 +102,9 @@ class Logger implements \Psr\Log\LoggerInterface protected $name = ''; /** - * The excluded adapters for this log process - * - * @var AdapterInterface[] + * @var DateTimeZone|null */ - protected $excluded = array(); + protected $timezone = null; /** @@ -117,8 +121,9 @@ public function getLogLevel(): int * * @param string $name The name of the logger * @param array $adapters The collection of adapters to be used for logging (default []) + * @param DateTimeZone|null $timezone The timezone */ - public function __construct(string $name, array $adapters = array()) + public function __construct(string $name, array $adapters = [], \DateTimeZone $timezone = null) { } @@ -143,7 +148,7 @@ public function addAdapter(string $name, \Phalcon\Logger\Adapter\AdapterInterfac * @param array $context * @return void */ - public function alert($message, array $context = array()) + public function alert($message, array $context = []): void { } @@ -156,7 +161,7 @@ public function alert($message, array $context = array()) * @param array $context * @return void */ - public function critical($message, array $context = array()) + public function critical($message, array $context = []): void { } @@ -167,7 +172,7 @@ public function critical($message, array $context = array()) * @param array $context * @return void */ - public function debug($message, array $context = array()) + public function debug($message, array $context = []): void { } @@ -179,7 +184,7 @@ public function debug($message, array $context = array()) * @param array $context * @return void */ - public function error($message, array $context = array()) + public function error($message, array $context = []): void { } @@ -190,7 +195,7 @@ public function error($message, array $context = array()) * @param array $context * @return void */ - public function emergency($message, array $context = array()) + public function emergency($message, array $context = []): void { } @@ -200,7 +205,7 @@ public function emergency($message, array $context = array()) * @param array $adapters * @return Logger */ - public function excludeAdapters(array $adapters = array()): Logger + public function excludeAdapters(array $adapters = []): Logger { } @@ -243,7 +248,7 @@ public function getName(): string * @param array $context * @return void */ - public function info($message, array $context = array()) + public function info($message, array $context = []): void { } @@ -255,7 +260,7 @@ public function info($message, array $context = array()) * @param array $context * @return void */ - public function log($level, $message, array $context = array()) + public function log($level, $message, array $context = []): void { } @@ -266,7 +271,7 @@ public function log($level, $message, array $context = array()) * @param array $context * @return void */ - public function notice($message, array $context = array()) + public function notice($message, array $context = []): void { } @@ -312,7 +317,7 @@ public function setLogLevel(int $level): Logger * @param array $context * @return void */ - public function warning($message, array $context = array()) + public function warning($message, array $context = []): void { } @@ -325,7 +330,7 @@ public function warning($message, array $context = array()) * @param array $context * @return bool */ - protected function addMessage(int $level, string $message, array $context = array()): bool + protected function addMessage(int $level, string $message, array $context = []): bool { } diff --git a/src/Phalcon/Logger/Adapter/AbstractAdapter.php b/src/Logger/Adapter/AbstractAdapter.php similarity index 91% rename from src/Phalcon/Logger/Adapter/AbstractAdapter.php rename to src/Logger/Adapter/AbstractAdapter.php index 325b51a8..bea8f69f 100644 --- a/src/Phalcon/Logger/Adapter/AbstractAdapter.php +++ b/src/Logger/Adapter/AbstractAdapter.php @@ -47,7 +47,7 @@ abstract class AbstractAdapter implements \Phalcon\Logger\Adapter\AdapterInterfa * * @var array */ - protected $queue = array(); + protected $queue = []; /** @@ -107,7 +107,7 @@ public function inTransaction(): bool * @param \Phalcon\Logger\Item $item * @return void */ - abstract public function process(\Phalcon\Logger\Item $item); + abstract public function process(\Phalcon\Logger\Item $item): void; /** * Rollbacks the internal transaction @@ -127,4 +127,14 @@ public function rollback(): AdapterInterface public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface { } + + /** + * Returns the formatted item + * + * @param \Phalcon\Logger\Item $item + * @return string + */ + protected function getFormattedItem(\Phalcon\Logger\Item $item): string + { + } } diff --git a/src/Phalcon/Logger/Adapter/AdapterInterface.php b/src/Logger/Adapter/AdapterInterface.php similarity index 96% rename from src/Phalcon/Logger/Adapter/AdapterInterface.php rename to src/Logger/Adapter/AdapterInterface.php index 1242f12b..daa19c2c 100644 --- a/src/Phalcon/Logger/Adapter/AdapterInterface.php +++ b/src/Logger/Adapter/AdapterInterface.php @@ -69,7 +69,7 @@ public function inTransaction(): bool; * @param \Phalcon\Logger\Item $item * @return void */ - public function process(\Phalcon\Logger\Item $item); + public function process(\Phalcon\Logger\Item $item): void; /** * Rollbacks the internal transaction diff --git a/src/Phalcon/Logger/Adapter/Noop.php b/src/Logger/Adapter/Noop.php similarity index 91% rename from src/Phalcon/Logger/Adapter/Noop.php rename to src/Logger/Adapter/Noop.php index 582a0261..7344fdca 100644 --- a/src/Phalcon/Logger/Adapter/Noop.php +++ b/src/Logger/Adapter/Noop.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Logger\Adapter; -use Phalcon\Logger\Item; - /** * Phalcon\Logger\Adapter\Noop * @@ -43,7 +41,7 @@ public function close(): bool * @param \Phalcon\Logger\Item $item * @return void */ - public function process(\Phalcon\Logger\Item $item) + public function process(\Phalcon\Logger\Item $item): void { } } diff --git a/src/Phalcon/Logger/Adapter/Stream.php b/src/Logger/Adapter/Stream.php similarity index 84% rename from src/Phalcon/Logger/Adapter/Stream.php rename to src/Logger/Adapter/Stream.php index c55dc795..7f5bc0b1 100644 --- a/src/Phalcon/Logger/Adapter/Stream.php +++ b/src/Logger/Adapter/Stream.php @@ -9,12 +9,6 @@ */ namespace Phalcon\Logger\Adapter; -use Phalcon\Logger\Adapter; -use Phalcon\Logger\Exception; -use Phalcon\Logger\Formatter\FormatterInterface; -use Phalcon\Logger\Item; -use UnexpectedValueException; - /** * Phalcon\Logger\Adapter\Stream * @@ -78,7 +72,7 @@ public function getName(): string * ] * @param string $name */ - public function __construct(string $name, array $options = array()) + public function __construct(string $name, array $options = []) { } @@ -97,7 +91,7 @@ public function close(): bool * @param \Phalcon\Logger\Item $item * @return void */ - public function process(\Phalcon\Logger\Item $item) + public function process(\Phalcon\Logger\Item $item): void { } } diff --git a/src/Phalcon/Logger/Adapter/Syslog.php b/src/Logger/Adapter/Syslog.php similarity index 85% rename from src/Phalcon/Logger/Adapter/Syslog.php rename to src/Logger/Adapter/Syslog.php index 603557a6..82533d06 100644 --- a/src/Phalcon/Logger/Adapter/Syslog.php +++ b/src/Logger/Adapter/Syslog.php @@ -9,14 +9,6 @@ */ namespace Phalcon\Logger\Adapter; -use LogicException; -use Phalcon\Helper\Arr; -use Phalcon\Logger; -use Phalcon\Logger\Adapter; -use Phalcon\Logger\Exception; -use Phalcon\Logger\Formatter\FormatterInterface; -use Phalcon\Logger\Item; - /** * Phalcon\Logger\Adapter\Syslog * @@ -79,7 +71,7 @@ class Syslog extends \Phalcon\Logger\Adapter\AbstractAdapter * ] * @param string $name */ - public function __construct(string $name, array $options = array()) + public function __construct(string $name, array $options = []) { } @@ -98,7 +90,7 @@ public function close(): bool * @param \Phalcon\Logger\Item $item * @return void */ - public function process(\Phalcon\Logger\Item $item) + public function process(\Phalcon\Logger\Item $item): void { } diff --git a/src/Phalcon/Logger/AdapterFactory.php b/src/Logger/AdapterFactory.php similarity index 87% rename from src/Phalcon/Logger/AdapterFactory.php rename to src/Logger/AdapterFactory.php index b2cb8c05..0eb162b7 100644 --- a/src/Phalcon/Logger/AdapterFactory.php +++ b/src/Logger/AdapterFactory.php @@ -23,12 +23,15 @@ class AdapterFactory extends AbstractFactory { + protected $exception = 'Phalcon\\\\Logger\\\\Exception'; + + /** * AdapterFactory constructor. * * @param array $services */ - public function __construct(array $services = array()) + public function __construct(array $services = []) { } @@ -40,7 +43,7 @@ public function __construct(array $services = array()) * @param array $options * @return AdapterInterface */ - public function newInstance(string $name, string $fileName, array $options = array()): AdapterInterface + public function newInstance(string $name, string $fileName, array $options = []): AdapterInterface { } diff --git a/src/Phalcon/Logger/Exception.php b/src/Logger/Exception.php similarity index 100% rename from src/Phalcon/Logger/Exception.php rename to src/Logger/Exception.php diff --git a/src/Phalcon/Logger/Formatter/AbstractFormatter.php b/src/Logger/Formatter/AbstractFormatter.php similarity index 61% rename from src/Phalcon/Logger/Formatter/AbstractFormatter.php rename to src/Logger/Formatter/AbstractFormatter.php index 9de8a6ce..d3b92172 100644 --- a/src/Phalcon/Logger/Formatter/AbstractFormatter.php +++ b/src/Logger/Formatter/AbstractFormatter.php @@ -44,26 +44,4 @@ public function getDateFormat(): string public function setDateFormat(string $dateFormat) { } - - /** - * Interpolates context values into the message placeholders - * - * @see http://www.php-fig.org/psr/psr-3/ Section 1.2 Message - * @param string $message - * @param array $context - */ - public function interpolate(string $message, $context = null) - { - } - - /** - * Returns the date formatted for the logger. - * - * @todo Not using the set time from the Item since we have interface - * misalignment which will break semver This will change in the future - * @return string - */ - protected function getFormattedDate(): string - { - } } diff --git a/src/Phalcon/Logger/Formatter/FormatterInterface.php b/src/Logger/Formatter/FormatterInterface.php similarity index 100% rename from src/Phalcon/Logger/Formatter/FormatterInterface.php rename to src/Logger/Formatter/FormatterInterface.php diff --git a/src/Phalcon/Logger/Formatter/Json.php b/src/Logger/Formatter/Json.php similarity index 92% rename from src/Phalcon/Logger/Formatter/Json.php rename to src/Logger/Formatter/Json.php index d1a65d25..19527618 100644 --- a/src/Phalcon/Logger/Formatter/Json.php +++ b/src/Logger/Formatter/Json.php @@ -9,9 +9,6 @@ */ namespace Phalcon\Logger\Formatter; -use Phalcon\Helper\Json as JsonHelper; -use Phalcon\Logger\Item; - /** * Phalcon\Logger\Formatter\Json * diff --git a/src/Phalcon/Logger/Formatter/Line.php b/src/Logger/Formatter/Line.php similarity index 89% rename from src/Phalcon/Logger/Formatter/Line.php rename to src/Logger/Formatter/Line.php index 173aec9b..b012cfa9 100644 --- a/src/Phalcon/Logger/Formatter/Line.php +++ b/src/Logger/Formatter/Line.php @@ -9,9 +9,6 @@ */ namespace Phalcon\Logger\Formatter; -use DateTime; -use Phalcon\Logger\Item; - /** * Phalcon\Logger\Formatter\Line * @@ -51,7 +48,7 @@ public function setFormat(string $format) * @param string $format * @param string $dateFormat */ - public function __construct(string $format = '[%date%][%type%] %message%', string $dateFormat = 'c') + public function __construct(string $format = '[%date%][%level%] %message%', string $dateFormat = 'c') { } diff --git a/src/Phalcon/Logger/Item.php b/src/Logger/Item.php similarity index 75% rename from src/Phalcon/Logger/Item.php rename to src/Logger/Item.php index 57b8c0d4..f1ce574c 100644 --- a/src/Phalcon/Logger/Item.php +++ b/src/Logger/Item.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Logger; +use DateTimeImmutable; + /** * Phalcon\Logger\Item * @@ -31,25 +33,25 @@ class Item protected $message; /** - * Log message + * Log type * - * @var string + * @var integer */ - protected $name; + protected $level; /** - * Log timestamp + * Log message * - * @var integer + * @var string */ - protected $time; + protected $levelName; /** - * Log type + * Log timestamp * - * @var integer + * @var DateTimeImmutable */ - protected $type; + protected $time; /** @@ -71,43 +73,42 @@ public function getMessage(): string } /** - * Log message + * Log type * - * @return string + * @return mixed */ - public function getName(): string + public function getLevel() { } /** - * Log timestamp + * Log message * - * @return mixed + * @return string */ - public function getTime() + public function getLevelName(): string { } /** - * Log type + * Log timestamp * * @return mixed */ - public function getType() + public function getTime() { } /** * Phalcon\Logger\Item constructor * - * @todo Remove the time or change the signature to an array * @param string $message - * @param string $name - * @param int $type - * @param int $time - * @param mixed $context + * @param string $levelName + * @param int $level + * @param \DateTimeImmutable $time + * @param array $context */ - public function __construct(string $message, string $name, int $type, int $time = 0, $context = array()) + public function __construct(string $message, string $levelName, int $level, \DateTimeImmutable $time, array $context = []) { } } diff --git a/src/Phalcon/Logger/LoggerFactory.php b/src/Logger/LoggerFactory.php similarity index 93% rename from src/Phalcon/Logger/LoggerFactory.php rename to src/Logger/LoggerFactory.php index 8d49ef6b..385acda0 100644 --- a/src/Phalcon/Logger/LoggerFactory.php +++ b/src/Logger/LoggerFactory.php @@ -9,9 +9,6 @@ */ namespace Phalcon\Logger; -use Phalcon\Config; -use Phalcon\Config\ConfigInterface; -use Phalcon\Helper\Arr; use Phalcon\Logger; /** @@ -63,7 +60,7 @@ public function load($config): Logger * * @return Logger */ - public function newInstance(string $name, array $adapters = array()): Logger + public function newInstance(string $name, array $adapters = []): Logger { } } diff --git a/src/Phalcon/Messages/Exception.php b/src/Messages/Exception.php similarity index 100% rename from src/Phalcon/Messages/Exception.php rename to src/Messages/Exception.php diff --git a/src/Phalcon/Messages/Message.php b/src/Messages/Message.php similarity index 95% rename from src/Phalcon/Messages/Message.php rename to src/Messages/Message.php index c0c64851..20ca3c3d 100644 --- a/src/Phalcon/Messages/Message.php +++ b/src/Messages/Message.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Messages; -use JsonSerializable; - /** * Phalcon\Messages\Message * @@ -41,7 +39,7 @@ class Message implements \Phalcon\Messages\MessageInterface, \JsonSerializable /** * @var array */ - protected $metaData = array(); + protected $metaData = []; /** @@ -88,7 +86,7 @@ public function getMetaData(): array * @param int $code * @param array $metaData */ - public function __construct(string $message, $field = '', string $type = '', int $code = 0, array $metaData = array()) + public function __construct(string $message, $field = '', string $type = '', int $code = 0, array $metaData = []) { } diff --git a/src/Phalcon/Messages/MessageInterface.php b/src/Messages/MessageInterface.php similarity index 100% rename from src/Phalcon/Messages/MessageInterface.php rename to src/Messages/MessageInterface.php diff --git a/src/Phalcon/Messages/Messages.php b/src/Messages/Messages.php similarity index 89% rename from src/Phalcon/Messages/Messages.php rename to src/Messages/Messages.php index 54d8d33b..b68c1e63 100644 --- a/src/Phalcon/Messages/Messages.php +++ b/src/Messages/Messages.php @@ -9,11 +9,6 @@ */ namespace Phalcon\Messages; -use ArrayAccess; -use Countable; -use Iterator; -use JsonSerializable; - /** * Represents a collection of messages */ @@ -35,7 +30,7 @@ class Messages implements \ArrayAccess, \Countable, \Iterator, \JsonSerializable * * @param array $messages */ - public function __construct(array $messages = array()) + public function __construct(array $messages = []) { } @@ -61,9 +56,7 @@ public function appendMessage(MessageInterface $message) * $messages->appendMessages($messagesArray); * ``` * - * @param \Phalcon\Messages\MessageInterface[] messages - * @param mixed $messages - * @param \Phalcon\Messages\MessageInterface [] messages + * @param \Phalcon\Messages\MessageInterface[] $messages */ public function appendMessages($messages) { @@ -126,7 +119,7 @@ public function key(): int * * @return void */ - public function next() + public function next(): void { } @@ -173,7 +166,7 @@ public function offsetGet($index) * @param mixed $index * @return void */ - public function offsetSet($index, $message) + public function offsetSet($index, $message): void { } @@ -187,7 +180,7 @@ public function offsetSet($index, $message) * @param mixed $index * @return void */ - public function offsetUnset($index) + public function offsetUnset($index): void { } @@ -196,7 +189,7 @@ public function offsetUnset($index) * * @return void */ - public function rewind() + public function rewind(): void { } diff --git a/src/Phalcon/Mvc/Application.php b/src/Mvc/Application.php similarity index 95% rename from src/Phalcon/Mvc/Application.php rename to src/Mvc/Application.php index 1c2c3a56..d236a155 100644 --- a/src/Phalcon/Mvc/Application.php +++ b/src/Mvc/Application.php @@ -59,13 +59,19 @@ */ class Application extends AbstractApplication { - + /** + * @var bool + */ protected $implicitView = true; - + /** + * @var bool + */ protected $sendCookies = true; - + /** + * @var bool + */ protected $sendHeaders = true; @@ -73,7 +79,7 @@ class Application extends AbstractApplication * Handles a MVC request * * @param string $uri - * @return bool|\Phalcon\Http\ResponseInterface + * @return 0|ResponseInterface */ public function handle(string $uri) { diff --git a/src/Phalcon/Mvc/Application/Exception.php b/src/Mvc/Application/Exception.php similarity index 100% rename from src/Phalcon/Mvc/Application/Exception.php rename to src/Mvc/Application/Exception.php diff --git a/src/Phalcon/Mvc/Controller.php b/src/Mvc/Controller.php similarity index 100% rename from src/Phalcon/Mvc/Controller.php rename to src/Mvc/Controller.php diff --git a/src/Phalcon/Mvc/Controller/BindModelInterface.php b/src/Mvc/Controller/BindModelInterface.php similarity index 100% rename from src/Phalcon/Mvc/Controller/BindModelInterface.php rename to src/Mvc/Controller/BindModelInterface.php diff --git a/src/Phalcon/Mvc/ControllerInterface.php b/src/Mvc/ControllerInterface.php similarity index 100% rename from src/Phalcon/Mvc/ControllerInterface.php rename to src/Mvc/ControllerInterface.php diff --git a/src/Phalcon/Mvc/Dispatcher.php b/src/Mvc/Dispatcher.php similarity index 99% rename from src/Phalcon/Mvc/Dispatcher.php rename to src/Mvc/Dispatcher.php index af0a7413..fa238287 100644 --- a/src/Phalcon/Mvc/Dispatcher.php +++ b/src/Mvc/Dispatcher.php @@ -101,7 +101,7 @@ class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phal * @param array $forward * @return void */ - public function forward(array $forward) + public function forward(array $forward): void { } diff --git a/src/Phalcon/Mvc/Dispatcher/Exception.php b/src/Mvc/Dispatcher/Exception.php similarity index 100% rename from src/Phalcon/Mvc/Dispatcher/Exception.php rename to src/Mvc/Dispatcher/Exception.php diff --git a/src/Phalcon/Mvc/DispatcherInterface.php b/src/Mvc/DispatcherInterface.php similarity index 100% rename from src/Phalcon/Mvc/DispatcherInterface.php rename to src/Mvc/DispatcherInterface.php diff --git a/src/Phalcon/Mvc/EntityInterface.php b/src/Mvc/EntityInterface.php similarity index 100% rename from src/Phalcon/Mvc/EntityInterface.php rename to src/Mvc/EntityInterface.php diff --git a/src/Phalcon/Mvc/Micro.php b/src/Mvc/Micro.php similarity index 87% rename from src/Phalcon/Mvc/Micro.php rename to src/Mvc/Micro.php index 5a51c953..9578ce51 100644 --- a/src/Phalcon/Mvc/Micro.php +++ b/src/Mvc/Micro.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Mvc; +use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; use Phalcon\Di\ServiceInterface; use Phalcon\Events\ManagerInterface; @@ -38,50 +39,80 @@ */ class Micro extends Injectable implements \ArrayAccess, \Phalcon\Events\EventsAwareInterface { + /** + * @var callable|null + */ + protected $activeHandler = null; - protected $activeHandler; - - - protected $afterBindingHandlers = array(); - - - protected $afterHandlers = array(); - - - protected $beforeHandlers = array(); - - - protected $container; - - - protected $errorHandler; - - - protected $eventsManager; - - - protected $finishHandlers = array(); - + /** + * @var array + */ + protected $afterBindingHandlers = []; - protected $handlers = array(); + /** + * @var array + */ + protected $afterHandlers = []; + /** + * @var array + */ + protected $beforeHandlers = []; - protected $modelBinder; + /** + * @var DiInterface|null + */ + protected $container = null; + /** + * @var callable|null + */ + protected $errorHandler = null; - protected $notFoundHandler; + /** + * @var ManagerInterface|null + */ + protected $eventsManager = null; + /** + * @var array + */ + protected $finishHandlers = []; - protected $responseHandler; + /** + * @var array + */ + protected $handlers = []; + /** + * @var BinderInterface|null + */ + protected $modelBinder = null; - protected $returnedValue; + /** + * @var callable|null + */ + protected $notFoundHandler = null; + /** + * @var callable|null + */ + protected $responseHandler = null; - protected $router; + /** + * @var mixed|null + */ + protected $returnedValue = null; + /** + * @var RouterInterface|null + */ + protected $router = null; - protected $stopped; + /** + * @var bool + */ + protected $stopped = false; /** @@ -187,7 +218,7 @@ public function getBoundModels(): array /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface|null + * @return ManagerInterface|null */ public function getEventsManager(): ?ManagerInterface { @@ -199,7 +230,7 @@ public function getEventsManager(): ?ManagerInterface * @param \Phalcon\Events\ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): void { } @@ -215,7 +246,7 @@ public function getHandlers(): array /** * Gets model binder * - * @return \Phalcon\Mvc\Model\BinderInterface|null + * @return BinderInterface|null */ public function getModelBinder(): ?BinderInterface { @@ -362,7 +393,7 @@ public function offsetGet($alias) * @param mixed $definition * @return void */ - public function offsetSet($alias, $definition) + public function offsetSet($alias, $definition): void { } @@ -373,7 +404,7 @@ public function offsetSet($alias, $definition) * @param mixed $alias * @return void */ - public function offsetUnset($alias) + public function offsetUnset($alias): void { } @@ -436,7 +467,7 @@ public function setActiveHandler($activeHandler) * @param \Phalcon\Di\DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(\Phalcon\Di\DiInterface $container): void { } diff --git a/src/Phalcon/Mvc/Micro/Collection.php b/src/Mvc/Micro/Collection.php similarity index 83% rename from src/Phalcon/Mvc/Micro/Collection.php rename to src/Mvc/Micro/Collection.php index 8479ed72..3d212785 100644 --- a/src/Phalcon/Mvc/Micro/Collection.php +++ b/src/Mvc/Micro/Collection.php @@ -30,25 +30,33 @@ */ class Collection implements \Phalcon\Mvc\Micro\CollectionInterface { - + /** + * @var callable + */ protected $handler; + /** + * @var array + */ + protected $handlers = []; - protected $handlers = array(); - - - protected $lazy; - + /** + * @var bool + */ + protected $lazy = false; - protected $prefix; + /** + * @var string + */ + protected $prefix = ''; /** * Maps a route to a handler that only matches if the HTTP method is DELETE. * - * @param callable|string $handler * @param string $routePattern - * @param string $name + * @param callable $handler + * @param string|null $name * * @return CollectionInterface */ public function delete(string $routePattern, $handler, string $name = null): CollectionInterface @@ -58,9 +66,9 @@ public function delete(string $routePattern, $handler, string $name = null): Col /** * Maps a route to a handler that only matches if the HTTP method is GET. * - * @param callable|string $handler * @param string $routePattern - * @param string $name + * @param callable $handler + * @param string|null $name * * @return CollectionInterface */ public function get(string $routePattern, $handler, string $name = null): CollectionInterface @@ -97,9 +105,9 @@ public function getPrefix(): string /** * Maps a route to a handler that only matches if the HTTP method is HEAD. * - * @param callable|string $handler * @param string $routePattern - * @param string $name + * @param callable|string $handler + * @param string|null $name * * @return CollectionInterface */ public function head(string $routePattern, $handler, string $name = null): CollectionInterface @@ -118,9 +126,9 @@ public function isLazy(): bool /** * Maps a route to a handler. * - * @param callable|string $handler * @param string $routePattern - * @param string $name + * @param callable $handler + * @param string|null $name * * @return CollectionInterface */ public function map(string $routePattern, $handler, string $name = null): CollectionInterface @@ -139,10 +147,10 @@ public function map(string $routePattern, $handler, string $name = null): Collec * ); * ``` * + * @param string $routePattern * @param callable $handler * @param string|array $method - * @param string $routePattern - * @param string $name + * @param string|null $name * * @return CollectionInterface */ public function mapVia(string $routePattern, $handler, $method, string $name = null): CollectionInterface @@ -153,9 +161,9 @@ public function mapVia(string $routePattern, $handler, $method, string $name = n * Maps a route to a handler that only matches if the HTTP method is * OPTIONS. * - * @param callable|string $handler * @param string $routePattern - * @param string $name + * @param callable $handler + * @param string|null $name * * @return CollectionInterface */ public function options(string $routePattern, $handler, string $name = null): CollectionInterface @@ -165,9 +173,9 @@ public function options(string $routePattern, $handler, string $name = null): Co /** * Maps a route to a handler that only matches if the HTTP method is PATCH. * - * @param callable|string $handler * @param string $routePattern - * @param string $name + * @param callable $handler + * @param string|null $name * * @return CollectionInterface */ public function patch(string $routePattern, $handler, string $name = null): CollectionInterface @@ -177,9 +185,9 @@ public function patch(string $routePattern, $handler, string $name = null): Coll /** * Maps a route to a handler that only matches if the HTTP method is POST. * - * @param callable|string $handler * @param string $routePattern - * @param string $name + * @param callable $handler + * @param string|null $name * * @return CollectionInterface */ public function post(string $routePattern, $handler, string $name = null): CollectionInterface @@ -189,9 +197,9 @@ public function post(string $routePattern, $handler, string $name = null): Colle /** * Maps a route to a handler that only matches if the HTTP method is PUT. * - * @param callable|string $handler * @param string $routePattern - * @param string $name + * @param callable $handler + * @param string|null $name * * @return CollectionInterface */ public function put(string $routePattern, $handler, string $name = null): CollectionInterface @@ -201,8 +209,8 @@ public function put(string $routePattern, $handler, string $name = null): Collec /** * Sets the main handler. * - * @param callable|string $handler - * @param bool $lazy + * @param mixed $handler + * @param bool $lazy * * @return CollectionInterface */ public function setHandler($handler, bool $lazy = false): CollectionInterface @@ -212,7 +220,7 @@ public function setHandler($handler, bool $lazy = false): CollectionInterface /** * Sets if the main handler must be lazy loaded * - * @param bool $lazy + * @param bool $lazy * * @return CollectionInterface */ public function setLazy(bool $lazy): CollectionInterface @@ -222,7 +230,7 @@ public function setLazy(bool $lazy): CollectionInterface /** * Sets a prefix for all routes added to the collection * - * @param string $prefix + * @param string $prefix * * @return CollectionInterface */ public function setPrefix(string $prefix): CollectionInterface @@ -233,11 +241,12 @@ public function setPrefix(string $prefix): CollectionInterface * Internal function to add a handler to the group. * * @param string|array $method - * @param callable|string $handler * @param string $routePattern + * @param callable $handler * @param string $name + * @return void */ - protected function addMap($method, string $routePattern, $handler, string $name) + protected function addMap($method, string $routePattern, $handler, string $name): void { } } diff --git a/src/Phalcon/Mvc/Micro/CollectionInterface.php b/src/Mvc/Micro/CollectionInterface.php similarity index 99% rename from src/Phalcon/Mvc/Micro/CollectionInterface.php rename to src/Mvc/Micro/CollectionInterface.php index a0b3d42a..18148560 100644 --- a/src/Phalcon/Mvc/Micro/CollectionInterface.php +++ b/src/Mvc/Micro/CollectionInterface.php @@ -129,7 +129,7 @@ public function put(string $routePattern, $handler, string $name = null): Collec * Sets the main handler * * @param mixed $handler - * @param bool $lazy + * @param bool $lazy * * @return CollectionInterface */ public function setHandler($handler, bool $lazy = false): CollectionInterface; diff --git a/src/Phalcon/Mvc/Micro/Exception.php b/src/Mvc/Micro/Exception.php similarity index 100% rename from src/Phalcon/Mvc/Micro/Exception.php rename to src/Mvc/Micro/Exception.php diff --git a/src/Phalcon/Mvc/Micro/LazyLoader.php b/src/Mvc/Micro/LazyLoader.php similarity index 80% rename from src/Phalcon/Mvc/Micro/LazyLoader.php rename to src/Mvc/Micro/LazyLoader.php index 6aa39862..c9460cfe 100644 --- a/src/Phalcon/Mvc/Micro/LazyLoader.php +++ b/src/Mvc/Micro/LazyLoader.php @@ -16,20 +16,28 @@ */ class LazyLoader { + /** + * @var object|null + */ + protected $handler = null; - protected $handler; - - + /** + * @var string + */ protected $definition; - + /** + * @return object|null + */ public function getHandler() { } - - public function getDefinition() + /** + * @return string + */ + public function getDefinition(): string { } diff --git a/src/Phalcon/Mvc/Micro/MiddlewareInterface.php b/src/Mvc/Micro/MiddlewareInterface.php similarity index 100% rename from src/Phalcon/Mvc/Micro/MiddlewareInterface.php rename to src/Mvc/Micro/MiddlewareInterface.php diff --git a/src/Phalcon/Mvc/Model.php b/src/Mvc/Model.php similarity index 88% rename from src/Phalcon/Mvc/Model.php rename to src/Mvc/Model.php index 4e282154..b18ab3b0 100644 --- a/src/Phalcon/Mvc/Model.php +++ b/src/Mvc/Model.php @@ -18,6 +18,7 @@ use Phalcon\Mvc\Model\Query; use Phalcon\Mvc\Model\Relation; use Phalcon\Mvc\Model\ResultsetInterface; +use Phalcon\Mvc\Model\TransactionInterface; /** * Phalcon\Mvc\Model @@ -82,58 +83,81 @@ abstract class Model extends AbstractInjectionAware implements \Phalcon\Mvc\Enti const TRANSACTION_INDEX = 'transaction'; - + /** + * @var int + */ protected $dirtyState = 1; /** * @var array */ - protected $dirtyRelated = array(); + protected $dirtyRelated = []; /** * @var array */ - protected $errorMessages = array(); - - - protected $modelsManager; + protected $errorMessages = []; + /** + * @var ManagerInterface|null + */ + protected $modelsManager = null; - protected $modelsMetaData; + /** + * @var MetaDataInterface|null + */ + protected $modelsMetaData = null; /** * @var array */ - protected $related = array(); - + protected $related = []; + /** + * @var int + */ protected $operationMade = 0; /** * @var array */ - protected $oldSnapshot = array(); - - - protected $skipped; - - - protected $snapshot; + protected $oldSnapshot = []; + /** + * @var bool + */ + protected $skipped = false; - protected $transaction; - - - protected $uniqueKey; - + /** + * @var array + */ + protected $snapshot = []; - protected $uniqueParams; + /** + * @var TransactionInterface|null + */ + protected $transaction = null; + /** + * @var string|null + */ + protected $uniqueKey = null; - protected $uniqueTypes; + /** + * @var array + */ + protected $uniqueParams = []; + /** + * @var array|null + * TODO: Make it always array in code + */ + protected $uniqueTypes = null; + /** + * @return TransactionInterface|null + */ public function getTransaction() { } @@ -243,7 +267,7 @@ public function __set(string $property, $value) * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior * @return void */ - public function addBehavior(\Phalcon\Mvc\Model\BehaviorInterface $behavior) + public function addBehavior(\Phalcon\Mvc\Model\BehaviorInterface $behavior): void { } @@ -320,9 +344,10 @@ public function appendMessage(\Phalcon\Messages\MessageInterface $message): Mode * ); * ``` * - * @param array $dataColumnMap array to transform keys of data to another - * @param array $whiteList * @param array $data + * @param mixed $whiteList + * @param mixed $dataColumnMap Array to transform keys of data to another + * * @return ModelInterface */ public function assign(array $data, $whiteList = null, $dataColumnMap = null): ModelInterface @@ -359,9 +384,9 @@ public function assign(array $data, $whiteList = null, $dataColumnMap = null): M * ``` * * @param array $parameters - * @return double | ResultsetInterface + * @return float | ResultsetInterface */ - public static function average($parameters = null) + public static function average(array $parameters = []) { } @@ -402,12 +427,12 @@ public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $dat * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row $base - * @param array $columnMap - * @param array $data + * @param ModelInterface|\Phalcon\Mvc\Model\Row $base + * @param mixed $columnMap * @param int $dirtyState - * @param bool $keepSnapshots + * @param bool $keepSnapshots * * @return ModelInterface + * @param array $data */ public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface { @@ -416,10 +441,10 @@ public static function cloneResultMap($base, array $data, $columnMap, int $dirty /** * Returns an hydrated result based on the data and the column map * - * @param array $columnMap - * @return mixed * @param array $data - * @param int $hydrationMode + * @param mixed $columnMap + * @param int $hydrationMode * + * @return mixed */ public static function cloneResultMapHydrate(array $data, $columnMap, int $hydrationMode) { @@ -454,8 +479,8 @@ protected function collectRelatedToSave(): array * echo "There are ", $number, " mechanical robots\n"; * ``` * - * @param array $parameters - * @return int|\Phalcon\Mvc\Model\ResultsetInterface + * @param array|string|null $parameters + * @return 0|ResultsetInterface */ public static function count($parameters = null) { @@ -798,7 +823,7 @@ public static function find($parameters = null): ResultsetInterface * ], * 'hydration' => null * ] - * @return \Phalcon\Mvc\ModelInterface|null + * @return ModelInterface|null */ public static function findFirst($parameters = null): ?ModelInterface { @@ -859,7 +884,7 @@ public function getDirtyState(): int /** * Returns the custom events manager or null if there is no custom events manager * - * @return \Phalcon\Events\ManagerInterface|null + * @return EventsManagerInterface|null */ public function getEventsManager(): ?EventsManagerInterface { @@ -955,7 +980,7 @@ final public function getReadConnectionService(): string * Returns related records based on defined relations * * @param array $arguments - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false + * @return \Phalcon\Mvc\Model\Resultset\Simple|false * @param string $alias */ public function getRelated(string $alias, $arguments = null) @@ -992,9 +1017,9 @@ public function isRelationshipLoaded(string $relationshipAlias): bool /** * Returns schema name where the mapped table is located * - * @return string + * @return string|null */ - final public function getSchema(): string + final public function getSchema(): ?string { } @@ -1269,7 +1294,7 @@ public function unserialize($data) * @param string $connectionService * @return void */ - final public function setConnectionService(string $connectionService) + final public function setConnectionService(string $connectionService): void { } @@ -1277,7 +1302,7 @@ final public function setConnectionService(string $connectionService) * Sets the dirty state of the object using one of the DIRTY_STATE_ constants * * @param int $dirtyState - * @return bool|\Phalcon\Mvc\ModelInterface + * @return bool|ModelInterface */ public function setDirtyState(int $dirtyState) { @@ -1298,7 +1323,7 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager * @param string $connectionService * @return void */ - final public function setReadConnectionService(string $connectionService) + final public function setReadConnectionService(string $connectionService): void { } @@ -1323,7 +1348,7 @@ public function setOldSnapshotData(array $data, $columnMap = null) * @param array $data * @return void */ - public function setSnapshotData(array $data, $columnMap = null) + public function setSnapshotData(array $data, $columnMap = null): void { } @@ -1379,7 +1404,7 @@ public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transact * @param array $options * @return void */ - public static function setup(array $options) + public static function setup(array $options): void { } @@ -1389,7 +1414,7 @@ public static function setup(array $options) * @param string $connectionService * @return void */ - final public function setWriteConnectionService(string $connectionService) + final public function setWriteConnectionService(string $connectionService): void { } @@ -1399,7 +1424,7 @@ final public function setWriteConnectionService(string $connectionService) * @param bool $skip * @return void */ - public function skipOperation(bool $skip) + public function skipOperation(bool $skip): void { } @@ -1482,7 +1507,7 @@ public function update(): bool * @param mixed $value * @return void */ - public function writeAttribute(string $attribute, $value) + public function writeAttribute(string $attribute, $value): void { } @@ -1493,7 +1518,7 @@ public function writeAttribute(string $attribute, $value) * * @return bool */ - final protected function _checkForeignKeysRestrict(): bool + final protected function checkForeignKeysRestrict(): bool { } @@ -1503,7 +1528,7 @@ final protected function _checkForeignKeysRestrict(): bool * * @return bool */ - final protected function _checkForeignKeysReverseCascade(): bool + final protected function checkForeignKeysReverseCascade(): bool { } @@ -1513,23 +1538,7 @@ final protected function _checkForeignKeysReverseCascade(): bool * * @return bool */ - final protected function _checkForeignKeysReverseRestrict(): bool - { - } - - /** - * Sends a pre-build INSERT SQL statement to the relational database system - * - * @todo Remove in v5.0 - * @deprecated Use doLowInsert() - * - * @param string|array $table - * @param bool|string $identityField - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\Adapter\AdapterInterface $connection - * @return bool - */ - protected function _doLowInsert(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table, $identityField): bool + final protected function checkForeignKeysReverseRestrict(): bool { } @@ -1546,21 +1555,6 @@ protected function doLowInsert(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \ { } - /** - * Sends a pre-build UPDATE SQL statement to the relational database system - * - * @todo Remove in v5.0 - * @deprecated Use doLowUpdate() - * - * @param string|array $table - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\Adapter\AdapterInterface $connection - * @return bool - */ - protected function _doLowUpdate(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table): bool - { - } - /** * Sends a pre-build UPDATE SQL statement to the relational database system * @@ -1573,20 +1567,6 @@ protected function doLowUpdate(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \ { } - /** - * Checks whether the current record already exists - * - * @todo Remove in v5.0 - * @deprecated Use exists() - * - * @return bool - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\Adapter\AdapterInterface $connection - */ - protected function _exists(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection): bool - { - } - /** * Checks whether the current record already exists * @@ -1598,22 +1578,6 @@ protected function exists(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalc { } - /** - * Returns related records defined relations depending on the method name. - * Returns false if the relation is non-existent. - * - * @todo Remove in v5.0 - * @deprecated Use getRelatedRecords() - * - * @param string $modelName - * @param string $method - * @param array $arguments * - * @return ResultsetInterface|ModelInterface|bool|null - */ - protected function _getRelatedRecords(string $modelName, string $method, array $arguments) - { - } - /** * Returns related records defined relations depending on the method name. * Returns false if the relation is non-existent. @@ -1630,38 +1594,23 @@ protected function getRelatedRecords(string $modelName, string $method, array $a /** * Generate a PHQL SELECT statement for an aggregate * - * @todo Remove in v5.0 - * @deprecated Use groupResult() - * - * @param array $parameters - * @return ResultsetInterface * @param string $functionName * @param string $alias - */ - protected static function _groupResult(string $functionName, string $alias, $parameters): ResultsetInterface - { - } - - /** - * Generate a PHQL SELECT statement for an aggregate - * - * @param array $parameters + * @param array|string|null $parameters * * @return ResultsetInterface - * @param string $functionName - * @param string $alias */ - protected static function groupResult(string $functionName, string $alias, $parameters): ResultsetInterface + protected static function groupResult(string $functionName, string $alias, $parameters = null): ResultsetInterface { } /** * Try to check if the query must invoke a finder * - * @return \Phalcon\Mvc\ModelInterface[]|\Phalcon\Mvc\ModelInterface|bool + * @return ModelInterface[]|ModelInterface|bool * @param string $method * @param array $arguments */ - final protected static function _invokeFinder(string $method, array $arguments) + final protected static function invokeFinder(string $method, array $arguments) { } @@ -1672,22 +1621,7 @@ final protected static function _invokeFinder(string $method, array $arguments) * @param mixed $value * @return bool */ - final protected function _possibleSetter(string $property, $value): bool - { - } - - /** - * Executes internal hooks before save a record - * - * @todo Remove in v5.0 - * @deprecated Use preSave() - * - * @return bool - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param bool $exists - * @param mixed $identityField - */ - protected function _preSave(\Phalcon\Mvc\Model\MetaDataInterface $metaData, bool $exists, $identityField): bool + final protected function possibleSetter(string $property, $value): bool { } @@ -1706,46 +1640,14 @@ protected function preSave(\Phalcon\Mvc\Model\MetaDataInterface $metaData, bool /** * Saves related records that must be stored prior to save the master record * - * @todo Remove in v5.0 - * @deprecated Use preSaveRelatedRecords() - * - * @param \Phalcon\Mvc\ModelInterface[] related - * @param \Phalcon\Db\Adapter\AdapterInterface $connection - * @param mixed $related - * @param \Phalcon\Mvc\ModelInterface [] related - * @return bool - */ - protected function _preSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool - { - } - - /** - * Saves related records that must be stored prior to save the master record - * - * @param \Phalcon\Mvc\ModelInterface[] related + * @param ModelInterface[] $related * @return bool * @param \Phalcon\Db\Adapter\AdapterInterface $connection - * @param mixed $related - * @param \Phalcon\Mvc\ModelInterface [] related */ protected function preSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool { } - /** - * Executes internal events after save a record - * - * @todo Remove in v5.0 - * @deprecated Use postSave() - * - * @return bool - * @param bool $success - * @param bool $exists - */ - protected function _postSave(bool $success, bool $exists): bool - { - } - /** * Executes internal events after save a record * @@ -1760,27 +1662,9 @@ protected function postSave(bool $success, bool $exists): bool /** * Save the related records assigned in the has-one/has-many relations * - * @todo Remove in v5.0 - * @deprecated Use postSaveRelatedRecords() - * - * @param Phalcon\Mvc\ModelInterface[] related + * @param ModelInterface[] $related * @return bool * @param \Phalcon\Db\Adapter\AdapterInterface $connection - * @param mixed $related - * @param Phalcon\Mvc\ModelInterface [] related - */ - protected function _postSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool - { - } - - /** - * Save the related records assigned in the has-one/has-many relations - * - * @param Phalcon\Mvc\ModelInterface[] related - * @return bool - * @param \Phalcon\Db\Adapter\AdapterInterface $connection - * @param mixed $related - * @param Phalcon\Mvc\ModelInterface [] related */ protected function postSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool { @@ -1807,17 +1691,7 @@ protected function postSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $ * @param array $attributes * @return void */ - protected function allowEmptyStringValues(array $attributes) - { - } - - /** - * Cancel the current operation - * - * @todo Remove in v5.0 - * @deprecated Use cancelOperation() - */ - protected function _cancelOperation() + protected function allowEmptyStringValues(array $attributes): void { } @@ -1966,11 +1840,12 @@ protected function hasMany($fields, string $referenceModel, $referencedFields, $ * ``` * * @param string|array $fields + * @param string $intermediateModel * @param string|array $intermediateFields * @param string|array $intermediateReferencedFields + * @param string $referenceModel * @param string|array $referencedFields - * @param array $options * - * @param array|null $options = [ + * @param array $options = [ * 'reusable' => false, * 'alias' => 'someAlias', * 'foreignKey' => [ @@ -1996,11 +1871,9 @@ protected function hasMany($fields, string $referenceModel, $referencedFields, $ * 'hydration' => null * ] * ] - * @param string $intermediateModel - * @param string $referenceModel * @return Relation */ - protected function hasManyToMany($fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referenceModel, $referencedFields, $options = null): Relation + protected function hasManyToMany($fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referenceModel, $referencedFields, $options = []): Relation { } @@ -2109,7 +1982,7 @@ protected function hasOneThrough($fields, string $intermediateModel, $intermedia * @param bool $keepSnapshot * @return void */ - protected function keepSnapshots(bool $keepSnapshot) + protected function keepSnapshots(bool $keepSnapshot): void { } @@ -2178,7 +2051,7 @@ protected function skipAttributes(array $attributes) * @param array $attributes * @return void */ - protected function skipAttributesOnCreate(array $attributes) + protected function skipAttributesOnCreate(array $attributes): void { } @@ -2203,7 +2076,7 @@ protected function skipAttributesOnCreate(array $attributes) * @param array $attributes * @return void */ - protected function skipAttributesOnUpdate(array $attributes) + protected function skipAttributesOnUpdate(array $attributes): void { } @@ -2225,7 +2098,7 @@ protected function skipAttributesOnUpdate(array $attributes) * @param bool $dynamicUpdate * @return void */ - protected function useDynamicUpdate(bool $dynamicUpdate) + protected function useDynamicUpdate(bool $dynamicUpdate): void { } diff --git a/src/Phalcon/Mvc/Model/Behavior.php b/src/Mvc/Model/Behavior.php similarity index 93% rename from src/Phalcon/Mvc/Model/Behavior.php rename to src/Mvc/Model/Behavior.php index 25bf961e..9afe06de 100644 --- a/src/Phalcon/Mvc/Model/Behavior.php +++ b/src/Mvc/Model/Behavior.php @@ -27,7 +27,7 @@ abstract class Behavior implements \Phalcon\Mvc\Model\BehaviorInterface * * @param array $options */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } @@ -48,7 +48,7 @@ protected function getOptions(string $eventName = null) * @param string $method * @param array $arguments */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method, array $arguments = array()) + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method, array $arguments = []) { } diff --git a/src/Phalcon/Mvc/Model/Behavior/SoftDelete.php b/src/Mvc/Model/Behavior/SoftDelete.php similarity index 100% rename from src/Phalcon/Mvc/Model/Behavior/SoftDelete.php rename to src/Mvc/Model/Behavior/SoftDelete.php diff --git a/src/Phalcon/Mvc/Model/Behavior/Timestampable.php b/src/Mvc/Model/Behavior/Timestampable.php similarity index 100% rename from src/Phalcon/Mvc/Model/Behavior/Timestampable.php rename to src/Mvc/Model/Behavior/Timestampable.php diff --git a/src/Phalcon/Mvc/Model/BehaviorInterface.php b/src/Mvc/Model/BehaviorInterface.php similarity index 94% rename from src/Phalcon/Mvc/Model/BehaviorInterface.php rename to src/Mvc/Model/BehaviorInterface.php index 8d42f024..30423559 100644 --- a/src/Phalcon/Mvc/Model/BehaviorInterface.php +++ b/src/Mvc/Model/BehaviorInterface.php @@ -24,7 +24,7 @@ interface BehaviorInterface * @param string $method * @param array $arguments */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method, array $arguments = array()); + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method, array $arguments = []); /** * This method receives the notifications from the EventsManager diff --git a/src/Phalcon/Mvc/Model/Binder.php b/src/Mvc/Model/Binder.php similarity index 90% rename from src/Phalcon/Mvc/Model/Binder.php rename to src/Mvc/Model/Binder.php index c5e25187..109aff8a 100644 --- a/src/Phalcon/Mvc/Model/Binder.php +++ b/src/Mvc/Model/Binder.php @@ -23,22 +23,28 @@ class Binder implements \Phalcon\Mvc\Model\BinderInterface * * @var array */ - protected $boundModels = array(); + protected $boundModels = []; /** * Cache object used for caching parameters for model binding + * + * @var AdapterInterface|null */ protected $cache; /** * Internal cache for caching parameters for model binding during request + * + * @var array */ - protected $internalCache = array(); + protected $internalCache = []; /** * Array for original values + * + * @var array */ - protected $originalValues = array(); + protected $originalValues = []; /** @@ -52,8 +58,10 @@ public function getBoundModels(): array /** * Array for original values + * + * @return array */ - public function getOriginalValues() + public function getOriginalValues(): array { } @@ -82,8 +90,7 @@ public function bindToHandler($handler, array $params, string $cacheKey, string /** * Find the model by param value. * - * @return bool - * + * @return mixed * @param mixed $paramValue * @param string $className */ diff --git a/src/Phalcon/Mvc/Model/Binder/BindableInterface.php b/src/Mvc/Model/Binder/BindableInterface.php similarity index 100% rename from src/Phalcon/Mvc/Model/Binder/BindableInterface.php rename to src/Mvc/Model/Binder/BindableInterface.php diff --git a/src/Phalcon/Mvc/Model/BinderInterface.php b/src/Mvc/Model/BinderInterface.php similarity index 100% rename from src/Phalcon/Mvc/Model/BinderInterface.php rename to src/Mvc/Model/BinderInterface.php diff --git a/src/Phalcon/Mvc/Model/Criteria.php b/src/Mvc/Model/Criteria.php similarity index 97% rename from src/Phalcon/Mvc/Model/Criteria.php rename to src/Mvc/Model/Criteria.php index 7214c6e4..119530eb 100644 --- a/src/Phalcon/Mvc/Model/Criteria.php +++ b/src/Mvc/Model/Criteria.php @@ -31,20 +31,30 @@ */ class Criteria implements \Phalcon\Mvc\Model\CriteriaInterface, \Phalcon\Di\InjectionAwareInterface { - + /** + * @var array + */ protected $bindParams; - + /** + * @var array + */ protected $bindTypes; - + /** + * @var int + */ protected $hiddenParamNumber = 0; + /** + * @var string|null + */ + protected $model = null; - protected $model; - - - protected $params = array(); + /** + * @var array + */ + protected $params = []; /** @@ -503,7 +513,7 @@ public function rightJoin(string $model, $conditions = null, $alias = null): Cri * @param \Phalcon\Di\DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(\Phalcon\Di\DiInterface $container): void { } diff --git a/src/Phalcon/Mvc/Model/CriteriaInterface.php b/src/Mvc/Model/CriteriaInterface.php similarity index 100% rename from src/Phalcon/Mvc/Model/CriteriaInterface.php rename to src/Mvc/Model/CriteriaInterface.php diff --git a/src/Phalcon/Mvc/Model/Exception.php b/src/Mvc/Model/Exception.php similarity index 100% rename from src/Phalcon/Mvc/Model/Exception.php rename to src/Mvc/Model/Exception.php diff --git a/src/Phalcon/Mvc/Model/Manager.php b/src/Mvc/Model/Manager.php similarity index 88% rename from src/Phalcon/Mvc/Model/Manager.php rename to src/Mvc/Model/Manager.php index 7cf8babf..268264b3 100644 --- a/src/Phalcon/Mvc/Model/Manager.php +++ b/src/Mvc/Model/Manager.php @@ -43,118 +43,172 @@ */ class Manager implements \Phalcon\Mvc\Model\ManagerInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface { - - protected $aliases = array(); + /** + * @var array + */ + protected $aliases = []; /** * Models' behaviors + * + * @var array */ - protected $behaviors = array(); + protected $behaviors = []; /** * Belongs to relations + * + * @var array */ - protected $belongsTo = array(); + protected $belongsTo = []; /** * All the relationships by model + * + * @var array */ - protected $belongsToSingle = array(); - - - protected $container; + protected $belongsToSingle = []; + /** + * @var DiInterface|null + */ + protected $container = null; - protected $customEventsManager = array(); + /** + * @var array + */ + protected $customEventsManager = []; /** * Does the model use dynamic update, instead of updating all rows? + * + * @var array */ - protected $dynamicUpdate = array(); + protected $dynamicUpdate = []; - - protected $eventsManager; + /** + * @var EventsManagerInterface|null + */ + protected $eventsManager = null; /** * Has many relations + * + * @var array */ - protected $hasMany = array(); + protected $hasMany = []; /** * Has many relations by model + * + * @var array */ - protected $hasManySingle = array(); + protected $hasManySingle = []; /** * Has many-Through relations + * + * @var array */ - protected $hasManyToMany = array(); + protected $hasManyToMany = []; /** * Has many-Through relations by model + * + * @var array */ - protected $hasManyToManySingle = array(); + protected $hasManyToManySingle = []; /** * Has one relations + * + * @var array */ - protected $hasOne = array(); + protected $hasOne = []; /** * Has one relations by model + * + * @var array */ - protected $hasOneSingle = array(); + protected $hasOneSingle = []; /** * Has one through relations + * + * @var array */ - protected $hasOneThrough = array(); + protected $hasOneThrough = []; /** * Has one through relations by model + * + * @var array */ - protected $hasOneThroughSingle = array(); + protected $hasOneThroughSingle = []; /** * Mark initialized models + * + * @var array */ - protected $initialized = array(); - + protected $initialized = []; - protected $keepSnapshots = array(); + /** + * @var array + */ + protected $keepSnapshots = []; /** * Last model initialized + * + * @var ModelInterface|null */ - protected $lastInitialized; + protected $lastInitialized = null; /** * Last query created/executed + * + * @var QueryInterface|null */ - protected $lastQuery; - - - protected $modelVisibility = array(); + protected $lastQuery = null; + /** + * @var array + */ + protected $modelVisibility = []; + /** + * @var string + */ protected $prefix = ''; + /** + * @var array + */ + protected $readConnectionServices = []; - protected $readConnectionServices = array(); - - - protected $sources = array(); - - - protected $schemas = array(); + /** + * @var array + */ + protected $sources = []; + /** + * @var array + */ + protected $schemas = []; - protected $writeConnectionServices = array(); + /** + * @var array + */ + protected $writeConnectionServices = []; /** * Stores a list of reusable instances + * + * @var array */ - protected $reusable = array(); + protected $reusable = []; /** @@ -163,7 +217,7 @@ class Manager implements \Phalcon\Mvc\Model\ManagerInterface, \Phalcon\Di\Inject * @param \Phalcon\Di\DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(\Phalcon\Di\DiInterface $container): void { } @@ -182,16 +236,16 @@ public function getDI(): DiInterface * @param \Phalcon\Events\ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): void { } /** * Returns the internal event manager * - * @return EventsManagerInterface + * @return EventsManagerInterface|null */ - public function getEventsManager(): EventsManagerInterface + public function getEventsManager(): ?EventsManagerInterface { } @@ -202,7 +256,7 @@ public function getEventsManager(): EventsManagerInterface * @param \Phalcon\Events\ManagerInterface $eventsManager * @return void */ - public function setCustomEventsManager(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Events\ManagerInterface $eventsManager) + public function setCustomEventsManager(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Events\ManagerInterface $eventsManager): void { } @@ -210,7 +264,7 @@ public function setCustomEventsManager(\Phalcon\Mvc\ModelInterface $model, \Phal * Returns a custom events manager related to a model or null if there is no related events manager * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Events\ManagerInterface|null + * @return EventsManagerInterface|null */ public function getCustomEventsManager(\Phalcon\Mvc\ModelInterface $model): ?EventsManagerInterface { @@ -280,7 +334,7 @@ public function load(string $modelName): ModelInterface * @param string $prefix * @return void */ - public function setModelPrefix(string $prefix) + public function setModelPrefix(string $prefix): void { } @@ -300,7 +354,7 @@ public function getModelPrefix(): string * @param string $source * @return void */ - public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source) + public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source): void { } @@ -339,7 +393,7 @@ public function getModelSource(\Phalcon\Mvc\ModelInterface $model): string * @param string $schema * @return void */ - public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema) + public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema): void { } @@ -347,9 +401,9 @@ public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schem * Returns the mapped schema for a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @return string|null */ - public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string + public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): ?string { } @@ -360,7 +414,7 @@ public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string * @param string $connectionService * @return void */ - public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) + public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService): void { } @@ -371,7 +425,7 @@ public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string * @param string $connectionService * @return void */ - public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) + public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService): void { } @@ -382,7 +436,7 @@ public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, st * @param string $connectionService * @return void */ - public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) + public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService): void { } @@ -406,20 +460,6 @@ public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model): AdapterI { } - /** - * Returns the connection to read or write data related to a model depending on the connection services. - * - * @todo Remove in v5.0 - * @deprecated Use getConnection() - * - * @return AdapterInterface - * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $connectionServices - */ - protected function _getConnection(\Phalcon\Mvc\ModelInterface $model, $connectionServices): AdapterInterface - { - } - /** * Returns the connection to read or write data related to a model depending on the connection services. * @@ -451,21 +491,6 @@ public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model): s { } - /** - * Returns the connection service name used to read or write data related to - * a model depending on the connection services - * - * @todo Remove in v5.0 - * @deprecated Use getConnectionService() - * - * @return string - * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $connectionServices - */ - public function _getConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionServices): string - { - } - /** * Returns the connection service name used to read or write data related to * a model depending on the connection services @@ -510,7 +535,7 @@ public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventN * @param BehaviorInterface $behavior * @return void */ - public function addBehavior(\Phalcon\Mvc\ModelInterface $model, BehaviorInterface $behavior) + public function addBehavior(\Phalcon\Mvc\ModelInterface $model, BehaviorInterface $behavior): void { } @@ -521,7 +546,7 @@ public function addBehavior(\Phalcon\Mvc\ModelInterface $model, BehaviorInterfac * @param bool $keepSnapshots * @return void */ - public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots) + public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots): void { } @@ -542,7 +567,7 @@ public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model): bool * @param bool $dynamicUpdate * @return void */ - public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate) + public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate): void { } @@ -691,8 +716,8 @@ public function existsHasManyToMany(string $modelName, string $modelRelation): b * Returns a relation by its alias * * @param string $modelName - * @param string $alias - * @return bool|RelationInterface + * @param string $alias * + * @return RelationInterface|bool */ public function getRelationByAlias(string $modelName, string $alias) { @@ -712,7 +737,7 @@ final protected function _mergeFindParameters($findParamsOne, $findParamsTwo): a /** * Helper method to query records based on a relation definition * - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false + * @return \Phalcon\Mvc\Model\Resultset\Simple|int|false * @param RelationInterface $relation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters @@ -740,7 +765,7 @@ public function getReusableRecords(string $modelName, string $key) * @param mixed $records * @return void */ - public function setReusableRecords(string $modelName, string $key, $records) + public function setReusableRecords(string $modelName, string $key, $records): void { } @@ -749,7 +774,7 @@ public function setReusableRecords(string $modelName, string $key, $records) * * @return void */ - public function clearReusableObjects() + public function clearReusableObjects(): void { } @@ -761,7 +786,7 @@ public function clearReusableObjects() * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters * @param string $method - * @return bool|ResultsetInterface + * @return 0|ResultsetInterface */ public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) { @@ -775,7 +800,7 @@ public function getBelongsToRecords(string $modelName, string $modelRelation, \P * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters * @param string $method - * @return bool|ResultsetInterface + * @return 0|ResultsetInterface */ public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) { @@ -789,7 +814,7 @@ public function getHasManyRecords(string $modelName, string $modelRelation, \Pha * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters * @param string $method - * @return bool|\Phalcon\Mvc\ModelInterface + * @return 0|ModelInterface */ public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) { diff --git a/src/Phalcon/Mvc/Model/ManagerInterface.php b/src/Mvc/Model/ManagerInterface.php similarity index 96% rename from src/Phalcon/Mvc/Model/ManagerInterface.php rename to src/Mvc/Model/ManagerInterface.php index c6b9256e..298df165 100644 --- a/src/Phalcon/Mvc/Model/ManagerInterface.php +++ b/src/Mvc/Model/ManagerInterface.php @@ -29,7 +29,7 @@ interface ManagerInterface * @param BehaviorInterface $behavior * @return void */ - public function addBehavior(\Phalcon\Mvc\ModelInterface $model, BehaviorInterface $behavior); + public function addBehavior(\Phalcon\Mvc\ModelInterface $model, BehaviorInterface $behavior): void; /** * Setup a relation reverse 1-1 between two models @@ -184,7 +184,7 @@ public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array; * @param array|string|null $parameters * @param ModelInterface $record * @param string|null $method - * @return bool|ResultsetInterface + * @return 0|ResultsetInterface */ public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); @@ -204,7 +204,7 @@ public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array; * @param array|string|null $parameters * @param ModelInterface $record * @param string|null $method - * @return bool|ResultsetInterface + * @return 0|ResultsetInterface */ public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); @@ -248,7 +248,7 @@ public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array; * @param array|string|null $parameters * @param ModelInterface $record * @param string|null $method - * @return bool|\Phalcon\Mvc\ModelInterface + * @return 0|ModelInterface */ public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); @@ -270,9 +270,9 @@ public function getLastQuery(): QueryInterface; * Returns the mapped schema for a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @return string|null */ - public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string; + public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): ?string; /** * Returns the mapped source for a model @@ -302,15 +302,15 @@ public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model): st * Returns a relation by its alias * * @param string $modelName - * @param string $alias - * @return bool|Relation + * @param string $alias * + * @return RelationInterface|bool */ public function getRelationByAlias(string $modelName, string $alias); /** * Helper method to query records based on a relation definition * - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false + * @return \Phalcon\Mvc\Model\Resultset\Simple|int|false * @param RelationInterface $relation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters @@ -413,7 +413,7 @@ public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, strin * @param bool $keepSnapshots * @return void */ - public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots); + public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots): void; /** * Dispatch an event to the listeners and behaviors @@ -443,7 +443,7 @@ public function notifyEvent(string $eventName, \Phalcon\Mvc\ModelInterface $mode * @param string $connectionService * @return void */ - public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); + public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService): void; /** * Sets read connection service for a model @@ -452,7 +452,7 @@ public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string * @param string $connectionService * @return void */ - public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); + public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService): void; /** * Sets the mapped schema for a model @@ -461,7 +461,7 @@ public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, str * @param string $schema * @return void */ - public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema); + public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema): void; /** * Sets the mapped source for a model @@ -470,7 +470,7 @@ public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schem * @param string $source * @return void */ - public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source); + public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source): void; /** * Sets write connection service for a model @@ -487,5 +487,5 @@ public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, st * @param bool $dynamicUpdate * @return void */ - public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate); + public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate): void; } diff --git a/src/Phalcon/Mvc/Model/MetaData.php b/src/Mvc/Model/MetaData.php similarity index 94% rename from src/Phalcon/Mvc/Model/MetaData.php rename to src/Mvc/Model/MetaData.php index 64ac785e..f6f6ba94 100644 --- a/src/Phalcon/Mvc/Model/MetaData.php +++ b/src/Mvc/Model/MetaData.php @@ -84,21 +84,29 @@ abstract class MetaData implements \Phalcon\Di\InjectionAwareInterface, \Phalcon const MODELS_REVERSE_COLUMN_MAP = 1; /** - * @var CacheAdapterInterface + * @var CacheAdapterInterface|null */ - protected $adapter; - - - protected $columnMap = array(); - - - protected $container; + protected $adapter = null; + /** + * @var array + */ + protected $columnMap = []; - protected $metaData = array(); + /** + * @var DiInterface|null + */ + protected $container = null; + /** + * @var array + */ + protected $metaData = []; - protected $strategy; + /** + * @var StrategyInterface|null + */ + protected $strategy = null; /** @@ -499,7 +507,7 @@ final public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int * * @return void */ - public function reset() + public function reset(): void { } @@ -519,7 +527,7 @@ public function reset() * @param array $attributes * @return void */ - public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) + public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes): void { } @@ -539,7 +547,7 @@ public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, * @param array $attributes * @return void */ - public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) + public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes): void { } @@ -559,7 +567,7 @@ public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, * @param array $attributes * @return void */ - public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) + public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes): void { } @@ -569,7 +577,7 @@ public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, arr * @param \Phalcon\Di\DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(\Phalcon\Di\DiInterface $container): void { } @@ -579,7 +587,7 @@ public function setDI(\Phalcon\Di\DiInterface $container) * @param \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface $strategy * @return void */ - public function setStrategy(\Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface $strategy) + public function setStrategy(\Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface $strategy): void { } @@ -590,7 +598,7 @@ public function setStrategy(\Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterfa * @param array $data * @return void */ - public function write(string $key, array $data) + public function write(string $key, array $data): void { } @@ -614,7 +622,7 @@ public function write(string $key, array $data) * @param mixed $data * @return void */ - final public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index, $data) + final public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index, $data): void { } @@ -636,7 +644,7 @@ final protected function initialize(\Phalcon\Mvc\ModelInterface $model, $key, $t * @param mixed $option * @return void */ - private function throwWriteException($option) + private function throwWriteException($option): void { } } diff --git a/src/Phalcon/Mvc/Model/MetaData/Apcu.php b/src/Mvc/Model/MetaData/Apcu.php similarity index 100% rename from src/Phalcon/Mvc/Model/MetaData/Apcu.php rename to src/Mvc/Model/MetaData/Apcu.php diff --git a/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php b/src/Mvc/Model/MetaData/Libmemcached.php similarity index 93% rename from src/Phalcon/Mvc/Model/MetaData/Libmemcached.php rename to src/Mvc/Model/MetaData/Libmemcached.php index 0598634e..724e4ee1 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php +++ b/src/Mvc/Model/MetaData/Libmemcached.php @@ -27,7 +27,7 @@ class Libmemcached extends MetaData * @param array $options * @param \Phalcon\Cache\AdapterFactory $factory */ - public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) + public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = []) { } @@ -36,7 +36,7 @@ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $optio * * @return void */ - public function reset() + public function reset(): void { } } diff --git a/src/Phalcon/Mvc/Model/MetaData/Memory.php b/src/Mvc/Model/MetaData/Memory.php similarity index 94% rename from src/Phalcon/Mvc/Model/MetaData/Memory.php rename to src/Mvc/Model/MetaData/Memory.php index 7b6ef87a..35a10c40 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Memory.php +++ b/src/Mvc/Model/MetaData/Memory.php @@ -45,7 +45,7 @@ public function read(string $key): ?array * @param array $data * @return void */ - public function write(string $key, array $data) + public function write(string $key, array $data): void { } } diff --git a/src/Phalcon/Mvc/Model/MetaData/Redis.php b/src/Mvc/Model/MetaData/Redis.php similarity index 94% rename from src/Phalcon/Mvc/Model/MetaData/Redis.php rename to src/Mvc/Model/MetaData/Redis.php index d320f49a..eefa8af0 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Redis.php +++ b/src/Mvc/Model/MetaData/Redis.php @@ -41,7 +41,7 @@ class Redis extends MetaData * @param array $options * @param \Phalcon\Cache\AdapterFactory $factory */ - public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) + public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = []) { } @@ -50,7 +50,7 @@ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $optio * * @return void */ - public function reset() + public function reset(): void { } } diff --git a/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php b/src/Mvc/Model/MetaData/Strategy/Annotations.php similarity index 100% rename from src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php rename to src/Mvc/Model/MetaData/Strategy/Annotations.php diff --git a/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php b/src/Mvc/Model/MetaData/Strategy/Introspection.php similarity index 100% rename from src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php rename to src/Mvc/Model/MetaData/Strategy/Introspection.php diff --git a/src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php b/src/Mvc/Model/MetaData/Strategy/StrategyInterface.php similarity index 100% rename from src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php rename to src/Mvc/Model/MetaData/Strategy/StrategyInterface.php diff --git a/src/Phalcon/Mvc/Model/MetaData/Stream.php b/src/Mvc/Model/MetaData/Stream.php similarity index 85% rename from src/Phalcon/Mvc/Model/MetaData/Stream.php rename to src/Mvc/Model/MetaData/Stream.php index a9c7d71d..1feae5e8 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Stream.php +++ b/src/Mvc/Model/MetaData/Stream.php @@ -26,7 +26,9 @@ */ class Stream extends MetaData { - + /** + * @var string + */ protected $metaDataDir = './'; @@ -35,7 +37,7 @@ class Stream extends MetaData * * @param array $options */ - public function __construct($options = null) + public function __construct(array $options = []) { } @@ -56,7 +58,7 @@ public function read(string $key): ?array * @param array $data * @return void */ - public function write(string $key, array $data) + public function write(string $key, array $data): void { } @@ -66,7 +68,7 @@ public function write(string $key, array $data) * @param mixed $option * @return void */ - private function throwWriteException($option) + private function throwWriteException($option): void { } } diff --git a/src/Phalcon/Mvc/Model/MetaDataInterface.php b/src/Mvc/Model/MetaDataInterface.php similarity index 98% rename from src/Phalcon/Mvc/Model/MetaDataInterface.php rename to src/Mvc/Model/MetaDataInterface.php index fe06aef5..51f83a65 100644 --- a/src/Phalcon/Mvc/Model/MetaDataInterface.php +++ b/src/Mvc/Model/MetaDataInterface.php @@ -223,7 +223,7 @@ public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, * @param array $attributes * @return void */ - public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); + public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes): void; /** * Writes meta-data for certain model using a MODEL_ constant @@ -248,5 +248,5 @@ public function setStrategy(\Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterfa * @param array $data * @return void */ - public function write(string $key, array $data); + public function write(string $key, array $data): void; } diff --git a/src/Phalcon/Mvc/Model/Query.php b/src/Mvc/Model/Query.php similarity index 76% rename from src/Phalcon/Mvc/Model/Query.php rename to src/Mvc/Model/Query.php index ad88cc04..9b761043 100644 --- a/src/Phalcon/Mvc/Model/Query.php +++ b/src/Mvc/Model/Query.php @@ -13,6 +13,7 @@ use Phalcon\Di\DiInterface; use Phalcon\Mvc\Model\Query\StatusInterface; use Phalcon\Mvc\ModelInterface; +use Psr\SimpleCache\CacheInterface; /** * Phalcon\Mvc\Model\Query @@ -78,82 +79,131 @@ class Query implements \Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionA const TYPE_UPDATE = 300; - + /** + * @var array + * TODO: Add default value, instead of null, also remove type check + */ protected $ast; + /** + * @var array + */ + protected $bindParams = []; - protected $bindParams; - - - protected $bindTypes; - - - protected $cache; + /** + * @var array + */ + protected $bindTypes = []; + /** + * @var \Psr\SimpleCache\CacheInterface|null + */ + protected $cache = null; + /** + * @var array|null + */ protected $cacheOptions; + /** + * @var DiInterface|null + */ + protected $container = null; - protected $container; - - + /** + * @var bool + */ protected $enableImplicitJoins; - + /** + * @var array + */ protected $intermediate; + /** + * @var \Phalcon\Mvc\Model\ManagerInterface|null + */ + protected $manager = null; - protected $manager; - - - protected $metaData; - - - protected $models; - + /** + * @var \Phalcon\Mvc\Model\MetaDataInterface|null + */ + protected $metaData = null; - protected $modelsInstances; + /** + * @var array + */ + protected $models = []; + /** + * @var array + */ + protected $modelsInstances = []; + /** + * @var int + */ protected $nestingLevel = -1; + /** + * @var string|null + */ + protected $phql = null; - protected $phql; - - - protected $sharedLock; - - - protected $sqlAliases; - - - protected $sqlAliasesModels; - - - protected $sqlAliasesModelsInstances; + /** + * @var bool + */ + protected $sharedLock = false; + /** + * @var array + */ + protected $sqlAliases = []; - protected $sqlColumnAliases = array(); + /** + * @var array + */ + protected $sqlAliasesModels = []; + /** + * @var array + */ + protected $sqlAliasesModelsInstances = []; - protected $sqlModelsAliases; + /** + * @var array + */ + protected $sqlColumnAliases = []; + /** + * @var array + */ + protected $sqlModelsAliases = []; + /** + * @var int|null + */ protected $type; - - protected $uniqueRow; - - - protected static $_irPhqlCache; + /** + * @var bool + */ + protected $uniqueRow = false; /** * TransactionInterface so that the query can wrap a transaction * around batch updates and intermediate selects within the transaction. * however if a model got a transaction set inside it will use the local * transaction instead of this one + * + * @var TransactionInterface|null + */ + protected $transaction; + + /** + * @var array|null */ - protected $_transaction; + protected static $internalPhqlCache; /** @@ -162,6 +212,8 @@ class Query implements \Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionA * around batch updates and intermediate selects within the transaction. * however if a model got a transaction set inside it will use the local * transaction instead of this one + * + * @return TransactionInterface|null */ public function getTransaction() { @@ -170,290 +222,242 @@ public function getTransaction() /** * Phalcon\Mvc\Model\Query constructor * - * @param string $phql - * @param \Phalcon\Di\DiInterface $container + * @param string|null $phql + * @param DiInterface|null $container * @param array $options */ - public function __construct(string $phql = null, \Phalcon\Di\DiInterface $container = null, array $options = array()) - { - } - - /** - * Sets the dependency injection container - * - * @param \Phalcon\Di\DiInterface $container - * @return void - */ - public function setDI(\Phalcon\Di\DiInterface $container) - { - } - - /** - * Returns the dependency injection container - * - * @return DiInterface - */ - public function getDI(): DiInterface + public function __construct(string $phql = null, \Phalcon\Di\DiInterface $container = null, array $options = []) { } /** - * Tells to the query if only the first row in the resultset must be - * returned + * Sets the cache parameters of the query * - * @param bool $uniqueRow + * @param array $cacheOptions * @return QueryInterface */ - public function setUniqueRow(bool $uniqueRow): QueryInterface + public function cache(array $cacheOptions): QueryInterface { } /** - * Check if the query is programmed to get only the first row in the - * resultset + * Destroys the internal PHQL cache * - * @return bool + * @return void */ - public function getUniqueRow(): bool + public static function clean(): void { } /** - * Replaces the model's name to its source name in a qualified-name - * expression + * Executes a parsed PHQL statement * - * @param array $expr - * @return array + * @return mixed + * @param array $bindParams + * @param array $bindTypes */ - final protected function _getQualified(array $expr): array + public function execute(array $bindParams = [], array $bindTypes = []) { } /** - * Resolves an expression in a single call argument + * Returns the current cache backend instance * - * @param array $argument - * @return array + * @return AdapterInterface */ - final protected function _getCallArgument(array $argument): array + public function getCache(): AdapterInterface { } /** - * Resolves an expression in a single call argument + * Returns the current cache options * - * @param array $expr * @return array */ - final protected function _getCaseExpression(array $expr): array + public function getCacheOptions(): array { } /** - * Resolves an expression in a single call argument + * Returns default bind params * - * @param array $expr * @return array */ - final protected function _getFunctionCall(array $expr): array - { - } - - /** - * Resolves an expression from its intermediate code into a string - * - * @param array $expr - * @param bool $quoting - * @return string - */ - final protected function _getExpression(array $expr, bool $quoting = true): string + public function getBindParams(): array { } /** - * Resolves a column from its intermediate representation into an array - * used to determine if the resultset produced is simple or complex + * Returns default bind types * - * @param array $column * @return array */ - final protected function _getSelectColumn(array $column): array + public function getBindTypes(): array { } /** - * Resolves a table in a SELECT statement checking if the model exists + * Returns the dependency injection container * - * @return string - * @param ManagerInterface $manager - * @param array $qualifiedName + * @return DiInterface */ - final protected function _getTable(ManagerInterface $manager, array $qualifiedName) + public function getDI(): DiInterface { } /** - * Resolves a JOIN clause checking if the associated models exist + * Returns the intermediate representation of the PHQL statement * - * @param ManagerInterface $manager - * @param array $join * @return array */ - final protected function _getJoin(ManagerInterface $manager, array $join): array + public function getIntermediate(): array { } /** - * Resolves a JOIN type + * Executes the query returning the first result * - * @param array $join - * @return string + * @param array $bindParams + * @param array $bindTypes + * @return ModelInterface */ - final protected function _getJoinType(array $join): string + public function getSingleResult(array $bindParams = [], array $bindTypes = []): ModelInterface { } /** - * Resolves joins involving has-one/belongs-to/has-many relations + * Returns the SQL to be generated by the internal PHQL (only works in + * SELECT statements) * - * @param string $joinSource - * @param string $joinType - * @param string $modelAlias - * @param string $joinAlias - * @param RelationInterface $relation * @return array */ - final protected function _getSingleJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, RelationInterface $relation): array + public function getSql(): array { } /** - * Resolves joins involving many-to-many relations + * Gets the type of PHQL statement executed * - * @param string $joinSource - * @param string $joinType - * @param string $modelAlias - * @param string $joinAlias - * @param RelationInterface $relation - * @return array + * @return int */ - final protected function _getMultiJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, RelationInterface $relation): array + public function getType(): int { } /** - * Processes the JOINs in the query returning an internal representation for - * the database dialect + * Check if the query is programmed to get only the first row in the + * resultset * - * @param array $select - * @return array + * @return bool */ - final protected function _getJoins(array $select): array + public function getUniqueRow(): bool { } /** - * Returns a processed order clause for a SELECT statement + * Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang + * generating another intermediate representation that could be executed by + * Phalcon\Mvc\Model\Query * - * @param array|string $order * @return array */ - final protected function _getOrderClause($order): array + public function parse(): array { } /** - * Returns a processed group clause for a SELECT statement + * Set default bind parameters * - * @param array $group - * @return array + * @param array $bindParams + * @param bool $merge + * @return QueryInterface */ - final protected function _getGroupClause(array $group): array + public function setBindParams(array $bindParams, bool $merge = false): QueryInterface { } /** - * Returns a processed limit clause for a SELECT statement + * Set default bind parameters * - * @param array $limitClause - * @return array + * @param array $bindTypes + * @param bool $merge + * @return QueryInterface */ - final protected function _getLimitClause(array $limitClause): array + public function setBindTypes(array $bindTypes, bool $merge = false): QueryInterface { } /** - * Analyzes a SELECT intermediate code and produces an array to be executed later + * Sets the dependency injection container * - * @param mixed $ast - * @param bool $merge - * @return array + * @param \Phalcon\Di\DiInterface $container + * @return void */ - final protected function _prepareSelect($ast = null, bool $merge = false): array + public function setDI(\Phalcon\Di\DiInterface $container): void { } /** - * Analyzes an INSERT intermediate code and produces an array to be executed - * later + * Allows to set the IR to be executed * - * @return array + * @param array $intermediate + * @return QueryInterface */ - final protected function _prepareInsert(): array + public function setIntermediate(array $intermediate): QueryInterface { } /** - * Analyzes an UPDATE intermediate code and produces an array to be executed - * later + * Set SHARED LOCK clause * - * @return array + * @param bool $sharedLock + * @return QueryInterface */ - final protected function _prepareUpdate(): array + public function setSharedLock(bool $sharedLock = false): QueryInterface { } /** - * Analyzes a DELETE intermediate code and produces an array to be executed - * later + * allows to wrap a transaction around all queries * - * @return array + * @param TransactionInterface $transaction + * @return QueryInterface */ - final protected function _prepareDelete(): array + public function setTransaction(TransactionInterface $transaction): QueryInterface { } /** - * Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang - * generating another intermediate representation that could be executed by - * Phalcon\Mvc\Model\Query + * Sets the type of PHQL statement to be executed * - * @return array + * @param int $type + * @return QueryInterface */ - public function parse(): array + public function setType(int $type): QueryInterface { } /** - * Returns the current cache backend instance + * Tells to the query if only the first row in the resultset must be + * returned * - * @return AdapterInterface + * @param bool $uniqueRow + * @return QueryInterface */ - public function getCache(): AdapterInterface + public function setUniqueRow(bool $uniqueRow): QueryInterface { } /** - * Executes the SELECT intermediate representation producing a - * Phalcon\Mvc\Model\Resultset + * Executes the DELETE intermediate representation producing a + * Phalcon\Mvc\Model\Query\Status * * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @param bool $simulate - * @return array|\Phalcon\Mvc\Model\ResultsetInterface + * @return StatusInterface */ - final protected function _executeSelect(array $intermediate, array $bindParams, array $bindTypes, bool $simulate = false) + final protected function executeDelete(array $intermediate, array $bindParams, array $bindTypes): StatusInterface { } @@ -466,25 +470,26 @@ final protected function _executeSelect(array $intermediate, array $bindParams, * @param array $bindTypes * @return StatusInterface */ - final protected function _executeInsert(array $intermediate, array $bindParams, array $bindTypes): StatusInterface + final protected function executeInsert(array $intermediate, array $bindParams, array $bindTypes): StatusInterface { } /** - * Executes the UPDATE intermediate representation producing a - * Phalcon\Mvc\Model\Query\Status + * Executes the SELECT intermediate representation producing a + * Phalcon\Mvc\Model\Resultset * * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @return StatusInterface + * @param bool $simulate + * @return 0|ResultsetInterface */ - final protected function _executeUpdate(array $intermediate, array $bindParams, array $bindTypes): StatusInterface + final protected function executeSelect(array $intermediate, array $bindParams, array $bindTypes, bool $simulate = false) { } /** - * Executes the DELETE intermediate representation producing a + * Executes the UPDATE intermediate representation producing a * Phalcon\Mvc\Model\Query\Status * * @param array $intermediate @@ -492,189 +497,203 @@ final protected function _executeUpdate(array $intermediate, array $bindParams, * @param array $bindTypes * @return StatusInterface */ - final protected function _executeDelete(array $intermediate, array $bindParams, array $bindTypes): StatusInterface + final protected function executeUpdate(array $intermediate, array $bindParams, array $bindTypes): StatusInterface { } /** - * Query the records on which the UPDATE/DELETE operation will be done - * - * @todo Remove in v5.0 - * @deprecated Use getRelatedRecords() + * Resolves an expression in a single call argument * - * @return ResultsetInterface - * @param \Phalcon\Mvc\ModelInterface $model - * @param array $intermediate - * @param array $bindParams - * @param array $bindTypes + * @param array $argument + * @return array */ - final protected function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, array $intermediate, array $bindParams, array $bindTypes): ResultsetInterface + final protected function getCallArgument(array $argument): array { } /** - * Query the records on which the UPDATE/DELETE operation will be done + * Resolves an expression in a single call argument * - * @return ResultsetInterface - * @param \Phalcon\Mvc\ModelInterface $model - * @param array $intermediate - * @param array $bindParams - * @param array $bindTypes + * @param array $expr + * @return array */ - final protected function getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, array $intermediate, array $bindParams, array $bindTypes): ResultsetInterface + final protected function getCaseExpression(array $expr): array { } /** - * Executes a parsed PHQL statement + * Resolves an expression from its intermediate code into a string * - * @return mixed - * @param array $bindParams - * @param array $bindTypes + * @param array $expr + * @param bool $quoting + * @return string */ - public function execute(array $bindParams = array(), array $bindTypes = array()) + final protected function getExpression(array $expr, bool $quoting = true): string { } /** - * Executes the query returning the first result + * Resolves an expression in a single call argument * - * @param array $bindParams - * @param array $bindTypes - * @return ModelInterface + * @param array $expr + * @return array */ - public function getSingleResult(array $bindParams = array(), array $bindTypes = array()): ModelInterface + final protected function getFunctionCall(array $expr): array { } /** - * Sets the type of PHQL statement to be executed + * Returns a processed group clause for a SELECT statement * - * @param int $type - * @return QueryInterface + * @param array $group + * @return array */ - public function setType(int $type): QueryInterface + final protected function getGroupClause(array $group): array { } /** - * Gets the type of PHQL statement executed + * Returns a processed limit clause for a SELECT statement * - * @return int + * @param array $limitClause + * @return array */ - public function getType(): int + final protected function getLimitClause(array $limitClause): array { } /** - * Set default bind parameters + * Resolves a JOIN clause checking if the associated models exist * - * @param array $bindParams - * @param bool $merge - * @return QueryInterface + * @param ManagerInterface $manager + * @param array $join + * @return array */ - public function setBindParams(array $bindParams, bool $merge = false): QueryInterface + final protected function getJoin(ManagerInterface $manager, array $join): array { } /** - * Returns default bind params + * Resolves a JOIN type * - * @return array + * @param array $join + * @return string */ - public function getBindParams(): array + final protected function getJoinType(array $join): string { } /** - * Set default bind parameters + * Processes the JOINs in the query returning an internal representation for + * the database dialect * - * @param array $bindTypes - * @param bool $merge - * @return QueryInterface + * @param array $select + * @return array */ - public function setBindTypes(array $bindTypes, bool $merge = false): QueryInterface + final protected function getJoins(array $select): array { } /** - * Set SHARED LOCK clause + * Resolves joins involving many-to-many relations * - * @param bool $sharedLock - * @return QueryInterface + * @param string $joinSource + * @param string $joinType + * @param string $modelAlias + * @param string $joinAlias + * @param RelationInterface $relation + * @return array */ - public function setSharedLock(bool $sharedLock = false): QueryInterface + final protected function getMultiJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, RelationInterface $relation): array { } /** - * Returns default bind types + * Returns a processed order clause for a SELECT statement * + * @param array|string $order * @return array */ - public function getBindTypes(): array + final protected function getOrderClause($order): array { } /** - * Allows to set the IR to be executed + * Replaces the model's name to its source name in a qualified-name + * expression * - * @param array $intermediate - * @return QueryInterface + * @param array $expr + * @return array */ - public function setIntermediate(array $intermediate): QueryInterface + final protected function getQualified(array $expr): array { } /** - * Returns the intermediate representation of the PHQL statement + * Gets the read connection from the model if there is no transaction set + * inside the query object * - * @return array + * @param \Phalcon\Mvc\ModelInterface $model + * @param array $intermediate + * @param array $bindParams + * @param array $bindTypes + * @return AdapterInterface */ - public function getIntermediate(): array + protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = [], array $bindTypes = []): AdapterInterface { } /** - * Sets the cache parameters of the query + * Query the records on which the UPDATE/DELETE operation will be done * - * @param array $cacheOptions - * @return QueryInterface + * @return ResultsetInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @param array $intermediate + * @param array $bindParams + * @param array $bindTypes */ - public function cache(array $cacheOptions): QueryInterface + final protected function getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, array $intermediate, array $bindParams, array $bindTypes): ResultsetInterface { } /** - * Returns the current cache options + * Resolves a column from its intermediate representation into an array + * used to determine if the resultset produced is simple or complex * + * @param array $column * @return array */ - public function getCacheOptions(): array + final protected function getSelectColumn(array $column): array { } /** - * Returns the SQL to be generated by the internal PHQL (only works in - * SELECT statements) + * Resolves joins involving has-one/belongs-to/has-many relations * + * @param string $joinSource + * @param string $joinType + * @param string $modelAlias + * @param string $joinAlias + * @param RelationInterface $relation * @return array */ - public function getSql(): array + final protected function getSingleJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, RelationInterface $relation): array { } /** - * Destroys the internal PHQL cache + * Resolves a table in a SELECT statement checking if the model exists * - * @return void + * @return string + * @param ManagerInterface $manager + * @param array $qualifiedName */ - public static function clean() + final protected function getTable(ManagerInterface $manager, array $qualifiedName) { } /** - * Gets the read connection from the model if there is no transaction set + * Gets the write connection from the model if there is no transaction * inside the query object * * @param \Phalcon\Mvc\ModelInterface $model @@ -683,31 +702,48 @@ public static function clean() * @param array $bindTypes * @return AdapterInterface */ - protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface + protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = [], array $bindTypes = []): AdapterInterface { } /** - * Gets the write connection from the model if there is no transaction - * inside the query object + * Analyzes a DELETE intermediate code and produces an array to be executed + * later * - * @param \Phalcon\Mvc\ModelInterface $model - * @param array $intermediate - * @param array $bindParams - * @param array $bindTypes - * @return AdapterInterface + * @return array */ - protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface + final protected function _prepareDelete(): array { } /** - * allows to wrap a transaction around all queries + * Analyzes an INSERT intermediate code and produces an array to be executed + * later * - * @param TransactionInterface $transaction - * @return QueryInterface + * @return array */ - public function setTransaction(TransactionInterface $transaction): QueryInterface + final protected function _prepareInsert(): array + { + } + + /** + * Analyzes a SELECT intermediate code and produces an array to be executed later + * + * @param mixed $ast + * @param bool $merge + * @return array + */ + final protected function _prepareSelect($ast = null, bool $merge = false): array + { + } + + /** + * Analyzes an UPDATE intermediate code and produces an array to be executed + * later + * + * @return array + */ + final protected function _prepareUpdate(): array { } } diff --git a/src/Phalcon/Mvc/Model/Query/Builder.php b/src/Mvc/Model/Query/Builder.php similarity index 92% rename from src/Phalcon/Mvc/Model/Query/Builder.php rename to src/Mvc/Model/Query/Builder.php index 101f74ae..20249718 100644 --- a/src/Phalcon/Mvc/Model/Query/Builder.php +++ b/src/Mvc/Model/Query/Builder.php @@ -50,42 +50,64 @@ */ class Builder implements \Phalcon\Mvc\Model\Query\BuilderInterface, \Phalcon\Di\InjectionAwareInterface { + /** + * @var array + */ + protected $bindParams = []; - protected $bindParams; - - - protected $bindTypes; - - - protected $columns; - + /** + * @var array + */ + protected $bindTypes = []; - protected $conditions; + /** + * @var array|string|null + */ + protected $columns = null; + /** + * @var array|string|null + */ + protected $conditions = null; + /** + * @var DiInterface|null + */ protected $container; + /** + * @var mixed + */ + protected $distinct = null; - protected $distinct; - - - protected $forUpdate; + /** + * @var bool + */ + protected $forUpdate = false; /** * @var array */ - protected $group; - - - protected $having; + protected $group = []; + /** + * @var string|null + */ + protected $having = null; + /** + * @var int + */ protected $hiddenParamNumber = 0; + /** + * @var array + */ + protected $joins = []; - protected $joins; - - + /** + * @var array|string + */ protected $limit; /** @@ -93,21 +115,27 @@ class Builder implements \Phalcon\Mvc\Model\Query\BuilderInterface, \Phalcon\Di\ */ protected $models; + /** + * @var int + */ + protected $offset = 0; - protected $offset; - - + /** + * @var array|string + */ protected $order; - - protected $sharedLock; + /** + * @var bool + */ + protected $sharedLock = false; /** * Phalcon\Mvc\Model\Query\Builder constructor * - * @param mixed $params - * @param \Phalcon\Di\DiInterface $container + * @param array|string|null $params + * @param DiInterface|null $container */ public function __construct($params = null, \Phalcon\Di\DiInterface $container = null) { @@ -156,7 +184,7 @@ public function addFrom(string $model, string $alias = null): BuilderInterface * @param array $bindTypes * @return BuilderInterface */ - public function andHaving(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface + public function andHaving(string $conditions, array $bindParams = [], array $bindTypes = []): BuilderInterface { } @@ -180,7 +208,7 @@ public function andHaving(string $conditions, array $bindParams = array(), array * @param array $bindTypes * @return BuilderInterface */ - public function andWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface + public function andWhere(string $conditions, array $bindParams = [], array $bindTypes = []): BuilderInterface { } @@ -336,7 +364,7 @@ public function getBindTypes(): array /** * Return the columns to be queried * - * @return string|array + * @return array|string */ public function getColumns() { @@ -363,7 +391,7 @@ public function getDistinct(): bool /** * Return the models who makes part of the query * - * @return string|array + * @return array|string */ public function getFrom() { @@ -399,7 +427,7 @@ public function getJoins(): array /** * Returns the current LIMIT clause * - * @return string|array + * @return array|string */ public function getLimit() { @@ -426,7 +454,7 @@ public function getOffset(): int /** * Returns the set ORDER BY clause * - * @return string|array + * @return array|string */ public function getOrderBy() { @@ -453,7 +481,7 @@ public function getQuery(): QueryInterface /** * Return the conditions for the query * - * @return string|array + * @return array|string */ public function getWhere() { @@ -470,7 +498,7 @@ public function getWhere() * ); * ``` * - * @param string|array $group + * @param array|string $group * @return BuilderInterface */ public function groupBy($group): BuilderInterface @@ -491,12 +519,12 @@ public function groupBy($group): BuilderInterface * ); * ``` * - * @param mixed $conditions + * @param string $conditions * @param array $bindParams * @param array $bindTypes * @return BuilderInterface */ - public function having($conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface + public function having(string $conditions, array $bindParams = [], array $bindTypes = []): BuilderInterface { } @@ -734,7 +762,7 @@ public function offset(int $offset): BuilderInterface * $builder->orderBy(["Robots.name DESC"]); * ``` * - * @param string|array $orderBy + * @param array|string $orderBy * @return BuilderInterface */ public function orderBy($orderBy): BuilderInterface @@ -760,7 +788,7 @@ public function orderBy($orderBy): BuilderInterface * @param array $bindTypes * @return BuilderInterface */ - public function orHaving(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface + public function orHaving(string $conditions, array $bindParams = [], array $bindTypes = []): BuilderInterface { } @@ -784,7 +812,7 @@ public function orHaving(string $conditions, array $bindParams = array(), array * @param array $bindTypes * @return BuilderInterface */ - public function orWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface + public function orWhere(string $conditions, array $bindParams = [], array $bindTypes = []): BuilderInterface { } @@ -836,7 +864,7 @@ public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInte * @param \Phalcon\Di\DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(\Phalcon\Di\DiInterface $container): void { } @@ -862,7 +890,7 @@ public function setDI(\Phalcon\Di\DiInterface $container) * @param array $bindTypes * @return BuilderInterface */ - public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface + public function where(string $conditions, array $bindParams = [], array $bindTypes = []): BuilderInterface { } diff --git a/src/Phalcon/Mvc/Model/Query/BuilderInterface.php b/src/Mvc/Model/Query/BuilderInterface.php similarity index 95% rename from src/Phalcon/Mvc/Model/Query/BuilderInterface.php rename to src/Mvc/Model/Query/BuilderInterface.php index d9b86f9b..dc49933e 100644 --- a/src/Phalcon/Mvc/Model/Query/BuilderInterface.php +++ b/src/Mvc/Model/Query/BuilderInterface.php @@ -42,7 +42,7 @@ public function addFrom(string $model, string $alias = null): BuilderInterface; * @param array $bindTypes * @return BuilderInterface */ - public function andWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; + public function andWhere(string $conditions, array $bindParams = [], array $bindTypes = []): BuilderInterface; /** * Appends a BETWEEN condition to the current conditions @@ -205,10 +205,10 @@ public function groupBy($group): BuilderInterface; /** * Sets a HAVING condition clause * - * @param string $having + * @param string $conditions * @return BuilderInterface */ - public function having(string $having): BuilderInterface; + public function having(string $conditions): BuilderInterface; /** * Adds an INNER join to the query @@ -298,10 +298,10 @@ public function offset(int $offset): BuilderInterface; /** * Sets an ORDER BY condition clause * - * @param string $orderBy + * @param array|string $orderBy * @return BuilderInterface */ - public function orderBy(string $orderBy): BuilderInterface; + public function orderBy($orderBy): BuilderInterface; /** * Appends a condition to the current conditions using an OR operator @@ -311,7 +311,7 @@ public function orderBy(string $orderBy): BuilderInterface; * @param array $bindTypes * @return BuilderInterface */ - public function orWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; + public function orWhere(string $conditions, array $bindParams = [], array $bindTypes = []): BuilderInterface; /** * Adds a RIGHT join to the query @@ -349,5 +349,5 @@ public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInte * @param array $bindTypes * @return BuilderInterface */ - public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; + public function where(string $conditions, array $bindParams = [], array $bindTypes = []): BuilderInterface; } diff --git a/src/Phalcon/Mvc/Model/Query/Lang.php b/src/Mvc/Model/Query/Lang.php similarity index 100% rename from src/Phalcon/Mvc/Model/Query/Lang.php rename to src/Mvc/Model/Query/Lang.php diff --git a/src/Phalcon/Mvc/Model/Query/Status.php b/src/Mvc/Model/Query/Status.php similarity index 95% rename from src/Phalcon/Mvc/Model/Query/Status.php rename to src/Mvc/Model/Query/Status.php index 623b3ca1..938f3cd6 100644 --- a/src/Phalcon/Mvc/Model/Query/Status.php +++ b/src/Mvc/Model/Query/Status.php @@ -40,10 +40,14 @@ */ class Status implements \Phalcon\Mvc\Model\Query\StatusInterface { - + /** + * @var ModelInterface|null + */ protected $model; - + /** + * @var bool + */ protected $success; diff --git a/src/Phalcon/Mvc/Model/Query/StatusInterface.php b/src/Mvc/Model/Query/StatusInterface.php similarity index 100% rename from src/Phalcon/Mvc/Model/Query/StatusInterface.php rename to src/Mvc/Model/Query/StatusInterface.php diff --git a/src/Phalcon/Mvc/Model/QueryInterface.php b/src/Mvc/Model/QueryInterface.php similarity index 93% rename from src/Phalcon/Mvc/Model/QueryInterface.php rename to src/Mvc/Model/QueryInterface.php index 23e22e87..9fbc47ef 100644 --- a/src/Phalcon/Mvc/Model/QueryInterface.php +++ b/src/Mvc/Model/QueryInterface.php @@ -34,7 +34,7 @@ public function cache(array $cacheOptions): QueryInterface; * @param array $bindParams * @param array $bindTypes */ - public function execute(array $bindParams = array(), array $bindTypes = array()); + public function execute(array $bindParams = [], array $bindTypes = []); /** * Returns default bind params @@ -71,7 +71,7 @@ public function getSql(): array; * @param array $bindTypes * @return ModelInterface */ - public function getSingleResult(array $bindParams = array(), array $bindTypes = array()): ModelInterface; + public function getSingleResult(array $bindParams = [], array $bindTypes = []): ModelInterface; /** * Check if the query is programmed to get only the first row in the resultset diff --git a/src/Phalcon/Mvc/Model/Relation.php b/src/Mvc/Model/Relation.php similarity index 82% rename from src/Phalcon/Mvc/Model/Relation.php rename to src/Mvc/Model/Relation.php index 5b0487aa..bfd6a013 100644 --- a/src/Phalcon/Mvc/Model/Relation.php +++ b/src/Mvc/Model/Relation.php @@ -40,48 +40,64 @@ class Relation implements \Phalcon\Mvc\Model\RelationInterface const NO_ACTION = 0; - + /** + * @var array|string + */ protected $fields; - + /** + * @var array|string + */ protected $intermediateFields; + /** + * @var string|null + */ + protected $intermediateModel = null; - protected $intermediateModel; - - + /** + * @var array|string + */ protected $intermediateReferencedFields; + /** + * @var array + */ + protected $options = []; - protected $options; - - + /** + * @var array|string + */ protected $referencedFields; - + /** + * @var string + */ protected $referencedModel; - + /** + * @var int + */ protected $type; /** * Phalcon\Mvc\Model\Relation constructor * - * @param string|array $fields - * @param string|array $referencedFields * @param int $type * @param string $referencedModel + * @param array|string $fields + * @param array|string $referencedFields * @param array $options */ - public function __construct(int $type, string $referencedModel, $fields, $referencedFields, array $options = array()) + public function __construct(int $type, string $referencedModel, $fields, $referencedFields, array $options = []) { } /** * Returns the fields * - * @return string|array + * @return array|string */ public function getFields() { @@ -90,7 +106,7 @@ public function getFields() /** * Returns the foreign key configuration * - * @return string|array + * @return array|string */ public function getForeignKey() { @@ -99,7 +115,7 @@ public function getForeignKey() /** * Gets the intermediate fields for has--through relations * - * @return string|array + * @return array|string */ public function getIntermediateFields() { @@ -117,7 +133,7 @@ public function getIntermediateModel(): string /** * Gets the intermediate referenced fields for has--through relations * - * @return string|array + * @return array|string */ public function getIntermediateReferencedFields() { @@ -163,7 +179,7 @@ public function getType(): int /** * Returns the referenced fields * - * @return string|array + * @return array|string */ public function getReferencedFields() { @@ -208,9 +224,9 @@ public function isReusable(): bool /** * Sets the intermediate model data for has--through relations * - * @param string|array $intermediateFields - * @param string $intermediateReferencedFields + * @param array|string $intermediateFields * @param string $intermediateModel + * @param array|string $intermediateReferencedFields */ public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields) { diff --git a/src/Phalcon/Mvc/Model/RelationInterface.php b/src/Mvc/Model/RelationInterface.php similarity index 100% rename from src/Phalcon/Mvc/Model/RelationInterface.php rename to src/Mvc/Model/RelationInterface.php diff --git a/src/Phalcon/Mvc/Model/ResultInterface.php b/src/Mvc/Model/ResultInterface.php similarity index 89% rename from src/Phalcon/Mvc/Model/ResultInterface.php rename to src/Mvc/Model/ResultInterface.php index 9e83d6bf..fc057681 100644 --- a/src/Phalcon/Mvc/Model/ResultInterface.php +++ b/src/Mvc/Model/ResultInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\ResultInterface * @@ -21,7 +23,7 @@ interface ResultInterface * Sets the object's state * * @param int $dirtyState - * @return bool|\Phalcon\Mvc\ModelInterface + * @return bool|ModelInterface */ public function setDirtyState(int $dirtyState); } diff --git a/src/Phalcon/Mvc/Model/Resultset.php b/src/Mvc/Model/Resultset.php similarity index 87% rename from src/Phalcon/Mvc/Model/Resultset.php rename to src/Mvc/Model/Resultset.php index 71a31004..4095e562 100644 --- a/src/Phalcon/Mvc/Model/Resultset.php +++ b/src/Mvc/Model/Resultset.php @@ -9,8 +9,8 @@ */ namespace Phalcon\Mvc\Model; -use Phalcon\Cache\Adapter\AdapterInterface; use Phalcon\Mvc\ModelInterface; +use Psr\SimpleCache\CacheInterface; /** * Phalcon\Mvc\Model\Resultset @@ -70,35 +70,55 @@ abstract class Resultset implements \Phalcon\Mvc\Model\ResultsetInterface, \Iter const TYPE_RESULT_PARTIAL = 1; - + /** + * @var mixed|null + */ protected $activeRow = null; - + /** + * @var CacheInterface|null + */ protected $cache = null; - + /** + * @var int + */ protected $count = 0; + /** + * @var array + */ + protected $errorMessages = []; - protected $errorMessages = array(); - - + /** + * @var int + */ protected $hydrateMode = 0; - + /** + * @var bool + */ protected $isFresh = true; - + /** + * @var int + */ protected $pointer = 0; - + /** + * @var mixed|null + */ protected $row = null; - + /** + * @var array|null + */ protected $rows = null; /** * Phalcon\Db\ResultInterface or false for empty resultset + * + * @var ResultInterface|bool */ protected $result; @@ -106,10 +126,10 @@ abstract class Resultset implements \Phalcon\Mvc\Model\ResultsetInterface, \Iter /** * Phalcon\Mvc\Model\Resultset constructor * - * @param \Phalcon\Db\ResultInterface|false $result - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @param ResultInterface|false $result + * @param CacheInterface|null $cache */ - public function __construct($result, \Phalcon\Cache\Adapter\AdapterInterface $cache = null) + public function __construct($result, \Psr\SimpleCache\CacheInterface $cache = null) { } @@ -155,9 +175,9 @@ public function filter($filter): array /** * Returns the associated cache for the resultset * - * @return AdapterInterface + * @return CacheInterface|null */ - public function getCache(): AdapterInterface + public function getCache(): ?CacheInterface { } @@ -202,7 +222,7 @@ public function getHydrateMode(): int /** * Get last row in the resultset * - * @return \Phalcon\Mvc\ModelInterface|null + * @return ModelInterface|null */ public function getLast(): ?ModelInterface { @@ -265,7 +285,7 @@ public function key(): ?int * * @return void */ - public function next() + public function next(): void { } @@ -273,7 +293,7 @@ public function next() * Gets row in a specific position of the resultset * * @param mixed $index - * @return bool|\Phalcon\Mvc\ModelInterface + * @return 0|ModelInterface */ public function offsetGet($index) { @@ -296,7 +316,7 @@ public function offsetExists($index): bool * @param \Phalcon\Mvc\ModelInterface $value * @return void */ - public function offsetSet($index, $value) + public function offsetSet($index, $value): void { } @@ -306,7 +326,7 @@ public function offsetSet($index, $value) * @param mixed $offset * @return void */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { } @@ -315,7 +335,7 @@ public function offsetUnset($offset) * * @return void */ - final public function rewind() + final public function rewind(): void { } @@ -326,7 +346,7 @@ final public function rewind() * @param mixed $position * @return void */ - final public function seek($position) + final public function seek($position): void { } diff --git a/src/Phalcon/Mvc/Model/Resultset/Complex.php b/src/Mvc/Model/Resultset/Complex.php similarity index 82% rename from src/Phalcon/Mvc/Model/Resultset/Complex.php rename to src/Mvc/Model/Resultset/Complex.php index 52929deb..78e89d64 100644 --- a/src/Phalcon/Mvc/Model/Resultset/Complex.php +++ b/src/Mvc/Model/Resultset/Complex.php @@ -9,7 +9,9 @@ */ namespace Phalcon\Mvc\Model\Resultset; +use Phalcon\Db\ResultInterface; use Phalcon\Mvc\Model\Resultset; +use Psr\SimpleCache\CacheInterface; /** * Phalcon\Mvc\Model\Resultset\Complex @@ -19,12 +21,16 @@ */ class Complex extends Resultset implements \Phalcon\Mvc\Model\ResultsetInterface { - + /** + * @var array + */ protected $columnTypes; /** * Unserialised result-set hydrated all rows already. unserialise() sets * disableHydration to true + * + * @var bool */ protected $disableHydration = false; @@ -33,17 +39,17 @@ class Complex extends Resultset implements \Phalcon\Mvc\Model\ResultsetInterface * Phalcon\Mvc\Model\Resultset\Complex constructor * * @param array $columnTypes - * @param \Phalcon\Db\ResultInterface $result - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @param ResultInterface|null $result + * @param CacheInterface|null $cache */ - public function __construct($columnTypes, \Phalcon\Db\ResultInterface $result = null, \Phalcon\Cache\Adapter\AdapterInterface $cache = null) + public function __construct($columnTypes, \Phalcon\Db\ResultInterface $result = null, \Psr\SimpleCache\CacheInterface $cache = null) { } /** * Returns current row in the resultset * - * @return bool|\Phalcon\Mvc\ModelInterface + * @return 0|ModelInterface */ final public function current() { @@ -74,7 +80,7 @@ public function serialize(): string * @param mixed $data * @return void */ - public function unserialize($data) + public function unserialize($data): void { } } diff --git a/src/Phalcon/Mvc/Model/Resultset/Simple.php b/src/Mvc/Model/Resultset/Simple.php similarity index 75% rename from src/Phalcon/Mvc/Model/Resultset/Simple.php rename to src/Mvc/Model/Resultset/Simple.php index 68eb43c9..9344cba7 100644 --- a/src/Phalcon/Mvc/Model/Resultset/Simple.php +++ b/src/Mvc/Model/Resultset/Simple.php @@ -10,7 +10,9 @@ namespace Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\Resultset; +use Phalcon\Mvc\Model\Row; use Phalcon\Mvc\ModelInterface; +use Psr\SimpleCache\CacheInterface; /** * Phalcon\Mvc\Model\Resultset\Simple @@ -20,10 +22,14 @@ */ class Simple extends Resultset { - + /** + * @var array|string + */ protected $columnMap; - + /** + * @var ModelInterface|Row + */ protected $model; /** @@ -36,19 +42,19 @@ class Simple extends Resultset * Phalcon\Mvc\Model\Resultset\Simple constructor * * @param array $columnMap - * @param \Phalcon\Mvc\ModelInterface|Phalcon\Mvc\Model\Row $model - * @param mixed $result - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache - * @param bool $keepSnapshots + * @param ModelInterface|Row $model + * @param \Phalcon\Db\ResultInterface|false $result + * @param CacheInterface|null $cache + * @param bool $keepSnapshots false */ - public function __construct($columnMap, $model, $result, \Phalcon\Cache\Adapter\AdapterInterface $cache = null, bool $keepSnapshots = null) + public function __construct($columnMap, $model, $result, \Psr\SimpleCache\CacheInterface $cache = null, bool $keepSnapshots = false) { } /** * Returns current row in the resultset * - * @return \Phalcon\Mvc\ModelInterface|null + * @return ModelInterface|null */ final public function current(): ?ModelInterface { @@ -83,7 +89,7 @@ public function serialize(): string * @param mixed $data * @return void */ - public function unserialize($data) + public function unserialize($data): void { } } diff --git a/src/Phalcon/Mvc/Model/ResultsetInterface.php b/src/Mvc/Model/ResultsetInterface.php similarity index 94% rename from src/Phalcon/Mvc/Model/ResultsetInterface.php rename to src/Mvc/Model/ResultsetInterface.php index 6c2fcdd2..1ec61669 100644 --- a/src/Phalcon/Mvc/Model/ResultsetInterface.php +++ b/src/Mvc/Model/ResultsetInterface.php @@ -9,8 +9,8 @@ */ namespace Phalcon\Mvc\Model; -use Phalcon\Cache\Adapter\AdapterInterface; use Phalcon\Mvc\ModelInterface; +use Psr\SimpleCache\CacheInterface; /** * Phalcon\Mvc\Model\ResultsetInterface @@ -49,9 +49,9 @@ public function filter($filter): array; /** * Returns the associated cache for the resultset * - * @return AdapterInterface + * @return CacheInterface|null */ - public function getCache(): AdapterInterface; + public function getCache(): ?CacheInterface; /** * Get first row in the resultset @@ -70,7 +70,7 @@ public function getHydrateMode(): int; /** * Get last row in the resultset * - * @return \Phalcon\Mvc\ModelInterface|null + * @return ModelInterface|null */ public function getLast(): ?ModelInterface; diff --git a/src/Phalcon/Mvc/Model/Row.php b/src/Mvc/Model/Row.php similarity index 88% rename from src/Phalcon/Mvc/Model/Row.php rename to src/Mvc/Model/Row.php index 65d1cff6..a6ec34c3 100644 --- a/src/Phalcon/Mvc/Model/Row.php +++ b/src/Mvc/Model/Row.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\Row * @@ -31,7 +33,7 @@ public function jsonSerialize(): array * Gets a record in a specific position of the row * * @param string|int $index * - * @return string|Phalcon\Mvc\ModelInterface + * @return string|ModelInterface */ public function offsetGet($index) { @@ -51,10 +53,10 @@ public function offsetExists($index): bool * Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * * @param string|int $index - * @param \Phalcon\Mvc\ModelInterface $value + * @param ModelInterface $value * @return void */ - public function offsetSet($index, $value) + public function offsetSet($index, $value): void { } @@ -64,7 +66,7 @@ public function offsetSet($index, $value) * @param string|int $offset * @return void */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { } @@ -86,7 +88,7 @@ public function readAttribute(string $attribute) * Set the current object's state * * @param int $dirtyState - * @return bool|\Phalcon\Mvc\ModelInterface + * @return bool|ModelInterface */ public function setDirtyState(int $dirtyState) { @@ -112,7 +114,7 @@ public function toArray(): array * @param string $attribute * @return void */ - public function writeAttribute(string $attribute, $value) + public function writeAttribute(string $attribute, $value): void { } } diff --git a/src/Phalcon/Mvc/Model/Transaction.php b/src/Mvc/Model/Transaction.php similarity index 82% rename from src/Phalcon/Mvc/Model/Transaction.php rename to src/Mvc/Model/Transaction.php index 0ffc5d86..7206cc76 100644 --- a/src/Phalcon/Mvc/Model/Transaction.php +++ b/src/Mvc/Model/Transaction.php @@ -9,6 +9,11 @@ */ namespace Phalcon\Mvc\Model; +use Phalcon\Db\Adapter\AdapterInterface; +use Phalcon\Di\DiInterface; +use Phalcon\Mvc\Model\Transaction\ManagerInterface; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\Transaction * @@ -55,35 +60,51 @@ */ class Transaction implements \Phalcon\Mvc\Model\TransactionInterface { - + /** + * @var bool + */ protected $activeTransaction = false; - + /** + * @var AdapterInterface + */ protected $connection; - + /** + * @var bool + */ protected $isNewTransaction = true; + /** + * @var ManagerInterface|null + */ + protected $manager = null; - protected $manager; - - - protected $messages = array(); - - - protected $rollbackRecord; + /** + * @var array + */ + protected $messages = []; + /** + * @var ModelInterface|null + */ + protected $rollbackRecord = null; + /** + * @var bool + */ protected $rollbackOnAbort = false; - + /** + * @var bool + */ protected $rollbackThrowException = false; /** * Phalcon\Mvc\Model\Transaction constructor * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @param bool $autoBegin * @param string $service */ @@ -112,9 +133,9 @@ public function commit(): bool /** * Returns the connection related to transaction * - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ - public function getConnection(): \Phalcon\Db\Adapter\AdapterInterface + public function getConnection(): AdapterInterface { } @@ -162,7 +183,7 @@ public function rollback(string $rollbackMessage = null, \Phalcon\Mvc\ModelInter * @param bool $isNew * @return void */ - public function setIsNewTransaction(bool $isNew) + public function setIsNewTransaction(bool $isNew): void { } @@ -172,7 +193,7 @@ public function setIsNewTransaction(bool $isNew) * @param bool $rollbackOnAbort * @return void */ - public function setRollbackOnAbort(bool $rollbackOnAbort) + public function setRollbackOnAbort(bool $rollbackOnAbort): void { } @@ -182,7 +203,7 @@ public function setRollbackOnAbort(bool $rollbackOnAbort) * @param \Phalcon\Mvc\ModelInterface $record * @return void */ - public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record) + public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record): void { } @@ -192,7 +213,7 @@ public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record) * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager * @return void */ - public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager) + public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager): void { } diff --git a/src/Phalcon/Mvc/Model/Transaction/Exception.php b/src/Mvc/Model/Transaction/Exception.php similarity index 100% rename from src/Phalcon/Mvc/Model/Transaction/Exception.php rename to src/Mvc/Model/Transaction/Exception.php diff --git a/src/Phalcon/Mvc/Model/Transaction/Failed.php b/src/Mvc/Model/Transaction/Failed.php similarity index 86% rename from src/Phalcon/Mvc/Model/Transaction/Failed.php rename to src/Mvc/Model/Transaction/Failed.php index 0c0ec856..88f5c1c6 100644 --- a/src/Phalcon/Mvc/Model/Transaction/Failed.php +++ b/src/Mvc/Model/Transaction/Failed.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Mvc\Model\Transaction; +use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\ModelInterface; /** @@ -18,7 +19,9 @@ */ class Failed extends \Phalcon\Mvc\Model\Transaction\Exception { - + /** + * @var ModelInterface|null + */ protected $record = null; @@ -26,7 +29,7 @@ class Failed extends \Phalcon\Mvc\Model\Transaction\Exception * Phalcon\Mvc\Model\Transaction\Failed constructor * * @param string $message - * @param \Phalcon\Mvc\ModelInterface $record + * @param ModelInterface|null $record */ public function __construct(string $message, \Phalcon\Mvc\ModelInterface $record = null) { @@ -44,7 +47,7 @@ public function getRecord(): ModelInterface /** * Returns validation record messages which stop the transaction * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return MessageInterface[] */ public function getRecordMessages(): array { diff --git a/src/Phalcon/Mvc/Model/Transaction/Manager.php b/src/Mvc/Model/Transaction/Manager.php similarity index 85% rename from src/Phalcon/Mvc/Model/Transaction/Manager.php rename to src/Mvc/Model/Transaction/Manager.php index 28fd6173..b98801a4 100644 --- a/src/Phalcon/Mvc/Model/Transaction/Manager.php +++ b/src/Mvc/Model/Transaction/Manager.php @@ -61,31 +61,41 @@ */ class Manager implements \Phalcon\Mvc\Model\Transaction\ManagerInterface, \Phalcon\Di\InjectionAwareInterface { - + /** + * @var DiInterface|null + */ protected $container; - + /** + * @var bool + */ protected $initialized = false; - + /** + * @var int + */ protected $number = 0; - + /** + * @var bool + */ protected $rollbackPendent = true; - + /** + * @var string + */ protected $service = 'db'; /** * @var array */ - protected $transactions = array(); + protected $transactions = []; /** * Phalcon\Mvc\Model\Transaction\Manager constructor * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface|null $container */ public function __construct(\Phalcon\Di\DiInterface $container = null) { @@ -96,7 +106,7 @@ public function __construct(\Phalcon\Di\DiInterface $container = null) * * @return void */ - public function collectTransactions() + public function collectTransactions(): void { } @@ -111,7 +121,7 @@ public function commit() * Returns a new \Phalcon\Mvc\Model\Transaction or an already created once * This method registers a shutdown function to rollback active connections * - * @param bool $autoBegin + * @param bool $autoBegin * * @return TransactionInterface */ public function get(bool $autoBegin = true): TransactionInterface @@ -139,7 +149,7 @@ public function getDI(): DiInterface /** * Create/Returns a new transaction or an existing one * - * @param bool $autoBegin + * @param bool $autoBegin * * @return TransactionInterface */ public function getOrCreateTransaction(bool $autoBegin = true): TransactionInterface @@ -168,20 +178,20 @@ public function has(): bool /** * Notifies the manager about a committed transaction * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param TransactionInterface $transaction * @return void */ - public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction) + public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction): void { } /** * Notifies the manager about a rollbacked transaction * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param TransactionInterface $transaction * @return void */ - public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction) + public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction): void { } @@ -192,7 +202,7 @@ public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transact * @param bool $collect * @return void */ - public function rollback(bool $collect = true) + public function rollback(bool $collect = true): void { } @@ -201,7 +211,7 @@ public function rollback(bool $collect = true) * * @return void */ - public function rollbackPendent() + public function rollbackPendent(): void { } @@ -218,10 +228,10 @@ public function setDbService(string $service): ManagerInterface /** * Sets the dependency injection container * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(\Phalcon\Di\DiInterface $container): void { } @@ -239,10 +249,10 @@ public function setRollbackPendent(bool $rollbackPendent): ManagerInterface /** * Removes transactions from the TransactionManager * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param TransactionInterface $transaction * @return void */ - protected function collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) + protected function collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): void { } } diff --git a/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php b/src/Mvc/Model/Transaction/ManagerInterface.php similarity index 92% rename from src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php rename to src/Mvc/Model/Transaction/ManagerInterface.php index d2acfa22..ba56e79d 100644 --- a/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php +++ b/src/Mvc/Model/Transaction/ManagerInterface.php @@ -24,7 +24,7 @@ interface ManagerInterface * * @return void */ - public function collectTransactions(); + public function collectTransactions(): void; /** * Commits active transactions within the manager @@ -66,7 +66,7 @@ public function has(): bool; * @param \Phalcon\Mvc\Model\TransactionInterface $transaction * @return void */ - public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction); + public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction): void; /** * Notifies the manager about a rollbacked transaction @@ -74,7 +74,7 @@ public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transactio * @param \Phalcon\Mvc\Model\TransactionInterface $transaction * @return void */ - public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction); + public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction): void; /** * Rollbacks active transactions within the manager @@ -83,14 +83,14 @@ public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transact * @param bool $collect * @return void */ - public function rollback(bool $collect = false); + public function rollback(bool $collect = false): void; /** * Rollbacks active transactions within the manager * * @return void */ - public function rollbackPendent(); + public function rollbackPendent(): void; /** * Sets the database service used to run the isolated transactions diff --git a/src/Phalcon/Mvc/Model/TransactionInterface.php b/src/Mvc/Model/TransactionInterface.php similarity index 92% rename from src/Phalcon/Mvc/Model/TransactionInterface.php rename to src/Mvc/Model/TransactionInterface.php index 99dba3e3..19b23ad9 100644 --- a/src/Phalcon/Mvc/Model/TransactionInterface.php +++ b/src/Mvc/Model/TransactionInterface.php @@ -74,7 +74,7 @@ public function rollback(string $rollbackMessage = null, \Phalcon\Mvc\ModelInter * @param bool $isNew * @return void */ - public function setIsNewTransaction(bool $isNew); + public function setIsNewTransaction(bool $isNew): void; /** * Sets flag to rollback on abort the HTTP connection @@ -82,7 +82,7 @@ public function setIsNewTransaction(bool $isNew); * @param bool $rollbackOnAbort * @return void */ - public function setRollbackOnAbort(bool $rollbackOnAbort); + public function setRollbackOnAbort(bool $rollbackOnAbort): void; /** * Sets object which generates rollback action @@ -90,7 +90,7 @@ public function setRollbackOnAbort(bool $rollbackOnAbort); * @param \Phalcon\Mvc\ModelInterface $record * @return void */ - public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record); + public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record): void; /** * Sets transaction manager related to the transaction @@ -98,7 +98,7 @@ public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record); * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager * @return void */ - public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager); + public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager): void; /** * Enables throwing exception diff --git a/src/Phalcon/Mvc/Model/ValidationFailed.php b/src/Mvc/Model/ValidationFailed.php similarity index 79% rename from src/Phalcon/Mvc/Model/ValidationFailed.php rename to src/Mvc/Model/ValidationFailed.php index 11a3dba9..a4562f9b 100644 --- a/src/Phalcon/Mvc/Model/ValidationFailed.php +++ b/src/Mvc/Model/ValidationFailed.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Mvc\Model; +use Phalcon\Messages\Message; use Phalcon\Mvc\ModelInterface; /** @@ -19,20 +20,22 @@ */ class ValidationFailed extends \Phalcon\Mvc\Model\Exception { + /** + * @var array + */ + protected $messages = []; - protected $messages = array(); - - + /** + * @var ModelInterface + */ protected $model; /** * Phalcon\Mvc\Model\ValidationFailed constructor * - * @param Message[] validationMessages - * @param \Phalcon\Mvc\ModelInterface $model - * @param array $validationMessages - * @param Message [] validationMessages + * @param ModelInterface $model + * @param Message[] $validationMessages */ public function __construct(\Phalcon\Mvc\ModelInterface $model, array $validationMessages) { @@ -41,7 +44,7 @@ public function __construct(\Phalcon\Mvc\ModelInterface $model, array $validatio /** * Returns the complete group of messages produced in the validation * - * @return array|Message[] + * @return array|\Phalcon\Messages\Message[] */ public function getMessages(): array { diff --git a/src/Phalcon/Mvc/ModelInterface.php b/src/Mvc/ModelInterface.php similarity index 88% rename from src/Phalcon/Mvc/ModelInterface.php rename to src/Mvc/ModelInterface.php index 390a2a97..50b25337 100644 --- a/src/Phalcon/Mvc/ModelInterface.php +++ b/src/Mvc/ModelInterface.php @@ -33,10 +33,10 @@ public function appendMessage(\Phalcon\Messages\MessageInterface $message): Mode /** * Assigns values to a model from an array * - * @param array $columnMap * @param array $data * @param mixed $whiteList - * @param mixed $dataColumnMap + * @param mixed $dataColumnMap Array to transform keys of data to another + * * @return ModelInterface */ public function assign(array $data, $whiteList = null, $dataColumnMap = null): ModelInterface; @@ -46,9 +46,9 @@ public function assign(array $data, $whiteList = null, $dataColumnMap = null): M * conditions * * @param array $parameters - * @return double | ResultsetInterface + * @return ResultsetInterface|float */ - public static function average($parameters = null); + public static function average(array $parameters = []); /** * Assigns values to a model from an array returning a new model @@ -63,14 +63,14 @@ public static function cloneResult(ModelInterface $base, array $data, int $dirty /** * Assigns values to a model from an array returning a new model * - * @param \Phalcon\Mvc\Model $base - * @param array $columnMap - * @return \Phalcon\Mvc\Model result - * @param array $data + * @param ModelInterface|\Phalcon\Mvc\Model\Row $base + * @param mixed $columnMap * @param int $dirtyState - * @param bool $keepSnapshots + * @param bool $keepSnapshots * + * @return ModelInterface + * @param array $data */ - public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface; + public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = false): ModelInterface; /** * Returns an hydrated result based on the data and the column map @@ -88,8 +88,8 @@ public static function cloneResultMapHydrate(array $data, $columnMap, int $hydra * instance for when the GROUP condition is used. The results will * contain the count of each group. * - * @param array $parameters - * @return int|\Phalcon\Mvc\Model\ResultsetInterface + * @param array|string|null $parameters + * @return 0|ResultsetInterface */ public static function count($parameters = null); @@ -112,7 +112,7 @@ public function delete(): bool; /** * Allows to query a set of records that match the specified conditions * - * @param mixed $parameters + * @param array|string|int|null $parameters * * @return ResultsetInterface */ public static function find($parameters = null): ResultsetInterface; @@ -121,9 +121,12 @@ public static function find($parameters = null): ResultsetInterface; * Allows to query the first record that match the specified conditions * * @param array $parameters - * @return ModelInterface|null + * @return \Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row|null + * + * TODO: Current method signature must be reviewed in v5. As it must return only ?ModelInterface. + * @see https://github.com/phalcon/cphalcon/issues/15212 */ - public static function findFirst($parameters = null): ?ModelInterface; + public static function findFirst($parameters = null); /** * Fires an event, implicitly calls behaviors and listeners in the events @@ -191,18 +194,18 @@ public function getReadConnectionService(): string; /** * Returns related records based on defined relations * - * @param array $arguments - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false * @param string $alias + * @param array $arguments + * @return \Phalcon\Mvc\Model\Resultset\Simple|false */ public function getRelated(string $alias, $arguments = null); /** * Returns schema name where table mapped is located * - * @return string + * @return string|null */ - public function getSchema(): string; + public function getSchema(): ?string; /** * Returns table name mapped in the model @@ -272,7 +275,7 @@ public function save(): bool; * @param string $connectionService * @return void */ - public function setConnectionService(string $connectionService); + public function setConnectionService(string $connectionService): void; /** * Sets the dirty state of the object using one of the DIRTY_STATE_ @@ -289,7 +292,7 @@ public function setDirtyState(int $dirtyState); * @param string $connectionService * @return void */ - public function setReadConnectionService(string $connectionService); + public function setReadConnectionService(string $connectionService): void; /** * Sets the record's snapshot data. This method is used internally to set @@ -299,7 +302,7 @@ public function setReadConnectionService(string $connectionService); * @param array $data * @return void */ - public function setSnapshotData(array $data, $columnMap = null); + public function setSnapshotData(array $data, $columnMap = null): void; /** * Sets a transaction related to the Model instance @@ -315,7 +318,7 @@ public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transact * @param string $connectionService * @return void */ - public function setWriteConnectionService(string $connectionService); + public function setWriteConnectionService(string $connectionService): void; /** * Skips the current operation forcing a success state @@ -323,13 +326,13 @@ public function setWriteConnectionService(string $connectionService); * @param bool $skip * @return void */ - public function skipOperation(bool $skip); + public function skipOperation(bool $skip): void; /** * Allows to calculate a sum on a column that match the specified conditions * * @param array $parameters - * @return double | ResultsetInterface + * @return float|ResultsetInterface */ public static function sum($parameters = null); diff --git a/src/Phalcon/Mvc/ModuleDefinitionInterface.php b/src/Mvc/ModuleDefinitionInterface.php similarity index 100% rename from src/Phalcon/Mvc/ModuleDefinitionInterface.php rename to src/Mvc/ModuleDefinitionInterface.php diff --git a/src/Phalcon/Mvc/Router.php b/src/Mvc/Router.php similarity index 70% rename from src/Phalcon/Mvc/Router.php rename to src/Mvc/Router.php index 8a28c7ae..e49eb958 100644 --- a/src/Phalcon/Mvc/Router.php +++ b/src/Mvc/Router.php @@ -11,6 +11,7 @@ use Phalcon\Di\AbstractInjectionAware; use Phalcon\Events\ManagerInterface; +use Phalcon\Mvc\Router\GroupInterface; use Phalcon\Mvc\Router\RouteInterface; /** @@ -49,85 +50,127 @@ class Router extends AbstractInjectionAware implements \Phalcon\Mvc\RouterInterf const POSITION_LAST = 1; - + /** + * @var string|null + */ protected $action = null; - + /** + * @var string|null + */ protected $controller = null; + /** + * @var string|null + */ + protected $defaultAction = null; - protected $defaultAction; - - - protected $defaultController; - - - protected $defaultModule; - - - protected $defaultNamespace; + /** + * @var string|null + */ + protected $defaultController = null; + /** + * @var string|null + */ + protected $defaultModule = null; - protected $defaultParams = array(); + /** + * @var string|null + */ + protected $defaultNamespace = null; + /** + * @var array + */ + protected $defaultParams = []; + /** + * @var ManagerInterface|null + */ protected $eventsManager; + /** + * @var array + */ + protected $keyRouteNames = []; - protected $keyRouteNames = array(); - - - protected $keyRouteIds = array(); - - - protected $matchedRoute; - + /** + * @var array + */ + protected $keyRouteIds = []; - protected $matches; + /** + * @var RouteInterface|null + */ + protected $matchedRoute = null; + /** + * @var array + */ + protected $matches = []; + /** + * @var string|null + */ protected $module = null; - + /** + * @var string|null + */ protected $namespaceName = null; + /** + * @var array|string|null + */ + protected $notFoundPaths = null; - protected $notFoundPaths; - - - protected $params = array(); - - - protected $removeExtraSlashes; - + /** + * @var array + */ + protected $params = []; - protected $routes; + /** + * @var bool + */ + protected $removeExtraSlashes = false; + /** + * @var array + */ + protected $routes = []; + /** + * @var bool + */ protected $wasMatched = false; - - public function getKeyRouteNames() + /** + * @return array + */ + public function getKeyRouteNames(): array { } /** - * @param mixed $keyRouteNames + * @param array $keyRouteNames */ - public function setKeyRouteNames($keyRouteNames) + public function setKeyRouteNames(array $keyRouteNames) { } - - public function getKeyRouteIds() + /** + * @return array + */ + public function getKeyRouteIds(): array { } /** - * @param mixed $keyRouteIds + * @param array $keyRouteIds */ - public function setKeyRouteIds($keyRouteIds) + public function setKeyRouteIds(array $keyRouteIds) { } @@ -162,137 +205,139 @@ public function __construct(bool $defaultRoutes = true) * ); * ``` * - * @param string|array $paths = [ + * @param string $pattern + * @param string|array|null $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern - * @param mixed $httpMethods - * @param mixed $position + * @param string|array|null $httpMethods + * @param int $position * * @return RouteInterface */ - public function add(string $pattern, $paths = null, $httpMethods = null, $position = Router::POSITION_LAST): RouteInterface + public function add(string $pattern, $paths = null, $httpMethods = null, int $position = Router::POSITION_LAST): RouteInterface { } /** * Adds a route to the router that only match if the HTTP method is CONNECT * - * @param string|array $paths = [ + * @param string $pattern + * @param string|array|null $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern - * @param mixed $position + * @param int $position * * @return RouteInterface */ - public function addConnect(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + public function addConnect(string $pattern, $paths = null, int $position = Router::POSITION_LAST): RouteInterface { } /** * Adds a route to the router that only match if the HTTP method is DELETE * - * @param string|array $paths = [ + * @param string $param + * @param string|array|null $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern - * @param mixed $position + * @param int $position * * @return RouteInterface + * @param string $pattern */ - public function addDelete(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + public function addDelete(string $pattern, $paths = null, int $position = Router::POSITION_LAST): RouteInterface { } /** * Adds a route to the router that only match if the HTTP method is GET * - * @param string|array $paths = [ + * @param string $param + * @param string|array|null $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern - * @param mixed $position + * @param int $position * * @return RouteInterface + * @param string $pattern */ - public function addGet(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + public function addGet(string $pattern, $paths = null, int $position = Router::POSITION_LAST): RouteInterface { } /** * Adds a route to the router that only match if the HTTP method is HEAD * - * @param string|array $paths = [ + * @param string $pattern + * @param string|array|null $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern - * @param mixed $position + * @param int $position * * @return RouteInterface */ - public function addHead(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + public function addHead(string $pattern, $paths = null, int $position = Router::POSITION_LAST): RouteInterface { } /** * Add a route to the router that only match if the HTTP method is OPTIONS * - * @param string|array $paths = [ + * @param string $pattern + * @param string|array|null $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern - * @param mixed $position + * @param int $position * * @return RouteInterface */ - public function addOptions(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + public function addOptions(string $pattern, $paths = null, int $position = Router::POSITION_LAST): RouteInterface { } /** * Adds a route to the router that only match if the HTTP method is PATCH * - * @param string|array $paths = [ + * @param string $pattern + * @param string|array|null $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern - * @param mixed $position + * @param int $position * * @return RouteInterface */ - public function addPatch(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + public function addPatch(string $pattern, $paths = null, int $position = Router::POSITION_LAST): RouteInterface { } /** * Adds a route to the router that only match if the HTTP method is POST * - * @param string|array $paths = [ + * @param string $pattern + * @param string|array|null $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern - * @param mixed $position + * @param int $position * * @return RouteInterface */ - public function addPost(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + public function addPost(string $pattern, $paths = null, int $position = Router::POSITION_LAST): RouteInterface { } @@ -300,51 +345,51 @@ public function addPost(string $pattern, $paths = null, $position = Router::POSI * Adds a route to the router that only match if the HTTP method is PURGE * (Squid and Varnish support) * - * @param string|array $paths = [ + * @param string $pattern + * @param string|array|null $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern - * @param mixed $position + * @param int $position * * @return RouteInterface */ - public function addPurge(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + public function addPurge(string $pattern, $paths = null, int $position = Router::POSITION_LAST): RouteInterface { } /** * Adds a route to the router that only match if the HTTP method is PUT * + * @param string $pattern * @param string|array $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern - * @param mixed $position + * @param int $position * * @return RouteInterface */ - public function addPut(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + public function addPut(string $pattern, $paths = null, int $position = Router::POSITION_LAST): RouteInterface { } /** * Adds a route to the router that only match if the HTTP method is TRACE * - * @param string|array $paths = [ + * @param string $pattern + * @param string|array|null $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern - * @param mixed $position + * @param int $position * * @return RouteInterface */ - public function addTrace(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + public function addTrace(string $pattern, $paths = null, int $position = Router::POSITION_LAST): RouteInterface { } @@ -367,11 +412,11 @@ public function addTrace(string $pattern, $paths = null, $position = Router::POS * ); * ``` * - * @param \Phalcon\Mvc\Router\RouteInterface $route - * @param mixed $position + * @param RouteInterface $route + * @param int $position * * @return RouterInterface */ - public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Router::POSITION_LAST): RouterInterface + public function attach(\Phalcon\Mvc\Router\RouteInterface $route, int $position = Router::POSITION_LAST): RouterInterface { } @@ -380,16 +425,16 @@ public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Ro * * @return void */ - public function clear() + public function clear(): void { } /** * Returns the internal event manager * - * @return ManagerInterface + * @return ManagerInterface|null */ - public function getEventsManager(): ManagerInterface + public function getEventsManager(): ?ManagerInterface { } @@ -459,8 +504,8 @@ public function getParams(): array /** * Returns a route object by its id * - * @param mixed $id - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @param mixed $id * + * @return RouteInterface|bool */ public function getRouteById($id) { @@ -469,8 +514,8 @@ public function getRouteById($id) /** * Returns a route object by its name * - * @param string $name - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @param string $name * + * @return RouteInterface|bool */ public function getRouteByName(string $name) { @@ -479,7 +524,7 @@ public function getRouteByName(string $name) /** * Returns all the routes defined in the router * - * @return array|\Phalcon\Mvc\Router\RouteInterface[] + * @return array */ public function getRoutes(): array { @@ -493,10 +538,10 @@ public function getRoutes(): array * $router->handle("/posts/edit/1"); * ``` * - * @param string $uri + * @param string $uri * * @return void */ - public function handle(string $uri) + public function handle(string $uri): void { } @@ -512,7 +557,7 @@ public function isExactControllerName(): bool /** * Mounts a group of routes in the router * - * @param \Phalcon\Mvc\Router\GroupInterface $group + * @param GroupInterface $group * * @return RouterInterface */ public function mount(\Phalcon\Mvc\Router\GroupInterface $group): RouterInterface @@ -523,7 +568,7 @@ public function mount(\Phalcon\Mvc\Router\GroupInterface $group): RouterInterfac * Set a group of paths to be returned when none of the defined routes are * matched * - * @param mixed $paths + * @param array|string|null $paths * * @return RouterInterface */ public function notFound($paths): RouterInterface @@ -533,7 +578,7 @@ public function notFound($paths): RouterInterface /** * Set whether router must remove the extra slashes in the handled routes * - * @param bool $remove + * @param bool $remove * * @return RouterInterface */ public function removeExtraSlashes(bool $remove): RouterInterface @@ -543,7 +588,7 @@ public function removeExtraSlashes(bool $remove): RouterInterface /** * Sets the default action name * - * @param string $actionName + * @param string $actionName * * @return RouterInterface */ public function setDefaultAction(string $actionName): RouterInterface @@ -553,7 +598,7 @@ public function setDefaultAction(string $actionName): RouterInterface /** * Sets the default controller name * - * @param string $controllerName + * @param string $controllerName * * @return RouterInterface */ public function setDefaultController(string $controllerName): RouterInterface @@ -563,7 +608,7 @@ public function setDefaultController(string $controllerName): RouterInterface /** * Sets the name of the default module * - * @param string $moduleName + * @param string $moduleName * * @return RouterInterface */ public function setDefaultModule(string $moduleName): RouterInterface @@ -573,8 +618,10 @@ public function setDefaultModule(string $moduleName): RouterInterface /** * Sets the name of the default namespace * - * @param string $namespaceName + * @parma string namespaceName + * * @return RouterInterface + * @param string $namespaceName */ public function setDefaultNamespace(string $namespaceName): RouterInterface { @@ -594,7 +641,7 @@ public function setDefaultNamespace(string $namespaceName): RouterInterface * ); * ``` * - * @param array $defaults + * @param array $defaults * * @return RouterInterface */ public function setDefaults(array $defaults): RouterInterface @@ -613,10 +660,10 @@ public function getDefaults(): array /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager * * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): void { } diff --git a/src/Phalcon/Mvc/Router/Annotations.php b/src/Mvc/Router/Annotations.php similarity index 90% rename from src/Phalcon/Mvc/Router/Annotations.php rename to src/Mvc/Router/Annotations.php index fdab5488..d3e39133 100644 --- a/src/Phalcon/Mvc/Router/Annotations.php +++ b/src/Mvc/Router/Annotations.php @@ -35,20 +35,30 @@ */ class Annotations extends Router { - + /** + * @var string + */ protected $actionSuffix = 'Action'; + /** + * @var callable|string|null + */ + protected $actionPreformatCallback = null; - protected $actionPreformatCallback; - - + /** + * @var string + */ protected $controllerSuffix = 'Controller'; + /** + * @var array + */ + protected $handlers = []; - protected $handlers = array(); - - - protected $routePrefix; + /** + * @var string + */ + protected $routePrefix = ''; /** @@ -92,7 +102,7 @@ public function getResources(): array * @param string $uri * @return void */ - public function handle(string $uri) + public function handle(string $uri): void { } @@ -104,8 +114,9 @@ public function handle(string $uri) * @param string $controller * @param string $action * @param \Phalcon\Annotations\Annotation $annotation + * @return void */ - public function processActionAnnotation(string $module, string $namespaceName, string $controller, string $action, \Phalcon\Annotations\Annotation $annotation) + public function processActionAnnotation(string $module, string $namespaceName, string $controller, string $action, \Phalcon\Annotations\Annotation $annotation): void { } diff --git a/src/Phalcon/Mvc/Router/Exception.php b/src/Mvc/Router/Exception.php similarity index 100% rename from src/Phalcon/Mvc/Router/Exception.php rename to src/Mvc/Router/Exception.php diff --git a/src/Phalcon/Mvc/Router/Group.php b/src/Mvc/Router/Group.php similarity index 90% rename from src/Phalcon/Mvc/Router/Group.php rename to src/Mvc/Router/Group.php index f6b9b6d7..81351637 100644 --- a/src/Phalcon/Mvc/Router/Group.php +++ b/src/Mvc/Router/Group.php @@ -59,26 +59,36 @@ */ class Group implements \Phalcon\Mvc\Router\GroupInterface { + /** + * @var callable|null + */ + protected $beforeMatch = null; - protected $beforeMatch; - - - protected $hostname; - - - protected $paths; - + /** + * @var string|null + */ + protected $hostname = null; - protected $prefix; + /** + * @var array|string|null + */ + protected $paths = null; + /** + * @var string|null + */ + protected $prefix = null; - protected $routes = array(); + /** + * @var array + */ + protected $routes = []; /** * Phalcon\Mvc\Router\Group constructor * - * @param mixed $paths + * @param array|string $paths */ public function __construct($paths = null) { @@ -91,15 +101,18 @@ public function __construct($paths = null) * $router->add("/about", "About::index"); * ``` * + * @param string $pattenr * @param string|array $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] + * @param httpMethods $array |string|null + * + * @return RouteInterface * @param string $pattern * @param mixed $httpMethods - * @return RouteInterface */ public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface { @@ -108,13 +121,14 @@ public function add(string $pattern, $paths = null, $httpMethods = null): RouteI /** * Adds a route to the router that only match if the HTTP method is CONNECT * + * @param string $pattern * @param string|array $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern + * * @return RouteInterface */ public function addConnect(string $pattern, $paths = null): RouteInterface @@ -124,13 +138,14 @@ public function addConnect(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is DELETE * + * @param string $pattern * @param string|array $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern + * * @return RouteInterface */ public function addDelete(string $pattern, $paths = null): RouteInterface @@ -140,13 +155,14 @@ public function addDelete(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is GET * + * @param string $pattern * @param string|array $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern + * * @return RouteInterface */ public function addGet(string $pattern, $paths = null): RouteInterface @@ -156,13 +172,14 @@ public function addGet(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is HEAD * + * @param string $pattern * @param string|array $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern + * * @return RouteInterface */ public function addHead(string $pattern, $paths = null): RouteInterface @@ -172,13 +189,14 @@ public function addHead(string $pattern, $paths = null): RouteInterface /** * Add a route to the router that only match if the HTTP method is OPTIONS * + * @param string $pattern * @param string|array $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern + * * @return RouteInterface */ public function addOptions(string $pattern, $paths = null): RouteInterface @@ -188,13 +206,14 @@ public function addOptions(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is PATCH * + * @param string $pattern * @param string|array $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern + * * @return RouteInterface */ public function addPatch(string $pattern, $paths = null): RouteInterface @@ -204,13 +223,14 @@ public function addPatch(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is POST * + * @param string $pattern * @param string|array $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern + * * @return RouteInterface */ public function addPost(string $pattern, $paths = null): RouteInterface @@ -220,13 +240,14 @@ public function addPost(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is PURGE * + * @param string $pattern * @param string|array $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern + * * @return RouteInterface */ public function addPurge(string $pattern, $paths = null): RouteInterface @@ -236,13 +257,14 @@ public function addPurge(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is PUT * + * @param string $pattern * @param string|array $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern + * * @return RouteInterface */ public function addPut(string $pattern, $paths = null): RouteInterface @@ -252,13 +274,14 @@ public function addPut(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is TRACE * + * @param string $pattern * @param string|array $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern + * * @return RouteInterface */ public function addTrace(string $pattern, $paths = null): RouteInterface @@ -270,8 +293,10 @@ public function addTrace(string $pattern, $paths = null): RouteInterface * The developer can implement any arbitrary conditions here * If the callback returns false the route is treated as not matched * - * @param callable $beforeMatch + * @paramm callable beforeMatch + * * @return GroupInterface + * @param callable $beforeMatch */ public function beforeMatch($beforeMatch): GroupInterface { @@ -282,7 +307,7 @@ public function beforeMatch($beforeMatch): GroupInterface * * @return void */ - public function clear() + public function clear(): void { } @@ -334,7 +359,7 @@ public function getRoutes(): array /** * Set a hostname restriction for all the routes in the group * - * @param string $hostname + * @param string $hostname * * @return GroupInterface */ public function setHostname(string $hostname): GroupInterface @@ -344,7 +369,7 @@ public function setHostname(string $hostname): GroupInterface /** * Set common paths for all the routes in the group * - * @param mixed $paths + * @param array|string $paths * * @return GroupInterface */ public function setPaths($paths): GroupInterface @@ -354,7 +379,7 @@ public function setPaths($paths): GroupInterface /** * Set a common uri prefix for all the routes in this group * - * @param string $prefix + * @param string $prefix * * @return GroupInterface */ public function setPrefix(string $prefix): GroupInterface @@ -364,14 +389,14 @@ public function setPrefix(string $prefix): GroupInterface /** * Adds a route applying the common attributes * - * @param string|array $paths = [ + * @param string $pattern + * @param string|array|null $paths = [ * 'module => '', * 'controller' => '', * 'action' => '', * 'namespace' => '' * ] - * @param string $pattern - * @param mixed $httpMethods + * @param array|string|null $httpMethods * * @return RouteInterface */ protected function addRoute(string $pattern, $paths = null, $httpMethods = null): RouteInterface diff --git a/src/Phalcon/Mvc/Router/GroupInterface.php b/src/Mvc/Router/GroupInterface.php similarity index 91% rename from src/Phalcon/Mvc/Router/GroupInterface.php rename to src/Mvc/Router/GroupInterface.php index 2ed4c526..3c780175 100644 --- a/src/Phalcon/Mvc/Router/GroupInterface.php +++ b/src/Mvc/Router/GroupInterface.php @@ -66,8 +66,8 @@ interface GroupInterface * ``` * * @param string $pattern - * @param mixed $paths - * @param mixed $httpMethods + * @param array|string|null $paths + * @param array|string|null $httpMethods * * @return RouteInterface */ public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface; @@ -76,7 +76,7 @@ public function add(string $pattern, $paths = null, $httpMethods = null): RouteI * Adds a route to the router that only match if the HTTP method is CONNECT * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addConnect(string $pattern, $paths = null): RouteInterface; @@ -85,7 +85,7 @@ public function addConnect(string $pattern, $paths = null): RouteInterface; * Adds a route to the router that only match if the HTTP method is DELETE * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addDelete(string $pattern, $paths = null): RouteInterface; @@ -94,7 +94,7 @@ public function addDelete(string $pattern, $paths = null): RouteInterface; * Adds a route to the router that only match if the HTTP method is GET * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addGet(string $pattern, $paths = null): RouteInterface; @@ -103,7 +103,7 @@ public function addGet(string $pattern, $paths = null): RouteInterface; * Adds a route to the router that only match if the HTTP method is HEAD * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addHead(string $pattern, $paths = null): RouteInterface; @@ -112,7 +112,7 @@ public function addHead(string $pattern, $paths = null): RouteInterface; * Add a route to the router that only match if the HTTP method is OPTIONS * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addOptions(string $pattern, $paths = null): RouteInterface; @@ -121,7 +121,7 @@ public function addOptions(string $pattern, $paths = null): RouteInterface; * Adds a route to the router that only match if the HTTP method is PATCH * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addPatch(string $pattern, $paths = null): RouteInterface; @@ -130,7 +130,7 @@ public function addPatch(string $pattern, $paths = null): RouteInterface; * Adds a route to the router that only match if the HTTP method is POST * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addPost(string $pattern, $paths = null): RouteInterface; @@ -139,7 +139,7 @@ public function addPost(string $pattern, $paths = null): RouteInterface; * Adds a route to the router that only match if the HTTP method is PURGE * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addPurge(string $pattern, $paths = null): RouteInterface; @@ -148,7 +148,7 @@ public function addPurge(string $pattern, $paths = null): RouteInterface; * Adds a route to the router that only match if the HTTP method is PUT * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addPut(string $pattern, $paths = null): RouteInterface; @@ -157,7 +157,7 @@ public function addPut(string $pattern, $paths = null): RouteInterface; * Adds a route to the router that only match if the HTTP method is TRACE * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addTrace(string $pattern, $paths = null): RouteInterface; @@ -177,7 +177,7 @@ public function beforeMatch($beforeMatch): GroupInterface; * * @return void */ - public function clear(); + public function clear(): void; /** * Returns the 'before match' callback if any diff --git a/src/Phalcon/Mvc/Router/Route.php b/src/Mvc/Router/Route.php similarity index 86% rename from src/Phalcon/Mvc/Router/Route.php rename to src/Mvc/Router/Route.php index 287f343a..91654de4 100644 --- a/src/Phalcon/Mvc/Router/Route.php +++ b/src/Mvc/Router/Route.php @@ -16,45 +16,71 @@ */ class Route implements \Phalcon\Mvc\Router\RouteInterface { + /** + * @var callable|null + */ + protected $beforeMatch = null; - protected $beforeMatch; - - - protected $compiledPattern; - - - protected $converters; - - - protected $group; - - - protected $hostname; - - - protected $id; - + /** + * @var string|null + */ + protected $compiledPattern = null; - protected $methods; + /** + * @var array + */ + protected $converters = []; + /** + * @var GroupInterface|null + */ + protected $group = null; - protected $match; + /** + * @var string|null + */ + protected $hostname = null; + /** + * @var string|null + */ + protected $id = null; - protected $name; + /** + * @var array|string + */ + protected $methods = []; + /** + * @var callable|null + */ + protected $match = null; - protected $paths; + /** + * @var string|null + */ + protected $name = null; + /** + * @var array + */ + protected $paths = []; + /** + * @var string + */ protected $pattern; - + /** + * @var int + */ protected static $uniqueId = 0; - - public function getId() + /** + * @return string|null + */ + public function getId(): ?string { } @@ -93,7 +119,7 @@ public function __construct(string $pattern, $paths = null, $httpMethods = null) * ); * ``` * - * @param mixed $callback + * @param callable $callback * @return RouteInterface */ public function beforeMatch($callback): RouteInterface @@ -277,7 +303,7 @@ public function match($callback): RouteInterface * @param mixed $paths * @return void */ - public function reConfigure(string $pattern, $paths = null) + public function reConfigure(string $pattern, $paths = null): void { } @@ -286,7 +312,7 @@ public function reConfigure(string $pattern, $paths = null) * * @return void */ - public static function reset() + public static function reset(): void { } diff --git a/src/Phalcon/Mvc/Router/RouteInterface.php b/src/Mvc/Router/RouteInterface.php similarity index 96% rename from src/Phalcon/Mvc/Router/RouteInterface.php rename to src/Mvc/Router/RouteInterface.php index 830cf72e..5f3759ce 100644 --- a/src/Phalcon/Mvc/Router/RouteInterface.php +++ b/src/Mvc/Router/RouteInterface.php @@ -121,14 +121,14 @@ public function setName(string $name): RouteInterface; * @param mixed $paths * @return void */ - public function reConfigure(string $pattern, $paths = null); + public function reConfigure(string $pattern, $paths = null): void; /** * Resets the internal route id generator * * @return void */ - public static function reset(); + public static function reset(): void; /** * Set one or more HTTP methods that constraint the matching of the route diff --git a/src/Phalcon/Mvc/RouterInterface.php b/src/Mvc/RouterInterface.php similarity index 88% rename from src/Phalcon/Mvc/RouterInterface.php rename to src/Mvc/RouterInterface.php index 336dd512..938590c4 100644 --- a/src/Phalcon/Mvc/RouterInterface.php +++ b/src/Mvc/RouterInterface.php @@ -21,8 +21,8 @@ interface RouterInterface * Adds a route to the router on any HTTP method * * @param string $pattern - * @param mixed $paths - * @param mixed $httpMethods + * @param array|string|null $paths + * @param array|string|null $httpMethods * * @return RouteInterface */ public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface; @@ -30,17 +30,17 @@ public function add(string $pattern, $paths = null, $httpMethods = null): RouteI /** * Attach Route object to the routes stack. * - * @param \Phalcon\Mvc\Router\RouteInterface $route - * @param mixed $position + * @param RouteInterface $route + * @param int $position * * @return RouterInterface */ - public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Router::POSITION_LAST): RouterInterface; + public function attach(\Phalcon\Mvc\Router\RouteInterface $route, int $position = Router::POSITION_LAST): RouterInterface; /** * Adds a route to the router that only match if the HTTP method is CONNECT * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addConnect(string $pattern, $paths = null): RouteInterface; @@ -49,7 +49,7 @@ public function addConnect(string $pattern, $paths = null): RouteInterface; * Adds a route to the router that only match if the HTTP method is DELETE * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addDelete(string $pattern, $paths = null): RouteInterface; @@ -58,7 +58,7 @@ public function addDelete(string $pattern, $paths = null): RouteInterface; * Adds a route to the router that only match if the HTTP method is HEAD * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addHead(string $pattern, $paths = null): RouteInterface; @@ -67,7 +67,7 @@ public function addHead(string $pattern, $paths = null): RouteInterface; * Adds a route to the router that only match if the HTTP method is GET * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addGet(string $pattern, $paths = null): RouteInterface; @@ -76,7 +76,7 @@ public function addGet(string $pattern, $paths = null): RouteInterface; * Add a route to the router that only match if the HTTP method is OPTIONS * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addOptions(string $pattern, $paths = null): RouteInterface; @@ -85,7 +85,7 @@ public function addOptions(string $pattern, $paths = null): RouteInterface; * Adds a route to the router that only match if the HTTP method is PATCH * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addPatch(string $pattern, $paths = null): RouteInterface; @@ -94,7 +94,7 @@ public function addPatch(string $pattern, $paths = null): RouteInterface; * Adds a route to the router that only match if the HTTP method is POST * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addPost(string $pattern, $paths = null): RouteInterface; @@ -104,7 +104,7 @@ public function addPost(string $pattern, $paths = null): RouteInterface; * (Squid and Varnish support) * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addPurge(string $pattern, $paths = null): RouteInterface; @@ -113,7 +113,7 @@ public function addPurge(string $pattern, $paths = null): RouteInterface; * Adds a route to the router that only match if the HTTP method is PUT * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addPut(string $pattern, $paths = null): RouteInterface; @@ -122,7 +122,7 @@ public function addPut(string $pattern, $paths = null): RouteInterface; * Adds a route to the router that only match if the HTTP method is TRACE * * @param string $pattern - * @param mixed $paths + * @param array|string|null $paths * * @return RouteInterface */ public function addTrace(string $pattern, $paths = null): RouteInterface; @@ -132,7 +132,7 @@ public function addTrace(string $pattern, $paths = null): RouteInterface; * * @return void */ - public function clear(); + public function clear(): void; /** * Returns processed action name @@ -193,16 +193,16 @@ public function getRoutes(): array; /** * Returns a route object by its id * + * @return RouteInterface|bool * @param mixed $id - * @return bool|\Phalcon\Mvc\Router\RouteInterface */ public function getRouteById($id); /** * Returns a route object by its name * + * @return RouteInterface|bool * @param string $name - * @return bool|\Phalcon\Mvc\Router\RouteInterface */ public function getRouteByName(string $name); @@ -212,7 +212,7 @@ public function getRouteByName(string $name); * @param string $uri * @return void */ - public function handle(string $uri); + public function handle(string $uri): void; /** * Mounts a group of routes in the router diff --git a/src/Phalcon/Mvc/View.php b/src/Mvc/View.php similarity index 90% rename from src/Phalcon/Mvc/View.php rename to src/Mvc/View.php index 01421d6a..35479a5f 100644 --- a/src/Phalcon/Mvc/View.php +++ b/src/Mvc/View.php @@ -70,88 +70,140 @@ class View extends Injectable implements \Phalcon\Mvc\ViewInterface, \Phalcon\Ev */ const LEVEL_AFTER_TEMPLATE = 4; - + /** + * @var string + */ protected $actionName; - + /** + * @var array + */ protected $activeRenderPaths; - + /** + * @var string + */ protected $basePath = ''; - + /** + * @var string + */ protected $content = ''; - + /** + * @var string + */ protected $controllerName; - + /** + * @var int + */ protected $currentRenderLevel = 0; - + /** + * @var bool + */ protected $disabled = false; + /** + * @var array + */ + protected $disabledLevels = []; - protected $disabledLevels; - - + /** + * @var array|bool + */ protected $engines = false; - + /** + * @var ManagerInterface|null + */ protected $eventsManager; + /** + * @var string|null + */ + protected $layout = null; - protected $layout; - - + /** + * @var string + */ protected $layoutsDir = ''; - + /** + * @var string + */ protected $mainView = 'index'; + /** + * @var array + */ + protected $options = []; - protected $options = array(); - - - protected $params; - + /** + * @var array + */ + protected $params = []; + /** + * @var array|null + */ protected $pickView; - + /** + * @var string + */ protected $partialsDir = ''; + /** + * @var array + */ + protected $registeredEngines = []; - protected $registeredEngines = array(); - - + /** + * @var int + */ protected $renderLevel = 5; + /** + * @var array + */ + protected $templatesAfter = []; - protected $templatesAfter = array(); - - - protected $templatesBefore = array(); - - - protected $viewsDirs = array(); - + /** + * @var array + */ + protected $templatesBefore = []; - protected $viewParams = array(); + /** + * @var array + */ + protected $viewsDirs = []; + /** + * @var array + */ + protected $viewParams = []; - public function getCurrentRenderLevel() + /** + * @return int + */ + public function getCurrentRenderLevel(): int { } - - public function getRegisteredEngines() + /** + * @return array + */ + public function getRegisteredEngines(): array { } - - public function getRenderLevel() + /** + * @return int + */ + public function getRenderLevel(): int { } @@ -160,7 +212,7 @@ public function getRenderLevel() * * @param array $options */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } @@ -326,7 +378,7 @@ public function getControllerName(): string /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface|null + * @return ManagerInterface|null */ public function getEventsManager(): ?ManagerInterface { @@ -422,7 +474,7 @@ public function getPartialsDir(): string * @param array $params * @return string */ - public function getRender(string $controllerName, string $actionName, array $params = array(), $configCallback = null): string + public function getRender(string $controllerName, string $actionName, array $params = [], $configCallback = null): string { } @@ -543,9 +595,9 @@ public function registerEngines(array $engines): View * @param string $controllerName * @param string $actionName * @param array $params - * @return bool|View + * @return 0|View */ - public function render(string $controllerName, string $actionName, array $params = array()) + public function render(string $controllerName, string $actionName, array $params = []) { } @@ -593,7 +645,7 @@ public function setContent(string $content): View * @param \Phalcon\Events\ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): void { } @@ -774,7 +826,7 @@ public function start(): View * @param array $params * @return string */ - public function toString(string $controllerName, string $actionName, array $params = array()): string + public function toString(string $controllerName, string $actionName, array $params = []): string { } @@ -818,7 +870,7 @@ protected function loadTemplateEngines(): array * @param bool $fireEvents * @return bool */ - public function processRender(string $controllerName, string $actionName, array $params = array(), bool $fireEvents = true): bool + public function processRender(string $controllerName, string $actionName, array $params = [], bool $fireEvents = true): bool { } } diff --git a/src/Phalcon/Mvc/View/Engine/AbstractEngine.php b/src/Mvc/View/Engine/AbstractEngine.php similarity index 87% rename from src/Phalcon/Mvc/View/Engine/AbstractEngine.php rename to src/Mvc/View/Engine/AbstractEngine.php index 007c9c85..55523132 100644 --- a/src/Phalcon/Mvc/View/Engine/AbstractEngine.php +++ b/src/Mvc/View/Engine/AbstractEngine.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Mvc\View\Engine; +use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; use Phalcon\Mvc\ViewBaseInterface; @@ -18,15 +19,17 @@ */ abstract class AbstractEngine extends Injectable implements \Phalcon\Mvc\View\Engine\EngineInterface { - + /** + * @var ViewBaseInterface + */ protected $view; /** * Phalcon\Mvc\View\Engine constructor * - * @param \Phalcon\Mvc\ViewBaseInterface $view - * @param \Phalcon\Di\DiInterface $container + * @param ViewBaseInterface $view + * @param DiInterface|null $container */ public function __construct(\Phalcon\Mvc\ViewBaseInterface $view, \Phalcon\Di\DiInterface $container = null) { @@ -53,11 +56,11 @@ public function getView(): ViewBaseInterface /** * Renders a partial inside another view * - * @param array $params * @param string $partialPath + * @param mixed|null $params * * @return void */ - public function partial(string $partialPath, $params = null) + public function partial(string $partialPath, $params = null): void { } } diff --git a/src/Phalcon/Mvc/View/Engine/EngineInterface.php b/src/Mvc/View/Engine/EngineInterface.php similarity index 94% rename from src/Phalcon/Mvc/View/Engine/EngineInterface.php rename to src/Mvc/View/Engine/EngineInterface.php index 78012e02..aa5dbe76 100644 --- a/src/Phalcon/Mvc/View/Engine/EngineInterface.php +++ b/src/Mvc/View/Engine/EngineInterface.php @@ -29,11 +29,13 @@ public function getContent(): string; * @param mixed $params * @return void */ - public function partial(string $partialPath, $params = null); + public function partial(string $partialPath, $params = null): void; /** * Renders a view using the template engine * + * TODO: Change params to array type + * * @param string $path * @param mixed $params * @param bool $mustClean diff --git a/src/Phalcon/Mvc/View/Engine/Php.php b/src/Mvc/View/Engine/Php.php similarity index 100% rename from src/Phalcon/Mvc/View/Engine/Php.php rename to src/Mvc/View/Engine/Php.php diff --git a/src/Phalcon/Mvc/View/Engine/Volt.php b/src/Mvc/View/Engine/Volt.php similarity index 78% rename from src/Phalcon/Mvc/View/Engine/Volt.php rename to src/Mvc/View/Engine/Volt.php index c2a9cfdb..7e031bcc 100644 --- a/src/Phalcon/Mvc/View/Engine/Volt.php +++ b/src/Mvc/View/Engine/Volt.php @@ -17,37 +17,48 @@ */ class Volt extends \Phalcon\Mvc\View\Engine\AbstractEngine implements \Phalcon\Events\EventsAwareInterface { - + /** + * @var Compiler + */ protected $compiler; - + /** + * @var ManagerInterface|null + */ protected $eventsManager; + /** + * @var array + */ + protected $macros = []; - protected $macros; - - - protected $options; + /** + * @var array + */ + protected $options = []; /** * Checks if a macro is defined and calls it * + * @params string name + * @params array arguments + * + * @return mixed * @param string $name * @param array $arguments - * @return mixed */ - public function callMacro(string $name, array $arguments = array()) + public function callMacro(string $name, array $arguments = []) { } /** * Performs a string conversion * + * @return string * @param string $text * @param string $from * @param string $to - * @return string */ public function convertEncoding(string $text, string $from, string $to): string { @@ -65,7 +76,7 @@ public function getCompiler(): Compiler /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface|null + * @return ManagerInterface|null */ public function getEventsManager(): ?ManagerInterface { @@ -84,7 +95,7 @@ public function getOptions(): array * Checks if the needle is included in the haystack * * @param mixed $needle - * @param mixed $haystack + * @param array|string $haystack * * @return bool */ public function isIncluded($needle, $haystack): bool @@ -94,7 +105,7 @@ public function isIncluded($needle, $haystack): bool /** * Length filter. If an array/object is passed a count is performed otherwise a strlen/mb_strlen * - * @param mixed $item + * @param mixed $item * * @return int */ public function length($item): int @@ -104,28 +115,32 @@ public function length($item): int /** * Renders a view using the template engine * - * @param string $templatePath + * @param string $path * @param mixed $params + * @params bool mustClean + * + * @return void * @param bool $mustClean */ - public function render(string $templatePath, $params, bool $mustClean = false) + public function render(string $path, $params, bool $mustClean = false) { } /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager * * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): void { } /** * Set Volt's options * - * @param array $options + * @param array $options * + * @return void */ public function setOptions(array $options) { diff --git a/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php b/src/Mvc/View/Engine/Volt/Compiler.php similarity index 79% rename from src/Phalcon/Mvc/View/Engine/Volt/Compiler.php rename to src/Mvc/View/Engine/Volt/Compiler.php index 520e8fd2..86c590e7 100644 --- a/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php +++ b/src/Mvc/View/Engine/Volt/Compiler.php @@ -10,6 +10,7 @@ namespace Phalcon\Mvc\View\Engine\Volt; use Phalcon\Di\DiInterface; +use Phalcon\Mvc\ViewBaseInterface; /** * This class reads and compiles Volt templates into PHP plain code @@ -24,74 +25,120 @@ */ class Compiler implements \Phalcon\Di\InjectionAwareInterface { - + /** + * @var bool + */ protected $autoescape = false; - + /** + * @var int + */ protected $blockLevel = 0; - + /** + * @var array|null + * + * TODO: Make array only? + */ protected $blocks; + /** + * @var DiInterface|null + */ + protected $container = null; - protected $container; - - + /** + * @var string|null + */ protected $compiledTemplatePath; + /** + * @var string|null + */ + protected $currentBlock = null; - protected $currentBlock; - - - protected $currentPath; - + /** + * @var string|null + */ + protected $currentPath = null; + /** + * @var int + */ protected $exprLevel = 0; - + /** + * @var bool + */ protected $extended = false; + /** + * @var array + */ + protected $extensions = []; - protected $extensions; - - + /** + * @var array|bool + * + * TODO: Make it always array + */ protected $extendedBlocks; + /** + * @var array + */ + protected $filters = []; - protected $filters; - - + /** + * @var int + */ protected $foreachLevel = 0; + /** + * @var array + */ + protected $forElsePointers = []; - protected $forElsePointers; - - - protected $functions; - + /** + * @var array + */ + protected $functions = []; + /** + * @var int + */ protected $level = 0; + /** + * @var array + */ + protected $loopPointers = []; - protected $loopPointers; - - - protected $macros; - - - protected $options; - + /** + * @var array + */ + protected $macros = []; - protected $prefix; + /** + * @var array + */ + protected $options = []; + /** + * @var string + */ + protected $prefix = ''; + /** + * @var ViewBaseInterface|null + */ protected $view; /** * Phalcon\Mvc\View\Engine\Volt\Compiler * - * @param \Phalcon\Mvc\ViewBaseInterface $view + * @param ViewBaseInterface|null $view */ public function __construct(\Phalcon\Mvc\ViewBaseInterface $view = null) { @@ -100,7 +147,7 @@ public function __construct(\Phalcon\Mvc\ViewBaseInterface $view = null) /** * Registers a Volt's extension * - * @param mixed $extension + * @param mixed $extension * * @return Compiler */ public function addExtension($extension): Compiler @@ -111,7 +158,7 @@ public function addExtension($extension): Compiler * Register a new filter in the compiler * * @param string $name - * @param mixed $definition + * @param mixed $definition * * @return Compiler */ public function addFilter(string $name, $definition): Compiler @@ -122,7 +169,7 @@ public function addFilter(string $name, $definition): Compiler * Register a new function in the compiler * * @param string $name - * @param mixed $definition + * @param mixed $definition * * @return Compiler */ public function addFunction(string $name, $definition): Compiler @@ -132,7 +179,7 @@ public function addFunction(string $name, $definition): Compiler /** * Resolves attribute reading * - * @param array $expr + * @param array $expr * * @return string */ public function attributeReader(array $expr): string @@ -150,7 +197,9 @@ public function attributeReader(array $expr): string * ``` * * @param string $templatePath - * @param bool $extendsMode + * @param bool $extendsMode * + * @throws \Phalcon\Mvc\View\Engine\Volt\Exception + * @return mixed */ public function compile(string $templatePath, bool $extendsMode = false) { @@ -160,26 +209,13 @@ public function compile(string $templatePath, bool $extendsMode = false) * Compiles a "autoescape" statement returning PHP code * * @param array $statement - * @param bool $extendsMode + * @param bool $extendsMode * * @return string */ public function compileAutoEscape(array $statement, bool $extendsMode): string { } - /** - * Compiles a "cache" statement returning PHP code - * - * @deprecated Will be removed in 5.0 - * @todo Remove this in the next major version - * @param array $statement - * @param bool $extendsMode - * @return string - */ - public function compileCache(array $statement, bool $extendsMode = false): string - { - } - /** * Compiles calls to macros * @@ -194,7 +230,7 @@ public function compileCall(array $statement, bool $extendsMode) * Compiles a "case"/"default" clause returning PHP code * * @param array $statement - * @param bool $caseClause + * @param bool $caseClause * * @return string */ public function compileCase(array $statement, bool $caseClause = true): string @@ -204,7 +240,7 @@ public function compileCase(array $statement, bool $caseClause = true): string /** * Compiles a "do" statement returning PHP code * - * @param array $statement + * @param array $statement * * @return string */ public function compileDo(array $statement): string @@ -214,7 +250,7 @@ public function compileDo(array $statement): string /** * Compiles a {% raw %}`{{` `}}`{% endraw %} statement returning PHP code * - * @param array $statement + * @param array $statement * * @return string */ public function compileEcho(array $statement): string @@ -224,7 +260,7 @@ public function compileEcho(array $statement): string /** * Compiles a "elseif" statement returning PHP code * - * @param array $statement + * @param array $statement * * @return string */ public function compileElseIf(array $statement): string @@ -241,10 +277,11 @@ public function compileElseIf(array $statement): string * ); * ``` * - * @return string|array * @param string $path * @param string $compiledPath - * @param bool $extendsMode + * @param bool $extendsMode * + * @throws \Phalcon\Mvc\View\Engine\Volt\Exception + * @return string|array */ public function compileFile(string $path, string $compiledPath, bool $extendsMode = false) { @@ -254,7 +291,7 @@ public function compileFile(string $path, string $compiledPath, bool $extendsMod * Compiles a "foreach" intermediate code representation into plain PHP code * * @param array $statement - * @param bool $extendsMode + * @param bool $extendsMode * * @return string */ public function compileForeach(array $statement, bool $extendsMode = false): string @@ -274,7 +311,8 @@ public function compileForElse(): string * Compiles a 'if' statement returning PHP code * * @param array $statement - * @param bool $extendsMode + * @param bool $extendsMode * + * @throws \Phalcon\Mvc\View\Engine\Volt\Exception * @return string */ public function compileIf(array $statement, bool $extendsMode = false): string @@ -284,7 +322,8 @@ public function compileIf(array $statement, bool $extendsMode = false): string /** * Compiles a 'include' statement returning PHP code * - * @param array $statement + * @param array $statement * + * @throws \Phalcon\Mvc\View\Engine\Volt\Exception * @return string */ public function compileInclude(array $statement): string @@ -295,7 +334,7 @@ public function compileInclude(array $statement): string * Compiles macros * * @param array $statement - * @param bool $extendsMode + * @param bool $extendsMode * * @return string */ public function compileMacro(array $statement, bool $extendsMode): string @@ -305,8 +344,9 @@ public function compileMacro(array $statement, bool $extendsMode): string /** * Compiles a "return" statement returning PHP code * - * @param array $statement + * @throws \Phalcon\Mvc\View\Engine\Volt\Exception * @return string + * @param array $statement */ public function compileReturn(array $statement): string { @@ -315,7 +355,8 @@ public function compileReturn(array $statement): string /** * Compiles a "set" statement returning PHP code * - * @param array $statement + * @param array $statement * + * @throws \Phalcon\Mvc\View\Engine\Volt\Exception * @return string */ public function compileSet(array $statement): string @@ -330,7 +371,7 @@ public function compileSet(array $statement): string * ``` * * @param string $viewCode - * @param bool $extendsMode + * @param bool $extendsMode * * @return string */ public function compileString(string $viewCode, bool $extendsMode = false): string @@ -341,7 +382,8 @@ public function compileString(string $viewCode, bool $extendsMode = false): stri * Compiles a 'switch' statement returning PHP code * * @param array $statement - * @param bool $extendsMode + * @param bool $extendsMode * + * @throws \Phalcon\Mvc\View\Engine\Volt\Exception * @return string */ public function compileSwitch(array $statement, bool $extendsMode = false): string @@ -351,7 +393,7 @@ public function compileSwitch(array $statement, bool $extendsMode = false): stri /** * Resolves an expression node in an AST volt tree * - * @param array $expr + * @param array $expr * * @return string */ final public function expression(array $expr): string @@ -361,9 +403,9 @@ final public function expression(array $expr): string /** * Fires an event to registered extensions * - * @param array $arguments - * @return mixed * @param string $name + * @param array $arguments * + * @return mixed */ final public function fireExtensionEvent(string $name, $arguments = null) { @@ -372,7 +414,8 @@ final public function fireExtensionEvent(string $name, $arguments = null) /** * Resolves function intermediate code into PHP function calls * - * @param array $expr + * @param array $expr * + * @throws \Phalcon\Mvc\View\Engine\Volt\Exception * @return string */ public function functionCall(array $expr): string @@ -427,10 +470,10 @@ public function getFunctions(): array /** * Returns a compiler's option * - * @return string - * @param string $option + * @param string $option * + * @return string|null */ - public function getOption(string $option) + public function getOption(string $option): ?string { } @@ -471,10 +514,10 @@ public function getUniquePrefix(): string * ); * ``` * + * @param string $viewCode * * @return array - * @param string $viewCode */ - public function parse(string $viewCode) + public function parse(string $viewCode): array { } @@ -495,7 +538,7 @@ public function resolveTest(array $test, string $left): string * @param \Phalcon\Di\DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(\Phalcon\Di\DiInterface $container): void { } diff --git a/src/Phalcon/Mvc/View/Engine/Volt/Exception.php b/src/Mvc/View/Engine/Volt/Exception.php similarity index 81% rename from src/Phalcon/Mvc/View/Engine/Volt/Exception.php rename to src/Mvc/View/Engine/Volt/Exception.php index 08a2dad3..8783b6f1 100644 --- a/src/Phalcon/Mvc/View/Engine/Volt/Exception.php +++ b/src/Mvc/View/Engine/Volt/Exception.php @@ -14,17 +14,19 @@ */ class Exception extends \Phalcon\Mvc\View\Exception { - - protected $statement; + /** + * @var array + */ + protected $statement = []; /** * @param string $message * @param array $statement * @param int $code - * @param \Exception $previous + * @param \Exception|null $previous */ - public function __construct(string $message = '', array $statement = array(), int $code = 0, \Exception $previous = null) + public function __construct(string $message = '', array $statement = [], int $code = 0, \Exception $previous = null) { } diff --git a/src/Phalcon/Mvc/View/Exception.php b/src/Mvc/View/Exception.php similarity index 100% rename from src/Phalcon/Mvc/View/Exception.php rename to src/Mvc/View/Exception.php diff --git a/src/Phalcon/Mvc/View/Simple.php b/src/Mvc/View/Simple.php similarity index 86% rename from src/Phalcon/Mvc/View/Simple.php rename to src/Mvc/View/Simple.php index 7501f4f6..991f012f 100644 --- a/src/Phalcon/Mvc/View/Simple.php +++ b/src/Mvc/View/Simple.php @@ -11,6 +11,7 @@ use Phalcon\Di\Injectable; use Phalcon\Events\ManagerInterface; +use Phalcon\Mvc\View\Engine\EngineInterface; /** * Phalcon\Mvc\View\Simple @@ -41,36 +42,45 @@ */ class Simple extends Injectable implements \Phalcon\Mvc\ViewBaseInterface, \Phalcon\Events\EventsAwareInterface { - + /** + * @var string + */ protected $activeRenderPath; - + /** + * @var string + */ protected $content; /** - * @var \Phalcon\Mvc\View\EngineInterface[]|false + * @var EngineInterface[]|false */ protected $engines = false; - + /** + * @var ManagerInterface|null + */ protected $eventsManager; - - protected $options; - - - protected $partialsDir; + /** + * @var array + */ + protected $options = []; /** * @var array|null */ protected $registeredEngines; - + /** + * @var string + */ protected $viewsDir; - - protected $viewParams = array(); + /** + * @var array + */ + protected $viewParams = []; /** @@ -85,7 +95,7 @@ public function getRegisteredEngines(): ?array * * @param array $options */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } @@ -96,8 +106,8 @@ public function __construct(array $options = array()) * echo $this->view->products; * ``` * - * @param string $key * @return mixed|null + * @param string $key */ public function __get(string $key) { @@ -110,10 +120,11 @@ public function __get(string $key) * $this->view->products = $products; * ``` * + * @return void * @param string $key * @param mixed $value */ - public function __set(string $key, $value) + public function __set(string $key, $value): void { } @@ -138,7 +149,7 @@ public function getContent(): string /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface|null + * @return ManagerInterface|null */ public function getEventsManager(): ?ManagerInterface { @@ -156,8 +167,8 @@ public function getParamsToView(): array /** * Returns a parameter previously set in the view * - * @param string $key * @return mixed|null + * @param string $key */ public function getVar(string $key) { @@ -190,10 +201,11 @@ public function getViewsDir(): string * ); * ``` * + * @return void * @param string $partialPath * @param mixed $params */ - public function partial(string $partialPath, $params = null) + public function partial(string $partialPath, $params = null): void { } @@ -210,20 +222,21 @@ public function partial(string $partialPath, $params = null) * ); * ``` * + * @return void * @param array $engines */ - public function registerEngines(array $engines) + public function registerEngines(array $engines): void { } /** * Renders a view * + * @return string * @param string $path * @param array $params - * @return string */ - public function render(string $path, array $params = array()): string + public function render(string $path, array $params = []): string { } @@ -234,8 +247,8 @@ public function render(string $path, array $params = array()): string * $this->view->setContent("

hello

"); * ``` * - * @param string $content * @return Simple + * @param string $content */ public function setContent(string $content): Simple { @@ -244,10 +257,10 @@ public function setContent(string $content): Simple /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager * @return void + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): void { } @@ -258,9 +271,9 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager * $this->view->setParamToView("products", $products); * ``` * + * @return Simple * @param string $key * @param mixed $value - * @return Simple */ public function setParamToView(string $key, $value): Simple { @@ -273,9 +286,9 @@ public function setParamToView(string $key, $value): Simple * $this->view->setVar("products", $products); * ``` * + * @return Simple * @param string $key * @param mixed $value - * @return Simple */ public function setVar(string $key, $value): Simple { @@ -292,9 +305,9 @@ public function setVar(string $key, $value): Simple * ); * ``` * + * @return Simple * @param array $params * @param bool $merge - * @return Simple */ public function setVars(array $params, bool $merge = true): Simple { @@ -303,9 +316,10 @@ public function setVars(array $params, bool $merge = true): Simple /** * Sets views directory * + * @return void * @param string $viewsDir */ - public function setViewsDir(string $viewsDir) + public function setViewsDir(string $viewsDir): void { } @@ -322,10 +336,11 @@ protected function loadTemplateEngines(): array /** * Tries to render the view with every engine registered in the component * - * @param array $params * @param string $path + * @param array $params * + * @return void */ - final protected function internalRender(string $path, $params) + final protected function internalRender(string $path, $params): void { } } diff --git a/src/Phalcon/Mvc/ViewBaseInterface.php b/src/Mvc/ViewBaseInterface.php similarity index 100% rename from src/Phalcon/Mvc/ViewBaseInterface.php rename to src/Mvc/ViewBaseInterface.php diff --git a/src/Phalcon/Mvc/ViewInterface.php b/src/Mvc/ViewInterface.php similarity index 98% rename from src/Phalcon/Mvc/ViewInterface.php rename to src/Mvc/ViewInterface.php index 5e6a88a6..bf430e4c 100644 --- a/src/Phalcon/Mvc/ViewInterface.php +++ b/src/Mvc/ViewInterface.php @@ -125,9 +125,9 @@ public function registerEngines(array $engines); * @param string $controllerName * @param string $actionName * @param array $params - * @return bool|ViewInterface + * @return 0|ViewInterface */ - public function render(string $controllerName, string $actionName, array $params = array()); + public function render(string $controllerName, string $actionName, array $params = []); /** * Resets the view component to its factory default values diff --git a/src/Phalcon/Paginator/Adapter/AbstractAdapter.php b/src/Paginator/Adapter/AbstractAdapter.php similarity index 96% rename from src/Phalcon/Paginator/Adapter/AbstractAdapter.php rename to src/Paginator/Adapter/AbstractAdapter.php index 4a919273..97c5b2c0 100644 --- a/src/Phalcon/Paginator/Adapter/AbstractAdapter.php +++ b/src/Paginator/Adapter/AbstractAdapter.php @@ -18,16 +18,22 @@ abstract class AbstractAdapter implements \Phalcon\Paginator\Adapter\AdapterInte { /** * Configuration of paginator + * + * @var array */ protected $config; /** * Number of rows to show in the paginator. By default is null + * + * @var int|null */ protected $limitRows = null; /** * Current page in paginate + * + * @var int|null */ protected $page = null; diff --git a/src/Phalcon/Paginator/Adapter/AdapterInterface.php b/src/Paginator/Adapter/AdapterInterface.php similarity index 100% rename from src/Phalcon/Paginator/Adapter/AdapterInterface.php rename to src/Paginator/Adapter/AdapterInterface.php diff --git a/src/Phalcon/Paginator/Adapter/Model.php b/src/Paginator/Adapter/Model.php similarity index 93% rename from src/Phalcon/Paginator/Adapter/Model.php rename to src/Paginator/Adapter/Model.php index 21f04fe3..cca3b9d3 100644 --- a/src/Phalcon/Paginator/Adapter/Model.php +++ b/src/Paginator/Adapter/Model.php @@ -9,10 +9,6 @@ */ namespace Phalcon\Paginator\Adapter; -use Phalcon\Helper\Arr; -use Phalcon\Mvc\ModelInterface; -use Phalcon\Mvc\Model\ResultsetInterface; -use Phalcon\Paginator\Exception; use Phalcon\Paginator\RepositoryInterface; /** diff --git a/src/Phalcon/Paginator/Adapter/NativeArray.php b/src/Paginator/Adapter/NativeArray.php similarity index 97% rename from src/Phalcon/Paginator/Adapter/NativeArray.php rename to src/Paginator/Adapter/NativeArray.php index 98dc5e5e..a6bae499 100644 --- a/src/Phalcon/Paginator/Adapter/NativeArray.php +++ b/src/Paginator/Adapter/NativeArray.php @@ -9,7 +9,6 @@ */ namespace Phalcon\Paginator\Adapter; -use Phalcon\Paginator\Exception; use Phalcon\Paginator\RepositoryInterface; /** diff --git a/src/Phalcon/Paginator/Adapter/QueryBuilder.php b/src/Paginator/Adapter/QueryBuilder.php similarity index 97% rename from src/Phalcon/Paginator/Adapter/QueryBuilder.php rename to src/Paginator/Adapter/QueryBuilder.php index 6d325ea0..5ed0a4a1 100644 --- a/src/Phalcon/Paginator/Adapter/QueryBuilder.php +++ b/src/Paginator/Adapter/QueryBuilder.php @@ -9,10 +9,8 @@ */ namespace Phalcon\Paginator\Adapter; -use Phalcon\Db\Enum; use Phalcon\Mvc\Model\Query\Builder; use Phalcon\Paginator\RepositoryInterface; -use Phalcon\Paginator\Exception; /** * Phalcon\Paginator\Adapter\QueryBuilder @@ -40,11 +38,15 @@ class QueryBuilder extends \Phalcon\Paginator\Adapter\AbstractAdapter { /** * Paginator's data + * + * @var Builder */ protected $builder; /** * Columns for count query if builder has having + * + * @var array|string */ protected $columns; diff --git a/src/Phalcon/Paginator/Exception.php b/src/Paginator/Exception.php similarity index 100% rename from src/Phalcon/Paginator/Exception.php rename to src/Paginator/Exception.php diff --git a/src/Phalcon/Paginator/PaginatorFactory.php b/src/Paginator/PaginatorFactory.php similarity index 84% rename from src/Phalcon/Paginator/PaginatorFactory.php rename to src/Paginator/PaginatorFactory.php index 457aa472..f1193ec5 100644 --- a/src/Phalcon/Paginator/PaginatorFactory.php +++ b/src/Paginator/PaginatorFactory.php @@ -9,9 +9,8 @@ */ namespace Phalcon\Paginator; -use Phalcon\Paginator\Adapter\AdapterInterface; use Phalcon\Factory\AbstractFactory; -use Phalcon\Helper\Arr; +use Phalcon\Paginator\Adapter\AdapterInterface; /** * This file is part of the Phalcon Framework. @@ -24,12 +23,15 @@ class PaginatorFactory extends AbstractFactory { + protected $exception = 'Phalcon\\\\Annotations\\\\Exception'; + + /** * AdapterFactory constructor. * * @param array $services */ - public function __construct(array $services = array()) + public function __construct(array $services = []) { } @@ -63,12 +65,6 @@ public function __construct(array $services = array()) * 'builder' => null * ] * @param mixed $config - * @param array|\Phalcon\Config = [ - * 'adapter' => 'queryBuilder', - * 'limit' => 20, - * 'page' => 1, - * 'builder' => null - * ] * @return AdapterInterface */ public function load($config): AdapterInterface @@ -82,7 +78,7 @@ public function load($config): AdapterInterface * @param array $options * @return AdapterInterface */ - public function newInstance(string $name, array $options = array()): AdapterInterface + public function newInstance(string $name, array $options = []): AdapterInterface { } diff --git a/src/Phalcon/Paginator/Repository.php b/src/Paginator/Repository.php similarity index 95% rename from src/Phalcon/Paginator/Repository.php rename to src/Paginator/Repository.php index 124c8086..19931fb2 100644 --- a/src/Phalcon/Paginator/Repository.php +++ b/src/Paginator/Repository.php @@ -9,9 +9,6 @@ */ namespace Phalcon\Paginator; -use JsonSerializable; -use Phalcon\Helper\Arr; - /** * Phalcon\Paginator\Repository * @@ -22,12 +19,12 @@ class Repository implements \Phalcon\Paginator\RepositoryInterface, \JsonSeriali /** * @var array */ - protected $aliases = array(); + protected $aliases = []; /** * @var array */ - protected $properties = array(); + protected $properties = []; /** diff --git a/src/Phalcon/Paginator/RepositoryInterface.php b/src/Paginator/RepositoryInterface.php similarity index 100% rename from src/Phalcon/Paginator/RepositoryInterface.php rename to src/Paginator/RepositoryInterface.php diff --git a/src/Phalcon/DataMapper/Pdo/Profiler/MemoryLogger.php b/src/Phalcon/DataMapper/Pdo/Profiler/MemoryLogger.php deleted file mode 100644 index 1e5e496c..00000000 --- a/src/Phalcon/DataMapper/Pdo/Profiler/MemoryLogger.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. - */ -namespace Phalcon\DataMapper\Pdo\Profiler; - -use Psr\Log\AbstractLogger; - -/** - * A naive memory-based logger. - * - * @property array $messages - */ -class MemoryLogger extends AbstractLogger -{ - /** - * @var array - */ - protected $messages = array(); - - - /** - * Returns the logged messages. - * - * @return array - */ - public function getMessages() - { - } - - /** - * Logs a message. - * - * @param mixed $level - * @param string $message - * @param array $context - */ - public function log($level, $message, array $context = array()) - { - } -} diff --git a/src/Phalcon/Registry.php b/src/Registry.php similarity index 91% rename from src/Phalcon/Registry.php rename to src/Registry.php index cd6dab97..0a27af22 100644 --- a/src/Phalcon/Registry.php +++ b/src/Registry.php @@ -69,7 +69,7 @@ final class Registry extends \Phalcon\Collection * * @param array $data */ - final public function __construct(array $data = null) + final public function __construct(array $data = []) { } @@ -100,7 +100,7 @@ final public function __isset(string $element): bool * @param mixed $value * @return void */ - final public function __set(string $element, $value) + final public function __set(string $element, $value): void { } @@ -110,7 +110,7 @@ final public function __set(string $element, $value) * @param string $element * @return void */ - final public function __unset(string $element) + final public function __unset(string $element): void { } @@ -119,7 +119,7 @@ final public function __unset(string $element) * * @return void */ - final public function clear() + final public function clear(): void { } @@ -170,7 +170,7 @@ final public function has(string $element): bool * @param array $data * @return void */ - final public function init(array $data = array()) + final public function init(array $data = []): void { } @@ -214,7 +214,7 @@ final public function offsetGet($element) * @param mixed $value * @return void */ - final public function offsetSet($element, $value) + final public function offsetSet($element, $value): void { } @@ -225,7 +225,7 @@ final public function offsetSet($element, $value) * @param mixed $element * @return void */ - final public function offsetUnset($element) + final public function offsetUnset($element): void { } @@ -235,7 +235,7 @@ final public function offsetUnset($element) * @param string $element * @return void */ - final public function remove(string $element) + final public function remove(string $element): void { } @@ -256,7 +256,7 @@ final public function serialize(): string * @param mixed $value * @return void */ - final public function set(string $element, $value) + final public function set(string $element, $value): void { } @@ -291,7 +291,7 @@ final public function toJson(int $options = 79): string * @param mixed $serialized * @return void */ - final public function unserialize($serialized) + final public function unserialize($serialized): void { } } diff --git a/src/Phalcon/Security.php b/src/Security.php similarity index 95% rename from src/Phalcon/Security.php rename to src/Security.php index 1b102d24..fdd8723e 100644 --- a/src/Phalcon/Security.php +++ b/src/Security.php @@ -9,11 +9,9 @@ */ namespace Phalcon; -use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Http\RequestInterface; use Phalcon\Security\Random; -use Phalcon\Security\Exception; use Phalcon\Session\ManagerInterface as SessionInterface; /** @@ -68,7 +66,7 @@ class Security extends AbstractInjectionAware /** * @var int|null */ - protected $defaultHash; + protected $defaultHash = null; /** * @var int @@ -81,19 +79,19 @@ class Security extends AbstractInjectionAware protected $random; /** - * @var string}null + * @var string|null */ - protected $requestToken; + protected $requestToken = null; /** * @var string|null */ - protected $token; + protected $token = null; /** * @var string|null */ - protected $tokenKey; + protected $tokenKey = null; /** * @var string @@ -316,14 +314,14 @@ public function setWorkFactor(int $workFactor): Security } /** - * @return \Phalcon\Http\RequestInterface|null + * @return RequestInterface|null */ private function getLocalRequest(): ?RequestInterface { } /** - * @return \Phalcon\Session\ManagerInterface|null + * @return SessionInterface|null */ private function getLocalSession(): ?SessionInterface { diff --git a/src/Phalcon/Security/Exception.php b/src/Security/Exception.php similarity index 100% rename from src/Phalcon/Security/Exception.php rename to src/Security/Exception.php diff --git a/src/Phalcon/Security/JWT/Builder.php b/src/Security/JWT/Builder.php similarity index 99% rename from src/Phalcon/Security/JWT/Builder.php rename to src/Security/JWT/Builder.php index 19163e59..8a481556 100644 --- a/src/Phalcon/Security/JWT/Builder.php +++ b/src/Security/JWT/Builder.php @@ -298,7 +298,7 @@ public function setPassphrase(string $passphrase): Builder * * @return Builder */ - private function setClaim(string $name, $value): Builder + protected function setClaim(string $name, $value): Builder { } } diff --git a/src/Phalcon/Security/JWT/Exceptions/UnsupportedAlgorithmException.php b/src/Security/JWT/Exceptions/UnsupportedAlgorithmException.php similarity index 100% rename from src/Phalcon/Security/JWT/Exceptions/UnsupportedAlgorithmException.php rename to src/Security/JWT/Exceptions/UnsupportedAlgorithmException.php diff --git a/src/Phalcon/Security/JWT/Exceptions/ValidatorException.php b/src/Security/JWT/Exceptions/ValidatorException.php similarity index 100% rename from src/Phalcon/Security/JWT/Exceptions/ValidatorException.php rename to src/Security/JWT/Exceptions/ValidatorException.php diff --git a/src/Phalcon/Security/JWT/Signer/AbstractSigner.php b/src/Security/JWT/Signer/AbstractSigner.php similarity index 100% rename from src/Phalcon/Security/JWT/Signer/AbstractSigner.php rename to src/Security/JWT/Signer/AbstractSigner.php diff --git a/src/Phalcon/Security/JWT/Signer/Hmac.php b/src/Security/JWT/Signer/Hmac.php similarity index 100% rename from src/Phalcon/Security/JWT/Signer/Hmac.php rename to src/Security/JWT/Signer/Hmac.php diff --git a/src/Phalcon/Security/JWT/Signer/None.php b/src/Security/JWT/Signer/None.php similarity index 100% rename from src/Phalcon/Security/JWT/Signer/None.php rename to src/Security/JWT/Signer/None.php diff --git a/src/Phalcon/Security/JWT/Signer/SignerInterface.php b/src/Security/JWT/Signer/SignerInterface.php similarity index 100% rename from src/Phalcon/Security/JWT/Signer/SignerInterface.php rename to src/Security/JWT/Signer/SignerInterface.php diff --git a/src/Phalcon/Security/JWT/Token/AbstractItem.php b/src/Security/JWT/Token/AbstractItem.php similarity index 94% rename from src/Phalcon/Security/JWT/Token/AbstractItem.php rename to src/Security/JWT/Token/AbstractItem.php index 65f322b1..c45c3d30 100644 --- a/src/Phalcon/Security/JWT/Token/AbstractItem.php +++ b/src/Security/JWT/Token/AbstractItem.php @@ -19,7 +19,7 @@ abstract class AbstractItem /** * @var array */ - protected $data = array(); + protected $data = []; /** diff --git a/src/Phalcon/Security/JWT/Token/Enum.php b/src/Security/JWT/Token/Enum.php similarity index 100% rename from src/Phalcon/Security/JWT/Token/Enum.php rename to src/Security/JWT/Token/Enum.php diff --git a/src/Phalcon/Security/JWT/Token/Item.php b/src/Security/JWT/Token/Item.php similarity index 100% rename from src/Phalcon/Security/JWT/Token/Item.php rename to src/Security/JWT/Token/Item.php diff --git a/src/Phalcon/Security/JWT/Token/Parser.php b/src/Security/JWT/Token/Parser.php similarity index 100% rename from src/Phalcon/Security/JWT/Token/Parser.php rename to src/Security/JWT/Token/Parser.php diff --git a/src/Phalcon/Security/JWT/Token/Signature.php b/src/Security/JWT/Token/Signature.php similarity index 100% rename from src/Phalcon/Security/JWT/Token/Signature.php rename to src/Security/JWT/Token/Signature.php diff --git a/src/Phalcon/Security/JWT/Token/Token.php b/src/Security/JWT/Token/Token.php similarity index 100% rename from src/Phalcon/Security/JWT/Token/Token.php rename to src/Security/JWT/Token/Token.php diff --git a/src/Phalcon/Security/JWT/Validator.php b/src/Security/JWT/Validator.php similarity index 100% rename from src/Phalcon/Security/JWT/Validator.php rename to src/Security/JWT/Validator.php diff --git a/src/Phalcon/Security/Random.php b/src/Security/Random.php similarity index 100% rename from src/Phalcon/Security/Random.php rename to src/Security/Random.php diff --git a/src/Phalcon/Session/Adapter/AbstractAdapter.php b/src/Session/Adapter/AbstractAdapter.php similarity index 100% rename from src/Phalcon/Session/Adapter/AbstractAdapter.php rename to src/Session/Adapter/AbstractAdapter.php diff --git a/src/Phalcon/Session/Adapter/Libmemcached.php b/src/Session/Adapter/Libmemcached.php similarity index 90% rename from src/Phalcon/Session/Adapter/Libmemcached.php rename to src/Session/Adapter/Libmemcached.php index 2a603e04..5a11b14d 100644 --- a/src/Phalcon/Session/Adapter/Libmemcached.php +++ b/src/Session/Adapter/Libmemcached.php @@ -9,9 +9,6 @@ */ namespace Phalcon\Session\Adapter; -use Phalcon\Storage\AdapterFactory; -use Phalcon\Helper\Arr; - /** * Phalcon\Session\Adapter\Libmemcached */ @@ -37,7 +34,7 @@ class Libmemcached extends \Phalcon\Session\Adapter\AbstractAdapter * ] * @param \Phalcon\Storage\AdapterFactory $factory */ - public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) + public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = []) { } } diff --git a/src/Phalcon/Session/Adapter/Noop.php b/src/Session/Adapter/Noop.php similarity index 93% rename from src/Phalcon/Session/Adapter/Noop.php rename to src/Session/Adapter/Noop.php index feb2e656..c1ffd2f4 100644 --- a/src/Phalcon/Session/Adapter/Noop.php +++ b/src/Session/Adapter/Noop.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Session\Adapter; -use SessionHandlerInterface; - /** * Phalcon\Session\Adapter\Noop * @@ -31,15 +29,17 @@ class Noop implements \SessionHandlerInterface { /** * The connection of some adapters + * + * @var null */ - protected $connection; + protected $connection = null; /** * Session options * * @var array */ - protected $options = array(); + protected $options = []; /** * Session prefix @@ -63,7 +63,7 @@ class Noop implements \SessionHandlerInterface * 'prefix' => '' * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Session/Adapter/Redis.php b/src/Session/Adapter/Redis.php similarity index 89% rename from src/Phalcon/Session/Adapter/Redis.php rename to src/Session/Adapter/Redis.php index 3fe6595f..6732c01a 100644 --- a/src/Phalcon/Session/Adapter/Redis.php +++ b/src/Session/Adapter/Redis.php @@ -9,9 +9,6 @@ */ namespace Phalcon\Session\Adapter; -use Phalcon\Storage\AdapterFactory; -use Phalcon\Helper\Arr; - /** * Phalcon\Session\Adapter\Redis */ @@ -32,7 +29,7 @@ class Redis extends \Phalcon\Session\Adapter\AbstractAdapter * ] * @param \Phalcon\Storage\AdapterFactory $factory */ - public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) + public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = []) { } } diff --git a/src/Phalcon/Session/Adapter/Stream.php b/src/Session/Adapter/Stream.php similarity index 93% rename from src/Phalcon/Session/Adapter/Stream.php rename to src/Session/Adapter/Stream.php index 2dcb1c33..9758443c 100644 --- a/src/Phalcon/Session/Adapter/Stream.php +++ b/src/Session/Adapter/Stream.php @@ -9,9 +9,6 @@ */ namespace Phalcon\Session\Adapter; -use Phalcon\Helper\Str; -use Phalcon\Session\Exception; - /** * Phalcon\Session\Adapter\Stream * @@ -48,7 +45,7 @@ class Stream extends \Phalcon\Session\Adapter\Noop * 'savePath' => '' * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Session/Bag.php b/src/Session/Bag.php similarity index 79% rename from src/Phalcon/Session/Bag.php rename to src/Session/Bag.php index 62471c9b..e616c49c 100644 --- a/src/Phalcon/Session/Bag.php +++ b/src/Session/Bag.php @@ -28,13 +28,21 @@ */ class Bag extends Collection implements \Phalcon\Di\InjectionAwareInterface { - + /** + * @var DiInterface|null + */ private $container; + /** + * Session Bag name + * + * @var string + */ + private $name; - private $name = null; - - + /** + * @var \Phalcon\Session\ManagerInterface + */ private $session; @@ -52,7 +60,7 @@ public function __construct(string $name) * * @return void */ - public function clear() + public function clear(): void { } @@ -71,7 +79,7 @@ public function getDI(): DiInterface * @param array $data * @return void */ - public function init(array $data = array()) + public function init(array $data = []): void { } @@ -81,7 +89,7 @@ public function init(array $data = array()) * @param string $element * @return void */ - public function remove(string $element) + public function remove(string $element): void { } @@ -92,7 +100,7 @@ public function remove(string $element) * @param mixed $value * @return void */ - public function set(string $element, $value) + public function set(string $element, $value): void { } @@ -102,7 +110,7 @@ public function set(string $element, $value) * @param \Phalcon\Di\DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(\Phalcon\Di\DiInterface $container): void { } } diff --git a/src/Phalcon/Session/Exception.php b/src/Session/Exception.php similarity index 100% rename from src/Phalcon/Session/Exception.php rename to src/Session/Exception.php diff --git a/src/Phalcon/Session/Manager.php b/src/Session/Manager.php similarity index 91% rename from src/Phalcon/Session/Manager.php rename to src/Session/Manager.php index 7a8529aa..111de4f4 100644 --- a/src/Phalcon/Session/Manager.php +++ b/src/Session/Manager.php @@ -10,11 +10,8 @@ namespace Phalcon\Session; use InvalidArgumentException; -use RuntimeException; -use SessionHandlerInterface; use Phalcon\Di\AbstractInjectionAware; -use Phalcon\Di\DiInterface; -use Phalcon\Helper\Arr; +use SessionHandlerInterface; /** * Phalcon\Session\Manager @@ -36,7 +33,7 @@ class Manager extends AbstractInjectionAware implements \Phalcon\Session\Manager /** * @var array */ - private $options = array(); + private $options = []; /** * @var string @@ -51,7 +48,7 @@ class Manager extends AbstractInjectionAware implements \Phalcon\Session\Manager * 'uniqueId' => null * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } @@ -82,7 +79,7 @@ public function __isset(string $key): bool * @param mixed $value * @return void */ - public function __set(string $key, $value) + public function __set(string $key, $value): void { } @@ -92,7 +89,7 @@ public function __set(string $key, $value) * @param string $key * @return void */ - public function __unset(string $key) + public function __unset(string $key): void { } @@ -101,7 +98,7 @@ public function __unset(string $key) * * @return void */ - public function destroy() + public function destroy(): void { } @@ -188,7 +185,7 @@ public function regenerateId($deleteOldSession = true): ManagerInterface * @param string $key * @return void */ - public function remove(string $key) + public function remove(string $key): void { } @@ -199,7 +196,7 @@ public function remove(string $key) * @param mixed $value * @return void */ - public function set(string $key, $value) + public function set(string $key, $value): void { } @@ -242,7 +239,7 @@ public function setName(string $name): ManagerInterface * @param array $options * @return void */ - public function setOptions(array $options) + public function setOptions(array $options): void { } diff --git a/src/Phalcon/Session/ManagerInterface.php b/src/Session/ManagerInterface.php similarity index 93% rename from src/Phalcon/Session/ManagerInterface.php rename to src/Session/ManagerInterface.php index 71730b61..58faaa25 100644 --- a/src/Phalcon/Session/ManagerInterface.php +++ b/src/Session/ManagerInterface.php @@ -10,7 +10,6 @@ namespace Phalcon\Session; use InvalidArgumentException; -use RuntimeException; use SessionHandlerInterface; /** @@ -53,7 +52,7 @@ public function __isset(string $key): bool; * @param mixed $value * @return void */ - public function __set(string $key, $value); + public function __set(string $key, $value): void; /** * Alias: Removes a session variable from an application context @@ -61,7 +60,7 @@ public function __set(string $key, $value); * @param string $key * @return void */ - public function __unset(string $key); + public function __unset(string $key): void; /** * Check whether the session has been started @@ -75,7 +74,7 @@ public function exists(): bool; * * @return void */ - public function destroy(); + public function destroy(): void; /** * Gets a session variable from an application context @@ -129,7 +128,7 @@ public function has(string $key): bool; * @param string $key * @return void */ - public function remove(string $key); + public function remove(string $key): void; /** * Sets a session variable in an application context @@ -138,7 +137,7 @@ public function remove(string $key); * @param mixed $value * @return void */ - public function set(string $key, $value); + public function set(string $key, $value): void; /** * Set the adapter for the session @@ -172,7 +171,7 @@ public function setName(string $name): ManagerInterface; * @param array $options * @return void */ - public function setOptions(array $options); + public function setOptions(array $options): void; /** * Returns the status of the current session. diff --git a/src/Phalcon/Storage/Adapter/AbstractAdapter.php b/src/Storage/Adapter/AbstractAdapter.php similarity index 94% rename from src/Phalcon/Storage/Adapter/AbstractAdapter.php rename to src/Storage/Adapter/AbstractAdapter.php index a19ab19c..85e98c57 100644 --- a/src/Phalcon/Storage/Adapter/AbstractAdapter.php +++ b/src/Storage/Adapter/AbstractAdapter.php @@ -25,7 +25,7 @@ abstract class AbstractAdapter implements \Phalcon\Storage\Adapter\AdapterInterface { /** - * @var mixed + * @var mixed|null */ protected $adapter; @@ -99,7 +99,7 @@ public function getPrefix(): string * ] * @param \Phalcon\Storage\SerializerFactory $factory */ - protected function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) + protected function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = []) { } @@ -131,7 +131,7 @@ abstract public function delete(string $key): bool; * Reads data from the adapter * * @param string $key - * @param mixed $defaultValue + * @param mixed|null $defaultValue * * @return mixed */ abstract public function get(string $key, $defaultValue = null); @@ -173,7 +173,7 @@ abstract public function increment(string $key, int $value = 1); * * @param string $key * @param mixed $value - * @param mixed $ttl + * @param DateInterval|int|null $ttl * @return bool */ abstract public function set(string $key, $value, $ttl = null): bool; @@ -226,10 +226,9 @@ protected function getTtl($ttl): int * Returns unserialized data * * @param mixed $content - * @param mixed $defaultValue * @return mixed */ - protected function getUnserializedData($content, $defaultValue = null) + protected function getUnserializedData($content) { } @@ -238,7 +237,7 @@ protected function getUnserializedData($content, $defaultValue = null) * * @return void */ - protected function initSerializer() + protected function initSerializer(): void { } } diff --git a/src/Phalcon/Storage/Adapter/AdapterInterface.php b/src/Storage/Adapter/AdapterInterface.php similarity index 95% rename from src/Phalcon/Storage/Adapter/AdapterInterface.php rename to src/Storage/Adapter/AdapterInterface.php index 2387928a..475ff95b 100644 --- a/src/Phalcon/Storage/Adapter/AdapterInterface.php +++ b/src/Storage/Adapter/AdapterInterface.php @@ -43,7 +43,7 @@ public function delete(string $key): bool; * Reads data from the adapter * * @param string $key - * @param mixed $defaultValue + * @param mixed|null $defaultValue * * @return mixed */ public function get(string $key, $defaultValue = null); @@ -93,7 +93,7 @@ public function increment(string $key, int $value = 1); * * @param string $key * @param mixed $value - * @param mixed $ttl + * @param \DateInterval|int|null $ttl * @return bool */ public function set(string $key, $value, $ttl = null): bool; diff --git a/src/Phalcon/Storage/Adapter/Apcu.php b/src/Storage/Adapter/Apcu.php similarity index 90% rename from src/Phalcon/Storage/Adapter/Apcu.php rename to src/Storage/Adapter/Apcu.php index 00d9940b..0e8019d2 100644 --- a/src/Phalcon/Storage/Adapter/Apcu.php +++ b/src/Storage/Adapter/Apcu.php @@ -17,7 +17,7 @@ class Apcu extends \Phalcon\Storage\Adapter\AbstractAdapter /** * @var array */ - protected $options = array(); + protected $options = []; /** @@ -31,7 +31,7 @@ class Apcu extends \Phalcon\Storage\Adapter\AbstractAdapter * ] * @param \Phalcon\Storage\SerializerFactory $factory */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) + public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = []) { } @@ -71,7 +71,7 @@ public function delete(string $key): bool * Reads data from the adapter * * @param string $key - * @param null $defaultValue + * @param mixed|null $defaultValue * * @return mixed */ @@ -124,9 +124,9 @@ public function increment(string $key, int $value = 1) /** * Stores data in the adapter * - * @param string $key - * @param mixed $value - * @param null $ttl + * @param string $key + * @param mixed $value + * @param \DateInterval|int|null $ttl * * @return bool * @throws \Exception diff --git a/src/Phalcon/Storage/Adapter/Libmemcached.php b/src/Storage/Adapter/Libmemcached.php similarity index 92% rename from src/Phalcon/Storage/Adapter/Libmemcached.php rename to src/Storage/Adapter/Libmemcached.php index 6e7d58fd..7ffb8697 100644 --- a/src/Phalcon/Storage/Adapter/Libmemcached.php +++ b/src/Storage/Adapter/Libmemcached.php @@ -9,10 +9,7 @@ */ namespace Phalcon\Storage\Adapter; -use Phalcon\Helper\Arr; use Phalcon\Storage\Exception; -use Phalcon\Storage\SerializerFactory; -use Phalcon\Storage\Serializer\SerializerInterface; /** * Libmemcached adapter @@ -22,7 +19,7 @@ class Libmemcached extends \Phalcon\Storage\Adapter\AbstractAdapter /** * @var array */ - protected $options = array(); + protected $options = []; /** @@ -43,7 +40,7 @@ class Libmemcached extends \Phalcon\Storage\Adapter\AbstractAdapter * ] * @param \Phalcon\Storage\SerializerFactory $factory */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) + public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = []) { } @@ -84,7 +81,7 @@ public function delete(string $key): bool * Reads data from the adapter * * @param string $key - * @param null $defaultValue + * @param mixed|null $defaultValue * * @return mixed * @throws Exception @@ -144,8 +141,7 @@ public function increment(string $key, int $value = 1) * * @param string $key * @param mixed $value - * @param null $ttl - * + * @param \DateInterval|int|null $ttl * * @return bool * @throws Exception */ diff --git a/src/Phalcon/Storage/Adapter/Memory.php b/src/Storage/Adapter/Memory.php similarity index 90% rename from src/Phalcon/Storage/Adapter/Memory.php rename to src/Storage/Adapter/Memory.php index 6f3883ea..ebb84aaf 100644 --- a/src/Phalcon/Storage/Adapter/Memory.php +++ b/src/Storage/Adapter/Memory.php @@ -11,10 +11,6 @@ use Phalcon\Collection; use Phalcon\Collection\CollectionInterface; -use Phalcon\Helper\Arr; -use Phalcon\Storage\Exception; -use Phalcon\Storage\SerializerFactory; -use Phalcon\Storage\Serializer\SerializerInterface; /** * Memory adapter @@ -29,7 +25,7 @@ class Memory extends \Phalcon\Storage\Adapter\AbstractAdapter /** * @var array */ - protected $options = array(); + protected $options = []; /** @@ -43,7 +39,7 @@ class Memory extends \Phalcon\Storage\Adapter\AbstractAdapter * ] * @param \Phalcon\Storage\SerializerFactory $factory */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) + public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = []) { } @@ -138,8 +134,7 @@ public function increment(string $key, int $value = 1) * * @param string $key * @param mixed $value - * @param null $ttl - * + * @param \DateInterval|int|null $ttl * * @return bool */ public function set(string $key, $value, $ttl = null): bool diff --git a/src/Phalcon/Storage/Adapter/Redis.php b/src/Storage/Adapter/Redis.php similarity index 92% rename from src/Phalcon/Storage/Adapter/Redis.php rename to src/Storage/Adapter/Redis.php index 5e0009a1..dcf9ea83 100644 --- a/src/Phalcon/Storage/Adapter/Redis.php +++ b/src/Storage/Adapter/Redis.php @@ -9,10 +9,7 @@ */ namespace Phalcon\Storage\Adapter; -use Phalcon\Helper\Arr; use Phalcon\Storage\Exception; -use Phalcon\Storage\SerializerFactory; -use Phalcon\Storage\Serializer\SerializerInterface; /** * Redis adapter @@ -22,7 +19,7 @@ class Redis extends \Phalcon\Storage\Adapter\AbstractAdapter /** * @var array */ - protected $options = array(); + protected $options = []; /** @@ -35,6 +32,9 @@ class Redis extends \Phalcon\Storage\Adapter\AbstractAdapter * 'persistent' => false, * 'auth' => '', * 'socket' => '', + * 'connectionTimeout' => 0, + * 'retryInterval' => null, + * 'readTimeout' => 0, * 'defaultSerializer' => 'Php', * 'lifetime' => 3600, * 'serializer' => null, @@ -42,7 +42,7 @@ class Redis extends \Phalcon\Storage\Adapter\AbstractAdapter * ] * @param \Phalcon\Storage\SerializerFactory $factory */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) + public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = []) { } @@ -85,8 +85,7 @@ public function delete(string $key): bool * Reads data from the adapter * * @param string $key - * @param null $defaultValue - * + * @param mixed|null $defaultValue * * @return mixed * @throws Exception */ @@ -147,8 +146,7 @@ public function increment(string $key, int $value = 1) * * @param string $key * @param mixed $value - * @param null $ttl - * + * @param \DateInterval|int|null $ttl * * @return bool * @throws Exception */ diff --git a/src/Phalcon/Storage/Adapter/Stream.php b/src/Storage/Adapter/Stream.php similarity index 89% rename from src/Phalcon/Storage/Adapter/Stream.php rename to src/Storage/Adapter/Stream.php index 9abc7e46..db256218 100644 --- a/src/Phalcon/Storage/Adapter/Stream.php +++ b/src/Storage/Adapter/Stream.php @@ -9,15 +9,8 @@ */ namespace Phalcon\Storage\Adapter; -use FilesystemIterator; use Iterator; -use Phalcon\Helper\Arr; -use Phalcon\Helper\Str; use Phalcon\Storage\Exception; -use Phalcon\Storage\SerializerFactory; -use Phalcon\Storage\Serializer\SerializerInterface; -use RecursiveDirectoryIterator; -use RecursiveIteratorIterator; /** * Stream adapter @@ -32,7 +25,7 @@ class Stream extends \Phalcon\Storage\Adapter\AbstractAdapter /** * @var array */ - protected $options = array(); + protected $options = []; /** @@ -49,7 +42,7 @@ class Stream extends \Phalcon\Storage\Adapter\AbstractAdapter * @throws Exception * @param \Phalcon\Storage\SerializerFactory $factory */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) + public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = []) { } @@ -90,9 +83,8 @@ public function delete(string $key): bool * Reads data from the adapter * * @param string $key - * @param null $defaultValue - * - * @return mixed|null + * @param mixed|null $defaultValue * + * @return mixed */ public function get(string $key, $defaultValue = null) { @@ -146,7 +138,7 @@ public function increment(string $key, int $value = 1) * * @param string $key * @param mixed $value - * @param DateInterval|int|null $ttl + * @param \DateInterval|int|null $ttl * * @return bool * @throws \Exception diff --git a/src/Phalcon/Storage/AdapterFactory.php b/src/Storage/AdapterFactory.php similarity index 91% rename from src/Phalcon/Storage/AdapterFactory.php rename to src/Storage/AdapterFactory.php index a27a2eb1..4b9bc331 100644 --- a/src/Phalcon/Storage/AdapterFactory.php +++ b/src/Storage/AdapterFactory.php @@ -22,6 +22,9 @@ */ class AdapterFactory extends AbstractFactory { + + protected $exception = 'Phalcon\\\\Storage\\\\Exception'; + /** * @var SerializerFactory */ @@ -34,7 +37,7 @@ class AdapterFactory extends AbstractFactory * @param SerializerFactory $factory * @param array $services */ - public function __construct(SerializerFactory $factory, array $services = array()) + public function __construct(SerializerFactory $factory, array $services = []) { } @@ -64,7 +67,7 @@ public function __construct(SerializerFactory $factory, array $services = array( * @param string $name * @return AdapterInterface */ - public function newInstance(string $name, array $options = array()): AdapterInterface + public function newInstance(string $name, array $options = []): AdapterInterface { } diff --git a/src/Phalcon/Storage/Exception.php b/src/Storage/Exception.php similarity index 100% rename from src/Phalcon/Storage/Exception.php rename to src/Storage/Exception.php diff --git a/src/Phalcon/Storage/Serializer/AbstractSerializer.php b/src/Storage/Serializer/AbstractSerializer.php similarity index 96% rename from src/Phalcon/Storage/Serializer/AbstractSerializer.php rename to src/Storage/Serializer/AbstractSerializer.php index 7dbe671d..3318abd4 100644 --- a/src/Phalcon/Storage/Serializer/AbstractSerializer.php +++ b/src/Storage/Serializer/AbstractSerializer.php @@ -55,7 +55,7 @@ public function getData() * @param mixed $data * @return void */ - public function setData($data) + public function setData($data): void { } } diff --git a/src/Phalcon/Storage/Serializer/Base64.php b/src/Storage/Serializer/Base64.php similarity index 94% rename from src/Phalcon/Storage/Serializer/Base64.php rename to src/Storage/Serializer/Base64.php index 45363d98..1263829f 100644 --- a/src/Phalcon/Storage/Serializer/Base64.php +++ b/src/Storage/Serializer/Base64.php @@ -35,7 +35,7 @@ public function serialize(): string * @param mixed $data * @return void */ - public function unserialize($data) + public function unserialize($data): void { } } diff --git a/src/Phalcon/Storage/Serializer/Igbinary.php b/src/Storage/Serializer/Igbinary.php similarity index 94% rename from src/Phalcon/Storage/Serializer/Igbinary.php rename to src/Storage/Serializer/Igbinary.php index c3db0cbe..d71302c8 100644 --- a/src/Phalcon/Storage/Serializer/Igbinary.php +++ b/src/Storage/Serializer/Igbinary.php @@ -35,7 +35,7 @@ public function serialize(): string * @param mixed $data * @return void */ - public function unserialize($data) + public function unserialize($data): void { } } diff --git a/src/Phalcon/Storage/Serializer/Json.php b/src/Storage/Serializer/Json.php similarity index 85% rename from src/Phalcon/Storage/Serializer/Json.php rename to src/Storage/Serializer/Json.php index 6e148320..e7eaa92e 100644 --- a/src/Phalcon/Storage/Serializer/Json.php +++ b/src/Storage/Serializer/Json.php @@ -9,10 +9,6 @@ */ namespace Phalcon\Storage\Serializer; -use InvalidArgumentException; -use JsonSerializable; -use Phalcon\Helper\Json as JsonHelper; - /** * This file is part of the Phalcon Framework. * @@ -39,7 +35,7 @@ public function serialize(): string * @param mixed $data * @return void */ - public function unserialize($data) + public function unserialize($data): void { } } diff --git a/src/Phalcon/Storage/Serializer/Msgpack.php b/src/Storage/Serializer/Msgpack.php similarity index 94% rename from src/Phalcon/Storage/Serializer/Msgpack.php rename to src/Storage/Serializer/Msgpack.php index 44c730ea..e1bb0d2e 100644 --- a/src/Phalcon/Storage/Serializer/Msgpack.php +++ b/src/Storage/Serializer/Msgpack.php @@ -35,7 +35,7 @@ public function serialize(): ?string * @param mixed $data * @return void */ - public function unserialize($data) + public function unserialize($data): void { } } diff --git a/src/Phalcon/Storage/Serializer/None.php b/src/Storage/Serializer/None.php similarity index 91% rename from src/Phalcon/Storage/Serializer/None.php rename to src/Storage/Serializer/None.php index 5f6931f4..98c17ab4 100644 --- a/src/Phalcon/Storage/Serializer/None.php +++ b/src/Storage/Serializer/None.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Storage\Serializer; -use InvalidArgumentException; - /** * This file is part of the Phalcon Framework. * @@ -37,7 +35,7 @@ public function serialize(): string * @param mixed $data * @return void */ - public function unserialize($data) + public function unserialize($data): void { } } diff --git a/src/Phalcon/Storage/Serializer/Php.php b/src/Storage/Serializer/Php.php similarity index 88% rename from src/Phalcon/Storage/Serializer/Php.php rename to src/Storage/Serializer/Php.php index a606e340..ee3d65b4 100644 --- a/src/Phalcon/Storage/Serializer/Php.php +++ b/src/Storage/Serializer/Php.php @@ -9,9 +9,6 @@ */ namespace Phalcon\Storage\Serializer; -use InvalidArgumentException; -use Phalcon\Storage\Exception; - /** * This file is part of the Phalcon Framework. * @@ -38,7 +35,7 @@ public function serialize(): string * @param mixed $data * @return void */ - public function unserialize($data) + public function unserialize($data): void { } } diff --git a/src/Phalcon/Storage/Serializer/SerializerInterface.php b/src/Storage/Serializer/SerializerInterface.php similarity index 92% rename from src/Phalcon/Storage/Serializer/SerializerInterface.php rename to src/Storage/Serializer/SerializerInterface.php index 0e567290..ac0c3979 100644 --- a/src/Phalcon/Storage/Serializer/SerializerInterface.php +++ b/src/Storage/Serializer/SerializerInterface.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Storage\Serializer; -use Serializable; - /** * This file is part of the Phalcon Framework. * @@ -31,5 +29,5 @@ public function getData(); * @param mixed $data * @return void */ - public function setData($data); + public function setData($data): void; } diff --git a/src/Phalcon/Storage/SerializerFactory.php b/src/Storage/SerializerFactory.php similarity index 89% rename from src/Phalcon/Storage/SerializerFactory.php rename to src/Storage/SerializerFactory.php index 0ae0be18..afaf5468 100644 --- a/src/Phalcon/Storage/SerializerFactory.php +++ b/src/Storage/SerializerFactory.php @@ -23,12 +23,15 @@ class SerializerFactory extends AbstractFactory { + protected $exception = 'Phalcon\\\\Storage\\\\Exception'; + + /** * SerializerFactory constructor. * * @param array $services */ - public function __construct(array $services = array()) + public function __construct(array $services = []) { } diff --git a/src/Phalcon/Debug.php b/src/Support/Debug.php similarity index 93% rename from src/Phalcon/Debug.php rename to src/Support/Debug.php index 8bc9cc36..3fb6895f 100644 --- a/src/Phalcon/Debug.php +++ b/src/Support/Debug.php @@ -7,7 +7,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon; +namespace Phalcon\Support; /** * Provides debug capabilities to Phalcon applications @@ -17,10 +17,12 @@ class Debug /** * @var array */ - protected $blacklist = array('request' => array(), 'server' => array()); + protected $blacklist = ['request' => [], 'server' => []]; - - protected $data; + /** + * @var array + */ + protected $data = []; /** * @var bool @@ -30,7 +32,7 @@ class Debug /** * @var bool */ - protected static $isActive; + protected static $isActive = false; /** * @var bool @@ -50,7 +52,7 @@ class Debug /** * @var string */ - protected $uri = 'https://assets.phalcon.io/debug/4.0.x/'; + protected $uri = 'https://assets.phalcon.io/debug/5.0.x/'; /** @@ -105,7 +107,7 @@ public function getVersion(): string * * @return void */ - public function halt() + public function halt(): void { } @@ -158,7 +160,15 @@ public function onUncaughtException(\Throwable $exception): bool * @param mixed $context * @return void */ - public function onUncaughtLowSeverity($severity, $message, $file, $line, $context) + public function onUncaughtLowSeverity($severity, $message, $file, $line, $context): void + { + } + + /** + * @param \Throwable $exception + * @return string + */ + public function renderHtml(\Throwable $exception): string { } @@ -254,12 +264,4 @@ protected function getVarDump($variable): string final protected function showTraceItem(int $n, array $trace): string { } - - /** - * @param \Throwable $exception - * @return string - */ - public function renderHtml(\Throwable $exception): string - { - } } diff --git a/src/Phalcon/Debug/Dump.php b/src/Support/Debug/Dump.php similarity index 93% rename from src/Phalcon/Debug/Dump.php rename to src/Support/Debug/Dump.php index aad14563..01b3ad7e 100644 --- a/src/Phalcon/Debug/Dump.php +++ b/src/Support/Debug/Dump.php @@ -7,7 +7,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Debug; +namespace Phalcon\Support\Debug; /** * Dumps information about a variable(s) @@ -36,12 +36,12 @@ class Dump /** * @var array */ - protected $methods = array(); + protected $methods = []; /** * @var array */ - protected $styles = array(); + protected $styles = []; /** @@ -64,7 +64,7 @@ public function setDetailed(bool $detailed) * @param array $styles * @param bool $detailed */ - public function __construct(array $styles = array(), bool $detailed = false) + public function __construct(array $styles = [], bool $detailed = false) { } @@ -94,7 +94,7 @@ public function one($variable, string $name = null): string * @param array $styles * @return array */ - public function setStyles(array $styles = array()): array + public function setStyles(array $styles = []): array { } diff --git a/src/Phalcon/Debug/Exception.php b/src/Support/Debug/Exception.php similarity index 91% rename from src/Phalcon/Debug/Exception.php rename to src/Support/Debug/Exception.php index 9b59519b..76f526d6 100644 --- a/src/Phalcon/Debug/Exception.php +++ b/src/Support/Debug/Exception.php @@ -7,7 +7,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Debug; +namespace Phalcon\Support\Debug; /** * Exceptions thrown in Phalcon\Debug will use this class diff --git a/src/Support/Exception.php b/src/Support/Exception.php new file mode 100644 index 00000000..b1dadc36 --- /dev/null +++ b/src/Support/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Support; + +/** + * Phalcon\Support\Exception + */ +class Exception extends \Exception +{ + +} diff --git a/src/Support/Helper/Str/Interpolate.php b/src/Support/Helper/Str/Interpolate.php new file mode 100644 index 00000000..58db8403 --- /dev/null +++ b/src/Support/Helper/Str/Interpolate.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Support\Helper\Str; + +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Interpolate +{ + + /** + * Interpolates context values into the message placeholders + * + * @see http://www.php-fig.org/psr/psr-3/ Section 1.2 Message + * + * @param string $message + * @param array $context + * @param string $leftToken + * @param string $rightToken + * @return string + */ + public function __invoke(string $message, array $context = [], string $leftToken = '%', string $rightToken = '%'): string + { + } +} diff --git a/src/Support/HelperFactory.php b/src/Support/HelperFactory.php new file mode 100644 index 00000000..ff728cd8 --- /dev/null +++ b/src/Support/HelperFactory.php @@ -0,0 +1,59 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Support; + +use Phalcon\Factory\AbstractFactory; + +/** + * ServiceLocator implementation for helpers + */ +class HelperFactory extends AbstractFactory +{ + + protected $exception = 'Phalcon\\\\Support\\\\Exception'; + + + /** + * HelperFactory constructor. + * + * @param array $services + */ + public function __construct(array $services = []) + { + } + + /** + * @param string $name + * @param array $arguments + * + * @return mixed + * @throws Exception + */ + public function __call(string $name, array $arguments) + { + } + + /** + * @param string $name + * + * @return mixed + * @throws Exception + */ + public function newInstance(string $name) + { + } + + /** + * @return string[] + */ + protected function getAdapters(): array + { + } +} diff --git a/src/Phalcon/Version.php b/src/Support/Version.php similarity index 55% rename from src/Phalcon/Version.php rename to src/Support/Version.php index 254272fc..54638561 100644 --- a/src/Phalcon/Version.php +++ b/src/Support/Version.php @@ -7,7 +7,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon; +namespace Phalcon\Support; /** * This class allows to get the installed version of the framework @@ -18,9 +18,8 @@ class Version * The constant referencing the major version. Returns 0 * * ```php - * echo Phalcon\Version::getPart( - * Phalcon\Version::VERSION_MAJOR - * ); + * echo (new Phalcon\Support\Version()) + * ->getPart(Phalcon\Support\Version::VERSION_MAJOR); * ``` */ const VERSION_MAJOR = 0; @@ -29,9 +28,8 @@ class Version * The constant referencing the major version. Returns 1 * * ```php - * echo Phalcon\Version::getPart( - * Phalcon\Version::VERSION_MEDIUM - * ); + * echo (new Phalcon\Support\Version()) + * ->getPart(Phalcon\Support\Version::VERSION_MEDIUM); * ``` */ const VERSION_MEDIUM = 1; @@ -40,9 +38,8 @@ class Version * The constant referencing the major version. Returns 2 * * ```php - * echo Phalcon\Version::getPart( - * Phalcon\Version::VERSION_MINOR - * ); + * echo (new Phalcon\Support\Version()) + * ->getPart(Phalcon\Support\Version::VERSION_MINOR); * ``` */ const VERSION_MINOR = 2; @@ -51,9 +48,8 @@ class Version * The constant referencing the major version. Returns 3 * * ```php - * echo Phalcon\Version::getPart( - * Phalcon\Version::VERSION_SPECIAL - * ); + * echo (new Phalcon\Support\Version()) + * ->getPart(Phalcon\Support\Version::VERSION_SPECIAL); * ``` */ const VERSION_SPECIAL = 3; @@ -62,9 +58,8 @@ class Version * The constant referencing the major version. Returns 4 * * ```php - * echo Phalcon\Version::getPart( - * Phalcon\Version::VERSION_SPECIAL_NUMBER - * ); + * echo (new Phalcon\Support\Version()) + * ->getPart(Phalcon\Support\Version::VERSION_SPECIAL_NUMBER); * ``` */ const VERSION_SPECIAL_NUMBER = 4; @@ -80,39 +75,9 @@ class Version * D - Special release: 1 = alpha, 2 = beta, 3 = RC, 4 = stable * E - Special release version i.e. RC1, Beta2 etc. * - * @todo Remove in v5 - * @deprecated Use getVersion() * @return array */ - protected static function _getVersion(): array - { - } - - /** - * Area where the version number is set. The format is as follows: - * ABBCCDE - * - * A - Major version - * B - Med version (two digits) - * C - Min version (two digits) - * D - Special release: 1 = alpha, 2 = beta, 3 = RC, 4 = stable - * E - Special release version i.e. RC1, Beta2 etc. - * - * @return array - */ - protected static function getVersion(): array - { - } - - /** - * Translates a number to a special release. - * - * @todo Remove in v5.0 - * @deprecated Use getSpecial() - * @param int $special - * @return string - */ - final protected static function _getSpecial(int $special): string + protected function getVersion(): array { } @@ -122,7 +87,7 @@ final protected static function _getSpecial(int $special): string * @param int $special * @return string */ - final protected static function getSpecial(int $special): string + final protected function getSpecial(int $special): string { } @@ -130,12 +95,12 @@ final protected static function getSpecial(int $special): string * Returns the active version (string) * * ```php - * echo Phalcon\Version::get(); + * echo (new Phalcon\Version())->get(); * ``` * * @return string */ - public static function get(): string + public function get(): string { } @@ -143,12 +108,12 @@ public static function get(): string * Returns the numeric active version * * ```php - * echo Phalcon\Version::getId(); + * echo (new Phalcon\Version())->getId(); * ``` * * @return string */ - public static function getId(): string + public function getId(): string { } @@ -157,15 +122,13 @@ public static function getId(): string * it will return the full version * * ```php - * echo Phalcon\Version::getPart( - * Phalcon\Version::VERSION_MAJOR - * ); + * echo (new Phalcon\Version())->getPart(Phalcon\Version::VERSION_MAJOR); * ``` * * @param int $part * @return string */ - public static function getPart(int $part): string + public function getPart(int $part): string { } } diff --git a/src/Phalcon/Tag.php b/src/Tag.php similarity index 93% rename from src/Phalcon/Tag.php rename to src/Tag.php index 59e4eb8e..0d64d75f 100644 --- a/src/Phalcon/Tag.php +++ b/src/Tag.php @@ -11,12 +11,6 @@ use Phalcon\Di\DiInterface; use Phalcon\Escaper\EscaperInterface; -use Phalcon\Html\Link\Link; -use Phalcon\Html\Link\Serializer\Header; -use Phalcon\Helper\Str; -use Phalcon\Helper\Exception as HelperException; -use Phalcon\Tag\Select; -use Phalcon\Tag\Exception; use Phalcon\Url\UrlInterface; /** @@ -59,50 +53,70 @@ class Tag const XHTML5 = 11; - + /** + * @var bool + */ protected static $autoEscape = true; /** * DI Container + * + * @var DiInterface|null */ - protected static $container; + protected static $container = null; /** * Pre-assigned values for components + * + * @var array */ protected static $displayValues; + /** + * @var array + */ + protected static $documentAppendTitle; - protected static $documentAppendTitle = null; - - - protected static $documentPrependTitle = null; + /** + * @var array + */ + protected static $documentPrependTitle; /** * HTML document title + * + * @var string|null */ protected static $documentTitle = null; - + /** + * @var string|null + */ protected static $documentTitleSeparator = null; - + /** + * @var int + */ protected static $documentType = 11; - + /** + * @var EscaperInterface|null + */ protected static $escaperService = null; - + /** + * @var UrlInterface|null + */ protected static $urlService = null; /** * Appends a text to current document title * - * @param mixed $title + * @param array|string $title * @return void */ - public static function appendTitle($title) + public static function appendTitle($title): void { } @@ -188,7 +202,7 @@ public static function dateTimeLocalField($parameters): string * @param mixed $value * @return void */ - public static function displayTo(string $id, $value) + public static function displayTo(string $id, $value): void { } @@ -274,7 +288,7 @@ public static function getDocType(): string * Obtains the 'escaper' service if required * * @param array $params - * @return \Phalcon\Escaper\EscaperInterface|null + * @return EscaperInterface|null */ public static function getEscaper(array $params): ?EscaperInterface { @@ -334,7 +348,7 @@ public static function getUrlService(): UrlInterface * @param mixed $name * @param array $params */ - public static function getValue($name, array $params = array()) + public static function getValue($name, array $params = []) { } @@ -485,10 +499,10 @@ public static function passwordField($parameters): string /** * Prepends a text to current document title * - * @param mixed $title + * @param array|string $title * @return void */ - public static function prependTitle($title) + public static function prependTitle($title): void { } @@ -575,7 +589,7 @@ public static function renderTitle(bool $prepend = true, bool $append = true): s * @deprecated * @return void */ - public static function resetInput() + public static function resetInput(): void { } @@ -637,7 +651,7 @@ public static function selectStatic($parameters, $data = null): string * @param bool $autoescape * @return void */ - public static function setAutoescape(bool $autoescape) + public static function setAutoescape(bool $autoescape): void { } @@ -648,7 +662,7 @@ public static function setAutoescape(bool $autoescape) * @param mixed $value * @return void */ - public static function setDefault(string $id, $value) + public static function setDefault(string $id, $value): void { } @@ -659,7 +673,7 @@ public static function setDefault(string $id, $value) * @param bool $merge * @return void */ - public static function setDefaults(array $values, bool $merge = false) + public static function setDefaults(array $values, bool $merge = false): void { } @@ -669,7 +683,7 @@ public static function setDefaults(array $values, bool $merge = false) * @param \Phalcon\Di\DiInterface $container * @return void */ - public static function setDI(\Phalcon\Di\DiInterface $container) + public static function setDI(\Phalcon\Di\DiInterface $container): void { } @@ -679,7 +693,7 @@ public static function setDI(\Phalcon\Di\DiInterface $container) * @param int $doctype * @return void */ - public static function setDocType(int $doctype) + public static function setDocType(int $doctype): void { } @@ -689,7 +703,7 @@ public static function setDocType(int $doctype) * @param string $title * @return void */ - public static function setTitle(string $title) + public static function setTitle(string $title): void { } @@ -699,7 +713,7 @@ public static function setTitle(string $title) * @param string $titleSeparator * @return void */ - public static function setTitleSeparator(string $titleSeparator) + public static function setTitleSeparator(string $titleSeparator): void { } diff --git a/src/Phalcon/Tag/Exception.php b/src/Tag/Exception.php similarity index 100% rename from src/Phalcon/Tag/Exception.php rename to src/Tag/Exception.php diff --git a/src/Phalcon/Tag/Select.php b/src/Tag/Select.php similarity index 100% rename from src/Phalcon/Tag/Select.php rename to src/Tag/Select.php diff --git a/src/Phalcon/Text.php b/src/Text.php similarity index 99% rename from src/Phalcon/Text.php rename to src/Text.php index 9b174342..fdb0bb09 100644 --- a/src/Phalcon/Text.php +++ b/src/Text.php @@ -9,8 +9,6 @@ */ namespace Phalcon; -use Phalcon\Helper\Str; - /** * Provides utilities to work with texts */ @@ -73,7 +71,6 @@ public static function camelize(string $text, $delimiter = null): string * @param string $a * @param string $b * @param string ...N - * @param string ...N * @return string */ public static function concat(): string @@ -208,7 +205,6 @@ public static function startsWith(string $text, string $start, bool $ignoreCase * * @param int $type * @param int $length - * * @return string */ public static function random(int $type = 0, int $length = 8): string diff --git a/src/Phalcon/Translate/Adapter/AbstractAdapter.php b/src/Translate/Adapter/AbstractAdapter.php similarity index 93% rename from src/Phalcon/Translate/Adapter/AbstractAdapter.php rename to src/Translate/Adapter/AbstractAdapter.php index 5c2cb5c4..346083ed 100644 --- a/src/Phalcon/Translate/Adapter/AbstractAdapter.php +++ b/src/Translate/Adapter/AbstractAdapter.php @@ -44,7 +44,7 @@ public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator * @param string $translateKey * @return string */ - public function _(string $translateKey, array $placeholders = array()): string + public function _(string $translateKey, array $placeholders = []): string { } @@ -75,7 +75,7 @@ public function offsetGet($translateKey) * @param mixed $offset * @return void */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { } @@ -85,7 +85,7 @@ public function offsetSet($offset, $value) * @param mixed $offset * @return void */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { } @@ -96,7 +96,7 @@ public function offsetUnset($offset) * @param string $translateKey * @return string */ - public function t(string $translateKey, array $placeholders = array()): string + public function t(string $translateKey, array $placeholders = []): string { } @@ -107,7 +107,7 @@ public function t(string $translateKey, array $placeholders = array()): string * @param array $placeholders * @return string */ - protected function replacePlaceholders(string $translation, array $placeholders = array()): string + protected function replacePlaceholders(string $translation, array $placeholders = []): string { } } diff --git a/src/Phalcon/Translate/Adapter/AdapterInterface.php b/src/Translate/Adapter/AdapterInterface.php similarity index 96% rename from src/Phalcon/Translate/Adapter/AdapterInterface.php rename to src/Translate/Adapter/AdapterInterface.php index 214bb99f..1c05a9db 100644 --- a/src/Phalcon/Translate/Adapter/AdapterInterface.php +++ b/src/Translate/Adapter/AdapterInterface.php @@ -32,7 +32,7 @@ public function exists(string $index): bool; * @param string $translateKey * @return string */ - public function query(string $translateKey, array $placeholders = array()): string; + public function query(string $translateKey, array $placeholders = []): string; /** * Returns the translation string of the given key @@ -41,5 +41,5 @@ public function query(string $translateKey, array $placeholders = array()): stri * @param string $translateKey * @return string */ - public function t(string $translateKey, array $placeholders = array()): string; + public function t(string $translateKey, array $placeholders = []): string; } diff --git a/src/Phalcon/Translate/Adapter/Csv.php b/src/Translate/Adapter/Csv.php similarity index 89% rename from src/Phalcon/Translate/Adapter/Csv.php rename to src/Translate/Adapter/Csv.php index 73fb0ccf..dd16753c 100644 --- a/src/Phalcon/Translate/Adapter/Csv.php +++ b/src/Translate/Adapter/Csv.php @@ -19,7 +19,7 @@ class Csv extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAc /** * @var array */ - protected $translate = array(); + protected $translate = []; /** @@ -49,11 +49,11 @@ public function exists(string $index): bool /** * Returns the translation related to the given key * - * @param string $index + * @param string $translateKey * @param array $placeholders * @return string */ - public function query(string $index, array $placeholders = array()): string + public function query(string $translateKey, array $placeholders = []): string { } @@ -66,7 +66,7 @@ public function query(string $index, array $placeholders = array()): string * @param string $enclosure * @return void */ - private function load(string $file, int $length, string $delimiter, string $enclosure) + private function load(string $file, int $length, string $delimiter, string $enclosure): void { } } diff --git a/src/Phalcon/Translate/Adapter/Gettext.php b/src/Translate/Adapter/Gettext.php similarity index 90% rename from src/Phalcon/Translate/Adapter/Gettext.php rename to src/Translate/Adapter/Gettext.php index 16c33aca..11bfe81c 100644 --- a/src/Phalcon/Translate/Adapter/Gettext.php +++ b/src/Translate/Adapter/Gettext.php @@ -115,7 +115,7 @@ public function exists(string $index): bool * @param string $domain * @return string */ - public function nquery(string $msgid1, string $msgid2, int $count, array $placeholders = array(), string $domain = null): string + public function nquery(string $msgid1, string $msgid2, int $count, array $placeholders = [], string $domain = null): string { } @@ -126,11 +126,11 @@ public function nquery(string $msgid1, string $msgid2, int $count, array $placeh * $translator->query("你好 %name%!", ["name" => "Phalcon"]); * ``` * + * @param string $translateKey * @param array $placeholders - * @param string $index * @return string */ - public function query(string $index, array $placeholders = array()): string + public function query(string $translateKey, array $placeholders = []): string { } @@ -149,7 +149,7 @@ public function resetDomain(): string * @param string $domain * @return void */ - public function setDefaultDomain(string $domain) + public function setDefaultDomain(string $domain): void { } @@ -172,7 +172,7 @@ public function setDefaultDomain(string $domain) * @param string|array $directory The directory path or an array of directories and domains * @return void */ - public function setDirectory($directory) + public function setDirectory($directory): void { } @@ -198,10 +198,10 @@ public function setDomain($domain): string * ``` * * @param int $category - * @param string $locale + * @param array $localeArray * @return string|bool */ - public function setLocale(int $category, string $locale) + public function setLocale(int $category, array $localeArray = []) { } @@ -220,7 +220,7 @@ protected function getOptionsDefault(): array * @param array $options * @return void */ - protected function prepareOptions(array $options) + protected function prepareOptions(array $options): void { } } diff --git a/src/Phalcon/Translate/Adapter/NativeArray.php b/src/Translate/Adapter/NativeArray.php similarity index 86% rename from src/Phalcon/Translate/Adapter/NativeArray.php rename to src/Translate/Adapter/NativeArray.php index 8bb8e759..49ec0fb6 100644 --- a/src/Phalcon/Translate/Adapter/NativeArray.php +++ b/src/Translate/Adapter/NativeArray.php @@ -9,10 +9,6 @@ */ namespace Phalcon\Translate\Adapter; -use ArrayAccess; -use Phalcon\Translate\Exception; -use Phalcon\Translate\InterpolatorFactory; - /** * Phalcon\Translate\Adapter\NativeArray * @@ -23,7 +19,7 @@ class NativeArray extends \Phalcon\Translate\Adapter\AbstractAdapter implements /** * @var array */ - private $translate; + private $translate = []; /** * @var bool @@ -67,11 +63,11 @@ public function notFound(string $index): string /** * Returns the translation related to the given key * - * @param string $index + * @param string $translateKey * @param array $placeholders * @return string */ - public function query(string $index, array $placeholders = array()): string + public function query(string $translateKey, array $placeholders = []): string { } } diff --git a/src/Phalcon/Translate/Exception.php b/src/Translate/Exception.php similarity index 100% rename from src/Phalcon/Translate/Exception.php rename to src/Translate/Exception.php diff --git a/src/Phalcon/Translate/Interpolator/AssociativeArray.php b/src/Translate/Interpolator/AssociativeArray.php similarity index 95% rename from src/Phalcon/Translate/Interpolator/AssociativeArray.php rename to src/Translate/Interpolator/AssociativeArray.php index ea3aad8e..2b08dc89 100644 --- a/src/Phalcon/Translate/Interpolator/AssociativeArray.php +++ b/src/Translate/Interpolator/AssociativeArray.php @@ -27,7 +27,7 @@ class AssociativeArray implements \Phalcon\Translate\Interpolator\InterpolatorIn * @param array $placeholders * @return string */ - public function replacePlaceholders(string $translation, array $placeholders = array()): string + public function replacePlaceholders(string $translation, array $placeholders = []): string { } } diff --git a/src/Phalcon/Translate/Interpolator/IndexedArray.php b/src/Translate/Interpolator/IndexedArray.php similarity index 95% rename from src/Phalcon/Translate/Interpolator/IndexedArray.php rename to src/Translate/Interpolator/IndexedArray.php index d363ba26..3aee4701 100644 --- a/src/Phalcon/Translate/Interpolator/IndexedArray.php +++ b/src/Translate/Interpolator/IndexedArray.php @@ -27,7 +27,7 @@ class IndexedArray implements \Phalcon\Translate\Interpolator\InterpolatorInterf * @param array $placeholders * @return string */ - public function replacePlaceholders(string $translation, array $placeholders = array()): string + public function replacePlaceholders(string $translation, array $placeholders = []): string { } } diff --git a/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php b/src/Translate/Interpolator/InterpolatorInterface.php similarity index 94% rename from src/Phalcon/Translate/Interpolator/InterpolatorInterface.php rename to src/Translate/Interpolator/InterpolatorInterface.php index e3ab9ade..8ce2faa3 100644 --- a/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php +++ b/src/Translate/Interpolator/InterpolatorInterface.php @@ -24,5 +24,5 @@ interface InterpolatorInterface * @param array $placeholders * @return string */ - public function replacePlaceholders(string $translation, array $placeholders = array()): string; + public function replacePlaceholders(string $translation, array $placeholders = []): string; } diff --git a/src/Phalcon/Translate/InterpolatorFactory.php b/src/Translate/InterpolatorFactory.php similarity index 89% rename from src/Phalcon/Translate/InterpolatorFactory.php rename to src/Translate/InterpolatorFactory.php index cff10ad8..07431b32 100644 --- a/src/Phalcon/Translate/InterpolatorFactory.php +++ b/src/Translate/InterpolatorFactory.php @@ -23,12 +23,15 @@ class InterpolatorFactory extends AbstractFactory { + protected $exception = 'Phalcon\\\\Translate\\\\Exception'; + + /** * AdapterFactory constructor. * * @param array $services */ - public function __construct(array $services = array()) + public function __construct(array $services = []) { } diff --git a/src/Phalcon/Translate/TranslateFactory.php b/src/Translate/TranslateFactory.php similarity index 75% rename from src/Phalcon/Translate/TranslateFactory.php rename to src/Translate/TranslateFactory.php index 14351a5b..bbbc47a0 100644 --- a/src/Phalcon/Translate/TranslateFactory.php +++ b/src/Translate/TranslateFactory.php @@ -9,9 +9,7 @@ */ namespace Phalcon\Translate; -use Phalcon\Config; use Phalcon\Factory\AbstractFactory; -use Phalcon\Helper\Arr; use Phalcon\Translate\Adapter\AdapterInterface; /** @@ -24,6 +22,9 @@ */ class TranslateFactory extends AbstractFactory { + + protected $exception = 'Phalcon\\\\Translate\\\\Exception'; + /** * @var InterpolatorFactory */ @@ -36,7 +37,7 @@ class TranslateFactory extends AbstractFactory * @param InterpolatorFactory $interpolator * @param array $services */ - public function __construct(InterpolatorFactory $interpolator, array $services = array()) + public function __construct(InterpolatorFactory $interpolator, array $services = []) { } @@ -57,19 +58,6 @@ public function __construct(InterpolatorFactory $interpolator, array $services = * ] * ] * @param mixed $config - * @param array|\Phalcon\Config = [ - * 'adapter' => 'ini, - * 'options' => [ - * 'content' => '', - * 'delimiter' => ';', - * 'enclosure' => '"', - * 'locale' => '', - * 'defaultDomain' => '', - * 'directory' => '', - * 'category' => '' - * 'triggerError' => false - * ] - * ] * @return mixed */ public function load($config) @@ -83,7 +71,7 @@ public function load($config) * @param array $options * @return AdapterInterface */ - public function newInstance(string $name, array $options = array()): AdapterInterface + public function newInstance(string $name, array $options = []): AdapterInterface { } diff --git a/src/Phalcon/Url.php b/src/Url.php similarity index 97% rename from src/Phalcon/Url.php rename to src/Url.php index 9d0d767e..86b152e2 100644 --- a/src/Phalcon/Url.php +++ b/src/Url.php @@ -9,11 +9,8 @@ */ namespace Phalcon; -use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Mvc\RouterInterface; -use Phalcon\Mvc\Router\RouteInterface; -use Phalcon\Url\Exception; use Phalcon\Url\UrlInterface; /** diff --git a/src/Phalcon/Url/Exception.php b/src/Url/Exception.php similarity index 100% rename from src/Phalcon/Url/Exception.php rename to src/Url/Exception.php diff --git a/src/Phalcon/Url/UrlInterface.php b/src/Url/UrlInterface.php similarity index 100% rename from src/Phalcon/Url/UrlInterface.php rename to src/Url/UrlInterface.php diff --git a/src/Phalcon/Validation.php b/src/Validation.php similarity index 76% rename from src/Phalcon/Validation.php rename to src/Validation.php index 6d8d3836..d8d1e746 100644 --- a/src/Phalcon/Validation.php +++ b/src/Validation.php @@ -9,55 +9,75 @@ */ namespace Phalcon; -use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; -use Phalcon\Filter\FilterInterface; use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; use Phalcon\Validation\ValidationInterface; -use Phalcon\Validation\Exception; use Phalcon\Validation\ValidatorInterface; -use Phalcon\Validation\AbstractCombinedFieldsValidator; /** * Allows to validate data using custom or built-in validators */ class Validation extends Injectable implements \Phalcon\Validation\ValidationInterface { + /** + * @var array + */ + protected $combinedFieldsValidators = []; - protected $combinedFieldsValidators; - - + /** + * @var mixed + */ protected $data; + /** + * @var object|null + */ + protected $entity = null; - protected $entity; - - - protected $filters = array(); - - - protected $labels = array(); - - - protected $messages; - + /** + * @var array + */ + protected $filters = []; - protected $validators; + /** + * @var array + */ + protected $labels = []; + /** + * @var Messages|null + */ + protected $messages = null; - protected $values; + /** + * List of validators + * + * @var array + */ + protected $validators = []; + /** + * Calculated values + * + * @var array + */ + protected $values = []; + /** + * @return mixed + */ public function getData() { } /** - * @param mixed $validators + * List of validators + * + * @param array $validators */ - public function setValidators($validators) + public function setValidators(array $validators) { } @@ -66,15 +86,16 @@ public function setValidators($validators) * * @param array $validators */ - public function __construct(array $validators = array()) + public function __construct(array $validators = []) { } /** * Adds a validator to a field * - * @param mixed $field - * @param \Phalcon\Validation\ValidatorInterface $validator + * @param string|array $field + * @param ValidatorInterface $validator + * * @return ValidationInterface */ public function add($field, \Phalcon\Validation\ValidatorInterface $validator): ValidationInterface @@ -84,7 +105,7 @@ public function add($field, \Phalcon\Validation\ValidatorInterface $validator): /** * Appends a message to the messages list * - * @param \Phalcon\Messages\MessageInterface $message + * @param MessageInterface $message * @return ValidationInterface */ public function appendMessage(\Phalcon\Messages\MessageInterface $message): ValidationInterface @@ -163,8 +184,9 @@ public function getValue(string $field) /** * Alias of `add` method * - * @param mixed $field - * @param \Phalcon\Validation\ValidatorInterface $validator + * @param string|array $field + * @param ValidatorInterface $validator + * * @return ValidationInterface */ public function rule($field, \Phalcon\Validation\ValidatorInterface $validator): ValidationInterface @@ -188,7 +210,7 @@ public function rules($field, array $validators): ValidationInterface * @param object $entity * @return void */ - public function setEntity($entity) + public function setEntity($entity): void { } @@ -209,7 +231,7 @@ public function setFilters($field, $filters): ValidationInterface * @param array $labels * @return void */ - public function setLabels(array $labels) + public function setLabels(array $labels): void { } @@ -227,8 +249,8 @@ public function validate($data = null, $entity = null): Messages /** * Internal validations, if it returns true, then skip the current validator * - * @param mixed $field - * @param \Phalcon\Validation\ValidatorInterface $validator + * @param array|string $field + * @param ValidatorInterface $validator * @return bool */ protected function preChecking($field, \Phalcon\Validation\ValidatorInterface $validator): bool diff --git a/src/Phalcon/Validation/AbstractCombinedFieldsValidator.php b/src/Validation/AbstractCombinedFieldsValidator.php similarity index 100% rename from src/Phalcon/Validation/AbstractCombinedFieldsValidator.php rename to src/Validation/AbstractCombinedFieldsValidator.php diff --git a/src/Phalcon/Validation/AbstractValidator.php b/src/Validation/AbstractValidator.php similarity index 91% rename from src/Phalcon/Validation/AbstractValidator.php rename to src/Validation/AbstractValidator.php index 92f00e49..dd2beffe 100644 --- a/src/Phalcon/Validation/AbstractValidator.php +++ b/src/Validation/AbstractValidator.php @@ -21,17 +21,19 @@ abstract class AbstractValidator implements \Phalcon\Validation\ValidatorInterfa * * @var string|null */ - protected $template; + protected $template = null; /** * Message templates * * @var array */ - protected $templates = array(); + protected $templates = []; - - protected $options; + /** + * @var array + */ + protected $options = []; /** @@ -39,7 +41,7 @@ abstract class AbstractValidator implements \Phalcon\Validation\ValidatorInterfa * * @param array $options */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } @@ -112,7 +114,7 @@ public function hasOption(string $key): bool * @param mixed $value * @return void */ - public function setOption(string $key, $value) + public function setOption(string $key, $value): void { } @@ -156,7 +158,7 @@ protected function prepareLabel(\Phalcon\Validation $validation, string $field) * @param mixed $field * @param array $replacements */ - public function messageFactory(\Phalcon\Validation $validation, $field, array $replacements = array()): Message + public function messageFactory(\Phalcon\Validation $validation, $field, array $replacements = []): Message { } } diff --git a/src/Phalcon/Validation/AbstractValidatorComposite.php b/src/Validation/AbstractValidatorComposite.php similarity index 95% rename from src/Phalcon/Validation/AbstractValidatorComposite.php rename to src/Validation/AbstractValidatorComposite.php index b1180f8d..cc4957be 100644 --- a/src/Phalcon/Validation/AbstractValidatorComposite.php +++ b/src/Validation/AbstractValidatorComposite.php @@ -17,7 +17,7 @@ abstract class AbstractValidatorComposite extends \Phalcon\Validation\AbstractVa /** * @var array */ - protected $validators = array(); + protected $validators = []; /** diff --git a/src/Phalcon/Validation/Exception.php b/src/Validation/Exception.php similarity index 100% rename from src/Phalcon/Validation/Exception.php rename to src/Validation/Exception.php diff --git a/src/Phalcon/Validation/ValidationInterface.php b/src/Validation/ValidationInterface.php similarity index 89% rename from src/Phalcon/Validation/ValidationInterface.php rename to src/Validation/ValidationInterface.php index 517fb752..5eb0bd1a 100644 --- a/src/Phalcon/Validation/ValidationInterface.php +++ b/src/Validation/ValidationInterface.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Validation; -use Phalcon\Di\Injectable; -use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; /** @@ -22,11 +20,11 @@ interface ValidationInterface /** * Adds a validator to a field * - * @param string $field + * @param string|array $field * @param ValidatorInterface $validator * @return ValidationInterface */ - public function add(string $field, ValidatorInterface $validator): ValidationInterface; + public function add($field, ValidatorInterface $validator): ValidationInterface; /** * Appends a message to the messages list @@ -94,11 +92,11 @@ public function getValue(string $field); /** * Alias of `add` method * - * @param string $field + * @param string|array $field * @param ValidatorInterface $validator * @return ValidationInterface */ - public function rule(string $field, ValidatorInterface $validator): ValidationInterface; + public function rule($field, ValidatorInterface $validator): ValidationInterface; /** * Adds the validators to a field @@ -124,7 +122,7 @@ public function setFilters(string $field, $filters): ValidationInterface; * @param array $labels * @return void */ - public function setLabels(array $labels); + public function setLabels(array $labels): void; /** * Validate a set of data according to a set of rules diff --git a/src/Phalcon/Validation/Validator/Alnum.php b/src/Validation/Validator/Alnum.php similarity index 96% rename from src/Phalcon/Validation/Validator/Alnum.php rename to src/Validation/Validator/Alnum.php index 342fdb1c..2e39dedc 100644 --- a/src/Phalcon/Validation/Validator/Alnum.php +++ b/src/Validation/Validator/Alnum.php @@ -60,7 +60,7 @@ class Alnum extends AbstractValidator * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/Alpha.php b/src/Validation/Validator/Alpha.php similarity index 96% rename from src/Phalcon/Validation/Validator/Alpha.php rename to src/Validation/Validator/Alpha.php index 8459a1e4..03a7502f 100644 --- a/src/Phalcon/Validation/Validator/Alpha.php +++ b/src/Validation/Validator/Alpha.php @@ -60,7 +60,7 @@ class Alpha extends AbstractValidator * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/Between.php b/src/Validation/Validator/Between.php similarity index 97% rename from src/Phalcon/Validation/Validator/Between.php rename to src/Validation/Validator/Between.php index 5582b835..eb743d2d 100644 --- a/src/Phalcon/Validation/Validator/Between.php +++ b/src/Validation/Validator/Between.php @@ -73,7 +73,7 @@ class Between extends AbstractValidator * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/Callback.php b/src/Validation/Validator/Callback.php similarity index 97% rename from src/Phalcon/Validation/Validator/Callback.php rename to src/Validation/Validator/Callback.php index 6bbe556a..8a170eae 100644 --- a/src/Phalcon/Validation/Validator/Callback.php +++ b/src/Validation/Validator/Callback.php @@ -71,7 +71,7 @@ class Callback extends AbstractValidator * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/Confirmation.php b/src/Validation/Validator/Confirmation.php similarity index 97% rename from src/Phalcon/Validation/Validator/Confirmation.php rename to src/Validation/Validator/Confirmation.php index 33e22044..d8be81aa 100644 --- a/src/Phalcon/Validation/Validator/Confirmation.php +++ b/src/Validation/Validator/Confirmation.php @@ -68,7 +68,7 @@ class Confirmation extends AbstractValidator * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/CreditCard.php b/src/Validation/Validator/CreditCard.php similarity index 97% rename from src/Phalcon/Validation/Validator/CreditCard.php rename to src/Validation/Validator/CreditCard.php index 17c60812..7b798741 100644 --- a/src/Phalcon/Validation/Validator/CreditCard.php +++ b/src/Validation/Validator/CreditCard.php @@ -60,7 +60,7 @@ class CreditCard extends AbstractValidator * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/Date.php b/src/Validation/Validator/Date.php similarity index 97% rename from src/Phalcon/Validation/Validator/Date.php rename to src/Validation/Validator/Date.php index 43d15351..37b084e0 100644 --- a/src/Phalcon/Validation/Validator/Date.php +++ b/src/Validation/Validator/Date.php @@ -66,7 +66,7 @@ class Date extends AbstractValidator * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/Digit.php b/src/Validation/Validator/Digit.php similarity index 96% rename from src/Phalcon/Validation/Validator/Digit.php rename to src/Validation/Validator/Digit.php index 56873037..5af0ffc7 100644 --- a/src/Phalcon/Validation/Validator/Digit.php +++ b/src/Validation/Validator/Digit.php @@ -60,7 +60,7 @@ class Digit extends AbstractValidator * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/Email.php b/src/Validation/Validator/Email.php similarity index 96% rename from src/Phalcon/Validation/Validator/Email.php rename to src/Validation/Validator/Email.php index dde2b525..f019b2f5 100644 --- a/src/Phalcon/Validation/Validator/Email.php +++ b/src/Validation/Validator/Email.php @@ -60,7 +60,7 @@ class Email extends AbstractValidator * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/Exception.php b/src/Validation/Validator/Exception.php similarity index 100% rename from src/Phalcon/Validation/Validator/Exception.php rename to src/Validation/Validator/Exception.php diff --git a/src/Phalcon/Validation/Validator/ExclusionIn.php b/src/Validation/Validator/ExclusionIn.php similarity index 97% rename from src/Phalcon/Validation/Validator/ExclusionIn.php rename to src/Validation/Validator/ExclusionIn.php index 8d6991d0..6a327382 100644 --- a/src/Phalcon/Validation/Validator/ExclusionIn.php +++ b/src/Validation/Validator/ExclusionIn.php @@ -73,7 +73,7 @@ class ExclusionIn extends AbstractValidator * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/File.php b/src/Validation/Validator/File.php similarity index 98% rename from src/Phalcon/Validation/Validator/File.php rename to src/Validation/Validator/File.php index 750903ee..f050b47d 100644 --- a/src/Phalcon/Validation/Validator/File.php +++ b/src/Validation/Validator/File.php @@ -106,7 +106,7 @@ class File extends AbstractValidatorComposite * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } } diff --git a/src/Phalcon/Validation/Validator/File/AbstractFile.php b/src/Validation/Validator/File/AbstractFile.php similarity index 79% rename from src/Phalcon/Validation/Validator/File/AbstractFile.php rename to src/Validation/Validator/File/AbstractFile.php index 8e824bf9..671c4f20 100644 --- a/src/Phalcon/Validation/Validator/File/AbstractFile.php +++ b/src/Validation/Validator/File/AbstractFile.php @@ -55,76 +55,77 @@ abstract class AbstractFile extends AbstractValidator { /** * Empty is empty + * + * @var string */ protected $messageFileEmpty = 'Field :field must not be empty'; /** * File exceeds the file size set in PHP configuration + * + * @var string */ protected $messageIniSize = 'File :field exceeds the maximum file size'; /** * File is not valid + * + * @var string */ protected $messageValid = 'Field :field is not valid'; /** * Empty is empty + * + * @return string */ - public function getMessageFileEmpty() + public function getMessageFileEmpty(): string { } /** * Empty is empty * - * @param mixed $messageFileEmpty + * @param string $messageFileEmpty */ - public function setMessageFileEmpty($messageFileEmpty) + public function setMessageFileEmpty(string $messageFileEmpty) { } /** * File exceeds the file size set in PHP configuration + * + * @return string */ - public function getMessageIniSize() + public function getMessageIniSize(): string { } /** * File exceeds the file size set in PHP configuration * - * @param mixed $messageIniSize - */ - public function setMessageIniSize($messageIniSize) - { - } - - /** - * File is not valid + * @param string $messageIniSize */ - public function getMessageValid() + public function setMessageIniSize(string $messageIniSize) { } /** * File is not valid * - * @param mixed $messageValid + * @return string */ - public function setMessageValid($messageValid) + public function getMessageValid(): string { } /** - * Check on empty + * File is not valid * - * @param Validation $validation - * @param string $field - * @return bool + * @param string $messageValid */ - public function isAllowEmpty(\Phalcon\Validation $validation, string $field): bool + public function setMessageValid(string $messageValid) { } @@ -140,35 +141,35 @@ public function checkUpload(\Phalcon\Validation $validation, $field): bool } /** - * Check if uploaded file is larger than PHP allowed size + * Check if upload is empty * * @param Validation $validation * @param mixed $field * @return boolean */ - public function checkUploadMaxSize(\Phalcon\Validation $validation, $field): bool + public function checkUploadIsEmpty(\Phalcon\Validation $validation, $field): bool { } /** - * Check if upload is empty + * Check if upload is valid * * @param Validation $validation * @param mixed $field * @return boolean */ - public function checkUploadIsEmpty(\Phalcon\Validation $validation, $field): bool + public function checkUploadIsValid(\Phalcon\Validation $validation, $field): bool { } /** - * Check if upload is valid + * Check if uploaded file is larger than PHP allowed size * * @param Validation $validation * @param mixed $field * @return boolean */ - public function checkUploadIsValid(\Phalcon\Validation $validation, $field): bool + public function checkUploadMaxSize(\Phalcon\Validation $validation, $field): bool { } @@ -181,4 +182,26 @@ public function checkUploadIsValid(\Phalcon\Validation $validation, $field): boo public function getFileSizeInBytes(string $size): float { } + + /** + * Check on empty + * + * @param Validation $validation + * @param string $field + * @return bool + */ + public function isAllowEmpty(\Phalcon\Validation $validation, string $field): bool + { + } + + /** + * Checks if a file has been uploaded; Internal check that can be + * overriden in a subclass if you do not want to check uploaded files + * + * @param string $name + * @return bool + */ + protected function checkIsUploadedFile(string $name): bool + { + } } diff --git a/src/Phalcon/Validation/Validator/File/MimeType.php b/src/Validation/Validator/File/MimeType.php similarity index 96% rename from src/Phalcon/Validation/Validator/File/MimeType.php rename to src/Validation/Validator/File/MimeType.php index 60cb7c75..443c35bd 100644 --- a/src/Phalcon/Validation/Validator/File/MimeType.php +++ b/src/Validation/Validator/File/MimeType.php @@ -9,9 +9,7 @@ */ namespace Phalcon\Validation\Validator\File; -use Phalcon\Messages\Message; use Phalcon\Validation; -use Phalcon\Validation\Exception; /** * Checks if a value has a correct file mime type diff --git a/src/Phalcon/Validation/Validator/File/Resolution/Equal.php b/src/Validation/Validator/File/Resolution/Equal.php similarity index 96% rename from src/Phalcon/Validation/Validator/File/Resolution/Equal.php rename to src/Validation/Validator/File/Resolution/Equal.php index 00c22fa6..a9994fe3 100644 --- a/src/Phalcon/Validation/Validator/File/Resolution/Equal.php +++ b/src/Validation/Validator/File/Resolution/Equal.php @@ -65,7 +65,7 @@ class Equal extends AbstractFile * 'resolution' => '1000x1000' * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/File/Resolution/Max.php b/src/Validation/Validator/File/Resolution/Max.php similarity index 94% rename from src/Phalcon/Validation/Validator/File/Resolution/Max.php rename to src/Validation/Validator/File/Resolution/Max.php index f81a4d7b..a031a582 100644 --- a/src/Phalcon/Validation/Validator/File/Resolution/Max.php +++ b/src/Validation/Validator/File/Resolution/Max.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Validation\Validator\File\Resolution; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -73,7 +71,7 @@ class Max extends AbstractFile * 'included' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/File/Resolution/Min.php b/src/Validation/Validator/File/Resolution/Min.php similarity index 94% rename from src/Phalcon/Validation/Validator/File/Resolution/Min.php rename to src/Validation/Validator/File/Resolution/Min.php index 70d9310d..d7afd978 100644 --- a/src/Phalcon/Validation/Validator/File/Resolution/Min.php +++ b/src/Validation/Validator/File/Resolution/Min.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Validation\Validator\File\Resolution; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -73,7 +71,7 @@ class Min extends AbstractFile * 'included' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/File/Size/Equal.php b/src/Validation/Validator/File/Size/Equal.php similarity index 97% rename from src/Phalcon/Validation/Validator/File/Size/Equal.php rename to src/Validation/Validator/File/Size/Equal.php index 1ac14551..d6a477d4 100644 --- a/src/Phalcon/Validation/Validator/File/Size/Equal.php +++ b/src/Validation/Validator/File/Size/Equal.php @@ -70,7 +70,7 @@ class Equal extends AbstractFile * 'size' => '2.5MB' * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/File/Size/Max.php b/src/Validation/Validator/File/Size/Max.php similarity index 94% rename from src/Phalcon/Validation/Validator/File/Size/Max.php rename to src/Validation/Validator/File/Size/Max.php index 8d03e1eb..1c4b605f 100644 --- a/src/Phalcon/Validation/Validator/File/Size/Max.php +++ b/src/Validation/Validator/File/Size/Max.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Validation\Validator\File\Size; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -73,7 +71,7 @@ class Max extends AbstractFile * 'included' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/File/Size/Min.php b/src/Validation/Validator/File/Size/Min.php similarity index 94% rename from src/Phalcon/Validation/Validator/File/Size/Min.php rename to src/Validation/Validator/File/Size/Min.php index edcc366c..435d6efa 100644 --- a/src/Phalcon/Validation/Validator/File/Size/Min.php +++ b/src/Validation/Validator/File/Size/Min.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Validation\Validator\File\Size; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -73,7 +71,7 @@ class Min extends AbstractFile * 'included' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/Identical.php b/src/Validation/Validator/Identical.php similarity index 96% rename from src/Phalcon/Validation/Validator/Identical.php rename to src/Validation/Validator/Identical.php index 62828f50..2af3ab03 100644 --- a/src/Phalcon/Validation/Validator/Identical.php +++ b/src/Validation/Validator/Identical.php @@ -67,7 +67,7 @@ class Identical extends AbstractValidator * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/InclusionIn.php b/src/Validation/Validator/InclusionIn.php similarity index 96% rename from src/Phalcon/Validation/Validator/InclusionIn.php rename to src/Validation/Validator/InclusionIn.php index 5ee64b88..9eb236e9 100644 --- a/src/Phalcon/Validation/Validator/InclusionIn.php +++ b/src/Validation/Validator/InclusionIn.php @@ -67,7 +67,7 @@ class InclusionIn extends AbstractValidator * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/Ip.php b/src/Validation/Validator/Ip.php similarity index 97% rename from src/Phalcon/Validation/Validator/Ip.php rename to src/Validation/Validator/Ip.php index 9949603b..1841f54e 100644 --- a/src/Phalcon/Validation/Validator/Ip.php +++ b/src/Validation/Validator/Ip.php @@ -85,7 +85,7 @@ class Ip extends AbstractValidator * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/Numericality.php b/src/Validation/Validator/Numericality.php similarity index 93% rename from src/Phalcon/Validation/Validator/Numericality.php rename to src/Validation/Validator/Numericality.php index 0dbffa5e..66db4678 100644 --- a/src/Phalcon/Validation/Validator/Numericality.php +++ b/src/Validation/Validator/Numericality.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -62,7 +60,7 @@ class Numericality extends AbstractValidator * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/PresenceOf.php b/src/Validation/Validator/PresenceOf.php similarity index 93% rename from src/Phalcon/Validation/Validator/PresenceOf.php rename to src/Validation/Validator/PresenceOf.php index 86fee665..a6f9edf4 100644 --- a/src/Phalcon/Validation/Validator/PresenceOf.php +++ b/src/Validation/Validator/PresenceOf.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -62,7 +60,7 @@ class PresenceOf extends AbstractValidator * 'allowEmpty' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/Regex.php b/src/Validation/Validator/Regex.php similarity index 94% rename from src/Phalcon/Validation/Validator/Regex.php rename to src/Validation/Validator/Regex.php index 20c406ea..432af3ca 100644 --- a/src/Phalcon/Validation/Validator/Regex.php +++ b/src/Validation/Validator/Regex.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -68,7 +66,7 @@ class Regex extends AbstractValidator * 'pattern' => '' * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/StringLength.php b/src/Validation/Validator/StringLength.php similarity index 90% rename from src/Phalcon/Validation/Validator/StringLength.php rename to src/Validation/Validator/StringLength.php index 8772ca8d..eb4b0460 100644 --- a/src/Phalcon/Validation/Validator/StringLength.php +++ b/src/Validation/Validator/StringLength.php @@ -9,12 +9,7 @@ */ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation\AbstractValidator; use Phalcon\Validation\AbstractValidatorComposite; -use Phalcon\Validation\Validator\StringLength\Max; -use Phalcon\Validation\Validator\StringLength\Min; -use Phalcon\Validation\Exception; /** * Validates that a string has the specified maximum and minimum constraints @@ -95,7 +90,7 @@ class StringLength extends AbstractValidatorComposite * 'includedMaximum' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } } diff --git a/src/Phalcon/Validation/Validator/StringLength/Max.php b/src/Validation/Validator/StringLength/Max.php similarity index 93% rename from src/Phalcon/Validation/Validator/StringLength/Max.php rename to src/Validation/Validator/StringLength/Max.php index 496c4100..8e38b435 100644 --- a/src/Phalcon/Validation/Validator/StringLength/Max.php +++ b/src/Validation/Validator/StringLength/Max.php @@ -9,10 +9,7 @@ */ namespace Phalcon\Validation\Validator\StringLength; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\Exception; /** * Validates that a string has the specified maximum constraints @@ -77,7 +74,7 @@ class Max extends AbstractValidator * 'included' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/StringLength/Min.php b/src/Validation/Validator/StringLength/Min.php similarity index 93% rename from src/Phalcon/Validation/Validator/StringLength/Min.php rename to src/Validation/Validator/StringLength/Min.php index 3e61bb04..fbcad109 100644 --- a/src/Phalcon/Validation/Validator/StringLength/Min.php +++ b/src/Validation/Validator/StringLength/Min.php @@ -9,10 +9,7 @@ */ namespace Phalcon\Validation\Validator\StringLength; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\Exception; /** * Validates that a string has the specified minimum constraints @@ -77,7 +74,7 @@ class Min extends AbstractValidator * 'included' => false * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/Uniqueness.php b/src/Validation/Validator/Uniqueness.php similarity index 93% rename from src/Phalcon/Validation/Validator/Uniqueness.php rename to src/Validation/Validator/Uniqueness.php index 48caa76d..e28736f7 100644 --- a/src/Phalcon/Validation/Validator/Uniqueness.php +++ b/src/Validation/Validator/Uniqueness.php @@ -9,12 +9,7 @@ */ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Mvc\Model; -use Phalcon\Mvc\ModelInterface; -use Phalcon\Validation; use Phalcon\Validation\AbstractCombinedFieldsValidator; -use Phalcon\Validation\Exception; /** * Check that a field is unique in the related table @@ -91,7 +86,9 @@ class Uniqueness extends AbstractCombinedFieldsValidator protected $template = 'Field :field must be unique'; - + /** + * @var array|null + */ private $columnMap = null; @@ -107,7 +104,7 @@ class Uniqueness extends AbstractCombinedFieldsValidator * 'except' => null * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/Validator/Url.php b/src/Validation/Validator/Url.php similarity index 93% rename from src/Phalcon/Validation/Validator/Url.php rename to src/Validation/Validator/Url.php index 68ee2633..88cc599f 100644 --- a/src/Phalcon/Validation/Validator/Url.php +++ b/src/Validation/Validator/Url.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -63,7 +61,7 @@ class Url extends AbstractValidator * 'options' => [] * ] */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { } diff --git a/src/Phalcon/Validation/ValidatorCompositeInterface.php b/src/Validation/ValidatorCompositeInterface.php similarity index 96% rename from src/Phalcon/Validation/ValidatorCompositeInterface.php rename to src/Validation/ValidatorCompositeInterface.php index 9d1335de..cb532dfc 100644 --- a/src/Phalcon/Validation/ValidatorCompositeInterface.php +++ b/src/Validation/ValidatorCompositeInterface.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Validation; -use Phalcon\Validation; - /** * This is a base class for combined fields validators */ diff --git a/src/Phalcon/Validation/ValidatorFactory.php b/src/Validation/ValidatorFactory.php similarity index 88% rename from src/Phalcon/Validation/ValidatorFactory.php rename to src/Validation/ValidatorFactory.php index 465222aa..a23b5a80 100644 --- a/src/Phalcon/Validation/ValidatorFactory.php +++ b/src/Validation/ValidatorFactory.php @@ -10,7 +10,6 @@ namespace Phalcon\Validation; use Phalcon\Factory\AbstractFactory; -use Phalcon\Helper\Arr; /** * This file is part of the Phalcon Framework. @@ -23,12 +22,15 @@ class ValidatorFactory extends AbstractFactory { + protected $exception = 'Phalcon\\\\Validation\\\\Exception'; + + /** * TagFactory constructor. * * @param array $services */ - public function __construct(array $services = array()) + public function __construct(array $services = []) { } diff --git a/src/Phalcon/Validation/ValidatorInterface.php b/src/Validation/ValidatorInterface.php similarity index 98% rename from src/Phalcon/Validation/ValidatorInterface.php rename to src/Validation/ValidatorInterface.php index 1b4f2c64..1844d552 100644 --- a/src/Phalcon/Validation/ValidatorInterface.php +++ b/src/Validation/ValidatorInterface.php @@ -9,8 +9,6 @@ */ namespace Phalcon\Validation; -use Phalcon\Validation; - /** * Interface for Phalcon\Validation\AbstractValidator */