diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..ca24693 --- /dev/null +++ b/.php_cs @@ -0,0 +1,53 @@ +files() + ->name('*.php') + ->in(__DIR__ . '/src') + ->in(__DIR__ . '/tests') +; + +/** + * Cache file for PHP-CS + */ +$cacheFilePath = sprintf('%s%sphp_cs.cache-%s', sys_get_temp_dir(), DIRECTORY_SEPARATOR, md5(__DIR__)); + +/** + * Configuration + * + * @see https://mlocati.github.io/php-cs-fixer-configurator/# + */ +return (new Config('pecee-pixie')) + ->setCacheFile($cacheFilePath) + ->setRiskyAllowed(true) + ->setRules([ + // default + '@PSR2' => true, + '@Symfony' => true, + // additionally + 'array_syntax' => ['syntax' => 'short'], + 'concat_space' => false, + 'cast_spaces' => false, + 'no_unused_imports' => false, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'no_superfluous_phpdoc_tags' => false, + 'ordered_imports' => true, + 'phpdoc_align' => true, + 'phpdoc_order' => true, + 'phpdoc_trim' => true, + 'phpdoc_summary' => false, + 'simplified_null_return' => false, + 'ternary_to_null_coalescing' => true, + 'binary_operator_spaces' => ['default' => 'align'], + ]) + ->setFinder($finder) + ; diff --git a/composer.json b/composer.json index 0cbf047..2cf612c 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,8 @@ "require-dev": { "phpunit/phpunit": "^6.0", "mockery/mockery": "^1", - "ext-pdo_sqlite": "*" + "ext-pdo_sqlite": "*", + "friendsofphp/php-cs-fixer": "^2" }, "suggest": { "ext-pdo_sqlite": "Add extension for SQLite support" @@ -49,5 +50,12 @@ "psr-4": { "Pecee\\Pixie\\": "src/Pecee/Pixie/" } + }, + "scripts": { + "test": [ + "@lint" + ], + "fixer": "php-cs-fixer fix --diff --show-progress=dots", + "lint": "php-cs-fixer fix --diff --dry-run" } } diff --git a/composer.lock b/composer.lock index 8449693..a765b58 100644 --- a/composer.lock +++ b/composer.lock @@ -4,39 +4,251 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "89530812849cbab14d74d980e90c0c46", + "content-hash": "031b7adc933153f6e070550599b95801", "packages": [], "packages-dev": [ { - "name": "doctrine/instantiator", - "version": "1.1.0", + "name": "composer/semver", + "version": "3.2.4", "source": { "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + "url": "https://github.com/composer/semver.git", + "reference": "a02fdf930a3c1c3ed3a49b5f63859c0c20e10464" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "url": "https://api.github.com/repos/composer/semver/zipball/a02fdf930a3c1c3ed3a49b5f63859c0c20e10464", + "reference": "a02fdf930a3c1c3ed3a49b5f63859c0c20e10464", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "^6.2.3", - "squizlabs/php_codesniffer": "^3.0.2" + "phpstan/phpstan": "^0.12.54", + "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.2.4" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2020-11-13T08:59:24+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "1.4.6", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "f27e06cd9675801df441b3656569b328e04aa37c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f27e06cd9675801df441b3656569b328e04aa37c", + "reference": "f27e06cd9675801df441b3656569b328e04aa37c", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpstan/phpstan": "^0.12.55", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "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.6" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2021-03-25T17:01:18+00:00" + }, + { + "name": "doctrine/annotations", + "version": "1.12.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "b17c5014ef81d212ac539f07a1001832df1b6d3b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/b17c5014ef81d212ac539f07a1001832df1b6d3b", + "reference": "b17c5014ef81d212ac539f07a1001832df1b6d3b", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "ext-tokenizer": "*", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/cache": "1.*", + "doctrine/coding-standard": "^6.0 || ^8.1", + "phpstan/phpstan": "^0.12.20", + "phpunit/phpunit": "^7.5 || ^9.1.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" } + ], + "description": "Docblock Annotations Parser", + "homepage": "https://www.doctrine-project.org/projects/annotations.html", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "support": { + "issues": "https://github.com/doctrine/annotations/issues", + "source": "https://github.com/doctrine/annotations/tree/1.12.1" + }, + "time": "2021-02-21T21:00:45+00:00" + }, + { + "name": "doctrine/instantiator", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^8.0", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + }, + "type": "library", "autoload": { "psr-4": { "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" @@ -50,33 +262,219 @@ { "name": "Marco Pivetta", "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" + "homepage": "https://ocramius.github.io/" } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", "keywords": [ "constructor", "instantiate" ], - "time": "2017-07-22T11:58:36+00:00" + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.4.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2020-11-10T18:47:58+00:00" + }, + { + "name": "doctrine/lexer", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "1febd6c3ef84253d7c815bed85fc622ad207a9f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/1febd6c3ef84253d7c815bed85fc622ad207a9f8", + "reference": "1febd6c3ef84253d7c815bed85fc622ad207a9f8", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "^4.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "https://www.doctrine-project.org/projects/lexer.html", + "keywords": [ + "annotations", + "docblock", + "lexer", + "parser", + "php" + ], + "support": { + "issues": "https://github.com/doctrine/lexer/issues", + "source": "https://github.com/doctrine/lexer/tree/1.0.2" + }, + "time": "2019-06-08T11:03:04+00:00" + }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v2.18.5", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", + "reference": "e0f6d05c8b157f50029ca6c65c19ed2694f475bf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/e0f6d05c8b157f50029ca6c65c19ed2694f475bf", + "reference": "e0f6d05c8b157f50029ca6c65c19ed2694f475bf", + "shasum": "" + }, + "require": { + "composer/semver": "^1.4 || ^2.0 || ^3.0", + "composer/xdebug-handler": "^1.2", + "doctrine/annotations": "^1.2", + "ext-json": "*", + "ext-tokenizer": "*", + "php": "^5.6 || ^7.0 || ^8.0", + "php-cs-fixer/diff": "^1.3", + "symfony/console": "^3.4.43 || ^4.1.6 || ^5.0", + "symfony/event-dispatcher": "^3.0 || ^4.0 || ^5.0", + "symfony/filesystem": "^3.0 || ^4.0 || ^5.0", + "symfony/finder": "^3.0 || ^4.0 || ^5.0", + "symfony/options-resolver": "^3.0 || ^4.0 || ^5.0", + "symfony/polyfill-php70": "^1.0", + "symfony/polyfill-php72": "^1.4", + "symfony/process": "^3.0 || ^4.0 || ^5.0", + "symfony/stopwatch": "^3.0 || ^4.0 || ^5.0" + }, + "require-dev": { + "justinrainbow/json-schema": "^5.0", + "keradus/cli-executor": "^1.4", + "mikey179/vfsstream": "^1.6", + "php-coveralls/php-coveralls": "^2.4.2", + "php-cs-fixer/accessible-object": "^1.0", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1", + "phpspec/prophecy-phpunit": "^1.1 || ^2.0", + "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.13 || ^9.5", + "phpunitgoodpractices/polyfill": "^1.5", + "phpunitgoodpractices/traits": "^1.9.1", + "sanmai/phpunit-legacy-adapter": "^6.4 || ^8.2.1", + "symfony/phpunit-bridge": "^5.2.1", + "symfony/yaml": "^3.0 || ^4.0 || ^5.0" + }, + "suggest": { + "ext-dom": "For handling output formats in XML", + "ext-mbstring": "For handling non-UTF8 characters.", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.", + "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + }, + "classmap": [ + "tests/Test/AbstractFixerTestCase.php", + "tests/Test/AbstractIntegrationCaseFactory.php", + "tests/Test/AbstractIntegrationTestCase.php", + "tests/Test/Assert/AssertTokensTrait.php", + "tests/Test/IntegrationCase.php", + "tests/Test/IntegrationCaseFactory.php", + "tests/Test/IntegrationCaseFactoryInterface.php", + "tests/Test/InternalIntegrationCaseFactory.php", + "tests/Test/IsIdenticalConstraint.php", + "tests/Test/TokensWithObservedTransformers.php", + "tests/TestCase.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Dariusz RumiƄski", + "email": "dariusz.ruminski@gmail.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "support": { + "issues": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues", + "source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v2.18.5" + }, + "funding": [ + { + "url": "https://github.com/keradus", + "type": "github" + } + ], + "time": "2021-04-06T18:37:33+00:00" }, { "name": "hamcrest/hamcrest-php", - "version": "v2.0.0", + "version": "v2.0.1", "source": { "type": "git", "url": "https://github.com/hamcrest/hamcrest-php.git", - "reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad" + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/776503d3a8e85d4f9a1148614f95b7a608b046ad", - "reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", "shasum": "" }, "require": { - "php": "^5.3|^7.0" + "php": "^5.3|^7.0|^8.0" }, "replace": { "cordoval/hamcrest-php": "*", @@ -84,14 +482,13 @@ "kodova/hamcrest-php": "*" }, "require-dev": { - "phpunit/php-file-iterator": "1.3.3", - "phpunit/phpunit": "~4.0", - "satooshi/php-coveralls": "^1.0" + "phpunit/php-file-iterator": "^1.4 || ^2.0", + "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -101,41 +498,44 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD" + "BSD-3-Clause" ], "description": "This is the PHP port of Hamcrest Matchers", "keywords": [ "test" ], - "time": "2016-01-20T08:20:44+00:00" + "support": { + "issues": "https://github.com/hamcrest/hamcrest-php/issues", + "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.0.1" + }, + "time": "2020-07-09T08:09:16+00:00" }, { "name": "mockery/mockery", - "version": "1.1.0", + "version": "1.3.4", "source": { "type": "git", "url": "https://github.com/mockery/mockery.git", - "reference": "99e29d3596b16dabe4982548527d5ddf90232e99" + "reference": "31467aeb3ca3188158613322d66df81cedd86626" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/99e29d3596b16dabe4982548527d5ddf90232e99", - "reference": "99e29d3596b16dabe4982548527d5ddf90232e99", + "url": "https://api.github.com/repos/mockery/mockery/zipball/31467aeb3ca3188158613322d66df81cedd86626", + "reference": "31467aeb3ca3188158613322d66df81cedd86626", "shasum": "" }, "require": { - "hamcrest/hamcrest-php": "~2.0", + "hamcrest/hamcrest-php": "^2.0.1", "lib-pcre": ">=7.0", "php": ">=5.6.0" }, "require-dev": { - "phpdocumentor/phpdocumentor": "^2.9", - "phpunit/phpunit": "~5.7.10|~6.5" + "phpunit/phpunit": "^5.7.10|^6.5|^7.5|^8.5|^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { @@ -173,24 +573,28 @@ "test double", "testing" ], - "time": "2018-05-08T08:54:48+00:00" + "support": { + "issues": "https://github.com/mockery/mockery/issues", + "source": "https://github.com/mockery/mockery/tree/1.3.4" + }, + "time": "2021-02-24T09:51:00+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.8.1", + "version": "1.10.2", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "replace": { "myclabs/deep-copy": "self.version" @@ -221,7 +625,17 @@ "object", "object graph" ], - "time": "2018-06-11T23:09:50+00:00" + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2020-11-13T09:40:50+00:00" }, { "name": "phar-io/manifest", @@ -276,6 +690,10 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/master" + }, "time": "2017-03-05T18:14:27+00:00" }, { @@ -323,85 +741,144 @@ } ], "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/master" + }, "time": "2017-03-05T17:38:23+00:00" }, { - "name": "phpdocumentor/reflection-common", - "version": "1.0.1", + "name": "php-cs-fixer/diff", + "version": "v1.3.1", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + "url": "https://github.com/PHP-CS-Fixer/diff.git", + "reference": "dbd31aeb251639ac0b9e7e29405c1441907f5759" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/dbd31aeb251639ac0b9e7e29405c1441907f5759", + "reference": "dbd31aeb251639ac0b9e7e29405c1441907f5759", "shasum": "" }, "require": { - "php": ">=5.5" + "php": "^5.6 || ^7.0 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^4.6" + "phpunit/phpunit": "^5.7.23 || ^6.4.3 || ^7.0", + "symfony/process": "^3.3" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "SpacePossum" } ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", + "description": "sebastian/diff v2 backport support for PHP5.6", + "homepage": "https://github.com/PHP-CS-Fixer", "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" + "diff" ], - "time": "2017-09-11T18:02:19+00:00" + "support": { + "issues": "https://github.com/PHP-CS-Fixer/diff/issues", + "source": "https://github.com/PHP-CS-Fixer/diff/tree/v1.3.1" + }, + "time": "2020-10-14T08:39:05+00:00" }, { - "name": "phpdocumentor/reflection-docblock", - "version": "4.3.0", + "name": "phpdocumentor/reflection-common", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/6568f4687e5b41b054365f9ae03fcb1ed5f2069b", + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/master" + }, + "time": "2020-04-27T09:25:28+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "4.3.4", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08" + "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/da3fd972d6bafd628114f7e7e036f45944b62e9c", + "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c", "shasum": "" }, "require": { "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0", - "phpdocumentor/type-resolver": "^0.4.0", + "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", + "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", "webmozart/assert": "^1.0" }, "require-dev": { - "doctrine/instantiator": "~1.0.5", + "doctrine/instantiator": "^1.0.5", "mockery/mockery": "^1.0", + "phpdocumentor/type-resolver": "0.4.*", "phpunit/phpunit": "^6.4" }, "type": "library", @@ -428,41 +905,44 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-11-30T07:14:17+00:00" + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/release/4.x" + }, + "time": "2019-12-28T18:55:12+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.4.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0", - "phpdocumentor/reflection-common": "^1.0" + "php": "^7.1", + "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" + "ext-tokenizer": "^7.1", + "mockery/mockery": "~1", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -475,42 +955,47 @@ "email": "me@mikevanriel.com" } ], - "time": "2017-07-14T14:27:02+00:00" + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/0.7.2" + }, + "time": "2019-08-22T18:11:29+00:00" }, { "name": "phpspec/prophecy", - "version": "1.8.0", + "version": "v1.10.3", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" + "reference": "451c3cd1418cf640de218914901e51b064abb093" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", + "reference": "451c3cd1418cf640de218914901e51b064abb093", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0|^3.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", + "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", + "phpspec/phpspec": "^2.5 || ^3.2", "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.10.x-dev" } }, "autoload": { - "psr-0": { - "Prophecy\\": "src/" + "psr-4": { + "Prophecy\\": "src/Prophecy" } }, "notification-url": "https://packagist.org/downloads/", @@ -538,7 +1023,11 @@ "spy", "stub" ], - "time": "2018-08-05T17:53:17+00:00" + "support": { + "issues": "https://github.com/phpspec/prophecy/issues", + "source": "https://github.com/phpspec/prophecy/tree/v1.10.3" + }, + "time": "2020-03-05T15:02:03+00:00" }, { "name": "phpunit/php-code-coverage", @@ -601,6 +1090,10 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/5.3" + }, "time": "2018-04-06T15:36:58+00:00" }, { @@ -648,6 +1141,11 @@ "filesystem", "iterator" ], + "support": { + "irc": "irc://irc.freenode.net/phpunit", + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/1.4.5" + }, "time": "2017-11-27T13:52:08+00:00" }, { @@ -689,6 +1187,10 @@ "keywords": [ "template" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1" + }, "time": "2015-06-21T13:50:34+00:00" }, { @@ -738,6 +1240,10 @@ "keywords": [ "timer" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/master" + }, "time": "2017-02-26T11:10:40+00:00" }, { @@ -787,20 +1293,25 @@ "keywords": [ "tokenizer" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", + "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master" + }, + "abandoned": true, "time": "2017-11-27T05:48:46+00:00" }, { "name": "phpunit/phpunit", - "version": "6.5.12", + "version": "6.5.14", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "24da433d7384824d65ea93fbb462e2f31bbb494e" + "reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/24da433d7384824d65ea93fbb462e2f31bbb494e", - "reference": "24da433d7384824d65ea93fbb462e2f31bbb494e", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/bac23fe7ff13dbdb461481f706f0e9fe746334b7", + "reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7", "shasum": "" }, "require": { @@ -871,7 +1382,11 @@ "testing", "xunit" ], - "time": "2018-08-22T06:32:48+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/6.5.14" + }, + "time": "2019-02-01T05:22:47+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -930,27 +1445,135 @@ "mock", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit-mock-objects/issues", + "source": "https://github.com/sebastianbergmann/phpunit-mock-objects/tree/5.0.10" + }, + "abandoned": true, "time": "2018-08-09T05:50:03+00:00" }, + { + "name": "psr/container", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/master" + }, + "time": "2017-02-14T16:28:37+00:00" + }, + { + "name": "psr/log", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.3" + }, + "time": "2020-03-23T09:12:05+00:00" + }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/1de8cd5c010cb153fcd68b8d0f64606f523f7619", + "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": ">=5.6" }, "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.0" + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { @@ -975,7 +1598,17 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2017-03-04T06:30:41+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/1.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T08:15:22+00:00" }, { "name": "sebastian/comparator", @@ -1039,6 +1672,10 @@ "compare", "equality" ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/master" + }, "time": "2018-02-01T13:46:46+00:00" }, { @@ -1091,6 +1728,10 @@ "keywords": [ "diff" ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/master" + }, "time": "2017-08-03T08:09:46+00:00" }, { @@ -1141,24 +1782,28 @@ "environment", "hhvm" ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/master" + }, "time": "2017-07-01T08:51:00+00:00" }, { "name": "sebastian/exporter", - "version": "3.1.0", + "version": "3.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" + "reference": "6b853149eab67d4da22291d36f5b0631c0fd856e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/6b853149eab67d4da22291d36f5b0631c0fd856e", + "reference": "6b853149eab67d4da22291d36f5b0631c0fd856e", "shasum": "" }, "require": { - "php": "^7.0", + "php": ">=7.0", "sebastian/recursion-context": "^3.0" }, "require-dev": { @@ -1181,6 +1826,10 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -1189,17 +1838,13 @@ "name": "Volker Dusch", "email": "github@wallbash.com" }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, { "name": "Adam Harvey", "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" } ], "description": "Provides the functionality to export PHP variables for visualization", @@ -1208,7 +1853,17 @@ "export", "exporter" ], - "time": "2017-04-03T13:19:02+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/3.1.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:47:53+00:00" }, { "name": "sebastian/global-state", @@ -1259,24 +1914,28 @@ "keywords": [ "global state" ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/2.0.0" + }, "time": "2017-04-27T15:39:26+00:00" }, { "name": "sebastian/object-enumerator", - "version": "3.0.3", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" + "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", + "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", "shasum": "" }, "require": { - "php": "^7.0", + "php": ">=7.0", "sebastian/object-reflector": "^1.1.1", "sebastian/recursion-context": "^3.0" }, @@ -1306,24 +1965,34 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-08-03T12:35:26+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/3.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:40:27+00:00" }, { "name": "sebastian/object-reflector", - "version": "1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "773f97c67f28de00d397be301821b06708fca0be" + "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", - "reference": "773f97c67f28de00d397be301821b06708fca0be", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", + "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=7.0" }, "require-dev": { "phpunit/phpunit": "^6.0" @@ -1351,24 +2020,34 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "time": "2017-03-29T09:07:27+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/1.1.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:37:18+00:00" }, { "name": "sebastian/recursion-context", - "version": "3.0.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" + "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/367dcba38d6e1977be014dc4b22f47a484dac7fb", + "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=7.0" }, "require-dev": { "phpunit/phpunit": "^6.0" @@ -1389,14 +2068,14 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, { "name": "Adam Harvey", "email": "aharvey@php.net" @@ -1404,7 +2083,17 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2017-03-03T06:23:57+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/3.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:34:24+00:00" }, { "name": "sebastian/resource-operations", @@ -1446,6 +2135,10 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/master" + }, "time": "2015-07-28T20:34:47+00:00" }, { @@ -1489,79 +2182,148 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/master" + }, "time": "2016-10-03T07:35:21+00:00" }, { - "name": "theseer/tokenizer", - "version": "1.1.0", + "name": "symfony/console", + "version": "v4.4.21", "source": { "type": "git", - "url": "https://github.com/theseer/tokenizer.git", - "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" + "url": "https://github.com/symfony/console.git", + "reference": "1ba4560dbbb9fcf5ae28b61f71f49c678086cf23" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", - "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", + "url": "https://api.github.com/repos/symfony/console/zipball/1ba4560dbbb9fcf5ae28b61f71f49c678086cf23", + "reference": "1ba4560dbbb9fcf5ae28b61f71f49c678086cf23", "shasum": "" }, "require": { - "ext-dom": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": "^7.0" + "php": ">=7.1.3", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.8", + "symfony/polyfill-php80": "^1.15", + "symfony/service-contracts": "^1.1|^2" + }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/event-dispatcher": "<4.3|>=5", + "symfony/lock": "<4.4", + "symfony/process": "<3.3" + }, + "provide": { + "psr/log-implementation": "1.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "^3.4|^4.0|^5.0", + "symfony/dependency-injection": "^3.4|^4.0|^5.0", + "symfony/event-dispatcher": "^4.3", + "symfony/lock": "^4.4|^5.0", + "symfony/process": "^3.4|^4.0|^5.0", + "symfony/var-dumper": "^4.3|^5.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" }, "type": "library", "autoload": { - "classmap": [ - "src/" + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2017-04-07T12:08:54+00:00" + "description": "Eases the creation of beautiful and testable command line interfaces", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/console/tree/v4.4.21" + }, + "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-03-26T09:23:24+00:00" }, { - "name": "webmozart/assert", - "version": "1.3.0", + "name": "symfony/event-dispatcher", + "version": "v4.4.20", "source": { "type": "git", - "url": "https://github.com/webmozart/assert.git", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a" + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "c352647244bd376bf7d31efbd5401f13f50dad0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/c352647244bd376bf7d31efbd5401f13f50dad0c", + "reference": "c352647244bd376bf7d31efbd5401f13f50dad0c", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": ">=7.1.3", + "symfony/event-dispatcher-contracts": "^1.1" + }, + "conflict": { + "symfony/dependency-injection": "<3.4" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "1.1" }, "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" + "psr/log": "~1.0", + "symfony/config": "^3.4|^4.0|^5.0", + "symfony/dependency-injection": "^3.4|^4.0|^5.0", + "symfony/error-handler": "~3.4|~4.4", + "symfony/expression-language": "^3.4|^4.0|^5.0", + "symfony/http-foundation": "^3.4|^4.0|^5.0", + "symfony/service-contracts": "^1.1|^2", + "symfony/stopwatch": "^3.4|^4.0|^5.0" }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" }, + "type": "library", "autoload": { "psr-4": { - "Webmozart\\Assert\\": "src/" - } + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1569,29 +2331,1079 @@ ], "authors": [ { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" + "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/event-dispatcher/tree/v4.4.20" + }, + "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": "2018-01-29T19:49:41+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=7.1", + "time": "2021-01-27T09:09:26+00:00" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v1.1.9", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "84e23fdcd2517bf37aecbd16967e83f0caee25a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/84e23fdcd2517bf37aecbd16967e83f0caee25a7", + "reference": "84e23fdcd2517bf37aecbd16967e83f0caee25a7", + "shasum": "" + }, + "require": { + "php": ">=7.1.3" + }, + "suggest": { + "psr/event-dispatcher": "", + "symfony/event-dispatcher-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" + } + }, + "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": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v1.1.9" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-06T13:19:58+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v4.4.21", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "940826c465be2690c9fae91b2793481e5cbd6834" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/940826c465be2690c9fae91b2793481e5cbd6834", + "reference": "940826c465be2690c9fae91b2793481e5cbd6834", + "shasum": "" + }, + "require": { + "php": ">=7.1.3", + "symfony/polyfill-ctype": "~1.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v4.4.21" + }, + "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-03-28T09:59:32+00:00" + }, + { + "name": "symfony/finder", + "version": "v4.4.20", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "2543795ab1570df588b9bbd31e1a2bd7037b94f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/2543795ab1570df588b9bbd31e1a2bd7037b94f6", + "reference": "2543795ab1570df588b9bbd31e1a2bd7037b94f6", + "shasum": "" + }, + "require": { + "php": ">=7.1.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Finds files and directories via an intuitive fluent interface", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v4.4.20" + }, + "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-02-12T10:48:09+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v4.4.20", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "cd8c6a2778d5f8b5e8fc4b7abdf126790b5d5095" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/cd8c6a2778d5f8b5e8fc4b7abdf126790b5d5095", + "reference": "cd8c6a2778d5f8b5e8fc4b7abdf126790b5d5095", + "shasum": "" + }, + "require": { + "php": ">=7.1.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an improved replacement for the array_replace PHP function", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "support": { + "source": "https://github.com/symfony/options-resolver/tree/v4.4.20" + }, + "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-01-27T09:09:26+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.22.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e", + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.22-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.1" + }, + "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-01-07T16:49:33+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.22.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "5232de97ee3b75b0360528dae24e73db49566ab1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/5232de97ee3b75b0360528dae24e73db49566ab1", + "reference": "5232de97ee3b75b0360528dae24e73db49566ab1", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.22-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.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": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.22.1" + }, + "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-01-22T09:19:47+00:00" + }, + { + "name": "symfony/polyfill-php70", + "version": "v1.20.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php70.git", + "reference": "5f03a781d984aae42cebd18e7912fa80f02ee644" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/5f03a781d984aae42cebd18e7912fa80f02ee644", + "reference": "5f03a781d984aae42cebd18e7912fa80f02ee644", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "metapackage", + "extra": { + "branch-alias": { + "dev-main": "1.20-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php70/tree/v1.20.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-23T14:02:19+00:00" + }, + { + "name": "symfony/polyfill-php72", + "version": "v1.22.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "cc6e6f9b39fe8075b3dabfbaf5b5f645ae1340c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/cc6e6f9b39fe8075b3dabfbaf5b5f645ae1340c9", + "reference": "cc6e6f9b39fe8075b3dabfbaf5b5f645ae1340c9", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.22-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + }, + "files": [ + "bootstrap.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": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php72/tree/v1.22.1" + }, + "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-01-07T16:49:33+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.22.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "a678b42e92f86eca04b7fa4c0f6f19d097fb69e2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/a678b42e92f86eca04b7fa4c0f6f19d097fb69e2", + "reference": "a678b42e92f86eca04b7fa4c0f6f19d097fb69e2", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.22-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.22.1" + }, + "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-01-07T16:49:33+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.22.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/dc3063ba22c2a1fd2f45ed856374d79114998f91", + "reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.22-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.22.1" + }, + "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-01-07T16:49:33+00:00" + }, + { + "name": "symfony/process", + "version": "v4.4.20", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "7e950b6366d4da90292c2e7fa820b3c1842b965a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/7e950b6366d4da90292c2e7fa820b3c1842b965a", + "reference": "7e950b6366d4da90292c2e7fa820b3c1842b965a", + "shasum": "" + }, + "require": { + "php": ">=7.1.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Executes commands in sub-processes", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/process/tree/v4.4.20" + }, + "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-01-27T09:09:26+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v1.1.9", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "b776d18b303a39f56c63747bcb977ad4b27aca26" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/b776d18b303a39f56c63747bcb977ad4b27aca26", + "reference": "b776d18b303a39f56c63747bcb977ad4b27aca26", + "shasum": "" + }, + "require": { + "php": ">=7.1.3", + "psr/container": "^1.0" + }, + "suggest": { + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "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": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v1.1.9" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-06T13:19:58+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v4.4.20", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "c5572f6494fc20668a73b77684d8dc77e534d8cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/c5572f6494fc20668a73b77684d8dc77e534d8cf", + "reference": "c5572f6494fc20668a73b77684d8dc77e534d8cf", + "shasum": "" + }, + "require": { + "php": ">=7.1.3", + "symfony/service-contracts": "^1.0|^2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a way to profile code", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/stopwatch/tree/v4.4.20" + }, + "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-01-27T09:09:26+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/master" + }, + "time": "2019-06-13T22:48:21+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.9.1", + "source": { + "type": "git", + "url": "https://github.com/webmozarts/assert.git", + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0 || ^8.0", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<3.9.1" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.36 || ^7.5.13" + }, + "type": "library", + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "support": { + "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" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=7.1", "ext-pdo": "*" }, "platform-dev": { "ext-pdo_sqlite": "*" - } + }, + "plugin-api-version": "2.0.0" } diff --git a/src/Pecee/Pixie/Connection.php b/src/Pecee/Pixie/Connection.php index 9caf7c8..17a7e34 100644 --- a/src/Pecee/Pixie/Connection.php +++ b/src/Pecee/Pixie/Connection.php @@ -9,12 +9,9 @@ /** * Class Connection - * - * @package Pecee\Pixie */ class Connection { - /** * @var Connection */ @@ -48,8 +45,8 @@ class Connection protected $lastQuery; /** - * @param string $adapter Adapter name or class - * @param array $adapterConfig + * @param string $adapter Adapter name or class + * @param array $adapterConfig */ public function __construct($adapter, array $adapterConfig) { @@ -66,7 +63,7 @@ public function __construct($adapter, array $adapterConfig) // Create event dependency $this->eventHandler = new EventHandler(); - if (static::$storedConnection === null) { + if (null === static::$storedConnection) { static::$storedConnection = $this; } } @@ -81,11 +78,12 @@ public static function getStoredConnection(): ?self /** * Create the connection adapter and connect to database + * * @return static */ public function connect(): self { - if ($this->pdoInstance !== null) { + if (null !== $this->pdoInstance) { return $this; } @@ -130,8 +128,9 @@ public function getPdoInstance(): \PDO /** * Returns an instance of Query Builder * - * @return QueryBuilderHandler * @throws Exception + * + * @return QueryBuilderHandler */ public function getQueryBuilder(): QueryBuilderHandler { @@ -178,6 +177,7 @@ public function setPdoInstance(\PDO $pdo): self * Set query-object for last executed query. * * @param QueryObject $query + * * @return static */ public function setLastQuery(QueryObject $query): self @@ -200,9 +200,9 @@ public function getLastQuery(): ?QueryObject /** * Register new event * - * @param string $name + * @param string $name * @param string|null $table - * @param \Closure $action + * @param \Closure $action * * @return void */ @@ -216,7 +216,7 @@ public function registerEvent($name, $table = null, \Closure $action): void */ public function close(): void { - $this->pdoInstance = null; + $this->pdoInstance = null; static::$storedConnection = null; } @@ -224,5 +224,4 @@ public function __destruct() { $this->close(); } - -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/ConnectionAdapters/BaseAdapter.php b/src/Pecee/Pixie/ConnectionAdapters/BaseAdapter.php index b978d45..3e5cc49 100644 --- a/src/Pecee/Pixie/ConnectionAdapters/BaseAdapter.php +++ b/src/Pecee/Pixie/ConnectionAdapters/BaseAdapter.php @@ -6,8 +6,6 @@ /** * Class BaseAdapter - * - * @package Pecee\Pixie\ConnectionAdapters */ abstract class BaseAdapter implements IConnectionAdapter { @@ -18,7 +16,7 @@ abstract class BaseAdapter implements IConnectionAdapter */ public function connect(array $config): PDO { - if (isset($config['options']) === false) { + if (false === isset($config['options'])) { $config['options'] = []; } @@ -31,4 +29,4 @@ public function connect(array $config): PDO * @return PDO */ abstract protected function doConnect(array $config): PDO; -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/ConnectionAdapters/IConnectionAdapter.php b/src/Pecee/Pixie/ConnectionAdapters/IConnectionAdapter.php index 5e3df54..42913c5 100644 --- a/src/Pecee/Pixie/ConnectionAdapters/IConnectionAdapter.php +++ b/src/Pecee/Pixie/ConnectionAdapters/IConnectionAdapter.php @@ -6,7 +6,6 @@ interface IConnectionAdapter { - /** * Connect to database * @@ -18,8 +17,8 @@ public function connect(array $config): PDO; /** * Get query adapter class + * * @return string */ public function getQueryAdapterClass(): string; - -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/ConnectionAdapters/Mysql.php b/src/Pecee/Pixie/ConnectionAdapters/Mysql.php index 757258a..377ab10 100644 --- a/src/Pecee/Pixie/ConnectionAdapters/Mysql.php +++ b/src/Pecee/Pixie/ConnectionAdapters/Mysql.php @@ -7,15 +7,12 @@ /** * Class Mysql - * - * @package Pecee\Pixie\ConnectionAdapters */ class Mysql extends BaseAdapter { /** * @param array $config * - * @return PDO * @throws \Pecee\Pixie\Exceptions\TableNotFoundException * @throws \Pecee\Pixie\Exceptions\ConnectionException * @throws \Pecee\Pixie\Exceptions\ColumnNotFoundException @@ -25,35 +22,35 @@ class Mysql extends BaseAdapter * @throws \Pecee\Pixie\Exceptions\DuplicateKeyException * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException + * + * @return PDO */ protected function doConnect(array $config): PDO { - if (\extension_loaded('pdo_mysql') === false) { + if (false === \extension_loaded('pdo_mysql')) { throw new Exception(sprintf('%s library not loaded', 'pdo_mysql')); } $connectionString = "mysql:dbname={$config['database']}"; - if (isset($config['host']) === true) { + if (true === isset($config['host'])) { $connectionString .= ";host={$config['host']}"; } - if (isset($config['port']) === true) { + if (true === isset($config['port'])) { $connectionString .= ";port={$config['port']}"; } - if (isset($config['unix_socket']) === true) { + if (true === isset($config['unix_socket'])) { $connectionString .= ";unix_socket={$config['unix_socket']}"; } try { - $connection = new PDO($connectionString, $config['username'], $config['password'], $config['options']); - if (isset($config['charset']) === true) { + if (true === isset($config['charset'])) { $connection->prepare("SET NAMES '{$config['charset']}'")->execute(); } - } catch (\PDOException $e) { throw Exception::create($e, $this->getQueryAdapterClass()); } @@ -63,10 +60,11 @@ protected function doConnect(array $config): PDO /** * Get query adapter class + * * @return string */ public function getQueryAdapterClass(): string { return \Pecee\Pixie\QueryBuilder\Adapters\Mysql::class; } -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/ConnectionAdapters/Pgsql.php b/src/Pecee/Pixie/ConnectionAdapters/Pgsql.php index e8466cb..9dd2bd5 100644 --- a/src/Pecee/Pixie/ConnectionAdapters/Pgsql.php +++ b/src/Pecee/Pixie/ConnectionAdapters/Pgsql.php @@ -7,15 +7,12 @@ /** * Class Pgsql - * - * @package Pecee\Pixie\ConnectionAdapters */ class Pgsql extends BaseAdapter { /** * @param array $config * - * @return PDO * @throws \Pecee\Pixie\Exceptions\TableNotFoundException * @throws \Pecee\Pixie\Exceptions\ConnectionException * @throws \Pecee\Pixie\Exceptions\ColumnNotFoundException @@ -25,31 +22,31 @@ class Pgsql extends BaseAdapter * @throws \Pecee\Pixie\Exceptions\DuplicateKeyException * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException + * + * @return PDO */ protected function doConnect(array $config): PDO { - if (\extension_loaded('pdo_pgsql') === false) { + if (false === \extension_loaded('pdo_pgsql')) { throw new Exception(sprintf('%s library not loaded', 'pdo_pgsql')); } $connectionString = "pgsql:host={$config['host']};dbname={$config['database']}"; - if (isset($config['port']) === true) { + if (true === isset($config['port'])) { $connectionString .= ";port={$config['port']}"; } try { - $connection = new PDO($connectionString, $config['username'], $config['password'], $config['options']); - if (isset($config['charset']) === true) { + if (true === isset($config['charset'])) { $connection->prepare("SET NAMES '{$config['charset']}'")->execute(); } - if (isset($config['schema']) === true) { + if (true === isset($config['schema'])) { $connection->prepare("SET search_path TO '{$config['schema']}'")->execute(); } - } catch (\PDOException $e) { throw Exception::create($e, $this->getQueryAdapterClass()); } @@ -59,10 +56,11 @@ protected function doConnect(array $config): PDO /** * Get query adapter class + * * @return string */ public function getQueryAdapterClass(): string { return \Pecee\Pixie\QueryBuilder\Adapters\Pgsql::class; } -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/ConnectionAdapters/Sqlite.php b/src/Pecee/Pixie/ConnectionAdapters/Sqlite.php index 493b441..87fe390 100644 --- a/src/Pecee/Pixie/ConnectionAdapters/Sqlite.php +++ b/src/Pecee/Pixie/ConnectionAdapters/Sqlite.php @@ -7,15 +7,12 @@ /** * Class Sqlite - * - * @package Pecee\Pixie\ConnectionAdapters */ class Sqlite extends BaseAdapter { /** * @param array $config * - * @return PDO * @throws \Pecee\Pixie\Exceptions\TableNotFoundException * @throws \Pecee\Pixie\Exceptions\ConnectionException * @throws \Pecee\Pixie\Exceptions\ColumnNotFoundException @@ -25,10 +22,12 @@ class Sqlite extends BaseAdapter * @throws \Pecee\Pixie\Exceptions\DuplicateKeyException * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException + * + * @return PDO */ public function doConnect(array $config): PDO { - if (\extension_loaded('pdo_sqlite') === false) { + if (false === \extension_loaded('pdo_sqlite')) { throw new Exception(sprintf('%s library not loaded', 'pdo_sqlite')); } @@ -43,10 +42,11 @@ public function doConnect(array $config): PDO /** * Get query adapter class + * * @return string */ public function getQueryAdapterClass(): string { return \Pecee\Pixie\QueryBuilder\Adapters\Sqlite::class; } -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/ConnectionAdapters/Sqlserver.php b/src/Pecee/Pixie/ConnectionAdapters/Sqlserver.php index a441cef..1e75dfc 100644 --- a/src/Pecee/Pixie/ConnectionAdapters/Sqlserver.php +++ b/src/Pecee/Pixie/ConnectionAdapters/Sqlserver.php @@ -1,18 +1,18 @@ getQueryAdapterClass()); } + return $connection; } + /** * Get query adapter class + * * @return string */ public function getQueryAdapterClass(): string diff --git a/src/Pecee/Pixie/Event/EventArguments.php b/src/Pecee/Pixie/Event/EventArguments.php index 6c31f5f..78dc752 100644 --- a/src/Pecee/Pixie/Event/EventArguments.php +++ b/src/Pecee/Pixie/Event/EventArguments.php @@ -9,6 +9,7 @@ class EventArguments { /** * Event name + * * @var string */ private $name; @@ -30,10 +31,10 @@ class EventArguments public function __construct($name, QueryObject $qo, QueryBuilderHandler $qb, array $arguments) { - $this->name = $name; - $this->queryObject = $qo; + $this->name = $name; + $this->queryObject = $qo; $this->queryBuilder = $qb; - $this->arguments = $arguments; + $this->arguments = $arguments; } /** @@ -71,7 +72,7 @@ public function getQuery(): QueryObject * * @return string|null */ - public function getInsertId() : ?string + public function getInsertId(): ?string { return $this->arguments['insert_id'] ?? null; } @@ -81,7 +82,7 @@ public function getInsertId() : ?string * * @return float|null */ - public function getExecutionTime() : ?float + public function getExecutionTime(): ?float { return $this->arguments['execution_time'] ?? null; } @@ -95,5 +96,4 @@ public function getArguments(): array { return $this->arguments; } - -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/Event/EventHandler.php b/src/Pecee/Pixie/Event/EventHandler.php index 6b1b1ef..36fa52d 100644 --- a/src/Pecee/Pixie/Event/EventHandler.php +++ b/src/Pecee/Pixie/Event/EventHandler.php @@ -8,12 +8,9 @@ /** * Class EventHandler - * - * @package Pecee\Pixie */ class EventHandler { - /** * Event-type that fires before each query * @@ -108,16 +105,17 @@ class EventHandler protected $events = []; /** - * @param string $name - * @param QueryObject $queryObject + * @param string $name + * @param QueryObject $queryObject * @param QueryBuilderHandler $queryBuilder - * @param array $eventArguments + * @param array $eventArguments + * * @return void */ public function fireEvents(string $name, QueryObject $queryObject, QueryBuilderHandler $queryBuilder, array $eventArguments = []): void { $statements = $queryBuilder->getStatements(); - $tables = $statements['tables'] ?? []; + $tables = $statements['tables'] ?? []; // Events added with :any will be fired in case of any table, we are adding :any as a fake table at the beginning. array_unshift($tables, static::TABLE_ANY); @@ -126,7 +124,7 @@ public function fireEvents(string $name, QueryObject $queryObject, QueryBuilderH foreach ($tables as $table) { // Fire before events for :any table $action = $this->getEvent($name, $table); - if ($action === null) { + if (null === $action) { continue; } @@ -135,7 +133,7 @@ public function fireEvents(string $name, QueryObject $queryObject, QueryBuilderH } /** - * @param string $event + * @param string $event * @param string|Raw|null $table * * @return callable|null @@ -148,16 +146,16 @@ public function getEvent(string $event, ?string $table = null): ?callable return null; } - if (isset($this->events[$table][$event]) === true) { + if (true === isset($this->events[$table][$event])) { return $this->events[$table][$event]; } // Find event with wildcard (*) - if (isset($this->events[$table]) === true) { + if (true === isset($this->events[$table])) { foreach ((array)$this->events[$table] as $name => $e) { - if (strpos($name, '*') !== false) { + if (false !== strpos($name, '*')) { $name = substr($name, 0, strpos($name, '*')); - if (strpos($event, $name) !== false) { + if (false !== strpos($event, $name)) { return $e; } } @@ -176,9 +174,9 @@ public function getEvents(): array } /** - * @param string $event + * @param string $event * @param string|null $table - * @param \Closure $action + * @param \Closure $action * * @return void */ @@ -197,4 +195,4 @@ public function removeEvent($event, $table = null): void { unset($this->events[$table ?? static::TABLE_ANY][$event]); } -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/Exception.php b/src/Pecee/Pixie/Exception.php index 46a5846..38a572d 100644 --- a/src/Pecee/Pixie/Exception.php +++ b/src/Pecee/Pixie/Exception.php @@ -18,8 +18,6 @@ /** * Class Exception - * - * @package Pecee\Pixie */ class Exception extends \Exception { @@ -32,8 +30,8 @@ public function __construct(string $message = '', int $code = 0, Throwable $prev } /** - * @param \Exception $e - * @param string|null $adapterName + * @param \Exception $e + * @param string|null $adapterName * @param QueryObject|null $query * * @return static|ColumnNotFoundException|ConnectionException|DuplicateColumnException|DuplicateEntryException|DuplicateKeyException|ForeignKeyException|NotNullException|TableNotFoundException @@ -44,17 +42,15 @@ public function __construct(string $message = '', int $code = 0, Throwable $prev */ public static function create(\Exception $e, string $adapterName = null, QueryObject $query = null) { - if ($e instanceof \PDOException) { - /** * @var string|null $errorSqlState - * @var integer|null $errorCode + * @var int|null $errorCode * @var string|null $errorMsg */ [$errorSqlState, $errorCode, $errorMsg] = $e->errorInfo; - $errorMsg = $errorMsg ?? $e->getMessage(); + $errorMsg = $errorMsg ?? $e->getMessage(); $errorCode = (int)($errorCode ?? $e->getCode()); switch ($adapterName) { @@ -100,37 +96,37 @@ public static function create(\Exception $e, string $adapterName = null, QueryOb break; case Sqlite::class: // https://sqlite.org/c3ref/c_abort.html - /** + /* * Hack for SQLite3 exceptions. * Error messages from source code: https://www.sqlite.org/download.html */ - switch($errorCode) { + switch ($errorCode) { case 14: return new ConnectionException($errorMsg, 1, $e->getPrevious(), $query); } switch ($errorSqlState) { - case null; - if ($errorCode === 14) { + case null: + if (14 === $errorCode) { return new ConnectionException($errorMsg, 1, $e->getPrevious(), $query); } break; case 'HY000': case '23000': - if (preg_match('/no such column:/', $errorMsg) === 1) { + if (1 === preg_match('/no such column:/', $errorMsg)) { return new ColumnNotFoundException($errorMsg, 1, $e->getPrevious(), $query); } - if (preg_match('/no such table:/', $errorMsg) === 1) { + if (1 === preg_match('/no such table:/', $errorMsg)) { return new TableNotFoundException($errorMsg, 1, $e->getPrevious(), $query); } - if (preg_match('/NOT NULL constraint failed:/', $errorMsg) === 1) { + if (1 === preg_match('/NOT NULL constraint failed:/', $errorMsg)) { return new NotNullException($errorMsg, 1, $e->getPrevious(), $query); } - if (preg_match('/UNIQUE constraint failed:/', $errorMsg) === 1) { + if (1 === preg_match('/UNIQUE constraint failed:/', $errorMsg)) { return new DuplicateEntryException($errorMsg, 1, $e->getPrevious(), $query); } - if (preg_match('/FOREIGN KEY constraint failed/', $errorMsg) === 1) { + if (1 === preg_match('/FOREIGN KEY constraint failed/', $errorMsg)) { return new ForeignKeyException($errorMsg, 1, $e->getPrevious(), $query); } } @@ -150,4 +146,4 @@ public function getQuery(): ?QueryObject { return $this->query; } -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/Exceptions/ColumnNotFoundException.php b/src/Pecee/Pixie/Exceptions/ColumnNotFoundException.php index 37b9639..a31411d 100644 --- a/src/Pecee/Pixie/Exceptions/ColumnNotFoundException.php +++ b/src/Pecee/Pixie/Exceptions/ColumnNotFoundException.php @@ -6,10 +6,7 @@ /** * Class DuplicateColumnException - * - * @package Pecee\Pixie\Exceptions */ class ColumnNotFoundException extends Exception { - -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/Exceptions/ConnectionException.php b/src/Pecee/Pixie/Exceptions/ConnectionException.php index 42a6ff1..042b1be 100644 --- a/src/Pecee/Pixie/Exceptions/ConnectionException.php +++ b/src/Pecee/Pixie/Exceptions/ConnectionException.php @@ -6,10 +6,7 @@ /** * Class DuplicateColumnException - * - * @package Pecee\Pixie\Exceptions */ class ConnectionException extends Exception { - -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/Exceptions/DuplicateColumnException.php b/src/Pecee/Pixie/Exceptions/DuplicateColumnException.php index dbf05e8..4eee1dc 100644 --- a/src/Pecee/Pixie/Exceptions/DuplicateColumnException.php +++ b/src/Pecee/Pixie/Exceptions/DuplicateColumnException.php @@ -6,10 +6,7 @@ /** * Class DuplicateColumnException - * - * @package Pecee\Pixie\Exceptions */ class DuplicateColumnException extends Exception { - -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/Exceptions/DuplicateEntryException.php b/src/Pecee/Pixie/Exceptions/DuplicateEntryException.php index 9fb4126..4c17287 100644 --- a/src/Pecee/Pixie/Exceptions/DuplicateEntryException.php +++ b/src/Pecee/Pixie/Exceptions/DuplicateEntryException.php @@ -6,10 +6,7 @@ /** * Class DuplicateEntryException - * - * @package Pecee\Pixie\Exceptions */ class DuplicateEntryException extends Exception { - -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/Exceptions/DuplicateKeyException.php b/src/Pecee/Pixie/Exceptions/DuplicateKeyException.php index c9988bc..c00defc 100644 --- a/src/Pecee/Pixie/Exceptions/DuplicateKeyException.php +++ b/src/Pecee/Pixie/Exceptions/DuplicateKeyException.php @@ -6,10 +6,7 @@ /** * Class DuplicateKeyException - * - * @package Pecee\Pixie\Exceptions */ class DuplicateKeyException extends Exception { - -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/Exceptions/ForeignKeyException.php b/src/Pecee/Pixie/Exceptions/ForeignKeyException.php index a6c1e06..b68ca63 100644 --- a/src/Pecee/Pixie/Exceptions/ForeignKeyException.php +++ b/src/Pecee/Pixie/Exceptions/ForeignKeyException.php @@ -6,10 +6,7 @@ /** * Class ForeignKeyException - * - * @package Pecee\Pixie\Exceptions */ class ForeignKeyException extends Exception { - -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/Exceptions/NotNullException.php b/src/Pecee/Pixie/Exceptions/NotNullException.php index 926cfaa..02eafcd 100644 --- a/src/Pecee/Pixie/Exceptions/NotNullException.php +++ b/src/Pecee/Pixie/Exceptions/NotNullException.php @@ -1,14 +1,12 @@ $piece) { - if ($wrapSanitizer === true) { + if (true === $wrapSanitizer) { $piece = $this->wrapSanitizer($piece); } - if (\is_int($key) === false) { + if (false === \is_int($key)) { $piece = ($wrapSanitizer ? $this->wrapSanitizer($key) : $key) . ' AS ' . $piece; } @@ -108,9 +107,10 @@ protected function arrayStr(array $pieces, string $glue = ',', bool $wrapSanitiz * Build generic criteria string and bindings from statements, like "a = b and c = ?" * * @param array $statements - * @param bool $bindValues + * @param bool $bindValues * * @throws Exception + * * @return array */ protected function buildCriteria(array $statements, bool $bindValues = true): array @@ -119,18 +119,17 @@ protected function buildCriteria(array $statements, bool $bindValues = true): ar $bindings = [[]]; foreach ($statements as $i => $statement) { - - if ($i === 0 && isset($statement['condition'])) { + if (0 === $i && isset($statement['condition'])) { $criteria[] = $statement['condition']; } - $joiner = ($i === 0) ? trim(str_ireplace(['and', 'or'], '', $statement['joiner'])) : $statement['joiner']; + $joiner = (0 === $i) ? trim(str_ireplace(['and', 'or'], '', $statement['joiner'])) : $statement['joiner']; - if ($joiner !== '') { + if ('' !== $joiner) { $criteria[] = $joiner; } - if (isset($statement['columns']) === true) { + if (true === isset($statement['columns'])) { $criteria[] = sprintf('(%s)', $this->arrayStr((array)$statement['columns'])); continue; } @@ -140,7 +139,7 @@ protected function buildCriteria(array $statements, bool $bindValues = true): ar $key = $this->wrapSanitizer($key); // Add alias non-existing - if(is_string($key) && $this->aliasPrefix !== null && strpos($key, '.') === false) { + if (is_string($key) && null !== $this->aliasPrefix && false === strpos($key, '.')) { $key = $this->aliasPrefix . '.' . $key; } @@ -150,13 +149,11 @@ protected function buildCriteria(array $statements, bool $bindValues = true): ar $value = $statement['value']; - if ($value === null && $key instanceof \Closure) { - + if (null === $value && $key instanceof \Closure) { /** * We have a closure, a nested criteria * Build a new NestedCriteria class, keep it by reference so any changes made in the closure should reflect here */ - $nestedCriteria = new NestedCriteria($this->connection); // Call the closure with our new nestedCriteria object @@ -174,12 +171,11 @@ protected function buildCriteria(array $statements, bool $bindValues = true): ar continue; } - if (\is_array($value) === true) { - + if (true === \is_array($value)) { // Where in or between like query $criteria[] = "$key {$statement['operator']}"; - if ($statement['operator'] === 'BETWEEN') { + if ('BETWEEN' === $statement['operator']) { $bindings[] = $statement['value']; $criteria[] = '? AND ?'; continue; @@ -193,22 +189,20 @@ protected function buildCriteria(array $statements, bool $bindValues = true): ar } $valuePlaceholder = trim($valuePlaceholder, ', '); - $criteria[] = "($valuePlaceholder)"; + $criteria[] = "($valuePlaceholder)"; continue; } - if ($bindValues === false || $value instanceof Raw) { - + if (false === $bindValues || $value instanceof Raw) { // Usual where like criteria specially for joins - we are not binding values, lets sanitize then - $value = ($bindValues === false) ? $this->wrapSanitizer($value) : $value; + $value = (false === $bindValues) ? $this->wrapSanitizer($value) : $value; $criteria[] = "{$key} {$statement['operator']} $value"; continue; } if ($statement['key'] instanceof Raw) { - - if ($statement['operator'] !== null) { + if (null !== $statement['operator']) { $criteria[] = "{$key} {$statement['operator']} ?"; $bindings[] = [$value]; continue; @@ -216,11 +210,10 @@ protected function buildCriteria(array $statements, bool $bindValues = true): ar $criteria[] = $key; continue; - } // Check for objects that implement the __toString() magic method - if(\is_object($value) === true && \method_exists($value, '__toString') === true) { + if (true === \is_object($value) && true === \method_exists($value, '__toString')) { $value = $value->__toString(); } @@ -240,24 +233,25 @@ protected function buildCriteria(array $statements, bool $bindValues = true): ar /** * Build criteria string and binding with various types added, like WHERE and Having * - * @param array $statements + * @param array $statements * @param string $key * @param string $type - * @param bool $bindValues + * @param bool $bindValues * - * @return array * @throws Exception + * + * @return array */ protected function buildCriteriaWithType(array $statements, $key, $type, $bindValues = true): array { $criteria = ''; $bindings = []; - if (isset($statements[$key]) === true) { + if (true === isset($statements[$key])) { // Get the generic/adapter agnostic criteria string from parent [$criteria, $bindings] = $this->buildCriteria($statements[$key], $bindValues); - if ($criteria !== null) { + if (null !== $criteria) { $criteria = $type . ' ' . $criteria; } } @@ -270,21 +264,22 @@ protected function buildCriteriaWithType(array $statements, $key, $type, $bindVa * * @param array $statements * - * @return string * @throws Exception + * + * @return string */ protected function buildJoin(array $statements): string { $sql = ''; - if (isset($statements['joins']) === false) { + if (false === isset($statements['joins'])) { return $sql; } foreach ((array)$statements['joins'] as $joinArr) { - if (\is_array($joinArr['table']) === true) { + if (true === \is_array($joinArr['table'])) { [$mainTable, $aliasTable] = $joinArr['table']; - $table = $this->wrapSanitizer($mainTable) . ' AS ' . $this->wrapSanitizer($aliasTable); + $table = $this->wrapSanitizer($mainTable) . ' AS ' . $this->wrapSanitizer($aliasTable); } else { $table = $joinArr['table'] instanceof Raw ? (string)$joinArr['table'] : $this->wrapSanitizer($joinArr['table']); } @@ -335,7 +330,7 @@ protected function concatenateQuery(array $pieces): string protected function buildAliasedTableName(string $table, array $statements): string { $this->aliasPrefix = $statements['aliases'][$table] ?? null; - if ($this->aliasPrefix !== null) { + if (null !== $this->aliasPrefix) { return sprintf('%s AS %s', $this->wrapSanitizer($table), $this->wrapSanitizer(strtolower($this->aliasPrefix))); } @@ -346,15 +341,16 @@ protected function buildAliasedTableName(string $table, array $statements): stri * Build just criteria part of the query * * @param array $statements - * @param bool $bindValues + * @param bool $bindValues * - * @return array * @throws Exception + * + * @return array */ public function criteriaOnly(array $statements, $bindValues = true): array { $sql = $bindings = []; - if (isset($statements['criteria']) === false) { + if (false === isset($statements['criteria'])) { return compact('sql', 'bindings'); } @@ -366,11 +362,12 @@ public function criteriaOnly(array $statements, $bindValues = true): array /** * Build delete query * - * @param array $statements + * @param array $statements * @param array|null $columns * - * @return array * @throws Exception + * + * @return array */ public function delete(array $statements, array $columns = null): array { @@ -378,8 +375,8 @@ public function delete(array $statements, array $columns = null): array $columnsQuery = ''; - if($columns !== null) { - foreach($columns as $key => $column) { + if (null !== $columns) { + foreach ($columns as $key => $column) { $columns[$key] = $this->wrapSanitizer($column); } @@ -399,7 +396,7 @@ public function delete(array $statements, array $columns = null): array $this->buildQueryPart(static::QUERY_PART_GROUPBY, $statements), $this->buildQueryPart(static::QUERY_PART_ORDERBY, $statements), $this->buildQueryPart(static::QUERY_PART_LIMIT, $statements), - $this->buildQueryPart(static::QUERY_PART_OFFSET, $statements) + $this->buildQueryPart(static::QUERY_PART_OFFSET, $statements), ]); $bindings = $whereBindings; @@ -409,12 +406,13 @@ public function delete(array $statements, array $columns = null): array /** * Build a generic insert/ignore/replace query * - * @param array $statements - * @param array $data + * @param array $statements + * @param array $data * @param string $type * - * @return array * @throws Exception + * + * @return array */ private function doInsert(array $statements, array $data, $type): array { @@ -427,7 +425,7 @@ private function doInsert(array $statements, array $data, $type): array if ($value instanceof Raw) { $values[] = (string)$value; } else { - $values[] = '?'; + $values[] = '?'; $bindings[] = $value; } } @@ -440,16 +438,14 @@ private function doInsert(array $statements, array $data, $type): array '(' . $this->arrayStr($values, ',', false) . ')', ]; - if (isset($statements['onduplicate']) === true) { - + if (true === isset($statements['onduplicate'])) { if (\count($statements['onduplicate']) < 1) { throw new Exception('No data given.', 4); } [$updateStatement, $updateBindings] = $this->getUpdateStatement($statements['onduplicate']); - $sqlArray[] = 'ON DUPLICATE KEY UPDATE ' . $updateStatement; - $bindings = array_merge($bindings, $updateBindings); - + $sqlArray[] = 'ON DUPLICATE KEY UPDATE ' . $updateStatement; + $bindings = array_merge($bindings, $updateBindings); } $sql = $this->concatenateQuery($sqlArray); @@ -466,11 +462,10 @@ private function doInsert(array $statements, array $data, $type): array */ private function getUpdateStatement(array $data): array { - $bindings = []; + $bindings = []; $statement = ''; foreach ($data as $key => $value) { - $statement .= $this->wrapSanitizer($key) . '='; if ($value instanceof Raw) { @@ -492,8 +487,9 @@ private function getUpdateStatement(array $data): array * @param array $statements * @param array $data * - * @return array * @throws Exception + * + * @return array */ public function insert(array $statements, array $data): array { @@ -506,8 +502,9 @@ public function insert(array $statements, array $data): array * @param array $statements * @param array $data * - * @return array * @throws Exception + * + * @return array */ public function insertIgnore(array $statements, array $data): array { @@ -520,8 +517,9 @@ public function insertIgnore(array $statements, array $data): array * @param array $statements * @param array $data * - * @return array * @throws Exception + * + * @return array */ public function replace(array $statements, array $data): array { @@ -534,30 +532,30 @@ public function replace(array $statements, array $data): array * @param array $statements * * @throws Exception + * * @return array */ public function select(array $statements): array { $hasDistincts = false; - if (isset($statements['distincts']) === true && \count($statements['distincts']) > 0) { + if (true === isset($statements['distincts']) && \count($statements['distincts']) > 0) { $hasDistincts = true; - if (isset($statements['selects']) === true && \count($statements['selects']) > 0) { + if (true === isset($statements['selects']) && \count($statements['selects']) > 0) { $statements['selects'] = array_merge($statements['distincts'], $statements['selects']); } else { $statements['selects'] = $statements['distincts']; } - - } else if (isset($statements['selects']) === false) { + } elseif (false === isset($statements['selects'])) { $statements['selects'] = ['*']; } // From $fromEnabled = false; - $tables = ''; + $tables = ''; - if (isset($statements['tables']) === true) { + if (true === isset($statements['tables'])) { $tablesFound = []; foreach ((array)$statements['tables'] as $table) { @@ -570,7 +568,7 @@ public function select(array $statements): array $tablesFound[] = $t; } - $tables = implode(',', $tablesFound); + $tables = implode(',', $tablesFound); $fromEnabled = true; } @@ -581,7 +579,7 @@ public function select(array $statements): array [$havingCriteria, $havingBindings] = $this->buildCriteriaWithType($statements, 'havings', 'HAVING'); $sql = $this->concatenateQuery([ - 'SELECT' . ($hasDistincts === true ? ' DISTINCT' : ''), + 'SELECT' . (true === $hasDistincts ? ' DISTINCT' : ''), $this->arrayStr($statements['selects'], ', '), $fromEnabled ? 'FROM' : '', $tables, @@ -609,9 +607,11 @@ public function select(array $statements): array * Returns specific part of a query like JOIN, LIMIT, OFFSET etc. * * @param string $section - * @param array $statements - * @return string + * @param array $statements + * * @throws Exception + * + * @return string */ protected function buildQueryPart(string $section, array $statements): string { @@ -626,7 +626,7 @@ protected function buildQueryPart(string $section, array $statements): string return isset($statements['offset']) ? 'OFFSET ' . $statements['offset'] : ''; case static::QUERY_PART_ORDERBY: $orderBys = ''; - if (isset($statements['orderBys']) === true && \is_array($statements['orderBys']) === true) { + if (true === isset($statements['orderBys']) && true === \is_array($statements['orderBys'])) { foreach ($statements['orderBys'] as $orderBy) { $orderBys .= $this->wrapSanitizer($orderBy['field']) . ' ' . $orderBy['type'] . ', '; } @@ -639,7 +639,7 @@ protected function buildQueryPart(string $section, array $statements): string return $orderBys; case static::QUERY_PART_GROUPBY: $groupBys = $this->arrayStr($statements['groupBys'], ', '); - if ($groupBys !== '' && isset($statements['groupBys']) === true) { + if ('' !== $groupBys && true === isset($statements['groupBys'])) { $groupBys = 'GROUP BY ' . $groupBys; } @@ -654,14 +654,16 @@ protected function buildQueryPart(string $section, array $statements): string /** * Adds union query to sql statement * - * @param array $statements + * @param array $statements * @param string $sql - * @return string + * * @throws Exception + * + * @return string */ protected function buildUnion(array $statements, string $sql): string { - if (isset($statements['unions']) === false || \count($statements['unions']) === 0) { + if (false === isset($statements['unions']) || 0 === \count($statements['unions'])) { return $sql; } @@ -669,11 +671,11 @@ protected function buildUnion(array $statements, string $sql): string /* @var $queryBuilder QueryBuilderHandler */ $queryBuilder = $union['query']; - if ($i === 0) { + if (0 === $i) { $sql .= ')'; } - $type = ($union['type'] !== QueryBuilderHandler::UNION_TYPE_NONE) ? $union['type'] . ' ' : ''; + $type = (QueryBuilderHandler::UNION_TYPE_NONE !== $union['type']) ? $union['type'] . ' ' : ''; $sql .= sprintf(' UNION %s(%s)', $type, $queryBuilder->getQuery('select')->getRawSql()); } @@ -686,12 +688,13 @@ protected function buildUnion(array $statements, string $sql): string * @param array $statements * @param array $data * - * @return array * @throws Exception + * + * @return array */ public function update(array $statements, array $data): array { - if (\count($data) === 0) { + if (0 === \count($data)) { throw new Exception('No data given.', 4); } @@ -705,7 +708,7 @@ public function update(array $statements, array $data): array $sqlArray = [ 'UPDATE', - $this->buildAliasedTableName($table,$statements), + $this->buildAliasedTableName($table, $statements), $this->buildQueryPart(static::QUERY_PART_JOIN, $statements), 'SET ' . $updateStatement, $whereCriteria, @@ -745,10 +748,10 @@ public function wrapSanitizer($value) foreach ($valueArr as $key => $subValue) { // Don't wrap if we have *, which is not a usual field - $valueArr[$key] = trim($subValue) === '*' ? $subValue : static::SANITIZER . $subValue . static::SANITIZER; + $valueArr[$key] = '*' === trim($subValue) ? $subValue : static::SANITIZER . $subValue . static::SANITIZER; } // Join these back with "." and return return implode('.', $valueArr); } -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/QueryBuilder/Adapters/Mysql.php b/src/Pecee/Pixie/QueryBuilder/Adapters/Mysql.php index b2a1684..1ff1ff7 100644 --- a/src/Pecee/Pixie/QueryBuilder/Adapters/Mysql.php +++ b/src/Pecee/Pixie/QueryBuilder/Adapters/Mysql.php @@ -4,8 +4,6 @@ /** * Class Mysql - * - * @package Pecee\Pixie\QueryBuilder\Adapters */ class Mysql extends BaseAdapter { @@ -13,4 +11,4 @@ class Mysql extends BaseAdapter * @var string */ public const SANITIZER = '`'; -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/QueryBuilder/Adapters/Pgsql.php b/src/Pecee/Pixie/QueryBuilder/Adapters/Pgsql.php index 768fdfb..856d561 100644 --- a/src/Pecee/Pixie/QueryBuilder/Adapters/Pgsql.php +++ b/src/Pecee/Pixie/QueryBuilder/Adapters/Pgsql.php @@ -4,8 +4,6 @@ /** * Class Pgsql - * - * @package Pecee\Pixie\QueryBuilder\Adapters */ class Pgsql extends BaseAdapter { @@ -13,4 +11,4 @@ class Pgsql extends BaseAdapter * @var string */ public const SANITIZER = '"'; -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/QueryBuilder/Adapters/Sqlite.php b/src/Pecee/Pixie/QueryBuilder/Adapters/Sqlite.php index ddd77d8..2f02fde 100644 --- a/src/Pecee/Pixie/QueryBuilder/Adapters/Sqlite.php +++ b/src/Pecee/Pixie/QueryBuilder/Adapters/Sqlite.php @@ -4,8 +4,6 @@ /** * Class Sqlite - * - * @package Pecee\Pixie\QueryBuilder\Adapters */ class Sqlite extends BaseAdapter { diff --git a/src/Pecee/Pixie/QueryBuilder/Adapters/Sqlserver.php b/src/Pecee/Pixie/QueryBuilder/Adapters/Sqlserver.php index 0dc9cbd..2ccbe49 100644 --- a/src/Pecee/Pixie/QueryBuilder/Adapters/Sqlserver.php +++ b/src/Pecee/Pixie/QueryBuilder/Adapters/Sqlserver.php @@ -1,4 +1,5 @@ 0) { + if (true === isset($statements['distincts']) && \count($statements['distincts']) > 0) { $hasDistincts = true; - if (isset($statements['selects']) === true && \count($statements['selects']) > 0) { + if (true === isset($statements['selects']) && \count($statements['selects']) > 0) { $statements['selects'] = array_merge($statements['distincts'], $statements['selects']); } else { $statements['selects'] = $statements['distincts']; } - - } else if (isset($statements['selects']) === false) { + } elseif (false === isset($statements['selects'])) { $statements['selects'] = ['*']; } // From $fromEnabled = false; - $tables = ''; + $tables = ''; - if (isset($statements['tables']) === true) { + if (true === isset($statements['tables'])) { $tablesFound = []; foreach ((array)$statements['tables'] as $table) { @@ -85,7 +87,7 @@ public function select(array $statements): array } else { $prefix = $statements['aliases'][$table] ?? null; - if ($prefix !== null) { + if (null !== $prefix) { $t = sprintf('%s AS %s', $table, strtolower($prefix)); } else { $t = sprintf('%s', $table); @@ -95,7 +97,7 @@ public function select(array $statements): array $tablesFound[] = $t; } - $tables = implode(',', $tablesFound); + $tables = implode(',', $tablesFound); $fromEnabled = true; } @@ -106,7 +108,7 @@ public function select(array $statements): array [$havingCriteria, $havingBindings] = $this->buildCriteriaWithType($statements, 'havings', 'HAVING'); $sql = $this->concatenateQuery([ - 'SELECT' . ($hasDistincts === true ? ' DISTINCT' : ''), + 'SELECT' . (true === $hasDistincts ? ' DISTINCT' : ''), $this->buildQueryPart(static::QUERY_PART_TOP, $statements), $this->arrayStr($statements['selects'], ', '), $fromEnabled ? 'FROM' : '', @@ -133,11 +135,12 @@ public function select(array $statements): array /** * Build delete query * - * @param array $statements + * @param array $statements * @param array|null $columns * - * @return array * @throws Exception + * + * @return array */ public function delete(array $statements, array $columns = null): array { @@ -145,8 +148,8 @@ public function delete(array $statements, array $columns = null): array $columnsQuery = ''; - if($columns !== null) { - foreach($columns as $key => $column) { + if (null !== $columns) { + foreach ($columns as $key => $column) { $columns[$key] = $this->wrapSanitizer($column); } @@ -188,10 +191,10 @@ public function wrapSanitizer($value) foreach ($valueArr as $key => $subValue) { // Don't wrap if we have *, which is not a usual field - $valueArr[$key] = trim($subValue) === '*' ? $subValue : '[' . $subValue . ']'; + $valueArr[$key] = '*' === trim($subValue) ? $subValue : '[' . $subValue . ']'; } // Join these back with "." and return return implode('.', $valueArr); } -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/QueryBuilder/IQueryBuilderHandler.php b/src/Pecee/Pixie/QueryBuilder/IQueryBuilderHandler.php index 6d38e24..a2eebe8 100644 --- a/src/Pecee/Pixie/QueryBuilder/IQueryBuilderHandler.php +++ b/src/Pecee/Pixie/QueryBuilder/IQueryBuilderHandler.php @@ -2,6 +2,6 @@ namespace Pecee\Pixie\QueryBuilder; -interface IQueryBuilderHandler { - -} \ No newline at end of file +interface IQueryBuilderHandler +{ +} diff --git a/src/Pecee/Pixie/QueryBuilder/JoinBuilder.php b/src/Pecee/Pixie/QueryBuilder/JoinBuilder.php index 5ee2483..b5ae13e 100644 --- a/src/Pecee/Pixie/QueryBuilder/JoinBuilder.php +++ b/src/Pecee/Pixie/QueryBuilder/JoinBuilder.php @@ -4,8 +4,6 @@ /** * Class JoinBuilder - * - * @package Pecee\Pixie\QueryBuilder */ class JoinBuilder extends QueryBuilderHandler { @@ -15,7 +13,7 @@ class JoinBuilder extends QueryBuilderHandler * @param string|Raw|\Closure $key * @param string|Raw|\Closure $operator * @param string|Raw|\Closure $value - * @param string $joiner + * @param string $joiner * * @return static */ @@ -36,6 +34,7 @@ public function on($key, $operator, $value, $joiner = 'AND'): self * Add join with USING syntax * * @param array $columns + * * @return static */ public function using(array $columns): self @@ -61,5 +60,4 @@ public function orOn($key, $operator, $value): self { return $this->on($key, $operator, $value, 'OR'); } - -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/QueryBuilder/NestedCriteria.php b/src/Pecee/Pixie/QueryBuilder/NestedCriteria.php index df0f797..98b53d5 100644 --- a/src/Pecee/Pixie/QueryBuilder/NestedCriteria.php +++ b/src/Pecee/Pixie/QueryBuilder/NestedCriteria.php @@ -4,24 +4,22 @@ /** * Class NestedCriteria - * - * @package Pecee\Pixie\QueryBuilder */ class NestedCriteria extends QueryBuilderHandler { /** - * @param string|Raw|\Closure $key + * @param string|Raw|\Closure $key * @param string|Raw|\Closure|null $operator * @param string|Raw|\Closure|null $value - * @param string $joiner + * @param string $joiner * * @return static */ protected function whereHandler($key, string $operator = null, $value = null, $joiner = 'AND'): QueryBuilderHandler { - $key = $this->addTablePrefix($key); + $key = $this->addTablePrefix($key); $this->statements['criteria'][] = compact('key', 'operator', 'value', 'joiner'); return $this; } -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php b/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php index 9330be8..c8e103a 100644 --- a/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php +++ b/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php @@ -12,8 +12,6 @@ /** * Class QueryBuilderHandler - * - * @package Pecee\Pixie\QueryBuilder */ class QueryBuilderHandler implements IQueryBuilderHandler { @@ -51,12 +49,12 @@ class QueryBuilderHandler implements IQueryBuilderHandler ]; /** - * @var null|\PDOStatement + * @var \PDOStatement|null */ protected $pdoStatement; /** - * @var null|string + * @var string|null */ protected $tablePrefix; @@ -88,7 +86,7 @@ public function __construct(Connection $connection = null) { $this->connection = $connection ?? Connection::getStoredConnection(); - if ($this->connection === null) { + if (null === $this->connection) { throw new ConnectionException('No database connection found.', 404); } @@ -97,16 +95,16 @@ public function __construct(Connection $connection = null) $adapterConfig = $this->connection->getAdapterConfig(); - if (isset($adapterConfig['prefix']) === true) { + if (true === isset($adapterConfig['prefix'])) { $this->tablePrefix = $adapterConfig['prefix']; } - if (isset($adapterConfig['query_overwriting']) === true) { + if (true === isset($adapterConfig['query_overwriting'])) { $this->overwriteEnabled = (bool)$adapterConfig['query_overwriting']; } // Query builder adapter instance - $adapterClass = $this->connection->getAdapter()->getQueryAdapterClass(); + $adapterClass = $this->connection->getAdapter()->getQueryAdapterClass(); $this->adapterInstance = new $adapterClass($this->connection); $this->connection->getPdoInstance()->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -116,7 +114,7 @@ public function __construct(Connection $connection = null) * Fetch query results as object of specified type * * @param string $className - * @param array $constructorArgs + * @param array $constructorArgs * * @return static */ @@ -153,7 +151,8 @@ public function setFetchMode($parameters = null): self * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException - * @return integer + * + * @return int */ public function count(string $field = '*'): int { @@ -175,16 +174,17 @@ public function count(string $field = '*'): int * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return float */ protected function aggregate(string $type, string $field = '*'): float { // Verify that field exists - if ($field !== '*' && isset($this->statements['selects']) === true && \in_array($field, $this->statements['selects'], true) === false) { + if ('*' !== $field && true === isset($this->statements['selects']) && false === \in_array($field, $this->statements['selects'], true)) { throw new ColumnNotFoundException(sprintf('Failed to count query - the column %s hasn\'t been selected in the query.', $field)); } - if (isset($this->statements['tables']) === false) { + if (false === isset($this->statements['tables'])) { throw new Exception('No table selected'); } @@ -193,7 +193,7 @@ protected function aggregate(string $type, string $field = '*'): float ->select([$this->raw(sprintf('%s(%s) AS ' . $this->adapterInstance->wrapSanitizer('field'), strtoupper($type), $field))]) ->first(); - return isset($count->field) === true ? (float)$count->field : 0; + return true === isset($count->field) ? (float)$count->field : 0; } /** @@ -203,7 +203,7 @@ protected function aggregate(string $type, string $field = '*'): float */ public function getAlias(): ?string { - return isset($this->statements['aliases']) === true ? array_values($this->statements['aliases'])[0] : null; + return true === isset($this->statements['aliases']) ? array_values($this->statements['aliases'])[0] : null; } /** @@ -213,9 +213,9 @@ public function getAlias(): ?string */ public function getTable(): ?string { - if (isset($this->statements['tables']) === true) { + if (true === isset($this->statements['tables'])) { $table = array_values($this->statements['tables'])[0]; - if ($table instanceof Raw === false) { + if (false === $table instanceof Raw) { return $table; } } @@ -235,13 +235,14 @@ public function getTable(): ?string * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return \stdClass|string|null */ public function first() { $result = $this->limit(1)->get(); - return ($result !== null && \count($result) !== 0) ? $result[0] : null; + return (null !== $result && 0 !== \count($result)) ? $result[0] : null; } /** @@ -256,6 +257,7 @@ public function first() * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return array */ public function get(): array @@ -266,24 +268,22 @@ public function get(): array * @var $start float * @var $result array */ - $queryObject = $this->getQuery(); $this->connection->setLastQuery($queryObject); $this->fireEvents(EventHandler::EVENT_BEFORE_SELECT, $queryObject); $executionTime = 0; - $startTime = microtime(true); - - if ($this->pdoStatement === null) { + $startTime = microtime(true); + if (null === $this->pdoStatement) { [$this->pdoStatement, $executionTime] = $this->statement( $queryObject->getSql(), $queryObject->getBindings() ); } - $result = \call_user_func_array([$this->pdoStatement, 'fetchAll'], $this->fetchParameters); + $result = \call_user_func_array([$this->pdoStatement, 'fetchAll'], $this->fetchParameters); $this->pdoStatement = null; $executionTime += microtime(true) - $startTime; @@ -298,11 +298,12 @@ public function get(): array /** * Returns Query-object. * - * @param string $type + * @param string $type * @param array|mixed|null $arguments * - * @return QueryObject * @throws Exception + * + * @return QueryObject */ public function getQuery(string $type = 'select', ...$arguments): QueryObject { @@ -316,7 +317,7 @@ public function getQuery(string $type = 'select', ...$arguments): QueryObject 'criteriaonly', ]; - if (\in_array(strtolower($type), $allowedTypes, true) === false) { + if (false === \in_array(strtolower($type), $allowedTypes, true)) { throw new Exception($type . ' is not a known type.', 1); } @@ -352,9 +353,9 @@ public function setConnection(Connection $connection): self /** * Fires event by given event name * - * @param string $name + * @param string $name * @param QueryObject $queryObject - * @param array $eventArguments + * @param array $eventArguments * * @return void */ @@ -367,9 +368,8 @@ public function fireEvents(string $name, QueryObject $queryObject, array $eventA * Execute statement * * @param string $sql - * @param array $bindings + * @param array $bindings * - * @return array PDOStatement and execution time as float * @throws \Pecee\Pixie\Exceptions\TableNotFoundException * @throws \Pecee\Pixie\Exceptions\ConnectionException * @throws \Pecee\Pixie\Exceptions\ColumnNotFoundException @@ -379,14 +379,16 @@ public function fireEvents(string $name, QueryObject $queryObject, array $eventA * @throws \Pecee\Pixie\Exceptions\DuplicateKeyException * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException + * + * @return array PDOStatement and execution time as float */ public function statement(string $sql, array $bindings = []): array { try { - $startTime = microtime(true); + $startTime = microtime(true); $pdoStatement = $this->pdo()->prepare($sql); - /** + /* * NOTE: * PHP 5.6 & 7 bug: https://bugs.php.net/bug.php?id=38546 * \PDO::PARAM_BOOL is not supported, use \PDO::PARAM_INT instead @@ -429,12 +431,11 @@ public function pdo(): PDO */ protected function parseParameterType($value): int { - - if ($value === null) { + if (null === $value) { return PDO::PARAM_NULL; } - if (\is_int($value) === true || \is_bool($value) === true) { + if (true === \is_int($value) || true === \is_bool($value)) { return PDO::PARAM_INT; } @@ -492,13 +493,13 @@ public function fetchNext(int $fetchNext): self */ public function select($fields): self { - if (\is_array($fields) === false) { + if (false === \is_array($fields)) { $fields = \func_get_args(); } $fields = $this->addTablePrefix($fields); - if ($this->overwriteEnabled === true) { + if (true === $this->overwriteEnabled) { $this->statements['selects'] = $fields; } else { $this->addStatement('selects', $fields); @@ -511,13 +512,13 @@ public function select($fields): self * Add table prefix (if given) on given string. * * @param string|array|Raw|\Closure $values - * @param bool $tableFieldMix If we have mixes of field and table names with a "." + * @param bool $tableFieldMix If we have mixes of field and table names with a "." * * @return array|string */ public function addTablePrefix($values, bool $tableFieldMix = true) { - if ($this->tablePrefix === null) { + if (null === $this->tablePrefix) { return $values; } @@ -525,7 +526,7 @@ public function addTablePrefix($values, bool $tableFieldMix = true) // If supplied value is not an array then make it one $single = false; - if (\is_array($values) === false) { + if (false === \is_array($values)) { $values = [$values]; // We had single value, so should return a single value @@ -544,11 +545,11 @@ public function addTablePrefix($values, bool $tableFieldMix = true) // If key is not integer, it is likely a alias mapping, so we need to change prefix target $target = &$value; - if (\is_int($key) === false) { + if (false === \is_int($key)) { $target = &$key; } - if ($tableFieldMix === false || ($tableFieldMix && strpos($target, '.') !== false)) { + if (false === $tableFieldMix || ($tableFieldMix && false !== strpos($target, '.'))) { $target = $this->tablePrefix . $target; } @@ -562,14 +563,14 @@ public function addTablePrefix($values, bool $tableFieldMix = true) /** * Add new statement to statement-list * - * @param string $key + * @param string $key * @param string|array $value * * @return void */ protected function addStatement(string $key, $value): void { - if (array_key_exists($key, $this->statements) === false) { + if (false === array_key_exists($key, $this->statements)) { $this->statements[$key] = (array)$value; } else { $this->statements[$key] = array_merge($this->statements[$key], (array)$value); @@ -582,7 +583,6 @@ protected function addStatement(string $key, $value): void * * @param string|array|null $tables Single table or multiple tables as an array or as multiple parameters * - * @return static * @throws Exception * * ``` @@ -595,14 +595,16 @@ protected function addStatement(string $key, $value): void * ->table(['table_one' => 'one']) * ->table($qb->raw('table_one as one')) * ``` + * + * @return static */ public function table($tables = null): self { - if ($tables === null) { + if (null === $tables) { return $this->from($tables); } - if (\is_array($tables) === false) { + if (false === \is_array($tables)) { // Because a single table is converted to an array anyways, this makes sense. $tables = \func_get_args(); } @@ -619,20 +621,20 @@ public function table($tables = null): self */ public function from($tables = null): self { - if ($tables === null) { + if (null === $tables) { $this->statements['tables'] = null; return $this; } - if (\is_array($tables) === false) { + if (false === \is_array($tables)) { $tables = \func_get_args(); } $tTables = []; foreach ((array)$tables as $key => $value) { - if (\is_string($key) === true) { + if (true === \is_string($key)) { $this->alias($value, $key); $tTables[] = $key; continue; @@ -641,7 +643,7 @@ public function from($tables = null): self $tTables[] = $value; } - $tTables = $this->addTablePrefix($tTables, false); + $tTables = $this->addTablePrefix($tTables, false); $this->statements['tables'] = $tTables; return $this; @@ -658,7 +660,7 @@ public function from($tables = null): self */ public function alias(string $alias, ?string $table = null): self { - if ($table === null && isset($this->statements['tables'][0]) === true) { + if (null === $table && true === isset($this->statements['tables'][0])) { $table = $this->statements['tables'][0]; } else { $table = $this->tablePrefix . $table; @@ -673,6 +675,7 @@ public function alias(string $alias, ?string $table = null): self * Creates and returns new query. * * @throws Exception + * * @return static */ public function newQuery(): self @@ -685,15 +688,16 @@ public function newQuery(): self * Call this method when you want to add a new sub-query in your where etc. * * @param QueryBuilderHandler $queryBuilder - * @param string|null $alias + * @param string|null $alias * * @throws Exception + * * @return Raw */ public function subQuery(QueryBuilderHandler $queryBuilder, $alias = null): Raw { $sql = '(' . $queryBuilder->getQuery()->getRawSql() . ')'; - if ($alias !== null) { + if (null !== $alias) { $sql .= ' AS ' . $this->adapterInstance->wrapSanitizer($alias); } @@ -707,14 +711,14 @@ public function subQuery(QueryBuilderHandler $queryBuilder, $alias = null): Raw * * For example: $qb->where('result', '>', $qb->raw('COUNT(`score`))); * - * @param string $value - * @param array|null|mixed $bindings ... + * @param string $value + * @param array|mixed|null $bindings ... * * @return Raw */ public function raw(string $value, $bindings = null): Raw { - if (\is_array($bindings) === false) { + if (false === \is_array($bindings)) { $bindings = \func_get_args(); array_shift($bindings); } @@ -736,6 +740,7 @@ public function raw(string $value, $bindings = null): Raw * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return float */ public function sum(string $field): float @@ -757,6 +762,7 @@ public function sum(string $field): float * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return float */ public function average(string $field): float @@ -778,6 +784,7 @@ public function average(string $field): float * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return float */ public function min(string $field): float @@ -799,6 +806,7 @@ public function min(string $field): float * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return float */ public function max(string $field): float @@ -809,7 +817,7 @@ public function max(string $field): float /** * Forms delete on the current query. * - * @var array|null $columns + * @var array|null * * @throws \Pecee\Pixie\Exception * @throws \Pecee\Pixie\Exceptions\ColumnNotFoundException @@ -820,6 +828,7 @@ public function max(string $field): float * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return \PDOStatement */ public function delete(array $columns = null): \PDOStatement @@ -854,6 +863,7 @@ public function delete(array $columns = null): \PDOStatement * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return \stdClass|string|null */ public function find($value, string $fieldName = 'id') @@ -864,8 +874,8 @@ public function find($value, string $fieldName = 'id') /** * Adds WHERE statement to the current query. * - * @param string|Raw|\Closure $key - * @param string|null $operator + * @param string|Raw|\Closure $key + * @param string|null $operator * @param mixed|Raw|\Closure|null $value * * @return static @@ -873,12 +883,12 @@ public function find($value, string $fieldName = 'id') public function where($key, $operator = null, $value = null): self { // If two params are given then assume operator is = - if (\func_num_args() === 2) { - $value = $operator; + if (2 === \func_num_args()) { + $value = $operator; $operator = '='; } - if (\is_bool($value) === true) { + if (true === \is_bool($value)) { $value = (int)$value; } @@ -888,16 +898,16 @@ public function where($key, $operator = null, $value = null): self /** * Handles where statements * - * @param string|Raw|\Closure $key - * @param string|null $operator + * @param string|Raw|\Closure $key + * @param string|null $operator * @param string|Raw|\Closure|null $value - * @param string $joiner + * @param string $joiner * * @return static */ protected function whereHandler($key, ?string $operator = null, $value = null, $joiner = 'AND'): self { - $key = $this->addTablePrefix($key); + $key = $this->addTablePrefix($key); $this->statements['wheres'][] = compact('key', 'operator', 'value', 'joiner'); return $this; @@ -918,6 +928,7 @@ protected function whereHandler($key, ?string $operator = null, $value = null, $ * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return array */ public function findAll(string $fieldName, $value): array @@ -928,7 +939,7 @@ public function findAll(string $fieldName, $value): array /** * Get event by event name * - * @param string $name + * @param string $name * @param string|null $table * * @return callable|null @@ -951,7 +962,7 @@ public function groupBy($field): self $field = $this->addTablePrefix($field); } - if (\is_array($field) === true) { + if (true === \is_array($field)) { $this->statements['groupBys'] = array_merge($this->statements['groupBys'], $field); } else { $this->statements['groupBys'][] = $field; @@ -963,13 +974,14 @@ public function groupBy($field): self /** * Adds new INNER JOIN statement to the current query. * - * @param string|Raw|\Closure $table + * @param string|Raw|\Closure $table * @param string|JoinBuilder|Raw|\Closure $key - * @param string|mixed|null $operator - * @param string|Raw|\Closure|null $value + * @param string|mixed|null $operator + * @param string|Raw|\Closure|null $value * - * @return static * @throws Exception + * + * @return static */ public function innerJoin($table, $key, $operator = null, $value = null): self { @@ -979,13 +991,12 @@ public function innerJoin($table, $key, $operator = null, $value = null): self /** * Adds new JOIN statement to the current query. * - * @param string|Raw|\Closure|array $table + * @param string|Raw|\Closure|array $table * @param string|JoinBuilder|Raw|\Closure|null $key - * @param string|null $operator - * @param string|Raw|\Closure $value - * @param string $type + * @param string|null $operator + * @param string|Raw|\Closure $value + * @param string $type * - * @return static * @throws Exception * * ``` @@ -1004,19 +1015,21 @@ public function innerJoin($table, $key, $operator = null, $value = null): self * $table->orOn('another_table.age', '>', $queryBuilder->raw(1)); * }) * ``` + * + * @return static */ public function join($table, $key = null, $operator = null, $value = null, $type = ''): self { $joinBuilder = null; - if ($key !== null) { + if (null !== $key) { $joinBuilder = new JoinBuilder($this->connection); - /** + /* * Build a new JoinBuilder class, keep it by reference so any changes made * in the closure should reflect here */ - if ($key instanceof \Closure === false) { + if (false === $key instanceof \Closure) { $key = static function (JoinBuilder $joinBuilder) use ($key, $operator, $value) { $joinBuilder->on($key, $operator, $value); }; @@ -1052,6 +1065,7 @@ public function join($table, $key = null, $operator = null, $value = null, $type * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return array|string */ public function insertIgnore(array $data) @@ -1074,13 +1088,14 @@ public function insertIgnore(array $data) * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return array|string|null */ private function doInsert(array $data, string $type) { // Insert single item - if (\is_array(current($data)) === false) { + if (false === \is_array(current($data))) { $queryObject = $this->getQuery($type, $data); $this->connection->setLastQuery($queryObject); @@ -1092,7 +1107,7 @@ private function doInsert(array $data, string $type) */ [$result, $executionTime] = $this->statement($queryObject->getSql(), $queryObject->getBindings()); - $insertId = $result->rowCount() === 1 ? $this->pdo()->lastInsertId() : null; + $insertId = 1 === $result->rowCount() ? $this->pdo()->lastInsertId() : null; $this->fireEvents(EventHandler::EVENT_AFTER_INSERT, $queryObject, [ 'insert_id' => $insertId, 'execution_time' => $executionTime, @@ -1105,8 +1120,7 @@ private function doInsert(array $data, string $type) // If the current batch insert is not in a transaction, we create one... - if ($this->pdo()->inTransaction() === false) { - + if (false === $this->pdo()->inTransaction()) { $this->transaction(function (Transaction $transaction) use (&$insertIds, $data, $type) { foreach ($data as $subData) { $insertIds[] = $transaction->doInsert($subData, $type); @@ -1130,16 +1144,17 @@ private function doInsert(array $data, string $type) * @param \Closure $callback * * @throws Exception + * * @return Transaction */ public function transaction(\Closure $callback): Transaction { - $queryTransaction = new Transaction($this->connection); + $queryTransaction = new Transaction($this->connection); $queryTransaction->statements = $this->statements; try { // Begin the PDO transaction - if ($this->pdo()->inTransaction() === false) { + if (false === $this->pdo()->inTransaction()) { $this->pdo()->beginTransaction(); } @@ -1148,16 +1163,12 @@ public function transaction(\Closure $callback): Transaction // If no errors have been thrown or the transaction wasn't completed within the closure, commit the changes $this->pdo()->commit(); - } catch (TransactionHaltException $e) { - // Commit or rollback behavior has been triggered in the closure return $queryTransaction; - } catch (\Exception $e) { - // Something went wrong. Rollback and throw Exception - if ($this->pdo()->inTransaction() === true) { + if (true === $this->pdo()->inTransaction()) { $this->pdo()->rollBack(); } @@ -1169,14 +1180,16 @@ public function transaction(\Closure $callback): Transaction /** * @param string|Raw|\Closure $table - * @param string|array $fields - * @param string $joinType - * @return static + * @param string|array $fields + * @param string $joinType + * * @throws Exception + * + * @return static */ public function joinUsing($table, $fields, $joinType = ''): self { - if (\is_array($fields) === false) { + if (false === \is_array($fields)) { $fields = [$fields]; } @@ -1197,13 +1210,14 @@ public function joinUsing($table, $fields, $joinType = ''): self /** * Adds new LEFT JOIN statement to the current query. * - * @param string|Raw|\Closure|array $table + * @param string|Raw|\Closure|array $table * @param string|JoinBuilder|Raw|\Closure $key - * @param string|null $operator - * @param string|Raw|\Closure|null $value + * @param string|null $operator + * @param string|Raw|\Closure|null $value * - * @return static * @throws Exception + * + * @return static */ public function leftJoin($table, $key, $operator = null, $value = null): self { @@ -1241,8 +1255,8 @@ public function onDuplicateKeyUpdate(array $data): self /** * Adds OR HAVING statement to the current query. * - * @param string|Raw|\Closure $key - * @param string|Raw|\Closure $operator + * @param string|Raw|\Closure $key + * @param string|Raw|\Closure $operator * @param mixed|Raw|\Closure|null $value * * @return static @@ -1256,15 +1270,15 @@ public function orHaving($key, $operator, $value): self * Adds HAVING statement to the current query. * * @param string|Raw|\Closure $key - * @param string|mixed $operator - * @param string|mixed $value - * @param string $joiner + * @param string|mixed $operator + * @param string|mixed $value + * @param string $joiner * * @return static */ public function having($key, $operator, $value, $joiner = 'AND'): self { - $key = $this->addTablePrefix($key); + $key = $this->addTablePrefix($key); $this->statements['havings'][] = compact('key', 'operator', 'value', 'joiner'); return $this; @@ -1273,8 +1287,8 @@ public function having($key, $operator, $value, $joiner = 'AND'): self /** * Adds OR WHERE statement to the current query. * - * @param string|Raw|\Closure $key - * @param string|null $operator + * @param string|Raw|\Closure $key + * @param string|null $operator * @param mixed|Raw|\Closure|null $value * * @return static @@ -1282,8 +1296,8 @@ public function having($key, $operator, $value, $joiner = 'AND'): self public function orWhere($key, $operator = null, $value = null): self { // If two params are given then assume operator is = - if (\func_num_args() === 2) { - $value = $operator; + if (2 === \func_num_args()) { + $value = $operator; $operator = '='; } @@ -1294,8 +1308,8 @@ public function orWhere($key, $operator = null, $value = null): self * Adds OR WHERE BETWEEN statement to the current query. * * @param string|Raw|\Closure $key - * @param string|integer|float $valueFrom - * @param string|integer|float $valueTo + * @param string|int|float $valueFrom + * @param string|int|float $valueTo * * @return static */ @@ -1308,7 +1322,7 @@ public function orWhereBetween($key, $valueFrom, $valueTo): self * Adds OR WHERE IN statement to the current query. * * @param string|Raw|\Closure $key - * @param array|Raw|\Closure $values + * @param array|Raw|\Closure $values * * @return static */ @@ -1320,8 +1334,8 @@ public function orWhereIn($key, $values): self /** * Adds OR WHERE NOT statement to the current query. * - * @param string|Raw|\Closure $key - * @param string|null $operator + * @param string|Raw|\Closure $key + * @param string|null $operator * @param mixed|Raw|\Closure|null $value * * @return static @@ -1329,8 +1343,8 @@ public function orWhereIn($key, $values): self public function orWhereNot($key, $operator = null, $value = null): self { // If two params are given then assume operator is = - if (\func_num_args() === 2) { - $value = $operator; + if (2 === \func_num_args()) { + $value = $operator; $operator = '='; } @@ -1341,7 +1355,7 @@ public function orWhereNot($key, $operator = null, $value = null): self * Adds or WHERE NOT IN statement to the current query. * * @param string|Raw|\Closure $key - * @param array|Raw|\Closure $values + * @param array|Raw|\Closure $values * * @return static */ @@ -1366,17 +1380,17 @@ public function orWhereNotNull($key): self * Handles WHERE NULL statements. * * @param string|Raw|\Closure $key - * @param string $prefix - * @param string $operator + * @param string $prefix + * @param string $operator * * @return static */ protected function whereNullHandler($key, string $prefix = '', string $operator = ''): self { - $key = $this->adapterInstance->wrapSanitizer($this->addTablePrefix($key)); - $prefix = ($prefix !== '') ? $prefix . ' ' : $prefix; + $key = $this->adapterInstance->wrapSanitizer($this->addTablePrefix($key)); + $prefix = ('' !== $prefix) ? $prefix . ' ' : $prefix; - return $this->{$operator . 'Where'}($this->raw("$key IS {$prefix}NULL")); + return $this->{$operator . 'Where'}($this->raw("$key IS {$prefix}null")); } /** @@ -1395,23 +1409,23 @@ public function orWhereNull($key): self * Adds ORDER BY statement to the current query. * * @param string|Raw|\Closure|array $fields - * @param string $direction + * @param string $direction * * @return static */ public function orderBy($fields, string $direction = 'ASC'): self { - if (\is_array($fields) === false) { + if (false === \is_array($fields)) { $fields = [$fields]; } foreach ((array)$fields as $key => $value) { $field = $key; - $type = $value; + $type = $value; - if (\is_int($key) === true) { + if (true === \is_int($key)) { $field = $value; - $type = $direction; + $type = $direction; } if (($field instanceof Raw) === false) { @@ -1439,6 +1453,7 @@ public function orderBy($fields, string $direction = 'ASC'): self * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return static */ public function query(string $sql, array $bindings = []): self @@ -1462,9 +1477,9 @@ public function query(string $sql, array $bindings = []): self /** * Register new event * - * @param string $name + * @param string $name * @param string|null $table - * @param \Closure $action + * @param \Closure $action * * @return void */ @@ -1476,7 +1491,7 @@ public function registerEvent(string $name, ?string $table = null, \Closure $act /** * Remove event by event-name and/or table * - * @param string $name + * @param string $name * @param string|null $table * * @return void @@ -1500,6 +1515,7 @@ public function removeEvent(string $name, ?string $table = null): void * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return array|string */ public function replace(array $data) @@ -1510,13 +1526,14 @@ public function replace(array $data) /** * Adds new right join statement to the current query. * - * @param string|Raw|\Closure|array $table + * @param string|Raw|\Closure|array $table * @param string|JoinBuilder|Raw|\Closure $key - * @param string|null $operator - * @param string|Raw|\Closure|null $value + * @param string|null $operator + * @param string|Raw|\Closure|null $value * - * @return static * @throws Exception + * + * @return static */ public function rightJoin($table, $key, ?string $operator = null, $value = null): self { @@ -1532,7 +1549,7 @@ public function rightJoin($table, $key, ?string $operator = null, $value = null) */ public function selectDistinct($fields): self { - if ($this->overwriteEnabled === true) { + if (true === $this->overwriteEnabled) { $this->statements['distincts'] = $fields; } else { $this->addStatement('distincts', $fields); @@ -1545,7 +1562,7 @@ public function selectDistinct($fields): self * Add union * * @param QueryBuilderHandler $query - * @param string|null $unionType + * @param string|null $unionType * * @return static $this */ @@ -1603,11 +1620,12 @@ public function setStatements(array $statements): self * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return array|\PDOStatement|string */ public function updateOrInsert(array $data) { - if ($this->first() !== null) { + if (null !== $this->first()) { return $this->update($data); } @@ -1628,6 +1646,7 @@ public function updateOrInsert(array $data) * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return \PDOStatement */ public function update(array $data): \PDOStatement @@ -1664,6 +1683,7 @@ public function update(array $data): \PDOStatement * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * * @return array|string */ public function insert(array $data) @@ -1674,9 +1694,9 @@ public function insert(array $data) /** * Adds WHERE BETWEEN statement to the current query. * - * @param string|Raw|\Closure $key - * @param string|integer|float|Raw|\Closure $valueFrom - * @param string|integer|float|Raw|\Closure $valueTo + * @param string|Raw|\Closure $key + * @param string|int|float|Raw|\Closure $valueFrom + * @param string|int|float|Raw|\Closure $valueTo * * @return static */ @@ -1689,7 +1709,7 @@ public function whereBetween($key, $valueFrom, $valueTo): self * Adds WHERE IN statement to the current query. * * @param string|Raw|\Closure $key - * @param array|Raw|\Closure $values + * @param array|Raw|\Closure $values * * @return static */ @@ -1701,17 +1721,17 @@ public function whereIn($key, $values): self /** * Adds WHERE NOT statement to the current query. * - * @param string|Raw|\Closure $key + * @param string|Raw|\Closure $key * @param string|array|Raw|\Closure|null $operator - * @param mixed|Raw|\Closure|null $value + * @param mixed|Raw|\Closure|null $value * * @return static */ public function whereNot($key, $operator = null, $value = null): self { // If two params are given then assume operator is = - if (\func_num_args() === 2) { - $value = $operator; + if (2 === \func_num_args()) { + $value = $operator; $operator = '='; } @@ -1722,7 +1742,7 @@ public function whereNot($key, $operator = null, $value = null): self * Adds OR WHERE NOT IN statement to the current query. * * @param string|Raw|\Closure $key - * @param array|Raw|\Closure $values + * @param array|Raw|\Closure $values * * @return static */ @@ -1757,12 +1777,15 @@ public function whereNull($key): self /** * Will add FOR statement to the end of the SELECT statement, like FOR UPDATE, FOR SHARE etc. + * * @param $statement string + * * @return static */ public function for(string $statement): self { $this->addStatement('for', $statement); + return $this; } @@ -1773,7 +1796,7 @@ public function for(string $statement): self */ public function getColumns(): array { - $tSelects = isset($this->statements['selects']) === true ? $this->statements['selects'] : []; + $tSelects = true === isset($this->statements['selects']) ? $this->statements['selects'] : []; $tColumns = []; foreach ($tSelects as $key => $value) { if (\is_string($value)) { @@ -1787,6 +1810,7 @@ public function getColumns(): array } } } + return $tColumns; } @@ -1804,6 +1828,7 @@ public function isOverwriteEnabled(): bool * If enabled calling from, select etc. will overwrite any existing values from previous calls in query. * * @param bool $enabled + * * @return static */ public function setOverwriteEnabled(bool $enabled): self @@ -1824,7 +1849,6 @@ public function __destruct() public function close(): void { $this->pdoStatement = null; - $this->connection = null; + $this->connection = null; } - } diff --git a/src/Pecee/Pixie/QueryBuilder/QueryObject.php b/src/Pecee/Pixie/QueryBuilder/QueryObject.php index 439061b..8844c15 100644 --- a/src/Pecee/Pixie/QueryBuilder/QueryObject.php +++ b/src/Pecee/Pixie/QueryBuilder/QueryObject.php @@ -6,8 +6,6 @@ /** * Class QueryObject - * - * @package Pecee\Pixie\QueryBuilder */ class QueryObject { @@ -29,14 +27,14 @@ class QueryObject /** * QueryObject constructor. * - * @param string $sql - * @param array $bindings + * @param string $sql + * @param array $bindings * @param Connection $connection */ public function __construct(string $sql, array $bindings, Connection $connection) { - $this->sql = $sql; - $this->bindings = $bindings; + $this->sql = $sql; + $this->bindings = $bindings; $this->connection = $connection; } @@ -73,40 +71,40 @@ public function getSql(): string * * Reference: http://stackoverflow.com/a/1376838/656489 * - * @param string $query The sql query with parameter placeholders - * @param array $params The array of substitution parameters + * @param string $query The sql query with parameter placeholders + * @param array $params The array of substitution parameters * * @return string The interpolated query */ protected function interpolateQuery($query, $params): string { - $keys = []; + $keys = []; $values = $params; // build a regular expression for each parameter foreach ($params as $key => $value) { $keys[] = '/' . (\is_string($key) ? ':' . $key : '[?]') . '/'; - if($value instanceof Raw) { + if ($value instanceof Raw) { continue; } // Try to parse object-types - if(\is_object($value) === true) { + if (true === \is_object($value)) { $value = (string)$value; } - if (\is_string($value) === true) { + if (true === \is_string($value)) { $values[$key] = $this->connection->getPdoInstance()->quote($value); continue; } - if (\is_array($value) === true) { + if (true === \is_array($value)) { $values[$key] = $this->connection->getPdoInstance()->quote(implode(',', $value)); continue; } - if ($value === null) { + if (null === $value) { $values[$key] = 'NULL'; continue; } @@ -122,5 +120,4 @@ public function getConnection(): Connection { return $this->connection; } - -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/QueryBuilder/Raw.php b/src/Pecee/Pixie/QueryBuilder/Raw.php index 677b3ed..a0d19cf 100644 --- a/src/Pecee/Pixie/QueryBuilder/Raw.php +++ b/src/Pecee/Pixie/QueryBuilder/Raw.php @@ -4,12 +4,9 @@ /** * Class Raw - * - * @package Pecee\Pixie\QueryBuilder */ class Raw { - /** * @var string */ @@ -23,12 +20,12 @@ class Raw /** * Raw constructor. * - * @param string $value + * @param string $value * @param array|string $bindings */ public function __construct(string $value, array $bindings = []) { - $this->value = $value; + $this->value = $value; $this->bindings = $bindings; } @@ -47,4 +44,4 @@ public function getBindings(): array { return $this->bindings; } -} \ No newline at end of file +} diff --git a/src/Pecee/Pixie/QueryBuilder/Transaction.php b/src/Pecee/Pixie/QueryBuilder/Transaction.php index 3399d69..3e97755 100644 --- a/src/Pecee/Pixie/QueryBuilder/Transaction.php +++ b/src/Pecee/Pixie/QueryBuilder/Transaction.php @@ -7,12 +7,9 @@ /** * Class Transaction - * - * @package Pecee\Pixie\QueryBuilder */ class Transaction extends QueryBuilderHandler { - protected $transactionStatement; /** @@ -41,7 +38,7 @@ public function transaction(\Closure $callback): Transaction * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws TransactionHaltException */ - public function commit() : void + public function commit(): void { try { $this->pdo()->commit(); @@ -66,7 +63,7 @@ public function commit() : void * @throws \Pecee\Pixie\Exceptions\NotNullException * @throws TransactionHaltException */ - public function rollBack() : void + public function rollBack(): void { try { $this->pdo()->rollBack(); @@ -83,22 +80,23 @@ public function rollBack() : void * @param string $sql * @param array $bindings * - * @throws \Pecee\Pixie\Exception - * @throws \Pecee\Pixie\Exceptions\ColumnNotFoundException + * @throws \Pecee\Pixie\Exceptions\TableNotFoundException * @throws \Pecee\Pixie\Exceptions\ConnectionException + * @throws \Pecee\Pixie\Exceptions\ColumnNotFoundException + * @throws \Pecee\Pixie\Exception * @throws \Pecee\Pixie\Exceptions\DuplicateColumnException * @throws \Pecee\Pixie\Exceptions\DuplicateEntryException * @throws \Pecee\Pixie\Exceptions\DuplicateKeyException * @throws \Pecee\Pixie\Exceptions\ForeignKeyException * @throws \Pecee\Pixie\Exceptions\NotNullException - * @throws \Pecee\Pixie\Exceptions\TableNotFoundException + * @throws Exception + * * @return array PDOStatement and execution time as float */ public function statement(string $sql, array $bindings = []): array { - if ($this->transactionStatement === null && $this->pdo()->inTransaction() === true) { - - $results = parent::statement($sql, $bindings); + if (null === $this->transactionStatement && true === $this->pdo()->inTransaction()) { + $results = parent::statement($sql, $bindings); $this->transactionStatement = $results[0]; return $results; @@ -106,5 +104,4 @@ public function statement(string $sql, array $bindings = []): array return parent::statement($sql, $bindings); } - } diff --git a/tests/Pecee/Pixie/ConnectionTest.php b/tests/Pecee/Pixie/ConnectionTest.php index 7d84e34..95bc9df 100644 --- a/tests/Pecee/Pixie/ConnectionTest.php +++ b/tests/Pecee/Pixie/ConnectionTest.php @@ -1,4 +1,6 @@ -assertEquals($class, \get_class($exception)); - if ($codes !== null) { + if (null !== $codes) { $this->assertContains($exception->getCode(), $codes, sprintf('Failed asserting exception- expected "%s" got "%s"', implode(' or ', $codes), $exception->getCode())); } } public function testConnectionException() { - // test error code 2002 try { (new \Pecee\Pixie\Connection('mysql', [ @@ -81,7 +80,6 @@ public function testConnectionException() ]))->connect(); throw new \RuntimeException('check'); } catch (\Exception $e) { - // Note: seems like some MySQL instances returns 1044 other 1045. $this->validateException($e, ConnectionException::class, 1044, 1045, 2002); } @@ -96,12 +94,10 @@ public function testConnectionException() } catch (\Exception $e) { $this->validateException($e, ConnectionException::class, 1); } - } public function testTableNotFoundException() { - $mysqlBuilder = $this->getQueryBuilder(); try { @@ -119,12 +115,10 @@ public function testTableNotFoundException() } catch (\Exception $e) { $this->validateException($e, TableNotFoundException::class, 1); } - } public function testColumnNotFoundException() { - $builder = $this->getQueryBuilder(); try { @@ -142,12 +136,10 @@ public function testColumnNotFoundException() } catch (\Exception $e) { $this->validateException($e, ColumnNotFoundException::class, 1); } - } public function testDuplicateEntryException() { - $builder = $this->getQueryBuilder(); try { @@ -169,7 +161,6 @@ public function testDuplicateEntryException() } catch (\Exception $e) { $this->validateException($e, DuplicateEntryException::class, 1); } - } public function testQueryAggregateColumnNotFoundException() @@ -250,5 +241,4 @@ public function testNotNullException() $this->validateException($e, NotNullException::class, 1); } } - } diff --git a/tests/Pecee/Pixie/NoTableSubQueryTest.php b/tests/Pecee/Pixie/NoTableSubQueryTest.php index 60d714e..4626b98 100644 --- a/tests/Pecee/Pixie/NoTableSubQueryTest.php +++ b/tests/Pecee/Pixie/NoTableSubQueryTest.php @@ -4,8 +4,6 @@ /** * Class NoTableSubQueryTest - * - * @package Pecee\Pixie */ class NoTableSubQueryTest extends TestCase { @@ -18,5 +16,4 @@ public function testRawQuery() $this->assertEquals('SELECT (SELECT COUNT(*) FROM `cb_mail`) AS `row1`, (SELECT COUNT(*) FROM `cb_event_message`) AS `row2` LIMIT 1', $count); } - } diff --git a/tests/Pecee/Pixie/QueryBuilderAggregateTest.php b/tests/Pecee/Pixie/QueryBuilderAggregateTest.php index 6b115b1..adb3303 100644 --- a/tests/Pecee/Pixie/QueryBuilderAggregateTest.php +++ b/tests/Pecee/Pixie/QueryBuilderAggregateTest.php @@ -4,12 +4,9 @@ /** * Class QueryBuilder - * - * @package Pecee\Pixie */ class QueryBuilderAggregateTest extends TestCase { - public function setUp() { return parent::setUp(); @@ -21,7 +18,6 @@ public function setUp() ['name' => 'horse', 'number_of_legs' => 4], ['name' => 'cat', 'number_of_legs' => 8], ]); - } public function testQueryCount() @@ -79,5 +75,4 @@ public function testSqliteQueryAverage() $this->assertEquals(13.3333333333333, $count); } - } diff --git a/tests/Pecee/Pixie/QueryBuilderBehaviorTest.php b/tests/Pecee/Pixie/QueryBuilderBehaviorTest.php index 4d6d430..266c40c 100644 --- a/tests/Pecee/Pixie/QueryBuilderBehaviorTest.php +++ b/tests/Pecee/Pixie/QueryBuilderBehaviorTest.php @@ -7,8 +7,6 @@ /** * Class QueryBuilderTest - * - * @package Pecee\Pixie */ class QueryBuilderTest extends TestCase { @@ -35,8 +33,7 @@ public function testDeleteQuery() $builder = $this->builder->table('my_table')->where('value', '=', 'Amrin'); - $this->assertEquals("DELETE FROM `cb_my_table` WHERE `value` = 'Amrin'" - , $builder->getQuery('delete')->getRawSql()); + $this->assertEquals("DELETE FROM `cb_my_table` WHERE `value` = 'Amrin'", $builder->getQuery('delete')->getRawSql()); } public function testEventPropagation() @@ -73,19 +70,18 @@ public function testEventPropagation() public function testInsertIgnoreQuery() { $builder = $this->builder->from('my_table'); - $data = [ + $data = [ 'key' => 'Name', 'value' => 'Sana', ]; - $this->assertEquals("INSERT IGNORE INTO `cb_my_table` (`key`,`value`) VALUES ('Name','Sana')" - , $builder->getQuery('insertignore', $data)->getRawSql()); + $this->assertEquals("INSERT IGNORE INTO `cb_my_table` (`key`,`value`) VALUES ('Name','Sana')", $builder->getQuery('insertignore', $data)->getRawSql()); } public function testInsertOnDuplicateKeyUpdateQuery() { $builder = $this->builder; - $data = [ + $data = [ 'name' => 'Sana', 'counter' => 1, ]; @@ -94,42 +90,40 @@ public function testInsertOnDuplicateKeyUpdateQuery() 'counter' => 2, ]; $builder->from('my_table')->onDuplicateKeyUpdate($dataUpdate); - $this->assertEquals("INSERT INTO `cb_my_table` (`name`,`counter`) VALUES ('Sana',1) ON DUPLICATE KEY UPDATE `name`='Sana',`counter`=2" - , $builder->getQuery('insert', $data)->getRawSql()); + $this->assertEquals("INSERT INTO `cb_my_table` (`name`,`counter`) VALUES ('Sana',1) ON DUPLICATE KEY UPDATE `name`='Sana',`counter`=2", $builder->getQuery('insert', $data)->getRawSql()); } public function testInsertQuery() { $builder = $this->builder->from('my_table'); - $data = [ + $data = [ 'key' => 'Name', 'value' => 'Sana', ]; - $this->assertEquals("INSERT INTO `cb_my_table` (`key`,`value`) VALUES ('Name','Sana')" - , $builder->getQuery('insert', $data)->getRawSql()); + $this->assertEquals("INSERT INTO `cb_my_table` (`key`,`value`) VALUES ('Name','Sana')", $builder->getQuery('insert', $data)->getRawSql()); } public function testIsPossibleToUseSubqueryInWhereClause() { - $sub = clone $this->builder; + $sub = clone $this->builder; $query = $this->builder->from('my_table')->whereIn('foo', $this->builder->subQuery( $sub->from('some_table')->select('foo')->where('id', 1) )); $this->assertEquals( - "SELECT * FROM `cb_my_table` WHERE `foo` IN (SELECT `foo` FROM `cb_some_table` WHERE `id` = 1)", + 'SELECT * FROM `cb_my_table` WHERE `foo` IN (SELECT `foo` FROM `cb_some_table` WHERE `id` = 1)', $query->getQuery()->getRawSql() ); } public function testIsPossibleToUseSubqueryInWhereNotClause() { - $sub = clone $this->builder; + $sub = clone $this->builder; $query = $this->builder->from('my_table')->whereNotIn('foo', $this->builder->subQuery( $sub->from('some_table')->select('foo')->where('id', 1) )); $this->assertEquals( - "SELECT * FROM `cb_my_table` WHERE `foo` NOT IN (SELECT `foo` FROM `cb_some_table` WHERE `id` = 1)", + 'SELECT * FROM `cb_my_table` WHERE `foo` NOT IN (SELECT `foo` FROM `cb_some_table` WHERE `id` = 1)', $query->getQuery()->getRawSql() ); } @@ -166,13 +160,12 @@ public function testRawStatementsWithinCriteria() public function testReplaceQuery() { $builder = $this->builder->from('my_table'); - $data = [ + $data = [ 'key' => 'Name', 'value' => 'Sana', ]; - $this->assertEquals("REPLACE INTO `cb_my_table` (`key`,`value`) VALUES ('Name','Sana')" - , $builder->getQuery('replace', $data)->getRawSql()); + $this->assertEquals("REPLACE INTO `cb_my_table` (`key`,`value`) VALUES ('Name','Sana')", $builder->getQuery('replace', $data)->getRawSql()); } public function testSelectAliases() @@ -180,7 +173,7 @@ public function testSelectAliases() $query = $this->builder->from('my_table')->select('foo')->select(['bar' => 'baz', 'qux']); $this->assertEquals( - "SELECT `foo`, `bar` AS `baz`, `qux` FROM `cb_my_table`", + 'SELECT `foo`, `bar` AS `baz`, `qux` FROM `cb_my_table`', $query->getQuery()->getRawSql() ); } @@ -188,7 +181,7 @@ public function testSelectAliases() public function testSelectDistinct() { $query = $this->builder->selectDistinct(['name', 'surname'])->from('my_table'); - $this->assertEquals("SELECT DISTINCT `name`, `surname` FROM `cb_my_table`", $query->getQuery()->getRawSql()); + $this->assertEquals('SELECT DISTINCT `name`, `surname` FROM `cb_my_table`', $query->getQuery()->getRawSql()); } public function testSelectDistinctAndSelectCalls() @@ -197,13 +190,13 @@ public function testSelectDistinctAndSelectCalls() 'birthday', 'address', ])->from('my_table'); - $this->assertEquals("SELECT DISTINCT `surname`, `name`, `birthday`, `address` FROM `cb_my_table`", $query->getQuery()->getRawSql()); + $this->assertEquals('SELECT DISTINCT `surname`, `name`, `birthday`, `address` FROM `cb_my_table`', $query->getQuery()->getRawSql()); } public function testSelectDistinctWithSingleColumn() { $query = $this->builder->selectDistinct('name')->from('my_table'); - $this->assertEquals("SELECT DISTINCT `name` FROM `cb_my_table`", $query->getQuery()->getRawSql()); + $this->assertEquals('SELECT DISTINCT `name` FROM `cb_my_table`', $query->getQuery()->getRawSql()); } public function testSelectFlexibility() @@ -248,8 +241,7 @@ public function testSelectQuery() ); $nestedQuery = $this->builder->table($this->builder->subQuery($query, 'bb'))->select('*'); - $this->assertEquals("SELECT * FROM (SELECT `cb_my_table`.*, count(cb_my_table.id) AS `tot`, (SELECT `details` FROM `cb_person_details` WHERE `person_id` = 3) AS `pop` FROM `cb_my_table` INNER JOIN `cb_person_details` ON `cb_person_details`.`person_id` = `cb_my_table`.`id` WHERE `value` = 'Ifrah' AND NOT `cb_my_table`.`id` = -1 OR NOT `cb_my_table`.`id` = -2 OR `cb_my_table`.`id` IN (1, 2) GROUP BY `value`, `cb_my_table`.`id`, `cb_person_details`.`id` HAVING `tot` < 2 ORDER BY `cb_my_table`.`id` DESC, `value` ASC LIMIT 1 OFFSET 0) AS `bb`" - , $nestedQuery->getQuery()->getRawSql()); + $this->assertEquals("SELECT * FROM (SELECT `cb_my_table`.*, count(cb_my_table.id) AS `tot`, (SELECT `details` FROM `cb_person_details` WHERE `person_id` = 3) AS `pop` FROM `cb_my_table` INNER JOIN `cb_person_details` ON `cb_person_details`.`person_id` = `cb_my_table`.`id` WHERE `value` = 'Ifrah' AND NOT `cb_my_table`.`id` = -1 OR NOT `cb_my_table`.`id` = -2 OR `cb_my_table`.`id` IN (1, 2) GROUP BY `value`, `cb_my_table`.`id`, `cb_person_details`.`id` HAVING `tot` < 2 ORDER BY `cb_my_table`.`id` DESC, `value` ASC LIMIT 1 OFFSET 0) AS `bb`", $nestedQuery->getQuery()->getRawSql()); } public function testSelectQueryWithNestedCriteriaAndJoins() @@ -273,8 +265,7 @@ public function testSelectQueryWithNestedCriteriaAndJoins() $table->orOn('b.age', '>', $builder->raw(1)); }); - $this->assertEquals("SELECT * FROM `cb_my_table` INNER JOIN `cb_person_details` AS `cb_a` ON `cb_a`.`person_id` = `cb_my_table`.`id` LEFT JOIN `cb_person_details` AS `cb_b` ON `cb_b`.`person_id` = `cb_my_table`.`id` AND `cb_b`.`deleted` = 0 OR `cb_b`.`age` > 1 WHERE `cb_my_table`.`id` > 1 OR `cb_my_table`.`id` = 1 AND (`value` LIKE '%sana%' OR (`key` LIKE '%sana%' OR `value` LIKE '%sana%'))" - , $query->getQuery()->getRawSql()); + $this->assertEquals("SELECT * FROM `cb_my_table` INNER JOIN `cb_person_details` AS `cb_a` ON `cb_a`.`person_id` = `cb_my_table`.`id` LEFT JOIN `cb_person_details` AS `cb_b` ON `cb_b`.`person_id` = `cb_my_table`.`id` AND `cb_b`.`deleted` = 0 OR `cb_b`.`age` > 1 WHERE `cb_my_table`.`id` > 1 OR `cb_my_table`.`id` = 1 AND (`value` LIKE '%sana%' OR (`key` LIKE '%sana%' OR `value` LIKE '%sana%'))", $query->getQuery()->getRawSql()); } public function testSelectQueryWithNull() @@ -287,7 +278,7 @@ public function testSelectQueryWithNull() ->orWhere('key5', '=', null); $this->assertEquals( - "SELECT * FROM `cb_my_table` WHERE `key1` IS NULL OR `key2` IS NULL AND `key3` IS NOT NULL OR `key4` IS NOT NULL OR `key5` = NULL", + 'SELECT * FROM `cb_my_table` WHERE `key1` IS NULL OR `key2` IS NULL AND `key3` IS NOT NULL OR `key4` IS NOT NULL OR `key5` = NULL', $query->getQuery()->getRawSql() ); } @@ -310,7 +301,7 @@ public function testSelectWithQueryEvents() public function testStandaloneWhereNot() { $query = $this->builder->table('my_table')->whereNot('foo', 1); - $this->assertEquals("SELECT * FROM `cb_my_table` WHERE NOT `foo` = 1", $query->getQuery()->getRawSql()); + $this->assertEquals('SELECT * FROM `cb_my_table` WHERE NOT `foo` = 1', $query->getQuery()->getRawSql()); } public function testUpdateQuery() @@ -322,8 +313,7 @@ public function testUpdateQuery() 'value' => 'Amrin', ]; - $this->assertEquals("UPDATE `cb_my_table` SET `key`='Sana',`value`='Amrin' WHERE `value` = 'Sana'" - , $builder->getQuery('update', $data)->getRawSql()); + $this->assertEquals("UPDATE `cb_my_table` SET `key`='Sana',`value`='Amrin' WHERE `value` = 'Sana'", $builder->getQuery('update', $data)->getRawSql()); } /** @@ -334,7 +324,6 @@ public function testUpdateQuery() */ public function testDeleteAdvancedQuery() { - $this->builder ->table('foo') ->leftJoin('bar', 'foo.id', '=', 'bar.id') @@ -358,7 +347,6 @@ public function testDeleteAdvancedQuery() */ public function testUpdateAdvancedQuery() { - $this->builder ->table('foo') ->leftJoin('bar', 'foo.id', '=', 'bar.id') @@ -376,21 +364,17 @@ public function testUpdateAdvancedQuery() public function testFromSubQuery() { - $subQuery = $this->builder->table('person'); - $builder = $this->builder->table($this->builder->subQuery($subQuery))->where('id', '=', 2); + $builder = $this->builder->table($this->builder->subQuery($subQuery))->where('id', '=', 2); $this->assertEquals('SELECT * FROM (SELECT * FROM `cb_person`) WHERE `id` = 2', $builder->getQuery()->getRawSql()); - } public function testTableAlias() { - $builder = $this->builder->table('persons')->alias('staff'); $this->assertEquals('SELECT * FROM `cb_persons` AS `staff`', $builder->getQuery()->getRawSql()); - } public function testWhereNotNullSubQuery() @@ -400,27 +384,21 @@ public function testWhereNotNullSubQuery() $query = $this->builder->whereNull($this->builder->subQuery($subQuery)); $this->assertEquals('SELECT * WHERE (SELECT * FROM `cb_persons` AS `staff`) IS NULL', $query->getQuery()->getRawSql()); - } public function testJoinUsing() { - $query = $this->builder->table('user')->joinUsing('user_data', ['user_id', 'image_id'])->where('user_id', '=', 1); $this->assertEquals('SELECT * FROM `cb_user` JOIN `cb_user_data` USING (`user_id`,`image_id`) WHERE `user_id` = 1', $query->getQuery()->getRawSql()); - } public function testJoinQueryBuilderUsing() { - $query = $this->builder->table('user')->join('user_data', function (JoinBuilder $jb) { $jb->using(['user_id', 'image_id']); })->where('user_id', '=', 1); $this->assertEquals('SELECT * FROM `cb_user` JOIN `cb_user_data` USING (`user_id`,`image_id`) WHERE `user_id` = 1', $query->getQuery()->getRawSql()); - } - } diff --git a/tests/Pecee/Pixie/QueryBuilderTest.php b/tests/Pecee/Pixie/QueryBuilderTest.php index ba53300..64e24b8 100644 --- a/tests/Pecee/Pixie/QueryBuilderTest.php +++ b/tests/Pecee/Pixie/QueryBuilderTest.php @@ -4,12 +4,9 @@ /** * Class QueryBuilder - * - * @package Pecee\Pixie */ class QueryBuilder extends TestCase { - public function testFalseBoolWhere() { $result = $this->builder->table('test')->where('id', '=', false); @@ -73,7 +70,7 @@ public function testInsertQueryReturnsNullForIgnoredInsert() public function testRawQuery() { - $query = 'select * from cb_my_table where id = ? and name = ? and hipster = null'; + $query = 'select * from cb_my_table where id = ? and name = ? and hipster = null'; $bindings = [5, 'usman', null]; $queryArr = $this->builder->query($query, $bindings)->get(); @@ -91,12 +88,11 @@ public function testNullableWhere() $query = $this->builder->table('person')->where('name', [1, null, 3]); $this->assertEquals('SELECT * FROM `cb_person` WHERE `name` = (1, NULL, 3)', $query->getQuery()->getRawSql()); - } public function testWhereBetween() { - $qb = $this->builder; + $qb = $this->builder; $query = $qb->table('animals')->whereBetween('created_date', $qb->raw('NOW()'), '27-05-2017'); $this->assertEquals('SELECT * FROM `cb_animals` WHERE `created_date` BETWEEN NOW() AND \'27-05-2017\'', $query->getQuery()->getRawSql()); @@ -104,8 +100,7 @@ public function testWhereBetween() public function testUnion() { - - $qb = $this->builder; + $qb = $this->builder; $firstQuery = $qb ->table('people') @@ -131,8 +126,8 @@ public function testUnion() public function testUnionSubQuery() { - $qb = $this->builder; - $first = $qb->table('people')->whereNull('name'); + $qb = $this->builder; + $first = $qb->table('people')->whereNull('name'); $second = $qb->table('people')->where('gender', '=', 'male')->union($first); $main = $qb->table($qb->subQuery($second, 'people'))->select(['id', 'name']); @@ -141,13 +136,12 @@ public function testUnionSubQuery() 'SELECT `id`, `name` FROM ((SELECT * FROM `cb_people` WHERE `gender` = \'male\') UNION (SELECT * FROM `cb_people` WHERE `name` IS NULL)) AS `people`', $main->getQuery()->getRawSql() ); - } public function testQueryOverwrite() { - $qb = $this->builder; - $first = $qb->table('people')->whereNull('name'); + $qb = $this->builder; + $first = $qb->table('people')->whereNull('name'); $second = $qb->table('people')->where('gender', '=', 'male')->union($first); $main = $qb->table($qb->subQuery($second, 'people'))->select(['id', 'name']); @@ -156,29 +150,29 @@ public function testQueryOverwrite() 'SELECT `id`, `name` FROM ((SELECT * FROM `cb_people` WHERE `gender` = \'male\') UNION (SELECT * FROM `cb_people` WHERE `name` IS NULL)) AS `people`', $main->getQuery()->getRawSql() ); - } - + /** * @throws \Pecee\Pixie\Exception */ - public function testGetColumns(){ + public function testGetColumns() + { $query = $this->builder ->newQuery() - ->table(['foo_table','foo']) - ->leftJoin(['bar_table','bar'],'foo._barId','=','bar.id') - ->leftJoin(['baz_table','baz'],'bar._bazId','=','baz.id') + ->table(['foo_table', 'foo']) + ->leftJoin(['bar_table', 'bar'], 'foo._barId', '=', 'bar.id') + ->leftJoin(['baz_table', 'baz'], 'bar._bazId', '=', 'baz.id') ->select([ 'foo.*', - 'bar.id'=>'barId', + 'bar.id'=> 'barId', 'name', - $this->builder->raw('baz.name as bazName') + $this->builder->raw('baz.name as bazName'), ]) ; $this->assertEquals([ - 'barId' => 'cb_bar.id', - 'name' => 'name' - ],$query->getColumns()); + 'barId' => 'cb_bar.id', + 'name' => 'name', + ], $query->getColumns()); } public function testQueryPartFor() @@ -187,5 +181,4 @@ public function testQueryPartFor() $this->assertEquals('SELECT * FROM `cb_users` FOR UPDATE', $query->getQuery()->getRawSql()); } - -} \ No newline at end of file +} diff --git a/tests/Pecee/Pixie/TransactionTest.php b/tests/Pecee/Pixie/TransactionTest.php index 04d0cd9..8727fa4 100644 --- a/tests/Pecee/Pixie/TransactionTest.php +++ b/tests/Pecee/Pixie/TransactionTest.php @@ -6,12 +6,9 @@ /** * Class QueryBuilderTest - * - * @package Pecee\Pixie */ class TransactionTest extends TestCase { - public function setUp() { $this->builder = $this->getLiveConnection(); @@ -19,13 +16,11 @@ public function setUp() public function testTransactionResult() { - $this->builder->statement('TRUNCATE `people`'); $ids = []; $this->builder->transaction(function (Transaction $q) use (&$ids) { - $ids = $q->table('people')->insert([ [ 'name' => 'Simon', @@ -46,7 +41,6 @@ public function testTransactionResult() 'nickname' => 'peter', ], ]); - }); $this->assertEquals(1, $ids[0]); @@ -54,7 +48,6 @@ public function testTransactionResult() $this->assertEquals(3, $ids[2]); $this->assertEquals($this->builder->table('people')->count(), 3); - } /** @@ -62,7 +55,6 @@ public function testTransactionResult() */ public function testNestedTransactions() { - $this->builder->statement('TRUNCATE `people`; TRUNCATE `animal`'); function getAnimals() @@ -100,33 +92,26 @@ function getPersons() } $this->builder->transaction(function (Transaction $qb) { - function firstTrans(Transaction $oQuery) { - $oQuery->transaction(function (Transaction $qb) { - $qb->table('animal')->insert([ getAnimals(), ]); - }); } function secondTrans(Transaction $oQuery) { - $oQuery->transaction(function (\Pecee\Pixie\QueryBuilder\Transaction $qb) { - + $oQuery->transaction(function (Transaction $qb) { $qb->table('people')->insert([ getPersons(), ]); - }); } firstTrans($qb); secondTrans($qb); - }); $animals = $this->builder->table('animal')->select(['name', 'number_of_legs'])->get(); @@ -183,5 +168,4 @@ public function testLastQuery() $this->assertEquals($this->builder->getLastQuery()->getRawSql(), 'SELECT * FROM `animal` WHERE `name` = 2'); } - } diff --git a/tests/TestCase.php b/tests/TestCase.php index 8bc331f..5e998d8 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -9,8 +9,6 @@ /** * Class TestCase - * - * @package Pecee\Pixie */ class TestCase extends \PHPUnit\Framework\TestCase { @@ -39,12 +37,11 @@ public function callbackMock() { $args = func_get_args(); - return count($args) == 1 ? $args[0] : $args; + return 1 == count($args) ? $args[0] : $args; } public function setUp() { - $this->mockPdoStatement = $this->getMockBuilder(\PDOStatement::class)->getMock(); $mockPdoStatement = &$this->mockPdoStatement; @@ -109,10 +106,12 @@ public function setUp() } /** - * @return \Pecee\Pixie\QueryBuilder\QueryBuilderHandler * @throws \Pecee\Pixie\Exception + * + * @return \Pecee\Pixie\QueryBuilder\QueryBuilderHandler */ - public function getLiveConnection() { + public function getLiveConnection() + { $connection = new \Pecee\Pixie\Connection('mysql', [ 'driver' => 'mysql', 'host' => '127.0.0.1', @@ -127,14 +126,17 @@ public function getLiveConnection() { $qb = $connection->getQueryBuilder(); $qb->pdo()->exec(file_get_contents(__DIR__.'/db_mysql.sql')); $qb->pdo()->exec(file_get_contents(__DIR__.'/db_values.sql')); + return $qb->newQuery(); } /** - * @return \Pecee\Pixie\QueryBuilder\QueryBuilderHandler * @throws \Pecee\Pixie\Exception + * + * @return \Pecee\Pixie\QueryBuilder\QueryBuilderHandler */ - public function getLiveConnectionSqlite() { + public function getLiveConnectionSqlite() + { $connection = new \Pecee\Pixie\Connection('sqlite', [ 'driver' => 'sqlite', 'database' => ':memory:', @@ -145,8 +147,8 @@ public function getLiveConnectionSqlite() { $qb = $connection->getQueryBuilder(); $qb->pdo()->exec(file_get_contents(__DIR__.'/db_sqlite.sql')); $qb->pdo()->exec(file_get_contents(__DIR__.'/db_values.sql')); - return $qb->newQuery(); + return $qb->newQuery(); } public function tearDown() @@ -157,8 +159,6 @@ public function tearDown() /** * Class MockPdo - * - * @package Pecee\Pixie */ class MockPdo extends \PDO { @@ -167,6 +167,5 @@ class MockPdo extends \PDO */ public function __construct() { - } -} \ No newline at end of file +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 56d1036..2ea7096 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,4 +1,4 @@