From d412a2475206edb77705fc4cda57f69e172058ee Mon Sep 17 00:00:00 2001 From: Gaiidenn Date: Thu, 7 Sep 2017 13:50:37 +0200 Subject: [PATCH 001/208] Update objectGetValidationFailures.php updated @return tag for better IDE auto-completion and parsing --- .../Behavior/Validate/templates/objectGetValidationFailures.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Generator/Behavior/Validate/templates/objectGetValidationFailures.php b/src/Propel/Generator/Behavior/Validate/templates/objectGetValidationFailures.php index 6e205a93f6..4a15761cd1 100644 --- a/src/Propel/Generator/Behavior/Validate/templates/objectGetValidationFailures.php +++ b/src/Propel/Generator/Behavior/Validate/templates/objectGetValidationFailures.php @@ -3,7 +3,7 @@ * Gets any ConstraintViolation objects that resulted from last call to validate(). * * - * @return object ConstraintViolationList + * @return ConstraintViolationList * @see validate() */ public function getValidationFailures() From 05a881d88ac5e5642bec82c496b1a77cd8b617f7 Mon Sep 17 00:00:00 2001 From: Sacha Durand Date: Thu, 20 Feb 2020 02:24:49 +0100 Subject: [PATCH 002/208] alphabetical order in 'use' statements --- .../Runtime/Collection/ArrayCollectionTest.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php b/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php index 8e28805f69..b093af725a 100644 --- a/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php +++ b/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php @@ -10,18 +10,19 @@ namespace Propel\Tests\Runtime\Collection; + +use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\ActiveQuery\PropelQuery; +use Propel\Runtime\Collection\ArrayCollection; +use Propel\Runtime\Collection\ObjectCollection; +use Propel\Runtime\Exception\PropelException; +use Propel\Runtime\Map\TableMap; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Country; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; +use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; -use Propel\Runtime\Collection\ObjectCollection; -use Propel\Runtime\Collection\ArrayCollection; -use Propel\Runtime\Exception\PropelException; -use Propel\Runtime\ActiveQuery\ModelCriteria; -use Propel\Runtime\ActiveQuery\PropelQuery; -use Propel\Runtime\Map\TableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Test class for ObjectCollection. From cec286714d995dbd2a7f587e13664f0b31cc79be Mon Sep 17 00:00:00 2001 From: nizcnas <67631582+nizcnas@users.noreply.github.com> Date: Tue, 30 Jun 2020 12:01:17 +0200 Subject: [PATCH 003/208] FIX bug CLOB_EMU oracle --- src/Propel/Generator/Platform/OraclePlatform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Generator/Platform/OraclePlatform.php b/src/Propel/Generator/Platform/OraclePlatform.php index 664398521c..ecdef9fcd2 100644 --- a/src/Propel/Generator/Platform/OraclePlatform.php +++ b/src/Propel/Generator/Platform/OraclePlatform.php @@ -359,7 +359,7 @@ public function getAddIndexDDL(Index $index) */ public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = " ") { - if ($column->getPDOType() == PropelTypes::CLOB_EMU) { + if ($column->getType() == PropelTypes::CLOB_EMU) { return sprintf( "%s\$stmt->bindParam(%s, %s, %s, strlen(%s)); ", From ae2f88c302bf980ca943daf04a5db6d112a27c2d Mon Sep 17 00:00:00 2001 From: Nizar Date: Wed, 1 Jul 2020 12:10:21 +0200 Subject: [PATCH 004/208] fix php version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f1bdef76b5..d5e975ea82 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=7.1", + "php": ">=7.0.29", "symfony/yaml": "~2.3||~3.0||~4.0||^5.0", "symfony/console": "~2.4||~3.0||^4.0", "symfony/finder": "~2.3||~3.0||~4.0||^5.0", From 9959d2c713824c04461db579a7b091ba6dbc0330 Mon Sep 17 00:00:00 2001 From: Nizar Date: Wed, 1 Jul 2020 12:24:29 +0200 Subject: [PATCH 005/208] set PHP version 7.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d5e975ea82..f1bdef76b5 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=7.0.29", + "php": ">=7.1", "symfony/yaml": "~2.3||~3.0||~4.0||^5.0", "symfony/console": "~2.4||~3.0||^4.0", "symfony/finder": "~2.3||~3.0||~4.0||^5.0", From 9cde76f5950cb42b2ddc9d2e7dcef8a184a82721 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Mon, 29 Jun 2020 12:23:46 +0200 Subject: [PATCH 006/208] Properly register the translation dependency needed by the validation behaviour for sf >= 2.5 Symfony\\Component\\Translation\\IdentityTranslator Class was introduced in 2.0 --- composer.json | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index f1bdef76b5..119d61e9f6 100644 --- a/composer.json +++ b/composer.json @@ -18,17 +18,18 @@ "require": { "php": ">=7.1", "symfony/yaml": "~2.3||~3.0||~4.0||^5.0", + "symfony/config": "~2.3||~3.0||^4.0", "symfony/console": "~2.4||~3.0||^4.0", - "symfony/finder": "~2.3||~3.0||~4.0||^5.0", - "symfony/validator": "~2.3||~3.0.0||~3.1.0||^3.2.4||~4.0.0||~4.1.0", "symfony/filesystem": "~2.3||~3.0||~4.0||^5.0", - "symfony/config": "~2.3||~3.0||^4.0", + "symfony/finder": "~2.3||~3.0||~4.0||^5.0", + "symfony/translation": "^2.0||^3.0|^4.0||^5.0", + "symfony/validator": "~2.3||~3.0.0||~3.1.0||^3.2.4||~4.0.0||~4.1.0||~4.2.0", "psr/log": "^1.0" }, "require-dev": { "monolog/monolog": "^1.3", - "phpunit/phpunit": "^7.0", - "phpstan/phpstan": "^0.12.4" + "phpstan/phpstan": "^0.12.4", + "phpunit/phpunit": "^7.0" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." From 9bc9162b45b00569985efb768f019c40acc27828 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Mon, 29 Jun 2020 13:59:12 +0200 Subject: [PATCH 007/208] sf 2.5 is about 5 years past EOL, dropping it reduces uppredictable codepaths and feature sniffing --- composer.json | 14 +++++----- .../Behavior/Validate/ValidateBehavior.php | 27 ++++++------------- .../Validate/templates/objectValidate.php | 8 ------ ...eInheritanceHandleValidateBehaviorTest.php | 8 +----- 4 files changed, 16 insertions(+), 41 deletions(-) diff --git a/composer.json b/composer.json index 119d61e9f6..ec3cd3da73 100644 --- a/composer.json +++ b/composer.json @@ -17,13 +17,13 @@ ], "require": { "php": ">=7.1", - "symfony/yaml": "~2.3||~3.0||~4.0||^5.0", - "symfony/config": "~2.3||~3.0||^4.0", - "symfony/console": "~2.4||~3.0||^4.0", - "symfony/filesystem": "~2.3||~3.0||~4.0||^5.0", - "symfony/finder": "~2.3||~3.0||~4.0||^5.0", - "symfony/translation": "^2.0||^3.0|^4.0||^5.0", - "symfony/validator": "~2.3||~3.0.0||~3.1.0||^3.2.4||~4.0.0||~4.1.0||~4.2.0", + "symfony/yaml": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", + "symfony/config": "^2.7.0||^3.0.0||^4.0.0", + "symfony/console": "^2.7.0||^3.0.0||^4.0.0", + "symfony/filesystem": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", + "symfony/finder": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", + "symfony/translation": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", + "symfony/validator": "^2.7.0||~3.0.0||~3.1.0||^3.2.4||~4.0.0||~4.1.0||~4.2.0", "psr/log": "^1.0" }, "require-dev": { diff --git a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php index 209b518b56..89d456078a 100644 --- a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php +++ b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php @@ -49,25 +49,14 @@ public function objectMethods($builder) 'Symfony\\Component\\Validator\\ConstraintViolationList' ); - //if SF >= 2.5 use new validator classes - if(class_exists('Symfony\\Component\\Validator\\Validator\\RecursiveValidator')) { - $this->builder->declareClasses( - 'Symfony\\Component\\Validator\\Validator\\RecursiveValidator', - 'Symfony\\Component\\Validator\\Context\\ExecutionContextFactory', - 'Symfony\\Component\\Validator\\Mapping\\Factory\LazyLoadingMetadataFactory', - 'Symfony\\Component\\Validator\\Context\\ExecutionContextInterface', - 'Symfony\\Component\\Validator\\Validator\\ValidatorInterface', - 'Symfony\\Component\\Translation\\IdentityTranslator' - ); - } else { - $this->builder->declareClasses( - 'Symfony\\Component\\Validator\\Validator', - 'Symfony\\Component\\Validator\\Mapping\ClassMetadataFactory', - 'Symfony\\Component\\Validator\\DefaultTranslator', - 'Symfony\\Component\\Validator\\ExecutionContextInterface', - 'Symfony\\Component\\Validator\\ValidatorInterface' - ); - } + $this->builder->declareClasses( + 'Symfony\\Component\\Validator\\Validator\\RecursiveValidator', + 'Symfony\\Component\\Validator\\Context\\ExecutionContextFactory', + 'Symfony\\Component\\Validator\\Mapping\\Factory\LazyLoadingMetadataFactory', + 'Symfony\\Component\\Validator\\Context\\ExecutionContextInterface', + 'Symfony\\Component\\Validator\\Validator\\ValidatorInterface', + 'Symfony\\Component\\Translation\\IdentityTranslator' + ); $script = $this->addLoadValidatorMetadataMethod(); $script .= $this->addValidateMethod(); diff --git a/src/Propel/Generator/Behavior/Validate/templates/objectValidate.php b/src/Propel/Generator/Behavior/Validate/templates/objectValidate.php index 3ac3c79984..d313b5f70b 100644 --- a/src/Propel/Generator/Behavior/Validate/templates/objectValidate.php +++ b/src/Propel/Generator/Behavior/Validate/templates/objectValidate.php @@ -9,19 +9,11 @@ public function validate(ValidatorInterface $validator = null) { if (null === $validator) { -= 2.5 use new validator classes?> $validator = new RecursiveValidator( new ExecutionContextFactory(new IdentityTranslator()), new LazyLoadingMetadataFactory(new StaticMethodLoader()), new ConstraintValidatorFactory() ); - - $validator = new Validator( - new ClassMetadataFactory(new StaticMethodLoader()), - new ConstraintValidatorFactory(), - new DefaultTranslator() - ); - } $failureMap = new ConstraintViolationList(); diff --git a/tests/Propel/Tests/Generator/Behavior/Validate/I18nConcreteInheritanceHandleValidateBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Validate/I18nConcreteInheritanceHandleValidateBehaviorTest.php index fc755fe787..117199bfe8 100644 --- a/tests/Propel/Tests/Generator/Behavior/Validate/I18nConcreteInheritanceHandleValidateBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Validate/I18nConcreteInheritanceHandleValidateBehaviorTest.php @@ -27,13 +27,7 @@ class I18nConcreteInheritanceHandleValidateBehaviorTest extends BookstoreTestBas public function assertPreConditions() { - //if SF >= 2.5 use new validator classes - if(class_exists('Symfony\\Component\\Validator\\Validator\\RecursiveValidator')) { - $this->metadataFactory = new \Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory(new StaticMethodLoader()); - } else { - $this->metadataFactory = new \Symfony\Component\Validator\Mapping\ClassMetadataFactory(new StaticMethodLoader()); - } - + $this->metadataFactory = new \Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory(new StaticMethodLoader()); } public function testI18nBehaviorHandlesValidateBehavior() From 5b3db85dd1d2295bf10e98ea503e19570a37d43b Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Mon, 29 Jun 2020 14:18:45 +0200 Subject: [PATCH 008/208] Requires phpunit fix for reflection on php7.4. 7.5.15 Also runs on php7.1 https://github.com/sebastianbergmann/phpunit/compare/7.5.14...7.5.15 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ec3cd3da73..10a4bee8a7 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "require-dev": { "monolog/monolog": "^1.3", "phpstan/phpstan": "^0.12.4", - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^7.5.15" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." From 0ed190f454774379604f0fec6a7af5feff368bbb Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Mon, 29 Jun 2020 14:35:28 +0200 Subject: [PATCH 009/208] Tooling does not function as expected When manually setting composer values to the minimum I get different actual results. --- .travis.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index e000f0517b..96d39cf9be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -326,17 +326,6 @@ jobs: - composer install --ignore-platform-reqs - composer show - - name: Minimum versions using prefer-lowest - php: 7.2 - env: DB=agnostic - install: - - composer update --prefer-lowest --prefer-stable --prefer-dist --no-interaction - - composer require --dev dereuromark/composer-prefer-lowest - script: - - vendor/bin/validate-prefer-lowest - - composer show - - vendor/bin/phpunit -v -c tests/$DB.phpunit.xml - allow_failures: - php: nightly From 073dcccc1925eebe462f8447323d7a5c663229f3 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Mon, 29 Jun 2020 16:35:13 +0200 Subject: [PATCH 010/208] Now that 4.x works, check 5.x --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 10a4bee8a7..dca6c98d69 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "symfony/filesystem": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/finder": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/translation": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/validator": "^2.7.0||~3.0.0||~3.1.0||^3.2.4||~4.0.0||~4.1.0||~4.2.0", + "symfony/validator": "^2.7.0||~3.0.0||~3.1.0||^3.2.4||^4.0.0||^5.0.0", "psr/log": "^1.0" }, "require-dev": { From b71bfd29fa4e1de76d881d8db7896ee52b69bda3 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Mon, 29 Jun 2020 16:37:19 +0200 Subject: [PATCH 011/208] sf/validator 3.0.0 -> 3.1.6 are not php 7.4 compatible --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index dca6c98d69..628f030d6b 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "symfony/filesystem": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/finder": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/translation": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/validator": "^2.7.0||~3.0.0||~3.1.0||^3.2.4||^4.0.0||^5.0.0", + "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||^4.0.0||^5.0.0", "psr/log": "^1.0" }, "require-dev": { From fedae23952006e39f2c8b22196808d4c798bf695 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Mon, 29 Jun 2020 17:44:48 +0200 Subject: [PATCH 012/208] Propel fails on multiple versions of symfony in different ways per version and module. When digging deeper into inter-major versions of symfony we appear to have even more issues than expected. Here's where CI is failing: | Version | All | Yaml | Config | Console | Filesystem | Finder | Translation | Validator | |:---------------------------------: |----------------------------------- |-------------------- |-------------------- |-------------------- |-------------------- |-------------------- |-------------------- |-------------------- | | ~2.7 | :x: | :heavy_check_mark: | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | ^2.7 | :x: | :heavy_check_mark: | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | ~3.0 | :x: | :heavy_check_mark: | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | :question: | :x: | | ^3.1.7 | :x: | :heavy_check_mark: | :heavy_check_mark: | :writing_hand: | :heavy_check_mark: | :heavy_check_mark: | :question: | :heavy_check_mark: | | ^3.0 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | ~v4.0 | :x: | :heavy_check_mark: | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | ^4.0 | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :question: | | v5 | :x: | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | mixed use of v2 or
v3 or v4 or v5 | :heavy_check_mark: | :game_die: | :game_die: | :game_die: | :game_die: | :game_die: | :game_die: | :game_die: | - :writing_hand: = I had to change propel - :game_die: = you need the magic versions to line up just right on your actual project too. - :heavy_check_mark: = No problems. - :x: = Propel doesn't work with this. - :question: = I don't know why it fails but I suspect this is related. --- .travis.yml | 73 ++++++++++++++++++++++ tests/composer/composer-symfony27-max.json | 55 ++++++++++++++++ tests/composer/composer-symfony27-min.json | 55 ++++++++++++++++ tests/composer/composer-symfony3-max.json | 55 ++++++++++++++++ tests/composer/composer-symfony3-min.json | 55 ++++++++++++++++ tests/composer/composer-symfony4-max.json | 55 ++++++++++++++++ tests/composer/composer-symfony4-min.json | 55 ++++++++++++++++ tests/composer/composer-symfony5-max.json | 55 ++++++++++++++++ tests/composer/composer-symfony5-min.json | 55 ++++++++++++++++ 9 files changed, 513 insertions(+) create mode 100644 tests/composer/composer-symfony27-max.json create mode 100644 tests/composer/composer-symfony27-min.json create mode 100644 tests/composer/composer-symfony3-max.json create mode 100644 tests/composer/composer-symfony3-min.json create mode 100644 tests/composer/composer-symfony4-max.json create mode 100644 tests/composer/composer-symfony4-min.json create mode 100644 tests/composer/composer-symfony5-max.json create mode 100644 tests/composer/composer-symfony5-min.json diff --git a/.travis.yml b/.travis.yml index 96d39cf9be..c41251741c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -326,8 +326,81 @@ jobs: - composer install --ignore-platform-reqs - composer show + - php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - composer install --ignore-platform-reqs + - composer show + + + - name: "sf ~2.7" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-min.json composer install + - composer show + - name: "sf ^2.7" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-max.json composer install + - composer show + - name: "sf ~3" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-min.json composer install + - composer show + - name: "sf ^3" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-max.json composer install + - composer show + - name: "sf ~4" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-min.json composer install + - composer show + - name: "sf ^4" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-max.json composer install + - composer show + - name: "sf ~5" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-min.json composer install + - composer show + - name: "sf ^5" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-max.json composer install + - composer show + allow_failures: - php: nightly + - name: "sf ~2.7" + - name: "sf ^2.7" + - name: "sf ~3" + - name: "sf ^3" + - name: "sf ~4" + - name: "sf ^4" + - name: "sf ~5" + - name: "sf ^5" fast_finish: true diff --git a/tests/composer/composer-symfony27-max.json b/tests/composer/composer-symfony27-max.json new file mode 100644 index 0000000000..37b323f9b0 --- /dev/null +++ b/tests/composer/composer-symfony27-max.json @@ -0,0 +1,55 @@ +{ + "name": "propel/propel", + "type": "library", + "description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.", + "keywords": [ + "ORM", + "persistence", + "Active Record" + ], + "homepage": "http://www.propelorm.org/", + "license": "MIT", + "authors": [ + { + "name": "William Durand", + "email": "william.durand1@gmail.com" + } + ], + "require": { + "php": ">=7.1", + "symfony/yaml": "^2.7.0", + "symfony/config": "^2.7.0", + "symfony/console": "^2.7.0", + "symfony/filesystem": "^2.7.0", + "symfony/finder": "^2.7.0", + "symfony/translation": "^2.7.0", + "symfony/validator": "^2.7.0", + "psr/log": "^1.0" + }, + "require-dev": { + "monolog/monolog": "^1.3", + "phpstan/phpstan": "^0.12.4", + "phpunit/phpunit": "^7.5.15" + }, + "suggest": { + "monolog/monolog": "The recommended logging library to use with Propel." + }, + "autoload": { + "psr-4": { + "Propel\\": "src/Propel/" + } + }, + "bin": [ + "bin/propel" + ], + "scripts": { + "stan": [ + "vendor/bin/phpstan analyze -l 1 -c tests/phpstan.neon src/" + ] + }, + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + } +} diff --git a/tests/composer/composer-symfony27-min.json b/tests/composer/composer-symfony27-min.json new file mode 100644 index 0000000000..2cec994dd2 --- /dev/null +++ b/tests/composer/composer-symfony27-min.json @@ -0,0 +1,55 @@ +{ + "name": "propel/propel", + "type": "library", + "description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.", + "keywords": [ + "ORM", + "persistence", + "Active Record" + ], + "homepage": "http://www.propelorm.org/", + "license": "MIT", + "authors": [ + { + "name": "William Durand", + "email": "william.durand1@gmail.com" + } + ], + "require": { + "php": ">=7.1", + "symfony/yaml": "~2.7.0", + "symfony/config": "~2.7.0", + "symfony/console": "~2.7.0", + "symfony/filesystem": "~2.7.0", + "symfony/finder": "~2.7.0", + "symfony/translation": "~2.7.0", + "symfony/validator": "~2.7.0", + "psr/log": "^1.0" + }, + "require-dev": { + "monolog/monolog": "^1.3", + "phpstan/phpstan": "^0.12.4", + "phpunit/phpunit": "^7.5.15" + }, + "suggest": { + "monolog/monolog": "The recommended logging library to use with Propel." + }, + "autoload": { + "psr-4": { + "Propel\\": "src/Propel/" + } + }, + "bin": [ + "bin/propel" + ], + "scripts": { + "stan": [ + "vendor/bin/phpstan analyze -l 1 -c tests/phpstan.neon src/" + ] + }, + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + } +} diff --git a/tests/composer/composer-symfony3-max.json b/tests/composer/composer-symfony3-max.json new file mode 100644 index 0000000000..5eb12e29ec --- /dev/null +++ b/tests/composer/composer-symfony3-max.json @@ -0,0 +1,55 @@ +{ + "name": "propel/propel", + "type": "library", + "description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.", + "keywords": [ + "ORM", + "persistence", + "Active Record" + ], + "homepage": "http://www.propelorm.org/", + "license": "MIT", + "authors": [ + { + "name": "William Durand", + "email": "william.durand1@gmail.com" + } + ], + "require": { + "php": ">=7.1", + "symfony/yaml": "^3.0.0", + "symfony/config": "^3.0.0", + "symfony/console": "^3.0.0", + "symfony/filesystem": "^3.0.0", + "symfony/finder": "^3.0.0", + "symfony/translation": "^3.0.0", + "symfony/validator": "~3.1.7||^3.2.4", + "psr/log": "^1.0" + }, + "require-dev": { + "monolog/monolog": "^1.3", + "phpstan/phpstan": "^0.12.4", + "phpunit/phpunit": "^7.5.15" + }, + "suggest": { + "monolog/monolog": "The recommended logging library to use with Propel." + }, + "autoload": { + "psr-4": { + "Propel\\": "src/Propel/" + } + }, + "bin": [ + "bin/propel" + ], + "scripts": { + "stan": [ + "vendor/bin/phpstan analyze -l 1 -c tests/phpstan.neon src/" + ] + }, + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + } +} diff --git a/tests/composer/composer-symfony3-min.json b/tests/composer/composer-symfony3-min.json new file mode 100644 index 0000000000..62132eabdf --- /dev/null +++ b/tests/composer/composer-symfony3-min.json @@ -0,0 +1,55 @@ +{ + "name": "propel/propel", + "type": "library", + "description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.", + "keywords": [ + "ORM", + "persistence", + "Active Record" + ], + "homepage": "http://www.propelorm.org/", + "license": "MIT", + "authors": [ + { + "name": "William Durand", + "email": "william.durand1@gmail.com" + } + ], + "require": { + "php": ">=7.1", + "symfony/yaml": "~3.0.0", + "symfony/config": "~3.0.0", + "symfony/console": "~3.0.0", + "symfony/filesystem": "~3.0.0", + "symfony/finder": "~3.0.0", + "symfony/translation": "~3.0.0", + "symfony/validator": "~3.1.7||~3.2.4", + "psr/log": "^1.0" + }, + "require-dev": { + "monolog/monolog": "^1.3", + "phpstan/phpstan": "^0.12.4", + "phpunit/phpunit": "^7.5.15" + }, + "suggest": { + "monolog/monolog": "The recommended logging library to use with Propel." + }, + "autoload": { + "psr-4": { + "Propel\\": "src/Propel/" + } + }, + "bin": [ + "bin/propel" + ], + "scripts": { + "stan": [ + "vendor/bin/phpstan analyze -l 1 -c tests/phpstan.neon src/" + ] + }, + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + } +} diff --git a/tests/composer/composer-symfony4-max.json b/tests/composer/composer-symfony4-max.json new file mode 100644 index 0000000000..9414f38a34 --- /dev/null +++ b/tests/composer/composer-symfony4-max.json @@ -0,0 +1,55 @@ +{ + "name": "propel/propel", + "type": "library", + "description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.", + "keywords": [ + "ORM", + "persistence", + "Active Record" + ], + "homepage": "http://www.propelorm.org/", + "license": "MIT", + "authors": [ + { + "name": "William Durand", + "email": "william.durand1@gmail.com" + } + ], + "require": { + "php": ">=7.1", + "symfony/yaml": "^4.0.0", + "symfony/config": "^4.0.0", + "symfony/console": "^4.0.0", + "symfony/filesystem": "^4.0.0", + "symfony/finder": "^4.0.0", + "symfony/translation": "^4.0.0", + "symfony/validator": "^4.0.0", + "psr/log": "^1.0" + }, + "require-dev": { + "monolog/monolog": "^1.3", + "phpstan/phpstan": "^0.12.4", + "phpunit/phpunit": "^7.5.15" + }, + "suggest": { + "monolog/monolog": "The recommended logging library to use with Propel." + }, + "autoload": { + "psr-4": { + "Propel\\": "src/Propel/" + } + }, + "bin": [ + "bin/propel" + ], + "scripts": { + "stan": [ + "vendor/bin/phpstan analyze -l 1 -c tests/phpstan.neon src/" + ] + }, + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + } +} diff --git a/tests/composer/composer-symfony4-min.json b/tests/composer/composer-symfony4-min.json new file mode 100644 index 0000000000..a418298458 --- /dev/null +++ b/tests/composer/composer-symfony4-min.json @@ -0,0 +1,55 @@ +{ + "name": "propel/propel", + "type": "library", + "description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.", + "keywords": [ + "ORM", + "persistence", + "Active Record" + ], + "homepage": "http://www.propelorm.org/", + "license": "MIT", + "authors": [ + { + "name": "William Durand", + "email": "william.durand1@gmail.com" + } + ], + "require": { + "php": ">=7.1", + "symfony/yaml": "~4.0.0", + "symfony/config": "~4.0.0", + "symfony/console": "~4.0.0", + "symfony/filesystem": "~4.0.0", + "symfony/finder": "~4.0.0", + "symfony/translation": "~4.0.0", + "symfony/validator": "~4.0.0", + "psr/log": "^1.0" + }, + "require-dev": { + "monolog/monolog": "^1.3", + "phpstan/phpstan": "^0.12.4", + "phpunit/phpunit": "^7.5.15" + }, + "suggest": { + "monolog/monolog": "The recommended logging library to use with Propel." + }, + "autoload": { + "psr-4": { + "Propel\\": "src/Propel/" + } + }, + "bin": [ + "bin/propel" + ], + "scripts": { + "stan": [ + "vendor/bin/phpstan analyze -l 1 -c tests/phpstan.neon src/" + ] + }, + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + } +} diff --git a/tests/composer/composer-symfony5-max.json b/tests/composer/composer-symfony5-max.json new file mode 100644 index 0000000000..902cb8bb7e --- /dev/null +++ b/tests/composer/composer-symfony5-max.json @@ -0,0 +1,55 @@ +{ + "name": "propel/propel", + "type": "library", + "description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.", + "keywords": [ + "ORM", + "persistence", + "Active Record" + ], + "homepage": "http://www.propelorm.org/", + "license": "MIT", + "authors": [ + { + "name": "William Durand", + "email": "william.durand1@gmail.com" + } + ], + "require": { + "php": ">=7.1", + "symfony/yaml": "^5.0.0", + "symfony/config": "^5.0.0", + "symfony/console": "^5.0.0", + "symfony/filesystem": "^5.0.0", + "symfony/finder": "^5.0.0", + "symfony/translation": "^5.0.0", + "symfony/validator": "^5.0.0", + "psr/log": "^1.0" + }, + "require-dev": { + "monolog/monolog": "^1.3", + "phpstan/phpstan": "^0.12.4", + "phpunit/phpunit": "^7.5.15" + }, + "suggest": { + "monolog/monolog": "The recommended logging library to use with Propel." + }, + "autoload": { + "psr-4": { + "Propel\\": "src/Propel/" + } + }, + "bin": [ + "bin/propel" + ], + "scripts": { + "stan": [ + "vendor/bin/phpstan analyze -l 1 -c tests/phpstan.neon src/" + ] + }, + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + } +} diff --git a/tests/composer/composer-symfony5-min.json b/tests/composer/composer-symfony5-min.json new file mode 100644 index 0000000000..3f12147871 --- /dev/null +++ b/tests/composer/composer-symfony5-min.json @@ -0,0 +1,55 @@ +{ + "name": "propel/propel", + "type": "library", + "description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.", + "keywords": [ + "ORM", + "persistence", + "Active Record" + ], + "homepage": "http://www.propelorm.org/", + "license": "MIT", + "authors": [ + { + "name": "William Durand", + "email": "william.durand1@gmail.com" + } + ], + "require": { + "php": ">=7.1", + "symfony/yaml": "~5.0.0", + "symfony/config": "~5.0.0", + "symfony/console": "~5.0.0", + "symfony/filesystem": "~5.0.0", + "symfony/finder": "~5.0.0", + "symfony/translation": "~5.0.0", + "symfony/validator": "~5.0.0", + "psr/log": "^1.0" + }, + "require-dev": { + "monolog/monolog": "^1.3", + "phpstan/phpstan": "^0.12.4", + "phpunit/phpunit": "^7.5.15" + }, + "suggest": { + "monolog/monolog": "The recommended logging library to use with Propel." + }, + "autoload": { + "psr-4": { + "Propel\\": "src/Propel/" + } + }, + "bin": [ + "bin/propel" + ], + "scripts": { + "stan": [ + "vendor/bin/phpstan analyze -l 1 -c tests/phpstan.neon src/" + ] + }, + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + } +} From c958931564a3451dbfd07441aca9378e2caa8a98 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Mon, 29 Jun 2020 18:05:07 +0200 Subject: [PATCH 013/208] Because a lot of failures happen on non-agnostic only --- .travis.yml | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/.travis.yml b/.travis.yml index c41251741c..62d9d28a7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -391,6 +391,66 @@ jobs: - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show + + - name: "mysql sf ~2.7" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-min.json composer install + - composer show + - name: "mysql sf ^2.7" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-max.json composer install + - composer show + - name: "mysql sf ~3" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-min.json composer install + - composer show + - name: "mysql sf ^3" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-max.json composer install + - composer show + - name: "mysql sf ~4" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-min.json composer install + - composer show + - name: "mysql sf ^4" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-max.json composer install + - composer show + - name: "mysql sf ~5" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-min.json composer install + - composer show + - name: "mysql sf ^5" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-max.json composer install + - composer show + + + allow_failures: - php: nightly - name: "sf ~2.7" @@ -401,6 +461,14 @@ jobs: - name: "sf ^4" - name: "sf ~5" - name: "sf ^5" + - name: "mysql sf ~2.7" + - name: "mysql sf ^2.7" + - name: "mysql sf ~3" + - name: "mysql sf ^3" + - name: "mysql sf ~4" + - name: "mysql sf ^4" + - name: "mysql sf ~5" + - name: "mysql sf ^5" fast_finish: true From 9aa6b93c14c1163cb4127ab71e915d3d3f49d61b Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Mon, 29 Jun 2020 16:30:49 +0200 Subject: [PATCH 014/208] Database is an optional parameter on mysql+travis --- src/Propel/Generator/Command/TestPrepareCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Generator/Command/TestPrepareCommand.php b/src/Propel/Generator/Command/TestPrepareCommand.php index 8bce1c596a..fbd961f948 100644 --- a/src/Propel/Generator/Command/TestPrepareCommand.php +++ b/src/Propel/Generator/Command/TestPrepareCommand.php @@ -82,7 +82,7 @@ protected function configure() new InputOption('vendor', null, InputOption::VALUE_REQUIRED, 'The database vendor', self::DEFAULT_VENDOR), new InputOption('dsn', null, InputOption::VALUE_REQUIRED, 'The data source name', self::DEFAULT_DSN), new InputOption('user', 'u', InputOption::VALUE_REQUIRED, 'The database user', self::DEFAULT_DB_USER), - new InputOption('password', 'p', InputOption::VALUE_REQUIRED, 'The database password', self::DEFAULT_DB_PASSWD), + new InputOption('password', 'p', InputOption::VALUE_OPTIONAL, 'The database password', self::DEFAULT_DB_PASSWD), new InputOption('exclude-database', null, InputOption::VALUE_NONE, 'Whether this should not touch database\'s schema'), ]) ->setName('test:prepare') From 23cde44466643e0af75489c4e1f22e9481a09760 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Mon, 29 Jun 2020 19:10:13 +0200 Subject: [PATCH 015/208] Something still wrong with sf validator v5. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 628f030d6b..47b21e256c 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "symfony/filesystem": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/finder": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/translation": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||^4.0.0||^5.0.0", + "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||^4.0.0", "psr/log": "^1.0" }, "require-dev": { From a2b6014c8cfd9ff4e15bd3f0461c4c32c826cc82 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Mon, 29 Jun 2020 21:37:11 +0200 Subject: [PATCH 016/208] Looking for debug output --- .../Generator/Behavior/Validate/UniqueConstraintTest.php | 6 +++++- .../Generator/Behavior/Validate/ValidateBehaviorTest.php | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/Propel/Tests/Generator/Behavior/Validate/UniqueConstraintTest.php b/tests/Propel/Tests/Generator/Behavior/Validate/UniqueConstraintTest.php index 28d6684329..a8b42bc22f 100644 --- a/tests/Propel/Tests/Generator/Behavior/Validate/UniqueConstraintTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Validate/UniqueConstraintTest.php @@ -28,7 +28,11 @@ public function testUniqueValidatorPass() $publisher = new Publisher(); $publisher->setName('Happy Reading'); $publisher->setWebsite('http://www.happyreading.com'); - $this->assertTrue($publisher->validate()); + $isValid = $publisher->validate(); + if (!$isValid) { + var_dump((string)$publisher->getValidationFailures()); + } + $this->assertTrue($isValid); } public function testUniqueValidatorIgnoresItself() diff --git a/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php index f070a90885..b55918f651 100755 --- a/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php @@ -317,6 +317,9 @@ public function testComplexValidationSingleFailure() $failures = $book->getValidationFailures(); $this->assertInstanceOf('Symfony\Component\Validator\ConstraintViolationList', $failures); + if (1 !== count($failures)) { + var_dump((string)$failures); + } $this->assertEquals(1, count($failures), 'Only one constraint violation object'); $failure = $failures[0]; From cd59cc2c0ebd687ebd513d86e6ac8d2bfbb87971 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Mon, 29 Jun 2020 22:03:09 +0200 Subject: [PATCH 017/208] Resorting to feature detection to avoid a breaking change --- src/Propel/Common/Config/PropelConfiguration.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Propel/Common/Config/PropelConfiguration.php b/src/Propel/Common/Config/PropelConfiguration.php index 50841fc826..86d419c69a 100644 --- a/src/Propel/Common/Config/PropelConfiguration.php +++ b/src/Propel/Common/Config/PropelConfiguration.php @@ -29,8 +29,15 @@ class PropelConfiguration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('propel'); + $isBeforeSymfony5 = method_exists(TreeBuilder::class, 'root'); + + if ($isBeforeSymfony5) { + $treeBuilder = new TreeBuilder(); + $rootNode = $treeBuilder->root('propel'); + } else { + $treeBuilder = new TreeBuilder('propel'); + $rootNode = $treeBuilder->getRootNode(); + } $this->addGeneralSection($rootNode); $this->addExcludeTablesSection($rootNode); From 49d3c617198ae16ff719042d534a15818deadbaf Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Mon, 29 Jun 2020 23:04:21 +0200 Subject: [PATCH 018/208] Let this run overnight and see what version breaks --- .travis.yml | 314 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 314 insertions(+) diff --git a/.travis.yml b/.travis.yml index 62d9d28a7b..b815c3f244 100644 --- a/.travis.yml +++ b/.travis.yml @@ -449,6 +449,320 @@ jobs: - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show + ############################ + - name: "sf ~2.7" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-min.json composer install + - composer show + - name: "sf ^2.7" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-max.json composer install + - composer show + - name: "sf ~3" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-min.json composer install + - composer show + - name: "sf ^3" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-max.json composer install + - composer show + - name: "sf ~4" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-min.json composer install + - composer show + - name: "sf ^4" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-max.json composer install + - composer show + - name: "sf ~5" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-min.json composer install + - composer show + - name: "sf ^5" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-max.json composer install + - composer show + + - name: "mysql sf ~2.7" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-min.json composer install + - composer show + - name: "mysql sf ^2.7" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-max.json composer install + - composer show + - name: "mysql sf ~3" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-min.json composer install + - composer show + - name: "mysql sf ^3" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-max.json composer install + - composer show + - name: "mysql sf ~4" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-min.json composer install + - composer show + - name: "mysql sf ^4" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-max.json composer install + - composer show + - name: "mysql sf ~5" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-min.json composer install + - composer show + - name: "mysql sf ^5" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-max.json composer install + - composer show + ############################ + - name: "sf ~2.7" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-min.json composer install + - composer show + - name: "sf ^2.7" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-max.json composer install + - composer show + - name: "sf ~3" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-min.json composer install + - composer show + - name: "sf ^3" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-max.json composer install + - composer show + - name: "sf ~4" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-min.json composer install + - composer show + - name: "sf ^4" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-max.json composer install + - composer show + - name: "sf ~5" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-min.json composer install + - composer show + - name: "sf ^5" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-max.json composer install + - composer show + + - name: "mysql sf ~2.7" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-min.json composer install + - composer show + - name: "mysql sf ^2.7" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-max.json composer install + - composer show + - name: "mysql sf ~3" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-min.json composer install + - composer show + - name: "mysql sf ^3" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-max.json composer install + - composer show + - name: "mysql sf ~4" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-min.json composer install + - composer show + - name: "mysql sf ^4" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-max.json composer install + - composer show + - name: "mysql sf ~5" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-min.json composer install + - composer show + - name: "mysql sf ^5" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-max.json composer install + - composer show + ############################ + - name: "sf ~2.7" + php: 7.1 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-min.json composer install + - composer show + - name: "sf ^2.7" + php: 7.1 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-max.json composer install + - composer show + - name: "sf ~3" + php: 7.1 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-min.json composer install + - composer show + - name: "sf ^3" + php: 7.1 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-max.json composer install + - composer show + - name: "sf ~4" + php: 7.1 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-min.json composer install + - composer show + - name: "sf ^4" + php: 7.1 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-max.json composer install + - composer show + + - name: "mysql sf ~2.7" + php: 7.1 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-min.json composer install + - composer show + - name: "mysql sf ^2.7" + php: 7.1 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony27-max.json composer install + - composer show + - name: "mysql sf ~3" + php: 7.1 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-min.json composer install + - composer show + - name: "mysql sf ^3" + php: 7.1 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-max.json composer install + - composer show + - name: "mysql sf ~4" + php: 7.1 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-min.json composer install + - composer show + - name: "mysql sf ^4" + php: 7.1 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-max.json composer install + - composer show allow_failures: From e44c55dc4b71ede2f0dac1925c92c162d025b465 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 09:06:41 +0200 Subject: [PATCH 019/208] Because config is feature-sniffing, it should work now --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 47b21e256c..f00fd531bf 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.1", "symfony/yaml": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/config": "^2.7.0||^3.0.0||^4.0.0", + "symfony/config": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/console": "^2.7.0||^3.0.0||^4.0.0", "symfony/filesystem": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/finder": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", From 8734275c23fdc62cda35c673eac82957d333fec4 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 09:16:47 +0200 Subject: [PATCH 020/208] Now with updated console to v5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f00fd531bf..5d0e1a5de0 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": ">=7.1", "symfony/yaml": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/config": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/console": "^2.7.0||^3.0.0||^4.0.0", + "symfony/console": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/filesystem": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/finder": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/translation": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", From 3328fe17a9ca58907f445f694c80b95ac4ce1d16 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 10:06:23 +0200 Subject: [PATCH 021/208] Symfony 5 enforces return types on execute method --- src/Propel/Generator/Command/ConfigConvertCommand.php | 4 +++- src/Propel/Generator/Command/DatabaseReverseCommand.php | 4 +++- src/Propel/Generator/Command/GraphvizGenerateCommand.php | 4 +++- src/Propel/Generator/Command/InitCommand.php | 2 +- src/Propel/Generator/Command/MigrationCreateCommand.php | 4 +++- src/Propel/Generator/Command/MigrationDiffCommand.php | 6 ++++-- src/Propel/Generator/Command/MigrationDownCommand.php | 8 +++++--- src/Propel/Generator/Command/MigrationMigrateCommand.php | 8 +++++--- src/Propel/Generator/Command/MigrationStatusCommand.php | 8 +++++--- src/Propel/Generator/Command/MigrationUpCommand.php | 6 ++++-- src/Propel/Generator/Command/ModelBuildCommand.php | 4 +++- src/Propel/Generator/Command/SqlBuildCommand.php | 4 +++- src/Propel/Generator/Command/SqlInsertCommand.php | 4 +++- src/Propel/Generator/Command/TestPrepareCommand.php | 4 +++- 14 files changed, 48 insertions(+), 22 deletions(-) diff --git a/src/Propel/Generator/Command/ConfigConvertCommand.php b/src/Propel/Generator/Command/ConfigConvertCommand.php index 52522d83cb..d559b3e3fc 100644 --- a/src/Propel/Generator/Command/ConfigConvertCommand.php +++ b/src/Propel/Generator/Command/ConfigConvertCommand.php @@ -39,7 +39,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $configManager = new ConfigurationManager($input->getOption('config-dir')); @@ -77,5 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output) file_put_contents($outputFilePath, $phpConf); $output->writeln(sprintf('Successfully wrote PHP configuration in file "%s".', $outputFilePath)); } + + return 0; } } diff --git a/src/Propel/Generator/Command/DatabaseReverseCommand.php b/src/Propel/Generator/Command/DatabaseReverseCommand.php index 513922dc76..d259a49138 100644 --- a/src/Propel/Generator/Command/DatabaseReverseCommand.php +++ b/src/Propel/Generator/Command/DatabaseReverseCommand.php @@ -53,7 +53,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $configOptions = []; @@ -100,5 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (true === $manager->reverse()) { $output->writeln('Schema reverse engineering finished.'); } + + return 0; } } diff --git a/src/Propel/Generator/Command/GraphvizGenerateCommand.php b/src/Propel/Generator/Command/GraphvizGenerateCommand.php index 3ba6a23753..e85e0107d6 100644 --- a/src/Propel/Generator/Command/GraphvizGenerateCommand.php +++ b/src/Propel/Generator/Command/GraphvizGenerateCommand.php @@ -41,7 +41,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $configOptions = []; if ($this->hasInputOption('schema-dir', $input)){ @@ -62,5 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $manager->setWorkingDirectory($input->getOption('output-dir')); $manager->build(); + + return 0; } } diff --git a/src/Propel/Generator/Command/InitCommand.php b/src/Propel/Generator/Command/InitCommand.php index 83aef28753..ffd372ff24 100644 --- a/src/Propel/Generator/Command/InitCommand.php +++ b/src/Propel/Generator/Command/InitCommand.php @@ -47,7 +47,7 @@ protected function configure() ; } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $consoleHelper = $this->createConsoleHelper($input, $output); $options = []; diff --git a/src/Propel/Generator/Command/MigrationCreateCommand.php b/src/Propel/Generator/Command/MigrationCreateCommand.php index 473edc4098..89c43c20fb 100644 --- a/src/Propel/Generator/Command/MigrationCreateCommand.php +++ b/src/Propel/Generator/Command/MigrationCreateCommand.php @@ -46,7 +46,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $configOptions = []; @@ -96,6 +96,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('Now add SQL statements and data migration code as necessary.'); $output->writeln('Once the migration class is valid, call the "migrate" task to execute it.'); } + + return 0; } } diff --git a/src/Propel/Generator/Command/MigrationDiffCommand.php b/src/Propel/Generator/Command/MigrationDiffCommand.php index 44e833cfef..7a2ab6f831 100644 --- a/src/Propel/Generator/Command/MigrationDiffCommand.php +++ b/src/Propel/Generator/Command/MigrationDiffCommand.php @@ -55,7 +55,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $configOptions = []; @@ -212,7 +212,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!$migrationsUp) { $output->writeln('Same XML and database structures for all datasource - no diff to generate'); - return; + return 0; } $timestamp = time(); @@ -231,6 +231,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('Please review the generated SQL statements, and add data migration code if necessary.'); $output->writeln('Once the migration class is valid, call the "migrate" task to execute it.'); } + + return 0; } } diff --git a/src/Propel/Generator/Command/MigrationDownCommand.php b/src/Propel/Generator/Command/MigrationDownCommand.php index d12249ad68..e25917fb85 100644 --- a/src/Propel/Generator/Command/MigrationDownCommand.php +++ b/src/Propel/Generator/Command/MigrationDownCommand.php @@ -44,7 +44,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $configOptions = []; @@ -83,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!$nextMigrationTimestamp) { $output->writeln('No migration were ever executed on this database - nothing to reverse.'); - return false; + return 1; } $output->writeln(sprintf( @@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $output->writeln('preDown() returned false. Aborting migration.'); - return false; + return 1; } } } @@ -181,5 +181,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $output->writeln('Reverse migration complete. No more migration available for reverse'); } + + return 0; } } diff --git a/src/Propel/Generator/Command/MigrationMigrateCommand.php b/src/Propel/Generator/Command/MigrationMigrateCommand.php index 5295308211..f2a6598728 100644 --- a/src/Propel/Generator/Command/MigrationMigrateCommand.php +++ b/src/Propel/Generator/Command/MigrationMigrateCommand.php @@ -44,7 +44,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $configOptions = []; @@ -81,7 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!$manager->getFirstUpMigrationTimestamp()) { $output->writeln('All migrations were already executed - nothing to migrate.'); - return false; + return 1; } $timestamps = $manager->getValidMigrationTimestamps(); @@ -113,7 +113,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $output->writeln('preUp() returned false. Aborting migration.'); - return false; + return 1; } } @@ -186,5 +186,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } $output->writeln('Migration complete. No further migration to execute.'); + + return 0; } } diff --git a/src/Propel/Generator/Command/MigrationStatusCommand.php b/src/Propel/Generator/Command/MigrationStatusCommand.php index 547b8c6b7e..47906d4e3d 100644 --- a/src/Propel/Generator/Command/MigrationStatusCommand.php +++ b/src/Propel/Generator/Command/MigrationStatusCommand.php @@ -40,7 +40,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $configOptions = []; @@ -142,7 +142,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $output->writeln(sprintf('No migration file found in "%s".', $dir)); - return false; + return 1; } $migrationTimestamps = $manager->getValidMigrationTimestamps(); @@ -151,12 +151,14 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!$nbNotYetExecutedMigrations) { $output->writeln('All migration files were already executed - Nothing to migrate.'); - return false; + return 1; } $output->writeln(sprintf( 'Call the "migrate" task to execute %s', $countValidTimestamps == 1 ? 'it' : 'them' )); + + return 0; } } diff --git a/src/Propel/Generator/Command/MigrationUpCommand.php b/src/Propel/Generator/Command/MigrationUpCommand.php index b2fe6f3035..c93f8a2788 100644 --- a/src/Propel/Generator/Command/MigrationUpCommand.php +++ b/src/Propel/Generator/Command/MigrationUpCommand.php @@ -82,7 +82,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!$nextMigrationTimestamp) { $output->writeln('All migrations were already executed - nothing to migrate.'); - return false; + return 1; } if ($input->getOption('fake')) { @@ -109,7 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('preUp() returned false. Continue migration.'); } else { $output->writeln('preUp() returned false. Aborting migration.'); - return false; + return 1; } } } @@ -190,5 +190,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $output->writeln('Migration complete. No further migration to execute.'); } + + return 0; } } diff --git a/src/Propel/Generator/Command/ModelBuildCommand.php b/src/Propel/Generator/Command/ModelBuildCommand.php index 36fae648d0..ecc9f0051f 100644 --- a/src/Propel/Generator/Command/ModelBuildCommand.php +++ b/src/Propel/Generator/Command/ModelBuildCommand.php @@ -55,7 +55,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $configOptions = []; $inputOptions = $input->getOptions(); @@ -131,5 +131,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $manager->setWorkingDirectory($generatorConfig->getSection('paths')['phpDir']); $manager->build(); + + return 0; } } diff --git a/src/Propel/Generator/Command/SqlBuildCommand.php b/src/Propel/Generator/Command/SqlBuildCommand.php index ade1f94367..a5ea31f024 100644 --- a/src/Propel/Generator/Command/SqlBuildCommand.php +++ b/src/Propel/Generator/Command/SqlBuildCommand.php @@ -47,7 +47,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $configOptions = []; @@ -110,5 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } $manager->buildSql(); + + return 0; } } diff --git a/src/Propel/Generator/Command/SqlInsertCommand.php b/src/Propel/Generator/Command/SqlInsertCommand.php index df8b7a20ca..92db98c77c 100644 --- a/src/Propel/Generator/Command/SqlInsertCommand.php +++ b/src/Propel/Generator/Command/SqlInsertCommand.php @@ -39,7 +39,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $manager = new SqlManager(); @@ -70,5 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $manager->setWorkingDirectory($generatorConfig->getSection('paths')['sqlDir']); $manager->insertSql(); + + return 0; } } diff --git a/src/Propel/Generator/Command/TestPrepareCommand.php b/src/Propel/Generator/Command/TestPrepareCommand.php index fbd961f948..e45cc4096f 100644 --- a/src/Propel/Generator/Command/TestPrepareCommand.php +++ b/src/Propel/Generator/Command/TestPrepareCommand.php @@ -93,11 +93,13 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { foreach ($this->fixtures as $fixturesDir => $connections) { $this->buildFixtures(sprintf('%s/%s', self::FIXTURES_DIR, $fixturesDir), $connections, $input, $output); } + + return 0; } /** From 7a71f8c19344b938693606a1d5f8393b914088d6 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 10:06:39 +0200 Subject: [PATCH 022/208] Prevent infinite loops when database is not connecting --- src/Propel/Generator/Command/InitCommand.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Propel/Generator/Command/InitCommand.php b/src/Propel/Generator/Command/InitCommand.php index ffd372ff24..903aaec24f 100644 --- a/src/Propel/Generator/Command/InitCommand.php +++ b/src/Propel/Generator/Command/InitCommand.php @@ -70,7 +70,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int $consoleHelper->writeln(''); + $connectionAttemptLimit = 10; + $connectionAttemptCount = 0; do { + if ($connectionAttemptCount >= $connectionAttemptLimit) { + $consoleHelper->writeln(''); + $consoleHelper->writeSection('Exceeded 10 attempts to connect to database'); + $consoleHelper->writeln(''); + + return 1; + } + $connectionAttemptCount += 1; switch ($options['rdbms']) { case 'mysql': $options['dsn'] = $this->initMysql($consoleHelper); From 7aae1a364fdfbdd481f4815bd1b1bd3a06027ed3 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 10:42:24 +0200 Subject: [PATCH 023/208] Abstract command test needs a return type --- .../Propel/Tests/Generator/Command/AbstractCommandTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Propel/Tests/Generator/Command/AbstractCommandTest.php b/tests/Propel/Tests/Generator/Command/AbstractCommandTest.php index acf091346c..7d859a1df6 100644 --- a/tests/Propel/Tests/Generator/Command/AbstractCommandTest.php +++ b/tests/Propel/Tests/Generator/Command/AbstractCommandTest.php @@ -84,10 +84,12 @@ public function parseConnection($connection) return parent::parseConnection($connection); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $result = $this->getSchemas($input->getOption('config-dir'), $input->getOption('recursive')); $output->write(count($result)); + + return 0; } -} \ No newline at end of file +} From 7890656992013f73252c20df4f713851fe16ba14 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 11:44:18 +0200 Subject: [PATCH 024/208] Test sf validator 5.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5d0e1a5de0..cd4751ec3b 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "symfony/filesystem": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/finder": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/translation": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||^4.0.0", + "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||^4.0.0||^5.0.0", "psr/log": "^1.0" }, "require-dev": { From 09f6f3a9882358596f6dbe42aa03f79bdfe0b3a3 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 12:10:16 +0200 Subject: [PATCH 025/208] Mysql test were incorrectly setup --- .travis.yml | 60 ++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index b815c3f244..40578e4b9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -394,56 +394,56 @@ jobs: - name: "mysql sf ~2.7" php: 7.4 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - composer show - name: "mysql sf ^2.7" php: 7.4 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - composer show - name: "mysql sf ~3" php: 7.4 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - composer show - name: "mysql sf ^3" php: 7.4 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show - name: "mysql sf ~4" php: 7.4 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - composer show - name: "mysql sf ^4" php: 7.4 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show - name: "mysql sf ~5" php: 7.4 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - composer show - name: "mysql sf ^5" php: 7.4 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-max.json composer install @@ -509,56 +509,56 @@ jobs: - name: "mysql sf ~2.7" php: 7.3 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - composer show - name: "mysql sf ^2.7" php: 7.3 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - composer show - name: "mysql sf ~3" php: 7.3 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - composer show - name: "mysql sf ^3" php: 7.3 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show - name: "mysql sf ~4" php: 7.3 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - composer show - name: "mysql sf ^4" php: 7.3 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show - name: "mysql sf ~5" php: 7.3 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - composer show - name: "mysql sf ^5" php: 7.3 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-max.json composer install @@ -623,56 +623,56 @@ jobs: - name: "mysql sf ~2.7" php: 7.2 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - composer show - name: "mysql sf ^2.7" php: 7.2 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - composer show - name: "mysql sf ~3" php: 7.2 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - composer show - name: "mysql sf ^3" php: 7.2 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show - name: "mysql sf ~4" php: 7.2 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - composer show - name: "mysql sf ^4" php: 7.2 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show - name: "mysql sf ~5" php: 7.2 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - composer show - name: "mysql sf ^5" php: 7.2 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-max.json composer install @@ -723,42 +723,42 @@ jobs: - name: "mysql sf ~2.7" php: 7.1 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - composer show - name: "mysql sf ^2.7" php: 7.1 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - composer show - name: "mysql sf ~3" php: 7.1 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - composer show - name: "mysql sf ^3" php: 7.1 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show - name: "mysql sf ~4" php: 7.1 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - composer show - name: "mysql sf ^4" php: 7.1 - env: DB=agnostic + env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install From 5e4361ff3644870e3c4572c2d24b7a95ff775c2e Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 12:22:34 +0200 Subject: [PATCH 026/208] Special composer for php8 testing --- .travis.yml | 6 ++-- tests/composer/composer-php8.json | 55 +++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 tests/composer/composer-php8.json diff --git a/.travis.yml b/.travis.yml index 40578e4b9d..386420c22a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -311,19 +311,19 @@ jobs: env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - composer install --ignore-platform-reqs # PHPUnit doesn't accept PHP8 + - COMPOSER=./tests/composer/composer-php8.json composer install - composer show - php: nightly env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - composer install --ignore-platform-reqs + - COMPOSER=./tests/composer/composer-php8.json composer install - composer show - php: nightly env: DB=sqlite install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - composer install --ignore-platform-reqs + - COMPOSER=./tests/composer/composer-php8.json composer install - composer show - php: 7.4 diff --git a/tests/composer/composer-php8.json b/tests/composer/composer-php8.json new file mode 100644 index 0000000000..8aaa8ad67d --- /dev/null +++ b/tests/composer/composer-php8.json @@ -0,0 +1,55 @@ +{ + "name": "propel/propel", + "type": "library", + "description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.", + "keywords": [ + "ORM", + "persistence", + "Active Record" + ], + "homepage": "http://www.propelorm.org/", + "license": "MIT", + "authors": [ + { + "name": "William Durand", + "email": "william.durand1@gmail.com" + } + ], + "require": { + "php": ">=7.1", + "symfony/yaml": "^5.0.0", + "symfony/config": "^5.0.0", + "symfony/console": "^5.0.0", + "symfony/filesystem": "^5.0.0", + "symfony/finder": "^5.0.0", + "symfony/translation": "^5.0.0", + "symfony/validator": "^5.0.0", + "psr/log": "^1.0" + }, + "require-dev": { + "monolog/monolog": "^1.3", + "phpstan/phpstan": "^0.12.4", + "phpunit/phpunit": "9.3.x-dev" + }, + "suggest": { + "monolog/monolog": "The recommended logging library to use with Propel." + }, + "autoload": { + "psr-4": { + "Propel\\": "src/Propel/" + } + }, + "bin": [ + "bin/propel" + ], + "scripts": { + "stan": [ + "vendor/bin/phpstan analyze -l 1 -c tests/phpstan.neon src/" + ] + }, + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + } +} From c72e30eb4903e08ab3f24b2dc69c41610afedd45 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 12:33:39 +0200 Subject: [PATCH 027/208] Revert "Test sf validator 5.0" This reverts commit 506d65649fc60e1c6d5417730efcdd066b12d570. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cd4751ec3b..5d0e1a5de0 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "symfony/filesystem": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/finder": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/translation": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||^4.0.0||^5.0.0", + "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||^4.0.0", "psr/log": "^1.0" }, "require-dev": { From 6402816cbc1e2e8a5efa5095e34de2b582b2f8d7 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 13:07:45 +0200 Subject: [PATCH 028/208] PHPStan doesn't work on php8 --- tests/composer/composer-php8.json | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/composer/composer-php8.json b/tests/composer/composer-php8.json index 8aaa8ad67d..fc6769bc9e 100644 --- a/tests/composer/composer-php8.json +++ b/tests/composer/composer-php8.json @@ -28,7 +28,6 @@ }, "require-dev": { "monolog/monolog": "^1.3", - "phpstan/phpstan": "^0.12.4", "phpunit/phpunit": "9.3.x-dev" }, "suggest": { From 1315e4932737be75e3b37545facc02fe4adb52ea Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 13:27:23 +0200 Subject: [PATCH 029/208] Check if validator 4.2 causes other issues --- composer.json | 2 +- tests/composer/composer-symfony4-max.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 5d0e1a5de0..b028beb58c 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "symfony/filesystem": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/finder": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/translation": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||^4.0.0", + "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||~4.0||~4.1", "psr/log": "^1.0" }, "require-dev": { diff --git a/tests/composer/composer-symfony4-max.json b/tests/composer/composer-symfony4-max.json index 9414f38a34..9bf4f3c553 100644 --- a/tests/composer/composer-symfony4-max.json +++ b/tests/composer/composer-symfony4-max.json @@ -23,7 +23,7 @@ "symfony/filesystem": "^4.0.0", "symfony/finder": "^4.0.0", "symfony/translation": "^4.0.0", - "symfony/validator": "^4.0.0", + "symfony/validator": "~4.0.0||~4.1", "psr/log": "^1.0" }, "require-dev": { From 740242f36906c86f5aa11582966682631e489bed Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 13:53:40 +0200 Subject: [PATCH 030/208] Revert "Check if validator 4.2 causes other issues" This reverts commit f2a463d25849d6b6a192b2d42f24f7338f03f96f. --- composer.json | 2 +- tests/composer/composer-symfony4-max.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b028beb58c..5d0e1a5de0 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "symfony/filesystem": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/finder": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/translation": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||~4.0||~4.1", + "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||^4.0.0", "psr/log": "^1.0" }, "require-dev": { diff --git a/tests/composer/composer-symfony4-max.json b/tests/composer/composer-symfony4-max.json index 9bf4f3c553..9414f38a34 100644 --- a/tests/composer/composer-symfony4-max.json +++ b/tests/composer/composer-symfony4-max.json @@ -23,7 +23,7 @@ "symfony/filesystem": "^4.0.0", "symfony/finder": "^4.0.0", "symfony/translation": "^4.0.0", - "symfony/validator": "~4.0.0||~4.1", + "symfony/validator": "^4.0.0", "psr/log": "^1.0" }, "require-dev": { From c9121798d017db59e21b63350df9c282ed687dc1 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 14:08:01 +0200 Subject: [PATCH 031/208] Make test BC with older versions of command --- tests/Propel/Tests/Generator/Command/InitCommandTest.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/Propel/Tests/Generator/Command/InitCommandTest.php b/tests/Propel/Tests/Generator/Command/InitCommandTest.php index c9e2a555f0..6c83c229b0 100644 --- a/tests/Propel/Tests/Generator/Command/InitCommandTest.php +++ b/tests/Propel/Tests/Generator/Command/InitCommandTest.php @@ -58,8 +58,11 @@ public function testExecute() $command = $app->find('init'); $commandTester = new CommandTester($command); - $commandTester->setInputs($this->getInputsArray()); - $commandTester->execute(['command' => $command->getName()]); + + $setInputs = $this->getInputsArray(); + $command = ['command' => $command->getName()]; + $input = array_merge($command, $setInputs); + $commandTester->execute($input); $this->assertContains('Propel 2 is ready to be used!', $commandTester->getDisplay()); $this->assertTrue(file_exists($this->dir . '/schema.xml'), 'Example schema file created.'); From c8eb5eeb06e526493f7fa3780086ab0ee688d6e1 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 15:37:39 +0200 Subject: [PATCH 032/208] sf validator 3 has regex issues When using v3.2.14 1) Propel\Tests\Generator\Behavior\Validate\UniqueConstraintTest::testUniqueValidatorPass preg_match(): Compilation failed: invalid range in character class at offset 179 /home/travis/build/spryker/Propel2/vendor/symfony/validator/Constraints/UrlValidator.php:65 /home/travis/build/spryker/Propel2/vendor/symfony/validator/Validator/RecursiveContextualValidator.php:850 /home/travis/build/spryker/Propel2/vendor/symfony/validator/Validator/RecursiveContextualValidator.php:696 /home/travis/build/spryker/Propel2/vendor/symfony/validator/Validator/RecursiveContextualValidator.php:590 /home/travis/build/spryker/Propel2/vendor/symfony/validator/Validator/RecursiveContextualValidator.php:361 /home/travis/build/spryker/Propel2/vendor/symfony/validator/Validator/RecursiveContextualValidator.php:162 /home/travis/build/spryker/Propel2/vendor/symfony/validator/Validator/RecursiveValidator.php:115 /home/travis/build/spryker/Propel2/tests/Fixtures/bookstore/build/classes/Propel/Tests/Bookstore/Behavior/Base/ValidatePublisher.php:1511 /home/travis/build/spryker/Propel2/tests/Propel/Tests/Generator/Behavior/Validate/UniqueConstraintTest.php:31 --- tests/composer/composer-symfony3-min.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/composer/composer-symfony3-min.json b/tests/composer/composer-symfony3-min.json index 62132eabdf..7942619b61 100644 --- a/tests/composer/composer-symfony3-min.json +++ b/tests/composer/composer-symfony3-min.json @@ -23,7 +23,7 @@ "symfony/filesystem": "~3.0.0", "symfony/finder": "~3.0.0", "symfony/translation": "~3.0.0", - "symfony/validator": "~3.1.7||~3.2.4", + "symfony/validator": "~3.3", "psr/log": "^1.0" }, "require-dev": { From aa901fcb1f26a9245a0d96bb203304a0b8527a23 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 16:04:49 +0200 Subject: [PATCH 033/208] Better understand what this mock is meant to do --- tests/Propel/Tests/Generator/Command/InitCommandTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/Propel/Tests/Generator/Command/InitCommandTest.php b/tests/Propel/Tests/Generator/Command/InitCommandTest.php index 6c83c229b0..ab32358568 100644 --- a/tests/Propel/Tests/Generator/Command/InitCommandTest.php +++ b/tests/Propel/Tests/Generator/Command/InitCommandTest.php @@ -60,9 +60,10 @@ public function testExecute() $commandTester = new CommandTester($command); $setInputs = $this->getInputsArray(); + var_dump($setInputs); $command = ['command' => $command->getName()]; - $input = array_merge($command, $setInputs); - $commandTester->execute($input); + $commandTester->setInputs($setInputs); + $commandTester->execute($command); $this->assertContains('Propel 2 is ready to be used!', $commandTester->getDisplay()); $this->assertTrue(file_exists($this->dir . '/schema.xml'), 'Example schema file created.'); From e14827c8eec5b7b411ba7bbd3990f0a9c83ea4eb Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 16:09:12 +0200 Subject: [PATCH 034/208] Validator3.3 needs yaml3.3 --- tests/composer/composer-symfony3-min.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/composer/composer-symfony3-min.json b/tests/composer/composer-symfony3-min.json index 7942619b61..8d35767395 100644 --- a/tests/composer/composer-symfony3-min.json +++ b/tests/composer/composer-symfony3-min.json @@ -17,13 +17,13 @@ ], "require": { "php": ">=7.1", - "symfony/yaml": "~3.0.0", + "symfony/yaml": "~3.3.0", "symfony/config": "~3.0.0", "symfony/console": "~3.0.0", "symfony/filesystem": "~3.0.0", "symfony/finder": "~3.0.0", "symfony/translation": "~3.0.0", - "symfony/validator": "~3.3", + "symfony/validator": "~3.3.0", "psr/log": "^1.0" }, "require-dev": { From 64555e23c6775cca7856ddb6ea29aeec2f069e0f Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 18:02:27 +0200 Subject: [PATCH 035/208] I have to implement a non-interactive version of init so I can have fully BC tests --- src/Propel/Generator/Command/InitCommand.php | 131 ++++++++++++++++-- .../Generator/Command/InitCommandTest.php | 61 +++----- 2 files changed, 140 insertions(+), 52 deletions(-) diff --git a/src/Propel/Generator/Command/InitCommand.php b/src/Propel/Generator/Command/InitCommand.php index 903aaec24f..ee8a6d8a4f 100644 --- a/src/Propel/Generator/Command/InitCommand.php +++ b/src/Propel/Generator/Command/InitCommand.php @@ -18,6 +18,7 @@ use Propel\Runtime\Connection\ConnectionFactory; use Propel\Runtime\Connection\Exception\ConnectionException; use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Finder\Finder; @@ -43,11 +44,127 @@ protected function configure() $this ->setName('init') - ->setDescription('Initializes a new project') - ; + ->setDescription('Initializes a new project. Interactive when no input is provided.') + ->addArgument( + 'adapter', + InputArgument::OPTIONAL, + 'DB Adapter to use. One of: mysql, sqlite, pgsql, oracle, sqlsrv, mssql' + ) + ->addArgument( + 'connection', + InputArgument::OPTIONAL, + 'The Pdo connection string to use. eg: mysql:host=127.0.0.1;port=;dbname=test' + ) + ->addArgument( + 'user', + InputArgument::OPTIONAL, + 'The database user. eg: root' + + ) + ->addArgument( + 'password', + InputArgument::OPTIONAL, + 'The database password. Passwords command arguments in production are insecure and discouraged' + ) + ->addArgument( + 'charset', + InputArgument::OPTIONAL, + 'The connection charset to use. eg: "utf8"' + ) + ->addArgument( + 'preexistingDB', + InputArgument::OPTIONAL, + 'If the database in the connection string already exists, Propel will reverse engineer the schema setup. answers: "yes", "no"' + ) + ->addArgument( + 'schemaPath', + InputArgument::OPTIONAL, + 'Path for the schema files' + ) + ->addArgument( + 'phpModelPath', + InputArgument::OPTIONAL, + 'Path to store generated PHP models' + ) + ->addArgument( + 'namespace', + InputArgument::OPTIONAL, + 'Namespace for generated PHP models' + ) + ->addArgument( + 'configFormat', + InputArgument::OPTIONAL, + 'Format of generated configuration files. One of: yml, xml, json, ini, php' + ); } protected function execute(InputInterface $input, OutputInterface $output): int + { + $args = $input->getArguments(); + $allArgumentsAreProvided = (count(array_filter($args)) === 10); + + if ($allArgumentsAreProvided) { + return $this->argumentBasedSetup($input, $output); + } + + return $this->interactiveSetup($input, $output); + } + + private function argumentBasedSetup(InputInterface $input, OutputInterface $output): int + { + $consoleHelper = $this->createConsoleHelper($input, $output); + + $args = $input->getArguments(); + $options = [ + 'format' => $args['configFormat'], + 'namespace' => $args['namespace'], + 'phpDir' => $args['phpModelPath'], + 'schemaDir' => $args['schemaPath'], + 'charset' => $args['charset'], + 'password' => $args['password'], + 'user' => $args['user'], + 'dsn' => $args['connection'], + 'rdbms' => $args['adapter'] + ]; + + $isReverseEngineerRequested = $args['preexistingDB']; + + if ($this->testConnection($consoleHelper, $options)) { + $consoleHelper->writeSection('Unable to connect to database'); + + return 1; + } + + if ($isReverseEngineerRequested) { + $options['schema'] = $this->reverseEngineerSchema($consoleHelper->getOutput(), $options); + } + + $consoleHelper->writeBlock('Propel 2 Initializer - Summary'); + $consoleHelper->writeSection('The Propel 2 Initializer will set up your project with the following settings:'); + + $consoleHelper->writeSummary([ + 'Path to schema.xml' => $options['schemaDir'] . '/schema.xml', + 'Path to config file' => sprintf('%s/propel.%s', getcwd(), $options['format']), + 'Path to generated php models' => $options['phpDir'], + 'Namespace of generated php models' => $options['namespace'], + ]); + + $consoleHelper->writeSummary([ + 'Database management system' => $options['rdbms'], + 'Charset' => $options['charset'], + 'User' => $options['user'], + ]); + + $consoleHelper->writeln(''); + + $this->generateProject($consoleHelper->getOutput(), $options); + + $consoleHelper->writeSection('Propel 2 is ready to be used!'); + + return 0; + } + + private function interactiveSetup(InputInterface $input, OutputInterface $output): int { $consoleHelper = $this->createConsoleHelper($input, $output); $options = []; @@ -74,11 +191,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $connectionAttemptCount = 0; do { if ($connectionAttemptCount >= $connectionAttemptLimit) { - $consoleHelper->writeln(''); - $consoleHelper->writeSection('Exceeded 10 attempts to connect to database'); - $consoleHelper->writeln(''); + $consoleHelper->writeln(''); + $consoleHelper->writeSection('Exceeded 10 attempts to connect to database'); + $consoleHelper->writeln(''); - return 1; + return 1; } $connectionAttemptCount += 1; switch ($options['rdbms']) { @@ -154,8 +271,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->generateProject($consoleHelper->getOutput(), $options); $consoleHelper->writeSection('Propel 2 is ready to be used!'); - - return 0; } private function detectDefaultPhpDir() diff --git a/tests/Propel/Tests/Generator/Command/InitCommandTest.php b/tests/Propel/Tests/Generator/Command/InitCommandTest.php index ab32358568..215e330ba0 100644 --- a/tests/Propel/Tests/Generator/Command/InitCommandTest.php +++ b/tests/Propel/Tests/Generator/Command/InitCommandTest.php @@ -59,11 +59,8 @@ public function testExecute() $command = $app->find('init'); $commandTester = new CommandTester($command); - $setInputs = $this->getInputsArray(); - var_dump($setInputs); - $command = ['command' => $command->getName()]; - $commandTester->setInputs($setInputs); - $commandTester->execute($command); + $input = ['command' => $command->getName()] + $this->getInputArguments(); + $commandTester->execute($input); $this->assertContains('Propel 2 is ready to be used!', $commandTester->getDisplay()); $this->assertTrue(file_exists($this->dir . '/schema.xml'), 'Example schema file created.'); @@ -88,50 +85,26 @@ public function testExecuteAborted() $command = $app->find('init'); $commandTester = new CommandTester($command); - $commandTester->setInputs($this->getInputsArray('no')); - $commandTester->execute(['command' => $command->getName()]); + $input = ['command' => $command->getName()] + $this->getInputArguments('no'); + $commandTester->execute($input); $this->assertContains('Process aborted', $commandTester->getDisplay()); } - private function getInputsArray($lastAnswer = 'yes') + private function getInputArguments($lastAnswer = 'yes') { - $dsn = $this->getConnectionDsn('bookstore', true); - - $dsn = str_replace(':', ';', $dsn); - $dsnArray = explode(';', $dsn); - $dsnArray = array_map(function ($element) { - $pos = strpos($element, '='); - if (false !== $pos) { - $element = substr($element, $pos + 1); - } - - return $element; - - }, $dsnArray); - - $inputs = []; - $firstDsnElement = array_shift($dsnArray); - if ($firstDsnElement) { - $inputs[] = $firstDsnElement; - } - - if ($this->getDriver() !== 'sqlite') { - $inputs[] = array_shift($dsnArray); - $inputs[] = null; - } - $inputs = array_merge($inputs, [ - $dsnArray[0], - isset($dsnArray[1]) ? $dsnArray[1] : null, - isset($dsnArray[2]) ? $dsnArray[2] : null, - 'utf8', - 'no', - $this->dir, - $this->dir . '/Model/', - 'Init\\Command\\Namespace', - 'yml', - $lastAnswer - ]); + $inputs = [ + 'connection' => $this->getConnectionDsn('bookstore', true), + 'namespace' => 'Init\\Command\\Namespace', + 'phpModelPath' => $this->dir . '/Model/', + 'schemaPath' => $this->dir, + 'charset' => 'utf8', + 'preexistingDB' => 'no', + 'password' => '', + 'user' => 'root', + 'adapter' => $this->getDriver(), + 'configFormat' => 'yml', + ]; return $inputs; } From 68fe10af817cdac5d8bada21cb1d747f77754bef Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 18:12:50 +0200 Subject: [PATCH 036/208] Get options, see what is missing --- src/Propel/Generator/Command/InitCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Propel/Generator/Command/InitCommand.php b/src/Propel/Generator/Command/InitCommand.php index ee8a6d8a4f..13b2775efc 100644 --- a/src/Propel/Generator/Command/InitCommand.php +++ b/src/Propel/Generator/Command/InitCommand.php @@ -129,6 +129,7 @@ private function argumentBasedSetup(InputInterface $input, OutputInterface $outp $isReverseEngineerRequested = $args['preexistingDB']; + var_dump($options); if ($this->testConnection($consoleHelper, $options)) { $consoleHelper->writeSection('Unable to connect to database'); From 54bf347fcfb1ea0ff3bdc71fe8f4c92547a33da0 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 18:32:01 +0200 Subject: [PATCH 037/208] Revert "Get options, see what is missing" This reverts commit 133209a6409e101ce994e078f424bf1a123b7cc6. --- src/Propel/Generator/Command/InitCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Propel/Generator/Command/InitCommand.php b/src/Propel/Generator/Command/InitCommand.php index 13b2775efc..ee8a6d8a4f 100644 --- a/src/Propel/Generator/Command/InitCommand.php +++ b/src/Propel/Generator/Command/InitCommand.php @@ -129,7 +129,6 @@ private function argumentBasedSetup(InputInterface $input, OutputInterface $outp $isReverseEngineerRequested = $args['preexistingDB']; - var_dump($options); if ($this->testConnection($consoleHelper, $options)) { $consoleHelper->writeSection('Unable to connect to database'); From c07a2d33c6ad269a868c5332f9a1b610d1f2e469 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 18:32:05 +0200 Subject: [PATCH 038/208] Revert "I have to implement a non-interactive version of init so I can have fully BC tests" This reverts commit 4d66d7508e10512d5795937ac6dc272967bfeb03. --- src/Propel/Generator/Command/InitCommand.php | 131 ++---------------- .../Generator/Command/InitCommandTest.php | 61 +++++--- 2 files changed, 52 insertions(+), 140 deletions(-) diff --git a/src/Propel/Generator/Command/InitCommand.php b/src/Propel/Generator/Command/InitCommand.php index ee8a6d8a4f..903aaec24f 100644 --- a/src/Propel/Generator/Command/InitCommand.php +++ b/src/Propel/Generator/Command/InitCommand.php @@ -18,7 +18,6 @@ use Propel\Runtime\Connection\ConnectionFactory; use Propel\Runtime\Connection\Exception\ConnectionException; use Symfony\Component\Console\Input\ArrayInput; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Finder\Finder; @@ -44,127 +43,11 @@ protected function configure() $this ->setName('init') - ->setDescription('Initializes a new project. Interactive when no input is provided.') - ->addArgument( - 'adapter', - InputArgument::OPTIONAL, - 'DB Adapter to use. One of: mysql, sqlite, pgsql, oracle, sqlsrv, mssql' - ) - ->addArgument( - 'connection', - InputArgument::OPTIONAL, - 'The Pdo connection string to use. eg: mysql:host=127.0.0.1;port=;dbname=test' - ) - ->addArgument( - 'user', - InputArgument::OPTIONAL, - 'The database user. eg: root' - - ) - ->addArgument( - 'password', - InputArgument::OPTIONAL, - 'The database password. Passwords command arguments in production are insecure and discouraged' - ) - ->addArgument( - 'charset', - InputArgument::OPTIONAL, - 'The connection charset to use. eg: "utf8"' - ) - ->addArgument( - 'preexistingDB', - InputArgument::OPTIONAL, - 'If the database in the connection string already exists, Propel will reverse engineer the schema setup. answers: "yes", "no"' - ) - ->addArgument( - 'schemaPath', - InputArgument::OPTIONAL, - 'Path for the schema files' - ) - ->addArgument( - 'phpModelPath', - InputArgument::OPTIONAL, - 'Path to store generated PHP models' - ) - ->addArgument( - 'namespace', - InputArgument::OPTIONAL, - 'Namespace for generated PHP models' - ) - ->addArgument( - 'configFormat', - InputArgument::OPTIONAL, - 'Format of generated configuration files. One of: yml, xml, json, ini, php' - ); + ->setDescription('Initializes a new project') + ; } protected function execute(InputInterface $input, OutputInterface $output): int - { - $args = $input->getArguments(); - $allArgumentsAreProvided = (count(array_filter($args)) === 10); - - if ($allArgumentsAreProvided) { - return $this->argumentBasedSetup($input, $output); - } - - return $this->interactiveSetup($input, $output); - } - - private function argumentBasedSetup(InputInterface $input, OutputInterface $output): int - { - $consoleHelper = $this->createConsoleHelper($input, $output); - - $args = $input->getArguments(); - $options = [ - 'format' => $args['configFormat'], - 'namespace' => $args['namespace'], - 'phpDir' => $args['phpModelPath'], - 'schemaDir' => $args['schemaPath'], - 'charset' => $args['charset'], - 'password' => $args['password'], - 'user' => $args['user'], - 'dsn' => $args['connection'], - 'rdbms' => $args['adapter'] - ]; - - $isReverseEngineerRequested = $args['preexistingDB']; - - if ($this->testConnection($consoleHelper, $options)) { - $consoleHelper->writeSection('Unable to connect to database'); - - return 1; - } - - if ($isReverseEngineerRequested) { - $options['schema'] = $this->reverseEngineerSchema($consoleHelper->getOutput(), $options); - } - - $consoleHelper->writeBlock('Propel 2 Initializer - Summary'); - $consoleHelper->writeSection('The Propel 2 Initializer will set up your project with the following settings:'); - - $consoleHelper->writeSummary([ - 'Path to schema.xml' => $options['schemaDir'] . '/schema.xml', - 'Path to config file' => sprintf('%s/propel.%s', getcwd(), $options['format']), - 'Path to generated php models' => $options['phpDir'], - 'Namespace of generated php models' => $options['namespace'], - ]); - - $consoleHelper->writeSummary([ - 'Database management system' => $options['rdbms'], - 'Charset' => $options['charset'], - 'User' => $options['user'], - ]); - - $consoleHelper->writeln(''); - - $this->generateProject($consoleHelper->getOutput(), $options); - - $consoleHelper->writeSection('Propel 2 is ready to be used!'); - - return 0; - } - - private function interactiveSetup(InputInterface $input, OutputInterface $output): int { $consoleHelper = $this->createConsoleHelper($input, $output); $options = []; @@ -191,11 +74,11 @@ private function interactiveSetup(InputInterface $input, OutputInterface $output $connectionAttemptCount = 0; do { if ($connectionAttemptCount >= $connectionAttemptLimit) { - $consoleHelper->writeln(''); - $consoleHelper->writeSection('Exceeded 10 attempts to connect to database'); - $consoleHelper->writeln(''); + $consoleHelper->writeln(''); + $consoleHelper->writeSection('Exceeded 10 attempts to connect to database'); + $consoleHelper->writeln(''); - return 1; + return 1; } $connectionAttemptCount += 1; switch ($options['rdbms']) { @@ -271,6 +154,8 @@ private function interactiveSetup(InputInterface $input, OutputInterface $output $this->generateProject($consoleHelper->getOutput(), $options); $consoleHelper->writeSection('Propel 2 is ready to be used!'); + + return 0; } private function detectDefaultPhpDir() diff --git a/tests/Propel/Tests/Generator/Command/InitCommandTest.php b/tests/Propel/Tests/Generator/Command/InitCommandTest.php index 215e330ba0..ab32358568 100644 --- a/tests/Propel/Tests/Generator/Command/InitCommandTest.php +++ b/tests/Propel/Tests/Generator/Command/InitCommandTest.php @@ -59,8 +59,11 @@ public function testExecute() $command = $app->find('init'); $commandTester = new CommandTester($command); - $input = ['command' => $command->getName()] + $this->getInputArguments(); - $commandTester->execute($input); + $setInputs = $this->getInputsArray(); + var_dump($setInputs); + $command = ['command' => $command->getName()]; + $commandTester->setInputs($setInputs); + $commandTester->execute($command); $this->assertContains('Propel 2 is ready to be used!', $commandTester->getDisplay()); $this->assertTrue(file_exists($this->dir . '/schema.xml'), 'Example schema file created.'); @@ -85,26 +88,50 @@ public function testExecuteAborted() $command = $app->find('init'); $commandTester = new CommandTester($command); - $input = ['command' => $command->getName()] + $this->getInputArguments('no'); - $commandTester->execute($input); + $commandTester->setInputs($this->getInputsArray('no')); + $commandTester->execute(['command' => $command->getName()]); $this->assertContains('Process aborted', $commandTester->getDisplay()); } - private function getInputArguments($lastAnswer = 'yes') + private function getInputsArray($lastAnswer = 'yes') { - $inputs = [ - 'connection' => $this->getConnectionDsn('bookstore', true), - 'namespace' => 'Init\\Command\\Namespace', - 'phpModelPath' => $this->dir . '/Model/', - 'schemaPath' => $this->dir, - 'charset' => 'utf8', - 'preexistingDB' => 'no', - 'password' => '', - 'user' => 'root', - 'adapter' => $this->getDriver(), - 'configFormat' => 'yml', - ]; + $dsn = $this->getConnectionDsn('bookstore', true); + + $dsn = str_replace(':', ';', $dsn); + $dsnArray = explode(';', $dsn); + $dsnArray = array_map(function ($element) { + $pos = strpos($element, '='); + if (false !== $pos) { + $element = substr($element, $pos + 1); + } + + return $element; + + }, $dsnArray); + + $inputs = []; + $firstDsnElement = array_shift($dsnArray); + if ($firstDsnElement) { + $inputs[] = $firstDsnElement; + } + + if ($this->getDriver() !== 'sqlite') { + $inputs[] = array_shift($dsnArray); + $inputs[] = null; + } + $inputs = array_merge($inputs, [ + $dsnArray[0], + isset($dsnArray[1]) ? $dsnArray[1] : null, + isset($dsnArray[2]) ? $dsnArray[2] : null, + 'utf8', + 'no', + $this->dir, + $this->dir . '/Model/', + 'Init\\Command\\Namespace', + 'yml', + $lastAnswer + ]); return $inputs; } From 8514a3e915b452c32500b109d3870f0b8f630dc8 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 18:35:24 +0200 Subject: [PATCH 039/208] The other option is to re-implement the entire CommandTester to support covering this test case on sf2.7 --- .../Tests/Generator/Command/InitCommandTest.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/Propel/Tests/Generator/Command/InitCommandTest.php b/tests/Propel/Tests/Generator/Command/InitCommandTest.php index ab32358568..72479fc62b 100644 --- a/tests/Propel/Tests/Generator/Command/InitCommandTest.php +++ b/tests/Propel/Tests/Generator/Command/InitCommandTest.php @@ -48,6 +48,10 @@ public function setUp() public function testExecute() { + if (!method_exists(CommandTester::class, 'setInputs')) { + $this->markTestSkipped('Interactive console input was not present in some earlier versions of symphony/console'); + } + $app = new Application('Propel', Propel::VERSION); $app->addCommands([ new InitCommand(), @@ -59,11 +63,8 @@ public function testExecute() $command = $app->find('init'); $commandTester = new CommandTester($command); - $setInputs = $this->getInputsArray(); - var_dump($setInputs); - $command = ['command' => $command->getName()]; - $commandTester->setInputs($setInputs); - $commandTester->execute($command); + $commandTester->setInputs($this->getInputsArray()); + $commandTester->execute(['command' => $command->getName()]); $this->assertContains('Propel 2 is ready to be used!', $commandTester->getDisplay()); $this->assertTrue(file_exists($this->dir . '/schema.xml'), 'Example schema file created.'); @@ -78,6 +79,10 @@ public function testExecute() public function testExecuteAborted() { + if (!method_exists(CommandTester::class, 'setInputs')) { + $this->markTestSkipped('Interactive console input was not present in some earlier versions of symphony/console'); + } + $app = new Application('Propel', Propel::VERSION); $app->addCommands([ new InitCommand(), From 7c2e8f62e95719d2fc34865a0c51cfbff0e2c43e Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 30 Jun 2020 20:36:33 +0200 Subject: [PATCH 040/208] php8 needs stability dev due to 2nd order deps --- tests/composer/composer-php8.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/composer/composer-php8.json b/tests/composer/composer-php8.json index fc6769bc9e..8aea8a336d 100644 --- a/tests/composer/composer-php8.json +++ b/tests/composer/composer-php8.json @@ -2,6 +2,8 @@ "name": "propel/propel", "type": "library", "description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.", + "minimum-stability": "dev", + "prefer-stable": true, "keywords": [ "ORM", "persistence", From e72bf4050bafebc3b5d09aa5a247806a099bb9c7 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Wed, 1 Jul 2020 09:05:01 +0200 Subject: [PATCH 041/208] Symfony fixed a bug with this in PHP7.4 that wasn't ported to 4.{0,1,2,3} The only way to support it is to clone-and-own the code. --- .../Command/Console/Input/ArrayInput.php | 202 ++++++++++++++++++ src/Propel/Generator/Command/InitCommand.php | 2 +- 2 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 src/Propel/Generator/Command/Console/Input/ArrayInput.php diff --git a/src/Propel/Generator/Command/Console/Input/ArrayInput.php b/src/Propel/Generator/Command/Console/Input/ArrayInput.php new file mode 100644 index 0000000000..a0fb987f9f --- /dev/null +++ b/src/Propel/Generator/Command/Console/Input/ArrayInput.php @@ -0,0 +1,202 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Propel\Generator\Command\Console\Input; + +use Symfony\Component\Console\Exception\InvalidArgumentException; +use Symfony\Component\Console\Exception\InvalidOptionException; + +/** + * ArrayInput represents an input provided as an array. + * + * Usage: + * + * $input = new ArrayInput(['command' => 'foo:bar', 'foo' => 'bar', '--bar' => 'foobar']); + * + * @author Fabien Potencier + */ +class ArrayInput extends Input +{ + private $parameters; + + public function __construct(array $parameters, InputDefinition $definition = null) + { + $this->parameters = $parameters; + + parent::__construct($definition); + } + + /** + * {@inheritdoc} + */ + public function getFirstArgument() + { + foreach ($this->parameters as $key => $value) { + if ($key && '-' === $key[0]) { + continue; + } + + return $value; + } + + return null; + } + + /** + * {@inheritdoc} + */ + public function hasParameterOption($values, $onlyParams = false) + { + $values = (array) $values; + + foreach ($this->parameters as $k => $v) { + if (!\is_int($k)) { + $v = $k; + } + + if ($onlyParams && '--' === $v) { + return false; + } + + if (\in_array($v, $values)) { + return true; + } + } + + return false; + } + + /** + * {@inheritdoc} + */ + public function getParameterOption($values, $default = false, $onlyParams = false) + { + $values = (array) $values; + + foreach ($this->parameters as $k => $v) { + if ($onlyParams && ('--' === $k || (\is_int($k) && '--' === $v))) { + return $default; + } + + if (\is_int($k)) { + if (\in_array($v, $values)) { + return true; + } + } elseif (\in_array($k, $values)) { + return $v; + } + } + + return $default; + } + + /** + * Returns a stringified representation of the args passed to the command. + * + * @return string + */ + public function __toString() + { + $params = []; + foreach ($this->parameters as $param => $val) { + if ($param && '-' === $param[0]) { + if (\is_array($val)) { + foreach ($val as $v) { + $params[] = $param.('' != $v ? '='.$this->escapeToken($v) : ''); + } + } else { + $params[] = $param.('' != $val ? '='.$this->escapeToken($val) : ''); + } + } else { + $params[] = \is_array($val) ? implode(' ', array_map([$this, 'escapeToken'], $val)) : $this->escapeToken($val); + } + } + + return implode(' ', $params); + } + + /** + * {@inheritdoc} + */ + protected function parse() + { + foreach ($this->parameters as $key => $value) { + if ('--' === $key) { + return; + } + if (0 === strpos($key, '--')) { + $this->addLongOption(substr($key, 2), $value); + } elseif (0 === strpos($key, '-')) { + $this->addShortOption(substr($key, 1), $value); + } else { + $this->addArgument($key, $value); + } + } + } + + /** + * Adds a short option value. + * + * @throws InvalidOptionException When option given doesn't exist + */ + private function addShortOption(string $shortcut, $value) + { + if (!$this->definition->hasShortcut($shortcut)) { + throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut)); + } + + $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value); + } + + /** + * Adds a long option value. + * + * @throws InvalidOptionException When option given doesn't exist + * @throws InvalidOptionException When a required value is missing + */ + private function addLongOption(string $name, $value) + { + if (!$this->definition->hasOption($name)) { + throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name)); + } + + $option = $this->definition->getOption($name); + + if (null === $value) { + if ($option->isValueRequired()) { + throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name)); + } + + if (!$option->isValueOptional()) { + $value = true; + } + } + + $this->options[$name] = $value; + } + + /** + * Adds an argument value. + * + * @param string|int $name The argument name + * @param mixed $value The value for the argument + * + * @throws InvalidArgumentException When argument given doesn't exist + */ + private function addArgument($name, $value) + { + if (!$this->definition->hasArgument($name)) { + throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); + } + + $this->arguments[$name] = $value; + } +} diff --git a/src/Propel/Generator/Command/InitCommand.php b/src/Propel/Generator/Command/InitCommand.php index 903aaec24f..b4f520011a 100644 --- a/src/Propel/Generator/Command/InitCommand.php +++ b/src/Propel/Generator/Command/InitCommand.php @@ -10,6 +10,7 @@ namespace Propel\Generator\Command; +use Propel\Generator\Command\Console\Input\ArrayInput; use Propel\Generator\Builder\Util\PropelTemplate; use Propel\Generator\Command\Helper\ConsoleHelper; use Propel\Generator\Command\Helper\ConsoleHelper3; @@ -17,7 +18,6 @@ use Propel\Runtime\Adapter\AdapterFactory; use Propel\Runtime\Connection\ConnectionFactory; use Propel\Runtime\Connection\Exception\ConnectionException; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Finder\Finder; From 42c0a08b4397f11df5c5c2d9fc499400e94bc1ee Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Wed, 1 Jul 2020 11:03:29 +0200 Subject: [PATCH 042/208] Missing import for input --- src/Propel/Generator/Command/Console/Input/ArrayInput.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Propel/Generator/Command/Console/Input/ArrayInput.php b/src/Propel/Generator/Command/Console/Input/ArrayInput.php index a0fb987f9f..6c30824118 100644 --- a/src/Propel/Generator/Command/Console/Input/ArrayInput.php +++ b/src/Propel/Generator/Command/Console/Input/ArrayInput.php @@ -13,6 +13,7 @@ use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\InvalidOptionException; +use Symfony\Component\Console\Input\Input; /** * ArrayInput represents an input provided as an array. From db208d7145f70b2a24d3ecff52b85f9252c91729 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Wed, 1 Jul 2020 14:32:57 +0200 Subject: [PATCH 043/208] The symfony 4.2 Unique validator is not a suitable replacement for Propel's --- src/Propel/Generator/Behavior/Validate/ValidateBehavior.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php index 89d456078a..864233a9b7 100644 --- a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php +++ b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php @@ -205,7 +205,11 @@ protected function addLoadValidatorMetadataMethod() $classConstraint = "Propel\\Runtime\\Validator\\Constraints\\".$properties['validator']; } } else { - $classConstraint = "Symfony\\Component\\Validator\\Constraints\\".$properties['validator']; + if ($properties['validator'] === 'Unique') { + $classConstraint = "Propel\\Runtime\\Validator\\Constraints\\".$properties['validator']; + } else { + $classConstraint = "Symfony\\Component\\Validator\\Constraints\\".$properties['validator']; + } } if (isset($properties['options'])) { From 5d6928f8f27dcd8f20c12f59f14cf06ea6ae839e Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Wed, 1 Jul 2020 14:35:56 +0200 Subject: [PATCH 044/208] Remove var_dumps --- .../Tests/Generator/Behavior/Validate/UniqueConstraintTest.php | 3 --- .../Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php | 3 --- 2 files changed, 6 deletions(-) diff --git a/tests/Propel/Tests/Generator/Behavior/Validate/UniqueConstraintTest.php b/tests/Propel/Tests/Generator/Behavior/Validate/UniqueConstraintTest.php index a8b42bc22f..1d2255d47a 100644 --- a/tests/Propel/Tests/Generator/Behavior/Validate/UniqueConstraintTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Validate/UniqueConstraintTest.php @@ -29,9 +29,6 @@ public function testUniqueValidatorPass() $publisher->setName('Happy Reading'); $publisher->setWebsite('http://www.happyreading.com'); $isValid = $publisher->validate(); - if (!$isValid) { - var_dump((string)$publisher->getValidationFailures()); - } $this->assertTrue($isValid); } diff --git a/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php index b55918f651..f070a90885 100755 --- a/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php @@ -317,9 +317,6 @@ public function testComplexValidationSingleFailure() $failures = $book->getValidationFailures(); $this->assertInstanceOf('Symfony\Component\Validator\ConstraintViolationList', $failures); - if (1 !== count($failures)) { - var_dump((string)$failures); - } $this->assertEquals(1, count($failures), 'Only one constraint violation object'); $failure = $failures[0]; From 81d303a3690eac8aa74ca5481d42b0fb821cfaca Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Wed, 1 Jul 2020 14:38:00 +0200 Subject: [PATCH 045/208] Unlock validator 5. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5d0e1a5de0..cd4751ec3b 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "symfony/filesystem": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/finder": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/translation": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||^4.0.0", + "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||^4.0.0||^5.0.0", "psr/log": "^1.0" }, "require-dev": { From 329a8d6f712364e46b22cf3abc20eb854f847308 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Wed, 1 Jul 2020 15:27:23 +0200 Subject: [PATCH 046/208] Tidy up travis builds --- .travis.yml | 168 +++++++++++++++++++--------------------------------- 1 file changed, 62 insertions(+), 106 deletions(-) diff --git a/.travis.yml b/.travis.yml index 386420c22a..384b52ecf6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -82,23 +82,6 @@ jobs: addons: mariadb: 10.2 - - php: 7.1 - env: DB=mysql MARIADB=10.2 - addons: - mariadb: 10.2 - - php: 7.2 - env: DB=mysql MARIADB=10.2 - addons: - mariadb: 10.2 - - php: 7.3 - env: DB=mysql MARIADB=10.2 - addons: - mariadb: 10.2 - - php: 7.4 - env: DB=mysql MARIADB=10.2 - addons: - mariadb: 10.2 - - php: 7.1 env: DB=mysql MARIADB=10.3 addons: @@ -326,64 +309,56 @@ jobs: - COMPOSER=./tests/composer/composer-php8.json composer install - composer show - - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - composer install --ignore-platform-reqs - - composer show - - - - name: "sf ~2.7" + - name: "PHP 7.4, Agnostic, Symfony ~2.7" php: 7.4 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - composer show - - name: "sf ^2.7" + - name: "PHP 7.4, Agnostic, Symfony ^2.7" php: 7.4 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - composer show - - name: "sf ~3" + - name: "PHP 7.4, Agnostic, Symfony ~3" php: 7.4 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - composer show - - name: "sf ^3" + - name: "PHP 7.4, Agnostic, Symfony ^3" php: 7.4 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show - - name: "sf ~4" + - name: "PHP 7.4, Agnostic, Symfony ~4" php: 7.4 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - composer show - - name: "sf ^4" + - name: "PHP 7.4, Agnostic, Symfony ^4" php: 7.4 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show - - name: "sf ~5" + - name: "PHP 7.4, Agnostic, Symfony ~5" php: 7.4 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - composer show - - name: "sf ^5" + - name: "PHP 7.4, Agnostic, Symfony ^5" php: 7.4 env: DB=agnostic install: @@ -391,57 +366,56 @@ jobs: - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show - - - name: "mysql sf ~2.7" + - name: "PHP 7.4, MySql, Symfony ~2.7" php: 7.4 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - composer show - - name: "mysql sf ^2.7" + - name: "PHP 7.4, MySql, Symfony ^2.7" php: 7.4 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - composer show - - name: "mysql sf ~3" + - name: "PHP 7.4, MySql, Symfony ~3" php: 7.4 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - composer show - - name: "mysql sf ^3" + - name: "PHP 7.4, MySql, Symfony ^3" php: 7.4 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show - - name: "mysql sf ~4" + - name: "PHP 7.4, MySql, Symfony ~4" php: 7.4 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - composer show - - name: "mysql sf ^4" + - name: "PHP 7.4, MySql, Symfony ^4" php: 7.4 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show - - name: "mysql sf ~5" + - name: "PHP 7.4, MySql, Symfony ~5" php: 7.4 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - composer show - - name: "mysql sf ^5" + - name: "PHP 7.4, MySql, Symfony ^5" php: 7.4 env: DB=mysql install: @@ -449,57 +423,56 @@ jobs: - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show - ############################ - - name: "sf ~2.7" + - name: "PHP 7.3, Agnostic, Symfony ~2.7" php: 7.3 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - composer show - - name: "sf ^2.7" + - name: "PHP 7.3, Agnostic, Symfony ^2.7" php: 7.3 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - composer show - - name: "sf ~3" + - name: "PHP 7.3, Agnostic, Symfony ~3" php: 7.3 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - composer show - - name: "sf ^3" + - name: "PHP 7.3, Agnostic, Symfony ^3" php: 7.3 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show - - name: "sf ~4" + - name: "PHP 7.3, Agnostic, Symfony ~4" php: 7.3 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - composer show - - name: "sf ^4" + - name: "PHP 7.3, Agnostic, Symfony ^4" php: 7.3 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show - - name: "sf ~5" + - name: "PHP 7.3, Agnostic, Symfony ~5" php: 7.3 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - composer show - - name: "sf ^5" + - name: "PHP 7.3, Agnostic, Symfony ^5" php: 7.3 env: DB=agnostic install: @@ -507,113 +480,113 @@ jobs: - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show - - name: "mysql sf ~2.7" + - name: "PHP 7.3, MySql, Symfony ~2.7" php: 7.3 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - composer show - - name: "mysql sf ^2.7" + - name: "PHP 7.3, MySql, Symfony ^2.7" php: 7.3 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - composer show - - name: "mysql sf ~3" + - name: "PHP 7.3, MySql, Symfony ~3" php: 7.3 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - composer show - - name: "mysql sf ^3" + - name: "PHP 7.3, MySql, Symfony ^3" php: 7.3 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show - - name: "mysql sf ~4" + - name: "PHP 7.3, MySql, Symfony ~4" php: 7.3 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - composer show - - name: "mysql sf ^4" + - name: "PHP 7.3, MySql, Symfony ^4" php: 7.3 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show - - name: "mysql sf ~5" + - name: "PHP 7.3, MySql, Symfony ~5" php: 7.3 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - composer show - - name: "mysql sf ^5" + - name: "PHP 7.3, MySql, Symfony ^5" php: 7.3 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show - ############################ - - name: "sf ~2.7" + + - name: "PHP 7.2, Agnostic, Symfony ~2.7" php: 7.2 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - composer show - - name: "sf ^2.7" + - name: "PHP 7.2, Agnostic, Symfony ^2.7" php: 7.2 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - composer show - - name: "sf ~3" + - name: "PHP 7.2, Agnostic, Symfony ~3" php: 7.2 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - composer show - - name: "sf ^3" + - name: "PHP 7.2, Agnostic, Symfony ^3" php: 7.2 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show - - name: "sf ~4" + - name: "PHP 7.2, Agnostic, Symfony ~4" php: 7.2 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - composer show - - name: "sf ^4" + - name: "PHP 7.2, Agnostic, Symfony ^4" php: 7.2 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show - - name: "sf ~5" + - name: "PHP 7.2, Agnostic, Symfony ~5" php: 7.2 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - composer show - - name: "sf ^5" + - name: "PHP 7.2, Agnostic, Symfony ^5" php: 7.2 env: DB=agnostic install: @@ -621,99 +594,99 @@ jobs: - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show - - name: "mysql sf ~2.7" + - name: "PHP 7.2, MySql, Symfony ~2.7" php: 7.2 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - composer show - - name: "mysql sf ^2.7" + - name: "PHP 7.2, MySql, Symfony ^2.7" php: 7.2 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - composer show - - name: "mysql sf ~3" + - name: "PHP 7.2, MySql, Symfony ~3" php: 7.2 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - composer show - - name: "mysql sf ^3" + - name: "PHP 7.2, MySql, Symfony ^3" php: 7.2 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show - - name: "mysql sf ~4" + - name: "PHP 7.2, MySql, Symfony ~4" php: 7.2 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - composer show - - name: "mysql sf ^4" + - name: "PHP 7.2, MySql, Symfony ^4" php: 7.2 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show - - name: "mysql sf ~5" + - name: "PHP 7.2, MySql, Symfony ~5" php: 7.2 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - composer show - - name: "mysql sf ^5" + - name: "PHP 7.2, MySql, Symfony ^5" php: 7.2 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show - ############################ - - name: "sf ~2.7" + + - name: "PHP 7.1, Agnostic, Symfony ~2.7" php: 7.1 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - composer show - - name: "sf ^2.7" + - name: "PHP 7.1, Agnostic, Symfony ^2.7" php: 7.1 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - composer show - - name: "sf ~3" + - name: "PHP 7.1, Agnostic, Symfony ~3" php: 7.1 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - composer show - - name: "sf ^3" + - name: "PHP 7.1, Agnostic, Symfony ^3" php: 7.1 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show - - name: "sf ~4" + - name: "PHP 7.1, Agnostic, Symfony ~4" php: 7.1 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - composer show - - name: "sf ^4" + - name: "PHP 7.1, Agnostic, Symfony ^4" php: 7.1 env: DB=agnostic install: @@ -721,42 +694,42 @@ jobs: - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show - - name: "mysql sf ~2.7" + - name: "PHP 7.1, MySql, Symfony ~2.7" php: 7.1 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - composer show - - name: "mysql sf ^2.7" + - name: "PHP 7.1, MySql, Symfony ^2.7" php: 7.1 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - composer show - - name: "mysql sf ~3" + - name: "PHP 7.1, MySql, Symfony ~3" php: 7.1 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - composer show - - name: "mysql sf ^3" + - name: "PHP 7.1, MySql, Symfony ^3" php: 7.1 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show - - name: "mysql sf ~4" + - name: "PHP 7.1, MySql, Symfony ~4" php: 7.1 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - composer show - - name: "mysql sf ^4" + - name: "PHP 7.1, MySql, Symfony ^4" php: 7.1 env: DB=mysql install: @@ -764,25 +737,8 @@ jobs: - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show - allow_failures: - php: nightly - - name: "sf ~2.7" - - name: "sf ^2.7" - - name: "sf ~3" - - name: "sf ^3" - - name: "sf ~4" - - name: "sf ^4" - - name: "sf ~5" - - name: "sf ^5" - - name: "mysql sf ~2.7" - - name: "mysql sf ^2.7" - - name: "mysql sf ~3" - - name: "mysql sf ^3" - - name: "mysql sf ~4" - - name: "mysql sf ^4" - - name: "mysql sf ~5" - - name: "mysql sf ^5" fast_finish: true From 59a8451dc0108d6d8e761f34067887b7a0a171de Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Wed, 1 Jul 2020 17:51:05 +0200 Subject: [PATCH 047/208] Revert "Unlock validator 5." This reverts commit 81d303a3690eac8aa74ca5481d42b0fb821cfaca. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cd4751ec3b..5d0e1a5de0 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "symfony/filesystem": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/finder": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/translation": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||^4.0.0||^5.0.0", + "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||^4.0.0", "psr/log": "^1.0" }, "require-dev": { From 0027b1cd2b93a54989d7535476e628d1962d1b4a Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Thu, 2 Jul 2020 09:34:03 +0200 Subject: [PATCH 048/208] sf validator in v3.0, v3.1 and v3.2 all have regex issues --- .travis.yml | 13 +++++++++++++ composer.json | 4 ++-- tests/composer/composer-symfony3-max.json | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 384b52ecf6..08fb6c8daa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -739,6 +739,19 @@ jobs: allow_failures: - php: nightly + - name: "PHP 7.4, Agnostic, Symfony ~5" + - name: "PHP 7.4, Agnostic, Symfony ^5" + - name: "PHP 7.4, MySql, Symfony ~5" + - name: "PHP 7.4, MySql, Symfony ^5" + - name: "PHP 7.3, Agnostic, Symfony ~5" + - name: "PHP 7.3, Agnostic, Symfony ^5" + - name: "PHP 7.3, MySql, Symfony ~5" + - name: "PHP 7.3, MySql, Symfony ^5" + - name: "PHP 7.2, Agnostic, Symfony ~5" + - name: "PHP 7.2, Agnostic, Symfony ^5" + - name: "PHP 7.2, MySql, Symfony ~5" + - name: "PHP 7.2, MySql, Symfony ^5" + fast_finish: true diff --git a/composer.json b/composer.json index 5d0e1a5de0..31aae6a044 100644 --- a/composer.json +++ b/composer.json @@ -17,13 +17,13 @@ ], "require": { "php": ">=7.1", - "symfony/yaml": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", + "symfony/yaml": "^2.7.0||^3.3.0||^4.0.0||^5.0.0", "symfony/config": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/console": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/filesystem": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/finder": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/translation": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/validator": "^2.7.0||~3.1.7||^3.2.4||^4.0.0", + "symfony/validator": "^2.7.0||^3.3.0||^4.0.0", "psr/log": "^1.0" }, "require-dev": { diff --git a/tests/composer/composer-symfony3-max.json b/tests/composer/composer-symfony3-max.json index 5eb12e29ec..cfbcf4dbd8 100644 --- a/tests/composer/composer-symfony3-max.json +++ b/tests/composer/composer-symfony3-max.json @@ -17,13 +17,13 @@ ], "require": { "php": ">=7.1", - "symfony/yaml": "^3.0.0", + "symfony/yaml": "^3.3.0", "symfony/config": "^3.0.0", "symfony/console": "^3.0.0", "symfony/filesystem": "^3.0.0", "symfony/finder": "^3.0.0", "symfony/translation": "^3.0.0", - "symfony/validator": "~3.1.7||^3.2.4", + "symfony/validator": "^3.3.0", "psr/log": "^1.0" }, "require-dev": { From f3d47fd6a7c18c922f60e19d6c46e6dfe1eea620 Mon Sep 17 00:00:00 2001 From: Steve Mareigner Date: Fri, 3 Jul 2020 15:19:18 +0200 Subject: [PATCH 049/208] fix(PDO): Can't prepare query with BINARY_ALL criteria when ATTR_EMULATE_PREPARES is false --- .../Runtime/ActiveQuery/Criterion/BinaryCriterion.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php index 9f52b5a9e5..7d7603a714 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php @@ -45,7 +45,11 @@ protected function appendPsForUniqueClauseTo(&$sb, array &$params) $field = ($this->table === null) ? $this->column : $this->table . '.' . $this->column; if ($this->comparison === Criteria::BINARY_ALL) { - $sb .= $field . ' & ' . $bindParam . ' = ' . $bindParam; + // With ATTR_EMULATE_PREPARES => false, we can't have two identical params, so let's add another param + // https://github.com/propelorm/Propel2/issues/1192 + $params[] = ['table' => $this->realtable, 'column' => $this->column, 'value' => $this->value]; + $bindParam2 = ':p' . count($params); + $sb .= $field . ' & ' . $bindParam . ' = ' . $bindParam2; } else { $sb .= $field . ' & ' . $bindParam . ' = 0'; } From 5543e1aa96d49f83a712e20719f6fe3251d6a39f Mon Sep 17 00:00:00 2001 From: Steve Mareigner Date: Fri, 3 Jul 2020 15:47:50 +0200 Subject: [PATCH 050/208] test(issue): Add test for issue 1192 --- tests/Propel/Tests/Issues/Issue1598Test.php | 63 +++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tests/Propel/Tests/Issues/Issue1598Test.php diff --git a/tests/Propel/Tests/Issues/Issue1598Test.php b/tests/Propel/Tests/Issues/Issue1598Test.php new file mode 100644 index 0000000000..f699661c3e --- /dev/null +++ b/tests/Propel/Tests/Issues/Issue1598Test.php @@ -0,0 +1,63 @@ + + + +
+ +END; + $builder = new QuickBuilder(); + $builder->setSchema($schema); + $builder->buildClasses(null, true); + Propel::getServiceContainer()->setAdapter('issue_1192', new MysqlAdapter()); + } + + /** + * Verifies that the correct SQL and Params are generated for queries that use `Criteria::BINARY_ALL`. + */ + public function testCriteriaBinaryAll() + { + /** @var ModelCriteria $query */ + $query = \Issue1192ItemQuery::create()->filterByTarget(1, Criteria::BINARY_ALL); + $params = []; + $actualSql = $query->createSelectSql($params); + + $this->assertEquals("SELECT FROM issue_1192_item WHERE issue_1192_item.target & :p1 = :p2", + $actualSql, + 'Generated SQL does not match expected SQL' + ); + + $this->assertEquals(2, count($params), 'Incorrect number of params'); + + $this->assertEquals($params[0], $params[1], 'Params are not identical'); + } + + +} From 67ba7b93b59e7ad08d989ad468b15e8e54ca3383 Mon Sep 17 00:00:00 2001 From: Steve Mareigner Date: Fri, 3 Jul 2020 15:49:15 +0200 Subject: [PATCH 051/208] chore(oops): Remove bad "use" --- tests/Propel/Tests/Issues/Issue1598Test.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Propel/Tests/Issues/Issue1598Test.php b/tests/Propel/Tests/Issues/Issue1598Test.php index f699661c3e..9bebccb980 100644 --- a/tests/Propel/Tests/Issues/Issue1598Test.php +++ b/tests/Propel/Tests/Issues/Issue1598Test.php @@ -2,7 +2,6 @@ namespace Propel\Tests\Issues; -use Domain\Module\Metadata\Form\Form; use Propel\Generator\Util\QuickBuilder; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\ModelCriteria; From 68fc1ee5815b28d4e11bf647514a0b0ef117de3e Mon Sep 17 00:00:00 2001 From: Steve Mareigner Date: Fri, 3 Jul 2020 15:50:12 +0200 Subject: [PATCH 052/208] fix(test): Incorrect class Name --- .../Propel/Tests/Issues/{Issue1598Test.php => Issue1192Test.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/Propel/Tests/Issues/{Issue1598Test.php => Issue1192Test.php} (100%) diff --git a/tests/Propel/Tests/Issues/Issue1598Test.php b/tests/Propel/Tests/Issues/Issue1192Test.php similarity index 100% rename from tests/Propel/Tests/Issues/Issue1598Test.php rename to tests/Propel/Tests/Issues/Issue1192Test.php From ef8219b189eebddd1f569ea78cf5c6a90266fb6e Mon Sep 17 00:00:00 2001 From: Steve Mareigner Date: Fri, 3 Jul 2020 15:52:11 +0200 Subject: [PATCH 053/208] fix(test): use assertSame instead of assertEquals --- tests/Propel/Tests/Issues/Issue1192Test.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/Propel/Tests/Issues/Issue1192Test.php b/tests/Propel/Tests/Issues/Issue1192Test.php index 9bebccb980..72b0ce1ac1 100644 --- a/tests/Propel/Tests/Issues/Issue1192Test.php +++ b/tests/Propel/Tests/Issues/Issue1192Test.php @@ -48,15 +48,13 @@ public function testCriteriaBinaryAll() $params = []; $actualSql = $query->createSelectSql($params); - $this->assertEquals("SELECT FROM issue_1192_item WHERE issue_1192_item.target & :p1 = :p2", + $this->assertSame("SELECT FROM issue_1192_item WHERE issue_1192_item.target & :p1 = :p2", $actualSql, 'Generated SQL does not match expected SQL' ); - $this->assertEquals(2, count($params), 'Incorrect number of params'); + $this->assertSame(2, count($params), 'Incorrect number of params'); - $this->assertEquals($params[0], $params[1], 'Params are not identical'); + $this->assertSame($params[0], $params[1], 'Params are not identical'); } - - } From c106a790cb10fd15cbc4768b80fc249ff862983f Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Mon, 6 Jul 2020 08:58:01 +0200 Subject: [PATCH 054/208] Update tests/Propel/Tests/Generator/Command/InitCommandTest.php --- tests/Propel/Tests/Generator/Command/InitCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Propel/Tests/Generator/Command/InitCommandTest.php b/tests/Propel/Tests/Generator/Command/InitCommandTest.php index 72479fc62b..d007fb8f16 100644 --- a/tests/Propel/Tests/Generator/Command/InitCommandTest.php +++ b/tests/Propel/Tests/Generator/Command/InitCommandTest.php @@ -49,7 +49,7 @@ public function setUp() public function testExecute() { if (!method_exists(CommandTester::class, 'setInputs')) { - $this->markTestSkipped('Interactive console input was not present in some earlier versions of symphony/console'); + $this->markTestSkipped('Interactive console input was not present in some earlier versions of symfony/console'); } $app = new Application('Propel', Propel::VERSION); From 9ea8516d45309fb7f8a951a996ba2c7465663d06 Mon Sep 17 00:00:00 2001 From: mscherer Date: Mon, 6 Jul 2020 15:05:05 +0200 Subject: [PATCH 055/208] Make execute() compatible to Symf5 int only. # Conflicts: # src/Propel/Generator/Command/ConfigConvertCommand.php # src/Propel/Generator/Command/DatabaseReverseCommand.php # src/Propel/Generator/Command/GraphvizGenerateCommand.php # src/Propel/Generator/Command/MigrationCreateCommand.php # src/Propel/Generator/Command/MigrationDiffCommand.php # src/Propel/Generator/Command/MigrationDownCommand.php # src/Propel/Generator/Command/MigrationMigrateCommand.php # src/Propel/Generator/Command/MigrationStatusCommand.php # src/Propel/Generator/Command/MigrationUpCommand.php # src/Propel/Generator/Command/ModelBuildCommand.php # src/Propel/Generator/Command/SqlBuildCommand.php # src/Propel/Generator/Command/SqlInsertCommand.php # src/Propel/Generator/Command/TestPrepareCommand.php --- .../Generator/Command/AbstractCommand.php | 15 +++++++++------ .../Generator/Command/ConfigConvertCommand.php | 2 +- .../Command/DatabaseReverseCommand.php | 4 ++-- .../Command/GraphvizGenerateCommand.php | 2 +- src/Propel/Generator/Command/InitCommand.php | 8 ++++---- .../Command/MigrationCreateCommand.php | 2 +- .../Generator/Command/MigrationDiffCommand.php | 6 +++--- .../Generator/Command/MigrationDownCommand.php | 8 ++++---- .../Command/MigrationMigrateCommand.php | 8 ++++---- .../Command/MigrationStatusCommand.php | 10 +++++----- .../Generator/Command/MigrationUpCommand.php | 10 +++++----- .../Generator/Command/ModelBuildCommand.php | 2 +- .../Generator/Command/SqlBuildCommand.php | 2 +- .../Generator/Command/SqlInsertCommand.php | 4 ++-- .../Generator/Command/TestPrepareCommand.php | 17 ++++++++++++----- 15 files changed, 55 insertions(+), 45 deletions(-) diff --git a/src/Propel/Generator/Command/AbstractCommand.php b/src/Propel/Generator/Command/AbstractCommand.php index 1c75dce2fb..87987f76b4 100644 --- a/src/Propel/Generator/Command/AbstractCommand.php +++ b/src/Propel/Generator/Command/AbstractCommand.php @@ -23,7 +23,10 @@ */ abstract class AbstractCommand extends Command { - const DEFAULT_CONFIG_DIRECTORY = '.'; + public const DEFAULT_CONFIG_DIRECTORY = '.'; + + public const CODE_SUCCESS = 0; + public const CODE_ERROR = 1; protected $filesystem; @@ -142,7 +145,7 @@ protected function parseConnection($connection) /** * Parse a connection string and return an array of properties to pass to GeneratorConfig constructor. - * The connection must be in the following format: + * The connection must be in the following format: * `bookstore=mysql:host=127.0.0.1;dbname=test;user=root;password=foobar` * where "bookstore" is your propel database name (used in your schema.xml). * @@ -152,18 +155,18 @@ protected function parseConnection($connection) * @return array */ protected function connectionToProperties($connection, $section = null) - { + { list($name, $dsn, $infos) = $this->parseConnection($connection); $config['propel']['database']['connections'][$name]['classname'] = '\Propel\Runtime\Connection\ConnectionWrapper'; $config['propel']['database']['connections'][$name]['adapter'] = strtolower($infos['adapter']); $config['propel']['database']['connections'][$name]['dsn'] = $dsn; $config['propel']['database']['connections'][$name]['user'] = isset($infos['user']) && $infos['user'] ? $infos['user'] : null; $config['propel']['database']['connections'][$name]['password'] = isset($infos['password']) ? $infos['password'] : null; - + if (null === $section) { $section = 'generator'; } - + if ('reverse' === $section) { $config['propel']['reverse']['connection'] = $name; } else { @@ -185,7 +188,7 @@ protected function hasInputOption($option, $input) { return $input->hasOption($option) && null !== $input->getOption($option); } - + /** * Check if a given input argument exists and it isn't null. * diff --git a/src/Propel/Generator/Command/ConfigConvertCommand.php b/src/Propel/Generator/Command/ConfigConvertCommand.php index d559b3e3fc..0e295dfe39 100644 --- a/src/Propel/Generator/Command/ConfigConvertCommand.php +++ b/src/Propel/Generator/Command/ConfigConvertCommand.php @@ -78,6 +78,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln(sprintf('Successfully wrote PHP configuration in file "%s".', $outputFilePath)); } - return 0; + return static::CODE_SUCCESS; } } diff --git a/src/Propel/Generator/Command/DatabaseReverseCommand.php b/src/Propel/Generator/Command/DatabaseReverseCommand.php index d259a49138..d7b902ab2d 100644 --- a/src/Propel/Generator/Command/DatabaseReverseCommand.php +++ b/src/Propel/Generator/Command/DatabaseReverseCommand.php @@ -92,7 +92,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $manager->setSchemaName($input->getOption('schema-name')); $namespace = $input->getOption('namespace'); - + if ($namespace) { $manager->setNamespace($namespace); } @@ -101,6 +101,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Schema reverse engineering finished.'); } - return 0; + return static::CODE_SUCCESS; } } diff --git a/src/Propel/Generator/Command/GraphvizGenerateCommand.php b/src/Propel/Generator/Command/GraphvizGenerateCommand.php index e85e0107d6..e23ec6cb68 100644 --- a/src/Propel/Generator/Command/GraphvizGenerateCommand.php +++ b/src/Propel/Generator/Command/GraphvizGenerateCommand.php @@ -63,6 +63,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $manager->build(); - return 0; + return static::CODE_SUCCESS; } } diff --git a/src/Propel/Generator/Command/InitCommand.php b/src/Propel/Generator/Command/InitCommand.php index b4f520011a..f7ff4962b7 100644 --- a/src/Propel/Generator/Command/InitCommand.php +++ b/src/Propel/Generator/Command/InitCommand.php @@ -147,7 +147,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!$correct) { $consoleHelper->writeln('Process aborted.'); - return 1; + return static::CODE_ERROR; } $consoleHelper->writeln(''); @@ -155,7 +155,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->generateProject($consoleHelper->getOutput(), $options); $consoleHelper->writeSection('Propel 2 is ready to be used!'); - return 0; + return static::CODE_SUCCESS; } private function detectDefaultPhpDir() @@ -305,11 +305,11 @@ private function reverseEngineerSchema(OutputInterface $output, array $options) 'connection' => $fullDsn, '--output-dir' => $outputDir ]; - + if (isset($options['namespace'])) { $arrInput['--namespace'] = $options['namespace']; } - + $input = new ArrayInput($arrInput); $result = $this->getApplication()->run($input,$output); diff --git a/src/Propel/Generator/Command/MigrationCreateCommand.php b/src/Propel/Generator/Command/MigrationCreateCommand.php index 89c43c20fb..71e5d4c09c 100644 --- a/src/Propel/Generator/Command/MigrationCreateCommand.php +++ b/src/Propel/Generator/Command/MigrationCreateCommand.php @@ -97,7 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Once the migration class is valid, call the "migrate" task to execute it.'); } - return 0; + return static::CODE_SUCCESS; } } diff --git a/src/Propel/Generator/Command/MigrationDiffCommand.php b/src/Propel/Generator/Command/MigrationDiffCommand.php index 7a2ab6f831..2065e3d6dd 100644 --- a/src/Propel/Generator/Command/MigrationDiffCommand.php +++ b/src/Propel/Generator/Command/MigrationDiffCommand.php @@ -169,7 +169,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $excludedTables = $input->getOption('skip-tables'); $configManager = new ConfigurationManager($input->getOption('config-dir')); $excludedTables = array_merge((array) $excludedTables, (array) $configManager->getSection('exclude_tables')); - + foreach ($reversedSchema->getDatabases() as $database) { $name = $database->getName(); @@ -212,7 +212,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!$migrationsUp) { $output->writeln('Same XML and database structures for all datasource - no diff to generate'); - return 0; + return static::CODE_SUCCESS; } $timestamp = time(); @@ -232,7 +232,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Once the migration class is valid, call the "migrate" task to execute it.'); } - return 0; + return static::CODE_SUCCESS; } } diff --git a/src/Propel/Generator/Command/MigrationDownCommand.php b/src/Propel/Generator/Command/MigrationDownCommand.php index e25917fb85..b7acc67834 100644 --- a/src/Propel/Generator/Command/MigrationDownCommand.php +++ b/src/Propel/Generator/Command/MigrationDownCommand.php @@ -55,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($this->hasInputOption('migration-table', $input)) { $configOptions['propel']['migrations']['tableName'] = $input->getOption('migration-table'); } - + $generatorConfig = $this->getGeneratorConfig($configOptions, $input); $this->createDirectory($generatorConfig->getSection('paths')['migrationDir']); @@ -83,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!$nextMigrationTimestamp) { $output->writeln('No migration were ever executed on this database - nothing to reverse.'); - return 1; + return static::CODE_ERROR; } $output->writeln(sprintf( @@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } else { $output->writeln('preDown() returned false. Aborting migration.'); - return 1; + return static::CODE_ERROR; } } } @@ -182,6 +182,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Reverse migration complete. No more migration available for reverse'); } - return 0; + return static::CODE_SUCCESS; } } diff --git a/src/Propel/Generator/Command/MigrationMigrateCommand.php b/src/Propel/Generator/Command/MigrationMigrateCommand.php index f2a6598728..411afe1938 100644 --- a/src/Propel/Generator/Command/MigrationMigrateCommand.php +++ b/src/Propel/Generator/Command/MigrationMigrateCommand.php @@ -55,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($this->hasInputOption('migration-table', $input)) { $configOptions['propel']['migrations']['tableName'] = $input->getOption('migration-table'); } - + $generatorConfig = $this->getGeneratorConfig($configOptions, $input); $this->createDirectory($generatorConfig->getSection('paths')['migrationDir']); @@ -81,7 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!$manager->getFirstUpMigrationTimestamp()) { $output->writeln('All migrations were already executed - nothing to migrate.'); - return 1; + return static::CODE_ERROR; } $timestamps = $manager->getValidMigrationTimestamps(); @@ -113,7 +113,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } else { $output->writeln('preUp() returned false. Aborting migration.'); - return 1; + return static::CODE_ERROR; } } @@ -187,6 +187,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Migration complete. No further migration to execute.'); - return 0; + return static::CODE_SUCCESS; } } diff --git a/src/Propel/Generator/Command/MigrationStatusCommand.php b/src/Propel/Generator/Command/MigrationStatusCommand.php index 47906d4e3d..5b7016657c 100644 --- a/src/Propel/Generator/Command/MigrationStatusCommand.php +++ b/src/Propel/Generator/Command/MigrationStatusCommand.php @@ -47,11 +47,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($this->hasInputOption('output-dir', $input)) { $configOptions['propel']['paths']['migrationDir'] = $input->getOption('output-dir'); } - + if ($this->hasInputOption('migration-table', $input)) { $configOptions['propel']['migrations']['tableName'] = $input->getOption('migration-table'); } - + $generatorConfig = $this->getGeneratorConfig($configOptions, $input); $this->createDirectory($generatorConfig->getSection('paths')['migrationDir']); @@ -142,7 +142,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } else { $output->writeln(sprintf('No migration file found in "%s".', $dir)); - return 1; + return static::CODE_ERROR; } $migrationTimestamps = $manager->getValidMigrationTimestamps(); @@ -151,7 +151,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!$nbNotYetExecutedMigrations) { $output->writeln('All migration files were already executed - Nothing to migrate.'); - return 1; + return static::CODE_ERROR; } $output->writeln(sprintf( @@ -159,6 +159,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $countValidTimestamps == 1 ? 'it' : 'them' )); - return 0; + return static::CODE_SUCCESS; } } diff --git a/src/Propel/Generator/Command/MigrationUpCommand.php b/src/Propel/Generator/Command/MigrationUpCommand.php index c93f8a2788..2c75b15f6d 100644 --- a/src/Propel/Generator/Command/MigrationUpCommand.php +++ b/src/Propel/Generator/Command/MigrationUpCommand.php @@ -51,11 +51,11 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($this->hasInputOption('output-dir', $input)) { $configOptions['propel']['paths']['migrationDir'] = $input->getOption('output-dir'); } - + if ($this->hasInputOption('migration-table', $input)) { $configOptions['propel']['migrations']['tableName'] = $input->getOption('migration-table'); } - + $generatorConfig = $this->getGeneratorConfig($configOptions, $input); $this->createDirectory($generatorConfig->getSection('paths')['migrationDir']); @@ -82,7 +82,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!$nextMigrationTimestamp) { $output->writeln('All migrations were already executed - nothing to migrate.'); - return 1; + return static::CODE_ERROR; } if ($input->getOption('fake')) { @@ -109,7 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('preUp() returned false. Continue migration.'); } else { $output->writeln('preUp() returned false. Aborting migration.'); - return 1; + return static::CODE_ERROR; } } } @@ -191,6 +191,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('Migration complete. No further migration to execute.'); } - return 0; + return static::CODE_SUCCESS; } } diff --git a/src/Propel/Generator/Command/ModelBuildCommand.php b/src/Propel/Generator/Command/ModelBuildCommand.php index ecc9f0051f..66562d6d49 100644 --- a/src/Propel/Generator/Command/ModelBuildCommand.php +++ b/src/Propel/Generator/Command/ModelBuildCommand.php @@ -132,6 +132,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $manager->build(); - return 0; + return static::CODE_SUCCESS; } } diff --git a/src/Propel/Generator/Command/SqlBuildCommand.php b/src/Propel/Generator/Command/SqlBuildCommand.php index a5ea31f024..5882fe562b 100644 --- a/src/Propel/Generator/Command/SqlBuildCommand.php +++ b/src/Propel/Generator/Command/SqlBuildCommand.php @@ -111,6 +111,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $manager->buildSql(); - return 0; + return static::CODE_SUCCESS; } } diff --git a/src/Propel/Generator/Command/SqlInsertCommand.php b/src/Propel/Generator/Command/SqlInsertCommand.php index 92db98c77c..0dd2b165d4 100644 --- a/src/Propel/Generator/Command/SqlInsertCommand.php +++ b/src/Propel/Generator/Command/SqlInsertCommand.php @@ -26,7 +26,7 @@ class SqlInsertCommand extends AbstractCommand protected function configure() { parent::configure(); - + $this ->addOption('sql-dir', null, InputOption::VALUE_REQUIRED, 'The SQL files directory') ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use. Example: \'bookstore=mysql:host=127.0.0.1;dbname=test;user=root;password=foobar\' where "bookstore" is your propel database name (used in your schema.xml)') @@ -71,6 +71,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $manager->insertSql(); - return 0; + return static::CODE_SUCCESS; } } diff --git a/src/Propel/Generator/Command/TestPrepareCommand.php b/src/Propel/Generator/Command/TestPrepareCommand.php index e45cc4096f..fc82b18760 100644 --- a/src/Propel/Generator/Command/TestPrepareCommand.php +++ b/src/Propel/Generator/Command/TestPrepareCommand.php @@ -95,11 +95,15 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output): int { + $result = static::CODE_SUCCESS; foreach ($this->fixtures as $fixturesDir => $connections) { - $this->buildFixtures(sprintf('%s/%s', self::FIXTURES_DIR, $fixturesDir), $connections, $input, $output); + $run = $this->buildFixtures(sprintf('%s/%s', self::FIXTURES_DIR, $fixturesDir), $connections, $input, $output); + if ($run !== static::CODE_SUCCESS) { + $result = $run; + } } - return 0; + return $result; } /** @@ -107,13 +111,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int * @param $connections * @param InputInterface $input * @param OutputInterface $output + * @return int Exit code */ - protected function buildFixtures($fixturesDir, $connections, InputInterface $input, OutputInterface $output) + protected function buildFixtures($fixturesDir, $connections, InputInterface $input, OutputInterface $output): int { if (!file_exists($this->root . '/' . $fixturesDir)) { $output->writeln(sprintf('Directory "%s" not found.', $fixturesDir)); - return 1; + return static::CODE_ERROR; } $output->writeln(sprintf('Building fixtures in %-40s ' . ($input->getOption('exclude-database') ? '(exclude-database)' : ''), $fixturesDir)); @@ -158,7 +163,7 @@ protected function buildFixtures($fixturesDir, $connections, InputInterface $inp } if ($input->getOption('exclude-database')) { - return 0; + return static::CODE_SUCCESS; } if (0 < count($this->getSchemas('.'))) { @@ -201,5 +206,7 @@ protected function buildFixtures($fixturesDir, $connections, InputInterface $inp } chdir($this->root); + + return static::CODE_SUCCESS; } } From 4e415af9cc0f02fd297f293458218c4dfb11bacf Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 26 Jun 2020 14:10:34 +0200 Subject: [PATCH 056/208] Add require-dev dependency needed for translation testing. --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 31aae6a044..1f319e8d8a 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,7 @@ "psr/log": "^1.0" }, "require-dev": { + "symfony/translation": "^3.4.0||^4.3.0||^5.0.0", "monolog/monolog": "^1.3", "phpstan/phpstan": "^0.12.4", "phpunit/phpunit": "^7.5.15" From 78862a261f15c39093710e8ecec4c66f357cf783 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 25 Jun 2020 22:51:40 +0200 Subject: [PATCH 057/208] Start enforcing PHPStan level 1. --- .travis.yml | 8 ++++++++ composer.json | 2 +- .../Common/Config/Exception/XmlParseException.php | 3 ++- .../ConcreteInheritanceBehavior.php | 2 ++ .../ConcreteInheritanceParentBehavior.php | 2 ++ .../VersionableBehaviorObjectBuilderModifier.php | 1 + .../VersionableBehaviorQueryBuilderModifier.php | 2 ++ .../ActiveQuery/Criterion/InModelCriterion.php | 2 -- tests/phpstan.neon | 12 ++++++++++-- 9 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 08fb6c8daa..b7e24dd9c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -737,6 +737,14 @@ jobs: - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show + - name: Checks + php: 7.4 + env: DB=agnostic CHECKS=1 + install: + - composer install --prefer-dist --no-interaction + script: + - composer stan + allow_failures: - php: nightly - name: "PHP 7.4, Agnostic, Symfony ~5" diff --git a/composer.json b/composer.json index 31aae6a044..905e7930d9 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ ], "scripts": { "stan": [ - "vendor/bin/phpstan analyze -l 1 -c tests/phpstan.neon src/" + "vendor/bin/phpstan analyze -c tests/phpstan.neon" ] }, "extra": { diff --git a/src/Propel/Common/Config/Exception/XmlParseException.php b/src/Propel/Common/Config/Exception/XmlParseException.php index 210fb4d294..753054e161 100644 --- a/src/Propel/Common/Config/Exception/XmlParseException.php +++ b/src/Propel/Common/Config/Exception/XmlParseException.php @@ -22,9 +22,10 @@ public function __construct(array $errors) { $numErrors = count($errors); + $message = ''; if (1 == $numErrors) { $message = "An error occurred "; - } elseif ($numErrors >1) { + } elseif ($numErrors > 1) { $message = "Some errors occurred "; } $message .= "while parsing XML configuration file:\n"; diff --git a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php index d7cae03689..ffe38d9e5f 100644 --- a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php +++ b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php @@ -25,6 +25,8 @@ */ class ConcreteInheritanceBehavior extends Behavior { + protected $builder; + // default parameters value protected $parameters = [ 'extends' => '', diff --git a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php index 08ab85a630..bb9a4102e2 100644 --- a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php +++ b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php @@ -21,6 +21,8 @@ */ class ConcreteInheritanceParentBehavior extends Behavior { + protected $builder; + // default parameters value protected $parameters = [ 'descendant_column' => 'descendant_class' diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php index 37a7dde309..7ea400a364 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php @@ -23,6 +23,7 @@ class VersionableBehaviorObjectBuilderModifier protected $table; protected $builder; protected $objectClassName; + protected $queryClassName; public function __construct($behavior) { diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php index b74186dcbc..b8ab0cb4bb 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php @@ -25,6 +25,8 @@ class VersionableBehaviorQueryBuilderModifier protected $objectClassName; + protected $queryClassName; + public function __construct($behavior) { $this->behavior = $behavior; diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php index 3c22a54cce..f62cde6e6b 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php @@ -41,7 +41,5 @@ protected function appendPsForUniqueClauseTo(&$sb, array &$params) } else { $sb .= (stripos($this->clause, ' NOT IN ') === false) ? "1<>1" : "1=1"; } - unset($value, $valuesLength); } - } diff --git a/tests/phpstan.neon b/tests/phpstan.neon index ee507fdba5..b45761bd82 100644 --- a/tests/phpstan.neon +++ b/tests/phpstan.neon @@ -1,5 +1,13 @@ parameters: + level: 1 + paths: + - '%rootDir%/../../../src/' excludes_analyse: - - '%rootDir%/../../../src/Propel/Generator/Command/templates/*' + - '%rootDir%/../../../src/Propel/Generator/Command/templates/*' + - '%rootDir%/../../../src/Propel/Generator/Behavior/AggregateColumn/templates/*' + - '%rootDir%/../../../src/Propel/Generator/Behavior/I18n/templates/*' + - '%rootDir%/../../../src/Propel/Generator/Builder/Om/templates/*' + - '%rootDir%/../../../src/Propel/Generator/Behavior/Validate/templates/*' + - '%rootDir%/../../../src/Propel/Generator/Behavior/Archivable/templates/*' ignoreErrors: - - '#Access to undefined constant PDO::.+#' + - '#Call to an undefined method .+Collection::.+Array\(\)#' From fbf0fa085a60c4fa379da6ceb22688b1438b1829 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 25 Jun 2020 23:03:12 +0200 Subject: [PATCH 058/208] Fix PHPStan detected issues. --- .../Behavior/Delegate/DelegateBehavior.php | 7 +- .../Builder/Om/AbstractOMBuilder.php | 4 +- .../Builder/Sql/Pgsql/PgsqlDataSQLBuilder.php | 99 ------------------- .../Generator/Builder/Util/SchemaReader.php | 1 + src/Propel/Generator/Model/Database.php | 4 +- .../Generator/Reverse/SqliteSchemaParser.php | 1 + src/Propel/Runtime/ActiveQuery/Criteria.php | 2 - .../Runtime/ActiveQuery/ModelCriteria.php | 6 +- tests/phpstan.neon | 3 + 9 files changed, 19 insertions(+), 108 deletions(-) delete mode 100644 src/Propel/Generator/Builder/Sql/Pgsql/PgsqlDataSQLBuilder.php diff --git a/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php b/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php index d2191c4fa6..7d41e18fa7 100644 --- a/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php +++ b/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php @@ -35,6 +35,11 @@ class DelegateBehavior extends Behavior protected $delegates = []; + /** + * @var array|null + */ + protected $double_defined; + /** * Lists the delegates and checks that the behavior can use them, * And adds a fk from the delegate to the main table if not already set @@ -187,7 +192,7 @@ protected function isColumnForeignKeyOrDuplicated(Column $column) $table = $this->getTable(); $fks = []; - if (!isset($this->double_defined)) { + if ($this->double_defined === null) { $this->double_defined = []; foreach ($this->delegates+[$table->getName() => 1] as $key => $value) { diff --git a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php index 1441c3e6cf..4d3d27ab55 100644 --- a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php @@ -1030,12 +1030,12 @@ private function clean($content) { // line feed $content = str_replace("\r\n", "\n", $content); - + // trailing whitespaces $content = preg_replace('/[ \t]*$/m', '', $content); // indentation - $content = preg_replace_callback('/^([ \t]+)/m', function ($matches) use ($content) { + $content = preg_replace_callback('/^([ \t]+)/m', function ($matches) { return str_replace("\t", ' ', $matches[0]); }, $content); diff --git a/src/Propel/Generator/Builder/Sql/Pgsql/PgsqlDataSQLBuilder.php b/src/Propel/Generator/Builder/Sql/Pgsql/PgsqlDataSQLBuilder.php deleted file mode 100644 index ba8fc7fb2e..0000000000 --- a/src/Propel/Generator/Builder/Sql/Pgsql/PgsqlDataSQLBuilder.php +++ /dev/null @@ -1,99 +0,0 @@ - - */ -class PgsqlDataSQLBuilder extends DataSQLBuilder -{ - /** - * The largest serial value encountered this far. - * - * @var int - */ - private $maxSeqVal; - - /** - * The main method in this class, returns the SQL for INSERTing data into a - * row. - * - * @param DataRow $row - * @return string - */ - public function buildRowSql(DataRow $row) - { - $sql = parent::buildRowSql($row); - - $table = $this->getTable(); - - if ($table->hasAutoIncrementPrimaryKey() && $table->getIdMethod() == IdMethod::NATIVE) { - foreach ($row->getColumnValues() as $colValue) { - if ($colValue->getColumn()->isAutoIncrement()) { - if ($colValue->getValue() > $this->maxSeqVal) { - $this->maxSeqVal = $colValue->getValue(); - } - } - } - } - - return $sql; - } - - public function getTableEndSql() - { - $table = $this->getTable(); - $sql = ''; - if ($table->hasAutoIncrementPrimaryKey() && $table->getIdMethod() == IdMethod::NATIVE) { - $seqname = $this->getPlatform()->getSequenceName($table); - $sql .= "SELECT pg_catalog.setval('$seqname', ".((int) $this->maxSeqVal)."); -"; - } - - return $sql; - } - - /** - * Returns the SQL value to insert for PostGres BOOLEAN column. - * - * @param boolean $value - * @return string - */ - protected function getBooleanSql($value) - { - if (in_array($value, ['f', 'false', '0'])) { - $value = false; - } - - return $value ? "'t'" : "'f'"; - } - - /** - * Returns the SQL code for inserting a Blob value. - * - * @param mixed $blob - * @return string - */ - protected function getBlobSql($blob) - { - if (is_resource($blob)) { - return fopen($blob, 'rb'); - } - - return (string) $blob; - } -} diff --git a/src/Propel/Generator/Builder/Util/SchemaReader.php b/src/Propel/Generator/Builder/Util/SchemaReader.php index 0a8b55d506..7299e110f5 100644 --- a/src/Propel/Generator/Builder/Util/SchemaReader.php +++ b/src/Propel/Generator/Builder/Util/SchemaReader.php @@ -70,6 +70,7 @@ class SchemaReader private $currentPackage; private $currentXmlFile; private $defaultPackage; + private $firstPass; private $encoding; /** diff --git a/src/Propel/Generator/Model/Database.php b/src/Propel/Generator/Model/Database.php index ebf634ca51..73a661c1af 100644 --- a/src/Propel/Generator/Model/Database.php +++ b/src/Propel/Generator/Model/Database.php @@ -574,7 +574,7 @@ public function removeSequence($sequence) { if ($this->sequences) { if (false !== ($idx = array_search($sequence, $this->sequences))) { - unset($this->sequence[$idx]); + unset($this->sequences[$idx]); } } } @@ -849,7 +849,7 @@ public function __toString() $column->isPrimaryKey() ? 'PK' : '', $column->isNotNull() ? 'NOT NULL' : '', $column->getDefaultValueString() ? "'".$column->getDefaultValueString()."'" : '', - $column->isAutoIncrement() ? 'AUTO_INCREMENT' : '' + $column->isAutoIncrement() ? 'AUTO_INCREMENT' : '' ); } diff --git a/src/Propel/Generator/Reverse/SqliteSchemaParser.php b/src/Propel/Generator/Reverse/SqliteSchemaParser.php index eb89c7dc64..a295ddb045 100644 --- a/src/Propel/Generator/Reverse/SqliteSchemaParser.php +++ b/src/Propel/Generator/Reverse/SqliteSchemaParser.php @@ -26,6 +26,7 @@ */ class SqliteSchemaParser extends AbstractSchemaParser { + protected $addVendorInfo; /** * Map Sqlite native types to Propel types. diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index d64a6a1b36..76d0912896 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -320,8 +320,6 @@ public function clear() $this->limit = -1; $this->aliases = []; $this->useTransaction = false; - $this->ifLvlCount = false; - $this->wasTrue = false; } /** diff --git a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php index be41b65bc6..bd31fbee9d 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php @@ -69,17 +69,19 @@ class ModelCriteria extends BaseModelCriteria protected $isWithOneToMany = false; // this is introduced to prevent useQuery->join from going wrong - protected $previousJoin = null; + protected $previousJoin; // whether to clone the current object before termination methods protected $isKeepQuery = true; // this is for the select method - protected $select = null; + protected $select; // temporary property used in replaceNames protected $currentAlias; + protected $foundMatch; + /** * Used to memorize whether we added self-select columns before. * diff --git a/tests/phpstan.neon b/tests/phpstan.neon index b45761bd82..9d1c7e2a4b 100644 --- a/tests/phpstan.neon +++ b/tests/phpstan.neon @@ -9,5 +9,8 @@ parameters: - '%rootDir%/../../../src/Propel/Generator/Builder/Om/templates/*' - '%rootDir%/../../../src/Propel/Generator/Behavior/Validate/templates/*' - '%rootDir%/../../../src/Propel/Generator/Behavior/Archivable/templates/*' + - '%rootDir%/../../../src/Propel/Generator/Behavior/Delegate/templates/*' + - '%rootDir%/../../../src/Propel/Generator/Behavior/Sortable/templates/*' + - '%rootDir%/../../../src/Propel/Generator/Behavior/NestedSet/templates/*' ignoreErrors: - '#Call to an undefined method .+Collection::.+Array\(\)#' From 6ec1c22cafc382ab0b72d56ffaaec2a7b8c1fade Mon Sep 17 00:00:00 2001 From: mscherer Date: Mon, 6 Jul 2020 15:15:25 +0200 Subject: [PATCH 059/208] Allow checks to fail for now. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b7e24dd9c9..cf607a5d6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -747,6 +747,7 @@ jobs: allow_failures: - php: nightly + - name: "Checks" - name: "PHP 7.4, Agnostic, Symfony ~5" - name: "PHP 7.4, Agnostic, Symfony ^5" - name: "PHP 7.4, MySql, Symfony ~5" @@ -760,7 +761,6 @@ jobs: - name: "PHP 7.2, MySql, Symfony ~5" - name: "PHP 7.2, MySql, Symfony ^5" - fast_finish: true cache: From 751adcd9901b98c72a1e295c045347b320474742 Mon Sep 17 00:00:00 2001 From: mscherer Date: Mon, 6 Jul 2020 15:20:33 +0200 Subject: [PATCH 060/208] Revert dependency addition. --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 1f319e8d8a..31aae6a044 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,6 @@ "psr/log": "^1.0" }, "require-dev": { - "symfony/translation": "^3.4.0||^4.3.0||^5.0.0", "monolog/monolog": "^1.3", "phpstan/phpstan": "^0.12.4", "phpunit/phpunit": "^7.5.15" From c8a40ff45c7a605372259a7c2dd387546025e4fb Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Tue, 7 Jul 2020 11:45:53 +0200 Subject: [PATCH 061/208] Sf validator v5 (#1603) * Prefer propel constraints over symfony ones. * Shim DateValidator to work with \Date objects as it did in sf4. * Symfony5 should be fully supported now * Update src/Propel/Runtime/Validator/Constraints/DateValidator.php Co-authored-by: Rene Klatt Co-authored-by: Denis Turkov --- .travis.yml | 12 ------ composer.json | 2 +- .../Behavior/Validate/ValidateBehavior.php | 37 ++++++++++++------- .../Runtime/Validator/Constraints/Date.php | 18 +++++++++ .../Validator/Constraints/DateValidator.php | 34 +++++++++++++++++ 5 files changed, 77 insertions(+), 26 deletions(-) create mode 100644 src/Propel/Runtime/Validator/Constraints/Date.php create mode 100644 src/Propel/Runtime/Validator/Constraints/DateValidator.php diff --git a/.travis.yml b/.travis.yml index cf607a5d6b..2751f58638 100644 --- a/.travis.yml +++ b/.travis.yml @@ -748,18 +748,6 @@ jobs: allow_failures: - php: nightly - name: "Checks" - - name: "PHP 7.4, Agnostic, Symfony ~5" - - name: "PHP 7.4, Agnostic, Symfony ^5" - - name: "PHP 7.4, MySql, Symfony ~5" - - name: "PHP 7.4, MySql, Symfony ^5" - - name: "PHP 7.3, Agnostic, Symfony ~5" - - name: "PHP 7.3, Agnostic, Symfony ^5" - - name: "PHP 7.3, MySql, Symfony ~5" - - name: "PHP 7.3, MySql, Symfony ^5" - - name: "PHP 7.2, Agnostic, Symfony ~5" - - name: "PHP 7.2, Agnostic, Symfony ^5" - - name: "PHP 7.2, MySql, Symfony ~5" - - name: "PHP 7.2, MySql, Symfony ^5" fast_finish: true diff --git a/composer.json b/composer.json index 905e7930d9..f58d0c0254 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "symfony/filesystem": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/finder": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", "symfony/translation": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/validator": "^2.7.0||^3.3.0||^4.0.0", + "symfony/validator": "^2.7.0||^3.3.0||^4.0.0||^5.0.0", "psr/log": "^1.0" }, "require-dev": { diff --git a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php index 864233a9b7..23f0db0809 100644 --- a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php +++ b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php @@ -198,19 +198,7 @@ protected function addLoadValidatorMetadataMethod() throw new InvalidArgumentException('Please, define the validator constraint.'); } - if (!class_exists("Symfony\\Component\\Validator\\Constraints\\".$properties['validator'], true)) { - if (!class_exists("Propel\\Runtime\\Validator\\Constraints\\".$properties['validator'], true)) { - throw new ConstraintNotFoundException('The constraint class '.$properties['validator'].' does not exist.'); - } else { - $classConstraint = "Propel\\Runtime\\Validator\\Constraints\\".$properties['validator']; - } - } else { - if ($properties['validator'] === 'Unique') { - $classConstraint = "Propel\\Runtime\\Validator\\Constraints\\".$properties['validator']; - } else { - $classConstraint = "Symfony\\Component\\Validator\\Constraints\\".$properties['validator']; - } - } + $classConstraint = $this->getClassConstraint($properties); if (isset($properties['options'])) { if (!is_array($properties['options'])) { @@ -230,6 +218,29 @@ protected function addLoadValidatorMetadataMethod() return $this->renderTemplate('objectLoadValidatorMetadata', ['constraints' => $constraints]); } + /** + * Propel constraints are preferred over Symfony ones. + * + * @param array $properties + * + * @return string + */ + protected function getClassConstraint(array $properties) + { + $constraintCandidates = [ + sprintf('Propel\\Runtime\\Validator\\Constraints\\%s', $properties['validator']), + sprintf('Symfony\\Component\\Validator\\Constraints\\%s', $properties['validator']), + ]; + + foreach ($constraintCandidates as $constraintCandidate) { + if (class_exists($constraintCandidate, true)) { + return $constraintCandidate; + } + } + + throw new ConstraintNotFoundException('The constraint class '.$properties['validator'].' does not exist.'); + } + /** * Adds the validate() method. * @return string The code to be added to model class diff --git a/src/Propel/Runtime/Validator/Constraints/Date.php b/src/Propel/Runtime/Validator/Constraints/Date.php new file mode 100644 index 0000000000..bed8dc6711 --- /dev/null +++ b/src/Propel/Runtime/Validator/Constraints/Date.php @@ -0,0 +1,18 @@ + Date: Tue, 7 Jul 2020 15:33:09 +0200 Subject: [PATCH 062/208] Add PHPStan level 1 check with baseline until we can remove symf2. --- .travis.yml | 1 - composer.json | 2 +- tests/phpstan.neon => phpstan.neon | 6 + ...rsionableBehaviorObjectBuilderModifier.php | 149 +++++++++++++++++- ...ersionableBehaviorQueryBuilderModifier.php | 72 ++++++++- 5 files changed, 223 insertions(+), 7 deletions(-) rename tests/phpstan.neon => phpstan.neon (71%) diff --git a/.travis.yml b/.travis.yml index 2751f58638..06d58c9691 100644 --- a/.travis.yml +++ b/.travis.yml @@ -747,7 +747,6 @@ jobs: allow_failures: - php: nightly - - name: "Checks" fast_finish: true diff --git a/composer.json b/composer.json index f58d0c0254..b9d8877361 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ ], "scripts": { "stan": [ - "vendor/bin/phpstan analyze -c tests/phpstan.neon" + "vendor/bin/phpstan analyze" ] }, "extra": { diff --git a/tests/phpstan.neon b/phpstan.neon similarity index 71% rename from tests/phpstan.neon rename to phpstan.neon index 9d1c7e2a4b..405dd30bc3 100644 --- a/tests/phpstan.neon +++ b/phpstan.neon @@ -1,3 +1,5 @@ +includes: + - phpstan-baseline.neon parameters: level: 1 paths: @@ -12,5 +14,9 @@ parameters: - '%rootDir%/../../../src/Propel/Generator/Behavior/Delegate/templates/*' - '%rootDir%/../../../src/Propel/Generator/Behavior/Sortable/templates/*' - '%rootDir%/../../../src/Propel/Generator/Behavior/NestedSet/templates/*' + - '%rootDir%/../../../src/Propel/Runtime/Connection/PdoConnection.php' + - '%rootDir%/../../../src/Propel/Generator/Command/Helper/ConsoleHelper.php' + - '%rootDir%/../../../src/Propel/Generator/Command/InitCommand.php' ignoreErrors: - '#Call to an undefined method .+Collection::.+Array\(\)#' + - '#Class .+TreeBuilder constructor invoked with 0 parameters, 1-3 required#' diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php index 7ea400a364..fee6261e67 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php @@ -19,43 +19,84 @@ */ class VersionableBehaviorObjectBuilderModifier { + /** + * @var \Propel\Generator\Model\Behavior + */ protected $behavior; + /** + * @var \Propel\Generator\Model\Table + */ protected $table; + /** + * @var \Propel\Generator\Builder\Om\AbstractOMBuilder + */ protected $builder; + /** + * @var string + */ protected $objectClassName; protected $queryClassName; + /** + * @param \Propel\Generator\Model\Behavior $behavior + */ public function __construct($behavior) { $this->behavior = $behavior; $this->table = $behavior->getTable(); } + /** + * @param string $key + * + * @return array + */ protected function getParameter($key) { return $this->behavior->getParameter($key); } + /** + * @param string $name + * + * @return string + */ protected function getColumnAttribute($name = 'version_column') { return strtolower($this->behavior->getColumnForParameter($name)->getName()); } + /** + * @param string $name + * + * @return string + */ protected function getColumnPhpName($name = 'version_column') { return $this->behavior->getColumnForParameter($name)->getPhpName(); } + /** + * @return string + */ protected function getVersionQueryClassName() { return $this->builder->getClassNameFromBuilder($this->builder->getNewStubQueryBuilder($this->behavior->getVersionTable())); } + /** + * @return string + */ protected function getActiveRecordClassName() { return $this->builder->getObjectClassName(); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return void + */ protected function setBuilder($builder) { $this->builder = $builder; @@ -83,6 +124,11 @@ protected function getColumnSetter($name = 'version_column') return 'set' . $this->getColumnPhpName($name); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function preSave($builder) { $script = "if (\$this->isVersioningNecessary()) { @@ -101,6 +147,11 @@ public function preSave($builder) return $script; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function postSave($builder) { return "if (isset(\$createVersion)) { @@ -108,6 +159,11 @@ public function postSave($builder) }"; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function postDelete($builder) { $this->builder = $builder; @@ -121,6 +177,11 @@ public function postDelete($builder) } } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function objectAttributes($builder) { $script = ''; @@ -130,6 +191,11 @@ public function objectAttributes($builder) return $script; } + /** + * @param string $script + * + * @return void + */ protected function addEnforceVersionAttribute(&$script) { $script .= " @@ -141,6 +207,11 @@ protected function addEnforceVersionAttribute(&$script) "; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function objectMethods($builder) { $this->setBuilder($builder); @@ -166,6 +237,11 @@ public function objectMethods($builder) return $script; } + /** + * @param string $script + * + * @return void + */ protected function addVersionSetter(&$script) { $script .= " @@ -182,6 +258,11 @@ public function setVersion(\$v) "; } + /** + * @param string $script + * + * @return void + */ protected function addVersionGetter(&$script) { $script .= " @@ -197,6 +278,11 @@ public function getVersion() "; } + /** + * @param string $script + * + * @return void + */ protected function addEnforceVersioning(&$script) { $objectClass = $this->builder->getStubObjectBuilder()->getClassname(); @@ -215,6 +301,11 @@ public function enforceVersioning() "; } + /** + * @param string $script + * + * @return void + */ protected function addIsVersioningNecessary(&$script) { $queryClassName = $this->builder->getQueryClassName(); @@ -298,6 +389,11 @@ public function isVersioningNecessary(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addAddVersion(&$script) { $versionTable = $this->behavior->getVersionTable(); @@ -366,6 +462,11 @@ public function addVersion(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addToVersion(&$script) { $ARclassName = $this->getActiveRecordClassName(); @@ -391,6 +492,11 @@ public function toVersion(\$versionNumber, ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addPopulateFromVersion(&$script) { $ARclassName = $this->getActiveRecordClassName(); @@ -414,7 +520,8 @@ public function populateFromVersion(\$version, \$con = null, &\$loadedObjects = $script .= " \$loadedObjects['{$ARclassName}'][\$version->get{$primaryKeyName}()][\$version->get{$versionColumnName}()] = \$this;"; - foreach ($this->table->getColumns() as $col) { + $columns = $this->table->getColumns(); + foreach ($columns as $col) { $script .= " \$this->set" . $col->getPhpName() . "(\$version->get" . $col->getPhpName() . "());"; } @@ -492,6 +599,11 @@ public function populateFromVersion(\$version, \$con = null, &\$loadedObjects = "; } + /** + * @param string $script + * + * @return void + */ protected function addGetLastVersionNumber(&$script) { $script .= " @@ -517,6 +629,11 @@ public function getLastVersionNumber(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addIsLastVersion(&$script) { $script .= " @@ -534,6 +651,11 @@ public function isLastVersion(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addGetOneVersion(&$script) { $versionARClassName = $this->builder->getClassNameFromBuilder($this->builder->getNewStubObjectBuilder($this->behavior->getVersionTable())); @@ -556,6 +678,11 @@ public function getOneVersion(\$versionNumber, ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addGetAllVersions(&$script) { $versionTable = $this->behavior->getVersionTable(); @@ -583,6 +710,11 @@ public function getAllVersions(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addComputeDiff(&$script) { $script .= " @@ -649,6 +781,11 @@ protected function computeDiff(\$fromVersion, \$toVersion, \$keys = 'columns', \ "; } + /** + * @param string $script + * + * @return void + */ protected function addCompareVersion(&$script) { $script .= " @@ -679,6 +816,11 @@ public function compareVersion(\$versionNumber, \$keys = 'columns', ConnectionIn "; } + /** + * @param string $script + * + * @return void + */ protected function addCompareVersions(&$script) { $script .= " @@ -710,6 +852,11 @@ public function compareVersions(\$fromVersionNumber, \$toVersionNumber, \$keys = "; } + /** + * @param string $script + * + * @return void + */ protected function addGetLastVersions(&$script) { $plural = true; diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php index b8ab0cb4bb..2f641eadce 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php @@ -17,22 +17,39 @@ */ class VersionableBehaviorQueryBuilderModifier { + /** + * @var \Propel\Generator\Model\Behavior + */ protected $behavior; - + /** + * @var \Propel\Generator\Model\Table + */ protected $table; - + /** + * @var \Propel\Generator\Builder\Om\AbstractOMBuilder + */ protected $builder; - + /** + * @var string + */ protected $objectClassName; - + /** + * @var string + */ protected $queryClassName; + /** + * @param \Propel\Generator\Model\Behavior $behavior + */ public function __construct($behavior) { $this->behavior = $behavior; $this->table = $behavior->getTable(); } + /** + * @return string + */ public function queryAttributes() { return " @@ -43,26 +60,49 @@ public function queryAttributes() "; } + /** + * @param string $key + * + * @return array + */ protected function getParameter($key) { return $this->behavior->getParameter($key); } + /** + * @param string $name + * + * @return string + */ protected function getColumnAttribute($name = 'version_column') { return strtolower($this->behavior->getColumnForParameter($name)->getName()); } + /** + * @param string $name + * + * @return string + */ protected function getColumnPhpName($name = 'version_column') { return $this->behavior->getColumnForParameter($name)->getPhpName(); } + /** + * @return string + */ protected function getVersionQueryClassName() { return $this->builder->getClassNameFromBuilder($this->builder->getNewStubQueryBuilder($this->behavior->getVersionTable())); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return void + */ protected function setBuilder($builder) { $this->builder = $builder; @@ -90,6 +130,11 @@ protected function getColumnSetter($name = 'version_column') return 'set' . $this->getColumnPhpName($name); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function queryMethods($builder) { $this->setBuilder($builder); @@ -106,6 +151,11 @@ public function queryMethods($builder) return $script; } + /** + * @param string $script + * + * @return void + */ protected function addFilterByVersion(&$script) { $script .= " @@ -123,6 +173,11 @@ public function filterByVersion(\$version = null, \$comparison = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addOrderByVersion(&$script) { $script .= " @@ -139,6 +194,9 @@ public function orderByVersion(\$order = Criteria::ASC) "; } + /** + * @return string + */ protected function addIsVersioningEnabled() { return " @@ -154,6 +212,9 @@ static public function isVersioningEnabled() "; } + /** + * @return string + */ protected function addEnableVersioning() { return " @@ -167,6 +228,9 @@ static public function enableVersioning() "; } + /** + * @return string + */ protected function addDisableVersioning() { return " From c276b116f41ba8460fefb848f12cf6c0f2fb9faf Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 7 Jul 2020 15:35:54 +0200 Subject: [PATCH 063/208] Add baseline file. --- phpstan-baseline.neon | 222 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 phpstan-baseline.neon diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000000..ea9316dfb6 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,222 @@ +parameters: + ignoreErrors: + - + message: "#^Variable \\$paramsDoc might not be defined\\.$#" + count: 4 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php + + - + message: "#^Variable \\$methodSignature might not be defined\\.$#" + count: 10 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php + + - + message: "#^Variable \\$buildScope might not be defined\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php + + - + message: "#^Variable \\$col might not be defined\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addTemporalAccessor\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addObjectAccessor\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addArrayAccessor\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addHasArrayElement\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addJsonAccessor\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addEnumAccessor\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addSetAccessor\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addDefaultAccessor\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addBooleanAccessor\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addLazyLoader\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addObjectMutator\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addLobMutator\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addTemporalMutator\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addArrayMutator\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addAddArrayElement\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addRemoveArrayElement\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addJsonMutator\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addEnumMutator\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addSetMutator\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addBooleanMutator\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addDefaultMutator\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + + - + message: "#^Variable \\$mysqlInvalidDateString might not be defined\\.$#" + count: 2 + path: src/Propel/Generator/Builder/Om/ObjectBuilder.php + + - + message: "#^Variable \\$crossFK might not be defined\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/ObjectBuilder.php + + - + message: "#^Parameter \\$definition of method Propel\\\\Generator\\\\Command\\\\Console\\\\Input\\\\ArrayInput\\:\\:__construct\\(\\) has invalid typehint type Propel\\\\Generator\\\\Command\\\\Console\\\\Input\\\\InputDefinition\\.$#" + count: 1 + path: src/Propel/Generator/Command/Console/Input/ArrayInput.php + + - + message: "#^Variable \\$migration might not be defined\\.$#" + count: 1 + path: src/Propel/Generator/Command/MigrationMigrateCommand.php + + - + message: "#^Variable \\$countValidTimestamps might not be defined\\.$#" + count: 1 + path: src/Propel/Generator/Command/MigrationStatusCommand.php + + - + message: "#^Variable \\$defaultDatasource might not be defined\\.$#" + count: 1 + path: src/Propel/Generator/Config/ArrayToPhpConverter.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Manager\\\\AbstractManager\\:\\:getLocation\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Manager/AbstractManager.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\ForeignKey\\:\\:getLocalForeignMapping\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Model/ForeignKey.php + + - + message: "#^Variable \\$strDefault might not be defined\\.$#" + count: 1 + path: src/Propel/Generator/Reverse/PgsqlSchemaParser.php + + - + message: "#^Variable \\$fk might not be defined\\.$#" + count: 1 + path: src/Propel/Generator/Reverse/SqliteSchemaParser.php + + - + message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\BaseModelCriteria\\:\\:\\$useAliasInSQL\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php + + - + message: "#^Call to an undefined static method Propel\\\\Runtime\\\\ActiveQuery\\\\BaseModelCriteria\\:\\:getShortName\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\BaseModelCriteria\\:\\:find\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php + + - + message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:\\$currentAlias\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/Criteria.php + + - + message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:\\$foundMatch\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/Criteria.php + + - + message: "#^Variable \\$sql might not be defined\\.$#" + count: 3 + path: src/Propel/Runtime/ActiveQuery/Criteria.php + + - + message: "#^Variable \\$sql might not be defined\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + + - + message: "#^Variable \\$dbMap might not be defined\\.$#" + count: 1 + path: src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php + + - + message: "#^Variable \\$params might not be defined\\.$#" + count: 1 + path: src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php + From e975172b5f436f3ffab7141696ac90a5c0ddaf18 Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 7 Jul 2020 15:39:11 +0200 Subject: [PATCH 064/208] Add missing meta files. --- .editorconfig | 13 +++++++++++++ .gitattributes | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..a11af767c6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at https://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.bat] +end_of_line = crlf diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..ad4d8326b8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,32 @@ +# Define the line ending behavior of the different file extensions +# Set the default behavior, in case people don't have core.autocrlf set. +* text text=auto eol=lf + +# Declare files that will always have CRLF line endings on checkout. +*.bat eol=crlf + +# Denote all files that are truly binary and should not be modified. +*.png binary +*.jpg binary +*.gif binary +*.jpeg binary +*.zip binary +*.phar binary +*.ttf binary +*.woff binary +*.eot binary +*.ico binary +*.mo binary +*.pdf binary +*.xcf binary +*.eps binary +*.psd binary +*.doc binary + +# Remove files for archives generated using `git archive` +phpstan.neon export-ignore +phpstan-baseline.neon export-ignore linguist-generated=true +.travis.yml export-ignore +.editorconfig export-ignore +.gitattributes export-ignore +.gitignore export-ignore From 4093a26ff5663bd18320ceea4e6ee6bc87672f59 Mon Sep 17 00:00:00 2001 From: Marcus Pettersen Irgens Date: Wed, 25 Apr 2018 14:59:53 +0200 Subject: [PATCH 065/208] Allow option MYSQL_ATTR_SSL_VERIFY_SERVER_CERT to be set This was implemented in early 2017 (see 247ce052cd0fc7d0d8ea1a0e7ea2075e9601766a), and is very useful for self-signed certificates. --- src/Propel/Common/Config/PropelConfiguration.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Propel/Common/Config/PropelConfiguration.php b/src/Propel/Common/Config/PropelConfiguration.php index 86d419c69a..4ab8048f6d 100644 --- a/src/Propel/Common/Config/PropelConfiguration.php +++ b/src/Propel/Common/Config/PropelConfiguration.php @@ -130,6 +130,7 @@ protected function addDatabaseSection(ArrayNodeDefinition $node) ->scalarNode('MYSQL_ATTR_SSL_CA')->end() ->scalarNode('MYSQL_ATTR_SSL_CERT')->end() ->scalarNode('MYSQL_ATTR_SSL_KEY')->end() + ->booleanNode('MYSQL_ATTR_SSL_VERIFY_SERVER_CERT')->end() ->scalarNode('MYSQL_ATTR_MAX_BUFFER_SIZE')->end() ->end() ->end() From 9dc7bd0ff442c798a8979b582692eae7b477a585 Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 7 Jul 2020 17:59:38 +0200 Subject: [PATCH 066/208] Prepare for phpstan level 2. --- .../Common/Config/ConfigurationManager.php | 2 +- src/Propel/Common/Config/FileLocator.php | 4 +- .../Common/Config/Loader/FileLoader.php | 6 +- .../AggregateColumnBehavior.php | 11 +- .../AggregateColumnRelationBehavior.php | 82 +++++ .../Archivable/ArchivableBehavior.php | 4 +- ...rchivableBehaviorObjectBuilderModifier.php | 46 ++- ...ArchivableBehaviorQueryBuilderModifier.php | 42 +++ .../SortableBehaviorObjectBuilderModifier.php | 84 ++++- .../SortableBehaviorQueryBuilderModifier.php | 123 ++++++- ...ortableBehaviorTableMapBuilderModifier.php | 25 +- ...rsionableBehaviorObjectBuilderModifier.php | 4 +- ...ersionableBehaviorQueryBuilderModifier.php | 2 +- .../Builder/Om/AbstractOMBuilder.php | 16 +- .../Builder/Om/AbstractObjectBuilder.php | 6 +- .../Builder/Om/ExtensionObjectBuilder.php | 4 +- .../Builder/Om/ExtensionQueryBuilder.php | 6 +- .../Generator/Builder/Om/InterfaceBuilder.php | 4 +- .../Builder/Om/MultiExtendObjectBuilder.php | 6 +- .../Generator/Builder/Om/ObjectBuilder.php | 334 +++++++++--------- .../Generator/Builder/Om/QueryBuilder.php | 86 ++--- .../Builder/Om/QueryInheritanceBuilder.php | 10 +- .../Generator/Builder/Om/TableMapBuilder.php | 56 +-- src/Propel/Generator/Builder/Util/DataRow.php | 5 +- .../Generator/Command/AbstractCommand.php | 4 +- .../Command/Helper/ConsoleHelperInterface.php | 2 +- .../Generator/Command/TestPrepareCommand.php | 4 +- .../Generator/Manager/AbstractManager.php | 18 +- .../Generator/Manager/MigrationManager.php | 4 +- .../Generator/Manager/ReverseManager.php | 2 +- src/Propel/Generator/Model/Behavior.php | 7 +- .../Generator/Model/BehaviorableTrait.php | 4 +- src/Propel/Generator/Model/Column.php | 19 +- .../Generator/Model/CrossForeignKeys.php | 4 +- src/Propel/Generator/Model/Database.php | 6 +- .../Model/Diff/DatabaseComparator.php | 8 +- .../Generator/Model/Diff/DatabaseDiff.php | 29 +- .../Generator/Model/Diff/TableComparator.php | 4 +- src/Propel/Generator/Model/Diff/TableDiff.php | 30 +- src/Propel/Generator/Model/Domain.php | 1 + src/Propel/Generator/Model/ForeignKey.php | 2 +- .../Generator/Model/IdMethodParameter.php | 20 +- src/Propel/Generator/Model/Index.php | 2 +- src/Propel/Generator/Model/MappingModel.php | 8 +- src/Propel/Generator/Model/Table.php | 23 +- .../Generator/Platform/DefaultPlatform.php | 18 +- .../Generator/Platform/MssqlPlatform.php | 31 +- .../Generator/Platform/MysqlPlatform.php | 6 +- .../Generator/Platform/OraclePlatform.php | 14 +- .../Generator/Platform/PgsqlPlatform.php | 8 +- .../Generator/Platform/PlatformInterface.php | 4 +- .../Generator/Platform/SqlitePlatform.php | 2 +- .../Generator/Platform/SqlsrvPlatform.php | 2 + .../Generator/Reverse/MysqlSchemaParser.php | 6 +- .../Generator/Reverse/OracleSchemaParser.php | 10 +- .../Generator/Reverse/PgsqlSchemaParser.php | 5 +- .../Generator/Reverse/SqliteSchemaParser.php | 6 +- .../Generator/Schema/Dumper/XmlDumper.php | 11 +- .../Runtime/ActiveQuery/BaseModelCriteria.php | 2 +- src/Propel/Runtime/ActiveQuery/Criteria.php | 16 +- .../Criterion/AbstractCriterion.php | 4 +- .../ActiveQuery/Criterion/BasicCriterion.php | 2 +- .../Criterion/BasicModelCriterion.php | 2 +- .../ActiveQuery/Criterion/BinaryCriterion.php | 2 +- .../Criterion/BinaryModelCriterion.php | 4 +- .../ActiveQuery/Criterion/CustomCriterion.php | 2 +- .../ActiveQuery/Criterion/InCriterion.php | 2 +- .../Criterion/InModelCriterion.php | 2 +- .../ActiveQuery/Criterion/LikeCriterion.php | 2 +- .../Criterion/LikeModelCriterion.php | 2 +- .../ActiveQuery/Criterion/RawCriterion.php | 2 +- .../Criterion/RawModelCriterion.php | 2 +- .../Criterion/SeveralModelCriterion.php | 2 +- src/Propel/Runtime/ActiveQuery/Join.php | 2 +- .../Runtime/ActiveQuery/ModelCriteria.php | 6 +- .../Runtime/ActiveQuery/PropelQuery.php | 2 +- .../Runtime/Adapter/Pdo/OracleAdapter.php | 2 +- src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php | 7 +- .../Runtime/Collection/ArrayCollection.php | 2 +- .../Runtime/Collection/ObjectCollection.php | 16 +- .../ObjectCombinationCollection.php | 2 +- .../Runtime/Collection/OnDemandCollection.php | 2 +- .../Connection/ConnectionInterface.php | 6 +- .../Runtime/Connection/ConnectionWrapper.php | 5 +- .../Connection/ProfilerConnectionWrapper.php | 5 +- .../Runtime/Formatter/AbstractFormatter.php | 2 +- src/Propel/Runtime/Map/ColumnMap.php | 4 +- src/Propel/Runtime/Map/RelationMap.php | 4 +- src/Propel/Runtime/Parser/CsvParser.php | 2 + src/Propel/Runtime/Parser/XmlParser.php | 1 + src/Propel/Runtime/Propel.php | 27 +- .../StandardServiceContainer.php | 2 +- 92 files changed, 978 insertions(+), 461 deletions(-) diff --git a/src/Propel/Common/Config/ConfigurationManager.php b/src/Propel/Common/Config/ConfigurationManager.php index 2dd6aa0384..0e1b5be261 100644 --- a/src/Propel/Common/Config/ConfigurationManager.php +++ b/src/Propel/Common/Config/ConfigurationManager.php @@ -234,7 +234,7 @@ private function getFiles($dirs, $fileName, $dist = false) * @param string $fileName The configuration file * * @return array|mixed - * @throws \Symfony\Component\Config\Exception\FileLoaderLoadException + * @throws \Symfony\Component\Config\Exception\LoaderLoadException */ private function loadFile($fileName) { diff --git a/src/Propel/Common/Config/FileLocator.php b/src/Propel/Common/Config/FileLocator.php index ae7e22e83f..ba840e2de8 100644 --- a/src/Propel/Common/Config/FileLocator.php +++ b/src/Propel/Common/Config/FileLocator.php @@ -20,12 +20,10 @@ class FileLocator extends BaseFileLocator { /** - * Constructor - * * By default, the locator looks for configuration file in the current directory (where bin/propel script is running) * or in a 'conf' or 'config' subdirectory. * - * @param null array $configDirectories The directories list where to look for configuration file(s) + * @param string|string[]|null $configDirectories The directories list where to look for configuration file(s) */ public function __construct($configDirectories = null) { diff --git a/src/Propel/Common/Config/Loader/FileLoader.php b/src/Propel/Common/Config/Loader/FileLoader.php index 9d65882e49..bd764e3ca9 100644 --- a/src/Propel/Common/Config/Loader/FileLoader.php +++ b/src/Propel/Common/Config/Loader/FileLoader.php @@ -104,8 +104,8 @@ protected function getPath($file) /** * Check if a resource has a given extension * - * @param $ext mixed An extension or an arrayof extensions - * @param $resource string A resource + * @param string|string[] $ext An extension or an array of extensions + * @param string|false $resource A resource */ protected function checkSupports($ext, $resource) { @@ -284,7 +284,7 @@ private function get($property_key) * * @return mixed The value or null if not found */ - private function getValue($property_key, $config = null, &$found) + private function getValue($property_key, $config, &$found) { if (null === $config) { $config = $this->config; diff --git a/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php b/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php index f48568f588..4f203b8d84 100644 --- a/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php +++ b/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php @@ -42,6 +42,8 @@ public function allowMultiple() /** * Add the aggregate key to the current table + * + * @return void */ public function modifyTable() { @@ -72,6 +74,13 @@ public function modifyTable() } } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @throws \InvalidArgumentException + * + * @return string + */ public function objectMethods(ObjectBuilder $builder) { if (!$this->getParameter('foreign_table')) { @@ -103,7 +112,7 @@ protected function addObjectCompute(ObjectBuilder $builder) } foreach ($this->getForeignKey()->getMapping() as $index => $mapping) { - list($localColumn, $foreignColumn) = $mapping; + [$localColumn, $foreignColumn] = $mapping; $conditions[] = $localColumn->getFullyQualifiedName() . ' = :p' . ($index + 1); $bindings[$index + 1] = $foreignColumn->getPhpName(); } diff --git a/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnRelationBehavior.php b/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnRelationBehavior.php index 39ebfdae8c..d7d85fe785 100644 --- a/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnRelationBehavior.php +++ b/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnRelationBehavior.php @@ -31,6 +31,11 @@ public function allowMultiple() return true; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function postSave($builder) { $relationName = $this->getRelationName($builder); @@ -42,6 +47,11 @@ public function postSave($builder) // no need for a postDelete() hook, since delete() uses Query::delete(), // which already has a hook + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function objectAttributes($builder) { $relationName = $this->getRelationName($builder); @@ -55,11 +65,21 @@ public function objectAttributes($builder) "; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function objectMethods($builder) { return $this->addObjectUpdateRelated($builder); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ protected function addObjectUpdateRelated($builder) { $relationName = $this->getRelationName($builder); @@ -72,6 +92,12 @@ protected function addObjectUpdateRelated($builder) ]); } + /** + * @param string $script + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return void + */ public function objectFilter(&$script, $builder) { $relationName = $this->getRelationName($builder); @@ -87,16 +113,31 @@ public function objectFilter(&$script, $builder) $script = str_replace($search, $replace, $script); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function preUpdateQuery($builder) { return $this->getFindRelated($builder); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function preDeleteQuery($builder) { return $this->getFindRelated($builder); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ protected function getFindRelated($builder) { $relationName = $this->getRelationName($builder); @@ -105,16 +146,31 @@ protected function getFindRelated($builder) return "\$this->findRelated{$relationName}{$aggregateName}s(\$con);"; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function postUpdateQuery($builder) { return $this->getUpdateRelated($builder); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function postDeleteQuery($builder) { return $this->getUpdateRelated($builder); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ protected function getUpdateRelated($builder) { $relationName = $this->getRelationName($builder); @@ -123,6 +179,11 @@ protected function getUpdateRelated($builder) return "\$this->updateRelated{$relationName}{$aggregateName}s(\$con);"; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function queryMethods($builder) { $script = ''; @@ -133,6 +194,11 @@ public function queryMethods($builder) return $script; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ protected function addQueryFindRelated($builder) { $foreignKey = $this->getForeignKey(); @@ -154,6 +220,11 @@ protected function addQueryFindRelated($builder) ]); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ protected function addQueryUpdateRelated($builder) { $relationName = $this->getRelationName($builder); @@ -166,11 +237,17 @@ protected function addQueryUpdateRelated($builder) ]); } + /** + * @return \Propel\Generator\Model\Table|null + */ protected function getForeignTable() { return $this->getTable()->getDatabase()->getTable($this->getParameter('foreign_table')); } + /** + * @return \Propel\Generator\Model\ForeignKey + */ protected function getForeignKey() { $foreignTable = $this->getForeignTable(); @@ -180,6 +257,11 @@ protected function getForeignKey() return array_shift($fks); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ protected function getRelationName($builder) { return $builder->getFKPhpNameAffix($this->getForeignKey()); diff --git a/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php b/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php index a3bbeec2c8..7177add6ef 100644 --- a/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php +++ b/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php @@ -161,13 +161,15 @@ public function hasArchiveClass() } /** - * @return Column + * @return Column|null */ public function getArchivedAtColumn() { if ($this->getArchiveTable() && 'true' === $this->getParameter('log_archived_at')) { return $this->getArchiveTable()->getColumn($this->getParameter('archived_at_column')); } + + return null; } public function isArchiveOnInsert() diff --git a/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php index b03899a66e..2de4825393 100644 --- a/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php @@ -17,22 +17,43 @@ */ class ArchivableBehaviorObjectBuilderModifier { + /** + * @var \Propel\Generator\Model\Behavior + */ protected $behavior; + + /** + * @var \Propel\Generator\Model\Table + */ protected $table; + + /** + * @var \Propel\Generator\Builder\Om\AbstractOMBuilder + */ protected $builder; + /** + * @param \Propel\Generator\Model\Behavior $behavior + */ public function __construct($behavior) { $this->behavior = $behavior; $this->table = $behavior->getTable(); } + /** + * @param string $key + * + * @return mixed + */ protected function getParameter($key) { return $this->behavior->getParameter($key); } /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string the PHP code to be added to the builder */ public function objectAttributes($builder) @@ -55,7 +76,9 @@ public function objectAttributes($builder) } /** - * @return string the PHP code to be added to the builder + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string|null the PHP code to be added to the builder */ public function postInsert($builder) { @@ -69,7 +92,9 @@ public function postInsert($builder) } /** - * @return string the PHP code to be added to the builder + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string|null the PHP code to be added to the builder */ public function postUpdate($builder) { @@ -89,7 +114,9 @@ public function postUpdate($builder) * The actual deletion is made by the query object, so the AR class must tell * the query class to enable or disable archiveOnDelete. * - * @return string the PHP code to be added to the builder + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string|null the PHP code to be added to the builder */ public function preDelete($builder) { @@ -102,6 +129,8 @@ public function preDelete($builder) } /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string the PHP code to be added to the builder */ public function objectMethods($builder) @@ -123,6 +152,8 @@ public function objectMethods($builder) } /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string the PHP code to be added to the builder */ public function addGetArchive($builder) @@ -134,6 +165,8 @@ public function addGetArchive($builder) } /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string the PHP code to be added to the builder */ public function addArchive($builder) @@ -147,6 +180,7 @@ public function addArchive($builder) } /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder * * @return string the PHP code to be added to the builder */ @@ -162,6 +196,8 @@ public function addRestoreFromArchive($builder) * This method is necessary because the archive's copyInto() may include the archived_at column * and therefore cannot be used. Besides, the way autoincremented PKs are handled should be explicit. * + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string the PHP code to be added to the builder */ public function addPopulateFromArchive($builder) @@ -175,6 +211,8 @@ public function addPopulateFromArchive($builder) } /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string the PHP code to be added to the builder */ public function addSaveWithoutArchive($builder) @@ -187,6 +225,8 @@ public function addSaveWithoutArchive($builder) } /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string the PHP code to be added to the builder */ public function addDeleteWithoutArchive($builder) diff --git a/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php index d1b3bf3b4f..5e213c17d3 100644 --- a/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php @@ -17,20 +17,40 @@ */ class ArchivableBehaviorQueryBuilderModifier { + /** + * @var \Propel\Generator\Model\Behavior + */ protected $behavior; + + /** + * @var \Propel\Generator\Model\Table + */ protected $table; + /** + * @param \Propel\Generator\Model\Behavior $behavior + */ public function __construct($behavior) { $this->behavior = $behavior; $this->table = $behavior->getTable(); } + /** + * @param string $key + * + * @return mixed + */ protected function getParameter($key) { return $this->behavior->getParameter($key); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function queryAttributes($builder) { $script = ''; @@ -46,6 +66,11 @@ public function queryAttributes($builder) return $script; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string|null + */ public function preDeleteQuery($builder) { if ($this->behavior->isArchiveOnDelete()) { @@ -59,6 +84,11 @@ public function preDeleteQuery($builder) } } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string|null + */ public function postUpdateQuery($builder) { if ($this->behavior->isArchiveOnUpdate()) { @@ -73,6 +103,8 @@ public function postUpdateQuery($builder) } /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string the PHP code to be added to the builder */ public function queryMethods($builder) @@ -92,6 +124,8 @@ public function queryMethods($builder) } /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string the PHP code to be added to the builder */ protected function addArchive($builder) @@ -103,6 +137,8 @@ protected function addArchive($builder) } /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string the PHP code to be added to the builder */ public function addSetArchiveOnUpdate($builder) @@ -111,6 +147,8 @@ public function addSetArchiveOnUpdate($builder) } /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string the PHP code to be added to the builder */ public function addUpdateWithoutArchive($builder) @@ -119,6 +157,8 @@ public function addUpdateWithoutArchive($builder) } /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string the PHP code to be added to the builder */ public function addSetArchiveOnDelete($builder) @@ -127,6 +167,8 @@ public function addSetArchiveOnDelete($builder) } /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string the PHP code to be added to the builder */ public function addDeleteWithoutArchive($builder) diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php index 9df8d16d71..16fc1d11ce 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php @@ -23,17 +23,17 @@ class SortableBehaviorObjectBuilderModifier { /** - * @var SortableBehavior + * @var \Propel\Generator\Model\Behavior */ protected $behavior; /** - * @var Table + * @var \Propel\Generator\Model\Table */ protected $table; /** - * @var AbstractOMBuilder + * @var \Propel\Generator\Builder\Om\AbstractOMBuilder */ protected $builder; @@ -250,7 +250,7 @@ public function objectFilter(&$script, $builder) /** * Get the wraps for getter/setter, if the rank column has not the default name * - * @return string + * @return void */ protected function addRankAccessors(&$script) { @@ -281,7 +281,7 @@ public function setRank(\$v) /** * Get the wraps for getter/setter, if the scope column has not the default name * - * @return string + * @return void */ protected function addScopeAccessors(&$script) { @@ -368,6 +368,11 @@ public function setScopeValue(\$v) "; } + /** + * @param string $script + * + * @return void + */ protected function addIsFirst(&$script) { $script .= " @@ -383,6 +388,11 @@ public function isFirst() "; } + /** + * @param string $script + * + * @return void + */ protected function addIsLast(&$script) { $useScope = $this->behavior->useScope(); @@ -401,12 +411,17 @@ public function isLast(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addGetNext(&$script) { $useScope = $this->behavior->useScope(); // The generateScopePhp() method below contains the following list of variables: // list($methodSignature, $paramsDoc, $buildScope, $buildScopeVars) - list($methodSignature, , , $buildScopeVars) = $this->behavior->generateScopePhp(); + [$methodSignature, , , $buildScopeVars] = $this->behavior->generateScopePhp(); $script .= " /** @@ -445,13 +460,18 @@ public function getNext(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addGetPrevious(&$script) { $useScope = $this->behavior->useScope(); // The generateScopePhp() method below contains the following list of variables: // list($methodSignature, $paramsDoc, $buildScope, $buildScopeVars) - list($methodSignature, , , $buildScopeVars) = $this->behavior->generateScopePhp(); + [$methodSignature, , , $buildScopeVars] = $this->behavior->generateScopePhp(); $script .= " /** @@ -490,6 +510,11 @@ public function getPrevious(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addInsertAtRank(&$script) { $useScope = $this->behavior->useScope(); @@ -528,6 +553,11 @@ public function insertAtRank(\$rank, ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addInsertAtBottom(&$script) { $useScope = $this->behavior->useScope(); @@ -552,6 +582,11 @@ public function insertAtBottom(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addInsertAtTop(&$script) { $script .= " @@ -615,6 +650,11 @@ public function moveToRank(\$newRank, ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addSwapWith(&$script) { $script .= " @@ -660,6 +700,11 @@ public function swapWith(\$object, ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addMoveUp(&$script) { $script .= " @@ -688,6 +733,11 @@ public function moveUp(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addMoveDown(&$script) { $script .= " @@ -716,6 +766,11 @@ public function moveDown(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addMoveToTop(&$script) { $script .= " @@ -737,6 +792,11 @@ public function moveToTop(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addMoveToBottom(&$script) { $useScope = $this->behavior->useScope(); @@ -766,6 +826,11 @@ public function moveToBottom(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addRemoveFromList(&$script) { $useScope = $this->behavior->useScope(); @@ -806,6 +871,11 @@ public function removeFromList() "; } + /** + * @param string $script + * + * @return void + */ protected function addProcessSortableQueries(&$script) { $script .= " diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php index 604aa0fea3..749ad19cfb 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php @@ -19,34 +19,64 @@ */ class SortableBehaviorQueryBuilderModifier { + /** + * @var \Propel\Generator\Model\Behavior + */ protected $behavior; + /** + * @var \Propel\Generator\Model\Table + */ protected $table; + /** + * @var \Propel\Generator\Builder\Om\AbstractOMBuilder + */ protected $builder; + /** + * @var string + */ protected $objectClassName; protected $queryClassName; protected $tableMapClassName; + /** + * @param \Propel\Generator\Model\Behavior $behavior + */ public function __construct($behavior) { $this->behavior = $behavior; $this->table = $behavior->getTable(); } + /** + * @param string $key + * + * @return mixed + */ protected function getParameter($key) { return $this->behavior->getParameter($key); } + /** + * @param string $name + * + * @return \Propel\Generator\Model\Column + */ protected function getColumn($name) { return $this->behavior->getColumnForParameter($name); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return void + */ protected function setBuilder($builder) { $this->builder = $builder; @@ -55,9 +85,13 @@ protected function setBuilder($builder) $this->tableMapClassName = $builder->getTableMapClassName(); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function queryMethods($builder) { - $this->setBuilder($builder); $this->builder->declareClasses( '\Propel\Runtime\Propel', @@ -98,6 +132,11 @@ public function queryMethods($builder) return $script; } + /** + * @param string $script + * + * @return void + */ public function addSortableApplyScopeCriteria(&$script) { $script .= " @@ -127,12 +166,16 @@ static public function sortableApplyScopeCriteria(Criteria \$criteria, \$scope, $script .= " } "; - } + /** + * @param string $script + * + * @return void + */ protected function addInList(&$script) { - list($methodSignature, $paramsDoc, $buildScope) = $this->behavior->generateScopePhp(); + [$methodSignature, $paramsDoc, $buildScope] = $this->behavior->generateScopePhp(); $script .= " /** * Returns the objects in a certain list, from the list scope @@ -151,11 +194,16 @@ public function inList($methodSignature) "; } + /** + * @param string $script + * + * @return void + */ protected function addFilterByRank(&$script) { $useScope = $this->behavior->useScope(); if ($useScope) { - list($methodSignature, $paramsDoc) = $this->behavior->generateScopePhp(); + [$methodSignature, $paramsDoc] = $this->behavior->generateScopePhp(); } $script .= " @@ -192,6 +240,11 @@ public function filterByRank(\$rank" . ($useScope ? ", $methodSignature" : "") . "; } + /** + * @param string $script + * + * @return void + */ protected function addOrderByRank(&$script) { $script .= " @@ -220,11 +273,16 @@ public function orderByRank(\$order = Criteria::ASC) "; } + /** + * @param string $script + * + * @return void + */ protected function addFindOneByRank(&$script) { $useScope = $this->behavior->useScope(); if ($useScope) { - list($methodSignature, $paramsDoc, ) = $this->behavior->generateScopePhp(); + [$methodSignature, $paramsDoc, ] = $this->behavior->generateScopePhp(); } $script .= " @@ -256,11 +314,16 @@ public function findOneByRank(\$rank, " . ($useScope ? "$methodSignature, " : "" "; } + /** + * @param string $script + * + * @return void + */ protected function addFindList(&$script) { $useScope = $this->behavior->useScope(); if ($useScope) { - list($methodSignature, $paramsDoc) = $this->behavior->generateScopePhp(); + [$methodSignature, $paramsDoc] = $this->behavior->generateScopePhp(); } $script .= " @@ -300,11 +363,16 @@ public function findList(" . ($useScope ? "$methodSignature, " : "") . "\$con = "; } + /** + * @param string $script + * + * @return void + */ protected function addGetMaxRank(&$script) { $useScope = $this->behavior->useScope(); if ($useScope) { - list($methodSignature, $paramsDoc, $buildScope) = $this->behavior->generateScopePhp(); + [$methodSignature, $paramsDoc, $buildScope] = $this->behavior->generateScopePhp(); } $script .= " @@ -340,6 +408,11 @@ public function getMaxRank(" . ($useScope ? "$methodSignature, " : "") . "Connec "; } + /** + * @param string $script + * + * @return void + */ protected function addGetMaxRankArray(&$script) { $useScope = $this->behavior->useScope(); @@ -377,6 +450,11 @@ public function getMaxRankArray(" . ($useScope ? "\$scope, " : "") . "Connection "; } + /** + * @param string $script + * + * @return void + */ protected function addReorder(&$script) { $columnGetter = 'get' . $this->behavior->getColumnForParameter('rank_column')->getPhpName(); @@ -415,6 +493,11 @@ public function reorder(\$order, ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addRetrieveByRank(&$script) { $useScope = $this->behavior->useScope(); @@ -451,6 +534,11 @@ static public function retrieveByRank(\$rank, " . ($useScope ? "\$scope = null, "; } + /** + * @param string $script + * + * @return void + */ protected function addDoSelectOrderByRank(&$script) { $queryClassName = $this->queryClassName; @@ -489,6 +577,11 @@ static public function doSelectOrderByRank(Criteria \$criteria = null, \$order = "; } + /** + * @param string $script + * + * @return void + */ protected function addRetrieveList(&$script) { $script .= " @@ -511,6 +604,11 @@ static public function retrieveList(\$scope, \$order = Criteria::ASC, Connection "; } + /** + * @param string $script + * + * @return void + */ protected function addCountList(&$script) { $script .= " @@ -532,6 +630,11 @@ static public function countList(\$scope, ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addDeleteList(&$script) { $script .= " @@ -552,6 +655,12 @@ static public function deleteList(\$scope, ConnectionInterface \$con = null) } "; } + + /** + * @param string $script + * + * @return void + */ protected function addShiftRank(&$script) { $useScope = $this->behavior->useScope(); diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php index 1a178678b3..ebd1022ace 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php @@ -18,18 +18,29 @@ class SortableBehaviorTableMapBuilderModifier { /** - * @var SortableBehavior + * @var \Propel\Generator\Model\Behavior */ protected $behavior; + /** + * @var \Propel\Generator\Model\Table + */ protected $table; + /** + * @param \Propel\Generator\Model\Behavior $behavior + */ public function __construct($behavior) { $this->behavior = $behavior; $this->table = $behavior->getTable(); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function staticAttributes($builder) { $tableName = $this->table->getName(); @@ -38,12 +49,11 @@ public function staticAttributes($builder) if ($this->behavior->useScope()) { if ($this->behavior->hasMultipleScopes()) { - $col = []; - + $columns = []; foreach ($this->behavior->getScopes() as $scope) { - $col[] = "$tableName.".strtoupper($scope); + $columns[] = "$tableName.".strtoupper($scope); } - $col = json_encode($col); + $col = json_encode($columns); $col = "'$col'"; } else { $colNames = $this->getColumnConstant('scope_column'); @@ -60,6 +70,11 @@ public function staticAttributes($builder) ]); } + /** + * @param string $name + * + * @return string + */ protected function getColumnConstant($name) { return $this->behavior->getColumnForParameter($name)->getName(); diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php index fee6261e67..bcdcd5a028 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php @@ -49,7 +49,7 @@ public function __construct($behavior) /** * @param string $key * - * @return array + * @return mixed */ protected function getParameter($key) { @@ -162,7 +162,7 @@ public function postSave($builder) /** * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder * - * @return string + * @return string|null */ public function postDelete($builder) { diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php index 2f641eadce..e5fe4b3931 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php @@ -63,7 +63,7 @@ public function queryAttributes() /** * @param string $key * - * @return array + * @return mixed */ protected function getParameter($key) { diff --git a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php index 4d3d27ab55..8179de9dd3 100644 --- a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php @@ -457,7 +457,7 @@ public function getDeclaredClasses($namespace = null) /** * return the string for the class namespace * - * @return string + * @return string|null */ public function getNamespaceStatement() { @@ -467,6 +467,8 @@ public function getNamespaceStatement() ", $namespace); } + + return null; } /** @@ -943,7 +945,7 @@ public function hasBehaviorModifier($hookName, $modifier) * Checks whether any registered behavior on that table has a modifier for a hook * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string $modifier The name of the modifier object providing the method in the behavior - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ public function applyBehaviorModifierBase($hookName, $modifier, &$script, $tab = " ") { @@ -1023,8 +1025,8 @@ public function getTableMapClass() /** * Most of the code comes from the PHP-CS-Fixer project * - * @param $content - * @return mixed + * @param string $content + * @return string */ private function clean($content) { @@ -1066,7 +1068,7 @@ private function clean($content) /** * Opens class. * - * @param string &$script + * @param string $script */ abstract protected function addClassOpen(&$script); @@ -1078,14 +1080,14 @@ abstract protected function addClassOpen(&$script); * Hint: Override this method in your subclass if you want to reorganize or * drastically change the contents of the generated object class. * - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ abstract protected function addClassBody(&$script); /** * Closes class. * - * @param string &$script + * @param string $script */ abstract protected function addClassClose(&$script); } diff --git a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php index b704a1d9f6..84a5e1a0d0 100644 --- a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php @@ -27,7 +27,7 @@ abstract class AbstractObjectBuilder extends AbstractOMBuilder * Adds the getter methods for the column values. * This is here because it is probably generic enough to apply to templates being generated * in different languages (e.g. PHP4 and PHP5). - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addColumnAccessorMethods(&$script) { @@ -74,7 +74,7 @@ protected function addColumnAccessorMethods(&$script) * Adds the mutator (setter) methods for setting column values. * This is here because it is probably generic enough to apply to templates being generated * in different languages (e.g. PHP4 and PHP5). - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addColumnMutatorMethods(&$script) { @@ -182,7 +182,7 @@ public function hasBehaviorModifier($hookName, $modifier = null) /** * Checks whether any registered behavior on that table has a modifier for a hook * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param string $tab */ public function applyBehaviorModifier($hookName, &$script, $tab = " ") diff --git a/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php index 733d0b9357..4a8599e242 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php @@ -32,7 +32,7 @@ public function getUnprefixedClassName() /** * Adds class phpdoc comment and opening of class. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addClassOpen(&$script) { @@ -81,7 +81,7 @@ protected function addClassBody(&$script) /** * Closes class. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addClassClose(&$script) { diff --git a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php index 5edf396ddd..c6abf3166a 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php @@ -32,7 +32,7 @@ public function getUnprefixedClassName() /** * Adds class phpdoc comment and opening of class. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addClassOpen(&$script) { @@ -83,7 +83,7 @@ protected function addClassBody(&$script) /** * Closes class. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addClassClose(&$script) { @@ -106,7 +106,7 @@ public function hasBehaviorModifier($hookName, $modifier = null) /** * Checks whether any registered behavior on that table has a modifier for a hook * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param string $tab */ public function applyBehaviorModifier($hookName, &$script, $tab = " ") diff --git a/src/Propel/Generator/Builder/Om/InterfaceBuilder.php b/src/Propel/Generator/Builder/Om/InterfaceBuilder.php index b1b53025ff..9cfe665ea8 100644 --- a/src/Propel/Generator/Builder/Om/InterfaceBuilder.php +++ b/src/Propel/Generator/Builder/Om/InterfaceBuilder.php @@ -33,7 +33,7 @@ public function getUnprefixedClassName() /** * Adds class phpdoc comment and opening of class. * - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addClassOpen(&$script) { @@ -80,7 +80,7 @@ protected function addClassBody(&$script) /** * Closes class. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addClassClose(&$script) { diff --git a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php index 2ff800e74b..ba7e533e84 100644 --- a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php @@ -103,7 +103,7 @@ protected function getParentClassName() /** * Adds class phpdoc comment and opening of class. * - * @param string &$script + * @param string $script */ protected function addClassOpen(&$script) { @@ -155,7 +155,7 @@ class ".$this->getUnqualifiedClassName()." extends ".$this->getParentClassName() * By default there are no methods for the empty stub classes; override this * method if you want to change that behavior. * - * @param string &$script + * @param string $script * @see ObjectBuilder::addClassBody() */ protected function addClassBody(&$script) @@ -182,7 +182,7 @@ public function __construct() /** * Closes class. * - * @param string &$script + * @param string $script */ protected function addClassClose(&$script) { diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index b844ef4f06..823609cb56 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -206,7 +206,7 @@ protected function getDefaultValueString(Column $column) /** * Adds class phpdoc comment and opening of class. * - * @param string &$script + * @param string $script */ protected function addClassOpen(&$script) { @@ -259,7 +259,7 @@ abstract class ".$this->getUnqualifiedClassName().$parentClass." implements Acti * Specifies the methods that are added as part of the basic OM class. * This can be overridden by subclasses that wish to add more methods. * - * @param string &$script + * @param string $script * @see ObjectBuilder::addClassBody() */ protected function addClassBody(&$script) @@ -372,7 +372,7 @@ protected function addClassBody(&$script) /** * Closes class. * - * @param string &$script + * @param string $script */ protected function addClassClose(&$script) { @@ -385,7 +385,7 @@ protected function addClassClose(&$script) /** * Adds any constants to the class. * - * @param string &$script + * @param string $script */ protected function addConstants(&$script) { @@ -400,7 +400,7 @@ protected function addConstants(&$script) /** * Adds class attributes. * - * @param string &$script + * @param string $script */ protected function addAttributes(&$script) { @@ -437,7 +437,7 @@ protected function addAttributes(&$script) /** * Adds variables that store column values. * - * @param string &$script + * @param string $script */ protected function addColumnAttributes(&$script) { @@ -464,7 +464,7 @@ protected function addColumnAttributes(&$script) /** * Adds comment about the attribute (variable) that stores column values. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addColumnAttributeComment(&$script, Column $column) @@ -497,7 +497,7 @@ protected function addColumnAttributeComment(&$script, Column $column) /** * Adds the declaration of a column value storage attribute. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addColumnAttributeDeclaration(&$script, Column $column) @@ -512,7 +512,7 @@ protected function addColumnAttributeDeclaration(&$script, Column $column) * Adds the comment about the attribute keeping track if an attribute value * has been loaded. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addColumnAttributeLoaderComment(&$script, Column $column) @@ -530,7 +530,7 @@ protected function addColumnAttributeLoaderComment(&$script, Column $column) * Adds the declaration of the attribute keeping track of an attribute * loaded state. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addColumnAttributeLoaderDeclaration(&$script, Column $column) @@ -544,7 +544,7 @@ protected function addColumnAttributeLoaderDeclaration(&$script, Column $column) /** * Adds the comment about the serialized attribute. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addColumnAttributeUnserializedComment(&$script, Column $column) @@ -561,7 +561,7 @@ protected function addColumnAttributeUnserializedComment(&$script, Column $colum /** * Adds the declaration of the serialized attribute. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addColumnAttributeUnserializedDeclaration(&$script, Column $column) @@ -573,7 +573,7 @@ protected function addColumnAttributeUnserializedDeclaration(&$script, Column $c } /** - * @param string &$script + * @param string $script * @param Column $column */ protected function addColumnAttributeConvertedDeclaration(&$script, Column $column) @@ -587,7 +587,7 @@ protected function addColumnAttributeConvertedDeclaration(&$script, Column $colu /** * Adds the constructor for this object. * - * @param string &$script + * @param string $script */ protected function addConstructor(&$script) { @@ -602,7 +602,7 @@ protected function addConstructor(&$script) /** * Adds the comment for the constructor * - * @param string &$script + * @param string $script */ protected function addConstructorComment(&$script) { @@ -620,7 +620,7 @@ protected function addConstructorComment(&$script) /** * Adds the function declaration for the constructor. * - * @param string &$script + * @param string $script */ protected function addConstructorOpen(&$script) { @@ -632,7 +632,7 @@ public function __construct() /** * Adds the function body for the constructor. * - * @param string &$script + * @param string $script */ protected function addConstructorBody(&$script) { @@ -643,7 +643,7 @@ protected function addConstructorBody(&$script) /** * Adds the function close for the constructor. * - * @param string &$script + * @param string $script */ protected function addConstructorClose(&$script) { @@ -655,7 +655,7 @@ protected function addConstructorClose(&$script) /** * Adds the base object functions. * - * @param string &$script + * @param string $script */ protected function addBaseObjectMethods(&$script) { @@ -665,7 +665,7 @@ protected function addBaseObjectMethods(&$script) /** * Adds the base object hook functions. * - * @param string &$script + * @param string $script */ protected function addHookMethods(&$script) { @@ -689,7 +689,7 @@ protected function addHookMethods(&$script) /** * Adds the applyDefaults() method, which is called from the constructor. * - * @param string &$script + * @param string $script */ protected function addApplyDefaultValues(&$script) { @@ -702,7 +702,7 @@ protected function addApplyDefaultValues(&$script) /** * Adds the comment for the applyDefaults method. * - * @param string &$script + * @param string $script */ protected function addApplyDefaultValuesComment(&$script) { @@ -718,7 +718,7 @@ protected function addApplyDefaultValuesComment(&$script) /** * Adds the function declaration for the applyDefaults method. * - * @param string &$script + * @param string $script */ protected function addApplyDefaultValuesOpen(&$script) { @@ -730,7 +730,7 @@ public function applyDefaultValues() /** * Adds the function body of the applyDefault method. * - * @param string &$script + * @param string $script */ protected function addApplyDefaultValuesBody(&$script) { @@ -764,7 +764,7 @@ protected function addApplyDefaultValuesBody(&$script) /** * Adds the function close for the applyDefaults method. * - * @param string &$script + * @param string $script */ protected function addApplyDefaultValuesClose(&$script) { @@ -776,7 +776,7 @@ protected function addApplyDefaultValuesClose(&$script) /** * Adds a date/time/timestamp getter method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addTemporalAccessor(&$script, Column $column) @@ -790,7 +790,7 @@ protected function addTemporalAccessor(&$script, Column $column) /** * Adds the comment for a temporal accessor. * - * @param string &$script + * @param string $script * @param Column $column */ public function addTemporalAccessorComment(&$script, Column $column) @@ -828,7 +828,7 @@ public function addTemporalAccessorComment(&$script, Column $column) /** * Adds the function declaration for a temporal accessor. * - * @param string &$script + * @param string $script * @param Column $column */ public function addTemporalAccessorOpen(&$script, Column $column) @@ -889,7 +889,7 @@ protected function getAccessorLazyLoadSnippet(Column $column) /** * Adds the body of the temporal accessor. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addTemporalAccessorBody(&$script, Column $column) @@ -929,7 +929,7 @@ protected function addTemporalAccessorBody(&$script, Column $column) /** * Adds the body of the temporal accessor. * - * @param string &$script + * @param string $script */ protected function addTemporalAccessorClose(&$script) { @@ -941,7 +941,7 @@ protected function addTemporalAccessorClose(&$script) /** * Adds an object getter method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addObjectAccessor(&$script, Column $column) @@ -955,7 +955,7 @@ protected function addObjectAccessor(&$script, Column $column) /** * Adds the function body for an object accessor method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addObjectAccessorBody(&$script, Column $column) @@ -987,7 +987,7 @@ protected function addJsonAccessor(&$script, Column $column) /** * Add the comment for a json accessor method (a getter). * - * @param string &$script + * @param string $script * @param Column $column */ public function addJsonAccessorComment(&$script, Column $column) @@ -1012,7 +1012,7 @@ public function addJsonAccessorComment(&$script, Column $column) /** * Adds the function declaration for a JSON accessor. * - * @param string &$script + * @param string $script * @param Column $column */ public function addJsonAccessorOpen(&$script, Column $column) @@ -1040,7 +1040,7 @@ protected function addJsonAccessorBody(&$script, Column $column) /** * Adds an array getter method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addArrayAccessor(&$script, Column $column) @@ -1054,7 +1054,7 @@ protected function addArrayAccessor(&$script, Column $column) /** * Adds the function body for an array accessor method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addArrayAccessorBody(&$script, Column $column) @@ -1080,7 +1080,7 @@ protected function addArrayAccessorBody(&$script, Column $column) /** * Adds a boolean isser method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addBooleanAccessor(&$script, Column $column) @@ -1114,7 +1114,7 @@ protected static function getBooleanAccessorName(Column $column) /** * Adds the function declaration for a boolean accessor. * - * @param string &$script + * @param string $script * @param Column $column */ public function addBooleanAccessorOpen(&$script, Column $column) @@ -1135,7 +1135,7 @@ public function addBooleanAccessorOpen(&$script, Column $column) /** * Adds the function body for a boolean accessor method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addBooleanAccessorBody(&$script, Column $column) @@ -1155,7 +1155,7 @@ protected function addBooleanAccessorBody(&$script, Column $column) /** * Adds an enum getter method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addEnumAccessor(&$script, Column $column) @@ -1169,7 +1169,7 @@ protected function addEnumAccessor(&$script, Column $column) /** * Add the comment for an enum accessor method. * - * @param string &$script + * @param string $script * @param Column $column */ public function addEnumAccessorComment(&$script, Column $column) @@ -1193,7 +1193,7 @@ public function addEnumAccessorComment(&$script, Column $column) /** * Adds the function body for an enum accessor method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addEnumAccessorBody(&$script, Column $column) @@ -1218,7 +1218,7 @@ protected function addEnumAccessorBody(&$script, Column $column) /** * Adds a SET column getter method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addSetAccessor(&$script, Column $column) @@ -1232,7 +1232,7 @@ protected function addSetAccessor(&$script, Column $column) /** * Add the comment for a SET column accessor method. * - * @param string &$script + * @param string $script * @param Column $column */ public function addSetAccessorComment(&$script, Column $column) @@ -1256,7 +1256,7 @@ public function addSetAccessorComment(&$script, Column $column) /** * Adds the function body for a SET column accessor method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addSetAccessorBody(&$script, Column $column) @@ -1283,7 +1283,7 @@ protected function addSetAccessorBody(&$script, Column $column) throw new PropelException('Unknown stored set key: ' . \$e->getValue(), \$e->getCode(), \$e); } } - + return \$this->$cloConverted;"; } @@ -1291,7 +1291,7 @@ protected function addSetAccessorBody(&$script, Column $column) /** * Adds a tester method for an array column. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addHasArrayElement(&$script, Column $column) @@ -1333,7 +1333,7 @@ protected function addHasArrayElement(&$script, Column $column) /** * Adds a normal (non-temporal) getter method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addDefaultAccessor(&$script, Column $column) @@ -1347,7 +1347,7 @@ protected function addDefaultAccessor(&$script, Column $column) /** * Add the comment for a default accessor method (a getter). * - * @param string &$script + * @param string $script * @param Column $column */ public function addDefaultAccessorComment(&$script, Column $column) @@ -1370,7 +1370,7 @@ public function addDefaultAccessorComment(&$script, Column $column) /** * Adds the function declaration for a default accessor. * - * @param string &$script + * @param string $script * @param Column $column */ public function addDefaultAccessorOpen(&$script, Column $column) @@ -1391,7 +1391,7 @@ public function addDefaultAccessorOpen(&$script, Column $column) /** * Adds the function body for a default accessor method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addDefaultAccessorBody(&$script, Column $column) @@ -1408,7 +1408,7 @@ protected function addDefaultAccessorBody(&$script, Column $column) /** * Adds the function close for a default accessor method. * - * @param string &$script + * @param string $script */ protected function addDefaultAccessorClose(&$script) { @@ -1420,7 +1420,7 @@ protected function addDefaultAccessorClose(&$script) /** * Adds the lazy loader method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addLazyLoader(&$script, Column $column) @@ -1434,7 +1434,7 @@ protected function addLazyLoader(&$script, Column $column) /** * Adds the comment for the lazy loader method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addLazyLoaderComment(&$script, Column $column) @@ -1458,7 +1458,7 @@ protected function addLazyLoaderComment(&$script, Column $column) /** * Adds the function declaration for the lazy loader method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addLazyLoaderOpen(&$script, Column $column) @@ -1472,7 +1472,7 @@ protected function load$cfc(ConnectionInterface \$con = null) /** * Adds the function body for the lazy loader method. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addLazyLoaderBody(&$script, Column $column) @@ -1544,7 +1544,7 @@ protected function addLazyLoaderBody(&$script, Column $column) /** * Adds the function close for the lazy loader. * - * @param string &$script + * @param string $script */ protected function addLazyLoaderClose(&$script) { @@ -1555,7 +1555,7 @@ protected function addLazyLoaderClose(&$script) /** * Adds the open of the mutator (setter) method for a column. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addMutatorOpen(&$script, Column $column) @@ -1568,7 +1568,7 @@ protected function addMutatorOpen(&$script, Column $column) /** * Adds the open of the mutator (setter) method for a JSON column. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addJsonMutatorOpen(&$script, Column $column) @@ -1581,7 +1581,7 @@ protected function addJsonMutatorOpen(&$script, Column $column) /** * Adds the comment for a mutator. * - * @param string &$script + * @param string $script * @param Column $column */ public function addJsonMutatorComment(&$script, Column $column) @@ -1599,7 +1599,7 @@ public function addJsonMutatorComment(&$script, Column $column) /** * Adds the comment for a mutator. * - * @param string &$script + * @param string $script * @param Column $column */ public function addMutatorComment(&$script, Column $column) @@ -1617,7 +1617,7 @@ public function addMutatorComment(&$script, Column $column) /** * Adds the mutator function declaration. * - * @param string &$script + * @param string $script * @param Column $column */ public function addMutatorOpenOpen(&$script, Column $column) @@ -1649,7 +1649,7 @@ public function addMutatorOpenOpen(&$script, Column $column) /** * Adds the mutator open body part. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addMutatorOpenBody(&$script, Column $column) @@ -1670,7 +1670,7 @@ protected function addMutatorOpenBody(&$script, Column $column) /** * Adds the close of the mutator (setter) method for a column. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addMutatorClose(&$script, Column $column) @@ -1682,7 +1682,7 @@ protected function addMutatorClose(&$script, Column $column) /** * Adds the body of the close part of a mutator. * - * @param string &$script + * @param string $script * @param Column $column */ protected function addMutatorCloseBody(&$script, Column $column) @@ -1748,7 +1748,7 @@ protected function addMutatorCloseBody(&$script, Column $column) /** * Adds the close for the mutator close - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see addMutatorClose() **/ @@ -1763,7 +1763,7 @@ protected function addMutatorCloseClose(&$script, Column $col) /** * Adds a setter for BLOB columns. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() */ @@ -1789,7 +1789,7 @@ protected function addLobMutator(&$script, Column $col) /** * Adds a setter method for date/time/timestamp columns. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() */ @@ -1857,7 +1857,7 @@ public function addTemporalMutatorComment(&$script, Column $col) /** * Adds a setter for Object columns. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() */ @@ -1881,7 +1881,7 @@ protected function addObjectMutator(&$script, Column $col) /** * Adds a setter for Json columns. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() */ @@ -1907,7 +1907,7 @@ protected function addJsonMutator(&$script, Column $col) /** * Adds a setter for Array columns. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() */ @@ -1929,7 +1929,7 @@ protected function addArrayMutator(&$script, Column $col) /** * Adds a push method for an array column. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param Column $col The current column. */ protected function addAddArrayElement(&$script, Column $col) @@ -1974,7 +1974,7 @@ protected function addAddArrayElement(&$script, Column $col) /** * Adds a remove method for an array column. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param Column $col The current column. */ protected function addRemoveArrayElement(&$script, Column $col) @@ -2022,7 +2022,7 @@ protected function addRemoveArrayElement(&$script, Column $col) /** * Adds a setter for Enum columns. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() */ @@ -2053,7 +2053,7 @@ protected function addEnumMutator(&$script, Column $col) /** * Adds the comment for an enum mutator. * - * @param string &$script + * @param string $script * @param Column $column */ public function addEnumMutatorComment(&$script, Column $column) @@ -2072,7 +2072,7 @@ public function addEnumMutatorComment(&$script, Column $column) /** * Adds a setter for SET column mutator. * - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() */ @@ -2110,7 +2110,7 @@ protected function addSetMutator(&$script, Column $col) /** * Adds the comment for a SET column mutator. * - * @param string &$script + * @param string $script * @param Column $column */ public function addSetMutatorComment(&$script, Column $column) @@ -2128,7 +2128,7 @@ public function addSetMutatorComment(&$script, Column $column) /** * Adds setter method for boolean columns. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() */ @@ -2176,7 +2176,7 @@ public function addBooleanMutatorComment(&$script, Column $col) /** * Adds setter method for "normal" columns. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() */ @@ -2207,7 +2207,7 @@ protected function addDefaultMutator(&$script, Column $col) /** * Adds the hasOnlyDefaultValues() method. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addHasOnlyDefaultValues(&$script) { @@ -2219,7 +2219,7 @@ protected function addHasOnlyDefaultValues(&$script) /** * Adds the comment for the hasOnlyDefaultValues method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues **/ protected function addHasOnlyDefaultValuesComment(&$script) @@ -2237,7 +2237,7 @@ protected function addHasOnlyDefaultValuesComment(&$script) /** * Adds the function declaration for the hasOnlyDefaultValues method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues **/ protected function addHasOnlyDefaultValuesOpen(&$script) @@ -2249,7 +2249,7 @@ public function hasOnlyDefaultValues() /** * Adds the function body for the hasOnlyDefaultValues method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues **/ protected function addHasOnlyDefaultValuesBody(&$script) @@ -2281,7 +2281,7 @@ protected function addHasOnlyDefaultValuesBody(&$script) /** * Adds the function close for the hasOnlyDefaultValues method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues **/ protected function addHasOnlyDefaultValuesClose(&$script) @@ -2296,7 +2296,7 @@ protected function addHasOnlyDefaultValuesClose(&$script) /** * Adds the hydrate() method, which sets attributes of the object based on a ResultSet. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addHydrate(&$script) { @@ -2308,7 +2308,7 @@ protected function addHydrate(&$script) /** * Adds the comment for the hydrate method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addHydrate() */ protected function addHydrateComment(&$script) @@ -2336,7 +2336,7 @@ protected function addHydrateComment(&$script) /** * Adds the function declaration for the hydrate method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addHydrate() */ protected function addHydrateOpen(&$script) @@ -2348,7 +2348,7 @@ public function hydrate(\$row, \$startcol = 0, \$rehydrate = false, \$indexType /** * Adds the function body for the hydrate method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addHydrate() */ protected function addHydrateBody(&$script) @@ -2456,7 +2456,7 @@ protected function addHydrateBody(&$script) /** * Adds the function close for the hydrate method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addHydrate() */ protected function addHydrateClose(&$script) @@ -2468,7 +2468,7 @@ protected function addHydrateClose(&$script) /** * Adds the buildPkeyCriteria method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. **/ protected function addBuildPkeyCriteria(&$script) { @@ -2482,7 +2482,7 @@ protected function addBuildPkeyCriteria(&$script) /** * Adds the comment for the buildPkeyCriteria method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() **/ protected function addBuildPkeyCriteriaComment(&$script) @@ -2502,7 +2502,7 @@ protected function addBuildPkeyCriteriaComment(&$script) /** * Adds the function declaration for the buildPkeyCriteria method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() **/ protected function addBuildPkeyCriteriaOpen(&$script) @@ -2514,7 +2514,7 @@ public function buildPkeyCriteria() /** * Adds the function body for the buildPkeyCriteria method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() **/ protected function addBuildPkeyCriteriaBody(&$script) @@ -2537,7 +2537,7 @@ protected function addBuildPkeyCriteriaBody(&$script) /** * Adds the function close for the buildPkeyCriteria method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() **/ protected function addBuildPkeyCriteriaClose(&$script) @@ -2551,7 +2551,7 @@ protected function addBuildPkeyCriteriaClose(&$script) /** * Adds the buildCriteria method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. **/ protected function addBuildCriteria(&$script) { @@ -2563,7 +2563,7 @@ protected function addBuildCriteria(&$script) /** * Adds comment for the buildCriteria method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addBuildCriteria() **/ protected function addBuildCriteriaComment(&$script) @@ -2578,7 +2578,7 @@ protected function addBuildCriteriaComment(&$script) /** * Adds the function declaration of the buildCriteria method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addBuildCriteria() **/ protected function addBuildCriteriaOpen(&$script) @@ -2590,7 +2590,7 @@ public function buildCriteria() /** * Adds the function body of the buildCriteria method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addBuildCriteria() **/ protected function addBuildCriteriaBody(&$script) @@ -2609,7 +2609,7 @@ protected function addBuildCriteriaBody(&$script) /** * Adds the function close of the buildCriteria method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addBuildCriteria() **/ protected function addBuildCriteriaClose(&$script) @@ -2623,7 +2623,7 @@ protected function addBuildCriteriaClose(&$script) /** * Adds the toArray method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. **/ protected function addToArray(&$script) { @@ -2759,7 +2759,7 @@ protected function addToArrayKeyLookUp($phpName, Table $table, $plural) /** * Adds the getByName method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. **/ protected function addGetByName(&$script) { @@ -2771,7 +2771,7 @@ protected function addGetByName(&$script) /** * Adds the comment for the getByName method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addGetByName **/ protected function addGetByNameComment(&$script) @@ -2792,7 +2792,7 @@ protected function addGetByNameComment(&$script) /** * Adds the function declaration for the getByName method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addGetByName **/ protected function addGetByNameOpen(&$script) @@ -2805,7 +2805,7 @@ public function getByName(\$name, \$type = TableMap::$defaultKeyType) /** * Adds the function body for the getByName method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addGetByName **/ protected function addGetByNameBody(&$script) @@ -2817,7 +2817,7 @@ protected function addGetByNameBody(&$script) /** * Adds the function close for the getByName method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addGetByName **/ protected function addGetByNameClose(&$script) @@ -2831,7 +2831,7 @@ protected function addGetByNameClose(&$script) /** * Adds the getByPosition method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. **/ protected function addGetByPosition(&$script) { @@ -2843,7 +2843,7 @@ protected function addGetByPosition(&$script) /** * Adds comment for the getByPosition method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addGetByPosition **/ protected function addGetByPositionComment(&$script) @@ -2860,7 +2860,7 @@ protected function addGetByPositionComment(&$script) /** * Adds the function declaration for the getByPosition method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addGetByPosition **/ protected function addGetByPositionOpen(&$script) @@ -2872,7 +2872,7 @@ public function getByPosition(\$pos) /** * Adds the function body for the getByPosition method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addGetByPosition **/ protected function addGetByPositionBody(&$script) @@ -2898,7 +2898,7 @@ protected function addGetByPositionBody(&$script) /** * Adds the function close for the getByPosition method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addGetByPosition **/ protected function addGetByPositionClose(&$script) @@ -3070,7 +3070,7 @@ public function importFrom(\$parser, \$data, \$keyType = TableMap::$defaultKeyTy /** * Adds a delete() method to remove the object form the datastore. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addDelete(&$script) { @@ -3082,7 +3082,7 @@ protected function addDelete(&$script) /** * Adds the comment for the delete function - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addDelete() **/ protected function addDeleteComment(&$script) @@ -3102,7 +3102,7 @@ protected function addDeleteComment(&$script) /** * Adds the function declaration for the delete function - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addDelete() **/ protected function addDeleteOpen(&$script) @@ -3114,7 +3114,7 @@ public function delete(ConnectionInterface \$con = null) /** * Adds the function body for the delete function - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addDelete() **/ protected function addDeleteBody(&$script) @@ -3162,7 +3162,7 @@ protected function addDeleteBody(&$script) /** * Adds the function close for the delete function - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addDelete() **/ protected function addDeleteClose(&$script) @@ -3174,7 +3174,7 @@ protected function addDeleteClose(&$script) /** * Adds a reload() method to re-fetch the data for this object from the database. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addReload(&$script) { @@ -3263,7 +3263,7 @@ public function reload(\$deep = false, ConnectionInterface \$con = null) /** * Adds the methods related to refreshing, saving and deleting the object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addManipulationMethods(&$script) { @@ -3297,7 +3297,7 @@ public function hashCode() $script .= ";\n"; - /** @var $primaryKeyFKs ForeignKey[] */ + /** @var ForeignKey[] $primaryKeyFKs */ $primaryKeyFKs = []; $foreignKeyPKCount = 0; foreach ($this->getTable()->getForeignKeys() as $foreignKey) { @@ -3340,7 +3340,7 @@ public function hashCode() /** * Adds the correct getPrimaryKey() method for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addGetPrimaryKey(&$script) { @@ -3357,7 +3357,7 @@ protected function addGetPrimaryKey(&$script) /** * Adds the getPrimaryKey() method for tables that contain a single-column primary key. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addGetPrimaryKey_SinglePK(&$script) { @@ -3379,7 +3379,7 @@ public function getPrimaryKey() /** * Adds the setPrimaryKey() method for tables that contain a multi-column primary key. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addGetPrimaryKey_MultiPK(&$script) { @@ -3411,7 +3411,7 @@ public function getPrimaryKey() * This "feature" is deprecated, since the getPrimaryKey() method is not required * by the Persistent interface (or used by the templates). Hence, this method is also * deprecated. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @deprecated */ protected function addGetPrimaryKey_NoPK(&$script) @@ -3431,7 +3431,7 @@ public function getPrimaryKey() /** * Adds the correct setPrimaryKey() method for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addSetPrimaryKey(&$script) { @@ -3448,7 +3448,7 @@ protected function addSetPrimaryKey(&$script) /** * Adds the setPrimaryKey() method for tables that contain a single-column primary key. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addSetPrimaryKey_SinglePK(&$script) { @@ -3474,7 +3474,7 @@ public function setPrimaryKey(\$key) /** * Adds the setPrimaryKey() method for tables that contain a multi-columnprimary key. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addSetPrimaryKey_MultiPK(&$script) { @@ -3504,7 +3504,7 @@ public function setPrimaryKey(\$keys) * This "feature" is deprecated, since the setPrimaryKey() method is not required * by the Persistent interface (or used by the templates). Hence, this method is also * deprecated. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @deprecated */ protected function addSetPrimaryKey_NoPK(&$script) @@ -3528,7 +3528,7 @@ public function setPrimaryKey(\$pk) /** * Adds the isPrimaryKeyNull() method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addIsPrimaryKeyNull(&$script) { @@ -3591,7 +3591,7 @@ public function getPKRefFKVarName(ForeignKey $fk) /** * Adds the methods that get & set objects related by foreign key to the current object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addFKMethods(&$script) { @@ -3605,7 +3605,7 @@ protected function addFKMethods(&$script) /** * Adds the class attributes that are needed to store fkey related objects. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $fk */ protected function addFKAttributes(&$script, ForeignKey $fk) @@ -3623,7 +3623,7 @@ protected function addFKAttributes(&$script, ForeignKey $fk) /** * Adds the mutator (setter) method for setting an fkey related object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $fk */ protected function addFKMutator(&$script, ForeignKey $fk) @@ -3708,7 +3708,7 @@ public function set".$this->getFKPhpNameAffix($fk, false)."($className \$v = nul /** * Adds the accessor (getter) method for getting an fkey related object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $fk */ protected function addFKAccessor(&$script, ForeignKey $fk) @@ -3813,7 +3813,7 @@ public function get".$this->getFKPhpNameAffix($fk, false)."(ConnectionInterface /** * Adds the method that fetches fkey-related (referencing) objects but also joins in data from another table. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $refFK */ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK) @@ -3883,7 +3883,7 @@ public function get".$relCol."Join".$relCol2."(Criteria \$criteria = null, Conne * Adds the attributes used to store objects that have referrer fkey relationships to this object. * protected collVarName; * private lastVarNameCriteria = null; - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $refFK */ protected function addRefFKAttributes(&$script, ForeignKey $refFK) @@ -3910,7 +3910,7 @@ protected function addRefFKAttributes(&$script, ForeignKey $refFK) /** * Adds the methods for retrieving, initializing, adding objects that are related to this one by foreign keys. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addRefFKMethods(&$script) { @@ -3940,7 +3940,7 @@ protected function addRefFKMethods(&$script) } /** - * @param string &$script + * @param string $script * @param ForeignKey[] $referrers */ protected function addInitRelations(&$script, $referrers) @@ -3975,7 +3975,7 @@ public function initRelation(\$relationName) /** * Adds the method that clears the referrer fkey collection. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $refFK */ protected function addRefFKClear(&$script, ForeignKey $refFK) @@ -4002,7 +4002,7 @@ public function clear$relCol() /** * Adds the method that initializes the referrer fkey collection. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $refFK */ protected function addRefFKInit(&$script, ForeignKey $refFK) @@ -4039,7 +4039,7 @@ public function init$relCol(\$overrideExisting = true) /** * Adds the method that adds an object into the referrer fkey collection. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $refFK */ protected function addRefFKAdd(&$script, ForeignKey $refFK) @@ -4086,7 +4086,7 @@ public function add".$this->getRefFKPhpNameAffix($refFK, false)."($className \$l /** * Adds the method that returns the size of the referrer fkey collection. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $refFK */ protected function addRefFKCount(&$script, ForeignKey $refFK) @@ -4137,7 +4137,7 @@ public function count{$relCol}(Criteria \$criteria = null, \$distinct = false, C /** * Adds the method that returns the referrer fkey collection. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $refFK */ protected function addRefFKGet(&$script, ForeignKey $refFK) @@ -4272,7 +4272,7 @@ public function set{$relatedName}(Collection \${$inputCollection}, ConnectionInt } /** - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $refFK */ protected function addRefFKDoAdd(&$script, ForeignKey $refFK) @@ -4302,7 +4302,7 @@ protected function doAdd{$relatedObjectClassName}($className \${$lowerRelatedObj } /** - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $refFK */ protected function addRefFKRemove(&$script, ForeignKey $refFK) @@ -4359,7 +4359,7 @@ public function remove{$relatedObjectClassName}($className \${$lowerRelatedObjec /** * Adds the method that gets a one-to-one related referrer fkey. * This is for one-to-one relationship special case. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $refFK */ protected function addPKRefFKGet(&$script, ForeignKey $refFK) @@ -4394,7 +4394,7 @@ public function get".$this->getRefFKPhpNameAffix($refFK, false)."(ConnectionInte /** * Adds the method that sets a one-to-one related referrer fkey. * This is for one-to-one relationships special case. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $refFK The referencing foreign key. */ protected function addPKRefFKSet(&$script, ForeignKey $refFK) @@ -4527,7 +4527,7 @@ protected function addRefFkScheduledForDeletionAttribute(&$script, ForeignKey $r } /** - * @param $script + * @param string $script * @param CrossForeignKeys $crossFKs */ protected function addCrossFkScheduledForDeletion(&$script, CrossForeignKeys $crossFKs) @@ -4740,7 +4740,7 @@ protected function addCrossFKMethods(&$script) /** * Adds the method that clears the referrer fkey collection. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs */ protected function addCrossFKClear(&$script, CrossForeignKeys $crossFKs) @@ -4768,7 +4768,7 @@ public function clear{$relCol}() /** * Adds the method that clears the referrer fkey collection. * - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $refFK */ protected function addRefFKPartial(&$script, ForeignKey $refFK) @@ -4789,7 +4789,7 @@ public function resetPartial{$relCol}(\$v = true) /** * Adds the method that initializes the referrer fkey collection. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs */ protected function addCrossFKInit(&$script, CrossForeignKeys $crossFKs) @@ -4869,7 +4869,7 @@ public function init$relCol() /** * Adds the method that check if the referrer fkey collection is initialized. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs */ protected function addCrossFKIsLoaded(&$script, CrossForeignKeys $crossFKs) @@ -5264,7 +5264,7 @@ public function set{$relatedNamePlural}(Collection \${$inputCollection}, Connect /** * @param string $script - * @param CrossForeignKeys $crossFks + * @param CrossForeignKeys $crossFKs */ protected function addCrossFKCount(&$script, CrossForeignKeys $crossFKs) { @@ -5365,7 +5365,7 @@ public function count{$firstFkName}($signature, Criteria \$criteria = null, Conn /** * Adds the method that adds an object into the referrer fkey collection. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs */ protected function addCrossFKAdd(&$script, CrossForeignKeys $crossFKs) @@ -5435,7 +5435,7 @@ protected function getCrossFKGetterSignature(CrossForeignKeys $crossFKs, $exclud } /** - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs */ protected function addCrossFKDoAdd(&$script, CrossForeignKeys $crossFKs) @@ -5648,7 +5648,7 @@ public function remove{$relatedObjectClassName}($signature) /** * Adds the workhourse doSave() method. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addDoSave(&$script) { @@ -6063,7 +6063,7 @@ protected function doUpdate(ConnectionInterface \$con) /** * Adds the $alreadyInSave attribute, which prevents attempting to re-save the same object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addAlreadyInSaveAttribute(&$script) { @@ -6080,7 +6080,7 @@ protected function addAlreadyInSaveAttribute(&$script) /** * Adds the save() method. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addSave(&$script) { @@ -6092,7 +6092,7 @@ protected function addSave(&$script) /** * Adds the comment for the save method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addSave() **/ protected function addSaveComment(&$script) @@ -6139,7 +6139,7 @@ protected function addSaveComment(&$script) /** * Adds the function declaration for the save method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addSave() **/ protected function addSaveOpen(&$script) @@ -6154,7 +6154,7 @@ public function save(ConnectionInterface \$con = null".($reloadOnUpdate || $relo /** * Adds the function body for the save method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addSave() **/ protected function addSaveBody(&$script) @@ -6171,7 +6171,7 @@ protected function addSaveBody(&$script) if (\$this->alreadyInSave) { return 0; } - + if (\$con === null) { \$con = Propel::getServiceContainer()->getWriteConnection(".$this->getTableMapClass()."::DATABASE_NAME); } @@ -6262,7 +6262,7 @@ protected function addSaveBody(&$script) /** * Adds the function close for the save method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addSave() **/ protected function addSaveClose(&$script) @@ -6274,7 +6274,7 @@ protected function addSaveClose(&$script) /** * Adds the ensureConsistency() method to ensure that internal state is correct. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addEnsureConsistency(&$script) { @@ -6327,7 +6327,7 @@ public function ensureConsistency() /** * Adds the copy() method, which (in complex OM) includes the $deepCopy param for making copies of related objects. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addCopy(&$script) { @@ -6361,7 +6361,7 @@ public function copy(\$deepCopy = false) /** * Adds the copyInto() method, which takes an object and sets contents to match current object. * In complex OM this method includes the $deepCopy param for making copies of related objects. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addCopyInto(&$script) { @@ -6459,7 +6459,7 @@ public function copyInto(\$copyObj, \$deepCopy = false, \$makeNew = true) /** * Adds clear method - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addClear(&$script) { @@ -6526,7 +6526,7 @@ public function clear() /** * Adds clearAllReferences() method which resets all the collections of referencing * fk objects. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addClearAllReferences(&$script) { @@ -6600,7 +6600,7 @@ public function clearAllReferences(\$deep = false) /** * Adds a magic __toString() method if a string column was defined as primary string - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addPrimaryString(&$script) { @@ -6638,7 +6638,7 @@ public function __toString() /** * Adds a magic __call() method. * - * @param string &$script + * @param string $script */ protected function addMagicCall(&$script) { diff --git a/src/Propel/Generator/Builder/Om/QueryBuilder.php b/src/Propel/Generator/Builder/Om/QueryBuilder.php index 5bcd02deb0..4e7db0fe46 100644 --- a/src/Propel/Generator/Builder/Om/QueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryBuilder.php @@ -71,7 +71,7 @@ public function getParentClass() /** * Adds class phpdoc comment and opening of class. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addClassOpen(&$script) { @@ -314,7 +314,7 @@ private function getEntityNotFoundExceptionClass() /** * Adds the doDeleteAll(), etc. methods. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addDeleteMethods(&$script) { @@ -368,7 +368,7 @@ protected function isDeleteSetNullEmulationNeeded() /** * Closes class. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addClassClose(&$script) { @@ -380,7 +380,7 @@ protected function addClassClose(&$script) /** * Adds the constructor for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @see addConstructor() */ protected function addConstructor(&$script) @@ -393,7 +393,7 @@ protected function addConstructor(&$script) /** * Adds the comment for the constructor - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. **/ protected function addConstructorComment(&$script) { @@ -409,7 +409,7 @@ protected function addConstructorComment(&$script) /** * Adds the function declaration for the constructor - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. **/ protected function addConstructorOpen(&$script) { @@ -421,7 +421,7 @@ public function __construct(\$dbName = '" . $table->getDatabase()->getName() . " /** * Adds the function body for the constructor - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. **/ protected function addConstructorBody(&$script) { @@ -431,7 +431,7 @@ protected function addConstructorBody(&$script) /** * Adds the function close for the constructor - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. **/ protected function addConstructorClose(&$script) { @@ -442,7 +442,7 @@ protected function addConstructorClose(&$script) /** * Adds the factory for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addFactory(&$script) { @@ -454,7 +454,7 @@ protected function addFactory(&$script) /** * Adds the comment for the factory - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. **/ protected function addFactoryComment(&$script) { @@ -472,7 +472,7 @@ protected function addFactoryComment(&$script) /** * Adds the function declaration for the factory - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. **/ protected function addFactoryOpen(&$script) { @@ -483,7 +483,7 @@ public static function create(\$modelAlias = null, Criteria \$criteria = null) /** * Adds the function body for the factory - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addFactoryBody(&$script) { @@ -505,7 +505,7 @@ protected function addFactoryBody(&$script) /** * Adds the function close for the factory - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addFactoryClose(&$script) { @@ -700,7 +700,7 @@ protected function findPkSimple(\$key, ConnectionInterface \$con) /** * Adds the findPk method for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addFindPkComplex(&$script) { @@ -737,7 +737,7 @@ protected function findPkComplex(\$key, ConnectionInterface \$con) /** * Adds the findPks method for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addFindPks(&$script) { @@ -796,7 +796,7 @@ public function findPks(\$keys, ConnectionInterface \$con = null) /** * Adds the filterByPrimaryKey method for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addFilterByPrimaryKey(&$script) { @@ -850,7 +850,7 @@ public function filterByPrimaryKey(\$key) /** * Adds the filterByPrimaryKey method for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addFilterByPrimaryKeys(&$script) { @@ -917,7 +917,7 @@ public function filterByPrimaryKeys(\$keys) /** * Adds the filterByCol method for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param Column $col */ protected function addFilterByCol(&$script, Column $col) @@ -1092,7 +1092,7 @@ public function filterBy$colPhpName(\$$variableName = null, \$comparison = null) \$this->add(\$key, \${$variableName}, Criteria::BINARY_NONE); } \$this->addOr(\$key, null, Criteria::ISNULL); - + return \$this; }"; } elseif ($col->getType() == PropelTypes::ENUM) { @@ -1138,7 +1138,7 @@ public function filterBy$colPhpName(\$$variableName = null, \$comparison = null) /** * Adds the singular filterByCol method for an Array column. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param Column $col */ protected function addFilterByArrayCol(&$script, Column $col) @@ -1185,7 +1185,7 @@ public function filterBy$singularPhpName(\$$variableName = null, \$comparison = /** * Adds the singular filterByCol method for an Array column. * - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param Column $col */ protected function addFilterBySetCol(&$script, Column $col) @@ -1211,8 +1211,8 @@ public function filterBy$singularPhpName(\$$variableName = null, \$comparison = /** * Adds the filterByFk method for this object. - * @param string &$script The script will be modified in this method. - * @param $fk ForeignKey + * @param string $script The script will be modified in this method. + * @param ForeignKey $fk ForeignKey */ protected function addFilterByFk(&$script, $fk) { @@ -1295,7 +1295,7 @@ public function filterBy$relationName($objectName, \$comparison = null) /** * Adds the filterByRefFk method for this object. * - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $fk */ protected function addFilterByRefFk(&$script, ForeignKey $fk) @@ -1366,8 +1366,8 @@ public function filterBy$relationName($objectName, \$comparison = null) /** * Adds the joinFk method for this object. - * @param string &$script The script will be modified in this method. - * @param $fk ForeignKey + * @param string $script The script will be modified in this method. + * @param ForeignKey $fk ForeignKey */ protected function addJoinFk(&$script, $fk) { @@ -1380,7 +1380,7 @@ protected function addJoinFk(&$script, $fk) /** * Adds the joinRefFk method for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $fk */ protected function addJoinRefFk(&$script, ForeignKey $fk) @@ -1394,7 +1394,7 @@ protected function addJoinRefFk(&$script, ForeignKey $fk) /** * Adds a joinRelated method for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addJoinRelated(&$script, $fkTable, $queryClass, $relationName, $joinType) { @@ -1435,8 +1435,8 @@ public function join" . $relationName . "(\$relationAlias = null, \$joinType = " /** * Adds the useFkQuery method for this object. - * @param string &$script The script will be modified in this method. - * @param $fk ForeignKey + * @param string $script The script will be modified in this method. + * @param ForeignKey $fk ForeignKey */ protected function addUseFkQuery(&$script, $fk) { @@ -1451,7 +1451,7 @@ protected function addUseFkQuery(&$script, $fk) /** * Adds the useFkQuery method for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param ForeignKey $fk */ protected function addUseRefFkQuery(&$script, ForeignKey $fk) @@ -1467,7 +1467,7 @@ protected function addUseRefFkQuery(&$script, ForeignKey $fk) /** * Adds a useRelatedQuery method for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addUseRelatedQuery(&$script, Table $fkTable, $queryClass, $relationName, $joinType) { @@ -1527,7 +1527,7 @@ public function filterBy{$relName}($objectName, \$comparison = Criteria::EQUAL) /** * Adds the prune method for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addPrune(&$script) { @@ -1582,7 +1582,7 @@ public function prune($objectName = null) /** * Adds the basePreSelect hook for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addBasePreSelect(&$script) { @@ -1607,7 +1607,7 @@ protected function basePreSelect(ConnectionInterface \$con) /** * Adds the basePreDelete hook for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addBasePreDelete(&$script) { @@ -1632,7 +1632,7 @@ protected function basePreDelete(ConnectionInterface \$con) /** * Adds the basePostDelete hook for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addBasePostDelete(&$script) { @@ -1658,7 +1658,7 @@ protected function basePostDelete(\$affectedRows, ConnectionInterface \$con) /** * Adds the basePreUpdate hook for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addBasePreUpdate(&$script) { @@ -1685,7 +1685,7 @@ protected function basePreUpdate(&\$values, ConnectionInterface \$con, \$forceIn /** * Adds the basePostUpdate hook for this object. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addBasePostUpdate(&$script) { @@ -1722,7 +1722,7 @@ public function hasBehaviorModifier($hookName, $modifier = null) /** * Checks whether any registered behavior on that table has a modifier for a hook * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ public function applyBehaviorModifier($hookName, &$script, $tab = " ") { @@ -1740,7 +1740,7 @@ public function getBehaviorContent($contentName) /** * Adds the doDelete() method. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addDelete(&$script) { @@ -1803,7 +1803,7 @@ public function delete(ConnectionInterface \$con = null) /** * Adds the doOnDeleteCascade() method, which provides ON DELETE CASCADE emulation. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addDoOnDeleteCascade(&$script) { @@ -1884,7 +1884,7 @@ protected function doOnDeleteCascade(ConnectionInterface \$con) /** * Adds the doOnDeleteSetNull() method, which provides ON DELETE SET NULL emulation. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addDoOnDeleteSetNull(&$script) { @@ -1961,7 +1961,7 @@ protected function doOnDeleteSetNull(ConnectionInterface \$con) /** * Adds the doDeleteAll() method. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addDoDeleteAll(&$script) { diff --git a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php index 55c885f58a..0535b353e5 100644 --- a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php @@ -93,7 +93,7 @@ public function getChild() /** * Returns classpath to parent class. * - * @return string + * @return string|null */ protected function getParentClassName() { @@ -112,12 +112,14 @@ protected function getParentClassName() return $this->getNewStubQueryInheritanceBuilder($child)->getUnqualifiedClassName(); } } + + return null; } /** * Adds class phpdoc comment and opening of class. * - * @param string &$script + * @param string $script */ protected function addClassOpen(&$script) { @@ -179,7 +181,7 @@ protected function addClassBody(&$script) /** * Adds the factory for this object. * - * @param string &$script + * @param string $script */ protected function addFactory(&$script) { @@ -291,7 +293,7 @@ public function doDeleteAll(ConnectionInterface \$con = null) /** * Closes class. * - * @param string &$script + * @param string $script */ protected function addClassClose(&$script) { diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index 392eecb738..a1073f112d 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -61,7 +61,7 @@ public function getUnprefixedClassName() /** * Adds class phpdoc comment and opening of class. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addClassOpen(&$script) { @@ -167,7 +167,7 @@ protected function addClassBody(&$script) /** * Adds the addSelectColumns(), doCount(), etc. methods. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addSelectMethods(&$script) { @@ -197,7 +197,7 @@ protected function addConstants() /** * Adds the COLUMN_NAME constant to the class definition. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addColumnNameConstants(&$script) { @@ -213,7 +213,7 @@ protected function addColumnNameConstants(&$script) /** * Adds the valueSet constants for ENUM and SET columns. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addValueSetColumnConstants(&$script) { @@ -233,7 +233,7 @@ protected function addValueSetColumnConstants(&$script) /** * Adds the valueSet attributes for ENUM columns. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addValueSetColumnAttributes(&$script) { @@ -259,7 +259,7 @@ protected function addValueSetColumnAttributes(&$script) /** * Adds the getValueSets() method. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addGetValueSets(&$script) { @@ -277,7 +277,7 @@ public static function getValueSets() /** * Adds the getValueSet() method. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addGetValueSet(&$script) { @@ -298,7 +298,7 @@ public static function getValueSet(\$colname) /** * Adds the CLASSKEY_* and CLASSNAME_* constants used for inheritance. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ public function addInheritanceColumnConstants(&$script) { @@ -345,7 +345,7 @@ protected function getValueSetConstant($value) /** * Adds any attributes needed for this TableMap class. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addAttributes(&$script) { @@ -403,7 +403,7 @@ protected function addFieldsAttributes() /** * Closes class. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addClassClose(&$script) { @@ -418,7 +418,7 @@ protected function addClassClose(&$script) /** * Adds the buildTableMap() method. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addBuildTableMap(&$script) { @@ -439,7 +439,7 @@ public static function buildTableMap() /** * Adds the addInitialize() method to the table map class. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addInitialize(&$script) { @@ -542,7 +542,7 @@ public function initialize() /** * Adds the method that build the RelationMap objects - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addBuildRelations(&$script) { @@ -595,7 +595,7 @@ public function buildRelations() /** * Adds the behaviors getter - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addGetBehaviors(&$script) { @@ -744,7 +744,7 @@ public function hasBehaviorModifier($hookName, $modifier = null) /** * Checks whether any registered behavior on that table has a modifier for a hook * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param string $tab */ public function applyBehaviorModifier($hookName, &$script, $tab = " ") @@ -755,7 +755,7 @@ public function applyBehaviorModifier($hookName, &$script, $tab = " ") /** * Adds method to get a version of the primary key that can be used as a unique key for identifier map. * - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addGetPrimaryKeyHash(&$script) { @@ -811,7 +811,7 @@ public static function getPrimaryKeyHashFromRow(\$row, \$offset = 0, \$indexType /** * Adds method to get the primary key from a row - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addGetPrimaryKeyFromRow(&$script) { @@ -886,7 +886,7 @@ public static function getPrimaryKeyFromRow(\$row, \$offset = 0, \$indexType = T /** * Adds the correct getOMClass() method, depending on whether this table uses inheritance. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addGetOMClassMethod(&$script) { @@ -904,7 +904,7 @@ protected function addGetOMClassMethod(&$script) /** * Adds a getOMClass() for non-abstract tables that have inheritance. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addGetOMClass_Inheritance(&$script) { @@ -968,7 +968,7 @@ public static function getOMClass(\$row, \$colnum, \$withPrefix = true) /** * Adds a getOMClass() for non-abstract tables that do note use inheritance. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addGetOMClass_NoInheritance(&$script) { @@ -993,7 +993,7 @@ public static function getOMClass(\$withPrefix = true) /** * Adds a getOMClass() signature for abstract tables that do not have inheritance. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addGetOMClass_NoInheritance_Abstract(&$script) { @@ -1014,7 +1014,7 @@ abstract public static function getOMClass(\$withPrefix = true); /** * Adds the populateObject() method. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addPopulateObject(&$script) { @@ -1072,7 +1072,7 @@ public static function populateObject(\$row, \$offset = 0, \$indexType = TableMa /** * Adds the populateObjects() method. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addPopulateObjects(&$script) { @@ -1137,7 +1137,7 @@ public static function populateObjects(DataFetcherInterface \$dataFetcher) /** * Adds the addSelectColumns() method. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addAddSelectColumns(&$script) { @@ -1180,7 +1180,7 @@ public static function addSelectColumns(Criteria \$criteria, \$alias = null) /** * Adds the getTableMap() method which is a convenience method for apps to get DB metadata. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addGetTableMap(&$script) { @@ -1201,7 +1201,7 @@ public static function getTableMap() /** * Adds the doDeleteAll() method. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addDoDeleteAll(&$script) { @@ -1222,7 +1222,7 @@ public static function doDeleteAll(ConnectionInterface \$con = null) /** * Adds the doDelete() method. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addDoDelete(&$script) { @@ -1324,7 +1324,7 @@ public static function doDelete(\$values, ConnectionInterface \$con = null) /** * Adds the doInsert() method. - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ protected function addDoInsert(&$script) { diff --git a/src/Propel/Generator/Builder/Util/DataRow.php b/src/Propel/Generator/Builder/Util/DataRow.php index a0e12a9903..806f8566d2 100644 --- a/src/Propel/Generator/Builder/Util/DataRow.php +++ b/src/Propel/Generator/Builder/Util/DataRow.php @@ -12,6 +12,9 @@ use Propel\Generator\Model\Table; +/** + * @deprecated Not in use + */ class DataRow { private $table; @@ -30,7 +33,7 @@ public function getTable() } /** - * @return ColumnValue[] + * @return \Propel\Generator\Model\ColumnDefaultValue[] */ public function getColumnValues() { diff --git a/src/Propel/Generator/Command/AbstractCommand.php b/src/Propel/Generator/Command/AbstractCommand.php index 87987f76b4..a9c4c9523d 100644 --- a/src/Propel/Generator/Command/AbstractCommand.php +++ b/src/Propel/Generator/Command/AbstractCommand.php @@ -47,7 +47,7 @@ protected function configure() * the configuration properties in the `config-dir` folder. * * @param array $properties Properties to add to the configuration. They usually come from command line. - * @param $input + * @param InputInterface|null $input * * @return GeneratorConfig */ @@ -70,7 +70,7 @@ protected function getGeneratorConfig(array $properties = null, InputInterface $ /** * Find every schema files. * - * @param string|array $directory Path to the input directory + * @param string|string[] $directory Path to the input directory * @param bool $recursive Search for file inside the input directory and all subdirectories * * @return array List of schema files diff --git a/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php b/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php index 090c41d4d7..8108aeee99 100644 --- a/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php +++ b/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php @@ -27,7 +27,7 @@ public function askQuestion($question, $default = null, array $autocomplete = nu public function askHiddenResponse($question, $fallback = true); /** - * @param $text + * @param string $text * * @return mixed */ diff --git a/src/Propel/Generator/Command/TestPrepareCommand.php b/src/Propel/Generator/Command/TestPrepareCommand.php index fc82b18760..6858b1f4cc 100644 --- a/src/Propel/Generator/Command/TestPrepareCommand.php +++ b/src/Propel/Generator/Command/TestPrepareCommand.php @@ -107,8 +107,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int } /** - * @param $fixturesDir - * @param $connections + * @param string $fixturesDir + * @param string[] $connections * @param InputInterface $input * @param OutputInterface $output * @return int Exit code diff --git a/src/Propel/Generator/Manager/AbstractManager.php b/src/Propel/Generator/Manager/AbstractManager.php index 8c0800840d..f2e7f0dc81 100644 --- a/src/Propel/Generator/Manager/AbstractManager.php +++ b/src/Propel/Generator/Manager/AbstractManager.php @@ -58,13 +58,19 @@ abstract class AbstractManager /** * The XSD schema file to use for validation. - * @var string + * + * @deprecated Not in use and not working due to missing class. + * + * @var mixed */ protected $xsd; /** * XSL file to use to normalize (or otherwise transform) schema before validation. - * @var string + * + * @deprecated Not in use and not working due to missing class. + * + * @var mixed */ protected $xsl; @@ -81,9 +87,9 @@ abstract class AbstractManager protected $workingDirectory; /** - * @var \Closure + * @var \Closure|null */ - private $loggerClosure = null; + private $loggerClosure; /** * Have datamodels been initialized? @@ -111,7 +117,7 @@ public function getSchemas() /** * Sets the schemas list. * - * @param array + * @param array $schemas */ public function setSchemas($schemas) { @@ -231,7 +237,7 @@ public function setXsd($xsd) * Sets the normalization XSLT to use to transform datamodel schema.xml * file(s) before validation and parsing. * - * @param string $xsl + * @param mixed $xsl */ public function setXsl($xsl) { diff --git a/src/Propel/Generator/Manager/MigrationManager.php b/src/Propel/Generator/Manager/MigrationManager.php index 3e7d9779bd..318c2d533a 100644 --- a/src/Propel/Generator/Manager/MigrationManager.php +++ b/src/Propel/Generator/Manager/MigrationManager.php @@ -72,7 +72,7 @@ public function getConnection($datasource) } /** - * @param $datasource + * @param string $datasource * @return ConnectionInterface */ public function getAdapterConnection($datasource) @@ -87,7 +87,7 @@ public function getAdapterConnection($datasource) } /** - * @param string $datasource + * @param string $datasource * @return PlatformInterface */ public function getPlatform($datasource) diff --git a/src/Propel/Generator/Manager/ReverseManager.php b/src/Propel/Generator/Manager/ReverseManager.php index 56d3bc43ee..dfb38f053c 100644 --- a/src/Propel/Generator/Manager/ReverseManager.php +++ b/src/Propel/Generator/Manager/ReverseManager.php @@ -202,7 +202,7 @@ protected function buildModel() $database = new Database($this->getDatabaseName()); - $database->setPlatform($config->getConfiguredPlatform($connection), $databaseName); + $database->setPlatform($config->getConfiguredPlatform($connection)); $database->setDefaultIdMethod(IdMethod::NATIVE); $this->getNamespace() && $database->setNamespace($this->getNamespace()); diff --git a/src/Propel/Generator/Model/Behavior.php b/src/Propel/Generator/Model/Behavior.php index e1c1a12f37..9a1b574916 100644 --- a/src/Propel/Generator/Model/Behavior.php +++ b/src/Propel/Generator/Model/Behavior.php @@ -146,7 +146,7 @@ public function getName() /** * Sets the table this behavior is applied to * - * @param Table $table + * @param \Propel\Generator\Model\Table $table */ public function setTable(Table $table) { @@ -224,7 +224,7 @@ public function getParameters() * Returns a single parameter by its name. * * @param string $name - * @return array + * @return mixed */ public function getParameter($name) { @@ -292,10 +292,11 @@ protected function getTables() * This method is automatically called on table behaviors when the database * model is finished. It also override it to add columns to the current * table. + * + * @return void */ public function modifyTable() { - } /** diff --git a/src/Propel/Generator/Model/BehaviorableTrait.php b/src/Propel/Generator/Model/BehaviorableTrait.php index 6a38bddfda..f459c674f7 100644 --- a/src/Propel/Generator/Model/BehaviorableTrait.php +++ b/src/Propel/Generator/Model/BehaviorableTrait.php @@ -22,7 +22,7 @@ trait BehaviorableTrait private $behaviorLocator; /** - * @return GeneratorConfigInterface + * @return \Propel\Generator\Config\GeneratorConfigInterface */ abstract protected function getGeneratorConfig(); @@ -51,7 +51,7 @@ private function getBehaviorLocator() /** * Adds a new Behavior * - * @param $bdata + * @param array|\Propel\Generator\Model\Behavior $bdata * @throws BuildException when the added behavior is not an instance of \Propel\Generator\Model\Behavior * @return Behavior $bdata */ diff --git a/src/Propel/Generator/Model/Column.php b/src/Propel/Generator/Model/Column.php index c9ecd8b2ae..e33c8b43cb 100644 --- a/src/Propel/Generator/Model/Column.php +++ b/src/Propel/Generator/Model/Column.php @@ -92,14 +92,17 @@ class Column extends MappingModel // maybe this can be retrieved from vendor specific information private $needsTransactionInPostgres; + /** + * @var string[] + */ protected $valueSet; /** * Creates a new column and set the name. * - * @param string $name The column's name - * @param string $type The column's type - * @param string $size The column's size + * @param string|null $name The column's name + * @param string|null $type The column's type + * @param string|null $size The column's size */ public function __construct($name = null, $type = null, $size = null) { @@ -637,7 +640,7 @@ public function setPosition($position) /** * Sets the parent table. * - * @param Table $table + * @param \Propel\Generator\Model\Table $table */ public function setTable(Table $table) { @@ -1191,7 +1194,7 @@ public function isSetType() /** * Sets the list of possible values for an ENUM or SET column. * - * @param array|string + * @param string|string[] $valueSet */ public function setValueSet($valueSet) { @@ -1206,7 +1209,7 @@ public function setValueSet($valueSet) /** * Returns the list of possible values for an ENUM or SET column. * - * @return array + * @return string[] */ public function getValueSet() { @@ -1306,8 +1309,8 @@ public function getDefaultValueString() /** * Sets a string that will give this column a default value. * - * @param ColumnDefaultValue|mixed $defaultValue The column's default value - * @return Column + * @param ColumnDefaultValue|string $defaultValue The column's default value + * @return void */ public function setDefaultValue($defaultValue) { diff --git a/src/Propel/Generator/Model/CrossForeignKeys.php b/src/Propel/Generator/Model/CrossForeignKeys.php index 00d2d695a5..ea24e2ecba 100644 --- a/src/Propel/Generator/Model/CrossForeignKeys.php +++ b/src/Propel/Generator/Model/CrossForeignKeys.php @@ -215,7 +215,7 @@ public function getCrossForeignKeys() } /** - * @param Table $foreignTable + * @param \Propel\Generator\Model\Table $foreignTable */ public function setMiddleTable(Table $foreignTable) { @@ -233,7 +233,7 @@ public function getMiddleTable() } /** - * @param Table $table + * @param \Propel\Generator\Model\Table $table */ public function setTable(Table $table) { diff --git a/src/Propel/Generator/Model/Database.php b/src/Propel/Generator/Model/Database.php index 73a661c1af..9a817f5141 100644 --- a/src/Propel/Generator/Model/Database.php +++ b/src/Propel/Generator/Model/Database.php @@ -165,7 +165,7 @@ public function getPlatform() /** * Sets the PlatformInterface implementation for this database. * - * @param PlatformInterface $platform A Platform implementation + * @param PlatformInterface|null $platform A Platform implementation */ public function setPlatform(PlatformInterface $platform = null) { @@ -293,7 +293,7 @@ public function setDefaultPhpNamingMethod($strategy) /** * Returns the list of supported string formats * - * @return array + * @return string[] */ public static function getSupportedStringFormats() { @@ -722,7 +722,7 @@ public function getDomain($name) /** * Returns the GeneratorConfigInterface object. * - * @return GeneratorConfigInterface + * @return \Propel\Generator\Config\GeneratorConfigInterface */ public function getGeneratorConfig() { diff --git a/src/Propel/Generator/Model/Diff/DatabaseComparator.php b/src/Propel/Generator/Model/Diff/DatabaseComparator.php index c2016697d5..d72ce065d0 100644 --- a/src/Propel/Generator/Model/Diff/DatabaseComparator.php +++ b/src/Propel/Generator/Model/Diff/DatabaseComparator.php @@ -49,7 +49,7 @@ class DatabaseComparator protected $removeTable = true; /** - * @var array list of excluded tables + * @var string[] list of excluded tables */ protected $excludedTables = []; @@ -124,7 +124,7 @@ public function getRemoveTable() /** * Set the list of tables excluded from the comparison * - * @param array $excludedTables set the list of table name + * @param string[] $excludedTables set the list of table name */ public function setExcludedTables(array $excludedTables) { @@ -134,7 +134,7 @@ public function setExcludedTables(array $excludedTables) /** * Returns the list of tables excluded from the comparison * - * @return array + * @return string[] */ public function getExcludedTables() { @@ -268,7 +268,7 @@ public function compareTables($caseInsensitive = false) } /** - * @param Table $table + * @param \Propel\Generator\Model\Table $table * @return bool */ protected function isTableExcluded(Table $table) diff --git a/src/Propel/Generator/Model/Diff/DatabaseDiff.php b/src/Propel/Generator/Model/Diff/DatabaseDiff.php index 3bbfbf4690..467c59b285 100644 --- a/src/Propel/Generator/Model/Diff/DatabaseDiff.php +++ b/src/Propel/Generator/Model/Diff/DatabaseDiff.php @@ -20,10 +20,25 @@ */ class DatabaseDiff { + /** + * @var \Propel\Generator\Model\Table[] + */ protected $addedTables; + /** + * @var \Propel\Generator\Model\Table[] + */ protected $removedTables; + /** + * @var \Propel\Generator\Model\Diff\TableDiff[] + */ protected $modifiedTables; + /** + * @var string[] + */ protected $renamedTables; + /** + * @var string[] + */ protected $possibleRenamedTables; public function __construct() @@ -109,7 +124,8 @@ public function countAddedTables() * Returns an added table by its name. * * @param string $name - * @param Table + * + * @return \Propel\Generator\Model\Table */ public function getAddedTable($name) { @@ -119,7 +135,7 @@ public function getAddedTable($name) /** * Sets the removes tables. * - * @param array $tables + * @param \Propel\Generator\Model\Table[] $tables */ public function setRemovedTables($tables) { @@ -171,7 +187,8 @@ public function countRemovedTables() * Returns a removed table. * * @param string $name - * @param Table + * + * @return \Propel\Generator\Model\Table */ public function getRemovedTable($name) { @@ -181,7 +198,7 @@ public function getRemovedTable($name) /** * Sets the modified tables * - * @param array $tables + * @param \Propel\Generator\Model\Diff\TableDiff[] $tables */ public function setModifiedTables($tables) { @@ -222,7 +239,7 @@ public function getModifiedTables() /** * Sets the renamed tables. * - * @param array $tables + * @param string[] $tables */ public function setRenamedTables($tables) { @@ -243,7 +260,7 @@ public function addRenamedTable($fromName, $toName) /** * Returns the list of renamed tables. * - * @return array + * @return string[] */ public function getRenamedTables() { diff --git a/src/Propel/Generator/Model/Diff/TableComparator.php b/src/Propel/Generator/Model/Diff/TableComparator.php index bc7add9374..f8d32a4d2f 100644 --- a/src/Propel/Generator/Model/Diff/TableComparator.php +++ b/src/Propel/Generator/Model/Diff/TableComparator.php @@ -49,7 +49,7 @@ public function getTableDiff() /** * Sets the table the comparator starts from. * - * @param Table $fromTable + * @param \Propel\Generator\Model\Table $fromTable */ public function setFromTable(Table $fromTable) { @@ -69,7 +69,7 @@ public function getFromTable() /** * Sets the table the comparator goes to. * - * @param Table $toTable + * @param \Propel\Generator\Model\Table $toTable */ public function setToTable(Table $toTable) { diff --git a/src/Propel/Generator/Model/Diff/TableDiff.php b/src/Propel/Generator/Model/Diff/TableDiff.php index 0109be8822..54729cad01 100644 --- a/src/Propel/Generator/Model/Diff/TableDiff.php +++ b/src/Propel/Generator/Model/Diff/TableDiff.php @@ -40,21 +40,21 @@ class TableDiff /** * The list of added columns. * - * @var array + * @var Column[] */ protected $addedColumns; /** * The list of removed columns. * - * @var array + * @var Column[] */ protected $removedColumns; /** * The list of modified columns. * - * @var array + * @var ColumnDiff[] */ protected $modifiedColumns; @@ -68,14 +68,14 @@ class TableDiff /** * The list of added primary key columns. * - * @var array + * @var Column[] */ protected $addedPkColumns; /** * The list of removed primary key columns. * - * @var array + * @var Column[] */ protected $removedPkColumns; @@ -117,7 +117,7 @@ class TableDiff /** * The list of removed foreign keys. * - * @var array + * @var ForeignKey[] */ protected $removedFks; @@ -131,8 +131,8 @@ class TableDiff /** * Constructor. * - * @param Table $fromTable The first table - * @param Table $toTable The second table + * @param \Propel\Generator\Model\Table $fromTable The first table + * @param \Propel\Generator\Model\Table $toTable The second table */ public function __construct(Table $fromTable = null, Table $toTable = null) { @@ -162,7 +162,7 @@ public function __construct(Table $fromTable = null, Table $toTable = null) /** * Sets the fromTable property. * - * @param Table $fromTable + * @param \Propel\Generator\Model\Table $fromTable */ public function setFromTable(Table $fromTable) { @@ -182,7 +182,7 @@ public function getFromTable() /** * Sets the toTable property. * - * @param Table $toTable + * @param \Propel\Generator\Model\Table $toTable */ public function setToTable(Table $toTable) { @@ -256,6 +256,8 @@ public function getAddedColumn($columnName) if (isset($this->addedColumns[$columnName])) { return $this->addedColumns[$columnName]; } + + return null; } /** @@ -307,13 +309,15 @@ public function getRemovedColumns() * * @param string $columnName * - * @param Column + * @return Column|null */ public function getRemovedColumn($columnName) { if (isset($this->removedColumns[$columnName])) { return $this->removedColumns[$columnName]; } + + return null; } /** @@ -452,7 +456,7 @@ public function setRemovedPkColumns(array $removedPkColumns) * Add a removed Pk column * * @param string $columnName - * @param Column $removedColumn + * @param Column $removedPkColumn */ public function addRemovedPkColumn($columnName, Column $removedPkColumn) { @@ -695,7 +699,7 @@ public function setRemovedFks(array $removedFks) * Adds a removed foreign key column. * * @param string $fkName - * @param ForeignKey $removedColumn + * @param ForeignKey $removedFk */ public function addRemovedFk($fkName, ForeignKey $removedFk) { diff --git a/src/Propel/Generator/Model/Domain.php b/src/Propel/Generator/Model/Domain.php index 25da619fc5..2ea869f559 100644 --- a/src/Propel/Generator/Model/Domain.php +++ b/src/Propel/Generator/Model/Domain.php @@ -378,6 +378,7 @@ public function appendXml(\DOMNode $node) { $doc = ($node instanceof \DOMDocument) ? $node : $node->ownerDocument; + /** @var \DOMElement $domainNode */ $domainNode = $node->appendChild($doc->createElement('domain')); $domainNode->setAttribute('type', $this->getType()); $domainNode->setAttribute('name', $this->getName()); diff --git a/src/Propel/Generator/Model/ForeignKey.php b/src/Propel/Generator/Model/ForeignKey.php index 0337d413c7..cef46198ca 100644 --- a/src/Propel/Generator/Model/ForeignKey.php +++ b/src/Propel/Generator/Model/ForeignKey.php @@ -462,7 +462,7 @@ public function setForeignSchemaName($schemaName) /** * Sets the parent Table of the foreign key. * - * @param Table $parent + * @param \Propel\Generator\Model\Table $parent */ public function setTable(Table $parent) { diff --git a/src/Propel/Generator/Model/IdMethodParameter.php b/src/Propel/Generator/Model/IdMethodParameter.php index 2415da1f36..41c50d5edc 100644 --- a/src/Propel/Generator/Model/IdMethodParameter.php +++ b/src/Propel/Generator/Model/IdMethodParameter.php @@ -20,12 +20,24 @@ */ class IdMethodParameter extends MappingModel { + /** + * @var string + */ private $name; + + /** + * @var mixed + */ private $value; - /** @var Table */ + /** + * @var Table + */ private $parentTable; + /** + * @return void + */ protected function setupObject() { $this->name = $this->getAttribute('name'); @@ -35,7 +47,7 @@ protected function setupObject() /** * Returns the parameter name. * - * @param string + * @return string */ public function getName() { @@ -55,7 +67,7 @@ public function setName($name) /** * Returns the parameter value. * - * @param mixed + * @return mixed */ public function getValue() { @@ -75,7 +87,7 @@ public function setValue($value) /** * Sets the parent table. * - * @param Table $parent + * @param \Propel\Generator\Model\Table $parent */ public function setTable(Table $parent) { diff --git a/src/Propel/Generator/Model/Index.php b/src/Propel/Generator/Model/Index.php index 8538434159..c242c07dbd 100644 --- a/src/Propel/Generator/Model/Index.php +++ b/src/Propel/Generator/Model/Index.php @@ -146,7 +146,7 @@ public function getFQName() /** * Sets the index parent Table. * - * @param Table $table + * @param \Propel\Generator\Model\Table $table */ public function setTable(Table $table) { diff --git a/src/Propel/Generator/Model/MappingModel.php b/src/Propel/Generator/Model/MappingModel.php index 8db7eb68e6..6201162cc5 100644 --- a/src/Propel/Generator/Model/MappingModel.php +++ b/src/Propel/Generator/Model/MappingModel.php @@ -58,6 +58,8 @@ public function loadMapping(array $attributes) * This method must be implemented by children classes to hydrate and * configure the current object with the loaded mapping definition stored in * the protected $attributes array. + * + * @return void */ abstract protected function setupObject(); @@ -136,10 +138,10 @@ protected function getDefaultValueForArray($stringValue) } /** - * Converts the default string for set columns to an array. - * + * Converts the default string for set columns to an array. + * * @param string $stringValue - * + * * @return array|null */ protected function getDefaultValueForSet($stringValue) diff --git a/src/Propel/Generator/Model/Table.php b/src/Propel/Generator/Model/Table.php index e89316c3bb..c2781ee6eb 100644 --- a/src/Propel/Generator/Model/Table.php +++ b/src/Propel/Generator/Model/Table.php @@ -43,7 +43,15 @@ class Table extends ScopedMappingModel implements IdMethod * @var ForeignKey[] */ private $foreignKeys; + + /** + * @var ForeignKey[] + */ private $foreignKeysByName; + + /** + * @var string[] + */ private $foreignTableNames; /** @@ -442,7 +450,7 @@ protected function collectIndexedColumns($indexName, $columns, &$collectedIndexe * Returns a delimiter-delimited string list of column names. * * @see Platform::getColumnList() if quoting is required - * @param array + * @param array $columns * @param string $delimiter * @return string */ @@ -856,8 +864,8 @@ public function getOtherRequiredPrimaryKeys(array $primaryKeys) /** * Sets whether or not this table contains a foreign primary key. * - * @param $containsForeignPK - * @return boolean + * @param bool $containsForeignPK + * @return void */ public function setContainsForeignPK($containsForeignPK) { @@ -1010,7 +1018,7 @@ public function addUnique($unique) /** * Retrieves the configuration object. * - * @return GeneratorConfig + * @return \Propel\Generator\Config\GeneratorConfigInterface */ public function getGeneratorConfig() { @@ -1035,7 +1043,8 @@ public function hasAdditionalBuilders() /** * Get the early table behaviors - * @return Array of Behavior objects + * + * @return \Propel\Generator\Model\Behavior[] Array of Behavior objects */ public function getEarlyBehaviors() { @@ -1691,7 +1700,7 @@ public function getColumnByPhpName($phpName) * in argument. * * @param string $tableName - * @return array + * @return \Propel\Generator\Model\ForeignKey[] */ public function getForeignKeysReferencingTable($tableName) { @@ -1713,7 +1722,7 @@ public function getForeignKeysReferencingTable($tableName) * is either a, b or c. * * @param string $column Name of the column - * @return array + * @return \Propel\Generator\Model\ForeignKey[] */ public function getColumnForeignKeys($column) { diff --git a/src/Propel/Generator/Platform/DefaultPlatform.php b/src/Propel/Generator/Platform/DefaultPlatform.php index 9ec3b844d3..f4667baf08 100644 --- a/src/Propel/Generator/Platform/DefaultPlatform.php +++ b/src/Propel/Generator/Platform/DefaultPlatform.php @@ -38,7 +38,7 @@ class DefaultPlatform implements PlatformInterface /** * Mapping from Propel types to Domain objects. * - * @var array + * @var Domain[] */ protected $schemaDomainMap; @@ -200,7 +200,7 @@ public function isNativeIdMethodAutoIncrement() /** * Returns the database specific domain for a mapping type. * - * @param string + * @param string $mappingType * @return Domain */ public function getDomainForType($mappingType) @@ -293,7 +293,7 @@ public function getAddTablesDDL(Database $database) /** * Gets the requests to execute at the beginning of a DDL file * - * @return string + * @return string|null */ public function getBeginDDL() { @@ -302,7 +302,7 @@ public function getBeginDDL() /** * Gets the requests to execute at the end of a DDL file * - * @return string + * @return string|null */ public function getEndDDL() { @@ -437,8 +437,8 @@ public function getColumnDefaultValueDDL(Column $col) * echo $platform->getColumnListDDL(array('foo', 'bar'); * // '"foo","bar"' * - * @param array Column[] or string[] - * @param string $delim The delimiter to use in separating the column names. + * @param Column[] $columns + * @param string $delimiter The delimiter to use in separating the column names. * * @return string */ @@ -468,7 +468,7 @@ public function getPrimaryKeyName(Table $table) /** * Returns the SQL for the primary key of a Table object. * - * @return string + * @return string|null */ public function getPrimaryKeyDDL(Table $table) { @@ -1236,8 +1236,8 @@ public function supportsVarcharWithoutSize() * This function is used to set default column values when building * SQL. * - * @param mixed $tf A Boolean or string representation of Boolean ('y', 'true'). - * @return mixed + * @param mixed $b A Boolean or string representation of Boolean ('y', 'true'). + * @return string */ public function getBooleanString($b) { diff --git a/src/Propel/Generator/Platform/MssqlPlatform.php b/src/Propel/Generator/Platform/MssqlPlatform.php index 9813dc83cd..e5c39929b5 100644 --- a/src/Propel/Generator/Platform/MssqlPlatform.php +++ b/src/Propel/Generator/Platform/MssqlPlatform.php @@ -77,8 +77,8 @@ public function supportsInsertNullPk() /** * Returns the DDL SQL to add the tables of a database - * together with index and foreign keys. - * Since MSSQL always checks it the tables in foreign key definitions exist, + * together with index and foreign keys. + * Since MSSQL always checks it the tables in foreign key definitions exist, * the foreign key DDLs are moved after all tables are created * * @return string @@ -145,6 +145,11 @@ public function getDropTableDDL(Table $table) return $ret; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string|null + */ public function getPrimaryKeyDDL(Table $table) { if ($table->hasPrimaryKey()) { @@ -157,11 +162,17 @@ public function getPrimaryKeyDDL(Table $table) } } + /** + * @param \Propel\Generator\Model\ForeignKey $fk + * + * @return string|null + */ public function getAddForeignKeyDDL(ForeignKey $fk) { if ($fk->isSkipSql() || $fk->isPolymorphic()) { - return; + return null; } + $pattern = " BEGIN ALTER TABLE %s ADD %s @@ -190,11 +201,17 @@ public function getUniqueDDL(Unique $unique) ); } + /** + * @param \Propel\Generator\Model\ForeignKey $fk + * + * @return string|null + */ public function getForeignKeyDDL(ForeignKey $fk) { if ($fk->isSkipSql() || $fk->isPolymorphic()) { - return; + return null; } + $pattern = 'CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)'; $script = sprintf($pattern, $this->quoteIdentifier($fk->getName()), @@ -220,9 +237,15 @@ public function supportsSchemas() return true; } + /** + * @param string $sqlType + * + * @return bool + */ public function hasSize($sqlType) { $nosize = ['INT', 'TEXT', 'GEOMETRY', 'VARCHAR(MAX)', 'VARBINARY(MAX)', 'SMALLINT', 'DATETIME', 'TINYINT', 'REAL', 'BIGINT']; + return !(in_array($sqlType, $nosize)); } diff --git a/src/Propel/Generator/Platform/MysqlPlatform.php b/src/Propel/Generator/Platform/MysqlPlatform.php index 6e34fd7db0..1c52ff7866 100644 --- a/src/Propel/Generator/Platform/MysqlPlatform.php +++ b/src/Propel/Generator/Platform/MysqlPlatform.php @@ -118,7 +118,7 @@ public function getMaxColumnNameLength() public function supportsNativeDeleteTrigger() { - return strtolower($this->getDefaultTableEngine()) == 'innodb'; + return strtolower($this->getDefaultTableEngine()) === 'innodb'; } public function supportsIndexSize() @@ -137,7 +137,7 @@ public function supportsForeignKeys(Table $table) $mysqlTableType = $this->getDefaultTableEngine(); } - return strtolower($mysqlTableType) == 'innodb'; + return strtolower($mysqlTableType) === 'innodb'; } public function getAddTablesDDL(Database $database) @@ -177,7 +177,7 @@ public function getEndDDL() * * @param Table $table * - * @return string + * @return string|null */ public function getPrimaryKeyDDL(Table $table) { diff --git a/src/Propel/Generator/Platform/OraclePlatform.php b/src/Propel/Generator/Platform/OraclePlatform.php index ecdef9fcd2..a45cf3ecdf 100644 --- a/src/Propel/Generator/Platform/OraclePlatform.php +++ b/src/Propel/Generator/Platform/OraclePlatform.php @@ -30,7 +30,6 @@ */ class OraclePlatform extends DefaultPlatform { - /** * Initializes db specific domain mapping. */ @@ -192,6 +191,11 @@ public function getPrimaryKeyName(Table $table) return $tableName . '_pk'; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string|null + */ public function getPrimaryKeyDDL(Table $table) { if ($table->hasPrimaryKey()) { @@ -213,11 +217,17 @@ public function getUniqueDDL(Unique $unique) ); } + /** + * @param \Propel\Generator\Model\ForeignKey $fk + * + * @return string|null + */ public function getForeignKeyDDL(ForeignKey $fk) { if ($fk->isSkipSql() || $fk->isPolymorphic()) { - return; + return null; } + $pattern = "CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)"; $script = sprintf($pattern, diff --git a/src/Propel/Generator/Platform/PgsqlPlatform.php b/src/Propel/Generator/Platform/PgsqlPlatform.php index 067b6a578f..1811335e56 100755 --- a/src/Propel/Generator/Platform/PgsqlPlatform.php +++ b/src/Propel/Generator/Platform/PgsqlPlatform.php @@ -32,7 +32,6 @@ */ class PgsqlPlatform extends DefaultPlatform { - /** * @var string */ @@ -91,6 +90,11 @@ public function getMaxColumnNameLength() return 63; } + /** + * @param mixed $b + * + * @return string + */ public function getBooleanString($b) { // parent method does the checking for allows string @@ -263,7 +267,7 @@ public function getBeginDDL() BEGIN; "; } - + /** * @return string */ diff --git a/src/Propel/Generator/Platform/PlatformInterface.php b/src/Propel/Generator/Platform/PlatformInterface.php index 92f059bb87..e1744431bd 100644 --- a/src/Propel/Generator/Platform/PlatformInterface.php +++ b/src/Propel/Generator/Platform/PlatformInterface.php @@ -158,7 +158,7 @@ public function quote($text); * Quotes a identifier. * * @param string $text - * @return mixed + * @return string */ public function doQuoting($text); @@ -208,7 +208,7 @@ public function supportsVarcharWithoutSize(); * SQL. * * @param mixed $tf A boolean or string representation of boolean ('y', 'true'). - * @return mixed + * @return string */ public function getBooleanString($tf); diff --git a/src/Propel/Generator/Platform/SqlitePlatform.php b/src/Propel/Generator/Platform/SqlitePlatform.php index e82c20b074..fde9d5670a 100644 --- a/src/Propel/Generator/Platform/SqlitePlatform.php +++ b/src/Propel/Generator/Platform/SqlitePlatform.php @@ -33,7 +33,7 @@ class SqlitePlatform extends DefaultPlatform * If we should generate FOREIGN KEY statements. * This is since SQLite version 3.6.19 possible. * - * @var bool + * @var bool|null */ protected $foreignKeySupport = null; diff --git a/src/Propel/Generator/Platform/SqlsrvPlatform.php b/src/Propel/Generator/Platform/SqlsrvPlatform.php index 0ec53fe193..01039b1b49 100644 --- a/src/Propel/Generator/Platform/SqlsrvPlatform.php +++ b/src/Propel/Generator/Platform/SqlsrvPlatform.php @@ -19,6 +19,8 @@ class SqlsrvPlatform extends MssqlPlatform { /** * @see Platform#getMaxColumnNameLength() + * + * @return int */ public function getMaxColumnNameLength() { diff --git a/src/Propel/Generator/Reverse/MysqlSchemaParser.php b/src/Propel/Generator/Reverse/MysqlSchemaParser.php index 7d591a929c..9549415f24 100644 --- a/src/Propel/Generator/Reverse/MysqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/MysqlSchemaParser.php @@ -161,6 +161,7 @@ protected function parseTables(Database $database, $filterTable = null) */ protected function addColumns(Table $table) { + /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query(sprintf('SHOW COLUMNS FROM %s', $this->getPlatform()->doQuoting($table->getName()))); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { @@ -371,12 +372,13 @@ protected function addForeignKeys(Table $table) */ protected function addIndexes(Table $table) { + /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query(sprintf('SHOW INDEX FROM %s', $this->getPlatform()->doQuoting($table->getName()))); // Loop through the returned results, grouping the same key_name together // adding each column for that key. - /** @var $indexes Index[] */ + /** @var Index[] $indexes */ $indexes = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $colName = $row['Column_name']; @@ -421,6 +423,7 @@ protected function addIndexes(Table $table) */ protected function addPrimaryKey(Table $table) { + /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query(sprintf('SHOW KEYS FROM %s', $this->getPlatform()->doQuoting($table->getName()))); // Loop through the returned results, grouping the same key_name together @@ -442,6 +445,7 @@ protected function addPrimaryKey(Table $table) */ protected function addTableVendorInfo(Table $table) { + /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query("SHOW TABLE STATUS LIKE '" . $table->getName() . "'"); $row = $stmt->fetch(\PDO::FETCH_ASSOC); if (!$this->addVendorInfo) { diff --git a/src/Propel/Generator/Reverse/OracleSchemaParser.php b/src/Propel/Generator/Reverse/OracleSchemaParser.php index d780426b6f..5e932acb58 100644 --- a/src/Propel/Generator/Reverse/OracleSchemaParser.php +++ b/src/Propel/Generator/Reverse/OracleSchemaParser.php @@ -80,6 +80,7 @@ protected function getTypeMapping() public function parse(Database $database, array $additionalTables = []) { $tables = []; + /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query("SELECT OBJECT_NAME FROM USER_OBJECTS WHERE OBJECT_TYPE = 'TABLE'"); $seqPattern = $this->getGeneratorConfig()->get()['database']['adapters']['oracle']['autoincrementSequencePattern']; @@ -106,6 +107,7 @@ public function parse(Database $database, array $additionalTables = []) $seqName = str_replace('${table}', $table->getName(), $seqPattern); $seqName = strtoupper($seqName); + /** @var \PDOStatement $stmt2 */ $stmt2 = $this->dbh->query("SELECT * FROM USER_SEQUENCES WHERE SEQUENCE_NAME = '" . $seqName . "'"); $hasSeq = $stmt2->fetch(\PDO::FETCH_ASSOC); @@ -134,6 +136,7 @@ public function parse(Database $database, array $additionalTables = []) */ protected function addColumns(Table $table) { + /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query("SELECT COLUMN_NAME, DATA_TYPE, NULLABLE, DATA_LENGTH, DATA_PRECISION, DATA_SCALE, DATA_DEFAULT FROM USER_TAB_COLS WHERE TABLE_NAME = '" . $table->getName() . "'"); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { if (false !== strpos($row['COLUMN_NAME'], '$')) { @@ -195,6 +198,7 @@ protected function addColumns(Table $table) */ protected function addIndexes(Table $table) { + /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query("SELECT INDEX_NAME, COLUMN_NAME FROM USER_IND_COLUMNS WHERE TABLE_NAME = '" . $table->getName() . "' ORDER BY COLUMN_NAME"); $indices = []; @@ -237,8 +241,9 @@ protected function addForeignKeys(Table $table) $localReferenceInfo = $stmt2->fetch(\PDO::FETCH_ASSOC); // Foreign reference - $stmt2 = $this->dbh->query("SELECT TABLE_NAME, COLUMN_NAME FROM USER_CONS_COLUMNS WHERE CONSTRAINT_NAME = '".$row['R_CONSTRAINT_NAME']."'"); - $foreignReferenceInfo = $stmt2->fetch(\PDO::FETCH_ASSOC); + /** @var \PDOStatement $stmt3 */ + $stmt3 = $this->dbh->query("SELECT TABLE_NAME, COLUMN_NAME FROM USER_CONS_COLUMNS WHERE CONSTRAINT_NAME = '".$row['R_CONSTRAINT_NAME']."'"); + $foreignReferenceInfo = $stmt3->fetch(\PDO::FETCH_ASSOC); if (!isset($foreignKeys[$row['CONSTRAINT_NAME']])) { $fk = new ForeignKey($row['CONSTRAINT_NAME']); @@ -260,6 +265,7 @@ protected function addForeignKeys(Table $table) */ protected function addPrimaryKey(Table $table) { + /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query("SELECT COLS.COLUMN_NAME FROM USER_CONSTRAINTS CONS, USER_CONS_COLUMNS COLS WHERE CONS.CONSTRAINT_NAME = COLS.CONSTRAINT_NAME AND CONS.TABLE_NAME = '".$table->getName()."' AND CONS.CONSTRAINT_TYPE = 'P'"); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { // This fixes a strange behavior by PDO. Sometimes the diff --git a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php index 763c30481f..869b1d3810 100755 --- a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php @@ -150,6 +150,7 @@ protected function parseTables(&$tableWraps, Database $database, Table $filterTa $params[] = $filterTable->getCommonName(); } else if (!$database->getSchema()) { + /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query('SELECT schema_name FROM information_schema.schemata'); $searchPath = []; @@ -173,6 +174,8 @@ protected function parseTables(&$tableWraps, Database $database, Table $filterTa $sql .= " ORDER BY relname"; + + /** @var \PDOStatement $stmt */ $stmt = $this->dbh->prepare($sql); $stmt->execute($params); @@ -347,7 +350,7 @@ protected function isColumnDefaultExpression($default) return true; } - false; + return false; } /** diff --git a/src/Propel/Generator/Reverse/SqliteSchemaParser.php b/src/Propel/Generator/Reverse/SqliteSchemaParser.php index a295ddb045..c30275a9b6 100644 --- a/src/Propel/Generator/Reverse/SqliteSchemaParser.php +++ b/src/Propel/Generator/Reverse/SqliteSchemaParser.php @@ -176,7 +176,7 @@ protected function addColumns(Table $table) { $tableName = $table->getName(); -// var_dump("PRAGMA table_info('$tableName') //"); + /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query("PRAGMA table_info('$tableName')"); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { @@ -235,6 +235,7 @@ protected function addColumns(Table $table) if ($column->isPrimaryKey()) { // check if autoIncrement + /** @var \PDOStatement $autoIncrementStmt */ $autoIncrementStmt = $this->dbh->prepare(' SELECT tbl_name FROM sqlite_master @@ -258,6 +259,7 @@ protected function addForeignKeys(Table $table) { $database = $table->getDatabase(); + /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query('PRAGMA foreign_key_list("' . $table->getName() . '")'); $lastId = null; @@ -302,6 +304,7 @@ protected function addForeignKeys(Table $table) */ protected function addIndexes(Table $table) { + /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query('PRAGMA index_list("' . $table->getName() . '")'); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { @@ -314,6 +317,7 @@ protected function addIndexes(Table $table) $index = $row['unique'] ? new Unique($internalName) : new Index($internalName); + /** @var \PDOStatement $stmt2 */ $stmt2 = $this->dbh->query("PRAGMA index_info('".$name."')"); while ($row2 = $stmt2->fetch(\PDO::FETCH_ASSOC)) { $colname = $row2['name']; diff --git a/src/Propel/Generator/Schema/Dumper/XmlDumper.php b/src/Propel/Generator/Schema/Dumper/XmlDumper.php index 6a2b7b7873..1cce58f22a 100644 --- a/src/Propel/Generator/Schema/Dumper/XmlDumper.php +++ b/src/Propel/Generator/Schema/Dumper/XmlDumper.php @@ -92,6 +92,7 @@ public function dumpSchema(Schema $schema, $doFinalInitialization = true) */ private function appendDatabaseNode(Database $database, \DOMNode $parentNode) { + /** @var \DOMElement $databaseNode */ $databaseNode = $parentNode->appendChild($this->document->createElement('database')); $databaseNode->setAttribute('name', $database->getName()); $databaseNode->setAttribute('defaultIdMethod', $database->getDefaultIdMethod()); @@ -173,6 +174,7 @@ private function appendDatabaseNode(Database $database, \DOMNode $parentNode) */ private function appendVendorInformationNode(VendorInfo $vendorInfo, \DOMNode $parentNode) { + /** @var \DOMElement $vendorNode */ $vendorNode = $parentNode->appendChild($this->document->createElement('vendor')); $vendorNode->setAttribute('type', $vendorInfo->getType()); @@ -192,6 +194,7 @@ private function appendVendorInformationNode(VendorInfo $vendorInfo, \DOMNode $p */ private function appendTableNode(Table $table, \DOMNode $parentNode) { + /** @var \DOMElement $tableNode */ $tableNode = $parentNode->appendChild($this->document->createElement('table')); $tableNode->setAttribute('name', $table->getCommonName()); @@ -323,6 +326,7 @@ private function appendTableNode(Table $table, \DOMNode $parentNode) */ private function appendBehaviorNode(Behavior $behavior, \DOMNode $parentNode) { + /** @var \DOMElement $behaviorNode */ $behaviorNode = $parentNode->appendChild($this->document->createElement('behavior')); $behaviorNode->setAttribute('name', $behavior->getName()); @@ -345,6 +349,7 @@ private function appendBehaviorNode(Behavior $behavior, \DOMNode $parentNode) */ private function appendColumnNode(Column $column, \DOMNode $parentNode) { + /** @var \DOMElement $columnNode */ $columnNode = $parentNode->appendChild($this->document->createElement('column')); $columnNode->setAttribute('name', $column->getName()); @@ -417,6 +422,7 @@ private function appendColumnNode(Column $column, \DOMNode $parentNode) */ private function appendInheritanceNode(Inheritance $inheritance, \DOMNode $parentNode) { + /** @var \DOMElement $inheritanceNode */ $inheritanceNode = $parentNode->appendChild($this->document->createElement('inheritance')); $inheritanceNode->setAttribute('key', $inheritance->getKey()); $inheritanceNode->setAttribute('class', $inheritance->getClassName()); @@ -434,6 +440,7 @@ private function appendInheritanceNode(Inheritance $inheritance, \DOMNode $paren */ private function appendForeignKeyNode(ForeignKey $foreignKey, \DOMNode $parentNode) { + /** @var \DOMElement $foreignKeyNode */ $foreignKeyNode = $parentNode->appendChild($this->document->createElement('foreign-key')); $foreignKeyNode->setAttribute('foreignTable', $foreignKey->getForeignTableCommonName()); @@ -482,6 +489,7 @@ private function appendForeignKeyNode(ForeignKey $foreignKey, \DOMNode $parentNo */ private function appendIdMethodParameterNode(IdMethodParameter $parameter, \DOMNode $parentNode) { + /** @var \DOMElement $idMethodParameterNode */ $idMethodParameterNode = $parentNode->appendChild($this->document->createElement('id-method-parameter')); if ($name = $parameter->getName()) { $idMethodParameterNode->setAttribute('name', $name); @@ -503,7 +511,7 @@ private function appendIndexNode(Index $index, \DOMNode $parentNode) /** * Appends the generated XML node to its parent node. * - * @param Unique $unique The Unique model instance + * @param Unique $index The Unique model instance * @param \DOMNode $parentNode The parent DOMNode object */ private function appendUniqueIndexNode(Unique $index, \DOMNode $parentNode) @@ -520,6 +528,7 @@ private function appendUniqueIndexNode(Unique $index, \DOMNode $parentNode) */ private function appendGenericIndexNode($nodeType, Index $index, \DOMNode $parentNode) { + /** @var \DOMElement $indexNode */ $indexNode = $parentNode->appendChild($this->document->createElement($nodeType)); $indexNode->setAttribute('name', $index->getName()); diff --git a/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php b/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php index 31b8651e12..e38621331f 100644 --- a/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php @@ -57,7 +57,7 @@ public function getWith() * Sets the array of ModelWith specifying which objects must be hydrated * together with the main object. * - * @param array + * @param array $with * * @return $this|ModelCriteria The current object, for fluid interface */ diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index 76d0912896..d64b9e5150 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -358,14 +358,16 @@ public function getAsColumns() /** * Returns the column name associated with an alias (AS-column). * - * @param string $alias - * @return string $string + * @param string $as Alias + * @return string|null $string */ public function getColumnForAs($as) { if (isset($this->asColumns[$as])) { return $this->asColumns[$as]; } + + return null; } /** @@ -412,13 +414,15 @@ public function getAliases() * Returns the table name associated with an alias. * * @param string $alias - * @return string $string + * @return string|null $string */ public function getTableForAlias($alias) { if (isset($this->aliases[$alias])) { return $this->aliases[$alias]; } + + return null; } /** @@ -687,7 +691,7 @@ public function getPrimaryTableName() * any SELECT columns or WHERE columns. This must be explicitly * set, of course, in order to be useful. * - * @param string $v + * @param string $tableName */ public function setPrimaryTableName($tableName) { @@ -1837,7 +1841,7 @@ public function addUsingOperator($p1, $value = null, $operator = null, $preferCo * to be set before the statement is executed. The reason we do it this way * is to let the PDO layer handle all escaping & value formatting. * - * @param array &$params Parameters that are to be replaced in prepared statement. + * @param array $params Parameters that are to be replaced in prepared statement. * @return string * * @throws \Propel\Runtime\Exception\PropelException Trouble creating the query string. @@ -2444,7 +2448,7 @@ public function doUpdate($updateValues, ConnectionInterface $con) $stmt = $con->prepare($sql); // Replace ':p?' with the actual values - $db->bindValues($stmt, $params, $dbMap, $db); + $db->bindValues($stmt, $params, $dbMap); $stmt->execute(); diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php index 71df539b98..1c65457459 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php @@ -259,7 +259,7 @@ public function addOr(AbstractCriterion $criterion) * Appends a Prepared Statement representation of the Criterion * onto the buffer. * - * @param string &$sb The string that will receive the Prepared Statement + * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended * @return void * @throws PropelException - if the expression builder cannot figure out how to turn a specified @@ -292,7 +292,7 @@ public function __toString() /** * Appends a Prepared Statement representation of the Criterion onto the buffer * - * @param string &$sb The string that will receive the Prepared Statement + * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended */ abstract protected function appendPsForUniqueClauseTo(&$sb, array &$params); diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php index 0aa4c1e6dd..1385423bb6 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php @@ -61,7 +61,7 @@ public function isIgnoreCase() /** * Appends a Prepared Statement representation of the Criterion onto the buffer * - * @param string &$sb The string that will receive the Prepared Statement + * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php index 263a5b5d46..c987967c63 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php @@ -21,7 +21,7 @@ class BasicModelCriterion extends AbstractModelCriterion /** * Appends a Prepared Statement representation of the ModelCriterion onto the buffer * - * @param string &$sb The string that will receive the Prepared Statement + * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php index 7d7603a714..65181498a3 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php @@ -34,7 +34,7 @@ public function __construct(Criteria $outer, $column, $value, $comparison = Crit /** * Appends a Prepared Statement representation of the Criterion onto the buffer * - * @param string &$sb The string that will receive the Prepared Statement + * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php index 3dec30786e..1d7074d887 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php @@ -18,7 +18,7 @@ class BinaryModelCriterion extends AbstractModelCriterion /** * Appends a Prepared Statement representation of the ModelCriterion onto the buffer * - * @param string &$sb The string that will receive the Prepared Statement + * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) @@ -31,4 +31,4 @@ protected function appendPsForUniqueClauseTo(&$sb, array &$params) $sb .= (stripos($this->clause, '= 0') !== false) ? '1=1' : '1<>1'; } } -} \ No newline at end of file +} diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php index 2b7a3ad4c8..0ff4a5cb0d 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php @@ -32,7 +32,7 @@ public function __construct(Criteria $outer, $value) /** * Appends a Prepared Statement representation of the Criterion onto the buffer * - * @param string &$sb The string that will receive the Prepared Statement + * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php index 9a1208ff58..2ab41b4a37 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php @@ -34,7 +34,7 @@ public function __construct(Criteria $outer, $column, $value, $comparison = Crit /** * Appends a Prepared Statement representation of the Criterion onto the buffer * - * @param string &$sb The string that will receive the Prepared Statement + * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php index f62cde6e6b..84caad534a 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php @@ -19,7 +19,7 @@ class InModelCriterion extends AbstractModelCriterion /** * Appends a Prepared Statement representation of the ModelCriterion onto the buffer * - * @param string &$sb The string that will receive the Prepared Statement + * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php index 97c355379b..1013aa2cd1 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php @@ -61,7 +61,7 @@ public function isIgnoreCase() /** * Appends a Prepared Statement representation of the Criterion onto the buffer * - * @param string &$sb The string that will receive the Prepared Statement + * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php index 5040de3277..3234004437 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php @@ -49,7 +49,7 @@ public function isIgnoreCase() * Appends a Prepared Statement representation of the ModelCriterion onto the buffer * Handles case insensitivity for VARCHAR columns * - * @param string &$sb The string that will receive the Prepared Statement + * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php index d108a19305..6f6d9ce6f5 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php @@ -46,7 +46,7 @@ public function __construct(Criteria $outer, $column, $value, $type = PDO::PARAM /** * Appends a Prepared Statement representation of the Criterion onto the buffer * - * @param string &$sb The string that will receive the Prepared Statement + * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php index 65e607744d..d79374b3b3 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php @@ -47,7 +47,7 @@ public function __construct(Criteria $outer, $clause, $column, $value = null, $t /** * Appends a Prepared Statement representation of the ModelCriterion onto the buffer * - * @param string &$sb The string that will receive the Prepared Statement + * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php index 69b263ab4d..bb9606e61a 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php @@ -20,7 +20,7 @@ class SeveralModelCriterion extends AbstractModelCriterion /** * Appends a Prepared Statement representation of the ModelCriterion onto the buffer * - * @param string &$sb The string that will receive the Prepared Statement + * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) diff --git a/src/Propel/Runtime/ActiveQuery/Join.php b/src/Propel/Runtime/ActiveQuery/Join.php index 2b2e43058d..7a82745c7d 100644 --- a/src/Propel/Runtime/ActiveQuery/Join.php +++ b/src/Propel/Runtime/ActiveQuery/Join.php @@ -649,7 +649,7 @@ public function buildJoinCondition(Criteria $c) * // 'LEFT JOIN author ON (book.AUTHOR_ID=author.ID)' * * - * @param array &$params + * @param array $params * * @return string SQL join clause with join condition */ diff --git a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php index bd31fbee9d..b4c8a05808 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php @@ -2115,13 +2115,13 @@ public static function getShortName($fullyQualifiedClassName) * @see Criteria::add() * @param string $column The colName of column to run the condition on (e.g. BookTableMap::ID) * @param mixed $value - * @param string $operator A String, like Criteria::EQUAL. + * @param string|null $operator A String, like Criteria::EQUAL. * * @return $this|ModelCriteria A modified Criteria object. */ - public function addUsingAlias($p1, $value = null, $operator = null) + public function addUsingAlias($column, $value = null, $operator = null) { - return $this->addUsingOperator($this->getAliasedColName($p1), $value, $operator); + return $this->addUsingOperator($this->getAliasedColName($column), $value, $operator); } /** diff --git a/src/Propel/Runtime/ActiveQuery/PropelQuery.php b/src/Propel/Runtime/ActiveQuery/PropelQuery.php index 64af0d3aae..1822dcab0e 100644 --- a/src/Propel/Runtime/ActiveQuery/PropelQuery.php +++ b/src/Propel/Runtime/ActiveQuery/PropelQuery.php @@ -20,7 +20,7 @@ class PropelQuery { /** - * @param $queryClassAndAlias + * @param string $queryClassAndAlias * @return ModelCriteria * @throws \Propel\Runtime\Exception\ClassNotFoundException */ diff --git a/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php b/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php index 9bffc3e34a..f4a55f5d7a 100644 --- a/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php @@ -37,7 +37,7 @@ class OracleAdapter extends PdoAdapter implements SqlAdapterInterface * * @see parent::initConnection() * - * @param \PDO $con + * @param ConnectionInterface $con * @param array $settings */ public function initConnection(ConnectionInterface $con, array $settings) diff --git a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php index cdac51083a..2df6437a4c 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php @@ -300,8 +300,9 @@ public function getId(ConnectionInterface $con, $name = null) */ public function formatTemporalValue($value, ColumnMap $cMap) { - /** @var $dt PropelDateTime */ - if ($dt = PropelDateTime::newInstance($value)) { + /** @var PropelDateTime $dt */ + $dt = PropelDateTime::newInstance($value); + if ($dt) { switch ($cMap->getType()) { case PropelTypes::TIMESTAMP: case PropelTypes::BU_TIMESTAMP: @@ -341,6 +342,8 @@ public function getGroupBy(Criteria $criteria) if ($groupBy) { return ' GROUP BY ' . implode(',', $groupBy); } + + return ''; } /** diff --git a/src/Propel/Runtime/Collection/ArrayCollection.php b/src/Propel/Runtime/Collection/ArrayCollection.php index bd09425c7b..9f148fc03b 100644 --- a/src/Propel/Runtime/Collection/ArrayCollection.php +++ b/src/Propel/Runtime/Collection/ArrayCollection.php @@ -23,7 +23,7 @@ class ArrayCollection extends Collection { /** - * @var + * @var object */ protected $workerObject; diff --git a/src/Propel/Runtime/Collection/ObjectCollection.php b/src/Propel/Runtime/Collection/ObjectCollection.php index 36eb0cfbfa..eaa66e700b 100644 --- a/src/Propel/Runtime/Collection/ObjectCollection.php +++ b/src/Propel/Runtime/Collection/ObjectCollection.php @@ -66,7 +66,7 @@ public function save($con = null) $con = $this->getWriteConnection(); } $con->transaction(function () use ($con) { - /** @var $element ActiveRecordInterface */ + /** @var \Propel\Runtime\ActiveRecord\ActiveRecordInterface $element */ foreach ($this as $element) { $element->save($con); } @@ -87,7 +87,7 @@ public function delete($con = null) $con = $this->getWriteConnection(); } $con->transaction(function () use ($con) { - /** @var $element ActiveRecordInterface */ + /** @var \Propel\Runtime\ActiveRecord\ActiveRecordInterface $element */ foreach ($this as $element) { $element->delete($con); } @@ -104,10 +104,10 @@ public function getPrimaryKeys($usePrefix = true) { $ret = []; - /** @var $obj ActiveRecordInterface */ + /** @var \Propel\Runtime\ActiveRecord\ActiveRecordInterface $obj */ foreach ($this as $key => $obj) { $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; - $ret[$key]= $obj->getPrimaryKey(); + $ret[$key] = $obj->getPrimaryKey(); } return $ret; @@ -124,7 +124,7 @@ public function fromArray($arr) { $class = $this->getFullyQualifiedModel(); foreach ($arr as $element) { - /** @var $obj ActiveRecordInterface */ + /** @var \Propel\Runtime\ActiveRecord\ActiveRecordInterface $obj */ $obj = new $class(); $obj->fromArray($element); $this->append($obj); @@ -170,7 +170,7 @@ public function toArray($keyColumn = null, $usePrefix = false, $keyType = TableM $ret = []; $keyGetterMethod = 'get' . $keyColumn; - /** @var $obj ActiveRecordInterface */ + /** @var \Propel\Runtime\ActiveRecord\ActiveRecordInterface $obj */ foreach ($this->data as $key => $obj) { $key = null === $keyColumn ? $key : $obj->$keyGetterMethod(); $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; @@ -413,7 +413,7 @@ public function offsetUnset($offset) } /** - * @param $element + * @param mixed $element */ public function removeObject($element) { @@ -498,4 +498,4 @@ protected function getHashCode($object) return spl_object_hash($object); } -} \ No newline at end of file +} diff --git a/src/Propel/Runtime/Collection/ObjectCombinationCollection.php b/src/Propel/Runtime/Collection/ObjectCombinationCollection.php index 42fed41a4f..548873c37b 100644 --- a/src/Propel/Runtime/Collection/ObjectCombinationCollection.php +++ b/src/Propel/Runtime/Collection/ObjectCombinationCollection.php @@ -31,9 +31,9 @@ public function getPrimaryKeys($usePrefix = true) { $ret = []; - /** @var $obj ActiveRecordInterface */ foreach ($this as $combination) { $pkCombo = []; + /** @var \Propel\Runtime\ActiveRecord\ActiveRecordInterface $obj */ foreach ($combination as $key => $obj) { $pkCombo[$key] = $obj->getPrimaryKey(); } diff --git a/src/Propel/Runtime/Collection/OnDemandCollection.php b/src/Propel/Runtime/Collection/OnDemandCollection.php index 72d9b4d0e2..f4eaafb321 100644 --- a/src/Propel/Runtime/Collection/OnDemandCollection.php +++ b/src/Propel/Runtime/Collection/OnDemandCollection.php @@ -77,7 +77,7 @@ public function toArray($keyColumn = null, $usePrefix = false, $keyType = TableM $ret = []; $keyGetterMethod = 'get' . $keyColumn; - /** @var $obj ActiveRecordInterface */ + /** @var \Propel\Runtime\ActiveRecord\ActiveRecordInterface $obj */ foreach ($this as $key => $obj) { $key = null === $keyColumn ? $key : $obj->$keyGetterMethod(); $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; diff --git a/src/Propel/Runtime/Connection/ConnectionInterface.php b/src/Propel/Runtime/Connection/ConnectionInterface.php index 210a4921de..79d9841efc 100644 --- a/src/Propel/Runtime/Connection/ConnectionInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionInterface.php @@ -88,7 +88,7 @@ public function getAttribute($attribute); * @param string $attribute * @param mixed $value * - * @return boolean TRUE on success or FALSE on failure. + * @return bool TRUE on success or FALSE on failure. */ public function setAttribute($attribute, $value); @@ -112,14 +112,14 @@ public function setAttribute($attribute, $value); public function lastInsertId($name = null); /** - * @param $data + * @param mixed $data * * @return \Propel\Runtime\DataFetcher\DataFetcherInterface */ public function getSingleDataFetcher($data); /** - * @param $data + * @param mixed $data * * @return \Propel\Runtime\DataFetcher\DataFetcherInterface */ diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index 4eb7a78db0..3f287beeb2 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -331,6 +331,7 @@ public function getAttribute($attribute) * * @param string $attribute The attribute name, or the constant name containing the attribute name (e.g. 'PDO::ATTR_CASE') * @param mixed $value + * @return bool */ public function setAttribute($attribute, $value) { @@ -357,6 +358,8 @@ public function setAttribute($attribute, $value) default: $this->connection->setAttribute($attribute, $value); } + + return true; } /** @@ -538,7 +541,7 @@ public function getQueryCount() * * Returns the original number of queries (ie the value of $this->queryCount before calling this method). * - * @return integer + * @return void */ public function incrementQueryCount() { diff --git a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php index 658785897f..1bb99a4574 100644 --- a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php @@ -61,6 +61,7 @@ public function getProfiler() * * @param string $attribute The attribute name, or the constant name containing the attribute name (e.g. 'PDO::ATTR_CASE') * @param mixed $value + * @return bool */ public function setAttribute($attribute, $value) { @@ -69,9 +70,9 @@ public function setAttribute($attribute, $value) // Set whether the connection must only log slow queries. // The slow threshold must be set on the profiler (100ms by default). $this->isSlowOnly = $value; - break; + return true; default: - parent::setAttribute($attribute, $value); + return parent::setAttribute($attribute, $value); } } diff --git a/src/Propel/Runtime/Formatter/AbstractFormatter.php b/src/Propel/Runtime/Formatter/AbstractFormatter.php index a5cfcef513..38e402d621 100644 --- a/src/Propel/Runtime/Formatter/AbstractFormatter.php +++ b/src/Propel/Runtime/Formatter/AbstractFormatter.php @@ -181,7 +181,7 @@ protected function getCollection() */ public function getCollectionClassName() { - + return null; } /** diff --git a/src/Propel/Runtime/Map/ColumnMap.php b/src/Propel/Runtime/Map/ColumnMap.php index 1336775907..954c56b177 100644 --- a/src/Propel/Runtime/Map/ColumnMap.php +++ b/src/Propel/Runtime/Map/ColumnMap.php @@ -101,7 +101,7 @@ class ColumnMap * Constructor. * * @param string $name The name of the column. - * @param \Propel\Runtime\Map\TableMap containingTable TableMap of the table this column is in. + * @param \Propel\Runtime\Map\TableMap $containingTable TableMap of the table this column is in. */ public function __construct($name, TableMap $containingTable) { @@ -251,7 +251,7 @@ public function isNumeric() /** * Whether this column is of type set. - * + * * @return bool */ public function isSetType() diff --git a/src/Propel/Runtime/Map/RelationMap.php b/src/Propel/Runtime/Map/RelationMap.php index 75ee3396f4..4d0e9ee3b0 100644 --- a/src/Propel/Runtime/Map/RelationMap.php +++ b/src/Propel/Runtime/Map/RelationMap.php @@ -363,7 +363,7 @@ public function getOnDelete() /** * Gets the symmetrical relation * - * @return \Propel\Runtime\Map\RelationMap + * @return \Propel\Runtime\Map\RelationMap|null */ public function getSymmetricalRelation() { @@ -373,5 +373,7 @@ public function getSymmetricalRelation() return $relation; } } + + return null; } } diff --git a/src/Propel/Runtime/Parser/CsvParser.php b/src/Propel/Runtime/Parser/CsvParser.php index b10d4bd002..d44d8dd96f 100644 --- a/src/Propel/Runtime/Parser/CsvParser.php +++ b/src/Propel/Runtime/Parser/CsvParser.php @@ -145,6 +145,8 @@ protected function containsSpecialChars($input) return true; } } + + return false; } /** diff --git a/src/Propel/Runtime/Parser/XmlParser.php b/src/Propel/Runtime/Parser/XmlParser.php index 447b42f91a..e97f810d6a 100644 --- a/src/Propel/Runtime/Parser/XmlParser.php +++ b/src/Propel/Runtime/Parser/XmlParser.php @@ -170,6 +170,7 @@ protected function convertDOMElementToArray(\DOMNode $data) { $array = []; $elementNames = []; + /** @var \DOMElement $element */ foreach ($data->childNodes as $element) { if ($element->nodeType == XML_TEXT_NODE) { continue; diff --git a/src/Propel/Runtime/Propel.php b/src/Propel/Runtime/Propel.php index 347b20ee34..263f352e81 100644 --- a/src/Propel/Runtime/Propel.php +++ b/src/Propel/Runtime/Propel.php @@ -124,7 +124,7 @@ public static function getServiceContainer() /** * Set the service container instance. * - * @param \Propel\Runtime\ServiceContainer\ServiceContainerInterface + * @param \Propel\Runtime\ServiceContainer\ServiceContainerInterface $serviceContainer */ public static function setServiceContainer(ServiceContainerInterface $serviceContainer) { @@ -267,7 +267,7 @@ public static function getLogger() * @param string $message The message that will be logged. * @param int $level The logging level. * - * @return boolean True if the message was logged successfully or no logger was used. + * @return void */ public static function log($message, $level = self::LOG_DEBUG) { @@ -275,21 +275,28 @@ public static function log($message, $level = self::LOG_DEBUG) switch ($level) { case self::LOG_EMERG: - return $logger->emergency($message); + $logger->emergency($message); + break; case self::LOG_ALERT: - return $logger->alert($message); + $logger->alert($message); + break; case self::LOG_CRIT: - return $logger->critical($message); + $logger->critical($message); + break; case self::LOG_ERR: - return $logger->error($message); + $logger->error($message); + break; case self::LOG_WARNING: - return $logger->warning($message); + $logger->warning($message); + break; case self::LOG_NOTICE: - return $logger->notice($message); + $logger->notice($message); + break; case self::LOG_INFO: - return $logger->info($message); + $logger->info($message); + break; default: - return $logger->debug($message); + $logger->debug($message); } } diff --git a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php index 6f5616c487..080bb32b94 100644 --- a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php +++ b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php @@ -376,7 +376,7 @@ public function getReadConnection($name) * Shortcut to define a single connection for a datasource. * * @param string $name The datasource name - * @param \Propel\Runtime\Connection\ConnectionInterface A database connection + * @param \Propel\Runtime\Connection\ConnectionInterface $connection A database connection */ public function setConnection($name, ConnectionInterface $connection) { From 2da73874fadf7632cde3ff5377cb3a2da434d59f Mon Sep 17 00:00:00 2001 From: Zack Whedbee Date: Tue, 7 Jul 2020 09:56:44 -0700 Subject: [PATCH 067/208] Fix issue where propel reverse breaks with system-versioned tables (#1549) * Fix issue where propel reverse breaks with system-versioned tables MariaDB 10.3.4 introduced system-versioned tables (https://mariadb.com/kb/en/temporal-data-tables/). There is a known issue (possibly a bug) that can cause issues for ORM tools like Propel, described here: https://jira.mariadb.org/browse/MDEV-16857?focusedCommentId=117570&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-117570 "ORM tool will be confused as the primary key definition in the database doesn't match the one defined in application code after system versioning is enabled." Basically, system versioning creates an invisible primary key that shows up with "SHOW KEYS FROM table" but not with "SHOW COLUMNS FROM table". This PR fixes that by skipping these invisible primary key columns when generating the schema. Co-authored-by: Denis Turkov Co-authored-by: Mark Sch --- src/Propel/Generator/Reverse/MysqlSchemaParser.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Propel/Generator/Reverse/MysqlSchemaParser.php b/src/Propel/Generator/Reverse/MysqlSchemaParser.php index 7d591a929c..1a76b24267 100644 --- a/src/Propel/Generator/Reverse/MysqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/MysqlSchemaParser.php @@ -431,7 +431,10 @@ protected function addPrimaryKey(Table $table) continue; } $name = $row['Column_name']; - $table->getColumn($name)->setPrimaryKey(true); + $column = $table->getColumn($name); + if ($column) { + $column->setPrimaryKey(true); + } } } From e334d82141a23798315282b2b77fab6e57ad7ba2 Mon Sep 17 00:00:00 2001 From: Mark Sch Date: Wed, 8 Jul 2020 09:55:13 +0200 Subject: [PATCH 068/208] Update src/Propel/Common/Config/ConfigurationManager.php Co-authored-by: Brian Graham --- src/Propel/Common/Config/ConfigurationManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Common/Config/ConfigurationManager.php b/src/Propel/Common/Config/ConfigurationManager.php index 0e1b5be261..3b8fe63288 100644 --- a/src/Propel/Common/Config/ConfigurationManager.php +++ b/src/Propel/Common/Config/ConfigurationManager.php @@ -234,7 +234,7 @@ private function getFiles($dirs, $fileName, $dist = false) * @param string $fileName The configuration file * * @return array|mixed - * @throws \Symfony\Component\Config\Exception\LoaderLoadException + * @throws \Symfony\Component\Config\Exception\LoaderLoadException|\Symfony\Component\Config\Exception\FileLoaderLoadException */ private function loadFile($fileName) { From 6bd8afeca2667bd4ec31394c42e9937277d59f54 Mon Sep 17 00:00:00 2001 From: Mark Sch Date: Wed, 8 Jul 2020 11:03:34 +0200 Subject: [PATCH 069/208] Update src/Propel/Generator/Model/Behavior.php Co-authored-by: Brian Graham --- src/Propel/Generator/Model/Behavior.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Generator/Model/Behavior.php b/src/Propel/Generator/Model/Behavior.php index 9a1b574916..3411164d92 100644 --- a/src/Propel/Generator/Model/Behavior.php +++ b/src/Propel/Generator/Model/Behavior.php @@ -290,7 +290,7 @@ protected function getTables() /** * This method is automatically called on table behaviors when the database - * model is finished. It also override it to add columns to the current + * model is finished. Override this method to add columns to the current * table. * * @return void From 33edcd9dd1b1895a6fb6e762a12e11cb23779da1 Mon Sep 17 00:00:00 2001 From: Mark Sch Date: Wed, 8 Jul 2020 11:33:22 +0200 Subject: [PATCH 070/208] Remove nightly except one --- .travis.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 06d58c9691..0e44b50309 100644 --- a/.travis.yml +++ b/.travis.yml @@ -297,17 +297,6 @@ jobs: - COMPOSER=./tests/composer/composer-php8.json composer install - composer show - php: nightly - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-php8.json composer install - - composer show - - php: nightly - env: DB=sqlite - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-php8.json composer install - - composer show - name: "PHP 7.4, Agnostic, Symfony ~2.7" php: 7.4 From 5188fb41c3ca423245acf810da620a45aa8bf94c Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 8 Jul 2020 11:44:06 +0200 Subject: [PATCH 071/208] Remove dead file. Enable level 2 now. --- phpstan-baseline.neon | 640 ++++++++++++++++++ phpstan.neon | 2 +- src/Propel/Generator/Builder/Util/DataRow.php | 42 -- 3 files changed, 641 insertions(+), 43 deletions(-) delete mode 100644 src/Propel/Generator/Builder/Util/DataRow.php diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ea9316dfb6..96adc92a20 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,5 +1,195 @@ parameters: ignoreErrors: + - + message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\TreeBuilder\\:\\:root\\(\\)\\.$#" + count: 1 + path: src/Propel/Common/Config/PropelConfiguration.php + + - + message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:scalarNode\\(\\)\\.$#" + count: 4 + path: src/Propel/Common/Config/PropelConfiguration.php + + - + message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:requiresAtLeastOneElement\\(\\)\\.$#" + count: 1 + path: src/Propel/Common/Config/PropelConfiguration.php + + - + message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:booleanNode\\(\\)\\.$#" + count: 1 + path: src/Propel/Common/Config/PropelConfiguration.php + + - + message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:end\\(\\)\\.$#" + count: 1 + path: src/Propel/Common/Config/PropelConfiguration.php + + - + message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:arrayNode\\(\\)\\.$#" + count: 1 + path: src/Propel/Common/Config/PropelConfiguration.php + + - + message: "#^Access to an undefined property Propel\\\\Generator\\\\Model\\\\Table\\:\\:\\$isArchiveTable\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:isArchiveOnInsert\\(\\)\\.$#" + count: 4 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:isArchiveOnUpdate\\(\\)\\.$#" + count: 4 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:isArchiveOnDelete\\(\\)\\.$#" + count: 3 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php + + - + message: "#^Method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehaviorObjectBuilderModifier\\:\\:postInsert\\(\\) should return string\\|null but return statement is missing\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php + + - + message: "#^Method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehaviorObjectBuilderModifier\\:\\:postUpdate\\(\\) should return string\\|null but return statement is missing\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php + + - + message: "#^Method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehaviorObjectBuilderModifier\\:\\:preDelete\\(\\) should return string\\|null but return statement is missing\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getArchiveTablePhpName\\(\\)\\.$#" + count: 3 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getArchiveTableQueryName\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getArchivedAtColumn\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:hasArchiveClass\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:isArchiveOnUpdate\\(\\)\\.$#" + count: 3 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:isArchiveOnDelete\\(\\)\\.$#" + count: 3 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php + + - + message: "#^Method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehaviorQueryBuilderModifier\\:\\:preDeleteQuery\\(\\) should return string\\|null but return statement is missing\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php + + - + message: "#^Method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehaviorQueryBuilderModifier\\:\\:postUpdateQuery\\(\\) should return string\\|null but return statement is missing\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getArchiveTablePhpName\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php + + - + message: "#^Access to an undefined property Propel\\\\Generator\\\\Model\\\\ForeignKey\\:\\:\\$isParentChild\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:mergeParameters\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getParametersFromColumnName\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/I18n/I18nBehavior.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:removeParametersFromColumnName\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/I18n/I18nBehavior.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:addRuleOnPk\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/I18n/I18nBehavior.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:useScope\\(\\)\\.$#" + count: 15 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getScopes\\(\\)\\.$#" + count: 5 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:hasMultipleScopes\\(\\)\\.$#" + count: 3 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getColumnGetter\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getColumnSetter\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:generateScopePhp\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:useScope\\(\\)\\.$#" + count: 10 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:hasMultipleScopes\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getScopes\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:generateScopePhp\\(\\)\\.$#" + count: 5 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php + - message: "#^Variable \\$paramsDoc might not be defined\\.$#" count: 4 @@ -15,11 +205,66 @@ parameters: count: 1 path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:useScope\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:hasMultipleScopes\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getScopes\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php + + - + message: "#^Access to an undefined property Propel\\\\Generator\\\\Model\\\\Table\\:\\:\\$isVersionTable\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getVersionTable\\(\\)\\.$#" + count: 6 + path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php + + - + message: "#^Method Propel\\\\Generator\\\\Behavior\\\\Versionable\\\\VersionableBehaviorObjectBuilderModifier\\:\\:postDelete\\(\\) should return string\\|null but return statement is missing\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getVersionableFks\\(\\)\\.$#" + count: 3 + path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getVersionableReferrers\\(\\)\\.$#" + count: 3 + path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getReferrerIdsColumn\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getReferrerVersionsColumn\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php + - message: "#^Variable \\$col might not be defined\\.$#" count: 1 path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getVersionTable\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php + - message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addTemporalAccessor\\(\\)\\.$#" count: 1 @@ -135,11 +380,36 @@ parameters: count: 1 path: src/Propel/Generator/Builder/Om/ObjectBuilder.php + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getSequenceName\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/ObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:isNativeIdMethodAutoIncrement\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Builder/Om/ObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getIdentifierPhp\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Builder/Om/ObjectBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getSequenceName\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/TableMapBuilder.php + - message: "#^Parameter \\$definition of method Propel\\\\Generator\\\\Command\\\\Console\\\\Input\\\\ArrayInput\\:\\:__construct\\(\\) has invalid typehint type Propel\\\\Generator\\\\Command\\\\Console\\\\Input\\\\InputDefinition\\.$#" count: 1 path: src/Propel/Generator/Command/Console/Input/ArrayInput.php + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getModifyDatabaseDDL\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Command/MigrationDiffCommand.php + - message: "#^Variable \\$migration might not be defined\\.$#" count: 1 @@ -155,26 +425,181 @@ parameters: count: 1 path: src/Propel/Generator/Config/ArrayToPhpConverter.php + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Reverse\\\\SchemaParserInterface\\:\\:setMigrationTable\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Config/GeneratorConfig.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Manager/AbstractManager.php + - message: "#^Call to an undefined method Propel\\\\Generator\\\\Manager\\\\AbstractManager\\:\\:getLocation\\(\\)\\.$#" count: 1 path: src/Propel/Generator/Manager/AbstractManager.php + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getAddTableDDL\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Manager/MigrationManager.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\:\\:setChild\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Manager/ModelManager.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:getBuildConnection\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Manager/ReverseManager.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:getConnection\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Manager/ReverseManager.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getAddTablesDDL\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Manager/SqlManager.php + - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\ForeignKey\\:\\:getLocalForeignMapping\\(\\)\\.$#" count: 1 path: src/Propel/Generator/Model/ForeignKey.php + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:isEarly\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Model/Table.php + + - + message: "#^Method Propel\\\\Generator\\\\Model\\\\Table\\:\\:getFirstPrimaryKeyColumn\\(\\) should return Propel\\\\Generator\\\\Model\\\\Column but return statement is missing\\.$#" + count: 1 + path: src/Propel/Generator/Model/Table.php + + - + message: "#^Method Propel\\\\Generator\\\\Model\\\\Table\\:\\:getAutoIncrementPrimaryKey\\(\\) should return Propel\\\\Generator\\\\Model\\\\Column but return statement is missing\\.$#" + count: 1 + path: src/Propel/Generator/Model/Table.php + + - + message: "#^Method Propel\\\\Generator\\\\Platform\\\\DefaultPlatform\\:\\:getBeginDDL\\(\\) should return string\\|null but return statement is missing\\.$#" + count: 1 + path: src/Propel/Generator/Platform/DefaultPlatform.php + + - + message: "#^Method Propel\\\\Generator\\\\Platform\\\\DefaultPlatform\\:\\:getEndDDL\\(\\) should return string\\|null but return statement is missing\\.$#" + count: 1 + path: src/Propel/Generator/Platform/DefaultPlatform.php + + - + message: "#^Method Propel\\\\Generator\\\\Platform\\\\DefaultPlatform\\:\\:getPrimaryKeyDDL\\(\\) should return string\\|null but return statement is missing\\.$#" + count: 1 + path: src/Propel/Generator/Platform/DefaultPlatform.php + + - + message: "#^Method Propel\\\\Generator\\\\Platform\\\\MssqlPlatform\\:\\:getPrimaryKeyDDL\\(\\) should return string\\|null but return statement is missing\\.$#" + count: 1 + path: src/Propel/Generator/Platform/MssqlPlatform.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Platform/MysqlPlatform.php + + - + message: "#^Method Propel\\\\Generator\\\\Platform\\\\MysqlPlatform\\:\\:getPrimaryKeyDDL\\(\\) should return string\\|null but return statement is missing\\.$#" + count: 1 + path: src/Propel/Generator/Platform/MysqlPlatform.php + + - + message: "#^Method Propel\\\\Generator\\\\Platform\\\\OraclePlatform\\:\\:getAddPrimaryKeyDDL\\(\\) should return string but return statement is missing\\.$#" + count: 1 + path: src/Propel/Generator/Platform/OraclePlatform.php + + - + message: "#^Method Propel\\\\Generator\\\\Platform\\\\OraclePlatform\\:\\:getPrimaryKeyDDL\\(\\) should return string\\|null but return statement is missing\\.$#" + count: 1 + path: src/Propel/Generator/Platform/OraclePlatform.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\DataFetcher\\\\DataFetcherInterface\\:\\:setStyle\\(\\)\\.$#" + count: 3 + path: src/Propel/Generator/Reverse/MssqlSchemaParser.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Reverse/MysqlSchemaParser.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Reverse/OracleSchemaParser.php + + - + message: "#^Method Propel\\\\Runtime\\\\DataFetcher\\\\DataFetcherInterface\\:\\:fetch\\(\\) invoked with 1 parameter, 0 required\\.$#" + count: 2 + path: src/Propel/Generator/Reverse/OracleSchemaParser.php + - message: "#^Variable \\$strDefault might not be defined\\.$#" count: 1 path: src/Propel/Generator/Reverse/PgsqlSchemaParser.php + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Reverse/SqliteSchemaParser.php + - message: "#^Variable \\$fk might not be defined\\.$#" count: 1 path: src/Propel/Generator/Reverse/SqliteSchemaParser.php + - + message: "#^Call to an undefined method DOMNode\\:\\:setAttribute\\(\\)\\.$#" + count: 6 + path: src/Propel/Generator/Schema/Dumper/XmlDumper.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Util/BehaviorLocator.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ServiceContainer\\\\ServiceContainerInterface\\:\\:setAdapter\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Util/QuickBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ServiceContainer\\\\ServiceContainerInterface\\:\\:setConnection\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Util/QuickBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getModifyDatabaseDDL\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Util/QuickBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getAddTablesDDL\\(\\)\\.$#" + count: 1 + path: src/Propel/Generator/Util/QuickBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\:\\:build\\(\\)\\.$#" + count: 4 + path: src/Propel/Generator/Util/QuickBuilder.php + + - + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\:\\:setChild\\(\\)\\.$#" + count: 2 + path: src/Propel/Generator/Util/QuickBuilder.php + - message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\BaseModelCriteria\\:\\:\\$useAliasInSQL\\.$#" count: 1 @@ -190,6 +615,16 @@ parameters: count: 1 path: src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:createSelectSqlPart\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/Criteria.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:applyLimit\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/Criteria.php + - message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:\\$currentAlias\\.$#" count: 1 @@ -200,16 +635,91 @@ parameters: count: 1 path: src/Propel/Runtime/ActiveQuery/Criteria.php + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:cleanupSQL\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/Criteria.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:bindValues\\(\\)\\.$#" + count: 4 + path: src/Propel/Runtime/ActiveQuery/Criteria.php + - message: "#^Variable \\$sql might not be defined\\.$#" count: 3 path: src/Propel/Runtime/ActiveQuery/Criteria.php + - + message: "#^Call to private method getClauses\\(\\) of class Propel\\\\Runtime\\\\ActiveQuery\\\\Criterion\\\\AbstractCriterion\\.$#" + count: 2 + path: src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:ignoreCase\\(\\)\\.$#" + count: 2 + path: src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:ignoreCase\\(\\)\\.$#" + count: 2 + path: src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\Join\\:\\:getTableMap\\(\\)\\.$#" + count: 7 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\Join\\:\\:getRelationMap\\(\\)\\.$#" + count: 3 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:addSelfSelectColumns\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\Join\\:\\:getRelationAlias\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + + - + message: "#^Method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:preDelete\\(\\) should return int but return statement is missing\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + + - + message: "#^Method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:postDelete\\(\\) should return int but return statement is missing\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - message: "#^Variable \\$sql might not be defined\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - + message: "#^Method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:preUpdate\\(\\) should return int but return statement is missing\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + + - + message: "#^Method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:postUpdate\\(\\) should return int but return statement is missing\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:getTableMap\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\Criterion\\\\AbstractCriterion\\:\\:setIgnoreCase\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - message: "#^Variable \\$dbMap might not be defined\\.$#" count: 1 @@ -220,3 +730,133 @@ parameters: count: 1 path: src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Connection\\\\ConnectionInterface\\:\\:sqliteCreateFunction\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:clear\\(\\)\\.$#" + count: 2 + path: src/Propel/Runtime/Collection/ArrayCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:fromArray\\(\\)\\.$#" + count: 3 + path: src/Propel/Runtime/Collection/ArrayCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:isPrimaryKeyNull\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/ArrayCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:setNew\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/ArrayCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:save\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/ArrayCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:setDeleted\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/ArrayCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:delete\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/ArrayCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:toArray\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/ArrayCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:save\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/ObjectCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:delete\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/ObjectCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:getPrimaryKey\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/ObjectCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:fromArray\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/ObjectCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:toArray\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/ObjectCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:getPrimaryKey\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/ObjectCombinationCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:hashCode\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/ObjectCombinationCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:toArray\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/OnDemandCollection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Connection\\\\ConnectionWrapper\\:\\:getProfiler\\(\\)\\.$#" + count: 3 + path: src/Propel/Runtime/Connection/ProfilerStatementWrapper.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:toArray\\(\\)\\.$#" + count: 3 + path: src/Propel/Runtime/Formatter/ArrayFormatter.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:isPrimaryKeyNull\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Formatter/ArrayFormatter.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:getPrimaryKey\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Formatter/ObjectFormatter.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:isPrimaryKeyNull\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Formatter/OnDemandFormatter.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:setVirtualColumn\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Formatter/OnDemandFormatter.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:toArray\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Formatter/SimpleArrayFormatter.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:ignoreCase\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Map/ColumnMap.php + + - + message: "#^Access to an undefined property Symfony\\\\Component\\\\Validator\\\\Constraint\\:\\:\\$message\\.$#" + count: 2 + path: src/Propel/Runtime/Validator/Constraints/UniqueValidator.php + diff --git a/phpstan.neon b/phpstan.neon index 405dd30bc3..bebfdde0d4 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,7 @@ includes: - phpstan-baseline.neon parameters: - level: 1 + level: 2 paths: - '%rootDir%/../../../src/' excludes_analyse: diff --git a/src/Propel/Generator/Builder/Util/DataRow.php b/src/Propel/Generator/Builder/Util/DataRow.php deleted file mode 100644 index 806f8566d2..0000000000 --- a/src/Propel/Generator/Builder/Util/DataRow.php +++ /dev/null @@ -1,42 +0,0 @@ -table = $table; - $this->columnValues = $columnValues; - } - - public function getTable() - { - return $this->table; - } - - /** - * @return \Propel\Generator\Model\ColumnDefaultValue[] - */ - public function getColumnValues() - { - return $this->columnValues; - } -} From 0b933d4f1a694b0efa258a0db825b56b39b4e93c Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 8 Jul 2020 11:47:39 +0200 Subject: [PATCH 072/208] Set new ignore for symf2+ compatibility doc. --- phpstan.neon | 1 + 1 file changed, 1 insertion(+) diff --git a/phpstan.neon b/phpstan.neon index bebfdde0d4..412838c5ae 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -20,3 +20,4 @@ parameters: ignoreErrors: - '#Call to an undefined method .+Collection::.+Array\(\)#' - '#Class .+TreeBuilder constructor invoked with 0 parameters, 1-3 required#' + - '#PHPDoc tag @throws with type .+FileLoaderLoadException|.+LoaderLoadException is not subtype of Throwable#' From 0d50cd845b84f3674354c4ec4d541be6eb61a30a Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 8 Jul 2020 14:07:06 +0200 Subject: [PATCH 073/208] Get nightly to work for now using ignore-platform-reqs --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0e44b50309..6a5a329672 100644 --- a/.travis.yml +++ b/.travis.yml @@ -294,9 +294,8 @@ jobs: env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-php8.json composer install + - COMPOSER=./tests/composer/composer-php8.json composer install --ignore-platform-reqs - composer show - - php: nightly - name: "PHP 7.4, Agnostic, Symfony ~2.7" php: 7.4 From d7d2c493db6ed1d16061d3d572c505f188be61df Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 8 Jul 2020 16:08:37 +0200 Subject: [PATCH 074/208] Prepare for php8 pre check branch. --- tests/Propel/Tests/BookstoreLoggingTest.php | 2 +- tests/Propel/Tests/CharacterEncodingTest.php | 2 +- .../Common/Config/ConfigurationManagerTest.php | 4 ++-- .../Common/Config/Loader/FileLoaderTest.php | 2 +- .../Common/Config/Loader/IniFileLoaderTest.php | 2 +- .../Common/Config/Loader/JsonFileLoaderTest.php | 2 +- .../Common/Config/Loader/PhpFileLoaderTest.php | 2 +- .../Common/Config/Loader/XmlFileLoaderTest.php | 2 +- .../Common/Config/Loader/YamlFileLoaderTest.php | 2 +- .../AggregateColumnBehaviorTest.php | 2 +- ...chivableBehaviorObjectBuilderModifierTest.php | 2 +- ...rchivableBehaviorQueryBuilderModifierTest.php | 2 +- .../Archivable/ArchivableBehaviorTest.php | 2 +- .../Generator/Behavior/BehaviorLocatorTest.php | 16 ++++++++-------- .../ConcreteInheritanceBehaviorTest.php | 2 +- ...eritanceBehaviorWithBehaviorExclusionTest.php | 2 +- .../Behavior/Delegate/DelegateBehaviorTest.php | 2 +- .../I18nBehaviorObjectBuilderModifierTest.php | 2 +- .../I18nBehaviorQueryBuilderModifierTest.php | 2 +- .../Generator/Behavior/NestedSet/TestCase.php | 2 +- .../Generator/Behavior/ObjectBehaviorTest.php | 2 +- .../Behavior/QueryCache/QueryCacheTest.php | 16 ++++++++-------- .../Behavior/Sluggable/SluggableBehaviorTest.php | 2 +- ...SortableBehaviorObjectBuilderModifierTest.php | 2 +- ...ehaviorObjectBuilderModifierWithScopeTest.php | 2 +- .../SortableBehaviorQueryBuilderModifierTest.php | 2 +- ...BehaviorQueryBuilderModifierWithScopeTest.php | 2 +- ...ableBehaviorQueryUtilsBuilderModifierTest.php | 2 +- ...iorQueryUtilsBuilderModifierWithScopeTest.php | 2 +- .../SortableBehaviorWithEnumScopeTest.php | 2 +- .../SortableBehaviorWithSetScopeTest.php | 2 +- .../Generator/Behavior/TableBehaviorTest.php | 2 +- ...rsionableBehaviorQueryBuilderModifierTest.php | 2 +- .../Tests/Generator/Builder/NamespaceTest.php | 4 ++-- .../Om/AbstractOMBuilderRelatedByTest.php | 2 +- .../Om/GeneratedObjectArrayColumnTypeTest.php | 2 +- .../Om/GeneratedObjectBooleanColumnTypeTest.php | 2 +- .../Om/GeneratedObjectEnumColumnTypeTest.php | 2 +- .../Om/GeneratedObjectJsonColumnTypeTest.php | 14 +++++++------- .../Builder/Om/GeneratedObjectLazyLoadTest.php | 2 +- .../Builder/Om/GeneratedObjectLobTest.php | 2 +- .../Om/GeneratedObjectM2MRelationSimpleTest.php | 4 ++-- .../GeneratedObjectM2MRelationThreePKs2Test.php | 4 ++-- .../GeneratedObjectM2MRelationThreePKsTest.php | 4 ++-- .../Om/GeneratedObjectMoreRelationTest.php | 2 +- .../Om/GeneratedObjectSetColumnTypeTest.php | 8 ++++---- .../Om/GeneratedObjectTemporalColumnTypeTest.php | 2 +- ...GeneratedObjectWithDateImmutableClassTest.php | 2 +- .../Om/GeneratedObjectWithInterfaceTest.php | 2 +- .../Om/GeneratedPKLessQueryBuilderTest.php | 2 +- .../Builder/Om/GeneratedPKLessTableMapTest.php | 2 +- .../Om/GeneratedQueryArrayColumnTypeTest.php | 2 +- .../Builder/Om/GeneratedQueryDoDeleteTest.php | 2 +- .../Builder/Om/GeneratedQueryDoSelectTest.php | 2 +- .../Om/GeneratedQueryEnumColumnTypeTest.php | 2 +- .../Om/GeneratedQueryObjectColumnTypeTest.php | 2 +- .../Om/GeneratedQuerySetColumnTypeTest.php | 4 ++-- .../Om/GeneratedTableMapEnumColumnTypeTest.php | 2 +- .../Builder/Om/GeneratedTableMapLazyLoadTest.php | 2 +- .../Om/GeneratedTableMapSetColumnTypeTest.php | 2 +- .../Generator/Builder/Om/ObjectBuilderTest.php | 2 +- .../Builder/Om/PoisonedCacheBugTest.php | 2 +- .../Generator/Builder/Om/QueryBuilderTest.php | 2 +- .../Generator/Builder/Om/TableMapBuilderTest.php | 2 +- .../Generator/Builder/Util/SchemaReaderTest.php | 4 ++-- .../Generator/Command/AbstractCommandTest.php | 2 +- .../Tests/Generator/Command/InitCommandTest.php | 2 +- .../Tests/Generator/Command/MigrationTest.php | 2 +- .../Generator/Config/GeneratorConfigTest.php | 2 +- .../Config/QuickGeneratorConfigTest.php | 2 +- .../Generator/Migration/MigrationTestCase.php | 2 +- .../Model/Diff/ColumnComparatorTest.php | 2 +- .../Model/Diff/DatabaseTableComparatorTest.php | 2 +- .../Diff/PropelTableColumnComparatorTest.php | 2 +- .../Diff/PropelTableForeignKeyComparatorTest.php | 2 +- .../Diff/PropelTableIndexComparatorTest.php | 2 +- .../Diff/PropelTablePkColumnComparatorTest.php | 2 +- .../Tests/Generator/Model/NameFactoryTest.php | 2 +- .../Generator/Platform/DefaultPlatformTest.php | 2 +- .../Generator/Reverse/PgsqlSchemaParserTest.php | 4 ++-- .../Generator/Schema/Dumper/XmlDumperTest.php | 4 ++-- .../Helpers/Bookstore/BookstoreEmptyTestBase.php | 2 +- .../Helpers/Bookstore/BookstoreTestBase.php | 4 ++-- .../Helpers/Namespaces/NamespacesTestBase.php | 4 ++-- .../Helpers/PlatformDatabaseBuildTimeBase.php | 2 +- tests/Propel/Tests/Issues/Issue1033Test.php | 4 ++-- tests/Propel/Tests/Issues/Issue1192Test.php | 2 +- tests/Propel/Tests/Issues/Issue1463Test.php | 2 +- tests/Propel/Tests/Issues/Issue617Test.php | 4 ++-- tests/Propel/Tests/Issues/Issue646Test.php | 4 ++-- tests/Propel/Tests/Issues/Issue656Test.php | 4 ++-- tests/Propel/Tests/Issues/Issue733Test.php | 8 ++++---- tests/Propel/Tests/Issues/Issue768Test.php | 2 +- tests/Propel/Tests/Issues/Issue829Test.php | 2 +- tests/Propel/Tests/Issues/Issue915Test.php | 2 +- tests/Propel/Tests/Issues/Issue989Test.php | 14 +++++++------- .../Runtime/ActiveQuery/CriteriaCombineTest.php | 4 ++-- .../Tests/Runtime/ActiveQuery/CriteriaTest.php | 2 +- .../Tests/Runtime/ActiveQuery/JoinTest.php | 4 ++-- .../ActiveQuery/ModelCriteriaHooksTest.php | 2 +- .../Runtime/ActiveQuery/PropelQueryTest.php | 4 ++-- .../Tests/Runtime/ActiveQuery/SubQueryTest.php | 2 +- .../Tests/Runtime/ActiveRecordConvertTest.php | 2 +- tests/Propel/Tests/Runtime/ActiveRecordTest.php | 2 +- .../Runtime/Adapter/Pdo/MssqlAdapterTest.php | 4 ++-- .../Runtime/Collection/ArrayCollectionTest.php | 2 +- .../Runtime/Collection/CollectionConvertTest.php | 2 +- .../ObjectCollectionWithFixturesTest.php | 2 +- .../Collection/OnDemandCollectionTest.php | 4 ++-- .../Runtime/Collection/OnDemandIteratorTest.php | 2 +- .../Tests/Runtime/Connection/PropelPDOTest.php | 4 ++-- .../Runtime/Formatter/ArrayFormatterTest.php | 2 +- .../Tests/Runtime/Formatter/DataFetcherTest.php | 2 +- .../Formatter/ObjectFormatterInheritanceTest.php | 2 +- .../Runtime/Formatter/ObjectFormatterTest.php | 2 +- .../Formatter/SimpleArrayFormatterTest.php | 2 +- .../Runtime/Formatter/StatementFormatterTest.php | 2 +- tests/Propel/Tests/Runtime/Map/ColumnMapTest.php | 4 ++-- .../Propel/Tests/Runtime/Map/DatabaseMapTest.php | 4 ++-- .../Runtime/Map/GeneratedRelationMapTest.php | 2 +- .../Map/GeneratedRelationMapWithSchemasTest.php | 2 +- .../Runtime/Map/RelatedMapSymmetricalTest.php | 2 +- .../Map/RelatedMapSymmetricalWithSchemasTest.php | 2 +- .../Propel/Tests/Runtime/Map/RelationMapTest.php | 2 +- tests/Propel/Tests/Runtime/Map/TableMapTest.php | 4 ++-- .../StandardServiceContainerTest.php | 4 ++-- tests/Propel/Tests/TestCaseFixtures.php | 5 ++--- 127 files changed, 185 insertions(+), 186 deletions(-) diff --git a/tests/Propel/Tests/BookstoreLoggingTest.php b/tests/Propel/Tests/BookstoreLoggingTest.php index b30939f476..5494afea3a 100644 --- a/tests/Propel/Tests/BookstoreLoggingTest.php +++ b/tests/Propel/Tests/BookstoreLoggingTest.php @@ -32,7 +32,7 @@ */ class BookstoreLoggingTest extends BookstoreEmptyTestBase { - public function setUp() + public function setUp(): void { parent::setUp(); PolymorphicRelationLogQuery::create()->deleteAll(); diff --git a/tests/Propel/Tests/CharacterEncodingTest.php b/tests/Propel/Tests/CharacterEncodingTest.php index 0ca88ff090..a0b2317bf9 100644 --- a/tests/Propel/Tests/CharacterEncodingTest.php +++ b/tests/Propel/Tests/CharacterEncodingTest.php @@ -47,7 +47,7 @@ class CharacterEncodingTest extends BookstoreTestBase */ private $adapter; - public function setUp() + public function setUp(): void { parent::setUp(); if (!extension_loaded('iconv')) { diff --git a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php index 410380ea5e..317b24c5b1 100644 --- a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php +++ b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php @@ -26,7 +26,7 @@ class ConfigurationManagerTest extends ConfigTestCase */ private $fixturesDir; - public function setUp() + public function setUp(): void { $this->currentDir = getcwd(); $this->fixturesDir = realpath( __DIR__ . '/../../../../Fixtures') . '/Configuration'; @@ -35,7 +35,7 @@ public function setUp() chdir($this->fixturesDir); } - public function tearDown() + public function tearDown(): void { chdir($this->currentDir); $this->getFileSystem()->remove($this->fixturesDir); diff --git a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php index 3bfa705cbb..368c65f5c7 100644 --- a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php @@ -17,7 +17,7 @@ class FileLoaderTest extends TestCase { private $loader; - public function setUp() + public function setUp(): void { $this->loader = new TestableFileLoader(); } diff --git a/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php index b7f2067997..5ebadba607 100644 --- a/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php @@ -18,7 +18,7 @@ class IniFileLoaderTest extends ConfigTestCase { protected $loader; - protected function setUp() + protected function setUp(): void { $this->loader = new IniFileLoader(new FileLocator(sys_get_temp_dir())); } diff --git a/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php index cb1b8a6f48..7281d1ea06 100644 --- a/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php @@ -18,7 +18,7 @@ class JsonFileLoaderTest extends ConfigTestCase { protected $loader; - protected function setUp() + protected function setUp(): void { $this->loader = new JsonFileLoader(new FileLocator(sys_get_temp_dir())); } diff --git a/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php index afec09044b..3aeb4319f0 100644 --- a/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php @@ -18,7 +18,7 @@ class PhpFileLoaderTest extends ConfigTestCase { protected $loader; - protected function setUp() + protected function setUp(): void { $this->loader = new PhpFileLoader(new FileLocator(sys_get_temp_dir())); } diff --git a/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php index 8299513fcf..e12dddfb78 100644 --- a/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php @@ -18,7 +18,7 @@ class XmlFileLoaderTest extends ConfigTestCase { protected $loader; - protected function setUp() + protected function setUp(): void { $this->loader = new XmlFileLoader(new FileLocator(sys_get_temp_dir())); } diff --git a/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php index 5b3eb1514d..72731c822d 100644 --- a/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php @@ -19,7 +19,7 @@ class YamlFileLoaderTest extends ConfigTestCase { protected $loader; - protected function setUp() + protected function setUp(): void { $this->loader = new YamlFileLoader(new FileLocator(sys_get_temp_dir())); } diff --git a/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnBehaviorTest.php index 37a879a835..e7f64c93db 100644 --- a/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnBehaviorTest.php @@ -33,7 +33,7 @@ */ class AggregateColumnBehaviorTest extends BookstoreTestBase { - protected function setUp() + protected function setUp(): void { parent::setUp(); include_once(__DIR__.'/AggregateColumnsBehaviorTestClasses.php'); diff --git a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php index 71c6d5706d..2540b7a34d 100644 --- a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php @@ -24,7 +24,7 @@ */ class ArchivableBehaviorObjectBuilderModifierTest extends TestCase { - public function setUp() + public function setUp(): void { if (!class_exists('\ArchivableTest10')) { $schema = <<getBehaviors(); $this->assertSame(1, count($behaviors)); - + $this->assertTrue(array_key_exists('l10n', $behaviors)); $this->assertSame('gossi/propel-l10n-behavior', $behaviors['l10n']['package']); - + // test class name $this->assertSame('\\gossi\\propel\\behavior\\l10n\\L10nBehavior', $locator->getBehavior('l10n')); } - + public function testBehaviorLocatorWithComposerJson() { $configOptions['propel']['paths']['composerDir'] = __DIR__ . '/../../../../Fixtures/behavior-development'; $config = new QuickGeneratorConfig($configOptions); $locator = new BehaviorLocator($config); - + // test found behaviors $behaviors = $locator->getBehaviors(); $this->assertSame(1, count($behaviors)); - + $this->assertTrue(array_key_exists('collection', $behaviors)); $this->assertSame('propel/collection-behavior', $behaviors['collection']['package']); - + // test class name $this->assertSame('\\Propel\\Behavior\\Collection\\CollectionBehavior', $locator->getBehavior('collection')); } diff --git a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorTest.php index c2bd4bc13e..4c237873af 100644 --- a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorTest.php @@ -40,7 +40,7 @@ */ class ConcreteInheritanceBehaviorTest extends BookstoreTestBase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithBehaviorExclusionTest.php b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithBehaviorExclusionTest.php index ce870cbdb0..733930b490 100644 --- a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithBehaviorExclusionTest.php +++ b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithBehaviorExclusionTest.php @@ -22,7 +22,7 @@ */ class ConcreteInheritanceBehaviorWithBehaviorExclusionTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php index 846b8dafce..f31fda22e5 100644 --- a/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php @@ -24,7 +24,7 @@ class DelegateBehaviorTest extends TestCase { - public function setUp() + public function setUp(): void { if (!class_exists('DelegateDelegate')) { $schema = <<assertEquals($expectedSql, $renderedSql); } - + public function testWithPaginate() { QuerycacheTable1Query::create()->deleteAll(); @@ -92,19 +92,19 @@ public function testWithPaginate() $coll[]= $b; } $coll->save(); - + $pager = $this->getPager(2, 1); $this->assertEquals(5, $pager->getNbResults()); - + $results = $pager->getResults(); $this->assertEquals('query cache with paginate offset 0 limit 2', $pager->getQuery()->getQueryKey()); $this->assertEquals(2, count($results)); $this->assertEquals('Title1', $results[1]->getTitle()); - + //jump to page 3 $pager = $this->getPager(2, 3); $this->assertEquals(5, $pager->getNbResults()); - + $results = $pager->getResults(); $this->assertEquals('query cache with paginate offset 4 limit 2', $pager->getQuery()->getQueryKey()); $this->assertEquals(1, count($results)); @@ -123,13 +123,13 @@ public function testQueryIsNotCachedIfExceptionIsThrown() $this->assertNull($q->cacheFetch('test4'), 'The query is not cached, if it has thrown exception'); } - + protected function getPager($maxPerPage, $page = 1) { $query = QuerycacheTable1Query::create() ->setQueryKey('query cache with paginate') ->orderByTitle(); - + $pager = new PropelModelPager($query, $maxPerPage); $pager->setPage($page); $pager->init(); diff --git a/tests/Propel/Tests/Generator/Behavior/Sluggable/SluggableBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Sluggable/SluggableBehaviorTest.php index c9178681b5..6aa82c99c1 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sluggable/SluggableBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sluggable/SluggableBehaviorTest.php @@ -33,7 +33,7 @@ */ class SluggableBehaviorTest extends BookstoreTestBase { - protected function setUp() + protected function setUp(): void { //prevent issue DSN not Found self::$isInitialized = false; diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierTest.php index ad44b3154e..0c04400542 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierTest.php @@ -23,7 +23,7 @@ */ class SortableBehaviorObjectBuilderModifierTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php index c264c00d70..0cb8c33a1a 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php @@ -28,7 +28,7 @@ */ class SortableBehaviorObjectBuilderModifierWithScopeTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierTest.php index 4ccc9bd230..a905d4bed5 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierTest.php @@ -26,7 +26,7 @@ */ class SortableBehaviorQueryBuilderModifierTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierWithScopeTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierWithScopeTest.php index 6dd42a6c0e..72cb7090ec 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierWithScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierWithScopeTest.php @@ -26,7 +26,7 @@ */ class SortableBehaviorQueryBuilderModifierWithScopeTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierTest.php index 26ee94a8ff..905212a684 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierTest.php @@ -24,7 +24,7 @@ */ class SortableBehaviorQueryUtilsBuilderModifierTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierWithScopeTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierWithScopeTest.php index 8ec9c0566d..24d0928ca7 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierWithScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierWithScopeTest.php @@ -24,7 +24,7 @@ */ class SortableBehaviorQueryUtilsBuilderModifierWithScopeTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithEnumScopeTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithEnumScopeTest.php index fb789c9203..1ed6036b3b 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithEnumScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithEnumScopeTest.php @@ -23,7 +23,7 @@ */ class SortableBehaviorWithEnumScopeTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithSetScopeTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithSetScopeTest.php index 479662a1f1..1e0e051c4e 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithSetScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithSetScopeTest.php @@ -21,7 +21,7 @@ */ class SortableBehaviorWithSetScopeTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Propel/Tests/Generator/Behavior/TableBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/TableBehaviorTest.php index c8cb5061cd..7aeaa336f4 100644 --- a/tests/Propel/Tests/Generator/Behavior/TableBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/TableBehaviorTest.php @@ -20,7 +20,7 @@ */ class TableBehaviorTest extends TestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); } diff --git a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifierTest.php index 9f8ffa7b1d..031918fa60 100644 --- a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifierTest.php @@ -19,7 +19,7 @@ */ class VersionableBehaviorQueryBuilderModifierTest extends TestCase { - public function setUp() + public function setUp(): void { if (!class_exists('VersionableBehaviorTest10')) { $schema = <<setBar(null); $this->assertNull($e->getBar()); } - + public function testIsModified() { $this->assertTrue(method_exists('ComplexColumnTypeJsonEntity', 'setBar')); @@ -77,24 +77,24 @@ public function testIsModified() 'key' => 'value' )); $this->assertTrue($e->isModified()); - + $e = new \PublicComplexColumnTypeJsonEntity(); $e->setBar(array( 'defaultKey' => 'defaultValue' )); $this->assertFalse($e->isModified()); - + $e->setBar('{"defaultKey":"defaultValue"}'); $this->assertFalse($e->isModified()); - + $e->setBar('{"defaultKey" : "defaultValue"}'); $this->assertFalse($e->isModified()); - + $e->setBar((object)array( 'defaultKey' => 'defaultValue' )); $this->assertFalse($e->isModified()); - + $e->setBar((object)array( 'key' => 'value' )); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLazyLoadTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLazyLoadTest.php index debab70f27..d5b177f080 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLazyLoadTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLazyLoadTest.php @@ -21,7 +21,7 @@ */ class GeneratedObjectLazyLoadTest extends TestCase { - public function setUp() + public function setUp(): void { if (!class_exists('LazyLoadActiveRecord')) { $schema = <<assertEquals($friend1, \Relation1UserQuery::create()->filterByWho($hans)->findOne(), 'Hans has Friend 1 as friend'); } -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKs2Test.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKs2Test.php index 40f156ad35..f8f138c79c 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKs2Test.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKs2Test.php @@ -19,7 +19,7 @@ class GeneratedObjectM2MRelationThreePKs2Test extends PlatformDatabaseBuildTimeB { protected $databaseName = 'migration'; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -557,4 +557,4 @@ public function test11_12(){ $this->assertEquals('chef', $userGroup->getPosition()); $this->assertEquals($cleaner->getId(), $userGroup->getGroupId()); } -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKsTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKsTest.php index 6b020b4c36..a411a280fa 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKsTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKsTest.php @@ -17,7 +17,7 @@ class GeneratedObjectM2MRelationThreePKsTest extends PlatformDatabaseBuildTimeBa { protected $databaseName = 'migration'; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -861,4 +861,4 @@ public function testRelationThree6() $this->assertEquals(0, \Relation6UserQuery::create()->filterByGroup($admins)->count(), 'Hans has zero groups.'); } -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectMoreRelationTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectMoreRelationTest.php index 0715013e67..d48604419c 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectMoreRelationTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectMoreRelationTest.php @@ -24,7 +24,7 @@ class GeneratedObjectMoreRelationTest extends TestCase /** * Setup schema und some default data */ - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php index 552fea7403..b1f6780ada 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php @@ -25,7 +25,7 @@ */ class GeneratedObjectSetColumnTypeTest extends TestCase { - public function setUp() + public function setUp(): void { if (!class_exists('MyNameSpace\\ComplexColumnTypeEntitySet')) { $schema = << - + EOF; @@ -149,7 +149,7 @@ public function testSetterArrayValue() $value = ['foo', '1']; $e->setTags($value); $this->assertEquals($value, $e->getTags(), 'array columns can store arrays'); - + $this->assertEquals(9, $e->tags); } @@ -248,4 +248,4 @@ public function testGetterDoesNotKeepValueBetweenTwoHydrationsWhenUsingOnDemandF } $this->assertNotEquals($tags[0], $tags[1]); } -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php index e3704c2144..4bb9175483 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php @@ -23,7 +23,7 @@ */ class GeneratedObjectTemporalColumnTypeTest extends TestCase { - public function setUp() + public function setUp(): void { if (!class_exists('ComplexColumnTypeEntity5')) { $schema = <<markTestSkipped('not used anymore look if all tests are present in Query'); parent::setUp(); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryEnumColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryEnumColumnTypeTest.php index a80be49c75..a5f43c8c54 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryEnumColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryEnumColumnTypeTest.php @@ -23,7 +23,7 @@ */ class GeneratedQueryEnumColumnTypeTest extends TestCase { - public function setUp() + public function setUp(): void { if (!class_exists('\ComplexColumnTypeEntity13')) { $schema = <<c1 = new FooColumnValue2(); $this->c1->bar = 1234; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php index 03e0a045ab..df068319d7 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php @@ -20,7 +20,7 @@ */ class GeneratedQuerySetColumnTypeTest extends \PHPUnit\Framework\TestCase { - public function setUp() + public function setUp(): void { if (!class_exists('\ComplexColumnTypeEntitySet2')) { $schema = <<find(); $this->assertEquals(0, $e->count(), 'set columns are searchable by multiple values using where()'); } - + /** * @expectedException \Propel\Runtime\Exception\PropelException */ diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapEnumColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapEnumColumnTypeTest.php index bc18264b56..99fdcaf3ab 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapEnumColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapEnumColumnTypeTest.php @@ -22,7 +22,7 @@ */ class GeneratedTableMapEnumColumnTypeTest extends TestCase { - public function setUp() + public function setUp(): void { if (!class_exists('ComplexColumnTypeEntity103')) { $schema = <<setPlatform(new MysqlPlatform()); diff --git a/tests/Propel/Tests/Generator/Builder/Om/PoisonedCacheBugTest.php b/tests/Propel/Tests/Generator/Builder/Om/PoisonedCacheBugTest.php index 0602fb8401..4b9e3dfa17 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/PoisonedCacheBugTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/PoisonedCacheBugTest.php @@ -35,7 +35,7 @@ class PoisonedCacheBugTest extends BookstoreTestBase */ private $books; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php b/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php index 25e09236d1..53573b277d 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php @@ -52,7 +52,7 @@ class QueryBuilderTest extends BookstoreTestBase { - protected function setUp() + protected function setUp(): void { parent::setUp(); include_once(__DIR__.'/QueryBuilderTestClasses.php'); diff --git a/tests/Propel/Tests/Generator/Builder/Om/TableMapBuilderTest.php b/tests/Propel/Tests/Generator/Builder/Om/TableMapBuilderTest.php index cf6fd01fb7..dc0fc12ebf 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/TableMapBuilderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/TableMapBuilderTest.php @@ -26,7 +26,7 @@ class TableMapBuilderTest extends BookstoreTestBase { protected $databaseMap; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->databaseMap = Propel::getServiceContainer()->getDatabaseMap('bookstore'); diff --git a/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php b/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php index df05315f14..0ba6355bc5 100644 --- a/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php @@ -130,12 +130,12 @@ public function testParseFileExternalSchema() $this->assertEquals($expectedSchema, $schema->toString()); } - protected function setUp() + protected function setUp(): void { $this->reader = new SchemaReader(); } - protected function tearDown() + protected function tearDown(): void { $this->reader = null; } diff --git a/tests/Propel/Tests/Generator/Command/AbstractCommandTest.php b/tests/Propel/Tests/Generator/Command/AbstractCommandTest.php index 7d859a1df6..d0d5064cc8 100644 --- a/tests/Propel/Tests/Generator/Command/AbstractCommandTest.php +++ b/tests/Propel/Tests/Generator/Command/AbstractCommandTest.php @@ -24,7 +24,7 @@ class AbstractCommandTest extends TestCase { protected $command; - public function setUp() + public function setUp(): void { $this->command = new TestableAbstractCommand(); } diff --git a/tests/Propel/Tests/Generator/Command/InitCommandTest.php b/tests/Propel/Tests/Generator/Command/InitCommandTest.php index d007fb8f16..aafa014992 100644 --- a/tests/Propel/Tests/Generator/Command/InitCommandTest.php +++ b/tests/Propel/Tests/Generator/Command/InitCommandTest.php @@ -31,7 +31,7 @@ class InitCommandTest extends TestCaseFixtures /** @var string */ private $currentDir; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Propel/Tests/Generator/Command/MigrationTest.php b/tests/Propel/Tests/Generator/Command/MigrationTest.php index e66202f35f..08cafdf818 100644 --- a/tests/Propel/Tests/Generator/Command/MigrationTest.php +++ b/tests/Propel/Tests/Generator/Command/MigrationTest.php @@ -23,7 +23,7 @@ class MigrationTest extends TestCaseFixturesDatabase protected $schemaDir; protected $outputDir; - public function setUp() + public function setUp(): void { parent::setUp(); $this->connectionOption = ['migration_command=' . $this->getConnectionDsn('bookstore', true)]; diff --git a/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php b/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php index bffff5a7ba..0d7de13b9f 100644 --- a/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php +++ b/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php @@ -30,7 +30,7 @@ public function setConfig($config) $refProp->setValue($this->generatorConfig, $config); } - public function setUp() + public function setUp(): void { $php = " generatorConfig = new QuickGeneratorConfig(); } diff --git a/tests/Propel/Tests/Generator/Migration/MigrationTestCase.php b/tests/Propel/Tests/Generator/Migration/MigrationTestCase.php index d44cf15809..18161c7bd6 100644 --- a/tests/Propel/Tests/Generator/Migration/MigrationTestCase.php +++ b/tests/Propel/Tests/Generator/Migration/MigrationTestCase.php @@ -34,7 +34,7 @@ class MigrationTestCase extends TestCaseFixturesDatabase */ protected $platform; - public function setUp() + public function setUp(): void { parent::setUp(); if (!$this->con) { diff --git a/tests/Propel/Tests/Generator/Model/Diff/ColumnComparatorTest.php b/tests/Propel/Tests/Generator/Model/Diff/ColumnComparatorTest.php index 3312c7dd3d..5b8c0581a4 100644 --- a/tests/Propel/Tests/Generator/Model/Diff/ColumnComparatorTest.php +++ b/tests/Propel/Tests/Generator/Model/Diff/ColumnComparatorTest.php @@ -21,7 +21,7 @@ */ class ColumnComparatorTest extends TestCase { - public function setUp() + public function setUp(): void { $this->platform = new MysqlPlatform(); } diff --git a/tests/Propel/Tests/Generator/Model/Diff/DatabaseTableComparatorTest.php b/tests/Propel/Tests/Generator/Model/Diff/DatabaseTableComparatorTest.php index e6d524806c..c45db367ec 100644 --- a/tests/Propel/Tests/Generator/Model/Diff/DatabaseTableComparatorTest.php +++ b/tests/Propel/Tests/Generator/Model/Diff/DatabaseTableComparatorTest.php @@ -26,7 +26,7 @@ */ class PropelDatabaseTableComparatorTest extends TestCase { - public function setUp() + public function setUp(): void { $this->platform = new MysqlPlatform(); } diff --git a/tests/Propel/Tests/Generator/Model/Diff/PropelTableColumnComparatorTest.php b/tests/Propel/Tests/Generator/Model/Diff/PropelTableColumnComparatorTest.php index dbb9468dbf..c574e2521c 100644 --- a/tests/Propel/Tests/Generator/Model/Diff/PropelTableColumnComparatorTest.php +++ b/tests/Propel/Tests/Generator/Model/Diff/PropelTableColumnComparatorTest.php @@ -24,7 +24,7 @@ */ class PropelTableColumnComparatorTest extends TestCase { - public function setUp() + public function setUp(): void { $this->platform = new MysqlPlatform(); } diff --git a/tests/Propel/Tests/Generator/Model/Diff/PropelTableForeignKeyComparatorTest.php b/tests/Propel/Tests/Generator/Model/Diff/PropelTableForeignKeyComparatorTest.php index 67ebfa1be0..8c24a148be 100644 --- a/tests/Propel/Tests/Generator/Model/Diff/PropelTableForeignKeyComparatorTest.php +++ b/tests/Propel/Tests/Generator/Model/Diff/PropelTableForeignKeyComparatorTest.php @@ -24,7 +24,7 @@ */ class PropelTableForeignKeyComparatorTest extends TestCase { - public function setUp() + public function setUp(): void { $this->platform = new MysqlPlatform(); } diff --git a/tests/Propel/Tests/Generator/Model/Diff/PropelTableIndexComparatorTest.php b/tests/Propel/Tests/Generator/Model/Diff/PropelTableIndexComparatorTest.php index 0af96b6aa2..23c35570da 100644 --- a/tests/Propel/Tests/Generator/Model/Diff/PropelTableIndexComparatorTest.php +++ b/tests/Propel/Tests/Generator/Model/Diff/PropelTableIndexComparatorTest.php @@ -25,7 +25,7 @@ */ class PropelTableIndexComparatorTest extends TestCase { - public function setUp() + public function setUp(): void { $this->platform = new MysqlPlatform(); } diff --git a/tests/Propel/Tests/Generator/Model/Diff/PropelTablePkColumnComparatorTest.php b/tests/Propel/Tests/Generator/Model/Diff/PropelTablePkColumnComparatorTest.php index fd5c0f9851..065b4199e6 100644 --- a/tests/Propel/Tests/Generator/Model/Diff/PropelTablePkColumnComparatorTest.php +++ b/tests/Propel/Tests/Generator/Model/Diff/PropelTablePkColumnComparatorTest.php @@ -23,7 +23,7 @@ */ class PropelTablePkColumnComparatorTest extends TestCase { - public function setUp() + public function setUp(): void { $this->platform = new MysqlPlatform(); } diff --git a/tests/Propel/Tests/Generator/Model/NameFactoryTest.php b/tests/Propel/Tests/Generator/Model/NameFactoryTest.php index c5b76c9507..ca41332875 100644 --- a/tests/Propel/Tests/Generator/Model/NameFactoryTest.php +++ b/tests/Propel/Tests/Generator/Model/NameFactoryTest.php @@ -80,7 +80,7 @@ private static function makeString($len) } /** Sets up the Propel model. */ - public function setUp() + public function setUp(): void { $this->inputs = [ [ diff --git a/tests/Propel/Tests/Generator/Platform/DefaultPlatformTest.php b/tests/Propel/Tests/Generator/Platform/DefaultPlatformTest.php index b6602d28d1..9d1c2b0ec6 100644 --- a/tests/Propel/Tests/Generator/Platform/DefaultPlatformTest.php +++ b/tests/Propel/Tests/Generator/Platform/DefaultPlatformTest.php @@ -32,7 +32,7 @@ protected function getPlatform() return $this->platform; } - protected function tearDown() + protected function tearDown(): void { $this->platform = null; } diff --git a/tests/Propel/Tests/Generator/Reverse/PgsqlSchemaParserTest.php b/tests/Propel/Tests/Generator/Reverse/PgsqlSchemaParserTest.php index 43ca0d10b0..ce52351ae7 100644 --- a/tests/Propel/Tests/Generator/Reverse/PgsqlSchemaParserTest.php +++ b/tests/Propel/Tests/Generator/Reverse/PgsqlSchemaParserTest.php @@ -27,7 +27,7 @@ */ class PgsqlSchemaParserTest extends TestCaseFixturesDatabase { - protected function setUp() + protected function setUp(): void { parent::setUp(); Propel::init(__DIR__ . '/../../../../Fixtures/reverse/pgsql/build/conf/reverse-bookstore-conf.php'); @@ -40,7 +40,7 @@ protected function setUp() } } - protected function tearDown() + protected function tearDown(): void { if ($this->con) { $this->con->rollback(); diff --git a/tests/Propel/Tests/Generator/Schema/Dumper/XmlDumperTest.php b/tests/Propel/Tests/Generator/Schema/Dumper/XmlDumperTest.php index 189613ce81..28aa1dd43c 100644 --- a/tests/Propel/Tests/Generator/Schema/Dumper/XmlDumperTest.php +++ b/tests/Propel/Tests/Generator/Schema/Dumper/XmlDumperTest.php @@ -32,12 +32,12 @@ protected function getExpectedXml($filename) return trim(file_get_contents(realpath(__DIR__.'/../../../Resources/'.$filename))); } - protected function setUp() + protected function setUp(): void { $this->dumper = new XmlDumper(); } - protected function tearDown() + protected function tearDown(): void { $this->dumper = null; } diff --git a/tests/Propel/Tests/Helpers/Bookstore/BookstoreEmptyTestBase.php b/tests/Propel/Tests/Helpers/Bookstore/BookstoreEmptyTestBase.php index 6e42051a84..84a5b7f48f 100644 --- a/tests/Propel/Tests/Helpers/Bookstore/BookstoreEmptyTestBase.php +++ b/tests/Propel/Tests/Helpers/Bookstore/BookstoreEmptyTestBase.php @@ -18,7 +18,7 @@ abstract class BookstoreEmptyTestBase extends BookstoreTestBase /** * This is run before each unit test; it empties the database. */ - protected function setUp() + protected function setUp(): void { parent::setUp(); if (static::$isInitialized) { diff --git a/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php b/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php index e19378c2ba..9c81b82088 100644 --- a/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php +++ b/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php @@ -31,7 +31,7 @@ abstract class BookstoreTestBase extends TestCaseFixturesDatabase /** * This is run before each unit test; it populates the database. */ - protected function setUp() + protected function setUp(): void { parent::setUp(); if (true !== self::$isInitialized) { @@ -49,7 +49,7 @@ protected function setUp() /** * This is run after each unit test. It empties the database. */ - protected function tearDown() + protected function tearDown(): void { // Only commit if the transaction hasn't failed. // This is because tearDown() is also executed on a failed tests, diff --git a/tests/Propel/Tests/Helpers/Namespaces/NamespacesTestBase.php b/tests/Propel/Tests/Helpers/Namespaces/NamespacesTestBase.php index 75b60f358a..0774b61b87 100644 --- a/tests/Propel/Tests/Helpers/Namespaces/NamespacesTestBase.php +++ b/tests/Propel/Tests/Helpers/Namespaces/NamespacesTestBase.php @@ -18,14 +18,14 @@ */ abstract class NamespacesTestBase extends TestCase { - protected function setUp() + protected function setUp(): void { if (!file_exists(__DIR__ . '/../../../../Fixtures/namespaced/build/conf/bookstore_namespaced-conf.php')) { $this->markTestSkipped('You must build the namespaced project for this tests to run'); } } - protected function tearDown() + protected function tearDown(): void { Propel::init(__DIR__ . '/../../../../Fixtures/bookstore/build/conf/bookstore-conf.php'); } diff --git a/tests/Propel/Tests/Helpers/PlatformDatabaseBuildTimeBase.php b/tests/Propel/Tests/Helpers/PlatformDatabaseBuildTimeBase.php index 9469d21504..6d5a7a7bd5 100644 --- a/tests/Propel/Tests/Helpers/PlatformDatabaseBuildTimeBase.php +++ b/tests/Propel/Tests/Helpers/PlatformDatabaseBuildTimeBase.php @@ -41,7 +41,7 @@ class PlatformDatabaseBuildTimeBase extends TestCaseFixtures */ public $con; - protected function setUp() + protected function setUp(): void { $config = sprintf('%s-conf.php', $this->databaseName); $path = 'reverse-bookstore' === $this->databaseName ? 'reverse/mysql' : $this->databaseName; diff --git a/tests/Propel/Tests/Issues/Issue1033Test.php b/tests/Propel/Tests/Issues/Issue1033Test.php index c76a2e1798..bffc1689f8 100644 --- a/tests/Propel/Tests/Issues/Issue1033Test.php +++ b/tests/Propel/Tests/Issues/Issue1033Test.php @@ -13,7 +13,7 @@ */ class Issue1033Test extends BookstoreTestBase { - public function setUp() + public function setUp(): void { if (!class_exists('\Base\Issue1033Book')) { $schema = <<assertTrue($noExceptionThrown); + $this->assertTrue($noExceptionThrown); } } diff --git a/tests/Propel/Tests/Issues/Issue1192Test.php b/tests/Propel/Tests/Issues/Issue1192Test.php index 72b0ce1ac1..ee25d08397 100644 --- a/tests/Propel/Tests/Issues/Issue1192Test.php +++ b/tests/Propel/Tests/Issues/Issue1192Test.php @@ -17,7 +17,7 @@ class Issue1192Test extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Propel/Tests/Issues/Issue1463Test.php b/tests/Propel/Tests/Issues/Issue1463Test.php index 65f0ecc4a2..77f472858c 100644 --- a/tests/Propel/Tests/Issues/Issue1463Test.php +++ b/tests/Propel/Tests/Issues/Issue1463Test.php @@ -16,7 +16,7 @@ class Issue1463Test extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Propel/Tests/Issues/Issue617Test.php b/tests/Propel/Tests/Issues/Issue617Test.php index 720b66e372..a6c6155f29 100644 --- a/tests/Propel/Tests/Issues/Issue617Test.php +++ b/tests/Propel/Tests/Issues/Issue617Test.php @@ -23,13 +23,13 @@ class Issue617Test extends PlatformDatabaseBuildTimeBase */ private $updatedBuilder; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->removeTables(); } - protected function tearDown() + protected function tearDown(): void { $this->removeTables(); parent::tearDown(); diff --git a/tests/Propel/Tests/Issues/Issue646Test.php b/tests/Propel/Tests/Issues/Issue646Test.php index 9b9defcc28..88108c7a57 100644 --- a/tests/Propel/Tests/Issues/Issue646Test.php +++ b/tests/Propel/Tests/Issues/Issue646Test.php @@ -21,7 +21,7 @@ class Issue646Test extends TestCaseFixtures { - protected function setUp() + protected function setUp(): void { parent::setUp(); if (!class_exists('\PkDate')) { @@ -45,7 +45,7 @@ protected function setUp() } - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); \PkDateQuery::create()->deleteAll(); diff --git a/tests/Propel/Tests/Issues/Issue656Test.php b/tests/Propel/Tests/Issues/Issue656Test.php index 71cb447c01..04c1871cc0 100644 --- a/tests/Propel/Tests/Issues/Issue656Test.php +++ b/tests/Propel/Tests/Issues/Issue656Test.php @@ -13,7 +13,7 @@ class Issue656Test extends TestCase { - public function setUp() + public function setUp(): void { if (!class_exists('\Issue656TestObject')) { $schema = <<assertEquals($collection, $objectA->getIssue656TestObjectsRelatedByTo()); } -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Issues/Issue733Test.php b/tests/Propel/Tests/Issues/Issue733Test.php index b61229dcfc..c12f74e321 100644 --- a/tests/Propel/Tests/Issues/Issue733Test.php +++ b/tests/Propel/Tests/Issues/Issue733Test.php @@ -10,11 +10,11 @@ * This test proves the bug described in https://github.com/propelorm/Propel2/issues/733. * * @group database - */ + */ class Issue733Test extends TestCase { - public function setUp() + public function setUp(): void { if (!class_exists('\Issue733Test1')) { $schema = << - + @@ -74,4 +74,4 @@ public function testGetColumnTranslationWithAlias() } -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Issues/Issue768Test.php b/tests/Propel/Tests/Issues/Issue768Test.php index 4052f4e754..21e1993e6e 100644 --- a/tests/Propel/Tests/Issues/Issue768Test.php +++ b/tests/Propel/Tests/Issues/Issue768Test.php @@ -18,7 +18,7 @@ */ class Issue768Test extends TestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); if (!class_exists('\Timing')) { diff --git a/tests/Propel/Tests/Issues/Issue829Test.php b/tests/Propel/Tests/Issues/Issue829Test.php index 329308727a..240e01a357 100644 --- a/tests/Propel/Tests/Issues/Issue829Test.php +++ b/tests/Propel/Tests/Issues/Issue829Test.php @@ -18,7 +18,7 @@ */ class Issue829Test extends TestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); if (!class_exists('\Table829')) { diff --git a/tests/Propel/Tests/Issues/Issue915Test.php b/tests/Propel/Tests/Issues/Issue915Test.php index 90f66148e8..53db728fb3 100644 --- a/tests/Propel/Tests/Issues/Issue915Test.php +++ b/tests/Propel/Tests/Issues/Issue915Test.php @@ -13,7 +13,7 @@ */ class Issue915Test extends BookstoreTestBase { - public function setUp() + public function setUp(): void { if (!class_exists('\Base\Issue915Book')) { $schema = <<setRechercheNatures($collection); - - $countBeforeSave = $recherche->countRechercheNatures(); + + $countBeforeSave = $recherche->countRechercheNatures(); $recherche->save(); $countAfterSave = $recherche->countRechercheNatures(); - + $this->assertEquals($countBeforeSave, $countAfterSave); } -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaCombineTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaCombineTest.php index 6c8c4de34d..8557134d4b 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaCombineTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaCombineTest.php @@ -40,7 +40,7 @@ class CriteriaCombineTest extends BaseTestCase */ private $savedAdapter; - protected function setUp() + protected function setUp(): void { Propel::init(__DIR__ . '/../../../../Fixtures/bookstore/build/conf/bookstore-conf.php'); parent::setUp(); @@ -55,7 +55,7 @@ protected function getDriver() return 'sqlite'; } - protected function tearDown() + protected function tearDown(): void { Propel::getServiceContainer()->setAdapter(Propel::getServiceContainer()->getDefaultDatasource(), $this->savedAdapter); parent::tearDown(); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaTest.php index 4854498174..2047f75a94 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaTest.php @@ -46,7 +46,7 @@ class CriteriaTest extends BookstoreTestBase // */ // private $savedAdapter; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->c = new ModelCriteria(); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/JoinTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/JoinTest.php index 301ba27ba3..0132a9f846 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/JoinTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/JoinTest.php @@ -32,7 +32,7 @@ class JoinTest extends BaseTestCase */ private $savedAdapter; - protected function setUp() + protected function setUp(): void { Propel::init(dirname(__FILE__) . '/../../../../Fixtures/bookstore/build/conf/bookstore-conf.php'); parent::setUp(); @@ -41,7 +41,7 @@ protected function setUp() Propel::getServiceContainer()->setAdapter(null, new SqliteAdapter()); } - protected function tearDown() + protected function tearDown(): void { Propel::getServiceContainer()->setAdapter(null, $this->savedAdapter); parent::tearDown(); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaHooksTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaHooksTest.php index 13d89004d1..d72d0b24e2 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaHooksTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaHooksTest.php @@ -25,7 +25,7 @@ */ class ModelCriteriaHooksTest extends BookstoreTestBase { - protected function setUp() + protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::depopulate(); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/PropelQueryTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/PropelQueryTest.php index 37599ac378..28cfb37112 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/PropelQueryTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/PropelQueryTest.php @@ -30,7 +30,7 @@ class PropelQueryTest extends BookstoreTestBase { - protected function setUp() + protected function setUp(): void { parent::setUp(); include_once(__DIR__.'/PropelQueryTestClasses.php'); @@ -164,4 +164,4 @@ public function testInstancePool() $object = Table6Query::create()->findPk($key); $this->assertSame($object, Table6TableMap::getInstanceFromPool($key)); } -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/SubQueryTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/SubQueryTest.php index db9841d3cd..b99581195a 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/SubQueryTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/SubQueryTest.php @@ -26,7 +26,7 @@ */ class SubQueryTest extends BookstoreTestBase { - protected function setUp() + protected function setUp(): void { parent::setUp(); include_once(__DIR__.'/SubQueryTestClasses.php'); diff --git a/tests/Propel/Tests/Runtime/ActiveRecordConvertTest.php b/tests/Propel/Tests/Runtime/ActiveRecordConvertTest.php index 66e5b75a3c..bc0b8b7302 100644 --- a/tests/Propel/Tests/Runtime/ActiveRecordConvertTest.php +++ b/tests/Propel/Tests/Runtime/ActiveRecordConvertTest.php @@ -24,7 +24,7 @@ class ActiveRecordConvertTest extends TestCaseFixtures { private $book; - protected function setUp() + protected function setUp(): void { parent::setUp(); $publisher = new Publisher(); diff --git a/tests/Propel/Tests/Runtime/ActiveRecordTest.php b/tests/Propel/Tests/Runtime/ActiveRecordTest.php index a5bbfd71e7..a4c15ff856 100644 --- a/tests/Propel/Tests/Runtime/ActiveRecordTest.php +++ b/tests/Propel/Tests/Runtime/ActiveRecordTest.php @@ -20,7 +20,7 @@ */ class ActiveRecordTest extends TestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); include_once(__DIR__.'/ActiveRecordTestClasses.php'); diff --git a/tests/Propel/Tests/Runtime/Adapter/Pdo/MssqlAdapterTest.php b/tests/Propel/Tests/Runtime/Adapter/Pdo/MssqlAdapterTest.php index 4d07b11b60..50fc2a0770 100644 --- a/tests/Propel/Tests/Runtime/Adapter/Pdo/MssqlAdapterTest.php +++ b/tests/Propel/Tests/Runtime/Adapter/Pdo/MssqlAdapterTest.php @@ -40,7 +40,7 @@ class MssqlAdapterTest extends TestCase */ private $savedAdapter; - protected function setUp() + protected function setUp(): void { Propel::init(__DIR__ . '/../../../../../Fixtures/bookstore/build/conf/bookstore-conf.php'); parent::setUp(); @@ -58,7 +58,7 @@ protected function setUp() ); } - protected function tearDown() + protected function tearDown(): void { Propel::getServiceContainer()->setAdapter( Propel::getServiceContainer()->getDefaultDatasource(), diff --git a/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php b/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php index 8e28805f69..97f3467707 100644 --- a/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php +++ b/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php @@ -32,7 +32,7 @@ */ class ArrayCollectionTest extends BookstoreEmptyTestBase { - protected function setUp() + protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate($this->con); diff --git a/tests/Propel/Tests/Runtime/Collection/CollectionConvertTest.php b/tests/Propel/Tests/Runtime/Collection/CollectionConvertTest.php index be949e2d41..a62d86308b 100644 --- a/tests/Propel/Tests/Runtime/Collection/CollectionConvertTest.php +++ b/tests/Propel/Tests/Runtime/Collection/CollectionConvertTest.php @@ -27,7 +27,7 @@ class CollectionConvertTest extends TestCaseFixtures { private $coll; - protected function setUp() + protected function setUp(): void { parent::setUp(); $book1 = new Book(); diff --git a/tests/Propel/Tests/Runtime/Collection/ObjectCollectionWithFixturesTest.php b/tests/Propel/Tests/Runtime/Collection/ObjectCollectionWithFixturesTest.php index a4f5c4f7d7..7182ac811d 100644 --- a/tests/Propel/Tests/Runtime/Collection/ObjectCollectionWithFixturesTest.php +++ b/tests/Propel/Tests/Runtime/Collection/ObjectCollectionWithFixturesTest.php @@ -31,7 +31,7 @@ */ class ObjectCollectionWithFixturesTest extends BookstoreEmptyTestBase { - protected function setUp() + protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate($this->con); diff --git a/tests/Propel/Tests/Runtime/Collection/OnDemandCollectionTest.php b/tests/Propel/Tests/Runtime/Collection/OnDemandCollectionTest.php index 187bfbe91e..45569d8c96 100644 --- a/tests/Propel/Tests/Runtime/Collection/OnDemandCollectionTest.php +++ b/tests/Propel/Tests/Runtime/Collection/OnDemandCollectionTest.php @@ -28,7 +28,7 @@ */ class OnDemandCollectionTest extends BookstoreEmptyTestBase { - protected function setUp() + protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate($this->con); @@ -36,7 +36,7 @@ protected function setUp() $this->books = PropelQuery::from('\Propel\Tests\Bookstore\Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find(); } - protected function tearDown() + protected function tearDown(): void { $this->books = null; parent::tearDown(); diff --git a/tests/Propel/Tests/Runtime/Collection/OnDemandIteratorTest.php b/tests/Propel/Tests/Runtime/Collection/OnDemandIteratorTest.php index ff7233cd39..2493eaf116 100644 --- a/tests/Propel/Tests/Runtime/Collection/OnDemandIteratorTest.php +++ b/tests/Propel/Tests/Runtime/Collection/OnDemandIteratorTest.php @@ -26,7 +26,7 @@ */ class OnDemandIteratorTest extends BookstoreEmptyTestBase { - protected function setUp() + protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate($this->con); diff --git a/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php b/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php index 6288a590c4..86ed68dd83 100644 --- a/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php +++ b/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php @@ -35,12 +35,12 @@ */ class PropelPDOTest extends BookstoreTestBase { - protected function setUp() + protected function setUp(): void { $this->con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); } - protected function tearDown() + protected function tearDown(): void { } diff --git a/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterTest.php b/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterTest.php index 1f1c42e70b..b5484e7738 100644 --- a/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterTest.php @@ -28,7 +28,7 @@ */ class ArrayFormatterTest extends BookstoreEmptyTestBase { - protected function setUp() + protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate(); diff --git a/tests/Propel/Tests/Runtime/Formatter/DataFetcherTest.php b/tests/Propel/Tests/Runtime/Formatter/DataFetcherTest.php index 7493ea64e4..20937427ec 100644 --- a/tests/Propel/Tests/Runtime/Formatter/DataFetcherTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/DataFetcherTest.php @@ -24,7 +24,7 @@ */ class DataFetcherTest extends BookstoreEmptyTestBase { - protected function setUp() + protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate(); diff --git a/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterInheritanceTest.php b/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterInheritanceTest.php index def1ced7e6..0361c390b0 100644 --- a/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterInheritanceTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterInheritanceTest.php @@ -29,7 +29,7 @@ */ class ObjectFormatterInheritanceTest extends BookstoreEmptyTestBase { - protected function setUp() + protected function setUp(): void { parent::setUp(); $b1 = new BookstoreEmployee(); diff --git a/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterTest.php b/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterTest.php index 275f77c2d7..cf08ae909a 100644 --- a/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterTest.php @@ -33,7 +33,7 @@ */ class ObjectFormatterTest extends BookstoreEmptyTestBase { - protected function setUp() + protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate(); diff --git a/tests/Propel/Tests/Runtime/Formatter/SimpleArrayFormatterTest.php b/tests/Propel/Tests/Runtime/Formatter/SimpleArrayFormatterTest.php index 83bd52a465..7d2fb8f4c8 100644 --- a/tests/Propel/Tests/Runtime/Formatter/SimpleArrayFormatterTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/SimpleArrayFormatterTest.php @@ -22,7 +22,7 @@ */ class SimpleArrayFormatterTest extends BookstoreEmptyTestBase { - protected function setUp() + protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate(); diff --git a/tests/Propel/Tests/Runtime/Formatter/StatementFormatterTest.php b/tests/Propel/Tests/Runtime/Formatter/StatementFormatterTest.php index 9023dac0d4..272519e46c 100644 --- a/tests/Propel/Tests/Runtime/Formatter/StatementFormatterTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/StatementFormatterTest.php @@ -34,7 +34,7 @@ */ class StatementFormatterTest extends BookstoreEmptyTestBase { - protected function setUp() + protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate(); diff --git a/tests/Propel/Tests/Runtime/Map/ColumnMapTest.php b/tests/Propel/Tests/Runtime/Map/ColumnMapTest.php index bca3cc0409..2aff732c15 100644 --- a/tests/Propel/Tests/Runtime/Map/ColumnMapTest.php +++ b/tests/Propel/Tests/Runtime/Map/ColumnMapTest.php @@ -28,7 +28,7 @@ class ColumnMapTest extends TestCaseFixtures { protected $databaseMap; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->dmap = new DatabaseMap('foodb'); @@ -37,7 +37,7 @@ protected function setUp() $this->cmap = new ColumnMap($this->columnName, $this->tmap); } - protected function tearDown() + protected function tearDown(): void { // nothing to do for now parent::tearDown(); diff --git a/tests/Propel/Tests/Runtime/Map/DatabaseMapTest.php b/tests/Propel/Tests/Runtime/Map/DatabaseMapTest.php index 3206e456ef..428c7d995e 100644 --- a/tests/Propel/Tests/Runtime/Map/DatabaseMapTest.php +++ b/tests/Propel/Tests/Runtime/Map/DatabaseMapTest.php @@ -27,14 +27,14 @@ class DatabaseMapTest extends TestCaseFixtures { protected $databaseMap; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->databaseName = 'foodb'; $this->databaseMap = TestDatabaseBuilder::getDmap(); } - protected function tearDown() + protected function tearDown(): void { // nothing to do for now parent::tearDown(); diff --git a/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapTest.php b/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapTest.php index 97efb1e718..2bb269bea6 100644 --- a/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapTest.php +++ b/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapTest.php @@ -23,7 +23,7 @@ class GeneratedRelationMapTest extends TestCaseFixtures { protected $databaseMap; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->databaseMap = Propel::getServiceContainer()->getDatabaseMap('bookstore'); diff --git a/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapWithSchemasTest.php b/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapWithSchemasTest.php index 4e96c612be..889ebb64e2 100644 --- a/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapWithSchemasTest.php +++ b/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapWithSchemasTest.php @@ -28,7 +28,7 @@ class GeneratedRelationMapWithSchemasTest extends TestCaseFixturesDatabase */ protected $databaseMap; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->databaseMap = Propel::getServiceContainer()->getDatabaseMap('bookstore-schemas'); diff --git a/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalTest.php b/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalTest.php index c72f203e44..c82d6bf0b2 100644 --- a/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalTest.php +++ b/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalTest.php @@ -22,7 +22,7 @@ class RelatedMapSymmetricalTest extends TestCaseFixtures { protected $databaseMap; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->databaseMap = Propel::getServiceContainer()->getDatabaseMap('bookstore'); diff --git a/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalWithSchemasTest.php b/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalWithSchemasTest.php index 36d320b151..b3514c2b01 100644 --- a/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalWithSchemasTest.php +++ b/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalWithSchemasTest.php @@ -24,7 +24,7 @@ class RelatedMapSymmetricalWithSchemasTest extends TestCaseFixturesDatabase { protected $databaseMap; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->databaseMap = Propel::getServiceContainer()->getDatabaseMap('bookstore-schemas'); diff --git a/tests/Propel/Tests/Runtime/Map/RelationMapTest.php b/tests/Propel/Tests/Runtime/Map/RelationMapTest.php index 9ec3c83c3a..f48a92275c 100644 --- a/tests/Propel/Tests/Runtime/Map/RelationMapTest.php +++ b/tests/Propel/Tests/Runtime/Map/RelationMapTest.php @@ -25,7 +25,7 @@ class RelationMapTest extends TestCase { protected $databaseMap, $relationName, $rmap; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->databaseMap = new DatabaseMap('foodb'); diff --git a/tests/Propel/Tests/Runtime/Map/TableMapTest.php b/tests/Propel/Tests/Runtime/Map/TableMapTest.php index b8afcb1720..7088f04cf3 100644 --- a/tests/Propel/Tests/Runtime/Map/TableMapTest.php +++ b/tests/Propel/Tests/Runtime/Map/TableMapTest.php @@ -27,7 +27,7 @@ class TableMapTest extends TestCase { protected $databaseMap; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->databaseMap = new DatabaseMap('foodb'); @@ -35,7 +35,7 @@ protected function setUp() $this->tmap = new TableMap($this->tableName, $this->databaseMap); } - protected function tearDown() + protected function tearDown(): void { // nothing to do for now parent::tearDown(); diff --git a/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php b/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php index eb94f6e02f..aece2086e3 100644 --- a/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php +++ b/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php @@ -31,12 +31,12 @@ class StandardServiceContainerTest extends BaseTestCase */ protected $sc; - protected function setUp() + protected function setUp(): void { $this->sc = new StandardServiceContainer; } - protected function tearDown() + protected function tearDown(): void { $this->sc = null; } diff --git a/tests/Propel/Tests/TestCaseFixtures.php b/tests/Propel/Tests/TestCaseFixtures.php index cd53f8e250..e352626337 100644 --- a/tests/Propel/Tests/TestCaseFixtures.php +++ b/tests/Propel/Tests/TestCaseFixtures.php @@ -46,7 +46,7 @@ class TestCaseFixtures extends TestCase /** * Setup fixture. Needed here because we want to have a realistic code coverage value. */ - protected function setUp() + protected function setUp(): void { $dsn = $this->getFixturesConnectionDsn(); @@ -109,10 +109,9 @@ protected function setUp() if (0 !== $app->run($input, $output)) { echo $output->fetch(); $this->fail('Can not initialize fixtures.'); - return false; + return; } - $builtInfo = __DIR__ . '/../../Fixtures/fixtures_built'; file_put_contents($builtInfo, "$dsn\n$mode\nFixtures has been created. Delete this file to let the test suite regenerate all fixtures." From e2244fb7939542ed99eea2598ebad3422bbb39dd Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 9 Jul 2020 00:49:43 +0200 Subject: [PATCH 075/208] Prepare for php8 pre check branch. --- tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php b/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php index 9c81b82088..16230f11b2 100644 --- a/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php +++ b/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php @@ -64,7 +64,7 @@ protected function tearDown(): void } } - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { Propel::getServiceContainer()->closeConnections(); } From aa60e0cb6fcb7b9f0ec94734f119b19f345c3912 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 9 Jul 2020 11:58:16 +0200 Subject: [PATCH 076/208] Prepare for php8 pre check branch. --- .../Behavior/Timestampable/TimestampableBehaviorTest.php | 2 +- .../VersionableBehaviorObjectBuilderModifierTest.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/Propel/Tests/Generator/Behavior/Timestampable/TimestampableBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Timestampable/TimestampableBehaviorTest.php index b011422fd3..89a27c2bb4 100644 --- a/tests/Propel/Tests/Generator/Behavior/Timestampable/TimestampableBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Timestampable/TimestampableBehaviorTest.php @@ -30,7 +30,7 @@ */ class TimestampableBehaviorTest extends BookstoreTestBase { - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { static::$isInitialized = false; parent::setUpBeforeClass(); diff --git a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php index 2e9d96a987..74b17c890e 100644 --- a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php @@ -20,8 +20,7 @@ */ class VersionableBehaviorObjectBuilderModifierTest extends TestCase { - - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { $schema = << From 37b45935f55c6d9276976239f9f0c1078f098e9e Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 9 Jul 2020 12:48:25 +0200 Subject: [PATCH 077/208] Prepare for php8 pre check branch. --- .../I18nConcreteInheritanceHandleValidateBehaviorTest.php | 2 +- .../Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Propel/Tests/Generator/Behavior/Validate/I18nConcreteInheritanceHandleValidateBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Validate/I18nConcreteInheritanceHandleValidateBehaviorTest.php index 117199bfe8..6b47267934 100644 --- a/tests/Propel/Tests/Generator/Behavior/Validate/I18nConcreteInheritanceHandleValidateBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Validate/I18nConcreteInheritanceHandleValidateBehaviorTest.php @@ -25,7 +25,7 @@ class I18nConcreteInheritanceHandleValidateBehaviorTest extends BookstoreTestBas { protected $metadataFactory; - public function assertPreConditions() + public function assertPreConditions(): void { $this->metadataFactory = new \Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory(new StaticMethodLoader()); } diff --git a/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php index f070a90885..233e6a2b1d 100755 --- a/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php @@ -33,7 +33,7 @@ class ValidateBehaviorTest extends BookstoreTestBase */ private $classes; - public function assertPreConditions() + public function assertPreConditions(): void { if (!class_exists('Propel\Tests\Bookstore\Behavior\ValidateAuthor')) { throw new \Exception('Please, run \'bin/propel test:prepare\' command before starting to test this behavior'); From 04de2237c17afeb136d83fbb80fad101a2a9bd15 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 9 Jul 2020 12:56:47 +0200 Subject: [PATCH 078/208] Prepare for php8 pre check branch. --- .../Builder/Om/GeneratedObjectObjectColumnTypeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectObjectColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectObjectColumnTypeTest.php index 062d5eff03..e5a56a1440 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectObjectColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectObjectColumnTypeTest.php @@ -23,7 +23,7 @@ */ class GeneratedObjectObjectColumnTypeTest extends TestCase { - public function setup() + public function setUp(): void { if (!class_exists('ComplexColumnTypeEntity1')) { $schema = << Date: Thu, 9 Jul 2020 17:31:57 +0200 Subject: [PATCH 079/208] Prepare for php8 pre check branch. --- .../Runtime/Connection/ConnectionInterface.php | 10 +++++----- .../Runtime/Connection/ConnectionWrapper.php | 6 +++--- src/Propel/Runtime/Connection/PdoConnection.php | 14 +------------- .../Connection/ProfilerConnectionWrapper.php | 2 +- 4 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/Propel/Runtime/Connection/ConnectionInterface.php b/src/Propel/Runtime/Connection/ConnectionInterface.php index 210a4921de..2d346575c5 100644 --- a/src/Propel/Runtime/Connection/ConnectionInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionInterface.php @@ -74,23 +74,23 @@ public function inTransaction(); /** * Retrieve a database connection attribute. * - * @param string $attribute The name of the attribute to retrieve, + * @param int $attribute The name of the attribute to retrieve, * e.g. PDO::ATTR_AUTOCOMMIT * * @return mixed A successful call returns the value of the requested attribute. * An unsuccessful call returns null. */ - public function getAttribute($attribute); + public function getAttribute(int $attribute); /** * Set an attribute. * - * @param string $attribute + * @param int $attribute * @param mixed $value * * @return boolean TRUE on success or FALSE on failure. */ - public function setAttribute($attribute, $value); + public function setAttribute(int $attribute, $value); /** * Returns the ID of the last inserted row or sequence value. @@ -170,7 +170,7 @@ public function exec($statement); * @throws \Propel\Runtime\Connection\Exception\ConnectionException depending on error handling. */ - public function prepare($statement, $driver_options = null); + public function prepare($statement, array $driver_options = []); /** * Executes an SQL statement, returning a result set as a Statement object. diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index 4eb7a78db0..1d1a52ec3f 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -309,13 +309,13 @@ public function inTransaction() /** * Retrieve a database connection attribute. * - * @param string $attribute The name of the attribute to retrieve, + * @param int $attribute The name of the attribute to retrieve, * e.g. PDO::ATTR_AUTOCOMMIT * * @return mixed A successful call returns the value of the requested attribute. * An unsuccessful call returns null. */ - public function getAttribute($attribute) + public function getAttribute(int $attribute) { switch ($attribute) { case self::PROPEL_ATTR_CACHE_PREPARES: @@ -372,7 +372,7 @@ public function setAttribute($attribute, $value) * * @return \PDOStatement */ - public function prepare($statement, $driver_options = null) + public function prepare($statement, array $driver_options = []) { $statementWrapper = null; diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index b499d8c56d..350dee0997 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -72,7 +72,7 @@ public function __construct($dsn, $user = null, $password = null, array $options * @return bool * @throws InvalidArgumentException */ - public function setAttribute($attribute, $value) + public function setAttribute(int $attribute, $value) { if (is_string($attribute) && false === strpos($attribute, '::')) { $attribute = '\PDO::' . $attribute; @@ -140,18 +140,6 @@ public function lastInsertId($name = null) return parent::lastInsertId($name); } - /** - * Overwrite. Fixes HHVM strict issue. - * - * @param string $statement - * @param array $driver_options - * @return bool|\PDOStatement|void - */ - public function prepare($statement, $driver_options = null) - { - return parent::prepare($statement, $driver_options ?: []); - } - /** * Overwrite. Fixes HHVM strict issue. * diff --git a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php index 658785897f..8be525362f 100644 --- a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php @@ -78,7 +78,7 @@ public function setAttribute($attribute, $value) /** * {@inheritDoc} */ - public function prepare($statement, $driver_options = null) + public function prepare($statement, array $driver_options = []) { $this->getProfiler()->start(); From a0ccfd7e7b95f284e50ca2b85a158b0b3663a234 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 9 Jul 2020 17:47:36 +0200 Subject: [PATCH 080/208] Cleanup PHP versioning mentioned. --- composer.json | 2 +- resources/xsd/database.xsd | 4 ++-- src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php | 4 ++-- src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php | 2 +- src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php | 2 +- .../Builder/Om/ExtensionQueryInheritanceBuilder.php | 2 +- src/Propel/Generator/Builder/Om/InterfaceBuilder.php | 2 +- .../Generator/Builder/Om/MultiExtendObjectBuilder.php | 2 +- src/Propel/Generator/Builder/Om/ObjectBuilder.php | 6 +++--- src/Propel/Generator/Builder/Om/QueryBuilder.php | 4 ++-- src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php | 4 ++-- src/Propel/Generator/Builder/Om/TableMapBuilder.php | 2 +- tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php | 2 +- tests/Propel/Tests/Runtime/Map/GeneratedRelationMapTest.php | 2 -- .../Runtime/Map/GeneratedRelationMapWithSchemasTest.php | 2 -- 15 files changed, 19 insertions(+), 23 deletions(-) diff --git a/composer.json b/composer.json index b9d8877361..8d1691b891 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "propel/propel", "type": "library", - "description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.", + "description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP.", "keywords": [ "ORM", "persistence", diff --git a/resources/xsd/database.xsd b/resources/xsd/database.xsd index d34722cd68..57cac923bd 100644 --- a/resources/xsd/database.xsd +++ b/resources/xsd/database.xsd @@ -646,7 +646,7 @@ - The PHP 5.3 namespace to use for the generated model classes. + The PHP namespace to use for the generated model classes. @@ -844,7 +844,7 @@ - The PHP 5.3 namespace to use for the generated model classes of the database. Can be overridden on a per-table basis. + The PHP namespace to use for the generated model classes of the database. Can be overridden on a per-table basis. diff --git a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php index b704a1d9f6..5dbfc7a393 100644 --- a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php @@ -26,7 +26,7 @@ abstract class AbstractObjectBuilder extends AbstractOMBuilder /** * Adds the getter methods for the column values. * This is here because it is probably generic enough to apply to templates being generated - * in different languages (e.g. PHP4 and PHP5). + * in different PHP versions. * @param string &$script The script will be modified in this method. */ protected function addColumnAccessorMethods(&$script) @@ -73,7 +73,7 @@ protected function addColumnAccessorMethods(&$script) /** * Adds the mutator (setter) methods for setting column values. * This is here because it is probably generic enough to apply to templates being generated - * in different languages (e.g. PHP4 and PHP5). + * in different PHP versions. * @param string &$script The script will be modified in this method. */ protected function addColumnMutatorMethods(&$script) diff --git a/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php index 733d0b9357..c2adb1a681 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php @@ -11,7 +11,7 @@ namespace Propel\Generator\Builder\Om; /** - * Generates the empty PHP5 stub object class for user object model (OM). + * Generates the empty stub object class for user object model (OM). * * This class produces the empty stub class that can be customized with application * business logic, custom behavior, etc. diff --git a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php index 5edf396ddd..c2971a2117 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php @@ -11,7 +11,7 @@ namespace Propel\Generator\Builder\Om; /** - * Generates the empty PHP5 stub class for object query + * Generates the empty stub class for object query * * This class produces the empty stub class that can be customized with application * business logic, custom behavior, etc. diff --git a/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php index 02d37e8500..779d95df5c 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php @@ -14,7 +14,7 @@ use Propel\Generator\Exception\BuildException; /** - * Generates the empty PHP5 stub query class for use with single table inheritance. + * Generates the empty stub query class for use with single table inheritance. * * This class produces the empty stub class that can be customized with * application business logic, custom behavior, etc. diff --git a/src/Propel/Generator/Builder/Om/InterfaceBuilder.php b/src/Propel/Generator/Builder/Om/InterfaceBuilder.php index b1b53025ff..8cbc975788 100644 --- a/src/Propel/Generator/Builder/Om/InterfaceBuilder.php +++ b/src/Propel/Generator/Builder/Om/InterfaceBuilder.php @@ -11,7 +11,7 @@ namespace Propel\Generator\Builder\Om; /** - * Generates the empty PHP5 stub interface for user object model (OM). + * Generates the empty stub interface for user object model (OM). * * This class produces the empty stub interface when the interface="" attribute is used * in the the schema xml. diff --git a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php index 2ff800e74b..66de78f898 100644 --- a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php @@ -14,7 +14,7 @@ use Propel\Generator\Model\Inheritance; /** - * Generates the empty PHP5 stub object class for use with inheritance in the + * Generates the empty stub object class for use with inheritance in the * user object model (OM). * * This class produces the empty stub class that can be customized with diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index b844ef4f06..7b3389afc7 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -26,7 +26,7 @@ use Propel\Runtime\Exception\PropelException; /** - * Generates a PHP5 base Object class for user object model (OM). + * Generates a base Object class for user object model (OM). * * This class produces the base object class (e.g. BaseMyTable) which contains * all the custom-built accessor and setter methods. @@ -1283,7 +1283,7 @@ protected function addSetAccessorBody(&$script, Column $column) throw new PropelException('Unknown stored set key: ' . \$e->getValue(), \$e->getCode(), \$e); } } - + return \$this->$cloConverted;"; } @@ -6171,7 +6171,7 @@ protected function addSaveBody(&$script) if (\$this->alreadyInSave) { return 0; } - + if (\$con === null) { \$con = Propel::getServiceContainer()->getWriteConnection(".$this->getTableMapClass()."::DATABASE_NAME); } diff --git a/src/Propel/Generator/Builder/Om/QueryBuilder.php b/src/Propel/Generator/Builder/Om/QueryBuilder.php index 5bcd02deb0..6633c7e39b 100644 --- a/src/Propel/Generator/Builder/Om/QueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryBuilder.php @@ -17,7 +17,7 @@ use Propel\Generator\Model\Table; /** - * Generates a PHP5 base Query class for user object model (OM). + * Generates a base Query class for user object model (OM). * * This class produces the base query class (e.g. BaseBookQuery) which contains * all the custom-built query methods. @@ -1092,7 +1092,7 @@ public function filterBy$colPhpName(\$$variableName = null, \$comparison = null) \$this->add(\$key, \${$variableName}, Criteria::BINARY_NONE); } \$this->addOr(\$key, null, Criteria::ISNULL); - + return \$this; }"; } elseif ($col->getType() == PropelTypes::ENUM) { diff --git a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php index 55c885f58a..7866a9b608 100644 --- a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php @@ -14,7 +14,7 @@ use Propel\Generator\Model\Inheritance; /** - * Generates the empty PHP5 stub query class for use with single table + * Generates the empty stub query class for use with single table * inheritance. * * This class produces the empty stub class that can be customized with @@ -84,7 +84,7 @@ public function setChild(Inheritance $child) public function getChild() { if (!$this->child) { - throw new BuildException("The PHP5MultiExtendObjectBuilder needs to be told which child class to build (via setChild() method) before it can build the stub class."); + throw new BuildException("The MultiExtendObjectBuilder needs to be told which child class to build (via setChild() method) before it can build the stub class."); } return $this->child; diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index 392eecb738..355f46ebf1 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -16,7 +16,7 @@ use Propel\Generator\Platform\PlatformInterface; /** - * Generates the PHP5 table map class for user object model (OM). + * Generates the table map class for user object model (OM). * * @author Hans Lellelid */ diff --git a/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php b/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php index 16230f11b2..3c2026591a 100644 --- a/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php +++ b/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php @@ -24,7 +24,7 @@ abstract class BookstoreTestBase extends TestCaseFixturesDatabase */ protected static $isInitialized = false; /** - * @var \PDO + * @var \PDO|\Propel\Runtime\Connection\ConnectionWrapper */ protected $con; diff --git a/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapTest.php b/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapTest.php index 2bb269bea6..f7be5c3f26 100644 --- a/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapTest.php +++ b/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapTest.php @@ -15,8 +15,6 @@ use Propel\Tests\TestCaseFixtures; /** - * Test class for PHP5TableMapBuilder. - * * @author François Zaninotto */ class GeneratedRelationMapTest extends TestCaseFixtures diff --git a/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapWithSchemasTest.php b/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapWithSchemasTest.php index 889ebb64e2..13f3196200 100644 --- a/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapWithSchemasTest.php +++ b/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapWithSchemasTest.php @@ -15,8 +15,6 @@ use Propel\Tests\TestCaseFixturesDatabase; /** - * Test class for PHP5TableMapBuilder with schemas. - * * @author Ulf Hermann * * @group database From 7d71b75b2e8e985fab773bbd4e082a9fe04a4b47 Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 10 Jul 2020 00:37:49 +0200 Subject: [PATCH 081/208] Fix syntax for PHP 8 --- .../Connection/ConnectionInterface.php | 2 +- .../Runtime/Connection/ConnectionWrapper.php | 4 +-- .../Runtime/Connection/PdoConnection.php | 33 ------------------- .../Connection/ProfilerConnectionWrapper.php | 2 +- 4 files changed, 4 insertions(+), 37 deletions(-) diff --git a/src/Propel/Runtime/Connection/ConnectionInterface.php b/src/Propel/Runtime/Connection/ConnectionInterface.php index 2d346575c5..329621aaee 100644 --- a/src/Propel/Runtime/Connection/ConnectionInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionInterface.php @@ -170,7 +170,7 @@ public function exec($statement); * @throws \Propel\Runtime\Connection\Exception\ConnectionException depending on error handling. */ - public function prepare($statement, array $driver_options = []); + public function prepare(string $statement, array $driver_options = []); /** * Executes an SQL statement, returning a result set as a Statement object. diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index 1d1a52ec3f..a02ed04317 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -332,7 +332,7 @@ public function getAttribute(int $attribute) * @param string $attribute The attribute name, or the constant name containing the attribute name (e.g. 'PDO::ATTR_CASE') * @param mixed $value */ - public function setAttribute($attribute, $value) + public function setAttribute(int $attribute, $value) { if (is_string($attribute)) { if (false === strpos($attribute, '::')) { @@ -372,7 +372,7 @@ public function setAttribute($attribute, $value) * * @return \PDOStatement */ - public function prepare($statement, array $driver_options = []) + public function prepare(string $statement, array $driver_options = []) { $statementWrapper = null; diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index 350dee0997..e63ea5b6a9 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -118,37 +118,4 @@ public function exec($statement) return $this->getDataFetcher($stmt); } - - /** - * Overwrite. Fixes HHVM strict issue. - * - * @return bool|void - */ - public function inTransaction() - { - return parent::inTransaction(); - } - - /** - * Overwrite. Fixes HHVM strict issue. - * - * @param null $name - * @return string|void - */ - public function lastInsertId($name = null) - { - return parent::lastInsertId($name); - } - - /** - * Overwrite. Fixes HHVM strict issue. - * - * @param string $string - * @param int $parameter_type - * @return string - */ - public function quote($string, $parameter_type = \PDO::PARAM_STR) - { - return parent::quote($string, $parameter_type); - } } diff --git a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php index 8be525362f..6f55cf3144 100644 --- a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php @@ -78,7 +78,7 @@ public function setAttribute($attribute, $value) /** * {@inheritDoc} */ - public function prepare($statement, array $driver_options = []) + public function prepare(string $statement, array $driver_options = []) { $this->getProfiler()->start(); From 06e61ad1303857eb4756f1d87c4272fbae0c7d0e Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 10 Jul 2020 02:02:05 +0200 Subject: [PATCH 082/208] Use adapter for PHP7+PHP8 --- .../Connection/ConnectionInterface.php | 6 +- .../Runtime/Connection/ConnectionWrapper.php | 5 +- .../Runtime/Connection/PdoConnection.php | 76 ++++++++++++++++--- .../Connection/ProfilerConnectionWrapper.php | 2 +- 4 files changed, 71 insertions(+), 18 deletions(-) diff --git a/src/Propel/Runtime/Connection/ConnectionInterface.php b/src/Propel/Runtime/Connection/ConnectionInterface.php index 329621aaee..9c549c07ba 100644 --- a/src/Propel/Runtime/Connection/ConnectionInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionInterface.php @@ -85,12 +85,12 @@ public function getAttribute(int $attribute); /** * Set an attribute. * - * @param int $attribute + * @param int|string $attribute * @param mixed $value * * @return boolean TRUE on success or FALSE on failure. */ - public function setAttribute(int $attribute, $value); + public function setAttribute($attribute, $value); /** * Returns the ID of the last inserted row or sequence value. @@ -109,7 +109,7 @@ public function setAttribute(int $attribute, $value); * a string representing the last value retrieved from the specified * sequence object. */ - public function lastInsertId($name = null); + public function lastInsertId(?string $name = null); /** * @param $data diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index a02ed04317..f9fedf9590 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -320,7 +320,6 @@ public function getAttribute(int $attribute) switch ($attribute) { case self::PROPEL_ATTR_CACHE_PREPARES: return $this->isCachePreparedStatements; - break; default: return $this->connection->getAttribute($attribute); } @@ -329,10 +328,10 @@ public function getAttribute(int $attribute) /** * Set an attribute. * - * @param string $attribute The attribute name, or the constant name containing the attribute name (e.g. 'PDO::ATTR_CASE') + * @param int|string $attribute The attribute name, or the constant name containing the attribute name (e.g. 'PDO::ATTR_CASE') * @param mixed $value */ - public function setAttribute(int $attribute, $value) + public function setAttribute($attribute, $value) { if (is_string($attribute)) { if (false === strpos($attribute, '::')) { diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index e63ea5b6a9..82f4f49842 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -16,7 +16,7 @@ /** * PDO extension that implements ConnectionInterface and builds \PDOStatement statements. */ -class PdoConnection extends \PDO implements ConnectionInterface +class PdoConnection implements ConnectionInterface { use TransactionTrait; @@ -25,6 +25,11 @@ class PdoConnection extends \PDO implements ConnectionInterface */ protected $name; + /** + * @var \PDO + */ + protected $pdo; + /** * @param string $name The datasource name associated to this connection */ @@ -43,10 +48,14 @@ public function getName() /** * Creates a PDO instance representing a connection to a database. + * + * @param string $dsn + * @param string|null $user + * @param string|null $password + * @param array|null $options */ - public function __construct($dsn, $user = null, $password = null, array $options = null) + public function __construct(string $dsn, ?string $user = null, ?string $password = null, ?array $options = null) { - // Convert option keys from a string to a \PDO:: constant $pdoOptions = []; if (is_array($options)) { @@ -56,9 +65,8 @@ public function __construct($dsn, $user = null, $password = null, array $options } } - parent::__construct($dsn, $user, $password, $pdoOptions); - - $this->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + $this->pdo = new \PDO($dsn, $user, $password, $pdoOptions); + $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); } /** @@ -66,13 +74,13 @@ public function __construct($dsn, $user = null, $password = null, array $options * * This is overridden here to allow names corresponding to PDO constant names. * - * @param integer $attribute The attribute to set (e.g. 'PDO::ATTR_CASE', or more simply 'ATTR_CASE'). + * @param int|string $attribute The attribute to set (e.g. 'PDO::ATTR_CASE', or more simply 'ATTR_CASE'). * @param mixed $value The attribute value. * * @return bool * @throws InvalidArgumentException */ - public function setAttribute(int $attribute, $value) + public function setAttribute($attribute, $value) { if (is_string($attribute) && false === strpos($attribute, '::')) { $attribute = '\PDO::' . $attribute; @@ -82,7 +90,7 @@ public function setAttribute(int $attribute, $value) $attribute = constant($attribute); } - return parent::setAttribute($attribute, $value); + $this->pdo->setAttribute($attribute, $value); } /** @@ -106,7 +114,7 @@ public function getSingleDataFetcher($data) */ public function query($statement) { - return parent::query($statement); + $this->pdo->query($statement); } /** @@ -114,8 +122,54 @@ public function query($statement) */ public function exec($statement) { - $stmt = parent::exec($statement); + $stmt = $this->pdo->exec($statement); return $this->getDataFetcher($stmt); } + + public function inTransaction() + { + // TODO: Implement inTransaction() method. + } + + public function getAttribute(int $attribute) + { + return $this->pdo->getAttribute($attribute); + } + + public function lastInsertId(?string $name = null) + { + return $this->pdo->lastInsertId(); + } + + /** + * @param string $statement + * @param array $driver_options + * + * @return bool|\PDOStatement + */ + public function prepare(string $statement, array $driver_options = []) + { + return $this->pdo->prepare($statement, $driver_options); + } + + public function quote($string, $parameter_type = \PDO::PARAM_STR) + { + return $this->pdo->quote($string, $parameter_type); + } + + public function beginTransaction() + { + return $this->pdo->beginTransaction(); + } + + public function commit() + { + return $this->pdo->commit(); + } + + public function rollBack() + { + return $this->pdo->rollBack(); + } } diff --git a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php index 6f55cf3144..64a1e44ddd 100644 --- a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php @@ -59,7 +59,7 @@ public function getProfiler() /** * Overrides the parent setAttribute to support the isSlowOnly attribute. * - * @param string $attribute The attribute name, or the constant name containing the attribute name (e.g. 'PDO::ATTR_CASE') + * @param int|string $attribute The attribute name, or the constant name containing the attribute name (e.g. 'PDO::ATTR_CASE') * @param mixed $value */ public function setAttribute($attribute, $value) From 1fee22f66f5d1ded498e058e20235ab071b1c255 Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 10 Jul 2020 12:35:19 +0200 Subject: [PATCH 083/208] Use adapter for PHP7+PHP8 --- src/Propel/Runtime/Connection/ConnectionWrapper.php | 2 +- src/Propel/Runtime/Connection/PdoConnection.php | 8 ++++++++ src/Propel/Runtime/Connection/StatementWrapper.php | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index f9fedf9590..0918464024 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -303,7 +303,7 @@ public function forceRollBack() */ public function inTransaction() { - return $this->connection->inTransaction(); + return (bool)$this->connection->inTransaction(); } /** diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index 82f4f49842..790f902441 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -30,6 +30,14 @@ class PdoConnection implements ConnectionInterface */ protected $pdo; + /** + * Forward any call to a method not found to the proxied connection. + */ + public function __call($method, $args) + { + return call_user_func_array([$this->pdo, $method], $args); + } + /** * @param string $name The datasource name associated to this connection */ diff --git a/src/Propel/Runtime/Connection/StatementWrapper.php b/src/Propel/Runtime/Connection/StatementWrapper.php index 64b97fed3d..7bbfe0bff9 100644 --- a/src/Propel/Runtime/Connection/StatementWrapper.php +++ b/src/Propel/Runtime/Connection/StatementWrapper.php @@ -287,7 +287,7 @@ public function rowCount() * * @return \Traversable */ - public function getIterator() + public function getIterator(): \Iterator { return $this->statement; } From a8d79f7a4ffd770bfa3df28a1609bb39da595dbf Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 10 Jul 2020 12:40:10 +0200 Subject: [PATCH 084/208] Use adapter for PHP7+PHP8 --- src/Propel/Runtime/Connection/ConnectionInterface.php | 4 ++-- src/Propel/Runtime/Connection/ConnectionWrapper.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Propel/Runtime/Connection/ConnectionInterface.php b/src/Propel/Runtime/Connection/ConnectionInterface.php index 9c549c07ba..d220f8d2b4 100644 --- a/src/Propel/Runtime/Connection/ConnectionInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionInterface.php @@ -99,7 +99,7 @@ public function setAttribute($attribute, $value); * object, depending on the underlying driver. For example, PDO_PGSQL() * requires you to specify the name of a sequence object for the name parameter. * - * @param string $name Name of the sequence object from which the ID should be + * @param string|null $name Name of the sequence object from which the ID should be * returned. * * @return string If a sequence name was not specified for the name parameter, @@ -109,7 +109,7 @@ public function setAttribute($attribute, $value); * a string representing the last value retrieved from the specified * sequence object. */ - public function lastInsertId(?string $name = null); + public function lastInsertId($name = null); /** * @param $data diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index 0918464024..c80c655df3 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -496,7 +496,7 @@ protected function createStatementWrapper($sql) * object, depending on the underlying driver. For example, PDO_PGSQL() * requires you to specify the name of a sequence object for the name parameter. * - * @param string $name Name of the sequence object from which the ID should be + * @param string|null $name Name of the sequence object from which the ID should be * returned. * * @return string If a sequence name was not specified for the name parameter, From b47af1db6bbf73e31ed6539174152bda2691cee7 Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 10 Jul 2020 14:00:41 +0200 Subject: [PATCH 085/208] Use adapter for PHP7+PHP8 --- src/Propel/Runtime/Connection/PdoConnection.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index 790f902441..7a98edd0a4 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -145,7 +145,12 @@ public function getAttribute(int $attribute) return $this->pdo->getAttribute($attribute); } - public function lastInsertId(?string $name = null) + /** + * @param string|null $name + * + * @return string + */ + public function lastInsertId($name = null) { return $this->pdo->lastInsertId(); } From 2e4b04337ce0be0405ffa589548580fabf2d1452 Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 10 Jul 2020 14:45:43 +0200 Subject: [PATCH 086/208] Use adapter for PHP7+PHP8 --- src/Propel/Runtime/Collection/CollectionIterator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Propel/Runtime/Collection/CollectionIterator.php b/src/Propel/Runtime/Collection/CollectionIterator.php index 970c546748..ac7c2608b8 100644 --- a/src/Propel/Runtime/Collection/CollectionIterator.php +++ b/src/Propel/Runtime/Collection/CollectionIterator.php @@ -208,9 +208,9 @@ public function append($value) $this->refreshPositions(); } - public function asort() + public function asort($sort_flags = SORT_REGULAR) { - parent::asort(); + parent::asort($sort_flags); $this->refreshPositions(); } From d140e4a26fc9cc8b13cd1c525a7ac10b69d9ea90 Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 10 Jul 2020 16:04:23 +0200 Subject: [PATCH 087/208] Use adapter for PHP7+PHP8 --- src/Propel/Runtime/Collection/CollectionIterator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Propel/Runtime/Collection/CollectionIterator.php b/src/Propel/Runtime/Collection/CollectionIterator.php index ac7c2608b8..988097cba4 100644 --- a/src/Propel/Runtime/Collection/CollectionIterator.php +++ b/src/Propel/Runtime/Collection/CollectionIterator.php @@ -214,9 +214,9 @@ public function asort($sort_flags = SORT_REGULAR) $this->refreshPositions(); } - public function ksort() + public function ksort($sort_flags = SORT_REGULAR) { - parent::ksort(); + parent::ksort($sort_flags); $this->refreshPositions(); } From ad70c980001bd6acccb78a3e018f69b728592f3c Mon Sep 17 00:00:00 2001 From: Mark Sch Date: Thu, 16 Jul 2020 14:48:12 +0200 Subject: [PATCH 088/208] Update MigrationMigrateCommand.php --- src/Propel/Generator/Command/MigrationMigrateCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Generator/Command/MigrationMigrateCommand.php b/src/Propel/Generator/Command/MigrationMigrateCommand.php index 411afe1938..f798290613 100644 --- a/src/Propel/Generator/Command/MigrationMigrateCommand.php +++ b/src/Propel/Generator/Command/MigrationMigrateCommand.php @@ -81,7 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!$manager->getFirstUpMigrationTimestamp()) { $output->writeln('All migrations were already executed - nothing to migrate.'); - return static::CODE_ERROR; + return static::CODE_SUCCESS; } $timestamps = $manager->getValidMigrationTimestamps(); From 69cfe791cad3a02c6c26efd9b23af78f58718e13 Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 17 Jul 2020 12:23:20 +0200 Subject: [PATCH 089/208] Fix log class to adhere to void return --- .../Generator/Builder/Om/templates/baseObjectMethods.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Propel/Generator/Builder/Om/templates/baseObjectMethods.php b/src/Propel/Generator/Builder/Om/templates/baseObjectMethods.php index 864a52dd44..31ec0a8b17 100644 --- a/src/Propel/Generator/Builder/Om/templates/baseObjectMethods.php +++ b/src/Propel/Generator/Builder/Om/templates/baseObjectMethods.php @@ -170,11 +170,11 @@ public function setVirtualColumn($name, $value) * * @param string $msg * @param int $priority One of the Propel::LOG_* logging levels - * @return boolean + * @return void */ protected function log($msg, $priority = Propel::LOG_INFO) { - return Propel::log(get_class($this) . ': ' . $msg, $priority); + Propel::log(get_class($this) . ': ' . $msg, $priority); } /** From 81fdf431cb349f3044c8ef82680a9ee86dab1d80 Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 17 Jul 2020 13:16:51 +0200 Subject: [PATCH 090/208] Cleanup outdated dependencies and min versions. --- .travis.yml | 223 --------------------- README.md | 6 +- composer.json | 16 +- tests/composer/composer-php8.json | 2 +- tests/composer/composer-symfony27-max.json | 55 ----- tests/composer/composer-symfony27-min.json | 55 ----- tests/composer/composer-symfony3-max.json | 16 +- tests/composer/composer-symfony3-min.json | 16 +- tests/composer/composer-symfony4-max.json | 2 +- tests/composer/composer-symfony4-min.json | 2 +- tests/composer/composer-symfony5-max.json | 2 +- tests/composer/composer-symfony5-min.json | 2 +- 12 files changed, 32 insertions(+), 365 deletions(-) delete mode 100644 tests/composer/composer-symfony27-max.json delete mode 100644 tests/composer/composer-symfony27-min.json diff --git a/.travis.yml b/.travis.yml index 6a5a329672..089a946cd1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ git: dist: bionic php: - - 7.1 - 7.2 - 7.3 - 7.4 @@ -40,12 +39,6 @@ script: jobs: include: - - php: 7.1 - dist: trusty - env: DB=mysql MARIADB=10.1 - services: - addons: - mariadb: 10.1 - php: 7.2 dist: trusty env: DB=mysql MARIADB=10.1 @@ -65,10 +58,6 @@ jobs: addons: mariadb: 10.1 - - php: 7.1 - env: DB=mysql MARIADB=10.2 - addons: - mariadb: 10.2 - php: 7.2 env: DB=mysql MARIADB=10.2 addons: @@ -99,16 +88,6 @@ jobs: addons: mariadb: 10.3 - - php: 7.1 - env: DB=mysql MARIADB=10.4 DB_USER=travis - addons: - mariadb: 10.4 - before_script: - - sudo mysql -e 'drop user if exists travis@localhost;' - - sudo mysql -e 'create user travis@localhost;' - - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; - - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; - - ./tests/bin/setup.$DB.sh - php: 7.2 env: DB=mysql MARIADB=10.4 DB_USER=travis addons: @@ -140,10 +119,6 @@ jobs: - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; - ./tests/bin/setup.$DB.sh - - php: 7.1 - env: DB=pgsql POSTGRES=9.4 - addons: - postgresql: 9.4 - php: 7.2 env: DB=pgsql POSTGRES=9.4 addons: @@ -157,10 +132,6 @@ jobs: addons: postgresql: 9.4 - - php: 7.1 - env: DB=pgsql POSTGRES=9.5 - addons: - postgresql: 9.5 - php: 7.2 env: DB=pgsql POSTGRES=9.5 addons: @@ -174,10 +145,6 @@ jobs: addons: postgresql: 9.5 - - php: 7.1 - env: DB=pgsql POSTGRES=9.6 - addons: - postgresql: 9.6 - php: 7.2 env: DB=pgsql POSTGRES=9.6 addons: @@ -208,10 +175,6 @@ jobs: addons: postgresql: 10 - - php: 7.1 - env: DB=pgsql POSTGRES=11 - addons: - postgresql: 11 - php: 7.2 env: DB=pgsql POSTGRES=11 addons: @@ -225,22 +188,6 @@ jobs: addons: postgresql: 11 - - php: 7.1 - env: DB=pgsql POSTGRES=12 PGPORT=5432 - addons: - postgresql: 12 - apt: - packages: - - postgresql-12 - - postgresql-client-12 - install: - - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf - - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf - - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf - - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - composer install -v - - composer show - php: 7.2 env: DB=pgsql POSTGRES=12 PGPORT=5432 addons: @@ -297,20 +244,6 @@ jobs: - COMPOSER=./tests/composer/composer-php8.json composer install --ignore-platform-reqs - composer show - - name: "PHP 7.4, Agnostic, Symfony ~2.7" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - - composer show - - name: "PHP 7.4, Agnostic, Symfony ^2.7" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - - composer show - name: "PHP 7.4, Agnostic, Symfony ~3" php: 7.4 env: DB=agnostic @@ -354,20 +287,6 @@ jobs: - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show - - name: "PHP 7.4, MySql, Symfony ~2.7" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - - composer show - - name: "PHP 7.4, MySql, Symfony ^2.7" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - - composer show - name: "PHP 7.4, MySql, Symfony ~3" php: 7.4 env: DB=mysql @@ -411,20 +330,6 @@ jobs: - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show - - name: "PHP 7.3, Agnostic, Symfony ~2.7" - php: 7.3 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - - composer show - - name: "PHP 7.3, Agnostic, Symfony ^2.7" - php: 7.3 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - - composer show - name: "PHP 7.3, Agnostic, Symfony ~3" php: 7.3 env: DB=agnostic @@ -468,20 +373,6 @@ jobs: - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show - - name: "PHP 7.3, MySql, Symfony ~2.7" - php: 7.3 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - - composer show - - name: "PHP 7.3, MySql, Symfony ^2.7" - php: 7.3 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - - composer show - name: "PHP 7.3, MySql, Symfony ~3" php: 7.3 env: DB=mysql @@ -525,20 +416,6 @@ jobs: - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show - - name: "PHP 7.2, Agnostic, Symfony ~2.7" - php: 7.2 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - - composer show - - name: "PHP 7.2, Agnostic, Symfony ^2.7" - php: 7.2 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - - composer show - name: "PHP 7.2, Agnostic, Symfony ~3" php: 7.2 env: DB=agnostic @@ -582,20 +459,6 @@ jobs: - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show - - name: "PHP 7.2, MySql, Symfony ~2.7" - php: 7.2 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - - composer show - - name: "PHP 7.2, MySql, Symfony ^2.7" - php: 7.2 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - - composer show - name: "PHP 7.2, MySql, Symfony ~3" php: 7.2 env: DB=mysql @@ -639,92 +502,6 @@ jobs: - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show - - name: "PHP 7.1, Agnostic, Symfony ~2.7" - php: 7.1 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - - composer show - - name: "PHP 7.1, Agnostic, Symfony ^2.7" - php: 7.1 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - - composer show - - name: "PHP 7.1, Agnostic, Symfony ~3" - php: 7.1 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - - composer show - - name: "PHP 7.1, Agnostic, Symfony ^3" - php: 7.1 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - - composer show - - name: "PHP 7.1, Agnostic, Symfony ~4" - php: 7.1 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - - composer show - - name: "PHP 7.1, Agnostic, Symfony ^4" - php: 7.1 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - - composer show - - - name: "PHP 7.1, MySql, Symfony ~2.7" - php: 7.1 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-min.json composer install - - composer show - - name: "PHP 7.1, MySql, Symfony ^2.7" - php: 7.1 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony27-max.json composer install - - composer show - - name: "PHP 7.1, MySql, Symfony ~3" - php: 7.1 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - - composer show - - name: "PHP 7.1, MySql, Symfony ^3" - php: 7.1 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - - composer show - - name: "PHP 7.1, MySql, Symfony ~4" - php: 7.1 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - - composer show - - name: "PHP 7.1, MySql, Symfony ^4" - php: 7.1 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - - composer show - - name: Checks php: 7.4 env: DB=agnostic CHECKS=1 diff --git a/README.md b/README.md index 39d536b4a4..4bd7f36103 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Propel2 -Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 7 and up. +Propel2 is an open-source Object-Relational Mapping (ORM) for PHP. [![Build Status](https://travis-ci.org/propelorm/Propel2.svg?branch=master)](https://travis-ci.org/propelorm/Propel2) [![Code Climate](https://codeclimate.com/github/propelorm/Propel2/badges/gpa.svg)](https://codeclimate.com/github/propelorm/Propel2) @@ -21,7 +21,7 @@ Propel2 uses the following Symfony2 Components: Propel2 also relies on [**Composer**](https://github.com/composer/composer) to manage dependencies but you also can use [ClassLoader](https://github.com/symfony/ClassLoader) (see the `autoload.php.dist` file for instance). -Propel2 is only supported on PHP 7 and up. +Propel2 is only supported on PHP 7.2 and up. ## Installation @@ -32,7 +32,7 @@ Read the [Propel documentation](http://propelorm.org/documentation/01-installati ## Contribute Everybody can contribute to Propel2. Just fork it, and send Pull Requests. -You have to follow [Propel2 Coding Standards](https://github.com/propelorm/Propel2/wiki/Coding-Standards) and provides unit +You have to follow [Propel2 Coding Standards](https://github.com/propelorm/Propel2/wiki/Coding-Standards) and provides unit tests as much as possible. Also [check out the roadmap](https://github.com/propelorm/Propel2/wiki) to get an overview of what we are working on! Please see our [contribution guideline](http://propelorm.org/contribute.html). Thank you! diff --git a/composer.json b/composer.json index 8d1691b891..ae79729aa6 100644 --- a/composer.json +++ b/composer.json @@ -16,14 +16,14 @@ } ], "require": { - "php": ">=7.1", - "symfony/yaml": "^2.7.0||^3.3.0||^4.0.0||^5.0.0", - "symfony/config": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/console": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/filesystem": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/finder": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/translation": "^2.7.0||^3.0.0||^4.0.0||^5.0.0", - "symfony/validator": "^2.7.0||^3.3.0||^4.0.0||^5.0.0", + "php": ">=7.2", + "symfony/yaml": "^3.4.0||^4.3.0||^5.0.0", + "symfony/config": "^3.4.0||^4.3.0||^5.0.0", + "symfony/console": "^3.4.0||^4.3.0||^5.0.0", + "symfony/filesystem": "^3.4.0||^4.3.0||^5.0.0", + "symfony/finder": "^3.4.0||^4.3.0||^5.0.0", + "symfony/translation": "^3.4.0||^4.3.0||^5.0.0", + "symfony/validator": "^3.4.0||^4.3.0||^5.0.0", "psr/log": "^1.0" }, "require-dev": { diff --git a/tests/composer/composer-php8.json b/tests/composer/composer-php8.json index 8aea8a336d..618b59c9b7 100644 --- a/tests/composer/composer-php8.json +++ b/tests/composer/composer-php8.json @@ -18,7 +18,7 @@ } ], "require": { - "php": ">=7.1", + "php": ">=7.2", "symfony/yaml": "^5.0.0", "symfony/config": "^5.0.0", "symfony/console": "^5.0.0", diff --git a/tests/composer/composer-symfony27-max.json b/tests/composer/composer-symfony27-max.json deleted file mode 100644 index 37b323f9b0..0000000000 --- a/tests/composer/composer-symfony27-max.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "propel/propel", - "type": "library", - "description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.", - "keywords": [ - "ORM", - "persistence", - "Active Record" - ], - "homepage": "http://www.propelorm.org/", - "license": "MIT", - "authors": [ - { - "name": "William Durand", - "email": "william.durand1@gmail.com" - } - ], - "require": { - "php": ">=7.1", - "symfony/yaml": "^2.7.0", - "symfony/config": "^2.7.0", - "symfony/console": "^2.7.0", - "symfony/filesystem": "^2.7.0", - "symfony/finder": "^2.7.0", - "symfony/translation": "^2.7.0", - "symfony/validator": "^2.7.0", - "psr/log": "^1.0" - }, - "require-dev": { - "monolog/monolog": "^1.3", - "phpstan/phpstan": "^0.12.4", - "phpunit/phpunit": "^7.5.15" - }, - "suggest": { - "monolog/monolog": "The recommended logging library to use with Propel." - }, - "autoload": { - "psr-4": { - "Propel\\": "src/Propel/" - } - }, - "bin": [ - "bin/propel" - ], - "scripts": { - "stan": [ - "vendor/bin/phpstan analyze -l 1 -c tests/phpstan.neon src/" - ] - }, - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - } -} diff --git a/tests/composer/composer-symfony27-min.json b/tests/composer/composer-symfony27-min.json deleted file mode 100644 index 2cec994dd2..0000000000 --- a/tests/composer/composer-symfony27-min.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "propel/propel", - "type": "library", - "description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.", - "keywords": [ - "ORM", - "persistence", - "Active Record" - ], - "homepage": "http://www.propelorm.org/", - "license": "MIT", - "authors": [ - { - "name": "William Durand", - "email": "william.durand1@gmail.com" - } - ], - "require": { - "php": ">=7.1", - "symfony/yaml": "~2.7.0", - "symfony/config": "~2.7.0", - "symfony/console": "~2.7.0", - "symfony/filesystem": "~2.7.0", - "symfony/finder": "~2.7.0", - "symfony/translation": "~2.7.0", - "symfony/validator": "~2.7.0", - "psr/log": "^1.0" - }, - "require-dev": { - "monolog/monolog": "^1.3", - "phpstan/phpstan": "^0.12.4", - "phpunit/phpunit": "^7.5.15" - }, - "suggest": { - "monolog/monolog": "The recommended logging library to use with Propel." - }, - "autoload": { - "psr-4": { - "Propel\\": "src/Propel/" - } - }, - "bin": [ - "bin/propel" - ], - "scripts": { - "stan": [ - "vendor/bin/phpstan analyze -l 1 -c tests/phpstan.neon src/" - ] - }, - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - } -} diff --git a/tests/composer/composer-symfony3-max.json b/tests/composer/composer-symfony3-max.json index cfbcf4dbd8..e2185069fc 100644 --- a/tests/composer/composer-symfony3-max.json +++ b/tests/composer/composer-symfony3-max.json @@ -16,14 +16,14 @@ } ], "require": { - "php": ">=7.1", - "symfony/yaml": "^3.3.0", - "symfony/config": "^3.0.0", - "symfony/console": "^3.0.0", - "symfony/filesystem": "^3.0.0", - "symfony/finder": "^3.0.0", - "symfony/translation": "^3.0.0", - "symfony/validator": "^3.3.0", + "php": ">=7.2", + "symfony/yaml": "^3.4.0", + "symfony/config": "^3.4.0", + "symfony/console": "^3.4.0", + "symfony/filesystem": "^3.4.0", + "symfony/finder": "^3.4.0", + "symfony/translation": "^3.4.0", + "symfony/validator": "^3.4.0", "psr/log": "^1.0" }, "require-dev": { diff --git a/tests/composer/composer-symfony3-min.json b/tests/composer/composer-symfony3-min.json index 8d35767395..7e29e38ef9 100644 --- a/tests/composer/composer-symfony3-min.json +++ b/tests/composer/composer-symfony3-min.json @@ -16,14 +16,14 @@ } ], "require": { - "php": ">=7.1", - "symfony/yaml": "~3.3.0", - "symfony/config": "~3.0.0", - "symfony/console": "~3.0.0", - "symfony/filesystem": "~3.0.0", - "symfony/finder": "~3.0.0", - "symfony/translation": "~3.0.0", - "symfony/validator": "~3.3.0", + "php": ">=7.2", + "symfony/yaml": "~3.4.0", + "symfony/config": "~3.4.0", + "symfony/console": "~3.4.0", + "symfony/filesystem": "~3.4.0", + "symfony/finder": "~3.4.0", + "symfony/translation": "~3.4.0", + "symfony/validator": "~3.4.0", "psr/log": "^1.0" }, "require-dev": { diff --git a/tests/composer/composer-symfony4-max.json b/tests/composer/composer-symfony4-max.json index 9414f38a34..f8d63c2c57 100644 --- a/tests/composer/composer-symfony4-max.json +++ b/tests/composer/composer-symfony4-max.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=7.1", + "php": ">=7.2", "symfony/yaml": "^4.0.0", "symfony/config": "^4.0.0", "symfony/console": "^4.0.0", diff --git a/tests/composer/composer-symfony4-min.json b/tests/composer/composer-symfony4-min.json index a418298458..d3e3b9c65f 100644 --- a/tests/composer/composer-symfony4-min.json +++ b/tests/composer/composer-symfony4-min.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=7.1", + "php": ">=7.2", "symfony/yaml": "~4.0.0", "symfony/config": "~4.0.0", "symfony/console": "~4.0.0", diff --git a/tests/composer/composer-symfony5-max.json b/tests/composer/composer-symfony5-max.json index 902cb8bb7e..62046f4b57 100644 --- a/tests/composer/composer-symfony5-max.json +++ b/tests/composer/composer-symfony5-max.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=7.1", + "php": ">=7.2", "symfony/yaml": "^5.0.0", "symfony/config": "^5.0.0", "symfony/console": "^5.0.0", diff --git a/tests/composer/composer-symfony5-min.json b/tests/composer/composer-symfony5-min.json index 3f12147871..6521c86c09 100644 --- a/tests/composer/composer-symfony5-min.json +++ b/tests/composer/composer-symfony5-min.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=7.1", + "php": ">=7.2", "symfony/yaml": "~5.0.0", "symfony/config": "~5.0.0", "symfony/console": "~5.0.0", From 538771a25df41f3ee5c02c4469c0edc504c945ce Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 17 Jul 2020 13:51:42 +0200 Subject: [PATCH 091/208] Remove also EOL Postgres 9.4 --- .travis.yml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index 089a946cd1..de1819f81f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -71,10 +71,6 @@ jobs: addons: mariadb: 10.2 - - php: 7.1 - env: DB=mysql MARIADB=10.3 - addons: - mariadb: 10.3 - php: 7.2 env: DB=mysql MARIADB=10.3 addons: @@ -119,19 +115,6 @@ jobs: - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; - ./tests/bin/setup.$DB.sh - - php: 7.2 - env: DB=pgsql POSTGRES=9.4 - addons: - postgresql: 9.4 - - php: 7.3 - env: DB=pgsql POSTGRES=9.4 - addons: - postgresql: 9.4 - - php: 7.4 - env: DB=pgsql POSTGRES=9.4 - addons: - postgresql: 9.4 - - php: 7.2 env: DB=pgsql POSTGRES=9.5 addons: @@ -158,10 +141,6 @@ jobs: addons: postgresql: 9.6 - - php: 7.1 - env: DB=pgsql POSTGRES=10 - addons: - postgresql: 10 - php: 7.2 env: DB=pgsql POSTGRES=10 addons: From d2e7b4879fce85c632402c5e4f2967df3d3e34a1 Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 17 Jul 2020 14:55:32 +0200 Subject: [PATCH 092/208] Fix nullable docblock for mutator methods. --- src/Propel/Generator/Builder/Om/ObjectBuilder.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index 36c050de56..9629a185d5 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -1601,16 +1601,22 @@ public function addJsonMutatorComment(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ public function addMutatorComment(&$script, Column $column) { $clo = $column->getLowercasedName(); + $type = $column->getPhpType(); + if ($type && !$column->isNotNull()) { + $type .= '|null'; + } + $script .= " /** * Set the value of [$clo] column. - * ".$column->getDescription()." - * @param ".($column->getPhpType() ?: 'mixed')." \$v new value - * @return \$this|".$this->getObjectClassName(true)." The current object (for fluent API support) + * " . $column->getDescription() . " + * @param " . $type . " \$v New value + * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) */"; } From b92c841349a7df059bb5eb96c6aaaa1cdd58f870 Mon Sep 17 00:00:00 2001 From: W0rma Date: Sat, 18 Jul 2020 12:50:29 +0200 Subject: [PATCH 093/208] Remove default value of optional parameters followed by required parameters as this behaviour is deprecated in PHP 8.0 --- src/Propel/Generator/Builder/Om/AbstractOMBuilder.php | 2 +- .../Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php | 6 +++--- .../Runtime/ActiveQuery/ModelCriteriaWithNamespaceTest.php | 6 +++--- .../Runtime/ActiveQuery/ModelCriteriaWithSchemaTest.php | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php index 4d3d27ab55..df74706763 100644 --- a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php @@ -767,7 +767,7 @@ protected function getCrossFKAddMethodInformation(CrossForeignKeys $crossFKs, $c */ protected function extractCrossInformation( CrossForeignKeys $crossFKs, - $crossFKToIgnore = null, + $crossFKToIgnore, &$signature, &$shortSignature, &$normalizedShortSignature, diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php index 4c9e580e32..aeccd1db78 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php @@ -141,13 +141,13 @@ public static function conditionsForTestReplaceNames() /** * @dataProvider conditionsForTestReplaceNames */ - public function testReplaceNames($origClause, $columnPhpName = false, $modifiedClause) + public function testReplaceNames($origClause, $columnPhpName, $modifiedClause) { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); - $this->doTestReplaceNames($c, BookTableMap::getTableMap(), $origClause, $columnPhpName = false, $modifiedClause); + $this->doTestReplaceNames($c, BookTableMap::getTableMap(), $origClause, $columnPhpName, $modifiedClause); } - public function doTestReplaceNames(Criteria $c, $tableMap, $origClause, $columnPhpName = false, $modifiedClause) + public function doTestReplaceNames(Criteria $c, $tableMap, $origClause, $columnPhpName, $modifiedClause) { $c->replaceNames($origClause); $columns = $c->replacedColumns; diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithNamespaceTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithNamespaceTest.php index 333872b989..b5df54acdc 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithNamespaceTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithNamespaceTest.php @@ -40,13 +40,13 @@ public static function conditionsForTestReplaceNamesWithNamespaces() /** * @dataProvider conditionsForTestReplaceNamesWithNamespaces */ - public function testReplaceNamesWithNamespaces($origClause, $columnPhpName = false, $modifiedClause) + public function testReplaceNamesWithNamespaces($origClause, $columnPhpName, $modifiedClause) { $c = new TestableModelCriteriaWithNamespace('bookstore_namespaced', 'Foo\\Bar\\NamespacedBook'); - $this->doTestReplaceNames($c, \Foo\Bar\Map\NamespacedBookTableMap::getTableMap(), $origClause, $columnPhpName = false, $modifiedClause); + $this->doTestReplaceNames($c, \Foo\Bar\Map\NamespacedBookTableMap::getTableMap(), $origClause, $columnPhpName, $modifiedClause); } - public function doTestReplaceNames($c, $tableMap, $origClause, $columnPhpName = false, $modifiedClause) + public function doTestReplaceNames($c, $tableMap, $origClause, $columnPhpName, $modifiedClause) { $c->replaceNames($origClause); $columns = $c->replacedColumns; diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithSchemaTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithSchemaTest.php index ee8a7702b0..fa220eb7f5 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithSchemaTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithSchemaTest.php @@ -49,13 +49,13 @@ public static function conditionsForTestReplaceNamesWithSchemas() /** * @dataProvider conditionsForTestReplaceNamesWithSchemas */ - public function testReplaceNamesWithSchemas($origClause, $columnPhpName = false, $modifiedClause) + public function testReplaceNamesWithSchemas($origClause, $columnPhpName, $modifiedClause) { $c = new TestableModelCriteriaWithSchema('bookstore-schemas', '\Propel\Tests\BookstoreSchemas\BookstoreContest'); - $this->doTestReplaceNames($c, BookstoreContestTableMap::getTableMap(), $origClause, $columnPhpName = false, $modifiedClause); + $this->doTestReplaceNames($c, BookstoreContestTableMap::getTableMap(), $origClause, $columnPhpName, $modifiedClause); } - public function doTestReplaceNames($c, $tableMap, $origClause, $columnPhpName = false, $modifiedClause) + public function doTestReplaceNames($c, $tableMap, $origClause, $columnPhpName, $modifiedClause) { $c->replaceNames($origClause); $columns = $c->replacedColumns; From 02c6031f489a71cc84b629635326cfce7bb11bad Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 8 Jul 2020 13:05:01 +0200 Subject: [PATCH 094/208] Prepare for phpstan level 3. --- phpstan-baseline.neon | 10 --- phpstan.neon | 2 +- .../Common/Config/ConfigurationManager.php | 2 +- src/Propel/Common/Util/SetColumnConverter.php | 15 ++-- .../Generator/Builder/DataModelBuilder.php | 80 +++++++++++++------ .../Builder/Om/AbstractObjectBuilder.php | 2 +- .../Builder/Om/ExtensionQueryBuilder.php | 2 +- .../Generator/Builder/Om/QueryBuilder.php | 2 +- .../Generator/Builder/Om/TableMapBuilder.php | 4 +- .../Generator/Builder/Util/SchemaReader.php | 9 ++- .../Config/GeneratorConfigInterface.php | 4 +- .../Generator/Model/BehaviorableTrait.php | 2 +- src/Propel/Generator/Model/Column.php | 2 +- src/Propel/Generator/Model/Database.php | 8 +- src/Propel/Generator/Model/ForeignKey.php | 41 +--------- src/Propel/Generator/Model/Index.php | 5 +- src/Propel/Generator/Model/Table.php | 8 +- .../Generator/Platform/DefaultPlatform.php | 77 +++++++++++++----- .../Generator/Platform/MssqlPlatform.php | 8 +- .../Generator/Platform/MysqlPlatform.php | 12 ++- .../Generator/Platform/OraclePlatform.php | 4 +- .../Generator/Platform/PgsqlPlatform.php | 5 ++ .../Generator/Platform/PlatformInterface.php | 7 ++ .../Generator/Platform/SqlitePlatform.php | 10 ++- .../Reverse/AbstractSchemaParser.php | 2 +- src/Propel/Generator/Util/BehaviorLocator.php | 8 +- src/Propel/Generator/Util/PhpParser.php | 2 +- src/Propel/Runtime/ActiveQuery/Criteria.php | 14 ++-- .../Criterion/AbstractCriterion.php | 13 ++- .../Criterion/AbstractModelCriterion.php | 2 +- .../ActiveQuery/Criterion/RawCriterion.php | 2 +- .../Criterion/RawModelCriterion.php | 2 +- .../Runtime/Adapter/MSSQL/MssqlPropelPDO.php | 27 +++---- .../Runtime/Collection/OnDemandIterator.php | 2 +- .../Connection/ConnectionInterface.php | 4 +- .../ConnectionManagerPrimaryReplica.php | 4 +- .../Connection/ConnectionManagerSingle.php | 2 +- .../Runtime/Connection/ConnectionWrapper.php | 6 +- .../Runtime/Connection/PdoConnection.php | 4 +- .../Runtime/Connection/StatementWrapper.php | 4 +- .../Runtime/DataFetcher/ArrayDataFetcher.php | 6 +- .../Runtime/DataFetcher/PDODataFetcher.php | 2 +- .../Runtime/Formatter/AbstractFormatter.php | 3 + .../Runtime/Formatter/ArrayFormatter.php | 5 +- .../Formatter/SimpleArrayFormatter.php | 10 ++- src/Propel/Runtime/Map/RelationMap.php | 2 +- src/Propel/Runtime/Map/TableMap.php | 4 +- .../StandardServiceContainer.php | 5 +- src/Propel/Runtime/Util/Profiler.php | 5 +- .../Tests/Runtime/Util/ProfilerTest.php | 24 +++--- 50 files changed, 282 insertions(+), 203 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 96adc92a20..e61d7ba32e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -465,11 +465,6 @@ parameters: count: 1 path: src/Propel/Generator/Manager/SqlManager.php - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\ForeignKey\\:\\:getLocalForeignMapping\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Model/ForeignKey.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:isEarly\\(\\)\\.$#" count: 1 @@ -650,11 +645,6 @@ parameters: count: 3 path: src/Propel/Runtime/ActiveQuery/Criteria.php - - - message: "#^Call to private method getClauses\\(\\) of class Propel\\\\Runtime\\\\ActiveQuery\\\\Criterion\\\\AbstractCriterion\\.$#" - count: 2 - path: src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:ignoreCase\\(\\)\\.$#" count: 2 diff --git a/phpstan.neon b/phpstan.neon index 412838c5ae..b67559e48b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,7 @@ includes: - phpstan-baseline.neon parameters: - level: 2 + level: 3 paths: - '%rootDir%/../../../src/' excludes_analyse: diff --git a/src/Propel/Common/Config/ConfigurationManager.php b/src/Propel/Common/Config/ConfigurationManager.php index 3b8fe63288..a383f90af5 100644 --- a/src/Propel/Common/Config/ConfigurationManager.php +++ b/src/Propel/Common/Config/ConfigurationManager.php @@ -62,7 +62,7 @@ public function get() * It ca be useful to get, in example, only 'generator' values. * * @param string $section the section to be returned - * @return array + * @return array|null */ public function getSection($section) { diff --git a/src/Propel/Common/Util/SetColumnConverter.php b/src/Propel/Common/Util/SetColumnConverter.php index 9e135a6167..4686177a5b 100644 --- a/src/Propel/Common/Util/SetColumnConverter.php +++ b/src/Propel/Common/Util/SetColumnConverter.php @@ -24,14 +24,13 @@ class SetColumnConverter * * @param mixed $val * @param array $valueSet - * @return int|null + * @return string|int * * @throws SetColumnConverterException */ public static function convertToInt($val, array $valueSet) { if ($val === null) { - return 0; } if (!is_array($val)) { @@ -44,16 +43,16 @@ public static function convertToInt($val, array $valueSet) } $bitValueArr[array_search($value, $valueSet)] = '1'; } - + return base_convert(implode(array_reverse($bitValueArr)), 2, 10); } /** - * Converts set column integer value to corresponding array. - * + * Converts set column integer value to corresponding array. + * * @param mixed $val * @param array $valueSet - * + * * @return array * * @throws SetColumnConverterException @@ -61,7 +60,7 @@ public static function convertToInt($val, array $valueSet) public static function convertIntToArray($val, array $valueSet) { if ($val === null) { - + return []; } $bitValueArr = array_reverse(str_split(base_convert($val, 10, 2))); @@ -76,4 +75,4 @@ public static function convertIntToArray($val, array $valueSet) } return $valueArr; } -} \ No newline at end of file +} diff --git a/src/Propel/Generator/Builder/DataModelBuilder.php b/src/Propel/Generator/Builder/DataModelBuilder.php index 4a61a08d9a..5aad38bcb2 100644 --- a/src/Propel/Generator/Builder/DataModelBuilder.php +++ b/src/Propel/Generator/Builder/DataModelBuilder.php @@ -59,43 +59,43 @@ abstract class DataModelBuilder /** * Object builder class for current table. - * @var DataModelBuilder + * @var ObjectBuilder */ private $objectBuilder; /** * Stub Object builder class for current table. - * @var DataModelBuilder + * @var ObjectBuilder */ private $stubObjectBuilder; /** * Query builder class for current table. - * @var DataModelBuilder + * @var ObjectBuilder */ private $queryBuilder; /** * Stub Query builder class for current table. - * @var DataModelBuilder + * @var ObjectBuilder */ private $stubQueryBuilder; /** * TableMap builder class for current table. - * @var DataModelBuilder + * @var TableMapBuilder */ protected $tablemapBuilder; /** * Stub Interface builder class for current table. - * @var DataModelBuilder + * @var ObjectBuilder */ private $interfaceBuilder; /** * Stub child object for current table. - * @var DataModelBuilder + * @var MultiExtendObjectBuilder */ private $multiExtendObjectBuilder; @@ -140,7 +140,9 @@ public function getPluralizer() public function getObjectBuilder() { if (!isset($this->objectBuilder)) { - $this->objectBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'object'); + /** @var ObjectBuilder $builder */ + $builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'object'); + $this->objectBuilder = $builder; } return $this->objectBuilder; @@ -153,7 +155,9 @@ public function getObjectBuilder() public function getStubObjectBuilder() { if (!isset($this->stubObjectBuilder)) { - $this->stubObjectBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'objectstub'); + /** @var ObjectBuilder $builder */ + $builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'objectstub'); + $this->stubObjectBuilder = $builder; } return $this->stubObjectBuilder; @@ -166,7 +170,9 @@ public function getStubObjectBuilder() public function getQueryBuilder() { if (!isset($this->queryBuilder)) { - $this->queryBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'query'); + /** @var ObjectBuilder $builder */ + $builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'query'); + $this->queryBuilder = $builder; } return $this->queryBuilder; @@ -179,7 +185,9 @@ public function getQueryBuilder() public function getStubQueryBuilder() { if (!isset($this->stubQueryBuilder)) { - $this->stubQueryBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'querystub'); + /** @var ObjectBuilder $builder */ + $builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'querystub'); + $this->stubQueryBuilder = $builder; } return $this->stubQueryBuilder; @@ -192,7 +200,9 @@ public function getStubQueryBuilder() public function getTableMapBuilder() { if (!isset($this->tablemapBuilder)) { - $this->tablemapBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'tablemap'); + /** @var TableMapBuilder $builder */ + $builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'tablemap'); + $this->tablemapBuilder = $builder; } return $this->tablemapBuilder; @@ -205,7 +215,9 @@ public function getTableMapBuilder() public function getInterfaceBuilder() { if (!isset($this->interfaceBuilder)) { - $this->interfaceBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'interface'); + /** @var ObjectBuilder $builder */ + $builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'interface'); + $this->interfaceBuilder = $builder; } return $this->interfaceBuilder; @@ -218,7 +230,9 @@ public function getInterfaceBuilder() public function getMultiExtendObjectBuilder() { if (!isset($this->multiExtendObjectBuilder)) { - $this->multiExtendObjectBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'objectmultiextend'); + /** @var MultiExtendObjectBuilder $builder */ + $builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'objectmultiextend'); + $this->multiExtendObjectBuilder= $builder; } return $this->multiExtendObjectBuilder; @@ -251,7 +265,10 @@ public function getNewBuilder(Table $table, $classname) */ public function getNewObjectBuilder(Table $table) { - return $this->getGeneratorConfig()->getConfiguredBuilder($table, 'object'); + /** @var ObjectBuilder $builder */ + $builder = $this->getGeneratorConfig()->getConfiguredBuilder($table, 'object'); + + return $builder; } /** @@ -265,7 +282,10 @@ public function getNewObjectBuilder(Table $table) */ public function getNewStubObjectBuilder(Table $table) { - return $this->getGeneratorConfig()->getConfiguredBuilder($table, 'objectstub'); + /** @var ObjectBuilder $builder */ + $builder = $this->getGeneratorConfig()->getConfiguredBuilder($table, 'objectstub'); + + return $builder; } /** @@ -279,7 +299,10 @@ public function getNewStubObjectBuilder(Table $table) */ public function getNewQueryBuilder(Table $table) { - return $this->getGeneratorConfig()->getConfiguredBuilder($table, 'query'); + /** @var QueryBuilder $builder */ + $builder = $this->getGeneratorConfig()->getConfiguredBuilder($table, 'query'); + + return $builder; } /** @@ -293,14 +316,17 @@ public function getNewQueryBuilder(Table $table) */ public function getNewStubQueryBuilder(Table $table) { - return $this->getGeneratorConfig()->getConfiguredBuilder($table, 'querystub'); + /** @var QueryBuilder $builder */ + $builder = $this->getGeneratorConfig()->getConfiguredBuilder($table, 'querystub'); + + return $builder; } /** * Returns new Query Inheritance builder class for this table. * * @param Inheritance $child - * @return ObjectBuilder + * @return QueryInheritanceBuilder */ public function getNewQueryInheritanceBuilder(Inheritance $child) { @@ -315,7 +341,7 @@ public function getNewQueryInheritanceBuilder(Inheritance $child) * Returns new stub Query Inheritance builder class for this table. * * @param Inheritance $child - * @return ObjectBuilder + * @return QueryInheritanceBuilder */ public function getNewStubQueryInheritanceBuilder(Inheritance $child) { @@ -328,11 +354,17 @@ public function getNewStubQueryInheritanceBuilder(Inheritance $child) /** * Returns new stub Query Inheritance builder class for this table. - * @return TableMapBuilder + * + * @param \Propel\Generator\Model\Table $table + * + * @return \Propel\Generator\Builder\Om\TableMapBuilder */ public function getNewTableMapBuilder(Table $table) { - return $this->getGeneratorConfig()->getConfiguredBuilder($table, 'tablemap'); + /** @var \Propel\Generator\Builder\Om\TableMapBuilder $builder */ + $builder = $this->getGeneratorConfig()->getConfiguredBuilder($table, 'tablemap'); + + return $builder; } /** @@ -355,7 +387,7 @@ public function getGeneratorConfig() * 'database.adapter.mysql.tableType * * @param string $name - * @return string + * @return string|null */ public function getBuildProperty($name) { @@ -363,7 +395,7 @@ public function getBuildProperty($name) return $this->getGeneratorConfig()->getConfigProperty($name); } - return null; // just to be explicit + return null; } /** diff --git a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php index 91374b9434..ea26bc690c 100644 --- a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php @@ -174,7 +174,7 @@ protected function hasDefaultValues() * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @return boolean */ - public function hasBehaviorModifier($hookName, $modifier = null) + public function hasBehaviorModifier($hookName, $modifier = '') { return parent::hasBehaviorModifier($hookName, 'ObjectBuilderModifier'); } diff --git a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php index 8be001f8ff..edcde40e3f 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php @@ -98,7 +98,7 @@ protected function addClassClose(&$script) * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @return boolean */ - public function hasBehaviorModifier($hookName, $modifier = null) + public function hasBehaviorModifier($hookName, $modifier = '') { return parent::hasBehaviorModifier($hookName, 'QueryBuilderModifier'); } diff --git a/src/Propel/Generator/Builder/Om/QueryBuilder.php b/src/Propel/Generator/Builder/Om/QueryBuilder.php index 0bfd73675a..7d0b41af79 100644 --- a/src/Propel/Generator/Builder/Om/QueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryBuilder.php @@ -1714,7 +1714,7 @@ protected function basePostUpdate(\$affectedRows, ConnectionInterface \$con) * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @return boolean */ - public function hasBehaviorModifier($hookName, $modifier = null) + public function hasBehaviorModifier($hookName, $modifier = '') { return parent::hasBehaviorModifier($hookName, 'QueryBuilderModifier'); } diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index 9834d9ec11..79847bffa1 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -733,10 +733,10 @@ public function addClearRelatedInstancePool() /** * Checks whether any registered behavior on that table has a modifier for a hook * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" - * @param null $modifier + * @param string $modifier * @return boolean */ - public function hasBehaviorModifier($hookName, $modifier = null) + public function hasBehaviorModifier($hookName, $modifier = '') { return parent::hasBehaviorModifier($hookName, 'TableMapBuilderModifier'); } diff --git a/src/Propel/Generator/Builder/Util/SchemaReader.php b/src/Propel/Generator/Builder/Util/SchemaReader.php index 7299e110f5..d7c45f2e68 100644 --- a/src/Propel/Generator/Builder/Util/SchemaReader.php +++ b/src/Propel/Generator/Builder/Util/SchemaReader.php @@ -110,13 +110,13 @@ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) * populated Schema structure. * * @param string $xmlFile The input file to parse. - * @return Schema populated by xmlFile. + * @return Schema|null populated by xmlFile. */ public function parseFile($xmlFile) { // we don't want infinite recursion if ($this->isAlreadyParsed($xmlFile)) { - return; + return null; } return $this->parseString(file_get_contents($xmlFile), $xmlFile); @@ -128,14 +128,15 @@ public function parseFile($xmlFile) * * @param string $xmlString The input string to parse. * @param string $xmlFile The input file name. - * @return Schema + * @return Schema|null */ public function parseString($xmlString, $xmlFile = null) { // we don't want infinite recursion if ($this->isAlreadyParsed($xmlFile)) { - return; + return null; } + // store current schema file path $this->schemasTagsStack[$xmlFile] = []; $this->currentXmlFile = $xmlFile; diff --git a/src/Propel/Generator/Config/GeneratorConfigInterface.php b/src/Propel/Generator/Config/GeneratorConfigInterface.php index b6ac912073..57aeddcf8d 100644 --- a/src/Propel/Generator/Config/GeneratorConfigInterface.php +++ b/src/Propel/Generator/Config/GeneratorConfigInterface.php @@ -43,7 +43,7 @@ public function getConfiguredPluralizer(); * * @param ConnectionInterface $con * @param string $database - * @return PlatformInterface + * @return PlatformInterface|null * * @throws \Propel\Generator\Exception\ClassNotFoundException if the platform class doesn't exists * @throws \Propel\Generator\Exception\BuildException if the class isn't an implementation of PlatformInterface @@ -56,7 +56,7 @@ public function getConfiguredPlatform(ConnectionInterface $con = null, $database * @param ConnectionInterface $con * @param string $database * - * @return SchemaParserInterface + * @return SchemaParserInterface|null * * @throws \Propel\Generator\Exception\ClassNotFoundException if the class doesn't exist * @throws \Propel\Generator\Exception\BuildException if the class isn't an implementation of SchemaParserInterface diff --git a/src/Propel/Generator/Model/BehaviorableTrait.php b/src/Propel/Generator/Model/BehaviorableTrait.php index f459c674f7..a335d2bd82 100644 --- a/src/Propel/Generator/Model/BehaviorableTrait.php +++ b/src/Propel/Generator/Model/BehaviorableTrait.php @@ -115,7 +115,7 @@ public function hasBehavior($id) * Get behavior by id * * @param string $id the behavior id - * @return Behavior a behavior object or null if the behavior doesn't exist + * @return Behavior|null A behavior object or null if the behavior doesn't exist */ public function getBehavior($id) { diff --git a/src/Propel/Generator/Model/Column.php b/src/Propel/Generator/Model/Column.php index e33c8b43cb..df8d996a71 100644 --- a/src/Propel/Generator/Model/Column.php +++ b/src/Propel/Generator/Model/Column.php @@ -1292,7 +1292,7 @@ public function getDefaultValueString() } if ($this->isNumericType()) { - return (float) $defaultValue->getValue(); + return (string)$defaultValue->getValue(); } if ($this->isTextType() || $this->getDefaultValue()->isExpression()) { diff --git a/src/Propel/Generator/Model/Database.php b/src/Propel/Generator/Model/Database.php index 9a817f5141..c864fb2454 100644 --- a/src/Propel/Generator/Model/Database.php +++ b/src/Propel/Generator/Model/Database.php @@ -433,7 +433,7 @@ public function hasTable($name, $caseInsensitive = false) * * @param string $name * @param boolean $caseInsensitive - * @return Table + * @return Table|null */ public function getTable($name, $caseInsensitive = false) { @@ -469,7 +469,7 @@ public function hasTableByPhpName($phpName) * Returns the table object with the specified PHP name. * * @param string $phpName - * @return Table + * @return Table|null */ public function getTableByPhpName($phpName) { @@ -477,7 +477,7 @@ public function getTableByPhpName($phpName) return $this->tablesByPhpName[$phpName]; } - return null; // just to be explicit + return null; } /** @@ -708,7 +708,7 @@ public function addDomain($data) * Returns the already configured domain object by its name. * * @param string $name - * @return Domain + * @return Domain|null */ public function getDomain($name) { diff --git a/src/Propel/Generator/Model/ForeignKey.php b/src/Propel/Generator/Model/ForeignKey.php index cef46198ca..366761dddb 100644 --- a/src/Propel/Generator/Model/ForeignKey.php +++ b/src/Propel/Generator/Model/ForeignKey.php @@ -86,12 +86,12 @@ class ForeignKey extends MappingModel private $localColumns; /** - * @var string[] + * @var (string|null)[] */ private $foreignColumns; /** - * @var string[] + * @var (string|null)[] */ private $localValues; @@ -952,43 +952,6 @@ public function getOtherFks() return $fks; } - /** - * Whether at least one foreign column is also the primary key of the foreign table. - * - * @return boolean True if there is at least one column that is a primary key of the foreign table - */ - public function isAtLeastOneForeignPrimaryKey() - { - $cols = $this->getForeignPrimaryKeys(); - - return 0 !== count($cols); - } - - /** - * Returns all foreign columns which are also a primary key of the foreign table. - * - * @return array Column[] - */ - public function getForeignPrimaryKeys() - { - $lfmap = $this->getLocalForeignMapping(); - $foreignTable = $this->getForeignTable(); - - $foreignPKCols = []; - foreach ($foreignTable->getPrimaryKey() as $fPKCol) { - $foreignPKCols[$fPKCol->getName()] = true; - } - - $foreignCols = []; - foreach ($this->getLocalColumn() as $colName) { - if ($foreignPKCols[$lfmap[$colName]]) { - $foreignCols[] = $foreignTable->getColumn($lfmap[$colName]); - } - } - - return $foreignCols; - } - /** * Returns all local columns which are also a primary key of the local table. * diff --git a/src/Propel/Generator/Model/Index.php b/src/Propel/Generator/Model/Index.php index c242c07dbd..465898f513 100644 --- a/src/Propel/Generator/Model/Index.php +++ b/src/Propel/Generator/Model/Index.php @@ -42,7 +42,7 @@ class Index extends MappingModel protected $columnObjects = []; /** - * @var string[] + * @var int[] */ protected $columnsSize; @@ -237,7 +237,7 @@ public function hasColumnSize($name) * * @param string $name * @param boolean $caseInsensitive - * @return integer + * @return int|null */ public function getColumnSize($name, $caseInsensitive = false) { @@ -249,6 +249,7 @@ public function getColumnSize($name, $caseInsensitive = false) } return null; } + return isset($this->columnsSize[$name]) ? $this->columnsSize[$name] : null; } diff --git a/src/Propel/Generator/Model/Table.php b/src/Propel/Generator/Model/Table.php index c2781ee6eb..99a480b30c 100644 --- a/src/Propel/Generator/Model/Table.php +++ b/src/Propel/Generator/Model/Table.php @@ -683,7 +683,7 @@ public function getChildrenColumn() /** * Returns the subclasses that can be created from this table. * - * @return array + * @return array|null */ public function getChildrenNames() { @@ -1665,12 +1665,12 @@ public function hasColumn($column, $caseInsensitive = false) * * @param string $name The name of the column (e.g. 'my_column') * @param boolean $caseInsensitive Whether the check is case insensitive. - * @return Column + * @return Column|null */ public function getColumn($name, $caseInsensitive = false) { if (!$this->hasColumn($name, $caseInsensitive)) { - return null; // just to be explicit + return null; } if ($caseInsensitive) { @@ -1684,7 +1684,7 @@ public function getColumn($name, $caseInsensitive = false) * Returns a specified column by its php name. * * @param string $phpName - * @return Column + * @return Column|null */ public function getColumnByPhpName($phpName) { diff --git a/src/Propel/Generator/Platform/DefaultPlatform.php b/src/Propel/Generator/Platform/DefaultPlatform.php index f4667baf08..6514aa4bbc 100644 --- a/src/Propel/Generator/Platform/DefaultPlatform.php +++ b/src/Propel/Generator/Platform/DefaultPlatform.php @@ -625,7 +625,7 @@ public function getAddForeignKeysDDL(Table $table) public function getAddForeignKeyDDL(ForeignKey $fk) { if ($fk->isSkipSql() || $fk->isPolymorphic()) { - return; + return ''; } $pattern = " ALTER TABLE %s ADD %s; @@ -641,12 +641,12 @@ public function getAddForeignKeyDDL(ForeignKey $fk) * Builds the DDL SQL to drop a foreign key. * * @param ForeignKey $fk - * @return string + * @return string|null */ public function getDropForeignKeyDDL(ForeignKey $fk) { if ($fk->isSkipSql() || $fk->isPolymorphic()) { - return; + return null; } $pattern = " ALTER TABLE %s DROP CONSTRAINT %s; @@ -660,13 +660,17 @@ public function getDropForeignKeyDDL(ForeignKey $fk) /** * Builds the DDL SQL for a ForeignKey object. + * + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return string */ public function getForeignKeyDDL(ForeignKey $fk) { if ($fk->isSkipSql() || $fk->isPolymorphic()) { - return; + return ''; } + $pattern = "CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)"; @@ -688,6 +692,11 @@ public function getForeignKeyDDL(ForeignKey $fk) return $script; } + /** + * @param string $comment + * + * @return string + */ public function getCommentLineDDL($comment) { $pattern = "-- %s @@ -696,6 +705,11 @@ public function getCommentLineDDL($comment) return sprintf($pattern, $comment); } + /** + * @param string $comment + * + * @return string + */ public function getCommentBlockDDL($comment) { $pattern = " @@ -711,6 +725,8 @@ public function getCommentBlockDDL($comment) * Builds the DDL SQL to modify a database * based on a DatabaseDiff instance * + * @param \Propel\Generator\Model\Diff\DatabaseDiff $databaseDiff + * * @return string */ public function getModifyDatabaseDDL(DatabaseDiff $databaseDiff) @@ -746,6 +762,10 @@ public function getModifyDatabaseDDL(DatabaseDiff $databaseDiff) /** * Builds the DDL SQL to rename a table + * + * @param string $fromTableName + * @param string $toTableName + * * @return string */ public function getRenameTableDDL($fromTableName, $toTableName) @@ -764,6 +784,8 @@ public function getRenameTableDDL($fromTableName, $toTableName) * Builds the DDL SQL to alter a table * based on a TableDiff instance * + * @param \Propel\Generator\Model\Diff\TableDiff $tableDiff + * * @return string */ public function getModifyTableDDL(TableDiff $tableDiff) @@ -777,45 +799,45 @@ public function getModifyTableDDL(TableDiff $tableDiff) $ret .= $this->getDropForeignKeyDDL($fk); } foreach ($tableDiff->getModifiedFks() as $fkModification) { - list($fromFk) = $fkModification; + [$fromFk] = $fkModification; $ret .= $this->getDropForeignKeyDDL($fromFk); } foreach ($tableDiff->getRemovedIndices() as $index) { $ret .= $this->getDropIndexDDL($index); } foreach ($tableDiff->getModifiedIndices() as $indexModification) { - list($fromIndex) = $indexModification; + [$fromIndex] = $indexModification; $ret .= $this->getDropIndexDDL($fromIndex); } - $columnChanges = ''; + $columnChangeString = ''; // alter table structure if ($tableDiff->hasModifiedPk()) { - $columnChanges .= $this->getDropPrimaryKeyDDL($tableDiff->getFromTable()); + $columnChangeString .= $this->getDropPrimaryKeyDDL($tableDiff->getFromTable()); } foreach ($tableDiff->getRenamedColumns() as $columnRenaming) { - $columnChanges .= $this->getRenameColumnDDL($columnRenaming[0], $columnRenaming[1]); + $columnChangeString .= $this->getRenameColumnDDL($columnRenaming[0], $columnRenaming[1]); } if ($modifiedColumns = $tableDiff->getModifiedColumns()) { - $columnChanges .= $this->getModifyColumnsDDL($modifiedColumns); + $columnChangeString .= $this->getModifyColumnsDDL($modifiedColumns); } if ($addedColumns = $tableDiff->getAddedColumns()) { - $columnChanges .= $this->getAddColumnsDDL($addedColumns); + $columnChangeString .= $this->getAddColumnsDDL($addedColumns); } foreach ($tableDiff->getRemovedColumns() as $column) { - $columnChanges .= $this->getRemoveColumnDDL($column); + $columnChangeString .= $this->getRemoveColumnDDL($column); } // add new indices and foreign keys if ($tableDiff->hasModifiedPk()) { - $columnChanges .= $this->getAddPrimaryKeyDDL($tableDiff->getToTable()); + $columnChangeString .= $this->getAddPrimaryKeyDDL($tableDiff->getToTable()); } - if ($columnChanges) { + if ($columnChangeString) { //merge column changes into one command. This is more compatible especially with PK constraints. - $changes = explode(';', $columnChanges); + $changes = explode(';', $columnChangeString); $columnChanges = []; foreach ($changes as $change) { @@ -845,14 +867,14 @@ public function getModifyTableDDL(TableDiff $tableDiff) // create indices, foreign keys foreach ($tableDiff->getModifiedIndices() as $indexModification) { - list($oldIndex, $toIndex) = $indexModification; + [$oldIndex, $toIndex] = $indexModification; $ret .= $this->getAddIndexDDL($toIndex); } foreach ($tableDiff->getAddedIndices() as $index) { $ret .= $this->getAddIndexDDL($index); } foreach ($tableDiff->getModifiedFks() as $fkModification) { - list(, $toFk) = $fkModification; + [, $toFk] = $fkModification; $ret .= $this->getAddForeignKeyDDL($toFk); } foreach ($tableDiff->getAddedFks() as $fk) { @@ -928,7 +950,7 @@ public function getModifyTableIndicesDDL(TableDiff $tableDiff) } foreach ($tableDiff->getModifiedIndices() as $indexModification) { - list($fromIndex, $toIndex) = $indexModification; + [$fromIndex, $toIndex] = $indexModification; $ret .= $this->getDropIndexDDL($fromIndex); $ret .= $this->getAddIndexDDL($toIndex); } @@ -955,7 +977,7 @@ public function getModifyTableForeignKeysDDL(TableDiff $tableDiff) } foreach ($tableDiff->getModifiedFks() as $fkModification) { - list($fromFk, $toFk) = $fkModification; + [$fromFk, $toFk] = $fkModification; $ret .= $this->getDropForeignKeyDDL($fromFk); $ret .= $this->getAddForeignKeyDDL($toFk); } @@ -966,6 +988,8 @@ public function getModifyTableForeignKeysDDL(TableDiff $tableDiff) /** * Builds the DDL SQL to remove a column * + * @param \Propel\Generator\Model\Column $column + * * @return string */ public function getRemoveColumnDDL(Column $column) @@ -983,6 +1007,9 @@ public function getRemoveColumnDDL(Column $column) /** * Builds the DDL SQL to rename a column * + * @param \Propel\Generator\Model\Column $fromColumn + * @param \Propel\Generator\Model\Column $toColumn + * * @return string */ public function getRenameColumnDDL(Column $fromColumn, Column $toColumn) @@ -1001,6 +1028,8 @@ public function getRenameColumnDDL(Column $fromColumn, Column $toColumn) /** * Builds the DDL SQL to modify a column * + * @param \Propel\Generator\Model\Diff\ColumnDiff $columnDiff + * * @return string */ public function getModifyColumnDDL(ColumnDiff $columnDiff) @@ -1053,6 +1082,8 @@ public function getModifyColumnsDDL($columnDiffs) /** * Builds the DDL SQL to remove a column * + * @param \Propel\Generator\Model\Column $column + * * @return string */ public function getAddColumnDDL(Column $column) @@ -1308,6 +1339,13 @@ public function getDateFormatter() * Get the PHP snippet for binding a value to a column. * Warning: duplicates logic from AdapterInterface::bindValue(). * Any code modification here must be ported there. + * + * @param \Propel\Generator\Model\Column $column + * @param string $identifier + * @param string $columnValueAccessor + * @param string $tab + * + * @return string */ public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = " ") { @@ -1387,6 +1425,7 @@ public function getDefaultTypeSize($type) * which the most Platforms requires but which is not always explicitly defined in the table model. * * @param Table $table The table object which gets modified. + * @return void */ public function normalizeTable(Table $table) { diff --git a/src/Propel/Generator/Platform/MssqlPlatform.php b/src/Propel/Generator/Platform/MssqlPlatform.php index e5c39929b5..d75ea5f6ae 100644 --- a/src/Propel/Generator/Platform/MssqlPlatform.php +++ b/src/Propel/Generator/Platform/MssqlPlatform.php @@ -165,12 +165,12 @@ public function getPrimaryKeyDDL(Table $table) /** * @param \Propel\Generator\Model\ForeignKey $fk * - * @return string|null + * @return string */ public function getAddForeignKeyDDL(ForeignKey $fk) { if ($fk->isSkipSql() || $fk->isPolymorphic()) { - return null; + return ''; } $pattern = " @@ -204,12 +204,12 @@ public function getUniqueDDL(Unique $unique) /** * @param \Propel\Generator\Model\ForeignKey $fk * - * @return string|null + * @return string */ public function getForeignKeyDDL(ForeignKey $fk) { if ($fk->isSkipSql() || $fk->isPolymorphic()) { - return null; + return ''; } $pattern = 'CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)'; diff --git a/src/Propel/Generator/Platform/MysqlPlatform.php b/src/Propel/Generator/Platform/MysqlPlatform.php index 1c52ff7866..70c86c0d4b 100644 --- a/src/Propel/Generator/Platform/MysqlPlatform.php +++ b/src/Propel/Generator/Platform/MysqlPlatform.php @@ -551,11 +551,16 @@ public function getForeignKeyDDL(ForeignKey $fk) return ''; } + /** + * @param \Propel\Generator\Model\ForeignKey $fk + * + * @return string|null + */ public function getDropForeignKeyDDL(ForeignKey $fk) { if (!$this->supportsForeignKeys($fk->getTable())) return ''; if ($fk->isSkipSql() || $fk->isPolymorphic()) { - return; + return null; } $pattern = " ALTER TABLE %s DROP FOREIGN KEY %s; @@ -567,6 +572,11 @@ public function getDropForeignKeyDDL(ForeignKey $fk) ); } + /** + * @param string $comment + * + * @return string + */ public function getCommentBlockDDL($comment) { $pattern = " diff --git a/src/Propel/Generator/Platform/OraclePlatform.php b/src/Propel/Generator/Platform/OraclePlatform.php index a45cf3ecdf..efb8365ff3 100644 --- a/src/Propel/Generator/Platform/OraclePlatform.php +++ b/src/Propel/Generator/Platform/OraclePlatform.php @@ -220,12 +220,12 @@ public function getUniqueDDL(Unique $unique) /** * @param \Propel\Generator\Model\ForeignKey $fk * - * @return string|null + * @return string */ public function getForeignKeyDDL(ForeignKey $fk) { if ($fk->isSkipSql() || $fk->isPolymorphic()) { - return null; + return ''; } $pattern = "CONSTRAINT %s diff --git a/src/Propel/Generator/Platform/PgsqlPlatform.php b/src/Propel/Generator/Platform/PgsqlPlatform.php index 1811335e56..625d795e43 100755 --- a/src/Propel/Generator/Platform/PgsqlPlatform.php +++ b/src/Propel/Generator/Platform/PgsqlPlatform.php @@ -242,6 +242,11 @@ public function getAddTablesDDL(Database $database) return $ret; } + /** + * @param \Propel\Generator\Model\ForeignKey $fk + * + * @return string + */ public function getForeignKeyDDL(ForeignKey $fk) { $script = parent::getForeignKeyDDL($fk); diff --git a/src/Propel/Generator/Platform/PlatformInterface.php b/src/Propel/Generator/Platform/PlatformInterface.php index e1744431bd..a3b4894503 100644 --- a/src/Propel/Generator/Platform/PlatformInterface.php +++ b/src/Propel/Generator/Platform/PlatformInterface.php @@ -256,6 +256,13 @@ public function normalizeTable(Table $table); * Get the PHP snippet for binding a value to a column. * Warning: duplicates logic from AdapterInterface::bindValue(). * Any code modification here must be ported there. + * + * @param \Propel\Generator\Model\Column $column + * @param string $identifier + * @param string $columnValueAccessor + * @param string $tab + * + * @return string */ public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = " "); diff --git a/src/Propel/Generator/Platform/SqlitePlatform.php b/src/Propel/Generator/Platform/SqlitePlatform.php index fde9d5670a..a5352439ff 100644 --- a/src/Propel/Generator/Platform/SqlitePlatform.php +++ b/src/Propel/Generator/Platform/SqlitePlatform.php @@ -214,7 +214,7 @@ public function getMigrationTableDDL(TableDiff $tableDiff) } foreach ($tableDiff->getRenamedColumns() as $col) { - list ($from, $to) = $col; + [$from, $to] = $col; $fieldMap[$from->getName()] = $to->getName(); } @@ -285,6 +285,7 @@ public function getAddTablesDDL(Database $database) * those UNIQUE is otherwise automatically created by the sqlite engine. * * @param Table $table + * @return void */ public function normalizeTable(Table $table) { @@ -496,10 +497,15 @@ public function getAddTableDDL(Table $table) ); } + /** + * @param \Propel\Generator\Model\ForeignKey $fk + * + * @return string + */ public function getForeignKeyDDL(ForeignKey $fk) { if ($fk->isSkipSql() || !$this->foreignKeySupport || $fk->isPolymorphic()) { - return; + return ''; } $pattern = "FOREIGN KEY (%s) REFERENCES %s (%s)"; diff --git a/src/Propel/Generator/Reverse/AbstractSchemaParser.php b/src/Propel/Generator/Reverse/AbstractSchemaParser.php index b5ac7af678..4c9d089cda 100644 --- a/src/Propel/Generator/Reverse/AbstractSchemaParser.php +++ b/src/Propel/Generator/Reverse/AbstractSchemaParser.php @@ -173,7 +173,7 @@ abstract protected function getTypeMapping(); * Gets a mapped Propel type for specified native type. * * @param string $nativeType - * @return string The mapped Propel type. + * @return string|null The mapped Propel type. */ protected function getMappedPropelType($nativeType) { diff --git a/src/Propel/Generator/Util/BehaviorLocator.php b/src/Propel/Generator/Util/BehaviorLocator.php index 7b30fee6b1..61515a5df1 100644 --- a/src/Propel/Generator/Util/BehaviorLocator.php +++ b/src/Propel/Generator/Util/BehaviorLocator.php @@ -45,7 +45,7 @@ public function __construct(GeneratorConfigInterface $config = null) /** * Searches a composer file * - * @return SplFileInfo the found composer file or null if composer file isn't found + * @return SplFileInfo|null The found composer file or null if composer file isn't found */ private function findComposerFile($fileName) { @@ -213,7 +213,7 @@ private function loadBehaviors($composerLock) * * @param array $package * @throws BuildException - * @return array behavior data + * @return array|null Behavior data */ private function loadBehavior($package) { @@ -229,9 +229,9 @@ private function loadBehavior($package) 'class' => $extra['class'], 'package' => $package['name'] ]; - } else { - throw new BuildException(sprintf('Cannot read behavior name and class from package %s', $package['name'])); } + + throw new BuildException(sprintf('Cannot read behavior name and class from package %s', $package['name'])); } } diff --git a/src/Propel/Generator/Util/PhpParser.php b/src/Propel/Generator/Util/PhpParser.php index fc6155924b..d324320e59 100644 --- a/src/Propel/Generator/Util/PhpParser.php +++ b/src/Propel/Generator/Util/PhpParser.php @@ -38,7 +38,7 @@ class PhpParser /** * methodName => methodCode * - * @var string[] + * @var (string|false)[] */ private $knownMethodCache = array(); diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index d64b9e5150..312c1c484e 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -196,9 +196,9 @@ class Criteria /** * Storage of having data. - * @var AbstractCriterion + * @var AbstractCriterion|null */ - protected $having = null; + protected $having; /** * Storage of join data. collection of Join objects. @@ -535,7 +535,7 @@ public function getCriterion($column) /** * Method to return the latest Criterion in a table. * - * @return AbstractCriterion A Criterion or null no Criterion is added. + * @return AbstractCriterion|null A Criterion or null no Criterion is added. */ public function getLastCriterion() { @@ -599,7 +599,7 @@ public function getNewCriterion($column, $value = null, $comparison = self::EQUA * Method to return a String table name. * * @param string $name Name of the key. - * @return string The value of the object at key. + * @return string|null The value of the object at key. */ public function getColumnName($name) { @@ -637,7 +637,7 @@ public function getTablesColumns() * Method to return a comparison String. * * @param string $key String name of the key. - * @return string A String with the value of the object at key. + * @return string|null A String with the value of the object at key. */ public function getComparison($key) { @@ -702,7 +702,7 @@ public function setPrimaryTableName($tableName) * Method to return a String table name. * * @param string $name The name of the key. - * @return string The value of table for criterion at key. + * @return string|null The value of table for criterion at key. */ public function getTableName($name) { @@ -1055,7 +1055,7 @@ public function getJoin($name) /** * @param string $name The name of the join clause * - * @return Join A join object + * @return bool */ public function hasJoin($name) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php index 1c65457459..6386247bb2 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php @@ -39,7 +39,7 @@ abstract class AbstractCriterion /** * Table name - * @var string + * @var string|null */ protected $table; @@ -213,7 +213,7 @@ public function setAdapter(AdapterInterface $v) * Get the list of clauses in this Criterion. * @return self[] */ - private function getClauses() + public function getClauses() { return $this->clauses; } @@ -268,8 +268,10 @@ public function addOr(AbstractCriterion $criterion) public function appendPsTo(&$sb, array &$params) { if (!$this->clauses) { - return $this->appendPsForUniqueClauseTo($sb, $params); + $this->appendPsForUniqueClauseTo($sb, $params); + return; } + // if there are sub criterions, they must be combined to this criterion $sb .= str_repeat('(', count($this->clauses)); $this->appendPsForUniqueClauseTo($sb, $params); @@ -280,6 +282,9 @@ public function appendPsTo(&$sb, array &$params) } } + /** + * @return string + */ public function __toString() { $sb = ''; @@ -337,7 +342,7 @@ public function equals($obj) $isEquiv &= $this->value === $crit->getValue(); } - return $isEquiv; + return (bool)$isEquiv; } /** diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php index 64e3745d1d..50c6073b9a 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php @@ -88,6 +88,6 @@ public function equals($obj) $isEquiv &= $this->value === $crit->getValue(); } - return $isEquiv; + return (bool)$isEquiv; } } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php index 6f6d9ce6f5..8a41735cdb 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php @@ -23,7 +23,7 @@ class RawCriterion extends AbstractCriterion /** * Binding type to be used for Criteria::RAW comparison - * @var string any of the PDO::PARAM_ constant values + * @var int Any of the PDO::PARAM_ constant values */ protected $type; diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php index d79374b3b3..99553d6f8f 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php @@ -24,7 +24,7 @@ class RawModelCriterion extends AbstractModelCriterion { /** * Binding type to be used for Criteria::RAW comparison - * @var string any of the PDO::PARAM_ constant values + * @var int Any of the PDO::PARAM_ constant values */ protected $type; diff --git a/src/Propel/Runtime/Adapter/MSSQL/MssqlPropelPDO.php b/src/Propel/Runtime/Adapter/MSSQL/MssqlPropelPDO.php index 8a8ca94706..ecf9b25625 100644 --- a/src/Propel/Runtime/Adapter/MSSQL/MssqlPropelPDO.php +++ b/src/Propel/Runtime/Adapter/MSSQL/MssqlPropelPDO.php @@ -26,14 +26,14 @@ class MssqlPropelPDO extends PropelPDO * It is necessary to override the abstract PDO transaction functions here, as * the PDO driver for MSSQL does not support transactions. * - * @return integer + * @return bool */ public function beginTransaction() { $return = true; $opcount = $this->getNestedTransactionCount(); if ($opcount === 0) { - $return = self::exec('BEGIN TRANSACTION'); + $return = (bool)$this->exec('BEGIN TRANSACTION'); if ($this->useDebug) { $this->log('Begin transaction: ' . __METHOD__); } @@ -50,7 +50,7 @@ public function beginTransaction() * It is necessary to override the abstract PDO transaction functions here, as * the PDO driver for MSSQL does not support transactions. * - * @return integer + * @return bool */ public function commit() { @@ -60,12 +60,11 @@ public function commit() if ($opcount === 1) { if ($this->isUncommitable) { throw new PropelException('Cannot commit because a nested transaction was rolled back'); - } else { - $return = self::exec('COMMIT TRANSACTION'); - if ($this->useDebug) { - $this->log('Commit transaction: ' . __METHOD__); - } + } + $return = (bool)$this->exec('COMMIT TRANSACTION'); + if ($this->useDebug) { + $this->log('Commit transaction: ' . __METHOD__); } } $this->nestedTransactionCount--; @@ -80,7 +79,7 @@ public function commit() * It is necessary to override the abstract PDO transaction functions here, as * the PDO driver for MSSQL does not support transactions. * - * @return integer + * @return bool */ public function rollBack() { @@ -88,7 +87,7 @@ public function rollBack() $opcount = $this->getNestedTransactionCount(); if ($opcount > 0) { if ($opcount === 1) { - $return = self::exec('ROLLBACK TRANSACTION'); + $return = (bool)$this->exec('ROLLBACK TRANSACTION'); if ($this->useDebug) { $this->log('Rollback transaction: ' . __METHOD__); } @@ -108,7 +107,7 @@ public function rollBack() * It is necessary to override the abstract PDO transaction functions here, as * the PDO driver for MSSQL does not support transactions. * - * @return integer + * @return bool */ public function forceRollBack() { @@ -117,7 +116,7 @@ public function forceRollBack() if ($opcount > 0) { // If we're in a transaction, always roll it back // regardless of nesting level. - $return = self::exec('ROLLBACK TRANSACTION'); + $return = (bool)$this->exec('ROLLBACK TRANSACTION'); // reset nested transaction count to 0 so that we don't // try to commit (or rollback) the transaction outside this scope. @@ -132,12 +131,12 @@ public function forceRollBack() } /** - * @param string $seqname + * @param string|null $seqname * @return integer */ public function lastInsertId($seqname = null) { - $result = self::query('SELECT SCOPE_IDENTITY()'); + $result = $this->query('SELECT SCOPE_IDENTITY()'); return (int) $result->fetchColumn(); } diff --git a/src/Propel/Runtime/Collection/OnDemandIterator.php b/src/Propel/Runtime/Collection/OnDemandIterator.php index 5ef01463c3..8a68fc1815 100644 --- a/src/Propel/Runtime/Collection/OnDemandIterator.php +++ b/src/Propel/Runtime/Collection/OnDemandIterator.php @@ -43,7 +43,7 @@ class OnDemandIterator implements \Iterator protected $enableInstancePoolingOnFinish; /** - * @param AbstractFormatter $formatter + * @param ObjectFormatter $formatter * @param DataFetcherInterface $dataFetcher */ public function __construct(AbstractFormatter $formatter, DataFetcherInterface $dataFetcher) diff --git a/src/Propel/Runtime/Connection/ConnectionInterface.php b/src/Propel/Runtime/Connection/ConnectionInterface.php index 79d9841efc..14a558adf1 100644 --- a/src/Propel/Runtime/Connection/ConnectionInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionInterface.php @@ -99,10 +99,10 @@ public function setAttribute($attribute, $value); * object, depending on the underlying driver. For example, PDO_PGSQL() * requires you to specify the name of a sequence object for the name parameter. * - * @param string $name Name of the sequence object from which the ID should be + * @param string|null $name Name of the sequence object from which the ID should be * returned. * - * @return string If a sequence name was not specified for the name parameter, + * @return string|int If a sequence name was not specified for the name parameter, * returns a string representing the row ID of the last row that was * inserted into the database. * If a sequence name was specified for the name parameter, returns diff --git a/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php b/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php index cab81eaf51..bb160cf43d 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php @@ -28,7 +28,7 @@ class ConnectionManagerPrimaryReplica implements ConnectionManagerInterface protected $writeConfiguration = []; /** - * @var \Propel\Runtime\Connection\ConnectionInterface + * @var \Propel\Runtime\Connection\ConnectionInterface|null */ protected $writeConnection; @@ -38,7 +38,7 @@ class ConnectionManagerPrimaryReplica implements ConnectionManagerInterface protected $readConfiguration; /** - * @var \Propel\Runtime\Connection\ConnectionInterface + * @var \Propel\Runtime\Connection\ConnectionInterface|null */ protected $readConnection; diff --git a/src/Propel/Runtime/Connection/ConnectionManagerSingle.php b/src/Propel/Runtime/Connection/ConnectionManagerSingle.php index 09640a6f33..69adfe80b0 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerSingle.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerSingle.php @@ -28,7 +28,7 @@ class ConnectionManagerSingle implements ConnectionManagerInterface protected $configuration = []; /** - * @var \Propel\Runtime\Connection\ConnectionInterface + * @var \Propel\Runtime\Connection\ConnectionInterface|null */ protected $connection; diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index 3f287beeb2..4d0265bc67 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -53,7 +53,7 @@ class ConnectionWrapper implements ConnectionInterface, LoggerAwareInterface /** * The wrapped connection class - * @var ConnectionInterface + * @var ConnectionInterface|null */ protected $connection; @@ -500,10 +500,10 @@ protected function createStatementWrapper($sql) * object, depending on the underlying driver. For example, PDO_PGSQL() * requires you to specify the name of a sequence object for the name parameter. * - * @param string $name Name of the sequence object from which the ID should be + * @param string|null $name Name of the sequence object from which the ID should be * returned. * - * @return string If a sequence name was not specified for the name parameter, + * @return string|int If a sequence name was not specified for the name parameter, * returns a string representing the row ID of the last row that was * inserted into the database. * If a sequence name was specified for the name parameter, returns diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index b499d8c56d..d4b9c216cd 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -132,8 +132,8 @@ public function inTransaction() /** * Overwrite. Fixes HHVM strict issue. * - * @param null $name - * @return string|void + * @param string|null $name + * @return string|int */ public function lastInsertId($name = null) { diff --git a/src/Propel/Runtime/Connection/StatementWrapper.php b/src/Propel/Runtime/Connection/StatementWrapper.php index 64b97fed3d..1be409fb73 100644 --- a/src/Propel/Runtime/Connection/StatementWrapper.php +++ b/src/Propel/Runtime/Connection/StatementWrapper.php @@ -82,7 +82,9 @@ public function prepare($options) */ public function query() { - $this->statement = $this->connection->getWrappedConnection()->query($this->sql); + /** @var \PDOStatement $statement */ + $statement = $this->connection->getWrappedConnection()->query($this->sql); + $this->statement = $statement; return $this->connection->getWrappedConnection()->getDataFetcher($this); } diff --git a/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php b/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php index ab3c3f6f44..61a31be931 100644 --- a/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php @@ -66,7 +66,11 @@ public function valid() */ public function rewind() { - return null === $this->dataObject ? null : reset($this->dataObject); + if ($this->dataObject === null) { + return; + } + + reset($this->dataObject); } /** diff --git a/src/Propel/Runtime/DataFetcher/PDODataFetcher.php b/src/Propel/Runtime/DataFetcher/PDODataFetcher.php index 729e7b0c66..06e5a17a0c 100644 --- a/src/Propel/Runtime/DataFetcher/PDODataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/PDODataFetcher.php @@ -14,7 +14,7 @@ class PDODataFetcher extends AbstractDataFetcher { /** - * @var array + * @var array|null */ private $current; diff --git a/src/Propel/Runtime/Formatter/AbstractFormatter.php b/src/Propel/Runtime/Formatter/AbstractFormatter.php index 38e402d621..dab995e191 100644 --- a/src/Propel/Runtime/Formatter/AbstractFormatter.php +++ b/src/Propel/Runtime/Formatter/AbstractFormatter.php @@ -200,6 +200,9 @@ abstract public function format(DataFetcherInterface $dataFetcher = null); abstract public function formatOne(DataFetcherInterface $dataFetcher = null); + /** + * @return bool + */ abstract public function isObjectFormatter(); public function checkInit() diff --git a/src/Propel/Runtime/Formatter/ArrayFormatter.php b/src/Propel/Runtime/Formatter/ArrayFormatter.php index 6582111d40..73f2a8cc2f 100644 --- a/src/Propel/Runtime/Formatter/ArrayFormatter.php +++ b/src/Propel/Runtime/Formatter/ArrayFormatter.php @@ -97,7 +97,7 @@ public function formatOne(DataFetcherInterface $dataFetcher = null) /** * Formats an ActiveRecord object * - * @param ActiveRecordInterface $record the object to format + * @param ActiveRecordInterface|null $record the object to format * * @return array The original record turned into an array */ @@ -106,6 +106,9 @@ public function formatRecord(ActiveRecordInterface $record = null) return $record ? $record->toArray() : []; } + /** + * @return bool + */ public function isObjectFormatter() { return false; diff --git a/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php b/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php index a2a6b0779f..043ad146ec 100644 --- a/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php +++ b/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php @@ -82,7 +82,7 @@ public function formatOne(DataFetcherInterface $dataFetcher = null) /** * Formats an ActiveRecord object * - * @param ActiveRecordInterface $record the object to format + * @param ActiveRecordInterface|null $record the object to format * * @return array The original record turned into an array */ @@ -91,11 +91,19 @@ public function formatRecord(ActiveRecordInterface $record = null) return $record ? $record->toArray() : []; } + /** + * @return bool + */ public function isObjectFormatter() { return false; } + /** + * @param array $row + * + * @return array + */ public function getStructuredArrayFromRow($row) { $columnNames = array_keys($this->getAsColumns()); diff --git a/src/Propel/Runtime/Map/RelationMap.php b/src/Propel/Runtime/Map/RelationMap.php index 4d0e9ee3b0..ce5792a520 100644 --- a/src/Propel/Runtime/Map/RelationMap.php +++ b/src/Propel/Runtime/Map/RelationMap.php @@ -66,7 +66,7 @@ class RelationMap protected $localValues = []; /** - * @var ColumnMap[] + * @var (\Propel\Runtime\Map\ColumnMap|null)[] */ protected $foreignColumns = []; diff --git a/src/Propel/Runtime/Map/TableMap.php b/src/Propel/Runtime/Map/TableMap.php index e7f46914b7..be71c80b1d 100644 --- a/src/Propel/Runtime/Map/TableMap.php +++ b/src/Propel/Runtime/Map/TableMap.php @@ -279,7 +279,7 @@ public function getCollectionClassName() if (class_exists($collectionClass)) { return $collectionClass; } - + return '\Propel\Runtime\Collection\ObjectCollection'; } @@ -752,7 +752,7 @@ public function hasPrimaryStringColumn() /** * Gets the ColumnMap for the primary string column. * - * @return \Propel\Runtime\Map\ColumnMap + * @return \Propel\Runtime\Map\ColumnMap|null */ public function getPrimaryStringColumn() { diff --git a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php index 080bb32b94..073c9dc260 100644 --- a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php +++ b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php @@ -57,6 +57,8 @@ class StandardServiceContainer implements ServiceContainerInterface protected $connectionManagers = []; /** + * @phpstan-var class-string<\Propel\Runtime\Util\Profiler> + * * @var string */ protected $profilerClass = ServiceContainerInterface::DEFAULT_PROFILER_CLASS; @@ -67,7 +69,7 @@ class StandardServiceContainer implements ServiceContainerInterface protected $profilerConfiguration = []; /** - * @var \Propel\Runtime\Util\Profiler + * @var \Propel\Runtime\Util\Profiler|null */ protected $profiler; @@ -432,6 +434,7 @@ public function getProfiler() { if (null === $this->profiler) { $class = $this->profilerClass; + /** @var \Propel\Runtime\Util\Profiler $profiler */ $profiler = new $class(); if (!empty($this->profilerConfiguration)) { $profiler->setConfiguration($this->profilerConfiguration); diff --git a/src/Propel/Runtime/Util/Profiler.php b/src/Propel/Runtime/Util/Profiler.php index dbf7a131c1..d0bb453de7 100644 --- a/src/Propel/Runtime/Util/Profiler.php +++ b/src/Propel/Runtime/Util/Profiler.php @@ -290,16 +290,15 @@ public static function formatDuration($duration, $precision = 3) /** * Rounding to significant digits (sort of like JavaScript's toPrecision()). * - * * @param float $number Value to round * @param integer $significantFigures Number of significant figures * - * @return float + * @return string */ public static function toPrecision($number, $significantFigures = 3) { if (0 === $number) { - return 0; + return '0'; } $significantDecimals = (int) floor($significantFigures - log10(abs($number))); diff --git a/tests/Propel/Tests/Runtime/Util/ProfilerTest.php b/tests/Propel/Tests/Runtime/Util/ProfilerTest.php index 1e228c19e3..9dce69e418 100644 --- a/tests/Propel/Tests/Runtime/Util/ProfilerTest.php +++ b/tests/Propel/Tests/Runtime/Util/ProfilerTest.php @@ -22,9 +22,9 @@ public function testGetProfileBetweenAddsSlowTreshold() $profiler->setDetails([]); $profiler->setSlowTreshold(1000); $res = $profiler->getProfileBetween(['microtime' => 1000], ['microtime' => 1200]); - $this->assertEquals(' ', $res); + $this->assertSame(' ', $res); $res = $profiler->getProfileBetween(['microtime' => 1000], ['microtime' => 2200]); - $this->assertEquals('SLOW ', $res); + $this->assertSame('SLOW ', $res); } public function testGetProfileBetweenDoesNotAddSlowTresholdWhenValueIsNull() @@ -33,9 +33,9 @@ public function testGetProfileBetweenDoesNotAddSlowTresholdWhenValueIsNull() $profiler->setDetails([]); $profiler->setSlowTreshold(0); $res = $profiler->getProfileBetween(['microtime' => 1000], ['microtime' => 1200]); - $this->assertEquals('', $res); + $this->assertSame('', $res); $res = $profiler->getProfileBetween(['microtime' => 1000], ['microtime' => 2200]); - $this->assertEquals('', $res); + $this->assertSame('', $res); } public function testGetProfileBetweenAddsTime() @@ -102,7 +102,7 @@ public function testGetProfileBetweenCombinesDetails() ['microtime' => 1.000, 'memoryUsage' => 343245, 'memoryPeakUsage' => 314357], ['microtime' => 1.0345, 'memoryUsage' => 245643, 'memoryPeakUsage' => 343245] ); - $this->assertEquals(' Time: 34.5ms | Memory: 240kB | Delta: -95.3kB | Peak: 335kB | ', $res); + $this->assertSame(' Time: 34.5ms | Memory: 240kB | Delta: -95.3kB | Peak: 335kB | ', $res); } public function providerForTestFormatMemory() @@ -126,7 +126,7 @@ public function providerForTestFormatMemory() */ public function testFormatMemory($input, $output) { - $this->assertEquals(Profiler::formatMemory($input), $output); + $this->assertSame(Profiler::formatMemory($input), $output); } public function providerForTestFormatMemoryPrecision() @@ -146,7 +146,7 @@ public function providerForTestFormatMemoryPrecision() */ public function testFormatMemoryPrecision($input, $output) { - $this->assertEquals(Profiler::formatMemory(12345.6789, $input), $output); + $this->assertSame(Profiler::formatMemory(12345.6789, $input), $output); } public function providerForTestFormatDuration() @@ -193,7 +193,7 @@ public function providerForTestFormatDurationPrecision() */ public function testFormatDurationPrecision($input, $output) { - $this->assertEquals(Profiler::formatDuration(123.456789, $input), $output); + $this->assertSame(Profiler::formatDuration(123.456789, $input), $output); } public function providerForTestToPrecision() @@ -209,7 +209,7 @@ public function providerForTestToPrecision() [123.4567890, number_format(123)], [12.34567890, number_format(12.3, 1)], [1.234567890, number_format(1.23, 2)], - [0, 0], + [0, '0'], [0.123456789, number_format(0.123, 3)], [0.012345678, number_format(0.0123, 4)], [0.001234567, number_format(0.00123, 5)], @@ -225,13 +225,13 @@ public function providerForTestToPrecision() */ public function testToPrecision($input, $output) { - $this->assertEquals(Profiler::toPrecision($input), $output); + $this->assertSame(Profiler::toPrecision($input), $output); } public function providerForTestToPrecisionPrecision() { return [ - [0, 0], + [0, '0'], [1, number_format(100)], [2, number_format(120)], [3, number_format(123)], @@ -246,6 +246,6 @@ public function providerForTestToPrecisionPrecision() */ public function testToPrecisionPrecision($input, $output) { - $this->assertEquals(Profiler::toPrecision(123.456789, $input), $output); + $this->assertSame(Profiler::toPrecision(123.456789, $input), $output); } } From b9fd1829d7a31e93ba547871546ec942759d28fb Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 8 Jul 2020 16:04:02 +0200 Subject: [PATCH 095/208] Fix test case. --- tests/Propel/Tests/Generator/Model/ColumnTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Propel/Tests/Generator/Model/ColumnTest.php b/tests/Propel/Tests/Generator/Model/ColumnTest.php index 1582eb5f98..177d5f633e 100644 --- a/tests/Propel/Tests/Generator/Model/ColumnTest.php +++ b/tests/Propel/Tests/Generator/Model/ColumnTest.php @@ -246,7 +246,7 @@ public function testGetDefaultValueString($mappingType, $value, $expected) public function provideDefaultValues() { return [ - ['DOUBLE', 3.14, 3.14], + ['DOUBLE', 3.14, '3.14'], ['VARCHAR', 'hello', "'hello'"], ['VARCHAR', "john's bike", "'john\\'s bike'"], ['BOOLEAN', 1, 'true'], From 392f787bf010723eb22ea99b75c6c7e1ce957f57 Mon Sep 17 00:00:00 2001 From: mscherer Date: Mon, 20 Jul 2020 14:29:27 +0200 Subject: [PATCH 096/208] Add 7 not fixable errors to baseline. --- phpstan-baseline.neon | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e61d7ba32e..22e807143d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -655,6 +655,11 @@ parameters: count: 2 path: src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php + - + message: "#^Method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:filterBy\\(\\) should return Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria but returns Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\Join\\:\\:getTableMap\\(\\)\\.$#" count: 7 @@ -700,11 +705,21 @@ parameters: count: 1 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - + message: "#^Parameter \\#1 \\$values \\(array\\) of method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:doUpdate\\(\\) should be compatible with parameter \\$updateValues \\(Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\) of method Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:doUpdate\\(\\)$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:getTableMap\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - + message: "#^Method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:addUsingAlias\\(\\) should return Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria but returns Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\Criterion\\\\AbstractCriterion\\:\\:setIgnoreCase\\(\\)\\.$#" count: 1 @@ -805,11 +820,26 @@ parameters: count: 1 path: src/Propel/Runtime/Collection/OnDemandCollection.php + - + message: "#^Return type \\(Propel\\\\Runtime\\\\Collection\\\\OnDemandIterator\\) of method Propel\\\\Runtime\\\\Collection\\\\OnDemandCollection\\:\\:getIterator\\(\\) should be compatible with return type \\(Propel\\\\Runtime\\\\Collection\\\\CollectionIterator\\) of method Propel\\\\Runtime\\\\Collection\\\\Collection\\:\\:getIterator\\(\\)$#" + count: 1 + path: src/Propel/Runtime/Collection/OnDemandCollection.php + + - + message: "#^Method Propel\\\\Runtime\\\\Collection\\\\OnDemandCollection\\:\\:getIterator\\(\\) should return Propel\\\\Runtime\\\\Collection\\\\OnDemandIterator but returns Iterator\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/OnDemandCollection.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\Connection\\\\ConnectionWrapper\\:\\:getProfiler\\(\\)\\.$#" count: 3 path: src/Propel/Runtime/Connection/ProfilerStatementWrapper.php + - + message: "#^Return type \\(array\\) of method Propel\\\\Runtime\\\\Formatter\\\\ArrayFormatter\\:\\:formatRecord\\(\\) should be compatible with return type \\(Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\) of method Propel\\\\Runtime\\\\Formatter\\\\AbstractFormatter\\:\\:formatRecord\\(\\)$#" + count: 1 + path: src/Propel/Runtime/Formatter/ArrayFormatter.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:toArray\\(\\)\\.$#" count: 3 @@ -835,6 +865,11 @@ parameters: count: 1 path: src/Propel/Runtime/Formatter/OnDemandFormatter.php + - + message: "#^Return type \\(array\\) of method Propel\\\\Runtime\\\\Formatter\\\\SimpleArrayFormatter\\:\\:formatRecord\\(\\) should be compatible with return type \\(Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\) of method Propel\\\\Runtime\\\\Formatter\\\\AbstractFormatter\\:\\:formatRecord\\(\\)$#" + count: 1 + path: src/Propel/Runtime/Formatter/SimpleArrayFormatter.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:toArray\\(\\)\\.$#" count: 1 From b1816300f9a94fba520abe31d3b21ad55e3ae7bc Mon Sep 17 00:00:00 2001 From: mscherer Date: Mon, 20 Jul 2020 15:52:06 +0200 Subject: [PATCH 097/208] Fix PHP8 warning. --- .../Runtime/ServiceContainer/StandardServiceContainer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php index 080bb32b94..a01a16fcb2 100644 --- a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php +++ b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php @@ -532,7 +532,7 @@ public function setLoggerConfiguration($name, $loggerConfiguration) $this->loggerConfigurations[$name] = $loggerConfiguration; } - final private function __clone() + private function __clone() { } } From 0f9bbdbff965c6ead86f3f67e39f4f2b3c3349f2 Mon Sep 17 00:00:00 2001 From: Daniel Rose Date: Tue, 21 Jul 2020 09:34:19 +0200 Subject: [PATCH 098/208] always create unique indices by constraint (for pgsql platform) --- .../Generator/Platform/PgsqlPlatform.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Propel/Generator/Platform/PgsqlPlatform.php b/src/Propel/Generator/Platform/PgsqlPlatform.php index 1811335e56..d964d237cd 100755 --- a/src/Propel/Generator/Platform/PgsqlPlatform.php +++ b/src/Propel/Generator/Platform/PgsqlPlatform.php @@ -718,4 +718,26 @@ public function getIdentifierPhp($columnValueMutator, $connectionVariableName = return preg_replace('/^/m', $tab, $script); } + /** + * @param \Propel\Generator\Model\Index $index + * + * @return string + */ + public function getAddIndexDDL(Index $index) + { + if (!$index->isUnique()) { + return parent::getAddIndexDDL($index); + } + + $pattern = " +ALTER TABLE %s ADD CONSTRAINT %s UNIQUE (%s); +"; + + return sprintf( + $pattern, + $this->quoteIdentifier($index->getTable()->getName()), + $this->quoteIdentifier($index->getName()), + $this->getColumnListDDL($index->getColumnObjects()) + ); + } } From 2347481276bb9fd1174a322909735641b71c1db0 Mon Sep 17 00:00:00 2001 From: mscherer Date: Mon, 20 Jul 2020 17:09:32 +0200 Subject: [PATCH 099/208] Prepare for phpstan level 4. --- phpstan-baseline.neon | 12 +- .../Common/Config/ConfigurationManager.php | 8 +- .../Common/Config/Loader/FileLoader.php | 22 +-- .../Archivable/ArchivableBehavior.php | 5 +- .../templates/objectRestoreFromArchive.php | 2 +- .../templates/objectRemoveTranslation.php | 2 +- .../I18n/templates/objectSetLocale.php | 2 +- .../I18n/templates/objectSetTranslation.php | 2 +- .../I18n/templates/queryJoinWithI18n.php | 2 +- .../Behavior/Sluggable/SluggableBehavior.php | 6 +- .../Builder/Om/AbstractOMBuilder.php | 6 +- .../Builder/Om/MultiExtendObjectBuilder.php | 4 +- .../Om/templates/baseObjectMethods.php | 6 +- .../Generator/Builder/Util/SchemaReader.php | 2 +- src/Propel/Generator/Command/InitCommand.php | 3 + .../Generator/Config/QuickGeneratorConfig.php | 8 +- .../Generator/Manager/MigrationManager.php | 2 +- src/Propel/Generator/Model/Behavior.php | 8 +- .../Generator/Model/BehaviorableTrait.php | 2 +- src/Propel/Generator/Model/Column.php | 45 +++--- .../Generator/Model/ColumnDefaultValue.php | 10 +- .../Generator/Model/CrossForeignKeys.php | 6 +- src/Propel/Generator/Model/Database.php | 75 +++++----- .../Model/Diff/DatabaseComparator.php | 3 + src/Propel/Generator/Model/Diff/TableDiff.php | 12 +- src/Propel/Generator/Model/Domain.php | 15 +- src/Propel/Generator/Model/ForeignKey.php | 32 ++--- src/Propel/Generator/Model/Index.php | 11 +- src/Propel/Generator/Model/Inheritance.php | 33 +++-- .../Generator/Model/ScopedMappingModel.php | 12 ++ src/Propel/Generator/Model/Table.php | 14 +- src/Propel/Generator/Model/VendorInfo.php | 2 +- .../Generator/Platform/OraclePlatform.php | 15 +- src/Propel/Generator/Util/BehaviorLocator.php | 9 +- .../Runtime/ActiveQuery/BaseModelCriteria.php | 16 +-- src/Propel/Runtime/ActiveQuery/Criteria.php | 130 ++++++++++-------- .../Criterion/AbstractCriterion.php | 11 +- .../Criterion/AbstractModelCriterion.php | 8 +- .../ActiveQuery/Criterion/BasicCriterion.php | 2 +- .../ActiveQuery/Criterion/LikeCriterion.php | 2 +- .../Criterion/LikeModelCriterion.php | 2 +- src/Propel/Runtime/ActiveQuery/Join.php | 8 +- .../Runtime/ActiveQuery/ModelCriteria.php | 87 ++++++------ src/Propel/Runtime/ActiveQuery/ModelJoin.php | 2 +- .../NestedSetRecursiveIterator.php | 17 ++- src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php | 2 +- .../Runtime/Adapter/Pdo/PgsqlAdapter.php | 6 +- .../Runtime/Collection/ObjectCollection.php | 3 + .../Runtime/Collection/OnDemandCollection.php | 2 +- .../Connection/ConnectionInterface.php | 4 +- .../Runtime/Connection/ConnectionWrapper.php | 1 - .../Connection/ProfilerStatementWrapper.php | 2 +- .../Runtime/Connection/StatementWrapper.php | 5 +- .../Runtime/Formatter/AbstractFormatter.php | 2 +- .../Runtime/Formatter/OnDemandFormatter.php | 2 +- src/Propel/Runtime/Map/TableMap.php | 5 +- src/Propel/Runtime/Parser/XmlParser.php | 4 +- .../StandardServiceContainer.php | 20 ++- src/Propel/Runtime/Util/Profiler.php | 6 +- src/Propel/Runtime/Util/PropelDateTime.php | 14 +- .../Common/Config/Loader/FileLoaderTest.php | 6 +- 61 files changed, 418 insertions(+), 349 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 22e807143d..e22fb35927 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -637,7 +637,7 @@ parameters: - message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:bindValues\\(\\)\\.$#" - count: 4 + count: 3 path: src/Propel/Runtime/ActiveQuery/Criteria.php - @@ -655,11 +655,6 @@ parameters: count: 2 path: src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php - - - message: "#^Method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:filterBy\\(\\) should return Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria but returns Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\.$#" - count: 1 - path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\Join\\:\\:getTableMap\\(\\)\\.$#" count: 7 @@ -715,11 +710,6 @@ parameters: count: 1 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - - message: "#^Method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:addUsingAlias\\(\\) should return Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria but returns Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\.$#" - count: 1 - path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\Criterion\\\\AbstractCriterion\\:\\:setIgnoreCase\\(\\)\\.$#" count: 1 diff --git a/src/Propel/Common/Config/ConfigurationManager.php b/src/Propel/Common/Config/ConfigurationManager.php index a383f90af5..fc95f69232 100644 --- a/src/Propel/Common/Config/ConfigurationManager.php +++ b/src/Propel/Common/Config/ConfigurationManager.php @@ -37,7 +37,7 @@ class ConfigurationManager /** * Load and validate configuration values from a file. * - * @param string $filename Configuration file name or directory in which resides the configuration file. + * @param string|null $filename Configuration file name or directory in which resides the configuration file. * @param array $extraConf Array of configuration properties, to be merged with those loaded from file. * It's useful when passing configuration parameters from command line. */ @@ -133,13 +133,13 @@ public function getConnectionParametersArray($section = 'runtime') * This method also looks for a '.dist' configuration file and loads it. * * @param string $fileName Configuration file name or directory in which resides the configuration file. - * @param array $extraConf Array of configuration properties, to be merged with those loaded from file. + * @param array|null $extraConf Array of configuration properties, to be merged with those loaded from file. */ protected function load($fileName, $extraConf) { $dirs = $this->getDirs($fileName); - if ((null === $fileName) || (is_dir($fileName))) { + if (!$fileName || is_dir($fileName)) { $fileName = self::CONFIG_FILE_NAME; } @@ -147,7 +147,7 @@ protected function load($fileName, $extraConf) $extraConf = []; } - if (self::CONFIG_FILE_NAME === $fileName) { + if (static::CONFIG_FILE_NAME === $fileName) { $files = $this->getFiles($dirs, $fileName); $distFiles = $this->getFiles($dirs, $fileName, true); diff --git a/src/Propel/Common/Config/Loader/FileLoader.php b/src/Propel/Common/Config/Loader/FileLoader.php index bd764e3ca9..6aee3db465 100644 --- a/src/Propel/Common/Config/Loader/FileLoader.php +++ b/src/Propel/Common/Config/Loader/FileLoader.php @@ -124,20 +124,20 @@ protected function checkSupports($ext, $resource) return ($ext === $extension); } - if (is_array($ext)) { - $supported = false; + if (!is_array($ext)) { + throw new \InvalidArgumentException('$ext must string or string[]'); + } - foreach ($ext as $value) { - if ($value === $extension) { - $supported = true; - break; - } - } + $supported = false; - return $supported; + foreach ($ext as $value) { + if ($value === $extension) { + $supported = true; + break; + } } - return false; + return $supported; } private function isResolved() @@ -279,7 +279,7 @@ private function get($property_key) * Scan recursively an array to find a value of a given key. * * @param string $property_key The array key - * @param array $config The array to scan + * @param array|null $config The array to scan * @param boolean $found if the key was found * * @return mixed The value or null if not found diff --git a/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php b/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php index 7177add6ef..f77f410a49 100644 --- a/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php +++ b/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php @@ -35,6 +35,9 @@ class ArchivableBehavior extends Behavior 'archive_on_delete' => 'true', ]; + /** + * @var Table|null + */ protected $archiveTable; protected $objectBuilderModifier; protected $queryBuilderModifier; @@ -130,7 +133,7 @@ protected function addArchiveTable() } /** - * @return Table + * @return Table|null */ public function getArchiveTable() { diff --git a/src/Propel/Generator/Behavior/Archivable/templates/objectRestoreFromArchive.php b/src/Propel/Generator/Behavior/Archivable/templates/objectRestoreFromArchive.php index b246d2adf9..09dc94de47 100644 --- a/src/Propel/Generator/Behavior/Archivable/templates/objectRestoreFromArchive.php +++ b/src/Propel/Generator/Behavior/Archivable/templates/objectRestoreFromArchive.php @@ -7,7 +7,7 @@ * * @throws PropelException If the object has no corresponding archive. * - * @return $this| The current object (for fluent API support) + * @return $this The current object (for fluent API support) */ public function restoreFromArchive(ConnectionInterface $con = null) { diff --git a/src/Propel/Generator/Behavior/I18n/templates/objectRemoveTranslation.php b/src/Propel/Generator/Behavior/I18n/templates/objectRemoveTranslation.php index df624df8df..5d029ab94e 100644 --- a/src/Propel/Generator/Behavior/I18n/templates/objectRemoveTranslation.php +++ b/src/Propel/Generator/Behavior/I18n/templates/objectRemoveTranslation.php @@ -5,7 +5,7 @@ * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * @param ConnectionInterface $con an optional connection object * - * @return $this| The current object (for fluent API support) + * @return $this The current object (for fluent API support) */ public function removeTranslation($locale = '', ConnectionInterface $con = null) { diff --git a/src/Propel/Generator/Behavior/I18n/templates/objectSetLocale.php b/src/Propel/Generator/Behavior/I18n/templates/objectSetLocale.php index e1d3aa8b3c..91d933fc4c 100644 --- a/src/Propel/Generator/Behavior/I18n/templates/objectSetLocale.php +++ b/src/Propel/Generator/Behavior/I18n/templates/objectSetLocale.php @@ -4,7 +4,7 @@ * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return $this| The current object (for fluent API support) + * @return $this The current object (for fluent API support) */ public function set($locale = '') { diff --git a/src/Propel/Generator/Behavior/I18n/templates/objectSetTranslation.php b/src/Propel/Generator/Behavior/I18n/templates/objectSetTranslation.php index c7d5751b4c..b3ca12fcfb 100644 --- a/src/Propel/Generator/Behavior/I18n/templates/objectSetTranslation.php +++ b/src/Propel/Generator/Behavior/I18n/templates/objectSetTranslation.php @@ -5,7 +5,7 @@ * @param $translation The translation object * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return $this| The current object (for fluent API support) + * @return $this The current object (for fluent API support) */ public function setTranslation($translation, $locale = '') { diff --git a/src/Propel/Generator/Behavior/I18n/templates/queryJoinWithI18n.php b/src/Propel/Generator/Behavior/I18n/templates/queryJoinWithI18n.php index 0c0ccfdffc..ade74adead 100644 --- a/src/Propel/Generator/Behavior/I18n/templates/queryJoinWithI18n.php +++ b/src/Propel/Generator/Behavior/I18n/templates/queryJoinWithI18n.php @@ -6,7 +6,7 @@ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. * - * @return $this| The current query, for fluid interface + * @return $this The current query, for fluid interface */ public function joinWithI18n($locale = '', $joinType = Criteria::LEFT_JOIN) { diff --git a/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php b/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php index 1976873c4a..269d2452bd 100644 --- a/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php +++ b/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php @@ -27,7 +27,7 @@ class SluggableBehavior extends Behavior * @var ObjectBuilder */ private $builder; - + /** * @var array */ @@ -63,7 +63,7 @@ public function modifyTable() } } } - + /** * Adds a unique constraint to the table to enforce uniqueness of the slug_column * @@ -71,7 +71,7 @@ public function modifyTable() */ protected function addUniqueConstraint(Table $table) { - $unique = new Unique($this->getColumnForParameter('slug_column')); + $unique = new Unique(); //$this->getColumnForParameter('slug_column') $unique->setName($table->getCommonName() . '_slug'); $unique->addColumn($table->getColumn($this->getParameter('slug_column'))); if ($this->getParameter('scope_column')) { diff --git a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php index 3d850cb1ce..837f150c2e 100644 --- a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php @@ -283,7 +283,7 @@ public function getClassNameFromTable(Table $table, $fqcn = false) * * @param string $class the class name * @param string $namespace the namespace - * @param string|boolean $alias the alias wanted, if set to True, it automatically adds an alias when needed + * @param string|bool|null $alias the alias wanted, if set to True, it automatically adds an alias when needed * @return string the class name or it's alias */ public function declareClassNamespace($class, $namespace = '', $alias = false) @@ -553,8 +553,8 @@ public function getTableMapClassName($fqcn = false) /** * Get the column constant name (e.g. TableMapName::COLUMN_NAME). * - * @param Column $col The column we need a name for. - * @param string $classname The TableMap classname to use. + * @param Column|null $col The column we need a name for. + * @param string|null $classname The TableMap classname to use. * * @return string If $classname is provided, then will return $classname::COLUMN_NAME; if not, then the TableMapName is looked up for current table to yield $currTableTableMap::COLUMN_NAME. */ diff --git a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php index c5cbd6a5c2..5f03f4b025 100644 --- a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php @@ -27,7 +27,7 @@ class MultiExtendObjectBuilder extends AbstractObjectBuilder /** * The current child "object" we are operating on. * - * @var Inheritance $child + * @var Inheritance|null $child */ private $child; @@ -48,7 +48,7 @@ public function getUnprefixedClassName() */ public function getPackage() { - return ($this->child->getPackage() ? $this->child->getPackage() : parent::getPackage()); + return ($this->getChild()->getPackage() ?: parent::getPackage()); } /** diff --git a/src/Propel/Generator/Builder/Om/templates/baseObjectMethods.php b/src/Propel/Generator/Builder/Om/templates/baseObjectMethods.php index 31ec0a8b17..065155f070 100644 --- a/src/Propel/Generator/Builder/Om/templates/baseObjectMethods.php +++ b/src/Propel/Generator/Builder/Om/templates/baseObjectMethods.php @@ -156,7 +156,7 @@ public function getVirtualColumn($name) * @param string $name The virtual column name * @param mixed $value The value to give to the virtual column * - * @return $this| The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function setVirtualColumn($name, $value) { @@ -209,10 +209,10 @@ public function __sleep() $cls = new \ReflectionClass($this); $propertyNames = []; $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC)); - + foreach($serializableProperties as $property) { $propertyNames[] = $property->getName(); } - + return $propertyNames; } diff --git a/src/Propel/Generator/Builder/Util/SchemaReader.php b/src/Propel/Generator/Builder/Util/SchemaReader.php index d7c45f2e68..383d3bc0be 100644 --- a/src/Propel/Generator/Builder/Util/SchemaReader.php +++ b/src/Propel/Generator/Builder/Util/SchemaReader.php @@ -377,7 +377,7 @@ public function endElement($parser, $name) $this->currTable->addUnique($this->currUnique); } - if (self::DEBUG) { + if (static::DEBUG) { print('endElement(' . $name . ") called\n"); } diff --git a/src/Propel/Generator/Command/InitCommand.php b/src/Propel/Generator/Command/InitCommand.php index f7ff4962b7..dfd37fe2c3 100644 --- a/src/Propel/Generator/Command/InitCommand.php +++ b/src/Propel/Generator/Command/InitCommand.php @@ -30,6 +30,9 @@ class InitCommand extends AbstractCommand private $defaultSchemaDir; private $defaultPhpDir; + /** + * @param string|null $name + */ public function __construct($name = null) { parent::__construct($name); diff --git a/src/Propel/Generator/Config/QuickGeneratorConfig.php b/src/Propel/Generator/Config/QuickGeneratorConfig.php index 4deb9e2dde..3ff772aa27 100644 --- a/src/Propel/Generator/Config/QuickGeneratorConfig.php +++ b/src/Propel/Generator/Config/QuickGeneratorConfig.php @@ -22,10 +22,13 @@ class QuickGeneratorConfig extends ConfigurationManager implements GeneratorConfigInterface { /** - * @var BehaviorLocator + * @var BehaviorLocator|null */ protected $behaviorLocator = null; + /** + * @param array|null $extraConf + */ public function __construct($extraConf = []) { if (null === $extraConf) { @@ -109,6 +112,9 @@ public function getConfiguredSchemaParser(ConnectionInterface $con = null, $data return null; } + /** + * @return \Propel\Generator\Util\BehaviorLocator + */ public function getBehaviorLocator() { if (!$this->behaviorLocator) { diff --git a/src/Propel/Generator/Manager/MigrationManager.php b/src/Propel/Generator/Manager/MigrationManager.php index 318c2d533a..ce9fc1361b 100644 --- a/src/Propel/Generator/Manager/MigrationManager.php +++ b/src/Propel/Generator/Manager/MigrationManager.php @@ -181,7 +181,7 @@ public function createMigrationTable($datasource) $column = new Column('version'); $column->getDomain()->copy($platform->getDomainForType('INTEGER')); - $column->setDefaultValue(0); + $column->setDefaultValue('0'); $table->addColumn($column); // insert the table into the database diff --git a/src/Propel/Generator/Model/Behavior.php b/src/Propel/Generator/Model/Behavior.php index 3411164d92..bef65bd9f0 100644 --- a/src/Propel/Generator/Model/Behavior.php +++ b/src/Propel/Generator/Model/Behavior.php @@ -393,7 +393,7 @@ protected function setupObject() * * The current object is returned by default. * - * @return $this|Behavior + * @return $this */ public function getTableModifier() { @@ -405,7 +405,7 @@ public function getTableModifier() * * The current object is returned by default. * - * @return $this|Behavior + * @return $this */ public function getObjectBuilderModifier() { @@ -417,7 +417,7 @@ public function getObjectBuilderModifier() * * The current object is returned by default. * - * @return $this|Behavior + * @return $this */ public function getQueryBuilderModifier() { @@ -429,7 +429,7 @@ public function getQueryBuilderModifier() * * The current object is returned by default. * - * @return $this|Behavior + * @return $this */ public function getTableMapBuilderModifier() { diff --git a/src/Propel/Generator/Model/BehaviorableTrait.php b/src/Propel/Generator/Model/BehaviorableTrait.php index a335d2bd82..293807f8fd 100644 --- a/src/Propel/Generator/Model/BehaviorableTrait.php +++ b/src/Propel/Generator/Model/BehaviorableTrait.php @@ -22,7 +22,7 @@ trait BehaviorableTrait private $behaviorLocator; /** - * @return \Propel\Generator\Config\GeneratorConfigInterface + * @return \Propel\Generator\Config\GeneratorConfigInterface|null */ abstract protected function getGeneratorConfig(); diff --git a/src/Propel/Generator/Model/Column.php b/src/Propel/Generator/Model/Column.php index df8d996a71..e647e06b91 100644 --- a/src/Propel/Generator/Model/Column.php +++ b/src/Propel/Generator/Model/Column.php @@ -58,7 +58,7 @@ class Column extends MappingModel private $phpType; /** - * @var Domain + * @var Domain|null */ private $domain; /** @@ -66,6 +66,9 @@ class Column extends MappingModel */ private $parentTable; + /** + * @var int|null + */ private $position; private $isPrimaryKey; private $isNodeKey; @@ -76,7 +79,7 @@ class Column extends MappingModel private $isUnique; private $isAutoIncrement; private $isLazyLoad; - private $referrers; + private $referrers = []; private $isPrimaryString; // only one type is supported currently, which assumes the @@ -102,7 +105,7 @@ class Column extends MappingModel * * @param string|null $name The column's name * @param string|null $type The column's type - * @param string|null $size The column's size + * @param string|int|null $size The column's size */ public function __construct($name = null, $type = null, $size = null) { @@ -117,7 +120,7 @@ public function __construct($name = null, $type = null, $size = null) } if (null !== $size) { - $this->setSize($size); + $this->setSize((int)$size); } $this->isAutoIncrement = false; @@ -313,11 +316,13 @@ private function getDatabase() */ public function getDomain() { - if (null === $this->domain) { - $this->domain = new Domain(); + $domain = $this->domain; + if ($domain === null) { + $domain = new Domain(); + $this->domain = $domain; } - return $this->domain; + return $domain; } /** @@ -620,7 +625,7 @@ public function getPhpType() /** * Returns the location of this column within the table (one-based). * - * @return integer + * @return integer|null */ public function getPosition() { @@ -978,10 +983,6 @@ public function getForeignKeys() */ public function addReferrer(ForeignKey $fk) { - if (null === $this->referrers) { - $this->referrers = []; - } - $this->referrers[] = $fk; } @@ -992,10 +993,6 @@ public function addReferrer(ForeignKey $fk) */ public function getReferrers() { - if (null === $this->referrers) { - $this->referrers = []; - } - return $this->referrers; } @@ -1006,7 +1003,7 @@ public function getReferrers() */ public function hasReferrers() { - return is_array($this->referrers) && count($this->referrers) > 0; + return count($this->referrers) > 0; } /** @@ -1018,7 +1015,7 @@ public function hasReferrers() */ public function hasReferrer(ForeignKey $fk) { - return $this->hasReferrers() && in_array($fk, $this->referrers, true); + return $this->referrers && in_array($fk, $this->referrers, true); } /** @@ -1027,7 +1024,7 @@ public function hasReferrer(ForeignKey $fk) */ public function clearReferrers() { - $this->referrers = null; + $this->referrers = []; } /** @@ -1309,7 +1306,7 @@ public function getDefaultValueString() /** * Sets a string that will give this column a default value. * - * @param ColumnDefaultValue|string $defaultValue The column's default value + * @param ColumnDefaultValue|string|null $defaultValue The column's default value * @return void */ public function setDefaultValue($defaultValue) @@ -1324,7 +1321,7 @@ public function setDefaultValue($defaultValue) /** * Returns the default value object for this column. * - * @return ColumnDefaultValue + * @return ColumnDefaultValue|null * @see Domain::getDefaultValue() */ public function getDefaultValue() @@ -1335,7 +1332,7 @@ public function getDefaultValue() /** * Returns the default value suitable for use in PHP. * - * @return mixed + * @return mixed|null * @see Domain::getPhpDefaultValue() */ public function getPhpDefaultValue() @@ -1452,7 +1449,7 @@ public function isPhpObjectType() /** * Returns an instance of PlatformInterface interface. * - * @return PlatformInterface + * @return PlatformInterface|null */ public function getPlatform() { @@ -1479,7 +1476,7 @@ public function hasPlatform() */ public function __clone() { - $this->referrers = null; + $this->referrers = []; if ($this->domain) { $this->domain = clone $this->domain; } diff --git a/src/Propel/Generator/Model/ColumnDefaultValue.php b/src/Propel/Generator/Model/ColumnDefaultValue.php index 366bc236d4..f463b864a3 100644 --- a/src/Propel/Generator/Model/ColumnDefaultValue.php +++ b/src/Propel/Generator/Model/ColumnDefaultValue.php @@ -22,7 +22,7 @@ class ColumnDefaultValue const TYPE_EXPR = 'expr'; /** - * @var string The default value, as specified in the schema. + * @var string|null The default value, as specified in the schema. */ private $value; @@ -34,8 +34,8 @@ class ColumnDefaultValue /** * Creates a new DefaultValue object. * - * @param string $value The default value, as specified in the schema. - * @param string $type The type of default value (DefaultValue::TYPE_VALUE or DefaultValue::TYPE_EXPR) + * @param string|null $value The default value, as specified in the schema. + * @param string|null $type The type of default value (DefaultValue::TYPE_VALUE or DefaultValue::TYPE_EXPR) */ public function __construct($value, $type = null) { @@ -73,7 +73,7 @@ public function isExpression() } /** - * @return string The value, as specified in the schema. + * @return string|null The value, as specified in the schema. */ public function getValue() { @@ -81,7 +81,7 @@ public function getValue() } /** - * @param string $value The value, as specified in the schema. + * @param string|null $value The value, as specified in the schema. */ public function setValue($value) { diff --git a/src/Propel/Generator/Model/CrossForeignKeys.php b/src/Propel/Generator/Model/CrossForeignKeys.php index ea24e2ecba..53755b6ba5 100644 --- a/src/Propel/Generator/Model/CrossForeignKeys.php +++ b/src/Propel/Generator/Model/CrossForeignKeys.php @@ -68,7 +68,7 @@ class CrossForeignKeys /** * The incoming foreign key from the middle-table to this table. * - * @var ForeignKey + * @var ForeignKey|null */ protected $incomingForeignKey; @@ -83,7 +83,7 @@ public function __construct(ForeignKey $foreignKey, Table $crossTable) } /** - * @param ForeignKey $foreignKey + * @param ForeignKey|null $foreignKey */ public function setIncomingForeignKey($foreignKey) { @@ -94,7 +94,7 @@ public function setIncomingForeignKey($foreignKey) /** * The foreign key from the middle-table to the target table. * - * @return ForeignKey + * @return ForeignKey|null */ public function getIncomingForeignKey() { diff --git a/src/Propel/Generator/Model/Database.php b/src/Propel/Generator/Model/Database.php index c864fb2454..b38512e02e 100644 --- a/src/Propel/Generator/Model/Database.php +++ b/src/Propel/Generator/Model/Database.php @@ -34,7 +34,7 @@ class Database extends ScopedMappingModel /** * The database's platform. * - * @var PlatformInterface + * @var PlatformInterface|null */ private $platform; @@ -44,7 +44,7 @@ class Database extends ScopedMappingModel private $tables; /** - * @var string + * @var string|null */ private $name; @@ -107,8 +107,8 @@ class Database extends ScopedMappingModel /** * Constructs a new Database object. * - * @param string $name The database's name - * @param PlatformInterface $platform The database's platform + * @param string|null $name The database's name + * @param PlatformInterface|null $platform The database's platform */ public function __construct($name = null, PlatformInterface $platform = null) { @@ -155,7 +155,7 @@ protected function setupObject() /** * Returns the PlatformInterface implementation for this database. * - * @return PlatformInterface + * @return PlatformInterface|null */ public function getPlatform() { @@ -185,7 +185,7 @@ public function getMaxColumnNameLength() /** * Returns the database name. * - * @return string + * @return string|null */ public function getName() { @@ -480,6 +480,33 @@ public function getTableByPhpName($phpName) return null; } + /** + * Adds several tables at once. + * + * @param Table[] $tables An array of Table instances + */ + public function addTables(array $tables) + { + foreach ($tables as $table) { + $this->addTable($table); + } + } + + public function removeTable(Table $table) + { + if ($this->hasTable($table->getName(), true)) { + foreach($this->tables as $id => $tableExam) { + if ($table->getName() === $tableExam->getName()) { + unset($this->tables[$id]); + } + } + + unset($this->tablesByName[$table->getName()]); + unset($this->tablesByLowercaseName[strtolower($table->getName())]); + unset($this->tablesByPhpName[$table->getPhpName()]); + } + } + /** * Adds a new table to this database. * @@ -516,33 +543,6 @@ public function addTable($table) return $table; } - /** - * Adds several tables at once. - * - * @param Table[] $tables An array of Table instances - */ - public function addTables(array $tables) - { - foreach ($tables as $table) { - $this->addTable($table); - } - } - - public function removeTable(Table $table) - { - if ($this->hasTable($table->getName(), true)) { - foreach($this->tables as $id => $tableExam) { - if ($table->getName() === $tableExam->getName()) { - unset($this->tables[$id]); - } - } - - unset($this->tablesByName[$table->getName()]); - unset($this->tablesByLowercaseName[strtolower($table->getName())]); - unset($this->tablesByPhpName[$table->getPhpName()]); - } - } - /** * @param string[] $sequences */ @@ -722,13 +722,15 @@ public function getDomain($name) /** * Returns the GeneratorConfigInterface object. * - * @return \Propel\Generator\Config\GeneratorConfigInterface + * @return \Propel\Generator\Config\GeneratorConfigInterface|null */ public function getGeneratorConfig() { if ($this->parentSchema) { return $this->parentSchema->getGeneratorConfig(); } + + return null; } /** @@ -741,9 +743,12 @@ public function getGeneratorConfig() */ public function getBuildProperty($name) { - if ($config = $this->getGeneratorConfig()) { + $config = $this->getGeneratorConfig(); + if ($config) { return $config->getConfigProperty($name); } + + return ''; } /** diff --git a/src/Propel/Generator/Model/Diff/DatabaseComparator.php b/src/Propel/Generator/Model/Diff/DatabaseComparator.php index d72ce065d0..758588775c 100644 --- a/src/Propel/Generator/Model/Diff/DatabaseComparator.php +++ b/src/Propel/Generator/Model/Diff/DatabaseComparator.php @@ -53,6 +53,9 @@ class DatabaseComparator */ protected $excludedTables = []; + /** + * @param \Propel\Generator\Model\Diff\DatabaseDiff|null $databaseDiff + */ public function __construct($databaseDiff = null) { $this->databaseDiff = (null === $databaseDiff) ? new DatabaseDiff() : $databaseDiff; diff --git a/src/Propel/Generator/Model/Diff/TableDiff.php b/src/Propel/Generator/Model/Diff/TableDiff.php index 54729cad01..afab5de59c 100644 --- a/src/Propel/Generator/Model/Diff/TableDiff.php +++ b/src/Propel/Generator/Model/Diff/TableDiff.php @@ -26,14 +26,14 @@ class TableDiff /** * The first Table object. * - * @var Table + * @var Table|null */ protected $fromTable; /** * The second Table object. * - * @var Table + * @var Table|null */ protected $toTable; @@ -172,7 +172,7 @@ public function setFromTable(Table $fromTable) /** * Returns the fromTable property. * - * @return Table + * @return Table|null */ public function getFromTable() { @@ -488,7 +488,7 @@ public function getRemovedPkColumns() /** * Sets the list of all renamed primary key columns. * - * @param Column[] $renamedPkColumns + * @param Column[][] $renamedPkColumns */ public function setRenamedPkColumns(array $renamedPkColumns) { @@ -603,7 +603,7 @@ public function getRemovedIndices() * * Array must be [ [ Index $fromIndex, Index $toIndex ], [ ... ] ] * - * @param Index[] $modifiedIndices An aray of modified indices + * @param Index[][] $modifiedIndices An aray of modified indices */ public function setModifiedIndices(array $modifiedIndices) { @@ -731,7 +731,7 @@ public function getRemovedFks() * * Array must be [ [ ForeignKey $fromFk, ForeignKey $toFk ], [ ... ] ] * - * @param ForeignKey[] $modifiedFks + * @param ForeignKey[][] $modifiedFks */ public function setModifiedFks(array $modifiedFks) { diff --git a/src/Propel/Generator/Model/Domain.php b/src/Propel/Generator/Model/Domain.php index 2ea869f559..987c7c9815 100644 --- a/src/Propel/Generator/Model/Domain.php +++ b/src/Propel/Generator/Model/Domain.php @@ -27,6 +27,9 @@ class Domain extends MappingModel private $scale; private $mappingType; private $sqlType; + /** + * @var ColumnDefaultValue|null + */ private $defaultValue; private $database; @@ -35,10 +38,10 @@ class Domain extends MappingModel * * If this domain needs a name, it must be specified manually. * - * @param string $type Propel type. - * @param string $sqlType SQL type. - * @param integer $size - * @param integer $scale + * @param string|null $type Propel type. + * @param string|null $sqlType SQL type. + * @param integer|null $size + * @param integer|null $scale */ public function __construct($type = null, $sqlType = null, $size = null, $scale = null) { @@ -255,7 +258,7 @@ public function replaceType($mappingType) /** * Returns the default value object. * - * @return ColumnDefaultValue + * @return ColumnDefaultValue|null */ public function getDefaultValue() { @@ -265,7 +268,7 @@ public function getDefaultValue() /** * Returns the default value, type-casted for use in PHP OM. * - * @return mixed + * @return mixed|null */ public function getPhpDefaultValue() { diff --git a/src/Propel/Generator/Model/ForeignKey.php b/src/Propel/Generator/Model/ForeignKey.php index 366761dddb..0df7cab9cf 100644 --- a/src/Propel/Generator/Model/ForeignKey.php +++ b/src/Propel/Generator/Model/ForeignKey.php @@ -83,22 +83,22 @@ class ForeignKey extends MappingModel /** * @var string[] */ - private $localColumns; + private $localColumns = []; /** * @var (string|null)[] */ - private $foreignColumns; + private $foreignColumns = []; /** * @var (string|null)[] */ - private $localValues; + private $localValues = []; /** * @var bool */ - private $skipSql; + private $skipSql = false; /** * @var string @@ -113,7 +113,7 @@ class ForeignKey extends MappingModel /** * Constructs a new ForeignKey object. * - * @param string $name + * @param string|null $name */ public function __construct($name = null) { @@ -125,9 +125,6 @@ public function __construct($name = null) $this->onUpdate = self::NONE; $this->onDelete = self::NONE; - $this->localColumns = []; - $this->foreignColumns = []; - $this->skipSql = false; } protected function setupObject() @@ -152,8 +149,8 @@ protected function doNaming() $hash = []; $hash[] = $this->foreignSchemaName . '.' . $this->foreignTableCommonName; - $hash[] = implode(',', (array)$this->localColumns); - $hash[] = implode(',', (array)$this->foreignColumns); + $hash[] = implode(',', $this->localColumns); + $hash[] = implode(',', $this->foreignColumns); $newName .= substr(md5(strtolower(implode(':', $hash))), 0, 6); @@ -169,7 +166,7 @@ protected function doNaming() /** * Returns the normalized input of onDelete and onUpdate behaviors. * - * @param string $behavior + * @param string|null $behavior * @return string */ public function normalizeFKey($behavior) @@ -255,7 +252,7 @@ public function setOnDelete($behavior) /** * Sets the onUpdate behavior. * - * @param string $behavior + * @param string|null $behavior */ public function setOnUpdate($behavior) { @@ -364,7 +361,7 @@ public function setDefaultJoin($join) /** * Returns the PlatformInterface instance. * - * @return PlatformInterface + * @return PlatformInterface|null */ private function getPlatform() { @@ -374,7 +371,7 @@ private function getPlatform() /** * Returns the Database object of this Column. * - * @return Database + * @return Database|null */ public function getDatabase() { @@ -430,13 +427,16 @@ public function setForeignTableCommonName($tableName) /** * Returns the resolved foreign Table model object. * - * @return Table + * @return Table|null */ public function getForeignTable() { - if ($database = $this->parentTable->getDatabase()) { + $database = $this->parentTable->getDatabase(); + if ($database) { return $database->getTable($this->getForeignTableName()); } + + return null; } /** diff --git a/src/Propel/Generator/Model/Index.php b/src/Propel/Generator/Model/Index.php index 465898f513..f52a83117b 100644 --- a/src/Propel/Generator/Model/Index.php +++ b/src/Propel/Generator/Model/Index.php @@ -27,7 +27,7 @@ class Index extends MappingModel /** * The Table instance. * - * @var Table + * @var Table|null */ protected $table; @@ -54,7 +54,7 @@ class Index extends MappingModel /** * Creates a new Index instance. * - * @param string $name Name of the index + * @param string|null $name Name of the index */ public function __construct($name = null) { @@ -98,7 +98,7 @@ public function getName() { $this->doNaming(); - if ($this->table && $database = $this->table->getDatabase()) { + if ($this->table && ($database = $this->table->getDatabase())) { return substr($this->name, 0, $database->getMaxColumnNameLength()); } @@ -132,7 +132,8 @@ protected function doNaming() public function getFQName() { $table = $this->getTable(); - if ($table->getDatabase() + if ($table + && $table->getDatabase() && ($table->getSchema() || $table->getDatabase()->getSchema()) && $table->getDatabase()->getPlatform() && $table->getDatabase()->getPlatform()->supportsSchemas() @@ -156,7 +157,7 @@ public function setTable(Table $table) /** * Returns the index parent table. * - * @return Table + * @return Table|null */ public function getTable() { diff --git a/src/Propel/Generator/Model/Inheritance.php b/src/Propel/Generator/Model/Inheritance.php index 44ca095ded..52d7666d15 100644 --- a/src/Propel/Generator/Model/Inheritance.php +++ b/src/Propel/Generator/Model/Inheritance.php @@ -19,10 +19,25 @@ */ class Inheritance extends MappingModel { + /** + * @var string|null + */ private $key; + /** + * @var string|null + */ private $className; + /** + * @var string|null + */ private $package; + /** + * @var string|null + */ private $ancestor; + /** + * @var Column|null + */ private $column; /** @@ -57,23 +72,23 @@ public function setKey($key) } /** - * Returns the parent column. + * Sets the parent column * - * @return Column + * @param Column $column */ - public function getColumn() + public function setColumn(Column $column) { - return $this->column; + $this->column = $column; } /** - * Sets the parent column + * Returns the parent column. * - * @param Column $column + * @return Column */ - public function setColumn(Column $column) + public function getColumn() { - $this->column = $column; + return $this->column; } /** @@ -119,7 +134,7 @@ public function setPackage($package) /** * Returns the ancestor value. * - * @return string + * @return string|null */ public function getAncestor() { diff --git a/src/Propel/Generator/Model/ScopedMappingModel.php b/src/Propel/Generator/Model/ScopedMappingModel.php index a4b623708d..9e560c127f 100644 --- a/src/Propel/Generator/Model/ScopedMappingModel.php +++ b/src/Propel/Generator/Model/ScopedMappingModel.php @@ -19,9 +19,21 @@ */ abstract class ScopedMappingModel extends MappingModel { + /** + * @var string|null + */ protected $package; + /** + * @var bool + */ protected $packageOverridden; + /** + * @var string|null + */ protected $namespace; + /** + * @var string|null + */ protected $schema; /** diff --git a/src/Propel/Generator/Model/Table.php b/src/Propel/Generator/Model/Table.php index 99a480b30c..7f96de270b 100644 --- a/src/Propel/Generator/Model/Table.php +++ b/src/Propel/Generator/Model/Table.php @@ -73,7 +73,7 @@ class Table extends ScopedMappingModel implements IdMethod private $phpNamingMethod; /** - * @var Database + * @var Database|null */ private $database; @@ -83,7 +83,7 @@ class Table extends ScopedMappingModel implements IdMethod private $referrers; private $containsForeignPK; /** - * @var Column + * @var Column|null */ private $inheritanceColumn; private $skipSql; @@ -135,7 +135,7 @@ class Table extends ScopedMappingModel implements IdMethod /** * Constructs a table object with a name * - * @param string $name table name + * @param string|null $name table name */ public function __construct($name = null) { @@ -673,7 +673,7 @@ public function addForeignKeys(array $foreignKeys) * Returns the column that subclasses the class representing this * table can be produced from. * - * @return Column + * @return Column|null */ public function getChildrenColumn() { @@ -1018,7 +1018,7 @@ public function addUnique($unique) /** * Retrieves the configuration object. * - * @return \Propel\Generator\Config\GeneratorConfigInterface + * @return \Propel\Generator\Config\GeneratorConfigInterface|null */ public function getGeneratorConfig() { @@ -1749,7 +1749,7 @@ public function setDatabase(Database $database) /** * Get the database that contains this table. * - * @return Database + * @return Database|null */ public function getDatabase() { @@ -1759,7 +1759,7 @@ public function getDatabase() /** * Returns the Database platform. * - * @return PlatformInterface + * @return PlatformInterface|null */ public function getPlatform() { diff --git a/src/Propel/Generator/Model/VendorInfo.php b/src/Propel/Generator/Model/VendorInfo.php index f7105c75a7..aa78beea4b 100644 --- a/src/Propel/Generator/Model/VendorInfo.php +++ b/src/Propel/Generator/Model/VendorInfo.php @@ -24,7 +24,7 @@ class VendorInfo extends MappingModel /** * Creates a new VendorInfo instance. * - * @param string $type RDBMS type (optional) + * @param string|null $type RDBMS type (optional) * @param array $parameters An associative array of vendor's parameters (optional) */ public function __construct($type = null, array $parameters = []) diff --git a/src/Propel/Generator/Platform/OraclePlatform.php b/src/Propel/Generator/Platform/OraclePlatform.php index efb8365ff3..9d499818dc 100644 --- a/src/Propel/Generator/Platform/OraclePlatform.php +++ b/src/Propel/Generator/Platform/OraclePlatform.php @@ -36,19 +36,19 @@ class OraclePlatform extends DefaultPlatform protected function initialize() { parent::initialize(); - $this->schemaDomainMap[PropelTypes::BOOLEAN] = new Domain(PropelTypes::BOOLEAN_EMU, 'NUMBER', '1', '0'); + $this->schemaDomainMap[PropelTypes::BOOLEAN] = new Domain(PropelTypes::BOOLEAN_EMU, 'NUMBER', 1, 0); $this->schemaDomainMap[PropelTypes::CLOB] = new Domain(PropelTypes::CLOB_EMU, 'CLOB'); $this->schemaDomainMap[PropelTypes::CLOB_EMU] = $this->schemaDomainMap[PropelTypes::CLOB]; - $this->setSchemaDomainMapping(new Domain(PropelTypes::TINYINT, 'NUMBER', '3', '0')); - $this->setSchemaDomainMapping(new Domain(PropelTypes::SMALLINT, 'NUMBER', '5', '0')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::TINYINT, 'NUMBER', 3, 0)); + $this->setSchemaDomainMapping(new Domain(PropelTypes::SMALLINT, 'NUMBER', 5, 0)); $this->setSchemaDomainMapping(new Domain(PropelTypes::INTEGER, 'NUMBER')); - $this->setSchemaDomainMapping(new Domain(PropelTypes::BIGINT, 'NUMBER', '20', '0')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::BIGINT, 'NUMBER', 20, 0)); $this->setSchemaDomainMapping(new Domain(PropelTypes::REAL, 'NUMBER')); $this->setSchemaDomainMapping(new Domain(PropelTypes::DOUBLE, 'FLOAT')); $this->setSchemaDomainMapping(new Domain(PropelTypes::DECIMAL, 'NUMBER')); $this->setSchemaDomainMapping(new Domain(PropelTypes::NUMERIC, 'NUMBER')); $this->setSchemaDomainMapping(new Domain(PropelTypes::VARCHAR, 'NVARCHAR2')); - $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, 'NVARCHAR2', '2000')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, 'NVARCHAR2', 2000)); $this->setSchemaDomainMapping(new Domain(PropelTypes::TIME, 'DATE')); $this->setSchemaDomainMapping(new Domain(PropelTypes::DATE, 'DATE')); $this->setSchemaDomainMapping(new Domain(PropelTypes::TIMESTAMP, 'TIMESTAMP')); @@ -56,10 +56,9 @@ protected function initialize() $this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, 'BLOB')); $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, 'LONG RAW')); $this->setSchemaDomainMapping(new Domain(PropelTypes::OBJECT, 'LONG RAW')); - $this->setSchemaDomainMapping(new Domain(PropelTypes::PHP_ARRAY, 'NVARCHAR2', '2000')); - $this->setSchemaDomainMapping(new Domain(PropelTypes::ENUM, 'NUMBER', '3', '0')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::PHP_ARRAY, 'NVARCHAR2', 2000)); + $this->setSchemaDomainMapping(new Domain(PropelTypes::ENUM, 'NUMBER', 3, 0)); $this->setSchemaDomainMapping(new Domain(PropelTypes::SET, 'NUMBER')); - } public function getMaxColumnNameLength() diff --git a/src/Propel/Generator/Util/BehaviorLocator.php b/src/Propel/Generator/Util/BehaviorLocator.php index 61515a5df1..16d1aeb78b 100644 --- a/src/Propel/Generator/Util/BehaviorLocator.php +++ b/src/Propel/Generator/Util/BehaviorLocator.php @@ -45,6 +45,7 @@ public function __construct(GeneratorConfigInterface $config = null) /** * Searches a composer file * + * @param string $fileName * @return SplFileInfo|null The found composer file or null if composer file isn't found */ private function findComposerFile($fileName) @@ -72,7 +73,7 @@ private function findComposerFile($fileName) /** * Searches the composer.lock file * - * @return SplFileInfo the found composer.lock or null if composer.lock isn't found + * @return SplFileInfo|null The found composer.lock or null if composer.lock isn't found */ private function findComposerLock() { @@ -82,7 +83,7 @@ private function findComposerLock() /** * Searches the composer.json file * - * @return SplFileInfo the found composer.json or null if composer.json isn't found + * @return SplFileInfo|null the found composer.json or null if composer.json isn't found */ private function findComposerJson() { @@ -189,10 +190,6 @@ private function loadBehaviors($composerLock) { $behaviors = []; - if (null === $composerLock) { - return $behaviors; - } - $json = json_decode($composerLock->getContents(), true); if (isset($json['packages'])) { diff --git a/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php b/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php index e38621331f..971ad3a7f7 100644 --- a/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php @@ -29,9 +29,9 @@ class BaseModelCriteria extends Criteria implements \IteratorAggregate * Creates a new instance with the default capacity which corresponds to * the specified database. * - * @param string $dbName The dabase name - * @param string $modelName The phpName of a model, e.g. 'Book' - * @param string $modelAlias The alias for the model in this query, e.g. 'b' + * @param string|null $dbName The dabase name + * @param string|null $modelName The phpName of a model, e.g. 'Book' + * @param string|null $modelAlias The alias for the model in this query, e.g. 'b' */ public function __construct($dbName = null, $modelName = null, $modelAlias = null) { @@ -59,7 +59,7 @@ public function getWith() * * @param array $with * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function setWith($with) { @@ -77,7 +77,7 @@ public function setWith($with) * * * @param string|AbstractFormatter $formatter a formatter class name, or a formatter instance - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface * * @throws InvalidArgumentException */ @@ -128,7 +128,7 @@ public function getModelName() * * @param string $modelName * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function setModelName($modelName) { @@ -140,7 +140,7 @@ public function setModelName($modelName) if ($this->modelName && !$this->modelTableMapName) { $this->modelTableMapName = constant($this->modelName . '::TABLE_MAP'); } - if (!$this->tableMap && $this->modelName) { + if ($this->modelName) { $this->tableMap = Propel::getServiceContainer()->getDatabaseMap($this->getDbName())->getTableByPhpName($this->modelName); } @@ -158,7 +158,7 @@ public function getFullyQualifiedModelName() * @param string $modelAlias The model alias * @param boolean $useAliasInSQL Whether to use the alias in the SQL code (false by default) * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function setModelAlias($modelAlias, $useAliasInSQL = false) { diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index 312c1c484e..d48ffa19f0 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -206,6 +206,9 @@ class Criteria */ protected $joins = []; + /** + * @var Criteria[] + */ protected $selectQueries = []; /** @@ -222,16 +225,23 @@ class Criteria */ protected $primaryTableName; - /** The name of the database as given in the constructor. */ + /** + * The name of the database as given in the constructor. + * @var string|null + */ protected $originalDbName; /** * To limit the number of rows to return. -1 means return all * rows. + * @var int */ protected $limit = -1; - /** To start the results at a row other than the first one. */ + /** + * To start the results at a row other than the first one. + * @var int + */ protected $offset = 0; /** @@ -246,7 +256,7 @@ class Criteria /** * Storage for Criterions expected to be combined - * @var array + * @var AbstractCriterion[] */ protected $namedCriterions = []; @@ -258,16 +268,16 @@ class Criteria protected $defaultCombineOperator = Criteria::LOGICAL_AND; /** - * @var PropelConditionalProxy + * @var PropelConditionalProxy|null */ - protected $conditionalProxy = null; + protected $conditionalProxy; /** * Whether identifier should be quoted. * * @var boolean */ - protected $identifierQuoting = null; + protected $identifierQuoting = false; /** * @var array @@ -278,7 +288,7 @@ class Criteria * Creates a new instance with the default capacity which corresponds to * the specified database. * - * @param String $dbName The database name. + * @param string|null $dbName The database name. */ public function __construct($dbName = null) { @@ -335,7 +345,7 @@ public function clear() * @param string $name Wanted Name of the column (alias). * @param string $clause SQL clause to select from the table * - * @return $this|Criteria A modified Criteria object. + * @return $this A modified Criteria object. */ public function addAsColumn($name, $clause) { @@ -377,7 +387,7 @@ public function getColumnForAs($as) * @param string $alias * @param string $table * - * @return $this|Criteria A modified Criteria object. + * @return $this A modified Criteria object. */ public function addAlias($alias, $table) { @@ -391,7 +401,7 @@ public function addAlias($alias, $table) * * @param string $alias * - * @return $this|Criteria A modified Criteria object. + * @return $this A modified Criteria object. */ public function removeAlias($alias) { @@ -555,8 +565,8 @@ public function getLastCriterion() * Criterions to form a more complex where clause. * * @param string $column Full name of column (for example TABLE.COLUMN). - * @param mixed $value - * @param string $comparison Criteria comparison constant or PDO binding type + * @param mixed|null $value + * @param string|int $comparison Criteria comparison constant or PDO binding type * @return AbstractCriterion */ public function getNewCriterion($column, $value = null, $comparison = self::EQUAL) @@ -751,7 +761,7 @@ public function get($key) * * @param string $key * @param mixed $value - * @return $this|Criteria Instance of self. + * @return $this Instance of self. */ public function put($key, $value) { @@ -798,11 +808,11 @@ public function putAll($t) * The name of the table must be used implicitly in the column name, * so the Column name must be something like 'TABLE.id'. * - * @param string $p1 The column to run the comparison on, or a Criterion object. + * @param string|AbstractCriterion $p1 The column to run the comparison on, or a Criterion object. * @param mixed $value - * @param string $comparison A String. + * @param string|int|null $comparison A String. * - * @return $this|Criteria A modified Criteria object. + * @return $this A modified Criteria object. */ public function add($p1, $value = null, $comparison = null) { @@ -844,7 +854,7 @@ public function __toString() * @param mixed $value * @param string $comparison A String. * - * @return $this|Criteria A modified Criteria object. + * @return $this A modified Criteria object. */ public function addCond($name, $p1, $value = null, $comparison = null) { @@ -859,7 +869,7 @@ public function addCond($name, $p1, $value = null, $comparison = null) * @param array $criterions array of the name of the criterions to combine * @param string $operator logical operator, either Criteria::LOGICAL_AND, or Criteria::LOGICAL_OR * @param string $name optional name to combine the criterion later - * @return $this|Criteria + * @return $this */ public function combine($criterions = [], $operator = self::LOGICAL_AND, $name = null) { @@ -894,13 +904,13 @@ public function combine($criterions = [], $operator = self::LOGICAL_AND, $name = * // LEFT JOIN FOO ON (PROJECT.ID = FOO.PROJECT_ID) * * - * @param mixed $left A String with the left side of the join. - * @param mixed $right A String with the right side of the join. + * @param string|array $left A String with the left side of the join. + * @param string|array $right A String with the right side of the join. * @param mixed $joinType A String with the join operator * among Criteria::INNER_JOIN, Criteria::LEFT_JOIN, * and Criteria::RIGHT_JOIN * - * @return $this|Criteria A modified Criteria object. + * @return $this A modified Criteria object. */ public function addJoin($left, $right, $joinType = null) { @@ -921,13 +931,13 @@ public function addJoin($left, $right, $joinType = null) $dotpos = strrpos($left, '.'); $leftTableAlias = substr($left, 0, $dotpos); $leftColumnName = substr($left, $dotpos + 1); - list($leftTableName, $leftTableAlias) = $this->getTableNameAndAlias($leftTableAlias); + [$leftTableName, $leftTableAlias] = $this->getTableNameAndAlias($leftTableAlias); // is the right table an alias ? $dotpos = strrpos($right, '.'); $rightTableAlias = substr($right, 0, $dotpos); $rightColumnName = substr($right, $dotpos + 1); - list($rightTableName, $rightTableAlias) = $this->getTableNameAndAlias($rightTableAlias); + [$rightTableName, $rightTableAlias] = $this->getTableNameAndAlias($rightTableAlias); $join->addExplicitCondition( $leftTableName, $leftColumnName, $leftTableAlias, @@ -958,7 +968,7 @@ public function addJoin($left, $right, $joinType = null) * @param array $conditions An array of conditions, each condition being an array (left, right, operator) * @param string $joinType A String with the join operator. Defaults to an implicit join. * - * @return $this|Criteria A modified Criteria object. + * @return $this A modified Criteria object. */ public function addMultipleJoin($conditions, $joinType = null) { @@ -972,9 +982,9 @@ public function addMultipleJoin($conditions, $joinType = null) if ($pos) { $leftTableAlias = substr($left, 0, $pos); $leftColumnName = substr($left, $pos + 1); - list($leftTableName, $leftTableAlias) = $this->getTableNameAndAlias($leftTableAlias); + [$leftTableName, $leftTableAlias] = $this->getTableNameAndAlias($leftTableAlias); } else { - list($leftTableName, $leftTableAlias) = [null, null]; + [$leftTableName, $leftTableAlias] = [null, null]; $leftColumnName = $left; } @@ -982,9 +992,9 @@ public function addMultipleJoin($conditions, $joinType = null) if ($pos) { $rightTableAlias = substr($right, 0, $pos); $rightColumnName = substr($right, $pos + 1); - list($rightTableName, $rightTableAlias) = $this->getTableNameAndAlias($rightTableAlias); + [$rightTableName, $rightTableAlias] = $this->getTableNameAndAlias($rightTableAlias); } else { - list($rightTableName, $rightTableAlias) = [null, null]; + [$rightTableName, $rightTableAlias] = [null, null]; $rightColumnName = $right; } @@ -1020,7 +1030,7 @@ public function addMultipleJoin($conditions, $joinType = null) * * @param Join $join A join object * - * @return $this|Criteria A modified Criteria object + * @return $this A modified Criteria object */ public function addJoinObject(Join $join) { @@ -1068,7 +1078,7 @@ public function hasJoin($name) * @param Criteria $subQueryCriteria Criteria to build the subquery from * @param string $alias alias for the subQuery * - * @return $this|Criteria this modified Criteria object (Fluid API) + * @return $this this modified Criteria object (Fluid API) */ public function addSelectQuery(Criteria $subQueryCriteria, $alias = null) { @@ -1134,7 +1144,7 @@ public function forgeSelectQueryAlias() /** * Adds 'ALL' modifier to the SQL statement. - * @return $this|Criteria Modified Criteria object (for fluent API) + * @return $this Modified Criteria object (for fluent API) */ public function setAll() { @@ -1146,7 +1156,7 @@ public function setAll() /** * Adds 'DISTINCT' modifier to the SQL statement. - * @return $this|Criteria Modified Criteria object (for fluent API) + * @return $this Modified Criteria object (for fluent API) */ public function setDistinct() { @@ -1162,7 +1172,7 @@ public function setDistinct() * * @param string $modifier The modifier to add * - * @return $this|Criteria Modified Criteria object (for fluent API) + * @return $this Modified Criteria object (for fluent API) */ public function addSelectModifier($modifier) { @@ -1180,7 +1190,7 @@ public function addSelectModifier($modifier) * * @param string $modifier The modifier to add * - * @return $this|Criteria Modified Criteria object (for fluent API) + * @return $this Modified Criteria object (for fluent API) */ public function removeSelectModifier($modifier) { @@ -1205,7 +1215,7 @@ public function hasSelectModifier($modifier) * Sets ignore case. * * @param boolean $b True if case should be ignored. - * @return $this|Criteria Modified Criteria object (for fluent API) + * @return $this Modified Criteria object (for fluent API) */ public function setIgnoreCase($b) { @@ -1234,7 +1244,7 @@ public function isIgnoreCase() * should be using setLimit(1). * * @param boolean $b Set to TRUE if you expect the query to select just one record. - * @return $this|Criteria Modified Criteria object (for fluent API) + * @return $this Modified Criteria object (for fluent API) */ public function setSingleRecord($b) { @@ -1257,7 +1267,7 @@ public function isSingleRecord() * Set limit. * * @param int $limit An int with the value for limit. - * @return $this|Criteria Modified Criteria object (for fluent API) + * @return $this Modified Criteria object (for fluent API) */ public function setLimit($limit) { @@ -1280,7 +1290,7 @@ public function getLimit() * Set offset. * * @param int $offset An int with the value for offset. - * @return $this|Criteria Modified Criteria object (for fluent API) + * @return $this Modified Criteria object (for fluent API) */ public function setOffset($offset) { @@ -1303,7 +1313,7 @@ public function getOffset() * Add select column. * * @param string $name Name of the select column. - * @return $this|Criteria Modified Criteria object (for fluent API) + * @return $this Modified Criteria object (for fluent API) */ public function addSelectColumn($name) { @@ -1316,7 +1326,7 @@ public function addSelectColumn($name) * Set the query comment, that appears after the first verb in the SQL query * * @param string $comment The comment to add to the query, without comment sign - * @return $this|Criteria Modified Criteria object (for fluent API) + * @return $this Modified Criteria object (for fluent API) */ public function setComment($comment = null) { @@ -1362,7 +1372,7 @@ public function getSelectColumns() /** * Clears current select columns. * - * @return $this|Criteria Modified Criteria object (for fluent API) + * @return $this Modified Criteria object (for fluent API) */ public function clearSelectColumns() { @@ -1385,7 +1395,7 @@ public function getSelectModifiers() * Add group by column name. * * @param string $groupBy The name of the column to group by. - * @return $this|Criteria A modified Criteria object. + * @return $this A modified Criteria object. */ public function addGroupByColumn($groupBy) { @@ -1398,7 +1408,7 @@ public function addGroupByColumn($groupBy) * Add order by column name, explicitly specifying ascending. * * @param string $name The name of the column to order by. - * @return $this|Criteria A modified Criteria object. + * @return $this A modified Criteria object. */ public function addAscendingOrderByColumn($name) { @@ -1411,7 +1421,7 @@ public function addAscendingOrderByColumn($name) * Add order by column name, explicitly specifying descending. * * @param string $name The name of the column to order by. - * @return $this|Criteria Modified Criteria object (for fluent API) + * @return $this Modified Criteria object (for fluent API) */ public function addDescendingOrderByColumn($name) { @@ -1433,7 +1443,7 @@ public function getOrderByColumns() /** * Clear the order-by columns. * - * @return $this|Criteria Modified Criteria object (for fluent API) + * @return $this Modified Criteria object (for fluent API) */ public function clearOrderByColumns() { @@ -1445,7 +1455,7 @@ public function clearOrderByColumns() /** * Clear the group-by columns. * - * @return $this|Criteria + * @return $this */ public function clearGroupByColumns() { @@ -1467,7 +1477,7 @@ public function getGroupByColumns() /** * Get Having Criterion. * - * @return AbstractCriterion A Criterion object that is the having clause. + * @return AbstractCriterion|null A Criterion object that is the having clause. */ public function getHaving() { @@ -1478,7 +1488,7 @@ public function getHaving() * Remove an object from the criteria. * * @param string $key A string with the key to be removed. - * @return mixed The removed value. + * @return mixed|null The removed value. */ public function remove($key) { @@ -1486,6 +1496,7 @@ public function remove($key) return null; } + /** @var AbstractCriterion|null */ $removed = $this->map[$key]; unset($this->map[$key]); if ($removed instanceof AbstractCriterion) { @@ -1606,7 +1617,7 @@ public function equals($crit) * Defaults to Criteria::LOGICAL_AND, also accepts Criteria::LOGICAL_OR * This parameter is deprecated, use _or() instead * - * @return $this|Criteria The current criteria object + * @return $this The current criteria object */ public function mergeWith(Criteria $criteria, $operator = null) { @@ -1702,7 +1713,7 @@ public function mergeWith(Criteria $criteria, $operator = null) * @param mixed $value The value to bind in the condition * @param mixed $comparison A PDO::PARAM_ class constant * - * @return $this|Criteria A modified Criteria object. + * @return $this A modified Criteria object. */ public function addHaving($p1, $value = null, $comparison = null) { @@ -1756,7 +1767,7 @@ protected function getCriterionForCondition($p1, $value = null, $comparison = nu * - addAnd(column, value) * - addAnd(Criterion) * - * @return $this|Criteria A modified Criteria object. + * @return $this A modified Criteria object. */ public function addAnd($p1, $p2 = null, $p3 = null, $preferColumnCondition = true) { @@ -1790,7 +1801,7 @@ public function addAnd($p1, $p2 = null, $p3 = null, $preferColumnCondition = tru * @param mixed $p2 * @param mixed $p3 * @param bool $preferColumnCondition - * @return $this|Criteria A modified Criteria object. + * @return $this A modified Criteria object. */ public function addOr($p1, $p2 = null, $p3 = null, $preferColumnCondition = true) { @@ -1820,7 +1831,7 @@ public function addOr($p1, $p2 = null, $p3 = null, $preferColumnCondition = true * (necessary for Propel 1.4 compatibility). * If false, the condition is combined with the last existing condition. * - * @return $this|Criteria A modified Criteria object. + * @return $this A modified Criteria object. */ public function addUsingOperator($p1, $value = null, $operator = null, $preferColumnCondition = true) { @@ -1996,7 +2007,7 @@ public function createSelectSql(&$params) if ($this->hasSelectQueries()) { foreach ($fromClause as $key => $ftable) { if (false !== strpos($ftable, ' ')) { - list(, $tableName) = explode(' ', $ftable); + [, $tableName] = explode(' ', $ftable); } else { $tableName = $ftable; } @@ -2457,7 +2468,7 @@ public function doUpdate($updateValues, ConnectionInterface $con) $stmt = null; // close } catch (\Exception $e) { - if ($stmt) { + if ($stmt !== null) { $stmt = null; // close } Propel::log($e->getMessage(), Propel::LOG_ERR); @@ -2492,6 +2503,7 @@ public function buildParams($columns, Criteria $values = null) public function doCount(ConnectionInterface $con = null) { $dbMap = Propel::getServiceContainer()->getDatabaseMap($this->getDbName()); + /** @var \Propel\Runtime\Adapter\SqlAdapterInterface $db */ $db = Propel::getServiceContainer()->getAdapter($this->getDbName()); if (null === $con) { @@ -2678,7 +2690,7 @@ public function _and() * * @param boolean $cond * - * @return PropelConditionalProxy|$this|Criteria + * @return PropelConditionalProxy|$this */ public function _if($cond) { @@ -2693,7 +2705,7 @@ public function _if($cond) * * @param boolean $cond ignored * - * @return PropelConditionalProxy|$this|Criteria + * @return PropelConditionalProxy|$this */ public function _elseif($cond) { @@ -2708,7 +2720,7 @@ public function _elseif($cond) * Returns a PropelConditionalProxy instance. * Allows for conditional statements in a fluid interface. * - * @return PropelConditionalProxy|$this|Criteria + * @return PropelConditionalProxy|$this */ public function _else() { @@ -2723,7 +2735,7 @@ public function _else() * Returns the current object * Allows for conditional statements in a fluid interface. * - * @return $this|Criteria + * @return $this */ public function _endif() { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php index 6386247bb2..5b670f02a9 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php @@ -231,7 +231,7 @@ public function getConjunctions() * Append an AND Criterion onto this Criterion's list. * * @param AbstractCriterion $criterion - * @return $this|AbstractCriterion + * @return $this */ public function addAnd(AbstractCriterion $criterion) { @@ -245,7 +245,7 @@ public function addAnd(AbstractCriterion $criterion) * Append an OR Criterion onto this Criterion's list. * * @param AbstractCriterion $criterion - * @return $this|AbstractCriterion + * @return $this */ public function addOr(AbstractCriterion $criterion) { @@ -321,11 +321,12 @@ public function equals($obj) /** @var AbstractCriterion $crit */ $crit = $obj; - $isEquiv = (((null === $this->table && null === $crit->getTable()) + $isEquiv = ( + ((null === $this->table && null === $crit->getTable()) || (null !== $this->table && $this->table === $crit->getTable())) && $this->column === $crit->getColumn() - && $this->comparison === $crit->getComparison()) - ; + && $this->comparison === $crit->getComparison() + ); // check chained criterion diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php index 50c6073b9a..a9f4ea9832 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php @@ -66,9 +66,11 @@ public function equals($obj) /** @var AbstractModelCriterion $crit */ $crit = $obj; - $isEquiv = (((null === $this->table && null === $crit->getTable()) - || (null !== $this->table && $crit->getTable() === $this->table) - ) + $isEquiv = ( + ( + (null === $this->table && null === $crit->getTable()) + || (null !== $this->table && $crit->getTable() === $this->table) + ) && $this->clause === $crit->getClause() && $this->column === $crit->getColumn() && $this->comparison === $crit->getComparison()); diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php index 1385423bb6..3bcadd19d3 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php @@ -39,7 +39,7 @@ public function __construct(Criteria $outer, $column, $value, $comparison = Crit * Sets ignore case. * * @param boolean $b True if case should be ignored. - * @return $this|BasicCriterion A modified Criterion object. + * @return $this A modified Criterion object. */ public function setIgnoreCase($b) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php index 1013aa2cd1..7072a38d65 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php @@ -39,7 +39,7 @@ public function __construct(Criteria $outer, $column, $value, $comparison = Crit * Sets ignore case. * * @param boolean $b True if case should be ignored. - * @return $this|LikeCriterion A modified Criterion object. + * @return $this A modified Criterion object. */ public function setIgnoreCase($b) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php index 3234004437..700591295b 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php @@ -26,7 +26,7 @@ class LikeModelCriterion extends BasicModelCriterion * Sets ignore case. * * @param boolean $b True if case should be ignored. - * @return $this|LikeModelCriterion A modified Criterion object. + * @return $this A modified Criterion object. */ public function setIgnoreCase($b) { diff --git a/src/Propel/Runtime/ActiveQuery/Join.php b/src/Propel/Runtime/ActiveQuery/Join.php index 7a82745c7d..28cc8845c7 100644 --- a/src/Propel/Runtime/ActiveQuery/Join.php +++ b/src/Propel/Runtime/ActiveQuery/Join.php @@ -77,11 +77,11 @@ class Join * Use it preferably with no arguments, and then use addCondition() and setJoinType() * Syntax with arguments used mainly for backwards compatibility * - * @param string $leftColumn The left column of the join condition + * @param string|array|null $leftColumn The left column of the join condition * (may contain an alias name) - * @param string $rightColumn The right column of the join condition + * @param string|array|null $rightColumn The right column of the join condition * (may contain an alias name) - * @param string $joinType The type of the join. Valid join types are null (implicit join), + * @param string|null $joinType The type of the join. Valid join types are null (implicit join), * Criteria::LEFT_JOIN, Criteria::RIGHT_JOIN, and Criteria::INNER_JOIN */ public function __construct($leftColumn = null, $rightColumn = null, $joinType = null) @@ -605,7 +605,7 @@ public function getJoinCondition() */ public function buildJoinCondition(Criteria $c) { - /** @var AbstractCriterion $joinCondition */ + /** @var AbstractCriterion|null $joinCondition */ $joinCondition = null; for ($i = 0; $i < $this->count; $i++) { if ($this->leftValues[$i]) { diff --git a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php index b4c8a05808..f174ee0bb6 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php @@ -64,6 +64,9 @@ class ModelCriteria extends BaseModelCriteria protected $useAliasInSQL = false; + /** + * @var \Propel\Runtime\ActiveQuery\ModelCriteria|null + */ protected $primaryCriteria; protected $isWithOneToMany = false; @@ -75,12 +78,18 @@ class ModelCriteria extends BaseModelCriteria protected $isKeepQuery = true; // this is for the select method + /** + * @var string|array|null + */ protected $select; // temporary property used in replaceNames protected $currentAlias; - protected $foundMatch; + /** + * @var bool + */ + protected $foundMatch = false; /** * Used to memorize whether we added self-select columns before. @@ -105,7 +114,7 @@ class ModelCriteria extends BaseModelCriteria * @param mixed $value A value for the condition * @param mixed $bindingType A value for the condition * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function condition($conditionName, $clause, $value = null, $bindingType = null) { @@ -128,7 +137,7 @@ public function condition($conditionName, $clause, $value = null, $bindingType = * @param mixed $value A value for the condition * @param string $comparison What to use for the column comparison, defaults to Criteria::EQUAL * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function filterBy($column, $value, $comparison = Criteria::EQUAL) { @@ -150,7 +159,7 @@ public function filterBy($column, $value, $comparison = Criteria::EQUAL) * * @param mixed $conditions An array of conditions, using column phpNames as key * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function filterByArray($conditions) { @@ -179,7 +188,7 @@ public function filterByArray($conditions) * Or an array of condition names * @param mixed $value A value for the condition * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function where($clause, $value = null, $bindingType = null) { @@ -214,7 +223,7 @@ public function where($clause, $value = null, $bindingType = null) * Or an array of condition names * @param mixed $value A value for the condition * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function having($clause, $value = null, $bindingType = null) { @@ -244,11 +253,11 @@ public function having($clause, $value = null, $bindingType = null) * @param string $columnName The column to order by * @param string $order The sorting order. Criteria::ASC by default, also accepts Criteria::DESC * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function orderBy($columnName, $order = Criteria::ASC) { - list(, $realColumnName) = $this->getColumnFromName($columnName, false); + [, $realColumnName] = $this->getColumnFromName($columnName, false); $order = strtoupper($order); switch ($order) { case Criteria::ASC: @@ -278,7 +287,7 @@ public function orderBy($columnName, $order = Criteria::ASC) * * @param mixed $columnName an array of columns name (e.g. array('Book.AuthorId', 'Book.AuthorName')) or a single column name (e.g. 'Book.AuthorId') * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function groupBy($columnName) { @@ -291,7 +300,7 @@ public function groupBy($columnName) } foreach ($columnName as $column) { - list(, $realColumnName) = $this->getColumnFromName($column, false); + [, $realColumnName] = $this->getColumnFromName($column, false); $this->addGroupByColumn($realColumnName); } @@ -309,7 +318,7 @@ public function groupBy($columnName) * * @param string $class The class name or alias * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function groupByClass($class) { @@ -338,7 +347,7 @@ public function groupByClass($class) * Adds a DISTINCT clause to the query * Alias for Criteria::setDistinct() * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function distinct() { @@ -353,7 +362,7 @@ public function distinct() * * @param int $limit Maximum number of results to return by the query * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function limit($limit) { @@ -368,7 +377,7 @@ public function limit($limit) * * @param int $offset Offset of the first result to return * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function offset($offset) { @@ -397,7 +406,7 @@ public function offset($offset) * * @param mixed $columnArray A list of column names (e.g. array('Title', 'Category.Name', 'c.Content')) or a single column name (e.g. 'Name') * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function select($columnArray) { @@ -469,12 +478,12 @@ public function setPreviousJoin(Join $previousJoin) * @param string $relation Relation to use for the join * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function join($relation, $joinType = Criteria::INNER_JOIN) { // relation looks like '$leftName.$relationName $relationAlias' - list($fullName, $relationAlias) = self::getClassAndAlias($relation); + [$fullName, $relationAlias] = self::getClassAndAlias($relation); if (false === strpos($fullName, '.')) { // simple relation name, refers to the current table $leftName = $this->getModelAliasOrName(); @@ -482,7 +491,7 @@ public function join($relation, $joinType = Criteria::INNER_JOIN) $previousJoin = $this->getPreviousJoin(); $tableMap = $this->getTableMap(); } else { - list($leftName, $relationName) = explode('.', $fullName); + [$leftName, $relationName] = explode('.', $fullName); $shortLeftName = self::getShortName($leftName); // find the TableMap for the left table using the $leftName if ($leftName === $this->getModelAliasOrName() || $leftName === $this->getModelShortName()) { @@ -538,7 +547,7 @@ public function join($relation, $joinType = Criteria::INNER_JOIN) * @param mixed $value An optional value to bind to the clause * @param string $operator The operator to use to add the condition. Defaults to 'AND' * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function addJoinCondition($name, $clause, $value = null, $operator = null, $bindingType = null) { @@ -570,7 +579,7 @@ public function addJoinCondition($name, $clause, $value = null, $operator = null * @param string $name The relation name or alias on which the join was created * @param mixed $condition A Criterion object, or a condition name * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function setJoinCondition($name, $condition) { @@ -594,7 +603,7 @@ public function setJoinCondition($name, $condition) * @see Criteria::addJoinObject() * @param Join $join A join object * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function addJoinObject(Join $join, $name = null) { @@ -624,7 +633,7 @@ public function addJoinObject(Join $join, $name = null) * @param string $relation Relation to use for the join * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function joinWith($relation, $joinType = Criteria::INNER_JOIN) { @@ -650,7 +659,7 @@ public function joinWith($relation, $joinType = Criteria::INNER_JOIN) * * @param string $relation Relation to use for the join * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function with($relation) { @@ -694,7 +703,7 @@ public function isWithOneToMany() * If no alias is provided, the clause is used as a column alias * This alias is used for retrieving the column via BaseObject::getVirtualColumn($alias) * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function withColumn($clause, $name = null) { @@ -773,7 +782,7 @@ public function endUse() * @param string $operator The logical operator used to combine conditions * Defaults to Criteria::LOGICAL_AND, also accepts Criteria::LOGICAL_OR * - * @return $this|ModelCriteria The primary criteria object + * @return $this The primary criteria object */ public function mergeWith(Criteria $criteria, $operator = null) { @@ -791,7 +800,7 @@ public function mergeWith(Criteria $criteria, $operator = null) * Clear the conditions to allow the reuse of the query object. * The ModelCriteria's Model and alias 'all the properties set by construct) will remain. * - * @return $this|ModelCriteria The primary criteria object + * @return $this The primary criteria object */ public function clear() { @@ -819,7 +828,7 @@ public function setPrimaryCriteria(ModelCriteria $criteria, Join $previousJoin) /** * Gets the primary criteria for this secondary Criteria * - * @return ModelCriteria The primary criteria + * @return ModelCriteria|null The primary criteria */ public function getPrimaryCriteria() { @@ -835,7 +844,7 @@ public function getPrimaryCriteria() * @param string $alias alias for the subQuery * @param boolean $addAliasAndSelectColumns Set to false if you want to manually add the aliased select columns * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function addSelectQuery(Criteria $subQueryCriteria, $alias = null, $addAliasAndSelectColumns = true) { @@ -863,7 +872,7 @@ public function addSelectQuery(Criteria $subQueryCriteria, $alias = null, $addAl * Adds the select columns for the current table * * @param bool $force To enforce adding columns for changed alias, set it to true (f.e. with sub selects) - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function addSelfSelectColumns($force = false) { @@ -883,7 +892,7 @@ public function addSelfSelectColumns($force = false) * * @param string $relation The relation name or alias, as defined in join() * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function addRelationSelectColumns($relation) { @@ -905,7 +914,7 @@ public function addRelationSelectColumns($relation) public static function getClassAndAlias($class) { if (false !== strpos($class, ' ')) { - list($class, $alias) = explode(' ', $class); + [$class, $alias] = explode(' ', $class); } else { $alias = null; } @@ -926,13 +935,13 @@ public static function getClassAndAlias($class) public static function getRelationName($relation) { // get the relationName - list($fullName, $relationAlias) = self::getClassAndAlias($relation); + [$fullName, $relationAlias] = self::getClassAndAlias($relation); if ($relationAlias) { $relationName = $relationAlias; } elseif (false === strpos($fullName, '.')) { $relationName = $fullName; } else { - list(, $relationName) = explode('.', $fullName); + [, $relationName] = explode('.', $fullName); } return $relationName; @@ -946,7 +955,7 @@ public static function getRelationName($relation) * * @param boolean $isKeepQuery * - * @return $this|ModelCriteria The current object, for fluid interface + * @return $this The current object, for fluid interface */ public function keepQuery($isKeepQuery = true) { @@ -1855,14 +1864,14 @@ protected function convertValueForColumn($value, ColumnMap $colMap) protected function doReplaceNameInExpression($matches) { $key = $matches[0]; - list($column, $realFullColumnName) = $this->getColumnFromName($key); + [$column, $realFullColumnName] = $this->getColumnFromName($key); if ($column instanceof ColumnMap) { $this->replacedColumns[] = $column; $this->foundMatch = true; if (false !== strpos($key, '.')) { - list($tableName, $columnName) = explode('.', $key); + [$tableName, $columnName] = explode('.', $key); $realColumnName = substr($realFullColumnName, strrpos($realFullColumnName, '.') + 1); if (isset($this->aliases[$tableName])) { //don't replace a alias with their real table name @@ -1898,7 +1907,7 @@ protected function getColumnFromName($phpName, $failSilently = true) $prefix = $this->getModelAliasOrName(); } else { // $prefix could be either class name or table name - list($prefix, $phpName) = explode('.', $phpName); + [$prefix, $phpName] = explode('.', $phpName); } $shortClass = self::getShortName($prefix); @@ -2117,7 +2126,7 @@ public static function getShortName($fullyQualifiedClassName) * @param mixed $value * @param string|null $operator A String, like Criteria::EQUAL. * - * @return $this|ModelCriteria A modified Criteria object. + * @return $this A modified Criteria object. */ public function addUsingAlias($column, $value = null, $operator = null) { @@ -2256,7 +2265,7 @@ public function __clone() * Override method to prevent an addition of self columns. * * @param string $name - * @return $this|Criteria + * @return $this */ public function addSelectColumn($name) { diff --git a/src/Propel/Runtime/ActiveQuery/ModelJoin.php b/src/Propel/Runtime/ActiveQuery/ModelJoin.php index e406527f61..d652e02974 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelJoin.php +++ b/src/Propel/Runtime/ActiveQuery/ModelJoin.php @@ -85,7 +85,7 @@ public function getRelationMap() * * @param TableMap $tableMap The table map to use * - * @return $this|ModelJoin The current join object, for fluid interface + * @return $this The current join object, for fluid interface */ public function setTableMap(TableMap $tableMap) { diff --git a/src/Propel/Runtime/ActiveRecord/NestedSetRecursiveIterator.php b/src/Propel/Runtime/ActiveRecord/NestedSetRecursiveIterator.php index 57fd04be52..0693c49eed 100644 --- a/src/Propel/Runtime/ActiveRecord/NestedSetRecursiveIterator.php +++ b/src/Propel/Runtime/ActiveRecord/NestedSetRecursiveIterator.php @@ -17,10 +17,19 @@ */ class NestedSetRecursiveIterator implements \RecursiveIterator { - protected $topNode = null; - - protected $curNode = null; - + /** + * @var object + */ + protected $topNode; + + /** + * @var object + */ + protected $curNode; + + /** + * @param object $node + */ public function __construct($node) { $this->topNode = $node; diff --git a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php index 2df6437a4c..817666eff0 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php @@ -300,7 +300,7 @@ public function getId(ConnectionInterface $con, $name = null) */ public function formatTemporalValue($value, ColumnMap $cMap) { - /** @var PropelDateTime $dt */ + /** @var PropelDateTime|null $dt */ $dt = PropelDateTime::newInstance($value); if ($dt) { switch ($cMap->getType()) { diff --git a/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php index e6e7e1a8c4..0d8ff49315 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php @@ -163,10 +163,10 @@ public function getGroupBy(Criteria $criteria) $groupBy[] = $colName; } } + } - if ($groupBy) { - return ' GROUP BY ' . implode(',', $groupBy); - } + if ($groupBy) { + return ' GROUP BY ' . implode(',', $groupBy); } return ''; diff --git a/src/Propel/Runtime/Collection/ObjectCollection.php b/src/Propel/Runtime/Collection/ObjectCollection.php index eaa66e700b..bd2a0eab88 100644 --- a/src/Propel/Runtime/Collection/ObjectCollection.php +++ b/src/Propel/Runtime/Collection/ObjectCollection.php @@ -32,6 +32,9 @@ class ObjectCollection extends Collection protected $index; protected $indexSplHash; + /** + * @param array $data + */ public function __construct($data = []) { parent::__construct($data); diff --git a/src/Propel/Runtime/Collection/OnDemandCollection.php b/src/Propel/Runtime/Collection/OnDemandCollection.php index f4eaafb321..75bfd37a05 100644 --- a/src/Propel/Runtime/Collection/OnDemandCollection.php +++ b/src/Propel/Runtime/Collection/OnDemandCollection.php @@ -30,7 +30,7 @@ class OnDemandCollection extends Collection private $lastIterator; /** - * @param AbstractFormatter $formatter + * @param \Propel\Runtime\Formatter\ObjectFormatter $formatter * @param DataFetcherInterface $dataFetcher */ public function initIterator(AbstractFormatter $formatter, DataFetcherInterface $dataFetcher) diff --git a/src/Propel/Runtime/Connection/ConnectionInterface.php b/src/Propel/Runtime/Connection/ConnectionInterface.php index 14a558adf1..9645b435d8 100644 --- a/src/Propel/Runtime/Connection/ConnectionInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionInterface.php @@ -74,7 +74,7 @@ public function inTransaction(); /** * Retrieve a database connection attribute. * - * @param string $attribute The name of the attribute to retrieve, + * @param string|int $attribute The name of the attribute to retrieve, * e.g. PDO::ATTR_AUTOCOMMIT * * @return mixed A successful call returns the value of the requested attribute. @@ -85,7 +85,7 @@ public function getAttribute($attribute); /** * Set an attribute. * - * @param string $attribute + * @param string|int $attribute * @param mixed $value * * @return bool TRUE on success or FALSE on failure. diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index 4d0265bc67..5b157857de 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -320,7 +320,6 @@ public function getAttribute($attribute) switch ($attribute) { case self::PROPEL_ATTR_CACHE_PREPARES: return $this->isCachePreparedStatements; - break; default: return $this->connection->getAttribute($attribute); } diff --git a/src/Propel/Runtime/Connection/ProfilerStatementWrapper.php b/src/Propel/Runtime/Connection/ProfilerStatementWrapper.php index 660d7f4820..16059df1db 100644 --- a/src/Propel/Runtime/Connection/ProfilerStatementWrapper.php +++ b/src/Propel/Runtime/Connection/ProfilerStatementWrapper.php @@ -57,7 +57,7 @@ public function bindValue($pos, $value, $type = \PDO::PARAM_STR) * Executes a prepared statement. Returns a boolean value indicating success. * Overridden for query counting and logging. * - * @param string $parameters + * @param array|null $parameters * @return boolean */ public function execute($parameters = null) diff --git a/src/Propel/Runtime/Connection/StatementWrapper.php b/src/Propel/Runtime/Connection/StatementWrapper.php index 1be409fb73..b97f2064a9 100644 --- a/src/Propel/Runtime/Connection/StatementWrapper.php +++ b/src/Propel/Runtime/Connection/StatementWrapper.php @@ -188,7 +188,7 @@ public function columnCount() * Returns a boolean value indicating success. * Overridden for query counting and logging. * - * @param array $input_parameters + * @param array|null $input_parameters * @return boolean */ public function execute($input_parameters = null) @@ -205,6 +205,7 @@ public function execute($input_parameters = null) } /** + * @param array|null $input_parameters * @return string */ public function getExecutedQueryString($input_parameters = null) @@ -217,7 +218,7 @@ public function getExecutedQueryString($input_parameters = null) $pos = $matches[1][$i]; if (isset($this->boundValues[$pos])) $sql = str_replace($pos, $this->boundValues[$pos], $sql); - if (isset($input_parameters[$pos])) + if ($input_parameters && isset($input_parameters[$pos])) $sql = str_replace($pos, $input_parameters[$pos], $sql); } } diff --git a/src/Propel/Runtime/Formatter/AbstractFormatter.php b/src/Propel/Runtime/Formatter/AbstractFormatter.php index dab995e191..ba3c61cd38 100644 --- a/src/Propel/Runtime/Formatter/AbstractFormatter.php +++ b/src/Propel/Runtime/Formatter/AbstractFormatter.php @@ -87,7 +87,7 @@ public function getDataFetcher() * @param BaseModelCriteria $criteria * @param DataFetcherInterface $dataFetcher * - * @return $this|AbstractFormatter The current formatter object + * @return $this The current formatter object */ public function init(BaseModelCriteria $criteria, DataFetcherInterface $dataFetcher = null) { diff --git a/src/Propel/Runtime/Formatter/OnDemandFormatter.php b/src/Propel/Runtime/Formatter/OnDemandFormatter.php index 92f4b6c080..236639bfd0 100644 --- a/src/Propel/Runtime/Formatter/OnDemandFormatter.php +++ b/src/Propel/Runtime/Formatter/OnDemandFormatter.php @@ -113,7 +113,7 @@ public function getAllObjectsFromRow($row) } // as we may be in a left join, the endObject may be empty // in which case it should not be related to the previous object - if (null === $endObject || $endObject->isPrimaryKeyNull()) { + if ($endObject->isPrimaryKeyNull()) { if ($modelWith->isAdd()) { call_user_func([$startObject, $modelWith->getInitMethod()], false); } diff --git a/src/Propel/Runtime/Map/TableMap.php b/src/Propel/Runtime/Map/TableMap.php index be71c80b1d..e4a4b7e852 100644 --- a/src/Propel/Runtime/Map/TableMap.php +++ b/src/Propel/Runtime/Map/TableMap.php @@ -167,6 +167,9 @@ class TableMap /** * Construct a new TableMap. + * + * @param string|null $name + * @param \Propel\Runtime\Map\DatabaseMap|null $dbMap */ public function __construct($name = null, $dbMap = null) { @@ -657,7 +660,7 @@ public function addRelation($name, $tablePhpName, $type, $joinConditionMapping = } // set columns foreach ($joinConditionMapping as $map) { - list($local, $foreign) = $map; + [$local, $foreign] = $map; $relation->addColumnMapping( $this->getColumnOrValue($local, $relation->getLocalTable()), $this->getColumnOrValue($foreign, $relation->getForeignTable()) diff --git a/src/Propel/Runtime/Parser/XmlParser.php b/src/Propel/Runtime/Parser/XmlParser.php index e97f810d6a..5837a2cd2f 100644 --- a/src/Propel/Runtime/Parser/XmlParser.php +++ b/src/Propel/Runtime/Parser/XmlParser.php @@ -103,7 +103,7 @@ protected function arrayToDOM($array, $rootElement, $charset = null) // Books => Book if (substr($key, -1, 1) === 's') { - $key = substr($key, 0, strlen($key) - 1); + $key = substr($key, 0, -1); } } @@ -125,7 +125,7 @@ protected function arrayToDOM($array, $rootElement, $charset = null) $child = $element->ownerDocument->createTextNode($value->format(\DateTime::ISO8601)); $element->appendChild($child); } else { - $child = $element->ownerDocument->createTextNode($value); + $child = $element->ownerDocument->createTextNode((string)$value); $element->appendChild($child); } $rootElement->appendChild($element); diff --git a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php index d80e3cbe3d..c23e4940bd 100644 --- a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php +++ b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php @@ -197,20 +197,19 @@ public function setAdapters($adapters) * the propel runtime. * * @param string $generatorVersion + * @return void */ public function checkVersion($generatorVersion) { - if ($generatorVersion != Propel::VERSION) { - $warning = "Version mismatch: The generated model was build using propel '" . $generatorVersion; - $warning .= " while the current runtime is at version '" . Propel::VERSION . "'"; - - $logger = $this->getLogger(); - if ($logger) { - $logger->warning($warning); - } else { - trigger_error($warning, E_USER_WARNING); - } + if ($generatorVersion === Propel::VERSION) { + return; } + + $warning = "Version mismatch: The generated model was build using propel '" . $generatorVersion; + $warning .= " while the current runtime is at version '" . Propel::VERSION . "'"; + + $logger = $this->getLogger(); + $logger->warning($warning); } /** @@ -505,7 +504,6 @@ protected function buildLogger($name = 'defaultLogger') 'Handler type "%s" not supported by StandardServiceContainer. Try setting the Logger manually, or use another ServiceContainer.', $configuration['type'] )); - break; } $logger->pushHandler($handler); diff --git a/src/Propel/Runtime/Util/Profiler.php b/src/Propel/Runtime/Util/Profiler.php index d0bb453de7..9a9448e3b9 100644 --- a/src/Propel/Runtime/Util/Profiler.php +++ b/src/Propel/Runtime/Util/Profiler.php @@ -222,10 +222,8 @@ public function getProfileBetween($startSnapshot, $endSnapshot) break; default: throw new InvalidConfigurationException("`$detailName` isn't a valid profiler key (Section: propel.runtime.profiler)."); - break; } $profile .= $config['name'] . $this->innerGlue . str_pad($value, $config['pad'], ' ', STR_PAD_LEFT) . $this->outerGlue; - } return $profile; @@ -290,14 +288,14 @@ public static function formatDuration($duration, $precision = 3) /** * Rounding to significant digits (sort of like JavaScript's toPrecision()). * - * @param float $number Value to round + * @param float|int $number Value to round * @param integer $significantFigures Number of significant figures * * @return string */ public static function toPrecision($number, $significantFigures = 3) { - if (0 === $number) { + if ((float)$number === 0.0) { return '0'; } diff --git a/src/Propel/Runtime/Util/PropelDateTime.php b/src/Propel/Runtime/Util/PropelDateTime.php index 55b6b75346..b011d0b3b7 100644 --- a/src/Propel/Runtime/Util/PropelDateTime.php +++ b/src/Propel/Runtime/Util/PropelDateTime.php @@ -50,9 +50,9 @@ protected static function isTimestamp($value) return true; } - $month = date('m', $value); - $day = date('d', $value); - $year = date('Y', $value); + $month = (int)date('m', $value); + $day = (int)date('d', $value); + $year = (int)date('Y', $value); return checkdate($month, $day, $year); } @@ -69,9 +69,9 @@ protected static function isTimestamp($value) public static function createHighPrecision($time = null) { $dateTime = \DateTime::createFromFormat('U.u', $time ?: self::getMicrotime()); - + $dateTime->setTimeZone(new \DateTimeZone(date_default_timezone_get())); - + return $dateTime; } @@ -95,7 +95,7 @@ public static function getMicrotime() * @param DateTimeZone $timeZone (optional) timezone * @param string $dateTimeClass The class of the object to create, defaults to DateTime * - * @return mixed null, or an instance of $dateTimeClass + * @return mixed|null An instance of $dateTimeClass * * @throws PropelException */ @@ -110,7 +110,7 @@ public static function newInstance($value, DateTimeZone $timeZone = null, $dateT return null; } try { - if (self::isTimestamp($value)) { // if it's a unix timestamp + if (static::isTimestamp($value)) { // if it's a unix timestamp $format = 'U'; if (strpos($value, '.')) { diff --git a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php index 368c65f5c7..e3fe556566 100644 --- a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php @@ -275,13 +275,13 @@ public function testResolveEmptyEnvironmentVariable() public function testResourceNameIsNotStringReturnsFalse() { $this->assertFalse($this->loader->checkSupports('ini', null)); - $this->assertFalse($this->loader->checkSupports('yaml', ['foo', 'bar'])); + $this->assertFalse($this->loader->checkSupports('yaml', false)); } public function testExtensionIsNotStringOrArrayReturnsFalse() { - $this->assertFalse($this->loader->checkSupports(null, '/tmp/propel.yaml')); - $this->assertFalse($this->loader->checkSupports(12, '/tmp/propel.yaml')); + $this->assertFalse($this->loader->checkSupports('', '/tmp/propel.yaml')); + $this->assertFalse($this->loader->checkSupports('12', '/tmp/propel.yaml')); } /** From d9d4d6f8751d886919760f3483f66dbfea3e746b Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 21 Jul 2020 17:20:54 +0200 Subject: [PATCH 100/208] Changes as per review. --- src/Propel/Common/Config/ConfigurationManager.php | 8 ++++---- .../Generator/Behavior/Sluggable/SluggableBehavior.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Propel/Common/Config/ConfigurationManager.php b/src/Propel/Common/Config/ConfigurationManager.php index fc95f69232..a1fbe47dff 100644 --- a/src/Propel/Common/Config/ConfigurationManager.php +++ b/src/Propel/Common/Config/ConfigurationManager.php @@ -132,7 +132,7 @@ public function getConnectionParametersArray($section = 'runtime') * Only one configuration file is supposed to be found. * This method also looks for a '.dist' configuration file and loads it. * - * @param string $fileName Configuration file name or directory in which resides the configuration file. + * @param string|null $fileName Configuration file name or directory in which resides the configuration file. * @param array|null $extraConf Array of configuration properties, to be merged with those loaded from file. */ protected function load($fileName, $extraConf) @@ -250,18 +250,18 @@ private function loadFile($fileName) /** * Return the directories where to find the configuration file. * - * @param string $fileName + * @param string|null $fileName * @return array */ private function getDirs($fileName) { - if (is_file($fileName)) { + if ($fileName && is_file($fileName)) { return []; } $currentDir = getcwd(); - if (is_dir($fileName)) { + if ($fileName && is_dir($fileName)) { $currentDir = $fileName; } diff --git a/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php b/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php index 269d2452bd..d9510389ba 100644 --- a/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php +++ b/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php @@ -71,7 +71,7 @@ public function modifyTable() */ protected function addUniqueConstraint(Table $table) { - $unique = new Unique(); //$this->getColumnForParameter('slug_column') + $unique = new Unique(); $unique->setName($table->getCommonName() . '_slug'); $unique->addColumn($table->getColumn($this->getParameter('slug_column'))); if ($this->getParameter('scope_column')) { From c4d9adebe221ea583f670809df0a8ca72774d2a2 Mon Sep 17 00:00:00 2001 From: Daniel Rose Date: Wed, 22 Jul 2020 08:25:25 +0200 Subject: [PATCH 101/208] add unit test for unique index handling (pgsql only) --- .../Platform/PgsqlPlatformMigrationTest.php | 4 ++++ .../Generator/Platform/PgsqlPlatformTest.php | 11 +++++++++++ .../Platform/PlatformMigrationTestProvider.php | 10 ++++++++++ .../Generator/Platform/PlatformTestProvider.php | 16 ++++++++++++++++ 4 files changed, 41 insertions(+) diff --git a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php index 3e9ff6aaab..e7fae34b04 100755 --- a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php +++ b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php @@ -155,8 +155,12 @@ public function testGetModifyTableIndicesDDL($tableDiff) DROP INDEX "bar_fk"; + ALTER TABLE "foo" DROP CONSTRAINT "bax_unique"; + CREATE INDEX "baz_fk" ON "foo" ("baz"); +ALTER TABLE "foo" ADD CONSTRAINT "bax_bay_unique" UNIQUE ("bax","bay"); + DROP INDEX "bar_baz_fk"; CREATE INDEX "bar_baz_fk" ON "foo" ("id","bar","baz"); diff --git a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php index 47e157269c..df038031d8 100755 --- a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php +++ b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php @@ -600,6 +600,17 @@ public function testAddIndexDDL($index) $this->assertEquals($expected, $this->getPlatform()->getAddIndexDDL($index)); } + /** + * @dataProvider providerForTestGetUniqueIndexDDL + */ + public function testAddUniqueIndexDDL($index) + { + $expected = ' +ALTER TABLE "foo" ADD CONSTRAINT "babar" UNIQUE ("bar1"); +'; + $this->assertEquals($expected, $this->getPlatform()->getAddIndexDDL($index)); + } + /** * @dataProvider providerForTestGetIndicesDDL */ diff --git a/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php b/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php index 31476b3406..8ac8edc37f 100644 --- a/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php +++ b/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php @@ -198,6 +198,7 @@ public function providerForTestGetModifyTableIndicesDDL()
+ @@ -206,6 +207,9 @@ public function providerForTestGetModifyTableIndicesDDL() + + +
EOF; @@ -214,6 +218,8 @@ public function providerForTestGetModifyTableIndicesDDL() + + @@ -223,6 +229,10 @@ public function providerForTestGetModifyTableIndicesDDL() + + + +
EOF; diff --git a/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php b/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php index a450483449..73f34a658e 100644 --- a/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php +++ b/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php @@ -247,6 +247,22 @@ public function providerForTestGetIndexDDL() ]; } + public function providerForTestGetUniqueIndexDDL() + { + $table = new Table('foo'); + $table->setIdentifierQuoting(true); + $column1 = new Column('bar1'); + $column1->getDomain()->copy(new Domain('FOOTYPE')); + $table->addColumn($column1); + $index = new Unique('babar'); + $index->addColumn($column1); + $table->addIndex($index); + + return [ + [$index] + ]; + } + public function providerForTestPrimaryKeyDDL() { $table = new Table('foo'); From 8dcdf5c0cc05eae6867ee457f8100deafb0e5069 Mon Sep 17 00:00:00 2001 From: Daniel Rose Date: Wed, 22 Jul 2020 09:42:00 +0200 Subject: [PATCH 102/208] prepare unit tests for all other platforms --- src/Propel/Generator/Platform/PgsqlPlatform.php | 4 ++-- .../Generator/Platform/MysqlPlatformMigrationMyISAMTest.php | 4 ++++ .../Tests/Generator/Platform/MysqlPlatformMigrationTest.php | 4 ++++ .../Tests/Generator/Platform/OraclePlatformMigrationTest.php | 4 ++++ .../Tests/Generator/Platform/PgsqlPlatformMigrationTest.php | 2 +- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Propel/Generator/Platform/PgsqlPlatform.php b/src/Propel/Generator/Platform/PgsqlPlatform.php index d964d237cd..f2f4f50f35 100755 --- a/src/Propel/Generator/Platform/PgsqlPlatform.php +++ b/src/Propel/Generator/Platform/PgsqlPlatform.php @@ -683,8 +683,8 @@ public function getDropIndexDDL(Index $index) { if ($index instanceof Unique) { $pattern = " - ALTER TABLE %s DROP CONSTRAINT %s; - "; +ALTER TABLE %s DROP CONSTRAINT %s; +"; return sprintf($pattern, $this->quoteIdentifier($index->getTable()->getName()), diff --git a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php index d950418173..c644757bd5 100644 --- a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php +++ b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php @@ -175,8 +175,12 @@ public function testGetModifyTableIndicesDDL($tableDiff) $expected = " DROP INDEX `bar_fk` ON `foo`; +DROP INDEX `bax_unique` ON `foo`; + CREATE INDEX `baz_fk` ON `foo` (`baz`); +CREATE UNIQUE INDEX `bax_bay_unique` ON `foo` (`bax`, `bay`); + DROP INDEX `bar_baz_fk` ON `foo`; CREATE INDEX `bar_baz_fk` ON `foo` (`id`, `bar`, `baz`); diff --git a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php index 6fbfcd28f8..2a222aaf6e 100644 --- a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php +++ b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php @@ -184,8 +184,12 @@ public function testGetModifyTableIndicesDDL($tableDiff) $expected = " DROP INDEX `bar_fk` ON `foo`; +DROP INDEX `bax_unique` ON `foo`; + CREATE INDEX `baz_fk` ON `foo` (`baz`); +CREATE UNIQUE INDEX `bax_bay_unique` ON `foo` (`bax`, `bay`); + DROP INDEX `bar_baz_fk` ON `foo`; CREATE INDEX `bar_baz_fk` ON `foo` (`id`, `bar`, `baz`); diff --git a/tests/Propel/Tests/Generator/Platform/OraclePlatformMigrationTest.php b/tests/Propel/Tests/Generator/Platform/OraclePlatformMigrationTest.php index c654e63971..d687641050 100644 --- a/tests/Propel/Tests/Generator/Platform/OraclePlatformMigrationTest.php +++ b/tests/Propel/Tests/Generator/Platform/OraclePlatformMigrationTest.php @@ -164,8 +164,12 @@ public function testGetModifyTableIndicesDDL($tableDiff) $expected = " DROP INDEX bar_fk; +DROP INDEX bax_unique; + CREATE INDEX baz_fk ON foo (baz); +CREATE UNIQUE INDEX bax_bay_unique ON foo (bax,bay); + DROP INDEX bar_baz_fk; CREATE INDEX bar_baz_fk ON foo (id,bar,baz); diff --git a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php index e7fae34b04..0823134177 100755 --- a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php +++ b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php @@ -155,7 +155,7 @@ public function testGetModifyTableIndicesDDL($tableDiff) DROP INDEX "bar_fk"; - ALTER TABLE "foo" DROP CONSTRAINT "bax_unique"; +ALTER TABLE "foo" DROP CONSTRAINT "bax_unique"; CREATE INDEX "baz_fk" ON "foo" ("baz"); From 56200daba2b9d4c8ff086a125968e3e1df2877d7 Mon Sep 17 00:00:00 2001 From: Gregor Harlan Date: Wed, 22 Jul 2020 13:07:13 +0200 Subject: [PATCH 103/208] failing test case --- tests/Propel/Tests/BookstoreTest.php | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/Propel/Tests/BookstoreTest.php b/tests/Propel/Tests/BookstoreTest.php index ac8471dd21..eef2d7a450 100644 --- a/tests/Propel/Tests/BookstoreTest.php +++ b/tests/Propel/Tests/BookstoreTest.php @@ -12,6 +12,7 @@ use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Collection\Collection; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\AuthorQuery; use Propel\Tests\Bookstore\Book; @@ -713,4 +714,32 @@ public function testScenarioUsingQuery() $this->assertCount(0, BookClubListQuery::create()->find(), 'no records in [book_club_list] table'); $this->assertCount(0, BookListRelQuery::create()->find(), 'no records in [book_x_list] table'); } + + public function testIssue1493() + { + $review = new Review(); + $review->setReviewedBy("Reviewer"); + $review->setRecommended(true); + $review->setReviewDate(time()); + $review->save(); + + $review = new Review(); + $review->setReviewedBy("Reviewer"); + $review->setRecommended(true); + $review->setReviewDate(time()); + $review->save(); + + $this->assertCount(2, ReviewQuery::create()->find(), 'reviews were saved to database'); + + $book = new Book(); + $book->setISBN("0140422161"); + $book->setTitle("Don Juan"); + + $book->getReviews(); + $book->setReviews(new Collection()); + + $book->save(); + + $this->assertCount(2, ReviewQuery::create()->find(), 'reviews are still there'); + } } From 7fee1991b3050b467553c9a49cac0aed3ffeebc3 Mon Sep 17 00:00:00 2001 From: Gregor Harlan Date: Fri, 10 Aug 2018 14:30:21 +0200 Subject: [PATCH 104/208] Do not try to fetch related objects of new object --- src/Propel/Generator/Builder/Om/ObjectBuilder.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index 9629a185d5..8044425faf 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -4172,10 +4172,19 @@ protected function addRefFKGet(&$script, ForeignKey $refFK) public function get$relCol(Criteria \$criteria = null, ConnectionInterface \$con = null) { \$partial = \$this->{$collName}Partial && !\$this->isNew(); - if (null === \$this->$collName || null !== \$criteria || \$partial) { - if (\$this->isNew() && null === \$this->$collName) { + if (null === \$this->$collName || null !== \$criteria || \$partial) { + if (\$this->isNew()) { // return empty collection - \$this->init" . $this->getRefFKPhpNameAffix($refFK, $plural = true) . "(); + if (null === \$this->$collName) { + \$this->init" . $this->getRefFKPhpNameAffix($refFK, $plural = true) . "(); + } else { + \$collectionClassName = ".$this->getClassNameFromBuilder($this->getNewTableMapBuilder($refFK->getTable()))."::getTableMap()->getCollectionClassName(); + + \$$collName = new \$collectionClassName; + \${$collName}->setModel('" . $this->getClassNameFromBuilder($this->getNewStubObjectBuilder($refFK->getTable()), true) . "'); + + return \$$collName; + } } else { \$$collName = $fkQueryClassName::create(null, \$criteria) ->filterBy" . $this->getFKPhpNameAffix($refFK) . "(\$this) From 658692e6036d6c1bf50ae51fdfde3b047a23adb9 Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 22 Jul 2020 13:28:24 +0200 Subject: [PATCH 105/208] Adjustments as per code review. --- src/Propel/Common/Config/Loader/FileLoader.php | 2 +- src/Propel/Generator/Model/Database.php | 5 +++++ src/Propel/Runtime/Parser/AbstractParser.php | 6 ++++++ src/Propel/Runtime/Parser/CsvParser.php | 8 +++++++- src/Propel/Runtime/Parser/XmlParser.php | 9 ++++++++- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/Propel/Common/Config/Loader/FileLoader.php b/src/Propel/Common/Config/Loader/FileLoader.php index 6aee3db465..7dee660c3c 100644 --- a/src/Propel/Common/Config/Loader/FileLoader.php +++ b/src/Propel/Common/Config/Loader/FileLoader.php @@ -125,7 +125,7 @@ protected function checkSupports($ext, $resource) } if (!is_array($ext)) { - throw new \InvalidArgumentException('$ext must string or string[]'); + throw new \InvalidArgumentException('$ext must be string or string[]'); } $supported = false; diff --git a/src/Propel/Generator/Model/Database.php b/src/Propel/Generator/Model/Database.php index b38512e02e..f4a545512f 100644 --- a/src/Propel/Generator/Model/Database.php +++ b/src/Propel/Generator/Model/Database.php @@ -492,6 +492,11 @@ public function addTables(array $tables) } } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return void + */ public function removeTable(Table $table) { if ($this->hasTable($table->getName(), true)) { diff --git a/src/Propel/Runtime/Parser/AbstractParser.php b/src/Propel/Runtime/Parser/AbstractParser.php index 91f2a65ad1..362e0d1c59 100644 --- a/src/Propel/Runtime/Parser/AbstractParser.php +++ b/src/Propel/Runtime/Parser/AbstractParser.php @@ -44,6 +44,12 @@ abstract public function fromArray($array, $rootKey = 'data'); */ abstract public function toArray($data, $rootKey = 'data'); + /** + * @param array $data + * @param string|null $rootKey + * + * @return string + */ public function listFromArray($data, $rootKey = 'data') { return $this->fromArray($data, $rootKey); diff --git a/src/Propel/Runtime/Parser/CsvParser.php b/src/Propel/Runtime/Parser/CsvParser.php index d44d8dd96f..8b84f3e76d 100644 --- a/src/Propel/Runtime/Parser/CsvParser.php +++ b/src/Propel/Runtime/Parser/CsvParser.php @@ -36,7 +36,7 @@ class CsvParser extends AbstractParser * Converts data from an associative array to CSV. * * @param array $array Source data to convert - * @param string $rootKey Will not be used for converting because csv is flat + * @param string|null $rootKey Will not be used for converting because csv is flat * @param boolean $isList Whether the input data contains more than one row * @param boolean $includeHeading Whether the output should contain a heading line * @@ -62,6 +62,12 @@ public function fromArray($array, $rootKey = null, $isList = false, $includeHead return implode($this->lineTerminator, $rows) . $this->lineTerminator; } + /** + * @param array $array + * @param string|null $rootKey + * + * @return string + */ public function listFromArray($array, $rootKey = null) { return $this->fromArray($array, $rootKey, true); diff --git a/src/Propel/Runtime/Parser/XmlParser.php b/src/Propel/Runtime/Parser/XmlParser.php index 5837a2cd2f..d0527099fb 100644 --- a/src/Propel/Runtime/Parser/XmlParser.php +++ b/src/Propel/Runtime/Parser/XmlParser.php @@ -34,12 +34,19 @@ public function fromArray($array, $rootKey = 'data', $charset = null) return $rootNode->ownerDocument->saveXML(); } + /** + * @param array $array + * @param string|null $rootKey + * @param string|null $charset + * + * @return string + */ public function listFromArray($array, $rootKey = 'data', $charset = null) { $rootNode = $this->getRootNode($rootKey); $this->arrayToDOM($array, $rootNode, $charset); - return $rootNode->ownerDocument->saveXML(); + return (string)$rootNode->ownerDocument->saveXML(); } /** From eedc18421d1badbd6e3b3899184a11117b571ed3 Mon Sep 17 00:00:00 2001 From: Daniel Rose Date: Wed, 22 Jul 2020 14:38:00 +0200 Subject: [PATCH 106/208] add dock blocks and type hints --- .../Propel/Tests/Generator/Platform/PgsqlPlatformTest.php | 7 ++++++- .../Generator/Platform/PlatformMigrationTestProvider.php | 6 +++--- .../Tests/Generator/Platform/PlatformTestProvider.php | 5 ++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php index df038031d8..56089b2cbc 100755 --- a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php +++ b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php @@ -17,6 +17,7 @@ use Propel\Generator\Model\IdMethodParameter; use Propel\Generator\Model\PropelTypes; use Propel\Generator\Model\Table; +use Propel\Generator\Model\Unique; use Propel\Generator\Platform\PgsqlPlatform; /** @@ -602,8 +603,12 @@ public function testAddIndexDDL($index) /** * @dataProvider providerForTestGetUniqueIndexDDL + * + * @param \Propel\Generator\Model\Unique $index + * + * @return void */ - public function testAddUniqueIndexDDL($index) + public function testAddUniqueIndexDDL(Unique $index): void { $expected = ' ALTER TABLE "foo" ADD CONSTRAINT "babar" UNIQUE ("bar1"); diff --git a/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php b/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php index 8ac8edc37f..451a71c1b2 100644 --- a/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php +++ b/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php @@ -198,8 +198,8 @@ public function providerForTestGetModifyTableIndicesDDL() - + @@ -218,9 +218,9 @@ public function providerForTestGetModifyTableIndicesDDL()
- - + + diff --git a/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php b/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php index 73f34a658e..c690f13bc6 100644 --- a/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php +++ b/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php @@ -247,7 +247,10 @@ public function providerForTestGetIndexDDL() ]; } - public function providerForTestGetUniqueIndexDDL() + /** + * @return array + */ + public function providerForTestGetUniqueIndexDDL(): array { $table = new Table('foo'); $table->setIdentifierQuoting(true); From 9b4ce207f2f4e2343151889f7b91c0288236846c Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 21 Jul 2020 16:18:18 +0200 Subject: [PATCH 107/208] Prepare for phpstan level 5. --- phpstan-baseline.neon | 250 ++++++++++++++++++++++++++++++++++++++++++ phpstan.neon | 2 +- 2 files changed, 251 insertions(+), 1 deletion(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e22fb35927..9d65e75a22 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -265,6 +265,26 @@ parameters: count: 1 path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php + - + message: "#^Parameter \\#1 \\$v of method Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\:\\:setGeneratorConfig\\(\\) expects Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface, \\$this\\(Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\) given\\.$#" + count: 1 + path: src/Propel/Generator/Builder/DataModelBuilder.php + + - + message: "#^If condition is always true\\.$#" + count: 2 + path: src/Propel/Generator/Builder/DataModelBuilder.php + + - + message: "#^Unreachable statement \\- code above always terminates\\.$#" + count: 1 + path: src/Propel/Generator/Builder/DataModelBuilder.php + + - + message: "#^Left side of && is always true\\.$#" + count: 1 + path: src/Propel/Generator/Builder/DataModelBuilder.php + - message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractObjectBuilder\\:\\:addTemporalAccessor\\(\\)\\.$#" count: 1 @@ -370,6 +390,11 @@ parameters: count: 1 path: src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php + - + message: "#^Result of \\|\\| is always true\\.$#" + count: 2 + path: src/Propel/Generator/Builder/Om/ObjectBuilder.php + - message: "#^Variable \\$mysqlInvalidDateString might not be defined\\.$#" count: 2 @@ -390,21 +415,56 @@ parameters: count: 2 path: src/Propel/Generator/Builder/Om/ObjectBuilder.php + - + message: "#^Negated boolean expression is always false\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/ObjectBuilder.php + - message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getIdentifierPhp\\(\\)\\.$#" count: 2 path: src/Propel/Generator/Builder/Om/ObjectBuilder.php + - + message: "#^If condition is always true\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/ObjectBuilder.php + + - + message: "#^Left side of && is always true\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Om/TableMapBuilder.php + - message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getSequenceName\\(\\)\\.$#" count: 1 path: src/Propel/Generator/Builder/Om/TableMapBuilder.php + - + message: "#^Parameter \\#2 \\$shdl of function xml_set_element_handler expects callable\\(\\)\\: mixed, 'startElement' given\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Util/SchemaReader.php + + - + message: "#^Parameter \\#3 \\$ehdl of function xml_set_element_handler expects callable\\(\\)\\: mixed, 'endElement' given\\.$#" + count: 1 + path: src/Propel/Generator/Builder/Util/SchemaReader.php + - message: "#^Parameter \\$definition of method Propel\\\\Generator\\\\Command\\\\Console\\\\Input\\\\ArrayInput\\:\\:__construct\\(\\) has invalid typehint type Propel\\\\Generator\\\\Command\\\\Console\\\\Input\\\\InputDefinition\\.$#" count: 1 path: src/Propel/Generator/Command/Console/Input/ArrayInput.php + - + message: "#^Parameter \\#1 \\$definition of method Symfony\\\\Component\\\\Console\\\\Input\\\\Input\\:\\:__construct\\(\\) expects Symfony\\\\Component\\\\Console\\\\Input\\\\InputDefinition\\|null, Propel\\\\Generator\\\\Command\\\\Console\\\\Input\\\\InputDefinition\\|null given\\.$#" + count: 1 + path: src/Propel/Generator/Command/Console/Input/ArrayInput.php + + - + message: "#^Parameter \\#1 \\$attempts of method Symfony\\\\Component\\\\Console\\\\Question\\\\Question\\:\\:setMaxAttempts\\(\\) expects int\\|null, true given\\.$#" + count: 1 + path: src/Propel/Generator/Command/Helper/ConsoleHelper3.php + - message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getModifyDatabaseDDL\\(\\)\\.$#" count: 2 @@ -430,6 +490,11 @@ parameters: count: 1 path: src/Propel/Generator/Config/GeneratorConfig.php + - + message: "#^Negated boolean expression is always false\\.$#" + count: 1 + path: src/Propel/Generator/Config/GeneratorConfig.php + - message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" count: 2 @@ -445,6 +510,11 @@ parameters: count: 1 path: src/Propel/Generator/Manager/MigrationManager.php + - + message: "#^Parameter \\#1 \\$builder of method Propel\\\\Generator\\\\Manager\\\\ModelManager\\:\\:doBuild\\(\\) expects Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractOMBuilder, Propel\\\\Generator\\\\Builder\\\\DataModelBuilder given\\.$#" + count: 5 + path: src/Propel/Generator/Manager/ModelManager.php + - message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\:\\:setChild\\(\\)\\.$#" count: 2 @@ -465,6 +535,51 @@ parameters: count: 1 path: src/Propel/Generator/Manager/SqlManager.php + - + message: "#^Strict comparison using \\=\\=\\= between null and string will always evaluate to false\\.$#" + count: 1 + path: src/Propel/Generator/Model/Column.php + + - + message: "#^Strict comparison using \\=\\=\\= between null and string will always evaluate to false\\.$#" + count: 1 + path: src/Propel/Generator/Model/Database.php + + - + message: "#^If condition is always true\\.$#" + count: 1 + path: src/Propel/Generator/Model/Database.php + + - + message: "#^Unreachable statement \\- code above always terminates\\.$#" + count: 2 + path: src/Propel/Generator/Model/Database.php + + - + message: "#^Strict comparison using \\=\\=\\= between null and int will always evaluate to false\\.$#" + count: 2 + path: src/Propel/Generator/Model/Domain.php + + - + message: "#^If condition is always true\\.$#" + count: 1 + path: src/Propel/Generator/Model/ForeignKey.php + + - + message: "#^If condition is always true\\.$#" + count: 1 + path: src/Propel/Generator/Model/Schema.php + + - + message: "#^Parameter \\#1 \\$namespace of method Propel\\\\Generator\\\\Model\\\\ScopedMappingModel\\:\\:setNamespace\\(\\) expects string, null given\\.$#" + count: 1 + path: src/Propel/Generator/Model/Schema.php + + - + message: "#^Strict comparison using \\=\\=\\= between null and array\\ will always evaluate to false\\.$#" + count: 1 + path: src/Propel/Generator/Model/Table.php + - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:isEarly\\(\\)\\.$#" count: 1 @@ -495,6 +610,26 @@ parameters: count: 1 path: src/Propel/Generator/Platform/DefaultPlatform.php + - + message: "#^If condition is always true\\.$#" + count: 1 + path: src/Propel/Generator/Platform/DefaultPlatform.php + + - + message: "#^Result of && is always false\\.$#" + count: 1 + path: src/Propel/Generator/Platform/DefaultPlatform.php + + - + message: "#^Strict comparison using \\=\\=\\= between null and int will always evaluate to false\\.$#" + count: 1 + path: src/Propel/Generator/Platform/DefaultPlatform.php + + - + message: "#^Parameter \\#1 \\$size of method Propel\\\\Generator\\\\Model\\\\Column\\:\\:setSize\\(\\) expects int, null given\\.$#" + count: 1 + path: src/Propel/Generator/Platform/DefaultPlatform.php + - message: "#^Method Propel\\\\Generator\\\\Platform\\\\MssqlPlatform\\:\\:getPrimaryKeyDDL\\(\\) should return string\\|null but return statement is missing\\.$#" count: 1 @@ -510,6 +645,11 @@ parameters: count: 1 path: src/Propel/Generator/Platform/MysqlPlatform.php + - + message: "#^Left side of && is always true\\.$#" + count: 2 + path: src/Propel/Generator/Platform/MysqlPlatform.php + - message: "#^Method Propel\\\\Generator\\\\Platform\\\\OraclePlatform\\:\\:getAddPrimaryKeyDDL\\(\\) should return string but return statement is missing\\.$#" count: 1 @@ -520,6 +660,26 @@ parameters: count: 1 path: src/Propel/Generator/Platform/OraclePlatform.php + - + message: "#^If condition is always true\\.$#" + count: 1 + path: src/Propel/Generator/Platform/PgsqlPlatform.php + + - + message: "#^Right side of && is always true\\.$#" + count: 2 + path: src/Propel/Generator/Platform/PgsqlPlatform.php + + - + message: "#^Left side of \\|\\| is always false\\.$#" + count: 2 + path: src/Propel/Generator/Platform/SqlitePlatform.php + + - + message: "#^Parameter \\#1 \\$str of function trim expects string, Propel\\\\Generator\\\\Model\\\\ColumnDefaultValue\\|null given\\.$#" + count: 1 + path: src/Propel/Generator/Platform/SqlitePlatform.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\DataFetcher\\\\DataFetcherInterface\\:\\:setStyle\\(\\)\\.$#" count: 3 @@ -545,6 +705,11 @@ parameters: count: 1 path: src/Propel/Generator/Reverse/PgsqlSchemaParser.php + - + message: "#^If condition is always true\\.$#" + count: 1 + path: src/Propel/Generator/Reverse/SqliteSchemaParser.php + - message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" count: 1 @@ -560,11 +725,26 @@ parameters: count: 6 path: src/Propel/Generator/Schema/Dumper/XmlDumper.php + - + message: "#^Parameter \\#2 \\$value of method DOMElement\\:\\:setAttribute\\(\\) expects string, int\\<1, max\\>\\|int\\ given\\.$#" + count: 1 + path: src/Propel/Generator/Schema/Dumper/XmlDumper.php + + - + message: "#^Parameter \\#2 \\$value of method DOMElement\\:\\:setAttribute\\(\\) expects string, int given\\.$#" + count: 1 + path: src/Propel/Generator/Schema/Dumper/XmlDumper.php + - message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" count: 1 path: src/Propel/Generator/Util/BehaviorLocator.php + - + message: "#^Parameter \\#1 \\$attribute of method Propel\\\\Runtime\\\\Connection\\\\ConnectionWrapper\\:\\:setAttribute\\(\\) expects string, int given\\.$#" + count: 1 + path: src/Propel/Generator/Util/QuickBuilder.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ServiceContainer\\\\ServiceContainerInterface\\:\\:setAdapter\\(\\)\\.$#" count: 1 @@ -580,6 +760,11 @@ parameters: count: 1 path: src/Propel/Generator/Util/QuickBuilder.php + - + message: "#^Parameter \\#2 \\$code of class Propel\\\\Generator\\\\Exception\\\\BuildException constructor expects int, null given\\.$#" + count: 1 + path: src/Propel/Generator/Util/QuickBuilder.php + - message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getAddTablesDDL\\(\\)\\.$#" count: 1 @@ -645,6 +830,36 @@ parameters: count: 3 path: src/Propel/Runtime/ActiveQuery/Criteria.php + - + message: "#^Strict comparison using \\!\\=\\= between null and null will always evaluate to false\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/Criteria.php + + - + message: "#^Parameter \\#2 \\$code of class Propel\\\\Runtime\\\\Exception\\\\PropelException constructor expects int, null given\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/Criteria.php + + - + message: "#^Result of && is always false\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php + + - + message: "#^Strict comparison using \\=\\=\\= between null and string will always evaluate to false\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php + + - + message: "#^Result of && is always false\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php + + - + message: "#^Strict comparison using \\=\\=\\= between null and string will always evaluate to false\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:ignoreCase\\(\\)\\.$#" count: 2 @@ -660,11 +875,26 @@ parameters: count: 7 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - + message: "#^Parameter \\#1 \\$join of method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelJoin\\:\\:setPreviousJoin\\(\\) expects Propel\\\\Runtime\\\\ActiveQuery\\\\ModelJoin, Propel\\\\Runtime\\\\ActiveQuery\\\\Join given\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\Join\\:\\:getRelationMap\\(\\)\\.$#" count: 3 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - + message: "#^Parameter \\#1 \\$join of class Propel\\\\Runtime\\\\ActiveQuery\\\\ModelWith constructor expects Propel\\\\Runtime\\\\ActiveQuery\\\\ModelJoin\\|null, Propel\\\\Runtime\\\\ActiveQuery\\\\Join given\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + + - + message: "#^Strict comparison using \\=\\=\\= between null and Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria will always evaluate to false\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:addSelfSelectColumns\\(\\)\\.$#" count: 1 @@ -705,6 +935,21 @@ parameters: count: 1 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - + message: "#^Instanceof between array and Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria will always evaluate to false\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + + - + message: "#^Call to function is_array\\(\\) with object will always evaluate to false\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + + - + message: "#^Left side of && is always true\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:getTableMap\\(\\)\\.$#" count: 1 @@ -715,6 +960,11 @@ parameters: count: 1 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - + message: "#^Result of \\|\\| is always false\\.$#" + count: 1 + path: src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php + - message: "#^Variable \\$dbMap might not be defined\\.$#" count: 1 diff --git a/phpstan.neon b/phpstan.neon index b67559e48b..4e42a9c864 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,7 @@ includes: - phpstan-baseline.neon parameters: - level: 3 + level: 5 paths: - '%rootDir%/../../../src/' excludes_analyse: From 01daaf4b02837ceb2feea4443336e8b5d6266b50 Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 22 Jul 2020 15:09:28 +0200 Subject: [PATCH 108/208] Fix ReverseManager skipping. --- src/Propel/Generator/Manager/ReverseManager.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Propel/Generator/Manager/ReverseManager.php b/src/Propel/Generator/Manager/ReverseManager.php index dfb38f053c..60217c8873 100644 --- a/src/Propel/Generator/Manager/ReverseManager.php +++ b/src/Propel/Generator/Manager/ReverseManager.php @@ -218,21 +218,25 @@ protected function buildModel() $tables = []; foreach ($database->getTables() as $table) { - /* Was copypasted from DatabaseComparator::isTableExcluded() */ $skip = false; $tablename = $table->getName(); - if (in_array($tablename, $excludeTables)) { + if (in_array($tablename, $excludeTables, true)) { $skip = true; } else { - foreach ($excludeTables as $exclude_tablename) { - if (preg_match('/^' . str_replace('*', '.*', $exclude_tablename) . '$/', $tablename)) { + foreach ($excludeTables as $excludeTable) { + if (preg_match('/^' . str_replace('*', '.*', $excludeTable) . '$/', $tablename)) { $skip = true; + break; } } } - $skip && $database->removeTable($table); + if ($skip) { + continue; + } + + $database->removeTable($table); } $this->log(sprintf('Successfully reverse engineered %d tables', $nbTables)); From abe4ecba98d3e08875ad50853e19379822466f58 Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 22 Jul 2020 17:39:58 +0200 Subject: [PATCH 109/208] Better log output. --- src/Propel/Generator/Manager/ReverseManager.php | 14 +++++++++----- .../Generator/Command/DatabaseReverseTest.php | 5 +++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Propel/Generator/Manager/ReverseManager.php b/src/Propel/Generator/Manager/ReverseManager.php index 60217c8873..87c8fbaa15 100644 --- a/src/Propel/Generator/Manager/ReverseManager.php +++ b/src/Propel/Generator/Manager/ReverseManager.php @@ -215,17 +215,17 @@ protected function buildModel() $nbTables = $parser->parse($database); $excludeTables = $config->getConfigProperty('exclude_tables'); - $tables = []; + $tableNames = []; foreach ($database->getTables() as $table) { $skip = false; - $tablename = $table->getName(); + $tableName = $table->getName(); - if (in_array($tablename, $excludeTables, true)) { + if (in_array($tableName, $excludeTables, true)) { $skip = true; } else { foreach ($excludeTables as $excludeTable) { - if (preg_match('/^' . str_replace('*', '.*', $excludeTable) . '$/', $tablename)) { + if (preg_match('/^' . str_replace('*', '.*', $excludeTable) . '$/', $tableName)) { $skip = true; break; } @@ -236,10 +236,14 @@ protected function buildModel() continue; } + $tableNames[] = $table; + $database->removeTable($table); } - $this->log(sprintf('Successfully reverse engineered %d tables', $nbTables)); + if ($tableNames) { + $this->log(sprintf('Successfully reverse engineered %d/%d tables (%s)', count($tableNames), $nbTables, implode(', ', $tableNames))); + } return $database; } diff --git a/tests/Propel/Tests/Generator/Command/DatabaseReverseTest.php b/tests/Propel/Tests/Generator/Command/DatabaseReverseTest.php index 91cbf55dc7..8a38e3d451 100644 --- a/tests/Propel/Tests/Generator/Command/DatabaseReverseTest.php +++ b/tests/Propel/Tests/Generator/Command/DatabaseReverseTest.php @@ -2,6 +2,7 @@ namespace Propel\Tests\Generator\Command; +use Propel\Generator\Command\AbstractCommand; use Propel\Generator\Command\DatabaseReverseCommand; use Propel\Runtime\Propel; use Propel\Tests\TestCaseFixturesDatabase; @@ -38,11 +39,11 @@ public function testCommandWithoutNamespace() chdir($currentDir); - if (0 !== $result) { + if (AbstractCommand::CODE_SUCCESS !== $result) { rewind($output->getStream()); echo stream_get_contents($output->getStream()); } - $this->assertEquals(0, $result, 'database:reverse tests exited successfully'); + $this->assertSame(AbstractCommand::CODE_SUCCESS, $result, 'database:reverse tests exited successfully'); $databaseXml = simplexml_load_file($outputDir . '/schema.xml'); $this->assertEquals('reverse-test', $databaseXml['name']); From 08d99ed3e369aea8e729011346f227d93551f934 Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 22 Jul 2020 18:02:58 +0200 Subject: [PATCH 110/208] Revert logic as per intention. --- src/Propel/Generator/Manager/ReverseManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Generator/Manager/ReverseManager.php b/src/Propel/Generator/Manager/ReverseManager.php index 87c8fbaa15..385542c327 100644 --- a/src/Propel/Generator/Manager/ReverseManager.php +++ b/src/Propel/Generator/Manager/ReverseManager.php @@ -232,7 +232,7 @@ protected function buildModel() } } - if ($skip) { + if (!$skip) { continue; } From 93777b7528f326b23339bed86a09f6428ebdc0f6 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 23 Jul 2020 10:25:14 +0200 Subject: [PATCH 111/208] Add missing docblocks and apply PHPStan level 5. --- phpstan-baseline.neon | 10 - .../Common/Config/Loader/FileLoader.php | 5 +- .../Common/Config/PropelConfiguration.php | 40 +++ .../AggregateColumnBehavior.php | 10 + .../Archivable/ArchivableBehavior.php | 35 ++ .../ConcreteInheritanceBehavior.php | 47 +++ .../ConcreteInheritanceParentBehavior.php | 21 ++ .../Behavior/Delegate/DelegateBehavior.php | 29 ++ .../Generator/Behavior/I18n/I18nBehavior.php | 65 +++- .../I18nBehaviorObjectBuilderModifier.php | 98 +++++- .../I18n/I18nBehaviorQueryBuilderModifier.php | 26 ++ .../Behavior/NestedSet/NestedSetBehavior.php | 19 ++ ...NestedSetBehaviorObjectBuilderModifier.php | 304 +++++++++++++++++- .../NestedSetBehaviorQueryBuilderModifier.php | 169 +++++++++- .../QueryCache/QueryCacheBehavior.php | 52 ++- .../Behavior/Sluggable/SluggableBehavior.php | 63 +++- .../Behavior/Sortable/SortableBehavior.php | 13 +- .../SortableBehaviorObjectBuilderModifier.php | 47 +++ .../Timestampable/TimestampableBehavior.php | 27 +- .../Versionable/VersionableBehavior.php | 46 +++ .../Builder/Om/AbstractOMBuilder.php | 8 +- .../Builder/Om/AbstractObjectBuilder.php | 10 +- .../Builder/Om/MultiExtendObjectBuilder.php | 1 + .../Generator/Builder/Om/ObjectBuilder.php | 131 +++++++- .../Generator/Builder/Om/QueryBuilder.php | 48 ++- .../Builder/Om/QueryInheritanceBuilder.php | 24 ++ .../Generator/Builder/Om/TableMapBuilder.php | 24 +- .../Generator/Builder/Util/SchemaReader.php | 57 +++- .../Generator/Command/AbstractCommand.php | 8 +- .../Command/Console/Input/ArrayInput.php | 8 + .../Command/Helper/ConsoleHelper.php | 4 + .../Command/Helper/ConsoleHelper3.php | 4 + .../Command/Helper/ConsoleHelperInterface.php | 4 + src/Propel/Generator/Command/InitCommand.php | 61 ++++ .../Command/MigrationStatusCommand.php | 2 +- .../Generator/Command/TestPrepareCommand.php | 2 +- .../Generator/Config/GeneratorConfig.php | 9 +- .../Generator/Manager/AbstractManager.php | 11 +- .../Generator/Manager/GraphvizManager.php | 18 +- .../Generator/Manager/MigrationManager.php | 93 ++++++ src/Propel/Generator/Manager/ModelManager.php | 3 + .../Generator/Manager/ReverseManager.php | 4 + src/Propel/Generator/Manager/SqlManager.php | 16 +- src/Propel/Generator/Model/Behavior.php | 4 + .../Generator/Model/BehaviorableTrait.php | 5 + src/Propel/Generator/Model/Column.php | 139 ++++++-- src/Propel/Generator/Model/Database.php | 75 +++-- .../Generator/Model/Diff/ColumnDiff.php | 16 +- .../Model/Diff/DatabaseComparator.php | 3 + .../Generator/Model/Diff/DatabaseDiff.php | 3 + src/Propel/Generator/Model/Diff/TableDiff.php | 1 + src/Propel/Generator/Model/Domain.php | 10 +- src/Propel/Generator/Model/ForeignKey.php | 19 +- src/Propel/Generator/Model/Index.php | 22 +- src/Propel/Generator/Model/Inheritance.php | 3 + src/Propel/Generator/Model/MappingModel.php | 23 +- .../Generator/Model/ScopedMappingModel.php | 9 +- src/Propel/Generator/Model/Table.php | 25 ++ src/Propel/Generator/Model/VendorInfo.php | 5 +- .../Generator/Platform/DefaultPlatform.php | 34 +- .../Generator/Platform/MssqlPlatform.php | 26 +- .../Generator/Platform/MysqlPlatform.php | 100 +++++- .../Generator/Platform/OraclePlatform.php | 68 +++- .../Generator/Platform/PgsqlPlatform.php | 147 ++++++++- .../Generator/Platform/SqlitePlatform.php | 42 ++- .../Reverse/AbstractSchemaParser.php | 5 + .../Generator/Reverse/MssqlSchemaParser.php | 10 +- .../Generator/Reverse/MysqlSchemaParser.php | 8 +- .../Generator/Reverse/SqliteSchemaParser.php | 16 +- src/Propel/Generator/Util/BehaviorLocator.php | 8 +- src/Propel/Generator/Util/QuickBuilder.php | 52 ++- src/Propel/Generator/Util/SqlParser.php | 6 + .../Runtime/ActiveQuery/BaseModelCriteria.php | 3 + src/Propel/Runtime/ActiveQuery/Criteria.php | 38 ++- .../Criterion/AbstractCriterion.php | 2 +- .../Criterion/AbstractModelCriterion.php | 5 +- .../Runtime/ActiveQuery/InstancePoolTrait.php | 30 ++ src/Propel/Runtime/ActiveQuery/Join.php | 28 +- .../Runtime/ActiveQuery/ModelCriteria.php | 88 +++-- src/Propel/Runtime/ActiveQuery/ModelJoin.php | 30 ++ src/Propel/Runtime/ActiveQuery/ModelWith.php | 122 +++++++ .../NestedSetRecursiveIterator.php | 23 +- .../Runtime/Adapter/Pdo/SqliteAdapter.php | 6 + src/Propel/Runtime/Collection/Collection.php | 15 + .../Runtime/Collection/CollectionIterator.php | 41 +++ .../Runtime/Collection/ObjectCollection.php | 8 + .../Runtime/Collection/OnDemandCollection.php | 22 ++ .../Runtime/Collection/OnDemandIterator.php | 3 + .../Runtime/Connection/ConnectionFactory.php | 2 +- .../Connection/ConnectionManagerInterface.php | 4 +- .../ConnectionManagerPrimaryReplica.php | 5 +- .../Connection/ConnectionManagerSingle.php | 26 +- .../Runtime/Connection/ConnectionWrapper.php | 5 + .../Runtime/Connection/StatementWrapper.php | 6 + .../Runtime/Formatter/AbstractFormatter.php | 87 ++++- .../Runtime/Formatter/ArrayFormatter.php | 11 +- .../Runtime/Formatter/ObjectFormatter.php | 16 +- .../Runtime/Formatter/OnDemandFormatter.php | 15 + .../Formatter/SimpleArrayFormatter.php | 9 + .../Runtime/Formatter/StatementFormatter.php | 14 + src/Propel/Runtime/Map/ColumnMap.php | 12 +- src/Propel/Runtime/Map/DatabaseMap.php | 2 - src/Propel/Runtime/Map/RelationMap.php | 7 +- src/Propel/Runtime/Parser/AbstractParser.php | 6 + src/Propel/Runtime/Parser/CsvParser.php | 34 +- .../StandardServiceContainer.php | 25 +- src/Propel/Runtime/Util/Profiler.php | 14 + .../Runtime/Util/PropelConditionalProxy.php | 22 ++ src/Propel/Runtime/Util/PropelModelPager.php | 51 ++- 109 files changed, 3113 insertions(+), 284 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9d65e75a22..f290180ecb 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -600,16 +600,6 @@ parameters: count: 1 path: src/Propel/Generator/Platform/DefaultPlatform.php - - - message: "#^Method Propel\\\\Generator\\\\Platform\\\\DefaultPlatform\\:\\:getEndDDL\\(\\) should return string\\|null but return statement is missing\\.$#" - count: 1 - path: src/Propel/Generator/Platform/DefaultPlatform.php - - - - message: "#^Method Propel\\\\Generator\\\\Platform\\\\DefaultPlatform\\:\\:getPrimaryKeyDDL\\(\\) should return string\\|null but return statement is missing\\.$#" - count: 1 - path: src/Propel/Generator/Platform/DefaultPlatform.php - - message: "#^If condition is always true\\.$#" count: 1 diff --git a/src/Propel/Common/Config/Loader/FileLoader.php b/src/Propel/Common/Config/Loader/FileLoader.php index 7dee660c3c..48cd61a75f 100644 --- a/src/Propel/Common/Config/Loader/FileLoader.php +++ b/src/Propel/Common/Config/Loader/FileLoader.php @@ -140,9 +140,12 @@ protected function checkSupports($ext, $resource) return $supported; } + /** + * @return bool + */ private function isResolved() { - return ($this->resolved); + return $this->resolved; } /** diff --git a/src/Propel/Common/Config/PropelConfiguration.php b/src/Propel/Common/Config/PropelConfiguration.php index 4ab8048f6d..e77acd1d64 100644 --- a/src/Propel/Common/Config/PropelConfiguration.php +++ b/src/Propel/Common/Config/PropelConfiguration.php @@ -51,6 +51,11 @@ public function getConfigTreeBuilder() return $treeBuilder; } + /** + * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node + * + * @return void + */ protected function addGeneralSection(ArrayNodeDefinition $node) { $node @@ -66,6 +71,11 @@ protected function addGeneralSection(ArrayNodeDefinition $node) ; } + /** + * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node + * + * @return void + */ protected function addPathsSection(ArrayNodeDefinition $node) { $node @@ -87,6 +97,11 @@ protected function addPathsSection(ArrayNodeDefinition $node) ; } + /** + * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node + * + * @return void + */ protected function addDatabaseSection(ArrayNodeDefinition $node) { $node @@ -196,6 +211,11 @@ protected function addDatabaseSection(ArrayNodeDefinition $node) ; } + /** + * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node + * + * @return void + */ protected function addMigrationsSection(ArrayNodeDefinition $node) { $node @@ -213,6 +233,11 @@ protected function addMigrationsSection(ArrayNodeDefinition $node) ; } + /** + * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node + * + * @return void + */ protected function addReverseSection(ArrayNodeDefinition $node) { $node @@ -227,6 +252,11 @@ protected function addReverseSection(ArrayNodeDefinition $node) ; } + /** + * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node + * + * @return void + */ protected function addExcludeTablesSection(ArrayNodeDefinition $node) { $node @@ -238,6 +268,11 @@ protected function addExcludeTablesSection(ArrayNodeDefinition $node) ; } + /** + * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node + * + * @return void + */ protected function addRuntimeSection(ArrayNodeDefinition $node) { $node @@ -312,6 +347,11 @@ protected function addRuntimeSection(ArrayNodeDefinition $node) ; } + /** + * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node + * + * @return void + */ protected function addGeneratorSection(ArrayNodeDefinition $node) { $node diff --git a/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php b/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php index 4f203b8d84..9bec9c67b0 100644 --- a/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php +++ b/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php @@ -136,6 +136,9 @@ protected function addObjectCompute(ObjectBuilder $builder) ]); } + /** + * @return string + */ protected function addObjectUpdate() { return $this->renderTemplate('objectUpdate', [ @@ -143,6 +146,9 @@ protected function addObjectUpdate() ]); } + /** + * @return \Propel\Generator\Model\Table|null + */ protected function getForeignTable() { $database = $this->getTable()->getDatabase(); @@ -155,6 +161,7 @@ protected function getForeignTable() } /** + * @throws \InvalidArgumentException * @return ForeignKey */ protected function getForeignKey() @@ -169,6 +176,9 @@ protected function getForeignKey() return array_shift($fks); } + /** + * @return \Propel\Generator\Model\Column|null + */ protected function getColumn() { return $this->getTable()->getColumn($this->getParameter('name')); diff --git a/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php b/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php index f77f410a49..1d8e899c69 100644 --- a/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php +++ b/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php @@ -58,6 +58,10 @@ public function modifyDatabase() } } + /** + * @throws \Propel\Generator\Exception\InvalidArgumentException + * @return void + */ public function modifyTable() { if ($this->getParameter('archive_class') && $this->getParameter('archive_table')) { @@ -68,6 +72,9 @@ public function modifyTable() } } + /** + * @return void + */ protected function addArchiveTable() { $table = $this->getTable(); @@ -140,6 +147,11 @@ public function getArchiveTable() return $this->archiveTable; } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return mixed + */ public function getArchiveTablePhpName($builder) { if ($this->hasArchiveClass()) { @@ -149,6 +161,11 @@ public function getArchiveTablePhpName($builder) return $builder->getClassNameFromBuilder($builder->getNewStubObjectBuilder($this->getArchiveTable())); } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return string + */ public function getArchiveTableQueryName($builder) { if ($this->hasArchiveClass()) { @@ -158,6 +175,9 @@ public function getArchiveTableQueryName($builder) return $builder->getClassNameFromBuilder($builder->getNewStubQueryBuilder($this->getArchiveTable())); } + /** + * @return bool + */ public function hasArchiveClass() { return $this->getParameter('archive_class') ? true : false; @@ -175,21 +195,33 @@ public function getArchivedAtColumn() return null; } + /** + * @return bool + */ public function isArchiveOnInsert() { return 'true' === $this->getParameter('archive_on_insert'); } + /** + * @return bool + */ public function isArchiveOnUpdate() { return 'true' === $this->getParameter('archive_on_update'); } + /** + * @return bool + */ public function isArchiveOnDelete() { return 'true' === $this->getParameter('archive_on_delete'); } + /** + * @return \Propel\Generator\Behavior\Archivable\ArchivableBehavior|\Propel\Generator\Behavior\Archivable\ArchivableBehaviorObjectBuilderModifier + */ public function getObjectBuilderModifier() { if (null === $this->objectBuilderModifier) { @@ -199,6 +231,9 @@ public function getObjectBuilderModifier() return $this->objectBuilderModifier; } + /** + * @return \Propel\Generator\Behavior\Archivable\ArchivableBehavior|\Propel\Generator\Behavior\Archivable\ArchivableBehaviorQueryBuilderModifier + */ public function getQueryBuilderModifier() { if (null === $this->queryBuilderModifier) { diff --git a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php index ffe38d9e5f..479ed3d40b 100644 --- a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php +++ b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php @@ -25,6 +25,9 @@ */ class ConcreteInheritanceBehavior extends Behavior { + /** + * @var \Propel\Generator\Builder\Om\ObjectBuilder + */ protected $builder; // default parameters value @@ -129,6 +132,10 @@ public function modifyTable() } + /** + * @throws \Propel\Generator\Exception\InvalidArgumentException + * @return \Propel\Generator\Model\Table + */ protected function getParentTable() { $database = $this->getTable()->getDatabase(); @@ -145,6 +152,9 @@ protected function getParentTable() return $table; } + /** + * @return bool + */ protected function isCopyData() { return 'true' === $this->getParameter('copy_data_to_parent'); @@ -166,6 +176,11 @@ protected function getCopyToChild() return explode(',', str_replace(' ', '', $this->getParameter('copy_data_to_child'))); } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder|\Propel\Generator\Builder\Om\QueryBuilder $builder + * + * @return string|null + */ public function parentClass($builder) { $parentTable = $this->getParentTable(); @@ -179,6 +194,9 @@ public function parentClass($builder) return null; } + /** + * @return string + */ public function preSave() { if ($this->isCopyData()) { @@ -193,16 +211,30 @@ public function preSave() return $script; } + + return ''; } + /** + * @param string $script + * + * @return string + */ public function postDelete($script) { if ($this->isCopyData()) { return "\$this->getParentOrCreate(\$con)->delete(\$con); "; } + + return ''; } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return string + */ public function objectMethods($builder) { $script = ''; @@ -220,6 +252,11 @@ public function objectMethods($builder) return $script; } + /** + * @param string $script + * + * @return void + */ protected function addSyncParentToChild(&$script) { $parentTable = $this->getParentTable(); @@ -272,6 +309,11 @@ public function syncParentToChild($parentClass \$parent) "; } + /** + * @param string $script + * + * @return void + */ protected function addObjectGetParentOrCreate(&$script) { $parentTable = $this->getParentTable(); @@ -307,6 +349,11 @@ public function getParentOrCreate(\$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addObjectGetSyncParent(&$script) { $parentTable = $this->getParentTable(); diff --git a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php index bb9a4102e2..f5a2d9414b 100644 --- a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php +++ b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php @@ -21,6 +21,9 @@ */ class ConcreteInheritanceParentBehavior extends Behavior { + /** + * @var \Propel\Generator\Builder\Om\ObjectBuilder + */ protected $builder; // default parameters value @@ -40,11 +43,19 @@ public function modifyTable() } } + /** + * @return string + */ protected function getColumnGetter() { return 'get' . $this->getColumnForParameter('descendant_column')->getPhpName(); } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return string + */ public function objectMethods($builder) { $this->builder = $builder; @@ -56,6 +67,11 @@ public function objectMethods($builder) return $script; } + /** + * @param string $script + * + * @return void + */ protected function addHasChildObject(&$script) { $script .= " @@ -71,6 +87,11 @@ public function hasChildObject() "; } + /** + * @param string $script + * + * @return void + */ protected function addGetChildObject(&$script) { $script .= " diff --git a/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php b/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php index 7d41e18fa7..53987ea8c4 100644 --- a/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php +++ b/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php @@ -85,6 +85,12 @@ public function modifyTable() } } + /** + * @param \Propel\Generator\Model\Table $delegateTable + * @param \Propel\Generator\Model\Table $mainTable + * + * @return void + */ protected function relateDelegateToMainTable($delegateTable, $mainTable) { $pks = $mainTable->getPrimaryKey(); @@ -109,11 +115,21 @@ protected function relateDelegateToMainTable($delegateTable, $mainTable) $delegateTable->addForeignKey($fk); } + /** + * @param string $delegateTableName + * + * @return \Propel\Generator\Model\Table|null + */ protected function getDelegateTable($delegateTableName) { return $this->getTable()->getDatabase()->getTable($delegateTableName); } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return string + */ public function objectCall($builder) { $plural = false; @@ -148,6 +164,11 @@ public function objectCall($builder) return $script; } + /** + * @param string $script + * + * @return void + */ public function objectFilter(&$script) { $p = new PhpParser($script, true); @@ -227,6 +248,9 @@ protected function isColumnForeignKeyOrDuplicated(Column $column) return false; } + /** + * @return string + */ public function queryAttributes() { $script = ''; @@ -255,6 +279,11 @@ public function queryAttributes() return $script; } + /** + * @param \Propel\Generator\Builder\Om\QueryBuilder $builder + * + * @return string + */ public function queryMethods(QueryBuilder $builder) { $script = ''; diff --git a/src/Propel/Generator/Behavior/I18n/I18nBehavior.php b/src/Propel/Generator/Behavior/I18n/I18nBehavior.php index 9ed8751248..334b37572f 100644 --- a/src/Propel/Generator/Behavior/I18n/I18nBehavior.php +++ b/src/Propel/Generator/Behavior/I18n/I18nBehavior.php @@ -58,20 +58,30 @@ public function modifyDatabase() } } + /** + * @return string + */ public function getDefaultLocale() { - if (!$defaultLocale = $this->getParameter('default_locale')) { + $defaultLocale = $this->getParameter('default_locale'); + if (!$defaultLocale) { $defaultLocale = self::DEFAULT_LOCALE; } return $defaultLocale; } + /** + * @return \Propel\Generator\Model\Table + */ public function getI18nTable() { return $this->i18nTable; } + /** + * @return ForeignKey|null + */ public function getI18nForeignKey() { foreach ($this->i18nTable->getForeignKeys() as $fk) { @@ -79,13 +89,21 @@ public function getI18nForeignKey() return $fk; } } + + return null; } + /** + * @return \Propel\Generator\Model\Column + */ public function getLocaleColumn() { return $this->getI18nTable()->getColumn($this->getLocaleColumnName()); } + /** + * @return \Propel\Generator\Model\Column[] + */ public function getI18nColumns() { $columns = []; @@ -109,6 +127,11 @@ public function getI18nColumns() return $columns; } + /** + * @param string $string + * + * @return string + */ public function replaceTokens($string) { $table = $this->getTable(); @@ -119,6 +142,9 @@ public function replaceTokens($string) ]); } + /** + * @return \Propel\Generator\Behavior\I18n\I18nBehavior|\Propel\Generator\Behavior\I18n\I18nBehaviorObjectBuilderModifier + */ public function getObjectBuilderModifier() { if (null === $this->objectBuilderModifier) { @@ -128,6 +154,9 @@ public function getObjectBuilderModifier() return $this->objectBuilderModifier; } + /** + * @return \Propel\Generator\Behavior\I18n\I18nBehavior|\Propel\Generator\Behavior\I18n\I18nBehaviorQueryBuilderModifier + */ public function getQueryBuilderModifier() { if (null === $this->queryBuilderModifier) { @@ -137,6 +166,11 @@ public function getQueryBuilderModifier() return $this->queryBuilderModifier; } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return string + */ public function staticAttributes($builder) { return $this->renderTemplate('staticAttributes', [ @@ -144,6 +178,9 @@ public function staticAttributes($builder) ]); } + /** + * @return void + */ public function modifyTable() { $this->addI18nTable(); @@ -152,6 +189,9 @@ public function modifyTable() $this->moveI18nColumns(); } + /** + * @return void + */ protected function addI18nTable() { $table = $this->getTable(); @@ -178,6 +218,10 @@ protected function addI18nTable() } } + /** + * @throws \Propel\Generator\Exception\EngineException + * @return void + */ protected function relateI18nTableToMainTable() { $table = $this->getTable(); @@ -215,6 +259,9 @@ protected function relateI18nTableToMainTable() $i18nTable->addForeignKey($fk); } + /** + * @return void + */ protected function addLocaleColumnToI18n() { $localeColumnName = $this->getLocaleColumnName(); @@ -232,8 +279,10 @@ protected function addLocaleColumnToI18n() /** * Moves i18n columns from the main table to the i18n table + * + * @return void */ - protected function moveI18nColumns() + protected function moveI18nColumns(): void { $table = $this->getTable(); $i18nTable = $this->i18nTable; @@ -276,21 +325,33 @@ protected function moveI18nColumns() } } + /** + * @return string + */ protected function getI18nTableName() { return $this->replaceTokens($this->getParameter('i18n_table')); } + /** + * @return string + */ protected function getI18nTablePhpName() { return $this->replaceTokens($this->getParameter('i18n_phpname')); } + /** + * @return string + */ protected function getLocaleColumnName() { return $this->replaceTokens($this->getParameter('locale_column')); } + /** + * @return string[] + */ protected function getI18nColumnNamesFromConfig() { $columnNames = explode(',', $this->getParameter('i18n_columns')); diff --git a/src/Propel/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifier.php index d15c68fdd7..21e1c91b4b 100644 --- a/src/Propel/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifier.php @@ -21,16 +21,35 @@ */ class I18nBehaviorObjectBuilderModifier { + /** + * @var \Propel\Generator\Behavior\I18n\I18nBehavior + */ protected $behavior; + + /** + * @var \Propel\Generator\Model\Table + */ protected $table; + + /** + * @var \Propel\Generator\Builder\Om\ObjectBuilder + */ protected $builder; + /** + * @param \Propel\Generator\Behavior\I18n\I18nBehavior $behavior + */ public function __construct($behavior) { $this->behavior = $behavior; $this->table = $behavior->getTable(); } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return string|null + */ public function postDelete($builder) { $this->builder = $builder; @@ -42,8 +61,15 @@ public function postDelete($builder) 'objectClassName' => $builder->getNewStubObjectBuilder($this->behavior->getTable())->getUnqualifiedClassName(), ]); } + + return null; } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return string + */ public function objectAttributes($builder) { return $this->behavior->renderTemplate('objectAttributes', [ @@ -52,6 +78,11 @@ public function objectAttributes($builder) ]); } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return string + */ public function objectClearReferences($builder) { return $this->behavior->renderTemplate('objectClearReferences', [ @@ -59,6 +90,11 @@ public function objectClearReferences($builder) ]); } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return string + */ public function objectMethods($builder) { $this->builder = $builder; @@ -84,15 +120,21 @@ public function objectMethods($builder) return $script; } + /** + * @return string + */ protected function addSetLocale() { return $this->behavior->renderTemplate('objectSetLocale', [ - 'objectClassName' => $this->builder->getClassNameFromBuilder($this->builder->getStubObjectBuilder($this->table)), + 'objectClassName' => $this->builder->getClassNameFromBuilder($this->builder->getStubObjectBuilder()), 'defaultLocale' => $this->behavior->getDefaultLocale(), 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName(), ]); } + /** + * @return string + */ protected function addGetLocale() { return $this->behavior->renderTemplate('objectGetLocale', [ @@ -100,16 +142,26 @@ protected function addGetLocale() ]); } + /** + * @param string $alias + * + * @return string + */ protected function addSetLocaleAlias($alias) { return $this->behavior->renderTemplate('objectSetLocaleAlias', [ - 'objectClassName' => $this->builder->getClassNameFromBuilder($this->builder->getStubObjectBuilder($this->table)), + 'objectClassName' => $this->builder->getClassNameFromBuilder($this->builder->getStubObjectBuilder()), 'defaultLocale' => $this->behavior->getDefaultLocale(), 'alias' => ucfirst($alias), 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName(), ]); } + /** + * @param string $alias + * + * @return string + */ protected function addGetLocaleAlias($alias) { return $this->behavior->renderTemplate('objectGetLocaleAlias', [ @@ -118,6 +170,9 @@ protected function addGetLocaleAlias($alias) ]); } + /** + * @return string + */ protected function addGetTranslation() { $plural = false; @@ -134,13 +189,16 @@ protected function addGetTranslation() ]); } + /** + * @return string + */ protected function addRemoveTranslation() { $i18nTable = $this->behavior->getI18nTable(); $fk = $this->behavior->getI18nForeignKey(); return $this->behavior->renderTemplate('objectRemoveTranslation', [ - 'objectClassName' => $this->builder->getClassNameFromBuilder($this->builder->getStubObjectBuilder($this->table)), + 'objectClassName' => $this->builder->getClassNameFromBuilder($this->builder->getStubObjectBuilder()), 'defaultLocale' => $this->behavior->getDefaultLocale(), 'i18nQueryName' => $this->builder->getClassNameFromBuilder($this->builder->getNewStubQueryBuilder($i18nTable)), 'i18nCollection' => $this->builder->getRefFKCollVarName($fk), @@ -148,6 +206,9 @@ protected function addRemoveTranslation() ]); } + /** + * @return string + */ protected function addGetCurrentTranslation() { return $this->behavior->renderTemplate('objectGetCurrentTranslation', [ @@ -156,8 +217,13 @@ protected function addGetCurrentTranslation() ]); } - // FIXME: the connection used by getCurrentTranslation in the generated code - // cannot be specified by the user + /** + * FIXME: the connection used by getCurrentTranslation in the generated code cannot be specified by the user + * + * @param \Propel\Generator\Model\Column $column + * + * @return string + */ protected function addTranslatedColumnGetter(Column $column) { $objectBuilder = $this->builder->getNewObjectBuilder($this->behavior->getI18nTable()); @@ -182,8 +248,13 @@ protected function addTranslatedColumnGetter(Column $column) ]); } - // FIXME: the connection used by getCurrentTranslation in the generated code - // cannot be specified by the user + /** + * FIXME: the connection used by getCurrentTranslation in the generated code cannot be specified by the user + * + * @param \Propel\Generator\Model\Column $column + * + * @return string + */ protected function addTranslatedColumnSetter(Column $column) { $i18nTablePhpName = $this->builder->getClassNameFromBuilder($this->builder->getNewStubObjectBuilder($this->behavior->getI18nTable())); @@ -211,6 +282,12 @@ protected function addTranslatedColumnSetter(Column $column) ]); } + /** + * @param string $script + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return void + */ public function objectFilter(&$script, $builder) { $i18nTable = $this->behavior->getI18nTable(); @@ -226,12 +303,17 @@ public function objectFilter(&$script, $builder) $script = preg_replace($pattern, $replacement, $script); } + /** + * @param string $columnType + * + * @return bool + */ protected function isDateType($columnType) { return in_array($columnType, [ PropelTypes::DATE, PropelTypes::TIME, PropelTypes::TIMESTAMP - ]); + ], true); } } diff --git a/src/Propel/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifier.php index d3c455dbf3..0366d63cad 100644 --- a/src/Propel/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifier.php @@ -18,18 +18,35 @@ */ class I18nBehaviorQueryBuilderModifier { + /** + * @var \Propel\Generator\Behavior\I18n\I18nBehavior + */ protected $behavior; + /** + * @var \Propel\Generator\Model\Table + */ protected $table; + /** + * @var \Propel\Generator\Builder\Om\QueryBuilder + */ protected $builder; + /** + * @param \Propel\Generator\Behavior\I18n\I18nBehavior $behavior + */ public function __construct($behavior) { $this->behavior = $behavior; $this->table = $behavior->getTable(); } + /** + * @param \Propel\Generator\Builder\Om\QueryBuilder $builder + * + * @return string + */ public function queryMethods($builder) { $this->builder = $builder; @@ -41,6 +58,9 @@ public function queryMethods($builder) return $script; } + /** + * @return string + */ protected function addJoinI18n() { $fk = $this->behavior->getI18nForeignKey(); @@ -53,6 +73,9 @@ protected function addJoinI18n() ]); } + /** + * @return string + */ protected function addJoinWithI18n() { $fk = $this->behavior->getI18nForeignKey(); @@ -64,6 +87,9 @@ protected function addJoinWithI18n() ]); } + /** + * @return string + */ protected function addUseI18nQuery() { $i18nTable = $this->behavior->getI18nTable(); diff --git a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php index 1ff172c584..6852db9eb9 100644 --- a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php +++ b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php @@ -69,6 +69,9 @@ public function modifyTable() } } + /** + * @return \Propel\Generator\Behavior\NestedSet\NestedSetBehavior|\Propel\Generator\Behavior\NestedSet\NestedSetBehaviorObjectBuilderModifier + */ public function getObjectBuilderModifier() { if (null === $this->objectBuilderModifier) { @@ -78,6 +81,9 @@ public function getObjectBuilderModifier() return $this->objectBuilderModifier; } + /** + * @return \Propel\Generator\Behavior\NestedSet\NestedSetBehavior|\Propel\Generator\Behavior\NestedSet\NestedSetBehaviorQueryBuilderModifier + */ public function getQueryBuilderModifier() { if (null === $this->queryBuilderModifier) { @@ -87,16 +93,29 @@ public function getQueryBuilderModifier() return $this->queryBuilderModifier; } + /** + * @return bool + */ public function useScope() { return 'true' === $this->getParameter('use_scope'); } + /** + * @param string $columnName + * + * @return string + */ public function getColumnConstant($columnName) { return $this->getColumn($columnName)->getName(); } + /** + * @param string $columnName + * + * @return \Propel\Generator\Model\Column + */ public function getColumn($columnName) { return $this->getColumnForParameter($columnName); diff --git a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifier.php index 7b039308a0..857da4fcbf 100644 --- a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifier.php @@ -21,43 +21,75 @@ */ class NestedSetBehaviorObjectBuilderModifier { - /** @var NestedSetBehavior */ + /** + * @var NestedSetBehavior + */ protected $behavior; - /** @var Table */ + /** + * @var Table + */ protected $table; - /** @var ObjectBuilder */ + /** + * @var ObjectBuilder + */ protected $builder; - protected $objectClassName; - + /** + * @param \Propel\Generator\Behavior\NestedSet\NestedSetBehavior $behavior + */ public function __construct(NestedSetBehavior $behavior) { $this->behavior = $behavior; $this->table = $behavior->getTable(); } + /** + * @param string $key + * + * @return mixed + */ protected function getParameter($key) { return $this->behavior->getParameter($key); } + /** + * @param string $name + * + * @return string + */ protected function getColumnAttribute($name) { return strtolower($this->behavior->getColumnForParameter($name)->getName()); } + /** + * @param string $name + * + * @return string + */ protected function getColumnPhpName($name) { return $this->behavior->getColumnForParameter($name)->getPhpName(); } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return void + */ protected function setBuilder(ObjectBuilder $builder) { $this->builder = $builder; } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return string + */ public function preSave(ObjectBuilder $builder) { $queryClassName = $builder->getQueryClassName(); @@ -92,6 +124,11 @@ public function preSave(ObjectBuilder $builder) return $script; } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return string + */ public function preDelete(ObjectBuilder $builder) { $queryClassName = $builder->getQueryClassName(); @@ -106,6 +143,11 @@ public function preDelete(ObjectBuilder $builder) "; } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return string + */ public function postDelete(ObjectBuilder $builder) { $queryClassName = $builder->getQueryClassName(); @@ -117,12 +159,22 @@ public function postDelete(ObjectBuilder $builder) "; } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return string + */ public function objectClearReferences(ObjectBuilder $builder) { return "\$this->collNestedSetChildren = null; \$this->aNestedSetParent = null;"; } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return string + */ public function objectMethods(ObjectBuilder $builder) { $this->setBuilder($builder); @@ -217,6 +269,11 @@ public function objectMethods(ObjectBuilder $builder) return $script; } + /** + * @param string $script + * + * @return void + */ protected function addProcessNestedSetQueries(&$script) { $script .= " @@ -235,6 +292,12 @@ protected function processNestedSetQueries(ConnectionInterface \$con) } "; } + + /** + * @param string $script + * + * @return void + */ protected function addGetLeft(&$script) { $script .= " @@ -251,6 +314,11 @@ public function getLeftValue() "; } + /** + * @param string $script + * + * @return void + */ protected function addGetRight(&$script) { $script .= " @@ -267,6 +335,11 @@ public function getRightValue() "; } + /** + * @param string $script + * + * @return void + */ protected function addGetLevel(&$script) { $script .= " @@ -283,6 +356,11 @@ public function getLevel() "; } + /** + * @param string $script + * + * @return void + */ protected function addGetScope(&$script) { $script .= " @@ -299,6 +377,9 @@ public function getScopeValue() "; } + /** + * @return string + */ protected function addSetLeft() { return $this->behavior->renderTemplate('objectSetLeft', [ @@ -307,6 +388,11 @@ protected function addSetLeft() ]); } + /** + * @param string $script + * + * @return void + */ protected function addSetRight(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -326,6 +412,11 @@ public function setRightValue(\$v) "; } + /** + * @param string $script + * + * @return void + */ protected function addSetLevel(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -345,6 +436,11 @@ public function setLevel(\$v) "; } + /** + * @param string $script + * + * @return void + */ protected function addSetScope(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -364,6 +460,11 @@ public function setScopeValue(\$v) "; } + /** + * @param string $script + * + * @return void + */ protected function addMakeRoot(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -390,6 +491,11 @@ public function makeRoot() "; } + /** + * @param string $script + * + * @return void + */ protected function addIsInTree(&$script) { $script .= " @@ -405,6 +511,11 @@ public function isInTree() "; } + /** + * @param string $script + * + * @return void + */ protected function addIsRoot(&$script) { $script .= " @@ -420,6 +531,11 @@ public function isRoot() "; } + /** + * @param string $script + * + * @return void + */ protected function addIsLeaf(&$script) { $script .= " @@ -435,6 +551,11 @@ public function isLeaf() "; } + /** + * @param string $script + * + * @return void + */ protected function addIsDescendantOf(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -461,6 +582,11 @@ public function isDescendantOf($objectClassName \$parent) "; } + /** + * @param string $script + * + * @return void + */ protected function addIsAncestorOf(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -479,6 +605,11 @@ public function isAncestorOf($objectClassName \$child) "; } + /** + * @param string $script + * + * @return void + */ protected function addHasParent(&$script) { $script .= " @@ -494,6 +625,11 @@ public function hasParent() "; } + /** + * @param string $script + * + * @return void + */ protected function addSetParent(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -516,6 +652,11 @@ public function setParent($objectClassName \$parent = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addGetParent(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -543,6 +684,11 @@ public function getParent(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addHasPrevSibling(&$script) { $queryClassName = $this->builder->getQueryClassName(); @@ -572,6 +718,11 @@ public function hasPrevSibling(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addGetPrevSibling(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -598,6 +749,11 @@ public function getPrevSibling(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addHasNextSibling(&$script) { $queryClassName = $this->builder->getQueryClassName(); @@ -627,6 +783,11 @@ public function hasNextSibling(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addGetNextSibling(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -653,6 +814,11 @@ public function getNextSibling(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addNestedSetChildrenClear(&$script) { $script .= " @@ -671,6 +837,11 @@ public function clearNestedSetChildren() "; } + /** + * @param string $script + * + * @return void + */ protected function addNestedSetChildrenInit(&$script) { $script .= " @@ -689,6 +860,11 @@ public function initNestedSetChildren() "; } + /** + * @param string $script + * + * @return void + */ protected function addNestedSetChildAdd(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -717,6 +893,11 @@ public function addNestedSetChild($objectClassName $objectName) "; } + /** + * @param string $script + * + * @return void + */ protected function addHasChildren(&$script) { $script .= " @@ -732,6 +913,11 @@ public function hasChildren() "; } + /** + * @param string $script + * + * @return void + */ protected function addGetChildren(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -768,6 +954,11 @@ public function getChildren(Criteria \$criteria = null, ConnectionInterface \$co "; } + /** + * @param string $script + * + * @return void + */ protected function addCountChildren(&$script) { $queryClassName = $this->builder->getQueryClassName(); @@ -797,6 +988,11 @@ public function countChildren(Criteria \$criteria = null, ConnectionInterface \$ "; } + /** + * @param string $script + * + * @return void + */ protected function addGetFirstChild(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -823,6 +1019,11 @@ public function getFirstChild(Criteria \$criteria = null, ConnectionInterface \$ "; } + /** + * @param string $script + * + * @return void + */ protected function addGetLastChild(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -850,6 +1051,11 @@ public function getLastChild(Criteria \$criteria = null, ConnectionInterface \$c "; } + /** + * @param string $script + * + * @return void + */ protected function addGetSiblings(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -883,6 +1089,11 @@ public function getSiblings(\$includeNode = false, Criteria \$criteria = null, C "; } + /** + * @param string $script + * + * @return void + */ protected function addGetDescendants(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -910,6 +1121,11 @@ public function getDescendants(Criteria \$criteria = null, ConnectionInterface \ "; } + /** + * @param string $script + * + * @return void + */ protected function addCountDescendants(&$script) { $queryClassName = $this->builder->getQueryClassName(); @@ -936,6 +1152,11 @@ public function countDescendants(Criteria \$criteria = null, ConnectionInterface "; } + /** + * @param string $script + * + * @return void + */ protected function addGetBranch(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -959,6 +1180,11 @@ public function getBranch(Criteria \$criteria = null, ConnectionInterface \$con "; } + /** + * @param string $script + * + * @return void + */ protected function addGetAncestors(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -988,6 +1214,11 @@ public function getAncestors(Criteria \$criteria = null, ConnectionInterface \$c "; } + /** + * @param string $script + * + * @return void + */ protected function addAddChild(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -1014,6 +1245,11 @@ public function addChild($objectClassName \$child) "; } + /** + * @param string $script + * + * @return void + */ protected function addInsertAsFirstChildOf(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -1062,6 +1298,9 @@ public function insertAsFirstChildOf($objectClassName \$parent) "; } + /** + * @return string + */ protected function addInsertAsLastChildOf() { return $this->behavior->renderTemplate('objectInsertAsLastChildOf', [ @@ -1071,6 +1310,11 @@ protected function addInsertAsLastChildOf() ]); } + /** + * @param string $script + * + * @return void + */ protected function addInsertAsPrevSiblingOf(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -1114,6 +1358,11 @@ public function insertAsPrevSiblingOf($objectClassName \$sibling) "; } + /** + * @param string $script + * + * @return void + */ protected function addInsertAsNextSiblingOf(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -1157,6 +1406,11 @@ public function insertAsNextSiblingOf($objectClassName \$sibling) "; } + /** + * @param string $script + * + * @return void + */ protected function addMoveToFirstChildOf(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -1188,6 +1442,11 @@ public function moveToFirstChildOf($objectClassName \$parent, ConnectionInterfac "; } + /** + * @param string $script + * + * @return void + */ protected function addMoveToLastChildOf(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -1220,6 +1479,11 @@ public function moveToLastChildOf($objectClassName \$parent, ConnectionInterface "; } + /** + * @param string $script + * + * @return void + */ protected function addMoveToPrevSiblingOf(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -1255,6 +1519,11 @@ public function moveToPrevSiblingOf($objectClassName \$sibling, ConnectionInterf "; } + /** + * @param string $script + * + * @return void + */ protected function addMoveToNextSiblingOf(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -1290,6 +1559,11 @@ public function moveToNextSiblingOf($objectClassName \$sibling, ConnectionInterf "; } + /** + * @param string $script + * + * @return void + */ protected function addMoveSubtreeTo(&$script) { $queryClassName = $this->builder->getQueryClassName(); @@ -1338,17 +1612,16 @@ protected function moveSubtreeTo(\$destLeft, \$levelDelta" . ($this->behavior->u if (\$targetScope != \$scope) { //move subtree to < 0, so the items are out of scope. - $queryClassName::shiftRLValues(-\$right, \$left, \$right" . ($useScope ? ", \$scope" : "") . ", \$con); + $queryClassName::shiftRLValues(-\$right, \$left, \$right, \$scope, \$con); //update scopes $queryClassName::setNegativeScope(\$targetScope, \$con); //update levels - $queryClassName::shiftLevel(\$levelDelta, \$left - \$right, 0" . ($useScope ? ", \$targetScope" : "") . ", \$con); + $queryClassName::shiftLevel(\$levelDelta, \$left - \$right, 0, \$targetScope, \$con); //move the subtree to the target - $queryClassName::shiftRLValues((\$right - \$left) + \$destLeft, \$left - \$right, 0" . ($useScope ? ", \$targetScope" : "") . ", \$con); - + $queryClassName::shiftRLValues((\$right - \$left) + \$destLeft, \$left - \$right, 0, \$targetScope, \$con); \$preventDefault = true; } @@ -1384,6 +1657,11 @@ protected function moveSubtreeTo(\$destLeft, \$levelDelta" . ($this->behavior->u "; } + /** + * @param string $script + * + * @return void + */ protected function addDeleteDescendants(&$script) { $objectClassName = $this->builder->getObjectClassName(); @@ -1436,6 +1714,11 @@ public function deleteDescendants(ConnectionInterface \$con = null) "; } + /** + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @return string + */ public function objectAttributes(ObjectBuilder $builder) { $tableName = $this->table->getName(); @@ -1488,6 +1771,9 @@ public function objectAttributes(ObjectBuilder $builder) return $script; } + /** + * @return string + */ protected function addGetIterator() { return $this->behavior->renderTemplate('objectGetIterator'); diff --git a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifier.php index d72ec0e598..bf83ef5e52 100644 --- a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifier.php @@ -20,37 +20,70 @@ */ class NestedSetBehaviorQueryBuilderModifier { - /** @var NestedSetBehavior */ + /** + * @var NestedSetBehavior + */ protected $behavior; - /** @var Table */ + /** + * @var Table + */ protected $table; - /** @var QueryBuilder */ + /** + * @var QueryBuilder + */ protected $builder; + /** + * @var string + */ protected $objectClassName; + /** + * @var string + */ protected $queryClassName; + /** + * @var string + */ protected $tableMapClassName; + /** + * @param \Propel\Generator\Behavior\NestedSet\NestedSetBehavior $behavior + */ public function __construct(NestedSetBehavior $behavior) { $this->behavior = $behavior; $this->table = $behavior->getTable(); } + /** + * @param string $key + * + * @return mixed + */ protected function getParameter($key) { return $this->behavior->getParameter($key); } + /** + * @param string $name + * + * @return \Propel\Generator\Model\Column + */ protected function getColumn($name) { return $this->behavior->getColumnForParameter($name); } + /** + * @param \Propel\Generator\Builder\Om\QueryBuilder $builder + * + * @return void + */ protected function setBuilder(QueryBuilder $builder) { $this->builder = $builder; @@ -59,6 +92,11 @@ protected function setBuilder(QueryBuilder $builder) $this->tableMapClassName = $builder->getTableMapClassName(); } + /** + * @param \Propel\Generator\Builder\Om\QueryBuilder $builder + * + * @return string + */ public function queryMethods(QueryBuilder $builder) { $this->setBuilder($builder); @@ -107,6 +145,11 @@ public function queryMethods(QueryBuilder $builder) return $script; } + /** + * @param string $script + * + * @return void + */ protected function addTreeRoots(&$script) { $script .= " @@ -122,6 +165,11 @@ public function treeRoots() "; } + /** + * @param string $script + * + * @return void + */ protected function addInTree(&$script) { $script .= " @@ -139,6 +187,11 @@ public function inTree(\$scope = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addDescendantsOf(&$script) { $objectName = '$' . $this->table->getCamelCaseName(); @@ -164,6 +217,11 @@ public function descendantsOf($this->objectClassName $objectName) "; } + /** + * @param string $script + * + * @return void + */ protected function addBranchOf(&$script) { $objectName = '$' . $this->table->getCamelCaseName(); @@ -190,6 +248,11 @@ public function branchOf($this->objectClassName $objectName) "; } + /** + * @param string $script + * + * @return void + */ protected function addChildrenOf(&$script) { $objectName = '$' . $this->table->getCamelCaseName(); @@ -210,6 +273,11 @@ public function childrenOf($this->objectClassName $objectName) "; } + /** + * @param string $script + * + * @return void + */ protected function addSiblingsOf(&$script) { $objectName = '$' . $this->table->getCamelCaseName(); @@ -237,6 +305,11 @@ public function siblingsOf($this->objectClassName $objectName, ConnectionInterfa "; } + /** + * @param string $script + * + * @return void + */ protected function addAncestorsOf(&$script) { $objectName = '$' . $this->table->getCamelCaseName(); @@ -262,6 +335,11 @@ public function ancestorsOf($this->objectClassName $objectName) "; } + /** + * @param string $script + * + * @return void + */ protected function addRootsOf(&$script) { $objectName = '$' . $this->table->getCamelCaseName(); @@ -288,6 +366,11 @@ public function rootsOf($this->objectClassName $objectName) "; } + /** + * @param string $script + * + * @return void + */ protected function addOrderByBranch(&$script) { $script .= " @@ -311,6 +394,11 @@ public function orderByBranch(\$reverse = false) "; } + /** + * @param string $script + * + * @return void + */ protected function addOrderByLevel(&$script) { $script .= " @@ -336,6 +424,11 @@ public function orderByLevel(\$reverse = false) "; } + /** + * @param string $script + * + * @return void + */ protected function addFindRoot(&$script) { $useScope = $this->behavior->useScope(); @@ -367,6 +460,11 @@ public function findRoot(" . ($useScope ? "\$scope = null, " : "") . "Connection "; } + /** + * @param string $script + * + * @return void + */ protected function addFindRoots(&$script) { $script .= " @@ -386,6 +484,11 @@ public function findRoots(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addFindTree(&$script) { $useScope = $this->behavior->useScope(); @@ -417,6 +520,11 @@ public function findTree(" . ($useScope ? "\$scope = null, " : "") . "Connection "; } + /** + * @param string $script + * + * @return void + */ protected function addRetrieveRoots(&$script) { $queryClassName = $this->queryClassName; @@ -443,6 +551,11 @@ static public function retrieveRoots(Criteria \$criteria = null, ConnectionInter "; } + /** + * @param string $script + * + * @return void + */ protected function addRetrieveRoot(&$script) { $queryClassName = $this->queryClassName; @@ -477,6 +590,11 @@ static public function retrieveRoot(" . ($useScope ? "\$scope = null, " : "") . "; } + /** + * @param string $script + * + * @return void + */ protected function addRetrieveTree(&$script) { $queryClassName = $this->queryClassName; @@ -514,6 +632,11 @@ static public function retrieveTree(" . ($useScope ? "\$scope = null, " : "") . "; } + /** + * @param string $script + * + * @return void + */ protected function addIsValid(&$script) { $objectClassName = $this->objectClassName; @@ -536,6 +659,11 @@ static public function isValid($objectClassName \$node = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addDeleteTree(&$script) { $objectClassName = $this->objectClassName; @@ -573,6 +701,11 @@ static public function deleteTree(" . ($useScope ? "\$scope = null, " : "") . "C "; } + /** + * @param string $script + * + * @return void + */ protected function addShiftRLValues(&$script) { $objectClassName = $this->objectClassName; @@ -641,6 +774,11 @@ static public function shiftRLValues(\$delta, \$first, \$last = null" . ($useSco "; } + /** + * @param string $script + * + * @return void + */ protected function addShiftLevel(&$script) { $objectClassName = $this->objectClassName; @@ -687,6 +825,11 @@ static public function shiftLevel(\$delta, \$first, \$last" . ($useScope ? ", \$ "; } + /** + * @param string $script + * + * @return void + */ protected function addUpdateLoadedNodes(&$script) { $queryClassName = $this->queryClassName; @@ -784,6 +927,11 @@ static public function updateLoadedNodes(\$prune = null, ConnectionInterface \$c "; } + /** + * @param string $script + * + * @return void + */ protected function addMakeRoomForLeaf(&$script) { $queryClassName = $this->queryClassName; @@ -813,6 +961,11 @@ static public function makeRoomForLeaf(\$left" . ($useScope ? ", \$scope" : ""). "; } + /** + * @param string $script + * + * @return void + */ protected function addFixLevels(&$script) { $objectClassName = $this->objectClassName; @@ -900,6 +1053,11 @@ static public function fixLevels(" . ($useScope ? "\$scope, " : ""). "Connection "; } + /** + * @param string $script + * + * @return void + */ protected function addSetNegativeScope(&$script) { $objectClassName = $this->objectClassName; @@ -925,6 +1083,11 @@ public static function setNegativeScope(\$scope, ConnectionInterface \$con = nul "; } + /** + * @param string $columnName + * + * @return string + */ protected function getColumnPhpName($columnName) { return $this->behavior->getColumnForParameter($columnName)->getPhpName(); diff --git a/src/Propel/Generator/Behavior/QueryCache/QueryCacheBehavior.php b/src/Propel/Generator/Behavior/QueryCache/QueryCacheBehavior.php index 95d9f72a03..0148798094 100644 --- a/src/Propel/Generator/Behavior/QueryCache/QueryCacheBehavior.php +++ b/src/Propel/Generator/Behavior/QueryCache/QueryCacheBehavior.php @@ -25,8 +25,16 @@ class QueryCacheBehavior extends Behavior 'lifetime' => 3600, ]; + /** + * @var string + */ private $tableClassName; + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function queryAttributes($builder) { $script = "protected \$queryKey = ''; @@ -48,6 +56,11 @@ public function queryAttributes($builder) return $script; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function queryMethods($builder) { $builder->declareClasses('\Propel\Runtime\Propel'); @@ -64,6 +77,11 @@ public function queryMethods($builder) return $script; } + /** + * @param string $script + * + * @return void + */ protected function addSetQueryKey(&$script) { $script .= " @@ -76,6 +94,11 @@ public function setQueryKey(\$key) "; } + /** + * @param string $script + * + * @return void + */ protected function addGetQueryKey(&$script) { $script .= " @@ -86,6 +109,11 @@ public function getQueryKey() "; } + /** + * @param string $script + * + * @return void + */ protected function addCacheContains(&$script) { $script .= " @@ -114,6 +142,11 @@ public function cacheContains(\$key) "; } + /** + * @param string $script + * + * @return void + */ protected function addCacheStore(&$script) { $script .= " @@ -139,6 +172,11 @@ public function cacheStore(\$key, \$value, \$lifetime = " .$this->getParameter(' "; } + /** + * @param string $script + * + * @return void + */ protected function addCacheFetch(&$script) { $script .= " @@ -166,6 +204,11 @@ public function cacheFetch(\$key) "; } + /** + * @param string $script + * + * @return void + */ protected function addDoSelect(&$script) { $script .= " @@ -197,7 +240,7 @@ public function doSelect(ConnectionInterface \$con = null) Propel::log(\$e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', \$sql), 0, \$e); } - + if (\$key && !\$this->cacheContains(\$key)) { \$this->cacheStore(\$key, \$sql); } @@ -207,6 +250,11 @@ public function doSelect(ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addDoCount(&$script) { $script .= " @@ -260,7 +308,7 @@ public function doCount(ConnectionInterface \$con = null) Propel::log(\$e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute COUNT statement [%s]', \$sql), 0, \$e); } - + if (\$key && !\$this->cacheContains(\$key)) { \$this->cacheStore(\$key, \$sql); } diff --git a/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php b/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php index d9510389ba..d7ca7465d7 100644 --- a/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php +++ b/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php @@ -24,7 +24,7 @@ class SluggableBehavior extends Behavior { /** - * @var ObjectBuilder + * @var \Propel\Generator\Builder\Om\AbstractOMBuilder */ private $builder; @@ -103,6 +103,8 @@ protected function getColumnSetter() /** * Add code in ObjectBuilder::preSave * + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string The code to put at the hook */ public function preSave($builder) @@ -126,6 +128,11 @@ public function preSave($builder) return $script; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function objectMethods($builder) { $this->builder = $builder; @@ -143,6 +150,11 @@ public function objectMethods($builder) return $script; } + /** + * @param string $script + * + * @return void + */ protected function addSlugSetter(&$script) { $script .= " @@ -159,6 +171,11 @@ public function setSlug(\$v) "; } + /** + * @param string $script + * + * @return void + */ protected function addSlugGetter(&$script) { $script .= " @@ -174,6 +191,11 @@ public function getSlug() "; } + /** + * @param string $script + * + * @return void + */ protected function addCreateSlug(&$script) { $script .= " @@ -193,6 +215,11 @@ protected function createSlug() "; } + /** + * @param string $script + * + * @return void + */ protected function addCreateRawSlug(&$script) { $pattern = $this->getParameter('slug_pattern'); @@ -213,10 +240,13 @@ protected function createRawSlug() $script .= " } "; - - return $script; } + /** + * @param string $script + * + * @return void + */ public function addCleanupSlugPart(&$script) { $script .= " @@ -260,6 +290,11 @@ protected static function cleanupSlugPart(\$slug, \$replacement = '" . $this->ge "; } + /** + * @param string $script + * + * @return void + */ public function addLimitSlugSize(&$script) { $size = $this->getColumnForParameter('slug_column')->getSize(); @@ -284,6 +319,11 @@ protected static function limitSlugSize(\$slug, \$incrementReservedSpace = 3) "; } + /** + * @param string $script + * + * @return void + */ public function addMakeSlugUnique(&$script) { $script .= " @@ -373,12 +413,17 @@ protected function makeSlugUnique(\$slug, \$separator = '" . $this->getParameter "; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function queryMethods($builder) { $this->builder = $builder; $script = ''; - if ($this->getParameter('slug_column') != 'slug') { + if ($this->getParameter('slug_column') !== 'slug') { $this->addFilterBySlug($script); $this->addFindOneBySlug($script); } @@ -386,6 +431,11 @@ public function queryMethods($builder) return $script; } + /** + * @param string $script + * + * @return void + */ protected function addFilterBySlug(&$script) { $script .= " @@ -403,6 +453,11 @@ public function filterBySlug(\$slug) "; } + /** + * @param string $script + * + * @return void + */ protected function addFindOneBySlug(&$script) { $script .= " diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php b/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php index a302444e2c..1f4f51d2ef 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php @@ -64,6 +64,9 @@ public function modifyTable() } } + /** + * @return \Propel\Generator\Behavior\Sortable\SortableBehavior|\Propel\Generator\Behavior\Sortable\SortableBehaviorObjectBuilderModifier + */ public function getObjectBuilderModifier() { if (null === $this->objectBuilderModifier) { @@ -73,6 +76,9 @@ public function getObjectBuilderModifier() return $this->objectBuilderModifier; } + /** + * @return \Propel\Generator\Behavior\Sortable\SortableBehavior|\Propel\Generator\Behavior\Sortable\SortableBehaviorQueryBuilderModifier + */ public function getQueryBuilderModifier() { if (null === $this->queryBuilderModifier) { @@ -82,6 +88,9 @@ public function getQueryBuilderModifier() return $this->queryBuilderModifier; } + /** + * @return \Propel\Generator\Behavior\Sortable\SortableBehavior|\Propel\Generator\Behavior\Sortable\SortableBehaviorTableMapBuilderModifier + */ public function getTableMapBuilderModifier() { if (null === $this->tableMapBuilderModifier) { @@ -91,6 +100,9 @@ public function getTableMapBuilderModifier() return $this->tableMapBuilderModifier; } + /** + * @return bool + */ public function useScope() { return 'true' === $this->getParameter('use_scope'); @@ -104,7 +116,6 @@ public function useScope() */ public function generateScopePhp() { - $methodSignature = ''; $paramsDoc = ''; $buildScope = ''; diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php index 16fc1d11ce..dd6bb20046 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php @@ -81,6 +81,11 @@ protected function getColumnPhpName($name) return $this->behavior->getColumnForParameter($name)->getPhpName(); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return void + */ protected function setBuilder(AbstractOMBuilder $builder) { $this->builder = $builder; @@ -114,11 +119,21 @@ protected function getColumnSetter($columnName = 'rank_column') return 'set' . $this->behavior->getColumnForParameter($columnName)->getPhpName(); } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function preSave($builder) { return "\$this->processSortableQueries(\$con);"; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function preInsert($builder) { $useScope = $this->behavior->useScope(); @@ -130,6 +145,11 @@ public function preInsert($builder) "; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function preUpdate($builder) { if ($this->behavior->useScope()) { @@ -152,8 +172,15 @@ public function preUpdate($builder) return $script; } + + return ''; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function preDelete($builder) { $useScope = $this->behavior->useScope(); @@ -165,6 +192,11 @@ public function preDelete($builder) "; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function objectAttributes($builder) { $script = " @@ -187,6 +219,11 @@ public function objectAttributes($builder) return $script; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function objectMethods($builder) { $this->setBuilder($builder); @@ -217,6 +254,12 @@ public function objectMethods($builder) return $script; } + /** + * @param string $script + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return void + */ public function objectFilter(&$script, $builder) { if ($this->behavior->useScope()) { @@ -250,6 +293,8 @@ public function objectFilter(&$script, $builder) /** * Get the wraps for getter/setter, if the rank column has not the default name * + * @param string $script + * * @return void */ protected function addRankAccessors(&$script) @@ -281,6 +326,8 @@ public function setRank(\$v) /** * Get the wraps for getter/setter, if the scope column has not the default name * + * @param string $script + * * @return void */ protected function addScopeAccessors(&$script) diff --git a/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php b/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php index 035071d24d..069810b45b 100644 --- a/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php +++ b/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php @@ -27,12 +27,17 @@ class TimestampableBehavior extends Behavior 'disable_updated_at' => 'false', ]; - + /** + * @return bool + */ protected function withUpdatedAt() { return !$this->booleanValue($this->getParameter('disable_updated_at')); } + /** + * @return bool + */ protected function withCreatedAt() { return !$this->booleanValue($this->getParameter('disable_created_at')); @@ -70,6 +75,12 @@ protected function getColumnSetter($column) return 'set' . $this->getColumnForParameter($column)->getPhpName(); } + /** + * @param string $columnName + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return mixed + */ protected function getColumnConstant($columnName, $builder) { return $builder->getColumnConstant($this->getColumnForParameter($columnName)); @@ -78,6 +89,8 @@ protected function getColumnConstant($columnName, $builder) /** * Add code in ObjectBuilder::preUpdate * + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string The code to put at the hook */ public function preUpdate($builder) @@ -98,6 +111,8 @@ public function preUpdate($builder) /** * Add code in ObjectBuilder::preInsert * + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * * @return string The code to put at the hook */ public function preInsert($builder) @@ -130,6 +145,11 @@ public function preInsert($builder) return $script; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function objectMethods($builder) { if (!$this->withUpdatedAt()) { @@ -151,6 +171,11 @@ public function keepUpdateDateUnchanged() "; } + /** + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * + * @return string + */ public function queryMethods($builder) { $queryClassName = $builder->getQueryClassName(); diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php index 1f37600dc6..30f1ad140f 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php @@ -33,6 +33,9 @@ class VersionableBehavior extends Behavior 'indices' => 'false' ]; + /** + * @var \Propel\Generator\Model\Table + */ protected $versionTable; protected $objectBuilderModifier; @@ -57,6 +60,9 @@ public function modifyDatabase() } } + /** + * @return void + */ public function modifyTable() { $this->addVersionColumn(); @@ -65,6 +71,9 @@ public function modifyTable() $this->addForeignKeyVersionColumns(); } + /** + * @return void + */ protected function addVersionColumn() { $table = $this->getTable(); @@ -78,6 +87,9 @@ protected function addVersionColumn() } } + /** + * @return void + */ protected function addLogColumns() { $table = $this->getTable(); @@ -103,6 +115,9 @@ protected function addLogColumns() } } + /** + * @return void + */ protected function addVersionTable() { $table = $this->getTable(); @@ -164,6 +179,9 @@ protected function addVersionTable() } } + /** + * @return void + */ public function addForeignKeyVersionColumns() { $versionTable = $this->versionTable; @@ -198,16 +216,25 @@ public function addForeignKeyVersionColumns() } } + /** + * @return \Propel\Generator\Model\Table + */ public function getVersionTable() { return $this->versionTable; } + /** + * @return string + */ public function getVersionTablePhpName() { return $this->getTable()->getPhpName() . 'Version'; } + /** + * @return ForeignKey[] + */ public function getVersionableFks() { $versionableFKs = []; @@ -222,6 +249,9 @@ public function getVersionableFks() return $versionableFKs; } + /** + * @return ForeignKey[] + */ public function getVersionableReferrers() { $versionableReferrers = []; @@ -236,6 +266,11 @@ public function getVersionableReferrers() return $versionableReferrers; } + /** + * @param \Propel\Generator\Model\ForeignKey $fk + * + * @return \Propel\Generator\Model\Column|null + */ public function getReferrerIdsColumn(ForeignKey $fk) { $fkTableName = $fk->getTable()->getName(); @@ -244,6 +279,11 @@ public function getReferrerIdsColumn(ForeignKey $fk) return $this->versionTable->getColumn($fkIdsColumnName); } + /** + * @param \Propel\Generator\Model\ForeignKey $fk + * + * @return \Propel\Generator\Model\Column|null + */ public function getReferrerVersionsColumn(ForeignKey $fk) { $fkTableName = $fk->getTable()->getName(); @@ -252,6 +292,9 @@ public function getReferrerVersionsColumn(ForeignKey $fk) return $this->versionTable->getColumn($fkIdsColumnName); } + /** + * @return \Propel\Generator\Behavior\Versionable\VersionableBehavior|\Propel\Generator\Behavior\Versionable\VersionableBehaviorObjectBuilderModifier + */ public function getObjectBuilderModifier() { if (null === $this->objectBuilderModifier) { @@ -261,6 +304,9 @@ public function getObjectBuilderModifier() return $this->objectBuilderModifier; } + /** + * @return \Propel\Generator\Behavior\Versionable\VersionableBehavior|\Propel\Generator\Behavior\Versionable\VersionableBehaviorQueryBuilderModifier + */ public function getQueryBuilderModifier() { if (null === $this->queryBuilderModifier) { diff --git a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php index 837f150c2e..f6d0cd79fb 100644 --- a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php @@ -431,6 +431,9 @@ public function declareClassFromBuilder(self $builder, $aliasPrefix = false) return $this->declareClassNamespacePrefix($builder->getUnqualifiedClassName(), $builder->getNamespace(), $aliasPrefix); } + /** + * @return void + */ public function declareClasses() { $args = func_get_args(); @@ -844,7 +847,7 @@ protected static function getRelatedBySuffix(ForeignKey $fk) $relCol = ''; foreach ($fk->getMapping() as $mapping) { - list($localColumn, $foreignValueOrColumn) = $mapping; + [$localColumn, $foreignValueOrColumn] = $mapping; $localColumnName = $localColumn->getPhpName(); $localTable = $fk->getTable(); if (!$localColumn) { @@ -895,7 +898,7 @@ protected static function getRefRelatedBySuffix(ForeignKey $fk) { $relCol = ''; foreach ($fk->getMapping() as $mapping) { - list($localColumn, $foreignValueOrColumn) = $mapping; + [$localColumn, $foreignValueOrColumn] = $mapping; $localColumnName = $localColumn->getPhpName(); $localTable = $fk->getTable(); if (!$localColumn) { @@ -975,6 +978,7 @@ public function applyBehaviorModifierBase($hookName, $modifier, &$script, $tab = * Checks whether any registered behavior content creator on that table exists a contentName * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassName" * @param string $modifier The name of the modifier object providing the method in the behavior + * @return mixed */ public function getBehaviorContentBase($contentName, $modifier) { diff --git a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php index ea26bc690c..580ac65e8b 100644 --- a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php @@ -158,6 +158,9 @@ protected function isAddGenericAccessors() return (!$table->isAlias() && $this->getBuildProperty('generator.objectModel.addGenericAccessors')); } + /** + * @return bool + */ protected function hasDefaultValues() { foreach ($this->getTable()->getColumns() as $col) { @@ -171,7 +174,10 @@ protected function hasDefaultValues() /** * Checks whether any registered behavior on that table has a modifier for a hook - * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" + * + * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" + * @param string $modifier + * * @return boolean */ public function hasBehaviorModifier($hookName, $modifier = '') @@ -184,6 +190,7 @@ public function hasBehaviorModifier($hookName, $modifier = '') * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string $script The script will be modified in this method. * @param string $tab + * @return void */ public function applyBehaviorModifier($hookName, &$script, $tab = " ") { @@ -193,6 +200,7 @@ public function applyBehaviorModifier($hookName, &$script, $tab = " ") /** * Checks whether any registered behavior content creator on that table exists a contentName * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassName" + * @return mixed */ public function getBehaviorContent($contentName) { diff --git a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php index 5f03f4b025..010b56a8bb 100644 --- a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php @@ -157,6 +157,7 @@ class ".$this->getUnqualifiedClassName()." extends ".$this->getParentClassName() * * @param string $script * @see ObjectBuilder::addClassBody() + * @return void */ protected function addClassBody(&$script) { diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index 8044425faf..860bc66378 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -621,6 +621,7 @@ protected function addConstructorComment(&$script) * Adds the function declaration for the constructor. * * @param string $script + * @return void */ protected function addConstructorOpen(&$script) { @@ -633,6 +634,7 @@ public function __construct() * Adds the function body for the constructor. * * @param string $script + * @return void */ protected function addConstructorBody(&$script) { @@ -644,6 +646,7 @@ protected function addConstructorBody(&$script) * Adds the function close for the constructor. * * @param string $script + * @return void */ protected function addConstructorClose(&$script) { @@ -656,6 +659,7 @@ protected function addConstructorClose(&$script) * Adds the base object functions. * * @param string $script + * @return void */ protected function addBaseObjectMethods(&$script) { @@ -666,6 +670,7 @@ protected function addBaseObjectMethods(&$script) * Adds the base object hook functions. * * @param string $script + * @return void */ protected function addHookMethods(&$script) { @@ -976,6 +981,12 @@ protected function addObjectAccessorBody(&$script, Column $column) return \$this->$cloUnserialized;"; } + /** + * @param string $script + * @param \Propel\Generator\Model\Column $column + * + * @return void + */ protected function addJsonAccessor(&$script, Column $column) { $this->addJsonAccessorComment($script, $column); @@ -1030,6 +1041,12 @@ public function addJsonAccessorOpen(&$script, Column $column) {"; } + /** + * @param string $script + * @param \Propel\Generator\Model\Column $column + * + * @return void + */ protected function addJsonAccessorBody(&$script, Column $column) { $clo = $column->getLowercasedName(); @@ -1847,6 +1864,12 @@ protected function addTemporalMutator(&$script, Column $col) $this->addMutatorClose($script, $col); } + /** + * @param string $script + * @param \Propel\Generator\Model\Column $col + * + * @return void + */ public function addTemporalMutatorComment(&$script, Column $col) { $clo = $col->getLowercasedName(); @@ -2163,6 +2186,12 @@ protected function addBooleanMutator(&$script, Column $col) $this->addMutatorClose($script, $col); } + /** + * @param string $script + * @param \Propel\Generator\Model\Column $col + * + * @return void + */ public function addBooleanMutatorComment(&$script, Column $col) { $clo = $col->getLowercasedName(); @@ -2914,6 +2943,11 @@ protected function addGetByPositionClose(&$script) "; } + /** + * @param string $script + * + * @return void + */ protected function addSetByName(&$script) { $defaultKeyType = $this->getDefaultKeyType(); @@ -2938,6 +2972,11 @@ public function setByName(\$name, \$value, \$type = TableMap::$defaultKeyType) "; } + /** + * @param string $script + * + * @return void + */ protected function addSetByPosition(&$script) { $table = $this->getTable(); @@ -3000,6 +3039,11 @@ public function setByPosition(\$pos, \$value) "; } + /** + * @param string $script + * + * @return void + */ protected function addFromArray(&$script) { $defaultKeyType = $this->getDefaultKeyType(); @@ -3038,6 +3082,11 @@ public function fromArray(\$arr, \$keyType = TableMap::$defaultKeyType) "; } + /** + * @param string $script + * + * @return void + */ protected function addImportFrom(&$script) { $defaultKeyType = $this->getDefaultKeyType(); @@ -3281,6 +3330,11 @@ protected function addManipulationMethods(&$script) $script .= $this->addDoUpdate(); } + /** + * @param string $script + * + * @return void + */ protected function addHashCode(&$script) { $script .= " @@ -3657,7 +3711,7 @@ public function set".$this->getFKPhpNameAffix($fk, false)."($className \$v = nul {"; foreach ($fk->getMapping() as $map) { - list($column, $rightValueOrColumn) = $map; + [$column, $rightValueOrColumn] = $map; if ($rightValueOrColumn instanceof Column) { $script .= " @@ -3743,7 +3797,7 @@ protected function addFKAccessor(&$script, ForeignKey $fk) $findPk = $fk->isForeignPrimaryKey(); foreach ($fk->getMapping() as $mapping) { - list($column, $rightValueOrColumn) = $mapping; + [$column, $rightValueOrColumn] = $mapping; $cptype = $column->getPhpType(); $clo = $column->getLowercasedName(); @@ -4440,10 +4494,16 @@ public function set".$this->getRefFKPhpNameAffix($refFK, false)."($className \$v "; } + /** + * @param string $script + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * + * @return void + */ protected function addCrossFKAttributes(&$script, CrossForeignKeys $crossFKs) { if (1 < count($crossFKs->getCrossForeignKeys()) || $crossFKs->getUnclassifiedPrimaryKeys()) { - list($names) = $this->getCrossFKInformation($crossFKs); + [$names] = $this->getCrossFKInformation($crossFKs); $script .= " /** * @var ObjectCombinationCollection Cross CombinationCollection to store aggregation of $names combinations. @@ -4475,11 +4535,17 @@ protected function addCrossFKAttributes(&$script, CrossForeignKeys $crossFKs) } } + /** + * @param string $script + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * + * @return void + */ protected function addCrossScheduledForDeletionAttribute(&$script, CrossForeignKeys $crossFKs) { $name = $this->getCrossScheduledForDeletionVarName($crossFKs); if (1 < count($crossFKs->getCrossForeignKeys()) || $crossFKs->getUnclassifiedPrimaryKeys()) { - list($names) = $this->getCrossFKInformation($crossFKs); + [$names] = $this->getCrossFKInformation($crossFKs); $script .= " /** * @var ObjectCombinationCollection Cross CombinationCollection to store aggregation of $names combinations. @@ -4502,6 +4568,11 @@ protected function addCrossScheduledForDeletionAttribute(&$script, CrossForeignK } } + /** + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * + * @return string + */ protected function getCrossScheduledForDeletionVarName(CrossForeignKeys $crossFKs) { if (1 < count($crossFKs->getCrossForeignKeys()) || $crossFKs->getUnclassifiedPrimaryKeys()) { @@ -4513,6 +4584,12 @@ protected function getCrossScheduledForDeletionVarName(CrossForeignKeys $crossFK } } + /** + * @param string $script + * @param \Propel\Generator\Model\ForeignKey $crossFK + * + * @return void + */ protected function addCrossFkScheduledForDeletionAttribute(&$script, ForeignKey $crossFK) { $className = $this->getClassNameFromTable($crossFK->getForeignTable()); @@ -4527,6 +4604,12 @@ protected function addCrossFkScheduledForDeletionAttribute(&$script, ForeignKey "; } + /** + * @param string $script + * @param \Propel\Generator\Model\ForeignKey $refFK + * + * @return void + */ protected function addRefFkScheduledForDeletionAttribute(&$script, ForeignKey $refFK) { $className = $this->getClassNameFromTable($refFK->getTable()); @@ -4700,6 +4783,12 @@ protected function addCrossFkScheduledForDeletion(&$script, CrossForeignKeys $cr } + /** + * @param string $script + * @param \Propel\Generator\Model\ForeignKey $refFK + * + * @return void + */ protected function addRefFkScheduledForDeletion(&$script, ForeignKey $refFK) { $relatedName = $this->getRefFKPhpNameAffix($refFK, $plural = true); @@ -4731,6 +4820,11 @@ protected function addRefFkScheduledForDeletion(&$script, ForeignKey $refFK) "; } + /** + * @param string $script + * + * @return void + */ protected function addCrossFKMethods(&$script) { foreach ($this->getTable()->getCrossFks() as $crossFKs) { @@ -4927,6 +5021,12 @@ public function is{$relCol}Loaded() } } + /** + * @param string $script + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * + * @return void + */ protected function addCrossFKCreateQuery(&$script, CrossForeignKeys $crossFKs) { if (1 <= count($crossFKs->getCrossForeignKeys()) && !$crossFKs->getUnclassifiedPrimaryKeys()) { @@ -5217,7 +5317,7 @@ protected function addCrossFKSet(&$script, CrossForeignKeys $crossFKs) $crossRefTableName = $crossFKs->getMiddleTable()->getName(); if ($multi) { - list($relatedObjectClassName) = $this->getCrossFKInformation($crossFKs); + [$relatedObjectClassName] = $this->getCrossFKInformation($crossFKs); $collName = 'combination' . ucfirst($this->getCrossFKsVarName($crossFKs)); } else { $crossFK = $crossFKs->getCrossForeignKeys()[0]; @@ -5292,7 +5392,7 @@ protected function addCrossFKCount(&$script, CrossForeignKeys $crossFKs) $crossRefTableName = $crossFKs->getMiddleTable()->getName(); if ($multi) { - list($relatedObjectClassName) = $this->getCrossFKInformation($crossFKs); + [$relatedObjectClassName] = $this->getCrossFKInformation($crossFKs); $collName = 'combination' . ucfirst($this->getCrossFKsVarName($crossFKs)); $relatedQueryClassName = $this->getClassNameFromBuilder($this->getNewStubQueryBuilder($crossFKs->getMiddleTable())); } else { @@ -5403,7 +5503,7 @@ protected function addCrossFKAdd(&$script, CrossForeignKeys $crossFKs) $tblFK = $refFK->getTable(); $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, false); $crossObjectClassName = $this->getClassNameFromTable($crossFK->getForeignTable()); - list ($signature, $shortSignature, $normalizedShortSignature, $phpDoc) = $this->getCrossFKAddMethodInformation($crossFKs, $crossFK); + [$signature, $shortSignature, $normalizedShortSignature, $phpDoc] = $this->getCrossFKAddMethodInformation($crossFKs, $crossFK); $script .= " /** @@ -5439,7 +5539,7 @@ public function add{$relatedObjectClassName}($signature) */ protected function getCrossFKGetterSignature(CrossForeignKeys $crossFKs, $excludeSignatureItem) { - list (, $getSignature) = $this->getCrossFKAddMethodInformation($crossFKs); + [, $getSignature] = $this->getCrossFKAddMethodInformation($crossFKs); $getSignature = explode(', ', $getSignature); if (false !== ($pos = array_search($excludeSignatureItem, $getSignature))) { @@ -5464,7 +5564,7 @@ protected function addCrossFKDoAdd(&$script, CrossForeignKeys $crossFKs) $tblFK = $crossFKs->getIncomingForeignKey()->getTable(); $foreignObjectName = '$' . $tblFK->getCamelCaseName(); - list ($signature, $shortSignature, $normalizedShortSignature, $phpDoc) = $this->getCrossFKAddMethodInformation($crossFKs); + [$signature, $shortSignature, $normalizedShortSignature, $phpDoc] = $this->getCrossFKAddMethodInformation($crossFKs); $script .= " /** @@ -5591,7 +5691,7 @@ protected function addCrossFKRemove(&$script, CrossForeignKeys $crossFKs) $M2MScheduledForDeletion = $this->getCrossScheduledForDeletionVarName($crossFKs); $relatedObjectClassName = $this->getCrossFKsPhpNameAffix($crossFKs, $plural = false); - list($signature, $shortSignature, $normalizedShortSignature, $phpDoc) = $this->getCrossFKAddMethodInformation($crossFKs); + [$signature, $shortSignature, $normalizedShortSignature, $phpDoc] = $this->getCrossFKAddMethodInformation($crossFKs); $names = str_replace('$', '', $normalizedShortSignature); $className = $this->getClassNameFromTable($crossFKs->getIncomingForeignKey()->getTable()); @@ -5858,12 +5958,18 @@ protected function doInsert(ConnectionInterface \$con) return $script; } + /** + * @return string + */ protected function addDoInsertBodyStandard() { return " \$pk = \$criteria->doInsert(\$con);"; } + /** + * @return string + */ protected function addDoInsertBodyWithIdMethod() { $table = $this->getTable(); @@ -6665,6 +6771,11 @@ protected function addMagicCall(&$script) ]); } + /** + * @param \Propel\Generator\Model\Column $column + * + * @return string + */ protected function getDateTimeClass(Column $column) { if (PropelTypes::isPhpObjectType($column->getPhpType())) { diff --git a/src/Propel/Generator/Builder/Om/QueryBuilder.php b/src/Propel/Generator/Builder/Om/QueryBuilder.php index 7d0b41af79..8752007cbc 100644 --- a/src/Propel/Generator/Builder/Om/QueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryBuilder.php @@ -307,6 +307,9 @@ protected function addEntityNotFoundExceptionClass(&$script) $script .= "protected \$entityNotFoundExceptionClass = '" . addslashes($this->getEntityNotFoundExceptionClass()) . "';\n"; } + /** + * @return string|null + */ private function getEntityNotFoundExceptionClass() { return $this->getBuildProperty('generator.objectModel.entityNotFoundExceptionClass'); @@ -410,7 +413,8 @@ protected function addConstructorComment(&$script) /** * Adds the function declaration for the constructor * @param string $script The script will be modified in this method. - **/ + * @return void + */ protected function addConstructorOpen(&$script) { $table = $this->getTable(); @@ -505,7 +509,10 @@ protected function addFactoryBody(&$script) /** * Adds the function close for the factory + * * @param string $script The script will be modified in this method. + * + * @return void */ protected function addFactoryClose(&$script) { @@ -514,6 +521,11 @@ protected function addFactoryClose(&$script) "; } + /** + * @param string $script + * + * @return void + */ protected function addFindPk(&$script) { $class = $this->getObjectClassName(); @@ -560,7 +572,7 @@ public function findPk(\$key, ConnectionInterface \$con = null) } "; - return $script; + return; } $script .= " @@ -602,13 +614,18 @@ public function findPk(\$key, ConnectionInterface \$con = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addFindPkSimple(&$script) { $table = $this->getTable(); // this method is not needed if the table has no primary key if (!$table->hasPrimaryKey()) { - return ''; + return; } $platform = $this->getPlatform(); @@ -701,6 +718,7 @@ protected function findPkSimple(\$key, ConnectionInterface \$con) /** * Adds the findPk method for this object. * @param string $script The script will be modified in this method. + * @return void */ protected function addFindPkComplex(&$script) { @@ -709,7 +727,7 @@ protected function addFindPkComplex(&$script) // this method is not needed if the table has no primary key if (!$table->hasPrimaryKey()) { - return ''; + return; } $this->declareClasses('\Propel\Runtime\Connection\ConnectionInterface'); @@ -738,6 +756,7 @@ protected function findPkComplex(\$key, ConnectionInterface \$con) /** * Adds the findPks method for this object. * @param string $script The script will be modified in this method. + * @return void */ protected function addFindPks(&$script) { @@ -776,7 +795,7 @@ public function findPks(\$keys, ConnectionInterface \$con = null) } "; - return $script; + return; } $script .= " @@ -797,6 +816,7 @@ public function findPks(\$keys, ConnectionInterface \$con = null) /** * Adds the filterByPrimaryKey method for this object. * @param string $script The script will be modified in this method. + * @return void */ protected function addFilterByPrimaryKey(&$script) { @@ -819,7 +839,7 @@ public function filterByPrimaryKey(\$key) } "; - return $script; + return; } $pks = $table->getPrimaryKey(); @@ -851,6 +871,7 @@ public function filterByPrimaryKey(\$key) /** * Adds the filterByPrimaryKey method for this object. * @param string $script The script will be modified in this method. + * @return void */ protected function addFilterByPrimaryKeys(&$script) { @@ -874,7 +895,7 @@ public function filterByPrimaryKeys(\$keys) } "; - return $script; + return; } $pks = $table->getPrimaryKey(); @@ -1252,7 +1273,7 @@ public function filterBy$relationName($objectName, \$comparison = null) return \$this"; foreach ($fk->getMapping() as $mapping) { - list($localColumn, $rightValueOrColumn) = $mapping; + [$localColumn, $rightValueOrColumn] = $mapping; if ($rightValueOrColumn instanceof Column) { $script .= " ->addUsingAlias(" . $this->getColumnConstant($localColumn) . ", " . $objectName . "->get" . $rightValueOrColumn->getPhpName() . "(), \$comparison)"; @@ -1326,7 +1347,7 @@ public function filterBy$relationName($objectName, \$comparison = null) return \$this"; foreach ($fk->getInverseMapping() as $mapping) { /** @var Column $foreignColumn */ - list($localValueOrColumn, $foreignColumn) = $mapping; + [$localValueOrColumn, $foreignColumn] = $mapping; $rightValue = "{$objectName}->get" . $foreignColumn->getPhpName() . "()"; if ($localValueOrColumn instanceof Column) { @@ -1492,6 +1513,12 @@ public function use" . $relationName . "Query(\$relationAlias = null, \$joinType "; } + /** + * @param string $script + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * + * @return void + */ protected function addFilterByCrossFK(&$script, CrossForeignKeys $crossFKs) { $relationName = $this->getRefFKPhpNameAffix($crossFKs->getIncomingForeignKey(), $plural = false); @@ -1528,6 +1555,7 @@ public function filterBy{$relName}($objectName, \$comparison = Criteria::EQUAL) /** * Adds the prune method for this object. * @param string $script The script will be modified in this method. + * @return void */ protected function addPrune(&$script) { @@ -1583,6 +1611,7 @@ public function prune($objectName = null) /** * Adds the basePreSelect hook for this object. * @param string $script The script will be modified in this method. + * @return void */ protected function addBasePreSelect(&$script) { @@ -1608,6 +1637,7 @@ protected function basePreSelect(ConnectionInterface \$con) /** * Adds the basePreDelete hook for this object. * @param string $script The script will be modified in this method. + * @return void */ protected function addBasePreDelete(&$script) { diff --git a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php index b2d317dab2..2a7c7e6659 100644 --- a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php @@ -215,6 +215,11 @@ public static function create(\$modelAlias = null, Criteria \$criteria = null) "; } + /** + * @param string $script + * + * @return void + */ protected function addPreSelect(&$script) { $child = $this->getChild(); @@ -230,6 +235,11 @@ public function preSelect(ConnectionInterface \$con) "; } + /** + * @param string $script + * + * @return void + */ protected function addPreUpdate(&$script) { $child = $this->getChild(); @@ -245,6 +255,11 @@ public function preUpdate(&\$values, ConnectionInterface \$con, \$forceIndividua "; } + /** + * @param string $script + * + * @return void + */ protected function addPreDelete(&$script) { $child = $this->getChild(); @@ -260,6 +275,9 @@ public function preDelete(ConnectionInterface \$con) "; } + /** + * @return string + */ protected function getClassKeyCondition() { $child = $this->getChild(); @@ -268,6 +286,11 @@ protected function getClassKeyCondition() return "\$this->addUsingAlias(" . $col->getFQConstantName() . ", " . $this->getTableMapClassName()."::CLASSKEY_".$child->getConstantSuffix().");"; } + /** + * @param string $script + * + * @return void + */ protected function addDoDeleteAll(&$script) { $child = $this->getChild(); @@ -294,6 +317,7 @@ public function doDeleteAll(ConnectionInterface \$con = null) * Closes class. * * @param string $script + * @return void */ protected function addClassClose(&$script) { diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index 79847bffa1..80a74c8e48 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -31,6 +31,9 @@ public function getPackage() return parent::getPackage() . '.Map'; } + /** + * @return string + */ public function getNamespace() { if (!$namespace = parent::getNamespace()) { @@ -45,6 +48,9 @@ public function getNamespace() return $namespace .'Map'; } + /** + * @return string + */ public function getBaseTableMapClassName() { return "TableMap"; @@ -52,6 +58,7 @@ public function getBaseTableMapClassName() /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassName() @@ -61,7 +68,10 @@ public function getUnprefixedClassName() /** * Adds class phpdoc comment and opening of class. + * * @param string $script The script will be modified in this method. + * + * @return void */ protected function addClassOpen(&$script) { @@ -99,6 +109,8 @@ class ".$this->getUnqualifiedClassName()." extends TableMap * Specifies the methods that are added as part of the map builder class. * This can be overridden by subclasses that wish to add more methods. * @see ObjectBuilder::addClassBody() + * @param string $script + * @return void */ protected function addClassBody(&$script) { @@ -168,6 +180,7 @@ protected function addClassBody(&$script) /** * Adds the addSelectColumns(), doCount(), etc. methods. * @param string $script The script will be modified in this method. + * @return void */ protected function addSelectMethods(&$script) { @@ -351,6 +364,9 @@ protected function addAttributes(&$script) { } + /** + * @return string + */ protected function addFieldsAttributes() { $tableColumns = $this->getTable()->getColumns(); @@ -658,6 +674,9 @@ public function getInstancePoolKeySnippet($pkphp) return $script; } + /** + * @return string + */ public function addInstancePool() { // No need to override instancePool if the PK is not composite @@ -668,7 +687,7 @@ public function addInstancePool() $pks = $this->getTable()->getPrimaryKey(); if (!count($pks)) { - return; + return ''; } $add = []; @@ -696,6 +715,9 @@ public function addInstancePool() ]); } + /** + * @return string + */ public function addClearRelatedInstancePool() { $table = $this->getTable(); diff --git a/src/Propel/Generator/Builder/Util/SchemaReader.php b/src/Propel/Generator/Builder/Util/SchemaReader.php index 383d3bc0be..6e9c5cb01d 100644 --- a/src/Propel/Generator/Builder/Util/SchemaReader.php +++ b/src/Propel/Generator/Builder/Util/SchemaReader.php @@ -66,7 +66,14 @@ class SchemaReader /** @var VendorInfo */ private $currVendorObject; + /** + * @var bool + */ private $isForReferenceOnly; + + /** + * @var string|null + */ private $currentPackage; private $currentXmlFile; private $defaultPackage; @@ -83,8 +90,8 @@ class SchemaReader /** * Creates a new instance for the specified database type. * - * @param PlatformInterface $defaultPlatform The default database platform for the application. - * @param string $defaultPackage the default PHP package used for the om + * @param PlatformInterface|null $defaultPlatform The default database platform for the application. + * @param string|null $defaultPackage the default PHP package used for the om * @param string $encoding The database encoding. */ public function __construct(PlatformInterface $defaultPlatform = null, $defaultPackage = null, $encoding = 'iso-8859-1') @@ -99,6 +106,7 @@ public function __construct(PlatformInterface $defaultPlatform = null, $defaultP * Set the Schema generator configuration * * @param GeneratorConfigInterface $generatorConfig + * @return void */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) { @@ -158,6 +166,14 @@ public function parseString($xmlString, $xmlFile = null) return $this->schema; } + /** + * @param resource $parser + * @param string $name + * @param array $attributes + * + * @throws \Propel\Generator\Exception\SchemaException + * @return void + */ public function startElement($parser, $name, $attributes) { $parentTag = $this->peekCurrentSchemaTag(); @@ -326,7 +342,7 @@ public function startElement($parser, $name, $attributes) default: $this->_throwInvalidTagException($parser, $name); } - } elseif ($parentTag == 'behavior') { + } elseif ($parentTag === 'behavior') { switch ($name) { case 'parameter': @@ -354,6 +370,13 @@ public function startElement($parser, $name, $attributes) $this->pushCurrentSchemaTag($name); } + /** + * @param resource $parser + * @param string $tag_name + * + * @throws \Propel\Generator\Exception\SchemaException + * @return void + */ protected function _throwInvalidTagException($parser, $tag_name) { $location = ''; @@ -369,6 +392,12 @@ protected function _throwInvalidTagException($parser, $tag_name) throw new SchemaException(sprintf('Unexpected tag <%s> in %s', $tag_name, $location)); } + /** + * @param resource $parser + * @param string $name + * + * @return void + */ public function endElement($parser, $name) { if ('index' === $name) { @@ -384,6 +413,9 @@ public function endElement($parser, $name) $this->popCurrentSchemaTag(); } + /** + * @return string|false + */ protected function peekCurrentSchemaTag() { $keys = array_keys($this->schemasTagsStack); @@ -391,23 +423,40 @@ protected function peekCurrentSchemaTag() return end($this->schemasTagsStack[end($keys)]); } + /** + * @return string|false + */ protected function popCurrentSchemaTag() { $keys = array_keys($this->schemasTagsStack); - array_pop($this->schemasTagsStack[end($keys)]); + + return array_pop($this->schemasTagsStack[end($keys)]); } + /** + * @param string $tag + * + * @return void + */ protected function pushCurrentSchemaTag($tag) { $keys = array_keys($this->schemasTagsStack); $this->schemasTagsStack[end($keys)][] = $tag; } + /** + * @return bool + */ protected function isExternalSchema() { return count($this->schemasTagsStack) > 1; } + /** + * @param string $filePath + * + * @return bool + */ protected function isAlreadyParsed($filePath) { return isset($this->schemasTagsStack[$filePath]); diff --git a/src/Propel/Generator/Command/AbstractCommand.php b/src/Propel/Generator/Command/AbstractCommand.php index a9c4c9523d..9e9b820e6c 100644 --- a/src/Propel/Generator/Command/AbstractCommand.php +++ b/src/Propel/Generator/Command/AbstractCommand.php @@ -103,6 +103,12 @@ protected function getFilesystem() return $this->filesystem; } + /** + * @param string $directory + * + * @throws \RuntimeException + * @return void + */ protected function createDirectory($directory) { $filesystem = $this->getFilesystem(); @@ -156,7 +162,7 @@ protected function parseConnection($connection) */ protected function connectionToProperties($connection, $section = null) { - list($name, $dsn, $infos) = $this->parseConnection($connection); + [$name, $dsn, $infos] = $this->parseConnection($connection); $config['propel']['database']['connections'][$name]['classname'] = '\Propel\Runtime\Connection\ConnectionWrapper'; $config['propel']['database']['connections'][$name]['adapter'] = strtolower($infos['adapter']); $config['propel']['database']['connections'][$name]['dsn'] = $dsn; diff --git a/src/Propel/Generator/Command/Console/Input/ArrayInput.php b/src/Propel/Generator/Command/Console/Input/ArrayInput.php index 6c30824118..8a30bfa546 100644 --- a/src/Propel/Generator/Command/Console/Input/ArrayInput.php +++ b/src/Propel/Generator/Command/Console/Input/ArrayInput.php @@ -14,6 +14,7 @@ use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\InvalidOptionException; use Symfony\Component\Console\Input\Input; +use Symfony\Component\Console\Input\InputDefinition; /** * ArrayInput represents an input provided as an array. @@ -26,8 +27,15 @@ */ class ArrayInput extends Input { + /** + * @var array + */ private $parameters; + /** + * @param array $parameters + * @param \Symfony\Component\Console\Input\InputDefinition|null $definition + */ public function __construct(array $parameters, InputDefinition $definition = null) { $this->parameters = $parameters; diff --git a/src/Propel/Generator/Command/Helper/ConsoleHelper.php b/src/Propel/Generator/Command/Helper/ConsoleHelper.php index fa1b05130f..c89349f54d 100644 --- a/src/Propel/Generator/Command/Helper/ConsoleHelper.php +++ b/src/Propel/Generator/Command/Helper/ConsoleHelper.php @@ -11,6 +11,10 @@ class ConsoleHelper extends Symfony23DialogHelper implements ConsoleHelperInterf protected $input; protected $output; + /** + * @param \Symfony\Component\Console\Input\InputInterface $input + * @param \Symfony\Component\Console\Output\OutputInterface $output + */ public function __construct(InputInterface $input, OutputInterface $output) { $this->input = $input; diff --git a/src/Propel/Generator/Command/Helper/ConsoleHelper3.php b/src/Propel/Generator/Command/Helper/ConsoleHelper3.php index ea6aed14ea..a17e4133c8 100644 --- a/src/Propel/Generator/Command/Helper/ConsoleHelper3.php +++ b/src/Propel/Generator/Command/Helper/ConsoleHelper3.php @@ -18,6 +18,10 @@ class ConsoleHelper3 extends QuestionHelper implements ConsoleHelperInterface /** @var OutputInterface $output */ protected $output; + /** + * @param \Symfony\Component\Console\Input\InputInterface $input + * @param \Symfony\Component\Console\Output\OutputInterface $output + */ public function __construct(InputInterface $input, OutputInterface $output) { $this->input = $input; diff --git a/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php b/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php index 8108aeee99..7939cd2a6e 100644 --- a/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php +++ b/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php @@ -7,6 +7,10 @@ interface ConsoleHelperInterface { + /** + * @param \Symfony\Component\Console\Input\InputInterface $input + * @param \Symfony\Component\Console\Output\OutputInterface $output + */ public function __construct(InputInterface $input, OutputInterface $output); /** diff --git a/src/Propel/Generator/Command/InitCommand.php b/src/Propel/Generator/Command/InitCommand.php index dfd37fe2c3..517433ba23 100644 --- a/src/Propel/Generator/Command/InitCommand.php +++ b/src/Propel/Generator/Command/InitCommand.php @@ -40,6 +40,9 @@ public function __construct($name = null) $this->defaultPhpDir = $this->detectDefaultPhpDir(); } + /** + * @return void + */ protected function configure() { parent::configure(); @@ -50,6 +53,12 @@ protected function configure() ; } + /** + * @param \Symfony\Component\Console\Input\InputInterface $input + * @param \Symfony\Component\Console\Output\OutputInterface $output + * + * @return int + */ protected function execute(InputInterface $input, OutputInterface $output): int { $consoleHelper = $this->createConsoleHelper($input, $output); @@ -161,6 +170,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int return static::CODE_SUCCESS; } + /** + * @return string + */ private function detectDefaultPhpDir() { if (file_exists(getcwd() . '/src/')) { @@ -177,6 +189,11 @@ private function detectDefaultPhpDir() return getcwd(); } + /** + * @param \Propel\Generator\Command\Helper\ConsoleHelperInterface $consoleHelper + * + * @return string + */ private function initMysql(ConsoleHelperInterface $consoleHelper) { $host = $consoleHelper->askQuestion('Please enter your database host', 'localhost'); @@ -186,6 +203,11 @@ private function initMysql(ConsoleHelperInterface $consoleHelper) return sprintf('mysql:host=%s;port=%s;dbname=%s', $host, $port, $database); } + /** + * @param \Propel\Generator\Command\Helper\ConsoleHelperInterface $consoleHelper + * + * @return string + */ private function initSqlite(ConsoleHelperInterface $consoleHelper) { $path = $consoleHelper->askQuestion('Where should the sqlite database be stored?', getcwd() . '/my.app.sq3'); @@ -193,6 +215,11 @@ private function initSqlite(ConsoleHelperInterface $consoleHelper) return sprintf('sqlite:%s', $path); } + /** + * @param \Propel\Generator\Command\Helper\ConsoleHelperInterface $consoleHelper + * + * @return string + */ private function initPgsql(ConsoleHelperInterface $consoleHelper) { $host = $consoleHelper->askQuestion('Please enter your database host (without port)', 'localhost'); @@ -202,6 +229,12 @@ private function initPgsql(ConsoleHelperInterface $consoleHelper) return sprintf('pgsql:host=%s;port=%s;dbname=%s', $host, $port, $database); } + /** + * @param \Propel\Generator\Command\Helper\ConsoleHelperInterface $consoleHelper + * @param string $rdbms + * + * @return mixed + */ private function initDsn(ConsoleHelperInterface $consoleHelper, $rdbms) { switch ($rdbms) { @@ -221,6 +254,12 @@ private function initDsn(ConsoleHelperInterface $consoleHelper, $rdbms) return $consoleHelper->askQuestion(sprintf('Please enter the dsn (see %s) for your database connection', $help)); } + /** + * @param \Symfony\Component\Console\Output\OutputInterface $output + * @param array $options + * + * @return void + */ private function generateProject(OutputInterface $output, array $options) { $schema = new PropelTemplate(); @@ -243,6 +282,9 @@ private function generateProject(OutputInterface $output, array $options) $this->buildSqlAndModelsAndConvertConfig(); } + /** + * @return void + */ private function buildSqlAndModelsAndConvertConfig() { $this->getApplication()->setAutoExit(false); @@ -262,6 +304,13 @@ private function buildSqlAndModelsAndConvertConfig() $this->getApplication()->setAutoExit(true); } + /** + * @param \Symfony\Component\Console\Output\OutputInterface $output + * @param string $filename + * @param string $content + * + * @return void + */ private function writeFile(OutputInterface $output, $filename, $content) { $this->getFilesystem()->dumpFile($filename, $content); @@ -269,6 +318,12 @@ private function writeFile(OutputInterface $output, $filename, $content) $output->writeln(sprintf(' + %s', $filename)); } + /** + * @param \Propel\Generator\Command\Helper\ConsoleHelperInterface $consoleHelper + * @param array $options + * + * @return bool + */ private function testConnection(ConsoleHelperInterface $consoleHelper, array $options) { $adapter = AdapterFactory::create($options['rdbms']); @@ -296,6 +351,12 @@ private function testConnection(ConsoleHelperInterface $consoleHelper, array $op } } + /** + * @param \Symfony\Component\Console\Output\OutputInterface $output + * @param array $options + * + * @return string + */ private function reverseEngineerSchema(OutputInterface $output, array $options) { $outputDir = sys_get_temp_dir(); diff --git a/src/Propel/Generator/Command/MigrationStatusCommand.php b/src/Propel/Generator/Command/MigrationStatusCommand.php index 5b7016657c..6c64101324 100644 --- a/src/Propel/Generator/Command/MigrationStatusCommand.php +++ b/src/Propel/Generator/Command/MigrationStatusCommand.php @@ -101,7 +101,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln(sprintf( 'Latest migration was executed on %s (timestamp %d)', date('Y-m-d H:i:s', $oldestMigrationTimestamp), - $oldestMigrationTimestamp + (string)$oldestMigrationTimestamp )); } else { $output->writeln('No migration was ever executed on these connection settings.'); diff --git a/src/Propel/Generator/Command/TestPrepareCommand.php b/src/Propel/Generator/Command/TestPrepareCommand.php index 6858b1f4cc..51596179bb 100644 --- a/src/Propel/Generator/Command/TestPrepareCommand.php +++ b/src/Propel/Generator/Command/TestPrepareCommand.php @@ -63,7 +63,7 @@ class TestPrepareCommand extends AbstractCommand /** * @var string */ - protected $root = null; + protected $root; public function __construct() { diff --git a/src/Propel/Generator/Config/GeneratorConfig.php b/src/Propel/Generator/Config/GeneratorConfig.php index 921ec2ffc0..f8c62069cd 100644 --- a/src/Propel/Generator/Config/GeneratorConfig.php +++ b/src/Propel/Generator/Config/GeneratorConfig.php @@ -44,7 +44,7 @@ class GeneratorConfig extends ConfigurationManager implements GeneratorConfigInt * * @var array */ - protected $buildConnections = null; + protected $buildConnections = []; /** * {@inheritdoc} @@ -175,7 +175,7 @@ public function getConfiguredPluralizer() } /** - * Return an array of all configured connection properties, from `generator` and `reverse` + * Return an array of all configured connection properties, from `generator` and `reverse` * sections of the configuration. * * @return array @@ -225,7 +225,7 @@ public function getBuildConnection($databaseName = null) /** * Return a connection object of a given database name * - * @param string $database + * @param string|null $database * @return ConnectionInterface */ public function getConnection($database = null) @@ -248,6 +248,9 @@ public function getConnection($database = null) return $con; } + /** + * @return \Propel\Generator\Util\BehaviorLocator + */ public function getBehaviorLocator() { if (!$this->behaviorLocator) { diff --git a/src/Propel/Generator/Manager/AbstractManager.php b/src/Propel/Generator/Manager/AbstractManager.php index f2e7f0dc81..6a273b6f3b 100644 --- a/src/Propel/Generator/Manager/AbstractManager.php +++ b/src/Propel/Generator/Manager/AbstractManager.php @@ -429,6 +429,10 @@ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) $this->generatorConfig = $generatorConfig; } + /** + * @throws \Propel\Generator\Exception\BuildException + * @return void + */ protected function validate() { if ($this->validate) { @@ -438,6 +442,11 @@ protected function validate() } } + /** + * @param string $message + * + * @return void + */ protected function log($message) { if (null !== $this->loggerClosure) { @@ -450,7 +459,7 @@ protected function log($message) * Returns an array of properties as key/value pairs from an input file. * * @param string $file - * @return array + * @return string[] */ protected function getProperties($file) { diff --git a/src/Propel/Generator/Manager/GraphvizManager.php b/src/Propel/Generator/Manager/GraphvizManager.php index a88f1d4778..1105851b3b 100644 --- a/src/Propel/Generator/Manager/GraphvizManager.php +++ b/src/Propel/Generator/Manager/GraphvizManager.php @@ -19,10 +19,11 @@ */ class GraphvizManager extends AbstractManager { + /** + * @return void + */ public function build() { - $count = 0; - foreach ($this->getDatabases() as $database) { $dotSyntax = "digraph G {\n"; @@ -44,12 +45,9 @@ public function build() } $dotSyntax .= '}", shape=record];'; $dotSyntax .= "\n"; - - $count++; } // print the relations - $count = 0; $dotSyntax .= "\n"; foreach ($database->getTables() as $tbl) { foreach ($tbl->getForeignKeys() as $fk) { @@ -57,7 +55,7 @@ public function build() $dotSyntax .= ':cols -> node'.$fk->getForeignTableName(); $label = []; foreach ($fk->getMapping() as $map) { - list ($localColumn, $foreignValueOrColumn) = $map; + [$localColumn, $foreignValueOrColumn] = $map; $labelString = $localColumn->getName().'='; if ($foreignValueOrColumn instanceof Column) { $labelString .= $foreignValueOrColumn->getName(); @@ -70,8 +68,6 @@ public function build() $dotSyntax .= ':table [label="' . implode('\l', $label) . ' ", color=gray];'; $dotSyntax .= "\n"; } - - $count++; } $dotSyntax .= "}\n"; @@ -80,6 +76,12 @@ public function build() } } + /** + * @param string $dotSyntax + * @param string $baseFilename + * + * @return void + */ protected function writeDot($dotSyntax, $baseFilename) { $file = $this->getWorkingDirectory() . DIRECTORY_SEPARATOR . $baseFilename . '.schema.dot'; diff --git a/src/Propel/Generator/Manager/MigrationManager.php b/src/Propel/Generator/Manager/MigrationManager.php index ce9fc1361b..a7a8f0c80c 100644 --- a/src/Propel/Generator/Manager/MigrationManager.php +++ b/src/Propel/Generator/Manager/MigrationManager.php @@ -62,6 +62,13 @@ public function getConnections() return $this->connections; } + /** + * @param string $datasource + * + * @throws \Propel\Generator\Exception\InvalidArgumentException + * + * @return array + */ public function getConnection($datasource) { if (!isset($this->connections[$datasource])) { @@ -120,6 +127,10 @@ public function getMigrationTable() return $this->migrationTable; } + /** + * @throws \Exception + * @return int[] + */ public function getAllDatabaseVersions() { $connections = $this->getConnections(); @@ -155,6 +166,11 @@ public function getAllDatabaseVersions() return $migrationTimestamps; } + /** + * @param string $datasource + * + * @return bool + */ public function migrationTableExists($datasource) { $conn = $this->getAdapterConnection($datasource); @@ -169,6 +185,13 @@ public function migrationTableExists($datasource) } } + /** + * @param string $datasource + * + * @throws \Exception + * + * @return void + */ public function createMigrationTable($datasource) { $platform = $this->getPlatform($datasource); @@ -194,6 +217,12 @@ public function createMigrationTable($datasource) } } + /** + * @param string $datasource + * @param int $timestamp + * + * @return void + */ public function removeMigrationTimestamp($datasource, $timestamp) { $platform = $this->getPlatform($datasource); @@ -209,6 +238,12 @@ public function removeMigrationTimestamp($datasource, $timestamp) }); } + /** + * @param string $datasource + * @param int $timestamp + * + * @return void + */ public function updateLatestMigrationTimestamp($datasource, $timestamp) { $platform = $this->getPlatform($datasource); @@ -222,6 +257,9 @@ public function updateLatestMigrationTimestamp($datasource, $timestamp) $stmt->execute(); } + /** + * @return int[] + */ public function getMigrationTimestamps() { $path = $this->getWorkingDirectory(); @@ -239,6 +277,9 @@ public function getMigrationTimestamps() return $migrationTimestamps; } + /** + * @return int[] + */ public function getValidMigrationTimestamps() { $migrationTimestamps = array_diff($this->getMigrationTimestamps(), $this->getAllDatabaseVersions()); @@ -247,11 +288,17 @@ public function getValidMigrationTimestamps() return $migrationTimestamps; } + /** + * @return bool + */ public function hasPendingMigrations() { return [] !== $this->getValidMigrationTimestamps(); } + /** + * @return int[] + */ public function getAlreadyExecutedMigrationTimestamps() { $migrationTimestamps = array_intersect($this->getMigrationTimestamps(), $this->getAllDatabaseVersions()); @@ -260,6 +307,9 @@ public function getAlreadyExecutedMigrationTimestamps() return $migrationTimestamps; } + /** + * @return int + */ public function getFirstUpMigrationTimestamp() { $validTimestamps = $this->getValidMigrationTimestamps(); @@ -267,11 +317,20 @@ public function getFirstUpMigrationTimestamp() return array_shift($validTimestamps); } + /** + * @return int|null + */ public function getFirstDownMigrationTimestamp() { return $this->getOldestDatabaseVersion(); } + /** + * @param int $timestamp + * @param string $suffix + * + * @return string + */ public function getMigrationClassName($timestamp, $suffix = "") { $className = sprintf('PropelMigration_%d', $timestamp); @@ -284,6 +343,11 @@ public function getMigrationClassName($timestamp, $suffix = "") return $className; } + /** + * @param int $timestamp + * + * @return string + */ public function findMigrationClassNameSuffix($timestamp) { $suffix = ""; $path = $this->getWorkingDirectory(); @@ -298,6 +362,11 @@ public function findMigrationClassNameSuffix($timestamp) { return $suffix; } + /** + * @param int $timestamp + * + * @return object + */ public function getMigrationObject($timestamp) { $className = $this->getMigrationClassName($timestamp); @@ -309,6 +378,15 @@ public function getMigrationObject($timestamp) return new $className(); } + /** + * @param string[] $migrationsUp + * @param string[] $migrationsDown + * @param int $timestamp + * @param string $comment + * @param string $suffix + * + * @return string + */ public function getMigrationClassBody($migrationsUp, $migrationsDown, $timestamp, $comment = "", $suffix = "") { $timeInWords = date('Y-m-d H:i:s', $timestamp); @@ -379,11 +457,20 @@ public function getDownSQL() return $migrationClassBody; } + /** + * @param int $timestamp + * @param string $suffix + * + * @return string + */ public function getMigrationFileName($timestamp, $suffix = "") { return sprintf('%s.php', $this->getMigrationClassName($timestamp, $suffix)); } + /** + * @return string + */ public static function getUser() { if (function_exists('posix_getuid')) { @@ -396,9 +483,15 @@ public static function getUser() return ''; } + /** + * @return int|null + */ public function getOldestDatabaseVersion() { $versions = $this->getAllDatabaseVersions(); + if (!$versions) { + return null; + } return array_pop($versions); } diff --git a/src/Propel/Generator/Manager/ModelManager.php b/src/Propel/Generator/Manager/ModelManager.php index ceaac3d0c6..a8985a01ca 100644 --- a/src/Propel/Generator/Manager/ModelManager.php +++ b/src/Propel/Generator/Manager/ModelManager.php @@ -37,6 +37,9 @@ public function setFilesystem(Filesystem $filesystem) $this->filesystem = $filesystem; } + /** + * @return void + */ public function build() { $this->validate(); diff --git a/src/Propel/Generator/Manager/ReverseManager.php b/src/Propel/Generator/Manager/ReverseManager.php index 385542c327..87788e3f3a 100644 --- a/src/Propel/Generator/Manager/ReverseManager.php +++ b/src/Propel/Generator/Manager/ReverseManager.php @@ -167,6 +167,10 @@ public function isSamePhpName() return $this->samePhpName; } + /** + * @throws \Propel\Generator\Exception\BuildException + * @return bool + */ public function reverse() { if (!$this->getDatabaseName()) { diff --git a/src/Propel/Generator/Manager/SqlManager.php b/src/Propel/Generator/Manager/SqlManager.php index 208fbea709..e98ceb9dcb 100644 --- a/src/Propel/Generator/Manager/SqlManager.php +++ b/src/Propel/Generator/Manager/SqlManager.php @@ -29,10 +29,8 @@ class SqlManager extends AbstractManager protected $connections; /** - * @var array + * @var bool */ - protected $databases = null; - protected $overwriteSqlMap = false; /** @@ -55,6 +53,11 @@ public function getConnections() return $this->connections; } + /** + * @param string $connection + * + * @return bool + */ public function hasConnection($connection) { return isset($this->connections[$connection]); @@ -76,6 +79,13 @@ public function setOverwriteSqlMap($overwriteSqlMap) $this->overwriteSqlMap = (boolean) $overwriteSqlMap; } + /** + * @param string $datasource + * + * @throws \Propel\Generator\Exception\InvalidArgumentException + * + * @return array + */ public function getConnection($datasource) { if (!$this->hasConnection($datasource)) { diff --git a/src/Propel/Generator/Model/Behavior.php b/src/Propel/Generator/Model/Behavior.php index bef65bd9f0..2af7869e27 100644 --- a/src/Propel/Generator/Model/Behavior.php +++ b/src/Propel/Generator/Model/Behavior.php @@ -377,6 +377,10 @@ public function getColumnForParameter($name) return $this->table->getColumn($this->getParameter($name)); } + /** + * @throws \Propel\Generator\Exception\LogicException + * @return void + */ protected function setupObject() { $this->setName($this->getAttribute('name')); diff --git a/src/Propel/Generator/Model/BehaviorableTrait.php b/src/Propel/Generator/Model/BehaviorableTrait.php index 293807f8fd..1750cd48fc 100644 --- a/src/Propel/Generator/Model/BehaviorableTrait.php +++ b/src/Propel/Generator/Model/BehaviorableTrait.php @@ -88,6 +88,11 @@ public function addBehavior($bdata) return $this->addBehavior($behavior); } + /** + * @param \Propel\Generator\Model\Behavior $behavior + * + * @return void + */ abstract protected function registerBehavior(Behavior $behavior); /** diff --git a/src/Propel/Generator/Model/Column.php b/src/Propel/Generator/Model/Column.php index e647e06b91..e8ab9c732f 100644 --- a/src/Propel/Generator/Model/Column.php +++ b/src/Propel/Generator/Model/Column.php @@ -33,15 +33,54 @@ class Column extends MappingModel public static $validVisibilities = [ 'public', 'protected', 'private' ]; + /** + * @var string|null + */ private $name; + + /** + * @var string|null + */ private $description; + + /** + * @var string|null + */ private $phpName; + + /** + * @var string|null + */ private $phpSingularName; + + /** + * @var string|null + */ private $phpNamingMethod; - private $isNotNull; + + /** + * @var bool + */ + private $isNotNull = false; + + /** + * @var string|null + */ private $namePrefix; + + /** + * @var string|null + */ private $accessorVisibility; + + /** + * @var string|null + */ private $mutatorVisibility; + + /** + * @var string|null + */ private $typeHint; /** @@ -70,16 +109,60 @@ class Column extends MappingModel * @var int|null */ private $position; + + /** + * @var bool + */ private $isPrimaryKey; + + /** + * @var bool + */ private $isNodeKey; + + /** + * @var string + */ private $nodeKeySep; + + /** + * @var bool + */ private $isNestedSetLeftKey; + + /** + * @var bool + */ private $isNestedSetRightKey; + + /** + * @var bool + */ private $isTreeScopeKey; + + /** + * @var bool + */ private $isUnique; + + /** + * @var bool + */ private $isAutoIncrement; + + /** + * @var bool + */ private $isLazyLoad; + + /** + * @var array + */ private $referrers = []; + + /** + * @var bool + */ private $isPrimaryString; // only one type is supported currently, which assumes the @@ -87,18 +170,37 @@ class Column extends MappingModel // classnames specified in the schema. Others may be // supported later. + /** + * @var string|null + */ private $inheritanceType; + + /** + * @var bool + */ private $isInheritance; + + /** + * @var bool + */ private $isEnumeratedClasses; + + /** + * @var array|null + */ private $inheritanceList; - // maybe this can be retrieved from vendor specific information + /** + * maybe this can be retrieved from vendor specific information + * + * @var bool + */ private $needsTransactionInPostgres; /** * @var string[] */ - protected $valueSet; + protected $valueSet = []; /** * Creates a new column and set the name. @@ -109,8 +211,6 @@ class Column extends MappingModel */ public function __construct($name = null, $type = null, $size = null) { - parent::__construct(); - if (null !== $name) { $this->setName($name); } @@ -122,24 +222,10 @@ public function __construct($name = null, $type = null, $size = null) if (null !== $size) { $this->setSize((int)$size); } - - $this->isAutoIncrement = false; - $this->isEnumeratedClasses = false; - $this->isLazyLoad = false; - $this->isNestedSetLeftKey = false; - $this->isNestedSetRightKey = false; - $this->isNodeKey = false; - $this->isNotNull = false; - $this->isPrimaryKey = false; - $this->isPrimaryString = false; - $this->isTreeScopeKey = false; - $this->isUnique = false; - $this->needsTransactionInPostgres = false; - $this->valueSet = []; } /** - * @return mixed + * @return string|null */ public function getTypeHint() { @@ -147,13 +233,17 @@ public function getTypeHint() } /** - * @param mixed $typeHint + * @param string|null $typeHint */ public function setTypeHint($typeHint) { $this->typeHint = $typeHint; } + /** + * @throws \Propel\Generator\Exception\EngineException + * @return void + */ protected function setupObject() { try { @@ -701,7 +791,7 @@ public function addInheritance($inheritance) /** * Returns the inheritance type. * - * @return string + * @return string|null */ public function getInheritanceType() { @@ -1085,6 +1175,11 @@ public function getPDOType() return PropelTypes::getPDOType($this->getType()); } + /** + * @param \Propel\Generator\Platform\PlatformInterface|null $platform + * + * @return bool + */ public function isDefaultSqlType(PlatformInterface $platform = null) { if (null === $this->domain diff --git a/src/Propel/Generator/Model/Database.php b/src/Propel/Generator/Model/Database.php index f4a545512f..0ad2ad8d11 100644 --- a/src/Propel/Generator/Model/Database.php +++ b/src/Propel/Generator/Model/Database.php @@ -41,16 +41,31 @@ class Database extends ScopedMappingModel /** * @var Table[] */ - private $tables; + private $tables = []; /** * @var string|null */ private $name; + /** + * @var string|null + */ private $baseClass; + + /** + * @var string|null + */ private $baseQueryClass; + + /** + * @var string + */ private $defaultIdMethod; + + /** + * @var string + */ private $defaultPhpNamingMethod; /** @@ -70,38 +85,55 @@ class Database extends ScopedMappingModel * @var string */ private $defaultMutatorVisibility; - private $domainMap; - private $heavyIndexing; + + /** + * @var array + */ + private $domainMap = []; + + /** + * @var bool + */ + private $heavyIndexing = false; /** * @var boolean */ - private $identifierQuoting; + private $identifierQuoting = false; - /** @var Schema */ + /** + * @var Schema + */ private $parentSchema; /** * @var Table[] */ - private $tablesByName; + private $tablesByName = []; /** * @var Table[] */ - private $tablesByLowercaseName; + private $tablesByLowercaseName = []; /** * @var Table[] */ - private $tablesByPhpName; + private $tablesByPhpName = []; /** * @var string[] */ - private $sequences; + private $sequences = []; + /** + * @var string + */ protected $defaultStringFormat; + + /** + * @var string|null + */ protected $tablePrefix; /** @@ -122,21 +154,16 @@ public function __construct($name = null, PlatformInterface $platform = null) $this->setPlatform($platform); } - $this->heavyIndexing = false; - $this->identifierQuoting = false; $this->defaultPhpNamingMethod = NameGeneratorInterface::CONV_METHOD_UNDERSCORE; $this->defaultIdMethod = IdMethod::NATIVE; $this->defaultStringFormat = static::DEFAULT_STRING_FORMAT; $this->defaultAccessorVisibility = static::VISIBILITY_PUBLIC; $this->defaultMutatorVisibility = static::VISIBILITY_PUBLIC; - $this->behaviors = []; - $this->domainMap = []; - $this->tables = []; - $this->tablesByName = []; - $this->tablesByPhpName = []; - $this->tablesByLowercaseName = []; } + /** + * @return void + */ protected function setupObject() { parent::setupObject(); @@ -830,6 +857,11 @@ public function doFinalInitialization() } } + /** + * @param \Propel\Generator\Model\Behavior $behavior + * + * @return void + */ protected function registerBehavior(Behavior $behavior) { $behavior->setDatabase($this); @@ -838,14 +870,18 @@ protected function registerBehavior(Behavior $behavior) /** * Setups all table referrers. * + * @return void */ - protected function setupTableReferrers() + protected function setupTableReferrers(): void { foreach ($this->tables as $table) { $table->setupReferrers(); } } + /** + * @return string + */ public function __toString() { $tables = []; @@ -961,6 +997,9 @@ public function getDefaultMutatorVisibility() return $this->defaultMutatorVisibility; } + /** + * @return void + */ public function __clone() { $tables = []; diff --git a/src/Propel/Generator/Model/Diff/ColumnDiff.php b/src/Propel/Generator/Model/Diff/ColumnDiff.php index 135882894d..f4f09ff930 100644 --- a/src/Propel/Generator/Model/Diff/ColumnDiff.php +++ b/src/Propel/Generator/Model/Diff/ColumnDiff.php @@ -24,27 +24,27 @@ class ColumnDiff * * @var array */ - protected $changedProperties; + protected $changedProperties = []; /** * The original column definition. * - * @var Column + * @var Column|null */ protected $fromColumn; /** * The modified column definition. * - * @var Column + * @var Column|null */ protected $toColumn; /** * Constructor. * - * @param Column $fromColumn The original column - * @param Column $toColumn The modified column + * @param Column|null $fromColumn The original column + * @param Column|null $toColumn The modified column */ public function __construct(Column $fromColumn = null, Column $toColumn = null) { @@ -55,8 +55,6 @@ public function __construct(Column $fromColumn = null, Column $toColumn = null) if (null !== $toColumn) { $this->setToColumn($toColumn); } - - $this->changedProperties = []; } /** @@ -92,7 +90,7 @@ public function setFromColumn(Column $fromColumn) /** * Returns the fromColumn property. * - * @return Column + * @return Column|null */ public function getFromColumn() { @@ -112,7 +110,7 @@ public function setToColumn(Column $toColumn) /** * Returns the toColumn property. * - * @return Column + * @return Column|null */ public function getToColumn() { diff --git a/src/Propel/Generator/Model/Diff/DatabaseComparator.php b/src/Propel/Generator/Model/Diff/DatabaseComparator.php index 758588775c..e829b8c238 100644 --- a/src/Propel/Generator/Model/Diff/DatabaseComparator.php +++ b/src/Propel/Generator/Model/Diff/DatabaseComparator.php @@ -61,6 +61,9 @@ public function __construct($databaseDiff = null) $this->databaseDiff = (null === $databaseDiff) ? new DatabaseDiff() : $databaseDiff; } + /** + * @return \Propel\Generator\Model\Diff\DatabaseDiff + */ public function getDatabaseDiff() { return $this->databaseDiff; diff --git a/src/Propel/Generator/Model/Diff/DatabaseDiff.php b/src/Propel/Generator/Model/Diff/DatabaseDiff.php index 467c59b285..aab645f5ce 100644 --- a/src/Propel/Generator/Model/Diff/DatabaseDiff.php +++ b/src/Propel/Generator/Model/Diff/DatabaseDiff.php @@ -328,6 +328,9 @@ public function getDescription() return implode(', ', $changes); } + /** + * @return string + */ public function __toString() { $ret = ''; diff --git a/src/Propel/Generator/Model/Diff/TableDiff.php b/src/Propel/Generator/Model/Diff/TableDiff.php index afab5de59c..087ba30a4d 100644 --- a/src/Propel/Generator/Model/Diff/TableDiff.php +++ b/src/Propel/Generator/Model/Diff/TableDiff.php @@ -1002,6 +1002,7 @@ public function getReverseDiff() /** * Clones the current diff object. * + * @return void */ public function __clone() { diff --git a/src/Propel/Generator/Model/Domain.php b/src/Propel/Generator/Model/Domain.php index 987c7c9815..bab17b59b9 100644 --- a/src/Propel/Generator/Model/Domain.php +++ b/src/Propel/Generator/Model/Domain.php @@ -45,8 +45,6 @@ class Domain extends MappingModel */ public function __construct($type = null, $sqlType = null, $size = null, $scale = null) { - parent::__construct(); - if (null !== $type) { $this->setType($type); } @@ -78,6 +76,9 @@ public function copy(Domain $domain) $this->mappingType = $domain->getType(); } + /** + * @return void + */ protected function setupObject() { $schemaType = strtoupper($this->getAttribute('type')); @@ -339,7 +340,7 @@ public function setSqlType($sqlType) /** * Replaces the SQL type if the new value is not null. * - * @param string $sqlType + * @param string|null $sqlType */ public function replaceSqlType($sqlType) { @@ -366,6 +367,9 @@ public function getSizeDefinition() return sprintf('(%u)', $this->size); } + /** + * @return void + */ public function __clone() { if ($this->defaultValue) { diff --git a/src/Propel/Generator/Model/ForeignKey.php b/src/Propel/Generator/Model/ForeignKey.php index 0df7cab9cf..14c9961a43 100644 --- a/src/Propel/Generator/Model/ForeignKey.php +++ b/src/Propel/Generator/Model/ForeignKey.php @@ -117,8 +117,6 @@ class ForeignKey extends MappingModel */ public function __construct($name = null) { - parent::__construct(); - if (null !== $name) { $this->setName($name); } @@ -127,6 +125,9 @@ public function __construct($name = null) $this->onDelete = self::NONE; } + /** + * @return void + */ protected function setupObject() { $this->foreignTableCommonName = $this->parentTable->getDatabase()->getTablePrefix() . $this->getAttribute('foreignTable'); @@ -142,6 +143,9 @@ protected function setupObject() $this->skipSql = $this->booleanValue($this->getAttribute('skipSql')); } + /** + * @return void + */ protected function doNaming() { if (!$this->name || $this->autoNaming) { @@ -823,7 +827,7 @@ public function getNormalizedMap($mapping) $result = []; foreach ($mapping as $map) { - list ($left, $right) = $map; + [$left, $right] = $map; $item = []; $item[0] = $left instanceof Column ? ':' . $left->getName() : $left; $item[1] = $right instanceof Column ? ':' . $right->getName() : $right; @@ -920,9 +924,16 @@ public function isMatchedByInverseFK() return (boolean) $this->getInverseFK(); } + /** + * @return \Propel\Generator\Model\ForeignKey|null + */ public function getInverseFK() { $foreignTable = $this->getForeignTable(); + if (!$foreignTable) { + throw new \RuntimeException('No foreign table given'); + } + $map = $this->getInverseMapping(); foreach ($foreignTable->getForeignKeys() as $refFK) { @@ -932,6 +943,8 @@ public function getInverseFK() return $refFK; } } + + return null; } /** diff --git a/src/Propel/Generator/Model/Index.php b/src/Propel/Generator/Model/Index.php index f52a83117b..729006d7cd 100644 --- a/src/Propel/Generator/Model/Index.php +++ b/src/Propel/Generator/Model/Index.php @@ -34,7 +34,7 @@ class Index extends MappingModel /** * @var string[] */ - protected $columns; + protected $columns = []; /** * @var Column[] @@ -44,7 +44,7 @@ class Index extends MappingModel /** * @var int[] */ - protected $columnsSize; + protected $columnsSize = []; /** * @var bool @@ -58,11 +58,6 @@ class Index extends MappingModel */ public function __construct($name = null) { - parent::__construct(); - - $this->columns = []; - $this->columnsSize = []; - if (null !== $name) { $this->setName($name); } @@ -105,6 +100,9 @@ public function getName() return $this->name; } + /** + * @return void + */ protected function doNaming() { if (!$this->name || $this->autoNaming) { @@ -129,6 +127,9 @@ protected function doNaming() } } + /** + * @return string + */ public function getFQName() { $table = $this->getTable(); @@ -269,7 +270,7 @@ public function resetColumnsSize() * * @param integer $pos Position in the column list * @param string $name Column name - * @param integer $size Optional size check + * @param integer|null $size Optional size check * @param boolean $caseInsensitive Whether or not the comparison is case insensitive (false by default) * @return boolean */ @@ -311,13 +312,16 @@ public function hasColumns() * * You should not edit this list. * - * @return array + * @return string[] */ public function getColumns() { return $this->columns; } + /** + * @return void + */ protected function setupObject() { $this->setName($this->getAttribute('name')); diff --git a/src/Propel/Generator/Model/Inheritance.php b/src/Propel/Generator/Model/Inheritance.php index 52d7666d15..e3dd5acdea 100644 --- a/src/Propel/Generator/Model/Inheritance.php +++ b/src/Propel/Generator/Model/Inheritance.php @@ -151,6 +151,9 @@ public function setAncestor($ancestor) $this->ancestor = $ancestor; } + /** + * @return void + */ protected function setupObject() { $this->key = $this->getAttribute('key'); diff --git a/src/Propel/Generator/Model/MappingModel.php b/src/Propel/Generator/Model/MappingModel.php index 6201162cc5..557a954955 100644 --- a/src/Propel/Generator/Model/MappingModel.php +++ b/src/Propel/Generator/Model/MappingModel.php @@ -24,24 +24,14 @@ abstract class MappingModel implements MappingModelInterface * * @var array */ - protected $attributes; + protected $attributes = []; /** * The list of vendor's information. * - * @var array + * @var VendorInfo[] */ - protected $vendorInfos; - - /** - * Constructor. - * - */ - public function __construct() - { - $this->attributes = []; - $this->vendorInfos = []; - } + protected $vendorInfos = []; /** * Loads a mapping definition from an array. @@ -82,7 +72,7 @@ public function getAttributes() * returned instead. * * @param string $name - * @param mixed $default + * @param mixed|null $default * @return mixed */ public function getAttribute($name, $default = null) @@ -116,6 +106,11 @@ protected function booleanValue($value) return in_array(strtolower($value), [ 'true', 't', 'y', 'yes' ], true); } + /** + * @param string $stringValue + * + * @return string|null + */ protected function getDefaultValueForArray($stringValue) { $stringValue = trim($stringValue); diff --git a/src/Propel/Generator/Model/ScopedMappingModel.php b/src/Propel/Generator/Model/ScopedMappingModel.php index 9e560c127f..9ba3ef7053 100644 --- a/src/Propel/Generator/Model/ScopedMappingModel.php +++ b/src/Propel/Generator/Model/ScopedMappingModel.php @@ -23,14 +23,17 @@ abstract class ScopedMappingModel extends MappingModel * @var string|null */ protected $package; + /** * @var bool */ - protected $packageOverridden; + protected $packageOverridden = false; + /** * @var string|null */ protected $namespace; + /** * @var string|null */ @@ -38,13 +41,9 @@ abstract class ScopedMappingModel extends MappingModel /** * Constructs a new scoped model object. - * */ public function __construct() { - parent::__construct(); - - $this->packageOverridden = false; } /** diff --git a/src/Propel/Generator/Model/Table.php b/src/Propel/Generator/Model/Table.php index 7f96de270b..034d448ad4 100644 --- a/src/Propel/Generator/Model/Table.php +++ b/src/Propel/Generator/Model/Table.php @@ -186,6 +186,9 @@ private function getStdSeparatedName() return $this->getCommonName(); } + /** + * @return void + */ public function setupObject() { parent::setupObject(); @@ -260,6 +263,11 @@ public function applyBehaviors() } } + /** + * @param \Propel\Generator\Model\Behavior $behavior + * + * @return void + */ protected function registerBehavior(Behavior $behavior) { $behavior->setTable($this); @@ -272,6 +280,8 @@ protected function registerBehavior(Behavior $behavior) * *

Performs heavy indexing and naming of elements which weren't * provided with a name.

+ * + * @return void */ public function doFinalInitialization() { @@ -310,6 +320,8 @@ public function doFinalInitialization() * See the mysql manual http://www.mysql.com/doc/E/X/EXPLAIN.html * for a better description of why heavy indexing is useful for * quickly searchable database tables. + * + * @return void */ private function doHeavyIndexing() { @@ -330,6 +342,8 @@ private function doHeavyIndexing() * Adds extra indices for reverse foreign keys * This is required for MySQL databases, * and is called from Database::doFinalInitialization() + * + * @return void */ public function addExtraIndices() { @@ -601,6 +615,11 @@ public function removeColumn($column) // @FIXME: also remove indexes and validators on this column? } + /** + * @param \Propel\Generator\Model\Column $column + * + * @return int|false + */ private function getColumnPosition(Column $column) { $position = false; @@ -614,6 +633,9 @@ private function getColumnPosition(Column $column) return $position; } + /** + * @return void + */ public function adjustColumnPositions() { $this->columns = array_values($this->columns); @@ -1864,6 +1886,9 @@ public function getFirstPrimaryKeyColumn() } } + /** + * @return void + */ public function __clone() { $columns = []; diff --git a/src/Propel/Generator/Model/VendorInfo.php b/src/Propel/Generator/Model/VendorInfo.php index aa78beea4b..cff8d63d2f 100644 --- a/src/Propel/Generator/Model/VendorInfo.php +++ b/src/Propel/Generator/Model/VendorInfo.php @@ -29,8 +29,6 @@ class VendorInfo extends MappingModel */ public function __construct($type = null, array $parameters = []) { - parent::__construct(); - $this->parameters = []; if (null !== $type) { @@ -142,6 +140,9 @@ public function getMergedVendorInfo(VendorInfo $info) return $newInfo; } + /** + * @return void + */ protected function setupObject() { $this->type = $this->getAttribute('type'); diff --git a/src/Propel/Generator/Platform/DefaultPlatform.php b/src/Propel/Generator/Platform/DefaultPlatform.php index 6514aa4bbc..66ffa0071d 100644 --- a/src/Propel/Generator/Platform/DefaultPlatform.php +++ b/src/Propel/Generator/Platform/DefaultPlatform.php @@ -192,6 +192,9 @@ public function getNativeIdMethod() return PlatformInterface::IDENTITY; } + /** + * @return bool + */ public function isNativeIdMethodAutoIncrement() { return PlatformInterface::IDENTITY === $this->getNativeIdMethod(); @@ -270,6 +273,8 @@ public function getSequenceName(Table $table) * Returns the DDL SQL to add the tables of a database * together with index and foreign keys * + * @param \Propel\Generator\Model\Database $database + * * @return string */ public function getAddTablesDDL(Database $database) @@ -302,10 +307,11 @@ public function getBeginDDL() /** * Gets the requests to execute at the end of a DDL file * - * @return string|null + * @return string */ public function getEndDDL() { + return ''; } /** @@ -468,13 +474,15 @@ public function getPrimaryKeyName(Table $table) /** * Returns the SQL for the primary key of a Table object. * - * @return string|null + * @return string */ public function getPrimaryKeyDDL(Table $table) { if ($table->hasPrimaryKey()) { return 'PRIMARY KEY (' . $this->getColumnListDDL($table->getPrimaryKey()) . ')'; } + + return ''; } /** @@ -1247,13 +1255,16 @@ public function supportsSchemas() /** * @see Platform::supportsMigrations() + * @return bool */ public function supportsMigrations() { return true; } - + /** + * @return bool + */ public function supportsVarcharWithoutSize() { return false; @@ -1267,7 +1278,7 @@ public function supportsVarcharWithoutSize() * This function is used to set default column values when building * SQL. * - * @param mixed $b A Boolean or string representation of Boolean ('y', 'true'). + * @param bool|int|string $b A Boolean or string representation of Boolean ('y', 'true'). * @return string */ public function getBooleanString($b) @@ -1288,6 +1299,11 @@ public function getBooleanString($b) return '0'; } + /** + * @param string $stringValue + * + * @return string|null + */ public function getPhpArrayString($stringValue) { $stringValue = trim($stringValue); @@ -1381,6 +1397,14 @@ public function getColumnBindingPHP(Column $column, $identifier, $columnValueAcc * * $this->id = $con->lastInsertId(); * + * + * @param string $columnValueMutator + * @param string $connectionVariableName + * @param string $sequenceName + * @param string $tab + * @param string|null $phpType + * + * @return string|string[]|null */ public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = " ", $phpType = null) { @@ -1398,7 +1422,7 @@ public function getIdentifierPhp($columnValueMutator, $connectionVariableName = /** * Returns a integer indexed array of default type sizes. * - * @return integer[] type indexed array of integers + * @return int[] type indexed array of integers */ public function getDefaultTypeSizes() { diff --git a/src/Propel/Generator/Platform/MssqlPlatform.php b/src/Propel/Generator/Platform/MssqlPlatform.php index d75ea5f6ae..b9159ff55a 100644 --- a/src/Propel/Generator/Platform/MssqlPlatform.php +++ b/src/Propel/Generator/Platform/MssqlPlatform.php @@ -55,21 +55,35 @@ protected function initialize() $this->setSchemaDomainMapping(new Domain(PropelTypes::SET, "INT")); } + /** + * @return int + */ public function getMaxColumnNameLength() { return 128; } + /** + * @param bool $notNull + * + * @return string + */ public function getNullString($notNull) { return $notNull ? 'NOT NULL' : 'NULL'; } + /** + * @return bool + */ public function supportsNativeDeleteTrigger() { return true; } + /** + * @return bool + */ public function supportsInsertNullPk() { return false; @@ -103,6 +117,11 @@ public function getAddTablesDDL(Database $database) return $ret; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ public function getDropTableDDL(Table $table) { $ret = ''; @@ -148,7 +167,7 @@ public function getDropTableDDL(Table $table) /** * @param \Propel\Generator\Model\Table $table * - * @return string|null + * @return string */ public function getPrimaryKeyDDL(Table $table) { @@ -160,6 +179,8 @@ public function getPrimaryKeyDDL(Table $table) $this->getColumnListDDL($table->getPrimaryKey()) ); } + + return ''; } /** @@ -257,6 +278,9 @@ public function doQuoting($text) return '[' . strtr($text, ['.' => '].[']) . ']'; } + /** + * @return string + */ public function getTimestampFormatter() { return 'Y-m-d H:i:s'; diff --git a/src/Propel/Generator/Platform/MysqlPlatform.php b/src/Propel/Generator/Platform/MysqlPlatform.php index 70c86c0d4b..5cb3994c70 100644 --- a/src/Propel/Generator/Platform/MysqlPlatform.php +++ b/src/Propel/Generator/Platform/MysqlPlatform.php @@ -55,6 +55,11 @@ protected function initialize() $this->setSchemaDomainMapping(new Domain(PropelTypes::REAL, 'DOUBLE')); } + /** + * @param \Propel\Generator\Config\GeneratorConfigInterface $generatorConfig + * + * @return void + */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) { parent::setGeneratorConfig($generatorConfig); @@ -106,26 +111,43 @@ public function getDefaultTableEngine() return $this->defaultTableEngine; } + /** + * @return string + */ public function getAutoIncrement() { return 'AUTO_INCREMENT'; } + /** + * @return int + */ public function getMaxColumnNameLength() { return 64; } + /** + * @return bool + */ public function supportsNativeDeleteTrigger() { return strtolower($this->getDefaultTableEngine()) === 'innodb'; } + /** + * @return bool + */ public function supportsIndexSize() { return true; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return bool + */ public function supportsForeignKeys(Table $table) { $vendorSpecific = $table->getVendorInfoForType('mysql'); @@ -140,6 +162,11 @@ public function supportsForeignKeys(Table $table) return strtolower($mysqlTableType) === 'innodb'; } + /** + * @param \Propel\Generator\Model\Database $database + * + * @return string + */ public function getAddTablesDDL(Database $database) { $ret = ''; @@ -155,6 +182,9 @@ public function getAddTablesDDL(Database $database) return $ret; } + /** + * @return string|null + */ public function getBeginDDL() { return " @@ -164,6 +194,9 @@ public function getBeginDDL() "; } + /** + * @return string + */ public function getEndDDL() { return " @@ -177,12 +210,11 @@ public function getEndDDL() * * @param Table $table * - * @return string|null + * @return string */ public function getPrimaryKeyDDL(Table $table) { if ($table->hasPrimaryKey()) { - $keys = $table->getPrimaryKey(); //MySQL throws an 'Incorrect table definition; there can be only one auto column and it must be defined as a key' @@ -199,8 +231,15 @@ public function getPrimaryKeyDDL(Table $table) return 'PRIMARY KEY (' . $this->getColumnListDDL($keys) . ')'; } + + return ''; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ public function getAddTableDDL(Table $table) { $lines = []; @@ -267,6 +306,11 @@ public function getAddTableDDL(Table $table) ); } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string[] + */ protected function getTableOptions(Table $table) { $dbVI = $table->getDatabase()->getVendorInfoForType('mysql'); @@ -326,6 +370,11 @@ protected function getTableOptions(Table $table) return $tableOptions; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ public function getDropTableDDL(Table $table) { return " @@ -333,6 +382,12 @@ public function getDropTableDDL(Table $table) "; } + /** + * @param \Propel\Generator\Model\Column $col + * + * @throws \Propel\Generator\Exception\EngineException + * @return string + */ public function getColumnDDL(Column $col) { $domain = $col->getDomain(); @@ -342,18 +397,18 @@ public function getColumnDDL(Column $col) // Special handling of TIMESTAMP/DATETIME types ... // See: http://propel.phpdb.org/trac/ticket/538 - if ($sqlType == 'DATETIME') { + if ($sqlType === 'DATETIME') { $def = $domain->getDefaultValue(); if ($def && $def->isExpression()) { // DATETIME values can only have constant expressions $sqlType = 'TIMESTAMP'; } - } elseif ($sqlType == 'DATE') { + } elseif ($sqlType === 'DATE') { $def = $domain->getDefaultValue(); if ($def && $def->isExpression()) { throw new EngineException('DATE columns cannot have default *expressions* in MySQL.'); } - } elseif ($sqlType == 'TEXT' || $sqlType == 'BLOB') { + } elseif ($sqlType === 'TEXT' || $sqlType === 'BLOB') { if ($domain->getDefaultValue()) { throw new EngineException('BLOB and TEXT columns cannot have DEFAULT values. in MySQL.'); } @@ -385,11 +440,11 @@ public function getColumnDDL(Column $col) } elseif ($colinfo->hasParameter('Collate')) { $ddl[] = 'COLLATE '. $this->quote($colinfo->getParameter('Collate')); } - if ($sqlType == 'TIMESTAMP') { + if ($sqlType === 'TIMESTAMP') { if ($notNullString == '') { $notNullString = 'NULL'; } - if ($defaultSetting == '' && $notNullString == 'NOT NULL') { + if ($defaultSetting == '' && $notNullString === 'NOT NULL') { $defaultSetting = 'DEFAULT CURRENT_TIMESTAMP'; } if ($notNullString) { @@ -505,6 +560,11 @@ public function getIndexDDL(Index $index) ); } + /** + * @param \Propel\Generator\Model\Index $index + * + * @return string + */ protected function getIndexType(Index $index) { $type = ''; @@ -518,6 +578,11 @@ protected function getIndexType(Index $index) return $type; } + /** + * @param \Propel\Generator\Model\Unique $unique + * + * @return string + */ public function getUniqueDDL(Unique $unique) { return sprintf('UNIQUE INDEX %s (%s)', @@ -526,6 +591,11 @@ public function getUniqueDDL(Unique $unique) ); } + /** + * @param \Propel\Generator\Model\ForeignKey $fk + * + * @return string + */ public function getAddForeignKeyDDL(ForeignKey $fk) { if ($this->supportsForeignKeys($fk->getTable())) { @@ -764,6 +834,11 @@ public function supportsSchemas() return true; } + /** + * @param string $sqlType + * + * @return bool + */ public function hasSize($sqlType) { return !in_array($sqlType, [ @@ -775,6 +850,9 @@ public function hasSize($sqlType) ]); } + /** + * @return int[] + */ public function getDefaultTypeSizes() { return [ @@ -812,6 +890,14 @@ public function doQuoting($text) return '`' . strtr($text, ['.' => '`.`']) . '`'; } + /** + * @param \Propel\Generator\Model\Column $column + * @param string $identifier + * @param string $columnValueAccessor + * @param string $tab + * + * @return string + */ public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = " ") { // FIXME - This is a temporary hack to get around apparent bugs w/ PDO+MYSQL diff --git a/src/Propel/Generator/Platform/OraclePlatform.php b/src/Propel/Generator/Platform/OraclePlatform.php index 9d499818dc..47549ae441 100644 --- a/src/Propel/Generator/Platform/OraclePlatform.php +++ b/src/Propel/Generator/Platform/OraclePlatform.php @@ -61,26 +61,41 @@ protected function initialize() $this->setSchemaDomainMapping(new Domain(PropelTypes::SET, 'NUMBER')); } + /** + * @return int + */ public function getMaxColumnNameLength() { return 30; } + /** + * @return string + */ public function getNativeIdMethod() { return PlatformInterface::SEQUENCE; } + /** + * @return string + */ public function getAutoIncrement() { return ''; } + /** + * @return bool + */ public function supportsNativeDeleteTrigger() { return true; } + /** + * @return string|null + */ public function getBeginDDL() { return " @@ -89,6 +104,11 @@ public function getBeginDDL() "; } + /** + * @param \Propel\Generator\Model\Database $database + * + * @return string + */ public function getAddTablesDDL(Database $database) { $ret = $this->getBeginDDL(); @@ -110,6 +130,11 @@ public function getAddTablesDDL(Database $database) return $ret; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ public function getAddTableDDL(Table $table) { $tableDescription = $table->hasDescription() ? $this->getCommentLineDDL($table->getDescription()) : ''; @@ -146,6 +171,11 @@ public function getAddTableDDL(Table $table) return $ret; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ public function getAddPrimaryKeyDDL(Table $table) { if (is_array($table->getPrimaryKey()) && count($table->getPrimaryKey())) { @@ -153,6 +183,11 @@ public function getAddPrimaryKeyDDL(Table $table) } } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ public function getAddSequencesDDL(Table $table) { if ('native' === $table->getIdMethod()) { @@ -165,8 +200,15 @@ public function getAddSequencesDDL(Table $table) $this->quoteIdentifier($this->getSequenceName($table)) ); } + + return ''; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ public function getDropTableDDL(Table $table) { $ret = " @@ -181,6 +223,11 @@ public function getDropTableDDL(Table $table) return $ret; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ public function getPrimaryKeyName(Table $table) { $tableName = $table->getName(); @@ -193,7 +240,7 @@ public function getPrimaryKeyName(Table $table) /** * @param \Propel\Generator\Model\Table $table * - * @return string|null + * @return string */ public function getPrimaryKeyDDL(Table $table) { @@ -206,8 +253,15 @@ public function getPrimaryKeyDDL(Table $table) $this->generateBlockStorage($table, true) ); } + + return ''; } + /** + * @param \Propel\Generator\Model\Unique $unique + * + * @return string + */ public function getUniqueDDL(Unique $unique) { return sprintf('CONSTRAINT %s UNIQUE (%s)', @@ -260,6 +314,9 @@ public function doQuoting($text) return $text; } + /** + * @return string + */ public function getTimestampFormatter() { return 'Y-m-d H:i:s'; @@ -387,6 +444,15 @@ public function getColumnBindingPHP(Column $column, $identifier, $columnValueAcc * Get the PHP snippet for getting a Pk from the database. * Warning: duplicates logic from OracleAdapter::getId(). * Any code modification here must be ported there. + * + * @param string $columnValueMutator + * @param string $connectionVariableName + * @param string $sequenceName + * @param string $tab + * @param string|null $phpType + * + * @throws \Propel\Generator\Exception\EngineException + * @return string|string[]|null */ public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = " ", $phpType = null) { diff --git a/src/Propel/Generator/Platform/PgsqlPlatform.php b/src/Propel/Generator/Platform/PgsqlPlatform.php index b99b69eda4..0cda5df5ef 100755 --- a/src/Propel/Generator/Platform/PgsqlPlatform.php +++ b/src/Propel/Generator/Platform/PgsqlPlatform.php @@ -63,16 +63,25 @@ protected function initialize() $this->setSchemaDomainMapping(new Domain(PropelTypes::DECIMAL, 'NUMERIC')); } + /** + * @return string + */ public function getNativeIdMethod() { return PlatformInterface::SERIAL; } + /** + * @return string + */ public function getAutoIncrement() { return ''; } + /** + * @return int[] + */ public function getDefaultTypeSizes() { return [ @@ -85,6 +94,9 @@ public function getDefaultTypeSizes() ]; } + /** + * @return int + */ public function getMaxColumnNameLength() { return 63; @@ -104,6 +116,9 @@ public function getBooleanString($b) return ($b ? "'t'" : "'f'"); } + /** + * @return bool + */ public function supportsNativeDeleteTrigger() { return true; @@ -140,6 +155,11 @@ public function getSequenceName(Table $table) return $result; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ protected function getAddSequenceDDL(Table $table) { if ($table->getIdMethod() == IdMethod::NATIVE @@ -152,8 +172,15 @@ protected function getAddSequenceDDL(Table $table) $this->quoteIdentifier(strtolower($this->getSequenceName($table))) ); } + + return ''; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ protected function getDropSequenceDDL(Table $table) { if ($table->getIdMethod() == IdMethod::NATIVE @@ -166,8 +193,15 @@ protected function getDropSequenceDDL(Table $table) $this->quoteIdentifier(strtolower($this->getSequenceName($table))) ); } + + return ''; } + /** + * @param \Propel\Generator\Model\Database $database + * + * @return string + */ public function getAddSchemasDDL(Database $database) { $ret = ''; @@ -183,6 +217,11 @@ public function getAddSchemasDDL(Database $database) return $ret; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ public function getAddSchemaDDL(Table $table) { $vi = $table->getVendorInfoForType('pgsql'); @@ -192,9 +231,16 @@ public function getAddSchemaDDL(Table $table) "; return sprintf($pattern, $this->quoteIdentifier($vi->getParameter('schema'))); - }; + } + + return ''; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ public function getUseSchemaDDL(Table $table) { $vi = $table->getVendorInfoForType('pgsql'); @@ -205,8 +251,15 @@ public function getUseSchemaDDL(Table $table) return sprintf($pattern, $this->quoteIdentifier($vi->getParameter('schema'))); } + + return ''; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ public function getResetSchemaDDL(Table $table) { $vi = $table->getVendorInfoForType('pgsql'); @@ -215,8 +268,15 @@ public function getResetSchemaDDL(Table $table) SET search_path TO public; "; } + + return ''; } + /** + * @param \Propel\Generator\Model\Database $database + * + * @return string + */ public function getAddTablesDDL(Database $database) { $ret = $this->getAddSchemasDDL($database); @@ -296,6 +356,11 @@ public function getAddForeignKeysDDL(Table $table) return $ret; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ public function getAddTableDDL(Table $table) { $ret = ''; @@ -345,6 +410,11 @@ public function getAddTableDDL(Table $table) return $ret; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ protected function getAddColumnsComments(Table $table) { $ret = ''; @@ -355,6 +425,11 @@ protected function getAddColumnsComments(Table $table) return $ret; } + /** + * @param \Propel\Generator\Model\Column $column + * + * @return string + */ protected function getAddColumnComment(Column $column) { $pattern = " @@ -367,8 +442,15 @@ protected function getAddColumnComment(Column $column) $this->quote($description) ); } + + return ''; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ public function getDropTableDDL(Table $table) { $ret = ''; @@ -383,6 +465,11 @@ public function getDropTableDDL(Table $table) return $ret; } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ public function getPrimaryKeyName(Table $table) { $tableName = $table->getCommonName(); @@ -390,6 +477,11 @@ public function getPrimaryKeyName(Table $table) return $tableName . '_pkey'; } + /** + * @param \Propel\Generator\Model\Column $col + * + * @return string + */ public function getColumnDDL(Column $col) { $domain = $col->getDomain(); @@ -426,6 +518,11 @@ public function getColumnDDL(Column $col) return implode(' ', $ddl); } + /** + * @param \Propel\Generator\Model\Unique $unique + * + * @return string + */ public function getUniqueDDL(Unique $unique) { return sprintf('CONSTRAINT %s UNIQUE (%s)', @@ -434,6 +531,12 @@ public function getUniqueDDL(Unique $unique) ); } + /** + * @param string $fromTableName + * @param string $toTableName + * + * @return string + */ public function getRenameTableDDL($fromTableName, $toTableName) { if (false !== ($pos = strpos($toTableName, '.'))) { @@ -452,27 +555,44 @@ public function getRenameTableDDL($fromTableName, $toTableName) /** * @see Platform::supportsSchemas() + * @return bool */ public function supportsSchemas() { return true; } + /** + * @param string $sqlType + * + * @return bool + */ public function hasSize($sqlType) { return !in_array($sqlType, ['BYTEA', 'TEXT', 'DOUBLE PRECISION']); } + /** + * @return bool + */ public function hasStreamBlobImpl() { return true; } + /** + * @return bool + */ public function supportsVarcharWithoutSize() { return true; } + /** + * @param \Propel\Generator\Model\Diff\TableDiff $tableDiff + * + * @return string + */ public function getModifyTableDDL(TableDiff $tableDiff) { $ret = parent::getModifyTableDDL($tableDiff); @@ -592,6 +712,11 @@ public function getModifyColumnDDL(ColumnDiff $columnDiff) return $ret; } + /** + * @param string $type + * + * @return bool + */ public function isString($type) { $strings = ['VARCHAR']; @@ -599,6 +724,11 @@ public function isString($type) return in_array(strtoupper($type), $strings); } + /** + * @param string $type + * + * @return bool + */ public function isNumber($type) { $numbers = ['INTEGER', 'INT4', 'INT2', 'NUMBER', 'NUMERIC', 'SMALLINT', 'BIGINT', 'DECIMAL', 'REAL', 'DOUBLE PRECISION', 'SERIAL', 'BIGSERIAL']; @@ -606,6 +736,12 @@ public function isNumber($type) return in_array(strtoupper($type), $numbers); } + /** + * @param \Propel\Generator\Model\Column $fromColumn + * @param \Propel\Generator\Model\Column $toColumn + * + * @return string + */ public function getUsingCast(Column $fromColumn, Column $toColumn) { $fromSqlType = strtoupper($fromColumn->getDomain()->getSqlType()); @@ -704,6 +840,15 @@ public function getDropIndexDDL(Index $index) * Get the PHP snippet for getting a Pk from the database. * Warning: duplicates logic from PgsqlAdapter::getId(). * Any code modification here must be ported there. + * + * @param string $columnValueMutator + * @param string $connectionVariableName + * @param string $sequenceName + * @param string $tab + * @param string|null $phpType + * + * @throws \Propel\Generator\Exception\EngineException + * @return string|string[]|null */ public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = " ", $phpType = null) { diff --git a/src/Propel/Generator/Platform/SqlitePlatform.php b/src/Propel/Generator/Platform/SqlitePlatform.php index a5352439ff..8d4d302c79 100644 --- a/src/Propel/Generator/Platform/SqlitePlatform.php +++ b/src/Propel/Generator/Platform/SqlitePlatform.php @@ -71,11 +71,17 @@ protected function initialize() $this->setSchemaDomainMapping(new Domain(PropelTypes::SET, 'INT')); } + /** + * @return string + */ public function getSchemaDelimiter() { return '§'; } + /** + * @return int[] + */ public function getDefaultTypeSizes() { return [ @@ -246,6 +252,9 @@ public function getMigrationTableDDL(TableDiff $tableDiff) return $sql; } + /** + * @return string|null + */ public function getBeginDDL() { return ' @@ -253,6 +262,9 @@ public function getBeginDDL() '; } + /** + * @return string + */ public function getEndDDL() { return ' @@ -261,7 +273,9 @@ public function getEndDDL() } /** - * {@inheritdoc} + * @param \Propel\Generator\Model\Database $database + * + * @return string */ public function getAddTablesDDL(Database $database) { @@ -419,17 +433,26 @@ public function getDropForeignKeyDDL(ForeignKey $fk) /** * @link http://www.sqlite.org/autoinc.html + * @return string */ public function getAutoIncrement() { return 'PRIMARY KEY AUTOINCREMENT'; } + /** + * @return int + */ public function getMaxColumnNameLength() { return 1024; } + /** + * @param \Propel\Generator\Model\Column $col + * + * @return string + */ public function getColumnDDL(Column $col) { if ($col->isAutoIncrement()) { @@ -450,6 +473,11 @@ public function getColumnDDL(Column $col) return parent::getColumnDDL($col); } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return string + */ public function getAddTableDDL(Table $table) { $table = clone $table; @@ -528,6 +556,11 @@ public function getForeignKeyDDL(ForeignKey $fk) return $script; } + /** + * @param string $sqlType + * + * @return bool + */ public function hasSize($sqlType) { return !in_array($sqlType, [ @@ -547,14 +580,19 @@ public function doQuoting($text) return '[' . strtr($text, ['.' => '].[']) . ']'; } + /** + * @return bool + */ public function supportsSchemas() { return true; } + /** + * @return bool + */ public function supportsNativeDeleteTrigger() { return true; } - } diff --git a/src/Propel/Generator/Reverse/AbstractSchemaParser.php b/src/Propel/Generator/Reverse/AbstractSchemaParser.php index 4c9d089cda..5b922903ee 100644 --- a/src/Propel/Generator/Reverse/AbstractSchemaParser.php +++ b/src/Propel/Generator/Reverse/AbstractSchemaParser.php @@ -218,6 +218,11 @@ protected function getNewVendorInfoObject(array $params) return $vi; } + /** + * @param \Propel\Generator\Platform\PlatformInterface $platform + * + * @return void + */ public function setPlatform($platform) { $this->platform = $platform; diff --git a/src/Propel/Generator/Reverse/MssqlSchemaParser.php b/src/Propel/Generator/Reverse/MssqlSchemaParser.php index e8cf051214..6c444e3b54 100644 --- a/src/Propel/Generator/Reverse/MssqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/MssqlSchemaParser.php @@ -80,6 +80,12 @@ protected function getTypeMapping() return self::$mssqlTypeMap; } + /** + * @param \Propel\Generator\Model\Database $database + * @param array $additionalTables + * + * @return int + */ public function parse(Database $database, array $additionalTables = []) { $dataFetcher = $this->dbh->query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME <> 'dtproperties'"); @@ -164,9 +170,9 @@ protected function addColumns(Table $table) protected function addForeignKeys(Table $table) { $database = $table->getDatabase(); - + $dataFetcher = $this->dbh->query("select fk.name as CONSTRAINT_NAME, lcol.name as COLUMN_NAME, rtab.name as FK_TABLE_NAME, rcol.name as FK_COLUMN_NAME - from sys.foreign_keys as fk + from sys.foreign_keys as fk inner join sys.foreign_key_columns ref on ref.constraint_object_id = fk.object_id inner join sys.columns lcol on lcol.object_id = ref.parent_object_id and lcol.column_id = ref.parent_column_id inner join sys.columns rcol on rcol.object_id = ref.referenced_object_id and rcol.column_id = ref.referenced_column_id diff --git a/src/Propel/Generator/Reverse/MysqlSchemaParser.php b/src/Propel/Generator/Reverse/MysqlSchemaParser.php index a3686793ff..0141783cea 100644 --- a/src/Propel/Generator/Reverse/MysqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/MysqlSchemaParser.php @@ -119,6 +119,12 @@ public function parse(Database $database, array $additionalTables = []) return count($database->getTables()); } + /** + * @param \Propel\Generator\Model\Database $database + * @param \Propel\Generator\Model\Table|null $filterTable + * + * @return void + */ protected function parseTables(Database $database, $filterTable = null) { $sql = 'SHOW FULL TABLES'; @@ -135,7 +141,6 @@ protected function parseTables(Database $database, $filterTable = null) $dataFetcher = $this->dbh->query($sql); // First load the tables (important that this happen before filling out details of tables) - $tables = []; foreach ($dataFetcher as $row) { $name = $row[0]; $type = $row[1]; @@ -150,7 +155,6 @@ protected function parseTables(Database $database, $filterTable = null) $table->setSchema($filterTable->getSchema()); } $database->addTable($table); - $tables[] = $table; } } diff --git a/src/Propel/Generator/Reverse/SqliteSchemaParser.php b/src/Propel/Generator/Reverse/SqliteSchemaParser.php index c30275a9b6..eb3338f3c0 100644 --- a/src/Propel/Generator/Reverse/SqliteSchemaParser.php +++ b/src/Propel/Generator/Reverse/SqliteSchemaParser.php @@ -34,7 +34,7 @@ class SqliteSchemaParser extends AbstractSchemaParser * There really aren't any SQLite native types, so we're just * using the MySQL ones here. * - * @var array + * @var string[] */ private static $sqliteTypeMap = [ 'tinyint' => PropelTypes::TINYINT, @@ -71,13 +71,19 @@ class SqliteSchemaParser extends AbstractSchemaParser /** * Gets a type mapping from native types to Propel types * - * @return array + * @return string[] */ protected function getTypeMapping() { return self::$sqliteTypeMap; } + /** + * @param \Propel\Generator\Model\Database $database + * @param Table[] $additionalTables + * + * @return int + */ public function parse(Database $database, array $additionalTables = []) { if ($this->getGeneratorConfig()) { @@ -104,6 +110,12 @@ public function parse(Database $database, array $additionalTables = []) return count($database->getTables()); } + /** + * @param \Propel\Generator\Model\Database $database + * @param \Propel\Generator\Model\Table|null $filterTable + * + * @return void + */ protected function parseTables(Database $database, Table $filterTable = null) { $sql = " diff --git a/src/Propel/Generator/Util/BehaviorLocator.php b/src/Propel/Generator/Util/BehaviorLocator.php index 16d1aeb78b..851ac2adc6 100644 --- a/src/Propel/Generator/Util/BehaviorLocator.php +++ b/src/Propel/Generator/Util/BehaviorLocator.php @@ -27,12 +27,12 @@ class BehaviorLocator * * @var GeneratorConfigInterface */ - private $generatorConfig = null; + private $generatorConfig; /** * Creates the composer finder * - * @param GeneratorConfigInterface $config build config + * @param GeneratorConfigInterface|null $config build config */ public function __construct(GeneratorConfigInterface $config = null) { @@ -93,9 +93,9 @@ private function findComposerJson() /** * Returns the directories to search the composer lock file in * - * @return array[string] + * @return string[] */ - private function getSearchDirs() + private function getSearchDirs(): array { return [ getcwd(), diff --git a/src/Propel/Generator/Util/QuickBuilder.php b/src/Propel/Generator/Util/QuickBuilder.php index d8a98f55a2..6f28f65219 100644 --- a/src/Propel/Generator/Util/QuickBuilder.php +++ b/src/Propel/Generator/Util/QuickBuilder.php @@ -180,6 +180,15 @@ public static function buildSchema($schema, $dsn = null, $user = null, $pass = n return $builder->build($dsn, $user, $pass, $adapter); } + /** + * @param string|null $dsn + * @param string|null $user + * @param string|null $pass + * @param \Propel\Runtime\Adapter\AdapterInterface|null $adapter + * @param array|null $classTargets + * + * @return \Propel\Runtime\Connection\ConnectionWrapper + */ public function build($dsn = null, $user = null, $pass = null, $adapter = null, array $classTargets = null) { if (null === $dsn) { @@ -194,6 +203,7 @@ public function build($dsn = null, $user = null, $pass = null, $adapter = null, $pdo = new PdoConnection($dsn, $user, $pass); $con = new ConnectionWrapper($pdo); $con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING); + /** @var SqliteAdapter $adapter */ $adapter->initConnection($con, []); $this->buildSQL($con); $this->buildClasses($classTargets); @@ -204,6 +214,9 @@ public function build($dsn = null, $user = null, $pass = null, $adapter = null, return $con; } + /** + * @return \Propel\Generator\Model\Database|null + */ public function getDatabase() { if (null === $this->database) { @@ -216,6 +229,12 @@ public function getDatabase() return $this->database; } + /** + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * + * @throws \Exception + * @return int + */ public function buildSQL(ConnectionInterface $con) { $sql = $this->getSQL(); @@ -239,6 +258,12 @@ public function buildSQL(ConnectionInterface $con) return count($statements); } + /** + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * + * @throws \Propel\Generator\Exception\BuildException + * @return \Propel\Generator\Model\Database|null + */ public function updateDB(ConnectionInterface $con) { $database = $this->readConnectedDatabase(); @@ -283,11 +308,19 @@ public function readConnectedDatabase() return $database; } + /** + * @return string + */ public function getSQL() { return $this->getPlatform()->getAddTablesDDL($this->getDatabase()); } + /** + * @param string[]|null $classTargets + * + * @return string + */ public function getBuildName($classTargets = null) { $tables = []; @@ -306,7 +339,7 @@ public function getBuildName($classTargets = null) } /** - * @param array $classTargets array('tablemap', 'object', 'query', 'objectstub', 'querystub') + * @param string[]|null $classTargets array('tablemap', 'object', 'query', 'objectstub', 'querystub') * @param bool $separate pass true to get for each class a own file. better for debugging. */ public function buildClasses(array $classTargets = null, $separate = false) @@ -354,6 +387,11 @@ public function buildClasses(array $classTargets = null, $separate = false) } } + /** + * @param string[]|null $classTargets + * + * @return string + */ public function getClasses(array $classTargets = null) { $script = ''; @@ -364,6 +402,12 @@ public function getClasses(array $classTargets = null) return $script; } + /** + * @param \Propel\Generator\Model\Table $table + * @param string[]|null $classTargets + * + * @return string + */ public function getClassesForTable(Table $table, array $classTargets = null) { if (null === $classTargets) { @@ -415,6 +459,12 @@ public function getClassesForTable(Table $table, array $classTargets = null) return $script; } + /** + * @param string $schema + * @param string $tableName + * + * @return void + */ public static function debugClassesForTable($schema, $tableName) { $builder = new self; diff --git a/src/Propel/Generator/Util/SqlParser.php b/src/Propel/Generator/Util/SqlParser.php index 1a2b75a259..6446899f2b 100644 --- a/src/Propel/Generator/Util/SqlParser.php +++ b/src/Propel/Generator/Util/SqlParser.php @@ -165,11 +165,17 @@ public static function parseFile($file) return self::parseString(file_get_contents($file)); } + /** + * @return void + */ public function convertLineFeedsToUnixStyle() { $this->setSQL(str_replace(["\r\n", "\r"], "\n", $this->sql)); } + /** + * @return void + */ public function stripSQLCommentLines() { $this->setSQL(preg_replace([ diff --git a/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php b/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php index 971ad3a7f7..47d174e42a 100644 --- a/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php @@ -147,6 +147,9 @@ public function setModelName($modelName) return $this; } + /** + * @return string + */ public function getFullyQualifiedModelName() { return '\\' . $this->getModelName(); diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index d48ffa19f0..4ec68a42b6 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -906,7 +906,7 @@ public function combine($criterions = [], $operator = self::LOGICAL_AND, $name = * * @param string|array $left A String with the left side of the join. * @param string|array $right A String with the right side of the join. - * @param mixed $joinType A String with the join operator + * @param string|null $joinType A String with the join operator * among Criteria::INNER_JOIN, Criteria::LEFT_JOIN, * and Criteria::RIGHT_JOIN * @@ -966,7 +966,7 @@ public function addJoin($left, $right, $joinType = null) * * @see addJoin() * @param array $conditions An array of conditions, each condition being an array (left, right, operator) - * @param string $joinType A String with the join operator. Defaults to an implicit join. + * @param string|null $joinType A String with the join operator. Defaults to an implicit join. * * @return $this A modified Criteria object. */ @@ -1076,7 +1076,7 @@ public function hasJoin($name) * Adds a Criteria as subQuery in the From Clause. * * @param Criteria $subQueryCriteria Criteria to build the subquery from - * @param string $alias alias for the subQuery + * @param string|null $alias alias for the subQuery * * @return $this this modified Criteria object (Fluid API) */ @@ -1132,6 +1132,9 @@ public function hasSelectQuery($alias) return isset($this->selectQueries[$alias]); } + /** + * @return int + */ public function forgeSelectQueryAlias() { $aliasNumber = 0; @@ -2105,6 +2108,11 @@ public function quoteIdentifier($string, $tableName = '') return $string; } + /** + * @param string $string + * + * @return string + */ public function quoteIdentifierTable($string) { $realTableName = $string; @@ -2313,6 +2321,11 @@ public function doInsert(ConnectionInterface $con = null) return $id; } + /** + * @param \Propel\Runtime\ActiveQuery\Criteria|null $criteria + * + * @return \Propel\Runtime\Map\ColumnMap|null + */ public function getPrimaryKey(Criteria $criteria = null) { if (!$criteria) { @@ -2480,6 +2493,12 @@ public function doUpdate($updateValues, ConnectionInterface $con) return $affectedRows; } + /** + * @param string[] $columns + * @param \Propel\Runtime\ActiveQuery\Criteria|null $values + * + * @return array + */ public function buildParams($columns, Criteria $values = null) { if (!$values) { @@ -2500,6 +2519,13 @@ public function buildParams($columns, Criteria $values = null) return $params; } + /** + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con + * + * @throws \Propel\Runtime\Exception\LogicException + * @throws \Propel\Runtime\Exception\PropelException + * @return \Propel\Runtime\DataFetcher\DataFetcherInterface + */ public function doCount(ConnectionInterface $con = null) { $dbMap = Propel::getServiceContainer()->getDatabaseMap($this->getDbName()); @@ -2667,6 +2693,9 @@ public function doSelect(ConnectionInterface $con = null) // Fluid operators + /** + * @return $this + */ public function _or() { $this->defaultCombineOperator = Criteria::LOGICAL_OR; @@ -2674,6 +2703,9 @@ public function _or() return $this; } + /** + * @return $this + */ public function _and() { $this->defaultCombineOperator = Criteria::LOGICAL_AND; diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php index 5b670f02a9..04877a8133 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php @@ -80,7 +80,7 @@ abstract class AbstractCriterion * @param Criteria $outer The outer class (this is an "inner" class). * @param string $column TABLE.COLUMN format. * @param mixed $value - * @param string $comparison + * @param string|null $comparison */ public function __construct(Criteria $outer, $column, $value, $comparison = null) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php index a9f4ea9832..a67cfbec1a 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php @@ -29,7 +29,7 @@ * @param string $clause A simple pseudo-SQL clause, e.g. 'foo.BAR LIKE ?' * @param ColumnMap $column A Column object to help escaping the value * @param mixed $value - * @param string $tableAlias optional table alias + * @param string|null $tableAlias optional table alias */ public function __construct(Criteria $outer, $clause, $column, $value = null, $tableAlias = null) { @@ -42,6 +42,9 @@ public function __construct(Criteria $outer, $clause, $column, $value = null, $t $this->init($outer); } + /** + * @return string + */ public function getClause() { return $this->clause; diff --git a/src/Propel/Runtime/ActiveQuery/InstancePoolTrait.php b/src/Propel/Runtime/ActiveQuery/InstancePoolTrait.php index 2a598aeb52..5ff32bf89f 100644 --- a/src/Propel/Runtime/ActiveQuery/InstancePoolTrait.php +++ b/src/Propel/Runtime/ActiveQuery/InstancePoolTrait.php @@ -14,8 +14,17 @@ trait InstancePoolTrait { + /** + * @var object[] + */ public static $instances = []; + /** + * @param object $object + * @param string|null $key + * + * @return void + */ public static function addInstanceToPool($object, $key = null) { if (Propel::isInstancePoolingEnabled()) { @@ -27,6 +36,11 @@ public static function addInstanceToPool($object, $key = null) } } + /** + * @param mixed $value + * + * @return string + */ public static function getInstanceKey($value) { if (!($value instanceof Criteria) && is_object($value)) { @@ -45,6 +59,11 @@ public static function getInstanceKey($value) } } + /** + * @param mixed $value + * + * @return void + */ public static function removeInstanceFromPool($value) { if (Propel::isInstancePoolingEnabled() && null !== $value) { @@ -57,6 +76,11 @@ public static function removeInstanceFromPool($value) } } + /** + * @param string $key + * + * @return object|null + */ public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { @@ -68,11 +92,17 @@ public static function getInstanceFromPool($key) return null; } + /** + * @return void + */ public static function clearInstancePool() { self::$instances = []; } + /** + * @return void + */ public static function clearRelatedInstancePool() { } diff --git a/src/Propel/Runtime/ActiveQuery/Join.php b/src/Propel/Runtime/ActiveQuery/Join.php index 28cc8845c7..911ffdce1d 100644 --- a/src/Propel/Runtime/ActiveQuery/Join.php +++ b/src/Propel/Runtime/ActiveQuery/Join.php @@ -45,7 +45,11 @@ class Join // the right parts of the join condition protected $right = []; - // the comparison operators for each pair of columns in the join condition + /** + * The comparison operators for each pair of columns in the join condition + * + * @var string[] + */ protected $operators = []; // the type of the join (LEFT JOIN, ...) @@ -136,7 +140,7 @@ public function addCondition($left, $right, $operator = self::EQUAL) * * @param array $lefts The left columns of the join condition * @param array $rights The right columns of the join condition - * @param array $operators The comparison operators of the join condition, default Join::EQUAL + * @param string[] $operators The comparison operators of the join condition, default Join::EQUAL * @throws \Propel\Runtime\Exception\LogicException */ public function addConditions($lefts, $rights, $operators = []) @@ -193,11 +197,11 @@ public function addExplicitCondition( /** * @param string $leftTableName * @param string $leftColumnName - * @param mixed $leftTableAlias + * @param string|null $leftTableAlias * @param mixed $leftColumnValue * @param string $operator */ - public function addLocalValueCondition($leftTableName, $leftColumnName, $leftTableAlias = null, $leftColumnValue, $operator = self::EQUAL) + public function addLocalValueCondition($leftTableName, $leftColumnName, $leftTableAlias, $leftColumnValue, $operator = self::EQUAL) { $this->leftTableName = $leftTableName; $this->leftTableAlias = $leftTableAlias; @@ -209,7 +213,16 @@ public function addLocalValueCondition($leftTableName, $leftColumnName, $leftTab $this->count++; } - public function addForeignValueCondition($rightTableName, $rightColumnName, $rightTableAlias = null, $rightColumnValue, $operator = self::EQUAL) + /** + * @param string $rightTableName + * @param string $rightColumnName + * @param string|null $rightTableAlias + * @param mixed $rightColumnValue + * @param string $operator + * + * @return void + */ + public function addForeignValueCondition($rightTableName, $rightColumnName, $rightTableAlias, $rightColumnValue, $operator = self::EQUAL) { $this->rightTableName = $rightTableName; $this->rightTableAlias = $rightTableAlias; @@ -253,7 +266,7 @@ public function getConditions() /** * @param string $operator the comparison operator for the join condition */ - public function addOperator($operator = null) + public function addOperator($operator) { $this->operators[] = $operator; } @@ -267,6 +280,9 @@ public function getOperator($index = 0) return $this->operators[$index]; } + /** + * @return string[] + */ public function getOperators() { return $this->operators; diff --git a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php index f174ee0bb6..081249a0e8 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php @@ -688,6 +688,9 @@ public function with($relation) return $this; } + /** + * @return bool + */ public function isWithOneToMany() { return $this->isWithOneToMany; @@ -978,12 +981,18 @@ public function isKeepQuery() * Code to execute before every SELECT statement * * @param ConnectionInterface $con The connection object used by the query + * @return void */ protected function basePreSelect(ConnectionInterface $con) { - return $this->preSelect($con); + $this->preSelect($con); } + /** + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * + * @return void + */ protected function preSelect(ConnectionInterface $con) { } @@ -993,7 +1002,7 @@ protected function preSelect(ConnectionInterface $con) * and format the list of results with the current formatter * By default, returns an array of model objects * - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return ObjectCollection|ActiveRecordInterface[]|array|mixed the list of results, formatted by the current formatter */ @@ -1019,7 +1028,7 @@ public function find(ConnectionInterface $con = null) * * Does not work with ->with()s containing one-to-many relations. * - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return mixed the result, formatted by the current formatter */ @@ -1053,7 +1062,7 @@ public function findOne(ConnectionInterface $con = null) * Throws an exception when nothing was found. * * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return mixed the result, formatted by the current formatter * @throws EntityNotFoundException|\Exception When nothing is found @@ -1078,7 +1087,7 @@ public function requirePk($key, ConnectionInterface $con = null) * * Does not work with ->with()s containing one-to-many relations. * - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return mixed the result, formatted by the current formatter * @throws EntityNotFoundException|\Exception When nothing is found @@ -1104,7 +1113,7 @@ public function requireOne(ConnectionInterface $con = null) * * @param mixed $column A string representing the column phpName, e.g. 'AuthorId' * @param mixed $value A value for the condition - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return mixed the result, formatted by the current formatter * @throws EntityNotFoundException|\Exception When nothing is found @@ -1132,7 +1141,7 @@ public function requireOneBy($column, $value, ConnectionInterface $con = null) * @see requireOne() * * @param mixed $conditions An array of conditions, using column phpNames as key - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return mixed the list of results, formatted by the current formatter */ @@ -1147,6 +1156,10 @@ public function requireOneByArray($conditions, ConnectionInterface $con = null) return $result; } + /** + * @throws \Propel\Runtime\Exception\PropelException + * @return \Exception + */ private function createEntityNotFoundException() { if (!isset($this->entityNotFoundExceptionClass)) { @@ -1161,7 +1174,7 @@ private function createEntityNotFoundException() * and format the result with the current formatter * By default, returns a model object * - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return mixed the result, formatted by the current formatter * @@ -1196,7 +1209,7 @@ public function findOneOrCreate(ConnectionInterface $con = null) * $bookOpinion = $c->findPk(array(34, 634), $con); * * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return mixed the result, formatted by the current formatter */ @@ -1236,7 +1249,7 @@ public function findPk($key, ConnectionInterface $con = null) * $bookOpinion = $c->findPks(array(array(34, 634), array(45, 518), array(34, 765)), $con); * * @param array $keys Primary keys to use for the query - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return mixed the list of results, formatted by the current formatter * @@ -1272,7 +1285,7 @@ public function findPks($keys, ConnectionInterface $con = null) * * @param string $column A string representing the column phpName, e.g. 'AuthorId' * @param mixed $value A value for the condition - * @param ConnectionInterface $con An optional connection object + * @param ConnectionInterface|null $con An optional connection object * * @return mixed the list of results, formatted by the current formatter */ @@ -1297,7 +1310,7 @@ public function findBy($column, $value, ConnectionInterface $con = null) * @see find() * * @param mixed $conditions An array of conditions, using column phpNames as key - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return mixed the list of results, formatted by the current formatter */ @@ -1316,7 +1329,7 @@ public function findByArray($conditions, ConnectionInterface $con = null) * * @param mixed $column A string representing thecolumn phpName, e.g. 'AuthorId' * @param mixed $value A value for the condition - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return mixed the result, formatted by the current formatter */ @@ -1341,7 +1354,7 @@ public function findOneBy($column, $value, ConnectionInterface $con = null) * @see findOne() * * @param mixed $conditions An array of conditions, using column phpNames as key - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return mixed the list of results, formatted by the current formatter */ @@ -1355,7 +1368,7 @@ public function findOneByArray($conditions, ConnectionInterface $con = null) /** * Issue a SELECT COUNT(*) query based on the current ModelCriteria * - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return integer the number of results */ @@ -1387,6 +1400,11 @@ public function count(ConnectionInterface $con = null) return $count; } + /** + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con + * + * @return \Propel\Runtime\DataFetcher\DataFetcherInterface + */ public function doCount(ConnectionInterface $con = null) { $this->configureSelectColumns(); @@ -1402,7 +1420,7 @@ public function doCount(ConnectionInterface $con = null) /** * Issue an existence check on the current ModelCriteria * - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return bool column existence */ @@ -1439,7 +1457,7 @@ public function exists(ConnectionInterface $con = null) * * @param int $page number of the page to start the pager on. Page 1 means no offset * @param int $maxPerPage maximum number of results per page. Determines the limit - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return PropelModelPager a pager object, supporting iteration */ @@ -1497,7 +1515,7 @@ protected function postDelete($affectedRows, ConnectionInterface $con) * Issue a DELETE query based on the current ModelCriteria * An optional hook on basePreDelete() can prevent the actual deletion * - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return integer the number of deleted rows * @@ -1535,7 +1553,7 @@ public function delete(ConnectionInterface $con = null) * Issue a DELETE query based on the current ModelCriteria deleting all rows in the table * An optional hook on basePreDelete() can prevent the actual deletion * - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * * @return integer the number of deleted rows * @@ -1564,7 +1582,7 @@ public function deleteAll(ConnectionInterface $con = null) * Issue a DELETE query based on the current ModelCriteria deleting all rows in the table * This method is called by ModelCriteria::deleteAll() inside a transaction * - * @param ConnectionInterface $con a connection object + * @param ConnectionInterface|null $con a connection object * * @return integer the number of deleted rows * @@ -1655,7 +1673,7 @@ protected function postUpdate($affectedRows, ConnectionInterface $con) * will only be triggered if you force individual saves, i.e. if you pass true as second argument. * * @param mixed $values Associative array of keys and values to replace - * @param ConnectionInterface $con an optional connection object + * @param ConnectionInterface|null $con an optional connection object * @param boolean $forceIndividualSaves If false (default), the resulting call is a Criteria::doUpdate(), otherwise it is a series of save() calls on all the found objects * * @return integer Number of updated rows @@ -1747,7 +1765,7 @@ public function doUpdate($values, ConnectionInterface $con, $forceIndividualSave * Creates a Criterion object based on a list of existing condition names and a comparator * * @param array $conditions The list of condition names, e.g. array('cond1', 'cond2') - * @param string $operator An operator, Criteria::LOGICAL_AND (default) or Criteria::LOGICAL_OR + * @param string|null $operator An operator, Criteria::LOGICAL_AND (default) or Criteria::LOGICAL_OR * * @return AbstractCriterion A Criterion or ModelCriterion object */ @@ -1766,7 +1784,10 @@ protected function getCriterionForConditions($conditions, $operator = null) * Uses introspection to translate the column phpName into a fully qualified name * * @param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?' - * @param mixed $value A value for the condition + * @param mixed $value A value for the condition + * @param int|null $bindingType + * + * @throws \Propel\Runtime\Exception\PropelException * * @return AbstractCriterion a Criterion object */ @@ -1827,7 +1848,7 @@ protected function getCriterionForClause($clause, $value, $bindingType = null) */ protected function convertValueForColumn($value, ColumnMap $colMap) { - if ($colMap->getType() == 'OBJECT' && is_object($value)) { + if ($colMap->getType() === 'OBJECT' && is_object($value)) { if (is_array($value)) { $value = array_map('serialize', $value); } else { @@ -1999,6 +2020,9 @@ public function doSelect(ConnectionInterface $con = null) return parent::doSelect($con); } + /** + * @return void + */ public function configureSelectColumns() { if (is_null($this->select)) { @@ -2034,10 +2058,14 @@ public function configureSelectColumns() } - /** * Special case for subquery columns * + * @param string $class + * @param string $phpName + * @param bool $failSilently + * + * @throws \Propel\Runtime\Exception\PropelException * @return array List($columnMap, $realColumnName) */ protected function getColumnFromSubQuery($class, $phpName, $failSilently = true) @@ -2049,14 +2077,16 @@ protected function getColumnFromSubQuery($class, $phpName, $failSilently = true) $realColumnName = $class.'.'.$column->getName(); return [$column, $realColumnName]; - } elseif (isset($subQueryCriteria->asColumns[$phpName])) { + } + if (isset($subQueryCriteria->asColumns[$phpName])) { // aliased column return [null, $class.'.'.$phpName]; - } elseif ($failSilently) { + } + if ($failSilently) { return [null, null]; - } else { - throw new PropelException(sprintf('Unknown column "%s" in the subQuery with alias "%s".', $phpName, $class)); } + + throw new PropelException(sprintf('Unknown column "%s" in the subQuery with alias "%s".', $phpName, $class)); } /** diff --git a/src/Propel/Runtime/ActiveQuery/ModelJoin.php b/src/Propel/Runtime/ActiveQuery/ModelJoin.php index d652e02974..86e3034b04 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelJoin.php +++ b/src/Propel/Runtime/ActiveQuery/ModelJoin.php @@ -108,6 +108,11 @@ public function getTableMap() return $this->tableMap; } + /** + * @param \Propel\Runtime\ActiveQuery\ModelJoin $join + * + * @return $this + */ public function setPreviousJoin(ModelJoin $join) { $this->previousJoin = $join; @@ -123,26 +128,43 @@ public function getPreviousJoin() return $this->previousJoin; } + /** + * @return bool + */ public function isPrimary() { return null === $this->previousJoin; } + /** + * @param string $relationAlias + * + * @return \Propel\Runtime\ActiveQuery\ModelJoin + */ public function setRelationAlias($relationAlias) { return $this->setRightTableAlias($relationAlias); } + /** + * @return string|null + */ public function getRelationAlias() { return $this->getRightTableAlias(); } + /** + * @return bool + */ public function hasRelationAlias() { return $this->hasRightTableAlias(); } + /** + * @return bool|null + */ public function isIdentifierQuotingEnabled() { return $this->getTableMap()->isIdentifierQuotingEnabled(); @@ -172,6 +194,11 @@ public function getObjectToRelate($startObject) return $previousObject->$method(); } + /** + * @param \Propel\Runtime\ActiveQuery\Join|null $join + * + * @return bool + */ public function equals($join) { /** @var ModelJoin $join */ @@ -183,6 +210,9 @@ public function equals($join) ; } + /** + * @return string + */ public function __toString() { return parent::toString() diff --git a/src/Propel/Runtime/ActiveQuery/ModelWith.php b/src/Propel/Runtime/ActiveQuery/ModelWith.php index 02250cfdc9..a46aa2faa2 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelWith.php +++ b/src/Propel/Runtime/ActiveQuery/ModelWith.php @@ -20,26 +20,59 @@ */ class ModelWith { + /** + * @var string + */ protected $modelName; + /** + * @var \Propel\Runtime\Map\TableMap + */ protected $getTableMap; + /** + * @var bool + */ protected $isSingleTableInheritance = false; + /** + * @var bool + */ protected $isAdd = false; + /** + * @var bool + */ protected $isWithOneToMany = false; + /** + * @var string + */ protected $relationName; + /** + * @var string + */ protected $relationMethod; + /** + * @var string + */ protected $initMethod; + /** + * @var string + */ protected $resetPartialMethod = ''; + /** + * @var string + */ protected $leftPhpName; + /** + * @var string + */ protected $rightPhpName; public function __construct(ModelJoin $join = null) @@ -81,6 +114,11 @@ public function init(ModelJoin $join) // DataObject getters & setters + /** + * @param string $modelName + * + * @return void + */ public function setModelName($modelName) { if (0 === strpos($modelName, '\\')) { @@ -90,101 +128,179 @@ public function setModelName($modelName) } } + /** + * @return \Propel\Runtime\Map\TableMap + */ public function getTableMap() { return $this->getTableMap; } + /** + * @return string + */ public function getModelName() { return $this->modelName; } + /** + * @param bool $isSingleTableInheritance + * + * @return void + */ public function setIsSingleTableInheritance($isSingleTableInheritance) { $this->isSingleTableInheritance = $isSingleTableInheritance; } + /** + * @return bool + */ public function isSingleTableInheritance() { return $this->isSingleTableInheritance; } + /** + * @param bool $isAdd + * + * @return void + */ public function setIsAdd($isAdd) { $this->isAdd = $isAdd; } + /** + * @return bool + */ public function isAdd() { return $this->isAdd; } + /** + * @param bool $isWithOneToMany + * + * @return void + */ public function setIsWithOneToMany($isWithOneToMany) { $this->isWithOneToMany = $isWithOneToMany; } + /** + * @return bool + */ public function isWithOneToMany() { return $this->isWithOneToMany; } + /** + * @param string $relationName + * + * @return void + */ public function setRelationName($relationName) { $this->relationName = $relationName; } + /** + * @return string + */ public function getRelationName() { return $this->relationName; } + /** + * @param string $relationMethod + * + * @return void + */ public function setRelationMethod($relationMethod) { $this->relationMethod = $relationMethod; } + /** + * @return string + */ public function getRelationMethod() { return $this->relationMethod; } + /** + * @param string $initMethod + * + * @return void + */ public function setInitMethod($initMethod) { $this->initMethod = $initMethod; } + /** + * @return string + */ public function getInitMethod() { return $this->initMethod; } + /** + * @param string $resetPartialMethod + * + * @return void + */ public function setResetPartialMethod($resetPartialMethod) { $this->resetPartialMethod = $resetPartialMethod; } + /** + * @return string + */ public function getResetPartialMethod() { return $this->resetPartialMethod; } + /** + * @param string $leftPhpName + * + * @return void + */ public function setLeftPhpName($leftPhpName) { $this->leftPhpName = $leftPhpName; } + /** + * @return string + */ public function getLeftPhpName() { return $this->leftPhpName; } + /** + * @param string $rightPhpName + * + * @return void + */ public function setRightPhpName($rightPhpName) { $this->rightPhpName = $rightPhpName; } + /** + * @return string + */ public function getRightPhpName() { return $this->rightPhpName; @@ -192,11 +308,17 @@ public function getRightPhpName() // Utility methods + /** + * @return bool + */ public function isPrimary() { return null === $this->leftPhpName; } + /** + * @return string + */ public function __toString() { return sprintf('modelName: %s, relationName: %s, relationMethod: %s, leftPhpName: %s, rightPhpName: %s', $this->modelName, $this->relationName, $this->relationMethod, $this->leftPhpName, $this->rightPhpName); diff --git a/src/Propel/Runtime/ActiveRecord/NestedSetRecursiveIterator.php b/src/Propel/Runtime/ActiveRecord/NestedSetRecursiveIterator.php index 0693c49eed..9a798efb4c 100644 --- a/src/Propel/Runtime/ActiveRecord/NestedSetRecursiveIterator.php +++ b/src/Propel/Runtime/ActiveRecord/NestedSetRecursiveIterator.php @@ -36,21 +36,33 @@ public function __construct($node) $this->curNode = $node; } + /** + * @return void + */ public function rewind() { $this->curNode = $this->topNode; } + /** + * @return bool + */ public function valid() { return null !== $this->curNode; } + /** + * @return mixed + */ public function current() { return $this->curNode; } + /** + * @return string + */ public function key() { $method = method_exists($this->curNode, 'getPath') ? 'getPath' : 'getAncestors'; @@ -62,6 +74,9 @@ public function key() return implode('.', $key); } + /** + * @return void + */ public function next() { $nextNode = null; @@ -80,15 +95,19 @@ public function next() } $this->curNode = $nextNode; } - - return $this->curNode; } + /** + * @return bool + */ public function hasChildren() { return $this->curNode->hasChildren(); } + /** + * @return \Propel\Runtime\ActiveRecord\NestedSetRecursiveIterator|\RecursiveIterator + */ public function getChildren() { $method = method_exists($this->curNode, 'retrieveFirstChild') ? 'retrieveFirstChild' : 'getFirstChild'; diff --git a/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php b/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php index 432d8ded51..e643cc1cbd 100644 --- a/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php @@ -34,6 +34,12 @@ public function setCharset(ConnectionInterface $con, $charset) { } + /** + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * @param array $settings + * + * @return void + */ public function initConnection(ConnectionInterface $con, array $settings) { $con->query('PRAGMA foreign_keys = ON'); diff --git a/src/Propel/Runtime/Collection/Collection.php b/src/Propel/Runtime/Collection/Collection.php index 57320fe40d..dd311c7809 100644 --- a/src/Propel/Runtime/Collection/Collection.php +++ b/src/Propel/Runtime/Collection/Collection.php @@ -438,6 +438,10 @@ public function getFullyQualifiedModel() return $this->fullyQualifiedModel; } + /** + * @throws \Propel\Runtime\Collection\Exception\ModelNotFoundException + * @return string + */ public function getTableMapClass() { $model = $this->getModel(); @@ -582,6 +586,9 @@ public function __clone() } } + /** + * @return \Propel\Common\Pluralizer\PluralizerInterface|null + */ protected function getPluralizer() { if ($this->pluralizer === null) { @@ -593,17 +600,25 @@ protected function getPluralizer() /** * Overwrite this method if you want to use a custom pluralizer + * + * @return PluralizerInterface */ protected function createPluralizer() { return new StandardEnglishPluralizer(); } + /** + * @return string + */ protected function getPluralModelName() { return $this->getPluralizer()->getPluralForm($this->getModel()); } + /** + * @return string + */ public function hashCode() { return spl_object_hash($this); diff --git a/src/Propel/Runtime/Collection/CollectionIterator.php b/src/Propel/Runtime/Collection/CollectionIterator.php index 970c546748..43ed32b5c5 100644 --- a/src/Propel/Runtime/Collection/CollectionIterator.php +++ b/src/Propel/Runtime/Collection/CollectionIterator.php @@ -187,6 +187,12 @@ public function isEven() return !$this->isOdd(); } + /** + * @param string $index + * @param string $newval + * + * @return void + */ public function offsetSet($index, $newval) { $this->collection->offsetSet($index, $newval); @@ -194,6 +200,11 @@ public function offsetSet($index, $newval) $this->refreshPositions(); } + /** + * @param string $index + * + * @return void + */ public function offsetUnset($index) { $this->collection->offsetUnset($index); @@ -201,6 +212,11 @@ public function offsetUnset($index) $this->refreshPositions(); } + /** + * @param mixed $value + * + * @return void + */ public function append($value) { $this->collection->append($value); @@ -208,42 +224,67 @@ public function append($value) $this->refreshPositions(); } + /** + * @return void + */ public function asort() { parent::asort(); $this->refreshPositions(); } + /** + * @return void + */ public function ksort() { parent::ksort(); $this->refreshPositions(); } + /** + * @param string $cmp_function + * + * @return void + */ public function uasort($cmp_function) { parent::uasort($cmp_function); $this->refreshPositions(); } + /** + * @param string $cmp_function + * + * @return void + */ public function uksort($cmp_function) { parent::uksort($cmp_function); $this->refreshPositions(); } + /** + * @return void + */ public function natsort() { parent::natsort(); $this->refreshPositions(); } + /** + * @return void + */ public function natcasesort() { parent::natcasesort(); $this->refreshPositions(); } + /** + * @return void + */ private function refreshPositions() { $this->positions = array_flip(array_keys($this->getArrayCopy())); diff --git a/src/Propel/Runtime/Collection/ObjectCollection.php b/src/Propel/Runtime/Collection/ObjectCollection.php index bd2a0eab88..3baa74beee 100644 --- a/src/Propel/Runtime/Collection/ObjectCollection.php +++ b/src/Propel/Runtime/Collection/ObjectCollection.php @@ -50,6 +50,11 @@ public function exchangeArray($input) $this->rebuildIndex(); } + /** + * @param array $data + * + * @return void + */ public function setData($data) { parent::setData($data); @@ -390,6 +395,9 @@ public function search($element) return false; } + /** + * @return void + */ protected function rebuildIndex() { $this->index = []; diff --git a/src/Propel/Runtime/Collection/OnDemandCollection.php b/src/Propel/Runtime/Collection/OnDemandCollection.php index 75bfd37a05..ef32f25cd8 100644 --- a/src/Propel/Runtime/Collection/OnDemandCollection.php +++ b/src/Propel/Runtime/Collection/OnDemandCollection.php @@ -186,21 +186,43 @@ public function count() // ArrayObject methods + /** + * @param mixed $value + * + * @throws \Propel\Runtime\Collection\Exception\ReadOnlyModelException + * @return void + */ public function append($value) { throw new ReadOnlyModelException('The On Demand Collection is read only'); } + /** + * @param mixed $value + * + * @throws \Propel\Runtime\Collection\Exception\ReadOnlyModelException + * @return int + */ public function prepend($value) { throw new ReadOnlyModelException('The On Demand Collection is read only'); } + /** + * @param array $input + * + * @throws \Propel\Runtime\Collection\Exception\ReadOnlyModelException + * @return void + */ public function exchangeArray($input) { throw new ReadOnlyModelException('The On Demand Collection is read only'); } + /** + * @throws \Propel\Runtime\Exception\PropelException + * @return array + */ public function getArrayCopy() { throw new PropelException('The On Demand Collection does not allow access by offset'); diff --git a/src/Propel/Runtime/Collection/OnDemandIterator.php b/src/Propel/Runtime/Collection/OnDemandIterator.php index 8a68fc1815..c870d9a6b4 100644 --- a/src/Propel/Runtime/Collection/OnDemandIterator.php +++ b/src/Propel/Runtime/Collection/OnDemandIterator.php @@ -54,6 +54,9 @@ public function __construct(AbstractFormatter $formatter, DataFetcherInterface $ $this->enableInstancePoolingOnFinish = Propel::disableInstancePooling(); } + /** + * @return void + */ public function closeCursor() { $this->dataFetcher->close(); diff --git a/src/Propel/Runtime/Connection/ConnectionFactory.php b/src/Propel/Runtime/Connection/ConnectionFactory.php index 0389ff0fc1..82cfca04a8 100644 --- a/src/Propel/Runtime/Connection/ConnectionFactory.php +++ b/src/Propel/Runtime/Connection/ConnectionFactory.php @@ -30,7 +30,7 @@ class ConnectionFactory * @throws \Propel\Runtime\Exception\InvalidArgumentException * @throws Exception\ConnectionException */ - public static function create(array $configuration = [], AdapterInterface $adapter, $defaultConnectionClass = self::DEFAULT_CONNECTION_CLASS) + public static function create(array $configuration, AdapterInterface $adapter, $defaultConnectionClass = self::DEFAULT_CONNECTION_CLASS) { if (isset($configuration['classname'])) { $connectionClass = $configuration['classname']; diff --git a/src/Propel/Runtime/Connection/ConnectionManagerInterface.php b/src/Propel/Runtime/Connection/ConnectionManagerInterface.php index 132c2478d8..783ca39316 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerInterface.php @@ -25,14 +25,14 @@ public function setName($name); public function getName(); /** - * @param \Propel\Runtime\Adapter\AdapterInterface $adapter + * @param \Propel\Runtime\Adapter\AdapterInterface|null $adapter * * @return \Propel\Runtime\Connection\ConnectionInterface */ public function getWriteConnection(AdapterInterface $adapter = null); /** - * @param \Propel\Runtime\Adapter\AdapterInterface $adapter + * @param \Propel\Runtime\Adapter\AdapterInterface|null $adapter * * @return \Propel\Runtime\Connection\ConnectionInterface */ diff --git a/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php b/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php index bb160cf43d..565dd89fdd 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php @@ -153,7 +153,7 @@ public function getWriteConnection(AdapterInterface $adapter = null) * If no replica connection exist yet, choose one configuration randomly in the * read configuration to open it. * - * @param \Propel\Runtime\Adapter\AdapterInterface $adapter + * @param \Propel\Runtime\Adapter\AdapterInterface|null $adapter * * @return \Propel\Runtime\Connection\ConnectionInterface */ @@ -181,6 +181,9 @@ public function getReadConnection(AdapterInterface $adapter = null) return $this->readConnection; } + /** + * @return void + */ public function closeConnections() { $this->writeConnection = null; diff --git a/src/Propel/Runtime/Connection/ConnectionManagerSingle.php b/src/Propel/Runtime/Connection/ConnectionManagerSingle.php index 69adfe80b0..fe1c075790 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerSingle.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerSingle.php @@ -48,31 +48,48 @@ public function getName() return $this->name; } + /** + * @return array + */ public function getConfiguration() { return $this->configuration; } + /** + * @param \Propel\Runtime\Connection\ConnectionInterface $connection + * + * @return void + */ public function setConnection(ConnectionInterface $connection) { $this->setConfiguration(null); $this->connection = $connection; } + /** + * @param array|null $configuration + * + * @return void + */ public function setConfiguration($configuration) { - $this->configuration = $configuration; + $this->configuration = (array)$configuration; $this->closeConnections(); } /** - * @param \Propel\Runtime\Adapter\AdapterInterface $adapter + * @param \Propel\Runtime\Adapter\AdapterInterface|null $adapter * * @return \Propel\Runtime\Connection\ConnectionInterface */ public function getWriteConnection(AdapterInterface $adapter = null) { if (null === $this->connection) { + if ($adapter === null) { + throw new \InvalidArgumentException('$adapter not given'); + } + $this->connection = ConnectionFactory::create($this->configuration, $adapter); $this->connection->setName($this->getName()); } @@ -81,7 +98,7 @@ public function getWriteConnection(AdapterInterface $adapter = null) } /** - * @param \Propel\Runtime\Adapter\AdapterInterface $adapter + * @param \Propel\Runtime\Adapter\AdapterInterface|null $adapter * * @return \Propel\Runtime\Connection\ConnectionInterface */ @@ -90,6 +107,9 @@ public function getReadConnection(AdapterInterface $adapter = null) return $this->getWriteConnection($adapter); } + /** + * @return void + */ public function closeConnections() { $this->connection = null; diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index 5b157857de..c4061f7705 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -599,6 +599,11 @@ public function getLogMethods() return $this->logMethods; } + /** + * @param string $methodName + * + * @return bool + */ protected function isLogEnabledForMethod($methodName) { return in_array($methodName, $this->getLogMethods()); diff --git a/src/Propel/Runtime/Connection/StatementWrapper.php b/src/Propel/Runtime/Connection/StatementWrapper.php index b97f2064a9..7e444871ad 100644 --- a/src/Propel/Runtime/Connection/StatementWrapper.php +++ b/src/Propel/Runtime/Connection/StatementWrapper.php @@ -327,6 +327,12 @@ public function getBoundValues() return $this->boundValues; } + /** + * @param string $method + * @param array $args + * + * @return mixed + */ public function __call($method, $args) { return call_user_func_array([$this->statement, $method], $args); diff --git a/src/Propel/Runtime/Formatter/AbstractFormatter.php b/src/Propel/Runtime/Formatter/AbstractFormatter.php index ba3c61cd38..12dad187f8 100644 --- a/src/Propel/Runtime/Formatter/AbstractFormatter.php +++ b/src/Propel/Runtime/Formatter/AbstractFormatter.php @@ -25,36 +25,52 @@ */ abstract class AbstractFormatter { + /** + * @var string|null + */ protected $dbName; + /** + * @var string|null + */ protected $class; + /** + * @var \Propel\Runtime\Map\TableMap|null + */ protected $tableMap; - /** @var ModelWith[] $with */ - protected $with; - - protected $asColumns; + /** + * @var ModelWith[] $with + */ + protected $with = []; - protected $hasLimit; + /** + * @var array + */ + protected $asColumns = []; - /** @var ActiveRecordInterface[] */ - protected $currentObjects; + /** + * @var bool + */ + protected $hasLimit = false; - protected $collectionName; + /** + * @var ActiveRecordInterface[] + */ + protected $currentObjects = []; /** * @var DataFetcherInterface */ protected $dataFetcher; + /** + * @param \Propel\Runtime\ActiveQuery\BaseModelCriteria|null $criteria + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher + */ public function __construct(BaseModelCriteria $criteria = null, DataFetcherInterface $dataFetcher = null) { - $this->with = []; - $this->asColumns = []; - $this->currentObjects = []; - $this->hasLimit = false; - if (null !== $criteria) { $this->init($criteria, $dataFetcher); } @@ -110,47 +126,82 @@ public function setDbName($dbName) $this->dbName = $dbName; } + /** + * @return string + */ public function getDbName() { return $this->dbName; } + /** + * @param string $class + * + * @return void + */ public function setClass($class) { $this->class = $class; $this->tableMap = constant($this->class . '::TABLE_MAP'); } + /** + * @return string|null + */ public function getClass() { return $this->class; } + /** + * @param array $withs + * + * @return void + */ public function setWith($withs = []) { $this->with = $withs; } + /** + * @return \Propel\Runtime\ActiveQuery\ModelWith[] + */ public function getWith() { return $this->with; } + /** + * @param array $asColumns + * + * @return void + */ public function setAsColumns($asColumns = []) { $this->asColumns = $asColumns; } + /** + * @return array + */ public function getAsColumns() { return $this->asColumns; } + /** + * @param bool $hasLimit + * + * @return void + */ public function setHasLimit($hasLimit = false) { $this->hasLimit = $hasLimit; } + /** + * @return bool + */ public function hasLimit() { return $this->hasLimit; @@ -205,6 +256,10 @@ abstract public function formatOne(DataFetcherInterface $dataFetcher = null); */ abstract public function isObjectFormatter(); + /** + * @throws \Propel\Runtime\Exception\PropelException + * @return void + */ public function checkInit() { if (null === $this->tableMap) { @@ -212,11 +267,17 @@ public function checkInit() } } + /** + * @return \Propel\Runtime\Map\TableMap + */ public function getTableMap() { return Propel::getServiceContainer()->getDatabaseMap($this->dbName)->getTableByPhpName($this->class); } + /** + * @return bool + */ protected function isWithOneToMany() { foreach ($this->with as $modelWith) { diff --git a/src/Propel/Runtime/Formatter/ArrayFormatter.php b/src/Propel/Runtime/Formatter/ArrayFormatter.php index 73f2a8cc2f..6d34c28aa7 100644 --- a/src/Propel/Runtime/Formatter/ArrayFormatter.php +++ b/src/Propel/Runtime/Formatter/ArrayFormatter.php @@ -61,11 +61,20 @@ public function format(DataFetcherInterface $dataFetcher = null) return $collection; } + /** + * @return string|null + */ public function getCollectionClassName() { return '\Propel\Runtime\Collection\ArrayCollection'; } + /** + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher + * + * @throws \Propel\Runtime\Exception\LogicException + * @return array|null + */ public function formatOne(DataFetcherInterface $dataFetcher = null) { $this->checkInit(); @@ -122,7 +131,7 @@ public function isObjectFormatter() * @param array $row associative array indexed by column number, * as returned by DataFetcher::fetch() * - * @return Array + * @return array */ public function &getStructuredArrayFromRow($row) { diff --git a/src/Propel/Runtime/Formatter/ObjectFormatter.php b/src/Propel/Runtime/Formatter/ObjectFormatter.php index f8788a1d59..4e4e522aee 100644 --- a/src/Propel/Runtime/Formatter/ObjectFormatter.php +++ b/src/Propel/Runtime/Formatter/ObjectFormatter.php @@ -64,11 +64,20 @@ public function format(DataFetcherInterface $dataFetcher = null) return $collection; } + /** + * @return string|null + */ public function getCollectionClassName() { return $this->getTableMap()->getCollectionClassName(); } + /** + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher + * + * @throws \Propel\Runtime\Exception\LogicException + * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface|null + */ public function formatOne(DataFetcherInterface $dataFetcher = null) { $this->checkInit(); @@ -91,6 +100,9 @@ public function formatOne(DataFetcherInterface $dataFetcher = null) return $result; } + /** + * @return bool + */ public function isObjectFormatter() { return true; @@ -109,7 +121,7 @@ public function isObjectFormatter() public function getAllObjectsFromRow($row) { // main object - list($obj, $col) = $this->getTableMap()->populateobject($row, 0, $this->getDataFetcher()->getIndexType()); + [$obj, $col] = $this->getTableMap()->populateObject($row, 0, $this->getDataFetcher()->getIndexType()); $pk = $obj->getPrimaryKey(); $serializedPk = serialize($pk); @@ -122,7 +134,7 @@ public function getAllObjectsFromRow($row) // related objects added using with() foreach ($this->getWith() as $modelWith) { - list($endObject, $col) = $modelWith->getTableMap()->populateobject($row, $col, $this->getDataFetcher()->getIndexType()); + [$endObject, $col] = $modelWith->getTableMap()->populateObject($row, $col, $this->getDataFetcher()->getIndexType()); if (null !== $modelWith->getLeftPhpName() && !isset($hydrationChain[$modelWith->getLeftPhpName()])) { continue; diff --git a/src/Propel/Runtime/Formatter/OnDemandFormatter.php b/src/Propel/Runtime/Formatter/OnDemandFormatter.php index 236639bfd0..e88d4d9347 100644 --- a/src/Propel/Runtime/Formatter/OnDemandFormatter.php +++ b/src/Propel/Runtime/Formatter/OnDemandFormatter.php @@ -28,6 +28,12 @@ class OnDemandFormatter extends ObjectFormatter { protected $isSingleTableInheritance = false; + /** + * @param \Propel\Runtime\ActiveQuery\BaseModelCriteria|null $criteria + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher + * + * @return $this + */ public function init(BaseModelCriteria $criteria = null, DataFetcherInterface $dataFetcher = null) { parent::init($criteria, $dataFetcher); @@ -37,6 +43,12 @@ public function init(BaseModelCriteria $criteria = null, DataFetcherInterface $d return $this; } + /** + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher + * + * @throws \Propel\Runtime\Exception\LogicException + * @return array|\Propel\Runtime\Collection\Collection|\Propel\Runtime\Collection\OnDemandCollection + */ public function format(DataFetcherInterface $dataFetcher = null) { $this->checkInit(); @@ -56,6 +68,9 @@ public function format(DataFetcherInterface $dataFetcher = null) return $collection; } + /** + * @return string|null + */ public function getCollectionClassName() { return '\Propel\Runtime\Collection\OnDemandCollection'; diff --git a/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php b/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php index 043ad146ec..a6e95724b3 100644 --- a/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php +++ b/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php @@ -49,11 +49,20 @@ public function format(DataFetcherInterface $dataFetcher = null) return $collection; } + /** + * @return string|null + */ public function getCollectionClassName() { return '\Propel\Runtime\Collection\ArrayCollection'; } + /** + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher + * + * @throws \Propel\Runtime\Exception\LogicException + * @return array|null + */ public function formatOne(DataFetcherInterface $dataFetcher = null) { $this->checkInit(); diff --git a/src/Propel/Runtime/Formatter/StatementFormatter.php b/src/Propel/Runtime/Formatter/StatementFormatter.php index c600cc28b5..ba43d6eeca 100644 --- a/src/Propel/Runtime/Formatter/StatementFormatter.php +++ b/src/Propel/Runtime/Formatter/StatementFormatter.php @@ -33,6 +33,11 @@ public function format(DataFetcherInterface $dataFetcher = null) return $dataFetcher; } + /** + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher + * + * @return \Propel\Runtime\DataFetcher\DataFetcherInterface|null + */ public function formatOne(DataFetcherInterface $dataFetcher = null) { if ($dataFetcher) { @@ -44,11 +49,20 @@ public function formatOne(DataFetcherInterface $dataFetcher = null) return $dataFetcher->count() > 0 ? $dataFetcher : null; } + /** + * @param \Propel\Runtime\ActiveRecord\ActiveRecordInterface|null $record + * + * @throws \Propel\Runtime\Exception\PropelException + * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface|void|null + */ public function formatRecord(ActiveRecordInterface $record = null) { throw new PropelException('The Statement formatter cannot transform a record into a statement'); } + /** + * @return bool + */ public function isObjectFormatter() { return false; diff --git a/src/Propel/Runtime/Map/ColumnMap.php b/src/Propel/Runtime/Map/ColumnMap.php index 954c56b177..e2cb126d3c 100644 --- a/src/Propel/Runtime/Map/ColumnMap.php +++ b/src/Propel/Runtime/Map/ColumnMap.php @@ -98,8 +98,6 @@ class ColumnMap protected $isPkString = false; /** - * Constructor. - * * @param string $name The name of the column. * @param \Propel\Runtime\Map\TableMap $containingTable TableMap of the table this column is in. */ @@ -475,11 +473,21 @@ public function getValueSet() return $this->valueSet; } + /** + * @param mixed $value + * + * @return bool + */ public function isInValueSet($value) { return in_array($value, $this->valueSet); } + /** + * @param mixed $value + * + * @return false|int|string + */ public function getValueSetKey($value) { return array_search($value, $this->valueSet); diff --git a/src/Propel/Runtime/Map/DatabaseMap.php b/src/Propel/Runtime/Map/DatabaseMap.php index 94fba8f9a1..55931dd6e9 100644 --- a/src/Propel/Runtime/Map/DatabaseMap.php +++ b/src/Propel/Runtime/Map/DatabaseMap.php @@ -51,8 +51,6 @@ class DatabaseMap protected $tablesByPhpName = []; /** - * Constructor. - * * @param string $name Name of the database. */ public function __construct($name) diff --git a/src/Propel/Runtime/Map/RelationMap.php b/src/Propel/Runtime/Map/RelationMap.php index ce5792a520..98210c78c6 100644 --- a/src/Propel/Runtime/Map/RelationMap.php +++ b/src/Propel/Runtime/Map/RelationMap.php @@ -75,8 +75,6 @@ class RelationMap protected $onDelete; /** - * Constructor. - * * @param string $name Name of the relation. */ public function __construct($name) @@ -110,6 +108,11 @@ public function getName() return $this->name; } + /** + * @param string $pluralName + * + * @return void + */ public function setPluralName($pluralName) { $this->pluralName = $pluralName; diff --git a/src/Propel/Runtime/Parser/AbstractParser.php b/src/Propel/Runtime/Parser/AbstractParser.php index 362e0d1c59..57aec66b50 100644 --- a/src/Propel/Runtime/Parser/AbstractParser.php +++ b/src/Propel/Runtime/Parser/AbstractParser.php @@ -55,6 +55,12 @@ public function listFromArray($data, $rootKey = 'data') return $this->fromArray($data, $rootKey); } + /** + * @param string $data + * @param string $rootKey + * + * @return array + */ public function listToArray($data, $rootKey = 'data') { return $this->toArray($data, $rootKey); diff --git a/src/Propel/Runtime/Parser/CsvParser.php b/src/Propel/Runtime/Parser/CsvParser.php index 8b84f3e76d..92c4734a1f 100644 --- a/src/Propel/Runtime/Parser/CsvParser.php +++ b/src/Propel/Runtime/Parser/CsvParser.php @@ -223,11 +223,22 @@ public function toArray($data, $rootKey = null, $isList = false, $includeHeading return $array; } - public function listToArray($array, $rootKey = null) + /** + * @param string $data + * @param string|null $rootKey + * + * @return array + */ + public function listToArray($data, $rootKey = null) { - return $this->toArray($array, $rootKey, true); + return $this->toArray($data, $rootKey, true); } + /** + * @param string $row + * + * @return array + */ protected function getColumns($row) { $delim = preg_quote($this->delimiter, '/'); @@ -260,6 +271,11 @@ protected function cleanupRow($row) return $row; } + /** + * @param string $input + * + * @return false|int + */ protected function isQuoted($input) { $quote = preg_quote($this->quotechar, '/'); @@ -267,6 +283,11 @@ protected function isQuoted($input) return preg_match('/^' . $quote . '.*' . $quote . '$/', $input); } + /** + * @param string $input + * + * @return string + */ protected function unescape($input) { return str_replace( @@ -276,6 +297,11 @@ protected function unescape($input) ); } + /** + * @param string $input + * + * @return string + */ protected function unquote($input) { return trim($input, $this->quotechar); @@ -283,6 +309,10 @@ protected function unquote($input) /** * Checks whether a value from CSV output is serialized + * + * @param string $input + * + * @return false|int */ protected function isSerialized($input) { diff --git a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php index c23e4940bd..5787ea85f8 100644 --- a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php +++ b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php @@ -27,12 +27,12 @@ class StandardServiceContainer implements ServiceContainerInterface { /** - * @var array[\Propel\Runtime\Adapter\AdapterInterface] List of database adapter instances + * @var \Propel\Runtime\Adapter\AdapterInterface[] List of database adapter instances */ protected $adapters = []; /** - * @var array[string] List of database adapter classes + * @var string[] List of database adapter classes */ protected $adapterClasses = []; @@ -47,12 +47,12 @@ class StandardServiceContainer implements ServiceContainerInterface protected $databaseMapClass = ServiceContainerInterface::DEFAULT_DATABASE_MAP_CLASS; /** - * @var array[\Propel\Runtime\Map\DatabaseMap] List of database map instances + * @var \Propel\Runtime\Map\DatabaseMap[] List of database map instances */ protected $databaseMaps = []; /** - * @var array[\Propel\Runtime\Connection\ConnectionManagerInterface] List of connection managers + * @var \Propel\Runtime\Connection\ConnectionManagerInterface[] List of connection managers */ protected $connectionManagers = []; @@ -74,7 +74,7 @@ class StandardServiceContainer implements ServiceContainerInterface protected $profiler; /** - * @var array[LoggerInterface] list of loggers + * @var LoggerInterface[] List of loggers */ protected $loggers = []; @@ -102,7 +102,7 @@ public function setDefaultDatasource($defaultDatasource) /** * Get the adapter class for a given datasource. * - * @param string $name The datasource name + * @param string|null $name The datasource name * * @return string */ @@ -132,7 +132,7 @@ public function setAdapterClass($name, $adapterClass) /** * Reset existing adapters classes and set new classes for all datasources. * - * @param array $adapterClasses A list of adapters + * @param string[] $adapterClasses A list of adapters */ public function setAdapterClasses($adapterClasses) { @@ -294,7 +294,7 @@ public function hasConnectionManager($name) } /** - * @return array[\Propel\Runtime\Connection\ConnectionManagerInterface] + * @return \Propel\Runtime\Connection\ConnectionManagerInterface[] */ public function getConnectionManagers() { @@ -467,6 +467,12 @@ public function setLogger($name, LoggerInterface $logger) $this->loggers[$name] = $logger; } + /** + * @param string $name + * + * @throws \Propel\Runtime\Exception\UnexpectedValueException + * @return \Psr\Log\LoggerInterface + */ protected function buildLogger($name = 'defaultLogger') { if (!isset($this->loggerConfigurations[$name])) { @@ -533,6 +539,9 @@ public function setLoggerConfiguration($name, $loggerConfiguration) $this->loggerConfigurations[$name] = $loggerConfiguration; } + /** + * @return void + */ private function __clone() { } diff --git a/src/Propel/Runtime/Util/Profiler.php b/src/Propel/Runtime/Util/Profiler.php index 9a9448e3b9..26fba7c865 100644 --- a/src/Propel/Runtime/Util/Profiler.php +++ b/src/Propel/Runtime/Util/Profiler.php @@ -47,6 +47,11 @@ class Profiler ], ]; + /** + * @param float $slowTreshold + * @param string $innerGlue + * @param string $outerGlue + */ public function __construct($slowTreshold = 0.1, $innerGlue = ': ', $outerGlue = ' | ') { $this->slowTreshold = $slowTreshold; @@ -163,16 +168,25 @@ public function getConfiguration() ]; } + /** + * @return void + */ public function start() { $this->snapshot = self::getSnapshot(); } + /** + * @return bool + */ public function isSlow() { return microtime(true) - $this->snapshot['microtime'] > $this->slowTreshold; } + /** + * @return string + */ public function getProfile() { return $this->getProfileBetween($this->snapshot, self::getSnapshot()); diff --git a/src/Propel/Runtime/Util/PropelConditionalProxy.php b/src/Propel/Runtime/Util/PropelConditionalProxy.php index 3618e470c1..f2ce13bdf7 100644 --- a/src/Propel/Runtime/Util/PropelConditionalProxy.php +++ b/src/Propel/Runtime/Util/PropelConditionalProxy.php @@ -46,6 +46,11 @@ class PropelConditionalProxy protected $parentState; + /** + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria + * @param mixed $cond + * @param \Propel\Runtime\Util\PropelConditionalProxy|null $proxy + */ public function __construct(Criteria $criteria, $cond, self $proxy = null) { $this->criteria = $criteria; @@ -116,6 +121,11 @@ protected function getConditionalState() return $this->state && $this->parentState; } + /** + * @param mixed $cond + * + * @return $this|\Propel\Runtime\ActiveQuery\Criteria + */ protected function setConditionalState($cond) { $this->state = (Boolean) $cond; @@ -124,11 +134,17 @@ protected function setConditionalState($cond) return $this->getCriteriaOrProxy(); } + /** + * @return \Propel\Runtime\Util\PropelConditionalProxy|null + */ public function getParentProxy() { return $this->parent; } + /** + * @return $this|\Propel\Runtime\ActiveQuery\Criteria + */ public function getCriteriaOrProxy() { if ($this->state && $this->parentState) { @@ -138,6 +154,12 @@ public function getCriteriaOrProxy() return $this; } + /** + * @param string $name + * @param array $arguments + * + * @return $this + */ public function __call($name, $arguments) { return $this; diff --git a/src/Propel/Runtime/Util/PropelModelPager.php b/src/Propel/Runtime/Util/PropelModelPager.php index 07f994ea3b..6aa22b1d63 100644 --- a/src/Propel/Runtime/Util/PropelModelPager.php +++ b/src/Propel/Runtime/Util/PropelModelPager.php @@ -69,34 +69,51 @@ class PropelModelPager implements \IteratorAggregate, \Countable */ protected $con; + /** + * @param \Propel\Runtime\ActiveQuery\ModelCriteria $query + * @param int $maxPerPage + */ public function __construct(ModelCriteria $query, $maxPerPage = 10) { $this->setQuery($query); $this->setMaxPerPage($maxPerPage); $this->setPage(1); $this->setLastPage(1); - $this->setMaxRecordLimit(false); + $this->setMaxRecordLimit(0); $this->setNbResults(0); $this->currentMaxLink = 1; } + /** + * @param \Propel\Runtime\ActiveQuery\ModelCriteria $query + * + * @return void + */ public function setQuery(ModelCriteria $query) { $this->query = $query; } + /** + * @return \Propel\Runtime\ActiveQuery\ModelCriteria + */ public function getQuery() { return $this->query; } + /** + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con + * + * @return void + */ public function init(ConnectionInterface $con = null) { $this->con = $con; - $hasMaxRecordLimit = false !== $this->getMaxRecordLimit(); $maxRecordLimit = $this->getMaxRecordLimit(); - + $hasMaxRecordLimit = (bool)$maxRecordLimit; + $qForCount = clone $this->getQuery(); $count = $qForCount ->offset(0) @@ -145,7 +162,7 @@ public function getResults() $newQueryKey = sprintf('%s offset %s limit %s', $queryKey, $this->getQuery()->getOffset(), $this->getQuery()->getLimit()); $this->getQuery()->setQueryKey($newQueryKey); } - + $this->results = $this->getQuery() ->find($this->con) ; @@ -154,21 +171,37 @@ public function getResults() return $this->results; } + /** + * @return int + */ public function getCurrentMaxLink() { return $this->currentMaxLink; } + /** + * @return int + */ public function getMaxRecordLimit() { return $this->maxRecordLimit; } + /** + * @param int $limit + * + * @return void + */ public function setMaxRecordLimit($limit) { $this->maxRecordLimit = $limit; } + /** + * @param int $nbLinks + * + * @return int[] + */ public function getLinks($nbLinks = 5) { $links = []; @@ -393,6 +426,9 @@ public function isEmpty() return $this->getResults()->isEmpty(); } + /** + * @return \Propel\Runtime\Collection\CollectionIterator|\Traversable + */ public function getIterator() { return $this->getResults()->getIterator(); @@ -409,6 +445,13 @@ public function count() return count($this->getResults()); } + /** + * @param string $name + * @param array $params + * + * @throws \Propel\Runtime\Exception\BadMethodCallException + * @return mixed + */ public function __call($name, $params) { try { From 3c834b1ef1621bcbcabbb3a53017a94a57d74671 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 23 Jul 2020 10:56:43 +0200 Subject: [PATCH 112/208] Fix up baseline errors. --- phpstan-baseline.neon | 282 ++---------------- ...rchivableBehaviorObjectBuilderModifier.php | 10 +- ...ArchivableBehaviorQueryBuilderModifier.php | 8 +- .../SortableBehaviorObjectBuilderModifier.php | 4 +- .../SortableBehaviorQueryBuilderModifier.php | 10 +- ...ortableBehaviorTableMapBuilderModifier.php | 4 +- ...rsionableBehaviorObjectBuilderModifier.php | 18 +- ...ersionableBehaviorQueryBuilderModifier.php | 4 +- .../Builder/Om/AbstractObjectBuilder.php | 14 +- src/Propel/Generator/Model/Column.php | 2 +- src/Propel/Generator/Model/Domain.php | 4 +- src/Propel/Generator/Model/Table.php | 10 +- .../Generator/Platform/DefaultPlatform.php | 3 +- .../Generator/Platform/MysqlPlatform.php | 2 +- .../Generator/Platform/OraclePlatform.php | 4 +- .../Generator/Platform/SqlitePlatform.php | 2 +- .../Generator/Schema/Dumper/XmlDumper.php | 4 +- src/Propel/Generator/Util/QuickBuilder.php | 4 +- .../Runtime/ActiveQuery/ModelCriteria.php | 16 +- 19 files changed, 114 insertions(+), 291 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index f290180ecb..381e393dc1 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -35,83 +35,23 @@ parameters: count: 1 path: src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:isArchiveOnInsert\\(\\)\\.$#" - count: 4 - path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:isArchiveOnUpdate\\(\\)\\.$#" - count: 4 - path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:isArchiveOnDelete\\(\\)\\.$#" - count: 3 - path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php - - - - message: "#^Method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehaviorObjectBuilderModifier\\:\\:postInsert\\(\\) should return string\\|null but return statement is missing\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php - - - - message: "#^Method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehaviorObjectBuilderModifier\\:\\:postUpdate\\(\\) should return string\\|null but return statement is missing\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php - - - - message: "#^Method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehaviorObjectBuilderModifier\\:\\:preDelete\\(\\) should return string\\|null but return statement is missing\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" count: 1 path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getArchiveTablePhpName\\(\\)\\.$#" + message: "#^Parameter \\#1 \\$builder of method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehavior\\:\\:getArchiveTablePhpName\\(\\) expects Propel\\\\Generator\\\\Builder\\\\Om\\\\ObjectBuilder, Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractOMBuilder given\\.$#" count: 3 path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getArchiveTableQueryName\\(\\)\\.$#" + message: "#^Parameter \\#1 \\$builder of method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehavior\\:\\:getArchiveTableQueryName\\(\\) expects Propel\\\\Generator\\\\Builder\\\\Om\\\\ObjectBuilder, Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractOMBuilder given\\.$#" count: 2 path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getArchivedAtColumn\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:hasArchiveClass\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:isArchiveOnUpdate\\(\\)\\.$#" - count: 3 - path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:isArchiveOnDelete\\(\\)\\.$#" - count: 3 - path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php - - - - message: "#^Method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehaviorQueryBuilderModifier\\:\\:preDeleteQuery\\(\\) should return string\\|null but return statement is missing\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php - - - - message: "#^Method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehaviorQueryBuilderModifier\\:\\:postUpdateQuery\\(\\) should return string\\|null but return statement is missing\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getArchiveTablePhpName\\(\\)\\.$#" + message: "#^Parameter \\#1 \\$builder of method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehavior\\:\\:getArchiveTablePhpName\\(\\) expects Propel\\\\Generator\\\\Builder\\\\Om\\\\ObjectBuilder, Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractOMBuilder given\\.$#" count: 1 path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php @@ -141,55 +81,10 @@ parameters: path: src/Propel/Generator/Behavior/I18n/I18nBehavior.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:useScope\\(\\)\\.$#" - count: 15 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getScopes\\(\\)\\.$#" - count: 5 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:hasMultipleScopes\\(\\)\\.$#" - count: 3 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getColumnGetter\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getColumnSetter\\(\\)\\.$#" + message: "#^Ternary operator condition is always false\\.$#" count: 1 path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:generateScopePhp\\(\\)\\.$#" - count: 2 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:useScope\\(\\)\\.$#" - count: 10 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:hasMultipleScopes\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getScopes\\(\\)\\.$#" - count: 2 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:generateScopePhp\\(\\)\\.$#" - count: 5 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php - - message: "#^Variable \\$paramsDoc might not be defined\\.$#" count: 4 @@ -205,56 +100,11 @@ parameters: count: 1 path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:useScope\\(\\)\\.$#" - count: 2 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:hasMultipleScopes\\(\\)\\.$#" - count: 2 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getScopes\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php - - message: "#^Access to an undefined property Propel\\\\Generator\\\\Model\\\\Table\\:\\:\\$isVersionTable\\.$#" count: 1 path: src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getVersionTable\\(\\)\\.$#" - count: 6 - path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php - - - - message: "#^Method Propel\\\\Generator\\\\Behavior\\\\Versionable\\\\VersionableBehaviorObjectBuilderModifier\\:\\:postDelete\\(\\) should return string\\|null but return statement is missing\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getVersionableFks\\(\\)\\.$#" - count: 3 - path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getVersionableReferrers\\(\\)\\.$#" - count: 3 - path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getReferrerIdsColumn\\(\\)\\.$#" - count: 2 - path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getReferrerVersionsColumn\\(\\)\\.$#" - count: 2 - path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php - - message: "#^Variable \\$col might not be defined\\.$#" count: 1 @@ -263,7 +113,7 @@ parameters: - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getVersionTable\\(\\)\\.$#" count: 1 - path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php + path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php - message: "#^Parameter \\#1 \\$v of method Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\:\\:setGeneratorConfig\\(\\) expects Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface, \\$this\\(Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\) given\\.$#" @@ -415,21 +265,11 @@ parameters: count: 2 path: src/Propel/Generator/Builder/Om/ObjectBuilder.php - - - message: "#^Negated boolean expression is always false\\.$#" - count: 1 - path: src/Propel/Generator/Builder/Om/ObjectBuilder.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getIdentifierPhp\\(\\)\\.$#" count: 2 path: src/Propel/Generator/Builder/Om/ObjectBuilder.php - - - message: "#^If condition is always true\\.$#" - count: 1 - path: src/Propel/Generator/Builder/Om/ObjectBuilder.php - - message: "#^Left side of && is always true\\.$#" count: 1 @@ -450,16 +290,6 @@ parameters: count: 1 path: src/Propel/Generator/Builder/Util/SchemaReader.php - - - message: "#^Parameter \\$definition of method Propel\\\\Generator\\\\Command\\\\Console\\\\Input\\\\ArrayInput\\:\\:__construct\\(\\) has invalid typehint type Propel\\\\Generator\\\\Command\\\\Console\\\\Input\\\\InputDefinition\\.$#" - count: 1 - path: src/Propel/Generator/Command/Console/Input/ArrayInput.php - - - - message: "#^Parameter \\#1 \\$definition of method Symfony\\\\Component\\\\Console\\\\Input\\\\Input\\:\\:__construct\\(\\) expects Symfony\\\\Component\\\\Console\\\\Input\\\\InputDefinition\\|null, Propel\\\\Generator\\\\Command\\\\Console\\\\Input\\\\InputDefinition\\|null given\\.$#" - count: 1 - path: src/Propel/Generator/Command/Console/Input/ArrayInput.php - - message: "#^Parameter \\#1 \\$attempts of method Symfony\\\\Component\\\\Console\\\\Question\\\\Question\\:\\:setMaxAttempts\\(\\) expects int\\|null, true given\\.$#" count: 1 @@ -557,7 +387,7 @@ parameters: - message: "#^Strict comparison using \\=\\=\\= between null and int will always evaluate to false\\.$#" - count: 2 + count: 1 path: src/Propel/Generator/Model/Domain.php - @@ -585,21 +415,6 @@ parameters: count: 1 path: src/Propel/Generator/Model/Table.php - - - message: "#^Method Propel\\\\Generator\\\\Model\\\\Table\\:\\:getFirstPrimaryKeyColumn\\(\\) should return Propel\\\\Generator\\\\Model\\\\Column but return statement is missing\\.$#" - count: 1 - path: src/Propel/Generator/Model/Table.php - - - - message: "#^Method Propel\\\\Generator\\\\Model\\\\Table\\:\\:getAutoIncrementPrimaryKey\\(\\) should return Propel\\\\Generator\\\\Model\\\\Column but return statement is missing\\.$#" - count: 1 - path: src/Propel/Generator/Model/Table.php - - - - message: "#^Method Propel\\\\Generator\\\\Platform\\\\DefaultPlatform\\:\\:getBeginDDL\\(\\) should return string\\|null but return statement is missing\\.$#" - count: 1 - path: src/Propel/Generator/Platform/DefaultPlatform.php - - message: "#^If condition is always true\\.$#" count: 1 @@ -615,40 +430,15 @@ parameters: count: 1 path: src/Propel/Generator/Platform/DefaultPlatform.php - - - message: "#^Parameter \\#1 \\$size of method Propel\\\\Generator\\\\Model\\\\Column\\:\\:setSize\\(\\) expects int, null given\\.$#" - count: 1 - path: src/Propel/Generator/Platform/DefaultPlatform.php - - - - message: "#^Method Propel\\\\Generator\\\\Platform\\\\MssqlPlatform\\:\\:getPrimaryKeyDDL\\(\\) should return string\\|null but return statement is missing\\.$#" - count: 1 - path: src/Propel/Generator/Platform/MssqlPlatform.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" count: 2 path: src/Propel/Generator/Platform/MysqlPlatform.php - - - message: "#^Method Propel\\\\Generator\\\\Platform\\\\MysqlPlatform\\:\\:getPrimaryKeyDDL\\(\\) should return string\\|null but return statement is missing\\.$#" - count: 1 - path: src/Propel/Generator/Platform/MysqlPlatform.php - - message: "#^Left side of && is always true\\.$#" - count: 2 - path: src/Propel/Generator/Platform/MysqlPlatform.php - - - - message: "#^Method Propel\\\\Generator\\\\Platform\\\\OraclePlatform\\:\\:getAddPrimaryKeyDDL\\(\\) should return string but return statement is missing\\.$#" count: 1 - path: src/Propel/Generator/Platform/OraclePlatform.php - - - - message: "#^Method Propel\\\\Generator\\\\Platform\\\\OraclePlatform\\:\\:getPrimaryKeyDDL\\(\\) should return string\\|null but return statement is missing\\.$#" - count: 1 - path: src/Propel/Generator/Platform/OraclePlatform.php + path: src/Propel/Generator/Platform/MysqlPlatform.php - message: "#^If condition is always true\\.$#" @@ -715,16 +505,6 @@ parameters: count: 6 path: src/Propel/Generator/Schema/Dumper/XmlDumper.php - - - message: "#^Parameter \\#2 \\$value of method DOMElement\\:\\:setAttribute\\(\\) expects string, int\\<1, max\\>\\|int\\ given\\.$#" - count: 1 - path: src/Propel/Generator/Schema/Dumper/XmlDumper.php - - - - message: "#^Parameter \\#2 \\$value of method DOMElement\\:\\:setAttribute\\(\\) expects string, int given\\.$#" - count: 1 - path: src/Propel/Generator/Schema/Dumper/XmlDumper.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" count: 1 @@ -761,13 +541,13 @@ parameters: path: src/Propel/Generator/Util/QuickBuilder.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\:\\:build\\(\\)\\.$#" - count: 4 + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\:\\:setChild\\(\\)\\.$#" + count: 2 path: src/Propel/Generator/Util/QuickBuilder.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\:\\:setChild\\(\\)\\.$#" - count: 2 + message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\:\\:build\\(\\)\\.$#" + count: 3 path: src/Propel/Generator/Util/QuickBuilder.php - @@ -830,6 +610,11 @@ parameters: count: 1 path: src/Propel/Runtime/ActiveQuery/Criteria.php + - + message: "#^Method Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:_endif\\(\\) should return \\$this\\(Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\) but returns Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\|Propel\\\\Runtime\\\\Util\\\\PropelConditionalProxy\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/Criteria.php + - message: "#^Result of && is always false\\.$#" count: 1 @@ -895,31 +680,11 @@ parameters: count: 1 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - - message: "#^Method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:preDelete\\(\\) should return int but return statement is missing\\.$#" - count: 1 - path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - - - message: "#^Method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:postDelete\\(\\) should return int but return statement is missing\\.$#" - count: 1 - path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - message: "#^Variable \\$sql might not be defined\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - - message: "#^Method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:preUpdate\\(\\) should return int but return statement is missing\\.$#" - count: 1 - path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - - - message: "#^Method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:postUpdate\\(\\) should return int but return statement is missing\\.$#" - count: 1 - path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - message: "#^Parameter \\#1 \\$values \\(array\\) of method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:doUpdate\\(\\) should be compatible with parameter \\$updateValues \\(Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\) of method Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:doUpdate\\(\\)$#" count: 1 @@ -1075,6 +840,11 @@ parameters: count: 3 path: src/Propel/Runtime/Formatter/ArrayFormatter.php + - + message: "#^Call to an undefined static method Propel\\\\Runtime\\\\Map\\\\TableMap\\:\\:getPrimaryKeyHashFromRow\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Formatter/ArrayFormatter.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:isPrimaryKeyNull\\(\\)\\.$#" count: 1 @@ -1085,6 +855,11 @@ parameters: count: 1 path: src/Propel/Runtime/Formatter/ObjectFormatter.php + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Map\\\\TableMap\\:\\:populateObject\\(\\)\\.$#" + count: 2 + path: src/Propel/Runtime/Formatter/ObjectFormatter.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:isPrimaryKeyNull\\(\\)\\.$#" count: 1 @@ -1110,6 +885,11 @@ parameters: count: 1 path: src/Propel/Runtime/Map/ColumnMap.php + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:setQueryKey\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Util/PropelModelPager.php + - message: "#^Access to an undefined property Symfony\\\\Component\\\\Validator\\\\Constraint\\:\\:\\$message\\.$#" count: 2 diff --git a/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php index 2de4825393..ec8ce8c8f4 100644 --- a/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php @@ -18,7 +18,7 @@ class ArchivableBehaviorObjectBuilderModifier { /** - * @var \Propel\Generator\Model\Behavior + * @var \Propel\Generator\Behavior\Archivable\ArchivableBehavior */ protected $behavior; @@ -33,7 +33,7 @@ class ArchivableBehaviorObjectBuilderModifier protected $builder; /** - * @param \Propel\Generator\Model\Behavior $behavior + * @param \Propel\Generator\Behavior\Archivable\ArchivableBehavior $behavior */ public function __construct($behavior) { @@ -89,6 +89,8 @@ public function postInsert($builder) \$this->archiveOnInsert = true; }"; } + + return null; } /** @@ -105,6 +107,8 @@ public function postUpdate($builder) \$this->archiveOnUpdate = true; }"; } + + return null; } /** @@ -126,6 +130,8 @@ public function preDelete($builder) 'isAddHooks' => $builder->getGeneratorConfig()->get()['generator']['objectModel']['addHooks'], ]); } + + return null; } /** diff --git a/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php index 5e213c17d3..a888d7dcdb 100644 --- a/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php @@ -18,7 +18,7 @@ class ArchivableBehaviorQueryBuilderModifier { /** - * @var \Propel\Generator\Model\Behavior + * @var \Propel\Generator\Behavior\Archivable\ArchivableBehavior */ protected $behavior; @@ -28,7 +28,7 @@ class ArchivableBehaviorQueryBuilderModifier protected $table; /** - * @param \Propel\Generator\Model\Behavior $behavior + * @param \Propel\Generator\Behavior\Archivable\ArchivableBehavior $behavior */ public function __construct($behavior) { @@ -82,6 +82,8 @@ public function preDeleteQuery($builder) } "; } + + return null; } /** @@ -100,6 +102,8 @@ public function postUpdateQuery($builder) } "; } + + return null; } /** diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php index dd6bb20046..1dafa88c46 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php @@ -23,7 +23,7 @@ class SortableBehaviorObjectBuilderModifier { /** - * @var \Propel\Generator\Model\Behavior + * @var \Propel\Generator\Behavior\Sortable\SortableBehavior */ protected $behavior; @@ -58,7 +58,7 @@ class SortableBehaviorObjectBuilderModifier protected $queryFullClassName; /** - * @param SortableBehavior $behavior + * @param \Propel\Generator\Behavior\Sortable\SortableBehavior $behavior */ public function __construct($behavior) { diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php index 749ad19cfb..bd9fadd962 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php @@ -20,7 +20,7 @@ class SortableBehaviorQueryBuilderModifier { /** - * @var \Propel\Generator\Model\Behavior + * @var \Propel\Generator\Behavior\Sortable\SortableBehavior */ protected $behavior; @@ -39,12 +39,18 @@ class SortableBehaviorQueryBuilderModifier */ protected $objectClassName; + /** + * @var string + */ protected $queryClassName; + /** + * @var string + */ protected $tableMapClassName; /** - * @param \Propel\Generator\Model\Behavior $behavior + * @param \Propel\Generator\Behavior\Sortable\SortableBehavior $behavior */ public function __construct($behavior) { diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php index ebd1022ace..d528942220 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php @@ -18,7 +18,7 @@ class SortableBehaviorTableMapBuilderModifier { /** - * @var \Propel\Generator\Model\Behavior + * @var \Propel\Generator\Behavior\Sortable\SortableBehavior */ protected $behavior; @@ -28,7 +28,7 @@ class SortableBehaviorTableMapBuilderModifier protected $table; /** - * @param \Propel\Generator\Model\Behavior $behavior + * @param \Propel\Generator\Behavior\Sortable\SortableBehavior $behavior */ public function __construct($behavior) { diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php index bcdcd5a028..e0378231dc 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php @@ -20,25 +20,32 @@ class VersionableBehaviorObjectBuilderModifier { /** - * @var \Propel\Generator\Model\Behavior + * @var \Propel\Generator\Behavior\Versionable\VersionableBehavior */ protected $behavior; + /** * @var \Propel\Generator\Model\Table */ protected $table; + /** * @var \Propel\Generator\Builder\Om\AbstractOMBuilder */ protected $builder; + /** * @var string */ protected $objectClassName; + + /** + * @var string + */ protected $queryClassName; /** - * @param \Propel\Generator\Model\Behavior $behavior + * @param \Propel\Generator\Behavior\Versionable\VersionableBehavior $behavior */ public function __construct($behavior) { @@ -175,6 +182,8 @@ public function postDelete($builder) return $script; } + + return null; } /** @@ -528,7 +537,10 @@ public function populateFromVersion(\$version, \$con = null, &\$loadedObjects = $plural = false; foreach ($this->behavior->getVersionableFks() as $fk) { $foreignTable = $fk->getForeignTable(); - $foreignVersionTable = $fk->getForeignTable()->getBehavior($this->behavior->getId())->getVersionTable(); + + /** @var \Propel\Generator\Behavior\Versionable\VersionableBehavior $behavior */ + $behavior = $fk->getForeignTable()->getBehavior($this->behavior->getId()); + $foreignVersionTable = $behavior->getVersionTable(); $relatedClassName = $this->builder->getClassNameFromBuilder($this->builder->getNewStubObjectBuilder($foreignTable)); $relatedVersionQueryClassName = $this->builder->getClassNameFromBuilder($this->builder->getNewStubQueryBuilder($foreignVersionTable)); $fkColumnName = $fk->getLocalColumnName(); diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php index e5fe4b3931..c06381fb07 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php @@ -18,7 +18,7 @@ class VersionableBehaviorQueryBuilderModifier { /** - * @var \Propel\Generator\Model\Behavior + * @var \Propel\Generator\Behavior\Versionable\VersionableBehavior */ protected $behavior; /** @@ -39,7 +39,7 @@ class VersionableBehaviorQueryBuilderModifier protected $queryClassName; /** - * @param \Propel\Generator\Model\Behavior $behavior + * @param \Propel\Generator\Behavior\Versionable\VersionableBehavior $behavior */ public function __construct($behavior) { diff --git a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php index 580ac65e8b..44fb187f73 100644 --- a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php @@ -34,21 +34,21 @@ protected function addColumnAccessorMethods(&$script) $table = $this->getTable(); foreach ($table->getColumns() as $col) { - + $type = $col->getType(); // if they're not using the DateTime class than we will generate "compatibility" accessor method - if (PropelTypes::DATE === $col->getType() - || PropelTypes::TIME === $col->getType() - || PropelTypes::TIMESTAMP === $col->getType() + if (PropelTypes::DATE === $type + || PropelTypes::TIME === $type + || PropelTypes::TIMESTAMP === $type ) { $this->addTemporalAccessor($script, $col); - } elseif (PropelTypes::OBJECT === $col->getType()) { + } elseif (PropelTypes::OBJECT === $type) { $this->addObjectAccessor($script, $col); - } elseif (PropelTypes::PHP_ARRAY === $col->getType()) { + } elseif (PropelTypes::PHP_ARRAY === $type) { $this->addArrayAccessor($script, $col); if ($col->isNamePlural()) { $this->addHasArrayElement($script, $col); } - } elseif (PropelTypes::JSON === $col->getType()) { + } elseif (PropelTypes::JSON === $type) { $this->addJsonAccessor($script, $col); } elseif ($col->isEnumType()) { $this->addEnumAccessor($script, $col); diff --git a/src/Propel/Generator/Model/Column.php b/src/Propel/Generator/Model/Column.php index e8ab9c732f..ed9a7ea449 100644 --- a/src/Propel/Generator/Model/Column.php +++ b/src/Propel/Generator/Model/Column.php @@ -1321,7 +1321,7 @@ public function getSize() /** * Sets the column size. * - * @param integer $size + * @param integer|null $size */ public function setSize($size) { diff --git a/src/Propel/Generator/Model/Domain.php b/src/Propel/Generator/Model/Domain.php index bab17b59b9..4ccc920603 100644 --- a/src/Propel/Generator/Model/Domain.php +++ b/src/Propel/Generator/Model/Domain.php @@ -205,7 +205,7 @@ public function getSize() /** * Sets the size. * - * @param integer $size + * @param integer|null $size */ public function setSize($size) { @@ -215,7 +215,7 @@ public function setSize($size) /** * Replaces the size if the new value is not null. * - * @param integer $size + * @param integer|null $size */ public function replaceSize($size) { diff --git a/src/Propel/Generator/Model/Table.php b/src/Propel/Generator/Model/Table.php index 034d448ad4..467766ebc7 100644 --- a/src/Propel/Generator/Model/Table.php +++ b/src/Propel/Generator/Model/Table.php @@ -1066,6 +1066,8 @@ public function hasAdditionalBuilders() /** * Get the early table behaviors * + * @deprecated Unused (no isEarly() method available). + * * @return \Propel\Generator\Model\Behavior[] Array of Behavior objects */ public function getEarlyBehaviors() @@ -1875,7 +1877,7 @@ public function hasCompositePrimaryKey() * * Useful for tables with a PK using a single column. * - * @return Column + * @return Column|null */ public function getFirstPrimaryKeyColumn() { @@ -1884,6 +1886,8 @@ public function getFirstPrimaryKeyColumn() return $col; } } + + return null; } /** @@ -1915,7 +1919,7 @@ public function hasAutoIncrementPrimaryKey() /** * Returns the auto incremented primary key. * - * @return Column + * @return Column|null */ public function getAutoIncrementPrimaryKey() { @@ -1926,6 +1930,8 @@ public function getAutoIncrementPrimaryKey() } } } + + return null; } /** diff --git a/src/Propel/Generator/Platform/DefaultPlatform.php b/src/Propel/Generator/Platform/DefaultPlatform.php index 66ffa0071d..a35cae2784 100644 --- a/src/Propel/Generator/Platform/DefaultPlatform.php +++ b/src/Propel/Generator/Platform/DefaultPlatform.php @@ -298,10 +298,11 @@ public function getAddTablesDDL(Database $database) /** * Gets the requests to execute at the beginning of a DDL file * - * @return string|null + * @return string */ public function getBeginDDL() { + return ''; } /** diff --git a/src/Propel/Generator/Platform/MysqlPlatform.php b/src/Propel/Generator/Platform/MysqlPlatform.php index 5cb3994c70..bac825c635 100644 --- a/src/Propel/Generator/Platform/MysqlPlatform.php +++ b/src/Propel/Generator/Platform/MysqlPlatform.php @@ -183,7 +183,7 @@ public function getAddTablesDDL(Database $database) } /** - * @return string|null + * @return string */ public function getBeginDDL() { diff --git a/src/Propel/Generator/Platform/OraclePlatform.php b/src/Propel/Generator/Platform/OraclePlatform.php index 47549ae441..9d78eeb7af 100644 --- a/src/Propel/Generator/Platform/OraclePlatform.php +++ b/src/Propel/Generator/Platform/OraclePlatform.php @@ -94,7 +94,7 @@ public function supportsNativeDeleteTrigger() } /** - * @return string|null + * @return string */ public function getBeginDDL() { @@ -181,6 +181,8 @@ public function getAddPrimaryKeyDDL(Table $table) if (is_array($table->getPrimaryKey()) && count($table->getPrimaryKey())) { return parent::getAddPrimaryKeyDDL($table); } + + return ''; } /** diff --git a/src/Propel/Generator/Platform/SqlitePlatform.php b/src/Propel/Generator/Platform/SqlitePlatform.php index 8d4d302c79..f3a00d3ce2 100644 --- a/src/Propel/Generator/Platform/SqlitePlatform.php +++ b/src/Propel/Generator/Platform/SqlitePlatform.php @@ -253,7 +253,7 @@ public function getMigrationTableDDL(TableDiff $tableDiff) } /** - * @return string|null + * @return string */ public function getBeginDDL() { diff --git a/src/Propel/Generator/Schema/Dumper/XmlDumper.php b/src/Propel/Generator/Schema/Dumper/XmlDumper.php index 1cce58f22a..92e638c2c4 100644 --- a/src/Propel/Generator/Schema/Dumper/XmlDumper.php +++ b/src/Propel/Generator/Schema/Dumper/XmlDumper.php @@ -361,11 +361,11 @@ private function appendColumnNode(Column $column, \DOMNode $parentNode) $domain = $column->getDomain(); if ($size = $domain->getSize()) { - $columnNode->setAttribute('size', $size); + $columnNode->setAttribute('size', (string)$size); } if (null !== ($scale = $domain->getScale())) { - $columnNode->setAttribute('scale', $scale); + $columnNode->setAttribute('scale', (string)$scale); } $platform = $column->getPlatform(); diff --git a/src/Propel/Generator/Util/QuickBuilder.php b/src/Propel/Generator/Util/QuickBuilder.php index 6f28f65219..e1d6983d9d 100644 --- a/src/Propel/Generator/Util/QuickBuilder.php +++ b/src/Propel/Generator/Util/QuickBuilder.php @@ -417,7 +417,9 @@ public function getClassesForTable(Table $table, array $classTargets = null) $script = ''; foreach ($classTargets as $target) { - $class = $this->getConfig()->getConfiguredBuilder($table, $target)->build(); + /** @var \Propel\Generator\Builder\Om\AbstractOMBuilder $abstractBuilder */ + $abstractBuilder = $this->getConfig()->getConfiguredBuilder($table, $target); + $class = $abstractBuilder->build(); $script .= $this->fixNamespaceDeclarations($class); } diff --git a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php index 081249a0e8..4df7a59bbd 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php @@ -1484,10 +1484,11 @@ protected function basePreDelete(ConnectionInterface $con) /** * @param ConnectionInterface $con - * @return int + * @return int|null */ protected function preDelete(ConnectionInterface $con) { + return null; } /** @@ -1505,10 +1506,11 @@ protected function basePostDelete($affectedRows, ConnectionInterface $con) /** * @param int $affectedRows * @param ConnectionInterface $con - * @return int + * @return int|null */ protected function postDelete($affectedRows, ConnectionInterface $con) { + return null; } /** @@ -1628,7 +1630,7 @@ public function doDeleteAll(ConnectionInterface $con = null) * @param array $values The associative array of columns and values for the update * @param ConnectionInterface $con The connection object used by the query * @param boolean $forceIndividualSaves If false (default), the resulting call is a Criteria::doUpdate(), otherwise it is a series of save() calls on all the found objects - * @return int + * @return int|null */ protected function basePreUpdate(&$values, ConnectionInterface $con, $forceIndividualSaves = false) { @@ -1639,10 +1641,11 @@ protected function basePreUpdate(&$values, ConnectionInterface $con, $forceIndiv * @param array $values * @param ConnectionInterface $con * @param bool $forceIndividualSaves - * @return int + * @return int|null */ protected function preUpdate(&$values, ConnectionInterface $con, $forceIndividualSaves = false) { + return null; } /** @@ -1650,7 +1653,7 @@ protected function preUpdate(&$values, ConnectionInterface $con, $forceIndividua * * @param int $affectedRows the number of updated rows * @param ConnectionInterface $con The connection object used by the query - * @return int + * @return int|null */ protected function basePostUpdate($affectedRows, ConnectionInterface $con) { @@ -1660,10 +1663,11 @@ protected function basePostUpdate($affectedRows, ConnectionInterface $con) /** * @param int $affectedRows * @param ConnectionInterface $con - * @return int + * @return int|null */ protected function postUpdate($affectedRows, ConnectionInterface $con) { + return null; } /** From 75bc1f049ae5ed6fd6697b93e50e90d10032c728 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 23 Jul 2020 12:09:22 +0200 Subject: [PATCH 113/208] Fix up baseline errors. --- phpstan-baseline.neon | 139 +----------------- phpstan.neon | 3 + .../Common/Config/XmlToArrayConverter.php | 2 +- .../Archivable/ArchivableBehavior.php | 4 +- .../ConcreteInheritanceBehavior.php | 6 +- .../Generator/Behavior/I18n/I18nBehavior.php | 2 + .../Validate/templates/objectValidate.php | 2 +- ...rsionableBehaviorObjectBuilderModifier.php | 1 + .../Generator/Builder/Om/ObjectBuilder.php | 2 + .../Generator/Builder/Om/TableMapBuilder.php | 1 + .../Command/Helper/ConsoleHelper.php | 2 +- .../Command/Helper/ConsoleHelper3.php | 12 +- .../Command/Helper/ConsoleHelperInterface.php | 4 +- .../Command/MigrationDiffCommand.php | 1 + .../Generator/Config/GeneratorConfig.php | 2 +- .../Config/GeneratorConfigInterface.php | 2 +- .../Generator/Manager/MigrationManager.php | 1 + src/Propel/Generator/Manager/ModelManager.php | 2 + .../Generator/Manager/ReverseManager.php | 5 +- src/Propel/Generator/Manager/SqlManager.php | 1 + src/Propel/Generator/Model/Behavior.php | 2 +- .../Generator/Model/BehaviorableTrait.php | 2 +- src/Propel/Generator/Model/Column.php | 16 +- src/Propel/Generator/Model/Database.php | 3 +- src/Propel/Generator/Model/Domain.php | 2 +- src/Propel/Generator/Model/MappingModel.php | 2 +- src/Propel/Generator/Model/Schema.php | 2 +- .../Generator/Model/ScopedMappingModel.php | 2 + src/Propel/Generator/Model/Table.php | 99 +++++++------ .../Generator/Platform/SqlitePlatform.php | 4 +- .../Generator/Reverse/MssqlSchemaParser.php | 5 +- src/Propel/Generator/Util/QuickBuilder.php | 11 +- src/Propel/Runtime/ActiveQuery/Criteria.php | 8 +- .../ActiveQuery/Criterion/BasicCriterion.php | 2 +- .../ActiveQuery/Criterion/LikeCriterion.php | 2 +- .../Criterion/LikeModelCriterion.php | 2 +- .../Runtime/ActiveQuery/ModelCriteria.php | 2 +- .../Runtime/Collection/OnDemandIterator.php | 4 +- src/Propel/Runtime/Map/ColumnMap.php | 6 +- src/Propel/Runtime/Map/TableMap.php | 4 + .../Runtime/Util/PropelConditionalProxy.php | 2 +- 41 files changed, 142 insertions(+), 234 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 381e393dc1..9e198e748c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,10 +1,5 @@ parameters: ignoreErrors: - - - message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\TreeBuilder\\:\\:root\\(\\)\\.$#" - count: 1 - path: src/Propel/Common/Config/PropelConfiguration.php - - message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:scalarNode\\(\\)\\.$#" count: 4 @@ -40,46 +35,11 @@ parameters: count: 1 path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php - - - message: "#^Parameter \\#1 \\$builder of method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehavior\\:\\:getArchiveTablePhpName\\(\\) expects Propel\\\\Generator\\\\Builder\\\\Om\\\\ObjectBuilder, Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractOMBuilder given\\.$#" - count: 3 - path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php - - - - message: "#^Parameter \\#1 \\$builder of method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehavior\\:\\:getArchiveTableQueryName\\(\\) expects Propel\\\\Generator\\\\Builder\\\\Om\\\\ObjectBuilder, Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractOMBuilder given\\.$#" - count: 2 - path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php - - - - message: "#^Parameter \\#1 \\$builder of method Propel\\\\Generator\\\\Behavior\\\\Archivable\\\\ArchivableBehavior\\:\\:getArchiveTablePhpName\\(\\) expects Propel\\\\Generator\\\\Builder\\\\Om\\\\ObjectBuilder, Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractOMBuilder given\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php - - message: "#^Access to an undefined property Propel\\\\Generator\\\\Model\\\\ForeignKey\\:\\:\\$isParentChild\\.$#" count: 1 path: src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:mergeParameters\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getParametersFromColumnName\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/I18n/I18nBehavior.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:removeParametersFromColumnName\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/I18n/I18nBehavior.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:addRuleOnPk\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/I18n/I18nBehavior.php - - message: "#^Ternary operator condition is always false\\.$#" count: 1 @@ -110,11 +70,6 @@ parameters: count: 1 path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Model\\\\Behavior\\:\\:getVersionTable\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php - - message: "#^Parameter \\#1 \\$v of method Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\:\\:setGeneratorConfig\\(\\) expects Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface, \\$this\\(Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\) given\\.$#" count: 1 @@ -247,39 +202,19 @@ parameters: - message: "#^Variable \\$mysqlInvalidDateString might not be defined\\.$#" - count: 2 - path: src/Propel/Generator/Builder/Om/ObjectBuilder.php - - - - message: "#^Variable \\$crossFK might not be defined\\.$#" count: 1 path: src/Propel/Generator/Builder/Om/ObjectBuilder.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getSequenceName\\(\\)\\.$#" + message: "#^Variable \\$crossFK might not be defined\\.$#" count: 1 path: src/Propel/Generator/Builder/Om/ObjectBuilder.php - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:isNativeIdMethodAutoIncrement\\(\\)\\.$#" - count: 2 - path: src/Propel/Generator/Builder/Om/ObjectBuilder.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getIdentifierPhp\\(\\)\\.$#" - count: 2 - path: src/Propel/Generator/Builder/Om/ObjectBuilder.php - - message: "#^Left side of && is always true\\.$#" count: 1 path: src/Propel/Generator/Builder/Om/TableMapBuilder.php - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getSequenceName\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Builder/Om/TableMapBuilder.php - - message: "#^Parameter \\#2 \\$shdl of function xml_set_element_handler expects callable\\(\\)\\: mixed, 'startElement' given\\.$#" count: 1 @@ -290,16 +225,6 @@ parameters: count: 1 path: src/Propel/Generator/Builder/Util/SchemaReader.php - - - message: "#^Parameter \\#1 \\$attempts of method Symfony\\\\Component\\\\Console\\\\Question\\\\Question\\:\\:setMaxAttempts\\(\\) expects int\\|null, true given\\.$#" - count: 1 - path: src/Propel/Generator/Command/Helper/ConsoleHelper3.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getModifyDatabaseDDL\\(\\)\\.$#" - count: 2 - path: src/Propel/Generator/Command/MigrationDiffCommand.php - - message: "#^Variable \\$migration might not be defined\\.$#" count: 1 @@ -315,11 +240,6 @@ parameters: count: 1 path: src/Propel/Generator/Config/ArrayToPhpConverter.php - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Reverse\\\\SchemaParserInterface\\:\\:setMigrationTable\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Config/GeneratorConfig.php - - message: "#^Negated boolean expression is always false\\.$#" count: 1 @@ -336,35 +256,10 @@ parameters: path: src/Propel/Generator/Manager/AbstractManager.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getAddTableDDL\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Manager/MigrationManager.php - - - - message: "#^Parameter \\#1 \\$builder of method Propel\\\\Generator\\\\Manager\\\\ModelManager\\:\\:doBuild\\(\\) expects Propel\\\\Generator\\\\Builder\\\\Om\\\\AbstractOMBuilder, Propel\\\\Generator\\\\Builder\\\\DataModelBuilder given\\.$#" - count: 5 - path: src/Propel/Generator/Manager/ModelManager.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\:\\:setChild\\(\\)\\.$#" - count: 2 - path: src/Propel/Generator/Manager/ModelManager.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:getBuildConnection\\(\\)\\.$#" + message: "#^Right side of && is always false\\.$#" count: 1 path: src/Propel/Generator/Manager/ReverseManager.php - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:getConnection\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Manager/ReverseManager.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getAddTablesDDL\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Manager/SqlManager.php - - message: "#^Strict comparison using \\=\\=\\= between null and string will always evaluate to false\\.$#" count: 1 @@ -400,11 +295,6 @@ parameters: count: 1 path: src/Propel/Generator/Model/Schema.php - - - message: "#^Parameter \\#1 \\$namespace of method Propel\\\\Generator\\\\Model\\\\ScopedMappingModel\\:\\:setNamespace\\(\\) expects string, null given\\.$#" - count: 1 - path: src/Propel/Generator/Model/Schema.php - - message: "#^Strict comparison using \\=\\=\\= between null and array\\ will always evaluate to false\\.$#" count: 1 @@ -460,11 +350,6 @@ parameters: count: 1 path: src/Propel/Generator/Platform/SqlitePlatform.php - - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\DataFetcher\\\\DataFetcherInterface\\:\\:setStyle\\(\\)\\.$#" - count: 3 - path: src/Propel/Generator/Reverse/MssqlSchemaParser.php - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Config\\\\GeneratorConfigInterface\\:\\:get\\(\\)\\.$#" count: 1 @@ -525,31 +410,11 @@ parameters: count: 1 path: src/Propel/Generator/Util/QuickBuilder.php - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getModifyDatabaseDDL\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Util/QuickBuilder.php - - message: "#^Parameter \\#2 \\$code of class Propel\\\\Generator\\\\Exception\\\\BuildException constructor expects int, null given\\.$#" count: 1 path: src/Propel/Generator/Util/QuickBuilder.php - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Platform\\\\PlatformInterface\\:\\:getAddTablesDDL\\(\\)\\.$#" - count: 1 - path: src/Propel/Generator/Util/QuickBuilder.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\:\\:setChild\\(\\)\\.$#" - count: 2 - path: src/Propel/Generator/Util/QuickBuilder.php - - - - message: "#^Call to an undefined method Propel\\\\Generator\\\\Builder\\\\DataModelBuilder\\:\\:build\\(\\)\\.$#" - count: 3 - path: src/Propel/Generator/Util/QuickBuilder.php - - message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\BaseModelCriteria\\:\\:\\$useAliasInSQL\\.$#" count: 1 diff --git a/phpstan.neon b/phpstan.neon index 4e42a9c864..8ded3db4ee 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -20,4 +20,7 @@ parameters: ignoreErrors: - '#Call to an undefined method .+Collection::.+Array\(\)#' - '#Class .+TreeBuilder constructor invoked with 0 parameters, 1-3 required#' + - + message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\TreeBuilder\\:\\:root\\(\\)\\.$#" + path: src/Propel/Common/Config/PropelConfiguration.php - '#PHPDoc tag @throws with type .+FileLoaderLoadException|.+LoaderLoadException is not subtype of Throwable#' diff --git a/src/Propel/Common/Config/XmlToArrayConverter.php b/src/Propel/Common/Config/XmlToArrayConverter.php index 317f8215b3..bd48f0ac5e 100644 --- a/src/Propel/Common/Config/XmlToArrayConverter.php +++ b/src/Propel/Common/Config/XmlToArrayConverter.php @@ -97,7 +97,7 @@ protected static function simpleXmlToArray($xml) // add the children attributes as if they where children foreach ($v->attributes() as $ak => $av) { - if ($ak == 'id') { + if ($ak === 'id') { // special exception: if there is a key named 'id' // then we will name the current key after that id $k = self::getConvertedXmlValue($av); diff --git a/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php b/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php index 1d8e899c69..6d53be3621 100644 --- a/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php +++ b/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php @@ -148,7 +148,7 @@ public function getArchiveTable() } /** - * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder * * @return mixed */ @@ -162,7 +162,7 @@ public function getArchiveTablePhpName($builder) } /** - * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder * * @return string */ diff --git a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php index 479ed3d40b..2d70d77fee 100644 --- a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php +++ b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php @@ -116,12 +116,14 @@ public function modifyTable() continue; } - if ($behavior->getName() == 'concrete_inheritance_parent' || $behavior->getName() == 'concrete_inheritance') { + if ($behavior->getName() === 'concrete_inheritance_parent' || $behavior->getName() === 'concrete_inheritance') { continue; } // validate behavior. If validate behavior already exists, clone only rules from parent if ('validate' === $behavior->getName() && $table->hasBehavior('validate')) { - $table->getBehavior('validate')->mergeParameters($behavior->getParameters()); + /** @var \Propel\Generator\Behavior\Validate\ValidateBehavior $validateBehavior */ + $validateBehavior = $table->getBehavior('validate'); + $validateBehavior->mergeParameters($behavior->getParameters()); continue; } diff --git a/src/Propel/Generator/Behavior/I18n/I18nBehavior.php b/src/Propel/Generator/Behavior/I18n/I18nBehavior.php index 334b37572f..87525f458a 100644 --- a/src/Propel/Generator/Behavior/I18n/I18nBehavior.php +++ b/src/Propel/Generator/Behavior/I18n/I18nBehavior.php @@ -299,6 +299,7 @@ protected function moveI18nColumns(): void // validate behavior: move rules associated to the column if ($table->hasBehavior('validate')) { + /** @var \Propel\Generator\Behavior\Validate\ValidateBehavior $validateBehavior */ $validateBehavior = $table->getBehavior('validate'); $params = $validateBehavior->getParametersFromColumnName($columnName); $i18nValidateParams = array_merge($i18nValidateParams, $params); @@ -320,6 +321,7 @@ protected function moveI18nColumns(): void $i18nTable->addBehavior($i18nVbehavior); // current table must have almost 1 validation rule + /** @var \Propel\Generator\Behavior\Validate\ValidateBehavior $validate */ $validate = $table->getBehavior('validate'); $validate->addRuleOnPk(); } diff --git a/src/Propel/Generator/Behavior/Validate/templates/objectValidate.php b/src/Propel/Generator/Behavior/Validate/templates/objectValidate.php index d313b5f70b..888e32c69e 100644 --- a/src/Propel/Generator/Behavior/Validate/templates/objectValidate.php +++ b/src/Propel/Generator/Behavior/Validate/templates/objectValidate.php @@ -60,6 +60,6 @@ public function validate(ValidatorInterface $validator = null) $this->validationFailures = $failureMap; - return (Boolean) (!(count($this->validationFailures) > 0)); + return (bool) (!(count($this->validationFailures) > 0)); } diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php index e0378231dc..3a5582e48f 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php @@ -570,6 +570,7 @@ public function populateFromVersion(\$version, \$con = null, &\$loadedObjects = $plural = false; $fkPhpName = $this->builder->getRefFKPhpNameAffix($fk, $plural); $foreignTable = $fk->getTable(); + /** @var \Propel\Generator\Behavior\Versionable\VersionableBehavior $foreignBehavior */ $foreignBehavior = $foreignTable->getBehavior($this->behavior->getId()); $foreignVersionTable = $foreignBehavior->getVersionTable(); $fkColumnIds = $this->behavior->getReferrerIdsColumn($fk); diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index 860bc66378..c8ca583cf2 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -805,6 +805,7 @@ public function addTemporalAccessorComment(&$script, Column $column) $dateTimeClass = $this->getDateTimeClass($column); $handleMysqlDate = false; + $mysqlInvalidDateString = ''; if ($this->getPlatform() instanceof MysqlPlatform) { if ($column->getType() === PropelTypes::TIMESTAMP) { $handleMysqlDate = true; @@ -6028,6 +6029,7 @@ protected function addDoInsertBodyRaw() '\PDO' ); $table = $this->getTable(); + /** @var \Propel\Generator\Platform\DefaultPlatform $platform */ $platform = $this->getPlatform(); $primaryKeyMethodInfo = ''; if ($table->getIdMethodParameters()) { diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index 80a74c8e48..f467c8e7dd 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -461,6 +461,7 @@ protected function addInitialize(&$script) { $table = $this->getTable(); + /** @var \Propel\Generator\Platform\DefaultPlatform $platform */ $platform = $this->getPlatform(); $script .= " diff --git a/src/Propel/Generator/Command/Helper/ConsoleHelper.php b/src/Propel/Generator/Command/Helper/ConsoleHelper.php index c89349f54d..0f818411b9 100644 --- a/src/Propel/Generator/Command/Helper/ConsoleHelper.php +++ b/src/Propel/Generator/Command/Helper/ConsoleHelper.php @@ -85,7 +85,7 @@ private function formatQuestion($question, $default = null) /** * @inheritdoc */ - public function select($question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false) + public function select($question, $choices, $default = null, $attempts = null, $errorMessage = 'Value "%s" is invalid', $multiselect = false) { return parent::select( $this->output, diff --git a/src/Propel/Generator/Command/Helper/ConsoleHelper3.php b/src/Propel/Generator/Command/Helper/ConsoleHelper3.php index a17e4133c8..4c6d9192cd 100644 --- a/src/Propel/Generator/Command/Helper/ConsoleHelper3.php +++ b/src/Propel/Generator/Command/Helper/ConsoleHelper3.php @@ -88,18 +88,18 @@ public function writeSummary($items) /** * @inheritdoc */ - public function select($question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false) + public function select($question, $choices, $default = null, $attempts = null, $errorMessage = 'Value "%s" is invalid', $multiselect = false) { - $question = new ChoiceQuestion($this->formatQuestion($question, $default), $choices, $default); + $choiceQuestion = new ChoiceQuestion($this->formatQuestion($question, $default), $choices, $default); if ($attempts) { - $question->setMaxAttempts($attempts); + $choiceQuestion->setMaxAttempts($attempts); } - $question->setErrorMessage($errorMessage); - $question->setMultiselect($multiselect); + $choiceQuestion->setErrorMessage($errorMessage); + $choiceQuestion->setMultiselect($multiselect); - return parent::ask($this->input, $this->output, $question); + return parent::ask($this->input, $this->output, $choiceQuestion); } /** diff --git a/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php b/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php index 7939cd2a6e..985b6c347b 100644 --- a/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php +++ b/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php @@ -51,13 +51,13 @@ public function writeSummary($items); * @param string $question * @param array $choices * @param string $default - * @param bool $attempts + * @param int|null $attempts * @param string $errorMessage * @param bool $multiselect * * @return mixed */ - public function select($question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false); + public function select($question, $choices, $default = null, $attempts = null, $errorMessage = 'Value "%s" is invalid', $multiselect = false); /** * @param string $question diff --git a/src/Propel/Generator/Command/MigrationDiffCommand.php b/src/Propel/Generator/Command/MigrationDiffCommand.php index 2065e3d6dd..6148d79e33 100644 --- a/src/Propel/Generator/Command/MigrationDiffCommand.php +++ b/src/Propel/Generator/Command/MigrationDiffCommand.php @@ -201,6 +201,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $conn = $manager->getAdapterConnection($name); + /** @var \Propel\Generator\Platform\DefaultPlatform $platform */ $platform = $generatorConfig->getConfiguredPlatform($conn, $name); if ($input->getOption('disable-identifier-quoting')) { $platform->setIdentifierQuoting(false); diff --git a/src/Propel/Generator/Config/GeneratorConfig.php b/src/Propel/Generator/Config/GeneratorConfig.php index f8c62069cd..a3a8cc91a8 100644 --- a/src/Propel/Generator/Config/GeneratorConfig.php +++ b/src/Propel/Generator/Config/GeneratorConfig.php @@ -133,7 +133,7 @@ public function getConfiguredSchemaParser(ConnectionInterface $con = null, $data throw new ClassNotFoundException(sprintf('Reverse SchemaParser class for `%s` not found.', $reverse)); } - /** @var SchemaParserInterface $parser */ + /** @var \Propel\Generator\Reverse\AbstractSchemaParser $parser */ $parser = $this->getInstance($reverseClass, null, '\\Propel\\Generator\\Reverse\\SchemaParserInterface'); $parser->setConnection($con); $parser->setMigrationTable($this->get()['migrations']['tableName']); diff --git a/src/Propel/Generator/Config/GeneratorConfigInterface.php b/src/Propel/Generator/Config/GeneratorConfigInterface.php index 57aeddcf8d..940910c1cc 100644 --- a/src/Propel/Generator/Config/GeneratorConfigInterface.php +++ b/src/Propel/Generator/Config/GeneratorConfigInterface.php @@ -26,7 +26,7 @@ interface GeneratorConfigInterface * * @param Table $table * @param string $type - * @return DataModelBuilder + * @return \Propel\Generator\Builder\Om\AbstractOMBuilder */ public function getConfiguredBuilder(Table $table, $type); diff --git a/src/Propel/Generator/Manager/MigrationManager.php b/src/Propel/Generator/Manager/MigrationManager.php index a7a8f0c80c..d573897d6e 100644 --- a/src/Propel/Generator/Manager/MigrationManager.php +++ b/src/Propel/Generator/Manager/MigrationManager.php @@ -194,6 +194,7 @@ public function migrationTableExists($datasource) */ public function createMigrationTable($datasource) { + /** @var \Propel\Generator\Platform\DefaultPlatform $platform */ $platform = $this->getPlatform($datasource); // modelize the table $database = new Database($datasource); diff --git a/src/Propel/Generator/Manager/ModelManager.php b/src/Propel/Generator/Manager/ModelManager.php index a8985a01ca..9bedecb551 100644 --- a/src/Propel/Generator/Manager/ModelManager.php +++ b/src/Propel/Generator/Manager/ModelManager.php @@ -96,12 +96,14 @@ public function build() if (!$child->getAncestor() && $child->getClassName() === $table->getPhpName()) { continue; } + /** @var \Propel\Generator\Builder\Om\QueryInheritanceBuilder $builder */ $builder = $generatorConfig->getConfiguredBuilder($table, $target); $builder->setChild($child); $nbWrittenFiles += $this->doBuild($builder, $overwrite); } $overwrite = false; foreach (['objectmultiextend', 'queryinheritancestub'] as $target) { + /** @var \Propel\Generator\Builder\Om\MultiExtendObjectBuilder $builder */ $builder = $generatorConfig->getConfiguredBuilder($table, $target); $builder->setChild($child); $nbWrittenFiles += $this->doBuild($builder, $overwrite); diff --git a/src/Propel/Generator/Manager/ReverseManager.php b/src/Propel/Generator/Manager/ReverseManager.php index 87788e3f3a..0ed63ac61b 100644 --- a/src/Propel/Generator/Manager/ReverseManager.php +++ b/src/Propel/Generator/Manager/ReverseManager.php @@ -153,7 +153,7 @@ public function setSamePhpName($samePhpName) */ public function setAddVendorInfo($addVendorInfo) { - $this->addVendorInfo = (Boolean) $addVendorInfo; + $this->addVendorInfo = (bool) $addVendorInfo; } /** @@ -200,6 +200,7 @@ public function reverse() */ protected function buildModel() { + /** @var \Propel\Generator\Config\GeneratorConfig $config */ $config = $this->getGeneratorConfig(); $connection = $this->getConnection(); $databaseName = $config->getConfigProperty('reverse.connection'); @@ -259,7 +260,9 @@ protected function buildModel() */ protected function getConnection() { + /** @var \Propel\Generator\Config\GeneratorConfig $generatorConfig */ $generatorConfig = $this->getGeneratorConfig(); + /** @var string|null $database */ $database = $generatorConfig->getConfigProperty('reverse.connection'); if (null === $database) { diff --git a/src/Propel/Generator/Manager/SqlManager.php b/src/Propel/Generator/Manager/SqlManager.php index e98ceb9dcb..110d6fff12 100644 --- a/src/Propel/Generator/Manager/SqlManager.php +++ b/src/Propel/Generator/Manager/SqlManager.php @@ -110,6 +110,7 @@ public function buildSql() { $sqlDbMapContent = "# Sqlfile -> Database map\n"; foreach ($this->getDatabases() as $datasource => $database) { + /** @var \Propel\Generator\Platform\DefaultPlatform $platform */ $platform = $database->getPlatform(); $filename = $database->getName() . '.sql'; diff --git a/src/Propel/Generator/Model/Behavior.php b/src/Propel/Generator/Model/Behavior.php index 2af7869e27..b1955aafca 100644 --- a/src/Propel/Generator/Model/Behavior.php +++ b/src/Propel/Generator/Model/Behavior.php @@ -54,7 +54,7 @@ class Behavior extends MappingModel * * @var array */ - protected $parameters = [ ]; + protected $parameters = []; /** * Wether or not the table has been diff --git a/src/Propel/Generator/Model/BehaviorableTrait.php b/src/Propel/Generator/Model/BehaviorableTrait.php index 1750cd48fc..c8d6e77a5f 100644 --- a/src/Propel/Generator/Model/BehaviorableTrait.php +++ b/src/Propel/Generator/Model/BehaviorableTrait.php @@ -14,7 +14,7 @@ trait BehaviorableTrait /** * @var Behavior[] */ - protected $behaviors; + protected $behaviors = []; /** * @var BehaviorLocator diff --git a/src/Propel/Generator/Model/Column.php b/src/Propel/Generator/Model/Column.php index ed9a7ea449..b170bdc2d8 100644 --- a/src/Propel/Generator/Model/Column.php +++ b/src/Propel/Generator/Model/Column.php @@ -857,7 +857,7 @@ public function isNotNull() */ public function setNotNull($flag = true) { - $this->isNotNull = (Boolean) $flag; + $this->isNotNull = (bool) $flag; } /** @@ -880,7 +880,7 @@ public function getNotNullString() */ public function setPrimaryString($isPrimaryString) { - $this->isPrimaryString = (Boolean) $isPrimaryString; + $this->isPrimaryString = (bool) $isPrimaryString; } /** @@ -901,7 +901,7 @@ public function isPrimaryString() */ public function setPrimaryKey($flag = true) { - $this->isPrimaryKey = (Boolean) $flag; + $this->isPrimaryKey = (bool) $flag; } /** @@ -921,7 +921,7 @@ public function isPrimaryKey() */ public function setNodeKey($isNodeKey) { - $this->isNodeKey = (Boolean) $isNodeKey; + $this->isNodeKey = (bool) $isNodeKey; } /** @@ -961,7 +961,7 @@ public function getNodeKeySep() */ public function setNestedSetLeftKey($isNestedSetLeftKey) { - $this->isNestedSetLeftKey = (Boolean) $isNestedSetLeftKey; + $this->isNestedSetLeftKey = (bool) $isNestedSetLeftKey; } /** @@ -981,7 +981,7 @@ public function isNestedSetLeftKey() */ public function setNestedSetRightKey($isNestedSetRightKey) { - $this->isNestedSetRightKey = (Boolean) $isNestedSetRightKey; + $this->isNestedSetRightKey = (bool) $isNestedSetRightKey; } /** @@ -1001,7 +1001,7 @@ public function isNestedSetRightKey() */ public function setTreeScopeKey($isTreeScopeKey) { - $this->isTreeScopeKey = (Boolean) $isTreeScopeKey; + $this->isTreeScopeKey = (bool) $isTreeScopeKey; } /** @@ -1491,7 +1491,7 @@ public function getAutoIncrementString() */ public function setAutoIncrement($flag = true) { - $this->isAutoIncrement = (Boolean) $flag; + $this->isAutoIncrement = (bool) $flag; } /** diff --git a/src/Propel/Generator/Model/Database.php b/src/Propel/Generator/Model/Database.php index 0ad2ad8d11..3abed40a7d 100644 --- a/src/Propel/Generator/Model/Database.php +++ b/src/Propel/Generator/Model/Database.php @@ -28,7 +28,6 @@ */ class Database extends ScopedMappingModel { - use BehaviorableTrait; /** @@ -390,7 +389,7 @@ public function getHeavyIndexing() */ public function setHeavyIndexing($flag = true) { - $this->heavyIndexing = (Boolean) $flag; + $this->heavyIndexing = (bool) $flag; } /** diff --git a/src/Propel/Generator/Model/Domain.php b/src/Propel/Generator/Model/Domain.php index 4ccc920603..0dff16ceff 100644 --- a/src/Propel/Generator/Model/Domain.php +++ b/src/Propel/Generator/Model/Domain.php @@ -269,7 +269,7 @@ public function getDefaultValue() /** * Returns the default value, type-casted for use in PHP OM. * - * @return mixed|null + * @return string|array|bool|null */ public function getPhpDefaultValue() { diff --git a/src/Propel/Generator/Model/MappingModel.php b/src/Propel/Generator/Model/MappingModel.php index 557a954955..df0221e641 100644 --- a/src/Propel/Generator/Model/MappingModel.php +++ b/src/Propel/Generator/Model/MappingModel.php @@ -100,7 +100,7 @@ protected function booleanValue($value) } if (is_numeric($value)) { - return (Boolean) $value; + return (bool) $value; } return in_array(strtolower($value), [ 'true', 't', 'y', 'yes' ], true); diff --git a/src/Propel/Generator/Model/Schema.php b/src/Propel/Generator/Model/Schema.php index 6ead874db1..0d5b56280c 100644 --- a/src/Propel/Generator/Model/Schema.php +++ b/src/Propel/Generator/Model/Schema.php @@ -264,7 +264,7 @@ public function joinSchemas(array $schemas) $db = $this->getDatabase($addDbName, false); // temporarily reset database namespace to avoid double namespace decoration (see ticket #1355) $namespace = $db->getNamespace(); - $db->setNamespace(null); + $db->setNamespace(''); // join tables foreach ($addDb->getTables() as $addTable) { if ($db->getTable($addTable->getName())) { diff --git a/src/Propel/Generator/Model/ScopedMappingModel.php b/src/Propel/Generator/Model/ScopedMappingModel.php index 9ba3ef7053..b9e4f1bcec 100644 --- a/src/Propel/Generator/Model/ScopedMappingModel.php +++ b/src/Propel/Generator/Model/ScopedMappingModel.php @@ -84,6 +84,8 @@ public function getNamespace() * Sets the namespace. * * @param string $namespace + * + * @return void */ public function setNamespace($namespace) { diff --git a/src/Propel/Generator/Model/Table.php b/src/Propel/Generator/Model/Table.php index 467766ebc7..14ad2ec467 100644 --- a/src/Propel/Generator/Model/Table.php +++ b/src/Propel/Generator/Model/Table.php @@ -37,39 +37,42 @@ class Table extends ScopedMappingModel implements IdMethod /** * @var Column[] */ - private $columns; + private $columns = []; /** * @var ForeignKey[] */ - private $foreignKeys; + private $foreignKeys = []; /** * @var ForeignKey[] */ - private $foreignKeysByName; + private $foreignKeysByName = []; /** * @var string[] */ - private $foreignTableNames; + private $foreignTableNames = []; /** * @var Index[] */ - private $indices; + private $indices = []; /** * @var Unique[] */ - private $unices; - private $idMethodParameters; + private $unices = []; + /** + * @var IdMethodParameter[] + */ + private $idMethodParameters = []; private $commonName; private $originCommonName; private $description; private $phpName; private $idMethod; - private $allowPkInsert; + private $allowPkInsert = false; private $phpNamingMethod; /** @@ -80,36 +83,54 @@ class Table extends ScopedMappingModel implements IdMethod /** * @var ForeignKey[] */ - private $referrers; - private $containsForeignPK; + private $referrers = []; + + /** + * @var bool + */ + private $containsForeignPK = false; + /** * @var Column|null */ private $inheritanceColumn; - private $skipSql; - private $readOnly; - private $isAbstract; + + private $skipSql = false; + private $readOnly = false; + private $isAbstract = false; private $alias; private $interface; private $baseClass; private $baseQueryClass; - private $columnsByName; - private $columnsByLowercaseName; - private $columnsByPhpName; - private $needsTransactionInPostgres; + private $columnsByName = []; + private $columnsByLowercaseName = []; + private $columnsByPhpName = []; + private $needsTransactionInPostgres = false; /** - * @var boolean + * @var bool */ - private $heavyIndexing; + private $heavyIndexing = false; /** - * @var boolean + * @var bool|null */ private $identifierQuoting; - private $forReferenceOnly; - private $reloadOnInsert; - private $reloadOnUpdate; + + /** + * @var bool + */ + private $forReferenceOnly = false; + + /** + * @var bool + */ + private $reloadOnInsert = false; + + /** + * @var bool + */ + private $reloadOnUpdate = false; /** * The default accessor visibility. @@ -129,7 +150,14 @@ class Table extends ScopedMappingModel implements IdMethod */ private $defaultMutatorVisibility; - protected $isCrossRef; + /** + * @var bool + */ + protected $isCrossRef = false; + + /** + * @var string|null + */ protected $defaultStringFormat; /** @@ -148,25 +176,6 @@ public function __construct($name = null) $this->idMethod = IdMethod::NO_ID_METHOD; $this->defaultAccessorVisibility = static::VISIBILITY_PUBLIC; $this->defaultMutatorVisibility = static::VISIBILITY_PUBLIC; - $this->allowPkInsert = false; - $this->isAbstract = false; - $this->isCrossRef = false; - $this->readOnly = false; - $this->reloadOnInsert = false; - $this->reloadOnUpdate = false; - $this->skipSql = false; - $this->behaviors = []; - $this->columns = []; - $this->columnsByName = []; - $this->columnsByPhpName = []; - $this->columnsByLowercaseName = []; - $this->foreignKeys = []; - $this->foreignKeysByName = []; - $this->foreignTableNames = []; - $this->idMethodParameters = []; - $this->indices = []; - $this->referrers = []; - $this->unices = []; } /** @@ -891,7 +900,7 @@ public function getOtherRequiredPrimaryKeys(array $primaryKeys) */ public function setContainsForeignPK($containsForeignPK) { - $this->containsForeignPK = (Boolean) $containsForeignPK; + $this->containsForeignPK = (bool) $containsForeignPK; } /** @@ -1333,7 +1342,7 @@ public function isSkipSql() */ public function setSkipSql($skip) { - $this->skipSql = (Boolean) $skip; + $this->skipSql = (bool) $skip; } /** diff --git a/src/Propel/Generator/Platform/SqlitePlatform.php b/src/Propel/Generator/Platform/SqlitePlatform.php index f3a00d3ce2..69e46bdc2f 100644 --- a/src/Propel/Generator/Platform/SqlitePlatform.php +++ b/src/Propel/Generator/Platform/SqlitePlatform.php @@ -167,10 +167,10 @@ public function getModifyTableDDL(TableDiff $tableDiff) //or an expression in parentheses. || false !== array_search( $column->getDefaultValue(), ['CURRENT_TIME', 'CURRENT_DATE', 'CURRENT_TIMESTAMP']) - || substr(trim($column->getDefaultValue()), 0, 1) == '(' + || substr(trim($column->getDefaultValue()), 0, 1) === '(' //If a NOT NULL constraint is specified, then the column must have a default value other than NULL. - || ($column->isNotNull() && $column->getDefaultValue() == 'NULL') + || ($column->isNotNull() && $column->getDefaultValue()->getValue() === 'NULL') ; if ($sqlChangeNotSupported) { diff --git a/src/Propel/Generator/Reverse/MssqlSchemaParser.php b/src/Propel/Generator/Reverse/MssqlSchemaParser.php index 6c444e3b54..0d552b84c5 100644 --- a/src/Propel/Generator/Reverse/MssqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/MssqlSchemaParser.php @@ -125,6 +125,7 @@ public function parse(Database $database, array $additionalTables = []) */ protected function addColumns(Table $table) { + /** @var \Propel\Runtime\DataFetcher\PDODataFetcher $dataFetcher */ $dataFetcher = $this->dbh->query("sp_columns '" . $table->getName() . "'"); $dataFetcher->setStyle(\PDO::FETCH_ASSOC); @@ -137,7 +138,7 @@ protected function addColumns(Table $table) $default = $row['COLUMN_DEF']; $scale = $row['SCALE']; $autoincrement = false; - if (strtolower($type) == 'int identity') { + if (strtolower($type) === 'int identity') { $autoincrement = true; } @@ -171,6 +172,7 @@ protected function addForeignKeys(Table $table) { $database = $table->getDatabase(); + /** @var \Propel\Runtime\DataFetcher\PDODataFetcher $dataFetcher */ $dataFetcher = $this->dbh->query("select fk.name as CONSTRAINT_NAME, lcol.name as COLUMN_NAME, rtab.name as FK_TABLE_NAME, rcol.name as FK_COLUMN_NAME from sys.foreign_keys as fk inner join sys.foreign_key_columns ref on ref.constraint_object_id = fk.object_id @@ -211,6 +213,7 @@ protected function addForeignKeys(Table $table) */ protected function addIndexes(Table $table) { + /** @var \Propel\Runtime\DataFetcher\PDODataFetcher $dataFetcher */ $dataFetcher = $this->dbh->query("sp_indexes_rowset '" . $table->getName() . "'"); $dataFetcher->setStyle(\PDO::FETCH_ASSOC); diff --git a/src/Propel/Generator/Util/QuickBuilder.php b/src/Propel/Generator/Util/QuickBuilder.php index e1d6983d9d..c72fbba18c 100644 --- a/src/Propel/Generator/Util/QuickBuilder.php +++ b/src/Propel/Generator/Util/QuickBuilder.php @@ -272,7 +272,9 @@ public function updateDB(ConnectionInterface $con) if (false === $diff) { return null; } - $sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff); + /** @var \Propel\Generator\Platform\DefaultPlatform $platform */ + $platform = $this->database->getPlatform(); + $sql = $platform->getModifyDatabaseDDL($diff); $statements = SqlParser::parseString($sql); foreach ($statements as $statement) { @@ -313,7 +315,10 @@ public function readConnectedDatabase() */ public function getSQL() { - return $this->getPlatform()->getAddTablesDDL($this->getDatabase()); + /** @var \Propel\Generator\Platform\DefaultPlatform $platform */ + $platform = $this->getPlatform(); + + return $platform->getAddTablesDDL($this->getDatabase()); } /** @@ -427,12 +432,14 @@ public function getClassesForTable(Table $table, array $classTargets = null) if ($col->isEnumeratedClasses()) { foreach ($col->getChildren() as $child) { if ($child->getAncestor()) { + /** @var \Propel\Generator\Builder\Om\QueryInheritanceBuilder $builder */ $builder = $this->getConfig()->getConfiguredBuilder($table, 'queryinheritance'); $builder->setChild($child); $class = $builder->build(); $script .= $this->fixNamespaceDeclarations($class); foreach (['objectmultiextend', 'queryinheritancestub'] as $target) { + /** @var \Propel\Generator\Builder\Om\MultiExtendObjectBuilder $builder */ $builder = $this->getConfig()->getConfiguredBuilder($table, $target); $builder->setChild($child); $class = $builder->build(); diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index 4ec68a42b6..5921c77974 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -514,7 +514,7 @@ public function hasWhereClause() */ public function setUseTransaction($v) { - $this->useTransaction = (Boolean) $v; + $this->useTransaction = (bool) $v; } /** @@ -1097,7 +1097,7 @@ public function addSelectQuery(Criteria $subQueryCriteria, $alias = null) */ public function hasSelectQueries() { - return (Boolean) $this->selectQueries; + return (bool) $this->selectQueries; } /** @@ -1222,7 +1222,7 @@ public function hasSelectModifier($modifier) */ public function setIgnoreCase($b) { - $this->ignoreCase = (Boolean) $b; + $this->ignoreCase = (bool) $b; return $this; } @@ -1251,7 +1251,7 @@ public function isIgnoreCase() */ public function setSingleRecord($b) { - $this->singleRecord = (Boolean) $b; + $this->singleRecord = (bool) $b; return $this; } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php index 3bcadd19d3..d4b9231170 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php @@ -43,7 +43,7 @@ public function __construct(Criteria $outer, $column, $value, $comparison = Crit */ public function setIgnoreCase($b) { - $this->ignoreStringCase = (Boolean) $b; + $this->ignoreStringCase = (bool) $b; return $this; } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php index 7072a38d65..1e73561db8 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php @@ -43,7 +43,7 @@ public function __construct(Criteria $outer, $column, $value, $comparison = Crit */ public function setIgnoreCase($b) { - $this->ignoreStringCase = (Boolean) $b; + $this->ignoreStringCase = (bool) $b; return $this; } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php index 700591295b..fee6dfdedf 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php @@ -30,7 +30,7 @@ class LikeModelCriterion extends BasicModelCriterion */ public function setIgnoreCase($b) { - $this->ignoreStringCase = (Boolean) $b; + $this->ignoreStringCase = (bool) $b; return $this; } diff --git a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php index 4df7a59bbd..2d44b1ba74 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php @@ -962,7 +962,7 @@ public static function getRelationName($relation) */ public function keepQuery($isKeepQuery = true) { - $this->isKeepQuery = (Boolean) $isKeepQuery; + $this->isKeepQuery = (bool) $isKeepQuery; return $this; } diff --git a/src/Propel/Runtime/Collection/OnDemandIterator.php b/src/Propel/Runtime/Collection/OnDemandIterator.php index c870d9a6b4..ae379b0fed 100644 --- a/src/Propel/Runtime/Collection/OnDemandIterator.php +++ b/src/Propel/Runtime/Collection/OnDemandIterator.php @@ -109,7 +109,7 @@ public function next() { $this->currentRow = $this->dataFetcher->fetch(); $this->currentKey++; - $this->isValid = (Boolean) $this->currentRow; + $this->isValid = (bool) $this->currentRow; if (!$this->isValid) { $this->closeCursor(); } @@ -141,6 +141,6 @@ public function rewind() */ public function valid() { - return (Boolean) $this->isValid; + return (bool) $this->isValid; } } diff --git a/src/Propel/Runtime/Map/ColumnMap.php b/src/Propel/Runtime/Map/ColumnMap.php index e2cb126d3c..14be72c74c 100644 --- a/src/Propel/Runtime/Map/ColumnMap.php +++ b/src/Propel/Runtime/Map/ColumnMap.php @@ -298,7 +298,7 @@ public function getSize() */ public function setPrimaryKey($pk) { - $this->pk = (Boolean) $pk; + $this->pk = (bool) $pk; } /** @@ -318,7 +318,7 @@ public function isPrimaryKey() */ public function setNotNull($nn) { - $this->notNull = (Boolean) $nn; + $this->notNull = (bool) $nn; } /** @@ -533,7 +533,7 @@ public static function normalizeName($name) */ public function setPrimaryString($pkString) { - $this->isPkString = (Boolean) $pkString; + $this->isPkString = (bool) $pkString; } /** diff --git a/src/Propel/Runtime/Map/TableMap.php b/src/Propel/Runtime/Map/TableMap.php index e4a4b7e852..887d9a8a51 100644 --- a/src/Propel/Runtime/Map/TableMap.php +++ b/src/Propel/Runtime/Map/TableMap.php @@ -185,6 +185,8 @@ public function __construct($name = null, $dbMap = null) /** * Initialize the TableMap to build columns, relations, etc * This method should be overridden by descendants + * + * @return void */ public function initialize() { @@ -194,6 +196,7 @@ public function initialize() * Set the DatabaseMap containing this TableMap. * * @param DatabaseMap $dbMap A DatabaseMap. + * @return void */ public function setDatabaseMap(DatabaseMap $dbMap) { @@ -214,6 +217,7 @@ public function getDatabaseMap() * Set the name of the Table. * * @param string $name The name of the table. + * @return void */ public function setName($name) { diff --git a/src/Propel/Runtime/Util/PropelConditionalProxy.php b/src/Propel/Runtime/Util/PropelConditionalProxy.php index f2ce13bdf7..2fa5a0add4 100644 --- a/src/Propel/Runtime/Util/PropelConditionalProxy.php +++ b/src/Propel/Runtime/Util/PropelConditionalProxy.php @@ -128,7 +128,7 @@ protected function getConditionalState() */ protected function setConditionalState($cond) { - $this->state = (Boolean) $cond; + $this->state = (bool) $cond; $this->wasTrue = $this->wasTrue || $this->state; return $this->getCriteriaOrProxy(); From d865734a3c97a6a5491423b02445474709fbce64 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 23 Jul 2020 12:15:52 +0200 Subject: [PATCH 114/208] Fix up baseline errors. --- .../NestedSet/NestedSetBehaviorQueryBuilderModifier.php | 8 ++++---- src/Propel/Generator/Builder/Om/AbstractOMBuilder.php | 4 ++-- src/Propel/Generator/Builder/Om/ObjectBuilder.php | 2 +- src/Propel/Generator/Reverse/SqliteSchemaParser.php | 2 +- src/Propel/Generator/Util/PhpParser.php | 6 +++--- src/Propel/Runtime/ActiveQuery/Criteria.php | 2 +- src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifier.php index bf83ef5e52..409294bbb4 100644 --- a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifier.php @@ -901,16 +901,16 @@ static public function updateLoadedNodes(\$prune = null, ConnectionInterface \$c if ($col->isLazyLoad()) { continue; } - if ($col->getPhpName() == $this->getColumnPhpName('left_column')) { + if ($col->getPhpName() === $this->getColumnPhpName('left_column')) { $script .= " \$object->setLeftValue(\$row[$n]);"; - } elseif ($col->getPhpName() == $this->getColumnPhpName('right_column')) { + } elseif ($col->getPhpName() === $this->getColumnPhpName('right_column')) { $script .= " \$object->setRightValue(\$row[$n]);"; - } elseif ($this->getParameter('use_scope') == 'true' && $col->getPhpName() == $this->getColumnPhpName('scope_column')) { + } elseif ($this->getParameter('use_scope') == 'true' && $col->getPhpName() === $this->getColumnPhpName('scope_column')) { $script .= " \$object->setScopeValue(\$row[$n]);"; - } elseif ($col->getPhpName() == $this->getColumnPhpName('level_column')) { + } elseif ($col->getPhpName() === $this->getColumnPhpName('level_column')) { $script .= " \$object->setLevel(\$row[$n]); \$object->clearNestedSetChildren();"; diff --git a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php index f6d0cd79fb..17be416918 100644 --- a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php @@ -319,11 +319,11 @@ public function declareClassNamespace($class, $namespace = '', $alias = false) // we have a duplicate class and asked for an automatic Alias if (false !== $alias) { - if ('\\Base' == substr($namespace, -5) || 'Base' == $namespace) { + if ('\\Base' === substr($namespace, -5) || 'Base' === $namespace) { return $this->declareClassNamespace($class, $namespace, 'Base' . $class); } - if ('Child' == substr($alias, 0, 5)) { + if ('Child' === substr($alias, 0, 5)) { //we already requested Child.$class and its in use too, //so use the fqcn return ($namespace ? '\\' . $namespace : '') . '\\' . $class; diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index c8ca583cf2..9c7705c74c 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -4023,7 +4023,7 @@ public function initRelation(\$relationName) $relationName = $this->getRefFKPhpNameAffix($refFK); $relCol = $this->getRefFKPhpNameAffix($refFK, true); $script .= " - if ('$relationName' == \$relationName) { + if ('$relationName' === \$relationName) { \$this->init$relCol(); return; }"; diff --git a/src/Propel/Generator/Reverse/SqliteSchemaParser.php b/src/Propel/Generator/Reverse/SqliteSchemaParser.php index eb3338f3c0..20a6e90b60 100644 --- a/src/Propel/Generator/Reverse/SqliteSchemaParser.php +++ b/src/Propel/Generator/Reverse/SqliteSchemaParser.php @@ -150,7 +150,7 @@ protected function parseTables(Database $database, Table $filterTable = null) $tableName = $row[0]; $tableSchema = ''; - if ('sqlite_' == substr($tableName, 0, 7)) { + if ('sqlite_' === substr($tableName, 0, 7)) { continue; } diff --git a/src/Propel/Generator/Util/PhpParser.php b/src/Propel/Generator/Util/PhpParser.php index d324320e59..2a46264db1 100644 --- a/src/Propel/Generator/Util/PhpParser.php +++ b/src/Propel/Generator/Util/PhpParser.php @@ -102,7 +102,7 @@ public function findMethod($methodName) // Single-character tokens. if (is_string($token)) { if (!$isInFunction) { - if ($token == '{' || $token == ';') { + if ($token === '{' || $token === ';') { // class-opening bracket or end of line $buffer = ''; } else { @@ -112,11 +112,11 @@ public function findMethod($methodName) continue; } $methodCode .= $token; - if ($token == '{') { + if ($token === '{') { // Increase the bracket-counter (not the class-brackets: `$isInFunction` must be true!) $functionBracketBalance++; } - if ($token == '}') { + if ($token === '}') { // Decrease the bracket-counter (not the class-brackets: `$isInFunction` must be true!) $functionBracketBalance--; if ($functionBracketBalance == 0) { diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index 5921c77974..4143af63a8 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -2434,7 +2434,7 @@ public function doUpdate($updateValues, ConnectionInterface $con) $rawcvt = ''; // parse the $params['raw'] for ? chars for ($r = 0, $len = strlen($raw); $r < $len; $r++) { - if ($raw[$r] == '?') { + if ($raw[$r] === '?') { $rawcvt .= ':p'.$p++; } else { $rawcvt .= $raw[$r]; diff --git a/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php index a76683573f..1944b061d9 100644 --- a/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php @@ -209,7 +209,7 @@ public function applyLimit(&$sql, $offset, $limit) $selColCount = count($selColArr) - 1; // make sure the current column isn't * or an aggregate - if ($selColArr[0] != '*' && ! strstr($selColArr[0], '(')) { + if ($selColArr[0] !== '*' && ! strstr($selColArr[0], '(')) { if (isset($orderArr[$selColArr[0]])) { $orders[$orderArr[$selColArr[0]]['key']] = $selColArr[0] . ' ' . $orderArr[$selColArr[0]]['sort']; } @@ -243,7 +243,7 @@ public function applyLimit(&$sql, $offset, $limit) // quote the alias $alias = $selColArr[$selColCount]; // don't quote the identifier if it is already quoted - if ($alias[0] != '[') { + if ($alias[0] !== '[') { $alias = $this->quoteIdentifier($alias); } From e1a434b4ed706bec437996addd5bbdcc8eb9ef7f Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 23 Jul 2020 12:59:13 +0200 Subject: [PATCH 115/208] Fix inheritdoc. --- .../Behavior/Sortable/SortableBehavior.php | 2 +- .../Generator/Command/AbstractCommand.php | 2 +- .../Command/ConfigConvertCommand.php | 4 ++-- .../Command/Console/Input/ArrayInput.php | 8 +++---- .../Command/DatabaseReverseCommand.php | 4 ++-- .../Command/GraphvizGenerateCommand.php | 4 ++-- .../Command/MigrationCreateCommand.php | 4 ++-- .../Command/MigrationDiffCommand.php | 4 ++-- .../Command/MigrationDownCommand.php | 4 ++-- .../Command/MigrationMigrateCommand.php | 4 ++-- .../Command/MigrationStatusCommand.php | 4 ++-- .../Generator/Command/MigrationUpCommand.php | 4 ++-- .../Generator/Command/ModelBuildCommand.php | 4 ++-- .../Generator/Command/SqlBuildCommand.php | 4 ++-- .../Generator/Command/SqlInsertCommand.php | 4 ++-- .../Generator/Command/TestPrepareCommand.php | 4 ++-- .../Generator/Config/GeneratorConfig.php | 4 ++-- .../Config/GeneratorConfigInterface.php | 8 +++---- .../Generator/Config/QuickGeneratorConfig.php | 4 ++-- src/Propel/Generator/Model/Table.php | 6 ++--- .../Generator/Platform/DefaultPlatform.php | 2 +- .../Generator/Platform/MssqlPlatform.php | 2 +- .../Generator/Platform/OraclePlatform.php | 2 +- .../Generator/Platform/SqlitePlatform.php | 22 +++++++++---------- .../Runtime/Collection/ObjectCollection.php | 4 ++-- .../ObjectCombinationCollection.php | 8 +++---- .../Runtime/Collection/OnDemandCollection.php | 2 +- .../Validator/Constraints/DateValidator.php | 2 +- 28 files changed, 65 insertions(+), 65 deletions(-) diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php b/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php index 1f4f51d2ef..29101d325e 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php @@ -185,7 +185,7 @@ public function getColumnSetter($name) } /** - * {@inheritdoc} + * @inheritdoc */ public function addParameter(array $parameter) { diff --git a/src/Propel/Generator/Command/AbstractCommand.php b/src/Propel/Generator/Command/AbstractCommand.php index 9e9b820e6c..2e9a969793 100644 --- a/src/Propel/Generator/Command/AbstractCommand.php +++ b/src/Propel/Generator/Command/AbstractCommand.php @@ -31,7 +31,7 @@ abstract class AbstractCommand extends Command protected $filesystem; /** - * {@inheritdoc} + * @inheritdoc */ protected function configure() { diff --git a/src/Propel/Generator/Command/ConfigConvertCommand.php b/src/Propel/Generator/Command/ConfigConvertCommand.php index 0e295dfe39..94c5820096 100644 --- a/src/Propel/Generator/Command/ConfigConvertCommand.php +++ b/src/Propel/Generator/Command/ConfigConvertCommand.php @@ -22,7 +22,7 @@ class ConfigConvertCommand extends AbstractCommand const DEFAULT_OUTPUT_FILE = 'config.php'; /** - * {@inheritdoc} + * @inheritdoc */ protected function configure() { @@ -37,7 +37,7 @@ protected function configure() } /** - * {@inheritdoc} + * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/Propel/Generator/Command/Console/Input/ArrayInput.php b/src/Propel/Generator/Command/Console/Input/ArrayInput.php index 8a30bfa546..4d38b99cd8 100644 --- a/src/Propel/Generator/Command/Console/Input/ArrayInput.php +++ b/src/Propel/Generator/Command/Console/Input/ArrayInput.php @@ -44,7 +44,7 @@ public function __construct(array $parameters, InputDefinition $definition = nul } /** - * {@inheritdoc} + * @inheritdoc */ public function getFirstArgument() { @@ -60,7 +60,7 @@ public function getFirstArgument() } /** - * {@inheritdoc} + * @inheritdoc */ public function hasParameterOption($values, $onlyParams = false) { @@ -84,7 +84,7 @@ public function hasParameterOption($values, $onlyParams = false) } /** - * {@inheritdoc} + * @inheritdoc */ public function getParameterOption($values, $default = false, $onlyParams = false) { @@ -133,7 +133,7 @@ public function __toString() } /** - * {@inheritdoc} + * @inheritdoc */ protected function parse() { diff --git a/src/Propel/Generator/Command/DatabaseReverseCommand.php b/src/Propel/Generator/Command/DatabaseReverseCommand.php index d7b902ab2d..e656a1ecc6 100644 --- a/src/Propel/Generator/Command/DatabaseReverseCommand.php +++ b/src/Propel/Generator/Command/DatabaseReverseCommand.php @@ -27,7 +27,7 @@ class DatabaseReverseCommand extends AbstractCommand const DEFAULT_SCHEMA_NAME = 'schema'; /** - * {@inheritdoc} + * @inheritdoc */ protected function configure() { @@ -51,7 +51,7 @@ protected function configure() } /** - * {@inheritdoc} + * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/Propel/Generator/Command/GraphvizGenerateCommand.php b/src/Propel/Generator/Command/GraphvizGenerateCommand.php index e23ec6cb68..0657479eb3 100644 --- a/src/Propel/Generator/Command/GraphvizGenerateCommand.php +++ b/src/Propel/Generator/Command/GraphvizGenerateCommand.php @@ -23,7 +23,7 @@ class GraphvizGenerateCommand extends AbstractCommand const DEFAULT_OUTPUT_DIRECTORY = 'generated-graphviz'; /** - * {@inheritdoc} + * @inheritdoc */ protected function configure() { @@ -39,7 +39,7 @@ protected function configure() } /** - * {@inheritdoc} + * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/Propel/Generator/Command/MigrationCreateCommand.php b/src/Propel/Generator/Command/MigrationCreateCommand.php index 71e5d4c09c..ccf71e18a6 100644 --- a/src/Propel/Generator/Command/MigrationCreateCommand.php +++ b/src/Propel/Generator/Command/MigrationCreateCommand.php @@ -25,7 +25,7 @@ class MigrationCreateCommand extends AbstractCommand { /** - * {@inheritdoc} + * @inheritdoc */ protected function configure() { @@ -44,7 +44,7 @@ protected function configure() } /** - * {@inheritdoc} + * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/Propel/Generator/Command/MigrationDiffCommand.php b/src/Propel/Generator/Command/MigrationDiffCommand.php index 6148d79e33..4ed0d9aa78 100644 --- a/src/Propel/Generator/Command/MigrationDiffCommand.php +++ b/src/Propel/Generator/Command/MigrationDiffCommand.php @@ -28,7 +28,7 @@ class MigrationDiffCommand extends AbstractCommand { /** - * {@inheritdoc} + * @inheritdoc */ protected function configure() { @@ -53,7 +53,7 @@ protected function configure() } /** - * {@inheritdoc} + * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/Propel/Generator/Command/MigrationDownCommand.php b/src/Propel/Generator/Command/MigrationDownCommand.php index b7acc67834..60f7c77f6e 100644 --- a/src/Propel/Generator/Command/MigrationDownCommand.php +++ b/src/Propel/Generator/Command/MigrationDownCommand.php @@ -23,7 +23,7 @@ class MigrationDownCommand extends AbstractCommand { /** - * {@inheritdoc} + * @inheritdoc */ protected function configure() { @@ -42,7 +42,7 @@ protected function configure() } /** - * {@inheritdoc} + * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/Propel/Generator/Command/MigrationMigrateCommand.php b/src/Propel/Generator/Command/MigrationMigrateCommand.php index f798290613..7e449efc13 100644 --- a/src/Propel/Generator/Command/MigrationMigrateCommand.php +++ b/src/Propel/Generator/Command/MigrationMigrateCommand.php @@ -23,7 +23,7 @@ class MigrationMigrateCommand extends AbstractCommand { /** - * {@inheritdoc} + * @inheritdoc */ protected function configure() { @@ -42,7 +42,7 @@ protected function configure() } /** - * {@inheritdoc} + * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/Propel/Generator/Command/MigrationStatusCommand.php b/src/Propel/Generator/Command/MigrationStatusCommand.php index 6c64101324..dc92570096 100644 --- a/src/Propel/Generator/Command/MigrationStatusCommand.php +++ b/src/Propel/Generator/Command/MigrationStatusCommand.php @@ -21,7 +21,7 @@ class MigrationStatusCommand extends AbstractCommand { /** - * {@inheritdoc} + * @inheritdoc */ protected function configure() { @@ -38,7 +38,7 @@ protected function configure() } /** - * {@inheritdoc} + * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/Propel/Generator/Command/MigrationUpCommand.php b/src/Propel/Generator/Command/MigrationUpCommand.php index 2c75b15f6d..fa8917e2c3 100644 --- a/src/Propel/Generator/Command/MigrationUpCommand.php +++ b/src/Propel/Generator/Command/MigrationUpCommand.php @@ -23,7 +23,7 @@ class MigrationUpCommand extends AbstractCommand { /** - * {@inheritdoc} + * @inheritdoc */ protected function configure() { @@ -42,7 +42,7 @@ protected function configure() } /** - * {@inheritdoc} + * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Propel/Generator/Command/ModelBuildCommand.php b/src/Propel/Generator/Command/ModelBuildCommand.php index 66562d6d49..19ed359257 100644 --- a/src/Propel/Generator/Command/ModelBuildCommand.php +++ b/src/Propel/Generator/Command/ModelBuildCommand.php @@ -22,7 +22,7 @@ class ModelBuildCommand extends AbstractCommand { /** - * {@inheritdoc} + * @inheritdoc */ protected function configure() { @@ -53,7 +53,7 @@ protected function configure() } /** - * {@inheritdoc} + * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/Propel/Generator/Command/SqlBuildCommand.php b/src/Propel/Generator/Command/SqlBuildCommand.php index 5882fe562b..325e4a0091 100644 --- a/src/Propel/Generator/Command/SqlBuildCommand.php +++ b/src/Propel/Generator/Command/SqlBuildCommand.php @@ -21,7 +21,7 @@ class SqlBuildCommand extends AbstractCommand { /** - * {@inheritdoc} + * @inheritdoc */ protected function configure() { @@ -45,7 +45,7 @@ protected function configure() } /** - * {@inheritdoc} + * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/Propel/Generator/Command/SqlInsertCommand.php b/src/Propel/Generator/Command/SqlInsertCommand.php index 0dd2b165d4..261ebdab5d 100644 --- a/src/Propel/Generator/Command/SqlInsertCommand.php +++ b/src/Propel/Generator/Command/SqlInsertCommand.php @@ -21,7 +21,7 @@ class SqlInsertCommand extends AbstractCommand { /** - * {@inheritdoc} + * @inheritdoc */ protected function configure() { @@ -37,7 +37,7 @@ protected function configure() } /** - * {@inheritdoc} + * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/Propel/Generator/Command/TestPrepareCommand.php b/src/Propel/Generator/Command/TestPrepareCommand.php index 51596179bb..30e703b693 100644 --- a/src/Propel/Generator/Command/TestPrepareCommand.php +++ b/src/Propel/Generator/Command/TestPrepareCommand.php @@ -73,7 +73,7 @@ public function __construct() } /** - * {@inheritdoc} + * @inheritdoc */ protected function configure() { @@ -91,7 +91,7 @@ protected function configure() } /** - * {@inheritdoc} + * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/Propel/Generator/Config/GeneratorConfig.php b/src/Propel/Generator/Config/GeneratorConfig.php index a3a8cc91a8..bee17b56b1 100644 --- a/src/Propel/Generator/Config/GeneratorConfig.php +++ b/src/Propel/Generator/Config/GeneratorConfig.php @@ -47,7 +47,7 @@ class GeneratorConfig extends ConfigurationManager implements GeneratorConfigInt protected $buildConnections = []; /** - * {@inheritdoc} + * @inheritdoc */ public function getConfiguredPlatform(ConnectionInterface $con = null, $database = null) { @@ -92,7 +92,7 @@ public function getConfiguredPlatform(ConnectionInterface $con = null, $database } /** - * {@inheritdoc} + * @inheritdoc */ public function getConfiguredSchemaParser(ConnectionInterface $con = null, $database = null) { diff --git a/src/Propel/Generator/Config/GeneratorConfigInterface.php b/src/Propel/Generator/Config/GeneratorConfigInterface.php index 940910c1cc..17860f36b6 100644 --- a/src/Propel/Generator/Config/GeneratorConfigInterface.php +++ b/src/Propel/Generator/Config/GeneratorConfigInterface.php @@ -41,8 +41,8 @@ public function getConfiguredPluralizer(); /** * Creates and configures a new Platform class. * - * @param ConnectionInterface $con - * @param string $database + * @param ConnectionInterface|null $con + * @param string|null $database * @return PlatformInterface|null * * @throws \Propel\Generator\Exception\ClassNotFoundException if the platform class doesn't exists @@ -53,8 +53,8 @@ public function getConfiguredPlatform(ConnectionInterface $con = null, $database /** * Creates and configures a new SchemaParser class for a specified platform. * - * @param ConnectionInterface $con - * @param string $database + * @param ConnectionInterface|null $con + * @param string|null $database * * @return SchemaParserInterface|null * diff --git a/src/Propel/Generator/Config/QuickGeneratorConfig.php b/src/Propel/Generator/Config/QuickGeneratorConfig.php index 3ff772aa27..0d27306a21 100644 --- a/src/Propel/Generator/Config/QuickGeneratorConfig.php +++ b/src/Propel/Generator/Config/QuickGeneratorConfig.php @@ -97,7 +97,7 @@ public function getConfiguredPluralizer() } /** - * {@inheritdoc} + * @inheritdoc */ public function getConfiguredPlatform(ConnectionInterface $con = null, $database = null) { @@ -105,7 +105,7 @@ public function getConfiguredPlatform(ConnectionInterface $con = null, $database } /** - * {@inheritdoc} + * @inheritdoc */ public function getConfiguredSchemaParser(ConnectionInterface $con = null, $database = null) { diff --git a/src/Propel/Generator/Model/Table.php b/src/Propel/Generator/Model/Table.php index 14ad2ec467..6c839de901 100644 --- a/src/Propel/Generator/Model/Table.php +++ b/src/Propel/Generator/Model/Table.php @@ -118,9 +118,9 @@ class Table extends ScopedMappingModel implements IdMethod private $identifierQuoting; /** - * @var bool + * @var bool|null */ - private $forReferenceOnly = false; + private $forReferenceOnly; /** * @var bool @@ -1825,7 +1825,7 @@ public function quoteIdentifier($text) * * Table will be skipped, if return true. * - * @return boolean + * @return boolean|null */ public function isForReferenceOnly() { diff --git a/src/Propel/Generator/Platform/DefaultPlatform.php b/src/Propel/Generator/Platform/DefaultPlatform.php index a35cae2784..fe7b14f7de 100644 --- a/src/Propel/Generator/Platform/DefaultPlatform.php +++ b/src/Propel/Generator/Platform/DefaultPlatform.php @@ -1203,7 +1203,7 @@ protected function quoteIdentifier($text) } /** - * {@inheritdoc} + * @inheritdoc */ public function doQuoting($text) { diff --git a/src/Propel/Generator/Platform/MssqlPlatform.php b/src/Propel/Generator/Platform/MssqlPlatform.php index b9159ff55a..ee28ac0b48 100644 --- a/src/Propel/Generator/Platform/MssqlPlatform.php +++ b/src/Propel/Generator/Platform/MssqlPlatform.php @@ -271,7 +271,7 @@ public function hasSize($sqlType) } /** - * {@inheritdoc} + * @inheritdoc */ public function doQuoting($text) { diff --git a/src/Propel/Generator/Platform/OraclePlatform.php b/src/Propel/Generator/Platform/OraclePlatform.php index 9d78eeb7af..5d66bc79b2 100644 --- a/src/Propel/Generator/Platform/OraclePlatform.php +++ b/src/Propel/Generator/Platform/OraclePlatform.php @@ -309,7 +309,7 @@ public function hasStreamBlobImpl() } /** - * {@inheritdoc} + * @inheritdoc */ public function doQuoting($text) { diff --git a/src/Propel/Generator/Platform/SqlitePlatform.php b/src/Propel/Generator/Platform/SqlitePlatform.php index 69e46bdc2f..70ca9f9308 100644 --- a/src/Propel/Generator/Platform/SqlitePlatform.php +++ b/src/Propel/Generator/Platform/SqlitePlatform.php @@ -95,7 +95,7 @@ public function getDefaultTypeSizes() } /** - * {@inheritdoc} + * @inheritdoc */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) { @@ -133,7 +133,7 @@ public function getAddColumnsDDL($columns) } /** - * {@inheritdoc} + * @inheritdoc */ public function getModifyTableDDL(TableDiff $tableDiff) { @@ -360,7 +360,7 @@ public function getPrimaryKeyDDL(Table $table) } /** - * {@inheritdoc} + * @inheritdoc */ public function getRemoveColumnDDL(Column $column) { @@ -369,7 +369,7 @@ public function getRemoveColumnDDL(Column $column) } /** - * {@inheritdoc} + * @inheritdoc */ public function getRenameColumnDDL(Column $fromColumn, Column $toColumn) { @@ -378,7 +378,7 @@ public function getRenameColumnDDL(Column $fromColumn, Column $toColumn) } /** - * {@inheritdoc} + * @inheritdoc */ public function getModifyColumnDDL(ColumnDiff $columnDiff) { @@ -387,7 +387,7 @@ public function getModifyColumnDDL(ColumnDiff $columnDiff) } /** - * {@inheritdoc} + * @inheritdoc */ public function getModifyColumnsDDL($columnDiffs) { @@ -396,7 +396,7 @@ public function getModifyColumnsDDL($columnDiffs) } /** - * {@inheritdoc} + * @inheritdoc */ public function getDropPrimaryKeyDDL(Table $table) { @@ -405,7 +405,7 @@ public function getDropPrimaryKeyDDL(Table $table) } /** - * {@inheritdoc} + * @inheritdoc */ public function getAddPrimaryKeyDDL(Table $table) { @@ -414,7 +414,7 @@ public function getAddPrimaryKeyDDL(Table $table) } /** - * {@inheritdoc} + * @inheritdoc */ public function getAddForeignKeyDDL(ForeignKey $fk) { @@ -423,7 +423,7 @@ public function getAddForeignKeyDDL(ForeignKey $fk) } /** - * {@inheritdoc} + * @inheritdoc */ public function getDropForeignKeyDDL(ForeignKey $fk) { @@ -573,7 +573,7 @@ public function hasSize($sqlType) } /** - * {@inheritdoc} + * @inheritdoc */ public function doQuoting($text) { diff --git a/src/Propel/Runtime/Collection/ObjectCollection.php b/src/Propel/Runtime/Collection/ObjectCollection.php index 3baa74beee..01b7fe0d1e 100644 --- a/src/Propel/Runtime/Collection/ObjectCollection.php +++ b/src/Propel/Runtime/Collection/ObjectCollection.php @@ -379,7 +379,7 @@ public function populateRelation($relation, $criteria = null, $con = null) } /** - * {@inheritdoc} + * @inheritdoc */ public function search($element) { @@ -485,7 +485,7 @@ public function offsetSet($offset, $value) } /** - * {@inheritdoc} + * @inheritdoc */ public function contains($element) { diff --git a/src/Propel/Runtime/Collection/ObjectCombinationCollection.php b/src/Propel/Runtime/Collection/ObjectCombinationCollection.php index 548873c37b..135dc89815 100644 --- a/src/Propel/Runtime/Collection/ObjectCombinationCollection.php +++ b/src/Propel/Runtime/Collection/ObjectCombinationCollection.php @@ -44,7 +44,7 @@ public function getPrimaryKeys($usePrefix = true) } /** - * {@inheritdoc} + * @inheritdoc */ public function push($value) { @@ -67,7 +67,7 @@ public function getObjectsFromPosition($position = 1) } /** - * {@inheritdoc} + * @inheritdoc */ public function search($element) { @@ -104,7 +104,7 @@ public function search($element) } /** - * {@inheritdoc} + * @inheritdoc */ public function removeObject($element) { @@ -114,7 +114,7 @@ public function removeObject($element) } /** - * {@inheritdoc} + * @inheritdoc */ public function contains($element) { diff --git a/src/Propel/Runtime/Collection/OnDemandCollection.php b/src/Propel/Runtime/Collection/OnDemandCollection.php index ef32f25cd8..ea3614cd9c 100644 --- a/src/Propel/Runtime/Collection/OnDemandCollection.php +++ b/src/Propel/Runtime/Collection/OnDemandCollection.php @@ -229,7 +229,7 @@ public function getArrayCopy() } /** - * {@inheritdoc} + * @inheritdoc */ public function exportTo($parser, $usePrefix = true, $includeLazyLoadColumns = true) { diff --git a/src/Propel/Runtime/Validator/Constraints/DateValidator.php b/src/Propel/Runtime/Validator/Constraints/DateValidator.php index 7de67d1016..31f8dc61b4 100644 --- a/src/Propel/Runtime/Validator/Constraints/DateValidator.php +++ b/src/Propel/Runtime/Validator/Constraints/DateValidator.php @@ -20,7 +20,7 @@ class DateValidator extends SymfonyDateValidator { /** - * {@inheritdoc} + * @inheritdoc */ public function validate($value, Constraint $constraint) { From 03d769a53acfacaf8fbec941aa05102c43e0bdca Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 23 Jul 2020 13:01:51 +0200 Subject: [PATCH 116/208] Fix regression. --- src/Propel/Generator/Config/GeneratorConfig.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Propel/Generator/Config/GeneratorConfig.php b/src/Propel/Generator/Config/GeneratorConfig.php index bee17b56b1..32360a4a32 100644 --- a/src/Propel/Generator/Config/GeneratorConfig.php +++ b/src/Propel/Generator/Config/GeneratorConfig.php @@ -18,8 +18,6 @@ use Propel\Generator\Exception\InvalidArgumentException; use Propel\Generator\Model\Table; use Propel\Generator\Platform\DefaultPlatform; -use Propel\Generator\Platform\PlatformInterface; -use Propel\Generator\Reverse\SchemaParserInterface; use Propel\Runtime\Adapter\AdapterFactory; use Propel\Runtime\Connection\ConnectionFactory; use Propel\Runtime\Connection\ConnectionInterface; @@ -37,14 +35,14 @@ class GeneratorConfig extends ConfigurationManager implements GeneratorConfigInt /** * @var BehaviorLocator */ - protected $behaviorLocator = null; + protected $behaviorLocator; /** * Connections configured in the `generator` section of the configuration file * * @var array */ - protected $buildConnections = []; + protected $buildConnections; /** * @inheritdoc From e420d2198781fb61953456dd4fe5b55816cbfc7a Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 23 Jul 2020 13:15:27 +0200 Subject: [PATCH 117/208] Set expected defaults as per method contract. --- .../Generator/Builder/Util/SchemaReader.php | 2 +- .../Generator/Manager/AbstractManager.php | 2 +- src/Propel/Generator/Model/Column.php | 24 +++++++++---------- src/Propel/Runtime/ActiveQuery/ModelJoin.php | 2 +- src/Propel/Runtime/Map/TableMap.php | 6 ++--- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Propel/Generator/Builder/Util/SchemaReader.php b/src/Propel/Generator/Builder/Util/SchemaReader.php index 6e9c5cb01d..c410bda254 100644 --- a/src/Propel/Generator/Builder/Util/SchemaReader.php +++ b/src/Propel/Generator/Builder/Util/SchemaReader.php @@ -69,7 +69,7 @@ class SchemaReader /** * @var bool */ - private $isForReferenceOnly; + private $isForReferenceOnly = false; /** * @var string|null diff --git a/src/Propel/Generator/Manager/AbstractManager.php b/src/Propel/Generator/Manager/AbstractManager.php index 6a273b6f3b..59a62488a9 100644 --- a/src/Propel/Generator/Manager/AbstractManager.php +++ b/src/Propel/Generator/Manager/AbstractManager.php @@ -54,7 +54,7 @@ abstract class AbstractManager * Whether to perform validation (XSD) on the schema.xml file(s). * @var boolean */ - protected $validate; + protected $validate = false; /** * The XSD schema file to use for validation. diff --git a/src/Propel/Generator/Model/Column.php b/src/Propel/Generator/Model/Column.php index b170bdc2d8..4b5e025e47 100644 --- a/src/Propel/Generator/Model/Column.php +++ b/src/Propel/Generator/Model/Column.php @@ -113,12 +113,12 @@ class Column extends MappingModel /** * @var bool */ - private $isPrimaryKey; + private $isPrimaryKey = false; /** * @var bool */ - private $isNodeKey; + private $isNodeKey = false; /** * @var string @@ -128,32 +128,32 @@ class Column extends MappingModel /** * @var bool */ - private $isNestedSetLeftKey; + private $isNestedSetLeftKey = false; /** * @var bool */ - private $isNestedSetRightKey; + private $isNestedSetRightKey = false; /** * @var bool */ - private $isTreeScopeKey; + private $isTreeScopeKey = false; /** * @var bool */ - private $isUnique; + private $isUnique = false; /** * @var bool */ - private $isAutoIncrement; + private $isAutoIncrement = false; /** * @var bool */ - private $isLazyLoad; + private $isLazyLoad = false; /** * @var array @@ -163,7 +163,7 @@ class Column extends MappingModel /** * @var bool */ - private $isPrimaryString; + private $isPrimaryString = false; // only one type is supported currently, which assumes the // column either contains the classnames or a key to @@ -178,12 +178,12 @@ class Column extends MappingModel /** * @var bool */ - private $isInheritance; + private $isInheritance = false; /** * @var bool */ - private $isEnumeratedClasses; + private $isEnumeratedClasses = false; /** * @var array|null @@ -195,7 +195,7 @@ class Column extends MappingModel * * @var bool */ - private $needsTransactionInPostgres; + private $needsTransactionInPostgres = false; /** * @var string[] diff --git a/src/Propel/Runtime/ActiveQuery/ModelJoin.php b/src/Propel/Runtime/ActiveQuery/ModelJoin.php index 86e3034b04..ef2f572448 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelJoin.php +++ b/src/Propel/Runtime/ActiveQuery/ModelJoin.php @@ -163,7 +163,7 @@ public function hasRelationAlias() } /** - * @return bool|null + * @return bool */ public function isIdentifierQuotingEnabled() { diff --git a/src/Propel/Runtime/Map/TableMap.php b/src/Propel/Runtime/Map/TableMap.php index 887d9a8a51..a257e1dc1a 100644 --- a/src/Propel/Runtime/Map/TableMap.php +++ b/src/Propel/Runtime/Map/TableMap.php @@ -109,7 +109,7 @@ class TableMap * * @var boolean */ - protected $useIdGenerator; + protected $useIdGenerator = false; /** * Whether the table uses single table inheritance @@ -163,7 +163,7 @@ class TableMap /** * @var boolean */ - protected $identifierQuoting = null; + protected $identifierQuoting = false; /** * Construct a new TableMap. @@ -317,7 +317,7 @@ public function getPackage() */ public function setUseIdGenerator($bit) { - $this->useIdGenerator = $bit; + $this->useIdGenerator = (bool)$bit; } /** From 77bd40b14cc7cc3b5fb37054f8deabeea234a3a6 Mon Sep 17 00:00:00 2001 From: tienbuide Date: Thu, 23 Jul 2020 13:30:26 +0200 Subject: [PATCH 118/208] add json to native pgsql type (#1631) --- src/Propel/Generator/Reverse/PgsqlSchemaParser.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php index 869b1d3810..aee7b80054 100755 --- a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php @@ -72,6 +72,7 @@ class PgsqlSchemaParser extends AbstractSchemaParser 'timestamp without time zone' => PropelTypes::TIMESTAMP, 'timestamp with time zone' => PropelTypes::TIMESTAMP, 'double precision' => PropelTypes::DOUBLE, + 'json' => PropelTypes::JSON, ]; protected static $defaultTypeSizes = [ From b88ee2309bee297a777e8ee8a5f9e43a0df30a96 Mon Sep 17 00:00:00 2001 From: Mark Sch Date: Thu, 23 Jul 2020 14:06:20 +0200 Subject: [PATCH 119/208] Add missing badges --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4bd7f36103..bae5a275ab 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,14 @@ Propel2 is an open-source Object-Relational Mapping (ORM) for PHP. [![Build Status](https://travis-ci.org/propelorm/Propel2.svg?branch=master)](https://travis-ci.org/propelorm/Propel2) [![Code Climate](https://codeclimate.com/github/propelorm/Propel2/badges/gpa.svg)](https://codeclimate.com/github/propelorm/Propel2) +[![Minimum PHP Version](http://img.shields.io/badge/php-%3E%3D%207.2-8892BF.svg)](https://php.net/) +[![License](https://poser.pugx.org/propel/propel/license.svg)](https://packagist.org/packages/propel/propel) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/propelorm/Propel) ## Requirements -Propel2 uses the following Symfony2 Components: +Propel uses the following Symfony Components: * [Console](https://github.com/symfony/Console) * [Yaml](https://github.com/symfony/Yaml) @@ -18,11 +20,9 @@ Propel2 uses the following Symfony2 Components: * [Filesystem](https://github.com/symfony/Filesystem) * [Config](https://github.com/symfony/config) -Propel2 also relies on [**Composer**](https://github.com/composer/composer) to manage dependencies but you +Propel also relies on [**Composer**](https://github.com/composer/composer) to manage dependencies but you also can use [ClassLoader](https://github.com/symfony/ClassLoader) (see the `autoload.php.dist` file for instance). -Propel2 is only supported on PHP 7.2 and up. - ## Installation @@ -31,7 +31,7 @@ Read the [Propel documentation](http://propelorm.org/documentation/01-installati ## Contribute -Everybody can contribute to Propel2. Just fork it, and send Pull Requests. +Everybody can contribute to Propel. Just fork it, and send Pull Requests. You have to follow [Propel2 Coding Standards](https://github.com/propelorm/Propel2/wiki/Coding-Standards) and provides unit tests as much as possible. Also [check out the roadmap](https://github.com/propelorm/Propel2/wiki) to get an overview of what we are working on! From 40305f8418d1af9f98d3afebf1c1b1ff7c3d848a Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 23 Jul 2020 14:35:24 +0200 Subject: [PATCH 120/208] Fix more docblocks and missing return type docs. --- phpstan.neon | 2 + .../Common/Config/ConfigurationManager.php | 8 +- .../Common/Config/Loader/FileLoader.php | 7 +- .../Common/Config/Loader/IniFileLoader.php | 6 +- .../Common/Config/Loader/JsonFileLoader.php | 4 +- .../Common/Config/Loader/PhpFileLoader.php | 4 +- .../Common/Config/Loader/XmlFileLoader.php | 4 +- .../Common/Config/Loader/YamlFileLoader.php | 4 +- src/Propel/Generator/Application.php | 8 +- .../Builder/Om/AbstractOMBuilder.php | 1 + .../Builder/Om/AbstractObjectBuilder.php | 2 + .../Builder/Om/ExtensionObjectBuilder.php | 2 + .../Builder/Om/ExtensionQueryBuilder.php | 2 + .../Generator/Builder/Om/InterfaceBuilder.php | 2 + .../Generator/Builder/Om/ObjectBuilder.php | 96 ++++++++++++------- .../Generator/Builder/Om/QueryBuilder.php | 29 +++++- .../Generator/Builder/Om/TableMapBuilder.php | 25 +++++ .../Runtime/Adapter/AdapterInterface.php | 2 +- src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php | 2 +- .../Connection/ConnectionInterface.php | 1 + .../Runtime/Connection/ConnectionWrapper.php | 1 + .../Runtime/Connection/PdoConnection.php | 7 +- .../Formatter/SimpleArrayFormatter.php | 6 ++ .../Runtime/Formatter/StatementFormatter.php | 5 + .../Validator/Constraints/DateValidator.php | 1 - .../Validator/Constraints/UniqueValidator.php | 6 ++ 26 files changed, 177 insertions(+), 60 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 8ded3db4ee..f0c8fd8f4d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,6 +2,8 @@ includes: - phpstan-baseline.neon parameters: level: 5 + checkGenericClassInNonGenericObjectType: false + checkMissingIterableValueType: false paths: - '%rootDir%/../../../src/' excludes_analyse: diff --git a/src/Propel/Common/Config/ConfigurationManager.php b/src/Propel/Common/Config/ConfigurationManager.php index a1fbe47dff..36748a9701 100644 --- a/src/Propel/Common/Config/ConfigurationManager.php +++ b/src/Propel/Common/Config/ConfigurationManager.php @@ -134,6 +134,7 @@ public function getConnectionParametersArray($section = 'runtime') * * @param string|null $fileName Configuration file name or directory in which resides the configuration file. * @param array|null $extraConf Array of configuration properties, to be merged with those loaded from file. + * @return void */ protected function load($fileName, $extraConf) { @@ -180,11 +181,12 @@ protected function load($fileName, $extraConf) * @param array $extraConf Extra configuration to merge before processing. It's useful when a child class overwrite * the constructor to pass a built-in array of configuration, without load it from file. I.e. * Propel\Generator\Config\QuickGeneratorConfig class. + * @return void */ protected function process($extraConf = null) { if (null === $extraConf && count($this->config) <= 0) { - return null; + return; } $processor = new Processor(); @@ -278,6 +280,8 @@ private function getDirs($fileName) /** * Remove empty `slaves` array from configured connections. + * + * @return void */ private function cleanupSlaveConnections() { @@ -291,6 +295,8 @@ private function cleanupSlaveConnections() /** * If not defined, set `runtime` and `generator` connections, based on `database.connections` property. * Check if runtime and generator connections are correctly defined. + * + * @return void */ private function cleanupConnections() { diff --git a/src/Propel/Common/Config/Loader/FileLoader.php b/src/Propel/Common/Config/Loader/FileLoader.php index 48cd61a75f..922e3e6036 100644 --- a/src/Propel/Common/Config/Loader/FileLoader.php +++ b/src/Propel/Common/Config/Loader/FileLoader.php @@ -46,7 +46,7 @@ abstract class FileLoader extends BaseFileLoader /** * Constructor. * - * @param FileLocatorInterface $locator A FileLocator instance + * @param FileLocatorInterface|null $locator A FileLocator instance */ public function __construct(FileLocatorInterface $locator = null) { @@ -61,11 +61,12 @@ public function __construct(FileLocatorInterface $locator = null) * Replaces parameter placeholders (%name%) by their values for all parameters. * * @param array $configuration The configuration array to resolve + * @return array|null */ public function resolveParams(array $configuration) { if ($this->resolved) { - return; + return null; } $this->config = $configuration; @@ -84,7 +85,7 @@ public function resolveParams(array $configuration) /** * Get the pathof a given resource * - * @param mixed $file The resource + * @param string $file The resource * * @return array|string * @throws \InvalidArgumentException If the file is not found diff --git a/src/Propel/Common/Config/Loader/IniFileLoader.php b/src/Propel/Common/Config/Loader/IniFileLoader.php index e15c093689..c58285da6e 100644 --- a/src/Propel/Common/Config/Loader/IniFileLoader.php +++ b/src/Propel/Common/Config/Loader/IniFileLoader.php @@ -47,12 +47,10 @@ public function supports($resource, $type = null) /** * Loads a resource, merge it with the default configuration array and resolve its parameters. * - * @param mixed $file The resource - * @param string $type The resource type + * @param string $file The resource + * @param string|null $type The resource type * @return array The configuration array * - * @return array - * * @throws \InvalidArgumentException if configuration file not found * @throws \Propel\Common\Config\Exception\InvalidArgumentException When ini file is not valid * @throws \Propel\Common\Config\Exception\InputOutputException if configuration file is not readable diff --git a/src/Propel/Common/Config/Loader/JsonFileLoader.php b/src/Propel/Common/Config/Loader/JsonFileLoader.php index 866714045c..d0f2f3e214 100644 --- a/src/Propel/Common/Config/Loader/JsonFileLoader.php +++ b/src/Propel/Common/Config/Loader/JsonFileLoader.php @@ -22,8 +22,8 @@ class JsonFileLoader extends FileLoader /** * Loads an Json file. * - * @param mixed $file The resource - * @param string $type The resource type + * @param string $file The resource + * @param string|null $type The resource type * * @return array * diff --git a/src/Propel/Common/Config/Loader/PhpFileLoader.php b/src/Propel/Common/Config/Loader/PhpFileLoader.php index 5ef033b68d..4dfaae7017 100644 --- a/src/Propel/Common/Config/Loader/PhpFileLoader.php +++ b/src/Propel/Common/Config/Loader/PhpFileLoader.php @@ -31,8 +31,8 @@ class PhpFileLoader extends FileLoader /** * Loads a PHP file. * - * @param mixed $file The resource - * @param string $type The resource type + * @param string $file The resource + * @param string|null $type The resource type * * @return array * diff --git a/src/Propel/Common/Config/Loader/XmlFileLoader.php b/src/Propel/Common/Config/Loader/XmlFileLoader.php index 2aa2aba7b7..1295cc7edb 100644 --- a/src/Propel/Common/Config/Loader/XmlFileLoader.php +++ b/src/Propel/Common/Config/Loader/XmlFileLoader.php @@ -22,8 +22,8 @@ class XmlFileLoader extends FileLoader /** * Loads an Xml file. * - * @param mixed $file The resource - * @param string $type The resource type + * @param string $file The resource + * @param string|null $type The resource type * * @return array * diff --git a/src/Propel/Common/Config/Loader/YamlFileLoader.php b/src/Propel/Common/Config/Loader/YamlFileLoader.php index 7359b4631a..4b73337459 100644 --- a/src/Propel/Common/Config/Loader/YamlFileLoader.php +++ b/src/Propel/Common/Config/Loader/YamlFileLoader.php @@ -24,8 +24,8 @@ class YamlFileLoader extends FileLoader /** * Loads a Yaml file. * - * @param mixed $file The resource - * @param string $type The resource type + * @param string $file The resource + * @param string|null $type The resource type * * @return array * diff --git a/src/Propel/Generator/Application.php b/src/Propel/Generator/Application.php index a8be658627..93e9c65d0b 100644 --- a/src/Propel/Generator/Application.php +++ b/src/Propel/Generator/Application.php @@ -7,6 +7,12 @@ class Application extends \Symfony\Component\Console\Application { + /** + * @param \Symfony\Component\Console\Input\InputInterface $input + * @param \Symfony\Component\Console\Output\OutputInterface $output + * + * @return int + */ public function doRun(InputInterface $input, OutputInterface $output) { if (extension_loaded('xdebug')) { @@ -16,4 +22,4 @@ public function doRun(InputInterface $input, OutputInterface $output) } return parent::doRun($input, $output); } -} \ No newline at end of file +} diff --git a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php index 17be416918..72b9415727 100644 --- a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php @@ -1085,6 +1085,7 @@ abstract protected function addClassOpen(&$script); * drastically change the contents of the generated object class. * * @param string $script The script will be modified in this method. + * @return void */ abstract protected function addClassBody(&$script); diff --git a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php index 44fb187f73..eee972e29a 100644 --- a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php @@ -28,6 +28,7 @@ abstract class AbstractObjectBuilder extends AbstractOMBuilder * This is here because it is probably generic enough to apply to templates being generated * in different PHP versions. * @param string $script The script will be modified in this method. + * @return void */ protected function addColumnAccessorMethods(&$script) { @@ -75,6 +76,7 @@ protected function addColumnAccessorMethods(&$script) * This is here because it is probably generic enough to apply to templates being generated * in different PHP versions. * @param string $script The script will be modified in this method. + * @return void */ protected function addColumnMutatorMethods(&$script) { diff --git a/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php index 08754f23af..02d959d141 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php @@ -33,6 +33,7 @@ public function getUnprefixedClassName() /** * Adds class phpdoc comment and opening of class. * @param string $script The script will be modified in this method. + * @return void */ protected function addClassOpen(&$script) { @@ -82,6 +83,7 @@ protected function addClassBody(&$script) /** * Closes class. * @param string $script The script will be modified in this method. + * @return void */ protected function addClassClose(&$script) { diff --git a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php index edcde40e3f..0edc227dda 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php @@ -33,6 +33,7 @@ public function getUnprefixedClassName() /** * Adds class phpdoc comment and opening of class. * @param string $script The script will be modified in this method. + * @return void */ protected function addClassOpen(&$script) { @@ -84,6 +85,7 @@ protected function addClassBody(&$script) /** * Closes class. * @param string $script The script will be modified in this method. + * @return void */ protected function addClassClose(&$script) { diff --git a/src/Propel/Generator/Builder/Om/InterfaceBuilder.php b/src/Propel/Generator/Builder/Om/InterfaceBuilder.php index 44f59b93c3..fd8f30d5aa 100644 --- a/src/Propel/Generator/Builder/Om/InterfaceBuilder.php +++ b/src/Propel/Generator/Builder/Om/InterfaceBuilder.php @@ -34,6 +34,7 @@ public function getUnprefixedClassName() * Adds class phpdoc comment and opening of class. * * @param string $script The script will be modified in this method. + * @return void */ protected function addClassOpen(&$script) { @@ -81,6 +82,7 @@ protected function addClassBody(&$script) /** * Closes class. * @param string $script The script will be modified in this method. + * @return void */ protected function addClassClose(&$script) { diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index 9c7705c74c..c0e0fed6cb 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -1775,7 +1775,7 @@ protected function addMutatorCloseBody(&$script, Column $column) * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see addMutatorClose() - **/ + */ protected function addMutatorCloseClose(&$script, Column $col) { $cfc = $col->getPhpName(); @@ -2244,6 +2244,7 @@ protected function addDefaultMutator(&$script, Column $col) /** * Adds the hasOnlyDefaultValues() method. * @param string $script The script will be modified in this method. + * @return void */ protected function addHasOnlyDefaultValues(&$script) { @@ -2257,7 +2258,7 @@ protected function addHasOnlyDefaultValues(&$script) * Adds the comment for the hasOnlyDefaultValues method * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues - **/ + */ protected function addHasOnlyDefaultValuesComment(&$script) { $script .= " @@ -2275,7 +2276,7 @@ protected function addHasOnlyDefaultValuesComment(&$script) * Adds the function declaration for the hasOnlyDefaultValues method * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues - **/ + */ protected function addHasOnlyDefaultValuesOpen(&$script) { $script .= " @@ -2287,7 +2288,7 @@ public function hasOnlyDefaultValues() * Adds the function body for the hasOnlyDefaultValues method * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues - **/ + */ protected function addHasOnlyDefaultValuesBody(&$script) { $table = $this->getTable(); @@ -2319,7 +2320,7 @@ protected function addHasOnlyDefaultValuesBody(&$script) * Adds the function close for the hasOnlyDefaultValues method * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues - **/ + */ protected function addHasOnlyDefaultValuesClose(&$script) { $script .= " @@ -2333,6 +2334,7 @@ protected function addHasOnlyDefaultValuesClose(&$script) /** * Adds the hydrate() method, which sets attributes of the object based on a ResultSet. * @param string $script The script will be modified in this method. + * @return void */ protected function addHydrate(&$script) { @@ -2505,7 +2507,8 @@ protected function addHydrateClose(&$script) /** * Adds the buildPkeyCriteria method * @param string $script The script will be modified in this method. - **/ + * @return void + */ protected function addBuildPkeyCriteria(&$script) { $this->declareClass('Propel\\Runtime\\Exception\\LogicException'); @@ -2520,7 +2523,7 @@ protected function addBuildPkeyCriteria(&$script) * Adds the comment for the buildPkeyCriteria method * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() - **/ + */ protected function addBuildPkeyCriteriaComment(&$script) { $script .= " @@ -2540,7 +2543,7 @@ protected function addBuildPkeyCriteriaComment(&$script) * Adds the function declaration for the buildPkeyCriteria method * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() - **/ + */ protected function addBuildPkeyCriteriaOpen(&$script) { $script .= " @@ -2552,7 +2555,7 @@ public function buildPkeyCriteria() * Adds the function body for the buildPkeyCriteria method * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() - **/ + */ protected function addBuildPkeyCriteriaBody(&$script) { if (!$this->getTable()->getPrimaryKey()) { @@ -2575,7 +2578,7 @@ protected function addBuildPkeyCriteriaBody(&$script) * Adds the function close for the buildPkeyCriteria method * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() - **/ + */ protected function addBuildPkeyCriteriaClose(&$script) { $script .= " @@ -2588,7 +2591,8 @@ protected function addBuildPkeyCriteriaClose(&$script) /** * Adds the buildCriteria method * @param string $script The script will be modified in this method. - **/ + * @return void + */ protected function addBuildCriteria(&$script) { $this->addBuildCriteriaComment($script); @@ -2601,7 +2605,7 @@ protected function addBuildCriteria(&$script) * Adds comment for the buildCriteria method * @param string $script The script will be modified in this method. * @see addBuildCriteria() - **/ + */ protected function addBuildCriteriaComment(&$script) { $script .= " @@ -2616,7 +2620,7 @@ protected function addBuildCriteriaComment(&$script) * Adds the function declaration of the buildCriteria method * @param string $script The script will be modified in this method. * @see addBuildCriteria() - **/ + */ protected function addBuildCriteriaOpen(&$script) { $script .= " @@ -2628,7 +2632,7 @@ public function buildCriteria() * Adds the function body of the buildCriteria method * @param string $script The script will be modified in this method. * @see addBuildCriteria() - **/ + */ protected function addBuildCriteriaBody(&$script) { $script .= " @@ -2647,7 +2651,7 @@ protected function addBuildCriteriaBody(&$script) * Adds the function close of the buildCriteria method * @param string $script The script will be modified in this method. * @see addBuildCriteria() - **/ + */ protected function addBuildCriteriaClose(&$script) { $script .= " @@ -2660,7 +2664,8 @@ protected function addBuildCriteriaClose(&$script) /** * Adds the toArray method * @param string $script The script will be modified in this method. - **/ + * @return void + */ protected function addToArray(&$script) { $fks = $this->getTable()->getForeignKeys(); @@ -2796,7 +2801,8 @@ protected function addToArrayKeyLookUp($phpName, Table $table, $plural) /** * Adds the getByName method * @param string $script The script will be modified in this method. - **/ + * @return void + */ protected function addGetByName(&$script) { $this->addGetByNameComment($script); @@ -2809,7 +2815,7 @@ protected function addGetByName(&$script) * Adds the comment for the getByName method * @param string $script The script will be modified in this method. * @see addGetByName - **/ + */ protected function addGetByNameComment(&$script) { $defaultKeyType = $this->getDefaultKeyType(); @@ -2830,7 +2836,7 @@ protected function addGetByNameComment(&$script) * Adds the function declaration for the getByName method * @param string $script The script will be modified in this method. * @see addGetByName - **/ + */ protected function addGetByNameOpen(&$script) { $defaultKeyType = $this->getDefaultKeyType(); @@ -2843,7 +2849,7 @@ public function getByName(\$name, \$type = TableMap::$defaultKeyType) * Adds the function body for the getByName method * @param string $script The script will be modified in this method. * @see addGetByName - **/ + */ protected function addGetByNameBody(&$script) { $script .= " @@ -2855,7 +2861,7 @@ protected function addGetByNameBody(&$script) * Adds the function close for the getByName method * @param string $script The script will be modified in this method. * @see addGetByName - **/ + */ protected function addGetByNameClose(&$script) { $script .= " @@ -2868,7 +2874,8 @@ protected function addGetByNameClose(&$script) /** * Adds the getByPosition method * @param string $script The script will be modified in this method. - **/ + * @return void + */ protected function addGetByPosition(&$script) { $this->addGetByPositionComment($script); @@ -2881,7 +2888,7 @@ protected function addGetByPosition(&$script) * Adds comment for the getByPosition method * @param string $script The script will be modified in this method. * @see addGetByPosition - **/ + */ protected function addGetByPositionComment(&$script) { $script .= " @@ -2898,7 +2905,7 @@ protected function addGetByPositionComment(&$script) * Adds the function declaration for the getByPosition method * @param string $script The script will be modified in this method. * @see addGetByPosition - **/ + */ protected function addGetByPositionOpen(&$script) { $script .= " @@ -2910,7 +2917,7 @@ public function getByPosition(\$pos) * Adds the function body for the getByPosition method * @param string $script The script will be modified in this method. * @see addGetByPosition - **/ + */ protected function addGetByPositionBody(&$script) { $table = $this->getTable(); @@ -2936,7 +2943,7 @@ protected function addGetByPositionBody(&$script) * Adds the function close for the getByPosition method * @param string $script The script will be modified in this method. * @see addGetByPosition - **/ + */ protected function addGetByPositionClose(&$script) { $script .= " @@ -3127,6 +3134,7 @@ public function importFrom(\$parser, \$data, \$keyType = TableMap::$defaultKeyTy /** * Adds a delete() method to remove the object form the datastore. * @param string $script The script will be modified in this method. + * @return void */ protected function addDelete(&$script) { @@ -3140,7 +3148,7 @@ protected function addDelete(&$script) * Adds the comment for the delete function * @param string $script The script will be modified in this method. * @see addDelete() - **/ + */ protected function addDeleteComment(&$script) { $className = $this->getUnqualifiedClassName(); @@ -3160,7 +3168,7 @@ protected function addDeleteComment(&$script) * Adds the function declaration for the delete function * @param string $script The script will be modified in this method. * @see addDelete() - **/ + */ protected function addDeleteOpen(&$script) { $script .= " @@ -3172,7 +3180,7 @@ public function delete(ConnectionInterface \$con = null) * Adds the function body for the delete function * @param string $script The script will be modified in this method. * @see addDelete() - **/ + */ protected function addDeleteBody(&$script) { $script .= " @@ -3220,7 +3228,7 @@ protected function addDeleteBody(&$script) * Adds the function close for the delete function * @param string $script The script will be modified in this method. * @see addDelete() - **/ + */ protected function addDeleteClose(&$script) { $script .= " @@ -3231,6 +3239,7 @@ protected function addDeleteClose(&$script) /** * Adds a reload() method to re-fetch the data for this object from the database. * @param string $script The script will be modified in this method. + * @return void */ protected function addReload(&$script) { @@ -3320,6 +3329,7 @@ public function reload(\$deep = false, ConnectionInterface \$con = null) /** * Adds the methods related to refreshing, saving and deleting the object. * @param string $script The script will be modified in this method. + * @return void */ protected function addManipulationMethods(&$script) { @@ -3402,6 +3412,7 @@ public function hashCode() /** * Adds the correct getPrimaryKey() method for this object. * @param string $script The script will be modified in this method. + * @return void */ protected function addGetPrimaryKey(&$script) { @@ -3419,6 +3430,7 @@ protected function addGetPrimaryKey(&$script) /** * Adds the getPrimaryKey() method for tables that contain a single-column primary key. * @param string $script The script will be modified in this method. + * @return void */ protected function addGetPrimaryKey_SinglePK(&$script) { @@ -3441,6 +3453,7 @@ public function getPrimaryKey() /** * Adds the setPrimaryKey() method for tables that contain a multi-column primary key. * @param string $script The script will be modified in this method. + * @return void */ protected function addGetPrimaryKey_MultiPK(&$script) { @@ -3493,6 +3506,7 @@ public function getPrimaryKey() /** * Adds the correct setPrimaryKey() method for this object. * @param string $script The script will be modified in this method. + * @return void */ protected function addSetPrimaryKey(&$script) { @@ -3510,6 +3524,7 @@ protected function addSetPrimaryKey(&$script) /** * Adds the setPrimaryKey() method for tables that contain a single-column primary key. * @param string $script The script will be modified in this method. + * @return void */ protected function addSetPrimaryKey_SinglePK(&$script) { @@ -3536,6 +3551,7 @@ public function setPrimaryKey(\$key) /** * Adds the setPrimaryKey() method for tables that contain a multi-columnprimary key. * @param string $script The script will be modified in this method. + * @return void */ protected function addSetPrimaryKey_MultiPK(&$script) { @@ -3590,6 +3606,7 @@ public function setPrimaryKey(\$pk) /** * Adds the isPrimaryKeyNull() method * @param string $script The script will be modified in this method. + * @return void */ protected function addIsPrimaryKeyNull(&$script) { @@ -3653,6 +3670,7 @@ public function getPKRefFKVarName(ForeignKey $fk) /** * Adds the methods that get & set objects related by foreign key to the current object. * @param string $script The script will be modified in this method. + * @return void */ protected function addFKMethods(&$script) { @@ -3972,6 +3990,7 @@ protected function addRefFKAttributes(&$script, ForeignKey $refFK) /** * Adds the methods for retrieving, initializing, adding objects that are related to this one by foreign keys. * @param string $script The script will be modified in this method. + * @return void */ protected function addRefFKMethods(&$script) { @@ -5765,6 +5784,7 @@ public function remove{$relatedObjectClassName}($signature) /** * Adds the workhourse doSave() method. * @param string $script The script will be modified in this method. + * @return void */ protected function addDoSave(&$script) { @@ -6187,6 +6207,7 @@ protected function doUpdate(ConnectionInterface \$con) /** * Adds the $alreadyInSave attribute, which prevents attempting to re-save the same object. * @param string $script The script will be modified in this method. + * @return void */ protected function addAlreadyInSaveAttribute(&$script) { @@ -6204,6 +6225,7 @@ protected function addAlreadyInSaveAttribute(&$script) /** * Adds the save() method. * @param string $script The script will be modified in this method. + * @return void */ protected function addSave(&$script) { @@ -6217,7 +6239,7 @@ protected function addSave(&$script) * Adds the comment for the save method * @param string $script The script will be modified in this method. * @see addSave() - **/ + */ protected function addSaveComment(&$script) { $table = $this->getTable(); @@ -6264,7 +6286,7 @@ protected function addSaveComment(&$script) * Adds the function declaration for the save method * @param string $script The script will be modified in this method. * @see addSave() - **/ + */ protected function addSaveOpen(&$script) { $table = $this->getTable(); @@ -6279,7 +6301,7 @@ public function save(ConnectionInterface \$con = null".($reloadOnUpdate || $relo * Adds the function body for the save method * @param string $script The script will be modified in this method. * @see addSave() - **/ + */ protected function addSaveBody(&$script) { $table = $this->getTable(); @@ -6387,7 +6409,7 @@ protected function addSaveBody(&$script) * Adds the function close for the save method * @param string $script The script will be modified in this method. * @see addSave() - **/ + */ protected function addSaveClose(&$script) { $script .= " @@ -6398,6 +6420,7 @@ protected function addSaveClose(&$script) /** * Adds the ensureConsistency() method to ensure that internal state is correct. * @param string $script The script will be modified in this method. + * @return void */ protected function addEnsureConsistency(&$script) { @@ -6451,6 +6474,7 @@ public function ensureConsistency() /** * Adds the copy() method, which (in complex OM) includes the $deepCopy param for making copies of related objects. * @param string $script The script will be modified in this method. + * @return void */ protected function addCopy(&$script) { @@ -6485,6 +6509,7 @@ public function copy(\$deepCopy = false) * Adds the copyInto() method, which takes an object and sets contents to match current object. * In complex OM this method includes the $deepCopy param for making copies of related objects. * @param string $script The script will be modified in this method. + * @return void */ protected function addCopyInto(&$script) { @@ -6583,6 +6608,7 @@ public function copyInto(\$copyObj, \$deepCopy = false, \$makeNew = true) /** * Adds clear method * @param string $script The script will be modified in this method. + * @return void */ protected function addClear(&$script) { @@ -6650,6 +6676,7 @@ public function clear() * Adds clearAllReferences() method which resets all the collections of referencing * fk objects. * @param string $script The script will be modified in this method. + * @return void */ protected function addClearAllReferences(&$script) { @@ -6724,6 +6751,7 @@ public function clearAllReferences(\$deep = false) /** * Adds a magic __toString() method if a string column was defined as primary string * @param string $script The script will be modified in this method. + * @return void */ protected function addPrimaryString(&$script) { diff --git a/src/Propel/Generator/Builder/Om/QueryBuilder.php b/src/Propel/Generator/Builder/Om/QueryBuilder.php index 8752007cbc..de74338761 100644 --- a/src/Propel/Generator/Builder/Om/QueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryBuilder.php @@ -72,6 +72,7 @@ public function getParentClass() /** * Adds class phpdoc comment and opening of class. * @param string $script The script will be modified in this method. + * @return void */ protected function addClassOpen(&$script) { @@ -318,6 +319,7 @@ private function getEntityNotFoundExceptionClass() /** * Adds the doDeleteAll(), etc. methods. * @param string $script The script will be modified in this method. + * @return void */ protected function addDeleteMethods(&$script) { @@ -372,6 +374,7 @@ protected function isDeleteSetNullEmulationNeeded() /** * Closes class. * @param string $script The script will be modified in this method. + * @return void */ protected function addClassClose(&$script) { @@ -397,7 +400,8 @@ protected function addConstructor(&$script) /** * Adds the comment for the constructor * @param string $script The script will be modified in this method. - **/ + * @return void + */ protected function addConstructorComment(&$script) { $script .= " @@ -426,7 +430,8 @@ public function __construct(\$dbName = '" . $table->getDatabase()->getName() . " /** * Adds the function body for the constructor * @param string $script The script will be modified in this method. - **/ + * @return void + */ protected function addConstructorBody(&$script) { $script .= " @@ -436,7 +441,8 @@ protected function addConstructorBody(&$script) /** * Adds the function close for the constructor * @param string $script The script will be modified in this method. - **/ + * @return void + */ protected function addConstructorClose(&$script) { $script .= " @@ -447,6 +453,7 @@ protected function addConstructorClose(&$script) /** * Adds the factory for this object. * @param string $script The script will be modified in this method. + * @return void */ protected function addFactory(&$script) { @@ -459,7 +466,8 @@ protected function addFactory(&$script) /** * Adds the comment for the factory * @param string $script The script will be modified in this method. - **/ + * @return void + */ protected function addFactoryComment(&$script) { $classname = $this->getClassNameFromBuilder($this->getNewStubQueryBuilder($this->getTable())); @@ -477,7 +485,8 @@ protected function addFactoryComment(&$script) /** * Adds the function declaration for the factory * @param string $script The script will be modified in this method. - **/ + * @return void + */ protected function addFactoryOpen(&$script) { $script .= " @@ -488,6 +497,7 @@ public static function create(\$modelAlias = null, Criteria \$criteria = null) /** * Adds the function body for the factory * @param string $script The script will be modified in this method. + * @return void */ protected function addFactoryBody(&$script) { @@ -1416,6 +1426,7 @@ protected function addJoinRefFk(&$script, ForeignKey $fk) /** * Adds a joinRelated method for this object. * @param string $script The script will be modified in this method. + * @return void */ protected function addJoinRelated(&$script, $fkTable, $queryClass, $relationName, $joinType) { @@ -1489,6 +1500,7 @@ protected function addUseRefFkQuery(&$script, ForeignKey $fk) /** * Adds a useRelatedQuery method for this object. * @param string $script The script will be modified in this method. + * @return void */ protected function addUseRelatedQuery(&$script, Table $fkTable, $queryClass, $relationName, $joinType) { @@ -1663,6 +1675,7 @@ protected function basePreDelete(ConnectionInterface \$con) /** * Adds the basePostDelete hook for this object. * @param string $script The script will be modified in this method. + * @return void */ protected function addBasePostDelete(&$script) { @@ -1689,6 +1702,7 @@ protected function basePostDelete(\$affectedRows, ConnectionInterface \$con) /** * Adds the basePreUpdate hook for this object. * @param string $script The script will be modified in this method. + * @return void */ protected function addBasePreUpdate(&$script) { @@ -1716,6 +1730,7 @@ protected function basePreUpdate(&\$values, ConnectionInterface \$con, \$forceIn /** * Adds the basePostUpdate hook for this object. * @param string $script The script will be modified in this method. + * @return void */ protected function addBasePostUpdate(&$script) { @@ -1771,6 +1786,7 @@ public function getBehaviorContent($contentName) /** * Adds the doDelete() method. * @param string $script The script will be modified in this method. + * @return void */ protected function addDelete(&$script) { @@ -1834,6 +1850,7 @@ public function delete(ConnectionInterface \$con = null) /** * Adds the doOnDeleteCascade() method, which provides ON DELETE CASCADE emulation. * @param string $script The script will be modified in this method. + * @return void */ protected function addDoOnDeleteCascade(&$script) { @@ -1915,6 +1932,7 @@ protected function doOnDeleteCascade(ConnectionInterface \$con) /** * Adds the doOnDeleteSetNull() method, which provides ON DELETE SET NULL emulation. * @param string $script The script will be modified in this method. + * @return void */ protected function addDoOnDeleteSetNull(&$script) { @@ -1992,6 +2010,7 @@ protected function doOnDeleteSetNull(ConnectionInterface \$con) /** * Adds the doDeleteAll() method. * @param string $script The script will be modified in this method. + * @return void */ protected function addDoDeleteAll(&$script) { diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index f467c8e7dd..0cdc04a391 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -211,6 +211,7 @@ protected function addConstants() /** * Adds the COLUMN_NAME constant to the class definition. * @param string $script The script will be modified in this method. + * @return void */ protected function addColumnNameConstants(&$script) { @@ -227,6 +228,7 @@ protected function addColumnNameConstants(&$script) /** * Adds the valueSet constants for ENUM and SET columns. * @param string $script The script will be modified in this method. + * @return void */ protected function addValueSetColumnConstants(&$script) { @@ -247,6 +249,7 @@ protected function addValueSetColumnConstants(&$script) /** * Adds the valueSet attributes for ENUM columns. * @param string $script The script will be modified in this method. + * @return void */ protected function addValueSetColumnAttributes(&$script) { @@ -273,6 +276,7 @@ protected function addValueSetColumnAttributes(&$script) /** * Adds the getValueSets() method. * @param string $script The script will be modified in this method. + * @return void */ protected function addGetValueSets(&$script) { @@ -291,6 +295,7 @@ public static function getValueSets() /** * Adds the getValueSet() method. * @param string $script The script will be modified in this method. + * @return void */ protected function addGetValueSet(&$script) { @@ -312,6 +317,7 @@ public static function getValueSet(\$colname) /** * Adds the CLASSKEY_* and CLASSNAME_* constants used for inheritance. * @param string $script The script will be modified in this method. + * @return void */ public function addInheritanceColumnConstants(&$script) { @@ -359,6 +365,7 @@ protected function getValueSetConstant($value) /** * Adds any attributes needed for this TableMap class. * @param string $script The script will be modified in this method. + * @return void */ protected function addAttributes(&$script) { @@ -420,6 +427,7 @@ protected function addFieldsAttributes() /** * Closes class. * @param string $script The script will be modified in this method. + * @return void */ protected function addClassClose(&$script) { @@ -435,6 +443,7 @@ protected function addClassClose(&$script) /** * Adds the buildTableMap() method. * @param string $script The script will be modified in this method. + * @return void */ protected function addBuildTableMap(&$script) { @@ -456,6 +465,7 @@ public static function buildTableMap() /** * Adds the addInitialize() method to the table map class. * @param string $script The script will be modified in this method. + * @return void */ protected function addInitialize(&$script) { @@ -560,6 +570,7 @@ public function initialize() /** * Adds the method that build the RelationMap objects * @param string $script The script will be modified in this method. + * @return void */ protected function addBuildRelations(&$script) { @@ -613,6 +624,7 @@ public function buildRelations() /** * Adds the behaviors getter * @param string $script The script will be modified in this method. + * @return void */ protected function addGetBehaviors(&$script) { @@ -779,6 +791,7 @@ public function applyBehaviorModifier($hookName, &$script, $tab = " ") * Adds method to get a version of the primary key that can be used as a unique key for identifier map. * * @param string $script The script will be modified in this method. + * @return void */ protected function addGetPrimaryKeyHash(&$script) { @@ -835,6 +848,7 @@ public static function getPrimaryKeyHashFromRow(\$row, \$offset = 0, \$indexType /** * Adds method to get the primary key from a row * @param string $script The script will be modified in this method. + * @return void */ protected function addGetPrimaryKeyFromRow(&$script) { @@ -910,6 +924,7 @@ public static function getPrimaryKeyFromRow(\$row, \$offset = 0, \$indexType = T /** * Adds the correct getOMClass() method, depending on whether this table uses inheritance. * @param string $script The script will be modified in this method. + * @return void */ protected function addGetOMClassMethod(&$script) { @@ -928,6 +943,7 @@ protected function addGetOMClassMethod(&$script) /** * Adds a getOMClass() for non-abstract tables that have inheritance. * @param string $script The script will be modified in this method. + * @return void */ protected function addGetOMClass_Inheritance(&$script) { @@ -992,6 +1008,7 @@ public static function getOMClass(\$row, \$colnum, \$withPrefix = true) /** * Adds a getOMClass() for non-abstract tables that do note use inheritance. * @param string $script The script will be modified in this method. + * @return void */ protected function addGetOMClass_NoInheritance(&$script) { @@ -1017,6 +1034,7 @@ public static function getOMClass(\$withPrefix = true) /** * Adds a getOMClass() signature for abstract tables that do not have inheritance. * @param string $script The script will be modified in this method. + * @return void */ protected function addGetOMClass_NoInheritance_Abstract(&$script) { @@ -1038,6 +1056,7 @@ abstract public static function getOMClass(\$withPrefix = true); /** * Adds the populateObject() method. * @param string $script The script will be modified in this method. + * @return void */ protected function addPopulateObject(&$script) { @@ -1096,6 +1115,7 @@ public static function populateObject(\$row, \$offset = 0, \$indexType = TableMa /** * Adds the populateObjects() method. * @param string $script The script will be modified in this method. + * @return void */ protected function addPopulateObjects(&$script) { @@ -1161,6 +1181,7 @@ public static function populateObjects(DataFetcherInterface \$dataFetcher) /** * Adds the addSelectColumns() method. * @param string $script The script will be modified in this method. + * @return void */ protected function addAddSelectColumns(&$script) { @@ -1204,6 +1225,7 @@ public static function addSelectColumns(Criteria \$criteria, \$alias = null) /** * Adds the getTableMap() method which is a convenience method for apps to get DB metadata. * @param string $script The script will be modified in this method. + * @return void */ protected function addGetTableMap(&$script) { @@ -1225,6 +1247,7 @@ public static function getTableMap() /** * Adds the doDeleteAll() method. * @param string $script The script will be modified in this method. + * @return void */ protected function addDoDeleteAll(&$script) { @@ -1246,6 +1269,7 @@ public static function doDeleteAll(ConnectionInterface \$con = null) /** * Adds the doDelete() method. * @param string $script The script will be modified in this method. + * @return void */ protected function addDoDelete(&$script) { @@ -1348,6 +1372,7 @@ public static function doDelete(\$values, ConnectionInterface \$con = null) /** * Adds the doInsert() method. * @param string $script The script will be modified in this method. + * @return void */ protected function addDoInsert(&$script) { diff --git a/src/Propel/Runtime/Adapter/AdapterInterface.php b/src/Propel/Runtime/Adapter/AdapterInterface.php index 2730395dd9..b5b1963961 100644 --- a/src/Propel/Runtime/Adapter/AdapterInterface.php +++ b/src/Propel/Runtime/Adapter/AdapterInterface.php @@ -110,7 +110,7 @@ public function quoteIdentifier($text); * * @param string $table The table name to quo * @return string The quoted table name - **/ + */ public function quoteIdentifierTable($table); /** diff --git a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php index 817666eff0..60e45e729a 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php @@ -241,7 +241,7 @@ public function quote($text) * * @param string $table The table name to quo * @return string The quoted table name - **/ + */ public function quoteIdentifierTable($table) { return implode(' ', array_map([$this, 'quoteIdentifier'], explode(' ', $table))); diff --git a/src/Propel/Runtime/Connection/ConnectionInterface.php b/src/Propel/Runtime/Connection/ConnectionInterface.php index 9645b435d8..16498a36df 100644 --- a/src/Propel/Runtime/Connection/ConnectionInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionInterface.php @@ -21,6 +21,7 @@ interface ConnectionInterface { /** * @param string $name The datasource name associated to this connection + * @return void */ public function setName($name); diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index c4061f7705..b33ed3b687 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -130,6 +130,7 @@ public function __construct(ConnectionInterface $connection) /** * @param string $name The datasource name associated to this connection + * @return void */ public function setName($name) { diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index d4b9c216cd..0c66610859 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -27,6 +27,7 @@ class PdoConnection extends \PDO implements ConnectionInterface /** * @param string $name The datasource name associated to this connection + * @return void */ public function setName($name) { @@ -43,10 +44,14 @@ public function getName() /** * Creates a PDO instance representing a connection to a database. + * + * @param string $dsn + * @param string|null $user + * @param string|null $password + * @param array|null $options */ public function __construct($dsn, $user = null, $password = null, array $options = null) { - // Convert option keys from a string to a \PDO:: constant $pdoOptions = []; if (is_array($options)) { diff --git a/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php b/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php index a6e95724b3..6b38ba6313 100644 --- a/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php +++ b/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php @@ -23,6 +23,12 @@ */ class SimpleArrayFormatter extends AbstractFormatter { + /** + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher + * + * @throws \Propel\Runtime\Exception\LogicException + * @return array|\Propel\Runtime\Collection\Collection + */ public function format(DataFetcherInterface $dataFetcher = null) { $this->checkInit(); diff --git a/src/Propel/Runtime/Formatter/StatementFormatter.php b/src/Propel/Runtime/Formatter/StatementFormatter.php index ba43d6eeca..1f914692de 100644 --- a/src/Propel/Runtime/Formatter/StatementFormatter.php +++ b/src/Propel/Runtime/Formatter/StatementFormatter.php @@ -22,6 +22,11 @@ */ class StatementFormatter extends AbstractFormatter { + /** + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher + * + * @return \Propel\Runtime\DataFetcher\DataFetcherInterface + */ public function format(DataFetcherInterface $dataFetcher = null) { if ($dataFetcher) { diff --git a/src/Propel/Runtime/Validator/Constraints/DateValidator.php b/src/Propel/Runtime/Validator/Constraints/DateValidator.php index 31f8dc61b4..3fdcf014a4 100644 --- a/src/Propel/Runtime/Validator/Constraints/DateValidator.php +++ b/src/Propel/Runtime/Validator/Constraints/DateValidator.php @@ -24,7 +24,6 @@ class DateValidator extends SymfonyDateValidator */ public function validate($value, Constraint $constraint) { - if ($value instanceof \DateTimeInterface) { return; } diff --git a/src/Propel/Runtime/Validator/Constraints/UniqueValidator.php b/src/Propel/Runtime/Validator/Constraints/UniqueValidator.php index 086c6cdfbb..7580e2de92 100644 --- a/src/Propel/Runtime/Validator/Constraints/UniqueValidator.php +++ b/src/Propel/Runtime/Validator/Constraints/UniqueValidator.php @@ -16,6 +16,12 @@ class UniqueValidator extends ConstraintValidator { + /** + * @param mixed $value + * @param \Symfony\Component\Validator\Constraint $constraint + * + * @return void + */ public function validate($value, Constraint $constraint) { if (null === $value) { From 1832162e3052f58e83539f171b86fb822284544d Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 23 Jul 2020 16:05:46 +0200 Subject: [PATCH 121/208] Adjustments as per review. Fix more docblocks and missing return type docs. --- .../Common/Config/Loader/FileLoader.php | 5 +- .../Common/Config/Loader/IniFileLoader.php | 2 + .../Archivable/ArchivableBehavior.php | 2 +- .../Generator/Behavior/I18n/I18nBehavior.php | 14 ++- .../I18nBehaviorObjectBuilderModifier.php | 4 +- .../SortableBehaviorObjectBuilderModifier.php | 20 ++++ .../Timestampable/TimestampableBehavior.php | 2 +- .../Behavior/Validate/ValidateBehavior.php | 2 + .../Generator/Builder/DataModelBuilder.php | 3 + .../Builder/Om/AbstractOMBuilder.php | 4 + .../Om/ExtensionQueryInheritanceBuilder.php | 4 +- .../Builder/Om/MultiExtendObjectBuilder.php | 6 +- .../Generator/Builder/Om/ObjectBuilder.php | 109 +++++++++++++++--- .../Builder/Om/QueryInheritanceBuilder.php | 6 +- src/Propel/Generator/Model/Behavior.php | 1 + .../Generator/Model/CrossForeignKeys.php | 1 + src/Propel/Generator/Model/Database.php | 2 + src/Propel/Generator/Model/ForeignKey.php | 1 + src/Propel/Generator/Model/Index.php | 1 + .../Generator/Reverse/PgsqlSchemaParser.php | 7 ++ .../Generator/Reverse/SqliteSchemaParser.php | 5 + src/Propel/Generator/Util/BehaviorLocator.php | 2 + src/Propel/Generator/Util/PhpParser.php | 18 ++- src/Propel/Generator/Util/SchemaValidator.php | 15 +++ src/Propel/Runtime/Parser/AbstractParser.php | 1 + src/Propel/Runtime/Propel.php | 6 +- .../ServiceContainerInterface.php | 2 + .../StandardServiceContainer.php | 2 + src/Propel/Runtime/Util/PropelDateTime.php | 5 + .../Validator/Constraints/DateValidator.php | 4 +- .../Common/Config/Loader/FileLoaderTest.php | 6 + 31 files changed, 228 insertions(+), 34 deletions(-) diff --git a/src/Propel/Common/Config/Loader/FileLoader.php b/src/Propel/Common/Config/Loader/FileLoader.php index 922e3e6036..a31a0c995c 100644 --- a/src/Propel/Common/Config/Loader/FileLoader.php +++ b/src/Propel/Common/Config/Loader/FileLoader.php @@ -61,12 +61,12 @@ public function __construct(FileLocatorInterface $locator = null) * Replaces parameter placeholders (%name%) by their values for all parameters. * * @param array $configuration The configuration array to resolve - * @return array|null + * @return array */ public function resolveParams(array $configuration) { if ($this->resolved) { - return null; + return $configuration; } $this->config = $configuration; @@ -107,6 +107,7 @@ protected function getPath($file) * * @param string|string[] $ext An extension or an array of extensions * @param string|false $resource A resource + * @return bool */ protected function checkSupports($ext, $resource) { diff --git a/src/Propel/Common/Config/Loader/IniFileLoader.php b/src/Propel/Common/Config/Loader/IniFileLoader.php index c58285da6e..86167654e6 100644 --- a/src/Propel/Common/Config/Loader/IniFileLoader.php +++ b/src/Propel/Common/Config/Loader/IniFileLoader.php @@ -141,6 +141,8 @@ private function parseSection(array $section) * @param array $config * * @throws \Propel\Common\Config\Exception\IniParseException + * + * @return void */ private function parseKey($key, $value, array &$config) { diff --git a/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php b/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php index 6d53be3621..e76fc80773 100644 --- a/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php +++ b/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php @@ -150,7 +150,7 @@ public function getArchiveTable() /** * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder * - * @return mixed + * @return string */ public function getArchiveTablePhpName($builder) { diff --git a/src/Propel/Generator/Behavior/I18n/I18nBehavior.php b/src/Propel/Generator/Behavior/I18n/I18nBehavior.php index 87525f458a..42412ddbe2 100644 --- a/src/Propel/Generator/Behavior/I18n/I18nBehavior.php +++ b/src/Propel/Generator/Behavior/I18n/I18nBehavior.php @@ -40,12 +40,24 @@ class I18nBehavior extends Behavior protected $tableModificationOrder = 70; + /** + * @var \Propel\Generator\Behavior\I18n\I18nBehaviorObjectBuilderModifier|null + */ protected $objectBuilderModifier; + /** + * @var \Propel\Generator\Behavior\I18n\I18nBehaviorQueryBuilderModifier|null + */ protected $queryBuilderModifier; + /** + * @var \Propel\Generator\Model\Table + */ protected $i18nTable; + /** + * @return void + */ public function modifyDatabase() { foreach ($this->getDatabase()->getTables() as $table) { @@ -282,7 +294,7 @@ protected function addLocaleColumnToI18n() * * @return void */ - protected function moveI18nColumns(): void + protected function moveI18nColumns() { $table = $this->getTable(); $i18nTable = $this->i18nTable; diff --git a/src/Propel/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifier.php index 21e1c91b4b..3b7f9ff550 100644 --- a/src/Propel/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifier.php @@ -218,7 +218,7 @@ protected function addGetCurrentTranslation() } /** - * FIXME: the connection used by getCurrentTranslation in the generated code cannot be specified by the user + * @todo The connection used by getCurrentTranslation in the generated code cannot be specified by the user * * @param \Propel\Generator\Model\Column $column * @@ -249,7 +249,7 @@ protected function addTranslatedColumnGetter(Column $column) } /** - * FIXME: the connection used by getCurrentTranslation in the generated code cannot be specified by the user + * @todo The connection used by getCurrentTranslation in the generated code cannot be specified by the user * * @param \Propel\Generator\Model\Column $column * diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php index 1dafa88c46..1ea5c740d1 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php @@ -66,16 +66,31 @@ public function __construct($behavior) $this->table = $behavior->getTable(); } + /** + * @param string $key + * + * @return mixed + */ protected function getParameter($key) { return $this->behavior->getParameter($key); } + /** + * @param string $name + * + * @return string + */ protected function getColumnAttribute($name) { return strtolower($this->behavior->getColumnForParameter($name)->getName()); } + /** + * @param string $name + * + * @return string|null + */ protected function getColumnPhpName($name) { return $this->behavior->getColumnForParameter($name)->getPhpName(); @@ -650,6 +665,11 @@ public function insertAtTop() "; } + /** + * @param string $script + * + * @return void + */ protected function addMoveToRank(&$script) { $useScope = $this->behavior->useScope(); diff --git a/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php b/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php index 069810b45b..d58d190fb5 100644 --- a/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php +++ b/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php @@ -79,7 +79,7 @@ protected function getColumnSetter($column) * @param string $columnName * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder * - * @return mixed + * @return string */ protected function getColumnConstant($columnName, $builder) { diff --git a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php index 23f0db0809..98da53c4ae 100644 --- a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php +++ b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php @@ -123,6 +123,8 @@ public function removeParametersFromColumnName($columnName = null) * Useful when modify table (i18n behavior). * If all the rules have been removed, the behavior can't perform validation on related tables. * This method introduce a rule to avoid this. + * + * @return void */ public function addRuleOnPk() { diff --git a/src/Propel/Generator/Builder/DataModelBuilder.php b/src/Propel/Generator/Builder/DataModelBuilder.php index 5aad38bcb2..a4f828a5c7 100644 --- a/src/Propel/Generator/Builder/DataModelBuilder.php +++ b/src/Propel/Generator/Builder/DataModelBuilder.php @@ -411,6 +411,7 @@ public function setGeneratorConfig(GeneratorConfigInterface $v) /** * Sets the table for this builder. * @param Table $table + * @return void */ public function setTable(Table $table) { @@ -451,6 +452,7 @@ public function getPlatform() * Platform setter * * @param PlatformInterface $platform + * @return void */ public function setPlatform(PlatformInterface $platform) { @@ -486,6 +488,7 @@ public function getDatabase() /** * Pushes a message onto the stack of warnings. * @param string $msg The warning message. + * @return void */ protected function warn($msg) { diff --git a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php index 72b9415727..e1f2b963b8 100644 --- a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php @@ -97,6 +97,8 @@ public function build() * This method may emit warnings for code which may cause problems * and will throw exceptions for errors that will definitely cause * problems. + * + * @return void */ protected function validateModel() { @@ -1073,6 +1075,7 @@ private function clean($content) * Opens class. * * @param string $script + * @return void */ abstract protected function addClassOpen(&$script); @@ -1093,6 +1096,7 @@ abstract protected function addClassBody(&$script); * Closes class. * * @param string $script + * @return void */ abstract protected function addClassClose(&$script); } diff --git a/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php index 779d95df5c..168636d1fa 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php @@ -77,7 +77,8 @@ public function getChild() /** * Adds class phpdoc comment and opening of class. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addClassOpen(&$script) { @@ -134,6 +135,7 @@ protected function addClassBody(&$script) * Closes class. * * @param string $script + * @return void */ protected function addClassClose(&$script) { diff --git a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php index 010b56a8bb..d3b94400ad 100644 --- a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php @@ -103,7 +103,8 @@ protected function getParentClassName() /** * Adds class phpdoc comment and opening of class. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addClassOpen(&$script) { @@ -183,7 +184,8 @@ public function __construct() /** * Closes class. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addClassClose(&$script) { diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index c0e0fed6cb..c9499150af 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -92,6 +92,8 @@ public function getUnprefixedClassName() * This method may emit warnings for code which may cause problems * and will throw exceptions for errors that will definitely cause * problems. + * + * @return void */ protected function validateModel() { @@ -206,7 +208,8 @@ protected function getDefaultValueString(Column $column) /** * Adds class phpdoc comment and opening of class. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addClassOpen(&$script) { @@ -372,7 +375,8 @@ protected function addClassBody(&$script) /** * Closes class. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addClassClose(&$script) { @@ -385,7 +389,8 @@ protected function addClassClose(&$script) /** * Adds any constants to the class. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addConstants(&$script) { @@ -400,7 +405,8 @@ protected function addConstants(&$script) /** * Adds class attributes. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addAttributes(&$script) { @@ -437,7 +443,8 @@ protected function addAttributes(&$script) /** * Adds variables that store column values. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addColumnAttributes(&$script) { @@ -466,6 +473,7 @@ protected function addColumnAttributes(&$script) * * @param string $script * @param Column $column + * @return void */ protected function addColumnAttributeComment(&$script, Column $column) { @@ -499,6 +507,7 @@ protected function addColumnAttributeComment(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addColumnAttributeDeclaration(&$script, Column $column) { @@ -514,6 +523,7 @@ protected function addColumnAttributeDeclaration(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addColumnAttributeLoaderComment(&$script, Column $column) { @@ -532,6 +542,7 @@ protected function addColumnAttributeLoaderComment(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addColumnAttributeLoaderDeclaration(&$script, Column $column) { @@ -546,6 +557,7 @@ protected function addColumnAttributeLoaderDeclaration(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addColumnAttributeUnserializedComment(&$script, Column $column) { @@ -563,6 +575,7 @@ protected function addColumnAttributeUnserializedComment(&$script, Column $colum * * @param string $script * @param Column $column + * @return void */ protected function addColumnAttributeUnserializedDeclaration(&$script, Column $column) { @@ -575,6 +588,7 @@ protected function addColumnAttributeUnserializedDeclaration(&$script, Column $c /** * @param string $script * @param Column $column + * @return void */ protected function addColumnAttributeConvertedDeclaration(&$script, Column $column) { @@ -587,7 +601,8 @@ protected function addColumnAttributeConvertedDeclaration(&$script, Column $colu /** * Adds the constructor for this object. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addConstructor(&$script) { @@ -602,7 +617,8 @@ protected function addConstructor(&$script) /** * Adds the comment for the constructor * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addConstructorComment(&$script) { @@ -694,7 +710,8 @@ protected function addHookMethods(&$script) /** * Adds the applyDefaults() method, which is called from the constructor. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addApplyDefaultValues(&$script) { @@ -707,7 +724,8 @@ protected function addApplyDefaultValues(&$script) /** * Adds the comment for the applyDefaults method. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addApplyDefaultValuesComment(&$script) { @@ -723,7 +741,8 @@ protected function addApplyDefaultValuesComment(&$script) /** * Adds the function declaration for the applyDefaults method. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addApplyDefaultValuesOpen(&$script) { @@ -735,7 +754,8 @@ public function applyDefaultValues() /** * Adds the function body of the applyDefault method. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addApplyDefaultValuesBody(&$script) { @@ -769,7 +789,8 @@ protected function addApplyDefaultValuesBody(&$script) /** * Adds the function close for the applyDefaults method. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addApplyDefaultValuesClose(&$script) { @@ -783,6 +804,7 @@ protected function addApplyDefaultValuesClose(&$script) * * @param string $script * @param Column $column + * @return void */ protected function addTemporalAccessor(&$script, Column $column) { @@ -836,6 +858,7 @@ public function addTemporalAccessorComment(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ public function addTemporalAccessorOpen(&$script, Column $column) { @@ -897,6 +920,7 @@ protected function getAccessorLazyLoadSnippet(Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addTemporalAccessorBody(&$script, Column $column) { @@ -935,7 +959,8 @@ protected function addTemporalAccessorBody(&$script, Column $column) /** * Adds the body of the temporal accessor. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addTemporalAccessorClose(&$script) { @@ -949,6 +974,7 @@ protected function addTemporalAccessorClose(&$script) * * @param string $script * @param Column $column + * @return void */ protected function addObjectAccessor(&$script, Column $column) { @@ -963,6 +989,7 @@ protected function addObjectAccessor(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addObjectAccessorBody(&$script, Column $column) { @@ -1001,6 +1028,7 @@ protected function addJsonAccessor(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ public function addJsonAccessorComment(&$script, Column $column) { @@ -1026,6 +1054,7 @@ public function addJsonAccessorComment(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ public function addJsonAccessorOpen(&$script, Column $column) { @@ -1060,6 +1089,7 @@ protected function addJsonAccessorBody(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addArrayAccessor(&$script, Column $column) { @@ -1074,6 +1104,7 @@ protected function addArrayAccessor(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addArrayAccessorBody(&$script, Column $column) { @@ -1100,6 +1131,7 @@ protected function addArrayAccessorBody(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addBooleanAccessor(&$script, Column $column) { @@ -1134,6 +1166,7 @@ protected static function getBooleanAccessorName(Column $column) * * @param string $script * @param Column $column + * @return void */ public function addBooleanAccessorOpen(&$script, Column $column) { @@ -1155,6 +1188,7 @@ public function addBooleanAccessorOpen(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addBooleanAccessorBody(&$script, Column $column) { @@ -1175,6 +1209,7 @@ protected function addBooleanAccessorBody(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addEnumAccessor(&$script, Column $column) { @@ -1189,6 +1224,7 @@ protected function addEnumAccessor(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ public function addEnumAccessorComment(&$script, Column $column) { @@ -1213,6 +1249,7 @@ public function addEnumAccessorComment(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addEnumAccessorBody(&$script, Column $column) { @@ -1238,6 +1275,7 @@ protected function addEnumAccessorBody(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addSetAccessor(&$script, Column $column) { @@ -1252,6 +1290,7 @@ protected function addSetAccessor(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ public function addSetAccessorComment(&$script, Column $column) { @@ -1276,6 +1315,7 @@ public function addSetAccessorComment(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addSetAccessorBody(&$script, Column $column) { @@ -1311,6 +1351,7 @@ protected function addSetAccessorBody(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addHasArrayElement(&$script, Column $column) { @@ -1353,6 +1394,7 @@ protected function addHasArrayElement(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addDefaultAccessor(&$script, Column $column) { @@ -1367,6 +1409,7 @@ protected function addDefaultAccessor(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ public function addDefaultAccessorComment(&$script, Column $column) { @@ -1390,6 +1433,7 @@ public function addDefaultAccessorComment(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ public function addDefaultAccessorOpen(&$script, Column $column) { @@ -1411,6 +1455,7 @@ public function addDefaultAccessorOpen(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addDefaultAccessorBody(&$script, Column $column) { @@ -1426,7 +1471,8 @@ protected function addDefaultAccessorBody(&$script, Column $column) /** * Adds the function close for a default accessor method. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addDefaultAccessorClose(&$script) { @@ -1440,6 +1486,7 @@ protected function addDefaultAccessorClose(&$script) * * @param string $script * @param Column $column + * @return void */ protected function addLazyLoader(&$script, Column $column) { @@ -1454,6 +1501,7 @@ protected function addLazyLoader(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addLazyLoaderComment(&$script, Column $column) { @@ -1478,6 +1526,7 @@ protected function addLazyLoaderComment(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addLazyLoaderOpen(&$script, Column $column) { @@ -1492,6 +1541,7 @@ protected function load$cfc(ConnectionInterface \$con = null) * * @param string $script * @param Column $column + * @return void */ protected function addLazyLoaderBody(&$script, Column $column) { @@ -1562,7 +1612,8 @@ protected function addLazyLoaderBody(&$script, Column $column) /** * Adds the function close for the lazy loader. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addLazyLoaderClose(&$script) { @@ -1575,6 +1626,7 @@ protected function addLazyLoaderClose(&$script) * * @param string $script * @param Column $column + * @return void */ protected function addMutatorOpen(&$script, Column $column) { @@ -1588,6 +1640,7 @@ protected function addMutatorOpen(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addJsonMutatorOpen(&$script, Column $column) { @@ -1601,6 +1654,7 @@ protected function addJsonMutatorOpen(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ public function addJsonMutatorComment(&$script, Column $column) { @@ -1643,6 +1697,7 @@ public function addMutatorComment(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ public function addMutatorOpenOpen(&$script, Column $column) { @@ -1675,6 +1730,7 @@ public function addMutatorOpenOpen(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addMutatorOpenBody(&$script, Column $column) { @@ -1696,6 +1752,7 @@ protected function addMutatorOpenBody(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addMutatorClose(&$script, Column $column) { @@ -1708,6 +1765,7 @@ protected function addMutatorClose(&$script, Column $column) * * @param string $script * @param Column $column + * @return void */ protected function addMutatorCloseBody(&$script, Column $column) { @@ -1790,6 +1848,7 @@ protected function addMutatorCloseClose(&$script, Column $col) * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() + * @return void */ protected function addLobMutator(&$script, Column $col) { @@ -1890,6 +1949,7 @@ public function addTemporalMutatorComment(&$script, Column $col) * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() + * @return void */ protected function addObjectMutator(&$script, Column $col) { @@ -1914,6 +1974,7 @@ protected function addObjectMutator(&$script, Column $col) * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() + * @return void */ protected function addJsonMutator(&$script, Column $col) { @@ -1940,6 +2001,7 @@ protected function addJsonMutator(&$script, Column $col) * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() + * @return void */ protected function addArrayMutator(&$script, Column $col) { @@ -1961,6 +2023,7 @@ protected function addArrayMutator(&$script, Column $col) * Adds a push method for an array column. * @param string $script The script will be modified in this method. * @param Column $col The current column. + * @return void */ protected function addAddArrayElement(&$script, Column $col) { @@ -2006,6 +2069,7 @@ protected function addAddArrayElement(&$script, Column $col) * Adds a remove method for an array column. * @param string $script The script will be modified in this method. * @param Column $col The current column. + * @return void */ protected function addRemoveArrayElement(&$script, Column $col) { @@ -2055,6 +2119,7 @@ protected function addRemoveArrayElement(&$script, Column $col) * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() + * @return void */ protected function addEnumMutator(&$script, Column $col) { @@ -2085,6 +2150,7 @@ protected function addEnumMutator(&$script, Column $col) * * @param string $script * @param Column $column + * @return void */ public function addEnumMutatorComment(&$script, Column $column) { @@ -2105,6 +2171,7 @@ public function addEnumMutatorComment(&$script, Column $column) * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() + * @return void */ protected function addSetMutator(&$script, Column $col) { @@ -2142,6 +2209,7 @@ protected function addSetMutator(&$script, Column $col) * * @param string $script * @param Column $column + * @return void */ public function addSetMutatorComment(&$script, Column $column) { @@ -2161,6 +2229,7 @@ public function addSetMutatorComment(&$script, Column $column) * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() + * @return void */ protected function addBooleanMutator(&$script, Column $col) { @@ -2215,6 +2284,7 @@ public function addBooleanMutatorComment(&$script, Column $col) * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() + * @return void */ protected function addDefaultMutator(&$script, Column $col) { @@ -2348,6 +2418,7 @@ protected function addHydrate(&$script) * Adds the comment for the hydrate method * @param string $script The script will be modified in this method. * @see addHydrate() + * @return void */ protected function addHydrateComment(&$script) { @@ -2376,6 +2447,7 @@ protected function addHydrateComment(&$script) * Adds the function declaration for the hydrate method * @param string $script The script will be modified in this method. * @see addHydrate() + * @return void */ protected function addHydrateOpen(&$script) { @@ -2496,6 +2568,7 @@ protected function addHydrateBody(&$script) * Adds the function close for the hydrate method * @param string $script The script will be modified in this method. * @see addHydrate() + * @return void */ protected function addHydrateClose(&$script) { @@ -6286,6 +6359,7 @@ protected function addSaveComment(&$script) * Adds the function declaration for the save method * @param string $script The script will be modified in this method. * @see addSave() + * @return void */ protected function addSaveOpen(&$script) { @@ -6301,6 +6375,7 @@ public function save(ConnectionInterface \$con = null".($reloadOnUpdate || $relo * Adds the function body for the save method * @param string $script The script will be modified in this method. * @see addSave() + * @return void */ protected function addSaveBody(&$script) { @@ -6409,6 +6484,7 @@ protected function addSaveBody(&$script) * Adds the function close for the save method * @param string $script The script will be modified in this method. * @see addSave() + * @return void */ protected function addSaveClose(&$script) { @@ -6789,7 +6865,8 @@ public function __toString() /** * Adds a magic __call() method. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addMagicCall(&$script) { diff --git a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php index 2a7c7e6659..217263603d 100644 --- a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php @@ -119,7 +119,8 @@ protected function getParentClassName() /** * Adds class phpdoc comment and opening of class. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addClassOpen(&$script) { @@ -181,7 +182,8 @@ protected function addClassBody(&$script) /** * Adds the factory for this object. * - * @param string $script + * @param string $script The script will be modified in this method. + * @return void */ protected function addFactory(&$script) { diff --git a/src/Propel/Generator/Model/Behavior.php b/src/Propel/Generator/Model/Behavior.php index b1955aafca..62c3b28c88 100644 --- a/src/Propel/Generator/Model/Behavior.php +++ b/src/Propel/Generator/Model/Behavior.php @@ -191,6 +191,7 @@ public function getDatabase() * [ 'name' => 'foo', 'value' => bar ] * * @param array $parameter + * @return void */ public function addParameter(array $parameter) { diff --git a/src/Propel/Generator/Model/CrossForeignKeys.php b/src/Propel/Generator/Model/CrossForeignKeys.php index 53755b6ba5..4364d60086 100644 --- a/src/Propel/Generator/Model/CrossForeignKeys.php +++ b/src/Propel/Generator/Model/CrossForeignKeys.php @@ -182,6 +182,7 @@ public function getUnclassifiedPrimaryKeys() /** * @param ForeignKey $foreignKey + * @return void */ public function addCrossForeignKey(ForeignKey $foreignKey) { diff --git a/src/Propel/Generator/Model/Database.php b/src/Propel/Generator/Model/Database.php index 3abed40a7d..b155084b88 100644 --- a/src/Propel/Generator/Model/Database.php +++ b/src/Propel/Generator/Model/Database.php @@ -510,6 +510,7 @@ public function getTableByPhpName($phpName) * Adds several tables at once. * * @param Table[] $tables An array of Table instances + * @return void */ public function addTables(array $tables) { @@ -592,6 +593,7 @@ public function getSequences() /** * @param string $sequence + * @return void */ public function addSequence($sequence) { diff --git a/src/Propel/Generator/Model/ForeignKey.php b/src/Propel/Generator/Model/ForeignKey.php index 14c9961a43..4871b2d7ed 100644 --- a/src/Propel/Generator/Model/ForeignKey.php +++ b/src/Propel/Generator/Model/ForeignKey.php @@ -508,6 +508,7 @@ public function getSchemaName() * * @param mixed $ref1 A Column object or an associative array or a string * @param mixed $ref2 A Column object or a single string name + * @return void */ public function addReference($ref1, $ref2 = null) { diff --git a/src/Propel/Generator/Model/Index.php b/src/Propel/Generator/Model/Index.php index 729006d7cd..b3c5c1c33f 100644 --- a/src/Propel/Generator/Model/Index.php +++ b/src/Propel/Generator/Model/Index.php @@ -179,6 +179,7 @@ public function getTableName() * Adds a new column to the index. * * @param Column|array $data Column or attributes from XML. + * @return void */ public function addColumn($data) { diff --git a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php index 869b1d3810..a4c7541b35 100755 --- a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php @@ -126,6 +126,13 @@ public function parse(Database $database, array $additionalTables = []) return count($tableWraps); } + /** + * @param array $tableWraps + * @param \Propel\Generator\Model\Database $database + * @param \Propel\Generator\Model\Table|null $filterTable + * + * @return void + */ protected function parseTables(&$tableWraps, Database $database, Table $filterTable = null) { $stmt = null; diff --git a/src/Propel/Generator/Reverse/SqliteSchemaParser.php b/src/Propel/Generator/Reverse/SqliteSchemaParser.php index 20a6e90b60..fe01ee7d75 100644 --- a/src/Propel/Generator/Reverse/SqliteSchemaParser.php +++ b/src/Propel/Generator/Reverse/SqliteSchemaParser.php @@ -267,6 +267,11 @@ protected function addColumns(Table $table) } } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return void + */ protected function addForeignKeys(Table $table) { $database = $table->getDatabase(); diff --git a/src/Propel/Generator/Util/BehaviorLocator.php b/src/Propel/Generator/Util/BehaviorLocator.php index 851ac2adc6..0ba0ca359d 100644 --- a/src/Propel/Generator/Util/BehaviorLocator.php +++ b/src/Propel/Generator/Util/BehaviorLocator.php @@ -185,6 +185,8 @@ private function getCoreBehavior($name) * Finds all behaviors by parsing composer.lock file * * @param SplFileInfo $composerLock + * + * @return array */ private function loadBehaviors($composerLock) { diff --git a/src/Propel/Generator/Util/PhpParser.php b/src/Propel/Generator/Util/PhpParser.php index 2a46264db1..507454d4e4 100644 --- a/src/Propel/Generator/Util/PhpParser.php +++ b/src/Propel/Generator/Util/PhpParser.php @@ -65,11 +65,21 @@ public function getCode() return $this->isAddPhp ? $this->removePhp($this->code) : $this->code; } + /** + * @param string $code + * + * @return string + */ protected function addPhp($code) { return 'errors); } + /** + * @param \Propel\Generator\Model\Database $database + * + * @return void + */ protected function validateDatabaseTables(Database $database) { $phpNames = []; @@ -72,6 +77,11 @@ protected function validateDatabaseTables(Database $database) } } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return void + */ protected function validateTableAttributes(Table $table) { $reservedTableNames = ['table_name']; @@ -81,6 +91,11 @@ protected function validateTableAttributes(Table $table) } } + /** + * @param \Propel\Generator\Model\Table $table + * + * @return void + */ protected function validateTableColumns(Table $table) { if (!$table->hasPrimaryKey() && !$table->isSkipSql()) { diff --git a/src/Propel/Runtime/Parser/AbstractParser.php b/src/Propel/Runtime/Parser/AbstractParser.php index 57aec66b50..c85f00fa33 100644 --- a/src/Propel/Runtime/Parser/AbstractParser.php +++ b/src/Propel/Runtime/Parser/AbstractParser.php @@ -91,6 +91,7 @@ public function load($path) * * @param string $data The file content * @param string $path Path of the file to create + * @return mixed|null|void */ public function dump($data, $path = null) { diff --git a/src/Propel/Runtime/Propel.php b/src/Propel/Runtime/Propel.php index 263f352e81..1538dacd1c 100644 --- a/src/Propel/Runtime/Propel.php +++ b/src/Propel/Runtime/Propel.php @@ -98,6 +98,7 @@ class Propel * * @param string $configFile Path (absolute or relative to include_path) to config file. * @deprecated Why don't you just include the configuration file? + * @return void */ public static function init($configFile) { @@ -125,6 +126,7 @@ public static function getServiceContainer() * Set the service container instance. * * @param \Propel\Runtime\ServiceContainer\ServiceContainerInterface $serviceContainer + * @return void */ public static function setServiceContainer(ServiceContainerInterface $serviceContainer) { @@ -182,10 +184,12 @@ public static function getConnectionManager($name) * * This method frees any database connection handles that have been * opened by the getConnection() method. + * + * @return void */ public static function closeConnections() { - return self::$serviceContainer->closeConnections(); + self::$serviceContainer->closeConnections(); } /** diff --git a/src/Propel/Runtime/ServiceContainer/ServiceContainerInterface.php b/src/Propel/Runtime/ServiceContainer/ServiceContainerInterface.php index af9ae9a82c..f11601dd8e 100644 --- a/src/Propel/Runtime/ServiceContainer/ServiceContainerInterface.php +++ b/src/Propel/Runtime/ServiceContainer/ServiceContainerInterface.php @@ -95,6 +95,8 @@ public function hasConnectionManager($name); * * This method frees any database connection handles that have been * opened by the getConnection() method. + * + * @return void */ public function closeConnections(); diff --git a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php index 5787ea85f8..9f69806f0a 100644 --- a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php +++ b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php @@ -306,6 +306,8 @@ public function getConnectionManagers() * * This method frees any database connection handles that have been * opened by the getConnection() method. + * + * @return void */ public function closeConnections() { diff --git a/src/Propel/Runtime/Util/PropelDateTime.php b/src/Propel/Runtime/Util/PropelDateTime.php index b011d0b3b7..50bb90932a 100644 --- a/src/Propel/Runtime/Util/PropelDateTime.php +++ b/src/Propel/Runtime/Util/PropelDateTime.php @@ -34,6 +34,11 @@ class PropelDateTime extends \DateTime */ private $tzString; + /** + * @param mixed $value + * + * @return bool + */ protected static function isTimestamp($value) { if (!is_numeric($value)) { diff --git a/src/Propel/Runtime/Validator/Constraints/DateValidator.php b/src/Propel/Runtime/Validator/Constraints/DateValidator.php index 3fdcf014a4..5487536a73 100644 --- a/src/Propel/Runtime/Validator/Constraints/DateValidator.php +++ b/src/Propel/Runtime/Validator/Constraints/DateValidator.php @@ -20,7 +20,9 @@ class DateValidator extends SymfonyDateValidator { /** - * @inheritdoc + * @param mixed $value The value that should be validated + * @param \Symfony\Component\Validator\Constraint $constraint + * @return void */ public function validate($value, Constraint $constraint) { diff --git a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php index e3fe556566..edf4a338ad 100644 --- a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php @@ -339,6 +339,12 @@ public function supports($resource, $type = null) } + /** + * @param string|string[] $ext + * @param false|string $resource + * + * @return bool + */ public function checkSupports($ext, $resource) { return parent::checkSupports($ext, $resource); From eff9ac56f51bd69f15eee13c2aac3d480d721512 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 23 Jul 2020 16:20:27 +0200 Subject: [PATCH 122/208] Add missing return void types. --- composer.json | 5 +- .../Behavior/AutoAddPk/AutoAddPkBehavior.php | 2 + .../Behavior/Delegate/DelegateBehavior.php | 1 + .../Behavior/NestedSet/NestedSetBehavior.php | 1 + .../Behavior/Sluggable/SluggableBehavior.php | 2 + .../Behavior/Sortable/SortableBehavior.php | 1 + .../Timestampable/TimestampableBehavior.php | 1 + .../Behavior/Validate/ValidateBehavior.php | 6 +- .../Generator/Builder/DataModelBuilder.php | 1 + .../Builder/Om/AbstractOMBuilder.php | 2 + .../Builder/Om/ExtensionObjectBuilder.php | 1 + .../Builder/Om/ExtensionQueryBuilder.php | 2 + .../Om/ExtensionQueryInheritanceBuilder.php | 2 + .../Generator/Builder/Om/InterfaceBuilder.php | 1 + .../Builder/Om/MultiExtendObjectBuilder.php | 1 + .../Generator/Builder/Om/ObjectBuilder.php | 56 +++++++++++++++++++ .../Generator/Builder/Om/QueryBuilder.php | 12 ++++ .../Builder/Om/QueryInheritanceBuilder.php | 2 + .../Generator/Builder/Om/TableMapBuilder.php | 1 + .../Generator/Builder/Util/PropelTemplate.php | 2 + .../Command/Console/Input/ArrayInput.php | 3 + .../Generator/Manager/AbstractManager.php | 9 +++ .../Generator/Manager/MigrationManager.php | 2 + src/Propel/Generator/Manager/ModelManager.php | 1 + .../Generator/Manager/ReverseManager.php | 5 ++ src/Propel/Generator/Manager/SqlManager.php | 3 + src/Propel/Generator/Model/Behavior.php | 8 +++ src/Propel/Generator/Model/Column.php | 29 ++++++++++ .../Generator/Model/ColumnDefaultValue.php | 2 + .../Generator/Model/CrossForeignKeys.php | 4 ++ src/Propel/Generator/Model/Database.php | 17 ++++++ .../Generator/Model/Diff/ColumnDiff.php | 3 + .../Model/Diff/DatabaseComparator.php | 5 ++ .../Generator/Model/Diff/DatabaseDiff.php | 11 ++++ .../Generator/Model/Diff/TableComparator.php | 2 + src/Propel/Generator/Model/Diff/TableDiff.php | 34 +++++++++++ src/Propel/Generator/Model/Domain.php | 15 +++++ src/Propel/Generator/Model/ForeignKey.php | 12 ++++ .../Generator/Model/IdMethodParameter.php | 3 + src/Propel/Generator/Model/Index.php | 5 ++ src/Propel/Generator/Model/Inheritance.php | 5 ++ src/Propel/Generator/Model/MappingModel.php | 1 + src/Propel/Generator/Model/Schema.php | 5 ++ .../Generator/Model/ScopedMappingModel.php | 2 + src/Propel/Generator/Model/Table.php | 30 ++++++++++ src/Propel/Generator/Model/VendorInfo.php | 3 + .../Generator/Platform/DefaultPlatform.php | 6 ++ .../Generator/Platform/MssqlPlatform.php | 1 + .../Generator/Platform/MysqlPlatform.php | 3 + .../Generator/Platform/OraclePlatform.php | 1 + .../Generator/Platform/PgsqlPlatform.php | 3 +- .../Generator/Platform/SqlitePlatform.php | 1 + .../Reverse/AbstractSchemaParser.php | 4 ++ .../Generator/Reverse/MssqlSchemaParser.php | 4 ++ .../Generator/Reverse/MysqlSchemaParser.php | 5 ++ .../Generator/Reverse/OracleSchemaParser.php | 4 ++ .../Generator/Reverse/PgsqlSchemaParser.php | 5 ++ .../Generator/Reverse/SqliteSchemaParser.php | 2 + .../Generator/Schema/Dumper/XmlDumper.php | 11 ++++ src/Propel/Generator/Util/QuickBuilder.php | 7 +++ src/Propel/Generator/Util/SqlParser.php | 1 + src/Propel/Runtime/ActiveQuery/Criteria.php | 4 ++ .../Criterion/AbstractCriterion.php | 3 + .../ActiveQuery/Criterion/BasicCriterion.php | 1 + .../Criterion/BasicModelCriterion.php | 1 + .../ActiveQuery/Criterion/BinaryCriterion.php | 1 + .../Criterion/BinaryModelCriterion.php | 1 + .../ActiveQuery/Criterion/CustomCriterion.php | 1 + .../ActiveQuery/Criterion/InCriterion.php | 1 + .../Criterion/InModelCriterion.php | 1 + .../ActiveQuery/Criterion/LikeCriterion.php | 1 + .../Criterion/LikeModelCriterion.php | 1 + .../ActiveQuery/Criterion/RawCriterion.php | 1 + .../Criterion/RawModelCriterion.php | 1 + .../Criterion/SeveralModelCriterion.php | 1 + src/Propel/Runtime/ActiveQuery/Join.php | 12 ++++ .../Runtime/ActiveQuery/ModelCriteria.php | 3 + src/Propel/Runtime/ActiveQuery/ModelWith.php | 1 + .../Runtime/Adapter/Pdo/MssqlAdapter.php | 4 +- .../Runtime/Adapter/Pdo/MysqlAdapter.php | 3 + .../Runtime/Adapter/Pdo/OracleAdapter.php | 4 +- src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php | 6 +- .../Runtime/Adapter/Pdo/PgsqlAdapter.php | 3 +- .../Runtime/Adapter/Pdo/SqliteAdapter.php | 2 + .../Runtime/Adapter/Pdo/SqlsrvAdapter.php | 3 + .../Runtime/Collection/ArrayCollection.php | 3 + src/Propel/Runtime/Collection/Collection.php | 11 ++++ .../Runtime/Collection/ObjectCollection.php | 9 +++ .../Runtime/Collection/OnDemandCollection.php | 6 ++ .../Runtime/Collection/OnDemandIterator.php | 2 + .../ConnectionManagerMasterSlave.php | 1 + .../ConnectionManagerPrimaryReplica.php | 4 ++ .../Connection/ConnectionManagerSingle.php | 1 + .../Runtime/Connection/ConnectionWrapper.php | 11 +++- .../Runtime/Connection/PdoConnection.php | 8 +-- .../Connection/ProfilerConnectionWrapper.php | 11 ++-- .../Runtime/Connection/StatementWrapper.php | 1 + .../DataFetcher/AbstractDataFetcher.php | 5 +- .../Runtime/DataFetcher/ArrayDataFetcher.php | 16 ++++-- .../Runtime/DataFetcher/PDODataFetcher.php | 16 ++++-- .../Runtime/Formatter/AbstractFormatter.php | 1 + src/Propel/Runtime/Map/ColumnMap.php | 9 +++ src/Propel/Runtime/Map/DatabaseMap.php | 1 + src/Propel/Runtime/Map/RelationMap.php | 7 +++ src/Propel/Runtime/Map/TableMap.php | 9 +++ .../StandardServiceContainer.php | 14 +++++ src/Propel/Runtime/Util/Profiler.php | 5 ++ src/Propel/Runtime/Util/PropelDateTime.php | 1 + src/Propel/Runtime/Util/PropelModelPager.php | 4 ++ 109 files changed, 563 insertions(+), 32 deletions(-) diff --git a/composer.json b/composer.json index ae79729aa6..fd566bfd55 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "require-dev": { "monolog/monolog": "^1.3", "phpstan/phpstan": "^0.12.4", - "phpunit/phpunit": "^7.5.15" + "phpunit/phpunit": "^7.5.15", + "spryker/code-sniffer": "^0.15.4" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." @@ -43,6 +44,8 @@ "bin/propel" ], "scripts": { + "cs-check": "phpcs -p -s --standard=vendor/spryker/code-sniffer/Spryker/ruleset.xml src/", + "cs-fix": "phpcbf -p --standard=vendor/spryker/code-sniffer/Spryker/ruleset.xml src/", "stan": [ "vendor/bin/phpstan analyze" ] diff --git a/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php b/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php index aee68bf1c6..25308ade2e 100644 --- a/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php +++ b/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php @@ -29,6 +29,7 @@ class AutoAddPkBehavior extends Behavior /** * Copy the behavior to the database tables * Only for tables that have no Pk +* @return void */ public function modifyDatabase() { @@ -42,6 +43,7 @@ public function modifyDatabase() /** * Add the primary key to the current table +* @return void */ public function modifyTable() { diff --git a/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php b/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php index 53987ea8c4..12a2f4a81a 100644 --- a/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php +++ b/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php @@ -43,6 +43,7 @@ class DelegateBehavior extends Behavior /** * Lists the delegates and checks that the behavior can use them, * And adds a fk from the delegate to the main table if not already set +* @return void */ public function modifyTable() { diff --git a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php index 6852db9eb9..227887e7ec 100644 --- a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php +++ b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php @@ -35,6 +35,7 @@ class NestedSetBehavior extends Behavior /** * Add the left, right and scope to the current table +* @return void */ public function modifyTable() { diff --git a/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php b/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php index d7ca7465d7..fbbb32392b 100644 --- a/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php +++ b/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php @@ -45,6 +45,7 @@ class SluggableBehavior extends Behavior /** * Adds the slug_column to the current table. * +* @return void */ public function modifyTable() { @@ -68,6 +69,7 @@ public function modifyTable() * Adds a unique constraint to the table to enforce uniqueness of the slug_column * * @param Table $table +* @return void */ protected function addUniqueConstraint(Table $table) { diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php b/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php index 29101d325e..bef56890dd 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php @@ -34,6 +34,7 @@ class SortableBehavior extends Behavior /** * Add the rank_column to the current table +* @return void */ public function modifyTable() { diff --git a/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php b/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php index d58d190fb5..357b7096ea 100644 --- a/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php +++ b/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php @@ -45,6 +45,7 @@ protected function withCreatedAt() /** * Add the create_column and update_columns to the current table +* @return void */ public function modifyTable() { diff --git a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php index 98da53c4ae..a2e3f79da3 100644 --- a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php +++ b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php @@ -102,6 +102,7 @@ public function getParametersFromColumnName($columnName = null) * Useful for i18n behavior * * @param string $columnName The column name +* @return void */ public function removeParametersFromColumnName($columnName = null) { @@ -145,6 +146,7 @@ public function addRuleOnPk() * Merge $paramArray array into parameters array. * This method avoid that there are rules with the same name, when adding parameters programmatically. * Useful for Concrete Inheritance behavior. +* @return void */ public function mergeParameters(array $params = null) { @@ -168,6 +170,7 @@ public function mergeParameters(array $params = null) /** * Convert those parameters, containing an array in YAML format * into a php array +* @return void */ protected function cleanupParameters() { @@ -280,10 +283,11 @@ protected function addValidateMethod() /** * Adds the getValidationFailures() method. + * + * @return string */ protected function addGetValidationFailuresMethod() { return $this->renderTemplate('objectGetValidationFailures'); } - } diff --git a/src/Propel/Generator/Builder/DataModelBuilder.php b/src/Propel/Generator/Builder/DataModelBuilder.php index a4f828a5c7..33adefdd60 100644 --- a/src/Propel/Generator/Builder/DataModelBuilder.php +++ b/src/Propel/Generator/Builder/DataModelBuilder.php @@ -402,6 +402,7 @@ public function getBuildProperty($name) * Sets the GeneratorConfig object. * * @param GeneratorConfigInterface $v +* @return void */ public function setGeneratorConfig(GeneratorConfigInterface $v) { diff --git a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php index e1f2b963b8..a6703d02e8 100644 --- a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php @@ -771,6 +771,7 @@ protected function getCrossFKAddMethodInformation(CrossForeignKeys $crossFKs, $c * @param array $shortSignature * @param array $normalizedShortSignature * @param array $phpDoc +* @return void */ protected function extractCrossInformation( CrossForeignKeys $crossFKs, @@ -951,6 +952,7 @@ public function hasBehaviorModifier($hookName, $modifier) * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string $modifier The name of the modifier object providing the method in the behavior * @param string $script The script will be modified in this method. +* @return void */ public function applyBehaviorModifierBase($hookName, $modifier, &$script, $tab = " ") { diff --git a/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php index 02d959d141..1e79f2ecfb 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php @@ -75,6 +75,7 @@ protected function addClassOpen(&$script) * if you want to change that behavior. * * @see ObjectBuilder::addClassBody() +* @return void */ protected function addClassBody(&$script) { diff --git a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php index 0edc227dda..96f340c029 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php @@ -76,6 +76,7 @@ class ".$this->getUnqualifiedClassName()." extends $baseClassName * if you want to change that behavior. * * @see QueryBuilder::addClassBody() +* @return void */ protected function addClassBody(&$script) @@ -110,6 +111,7 @@ public function hasBehaviorModifier($hookName, $modifier = '') * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string $script The script will be modified in this method. * @param string $tab +* @return void */ public function applyBehaviorModifier($hookName, &$script, $tab = " ") { diff --git a/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php index 168636d1fa..59c22c3a6f 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php @@ -53,6 +53,7 @@ public function getPackage() * Set the child object that we're operating on currently. * * @param Inheritance $child Inheritance +* @return void */ public function setChild(Inheritance $child) { @@ -125,6 +126,7 @@ class " .$this->getUnqualifiedClassName() . " extends " . $baseClassName . " * * @param string $script * @see ObjectBuilder::addClassBody() +* @return void */ protected function addClassBody(&$script) { diff --git a/src/Propel/Generator/Builder/Om/InterfaceBuilder.php b/src/Propel/Generator/Builder/Om/InterfaceBuilder.php index fd8f30d5aa..b1865e5a24 100644 --- a/src/Propel/Generator/Builder/Om/InterfaceBuilder.php +++ b/src/Propel/Generator/Builder/Om/InterfaceBuilder.php @@ -73,6 +73,7 @@ interface ".$this->getUnqualifiedClassName()." * if you want to change that behavior. * * @see ObjectBuilder::addClassBody() +* @return void */ protected function addClassBody(&$script) { diff --git a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php index d3b94400ad..92f690107f 100644 --- a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php @@ -55,6 +55,7 @@ public function getPackage() * Sets the child object that we're operating on currently. * * @param Inheritance $child Inheritance +* @return void */ public function setChild(Inheritance $child) { diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index c9499150af..f699e1407f 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -264,6 +264,7 @@ abstract class ".$this->getUnqualifiedClassName().$parentClass." implements Acti * * @param string $script * @see ObjectBuilder::addClassBody() +* @return void */ protected function addClassBody(&$script) { @@ -819,6 +820,7 @@ protected function addTemporalAccessor(&$script, Column $column) * * @param string $script * @param Column $column +* @return void */ public function addTemporalAccessorComment(&$script, Column $column) { @@ -1833,6 +1835,7 @@ protected function addMutatorCloseBody(&$script, Column $column) * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see addMutatorClose() +* @return void */ protected function addMutatorCloseClose(&$script, Column $col) { @@ -1875,6 +1878,7 @@ protected function addLobMutator(&$script, Column $col) * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() +* @return void */ protected function addTemporalMutator(&$script, Column $col) { @@ -2328,6 +2332,7 @@ protected function addHasOnlyDefaultValues(&$script) * Adds the comment for the hasOnlyDefaultValues method * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues +* @return void */ protected function addHasOnlyDefaultValuesComment(&$script) { @@ -2346,6 +2351,7 @@ protected function addHasOnlyDefaultValuesComment(&$script) * Adds the function declaration for the hasOnlyDefaultValues method * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues +* @return void */ protected function addHasOnlyDefaultValuesOpen(&$script) { @@ -2358,6 +2364,7 @@ public function hasOnlyDefaultValues() * Adds the function body for the hasOnlyDefaultValues method * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues +* @return void */ protected function addHasOnlyDefaultValuesBody(&$script) { @@ -2390,6 +2397,7 @@ protected function addHasOnlyDefaultValuesBody(&$script) * Adds the function close for the hasOnlyDefaultValues method * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues +* @return void */ protected function addHasOnlyDefaultValuesClose(&$script) { @@ -2460,6 +2468,7 @@ public function hydrate(\$row, \$startcol = 0, \$rehydrate = false, \$indexType * Adds the function body for the hydrate method * @param string $script The script will be modified in this method. * @see addHydrate() +* @return void */ protected function addHydrateBody(&$script) { @@ -2596,6 +2605,7 @@ protected function addBuildPkeyCriteria(&$script) * Adds the comment for the buildPkeyCriteria method * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() +* @return void */ protected function addBuildPkeyCriteriaComment(&$script) { @@ -2616,6 +2626,7 @@ protected function addBuildPkeyCriteriaComment(&$script) * Adds the function declaration for the buildPkeyCriteria method * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() +* @return void */ protected function addBuildPkeyCriteriaOpen(&$script) { @@ -2628,6 +2639,7 @@ public function buildPkeyCriteria() * Adds the function body for the buildPkeyCriteria method * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() +* @return void */ protected function addBuildPkeyCriteriaBody(&$script) { @@ -2651,6 +2663,7 @@ protected function addBuildPkeyCriteriaBody(&$script) * Adds the function close for the buildPkeyCriteria method * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() +* @return void */ protected function addBuildPkeyCriteriaClose(&$script) { @@ -2678,6 +2691,7 @@ protected function addBuildCriteria(&$script) * Adds comment for the buildCriteria method * @param string $script The script will be modified in this method. * @see addBuildCriteria() +* @return void */ protected function addBuildCriteriaComment(&$script) { @@ -2693,6 +2707,7 @@ protected function addBuildCriteriaComment(&$script) * Adds the function declaration of the buildCriteria method * @param string $script The script will be modified in this method. * @see addBuildCriteria() +* @return void */ protected function addBuildCriteriaOpen(&$script) { @@ -2705,6 +2720,7 @@ public function buildCriteria() * Adds the function body of the buildCriteria method * @param string $script The script will be modified in this method. * @see addBuildCriteria() +* @return void */ protected function addBuildCriteriaBody(&$script) { @@ -2724,6 +2740,7 @@ protected function addBuildCriteriaBody(&$script) * Adds the function close of the buildCriteria method * @param string $script The script will be modified in this method. * @see addBuildCriteria() +* @return void */ protected function addBuildCriteriaClose(&$script) { @@ -2888,6 +2905,7 @@ protected function addGetByName(&$script) * Adds the comment for the getByName method * @param string $script The script will be modified in this method. * @see addGetByName +* @return void */ protected function addGetByNameComment(&$script) { @@ -2909,6 +2927,7 @@ protected function addGetByNameComment(&$script) * Adds the function declaration for the getByName method * @param string $script The script will be modified in this method. * @see addGetByName +* @return void */ protected function addGetByNameOpen(&$script) { @@ -2922,6 +2941,7 @@ public function getByName(\$name, \$type = TableMap::$defaultKeyType) * Adds the function body for the getByName method * @param string $script The script will be modified in this method. * @see addGetByName +* @return void */ protected function addGetByNameBody(&$script) { @@ -2934,6 +2954,7 @@ protected function addGetByNameBody(&$script) * Adds the function close for the getByName method * @param string $script The script will be modified in this method. * @see addGetByName +* @return void */ protected function addGetByNameClose(&$script) { @@ -2961,6 +2982,7 @@ protected function addGetByPosition(&$script) * Adds comment for the getByPosition method * @param string $script The script will be modified in this method. * @see addGetByPosition +* @return void */ protected function addGetByPositionComment(&$script) { @@ -2978,6 +3000,7 @@ protected function addGetByPositionComment(&$script) * Adds the function declaration for the getByPosition method * @param string $script The script will be modified in this method. * @see addGetByPosition +* @return void */ protected function addGetByPositionOpen(&$script) { @@ -2990,6 +3013,7 @@ public function getByPosition(\$pos) * Adds the function body for the getByPosition method * @param string $script The script will be modified in this method. * @see addGetByPosition +* @return void */ protected function addGetByPositionBody(&$script) { @@ -3016,6 +3040,7 @@ protected function addGetByPositionBody(&$script) * Adds the function close for the getByPosition method * @param string $script The script will be modified in this method. * @see addGetByPosition +* @return void */ protected function addGetByPositionClose(&$script) { @@ -3221,6 +3246,7 @@ protected function addDelete(&$script) * Adds the comment for the delete function * @param string $script The script will be modified in this method. * @see addDelete() +* @return void */ protected function addDeleteComment(&$script) { @@ -3241,6 +3267,7 @@ protected function addDeleteComment(&$script) * Adds the function declaration for the delete function * @param string $script The script will be modified in this method. * @see addDelete() +* @return void */ protected function addDeleteOpen(&$script) { @@ -3253,6 +3280,7 @@ public function delete(ConnectionInterface \$con = null) * Adds the function body for the delete function * @param string $script The script will be modified in this method. * @see addDelete() +* @return void */ protected function addDeleteBody(&$script) { @@ -3301,6 +3329,7 @@ protected function addDeleteBody(&$script) * Adds the function close for the delete function * @param string $script The script will be modified in this method. * @see addDelete() +* @return void */ protected function addDeleteClose(&$script) { @@ -3560,6 +3589,7 @@ public function getPrimaryKey() * deprecated. * @param string $script The script will be modified in this method. * @deprecated +* @return void */ protected function addGetPrimaryKey_NoPK(&$script) { @@ -3656,6 +3686,7 @@ public function setPrimaryKey(\$keys) * deprecated. * @param string $script The script will be modified in this method. * @deprecated +* @return void */ protected function addSetPrimaryKey_NoPK(&$script) { @@ -3759,6 +3790,7 @@ protected function addFKMethods(&$script) * Adds the class attributes that are needed to store fkey related objects. * @param string $script The script will be modified in this method. * @param ForeignKey $fk +* @return void */ protected function addFKAttributes(&$script, ForeignKey $fk) { @@ -3777,6 +3809,7 @@ protected function addFKAttributes(&$script, ForeignKey $fk) * Adds the mutator (setter) method for setting an fkey related object. * @param string $script The script will be modified in this method. * @param ForeignKey $fk +* @return void */ protected function addFKMutator(&$script, ForeignKey $fk) { @@ -3862,6 +3895,7 @@ public function set".$this->getFKPhpNameAffix($fk, false)."($className \$v = nul * Adds the accessor (getter) method for getting an fkey related object. * @param string $script The script will be modified in this method. * @param ForeignKey $fk +* @return void */ protected function addFKAccessor(&$script, ForeignKey $fk) { @@ -3967,6 +4001,7 @@ public function get".$this->getFKPhpNameAffix($fk, false)."(ConnectionInterface * Adds the method that fetches fkey-related (referencing) objects but also joins in data from another table. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK +* @return void */ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK) { @@ -4037,6 +4072,7 @@ public function get".$relCol."Join".$relCol2."(Criteria \$criteria = null, Conne * private lastVarNameCriteria = null; * @param string $script The script will be modified in this method. * @param ForeignKey $refFK +* @return void */ protected function addRefFKAttributes(&$script, ForeignKey $refFK) { @@ -4095,6 +4131,7 @@ protected function addRefFKMethods(&$script) /** * @param string $script * @param ForeignKey[] $referrers +* @return void */ protected function addInitRelations(&$script, $referrers) { @@ -4130,6 +4167,7 @@ public function initRelation(\$relationName) * Adds the method that clears the referrer fkey collection. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK +* @return void */ protected function addRefFKClear(&$script, ForeignKey $refFK) { @@ -4157,6 +4195,7 @@ public function clear$relCol() * Adds the method that initializes the referrer fkey collection. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK +* @return void */ protected function addRefFKInit(&$script, ForeignKey $refFK) { @@ -4194,6 +4233,7 @@ public function init$relCol(\$overrideExisting = true) * Adds the method that adds an object into the referrer fkey collection. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK +* @return void */ protected function addRefFKAdd(&$script, ForeignKey $refFK) { @@ -4241,6 +4281,7 @@ public function add".$this->getRefFKPhpNameAffix($refFK, false)."($className \$l * Adds the method that returns the size of the referrer fkey collection. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK +* @return void */ protected function addRefFKCount(&$script, ForeignKey $refFK) { @@ -4292,6 +4333,7 @@ public function count{$relCol}(Criteria \$criteria = null, \$distinct = false, C * Adds the method that returns the referrer fkey collection. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK +* @return void */ protected function addRefFKGet(&$script, ForeignKey $refFK) { @@ -4436,6 +4478,7 @@ public function set{$relatedName}(Collection \${$inputCollection}, ConnectionInt /** * @param string $script The script will be modified in this method. * @param ForeignKey $refFK +* @return void */ protected function addRefFKDoAdd(&$script, ForeignKey $refFK) { @@ -4466,6 +4509,7 @@ protected function doAdd{$relatedObjectClassName}($className \${$lowerRelatedObj /** * @param string $script The script will be modified in this method. * @param ForeignKey $refFK +* @return void */ protected function addRefFKRemove(&$script, ForeignKey $refFK) { @@ -4523,6 +4567,7 @@ public function remove{$relatedObjectClassName}($className \${$lowerRelatedObjec * This is for one-to-one relationship special case. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK +* @return void */ protected function addPKRefFKGet(&$script, ForeignKey $refFK) { @@ -4558,6 +4603,7 @@ public function get".$this->getRefFKPhpNameAffix($refFK, false)."(ConnectionInte * This is for one-to-one relationships special case. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK The referencing foreign key. +* @return void */ protected function addPKRefFKSet(&$script, ForeignKey $refFK) { @@ -4720,6 +4766,7 @@ protected function addRefFkScheduledForDeletionAttribute(&$script, ForeignKey $r /** * @param string $script * @param CrossForeignKeys $crossFKs +* @return void */ protected function addCrossFkScheduledForDeletion(&$script, CrossForeignKeys $crossFKs) { @@ -4944,6 +4991,7 @@ protected function addCrossFKMethods(&$script) * Adds the method that clears the referrer fkey collection. * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs +* @return void */ protected function addCrossFKClear(&$script, CrossForeignKeys $crossFKs) { @@ -4972,6 +5020,7 @@ public function clear{$relCol}() * * @param string $script The script will be modified in this method. * @param ForeignKey $refFK +* @return void */ protected function addRefFKPartial(&$script, ForeignKey $refFK) { @@ -4993,6 +5042,7 @@ public function resetPartial{$relCol}(\$v = true) * Adds the method that initializes the referrer fkey collection. * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs +* @return void */ protected function addCrossFKInit(&$script, CrossForeignKeys $crossFKs) { @@ -5073,6 +5123,7 @@ public function init$relCol() * Adds the method that check if the referrer fkey collection is initialized. * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs +* @return void */ protected function addCrossFKIsLoaded(&$script, CrossForeignKeys $crossFKs) { @@ -5396,6 +5447,7 @@ public function get{$relatedName}(Criteria \$criteria = null, ConnectionInterfac /** * @param string $script * @param CrossForeignKeys $crossFKs +* @return void */ protected function addCrossFKSet(&$script, CrossForeignKeys $crossFKs) { @@ -5575,6 +5627,7 @@ public function count{$firstFkName}($signature, Criteria \$criteria = null, Conn * Adds the method that adds an object into the referrer fkey collection. * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs +* @return void */ protected function addCrossFKAdd(&$script, CrossForeignKeys $crossFKs) { @@ -5645,6 +5698,7 @@ protected function getCrossFKGetterSignature(CrossForeignKeys $crossFKs, $exclud /** * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs +* @return void */ protected function addCrossFKDoAdd(&$script, CrossForeignKeys $crossFKs) { @@ -5769,6 +5823,7 @@ protected function getCrossRefFKRemoveObjectNames(CrossForeignKeys $crossFKs, Fo * Adds the method that remove an object from the referrer fkey collection. * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs +* @return void */ protected function addCrossFKRemove(&$script, CrossForeignKeys $crossFKs) { @@ -6312,6 +6367,7 @@ protected function addSave(&$script) * Adds the comment for the save method * @param string $script The script will be modified in this method. * @see addSave() +* @return void */ protected function addSaveComment(&$script) { diff --git a/src/Propel/Generator/Builder/Om/QueryBuilder.php b/src/Propel/Generator/Builder/Om/QueryBuilder.php index de74338761..c5045e023b 100644 --- a/src/Propel/Generator/Builder/Om/QueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryBuilder.php @@ -228,6 +228,7 @@ abstract class ".$this->getUnqualifiedClassName()." extends " . $parentClass . " * if you want to change that behavior. * * @see ObjectBuilder::addClassBody() +* @return void */ protected function addClassBody(&$script) { @@ -302,6 +303,7 @@ protected function addClassBody(&$script) /** * Adds the entityNotFoundExceptionClass property which is necessary for the `requireOne` method * of the `ModelCriteria` +* @return void */ protected function addEntityNotFoundExceptionClass(&$script) { @@ -388,6 +390,7 @@ protected function addClassClose(&$script) * Adds the constructor for this object. * @param string $script The script will be modified in this method. * @see addConstructor() +* @return void */ protected function addConstructor(&$script) { @@ -950,6 +953,7 @@ public function filterByPrimaryKeys(\$keys) * Adds the filterByCol method for this object. * @param string $script The script will be modified in this method. * @param Column $col +* @return void */ protected function addFilterByCol(&$script, Column $col) { @@ -1171,6 +1175,7 @@ public function filterBy$colPhpName(\$$variableName = null, \$comparison = null) * Adds the singular filterByCol method for an Array column. * @param string $script The script will be modified in this method. * @param Column $col +* @return void */ protected function addFilterByArrayCol(&$script, Column $col) { @@ -1218,6 +1223,7 @@ public function filterBy$singularPhpName(\$$variableName = null, \$comparison = * * @param string $script The script will be modified in this method. * @param Column $col +* @return void */ protected function addFilterBySetCol(&$script, Column $col) { @@ -1244,6 +1250,7 @@ public function filterBy$singularPhpName(\$$variableName = null, \$comparison = * Adds the filterByFk method for this object. * @param string $script The script will be modified in this method. * @param ForeignKey $fk ForeignKey +* @return void */ protected function addFilterByFk(&$script, $fk) { @@ -1328,6 +1335,7 @@ public function filterBy$relationName($objectName, \$comparison = null) * * @param string $script The script will be modified in this method. * @param ForeignKey $fk +* @return void */ protected function addFilterByRefFk(&$script, ForeignKey $fk) { @@ -1399,6 +1407,7 @@ public function filterBy$relationName($objectName, \$comparison = null) * Adds the joinFk method for this object. * @param string $script The script will be modified in this method. * @param ForeignKey $fk ForeignKey +* @return void */ protected function addJoinFk(&$script, $fk) { @@ -1413,6 +1422,7 @@ protected function addJoinFk(&$script, $fk) * Adds the joinRefFk method for this object. * @param string $script The script will be modified in this method. * @param ForeignKey $fk +* @return void */ protected function addJoinRefFk(&$script, ForeignKey $fk) { @@ -1469,6 +1479,7 @@ public function join" . $relationName . "(\$relationAlias = null, \$joinType = " * Adds the useFkQuery method for this object. * @param string $script The script will be modified in this method. * @param ForeignKey $fk ForeignKey +* @return void */ protected function addUseFkQuery(&$script, $fk) { @@ -1485,6 +1496,7 @@ protected function addUseFkQuery(&$script, $fk) * Adds the useFkQuery method for this object. * @param string $script The script will be modified in this method. * @param ForeignKey $fk +* @return void */ protected function addUseRefFkQuery(&$script, ForeignKey $fk) { diff --git a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php index 217263603d..fae26334cc 100644 --- a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php @@ -69,6 +69,7 @@ public function getNamespace() * Sets the child object that we're operating on currently. * * @param Inheritance $child +* @return void */ public function setChild(Inheritance $child) { @@ -164,6 +165,7 @@ class " .$this->getUnqualifiedClassName() . " extends " . $baseClassName . " * * @param string $script * @see ObjectBuilder::addClassBody() +* @return void */ protected function addClassBody(&$script) { diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index 0cdc04a391..c5694148cd 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -781,6 +781,7 @@ public function hasBehaviorModifier($hookName, $modifier = '') * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string $script The script will be modified in this method. * @param string $tab +* @return void */ public function applyBehaviorModifier($hookName, &$script, $tab = " ") { diff --git a/src/Propel/Generator/Builder/Util/PropelTemplate.php b/src/Propel/Generator/Builder/Util/PropelTemplate.php index eb93124d64..94264bfaca 100644 --- a/src/Propel/Generator/Builder/Util/PropelTemplate.php +++ b/src/Propel/Generator/Builder/Util/PropelTemplate.php @@ -38,6 +38,7 @@ class PropelTemplate * * * @param string $template the template string +* @return void */ public function setTemplate($template) { @@ -52,6 +53,7 @@ public function setTemplate($template) * * * @param string $filePath The (absolute or relative to the include path) file path +* @return void */ public function setTemplateFile($filePath) { diff --git a/src/Propel/Generator/Command/Console/Input/ArrayInput.php b/src/Propel/Generator/Command/Console/Input/ArrayInput.php index 4d38b99cd8..99b19e4b66 100644 --- a/src/Propel/Generator/Command/Console/Input/ArrayInput.php +++ b/src/Propel/Generator/Command/Console/Input/ArrayInput.php @@ -155,6 +155,7 @@ protected function parse() * Adds a short option value. * * @throws InvalidOptionException When option given doesn't exist +* @return void */ private function addShortOption(string $shortcut, $value) { @@ -170,6 +171,7 @@ private function addShortOption(string $shortcut, $value) * * @throws InvalidOptionException When option given doesn't exist * @throws InvalidOptionException When a required value is missing +* @return void */ private function addLongOption(string $name, $value) { @@ -199,6 +201,7 @@ private function addLongOption(string $name, $value) * @param mixed $value The value for the argument * * @throws InvalidArgumentException When argument given doesn't exist +* @return void */ private function addArgument($name, $value) { diff --git a/src/Propel/Generator/Manager/AbstractManager.php b/src/Propel/Generator/Manager/AbstractManager.php index 59a62488a9..6de0ffab67 100644 --- a/src/Propel/Generator/Manager/AbstractManager.php +++ b/src/Propel/Generator/Manager/AbstractManager.php @@ -118,6 +118,7 @@ public function getSchemas() * Sets the schemas list. * * @param array $schemas +* @return void */ public function setSchemas($schemas) { @@ -128,6 +129,7 @@ public function setSchemas($schemas) * Sets the working directory path. * * @param string $workingDirectory +* @return void */ public function setWorkingDirectory($workingDirectory) { @@ -216,6 +218,7 @@ public function getDatabase($name) * Sets whether to perform validation on the datamodel schema.xml file(s). * * @param boolean $validate +* @return void */ public function setValidate($validate) { @@ -227,6 +230,7 @@ public function setValidate($validate) * file(s). * * @param string $xsd +* @return void */ public function setXsd($xsd) { @@ -238,6 +242,7 @@ public function setXsd($xsd) * file(s) before validation and parsing. * * @param mixed $xsl +* @return void */ public function setXsl($xsl) { @@ -248,6 +253,7 @@ public function setXsl($xsl) * Sets the current target database encoding. * * @param string $encoding Target database encoding +* @return void */ public function setDbEncoding($encoding) { @@ -258,6 +264,7 @@ public function setDbEncoding($encoding) * Sets a logger closure. * * @param \Closure $logger +* @return void */ public function setLoggerClosure(\Closure $logger) { @@ -267,6 +274,7 @@ public function setLoggerClosure(\Closure $logger) /** * Returns all matching XML schema files and loads them into data models for * class. +* @return void */ protected function loadDataModels() { @@ -423,6 +431,7 @@ protected function getGeneratorConfig() * Sets the GeneratorConfigInterface implementation. * * @param GeneratorConfigInterface $generatorConfig +* @return void */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) { diff --git a/src/Propel/Generator/Manager/MigrationManager.php b/src/Propel/Generator/Manager/MigrationManager.php index d573897d6e..330897a82a 100644 --- a/src/Propel/Generator/Manager/MigrationManager.php +++ b/src/Propel/Generator/Manager/MigrationManager.php @@ -46,6 +46,7 @@ class MigrationManager extends AbstractManager * Set the database connection settings * * @param array $connections +* @return void */ public function setConnections($connections) { @@ -111,6 +112,7 @@ public function getPlatform($datasource) * Set the migration table name * * @param string $migrationTable +* @return void */ public function setMigrationTable($migrationTable) { diff --git a/src/Propel/Generator/Manager/ModelManager.php b/src/Propel/Generator/Manager/ModelManager.php index 9bedecb551..add594121d 100644 --- a/src/Propel/Generator/Manager/ModelManager.php +++ b/src/Propel/Generator/Manager/ModelManager.php @@ -31,6 +31,7 @@ class ModelManager extends AbstractManager * Sets the filesystem object. * * @param Filesystem $filesystem +* @return void */ public function setFilesystem(Filesystem $filesystem) { diff --git a/src/Propel/Generator/Manager/ReverseManager.php b/src/Propel/Generator/Manager/ReverseManager.php index 0ed63ac61b..9e8826a93a 100644 --- a/src/Propel/Generator/Manager/ReverseManager.php +++ b/src/Propel/Generator/Manager/ReverseManager.php @@ -88,6 +88,7 @@ public function getSchemaName() * Sets the name of a database schema to use (optional). * * @param string $schemaName +* @return void */ public function setSchemaName($schemaName) { @@ -108,6 +109,7 @@ public function getNamespace() * Sets the php namespace to use (optional). * * @param string $namespace +* @return void */ public function setNamespace($namespace) { @@ -130,6 +132,7 @@ public function getDatabaseName() * schema.xml * * @param string $databaseName +* @return void */ public function setDatabaseName($databaseName) { @@ -140,6 +143,7 @@ public function setDatabaseName($databaseName) * Sets whether to use the column name as phpName without any translation. * * @param boolean $samePhpName +* @return void */ public function setSamePhpName($samePhpName) { @@ -150,6 +154,7 @@ public function setSamePhpName($samePhpName) * Sets whether to add vendor info to the schema. * * @param boolean $addVendorInfo +* @return void */ public function setAddVendorInfo($addVendorInfo) { diff --git a/src/Propel/Generator/Manager/SqlManager.php b/src/Propel/Generator/Manager/SqlManager.php index 110d6fff12..a465586cf9 100644 --- a/src/Propel/Generator/Manager/SqlManager.php +++ b/src/Propel/Generator/Manager/SqlManager.php @@ -37,6 +37,7 @@ class SqlManager extends AbstractManager * Set the database connection settings * * @param array $connections +* @return void */ public function setConnections($connections) { @@ -73,6 +74,7 @@ public function isOverwriteSqlMap() /** * @param boolean $overwriteSqlMap +* @return void */ public function setOverwriteSqlMap($overwriteSqlMap) { @@ -105,6 +107,7 @@ public function getSqlDbMapFilename() /** * Build SQL files. +* @return void */ public function buildSql() { diff --git a/src/Propel/Generator/Model/Behavior.php b/src/Propel/Generator/Model/Behavior.php index 62c3b28c88..6b14307748 100644 --- a/src/Propel/Generator/Model/Behavior.php +++ b/src/Propel/Generator/Model/Behavior.php @@ -92,6 +92,7 @@ class Behavior extends MappingModel * Sets the name of the Behavior * * @param string $name the name of the behavior +* @return void */ public function setName($name) { @@ -106,6 +107,7 @@ public function setName($name) * Sets the id of the Behavior * * @param string $id The id of the behavior +* @return void */ public function setId($id) { @@ -147,6 +149,7 @@ public function getName() * Sets the table this behavior is applied to * * @param \Propel\Generator\Model\Table $table +* @return void */ public function setTable(Table $table) { @@ -167,6 +170,7 @@ public function getTable() * Sets the database this behavior is applied to * * @param Database $database +* @return void */ public function setDatabase(Database $database) { @@ -205,6 +209,7 @@ public function addParameter(array $parameter) * Expects an associative array looking like [ 'foo' => 'bar' ]. * * @param array $parameters +* @return void */ public function setParameters(array $parameters) { @@ -240,6 +245,7 @@ public function getParameter($name) * Default is 50. * * @param integer $tableModificationOrder +* @return void */ public function setTableModificationOrder($tableModificationOrder) { @@ -266,6 +272,7 @@ public function getTableModificationOrder() * * Propagates the behavior to the tables of the database and override this * method to have a database behavior do something special. +* @return void */ public function modifyDatabase() { @@ -304,6 +311,7 @@ public function modifyTable() * Sets whether or not the table has been modified. * * @param boolean $modified +* @return void */ public function setTableModified($modified) { diff --git a/src/Propel/Generator/Model/Column.php b/src/Propel/Generator/Model/Column.php index 4b5e025e47..c8efd5d9ca 100644 --- a/src/Propel/Generator/Model/Column.php +++ b/src/Propel/Generator/Model/Column.php @@ -234,6 +234,7 @@ public function getTypeHint() /** * @param string|null $typeHint +* @return void */ public function setTypeHint($typeHint) { @@ -419,6 +420,7 @@ public function getDomain() * Sets the domain for this column. * * @param Domain $domain +* @return void */ public function setDomain(Domain $domain) { @@ -469,6 +471,7 @@ public function getUppercasedName() * Sets the column name. * * @param string $name +* @return void */ public function setName($name) { @@ -510,6 +513,7 @@ public function getDescription() * Sets the column description. * * @param string $description +* @return void */ public function setDescription($description) { @@ -554,6 +558,7 @@ public function getPhpSingularName() * $phpName is passed. * * @param string $phpName +* @return void */ public function setPhpName($phpName = null) { @@ -572,6 +577,7 @@ public function setPhpName($phpName = null) * $phpSingularName is passed. * * @param string $phpSingularName +* @return void */ public function setPhpSingularName($phpSingularName = null) { @@ -612,6 +618,7 @@ public function getAccessorVisibility() * Sets the accessor methods visibility for this column / attribute. * * @param string $visibility +* @return void */ public function setAccessorVisibility($visibility) { @@ -641,6 +648,7 @@ public function getMutatorVisibility() * Sets the mutator methods visibility for this column / attribute. * * @param string $visibility +* @return void */ public function setMutatorVisibility($visibility) { @@ -694,6 +702,7 @@ public function getTableMapName() * Sets the TableMap constant name that will identify this column. * * @param string $name +* @return void */ public function setTableMapName($name) { @@ -726,6 +735,7 @@ public function getPosition() * Returns the location of this column within the table (one-based). * * @param integer $position +* @return void */ public function setPosition($position) { @@ -736,6 +746,7 @@ public function setPosition($position) * Sets the parent table. * * @param \Propel\Generator\Model\Table $table +* @return void */ public function setTable(Table $table) { @@ -854,6 +865,7 @@ public function isNotNull() * Sets whether or not the column is not null. * * @param boolean $flag +* @return void */ public function setNotNull($flag = true) { @@ -877,6 +889,7 @@ public function getNotNullString() * __toString method of an active record object. * * @param boolean $isPrimaryString +* @return void */ public function setPrimaryString($isPrimaryString) { @@ -898,6 +911,7 @@ public function isPrimaryString() * Sets whether or not the column is a primary key. * * @param boolean $flag +* @return void */ public function setPrimaryKey($flag = true) { @@ -918,6 +932,7 @@ public function isPrimaryKey() * Sets whether or not the column is a node key of a tree. * * @param boolean $isNodeKey +* @return void */ public function setNodeKey($isNodeKey) { @@ -938,6 +953,7 @@ public function isNodeKey() * Sets the separator for the node key column in a tree. * * @param string $sep +* @return void */ public function setNodeKeySep($sep) { @@ -958,6 +974,7 @@ public function getNodeKeySep() * Sets whether or not the column is the nested set left key of a tree. * * @param boolean $isNestedSetLeftKey +* @return void */ public function setNestedSetLeftKey($isNestedSetLeftKey) { @@ -978,6 +995,7 @@ public function isNestedSetLeftKey() * Set if the column is the nested set right key of a tree. * * @param boolean $isNestedSetRightKey +* @return void */ public function setNestedSetRightKey($isNestedSetRightKey) { @@ -998,6 +1016,7 @@ public function isNestedSetRightKey() * Sets whether or not the column is the scope key of a tree. * * @param boolean $isTreeScopeKey +* @return void */ public function setTreeScopeKey($isTreeScopeKey) { @@ -1070,6 +1089,7 @@ public function getForeignKeys() * Adds the foreign key from another table that refers to this column. * * @param ForeignKey $fk +* @return void */ public function addReferrer(ForeignKey $fk) { @@ -1111,6 +1131,7 @@ public function hasReferrer(ForeignKey $fk) /** * Clears all referrers. * +* @return void */ public function clearReferrers() { @@ -1120,6 +1141,7 @@ public function clearReferrers() /** * Clears all inheritance children. * +* @return void */ public function clearInheritanceList() { @@ -1133,6 +1155,7 @@ public function clearInheritanceList() * size, scale (or other domain attributes). * * @param string $mappingType +* @return void */ public function setDomainForType($mappingType) { @@ -1144,6 +1167,7 @@ public function setDomainForType($mappingType) * * @param string $mappingType * @see Domain::setType() +* @return void */ public function setType($mappingType) { @@ -1287,6 +1311,7 @@ public function isSetType() * Sets the list of possible values for an ENUM or SET column. * * @param string|string[] $valueSet +* @return void */ public function setValueSet($valueSet) { @@ -1322,6 +1347,7 @@ public function getSize() * Sets the column size. * * @param integer|null $size +* @return void */ public function setSize($size) { @@ -1342,6 +1368,7 @@ public function getScale() * Sets the column scale. * * @param integer $scale +* @return void */ public function setScale($scale) { @@ -1488,6 +1515,7 @@ public function getAutoIncrementString() * Use isAutoIncrement() to find out if it is set or not. * * @param boolean $flag +* @return void */ public function setAutoIncrement($flag = true) { @@ -1568,6 +1596,7 @@ public function hasPlatform() /** * Clones the current object. * +* @return void */ public function __clone() { diff --git a/src/Propel/Generator/Model/ColumnDefaultValue.php b/src/Propel/Generator/Model/ColumnDefaultValue.php index f463b864a3..12a14d409c 100644 --- a/src/Propel/Generator/Model/ColumnDefaultValue.php +++ b/src/Propel/Generator/Model/ColumnDefaultValue.php @@ -56,6 +56,7 @@ public function getType() /** * @param string $type The type of default value (DefaultValue::TYPE_VALUE or DefaultValue::TYPE_EXPR) +* @return void */ public function setType($type) { @@ -82,6 +83,7 @@ public function getValue() /** * @param string|null $value The value, as specified in the schema. +* @return void */ public function setValue($value) { diff --git a/src/Propel/Generator/Model/CrossForeignKeys.php b/src/Propel/Generator/Model/CrossForeignKeys.php index 4364d60086..e3fb75aa23 100644 --- a/src/Propel/Generator/Model/CrossForeignKeys.php +++ b/src/Propel/Generator/Model/CrossForeignKeys.php @@ -84,6 +84,7 @@ public function __construct(ForeignKey $foreignKey, Table $crossTable) /** * @param ForeignKey|null $foreignKey +* @return void */ public function setIncomingForeignKey($foreignKey) { @@ -199,6 +200,7 @@ public function hasCrossForeignKeys() /** * @param ForeignKey[] $foreignKeys +* @return void */ public function setCrossForeignKeys(array $foreignKeys) { @@ -217,6 +219,7 @@ public function getCrossForeignKeys() /** * @param \Propel\Generator\Model\Table $foreignTable +* @return void */ public function setMiddleTable(Table $foreignTable) { @@ -235,6 +238,7 @@ public function getMiddleTable() /** * @param \Propel\Generator\Model\Table $table +* @return void */ public function setTable(Table $table) { diff --git a/src/Propel/Generator/Model/Database.php b/src/Propel/Generator/Model/Database.php index b155084b88..feb2372226 100644 --- a/src/Propel/Generator/Model/Database.php +++ b/src/Propel/Generator/Model/Database.php @@ -192,6 +192,7 @@ public function getPlatform() * Sets the PlatformInterface implementation for this database. * * @param PlatformInterface|null $platform A Platform implementation +* @return void */ public function setPlatform(PlatformInterface $platform = null) { @@ -222,6 +223,7 @@ public function getName() * Sets the database name. * * @param string $name +* @return void */ public function setName($name) { @@ -255,6 +257,7 @@ public function getBaseQueryClass() * This parameter is overridden at the table level. * * @param string $class. +* @return void */ public function setBaseClass($class) { @@ -266,6 +269,7 @@ public function setBaseClass($class) * This parameter is overridden at the table level. * * @param string $class. +* @return void */ public function setBaseQueryClass($class) { @@ -288,6 +292,7 @@ public function getDefaultIdMethod() * This parameter can be overridden at the table level. * * @param string $strategy +* @return void */ public function setDefaultIdMethod($strategy) { @@ -310,6 +315,7 @@ public function getDefaultPhpNamingMethod() * Sets name of the default PHP naming method strategy. * * @param string $strategy +* @return void */ public function setDefaultPhpNamingMethod($strategy) { @@ -334,6 +340,7 @@ public static function getSupportedStringFormats() * * @param string $format * @throws InvalidArgumentException +* @return void */ public function setDefaultStringFormat($format) { @@ -386,6 +393,7 @@ public function getHeavyIndexing() * Sets whether or not heavy indexing is enabled. * * @param boolean $flag +* @return void */ public function setHeavyIndexing($flag = true) { @@ -577,6 +585,7 @@ public function addTable($table) /** * @param string[] $sequences +* @return void */ public function setSequences($sequences) { @@ -602,6 +611,7 @@ public function addSequence($sequence) /** * @param string $sequence +* @return void */ public function removeSequence($sequence) { @@ -638,6 +648,7 @@ public function getSchemaDelimiter() * Sets the database's schema. * * @param string $schema +* @return void */ public function setSchema($schema) { @@ -698,6 +709,7 @@ private function computeTableNamespace(Table $table) * Sets the parent schema * * @param Schema $parent The parent schema +* @return void */ public function setParentSchema(Schema $parent) { @@ -798,6 +810,7 @@ public function getTablePrefix() * Sets the tables' prefix. * * @param string $tablePrefix +* @return void */ public function setTablePrefix($tablePrefix) { @@ -833,6 +846,7 @@ public function getNextTableBehavior() /** * Finalizes the setup process. * +* @return void */ public function doFinalInitialization() { @@ -962,6 +976,7 @@ public function __toString() * Sets the default accessor visibility. * * @param string $defaultAccessorVisibility +* @return void */ public function setDefaultAccessorVisibility($defaultAccessorVisibility) { @@ -982,6 +997,7 @@ public function getDefaultAccessorVisibility() * Sets the default mutator visibility. * * @param string $defaultMutatorVisibility +* @return void */ public function setDefaultMutatorVisibility($defaultMutatorVisibility) { @@ -1024,6 +1040,7 @@ public function isIdentifierQuotingEnabled() /** * @param boolean $identifierQuoting +* @return void */ public function setIdentifierQuoting($identifierQuoting) { diff --git a/src/Propel/Generator/Model/Diff/ColumnDiff.php b/src/Propel/Generator/Model/Diff/ColumnDiff.php index f4f09ff930..d49e053a85 100644 --- a/src/Propel/Generator/Model/Diff/ColumnDiff.php +++ b/src/Propel/Generator/Model/Diff/ColumnDiff.php @@ -61,6 +61,7 @@ public function __construct(Column $fromColumn = null, Column $toColumn = null) * Sets for the changed properties. * * @param array $properties +* @return void */ public function setChangedProperties($properties) { @@ -81,6 +82,7 @@ public function getChangedProperties() * Sets the fromColumn property. * * @param Column $fromColumn +* @return void */ public function setFromColumn(Column $fromColumn) { @@ -101,6 +103,7 @@ public function getFromColumn() * Sets the toColumn property. * * @param Column $toColumn +* @return void */ public function setToColumn(Column $toColumn) { diff --git a/src/Propel/Generator/Model/Diff/DatabaseComparator.php b/src/Propel/Generator/Model/Diff/DatabaseComparator.php index e829b8c238..eaaa2c9b08 100644 --- a/src/Propel/Generator/Model/Diff/DatabaseComparator.php +++ b/src/Propel/Generator/Model/Diff/DatabaseComparator.php @@ -73,6 +73,7 @@ public function getDatabaseDiff() * Sets the fromDatabase property. * * @param Database $fromDatabase +* @return void */ public function setFromDatabase(Database $fromDatabase) { @@ -93,6 +94,7 @@ public function getFromDatabase() * Sets the toDatabase property. * * @param Database $toDatabase +* @return void */ public function setToDatabase(Database $toDatabase) { @@ -113,6 +115,7 @@ public function getToDatabase() * Set true to handle removed tables or false to ignore them * * @param boolean $removeTable +* @return void */ public function setRemoveTable($removeTable) { @@ -131,6 +134,7 @@ public function getRemoveTable() * Set the list of tables excluded from the comparison * * @param string[] $excludedTables set the list of table name +* @return void */ public function setExcludedTables(array $excludedTables) { @@ -183,6 +187,7 @@ public static function computeDiff(Database $fromDatabase, Database $toDatabase, /** * @param boolean $withRenaming +* @return void */ public function setWithRenaming($withRenaming) { diff --git a/src/Propel/Generator/Model/Diff/DatabaseDiff.php b/src/Propel/Generator/Model/Diff/DatabaseDiff.php index aab645f5ce..f1f66d6388 100644 --- a/src/Propel/Generator/Model/Diff/DatabaseDiff.php +++ b/src/Propel/Generator/Model/Diff/DatabaseDiff.php @@ -54,6 +54,7 @@ public function __construct() * Sets the added tables. * * @param array $tables +* @return void */ public function setAddedTables($tables) { @@ -65,6 +66,7 @@ public function setAddedTables($tables) * * @param string $name * @param Table $table +* @return void */ public function addAddedTable($name, Table $table) { @@ -75,6 +77,7 @@ public function addAddedTable($name, Table $table) * Removes an added table. * * @param string $name +* @return void */ public function removeAddedTable($name) { @@ -94,6 +97,7 @@ public function getPossibleRenamedTables() * * @param string $fromName * @param string $toName +* @return void */ public function addPossibleRenamedTable($fromName, $toName) { @@ -136,6 +140,7 @@ public function getAddedTable($name) * Sets the removes tables. * * @param \Propel\Generator\Model\Table[] $tables +* @return void */ public function setRemovedTables($tables) { @@ -147,6 +152,7 @@ public function setRemovedTables($tables) * * @param string $name * @param Table $table +* @return void */ public function addRemovedTable($name, Table $table) { @@ -157,6 +163,7 @@ public function addRemovedTable($name, Table $table) * Removes a removed table. * * @param string $name +* @return void */ public function removeRemovedTable($name) { @@ -199,6 +206,7 @@ public function getRemovedTable($name) * Sets the modified tables * * @param \Propel\Generator\Model\Diff\TableDiff[] $tables +* @return void */ public function setModifiedTables($tables) { @@ -210,6 +218,7 @@ public function setModifiedTables($tables) * * @param string $name * @param TableDiff $difference +* @return void */ public function addModifiedTable($name, TableDiff $difference) { @@ -240,6 +249,7 @@ public function getModifiedTables() * Sets the renamed tables. * * @param string[] $tables +* @return void */ public function setRenamedTables($tables) { @@ -251,6 +261,7 @@ public function setRenamedTables($tables) * * @param string $fromName * @param string $toName +* @return void */ public function addRenamedTable($fromName, $toName) { diff --git a/src/Propel/Generator/Model/Diff/TableComparator.php b/src/Propel/Generator/Model/Diff/TableComparator.php index f8d32a4d2f..d9e359dae5 100644 --- a/src/Propel/Generator/Model/Diff/TableComparator.php +++ b/src/Propel/Generator/Model/Diff/TableComparator.php @@ -50,6 +50,7 @@ public function getTableDiff() * Sets the table the comparator starts from. * * @param \Propel\Generator\Model\Table $fromTable +* @return void */ public function setFromTable(Table $fromTable) { @@ -70,6 +71,7 @@ public function getFromTable() * Sets the table the comparator goes to. * * @param \Propel\Generator\Model\Table $toTable +* @return void */ public function setToTable(Table $toTable) { diff --git a/src/Propel/Generator/Model/Diff/TableDiff.php b/src/Propel/Generator/Model/Diff/TableDiff.php index 087ba30a4d..061ef32256 100644 --- a/src/Propel/Generator/Model/Diff/TableDiff.php +++ b/src/Propel/Generator/Model/Diff/TableDiff.php @@ -163,6 +163,7 @@ public function __construct(Table $fromTable = null, Table $toTable = null) * Sets the fromTable property. * * @param \Propel\Generator\Model\Table $fromTable +* @return void */ public function setFromTable(Table $fromTable) { @@ -183,6 +184,7 @@ public function getFromTable() * Sets the toTable property. * * @param \Propel\Generator\Model\Table $toTable +* @return void */ public function setToTable(Table $toTable) { @@ -203,6 +205,7 @@ public function getToTable() * Sets the added columns. * * @param Column[] $columns +* @return void */ public function setAddedColumns(array $columns) { @@ -217,6 +220,7 @@ public function setAddedColumns(array $columns) * * @param string $name * @param Column $column +* @return void */ public function addAddedColumn($name, Column $column) { @@ -227,6 +231,7 @@ public function addAddedColumn($name, Column $column) * Removes an added column. * * @param string $columnName +* @return void */ public function removeAddedColumn($columnName) { @@ -264,6 +269,7 @@ public function getAddedColumn($columnName) * Setter for the removedColumns property * * @param Column[] $removedColumns +* @return void */ public function setRemovedColumns(array $removedColumns) { @@ -278,6 +284,7 @@ public function setRemovedColumns(array $removedColumns) * * @param string $columnName * @param Column $removedColumn +* @return void */ public function addRemovedColumn($columnName, Column $removedColumn) { @@ -288,6 +295,7 @@ public function addRemovedColumn($columnName, Column $removedColumn) * Removes a removed column. * * @param string $columnName +* @return void */ public function removeRemovedColumn($columnName) { @@ -324,6 +332,7 @@ public function getRemovedColumn($columnName) * Sets the list of modified columns. * * @param ColumnDiff[] $modifiedColumns An associative array of ColumnDiff objects +* @return void */ public function setModifiedColumns(array $modifiedColumns) { @@ -338,6 +347,7 @@ public function setModifiedColumns(array $modifiedColumns) * * @param string $columnName * @param ColumnDiff $modifiedColumn +* @return void */ public function addModifiedColumn($columnName, ColumnDiff $modifiedColumn) { @@ -358,6 +368,7 @@ public function getModifiedColumns() * Sets the list of renamed columns. * * @param array $renamedColumns +* @return void */ public function setRenamedColumns(array $renamedColumns) { @@ -373,6 +384,7 @@ public function setRenamedColumns(array $renamedColumns) * * @param Column $fromColumn * @param Column $toColumn +* @return void */ public function addRenamedColumn(Column $fromColumn, Column $toColumn) { @@ -393,6 +405,7 @@ public function getRenamedColumns() * Sets the list of added primary key columns. * * @param Column[] $addedPkColumns +* @return void */ public function setAddedPkColumns(array $addedPkColumns) { @@ -407,6 +420,7 @@ public function setAddedPkColumns(array $addedPkColumns) * * @param string $columnName * @param Column $addedPkColumn +* @return void */ public function addAddedPkColumn($columnName, Column $addedPkColumn) { @@ -421,6 +435,7 @@ public function addAddedPkColumn($columnName, Column $addedPkColumn) * Removes an added primary key column. * * @param string $columnName +* @return void */ public function removeAddedPkColumn($columnName) { @@ -443,6 +458,7 @@ public function getAddedPkColumns() * Sets the list of removed primary key columns. * * @param Column[] $removedPkColumns +* @return void */ public function setRemovedPkColumns(array $removedPkColumns) { @@ -457,6 +473,7 @@ public function setRemovedPkColumns(array $removedPkColumns) * * @param string $columnName * @param Column $removedPkColumn +* @return void */ public function addRemovedPkColumn($columnName, Column $removedPkColumn) { @@ -467,6 +484,7 @@ public function addRemovedPkColumn($columnName, Column $removedPkColumn) * Removes a removed primary key column. * * @param string $columnName +* @return void */ public function removeRemovedPkColumn($columnName) { @@ -489,6 +507,7 @@ public function getRemovedPkColumns() * Sets the list of all renamed primary key columns. * * @param Column[][] $renamedPkColumns +* @return void */ public function setRenamedPkColumns(array $renamedPkColumns) { @@ -504,6 +523,7 @@ public function setRenamedPkColumns(array $renamedPkColumns) * * @param Column $fromColumn The original column * @param Column $toColumn The renamed column +* @return void */ public function addRenamedPkColumn(Column $fromColumn, Column $toColumn) { @@ -534,6 +554,7 @@ public function hasModifiedPk() * Sets the list of new added indices. * * @param Index[] $addedIndices +* @return void */ public function setAddedIndices(array $addedIndices) { @@ -548,6 +569,7 @@ public function setAddedIndices(array $addedIndices) * * @param string $indexName * @param Index $addedIndex +* @return void */ public function addAddedIndex($indexName, Index $addedIndex) { @@ -568,6 +590,7 @@ public function getAddedIndices() * Sets the list of removed indices. * * @param Index[] $removedIndices +* @return void */ public function setRemovedIndices(array $removedIndices) { @@ -582,6 +605,7 @@ public function setRemovedIndices(array $removedIndices) * * @param string $indexName * @param Index $removedIndex +* @return void */ public function addRemovedIndex($indexName, Index $removedIndex) { @@ -604,6 +628,7 @@ public function getRemovedIndices() * Array must be [ [ Index $fromIndex, Index $toIndex ], [ ... ] ] * * @param Index[][] $modifiedIndices An aray of modified indices +* @return void */ public function setModifiedIndices(array $modifiedIndices) { @@ -620,6 +645,7 @@ public function setModifiedIndices(array $modifiedIndices) * @param string $indexName * @param Index $fromIndex * @param Index $toIndex +* @return void */ public function addModifiedIndex($indexName, Index $fromIndex, Index $toIndex) { @@ -640,6 +666,7 @@ public function getModifiedIndices() * Sets the list of added foreign keys. * * @param ForeignKey[] $addedFks +* @return void */ public function setAddedFks(array $addedFks) { @@ -654,6 +681,7 @@ public function setAddedFks(array $addedFks) * * @param string $fkName * @param ForeignKey $addedFk +* @return void */ public function addAddedFk($fkName, ForeignKey $addedFk) { @@ -664,6 +692,7 @@ public function addAddedFk($fkName, ForeignKey $addedFk) * Remove an added Fk column * * @param string $fkName +* @return void */ public function removeAddedFk($fkName) { @@ -686,6 +715,7 @@ public function getAddedFks() * Sets the list of removed foreign keys. * * @param ForeignKey[] $removedFks +* @return void */ public function setRemovedFks(array $removedFks) { @@ -700,6 +730,7 @@ public function setRemovedFks(array $removedFks) * * @param string $fkName * @param ForeignKey $removedFk +* @return void */ public function addRemovedFk($fkName, ForeignKey $removedFk) { @@ -710,6 +741,7 @@ public function addRemovedFk($fkName, ForeignKey $removedFk) * Removes a removed foreign key. * * @param string $fkName +* @return void */ public function removeRemovedFk($fkName) { @@ -732,6 +764,7 @@ public function getRemovedFks() * Array must be [ [ ForeignKey $fromFk, ForeignKey $toFk ], [ ... ] ] * * @param ForeignKey[][] $modifiedFks +* @return void */ public function setModifiedFks(array $modifiedFks) { @@ -748,6 +781,7 @@ public function setModifiedFks(array $modifiedFks) * @param string $fkName * @param ForeignKey $fromFk * @param ForeignKey $toFk +* @return void */ public function addModifiedFk($fkName, ForeignKey $fromFk, ForeignKey $toFk) { diff --git a/src/Propel/Generator/Model/Domain.php b/src/Propel/Generator/Model/Domain.php index 0dff16ceff..ea95f206d4 100644 --- a/src/Propel/Generator/Model/Domain.php +++ b/src/Propel/Generator/Model/Domain.php @@ -64,6 +64,7 @@ public function __construct($type = null, $sqlType = null, $size = null, $scale * Copies the values from current object into passed-in Domain. * * @param Domain $domain Domain to copy values into. +* @return void */ public function copy(Domain $domain) { @@ -104,6 +105,7 @@ protected function setupObject() * Sets the owning database object (if this domain is being setup via XML). * * @param Database $database +* @return void */ public function setDatabase(Database $database) { @@ -134,6 +136,7 @@ public function getDescription() * Sets the domain description. * * @param string $description +* @return void */ public function setDescription($description) { @@ -154,6 +157,7 @@ public function getName() * Sets the domain name. * * @param string $name +* @return void */ public function setName($name) { @@ -174,6 +178,7 @@ public function getScale() * Sets the scale value. * * @param integer $scale +* @return void */ public function setScale($scale) { @@ -184,6 +189,7 @@ public function setScale($scale) * Replaces the size if the new value is not null. * * @param integer $scale +* @return void */ public function replaceScale($scale) { @@ -206,6 +212,7 @@ public function getSize() * Sets the size. * * @param integer|null $size +* @return void */ public function setSize($size) { @@ -216,6 +223,7 @@ public function setSize($size) * Replaces the size if the new value is not null. * * @param integer|null $size +* @return void */ public function replaceSize($size) { @@ -238,6 +246,7 @@ public function getType() * Sets the mapping type. * * @param string $mappingType +* @return void */ public function setType($mappingType) { @@ -248,6 +257,7 @@ public function setType($mappingType) * Replaces the mapping type if the new value is not null. * * @param string $mappingType +* @return void */ public function replaceType($mappingType) { @@ -299,6 +309,7 @@ public function getPhpDefaultValue() * Sets the default value. * * @param ColumnDefaultValue $value +* @return void */ public function setDefaultValue(ColumnDefaultValue $value) { @@ -309,6 +320,7 @@ public function setDefaultValue(ColumnDefaultValue $value) * Replaces the default value if the new value is not null. * * @param ColumnDefaultValue $value +* @return void */ public function replaceDefaultValue(ColumnDefaultValue $value = null) { @@ -331,6 +343,7 @@ public function getSqlType() * Sets the SQL type. * * @param string $sqlType +* @return void */ public function setSqlType($sqlType) { @@ -341,6 +354,7 @@ public function setSqlType($sqlType) * Replaces the SQL type if the new value is not null. * * @param string|null $sqlType +* @return void */ public function replaceSqlType($sqlType) { @@ -380,6 +394,7 @@ public function __clone() /** * @todo Remove? This method is never called. * @param \DOMNode $node +* @return void */ public function appendXml(\DOMNode $node) { diff --git a/src/Propel/Generator/Model/ForeignKey.php b/src/Propel/Generator/Model/ForeignKey.php index 4871b2d7ed..8ecaebf28d 100644 --- a/src/Propel/Generator/Model/ForeignKey.php +++ b/src/Propel/Generator/Model/ForeignKey.php @@ -247,6 +247,7 @@ public function getOnDelete() * Sets the onDelete behavior. * * @param string $behavior +* @return void */ public function setOnDelete($behavior) { @@ -257,6 +258,7 @@ public function setOnDelete($behavior) * Sets the onUpdate behavior. * * @param string|null $behavior +* @return void */ public function setOnUpdate($behavior) { @@ -279,6 +281,7 @@ public function getName() * Sets the foreign key name. * * @param string $name +* @return void */ public function setName($name) { @@ -296,6 +299,7 @@ public function getInterface() /** * @param string $interface +* @return void */ public function setInterface($interface) { @@ -316,6 +320,7 @@ public function getPhpName() * Sets a phpName to use for this foreign key. * * @param string $name +* @return void */ public function setPhpName($name) { @@ -336,6 +341,7 @@ public function getRefPhpName() * Sets a refPhpName to use for this foreign key. * * @param string $name +* @return void */ public function setRefPhpName($name) { @@ -356,6 +362,7 @@ public function getDefaultJoin() * Sets the default join strategy for this foreign key (if any). * * @param string $join +* @return void */ public function setDefaultJoin($join) { @@ -422,6 +429,7 @@ public function getForeignTableCommonName() * Sets the foreign table common name of the FK. * * @param string $tableName +* @return void */ public function setForeignTableCommonName($tableName) { @@ -457,6 +465,7 @@ public function getForeignSchemaName() * Set the foreign schema name of the foreign key. * * @param string $schemaName +* @return void */ public function setForeignSchemaName($schemaName) { @@ -467,6 +476,7 @@ public function setForeignSchemaName($schemaName) * Sets the parent Table of the foreign key. * * @param \Propel\Generator\Model\Table $parent +* @return void */ public function setTable(Table $parent) { @@ -550,6 +560,7 @@ public function addReference($ref1, $ref2 = null) /** * Clears the references of this foreign key. * +* @return void */ public function clearReferences() { @@ -893,6 +904,7 @@ public function isLocalPrimaryKey() * generated. * * @param boolean $skip +* @return void */ public function setSkipSql($skip) { diff --git a/src/Propel/Generator/Model/IdMethodParameter.php b/src/Propel/Generator/Model/IdMethodParameter.php index 41c50d5edc..5cf26fc2e4 100644 --- a/src/Propel/Generator/Model/IdMethodParameter.php +++ b/src/Propel/Generator/Model/IdMethodParameter.php @@ -58,6 +58,7 @@ public function getName() * Sets the parameter name. * * @param string $name +* @return void */ public function setName($name) { @@ -78,6 +79,7 @@ public function getValue() * Sets the parameter value. * * @param mixed $value +* @return void */ public function setValue($value) { @@ -88,6 +90,7 @@ public function setValue($value) * Sets the parent table. * * @param \Propel\Generator\Model\Table $parent +* @return void */ public function setTable(Table $parent) { diff --git a/src/Propel/Generator/Model/Index.php b/src/Propel/Generator/Model/Index.php index b3c5c1c33f..44cca9357c 100644 --- a/src/Propel/Generator/Model/Index.php +++ b/src/Propel/Generator/Model/Index.php @@ -77,6 +77,7 @@ public function isUnique() * Sets the index name. * * @param string $name +* @return void */ public function setName($name) { @@ -149,6 +150,7 @@ public function getFQName() * Sets the index parent Table. * * @param \Propel\Generator\Model\Table $table +* @return void */ public function setTable(Table $table) { @@ -214,6 +216,7 @@ public function hasColumn($name) * Sets an array of columns to use for the index. * * @param array $columns array of array definitions $columns[]['name'] = 'columnName' +* @return void */ public function setColumns(array $columns) { @@ -260,6 +263,7 @@ public function getColumnSize($name, $caseInsensitive = false) * Resets the columns sizes. * * This method is useful for generated indices for FKs. +* @return void */ public function resetColumnsSize() { @@ -338,6 +342,7 @@ public function getColumnObjects() /** * @param Column[] $columnObjects +* @return void */ public function setColumnObjects($columnObjects) { diff --git a/src/Propel/Generator/Model/Inheritance.php b/src/Propel/Generator/Model/Inheritance.php index e3dd5acdea..6dba232dec 100644 --- a/src/Propel/Generator/Model/Inheritance.php +++ b/src/Propel/Generator/Model/Inheritance.php @@ -65,6 +65,7 @@ public function getConstantSuffix() * Sets a key name. * * @param string $key +* @return void */ public function setKey($key) { @@ -75,6 +76,7 @@ public function setKey($key) * Sets the parent column * * @param Column $column +* @return void */ public function setColumn(Column $column) { @@ -105,6 +107,7 @@ public function getClassName() * Sets the class name. * * @param string $name +* @return void */ public function setClassName($name) { @@ -125,6 +128,7 @@ public function getPackage() * Sets the package. * * @param string $package +* @return void */ public function setPackage($package) { @@ -145,6 +149,7 @@ public function getAncestor() * Sets the ancestor. * * @param string $ancestor +* @return void */ public function setAncestor($ancestor) { diff --git a/src/Propel/Generator/Model/MappingModel.php b/src/Propel/Generator/Model/MappingModel.php index df0221e641..87c8a08739 100644 --- a/src/Propel/Generator/Model/MappingModel.php +++ b/src/Propel/Generator/Model/MappingModel.php @@ -37,6 +37,7 @@ abstract class MappingModel implements MappingModelInterface * Loads a mapping definition from an array. * * @param array $attributes +* @return void */ public function loadMapping(array $attributes) { diff --git a/src/Propel/Generator/Model/Schema.php b/src/Propel/Generator/Model/Schema.php index 0d5b56280c..d12dda45aa 100644 --- a/src/Propel/Generator/Model/Schema.php +++ b/src/Propel/Generator/Model/Schema.php @@ -58,6 +58,7 @@ public function __construct(PlatformInterface $platform = null) * application schema. * * @param PlatformInterface $platform +* @return void */ public function setPlatform(PlatformInterface $platform) { @@ -79,6 +80,7 @@ public function getPlatform() * Sets the generator configuration * * @param GeneratorConfigInterface $generatorConfig +* @return void */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) { @@ -99,6 +101,7 @@ public function getGeneratorConfig() * Sets the schema name. * * @param string $name +* @return void */ public function setName($name) { @@ -239,6 +242,7 @@ public function addDatabase($database) /** * Finalizes the databases initialization. * +* @return void */ public function doFinalInitialization() { @@ -254,6 +258,7 @@ public function doFinalInitialization() * Merge other Schema objects together into this Schema object. * * @param Schema[] $schemas +* @return void */ public function joinSchemas(array $schemas) { diff --git a/src/Propel/Generator/Model/ScopedMappingModel.php b/src/Propel/Generator/Model/ScopedMappingModel.php index b9e4f1bcec..a4b2f1315c 100644 --- a/src/Propel/Generator/Model/ScopedMappingModel.php +++ b/src/Propel/Generator/Model/ScopedMappingModel.php @@ -129,6 +129,7 @@ public function getPackage() * Sets the package name. * * @param string $package +* @return void */ public function setPackage($package) { @@ -154,6 +155,7 @@ public function getSchema() * Sets the schema name. * * @param string $schema +* @return void */ public function setSchema($schema) { diff --git a/src/Propel/Generator/Model/Table.php b/src/Propel/Generator/Model/Table.php index 6c839de901..1145e87c55 100644 --- a/src/Propel/Generator/Model/Table.php +++ b/src/Propel/Generator/Model/Table.php @@ -261,6 +261,7 @@ public function getBuildProperty($key) /** * Executes behavior table modifiers. * +* @return void */ public function applyBehaviors() { @@ -448,6 +449,7 @@ protected function createIndex($name, array $columns) * @param string $indexName The name of the index * @param array $columns The column names or objects * @param array $collectedIndexes The collected indexes +* @return void */ protected function collectIndexedColumns($indexName, $columns, &$collectedIndexes) { @@ -528,6 +530,7 @@ public function getBaseQueryClass() * Sets the base class name. * * @param string $class +* @return void */ public function setBaseClass($class) { @@ -538,6 +541,7 @@ public function setBaseClass($class) * Sets the base query class name. * * @param string $class +* @return void */ public function setBaseQueryClass($class) { @@ -589,6 +593,7 @@ public function addColumn($col) * Adds several columns at once. * * @param Column[] $columns An array of Column instance +* @return void */ public function addColumns(array $columns) { @@ -602,6 +607,7 @@ public function addColumns(array $columns) * * @param Column|string $column The Column or its name * @throws EngineException +* @return void */ public function removeColumn($column) { @@ -692,6 +698,7 @@ public function addForeignKey($foreignKey) * Adds several foreign keys at once. * * @param ForeignKey[] $foreignKeys An array of ForeignKey objects +* @return void */ public function addForeignKeys(array $foreignKeys) { @@ -735,6 +742,7 @@ public function getChildrenNames() * Adds the foreign key from another table that refers to this table. * * @param ForeignKey $fk +* @return void */ public function addReferrer(ForeignKey $fk) { @@ -759,6 +767,7 @@ public function getReferrers() * * @param boolean $throwErrors * @throws BuildException +* @return void */ public function setupReferrers($throwErrors = false) { @@ -959,6 +968,7 @@ public function addIdMethodParameter($idMethodParameter) * Removes a index from the table. * * @param string $name +* @return void */ public function removeIndex($name) { @@ -1171,6 +1181,7 @@ public function hasDescription() * Sets the table description. * * @param string $description +* @return void */ public function setDescription($description) { @@ -1196,6 +1207,7 @@ public function getPhpName() * Sets the name to use in PHP sources. * * @param string $phpName +* @return void */ public function setPhpName($phpName) { @@ -1239,6 +1251,7 @@ public function getCommonName() * Sets the table common name (without schema name). * * @param string $name +* @return void */ public function setCommonName($name) { @@ -1262,6 +1275,7 @@ public function getOriginCommonName() * * @param string $format * @throws InvalidArgumentException +* @return void */ public function setDefaultStringFormat($format) { @@ -1318,6 +1332,7 @@ public function isAllowPkInsert() * Sets the method strategy for generating primary keys. * * @param string $idMethod +* @return void */ public function setIdMethod($idMethod) { @@ -1339,6 +1354,7 @@ public function isSkipSql() * Sets whether or not this table should have its SQL DDL code generated. * * @param boolean $skip +* @return void */ public function setSkipSql($skip) { @@ -1360,6 +1376,7 @@ public function isReadOnly() * Makes this database in read-only mode. * * @param boolean $flag True by default +* @return void */ public function setReadOnly($flag = true) { @@ -1379,6 +1396,7 @@ public function isReloadOnInsert() * Makes this database reload on insert statement. * * @param boolean $flag True by default +* @return void */ public function setReloadOnInsert($flag = true) { @@ -1399,6 +1417,7 @@ public function isReloadOnUpdate() * Makes this database reload on update statement. * * @param boolean $flag True by default +* @return void */ public function setReloadOnUpdate($flag = true) { @@ -1431,6 +1450,7 @@ public function isAlias() * just a foreign key reference to it. * * @param string $alias +* @return void */ public function setAlias($alias) { @@ -1451,6 +1471,7 @@ public function getInterface() * Sets the interface objects of this table will implement. * * @param string $interface +* @return void */ public function setInterface($interface) { @@ -1477,6 +1498,7 @@ public function isAbstract() * declared abstract. This helps support class hierarchies * * @param boolean $flag +* @return void */ public function setAbstract($flag = true) { @@ -1773,6 +1795,7 @@ public function getColumnForeignKeys($column) * Set the database that contains this table. * * @param Database $database +* @return void */ public function setDatabase(Database $database) { @@ -1837,6 +1860,7 @@ public function isForReferenceOnly() * Table will be skipped, if set to true. * * @param boolean $flag +* @return void */ public function setForReferenceOnly($flag = true) { @@ -1968,6 +1992,7 @@ public function isCrossRef() * Sets a cross reference status for this foreign key. * * @param boolean $flag +* @return void */ public function setIsCrossRef($flag = true) { @@ -1978,6 +2003,7 @@ public function setIsCrossRef($flag = true) * Sets a cross reference status for this foreign key. * * @param boolean $flag +* @return void */ public function setCrossRef($flag = true) { @@ -2018,6 +2044,7 @@ public function getPhpNamingMethod() * Sets the PHP naming method. * * @param string $phpNamingMethod +* @return void */ public function setPhpNamingMethod($phpNamingMethod) { @@ -2028,6 +2055,7 @@ public function setPhpNamingMethod($phpNamingMethod) * Sets the default accessor visibility. * * @param string $defaultAccessorVisibility +* @return void */ public function setDefaultAccessorVisibility($defaultAccessorVisibility) { @@ -2048,6 +2076,7 @@ public function getDefaultAccessorVisibility() * Sets the default mutator visibility. * * @param string $defaultMutatorVisibility +* @return void */ public function setDefaultMutatorVisibility($defaultMutatorVisibility) { @@ -2087,6 +2116,7 @@ public function getIdentifierQuoting() /** * @param boolean $identifierQuoting +* @return void */ public function setIdentifierQuoting($identifierQuoting) { diff --git a/src/Propel/Generator/Model/VendorInfo.php b/src/Propel/Generator/Model/VendorInfo.php index cff8d63d2f..87813e331d 100644 --- a/src/Propel/Generator/Model/VendorInfo.php +++ b/src/Propel/Generator/Model/VendorInfo.php @@ -44,6 +44,7 @@ public function __construct($type = null, array $parameters = []) * Sets the RDBMS type for this vendor specific information. * * @param string $type +* @return void */ public function setType($type) { @@ -65,6 +66,7 @@ public function getType() * * @param string $name The parameter name * @param mixed $value The parameter value +* @return void */ public function setParameter($name, $value) { @@ -97,6 +99,7 @@ public function hasParameter($name) * Sets an associative array of parameters for vendor specific information. * * @param array $parameters Parameter data. +* @return void */ public function setParameters(array $parameters = []) { diff --git a/src/Propel/Generator/Platform/DefaultPlatform.php b/src/Propel/Generator/Platform/DefaultPlatform.php index fe7b14f7de..59fadfd4c9 100644 --- a/src/Propel/Generator/Platform/DefaultPlatform.php +++ b/src/Propel/Generator/Platform/DefaultPlatform.php @@ -83,6 +83,7 @@ public function getObjectBuilderClass($type) * Sets the database connection to use for this Platform class. * * @param ConnectionInterface $con Database connection to use in this platform. +* @return void */ public function setConnection(ConnectionInterface $con = null) { @@ -109,6 +110,7 @@ public function isIdentifierQuotingEnabled() /** * @param boolean $enabled +* @return void */ public function setIdentifierQuoting($enabled) { @@ -119,6 +121,7 @@ public function setIdentifierQuoting($enabled) * Sets the GeneratorConfigInterface to use in the parsing. * * @param GeneratorConfigInterface $generatorConfig +* @return void */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) { @@ -126,6 +129,7 @@ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) /** * Initialize the type -> Domain mapping. +* @return void */ protected function initialize() { @@ -144,6 +148,7 @@ protected function initialize() /** * Adds a mapping entry for specified Domain. * @param Domain $domain +* @return void */ protected function setSchemaDomainMapping(Domain $domain) { @@ -1248,6 +1253,7 @@ public function hasStreamBlobImpl() /** * @see Platform::supportsSchemas() + * @return bool */ public function supportsSchemas() { diff --git a/src/Propel/Generator/Platform/MssqlPlatform.php b/src/Propel/Generator/Platform/MssqlPlatform.php index ee28ac0b48..cc59e576b8 100644 --- a/src/Propel/Generator/Platform/MssqlPlatform.php +++ b/src/Propel/Generator/Platform/MssqlPlatform.php @@ -30,6 +30,7 @@ class MssqlPlatform extends DefaultPlatform /** * Initializes db specific domain mapping. +* @return void */ protected function initialize() { diff --git a/src/Propel/Generator/Platform/MysqlPlatform.php b/src/Propel/Generator/Platform/MysqlPlatform.php index bac825c635..2a30cdabce 100644 --- a/src/Propel/Generator/Platform/MysqlPlatform.php +++ b/src/Propel/Generator/Platform/MysqlPlatform.php @@ -36,6 +36,7 @@ class MysqlPlatform extends DefaultPlatform /** * Initializes db specific domain mapping. +* @return void */ protected function initialize() { @@ -75,6 +76,7 @@ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) * Setter for the tableEngineKeyword property * * @param string $tableEngineKeyword +* @return void */ public function setTableEngineKeyword($tableEngineKeyword) { @@ -95,6 +97,7 @@ public function getTableEngineKeyword() * Setter for the defaultTableEngine property * * @param string $defaultTableEngine +* @return void */ public function setDefaultTableEngine($defaultTableEngine) { diff --git a/src/Propel/Generator/Platform/OraclePlatform.php b/src/Propel/Generator/Platform/OraclePlatform.php index 5d66bc79b2..54b15dec3f 100644 --- a/src/Propel/Generator/Platform/OraclePlatform.php +++ b/src/Propel/Generator/Platform/OraclePlatform.php @@ -32,6 +32,7 @@ class OraclePlatform extends DefaultPlatform { /** * Initializes db specific domain mapping. +* @return void */ protected function initialize() { diff --git a/src/Propel/Generator/Platform/PgsqlPlatform.php b/src/Propel/Generator/Platform/PgsqlPlatform.php index 0cda5df5ef..b46fcf9cc0 100755 --- a/src/Propel/Generator/Platform/PgsqlPlatform.php +++ b/src/Propel/Generator/Platform/PgsqlPlatform.php @@ -39,6 +39,7 @@ class PgsqlPlatform extends DefaultPlatform /** * Initializes db specific domain mapping. +* @return void */ protected function initialize() { @@ -344,7 +345,7 @@ public function getEndDDL() } /** - * {@inheritDoc} + * @inheritDoc */ public function getAddForeignKeysDDL(Table $table) { diff --git a/src/Propel/Generator/Platform/SqlitePlatform.php b/src/Propel/Generator/Platform/SqlitePlatform.php index 70ca9f9308..ca853285c1 100644 --- a/src/Propel/Generator/Platform/SqlitePlatform.php +++ b/src/Propel/Generator/Platform/SqlitePlatform.php @@ -47,6 +47,7 @@ class SqlitePlatform extends DefaultPlatform /** * Initializes db specific domain mapping. +* @return void */ protected function initialize() { diff --git a/src/Propel/Generator/Reverse/AbstractSchemaParser.php b/src/Propel/Generator/Reverse/AbstractSchemaParser.php index 5b922903ee..d5b9d3345a 100644 --- a/src/Propel/Generator/Reverse/AbstractSchemaParser.php +++ b/src/Propel/Generator/Reverse/AbstractSchemaParser.php @@ -87,6 +87,7 @@ public function __construct(ConnectionInterface $dbh = null) * Sets the database connection. * * @param ConnectionInterface $dbh +* @return void */ public function setConnection(ConnectionInterface $dbh) { @@ -106,6 +107,7 @@ public function getConnection() * Setter for the migrationTable property * * @param string $migrationTable +* @return void */ public function setMigrationTable($migrationTable) { @@ -126,6 +128,7 @@ public function getMigrationTable() * Pushes a message onto the stack of warnings. * * @param string $msg The warning message. +* @return void */ protected function warn($msg) { @@ -146,6 +149,7 @@ public function getWarnings() * Sets the GeneratorConfig to use in the parsing. * * @param GeneratorConfigInterface $config +* @return void */ public function setGeneratorConfig(GeneratorConfigInterface $config) { diff --git a/src/Propel/Generator/Reverse/MssqlSchemaParser.php b/src/Propel/Generator/Reverse/MssqlSchemaParser.php index 0d552b84c5..ed6109871c 100644 --- a/src/Propel/Generator/Reverse/MssqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/MssqlSchemaParser.php @@ -122,6 +122,7 @@ public function parse(Database $database, array $additionalTables = []) * Adds Columns to the specified table. * * @param Table $table The Table model class to add columns to. +* @return void */ protected function addColumns(Table $table) { @@ -167,6 +168,7 @@ protected function addColumns(Table $table) /** * Load foreign keys for this table. +* @return void */ protected function addForeignKeys(Table $table) { @@ -210,6 +212,7 @@ protected function addForeignKeys(Table $table) /** * Load indexes for this table +* @return void */ protected function addIndexes(Table $table) { @@ -255,6 +258,7 @@ protected function addIndexes(Table $table) /** * Loads the primary key for this table. +* @return void */ protected function addPrimaryKey(Table $table) { diff --git a/src/Propel/Generator/Reverse/MysqlSchemaParser.php b/src/Propel/Generator/Reverse/MysqlSchemaParser.php index 0141783cea..77452ffa43 100644 --- a/src/Propel/Generator/Reverse/MysqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/MysqlSchemaParser.php @@ -162,6 +162,7 @@ protected function parseTables(Database $database, $filterTable = null) * Adds Columns to the specified table. * * @param Table $table The Table model class to add columns to. +* @return void */ protected function addColumns(Table $table) { @@ -277,6 +278,7 @@ public function getColumnFromRow($row, Table $table) /** * Load foreign keys for this table. +* @return void */ protected function addForeignKeys(Table $table) { @@ -373,6 +375,7 @@ protected function addForeignKeys(Table $table) /** * Load indexes for this table +* @return void */ protected function addIndexes(Table $table) { @@ -424,6 +427,7 @@ protected function addIndexes(Table $table) /** * Loads the primary key for this table. +* @return void */ protected function addPrimaryKey(Table $table) { @@ -449,6 +453,7 @@ protected function addPrimaryKey(Table $table) * Adds vendor-specific info for table. * * @param Table $table +* @return void */ protected function addTableVendorInfo(Table $table) { diff --git a/src/Propel/Generator/Reverse/OracleSchemaParser.php b/src/Propel/Generator/Reverse/OracleSchemaParser.php index 5e932acb58..80d79b33e1 100644 --- a/src/Propel/Generator/Reverse/OracleSchemaParser.php +++ b/src/Propel/Generator/Reverse/OracleSchemaParser.php @@ -133,6 +133,7 @@ public function parse(Database $database, array $additionalTables = []) * Adds Columns to the specified table. * * @param Table $table The Table model class to add columns to. +* @return void */ protected function addColumns(Table $table) { @@ -195,6 +196,7 @@ protected function addColumns(Table $table) * Adds Indexes to the specified table. * * @param Table $table The Table model class to add columns to. +* @return void */ protected function addIndexes(Table $table) { @@ -226,6 +228,7 @@ protected function addIndexes(Table $table) * Load foreign keys for this table. * * @param Table $table The Table model class to add FKs to +* @return void */ protected function addForeignKeys(Table $table) { @@ -262,6 +265,7 @@ protected function addForeignKeys(Table $table) * Loads the primary key for this table. * * @param Table $table The Table model class to add PK to. +* @return void */ protected function addPrimaryKey(Table $table) { diff --git a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php index a4c7541b35..a16d4fe5b2 100755 --- a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php @@ -219,6 +219,7 @@ protected function parseTables(&$tableWraps, Database $database, Table $filterTa * * @param Table $table The Table model class to add columns to. * @param int $oid The table OID +* @return void */ protected function addColumns(Table $table, $oid) { @@ -362,6 +363,7 @@ protected function isColumnDefaultExpression($default) /** * Load foreign keys for this table. +* @return void */ protected function addForeignKeys(Table $table, $oid) { @@ -472,6 +474,7 @@ protected function addForeignKeys(Table $table, $oid) /** * Load indexes for this table +* @return void */ protected function addIndexes(Table $table, $oid) { @@ -534,6 +537,7 @@ protected function addIndexes(Table $table, $oid) /** * Loads the primary key for this table. +* @return void */ protected function addPrimaryKey(Table $table, $oid) { @@ -576,6 +580,7 @@ protected function addPrimaryKey(Table $table, $oid) * Adds the sequences for this database. * * @param Database $database +* @return void */ protected function addSequences(Database $database) { diff --git a/src/Propel/Generator/Reverse/SqliteSchemaParser.php b/src/Propel/Generator/Reverse/SqliteSchemaParser.php index fe01ee7d75..96447b71ab 100644 --- a/src/Propel/Generator/Reverse/SqliteSchemaParser.php +++ b/src/Propel/Generator/Reverse/SqliteSchemaParser.php @@ -183,6 +183,7 @@ protected function parseTables(Database $database, Table $filterTable = null) * Adds Columns to the specified table. * * @param Table $table The Table model class to add columns to. +* @return void */ protected function addColumns(Table $table) { @@ -318,6 +319,7 @@ protected function addForeignKeys(Table $table) /** * Load indexes for this table +* @return void */ protected function addIndexes(Table $table) { diff --git a/src/Propel/Generator/Schema/Dumper/XmlDumper.php b/src/Propel/Generator/Schema/Dumper/XmlDumper.php index 92e638c2c4..296a4b44be 100644 --- a/src/Propel/Generator/Schema/Dumper/XmlDumper.php +++ b/src/Propel/Generator/Schema/Dumper/XmlDumper.php @@ -89,6 +89,7 @@ public function dumpSchema(Schema $schema, $doFinalInitialization = true) * * @param Database $database The Database model instance * @param \DOMNode $parentNode The parent DOMNode object +* @return void */ private function appendDatabaseNode(Database $database, \DOMNode $parentNode) { @@ -171,6 +172,7 @@ private function appendDatabaseNode(Database $database, \DOMNode $parentNode) * * @param VendorInfo $vendorInfo The VendorInfo model instance * @param \DOMNode $parentNode The parent DOMNode object +* @return void */ private function appendVendorInformationNode(VendorInfo $vendorInfo, \DOMNode $parentNode) { @@ -191,6 +193,7 @@ private function appendVendorInformationNode(VendorInfo $vendorInfo, \DOMNode $p * * @param Table $table The Table model instance * @param \DOMNode $parentNode The parent DOMNode object +* @return void */ private function appendTableNode(Table $table, \DOMNode $parentNode) { @@ -323,6 +326,7 @@ private function appendTableNode(Table $table, \DOMNode $parentNode) * * @param Behavior $behavior The Behavior model instance * @param \DOMNode $parentNode The parent DOMNode object +* @return void */ private function appendBehaviorNode(Behavior $behavior, \DOMNode $parentNode) { @@ -346,6 +350,7 @@ private function appendBehaviorNode(Behavior $behavior, \DOMNode $parentNode) * * @param Column $column The Column model instance * @param \DOMNode $parentNode The parent DOMNode object +* @return void */ private function appendColumnNode(Column $column, \DOMNode $parentNode) { @@ -419,6 +424,7 @@ private function appendColumnNode(Column $column, \DOMNode $parentNode) * * @param Inheritance $inheritance The Inheritance model instance * @param \DOMNode $parentNode The parent DOMNode object +* @return void */ private function appendInheritanceNode(Inheritance $inheritance, \DOMNode $parentNode) { @@ -437,6 +443,7 @@ private function appendInheritanceNode(Inheritance $inheritance, \DOMNode $paren * * @param ForeignKey $foreignKey The ForeignKey model instance * @param \DOMNode $parentNode The parent DOMNode object +* @return void */ private function appendForeignKeyNode(ForeignKey $foreignKey, \DOMNode $parentNode) { @@ -486,6 +493,7 @@ private function appendForeignKeyNode(ForeignKey $foreignKey, \DOMNode $parentNo * * @param IdMethodParameter $parameter The IdMethodParameter model instance * @param \DOMNode $parentNode The parent DOMNode object +* @return void */ private function appendIdMethodParameterNode(IdMethodParameter $parameter, \DOMNode $parentNode) { @@ -502,6 +510,7 @@ private function appendIdMethodParameterNode(IdMethodParameter $parameter, \DOMN * * @param Index $index The Index model instance * @param \DOMNode $parentNode The parent DOMNode object +* @return void */ private function appendIndexNode(Index $index, \DOMNode $parentNode) { @@ -513,6 +522,7 @@ private function appendIndexNode(Index $index, \DOMNode $parentNode) * * @param Unique $index The Unique model instance * @param \DOMNode $parentNode The parent DOMNode object +* @return void */ private function appendUniqueIndexNode(Unique $index, \DOMNode $parentNode) { @@ -525,6 +535,7 @@ private function appendUniqueIndexNode(Unique $index, \DOMNode $parentNode) * @param string $nodeType The node type (index or unique) * @param Index $index The Index model instance * @param \DOMNode $parentNode The parent DOMNode object +* @return void */ private function appendGenericIndexNode($nodeType, Index $index, \DOMNode $parentNode) { diff --git a/src/Propel/Generator/Util/QuickBuilder.php b/src/Propel/Generator/Util/QuickBuilder.php index c72fbba18c..063dd210a9 100644 --- a/src/Propel/Generator/Util/QuickBuilder.php +++ b/src/Propel/Generator/Util/QuickBuilder.php @@ -76,6 +76,7 @@ class QuickBuilder /** * @param string $schema +* @return void */ public function setSchema($schema) { @@ -92,6 +93,7 @@ public function getSchema() /** * @param string $schemaName +* @return void */ public function setSchemaName($schemaName) { @@ -108,6 +110,7 @@ public function getSchemaName() /** * @param \Propel\Generator\Reverse\SchemaParserInterface $parser +* @return void */ public function setParser($parser) { @@ -126,6 +129,7 @@ public function getParser() * Setter for the platform property * * @param PlatformInterface $platform +* @return void */ public function setPlatform($platform) { @@ -152,6 +156,7 @@ public function getPlatform() * Setter for the config property * * @param GeneratorConfigInterface $config +* @return void */ public function setConfig(GeneratorConfigInterface $config) { @@ -346,6 +351,7 @@ public function getBuildName($classTargets = null) /** * @param string[]|null $classTargets array('tablemap', 'object', 'query', 'objectstub', 'querystub') * @param bool $separate pass true to get for each class a own file. better for debugging. +* @return void */ public function buildClasses(array $classTargets = null, $separate = false) { @@ -567,6 +573,7 @@ public function isIdentifierQuotingEnabled() /** * @param boolean $identifierQuoting +* @return void */ public function setIdentifierQuoting($identifierQuoting) { diff --git a/src/Propel/Generator/Util/SqlParser.php b/src/Propel/Generator/Util/SqlParser.php index 6446899f2b..499d97afec 100644 --- a/src/Propel/Generator/Util/SqlParser.php +++ b/src/Propel/Generator/Util/SqlParser.php @@ -31,6 +31,7 @@ class SqlParser * Also resets the parsing cursor (see getNextStatement) * * @param string $sql The SQL string to parse +* @return void */ public function setSQL($sql) { diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index 4143af63a8..d65c47d069 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -702,6 +702,7 @@ public function getPrimaryTableName() * set, of course, in order to be useful. * * @param string $tableName +* @return void */ public function setPrimaryTableName($tableName) { @@ -777,6 +778,7 @@ public function put($key, $value) * Criteria, overwriting previous settings. * * @param mixed $t Mappings to be stored in this map. +* @return void */ public function putAll($t) { @@ -2787,6 +2789,7 @@ public function _endif() /** * Ensures deep cloning of attached objects +* @return void */ public function __clone() { @@ -2813,6 +2816,7 @@ public function isIdentifierQuotingEnabled() /** * @param boolean $identifierQuoting +* @return void */ public function setIdentifierQuoting($identifierQuoting) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php index 04877a8133..4bf8d52e9d 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php @@ -93,6 +93,7 @@ public function __construct(Criteria $outer, $column, $value, $comparison = null /** * Init some properties with the help of outer class * @param Criteria $criteria The outer class +* @return void */ public function init(Criteria $criteria) { @@ -112,6 +113,7 @@ public function init(Criteria $criteria) /** * Set the $column and $table properties based on a column name or object +* @return void */ protected function setColumn($column) { @@ -388,6 +390,7 @@ public function getAttachedCriterion() /** * Ensures deep cloning of attached objects +* @return void */ public function __clone() { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php index d4b9231170..f180d3ac1b 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php @@ -63,6 +63,7 @@ public function isIgnoreCase() * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended +* @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php index c987967c63..33b8df636f 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php @@ -23,6 +23,7 @@ class BasicModelCriterion extends AbstractModelCriterion * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended +* @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php index 65181498a3..53efcbb5de 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php @@ -36,6 +36,7 @@ public function __construct(Criteria $outer, $column, $value, $comparison = Crit * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended +* @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php index 1d7074d887..4571ded92e 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php @@ -20,6 +20,7 @@ class BinaryModelCriterion extends AbstractModelCriterion * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended +* @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php index 0ff4a5cb0d..1d68991236 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php @@ -34,6 +34,7 @@ public function __construct(Criteria $outer, $value) * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended +* @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php index 2ab41b4a37..21ddba1fc4 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php @@ -36,6 +36,7 @@ public function __construct(Criteria $outer, $column, $value, $comparison = Crit * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended +* @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php index 84caad534a..d8f070fbda 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php @@ -21,6 +21,7 @@ class InModelCriterion extends AbstractModelCriterion * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended +* @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php index 1e73561db8..857b07c974 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php @@ -63,6 +63,7 @@ public function isIgnoreCase() * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended +* @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php index fee6dfdedf..4747ad5015 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php @@ -51,6 +51,7 @@ public function isIgnoreCase() * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended +* @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php index 8a41735cdb..3e08172cd9 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php @@ -48,6 +48,7 @@ public function __construct(Criteria $outer, $column, $value, $type = PDO::PARAM * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended +* @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php index 99553d6f8f..87f57cb644 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php @@ -49,6 +49,7 @@ public function __construct(Criteria $outer, $clause, $column, $value = null, $t * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended +* @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php index bb9606e61a..cf7bc913f1 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php @@ -22,6 +22,7 @@ class SeveralModelCriterion extends AbstractModelCriterion * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended +* @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Join.php b/src/Propel/Runtime/ActiveQuery/Join.php index 911ffdce1d..23fbab9e45 100644 --- a/src/Propel/Runtime/ActiveQuery/Join.php +++ b/src/Propel/Runtime/ActiveQuery/Join.php @@ -114,6 +114,7 @@ public function __construct($leftColumn = null, $rightColumn = null, $joinType = * @param string $right The right column of the join condition * (may contain an alias name) * @param string $operator The comparison operator of the join condition, default Join::EQUAL +* @return void */ public function addCondition($left, $right, $operator = self::EQUAL) { @@ -142,6 +143,7 @@ public function addCondition($left, $right, $operator = self::EQUAL) * @param array $rights The right columns of the join condition * @param string[] $operators The comparison operators of the join condition, default Join::EQUAL * @throws \Propel\Runtime\Exception\LogicException +* @return void */ public function addConditions($lefts, $rights, $operators = []) { @@ -172,6 +174,7 @@ public function addConditions($lefts, $rights, $operators = []) * @param string $rightColumnName * @param string $rightTableAlias * @param string $operator The comparison operator of the join condition, default Join::EQUAL +* @return void */ public function addExplicitCondition( $leftTableName, @@ -200,6 +203,7 @@ public function addExplicitCondition( * @param string|null $leftTableAlias * @param mixed $leftColumnValue * @param string $operator +* @return void */ public function addLocalValueCondition($leftTableName, $leftColumnName, $leftTableAlias, $leftColumnValue, $operator = self::EQUAL) { @@ -265,6 +269,7 @@ public function getConditions() /** * @param string $operator the comparison operator for the join condition +* @return void */ public function addOperator($operator) { @@ -294,6 +299,7 @@ public function getOperators() * @param string $joinType The type of the join. Valid join types are * null (adding the join condition to the where clause), * Criteria::LEFT_JOIN(), Criteria::RIGHT_JOIN(), and Criteria::INNER_JOIN() +* @return void */ public function setJoinType($joinType = null) { @@ -320,6 +326,7 @@ public function getJoinType() * $join->addLeftColumnName('AUTHOR_ID'); * * @param string $left The name of the left column to add +* @return void */ public function addLeftColumnName($left) { @@ -330,6 +337,7 @@ public function addLeftColumnName($left) * Adds a value for a leftColumn. * * @param string|number $value an actual value +* @return void */ public function addLeftValue($value) { @@ -455,6 +463,7 @@ public function getLeftTableWithAlias() * $join->addRightColumnName('ID'); * * @param string $right The name of the right column to add +* @return void */ public function addRightColumnName($right) { @@ -598,6 +607,7 @@ public function setAdapter(AdapterInterface $db) * Set a custom join condition * * @param AbstractCriterion $joinCondition a Join condition +* @return void */ public function setJoinCondition(AbstractCriterion $joinCondition) { @@ -618,6 +628,7 @@ public function getJoinCondition() * Set the custom join condition Criterion based on the conditions of this join * * @param Criteria $c A Criteria object to get Criterions from +* @return void */ public function buildJoinCondition(Criteria $c) { @@ -748,6 +759,7 @@ public function isIdentifierQuotingEnabled() /** * @param boolean $identifierQuoting +* @return void */ public function setIdentifierQuoting($identifierQuoting) { diff --git a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php index 2d44b1ba74..2c6e18dad7 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php @@ -453,6 +453,7 @@ public function getPreviousJoin() * by default this is null, but after useQuery this is set the to the join of that use * * @param Join $previousJoin The previousJoin for this ModelCriteria +* @return void */ public function setPreviousJoin(Join $previousJoin) { @@ -821,6 +822,7 @@ public function clear() * * @param ModelCriteria $criteria The primary criteria * @param Join $previousJoin The previousJoin for this ModelCriteria +* @return void */ public function setPrimaryCriteria(ModelCriteria $criteria, Join $previousJoin) { @@ -2281,6 +2283,7 @@ public function __call($name, $arguments) /** * Ensures deep cloning of attached objects +* @return void */ public function __clone() { diff --git a/src/Propel/Runtime/ActiveQuery/ModelWith.php b/src/Propel/Runtime/ActiveQuery/ModelWith.php index a46aa2faa2..aecaa0b438 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelWith.php +++ b/src/Propel/Runtime/ActiveQuery/ModelWith.php @@ -87,6 +87,7 @@ public function __construct(ModelJoin $join = null) * Fills the ModelWith properties using a ModelJoin as source * * @param ModelJoin $join +* @return void */ public function init(ModelJoin $join) { diff --git a/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php index 1944b061d9..e68fe211fb 100644 --- a/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php @@ -32,6 +32,7 @@ class MssqlAdapter extends PdoAdapter implements SqlAdapterInterface * * @param ConnectionInterface $con * @param string $charset +* @return void */ public function setCharset(ConnectionInterface $con, $charset) { @@ -76,7 +77,7 @@ public function strLength($s) } /** - * {@inheritDoc} + * @inheritDoc */ public function compareRegex($left, $right) { @@ -279,6 +280,7 @@ public function applyLimit(&$sql, $offset, $limit) * @param array $params * @param Criteria $values * @param DatabaseMap $dbMap +* @return void */ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap) { diff --git a/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php index a46ae815d8..69389d61aa 100644 --- a/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php @@ -70,6 +70,7 @@ public function strLength($s) * @param string $table The name of the table to lock. * * @throws \PDOException No Statement could be created or executed. +* @return void */ public function lockTable($con, $table) { @@ -83,6 +84,7 @@ public function lockTable($con, $table) * @param string $table The name of the table to unlock. * * @throws \PDOException No Statement could be created or executed. +* @return void */ public function unlockTable($con, $table) { @@ -118,6 +120,7 @@ public function quoteIdentifierTable($table) * @param string $sql * @param integer $offset * @param integer $limit +* @return void */ public function applyLimit(&$sql, $offset, $limit) { diff --git a/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php b/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php index f4a55f5d7a..21be3de436 100644 --- a/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php @@ -39,6 +39,7 @@ class OracleAdapter extends PdoAdapter implements SqlAdapterInterface * * @param ConnectionInterface $con * @param array $settings +* @return void */ public function initConnection(ConnectionInterface $con, array $settings) { @@ -67,7 +68,7 @@ public function concatString($s1, $s2) } /** - * {@inheritDoc} + * @inheritDoc */ public function compareRegex($left, $right) { @@ -106,6 +107,7 @@ public function strLength($s) * @param integer $offset * @param integer $limit * @param null|Criteria $criteria +* @return void */ public function applyLimit(&$sql, $offset, $limit, $criteria = null) { diff --git a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php index 60e45e729a..11cad700b1 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php @@ -76,7 +76,7 @@ public function getConnection($conparams) } /** - * {@inheritDoc} + * @inheritDoc */ public function compareRegex($left, $right) { @@ -119,6 +119,7 @@ protected function prepareParams($conparams) * * @param ConnectionInterface $con * @param array $settings An array of settings. +* @return void */ public function initConnection(ConnectionInterface $con, array $settings) { @@ -143,6 +144,7 @@ public function initConnection(ConnectionInterface $con, array $settings) * * @param ConnectionInterface $con * @param string $charset The $string charset encoding. +* @return void */ public function setCharset(ConnectionInterface $con, $charset) { @@ -373,6 +375,7 @@ public function getTimeFormatter() * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) * @param Criteria $values * @param DatabaseMap $dbMap +* @return void */ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap) { @@ -557,6 +560,7 @@ public function turnSelectColumnsToAliases(Criteria $criteria) * @param \PDOStatement $stmt * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) * @param DatabaseMap $dbMap +* @return void */ public function bindValues(\PDOStatement $stmt, array $params, DatabaseMap $dbMap) { diff --git a/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php index 0d8ff49315..b25b0f51f8 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php @@ -41,7 +41,7 @@ public function concatString($s1, $s2) } /** - * {@inheritDoc} + * @inheritDoc */ public function compareRegex($left, $right) { @@ -126,6 +126,7 @@ public function getTimeFormatter() * @param string $sql * @param integer $offset * @param integer $limit +* @return void */ public function applyLimit(&$sql, $offset, $limit) { diff --git a/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php b/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php index e643cc1cbd..bd6cef0847 100644 --- a/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php @@ -29,6 +29,7 @@ class SqliteAdapter extends PdoAdapter implements SqlAdapterInterface * @param string $charset The charset encoding. * * @throws \Propel\Runtime\Exception\PropelException If the specified charset doesn't match sqlite_libencoding() +* @return void */ public function setCharset(ConnectionInterface $con, $charset) { @@ -107,6 +108,7 @@ public function quoteIdentifier($text) * @param string $sql * @param integer $offset * @param integer $limit +* @return void */ public function applyLimit(&$sql, $offset, $limit) { diff --git a/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php b/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php index 105b1cd63d..88de46c2e3 100644 --- a/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php @@ -29,6 +29,7 @@ class SqlsrvAdapter extends MssqlAdapter implements SqlAdapterInterface * * @param ConnectionInterface $con * @param array $settings An array of settings. +* @return void */ public function initConnection(ConnectionInterface $con, array $settings) { @@ -45,6 +46,7 @@ public function initConnection(ConnectionInterface $con, array $settings) * @param string $charset * * @throws \Propel\Runtime\Adapter\Exception\UnsupportedEncodingException +* @return void */ public function setCharset(ConnectionInterface $con, $charset) { @@ -67,6 +69,7 @@ public function setCharset(ConnectionInterface $con, $charset) * @param array $params * @param Criteria $values * @param DatabaseMap $dbMap +* @return void */ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap) { diff --git a/src/Propel/Runtime/Collection/ArrayCollection.php b/src/Propel/Runtime/Collection/ArrayCollection.php index 9f148fc03b..3d51e6c04c 100644 --- a/src/Propel/Runtime/Collection/ArrayCollection.php +++ b/src/Propel/Runtime/Collection/ArrayCollection.php @@ -34,6 +34,7 @@ class ArrayCollection extends Collection * * @throws ReadOnlyModelException * @throws PropelException +* @return void */ public function save($con = null) { @@ -61,6 +62,7 @@ public function save($con = null) * * @throws ReadOnlyModelException * @throws PropelException +* @return void */ public function delete($con = null) { @@ -105,6 +107,7 @@ public function getPrimaryKeys($usePrefix = true) * Does not empty the collection before adding the data from the array * * @param array $arr +* @return void */ public function fromArray($arr) { diff --git a/src/Propel/Runtime/Collection/Collection.php b/src/Propel/Runtime/Collection/Collection.php index dd311c7809..8762f55c75 100644 --- a/src/Propel/Runtime/Collection/Collection.php +++ b/src/Propel/Runtime/Collection/Collection.php @@ -74,6 +74,7 @@ public function __construct($data = []) /** * @param mixed $value +* @return void */ public function append($value) { @@ -103,6 +104,7 @@ public function &offsetGet($offset) /** * @param mixed $offset * @param mixed $value +* @return void */ public function offsetSet($offset, $value) { @@ -115,6 +117,7 @@ public function offsetSet($offset, $value) /** * @param mixed $offset +* @return void */ public function offsetUnset($offset) { @@ -123,6 +126,7 @@ public function offsetUnset($offset) /** * @param array $input +* @return void */ public function exchangeArray($input) { @@ -151,6 +155,7 @@ public function getArrayCopy() * Set the data in the collection * * @param array $data +* @return void */ public function setData($data) { @@ -270,6 +275,7 @@ public function shift() * Prepend one elements to the end of the collection * * @param mixed $value the element to prepend +* @return void */ public function push($value) { @@ -299,6 +305,7 @@ public function prepend($value) * * @param mixed $key * @param mixed $value +* @return void */ public function set($key, $value) { @@ -392,6 +399,7 @@ public function serialize() /** * @param string $data +* @return void */ public function unserialize($data) { @@ -407,6 +415,7 @@ public function unserialize($data) * Set the model of the elements in the collection * * @param string $model Name of the Propel object classes stored in the collection +* @return void */ public function setModel($model) { @@ -455,6 +464,7 @@ public function getTableMapClass() /** * @param AbstractFormatter $formatter +* @return void */ public function setFormatter(AbstractFormatter $formatter) { @@ -576,6 +586,7 @@ public function __toString() /** * Creates clones of the containing data. +* @return void */ public function __clone() { diff --git a/src/Propel/Runtime/Collection/ObjectCollection.php b/src/Propel/Runtime/Collection/ObjectCollection.php index 01b7fe0d1e..af66f72316 100644 --- a/src/Propel/Runtime/Collection/ObjectCollection.php +++ b/src/Propel/Runtime/Collection/ObjectCollection.php @@ -43,6 +43,7 @@ public function __construct($data = []) /** * @param array $input +* @return void */ public function exchangeArray($input) { @@ -64,6 +65,7 @@ public function setData($data) * Save all the elements in the collection * * @param ConnectionInterface $con +* @return void */ public function save($con = null) { @@ -85,6 +87,7 @@ public function save($con = null) * Delete all the elements in the collection * * @param ConnectionInterface $con +* @return void */ public function delete($con = null) { @@ -127,6 +130,7 @@ public function getPrimaryKeys($usePrefix = true) * Does not empty the collection before adding the data from the array * * @param array $arr +* @return void */ public function fromArray($arr) { @@ -411,6 +415,7 @@ protected function rebuildIndex() /** * @param mixed $offset +* @return void */ public function offsetUnset($offset) { @@ -425,6 +430,7 @@ public function offsetUnset($offset) /** * @param mixed $element +* @return void */ public function removeObject($element) { @@ -435,6 +441,7 @@ public function removeObject($element) /** * @param mixed $value +* @return void */ public function append($value) { @@ -455,6 +462,7 @@ public function append($value) /** * @param mixed $offset * @param mixed $value +* @return void */ public function offsetSet($offset, $value) { @@ -500,6 +508,7 @@ public function contains($element) * Returns the result of $object->hashCode() if available or uses spl_object_hash($object). * * @param mixed $object + * @return string */ protected function getHashCode($object) { diff --git a/src/Propel/Runtime/Collection/OnDemandCollection.php b/src/Propel/Runtime/Collection/OnDemandCollection.php index ea3614cd9c..cfc2b9d8e8 100644 --- a/src/Propel/Runtime/Collection/OnDemandCollection.php +++ b/src/Propel/Runtime/Collection/OnDemandCollection.php @@ -32,6 +32,7 @@ class OnDemandCollection extends Collection /** * @param \Propel\Runtime\Formatter\ObjectFormatter $formatter * @param DataFetcherInterface $dataFetcher +* @return void */ public function initIterator(AbstractFormatter $formatter, DataFetcherInterface $dataFetcher) { @@ -93,6 +94,7 @@ public function toArray($keyColumn = null, $usePrefix = false, $keyType = TableM * Does not empty the collection before adding the data from the array * * @param array $arr +* @return void */ public function fromArray($arr) { @@ -138,6 +140,7 @@ public function &offsetGet($offset) * * @param integer $offset * @param mixed $value +* @return void */ public function offsetSet($offset, $value) { @@ -147,6 +150,7 @@ public function offsetSet($offset, $value) /** * @throws \Propel\Runtime\Collection\Exception\ReadOnlyModelException * @param integer $offset +* @return void */ public function offsetUnset($offset) { @@ -157,6 +161,7 @@ public function offsetUnset($offset) /** * @throws \Propel\Runtime\Exception\PropelException +* @return void */ public function serialize() { @@ -166,6 +171,7 @@ public function serialize() /** * @throws \Propel\Runtime\Exception\PropelException * @param string $data +* @return void */ public function unserialize($data) { diff --git a/src/Propel/Runtime/Collection/OnDemandIterator.php b/src/Propel/Runtime/Collection/OnDemandIterator.php index ae379b0fed..4803f5e5b8 100644 --- a/src/Propel/Runtime/Collection/OnDemandIterator.php +++ b/src/Propel/Runtime/Collection/OnDemandIterator.php @@ -104,6 +104,7 @@ public function key() /** * Advances the cursor in the statement * Closes the cursor if the end of the statement is reached +* @return void */ public function next() { @@ -118,6 +119,7 @@ public function next() /** * Initializes the iterator by advancing to the first position * This method can only be called once (this is a NoRewindIterator) +* @return void */ public function rewind() { diff --git a/src/Propel/Runtime/Connection/ConnectionManagerMasterSlave.php b/src/Propel/Runtime/Connection/ConnectionManagerMasterSlave.php index cdaf2c24ff..aee964571b 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerMasterSlave.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerMasterSlave.php @@ -33,6 +33,7 @@ public function isForceMasterConnection() * * @param boolean $isForceMasterConnection * @deprecated Use setForcePrimaryConnection() instead. +* @return void */ public function setForceMasterConnection($isForceMasterConnection) { diff --git a/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php b/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php index 565dd89fdd..1cd4309840 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php @@ -49,6 +49,7 @@ class ConnectionManagerPrimaryReplica implements ConnectionManagerInterface /** * @param string $name The datasource name associated to this connection +* @return void */ public function setName($name) { @@ -77,6 +78,7 @@ public function isForcePrimaryConnection() * For replication, set whether to always force the use of a primary connection. * * @param boolean $isForceMasterConnection +* @return void */ public function setForcePrimaryConnection($isForceMasterConnection) { @@ -95,6 +97,7 @@ public function setForcePrimaryConnection($isForceMasterConnection) * * * @param array $configuration +* @return void */ public function setWriteConfiguration($configuration) { @@ -121,6 +124,7 @@ public function setWriteConfiguration($configuration) * * * @param array $configuration +* @return void */ public function setReadConfiguration($configuration) { diff --git a/src/Propel/Runtime/Connection/ConnectionManagerSingle.php b/src/Propel/Runtime/Connection/ConnectionManagerSingle.php index fe1c075790..c74c9e885f 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerSingle.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerSingle.php @@ -34,6 +34,7 @@ class ConnectionManagerSingle implements ConnectionManagerInterface /** * @param string $name The datasource name associated to this connection +* @return void */ public function setName($name) { diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index b33ed3b687..d9676542e2 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -166,6 +166,7 @@ public function getNestedTransactionCount() /** * Set the current transaction depth. * @param int $v The new depth. +* @return void */ protected function setNestedTransactionCount($v) { @@ -466,7 +467,7 @@ public function quote($string, $parameter_type = 2) } /** - * {@inheritDoc} + * @inheritDoc */ public function getSingleDataFetcher($data) { @@ -474,7 +475,7 @@ public function getSingleDataFetcher($data) } /** - * {@inheritDoc} + * @inheritDoc */ public function getDataFetcher($data) { @@ -517,6 +518,7 @@ public function lastInsertId($name = null) /** * Clears any stored prepared statements for this connection. +* @return void */ public function clearStatementCache() { @@ -562,6 +564,7 @@ public function getLastExecutedQuery() * Set the SQL code for the latest query executed by Propel * * @param string $query Executable SQL code +* @return void */ public function setLastExecutedQuery($query) { @@ -572,6 +575,7 @@ public function setLastExecutedQuery($query) * Enable or disable the query debug features * * @param boolean $value True to enable debug (default), false to disable it +* @return void */ public function useDebug($value = true) { @@ -586,6 +590,7 @@ public function useDebug($value = true) /** * @param array $logMethods +* @return void */ public function setLogMethods($logMethods) { @@ -612,6 +617,7 @@ protected function isLogEnabledForMethod($methodName) /** * {@inheritDoc} +* @return void */ public function setLogger(LoggerInterface $logger) { @@ -637,6 +643,7 @@ public function getLogger() * Logs the method call or the executed SQL statement. * * @param string $msg Message to log. +* @return void */ public function log($msg) { diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index 0c66610859..ddb2b010a0 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -91,7 +91,7 @@ public function setAttribute($attribute, $value) } /** - * {@inheritDoc} + * @inheritDoc */ public function getDataFetcher($data) { @@ -99,7 +99,7 @@ public function getDataFetcher($data) } /** - * {@inheritDoc} + * @inheritDoc */ public function getSingleDataFetcher($data) { @@ -107,7 +107,7 @@ public function getSingleDataFetcher($data) } /** - * {@inheritDoc} + * @inheritDoc */ public function query($statement) { @@ -115,7 +115,7 @@ public function query($statement) } /** - * {@inheritDoc} + * @inheritDoc */ public function exec($statement) { diff --git a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php index 1bb99a4574..30cf6ad2c1 100644 --- a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php @@ -38,6 +38,7 @@ class ProfilerConnectionWrapper extends ConnectionWrapper /** * @param \Propel\Runtime\Util\Profiler $profiler +* @return void */ public function setProfiler(Profiler $profiler) { @@ -77,7 +78,7 @@ public function setAttribute($attribute, $value) } /** - * {@inheritDoc} + * @inheritDoc */ public function prepare($statement, $driver_options = null) { @@ -87,7 +88,7 @@ public function prepare($statement, $driver_options = null) } /** - * {@inheritDoc} + * @inheritDoc */ public function exec($sql) { @@ -97,7 +98,7 @@ public function exec($sql) } /** - * {@inheritDoc} + * @inheritDoc */ public function query($statement = '') { @@ -108,7 +109,7 @@ public function query($statement = '') } /** - * {@inheritDoc} + * @inheritDoc */ protected function createStatementWrapper($sql) { @@ -116,7 +117,7 @@ protected function createStatementWrapper($sql) } /** - * {@inheritDoc} + * @inheritDoc */ public function log($msg) { diff --git a/src/Propel/Runtime/Connection/StatementWrapper.php b/src/Propel/Runtime/Connection/StatementWrapper.php index 7e444871ad..bca7d9a0c4 100644 --- a/src/Propel/Runtime/Connection/StatementWrapper.php +++ b/src/Propel/Runtime/Connection/StatementWrapper.php @@ -313,6 +313,7 @@ public function getStatement() /** * @param \PDOStatement $statement +* @return void */ public function setStatement(\PDOStatement $statement) { diff --git a/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php b/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php index c2a93c13f3..396c386738 100644 --- a/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php @@ -22,6 +22,7 @@ public function __construct($dataObject) /** * {@inheritDoc} +* @return void */ public function setDataObject($dataObject) { @@ -29,7 +30,7 @@ public function setDataObject($dataObject) } /** - * {@inheritDoc} + * @inheritDoc */ public function getDataObject() { @@ -37,7 +38,7 @@ public function getDataObject() } /** - * {@inheritDoc} + * @inheritDoc */ public function fetchColumn($index = null) { diff --git a/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php b/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php index 61a31be931..b1e62fbc29 100644 --- a/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php @@ -18,6 +18,7 @@ class ArrayDataFetcher extends AbstractDataFetcher /** * {@inheritDoc} +* @return void */ public function next() { @@ -27,7 +28,7 @@ public function next() } /** - * {@inheritDoc} + * @inheritDoc */ public function current() { @@ -35,7 +36,7 @@ public function current() } /** - * {@inheritDoc} + * @inheritDoc */ public function fetch() { @@ -46,7 +47,7 @@ public function fetch() } /** - * {@inheritDoc} + * @inheritDoc */ public function key() { @@ -54,7 +55,7 @@ public function key() } /** - * {@inheritDoc} + * @inheritDoc */ public function valid() { @@ -63,6 +64,7 @@ public function valid() /** * {@inheritDoc} +* @return void */ public function rewind() { @@ -74,7 +76,7 @@ public function rewind() } /** - * {@inheritDoc} + * @inheritDoc */ public function getIndexType() { @@ -82,7 +84,7 @@ public function getIndexType() } /** - * {@inheritDoc} + * @inheritDoc */ public function count() { @@ -93,6 +95,7 @@ public function count() * Sets the current index type. * * @param string $indexType one of TableMap::TYPE_* +* @return void */ public function setIndexType($indexType) { @@ -101,6 +104,7 @@ public function setIndexType($indexType) /** * {@inheritDoc} +* @return void */ public function close() { diff --git a/src/Propel/Runtime/DataFetcher/PDODataFetcher.php b/src/Propel/Runtime/DataFetcher/PDODataFetcher.php index 06e5a17a0c..669c0e222d 100644 --- a/src/Propel/Runtime/DataFetcher/PDODataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/PDODataFetcher.php @@ -54,7 +54,7 @@ public function getStyle() { } /** - * {@inheritDoc} + * @inheritDoc */ public function fetch($style = null) { @@ -66,6 +66,7 @@ public function fetch($style = null) /** * {@inheritDoc} +* @return void */ public function next() { @@ -78,7 +79,7 @@ public function next() } /** - * {@inheritDoc} + * @inheritDoc */ public function current() { @@ -86,7 +87,7 @@ public function current() } /** - * {@inheritDoc} + * @inheritDoc */ public function key() { @@ -94,7 +95,7 @@ public function key() } /** - * {@inheritDoc} + * @inheritDoc */ public function valid() { @@ -105,6 +106,7 @@ public function valid() * Not supported in PDODataFetcher. * It actually fetches the first row, since a foreach in php triggers that * function as init. +* @return void */ public function rewind() { @@ -114,6 +116,7 @@ public function rewind() /** * {@inheritDoc} +* @return void */ public function close() { @@ -124,7 +127,7 @@ public function close() } /** - * {@inheritDoc} + * @inheritDoc */ public function count() { @@ -149,7 +152,7 @@ public function count() } /** - * {@inheritDoc} + * @inheritDoc */ public function getIndexType() { @@ -166,6 +169,7 @@ public function getIndexType() * @param int $type * @param int $maxlen * @param mixed $driverdata +* @return void */ public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null) { diff --git a/src/Propel/Runtime/Formatter/AbstractFormatter.php b/src/Propel/Runtime/Formatter/AbstractFormatter.php index 12dad187f8..32d5826456 100644 --- a/src/Propel/Runtime/Formatter/AbstractFormatter.php +++ b/src/Propel/Runtime/Formatter/AbstractFormatter.php @@ -80,6 +80,7 @@ public function __construct(BaseModelCriteria $criteria = null, DataFetcherInter * Sets a DataFetcherInterface object. * * @param DataFetcherInterface $dataFetcher +* @return void */ public function setDataFetcher(DataFetcherInterface $dataFetcher) { diff --git a/src/Propel/Runtime/Map/ColumnMap.php b/src/Propel/Runtime/Map/ColumnMap.php index 14be72c74c..e991c2e2d7 100644 --- a/src/Propel/Runtime/Map/ColumnMap.php +++ b/src/Propel/Runtime/Map/ColumnMap.php @@ -151,6 +151,7 @@ public function getFullyQualifiedName() * Set the php name of this column. * * @param string $phpName A string representing the PHP name. +* @return void */ public function setPhpName($phpName) { @@ -171,6 +172,7 @@ public function getPhpName() * Set the Propel type of this column. * * @param string $type A string representing the Propel type (e.g. PropelTypes::DATE). +* @return void */ public function setType($type) { @@ -275,6 +277,7 @@ public function isText() * Set the size of this column. * * @param int $size An int specifying the size. +* @return void */ public function setSize($size) { @@ -295,6 +298,7 @@ public function getSize() * Set if this column is a primary key or not. * * @param boolean $pk True if column is a primary key. +* @return void */ public function setPrimaryKey($pk) { @@ -315,6 +319,7 @@ public function isPrimaryKey() * Set if this column may be null. * * @param boolean $nn True if column may be null. +* @return void */ public function setNotNull($nn) { @@ -335,6 +340,7 @@ public function isNotNull() * Sets the default value for this column. * * @param mixed $defaultValue the default value for the column +* @return void */ public function setDefaultValue($defaultValue) { @@ -355,6 +361,7 @@ public function getDefaultValue() * * @param string $tableName The name of the table that is foreign. * @param string $columnName The name of the column that is foreign. +* @return void */ public function setForeignKey($tableName, $columnName) { @@ -457,6 +464,7 @@ public function getRelatedColumn() * Set the valueSet of this column (only valid for ENUM and SET columns). * * @param array $values A list of allowed values +* @return void */ public function setValueSet($values) { @@ -530,6 +538,7 @@ public static function normalizeName($name) * Set this column to be a primaryString column. * * @param boolean $pkString +* @return void */ public function setPrimaryString($pkString) { diff --git a/src/Propel/Runtime/Map/DatabaseMap.php b/src/Propel/Runtime/Map/DatabaseMap.php index 55931dd6e9..b6d0b63a64 100644 --- a/src/Propel/Runtime/Map/DatabaseMap.php +++ b/src/Propel/Runtime/Map/DatabaseMap.php @@ -85,6 +85,7 @@ public function addTable($tableName) * Add a new table object to the database. * * @param \Propel\Runtime\Map\TableMap $table The table to add +* @return void */ public function addTableObject(TableMap $table) { diff --git a/src/Propel/Runtime/Map/RelationMap.php b/src/Propel/Runtime/Map/RelationMap.php index 98210c78c6..41c87d8536 100644 --- a/src/Propel/Runtime/Map/RelationMap.php +++ b/src/Propel/Runtime/Map/RelationMap.php @@ -92,6 +92,7 @@ public function isPolymorphic() /** * @param boolean $polymorphic +* @return void */ public function setPolymorphic($polymorphic) { @@ -132,6 +133,7 @@ public function getPluralName() * Set the type * * @param int $type The relation type (either self::MANY_TO_ONE, self::ONE_TO_MANY, or self::ONE_TO_ONE) +* @return void */ public function setType($type) { @@ -152,6 +154,7 @@ public function getType() * Set the local table * * @param \Propel\Runtime\Map\TableMap $table The local table for this relationship +* @return void */ public function setLocalTable(TableMap $table) { @@ -172,6 +175,7 @@ public function getLocalTable() * Set the foreign table * * @param \Propel\Runtime\Map\TableMap $table The foreign table for this relationship +* @return void */ public function setForeignTable($table) { @@ -213,6 +217,7 @@ public function getRightTable() * * @param ColumnMap $local The local column * @param ColumnMap|mixed $foreign The foreign column or value +* @return void */ public function addColumnMapping(ColumnMap $local, $foreign) { @@ -327,6 +332,7 @@ public function getLocalValues() * Set the onUpdate behavior * * @param string $onUpdate +* @return void */ public function setOnUpdate($onUpdate) { @@ -347,6 +353,7 @@ public function getOnUpdate() * Set the onDelete behavior * * @param string $onDelete +* @return void */ public function setOnDelete($onDelete) { diff --git a/src/Propel/Runtime/Map/TableMap.php b/src/Propel/Runtime/Map/TableMap.php index a257e1dc1a..ba2d3eadfd 100644 --- a/src/Propel/Runtime/Map/TableMap.php +++ b/src/Propel/Runtime/Map/TableMap.php @@ -238,6 +238,7 @@ public function getName() * Set the PHP name of the Table. * * @param string $phpName The PHP Name for this table +* @return void */ public function setPhpName($phpName) { @@ -259,6 +260,7 @@ public function getPhpName() * tableMap and Object methods dynamically. * * @param string $classname The ClassName +* @return void */ public function setClassName($classname) { @@ -294,6 +296,7 @@ public function getCollectionClassName() * Set the Package of the Table * * @param string $package The Package +* @return void */ public function setPackage($package) { @@ -314,6 +317,7 @@ public function getPackage() * Set whether or not to use Id generator for primary key. * * @param boolean $bit +* @return void */ public function setUseIdGenerator($bit) { @@ -334,6 +338,7 @@ public function isUseIdGenerator() * Set whether or not to this table uses single table inheritance * * @param boolean $bit +* @return void */ public function setSingleTableInheritance($bit) { @@ -354,6 +359,7 @@ public function isSingleTableInheritance() * Sets the name of the sequence used to generate a key * * @param mixed $pkInfo information needed to generate a key +* @return void */ public function setPrimaryKeyMethodInfo($pkInfo) { @@ -592,6 +598,7 @@ public function isCrossRef() * Set the isCrossRef * @param boolean $isCrossRef +* @return void */ public function setIsCrossRef($isCrossRef) { @@ -622,6 +629,7 @@ public function getForeignKeys() * Build relations * Relations are lazy loaded for performance reasons * This method should be overridden by descendants +* @return void */ public function buildRelations() { @@ -797,6 +805,7 @@ public function isIdentifierQuotingEnabled() /** * @param boolean $identifierQuoting +* @return void */ public function setIdentifierQuoting($identifierQuoting) { diff --git a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php index 9f69806f0a..7fb6ffe524 100644 --- a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php +++ b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php @@ -93,6 +93,7 @@ public function getDefaultDatasource() /** * @param string $defaultDatasource +* @return void */ public function setDefaultDatasource($defaultDatasource) { @@ -122,6 +123,7 @@ public function getAdapterClass($name = null) * * @param string $name The datasource name * @param string $adapterClass +* @return void */ public function setAdapterClass($name, $adapterClass) { @@ -133,6 +135,7 @@ public function setAdapterClass($name, $adapterClass) * Reset existing adapters classes and set new classes for all datasources. * * @param string[] $adapterClasses A list of adapters +* @return void */ public function setAdapterClasses($adapterClasses) { @@ -171,6 +174,7 @@ public function getAdapter($name = null) * * @param string $name The datasource name * @param \Propel\Runtime\Adapter\AdapterInterface $adapter +* @return void */ public function setAdapter($name, AdapterInterface $adapter) { @@ -182,6 +186,7 @@ public function setAdapter($name, AdapterInterface $adapter) * Reset existing adapters and set new adapters for all datasources. * * @param array $adapters A list of adapters +* @return void */ public function setAdapters($adapters) { @@ -214,6 +219,7 @@ public function checkVersion($generatorVersion) /** * @param string $databaseMapClass +* @return void */ public function setDatabaseMapClass($databaseMapClass) { @@ -247,6 +253,7 @@ public function getDatabaseMap($name = null) * * @param string $name The datasource name * @param \Propel\Runtime\Map\DatabaseMap $databaseMap +* @return void */ public function setDatabaseMap($name, DatabaseMap $databaseMap) { @@ -256,6 +263,7 @@ public function setDatabaseMap($name, DatabaseMap $databaseMap) /** * @param string $name The datasource name * @param \Propel\Runtime\Connection\ConnectionManagerInterface $manager +* @return void */ public function setConnectionManager($name, ConnectionManagerInterface $manager) { @@ -380,6 +388,7 @@ public function getReadConnection($name) * * @param string $name The datasource name * @param \Propel\Runtime\Connection\ConnectionInterface $connection A database connection +* @return void */ public function setConnection($name, ConnectionInterface $connection) { @@ -395,6 +404,7 @@ public function setConnection($name, ConnectionInterface $connection) * getProfiler() is called. * * @param string $profilerClass +* @return void */ public function setProfilerClass($profilerClass) { @@ -407,6 +417,7 @@ public function setProfilerClass($profilerClass) * @see \Propel\Runtime\Util\Profiler::setConfiguration() * * @param array $profilerConfiguration +* @return void */ public function setProfilerConfiguration($profilerConfiguration) { @@ -418,6 +429,7 @@ public function setProfilerConfiguration($profilerConfiguration) * Set the profiler instance. * * @param \Propel\Runtime\Util\Profiler $profiler +* @return void */ public function setProfiler($profiler) { @@ -463,6 +475,7 @@ public function getLogger($name = 'defaultLogger') /** * @param string $name the name of the logger to be set * @param LoggerInterface $logger A logger instance +* @return void */ public function setLogger($name, LoggerInterface $logger) { @@ -535,6 +548,7 @@ protected function buildLogger($name = 'defaultLogger') * * @param string $name * @param array $loggerConfiguration +* @return void */ public function setLoggerConfiguration($name, $loggerConfiguration) { diff --git a/src/Propel/Runtime/Util/Profiler.php b/src/Propel/Runtime/Util/Profiler.php index 26fba7c865..a67c6d2203 100644 --- a/src/Propel/Runtime/Util/Profiler.php +++ b/src/Propel/Runtime/Util/Profiler.php @@ -63,6 +63,7 @@ public function __construct($slowTreshold = 0.1, $innerGlue = ': ', $outerGlue = * Set the duration which triggers the 'slow' label on details. * * @param integer $slowTreshold duration in seconds +* @return void */ public function setSlowTreshold($slowTreshold) { @@ -73,6 +74,7 @@ public function setSlowTreshold($slowTreshold) * Set the list of details to be included in a profile. * * @param array $details +* @return void */ public function setDetails($details) { @@ -83,6 +85,7 @@ public function setDetails($details) * Set the inner glue for the details. * * @param string $innerGlue +* @return void */ public function setInnerGlue($innerGlue) { @@ -93,6 +96,7 @@ public function setInnerGlue($innerGlue) * Set the outer glue for the details. * * @param string $outerGlue +* @return void */ public function setOuterGlue($outerGlue) { @@ -134,6 +138,7 @@ public function setOuterGlue($outerGlue) * * * @param array $profilerConfiguration +* @return void */ public function setConfiguration($profilerConfiguration) { diff --git a/src/Propel/Runtime/Util/PropelDateTime.php b/src/Propel/Runtime/Util/PropelDateTime.php index 50bb90932a..12108f7c88 100644 --- a/src/Propel/Runtime/Util/PropelDateTime.php +++ b/src/Propel/Runtime/Util/PropelDateTime.php @@ -161,6 +161,7 @@ public function __sleep() /** * PHP "magic" function called when object is restored from serialized state. * Calls DateTime constructor with previously stored string value of date. +* @return void */ public function __wakeup() { diff --git a/src/Propel/Runtime/Util/PropelModelPager.php b/src/Propel/Runtime/Util/PropelModelPager.php index 6aa22b1d63..b3c4560d2e 100644 --- a/src/Propel/Runtime/Util/PropelModelPager.php +++ b/src/Propel/Runtime/Util/PropelModelPager.php @@ -279,6 +279,7 @@ public function getNbResults() * Set the total number of results of the query * * @param int $nb +* @return void */ protected function setNbResults($nb) { @@ -329,6 +330,7 @@ public function getLastPage() * Set the number of the first page * * @param int $page +* @return void */ protected function setLastPage($page) { @@ -352,6 +354,7 @@ public function getPage() * Set the number of the current page * * @param int $page +* @return void */ public function setPage($page) { @@ -396,6 +399,7 @@ public function getMaxPerPage() * Set the maximum number results per page * * @param int $max +* @return void */ public function setMaxPerPage($max) { From 9dab0cf20996b0d08c6030ccee5846c9b238bb46 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 23 Jul 2020 16:35:48 +0200 Subject: [PATCH 123/208] Fix CS and more missing return type docs. --- .../Behavior/AutoAddPk/AutoAddPkBehavior.php | 4 +- .../Behavior/Delegate/DelegateBehavior.php | 2 +- .../Behavior/NestedSet/NestedSetBehavior.php | 2 +- .../Behavior/Sluggable/SluggableBehavior.php | 4 +- .../Behavior/Sortable/SortableBehavior.php | 2 +- .../Timestampable/TimestampableBehavior.php | 2 +- .../Behavior/Validate/ValidateBehavior.php | 12 +- .../Generator/Builder/DataModelBuilder.php | 2 +- .../Builder/Om/AbstractOMBuilder.php | 4 +- .../Builder/Om/ExtensionObjectBuilder.php | 2 +- .../Builder/Om/ExtensionQueryBuilder.php | 4 +- .../Om/ExtensionQueryInheritanceBuilder.php | 4 +- .../Generator/Builder/Om/InterfaceBuilder.php | 2 +- .../Builder/Om/MultiExtendObjectBuilder.php | 2 +- .../Generator/Builder/Om/ObjectBuilder.php | 112 +++++++++--------- .../Generator/Builder/Om/QueryBuilder.php | 28 +++-- .../Builder/Om/QueryInheritanceBuilder.php | 4 +- .../Generator/Builder/Om/TableMapBuilder.php | 2 +- .../Generator/Builder/Util/PropelTemplate.php | 4 +- .../Command/Console/Input/ArrayInput.php | 6 +- .../Command/Helper/ConsoleHelper3.php | 2 +- .../Command/Helper/ConsoleHelperInterface.php | 3 + .../Generator/Manager/AbstractManager.php | 19 +-- .../Generator/Manager/MigrationManager.php | 4 +- src/Propel/Generator/Manager/ModelManager.php | 2 +- .../Generator/Manager/ReverseManager.php | 10 +- src/Propel/Generator/Manager/SqlManager.php | 9 +- src/Propel/Generator/Model/Behavior.php | 16 +-- src/Propel/Generator/Model/Column.php | 58 ++++----- .../Generator/Model/ColumnDefaultValue.php | 4 +- .../Generator/Model/CrossForeignKeys.php | 8 +- src/Propel/Generator/Model/Database.php | 34 +++--- .../Generator/Model/Diff/ColumnDiff.php | 6 +- .../Model/Diff/DatabaseComparator.php | 10 +- .../Generator/Model/Diff/DatabaseDiff.php | 22 ++-- .../Generator/Model/Diff/TableComparator.php | 4 +- src/Propel/Generator/Model/Diff/TableDiff.php | 68 +++++------ src/Propel/Generator/Model/Domain.php | 30 ++--- src/Propel/Generator/Model/ForeignKey.php | 24 ++-- .../Generator/Model/IdMethodParameter.php | 6 +- src/Propel/Generator/Model/Index.php | 10 +- src/Propel/Generator/Model/Inheritance.php | 18 +-- src/Propel/Generator/Model/MappingModel.php | 2 +- src/Propel/Generator/Model/Schema.php | 10 +- .../Generator/Model/ScopedMappingModel.php | 4 +- src/Propel/Generator/Model/Table.php | 60 +++++----- src/Propel/Generator/Model/VendorInfo.php | 6 +- .../Generator/Platform/DefaultPlatform.php | 10 +- .../Generator/Platform/MssqlPlatform.php | 2 +- .../Generator/Platform/MysqlPlatform.php | 6 +- .../Generator/Platform/OraclePlatform.php | 2 +- .../Generator/Platform/PgsqlPlatform.php | 2 +- .../Generator/Platform/SqlitePlatform.php | 2 +- .../Reverse/AbstractSchemaParser.php | 8 +- .../Generator/Reverse/MssqlSchemaParser.php | 8 +- .../Generator/Reverse/MysqlSchemaParser.php | 10 +- .../Generator/Reverse/OracleSchemaParser.php | 8 +- .../Generator/Reverse/PgsqlSchemaParser.php | 10 +- .../Generator/Reverse/SqliteSchemaParser.php | 4 +- .../Generator/Schema/Dumper/XmlDumper.php | 22 ++-- src/Propel/Generator/Util/QuickBuilder.php | 14 +-- src/Propel/Generator/Util/SqlParser.php | 2 +- src/Propel/Runtime/ActiveQuery/Criteria.php | 14 ++- .../Criterion/AbstractCriterion.php | 13 +- .../ActiveQuery/Criterion/BasicCriterion.php | 2 +- .../Criterion/BasicModelCriterion.php | 2 +- .../ActiveQuery/Criterion/BinaryCriterion.php | 2 +- .../Criterion/BinaryModelCriterion.php | 2 +- .../ActiveQuery/Criterion/CustomCriterion.php | 2 +- .../ActiveQuery/Criterion/InCriterion.php | 2 +- .../Criterion/InModelCriterion.php | 2 +- .../ActiveQuery/Criterion/LikeCriterion.php | 2 +- .../Criterion/LikeModelCriterion.php | 2 +- .../ActiveQuery/Criterion/RawCriterion.php | 2 +- .../Criterion/RawModelCriterion.php | 2 +- .../Criterion/SeveralModelCriterion.php | 8 +- src/Propel/Runtime/ActiveQuery/Join.php | 24 ++-- .../Runtime/ActiveQuery/ModelCriteria.php | 6 +- src/Propel/Runtime/ActiveQuery/ModelWith.php | 2 +- .../Runtime/Adapter/AdapterInterface.php | 1 + .../Runtime/Adapter/Pdo/MssqlAdapter.php | 4 +- .../Runtime/Adapter/Pdo/MysqlAdapter.php | 6 +- .../Runtime/Adapter/Pdo/OracleAdapter.php | 4 +- src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php | 8 +- .../Runtime/Adapter/Pdo/PgsqlAdapter.php | 3 +- .../Runtime/Adapter/Pdo/SqliteAdapter.php | 4 +- .../Runtime/Adapter/Pdo/SqlsrvAdapter.php | 6 +- .../Runtime/Collection/ArrayCollection.php | 6 +- src/Propel/Runtime/Collection/Collection.php | 22 ++-- .../Runtime/Collection/ObjectCollection.php | 16 +-- .../Runtime/Collection/OnDemandCollection.php | 12 +- .../Runtime/Collection/OnDemandIterator.php | 4 +- .../Connection/ConnectionManagerInterface.php | 1 + .../ConnectionManagerMasterSlave.php | 2 +- .../ConnectionManagerPrimaryReplica.php | 8 +- .../Connection/ConnectionManagerSingle.php | 2 +- .../Runtime/Connection/ConnectionWrapper.php | 14 +-- .../Connection/ProfilerConnectionWrapper.php | 4 +- .../Runtime/Connection/StatementWrapper.php | 2 +- .../DataFetcher/AbstractDataFetcher.php | 2 +- .../Runtime/DataFetcher/ArrayDataFetcher.php | 8 +- .../Runtime/DataFetcher/PDODataFetcher.php | 8 +- .../Runtime/Formatter/AbstractFormatter.php | 2 +- .../Runtime/Formatter/ArrayFormatter.php | 2 +- .../Runtime/Formatter/OnDemandFormatter.php | 2 +- src/Propel/Runtime/Map/ColumnMap.php | 23 ++-- src/Propel/Runtime/Map/DatabaseMap.php | 2 +- src/Propel/Runtime/Map/RelationMap.php | 14 +-- src/Propel/Runtime/Map/TableMap.php | 18 +-- src/Propel/Runtime/Parser/CsvParser.php | 10 +- .../StandardServiceContainer.php | 28 ++--- src/Propel/Runtime/Util/Profiler.php | 14 +-- src/Propel/Runtime/Util/PropelDateTime.php | 2 +- src/Propel/Runtime/Util/PropelModelPager.php | 8 +- 114 files changed, 574 insertions(+), 550 deletions(-) diff --git a/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php b/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php index 25308ade2e..3dd0908d27 100644 --- a/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php +++ b/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php @@ -29,7 +29,7 @@ class AutoAddPkBehavior extends Behavior /** * Copy the behavior to the database tables * Only for tables that have no Pk -* @return void + * @return void */ public function modifyDatabase() { @@ -43,7 +43,7 @@ public function modifyDatabase() /** * Add the primary key to the current table -* @return void + * @return void */ public function modifyTable() { diff --git a/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php b/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php index 12a2f4a81a..6601122ca6 100644 --- a/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php +++ b/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php @@ -43,7 +43,7 @@ class DelegateBehavior extends Behavior /** * Lists the delegates and checks that the behavior can use them, * And adds a fk from the delegate to the main table if not already set -* @return void + * @return void */ public function modifyTable() { diff --git a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php index 227887e7ec..56a6233958 100644 --- a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php +++ b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php @@ -35,7 +35,7 @@ class NestedSetBehavior extends Behavior /** * Add the left, right and scope to the current table -* @return void + * @return void */ public function modifyTable() { diff --git a/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php b/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php index fbbb32392b..e442b9c9ea 100644 --- a/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php +++ b/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php @@ -45,7 +45,7 @@ class SluggableBehavior extends Behavior /** * Adds the slug_column to the current table. * -* @return void + * @return void */ public function modifyTable() { @@ -69,7 +69,7 @@ public function modifyTable() * Adds a unique constraint to the table to enforce uniqueness of the slug_column * * @param Table $table -* @return void + * @return void */ protected function addUniqueConstraint(Table $table) { diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php b/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php index bef56890dd..697103f259 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php @@ -34,7 +34,7 @@ class SortableBehavior extends Behavior /** * Add the rank_column to the current table -* @return void + * @return void */ public function modifyTable() { diff --git a/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php b/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php index 357b7096ea..24bba7d0ee 100644 --- a/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php +++ b/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php @@ -45,7 +45,7 @@ protected function withCreatedAt() /** * Add the create_column and update_columns to the current table -* @return void + * @return void */ public function modifyTable() { diff --git a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php index a2e3f79da3..7f8d3132cf 100644 --- a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php +++ b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php @@ -19,7 +19,7 @@ * Validate a model object using Symfony2 Validator component * * @author Cristiano Cinotti -*/ + */ class ValidateBehavior extends Behavior { /** @@ -79,7 +79,7 @@ public function objectAttributes() * Returns the parameters associated with a given column. * Useful for i18n behavior * - * @param string $columnName The column name + * @param string|null $columnName The column name * @return array The array of parameters associated to given column */ public function getParametersFromColumnName($columnName = null) @@ -101,8 +101,8 @@ public function getParametersFromColumnName($columnName = null) * Remove parameters associated with given column. * Useful for i18n behavior * - * @param string $columnName The column name -* @return void + * @param string|null $columnName The column name + * @return void */ public function removeParametersFromColumnName($columnName = null) { @@ -146,7 +146,7 @@ public function addRuleOnPk() * Merge $paramArray array into parameters array. * This method avoid that there are rules with the same name, when adding parameters programmatically. * Useful for Concrete Inheritance behavior. -* @return void + * @return void */ public function mergeParameters(array $params = null) { @@ -170,7 +170,7 @@ public function mergeParameters(array $params = null) /** * Convert those parameters, containing an array in YAML format * into a php array -* @return void + * @return void */ protected function cleanupParameters() { diff --git a/src/Propel/Generator/Builder/DataModelBuilder.php b/src/Propel/Generator/Builder/DataModelBuilder.php index 33adefdd60..749301740b 100644 --- a/src/Propel/Generator/Builder/DataModelBuilder.php +++ b/src/Propel/Generator/Builder/DataModelBuilder.php @@ -402,7 +402,7 @@ public function getBuildProperty($name) * Sets the GeneratorConfig object. * * @param GeneratorConfigInterface $v -* @return void + * @return void */ public function setGeneratorConfig(GeneratorConfigInterface $v) { diff --git a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php index a6703d02e8..09754a6358 100644 --- a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php @@ -771,7 +771,7 @@ protected function getCrossFKAddMethodInformation(CrossForeignKeys $crossFKs, $c * @param array $shortSignature * @param array $normalizedShortSignature * @param array $phpDoc -* @return void + * @return void */ protected function extractCrossInformation( CrossForeignKeys $crossFKs, @@ -952,7 +952,7 @@ public function hasBehaviorModifier($hookName, $modifier) * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string $modifier The name of the modifier object providing the method in the behavior * @param string $script The script will be modified in this method. -* @return void + * @return void */ public function applyBehaviorModifierBase($hookName, $modifier, &$script, $tab = " ") { diff --git a/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php index 1e79f2ecfb..3483c0c257 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php @@ -75,7 +75,7 @@ protected function addClassOpen(&$script) * if you want to change that behavior. * * @see ObjectBuilder::addClassBody() -* @return void + * @return void */ protected function addClassBody(&$script) { diff --git a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php index 96f340c029..17c5a3dd7d 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php @@ -76,7 +76,7 @@ class ".$this->getUnqualifiedClassName()." extends $baseClassName * if you want to change that behavior. * * @see QueryBuilder::addClassBody() -* @return void + * @return void */ protected function addClassBody(&$script) @@ -111,7 +111,7 @@ public function hasBehaviorModifier($hookName, $modifier = '') * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string $script The script will be modified in this method. * @param string $tab -* @return void + * @return void */ public function applyBehaviorModifier($hookName, &$script, $tab = " ") { diff --git a/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php index 59c22c3a6f..becf9e51cf 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php @@ -53,7 +53,7 @@ public function getPackage() * Set the child object that we're operating on currently. * * @param Inheritance $child Inheritance -* @return void + * @return void */ public function setChild(Inheritance $child) { @@ -126,7 +126,7 @@ class " .$this->getUnqualifiedClassName() . " extends " . $baseClassName . " * * @param string $script * @see ObjectBuilder::addClassBody() -* @return void + * @return void */ protected function addClassBody(&$script) { diff --git a/src/Propel/Generator/Builder/Om/InterfaceBuilder.php b/src/Propel/Generator/Builder/Om/InterfaceBuilder.php index b1865e5a24..da7f42764a 100644 --- a/src/Propel/Generator/Builder/Om/InterfaceBuilder.php +++ b/src/Propel/Generator/Builder/Om/InterfaceBuilder.php @@ -73,7 +73,7 @@ interface ".$this->getUnqualifiedClassName()." * if you want to change that behavior. * * @see ObjectBuilder::addClassBody() -* @return void + * @return void */ protected function addClassBody(&$script) { diff --git a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php index 92f690107f..a04ddadb9c 100644 --- a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php @@ -55,7 +55,7 @@ public function getPackage() * Sets the child object that we're operating on currently. * * @param Inheritance $child Inheritance -* @return void + * @return void */ public function setChild(Inheritance $child) { diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index f699e1407f..46c81beb97 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -264,7 +264,7 @@ abstract class ".$this->getUnqualifiedClassName().$parentClass." implements Acti * * @param string $script * @see ObjectBuilder::addClassBody() -* @return void + * @return void */ protected function addClassBody(&$script) { @@ -820,7 +820,7 @@ protected function addTemporalAccessor(&$script, Column $column) * * @param string $script * @param Column $column -* @return void + * @return void */ public function addTemporalAccessorComment(&$script, Column $column) { @@ -1835,7 +1835,7 @@ protected function addMutatorCloseBody(&$script, Column $column) * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see addMutatorClose() -* @return void + * @return void */ protected function addMutatorCloseClose(&$script, Column $col) { @@ -1878,7 +1878,7 @@ protected function addLobMutator(&$script, Column $col) * @param string $script The script will be modified in this method. * @param Column $col The current column. * @see parent::addColumnMutators() -* @return void + * @return void */ protected function addTemporalMutator(&$script, Column $col) { @@ -2332,7 +2332,7 @@ protected function addHasOnlyDefaultValues(&$script) * Adds the comment for the hasOnlyDefaultValues method * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues -* @return void + * @return void */ protected function addHasOnlyDefaultValuesComment(&$script) { @@ -2351,7 +2351,7 @@ protected function addHasOnlyDefaultValuesComment(&$script) * Adds the function declaration for the hasOnlyDefaultValues method * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues -* @return void + * @return void */ protected function addHasOnlyDefaultValuesOpen(&$script) { @@ -2364,7 +2364,7 @@ public function hasOnlyDefaultValues() * Adds the function body for the hasOnlyDefaultValues method * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues -* @return void + * @return void */ protected function addHasOnlyDefaultValuesBody(&$script) { @@ -2397,7 +2397,7 @@ protected function addHasOnlyDefaultValuesBody(&$script) * Adds the function close for the hasOnlyDefaultValues method * @param string $script The script will be modified in this method. * @see addHasOnlyDefaultValues -* @return void + * @return void */ protected function addHasOnlyDefaultValuesClose(&$script) { @@ -2468,7 +2468,7 @@ public function hydrate(\$row, \$startcol = 0, \$rehydrate = false, \$indexType * Adds the function body for the hydrate method * @param string $script The script will be modified in this method. * @see addHydrate() -* @return void + * @return void */ protected function addHydrateBody(&$script) { @@ -2605,7 +2605,7 @@ protected function addBuildPkeyCriteria(&$script) * Adds the comment for the buildPkeyCriteria method * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() -* @return void + * @return void */ protected function addBuildPkeyCriteriaComment(&$script) { @@ -2626,7 +2626,7 @@ protected function addBuildPkeyCriteriaComment(&$script) * Adds the function declaration for the buildPkeyCriteria method * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() -* @return void + * @return void */ protected function addBuildPkeyCriteriaOpen(&$script) { @@ -2639,7 +2639,7 @@ public function buildPkeyCriteria() * Adds the function body for the buildPkeyCriteria method * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() -* @return void + * @return void */ protected function addBuildPkeyCriteriaBody(&$script) { @@ -2663,7 +2663,7 @@ protected function addBuildPkeyCriteriaBody(&$script) * Adds the function close for the buildPkeyCriteria method * @param string $script The script will be modified in this method. * @see addBuildPkeyCriteria() -* @return void + * @return void */ protected function addBuildPkeyCriteriaClose(&$script) { @@ -2691,7 +2691,7 @@ protected function addBuildCriteria(&$script) * Adds comment for the buildCriteria method * @param string $script The script will be modified in this method. * @see addBuildCriteria() -* @return void + * @return void */ protected function addBuildCriteriaComment(&$script) { @@ -2707,7 +2707,7 @@ protected function addBuildCriteriaComment(&$script) * Adds the function declaration of the buildCriteria method * @param string $script The script will be modified in this method. * @see addBuildCriteria() -* @return void + * @return void */ protected function addBuildCriteriaOpen(&$script) { @@ -2720,7 +2720,7 @@ public function buildCriteria() * Adds the function body of the buildCriteria method * @param string $script The script will be modified in this method. * @see addBuildCriteria() -* @return void + * @return void */ protected function addBuildCriteriaBody(&$script) { @@ -2740,7 +2740,7 @@ protected function addBuildCriteriaBody(&$script) * Adds the function close of the buildCriteria method * @param string $script The script will be modified in this method. * @see addBuildCriteria() -* @return void + * @return void */ protected function addBuildCriteriaClose(&$script) { @@ -2905,7 +2905,7 @@ protected function addGetByName(&$script) * Adds the comment for the getByName method * @param string $script The script will be modified in this method. * @see addGetByName -* @return void + * @return void */ protected function addGetByNameComment(&$script) { @@ -2927,7 +2927,7 @@ protected function addGetByNameComment(&$script) * Adds the function declaration for the getByName method * @param string $script The script will be modified in this method. * @see addGetByName -* @return void + * @return void */ protected function addGetByNameOpen(&$script) { @@ -2941,7 +2941,7 @@ public function getByName(\$name, \$type = TableMap::$defaultKeyType) * Adds the function body for the getByName method * @param string $script The script will be modified in this method. * @see addGetByName -* @return void + * @return void */ protected function addGetByNameBody(&$script) { @@ -2954,7 +2954,7 @@ protected function addGetByNameBody(&$script) * Adds the function close for the getByName method * @param string $script The script will be modified in this method. * @see addGetByName -* @return void + * @return void */ protected function addGetByNameClose(&$script) { @@ -2982,7 +2982,7 @@ protected function addGetByPosition(&$script) * Adds comment for the getByPosition method * @param string $script The script will be modified in this method. * @see addGetByPosition -* @return void + * @return void */ protected function addGetByPositionComment(&$script) { @@ -3000,7 +3000,7 @@ protected function addGetByPositionComment(&$script) * Adds the function declaration for the getByPosition method * @param string $script The script will be modified in this method. * @see addGetByPosition -* @return void + * @return void */ protected function addGetByPositionOpen(&$script) { @@ -3013,7 +3013,7 @@ public function getByPosition(\$pos) * Adds the function body for the getByPosition method * @param string $script The script will be modified in this method. * @see addGetByPosition -* @return void + * @return void */ protected function addGetByPositionBody(&$script) { @@ -3040,7 +3040,7 @@ protected function addGetByPositionBody(&$script) * Adds the function close for the getByPosition method * @param string $script The script will be modified in this method. * @see addGetByPosition -* @return void + * @return void */ protected function addGetByPositionClose(&$script) { @@ -3246,7 +3246,7 @@ protected function addDelete(&$script) * Adds the comment for the delete function * @param string $script The script will be modified in this method. * @see addDelete() -* @return void + * @return void */ protected function addDeleteComment(&$script) { @@ -3267,7 +3267,7 @@ protected function addDeleteComment(&$script) * Adds the function declaration for the delete function * @param string $script The script will be modified in this method. * @see addDelete() -* @return void + * @return void */ protected function addDeleteOpen(&$script) { @@ -3280,7 +3280,7 @@ public function delete(ConnectionInterface \$con = null) * Adds the function body for the delete function * @param string $script The script will be modified in this method. * @see addDelete() -* @return void + * @return void */ protected function addDeleteBody(&$script) { @@ -3329,7 +3329,7 @@ protected function addDeleteBody(&$script) * Adds the function close for the delete function * @param string $script The script will be modified in this method. * @see addDelete() -* @return void + * @return void */ protected function addDeleteClose(&$script) { @@ -3589,7 +3589,7 @@ public function getPrimaryKey() * deprecated. * @param string $script The script will be modified in this method. * @deprecated -* @return void + * @return void */ protected function addGetPrimaryKey_NoPK(&$script) { @@ -3686,7 +3686,7 @@ public function setPrimaryKey(\$keys) * deprecated. * @param string $script The script will be modified in this method. * @deprecated -* @return void + * @return void */ protected function addSetPrimaryKey_NoPK(&$script) { @@ -3790,7 +3790,7 @@ protected function addFKMethods(&$script) * Adds the class attributes that are needed to store fkey related objects. * @param string $script The script will be modified in this method. * @param ForeignKey $fk -* @return void + * @return void */ protected function addFKAttributes(&$script, ForeignKey $fk) { @@ -3809,7 +3809,7 @@ protected function addFKAttributes(&$script, ForeignKey $fk) * Adds the mutator (setter) method for setting an fkey related object. * @param string $script The script will be modified in this method. * @param ForeignKey $fk -* @return void + * @return void */ protected function addFKMutator(&$script, ForeignKey $fk) { @@ -3895,7 +3895,7 @@ public function set".$this->getFKPhpNameAffix($fk, false)."($className \$v = nul * Adds the accessor (getter) method for getting an fkey related object. * @param string $script The script will be modified in this method. * @param ForeignKey $fk -* @return void + * @return void */ protected function addFKAccessor(&$script, ForeignKey $fk) { @@ -4001,7 +4001,7 @@ public function get".$this->getFKPhpNameAffix($fk, false)."(ConnectionInterface * Adds the method that fetches fkey-related (referencing) objects but also joins in data from another table. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK -* @return void + * @return void */ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK) { @@ -4072,7 +4072,7 @@ public function get".$relCol."Join".$relCol2."(Criteria \$criteria = null, Conne * private lastVarNameCriteria = null; * @param string $script The script will be modified in this method. * @param ForeignKey $refFK -* @return void + * @return void */ protected function addRefFKAttributes(&$script, ForeignKey $refFK) { @@ -4131,7 +4131,7 @@ protected function addRefFKMethods(&$script) /** * @param string $script * @param ForeignKey[] $referrers -* @return void + * @return void */ protected function addInitRelations(&$script, $referrers) { @@ -4167,7 +4167,7 @@ public function initRelation(\$relationName) * Adds the method that clears the referrer fkey collection. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK -* @return void + * @return void */ protected function addRefFKClear(&$script, ForeignKey $refFK) { @@ -4195,7 +4195,7 @@ public function clear$relCol() * Adds the method that initializes the referrer fkey collection. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK -* @return void + * @return void */ protected function addRefFKInit(&$script, ForeignKey $refFK) { @@ -4233,7 +4233,7 @@ public function init$relCol(\$overrideExisting = true) * Adds the method that adds an object into the referrer fkey collection. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK -* @return void + * @return void */ protected function addRefFKAdd(&$script, ForeignKey $refFK) { @@ -4281,7 +4281,7 @@ public function add".$this->getRefFKPhpNameAffix($refFK, false)."($className \$l * Adds the method that returns the size of the referrer fkey collection. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK -* @return void + * @return void */ protected function addRefFKCount(&$script, ForeignKey $refFK) { @@ -4333,7 +4333,7 @@ public function count{$relCol}(Criteria \$criteria = null, \$distinct = false, C * Adds the method that returns the referrer fkey collection. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK -* @return void + * @return void */ protected function addRefFKGet(&$script, ForeignKey $refFK) { @@ -4478,7 +4478,7 @@ public function set{$relatedName}(Collection \${$inputCollection}, ConnectionInt /** * @param string $script The script will be modified in this method. * @param ForeignKey $refFK -* @return void + * @return void */ protected function addRefFKDoAdd(&$script, ForeignKey $refFK) { @@ -4509,7 +4509,7 @@ protected function doAdd{$relatedObjectClassName}($className \${$lowerRelatedObj /** * @param string $script The script will be modified in this method. * @param ForeignKey $refFK -* @return void + * @return void */ protected function addRefFKRemove(&$script, ForeignKey $refFK) { @@ -4567,7 +4567,7 @@ public function remove{$relatedObjectClassName}($className \${$lowerRelatedObjec * This is for one-to-one relationship special case. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK -* @return void + * @return void */ protected function addPKRefFKGet(&$script, ForeignKey $refFK) { @@ -4603,7 +4603,7 @@ public function get".$this->getRefFKPhpNameAffix($refFK, false)."(ConnectionInte * This is for one-to-one relationships special case. * @param string $script The script will be modified in this method. * @param ForeignKey $refFK The referencing foreign key. -* @return void + * @return void */ protected function addPKRefFKSet(&$script, ForeignKey $refFK) { @@ -4766,7 +4766,7 @@ protected function addRefFkScheduledForDeletionAttribute(&$script, ForeignKey $r /** * @param string $script * @param CrossForeignKeys $crossFKs -* @return void + * @return void */ protected function addCrossFkScheduledForDeletion(&$script, CrossForeignKeys $crossFKs) { @@ -4991,7 +4991,7 @@ protected function addCrossFKMethods(&$script) * Adds the method that clears the referrer fkey collection. * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs -* @return void + * @return void */ protected function addCrossFKClear(&$script, CrossForeignKeys $crossFKs) { @@ -5020,7 +5020,7 @@ public function clear{$relCol}() * * @param string $script The script will be modified in this method. * @param ForeignKey $refFK -* @return void + * @return void */ protected function addRefFKPartial(&$script, ForeignKey $refFK) { @@ -5042,7 +5042,7 @@ public function resetPartial{$relCol}(\$v = true) * Adds the method that initializes the referrer fkey collection. * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs -* @return void + * @return void */ protected function addCrossFKInit(&$script, CrossForeignKeys $crossFKs) { @@ -5123,7 +5123,7 @@ public function init$relCol() * Adds the method that check if the referrer fkey collection is initialized. * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs -* @return void + * @return void */ protected function addCrossFKIsLoaded(&$script, CrossForeignKeys $crossFKs) { @@ -5447,7 +5447,7 @@ public function get{$relatedName}(Criteria \$criteria = null, ConnectionInterfac /** * @param string $script * @param CrossForeignKeys $crossFKs -* @return void + * @return void */ protected function addCrossFKSet(&$script, CrossForeignKeys $crossFKs) { @@ -5627,7 +5627,7 @@ public function count{$firstFkName}($signature, Criteria \$criteria = null, Conn * Adds the method that adds an object into the referrer fkey collection. * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs -* @return void + * @return void */ protected function addCrossFKAdd(&$script, CrossForeignKeys $crossFKs) { @@ -5698,7 +5698,7 @@ protected function getCrossFKGetterSignature(CrossForeignKeys $crossFKs, $exclud /** * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs -* @return void + * @return void */ protected function addCrossFKDoAdd(&$script, CrossForeignKeys $crossFKs) { @@ -5823,7 +5823,7 @@ protected function getCrossRefFKRemoveObjectNames(CrossForeignKeys $crossFKs, Fo * Adds the method that remove an object from the referrer fkey collection. * @param string $script The script will be modified in this method. * @param CrossForeignKeys $crossFKs -* @return void + * @return void */ protected function addCrossFKRemove(&$script, CrossForeignKeys $crossFKs) { @@ -6367,7 +6367,7 @@ protected function addSave(&$script) * Adds the comment for the save method * @param string $script The script will be modified in this method. * @see addSave() -* @return void + * @return void */ protected function addSaveComment(&$script) { diff --git a/src/Propel/Generator/Builder/Om/QueryBuilder.php b/src/Propel/Generator/Builder/Om/QueryBuilder.php index c5045e023b..c1220cffe4 100644 --- a/src/Propel/Generator/Builder/Om/QueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryBuilder.php @@ -228,7 +228,7 @@ abstract class ".$this->getUnqualifiedClassName()." extends " . $parentClass . " * if you want to change that behavior. * * @see ObjectBuilder::addClassBody() -* @return void + * @return void */ protected function addClassBody(&$script) { @@ -303,7 +303,7 @@ protected function addClassBody(&$script) /** * Adds the entityNotFoundExceptionClass property which is necessary for the `requireOne` method * of the `ModelCriteria` -* @return void + * @return void */ protected function addEntityNotFoundExceptionClass(&$script) { @@ -390,7 +390,7 @@ protected function addClassClose(&$script) * Adds the constructor for this object. * @param string $script The script will be modified in this method. * @see addConstructor() -* @return void + * @return void */ protected function addConstructor(&$script) { @@ -953,7 +953,7 @@ public function filterByPrimaryKeys(\$keys) * Adds the filterByCol method for this object. * @param string $script The script will be modified in this method. * @param Column $col -* @return void + * @return void */ protected function addFilterByCol(&$script, Column $col) { @@ -1175,7 +1175,7 @@ public function filterBy$colPhpName(\$$variableName = null, \$comparison = null) * Adds the singular filterByCol method for an Array column. * @param string $script The script will be modified in this method. * @param Column $col -* @return void + * @return void */ protected function addFilterByArrayCol(&$script, Column $col) { @@ -1223,7 +1223,7 @@ public function filterBy$singularPhpName(\$$variableName = null, \$comparison = * * @param string $script The script will be modified in this method. * @param Column $col -* @return void + * @return void */ protected function addFilterBySetCol(&$script, Column $col) { @@ -1250,7 +1250,7 @@ public function filterBy$singularPhpName(\$$variableName = null, \$comparison = * Adds the filterByFk method for this object. * @param string $script The script will be modified in this method. * @param ForeignKey $fk ForeignKey -* @return void + * @return void */ protected function addFilterByFk(&$script, $fk) { @@ -1335,7 +1335,7 @@ public function filterBy$relationName($objectName, \$comparison = null) * * @param string $script The script will be modified in this method. * @param ForeignKey $fk -* @return void + * @return void */ protected function addFilterByRefFk(&$script, ForeignKey $fk) { @@ -1407,7 +1407,7 @@ public function filterBy$relationName($objectName, \$comparison = null) * Adds the joinFk method for this object. * @param string $script The script will be modified in this method. * @param ForeignKey $fk ForeignKey -* @return void + * @return void */ protected function addJoinFk(&$script, $fk) { @@ -1422,7 +1422,7 @@ protected function addJoinFk(&$script, $fk) * Adds the joinRefFk method for this object. * @param string $script The script will be modified in this method. * @param ForeignKey $fk -* @return void + * @return void */ protected function addJoinRefFk(&$script, ForeignKey $fk) { @@ -1479,7 +1479,7 @@ public function join" . $relationName . "(\$relationAlias = null, \$joinType = " * Adds the useFkQuery method for this object. * @param string $script The script will be modified in this method. * @param ForeignKey $fk ForeignKey -* @return void + * @return void */ protected function addUseFkQuery(&$script, $fk) { @@ -1496,7 +1496,7 @@ protected function addUseFkQuery(&$script, $fk) * Adds the useFkQuery method for this object. * @param string $script The script will be modified in this method. * @param ForeignKey $fk -* @return void + * @return void */ protected function addUseRefFkQuery(&$script, ForeignKey $fk) { @@ -1783,7 +1783,9 @@ public function hasBehaviorModifier($hookName, $modifier = '') */ public function applyBehaviorModifier($hookName, &$script, $tab = " ") { - return $this->applyBehaviorModifierBase($hookName, 'QueryBuilderModifier', $script, $tab); + $this->applyBehaviorModifierBase($hookName, 'QueryBuilderModifier', $script, $tab); + + return $script; } /** diff --git a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php index fae26334cc..d32022de9b 100644 --- a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php @@ -69,7 +69,7 @@ public function getNamespace() * Sets the child object that we're operating on currently. * * @param Inheritance $child -* @return void + * @return void */ public function setChild(Inheritance $child) { @@ -165,7 +165,7 @@ class " .$this->getUnqualifiedClassName() . " extends " . $baseClassName . " * * @param string $script * @see ObjectBuilder::addClassBody() -* @return void + * @return void */ protected function addClassBody(&$script) { diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index c5694148cd..ea1ba2c069 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -781,7 +781,7 @@ public function hasBehaviorModifier($hookName, $modifier = '') * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string $script The script will be modified in this method. * @param string $tab -* @return void + * @return void */ public function applyBehaviorModifier($hookName, &$script, $tab = " ") { diff --git a/src/Propel/Generator/Builder/Util/PropelTemplate.php b/src/Propel/Generator/Builder/Util/PropelTemplate.php index 94264bfaca..0ccac20ef2 100644 --- a/src/Propel/Generator/Builder/Util/PropelTemplate.php +++ b/src/Propel/Generator/Builder/Util/PropelTemplate.php @@ -38,7 +38,7 @@ class PropelTemplate * * * @param string $template the template string -* @return void + * @return void */ public function setTemplate($template) { @@ -53,7 +53,7 @@ public function setTemplate($template) * * * @param string $filePath The (absolute or relative to the include path) file path -* @return void + * @return void */ public function setTemplateFile($filePath) { diff --git a/src/Propel/Generator/Command/Console/Input/ArrayInput.php b/src/Propel/Generator/Command/Console/Input/ArrayInput.php index 99b19e4b66..c5c43dc004 100644 --- a/src/Propel/Generator/Command/Console/Input/ArrayInput.php +++ b/src/Propel/Generator/Command/Console/Input/ArrayInput.php @@ -155,7 +155,7 @@ protected function parse() * Adds a short option value. * * @throws InvalidOptionException When option given doesn't exist -* @return void + * @return void */ private function addShortOption(string $shortcut, $value) { @@ -171,7 +171,7 @@ private function addShortOption(string $shortcut, $value) * * @throws InvalidOptionException When option given doesn't exist * @throws InvalidOptionException When a required value is missing -* @return void + * @return void */ private function addLongOption(string $name, $value) { @@ -201,7 +201,7 @@ private function addLongOption(string $name, $value) * @param mixed $value The value for the argument * * @throws InvalidArgumentException When argument given doesn't exist -* @return void + * @return void */ private function addArgument($name, $value) { diff --git a/src/Propel/Generator/Command/Helper/ConsoleHelper3.php b/src/Propel/Generator/Command/Helper/ConsoleHelper3.php index 4c6d9192cd..6f263d5553 100644 --- a/src/Propel/Generator/Command/Helper/ConsoleHelper3.php +++ b/src/Propel/Generator/Command/Helper/ConsoleHelper3.php @@ -149,7 +149,7 @@ public function setOutput(OutputInterface $output) */ public function writeln($messages, $options = 0) { - return $this->output->writeln($messages, $options); + $this->output->writeln($messages, $options); } /** diff --git a/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php b/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php index 985b6c347b..0af822a5fe 100644 --- a/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php +++ b/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php @@ -79,11 +79,13 @@ public function getInput(); /** * @param OutputInterface $output + * @return void */ public function setOutput(OutputInterface $output); /** * @param InputInterface $input + * @return void */ public function setInput(InputInterface $input); @@ -92,6 +94,7 @@ public function setInput(InputInterface $input); * * @param string|array $messages The message as an array of lines of a single string * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL + * @return void */ public function writeln($messages, $options = 0); } diff --git a/src/Propel/Generator/Manager/AbstractManager.php b/src/Propel/Generator/Manager/AbstractManager.php index 6de0ffab67..ddf24234ad 100644 --- a/src/Propel/Generator/Manager/AbstractManager.php +++ b/src/Propel/Generator/Manager/AbstractManager.php @@ -118,7 +118,7 @@ public function getSchemas() * Sets the schemas list. * * @param array $schemas -* @return void + * @return void */ public function setSchemas($schemas) { @@ -129,7 +129,7 @@ public function setSchemas($schemas) * Sets the working directory path. * * @param string $workingDirectory -* @return void + * @return void */ public function setWorkingDirectory($workingDirectory) { @@ -218,7 +218,7 @@ public function getDatabase($name) * Sets whether to perform validation on the datamodel schema.xml file(s). * * @param boolean $validate -* @return void + * @return void */ public function setValidate($validate) { @@ -230,7 +230,7 @@ public function setValidate($validate) * file(s). * * @param string $xsd -* @return void + * @return void */ public function setXsd($xsd) { @@ -242,7 +242,7 @@ public function setXsd($xsd) * file(s) before validation and parsing. * * @param mixed $xsl -* @return void + * @return void */ public function setXsl($xsl) { @@ -253,7 +253,7 @@ public function setXsl($xsl) * Sets the current target database encoding. * * @param string $encoding Target database encoding -* @return void + * @return void */ public function setDbEncoding($encoding) { @@ -264,7 +264,7 @@ public function setDbEncoding($encoding) * Sets a logger closure. * * @param \Closure $logger -* @return void + * @return void */ public function setLoggerClosure(\Closure $logger) { @@ -274,7 +274,7 @@ public function setLoggerClosure(\Closure $logger) /** * Returns all matching XML schema files and loads them into data models for * class. -* @return void + * @return void */ protected function loadDataModels() { @@ -364,6 +364,7 @@ protected function loadDataModels() * * @param \DOMDocument $dom * @param string $srcDir + * @return int */ protected function includeExternalSchemas(\DOMDocument $dom, $srcDir) { @@ -431,7 +432,7 @@ protected function getGeneratorConfig() * Sets the GeneratorConfigInterface implementation. * * @param GeneratorConfigInterface $generatorConfig -* @return void + * @return void */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) { diff --git a/src/Propel/Generator/Manager/MigrationManager.php b/src/Propel/Generator/Manager/MigrationManager.php index 330897a82a..0b485c1f1a 100644 --- a/src/Propel/Generator/Manager/MigrationManager.php +++ b/src/Propel/Generator/Manager/MigrationManager.php @@ -46,7 +46,7 @@ class MigrationManager extends AbstractManager * Set the database connection settings * * @param array $connections -* @return void + * @return void */ public function setConnections($connections) { @@ -112,7 +112,7 @@ public function getPlatform($datasource) * Set the migration table name * * @param string $migrationTable -* @return void + * @return void */ public function setMigrationTable($migrationTable) { diff --git a/src/Propel/Generator/Manager/ModelManager.php b/src/Propel/Generator/Manager/ModelManager.php index add594121d..7b4fba3263 100644 --- a/src/Propel/Generator/Manager/ModelManager.php +++ b/src/Propel/Generator/Manager/ModelManager.php @@ -31,7 +31,7 @@ class ModelManager extends AbstractManager * Sets the filesystem object. * * @param Filesystem $filesystem -* @return void + * @return void */ public function setFilesystem(Filesystem $filesystem) { diff --git a/src/Propel/Generator/Manager/ReverseManager.php b/src/Propel/Generator/Manager/ReverseManager.php index 9e8826a93a..0c9537bf17 100644 --- a/src/Propel/Generator/Manager/ReverseManager.php +++ b/src/Propel/Generator/Manager/ReverseManager.php @@ -88,7 +88,7 @@ public function getSchemaName() * Sets the name of a database schema to use (optional). * * @param string $schemaName -* @return void + * @return void */ public function setSchemaName($schemaName) { @@ -109,7 +109,7 @@ public function getNamespace() * Sets the php namespace to use (optional). * * @param string $namespace -* @return void + * @return void */ public function setNamespace($namespace) { @@ -132,7 +132,7 @@ public function getDatabaseName() * schema.xml * * @param string $databaseName -* @return void + * @return void */ public function setDatabaseName($databaseName) { @@ -143,7 +143,7 @@ public function setDatabaseName($databaseName) * Sets whether to use the column name as phpName without any translation. * * @param boolean $samePhpName -* @return void + * @return void */ public function setSamePhpName($samePhpName) { @@ -154,7 +154,7 @@ public function setSamePhpName($samePhpName) * Sets whether to add vendor info to the schema. * * @param boolean $addVendorInfo -* @return void + * @return void */ public function setAddVendorInfo($addVendorInfo) { diff --git a/src/Propel/Generator/Manager/SqlManager.php b/src/Propel/Generator/Manager/SqlManager.php index a465586cf9..17372b32ed 100644 --- a/src/Propel/Generator/Manager/SqlManager.php +++ b/src/Propel/Generator/Manager/SqlManager.php @@ -37,7 +37,7 @@ class SqlManager extends AbstractManager * Set the database connection settings * * @param array $connections -* @return void + * @return void */ public function setConnections($connections) { @@ -74,7 +74,7 @@ public function isOverwriteSqlMap() /** * @param boolean $overwriteSqlMap -* @return void + * @return void */ public function setOverwriteSqlMap($overwriteSqlMap) { @@ -107,7 +107,7 @@ public function getSqlDbMapFilename() /** * Build SQL files. -* @return void + * @return void */ public function buildSql() { @@ -144,7 +144,8 @@ public function existSqlMap() } /** - * @param string $datasource A datasource name. + * @param string|null $datasource A datasource name. + * @return bool */ public function insertSql($datasource = null) { diff --git a/src/Propel/Generator/Model/Behavior.php b/src/Propel/Generator/Model/Behavior.php index 6b14307748..ecbee3e7da 100644 --- a/src/Propel/Generator/Model/Behavior.php +++ b/src/Propel/Generator/Model/Behavior.php @@ -92,7 +92,7 @@ class Behavior extends MappingModel * Sets the name of the Behavior * * @param string $name the name of the behavior -* @return void + * @return void */ public function setName($name) { @@ -107,7 +107,7 @@ public function setName($name) * Sets the id of the Behavior * * @param string $id The id of the behavior -* @return void + * @return void */ public function setId($id) { @@ -149,7 +149,7 @@ public function getName() * Sets the table this behavior is applied to * * @param \Propel\Generator\Model\Table $table -* @return void + * @return void */ public function setTable(Table $table) { @@ -170,7 +170,7 @@ public function getTable() * Sets the database this behavior is applied to * * @param Database $database -* @return void + * @return void */ public function setDatabase(Database $database) { @@ -209,7 +209,7 @@ public function addParameter(array $parameter) * Expects an associative array looking like [ 'foo' => 'bar' ]. * * @param array $parameters -* @return void + * @return void */ public function setParameters(array $parameters) { @@ -245,7 +245,7 @@ public function getParameter($name) * Default is 50. * * @param integer $tableModificationOrder -* @return void + * @return void */ public function setTableModificationOrder($tableModificationOrder) { @@ -272,7 +272,7 @@ public function getTableModificationOrder() * * Propagates the behavior to the tables of the database and override this * method to have a database behavior do something special. -* @return void + * @return void */ public function modifyDatabase() { @@ -311,7 +311,7 @@ public function modifyTable() * Sets whether or not the table has been modified. * * @param boolean $modified -* @return void + * @return void */ public function setTableModified($modified) { diff --git a/src/Propel/Generator/Model/Column.php b/src/Propel/Generator/Model/Column.php index c8efd5d9ca..ae50248585 100644 --- a/src/Propel/Generator/Model/Column.php +++ b/src/Propel/Generator/Model/Column.php @@ -234,7 +234,7 @@ public function getTypeHint() /** * @param string|null $typeHint -* @return void + * @return void */ public function setTypeHint($typeHint) { @@ -420,7 +420,7 @@ public function getDomain() * Sets the domain for this column. * * @param Domain $domain -* @return void + * @return void */ public function setDomain(Domain $domain) { @@ -471,7 +471,7 @@ public function getUppercasedName() * Sets the column name. * * @param string $name -* @return void + * @return void */ public function setName($name) { @@ -513,7 +513,7 @@ public function getDescription() * Sets the column description. * * @param string $description -* @return void + * @return void */ public function setDescription($description) { @@ -558,7 +558,7 @@ public function getPhpSingularName() * $phpName is passed. * * @param string $phpName -* @return void + * @return void */ public function setPhpName($phpName = null) { @@ -577,7 +577,7 @@ public function setPhpName($phpName = null) * $phpSingularName is passed. * * @param string $phpSingularName -* @return void + * @return void */ public function setPhpSingularName($phpSingularName = null) { @@ -618,7 +618,7 @@ public function getAccessorVisibility() * Sets the accessor methods visibility for this column / attribute. * * @param string $visibility -* @return void + * @return void */ public function setAccessorVisibility($visibility) { @@ -648,7 +648,7 @@ public function getMutatorVisibility() * Sets the mutator methods visibility for this column / attribute. * * @param string $visibility -* @return void + * @return void */ public function setMutatorVisibility($visibility) { @@ -702,7 +702,7 @@ public function getTableMapName() * Sets the TableMap constant name that will identify this column. * * @param string $name -* @return void + * @return void */ public function setTableMapName($name) { @@ -735,7 +735,7 @@ public function getPosition() * Returns the location of this column within the table (one-based). * * @param integer $position -* @return void + * @return void */ public function setPosition($position) { @@ -746,7 +746,7 @@ public function setPosition($position) * Sets the parent table. * * @param \Propel\Generator\Model\Table $table -* @return void + * @return void */ public function setTable(Table $table) { @@ -865,7 +865,7 @@ public function isNotNull() * Sets whether or not the column is not null. * * @param boolean $flag -* @return void + * @return void */ public function setNotNull($flag = true) { @@ -889,7 +889,7 @@ public function getNotNullString() * __toString method of an active record object. * * @param boolean $isPrimaryString -* @return void + * @return void */ public function setPrimaryString($isPrimaryString) { @@ -911,7 +911,7 @@ public function isPrimaryString() * Sets whether or not the column is a primary key. * * @param boolean $flag -* @return void + * @return void */ public function setPrimaryKey($flag = true) { @@ -932,7 +932,7 @@ public function isPrimaryKey() * Sets whether or not the column is a node key of a tree. * * @param boolean $isNodeKey -* @return void + * @return void */ public function setNodeKey($isNodeKey) { @@ -953,7 +953,7 @@ public function isNodeKey() * Sets the separator for the node key column in a tree. * * @param string $sep -* @return void + * @return void */ public function setNodeKeySep($sep) { @@ -974,7 +974,7 @@ public function getNodeKeySep() * Sets whether or not the column is the nested set left key of a tree. * * @param boolean $isNestedSetLeftKey -* @return void + * @return void */ public function setNestedSetLeftKey($isNestedSetLeftKey) { @@ -995,7 +995,7 @@ public function isNestedSetLeftKey() * Set if the column is the nested set right key of a tree. * * @param boolean $isNestedSetRightKey -* @return void + * @return void */ public function setNestedSetRightKey($isNestedSetRightKey) { @@ -1016,7 +1016,7 @@ public function isNestedSetRightKey() * Sets whether or not the column is the scope key of a tree. * * @param boolean $isTreeScopeKey -* @return void + * @return void */ public function setTreeScopeKey($isTreeScopeKey) { @@ -1089,7 +1089,7 @@ public function getForeignKeys() * Adds the foreign key from another table that refers to this column. * * @param ForeignKey $fk -* @return void + * @return void */ public function addReferrer(ForeignKey $fk) { @@ -1131,7 +1131,7 @@ public function hasReferrer(ForeignKey $fk) /** * Clears all referrers. * -* @return void + * @return void */ public function clearReferrers() { @@ -1141,7 +1141,7 @@ public function clearReferrers() /** * Clears all inheritance children. * -* @return void + * @return void */ public function clearInheritanceList() { @@ -1155,7 +1155,7 @@ public function clearInheritanceList() * size, scale (or other domain attributes). * * @param string $mappingType -* @return void + * @return void */ public function setDomainForType($mappingType) { @@ -1167,7 +1167,7 @@ public function setDomainForType($mappingType) * * @param string $mappingType * @see Domain::setType() -* @return void + * @return void */ public function setType($mappingType) { @@ -1311,7 +1311,7 @@ public function isSetType() * Sets the list of possible values for an ENUM or SET column. * * @param string|string[] $valueSet -* @return void + * @return void */ public function setValueSet($valueSet) { @@ -1347,7 +1347,7 @@ public function getSize() * Sets the column size. * * @param integer|null $size -* @return void + * @return void */ public function setSize($size) { @@ -1368,7 +1368,7 @@ public function getScale() * Sets the column scale. * * @param integer $scale -* @return void + * @return void */ public function setScale($scale) { @@ -1515,7 +1515,7 @@ public function getAutoIncrementString() * Use isAutoIncrement() to find out if it is set or not. * * @param boolean $flag -* @return void + * @return void */ public function setAutoIncrement($flag = true) { @@ -1596,7 +1596,7 @@ public function hasPlatform() /** * Clones the current object. * -* @return void + * @return void */ public function __clone() { diff --git a/src/Propel/Generator/Model/ColumnDefaultValue.php b/src/Propel/Generator/Model/ColumnDefaultValue.php index 12a14d409c..8788a49f29 100644 --- a/src/Propel/Generator/Model/ColumnDefaultValue.php +++ b/src/Propel/Generator/Model/ColumnDefaultValue.php @@ -56,7 +56,7 @@ public function getType() /** * @param string $type The type of default value (DefaultValue::TYPE_VALUE or DefaultValue::TYPE_EXPR) -* @return void + * @return void */ public function setType($type) { @@ -83,7 +83,7 @@ public function getValue() /** * @param string|null $value The value, as specified in the schema. -* @return void + * @return void */ public function setValue($value) { diff --git a/src/Propel/Generator/Model/CrossForeignKeys.php b/src/Propel/Generator/Model/CrossForeignKeys.php index e3fb75aa23..f1477518d0 100644 --- a/src/Propel/Generator/Model/CrossForeignKeys.php +++ b/src/Propel/Generator/Model/CrossForeignKeys.php @@ -84,7 +84,7 @@ public function __construct(ForeignKey $foreignKey, Table $crossTable) /** * @param ForeignKey|null $foreignKey -* @return void + * @return void */ public function setIncomingForeignKey($foreignKey) { @@ -200,7 +200,7 @@ public function hasCrossForeignKeys() /** * @param ForeignKey[] $foreignKeys -* @return void + * @return void */ public function setCrossForeignKeys(array $foreignKeys) { @@ -219,7 +219,7 @@ public function getCrossForeignKeys() /** * @param \Propel\Generator\Model\Table $foreignTable -* @return void + * @return void */ public function setMiddleTable(Table $foreignTable) { @@ -238,7 +238,7 @@ public function getMiddleTable() /** * @param \Propel\Generator\Model\Table $table -* @return void + * @return void */ public function setTable(Table $table) { diff --git a/src/Propel/Generator/Model/Database.php b/src/Propel/Generator/Model/Database.php index feb2372226..0fd2823099 100644 --- a/src/Propel/Generator/Model/Database.php +++ b/src/Propel/Generator/Model/Database.php @@ -192,7 +192,7 @@ public function getPlatform() * Sets the PlatformInterface implementation for this database. * * @param PlatformInterface|null $platform A Platform implementation -* @return void + * @return void */ public function setPlatform(PlatformInterface $platform = null) { @@ -223,7 +223,7 @@ public function getName() * Sets the database name. * * @param string $name -* @return void + * @return void */ public function setName($name) { @@ -257,7 +257,7 @@ public function getBaseQueryClass() * This parameter is overridden at the table level. * * @param string $class. -* @return void + * @return void */ public function setBaseClass($class) { @@ -269,7 +269,7 @@ public function setBaseClass($class) * This parameter is overridden at the table level. * * @param string $class. -* @return void + * @return void */ public function setBaseQueryClass($class) { @@ -292,7 +292,7 @@ public function getDefaultIdMethod() * This parameter can be overridden at the table level. * * @param string $strategy -* @return void + * @return void */ public function setDefaultIdMethod($strategy) { @@ -315,7 +315,7 @@ public function getDefaultPhpNamingMethod() * Sets name of the default PHP naming method strategy. * * @param string $strategy -* @return void + * @return void */ public function setDefaultPhpNamingMethod($strategy) { @@ -340,7 +340,7 @@ public static function getSupportedStringFormats() * * @param string $format * @throws InvalidArgumentException -* @return void + * @return void */ public function setDefaultStringFormat($format) { @@ -393,7 +393,7 @@ public function getHeavyIndexing() * Sets whether or not heavy indexing is enabled. * * @param boolean $flag -* @return void + * @return void */ public function setHeavyIndexing($flag = true) { @@ -585,7 +585,7 @@ public function addTable($table) /** * @param string[] $sequences -* @return void + * @return void */ public function setSequences($sequences) { @@ -611,7 +611,7 @@ public function addSequence($sequence) /** * @param string $sequence -* @return void + * @return void */ public function removeSequence($sequence) { @@ -648,7 +648,7 @@ public function getSchemaDelimiter() * Sets the database's schema. * * @param string $schema -* @return void + * @return void */ public function setSchema($schema) { @@ -709,7 +709,7 @@ private function computeTableNamespace(Table $table) * Sets the parent schema * * @param Schema $parent The parent schema -* @return void + * @return void */ public function setParentSchema(Schema $parent) { @@ -810,7 +810,7 @@ public function getTablePrefix() * Sets the tables' prefix. * * @param string $tablePrefix -* @return void + * @return void */ public function setTablePrefix($tablePrefix) { @@ -846,7 +846,7 @@ public function getNextTableBehavior() /** * Finalizes the setup process. * -* @return void + * @return void */ public function doFinalInitialization() { @@ -976,7 +976,7 @@ public function __toString() * Sets the default accessor visibility. * * @param string $defaultAccessorVisibility -* @return void + * @return void */ public function setDefaultAccessorVisibility($defaultAccessorVisibility) { @@ -997,7 +997,7 @@ public function getDefaultAccessorVisibility() * Sets the default mutator visibility. * * @param string $defaultMutatorVisibility -* @return void + * @return void */ public function setDefaultMutatorVisibility($defaultMutatorVisibility) { @@ -1040,7 +1040,7 @@ public function isIdentifierQuotingEnabled() /** * @param boolean $identifierQuoting -* @return void + * @return void */ public function setIdentifierQuoting($identifierQuoting) { diff --git a/src/Propel/Generator/Model/Diff/ColumnDiff.php b/src/Propel/Generator/Model/Diff/ColumnDiff.php index d49e053a85..93917de831 100644 --- a/src/Propel/Generator/Model/Diff/ColumnDiff.php +++ b/src/Propel/Generator/Model/Diff/ColumnDiff.php @@ -61,7 +61,7 @@ public function __construct(Column $fromColumn = null, Column $toColumn = null) * Sets for the changed properties. * * @param array $properties -* @return void + * @return void */ public function setChangedProperties($properties) { @@ -82,7 +82,7 @@ public function getChangedProperties() * Sets the fromColumn property. * * @param Column $fromColumn -* @return void + * @return void */ public function setFromColumn(Column $fromColumn) { @@ -103,7 +103,7 @@ public function getFromColumn() * Sets the toColumn property. * * @param Column $toColumn -* @return void + * @return void */ public function setToColumn(Column $toColumn) { diff --git a/src/Propel/Generator/Model/Diff/DatabaseComparator.php b/src/Propel/Generator/Model/Diff/DatabaseComparator.php index eaaa2c9b08..137c070f1f 100644 --- a/src/Propel/Generator/Model/Diff/DatabaseComparator.php +++ b/src/Propel/Generator/Model/Diff/DatabaseComparator.php @@ -73,7 +73,7 @@ public function getDatabaseDiff() * Sets the fromDatabase property. * * @param Database $fromDatabase -* @return void + * @return void */ public function setFromDatabase(Database $fromDatabase) { @@ -94,7 +94,7 @@ public function getFromDatabase() * Sets the toDatabase property. * * @param Database $toDatabase -* @return void + * @return void */ public function setToDatabase(Database $toDatabase) { @@ -115,7 +115,7 @@ public function getToDatabase() * Set true to handle removed tables or false to ignore them * * @param boolean $removeTable -* @return void + * @return void */ public function setRemoveTable($removeTable) { @@ -134,7 +134,7 @@ public function getRemoveTable() * Set the list of tables excluded from the comparison * * @param string[] $excludedTables set the list of table name -* @return void + * @return void */ public function setExcludedTables(array $excludedTables) { @@ -187,7 +187,7 @@ public static function computeDiff(Database $fromDatabase, Database $toDatabase, /** * @param boolean $withRenaming -* @return void + * @return void */ public function setWithRenaming($withRenaming) { diff --git a/src/Propel/Generator/Model/Diff/DatabaseDiff.php b/src/Propel/Generator/Model/Diff/DatabaseDiff.php index f1f66d6388..de5482eacf 100644 --- a/src/Propel/Generator/Model/Diff/DatabaseDiff.php +++ b/src/Propel/Generator/Model/Diff/DatabaseDiff.php @@ -54,7 +54,7 @@ public function __construct() * Sets the added tables. * * @param array $tables -* @return void + * @return void */ public function setAddedTables($tables) { @@ -66,7 +66,7 @@ public function setAddedTables($tables) * * @param string $name * @param Table $table -* @return void + * @return void */ public function addAddedTable($name, Table $table) { @@ -77,7 +77,7 @@ public function addAddedTable($name, Table $table) * Removes an added table. * * @param string $name -* @return void + * @return void */ public function removeAddedTable($name) { @@ -97,7 +97,7 @@ public function getPossibleRenamedTables() * * @param string $fromName * @param string $toName -* @return void + * @return void */ public function addPossibleRenamedTable($fromName, $toName) { @@ -140,7 +140,7 @@ public function getAddedTable($name) * Sets the removes tables. * * @param \Propel\Generator\Model\Table[] $tables -* @return void + * @return void */ public function setRemovedTables($tables) { @@ -152,7 +152,7 @@ public function setRemovedTables($tables) * * @param string $name * @param Table $table -* @return void + * @return void */ public function addRemovedTable($name, Table $table) { @@ -163,7 +163,7 @@ public function addRemovedTable($name, Table $table) * Removes a removed table. * * @param string $name -* @return void + * @return void */ public function removeRemovedTable($name) { @@ -206,7 +206,7 @@ public function getRemovedTable($name) * Sets the modified tables * * @param \Propel\Generator\Model\Diff\TableDiff[] $tables -* @return void + * @return void */ public function setModifiedTables($tables) { @@ -218,7 +218,7 @@ public function setModifiedTables($tables) * * @param string $name * @param TableDiff $difference -* @return void + * @return void */ public function addModifiedTable($name, TableDiff $difference) { @@ -249,7 +249,7 @@ public function getModifiedTables() * Sets the renamed tables. * * @param string[] $tables -* @return void + * @return void */ public function setRenamedTables($tables) { @@ -261,7 +261,7 @@ public function setRenamedTables($tables) * * @param string $fromName * @param string $toName -* @return void + * @return void */ public function addRenamedTable($fromName, $toName) { diff --git a/src/Propel/Generator/Model/Diff/TableComparator.php b/src/Propel/Generator/Model/Diff/TableComparator.php index d9e359dae5..ff89e5b78e 100644 --- a/src/Propel/Generator/Model/Diff/TableComparator.php +++ b/src/Propel/Generator/Model/Diff/TableComparator.php @@ -50,7 +50,7 @@ public function getTableDiff() * Sets the table the comparator starts from. * * @param \Propel\Generator\Model\Table $fromTable -* @return void + * @return void */ public function setFromTable(Table $fromTable) { @@ -71,7 +71,7 @@ public function getFromTable() * Sets the table the comparator goes to. * * @param \Propel\Generator\Model\Table $toTable -* @return void + * @return void */ public function setToTable(Table $toTable) { diff --git a/src/Propel/Generator/Model/Diff/TableDiff.php b/src/Propel/Generator/Model/Diff/TableDiff.php index 061ef32256..2dadaa9b01 100644 --- a/src/Propel/Generator/Model/Diff/TableDiff.php +++ b/src/Propel/Generator/Model/Diff/TableDiff.php @@ -163,7 +163,7 @@ public function __construct(Table $fromTable = null, Table $toTable = null) * Sets the fromTable property. * * @param \Propel\Generator\Model\Table $fromTable -* @return void + * @return void */ public function setFromTable(Table $fromTable) { @@ -184,7 +184,7 @@ public function getFromTable() * Sets the toTable property. * * @param \Propel\Generator\Model\Table $toTable -* @return void + * @return void */ public function setToTable(Table $toTable) { @@ -205,7 +205,7 @@ public function getToTable() * Sets the added columns. * * @param Column[] $columns -* @return void + * @return void */ public function setAddedColumns(array $columns) { @@ -220,7 +220,7 @@ public function setAddedColumns(array $columns) * * @param string $name * @param Column $column -* @return void + * @return void */ public function addAddedColumn($name, Column $column) { @@ -231,7 +231,7 @@ public function addAddedColumn($name, Column $column) * Removes an added column. * * @param string $columnName -* @return void + * @return void */ public function removeAddedColumn($columnName) { @@ -269,7 +269,7 @@ public function getAddedColumn($columnName) * Setter for the removedColumns property * * @param Column[] $removedColumns -* @return void + * @return void */ public function setRemovedColumns(array $removedColumns) { @@ -284,7 +284,7 @@ public function setRemovedColumns(array $removedColumns) * * @param string $columnName * @param Column $removedColumn -* @return void + * @return void */ public function addRemovedColumn($columnName, Column $removedColumn) { @@ -295,7 +295,7 @@ public function addRemovedColumn($columnName, Column $removedColumn) * Removes a removed column. * * @param string $columnName -* @return void + * @return void */ public function removeRemovedColumn($columnName) { @@ -332,7 +332,7 @@ public function getRemovedColumn($columnName) * Sets the list of modified columns. * * @param ColumnDiff[] $modifiedColumns An associative array of ColumnDiff objects -* @return void + * @return void */ public function setModifiedColumns(array $modifiedColumns) { @@ -347,7 +347,7 @@ public function setModifiedColumns(array $modifiedColumns) * * @param string $columnName * @param ColumnDiff $modifiedColumn -* @return void + * @return void */ public function addModifiedColumn($columnName, ColumnDiff $modifiedColumn) { @@ -368,7 +368,7 @@ public function getModifiedColumns() * Sets the list of renamed columns. * * @param array $renamedColumns -* @return void + * @return void */ public function setRenamedColumns(array $renamedColumns) { @@ -384,7 +384,7 @@ public function setRenamedColumns(array $renamedColumns) * * @param Column $fromColumn * @param Column $toColumn -* @return void + * @return void */ public function addRenamedColumn(Column $fromColumn, Column $toColumn) { @@ -405,7 +405,7 @@ public function getRenamedColumns() * Sets the list of added primary key columns. * * @param Column[] $addedPkColumns -* @return void + * @return void */ public function setAddedPkColumns(array $addedPkColumns) { @@ -420,7 +420,7 @@ public function setAddedPkColumns(array $addedPkColumns) * * @param string $columnName * @param Column $addedPkColumn -* @return void + * @return void */ public function addAddedPkColumn($columnName, Column $addedPkColumn) { @@ -435,7 +435,7 @@ public function addAddedPkColumn($columnName, Column $addedPkColumn) * Removes an added primary key column. * * @param string $columnName -* @return void + * @return void */ public function removeAddedPkColumn($columnName) { @@ -458,7 +458,7 @@ public function getAddedPkColumns() * Sets the list of removed primary key columns. * * @param Column[] $removedPkColumns -* @return void + * @return void */ public function setRemovedPkColumns(array $removedPkColumns) { @@ -473,7 +473,7 @@ public function setRemovedPkColumns(array $removedPkColumns) * * @param string $columnName * @param Column $removedPkColumn -* @return void + * @return void */ public function addRemovedPkColumn($columnName, Column $removedPkColumn) { @@ -484,7 +484,7 @@ public function addRemovedPkColumn($columnName, Column $removedPkColumn) * Removes a removed primary key column. * * @param string $columnName -* @return void + * @return void */ public function removeRemovedPkColumn($columnName) { @@ -507,7 +507,7 @@ public function getRemovedPkColumns() * Sets the list of all renamed primary key columns. * * @param Column[][] $renamedPkColumns -* @return void + * @return void */ public function setRenamedPkColumns(array $renamedPkColumns) { @@ -523,7 +523,7 @@ public function setRenamedPkColumns(array $renamedPkColumns) * * @param Column $fromColumn The original column * @param Column $toColumn The renamed column -* @return void + * @return void */ public function addRenamedPkColumn(Column $fromColumn, Column $toColumn) { @@ -554,7 +554,7 @@ public function hasModifiedPk() * Sets the list of new added indices. * * @param Index[] $addedIndices -* @return void + * @return void */ public function setAddedIndices(array $addedIndices) { @@ -569,7 +569,7 @@ public function setAddedIndices(array $addedIndices) * * @param string $indexName * @param Index $addedIndex -* @return void + * @return void */ public function addAddedIndex($indexName, Index $addedIndex) { @@ -590,7 +590,7 @@ public function getAddedIndices() * Sets the list of removed indices. * * @param Index[] $removedIndices -* @return void + * @return void */ public function setRemovedIndices(array $removedIndices) { @@ -605,7 +605,7 @@ public function setRemovedIndices(array $removedIndices) * * @param string $indexName * @param Index $removedIndex -* @return void + * @return void */ public function addRemovedIndex($indexName, Index $removedIndex) { @@ -628,7 +628,7 @@ public function getRemovedIndices() * Array must be [ [ Index $fromIndex, Index $toIndex ], [ ... ] ] * * @param Index[][] $modifiedIndices An aray of modified indices -* @return void + * @return void */ public function setModifiedIndices(array $modifiedIndices) { @@ -645,7 +645,7 @@ public function setModifiedIndices(array $modifiedIndices) * @param string $indexName * @param Index $fromIndex * @param Index $toIndex -* @return void + * @return void */ public function addModifiedIndex($indexName, Index $fromIndex, Index $toIndex) { @@ -666,7 +666,7 @@ public function getModifiedIndices() * Sets the list of added foreign keys. * * @param ForeignKey[] $addedFks -* @return void + * @return void */ public function setAddedFks(array $addedFks) { @@ -681,7 +681,7 @@ public function setAddedFks(array $addedFks) * * @param string $fkName * @param ForeignKey $addedFk -* @return void + * @return void */ public function addAddedFk($fkName, ForeignKey $addedFk) { @@ -692,7 +692,7 @@ public function addAddedFk($fkName, ForeignKey $addedFk) * Remove an added Fk column * * @param string $fkName -* @return void + * @return void */ public function removeAddedFk($fkName) { @@ -715,7 +715,7 @@ public function getAddedFks() * Sets the list of removed foreign keys. * * @param ForeignKey[] $removedFks -* @return void + * @return void */ public function setRemovedFks(array $removedFks) { @@ -730,7 +730,7 @@ public function setRemovedFks(array $removedFks) * * @param string $fkName * @param ForeignKey $removedFk -* @return void + * @return void */ public function addRemovedFk($fkName, ForeignKey $removedFk) { @@ -741,7 +741,7 @@ public function addRemovedFk($fkName, ForeignKey $removedFk) * Removes a removed foreign key. * * @param string $fkName -* @return void + * @return void */ public function removeRemovedFk($fkName) { @@ -764,7 +764,7 @@ public function getRemovedFks() * Array must be [ [ ForeignKey $fromFk, ForeignKey $toFk ], [ ... ] ] * * @param ForeignKey[][] $modifiedFks -* @return void + * @return void */ public function setModifiedFks(array $modifiedFks) { @@ -781,7 +781,7 @@ public function setModifiedFks(array $modifiedFks) * @param string $fkName * @param ForeignKey $fromFk * @param ForeignKey $toFk -* @return void + * @return void */ public function addModifiedFk($fkName, ForeignKey $fromFk, ForeignKey $toFk) { diff --git a/src/Propel/Generator/Model/Domain.php b/src/Propel/Generator/Model/Domain.php index ea95f206d4..4315de685d 100644 --- a/src/Propel/Generator/Model/Domain.php +++ b/src/Propel/Generator/Model/Domain.php @@ -64,7 +64,7 @@ public function __construct($type = null, $sqlType = null, $size = null, $scale * Copies the values from current object into passed-in Domain. * * @param Domain $domain Domain to copy values into. -* @return void + * @return void */ public function copy(Domain $domain) { @@ -105,7 +105,7 @@ protected function setupObject() * Sets the owning database object (if this domain is being setup via XML). * * @param Database $database -* @return void + * @return void */ public function setDatabase(Database $database) { @@ -136,7 +136,7 @@ public function getDescription() * Sets the domain description. * * @param string $description -* @return void + * @return void */ public function setDescription($description) { @@ -157,7 +157,7 @@ public function getName() * Sets the domain name. * * @param string $name -* @return void + * @return void */ public function setName($name) { @@ -178,7 +178,7 @@ public function getScale() * Sets the scale value. * * @param integer $scale -* @return void + * @return void */ public function setScale($scale) { @@ -189,7 +189,7 @@ public function setScale($scale) * Replaces the size if the new value is not null. * * @param integer $scale -* @return void + * @return void */ public function replaceScale($scale) { @@ -212,7 +212,7 @@ public function getSize() * Sets the size. * * @param integer|null $size -* @return void + * @return void */ public function setSize($size) { @@ -223,7 +223,7 @@ public function setSize($size) * Replaces the size if the new value is not null. * * @param integer|null $size -* @return void + * @return void */ public function replaceSize($size) { @@ -246,7 +246,7 @@ public function getType() * Sets the mapping type. * * @param string $mappingType -* @return void + * @return void */ public function setType($mappingType) { @@ -257,7 +257,7 @@ public function setType($mappingType) * Replaces the mapping type if the new value is not null. * * @param string $mappingType -* @return void + * @return void */ public function replaceType($mappingType) { @@ -309,7 +309,7 @@ public function getPhpDefaultValue() * Sets the default value. * * @param ColumnDefaultValue $value -* @return void + * @return void */ public function setDefaultValue(ColumnDefaultValue $value) { @@ -320,7 +320,7 @@ public function setDefaultValue(ColumnDefaultValue $value) * Replaces the default value if the new value is not null. * * @param ColumnDefaultValue $value -* @return void + * @return void */ public function replaceDefaultValue(ColumnDefaultValue $value = null) { @@ -343,7 +343,7 @@ public function getSqlType() * Sets the SQL type. * * @param string $sqlType -* @return void + * @return void */ public function setSqlType($sqlType) { @@ -354,7 +354,7 @@ public function setSqlType($sqlType) * Replaces the SQL type if the new value is not null. * * @param string|null $sqlType -* @return void + * @return void */ public function replaceSqlType($sqlType) { @@ -394,7 +394,7 @@ public function __clone() /** * @todo Remove? This method is never called. * @param \DOMNode $node -* @return void + * @return void */ public function appendXml(\DOMNode $node) { diff --git a/src/Propel/Generator/Model/ForeignKey.php b/src/Propel/Generator/Model/ForeignKey.php index 8ecaebf28d..50f0578fac 100644 --- a/src/Propel/Generator/Model/ForeignKey.php +++ b/src/Propel/Generator/Model/ForeignKey.php @@ -247,7 +247,7 @@ public function getOnDelete() * Sets the onDelete behavior. * * @param string $behavior -* @return void + * @return void */ public function setOnDelete($behavior) { @@ -258,7 +258,7 @@ public function setOnDelete($behavior) * Sets the onUpdate behavior. * * @param string|null $behavior -* @return void + * @return void */ public function setOnUpdate($behavior) { @@ -281,7 +281,7 @@ public function getName() * Sets the foreign key name. * * @param string $name -* @return void + * @return void */ public function setName($name) { @@ -299,7 +299,7 @@ public function getInterface() /** * @param string $interface -* @return void + * @return void */ public function setInterface($interface) { @@ -320,7 +320,7 @@ public function getPhpName() * Sets a phpName to use for this foreign key. * * @param string $name -* @return void + * @return void */ public function setPhpName($name) { @@ -341,7 +341,7 @@ public function getRefPhpName() * Sets a refPhpName to use for this foreign key. * * @param string $name -* @return void + * @return void */ public function setRefPhpName($name) { @@ -362,7 +362,7 @@ public function getDefaultJoin() * Sets the default join strategy for this foreign key (if any). * * @param string $join -* @return void + * @return void */ public function setDefaultJoin($join) { @@ -429,7 +429,7 @@ public function getForeignTableCommonName() * Sets the foreign table common name of the FK. * * @param string $tableName -* @return void + * @return void */ public function setForeignTableCommonName($tableName) { @@ -465,7 +465,7 @@ public function getForeignSchemaName() * Set the foreign schema name of the foreign key. * * @param string $schemaName -* @return void + * @return void */ public function setForeignSchemaName($schemaName) { @@ -476,7 +476,7 @@ public function setForeignSchemaName($schemaName) * Sets the parent Table of the foreign key. * * @param \Propel\Generator\Model\Table $parent -* @return void + * @return void */ public function setTable(Table $parent) { @@ -560,7 +560,7 @@ public function addReference($ref1, $ref2 = null) /** * Clears the references of this foreign key. * -* @return void + * @return void */ public function clearReferences() { @@ -904,7 +904,7 @@ public function isLocalPrimaryKey() * generated. * * @param boolean $skip -* @return void + * @return void */ public function setSkipSql($skip) { diff --git a/src/Propel/Generator/Model/IdMethodParameter.php b/src/Propel/Generator/Model/IdMethodParameter.php index 5cf26fc2e4..0bba7c8ca3 100644 --- a/src/Propel/Generator/Model/IdMethodParameter.php +++ b/src/Propel/Generator/Model/IdMethodParameter.php @@ -58,7 +58,7 @@ public function getName() * Sets the parameter name. * * @param string $name -* @return void + * @return void */ public function setName($name) { @@ -79,7 +79,7 @@ public function getValue() * Sets the parameter value. * * @param mixed $value -* @return void + * @return void */ public function setValue($value) { @@ -90,7 +90,7 @@ public function setValue($value) * Sets the parent table. * * @param \Propel\Generator\Model\Table $parent -* @return void + * @return void */ public function setTable(Table $parent) { diff --git a/src/Propel/Generator/Model/Index.php b/src/Propel/Generator/Model/Index.php index 44cca9357c..0a4e627939 100644 --- a/src/Propel/Generator/Model/Index.php +++ b/src/Propel/Generator/Model/Index.php @@ -77,7 +77,7 @@ public function isUnique() * Sets the index name. * * @param string $name -* @return void + * @return void */ public function setName($name) { @@ -150,7 +150,7 @@ public function getFQName() * Sets the index parent Table. * * @param \Propel\Generator\Model\Table $table -* @return void + * @return void */ public function setTable(Table $table) { @@ -216,7 +216,7 @@ public function hasColumn($name) * Sets an array of columns to use for the index. * * @param array $columns array of array definitions $columns[]['name'] = 'columnName' -* @return void + * @return void */ public function setColumns(array $columns) { @@ -263,7 +263,7 @@ public function getColumnSize($name, $caseInsensitive = false) * Resets the columns sizes. * * This method is useful for generated indices for FKs. -* @return void + * @return void */ public function resetColumnsSize() { @@ -342,7 +342,7 @@ public function getColumnObjects() /** * @param Column[] $columnObjects -* @return void + * @return void */ public function setColumnObjects($columnObjects) { diff --git a/src/Propel/Generator/Model/Inheritance.php b/src/Propel/Generator/Model/Inheritance.php index 6dba232dec..785c4a4821 100644 --- a/src/Propel/Generator/Model/Inheritance.php +++ b/src/Propel/Generator/Model/Inheritance.php @@ -51,10 +51,10 @@ public function getKey() } /** - * Get constant names' safe value of the key name. - * - * @return string - */ + * Get constant names' safe value of the key name. + * + * @return string + */ public function getConstantSuffix() { $separator = PhpNameGenerator::STD_SEPARATOR_CHAR; @@ -65,7 +65,7 @@ public function getConstantSuffix() * Sets a key name. * * @param string $key -* @return void + * @return void */ public function setKey($key) { @@ -76,7 +76,7 @@ public function setKey($key) * Sets the parent column * * @param Column $column -* @return void + * @return void */ public function setColumn(Column $column) { @@ -107,7 +107,7 @@ public function getClassName() * Sets the class name. * * @param string $name -* @return void + * @return void */ public function setClassName($name) { @@ -128,7 +128,7 @@ public function getPackage() * Sets the package. * * @param string $package -* @return void + * @return void */ public function setPackage($package) { @@ -149,7 +149,7 @@ public function getAncestor() * Sets the ancestor. * * @param string $ancestor -* @return void + * @return void */ public function setAncestor($ancestor) { diff --git a/src/Propel/Generator/Model/MappingModel.php b/src/Propel/Generator/Model/MappingModel.php index 87c8a08739..7e73eae951 100644 --- a/src/Propel/Generator/Model/MappingModel.php +++ b/src/Propel/Generator/Model/MappingModel.php @@ -37,7 +37,7 @@ abstract class MappingModel implements MappingModelInterface * Loads a mapping definition from an array. * * @param array $attributes -* @return void + * @return void */ public function loadMapping(array $attributes) { diff --git a/src/Propel/Generator/Model/Schema.php b/src/Propel/Generator/Model/Schema.php index d12dda45aa..24294ffd61 100644 --- a/src/Propel/Generator/Model/Schema.php +++ b/src/Propel/Generator/Model/Schema.php @@ -58,7 +58,7 @@ public function __construct(PlatformInterface $platform = null) * application schema. * * @param PlatformInterface $platform -* @return void + * @return void */ public function setPlatform(PlatformInterface $platform) { @@ -80,7 +80,7 @@ public function getPlatform() * Sets the generator configuration * * @param GeneratorConfigInterface $generatorConfig -* @return void + * @return void */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) { @@ -101,7 +101,7 @@ public function getGeneratorConfig() * Sets the schema name. * * @param string $name -* @return void + * @return void */ public function setName($name) { @@ -242,7 +242,7 @@ public function addDatabase($database) /** * Finalizes the databases initialization. * -* @return void + * @return void */ public function doFinalInitialization() { @@ -258,7 +258,7 @@ public function doFinalInitialization() * Merge other Schema objects together into this Schema object. * * @param Schema[] $schemas -* @return void + * @return void */ public function joinSchemas(array $schemas) { diff --git a/src/Propel/Generator/Model/ScopedMappingModel.php b/src/Propel/Generator/Model/ScopedMappingModel.php index a4b2f1315c..49be74ab68 100644 --- a/src/Propel/Generator/Model/ScopedMappingModel.php +++ b/src/Propel/Generator/Model/ScopedMappingModel.php @@ -129,7 +129,7 @@ public function getPackage() * Sets the package name. * * @param string $package -* @return void + * @return void */ public function setPackage($package) { @@ -155,7 +155,7 @@ public function getSchema() * Sets the schema name. * * @param string $schema -* @return void + * @return void */ public function setSchema($schema) { diff --git a/src/Propel/Generator/Model/Table.php b/src/Propel/Generator/Model/Table.php index 1145e87c55..5fc749f9ac 100644 --- a/src/Propel/Generator/Model/Table.php +++ b/src/Propel/Generator/Model/Table.php @@ -261,7 +261,7 @@ public function getBuildProperty($key) /** * Executes behavior table modifiers. * -* @return void + * @return void */ public function applyBehaviors() { @@ -449,7 +449,7 @@ protected function createIndex($name, array $columns) * @param string $indexName The name of the index * @param array $columns The column names or objects * @param array $collectedIndexes The collected indexes -* @return void + * @return void */ protected function collectIndexedColumns($indexName, $columns, &$collectedIndexes) { @@ -530,7 +530,7 @@ public function getBaseQueryClass() * Sets the base class name. * * @param string $class -* @return void + * @return void */ public function setBaseClass($class) { @@ -541,7 +541,7 @@ public function setBaseClass($class) * Sets the base query class name. * * @param string $class -* @return void + * @return void */ public function setBaseQueryClass($class) { @@ -593,7 +593,7 @@ public function addColumn($col) * Adds several columns at once. * * @param Column[] $columns An array of Column instance -* @return void + * @return void */ public function addColumns(array $columns) { @@ -607,7 +607,7 @@ public function addColumns(array $columns) * * @param Column|string $column The Column or its name * @throws EngineException -* @return void + * @return void */ public function removeColumn($column) { @@ -698,7 +698,7 @@ public function addForeignKey($foreignKey) * Adds several foreign keys at once. * * @param ForeignKey[] $foreignKeys An array of ForeignKey objects -* @return void + * @return void */ public function addForeignKeys(array $foreignKeys) { @@ -742,7 +742,7 @@ public function getChildrenNames() * Adds the foreign key from another table that refers to this table. * * @param ForeignKey $fk -* @return void + * @return void */ public function addReferrer(ForeignKey $fk) { @@ -767,7 +767,7 @@ public function getReferrers() * * @param boolean $throwErrors * @throws BuildException -* @return void + * @return void */ public function setupReferrers($throwErrors = false) { @@ -968,7 +968,7 @@ public function addIdMethodParameter($idMethodParameter) * Removes a index from the table. * * @param string $name -* @return void + * @return void */ public function removeIndex($name) { @@ -1181,7 +1181,7 @@ public function hasDescription() * Sets the table description. * * @param string $description -* @return void + * @return void */ public function setDescription($description) { @@ -1207,7 +1207,7 @@ public function getPhpName() * Sets the name to use in PHP sources. * * @param string $phpName -* @return void + * @return void */ public function setPhpName($phpName) { @@ -1251,7 +1251,7 @@ public function getCommonName() * Sets the table common name (without schema name). * * @param string $name -* @return void + * @return void */ public function setCommonName($name) { @@ -1275,7 +1275,7 @@ public function getOriginCommonName() * * @param string $format * @throws InvalidArgumentException -* @return void + * @return void */ public function setDefaultStringFormat($format) { @@ -1332,7 +1332,7 @@ public function isAllowPkInsert() * Sets the method strategy for generating primary keys. * * @param string $idMethod -* @return void + * @return void */ public function setIdMethod($idMethod) { @@ -1354,7 +1354,7 @@ public function isSkipSql() * Sets whether or not this table should have its SQL DDL code generated. * * @param boolean $skip -* @return void + * @return void */ public function setSkipSql($skip) { @@ -1376,7 +1376,7 @@ public function isReadOnly() * Makes this database in read-only mode. * * @param boolean $flag True by default -* @return void + * @return void */ public function setReadOnly($flag = true) { @@ -1396,7 +1396,7 @@ public function isReloadOnInsert() * Makes this database reload on insert statement. * * @param boolean $flag True by default -* @return void + * @return void */ public function setReloadOnInsert($flag = true) { @@ -1417,7 +1417,7 @@ public function isReloadOnUpdate() * Makes this database reload on update statement. * * @param boolean $flag True by default -* @return void + * @return void */ public function setReloadOnUpdate($flag = true) { @@ -1450,7 +1450,7 @@ public function isAlias() * just a foreign key reference to it. * * @param string $alias -* @return void + * @return void */ public function setAlias($alias) { @@ -1471,7 +1471,7 @@ public function getInterface() * Sets the interface objects of this table will implement. * * @param string $interface -* @return void + * @return void */ public function setInterface($interface) { @@ -1498,7 +1498,7 @@ public function isAbstract() * declared abstract. This helps support class hierarchies * * @param boolean $flag -* @return void + * @return void */ public function setAbstract($flag = true) { @@ -1795,7 +1795,7 @@ public function getColumnForeignKeys($column) * Set the database that contains this table. * * @param Database $database -* @return void + * @return void */ public function setDatabase(Database $database) { @@ -1860,7 +1860,7 @@ public function isForReferenceOnly() * Table will be skipped, if set to true. * * @param boolean $flag -* @return void + * @return void */ public function setForReferenceOnly($flag = true) { @@ -1992,7 +1992,7 @@ public function isCrossRef() * Sets a cross reference status for this foreign key. * * @param boolean $flag -* @return void + * @return void */ public function setIsCrossRef($flag = true) { @@ -2003,7 +2003,7 @@ public function setIsCrossRef($flag = true) * Sets a cross reference status for this foreign key. * * @param boolean $flag -* @return void + * @return void */ public function setCrossRef($flag = true) { @@ -2044,7 +2044,7 @@ public function getPhpNamingMethod() * Sets the PHP naming method. * * @param string $phpNamingMethod -* @return void + * @return void */ public function setPhpNamingMethod($phpNamingMethod) { @@ -2055,7 +2055,7 @@ public function setPhpNamingMethod($phpNamingMethod) * Sets the default accessor visibility. * * @param string $defaultAccessorVisibility -* @return void + * @return void */ public function setDefaultAccessorVisibility($defaultAccessorVisibility) { @@ -2076,7 +2076,7 @@ public function getDefaultAccessorVisibility() * Sets the default mutator visibility. * * @param string $defaultMutatorVisibility -* @return void + * @return void */ public function setDefaultMutatorVisibility($defaultMutatorVisibility) { @@ -2116,7 +2116,7 @@ public function getIdentifierQuoting() /** * @param boolean $identifierQuoting -* @return void + * @return void */ public function setIdentifierQuoting($identifierQuoting) { diff --git a/src/Propel/Generator/Model/VendorInfo.php b/src/Propel/Generator/Model/VendorInfo.php index 87813e331d..fc358f8fd7 100644 --- a/src/Propel/Generator/Model/VendorInfo.php +++ b/src/Propel/Generator/Model/VendorInfo.php @@ -44,7 +44,7 @@ public function __construct($type = null, array $parameters = []) * Sets the RDBMS type for this vendor specific information. * * @param string $type -* @return void + * @return void */ public function setType($type) { @@ -66,7 +66,7 @@ public function getType() * * @param string $name The parameter name * @param mixed $value The parameter value -* @return void + * @return void */ public function setParameter($name, $value) { @@ -99,7 +99,7 @@ public function hasParameter($name) * Sets an associative array of parameters for vendor specific information. * * @param array $parameters Parameter data. -* @return void + * @return void */ public function setParameters(array $parameters = []) { diff --git a/src/Propel/Generator/Platform/DefaultPlatform.php b/src/Propel/Generator/Platform/DefaultPlatform.php index 59fadfd4c9..d302af337e 100644 --- a/src/Propel/Generator/Platform/DefaultPlatform.php +++ b/src/Propel/Generator/Platform/DefaultPlatform.php @@ -83,7 +83,7 @@ public function getObjectBuilderClass($type) * Sets the database connection to use for this Platform class. * * @param ConnectionInterface $con Database connection to use in this platform. -* @return void + * @return void */ public function setConnection(ConnectionInterface $con = null) { @@ -110,7 +110,7 @@ public function isIdentifierQuotingEnabled() /** * @param boolean $enabled -* @return void + * @return void */ public function setIdentifierQuoting($enabled) { @@ -121,7 +121,7 @@ public function setIdentifierQuoting($enabled) * Sets the GeneratorConfigInterface to use in the parsing. * * @param GeneratorConfigInterface $generatorConfig -* @return void + * @return void */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) { @@ -129,7 +129,7 @@ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) /** * Initialize the type -> Domain mapping. -* @return void + * @return void */ protected function initialize() { @@ -148,7 +148,7 @@ protected function initialize() /** * Adds a mapping entry for specified Domain. * @param Domain $domain -* @return void + * @return void */ protected function setSchemaDomainMapping(Domain $domain) { diff --git a/src/Propel/Generator/Platform/MssqlPlatform.php b/src/Propel/Generator/Platform/MssqlPlatform.php index cc59e576b8..839fcdd4b7 100644 --- a/src/Propel/Generator/Platform/MssqlPlatform.php +++ b/src/Propel/Generator/Platform/MssqlPlatform.php @@ -30,7 +30,7 @@ class MssqlPlatform extends DefaultPlatform /** * Initializes db specific domain mapping. -* @return void + * @return void */ protected function initialize() { diff --git a/src/Propel/Generator/Platform/MysqlPlatform.php b/src/Propel/Generator/Platform/MysqlPlatform.php index 2a30cdabce..eef38f83f2 100644 --- a/src/Propel/Generator/Platform/MysqlPlatform.php +++ b/src/Propel/Generator/Platform/MysqlPlatform.php @@ -36,7 +36,7 @@ class MysqlPlatform extends DefaultPlatform /** * Initializes db specific domain mapping. -* @return void + * @return void */ protected function initialize() { @@ -76,7 +76,7 @@ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) * Setter for the tableEngineKeyword property * * @param string $tableEngineKeyword -* @return void + * @return void */ public function setTableEngineKeyword($tableEngineKeyword) { @@ -97,7 +97,7 @@ public function getTableEngineKeyword() * Setter for the defaultTableEngine property * * @param string $defaultTableEngine -* @return void + * @return void */ public function setDefaultTableEngine($defaultTableEngine) { diff --git a/src/Propel/Generator/Platform/OraclePlatform.php b/src/Propel/Generator/Platform/OraclePlatform.php index 54b15dec3f..689f94de73 100644 --- a/src/Propel/Generator/Platform/OraclePlatform.php +++ b/src/Propel/Generator/Platform/OraclePlatform.php @@ -32,7 +32,7 @@ class OraclePlatform extends DefaultPlatform { /** * Initializes db specific domain mapping. -* @return void + * @return void */ protected function initialize() { diff --git a/src/Propel/Generator/Platform/PgsqlPlatform.php b/src/Propel/Generator/Platform/PgsqlPlatform.php index b46fcf9cc0..9e6a471c21 100755 --- a/src/Propel/Generator/Platform/PgsqlPlatform.php +++ b/src/Propel/Generator/Platform/PgsqlPlatform.php @@ -39,7 +39,7 @@ class PgsqlPlatform extends DefaultPlatform /** * Initializes db specific domain mapping. -* @return void + * @return void */ protected function initialize() { diff --git a/src/Propel/Generator/Platform/SqlitePlatform.php b/src/Propel/Generator/Platform/SqlitePlatform.php index ca853285c1..37808eb5b8 100644 --- a/src/Propel/Generator/Platform/SqlitePlatform.php +++ b/src/Propel/Generator/Platform/SqlitePlatform.php @@ -47,7 +47,7 @@ class SqlitePlatform extends DefaultPlatform /** * Initializes db specific domain mapping. -* @return void + * @return void */ protected function initialize() { diff --git a/src/Propel/Generator/Reverse/AbstractSchemaParser.php b/src/Propel/Generator/Reverse/AbstractSchemaParser.php index d5b9d3345a..6826d9de9a 100644 --- a/src/Propel/Generator/Reverse/AbstractSchemaParser.php +++ b/src/Propel/Generator/Reverse/AbstractSchemaParser.php @@ -87,7 +87,7 @@ public function __construct(ConnectionInterface $dbh = null) * Sets the database connection. * * @param ConnectionInterface $dbh -* @return void + * @return void */ public function setConnection(ConnectionInterface $dbh) { @@ -107,7 +107,7 @@ public function getConnection() * Setter for the migrationTable property * * @param string $migrationTable -* @return void + * @return void */ public function setMigrationTable($migrationTable) { @@ -128,7 +128,7 @@ public function getMigrationTable() * Pushes a message onto the stack of warnings. * * @param string $msg The warning message. -* @return void + * @return void */ protected function warn($msg) { @@ -149,7 +149,7 @@ public function getWarnings() * Sets the GeneratorConfig to use in the parsing. * * @param GeneratorConfigInterface $config -* @return void + * @return void */ public function setGeneratorConfig(GeneratorConfigInterface $config) { diff --git a/src/Propel/Generator/Reverse/MssqlSchemaParser.php b/src/Propel/Generator/Reverse/MssqlSchemaParser.php index ed6109871c..0a4abe47e5 100644 --- a/src/Propel/Generator/Reverse/MssqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/MssqlSchemaParser.php @@ -122,7 +122,7 @@ public function parse(Database $database, array $additionalTables = []) * Adds Columns to the specified table. * * @param Table $table The Table model class to add columns to. -* @return void + * @return void */ protected function addColumns(Table $table) { @@ -168,7 +168,7 @@ protected function addColumns(Table $table) /** * Load foreign keys for this table. -* @return void + * @return void */ protected function addForeignKeys(Table $table) { @@ -212,7 +212,7 @@ protected function addForeignKeys(Table $table) /** * Load indexes for this table -* @return void + * @return void */ protected function addIndexes(Table $table) { @@ -258,7 +258,7 @@ protected function addIndexes(Table $table) /** * Loads the primary key for this table. -* @return void + * @return void */ protected function addPrimaryKey(Table $table) { diff --git a/src/Propel/Generator/Reverse/MysqlSchemaParser.php b/src/Propel/Generator/Reverse/MysqlSchemaParser.php index 77452ffa43..1797c0e2b4 100644 --- a/src/Propel/Generator/Reverse/MysqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/MysqlSchemaParser.php @@ -162,7 +162,7 @@ protected function parseTables(Database $database, $filterTable = null) * Adds Columns to the specified table. * * @param Table $table The Table model class to add columns to. -* @return void + * @return void */ protected function addColumns(Table $table) { @@ -278,7 +278,7 @@ public function getColumnFromRow($row, Table $table) /** * Load foreign keys for this table. -* @return void + * @return void */ protected function addForeignKeys(Table $table) { @@ -375,7 +375,7 @@ protected function addForeignKeys(Table $table) /** * Load indexes for this table -* @return void + * @return void */ protected function addIndexes(Table $table) { @@ -427,7 +427,7 @@ protected function addIndexes(Table $table) /** * Loads the primary key for this table. -* @return void + * @return void */ protected function addPrimaryKey(Table $table) { @@ -453,7 +453,7 @@ protected function addPrimaryKey(Table $table) * Adds vendor-specific info for table. * * @param Table $table -* @return void + * @return void */ protected function addTableVendorInfo(Table $table) { diff --git a/src/Propel/Generator/Reverse/OracleSchemaParser.php b/src/Propel/Generator/Reverse/OracleSchemaParser.php index 80d79b33e1..380a11645f 100644 --- a/src/Propel/Generator/Reverse/OracleSchemaParser.php +++ b/src/Propel/Generator/Reverse/OracleSchemaParser.php @@ -133,7 +133,7 @@ public function parse(Database $database, array $additionalTables = []) * Adds Columns to the specified table. * * @param Table $table The Table model class to add columns to. -* @return void + * @return void */ protected function addColumns(Table $table) { @@ -196,7 +196,7 @@ protected function addColumns(Table $table) * Adds Indexes to the specified table. * * @param Table $table The Table model class to add columns to. -* @return void + * @return void */ protected function addIndexes(Table $table) { @@ -228,7 +228,7 @@ protected function addIndexes(Table $table) * Load foreign keys for this table. * * @param Table $table The Table model class to add FKs to -* @return void + * @return void */ protected function addForeignKeys(Table $table) { @@ -265,7 +265,7 @@ protected function addForeignKeys(Table $table) * Loads the primary key for this table. * * @param Table $table The Table model class to add PK to. -* @return void + * @return void */ protected function addPrimaryKey(Table $table) { diff --git a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php index a16d4fe5b2..bca898aff7 100755 --- a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php @@ -219,7 +219,7 @@ protected function parseTables(&$tableWraps, Database $database, Table $filterTa * * @param Table $table The Table model class to add columns to. * @param int $oid The table OID -* @return void + * @return void */ protected function addColumns(Table $table, $oid) { @@ -363,7 +363,7 @@ protected function isColumnDefaultExpression($default) /** * Load foreign keys for this table. -* @return void + * @return void */ protected function addForeignKeys(Table $table, $oid) { @@ -474,7 +474,7 @@ protected function addForeignKeys(Table $table, $oid) /** * Load indexes for this table -* @return void + * @return void */ protected function addIndexes(Table $table, $oid) { @@ -537,7 +537,7 @@ protected function addIndexes(Table $table, $oid) /** * Loads the primary key for this table. -* @return void + * @return void */ protected function addPrimaryKey(Table $table, $oid) { @@ -580,7 +580,7 @@ protected function addPrimaryKey(Table $table, $oid) * Adds the sequences for this database. * * @param Database $database -* @return void + * @return void */ protected function addSequences(Database $database) { diff --git a/src/Propel/Generator/Reverse/SqliteSchemaParser.php b/src/Propel/Generator/Reverse/SqliteSchemaParser.php index 96447b71ab..85c8217d38 100644 --- a/src/Propel/Generator/Reverse/SqliteSchemaParser.php +++ b/src/Propel/Generator/Reverse/SqliteSchemaParser.php @@ -183,7 +183,7 @@ protected function parseTables(Database $database, Table $filterTable = null) * Adds Columns to the specified table. * * @param Table $table The Table model class to add columns to. -* @return void + * @return void */ protected function addColumns(Table $table) { @@ -319,7 +319,7 @@ protected function addForeignKeys(Table $table) /** * Load indexes for this table -* @return void + * @return void */ protected function addIndexes(Table $table) { diff --git a/src/Propel/Generator/Schema/Dumper/XmlDumper.php b/src/Propel/Generator/Schema/Dumper/XmlDumper.php index 296a4b44be..b43b8890f8 100644 --- a/src/Propel/Generator/Schema/Dumper/XmlDumper.php +++ b/src/Propel/Generator/Schema/Dumper/XmlDumper.php @@ -89,7 +89,7 @@ public function dumpSchema(Schema $schema, $doFinalInitialization = true) * * @param Database $database The Database model instance * @param \DOMNode $parentNode The parent DOMNode object -* @return void + * @return void */ private function appendDatabaseNode(Database $database, \DOMNode $parentNode) { @@ -172,7 +172,7 @@ private function appendDatabaseNode(Database $database, \DOMNode $parentNode) * * @param VendorInfo $vendorInfo The VendorInfo model instance * @param \DOMNode $parentNode The parent DOMNode object -* @return void + * @return void */ private function appendVendorInformationNode(VendorInfo $vendorInfo, \DOMNode $parentNode) { @@ -193,7 +193,7 @@ private function appendVendorInformationNode(VendorInfo $vendorInfo, \DOMNode $p * * @param Table $table The Table model instance * @param \DOMNode $parentNode The parent DOMNode object -* @return void + * @return void */ private function appendTableNode(Table $table, \DOMNode $parentNode) { @@ -326,7 +326,7 @@ private function appendTableNode(Table $table, \DOMNode $parentNode) * * @param Behavior $behavior The Behavior model instance * @param \DOMNode $parentNode The parent DOMNode object -* @return void + * @return void */ private function appendBehaviorNode(Behavior $behavior, \DOMNode $parentNode) { @@ -350,7 +350,7 @@ private function appendBehaviorNode(Behavior $behavior, \DOMNode $parentNode) * * @param Column $column The Column model instance * @param \DOMNode $parentNode The parent DOMNode object -* @return void + * @return void */ private function appendColumnNode(Column $column, \DOMNode $parentNode) { @@ -424,7 +424,7 @@ private function appendColumnNode(Column $column, \DOMNode $parentNode) * * @param Inheritance $inheritance The Inheritance model instance * @param \DOMNode $parentNode The parent DOMNode object -* @return void + * @return void */ private function appendInheritanceNode(Inheritance $inheritance, \DOMNode $parentNode) { @@ -443,7 +443,7 @@ private function appendInheritanceNode(Inheritance $inheritance, \DOMNode $paren * * @param ForeignKey $foreignKey The ForeignKey model instance * @param \DOMNode $parentNode The parent DOMNode object -* @return void + * @return void */ private function appendForeignKeyNode(ForeignKey $foreignKey, \DOMNode $parentNode) { @@ -493,7 +493,7 @@ private function appendForeignKeyNode(ForeignKey $foreignKey, \DOMNode $parentNo * * @param IdMethodParameter $parameter The IdMethodParameter model instance * @param \DOMNode $parentNode The parent DOMNode object -* @return void + * @return void */ private function appendIdMethodParameterNode(IdMethodParameter $parameter, \DOMNode $parentNode) { @@ -510,7 +510,7 @@ private function appendIdMethodParameterNode(IdMethodParameter $parameter, \DOMN * * @param Index $index The Index model instance * @param \DOMNode $parentNode The parent DOMNode object -* @return void + * @return void */ private function appendIndexNode(Index $index, \DOMNode $parentNode) { @@ -522,7 +522,7 @@ private function appendIndexNode(Index $index, \DOMNode $parentNode) * * @param Unique $index The Unique model instance * @param \DOMNode $parentNode The parent DOMNode object -* @return void + * @return void */ private function appendUniqueIndexNode(Unique $index, \DOMNode $parentNode) { @@ -535,7 +535,7 @@ private function appendUniqueIndexNode(Unique $index, \DOMNode $parentNode) * @param string $nodeType The node type (index or unique) * @param Index $index The Index model instance * @param \DOMNode $parentNode The parent DOMNode object -* @return void + * @return void */ private function appendGenericIndexNode($nodeType, Index $index, \DOMNode $parentNode) { diff --git a/src/Propel/Generator/Util/QuickBuilder.php b/src/Propel/Generator/Util/QuickBuilder.php index 063dd210a9..19e8ce32bd 100644 --- a/src/Propel/Generator/Util/QuickBuilder.php +++ b/src/Propel/Generator/Util/QuickBuilder.php @@ -76,7 +76,7 @@ class QuickBuilder /** * @param string $schema -* @return void + * @return void */ public function setSchema($schema) { @@ -93,7 +93,7 @@ public function getSchema() /** * @param string $schemaName -* @return void + * @return void */ public function setSchemaName($schemaName) { @@ -110,7 +110,7 @@ public function getSchemaName() /** * @param \Propel\Generator\Reverse\SchemaParserInterface $parser -* @return void + * @return void */ public function setParser($parser) { @@ -129,7 +129,7 @@ public function getParser() * Setter for the platform property * * @param PlatformInterface $platform -* @return void + * @return void */ public function setPlatform($platform) { @@ -156,7 +156,7 @@ public function getPlatform() * Setter for the config property * * @param GeneratorConfigInterface $config -* @return void + * @return void */ public function setConfig(GeneratorConfigInterface $config) { @@ -351,7 +351,7 @@ public function getBuildName($classTargets = null) /** * @param string[]|null $classTargets array('tablemap', 'object', 'query', 'objectstub', 'querystub') * @param bool $separate pass true to get for each class a own file. better for debugging. -* @return void + * @return void */ public function buildClasses(array $classTargets = null, $separate = false) { @@ -573,7 +573,7 @@ public function isIdentifierQuotingEnabled() /** * @param boolean $identifierQuoting -* @return void + * @return void */ public function setIdentifierQuoting($identifierQuoting) { diff --git a/src/Propel/Generator/Util/SqlParser.php b/src/Propel/Generator/Util/SqlParser.php index 499d97afec..272abc2a5a 100644 --- a/src/Propel/Generator/Util/SqlParser.php +++ b/src/Propel/Generator/Util/SqlParser.php @@ -31,7 +31,7 @@ class SqlParser * Also resets the parsing cursor (see getNextStatement) * * @param string $sql The SQL string to parse -* @return void + * @return void */ public function setSQL($sql) { diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index d65c47d069..01d913e46f 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -702,7 +702,7 @@ public function getPrimaryTableName() * set, of course, in order to be useful. * * @param string $tableName -* @return void + * @return void */ public function setPrimaryTableName($tableName) { @@ -778,7 +778,7 @@ public function put($key, $value) * Criteria, overwriting previous settings. * * @param mixed $t Mappings to be stored in this map. -* @return void + * @return void */ public function putAll($t) { @@ -964,7 +964,7 @@ public function addJoin($left, $right, $joinType = null) * array(FoldersTableMap::alias( 'fo', FoldersTableMap::LFT ), FoldersTableMap::alias( 'parent', FoldersTableMap::RGT ), Criteria::LESS_EQUAL ) * ), * Criteria::LEFT_JOIN - * ); + * ); * * @see addJoin() * @param array $conditions An array of conditions, each condition being an array (left, right, operator) @@ -1833,7 +1833,7 @@ public function addOr($p1, $p2 = null, $p3 = null, $preferColumnCondition = true * @param mixed $value * @param string $operator A String, like Criteria::EQUAL. * @param boolean $preferColumnCondition If true, the condition is combined with an existing condition on the same column - * (necessary for Propel 1.4 compatibility). + * (necessary for Propel 1.4 compatibility). * If false, the condition is combined with the last existing condition. * * @return $this A modified Criteria object. @@ -2577,6 +2577,8 @@ public function doCount(ConnectionInterface $con = null) * Checks whether the Criteria needs to use column aliasing * This is implemented in a service class rather than in Criteria itself * in order to avoid doing the tests when it's not necessary (e.g. for SELECTs) + * + * @return bool */ public function needsSelectAliases() { @@ -2789,7 +2791,7 @@ public function _endif() /** * Ensures deep cloning of attached objects -* @return void + * @return void */ public function __clone() { @@ -2816,7 +2818,7 @@ public function isIdentifierQuotingEnabled() /** * @param boolean $identifierQuoting -* @return void + * @return void */ public function setIdentifierQuoting($identifierQuoting) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php index 4bf8d52e9d..cff66f0642 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php @@ -91,10 +91,10 @@ public function __construct(Criteria $outer, $column, $value, $comparison = null } /** - * Init some properties with the help of outer class - * @param Criteria $criteria The outer class -* @return void - */ + * Init some properties with the help of outer class + * @param Criteria $criteria The outer class + * @return void + */ public function init(Criteria $criteria) { try { @@ -113,7 +113,7 @@ public function init(Criteria $criteria) /** * Set the $column and $table properties based on a column name or object -* @return void + * @return void */ protected function setColumn($column) { @@ -301,6 +301,7 @@ public function __toString() * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended + * @return void */ abstract protected function appendPsForUniqueClauseTo(&$sb, array &$params); @@ -390,7 +391,7 @@ public function getAttachedCriterion() /** * Ensures deep cloning of attached objects -* @return void + * @return void */ public function __clone() { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php index f180d3ac1b..bbea6fbde2 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php @@ -63,7 +63,7 @@ public function isIgnoreCase() * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended -* @return void + * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php index 33b8df636f..46533fb2a6 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php @@ -23,7 +23,7 @@ class BasicModelCriterion extends AbstractModelCriterion * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended -* @return void + * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php index 53efcbb5de..1518160d6b 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php @@ -36,7 +36,7 @@ public function __construct(Criteria $outer, $column, $value, $comparison = Crit * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended -* @return void + * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php index 4571ded92e..8b09120827 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php @@ -20,7 +20,7 @@ class BinaryModelCriterion extends AbstractModelCriterion * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended -* @return void + * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php index 1d68991236..ca83a3792a 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php @@ -34,7 +34,7 @@ public function __construct(Criteria $outer, $value) * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended -* @return void + * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php index 21ddba1fc4..2ecd53514d 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php @@ -36,7 +36,7 @@ public function __construct(Criteria $outer, $column, $value, $comparison = Crit * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended -* @return void + * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php index d8f070fbda..07804e8a5c 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php @@ -21,7 +21,7 @@ class InModelCriterion extends AbstractModelCriterion * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended -* @return void + * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php index 857b07c974..fd9e68ead6 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php @@ -63,7 +63,7 @@ public function isIgnoreCase() * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended -* @return void + * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php index 4747ad5015..a3853a3d35 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php @@ -51,7 +51,7 @@ public function isIgnoreCase() * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended -* @return void + * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php index 3e08172cd9..50202be91c 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php @@ -48,7 +48,7 @@ public function __construct(Criteria $outer, $column, $value, $type = PDO::PARAM * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended -* @return void + * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php index 87f57cb644..1af8296311 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php @@ -49,7 +49,7 @@ public function __construct(Criteria $outer, $clause, $column, $value = null, $t * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended -* @return void + * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php index cf7bc913f1..ea486493e9 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php @@ -22,7 +22,7 @@ class SeveralModelCriterion extends AbstractModelCriterion * * @param string $sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended -* @return void + * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { @@ -50,6 +50,12 @@ protected function appendPsForUniqueClauseTo(&$sb, array &$params) /** * Replace only once * taken from http://www.php.net/manual/en/function.str-replace.php + * + * @param string $search + * @param string $replace + * @param string $subject + * + * @return string */ protected static function strReplaceOnce($search, $replace, $subject) { diff --git a/src/Propel/Runtime/ActiveQuery/Join.php b/src/Propel/Runtime/ActiveQuery/Join.php index 23fbab9e45..9b2f1f3055 100644 --- a/src/Propel/Runtime/ActiveQuery/Join.php +++ b/src/Propel/Runtime/ActiveQuery/Join.php @@ -114,7 +114,7 @@ public function __construct($leftColumn = null, $rightColumn = null, $joinType = * @param string $right The right column of the join condition * (may contain an alias name) * @param string $operator The comparison operator of the join condition, default Join::EQUAL -* @return void + * @return void */ public function addCondition($left, $right, $operator = self::EQUAL) { @@ -143,7 +143,7 @@ public function addCondition($left, $right, $operator = self::EQUAL) * @param array $rights The right columns of the join condition * @param string[] $operators The comparison operators of the join condition, default Join::EQUAL * @throws \Propel\Runtime\Exception\LogicException -* @return void + * @return void */ public function addConditions($lefts, $rights, $operators = []) { @@ -174,7 +174,7 @@ public function addConditions($lefts, $rights, $operators = []) * @param string $rightColumnName * @param string $rightTableAlias * @param string $operator The comparison operator of the join condition, default Join::EQUAL -* @return void + * @return void */ public function addExplicitCondition( $leftTableName, @@ -203,7 +203,7 @@ public function addExplicitCondition( * @param string|null $leftTableAlias * @param mixed $leftColumnValue * @param string $operator -* @return void + * @return void */ public function addLocalValueCondition($leftTableName, $leftColumnName, $leftTableAlias, $leftColumnValue, $operator = self::EQUAL) { @@ -269,7 +269,7 @@ public function getConditions() /** * @param string $operator the comparison operator for the join condition -* @return void + * @return void */ public function addOperator($operator) { @@ -299,7 +299,7 @@ public function getOperators() * @param string $joinType The type of the join. Valid join types are * null (adding the join condition to the where clause), * Criteria::LEFT_JOIN(), Criteria::RIGHT_JOIN(), and Criteria::INNER_JOIN() -* @return void + * @return void */ public function setJoinType($joinType = null) { @@ -326,7 +326,7 @@ public function getJoinType() * $join->addLeftColumnName('AUTHOR_ID'); * * @param string $left The name of the left column to add -* @return void + * @return void */ public function addLeftColumnName($left) { @@ -337,7 +337,7 @@ public function addLeftColumnName($left) * Adds a value for a leftColumn. * * @param string|number $value an actual value -* @return void + * @return void */ public function addLeftValue($value) { @@ -463,7 +463,7 @@ public function getLeftTableWithAlias() * $join->addRightColumnName('ID'); * * @param string $right The name of the right column to add -* @return void + * @return void */ public function addRightColumnName($right) { @@ -607,7 +607,7 @@ public function setAdapter(AdapterInterface $db) * Set a custom join condition * * @param AbstractCriterion $joinCondition a Join condition -* @return void + * @return void */ public function setJoinCondition(AbstractCriterion $joinCondition) { @@ -628,7 +628,7 @@ public function getJoinCondition() * Set the custom join condition Criterion based on the conditions of this join * * @param Criteria $c A Criteria object to get Criterions from -* @return void + * @return void */ public function buildJoinCondition(Criteria $c) { @@ -759,7 +759,7 @@ public function isIdentifierQuotingEnabled() /** * @param boolean $identifierQuoting -* @return void + * @return void */ public function setIdentifierQuoting($identifierQuoting) { diff --git a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php index 2c6e18dad7..a3071715ec 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php @@ -453,7 +453,7 @@ public function getPreviousJoin() * by default this is null, but after useQuery this is set the to the join of that use * * @param Join $previousJoin The previousJoin for this ModelCriteria -* @return void + * @return void */ public function setPreviousJoin(Join $previousJoin) { @@ -822,7 +822,7 @@ public function clear() * * @param ModelCriteria $criteria The primary criteria * @param Join $previousJoin The previousJoin for this ModelCriteria -* @return void + * @return void */ public function setPrimaryCriteria(ModelCriteria $criteria, Join $previousJoin) { @@ -2283,7 +2283,7 @@ public function __call($name, $arguments) /** * Ensures deep cloning of attached objects -* @return void + * @return void */ public function __clone() { diff --git a/src/Propel/Runtime/ActiveQuery/ModelWith.php b/src/Propel/Runtime/ActiveQuery/ModelWith.php index aecaa0b438..273d4e6b94 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelWith.php +++ b/src/Propel/Runtime/ActiveQuery/ModelWith.php @@ -87,7 +87,7 @@ public function __construct(ModelJoin $join = null) * Fills the ModelWith properties using a ModelJoin as source * * @param ModelJoin $join -* @return void + * @return void */ public function init(ModelJoin $join) { diff --git a/src/Propel/Runtime/Adapter/AdapterInterface.php b/src/Propel/Runtime/Adapter/AdapterInterface.php index b5b1963961..686c504134 100644 --- a/src/Propel/Runtime/Adapter/AdapterInterface.php +++ b/src/Propel/Runtime/Adapter/AdapterInterface.php @@ -43,6 +43,7 @@ public function getConnection($conparams); * * @param ConnectionInterface $con * @param string $charset The $string charset encoding. + * @return void */ public function setCharset(ConnectionInterface $con, $charset); diff --git a/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php index e68fe211fb..958923c63a 100644 --- a/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php @@ -32,7 +32,7 @@ class MssqlAdapter extends PdoAdapter implements SqlAdapterInterface * * @param ConnectionInterface $con * @param string $charset -* @return void + * @return void */ public function setCharset(ConnectionInterface $con, $charset) { @@ -280,7 +280,7 @@ public function applyLimit(&$sql, $offset, $limit) * @param array $params * @param Criteria $values * @param DatabaseMap $dbMap -* @return void + * @return void */ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap) { diff --git a/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php index 69389d61aa..d80acb1140 100644 --- a/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php @@ -70,7 +70,7 @@ public function strLength($s) * @param string $table The name of the table to lock. * * @throws \PDOException No Statement could be created or executed. -* @return void + * @return void */ public function lockTable($con, $table) { @@ -84,7 +84,7 @@ public function lockTable($con, $table) * @param string $table The name of the table to unlock. * * @throws \PDOException No Statement could be created or executed. -* @return void + * @return void */ public function unlockTable($con, $table) { @@ -120,7 +120,7 @@ public function quoteIdentifierTable($table) * @param string $sql * @param integer $offset * @param integer $limit -* @return void + * @return void */ public function applyLimit(&$sql, $offset, $limit) { diff --git a/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php b/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php index 21be3de436..b8f054c57c 100644 --- a/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php @@ -39,7 +39,7 @@ class OracleAdapter extends PdoAdapter implements SqlAdapterInterface * * @param ConnectionInterface $con * @param array $settings -* @return void + * @return void */ public function initConnection(ConnectionInterface $con, array $settings) { @@ -107,7 +107,7 @@ public function strLength($s) * @param integer $offset * @param integer $limit * @param null|Criteria $criteria -* @return void + * @return void */ public function applyLimit(&$sql, $offset, $limit, $criteria = null) { diff --git a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php index 11cad700b1..540ada0ca5 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php @@ -119,7 +119,7 @@ protected function prepareParams($conparams) * * @param ConnectionInterface $con * @param array $settings An array of settings. -* @return void + * @return void */ public function initConnection(ConnectionInterface $con, array $settings) { @@ -144,7 +144,7 @@ public function initConnection(ConnectionInterface $con, array $settings) * * @param ConnectionInterface $con * @param string $charset The $string charset encoding. -* @return void + * @return void */ public function setCharset(ConnectionInterface $con, $charset) { @@ -375,7 +375,7 @@ public function getTimeFormatter() * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) * @param Criteria $values * @param DatabaseMap $dbMap -* @return void + * @return void */ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap) { @@ -560,7 +560,7 @@ public function turnSelectColumnsToAliases(Criteria $criteria) * @param \PDOStatement $stmt * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) * @param DatabaseMap $dbMap -* @return void + * @return void */ public function bindValues(\PDOStatement $stmt, array $params, DatabaseMap $dbMap) { diff --git a/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php index b25b0f51f8..b68bfbd631 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php @@ -126,7 +126,7 @@ public function getTimeFormatter() * @param string $sql * @param integer $offset * @param integer $limit -* @return void + * @return void */ public function applyLimit(&$sql, $offset, $limit) { @@ -255,6 +255,7 @@ public function doExplainPlan(ConnectionInterface $con, $query) * Explain Plan compute query getter * * @param string $query query to explain + * @return string */ public function getExplainPlanQuery($query) { diff --git a/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php b/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php index bd6cef0847..a373eca88b 100644 --- a/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php @@ -29,7 +29,7 @@ class SqliteAdapter extends PdoAdapter implements SqlAdapterInterface * @param string $charset The charset encoding. * * @throws \Propel\Runtime\Exception\PropelException If the specified charset doesn't match sqlite_libencoding() -* @return void + * @return void */ public function setCharset(ConnectionInterface $con, $charset) { @@ -108,7 +108,7 @@ public function quoteIdentifier($text) * @param string $sql * @param integer $offset * @param integer $limit -* @return void + * @return void */ public function applyLimit(&$sql, $offset, $limit) { diff --git a/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php b/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php index 88de46c2e3..94f96aa79f 100644 --- a/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php @@ -29,7 +29,7 @@ class SqlsrvAdapter extends MssqlAdapter implements SqlAdapterInterface * * @param ConnectionInterface $con * @param array $settings An array of settings. -* @return void + * @return void */ public function initConnection(ConnectionInterface $con, array $settings) { @@ -46,7 +46,7 @@ public function initConnection(ConnectionInterface $con, array $settings) * @param string $charset * * @throws \Propel\Runtime\Adapter\Exception\UnsupportedEncodingException -* @return void + * @return void */ public function setCharset(ConnectionInterface $con, $charset) { @@ -69,7 +69,7 @@ public function setCharset(ConnectionInterface $con, $charset) * @param array $params * @param Criteria $values * @param DatabaseMap $dbMap -* @return void + * @return void */ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap) { diff --git a/src/Propel/Runtime/Collection/ArrayCollection.php b/src/Propel/Runtime/Collection/ArrayCollection.php index 3d51e6c04c..fc8c9b35fa 100644 --- a/src/Propel/Runtime/Collection/ArrayCollection.php +++ b/src/Propel/Runtime/Collection/ArrayCollection.php @@ -34,7 +34,7 @@ class ArrayCollection extends Collection * * @throws ReadOnlyModelException * @throws PropelException -* @return void + * @return void */ public function save($con = null) { @@ -62,7 +62,7 @@ public function save($con = null) * * @throws ReadOnlyModelException * @throws PropelException -* @return void + * @return void */ public function delete($con = null) { @@ -107,7 +107,7 @@ public function getPrimaryKeys($usePrefix = true) * Does not empty the collection before adding the data from the array * * @param array $arr -* @return void + * @return void */ public function fromArray($arr) { diff --git a/src/Propel/Runtime/Collection/Collection.php b/src/Propel/Runtime/Collection/Collection.php index 8762f55c75..92d2b2b024 100644 --- a/src/Propel/Runtime/Collection/Collection.php +++ b/src/Propel/Runtime/Collection/Collection.php @@ -74,7 +74,7 @@ public function __construct($data = []) /** * @param mixed $value -* @return void + * @return void */ public function append($value) { @@ -104,7 +104,7 @@ public function &offsetGet($offset) /** * @param mixed $offset * @param mixed $value -* @return void + * @return void */ public function offsetSet($offset, $value) { @@ -117,7 +117,7 @@ public function offsetSet($offset, $value) /** * @param mixed $offset -* @return void + * @return void */ public function offsetUnset($offset) { @@ -126,7 +126,7 @@ public function offsetUnset($offset) /** * @param array $input -* @return void + * @return void */ public function exchangeArray($input) { @@ -155,7 +155,7 @@ public function getArrayCopy() * Set the data in the collection * * @param array $data -* @return void + * @return void */ public function setData($data) { @@ -275,7 +275,7 @@ public function shift() * Prepend one elements to the end of the collection * * @param mixed $value the element to prepend -* @return void + * @return void */ public function push($value) { @@ -305,7 +305,7 @@ public function prepend($value) * * @param mixed $key * @param mixed $value -* @return void + * @return void */ public function set($key, $value) { @@ -399,7 +399,7 @@ public function serialize() /** * @param string $data -* @return void + * @return void */ public function unserialize($data) { @@ -415,7 +415,7 @@ public function unserialize($data) * Set the model of the elements in the collection * * @param string $model Name of the Propel object classes stored in the collection -* @return void + * @return void */ public function setModel($model) { @@ -464,7 +464,7 @@ public function getTableMapClass() /** * @param AbstractFormatter $formatter -* @return void + * @return void */ public function setFormatter(AbstractFormatter $formatter) { @@ -586,7 +586,7 @@ public function __toString() /** * Creates clones of the containing data. -* @return void + * @return void */ public function __clone() { diff --git a/src/Propel/Runtime/Collection/ObjectCollection.php b/src/Propel/Runtime/Collection/ObjectCollection.php index af66f72316..323ab6b8f0 100644 --- a/src/Propel/Runtime/Collection/ObjectCollection.php +++ b/src/Propel/Runtime/Collection/ObjectCollection.php @@ -43,7 +43,7 @@ public function __construct($data = []) /** * @param array $input -* @return void + * @return void */ public function exchangeArray($input) { @@ -65,7 +65,7 @@ public function setData($data) * Save all the elements in the collection * * @param ConnectionInterface $con -* @return void + * @return void */ public function save($con = null) { @@ -87,7 +87,7 @@ public function save($con = null) * Delete all the elements in the collection * * @param ConnectionInterface $con -* @return void + * @return void */ public function delete($con = null) { @@ -130,7 +130,7 @@ public function getPrimaryKeys($usePrefix = true) * Does not empty the collection before adding the data from the array * * @param array $arr -* @return void + * @return void */ public function fromArray($arr) { @@ -415,7 +415,7 @@ protected function rebuildIndex() /** * @param mixed $offset -* @return void + * @return void */ public function offsetUnset($offset) { @@ -430,7 +430,7 @@ public function offsetUnset($offset) /** * @param mixed $element -* @return void + * @return void */ public function removeObject($element) { @@ -441,7 +441,7 @@ public function removeObject($element) /** * @param mixed $value -* @return void + * @return void */ public function append($value) { @@ -462,7 +462,7 @@ public function append($value) /** * @param mixed $offset * @param mixed $value -* @return void + * @return void */ public function offsetSet($offset, $value) { diff --git a/src/Propel/Runtime/Collection/OnDemandCollection.php b/src/Propel/Runtime/Collection/OnDemandCollection.php index cfc2b9d8e8..e3f6aa3881 100644 --- a/src/Propel/Runtime/Collection/OnDemandCollection.php +++ b/src/Propel/Runtime/Collection/OnDemandCollection.php @@ -32,7 +32,7 @@ class OnDemandCollection extends Collection /** * @param \Propel\Runtime\Formatter\ObjectFormatter $formatter * @param DataFetcherInterface $dataFetcher -* @return void + * @return void */ public function initIterator(AbstractFormatter $formatter, DataFetcherInterface $dataFetcher) { @@ -94,7 +94,7 @@ public function toArray($keyColumn = null, $usePrefix = false, $keyType = TableM * Does not empty the collection before adding the data from the array * * @param array $arr -* @return void + * @return void */ public function fromArray($arr) { @@ -140,7 +140,7 @@ public function &offsetGet($offset) * * @param integer $offset * @param mixed $value -* @return void + * @return void */ public function offsetSet($offset, $value) { @@ -150,7 +150,7 @@ public function offsetSet($offset, $value) /** * @throws \Propel\Runtime\Collection\Exception\ReadOnlyModelException * @param integer $offset -* @return void + * @return void */ public function offsetUnset($offset) { @@ -161,7 +161,7 @@ public function offsetUnset($offset) /** * @throws \Propel\Runtime\Exception\PropelException -* @return void + * @return string */ public function serialize() { @@ -171,7 +171,7 @@ public function serialize() /** * @throws \Propel\Runtime\Exception\PropelException * @param string $data -* @return void + * @return void */ public function unserialize($data) { diff --git a/src/Propel/Runtime/Collection/OnDemandIterator.php b/src/Propel/Runtime/Collection/OnDemandIterator.php index 4803f5e5b8..bd93bfe92a 100644 --- a/src/Propel/Runtime/Collection/OnDemandIterator.php +++ b/src/Propel/Runtime/Collection/OnDemandIterator.php @@ -104,7 +104,7 @@ public function key() /** * Advances the cursor in the statement * Closes the cursor if the end of the statement is reached -* @return void + * @return void */ public function next() { @@ -119,7 +119,7 @@ public function next() /** * Initializes the iterator by advancing to the first position * This method can only be called once (this is a NoRewindIterator) -* @return void + * @return void */ public function rewind() { diff --git a/src/Propel/Runtime/Connection/ConnectionManagerInterface.php b/src/Propel/Runtime/Connection/ConnectionManagerInterface.php index 783ca39316..0e368ab7c7 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerInterface.php @@ -16,6 +16,7 @@ interface ConnectionManagerInterface { /** * @param string $name The datasource name associated to this connection + * @return void */ public function setName($name); diff --git a/src/Propel/Runtime/Connection/ConnectionManagerMasterSlave.php b/src/Propel/Runtime/Connection/ConnectionManagerMasterSlave.php index aee964571b..abd1c5f031 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerMasterSlave.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerMasterSlave.php @@ -33,7 +33,7 @@ public function isForceMasterConnection() * * @param boolean $isForceMasterConnection * @deprecated Use setForcePrimaryConnection() instead. -* @return void + * @return void */ public function setForceMasterConnection($isForceMasterConnection) { diff --git a/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php b/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php index 1cd4309840..57b135abb1 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php @@ -49,7 +49,7 @@ class ConnectionManagerPrimaryReplica implements ConnectionManagerInterface /** * @param string $name The datasource name associated to this connection -* @return void + * @return void */ public function setName($name) { @@ -78,7 +78,7 @@ public function isForcePrimaryConnection() * For replication, set whether to always force the use of a primary connection. * * @param boolean $isForceMasterConnection -* @return void + * @return void */ public function setForcePrimaryConnection($isForceMasterConnection) { @@ -97,7 +97,7 @@ public function setForcePrimaryConnection($isForceMasterConnection) * * * @param array $configuration -* @return void + * @return void */ public function setWriteConfiguration($configuration) { @@ -124,7 +124,7 @@ public function setWriteConfiguration($configuration) * * * @param array $configuration -* @return void + * @return void */ public function setReadConfiguration($configuration) { diff --git a/src/Propel/Runtime/Connection/ConnectionManagerSingle.php b/src/Propel/Runtime/Connection/ConnectionManagerSingle.php index c74c9e885f..d45a02d7af 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerSingle.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerSingle.php @@ -34,7 +34,7 @@ class ConnectionManagerSingle implements ConnectionManagerInterface /** * @param string $name The datasource name associated to this connection -* @return void + * @return void */ public function setName($name) { diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index d9676542e2..cd5b256f43 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -166,7 +166,7 @@ public function getNestedTransactionCount() /** * Set the current transaction depth. * @param int $v The new depth. -* @return void + * @return void */ protected function setNestedTransactionCount($v) { @@ -518,7 +518,7 @@ public function lastInsertId($name = null) /** * Clears any stored prepared statements for this connection. -* @return void + * @return void */ public function clearStatementCache() { @@ -564,7 +564,7 @@ public function getLastExecutedQuery() * Set the SQL code for the latest query executed by Propel * * @param string $query Executable SQL code -* @return void + * @return void */ public function setLastExecutedQuery($query) { @@ -575,7 +575,7 @@ public function setLastExecutedQuery($query) * Enable or disable the query debug features * * @param boolean $value True to enable debug (default), false to disable it -* @return void + * @return void */ public function useDebug($value = true) { @@ -590,7 +590,7 @@ public function useDebug($value = true) /** * @param array $logMethods -* @return void + * @return void */ public function setLogMethods($logMethods) { @@ -617,7 +617,7 @@ protected function isLogEnabledForMethod($methodName) /** * {@inheritDoc} -* @return void + * @return void */ public function setLogger(LoggerInterface $logger) { @@ -643,7 +643,7 @@ public function getLogger() * Logs the method call or the executed SQL statement. * * @param string $msg Message to log. -* @return void + * @return void */ public function log($msg) { diff --git a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php index 30cf6ad2c1..55835165c3 100644 --- a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php @@ -38,7 +38,7 @@ class ProfilerConnectionWrapper extends ConnectionWrapper /** * @param \Propel\Runtime\Util\Profiler $profiler -* @return void + * @return void */ public function setProfiler(Profiler $profiler) { @@ -126,6 +126,6 @@ public function log($msg) } $msg = $this->getProfiler()->getProfile() . $msg; - return parent::log($msg); + parent::log($msg); } } diff --git a/src/Propel/Runtime/Connection/StatementWrapper.php b/src/Propel/Runtime/Connection/StatementWrapper.php index bca7d9a0c4..4c95734311 100644 --- a/src/Propel/Runtime/Connection/StatementWrapper.php +++ b/src/Propel/Runtime/Connection/StatementWrapper.php @@ -313,7 +313,7 @@ public function getStatement() /** * @param \PDOStatement $statement -* @return void + * @return void */ public function setStatement(\PDOStatement $statement) { diff --git a/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php b/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php index 396c386738..be73091d52 100644 --- a/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php @@ -22,7 +22,7 @@ public function __construct($dataObject) /** * {@inheritDoc} -* @return void + * @return void */ public function setDataObject($dataObject) { diff --git a/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php b/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php index b1e62fbc29..275de5505b 100644 --- a/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php @@ -18,7 +18,7 @@ class ArrayDataFetcher extends AbstractDataFetcher /** * {@inheritDoc} -* @return void + * @return void */ public function next() { @@ -64,7 +64,7 @@ public function valid() /** * {@inheritDoc} -* @return void + * @return void */ public function rewind() { @@ -95,7 +95,7 @@ public function count() * Sets the current index type. * * @param string $indexType one of TableMap::TYPE_* -* @return void + * @return void */ public function setIndexType($indexType) { @@ -104,7 +104,7 @@ public function setIndexType($indexType) /** * {@inheritDoc} -* @return void + * @return void */ public function close() { diff --git a/src/Propel/Runtime/DataFetcher/PDODataFetcher.php b/src/Propel/Runtime/DataFetcher/PDODataFetcher.php index 669c0e222d..8a9653d321 100644 --- a/src/Propel/Runtime/DataFetcher/PDODataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/PDODataFetcher.php @@ -66,7 +66,7 @@ public function fetch($style = null) /** * {@inheritDoc} -* @return void + * @return void */ public function next() { @@ -106,7 +106,7 @@ public function valid() * Not supported in PDODataFetcher. * It actually fetches the first row, since a foreach in php triggers that * function as init. -* @return void + * @return void */ public function rewind() { @@ -116,7 +116,7 @@ public function rewind() /** * {@inheritDoc} -* @return void + * @return void */ public function close() { @@ -169,7 +169,7 @@ public function getIndexType() * @param int $type * @param int $maxlen * @param mixed $driverdata -* @return void + * @return void */ public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null) { diff --git a/src/Propel/Runtime/Formatter/AbstractFormatter.php b/src/Propel/Runtime/Formatter/AbstractFormatter.php index 32d5826456..088c34619e 100644 --- a/src/Propel/Runtime/Formatter/AbstractFormatter.php +++ b/src/Propel/Runtime/Formatter/AbstractFormatter.php @@ -80,7 +80,7 @@ public function __construct(BaseModelCriteria $criteria = null, DataFetcherInter * Sets a DataFetcherInterface object. * * @param DataFetcherInterface $dataFetcher -* @return void + * @return void */ public function setDataFetcher(DataFetcherInterface $dataFetcher) { diff --git a/src/Propel/Runtime/Formatter/ArrayFormatter.php b/src/Propel/Runtime/Formatter/ArrayFormatter.php index 6d34c28aa7..061e9713b1 100644 --- a/src/Propel/Runtime/Formatter/ArrayFormatter.php +++ b/src/Propel/Runtime/Formatter/ArrayFormatter.php @@ -128,7 +128,7 @@ public function isObjectFormatter() * The first object to hydrate is the model of the Criteria * The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one * - * @param array $row associative array indexed by column number, + * @param array $row associative array indexed by column number, * as returned by DataFetcher::fetch() * * @return array diff --git a/src/Propel/Runtime/Formatter/OnDemandFormatter.php b/src/Propel/Runtime/Formatter/OnDemandFormatter.php index e88d4d9347..b65bceedf3 100644 --- a/src/Propel/Runtime/Formatter/OnDemandFormatter.php +++ b/src/Propel/Runtime/Formatter/OnDemandFormatter.php @@ -95,7 +95,7 @@ public function getCollection() * The first object to hydrate is the model of the Criteria * The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one * - * @param array $row associative array with data + * @param array $row associative array with data * * @return ActiveRecordInterface */ diff --git a/src/Propel/Runtime/Map/ColumnMap.php b/src/Propel/Runtime/Map/ColumnMap.php index e991c2e2d7..09fbb91c17 100644 --- a/src/Propel/Runtime/Map/ColumnMap.php +++ b/src/Propel/Runtime/Map/ColumnMap.php @@ -151,7 +151,7 @@ public function getFullyQualifiedName() * Set the php name of this column. * * @param string $phpName A string representing the PHP name. -* @return void + * @return void */ public function setPhpName($phpName) { @@ -172,7 +172,7 @@ public function getPhpName() * Set the Propel type of this column. * * @param string $type A string representing the Propel type (e.g. PropelTypes::DATE). -* @return void + * @return void */ public function setType($type) { @@ -277,7 +277,7 @@ public function isText() * Set the size of this column. * * @param int $size An int specifying the size. -* @return void + * @return void */ public function setSize($size) { @@ -298,7 +298,7 @@ public function getSize() * Set if this column is a primary key or not. * * @param boolean $pk True if column is a primary key. -* @return void + * @return void */ public function setPrimaryKey($pk) { @@ -319,7 +319,7 @@ public function isPrimaryKey() * Set if this column may be null. * * @param boolean $nn True if column may be null. -* @return void + * @return void */ public function setNotNull($nn) { @@ -340,7 +340,7 @@ public function isNotNull() * Sets the default value for this column. * * @param mixed $defaultValue the default value for the column -* @return void + * @return void */ public function setDefaultValue($defaultValue) { @@ -361,7 +361,7 @@ public function getDefaultValue() * * @param string $tableName The name of the table that is foreign. * @param string $columnName The name of the column that is foreign. -* @return void + * @return void */ public function setForeignKey($tableName, $columnName) { @@ -387,6 +387,8 @@ public function isForeignKey() /** * Get the RelationMap object for this foreign key + * + * @return \Propel\Runtime\Map\RelationMap|null */ public function getRelation() { @@ -402,6 +404,8 @@ public function getRelation() } } } + + return null; } /** @@ -464,7 +468,7 @@ public function getRelatedColumn() * Set the valueSet of this column (only valid for ENUM and SET columns). * * @param array $values A list of allowed values -* @return void + * @return void */ public function setValueSet($values) { @@ -506,6 +510,7 @@ public function getValueSetKey($value) * * @param string $str The expression we want to apply the ignore case formatting to (e.g. the column name). * @param \Propel\Runtime\Adapter\AdapterInterface $db + * @return string */ public function ignoreCase($str, AdapterInterface $db) { @@ -538,7 +543,7 @@ public static function normalizeName($name) * Set this column to be a primaryString column. * * @param boolean $pkString -* @return void + * @return void */ public function setPrimaryString($pkString) { diff --git a/src/Propel/Runtime/Map/DatabaseMap.php b/src/Propel/Runtime/Map/DatabaseMap.php index b6d0b63a64..ea7f11f4af 100644 --- a/src/Propel/Runtime/Map/DatabaseMap.php +++ b/src/Propel/Runtime/Map/DatabaseMap.php @@ -85,7 +85,7 @@ public function addTable($tableName) * Add a new table object to the database. * * @param \Propel\Runtime\Map\TableMap $table The table to add -* @return void + * @return void */ public function addTableObject(TableMap $table) { diff --git a/src/Propel/Runtime/Map/RelationMap.php b/src/Propel/Runtime/Map/RelationMap.php index 41c87d8536..9d977ea2fb 100644 --- a/src/Propel/Runtime/Map/RelationMap.php +++ b/src/Propel/Runtime/Map/RelationMap.php @@ -92,7 +92,7 @@ public function isPolymorphic() /** * @param boolean $polymorphic -* @return void + * @return void */ public function setPolymorphic($polymorphic) { @@ -133,7 +133,7 @@ public function getPluralName() * Set the type * * @param int $type The relation type (either self::MANY_TO_ONE, self::ONE_TO_MANY, or self::ONE_TO_ONE) -* @return void + * @return void */ public function setType($type) { @@ -154,7 +154,7 @@ public function getType() * Set the local table * * @param \Propel\Runtime\Map\TableMap $table The local table for this relationship -* @return void + * @return void */ public function setLocalTable(TableMap $table) { @@ -175,7 +175,7 @@ public function getLocalTable() * Set the foreign table * * @param \Propel\Runtime\Map\TableMap $table The foreign table for this relationship -* @return void + * @return void */ public function setForeignTable($table) { @@ -217,7 +217,7 @@ public function getRightTable() * * @param ColumnMap $local The local column * @param ColumnMap|mixed $foreign The foreign column or value -* @return void + * @return void */ public function addColumnMapping(ColumnMap $local, $foreign) { @@ -332,7 +332,7 @@ public function getLocalValues() * Set the onUpdate behavior * * @param string $onUpdate -* @return void + * @return void */ public function setOnUpdate($onUpdate) { @@ -353,7 +353,7 @@ public function getOnUpdate() * Set the onDelete behavior * * @param string $onDelete -* @return void + * @return void */ public function setOnDelete($onDelete) { diff --git a/src/Propel/Runtime/Map/TableMap.php b/src/Propel/Runtime/Map/TableMap.php index ba2d3eadfd..25ef8020bb 100644 --- a/src/Propel/Runtime/Map/TableMap.php +++ b/src/Propel/Runtime/Map/TableMap.php @@ -238,7 +238,7 @@ public function getName() * Set the PHP name of the Table. * * @param string $phpName The PHP Name for this table -* @return void + * @return void */ public function setPhpName($phpName) { @@ -260,7 +260,7 @@ public function getPhpName() * tableMap and Object methods dynamically. * * @param string $classname The ClassName -* @return void + * @return void */ public function setClassName($classname) { @@ -296,7 +296,7 @@ public function getCollectionClassName() * Set the Package of the Table * * @param string $package The Package -* @return void + * @return void */ public function setPackage($package) { @@ -317,7 +317,7 @@ public function getPackage() * Set whether or not to use Id generator for primary key. * * @param boolean $bit -* @return void + * @return void */ public function setUseIdGenerator($bit) { @@ -338,7 +338,7 @@ public function isUseIdGenerator() * Set whether or not to this table uses single table inheritance * * @param boolean $bit -* @return void + * @return void */ public function setSingleTableInheritance($bit) { @@ -359,7 +359,7 @@ public function isSingleTableInheritance() * Sets the name of the sequence used to generate a key * * @param mixed $pkInfo information needed to generate a key -* @return void + * @return void */ public function setPrimaryKeyMethodInfo($pkInfo) { @@ -598,7 +598,7 @@ public function isCrossRef() * Set the isCrossRef * @param boolean $isCrossRef -* @return void + * @return void */ public function setIsCrossRef($isCrossRef) { @@ -629,7 +629,7 @@ public function getForeignKeys() * Build relations * Relations are lazy loaded for performance reasons * This method should be overridden by descendants -* @return void + * @return void */ public function buildRelations() { @@ -805,7 +805,7 @@ public function isIdentifierQuotingEnabled() /** * @param boolean $identifierQuoting -* @return void + * @return void */ public function setIdentifierQuoting($identifierQuoting) { diff --git a/src/Propel/Runtime/Parser/CsvParser.php b/src/Propel/Runtime/Parser/CsvParser.php index 92c4734a1f..13eedf8e38 100644 --- a/src/Propel/Runtime/Parser/CsvParser.php +++ b/src/Propel/Runtime/Parser/CsvParser.php @@ -110,11 +110,11 @@ protected function formatRow($row) } /** - * Escapes a column (escapes quotechar with escapechar) - * - * @param string $input A single value to be escaped for output - * @return string Escaped input value - */ + * Escapes a column (escapes quotechar with escapechar) + * + * @param string $input A single value to be escaped for output + * @return string Escaped input value + */ protected function escape($input) { return str_replace( diff --git a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php index 7fb6ffe524..01d4c0d5f0 100644 --- a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php +++ b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php @@ -93,7 +93,7 @@ public function getDefaultDatasource() /** * @param string $defaultDatasource -* @return void + * @return void */ public function setDefaultDatasource($defaultDatasource) { @@ -123,7 +123,7 @@ public function getAdapterClass($name = null) * * @param string $name The datasource name * @param string $adapterClass -* @return void + * @return void */ public function setAdapterClass($name, $adapterClass) { @@ -135,7 +135,7 @@ public function setAdapterClass($name, $adapterClass) * Reset existing adapters classes and set new classes for all datasources. * * @param string[] $adapterClasses A list of adapters -* @return void + * @return void */ public function setAdapterClasses($adapterClasses) { @@ -174,7 +174,7 @@ public function getAdapter($name = null) * * @param string $name The datasource name * @param \Propel\Runtime\Adapter\AdapterInterface $adapter -* @return void + * @return void */ public function setAdapter($name, AdapterInterface $adapter) { @@ -186,7 +186,7 @@ public function setAdapter($name, AdapterInterface $adapter) * Reset existing adapters and set new adapters for all datasources. * * @param array $adapters A list of adapters -* @return void + * @return void */ public function setAdapters($adapters) { @@ -219,7 +219,7 @@ public function checkVersion($generatorVersion) /** * @param string $databaseMapClass -* @return void + * @return void */ public function setDatabaseMapClass($databaseMapClass) { @@ -253,7 +253,7 @@ public function getDatabaseMap($name = null) * * @param string $name The datasource name * @param \Propel\Runtime\Map\DatabaseMap $databaseMap -* @return void + * @return void */ public function setDatabaseMap($name, DatabaseMap $databaseMap) { @@ -263,7 +263,7 @@ public function setDatabaseMap($name, DatabaseMap $databaseMap) /** * @param string $name The datasource name * @param \Propel\Runtime\Connection\ConnectionManagerInterface $manager -* @return void + * @return void */ public function setConnectionManager($name, ConnectionManagerInterface $manager) { @@ -388,7 +388,7 @@ public function getReadConnection($name) * * @param string $name The datasource name * @param \Propel\Runtime\Connection\ConnectionInterface $connection A database connection -* @return void + * @return void */ public function setConnection($name, ConnectionInterface $connection) { @@ -404,7 +404,7 @@ public function setConnection($name, ConnectionInterface $connection) * getProfiler() is called. * * @param string $profilerClass -* @return void + * @return void */ public function setProfilerClass($profilerClass) { @@ -417,7 +417,7 @@ public function setProfilerClass($profilerClass) * @see \Propel\Runtime\Util\Profiler::setConfiguration() * * @param array $profilerConfiguration -* @return void + * @return void */ public function setProfilerConfiguration($profilerConfiguration) { @@ -429,7 +429,7 @@ public function setProfilerConfiguration($profilerConfiguration) * Set the profiler instance. * * @param \Propel\Runtime\Util\Profiler $profiler -* @return void + * @return void */ public function setProfiler($profiler) { @@ -475,7 +475,7 @@ public function getLogger($name = 'defaultLogger') /** * @param string $name the name of the logger to be set * @param LoggerInterface $logger A logger instance -* @return void + * @return void */ public function setLogger($name, LoggerInterface $logger) { @@ -548,7 +548,7 @@ protected function buildLogger($name = 'defaultLogger') * * @param string $name * @param array $loggerConfiguration -* @return void + * @return void */ public function setLoggerConfiguration($name, $loggerConfiguration) { diff --git a/src/Propel/Runtime/Util/Profiler.php b/src/Propel/Runtime/Util/Profiler.php index a67c6d2203..91ebd74bfc 100644 --- a/src/Propel/Runtime/Util/Profiler.php +++ b/src/Propel/Runtime/Util/Profiler.php @@ -12,8 +12,8 @@ use Propel\Common\Config\Exception\InvalidConfigurationException; /** -* Profiler for Propel -*/ + * Profiler for Propel + */ class Profiler { protected $slowTreshold; @@ -63,7 +63,7 @@ public function __construct($slowTreshold = 0.1, $innerGlue = ': ', $outerGlue = * Set the duration which triggers the 'slow' label on details. * * @param integer $slowTreshold duration in seconds -* @return void + * @return void */ public function setSlowTreshold($slowTreshold) { @@ -74,7 +74,7 @@ public function setSlowTreshold($slowTreshold) * Set the list of details to be included in a profile. * * @param array $details -* @return void + * @return void */ public function setDetails($details) { @@ -85,7 +85,7 @@ public function setDetails($details) * Set the inner glue for the details. * * @param string $innerGlue -* @return void + * @return void */ public function setInnerGlue($innerGlue) { @@ -96,7 +96,7 @@ public function setInnerGlue($innerGlue) * Set the outer glue for the details. * * @param string $outerGlue -* @return void + * @return void */ public function setOuterGlue($outerGlue) { @@ -138,7 +138,7 @@ public function setOuterGlue($outerGlue) * * * @param array $profilerConfiguration -* @return void + * @return void */ public function setConfiguration($profilerConfiguration) { diff --git a/src/Propel/Runtime/Util/PropelDateTime.php b/src/Propel/Runtime/Util/PropelDateTime.php index 12108f7c88..3a5b5971fb 100644 --- a/src/Propel/Runtime/Util/PropelDateTime.php +++ b/src/Propel/Runtime/Util/PropelDateTime.php @@ -161,7 +161,7 @@ public function __sleep() /** * PHP "magic" function called when object is restored from serialized state. * Calls DateTime constructor with previously stored string value of date. -* @return void + * @return void */ public function __wakeup() { diff --git a/src/Propel/Runtime/Util/PropelModelPager.php b/src/Propel/Runtime/Util/PropelModelPager.php index b3c4560d2e..4eba3b9f4a 100644 --- a/src/Propel/Runtime/Util/PropelModelPager.php +++ b/src/Propel/Runtime/Util/PropelModelPager.php @@ -279,7 +279,7 @@ public function getNbResults() * Set the total number of results of the query * * @param int $nb -* @return void + * @return void */ protected function setNbResults($nb) { @@ -330,7 +330,7 @@ public function getLastPage() * Set the number of the first page * * @param int $page -* @return void + * @return void */ protected function setLastPage($page) { @@ -354,7 +354,7 @@ public function getPage() * Set the number of the current page * * @param int $page -* @return void + * @return void */ public function setPage($page) { @@ -399,7 +399,7 @@ public function getMaxPerPage() * Set the maximum number results per page * * @param int $max -* @return void + * @return void */ public function setMaxPerPage($max) { From 48a88b902e26a09c8d18bb02bef5624ab675ca4a Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 23 Jul 2020 16:47:55 +0200 Subject: [PATCH 124/208] Fixes as per review. --- src/Propel/Common/Config/Loader/FileLoader.php | 2 +- src/Propel/Generator/Builder/Om/AbstractOMBuilder.php | 4 +++- src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php | 2 +- src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php | 1 + src/Propel/Generator/Builder/Om/QueryBuilder.php | 1 + .../Propel/Tests/Common/Config/Loader/FileLoaderTest.php | 8 ++++---- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Propel/Common/Config/Loader/FileLoader.php b/src/Propel/Common/Config/Loader/FileLoader.php index a31a0c995c..0b070601f9 100644 --- a/src/Propel/Common/Config/Loader/FileLoader.php +++ b/src/Propel/Common/Config/Loader/FileLoader.php @@ -66,7 +66,7 @@ public function __construct(FileLocatorInterface $locator = null) public function resolveParams(array $configuration) { if ($this->resolved) { - return $configuration; + return []; } $this->config = $configuration; diff --git a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php index 09754a6358..f5ce1262cf 100644 --- a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php @@ -982,7 +982,7 @@ public function applyBehaviorModifierBase($hookName, $modifier, &$script, $tab = * Checks whether any registered behavior content creator on that table exists a contentName * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassName" * @param string $modifier The name of the modifier object providing the method in the behavior - * @return mixed + * @return string|null */ public function getBehaviorContentBase($contentName, $modifier) { @@ -993,6 +993,8 @@ public function getBehaviorContentBase($contentName, $modifier) return $modifier->$contentName($this); } } + + return null; } /** diff --git a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php index eee972e29a..74cf371269 100644 --- a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php @@ -202,7 +202,7 @@ public function applyBehaviorModifier($hookName, &$script, $tab = " ") /** * Checks whether any registered behavior content creator on that table exists a contentName * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassName" - * @return mixed + * @return string|null */ public function getBehaviorContent($contentName) { diff --git a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php index 17c5a3dd7d..38dac25803 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php @@ -121,6 +121,7 @@ public function applyBehaviorModifier($hookName, &$script, $tab = " ") /** * Checks whether any registered behavior content creator on that table exists a contentName * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassName" + * @return string|null */ public function getBehaviorContent($contentName) { diff --git a/src/Propel/Generator/Builder/Om/QueryBuilder.php b/src/Propel/Generator/Builder/Om/QueryBuilder.php index c1220cffe4..d84b3c5926 100644 --- a/src/Propel/Generator/Builder/Om/QueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryBuilder.php @@ -1791,6 +1791,7 @@ public function applyBehaviorModifier($hookName, &$script, $tab = " ") /** * Checks whether any registered behavior content creator on that table exists a contentName * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassName" + * @return string|null */ public function getBehaviorContent($contentName) { diff --git a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php index edf4a338ad..09e9e5f0dd 100644 --- a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php @@ -56,8 +56,8 @@ public function resolveParamsProvider() '->resolve() supports % escaping by doubling it' ], [ - ['foo'=>'bar', 'foo' => ['bar' => ['ding' => 'I\'m a bar %%foo %%bar']]], - ['foo'=>'bar', 'foo' => ['bar' => ['ding' => 'I\'m a bar %foo %bar']]], + ['foo' => ['bar' => ['ding' => 'I\'m a bar %%foo %%bar']]], + ['foo' => ['bar' => ['ding' => 'I\'m a bar %foo %bar']]], '->resolve() supports % escaping by doubling it' ], [ @@ -315,7 +315,7 @@ public function testParameterIsNotStringOrNumber() $this->loader->resolveParams($config); } - public function testCallResolveParamTwiceReturnNull() + public function testCallResolveParamTwiceReturnsEmpty() { $config = [ 'foo' => 'bar', @@ -323,7 +323,7 @@ public function testCallResolveParamTwiceReturnNull() ]; $this->assertEquals(['foo' => 'bar', 'baz' => 'bar'], $this->loader->resolveParams($config)); - $this->assertNull($this->loader->resolveParams($config)); + $this->assertSame([], $this->loader->resolveParams($config)); } } From 4c9abd23587772ae96e57520c1a23865ef9e14e2 Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 24 Jul 2020 01:55:20 +0200 Subject: [PATCH 125/208] Fix CS using Spryker+Slevomat cs ruleset. --- .license | 7 + composer.json | 6 +- config/phpcs.xml | 24 + phpstan-baseline.neon | 31 +- phpstan.neon | 1 - .../Common/Config/ConfigurationManager.php | 66 +- .../Exception/InvalidArgumentException.php | 4 +- .../Config/Exception/JsonParseException.php | 9 +- .../Config/Exception/RuntimeException.php | 4 +- .../Config/Exception/XmlParseException.php | 14 +- src/Propel/Common/Config/FileLocator.php | 2 +- .../Common/Config/Loader/FileLoader.php | 61 +- .../Common/Config/Loader/IniFileLoader.php | 50 +- .../Common/Config/Loader/JsonFileLoader.php | 18 +- .../Common/Config/Loader/LoaderResolver.php | 6 +- .../Common/Config/Loader/PhpFileLoader.php | 15 +- .../Common/Config/Loader/XmlFileLoader.php | 13 +- .../Common/Config/Loader/YamlFileLoader.php | 17 +- .../Common/Config/PropelConfiguration.php | 40 +- .../Common/Config/XmlToArrayConverter.php | 39 +- .../Exception/SetColumnConverterException.php | 22 +- .../Common/Pluralizer/PluralizerInterface.php | 4 +- .../Pluralizer/SimpleEnglishPluralizer.php | 3 +- .../Pluralizer/StandardEnglishPluralizer.php | 62 +- src/Propel/Common/Util/SetColumnConverter.php | 13 +- src/Propel/Generator/Application.php | 14 +- .../AggregateColumnBehavior.php | 52 +- .../AggregateColumnRelationBehavior.php | 29 +- .../Archivable/ArchivableBehavior.php | 58 +- ...rchivableBehaviorObjectBuilderModifier.php | 18 +- ...ArchivableBehaviorQueryBuilderModifier.php | 2 +- .../Behavior/AutoAddPk/AutoAddPkBehavior.php | 6 +- .../ConcreteInheritanceBehavior.php | 32 +- .../ConcreteInheritanceParentBehavior.php | 7 +- .../Behavior/Delegate/DelegateBehavior.php | 28 +- .../Generator/Behavior/I18n/I18nBehavior.php | 75 +- .../I18nBehaviorObjectBuilderModifier.php | 50 +- .../I18n/I18nBehaviorQueryBuilderModifier.php | 20 +- .../Behavior/NestedSet/NestedSetBehavior.php | 33 +- ...NestedSetBehaviorObjectBuilderModifier.php | 125 +- .../NestedSetBehaviorQueryBuilderModifier.php | 85 +- .../QueryCache/QueryCacheBehavior.php | 22 +- .../Behavior/Sluggable/SluggableBehavior.php | 34 +- .../Behavior/Sortable/SortableBehavior.php | 73 +- .../SortableBehaviorObjectBuilderModifier.php | 49 +- .../SortableBehaviorQueryBuilderModifier.php | 32 +- ...ortableBehaviorTableMapBuilderModifier.php | 12 +- .../Timestampable/TimestampableBehavior.php | 20 +- .../Behavior/Validate/ValidateBehavior.php | 42 +- .../Versionable/VersionableBehavior.php | 81 +- ...rsionableBehaviorObjectBuilderModifier.php | 17 +- ...ersionableBehaviorQueryBuilderModifier.php | 8 +- .../Generator/Builder/DataModelBuilder.php | 171 ++- .../Builder/Om/AbstractOMBuilder.php | 247 +-- .../Builder/Om/AbstractObjectBuilder.php | 44 +- .../Generator/Builder/Om/ClassTools.php | 19 +- .../Builder/Om/ExtensionObjectBuilder.php | 11 +- .../Builder/Om/ExtensionQueryBuilder.php | 27 +- .../Om/ExtensionQueryInheritanceBuilder.php | 22 +- .../Generator/Builder/Om/InterfaceBuilder.php | 7 +- .../Builder/Om/MultiExtendObjectBuilder.php | 28 +- .../Generator/Builder/Om/ObjectBuilder.php | 1346 ++++++++++------- .../Generator/Builder/Om/QueryBuilder.php | 275 ++-- .../Builder/Om/QueryInheritanceBuilder.php | 25 +- .../Generator/Builder/Om/TableMapBuilder.php | 355 +++-- .../Om/templates/baseObjectMethodHook.php | 50 +- .../templates/baseObjectMethodMagicCall.php | 2 +- .../Generator/Builder/Util/PropelTemplate.php | 10 +- .../Generator/Builder/Util/SchemaReader.php | 175 ++- .../Generator/Command/AbstractCommand.php | 56 +- .../Command/ConfigConvertCommand.php | 29 +- .../Command/Console/Input/ArrayInput.php | 63 +- .../Command/DatabaseReverseCommand.php | 27 +- .../Command/GraphvizGenerateCommand.php | 19 +- .../Command/Helper/ConsoleHelper.php | 47 +- .../Command/Helper/ConsoleHelper3.php | 41 +- .../Command/Helper/ConsoleHelperInterface.php | 33 +- src/Propel/Generator/Command/InitCommand.php | 46 +- .../Command/MigrationCreateCommand.php | 35 +- .../Command/MigrationDiffCommand.php | 63 +- .../Command/MigrationDownCommand.php | 33 +- .../Command/MigrationMigrateCommand.php | 33 +- .../Command/MigrationStatusCommand.php | 21 +- .../Generator/Command/MigrationUpCommand.php | 33 +- .../Generator/Command/ModelBuildCommand.php | 32 +- .../Generator/Command/SqlBuildCommand.php | 37 +- .../Generator/Command/SqlInsertCommand.php | 13 +- .../Generator/Command/TestPrepareCommand.php | 97 +- .../Generator/Config/ArrayToPhpConverter.php | 9 +- .../Generator/Config/GeneratorConfig.php | 65 +- .../Config/GeneratorConfigInterface.php | 40 +- .../Generator/Config/QuickGeneratorConfig.php | 45 +- .../Exception/ConstraintNotFoundException.php | 1 + .../Generator/Exception/DiffException.php | 1 - .../Exception/InvalidArgumentException.php | 4 +- .../Generator/Exception/LogicException.php | 4 +- .../Generator/Exception/RuntimeException.php | 4 +- .../Generator/Exception/SchemaException.php | 4 +- .../Generator/Manager/AbstractManager.php | 94 +- .../Generator/Manager/GraphvizManager.php | 14 +- .../Generator/Manager/MigrationManager.php | 66 +- src/Propel/Generator/Manager/ModelManager.php | 21 +- .../Generator/Manager/ReverseManager.php | 47 +- src/Propel/Generator/Manager/SqlManager.php | 34 +- src/Propel/Generator/Model/Behavior.php | 62 +- .../Generator/Model/BehaviorableTrait.php | 48 +- src/Propel/Generator/Model/Column.php | 292 ++-- .../Generator/Model/ColumnDefaultValue.php | 22 +- .../Model/ConstraintNameGenerator.php | 21 +- .../Generator/Model/CrossForeignKeys.php | 78 +- src/Propel/Generator/Model/Database.php | 193 ++- .../Generator/Model/Diff/ColumnComparator.php | 7 +- .../Generator/Model/Diff/ColumnDiff.php | 27 +- .../Model/Diff/DatabaseComparator.php | 62 +- .../Generator/Model/Diff/DatabaseDiff.php | 47 +- .../Model/Diff/ForeignKeyComparator.php | 19 +- .../Generator/Model/Diff/IndexComparator.php | 9 +- .../Generator/Model/Diff/TableComparator.php | 63 +- src/Propel/Generator/Model/Diff/TableDiff.php | 219 +-- src/Propel/Generator/Model/Domain.php | 110 +- src/Propel/Generator/Model/ForeignKey.php | 161 +- src/Propel/Generator/Model/IdMethod.php | 4 +- .../Generator/Model/IdMethodParameter.php | 7 +- src/Propel/Generator/Model/Index.php | 58 +- src/Propel/Generator/Model/Inheritance.php | 22 +- src/Propel/Generator/Model/MappingModel.php | 33 +- .../Generator/Model/MappingModelInterface.php | 8 +- src/Propel/Generator/Model/NameFactory.php | 15 +- .../Model/NameGeneratorInterface.php | 22 +- .../Generator/Model/PhpNameGenerator.php | 46 +- src/Propel/Generator/Model/PropelTypes.php | 308 ++-- src/Propel/Generator/Model/Schema.php | 63 +- .../Generator/Model/ScopedMappingModel.php | 14 +- src/Propel/Generator/Model/Table.php | 386 +++-- src/Propel/Generator/Model/Unique.php | 5 +- src/Propel/Generator/Model/VendorInfo.php | 29 +- .../Generator/Platform/DefaultPlatform.php | 244 +-- .../Generator/Platform/MssqlPlatform.php | 65 +- .../Generator/Platform/MysqlPlatform.php | 159 +- .../Generator/Platform/OraclePlatform.php | 76 +- .../Generator/Platform/PgsqlPlatform.php | 121 +- .../Generator/Platform/PlatformInterface.php | 94 +- .../Generator/Platform/SqlitePlatform.php | 103 +- .../Reverse/AbstractSchemaParser.php | 35 +- .../Generator/Reverse/MssqlSchemaParser.php | 103 +- .../Generator/Reverse/MysqlSchemaParser.php | 141 +- .../Generator/Reverse/OracleSchemaParser.php | 91 +- .../Generator/Reverse/PgsqlSchemaParser.php | 165 +- .../Reverse/SchemaParserInterface.php | 16 +- .../Generator/Reverse/SqliteSchemaParser.php | 103 +- .../Schema/Dumper/DumperInterface.php | 20 +- .../Generator/Schema/Dumper/XmlDumper.php | 97 +- src/Propel/Generator/Util/BehaviorLocator.php | 79 +- src/Propel/Generator/Util/PhpParser.php | 23 +- src/Propel/Generator/Util/QuickBuilder.php | 105 +- src/Propel/Generator/Util/SchemaValidator.php | 20 +- src/Propel/Generator/Util/SqlParser.php | 77 +- .../Runtime/ActiveQuery/BaseModelCriteria.php | 50 +- src/Propel/Runtime/ActiveQuery/Criteria.php | 678 +++++---- .../Criterion/AbstractCriterion.php | 89 +- .../Criterion/AbstractModelCriterion.php | 26 +- .../ActiveQuery/Criterion/BasicCriterion.php | 42 +- .../Criterion/BasicModelCriterion.php | 18 +- .../ActiveQuery/Criterion/BinaryCriterion.php | 15 +- .../Criterion/BinaryModelCriterion.php | 5 +- .../ActiveQuery/Criterion/CustomCriterion.php | 14 +- .../ActiveQuery/Criterion/InCriterion.php | 20 +- .../Criterion/InModelCriterion.php | 15 +- .../ActiveQuery/Criterion/LikeCriterion.php | 34 +- .../Criterion/LikeModelCriterion.php | 16 +- .../ActiveQuery/Criterion/RawCriterion.php | 25 +- .../Criterion/RawModelCriterion.php | 33 +- .../Criterion/SeveralModelCriterion.php | 19 +- .../Runtime/ActiveQuery/InstancePoolTrait.php | 15 +- src/Propel/Runtime/ActiveQuery/Join.php | 153 +- .../Runtime/ActiveQuery/ModelCriteria.php | 549 ++++--- src/Propel/Runtime/ActiveQuery/ModelJoin.php | 30 +- src/Propel/Runtime/ActiveQuery/ModelWith.php | 14 +- .../Runtime/ActiveQuery/PropelQuery.php | 10 +- .../NestedSetRecursiveIterator.php | 10 +- src/Propel/Runtime/Adapter/AdapterFactory.php | 6 +- .../Runtime/Adapter/AdapterInterface.php | 53 +- .../Runtime/Adapter/MSSQL/MssqlDebugPDO.php | 1 - .../Runtime/Adapter/MSSQL/MssqlPropelPDO.php | 14 +- .../Runtime/Adapter/Pdo/MssqlAdapter.php | 80 +- .../Runtime/Adapter/Pdo/MysqlAdapter.php | 66 +- .../Runtime/Adapter/Pdo/OracleAdapter.php | 64 +- src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php | 157 +- .../Runtime/Adapter/Pdo/PgsqlAdapter.php | 60 +- .../Runtime/Adapter/Pdo/SqliteAdapter.php | 33 +- .../Runtime/Adapter/Pdo/SqlsrvAdapter.php | 55 +- .../Runtime/Adapter/SqlAdapterInterface.php | 60 +- .../Runtime/Collection/ArrayCollection.php | 64 +- src/Propel/Runtime/Collection/Collection.php | 142 +- .../Runtime/Collection/CollectionIterator.php | 36 +- .../Runtime/Collection/ObjectCollection.php | 140 +- .../ObjectCombinationCollection.php | 26 +- .../Runtime/Collection/OnDemandCollection.php | 68 +- .../Runtime/Collection/OnDemandIterator.php | 35 +- .../Runtime/Connection/ConnectionFactory.php | 17 +- .../Connection/ConnectionInterface.php | 33 +- .../Connection/ConnectionManagerInterface.php | 5 +- .../ConnectionManagerMasterSlave.php | 7 +- .../ConnectionManagerPrimaryReplica.php | 36 +- .../Connection/ConnectionManagerSingle.php | 12 +- .../Runtime/Connection/ConnectionWrapper.php | 92 +- .../Runtime/Connection/PdoConnection.php | 36 +- .../Connection/ProfilerConnectionWrapper.php | 10 +- .../Connection/ProfilerStatementWrapper.php | 33 +- .../Runtime/Connection/StatementWrapper.php | 103 +- .../Runtime/Connection/TransactionTrait.php | 8 +- .../DataFetcher/AbstractDataFetcher.php | 3 +- .../Runtime/DataFetcher/ArrayDataFetcher.php | 14 +- .../DataFetcher/DataFetcherInterface.php | 16 +- .../Runtime/DataFetcher/PDODataFetcher.php | 55 +- .../Exception/BadMethodCallException.php | 4 +- .../Exception/InvalidArgumentException.php | 4 +- .../Runtime/Exception/LogicException.php | 4 +- .../Runtime/Exception/PropelException.php | 4 +- .../Runtime/Exception/RuntimeException.php | 4 +- .../Exception/UnexpectedValueException.php | 4 +- .../Runtime/Formatter/AbstractFormatter.php | 71 +- .../Runtime/Formatter/ArrayFormatter.php | 32 +- .../Runtime/Formatter/ObjectFormatter.php | 22 +- .../Runtime/Formatter/OnDemandFormatter.php | 26 +- .../Formatter/SimpleArrayFormatter.php | 10 +- .../Runtime/Formatter/StatementFormatter.php | 11 +- src/Propel/Runtime/Map/ColumnMap.php | 92 +- src/Propel/Runtime/Map/DatabaseMap.php | 47 +- src/Propel/Runtime/Map/RelationMap.php | 67 +- src/Propel/Runtime/Map/TableMap.php | 250 +-- src/Propel/Runtime/Map/TableMapTrait.php | 30 +- src/Propel/Runtime/Parser/AbstractParser.php | 21 +- src/Propel/Runtime/Parser/CsvParser.php | 72 +- src/Propel/Runtime/Parser/JsonParser.php | 24 +- src/Propel/Runtime/Parser/XmlParser.php | 51 +- src/Propel/Runtime/Parser/YamlParser.php | 24 +- src/Propel/Runtime/Propel.php | 65 +- .../ServiceContainerInterface.php | 34 +- .../StandardServiceContainer.php | 94 +- src/Propel/Runtime/Util/Profiler.php | 60 +- .../Runtime/Util/PropelConditionalProxy.php | 44 +- src/Propel/Runtime/Util/PropelDateTime.php | 50 +- src/Propel/Runtime/Util/PropelModelPager.php | 64 +- .../Runtime/Validator/Constraints/Date.php | 1 + .../Validator/Constraints/DateValidator.php | 6 +- .../Runtime/Validator/Constraints/Unique.php | 7 + .../Validator/Constraints/UniqueValidator.php | 14 +- 248 files changed, 8529 insertions(+), 6281 deletions(-) create mode 100644 .license create mode 100644 config/phpcs.xml diff --git a/.license b/.license new file mode 100644 index 0000000000..361217be36 --- /dev/null +++ b/.license @@ -0,0 +1,7 @@ +/** + * This file is part of the Propel package. + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * @license MIT License + */ diff --git a/composer.json b/composer.json index fd566bfd55..db87f98145 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,8 @@ "psr/log": "^1.0" }, "require-dev": { + "ext-pdo": "*", + "ext-json": "*", "monolog/monolog": "^1.3", "phpstan/phpstan": "^0.12.4", "phpunit/phpunit": "^7.5.15", @@ -44,8 +46,8 @@ "bin/propel" ], "scripts": { - "cs-check": "phpcs -p -s --standard=vendor/spryker/code-sniffer/Spryker/ruleset.xml src/", - "cs-fix": "phpcbf -p --standard=vendor/spryker/code-sniffer/Spryker/ruleset.xml src/", + "cs-check": "phpcs -p -s --standard=config/phpcs.xml src/", + "cs-fix": "phpcbf -p --standard=config/phpcs.xml src/", "stan": [ "vendor/bin/phpstan analyze" ] diff --git a/config/phpcs.xml b/config/phpcs.xml new file mode 100644 index 0000000000..996d9bee87 --- /dev/null +++ b/config/phpcs.xml @@ -0,0 +1,24 @@ + + + + Propel Coding Standard. + + Extends Spryker+Slevomatik Coding Standard. + + + + + */templates/* + + + + 0 + + + 0 + + + 0 + + + diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9e198e748c..2dc63f3fc3 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -261,12 +261,12 @@ parameters: path: src/Propel/Generator/Manager/ReverseManager.php - - message: "#^Strict comparison using \\=\\=\\= between null and string will always evaluate to false\\.$#" + message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#" count: 1 path: src/Propel/Generator/Model/Column.php - - message: "#^Strict comparison using \\=\\=\\= between null and string will always evaluate to false\\.$#" + message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#" count: 1 path: src/Propel/Generator/Model/Database.php @@ -281,7 +281,12 @@ parameters: path: src/Propel/Generator/Model/Database.php - - message: "#^Strict comparison using \\=\\=\\= between null and int will always evaluate to false\\.$#" + message: "#^Strict comparison using \\=\\=\\= between int and null will always evaluate to false\\.$#" + count: 1 + path: src/Propel/Generator/Model/Domain.php + + - + message: "#^Parameter \\#2 \\$value of method DOMElement\\:\\:setAttribute\\(\\) expects string, int\\<1, max\\>\\|int\\ given\\.$#" count: 1 path: src/Propel/Generator/Model/Domain.php @@ -296,7 +301,7 @@ parameters: path: src/Propel/Generator/Model/Schema.php - - message: "#^Strict comparison using \\=\\=\\= between null and array\\ will always evaluate to false\\.$#" + message: "#^Strict comparison using \\=\\=\\= between array\\ and null will always evaluate to false\\.$#" count: 1 path: src/Propel/Generator/Model/Table.php @@ -316,7 +321,7 @@ parameters: path: src/Propel/Generator/Platform/DefaultPlatform.php - - message: "#^Strict comparison using \\=\\=\\= between null and int will always evaluate to false\\.$#" + message: "#^Strict comparison using \\=\\=\\= between int and null will always evaluate to false\\.$#" count: 1 path: src/Propel/Generator/Platform/DefaultPlatform.php @@ -360,11 +365,6 @@ parameters: count: 1 path: src/Propel/Generator/Reverse/OracleSchemaParser.php - - - message: "#^Method Propel\\\\Runtime\\\\DataFetcher\\\\DataFetcherInterface\\:\\:fetch\\(\\) invoked with 1 parameter, 0 required\\.$#" - count: 2 - path: src/Propel/Generator/Reverse/OracleSchemaParser.php - - message: "#^Variable \\$strDefault might not be defined\\.$#" count: 1 @@ -486,7 +486,7 @@ parameters: path: src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php - - message: "#^Strict comparison using \\=\\=\\= between null and string will always evaluate to false\\.$#" + message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php @@ -496,7 +496,7 @@ parameters: path: src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php - - message: "#^Strict comparison using \\=\\=\\= between null and string will always evaluate to false\\.$#" + message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php @@ -531,7 +531,12 @@ parameters: path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - message: "#^Strict comparison using \\=\\=\\= between null and Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria will always evaluate to false\\.$#" + message: "#^Strict comparison using \\=\\=\\= between Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria and null will always evaluate to false\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + + - + message: "#^Method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:getPrimaryCriteria\\(\\) should return \\$this\\(Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\)\\|null but returns Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\|null\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php diff --git a/phpstan.neon b/phpstan.neon index f0c8fd8f4d..443ac87a1d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -25,4 +25,3 @@ parameters: - message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\TreeBuilder\\:\\:root\\(\\)\\.$#" path: src/Propel/Common/Config/PropelConfiguration.php - - '#PHPDoc tag @throws with type .+FileLoaderLoadException|.+LoaderLoadException is not subtype of Throwable#' diff --git a/src/Propel/Common/Config/ConfigurationManager.php b/src/Propel/Common/Config/ConfigurationManager.php index 36748a9701..b5fcb544b3 100644 --- a/src/Propel/Common/Config/ConfigurationManager.php +++ b/src/Propel/Common/Config/ConfigurationManager.php @@ -13,8 +13,8 @@ use Propel\Common\Config\Exception\InvalidArgumentException; use Propel\Common\Config\Exception\InvalidConfigurationException; use Propel\Common\Config\Loader\DelegatingLoader; -use Symfony\Component\Finder\Finder; use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Finder\Finder; /** * Class ConfigurationManager @@ -25,7 +25,7 @@ */ class ConfigurationManager { - const CONFIG_FILE_NAME = 'propel'; + public const CONFIG_FILE_NAME = 'propel'; /** * Array of configuration values @@ -37,8 +37,8 @@ class ConfigurationManager /** * Load and validate configuration values from a file. * - * @param string|null $filename Configuration file name or directory in which resides the configuration file. - * @param array $extraConf Array of configuration properties, to be merged with those loaded from file. + * @param string|null $filename Configuration file name or directory in which resides the configuration file. + * @param array $extraConf Array of configuration properties, to be merged with those loaded from file. * It's useful when passing configuration parameters from command line. */ public function __construct($filename = null, $extraConf = []) @@ -61,7 +61,8 @@ public function get() * Return a specific section of the configuration array. * It ca be useful to get, in example, only 'generator' values. * - * @param string $section the section to be returned + * @param string $section the section to be returned + * * @return array|null */ public function getSection($section) @@ -81,9 +82,11 @@ public function getSection($section) * is expressed by: * 'database.adapter.mysql.tableType * - * @param string $name The name of property, expressed as a dot separated level hierarchy + * @param string $name The name of property, expressed as a dot separated level hierarchy + * * @throws \Propel\Common\Config\Exception\InvalidArgumentException - * @return mixed The configuration property + * + * @return mixed The configuration property */ public function getConfigProperty($name) { @@ -107,7 +110,8 @@ public function getConfigProperty($name) * Return an array of parameters relative to configured connections, for `runtime` or `generator` section. * It's useful for \Propel\Generator\Command\ConfigConvertCommand class * - * @param string $section `runtime` or `generator` section + * @param string $section `runtime` or `generator` section + * * @return array|null */ public function getConnectionParametersArray($section = 'runtime') @@ -132,8 +136,9 @@ public function getConnectionParametersArray($section = 'runtime') * Only one configuration file is supposed to be found. * This method also looks for a '.dist' configuration file and loads it. * - * @param string|null $fileName Configuration file name or directory in which resides the configuration file. + * @param string|null $fileName Configuration file name or directory in which resides the configuration file. * @param array|null $extraConf Array of configuration properties, to be merged with those loaded from file. + * * @return void */ protected function load($fileName, $extraConf) @@ -144,11 +149,11 @@ protected function load($fileName, $extraConf) $fileName = self::CONFIG_FILE_NAME; } - if (null === $extraConf) { + if ($extraConf === null) { $extraConf = []; } - if (static::CONFIG_FILE_NAME === $fileName) { + if ($fileName === static::CONFIG_FILE_NAME) { $files = $this->getFiles($dirs, $fileName); $distFiles = $this->getFiles($dirs, $fileName, true); @@ -156,7 +161,7 @@ protected function load($fileName, $extraConf) $numDistFiles = count($distFiles); //allow to load only .dist file - if (0 === $numFiles && 1 === $numDistFiles) { + if ($numFiles === 0 && $numDistFiles === 1) { $files = $distFiles; $numFiles = 1; } @@ -171,21 +176,22 @@ protected function load($fileName, $extraConf) $fileName = $file->getPathName(); } - $this->config = array_replace_recursive($this->loadFile($fileName.'.dist'), $this->loadFile($fileName), $extraConf); + $this->config = array_replace_recursive($this->loadFile($fileName . '.dist'), $this->loadFile($fileName), $extraConf); } /** * Validate the configuration array via Propel\Common\Config\PropelConfiguration class * and add default values. * - * @param array $extraConf Extra configuration to merge before processing. It's useful when a child class overwrite + * @param array|null $extraConf Extra configuration to merge before processing. It's useful when a child class overwrite * the constructor to pass a built-in array of configuration, without load it from file. I.e. * Propel\Generator\Config\QuickGeneratorConfig class. + * * @return void */ protected function process($extraConf = null) { - if (null === $extraConf && count($this->config) <= 0) { + if ($extraConf === null && count($this->config) <= 0) { return; } @@ -205,9 +211,11 @@ protected function process($extraConf = null) /** * Return an array of configuration files in the $dirs directories * - * @param array $dirs The directories where to find the configuration files + * @param array $dirs The directories where to find the configuration files * @param string $fileName The name of the file - * @param bool $dist If search .dist files + * @param bool $dist If search .dist files + * + * @throws \Propel\Common\Config\Exception\InvalidArgumentException * * @return array */ @@ -216,7 +224,7 @@ private function getFiles($dirs, $fileName, $dist = false) $finder = new Finder(); $fileName .= '.{php,inc,ini,properties,yaml,yml,xml,json}'; - if (true === $dist) { + if ($dist === true) { $fileName .= '.dist'; } @@ -236,7 +244,6 @@ private function getFiles($dirs, $fileName, $dist = false) * @param string $fileName The configuration file * * @return array|mixed - * @throws \Symfony\Component\Config\Exception\LoaderLoadException|\Symfony\Component\Config\Exception\FileLoaderLoadException */ private function loadFile($fileName) { @@ -252,7 +259,8 @@ private function loadFile($fileName) /** * Return the directories where to find the configuration file. * - * @param string|null $fileName + * @param string|null $fileName + * * @return array */ private function getDirs($fileName) @@ -268,11 +276,11 @@ private function getDirs($fileName) } $dirs[] = $currentDir; - if (is_dir($currentDir.'/conf')) { - $dirs[] = $currentDir.'/conf'; + if (is_dir($currentDir . '/conf')) { + $dirs[] = $currentDir . '/conf'; } - if (is_dir($currentDir.'/config')) { - $dirs[] = $currentDir.'/config'; + if (is_dir($currentDir . '/config')) { + $dirs[] = $currentDir . '/config'; } return $dirs; @@ -296,6 +304,8 @@ private function cleanupSlaveConnections() * If not defined, set `runtime` and `generator` connections, based on `database.connections` property. * Check if runtime and generator connections are correctly defined. * + * @throws \Propel\Common\Config\Exception\InvalidConfigurationException + * * @return void */ private function cleanupConnections() @@ -314,14 +324,14 @@ private function cleanupConnections() foreach ($this->config[$section]['connections'] as $connection) { if (!array_key_exists($connection, $this->config['database']['connections'])) { - throw new InvalidConfigurationException("`$connection` isn't a valid configured connection (Section: propel.$section.connections). ". - "Please, check your configured connections in `propel.database.connections` section of your configuration file."); + throw new InvalidConfigurationException("`$connection` isn't a valid configured connection (Section: propel.$section.connections). " . + 'Please, check your configured connections in `propel.database.connections` section of your configuration file.'); } } if (!array_key_exists($defaultConnection = $this->config[$section]['defaultConnection'], $this->config['database']['connections'])) { - throw new InvalidConfigurationException("`$defaultConnection` isn't a valid configured connection (Section: propel.$section.defaultConnection). ". - "Please, check your configured connections in `propel.database.connections` section of your configuration file."); + throw new InvalidConfigurationException("`$defaultConnection` isn't a valid configured connection (Section: propel.$section.defaultConnection). " . + 'Please, check your configured connections in `propel.database.connections` section of your configuration file.'); } } } diff --git a/src/Propel/Common/Config/Exception/InvalidArgumentException.php b/src/Propel/Common/Config/Exception/InvalidArgumentException.php index fa8a3db0c8..9b57634268 100644 --- a/src/Propel/Common/Config/Exception/InvalidArgumentException.php +++ b/src/Propel/Common/Config/Exception/InvalidArgumentException.php @@ -10,6 +10,8 @@ namespace Propel\Common\Config\Exception; -class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface +use InvalidArgumentException as CoreInvalidArgumentException; + +class InvalidArgumentException extends CoreInvalidArgumentException implements ExceptionInterface { } diff --git a/src/Propel/Common/Config/Exception/JsonParseException.php b/src/Propel/Common/Config/Exception/JsonParseException.php index bf7182a50d..091d77ec62 100644 --- a/src/Propel/Common/Config/Exception/JsonParseException.php +++ b/src/Propel/Common/Config/Exception/JsonParseException.php @@ -15,8 +15,9 @@ class JsonParseException extends RuntimeException implements ExceptionInterface /** * Create an exception based on error codes returned by json_last_error function * - * @param int $error A JSON error constant, as returned by json_last_error() * @see http://www.php.net/manual/en/function.json-last-error.php + * + * @param int $error A JSON error constant, as returned by json_last_error() */ public function __construct($error) { @@ -26,21 +27,27 @@ public function __construct($error) switch ($error) { case JSON_ERROR_DEPTH: $message .= 'maximum stack depth exceeded'; + break; case JSON_ERROR_STATE_MISMATCH: $message .= 'underflow or the modes mismatch'; + break; case JSON_ERROR_CTRL_CHAR: $message .= 'unexpected control character found'; + break; case JSON_ERROR_SYNTAX: $message .= 'syntax error, malformed JSON'; + break; case JSON_ERROR_UTF8: $message .= 'malformed UTF-8 characters, possibly incorrectly encoded'; + break; default: $message .= 'unknown error'; + break; } } else { diff --git a/src/Propel/Common/Config/Exception/RuntimeException.php b/src/Propel/Common/Config/Exception/RuntimeException.php index 48918a85e1..58dc4b38ab 100644 --- a/src/Propel/Common/Config/Exception/RuntimeException.php +++ b/src/Propel/Common/Config/Exception/RuntimeException.php @@ -10,6 +10,8 @@ namespace Propel\Common\Config\Exception; -class RuntimeException extends \RuntimeException implements ExceptionInterface +use RuntimeException as CoreRuntimeException; + +class RuntimeException extends CoreRuntimeException implements ExceptionInterface { } diff --git a/src/Propel/Common/Config/Exception/XmlParseException.php b/src/Propel/Common/Config/Exception/XmlParseException.php index 753054e161..a70b757466 100644 --- a/src/Propel/Common/Config/Exception/XmlParseException.php +++ b/src/Propel/Common/Config/Exception/XmlParseException.php @@ -15,33 +15,37 @@ class XmlParseException extends RuntimeException implements ExceptionInterface /** * Create an exception based on LibXMLError objects * - * @param array $errors Array of LibXMLError objects * @see http://www.php.net/manual/en/class.libxmlerror.php + * + * @param array $errors Array of LibXMLError objects */ public function __construct(array $errors) { $numErrors = count($errors); $message = ''; - if (1 == $numErrors) { - $message = "An error occurred "; + if ($numErrors == 1) { + $message = 'An error occurred '; } elseif ($numErrors > 1) { - $message = "Some errors occurred "; + $message = 'Some errors occurred '; } $message .= "while parsing XML configuration file:\n"; foreach ($errors as $error) { - $message .= " - "; + $message .= ' - '; switch ($error->level) { case LIBXML_ERR_WARNING: $message .= "Warning $error->code: "; + break; case LIBXML_ERR_ERROR: $message .= "Error $error->code: "; + break; case LIBXML_ERR_FATAL: $message .= "Fatal Error $error->code: "; + break; } diff --git a/src/Propel/Common/Config/FileLocator.php b/src/Propel/Common/Config/FileLocator.php index ba840e2de8..2e7829175f 100644 --- a/src/Propel/Common/Config/FileLocator.php +++ b/src/Propel/Common/Config/FileLocator.php @@ -27,7 +27,7 @@ class FileLocator extends BaseFileLocator */ public function __construct($configDirectories = null) { - if (null === $configDirectories) { + if ($configDirectories === null) { $configDirectories = [ getcwd(), 'config', diff --git a/src/Propel/Common/Config/Loader/FileLoader.php b/src/Propel/Common/Config/Loader/FileLoader.php index 0b070601f9..e75fdfbf2b 100644 --- a/src/Propel/Common/Config/Loader/FileLoader.php +++ b/src/Propel/Common/Config/Loader/FileLoader.php @@ -14,8 +14,8 @@ use Propel\Common\Config\Exception\InvalidArgumentException; use Propel\Common\Config\Exception\RuntimeException; use Propel\Common\Config\FileLocator; -use Symfony\Component\Config\Loader\FileLoader as BaseFileLoader; use Symfony\Component\Config\FileLocatorInterface; +use Symfony\Component\Config\Loader\FileLoader as BaseFileLoader; /** * Abstract class used by all file-based loaders. @@ -46,11 +46,11 @@ abstract class FileLoader extends BaseFileLoader /** * Constructor. * - * @param FileLocatorInterface|null $locator A FileLocator instance + * @param \Symfony\Component\Config\FileLocatorInterface|null $locator A FileLocator instance */ - public function __construct(FileLocatorInterface $locator = null) + public function __construct(?FileLocatorInterface $locator = null) { - if (null === $locator) { + if ($locator === null) { $locator = new FileLocator(); } @@ -61,6 +61,7 @@ public function __construct(FileLocatorInterface $locator = null) * Replaces parameter placeholders (%name%) by their values for all parameters. * * @param array $configuration The configuration array to resolve + * * @return array */ public function resolveParams(array $configuration) @@ -87,9 +88,9 @@ public function resolveParams(array $configuration) * * @param string $file The resource * - * @return array|string - * @throws \InvalidArgumentException If the file is not found * @throws \Propel\Common\Config\Exception\InputOutputException If the path isnot readable + * + * @return array|string */ protected function getPath($file) { @@ -107,6 +108,9 @@ protected function getPath($file) * * @param string|string[] $ext An extension or an array of extensions * @param string|false $resource A resource + * + * @throws \Propel\Common\Config\Exception\InvalidArgumentException + * * @return bool */ protected function checkSupports($ext, $resource) @@ -118,7 +122,7 @@ protected function checkSupports($ext, $resource) $info = pathinfo($resource); $extension = $info['extension']; - if ('dist' === $extension) { + if ($extension === 'dist') { $extension = pathinfo($info['filename'], PATHINFO_EXTENSION); } @@ -127,7 +131,7 @@ protected function checkSupports($ext, $resource) } if (!is_array($ext)) { - throw new \InvalidArgumentException('$ext must be string or string[]'); + throw new InvalidArgumentException('$ext must be string or string[]'); } $supported = false; @@ -135,6 +139,7 @@ protected function checkSupports($ext, $resource) foreach ($ext as $value) { if ($value === $extension) { $supported = true; + break; } } @@ -153,11 +158,10 @@ private function isResolved() /** * Replaces parameter placeholders (%name%) by their values. * - * @param mixed $value The value to be resolved + * @param mixed $value The value to be resolved * @param array $resolving An array of keys that are being resolved (used internally to detect circular references) * * @return mixed The resolved value - * */ private function resolveValue($value, array $resolving = []) { @@ -180,12 +184,12 @@ private function resolveValue($value, array $resolving = []) /** * Resolves parameters inside a string * - * @param string $value The string to resolve - * @param array $resolving An array of keys that are being resolved (used internally to detect circular references) + * @param string $value The string to resolve + * @param array $resolving An array of keys that are being resolved (used internally to detect circular references) + * + * @throws \Propel\Common\Config\Exception\RuntimeException if a problem occurs * - * @return string The resolved string - * @throws \Propel\Common\Config\Exception\RuntimeException if a problem occurs - * @throws \Propel\Common\Config\Exception\InvalidArgumentException if a parameter is non-existent + * @return string The resolved string */ private function resolveString($value, array $resolving = []) { @@ -228,7 +232,7 @@ private function resolveString($value, array $resolving = []) throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type %s inside string value "%s".', $key, gettype($resolved), $value)); } - $resolved = (string) $resolved; + $resolved = (string)$resolved; $resolving[$key] = true; return $self->isResolved() ? $resolved : $self->resolveString($resolved, $resolving); @@ -238,7 +242,8 @@ private function resolveString($value, array $resolving = []) /** * Return unescaped variable. * - * @param mixed $value The variable to unescape + * @param mixed $value The variable to unescape + * * @return array|mixed */ private function unescapeValue($value) @@ -264,8 +269,9 @@ private function unescapeValue($value) * * @param mixed $property_key The key, in the configuration values array, to return the respective value * - * @return mixed * @throws \Propel\Common\Config\Exception\InvalidArgumentException when non-existent key in configuration array + * + * @return mixed */ private function get($property_key) { @@ -273,7 +279,7 @@ private function get($property_key) $ret = $this->getValue($property_key, null, $found); - if (false === $found) { + if ($found === false) { throw new InvalidArgumentException("Parameter '$property_key' not found in configuration file."); } @@ -283,15 +289,15 @@ private function get($property_key) /** * Scan recursively an array to find a value of a given key. * - * @param string $property_key The array key - * @param array|null $config The array to scan - * @param boolean $found if the key was found + * @param string $property_key The array key + * @param array|null $config The array to scan + * @param bool $found if the key was found * * @return mixed The value or null if not found */ private function getValue($property_key, $config, &$found) { - if (null === $config) { + if ($config === null) { $config = $this->config; } @@ -304,7 +310,7 @@ private function getValue($property_key, $config, &$found) if (is_array($value)) { $ret = $this->getValue($property_key, $value, $found); - if (null !== $ret) { + if ($ret !== null) { return $ret; } } @@ -316,16 +322,17 @@ private function getValue($property_key, $config, &$found) * * @param string $value The value to parse * - * @return string|null * @throws \Propel\Common\Config\Exception\InvalidArgumentException if the environment variable is not set + * + * @return string|null */ private function parseEnvironmentParams($value) { // env.variable is an environment variable $env = explode('.', $value); - if ('env' === $env[0]) { + if ($env[0] === 'env') { $envParam = getenv($env[1]); - if (false === $envParam) { + if ($envParam === false) { throw new InvalidArgumentException("Environment variable '$env[1]' is not defined."); } diff --git a/src/Propel/Common/Config/Loader/IniFileLoader.php b/src/Propel/Common/Config/Loader/IniFileLoader.php index 86167654e6..440c105f2f 100644 --- a/src/Propel/Common/Config/Loader/IniFileLoader.php +++ b/src/Propel/Common/Config/Loader/IniFileLoader.php @@ -10,8 +10,8 @@ namespace Propel\Common\Config\Loader; -use Propel\Common\Config\Exception\InvalidArgumentException; use Propel\Common\Config\Exception\IniParseException; +use Propel\Common\Config\Exception\InvalidArgumentException; /** * IniFileLoader loads parameters from INI files. @@ -23,7 +23,6 @@ */ class IniFileLoader extends FileLoader { - /** * Separator for nesting levels of configuration data identifiers. * @@ -34,10 +33,10 @@ class IniFileLoader extends FileLoader /** * Returns true if this class supports the given resource. * - * @param mixed $resource A resource - * @param string $type The resource type + * @param mixed $resource A resource + * @param string|null $type The resource type * - * @return Boolean true if this class supports the given resource, false otherwise + * @return bool true if this class supports the given resource, false otherwise */ public function supports($resource, $type = null) { @@ -47,19 +46,19 @@ public function supports($resource, $type = null) /** * Loads a resource, merge it with the default configuration array and resolve its parameters. * - * @param string $file The resource - * @param string|null $type The resource type - * @return array The configuration array + * @param string $file The resource + * @param string|null $type The resource type * - * @throws \InvalidArgumentException if configuration file not found + * @throws \InvalidArgumentException if configuration file not found * @throws \Propel\Common\Config\Exception\InvalidArgumentException When ini file is not valid - * @throws \Propel\Common\Config\Exception\InputOutputException if configuration file is not readable + * + * @return array The configuration array */ public function load($file, $type = null) { $ini = parse_ini_file($this->getPath($file), true, INI_SCANNER_RAW); - if (false === $ini) { + if ($ini === false) { throw new InvalidArgumentException("The configuration file '$file' has invalid content."); } @@ -72,7 +71,9 @@ public function load($file, $type = null) /** * Parse data from the configuration array, to transform nested sections into associative arrays * and to fix int/float/bool typing - * @param array $data + * + * @param array $data + * * @return array */ private function parse(array $data) @@ -98,8 +99,9 @@ private function parse(array $data) /** * Process a nested section * - * @param array $sections - * @param mixed $value + * @param array $sections + * @param mixed $value + * * @return array */ private function buildNestedSection($sections, $value) @@ -119,7 +121,8 @@ private function buildNestedSection($sections, $value) /** * Parse a section. * - * @param array $section + * @param array $section + * * @return array */ private function parseSection(array $section) @@ -138,7 +141,7 @@ private function parseSection(array $section) * * @param string $key * @param string $value - * @param array $config + * @param array $config * * @throws \Propel\Common\Config\Exception\IniParseException * @@ -159,17 +162,18 @@ private function parseKey($key, $value, array &$config) } } elseif (!is_array($config[$pieces[0]])) { throw new IniParseException(sprintf( - 'Cannot create sub-key for "%s", as key already exists', $pieces[0] + 'Cannot create sub-key for "%s", as key already exists', + $pieces[0] )); } $this->parseKey($pieces[1], $value, $config[$pieces[0]]); - } else if (is_string($value) && in_array(strtolower($value), array("true", "false"))) { - $config[$key] = (strtolower($value) === "true"); - } else if ($value === (string)(int) $value) { - $config[$key] = (int) $value; - } else if ($value === (string)(float) $value) { - $config[$key] = (float) $value; + } elseif (is_string($value) && in_array(strtolower($value), ['true', 'false'])) { + $config[$key] = (strtolower($value) === 'true'); + } elseif ($value === (string)(int)$value) { + $config[$key] = (int)$value; + } elseif ($value === (string)(float)$value) { + $config[$key] = (float)$value; } else { $config[$key] = $value; } diff --git a/src/Propel/Common/Config/Loader/JsonFileLoader.php b/src/Propel/Common/Config/Loader/JsonFileLoader.php index d0f2f3e214..4e8bbbceab 100644 --- a/src/Propel/Common/Config/Loader/JsonFileLoader.php +++ b/src/Propel/Common/Config/Loader/JsonFileLoader.php @@ -22,14 +22,12 @@ class JsonFileLoader extends FileLoader /** * Loads an Json file. * - * @param string $file The resource + * @param string $file The resource * @param string|null $type The resource type * - * @return array + * @throws \Propel\Common\Config\Exception\JsonParseException if invalid json file * - * @throws \InvalidArgumentException if configuration file not found - * @throws \Propel\Common\Config\Exception\JsonParseException if invalid json file - * @throws \Propel\Common\Config\Exception\InputOutputException if configuration file is not readable + * @return array */ public function load($file, $type = null) { @@ -37,11 +35,11 @@ public function load($file, $type = null) $content = []; - if ('' !== $json) { + if ($json !== '') { $content = json_decode($json, true); $error = json_last_error(); - if (JSON_ERROR_NONE !== $error) { + if ($error !== JSON_ERROR_NONE) { throw new JsonParseException($error); } } @@ -54,10 +52,10 @@ public function load($file, $type = null) /** * Returns true if this class supports the given resource. * - * @param mixed $resource A resource - * @param string $type The resource type + * @param mixed $resource A resource + * @param string|null $type The resource type * - * @return Boolean true if this class supports the given resource, false otherwise + * @return bool true if this class supports the given resource, false otherwise */ public function supports($resource, $type = null) { diff --git a/src/Propel/Common/Config/Loader/LoaderResolver.php b/src/Propel/Common/Config/Loader/LoaderResolver.php index a1e4982b81..491bc7e667 100644 --- a/src/Propel/Common/Config/Loader/LoaderResolver.php +++ b/src/Propel/Common/Config/Loader/LoaderResolver.php @@ -20,11 +20,11 @@ class LoaderResolver extends BaseLoaderResolver { /** - * @param array $loaders + * @param array|null $loaders */ - public function __construct(array $loaders = null) + public function __construct(?array $loaders = null) { - if (null === $loaders) { + if ($loaders === null) { $loaders = [ new IniFileLoader(), new PhpFileLoader(), diff --git a/src/Propel/Common/Config/Loader/PhpFileLoader.php b/src/Propel/Common/Config/Loader/PhpFileLoader.php index 4dfaae7017..bf9213efcb 100644 --- a/src/Propel/Common/Config/Loader/PhpFileLoader.php +++ b/src/Propel/Common/Config/Loader/PhpFileLoader.php @@ -31,14 +31,13 @@ class PhpFileLoader extends FileLoader /** * Loads a PHP file. * - * @param string $file The resource + * @param string $file The resource * @param string|null $type The resource type * - * @return array - * - * @throws \InvalidArgumentException if configuration file not found + * @throws \InvalidArgumentException if configuration file not found * @throws \Propel\Common\Config\Exception\InvalidArgumentException if invalid json file - * @throws \Propel\Common\Config\Exception\InputOutputException if configuration file is not readable + * + * @return array */ public function load($file, $type = null) { @@ -63,10 +62,10 @@ public function load($file, $type = null) * Returns true if this class supports the given resource. * It supports both .php and .inc extensions. * - * @param mixed $resource A resource - * @param string $type The resource type + * @param mixed $resource A resource + * @param string|null $type The resource type * - * @return Boolean true if this class supports the given resource, false otherwise + * @return bool true if this class supports the given resource, false otherwise */ public function supports($resource, $type = null) { diff --git a/src/Propel/Common/Config/Loader/XmlFileLoader.php b/src/Propel/Common/Config/Loader/XmlFileLoader.php index 1295cc7edb..b9863997c4 100644 --- a/src/Propel/Common/Config/Loader/XmlFileLoader.php +++ b/src/Propel/Common/Config/Loader/XmlFileLoader.php @@ -22,15 +22,10 @@ class XmlFileLoader extends FileLoader /** * Loads an Xml file. * - * @param string $file The resource + * @param string $file The resource * @param string|null $type The resource type * * @return array - * - * @throws \InvalidArgumentException if configuration file not found - * @throws \Propel\Common\Config\Exception\InputOutputException if configuration file is not readable - * @throws \Propel\Common\Config\Exception\InvalidArgumentException if invalid xml file - * @throws \Propel\Common\Config\Exception\XmlParseException if something went wrong while parsing xml file */ public function load($file, $type = null) { @@ -43,10 +38,10 @@ public function load($file, $type = null) /** * Returns true if this class supports the given resource. * - * @param mixed $resource A resource - * @param string $type The resource type + * @param mixed $resource A resource + * @param string|null $type The resource type * - * @return Boolean true if this class supports the given resource, false otherwise + * @return bool true if this class supports the given resource, false otherwise */ public function supports($resource, $type = null) { diff --git a/src/Propel/Common/Config/Loader/YamlFileLoader.php b/src/Propel/Common/Config/Loader/YamlFileLoader.php index 4b73337459..4912470856 100644 --- a/src/Propel/Common/Config/Loader/YamlFileLoader.php +++ b/src/Propel/Common/Config/Loader/YamlFileLoader.php @@ -24,14 +24,13 @@ class YamlFileLoader extends FileLoader /** * Loads a Yaml file. * - * @param string $file The resource + * @param string $file The resource * @param string|null $type The resource type * - * @return array - * - * @throws \InvalidArgumentException if configuration file not found - * @throws \Symfony\Component\Yaml\Exception\ParseException if something goes wrong in parsing file + * @throws \Symfony\Component\Yaml\Exception\ParseException if something goes wrong in parsing file * @throws \Propel\Common\Config\Exception\InputOutputException if configuration file is not readable + * + * @return array */ public function load($file, $type = null) { @@ -44,7 +43,7 @@ public function load($file, $type = null) $content = Yaml::parse(file_get_contents($path)); //config file is empty - if (null === $content) { + if ($content === null) { $content = []; } @@ -61,10 +60,10 @@ public function load($file, $type = null) * Returns true if this class supports the given resource. * Both 'yml' and 'yaml' extensions are accepted. * - * @param mixed $resource A resource - * @param string $type The resource type + * @param mixed $resource A resource + * @param string|null $type The resource type * - * @return Boolean true if this class supports the given resource, false otherwise + * @return bool true if this class supports the given resource, false otherwise */ public function supports($resource, $type = null) { diff --git a/src/Propel/Common/Config/PropelConfiguration.php b/src/Propel/Common/Config/PropelConfiguration.php index e77acd1d64..dfb350f8c5 100644 --- a/src/Propel/Common/Config/PropelConfiguration.php +++ b/src/Propel/Common/Config/PropelConfiguration.php @@ -10,15 +10,15 @@ namespace Propel\Common\Config; -use Symfony\Component\Config\Definition\ConfigurationInterface; +use InvalidArgumentException; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\ConfigurationInterface; /** * Class PropelConfiguration * * This class performs validation of configuration array and assign default values - * */ class PropelConfiguration implements ConfigurationInterface { @@ -67,8 +67,7 @@ protected function addGeneralSection(ArrayNodeDefinition $node) ->scalarNode('version')->defaultValue('2.0.0-dev')->end() ->end() ->end() - ->end() - ; + ->end(); } /** @@ -86,20 +85,21 @@ protected function addPathsSection(ArrayNodeDefinition $node) ->scalarNode('projectDir')->defaultValue(getcwd())->end() ->scalarNode('schemaDir')->defaultValue(getcwd())->end() ->scalarNode('outputDir')->defaultValue(getcwd())->end() - ->scalarNode('phpDir')->defaultValue(getcwd().'/generated-classes')->end() - ->scalarNode('phpConfDir')->defaultValue(getcwd().'/generated-conf')->end() - ->scalarNode('sqlDir')->defaultValue(getcwd().'/generated-sql')->end() - ->scalarNode('migrationDir')->defaultValue(getcwd().'/generated-migrations')->end() + ->scalarNode('phpDir')->defaultValue(getcwd() . '/generated-classes')->end() + ->scalarNode('phpConfDir')->defaultValue(getcwd() . '/generated-conf')->end() + ->scalarNode('sqlDir')->defaultValue(getcwd() . '/generated-sql')->end() + ->scalarNode('migrationDir')->defaultValue(getcwd() . '/generated-migrations')->end() ->scalarNode('composerDir')->defaultNull()->end() ->end() ->end() - ->end() - ; + ->end(); } /** * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node * + * @throws \InvalidArgumentException + * * @return void */ protected function addDatabaseSection(ArrayNodeDefinition $node) @@ -117,7 +117,7 @@ protected function addDatabaseSection(ArrayNodeDefinition $node) ->then(function ($connections) { foreach ($connections as $name => $connection) { if (strpos($name, '.') !== false) { - throw new \InvalidArgumentException('Dots are not allowed in connection names'); + throw new InvalidArgumentException('Dots are not allowed in connection names'); } } @@ -207,8 +207,7 @@ protected function addDatabaseSection(ArrayNodeDefinition $node) ->end() //adapters ->end() ->end() //database - ->end() - ; + ->end(); } /** @@ -229,8 +228,7 @@ protected function addMigrationsSection(ArrayNodeDefinition $node) ->scalarNode('parserClass')->defaultNull()->end() ->end() ->end() //migrations - ->end() - ; + ->end(); } /** @@ -248,8 +246,7 @@ protected function addReverseSection(ArrayNodeDefinition $node) ->scalarNode('parserClass')->end() ->end() ->end() //reverse - ->end() - ; + ->end(); } /** @@ -264,8 +261,7 @@ protected function addExcludeTablesSection(ArrayNodeDefinition $node) ->arrayNode('exclude_tables') ->prototype('scalar')->end() ->end() - ->end() - ; + ->end(); } /** @@ -343,8 +339,7 @@ protected function addRuntimeSection(ArrayNodeDefinition $node) ->end() ->end() ->end() //runtime - ->end() - ; + ->end(); } /** @@ -425,7 +420,6 @@ protected function addGeneratorSection(ArrayNodeDefinition $node) ->end() //objectModel ->end() ->end() //generator - ->end() - ; + ->end(); } } diff --git a/src/Propel/Common/Config/XmlToArrayConverter.php b/src/Propel/Common/Config/XmlToArrayConverter.php index bd48f0ac5e..9b2ac204e8 100644 --- a/src/Propel/Common/Config/XmlToArrayConverter.php +++ b/src/Propel/Common/Config/XmlToArrayConverter.php @@ -22,31 +22,32 @@ class XmlToArrayConverter /** * Create a PHP array from the XML file * - * @param String $xmlToParse The XML file or a string containing xml to parse - * - * @return array + * @param string $xmlToParse The XML file or a string containing xml to parse * * @throws \Propel\Common\Config\Exception\XmlParseException if parse errors occur + * @throws \Propel\Common\Config\Exception\InvalidArgumentException + * + * @return array */ public static function convert($xmlToParse) { if (!is_string($xmlToParse)) { - throw new InvalidArgumentException("XmlToArrayConverter::convert method expects an xml file to parse, or a string containing valid xml"); + throw new InvalidArgumentException('XmlToArrayConverter::convert method expects an xml file to parse, or a string containing valid xml'); } $isFile = file_exists($xmlToParse); //Empty xml file returns empty array if ( - ($isFile && 0 === filesize($xmlToParse)) - or (!$isFile && '' === $xmlToParse) + ($isFile && filesize($xmlToParse) === 0) + || (!$isFile && $xmlToParse === '') ) { return []; } if ( ($isFile && file_get_contents($xmlToParse, false, null, 0, 1) !== '<') - or (!$isFile && $xmlToParse[0] !== '<') + || (!$isFile && $xmlToParse[0] !== '<') ) { throw new InvalidArgumentException('Invalid xml content'); } @@ -78,10 +79,12 @@ public static function convert($xmlToParse) /** * Recursive function that converts an SimpleXML object into an array. - * @author Christophe VG (based on code form php.net manual comment) * - * @param \SimpleXMLElement $xml SimpleXML object. - * @return array Array representation of SimpleXML object. + * @author Christophe VG (based on code form php.net manual comment) + * + * @param \SimpleXMLElement $xml SimpleXML object. + * + * @return array Array representation of SimpleXML object. */ protected static function simpleXmlToArray($xml) { @@ -134,28 +137,30 @@ protected static function simpleXmlToArray($xml) /** * Process XML value, handling boolean, if appropriate. - * @param \SimpleXMLElement $value The simplexml value object. - * @return mixed string or boolean value + * + * @param \SimpleXMLElement $value The simplexml value object. + * + * @return mixed string or boolean value */ private static function getConvertedXmlValue($value) { - $value = (string) $value; // convert from simplexml to string + $value = (string)$value; // convert from simplexml to string //handle numeric values if (is_numeric($value)) { if (ctype_digit($value)) { - $value = intval($value); + $value = (int)$value; } else { - $value = floatval($value); + $value = (float)$value; } } // handle booleans specially $lwr = strtolower($value); - if ($lwr === "false") { + if ($lwr === 'false') { return false; } - if ($lwr === "true") { + if ($lwr === 'true') { return true; } diff --git a/src/Propel/Common/Exception/SetColumnConverterException.php b/src/Propel/Common/Exception/SetColumnConverterException.php index 5a74d2c749..99f1990a50 100644 --- a/src/Propel/Common/Exception/SetColumnConverterException.php +++ b/src/Propel/Common/Exception/SetColumnConverterException.php @@ -8,31 +8,29 @@ */ namespace Propel\Common\Exception; -use Exception; +use Exception; +use InvalidArgumentException; /** * Exception for Propel\Common\Util\SetColumnConverter class. - * + * * @author Moritz Schroeder */ -class SetColumnConverterException extends \InvalidArgumentException +class SetColumnConverterException extends InvalidArgumentException { - /** * @var mixed */ protected $value; /** - * SetColumnConverterException constructor. - * - * @param string $message - * @param mixed $value - * @param int $code - * @param Exception|null $previous + * @param string $message + * @param mixed $value + * @param int $code + * @param \Exception|null $previous */ - public function __construct($message, $value, $code = 0, Exception $previous = null) + public function __construct($message, $value, $code = 0, ?Exception $previous = null) { $this->value = $value; parent::__construct($message, $code, $previous); @@ -47,4 +45,4 @@ public function getValue() { return $this->value; } -} \ No newline at end of file +} diff --git a/src/Propel/Common/Pluralizer/PluralizerInterface.php b/src/Propel/Common/Pluralizer/PluralizerInterface.php index 205a6de291..8055714f6c 100644 --- a/src/Propel/Common/Pluralizer/PluralizerInterface.php +++ b/src/Propel/Common/Pluralizer/PluralizerInterface.php @@ -19,7 +19,9 @@ interface PluralizerInterface { /** * Generate a plural name based on the passed in root. - * @param string $root The root that needs to be pluralized (e.g. Author) + * + * @param string $root The root that needs to be pluralized (e.g. Author) + * * @return string The plural form of $root. */ public function getPluralForm($root); diff --git a/src/Propel/Common/Pluralizer/SimpleEnglishPluralizer.php b/src/Propel/Common/Pluralizer/SimpleEnglishPluralizer.php index 6033b21ee7..66bd44f244 100644 --- a/src/Propel/Common/Pluralizer/SimpleEnglishPluralizer.php +++ b/src/Propel/Common/Pluralizer/SimpleEnglishPluralizer.php @@ -21,7 +21,8 @@ class SimpleEnglishPluralizer implements PluralizerInterface /** * Generate a plural name based on the passed in root. * - * @param string $root The root that needs to be pluralized (e.g. Author) + * @param string $root The root that needs to be pluralized (e.g. Author) + * * @return string The plural form of $root (e.g. Authors). */ public function getPluralForm($root) diff --git a/src/Propel/Common/Pluralizer/StandardEnglishPluralizer.php b/src/Propel/Common/Pluralizer/StandardEnglishPluralizer.php index 6ce46067be..cfa9dac5ba 100644 --- a/src/Propel/Common/Pluralizer/StandardEnglishPluralizer.php +++ b/src/Propel/Common/Pluralizer/StandardEnglishPluralizer.php @@ -22,14 +22,14 @@ class StandardEnglishPluralizer implements PluralizerInterface { /** - * @var array + * @var string[] */ protected $plural = [ '(matr|vert|ind)(ix|ex)' => '\1ices', '(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us' => '\1i', '(buffal|tomat)o' => '\1oes', - 'x' => 'xes', + 'x' => 'xes', 'ch' => 'ches', 'sh' => 'shes', 'ss' => 'sses', @@ -39,14 +39,14 @@ class StandardEnglishPluralizer implements PluralizerInterface 'iy' => 'iys', 'oy' => 'oys', 'uy' => 'uys', - 'y' => 'ies', + 'y' => 'ies', 'ao' => 'aos', 'eo' => 'eos', 'io' => 'ios', 'oo' => 'oos', 'uo' => 'uos', - 'o' => 'os', + 'o' => 'os', 'us' => 'uses', @@ -57,45 +57,51 @@ class StandardEnglishPluralizer implements PluralizerInterface 'zoon' => 'zoa', 'itis' => 'itis', - 'ois' => 'ois', - 'pox' => 'pox', - 'ox' => 'oxes', + 'ois' => 'ois', + 'pox' => 'pox', + 'ox' => 'oxes', - 'foot' => 'feet', + 'foot' => 'feet', 'goose' => 'geese', 'tooth' => 'teeth', 'quiz' => 'quizzes', 'alias' => 'aliases', - 'alf' => 'alves', - 'elf' => 'elves', - 'olf' => 'olves', - 'arf' => 'arves', + 'alf' => 'alves', + 'elf' => 'elves', + 'olf' => 'olves', + 'arf' => 'arves', 'nife' => 'nives', - 'life' => 'lives' + 'life' => 'lives', ]; + /** + * @var string[] + */ protected $irregular = [ - 'leaf' => 'leaves', - 'loaf' => 'loaves', - 'move' => 'moves', - 'foot' => 'feet', - 'goose' => 'geese', - 'genus' => 'genera', - 'sex' => 'sexes', - 'ox' => 'oxen', - 'child' => 'children', - 'man' => 'men', - 'tooth' => 'teeth', + 'leaf' => 'leaves', + 'loaf' => 'loaves', + 'move' => 'moves', + 'foot' => 'feet', + 'goose' => 'geese', + 'genus' => 'genera', + 'sex' => 'sexes', + 'ox' => 'oxen', + 'child' => 'children', + 'man' => 'men', + 'tooth' => 'teeth', 'person' => 'people', - 'wife' => 'wives', + 'wife' => 'wives', 'mythos' => 'mythoi', 'testis' => 'testes', - 'numen' => 'numina', + 'numen' => 'numina', 'quiz' => 'quizzes', 'alias' => 'aliases', ]; + /** + * @var string[] + */ protected $uncountable = [ 'sheep', 'fish', @@ -112,7 +118,9 @@ class StandardEnglishPluralizer implements PluralizerInterface /** * Generate a plural name based on the passed in root. - * @param string $root The root that needs to be pluralized (e.g. Author) + * + * @param string $root The root that needs to be pluralized (e.g. Author) + * * @return string The plural form of $root (e.g. Authors). */ public function getPluralForm($root) diff --git a/src/Propel/Common/Util/SetColumnConverter.php b/src/Propel/Common/Util/SetColumnConverter.php index 4686177a5b..ec3c89d954 100644 --- a/src/Propel/Common/Util/SetColumnConverter.php +++ b/src/Propel/Common/Util/SetColumnConverter.php @@ -9,8 +9,8 @@ */ namespace Propel\Common\Util; -use Propel\Common\Exception\SetColumnConverterException; +use Propel\Common\Exception\SetColumnConverterException; /** * Class converts SET column values between integer and string/array representation. @@ -24,9 +24,10 @@ class SetColumnConverter * * @param mixed $val * @param array $valueSet - * @return string|int * - * @throws SetColumnConverterException + * @throws \Propel\Common\Exception\SetColumnConverterException + * + * @return string|int */ public static function convertToInt($val, array $valueSet) { @@ -53,14 +54,13 @@ public static function convertToInt($val, array $valueSet) * @param mixed $val * @param array $valueSet * - * @return array + * @throws \Propel\Common\Exception\SetColumnConverterException * - * @throws SetColumnConverterException + * @return array */ public static function convertIntToArray($val, array $valueSet) { if ($val === null) { - return []; } $bitValueArr = array_reverse(str_split(base_convert($val, 10, 2))); @@ -73,6 +73,7 @@ public static function convertIntToArray($val, array $valueSet) $valueArr[] = $valueSet[$bit]; } } + return $valueArr; } } diff --git a/src/Propel/Generator/Application.php b/src/Propel/Generator/Application.php index 93e9c65d0b..46043725e0 100644 --- a/src/Propel/Generator/Application.php +++ b/src/Propel/Generator/Application.php @@ -1,11 +1,20 @@ writeln( - 'You are running propel with xdebug enabled. This has a major impact on runtime performance.'."\n" + 'You are running propel with xdebug enabled. This has a major impact on runtime performance.' . "\n" ); } + return parent::doRun($input, $output); } } diff --git a/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php b/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php index 9bec9c67b0..b163329df0 100644 --- a/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php +++ b/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php @@ -10,9 +10,9 @@ namespace Propel\Generator\Behavior\AggregateColumn; +use InvalidArgumentException; use Propel\Generator\Builder\Om\ObjectBuilder; use Propel\Generator\Model\Behavior; -use Propel\Generator\Model\ForeignKey; /** * Keeps an aggregate column updated with related table @@ -23,10 +23,10 @@ class AggregateColumnBehavior extends Behavior { // default parameters value protected $parameters = [ - 'name' => null, - 'expression' => null, - 'condition' => null, - 'foreign_table' => null, + 'name' => null, + 'expression' => null, + 'condition' => null, + 'foreign_table' => null, 'foreign_schema' => null, ]; @@ -43,6 +43,8 @@ public function allowMultiple() /** * Add the aggregate key to the current table * + * @throws \InvalidArgumentException + * * @return void */ public function modifyTable() @@ -50,14 +52,14 @@ public function modifyTable() $table = $this->getTable(); $columnName = $this->getParameter('name'); if (!$columnName) { - throw new \InvalidArgumentException(sprintf('You must define a \'name\' parameter for the \'aggregate_column\' behavior in the \'%s\' table', $table->getName())); + throw new InvalidArgumentException(sprintf('You must define a \'name\' parameter for the \'aggregate_column\' behavior in the \'%s\' table', $table->getName())); } // add the aggregate column if not present if (!$table->hasColumn($columnName)) { $table->addColumn([ - 'name' => $columnName, - 'type' => 'INTEGER', + 'name' => $columnName, + 'type' => 'INTEGER', ]); } @@ -66,7 +68,7 @@ public function modifyTable() if (!$foreignTable->hasBehavior('concrete_inheritance_parent')) { $relationBehavior = new AggregateColumnRelationBehavior(); $relationBehavior->setName('aggregate_column_relation'); - $relationBehavior->setId('aggregate_column_relation_'.$this->getId()); + $relationBehavior->setId('aggregate_column_relation_' . $this->getId()); $relationBehavior->addParameter(['name' => 'foreign_table', 'value' => $table->getName()]); $relationBehavior->addParameter(['name' => 'aggregate_name', 'value' => $this->getColumn()->getPhpName()]); $relationBehavior->addParameter(['name' => 'update_method', 'value' => 'update' . $this->getColumn()->getPhpName()]); @@ -84,7 +86,7 @@ public function modifyTable() public function objectMethods(ObjectBuilder $builder) { if (!$this->getParameter('foreign_table')) { - throw new \InvalidArgumentException(sprintf('You must define a \'foreign_table\' parameter for the \'aggregate_column\' behavior in the \'%s\' table', $this->getTable()->getName())); + throw new InvalidArgumentException(sprintf('You must define a \'foreign_table\' parameter for the \'aggregate_column\' behavior in the \'%s\' table', $this->getTable()->getName())); } $script = ''; $script .= $this->addObjectCompute($builder); @@ -94,7 +96,10 @@ public function objectMethods(ObjectBuilder $builder) } /** - * @param ObjectBuilder $builder + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * + * @throws \InvalidArgumentException + * * @return string */ protected function addObjectCompute(ObjectBuilder $builder) @@ -108,30 +113,31 @@ protected function addObjectCompute(ObjectBuilder $builder) $database = $this->getTable()->getDatabase(); if ($this->getForeignKey()->isPolymorphic()) { - throw new \InvalidArgumentException('AggregateColumnBehavior does not work with polymorphic relations.'); + throw new InvalidArgumentException('AggregateColumnBehavior does not work with polymorphic relations.'); } foreach ($this->getForeignKey()->getMapping() as $index => $mapping) { [$localColumn, $foreignColumn] = $mapping; $conditions[] = $localColumn->getFullyQualifiedName() . ' = :p' . ($index + 1); - $bindings[$index + 1] = $foreignColumn->getPhpName(); + $bindings[$index + 1] = $foreignColumn->getPhpName(); } $tableName = $database->getTablePrefix() . $this->getParameter('foreign_table'); if ($database->getPlatform()->supportsSchemas() && $this->getParameter('foreign_schema')) { $tableName = $this->getParameter('foreign_schema') - .$database->getPlatform()->getSchemaDelimiter() - .$tableName; + . $database->getPlatform()->getSchemaDelimiter() + . $tableName; } - $sql = sprintf('SELECT %s FROM %s WHERE %s', + $sql = sprintf( + 'SELECT %s FROM %s WHERE %s', $this->getParameter('expression'), $builder->getTable()->quoteIdentifier($tableName), implode(' AND ', $conditions) ); return $this->renderTemplate('objectCompute', [ - 'column' => $this->getColumn(), - 'sql' => $sql, + 'column' => $this->getColumn(), + 'sql' => $sql, 'bindings' => $bindings, ]); } @@ -142,7 +148,7 @@ protected function addObjectCompute(ObjectBuilder $builder) protected function addObjectUpdate() { return $this->renderTemplate('objectUpdate', [ - 'column' => $this->getColumn(), + 'column' => $this->getColumn(), ]); } @@ -154,7 +160,7 @@ protected function getForeignTable() $database = $this->getTable()->getDatabase(); $tableName = $database->getTablePrefix() . $this->getParameter('foreign_table'); if ($database->getPlatform()->supportsSchemas() && $this->getParameter('foreign_schema')) { - $tableName = $this->getParameter('foreign_schema'). $database->getPlatform()->getSchemaDelimiter() . $tableName; + $tableName = $this->getParameter('foreign_schema') . $database->getPlatform()->getSchemaDelimiter() . $tableName; } return $database->getTable($tableName); @@ -162,7 +168,8 @@ protected function getForeignTable() /** * @throws \InvalidArgumentException - * @return ForeignKey + * + * @return \Propel\Generator\Model\ForeignKey */ protected function getForeignKey() { @@ -170,8 +177,9 @@ protected function getForeignKey() // let's infer the relation from the foreign table $fks = $foreignTable->getForeignKeysReferencingTable($this->getTable()->getName()); if (!$fks) { - throw new \InvalidArgumentException(sprintf('You must define a foreign key to the \'%s\' table in the \'%s\' table to enable the \'aggregate_column\' behavior', $this->getTable()->getName(), $foreignTable->getName())); + throw new InvalidArgumentException(sprintf('You must define a foreign key to the \'%s\' table in the \'%s\' table to enable the \'aggregate_column\' behavior', $this->getTable()->getName(), $foreignTable->getName())); } + // FIXME doesn't work when more than one fk to the same table return array_shift($fks); } diff --git a/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnRelationBehavior.php b/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnRelationBehavior.php index d7d85fe785..b58c693078 100644 --- a/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnRelationBehavior.php +++ b/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnRelationBehavior.php @@ -21,9 +21,9 @@ class AggregateColumnRelationBehavior extends Behavior { // default parameters value protected $parameters = [ - 'foreign_table' => '', - 'update_method' => '', - 'aggregate_name' => '', + 'foreign_table' => '', + 'update_method' => '', + 'aggregate_name' => '', ]; public function allowMultiple() @@ -85,9 +85,9 @@ protected function addObjectUpdateRelated($builder) $relationName = $this->getRelationName($builder); return $this->renderTemplate('objectUpdateRelated', [ - 'relationName' => $relationName, - 'aggregateName' => $this->getParameter('aggregate_name'), - 'variableName' => lcfirst($relationName), + 'relationName' => $relationName, + 'aggregateName' => $this->getParameter('aggregate_name'), + 'variableName' => lcfirst($relationName), 'updateMethodName' => $this->getParameter('update_method'), ]); } @@ -211,12 +211,12 @@ protected function addQueryFindRelated($builder) ); return $this->renderTemplate('queryFindRelated', [ - 'foreignTable' => $this->getForeignTable(), - 'relationName' => $relationName, - 'aggregateName' => $this->getParameter('aggregate_name'), - 'variableName' => lcfirst($relationName.$this->getParameter('aggregate_name')), + 'foreignTable' => $this->getForeignTable(), + 'relationName' => $relationName, + 'aggregateName' => $this->getParameter('aggregate_name'), + 'variableName' => lcfirst($relationName . $this->getParameter('aggregate_name')), 'foreignQueryName' => $foreignQueryBuilder->getClassName(), - 'refRelationName' => $builder->getRefFKPhpNameAffix($foreignKey), + 'refRelationName' => $builder->getRefFKPhpNameAffix($foreignKey), ]); } @@ -230,9 +230,9 @@ protected function addQueryUpdateRelated($builder) $relationName = $this->getRelationName($builder); return $this->renderTemplate('queryUpdateRelated', [ - 'relationName' => $relationName, - 'aggregateName' => $this->getParameter('aggregate_name'), - 'variableName' => lcfirst($relationName.$this->getParameter('aggregate_name')), + 'relationName' => $relationName, + 'aggregateName' => $this->getParameter('aggregate_name'), + 'variableName' => lcfirst($relationName . $this->getParameter('aggregate_name')), 'updateMethodName' => $this->getParameter('update_method'), ]); } @@ -253,6 +253,7 @@ protected function getForeignKey() $foreignTable = $this->getForeignTable(); // let's infer the relation from the foreign table $fks = $this->getTable()->getForeignKeysReferencingTable($foreignTable->getName()); + // FIXME doesn't work when more than one fk to the same table return array_shift($fks); } diff --git a/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php b/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php index e76fc80773..0331a83cbd 100644 --- a/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php +++ b/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php @@ -12,9 +12,7 @@ use Propel\Generator\Exception\InvalidArgumentException; use Propel\Generator\Model\Behavior; -use Propel\Generator\Model\Column; use Propel\Generator\Model\Index; -use Propel\Generator\Model\Table; /** * Keeps tracks of an ActiveRecord object, even after deletion @@ -25,23 +23,28 @@ class ArchivableBehavior extends Behavior { // default parameters value protected $parameters = [ - 'archive_table' => '', - 'archive_phpname' => null, - 'archive_class' => '', - 'log_archived_at' => 'true', - 'archived_at_column' => 'archived_at', - 'archive_on_insert' => 'false', - 'archive_on_update' => 'false', - 'archive_on_delete' => 'true', + 'archive_table' => '', + 'archive_phpname' => null, + 'archive_class' => '', + 'log_archived_at' => 'true', + 'archived_at_column' => 'archived_at', + 'archive_on_insert' => 'false', + 'archive_on_update' => 'false', + 'archive_on_delete' => 'true', ]; /** - * @var Table|null + * @var \Propel\Generator\Model\Table|null */ protected $archiveTable; + protected $objectBuilderModifier; + protected $queryBuilderModifier; + /** + * @return void + */ public function modifyDatabase() { foreach ($this->getDatabase()->getTables() as $table) { @@ -60,6 +63,7 @@ public function modifyDatabase() /** * @throws \Propel\Generator\Exception\InvalidArgumentException + * * @return void */ public function modifyTable() @@ -83,12 +87,12 @@ protected function addArchiveTable() if (!$database->hasTable($archiveTableName)) { // create the version table $archiveTable = $database->addTable([ - 'name' => $archiveTableName, - 'phpName' => $this->getParameter('archive_phpname'), - 'package' => $table->getPackage(), - 'schema' => $table->getSchema(), + 'name' => $archiveTableName, + 'phpName' => $this->getParameter('archive_phpname'), + 'package' => $table->getPackage(), + 'schema' => $table->getSchema(), 'namespace' => $table->getNamespace() ? '\\' . $table->getNamespace() : null, - 'identifierQuoting' => $table->getIdentifierQuoting() + 'identifierQuoting' => $table->getIdentifierQuoting(), ]); $archiveTable->isArchiveTable = true; // copy all the columns @@ -106,7 +110,7 @@ protected function addArchiveTable() if ($this->getParameter('log_archived_at') == 'true') { $archiveTable->addColumn([ 'name' => $this->getParameter('archived_at_column'), - 'type' => 'TIMESTAMP' + 'type' => 'TIMESTAMP', ]); } // do not copy foreign keys @@ -140,7 +144,7 @@ protected function addArchiveTable() } /** - * @return Table|null + * @return \Propel\Generator\Model\Table|null */ public function getArchiveTable() { @@ -184,11 +188,11 @@ public function hasArchiveClass() } /** - * @return Column|null + * @return \Propel\Generator\Model\Column|null */ public function getArchivedAtColumn() { - if ($this->getArchiveTable() && 'true' === $this->getParameter('log_archived_at')) { + if ($this->getArchiveTable() && $this->getParameter('log_archived_at') === 'true') { return $this->getArchiveTable()->getColumn($this->getParameter('archived_at_column')); } @@ -200,7 +204,7 @@ public function getArchivedAtColumn() */ public function isArchiveOnInsert() { - return 'true' === $this->getParameter('archive_on_insert'); + return $this->getParameter('archive_on_insert') === 'true'; } /** @@ -208,7 +212,7 @@ public function isArchiveOnInsert() */ public function isArchiveOnUpdate() { - return 'true' === $this->getParameter('archive_on_update'); + return $this->getParameter('archive_on_update') === 'true'; } /** @@ -216,15 +220,15 @@ public function isArchiveOnUpdate() */ public function isArchiveOnDelete() { - return 'true' === $this->getParameter('archive_on_delete'); + return $this->getParameter('archive_on_delete') === 'true'; } /** - * @return \Propel\Generator\Behavior\Archivable\ArchivableBehavior|\Propel\Generator\Behavior\Archivable\ArchivableBehaviorObjectBuilderModifier + * @return $this|\Propel\Generator\Behavior\Archivable\ArchivableBehaviorObjectBuilderModifier */ public function getObjectBuilderModifier() { - if (null === $this->objectBuilderModifier) { + if ($this->objectBuilderModifier === null) { $this->objectBuilderModifier = new ArchivableBehaviorObjectBuilderModifier($this); } @@ -232,11 +236,11 @@ public function getObjectBuilderModifier() } /** - * @return \Propel\Generator\Behavior\Archivable\ArchivableBehavior|\Propel\Generator\Behavior\Archivable\ArchivableBehaviorQueryBuilderModifier + * @return $this|\Propel\Generator\Behavior\Archivable\ArchivableBehaviorQueryBuilderModifier */ public function getQueryBuilderModifier() { - if (null === $this->queryBuilderModifier) { + if ($this->queryBuilderModifier === null) { $this->queryBuilderModifier = new ArchivableBehaviorQueryBuilderModifier($this); } diff --git a/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php index ec8ce8c8f4..0c940e1bae 100644 --- a/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php @@ -127,7 +127,7 @@ public function preDelete($builder) if ($this->behavior->isArchiveOnDelete()) { return $this->behavior->renderTemplate('objectPreDelete', [ 'queryClassName' => $builder->getQueryClassName(), - 'isAddHooks' => $builder->getGeneratorConfig()->get()['generator']['objectModel']['addHooks'], + 'isAddHooks' => $builder->getGeneratorConfig()->get()['generator']['objectModel']['addHooks'], ]); } @@ -165,7 +165,7 @@ public function objectMethods($builder) public function addGetArchive($builder) { return $this->behavior->renderTemplate('objectGetArchive', [ - 'archiveTablePhpName' => $this->behavior->getArchiveTablePhpName($builder), + 'archiveTablePhpName' => $this->behavior->getArchiveTablePhpName($builder), 'archiveTableQueryName' => $this->behavior->getArchiveTableQueryName($builder), ]); } @@ -178,10 +178,10 @@ public function addGetArchive($builder) public function addArchive($builder) { return $this->behavior->renderTemplate('objectArchive', [ - 'archiveTablePhpName' => $this->behavior->getArchiveTablePhpName($builder), + 'archiveTablePhpName' => $this->behavior->getArchiveTablePhpName($builder), 'archiveTableQueryName' => $this->behavior->getArchiveTableQueryName($builder), - 'archivedAtColumn' => $this->behavior->getArchivedAtColumn(), - 'hasArchiveClass' => $this->behavior->hasArchiveClass() + 'archivedAtColumn' => $this->behavior->getArchivedAtColumn(), + 'hasArchiveClass' => $this->behavior->hasArchiveClass(), ]); } @@ -210,9 +210,9 @@ public function addPopulateFromArchive($builder) { return $this->behavior->renderTemplate('objectPopulateFromArchive', [ 'archiveTablePhpName' => $this->behavior->getArchiveTablePhpName($builder), - 'usesAutoIncrement' => $this->table->hasAutoIncrementPrimaryKey(), - 'objectClassName' => $this->builder->getObjectClassName(), - 'columns' => $this->table->getColumns(), + 'usesAutoIncrement' => $this->table->hasAutoIncrementPrimaryKey(), + 'objectClassName' => $this->builder->getObjectClassName(), + 'columns' => $this->table->getColumns(), ]); } @@ -224,7 +224,7 @@ public function addPopulateFromArchive($builder) public function addSaveWithoutArchive($builder) { return $this->behavior->renderTemplate('objectSaveWithoutArchive', [ - 'objectClassName' => $this->builder->getObjectClassName(), + 'objectClassName' => $this->builder->getObjectClassName(), 'isArchiveOnInsert' => $this->behavior->isArchiveOnInsert(), 'isArchiveOnUpdate' => $this->behavior->isArchiveOnUpdate(), ]); diff --git a/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php index a888d7dcdb..f7b0694f86 100644 --- a/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifier.php @@ -136,7 +136,7 @@ protected function addArchive($builder) { return $this->behavior->renderTemplate('queryArchive', [ 'archiveTablePhpName' => $this->behavior->getArchiveTablePhpName($builder), - 'modelTableMap' => $builder->getTableMapClass(), + 'modelTableMap' => $builder->getTableMapClass(), ]); } diff --git a/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php b/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php index 3dd0908d27..3de65803e0 100644 --- a/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php +++ b/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php @@ -21,14 +21,15 @@ class AutoAddPkBehavior extends Behavior { // default parameters value protected $parameters = [ - 'name' => 'id', + 'name' => 'id', 'autoIncrement' => 'true', - 'type' => 'INTEGER' + 'type' => 'INTEGER', ]; /** * Copy the behavior to the database tables * Only for tables that have no Pk + * * @return void */ public function modifyDatabase() @@ -43,6 +44,7 @@ public function modifyDatabase() /** * Add the primary key to the current table + * * @return void */ public function modifyTable() diff --git a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php index 2d70d77fee..9aab2d4e8c 100644 --- a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php +++ b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php @@ -32,14 +32,17 @@ class ConcreteInheritanceBehavior extends Behavior // default parameters value protected $parameters = [ - 'extends' => '', - 'descendant_column' => 'descendant_class', + 'extends' => '', + 'descendant_column' => 'descendant_class', 'copy_data_to_parent' => 'true', - 'copy_data_to_child' => 'false', - 'schema' => '', - 'exclude_behaviors' => '', + 'copy_data_to_child' => 'false', + 'schema' => '', + 'exclude_behaviors' => '', ]; + /** + * @return void + */ public function modifyTable() { $table = $this->getTable(); @@ -120,7 +123,7 @@ public function modifyTable() continue; } // validate behavior. If validate behavior already exists, clone only rules from parent - if ('validate' === $behavior->getName() && $table->hasBehavior('validate')) { + if ($behavior->getName() === 'validate' && $table->hasBehavior('validate')) { /** @var \Propel\Generator\Behavior\Validate\ValidateBehavior $validateBehavior */ $validateBehavior = $table->getBehavior('validate'); $validateBehavior->mergeParameters($behavior->getParameters()); @@ -131,11 +134,11 @@ public function modifyTable() $copiedBehavior->setTableModified(false); $this->getTable()->addBehavior($copiedBehavior); } - } /** * @throws \Propel\Generator\Exception\InvalidArgumentException + * * @return \Propel\Generator\Model\Table */ protected function getParentTable() @@ -143,7 +146,7 @@ protected function getParentTable() $database = $this->getTable()->getDatabase(); $tableName = $database->getTablePrefix() . $this->getParameter('extends'); if ($database->getPlatform()->supportsSchemas() && $this->getParameter('schema')) { - $tableName = $this->getParameter('schema').$database->getPlatform()->getSchemaDelimiter().$tableName; + $tableName = $this->getParameter('schema') . $database->getPlatform()->getSchemaDelimiter() . $tableName; } $table = $database->getTable($tableName); @@ -159,7 +162,7 @@ protected function getParentTable() */ protected function isCopyData() { - return 'true' === $this->getParameter('copy_data_to_parent'); + return $this->getParameter('copy_data_to_parent') === 'true'; } /** @@ -167,11 +170,11 @@ protected function isCopyData() */ protected function getCopyToChild() { - if ('false' === strtolower($this->getParameter('copy_data_to_child'))) { + if (strtolower($this->getParameter('copy_data_to_child')) === 'false') { return false; } - if ('true' === strtolower($this->getParameter('copy_data_to_child'))) { + if (strtolower($this->getParameter('copy_data_to_child')) === 'true') { return true; } @@ -280,7 +283,7 @@ public function syncParentToChild($parentClass \$parent) "; $columns = $this->getCopyToChild(); - if (true === $columns) { + if ($columns === true) { $columns = $parentTable->getColumns(); } else { $columnNames = $columns; @@ -300,7 +303,6 @@ public function syncParentToChild($parentClass \$parent) $getter = 'get' . ucfirst($column->getPhpName()); $setter = 'set' . ucfirst($column->getPhpName()); - $script .= " \$this->{$setter}(\$parent->{$getter}()); "; @@ -385,8 +387,8 @@ public function getSyncParent(\$con = null) } $refPhpName = $this->builder->getFKPhpNameAffix($fk, false); $script .= " - if (\$this->get" . $refPhpName . "() && \$this->get" . $refPhpName . "()->isNew()) { - \$parent->set" . $refPhpName . "(\$this->get" . $refPhpName . "()); + if (\$this->get" . $refPhpName . '() && $this->get' . $refPhpName . "()->isNew()) { + \$parent->set" . $refPhpName . '($this->get' . $refPhpName . "()); }"; } $script .= " diff --git a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php index f5a2d9414b..ddb5ab4202 100644 --- a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php +++ b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php @@ -28,9 +28,12 @@ class ConcreteInheritanceParentBehavior extends Behavior // default parameters value protected $parameters = [ - 'descendant_column' => 'descendant_class' + 'descendant_column' => 'descendant_class', ]; + /** + * @return void + */ public function modifyTable() { $table = $this->getTable(); @@ -38,7 +41,7 @@ public function modifyTable() $table->addColumn([ 'name' => $this->getParameter('descendant_column'), 'type' => 'VARCHAR', - 'size' => 100 + 'size' => 100, ]); } } diff --git a/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php b/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php index 6601122ca6..b1a3b7712e 100644 --- a/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php +++ b/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php @@ -10,13 +10,13 @@ namespace Propel\Generator\Behavior\Delegate; +use InvalidArgumentException; use Propel\Generator\Builder\Om\QueryBuilder; use Propel\Generator\Model\Behavior; use Propel\Generator\Model\Column; use Propel\Generator\Model\ForeignKey; use Propel\Generator\Model\NameGeneratorInterface; use Propel\Generator\Util\PhpParser; -use Propel\Runtime\Exception\PropelException; /** * Gives a model class the ability to delegate methods to a relationship. @@ -25,12 +25,12 @@ */ class DelegateBehavior extends Behavior { - const ONE_TO_ONE = 1; - const MANY_TO_ONE = 2; + public const ONE_TO_ONE = 1; + public const MANY_TO_ONE = 2; // default parameters value protected $parameters = [ - 'to' => '' + 'to' => '', ]; protected $delegates = []; @@ -43,6 +43,9 @@ class DelegateBehavior extends Behavior /** * Lists the delegates and checks that the behavior can use them, * And adds a fk from the delegate to the main table if not already set + * + * @throws \InvalidArgumentException + * * @return void */ public function modifyTable() @@ -53,7 +56,7 @@ public function modifyTable() foreach ($delegates as $delegate) { $delegate = $database->getTablePrefix() . trim($delegate); if (!$database->hasTable($delegate)) { - throw new \InvalidArgumentException(sprintf( + throw new InvalidArgumentException(sprintf( 'No delegate table "%s" found for table "%s"', $delegate, $table->getName() @@ -70,7 +73,7 @@ public function modifyTable() $fks = $delegateTable->getForeignKeysReferencingTable($this->getTable()->getName()); $fk = $fks[0]; if (!$fk->isLocalPrimaryKey()) { - throw new \InvalidArgumentException(sprintf( + throw new InvalidArgumentException(sprintf( 'Delegate table "%s" has a relationship with table "%s", but it\'s a one-to-many relationship. The `delegate` behavior only supports one-to-one relationships in this case.', $delegate, $table->getName() @@ -184,7 +187,7 @@ public function objectFilter(&$script) $delegateTable = $this->getDelegateTable($key); $tn = ($delegateTable->getSchema() ? $delegateTable->getSchema() . NameGeneratorInterface::STD_SEPARATOR_CHAR : '') . $delegateTable->getCommonName(); - $ns = $delegateTable->getNamespace() ? '\\'.$delegateTable->getNamespace() : ''; + $ns = $delegateTable->getNamespace() ? '\\' . $delegateTable->getNamespace() : ''; $new_result .= "{$indent}\$keys_{$tn} = {$ns}\\Map\\{$delegateTable->getPhpName()}TableMap::getFieldNames(\$keyType);\n"; $i = 0; foreach ($delegateTable->getColumns() as $column) { @@ -202,11 +205,9 @@ public function objectFilter(&$script) } /** - * @param Column $column + * @param \Propel\Generator\Model\Column $column * * @return bool - * - * @throws PropelException */ protected function isColumnForeignKeyOrDuplicated(Column $column) { @@ -217,7 +218,7 @@ protected function isColumnForeignKeyOrDuplicated(Column $column) if ($this->double_defined === null) { $this->double_defined = []; - foreach ($this->delegates+[$table->getName() => 1] as $key => $value) { + foreach ($this->delegates + [$table->getName() => 1] as $key => $value) { $delegateTable = $this->getDelegateTable($key); foreach ($delegateTable->getColumns() as $columnDelegated) { if (isset($this->double_defined[$columnDelegated->getName()])) { @@ -229,7 +230,7 @@ protected function isColumnForeignKeyOrDuplicated(Column $column) } } - if (1<$this->double_defined[$column->getName()]) { + if (1 < $this->double_defined[$column->getName()]) { return true; } @@ -301,7 +302,6 @@ public function queryMethods(QueryBuilder $builder) $script .= $this->renderTemplate('queryMethodsTemplate', compact('tablePhpName', 'phpName', 'childClassName', 'fieldName')); } - } } @@ -336,6 +336,6 @@ public function filterBy(\$column, \$value, \$comparison = Criteria::EQUAL) "; } - return $script; + return $script; } } diff --git a/src/Propel/Generator/Behavior/I18n/I18nBehavior.php b/src/Propel/Generator/Behavior/I18n/I18nBehavior.php index 42412ddbe2..aeab6c16f2 100644 --- a/src/Propel/Generator/Behavior/I18n/I18nBehavior.php +++ b/src/Propel/Generator/Behavior/I18n/I18nBehavior.php @@ -10,11 +10,11 @@ namespace Propel\Generator\Behavior\I18n; +use Propel\Generator\Behavior\Validate\ValidateBehavior; use Propel\Generator\Exception\EngineException; use Propel\Generator\Model\Behavior; use Propel\Generator\Model\ForeignKey; use Propel\Generator\Model\PropelTypes; -use Propel\Generator\Behavior\Validate\ValidateBehavior; /** * Allows translation of text columns through transparent one-to-many @@ -24,18 +24,18 @@ */ class I18nBehavior extends Behavior { - const DEFAULT_LOCALE = 'en_US'; + public const DEFAULT_LOCALE = 'en_US'; // default parameters value protected $parameters = [ - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => '', - 'i18n_pk_column' => null, - 'locale_column' => 'locale', - 'locale_length' => 5, - 'default_locale' => null, - 'locale_alias' => '', + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => '', + 'i18n_pk_column' => null, + 'locale_column' => 'locale', + 'locale_length' => 5, + 'default_locale' => null, + 'locale_alias' => '', ]; protected $tableModificationOrder = 70; @@ -63,7 +63,7 @@ public function modifyDatabase() foreach ($this->getDatabase()->getTables() as $table) { if ($table->hasBehavior('i18n') && !$table->getBehavior('i18n')->getParameter('default_locale')) { $table->getBehavior('i18n')->addParameter([ - 'name' => 'default_locale', + 'name' => 'default_locale', 'value' => $this->getParameter('default_locale'), ]); } @@ -92,7 +92,7 @@ public function getI18nTable() } /** - * @return ForeignKey|null + * @return \Propel\Generator\Model\ForeignKey|null */ public function getI18nForeignKey() { @@ -123,7 +123,7 @@ public function getI18nColumns() if ($columnNames = $this->getI18nColumnNamesFromConfig()) { // Strategy 1: use the i18n_columns parameter foreach ($columnNames as $columnName) { - $columns []= $i18nTable->getColumn($columnName); + $columns[] = $i18nTable->getColumn($columnName); } } else { // strategy 2: use the columns of the i18n table @@ -131,7 +131,7 @@ public function getI18nColumns() // (such as timestampable behavior) foreach ($i18nTable->getColumns() as $column) { if (!$column->isPrimaryKey()) { - $columns []= $column; + $columns[] = $column; } } } @@ -149,17 +149,17 @@ public function replaceTokens($string) $table = $this->getTable(); return strtr($string, [ - '%TABLE%' => $table->getOriginCommonName(), + '%TABLE%' => $table->getOriginCommonName(), '%PHPNAME%' => $table->getPhpName(), ]); } /** - * @return \Propel\Generator\Behavior\I18n\I18nBehavior|\Propel\Generator\Behavior\I18n\I18nBehaviorObjectBuilderModifier + * @return $this|\Propel\Generator\Behavior\I18n\I18nBehaviorObjectBuilderModifier */ public function getObjectBuilderModifier() { - if (null === $this->objectBuilderModifier) { + if ($this->objectBuilderModifier === null) { $this->objectBuilderModifier = new I18nBehaviorObjectBuilderModifier($this); } @@ -167,11 +167,11 @@ public function getObjectBuilderModifier() } /** - * @return \Propel\Generator\Behavior\I18n\I18nBehavior|\Propel\Generator\Behavior\I18n\I18nBehaviorQueryBuilderModifier + * @return $this|\Propel\Generator\Behavior\I18n\I18nBehaviorQueryBuilderModifier */ public function getQueryBuilderModifier() { - if (null === $this->queryBuilderModifier) { + if ($this->queryBuilderModifier === null) { $this->queryBuilderModifier = new I18nBehaviorQueryBuilderModifier($this); } @@ -206,21 +206,21 @@ public function modifyTable() */ protected function addI18nTable() { - $table = $this->getTable(); - $database = $table->getDatabase(); + $table = $this->getTable(); + $database = $table->getDatabase(); $i18nTableName = $this->getI18nTableName(); if ($database->hasTable($i18nTableName)) { $this->i18nTable = $database->getTable($i18nTableName); } else { $this->i18nTable = $database->addTable([ - 'name' => $i18nTableName, - 'phpName' => $this->getI18nTablePhpName(), - 'package' => $table->getPackage(), - 'schema' => $table->getSchema(), + 'name' => $i18nTableName, + 'phpName' => $this->getI18nTablePhpName(), + 'package' => $table->getPackage(), + 'schema' => $table->getSchema(), 'namespace' => $table->getNamespace() ? '\\' . $table->getNamespace() : null, - 'skipSql' => $table->isSkipSql(), - 'identifierQuoting' => $table->getIdentifierQuoting() + 'skipSql' => $table->isSkipSql(), + 'identifierQuoting' => $table->getIdentifierQuoting(), ]); // every behavior adding a table should re-execute database behaviors @@ -232,13 +232,14 @@ protected function addI18nTable() /** * @throws \Propel\Generator\Exception\EngineException + * * @return void */ protected function relateI18nTableToMainTable() { - $table = $this->getTable(); + $table = $this->getTable(); $i18nTable = $this->i18nTable; - $pks = $this->getTable()->getPrimaryKey(); + $pks = $this->getTable()->getPrimaryKey(); if (count($pks) > 1) { throw new EngineException('The i18n behavior does not support tables with composite primary keys'); @@ -250,7 +251,7 @@ protected function relateI18nTableToMainTable() if ($this->getParameter('i18n_pk_column')) { // custom i18n table pk name $i18nColumn->setName($this->getParameter('i18n_pk_column')); - } else if (in_array($table->getName(), $i18nTable->getForeignTableNames())) { + } elseif (in_array($table->getName(), $i18nTable->getForeignTableNames())) { // custom i18n table pk name not set, but some fk already exists return; } @@ -278,12 +279,12 @@ protected function addLocaleColumnToI18n() { $localeColumnName = $this->getLocaleColumnName(); - if (! $this->i18nTable->hasColumn($localeColumnName)) { + if (!$this->i18nTable->hasColumn($localeColumnName)) { $this->i18nTable->addColumn([ - 'name' => $localeColumnName, - 'type' => PropelTypes::VARCHAR, - 'size' => $this->getParameter('locale_length') ? (int) $this->getParameter('locale_length') : 5, - 'default' => $this->getDefaultLocale(), + 'name' => $localeColumnName, + 'type' => PropelTypes::VARCHAR, + 'size' => $this->getParameter('locale_length') ? (int)$this->getParameter('locale_length') : 5, + 'default' => $this->getDefaultLocale(), 'primaryKey' => 'true', ]); } @@ -292,11 +293,13 @@ protected function addLocaleColumnToI18n() /** * Moves i18n columns from the main table to the i18n table * + * @throws \Propel\Generator\Exception\EngineException + * * @return void */ protected function moveI18nColumns() { - $table = $this->getTable(); + $table = $this->getTable(); $i18nTable = $this->i18nTable; $i18nValidateParams = []; diff --git a/src/Propel/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifier.php index 3b7f9ff550..aaa0ba9d2b 100644 --- a/src/Propel/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifier.php @@ -57,7 +57,7 @@ public function postDelete($builder) $i18nTable = $this->behavior->getI18nTable(); return $this->behavior->renderTemplate('objectPostDelete', [ - 'i18nQueryName' => $builder->getClassNameFromBuilder($builder->getNewStubQueryBuilder($i18nTable)), + 'i18nQueryName' => $builder->getClassNameFromBuilder($builder->getNewStubQueryBuilder($i18nTable)), 'objectClassName' => $builder->getNewStubObjectBuilder($this->behavior->getTable())->getUnqualifiedClassName(), ]); } @@ -73,7 +73,7 @@ public function postDelete($builder) public function objectAttributes($builder) { return $this->behavior->renderTemplate('objectAttributes', [ - 'defaultLocale' => $this->behavior->getDefaultLocale(), + 'defaultLocale' => $this->behavior->getDefaultLocale(), 'objectClassName' => $builder->getClassNameFromBuilder($builder->getNewStubObjectBuilder($this->behavior->getI18nTable())), ]); } @@ -86,7 +86,7 @@ public function objectAttributes($builder) public function objectClearReferences($builder) { return $this->behavior->renderTemplate('objectClearReferences', [ - 'defaultLocale' => $this->behavior->getDefaultLocale(), + 'defaultLocale' => $this->behavior->getDefaultLocale(), ]); } @@ -126,9 +126,9 @@ public function objectMethods($builder) protected function addSetLocale() { return $this->behavior->renderTemplate('objectSetLocale', [ - 'objectClassName' => $this->builder->getClassNameFromBuilder($this->builder->getStubObjectBuilder()), - 'defaultLocale' => $this->behavior->getDefaultLocale(), - 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName(), + 'objectClassName' => $this->builder->getClassNameFromBuilder($this->builder->getStubObjectBuilder()), + 'defaultLocale' => $this->behavior->getDefaultLocale(), + 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName(), ]); } @@ -138,7 +138,7 @@ protected function addSetLocale() protected function addGetLocale() { return $this->behavior->renderTemplate('objectGetLocale', [ - 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName(), + 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName(), ]); } @@ -150,10 +150,10 @@ protected function addGetLocale() protected function addSetLocaleAlias($alias) { return $this->behavior->renderTemplate('objectSetLocaleAlias', [ - 'objectClassName' => $this->builder->getClassNameFromBuilder($this->builder->getStubObjectBuilder()), - 'defaultLocale' => $this->behavior->getDefaultLocale(), - 'alias' => ucfirst($alias), - 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName(), + 'objectClassName' => $this->builder->getClassNameFromBuilder($this->builder->getStubObjectBuilder()), + 'defaultLocale' => $this->behavior->getDefaultLocale(), + 'alias' => ucfirst($alias), + 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName(), ]); } @@ -166,7 +166,7 @@ protected function addGetLocaleAlias($alias) { return $this->behavior->renderTemplate('objectGetLocaleAlias', [ 'alias' => ucfirst($alias), - 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName(), + 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName(), ]); } @@ -181,10 +181,10 @@ protected function addGetTranslation() return $this->behavior->renderTemplate('objectGetTranslation', [ 'i18nTablePhpName' => $this->builder->getClassNameFromBuilder($this->builder->getNewStubObjectBuilder($i18nTable)), - 'defaultLocale' => $this->behavior->getDefaultLocale(), + 'defaultLocale' => $this->behavior->getDefaultLocale(), 'i18nListVariable' => $this->builder->getRefFKCollVarName($fk), 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName(), - 'i18nQueryName' => $this->builder->getClassNameFromBuilder($this->builder->getNewStubQueryBuilder($i18nTable)), + 'i18nQueryName' => $this->builder->getClassNameFromBuilder($this->builder->getNewStubQueryBuilder($i18nTable)), 'i18nSetterMethod' => $this->builder->getRefFKPhpNameAffix($fk, $plural), ]); } @@ -199,9 +199,9 @@ protected function addRemoveTranslation() return $this->behavior->renderTemplate('objectRemoveTranslation', [ 'objectClassName' => $this->builder->getClassNameFromBuilder($this->builder->getStubObjectBuilder()), - 'defaultLocale' => $this->behavior->getDefaultLocale(), - 'i18nQueryName' => $this->builder->getClassNameFromBuilder($this->builder->getNewStubQueryBuilder($i18nTable)), - 'i18nCollection' => $this->builder->getRefFKCollVarName($fk), + 'defaultLocale' => $this->behavior->getDefaultLocale(), + 'i18nQueryName' => $this->builder->getClassNameFromBuilder($this->builder->getNewStubQueryBuilder($i18nTable)), + 'i18nCollection' => $this->builder->getRefFKCollVarName($fk), 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName(), ]); } @@ -213,7 +213,7 @@ protected function addGetCurrentTranslation() { return $this->behavior->renderTemplate('objectGetCurrentTranslation', [ 'i18nTablePhpName' => $this->builder->getClassNameFromBuilder($this->builder->getNewStubObjectBuilder($this->behavior->getI18nTable())), - 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName(), + 'localeColumnName' => $this->behavior->getLocaleColumn()->getPhpName(), ]); } @@ -241,10 +241,10 @@ protected function addTranslatedColumnGetter(Column $column) preg_match_all('/\$[a-z]+/i', $functionStatement, $params); return $this->behavior->renderTemplate('objectTranslatedColumnGetter', [ - 'comment' => $comment, + 'comment' => $comment, 'functionStatement' => $functionStatement, - 'columnPhpName' => $column->getPhpName(), - 'params' => implode(', ', $params[0]), + 'columnPhpName' => $column->getPhpName(), + 'params' => implode(', ', $params[0]), ]); } @@ -275,10 +275,10 @@ protected function addTranslatedColumnSetter(Column $column) preg_match_all('/\$[a-z]+/i', $functionStatement, $params); return $this->behavior->renderTemplate('objectTranslatedColumnSetter', [ - 'comment' => $comment, + 'comment' => $comment, 'functionStatement' => $functionStatement, - 'columnPhpName' => $column->getPhpName(), - 'params' => implode(', ', $params[0]), + 'columnPhpName' => $column->getPhpName(), + 'params' => implode(', ', $params[0]), ]); } @@ -313,7 +313,7 @@ protected function isDateType($columnType) return in_array($columnType, [ PropelTypes::DATE, PropelTypes::TIME, - PropelTypes::TIMESTAMP + PropelTypes::TIMESTAMP, ], true); } } diff --git a/src/Propel/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifier.php index 0366d63cad..c3be400b25 100644 --- a/src/Propel/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifier.php @@ -39,7 +39,7 @@ class I18nBehaviorQueryBuilderModifier public function __construct($behavior) { $this->behavior = $behavior; - $this->table = $behavior->getTable(); + $this->table = $behavior->getTable(); } /** @@ -66,10 +66,10 @@ protected function addJoinI18n() $fk = $this->behavior->getI18nForeignKey(); return $this->behavior->renderTemplate('queryJoinI18n', [ - 'queryClass' => $this->builder->getQueryClassName(), - 'defaultLocale' => $this->behavior->getDefaultLocale(), + 'queryClass' => $this->builder->getQueryClassName(), + 'defaultLocale' => $this->behavior->getDefaultLocale(), 'i18nRelationName' => $this->builder->getRefFKPhpNameAffix($fk), - 'localeColumn' => $this->behavior->getLocaleColumn()->getPhpName(), + 'localeColumn' => $this->behavior->getLocaleColumn()->getPhpName(), ]); } @@ -81,8 +81,8 @@ protected function addJoinWithI18n() $fk = $this->behavior->getI18nForeignKey(); return $this->behavior->renderTemplate('queryJoinWithI18n', [ - 'queryClass' => $this->builder->getQueryClassName(), - 'defaultLocale' => $this->behavior->getDefaultLocale(), + 'queryClass' => $this->builder->getQueryClassName(), + 'defaultLocale' => $this->behavior->getDefaultLocale(), 'i18nRelationName' => $this->builder->getRefFKPhpNameAffix($fk), ]); } @@ -96,11 +96,11 @@ protected function addUseI18nQuery() $fk = $this->behavior->getI18nForeignKey(); return $this->behavior->renderTemplate('queryUseI18nQuery', [ - 'queryClass' => $this->builder->getClassNameFromBuilder($this->builder->getNewStubQueryBuilder($i18nTable)), + 'queryClass' => $this->builder->getClassNameFromBuilder($this->builder->getNewStubQueryBuilder($i18nTable)), 'namespacedQueryClass' => $this->builder->getNewStubQueryBuilder($i18nTable)->getFullyQualifiedClassName(), - 'defaultLocale' => $this->behavior->getDefaultLocale(), - 'i18nRelationName' => $this->builder->getRefFKPhpNameAffix($fk), - 'localeColumn' => $this->behavior->getLocaleColumn()->getPhpName(), + 'defaultLocale' => $this->behavior->getDefaultLocale(), + 'i18nRelationName' => $this->builder->getRefFKPhpNameAffix($fk), + 'localeColumn' => $this->behavior->getLocaleColumn()->getPhpName(), ]); } } diff --git a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php index 56a6233958..04ee7d1631 100644 --- a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php +++ b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php @@ -21,12 +21,12 @@ class NestedSetBehavior extends Behavior { // default parameters value protected $parameters = [ - 'left_column' => 'tree_left', - 'right_column' => 'tree_right', - 'level_column' => 'tree_level', - 'use_scope' => 'false', - 'scope_column' => 'tree_scope', - 'method_proxies' => 'false' + 'left_column' => 'tree_left', + 'right_column' => 'tree_right', + 'level_column' => 'tree_level', + 'use_scope' => 'false', + 'scope_column' => 'tree_scope', + 'method_proxies' => 'false', ]; protected $objectBuilderModifier; @@ -35,6 +35,7 @@ class NestedSetBehavior extends Behavior /** * Add the left, right and scope to the current table + * * @return void */ public function modifyTable() @@ -44,38 +45,38 @@ public function modifyTable() if (!$table->hasColumn($this->getParameter('left_column'))) { $table->addColumn([ 'name' => $this->getParameter('left_column'), - 'type' => 'INTEGER' + 'type' => 'INTEGER', ]); } if (!$table->hasColumn($this->getParameter('right_column'))) { $table->addColumn([ 'name' => $this->getParameter('right_column'), - 'type' => 'INTEGER' + 'type' => 'INTEGER', ]); } if (!$table->hasColumn($this->getParameter('level_column'))) { $table->addColumn([ 'name' => $this->getParameter('level_column'), - 'type' => 'INTEGER' + 'type' => 'INTEGER', ]); } - if ('true' === $this->getParameter('use_scope') && !$table->hasColumn($this->getParameter('scope_column'))) { + if ($this->getParameter('use_scope') === 'true' && !$table->hasColumn($this->getParameter('scope_column'))) { $table->addColumn([ 'name' => $this->getParameter('scope_column'), - 'type' => 'INTEGER' + 'type' => 'INTEGER', ]); } } /** - * @return \Propel\Generator\Behavior\NestedSet\NestedSetBehavior|\Propel\Generator\Behavior\NestedSet\NestedSetBehaviorObjectBuilderModifier + * @return $this|\Propel\Generator\Behavior\NestedSet\NestedSetBehaviorObjectBuilderModifier */ public function getObjectBuilderModifier() { - if (null === $this->objectBuilderModifier) { + if ($this->objectBuilderModifier === null) { $this->objectBuilderModifier = new NestedSetBehaviorObjectBuilderModifier($this); } @@ -83,11 +84,11 @@ public function getObjectBuilderModifier() } /** - * @return \Propel\Generator\Behavior\NestedSet\NestedSetBehavior|\Propel\Generator\Behavior\NestedSet\NestedSetBehaviorQueryBuilderModifier + * @return $this|\Propel\Generator\Behavior\NestedSet\NestedSetBehaviorQueryBuilderModifier */ public function getQueryBuilderModifier() { - if (null === $this->queryBuilderModifier) { + if ($this->queryBuilderModifier === null) { $this->queryBuilderModifier = new NestedSetBehaviorQueryBuilderModifier($this); } @@ -99,7 +100,7 @@ public function getQueryBuilderModifier() */ public function useScope() { - return 'true' === $this->getParameter('use_scope'); + return $this->getParameter('use_scope') === 'true'; } /** diff --git a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifier.php index 857da4fcbf..d7e59cb90c 100644 --- a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifier.php @@ -11,7 +11,6 @@ namespace Propel\Generator\Behavior\NestedSet; use Propel\Generator\Builder\Om\ObjectBuilder; -use Propel\Generator\Model\Table; /** * Behavior to adds nested set tree structure columns and abilities @@ -22,17 +21,17 @@ class NestedSetBehaviorObjectBuilderModifier { /** - * @var NestedSetBehavior + * @var \Propel\Generator\Behavior\NestedSet\NestedSetBehavior */ protected $behavior; /** - * @var Table + * @var \Propel\Generator\Model\Table */ protected $table; /** - * @var ObjectBuilder + * @var \Propel\Generator\Builder\Om\ObjectBuilder */ protected $builder; @@ -42,7 +41,7 @@ class NestedSetBehaviorObjectBuilderModifier public function __construct(NestedSetBehavior $behavior) { $this->behavior = $behavior; - $this->table = $behavior->getTable(); + $this->table = $behavior->getTable(); } /** @@ -92,7 +91,7 @@ protected function setBuilder(ObjectBuilder $builder) */ public function preSave(ObjectBuilder $builder) { - $queryClassName = $builder->getQueryClassName(); + $queryClassName = $builder->getQueryClassName(); $objectClassName = $builder->getObjectClassName(); $script = "if (\$this->isNew() && \$this->isRoot()) { @@ -154,7 +153,7 @@ public function postDelete(ObjectBuilder $builder) return "if (\$this->isInTree()) { // fill up the room that was used by the node - $queryClassName::shiftRLValues(-2, \$this->getRightValue() + 1, null" . ($this->behavior->useScope() ? ", \$this->getScopeValue()" : "") . ", \$con); + $queryClassName::shiftRLValues(-2, \$this->getRightValue() + 1, null" . ($this->behavior->useScope() ? ', $this->getScopeValue()' : '') . ", \$con); } "; } @@ -182,31 +181,35 @@ public function objectMethods(ObjectBuilder $builder) $this->addProcessNestedSetQueries($script); - if ('LeftValue' !== $this->getColumnPhpName('left_column')) { + if ($this->getColumnPhpName('left_column') !== 'LeftValue') { $this->addGetLeft($script); } - if ('RightValue' !== $this->getColumnPhpName('right_column')) { + if ($this->getColumnPhpName('right_column') !== 'RightValue') { $this->addGetRight($script); } - if ('Level' !== $this->getColumnPhpName('level_column')) { + if ($this->getColumnPhpName('level_column') !== 'Level') { $this->addGetLevel($script); } - if ('true' === $this->getParameter('use_scope') - && 'ScopeValue' !== $this->getColumnPhpName('scope_column')) { + if ( + $this->getParameter('use_scope') === 'true' + && $this->getColumnPhpName('scope_column') !== 'ScopeValue' + ) { $this->addGetScope($script); } - if ('LeftValue' !== $this->getColumnPhpName('left_column')) { + if ($this->getColumnPhpName('left_column') !== 'LeftValue') { $script .= $this->addSetLeft(); } - if ('RightValue' !== $this->getColumnPhpName('right_column')) { + if ($this->getColumnPhpName('right_column') !== 'RightValue') { $this->addSetRight($script); } - if ('Level' !== $this->getColumnPhpName('level_column')) { + if ($this->getColumnPhpName('level_column') !== 'Level') { $this->addSetLevel($script); } - if ('true' === $this->getParameter('use_scope') - && 'ScopeValue' !== $this->getColumnPhpName('scope_column')) { + if ( + $this->getParameter('use_scope') === 'true' + && $this->getColumnPhpName('scope_column') !== 'ScopeValue' + ) { $this->addSetScope($script); } @@ -383,8 +386,8 @@ public function getScopeValue() protected function addSetLeft() { return $this->behavior->renderTemplate('objectSetLeft', [ - 'objectClassName' => $this->builder->getObjectClassName(), - 'leftColumn' => $this->getColumnPhpName('left_column'), + 'objectClassName' => $this->builder->getObjectClassName(), + 'leftColumn' => $this->getColumnPhpName('left_column'), ]); } @@ -707,7 +710,7 @@ public function hasPrevSibling(ConnectionInterface \$con = null) } return $queryClassName::create() - ->filterBy" . $this->getColumnPhpName('right_column') . "(\$this->getLeftValue() - 1)"; + ->filterBy" . $this->getColumnPhpName('right_column') . '($this->getLeftValue() - 1)'; if ($this->behavior->useScope()) { $script .= " ->inTree(\$this->getScopeValue())"; @@ -738,7 +741,7 @@ protected function addGetPrevSibling(&$script) public function getPrevSibling(ConnectionInterface \$con = null) { return $queryClassName::create() - ->filterBy" . $this->getColumnPhpName('right_column') . "(\$this->getLeftValue() - 1)"; + ->filterBy" . $this->getColumnPhpName('right_column') . '($this->getLeftValue() - 1)'; if ($this->behavior->useScope()) { $script .= " ->inTree(\$this->getScopeValue())"; @@ -772,7 +775,7 @@ public function hasNextSibling(ConnectionInterface \$con = null) } return $queryClassName::create() - ->filterBy" . $this->getColumnPhpName('left_column') . "(\$this->getRightValue() + 1)"; + ->filterBy" . $this->getColumnPhpName('left_column') . '($this->getRightValue() + 1)'; if ($this->behavior->useScope()) { $script .= " ->inTree(\$this->getScopeValue())"; @@ -803,7 +806,7 @@ protected function addGetNextSibling(&$script) public function getNextSibling(ConnectionInterface \$con = null) { return $queryClassName::create() - ->filterBy" . $this->getColumnPhpName('left_column') . "(\$this->getRightValue() + 1)"; + ->filterBy" . $this->getColumnPhpName('left_column') . '($this->getRightValue() + 1)'; if ($this->behavior->useScope()) { $script .= " ->inTree(\$this->getScopeValue())"; @@ -852,7 +855,7 @@ protected function addNestedSetChildrenInit(&$script) */ public function initNestedSetChildren() { - \$collectionClassName = ".$this->builder->getNewTableMapBuilder($this->table)->getFullyQualifiedClassName()."::getTableMap()->getCollectionClassName(); + \$collectionClassName = " . $this->builder->getNewTableMapBuilder($this->table)->getFullyQualifiedClassName() . "::getTableMap()->getCollectionClassName(); \$this->collNestedSetChildren = new \$collectionClassName; \$this->collNestedSetChildren->setModel('" . $this->builder->getNewStubObjectBuilder($this->table)->getFullyQualifiedClassName() . "'); @@ -868,7 +871,7 @@ public function initNestedSetChildren() protected function addNestedSetChildAdd(&$script) { $objectClassName = $this->builder->getObjectClassName(); - $objectName = '$' . $this->table->getCamelCaseName(); + $objectName = '$' . $this->table->getCamelCaseName(); $script .= " /** @@ -921,7 +924,7 @@ public function hasChildren() protected function addGetChildren(&$script) { $objectClassName = $this->builder->getObjectClassName(); - $queryClassName = $this->builder->getQueryClassName(); + $queryClassName = $this->builder->getQueryClassName(); $script .= " /** @@ -996,7 +999,7 @@ public function countChildren(Criteria \$criteria = null, ConnectionInterface \$ protected function addGetFirstChild(&$script) { $objectClassName = $this->builder->getObjectClassName(); - $queryClassName = $this->builder->getQueryClassName(); + $queryClassName = $this->builder->getQueryClassName(); $script .= " /** * Gets the first child of the given node @@ -1027,7 +1030,7 @@ public function getFirstChild(Criteria \$criteria = null, ConnectionInterface \$ protected function addGetLastChild(&$script) { $objectClassName = $this->builder->getObjectClassName(); - $queryClassName = $this->builder->getQueryClassName(); + $queryClassName = $this->builder->getQueryClassName(); $script .= " /** @@ -1059,7 +1062,7 @@ public function getLastChild(Criteria \$criteria = null, ConnectionInterface \$c protected function addGetSiblings(&$script) { $objectClassName = $this->builder->getObjectClassName(); - $queryClassName = $this->builder->getQueryClassName(); + $queryClassName = $this->builder->getQueryClassName(); $script .= " /** @@ -1097,7 +1100,7 @@ public function getSiblings(\$includeNode = false, Criteria \$criteria = null, C protected function addGetDescendants(&$script) { $objectClassName = $this->builder->getObjectClassName(); - $queryClassName = $this->builder->getQueryClassName(); + $queryClassName = $this->builder->getQueryClassName(); $script .= " /** @@ -1160,7 +1163,7 @@ public function countDescendants(Criteria \$criteria = null, ConnectionInterface protected function addGetBranch(&$script) { $objectClassName = $this->builder->getObjectClassName(); - $queryClassName = $this->builder->getQueryClassName(); + $queryClassName = $this->builder->getQueryClassName(); $script .= " /** @@ -1188,7 +1191,7 @@ public function getBranch(Criteria \$criteria = null, ConnectionInterface \$con protected function addGetAncestors(&$script) { $objectClassName = $this->builder->getObjectClassName(); - $queryClassName = $this->builder->getQueryClassName(); + $queryClassName = $this->builder->getQueryClassName(); $script .= " /** @@ -1253,8 +1256,8 @@ public function addChild($objectClassName \$child) protected function addInsertAsFirstChildOf(&$script) { $objectClassName = $this->builder->getObjectClassName(); - $queryClassName = $this->builder->getQueryClassName(true); - $useScope = $this->behavior->useScope(); + $queryClassName = $this->builder->getQueryClassName(true); + $useScope = $this->behavior->useScope(); $script .= " /** @@ -1290,7 +1293,7 @@ public function insertAsFirstChildOf($objectClassName \$parent) // Keep the tree modification query for the save() transaction \$this->nestedSetQueries[] = array( 'callable' => array('$queryClassName', 'makeRoomForLeaf'), - 'arguments' => array(\$left" . ($useScope ? ", \$scope" : "") . ", \$this->isNew() ? null : \$this) + 'arguments' => array(\$left" . ($useScope ? ', $scope' : '') . ", \$this->isNew() ? null : \$this) ); return \$this; @@ -1305,8 +1308,8 @@ protected function addInsertAsLastChildOf() { return $this->behavior->renderTemplate('objectInsertAsLastChildOf', [ 'objectClassName' => $this->builder->getObjectClassName(), - 'queryClassName' => $this->builder->getQueryClassName(true), - 'useScope' => $this->behavior->useScope(), + 'queryClassName' => $this->builder->getQueryClassName(true), + 'useScope' => $this->behavior->useScope(), ]); } @@ -1318,8 +1321,8 @@ protected function addInsertAsLastChildOf() protected function addInsertAsPrevSiblingOf(&$script) { $objectClassName = $this->builder->getObjectClassName(); - $queryClassName = $this->builder->getQueryClassName(true); - $useScope = $this->behavior->useScope(); + $queryClassName = $this->builder->getQueryClassName(true); + $useScope = $this->behavior->useScope(); $script .= " /** @@ -1350,7 +1353,7 @@ public function insertAsPrevSiblingOf($objectClassName \$sibling) // Keep the tree modification query for the save() transaction \$this->nestedSetQueries []= array( 'callable' => array('$queryClassName', 'makeRoomForLeaf'), - 'arguments' => array(\$left" . ($useScope ? ", \$scope" : "") . ", \$this->isNew() ? null : \$this) + 'arguments' => array(\$left" . ($useScope ? ', $scope' : '') . ", \$this->isNew() ? null : \$this) ); return \$this; @@ -1366,8 +1369,8 @@ public function insertAsPrevSiblingOf($objectClassName \$sibling) protected function addInsertAsNextSiblingOf(&$script) { $objectClassName = $this->builder->getObjectClassName(); - $queryClassName = $this->builder->getQueryClassName(true); - $useScope = $this->behavior->useScope(); + $queryClassName = $this->builder->getQueryClassName(true); + $useScope = $this->behavior->useScope(); $script .= " /** @@ -1398,7 +1401,7 @@ public function insertAsNextSiblingOf($objectClassName \$sibling) // Keep the tree modification query for the save() transaction \$this->nestedSetQueries []= array( 'callable' => array('$queryClassName', 'makeRoomForLeaf'), - 'arguments' => array(\$left" . ($useScope ? ", \$scope" : "") . ", \$this->isNew() ? null : \$this) + 'arguments' => array(\$left" . ($useScope ? ', $scope' : '') . ", \$this->isNew() ? null : \$this) ); return \$this; @@ -1435,7 +1438,7 @@ public function moveToFirstChildOf($objectClassName \$parent, ConnectionInterfac throw new PropelException('Cannot move a node as child of one of its subtree nodes.'); } - \$this->moveSubtreeTo(\$parent->getLeftValue() + 1, \$parent->getLevel() - \$this->getLevel() + 1" . ($this->behavior->useScope() ? ", \$parent->getScopeValue()" : "") . ", \$con); + \$this->moveSubtreeTo(\$parent->getLeftValue() + 1, \$parent->getLevel() - \$this->getLevel() + 1" . ($this->behavior->useScope() ? ', $parent->getScopeValue()' : '') . ", \$con); return \$this; } @@ -1472,7 +1475,7 @@ public function moveToLastChildOf($objectClassName \$parent, ConnectionInterface throw new PropelException('Cannot move a node as child of one of its subtree nodes.'); } - \$this->moveSubtreeTo(\$parent->getRightValue(), \$parent->getLevel() - \$this->getLevel() + 1" . ($this->behavior->useScope() ? ", \$parent->getScopeValue()" : "") . ", \$con); + \$this->moveSubtreeTo(\$parent->getRightValue(), \$parent->getLevel() - \$this->getLevel() + 1" . ($this->behavior->useScope() ? ', $parent->getScopeValue()' : '') . ", \$con); return \$this; } @@ -1512,7 +1515,7 @@ public function moveToPrevSiblingOf($objectClassName \$sibling, ConnectionInterf throw new PropelException('Cannot move a node as sibling of one of its subtree nodes.'); } - \$this->moveSubtreeTo(\$sibling->getLeftValue(), \$sibling->getLevel() - \$this->getLevel()" . ($this->behavior->useScope() ? ", \$sibling->getScopeValue()" : "") . ", \$con); + \$this->moveSubtreeTo(\$sibling->getLeftValue(), \$sibling->getLevel() - \$this->getLevel()" . ($this->behavior->useScope() ? ', $sibling->getScopeValue()' : '') . ", \$con); return \$this; } @@ -1552,7 +1555,7 @@ public function moveToNextSiblingOf($objectClassName \$sibling, ConnectionInterf throw new PropelException('Cannot move a node as sibling of one of its subtree nodes.'); } - \$this->moveSubtreeTo(\$sibling->getRightValue() + 1, \$sibling->getLevel() - \$this->getLevel()" . ($this->behavior->useScope() ? ", \$sibling->getScopeValue()" : "") . ", \$con); + \$this->moveSubtreeTo(\$sibling->getRightValue() + 1, \$sibling->getLevel() - \$this->getLevel()" . ($this->behavior->useScope() ? ', $sibling->getScopeValue()' : '') . ", \$con); return \$this; } @@ -1567,8 +1570,8 @@ public function moveToNextSiblingOf($objectClassName \$sibling, ConnectionInterf protected function addMoveSubtreeTo(&$script) { $queryClassName = $this->builder->getQueryClassName(); - $tableMapClass = $this->builder->getTableMapClass(); - $useScope = $this->behavior->useScope(); + $tableMapClass = $this->builder->getTableMapClass(); + $useScope = $this->behavior->useScope(); $script .= " /** @@ -1578,7 +1581,7 @@ protected function addMoveSubtreeTo(&$script) * @param int \$levelDelta Delta to add to the levels * @param ConnectionInterface \$con Connection to use. */ -protected function moveSubtreeTo(\$destLeft, \$levelDelta" . ($this->behavior->useScope() ? ", \$targetScope = null" : "") . ", ConnectionInterface \$con = null) +protected function moveSubtreeTo(\$destLeft, \$levelDelta" . ($this->behavior->useScope() ? ', $targetScope = null' : '') . ", ConnectionInterface \$con = null) { \$left = \$this->getLeftValue(); \$right = \$this->getRightValue();"; @@ -1600,11 +1603,11 @@ protected function moveSubtreeTo(\$destLeft, \$levelDelta" . ($this->behavior->u \$con = Propel::getServiceContainer()->getWriteConnection($tableMapClass::DATABASE_NAME); } - \$con->transaction(function () use (\$con, \$treeSize, \$destLeft, \$left, \$right, \$levelDelta" . ($useScope ? ", \$scope, \$targetScope" : "") . ") { + \$con->transaction(function () use (\$con, \$treeSize, \$destLeft, \$left, \$right, \$levelDelta" . ($useScope ? ', $scope, $targetScope' : '') . ") { \$preventDefault = false; // make room next to the target for the subtree - $queryClassName::shiftRLValues(\$treeSize, \$destLeft, null" . ($useScope ? ", \$targetScope" : "") . ", \$con); + $queryClassName::shiftRLValues(\$treeSize, \$destLeft, null" . ($useScope ? ', $targetScope' : '') . ", \$con); "; if ($useScope) { @@ -1638,17 +1641,17 @@ protected function moveSubtreeTo(\$destLeft, \$levelDelta" . ($this->behavior->u if (\$levelDelta) { // update the levels of the subtree - $queryClassName::shiftLevel(\$levelDelta, \$left, \$right" . ($useScope ? ", \$scope" : "") . ", \$con); + $queryClassName::shiftLevel(\$levelDelta, \$left, \$right" . ($useScope ? ', $scope' : '') . ", \$con); } // move the subtree to the target - $queryClassName::shiftRLValues(\$destLeft - \$left, \$left, \$right" . ($useScope ? ", \$scope" : "") . ", \$con); + $queryClassName::shiftRLValues(\$destLeft - \$left, \$left, \$right" . ($useScope ? ', $scope' : '') . ", \$con); } "; $script .= " // remove the empty room at the previous location of the subtree - $queryClassName::shiftRLValues(-\$treeSize, \$right + 1, null" . ($useScope ? ", \$scope" : "") . ", \$con); + $queryClassName::shiftRLValues(-\$treeSize, \$right + 1, null" . ($useScope ? ', $scope' : '') . ", \$con); // update all loaded nodes $queryClassName::updateLoadedNodes(null, \$con); @@ -1665,9 +1668,9 @@ protected function moveSubtreeTo(\$destLeft, \$levelDelta" . ($this->behavior->u protected function addDeleteDescendants(&$script) { $objectClassName = $this->builder->getObjectClassName(); - $queryClassName = $this->builder->getQueryClassName(); - $tableMapClass = $this->builder->getTableMapClass(); - $useScope = $this->behavior->useScope(); + $queryClassName = $this->builder->getQueryClassName(); + $tableMapClass = $this->builder->getTableMapClass(); + $useScope = $this->behavior->useScope(); $script .= " /** @@ -1696,14 +1699,14 @@ public function deleteDescendants(ConnectionInterface \$con = null) } $script .= " - return \$con->transaction(function () use (\$con, \$left, \$right" . ($useScope ? ", \$scope" : "") . ") { + return \$con->transaction(function () use (\$con, \$left, \$right" . ($useScope ? ', $scope' : '') . ") { // delete descendant nodes (will empty the instance pool) \$ret = $queryClassName::create() ->descendantsOf(\$this) ->delete(\$con); // fill up the room that was used by descendants - $queryClassName::shiftRLValues(\$left - \$right + 1, \$right, null" . ($useScope ? ", \$scope" : "") . ", \$con); + $queryClassName::shiftRLValues(\$left - \$right + 1, \$right, null" . ($useScope ? ', $scope' : '') . ", \$con); // fix the right value for the current node, which is now a leaf \$this->setRightValue(\$left + 1); @@ -1760,7 +1763,7 @@ public function objectAttributes(ObjectBuilder $builder) "; if ($this->behavior->useScope()) { - $script .= " + $script .= " /** * Scope column for the set */ diff --git a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifier.php index 409294bbb4..35f9e5e57f 100644 --- a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifier.php @@ -11,7 +11,6 @@ namespace Propel\Generator\Behavior\NestedSet; use Propel\Generator\Builder\Om\QueryBuilder; -use Propel\Generator\Model\Table; /** * Behavior to adds nested set tree structure columns and abilities @@ -21,17 +20,17 @@ class NestedSetBehaviorQueryBuilderModifier { /** - * @var NestedSetBehavior + * @var \Propel\Generator\Behavior\NestedSet\NestedSetBehavior */ protected $behavior; /** - * @var Table + * @var \Propel\Generator\Model\Table */ protected $table; /** - * @var QueryBuilder + * @var \Propel\Generator\Builder\Om\QueryBuilder */ protected $builder; @@ -86,9 +85,9 @@ protected function getColumn($name) */ protected function setBuilder(QueryBuilder $builder) { - $this->builder = $builder; - $this->objectClassName = $builder->getObjectClassName(); - $this->queryClassName = $builder->getQueryClassName(); + $this->builder = $builder; + $this->objectClassName = $builder->getObjectClassName(); + $this->queryClassName = $builder->getQueryClassName(); $this->tableMapClassName = $builder->getTableMapClassName(); } @@ -434,7 +433,7 @@ protected function addFindRoot(&$script) $useScope = $this->behavior->useScope(); $script .= " /** - * Returns " . ($useScope ? 'a' : 'the') ." root node for the tree + * Returns " . ($useScope ? 'a' : 'the') . " root node for the tree *"; if ($useScope) { $script .= " @@ -446,7 +445,7 @@ protected function addFindRoot(&$script) * * @return {$this->objectClassName} The tree root object */ -public function findRoot(" . ($useScope ? "\$scope = null, " : "") . "ConnectionInterface \$con = null) +public function findRoot(" . ($useScope ? '$scope = null, ' : '') . "ConnectionInterface \$con = null) { return \$this ->addUsingAlias({$this->objectClassName}::LEFT_COL, 1, Criteria::EQUAL)"; @@ -494,7 +493,7 @@ protected function addFindTree(&$script) $useScope = $this->behavior->useScope(); $script .= " /** - * Returns " . ($useScope ? 'a' : 'the') ." tree of objects + * Returns " . ($useScope ? 'a' : 'the') . " tree of objects *"; if ($useScope) { $script .= " @@ -506,7 +505,7 @@ protected function addFindTree(&$script) * * @return {$this->objectClassName}[]|ObjectCollection|mixed the list of results, formatted by the current formatter */ -public function findTree(" . ($useScope ? "\$scope = null, " : "") . "ConnectionInterface \$con = null) +public function findTree(" . ($useScope ? '$scope = null, ' : '') . "ConnectionInterface \$con = null) { return \$this"; if ($useScope) { @@ -527,8 +526,8 @@ public function findTree(" . ($useScope ? "\$scope = null, " : "") . "Connection */ protected function addRetrieveRoots(&$script) { - $queryClassName = $this->queryClassName; - $objectClassName = $this->objectClassName; + $queryClassName = $this->queryClassName; + $objectClassName = $this->objectClassName; $tableMapClassName = $this->builder->getTableMapClass(); $script .= " @@ -558,9 +557,9 @@ static public function retrieveRoots(Criteria \$criteria = null, ConnectionInter */ protected function addRetrieveRoot(&$script) { - $queryClassName = $this->queryClassName; - $objectClassName = $this->objectClassName; - $useScope = $this->behavior->useScope(); + $queryClassName = $this->queryClassName; + $objectClassName = $this->objectClassName; + $useScope = $this->behavior->useScope(); $tableMapClassName = $this->builder->getTableMapClass(); $script .= " @@ -575,7 +574,7 @@ protected function addRetrieveRoot(&$script) * @param ConnectionInterface \$con Connection to use. * @return {$this->objectClassName} Propel object for root node */ -static public function retrieveRoot(" . ($useScope ? "\$scope = null, " : "") . "ConnectionInterface \$con = null) +static public function retrieveRoot(" . ($useScope ? '$scope = null, ' : '') . "ConnectionInterface \$con = null) { \$c = new Criteria($tableMapClassName::DATABASE_NAME); \$c->add($objectClassName::LEFT_COL, 1, Criteria::EQUAL);"; @@ -597,9 +596,9 @@ static public function retrieveRoot(" . ($useScope ? "\$scope = null, " : "") . */ protected function addRetrieveTree(&$script) { - $queryClassName = $this->queryClassName; - $objectClassName = $this->objectClassName; - $useScope = $this->behavior->useScope(); + $queryClassName = $this->queryClassName; + $objectClassName = $this->objectClassName; + $useScope = $this->behavior->useScope(); $tableMapClassName = $this->builder->getTableMapClass(); $script .= " @@ -615,7 +614,7 @@ protected function addRetrieveTree(&$script) * @param ConnectionInterface \$con Connection to use. * @return {$this->objectClassName}[]|ObjectCollection|mixed the list of results, formatted by the current formatter */ -static public function retrieveTree(" . ($useScope ? "\$scope = null, " : "") . "Criteria \$criteria = null, ConnectionInterface \$con = null) +static public function retrieveTree(" . ($useScope ? '$scope = null, ' : '') . "Criteria \$criteria = null, ConnectionInterface \$con = null) { if (null === \$criteria) { \$criteria = new Criteria($tableMapClassName::DATABASE_NAME); @@ -666,8 +665,8 @@ static public function isValid($objectClassName \$node = null) */ protected function addDeleteTree(&$script) { - $objectClassName = $this->objectClassName; - $useScope = $this->behavior->useScope(); + $objectClassName = $this->objectClassName; + $useScope = $this->behavior->useScope(); $tableMapClassName = $this->builder->getTableMapClass(); $script .= " @@ -683,7 +682,7 @@ protected function addDeleteTree(&$script) * * @return int The number of deleted nodes */ -static public function deleteTree(" . ($useScope ? "\$scope = null, " : "") . "ConnectionInterface \$con = null) +static public function deleteTree(" . ($useScope ? '$scope = null, ' : '') . "ConnectionInterface \$con = null) {"; if ($useScope) { $script .= " @@ -708,8 +707,8 @@ static public function deleteTree(" . ($useScope ? "\$scope = null, " : "") . "C */ protected function addShiftRLValues(&$script) { - $objectClassName = $this->objectClassName; - $useScope = $this->behavior->useScope(); + $objectClassName = $this->objectClassName; + $useScope = $this->behavior->useScope(); $tableMapClassName = $this->builder->getTableMapClass(); $this->builder->declareClass('Propel\\Runtime\Map\\TableMap'); @@ -729,7 +728,7 @@ protected function addShiftRLValues(&$script) $script .= " * @param ConnectionInterface \$con Connection to use. */ -static public function shiftRLValues(\$delta, \$first, \$last = null" . ($useScope ? ", \$scope = null" : ""). ", ConnectionInterface \$con = null) +static public function shiftRLValues(\$delta, \$first, \$last = null" . ($useScope ? ', $scope = null' : '') . ", ConnectionInterface \$con = null) { if (\$con === null) { \$con = Propel::getServiceContainer()->getWriteConnection($tableMapClassName::DATABASE_NAME); @@ -781,8 +780,8 @@ static public function shiftRLValues(\$delta, \$first, \$last = null" . ($useSco */ protected function addShiftLevel(&$script) { - $objectClassName = $this->objectClassName; - $useScope = $this->behavior->useScope(); + $objectClassName = $this->objectClassName; + $useScope = $this->behavior->useScope(); $tableMapClassName = $this->builder->getTableMapClass(); $this->builder->declareClass('Propel\\Runtime\Map\\TableMap'); @@ -802,7 +801,7 @@ protected function addShiftLevel(&$script) $script .= " * @param ConnectionInterface \$con Connection to use. */ -static public function shiftLevel(\$delta, \$first, \$last" . ($useScope ? ", \$scope = null" : ""). ", ConnectionInterface \$con = null) +static public function shiftLevel(\$delta, \$first, \$last" . ($useScope ? ', $scope = null' : '') . ", ConnectionInterface \$con = null) { if (\$con === null) { \$con = Propel::getServiceContainer()->getWriteConnection($tableMapClassName::DATABASE_NAME); @@ -832,7 +831,7 @@ static public function shiftLevel(\$delta, \$first, \$last" . ($useScope ? ", \$ */ protected function addUpdateLoadedNodes(&$script) { - $queryClassName = $this->queryClassName; + $queryClassName = $this->queryClassName; $objectClassName = $this->objectClassName; $tableMapClassName = $this->tableMapClassName; @@ -858,22 +857,22 @@ static public function updateLoadedNodes(\$prune = null, ConnectionInterface \$c // We don't need to alter the object instance pool; we're just modifying these ones // already in the pool. \$criteria = new Criteria($tableMapClassName::DATABASE_NAME);"; - if (1 === count($this->table->getPrimaryKey())) { + if (count($this->table->getPrimaryKey()) === 1) { $pkey = $this->table->getPrimaryKey(); $col = array_shift($pkey); $script .= " - \$criteria->add(".$this->builder->getColumnConstant($col).", \$keys, Criteria::IN);"; + \$criteria->add(" . $this->builder->getColumnConstant($col) . ', $keys, Criteria::IN);'; } else { $fields = []; foreach ($this->table->getPrimaryKey() as $k => $col) { $fields[] = $this->builder->getColumnConstant($col); - }; + } $script .= " // Loop on each instances in pool foreach (\$keys as \$values) { // Create initial Criterion - \$cton = \$criteria->getNewCriterion(" . $fields[0] . ", \$values[0]);"; + \$cton = \$criteria->getNewCriterion(" . $fields[0] . ', $values[0]);'; unset($fields[0]); foreach ($fields as $k => $col) { $script .= " @@ -935,7 +934,7 @@ static public function updateLoadedNodes(\$prune = null, ConnectionInterface \$c protected function addMakeRoomForLeaf(&$script) { $queryClassName = $this->queryClassName; - $useScope = $this->behavior->useScope(); + $useScope = $this->behavior->useScope(); $script .= " /** @@ -950,10 +949,10 @@ protected function addMakeRoomForLeaf(&$script) * @param mixed \$prune Object to prune from the shift * @param ConnectionInterface \$con Connection to use. */ -static public function makeRoomForLeaf(\$left" . ($useScope ? ", \$scope" : ""). ", \$prune = null, ConnectionInterface \$con = null) +static public function makeRoomForLeaf(\$left" . ($useScope ? ', $scope' : '') . ", \$prune = null, ConnectionInterface \$con = null) { // Update database nodes - $queryClassName::shiftRLValues(2, \$left, null" . ($useScope ? ", \$scope" : "") . ", \$con); + $queryClassName::shiftRLValues(2, \$left, null" . ($useScope ? ', $scope' : '') . ", \$con); // Update all loaded nodes $queryClassName::updateLoadedNodes(\$prune, \$con); @@ -968,10 +967,10 @@ static public function makeRoomForLeaf(\$left" . ($useScope ? ", \$scope" : ""). */ protected function addFixLevels(&$script) { - $objectClassName = $this->objectClassName; - $queryClassName = $this->queryClassName; + $objectClassName = $this->objectClassName; + $queryClassName = $this->queryClassName; $tableMapClassName = $this->tableMapClassName; - $useScope = $this->behavior->useScope(); + $useScope = $this->behavior->useScope(); $script .= " /** @@ -984,7 +983,7 @@ protected function addFixLevels(&$script) $script .= " * @param ConnectionInterface \$con Connection to use. */ -static public function fixLevels(" . ($useScope ? "\$scope, " : ""). "ConnectionInterface \$con = null) +static public function fixLevels(" . ($useScope ? '$scope, ' : '') . "ConnectionInterface \$con = null) { \$c = new Criteria();"; if ($useScope) { @@ -1060,7 +1059,7 @@ static public function fixLevels(" . ($useScope ? "\$scope, " : ""). "Connection */ protected function addSetNegativeScope(&$script) { - $objectClassName = $this->objectClassName; + $objectClassName = $this->objectClassName; $tableMapClassName = $this->tableMapClassName; $script .= " /** diff --git a/src/Propel/Generator/Behavior/QueryCache/QueryCacheBehavior.php b/src/Propel/Generator/Behavior/QueryCache/QueryCacheBehavior.php index 0148798094..72e31062dd 100644 --- a/src/Propel/Generator/Behavior/QueryCache/QueryCacheBehavior.php +++ b/src/Propel/Generator/Behavior/QueryCache/QueryCacheBehavior.php @@ -21,8 +21,8 @@ class QueryCacheBehavior extends Behavior { // default parameters value protected $parameters = [ - 'backend' => 'apc', - 'lifetime' => 3600, + 'backend' => 'apc', + 'lifetime' => 3600, ]; /** @@ -43,6 +43,7 @@ public function queryAttributes($builder) case 'backend': $script .= "protected static \$cacheBackend = array(); "; + break; case 'apc': break; @@ -50,6 +51,7 @@ public function queryAttributes($builder) default: $script .= "protected static \$cacheBackend; "; + break; } @@ -124,18 +126,20 @@ public function cacheContains(\$key) $script .= " return apc_fetch(\$key);"; + break; case 'array': $script .= " return isset(self::\$cacheBackend[\$key]);"; + break; case 'custom': default: $script .= " throw new PropelException('You must override the cacheContains(), cacheStore(), and cacheFetch() methods to enable query cache');"; - break; + break; } $script .= " } @@ -150,21 +154,24 @@ public function cacheContains(\$key) protected function addCacheStore(&$script) { $script .= " -public function cacheStore(\$key, \$value, \$lifetime = " .$this->getParameter('lifetime') . ") +public function cacheStore(\$key, \$value, \$lifetime = " . $this->getParameter('lifetime') . ") {"; switch ($this->getParameter('backend')) { case 'apc': $script .= " apc_store(\$key, \$value, \$lifetime);"; + break; case 'array': $script .= " self::\$cacheBackend[\$key] = \$value;"; + break; case 'custom': default: $script .= " throw new PropelException('You must override the cacheContains(), cacheStore(), and cacheFetch() methods to enable query cache');"; + break; } $script .= " @@ -187,16 +194,19 @@ public function cacheFetch(\$key) $script .= " return apc_fetch(\$key);"; + break; case 'array': $script .= " return isset(self::\$cacheBackend[\$key]) ? self::\$cacheBackend[\$key] : null;"; + break; case 'custom': default: $script .= " throw new PropelException('You must override the cacheContains(), cacheStore(), and cacheFetch() methods to enable query cache');"; + break; } $script .= " @@ -220,8 +230,8 @@ public function doSelect(ConnectionInterface \$con = null) } \$this->configureSelectColumns(); - \$dbMap = Propel::getServiceContainer()->getDatabaseMap(" . $this->tableClassName ."::DATABASE_NAME); - \$db = Propel::getServiceContainer()->getAdapter(" . $this->tableClassName ."::DATABASE_NAME); + \$dbMap = Propel::getServiceContainer()->getDatabaseMap(" . $this->tableClassName . "::DATABASE_NAME); + \$db = Propel::getServiceContainer()->getAdapter(" . $this->tableClassName . "::DATABASE_NAME); \$key = \$this->getQueryKey(); if (\$key && \$this->cacheContains(\$key)) { diff --git a/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php b/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php index e442b9c9ea..ecde93fb5a 100644 --- a/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php +++ b/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php @@ -10,7 +10,6 @@ namespace Propel\Generator\Behavior\Sluggable; -use Propel\Generator\Builder\Om\ObjectBuilder; use Propel\Generator\Model\Behavior; use Propel\Generator\Model\Table; use Propel\Generator\Model\Unique; @@ -32,13 +31,13 @@ class SluggableBehavior extends Behavior * @var array */ protected $parameters = [ - 'slug_column' => 'slug', - 'slug_pattern' => '', + 'slug_column' => 'slug', + 'slug_pattern' => '', 'replace_pattern' => '/\W+/', - 'replacement' => '-', - 'separator' => '-', - 'permanent' => 'false', - 'scope_column' => '', + 'replacement' => '-', + 'separator' => '-', + 'permanent' => 'false', + 'scope_column' => '', 'unique_constraint' => 'true', ]; @@ -53,13 +52,13 @@ public function modifyTable() if (!$table->hasColumn($this->getParameter('slug_column'))) { $table->addColumn([ - 'name' => $this->getParameter('slug_column'), - 'type' => 'VARCHAR', - 'size' => 255, + 'name' => $this->getParameter('slug_column'), + 'type' => 'VARCHAR', + 'size' => 255, 'required' => false, ]); // add a unique to column - if ('true' === $this->getParameter('unique_constraint')) { + if ($this->getParameter('unique_constraint') === 'true') { $this->addUniqueConstraint($table); } } @@ -68,7 +67,8 @@ public function modifyTable() /** * Adds a unique constraint to the table to enforce uniqueness of the slug_column * - * @param Table $table + * @param \Propel\Generator\Model\Table $table + * * @return void */ protected function addUniqueConstraint(Table $table) @@ -115,7 +115,7 @@ public function preSave($builder) $script = " if (\$this->isColumnModified($const) && \$this->{$this->getColumnGetter()}()) { \$this->{$this->getColumnSetter()}(\$this->makeSlugUnique(\$this->{$this->getColumnGetter()}()));"; - if ('true' === $this->getParameter('permanent')) { + if ($this->getParameter('permanent') === 'true') { $script .= " } elseif (!\$this->{$this->getColumnGetter()}()) { \$this->{$this->getColumnSetter()}(\$this->createSlug()); @@ -139,7 +139,7 @@ public function objectMethods($builder) { $this->builder = $builder; $script = ''; - if ('slug' !== $this->getParameter('slug_column')) { + if ($this->getParameter('slug_column') !== 'slug') { $this->addSlugSetter($script); $this->addSlugGetter($script); } @@ -235,9 +235,9 @@ protected function createRawSlug() { "; if ($pattern) { - $script .= "return '" . str_replace(['{', '}'], ['\' . $this->cleanupSlugPart($this->get', '()) . \''], $pattern). "';"; + $script .= "return '" . str_replace(['{', '}'], ['\' . $this->cleanupSlugPart($this->get', '()) . \''], $pattern) . "';"; } else { - $script .= "return \$this->cleanupSlugPart(\$this->__toString());"; + $script .= 'return $this->cleanupSlugPart($this->__toString());'; } $script .= " } @@ -347,7 +347,7 @@ protected function makeSlugUnique(\$slug, \$separator = '" . $this->getParameter } else { \$slug2 = \$slug . \$separator;"; - if (null == $this->getParameter('slug_pattern')) { + if ($this->getParameter('slug_pattern') == null) { $script .= " \$count = " . $this->builder->getStubQueryBuilder()->getClassname() . "::create() diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php b/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php index 697103f259..555b9c2b2d 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php @@ -10,6 +10,7 @@ namespace Propel\Generator\Behavior\Sortable; +use InvalidArgumentException; use Propel\Generator\Model\Behavior; /** @@ -17,23 +18,28 @@ * Uses one additional column storing the rank * * @author Massimiliano Arione - * @version $Revision$ + * @version $Revision$ */ class SortableBehavior extends Behavior { // default parameters value protected $parameters = [ - 'rank_column' => 'sortable_rank', - 'use_scope' => 'false', + 'rank_column' => 'sortable_rank', + 'use_scope' => 'false', 'scope_column' => '', ]; protected $objectBuilderModifier; + protected $queryBuilderModifier; + protected $tableMapBuilderModifier; /** * Add the rank_column to the current table + * + * @throws \InvalidArgumentException + * * @return void */ public function modifyTable() @@ -43,7 +49,7 @@ public function modifyTable() if (!$table->hasColumn($this->getParameter('rank_column'))) { $table->addColumn([ 'name' => $this->getParameter('rank_column'), - 'type' => 'INTEGER' + 'type' => 'INTEGER', ]); } @@ -51,13 +57,13 @@ public function modifyTable() if (!$this->hasMultipleScopes() && !$table->hasColumn($this->getParameter('scope_column'))) { $table->addColumn([ 'name' => $this->getParameter('scope_column'), - 'type' => 'INTEGER' + 'type' => 'INTEGER', ]); } $scopes = $this->getScopes(); - if (0 === count($scopes)) { - throw new \InvalidArgumentException(sprintf( + if (count($scopes) === 0) { + throw new InvalidArgumentException(sprintf( 'The sortable behavior in `%s` needs a `scope_column` parameter.', $this->getTable()->getName() )); @@ -66,11 +72,11 @@ public function modifyTable() } /** - * @return \Propel\Generator\Behavior\Sortable\SortableBehavior|\Propel\Generator\Behavior\Sortable\SortableBehaviorObjectBuilderModifier + * @return $this|\Propel\Generator\Behavior\Sortable\SortableBehaviorObjectBuilderModifier */ public function getObjectBuilderModifier() { - if (null === $this->objectBuilderModifier) { + if ($this->objectBuilderModifier === null) { $this->objectBuilderModifier = new SortableBehaviorObjectBuilderModifier($this); } @@ -78,11 +84,11 @@ public function getObjectBuilderModifier() } /** - * @return \Propel\Generator\Behavior\Sortable\SortableBehavior|\Propel\Generator\Behavior\Sortable\SortableBehaviorQueryBuilderModifier + * @return $this|\Propel\Generator\Behavior\Sortable\SortableBehaviorQueryBuilderModifier */ public function getQueryBuilderModifier() { - if (null === $this->queryBuilderModifier) { + if ($this->queryBuilderModifier === null) { $this->queryBuilderModifier = new SortableBehaviorQueryBuilderModifier($this); } @@ -90,11 +96,11 @@ public function getQueryBuilderModifier() } /** - * @return \Propel\Generator\Behavior\Sortable\SortableBehavior|\Propel\Generator\Behavior\Sortable\SortableBehaviorTableMapBuilderModifier + * @return $this|\Propel\Generator\Behavior\Sortable\SortableBehaviorTableMapBuilderModifier */ public function getTableMapBuilderModifier() { - if (null === $this->tableMapBuilderModifier) { + if ($this->tableMapBuilderModifier === null) { $this->tableMapBuilderModifier = new SortableBehaviorTableMapBuilderModifier($this); } @@ -106,7 +112,7 @@ public function getTableMapBuilderModifier() */ public function useScope() { - return 'true' === $this->getParameter('use_scope'); + return $this->getParameter('use_scope') === 'true'; } /** @@ -118,25 +124,23 @@ public function useScope() public function generateScopePhp() { $methodSignature = ''; - $paramsDoc = ''; - $buildScope = ''; - $buildScopeVars = ''; + $paramsDoc = ''; + $buildScope = ''; + $buildScopeVars = ''; if ($this->hasMultipleScopes()) { - $methodSignature = []; - $buildScope = []; - $buildScopeVars = []; - $paramsDoc = []; + $buildScope = []; + $buildScopeVars = []; + $paramsDoc = []; foreach ($this->getScopes() as $idx => $scope) { - $column = $this->table->getColumn($scope); - $param = '$scope'.$column->getPhpName(); + $param = '$scope' . $column->getPhpName(); - $buildScope[] = " \$scope[] = $param;\n"; + $buildScope[] = " \$scope[] = $param;\n"; $buildScopeVars[] = " $param = \$scope[$idx];\n"; - $paramsDoc[] = " * @param ".$column->getPhpType()." $param Scope value for column `".$column->getPhpName()."`"; + $paramsDoc[] = ' * @param ' . $column->getPhpType() . " $param Scope value for column `" . $column->getPhpName() . '`'; if (!$column->isNotNull()) { $param .= ' = null'; @@ -145,10 +149,9 @@ public function generateScopePhp() } $methodSignature = implode(', ', $methodSignature); - $paramsDoc = implode("\n", $paramsDoc); - $buildScope = "\n".implode('', $buildScope)."\n"; - $buildScopeVars = "\n".implode('', $buildScopeVars)."\n"; - + $paramsDoc = implode("\n", $paramsDoc); + $buildScope = "\n" . implode('', $buildScope) . "\n"; + $buildScopeVars = "\n" . implode('', $buildScopeVars) . "\n"; } elseif ($this->useScope()) { $methodSignature = '$scope'; $column = $this->table->getColumn($this->getParameter('scope_column')); @@ -156,7 +159,7 @@ public function generateScopePhp() if (!$column->isNotNull()) { $methodSignature .= ' = null'; } - $paramsDoc .= ' * @param '.$column->getPhpType().' $scope Scope to determine which objects node to return'; + $paramsDoc .= ' * @param ' . $column->getPhpType() . ' $scope Scope to determine which objects node to return'; } } @@ -166,7 +169,8 @@ public function generateScopePhp() /** * Returns the getter method name. * - * @param string $name + * @param string $name + * * @return string */ public function getColumnGetter($name) @@ -177,7 +181,8 @@ public function getColumnGetter($name) /** * Returns the setter method name. * - * @param string $name + * @param string $name + * * @return string */ public function getColumnSetter($name) @@ -186,11 +191,11 @@ public function getColumnSetter($name) } /** - * @inheritdoc + * @inheritDoc */ public function addParameter(array $parameter) { - if ('scope_column' === $parameter['name']) { + if ($parameter['name'] === 'scope_column') { $this->parameters['scope_column'] .= ($this->parameters['scope_column'] ? ',' : '') . $parameter['value']; } else { parent::addParameter($parameter); diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php index 1ea5c740d1..92be4fabbc 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php @@ -12,7 +12,6 @@ use Propel\Generator\Builder\Om\AbstractOMBuilder; use Propel\Generator\Model\Column; -use Propel\Generator\Model\Table; /** * Behavior to add sortable columns and abilities @@ -141,7 +140,7 @@ protected function getColumnSetter($columnName = 'rank_column') */ public function preSave($builder) { - return "\$this->processSortableQueries(\$con);"; + return '$this->processSortableQueries($con);'; } /** @@ -155,7 +154,7 @@ public function preInsert($builder) $this->setBuilder($builder); return "if (!\$this->isColumnModified({$this->tableMapClassName}::RANK_COL)) { - \$this->{$this->getColumnSetter()}({$this->queryClassName}::create()->getMaxRankArray(" . ($useScope ? "\$this->getScopeValue(), " : '') . "\$con) + 1); + \$this->{$this->getColumnSetter()}({$this->queryClassName}::create()->getMaxRankArray(" . ($useScope ? '$this->getScopeValue(), ' : '') . "\$con) + 1); } "; } @@ -173,7 +172,7 @@ public function preUpdate($builder) $condition = []; foreach ($this->behavior->getScopes() as $scope) { - $condition[] = "\$this->isColumnModified({$this->tableMapClassName}::".Column::CONSTANT_PREFIX.strtoupper($scope).")"; + $condition[] = "\$this->isColumnModified({$this->tableMapClassName}::" . Column::CONSTANT_PREFIX . strtoupper($scope) . ')'; } $condition = implode(' OR ', $condition); @@ -202,7 +201,7 @@ public function preDelete($builder) $this->setBuilder($builder); return " -{$this->queryClassName}::sortableShiftRank(-1, \$this->{$this->getColumnGetter()}() + 1, null, ". ($useScope ? "\$this->getScopeValue(), " : '') . "\$con); +{$this->queryClassName}::sortableShiftRank(-1, \$this->{$this->getColumnGetter()}() + 1, null, " . ($useScope ? '$this->getScopeValue(), ' : '') . "\$con); {$this->tableMapClassName}::clearInstancePool(); "; } @@ -243,11 +242,13 @@ public function objectMethods($builder) { $this->setBuilder($builder); $script = ''; - if ('rank' !== $this->getParameter('rank_column')) { + if ($this->getParameter('rank_column') !== 'rank') { $this->addRankAccessors($script); } - if ($this->behavior->useScope() - && 'scope_value' !== $this->getParameter('scope_column')) { + if ( + $this->behavior->useScope() + && $this->getParameter('scope_column') !== 'scope_value' + ) { $this->addScopeAccessors($script); } $this->addIsFirst($script); @@ -279,7 +280,6 @@ public function objectFilter(&$script, $builder) { if ($this->behavior->useScope()) { if ($this->behavior->hasMultipleScopes()) { - foreach ($this->behavior->getScopes() as $idx => $scope) { $name = strtolower($this->behavior->getTable()->getColumn($scope)->getName()); @@ -290,7 +290,6 @@ public function objectFilter(&$script, $builder) "; $script = str_replace($search, $replace, $script); } - } else { $scope = current($this->behavior->getScopes()); $name = strtolower($this->behavior->getTable()->getColumn($scope)->getName()); @@ -347,7 +346,6 @@ public function setRank(\$v) */ protected function addScopeAccessors(&$script) { - $script .= " /** * Wrap the getter for scope value @@ -368,19 +366,18 @@ public function getScopeValue(\$returnNulls = true) $script .= " \$onlyNulls &= null === (\$result[] = \$this->{$this->behavior->getColumnGetter($scopeField)}()); "; - } $script .= " return \$onlyNulls && \$returnNulls ? null : \$result; "; - } else if ($this->behavior->getColumnForParameter('scope_column')->isEnumType()){ + } elseif ($this->behavior->getColumnForParameter('scope_column')->isEnumType()) { $columnConstant = strtoupper(preg_replace('/[^a-zA-Z0-9_\x7f-\xff]/', '_', $this->getColumnAttribute('scope_column'))); $script .= " return array_search(\$this->{$this->getColumnGetter('scope_column')}(), {$this->tableMapClassName}::getValueSet({$this->tableMapClassName}::COL_{$columnConstant})); "; - } else if ($this->behavior->getColumnForParameter('scope_column')->isSetType()){ + } elseif ($this->behavior->getColumnForParameter('scope_column')->isSetType()) { $columnConstant = strtoupper(preg_replace('/[^a-zA-Z0-9_\x7f-\xff]/', '_', $this->getColumnAttribute('scope_column'))); $script .= " try { @@ -390,7 +387,6 @@ public function getScopeValue(\$returnNulls = true) } "; } else { - $script .= " return \$this->{$this->getColumnGetter('scope_column')}(); @@ -411,19 +407,16 @@ public function setScopeValue(\$v) "; if ($this->behavior->hasMultipleScopes()) { - foreach ($this->behavior->getScopes() as $idx => $scopeField) { $script .= " \$this->{$this->behavior->getColumnSetter($scopeField)}(\$v === null ? null : \$v[$idx]); "; } - } else { $script .= " return \$this->{$this->getColumnSetter('scope_column')}(\$v); "; - } $script .= " } @@ -468,7 +461,7 @@ protected function addIsLast(&$script) */ public function isLast(ConnectionInterface \$con = null) { - return \$this->{$this->getColumnGetter()}() == {$this->queryClassName}::create()->getMaxRankArray(" . ($useScope ? "\$this->getScopeValue(), " : '') . "\$con); + return \$this->{$this->getColumnGetter()}() == {$this->queryClassName}::create()->getMaxRankArray(" . ($useScope ? '$this->getScopeValue(), ' : '') . "\$con); } "; } @@ -509,7 +502,6 @@ public function getNext(ConnectionInterface \$con = null) \$query->filterByRank(\$this->{$this->getColumnGetter()}() + 1, $methodSignature); "; } else { - $script .= " \$query->filterByRank(\$this->{$this->getColumnGetter()}() + 1); "; @@ -559,7 +551,6 @@ public function getPrevious(ConnectionInterface \$con = null) \$query->filterByRank(\$this->{$this->getColumnGetter()}() - 1, $methodSignature); "; } else { - $script .= " \$query->filterByRank(\$this->{$this->getColumnGetter()}() - 1); "; @@ -596,7 +587,7 @@ protected function addInsertAtRank(&$script) public function insertAtRank(\$rank, ConnectionInterface \$con = null) {"; $script .= " - \$maxRank = {$this->queryClassName}::create()->getMaxRankArray(" . ($useScope ? "\$this->getScopeValue(), " : '') . "\$con); + \$maxRank = {$this->queryClassName}::create()->getMaxRankArray(" . ($useScope ? '$this->getScopeValue(), ' : '') . "\$con); if (\$rank < 1 || \$rank > \$maxRank + 1) { throw new PropelException('Invalid rank ' . \$rank); } @@ -606,7 +597,7 @@ public function insertAtRank(\$rank, ConnectionInterface \$con = null) // Keep the list modification query for the save() transaction \$this->sortableQueries []= array( 'callable' => array('{$queryClassName}', 'sortableShiftRank'), - 'arguments' => array(1, \$rank, null, " . ($useScope ? "\$this->getScopeValue()" : '') . ") + 'arguments' => array(1, \$rank, null, " . ($useScope ? '$this->getScopeValue()' : '') . ") ); } @@ -637,7 +628,7 @@ protected function addInsertAtBottom(&$script) public function insertAtBottom(ConnectionInterface \$con = null) {"; $script .= " - \$this->{$this->getColumnSetter()}({$this->queryClassName}::create()->getMaxRankArray(" . ($useScope ? "\$this->getScopeValue(), " : '') . "\$con) + 1); + \$this->{$this->getColumnSetter()}({$this->queryClassName}::create()->getMaxRankArray(" . ($useScope ? '$this->getScopeValue(), ' : '') . "\$con) + 1); return \$this; } @@ -693,7 +684,7 @@ public function moveToRank(\$newRank, ConnectionInterface \$con = null) if (null === \$con) { \$con = Propel::getServiceContainer()->getWriteConnection({$this->tableMapClassName}::DATABASE_NAME); } - if (\$newRank < 1 || \$newRank > {$this->queryClassName}::create()->getMaxRankArray(" . ($useScope ? "\$this->getScopeValue(), " : '') . "\$con)) { + if (\$newRank < 1 || \$newRank > {$this->queryClassName}::create()->getMaxRankArray(" . ($useScope ? '$this->getScopeValue(), ' : '') . "\$con)) { throw new PropelException('Invalid rank ' . \$newRank); } @@ -705,7 +696,7 @@ public function moveToRank(\$newRank, ConnectionInterface \$con = null) \$con->transaction(function () use (\$con, \$oldRank, \$newRank) { // shift the objects between the old and the new rank \$delta = (\$oldRank < \$newRank) ? -1 : 1; - {$this->queryClassName}::sortableShiftRank(\$delta, min(\$oldRank, \$newRank), max(\$oldRank, \$newRank), " . ($useScope ? "\$this->getScopeValue(), " : '') . "\$con); + {$this->queryClassName}::sortableShiftRank(\$delta, min(\$oldRank, \$newRank), max(\$oldRank, \$newRank), " . ($useScope ? '$this->getScopeValue(), ' : '') . "\$con); // move the object to its new rank \$this->{$this->getColumnSetter()}(\$newRank); @@ -885,7 +876,7 @@ public function moveToBottom(ConnectionInterface \$con = null) } return \$con->transaction(function () use (\$con) { - \$bottom = {$this->queryClassName}::create()->getMaxRankArray(" . ($useScope ? "\$this->getScopeValue(), " : '') . "\$con); + \$bottom = {$this->queryClassName}::create()->getMaxRankArray(" . ($useScope ? '$this->getScopeValue(), ' : '') . "\$con); return \$this->moveToRank(\$bottom, \$con); }); @@ -903,7 +894,7 @@ protected function addRemoveFromList(&$script) $useScope = $this->behavior->useScope(); $script .= " /** - * Removes the current object from the list".($useScope ? ' (moves it to the null scope)' : '').". + * Removes the current object from the list" . ($useScope ? ' (moves it to the null scope)' : '') . ". * The modifications are not persisted until the object is saved. * * @return \$this|{$this->objectClassName} the current object @@ -925,7 +916,7 @@ public function removeFromList() // Keep the list modification query for the save() transaction \$this->sortableQueries[] = array( 'callable' => array('{$this->queryFullClassName}', 'sortableShiftRank'), - 'arguments' => array(-1, \$this->{$this->getColumnGetter()}() + 1, null" . ($useScope ? ", \$this->getScopeValue()" : '') . ") + 'arguments' => array(-1, \$this->{$this->getColumnGetter()}() + 1, null" . ($useScope ? ', $this->getScopeValue()' : '') . ") ); // remove the object from the list \$this->{$this->getColumnSetter('rank_column')}(null); diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php index bd9fadd962..118b535f38 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php @@ -109,14 +109,16 @@ public function queryMethods($builder) if ($this->behavior->useScope()) { $this->addInList($script); } - if ('rank' !== $this->getParameter('rank_column')) { + if ($this->getParameter('rank_column') !== 'rank') { $this->addFilterByRank($script); $this->addOrderByRank($script); } // select termination methods - if ('rank' !== $this->getParameter('rank_column') - || $this->behavior->useScope()) { + if ( + $this->getParameter('rank_column') !== 'rank' + || $this->behavior->useScope() + ) { $this->addFindOneByRank($script); } $this->addFindList($script); @@ -160,12 +162,12 @@ static public function sortableApplyScopeCriteria(Criteria \$criteria, \$scope, if ($this->behavior->hasMultipleScopes()) { foreach ($this->behavior->getScopes() as $idx => $scope) { $script .= " - \$criteria->\$method({$this->tableMapClassName}::".Column::CONSTANT_PREFIX.strtoupper($scope).", \$scope[$idx], Criteria::EQUAL); + \$criteria->\$method({$this->tableMapClassName}::" . Column::CONSTANT_PREFIX . strtoupper($scope) . ", \$scope[$idx], Criteria::EQUAL); "; } } else { $script .= " - \$criteria->\$method({$this->tableMapClassName}::".Column::CONSTANT_PREFIX.strtoupper(current($this->behavior->getScopes())).", \$scope, Criteria::EQUAL); + \$criteria->\$method({$this->tableMapClassName}::" . Column::CONSTANT_PREFIX . strtoupper(current($this->behavior->getScopes())) . ", \$scope, Criteria::EQUAL); "; } @@ -226,7 +228,7 @@ protected function addFilterByRank(&$script) * * @return " . $this->queryClassName . " The current query, for fluid interface */ -public function filterByRank(\$rank" . ($useScope ? ", $methodSignature" : "") . ") +public function filterByRank(\$rank" . ($useScope ? ", $methodSignature" : '') . ") {"; if ($useScope) { @@ -288,7 +290,7 @@ protected function addFindOneByRank(&$script) { $useScope = $this->behavior->useScope(); if ($useScope) { - [$methodSignature, $paramsDoc, ] = $this->behavior->generateScopePhp(); + [$methodSignature, $paramsDoc] = $this->behavior->generateScopePhp(); } $script .= " @@ -305,7 +307,7 @@ protected function addFindOneByRank(&$script) * * @return {$this->objectClassName} */ -public function findOneByRank(\$rank, " . ($useScope ? "$methodSignature, " : "") . "ConnectionInterface \$con = null) +public function findOneByRank(\$rank, " . ($useScope ? "$methodSignature, " : '') . "ConnectionInterface \$con = null) {"; if ($useScope) { $methodSignature = str_replace(' = null', '', $methodSignature); @@ -314,7 +316,7 @@ public function findOneByRank(\$rank, " . ($useScope ? "$methodSignature, " : "" $script .= " return \$this - ->filterByRank(\$rank" . ($useScope ? ", $methodSignature" : "") . ") + ->filterByRank(\$rank" . ($useScope ? ", $methodSignature" : '') . ") ->findOne(\$con); } "; @@ -334,7 +336,7 @@ protected function addFindList(&$script) $script .= " /** - * Returns " . ($useScope ? 'a' : 'the') ." list of objects + * Returns " . ($useScope ? 'a' : 'the') . " list of objects *"; if ($useScope) { $script .= " @@ -347,7 +349,7 @@ protected function addFindList(&$script) * * @return mixed the list of results, formatted by the current formatter */ -public function findList(" . ($useScope ? "$methodSignature, " : "") . "\$con = null) +public function findList(" . ($useScope ? "$methodSignature, " : '') . "\$con = null) {"; if ($useScope) { @@ -394,7 +396,7 @@ protected function addGetMaxRank(&$script) * * @return integer highest position */ -public function getMaxRank(" . ($useScope ? "$methodSignature, " : "") . "ConnectionInterface \$con = null) +public function getMaxRank(" . ($useScope ? "$methodSignature, " : '') . "ConnectionInterface \$con = null) { if (null === \$con) { \$con = Propel::getServiceContainer()->getReadConnection({$this->tableMapClassName}::DATABASE_NAME); @@ -437,7 +439,7 @@ protected function addGetMaxRankArray(&$script) * * @return integer highest position */ -public function getMaxRankArray(" . ($useScope ? "\$scope, " : "") . "ConnectionInterface \$con = null) +public function getMaxRankArray(" . ($useScope ? '$scope, ' : '') . "ConnectionInterface \$con = null) { if (\$con === null) { \$con = Propel::getConnection({$this->tableMapClassName}::DATABASE_NAME); @@ -521,7 +523,7 @@ protected function addRetrieveByRank(&$script) * * @return {$this->objectClassName} */ -static public function retrieveByRank(\$rank, " . ($useScope ? "\$scope = null, " : "") . "ConnectionInterface \$con = null) +static public function retrieveByRank(\$rank, " . ($useScope ? '$scope = null, ' : '') . "ConnectionInterface \$con = null) { if (null === \$con) { \$con = Propel::getServiceContainer()->getReadConnection({$this->tableMapClassName}::DATABASE_NAME); @@ -685,7 +687,7 @@ protected function addShiftRank(&$script) $script .= " * @param ConnectionInterface \$con Connection to use. */ -static public function sortableShiftRank(\$delta, \$first, \$last = null, " . ($useScope ? "\$scope = null, " : "") . "ConnectionInterface \$con = null) +static public function sortableShiftRank(\$delta, \$first, \$last = null, " . ($useScope ? '$scope = null, ' : '') . "ConnectionInterface \$con = null) { if (null === \$con) { \$con = Propel::getServiceContainer()->getWriteConnection({$this->tableMapClassName}::DATABASE_NAME); diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php index d528942220..6af5f1a7f2 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehaviorTableMapBuilderModifier.php @@ -47,26 +47,25 @@ public function staticAttributes($builder) $col = ''; if ($this->behavior->useScope()) { - if ($this->behavior->hasMultipleScopes()) { $columns = []; foreach ($this->behavior->getScopes() as $scope) { - $columns[] = "$tableName.".strtoupper($scope); + $columns[] = "$tableName." . strtoupper($scope); } $col = json_encode($columns); $col = "'$col'"; } else { $colNames = $this->getColumnConstant('scope_column'); - $col = "'$tableName.$colNames'"; + $col = "'$tableName.$colNames'"; } } return $this->behavior->renderTemplate('tableMapSortable', [ 'rankColumn' => $this->getColumnConstant('rank_column'), 'multiScope' => $this->behavior->hasMultipleScopes(), - 'scope' => $col, - 'tableName' => $this->table->getName(), - 'useScope' => $this->behavior->useScope(), + 'scope' => $col, + 'tableName' => $this->table->getName(), + 'useScope' => $this->behavior->useScope(), ]); } @@ -79,5 +78,4 @@ protected function getColumnConstant($name) { return $this->behavior->getColumnForParameter($name)->getName(); } - } diff --git a/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php b/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php index 24bba7d0ee..62e0576ad5 100644 --- a/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php +++ b/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php @@ -45,6 +45,7 @@ protected function withCreatedAt() /** * Add the create_column and update_columns to the current table + * * @return void */ public function modifyTable() @@ -54,13 +55,13 @@ public function modifyTable() if ($this->withCreatedAt() && !$table->hasColumn($this->getParameter('create_column'))) { $table->addColumn([ 'name' => $this->getParameter('create_column'), - 'type' => 'TIMESTAMP' + 'type' => 'TIMESTAMP', ]); } if ($this->withUpdatedAt() && !$table->hasColumn($this->getParameter('update_column'))) { $table->addColumn([ 'name' => $this->getParameter('update_column'), - 'type' => 'TIMESTAMP' + 'type' => 'TIMESTAMP', ]); } } @@ -68,7 +69,8 @@ public function modifyTable() /** * Get the setter of one of the columns of the behavior * - * @param string $column One of the behavior columns, 'create_column' or 'update_column' + * @param string $column One of the behavior columns, 'create_column' or 'update_column' + * * @return string The related setter, 'setCreatedOn' or 'setUpdatedOn' */ protected function getColumnSetter($column) @@ -99,9 +101,9 @@ public function preUpdate($builder) if ($this->withUpdatedAt()) { $valueSource = strtoupper($this->getTable()->getColumn($this->getParameter('update_column'))->getType()) === 'INTEGER' ? 'time()' - : '\\Propel\\Runtime\\Util\\PropelDateTime::createHighPrecision()' - ; - return "if (\$this->isModified() && !\$this->isColumnModified(" . $this->getColumnConstant('update_column', $builder) . ")) { + : '\\Propel\\Runtime\\Util\\PropelDateTime::createHighPrecision()'; + + return 'if ($this->isModified() && !$this->isColumnModified(' . $this->getColumnConstant('update_column', $builder) . ")) { \$this->" . $this->getColumnSetter('update_column') . "(${valueSource}); }"; } @@ -124,8 +126,7 @@ public function preInsert($builder) if ($this->withCreatedAt()) { $valueSource = strtoupper($this->getTable()->getColumn($this->getParameter('create_column'))->getType()) === 'INTEGER' ? '$time' - : '$highPrecision' - ; + : '$highPrecision'; $script .= " if (!\$this->isColumnModified(" . $this->getColumnConstant('create_column', $builder) . ")) { \$this->" . $this->getColumnSetter('create_column') . "(${valueSource}); @@ -135,8 +136,7 @@ public function preInsert($builder) if ($this->withUpdatedAt()) { $valueSource = strtoupper($this->getTable()->getColumn($this->getParameter('update_column'))->getType()) === 'INTEGER' ? '$time' - : '$highPrecision' - ; + : '$highPrecision'; $script .= " if (!\$this->isColumnModified(" . $this->getColumnConstant('update_column', $builder) . ")) { \$this->" . $this->getColumnSetter('update_column') . "(${valueSource}); diff --git a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php index 7f8d3132cf..2f39c17b93 100644 --- a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php +++ b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php @@ -23,13 +23,15 @@ class ValidateBehavior extends Behavior { /** - * @param object $builder The current builder + * @var object $builder The current builder */ protected $builder; /** * Add behavior methods to model class * + * @throws \Propel\Generator\Exception\InvalidArgumentException + * * @return string */ public function objectMethods($builder) @@ -79,13 +81,14 @@ public function objectAttributes() * Returns the parameters associated with a given column. * Useful for i18n behavior * - * @param string|null $columnName The column name - * @return array The array of parameters associated to given column + * @param string|null $columnName The column name + * + * @return array The array of parameters associated to given column */ public function getParametersFromColumnName($columnName = null) { $array = []; - if (null !== $columnName) { + if ($columnName !== null) { $this->cleanupParameters(); foreach ($this->getParameters() as $key => $parameter) { if ($parameter['column'] === $columnName) { @@ -102,11 +105,12 @@ public function getParametersFromColumnName($columnName = null) * Useful for i18n behavior * * @param string|null $columnName The column name + * * @return void */ public function removeParametersFromColumnName($columnName = null) { - if (null !== $columnName) { + if ($columnName !== null) { $newParams = []; $parameters = $this->getParameters(); foreach ($parameters as $key => $parameter) { @@ -131,11 +135,12 @@ public function addRuleOnPk() { if (!count($this->getParameters())) { $pk = $this->getTable()->getPrimaryKey(); - $parameters = ['auto_rule' => [ - 'column' => $pk[0]->getName(), + $parameters = [ + 'auto_rule' => [ + 'column' => $pk[0]->getName(), 'validators' => 'Type', - 'options' => [ - 'type' => $pk[0]->getPhpType(), + 'options' => [ + 'type' => $pk[0]->getPhpType(), ], ]]; $this->setParameters($parameters); @@ -146,11 +151,12 @@ public function addRuleOnPk() * Merge $paramArray array into parameters array. * This method avoid that there are rules with the same name, when adding parameters programmatically. * Useful for Concrete Inheritance behavior. + * * @return void */ - public function mergeParameters(array $params = null) + public function mergeParameters(?array $params = null) { - if (null !== $params) { + if ($params !== null) { $parameters = $this->getParameters(); $out = []; $i = 1; @@ -170,6 +176,7 @@ public function mergeParameters(array $params = null) /** * Convert those parameters, containing an array in YAML format * into a php array + * * @return void */ protected function cleanupParameters() @@ -187,6 +194,8 @@ protected function cleanupParameters() /** * Add loadValidatorMetadata() method * + * @throws \Propel\Generator\Exception\InvalidArgumentException + * * @return string */ protected function addLoadValidatorMetadataMethod() @@ -228,6 +237,8 @@ protected function addLoadValidatorMetadataMethod() * * @param array $properties * + * @throws \Propel\Generator\Exception\ConstraintNotFoundException + * * @return string */ protected function getClassConstraint(array $properties) @@ -243,11 +254,12 @@ protected function getClassConstraint(array $properties) } } - throw new ConstraintNotFoundException('The constraint class '.$properties['validator'].' does not exist.'); + throw new ConstraintNotFoundException('The constraint class ' . $properties['validator'] . ' does not exist.'); } /** * Adds the validate() method. + * * @return string The code to be added to model class */ protected function addValidateMethod() @@ -275,9 +287,9 @@ protected function addValidateMethod() return $this->renderTemplate('objectValidate', [ 'hasForeignKeys' => $hasForeignKeys, - 'aVarNames' => $aVarNames, - 'refFkVarNames' => $refFkVarNames, - 'collVarNames' => $collVarNames + 'aVarNames' => $aVarNames, + 'refFkVarNames' => $refFkVarNames, + 'collVarNames' => $collVarNames, ]); } diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php index 30f1ad140f..5804de7543 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php @@ -22,15 +22,15 @@ class VersionableBehavior extends Behavior { // default parameters value protected $parameters = [ - 'version_column' => 'version', - 'version_table' => '', - 'log_created_at' => 'false', - 'log_created_by' => 'false', - 'log_comment' => 'false', + 'version_column' => 'version', + 'version_table' => '', + 'log_created_at' => 'false', + 'log_created_by' => 'false', + 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', - 'version_comment_column' => 'version_comment', - 'indices' => 'false' + 'version_comment_column' => 'version_comment', + 'indices' => 'false', ]; /** @@ -44,6 +44,9 @@ class VersionableBehavior extends Behavior protected $tableModificationOrder = 80; + /** + * @return void + */ public function modifyDatabase() { foreach ($this->getDatabase()->getTables() as $table) { @@ -80,9 +83,9 @@ protected function addVersionColumn() // add the version column if (!$table->hasColumn($this->getParameter('version_column'))) { $table->addColumn([ - 'name' => $this->getParameter('version_column'), - 'type' => 'INTEGER', - 'default' => 0 + 'name' => $this->getParameter('version_column'), + 'type' => 'INTEGER', + 'default' => 0, ]); } } @@ -93,24 +96,24 @@ protected function addVersionColumn() protected function addLogColumns() { $table = $this->getTable(); - if ('true' === $this->getParameter('log_created_at') && !$table->hasColumn($this->getParameter('version_created_at_column'))) { + if ($this->getParameter('log_created_at') === 'true' && !$table->hasColumn($this->getParameter('version_created_at_column'))) { $table->addColumn([ 'name' => $this->getParameter('version_created_at_column'), - 'type' => 'TIMESTAMP' + 'type' => 'TIMESTAMP', ]); } - if ('true' === $this->getParameter('log_created_by') && !$table->hasColumn($this->getParameter('version_created_by_column'))) { + if ($this->getParameter('log_created_by') === 'true' && !$table->hasColumn($this->getParameter('version_created_by_column'))) { $table->addColumn([ 'name' => $this->getParameter('version_created_by_column'), 'type' => 'VARCHAR', - 'size' => 100 + 'size' => 100, ]); } - if ('true' === $this->getParameter('log_comment') && !$table->hasColumn($this->getParameter('version_comment_column'))) { + if ($this->getParameter('log_comment') === 'true' && !$table->hasColumn($this->getParameter('version_comment_column'))) { $table->addColumn([ 'name' => $this->getParameter('version_comment_column'), 'type' => 'VARCHAR', - 'size' => 255 + 'size' => 255, ]); } } @@ -126,12 +129,12 @@ protected function addVersionTable() if (!$database->hasTable($versionTableName)) { // create the version table $versionTable = $database->addTable([ - 'name' => $versionTableName, - 'phpName' => $this->getVersionTablePhpName(), - 'package' => $table->getPackage(), - 'schema' => $table->getSchema(), + 'name' => $versionTableName, + 'phpName' => $this->getVersionTablePhpName(), + 'package' => $table->getPackage(), + 'schema' => $table->getSchema(), 'namespace' => $table->getNamespace() ? '\\' . $table->getNamespace() : null, - 'skipSql' => $table->isSkipSql() + 'skipSql' => $table->isSkipSql(), ]); $versionTable->isVersionTable = true; // every behavior adding a table should re-execute database behaviors @@ -162,7 +165,7 @@ protected function addVersionTable() } $versionTable->addForeignKey($fk); - if ('true' === $this->getParameter('indices')) { + if ($this->getParameter('indices') === 'true') { foreach ($table->getIndices() as $index) { $index = clone $index; $versionTable->addIndex($index); @@ -189,9 +192,9 @@ public function addForeignKeyVersionColumns() $fkVersionColumnName = $fk->getLocalColumnName() . '_version'; if (!$versionTable->hasColumn($fkVersionColumnName)) { $versionTable->addColumn([ - 'name' => $fkVersionColumnName, - 'type' => 'INTEGER', - 'default' => 0 + 'name' => $fkVersionColumnName, + 'type' => 'INTEGER', + 'default' => 0, ]); } } @@ -201,16 +204,16 @@ public function addForeignKeyVersionColumns() $fkIdsColumnName = $fkTableName . '_ids'; if (!$versionTable->hasColumn($fkIdsColumnName)) { $versionTable->addColumn([ - 'name' => $fkIdsColumnName, - 'type' => 'ARRAY' + 'name' => $fkIdsColumnName, + 'type' => 'ARRAY', ]); } $fkVersionsColumnName = $fkTableName . '_versions'; if (!$versionTable->hasColumn($fkVersionsColumnName)) { $versionTable->addColumn([ - 'name' => $fkVersionsColumnName, - 'type' => 'ARRAY' + 'name' => $fkVersionsColumnName, + 'type' => 'ARRAY', ]); } } @@ -233,15 +236,15 @@ public function getVersionTablePhpName() } /** - * @return ForeignKey[] + * @return \Propel\Generator\Model\ForeignKey[] */ public function getVersionableFks() { $versionableFKs = []; if ($fks = $this->getTable()->getForeignKeys()) { foreach ($fks as $fk) { - if ($fk->getForeignTable()->hasBehavior($this->getName()) && ! $fk->isComposite()) { - $versionableFKs []= $fk; + if ($fk->getForeignTable()->hasBehavior($this->getName()) && !$fk->isComposite()) { + $versionableFKs[] = $fk; } } } @@ -250,15 +253,15 @@ public function getVersionableFks() } /** - * @return ForeignKey[] + * @return \Propel\Generator\Model\ForeignKey[] */ public function getVersionableReferrers() { $versionableReferrers = []; if ($fks = $this->getTable()->getReferrers()) { foreach ($fks as $fk) { - if ($fk->getTable()->hasBehavior($this->getName()) && ! $fk->isComposite()) { - $versionableReferrers []= $fk; + if ($fk->getTable()->hasBehavior($this->getName()) && !$fk->isComposite()) { + $versionableReferrers[] = $fk; } } } @@ -293,11 +296,11 @@ public function getReferrerVersionsColumn(ForeignKey $fk) } /** - * @return \Propel\Generator\Behavior\Versionable\VersionableBehavior|\Propel\Generator\Behavior\Versionable\VersionableBehaviorObjectBuilderModifier + * @return $this|\Propel\Generator\Behavior\Versionable\VersionableBehaviorObjectBuilderModifier */ public function getObjectBuilderModifier() { - if (null === $this->objectBuilderModifier) { + if ($this->objectBuilderModifier === null) { $this->objectBuilderModifier = new VersionableBehaviorObjectBuilderModifier($this); } @@ -305,11 +308,11 @@ public function getObjectBuilderModifier() } /** - * @return \Propel\Generator\Behavior\Versionable\VersionableBehavior|\Propel\Generator\Behavior\Versionable\VersionableBehaviorQueryBuilderModifier + * @return $this|\Propel\Generator\Behavior\Versionable\VersionableBehaviorQueryBuilderModifier */ public function getQueryBuilderModifier() { - if (null === $this->queryBuilderModifier) { + if ($this->queryBuilderModifier === null) { $this->queryBuilderModifier = new VersionableBehaviorQueryBuilderModifier($this); } diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php index 3a5582e48f..aa538d5205 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php @@ -106,9 +106,9 @@ protected function getActiveRecordClassName() */ protected function setBuilder($builder) { - $this->builder = $builder; + $this->builder = $builder; $this->objectClassName = $builder->getObjectClassName(); - $this->queryClassName = $builder->getQueryClassName(); + $this->queryClassName = $builder->getQueryClassName(); } /** @@ -225,7 +225,7 @@ public function objectMethods($builder) { $this->setBuilder($builder); $script = ''; - if ('version' !== $this->getParameter('version_column')) { + if ($this->getParameter('version_column') !== 'version') { $this->addVersionSetter($script); $this->addVersionGetter($script); } @@ -350,9 +350,7 @@ public function isVersioningNecessary(ConnectionInterface \$con = null) } foreach ($this->behavior->getVersionableReferrers() as $fk) { - if ($fk->isLocalPrimaryKey()) { - $fkGetter = $this->builder->getRefFKPhpNameAffix($fk); $script .= " if (\$this->single{$fkGetter}) { @@ -369,7 +367,6 @@ public function isVersioningNecessary(ConnectionInterface \$con = null) } "; } else { - $fkGetter = $this->builder->getRefFKPhpNameAffix($fk, $plural = true); $script .= " if (\$this->coll{$fkGetter}) { @@ -405,7 +402,7 @@ public function isVersioningNecessary(ConnectionInterface \$con = null) */ protected function addAddVersion(&$script) { - $versionTable = $this->behavior->getVersionTable(); + $versionTable = $this->behavior->getVersionTable(); $versionARClassName = $this->builder->getClassNameFromBuilder($this->builder->getNewStubObjectBuilder($versionTable)); $script .= " @@ -423,7 +420,7 @@ public function addVersion(ConnectionInterface \$con = null) \$version = new {$versionARClassName}();"; foreach ($this->table->getColumns() as $col) { $script .= " - \$version->set" . $col->getPhpName() . "(\$this->get" . $col->getPhpName() . "());"; + \$version->set" . $col->getPhpName() . '($this->get' . $col->getPhpName() . '());'; } $script .= " \$version->set{$this->table->getPhpName()}(\$this);"; @@ -532,7 +529,7 @@ public function populateFromVersion(\$version, \$con = null, &\$loadedObjects = $columns = $this->table->getColumns(); foreach ($columns as $col) { $script .= " - \$this->set" . $col->getPhpName() . "(\$version->get" . $col->getPhpName() . "());"; + \$this->set" . $col->getPhpName() . '($version->get' . $col->getPhpName() . '());'; } $plural = false; foreach ($this->behavior->getVersionableFks() as $fk) { @@ -878,7 +875,7 @@ protected function addGetLastVersions(&$script) $versionTableMapClassName = $this->builder->getClassNameFromBuilder($this->builder->getNewTableMapBuilder($versionTable)); $fks = $versionTable->getForeignKeysReferencingTable($this->table->getName()); $relCol = $this->builder->getRefFKPhpNameAffix($fks[0], $plural); - $versionGetter = 'get'.$relCol; + $versionGetter = 'get' . $relCol; $colPrefix = Column::CONSTANT_PREFIX; $script .= <<behavior = $behavior; - $this->table = $behavior->getTable(); + $this->table = $behavior->getTable(); } /** @@ -139,7 +143,7 @@ public function queryMethods($builder) { $this->setBuilder($builder); $script = ''; - if ('version' !== $this->getParameter('version_column')) { + if ($this->getParameter('version_column') !== 'version') { $this->addFilterByVersion($script); $this->addOrderByVersion($script); } diff --git a/src/Propel/Generator/Builder/DataModelBuilder.php b/src/Propel/Generator/Builder/DataModelBuilder.php index 749301740b..937f0f2cdd 100644 --- a/src/Propel/Generator/Builder/DataModelBuilder.php +++ b/src/Propel/Generator/Builder/DataModelBuilder.php @@ -10,14 +10,7 @@ namespace Propel\Generator\Builder; -use Propel\Common\Pluralizer\PluralizerInterface; -use Propel\Generator\Builder\Om\MultiExtendObjectBuilder; -use Propel\Generator\Builder\Om\ObjectBuilder; -use Propel\Generator\Builder\Om\QueryBuilder; -use Propel\Generator\Builder\Om\QueryInheritanceBuilder; -use Propel\Generator\Builder\Om\TableMapBuilder; use Propel\Generator\Config\GeneratorConfigInterface; -use Propel\Generator\Model\Database; use Propel\Generator\Model\Inheritance; use Propel\Generator\Model\Table; use Propel\Generator\Platform\PlatformInterface; @@ -29,7 +22,7 @@ * files, input forms, etc. * * The GeneratorConfig needs to be set on this class in order for the builders - * to be able to access the propel generator build properties. You should be + * to be able to access the propel generator build properties. You should be * safe if you always use the GeneratorConfig to get a configured builder class * anyway. * @@ -37,83 +30,94 @@ */ abstract class DataModelBuilder { - /** * The current table. - * @var Table + * + * @var \Propel\Generator\Model\Table */ private $table; /** * The generator config object holding build properties, etc. * - * @var GeneratorConfigInterface + * @var \Propel\Generator\Config\GeneratorConfigInterface */ private $generatorConfig; /** * An array of warning messages that can be retrieved for display. + * * @var array string[] */ private $warnings = []; /** * Object builder class for current table. - * @var ObjectBuilder + * + * @var \Propel\Generator\Builder\Om\ObjectBuilder */ private $objectBuilder; /** * Stub Object builder class for current table. - * @var ObjectBuilder + * + * @var \Propel\Generator\Builder\Om\ObjectBuilder */ private $stubObjectBuilder; /** * Query builder class for current table. - * @var ObjectBuilder + * + * @var \Propel\Generator\Builder\Om\ObjectBuilder */ private $queryBuilder; /** * Stub Query builder class for current table. - * @var ObjectBuilder + * + * @var \Propel\Generator\Builder\Om\ObjectBuilder */ private $stubQueryBuilder; /** * TableMap builder class for current table. - * @var TableMapBuilder + * + * @var \Propel\Generator\Builder\Om\TableMapBuilder */ protected $tablemapBuilder; /** * Stub Interface builder class for current table. - * @var ObjectBuilder + * + * @var \Propel\Generator\Builder\Om\ObjectBuilder */ private $interfaceBuilder; /** * Stub child object for current table. - * @var MultiExtendObjectBuilder + * + * @var \Propel\Generator\Builder\Om\MultiExtendObjectBuilder */ private $multiExtendObjectBuilder; /** * The Pluralizer class to use. - * @var PluralizerInterface + * + * @var \Propel\Common\Pluralizer\PluralizerInterface */ private $pluralizer; /** * The platform class - * @var PlatformInterface + * + * @var \Propel\Generator\Platform\PlatformInterface */ protected $platform; /** * Creates new instance of DataModelBuilder subclass. - * @param Table $table The Table which we are using to build [OM, DDL, etc.]. + * + * @param \Propel\Generator\Model\Table $table The Table which we are using to build [OM, DDL, etc.]. */ public function __construct(Table $table) { @@ -122,7 +126,8 @@ public function __construct(Table $table) /** * Returns new or existing Pluralizer class. - * @return PluralizerInterface + * + * @return \Propel\Common\Pluralizer\PluralizerInterface */ public function getPluralizer() { @@ -135,12 +140,13 @@ public function getPluralizer() /** * Returns new or existing Object builder class for this table. - * @return ObjectBuilder + * + * @return \Propel\Generator\Builder\Om\ObjectBuilder */ public function getObjectBuilder() { if (!isset($this->objectBuilder)) { - /** @var ObjectBuilder $builder */ + /** @var \Propel\Generator\Builder\Om\ObjectBuilder $builder */ $builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'object'); $this->objectBuilder = $builder; } @@ -150,12 +156,13 @@ public function getObjectBuilder() /** * Returns new or existing stub Object builder class for this table. - * @return ObjectBuilder + * + * @return \Propel\Generator\Builder\Om\ObjectBuilder */ public function getStubObjectBuilder() { if (!isset($this->stubObjectBuilder)) { - /** @var ObjectBuilder $builder */ + /** @var \Propel\Generator\Builder\Om\ObjectBuilder $builder */ $builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'objectstub'); $this->stubObjectBuilder = $builder; } @@ -165,12 +172,13 @@ public function getStubObjectBuilder() /** * Returns new or existing Query builder class for this table. - * @return ObjectBuilder + * + * @return \Propel\Generator\Builder\Om\ObjectBuilder */ public function getQueryBuilder() { if (!isset($this->queryBuilder)) { - /** @var ObjectBuilder $builder */ + /** @var \Propel\Generator\Builder\Om\ObjectBuilder $builder */ $builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'query'); $this->queryBuilder = $builder; } @@ -180,12 +188,13 @@ public function getQueryBuilder() /** * Returns new or existing stub Query builder class for this table. - * @return ObjectBuilder + * + * @return \Propel\Generator\Builder\Om\ObjectBuilder */ public function getStubQueryBuilder() { if (!isset($this->stubQueryBuilder)) { - /** @var ObjectBuilder $builder */ + /** @var \Propel\Generator\Builder\Om\ObjectBuilder $builder */ $builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'querystub'); $this->stubQueryBuilder = $builder; } @@ -195,12 +204,13 @@ public function getStubQueryBuilder() /** * Returns new or existing Object builder class for this table. - * @return TableMapBuilder + * + * @return \Propel\Generator\Builder\Om\TableMapBuilder */ public function getTableMapBuilder() { if (!isset($this->tablemapBuilder)) { - /** @var TableMapBuilder $builder */ + /** @var \Propel\Generator\Builder\Om\TableMapBuilder $builder */ $builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'tablemap'); $this->tablemapBuilder = $builder; } @@ -210,12 +220,13 @@ public function getTableMapBuilder() /** * Returns new or existing stub Interface builder class for this table. - * @return ObjectBuilder + * + * @return \Propel\Generator\Builder\Om\ObjectBuilder */ public function getInterfaceBuilder() { if (!isset($this->interfaceBuilder)) { - /** @var ObjectBuilder $builder */ + /** @var \Propel\Generator\Builder\Om\ObjectBuilder $builder */ $builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'interface'); $this->interfaceBuilder = $builder; } @@ -225,14 +236,15 @@ public function getInterfaceBuilder() /** * Returns new or existing stub child object builder class for this table. - * @return MultiExtendObjectBuilder + * + * @return \Propel\Generator\Builder\Om\MultiExtendObjectBuilder */ public function getMultiExtendObjectBuilder() { if (!isset($this->multiExtendObjectBuilder)) { - /** @var MultiExtendObjectBuilder $builder */ + /** @var \Propel\Generator\Builder\Om\MultiExtendObjectBuilder $builder */ $builder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'objectmultiextend'); - $this->multiExtendObjectBuilder= $builder; + $this->multiExtendObjectBuilder = $builder; } return $this->multiExtendObjectBuilder; @@ -241,13 +253,14 @@ public function getMultiExtendObjectBuilder() /** * Gets a new data model builder class for specified table and classname. * - * @param Table $table - * @param string $classname The class of builder - * @return DataModelBuilder + * @param \Propel\Generator\Model\Table $table + * @param string $classname The class of builder + * + * @return \Propel\Generator\Builder\DataModelBuilder */ public function getNewBuilder(Table $table, $classname) { - /** @var DataModelBuilder $builder */ + /** @var \Propel\Generator\Builder\DataModelBuilder $builder */ $builder = new $classname($table); $builder->setGeneratorConfig($this); @@ -260,12 +273,13 @@ public function getNewBuilder(Table $table, $classname) * This is used very frequently from the tableMap and object builders to get * an object builder for a RELATED table. * - * @param Table $table - * @return ObjectBuilder + * @param \Propel\Generator\Model\Table $table + * + * @return \Propel\Generator\Builder\Om\ObjectBuilder */ public function getNewObjectBuilder(Table $table) { - /** @var ObjectBuilder $builder */ + /** @var \Propel\Generator\Builder\Om\ObjectBuilder $builder */ $builder = $this->getGeneratorConfig()->getConfiguredBuilder($table, 'object'); return $builder; @@ -277,12 +291,13 @@ public function getNewObjectBuilder(Table $table) * This is used from the query builders to get * an object builder for a RELATED table. * - * @param Table $table - * @return ObjectBuilder + * @param \Propel\Generator\Model\Table $table + * + * @return \Propel\Generator\Builder\Om\ObjectBuilder */ public function getNewStubObjectBuilder(Table $table) { - /** @var ObjectBuilder $builder */ + /** @var \Propel\Generator\Builder\Om\ObjectBuilder $builder */ $builder = $this->getGeneratorConfig()->getConfiguredBuilder($table, 'objectstub'); return $builder; @@ -294,12 +309,13 @@ public function getNewStubObjectBuilder(Table $table) * This is used from the query builders to get * a query builder for a RELATED table. * - * @param Table $table - * @return QueryBuilder + * @param \Propel\Generator\Model\Table $table + * + * @return \Propel\Generator\Builder\Om\QueryBuilder */ public function getNewQueryBuilder(Table $table) { - /** @var QueryBuilder $builder */ + /** @var \Propel\Generator\Builder\Om\QueryBuilder $builder */ $builder = $this->getGeneratorConfig()->getConfiguredBuilder($table, 'query'); return $builder; @@ -311,12 +327,13 @@ public function getNewQueryBuilder(Table $table) * This is used from the query builders to get * a query builder for a RELATED table. * - * @param Table $table - * @return QueryBuilder + * @param \Propel\Generator\Model\Table $table + * + * @return \Propel\Generator\Builder\Om\QueryBuilder */ public function getNewStubQueryBuilder(Table $table) { - /** @var QueryBuilder $builder */ + /** @var \Propel\Generator\Builder\Om\QueryBuilder $builder */ $builder = $this->getGeneratorConfig()->getConfiguredBuilder($table, 'querystub'); return $builder; @@ -325,12 +342,13 @@ public function getNewStubQueryBuilder(Table $table) /** * Returns new Query Inheritance builder class for this table. * - * @param Inheritance $child - * @return QueryInheritanceBuilder + * @param \Propel\Generator\Model\Inheritance $child + * + * @return \Propel\Generator\Builder\Om\QueryInheritanceBuilder */ public function getNewQueryInheritanceBuilder(Inheritance $child) { - /** @var QueryInheritanceBuilder $queryInheritanceBuilder */ + /** @var \Propel\Generator\Builder\Om\QueryInheritanceBuilder $queryInheritanceBuilder */ $queryInheritanceBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'queryinheritance'); $queryInheritanceBuilder->setChild($child); @@ -340,12 +358,13 @@ public function getNewQueryInheritanceBuilder(Inheritance $child) /** * Returns new stub Query Inheritance builder class for this table. * - * @param Inheritance $child - * @return QueryInheritanceBuilder + * @param \Propel\Generator\Model\Inheritance $child + * + * @return \Propel\Generator\Builder\Om\QueryInheritanceBuilder */ public function getNewStubQueryInheritanceBuilder(Inheritance $child) { - /** @var QueryInheritanceBuilder $stubQueryInheritanceBuilder */ + /** @var \Propel\Generator\Builder\Om\QueryInheritanceBuilder $stubQueryInheritanceBuilder */ $stubQueryInheritanceBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'queryinheritancestub'); $stubQueryInheritanceBuilder->setChild($child); @@ -370,7 +389,7 @@ public function getNewTableMapBuilder(Table $table) /** * Gets the GeneratorConfig object. * - * @return GeneratorConfigInterface + * @return \Propel\Generator\Config\GeneratorConfigInterface */ public function getGeneratorConfig() { @@ -386,7 +405,8 @@ public function getGeneratorConfig() * is expressed by: * 'database.adapter.mysql.tableType * - * @param string $name + * @param string $name + * * @return string|null */ public function getBuildProperty($name) @@ -401,7 +421,8 @@ public function getBuildProperty($name) /** * Sets the GeneratorConfig object. * - * @param GeneratorConfigInterface $v + * @param \Propel\Generator\Config\GeneratorConfigInterface $v + * * @return void */ public function setGeneratorConfig(GeneratorConfigInterface $v) @@ -411,7 +432,9 @@ public function setGeneratorConfig(GeneratorConfigInterface $v) /** * Sets the table for this builder. - * @param Table $table + * + * @param \Propel\Generator\Model\Table $table + * * @return void */ public function setTable(Table $table) @@ -421,7 +444,8 @@ public function setTable(Table $table) /** * Returns the current Table object. - * @return Table + * + * @return \Propel\Generator\Model\Table */ public function getTable() { @@ -430,11 +454,12 @@ public function getTable() /** * Convenience method to returns the Platform class for this table (database). - * @return PlatformInterface + * + * @return \Propel\Generator\Platform\PlatformInterface */ public function getPlatform() { - if (null === $this->platform) { + if ($this->platform === null) { // try to load the platform from the table $table = $this->getTable(); if ($table && $database = $table->getDatabase()) { @@ -452,7 +477,8 @@ public function getPlatform() /** * Platform setter * - * @param PlatformInterface $platform + * @param \Propel\Generator\Platform\PlatformInterface $platform + * * @return void */ public function setPlatform(PlatformInterface $platform) @@ -464,6 +490,7 @@ public function setPlatform(PlatformInterface $platform) * Quotes identifier based on $this->getTable()->isIdentifierQuotingEnabled. * * @param string $text + * * @return string */ public function quoteIdentifier($text) @@ -477,7 +504,8 @@ public function quoteIdentifier($text) /** * Convenience method to returns the database for current table. - * @return Database + * + * @return \Propel\Generator\Model\Database */ public function getDatabase() { @@ -488,7 +516,9 @@ public function getDatabase() /** * Pushes a message onto the stack of warnings. + * * @param string $msg The warning message. + * * @return void */ protected function warn($msg) @@ -498,6 +528,7 @@ protected function warn($msg) /** * Gets array of warning messages. + * * @return string[] */ public function getWarnings() @@ -507,8 +538,10 @@ public function getWarnings() /** * Returns the name of the current class being built, with a possible prefix. - * @return string + * * @see OMBuilder#getClassName() + * + * @return string */ public function prefixClassName($identifier) { diff --git a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php index f5ce1262cf..bb06aac731 100644 --- a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php @@ -10,6 +10,7 @@ namespace Propel\Generator\Builder\Om; +use InvalidArgumentException as CoreInvalidArgumentException; use Propel\Generator\Builder\DataModelBuilder; use Propel\Generator\Builder\Util\PropelTemplate; use Propel\Generator\Exception\InvalidArgumentException; @@ -24,7 +25,7 @@ * Baseclass for OM-building classes. * * OM-building classes are those that build a PHP (or other) class to service - * a single table. This includes Entity classes, Map classes, + * a single table. This includes Entity classes, Map classes, * Node classes, Nested Set classes, etc. * * @author Hans Lellelid @@ -57,7 +58,7 @@ abstract class AbstractOMBuilder extends DataModelBuilder * Builds the PHP source for current class and returns it as a string. * * This is the main entry point and defines a basic structure that classes should follow. - * In most cases this method will not need to be overridden by subclasses. This method + * In most cases this method will not need to be overridden by subclasses. This method * does assume that the output language is PHP code, so it will need to be overridden if * this is not the case. * @@ -83,7 +84,7 @@ public function build() $script = $namespaceStatement . $script; } - $script = "getQualifiedClassName(); } + /** * Returns FQCN alias of getFullyQualifiedClassName * @@ -194,6 +196,7 @@ public function getClassFilePath() /** * Gets package name for this table. * This is overridden by child classes that have different packages. + * * @return string */ public function getPackage() @@ -208,13 +211,14 @@ public function getPackage() /** * Returns filesystem path for current package. + * * @return string */ public function getPackagePath() { $pkg = $this->getPackage(); - if (false !== strpos($pkg, '/')) { + if (strpos($pkg, '/') !== false) { $pkg = preg_replace('#\.(map|om)$#', '/\1', $pkg); $pkg = preg_replace('#\.(Map|Om)$#', '/\1', $pkg); @@ -244,9 +248,10 @@ public function getNamespace() /** * This declares the class use and returns the correct name to use (short classname, Alias, or FQCN) * - * @param AbstractOMBuilder $builder - * @param boolean $fqcn true to return the $fqcn classname - * @return string ClassName, Alias or FQCN + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * @param bool $fqcn true to return the $fqcn classname + * + * @return string ClassName, Alias or FQCN */ public function getClassNameFromBuilder($builder, $fqcn = false) { @@ -257,8 +262,10 @@ public function getClassNameFromBuilder($builder, $fqcn = false) $namespace = $builder->getNamespace(); $class = $builder->getUnqualifiedClassName(); - if (isset($this->declaredClasses[$namespace]) - && isset($this->declaredClasses[$namespace][$class])) { + if ( + isset($this->declaredClasses[$namespace]) + && isset($this->declaredClasses[$namespace][$class]) + ) { return $this->declaredClasses[$namespace][$class]; } @@ -268,8 +275,9 @@ public function getClassNameFromBuilder($builder, $fqcn = false) /** * This declares the class use and returns the correct name to use * - * @param Table $table + * @param \Propel\Generator\Model\Table $table * @param bool $fqcn + * * @return string */ public function getClassNameFromTable(Table $table, $fqcn = false) @@ -283,24 +291,29 @@ public function getClassNameFromTable(Table $table, $fqcn = false) /** * Declare a class to be use and return it's name or it's alias * - * @param string $class the class name - * @param string $namespace the namespace - * @param string|bool|null $alias the alias wanted, if set to True, it automatically adds an alias when needed - * @return string the class name or it's alias + * @param string $class the class name + * @param string $namespace the namespace + * @param string|bool|null $alias the alias wanted, if set to True, it automatically adds an alias when needed + * + * @throws \Propel\Generator\Exception\LogicException + * + * @return string the class name or it's alias */ public function declareClassNamespace($class, $namespace = '', $alias = false) { $namespace = trim($namespace, '\\'); // check if the class is already declared - if (isset($this->declaredClasses[$namespace]) - && isset($this->declaredClasses[$namespace][$class])) { + if ( + isset($this->declaredClasses[$namespace]) + && isset($this->declaredClasses[$namespace][$class]) + ) { return $this->declaredClasses[$namespace][$class]; } $forcedAlias = $this->needAliasForClassName($class, $namespace); - if (false === $alias || true === $alias || null === $alias) { + if ($alias === false || $alias === true || $alias === null) { $aliasWanted = $class; $alias = $alias || $forcedAlias; } else { @@ -320,15 +333,15 @@ public function declareClassNamespace($class, $namespace = '', $alias = false) } // we have a duplicate class and asked for an automatic Alias - if (false !== $alias) { - if ('\\Base' === substr($namespace, -5) || 'Base' === $namespace) { + if ($alias !== false) { + if (substr($namespace, -5) === '\\Base' || $namespace === 'Base') { return $this->declareClassNamespace($class, $namespace, 'Base' . $class); } - if ('Child' === substr($alias, 0, 5)) { + if (substr($alias, 0, 5) === 'Child') { //we already requested Child.$class and its in use too, //so use the fqcn - return ($namespace ? '\\' . $namespace : '') . '\\' . $class; + return ($namespace ? '\\' . $namespace : '') . '\\' . $class; } else { $autoAliasName = 'Child' . $class; } @@ -348,7 +361,8 @@ public function declareClassNamespace($class, $namespace = '', $alias = false) * * @param string $class * @param string $namespace - * @return boolean + * + * @return bool */ protected function needAliasForClassName($class, $namespace) { @@ -360,24 +374,24 @@ protected function needAliasForClassName($class, $namespace) return true; } - if (empty($namespace) && 'Base' === $this->getNamespace()) { + if (empty($namespace) && $this->getNamespace() === 'Base') { if (str_replace(['Query'], '', $class) == str_replace(['Query'], '', $this->getUnqualifiedClassName())) { return true; } - if ((false !== strpos($class, 'Query'))) { + if ((strpos($class, 'Query') !== false)) { return true; } // force alias for model without namespace - if (false === array_search($class, $this->whiteListOfDeclaredClasses, true)) { + if (array_search($class, $this->whiteListOfDeclaredClasses, true) === false) { return true; } } - if ('Base' === $namespace && '' === $this->getNamespace()) { + if ($namespace === 'Base' && $this->getNamespace() === '') { // force alias for model without namespace - if (false === array_search($class, $this->whiteListOfDeclaredClasses, true)) { + if (array_search($class, $this->whiteListOfDeclaredClasses, true) === false) { return true; } } @@ -389,14 +403,15 @@ protected function needAliasForClassName($class, $namespace) * Declare a use statement for a $class with a $namespace and an $aliasPrefix * This return the short ClassName or an alias * - * @param string $class the class - * @param string $namespace the namespace - * @param mixed $aliasPrefix optionally an alias or True to force an automatic alias prefix (Base or Child) + * @param string $class the class + * @param string $namespace the namespace + * @param mixed $aliasPrefix optionally an alias or True to force an automatic alias prefix (Base or Child) + * * @return string the short ClassName or an alias */ public function declareClassNamespacePrefix($class, $namespace = '', $aliasPrefix = false) { - if (false !== $aliasPrefix && true !== $aliasPrefix) { + if ($aliasPrefix !== false && $aliasPrefix !== true) { $alias = $aliasPrefix . $class; } else { $alias = $aliasPrefix; @@ -409,8 +424,9 @@ public function declareClassNamespacePrefix($class, $namespace = '', $aliasPrefi * Declare a Fully qualified classname with an $aliasPrefix * This return the short ClassName to use or an alias * - * @param string $fullyQualifiedClassName the fully qualified classname - * @param mixed $aliasPrefix optionally an alias or True to force an automatic alias prefix (Base or Child) + * @param string $fullyQualifiedClassName the fully qualified classname + * @param mixed $aliasPrefix optionally an alias or True to force an automatic alias prefix (Base or Child) + * * @return string the short ClassName or an alias */ public function declareClass($fullyQualifiedClassName, $aliasPrefix = false) @@ -419,13 +435,15 @@ public function declareClass($fullyQualifiedClassName, $aliasPrefix = false) if (($pos = strrpos($fullyQualifiedClassName, '\\')) !== false) { return $this->declareClassNamespacePrefix(substr($fullyQualifiedClassName, $pos + 1), substr($fullyQualifiedClassName, 0, $pos), $aliasPrefix); } + // root namespace return $this->declareClassNamespacePrefix($fullyQualifiedClassName, '', $aliasPrefix); } /** - * @param self $builder - * @param boolean|string $aliasPrefix the prefix for the Alias or True for auto generation of the Alias + * @param self $builder + * @param bool|string $aliasPrefix the prefix for the Alias or True for auto generation of the Alias + * * @return string */ public function declareClassFromBuilder(self $builder, $aliasPrefix = false) @@ -447,12 +465,13 @@ public function declareClasses() /** * Get the list of declared classes for a given $namespace or all declared classes * - * @param string $namespace the namespace or null - * @return array list of declared classes + * @param string|null $namespace the namespace or null + * + * @return array list of declared classes */ public function getDeclaredClasses($namespace = null) { - if (null !== $namespace && isset($this->declaredClasses[$namespace])) { + if ($namespace !== null && isset($this->declaredClasses[$namespace])) { return $this->declaredClasses[$namespace]; } @@ -479,7 +498,8 @@ public function getNamespaceStatement() /** * Return all the use statement of the class * - * @param string $ignoredNamespace the ignored namespace + * @param string|null $ignoredNamespace the ignored namespace + * * @return string */ public function getUseStatements($ignoredNamespace = null) @@ -512,8 +532,10 @@ public function getUseStatements($ignoredNamespace = null) * Shortcut method to return the [stub] query classname for current table. * This is the classname that is used whenever object or tablemap classes want * to invoke methods of the query classes. - * @param boolean $fqcn - * @return string (e.g. 'Myquery') + * + * @param bool $fqcn + * + * @return string (e.g. 'Myquery') */ public function getQueryClassName($fqcn = false) { @@ -524,8 +546,10 @@ public function getQueryClassName($fqcn = false) * Returns the object classname for current table. * This is the classname that is used whenever object or tablemap classes want * to invoke methods of the object classes. - * @param boolean $fqcn - * @return string (e.g. 'MyTable' or 'ChildMyTable') + * + * @param bool $fqcn + * + * @return string (e.g. 'MyTable' or 'ChildMyTable') */ public function getObjectClassName($fqcn = false) { @@ -547,8 +571,10 @@ public function getObjectName() * Returns the tableMap classname for current table. * This is the classname that is used whenever object or tablemap classes want * to invoke methods of the object classes. - * @param boolean $fqcn - * @return string (e.g. 'My') + * + * @param bool $fqcn + * + * @return string (e.g. 'My') */ public function getTableMapClassName($fqcn = false) { @@ -558,18 +584,20 @@ public function getTableMapClassName($fqcn = false) /** * Get the column constant name (e.g. TableMapName::COLUMN_NAME). * - * @param Column|null $col The column we need a name for. + * @param \Propel\Generator\Model\Column|null $col The column we need a name for. * @param string|null $classname The TableMap classname to use. * + * @throws \Propel\Generator\Exception\InvalidArgumentException + * * @return string If $classname is provided, then will return $classname::COLUMN_NAME; if not, then the TableMapName is looked up for current table to yield $currTableTableMap::COLUMN_NAME. */ public function getColumnConstant($col, $classname = null) { - if (null === $col) { + if ($col === null) { throw new InvalidArgumentException('No columns were specified.'); } - if (null === $classname) { + if ($classname === null) { return $this->getBuildProperty('generator.objectModel.classPrefix') . $col->getFQConstantName(); } @@ -580,7 +608,7 @@ public function getColumnConstant($col, $classname = null) $const = strtoupper($col->getName()); } - return $classname.'::'.Column::CONSTANT_PREFIX.$const; + return $classname . '::' . Column::CONSTANT_PREFIX . $const; } /** @@ -588,7 +616,8 @@ public function getColumnConstant($col, $classname = null) * If the key is required, an INNER JOIN will be returned, else a LEFT JOIN will be suggested, * unless the schema is provided with the DefaultJoin attribute, which overrules the default Join Type * - * @param ForeignKey $fk + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return string */ protected function getJoinType(ForeignKey $fk) @@ -610,8 +639,9 @@ protected function getJoinType(ForeignKey $fk) * The difference between this method and the getRefFKPhpNameAffix() method is that in this method the * classname in the affix is the foreign table classname. * - * @param ForeignKey $fk The local FK that we need a name for. - * @param boolean $plural Whether the php name should be plural (e.g. initRelatedObjs() vs. addRelatedObj() + * @param \Propel\Generator\Model\ForeignKey $fk The local FK that we need a name for. + * @param bool $plural Whether the php name should be plural (e.g. initRelatedObjs() vs. addRelatedObj() + * * @return string */ public function getFKPhpNameAffix(ForeignKey $fk, $plural = false) @@ -633,8 +663,9 @@ public function getFKPhpNameAffix(ForeignKey $fk, $plural = false) } /** - * @param CrossForeignKeys $crossFKs - * @param bool $plural + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * @param bool $plural + * * @return string */ protected function getCrossFKsPhpNameAffix(CrossForeignKeys $crossFKs, $plural = true) @@ -671,12 +702,13 @@ protected function getCrossFKsPhpNameAffix(CrossForeignKeys $crossFKs, $plural = $name = implode($names); - return (true === $plural ? $this->getPluralizer()->getPluralForm($name) : $name); + return ($plural === true ? $this->getPluralizer()->getPluralForm($name) : $name); } /** - * @param CrossForeignKeys $crossFKs - * @param ForeignKey $excludeFK + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * @param \Propel\Generator\Model\ForeignKey $excludeFK + * * @return string */ protected function getCrossRefFKGetterName(CrossForeignKeys $crossFKs, ForeignKey $excludeFK) @@ -701,7 +733,8 @@ protected function getCrossRefFKGetterName(CrossForeignKeys $crossFKs, ForeignKe } /** - * @param CrossForeignKeys $crossFKs + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * * @return array */ protected function getCrossFKInformation(CrossForeignKeys $crossFKs) @@ -712,8 +745,8 @@ protected function getCrossFKInformation(CrossForeignKeys $crossFKs) $phpDoc = []; foreach ($crossFKs->getCrossForeignKeys() as $fk) { - $crossObjectName = '$' . lcfirst($this->getFKPhpNameAffix($fk)); - $crossObjectClassName = $this->getNewObjectBuilder($fk->getForeignTable())->getObjectClassName(); + $crossObjectName = '$' . lcfirst($this->getFKPhpNameAffix($fk)); + $crossObjectClassName = $this->getNewObjectBuilder($fk->getForeignTable())->getObjectClassName(); $names[] = $crossObjectClassName; $signatures[] = "$crossObjectClassName $crossObjectName" . ($fk->isAtLeastOneLocalColumnRequired() ? '' : ' = null'); @@ -722,7 +755,7 @@ protected function getCrossFKInformation(CrossForeignKeys $crossFKs) * @param $crossObjectClassName $crossObjectName The object to relate"; } - $names = implode(', ', $names). (1 < count($names) ? ' combination' : ''); + $names = implode(', ', $names) . (1 < count($names) ? ' combination' : ''); $phpDoc = implode($phpDoc); $signatures = implode(', ', $signatures); $shortSignature = implode(', ', $shortSignature); @@ -731,13 +764,14 @@ protected function getCrossFKInformation(CrossForeignKeys $crossFKs) $names, $phpDoc, $signatures, - $shortSignature + $shortSignature, ]; } /** - * @param CrossForeignKeys $crossFKs - * @param array|ForeignKey $crossFK will be the first variable defined + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * @param array|\Propel\Generator\Model\ForeignKey|null $crossFK will be the first variable defined + * * @return array */ protected function getCrossFKAddMethodInformation(CrossForeignKeys $crossFKs, $crossFK = null) @@ -765,12 +799,13 @@ protected function getCrossFKAddMethodInformation(CrossForeignKeys $crossFKs, $c /** * Extracts some useful information from a CrossForeignKeys object. * - * @param CrossForeignKeys $crossFKs - * @param array|ForeignKey $crossFKToIgnore - * @param array $signature - * @param array $shortSignature - * @param array $normalizedShortSignature - * @param array $phpDoc + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * @param array|\Propel\Generator\Model\ForeignKey $crossFKToIgnore + * @param array $signature + * @param array $shortSignature + * @param array $normalizedShortSignature + * @param array $phpDoc + * * @return void */ protected function extractCrossInformation( @@ -784,7 +819,7 @@ protected function extractCrossInformation( foreach ($crossFKs->getCrossForeignKeys() as $fk) { if (is_array($crossFKToIgnore) && in_array($fk, $crossFKToIgnore)) { continue; - } else if ($fk === $crossFKToIgnore) { + } elseif ($fk === $crossFKToIgnore) { continue; } @@ -809,17 +844,16 @@ protected function extractCrossInformation( $name = '$' . lcfirst($primaryKey->getPhpName()); $normalizedShortSignature[] = $name; - $signature[] = ($typeHint ? "$typeHint " : '') . $name . ('null' !== $defaultValue ? " = $defaultValue" : ''); + $signature[] = ($typeHint ? "$typeHint " : '') . $name . ($defaultValue !== 'null' ? " = $defaultValue" : ''); $shortSignature[] = $name; $phpDoc[] = " * @param $phpType $name"; } - } - /** - * @param CrossForeignKeys $crossFKs + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * * @return string */ protected function getCrossFKsVarName(CrossForeignKeys $crossFKs) @@ -828,7 +862,8 @@ protected function getCrossFKsVarName(CrossForeignKeys $crossFKs) } /** - * @param ForeignKey $crossFK + * @param \Propel\Generator\Model\ForeignKey $crossFK + * * @return string */ protected function getCrossFKVarName(ForeignKey $crossFK) @@ -839,10 +874,12 @@ protected function getCrossFKVarName(ForeignKey $crossFK) /** * Gets the "RelatedBy*" suffix (if needed) that is attached to method and variable names. * - * The related by suffix is based on the local columns of the foreign key. If there is more than + * The related by suffix is based on the local columns of the foreign key. If there is more than * one column in a table that points to the same foreign table, then a 'RelatedByLocalColName' suffix * will be appended. * + * @throws \Propel\Generator\Exception\RuntimeException + * * @return string */ protected static function getRelatedBySuffix(ForeignKey $fk) @@ -852,14 +889,16 @@ protected static function getRelatedBySuffix(ForeignKey $fk) foreach ($fk->getMapping() as $mapping) { [$localColumn, $foreignValueOrColumn] = $mapping; $localColumnName = $localColumn->getPhpName(); - $localTable = $fk->getTable(); + $localTable = $fk->getTable(); if (!$localColumn) { throw new RuntimeException(sprintf('Could not fetch column: %s in table %s.', $localColumnName, $localTable->getName())); } - if (count($localTable->getForeignKeysReferencingTable($fk->getForeignTableName())) > 1 - || count($fk->getForeignTable()->getForeignKeysReferencingTable($fk->getTableName())) > 0 - || $fk->getForeignTableName() == $fk->getTableName()) { + if ( + count($localTable->getForeignKeysReferencingTable($fk->getForeignTableName())) > 1 + || count($fk->getForeignTable()->getForeignKeysReferencingTable($fk->getTableName())) > 0 + || $fk->getForeignTableName() == $fk->getTableName() + ) { // self referential foreign key, or several foreign keys to the same table, or cross-reference fkey $relCol .= $localColumn->getPhpName(); } @@ -878,8 +917,9 @@ protected static function getRelatedBySuffix(ForeignKey $fk) * The difference between this method and the getFKPhpNameAffix() method is that in this method the * classname in the affix is the classname of the local fkey table. * - * @param ForeignKey $fk The referrer FK that we need a name for. - * @param boolean $plural Whether the php name should be plural (e.g. initRelatedObjs() vs. addRelatedObj() + * @param \Propel\Generator\Model\ForeignKey $fk The referrer FK that we need a name for. + * @param bool $plural Whether the php name should be plural (e.g. initRelatedObjs() vs. addRelatedObj() + * * @return string */ public function getRefFKPhpNameAffix(ForeignKey $fk, $plural = false) @@ -931,9 +971,11 @@ protected static function getRefRelatedBySuffix(ForeignKey $fk) /** * Checks whether any registered behavior on that table has a modifier for a hook - * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" - * @param string $modifier The name of the modifier object providing the method in the behavior - * @return boolean + * + * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" + * @param string $modifier The name of the modifier object providing the method in the behavior + * + * @return bool */ public function hasBehaviorModifier($hookName, $modifier) { @@ -949,12 +991,14 @@ public function hasBehaviorModifier($hookName, $modifier) /** * Checks whether any registered behavior on that table has a modifier for a hook + * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string $modifier The name of the modifier object providing the method in the behavior - * @param string $script The script will be modified in this method. + * @param string $script The script will be modified in this method. + * * @return void */ - public function applyBehaviorModifierBase($hookName, $modifier, &$script, $tab = " ") + public function applyBehaviorModifierBase($hookName, $modifier, &$script, $tab = ' ') { $modifierGetter = 'get' . $modifier; foreach ($this->getTable()->getBehaviors() as $behavior) { @@ -980,8 +1024,10 @@ public function applyBehaviorModifierBase($hookName, $modifier, &$script, $tab = /** * Checks whether any registered behavior content creator on that table exists a contentName + * * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassName" - * @param string $modifier The name of the modifier object providing the method in the behavior + * @param string $modifier The name of the modifier object providing the method in the behavior + * * @return string|null */ public function getBehaviorContentBase($contentName, $modifier) @@ -1002,9 +1048,12 @@ public function getBehaviorContentBase($contentName, $modifier) * passed as arguments. The template file name is relative to the behavior's * directory name. * - * @param string $filename - * @param array $vars - * @param string $templateDir + * @param string $filename + * @param array $vars + * @param string $templateDir + * + * @throws \Propel\Generator\Exception\InvalidArgumentException + * * @return string */ public function renderTemplate($filename, $vars = [], $templateDir = '/templates/') @@ -1014,7 +1063,7 @@ public function renderTemplate($filename, $vars = [], $templateDir = '/templates // try with '.php' at the end $filePath = $filePath . '.php'; if (!file_exists($filePath)) { - throw new \InvalidArgumentException(sprintf('Template "%s" not found in "%s" directory', $filename, __DIR__ . $templateDir)); + throw new CoreInvalidArgumentException(sprintf('Template "%s" not found in "%s" directory', $filename, __DIR__ . $templateDir)); } } $template = new PropelTemplate(); @@ -1036,6 +1085,7 @@ public function getTableMapClass() * Most of the code comes from the PHP-CS-Fixer project * * @param string $content + * * @return string */ private function clean($content) @@ -1061,15 +1111,15 @@ private function clean($content) $short = array_pop($parts); } - preg_match_all('/\b'.$short.'\b/i', str_replace($match[0]."\n", '', $content), $m); + preg_match_all('/\b' . $short . '\b/i', str_replace($match[0] . "\n", '', $content), $m); if (!count($m[0])) { - $content = str_replace($match[0]."\n", '', $content); + $content = str_replace($match[0] . "\n", '', $content); } } // end of line - if (strlen($content) && "\n" != substr($content, -1)) { - $content = $content."\n"; + if (strlen($content) && substr($content, -1) != "\n") { + $content = $content . "\n"; } return $content; @@ -1079,6 +1129,7 @@ private function clean($content) * Opens class. * * @param string $script + * * @return void */ abstract protected function addClassOpen(&$script); @@ -1092,6 +1143,7 @@ abstract protected function addClassOpen(&$script); * drastically change the contents of the generated object class. * * @param string $script The script will be modified in this method. + * * @return void */ abstract protected function addClassBody(&$script); @@ -1100,6 +1152,7 @@ abstract protected function addClassBody(&$script); * Closes class. * * @param string $script + * * @return void */ abstract protected function addClassClose(&$script); diff --git a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php index 74cf371269..98f75176c5 100644 --- a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php @@ -16,7 +16,7 @@ * Base class for object-building classes. * * This class is designed so that it can be extended the "standard" ObjectBuilder - * and ComplexOMObjectBuilder. Hence, this class should not have any actual + * and ComplexOMObjectBuilder. Hence, this class should not have any actual * template code in it -- simply basic logic & utility methods. * * @author Hans Lellelid @@ -27,7 +27,9 @@ abstract class AbstractObjectBuilder extends AbstractOMBuilder * Adds the getter methods for the column values. * This is here because it is probably generic enough to apply to templates being generated * in different PHP versions. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addColumnAccessorMethods(&$script) @@ -37,19 +39,20 @@ protected function addColumnAccessorMethods(&$script) foreach ($table->getColumns() as $col) { $type = $col->getType(); // if they're not using the DateTime class than we will generate "compatibility" accessor method - if (PropelTypes::DATE === $type - || PropelTypes::TIME === $type - || PropelTypes::TIMESTAMP === $type + if ( + $type === PropelTypes::DATE + || $type === PropelTypes::TIME + || $type === PropelTypes::TIMESTAMP ) { $this->addTemporalAccessor($script, $col); - } elseif (PropelTypes::OBJECT === $type) { + } elseif ($type === PropelTypes::OBJECT) { $this->addObjectAccessor($script, $col); - } elseif (PropelTypes::PHP_ARRAY === $type) { + } elseif ($type === PropelTypes::PHP_ARRAY) { $this->addArrayAccessor($script, $col); if ($col->isNamePlural()) { $this->addHasArrayElement($script, $col); } - } elseif (PropelTypes::JSON === $type) { + } elseif ($type === PropelTypes::JSON) { $this->addJsonAccessor($script, $col); } elseif ($col->isEnumType()) { $this->addEnumAccessor($script, $col); @@ -75,29 +78,31 @@ protected function addColumnAccessorMethods(&$script) * Adds the mutator (setter) methods for setting column values. * This is here because it is probably generic enough to apply to templates being generated * in different PHP versions. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addColumnMutatorMethods(&$script) { foreach ($this->getTable()->getColumns() as $col) { - if (PropelTypes::OBJECT === $col->getType()) { + if ($col->getType() === PropelTypes::OBJECT) { $this->addObjectMutator($script, $col); } elseif ($col->isLobType()) { $this->addLobMutator($script, $col); } elseif ( - PropelTypes::DATE === $col->getType() - || PropelTypes::TIME === $col->getType() - || PropelTypes::TIMESTAMP === $col->getType() + $col->getType() === PropelTypes::DATE + || $col->getType() === PropelTypes::TIME + || $col->getType() === PropelTypes::TIMESTAMP ) { $this->addTemporalMutator($script, $col); - } elseif (PropelTypes::PHP_ARRAY === $col->getType()) { + } elseif ($col->getType() === PropelTypes::PHP_ARRAY) { $this->addArrayMutator($script, $col); if ($col->isNamePlural()) { $this->addAddArrayElement($script, $col); $this->addRemoveArrayElement($script, $col); } - } elseif (PropelTypes::JSON === $col->getType()) { + } elseif ($col->getType() === PropelTypes::JSON) { $this->addJsonMutator($script, $col); } elseif ($col->isEnumType()) { $this->addEnumMutator($script, $col); @@ -115,7 +120,6 @@ protected function addColumnMutatorMethods(&$script) } } - /** * Gets the baseClass path if specified for table/db. * @@ -166,7 +170,7 @@ protected function isAddGenericAccessors() protected function hasDefaultValues() { foreach ($this->getTable()->getColumns() as $col) { - if (null !== $col->getDefaultValue()) { + if ($col->getDefaultValue() !== null) { return true; } } @@ -180,7 +184,7 @@ protected function hasDefaultValues() * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string $modifier * - * @return boolean + * @return bool */ public function hasBehaviorModifier($hookName, $modifier = '') { @@ -189,19 +193,23 @@ public function hasBehaviorModifier($hookName, $modifier = '') /** * Checks whether any registered behavior on that table has a modifier for a hook + * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" - * @param string $script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param string $tab + * * @return void */ - public function applyBehaviorModifier($hookName, &$script, $tab = " ") + public function applyBehaviorModifier($hookName, &$script, $tab = ' ') { $this->applyBehaviorModifierBase($hookName, 'ObjectBuilderModifier', $script, $tab); } /** * Checks whether any registered behavior content creator on that table exists a contentName + * * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassName" + * * @return string|null */ public function getBehaviorContent($contentName) diff --git a/src/Propel/Generator/Builder/Om/ClassTools.php b/src/Propel/Generator/Builder/Om/ClassTools.php index c68334065c..32f8bbb776 100644 --- a/src/Propel/Generator/Builder/Om/ClassTools.php +++ b/src/Propel/Generator/Builder/Om/ClassTools.php @@ -19,10 +19,11 @@ */ class ClassTools { - /** * Gets just classname, given a dot-path to class. - * @param string $qualifiedName + * + * @param string $qualifiedName + * * @return string */ public static function classname($qualifiedName) @@ -34,22 +35,22 @@ public static function classname($qualifiedName) } else { return $qualifiedName; // there is no '.' in the qualified name } - } /** * This method replaces the `getFilePath()` method in OMBuilder as we consider `$path` as - * a real path instead of a dot-notation value. `$path` is generated by the `getPackagePath()` + * a real path instead of a dot-notation value. `$path` is generated by the `getPackagePath()` * method. * - * @param string $path path to class or to package prefix. - * @param string $classname class name - * @param string $extension The extension to use on the file. + * @param string $path path to class or to package prefix. + * @param string|null $classname class name + * @param string $extension The extension to use on the file. + * * @return string The constructed file path. */ public static function createFilePath($path, $classname = null, $extension = '.php') { - if (null === $classname) { + if ($classname === null) { return $path . $extension; } @@ -97,7 +98,7 @@ public static function getPhpReservedWords() 'require_once', 'return', 'static', 'switch', 'unset', 'use', 'var', 'while', '__FUNCTION__', '__CLASS__', '__METHOD__', '__DIR__', '__NAMESPACE__', 'final', 'php_user_filter', 'interface', 'implements', 'extends', 'public', 'protected', 'private', 'abstract', 'clone', 'try', 'catch', - 'throw', 'this', 'namespace' + 'throw', 'this', 'namespace', ]; } diff --git a/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php index 3483c0c257..4ac5a062aa 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php @@ -20,9 +20,9 @@ */ class ExtensionObjectBuilder extends AbstractObjectBuilder { - /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassName() @@ -32,7 +32,9 @@ public function getUnprefixedClassName() /** * Adds class phpdoc comment and opening of class. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClassOpen(&$script) @@ -63,7 +65,7 @@ protected function addClassOpen(&$script) * long as it does not already exist in the output directory. */"; } - $script .= PHP_EOL . ($table->isAbstract() ? "abstract " : "")."class ".$this->getUnqualifiedClassName()." extends $baseClassName + $script .= PHP_EOL . ($table->isAbstract() ? 'abstract ' : '') . 'class ' . $this->getUnqualifiedClassName() . " extends $baseClassName { "; } @@ -75,6 +77,7 @@ protected function addClassOpen(&$script) * if you want to change that behavior. * * @see ObjectBuilder::addClassBody() + * * @return void */ protected function addClassBody(&$script) @@ -83,7 +86,9 @@ protected function addClassBody(&$script) /** * Closes class. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClassClose(&$script) @@ -91,6 +96,6 @@ protected function addClassClose(&$script) $script .= " } "; - $this->applyBehaviorModifier('extensionObjectFilter', $script, ""); + $this->applyBehaviorModifier('extensionObjectFilter', $script, ''); } } diff --git a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php index 38dac25803..30634edca9 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php @@ -20,9 +20,9 @@ */ class ExtensionQueryBuilder extends AbstractOMBuilder { - /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassName() @@ -32,7 +32,9 @@ public function getUnprefixedClassName() /** * Adds class phpdoc comment and opening of class. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClassOpen(&$script) @@ -64,7 +66,7 @@ protected function addClassOpen(&$script) */"; } $script .= " -class ".$this->getUnqualifiedClassName()." extends $baseClassName +class " . $this->getUnqualifiedClassName() . " extends $baseClassName { "; } @@ -76,16 +78,18 @@ class ".$this->getUnqualifiedClassName()." extends $baseClassName * if you want to change that behavior. * * @see QueryBuilder::addClassBody() + * * @return void */ - protected function addClassBody(&$script) { } /** * Closes class. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClassClose(&$script) @@ -93,13 +97,15 @@ protected function addClassClose(&$script) $script .= " } "; - $this->applyBehaviorModifier('extensionQueryFilter', $script, ""); + $this->applyBehaviorModifier('extensionQueryFilter', $script, ''); } /** * Checks whether any registered behavior on that table has a modifier for a hook - * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" - * @return boolean + * + * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" + * + * @return bool */ public function hasBehaviorModifier($hookName, $modifier = '') { @@ -108,24 +114,27 @@ public function hasBehaviorModifier($hookName, $modifier = '') /** * Checks whether any registered behavior on that table has a modifier for a hook + * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" - * @param string $script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param string $tab + * * @return void */ - public function applyBehaviorModifier($hookName, &$script, $tab = " ") + public function applyBehaviorModifier($hookName, &$script, $tab = ' ') { $this->applyBehaviorModifierBase($hookName, 'QueryBuilderModifier', $script, $tab); } /** * Checks whether any registered behavior content creator on that table exists a contentName + * * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassName" + * * @return string|null */ public function getBehaviorContent($contentName) { return $this->getBehaviorContentBase($contentName, 'QueryBuilderModifier'); } - } diff --git a/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php index becf9e51cf..c4c3147c7e 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php @@ -10,8 +10,8 @@ namespace Propel\Generator\Builder\Om; -use Propel\Generator\Model\Inheritance; use Propel\Generator\Exception\BuildException; +use Propel\Generator\Model\Inheritance; /** * Generates the empty stub query class for use with single table inheritance. @@ -25,7 +25,6 @@ class ExtensionQueryInheritanceBuilder extends AbstractOMBuilder { /** * The current child "object" we are operating on. - * */ protected $child; @@ -52,7 +51,8 @@ public function getPackage() /** * Set the child object that we're operating on currently. * - * @param Inheritance $child Inheritance + * @param \Propel\Generator\Model\Inheritance $child Inheritance + * * @return void */ public function setChild(Inheritance $child) @@ -63,13 +63,14 @@ public function setChild(Inheritance $child) /** * Returns the child object we're operating on currently. * - * @return Inheritance - * @throws BuildException + * @throws \Propel\Generator\Exception\BuildException + * + * @return \Propel\Generator\Model\Inheritance */ public function getChild() { if (!$this->child) { - throw new BuildException("The MultiExtendObjectBuilder needs to be told which child class to build (via setChild() method) before it can build the stub class."); + throw new BuildException('The MultiExtendObjectBuilder needs to be told which child class to build (via setChild() method) before it can build the stub class.'); } return $this->child; @@ -79,6 +80,7 @@ public function getChild() * Adds class phpdoc comment and opening of class. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClassOpen(&$script) @@ -113,7 +115,7 @@ protected function addClassOpen(&$script) */"; } $script .= " -class " .$this->getUnqualifiedClassName() . " extends " . $baseClassName . " +class " . $this->getUnqualifiedClassName() . ' extends ' . $baseClassName . " { "; } @@ -124,19 +126,21 @@ class " .$this->getUnqualifiedClassName() . " extends " . $baseClassName . " * By default there are no methods for the empty stub classes; override this method * if you want to change that behavior. * - * @param string $script * @see ObjectBuilder::addClassBody() + * + * @param string $script + * * @return void */ protected function addClassBody(&$script) { - } /** * Closes class. * * @param string $script + * * @return void */ protected function addClassClose(&$script) diff --git a/src/Propel/Generator/Builder/Om/InterfaceBuilder.php b/src/Propel/Generator/Builder/Om/InterfaceBuilder.php index da7f42764a..94be15ec46 100644 --- a/src/Propel/Generator/Builder/Om/InterfaceBuilder.php +++ b/src/Propel/Generator/Builder/Om/InterfaceBuilder.php @@ -34,6 +34,7 @@ public function getUnprefixedClassName() * Adds class phpdoc comment and opening of class. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClassOpen(&$script) @@ -61,7 +62,7 @@ protected function addClassOpen(&$script) * application requirements. This interface will only be generated as * long as it does not already exist in the output directory. */ -interface ".$this->getUnqualifiedClassName()." +interface " . $this->getUnqualifiedClassName() . " { "; } @@ -73,6 +74,7 @@ interface ".$this->getUnqualifiedClassName()." * if you want to change that behavior. * * @see ObjectBuilder::addClassBody() + * * @return void */ protected function addClassBody(&$script) @@ -82,7 +84,9 @@ protected function addClassBody(&$script) /** * Closes class. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClassClose(&$script) @@ -91,5 +95,4 @@ protected function addClassClose(&$script) } // " . $this->getUnqualifiedClassName() . " "; } - } // ExtensionObjectBuilder diff --git a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php index a04ddadb9c..5d928667c4 100644 --- a/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/MultiExtendObjectBuilder.php @@ -27,7 +27,7 @@ class MultiExtendObjectBuilder extends AbstractObjectBuilder /** * The current child "object" we are operating on. * - * @var Inheritance|null $child + * @var \Propel\Generator\Model\Inheritance|null $child */ private $child; @@ -54,7 +54,8 @@ public function getPackage() /** * Sets the child object that we're operating on currently. * - * @param Inheritance $child Inheritance + * @param \Propel\Generator\Model\Inheritance $child Inheritance + * * @return void */ public function setChild(Inheritance $child) @@ -65,13 +66,14 @@ public function setChild(Inheritance $child) /** * Returns the child object we're operating on currently. * - * @return Inheritance - * @throws BuildException + * @throws \Propel\Generator\Exception\BuildException + * + * @return \Propel\Generator\Model\Inheritance */ public function getChild() { if (!$this->child) { - throw new BuildException("The MultiExtendObjectBuilder needs to be told which child class to build (via setChild() method) before it can build the stub class."); + throw new BuildException('The MultiExtendObjectBuilder needs to be told which child class to build (via setChild() method) before it can build the stub class.'); } return $this->child; @@ -105,6 +107,7 @@ protected function getParentClassName() * Adds class phpdoc comment and opening of class. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClassOpen(&$script) @@ -138,7 +141,7 @@ protected function addClassOpen(&$script) * * $now *"; - } + } $script .= " * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -146,7 +149,7 @@ protected function addClassOpen(&$script) */"; } $script .= " -class ".$this->getUnqualifiedClassName()." extends ".$this->getParentClassName()." +class " . $this->getUnqualifiedClassName() . ' extends ' . $this->getParentClassName() . " { "; } @@ -157,8 +160,10 @@ class ".$this->getUnqualifiedClassName()." extends ".$this->getParentClassName() * By default there are no methods for the empty stub classes; override this * method if you want to change that behavior. * - * @param string $script * @see ObjectBuilder::addClassBody() + * + * @param string $script + * * @return void */ protected function addClassBody(&$script) @@ -167,17 +172,17 @@ protected function addClassBody(&$script) $col = $child->getColumn(); $cfc = $col->getPhpName(); - $const = "CLASSKEY_".$child->getConstantSuffix(); + $const = 'CLASSKEY_' . $child->getConstantSuffix(); $script .= " /** - * Constructs a new ".$this->getChild()->getClassName()." class, setting the ".$col->getName()." column to ".$this->getTableMapClassName()."::$const. + * Constructs a new " . $this->getChild()->getClassName() . ' class, setting the ' . $col->getName() . ' column to ' . $this->getTableMapClassName() . "::$const. */ public function __construct() {"; $script .= " parent::__construct(); - \$this->set$cfc(".$this->getTableMapClassName()."::CLASSKEY_".$child->getConstantSuffix()."); + \$this->set$cfc(" . $this->getTableMapClassName() . '::CLASSKEY_' . $child->getConstantSuffix() . "); } "; } @@ -186,6 +191,7 @@ public function __construct() * Closes class. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClassClose(&$script) diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index 46c81beb97..8a708980f3 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -10,6 +10,8 @@ namespace Propel\Generator\Builder\Om; +use DateTime; +use Exception; use Propel\Common\Util\SetColumnConverter; use Propel\Generator\Exception\EngineException; use Propel\Generator\Model\Column; @@ -35,7 +37,6 @@ */ class ObjectBuilder extends AbstractObjectBuilder { - /** * Returns the package for the base object classes. * @@ -43,14 +44,15 @@ class ObjectBuilder extends AbstractObjectBuilder */ public function getPackage() { - return parent::getPackage() . ".Base"; + return parent::getPackage() . '.Base'; } /** * Returns the namespace for the base class. * - * @return string * @see Propel\Generator\Builder\Om.AbstractOMBuilder::getNamespace() + * + * @return string */ public function getNamespace() { @@ -72,7 +74,7 @@ public function getDefaultKeyType() { $defaultKeyType = $this->getBuildProperty('generator.objectModel.defaultKeyType') ? $this->getBuildProperty('generator.objectModel.defaultKeyType') : 'phpName'; - return "TYPE_".strtoupper($defaultKeyType); + return 'TYPE_' . strtoupper($defaultKeyType); } /** @@ -93,6 +95,8 @@ public function getUnprefixedClassName() * and will throw exceptions for errors that will definitely cause * problems. * + * @throws \Propel\Generator\Exception\EngineException + * * @return void */ protected function validateModel() @@ -117,7 +121,7 @@ protected function validateModel() $intersect = array_intersect($colPhpNames, $fkPhpNames); if (!empty($intersect)) { - throw new EngineException("One or more of your column names for [" . $table->getName() . "] table conflict with foreign key names (" . implode(", ", $intersect) . ")"); + throw new EngineException('One or more of your column names for [' . $table->getName() . '] table conflict with foreign key names (' . implode(', ', $intersect) . ')'); } // Check foreign keys to see if there are any foreign keys that @@ -135,7 +139,8 @@ protected function validateModel() /** * Returns the appropriate formatter (from platform) for a date/time column. * - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return string */ protected function getTemporalFormatter(Column $column) @@ -156,31 +161,36 @@ protected function getTemporalFormatter(Column $column) * Returns the type-casted and stringified default value for the specified * Column. This only works for scalar default values currently. * - * @param Column $column - * @throws EngineException + * @param \Propel\Generator\Model\Column $column + * + * @throws \Propel\Generator\Exception\EngineException + * * @return string */ protected function getDefaultValueString(Column $column) { $defaultValue = var_export(null, true); $val = $column->getPhpDefaultValue(); - if (null === $val) { + if ($val === null) { return $defaultValue; } if ($column->isTemporalType()) { $fmt = $this->getTemporalFormatter($column); try { - if (!($this->getPlatform() instanceof MysqlPlatform && - ($val === '0000-00-00 00:00:00' || $val === '0000-00-00'))) { + if ( + !($this->getPlatform() instanceof MysqlPlatform && + ($val === '0000-00-00 00:00:00' || $val === '0000-00-00')) + ) { // while technically this is not a default value of NULL, // this seems to be closest in meaning. - $defDt = new \DateTime($val); + $defDt = new DateTime($val); $defaultValue = var_export($defDt->format($fmt), true); } - } catch (\Exception $exception) { + } catch (Exception $exception) { // prevent endless loop when timezone is undefined date_default_timezone_set('America/Los_Angeles'); + throw new EngineException(sprintf('Unable to parse default temporal value "%s" for column "%s"', $column->getDefaultValueString(), $column->getFullyQualifiedName()), 0, $exception); } } elseif ($column->isEnumType()) { @@ -195,11 +205,11 @@ protected function getDefaultValueString(Column $column) settype($val, $column->getPhpType()); $defaultValue = var_export($val, true); } elseif ($column->isPhpObjectType()) { - $defaultValue = 'new '.$column->getPhpType().'(' . var_export($val, true) . ')'; + $defaultValue = 'new ' . $column->getPhpType() . '(' . var_export($val, true) . ')'; } elseif ($column->isPhpArrayType()) { $defaultValue = var_export($val, true); } else { - throw new EngineException("Cannot get default value string for " . $column->getFullyQualifiedName()); + throw new EngineException('Cannot get default value string for ' . $column->getFullyQualifiedName()); } return $defaultValue; @@ -209,6 +219,7 @@ protected function getDefaultValueString(Column $column) * Adds class phpdoc comment and opening of class. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClassOpen(&$script) @@ -217,9 +228,11 @@ protected function addClassOpen(&$script) $tableName = $table->getName(); $tableDesc = $table->getDescription(); - if (null !== ($parentClass = $this->getBehaviorContent('parentClass')) || - null !== ($parentClass = ClassTools::classname($this->getBaseClass()))) { - $parentClass = ' extends '.$parentClass; + if ( + ($parentClass = $this->getBehaviorContent('parentClass')) !== null || + ($parentClass = ClassTools::classname($this->getBaseClass())) !== null + ) { + $parentClass = ' extends ' . $parentClass; } if ($this->getBuildProperty('generator.objectModel.addClassLevelComment')) { @@ -238,15 +251,15 @@ protected function addClassOpen(&$script) *"; } $script .= " - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */"; } $script .= " -abstract class ".$this->getUnqualifiedClassName().$parentClass." implements ActiveRecordInterface "; +abstract class " . $this->getUnqualifiedClassName() . $parentClass . ' implements ActiveRecordInterface '; if ($interface = $this->getInterface()) { - $script .= ", Child" . ClassTools::classname($interface); + $script .= ', Child' . ClassTools::classname($interface); if ($interface !== ClassTools::classname($interface)) { $this->declareClass($interface); } else { @@ -262,8 +275,10 @@ abstract class ".$this->getUnqualifiedClassName().$parentClass." implements Acti * Specifies the methods that are added as part of the basic OM class. * This can be overridden by subclasses that wish to add more methods. * - * @param string $script * @see ObjectBuilder::addClassBody() + * + * @param string $script + * * @return void */ protected function addClassBody(&$script) @@ -302,7 +317,6 @@ protected function addClassBody(&$script) } if ($table->hasCrossForeignKeys()) { - /* @var $refFK ForeignKey */ foreach ($table->getCrossFks() as $crossFKs) { $this->addCrossScheduledForDeletionAttribute($script, $crossFKs); } @@ -364,7 +378,7 @@ protected function addClassBody(&$script) $this->addPrimaryString($script); // apply behaviors - $this->applyBehaviorModifier('objectMethods', $script, " "); + $this->applyBehaviorModifier('objectMethods', $script, ' '); if ($this->getBuildProperty('generator.objectModel.addHooks')) { $this->addHookMethods($script); @@ -377,6 +391,7 @@ protected function addClassBody(&$script) * Closes class. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClassClose(&$script) @@ -384,13 +399,14 @@ protected function addClassClose(&$script) $script .= " } "; - $this->applyBehaviorModifier('objectFilter', $script, ""); + $this->applyBehaviorModifier('objectFilter', $script, ''); } /** * Adds any constants to the class. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addConstants(&$script) @@ -407,6 +423,7 @@ protected function addConstants(&$script) * Adds class attributes. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addAttributes(&$script) @@ -438,24 +455,24 @@ protected function addAttributes(&$script) $this->addAlreadyInSaveAttribute($script); // apply behaviors - $this->applyBehaviorModifier('objectAttributes', $script, " "); + $this->applyBehaviorModifier('objectAttributes', $script, ' '); } /** * Adds variables that store column values. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addColumnAttributes(&$script) { - $table = $this->getTable(); foreach ($table->getColumns() as $col) { $this->addColumnAttributeComment($script, $col); $this->addColumnAttributeDeclaration($script, $col); - if ($col->isLazyLoad() ) { + if ($col->isLazyLoad()) { $this->addColumnAttributeLoaderComment($script, $col); $this->addColumnAttributeLoaderDeclaration($script, $col); } @@ -473,7 +490,8 @@ protected function addColumnAttributes(&$script) * Adds comment about the attribute (variable) that stores column values. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addColumnAttributeComment(&$script, Column $column) @@ -488,14 +506,14 @@ protected function addColumnAttributeComment(&$script, Column $column) $script .= " /** * The value for the $clo field. - * ".$column->getDescription(); + * " . $column->getDescription(); if ($column->getDefaultValue()) { if ($column->getDefaultValue()->isExpression()) { $script .= " - * Note: this column has a database default value of: (expression) ".$column->getDefaultValue()->getValue(); + * Note: this column has a database default value of: (expression) " . $column->getDefaultValue()->getValue(); } else { $script .= " - * Note: this column has a database default value of: ". $this->getDefaultValueString($column); + * Note: this column has a database default value of: " . $this->getDefaultValueString($column); } } $script .= " @@ -507,7 +525,8 @@ protected function addColumnAttributeComment(&$script, Column $column) * Adds the declaration of a column value storage attribute. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addColumnAttributeDeclaration(&$script, Column $column) @@ -523,7 +542,8 @@ protected function addColumnAttributeDeclaration(&$script, Column $column) * has been loaded. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addColumnAttributeLoaderComment(&$script, Column $column) @@ -542,14 +562,15 @@ protected function addColumnAttributeLoaderComment(&$script, Column $column) * loaded state. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addColumnAttributeLoaderDeclaration(&$script, Column $column) { $clo = $column->getLowercasedName(); $script .= " - protected \$".$clo."_isLoaded = false; + protected \$" . $clo . "_isLoaded = false; "; } @@ -557,7 +578,8 @@ protected function addColumnAttributeLoaderDeclaration(&$script, Column $column) * Adds the comment about the serialized attribute. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addColumnAttributeUnserializedComment(&$script, Column $column) @@ -575,12 +597,13 @@ protected function addColumnAttributeUnserializedComment(&$script, Column $colum * Adds the declaration of the serialized attribute. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addColumnAttributeUnserializedDeclaration(&$script, Column $column) { - $clo = $column->getLowercasedName() . "_unserialized"; + $clo = $column->getLowercasedName() . '_unserialized'; $script .= " protected \$" . $clo . "; "; @@ -588,12 +611,13 @@ protected function addColumnAttributeUnserializedDeclaration(&$script, Column $c /** * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addColumnAttributeConvertedDeclaration(&$script, Column $column) { - $clo = $column->getLowercasedName() . "_converted"; + $clo = $column->getLowercasedName() . '_converted'; $script .= " protected \$" . $clo . "; "; @@ -603,6 +627,7 @@ protected function addColumnAttributeConvertedDeclaration(&$script, Column $colu * Adds the constructor for this object. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addConstructor(&$script) @@ -619,13 +644,14 @@ protected function addConstructor(&$script) * Adds the comment for the constructor * * @param string $script The script will be modified in this method. + * * @return void */ protected function addConstructorComment(&$script) { $script .= " /** - * Initializes internal state of ".$this->getQualifiedClassName()." object."; + * Initializes internal state of " . $this->getQualifiedClassName() . ' object.'; if ($this->hasDefaultValues()) { $script .= " * @see applyDefaults()"; @@ -638,6 +664,7 @@ protected function addConstructorComment(&$script) * Adds the function declaration for the constructor. * * @param string $script + * * @return void */ protected function addConstructorOpen(&$script) @@ -651,6 +678,7 @@ public function __construct() * Adds the function body for the constructor. * * @param string $script + * * @return void */ protected function addConstructorBody(&$script) @@ -663,6 +691,7 @@ protected function addConstructorBody(&$script) * Adds the function close for the constructor. * * @param string $script + * * @return void */ protected function addConstructorClose(&$script) @@ -676,6 +705,7 @@ protected function addConstructorClose(&$script) * Adds the base object functions. * * @param string $script + * * @return void */ protected function addBaseObjectMethods(&$script) @@ -687,6 +717,7 @@ protected function addBaseObjectMethods(&$script) * Adds the base object hook functions. * * @param string $script + * * @return void */ protected function addHookMethods(&$script) @@ -694,16 +725,18 @@ protected function addHookMethods(&$script) $hooks = []; foreach (['pre', 'post'] as $hook) { foreach (['Insert', 'Update', 'Save', 'Delete'] as $action) { - $hooks[$hook.$action] = false === strpos($script, "function $hook.$action("); + $hooks[$hook . $action] = strpos($script, "function $hook.$action(") === false; } } - if (null !== $this->getBehaviorContent('parentClass') || - null !== ClassTools::classname($this->getBaseClass())) { - $hooks['hasBaseClass'] = true; + if ( + $this->getBehaviorContent('parentClass') !== null || + ClassTools::classname($this->getBaseClass()) !== null + ) { + $hooks['hasBaseClass'] = true; } else { - $hooks['hasBaseClass'] = false; - } + $hooks['hasBaseClass'] = false; + } $script .= $this->renderTemplate('baseObjectMethodHook', $hooks); } @@ -712,6 +745,7 @@ protected function addHookMethods(&$script) * Adds the applyDefaults() method, which is called from the constructor. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addApplyDefaultValues(&$script) @@ -726,6 +760,7 @@ protected function addApplyDefaultValues(&$script) * Adds the comment for the applyDefaults method. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addApplyDefaultValuesComment(&$script) @@ -743,6 +778,7 @@ protected function addApplyDefaultValuesComment(&$script) * Adds the function declaration for the applyDefaults method. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addApplyDefaultValuesOpen(&$script) @@ -756,6 +792,7 @@ public function applyDefaultValues() * Adds the function body of the applyDefault method. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addApplyDefaultValuesBody(&$script) @@ -773,16 +810,16 @@ protected function addApplyDefaultValuesBody(&$script) } foreach ($colsWithDefaults as $column) { - /** @var Column $column */ + /** @var \Propel\Generator\Model\Column $column */ $clo = $column->getLowercasedName(); $defaultValue = $this->getDefaultValueString($column); if ($column->isTemporalType()) { $dateTimeClass = $this->getDateTimeClass($column); $script .= " - \$this->".$clo." = PropelDateTime::newInstance($defaultValue, null, '$dateTimeClass');"; + \$this->" . $clo . " = PropelDateTime::newInstance($defaultValue, null, '$dateTimeClass');"; } else { $script .= " - \$this->".$clo." = $defaultValue;"; + \$this->" . $clo . " = $defaultValue;"; } } } @@ -791,6 +828,7 @@ protected function addApplyDefaultValuesBody(&$script) * Adds the function close for the applyDefaults method. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addApplyDefaultValuesClose(&$script) @@ -804,7 +842,8 @@ protected function addApplyDefaultValuesClose(&$script) * Adds a date/time/timestamp getter method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addTemporalAccessor(&$script, Column $column) @@ -819,7 +858,8 @@ protected function addTemporalAccessor(&$script, Column $column) * Adds the comment for a temporal accessor. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function addTemporalAccessorComment(&$script, Column $column) @@ -849,7 +889,7 @@ public function addTemporalAccessorComment(&$script, Column $column) * @param string|null \$format The date/time format string (either date()-style or strftime()-style). * If format is NULL, then the raw $dateTimeClass object will be returned. * - * @return string|$dateTimeClass Formatted date/time value as string or $dateTimeClass object (if format is NULL), NULL if column is NULL" .($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : '')." + * @return string|$dateTimeClass Formatted date/time value as string or $dateTimeClass object (if format is NULL), NULL if column is NULL" . ($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : '') . " * * @throws PropelException - if unable to parse/validate the date/time value. */"; @@ -859,7 +899,8 @@ public function addTemporalAccessorComment(&$script, Column $column) * Adds the function declaration for a temporal accessor. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function addTemporalAccessorOpen(&$script, Column $column) @@ -883,9 +924,9 @@ public function addTemporalAccessorOpen(&$script, Column $column) } $script .= " - ".$visibility." function get$cfc(\$format = ".var_export($defaultfmt, true).""; + " . $visibility . " function get$cfc(\$format = " . var_export($defaultfmt, true) . ''; if ($column->isLazyLoad()) { - $script .= ", \$con = null"; + $script .= ', $con = null'; } $script .= ") {"; @@ -894,7 +935,8 @@ public function addTemporalAccessorOpen(&$script, Column $column) /** * Gets accessor lazy loaded snippets. * - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return string */ protected function getAccessorLazyLoadSnippet(Column $column) @@ -921,7 +963,8 @@ protected function getAccessorLazyLoadSnippet(Column $column) * Adds the body of the temporal accessor. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addTemporalAccessorBody(&$script, Column $column) @@ -962,6 +1005,7 @@ protected function addTemporalAccessorBody(&$script, Column $column) * Adds the body of the temporal accessor. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addTemporalAccessorClose(&$script) @@ -975,7 +1019,8 @@ protected function addTemporalAccessorClose(&$script) * Adds an object getter method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addObjectAccessor(&$script, Column $column) @@ -990,13 +1035,14 @@ protected function addObjectAccessor(&$script, Column $column) * Adds the function body for an object accessor method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addObjectAccessorBody(&$script, Column $column) { $clo = $column->getLowercasedName(); - $cloUnserialized = $clo.'_unserialized'; + $cloUnserialized = $clo . '_unserialized'; if ($column->isLazyLoad()) { $script .= $this->getAccessorLazyLoadSnippet($column); } @@ -1029,17 +1075,18 @@ protected function addJsonAccessor(&$script, Column $column) * Add the comment for a json accessor method (a getter). * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function addJsonAccessorComment(&$script, Column $column) { - $clo=$column->getLowercasedName(); + $clo = $column->getLowercasedName(); $script .= " /** * Get the [$clo] column value. - * ".$column->getDescription() ." + * " . $column->getDescription() . " * @param bool \$asArray Returns the JSON data as array instead of object "; if ($column->isLazyLoad()) { @@ -1055,7 +1102,8 @@ public function addJsonAccessorComment(&$script, Column $column) * Adds the function declaration for a JSON accessor. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function addJsonAccessorOpen(&$script, Column $column) @@ -1064,9 +1112,9 @@ public function addJsonAccessorOpen(&$script, Column $column) $visibility = $column->getAccessorVisibility(); $script .= " - ".$visibility." function get$cfc(\$asArray = true"; + " . $visibility . " function get$cfc(\$asArray = true"; if ($column->isLazyLoad()) { - $script .= ", ConnectionInterface \$con = null"; + $script .= ', ConnectionInterface $con = null'; } $script .= ") @@ -1090,7 +1138,8 @@ protected function addJsonAccessorBody(&$script, Column $column) * Adds an array getter method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addArrayAccessor(&$script, Column $column) @@ -1105,13 +1154,14 @@ protected function addArrayAccessor(&$script, Column $column) * Adds the function body for an array accessor method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addArrayAccessorBody(&$script, Column $column) { $clo = $column->getLowercasedName(); - $cloUnserialized = $clo.'_unserialized'; + $cloUnserialized = $clo . '_unserialized'; if ($column->isLazyLoad()) { $script .= $this->getAccessorLazyLoadSnippet($column); } @@ -1132,7 +1182,8 @@ protected function addArrayAccessorBody(&$script, Column $column) * Adds a boolean isser method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addBooleanAccessor(&$script, Column $column) @@ -1151,7 +1202,8 @@ protected function addBooleanAccessor(&$script, Column $column) /** * Returns the name to be used as boolean accessor name * - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return string */ protected static function getBooleanAccessorName(Column $column) @@ -1160,6 +1212,7 @@ protected static function getBooleanAccessorName(Column $column) if (!preg_match('/^(?:is|has)(?=[A-Z])/', $name)) { $name = 'is' . ucfirst($name); } + return $name; } @@ -1167,7 +1220,8 @@ protected static function getBooleanAccessorName(Column $column) * Adds the function declaration for a boolean accessor. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function addBooleanAccessorOpen(&$script, Column $column) @@ -1176,9 +1230,9 @@ public function addBooleanAccessorOpen(&$script, Column $column) $visibility = $column->getAccessorVisibility(); $script .= " - ".$visibility." function $name("; + " . $visibility . " function $name("; if ($column->isLazyLoad()) { - $script .= "ConnectionInterface \$con = null"; + $script .= 'ConnectionInterface $con = null'; } $script .= ") @@ -1189,7 +1243,8 @@ public function addBooleanAccessorOpen(&$script, Column $column) * Adds the function body for a boolean accessor method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addBooleanAccessorBody(&$script, Column $column) @@ -1203,14 +1258,15 @@ protected function addBooleanAccessorBody(&$script, Column $column) $script .= '$con'; } - $script .= ");"; + $script .= ');'; } /** * Adds an enum getter method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addEnumAccessor(&$script, Column $column) @@ -1225,17 +1281,18 @@ protected function addEnumAccessor(&$script, Column $column) * Add the comment for an enum accessor method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function addEnumAccessorComment(&$script, Column $column) { - $clo=$column->getLowercasedName(); + $clo = $column->getLowercasedName(); $script .= " /** * Get the [$clo] column value. - * ".$column->getDescription(); + * " . $column->getDescription(); if ($column->isLazyLoad()) { $script .= " * @param ConnectionInterface An optional ConnectionInterface connection to use for fetching this lazy-loaded column."; @@ -1250,7 +1307,8 @@ public function addEnumAccessorComment(&$script, Column $column) * Adds the function body for an enum accessor method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addEnumAccessorBody(&$script, Column $column) @@ -1264,7 +1322,7 @@ protected function addEnumAccessorBody(&$script, Column $column) if (null === \$this->$clo) { return null; } - \$valueSet = " . $this->getTableMapClassName() . "::getValueSet(" . $this->getColumnConstant($column) . "); + \$valueSet = " . $this->getTableMapClassName() . '::getValueSet(' . $this->getColumnConstant($column) . "); if (!isset(\$valueSet[\$this->$clo])) { throw new PropelException('Unknown stored enum key: ' . \$this->$clo); } @@ -1276,7 +1334,8 @@ protected function addEnumAccessorBody(&$script, Column $column) * Adds a SET column getter method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addSetAccessor(&$script, Column $column) @@ -1291,7 +1350,8 @@ protected function addSetAccessor(&$script, Column $column) * Add the comment for a SET column accessor method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function addSetAccessorComment(&$script, Column $column) @@ -1316,7 +1376,8 @@ public function addSetAccessorComment(&$script, Column $column) * Adds the function body for a SET column accessor method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addSetAccessorBody(&$script, Column $column) @@ -1336,7 +1397,7 @@ protected function addSetAccessorBody(&$script, Column $column) \$this->$cloConverted = array(); } if (!\$this->$cloConverted && null !== \$this->$clo) { - \$valueSet = " . $this->getTableMapClassName() . "::getValueSet(" . $this->getColumnConstant($column) . "); + \$valueSet = " . $this->getTableMapClassName() . '::getValueSet(' . $this->getColumnConstant($column) . "); try { \$this->$cloConverted = SetColumnConverter::convertIntToArray(\$this->$clo, \$valueSet); } catch (SetColumnConverterException \$e) { @@ -1347,12 +1408,12 @@ protected function addSetAccessorBody(&$script, Column $column) return \$this->$cloConverted;"; } - /** * Adds a tester method for an array column. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addHasArrayElement(&$script, Column $column) @@ -1366,7 +1427,7 @@ protected function addHasArrayElement(&$script, Column $column) /** * Test the presence of a value in the [$clo] $columnType column value. * @param mixed \$value - * ".$column->getDescription(); + * " . $column->getDescription(); if ($column->isLazyLoad()) { $script .= " * @param ConnectionInterface \$con An optional ConnectionInterface connection to use for fetching this lazy-loaded column."; @@ -1376,14 +1437,14 @@ protected function addHasArrayElement(&$script, Column $column) */ $visibility function has$singularPhpName(\$value"; if ($column->isLazyLoad()) { - $script .= ", ConnectionInterface \$con = null"; + $script .= ', ConnectionInterface $con = null'; } $script .= ") { return in_array(\$value, \$this->get$cfc("; if ($column->isLazyLoad()) { - $script .= "\$con"; + $script .= '$con'; } $script .= ")); @@ -1395,7 +1456,8 @@ protected function addHasArrayElement(&$script, Column $column) * Adds a normal (non-temporal) getter method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addDefaultAccessor(&$script, Column $column) @@ -1410,23 +1472,24 @@ protected function addDefaultAccessor(&$script, Column $column) * Add the comment for a default accessor method (a getter). * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function addDefaultAccessorComment(&$script, Column $column) { - $clo=$column->getLowercasedName(); + $clo = $column->getLowercasedName(); $script .= " /** * Get the [$clo] column value. - * ".$column->getDescription(); + * " . $column->getDescription(); if ($column->isLazyLoad()) { $script .= " * @param ConnectionInterface \$con An optional ConnectionInterface connection to use for fetching this lazy-loaded column."; } $script .= " - * @return ".($column->getTypeHint() ?: ($column->getPhpType() ?: 'mixed'))." + * @return " . ($column->getTypeHint() ?: ($column->getPhpType() ?: 'mixed')) . " */"; } @@ -1434,7 +1497,8 @@ public function addDefaultAccessorComment(&$script, Column $column) * Adds the function declaration for a default accessor. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function addDefaultAccessorOpen(&$script, Column $column) @@ -1443,9 +1507,9 @@ public function addDefaultAccessorOpen(&$script, Column $column) $visibility = $column->getAccessorVisibility(); $script .= " - ".$visibility." function get$cfc("; + " . $visibility . " function get$cfc("; if ($column->isLazyLoad()) { - $script .= "ConnectionInterface \$con = null"; + $script .= 'ConnectionInterface $con = null'; } $script .= ") @@ -1456,7 +1520,8 @@ public function addDefaultAccessorOpen(&$script, Column $column) * Adds the function body for a default accessor method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addDefaultAccessorBody(&$script, Column $column) @@ -1474,6 +1539,7 @@ protected function addDefaultAccessorBody(&$script, Column $column) * Adds the function close for a default accessor method. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addDefaultAccessorClose(&$script) @@ -1487,7 +1553,8 @@ protected function addDefaultAccessorClose(&$script) * Adds the lazy loader method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addLazyLoader(&$script, Column $column) @@ -1502,7 +1569,8 @@ protected function addLazyLoader(&$script, Column $column) * Adds the comment for the lazy loader method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addLazyLoaderComment(&$script, Column $column) @@ -1527,7 +1595,8 @@ protected function addLazyLoaderComment(&$script, Column $column) * Adds the function declaration for the lazy loader method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addLazyLoaderOpen(&$script, Column $column) @@ -1542,7 +1611,8 @@ protected function load$cfc(ConnectionInterface \$con = null) * Adds the function body for the lazy loader method. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addLazyLoaderBody(&$script, Column $column) @@ -1554,10 +1624,10 @@ protected function addLazyLoaderBody(&$script, Column $column) if ($column->getType() === PropelTypes::BLOB && $platform instanceof SqlsrvPlatform) { $script .= " \$c = \$this->buildPkeyCriteria(); - \$c->addSelectColumn(".$this->getColumnConstant($column)."); + \$c->addSelectColumn(" . $this->getColumnConstant($column) . "); try { \$row = array(0 => null); - \$dataFetcher = ".$this->getQueryClassName()."::create(null, \$c)->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find(\$con); + \$dataFetcher = " . $this->getQueryClassName() . "::create(null, \$c)->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find(\$con); if (\$dataFetcher instanceof PDODataFetcher) { \$dataFetcher->bindColumn(1, \$row[0], PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY); } @@ -1566,9 +1636,9 @@ protected function addLazyLoaderBody(&$script, Column $column) } else { $script .= " \$c = \$this->buildPkeyCriteria(); - \$c->addSelectColumn(".$this->getColumnConstant($column)."); + \$c->addSelectColumn(" . $this->getColumnConstant($column) . "); try { - \$dataFetcher = ".$this->getQueryClassName()."::create(null, \$c)->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find(\$con); + \$dataFetcher = " . $this->getQueryClassName() . "::create(null, \$c)->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find(\$con); \$row = \$dataFetcher->fetch(); \$dataFetcher->close();"; } @@ -1595,17 +1665,17 @@ protected function addLazyLoaderBody(&$script, Column $column) }"; } elseif ($column->isPhpPrimitiveType()) { $script .= " - \$this->$clo = (\$firstColumn !== null) ? (".$column->getPhpType().") \$firstColumn : null;"; + \$this->$clo = (\$firstColumn !== null) ? (" . $column->getPhpType() . ') $firstColumn : null;'; } elseif ($column->isPhpObjectType()) { $script .= " - \$this->$clo = (\$firstColumn !== null) ? new ".$column->getPhpType()."(\$firstColumn) : null;"; + \$this->$clo = (\$firstColumn !== null) ? new " . $column->getPhpType() . '($firstColumn) : null;'; } else { $script .= " \$this->$clo = \$firstColumn;"; } $script .= " - \$this->".$clo."_isLoaded = true; + \$this->" . $clo . "_isLoaded = true; } catch (Exception \$e) { throw new PropelException(\"Error loading value for [$clo] column on demand.\", 0, \$e); }"; @@ -1615,6 +1685,7 @@ protected function addLazyLoaderBody(&$script, Column $column) * Adds the function close for the lazy loader. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addLazyLoaderClose(&$script) @@ -1627,7 +1698,8 @@ protected function addLazyLoaderClose(&$script) * Adds the open of the mutator (setter) method for a column. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addMutatorOpen(&$script, Column $column) @@ -1641,7 +1713,8 @@ protected function addMutatorOpen(&$script, Column $column) * Adds the open of the mutator (setter) method for a JSON column. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addJsonMutatorOpen(&$script, Column $column) @@ -1655,7 +1728,8 @@ protected function addJsonMutatorOpen(&$script, Column $column) * Adds the comment for a mutator. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function addJsonMutatorComment(&$script, Column $column) @@ -1664,9 +1738,9 @@ public function addJsonMutatorComment(&$script, Column $column) $script .= " /** * Set the value of [$clo] column. - * ".$column->getDescription()." + * " . $column->getDescription() . " * @param string|array|object \$v new value - * @return \$this|".$this->getObjectClassName(true)." The current object (for fluent API support) + * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) */"; } @@ -1674,7 +1748,8 @@ public function addJsonMutatorComment(&$script, Column $column) * Adds the comment for a mutator. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function addMutatorComment(&$script, Column $column) @@ -1698,7 +1773,8 @@ public function addMutatorComment(&$script, Column $column) * Adds the mutator function declaration. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function addMutatorOpenOpen(&$script, Column $column) @@ -1711,7 +1787,7 @@ public function addMutatorOpenOpen(&$script, Column $column) if ($column->getTypeHint()) { $typeHint = $column->getTypeHint(); - if ('array' !== $typeHint) { + if ($typeHint !== 'array') { $typeHint = $this->declareClass($typeHint); } @@ -1723,7 +1799,7 @@ public function addMutatorOpenOpen(&$script, Column $column) } $script .= " - ".$visibility." function set$cfc($typeHint\$v$null) + " . $visibility . " function set$cfc($typeHint\$v$null) {"; } @@ -1731,7 +1807,8 @@ public function addMutatorOpenOpen(&$script, Column $column) * Adds the mutator open body part. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addMutatorOpenBody(&$script, Column $column) @@ -1744,7 +1821,7 @@ protected function addMutatorOpenBody(&$script, Column $column) // it doesn't matter if the value is actually set or not (logic below) as // any attempt to set the value means that no db lookup should be performed // when the get$cfc() method is called. - \$this->".$clo."_isLoaded = true; + \$this->" . $clo . "_isLoaded = true; "; } } @@ -1753,7 +1830,8 @@ protected function addMutatorOpenBody(&$script, Column $column) * Adds the close of the mutator (setter) method for a column. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addMutatorClose(&$script, Column $column) @@ -1766,7 +1844,8 @@ protected function addMutatorClose(&$script, Column $column) * Adds the body of the close part of a mutator. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ protected function addMutatorCloseBody(&$script, Column $column) @@ -1774,10 +1853,8 @@ protected function addMutatorCloseBody(&$script, Column $column) $table = $this->getTable(); if ($column->isForeignKey()) { - foreach ($column->getForeignKeys() as $fk) { - - $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName()); + $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName()); $colFK = $tblFK->getColumn($fk->getMappedForeignColumn($column->getName())); if (!$colFK) { @@ -1787,7 +1864,7 @@ protected function addMutatorCloseBody(&$script, Column $column) $varName = $this->getFKVarName($fk); $script .= " - if (\$this->$varName !== null && \$this->".$varName."->get".$colFK->getPhpName()."() !== \$v) { + if (\$this->$varName !== null && \$this->" . $varName . '->get' . $colFK->getPhpName() . "() !== \$v) { \$this->$varName = null; } "; @@ -1795,32 +1872,29 @@ protected function addMutatorCloseBody(&$script, Column $column) } /* if col is foreign key */ foreach ($column->getReferrers() as $refFK) { - $tblFK = $this->getDatabase()->getTable($refFK->getForeignTableName()); - if ( $tblFK->getName() != $table->getName() ) { - + if ($tblFK->getName() != $table->getName()) { foreach ($column->getForeignKeys() as $fk) { - $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName()); $colFK = $tblFK->getColumn($fk->getMappedForeignColumn($column->getName())); if ($refFK->isLocalPrimaryKey()) { $varName = $this->getPKRefFKVarName($refFK); $script .= " - // update associated ".$tblFK->getPhpName()." + // update associated " . $tblFK->getPhpName() . " if (\$this->$varName !== null) { - \$this->{$varName}->set".$colFK->getPhpName()."(\$v); + \$this->{$varName}->set" . $colFK->getPhpName() . "(\$v); } "; } else { $collName = $this->getRefFKCollVarName($refFK); $script .= " - // update associated ".$tblFK->getPhpName()." + // update associated " . $tblFK->getPhpName() . " if (\$this->$collName !== null) { foreach (\$this->$collName as \$referrerObject) { - \$referrerObject->set".$colFK->getPhpName()."(\$v); + \$referrerObject->set" . $colFK->getPhpName() . "(\$v); } } "; @@ -1832,9 +1906,12 @@ protected function addMutatorCloseBody(&$script, Column $column) /** * Adds the close for the mutator close - * @param string $script The script will be modified in this method. - * @param Column $col The current column. + * * @see addMutatorClose() + * + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\Column $col The current column. + * * @return void */ protected function addMutatorCloseClose(&$script, Column $col) @@ -1848,9 +1925,12 @@ protected function addMutatorCloseClose(&$script, Column $col) /** * Adds a setter for BLOB columns. - * @param string $script The script will be modified in this method. - * @param Column $col The current column. + * * @see parent::addColumnMutators() + * + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\Column $col The current column. + * * @return void */ protected function addLobMutator(&$script, Column $col) @@ -1868,16 +1948,21 @@ protected function addLobMutator(&$script, Column $col) } else { // it's already a stream \$this->$clo = \$v; } - \$this->modifiedColumns[".$this->getColumnConstant($col)."] = true; + \$this->modifiedColumns[" . $this->getColumnConstant($col) . "] = true; "; $this->addMutatorClose($script, $col); - } // addLobMutatorSnippet + } + + // addLobMutatorSnippet /** * Adds a setter method for date/time/timestamp columns. - * @param string $script The script will be modified in this method. - * @param Column $col The current column. + * * @see parent::addColumnMutators() + * + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\Column $col The current column. + * * @return void */ protected function addTemporalMutator(&$script, Column $col) @@ -1908,9 +1993,11 @@ protected function addTemporalMutator(&$script, Column $col) switch ($col->getType()) { case 'DATE': $format = 'Y-m-d'; + break; case 'TIME': $format = 'H:i:s.u'; + break; default: $format = 'Y-m-d H:i:s.u'; @@ -1921,7 +2008,7 @@ protected function addTemporalMutator(&$script, Column $col) $script .= " \$this->$clo = \$dt === null ? null : clone \$dt; - \$this->modifiedColumns[".$this->getColumnConstant($col)."] = true; + \$this->modifiedColumns[" . $this->getColumnConstant($col) . "] = true; } } // if either are not null "; @@ -1941,24 +2028,27 @@ public function addTemporalMutatorComment(&$script, Column $col) $script .= " /** * Sets the value of [$clo] column to a normalized version of the date/time value specified. - * ".$col->getDescription()." + * " . $col->getDescription() . " * @param mixed \$v string, integer (timestamp), or \DateTimeInterface value. * Empty strings are treated as NULL. - * @return \$this|".$this->getObjectClassName(true)." The current object (for fluent API support) + * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) */"; } /** * Adds a setter for Object columns. - * @param string $script The script will be modified in this method. - * @param Column $col The current column. + * * @see parent::addColumnMutators() + * + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\Column $col The current column. + * * @return void */ protected function addObjectMutator(&$script, Column $col) { $clo = $col->getLowercasedName(); - $cloUnserialized = $clo.'_unserialized'; + $cloUnserialized = $clo . '_unserialized'; $this->addMutatorOpen($script, $col); $script .= " @@ -1966,7 +2056,7 @@ protected function addObjectMutator(&$script, Column $col) \$this->$cloUnserialized = \$v; \$this->$clo = fopen('php://memory', 'r+'); fwrite(\$this->$clo, serialize(\$v)); - \$this->modifiedColumns[".$this->getColumnConstant($col)."] = true; + \$this->modifiedColumns[" . $this->getColumnConstant($col) . "] = true; } rewind(\$this->$clo); "; @@ -1975,9 +2065,12 @@ protected function addObjectMutator(&$script, Column $col) /** * Adds a setter for Json columns. - * @param string $script The script will be modified in this method. - * @param Column $col The current column. + * * @see parent::addColumnMutators() + * + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\Column $col The current column. + * * @return void */ protected function addJsonMutator(&$script, Column $col) @@ -1994,7 +2087,7 @@ protected function addJsonMutator(&$script, Column $col) \$encodedValue = json_encode(\$v); if (\$encodedValue !== \$this->$clo) { \$this->$clo = \$encodedValue; - \$this->modifiedColumns[".$this->getColumnConstant($col)."] = true; + \$this->modifiedColumns[" . $this->getColumnConstant($col) . "] = true; } "; $this->addMutatorClose($script, $col); @@ -2002,22 +2095,25 @@ protected function addJsonMutator(&$script, Column $col) /** * Adds a setter for Array columns. - * @param string $script The script will be modified in this method. - * @param Column $col The current column. + * * @see parent::addColumnMutators() + * + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\Column $col The current column. + * * @return void */ protected function addArrayMutator(&$script, Column $col) { $clo = $col->getLowercasedName(); - $cloUnserialized = $clo.'_unserialized'; + $cloUnserialized = $clo . '_unserialized'; $this->addMutatorOpen($script, $col); $script .= " if (\$this->$cloUnserialized !== \$v) { \$this->$cloUnserialized = \$v; \$this->$clo = '| ' . implode(' | ', \$v) . ' |'; - \$this->modifiedColumns[".$this->getColumnConstant($col)."] = true; + \$this->modifiedColumns[" . $this->getColumnConstant($col) . "] = true; } "; $this->addMutatorClose($script, $col); @@ -2025,8 +2121,10 @@ protected function addArrayMutator(&$script, Column $col) /** * Adds a push method for an array column. + * * @param string $script The script will be modified in this method. - * @param Column $col The current column. + * @param \Propel\Generator\Model\Column $col The current column. + * * @return void */ protected function addAddArrayElement(&$script, Column $col) @@ -2040,24 +2138,24 @@ protected function addAddArrayElement(&$script, Column $col) /** * Adds a value to the [$clo] $columnType column value. * @param mixed \$value - * ".$col->getDescription(); + * " . $col->getDescription(); if ($col->isLazyLoad()) { $script .= " * @param ConnectionInterface \$con An optional ConnectionInterface connection to use for fetching this lazy-loaded column."; } $script .= " - * @return \$this|".$this->getObjectClassName(true)." The current object (for fluent API support) + * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) */ $visibility function add$singularPhpName(\$value"; if ($col->isLazyLoad()) { - $script .= ", ConnectionInterface \$con = null"; + $script .= ', ConnectionInterface $con = null'; } $script .= ") { \$currentArray = \$this->get$cfc("; if ($col->isLazyLoad()) { - $script .= "\$con"; + $script .= '$con'; } $script .= "); @@ -2071,8 +2169,10 @@ protected function addAddArrayElement(&$script, Column $col) /** * Adds a remove method for an array column. + * * @param string $script The script will be modified in this method. - * @param Column $col The current column. + * @param \Propel\Generator\Model\Column $col The current column. + * * @return void */ protected function addRemoveArrayElement(&$script, Column $col) @@ -2086,17 +2186,17 @@ protected function addRemoveArrayElement(&$script, Column $col) /** * Removes a value from the [$clo] $columnType column value. * @param mixed \$value - * ".$col->getDescription(); + * " . $col->getDescription(); if ($col->isLazyLoad()) { $script .= " * @param ConnectionInterface \$con An optional ConnectionInterface connection to use for fetching this lazy-loaded column."; } $script .= " - * @return \$this|".$this->getObjectClassName(true)." The current object (for fluent API support) + * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) */ $visibility function remove$singularPhpName(\$value"; if ($col->isLazyLoad()) { - $script .= ", ConnectionInterface \$con = null"; + $script .= ', ConnectionInterface $con = null'; } // we want to reindex the array, so array_ functions are not the best choice $script .= ") @@ -2104,7 +2204,7 @@ protected function addRemoveArrayElement(&$script, Column $col) \$targetArray = array(); foreach (\$this->get$cfc("; if ($col->isLazyLoad()) { - $script .= "\$con"; + $script .= '$con'; } $script .= ") as \$element) { if (\$element != \$value) { @@ -2120,9 +2220,12 @@ protected function addRemoveArrayElement(&$script, Column $col) /** * Adds a setter for Enum columns. - * @param string $script The script will be modified in this method. - * @param Column $col The current column. + * * @see parent::addColumnMutators() + * + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\Column $col The current column. + * * @return void */ protected function addEnumMutator(&$script, Column $col) @@ -2134,7 +2237,7 @@ protected function addEnumMutator(&$script, Column $col) $script .= " if (\$v !== null) { - \$valueSet = " . $this->getTableMapClassName() . "::getValueSet(" . $this->getColumnConstant($col) . "); + \$valueSet = " . $this->getTableMapClassName() . '::getValueSet(' . $this->getColumnConstant($col) . "); if (!in_array(\$v, \$valueSet)) { throw new PropelException(sprintf('Value \"%s\" is not accepted in this enumerated column', \$v)); } @@ -2143,7 +2246,7 @@ protected function addEnumMutator(&$script, Column $col) if (\$this->$clo !== \$v) { \$this->$clo = \$v; - \$this->modifiedColumns[".$this->getColumnConstant($col)."] = true; + \$this->modifiedColumns[" . $this->getColumnConstant($col) . "] = true; } "; $this->addMutatorClose($script, $col); @@ -2153,7 +2256,8 @@ protected function addEnumMutator(&$script, Column $col) * Adds the comment for an enum mutator. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function addEnumMutatorComment(&$script, Column $column) @@ -2162,9 +2266,9 @@ public function addEnumMutatorComment(&$script, Column $column) $script .= " /** * Set the value of [$clo] column. - * ".$column->getDescription()." + * " . $column->getDescription() . " * @param string \$v new value - * @return \$this|".$this->getObjectClassName(true)." The current object (for fluent API support) + * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) * @throws \\Propel\\Runtime\\Exception\\PropelException */"; } @@ -2172,9 +2276,11 @@ public function addEnumMutatorComment(&$script, Column $column) /** * Adds a setter for SET column mutator. * - * @param string $script The script will be modified in this method. - * @param Column $col The current column. * @see parent::addColumnMutators() + * + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\Column $col The current column. + * * @return void */ protected function addSetMutator(&$script, Column $col) @@ -2192,7 +2298,7 @@ protected function addSetMutator(&$script, Column $col) $script .= " if (\$this->$cloConverted === null || count(array_diff(\$this->$cloConverted, \$v)) > 0 || count(array_diff(\$v, \$this->$cloConverted)) > 0) { - \$valueSet = " . $this->getTableMapClassName() . "::getValueSet(" . $this->getColumnConstant($col) . "); + \$valueSet = " . $this->getTableMapClassName() . '::getValueSet(' . $this->getColumnConstant($col) . "); try { \$v = SetColumnConverter::convertToInt(\$v, \$valueSet); } catch (SetColumnConverterException \$e) { @@ -2201,7 +2307,7 @@ protected function addSetMutator(&$script, Column $col) if (\$this->$clo !== \$v) { \$this->$cloConverted = null; \$this->$clo = \$v; - \$this->modifiedColumns[".$this->getColumnConstant($col)."] = true; + \$this->modifiedColumns[" . $this->getColumnConstant($col) . "] = true; } } "; @@ -2212,7 +2318,8 @@ protected function addSetMutator(&$script, Column $col) * Adds the comment for a SET column mutator. * * @param string $script - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function addSetMutatorComment(&$script, Column $column) @@ -2221,18 +2328,21 @@ public function addSetMutatorComment(&$script, Column $column) $script .= " /** * Set the value of [$clo] column. - * ".$column->getDescription()." + * " . $column->getDescription() . " * @param array \$v new value - * @return \$this|".$this->getObjectClassName(true)." The current object (for fluent API support) + * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) * @throws \\Propel\\Runtime\\Exception\\PropelException */"; } /** * Adds setter method for boolean columns. - * @param string $script The script will be modified in this method. - * @param Column $col The current column. + * * @see parent::addColumnMutators() + * + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\Column $col The current column. + * * @return void */ protected function addBooleanMutator(&$script, Column $col) @@ -2254,7 +2364,7 @@ protected function addBooleanMutator(&$script, Column $col) if (\$this->$clo !== \$v) { \$this->$clo = \$v; - \$this->modifiedColumns[".$this->getColumnConstant($col)."] = true; + \$this->modifiedColumns[" . $this->getColumnConstant($col) . "] = true; } "; $this->addMutatorClose($script, $col); @@ -2277,17 +2387,20 @@ public function addBooleanMutatorComment(&$script, Column $col) * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true * * 0, '0', 'false', 'off', and 'no' are converted to boolean false * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). - * ".$col->getDescription()." + * " . $col->getDescription() . " * @param boolean|integer|string \$v The new value - * @return \$this|".$this->getObjectClassName(true)." The current object (for fluent API support) + * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) */"; } /** * Adds setter method for "normal" columns. - * @param string $script The script will be modified in this method. - * @param Column $col The current column. + * * @see parent::addColumnMutators() + * + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\Column $col The current column. + * * @return void */ protected function addDefaultMutator(&$script, Column $col) @@ -2301,7 +2414,7 @@ protected function addDefaultMutator(&$script, Column $col) if ($col->isPhpPrimitiveType()) { $script .= " if (\$v !== null) { - \$v = (".$col->getPhpType().") \$v; + \$v = (" . $col->getPhpType() . ") \$v; } "; } @@ -2309,7 +2422,7 @@ protected function addDefaultMutator(&$script, Column $col) $script .= " if (\$this->$clo !== \$v) { \$this->$clo = \$v; - \$this->modifiedColumns[".$this->getColumnConstant($col)."] = true; + \$this->modifiedColumns[" . $this->getColumnConstant($col) . "] = true; } "; $this->addMutatorClose($script, $col); @@ -2317,7 +2430,9 @@ protected function addDefaultMutator(&$script, Column $col) /** * Adds the hasOnlyDefaultValues() method. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addHasOnlyDefaultValues(&$script) @@ -2330,8 +2445,11 @@ protected function addHasOnlyDefaultValues(&$script) /** * Adds the comment for the hasOnlyDefaultValues method - * @param string $script The script will be modified in this method. + * * @see addHasOnlyDefaultValues + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addHasOnlyDefaultValuesComment(&$script) @@ -2349,8 +2467,11 @@ protected function addHasOnlyDefaultValuesComment(&$script) /** * Adds the function declaration for the hasOnlyDefaultValues method - * @param string $script The script will be modified in this method. + * * @see addHasOnlyDefaultValues + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addHasOnlyDefaultValuesOpen(&$script) @@ -2362,8 +2483,11 @@ public function hasOnlyDefaultValues() /** * Adds the function body for the hasOnlyDefaultValues method - * @param string $script The script will be modified in this method. + * * @see addHasOnlyDefaultValues + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addHasOnlyDefaultValuesBody(&$script) @@ -2378,7 +2502,7 @@ protected function addHasOnlyDefaultValuesBody(&$script) } foreach ($colsWithDefaults as $col) { - /** @var Column $col */ + /** @var \Propel\Generator\Model\Column $col */ $clo = $col->getLowercasedName(); $accessor = "\$this->$clo"; if ($col->isTemporalType()) { @@ -2386,7 +2510,7 @@ protected function addHasOnlyDefaultValuesBody(&$script) $accessor = "\$this->$clo && \$this->{$clo}->format('$fmt')"; } $script .= " - if ($accessor !== " . $this->getDefaultValueString($col).") { + if ($accessor !== " . $this->getDefaultValueString($col) . ") { return false; } "; @@ -2395,8 +2519,11 @@ protected function addHasOnlyDefaultValuesBody(&$script) /** * Adds the function close for the hasOnlyDefaultValues method - * @param string $script The script will be modified in this method. + * * @see addHasOnlyDefaultValues + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addHasOnlyDefaultValuesClose(&$script) @@ -2411,7 +2538,9 @@ protected function addHasOnlyDefaultValuesClose(&$script) /** * Adds the hydrate() method, which sets attributes of the object based on a ResultSet. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addHydrate(&$script) @@ -2424,8 +2553,11 @@ protected function addHydrate(&$script) /** * Adds the comment for the hydrate method - * @param string $script The script will be modified in this method. + * * @see addHydrate() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addHydrateComment(&$script) @@ -2453,8 +2585,11 @@ protected function addHydrateComment(&$script) /** * Adds the function declaration for the hydrate method - * @param string $script The script will be modified in this method. + * * @see addHydrate() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addHydrateOpen(&$script) @@ -2466,8 +2601,11 @@ public function hydrate(\$row, \$startcol = 0, \$rehydrate = false, \$indexType /** * Adds the function body for the hydrate method - * @param string $script The script will be modified in this method. + * * @see addHydrate() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addHydrateBody(&$script) @@ -2524,7 +2662,7 @@ protected function addHydrateBody(&$script) \$this->$clo = (null !== \$col) ? PropelDateTime::newInstance(\$col, null, '$dateTimeClass') : null;"; } elseif ($col->isPhpPrimitiveType()) { $script .= " - \$this->$clo = (null !== \$col) ? (".$col->getPhpType().") \$col : null;"; + \$this->$clo = (null !== \$col) ? (" . $col->getPhpType() . ') $col : null;'; } elseif ($col->getType() === PropelTypes::OBJECT) { $script .= " \$this->$clo = \$col;"; @@ -2540,7 +2678,7 @@ protected function addHydrateBody(&$script) \$this->$cloConverted = null;"; } elseif ($col->isPhpObjectType()) { $script .= " - \$this->$clo = (null !== \$col) ? new ".$col->getPhpType()."(\$col) : null;"; + \$this->$clo = (null !== \$col) ? new " . $col->getPhpType() . '($col) : null;'; } else { $script .= " \$this->$clo = \$col;"; @@ -2549,7 +2687,7 @@ protected function addHydrateBody(&$script) } // if col->isLazyLoad() } /* foreach */ - if ($this->getBuildProperty("generator.objectModel.addSaveMethod")) { + if ($this->getBuildProperty('generator.objectModel.addSaveMethod')) { $script .= " \$this->resetModified(); "; @@ -2563,20 +2701,23 @@ protected function addHydrateBody(&$script) } "; - $this->applyBehaviorModifier('postHydrate', $script, " "); + $this->applyBehaviorModifier('postHydrate', $script, ' '); $script .= " - return \$startcol + $n; // $n = ".$this->getTableMapClass()."::NUM_HYDRATE_COLUMNS. + return \$startcol + $n; // $n = " . $this->getTableMapClass() . "::NUM_HYDRATE_COLUMNS. } catch (Exception \$e) { - throw new PropelException(sprintf('Error populating %s object', ".var_export($this->getStubObjectBuilder()->getClassName(), true)."), 0, \$e); + throw new PropelException(sprintf('Error populating %s object', " . var_export($this->getStubObjectBuilder()->getClassName(), true) . "), 0, \$e); }"; } /** * Adds the function close for the hydrate method - * @param string $script The script will be modified in this method. + * * @see addHydrate() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addHydrateClose(&$script) @@ -2588,7 +2729,9 @@ protected function addHydrateClose(&$script) /** * Adds the buildPkeyCriteria method + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addBuildPkeyCriteria(&$script) @@ -2603,8 +2746,11 @@ protected function addBuildPkeyCriteria(&$script) /** * Adds the comment for the buildPkeyCriteria method - * @param string $script The script will be modified in this method. + * * @see addBuildPkeyCriteria() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addBuildPkeyCriteriaComment(&$script) @@ -2624,8 +2770,11 @@ protected function addBuildPkeyCriteriaComment(&$script) /** * Adds the function declaration for the buildPkeyCriteria method - * @param string $script The script will be modified in this method. + * * @see addBuildPkeyCriteria() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addBuildPkeyCriteriaOpen(&$script) @@ -2637,8 +2786,11 @@ public function buildPkeyCriteria() /** * Adds the function body for the buildPkeyCriteria method - * @param string $script The script will be modified in this method. + * * @see addBuildPkeyCriteria() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addBuildPkeyCriteriaBody(&$script) @@ -2651,18 +2803,21 @@ protected function addBuildPkeyCriteriaBody(&$script) } $script .= " - \$criteria = ".$this->getQueryClassName()."::create();"; + \$criteria = " . $this->getQueryClassName() . '::create();'; foreach ($this->getTable()->getPrimaryKey() as $col) { $clo = $col->getLowercasedName(); $script .= " - \$criteria->add(".$this->getColumnConstant($col).", \$this->$clo);"; + \$criteria->add(" . $this->getColumnConstant($col) . ", \$this->$clo);"; } } /** * Adds the function close for the buildPkeyCriteria method - * @param string $script The script will be modified in this method. + * * @see addBuildPkeyCriteria() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addBuildPkeyCriteriaClose(&$script) @@ -2676,7 +2831,9 @@ protected function addBuildPkeyCriteriaClose(&$script) /** * Adds the buildCriteria method + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addBuildCriteria(&$script) @@ -2689,8 +2846,11 @@ protected function addBuildCriteria(&$script) /** * Adds comment for the buildCriteria method - * @param string $script The script will be modified in this method. + * * @see addBuildCriteria() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addBuildCriteriaComment(&$script) @@ -2705,8 +2865,11 @@ protected function addBuildCriteriaComment(&$script) /** * Adds the function declaration of the buildCriteria method - * @param string $script The script will be modified in this method. + * * @see addBuildCriteria() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addBuildCriteriaOpen(&$script) @@ -2718,28 +2881,34 @@ public function buildCriteria() /** * Adds the function body of the buildCriteria method - * @param string $script The script will be modified in this method. + * * @see addBuildCriteria() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addBuildCriteriaBody(&$script) { $script .= " - \$criteria = new Criteria(".$this->getTableMapClass()."::DATABASE_NAME); + \$criteria = new Criteria(" . $this->getTableMapClass() . "::DATABASE_NAME); "; foreach ($this->getTable()->getColumns() as $col) { $clo = $col->getLowercasedName(); $script .= " - if (\$this->isColumnModified(".$this->getColumnConstant($col).")) { - \$criteria->add(".$this->getColumnConstant($col).", \$this->$clo); + if (\$this->isColumnModified(" . $this->getColumnConstant($col) . ")) { + \$criteria->add(" . $this->getColumnConstant($col) . ", \$this->$clo); }"; } } /** * Adds the function close of the buildCriteria method - * @param string $script The script will be modified in this method. + * * @see addBuildCriteria() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addBuildCriteriaClose(&$script) @@ -2753,7 +2922,9 @@ protected function addBuildCriteriaClose(&$script) /** * Adds the toArray method + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addToArray(&$script) @@ -2784,22 +2955,22 @@ protected function addToArray(&$script) * * @return array an associative array containing the field names (as keys) and field values */ - public function toArray(\$keyType = TableMap::$defaultKeyType, \$includeLazyLoadColumns = true, \$alreadyDumpedObjects = array()" . ($hasFks ? ", \$includeForeignObjects = false" : '') . ") + public function toArray(\$keyType = TableMap::$defaultKeyType, \$includeLazyLoadColumns = true, \$alreadyDumpedObjects = array()" . ($hasFks ? ', $includeForeignObjects = false' : '') . ") { if (isset(\$alreadyDumpedObjects['$objectClassName'][\$this->hashCode()])) { return '*RECURSION*'; } \$alreadyDumpedObjects['$objectClassName'][\$this->hashCode()] = true; - \$keys = ".$this->getTableMapClassName()."::getFieldNames(\$keyType); + \$keys = " . $this->getTableMapClassName() . "::getFieldNames(\$keyType); \$result = array("; foreach ($this->getTable()->getColumns() as $num => $col) { if ($col->isLazyLoad()) { $script .= " - \$keys[$num] => (\$includeLazyLoadColumns) ? \$this->get".$col->getPhpName()."() : null,"; + \$keys[$num] => (\$includeLazyLoadColumns) ? \$this->get" . $col->getPhpName() . '() : null,'; } else { $script .= " - \$keys[$num] => \$this->get".$col->getPhpName()."(),"; + \$keys[$num] => \$this->get" . $col->getPhpName() . '(),'; } } $script .= " @@ -2853,15 +3024,18 @@ public function toArray(\$keyType = TableMap::$defaultKeyType, \$includeLazyLoad return \$result; } "; - } // addToArray() + } + + // addToArray() /** * Adds the switch-statement for looking up the array-key name for toArray + * * @see toArray */ protected function addToArrayKeyLookUp($phpName, Table $table, $plural) { - if($phpName == "") { + if ($phpName == '') { $phpName = $table->getPhpName(); } @@ -2890,7 +3064,9 @@ protected function addToArrayKeyLookUp($phpName, Table $table, $plural) /** * Adds the getByName method + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetByName(&$script) @@ -2903,8 +3079,11 @@ protected function addGetByName(&$script) /** * Adds the comment for the getByName method - * @param string $script The script will be modified in this method. + * * @see addGetByName + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetByNameComment(&$script) @@ -2925,8 +3104,11 @@ protected function addGetByNameComment(&$script) /** * Adds the function declaration for the getByName method - * @param string $script The script will be modified in this method. + * * @see addGetByName + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetByNameOpen(&$script) @@ -2939,21 +3121,27 @@ public function getByName(\$name, \$type = TableMap::$defaultKeyType) /** * Adds the function body for the getByName method - * @param string $script The script will be modified in this method. + * * @see addGetByName + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetByNameBody(&$script) { $script .= " - \$pos = ".$this->getTableMapClassName()."::translateFieldName(\$name, \$type, TableMap::TYPE_NUM); + \$pos = " . $this->getTableMapClassName() . "::translateFieldName(\$name, \$type, TableMap::TYPE_NUM); \$field = \$this->getByPosition(\$pos);"; } /** * Adds the function close for the getByName method - * @param string $script The script will be modified in this method. + * * @see addGetByName + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetByNameClose(&$script) @@ -2967,7 +3155,9 @@ protected function addGetByNameClose(&$script) /** * Adds the getByPosition method + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetByPosition(&$script) @@ -2980,8 +3170,11 @@ protected function addGetByPosition(&$script) /** * Adds comment for the getByPosition method - * @param string $script The script will be modified in this method. + * * @see addGetByPosition + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetByPositionComment(&$script) @@ -2998,8 +3191,11 @@ protected function addGetByPositionComment(&$script) /** * Adds the function declaration for the getByPosition method - * @param string $script The script will be modified in this method. + * * @see addGetByPosition + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetByPositionOpen(&$script) @@ -3011,8 +3207,11 @@ public function getByPosition(\$pos) /** * Adds the function body for the getByPosition method - * @param string $script The script will be modified in this method. + * * @see addGetByPosition + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetByPositionBody(&$script) @@ -3038,8 +3237,11 @@ protected function addGetByPositionBody(&$script) /** * Adds the function close for the getByPosition method - * @param string $script The script will be modified in this method. + * * @see addGetByPosition + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetByPositionClose(&$script) @@ -3067,11 +3269,11 @@ protected function addSetByName(&$script) * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. * Defaults to TableMap::$defaultKeyType. - * @return \$this|".$this->getObjectClassName(true)." + * @return \$this|" . $this->getObjectClassName(true) . " */ public function setByName(\$name, \$value, \$type = TableMap::$defaultKeyType) { - \$pos = ".$this->getTableMapClassName()."::translateFieldName(\$name, \$type, TableMap::TYPE_NUM); + \$pos = " . $this->getTableMapClassName() . "::translateFieldName(\$name, \$type, TableMap::TYPE_NUM); return \$this->setByPosition(\$pos, \$value); } @@ -3093,7 +3295,7 @@ protected function addSetByPosition(&$script) * * @param int \$pos position in xml schema * @param mixed \$value field value - * @return \$this|".$this->getObjectClassName(true)." + * @return \$this|" . $this->getObjectClassName(true) . " */ public function setByPosition(\$pos, \$value) { @@ -3105,9 +3307,9 @@ public function setByPosition(\$pos, \$value) $script .= " case $i:"; - if (PropelTypes::ENUM === $col->getType()) { + if ($col->getType() === PropelTypes::ENUM) { $script .= " - \$valueSet = " . $this->getTableMapClassName() . "::getValueSet(" . $this->getColumnConstant($col) . "); + \$valueSet = " . $this->getTableMapClassName() . '::getValueSet(' . $this->getColumnConstant($col) . "); if (isset(\$valueSet[\$value])) { \$value = \$valueSet[\$value]; }"; @@ -3117,14 +3319,14 @@ public function setByPosition(\$pos, \$value) 'Propel\Common\Exception\SetColumnConverterException' ); $script .= " - \$valueSet = " . $this->getTableMapClassName() . "::getValueSet(" . $this->getColumnConstant($col) . "); + \$valueSet = " . $this->getTableMapClassName() . '::getValueSet(' . $this->getColumnConstant($col) . "); try { \$value = SetColumnConverter::convertIntToArray(\$value, \$valueSet); } catch (SetColumnConverterException \$e) { throw new PropelException('Unknown stored set key: ' . \$e->getValue(), \$e->getCode(), \$e); } "; - } elseif (PropelTypes::PHP_ARRAY === $col->getType()) { + } elseif ($col->getType() === PropelTypes::PHP_ARRAY) { $script .= " if (!is_array(\$value)) { \$v = trim(substr(\$value, 2, -2)); @@ -3174,7 +3376,7 @@ protected function addFromArray(&$script) */ public function fromArray(\$arr, \$keyType = TableMap::$defaultKeyType) { - \$keys = ".$this->getTableMapClassName()."::getFieldNames(\$keyType); + \$keys = " . $this->getTableMapClassName() . "::getFieldNames(\$keyType); "; foreach ($table->getColumns() as $num => $col) { $cfc = $col->getPhpName(); @@ -3214,7 +3416,7 @@ protected function addImportFrom(&$script) * @param string \$data The source data to import from * @param string \$keyType The type of keys the array uses. * - * @return \$this|".$this->getObjectClassName(true)." The current object, for fluid interface + * @return \$this|" . $this->getObjectClassName(true) . " The current object, for fluid interface */ public function importFrom(\$parser, \$data, \$keyType = TableMap::$defaultKeyType) { @@ -3231,7 +3433,9 @@ public function importFrom(\$parser, \$data, \$keyType = TableMap::$defaultKeyTy /** * Adds a delete() method to remove the object form the datastore. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addDelete(&$script) @@ -3244,8 +3448,11 @@ protected function addDelete(&$script) /** * Adds the comment for the delete function - * @param string $script The script will be modified in this method. + * * @see addDelete() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addDeleteComment(&$script) @@ -3265,8 +3472,11 @@ protected function addDeleteComment(&$script) /** * Adds the function declaration for the delete function - * @param string $script The script will be modified in this method. + * * @see addDelete() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addDeleteOpen(&$script) @@ -3278,8 +3488,11 @@ public function delete(ConnectionInterface \$con = null) /** * Adds the function body for the delete function - * @param string $script The script will be modified in this method. + * * @see addDelete() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addDeleteBody(&$script) @@ -3290,33 +3503,33 @@ protected function addDeleteBody(&$script) } if (\$con === null) { - \$con = Propel::getServiceContainer()->getWriteConnection(".$this->getTableMapClass()."::DATABASE_NAME); + \$con = Propel::getServiceContainer()->getWriteConnection(" . $this->getTableMapClass() . "::DATABASE_NAME); } \$con->transaction(function () use (\$con) { - \$deleteQuery = ".$this->getQueryClassName()."::create() + \$deleteQuery = " . $this->getQueryClassName() . "::create() ->filterByPrimaryKey(\$this->getPrimaryKey());"; if ($this->getBuildProperty('generator.objectModel.addHooks')) { $script .= " \$ret = \$this->preDelete(\$con);"; // apply behaviors - $this->applyBehaviorModifier('preDelete', $script, " "); + $this->applyBehaviorModifier('preDelete', $script, ' '); $script .= " if (\$ret) { \$deleteQuery->delete(\$con); \$this->postDelete(\$con);"; // apply behaviors - $this->applyBehaviorModifier('postDelete', $script, " "); + $this->applyBehaviorModifier('postDelete', $script, ' '); $script .= " \$this->setDeleted(true); }"; } else { // apply behaviors - $this->applyBehaviorModifier('preDelete', $script, " "); + $this->applyBehaviorModifier('preDelete', $script, ' '); $script .= " \$deleteQuery->delete(\$con);"; // apply behaviors - $this->applyBehaviorModifier('postDelete', $script, " "); + $this->applyBehaviorModifier('postDelete', $script, ' '); $script .= " \$this->setDeleted(true);"; } @@ -3327,8 +3540,11 @@ protected function addDeleteBody(&$script) /** * Adds the function close for the delete function - * @param string $script The script will be modified in this method. + * * @see addDelete() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addDeleteClose(&$script) @@ -3336,11 +3552,15 @@ protected function addDeleteClose(&$script) $script .= " } "; - } // addDelete() + } + + // addDelete() /** * Adds a reload() method to re-fetch the data for this object from the database. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addReload(&$script) @@ -3368,13 +3588,13 @@ public function reload(\$deep = false, ConnectionInterface \$con = null) } if (\$con === null) { - \$con = Propel::getServiceContainer()->getReadConnection(".$this->getTableMapClass()."::DATABASE_NAME); + \$con = Propel::getServiceContainer()->getReadConnection(" . $this->getTableMapClass() . "::DATABASE_NAME); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. - \$dataFetcher = ".$this->getQueryClassName()."::create(null, \$this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find(\$con); + \$dataFetcher = " . $this->getQueryClassName() . "::create(null, \$this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find(\$con); \$row = \$dataFetcher->fetch(); \$dataFetcher->close(); if (!\$row) { @@ -3390,7 +3610,7 @@ public function reload(\$deep = false, ConnectionInterface \$con = null) $script .= " // Reset the $clo lazy-load column \$this->" . $clo . " = null; - \$this->".$clo."_isLoaded = false; + \$this->" . $clo . "_isLoaded = false; "; } } @@ -3402,35 +3622,39 @@ public function reload(\$deep = false, ConnectionInterface \$con = null) foreach ($table->getForeignKeys() as $fk) { $varName = $this->getFKVarName($fk); $script .= " - \$this->".$varName." = null;"; + \$this->" . $varName . ' = null;'; } foreach ($table->getReferrers() as $refFK) { if ($refFK->isLocalPrimaryKey()) { $script .= " - \$this->".$this->getPKRefFKVarName($refFK)." = null; + \$this->" . $this->getPKRefFKVarName($refFK) . " = null; "; } else { $script .= " - \$this->".$this->getRefFKCollVarName($refFK)." = null; + \$this->" . $this->getRefFKCollVarName($refFK) . " = null; "; } } foreach ($table->getCrossFks() as $crossFKs) { $script .= " - \$this->" . $this->getCrossFKsVarName($crossFKs). " = null;"; + \$this->" . $this->getCrossFKsVarName($crossFKs) . ' = null;'; } $script .= " } // if (deep) } "; - } // addReload() + } + + // addReload() /** * Adds the methods related to refreshing, saving and deleting the object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addManipulationMethods(&$script) @@ -3470,7 +3694,7 @@ public function hashCode() $script .= ";\n"; - /** @var ForeignKey[] $primaryKeyFKs */ + /** @var \Propel\Generator\Model\ForeignKey[] $primaryKeyFKs */ $primaryKeyFKs = []; $foreignKeyPKCount = 0; foreach ($this->getTable()->getForeignKeys() as $foreignKey) { @@ -3513,7 +3737,9 @@ public function hashCode() /** * Adds the correct getPrimaryKey() method for this object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetPrimaryKey(&$script) @@ -3531,7 +3757,9 @@ protected function addGetPrimaryKey(&$script) /** * Adds the getPrimaryKey() method for tables that contain a single-column primary key. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetPrimaryKey_SinglePK(&$script) @@ -3547,19 +3775,22 @@ protected function addGetPrimaryKey_SinglePK(&$script) */ public function getPrimaryKey() { - return \$this->get".$pkeys[0]->getPhpName()."(); + return \$this->get" . $pkeys[0]->getPhpName() . "(); } "; - } // addetPrimaryKey_SingleFK + } + + // addetPrimaryKey_SingleFK /** * Adds the setPrimaryKey() method for tables that contain a multi-column primary key. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetPrimaryKey_MultiPK(&$script) { - $script .= " /** * Returns the composite primary key for this object. @@ -3572,7 +3803,7 @@ public function getPrimaryKey() $i = 0; foreach ($this->getTable()->getPrimaryKey() as $pk) { $script .= " - \$pks[$i] = \$this->get".$pk->getPhpName()."();"; + \$pks[$i] = \$this->get" . $pk->getPhpName() . '();'; $i++; } /* foreach */ $script .= " @@ -3580,15 +3811,20 @@ public function getPrimaryKey() return \$pks; } "; - } // addGetPrimaryKey_MultiFK() + } + + // addGetPrimaryKey_MultiFK() /** * Adds the getPrimaryKey() method for objects that have no primary key. * This "feature" is deprecated, since the getPrimaryKey() method is not required - * by the Persistent interface (or used by the templates). Hence, this method is also + * by the Persistent interface (or used by the templates). Hence, this method is also * deprecated. - * @param string $script The script will be modified in this method. + * * @deprecated + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetPrimaryKey_NoPK(&$script) @@ -3608,7 +3844,9 @@ public function getPrimaryKey() /** * Adds the correct setPrimaryKey() method for this object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addSetPrimaryKey(&$script) @@ -3626,15 +3864,16 @@ protected function addSetPrimaryKey(&$script) /** * Adds the setPrimaryKey() method for tables that contain a single-column primary key. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addSetPrimaryKey_SinglePK(&$script) { - $pkeys = $this->getTable()->getPrimaryKey(); $col = $pkeys[0]; - $clo=$col->getLowercasedName(); + $clo = $col->getLowercasedName(); $ctype = $col->getPhpType(); $script .= " @@ -3646,20 +3885,23 @@ protected function addSetPrimaryKey_SinglePK(&$script) */ public function setPrimaryKey(\$key) { - \$this->set".$col->getPhpName()."(\$key); + \$this->set" . $col->getPhpName() . "(\$key); } "; - } // addSetPrimaryKey_SinglePK + } + + // addSetPrimaryKey_SinglePK /** * Adds the setPrimaryKey() method for tables that contain a multi-columnprimary key. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addSetPrimaryKey_MultiPK(&$script) { - - $script .=" + $script .= " /** * Set the [composite] primary key. * @@ -3671,7 +3913,7 @@ public function setPrimaryKey(\$keys) $i = 0; foreach ($this->getTable()->getPrimaryKey() as $pk) { $script .= " - \$this->set".$pk->getPhpName()."(\$keys[$i]);"; + \$this->set" . $pk->getPhpName() . "(\$keys[$i]);"; $i++; } $script .= " @@ -3682,15 +3924,18 @@ public function setPrimaryKey(\$keys) /** * Adds the setPrimaryKey() method for objects that have no primary key. * This "feature" is deprecated, since the setPrimaryKey() method is not required - * by the Persistent interface (or used by the templates). Hence, this method is also + * by the Persistent interface (or used by the templates). Hence, this method is also * deprecated. - * @param string $script The script will be modified in this method. + * * @deprecated + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addSetPrimaryKey_NoPK(&$script) { - $script .=" + $script .= " /** * Dummy primary key setter. * @@ -3709,7 +3954,9 @@ public function setPrimaryKey(\$pk) /** * Adds the isPrimaryKeyNull() method + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addIsPrimaryKeyNull(&$script) @@ -3726,14 +3973,14 @@ public function isPrimaryKeyNull() {"; if (count($pkeys) == 1) { $script .= " - return null === \$this->get" . $pkeys[0]->getPhpName() . "();"; + return null === \$this->get" . $pkeys[0]->getPhpName() . '();'; } else { $tests = []; foreach ($pkeys as $pkey) { - $tests[]= "(null === \$this->get" . $pkey->getPhpName() . "())"; + $tests[] = '(null === $this->get' . $pkey->getPhpName() . '())'; } $script .= " - return " . join(' && ', $tests) . ";"; + return " . implode(' && ', $tests) . ';'; } $script .= " } @@ -3742,7 +3989,9 @@ public function isPrimaryKeyNull() /** * Constructs variable name for fkey-related objects. - * @param ForeignKey $fk + * + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return string */ public function getFKVarName(ForeignKey $fk) @@ -3752,7 +4001,9 @@ public function getFKVarName(ForeignKey $fk) /** * Constructs variable name for objects which referencing current table by specified foreign key. - * @param ForeignKey $fk + * + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return string */ public function getRefFKCollVarName(ForeignKey $fk) @@ -3763,7 +4014,9 @@ public function getRefFKCollVarName(ForeignKey $fk) /** * Constructs variable name for single object which references current table by specified foreign key * which is ALSO a primary key (hence one-to-one relationship). - * @param ForeignKey $fk + * + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return string */ public function getPKRefFKVarName(ForeignKey $fk) @@ -3773,7 +4026,9 @@ public function getPKRefFKVarName(ForeignKey $fk) /** * Adds the methods that get & set objects related by foreign key to the current object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addFKMethods(&$script) @@ -3788,8 +4043,10 @@ protected function addFKMethods(&$script) /** * Adds the class attributes that are needed to store fkey related objects. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $fk + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return void */ protected function addFKAttributes(&$script, ForeignKey $fk) @@ -3801,14 +4058,16 @@ protected function addFKAttributes(&$script, ForeignKey $fk) /** * @var $className */ - protected $".$varName."; + protected $" . $varName . "; "; } /** * Adds the mutator (setter) method for setting an fkey related object. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $fk + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return void */ protected function addFKMutator(&$script, ForeignKey $fk) @@ -3829,10 +4088,10 @@ protected function addFKMutator(&$script, ForeignKey $fk) * Declares an association between this object and a $className object. * * @param $className \$v - * @return \$this|".$this->getObjectClassName(true)." The current object (for fluent API support) + * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) * @throws PropelException */ - public function set".$this->getFKPhpNameAffix($fk, false)."($className \$v = null) + public function set" . $this->getFKPhpNameAffix($fk, false) . "($className \$v = null) {"; foreach ($fk->getMapping() as $map) { @@ -3841,9 +4100,9 @@ public function set".$this->getFKPhpNameAffix($fk, false)."($className \$v = nul if ($rightValueOrColumn instanceof Column) { $script .= " if (\$v === null) { - \$this->set" . $column->getPhpName() . "(" . $this->getDefaultValueString($column) . "); + \$this->set" . $column->getPhpName() . '(' . $this->getDefaultValueString($column) . "); } else { - \$this->set" . $column->getPhpName() . "(\$v->get" . $rightValueOrColumn->getPhpName() . "()); + \$this->set" . $column->getPhpName() . '($v->get' . $rightValueOrColumn->getPhpName() . "()); } "; } else { @@ -3856,7 +4115,6 @@ public function set".$this->getFKPhpNameAffix($fk, false)."($className \$v = nul } "; } - } /* foreach local col */ $script .= " @@ -3870,7 +4128,7 @@ public function set".$this->getFKPhpNameAffix($fk, false)."($className \$v = nul $script .= " // Add binding for other direction of this 1:1 relationship. if (\$v !== null) { - \$v->set".$this->getRefFKPhpNameAffix($fk, false)."(\$this); + \$v->set" . $this->getRefFKPhpNameAffix($fk, false) . "(\$this); } "; } else { @@ -3878,10 +4136,9 @@ public function set".$this->getFKPhpNameAffix($fk, false)."($className \$v = nul // Add binding for other direction of this n:n relationship. // If this object has already been added to the $className object, it will not be re-added. if (\$v !== null) { - \$v->add".$this->getRefFKPhpNameAffix($fk, false)."(\$this); + \$v->add" . $this->getRefFKPhpNameAffix($fk, false) . "(\$this); } "; - } $script .= " @@ -3893,8 +4150,10 @@ public function set".$this->getFKPhpNameAffix($fk, false)."($className \$v = nul /** * Adds the accessor (getter) method for getting an fkey related object. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $fk + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return void */ protected function addFKAccessor(&$script, ForeignKey $fk) @@ -3931,25 +4190,24 @@ protected function addFKAccessor(&$script, ForeignKey $fk) if ($rightValueOrColumn instanceof Column) { $localColumns[$rightValueOrColumn->getPosition()] = '$this->' . $clo; - if ($cptype == "int" || $cptype == "float" || $cptype == "double") { - $conditional .= $and . "\$this->". $clo ." != 0"; - } elseif ($cptype == "string") { - $conditional .= $and . "(\$this->" . $clo ." !== \"\" && \$this->".$clo." !== null)"; + if ($cptype == 'int' || $cptype == 'float' || $cptype == 'double') { + $conditional .= $and . '$this->' . $clo . ' != 0'; + } elseif ($cptype == 'string') { + $conditional .= $and . '($this->' . $clo . ' !== "" && $this->' . $clo . ' !== null)'; } else { - $conditional .= $and . "\$this->" . $clo ." !== null"; + $conditional .= $and . '$this->' . $clo . ' !== null'; } } else { $val = var_export($rightValueOrColumn, true); - $conditional .= $and . "\$this->" . $clo ." === " . $val; + $conditional .= $and . '$this->' . $clo . ' === ' . $val; } - - $and = " && "; + $and = ' && '; } ksort($localColumns); // restoring the order of the foreign PK $localColumns = count($localColumns) > 1 ? - ('array('.implode(', ', $localColumns).')') : reset($localColumns); + ('array(' . implode(', ', $localColumns) . ')') : reset($localColumns); $script .= " @@ -3960,23 +4218,23 @@ protected function addFKAccessor(&$script, ForeignKey $fk) * @return $className $returnDesc * @throws PropelException */ - public function get".$this->getFKPhpNameAffix($fk, false)."(ConnectionInterface \$con = null) + public function get" . $this->getFKPhpNameAffix($fk, false) . "(ConnectionInterface \$con = null) {"; $script .= " if (\$this->$varName === null && ($conditional)) {"; if ($findPk) { $script .= " - \$this->$varName = ".$this->getClassNameFromBuilder($fkQueryBuilder)."::create()->findPk($localColumns, \$con);"; + \$this->$varName = " . $this->getClassNameFromBuilder($fkQueryBuilder) . "::create()->findPk($localColumns, \$con);"; } else { $script .= " - \$this->$varName = ".$this->getClassNameFromBuilder($fkQueryBuilder)."::create() + \$this->$varName = " . $this->getClassNameFromBuilder($fkQueryBuilder) . "::create() ->filterBy" . $this->getRefFKPhpNameAffix($fk, $plural = false) . "(\$this) // here ->findOne(\$con);"; } if ($fk->isLocalPrimaryKey()) { $script .= " // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association. - \$this->{$varName}->set".$this->getRefFKPhpNameAffix($fk, false)."(\$this);"; + \$this->{$varName}->set" . $this->getRefFKPhpNameAffix($fk, false) . '($this);'; } else { $script .= " /* The following can be used additionally to @@ -3984,7 +4242,7 @@ public function get".$this->getFKPhpNameAffix($fk, false)."(ConnectionInterface to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - \$this->{$varName}->add".$this->getRefFKPhpNameAffix($fk, true)."(\$this); + \$this->{$varName}->add" . $this->getRefFKPhpNameAffix($fk, true) . "(\$this); */"; } @@ -3994,13 +4252,16 @@ public function get".$this->getFKPhpNameAffix($fk, false)."(ConnectionInterface return \$this->$varName; } "; + } - } // addFKAccessor + // addFKAccessor /** * Adds the method that fetches fkey-related (referencing) objects but also joins in data from another table. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $refFK + * @param \Propel\Generator\Model\ForeignKey $refFK + * * @return void */ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK) @@ -4015,7 +4276,6 @@ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK) $className = $this->getClassNameFromTable($tblFK); foreach ($tblFK->getForeignKeys() as $fk2) { - $tblFK2 = $fk2->getForeignTable(); $doJoinGet = !$tblFK2->isForReferenceOnly(); @@ -4027,8 +4287,10 @@ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK) $relCol2 = $this->getFKPhpNameAffix($fk2, false); - if ( $this->getRelatedBySuffix($refFK) != "" && - ($this->getRelatedBySuffix($refFK) == $this->getRelatedBySuffix($fk2))) { + if ( + $this->getRelatedBySuffix($refFK) != '' && + ($this->getRelatedBySuffix($refFK) == $this->getRelatedBySuffix($fk2)) + ) { $doJoinGet = false; } @@ -4038,40 +4300,42 @@ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK) /** * If this collection has already been initialized with * an identical criteria, it returns the collection. - * Otherwise if this ".$table->getPhpName()." is new, it will return - * an empty collection; or if this ".$table->getPhpName()." has previously + * Otherwise if this " . $table->getPhpName() . " is new, it will return + * an empty collection; or if this " . $table->getPhpName() . " has previously * been saved, it will retrieve related $relCol from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you - * actually need in ".$table->getPhpName().". + * actually need in " . $table->getPhpName() . ". * * @param Criteria \$criteria optional Criteria object to narrow the query * @param ConnectionInterface \$con optional connection object * @param string \$joinBehavior optional join type to use (defaults to $joinBehavior) * @return ObjectCollection|{$className}[] List of $className objects */ - public function get".$relCol."Join".$relCol2."(Criteria \$criteria = null, ConnectionInterface \$con = null, \$joinBehavior = $joinBehavior) + public function get" . $relCol . 'Join' . $relCol2 . "(Criteria \$criteria = null, ConnectionInterface \$con = null, \$joinBehavior = $joinBehavior) {"; $script .= " \$query = $fkQueryClassName::create(null, \$criteria); \$query->joinWith('" . $this->getFKPhpNameAffix($fk2, false) . "', \$joinBehavior); - return \$this->get". $relCol . "(\$query, \$con); + return \$this->get" . $relCol . "(\$query, \$con); } "; } /* end if ($doJoinGet) */ - } /* end foreach ($tblFK->getForeignKeys() as $fk2) { */ + } - } // function + // function /** * Adds the attributes used to store objects that have referrer fkey relationships to this object. * protected collVarName; * private lastVarNameCriteria = null; + * * @param string $script The script will be modified in this method. - * @param ForeignKey $refFK + * @param \Propel\Generator\Model\ForeignKey $refFK + * * @return void */ protected function addRefFKAttributes(&$script, ForeignKey $refFK) @@ -4083,7 +4347,7 @@ protected function addRefFKAttributes(&$script, ForeignKey $refFK) /** * @var $className one-to-one related $className object */ - protected $".$this->getPKRefFKVarName($refFK)."; + protected $" . $this->getPKRefFKVarName($refFK) . "; "; } else { $script .= " @@ -4098,7 +4362,9 @@ protected function addRefFKAttributes(&$script, ForeignKey $refFK) /** * Adds the methods for retrieving, initializing, adding objects that are related to this one by foreign keys. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addRefFKMethods(&$script) @@ -4130,7 +4396,8 @@ protected function addRefFKMethods(&$script) /** * @param string $script - * @param ForeignKey[] $referrers + * @param \Propel\Generator\Model\ForeignKey[] $referrers + * * @return void */ protected function addInitRelations(&$script, $referrers) @@ -4165,8 +4432,10 @@ public function initRelation(\$relationName) /** * Adds the method that clears the referrer fkey collection. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $refFK + * @param \Propel\Generator\Model\ForeignKey $refFK + * * @return void */ protected function addRefFKClear(&$script, ForeignKey $refFK) @@ -4189,12 +4458,16 @@ public function clear$relCol() \$this->$collName = null; // important to set this to NULL since that means it is uninitialized } "; - } // addRefererClear() + } + + // addRefererClear() /** * Adds the method that initializes the referrer fkey collection. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $refFK + * @param \Propel\Generator\Model\ForeignKey $refFK + * * @return void */ protected function addRefFKInit(&$script, ForeignKey $refFK) @@ -4221,18 +4494,22 @@ public function init$relCol(\$overrideExisting = true) return; } - \$collectionClassName = ".$this->getClassNameFromBuilder($this->getNewTableMapBuilder($refFK->getTable()))."::getTableMap()->getCollectionClassName(); + \$collectionClassName = " . $this->getClassNameFromBuilder($this->getNewTableMapBuilder($refFK->getTable())) . "::getTableMap()->getCollectionClassName(); \$this->{$collName} = new \$collectionClassName; \$this->{$collName}->setModel('" . $this->getClassNameFromBuilder($this->getNewStubObjectBuilder($refFK->getTable()), true) . "'); } "; - } // addRefererInit() + } + + // addRefererInit() /** * Adds the method that adds an object into the referrer fkey collection. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $refFK + * @param \Propel\Generator\Model\ForeignKey $refFK + * * @return void */ protected function addRefFKAdd(&$script, ForeignKey $refFK) @@ -4247,7 +4524,7 @@ protected function addRefFKAdd(&$script, ForeignKey $refFK) $collName = $this->getRefFKCollVarName($refFK); - $scheduledForDeletion = lcfirst($this->getRefFKPhpNameAffix($refFK, $plural = true)) . "ScheduledForDeletion"; + $scheduledForDeletion = lcfirst($this->getRefFKPhpNameAffix($refFK, $plural = true)) . 'ScheduledForDeletion'; $script .= " /** @@ -4255,9 +4532,9 @@ protected function addRefFKAdd(&$script, ForeignKey $refFK) * through the $className foreign key attribute. * * @param $className \$l $className - * @return \$this|".$this->getObjectClassName(true)." The current object (for fluent API support) + * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) */ - public function add".$this->getRefFKPhpNameAffix($refFK, false)."($className \$l) + public function add" . $this->getRefFKPhpNameAffix($refFK, false) . "($className \$l) { if (\$this->$collName === null) { \$this->init" . $this->getRefFKPhpNameAffix($refFK, $plural = true) . "(); @@ -4275,12 +4552,16 @@ public function add".$this->getRefFKPhpNameAffix($refFK, false)."($className \$l return \$this; } "; - } // addRefererAdd + } + + // addRefererAdd /** * Adds the method that returns the size of the referrer fkey collection. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $refFK + * @param \Propel\Generator\Model\ForeignKey $refFK + * * @return void */ protected function addRefFKCount(&$script, ForeignKey $refFK) @@ -4331,8 +4612,10 @@ public function count{$relCol}(Criteria \$criteria = null, \$distinct = false, C /** * Adds the method that returns the referrer fkey collection. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $refFK + * @param \Propel\Generator\Model\ForeignKey $refFK + * * @return void */ protected function addRefFKGet(&$script, ForeignKey $refFK) @@ -4350,7 +4633,7 @@ protected function addRefFKGet(&$script, ForeignKey $refFK) * If the \$criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. * Next time the same method is called without \$criteria, the cached collection is returned. - * If this ".$this->getObjectClassName()." is new, it will return + * If this " . $this->getObjectClassName() . " is new, it will return * an empty collection or the current collection; the criteria is ignored on a new object. * * @param Criteria \$criteria optional Criteria object to narrow the query @@ -4367,7 +4650,7 @@ public function get$relCol(Criteria \$criteria = null, ConnectionInterface \$con if (null === \$this->$collName) { \$this->init" . $this->getRefFKPhpNameAffix($refFK, $plural = true) . "(); } else { - \$collectionClassName = ".$this->getClassNameFromBuilder($this->getNewTableMapBuilder($refFK->getTable()))."::getTableMap()->getCollectionClassName(); + \$collectionClassName = " . $this->getClassNameFromBuilder($this->getNewTableMapBuilder($refFK->getTable())) . "::getTableMap()->getCollectionClassName(); \$$collName = new \$collectionClassName; \${$collName}->setModel('" . $this->getClassNameFromBuilder($this->getNewStubObjectBuilder($refFK->getTable()), true) . "'); @@ -4411,8 +4694,13 @@ public function get$relCol(Criteria \$criteria = null, ConnectionInterface \$con return \$this->$collName; } "; - } // addRefererGet() + } + // addRefererGet() + + /** + * @return void + */ protected function addRefFKSet(&$script, ForeignKey $refFK) { $relatedName = $this->getRefFKPhpNameAffix($refFK, true); @@ -4424,7 +4712,7 @@ protected function addRefFKSet(&$script, ForeignKey $refFK) $inputCollectionEntry = lcfirst($this->getRefFKPhpNameAffix($refFK, false)); $collName = $this->getRefFKCollVarName($refFK); - $relCol = $this->getFKPhpNameAffix($refFK, $plural = false); + $relCol = $this->getFKPhpNameAffix($refFK, $plural = false); $script .= " /** @@ -4435,7 +4723,7 @@ protected function addRefFKSet(&$script, ForeignKey $refFK) * * @param Collection \${$inputCollection} A Propel collection. * @param ConnectionInterface \$con Optional connection object - * @return \$this|".$this->getObjectClassname()." The current object (for fluent API support) + * @return \$this|" . $this->getObjectClassname() . " The current object (for fluent API support) */ public function set{$relatedName}(Collection \${$inputCollection}, ConnectionInterface \$con = null) { @@ -4477,7 +4765,8 @@ public function set{$relatedName}(Collection \${$inputCollection}, ConnectionInt /** * @param string $script The script will be modified in this method. - * @param ForeignKey $refFK + * @param \Propel\Generator\Model\ForeignKey $refFK + * * @return void */ protected function addRefFKDoAdd(&$script, ForeignKey $refFK) @@ -4508,7 +4797,8 @@ protected function doAdd{$relatedObjectClassName}($className \${$lowerRelatedObj /** * @param string $script The script will be modified in this method. - * @param ForeignKey $refFK + * @param \Propel\Generator\Model\ForeignKey $refFK + * * @return void */ protected function addRefFKRemove(&$script, ForeignKey $refFK) @@ -4521,19 +4811,19 @@ protected function addRefFKRemove(&$script, ForeignKey $refFK) $className = $this->getClassNameFromTable($refFK->getTable(), true); } - $relatedName = $this->getRefFKPhpNameAffix($refFK, $plural = true); - $relatedObjectClassName = $this->getRefFKPhpNameAffix($refFK, $plural = false); - $inputCollection = lcfirst($relatedName . 'ScheduledForDeletion'); + $relatedName = $this->getRefFKPhpNameAffix($refFK, $plural = true); + $relatedObjectClassName = $this->getRefFKPhpNameAffix($refFK, $plural = false); + $inputCollection = lcfirst($relatedName . 'ScheduledForDeletion'); $lowerRelatedObjectClassName = lcfirst($relatedObjectClassName); - $collName = $this->getRefFKCollVarName($refFK); - $relCol = $this->getFKPhpNameAffix($refFK, $plural = false); + $collName = $this->getRefFKCollVarName($refFK); + $relCol = $this->getFKPhpNameAffix($refFK, $plural = false); $localColumn = $refFK->getLocalColumn(); $script .= " /** * @param {$className} \${$lowerRelatedObjectClassName} The $className object to remove. - * @return \$this|". $this->getObjectClassname() ." The current object (for fluent API support) + * @return \$this|" . $this->getObjectClassname() . " The current object (for fluent API support) */ public function remove{$relatedObjectClassName}($className \${$lowerRelatedObjectClassName}) { @@ -4565,8 +4855,10 @@ public function remove{$relatedObjectClassName}($className \${$lowerRelatedObjec /** * Adds the method that gets a one-to-one related referrer fkey. * This is for one-to-one relationship special case. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $refFK + * @param \Propel\Generator\Model\ForeignKey $refFK + * * @return void */ protected function addPKRefFKGet(&$script, ForeignKey $refFK) @@ -4585,7 +4877,7 @@ protected function addPKRefFKGet(&$script, ForeignKey $refFK) * @return $className * @throws PropelException */ - public function get".$this->getRefFKPhpNameAffix($refFK, false)."(ConnectionInterface \$con = null) + public function get" . $this->getRefFKPhpNameAffix($refFK, false) . "(ConnectionInterface \$con = null) { "; $script .= " @@ -4601,8 +4893,10 @@ public function get".$this->getRefFKPhpNameAffix($refFK, false)."(ConnectionInte /** * Adds the method that sets a one-to-one related referrer fkey. * This is for one-to-one relationships special case. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $refFK The referencing foreign key. + * @param \Propel\Generator\Model\ForeignKey $refFK The referencing foreign key. + * * @return void */ protected function addPKRefFKSet(&$script, ForeignKey $refFK) @@ -4616,10 +4910,10 @@ protected function addPKRefFKSet(&$script, ForeignKey $refFK) * Sets a single $className object as related to this object by a one-to-one relationship. * * @param $className \$v $className - * @return \$this|".$this->getObjectClassName(true)." The current object (for fluent API support) + * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) * @throws PropelException */ - public function set".$this->getRefFKPhpNameAffix($refFK, false)."($className \$v = null) + public function set" . $this->getRefFKPhpNameAffix($refFK, false) . "($className \$v = null) { \$this->$varName = \$v; @@ -4670,7 +4964,6 @@ protected function addCrossFKAttributes(&$script, CrossForeignKeys $crossFKs) */ protected \$coll" . $this->getFKPhpNameAffix($fk, true) . "Partial; "; - } } @@ -4715,7 +5008,7 @@ protected function addCrossScheduledForDeletionAttribute(&$script, CrossForeignK protected function getCrossScheduledForDeletionVarName(CrossForeignKeys $crossFKs) { if (1 < count($crossFKs->getCrossForeignKeys()) || $crossFKs->getUnclassifiedPrimaryKeys()) { - return 'combination' . ucfirst($this->getCrossFKsVarName($crossFKs)) . "ScheduledForDeletion"; + return 'combination' . ucfirst($this->getCrossFKsVarName($crossFKs)) . 'ScheduledForDeletion'; } else { $fkName = lcfirst($this->getFKPhpNameAffix($crossFKs->getCrossForeignKeys()[0], true)); @@ -4765,12 +5058,13 @@ protected function addRefFkScheduledForDeletionAttribute(&$script, ForeignKey $r /** * @param string $script - * @param CrossForeignKeys $crossFKs + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * * @return void */ protected function addCrossFkScheduledForDeletion(&$script, CrossForeignKeys $crossFKs) { - $multipleFks = 1 < count($crossFKs->getCrossForeignKeys()) || !!$crossFKs->getUnclassifiedPrimaryKeys(); + $multipleFks = 1 < count($crossFKs->getCrossForeignKeys()) || (bool)$crossFKs->getUnclassifiedPrimaryKeys(); $scheduledForDeletionVarName = $this->getCrossScheduledForDeletionVarName($crossFKs); $queryClassName = $this->getNewStubQueryBuilder($crossFKs->getMiddleTable())->getClassname(); @@ -4786,7 +5080,7 @@ protected function addCrossFkScheduledForDeletion(&$script, CrossForeignKeys $cr \$entryPk = []; "; foreach ($crossFKs->getIncomingForeignKey()->getColumnObjectsMapping() as $reference) { - $local = $reference['local']; + $local = $reference['local']; $foreign = $reference['foreign']; $idx = array_search($local, $crossPks, true); @@ -4797,7 +5091,7 @@ protected function addCrossFkScheduledForDeletion(&$script, CrossForeignKeys $cr $combinationIdx = 0; foreach ($crossFKs->getCrossForeignKeys() as $crossFK) { foreach ($crossFK->getColumnObjectsMapping() as $reference) { - $local = $reference['local']; + $local = $reference['local']; $foreign = $reference['foreign']; $idx = array_search($local, $crossPks, true); @@ -4827,14 +5121,13 @@ protected function addCrossFkScheduledForDeletion(&$script, CrossForeignKeys $cr ->delete(\$con); "; } else { - $script .= " foreach (\$this->{$scheduledForDeletionVarName} as \$entry) { \$entryPk = []; "; foreach ($crossFKs->getIncomingForeignKey()->getColumnObjectsMapping() as $reference) { - $local = $reference['local']; + $local = $reference['local']; $foreign = $reference['foreign']; $idx = array_search($local, $crossPks, true); @@ -4844,7 +5137,7 @@ protected function addCrossFkScheduledForDeletion(&$script, CrossForeignKeys $cr $crossFK = $crossFKs->getCrossForeignKeys()[0]; foreach ($crossFK->getColumnObjectsMapping() as $reference) { - $local = $reference['local']; + $local = $reference['local']; $foreign = $reference['foreign']; $idx = array_search($local, $crossPks, true); @@ -4901,9 +5194,8 @@ protected function addCrossFkScheduledForDeletion(&$script, CrossForeignKeys $cr } "; } else { - foreach ($crossFKs->getCrossForeignKeys() as $fk) { - $relatedName = $this->getFKPhpNameAffix($fk, true); + $relatedName = $this->getFKPhpNameAffix($fk, true); $lowerSingleRelatedName = lcfirst($this->getFKPhpNameAffix($fk, false)); $script .= " @@ -4920,7 +5212,6 @@ protected function addCrossFkScheduledForDeletion(&$script, CrossForeignKeys $cr $script .= " "; - } /** @@ -4931,16 +5222,16 @@ protected function addCrossFkScheduledForDeletion(&$script, CrossForeignKeys $cr */ protected function addRefFkScheduledForDeletion(&$script, ForeignKey $refFK) { - $relatedName = $this->getRefFKPhpNameAffix($refFK, $plural = true); - $lowerRelatedName = lcfirst($relatedName); + $relatedName = $this->getRefFKPhpNameAffix($refFK, $plural = true); + $lowerRelatedName = lcfirst($relatedName); $lowerSingleRelatedName = lcfirst($this->getRefFKPhpNameAffix($refFK, $plural = false)); - $queryClassName = $this->getNewStubQueryBuilder($refFK->getTable())->getClassname(); + $queryClassName = $this->getNewStubQueryBuilder($refFK->getTable())->getClassname(); $script .= " if (\$this->{$lowerRelatedName}ScheduledForDeletion !== null) { if (!\$this->{$lowerRelatedName}ScheduledForDeletion->isEmpty()) {"; - if ($refFK->isLocalColumnsRequired() || ForeignKey::CASCADE === $refFK->getOnDelete()) { + if ($refFK->isLocalColumnsRequired() || $refFK->getOnDelete() === ForeignKey::CASCADE) { $script .= " $queryClassName::create() ->filterByPrimaryKeys(\$this->{$lowerRelatedName}ScheduledForDeletion->getPrimaryKeys(false)) @@ -4989,13 +5280,15 @@ protected function addCrossFKMethods(&$script) /** * Adds the method that clears the referrer fkey collection. - * @param string $script The script will be modified in this method. - * @param CrossForeignKeys $crossFKs + * + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * * @return void */ protected function addCrossFKClear(&$script, CrossForeignKeys $crossFKs) { - $relCol = $this->getCrossFKsPhpNameAffix($crossFKs); + $relCol = $this->getCrossFKsPhpNameAffix($crossFKs); $collName = $this->getCrossFKsVarName($crossFKs); $script .= " @@ -5013,18 +5306,21 @@ public function clear{$relCol}() \$this->$collName = null; // important to set this to NULL since that means it is uninitialized } "; - } // addRefererClear() + } + + // addRefererClear() /** * Adds the method that clears the referrer fkey collection. * * @param string $script The script will be modified in this method. - * @param ForeignKey $refFK + * @param \Propel\Generator\Model\ForeignKey $refFK + * * @return void */ protected function addRefFKPartial(&$script, ForeignKey $refFK) { - $relCol = $this->getRefFKPhpNameAffix($refFK, $plural = true); + $relCol = $this->getRefFKPhpNameAffix($refFK, $plural = true); $collName = $this->getRefFKCollVarName($refFK); $script .= " @@ -5036,12 +5332,16 @@ public function resetPartial{$relCol}(\$v = true) \$this->{$collName}Partial = \$v; } "; - } // addRefFKPartial() + } + + // addRefFKPartial() /** * Adds the method that initializes the referrer fkey collection. - * @param string $script The script will be modified in this method. - * @param CrossForeignKeys $crossFKs + * + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * * @return void */ protected function addCrossFKInit(&$script, CrossForeignKeys $crossFKs) @@ -5050,7 +5350,7 @@ protected function addCrossFKInit(&$script, CrossForeignKeys $crossFKs) if (1 < count($crossFKs->getCrossForeignKeys()) || $crossFKs->getUnclassifiedPrimaryKeys()) { $inits[] = [ - 'relCol' => $this->getCrossFKsPhpNameAffix($crossFKs, true), + 'relCol' => $this->getCrossFKsPhpNameAffix($crossFKs, true), 'collName' => 'combination' . ucfirst($this->getCrossFKsVarName($crossFKs)), 'collectionClass' => 'ObjectCombinationCollection', 'relatedObjectClassName' => false, @@ -5096,12 +5396,12 @@ protected function addCrossFKInit(&$script, CrossForeignKeys $crossFKs) */ public function init$relCol() {"; - if($collectionClass) { + if ($collectionClass) { $script .= " \$this->$collName = new $collectionClass;"; } else { $script .= " - \$collectionClassName = ".$foreignTableMapName."::getTableMap()->getCollectionClassName(); + \$collectionClassName = " . $foreignTableMapName . "::getTableMap()->getCollectionClassName(); \$this->$collName = new \$collectionClassName;"; } @@ -5116,13 +5416,14 @@ public function init$relCol() } "; } - } /** * Adds the method that check if the referrer fkey collection is initialized. - * @param string $script The script will be modified in this method. - * @param CrossForeignKeys $crossFKs + * + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * * @return void */ protected function addCrossFKIsLoaded(&$script, CrossForeignKeys $crossFKs) @@ -5131,11 +5432,10 @@ protected function addCrossFKIsLoaded(&$script, CrossForeignKeys $crossFKs) if (1 < count($crossFKs->getCrossForeignKeys()) || $crossFKs->getUnclassifiedPrimaryKeys()) { $inits[] = [ - 'relCol' => $this->getCrossFKsPhpNameAffix($crossFKs, true), + 'relCol' => $this->getCrossFKsPhpNameAffix($crossFKs, true), 'collName' => 'combination' . ucfirst($this->getCrossFKsVarName($crossFKs)), ]; } else { - foreach ($crossFKs->getCrossForeignKeys() as $crossFK) { $relCol = $this->getFKPhpNameAffix($crossFK, true); $collName = $this->getCrossFKVarName($crossFK); @@ -5186,7 +5486,7 @@ protected function addCrossFKCreateQuery(&$script, CrossForeignKeys $crossFKs) $signature = $shortSignature = $normalizedShortSignature = $phpDoc = []; $this->extractCrossInformation($crossFKs, [$firstFK], $signature, $shortSignature, $normalizedShortSignature, $phpDoc); - $signature = array_map(function($item) { + $signature = array_map(function ($item) { return $item . ' = null'; }, $signature); $signature = implode(', ', $signature); @@ -5243,12 +5543,11 @@ public function create{$firstFkName}Query($signature, Criteria \$criteria = null return \$criteria; } "; - } /** - * @param string $script - * @param CrossForeignKeys $crossFKs + * @param string $script + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs */ protected function addCrossFKGet(&$script, CrossForeignKeys $crossFKs) { @@ -5275,7 +5574,7 @@ protected function addCrossFKGet(&$script, CrossForeignKeys $crossFKs) * If the \$criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. * Next time the same method is called without \$criteria, the cached collection is returned. - * If this ".$this->getObjectClassName()." is new, it will return + * If this " . $this->getObjectClassName() . " is new, it will return * an empty collection or the current collection; the criteria is ignored on a new object. * * @param Criteria \$criteria Optional query object to filter the query @@ -5357,7 +5656,7 @@ public function get{$relatedName}(\$criteria = null, ConnectionInterface \$con = $signature = $shortSignature = $normalizedShortSignature = $phpDoc = []; $this->extractCrossInformation($crossFKs, [$firstFK], $signature, $shortSignature, $normalizedShortSignature, $phpDoc); - $signature = array_map(function($item) { + $signature = array_map(function ($item) { return $item . ' = null'; }, $signature); $signature = implode(', ', $signature); @@ -5380,6 +5679,7 @@ public function get{$firstFkName}($signature, Criteria \$criteria = null, Connec return \$this->create{$firstFkName}Query($shortSignature, \$criteria)->find(\$con); } "; + return; } @@ -5398,7 +5698,7 @@ public function get{$firstFkName}($signature, Criteria \$criteria = null, Connec * If the \$criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. * Next time the same method is called without \$criteria, the cached collection is returned. - * If this ".$this->getObjectClassName()." is new, it will return + * If this " . $this->getObjectClassName() . " is new, it will return * an empty collection or the current collection; the criteria is ignored on a new object. * * @param Criteria \$criteria Optional query object to filter the query @@ -5445,20 +5745,21 @@ public function get{$relatedName}(Criteria \$criteria = null, ConnectionInterfac } /** - * @param string $script - * @param CrossForeignKeys $crossFKs + * @param string $script + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * * @return void */ protected function addCrossFKSet(&$script, CrossForeignKeys $crossFKs) { $scheduledForDeletionVarName = $this->getCrossScheduledForDeletionVarName($crossFKs); - $multi = 1 < count($crossFKs->getCrossForeignKeys()) || !!$crossFKs->getUnclassifiedPrimaryKeys(); + $multi = 1 < count($crossFKs->getCrossForeignKeys()) || (bool)$crossFKs->getUnclassifiedPrimaryKeys(); $relatedNamePlural = $this->getCrossFKsPhpNameAffix($crossFKs, true); - $relatedName = $this->getCrossFKsPhpNameAffix($crossFKs, false); - $inputCollection = lcfirst($relatedNamePlural); - $foreachItem = lcfirst($relatedName); + $relatedName = $this->getCrossFKsPhpNameAffix($crossFKs, false); + $inputCollection = lcfirst($relatedNamePlural); + $foreachItem = lcfirst($relatedName); $crossRefTableName = $crossFKs->getMiddleTable()->getName(); if ($multi) { @@ -5523,17 +5824,17 @@ public function set{$relatedNamePlural}(Collection \${$inputCollection}, Connect } /** - * @param string $script - * @param CrossForeignKeys $crossFKs + * @param string $script + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs */ protected function addCrossFKCount(&$script, CrossForeignKeys $crossFKs) { $refFK = $crossFKs->getIncomingForeignKey(); $selfRelationName = $this->getFKPhpNameAffix($refFK, $plural = false); - $multi = 1 < count($crossFKs->getCrossForeignKeys()) || !!$crossFKs->getUnclassifiedPrimaryKeys(); + $multi = 1 < count($crossFKs->getCrossForeignKeys()) || (bool)$crossFKs->getUnclassifiedPrimaryKeys(); - $relatedName = $this->getCrossFKsPhpNameAffix($crossFKs, true); + $relatedName = $this->getCrossFKsPhpNameAffix($crossFKs, true); $crossRefTableName = $crossFKs->getMiddleTable()->getName(); if ($multi) { @@ -5585,7 +5886,6 @@ public function count{$relatedName}(Criteria \$criteria = null, \$distinct = fal } "; - if ($multi) { $relatedName = $this->getCrossFKsPhpNameAffix($crossFKs, true); $firstFK = $crossFKs->getCrossForeignKeys()[0]; @@ -5595,7 +5895,7 @@ public function count{$relatedName}(Criteria \$criteria = null, \$distinct = fal $signature = $shortSignature = $normalizedShortSignature = $phpDoc = []; $this->extractCrossInformation($crossFKs, [$firstFK], $signature, $shortSignature, $normalizedShortSignature, $phpDoc); - $signature = array_map(function($item) { + $signature = array_map(function ($item) { return $item . ' = null'; }, $signature); $signature = implode(', ', $signature); @@ -5619,14 +5919,14 @@ public function count{$firstFkName}($signature, Criteria \$criteria = null, Conn } "; } - } - /** * Adds the method that adds an object into the referrer fkey collection. - * @param string $script The script will be modified in this method. - * @param CrossForeignKeys $crossFKs + * + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * * @return void */ protected function addCrossFKAdd(&$script, CrossForeignKeys $crossFKs) @@ -5664,9 +5964,9 @@ public function add{$relatedObjectClassName}($signature) \$this->init" . $relNamePlural . "(); } - if (!\$this->get" . $relNamePlural . "()->contains(" . $normalizedShortSignature . ")) { + if (!\$this->get" . $relNamePlural . '()->contains(' . $normalizedShortSignature . ")) { // only add it if the **same** object is not already associated - \$this->" . $collName . "->push(" . $normalizedShortSignature . "); + \$this->" . $collName . '->push(' . $normalizedShortSignature . "); \$this->doAdd{$relName}($normalizedShortSignature); } @@ -5679,8 +5979,9 @@ public function add{$relatedObjectClassName}($signature) /** * Returns a function signature comma separated. * - * @param CrossForeignKeys $crossFKs - * @param string $excludeSignatureItem Which variable to exclude. + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * @param string $excludeSignatureItem Which variable to exclude. + * * @return string */ protected function getCrossFKGetterSignature(CrossForeignKeys $crossFKs, $excludeSignatureItem) @@ -5688,7 +5989,7 @@ protected function getCrossFKGetterSignature(CrossForeignKeys $crossFKs, $exclud [, $getSignature] = $this->getCrossFKAddMethodInformation($crossFKs); $getSignature = explode(', ', $getSignature); - if (false !== ($pos = array_search($excludeSignatureItem, $getSignature))) { + if (($pos = array_search($excludeSignatureItem, $getSignature)) !== false) { unset($getSignature[$pos]); } @@ -5696,20 +5997,21 @@ protected function getCrossFKGetterSignature(CrossForeignKeys $crossFKs, $exclud } /** - * @param string $script The script will be modified in this method. - * @param CrossForeignKeys $crossFKs + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * * @return void */ protected function addCrossFKDoAdd(&$script, CrossForeignKeys $crossFKs) { - $selfRelationName = $this->getFKPhpNameAffix($crossFKs->getIncomingForeignKey(), $plural = false); - $selfRelationNamePlural = $this->getFKPhpNameAffix($crossFKs->getIncomingForeignKey(), $plural = true); - $relatedObjectClassName = $this->getCrossFKsPhpNameAffix($crossFKs, $plural = false); - $className = $this->getClassNameFromTable($crossFKs->getIncomingForeignKey()->getTable()); + $selfRelationName = $this->getFKPhpNameAffix($crossFKs->getIncomingForeignKey(), $plural = false); + $selfRelationNamePlural = $this->getFKPhpNameAffix($crossFKs->getIncomingForeignKey(), $plural = true); + $relatedObjectClassName = $this->getCrossFKsPhpNameAffix($crossFKs, $plural = false); + $className = $this->getClassNameFromTable($crossFKs->getIncomingForeignKey()->getTable()); - $refKObjectClassName = $this->getRefFKPhpNameAffix($crossFKs->getIncomingForeignKey(), $plural = false); - $tblFK = $crossFKs->getIncomingForeignKey()->getTable(); - $foreignObjectName = '$' . $tblFK->getCamelCaseName(); + $refKObjectClassName = $this->getRefFKPhpNameAffix($crossFKs->getIncomingForeignKey(), $plural = false); + $tblFK = $crossFKs->getIncomingForeignKey()->getTable(); + $foreignObjectName = '$' . $tblFK->getCamelCaseName(); [$signature, $shortSignature, $normalizedShortSignature, $phpDoc] = $this->getCrossFKAddMethodInformation($crossFKs); @@ -5737,7 +6039,7 @@ protected function doAdd{$relatedObjectClassName}($signature) } } else { $crossFK = $crossFKs->getCrossForeignKeys()[0]; - $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, $plural = false); + $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, $plural = false); $lowerRelatedObjectClassName = lcfirst($relatedObjectClassName); $script .= " {$foreignObjectName}->set{$relatedObjectClassName}(\${$lowerRelatedObjectClassName});"; @@ -5767,11 +6069,9 @@ protected function doAdd{$relatedObjectClassName}($signature) } elseif (!\${$lowerRelatedObjectClassName}->get{$getterName}()->contains($getterRemoveObjectName)) { \${$lowerRelatedObjectClassName}->get{$getterName}()->push($getterRemoveObjectName); }\n"; - } - } else { - $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, $plural = false); + $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, $plural = false); $lowerRelatedObjectClassName = lcfirst($relatedObjectClassName); $getterSignature = $this->getCrossFKGetterSignature($crossFKs, '$' . $lowerRelatedObjectClassName); $script .= " @@ -5783,7 +6083,6 @@ protected function doAdd{$relatedObjectClassName}($signature) } elseif (!\${$lowerRelatedObjectClassName}->get{$selfRelationNamePlural}($getterSignature)->contains(\$this)) { \${$lowerRelatedObjectClassName}->get{$selfRelationNamePlural}($getterSignature)->push(\$this); }\n"; - } $script .= " @@ -5792,8 +6091,9 @@ protected function doAdd{$relatedObjectClassName}($signature) } /** - * @param CrossForeignKeys $crossFKs - * @param ForeignKey $excludeFK + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * @param \Propel\Generator\Model\ForeignKey $excludeFK + * * @return string */ protected function getCrossRefFKRemoveObjectNames(CrossForeignKeys $crossFKs, ForeignKey $excludeFK) @@ -5821,23 +6121,25 @@ protected function getCrossRefFKRemoveObjectNames(CrossForeignKeys $crossFKs, Fo /** * Adds the method that remove an object from the referrer fkey collection. - * @param string $script The script will be modified in this method. - * @param CrossForeignKeys $crossFKs + * + * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * * @return void */ protected function addCrossFKRemove(&$script, CrossForeignKeys $crossFKs) { - $relCol = $this->getCrossFKsPhpNameAffix($crossFKs, $plural = true); + $relCol = $this->getCrossFKsPhpNameAffix($crossFKs, $plural = true); if (1 < count($crossFKs->getCrossForeignKeys()) || $crossFKs->getUnclassifiedPrimaryKeys()) { $collName = 'combination' . ucfirst($this->getCrossFKsVarName($crossFKs)); } else { $collName = $this->getCrossFKsVarName($crossFKs); } - $tblFK = $crossFKs->getIncomingForeignKey()->getTable(); + $tblFK = $crossFKs->getIncomingForeignKey()->getTable(); - $M2MScheduledForDeletion = $this->getCrossScheduledForDeletionVarName($crossFKs); - $relatedObjectClassName = $this->getCrossFKsPhpNameAffix($crossFKs, $plural = false); + $M2MScheduledForDeletion = $this->getCrossScheduledForDeletionVarName($crossFKs); + $relatedObjectClassName = $this->getCrossFKsPhpNameAffix($crossFKs, $plural = false); [$signature, $shortSignature, $normalizedShortSignature, $phpDoc] = $this->getCrossFKAddMethodInformation($crossFKs); $names = str_replace('$', '', $normalizedShortSignature); @@ -5861,7 +6163,7 @@ public function remove{$relatedObjectClassName}($signature) $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, $plural = false); $lowerRelatedObjectClassName = lcfirst($relatedObjectClassName); - $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, $plural = false); + $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, $plural = false); $script .= " {$foreignObjectName}->set{$relatedObjectClassName}(\${$lowerRelatedObjectClassName});"; @@ -5875,7 +6177,6 @@ public function remove{$relatedObjectClassName}($signature) //remove the back reference if available \${$lowerRelatedObjectClassName}->get$getterName()->removeObject($getterRemoveObjectName); }\n"; - } foreach ($crossFKs->getUnclassifiedPrimaryKeys() as $primaryKey) { @@ -5911,7 +6212,9 @@ public function remove{$relatedObjectClassName}($signature) /** * Adds the workhourse doSave() method. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addDoSave(&$script) @@ -5938,7 +6241,7 @@ protected function addDoSave(&$script) * @throws PropelException * @see save() */ - protected function doSave(ConnectionInterface \$con".($reloadOnUpdate || $reloadOnInsert ? ", \$skipReload = false" : "").") + protected function doSave(ConnectionInterface \$con" . ($reloadOnUpdate || $reloadOnInsert ? ', $skipReload = false' : '') . ") { \$affectedRows = 0; // initialize var to track total num of affected rows if (!\$this->alreadyInSave) { @@ -5951,7 +6254,6 @@ protected function doSave(ConnectionInterface \$con".($reloadOnUpdate || $reload } if (count($table->getForeignKeys())) { - $script .= " // We call the save method on the following object(s) if they // were passed to this object by their corresponding set @@ -5963,10 +6265,10 @@ protected function doSave(ConnectionInterface \$con".($reloadOnUpdate || $reload $aVarName = $this->getFKVarName($fk); $script .= " if (\$this->$aVarName !== null) { - if (\$this->" . $aVarName . "->isModified() || \$this->" . $aVarName . "->isNew()) { + if (\$this->" . $aVarName . '->isModified() || $this->' . $aVarName . "->isNew()) { \$affectedRows += \$this->" . $aVarName . "->save(\$con); } - \$this->set".$this->getFKPhpNameAffix($fk, false)."(\$this->$aVarName); + \$this->set" . $this->getFKPhpNameAffix($fk, false) . "(\$this->$aVarName); } "; } // foreach foreign k @@ -6062,7 +6364,6 @@ protected function doSave(ConnectionInterface \$con".($reloadOnUpdate || $reload return \$affectedRows; } // doSave() "; - } /** @@ -6085,9 +6386,9 @@ protected function addDoInsert() protected function doInsert(ConnectionInterface \$con) {"; if ($this->getPlatform() instanceof MssqlPlatform) { - if ($table->hasAutoIncrementPrimaryKey() ) { + if ($table->hasAutoIncrementPrimaryKey()) { $script .= " - \$this->modifiedColumns[" . $this->getColumnConstant($table->getAutoIncrementPrimaryKey()).'] = true;'; + \$this->modifiedColumns[" . $this->getColumnConstant($table->getAutoIncrementPrimaryKey()) . '] = true;'; } $script .= " \$criteria = \$this->buildCriteria();"; @@ -6156,11 +6457,11 @@ protected function addDoInsertBodyWithIdMethod() if ($table->isAllowPkInsert()) { $script .= " if (\$pk !== null) { - \$this->set".$col->getPhpName()."(\$pk); //[IMV] update autoincrement primary key + \$this->set" . $col->getPhpName() . "(\$pk); //[IMV] update autoincrement primary key }"; } else { $script .= " - \$this->set".$col->getPhpName()."(\$pk); //[IMV] update autoincrement primary key"; + \$this->set" . $col->getPhpName() . '($pk); //[IMV] update autoincrement primary key'; } } @@ -6169,6 +6470,8 @@ protected function addDoInsertBodyWithIdMethod() /** * Boosts ActiveRecord::doInsert() by doing more calculations at buildtime. + * + * @throws \Propel\Runtime\Exception\PropelException */ protected function addDoInsertBodyRaw() { @@ -6218,7 +6521,7 @@ protected function addDoInsertBodyRaw() } // if non auto-increment but using sequence, get the id first - if (!$platform->isNativeIdMethodAutoIncrement() && $table->getIdMethod() == "native") { + if (!$platform->isNativeIdMethodAutoIncrement() && $table->getIdMethod() == 'native') { $column = $table->getFirstPrimaryKeyColumn(); if (!$column) { throw new PropelException('Cannot find primary key column in table `' . $table->getName() . '`.'); @@ -6227,7 +6530,7 @@ protected function addDoInsertBodyRaw() $script .= " if (null === \$this->{$columnProperty}) { try {"; - $script .= $platform->getIdentifierPhp('$this->'. $columnProperty, '$con', $primaryKeyMethodInfo, ' ', $column->getPhpType()); + $script .= $platform->getIdentifierPhp('$this->' . $columnProperty, '$con', $primaryKeyMethodInfo, ' ', $column->getPhpType()); $script .= " } catch (Exception \$e) { throw new PropelException('Unable to get sequence id.', 0, \$e); @@ -6264,7 +6567,7 @@ protected function addDoInsertBodyRaw() $columnNameCase = var_export($this->quoteIdentifier($column->getName()), true); $script .= " case $columnNameCase:"; - $script .= $platform->getColumnBindingPHP($column, "\$identifier", '$this->' . $column->getLowercasedName(), ' '); + $script .= $platform->getColumnBindingPHP($column, '$identifier', '$this->' . $column->getLowercasedName(), ' '); $script .= " break;"; } @@ -6279,7 +6582,7 @@ protected function addDoInsertBodyRaw() "; // if auto-increment, get the id after - if ($platform->isNativeIdMethodAutoIncrement() && $table->getIdMethod() == "native") { + if ($platform->isNativeIdMethodAutoIncrement() && $table->getIdMethod() == 'native') { $script .= " try {"; $script .= $platform->getIdentifierPhp('$pk', '$con', $primaryKeyMethodInfo); @@ -6292,11 +6595,11 @@ protected function addDoInsertBodyRaw() if ($table->isAllowPkInsert()) { $script .= " if (\$pk !== null) { - \$this->set".$column->getPhpName()."(\$pk); + \$this->set" . $column->getPhpName() . "(\$pk); }"; } else { $script .= " - \$this->set".$column->getPhpName()."(\$pk);"; + \$this->set" . $column->getPhpName() . '($pk);'; } } $script .= " @@ -6334,7 +6637,9 @@ protected function doUpdate(ConnectionInterface \$con) /** * Adds the $alreadyInSave attribute, which prevents attempting to re-save the same object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addAlreadyInSaveAttribute(&$script) @@ -6352,7 +6657,9 @@ protected function addAlreadyInSaveAttribute(&$script) /** * Adds the save() method. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addSave(&$script) @@ -6365,8 +6672,11 @@ protected function addSave(&$script) /** * Adds the comment for the save method - * @param string $script The script will be modified in this method. + * * @see addSave() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addSaveComment(&$script) @@ -6413,8 +6723,11 @@ protected function addSaveComment(&$script) /** * Adds the function declaration for the save method - * @param string $script The script will be modified in this method. + * * @see addSave() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addSaveOpen(&$script) @@ -6423,14 +6736,17 @@ protected function addSaveOpen(&$script) $reloadOnUpdate = $table->isReloadOnUpdate(); $reloadOnInsert = $table->isReloadOnInsert(); $script .= " - public function save(ConnectionInterface \$con = null".($reloadOnUpdate || $reloadOnInsert ? ", \$skipReload = false" : "").") + public function save(ConnectionInterface \$con = null" . ($reloadOnUpdate || $reloadOnInsert ? ', $skipReload = false' : '') . ") {"; } /** * Adds the function body for the save method - * @param string $script The script will be modified in this method. + * * @see addSave() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addSaveBody(&$script) @@ -6449,42 +6765,42 @@ protected function addSaveBody(&$script) } if (\$con === null) { - \$con = Propel::getServiceContainer()->getWriteConnection(".$this->getTableMapClass()."::DATABASE_NAME); + \$con = Propel::getServiceContainer()->getWriteConnection(" . $this->getTableMapClass() . "::DATABASE_NAME); } - return \$con->transaction(function () use (\$con".($reloadOnUpdate || $reloadOnInsert ? ", \$skipReload" : "").") {"; + return \$con->transaction(function () use (\$con" . ($reloadOnUpdate || $reloadOnInsert ? ', $skipReload' : '') . ') {'; if ($this->getBuildProperty('generator.objectModel.addHooks')) { // save with runtime hooks $script .= " \$ret = \$this->preSave(\$con); \$isInsert = \$this->isNew();"; - $this->applyBehaviorModifier('preSave', $script, " "); + $this->applyBehaviorModifier('preSave', $script, ' '); $script .= " if (\$isInsert) { \$ret = \$ret && \$this->preInsert(\$con);"; - $this->applyBehaviorModifier('preInsert', $script, " "); + $this->applyBehaviorModifier('preInsert', $script, ' '); $script .= " } else { \$ret = \$ret && \$this->preUpdate(\$con);"; - $this->applyBehaviorModifier('preUpdate', $script, " "); + $this->applyBehaviorModifier('preUpdate', $script, ' '); $script .= " } if (\$ret) { - \$affectedRows = \$this->doSave(\$con".($reloadOnUpdate || $reloadOnInsert ? ", \$skipReload" : "")."); + \$affectedRows = \$this->doSave(\$con" . ($reloadOnUpdate || $reloadOnInsert ? ', $skipReload' : '') . "); if (\$isInsert) { \$this->postInsert(\$con);"; - $this->applyBehaviorModifier('postInsert', $script, " "); + $this->applyBehaviorModifier('postInsert', $script, ' '); $script .= " } else { \$this->postUpdate(\$con);"; - $this->applyBehaviorModifier('postUpdate', $script, " "); + $this->applyBehaviorModifier('postUpdate', $script, ' '); $script .= " } \$this->postSave(\$con);"; - $this->applyBehaviorModifier('postSave', $script, " "); + $this->applyBehaviorModifier('postSave', $script, ' '); $script .= " - ".$this->getTableMapClassName()."::addInstanceToPool(\$this); + " . $this->getTableMapClassName() . "::addInstanceToPool(\$this); } else { \$affectedRows = 0; } @@ -6494,40 +6810,40 @@ protected function addSaveBody(&$script) // save without runtime hooks $script .= " \$isInsert = \$this->isNew();"; - $this->applyBehaviorModifier('preSave', $script, " "); + $this->applyBehaviorModifier('preSave', $script, ' '); if ($this->hasBehaviorModifier('preUpdate')) { $script .= " if (!\$isInsert) {"; - $this->applyBehaviorModifier('preUpdate', $script, " "); + $this->applyBehaviorModifier('preUpdate', $script, ' '); $script .= " }"; } if ($this->hasBehaviorModifier('preInsert')) { $script .= " if (\$isInsert) {"; - $this->applyBehaviorModifier('preInsert', $script, " "); + $this->applyBehaviorModifier('preInsert', $script, ' '); $script .= " }"; } $script .= " - \$affectedRows = \$this->doSave(\$con".($reloadOnUpdate || $reloadOnInsert ? ", \$skipReload" : "").");"; - $this->applyBehaviorModifier('postSave', $script, " "); + \$affectedRows = \$this->doSave(\$con" . ($reloadOnUpdate || $reloadOnInsert ? ', $skipReload' : '') . ');'; + $this->applyBehaviorModifier('postSave', $script, ' '); if ($this->hasBehaviorModifier('postUpdate')) { $script .= " if (!\$isInsert) {"; - $this->applyBehaviorModifier('postUpdate', $script, " "); + $this->applyBehaviorModifier('postUpdate', $script, ' '); $script .= " }"; } if ($this->hasBehaviorModifier('postInsert')) { $script .= " if (\$isInsert) {"; - $this->applyBehaviorModifier('postInsert', $script, " "); + $this->applyBehaviorModifier('postInsert', $script, ' '); $script .= " }"; } $script .= " - ".$this->getTableMapClassName()."::addInstanceToPool(\$this); + " . $this->getTableMapClassName() . "::addInstanceToPool(\$this); return \$affectedRows;"; } @@ -6538,8 +6854,11 @@ protected function addSaveBody(&$script) /** * Adds the function close for the save method - * @param string $script The script will be modified in this method. + * * @see addSave() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addSaveClose(&$script) @@ -6551,7 +6870,9 @@ protected function addSaveClose(&$script) /** * Adds the ensureConsistency() method to ensure that internal state is correct. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addEnsureConsistency(&$script) @@ -6575,12 +6896,10 @@ protected function addEnsureConsistency(&$script) public function ensureConsistency() {"; foreach ($table->getColumns() as $col) { - - $clo=$col->getLowercasedName(); + $clo = $col->getLowercasedName(); if ($col->isForeignKey()) { foreach ($col->getForeignKeys() as $fk) { - $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName()); $colFK = $tblFK->getColumn($fk->getMappedForeignColumn($col->getName())); $varName = $this->getFKVarName($fk); @@ -6590,22 +6909,25 @@ public function ensureConsistency() } $script .= " - if (\$this->".$varName." !== null && \$this->$clo !== \$this->".$varName."->get".$colFK->getPhpName()."()) { + if (\$this->" . $varName . " !== null && \$this->$clo !== \$this->" . $varName . '->get' . $colFK->getPhpName() . "()) { \$this->$varName = null; }"; } // foreach } /* if col is foreign key */ - } // foreach $script .= " } // ensureConsistency "; - } // addCheckRelConsistency + } + + // addCheckRelConsistency /** * Adds the copy() method, which (in complex OM) includes the $deepCopy param for making copies of related objects. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addCopy(&$script) @@ -6622,7 +6944,7 @@ protected function addCopy(&$script) * objects. * * @param boolean \$deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return ".$this->getObjectClassName(true)." Clone of current object. + * @return " . $this->getObjectClassName(true) . " Clone of current object. * @throws PropelException */ public function copy(\$deepCopy = false) @@ -6640,7 +6962,9 @@ public function copy(\$deepCopy = false) /** * Adds the copyInto() method, which takes an object and sets contents to match current object. * In complex OM this method includes the $deepCopy param for making copies of related objects. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addCopyInto(&$script) @@ -6654,7 +6978,7 @@ protected function addCopyInto(&$script) * If desired, this method can also make copies of all associated (fkey referrers) * objects. * - * @param object \$copyObj An object of ".$this->getObjectClassName(true)." (or compatible) type. + * @param object \$copyObj An object of " . $this->getObjectClassName(true) . " (or compatible) type. * @param boolean \$deepCopy Whether to also copy all rows that refer (by fkey) to the current row. * @param boolean \$makeNew Whether to reset autoincrement PKs and make the object new. * @throws PropelException @@ -6664,7 +6988,7 @@ public function copyInto(\$copyObj, \$deepCopy = false, \$makeNew = true) $autoIncCols = []; foreach ($table->getColumns() as $col) { - /* @var $col Column */ + /** @var \Propel\Generator\Model\Column $col */ if ($col->isAutoIncrement()) { $autoIncCols[] = $col; } @@ -6673,7 +6997,7 @@ public function copyInto(\$copyObj, \$deepCopy = false, \$makeNew = true) foreach ($table->getColumns() as $col) { if (!in_array($col, $autoIncCols, true)) { $script .= " - \$copyObj->set".$col->getPhpName()."(\$this->get".$col->getPhpName()."());"; + \$copyObj->set" . $col->getPhpName() . '($this->get' . $col->getPhpName() . '());'; } } // foreach @@ -6693,7 +7017,6 @@ public function copyInto(\$copyObj, \$deepCopy = false, \$makeNew = true) //if ( $fk->getTable()->getName() != $table->getName() ) { if ($fk->isLocalPrimaryKey()) { - $afx = $this->getRefFKPhpNameAffix($fk, false); $script .= " \$relObj = \$this->get$afx(); @@ -6702,11 +7025,10 @@ public function copyInto(\$copyObj, \$deepCopy = false, \$makeNew = true) } "; } else { - $script .= " - foreach (\$this->get".$this->getRefFKPhpNameAffix($fk, true)."() as \$relObj) { + foreach (\$this->get" . $this->getRefFKPhpNameAffix($fk, true) . "() as \$relObj) { if (\$relObj !== \$this) { // ensure that we don't try to copy a reference to ourselves - \$copyObj->add".$this->getRefFKPhpNameAffix($fk)."(\$relObj->copy(\$deepCopy)); + \$copyObj->add" . $this->getRefFKPhpNameAffix($fk) . "(\$relObj->copy(\$deepCopy)); } } "; @@ -6729,17 +7051,21 @@ public function copyInto(\$copyObj, \$deepCopy = false, \$makeNew = true) $coldefval = $col->getPhpDefaultValue(); $coldefval = var_export($coldefval, true); $script .= " - \$copyObj->set".$col->getPhpName() ."($coldefval); // this is a auto-increment column, so set to default value"; + \$copyObj->set" . $col->getPhpName() . "($coldefval); // this is a auto-increment column, so set to default value"; } // foreach $script .= " } } "; - } // addCopyInto() + } + + // addCopyInto() /** * Adds clear method + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClear(&$script) @@ -6767,21 +7093,21 @@ public function clear() foreach ($table->getColumns() as $col) { $clo = $col->getLowercasedName(); $script .= " - \$this->".$clo." = null;"; + \$this->" . $clo . ' = null;'; if ($col->isLazyLoad()) { $script .= " - \$this->".$clo."_isLoaded = false;"; + \$this->" . $clo . '_isLoaded = false;'; } if ($col->getType() == PropelTypes::OBJECT || $col->getType() == PropelTypes::PHP_ARRAY) { - $cloUnserialized = $clo.'_unserialized'; + $cloUnserialized = $clo . '_unserialized'; - $script .=" + $script .= " \$this->$cloUnserialized = null;"; } if ($col->isSetType()) { $cloConverted = $clo . '_converted'; - $script .=" + $script .= " \$this->$cloConverted = null;"; } } @@ -6803,11 +7129,12 @@ public function clear() "; } - /** * Adds clearAllReferences() method which resets all the collections of referencing * fk objects. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClearAllReferences(&$script) @@ -6862,7 +7189,7 @@ public function clearAllReferences(\$deep = false) } // if (\$deep) "; - $this->applyBehaviorModifier('objectClearReferences', $script, " "); + $this->applyBehaviorModifier('objectClearReferences', $script, ' '); foreach ($vars as $varName) { $script .= " @@ -6882,7 +7209,9 @@ public function clearAllReferences(\$deep = false) /** * Adds a magic __toString() method if a string column was defined as primary string + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addPrimaryString(&$script) @@ -6922,15 +7251,16 @@ public function __toString() * Adds a magic __call() method. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addMagicCall(&$script) { $behaviorCallScript = ''; - $this->applyBehaviorModifier('objectCall', $behaviorCallScript, " "); + $this->applyBehaviorModifier('objectCall', $behaviorCallScript, ' '); $script .= $this->renderTemplate('baseObjectMethodMagicCall', [ - 'behaviorCallScript' => $behaviorCallScript + 'behaviorCallScript' => $behaviorCallScript, ]); } diff --git a/src/Propel/Generator/Builder/Om/QueryBuilder.php b/src/Propel/Generator/Builder/Om/QueryBuilder.php index d84b3c5926..8a777fb46a 100644 --- a/src/Propel/Generator/Builder/Om/QueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryBuilder.php @@ -52,6 +52,7 @@ public function getNamespace() /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassName() @@ -61,17 +62,21 @@ public function getUnprefixedClassName() /** * Returns parent class name that extends TableQuery Object if is set this class must extends ModelCriteria for be compatible + * * @return string */ public function getParentClass() { $parentClass = $this->getBehaviorContent('parentClass'); - return null === $parentClass ? ($this->getTable()->getBaseQueryClass() != "" ? $this->getTable()->getBaseQueryClass() : 'ModelCriteria') : $parentClass; + + return $parentClass === null ? ($this->getTable()->getBaseQueryClass() != '' ? $this->getTable()->getBaseQueryClass() : 'ModelCriteria') : $parentClass; } /** * Adds class phpdoc comment and opening of class. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClassOpen(&$script) @@ -100,7 +105,7 @@ protected function addClassOpen(&$script) // magic orderBy() methods, for IDE completion foreach ($this->getTable()->getColumns() as $column) { $script .= " - * @method $queryClass orderBy" . $column->getPhpName() . "(\$order = Criteria::ASC) Order by the " . $column->getName() . " column"; + * @method $queryClass orderBy" . $column->getPhpName() . '($order = Criteria::ASC) Order by the ' . $column->getName() . ' column'; } $script .= " *"; @@ -108,7 +113,7 @@ protected function addClassOpen(&$script) // magic groupBy() methods, for IDE completion foreach ($this->getTable()->getColumns() as $column) { $script .= " - * @method $queryClass groupBy" . $column->getPhpName() . "() Group by the " . $column->getName() . " column"; + * @method $queryClass groupBy" . $column->getPhpName() . '() Group by the ' . $column->getName() . ' column'; } // override the signature of ModelCriteria::left-, right- and innerJoin to specify the class of the returned object, for IDE completion @@ -132,19 +137,19 @@ protected function addClassOpen(&$script) $relationName = $this->getFKPhpNameAffix($fk); $script .= " - * @method $queryClass leftJoin" . $relationName . "(\$relationAlias = null) Adds a LEFT JOIN clause to the query using the " . $relationName . " relation - * @method $queryClass rightJoin" . $relationName . "(\$relationAlias = null) Adds a RIGHT JOIN clause to the query using the " . $relationName . " relation - * @method $queryClass innerJoin" . $relationName . "(\$relationAlias = null) Adds a INNER JOIN clause to the query using the " . $relationName . " relation + * @method $queryClass leftJoin" . $relationName . '($relationAlias = null) Adds a LEFT JOIN clause to the query using the ' . $relationName . " relation + * @method $queryClass rightJoin" . $relationName . '($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ' . $relationName . " relation + * @method $queryClass innerJoin" . $relationName . '($relationAlias = null) Adds a INNER JOIN clause to the query using the ' . $relationName . " relation *"; $script .= " - * @method $queryClass joinWith" . $relationName . "(\$joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the " . $relationName . " relation + * @method $queryClass joinWith" . $relationName . '($joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the ' . $relationName . " relation *"; $script .= " - * @method $queryClass leftJoinWith" . $relationName . "() Adds a LEFT JOIN clause and with to the query using the " . $relationName . " relation - * @method $queryClass rightJoinWith" . $relationName . "() Adds a RIGHT JOIN clause and with to the query using the " . $relationName . " relation - * @method $queryClass innerJoinWith" . $relationName . "() Adds a INNER JOIN clause and with to the query using the " . $relationName . " relation + * @method $queryClass leftJoinWith" . $relationName . '() Adds a LEFT JOIN clause and with to the query using the ' . $relationName . " relation + * @method $queryClass rightJoinWith" . $relationName . '() Adds a RIGHT JOIN clause and with to the query using the ' . $relationName . " relation + * @method $queryClass innerJoinWith" . $relationName . '() Adds a INNER JOIN clause and with to the query using the ' . $relationName . " relation *"; $relationQueryClasses[$this->getNewStubQueryBuilder($fk->getForeignTable())->getQueryClassName(true)] = true; @@ -153,19 +158,19 @@ protected function addClassOpen(&$script) $relationName = $this->getRefFKPhpNameAffix($refFK); $script .= " - * @method $queryClass leftJoin" . $relationName . "(\$relationAlias = null) Adds a LEFT JOIN clause to the query using the " . $relationName . " relation - * @method $queryClass rightJoin" . $relationName . "(\$relationAlias = null) Adds a RIGHT JOIN clause to the query using the " . $relationName . " relation - * @method $queryClass innerJoin" . $relationName . "(\$relationAlias = null) Adds a INNER JOIN clause to the query using the " . $relationName . " relation + * @method $queryClass leftJoin" . $relationName . '($relationAlias = null) Adds a LEFT JOIN clause to the query using the ' . $relationName . " relation + * @method $queryClass rightJoin" . $relationName . '($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ' . $relationName . " relation + * @method $queryClass innerJoin" . $relationName . '($relationAlias = null) Adds a INNER JOIN clause to the query using the ' . $relationName . " relation *"; $script .= " - * @method $queryClass joinWith" . $relationName . "(\$joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the " . $relationName . " relation + * @method $queryClass joinWith" . $relationName . '($joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the ' . $relationName . " relation *"; $script .= " - * @method $queryClass leftJoinWith" . $relationName . "() Adds a LEFT JOIN clause and with to the query using the " . $relationName . " relation - * @method $queryClass rightJoinWith" . $relationName . "() Adds a RIGHT JOIN clause and with to the query using the " . $relationName . " relation - * @method $queryClass innerJoinWith" . $relationName . "() Adds a INNER JOIN clause and with to the query using the " . $relationName . " relation + * @method $queryClass leftJoinWith" . $relationName . '() Adds a LEFT JOIN clause and with to the query using the ' . $relationName . " relation + * @method $queryClass rightJoinWith" . $relationName . '() Adds a RIGHT JOIN clause and with to the query using the ' . $relationName . " relation + * @method $queryClass innerJoinWith" . $relationName . '() Adds a INNER JOIN clause and with to the query using the ' . $relationName . " relation *"; $relationQueryClasses[$this->getNewStubQueryBuilder($refFK->getTable())->getQueryClassName(true)] = true; @@ -187,7 +192,7 @@ protected function addClassOpen(&$script) // magic findBy() methods, for IDE completion foreach ($this->getTable()->getColumns() as $column) { $script .= " - * @method $modelClass findOneBy" . $column->getPhpName() . "(" . $column->getPhpType() . " \$" . $column->getName() . ") Return the first $modelClass filtered by the " . $column->getName() . " column"; + * @method $modelClass findOneBy" . $column->getPhpName() . '(' . $column->getPhpType() . ' $' . $column->getName() . ") Return the first $modelClass filtered by the " . $column->getName() . ' column'; } $script .= " * \n"; @@ -201,7 +206,7 @@ protected function addClassOpen(&$script) // magic requireOneBy() methods, for IDE completion foreach ($this->getTable()->getColumns() as $column) { $script .= " - * @method $modelClass requireOneBy" . $column->getPhpName() . "(" . $column->getPhpType() . " \$" . $column->getName() . ") Return the first $modelClass filtered by the " . $column->getName() . " column and throws {$this->getEntityNotFoundExceptionClass()} when not found"; + * @method $modelClass requireOneBy" . $column->getPhpName() . '(' . $column->getPhpType() . ' $' . $column->getName() . ") Return the first $modelClass filtered by the " . $column->getName() . " column and throws {$this->getEntityNotFoundExceptionClass()} when not found"; } $script .= " @@ -209,14 +214,14 @@ protected function addClassOpen(&$script) * @method {$modelClass}[]|ObjectCollection find(ConnectionInterface \$con = null) Return $modelClass objects based on current ModelCriteria"; foreach ($this->getTable()->getColumns() as $column) { $script .= " - * @method {$modelClass}[]|ObjectCollection findBy" . $column->getPhpName() . "(" . $column->getPhpType() . " \$" . $column->getName() . ") Return $modelClass objects filtered by the " . $column->getName() . " column"; + * @method {$modelClass}[]|ObjectCollection findBy" . $column->getPhpName() . '(' . $column->getPhpType() . ' $' . $column->getName() . ") Return $modelClass objects filtered by the " . $column->getName() . ' column'; } $script .= " * @method {$modelClass}[]|\\Propel\\Runtime\\Util\\PropelModelPager paginate(\$page = 1, \$maxPerPage = 10, ConnectionInterface \$con = null) Issue a SELECT query based on the current ModelCriteria and uses a page and a maximum number of results per page to compute an offset and a limit * */ -abstract class ".$this->getUnqualifiedClassName()." extends " . $parentClass . " +abstract class " . $this->getUnqualifiedClassName() . ' extends ' . $parentClass . " { "; } @@ -228,6 +233,7 @@ abstract class ".$this->getUnqualifiedClassName()." extends " . $parentClass . " * if you want to change that behavior. * * @see ObjectBuilder::addClassBody() + * * @return void */ protected function addClassBody(&$script) @@ -247,7 +253,7 @@ protected function addClassBody(&$script) $this->declareClassFromBuilder($this->getTableMapBuilder()); // apply behaviors - $this->applyBehaviorModifier('queryAttributes', $script, " "); + $this->applyBehaviorModifier('queryAttributes', $script, ' '); $this->addEntityNotFoundExceptionClass($script); $this->addConstructor($script); $this->addFactory($script); @@ -266,7 +272,6 @@ protected function addClassBody(&$script) $this->addFilterBySetCol($script, $col); } } - } foreach ($this->getTable()->getForeignKeys() as $fk) { $this->addFilterByFK($script, $fk); @@ -294,15 +299,16 @@ protected function addClassBody(&$script) } // apply behaviors - $this->applyBehaviorModifier('staticConstants', $script, " "); - $this->applyBehaviorModifier('staticAttributes', $script, " "); - $this->applyBehaviorModifier('staticMethods', $script, " "); - $this->applyBehaviorModifier('queryMethods', $script, " "); + $this->applyBehaviorModifier('staticConstants', $script, ' '); + $this->applyBehaviorModifier('staticAttributes', $script, ' '); + $this->applyBehaviorModifier('staticMethods', $script, ' '); + $this->applyBehaviorModifier('queryMethods', $script, ' '); } /** * Adds the entityNotFoundExceptionClass property which is necessary for the `requireOne` method * of the `ModelCriteria` + * * @return void */ protected function addEntityNotFoundExceptionClass(&$script) @@ -320,7 +326,9 @@ private function getEntityNotFoundExceptionClass() /** * Adds the doDeleteAll(), etc. methods. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addDeleteMethods(&$script) @@ -339,14 +347,15 @@ protected function addDeleteMethods(&$script) /** * Whether the platform in use requires ON DELETE CASCADE emulation and whether there are references to this table. - * @return boolean + * + * @return bool */ protected function isDeleteCascadeEmulationNeeded() { $table = $this->getTable(); if ((!$this->getPlatform()->supportsNativeDeleteTrigger() || $this->getBuildProperty('generator.objectModel.emulateForeignKeyConstraints')) && count($table->getReferrers()) > 0) { foreach ($table->getReferrers() as $fk) { - if ( ForeignKey::CASCADE === $fk->getOnDelete()) { + if ($fk->getOnDelete() === ForeignKey::CASCADE) { return true; } } @@ -357,14 +366,15 @@ protected function isDeleteCascadeEmulationNeeded() /** * Whether the platform in use requires ON DELETE SETNULL emulation and whether there are references to this table. - * @return boolean + * + * @return bool */ protected function isDeleteSetNullEmulationNeeded() { $table = $this->getTable(); if ((!$this->getPlatform()->supportsNativeDeleteTrigger() || $this->getBuildProperty('generator.objectModel.emulateForeignKeyConstraints')) && count($table->getReferrers()) > 0) { foreach ($table->getReferrers() as $fk) { - if (ForeignKey::SETNULL === $fk->getOnDelete()) { + if ($fk->getOnDelete() === ForeignKey::SETNULL) { return true; } } @@ -375,7 +385,9 @@ protected function isDeleteSetNullEmulationNeeded() /** * Closes class. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClassClose(&$script) @@ -383,13 +395,16 @@ protected function addClassClose(&$script) $script .= " } // " . $this->getUnqualifiedClassName() . " "; - $this->applyBehaviorModifier('queryFilter', $script, ""); + $this->applyBehaviorModifier('queryFilter', $script, ''); } /** * Adds the constructor for this object. - * @param string $script The script will be modified in this method. + * * @see addConstructor() + * + * @param string $script The script will be modified in this method. + * * @return void */ protected function addConstructor(&$script) @@ -402,14 +417,16 @@ protected function addConstructor(&$script) /** * Adds the comment for the constructor + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addConstructorComment(&$script) { $script .= " /** - * Initializes internal state of ".$this->getClassName()." object. + * Initializes internal state of " . $this->getClassName() . " object. * * @param string \$dbName The database name * @param string \$modelName The phpName of a model, e.g. 'Book' @@ -419,7 +436,9 @@ protected function addConstructorComment(&$script) /** * Adds the function declaration for the constructor + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addConstructorOpen(&$script) @@ -432,7 +451,9 @@ public function __construct(\$dbName = '" . $table->getDatabase()->getName() . " /** * Adds the function body for the constructor + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addConstructorBody(&$script) @@ -443,7 +464,9 @@ protected function addConstructorBody(&$script) /** * Adds the function close for the constructor + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addConstructorClose(&$script) @@ -455,7 +478,9 @@ protected function addConstructorClose(&$script) /** * Adds the factory for this object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addFactory(&$script) @@ -468,7 +493,9 @@ protected function addFactory(&$script) /** * Adds the comment for the factory + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addFactoryComment(&$script) @@ -487,7 +514,9 @@ protected function addFactoryComment(&$script) /** * Adds the function declaration for the factory + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addFactoryOpen(&$script) @@ -499,7 +528,9 @@ public static function create(\$modelAlias = null, Criteria \$criteria = null) /** * Adds the function body for the factory + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addFactoryBody(&$script) @@ -556,12 +587,12 @@ protected function addFindPk(&$script) $examplePk = array_slice([12, 34, 56, 78, 91], 0, count($pks)); $colNames = []; foreach ($pks as $col) { - $colNames[]= '$' . $col->getName(); + $colNames[] = '$' . $col->getName(); } - $pkType = 'array['. join(', ', $colNames) . ']'; + $pkType = 'array[' . implode(', ', $colNames) . ']'; $script .= " * - * \$obj = \$c->findPk(array(" . join(', ', $examplePk) . "), \$con);"; + * \$obj = \$c->findPk(array(" . implode(', ', $examplePk) . '), $con);'; } else { $pkType = 'mixed'; $script .= " @@ -649,12 +680,12 @@ protected function addFindPkSimple(&$script) $selectColumns = []; foreach ($table->getColumns() as $column) { if (!$column->isLazyLoad()) { - $selectColumns []= $this->quoteIdentifier($column->getName()); + $selectColumns[] = $this->quoteIdentifier($column->getName()); } } $conditions = []; foreach ($table->getPrimaryKey() as $index => $column) { - $conditions []= sprintf('%s = :p%d', $this->quoteIdentifier($column->getName()), $index); + $conditions[] = sprintf('%s = :p%d', $this->quoteIdentifier($column->getName()), $index); } $query = sprintf( 'SELECT %s FROM %s WHERE %s', @@ -665,10 +696,10 @@ protected function addFindPkSimple(&$script) $pks = []; if ($table->hasCompositePrimaryKey()) { foreach ($table->getPrimaryKey() as $index => $column) { - $pks []= "\$key[$index]"; + $pks[] = "\$key[$index]"; } } else { - $pks []= "\$key"; + $pks[] = '$key'; } $pkHashFromRow = $this->getTableMapBuilder()->getInstancePoolKeySnippet($pks); @@ -696,7 +727,7 @@ protected function findPkSimple(\$key, ConnectionInterface \$con) } else { $pk = $table->getPrimaryKey(); $column = $pk[0]; - $script .= $platform->getColumnBindingPHP($column, "':p0'", "\$key", ' '); + $script .= $platform->getColumnBindingPHP($column, "':p0'", '$key', ' '); } $script .= " \$stmt->execute(); @@ -708,12 +739,12 @@ protected function findPkSimple(\$key, ConnectionInterface \$con) if (\$row = \$stmt->fetch(\PDO::FETCH_NUM)) {"; if ($table->getChildrenColumn()) { - $script .=" + $script .= " \$cls = {$tableMapClassName}::getOMClass(\$row, 0, false); /** @var $ARClassName \$obj */ \$obj = new \$cls();"; } else { - $script .=" + $script .= " /** @var $ARClassName \$obj */ \$obj = new $ARClassName();"; } @@ -730,7 +761,9 @@ protected function findPkSimple(\$key, ConnectionInterface \$con) /** * Adds the findPk method for this object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addFindPkComplex(&$script) @@ -768,7 +801,9 @@ protected function findPkComplex(\$key, ConnectionInterface \$con) /** * Adds the findPks method for this object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addFindPks(&$script) @@ -785,7 +820,7 @@ protected function addFindPks(&$script) /** * Find objects by primary key * "; - if (1 === $count) { + if ($count === 1) { $script .= " * \$objs = \$c->findPks(array(12, 56, 832), \$con);"; } else { @@ -828,7 +863,9 @@ public function findPks(\$keys, ConnectionInterface \$con = null) /** * Adds the filterByPrimaryKey method for this object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addFilterByPrimaryKey(&$script) @@ -856,7 +893,7 @@ public function filterByPrimaryKey(\$key) } $pks = $table->getPrimaryKey(); - if (1 === count($pks)) { + if (count($pks) === 1) { // simple primary key $col = $pks[0]; $const = $this->getColumnConstant($col); @@ -883,7 +920,9 @@ public function filterByPrimaryKey(\$key) /** * Adds the filterByPrimaryKey method for this object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addFilterByPrimaryKeys(&$script) @@ -901,7 +940,6 @@ public function filterByPrimaryKeys(\$keys) $table = $this->getTable(); if (!$table->hasPrimaryKey()) { - $this->declareClass('Propel\\Runtime\\Exception\\LogicException'); $script .= " throw new LogicException('The {$this->getObjectName()} object has no primary key'); @@ -912,7 +950,7 @@ public function filterByPrimaryKeys(\$keys) } $pks = $table->getPrimaryKey(); - if (1 === count($pks)) { + if (count($pks) === 1) { // simple primary key $col = $pks[0]; $const = $this->getColumnConstant($col); @@ -951,8 +989,10 @@ public function filterByPrimaryKeys(\$keys) /** * Adds the filterByCol method for this object. + * * @param string $script The script will be modified in this method. - * @param Column $col + * @param \Propel\Generator\Model\Column $col + * * @return void */ protected function addFilterByCol(&$script, Column $col) @@ -977,7 +1017,7 @@ protected function addFilterByCol(&$script, Column $col) foreach ($col->getForeignKeys() as $fk) { $script .= " * - * @see filterBy" . $this->getFKPhpNameAffix($fk) . "()"; + * @see filterBy" . $this->getFKPhpNameAffix($fk) . '()'; } } $script .= " @@ -1105,7 +1145,7 @@ public function filterBy$colPhpName(\$$variableName = null, \$comparison = null) 'Propel\Common\Exception\SetColumnConverterException' ); $script .= " - \$valueSet = " . $this->getTableMapClassName() . "::getValueSet(" . $this->getColumnConstant($col) . "); + \$valueSet = " . $this->getTableMapClassName() . '::getValueSet(' . $this->getColumnConstant($col) . "); try { \${$variableName} = SetColumnConverter::convertToInt(\${$variableName}, \$valueSet); } catch (SetColumnConverterException \$e) { @@ -1132,7 +1172,7 @@ public function filterBy$colPhpName(\$$variableName = null, \$comparison = null) }"; } elseif ($col->getType() == PropelTypes::ENUM) { $script .= " - \$valueSet = " . $this->getTableMapClassName() . "::getValueSet(" . $this->getColumnConstant($col) . "); + \$valueSet = " . $this->getTableMapClassName() . '::getValueSet(' . $this->getColumnConstant($col) . "); if (is_scalar(\$$variableName)) { if (!in_array(\$$variableName, \$valueSet)) { throw new PropelException(sprintf('Value \"%s\" is not accepted in this enumerated column', \$$variableName)); @@ -1173,8 +1213,10 @@ public function filterBy$colPhpName(\$$variableName = null, \$comparison = null) /** * Adds the singular filterByCol method for an Array column. + * * @param string $script The script will be modified in this method. - * @param Column $col + * @param \Propel\Generator\Model\Column $col + * * @return void */ protected function addFilterByArrayCol(&$script, Column $col) @@ -1222,7 +1264,8 @@ public function filterBy$singularPhpName(\$$variableName = null, \$comparison = * Adds the singular filterByCol method for an Array column. * * @param string $script The script will be modified in this method. - * @param Column $col + * @param \Propel\Generator\Model\Column $col + * * @return void */ protected function addFilterBySetCol(&$script, Column $col) @@ -1248,8 +1291,10 @@ public function filterBy$singularPhpName(\$$variableName = null, \$comparison = /** * Adds the filterByFk method for this object. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $fk ForeignKey + * @param \Propel\Generator\Model\ForeignKey $fk ForeignKey + * * @return void */ protected function addFilterByFk(&$script, $fk) @@ -1293,7 +1338,7 @@ public function filterBy$relationName($objectName, \$comparison = null) [$localColumn, $rightValueOrColumn] = $mapping; if ($rightValueOrColumn instanceof Column) { $script .= " - ->addUsingAlias(" . $this->getColumnConstant($localColumn) . ", " . $objectName . "->get" . $rightValueOrColumn->getPhpName() . "(), \$comparison)"; + ->addUsingAlias(" . $this->getColumnConstant($localColumn) . ', ' . $objectName . '->get' . $rightValueOrColumn->getPhpName() . '(), $comparison)'; } else { $value = var_export($rightValueOrColumn, true); $script .= " @@ -1301,7 +1346,7 @@ public function filterBy$relationName($objectName, \$comparison = null) } } - $script .= ";"; + $script .= ';'; if (!$fk->isComposite()) { $localColumnConstant = $this->getColumnConstant($fk->getLocalColumn()); $foreignColumnName = $fk->getForeignColumn()->getPhpName(); @@ -1334,7 +1379,8 @@ public function filterBy$relationName($objectName, \$comparison = null) * Adds the filterByRefFk method for this object. * * @param string $script The script will be modified in this method. - * @param ForeignKey $fk + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return void */ protected function addFilterByRefFk(&$script, ForeignKey $fk) @@ -1364,9 +1410,9 @@ public function filterBy$relationName($objectName, \$comparison = null) if ($objectName instanceof $fkPhpName) { return \$this"; foreach ($fk->getInverseMapping() as $mapping) { - /** @var Column $foreignColumn */ + /** @var \Propel\Generator\Model\Column $foreignColumn */ [$localValueOrColumn, $foreignColumn] = $mapping; - $rightValue = "{$objectName}->get" . $foreignColumn->getPhpName() . "()"; + $rightValue = "{$objectName}->get" . $foreignColumn->getPhpName() . '()'; if ($localValueOrColumn instanceof Column) { $script .= " @@ -1377,9 +1423,8 @@ public function filterBy$relationName($objectName, \$comparison = null) $script .= " ->where(\"$leftValue = ?\", $rightValue, $bindingType)"; } - } - $script .= ";"; + $script .= ';'; if (!$fk->isComposite()) { $script .= " } elseif ($objectName instanceof ObjectCollection) { @@ -1405,8 +1450,10 @@ public function filterBy$relationName($objectName, \$comparison = null) /** * Adds the joinFk method for this object. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $fk ForeignKey + * @param \Propel\Generator\Model\ForeignKey $fk ForeignKey + * * @return void */ protected function addJoinFk(&$script, $fk) @@ -1420,8 +1467,10 @@ protected function addJoinFk(&$script, $fk) /** * Adds the joinRefFk method for this object. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $fk + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return void */ protected function addJoinRefFk(&$script, ForeignKey $fk) @@ -1435,7 +1484,9 @@ protected function addJoinRefFk(&$script, ForeignKey $fk) /** * Adds a joinRelated method for this object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addJoinRelated(&$script, $fkTable, $queryClass, $relationName, $joinType) @@ -1447,9 +1498,9 @@ protected function addJoinRelated(&$script, $fkTable, $queryClass, $relationName * @param string \$relationAlias optional alias for the relation * @param string \$joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \$this|". $queryClass . " The current query, for fluid interface + * @return \$this|" . $queryClass . " The current query, for fluid interface */ - public function join" . $relationName . "(\$relationAlias = null, \$joinType = " . $joinType . ") + public function join" . $relationName . '($relationAlias = null, $joinType = ' . $joinType . ") { \$tableMap = \$this->getTableMap(); \$relationMap = \$tableMap->getRelation('" . $relationName . "'); @@ -1477,8 +1528,10 @@ public function join" . $relationName . "(\$relationAlias = null, \$joinType = " /** * Adds the useFkQuery method for this object. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $fk ForeignKey + * @param \Propel\Generator\Model\ForeignKey $fk ForeignKey + * * @return void */ protected function addUseFkQuery(&$script, $fk) @@ -1494,8 +1547,10 @@ protected function addUseFkQuery(&$script, $fk) /** * Adds the useFkQuery method for this object. + * * @param string $script The script will be modified in this method. - * @param ForeignKey $fk + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return void */ protected function addUseRefFkQuery(&$script, ForeignKey $fk) @@ -1511,7 +1566,9 @@ protected function addUseRefFkQuery(&$script, ForeignKey $fk) /** * Adds a useRelatedQuery method for this object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addUseRelatedQuery(&$script, Table $fkTable, $queryClass, $relationName, $joinType) @@ -1528,7 +1585,7 @@ protected function addUseRelatedQuery(&$script, Table $fkTable, $queryClass, $re * * @return $queryClass A secondary query class using the current class as primary query */ - public function use" . $relationName . "Query(\$relationAlias = null, \$joinType = " . $joinType . ") + public function use" . $relationName . 'Query($relationAlias = null, $joinType = ' . $joinType . ") { return \$this ->join" . $relationName . "(\$relationAlias, \$joinType) @@ -1551,7 +1608,7 @@ protected function addFilterByCrossFK(&$script, CrossForeignKeys $crossFKs) $queryClass = $this->getQueryClassName(); $crossRefTable = $crossFK->getTable(); $foreignTable = $crossFK->getForeignTable(); - $fkPhpName = $foreignTable->getPhpName(); + $fkPhpName = $foreignTable->getPhpName(); $crossTableName = $crossRefTable->getName(); $relName = $this->getFKPhpNameAffix($crossFK, $plural = false); $objectName = '$' . $foreignTable->getCamelCaseName(); @@ -1578,7 +1635,9 @@ public function filterBy{$relName}($objectName, \$comparison = Criteria::EQUAL) /** * Adds the prune method for this object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addPrune(&$script) @@ -1605,19 +1664,19 @@ public function prune($objectName = null) foreach ($pks as $col) { $const = $this->getColumnConstant($col); $condName = "'pruneCond" . $i . "'"; - $conditions[]= $condName; + $conditions[] = $condName; $script .= " - \$this->addCond(". $condName . ", \$this->getAliasedColName($const), " . $objectName . "->get" . $col->getPhpName() . "(), Criteria::NOT_EQUAL);"; + \$this->addCond(" . $condName . ", \$this->getAliasedColName($const), " . $objectName . '->get' . $col->getPhpName() . '(), Criteria::NOT_EQUAL);'; $i++; } $conditionsString = implode(', ', $conditions); $script .= " - \$this->combine(array(" . $conditionsString . "), Criteria::LOGICAL_OR);"; + \$this->combine(array(" . $conditionsString . '), Criteria::LOGICAL_OR);'; } elseif ($table->hasPrimaryKey()) { $col = $pks[0]; $const = $this->getColumnConstant($col); $script .= " - \$this->addUsingAlias($const, " . $objectName . "->get" . $col->getPhpName() . "(), Criteria::NOT_EQUAL);"; + \$this->addUsingAlias($const, " . $objectName . '->get' . $col->getPhpName() . '(), Criteria::NOT_EQUAL);'; } else { $this->declareClass('Propel\\Runtime\\Exception\\LogicException'); $script .= " @@ -1634,13 +1693,15 @@ public function prune($objectName = null) /** * Adds the basePreSelect hook for this object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addBasePreSelect(&$script) { $behaviorCode = ''; - $this->applyBehaviorModifier('preSelectQuery', $behaviorCode, " "); + $this->applyBehaviorModifier('preSelectQuery', $behaviorCode, ' '); if (!$behaviorCode) { return; } @@ -1660,13 +1721,15 @@ protected function basePreSelect(ConnectionInterface \$con) /** * Adds the basePreDelete hook for this object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addBasePreDelete(&$script) { $behaviorCode = ''; - $this->applyBehaviorModifier('preDeleteQuery', $behaviorCode, " "); + $this->applyBehaviorModifier('preDeleteQuery', $behaviorCode, ' '); if (!$behaviorCode) { return; } @@ -1686,13 +1749,15 @@ protected function basePreDelete(ConnectionInterface \$con) /** * Adds the basePostDelete hook for this object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addBasePostDelete(&$script) { $behaviorCode = ''; - $this->applyBehaviorModifier('postDeleteQuery', $behaviorCode, " "); + $this->applyBehaviorModifier('postDeleteQuery', $behaviorCode, ' '); if (!$behaviorCode) { return; } @@ -1713,13 +1778,15 @@ protected function basePostDelete(\$affectedRows, ConnectionInterface \$con) /** * Adds the basePreUpdate hook for this object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addBasePreUpdate(&$script) { $behaviorCode = ''; - $this->applyBehaviorModifier('preUpdateQuery', $behaviorCode, " "); + $this->applyBehaviorModifier('preUpdateQuery', $behaviorCode, ' '); if (!$behaviorCode) { return; } @@ -1741,13 +1808,15 @@ protected function basePreUpdate(&\$values, ConnectionInterface \$con, \$forceIn /** * Adds the basePostUpdate hook for this object. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addBasePostUpdate(&$script) { $behaviorCode = ''; - $this->applyBehaviorModifier('postUpdateQuery', $behaviorCode, " "); + $this->applyBehaviorModifier('postUpdateQuery', $behaviorCode, ' '); if (!$behaviorCode) { return; } @@ -1768,8 +1837,10 @@ protected function basePostUpdate(\$affectedRows, ConnectionInterface \$con) /** * Checks whether any registered behavior on that table has a modifier for a hook - * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" - * @return boolean + * + * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" + * + * @return bool */ public function hasBehaviorModifier($hookName, $modifier = '') { @@ -1778,10 +1849,11 @@ public function hasBehaviorModifier($hookName, $modifier = '') /** * Checks whether any registered behavior on that table has a modifier for a hook + * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" - * @param string $script The script will be modified in this method. + * @param string $script The script will be modified in this method. */ - public function applyBehaviorModifier($hookName, &$script, $tab = " ") + public function applyBehaviorModifier($hookName, &$script, $tab = ' ') { $this->applyBehaviorModifierBase($hookName, 'QueryBuilderModifier', $script, $tab); @@ -1790,7 +1862,9 @@ public function applyBehaviorModifier($hookName, &$script, $tab = " ") /** * Checks whether any registered behavior content creator on that table exists a contentName + * * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassName" + * * @return string|null */ public function getBehaviorContent($contentName) @@ -1800,7 +1874,9 @@ public function getBehaviorContent($contentName) /** * Adds the doDelete() method. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addDelete(&$script) @@ -1864,7 +1940,9 @@ public function delete(ConnectionInterface \$con = null) /** * Adds the doOnDeleteCascade() method, which provides ON DELETE CASCADE emulation. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addDoOnDeleteCascade(&$script) @@ -1894,7 +1972,6 @@ protected function doOnDeleteCascade(ConnectionInterface \$con) "; foreach ($table->getReferrers() as $fk) { - // $fk is the foreign key in the other table, so localTableName will // actually be the table name of other table $tblFK = $fk->getTable(); @@ -1907,8 +1984,7 @@ protected function doOnDeleteCascade(ConnectionInterface \$con) $fkClassName = $joinedTableTableMapBuilder->getObjectClassName(); - if (ForeignKey::CASCADE === $fk->getOnDelete()) { - + if ($fk->getOnDelete() === ForeignKey::CASCADE) { // backwards on purpose $columnNamesF = $fk->getLocalColumns(); $columnNamesL = $fk->getForeignColumns(); @@ -1918,21 +1994,19 @@ protected function doOnDeleteCascade(ConnectionInterface \$con) $script .= " // delete related $fkClassName objects - \$query = new ".$joinedTableTableMapBuilder->getQueryClassName(true)."; + \$query = new " . $joinedTableTableMapBuilder->getQueryClassName(true) . "; "; for ($x = 0, $xlen = count($columnNamesF); $x < $xlen; $x++) { $columnFK = $tblFK->getColumn($columnNamesF[$x]); $columnL = $table->getColumn($columnNamesL[$x]); $script .= " - \$query->add(".$joinedTableTableMapBuilder->getColumnConstant($columnFK) .", \$obj->get".$columnL->getPhpName()."());"; + \$query->add(" . $joinedTableTableMapBuilder->getColumnConstant($columnFK) . ', $obj->get' . $columnL->getPhpName() . '());'; } $script .= " \$affectedRows += \$query->delete(\$con);"; - } // if cascade && fkey table name != curr table name - } // if not for ref only } // foreach foreign keys $script .= " @@ -1941,12 +2015,16 @@ protected function doOnDeleteCascade(ConnectionInterface \$con) return \$affectedRows; } "; - } // end addDoOnDeleteCascade + } + + // end addDoOnDeleteCascade /** * Adds the doOnDeleteSetNull() method, which provides ON DELETE SET NULL emulation. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addDoOnDeleteSetNull(&$script) @@ -1976,7 +2054,6 @@ protected function doOnDeleteSetNull(ConnectionInterface \$con) // it may make sense to refactor this, provided that things don't // get too complicated. foreach ($table->getReferrers() as $fk) { - // $fk is the foreign key in the other table, so localTableName will // actually be the table name of other table $tblFK = $fk->getTable(); @@ -1988,7 +2065,7 @@ protected function doOnDeleteSetNull(ConnectionInterface \$con) $fkClassName = $refTableTableMapBuilder->getObjectClassName(); - if (ForeignKey::SETNULL === $fk->getOnDelete()) { + if ($fk->getOnDelete() === ForeignKey::SETNULL) { // backwards on purpose $columnNamesF = $fk->getLocalColumns(); $columnNamesL = $fk->getForeignColumns(); // should be same num as foreign @@ -2004,8 +2081,8 @@ protected function doOnDeleteSetNull(ConnectionInterface \$con) $columnFK = $tblFK->getColumn($columnNamesF[$x]); $columnL = $table->getColumn($columnNamesL[$x]); $script .= " - \$query->add(".$refTableTableMapBuilder->getColumnConstant($columnFK).", \$obj->get".$columnL->getPhpName()."()); - \$updateValues->add(".$refTableTableMapBuilder->getColumnConstant($columnFK).", null); + \$query->add(" . $refTableTableMapBuilder->getColumnConstant($columnFK) . ', $obj->get' . $columnL->getPhpName() . "()); + \$updateValues->add(" . $refTableTableMapBuilder->getColumnConstant($columnFK) . ", null); "; } @@ -2021,10 +2098,11 @@ protected function doOnDeleteSetNull(ConnectionInterface \$con) "; } - /** * Adds the doDeleteAll() method. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addDoDeleteAll(&$script) @@ -2032,7 +2110,7 @@ protected function addDoDeleteAll(&$script) $table = $this->getTable(); $script .= " /** - * Deletes all rows from the ".$table->getName()." table. + * Deletes all rows from the " . $table->getName() . " table. * * @param ConnectionInterface \$con the connection to use * @return int The number of affected rows (if supported by underlying database driver). @@ -2049,7 +2127,7 @@ public function doDeleteAll(ConnectionInterface \$con = null) \$affectedRows = 0; // initialize var to track total num of affected rows "; if ($this->isDeleteCascadeEmulationNeeded()) { - $script .="\$affectedRows += \$this->doOnDeleteCascade(\$con); + $script .= "\$affectedRows += \$this->doOnDeleteCascade(\$con); "; } if ($this->isDeleteSetNullEmulationNeeded()) { @@ -2068,5 +2146,4 @@ public function doDeleteAll(ConnectionInterface \$con = null) } "; } - } diff --git a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php index d32022de9b..c92c6b3b8f 100644 --- a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php @@ -20,12 +20,10 @@ * This class produces the empty stub class that can be customized with * application business logic, custom behavior, etc. * - * * @author François Zaninotto */ class QueryInheritanceBuilder extends AbstractOMBuilder { - /** * The current child "object" we are operating on. */ @@ -68,7 +66,8 @@ public function getNamespace() /** * Sets the child object that we're operating on currently. * - * @param Inheritance $child + * @param \Propel\Generator\Model\Inheritance $child + * * @return void */ public function setChild(Inheritance $child) @@ -79,13 +78,14 @@ public function setChild(Inheritance $child) /** * Returns the child object we're operating on currently. * - * @return Inheritance - * @throws BuildException + * @throws \Propel\Generator\Exception\BuildException + * + * @return \Propel\Generator\Model\Inheritance */ public function getChild() { if (!$this->child) { - throw new BuildException("The MultiExtendObjectBuilder needs to be told which child class to build (via setChild() method) before it can build the stub class."); + throw new BuildException('The MultiExtendObjectBuilder needs to be told which child class to build (via setChild() method) before it can build the stub class.'); } return $this->child; @@ -98,7 +98,7 @@ public function getChild() */ protected function getParentClassName() { - if (is_null($this->getChild()->getAncestor())) { + if ($this->getChild()->getAncestor() === null) { return $this->getNewStubQueryBuilder($this->getTable())->getUnqualifiedClassName(); } @@ -121,6 +121,7 @@ protected function getParentClassName() * Adds class phpdoc comment and opening of class. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClassOpen(&$script) @@ -152,7 +153,7 @@ protected function addClassOpen(&$script) * application requirements. This class will only be generated as * long as it does not already exist in the output directory. */ -class " .$this->getUnqualifiedClassName() . " extends " . $baseClassName . " +class " . $this->getUnqualifiedClassName() . ' extends ' . $baseClassName . " { "; } @@ -163,8 +164,10 @@ class " .$this->getUnqualifiedClassName() . " extends " . $baseClassName . " * By default there are no methods for the empty stub classes; override this * method if you want to change that behavior. * - * @param string $script * @see ObjectBuilder::addClassBody() + * + * @param string $script + * * @return void */ protected function addClassBody(&$script) @@ -185,6 +188,7 @@ protected function addClassBody(&$script) * Adds the factory for this object. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addFactory(&$script) @@ -287,7 +291,7 @@ protected function getClassKeyCondition() $child = $this->getChild(); $col = $child->getColumn(); - return "\$this->addUsingAlias(" . $col->getFQConstantName() . ", " . $this->getTableMapClassName()."::CLASSKEY_".$child->getConstantSuffix().");"; + return '$this->addUsingAlias(' . $col->getFQConstantName() . ', ' . $this->getTableMapClassName() . '::CLASSKEY_' . $child->getConstantSuffix() . ');'; } /** @@ -321,6 +325,7 @@ public function doDeleteAll(ConnectionInterface \$con = null) * Closes class. * * @param string $script + * * @return void */ protected function addClassClose(&$script) diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index ea1ba2c069..a49d1fa6ba 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -11,7 +11,6 @@ namespace Propel\Generator\Builder\Om; use Propel\Generator\Model\ForeignKey; - use Propel\Generator\Model\IdMethod; use Propel\Generator\Platform\PlatformInterface; @@ -24,6 +23,7 @@ class TableMapBuilder extends AbstractOMBuilder { /** * Gets the package for the map builder classes. + * * @return string */ public function getPackage() @@ -40,12 +40,14 @@ public function getNamespace() return 'Map'; } - if ($this->getGeneratorConfig() - && $omns = $this->getBuildProperty('generator.objectModel.namespaceMap')) { + if ( + $this->getGeneratorConfig() + && $omns = $this->getBuildProperty('generator.objectModel.namespaceMap') + ) { return $namespace . '\\' . $omns; } - return $namespace .'Map'; + return $namespace . 'Map'; } /** @@ -53,7 +55,7 @@ public function getNamespace() */ public function getBaseTableMapClassName() { - return "TableMap"; + return 'TableMap'; } /** @@ -79,7 +81,7 @@ protected function addClassOpen(&$script) $script .= " /** - * This class defines the structure of the '".$table->getName()."' table. + * This class defines the structure of the '" . $table->getName() . "' table. * *"; if ($this->getBuildProperty('generator.objectModel.addTimeStamp')) { @@ -97,7 +99,7 @@ protected function addClassOpen(&$script) * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive * (i.e. if it's a text column type). */ -class ".$this->getUnqualifiedClassName()." extends TableMap +class " . $this->getUnqualifiedClassName() . " extends TableMap { use InstancePoolTrait; use TableMapTrait; @@ -108,8 +110,11 @@ class ".$this->getUnqualifiedClassName()." extends TableMap /** * Specifies the methods that are added as part of the map builder class. * This can be overridden by subclasses that wish to add more methods. + * * @see ObjectBuilder::addClassBody() + * * @param string $script + * * @return void */ protected function addClassBody(&$script) @@ -136,9 +141,9 @@ protected function addClassBody(&$script) } // apply behaviors - $this->applyBehaviorModifier('staticConstants', $script, " "); - $this->applyBehaviorModifier('staticAttributes', $script, " "); - $this->applyBehaviorModifier('staticMethods', $script, " "); + $this->applyBehaviorModifier('staticConstants', $script, ' '); + $this->applyBehaviorModifier('staticAttributes', $script, ' '); + $this->applyBehaviorModifier('staticMethods', $script, ' '); $this->addAttributes($script); @@ -179,7 +184,9 @@ protected function addClassBody(&$script) /** * Adds the addSelectColumns(), doCount(), etc. methods. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addSelectMethods(&$script) @@ -195,22 +202,24 @@ protected function addSelectMethods(&$script) protected function addConstants() { return $this->renderTemplate('tableMapConstants', [ - 'className' => $this->getClasspath(), - 'dbName' => $this->getDatabase()->getName(), - 'tableName' => $this->getTable()->getName(), - 'tablePhpName' => $this->getTable()->isAbstract() ? '' : addslashes($this->getStubObjectBuilder()->getFullyQualifiedClassName()), - 'classPath' => $this->getStubObjectBuilder()->getClasspath(), - 'nbColumns' => $this->getTable()->getNumColumns(), + 'className' => $this->getClasspath(), + 'dbName' => $this->getDatabase()->getName(), + 'tableName' => $this->getTable()->getName(), + 'tablePhpName' => $this->getTable()->isAbstract() ? '' : addslashes($this->getStubObjectBuilder()->getFullyQualifiedClassName()), + 'classPath' => $this->getStubObjectBuilder()->getClasspath(), + 'nbColumns' => $this->getTable()->getNumColumns(), 'nbLazyLoadColumns' => $this->getTable()->getNumLazyLoadColumns(), - 'nbHydrateColumns' => $this->getTable()->getNumColumns() - $this->getTable()->getNumLazyLoadColumns(), - 'columns' => $this->getTable()->getColumns(), - 'stringFormat' => $this->getTable()->getDefaultStringFormat(), + 'nbHydrateColumns' => $this->getTable()->getNumColumns() - $this->getTable()->getNumLazyLoadColumns(), + 'columns' => $this->getTable()->getColumns(), + 'stringFormat' => $this->getTable()->getDefaultStringFormat(), ]); } /** * Adds the COLUMN_NAME constant to the class definition. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addColumnNameConstants(&$script) @@ -218,16 +227,18 @@ protected function addColumnNameConstants(&$script) foreach ($this->getTable()->getColumns() as $col) { $script .= " /** - * the column name for the " . $col->getName() ." field + * the column name for the " . $col->getName() . " field */ - const ".$col->getConstantName() ." = '" . $this->getTable()->getName() . ".".$col->getName()."'; + const " . $col->getConstantName() . " = '" . $this->getTable()->getName() . '.' . $col->getName() . "'; "; } // foreach } /** * Adds the valueSet constants for ENUM and SET columns. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addValueSetColumnConstants(&$script) @@ -235,7 +246,7 @@ protected function addValueSetColumnConstants(&$script) foreach ($this->getTable()->getColumns() as $col) { if ($col->isValueSetType()) { $script .= " - /** The enumerated values for the " . $col->getName() . " field */"; + /** The enumerated values for the " . $col->getName() . ' field */'; foreach ($col->getValueSet() as $value) { $script .= " const " . $col->getConstantName() . '_' . $this->getValueSetConstant($value) . " = '" . $value . "';"; @@ -248,7 +259,9 @@ protected function addValueSetColumnConstants(&$script) /** * Adds the valueSet attributes for ENUM columns. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addValueSetColumnAttributes(&$script) @@ -262,10 +275,10 @@ protected function addValueSetColumnAttributes(&$script) {$col->getFQConstantName()} => array( "; foreach ($col->getValueSet() as $value) { - $script .= " self::" . $col->getConstantName() . '_' . $this->getValueSetConstant($value) . ", + $script .= ' self::' . $col->getConstantName() . '_' . $this->getValueSetConstant($value) . ", "; } - $script .= " ),"; + $script .= ' ),'; } } $script .= " @@ -275,7 +288,9 @@ protected function addValueSetColumnAttributes(&$script) /** * Adds the getValueSets() method. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetValueSets(&$script) @@ -294,7 +309,9 @@ public static function getValueSets() /** * Adds the getValueSet() method. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetValueSet(&$script) @@ -316,7 +333,9 @@ public static function getValueSet(\$colname) /** * Adds the CLASSKEY_* and CLASSNAME_* constants used for inheritance. + * * @param string $script The script will be modified in this method. + * * @return void */ public function addInheritanceColumnConstants(&$script) @@ -336,25 +355,26 @@ public function addInheritanceColumnConstants(&$script) $script .= " /** A key representing a particular subclass */ - const CLASSKEY_".$child->getConstantSuffix()." = '" . $child->getKey() . "'; + const CLASSKEY_" . $child->getConstantSuffix() . " = '" . $child->getKey() . "'; "; if (strtoupper($child->getClassName()) != $child->getConstantSuffix()) { $script .= " /** A key representing a particular subclass */ - const CLASSKEY_".strtoupper($child->getClassname())." = '" . $fqcn . "'; + const CLASSKEY_" . strtoupper($child->getClassname()) . " = '" . $fqcn . "'; "; } $script .= " /** A class that can be returned by this tableMap. */ - const CLASSNAME_".$child->getConstantSuffix()." = '". $fqcn . "'; + const CLASSNAME_" . $child->getConstantSuffix() . " = '" . $fqcn . "'; "; } } /** - * @param string $value + * @param string $value + * * @return string */ protected function getValueSetConstant($value) @@ -364,7 +384,9 @@ protected function getValueSetConstant($value) /** * Adds any attributes needed for this TableMap class. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addAttributes(&$script) @@ -378,55 +400,57 @@ protected function addFieldsAttributes() { $tableColumns = $this->getTable()->getColumns(); - $fieldNamesPhpName = ''; + $fieldNamesPhpName = ''; $fieldNamesCamelCaseName = ''; - $fieldNamesColname = ''; - $fieldNamesRawColname = ''; - $fieldNamesFieldName = ''; - $fieldNamesNum = ''; - - $fieldKeysPhpName = ''; - $fieldKeysCamelCaseName = ''; - $fieldKeysColname = ''; - $fieldKeysRawColname = ''; - $fieldKeysFieldName = ''; - $fieldKeysNum = ''; + $fieldNamesColname = ''; + $fieldNamesRawColname = ''; + $fieldNamesFieldName = ''; + $fieldNamesNum = ''; + + $fieldKeysPhpName = ''; + $fieldKeysCamelCaseName = ''; + $fieldKeysColname = ''; + $fieldKeysRawColname = ''; + $fieldKeysFieldName = ''; + $fieldKeysNum = ''; foreach ($tableColumns as $num => $col) { - $fieldNamesPhpName .= "'" . $col->getPhpName() . "', "; + $fieldNamesPhpName .= "'" . $col->getPhpName() . "', "; $fieldNamesCamelCaseName .= "'" . $col->getCamelCaseName() . "', "; - $fieldNamesColname .= $this->getColumnConstant($col, $this->getTableMapClass()) . ", "; - $fieldNamesRawColname .= "'" . $col->getConstantName() . "', "; - $fieldNamesFieldName .= "'" . $col->getName() . "', "; - $fieldNamesNum .= "$num, "; - - $fieldKeysPhpName .= "'" . $col->getPhpName() . "' => $num, "; - $fieldKeysCamelCaseName .= "'" . $col->getCamelCaseName() . "' => $num, "; - $fieldKeysColname .= $this->getColumnConstant($col, $this->getTableMapClass())." => $num, "; - $fieldKeysRawColname .= "'" . $col->getConstantName() . "' => $num, "; - $fieldKeysFieldName .= "'" . $col->getName() . "' => $num, "; - $fieldKeysNum .= "$num, "; + $fieldNamesColname .= $this->getColumnConstant($col, $this->getTableMapClass()) . ', '; + $fieldNamesRawColname .= "'" . $col->getConstantName() . "', "; + $fieldNamesFieldName .= "'" . $col->getName() . "', "; + $fieldNamesNum .= "$num, "; + + $fieldKeysPhpName .= "'" . $col->getPhpName() . "' => $num, "; + $fieldKeysCamelCaseName .= "'" . $col->getCamelCaseName() . "' => $num, "; + $fieldKeysColname .= $this->getColumnConstant($col, $this->getTableMapClass()) . " => $num, "; + $fieldKeysRawColname .= "'" . $col->getConstantName() . "' => $num, "; + $fieldKeysFieldName .= "'" . $col->getName() . "' => $num, "; + $fieldKeysNum .= "$num, "; } return $this->renderTemplate('tableMapFields', [ - 'fieldNamesPhpName' => $fieldNamesPhpName, + 'fieldNamesPhpName' => $fieldNamesPhpName, 'fieldNamesCamelCaseName' => $fieldNamesCamelCaseName, - 'fieldNamesColname' => $fieldNamesColname, - 'fieldNamesRawColname' => $fieldNamesRawColname, - 'fieldNamesFieldName' => $fieldNamesFieldName, - 'fieldNamesNum' => $fieldNamesNum, - 'fieldKeysPhpName' => $fieldKeysPhpName, - 'fieldKeysCamelCaseName' => $fieldKeysCamelCaseName, - 'fieldKeysColname' => $fieldKeysColname, - 'fieldKeysRawColname' => $fieldKeysRawColname, - 'fieldKeysFieldName' => $fieldKeysFieldName, - 'fieldKeysNum' => $fieldKeysNum, + 'fieldNamesColname' => $fieldNamesColname, + 'fieldNamesRawColname' => $fieldNamesRawColname, + 'fieldNamesFieldName' => $fieldNamesFieldName, + 'fieldNamesNum' => $fieldNamesNum, + 'fieldKeysPhpName' => $fieldKeysPhpName, + 'fieldKeysCamelCaseName' => $fieldKeysCamelCaseName, + 'fieldKeysColname' => $fieldKeysColname, + 'fieldKeysRawColname' => $fieldKeysRawColname, + 'fieldKeysFieldName' => $fieldKeysFieldName, + 'fieldKeysNum' => $fieldKeysNum, ]); } /** * Closes class. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addClassClose(&$script) @@ -435,14 +459,16 @@ protected function addClassClose(&$script) } // " . $this->getUnqualifiedClassName() . " // This is the static code needed to register the TableMap for this table with the main Propel class. // -".$this->getUnqualifiedClassName()."::buildTableMap(); +" . $this->getUnqualifiedClassName() . "::buildTableMap(); "; - $this->applyBehaviorModifier('tableMapFilter', $script, ""); + $this->applyBehaviorModifier('tableMapFilter', $script, ''); } /** * Adds the buildTableMap() method. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addBuildTableMap(&$script) @@ -456,20 +482,21 @@ public static function buildTableMap() { \$dbMap = Propel::getServiceContainer()->getDatabaseMap(" . $this->getTableMapClass() . "::DATABASE_NAME); if (!\$dbMap->hasTable(" . $this->getTableMapClass() . "::TABLE_NAME)) { - \$dbMap->addTableObject(new ".$this->getTableMapClass()."()); + \$dbMap->addTableObject(new " . $this->getTableMapClass() . "()); } } "; } /** - * Adds the addInitialize() method to the table map class. + * Adds the addInitialize() method to the table map class. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addInitialize(&$script) { - $table = $this->getTable(); /** @var \Propel\Generator\Platform\DefaultPlatform $platform */ $platform = $this->getPlatform(); @@ -485,12 +512,12 @@ protected function addInitialize(&$script) public function initialize() { // attributes - \$this->setName('".$table->getName()."'); - \$this->setPhpName('".$table->getPhpName()."'); - \$this->setIdentifierQuoting(".($table->isIdentifierQuotingEnabled() ? 'true' : 'false')."); + \$this->setName('" . $table->getName() . "'); + \$this->setPhpName('" . $table->getPhpName() . "'); + \$this->setIdentifierQuoting(" . ($table->isIdentifierQuotingEnabled() ? 'true' : 'false') . "); \$this->setClassName('" . addslashes($this->getStubObjectBuilder()->getFullyQualifiedClassName()) . "'); \$this->setPackage('" . parent::getPackage() . "');"; - if ($table->getIdMethod() == "native") { + if ($table->getIdMethod() == 'native') { $script .= " \$this->setUseIdGenerator(true);"; } else { @@ -502,10 +529,10 @@ public function initialize() $params = $table->getIdMethodParameters(); $imp = $params[0]; $script .= " - \$this->setPrimaryKeyMethodInfo('".$imp->getValue()."');"; + \$this->setPrimaryKeyMethodInfo('" . $imp->getValue() . "');"; } elseif ($table->getIdMethod() == IdMethod::NATIVE && ($platform->getNativeIdMethod() == PlatformInterface::SEQUENCE || $platform->getNativeIdMethod() == PlatformInterface::SERIAL)) { $script .= " - \$this->setPrimaryKeyMethodInfo('".$platform->getSequenceName($table)."');"; + \$this->setPrimaryKeyMethodInfo('" . $platform->getSequenceName($table) . "');"; } if ($this->getTable()->getChildrenColumn()) { @@ -525,7 +552,7 @@ public function initialize() $columnName = $col->getName(); $cfc = $col->getPhpName(); if (!$col->getSize()) { - $size = "null"; + $size = 'null'; } else { $size = $col->getSize(); } @@ -534,26 +561,26 @@ public function initialize() if ($col->isForeignKey()) { foreach ($col->getForeignKeys() as $fk) { $script .= " - \$this->addForeignPrimaryKey('$columnName', '$cfc', '".$col->getType()."' , '".$fk->getForeignTableName()."', '".$fk->getMappedForeignColumn($col->getName())."', ".($col->isNotNull() ? 'true' : 'false').", ".$size.", $default);"; + \$this->addForeignPrimaryKey('$columnName', '$cfc', '" . $col->getType() . "' , '" . $fk->getForeignTableName() . "', '" . $fk->getMappedForeignColumn($col->getName()) . "', " . ($col->isNotNull() ? 'true' : 'false') . ', ' . $size . ", $default);"; } } else { $script .= " - \$this->addPrimaryKey('$columnName', '$cfc', '".$col->getType()."', ".var_export($col->isNotNull(), true).", ".$size.", $default);"; + \$this->addPrimaryKey('$columnName', '$cfc', '" . $col->getType() . "', " . var_export($col->isNotNull(), true) . ', ' . $size . ", $default);"; } } else { if ($col->isForeignKey()) { foreach ($col->getForeignKeys() as $fk) { $script .= " - \$this->addForeignKey('$columnName', '$cfc', '".$col->getType()."', '".$fk->getForeignTableName()."', '".$fk->getMappedForeignColumn($col->getName())."', ".($col->isNotNull() ? 'true' : 'false').", ".$size.", $default);"; + \$this->addForeignKey('$columnName', '$cfc', '" . $col->getType() . "', '" . $fk->getForeignTableName() . "', '" . $fk->getMappedForeignColumn($col->getName()) . "', " . ($col->isNotNull() ? 'true' : 'false') . ', ' . $size . ", $default);"; } } else { $script .= " - \$this->addColumn('$columnName', '$cfc', '".$col->getType()."', ".var_export($col->isNotNull(), true).", ".$size.", $default);"; + \$this->addColumn('$columnName', '$cfc', '" . $col->getType() . "', " . var_export($col->isNotNull(), true) . ', ' . $size . ", $default);"; } } // if col-is prim key if ($col->isValueSetType()) { $script .= " - \$this->getColumn('$columnName')->setValueSet(" . var_export($col->getValueSet(), true). ");"; + \$this->getColumn('$columnName')->setValueSet(" . var_export($col->getValueSet(), true) . ');'; } if ($col->isPrimaryString()) { $script .= " @@ -564,12 +591,13 @@ public function initialize() $script .= " } // initialize() "; - } /** * Adds the method that build the RelationMap objects + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addBuildRelations(&$script) @@ -596,9 +624,9 @@ public function buildRelations() $onUpdate = $fkey->hasOnUpdate() ? "'" . $fkey->getOnUpdate() . "'" : 'null'; $isPolymorphic = $fkey->isPolymorphic() ? 'true' : 'false'; $script .= " - \$this->addRelation('$relationName', '" . addslashes($this->getNewStubObjectBuilder($fkey->getTable())->getFullyQualifiedClassName()) . "', RelationMap::ONE_TO_" . ($fkey->isLocalPrimaryKey() ? "ONE" : "MANY") .", $joinCondition, $onDelete, $onUpdate"; + \$this->addRelation('$relationName', '" . addslashes($this->getNewStubObjectBuilder($fkey->getTable())->getFullyQualifiedClassName()) . "', RelationMap::ONE_TO_" . ($fkey->isLocalPrimaryKey() ? 'ONE' : 'MANY') . ", $joinCondition, $onDelete, $onUpdate"; if ($fkey->isLocalPrimaryKey()) { - $script .= ", null"; + $script .= ', null'; } else { $script .= ", '" . $this->getRefFKPhpNameAffix($fkey, true) . "'"; } @@ -623,7 +651,9 @@ public function buildRelations() /** * Adds the behaviors getter + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetBehaviors(&$script) @@ -649,12 +679,12 @@ public function getBehaviors() $string = var_export($value, true); $string = str_replace("\n", '', $string); $string = str_replace(' ', '', $string); - $script .= $string.", "; + $script .= $string . ', '; } else { $script .= "'$value', "; } } - $script .= "),"; + $script .= '),'; } $script .= " ); @@ -666,20 +696,21 @@ public function getBehaviors() /** * Adds the PHP code to return a instance pool key for the passed-in primary key variable names. * - * @param array $pkphp An array of PHP var names / method calls representing complete pk. + * @param array $pkphp An array of PHP var names / method calls representing complete pk. + * * @return string */ public function getInstancePoolKeySnippet($pkphp) { - $pkphp = (array) $pkphp; // make it an array if it is not. + $pkphp = (array)$pkphp; // make it an array if it is not. $script = ''; if (count($pkphp) > 1) { - $script .= "serialize(["; + $script .= 'serialize(['; $i = 0; foreach ($pkphp as $pkvar) { $script .= ($i++ ? ', ' : '') . "(null === {$pkvar} || is_scalar({$pkvar}) || is_callable([{$pkvar}, '__toString']) ? (string) {$pkvar} : {$pkvar})"; } - $script .= "])"; + $script .= '])'; } else { $script .= "null === {$pkphp[0]} || is_scalar({$pkphp[0]}) || is_callable([{$pkphp[0]}, '__toString']) ? (string) {$pkphp[0]} : {$pkphp[0]}"; } @@ -720,11 +751,11 @@ public function addInstancePool() $removeInstancePoolKeySnippetPks = $this->getInstancePoolKeySnippet($removePks); return $this->renderTemplate('tableMapInstancePool', [ - 'objectClassName' => $this->getStubObjectBuilder()->getClassName(), - 'addInstancePoolKeySnippet' => $addInstancePoolKeySnippet, + 'objectClassName' => $this->getStubObjectBuilder()->getClassName(), + 'addInstancePoolKeySnippet' => $addInstancePoolKeySnippet, 'removeInstancePoolKeySnippetObjects' => $removeInstancePoolKeySnippetObjects, - 'removeInstancePoolKeySnippetPks' => $removeInstancePoolKeySnippetPks, - 'countPks' => count($pks) + 'removeInstancePoolKeySnippetPks' => $removeInstancePoolKeySnippetPks, + 'countPks' => count($pks), ]); } @@ -749,27 +780,29 @@ public function addClearRelatedInstancePool() // we can't perform operations on tables that are // not within the schema (i.e. that we have no map for, etc.) - if (ForeignKey::CASCADE === $fk->getOnDelete() || ForeignKey::SETNULL === $fk->getOnDelete()) { + if ($fk->getOnDelete() === ForeignKey::CASCADE || $fk->getOnDelete() === ForeignKey::SETNULL) { $relatedClassNames[$tableMapClassName] = $tableMapClassName; } } } - if (0 == count($relatedClassNames)) { + if (count($relatedClassNames) == 0) { return ''; } return $this->renderTemplate('tableMapClearRelatedInstancePool', [ - 'tableName' => $table->getName(), - 'relatedClassNames' => $relatedClassNames, + 'tableName' => $table->getName(), + 'relatedClassNames' => $relatedClassNames, ]); } /** * Checks whether any registered behavior on that table has a modifier for a hook - * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" - * @param string $modifier - * @return boolean + * + * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" + * @param string $modifier + * + * @return bool */ public function hasBehaviorModifier($hookName, $modifier = '') { @@ -778,12 +811,14 @@ public function hasBehaviorModifier($hookName, $modifier = '') /** * Checks whether any registered behavior on that table has a modifier for a hook + * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" - * @param string $script The script will be modified in this method. + * @param string $script The script will be modified in this method. * @param string $tab + * * @return void */ - public function applyBehaviorModifier($hookName, &$script, $tab = " ") + public function applyBehaviorModifier($hookName, &$script, $tab = ' ') { $this->applyBehaviorModifierBase($hookName, 'TableMapBuilderModifier', $script, $tab); } @@ -792,6 +827,7 @@ public function applyBehaviorModifier($hookName, &$script, $tab = " ") * Adds method to get a version of the primary key that can be used as a unique key for identifier map. * * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetPrimaryKeyHash(&$script) @@ -805,7 +841,7 @@ protected function addGetPrimaryKeyHash(&$script) if (!$col->isLazyLoad()) { if ($col->isPrimaryKey()) { $part = "\$row[TableMap::TYPE_NUM == \$indexType ? $n + \$offset : static::translateFieldName('{$col->getPhpName()}', TableMap::TYPE_PHPNAME, \$indexType)]"; - $cond[] = $part . " === null"; + $cond[] = $part . ' === null'; $pk[] = $part; } $n++; @@ -831,11 +867,11 @@ public static function getPrimaryKeyHashFromRow(\$row, \$offset = 0, \$indexType if (count($pk) > 0) { $script .= " // If the PK cannot be derived from the row, return NULL. - if (".implode(' && ', $cond).") { + if (" . implode(' && ', $cond) . ") { return null; } - return ".$this->getInstancePoolKeySnippet($pk)."; + return " . $this->getInstancePoolKeySnippet($pk) . "; } "; } else { @@ -848,7 +884,9 @@ public static function getPrimaryKeyHashFromRow(\$row, \$offset = 0, \$indexType /** * Adds method to get the primary key from a row + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetPrimaryKeyFromRow(&$script) @@ -898,7 +936,6 @@ public static function getPrimaryKeyFromRow(\$row, \$offset = 0, \$indexType = T return \$pks;"; } else { - $pk = "''"; foreach ($table->getColumns() as $col) { if (!$col->isLazyLoad()) { @@ -914,7 +951,7 @@ public static function getPrimaryKeyFromRow(\$row, \$offset = 0, \$indexType = T } $script .= " - return " . $pk . ";"; + return " . $pk . ';'; } $script .= " @@ -924,7 +961,9 @@ public static function getPrimaryKeyFromRow(\$row, \$offset = 0, \$indexType = T /** * Adds the correct getOMClass() method, depending on whether this table uses inheritance. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetOMClassMethod(&$script) @@ -943,7 +982,9 @@ protected function addGetOMClassMethod(&$script) /** * Adds a getOMClass() for non-abstract tables that have inheritance. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetOMClass_Inheritance(&$script) @@ -975,8 +1016,8 @@ public static function getOMClass(\$row, \$colnum, \$withPrefix = true) "; foreach ($col->getChildren() as $child) { $script .= " - case {$this->getTableMapClassName()}::CLASSKEY_".$child->getConstantSuffix().": - \$omClass = {$this->getTableMapClassName()}::CLASSNAME_".$child->getConstantSuffix()."; + case {$this->getTableMapClassName()}::CLASSKEY_" . $child->getConstantSuffix() . ": + \$omClass = {$this->getTableMapClassName()}::CLASSNAME_" . $child->getConstantSuffix() . "; break; "; } /* foreach */ @@ -992,7 +1033,7 @@ public static function getOMClass(\$row, \$colnum, \$withPrefix = true) "; } else { /* if not enumerated */ $script .= " - \$omClass = \$row[\$colnum + ".($col->getPosition()-1)."]; + \$omClass = \$row[\$colnum + " . ($col->getPosition() - 1) . "]; \$omClass = preg_replace('#\.#', '\\\\', '.'.\$omClass); "; } @@ -1008,7 +1049,9 @@ public static function getOMClass(\$row, \$colnum, \$withPrefix = true) /** * Adds a getOMClass() for non-abstract tables that do note use inheritance. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetOMClass_NoInheritance(&$script) @@ -1027,14 +1070,16 @@ protected function addGetOMClass_NoInheritance(&$script) */ public static function getOMClass(\$withPrefix = true) { - return \$withPrefix ? " . $this->getTableMapClass() . "::CLASS_DEFAULT : " . $this->getTableMapClass() . "::OM_CLASS; + return \$withPrefix ? " . $this->getTableMapClass() . '::CLASS_DEFAULT : ' . $this->getTableMapClass() . "::OM_CLASS; } "; } /** * Adds a getOMClass() signature for abstract tables that do not have inheritance. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetOMClass_NoInheritance_Abstract(&$script) @@ -1044,7 +1089,7 @@ protected function addGetOMClass_NoInheritance_Abstract(&$script) * The class that the tableMap will make instances of. * * This method must be overridden by the stub subclass, because - * ".$this->getObjectClassName()." is declared abstract in the schema. + * " . $this->getObjectClassName() . " is declared abstract in the schema. * * @param boolean \$withPrefix */ @@ -1052,11 +1097,11 @@ abstract public static function getOMClass(\$withPrefix = true); "; } - - /** * Adds the populateObject() method. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addPopulateObject(&$script) @@ -1074,7 +1119,7 @@ protected function addPopulateObject(&$script) * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. - * @return array (" . $this->getObjectClassName(). " object, last column rank) + * @return array (" . $this->getObjectClassName() . " object, last column rank) */ public static function populateObject(\$row, \$offset = 0, \$indexType = TableMap::TYPE_NUM) { @@ -1083,20 +1128,20 @@ public static function populateObject(\$row, \$offset = 0, \$indexType = TableMa // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // \$obj->hydrate(\$row, \$offset, true); // rehydrate - \$col = \$offset + " . $this->getTableMapClass() . "::NUM_HYDRATE_COLUMNS;"; + \$col = \$offset + " . $this->getTableMapClass() . '::NUM_HYDRATE_COLUMNS;'; if ($table->isAbstract()) { $script .= " } elseif (null == \$key) { // empty resultset, probably from a left join // since this table is abstract, we can't hydrate an empty object \$obj = null; - \$col = \$offset + " . $this->getTableMapClass() . "::NUM_HYDRATE_COLUMNS;"; + \$col = \$offset + " . $this->getTableMapClass() . '::NUM_HYDRATE_COLUMNS;'; } $script .= " } else {"; if (!$table->getChildrenColumn()) { $script .= " - \$cls = " . $this->getTableMapClass() . "::OM_CLASS;"; + \$cls = " . $this->getTableMapClass() . '::OM_CLASS;'; } else { $script .= " \$cls = static::getOMClass(\$row, \$offset, false);"; @@ -1115,7 +1160,9 @@ public static function populateObject(\$row, \$offset = 0, \$indexType = TableMa /** * Adds the populateObjects() method. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addPopulateObjects(&$script) @@ -1150,8 +1197,7 @@ public static function populateObjects(DataFetcherInterface \$dataFetcher) // See http://www.propelorm.org/ticket/509 // \$obj->hydrate(\$row, 0, true); // rehydrate \$results[] = \$obj; - } else {" - ; + } else {"; if ($table->getChildrenColumn()) { $script .= " @@ -1181,7 +1227,9 @@ public static function populateObjects(DataFetcherInterface \$dataFetcher) /** * Adds the addSelectColumns() method. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addAddSelectColumns(&$script) @@ -1213,19 +1261,23 @@ public static function addSelectColumns(Criteria \$criteria, \$alias = null) foreach ($this->getTable()->getColumns() as $col) { if (!$col->isLazyLoad()) { $script .= " - \$criteria->addSelectColumn(\$alias . '." . $col->getName()."');"; + \$criteria->addSelectColumn(\$alias . '." . $col->getName() . "');"; } // if !col->isLazyLoad } // foreach $script .= " }"; - $script .=" + $script .= " } "; - } // addAddSelectColumns() + } + + // addAddSelectColumns() /** * Adds the getTableMap() method which is a convenience method for apps to get DB metadata. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addGetTableMap(&$script) @@ -1240,14 +1292,16 @@ protected function addGetTableMap(&$script) */ public static function getTableMap() { - return Propel::getServiceContainer()->getDatabaseMap(" . $this->getTableMapClass() . "::DATABASE_NAME)->getTable(" . $this->getTableMapClass() . "::TABLE_NAME); + return Propel::getServiceContainer()->getDatabaseMap(" . $this->getTableMapClass() . '::DATABASE_NAME)->getTable(' . $this->getTableMapClass() . "::TABLE_NAME); } "; } /** * Adds the doDeleteAll() method. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addDoDeleteAll(&$script) @@ -1255,7 +1309,7 @@ protected function addDoDeleteAll(&$script) $table = $this->getTable(); $script .= " /** - * Deletes all rows from the ".$table->getName()." table. + * Deletes all rows from the " . $table->getName() . " table. * * @param ConnectionInterface \$con the connection to use * @return int The number of affected rows (if supported by underlying database driver). @@ -1269,7 +1323,9 @@ public static function doDeleteAll(ConnectionInterface \$con = null) /** * Adds the doDelete() method. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addDoDelete(&$script) @@ -1277,9 +1333,9 @@ protected function addDoDelete(&$script) $table = $this->getTable(); $script .= " /** - * Performs a DELETE on the database, given a ".$this->getObjectClassName()." or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a " . $this->getObjectClassName() . " or Criteria object OR a primary key value. * - * @param mixed \$values Criteria or ".$this->getObjectClassName()." object or primary key or array of primary keys + * @param mixed \$values Criteria or " . $this->getObjectClassName() . " object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface \$con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -1297,7 +1353,7 @@ public static function doDelete(\$values, ConnectionInterface \$con = null) $script .= " // rename for clarity \$criteria = \$values; - } elseif (\$values instanceof \\".$this->getStubObjectBuilder()->getQualifiedClassName().") { // it's a model object"; + } elseif (\$values instanceof \\" . $this->getStubObjectBuilder()->getQualifiedClassName() . ") { // it's a model object"; if (count($table->getPrimaryKey()) > 0) { $script .= " // create criteria based on pk values @@ -1318,13 +1374,13 @@ public static function doDelete(\$values, ConnectionInterface \$con = null) throw new LogicException('The $class object has no primary key');"; } else { $script .= " - \$criteria = new Criteria(" . $this->getTableMapClass() . "::DATABASE_NAME);"; + \$criteria = new Criteria(" . $this->getTableMapClass() . '::DATABASE_NAME);'; - if (1 === count($table->getPrimaryKey())) { + if (count($table->getPrimaryKey()) === 1) { $pkey = $table->getPrimaryKey(); $col = array_shift($pkey); $script .= " - \$criteria->add(".$this->getColumnConstant($col).", (array) \$values, Criteria::IN);"; + \$criteria->add(" . $this->getColumnConstant($col) . ', (array) $values, Criteria::IN);'; } else { $script .= " // primary key is composite; we therefore, expect @@ -1336,12 +1392,12 @@ public static function doDelete(\$values, ConnectionInterface \$con = null) foreach (\$values as \$value) {"; $i = 0; foreach ($table->getPrimaryKey() as $col) { - if (0 === $i) { + if ($i === 0) { $script .= " - \$criterion = \$criteria->getNewCriterion(".$this->getColumnConstant($col).", \$value[$i]);"; + \$criterion = \$criteria->getNewCriterion(" . $this->getColumnConstant($col) . ", \$value[$i]);"; } else { $script .= " - \$criterion->addAnd(\$criteria->getNewCriterion(".$this->getColumnConstant($col).", \$value[$i]));"; + \$criterion->addAnd(\$criteria->getNewCriterion(" . $this->getColumnConstant($col) . ", \$value[$i]));"; } $i++; } @@ -1372,7 +1428,9 @@ public static function doDelete(\$values, ConnectionInterface \$con = null) /** * Adds the doInsert() method. + * * @param string $script The script will be modified in this method. + * * @return void */ protected function addDoInsert(&$script) @@ -1382,9 +1440,9 @@ protected function addDoInsert(&$script) $script .= " /** - * Performs an INSERT on the database, given a ".$this->getObjectClassName()." or Criteria object. + * Performs an INSERT on the database, given a " . $this->getObjectClassName() . " or Criteria object. * - * @param mixed \$criteria Criteria or ".$this->getObjectClassName()." object containing data that is used to create the INSERT statement. + * @param mixed \$criteria Criteria or " . $this->getObjectClassName() . " object containing data that is used to create the INSERT statement. * @param ConnectionInterface \$con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be @@ -1393,43 +1451,45 @@ protected function addDoInsert(&$script) public static function doInsert(\$criteria, ConnectionInterface \$con = null) { if (null === \$con) { - \$con = Propel::getServiceContainer()->getWriteConnection(" . $tableMapClass . "::DATABASE_NAME); + \$con = Propel::getServiceContainer()->getWriteConnection(" . $tableMapClass . "::DATABASE_NAME); } if (\$criteria instanceof Criteria) { \$criteria = clone \$criteria; // rename for clarity } else { - \$criteria = \$criteria->buildCriteria(); // build Criteria from ".$this->getObjectClassName()." object + \$criteria = \$criteria->buildCriteria(); // build Criteria from " . $this->getObjectClassName() . " object } "; foreach ($table->getColumns() as $col) { - if ($col->isPrimaryKey() + if ( + $col->isPrimaryKey() && $col->isAutoIncrement() - && 'none' !== $table->getIdMethod() + && $table->getIdMethod() !== 'none' && !$table->isAllowPkInsert() ) { $script .= " - if (\$criteria->containsKey(".$this->getColumnConstant($col).") && \$criteria->keyContainsValue(" . $this->getColumnConstant($col) . ") ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.".$this->getColumnConstant($col).".')'); + if (\$criteria->containsKey(" . $this->getColumnConstant($col) . ') && $criteria->keyContainsValue(' . $this->getColumnConstant($col) . ") ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('." . $this->getColumnConstant($col) . ".')'); } "; if (!$this->getPlatform()->supportsInsertNullPk()) { $script .= " // remove pkey col since this table uses auto-increment and passing a null value for it is not valid - \$criteria->remove(".$this->getColumnConstant($col)."); + \$criteria->remove(" . $this->getColumnConstant($col) . "); "; } - } elseif ($col->isPrimaryKey() + } elseif ( + $col->isPrimaryKey() && $col->isAutoIncrement() - && 'none' !== $table->getIdMethod() + && $table->getIdMethod() !== 'none' && $table->isAllowPkInsert() && !$this->getPlatform()->supportsInsertNullPk() ) { $script .= " // remove pkey col if it is null since this table does not accept that - if (\$criteria->containsKey(".$this->getColumnConstant($col).") && !\$criteria->keyContainsValue(" . $this->getColumnConstant($col) . ") ) { - \$criteria->remove(".$this->getColumnConstant($col)."); + if (\$criteria->containsKey(" . $this->getColumnConstant($col) . ') && !$criteria->keyContainsValue(' . $this->getColumnConstant($col) . ") ) { + \$criteria->remove(" . $this->getColumnConstant($col) . "); } "; } @@ -1448,5 +1508,4 @@ public static function doInsert(\$criteria, ConnectionInterface \$con = null) } "; } - } diff --git a/src/Propel/Generator/Builder/Om/templates/baseObjectMethodHook.php b/src/Propel/Generator/Builder/Om/templates/baseObjectMethodHook.php index 50e4048d7a..ff61aa5002 100644 --- a/src/Propel/Generator/Builder/Om/templates/baseObjectMethodHook.php +++ b/src/Propel/Generator/Builder/Om/templates/baseObjectMethodHook.php @@ -1,5 +1,5 @@ - + /** * Code to be run before persisting the object * @param ConnectionInterface $con @@ -7,31 +7,31 @@ */ public function preSave(ConnectionInterface $con = null) { - + if (is_callable('parent::preSave')) { - return parent::preSave($con); + return parent::preSave($con); } return true; } - + /** * Code to be run after persisting the object * @param ConnectionInterface $con */ public function postSave(ConnectionInterface $con = null) { - + if (is_callable('parent::postSave')) { - parent::postSave($con); + parent::postSave($con); } } - + /** * Code to be run before inserting to database * @param ConnectionInterface $con @@ -39,31 +39,31 @@ public function postSave(ConnectionInterface $con = null) */ public function preInsert(ConnectionInterface $con = null) { - + if (is_callable('parent::preInsert')) { - return parent::preInsert($con); + return parent::preInsert($con); } return true; } - + /** * Code to be run after inserting to database * @param ConnectionInterface $con */ public function postInsert(ConnectionInterface $con = null) { - + if (is_callable('parent::postInsert')) { - parent::postInsert($con); + parent::postInsert($con); } } - + /** * Code to be run before updating the object in database * @param ConnectionInterface $con @@ -71,31 +71,31 @@ public function postInsert(ConnectionInterface $con = null) */ public function preUpdate(ConnectionInterface $con = null) { - + if (is_callable('parent::preUpdate')) { - return parent::preUpdate($con); + return parent::preUpdate($con); } return true; } - + /** * Code to be run after updating the object in database * @param ConnectionInterface $con */ public function postUpdate(ConnectionInterface $con = null) { - + if (is_callable('parent::postUpdate')) { - parent::postUpdate($con); + parent::postUpdate($con); } } - + /** * Code to be run before deleting the object in database * @param ConnectionInterface $con @@ -103,27 +103,27 @@ public function postUpdate(ConnectionInterface $con = null) */ public function preDelete(ConnectionInterface $con = null) { - + if (is_callable('parent::preDelete')) { - return parent::preDelete($con); + return parent::preDelete($con); } return true; } - + /** * Code to be run after deleting the object in database * @param ConnectionInterface $con */ public function postDelete(ConnectionInterface $con = null) { - + if (is_callable('parent::postDelete')) { - parent::postDelete($con); + parent::postDelete($con); } } - +($name, $params) + public function __($name, $params) { if (0 === strpos($name, 'get')) { $virtualColumn = substr($name, 3); diff --git a/src/Propel/Generator/Builder/Util/PropelTemplate.php b/src/Propel/Generator/Builder/Util/PropelTemplate.php index 0ccac20ef2..4fb460f516 100644 --- a/src/Propel/Generator/Builder/Util/PropelTemplate.php +++ b/src/Propel/Generator/Builder/Util/PropelTemplate.php @@ -10,6 +10,7 @@ namespace Propel\Generator\Builder\Util; +use Exception; use Propel\Generator\Exception\InvalidArgumentException; /** @@ -38,6 +39,7 @@ class PropelTemplate * * * @param string $template the template string + * * @return void */ public function setTemplate($template) @@ -53,6 +55,7 @@ public function setTemplate($template) * * * @param string $filePath The (absolute or relative to the include path) file path + * * @return void */ public function setTemplateFile($filePath) @@ -76,7 +79,7 @@ public function setTemplateFile($filePath) */ public function render($vars = []) { - if (null === $this->templateFile && null === $this->template) { + if ($this->templateFile === null && $this->template === null) { throw new InvalidArgumentException('You must set a template or a template file before rendering'); } @@ -85,14 +88,15 @@ public function render($vars = []) ob_implicit_flush(0); try { - if (null !== $this->templateFile) { + if ($this->templateFile !== null) { require $this->templateFile; } else { eval('?>' . $this->template . 'schema = new Schema($defaultPlatform); $this->defaultPackage = $defaultPackage; @@ -105,7 +121,8 @@ public function __construct(PlatformInterface $defaultPlatform = null, $defaultP /** * Set the Schema generator configuration * - * @param GeneratorConfigInterface $generatorConfig + * @param \Propel\Generator\Config\GeneratorConfigInterface $generatorConfig + * * @return void */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) @@ -117,8 +134,9 @@ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) * Parses a XML input file and returns a newly created and * populated Schema structure. * - * @param string $xmlFile The input file to parse. - * @return Schema|null populated by xmlFile. + * @param string $xmlFile The input file to parse. + * + * @return \Propel\Generator\Model\Schema|null */ public function parseFile($xmlFile) { @@ -134,9 +152,12 @@ public function parseFile($xmlFile) * Parses a XML input string and returns a newly created and * populated Schema structure. * - * @param string $xmlString The input string to parse. - * @param string $xmlFile The input file name. - * @return Schema|null + * @param string $xmlString The input string to parse. + * @param string|null $xmlFile The input file name. + * + * @throws \Propel\Generator\Exception\SchemaException + * + * @return \Propel\Generator\Model\Schema|null */ public function parseString($xmlString, $xmlFile = null) { @@ -154,10 +175,11 @@ public function parseString($xmlString, $xmlFile = null) xml_set_object($parser, $this); xml_set_element_handler($parser, 'startElement', 'endElement'); if (!xml_parse($parser, $xmlString)) { - throw new SchemaException(sprintf('XML error: %s at line %d', + throw new SchemaException(sprintf( + 'XML error: %s at line %d', xml_error_string(xml_get_error_code($parser)), - xml_get_current_line_number($parser)) - ); + xml_get_current_line_number($parser) + )); } xml_parser_free($parser); @@ -172,28 +194,29 @@ public function parseString($xmlString, $xmlFile = null) * @param array $attributes * * @throws \Propel\Generator\Exception\SchemaException + * * @return void */ public function startElement($parser, $name, $attributes) { $parentTag = $this->peekCurrentSchemaTag(); - if (false === $parentTag) { + if ($parentTag === false) { switch ($name) { case 'database': if ($this->isExternalSchema()) { $this->currentPackage = isset($attributes['package']) ? $attributes['package'] : null; - if (null === $this->currentPackage) { + if ($this->currentPackage === null) { $this->currentPackage = $this->defaultPackage; } } else { $this->currDB = $this->schema->addDatabase($attributes); } - break; + break; default: $this->_throwInvalidTagException($parser, $name); } - } elseif ('database' === $parentTag) { + } elseif ($parentTag === 'database') { switch ($name) { case 'external-schema': $xmlFile = isset($attributes['filename']) ? $attributes['filename'] : null; @@ -202,10 +225,10 @@ public function startElement($parser, $name, $attributes) // and it's ignored in the nested external-schemas if (!$this->isExternalSchema()) { $isForRefOnly = isset($attributes['referenceOnly']) ? $attributes['referenceOnly'] : null; - $this->isForReferenceOnly = (null !== $isForRefOnly ? ('true' === strtolower($isForRefOnly)) : true); // defaults to TRUE + $this->isForReferenceOnly = ($isForRefOnly !== null ? (strtolower($isForRefOnly) === 'true') : true); // defaults to TRUE } - if ('/' !== $xmlFile[0]) { + if ($xmlFile[0] !== '/') { $xmlFile = realpath(dirname($this->currentXmlFile) . DIRECTORY_SEPARATOR . $xmlFile); if (!file_exists($xmlFile)) { throw new SchemaException(sprintf('Unknown include external "%s"', $xmlFile)); @@ -213,16 +236,18 @@ public function startElement($parser, $name, $attributes) } $this->parseFile($xmlFile); - break; + break; case 'domain': $this->currDB->addDomain($attributes); - break; + break; case 'table': - if (!isset($attributes['schema']) + if ( + !isset($attributes['schema']) && $this->currDB->getSchema() && $this->currDB->getPlatform()->supportsSchemas() - && false === strpos($attributes['name'], $this->currDB->getPlatform()->getSchemaDelimiter())) { + && strpos($attributes['name'], $this->currDB->getPlatform()->getSchemaDelimiter()) === false + ) { $attributes['schema'] = $this->currDB->getSchema(); } @@ -231,134 +256,123 @@ public function startElement($parser, $name, $attributes) $this->currTable->setForReferenceOnly($this->isForReferenceOnly); $this->currTable->setPackage($this->currentPackage); } - break; + break; case 'vendor': $this->currVendorObject = $this->currDB->addVendorInfo($attributes); - break; + break; case 'behavior': $this->currBehavior = $this->currDB->addBehavior($attributes); - break; + break; default: $this->_throwInvalidTagException($parser, $name); } - - } elseif ('table' === $parentTag) { + } elseif ($parentTag === 'table') { switch ($name) { case 'column': $this->currColumn = $this->currTable->addColumn($attributes); - break; + break; case 'foreign-key': $this->currFK = $this->currTable->addForeignKey($attributes); - break; + break; case 'index': $this->currIndex = new Index(); $this->currIndex->setTable($this->currTable); $this->currIndex->loadMapping($attributes); - break; + break; case 'unique': $this->currUnique = new Unique(); $this->currUnique->setTable($this->currTable); $this->currUnique->loadMapping($attributes); - break; + break; case 'vendor': $this->currVendorObject = $this->currTable->addVendorInfo($attributes); - break; + break; case 'id-method-parameter': $this->currTable->addIdMethodParameter($attributes); - break; + break; case 'behavior': $this->currBehavior = $this->currTable->addBehavior($attributes); - break; + break; default: $this->_throwInvalidTagException($parser, $name); } - - } elseif ('column' === $parentTag) { - + } elseif ($parentTag === 'column') { switch ($name) { case 'inheritance': $this->currColumn->addInheritance($attributes); - break; + break; case 'vendor': $this->currVendorObject = $this->currColumn->addVendorInfo($attributes); - break; + break; default: $this->_throwInvalidTagException($parser, $name); } - - } elseif ('foreign-key' === $parentTag) { - + } elseif ($parentTag === 'foreign-key') { switch ($name) { case 'reference': $this->currFK->addReference($attributes); - break; + break; case 'vendor': $this->currVendorObject = $this->currFK->addVendorInfo($attributes); - break; + break; default: $this->_throwInvalidTagException($parser, $name); } - - } elseif ('index' === $parentTag) { - + } elseif ($parentTag === 'index') { switch ($name) { case 'index-column': $this->currIndex->addColumn($attributes); - break; + break; case 'vendor': $this->currVendorObject = $this->currIndex->addVendorInfo($attributes); - break; + break; default: $this->_throwInvalidTagException($parser, $name); } - - } elseif ('unique' === $parentTag) { - + } elseif ($parentTag === 'unique') { switch ($name) { case 'unique-column': $this->currUnique->addColumn($attributes); - break; + break; case 'vendor': $this->currVendorObject = $this->currUnique->addVendorInfo($attributes); - break; + break; default: $this->_throwInvalidTagException($parser, $name); } } elseif ($parentTag === 'behavior') { - switch ($name) { case 'parameter': $this->currBehavior->addParameter($attributes); - break; + break; default: $this->_throwInvalidTagException($parser, $name); } - } elseif ('vendor' === $parentTag) { - + } elseif ($parentTag === 'vendor') { switch ($name) { case 'parameter': $this->currVendorObject->setParameter($attributes['name'], $attributes['value']); - break; + break; default: $this->_throwInvalidTagException($parser, $name); } @@ -375,12 +389,13 @@ public function startElement($parser, $name, $attributes) * @param string $tag_name * * @throws \Propel\Generator\Exception\SchemaException + * * @return void */ protected function _throwInvalidTagException($parser, $tag_name) { $location = ''; - if (null !== $this->currentXmlFile) { + if ($this->currentXmlFile !== null) { $location .= sprintf('file %s,', $this->currentXmlFile); } @@ -400,9 +415,9 @@ protected function _throwInvalidTagException($parser, $tag_name) */ public function endElement($parser, $name) { - if ('index' === $name) { + if ($name === 'index') { $this->currTable->addIndex($this->currIndex); - } else if ('unique' === $name) { + } elseif ($name === 'unique') { $this->currTable->addUnique($this->currUnique); } diff --git a/src/Propel/Generator/Command/AbstractCommand.php b/src/Propel/Generator/Command/AbstractCommand.php index 2e9a969793..a32434b598 100644 --- a/src/Propel/Generator/Command/AbstractCommand.php +++ b/src/Propel/Generator/Command/AbstractCommand.php @@ -11,19 +11,20 @@ namespace Propel\Generator\Command; use Propel\Generator\Config\GeneratorConfig; +use RuntimeException; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Finder\Finder; use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Finder\Finder; /** * @author William Durand */ abstract class AbstractCommand extends Command { - public const DEFAULT_CONFIG_DIRECTORY = '.'; + public const DEFAULT_CONFIG_DIRECTORY = '.'; public const CODE_SUCCESS = 0; public const CODE_ERROR = 1; @@ -31,29 +32,28 @@ abstract class AbstractCommand extends Command protected $filesystem; /** - * @inheritdoc + * @inheritDoc */ protected function configure() { $this - ->addOption('platform', null, InputOption::VALUE_REQUIRED, 'The platform to use. Define a full qualified class name or mysql|pgsql|sqlite|mssql|oracle.') - ->addOption('config-dir', null, InputOption::VALUE_REQUIRED, 'The directory where the configuration file is placed.', self::DEFAULT_CONFIG_DIRECTORY) - ->addOption('recursive', null, InputOption::VALUE_NONE, 'Search recursive for *schema.xml inside the input directory') - ; + ->addOption('platform', null, InputOption::VALUE_REQUIRED, 'The platform to use. Define a full qualified class name or mysql|pgsql|sqlite|mssql|oracle.') + ->addOption('config-dir', null, InputOption::VALUE_REQUIRED, 'The directory where the configuration file is placed.', self::DEFAULT_CONFIG_DIRECTORY) + ->addOption('recursive', null, InputOption::VALUE_NONE, 'Search recursive for *schema.xml inside the input directory'); } /** * Returns a new `GeneratorConfig` object with your `$properties` merged with * the configuration properties in the `config-dir` folder. * - * @param array $properties Properties to add to the configuration. They usually come from command line. - * @param InputInterface|null $input + * @param array|null $properties Properties to add to the configuration. They usually come from command line. + * @param \Symfony\Component\Console\Input\InputInterface|null $input * - * @return GeneratorConfig + * @return \Propel\Generator\Config\GeneratorConfig */ - protected function getGeneratorConfig(array $properties = null, InputInterface $input = null) + protected function getGeneratorConfig(?array $properties = null, ?InputInterface $input = null) { - if (null === $input) { + if ($input === null) { return new GeneratorConfig(null, $properties); } @@ -64,6 +64,7 @@ protected function getGeneratorConfig(array $properties = null, InputInterface $ if ($input->hasParameterOption('--recursive')) { $properties['propel']['generator']['recursive'] = $input->getOption('recursive'); } + return new GeneratorConfig($input->getOption('config-dir'), $properties); } @@ -71,7 +72,7 @@ protected function getGeneratorConfig(array $properties = null, InputInterface $ * Find every schema files. * * @param string|string[] $directory Path to the input directory - * @param bool $recursive Search for file inside the input directory and all subdirectories + * @param bool $recursive Search for file inside the input directory and all subdirectories * * @return array List of schema files */ @@ -92,11 +93,11 @@ protected function getSchemas($directory, $recursive = false) /** * Returns a Filesystem instance. * - * @return Filesystem + * @return \Symfony\Component\Filesystem\Filesystem */ protected function getFilesystem() { - if (null === $this->filesystem) { + if ($this->filesystem === null) { $this->filesystem = new Filesystem(); } @@ -107,6 +108,7 @@ protected function getFilesystem() * @param string $directory * * @throws \RuntimeException + * * @return void */ protected function createDirectory($directory) @@ -116,7 +118,7 @@ protected function createDirectory($directory) try { $filesystem->mkdir($directory); } catch (IOException $e) { - throw new \RuntimeException(sprintf('Unable to write the "%s" directory', $directory), 0, $e); + throw new RuntimeException(sprintf('Unable to write the "%s" directory', $directory), 0, $e); } } @@ -129,18 +131,18 @@ protected function createDirectory($directory) */ protected function parseConnection($connection) { - $pos = strpos($connection, '='); + $pos = strpos($connection, '='); $name = substr($connection, 0, $pos); - $dsn = substr($connection, $pos + 1, strlen($connection)); + $dsn = substr($connection, $pos + 1, strlen($connection)); - $pos = strpos($dsn, ':'); + $pos = strpos($dsn, ':'); $adapter = substr($dsn, 0, $pos); $extras = []; foreach (explode(';', $dsn) as $element) { $parts = preg_split('/=/', $element); - if (2 === count($parts)) { + if (count($parts) === 2) { $extras[strtolower($parts[0])] = urldecode($parts[1]); } } @@ -156,7 +158,7 @@ protected function parseConnection($connection) * where "bookstore" is your propel database name (used in your schema.xml). * * @param string $connection The connection string - * @param string $section The section where the connection must be registered in (generator, runtime...) + * @param string|null $section The section where the connection must be registered in (generator, runtime...) * * @return array */ @@ -169,11 +171,11 @@ protected function connectionToProperties($connection, $section = null) $config['propel']['database']['connections'][$name]['user'] = isset($infos['user']) && $infos['user'] ? $infos['user'] : null; $config['propel']['database']['connections'][$name]['password'] = isset($infos['password']) ? $infos['password'] : null; - if (null === $section) { + if ($section === null) { $section = 'generator'; } - if ('reverse' === $section) { + if ($section === 'reverse') { $config['propel']['reverse']['connection'] = $name; } else { $config['propel'][$section]['connections'][] = $name; @@ -188,11 +190,11 @@ protected function connectionToProperties($connection, $section = null) * @param string $option The name of the input option to check * @param \Symfony\Component\Console\Input\InputInterface $input object * - * @return boolean + * @return bool */ protected function hasInputOption($option, $input) { - return $input->hasOption($option) && null !== $input->getOption($option); + return $input->hasOption($option) && $input->getOption($option) !== null; } /** @@ -201,10 +203,10 @@ protected function hasInputOption($option, $input) * @param string $argument The name of the input argument to check * @param \Symfony\Component\Console\Input\InputInterface $input object * - * @return boolean + * @return bool */ protected function hasInputArgument($argument, $input) { - return $input->hasArgument($argument) && null !== $input->getArgument($argument); + return $input->hasArgument($argument) && $input->getArgument($argument) !== null; } } diff --git a/src/Propel/Generator/Command/ConfigConvertCommand.php b/src/Propel/Generator/Command/ConfigConvertCommand.php index 94c5820096..d3a3099992 100644 --- a/src/Propel/Generator/Command/ConfigConvertCommand.php +++ b/src/Propel/Generator/Command/ConfigConvertCommand.php @@ -11,33 +11,35 @@ namespace Propel\Generator\Command; use Propel\Common\Config\ConfigurationManager; -use Symfony\Component\Console\Input\InputOption; +use Propel\Generator\Config\ArrayToPhpConverter; +use RuntimeException; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Propel\Generator\Config\ArrayToPhpConverter; class ConfigConvertCommand extends AbstractCommand { - const DEFAULT_CONFIG_DIRECTORY = '.'; - const DEFAULT_OUTPUT_FILE = 'config.php'; + public const DEFAULT_CONFIG_DIRECTORY = '.'; + public const DEFAULT_OUTPUT_FILE = 'config.php'; /** - * @inheritdoc + * @inheritDoc */ protected function configure() { $this - ->addOption('config-dir', null, InputOption::VALUE_REQUIRED, 'The directory where the configuration file is placed.', self::DEFAULT_CONFIG_DIRECTORY) - ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory') - ->addOption('output-file', null, InputOption::VALUE_REQUIRED, 'The output file', self::DEFAULT_OUTPUT_FILE) + ->addOption('config-dir', null, InputOption::VALUE_REQUIRED, 'The directory where the configuration file is placed.', self::DEFAULT_CONFIG_DIRECTORY) + ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory') + ->addOption('output-file', null, InputOption::VALUE_REQUIRED, 'The output file', self::DEFAULT_OUTPUT_FILE) ->setName('config:convert') ->setAliases(['convert-conf']) - ->setDescription('Transform the configuration to PHP code leveraging the ServiceContainer') - ; + ->setDescription('Transform the configuration to PHP code leveraging the ServiceContainer'); } /** - * @inheritdoc + * @inheritDoc + * + * @throws \RuntimeException */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -49,9 +51,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->createDirectory($input->getOption('output-dir')); - $outputFilePath = $input->getOption('output-dir') . DIRECTORY_SEPARATOR .$input->getOption('output-file'); + $outputFilePath = $input->getOption('output-dir') . DIRECTORY_SEPARATOR . $input->getOption('output-file'); if (!is_writable(dirname($outputFilePath))) { - throw new \RuntimeException(sprintf('Unable to write the "%s" output file', $outputFilePath)); + throw new RuntimeException(sprintf('Unable to write the "%s" output file', $outputFilePath)); } //Create the options array to pass to ArrayToPhpConverter @@ -68,7 +70,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $currentContent = file_get_contents($outputFilePath); if ($currentContent == $phpConf) { $output->writeln(sprintf('No change required in the current configuration file "%s".', $outputFilePath)); - } else { file_put_contents($outputFilePath, $phpConf); $output->writeln(sprintf('Successfully updated PHP configuration in file "%s".', $outputFilePath)); diff --git a/src/Propel/Generator/Command/Console/Input/ArrayInput.php b/src/Propel/Generator/Command/Console/Input/ArrayInput.php index c5c43dc004..2659cc45d9 100644 --- a/src/Propel/Generator/Command/Console/Input/ArrayInput.php +++ b/src/Propel/Generator/Command/Console/Input/ArrayInput.php @@ -36,7 +36,7 @@ class ArrayInput extends Input * @param array $parameters * @param \Symfony\Component\Console\Input\InputDefinition|null $definition */ - public function __construct(array $parameters, InputDefinition $definition = null) + public function __construct(array $parameters, ?InputDefinition $definition = null) { $this->parameters = $parameters; @@ -44,12 +44,12 @@ public function __construct(array $parameters, InputDefinition $definition = nul } /** - * @inheritdoc + * @inheritDoc */ public function getFirstArgument() { foreach ($this->parameters as $key => $value) { - if ($key && '-' === $key[0]) { + if ($key && $key[0] === '-') { continue; } @@ -60,22 +60,22 @@ public function getFirstArgument() } /** - * @inheritdoc + * @inheritDoc */ public function hasParameterOption($values, $onlyParams = false) { - $values = (array) $values; + $values = (array)$values; foreach ($this->parameters as $k => $v) { - if (!\is_int($k)) { + if (!is_int($k)) { $v = $k; } - if ($onlyParams && '--' === $v) { + if ($onlyParams && $v === '--') { return false; } - if (\in_array($v, $values)) { + if (in_array($v, $values)) { return true; } } @@ -84,22 +84,22 @@ public function hasParameterOption($values, $onlyParams = false) } /** - * @inheritdoc + * @inheritDoc */ public function getParameterOption($values, $default = false, $onlyParams = false) { - $values = (array) $values; + $values = (array)$values; foreach ($this->parameters as $k => $v) { - if ($onlyParams && ('--' === $k || (\is_int($k) && '--' === $v))) { + if ($onlyParams && ($k === '--' || (is_int($k) && $v === '--'))) { return $default; } - if (\is_int($k)) { - if (\in_array($v, $values)) { + if (is_int($k)) { + if (in_array($v, $values)) { return true; } - } elseif (\in_array($k, $values)) { + } elseif (in_array($k, $values)) { return $v; } } @@ -116,16 +116,16 @@ public function __toString() { $params = []; foreach ($this->parameters as $param => $val) { - if ($param && '-' === $param[0]) { - if (\is_array($val)) { + if ($param && $param[0] === '-') { + if (is_array($val)) { foreach ($val as $v) { - $params[] = $param.('' != $v ? '='.$this->escapeToken($v) : ''); + $params[] = $param . ($v != '' ? '=' . $this->escapeToken($v) : ''); } } else { - $params[] = $param.('' != $val ? '='.$this->escapeToken($val) : ''); + $params[] = $param . ($val != '' ? '=' . $this->escapeToken($val) : ''); } } else { - $params[] = \is_array($val) ? implode(' ', array_map([$this, 'escapeToken'], $val)) : $this->escapeToken($val); + $params[] = is_array($val) ? implode(' ', array_map([$this, 'escapeToken'], $val)) : $this->escapeToken($val); } } @@ -133,17 +133,17 @@ public function __toString() } /** - * @inheritdoc + * @inheritDoc */ protected function parse() { foreach ($this->parameters as $key => $value) { - if ('--' === $key) { + if ($key === '--') { return; } - if (0 === strpos($key, '--')) { + if (strpos($key, '--') === 0) { $this->addLongOption(substr($key, 2), $value); - } elseif (0 === strpos($key, '-')) { + } elseif (strpos($key, '-') === 0) { $this->addShortOption(substr($key, 1), $value); } else { $this->addArgument($key, $value); @@ -154,7 +154,8 @@ protected function parse() /** * Adds a short option value. * - * @throws InvalidOptionException When option given doesn't exist + * @throws \Symfony\Component\Console\Exception\InvalidOptionException When option given doesn't exist + * * @return void */ private function addShortOption(string $shortcut, $value) @@ -169,8 +170,9 @@ private function addShortOption(string $shortcut, $value) /** * Adds a long option value. * - * @throws InvalidOptionException When option given doesn't exist - * @throws InvalidOptionException When a required value is missing + * @throws \Symfony\Component\Console\Exception\InvalidOptionException When option given doesn't exist + * @throws \Symfony\Component\Console\Exception\InvalidOptionException When a required value is missing + * * @return void */ private function addLongOption(string $name, $value) @@ -181,7 +183,7 @@ private function addLongOption(string $name, $value) $option = $this->definition->getOption($name); - if (null === $value) { + if ($value === null) { if ($option->isValueRequired()) { throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name)); } @@ -197,10 +199,11 @@ private function addLongOption(string $name, $value) /** * Adds an argument value. * - * @param string|int $name The argument name - * @param mixed $value The value for the argument + * @param string|int $name The argument name + * @param mixed $value The value for the argument + * + * @throws \Symfony\Component\Console\Exception\InvalidArgumentException When argument given doesn't exist * - * @throws InvalidArgumentException When argument given doesn't exist * @return void */ private function addArgument($name, $value) diff --git a/src/Propel/Generator/Command/DatabaseReverseCommand.php b/src/Propel/Generator/Command/DatabaseReverseCommand.php index e656a1ecc6..ee7d507752 100644 --- a/src/Propel/Generator/Command/DatabaseReverseCommand.php +++ b/src/Propel/Generator/Command/DatabaseReverseCommand.php @@ -10,34 +10,34 @@ namespace Propel\Generator\Command; +use Propel\Generator\Manager\ReverseManager; use Propel\Generator\Schema\Dumper\XmlDumper; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Propel\Generator\Manager\ReverseManager; /** * @author William Durand */ class DatabaseReverseCommand extends AbstractCommand { - const DEFAULT_OUTPUT_DIRECTORY = 'generated-reversed-database'; - const DEFAULT_DATABASE_NAME = 'default'; - const DEFAULT_SCHEMA_NAME = 'schema'; + public const DEFAULT_OUTPUT_DIRECTORY = 'generated-reversed-database'; + public const DEFAULT_DATABASE_NAME = 'default'; + public const DEFAULT_SCHEMA_NAME = 'schema'; /** - * @inheritdoc + * @inheritDoc */ protected function configure() { parent::configure(); $this - ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory', self::DEFAULT_OUTPUT_DIRECTORY) + ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory', self::DEFAULT_OUTPUT_DIRECTORY) ->addOption('database-name', null, InputOption::VALUE_REQUIRED, 'The database name used in the created schema.xml. If not defined we use `connection`.') - ->addOption('schema-name', null, InputOption::VALUE_REQUIRED, 'The schema name to generate', self::DEFAULT_SCHEMA_NAME) - ->addOption('namespace', null, InputOption::VALUE_OPTIONAL, 'The PHP namespace to use for generated models') + ->addOption('schema-name', null, InputOption::VALUE_REQUIRED, 'The schema name to generate', self::DEFAULT_SCHEMA_NAME) + ->addOption('namespace', null, InputOption::VALUE_OPTIONAL, 'The PHP namespace to use for generated models') ->addArgument( 'connection', InputArgument::OPTIONAL, @@ -46,19 +46,18 @@ protected function configure() ) ->setName('database:reverse') ->setAliases(['reverse']) - ->setDescription('Reverse-engineer a XML schema file based on given database. Uses given `connection` as name, as dsn or your `reverse.connection` configuration in propel config as connection.') - ; + ->setDescription('Reverse-engineer a XML schema file based on given database. Uses given `connection` as name, as dsn or your `reverse.connection` configuration in propel config as connection.'); } /** - * @inheritdoc + * @inheritDoc */ protected function execute(InputInterface $input, OutputInterface $output): int { $configOptions = []; $connection = $input->getArgument('connection'); - if (false === strpos($connection, ':')) { + if (strpos($connection, ':') === false) { //treat it as connection name $configOptions['propel']['reverse']['connection'] = $connection; if (!$input->getOption('database-name')) { @@ -97,7 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $manager->setNamespace($namespace); } - if (true === $manager->reverse()) { + if ($manager->reverse() === true) { $output->writeln('Schema reverse engineering finished.'); } diff --git a/src/Propel/Generator/Command/GraphvizGenerateCommand.php b/src/Propel/Generator/Command/GraphvizGenerateCommand.php index 0657479eb3..679d87f627 100644 --- a/src/Propel/Generator/Command/GraphvizGenerateCommand.php +++ b/src/Propel/Generator/Command/GraphvizGenerateCommand.php @@ -10,41 +10,40 @@ namespace Propel\Generator\Command; -use Symfony\Component\Console\Input\InputOption; +use Propel\Generator\Manager\GraphvizManager; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Propel\Generator\Manager\GraphvizManager; /** * @author William Durand */ class GraphvizGenerateCommand extends AbstractCommand { - const DEFAULT_OUTPUT_DIRECTORY = 'generated-graphviz'; + public const DEFAULT_OUTPUT_DIRECTORY = 'generated-graphviz'; /** - * @inheritdoc + * @inheritDoc */ protected function configure() { parent::configure(); $this - ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory', self::DEFAULT_OUTPUT_DIRECTORY) - ->addOption('schema-dir', null, InputOption::VALUE_REQUIRED, 'The directory where the schema files are placed') + ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory', self::DEFAULT_OUTPUT_DIRECTORY) + ->addOption('schema-dir', null, InputOption::VALUE_REQUIRED, 'The directory where the schema files are placed') ->setName('graphviz:generate') ->setAliases(['graphviz']) - ->setDescription('Generate Graphviz files (.dot)') - ; + ->setDescription('Generate Graphviz files (.dot)'); } /** - * @inheritdoc + * @inheritDoc */ protected function execute(InputInterface $input, OutputInterface $output): int { $configOptions = []; - if ($this->hasInputOption('schema-dir', $input)){ + if ($this->hasInputOption('schema-dir', $input)) { $configOptions['propel']['paths']['schemaDir'] = $input->getOption('schema-dir'); } $generatorConfig = $this->getGeneratorConfig($configOptions, $input); diff --git a/src/Propel/Generator/Command/Helper/ConsoleHelper.php b/src/Propel/Generator/Command/Helper/ConsoleHelper.php index 0f818411b9..55738b3383 100644 --- a/src/Propel/Generator/Command/Helper/ConsoleHelper.php +++ b/src/Propel/Generator/Command/Helper/ConsoleHelper.php @@ -2,13 +2,14 @@ namespace Propel\Generator\Command\Helper; +use Symfony\Component\Console\Helper\DialogHelper as Symfony23DialogHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Helper\DialogHelper as Symfony23DialogHelper; class ConsoleHelper extends Symfony23DialogHelper implements ConsoleHelperInterface { protected $input; + protected $output; /** @@ -22,15 +23,15 @@ public function __construct(InputInterface $input, OutputInterface $output) } /** - * @inheritdoc + * @inheritDoc */ - public function askQuestion($question, $default = null, array $autocomplete = null) + public function askQuestion($question, $default = null, ?array $autocomplete = null) { return parent::ask($this->output, $this->formatQuestion($question, $default), $default, $autocomplete); } /** - * @inheritdoc + * @inheritDoc */ public function askHiddenResponse($question, $fallback = true) { @@ -38,7 +39,7 @@ public function askHiddenResponse($question, $fallback = true) } /** - * @inheritdoc + * @inheritDoc */ public function writeSection($text) { @@ -49,7 +50,7 @@ public function writeSection($text) } /** - * @inheritdoc + * @inheritDoc */ public function writeBlock($text, $style = 'bg=blue;fg=white') { @@ -60,7 +61,7 @@ public function writeBlock($text, $style = 'bg=blue;fg=white') } /** - * @inheritdoc + * @inheritDoc */ public function writeSummary($items) { @@ -71,7 +72,7 @@ public function writeSummary($items) } /** - * @inheritdoc + * @inheritDoc */ private function formatQuestion($question, $default = null) { @@ -83,23 +84,23 @@ private function formatQuestion($question, $default = null) } /** - * @inheritdoc + * @inheritDoc */ public function select($question, $choices, $default = null, $attempts = null, $errorMessage = 'Value "%s" is invalid', $multiselect = false) { return parent::select( - $this->output, - $this->formatQuestion($question, $default), - $choices, - $default, - $attempts, - $errorMessage, - $multiselect - ); + $this->output, + $this->formatQuestion($question, $default), + $choices, + $default, + $attempts, + $errorMessage, + $multiselect + ); } /** - * @inheritdoc + * @inheritDoc */ public function askConfirmation($question, $default = true) { @@ -107,7 +108,7 @@ public function askConfirmation($question, $default = true) } /** - * @inheritdoc + * @inheritDoc */ public function getInput() { @@ -115,7 +116,7 @@ public function getInput() } /** - * @inheritdoc + * @inheritDoc */ public function setInput(InputInterface $input) { @@ -123,7 +124,7 @@ public function setInput(InputInterface $input) } /** - * @inheritdoc + * @inheritDoc */ public function getOutput() { @@ -131,7 +132,7 @@ public function getOutput() } /** - * @inheritdoc + * @inheritDoc */ public function setOutput(OutputInterface $output) { @@ -139,7 +140,7 @@ public function setOutput(OutputInterface $output) } /** - * @inheritdoc + * @inheritDoc */ public function writeln($messages, $options = 0) { diff --git a/src/Propel/Generator/Command/Helper/ConsoleHelper3.php b/src/Propel/Generator/Command/Helper/ConsoleHelper3.php index 6f263d5553..bbcf1c9de8 100644 --- a/src/Propel/Generator/Command/Helper/ConsoleHelper3.php +++ b/src/Propel/Generator/Command/Helper/ConsoleHelper3.php @@ -2,7 +2,6 @@ namespace Propel\Generator\Command\Helper; -use Symfony\Component\Console\Helper\FormatterHelper; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -12,10 +11,14 @@ class ConsoleHelper3 extends QuestionHelper implements ConsoleHelperInterface { - /** @var InputInterface $input */ + /** + * @var \Symfony\Component\Console\Input\InputInterface $input + */ protected $input; - /** @var OutputInterface $output */ + /** + * @var \Symfony\Component\Console\Output\OutputInterface $output + */ protected $output; /** @@ -29,9 +32,9 @@ public function __construct(InputInterface $input, OutputInterface $output) } /** - * @inheritdoc + * @inheritDoc */ - public function askQuestion($question, $default = null, array $autocomplete = null) + public function askQuestion($question, $default = null, ?array $autocomplete = null) { $question = new Question($this->formatQuestion($question, $default), $default); $question->setAutocompleterValues($autocomplete); @@ -40,7 +43,7 @@ public function askQuestion($question, $default = null, array $autocomplete = nu } /** - * @inheritdoc + * @inheritDoc */ public function askHiddenResponse($question, $fallback = true) { @@ -52,7 +55,7 @@ public function askHiddenResponse($question, $fallback = true) } /** - * @inheritdoc + * @inheritDoc */ public function writeSection($text) { @@ -63,11 +66,11 @@ public function writeSection($text) } /** - * @inheritdoc + * @inheritDoc */ public function writeBlock($text, $style = 'bg=blue;fg=white') { - /** @var FormatterHelper $formatter */ + /** @var \Symfony\Component\Console\Helper\FormatterHelper $formatter */ $formatter = $this->getHelperSet()->get('formatter'); $block = $formatter->formatBlock($text, $style, true); @@ -75,7 +78,7 @@ public function writeBlock($text, $style = 'bg=blue;fg=white') } /** - * @inheritdoc + * @inheritDoc */ public function writeSummary($items) { @@ -86,7 +89,7 @@ public function writeSummary($items) } /** - * @inheritdoc + * @inheritDoc */ public function select($question, $choices, $default = null, $attempts = null, $errorMessage = 'Value "%s" is invalid', $multiselect = false) { @@ -103,7 +106,7 @@ public function select($question, $choices, $default = null, $attempts = null, $ } /** - * @inheritdoc + * @inheritDoc */ public function askConfirmation($question, $default = true) { @@ -113,7 +116,7 @@ public function askConfirmation($question, $default = true) } /** - * @inheritdoc + * @inheritDoc */ public function getInput() { @@ -121,7 +124,7 @@ public function getInput() } /** - * @inheritdoc + * @inheritDoc */ public function setInput(InputInterface $input) { @@ -129,7 +132,7 @@ public function setInput(InputInterface $input) } /** - * @inheritdoc + * @inheritDoc */ public function getOutput() { @@ -137,7 +140,7 @@ public function getOutput() } /** - * @inheritdoc + * @inheritDoc */ public function setOutput(OutputInterface $output) { @@ -145,7 +148,7 @@ public function setOutput(OutputInterface $output) } /** - * @inheritdoc + * @inheritDoc */ public function writeln($messages, $options = 0) { @@ -153,8 +156,8 @@ public function writeln($messages, $options = 0) } /** - * @param string $question - * @param string|null $default + * @param string $question + * @param string|null $default * * @return string */ diff --git a/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php b/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php index 0af822a5fe..55a8cf9bbc 100644 --- a/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php +++ b/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php @@ -14,13 +14,13 @@ interface ConsoleHelperInterface public function __construct(InputInterface $input, OutputInterface $output); /** - * @param string $question - * @param string|null $default - * @param array|null $autocomplete + * @param string $question + * @param string|null $default + * @param array|null $autocomplete * * @return mixed */ - public function askQuestion($question, $default = null, array $autocomplete = null); + public function askQuestion($question, $default = null, ?array $autocomplete = null); /** * @param string $question @@ -49,42 +49,44 @@ public function writeSummary($items); /** * @param string $question - * @param array $choices - * @param string $default - * @param int|null $attempts + * @param array $choices + * @param string|null $default + * @param int|null $attempts * @param string $errorMessage - * @param bool $multiselect + * @param bool $multiselect * * @return mixed */ public function select($question, $choices, $default = null, $attempts = null, $errorMessage = 'Value "%s" is invalid', $multiselect = false); /** - * @param string $question - * @param bool $default + * @param string $question + * @param bool $default * * @return mixed */ public function askConfirmation($question, $default = true); /** - * @return OutputInterface + * @return \Symfony\Component\Console\Output\OutputInterface */ public function getOutput(); /** - * @return InputInterface + * @return \Symfony\Component\Console\Input\InputInterface */ public function getInput(); /** - * @param OutputInterface $output + * @param \Symfony\Component\Console\Output\OutputInterface $output + * * @return void */ public function setOutput(OutputInterface $output); /** - * @param InputInterface $input + * @param \Symfony\Component\Console\Input\InputInterface $input + * * @return void */ public function setInput(InputInterface $input); @@ -93,7 +95,8 @@ public function setInput(InputInterface $input); * Writes a message to the output and adds a newline at the end. * * @param string|array $messages The message as an array of lines of a single string - * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL + * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL + * * @return void */ public function writeln($messages, $options = 0); diff --git a/src/Propel/Generator/Command/InitCommand.php b/src/Propel/Generator/Command/InitCommand.php index 517433ba23..00df1123ea 100644 --- a/src/Propel/Generator/Command/InitCommand.php +++ b/src/Propel/Generator/Command/InitCommand.php @@ -10,8 +10,8 @@ namespace Propel\Generator\Command; -use Propel\Generator\Command\Console\Input\ArrayInput; use Propel\Generator\Builder\Util\PropelTemplate; +use Propel\Generator\Command\Console\Input\ArrayInput; use Propel\Generator\Command\Helper\ConsoleHelper; use Propel\Generator\Command\Helper\ConsoleHelper3; use Propel\Generator\Command\Helper\ConsoleHelperInterface; @@ -28,6 +28,7 @@ class InitCommand extends AbstractCommand { private $defaultSchemaDir; + private $defaultPhpDir; /** @@ -49,8 +50,7 @@ protected function configure() $this ->setName('init') - ->setDescription('Initializes a new project') - ; + ->setDescription('Initializes a new project'); } /** @@ -75,7 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'pgsql' => 'PostgreSQL', 'oracle' => 'Oracle', 'sqlsrv' => 'MSSQL (via pdo-sqlsrv)', - 'mssql' => 'MSSQL (via pdo-mssql)' + 'mssql' => 'MSSQL (via pdo-mssql)', ]; $options['rdbms'] = $consoleHelper->select('Please pick your favorite database management system', $supportedRdbms); @@ -86,29 +86,32 @@ protected function execute(InputInterface $input, OutputInterface $output): int $connectionAttemptCount = 0; do { if ($connectionAttemptCount >= $connectionAttemptLimit) { - $consoleHelper->writeln(''); - $consoleHelper->writeSection('Exceeded 10 attempts to connect to database'); - $consoleHelper->writeln(''); + $consoleHelper->writeln(''); + $consoleHelper->writeSection('Exceeded 10 attempts to connect to database'); + $consoleHelper->writeln(''); - return 1; + return 1; } $connectionAttemptCount += 1; switch ($options['rdbms']) { case 'mysql': $options['dsn'] = $this->initMysql($consoleHelper); + break; case 'sqlite': $options['dsn'] = $this->initSqlite($consoleHelper); + break; case 'pgsql': $options['dsn'] = $this->initPgsql($consoleHelper); + break; default: $options['dsn'] = $this->initDsn($consoleHelper, $options['rdbms']); + break; } - $options['user'] = $consoleHelper->askQuestion('Please enter your database user', 'root'); $options['password'] = $consoleHelper->askHiddenResponse('Please enter your database password'); @@ -159,6 +162,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!$correct) { $consoleHelper->writeln('Process aborted.'); + return static::CODE_ERROR; } @@ -240,12 +244,15 @@ private function initDsn(ConsoleHelperInterface $consoleHelper, $rdbms) switch ($rdbms) { case 'oracle': $help = 'https://php.net/manual/en/ref.pdo-oci.connection.php#refsect1-ref.pdo-oci.connection-description'; + break; case 'sqlsrv': $help = 'https://php.net/manual/en/ref.pdo-sqlsrv.connection.php#refsect1-ref.pdo-sqlsrv.connection-description'; + break; case 'mssql': $help = 'https://php.net/manual/en/ref.pdo-dblib.connection.php#refsect1-ref.pdo-dblib.connection-description'; + break; default: $help = 'https://php.net/manual/en/pdo.drivers.php'; @@ -295,8 +302,8 @@ private function buildSqlAndModelsAndConvertConfig() 'config:convert', ]; - foreach($followupCommands as $command) { - if (0 !== $this->getApplication()->run(new ArrayInput([$command]))) { + foreach ($followupCommands as $command) { + if ($this->getApplication()->run(new ArrayInput([$command])) !== 0) { exit(1); } } @@ -332,18 +339,19 @@ private function testConnection(ConsoleHelperInterface $consoleHelper, array $op ConnectionFactory::create($options, $adapter); $consoleHelper->writeBlock('Connected to sql server successful!'); + return true; } catch (ConnectionException $e) { // get the "real" wrapped exception message do { $message = $e->getMessage(); - } while (null !== ($e = $e->getPrevious())); + } while (($e = $e->getPrevious()) !== null); $consoleHelper->writeBlock('Unable to connect to the specific sql server: ' . $message, 'error'); $consoleHelper->writeSection('Make sure the specified credentials are correct and try it again.'); $consoleHelper->writeln(''); - if (OutputInterface::VERBOSITY_DEBUG === $consoleHelper->getOutput()->getVerbosity()) { + if ($consoleHelper->getOutput()->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) { $consoleHelper->writeln($e); } @@ -367,7 +375,7 @@ private function reverseEngineerSchema(OutputInterface $output, array $options) $arrInput = [ 'reverse', 'connection' => $fullDsn, - '--output-dir' => $outputDir + '--output-dir' => $outputDir, ]; if (isset($options['namespace'])) { @@ -375,9 +383,9 @@ private function reverseEngineerSchema(OutputInterface $output, array $options) } $input = new ArrayInput($arrInput); - $result = $this->getApplication()->run($input,$output); + $result = $this->getApplication()->run($input, $output); - if (0 === $result) { + if ($result === 0) { $schema = file_get_contents($outputDir . '/schema.xml'); } else { exit(1); @@ -389,10 +397,10 @@ private function reverseEngineerSchema(OutputInterface $output, array $options) } /** - * @param InputInterface $input - * @param OutputInterface $output + * @param \Symfony\Component\Console\Input\InputInterface $input + * @param \Symfony\Component\Console\Output\OutputInterface $output * - * @return ConsoleHelperInterface + * @return \Propel\Generator\Command\Helper\ConsoleHelperInterface */ protected function createConsoleHelper(InputInterface $input, OutputInterface $output) { diff --git a/src/Propel/Generator/Command/MigrationCreateCommand.php b/src/Propel/Generator/Command/MigrationCreateCommand.php index ccf71e18a6..d23effe79d 100644 --- a/src/Propel/Generator/Command/MigrationCreateCommand.php +++ b/src/Propel/Generator/Command/MigrationCreateCommand.php @@ -10,13 +10,10 @@ namespace Propel\Generator\Command; -use Propel\Common\Config\ConfigurationManager; -use Symfony\Component\Console\Input\InputOption; +use Propel\Generator\Manager\MigrationManager; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Output\Output; -use Propel\Generator\Exception\RuntimeException; -use Propel\Generator\Manager\MigrationManager; /** * @author William Durand @@ -25,26 +22,25 @@ class MigrationCreateCommand extends AbstractCommand { /** - * @inheritdoc + * @inheritDoc */ protected function configure() { parent::configure(); $this - ->addOption('schema-dir', null, InputOption::VALUE_REQUIRED, 'The directory where the schema files are placed') - ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory where the migration files are located') - ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use. Example: \'bookstore=mysql:host=127.0.0.1;dbname=test;user=root;password=foobar\' where "bookstore" is your propel database name (used in your schema.xml)', []) - ->addOption('editor', null, InputOption::VALUE_OPTIONAL, 'The text editor to use to open diff files', null) - ->addOption('comment', "m", InputOption::VALUE_OPTIONAL, 'A comment for the migration', '') - ->addOption('suffix', null, InputOption::VALUE_OPTIONAL, 'A suffix for the migration class', '') + ->addOption('schema-dir', null, InputOption::VALUE_REQUIRED, 'The directory where the schema files are placed') + ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory where the migration files are located') + ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use. Example: \'bookstore=mysql:host=127.0.0.1;dbname=test;user=root;password=foobar\' where "bookstore" is your propel database name (used in your schema.xml)', []) + ->addOption('editor', null, InputOption::VALUE_OPTIONAL, 'The text editor to use to open diff files', null) + ->addOption('comment', 'm', InputOption::VALUE_OPTIONAL, 'A comment for the migration', '') + ->addOption('suffix', null, InputOption::VALUE_OPTIONAL, 'A suffix for the migration class', '') ->setName('migration:create') - ->setDescription('Create an empty migration class') - ; + ->setDescription('Create an empty migration class'); } /** - * @inheritdoc + * @inheritDoc */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -72,16 +68,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int $manager->setGeneratorConfig($generatorConfig); $manager->setSchemas($this->getSchemas($generatorConfig->getSection('paths')['schemaDir'], $generatorConfig->getSection('generator')['recursive'])); - $migrationsUp = []; + $migrationsUp = []; $migrationsDown = []; foreach ($manager->getDatabases() as $appDatabase) { $name = $appDatabase->getName(); - $migrationsUp[$name] = ''; - $migrationsDown[$name] = ''; + $migrationsUp[$name] = ''; + $migrationsDown[$name] = ''; } $timestamp = time(); - $migrationFileName = $manager->getMigrationFileName($timestamp, $input->getOption('suffix')); + $migrationFileName = $manager->getMigrationFileName($timestamp, $input->getOption('suffix')); $migrationClassBody = $manager->getMigrationClassBody($migrationsUp, $migrationsDown, $timestamp, $input->getOption('comment'), $input->getOption('suffix')); $file = $generatorConfig->getSection('paths')['migrationDir'] . DIRECTORY_SEPARATOR . $migrationFileName; @@ -99,5 +95,4 @@ protected function execute(InputInterface $input, OutputInterface $output): int return static::CODE_SUCCESS; } - } diff --git a/src/Propel/Generator/Command/MigrationDiffCommand.php b/src/Propel/Generator/Command/MigrationDiffCommand.php index 4ed0d9aa78..8bf80f5d00 100644 --- a/src/Propel/Generator/Command/MigrationDiffCommand.php +++ b/src/Propel/Generator/Command/MigrationDiffCommand.php @@ -11,16 +11,16 @@ namespace Propel\Generator\Command; use Propel\Common\Config\ConfigurationManager; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Output\Output; use Propel\Generator\Exception\RuntimeException; use Propel\Generator\Manager\MigrationManager; use Propel\Generator\Model\Database; use Propel\Generator\Model\Diff\DatabaseComparator; use Propel\Generator\Model\IdMethod; use Propel\Generator\Model\Schema; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\Output; +use Symfony\Component\Console\Output\OutputInterface; /** * @author William Durand @@ -28,32 +28,33 @@ class MigrationDiffCommand extends AbstractCommand { /** - * @inheritdoc + * @inheritDoc */ protected function configure() { parent::configure(); $this - ->addOption('schema-dir', null, InputOption::VALUE_REQUIRED, 'The directory where the schema files are placed') - ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory where the migration files are located') - ->addOption('migration-table', null, InputOption::VALUE_REQUIRED, 'Migration table name', null) - ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use. Example: \'bookstore=mysql:host=127.0.0.1;dbname=test;user=root;password=foobar\' where "bookstore" is your propel database name (used in your schema.xml)', []) - ->addOption('table-renaming', null, InputOption::VALUE_NONE, 'Detect table renaming', null) - ->addOption('editor', null, InputOption::VALUE_OPTIONAL, 'The text editor to use to open diff files', null) - ->addOption('skip-removed-table', null, InputOption::VALUE_NONE, 'Option to skip removed table from the migration') - ->addOption('skip-tables', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'List of excluded tables', []) + ->addOption('schema-dir', null, InputOption::VALUE_REQUIRED, 'The directory where the schema files are placed') + ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory where the migration files are located') + ->addOption('migration-table', null, InputOption::VALUE_REQUIRED, 'Migration table name', null) + ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use. Example: \'bookstore=mysql:host=127.0.0.1;dbname=test;user=root;password=foobar\' where "bookstore" is your propel database name (used in your schema.xml)', []) + ->addOption('table-renaming', null, InputOption::VALUE_NONE, 'Detect table renaming', null) + ->addOption('editor', null, InputOption::VALUE_OPTIONAL, 'The text editor to use to open diff files', null) + ->addOption('skip-removed-table', null, InputOption::VALUE_NONE, 'Option to skip removed table from the migration') + ->addOption('skip-tables', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'List of excluded tables', []) ->addOption('disable-identifier-quoting', null, InputOption::VALUE_NONE, 'Disable identifier quoting in SQL queries for reversed database tables.') - ->addOption('comment', "m", InputOption::VALUE_OPTIONAL, 'A comment for the migration', '') - ->addOption('suffix', null, InputOption::VALUE_OPTIONAL, 'A suffix for the migration class', '') + ->addOption('comment', 'm', InputOption::VALUE_OPTIONAL, 'A comment for the migration', '') + ->addOption('suffix', null, InputOption::VALUE_OPTIONAL, 'A suffix for the migration class', '') ->setName('migration:diff') ->setAliases(['diff']) - ->setDescription('Generate diff classes') - ; + ->setDescription('Generate diff classes'); } /** - * @inheritdoc + * @inheritDoc + * + * @throws \Propel\Generator\Exception\RuntimeException */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -91,7 +92,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $connections = $generatorConfig->getBuildConnections(); } else { foreach ($optionConnections as $connection) { - list($name, $dsn, $infos) = $this->parseConnection($connection); + [$name, $dsn, $infos] = $this->parseConnection($connection); $connections[$name] = array_merge(['dsn' => $dsn], $infos); } } @@ -108,7 +109,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $reversedSchema = new Schema(); foreach ($manager->getDatabases() as $appDatabase) { - $name = $appDatabase->getName(); if (!$params = @$connections[$name]) { $output->writeln(sprintf('No connection configured for database "%s"', $name)); @@ -118,11 +118,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln(sprintf('Connecting to database "%s" using DSN "%s"', $name, $params['dsn'])); } - $conn = $manager->getAdapterConnection($name); + $conn = $manager->getAdapterConnection($name); $platform = $generatorConfig->getConfiguredPlatform($conn, $name); if (!$platform->supportsMigrations()) { $output->writeln(sprintf('Skipping database "%s" since vendor "%s" does not support migrations', $name, $platform->getDatabaseType())); + continue; } @@ -142,7 +143,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $database->setSchema($appDatabase->getSchema()); $database->setDefaultIdMethod(IdMethod::NATIVE); - $parser = $generatorConfig->getConfiguredSchemaParser($conn, $name); + $parser = $generatorConfig->getConfiguredSchemaParser($conn, $name); $nbTables = $parser->parse($database, $additionalTables); $reversedSchema->addDatabase($database); @@ -163,12 +164,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Comparing models...'); $tableRenaming = $input->getOption('table-renaming'); - $migrationsUp = []; + $migrationsUp = []; $migrationsDown = []; $removeTable = !$input->getOption('skip-removed-table'); $excludedTables = $input->getOption('skip-tables'); $configManager = new ConfigurationManager($input->getOption('config-dir')); - $excludedTables = array_merge((array) $excludedTables, (array) $configManager->getSection('exclude_tables')); + $excludedTables = array_merge((array)$excludedTables, (array)$configManager->getSection('exclude_tables')); foreach ($reversedSchema->getDatabases() as $database) { $name = $database->getName(); @@ -179,6 +180,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!$appDataDatabase = $manager->getDatabase($name)) { $output->writeln(sprintf('Database "%s" does not exist in schema.xml. Skipped.', $name)); + continue; } @@ -188,6 +190,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($input->getOption('verbose')) { $output->writeln(sprintf('Same XML and database structures for datasource "%s" - no diff to generate', $name)); } + continue; } @@ -196,18 +199,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int foreach ($databaseDiff->getPossibleRenamedTables() as $fromTableName => $toTableName) { $output->writeln(sprintf( 'Possible table renaming detected: "%s" to "%s". It will be deleted and recreated. Use --table-renaming to only rename it.', - $fromTableName, $toTableName + $fromTableName, + $toTableName )); } - $conn = $manager->getAdapterConnection($name); + $conn = $manager->getAdapterConnection($name); /** @var \Propel\Generator\Platform\DefaultPlatform $platform */ $platform = $generatorConfig->getConfiguredPlatform($conn, $name); if ($input->getOption('disable-identifier-quoting')) { $platform->setIdentifierQuoting(false); } - $migrationsUp[$name] = $platform->getModifyDatabaseDDL($databaseDiff); - $migrationsDown[$name] = $platform->getModifyDatabaseDDL($databaseDiff->getReverseDiff()); + $migrationsUp[$name] = $platform->getModifyDatabaseDDL($databaseDiff); + $migrationsDown[$name] = $platform->getModifyDatabaseDDL($databaseDiff->getReverseDiff()); } if (!$migrationsUp) { @@ -217,7 +221,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $timestamp = time(); - $migrationFileName = $manager->getMigrationFileName($timestamp, $input->getOption('suffix')); + $migrationFileName = $manager->getMigrationFileName($timestamp, $input->getOption('suffix')); $migrationClassBody = $manager->getMigrationClassBody($migrationsUp, $migrationsDown, $timestamp, $input->getOption('comment'), $input->getOption('suffix')); $file = $generatorConfig->getSection('paths')['migrationDir'] . DIRECTORY_SEPARATOR . $migrationFileName; @@ -235,5 +239,4 @@ protected function execute(InputInterface $input, OutputInterface $output): int return static::CODE_SUCCESS; } - } diff --git a/src/Propel/Generator/Command/MigrationDownCommand.php b/src/Propel/Generator/Command/MigrationDownCommand.php index 60f7c77f6e..cead365af0 100644 --- a/src/Propel/Generator/Command/MigrationDownCommand.php +++ b/src/Propel/Generator/Command/MigrationDownCommand.php @@ -10,12 +10,13 @@ namespace Propel\Generator\Command; +use Exception; +use Propel\Generator\Manager\MigrationManager; +use Propel\Generator\Util\SqlParser; use Propel\Runtime\Exception\RuntimeException; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Propel\Generator\Manager\MigrationManager; -use Propel\Generator\Util\SqlParser; /** * @author William Durand @@ -23,26 +24,27 @@ class MigrationDownCommand extends AbstractCommand { /** - * @inheritdoc + * @inheritDoc */ protected function configure() { parent::configure(); $this - ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory') - ->addOption('migration-table', null, InputOption::VALUE_REQUIRED, 'Migration table name') - ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use', []) - ->addOption('fake', null, InputOption::VALUE_NONE, 'Does not touch the actual schema, but marks previous migration as executed.') - ->addOption('force', null, InputOption::VALUE_NONE, 'Continues with the migration even when errors occur.') + ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory') + ->addOption('migration-table', null, InputOption::VALUE_REQUIRED, 'Migration table name') + ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use', []) + ->addOption('fake', null, InputOption::VALUE_NONE, 'Does not touch the actual schema, but marks previous migration as executed.') + ->addOption('force', null, InputOption::VALUE_NONE, 'Continues with the migration even when errors occur.') ->setName('migration:down') ->setAliases(['down']) - ->setDescription('Execute migrations down') - ; + ->setDescription('Execute migrations down'); } /** - * @inheritdoc + * @inheritDoc + * + * @throws \Propel\Runtime\Exception\RuntimeException */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -69,7 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $connections = $generatorConfig->getBuildConnections(); } else { foreach ($optionConnections as $connection) { - list($name, $dsn, $infos) = $this->parseConnection($connection); + [$name, $dsn, $infos] = $this->parseConnection($connection); $connections[$name] = array_merge(['dsn' => $dsn], $infos); } } @@ -100,9 +102,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $migration = $manager->getMigrationObject($nextMigrationTimestamp); - if (!$input->getOption('fake')) { - if (false === $migration->preDown($manager)) { + if ($migration->preDown($manager) === false) { if ($input->getOption('force')) { $output->writeln('preDown() returned false. Continue migration.'); } else { @@ -137,7 +138,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $conn->exec($statement); $res++; - } catch (\Exception $e) { + } catch (Exception $e) { if ($input->getOption('force')) { //continue, but print error message $output->writeln( diff --git a/src/Propel/Generator/Command/MigrationMigrateCommand.php b/src/Propel/Generator/Command/MigrationMigrateCommand.php index 7e449efc13..9b5890e012 100644 --- a/src/Propel/Generator/Command/MigrationMigrateCommand.php +++ b/src/Propel/Generator/Command/MigrationMigrateCommand.php @@ -10,12 +10,13 @@ namespace Propel\Generator\Command; +use Exception; +use Propel\Generator\Manager\MigrationManager; +use Propel\Generator\Util\SqlParser; use Propel\Runtime\Exception\RuntimeException; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Propel\Generator\Manager\MigrationManager; -use Propel\Generator\Util\SqlParser; /** * @author William Durand @@ -23,26 +24,27 @@ class MigrationMigrateCommand extends AbstractCommand { /** - * @inheritdoc + * @inheritDoc */ protected function configure() { parent::configure(); $this - ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory') - ->addOption('migration-table', null, InputOption::VALUE_REQUIRED, 'Migration table name') - ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use', []) - ->addOption('fake', null, InputOption::VALUE_NONE, 'Does not touch the actual schema, but marks all migration as executed.') - ->addOption('force', null, InputOption::VALUE_NONE, 'Continues with the migration even when errors occur.') + ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory') + ->addOption('migration-table', null, InputOption::VALUE_REQUIRED, 'Migration table name') + ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use', []) + ->addOption('fake', null, InputOption::VALUE_NONE, 'Does not touch the actual schema, but marks all migration as executed.') + ->addOption('force', null, InputOption::VALUE_NONE, 'Continues with the migration even when errors occur.') ->setName('migration:migrate') ->setAliases(['migrate']) - ->setDescription('Execute all pending migrations') - ; + ->setDescription('Execute all pending migrations'); } /** - * @inheritdoc + * @inheritDoc + * + * @throws \Propel\Runtime\Exception\RuntimeException */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -69,7 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $connections = $generatorConfig->getBuildConnections(); } else { foreach ($optionConnections as $connection) { - list($name, $dsn, $infos) = $this->parseConnection($connection); + [$name, $dsn, $infos] = $this->parseConnection($connection); $connections[$name] = array_merge(['dsn' => $dsn], $infos); } } @@ -90,7 +92,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int } foreach ($timestamps as $timestamp) { - if ($input->getOption('fake')) { $output->writeln( sprintf('Faking migration %s up', $manager->getMigrationClassName($timestamp)) @@ -107,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln(sprintf('%s', $migration->comment)); } - if (false === $migration->preUp($manager)) { + if ($migration->preUp($manager) === false) { if ($input->getOption('force')) { $output->writeln('preUp() returned false. Continue migration.'); } else { @@ -140,7 +141,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $conn->exec($statement); $res++; - } catch (\Exception $e) { + } catch (Exception $e) { if ($input->getOption('force')) { //continue, but print error message $output->writeln( diff --git a/src/Propel/Generator/Command/MigrationStatusCommand.php b/src/Propel/Generator/Command/MigrationStatusCommand.php index dc92570096..4a38cbc5a7 100644 --- a/src/Propel/Generator/Command/MigrationStatusCommand.php +++ b/src/Propel/Generator/Command/MigrationStatusCommand.php @@ -10,10 +10,10 @@ namespace Propel\Generator\Command; -use Symfony\Component\Console\Input\InputOption; +use Propel\Generator\Manager\MigrationManager; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Propel\Generator\Manager\MigrationManager; /** * @author William Durand @@ -21,24 +21,23 @@ class MigrationStatusCommand extends AbstractCommand { /** - * @inheritdoc + * @inheritDoc */ protected function configure() { parent::configure(); $this - ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory') - ->addOption('migration-table', null, InputOption::VALUE_REQUIRED, 'Migration table name') - ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use', []) + ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory') + ->addOption('migration-table', null, InputOption::VALUE_REQUIRED, 'Migration table name') + ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use', []) ->setName('migration:status') ->setAliases(['status']) - ->setDescription('Get migration status') - ; + ->setDescription('Get migration status'); } /** - * @inheritdoc + * @inheritDoc */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -65,7 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $connections = $generatorConfig->getBuildConnections(); } else { foreach ($optionConnections as $connection) { - list($name, $dsn, $infos) = $this->parseConnection($connection); + [$name, $dsn, $infos] = $this->parseConnection($connection); $connections[$name] = array_merge(['dsn' => $dsn], $infos); } } @@ -110,7 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Listing Migration files...'); $dir = $generatorConfig->getSection('paths')['migrationDir']; - $migrationTimestamps = $manager->getMigrationTimestamps(); + $migrationTimestamps = $manager->getMigrationTimestamps(); $nbExistingMigrations = count($migrationTimestamps); if ($migrationTimestamps) { diff --git a/src/Propel/Generator/Command/MigrationUpCommand.php b/src/Propel/Generator/Command/MigrationUpCommand.php index fa8917e2c3..8279bc3838 100644 --- a/src/Propel/Generator/Command/MigrationUpCommand.php +++ b/src/Propel/Generator/Command/MigrationUpCommand.php @@ -10,12 +10,13 @@ namespace Propel\Generator\Command; +use Exception; +use Propel\Generator\Manager\MigrationManager; +use Propel\Generator\Util\SqlParser; use Propel\Runtime\Exception\RuntimeException; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Propel\Generator\Manager\MigrationManager; -use Propel\Generator\Util\SqlParser; /** * @author William Durand @@ -23,26 +24,27 @@ class MigrationUpCommand extends AbstractCommand { /** - * @inheritdoc + * @inheritDoc */ protected function configure() { parent::configure(); $this - ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory') - ->addOption('migration-table', null, InputOption::VALUE_REQUIRED, 'Migration table name') - ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use', []) - ->addOption('fake', null, InputOption::VALUE_NONE, 'Does not touch the actual schema, but marks next migration as executed.') - ->addOption('force', null, InputOption::VALUE_NONE, 'Continues with the migration even when errors occur.') + ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory') + ->addOption('migration-table', null, InputOption::VALUE_REQUIRED, 'Migration table name') + ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use', []) + ->addOption('fake', null, InputOption::VALUE_NONE, 'Does not touch the actual schema, but marks next migration as executed.') + ->addOption('force', null, InputOption::VALUE_NONE, 'Continues with the migration even when errors occur.') ->setName('migration:up') ->setAliases(['up']) - ->setDescription('Execute migrations up') - ; + ->setDescription('Execute migrations up'); } /** - * @inheritdoc + * @inheritDoc + * + * @throws \Propel\Runtime\Exception\RuntimeException */ protected function execute(InputInterface $input, OutputInterface $output) { @@ -69,7 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $connections = $generatorConfig->getBuildConnections(); } else { foreach ($optionConnections as $connection) { - list($name, $dsn, $infos) = $this->parseConnection($connection); + [$name, $dsn, $infos] = $this->parseConnection($connection); $connections[$name] = array_merge(['dsn' => $dsn], $infos); } } @@ -104,11 +106,12 @@ protected function execute(InputInterface $input, OutputInterface $output) $migration = $manager->getMigrationObject($nextMigrationTimestamp); if (!$input->getOption('fake')) { - if (false === $migration->preUp($manager)) { + if ($migration->preUp($manager) === false) { if ($input->getOption('force')) { $output->writeln('preUp() returned false. Continue migration.'); } else { $output->writeln('preUp() returned false. Aborting migration.'); + return static::CODE_ERROR; } } @@ -138,7 +141,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $conn->exec($statement); $res++; - } catch (\Exception $e) { + } catch (Exception $e) { if ($input->getOption('force')) { //continue, but print error message $output->writeln( diff --git a/src/Propel/Generator/Command/ModelBuildCommand.php b/src/Propel/Generator/Command/ModelBuildCommand.php index 19ed359257..68f65ac9cc 100644 --- a/src/Propel/Generator/Command/ModelBuildCommand.php +++ b/src/Propel/Generator/Command/ModelBuildCommand.php @@ -10,10 +10,10 @@ namespace Propel\Generator\Command; -use Symfony\Component\Console\Input\InputOption; +use Propel\Generator\Manager\ModelManager; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Propel\Generator\Manager\ModelManager; /** * @author Florian Klein @@ -22,15 +22,15 @@ class ModelBuildCommand extends AbstractCommand { /** - * @inheritdoc + * @inheritDoc */ protected function configure() { parent::configure(); $this - ->addOption('mysql-engine', null, InputOption::VALUE_REQUIRED, 'MySQL engine (MyISAM, InnoDB, ...)') - ->addOption('schema-dir', null, InputOption::VALUE_REQUIRED, 'The directory where the schema files are placed') + ->addOption('mysql-engine', null, InputOption::VALUE_REQUIRED, 'MySQL engine (MyISAM, InnoDB, ...)') + ->addOption('schema-dir', null, InputOption::VALUE_REQUIRED, 'The directory where the schema files are placed') ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory') ->addOption('object-class', null, InputOption::VALUE_REQUIRED, 'The object class generator name') ->addOption('object-stub-class', null, InputOption::VALUE_REQUIRED, 'The object stub class generator name') @@ -48,12 +48,11 @@ protected function configure() ->addOption('composer-dir', null, InputOption::VALUE_REQUIRED, 'Directory in which your composer.json resides', null) ->setName('model:build') ->setAliases(['build']) - ->setDescription('Build the model classes based on Propel XML schemas') - ; + ->setDescription('Build the model classes based on Propel XML schemas'); } /** - * @inheritdoc + * @inheritDoc */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -61,56 +60,71 @@ protected function execute(InputInterface $input, OutputInterface $output): int $inputOptions = $input->getOptions(); foreach ($inputOptions as $key => $option) { - if (null !== $option) { + if ($option !== null) { switch ($key) { case 'schema-dir': $configOptions['propel']['paths']['schemaDir'] = $option; + break; case 'output-dir': $configOptions['propel']['paths']['phpDir'] = $option; + break; case 'object-class': $configOptions['propel']['generator']['objectModel']['builders']['object'] = $option; + break; case 'object-stub-class': $configOptions['propel']['generator']['objectModel']['builders']['objectstub'] = $option; + break; case 'object-multiextend-class': $configOptions['propel']['generator']['objectModel']['builders']['objectmultiextend'] = $option; + break; case 'query-class': $configOptions['propel']['generator']['objectModel']['builders']['query'] = $option; + break; case 'query-stub-class': $configOptions['propel']['generator']['objectModel']['builders']['querystub'] = $option; + break; case 'query-inheritance-class': $configOptions['propel']['generator']['objectModel']['builders']['queryinheritance'] = $option; + break; case 'query-inheritance-stub-class': $configOptions['propel']['generator']['objectModel']['builders']['queryinheritancestub'] = $option; + break; case 'tablemap-class': $configOptions['propel']['generator']['objectModel']['builders']['tablemap'] = $option; + break; case 'pluralizer-class': $configOptions['propel']['generator']['objectModel']['pluralizerClass'] = $option; + break; case 'composer-dir': $configOptions['propel']['paths']['composerDir'] = $option; + break; case 'disable-package-object-model': if ($option) { $configOptions['propel']['generator']['packageObjectModel'] = false; } + break; case 'disable-namespace-auto-package': if ($option) { $configOptions['propel']['generator']['namespaceAutoPackage'] = false; } + break; case 'mysql-engine': $configOptions['propel']['database']['adapters']['mysql']['tableType'] = $option; + break; } } diff --git a/src/Propel/Generator/Command/SqlBuildCommand.php b/src/Propel/Generator/Command/SqlBuildCommand.php index 325e4a0091..8e3534e34f 100644 --- a/src/Propel/Generator/Command/SqlBuildCommand.php +++ b/src/Propel/Generator/Command/SqlBuildCommand.php @@ -10,10 +10,10 @@ namespace Propel\Generator\Command; -use Symfony\Component\Console\Input\InputOption; +use Propel\Generator\Manager\SqlManager; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Propel\Generator\Manager\SqlManager; /** * @author William Durand @@ -21,56 +21,61 @@ class SqlBuildCommand extends AbstractCommand { /** - * @inheritdoc + * @inheritDoc */ protected function configure() { parent::configure(); $this - ->addOption('mysql-engine', null, InputOption::VALUE_REQUIRED, 'MySQL engine (MyISAM, InnoDB, ...)') - ->addOption('schema-dir', null, InputOption::VALUE_REQUIRED, 'The directory where the schema files are placed') - ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory') - ->addOption('validate', null, InputOption::VALUE_NONE, '') - ->addOption('overwrite', null, InputOption::VALUE_NONE, '') - ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use', []) - ->addOption('schema-name', null, InputOption::VALUE_REQUIRED, 'The schema name for RDBMS supporting them', '') + ->addOption('mysql-engine', null, InputOption::VALUE_REQUIRED, 'MySQL engine (MyISAM, InnoDB, ...)') + ->addOption('schema-dir', null, InputOption::VALUE_REQUIRED, 'The directory where the schema files are placed') + ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory') + ->addOption('validate', null, InputOption::VALUE_NONE, '') + ->addOption('overwrite', null, InputOption::VALUE_NONE, '') + ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use', []) + ->addOption('schema-name', null, InputOption::VALUE_REQUIRED, 'The schema name for RDBMS supporting them', '') //->addOption('encoding', null, InputOption::VALUE_REQUIRED, 'The encoding to use for the database') - ->addOption('table-prefix', null, InputOption::VALUE_REQUIRED, 'Add a prefix to all the table names in the database') + ->addOption('table-prefix', null, InputOption::VALUE_REQUIRED, 'Add a prefix to all the table names in the database') ->addOption('composer-dir', null, InputOption::VALUE_REQUIRED, 'Directory in which your composer.json resides', null) ->setName('sql:build') ->setAliases(['build-sql']) - ->setDescription('Build SQL files') - ; + ->setDescription('Build SQL files'); } /** - * @inheritdoc + * @inheritDoc */ protected function execute(InputInterface $input, OutputInterface $output): int { $configOptions = []; foreach ($input->getOptions() as $key => $option) { - if (null !== $option) { + if ($option !== null) { switch ($key) { case 'schema-dir': $configOptions['propel']['paths']['schemaDir'] = $option; + break; case 'output-dir': $configOptions['propel']['paths']['sqlDir'] = $option; + break; case 'schema-name'; $configOptions['propel']['generator']['schema']['basename'] = $option; + break; case 'table-prefix': $configOptions['propel']['generator']['tablePrefix'] = $option; + break; case 'mysql-engine'; $configOptions['propel']['database']['adapters']['mysql']['tableType'] = $option; + break; case 'composer-dir': $configOptions['propel']['paths']['composerDir'] = $option; + break; } } @@ -88,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $connections = $generatorConfig->getBuildConnections(); } else { foreach ($optionConnections as $connection) { - list($name, $dsn, $infos) = $this->parseConnection($connection); + [$name, $dsn, $infos] = $this->parseConnection($connection); $connections[$name] = array_merge(['dsn' => $dsn], $infos); } } diff --git a/src/Propel/Generator/Command/SqlInsertCommand.php b/src/Propel/Generator/Command/SqlInsertCommand.php index 261ebdab5d..67857f4f33 100644 --- a/src/Propel/Generator/Command/SqlInsertCommand.php +++ b/src/Propel/Generator/Command/SqlInsertCommand.php @@ -10,10 +10,10 @@ namespace Propel\Generator\Command; -use Symfony\Component\Console\Input\InputOption; +use Propel\Generator\Manager\SqlManager; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Propel\Generator\Manager\SqlManager; /** * @author William Durand @@ -21,7 +21,7 @@ class SqlInsertCommand extends AbstractCommand { /** - * @inheritdoc + * @inheritDoc */ protected function configure() { @@ -32,12 +32,11 @@ protected function configure() ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Connection to use. Example: \'bookstore=mysql:host=127.0.0.1;dbname=test;user=root;password=foobar\' where "bookstore" is your propel database name (used in your schema.xml)') ->setName('sql:insert') ->setAliases(['insert-sql']) - ->setDescription('Insert SQL statements') - ; + ->setDescription('Insert SQL statements'); } /** - * @inheritdoc + * @inheritDoc */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -56,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $connections = $generatorConfig->getBuildConnections(); } else { foreach ($optionConnections as $connection) { - list($name, $dsn, $infos) = $this->parseConnection($connection); + [$name, $dsn, $infos] = $this->parseConnection($connection); $connections[$name] = array_merge(['dsn' => $dsn], $infos); } } diff --git a/src/Propel/Generator/Command/TestPrepareCommand.php b/src/Propel/Generator/Command/TestPrepareCommand.php index 30e703b693..468754d0fc 100644 --- a/src/Propel/Generator/Command/TestPrepareCommand.php +++ b/src/Propel/Generator/Command/TestPrepareCommand.php @@ -11,8 +11,8 @@ namespace Propel\Generator\Command; use Symfony\Component\Console\Input\ArrayInput; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; /** @@ -23,41 +23,41 @@ class TestPrepareCommand extends AbstractCommand /** * @var string */ - const FIXTURES_DIR = 'tests/Fixtures'; + public const FIXTURES_DIR = 'tests/Fixtures'; /** * @var string */ - const DEFAULT_VENDOR = 'mysql'; + public const DEFAULT_VENDOR = 'mysql'; /** * @var string */ - const DEFAULT_DSN = 'mysql:host=127.0.0.1;dbname=test'; + public const DEFAULT_DSN = 'mysql:host=127.0.0.1;dbname=test'; /** * @var string */ - const DEFAULT_DB_USER = 'root'; + public const DEFAULT_DB_USER = 'root'; /** * @var string */ - const DEFAULT_DB_PASSWD = ''; + public const DEFAULT_DB_PASSWD = ''; /** * @var array */ protected $fixtures = [ //directory - array of connections - 'bookstore' => ['bookstore', 'bookstore-cms', 'bookstore-behavior'], - 'bookstore-packaged' => ['bookstore-packaged', 'bookstore-log'], - 'namespaced' => ['bookstore_namespaced'], - 'reverse/mysql' => ['reverse-bookstore'], - 'reverse/pgsql' => ['reverse-bookstore'], - 'schemas' => ['bookstore-schemas'], - 'migration' => ['migration'], - 'quoting' => ['quoting'], + 'bookstore' => ['bookstore', 'bookstore-cms', 'bookstore-behavior'], + 'bookstore-packaged' => ['bookstore-packaged', 'bookstore-log'], + 'namespaced' => ['bookstore_namespaced'], + 'reverse/mysql' => ['reverse-bookstore'], + 'reverse/pgsql' => ['reverse-bookstore'], + 'schemas' => ['bookstore-schemas'], + 'migration' => ['migration'], + 'quoting' => ['quoting'], ]; /** @@ -69,29 +69,28 @@ public function __construct() { parent::__construct(); - $this->root = realpath(__DIR__.'/../../../../'); + $this->root = realpath(__DIR__ . '/../../../../'); } /** - * @inheritdoc + * @inheritDoc */ protected function configure() { $this ->setDefinition([ - new InputOption('vendor', null, InputOption::VALUE_REQUIRED, 'The database vendor', self::DEFAULT_VENDOR), - new InputOption('dsn', null, InputOption::VALUE_REQUIRED, 'The data source name', self::DEFAULT_DSN), - new InputOption('user', 'u', InputOption::VALUE_REQUIRED, 'The database user', self::DEFAULT_DB_USER), - new InputOption('password', 'p', InputOption::VALUE_OPTIONAL, 'The database password', self::DEFAULT_DB_PASSWD), - new InputOption('exclude-database', null, InputOption::VALUE_NONE, 'Whether this should not touch database\'s schema'), + new InputOption('vendor', null, InputOption::VALUE_REQUIRED, 'The database vendor', self::DEFAULT_VENDOR), + new InputOption('dsn', null, InputOption::VALUE_REQUIRED, 'The data source name', self::DEFAULT_DSN), + new InputOption('user', 'u', InputOption::VALUE_REQUIRED, 'The database user', self::DEFAULT_DB_USER), + new InputOption('password', 'p', InputOption::VALUE_OPTIONAL, 'The database password', self::DEFAULT_DB_PASSWD), + new InputOption('exclude-database', null, InputOption::VALUE_NONE, 'Whether this should not touch database\'s schema'), ]) ->setName('test:prepare') - ->setDescription('Prepare the Propel test suite by building fixtures') - ; + ->setDescription('Prepare the Propel test suite by building fixtures'); } /** - * @inheritdoc + * @inheritDoc */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -109,8 +108,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** * @param string $fixturesDir * @param string[] $connections - * @param InputInterface $input - * @param OutputInterface $output + * @param \Symfony\Component\Console\Input\InputInterface $input + * @param \Symfony\Component\Console\Output\OutputInterface $output + * * @return int Exit code */ protected function buildFixtures($fixturesDir, $connections, InputInterface $input, OutputInterface $output): int @@ -128,9 +128,9 @@ protected function buildFixtures($fixturesDir, $connections, InputInterface $inp if (is_file('propel.yaml.dist')) { $content = file_get_contents('propel.yaml.dist'); - $content = str_replace('##DATABASE_VENDOR##', $input->getOption('vendor'), $content); - $content = str_replace('##DATABASE_URL##', $input->getOption('dsn'), $content); - $content = str_replace('##DATABASE_USER##', $input->getOption('user'), $content); + $content = str_replace('##DATABASE_VENDOR##', $input->getOption('vendor'), $content); + $content = str_replace('##DATABASE_URL##', $input->getOption('dsn'), $content); + $content = str_replace('##DATABASE_USER##', $input->getOption('user'), $content); $content = str_replace('##DATABASE_PASSWORD##', $input->getOption('password'), $content); file_put_contents('propel.yaml', $content); @@ -140,8 +140,8 @@ protected function buildFixtures($fixturesDir, $connections, InputInterface $inp if (is_file('propel.yaml')) { $in = new ArrayInput([ - 'command' => 'config:convert', - '--output-dir' => './build/conf', + 'command' => 'config:convert', + '--output-dir' => './build/conf', '--output-file' => sprintf('%s-conf.php', $connections[0]), // the first connection is the main one ]); @@ -149,13 +149,13 @@ protected function buildFixtures($fixturesDir, $connections, InputInterface $inp $command->run($in, $output); } - if (0 < count((array) $this->getSchemas('.'))) { + if (0 < count((array)$this->getSchemas('.'))) { $in = new ArrayInput([ - 'command' => 'model:build', - '--schema-dir' => '.', + 'command' => 'model:build', + '--schema-dir' => '.', '--output-dir' => 'build/classes/', - '--platform' => ucfirst($input->getOption('vendor')) . 'Platform', - '--verbose' => $input->getOption('verbose'), + '--platform' => ucfirst($input->getOption('vendor')) . 'Platform', + '--verbose' => $input->getOption('verbose'), ]); $command = $this->getApplication()->find('model:build'); @@ -168,11 +168,11 @@ protected function buildFixtures($fixturesDir, $connections, InputInterface $inp if (0 < count($this->getSchemas('.'))) { $in = new ArrayInput([ - 'command' => 'sql:build', - '--schema-dir' => '.', + 'command' => 'sql:build', + '--schema-dir' => '.', '--output-dir' => 'build/sql/', - '--platform' => ucfirst($input->getOption('vendor')) . 'Platform', - '--verbose' => $input->getOption('verbose'), + '--platform' => ucfirst($input->getOption('vendor')) . 'Platform', + '--verbose' => $input->getOption('verbose'), ]); $command = $this->getApplication()->find('sql:build'); @@ -180,25 +180,28 @@ protected function buildFixtures($fixturesDir, $connections, InputInterface $inp $conParams = []; foreach ($connections as $con) { - if ('sqlite' === substr($input->getOption('dsn'), 0, 6)) { + if (substr($input->getOption('dsn'), 0, 6) === 'sqlite') { $conParams[] = sprintf( '%s=%s', - $con, $input->getOption('dsn') + $con, + $input->getOption('dsn') ); } else { $conParams[] = sprintf( '%s=%s;user=%s;password=%s', - $con, $input->getOption('dsn'), - $input->getOption('user'), $input->getOption('password') + $con, + $input->getOption('dsn'), + $input->getOption('user'), + $input->getOption('password') ); } } $in = new ArrayInput([ - 'command' => 'sql:insert', - '--sql-dir' => 'build/sql/', + 'command' => 'sql:insert', + '--sql-dir' => 'build/sql/', '--connection' => $conParams, - '--verbose' => $input->getOption('verbose'), + '--verbose' => $input->getOption('verbose'), ]); $command = $this->getApplication()->find('sql:insert'); diff --git a/src/Propel/Generator/Config/ArrayToPhpConverter.php b/src/Propel/Generator/Config/ArrayToPhpConverter.php index 1b5049dc31..5d59fe9b0e 100644 --- a/src/Propel/Generator/Config/ArrayToPhpConverter.php +++ b/src/Propel/Generator/Config/ArrayToPhpConverter.php @@ -9,6 +9,7 @@ */ namespace Propel\Generator\Config; + use Propel\Runtime\Propel; /** @@ -49,7 +50,7 @@ public static function convert($c) if (isset($params['slaves'])) { $conf .= " \$manager = new \Propel\Runtime\Connection\ConnectionManagerMasterSlave(); -\$manager->setReadConfiguration(" . var_export($params['slaves'], true). ");"; +\$manager->setReadConfiguration(" . var_export($params['slaves'], true) . ');'; } elseif (isset($params['dsn'])) { $conf .= " \$manager = new \Propel\Runtime\Connection\ConnectionManagerSingle();"; @@ -63,7 +64,7 @@ public static function convert($c) unset($connection['adapter']); unset($connection['slaves']); $conf .= " -\$manager->{$masterConfigurationSetter}(". var_export($connection, true) . ");"; +\$manager->{$masterConfigurationSetter}(" . var_export($connection, true) . ');'; } $conf .= " @@ -95,7 +96,7 @@ public static function convert($c) if ($profilerConf) { $conf .= " -\$serviceContainer->setProfilerConfiguration(" . var_export($profilerConf, true) . ");"; +\$serviceContainer->setProfilerConfiguration(" . var_export($profilerConf, true) . ');'; } unset($c['profiler']); } @@ -104,7 +105,7 @@ public static function convert($c) if (isset($c['log']) && count($c['log']) > 0) { foreach ($c['log'] as $key => $logger) { $conf .= " -\$serviceContainer->setLoggerConfiguration('{$key}', " . var_export($logger, true) . ");"; +\$serviceContainer->setLoggerConfiguration('{$key}', " . var_export($logger, true) . ');'; } unset($c['log']); } diff --git a/src/Propel/Generator/Config/GeneratorConfig.php b/src/Propel/Generator/Config/GeneratorConfig.php index 32360a4a32..773c7178f6 100644 --- a/src/Propel/Generator/Config/GeneratorConfig.php +++ b/src/Propel/Generator/Config/GeneratorConfig.php @@ -11,17 +11,14 @@ namespace Propel\Generator\Config; use Propel\Common\Config\ConfigurationManager; -use Propel\Common\Pluralizer\PluralizerInterface; -use Propel\Generator\Builder\DataModelBuilder; use Propel\Generator\Exception\BuildException; use Propel\Generator\Exception\ClassNotFoundException; use Propel\Generator\Exception\InvalidArgumentException; use Propel\Generator\Model\Table; -use Propel\Generator\Platform\DefaultPlatform; +use Propel\Generator\Util\BehaviorLocator; use Propel\Runtime\Adapter\AdapterFactory; use Propel\Runtime\Connection\ConnectionFactory; use Propel\Runtime\Connection\ConnectionInterface; -use Propel\Generator\Util\BehaviorLocator; /** * A class that holds build properties and provide a class loading mechanism for @@ -33,7 +30,7 @@ class GeneratorConfig extends ConfigurationManager implements GeneratorConfigInterface { /** - * @var BehaviorLocator + * @var \Propel\Generator\Util\BehaviorLocator */ protected $behaviorLocator; @@ -45,13 +42,15 @@ class GeneratorConfig extends ConfigurationManager implements GeneratorConfigInt protected $buildConnections; /** - * @inheritdoc + * @inheritDoc + * + * @throws \Propel\Generator\Exception\ClassNotFoundException */ - public function getConfiguredPlatform(ConnectionInterface $con = null, $database = null) + public function getConfiguredPlatform(?ConnectionInterface $con = null, $database = null) { $platform = $this->get()['generator']['platformClass']; - if (null === $platform) { + if ($platform === null) { if ($database) { $platform = $this->getBuildConnection($database)['adapter']; } @@ -73,15 +72,16 @@ public function getConfiguredPlatform(ConnectionInterface $con = null, $database foreach ($classes as $class) { if (class_exists($class)) { $platformClass = $class; + break; } } - if (null === $platformClass) { + if ($platformClass === null) { throw new ClassNotFoundException(sprintf('Platform class for `%s` not found.', $platform)); } - /** @var DefaultPlatform $platform */ + /** @var \Propel\Generator\Platform\DefaultPlatform $platform */ $platform = $this->getInstance($platformClass); $platform->setConnection($con); $platform->setGeneratorConfig($this); @@ -90,13 +90,15 @@ public function getConfiguredPlatform(ConnectionInterface $con = null, $database } /** - * @inheritdoc + * @inheritDoc + * + * @throws \Propel\Generator\Exception\ClassNotFoundException */ - public function getConfiguredSchemaParser(ConnectionInterface $con = null, $database = null) + public function getConfiguredSchemaParser(?ConnectionInterface $con = null, $database = null) { $reverse = $this->get()['migrations']['parserClass']; - if (null === $reverse) { + if ($reverse === null) { if ($database) { $reverse = $this->getBuildConnection($database)['adapter']; } else { @@ -123,11 +125,12 @@ public function getConfiguredSchemaParser(ConnectionInterface $con = null, $data foreach ($classes as $class) { if (class_exists($class)) { $reverseClass = $class; + break; } } - if (null === $reverseClass) { + if ($reverseClass === null) { throw new ClassNotFoundException(sprintf('Reverse SchemaParser class for `%s` not found.', $reverse)); } @@ -144,11 +147,10 @@ public function getConfiguredSchemaParser(ConnectionInterface $con = null, $data * Returns a configured data model builder class for specified table and * based on type ('object', 'query', 'tableMap' etc.). * - * @param Table $table - * @param string $type - * @return DataModelBuilder + * @param \Propel\Generator\Model\Table $table + * @param string $type * - * @throws \Propel\Generator\Exception\ClassNotFoundException if the type of builder is wrong and the builder class doesn't exists + * @return \Propel\Generator\Builder\DataModelBuilder */ public function getConfiguredBuilder(Table $table, $type) { @@ -163,7 +165,7 @@ public function getConfiguredBuilder(Table $table, $type) /** * Returns a configured Pluralizer class. * - * @return PluralizerInterface + * @return \Propel\Common\Pluralizer\PluralizerInterface */ public function getConfiguredPluralizer() { @@ -180,11 +182,11 @@ public function getConfiguredPluralizer() */ public function getBuildConnections() { - if (null === $this->buildConnections) { + if ($this->buildConnections === null) { $connectionNames = $this->get()['generator']['connections']; $reverseConnection = $this->getConfigProperty('reverse.connection'); - if (null !== $reverseConnection && !in_array($reverseConnection, $connectionNames)) { + if ($reverseConnection !== null && !in_array($reverseConnection, $connectionNames)) { $connectionNames[] = $reverseConnection; } @@ -202,14 +204,15 @@ public function getBuildConnections() * Return the connection properties array, of a given database name. * If the database name is null, it returns the default connection properties * - * @param string $databaseName - * @return array + * @param string|null $databaseName * * @throws \Propel\Generator\Exception\InvalidArgumentException if wrong database name + * + * @return array */ public function getBuildConnection($databaseName = null) { - if (null === $databaseName) { + if ($databaseName === null) { $databaseName = $this->get()['generator']['defaultConnection']; } @@ -223,8 +226,9 @@ public function getBuildConnection($databaseName = null) /** * Return a connection object of a given database name * - * @param string|null $database - * @return ConnectionInterface + * @param string|null $database + * + * @return \Propel\Runtime\Connection\ConnectionInterface */ public function getConnection($database = null) { @@ -262,11 +266,12 @@ public function getBehaviorLocator() * Return an instance of $className * * @param string $className The name of the class to return an instance - * @param string $interfaceName The name of the interface to be implemented by the returned class + * @param mixed|null $arguments + * @param string|null $interfaceName The name of the interface to be implemented by the returned class * - * @throws \Propel\Generator\Exception\ClassNotFoundException if the class doesn't exists + * @throws \Propel\Generator\Exception\ClassNotFoundException if the class doesn't exists * @throws \Propel\Generator\Exception\InvalidArgumentException if the interface doesn't exists - * @throws \Propel\Generator\Exception\BuildException if the class isn't an implementation of the given interface + * @throws \Propel\Generator\Exception\BuildException if the class isn't an implementation of the given interface */ private function getInstance($className, $arguments = null, $interfaceName = null) { @@ -276,7 +281,7 @@ private function getInstance($className, $arguments = null, $interfaceName = nul $object = new $className($arguments); - if (null !== $interfaceName) { + if ($interfaceName !== null) { if (!interface_exists($interfaceName)) { throw new InvalidArgumentException("Interface $interfaceName does not exists."); } diff --git a/src/Propel/Generator/Config/GeneratorConfigInterface.php b/src/Propel/Generator/Config/GeneratorConfigInterface.php index 17860f36b6..b1c76dc616 100644 --- a/src/Propel/Generator/Config/GeneratorConfigInterface.php +++ b/src/Propel/Generator/Config/GeneratorConfigInterface.php @@ -10,13 +10,8 @@ namespace Propel\Generator\Config; -use Propel\Common\Pluralizer\PluralizerInterface; -use Propel\Generator\Builder\DataModelBuilder; use Propel\Generator\Model\Table; -use Propel\Generator\Platform\PlatformInterface; -use Propel\Generator\Reverse\SchemaParserInterface; use Propel\Runtime\Connection\ConnectionInterface; -use Propel\Generator\Util\BehaviorLocator; interface GeneratorConfigInterface { @@ -24,8 +19,9 @@ interface GeneratorConfigInterface * Returns a configured data model builder class for specified table and * based on type ('ddl', 'sql', etc.). * - * @param Table $table - * @param string $type + * @param \Propel\Generator\Model\Table $table + * @param string $type + * * @return \Propel\Generator\Builder\Om\AbstractOMBuilder */ public function getConfiguredBuilder(Table $table, $type); @@ -33,40 +29,40 @@ public function getConfiguredBuilder(Table $table, $type); /** * Returns a configured Pluralizer class. * - * @return PluralizerInterface + * @return \Propel\Common\Pluralizer\PluralizerInterface */ public function getConfiguredPluralizer(); - /** * Creates and configures a new Platform class. * - * @param ConnectionInterface|null $con - * @param string|null $database - * @return PlatformInterface|null + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con + * @param string|null $database * * @throws \Propel\Generator\Exception\ClassNotFoundException if the platform class doesn't exists - * @throws \Propel\Generator\Exception\BuildException if the class isn't an implementation of PlatformInterface + * @throws \Propel\Generator\Exception\BuildException if the class isn't an implementation of PlatformInterface + * + * @return \Propel\Generator\Platform\PlatformInterface|null */ - public function getConfiguredPlatform(ConnectionInterface $con = null, $database = null); + public function getConfiguredPlatform(?ConnectionInterface $con = null, $database = null); /** * Creates and configures a new SchemaParser class for a specified platform. * - * @param ConnectionInterface|null $con - * @param string|null $database - * - * @return SchemaParserInterface|null + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con + * @param string|null $database * * @throws \Propel\Generator\Exception\ClassNotFoundException if the class doesn't exist - * @throws \Propel\Generator\Exception\BuildException if the class isn't an implementation of SchemaParserInterface + * @throws \Propel\Generator\Exception\BuildException if the class isn't an implementation of SchemaParserInterface + * + * @return \Propel\Generator\Reverse\SchemaParserInterface|null */ - public function getConfiguredSchemaParser(ConnectionInterface $con = null, $database = null); + public function getConfiguredSchemaParser(?ConnectionInterface $con = null, $database = null); /** * Returns the behavior locator. * - * @return BehaviorLocator + * @return \Propel\Generator\Util\BehaviorLocator */ public function getBehaviorLocator(); @@ -79,7 +75,9 @@ public function getBehaviorLocator(); * 'database.adapter.mysql.tableType * * @param string $name The name of property, expressed as a dot separated level hierarchy + * * @throws \Propel\Common\Config\Exception\InvalidArgumentException + * * @return mixed The configuration property */ public function getConfigProperty($name); diff --git a/src/Propel/Generator/Config/QuickGeneratorConfig.php b/src/Propel/Generator/Config/QuickGeneratorConfig.php index 0d27306a21..3f2c072a20 100644 --- a/src/Propel/Generator/Config/QuickGeneratorConfig.php +++ b/src/Propel/Generator/Config/QuickGeneratorConfig.php @@ -11,27 +11,25 @@ namespace Propel\Generator\Config; use Propel\Common\Config\ConfigurationManager; -use Propel\Common\Pluralizer\PluralizerInterface; use Propel\Common\Pluralizer\StandardEnglishPluralizer; -use Propel\Generator\Builder\DataModelBuilder; use Propel\Generator\Exception\InvalidArgumentException; use Propel\Generator\Model\Table; -use \Propel\Runtime\Connection\ConnectionInterface; use Propel\Generator\Util\BehaviorLocator; +use Propel\Runtime\Connection\ConnectionInterface; class QuickGeneratorConfig extends ConfigurationManager implements GeneratorConfigInterface { /** - * @var BehaviorLocator|null + * @var \Propel\Generator\Util\BehaviorLocator|null */ - protected $behaviorLocator = null; + protected $behaviorLocator; /** * @param array|null $extraConf */ public function __construct($extraConf = []) { - if (null === $extraConf) { + if ($extraConf === null) { $extraConf = []; } @@ -45,19 +43,19 @@ public function __construct($extraConf = []) 'classname' => 'Propel\Runtime\Connection\DebugPDO', 'dsn' => 'sqlite::memory:', 'user' => '', - 'password' => '' - ] - ] + 'password' => '', + ], + ], ], 'runtime' => [ 'defaultConnection' => 'default', - 'connections' => ['default'] + 'connections' => ['default'], ], 'generator' => [ 'defaultConnection' => 'default', - 'connections' => ['default'] - ] - ] + 'connections' => ['default'], + ], + ], ]; $configs = array_replace_recursive($configs, $extraConf); @@ -68,15 +66,18 @@ public function __construct($extraConf = []) * Gets a configured data model builder class for specified table and based * on type ('ddl', 'sql', etc.). * - * @param Table $table - * @param string $type - * @return DataModelBuilder + * @param \Propel\Generator\Model\Table $table + * @param string $type + * + * @throws \Propel\Generator\Exception\InvalidArgumentException + * + * @return \Propel\Generator\Builder\DataModelBuilder */ public function getConfiguredBuilder(Table $table, $type) { $class = $this->getConfigProperty('generator.objectModel.builders.' . $type); - if (null === $class) { + if ($class === null) { throw new InvalidArgumentException("Invalid data model builder type `$type`"); } @@ -89,7 +90,7 @@ public function getConfiguredBuilder(Table $table, $type) /** * Returns a configured Pluralizer class. * - * @return PluralizerInterface + * @return \Propel\Common\Pluralizer\PluralizerInterface */ public function getConfiguredPluralizer() { @@ -97,17 +98,17 @@ public function getConfiguredPluralizer() } /** - * @inheritdoc + * @inheritDoc */ - public function getConfiguredPlatform(ConnectionInterface $con = null, $database = null) + public function getConfiguredPlatform(?ConnectionInterface $con = null, $database = null) { return null; } /** - * @inheritdoc + * @inheritDoc */ - public function getConfiguredSchemaParser(ConnectionInterface $con = null, $database = null) + public function getConfiguredSchemaParser(?ConnectionInterface $con = null, $database = null) { return null; } diff --git a/src/Propel/Generator/Exception/ConstraintNotFoundException.php b/src/Propel/Generator/Exception/ConstraintNotFoundException.php index ccfb0a8553..f1e99b52b6 100644 --- a/src/Propel/Generator/Exception/ConstraintNotFoundException.php +++ b/src/Propel/Generator/Exception/ConstraintNotFoundException.php @@ -1,4 +1,5 @@ workingDirectory; } - /** * Returns the data models that have been * processed. * - * @return Schema[] + * @return \Propel\Generator\Model\Schema[] */ public function getDataModels() { @@ -177,11 +187,11 @@ public function getDataModelDbMap() } /** - * @return Database[] + * @return \Propel\Generator\Model\Database[] */ public function getDatabases() { - if (null === $this->databases) { + if ($this->databases === null) { $databases = []; foreach ($this->getDataModels() as $dataModel) { foreach ($dataModel->getDatabases() as $database) { @@ -205,24 +215,27 @@ public function getDatabases() } /** - * @param string $name - * @return Database|null + * @param string $name + * + * @return \Propel\Generator\Model\Database|null */ public function getDatabase($name) { $dbs = $this->getDatabases(); + return @$dbs[$name]; } /** * Sets whether to perform validation on the datamodel schema.xml file(s). * - * @param boolean $validate + * @param bool $validate + * * @return void */ public function setValidate($validate) { - $this->validate = (boolean) $validate; + $this->validate = (bool)$validate; } /** @@ -230,6 +243,7 @@ public function setValidate($validate) * file(s). * * @param string $xsd + * * @return void */ public function setXsd($xsd) @@ -242,6 +256,7 @@ public function setXsd($xsd) * file(s) before validation and parsing. * * @param mixed $xsl + * * @return void */ public function setXsl($xsl) @@ -253,6 +268,7 @@ public function setXsl($xsl) * Sets the current target database encoding. * * @param string $encoding Target database encoding + * * @return void */ public function setDbEncoding($encoding) @@ -264,9 +280,10 @@ public function setDbEncoding($encoding) * Sets a logger closure. * * @param \Closure $logger + * * @return void */ - public function setLoggerClosure(\Closure $logger) + public function setLoggerClosure(Closure $logger) { $this->loggerClosure = $logger; } @@ -274,13 +291,17 @@ public function setLoggerClosure(\Closure $logger) /** * Returns all matching XML schema files and loads them into data models for * class. + * + * @throws \Propel\Generator\Exception\EngineException + * @throws \Propel\Generator\Exception\BuildException + * * @return void */ protected function loadDataModels() { $schemas = []; - $totalNbTables = 0; - $dataModelFiles = $this->getSchemas(); + $totalNbTables = 0; + $dataModelFiles = $this->getSchemas(); $defaultPlatform = $this->getGeneratorConfig()->getConfiguredPlatform(); // Make a transaction for each file @@ -288,7 +309,7 @@ protected function loadDataModels() $dmFilename = $schema->getPathName(); $this->log('Processing: ' . $schema->getFileName()); - $dom = new \DOMDocument('1.0', 'UTF-8'); + $dom = new DOMDocument('1.0', 'UTF-8'); $dom->load($dmFilename); $this->includeExternalSchemas($dom, $schema->getPath()); @@ -301,9 +322,9 @@ protected function loadDataModels() $this->log('Could not perform XLST transformation. Make sure PHP has been compiled/configured to support XSLT.'); } else { // normalize the document using normalizer stylesheet - $xslDom = new \DOMDocument('1.0', 'UTF-8'); + $xslDom = new DOMDocument('1.0', 'UTF-8'); $xslDom->load($this->xsl->getAbsolutePath()); - $xsl = new \XsltProcessor(); + $xsl = new XsltProcessor(); $xsl->importStyleSheet($xslDom); $dom = $xsl->transformToDoc($dom); } @@ -363,10 +384,13 @@ protected function loadDataModels() * users don't have those and adding some more informative exceptions would be better * * @param \DOMDocument $dom - * @param string $srcDir + * @param string $srcDir + * + * @throws \Propel\Generator\Exception\BuildException + * * @return int */ - protected function includeExternalSchemas(\DOMDocument $dom, $srcDir) + protected function includeExternalSchemas(DOMDocument $dom, $srcDir) { $databaseNode = $dom->getElementsByTagName('database')->item(0); $externalSchemaNodes = $dom->getElementsByTagName('external-schema'); @@ -383,14 +407,14 @@ protected function includeExternalSchemas(\DOMDocument $dom, $srcDir) throw new BuildException("External schema '$include' does not exist"); } - $externalSchemaDom = new \DOMDocument('1.0', 'UTF-8'); + $externalSchemaDom = new DOMDocument('1.0', 'UTF-8'); $externalSchemaDom->load(realpath($include)); // The external schema may have external schemas of its own ; recurs $this->includeExternalSchemas($externalSchemaDom, $srcDir); foreach ($externalSchemaDom->getElementsByTagName('table') as $tableNode) { - if ("true" === $referenceOnly) { - $tableNode->setAttribute("skipSql", "true"); + if ($referenceOnly === 'true') { + $tableNode->setAttribute('skipSql', 'true'); } $databaseNode->appendChild($dom->importNode($tableNode, true)); } @@ -406,8 +430,9 @@ protected function includeExternalSchemas(\DOMDocument $dom, $srcDir) * We need to join the datamodels in this case to allow for foreign keys * that point to tables in different packages. * - * @param array $schemas - * @return Schema + * @param array $schemas + * + * @return \Propel\Generator\Model\Schema */ protected function joinDataModels(array $schemas) { @@ -421,7 +446,7 @@ protected function joinDataModels(array $schemas) * Returns the GeneratorConfig object for this manager or creates it * on-demand. * - * @return GeneratorConfigInterface + * @return \Propel\Generator\Config\GeneratorConfigInterface */ protected function getGeneratorConfig() { @@ -431,7 +456,8 @@ protected function getGeneratorConfig() /** * Sets the GeneratorConfigInterface implementation. * - * @param GeneratorConfigInterface $generatorConfig + * @param \Propel\Generator\Config\GeneratorConfigInterface $generatorConfig + * * @return void */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) @@ -441,6 +467,7 @@ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) /** * @throws \Propel\Generator\Exception\BuildException + * * @return void */ protected function validate() @@ -459,7 +486,7 @@ protected function validate() */ protected function log($message) { - if (null !== $this->loggerClosure) { + if ($this->loggerClosure !== null) { $closure = $this->loggerClosure; $closure($message); } @@ -468,7 +495,10 @@ protected function log($message) /** * Returns an array of properties as key/value pairs from an input file. * - * @param string $file + * @param string $file + * + * @throws \Exception + * * @return string[] */ protected function getProperties($file) @@ -476,7 +506,7 @@ protected function getProperties($file) $properties = []; if (false === $lines = @file($file)) { - throw new \Exception(sprintf('Unable to parse contents of "%s".', $file)); + throw new Exception(sprintf('Unable to parse contents of "%s".', $file)); } foreach ($lines as $line) { diff --git a/src/Propel/Generator/Manager/GraphvizManager.php b/src/Propel/Generator/Manager/GraphvizManager.php index 1105851b3b..635eb2eb08 100644 --- a/src/Propel/Generator/Manager/GraphvizManager.php +++ b/src/Propel/Generator/Manager/GraphvizManager.php @@ -27,15 +27,15 @@ public function build() foreach ($this->getDatabases() as $database) { $dotSyntax = "digraph G {\n"; - $this->log("db: " . $database->getName()); + $this->log('db: ' . $database->getName()); // print the tables foreach ($database->getTables() as $tbl) { $this->log("\t+ " . $tbl->getName()); - $dotSyntax .= 'node'.$tbl->getName().' [label="{
'.$tbl->getName().'|'; + $dotSyntax .= 'node' . $tbl->getName() . ' [label="{
' . $tbl->getName() . '|'; foreach ($tbl->getColumns() as $col) { - $dotSyntax .= $col->getName() . ' (' . $col->getType() . ')'; + $dotSyntax .= $col->getName() . ' (' . $col->getType() . ')'; if (count($col->getForeignKeys()) > 0) { $dotSyntax .= ' [FK]'; } elseif ($col->isPrimaryKey()) { @@ -51,12 +51,12 @@ public function build() $dotSyntax .= "\n"; foreach ($database->getTables() as $tbl) { foreach ($tbl->getForeignKeys() as $fk) { - $dotSyntax .= 'node'.$tbl->getName(); - $dotSyntax .= ':cols -> node'.$fk->getForeignTableName(); + $dotSyntax .= 'node' . $tbl->getName(); + $dotSyntax .= ':cols -> node' . $fk->getForeignTableName(); $label = []; foreach ($fk->getMapping() as $map) { [$localColumn, $foreignValueOrColumn] = $map; - $labelString = $localColumn->getName().'='; + $labelString = $localColumn->getName() . '='; if ($foreignValueOrColumn instanceof Column) { $labelString .= $foreignValueOrColumn->getName(); } else { @@ -86,7 +86,7 @@ protected function writeDot($dotSyntax, $baseFilename) { $file = $this->getWorkingDirectory() . DIRECTORY_SEPARATOR . $baseFilename . '.schema.dot'; - $this->log("Writing dot file to " . $file); + $this->log('Writing dot file to ' . $file); file_put_contents($file, $dotSyntax); } diff --git a/src/Propel/Generator/Manager/MigrationManager.php b/src/Propel/Generator/Manager/MigrationManager.php index 0b485c1f1a..745e861d7b 100644 --- a/src/Propel/Generator/Manager/MigrationManager.php +++ b/src/Propel/Generator/Manager/MigrationManager.php @@ -10,15 +10,16 @@ namespace Propel\Generator\Manager; +use Exception; +use PDO; +use PDOException; use Propel\Generator\Exception\InvalidArgumentException; use Propel\Generator\Model\Column; use Propel\Generator\Model\Database; use Propel\Generator\Model\Table; -use Propel\Generator\Platform\PlatformInterface; use Propel\Generator\Util\SqlParser; use Propel\Runtime\Adapter\AdapterFactory; use Propel\Runtime\Connection\ConnectionFactory; -use Propel\Runtime\Connection\ConnectionInterface; /** * Service class for preparing and executing migrations @@ -33,7 +34,7 @@ class MigrationManager extends AbstractManager protected $connections = []; /** - * @var ConnectionInterface[] + * @var \Propel\Runtime\Connection\ConnectionInterface[] */ protected $adapterConnections = []; @@ -46,6 +47,7 @@ class MigrationManager extends AbstractManager * Set the database connection settings * * @param array $connections + * * @return void */ public function setConnections($connections) @@ -81,7 +83,8 @@ public function getConnection($datasource) /** * @param string $datasource - * @return ConnectionInterface + * + * @return \Propel\Runtime\Connection\ConnectionInterface */ public function getAdapterConnection($datasource) { @@ -95,12 +98,13 @@ public function getAdapterConnection($datasource) } /** - * @param string $datasource - * @return PlatformInterface + * @param string $datasource + * + * @return \Propel\Generator\Platform\PlatformInterface */ public function getPlatform($datasource) { - $params = $this->getConnection($datasource); + $params = $this->getConnection($datasource); $adapter = $params['adapter']; $class = '\\Propel\\Generator\\Platform\\' . ucfirst($adapter) . 'Platform'; @@ -112,6 +116,7 @@ public function getPlatform($datasource) * Set the migration table name * * @param string $migrationTable + * * @return void */ public function setMigrationTable($migrationTable) @@ -131,13 +136,14 @@ public function getMigrationTable() /** * @throws \Exception + * * @return int[] */ public function getAllDatabaseVersions() { $connections = $this->getConnections(); if (!$connections) { - throw new \Exception('You must define database connection settings in a buildtime-conf.xml file to use migrations'); + throw new Exception('You must define database connection settings in a buildtime-conf.xml file to use migrations'); } $migrationTimestamps = []; @@ -157,7 +163,7 @@ public function getAllDatabaseVersions() while ($migrationTimestamp = $stmt->fetchColumn()) { $migrationTimestamps[] = $migrationTimestamp; } - } catch (\PDOException $e) { + } catch (PDOException $e) { $this->createMigrationTable($name); $migrationTimestamps = []; } @@ -182,7 +188,7 @@ public function migrationTableExists($datasource) $stmt->execute(); return true; - } catch (\PDOException $e) { + } catch (PDOException $e) { return false; } } @@ -216,7 +222,7 @@ public function createMigrationTable($datasource) $res = SqlParser::executeString($statements, $conn); if (!$res) { - throw new \Exception(sprintf('Unable to create migration table in datasource "%s"', $datasource)); + throw new Exception(sprintf('Unable to create migration table in datasource "%s"', $datasource)); } } @@ -231,12 +237,13 @@ public function removeMigrationTimestamp($datasource, $timestamp) $platform = $this->getPlatform($datasource); $conn = $this->getAdapterConnection($datasource); $conn->transaction(function () use ($conn, $platform, $timestamp) { - $sql = sprintf('DELETE FROM %s WHERE %s = ?', + $sql = sprintf( + 'DELETE FROM %s WHERE %s = ?', $this->getMigrationTable(), $platform->doQuoting('version') ); $stmt = $conn->prepare($sql); - $stmt->bindParam(1, $timestamp, \PDO::PARAM_INT); + $stmt->bindParam(1, $timestamp, PDO::PARAM_INT); $stmt->execute(); }); } @@ -251,12 +258,13 @@ public function updateLatestMigrationTimestamp($datasource, $timestamp) { $platform = $this->getPlatform($datasource); $conn = $this->getAdapterConnection($datasource); - $sql = sprintf('INSERT INTO %s (%s) VALUES (?)', + $sql = sprintf( + 'INSERT INTO %s (%s) VALUES (?)', $this->getMigrationTable(), $platform->doQuoting('version') ); $stmt = $conn->prepare($sql); - $stmt->bindParam(1, $timestamp, \PDO::PARAM_INT); + $stmt->bindParam(1, $timestamp, PDO::PARAM_INT); $stmt->execute(); } @@ -272,7 +280,7 @@ public function getMigrationTimestamps() $files = scandir($path); foreach ($files as $file) { if (preg_match('/^PropelMigration_(\d+).*\.php$/', $file, $matches)) { - $migrationTimestamps[] = (integer) $matches[1]; + $migrationTimestamps[] = (int)$matches[1]; } } } @@ -296,7 +304,7 @@ public function getValidMigrationTimestamps() */ public function hasPendingMigrations() { - return [] !== $this->getValidMigrationTimestamps(); + return $this->getValidMigrationTimestamps() !== []; } /** @@ -334,15 +342,16 @@ public function getFirstDownMigrationTimestamp() * * @return string */ - public function getMigrationClassName($timestamp, $suffix = "") + public function getMigrationClassName($timestamp, $suffix = '') { $className = sprintf('PropelMigration_%d', $timestamp); - if ($suffix === "") { + if ($suffix === '') { $suffix = $this->findMigrationClassNameSuffix($timestamp); } - if ($suffix !== "") { + if ($suffix !== '') { $className .= '_' . $suffix; } + return $className; } @@ -351,17 +360,19 @@ public function getMigrationClassName($timestamp, $suffix = "") * * @return string */ - public function findMigrationClassNameSuffix($timestamp) { - $suffix = ""; + public function findMigrationClassNameSuffix($timestamp) + { + $suffix = ''; $path = $this->getWorkingDirectory(); if (is_dir($path)) { $files = scandir($path); foreach ($files as $file) { - if (preg_match('/^PropelMigration_'.$timestamp.'(_)?(.*)\.php$/', $file, $matches)) { - $suffix = (string) $matches[2]; + if (preg_match('/^PropelMigration_' . $timestamp . '(_)?(.*)\.php$/', $file, $matches)) { + $suffix = (string)$matches[2]; } } } + return $suffix; } @@ -373,7 +384,8 @@ public function findMigrationClassNameSuffix($timestamp) { public function getMigrationObject($timestamp) { $className = $this->getMigrationClassName($timestamp); - require_once sprintf('%s/%s.php', + require_once sprintf( + '%s/%s.php', $this->getWorkingDirectory(), $className ); @@ -390,7 +402,7 @@ public function getMigrationObject($timestamp) * * @return string */ - public function getMigrationClassBody($migrationsUp, $migrationsDown, $timestamp, $comment = "", $suffix = "") + public function getMigrationClassBody($migrationsUp, $migrationsDown, $timestamp, $comment = '', $suffix = '') { $timeInWords = date('Y-m-d H:i:s', $timestamp); $migrationAuthor = ($author = $this->getUser()) ? 'by ' . $author : ''; @@ -466,7 +478,7 @@ public function getDownSQL() * * @return string */ - public function getMigrationFileName($timestamp, $suffix = "") + public function getMigrationFileName($timestamp, $suffix = '') { return sprintf('%s.php', $this->getMigrationClassName($timestamp, $suffix)); } diff --git a/src/Propel/Generator/Manager/ModelManager.php b/src/Propel/Generator/Manager/ModelManager.php index 7b4fba3263..49644ccfff 100644 --- a/src/Propel/Generator/Manager/ModelManager.php +++ b/src/Propel/Generator/Manager/ModelManager.php @@ -10,8 +10,9 @@ namespace Propel\Generator\Manager; -use Symfony\Component\Filesystem\Filesystem; use Propel\Generator\Builder\Om\AbstractOMBuilder; +use SplFileInfo; +use Symfony\Component\Filesystem\Filesystem; /** * This manager creates the Object Model classes based on the XML schema file. @@ -23,14 +24,15 @@ class ModelManager extends AbstractManager /** * A Filesystem object. * - * @var Filesystem + * @var \Symfony\Component\Filesystem\Filesystem */ private $filesystem; /** * Sets the filesystem object. * - * @param Filesystem $filesystem + * @param \Symfony\Component\Filesystem\Filesystem $filesystem + * * @return void */ public function setFilesystem(Filesystem $filesystem) @@ -45,8 +47,8 @@ public function build() { $this->validate(); - $totalNbFiles = 0; - $dataModels = $this->getDataModels(); + $totalNbFiles = 0; + $dataModels = $this->getDataModels(); $generatorConfig = $this->getGeneratorConfig(); $this->log('Generating PHP files...'); @@ -136,7 +138,7 @@ public function build() } $totalNbFiles += $nbWrittenFiles; - if (0 === $nbWrittenFiles) { + if ($nbWrittenFiles === 0) { $this->log("\t\t(no change)"); } } @@ -156,14 +158,15 @@ public function build() * This method assumes that the DataModelBuilder class has been initialized * with the build properties. * - * @param AbstractOMBuilder $builder - * @param boolean $overwrite + * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $builder + * @param bool $overwrite + * * @return int */ protected function doBuild(AbstractOMBuilder $builder, $overwrite = true) { $path = $builder->getClassFilePath(); - $file = new \SplFileInfo($this->getWorkingDirectory() . DIRECTORY_SEPARATOR . $path); + $file = new SplFileInfo($this->getWorkingDirectory() . DIRECTORY_SEPARATOR . $path); $this->filesystem->mkdir($file->getPath()); diff --git a/src/Propel/Generator/Manager/ReverseManager.php b/src/Propel/Generator/Manager/ReverseManager.php index 0c9537bf17..897b7d32df 100644 --- a/src/Propel/Generator/Manager/ReverseManager.php +++ b/src/Propel/Generator/Manager/ReverseManager.php @@ -10,11 +10,11 @@ namespace Propel\Generator\Manager; +use Exception; use Propel\Generator\Exception\BuildException; -use Propel\Generator\Model\IdMethod; use Propel\Generator\Model\Database; +use Propel\Generator\Model\IdMethod; use Propel\Generator\Schema\Dumper\DumperInterface; -use Propel\Runtime\Connection\ConnectionInterface; /** * @author William Durand @@ -41,7 +41,7 @@ class ReverseManager extends AbstractManager /** * Whether to use same name for phpName or not. * - * @var boolean + * @var bool */ protected $samePhpName; @@ -53,21 +53,21 @@ class ReverseManager extends AbstractManager /** * Whether to add vendor info or not. * - * @var boolean + * @var bool */ protected $addVendorInfo; /** * The schema dumper. * - * @var DumperInterface + * @var \Propel\Generator\Schema\Dumper\DumperInterface */ private $schemaDumper; /** * Constructor. * - * @param DumperInterface $schemaDumper + * @param \Propel\Generator\Schema\Dumper\DumperInterface $schemaDumper */ public function __construct(DumperInterface $schemaDumper) { @@ -88,6 +88,7 @@ public function getSchemaName() * Sets the name of a database schema to use (optional). * * @param string $schemaName + * * @return void */ public function setSchemaName($schemaName) @@ -109,6 +110,7 @@ public function getNamespace() * Sets the php namespace to use (optional). * * @param string $namespace + * * @return void */ public function setNamespace($namespace) @@ -132,6 +134,7 @@ public function getDatabaseName() * schema.xml * * @param string $databaseName + * * @return void */ public function setDatabaseName($databaseName) @@ -142,30 +145,32 @@ public function setDatabaseName($databaseName) /** * Sets whether to use the column name as phpName without any translation. * - * @param boolean $samePhpName + * @param bool $samePhpName + * * @return void */ public function setSamePhpName($samePhpName) { - $this->samePhpName = (boolean) $samePhpName; + $this->samePhpName = (bool)$samePhpName; } /** * Sets whether to add vendor info to the schema. * - * @param boolean $addVendorInfo + * @param bool $addVendorInfo + * * @return void */ public function setAddVendorInfo($addVendorInfo) { - $this->addVendorInfo = (bool) $addVendorInfo; + $this->addVendorInfo = (bool)$addVendorInfo; } /** * Returns whether to use the column name as phpName without any * translation. * - * @return boolean + * @return bool */ public function isSamePhpName() { @@ -174,6 +179,7 @@ public function isSamePhpName() /** * @throws \Propel\Generator\Exception\BuildException + * * @return bool */ public function reverse() @@ -184,14 +190,15 @@ public function reverse() try { $database = $this->buildModel(); - $schema = $this->schemaDumper->dump($database); + $schema = $this->schemaDumper->dump($database); $file = $this->getWorkingDirectory() . DIRECTORY_SEPARATOR . $this->getSchemaName() . '.xml'; $this->log('Writing XML file to ' . $file); file_put_contents($file, $schema); - } catch (\Exception $e) { + } catch (Exception $e) { $this->log(sprintf('There was an error building XML from metadata: %s', $e->getMessage())); + throw $e; } @@ -201,16 +208,15 @@ public function reverse() /** * Builds the model classes from the database schema. * - * @return Database The built-out Database (with all tables, etc.) + * @return \Propel\Generator\Model\Database The built-out Database (with all tables, etc.) */ protected function buildModel() { /** @var \Propel\Generator\Config\GeneratorConfig $config */ - $config = $this->getGeneratorConfig(); + $config = $this->getGeneratorConfig(); $connection = $this->getConnection(); $databaseName = $config->getConfigProperty('reverse.connection'); - $database = new Database($this->getDatabaseName()); $database->setPlatform($config->getConfiguredPlatform($connection)); $database->setDefaultIdMethod(IdMethod::NATIVE); @@ -220,7 +226,7 @@ protected function buildModel() $buildConnection = $config->getBuildConnection($databaseName); $this->log(sprintf('Reading database structure of database `%s` using dsn `%s`', $this->getDatabaseName(), $buildConnection['dsn'])); - $parser = $config->getConfiguredSchemaParser($connection, $databaseName); + $parser = $config->getConfiguredSchemaParser($connection, $databaseName); $this->log(sprintf('SchemaParser `%s` chosen', get_class($parser))); $nbTables = $parser->parse($database); @@ -237,6 +243,7 @@ protected function buildModel() foreach ($excludeTables as $excludeTable) { if (preg_match('/^' . str_replace('*', '.*', $excludeTable) . '$/', $tableName)) { $skip = true; + break; } } @@ -259,9 +266,9 @@ protected function buildModel() } /** - * @return ConnectionInterface + * @throws \Propel\Generator\Exception\BuildException if there isn't a configured connection for reverse * - * @throws BuildException if there isn't a configured connection for reverse + * @return \Propel\Runtime\Connection\ConnectionInterface */ protected function getConnection() { @@ -270,7 +277,7 @@ protected function getConnection() /** @var string|null $database */ $database = $generatorConfig->getConfigProperty('reverse.connection'); - if (null === $database) { + if ($database === null) { throw new BuildException('No configured connection. Please add a connection to your configuration file or pass a `connection` option to your command line.'); } diff --git a/src/Propel/Generator/Manager/SqlManager.php b/src/Propel/Generator/Manager/SqlManager.php index 17372b32ed..8aa85c4929 100644 --- a/src/Propel/Generator/Manager/SqlManager.php +++ b/src/Propel/Generator/Manager/SqlManager.php @@ -10,11 +10,11 @@ namespace Propel\Generator\Manager; +use Exception; use Propel\Generator\Exception\InvalidArgumentException; use Propel\Generator\Util\SqlParser; use Propel\Runtime\Adapter\AdapterFactory; use Propel\Runtime\Connection\ConnectionFactory; -use Propel\Runtime\Connection\ConnectionInterface; /** * Service class for managing SQL. @@ -37,6 +37,7 @@ class SqlManager extends AbstractManager * Set the database connection settings * * @param array $connections + * * @return void */ public function setConnections($connections) @@ -65,7 +66,7 @@ public function hasConnection($connection) } /** - * @return boolean + * @return bool */ public function isOverwriteSqlMap() { @@ -73,12 +74,13 @@ public function isOverwriteSqlMap() } /** - * @param boolean $overwriteSqlMap + * @param bool $overwriteSqlMap + * * @return void */ public function setOverwriteSqlMap($overwriteSqlMap) { - $this->overwriteSqlMap = (boolean) $overwriteSqlMap; + $this->overwriteSqlMap = (bool)$overwriteSqlMap; } /** @@ -107,6 +109,7 @@ public function getSqlDbMapFilename() /** * Build SQL files. + * * @return void */ public function buildSql() @@ -145,15 +148,19 @@ public function existSqlMap() /** * @param string|null $datasource A datasource name. + * + * @throws \Exception + * * @return bool */ public function insertSql($datasource = null) { $statementsToInsert = []; foreach ($this->getProperties($this->getSqlDbMapFilename()) as $sqlFile => $database) { - if (null !== $datasource && $database !== $datasource) { + if ($datasource !== null && $database !== $datasource) { // skip $this->log(sprintf('Skipping %s.', $sqlFile)); + break; } @@ -161,7 +168,7 @@ public function insertSql($datasource = null) $statementsToInsert[$database] = []; } - if (null === $datasource || (null !== $database && $database === $datasource)) { + if ($datasource === null || ($database !== null && $database === $datasource)) { $filename = $this->getWorkingDirectory() . DIRECTORY_SEPARATOR . $sqlFile; if (file_exists($filename)) { @@ -176,7 +183,8 @@ public function insertSql($datasource = null) foreach ($statementsToInsert as $database => $sqls) { if (!$this->hasConnection($database)) { - $this->log(sprintf("No connection available for %s database", $database)); + $this->log(sprintf('No connection available for %s database', $database)); + continue; } @@ -186,9 +194,10 @@ public function insertSql($datasource = null) try { $stmt = $con->prepare($sql); $stmt->execute(); - } catch (\Exception $e) { + } catch (Exception $e) { $message = sprintf('SQL insert failed: %s', $sql); - throw new \Exception($message, 0, $e); + + throw new Exception($message, 0, $e); } } }); @@ -202,14 +211,15 @@ public function insertSql($datasource = null) /** * Returns a ConnectionInterface instance for a given datasource. * - * @param string $datasource - * @return ConnectionInterface + * @param string $datasource + * + * @return \Propel\Runtime\Connection\ConnectionInterface */ protected function getConnectionInstance($datasource) { $buildConnection = $this->getConnection($datasource); - $dsn = str_replace("@DB@", $datasource, $buildConnection['dsn']); + $dsn = str_replace('@DB@', $datasource, $buildConnection['dsn']); // Set user + password to null if they are empty strings or missing $username = isset($buildConnection['user']) && $buildConnection['user'] ? $buildConnection['user'] : null; diff --git a/src/Propel/Generator/Model/Behavior.php b/src/Propel/Generator/Model/Behavior.php index ecbee3e7da..4f260633d3 100644 --- a/src/Propel/Generator/Model/Behavior.php +++ b/src/Propel/Generator/Model/Behavior.php @@ -10,8 +10,10 @@ namespace Propel\Generator\Model; +use InvalidArgumentException; use Propel\Generator\Builder\Util\PropelTemplate; use Propel\Generator\Exception\LogicException; +use ReflectionObject; /** * Information about behaviors of a table. @@ -24,14 +26,14 @@ class Behavior extends MappingModel /** * The table object on which the behavior is applied. * - * @var Table + * @var \Propel\Generator\Model\Table */ protected $table; /** * The database object. * - * @var Database + * @var \Propel\Generator\Model\Database */ protected $database; @@ -60,7 +62,7 @@ class Behavior extends MappingModel * Wether or not the table has been * modified by the behavior. * - * @var boolean + * @var bool */ protected $isTableModified = false; @@ -92,6 +94,7 @@ class Behavior extends MappingModel * Sets the name of the Behavior * * @param string $name the name of the behavior + * * @return void */ public function setName($name) @@ -107,6 +110,7 @@ public function setName($name) * Sets the id of the Behavior * * @param string $id The id of the behavior + * * @return void */ public function setId($id) @@ -149,6 +153,7 @@ public function getName() * Sets the table this behavior is applied to * * @param \Propel\Generator\Model\Table $table + * * @return void */ public function setTable(Table $table) @@ -159,7 +164,7 @@ public function setTable(Table $table) /** * Returns the table this behavior is applied to * - * @return Table + * @return \Propel\Generator\Model\Table */ public function getTable() { @@ -169,7 +174,8 @@ public function getTable() /** * Sets the database this behavior is applied to * - * @param Database $database + * @param \Propel\Generator\Model\Database $database + * * @return void */ public function setDatabase(Database $database) @@ -181,7 +187,7 @@ public function setDatabase(Database $database) * Returns the table this behavior is applied to if behavior is applied to * a database element. * - * @return Database + * @return \Propel\Generator\Model\Database */ public function getDatabase() { @@ -195,6 +201,7 @@ public function getDatabase() * [ 'name' => 'foo', 'value' => bar ] * * @param array $parameter + * * @return void */ public function addParameter(array $parameter) @@ -209,6 +216,7 @@ public function addParameter(array $parameter) * Expects an associative array looking like [ 'foo' => 'bar' ]. * * @param array $parameters + * * @return void */ public function setParameters(array $parameters) @@ -229,7 +237,8 @@ public function getParameters() /** * Returns a single parameter by its name. * - * @param string $name + * @param string $name + * * @return mixed */ public function getParameter($name) @@ -244,12 +253,13 @@ public function getParameter($name) * * Default is 50. * - * @param integer $tableModificationOrder + * @param int $tableModificationOrder + * * @return void */ public function setTableModificationOrder($tableModificationOrder) { - $this->tableModificationOrder = (int) $tableModificationOrder; + $this->tableModificationOrder = (int)$tableModificationOrder; } /** @@ -259,7 +269,7 @@ public function setTableModificationOrder($tableModificationOrder) * * Default is 50. * - * @return integer + * @return int */ public function getTableModificationOrder() { @@ -272,6 +282,7 @@ public function getTableModificationOrder() * * Propagates the behavior to the tables of the database and override this * method to have a database behavior do something special. + * * @return void */ public function modifyDatabase() @@ -289,7 +300,7 @@ public function modifyDatabase() /** * Returns the list of all tables in the same database. * - * @return Table[] A collection of Table instance + * @return \Propel\Generator\Model\Table[] A collection of Table instance */ protected function getTables() { @@ -310,7 +321,8 @@ public function modifyTable() /** * Sets whether or not the table has been modified. * - * @param boolean $modified + * @param bool $modified + * * @return void */ public function setTableModified($modified) @@ -321,7 +333,7 @@ public function setTableModified($modified) /** * Returns whether or not the table has been modified. * - * @return boolean + * @return bool */ public function isTableModified() { @@ -333,9 +345,12 @@ public function isTableModified() * passed as arguments. The template file name is relative to the behavior's * directory name. * - * @param string $filename - * @param array $vars - * @param string $templateDir + * @param string $filename + * @param array $vars + * @param string $templateDir + * + * @throws \InvalidArgumentException + * * @return string */ public function renderTemplate($filename, $vars = [], $templateDir = '/templates/') @@ -345,7 +360,8 @@ public function renderTemplate($filename, $vars = [], $templateDir = '/templates // try with '.php' at the end $filePath = $filePath . '.php'; if (!file_exists($filePath)) { - throw new \InvalidArgumentException(sprintf('Template "%s" not found in "%s" directory', + throw new InvalidArgumentException(sprintf( + 'Template "%s" not found in "%s" directory', $filename, $this->getDirname() . $templateDir )); @@ -366,8 +382,8 @@ public function renderTemplate($filename, $vars = [], $templateDir = '/templates */ protected function getDirname() { - if (null === $this->dirname) { - $r = new \ReflectionObject($this); + if ($this->dirname === null) { + $r = new ReflectionObject($this); $this->dirname = dirname($r->getFileName()); } @@ -378,8 +394,9 @@ protected function getDirname() * Returns a column object using a name stored in the behavior parameters. * Useful for table behaviors. * - * @param string $name - * @return Column + * @param string $name + * + * @return \Propel\Generator\Model\Column */ public function getColumnForParameter($name) { @@ -388,6 +405,7 @@ public function getColumnForParameter($name) /** * @throws \Propel\Generator\Exception\LogicException + * * @return void */ protected function setupObject() @@ -452,7 +470,7 @@ public function getTableMapBuilderModifier() /** * Returns whether or not this behavior has additional builders. * - * @return boolean + * @return bool */ public function hasAdditionalBuilders() { diff --git a/src/Propel/Generator/Model/BehaviorableTrait.php b/src/Propel/Generator/Model/BehaviorableTrait.php index c8d6e77a5f..f93361e13f 100644 --- a/src/Propel/Generator/Model/BehaviorableTrait.php +++ b/src/Propel/Generator/Model/BehaviorableTrait.php @@ -1,23 +1,22 @@ behaviorLocator) { + if ($this->behaviorLocator === null) { $config = $this->getGeneratorConfig(); - if (null !== $config) { + if ($config !== null) { $this->behaviorLocator = $config->getBehaviorLocator(); - if (null === $this->behaviorLocator) { + if ($this->behaviorLocator === null) { $this->behaviorLocator = new BehaviorLocator(); } } else { @@ -52,8 +51,10 @@ private function getBehaviorLocator() * Adds a new Behavior * * @param array|\Propel\Generator\Model\Behavior $bdata - * @throws BuildException when the added behavior is not an instance of \Propel\Generator\Model\Behavior - * @return Behavior $bdata + * + * @throws \Propel\Generator\Exception\BuildException when the added behavior is not an instance of \Propel\Generator\Model\Behavior + * + * @return \Propel\Generator\Model\Behavior */ public function addBehavior($bdata) { @@ -65,9 +66,10 @@ public function addBehavior($bdata) // the user probably just forgot to specify the "id" attribute if ($behavior->getId() === $behavior->getName()) { throw new BuildException(sprintf('Behavior "%s" is already registered. Specify a different ID attribute to register the same behavior several times.', $behavior->getName())); - } else { // or he copy-pasted it and forgot to update it. - throw new BuildException(sprintf('A behavior with ID "%s" is already registered.', $behavior->getId())); } + + // or he copy-pasted it and forgot to update it. + throw new BuildException(sprintf('A behavior with ID "%s" is already registered.', $behavior->getId())); } $this->registerBehavior($behavior); @@ -80,8 +82,12 @@ public function addBehavior($bdata) $class = $locator->getBehavior($bdata['name']); $behavior = new $class(); if (!($behavior instanceof Behavior)) { - throw new BuildException(sprintf('Behavior [%s: %s] not instance of %s', - $bdata['name'], $class, '\Propel\Generator\Model\Behavior')); + throw new BuildException(sprintf( + 'Behavior [%s: %s] not instance of %s', + $bdata['name'], + $class, + '\Propel\Generator\Model\Behavior' + )); } $behavior->loadMapping($bdata); @@ -98,7 +104,7 @@ abstract protected function registerBehavior(Behavior $behavior); /** * Returns the list of behaviors. * - * @return Behavior[] + * @return \Propel\Generator\Model\Behavior[] */ public function getBehaviors() { @@ -108,8 +114,9 @@ public function getBehaviors() /** * check if the given behavior exists * - * @param string $id the behavior id - * @return boolean True if the behavior exists + * @param string $id the behavior id + * + * @return bool True if the behavior exists */ public function hasBehavior($id) { @@ -119,8 +126,9 @@ public function hasBehavior($id) /** * Get behavior by id * - * @param string $id the behavior id - * @return Behavior|null A behavior object or null if the behavior doesn't exist + * @param string $id the behavior id + * + * @return \Propel\Generator\Model\Behavior|null A behavior object or null if the behavior doesn't exist */ public function getBehavior($id) { diff --git a/src/Propel/Generator/Model/Column.php b/src/Propel/Generator/Model/Column.php index ae50248585..d7000dc75a 100644 --- a/src/Propel/Generator/Model/Column.php +++ b/src/Propel/Generator/Model/Column.php @@ -10,6 +10,7 @@ namespace Propel\Generator\Model; +use Exception; use Propel\Generator\Exception\EngineException; use Propel\Generator\Platform\PlatformInterface; @@ -27,9 +28,9 @@ */ class Column extends MappingModel { - const DEFAULT_TYPE = 'VARCHAR'; - const DEFAULT_VISIBILITY = 'public'; - const CONSTANT_PREFIX = 'COL_'; + public const DEFAULT_TYPE = 'VARCHAR'; + public const DEFAULT_VISIBILITY = 'public'; + public const CONSTANT_PREFIX = 'COL_'; public static $validVisibilities = [ 'public', 'protected', 'private' ]; @@ -86,22 +87,25 @@ class Column extends MappingModel /** * The name to use for the tableMap constant that identifies this column. * (Will be converted to all-uppercase in the templates.) + * * @var string */ private $tableMapName; /** * Native PHP type (scalar or class name) + * * @var string "string", "boolean", "int", "double" */ private $phpType; /** - * @var Domain|null + * @var \Propel\Generator\Model\Domain|null */ private $domain; + /** - * @var Table + * @var \Propel\Generator\Model\Table */ private $parentTable; @@ -211,15 +215,15 @@ class Column extends MappingModel */ public function __construct($name = null, $type = null, $size = null) { - if (null !== $name) { + if ($name !== null) { $this->setName($name); } - if (null !== $type) { + if ($type !== null) { $this->setType($type); } - if (null !== $size) { + if ($size !== null) { $this->setSize((int)$size); } } @@ -234,6 +238,7 @@ public function getTypeHint() /** * @param string|null $typeHint + * * @return void */ public function setTypeHint($typeHint) @@ -243,13 +248,14 @@ public function setTypeHint($typeHint) /** * @throws \Propel\Generator\Exception\EngineException + * * @return void */ protected function setupObject() { try { $database = $this->getDatabase(); - $domain = $this->getDomain(); + $domain = $this->getDomain(); $platform = null; if ($this->hasPlatform()) { @@ -324,11 +330,13 @@ protected function setupObject() // Add type, size information to associated Domain object $domain->replaceSqlType($this->getAttribute('sqlType')); - if (!$this->getAttribute('size') + if ( + !$this->getAttribute('size') && $domain->getType() === 'VARCHAR' && !$this->getAttribute('sqlType') && $platform - && !$platform->supportsVarcharWithoutSize()) { + && !$platform->supportsVarcharWithoutSize() + ) { $size = 255; } else { $size = $this->getAttribute('size'); @@ -338,9 +346,9 @@ protected function setupObject() $domain->replaceScale($this->getAttribute('scale')); $defval = $this->getAttribute('defaultValue', $this->getAttribute('default')); - if (null !== $defval && 'null' !== strtolower($defval)) { + if ($defval !== null && strtolower($defval) !== 'null') { $domain->setDefaultValue(new ColumnDefaultValue($defval, ColumnDefaultValue::TYPE_VALUE)); - } elseif (null !== $this->getAttribute('defaultExpr')) { + } elseif ($this->getAttribute('defaultExpr') !== null) { $domain->setDefaultValue(new ColumnDefaultValue($this->getAttribute('defaultExpr'), ColumnDefaultValue::TYPE_EXPR)); } @@ -354,8 +362,8 @@ protected function setupObject() here we are only checking for 'false', so don't use booleanValue() */ - $this->isInheritance = (null !== $this->inheritanceType && 'false' !== $this->inheritanceType); - } catch (\Exception $e) { + $this->isInheritance = ($this->inheritanceType !== null && $this->inheritanceType !== 'false'); + } catch (Exception $e) { throw new EngineException(sprintf( 'Error setting up column %s: %s', $this->getAttribute('name'), @@ -369,8 +377,9 @@ protected function setupObject() * attribute value in the column, parent table or parent database. * Finally, it defaults to the default visibility (public). * - * @param string $attribute Local column attribute - * @param string $parentAttribute Parent (table or database) attribute + * @param string $attribute Local column attribute + * @param string $parentAttribute Parent (table or database) attribute + * * @return string */ private function getMethodVisibility($attribute, $parentAttribute) @@ -394,7 +403,7 @@ private function getMethodVisibility($attribute, $parentAttribute) /** * Returns the database object the current column is in. * - * @return Database + * @return \Propel\Generator\Model\Database */ private function getDatabase() { @@ -403,7 +412,8 @@ private function getDatabase() /** * Gets domain for this column, creating a new empty domain object if none is set. - * @return Domain + * + * @return \Propel\Generator\Model\Domain */ public function getDomain() { @@ -419,7 +429,8 @@ public function getDomain() /** * Sets the domain for this column. * - * @param Domain $domain + * @param \Propel\Generator\Model\Domain $domain + * * @return void */ public function setDomain(Domain $domain) @@ -471,6 +482,7 @@ public function getUppercasedName() * Sets the column name. * * @param string $name + * * @return void */ public function setName($name) @@ -481,7 +493,7 @@ public function setName($name) /** * Returns whether or not the column name is plural. * - * @return boolean + * @return bool */ public function isNamePlural() { @@ -495,7 +507,10 @@ public function isNamePlural() */ public function getSingularName() { - if ($this->getAttribute('phpSingularName')) return $this->getAttribute('phpSingularName'); + if ($this->getAttribute('phpSingularName')) { + return $this->getAttribute('phpSingularName'); + } + return rtrim($this->name, 's'); } @@ -513,6 +528,7 @@ public function getDescription() * Sets the column description. * * @param string $description + * * @return void */ public function setDescription($description) @@ -528,7 +544,7 @@ public function setDescription($description) */ public function getPhpName() { - if (null === $this->phpName) { + if ($this->phpName === null) { $this->setPhpName(); } @@ -544,7 +560,7 @@ public function getPhpName() */ public function getPhpSingularName() { - if (null === $this->phpSingularName) { + if ($this->phpSingularName === null) { $this->setPhpSingularName(); } @@ -557,12 +573,13 @@ public function getPhpSingularName() * It will generate a phpName from its name if no * $phpName is passed. * - * @param string $phpName + * @param string|null $phpName + * * @return void */ public function setPhpName($phpName = null) { - if (null === $phpName) { + if ($phpName === null) { $this->phpName = self::generatePhpName($this->name, $this->phpNamingMethod, $this->namePrefix); } else { $this->phpName = $phpName; @@ -576,12 +593,13 @@ public function setPhpName($phpName = null) * It will generate a phpName from its name if no * $phpSingularName is passed. * - * @param string $phpSingularName + * @param string|null $phpSingularName + * * @return void */ public function setPhpSingularName($phpSingularName = null) { - if (null === $phpSingularName) { + if ($phpSingularName === null) { $this->phpSingularName = self::generatePhpSingularName($this->getPhpName()); } else { $this->phpSingularName = $phpSingularName; @@ -607,7 +625,7 @@ public function getCamelCaseName() */ public function getAccessorVisibility() { - if (null !== $this->accessorVisibility) { + if ($this->accessorVisibility !== null) { return $this->accessorVisibility; } @@ -618,6 +636,7 @@ public function getAccessorVisibility() * Sets the accessor methods visibility for this column / attribute. * * @param string $visibility + * * @return void */ public function setAccessorVisibility($visibility) @@ -637,7 +656,7 @@ public function setAccessorVisibility($visibility) */ public function getMutatorVisibility() { - if (null !== $this->mutatorVisibility) { + if ($this->mutatorVisibility !== null) { return $this->mutatorVisibility; } @@ -648,6 +667,7 @@ public function getMutatorVisibility() * Sets the mutator methods visibility for this column / attribute. * * @param string $visibility + * * @return void */ public function setMutatorVisibility($visibility) @@ -670,7 +690,7 @@ public function getFQConstantName() $classname = $this->parentTable->getPhpName() . 'TableMap'; $const = $this->getConstantName(); - return $classname.'::'.$const; + return $classname . '::' . $const; } /** @@ -682,10 +702,10 @@ public function getConstantName() { // was it overridden in schema.xml ? if ($this->getTableMapName()) { - return self::CONSTANT_PREFIX.strtoupper($this->getTableMapName()); + return self::CONSTANT_PREFIX . strtoupper($this->getTableMapName()); } - return self::CONSTANT_PREFIX.strtoupper($this->getName()); + return self::CONSTANT_PREFIX . strtoupper($this->getName()); } /** @@ -702,6 +722,7 @@ public function getTableMapName() * Sets the TableMap constant name that will identify this column. * * @param string $name + * * @return void */ public function setTableMapName($name) @@ -724,7 +745,7 @@ public function getPhpType() /** * Returns the location of this column within the table (one-based). * - * @return integer|null + * @return int|null */ public function getPosition() { @@ -734,18 +755,20 @@ public function getPosition() /** * Returns the location of this column within the table (one-based). * - * @param integer $position + * @param int $position + * * @return void */ public function setPosition($position) { - $this->position = (int) $position; + $this->position = (int)$position; } /** * Sets the parent table. * * @param \Propel\Generator\Model\Table $table + * * @return void */ public function setTable(Table $table) @@ -756,7 +779,7 @@ public function setTable(Table $table) /** * Returns the parent table. * - * @return Table + * @return \Propel\Generator\Model\Table */ public function getTable() { @@ -777,14 +800,15 @@ public function getTableName() * Adds a new inheritance definition to the inheritance list and sets the * parent column of the inheritance to the current column. * - * @param Inheritance|array $inheritance - * @return Inheritance + * @param \Propel\Generator\Model\Inheritance|array $inheritance + * + * @return \Propel\Generator\Model\Inheritance */ public function addInheritance($inheritance) { if ($inheritance instanceof Inheritance) { $inheritance->setColumn($this); - if (null === $this->inheritanceList) { + if ($this->inheritanceList === null) { $this->inheritanceList = []; $this->isEnumeratedClasses = true; } @@ -812,7 +836,7 @@ public function getInheritanceType() /** * Returns the inheritance list. * - * @return Inheritance[] + * @return \Propel\Generator\Model\Inheritance[] */ public function getInheritanceList() { @@ -822,7 +846,7 @@ public function getInheritanceList() /** * Returns the inheritance definitions. * - * @return Inheritance[] + * @return \Propel\Generator\Model\Inheritance[] */ public function getChildren() { @@ -833,7 +857,7 @@ public function getChildren() * Returns whether or not this column is a normal property or specifies a * the classes that are represented in the table containing this column. * - * @return boolean + * @return bool */ public function isInheritance() { @@ -844,7 +868,7 @@ public function isInheritance() * Returns whether or not possible classes have been enumerated in the * schema file. * - * @return boolean + * @return bool */ public function isEnumeratedClasses() { @@ -854,7 +878,7 @@ public function isEnumeratedClasses() /** * Returns whether or not the column is not null. * - * @return boolean + * @return bool */ public function isNotNull() { @@ -864,18 +888,19 @@ public function isNotNull() /** * Sets whether or not the column is not null. * - * @param boolean $flag + * @param bool $flag + * * @return void */ public function setNotNull($flag = true) { - $this->isNotNull = (bool) $flag; + $this->isNotNull = (bool)$flag; } /** * Returns NOT NULL string for this column. * - * @return string. + * @return string */ public function getNotNullString() { @@ -888,19 +913,20 @@ public function getNotNullString() * The primary string is the value used by default in the magic * __toString method of an active record object. * - * @param boolean $isPrimaryString + * @param bool $isPrimaryString + * * @return void */ public function setPrimaryString($isPrimaryString) { - $this->isPrimaryString = (bool) $isPrimaryString; + $this->isPrimaryString = (bool)$isPrimaryString; } /** * Returns true if the column is the primary string (used for the magic * __toString() method). * - * @return boolean + * @return bool */ public function isPrimaryString() { @@ -910,18 +936,19 @@ public function isPrimaryString() /** * Sets whether or not the column is a primary key. * - * @param boolean $flag + * @param bool $flag + * * @return void */ public function setPrimaryKey($flag = true) { - $this->isPrimaryKey = (bool) $flag; + $this->isPrimaryKey = (bool)$flag; } /** * Returns whether or not the column is the primary key. * - * @return boolean + * @return bool */ public function isPrimaryKey() { @@ -931,18 +958,19 @@ public function isPrimaryKey() /** * Sets whether or not the column is a node key of a tree. * - * @param boolean $isNodeKey + * @param bool $isNodeKey + * * @return void */ public function setNodeKey($isNodeKey) { - $this->isNodeKey = (bool) $isNodeKey; + $this->isNodeKey = (bool)$isNodeKey; } /** * Returns whether or not the column is a node key of a tree. * - * @return boolean + * @return bool */ public function isNodeKey() { @@ -953,11 +981,12 @@ public function isNodeKey() * Sets the separator for the node key column in a tree. * * @param string $sep + * * @return void */ public function setNodeKeySep($sep) { - $this->nodeKeySep = (string) $sep; + $this->nodeKeySep = (string)$sep; } /** @@ -973,18 +1002,19 @@ public function getNodeKeySep() /** * Sets whether or not the column is the nested set left key of a tree. * - * @param boolean $isNestedSetLeftKey + * @param bool $isNestedSetLeftKey + * * @return void */ public function setNestedSetLeftKey($isNestedSetLeftKey) { - $this->isNestedSetLeftKey = (bool) $isNestedSetLeftKey; + $this->isNestedSetLeftKey = (bool)$isNestedSetLeftKey; } /** * Returns whether or not the column is a nested set key of a tree. * - * @return boolean + * @return bool */ public function isNestedSetLeftKey() { @@ -994,18 +1024,19 @@ public function isNestedSetLeftKey() /** * Set if the column is the nested set right key of a tree. * - * @param boolean $isNestedSetRightKey + * @param bool $isNestedSetRightKey + * * @return void */ public function setNestedSetRightKey($isNestedSetRightKey) { - $this->isNestedSetRightKey = (bool) $isNestedSetRightKey; + $this->isNestedSetRightKey = (bool)$isNestedSetRightKey; } /** * Return whether or not the column is a nested set right key of a tree. * - * @return boolean + * @return bool */ public function isNestedSetRightKey() { @@ -1015,18 +1046,19 @@ public function isNestedSetRightKey() /** * Sets whether or not the column is the scope key of a tree. * - * @param boolean $isTreeScopeKey + * @param bool $isTreeScopeKey + * * @return void */ public function setTreeScopeKey($isTreeScopeKey) { - $this->isTreeScopeKey = (bool) $isTreeScopeKey; + $this->isTreeScopeKey = (bool)$isTreeScopeKey; } /** * Returns whether or not the column is a scope key of a tree. * - * @return boolean + * @return bool */ public function isTreeScopeKey() { @@ -1036,7 +1068,7 @@ public function isTreeScopeKey() /** * Returns whether or not the column must have a unique index. * - * @return boolean + * @return bool */ public function isUnique() { @@ -1046,7 +1078,7 @@ public function isUnique() /** * Returns true if the column requires a transaction in PostGreSQL. * - * @return boolean + * @return bool */ public function requiresTransactionInPostgres() { @@ -1056,7 +1088,7 @@ public function requiresTransactionInPostgres() /** * Returns whether or not this column is a foreign key. * - * @return boolean + * @return bool */ public function isForeignKey() { @@ -1066,7 +1098,7 @@ public function isForeignKey() /** * Returns whether or not this column is part of more than one foreign key. * - * @return boolean + * @return bool */ public function hasMultipleFK() { @@ -1078,7 +1110,7 @@ public function hasMultipleFK() * * Only if it is a foreign key or part of a foreign key. * - * @return ForeignKey[] + * @return \Propel\Generator\Model\ForeignKey[] */ public function getForeignKeys() { @@ -1088,7 +1120,8 @@ public function getForeignKeys() /** * Adds the foreign key from another table that refers to this column. * - * @param ForeignKey $fk + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return void */ public function addReferrer(ForeignKey $fk) @@ -1099,7 +1132,7 @@ public function addReferrer(ForeignKey $fk) /** * Returns the list of references to this column. * - * @return ForeignKey[] + * @return \Propel\Generator\Model\ForeignKey[] */ public function getReferrers() { @@ -1109,7 +1142,7 @@ public function getReferrers() /** * Returns whether or not this column has referers. * - * @return boolean + * @return bool */ public function hasReferrers() { @@ -1120,8 +1153,9 @@ public function hasReferrers() * Returns whether or not this column has a specific referrer for a * specific foreign key object. * - * @param ForeignKey $fk - * @return boolean + * @param \Propel\Generator\Model\ForeignKey $fk + * + * @return bool */ public function hasReferrer(ForeignKey $fk) { @@ -1155,6 +1189,7 @@ public function clearInheritanceList() * size, scale (or other domain attributes). * * @param string $mappingType + * * @return void */ public function setDomainForType($mappingType) @@ -1165,8 +1200,10 @@ public function setDomainForType($mappingType) /** * Sets the mapping column type. * - * @param string $mappingType * @see Domain::setType() + * + * @param string $mappingType + * * @return void */ public function setType($mappingType) @@ -1181,8 +1218,9 @@ public function setType($mappingType) /** * Returns the Propel column type as a string. * - * @return string * @see Domain::getType() + * + * @return string */ public function getType() { @@ -1192,7 +1230,7 @@ public function getType() /** * Returns the column PDO type integer for this column's mapping type. * - * @return integer + * @return int */ public function getPDOType() { @@ -1204,11 +1242,13 @@ public function getPDOType() * * @return bool */ - public function isDefaultSqlType(PlatformInterface $platform = null) + public function isDefaultSqlType(?PlatformInterface $platform = null) { - if (null === $this->domain - || null === $this->domain->getSqlType() - || null === $platform) { + if ( + $this->domain === null + || $this->domain->getSqlType() === null + || $platform === null + ) { return true; } @@ -1220,7 +1260,7 @@ public function isDefaultSqlType(PlatformInterface $platform = null) /** * Returns whether or not this column is a blob/lob type. * - * @return boolean + * @return bool */ public function isLobType() { @@ -1230,7 +1270,7 @@ public function isLobType() /** * Returns whether or not this column is a text type. * - * @return boolean + * @return bool */ public function isTextType() { @@ -1240,7 +1280,7 @@ public function isTextType() /** * Returns whether or not this column is a numeric type. * - * @return boolean + * @return bool */ public function isNumericType() { @@ -1250,7 +1290,7 @@ public function isNumericType() /** * Returns whether or not this column is a boolean type. * - * @return boolean + * @return bool */ public function isBooleanType() { @@ -1260,7 +1300,7 @@ public function isBooleanType() /** * Returns whether or not this column is a temporal type. * - * @return boolean + * @return bool */ public function isTemporalType() { @@ -1270,7 +1310,7 @@ public function isTemporalType() /** * Returns whether or not the column is an array column. * - * @return boolean + * @return bool */ public function isPhpArrayType() { @@ -1280,7 +1320,7 @@ public function isPhpArrayType() /** * Returns whether or not this column is an ENUM or SET column. * - * @return boolean + * @return bool */ public function isValueSetType() { @@ -1290,27 +1330,28 @@ public function isValueSetType() /** * Returns whether or not this column is an ENUM column. * - * @return boolean + * @return bool */ public function isEnumType() { - return PropelTypes::ENUM === $this->getType(); + return $this->getType() === PropelTypes::ENUM; } /** * Returns whether or not this column is a SET column. * - * @return boolean + * @return bool */ public function isSetType() { - return PropelTypes::SET === $this->getType(); + return $this->getType() === PropelTypes::SET; } /** * Sets the list of possible values for an ENUM or SET column. * * @param string|string[] $valueSet + * * @return void */ public function setValueSet($valueSet) @@ -1336,7 +1377,7 @@ public function getValueSet() /** * Returns the column size. * - * @return integer + * @return int */ public function getSize() { @@ -1346,7 +1387,8 @@ public function getSize() /** * Sets the column size. * - * @param integer|null $size + * @param int|null $size + * * @return void */ public function setSize($size) @@ -1357,7 +1399,7 @@ public function setSize($size) /** * Returns the column scale. * - * @return integer + * @return int */ public function getScale() { @@ -1367,7 +1409,8 @@ public function getScale() /** * Sets the column scale. * - * @param integer $scale + * @param int $scale + * * @return void */ public function setScale($scale) @@ -1394,7 +1437,7 @@ public function getSizeDefinition() */ public function hasDefaultValue() { - return null !== $this->getDefaultValue(); + return $this->getDefaultValue() !== null; } /** @@ -1406,7 +1449,7 @@ public function getDefaultValueString() { $defaultValue = $this->getDefaultValue(); - if (null === $defaultValue) { + if ($defaultValue === null) { return 'null'; } @@ -1428,7 +1471,8 @@ public function getDefaultValueString() /** * Sets a string that will give this column a default value. * - * @param ColumnDefaultValue|string|null $defaultValue The column's default value + * @param \Propel\Generator\Model\ColumnDefaultValue|string|null $defaultValue The column's default value + * * @return void */ public function setDefaultValue($defaultValue) @@ -1443,8 +1487,9 @@ public function setDefaultValue($defaultValue) /** * Returns the default value object for this column. * - * @return ColumnDefaultValue|null * @see Domain::getDefaultValue() + * + * @return \Propel\Generator\Model\ColumnDefaultValue|null */ public function getDefaultValue() { @@ -1454,8 +1499,9 @@ public function getDefaultValue() /** * Returns the default value suitable for use in PHP. * - * @return mixed|null * @see Domain::getPhpDefaultValue() + * + * @return mixed|null */ public function getPhpDefaultValue() { @@ -1467,7 +1513,7 @@ public function getPhpDefaultValue() * the target database. We need to pass in the properties for the target * database! * - * @return boolean + * @return bool */ public function isAutoIncrement() { @@ -1480,7 +1526,7 @@ public function isAutoIncrement() * For example, if a runtime query on the table doesn't hydrate this column * but a getter does. * - * @return boolean + * @return bool */ public function isLazyLoad() { @@ -1490,11 +1536,13 @@ public function isLazyLoad() /** * Returns the auto-increment string. * + * @throws \Propel\Generator\Exception\EngineException + * * @return string */ public function getAutoIncrementString() { - if ($this->isAutoIncrement() && IdMethod::NATIVE === $this->parentTable->getIdMethod()) { + if ($this->isAutoIncrement() && $this->parentTable->getIdMethod() === IdMethod::NATIVE) { return $this->getPlatform()->getAutoIncrement(); } @@ -1514,12 +1562,13 @@ public function getAutoIncrementString() * * Use isAutoIncrement() to find out if it is set or not. * - * @param boolean $flag + * @param bool $flag + * * @return void */ public function setAutoIncrement($flag = true) { - $this->isAutoIncrement = (bool) $flag; + $this->isAutoIncrement = (bool)$flag; } /** @@ -1538,8 +1587,9 @@ public function getPhpNative() * Returns whether or not the column PHP native type is primitive type (aka * a boolean, an integer, a long, a float, a double or a string). * - * @return boolean * @see PropelTypes::isPhpPrimitiveType() + * + * @return bool */ public function isPhpPrimitiveType() { @@ -1550,8 +1600,9 @@ public function isPhpPrimitiveType() * Returns whether or not the column PHP native type is a primitive numeric * type (aka an integer, a long, a float or a double). * - * @return boolean * @see PropelTypes::isPhpPrimitiveNumericType() + * + * @return bool */ public function isPhpPrimitiveNumericType() { @@ -1561,8 +1612,9 @@ public function isPhpPrimitiveNumericType() /** * Returns whether or not the column PHP native type is an object. * - * @return boolean * @see PropelTypes::isPhpObjectType() + * + * @return bool */ public function isPhpObjectType() { @@ -1572,7 +1624,7 @@ public function isPhpObjectType() /** * Returns an instance of PlatformInterface interface. * - * @return PlatformInterface|null + * @return \Propel\Generator\Platform\PlatformInterface|null */ public function getPlatform() { @@ -1582,11 +1634,11 @@ public function getPlatform() /** * Returns whether or not this column has a platform adapter. * - * @return boolean + * @return bool */ public function hasPlatform() { - if (null === $this->parentTable) { + if ($this->parentTable === null) { return false; } @@ -1609,9 +1661,10 @@ public function __clone() /** * Returns a generated PHP name. * - * @param string $name - * @param string $phpNamingMethod - * @param string $namePrefix + * @param string $name + * @param string $phpNamingMethod + * @param string|null $namePrefix + * * @return string */ public static function generatePhpName($name, $phpNamingMethod = PhpNameGenerator::CONV_METHOD_CLEAN, $namePrefix = null) @@ -1622,7 +1675,8 @@ public static function generatePhpName($name, $phpNamingMethod = PhpNameGenerato /** * Generates the singular form of a PHP name. * - * @param string $phpname + * @param string $phpname + * * @return string */ public static function generatePhpSingularName($phpname) diff --git a/src/Propel/Generator/Model/ColumnDefaultValue.php b/src/Propel/Generator/Model/ColumnDefaultValue.php index 8788a49f29..105b40a986 100644 --- a/src/Propel/Generator/Model/ColumnDefaultValue.php +++ b/src/Propel/Generator/Model/ColumnDefaultValue.php @@ -18,8 +18,8 @@ */ class ColumnDefaultValue { - const TYPE_VALUE = 'value'; - const TYPE_EXPR = 'expr'; + public const TYPE_VALUE = 'value'; + public const TYPE_EXPR = 'expr'; /** * @var string|null The default value, as specified in the schema. @@ -35,13 +35,13 @@ class ColumnDefaultValue * Creates a new DefaultValue object. * * @param string|null $value The default value, as specified in the schema. - * @param string|null $type The type of default value (DefaultValue::TYPE_VALUE or DefaultValue::TYPE_EXPR) + * @param string|null $type The type of default value (DefaultValue::TYPE_VALUE or DefaultValue::TYPE_EXPR) */ public function __construct($value, $type = null) { $this->setValue($value); - if (null !== $type) { + if ($type !== null) { $this->setType($type); } } @@ -56,6 +56,7 @@ public function getType() /** * @param string $type The type of default value (DefaultValue::TYPE_VALUE or DefaultValue::TYPE_EXPR) + * * @return void */ public function setType($type) @@ -66,11 +67,11 @@ public function setType($type) /** * Convenience method to indicate whether the value in this object is an expression (as opposed to simple value). * - * @return boolean Whether value this object holds is an expression. + * @return bool Whether value this object holds is an expression. */ public function isExpression() { - return self::TYPE_EXPR === $this->type; + return $this->type === self::TYPE_EXPR; } /** @@ -83,6 +84,7 @@ public function getValue() /** * @param string|null $value The value, as specified in the schema. + * * @return void */ public function setValue($value) @@ -93,9 +95,11 @@ public function setValue($value) /** * A method to compare if two Default values match * - * @param ColumnDefaultValue $other The value to compare to - * @return boolean Whether this object represents same default value as $other - * @author Niklas Närhinen + * @author Niklas Närhinen + * + * @param \Propel\Generator\Model\ColumnDefaultValue $other The value to compare to + * + * @return bool Whether this object represents same default value as $other */ public function equals(ColumnDefaultValue $other) { diff --git a/src/Propel/Generator/Model/ConstraintNameGenerator.php b/src/Propel/Generator/Model/ConstraintNameGenerator.php index 9f33711a73..7d25e3b636 100644 --- a/src/Propel/Generator/Model/ConstraintNameGenerator.php +++ b/src/Propel/Generator/Model/ConstraintNameGenerator.php @@ -14,7 +14,7 @@ /** * A NameGeneratorInterface implementation for table-specific - * constraints. Conforms to the maximum column name length for the + * constraints. Conforms to the maximum column name length for the * type of database in use. * * @author Hans Lellelid (Propel) @@ -26,7 +26,7 @@ class ConstraintNameGenerator implements NameGeneratorInterface /** * Conditional compilation flag. */ - const DEBUG = false; + public const DEBUG = false; /** * First element of inputs should be of type {@link Database}, second @@ -36,20 +36,23 @@ class ConstraintNameGenerator implements NameGeneratorInterface * of this constraint. * * @see NameGenerator - * @param array $inputs An array of input parameters + * + * @param array $inputs An array of input parameters + * + * @throws \Propel\Generator\Exception\EngineException + * * @return string - * @throws EngineException */ public function generateName($inputs) { - $db = $inputs[0]; - $name = $inputs[1]; - $namePostfix = $inputs[2]; - $constraintNbr = (string) $inputs[3]; + $db = $inputs[0]; + $name = $inputs[1]; + $namePostfix = $inputs[2]; + $constraintNbr = (string)$inputs[3]; // Calculate maximum RDBMS-specific column character limit. try { - $maxColumnNameLength = (int) $db->getMaxColumnNameLength(); + $maxColumnNameLength = (int)$db->getMaxColumnNameLength(); $maxBodyLength = ($maxColumnNameLength - strlen($namePostfix) - strlen($constraintNbr) - 2); } catch (EngineException $e) { throw $e; diff --git a/src/Propel/Generator/Model/CrossForeignKeys.php b/src/Propel/Generator/Model/CrossForeignKeys.php index f1477518d0..3f6091637b 100644 --- a/src/Propel/Generator/Model/CrossForeignKeys.php +++ b/src/Propel/Generator/Model/CrossForeignKeys.php @@ -14,67 +14,66 @@ * A class for information about table cross foreign keys which are used in many-to-many relations. * * - * ___CrossTable1___ ___User___ - * | PK1 userId |----------FK1------------------->| id | - * | | _Group__ | name | - * | PK2 groupId |-----+----FK2----->| id | |__________| - * | | / \->| id2 | - * | PK3 relationId | / | name | - * | | / |________| - * | PK4 groupId2 |-/ + * ___CrossTable1___ ___User___ + * | PK1 userId |----------FK1------------------->| id | + * ||_Group__|name| + * | PK2 groupId |-----+----FK2----->| id | |__________| + * ||/ \->| id2 | + * | PK3 relationId | / | name | + * ||/|________| + * | PK4 groupId2 |-/ * |_________________| * * * User->getCrossFks(): * 0: - * getTable() -> User - * getCrossForeignKeys() -> [FK2] - * getMiddleTable() -> CrossTable1 - * getIncomingForeignKey() -> FK1 + * getTable() -> User + * getCrossForeignKeys() -> [FK2] + * getMiddleTable() -> CrossTable1 + * getIncomingForeignKey() -> FK1 * getUnclassifiedPrimaryKeys() -> [PK3] * * Group->getCrossFks(): * 0: - * getTable() -> Group - * getCrossForeignKeys() -> [FK1] - * getMiddleTable() -> CrossTable1 - * getIncomingForeignKey() -> FK2 + * getTable() -> Group + * getCrossForeignKeys() -> [FK1] + * getMiddleTable() -> CrossTable1 + * getIncomingForeignKey() -> FK2 * getUnclassifiedPrimaryKeys() -> [PK3] */ class CrossForeignKeys { - /** * The middle-table. * - * @var Table + * @var \Propel\Generator\Model\Table */ protected $table; /** * The target table (which has crossRef=true). * - * @var Table + * @var \Propel\Generator\Model\Table */ protected $middleTable; /** * All other outgoing relations from the middle-table to other tables. * - * @var ForeignKey[] + * @var \Propel\Generator\Model\ForeignKey[] */ protected $crossForeignKeys = []; /** * The incoming foreign key from the middle-table to this table. * - * @var ForeignKey|null + * @var \Propel\Generator\Model\ForeignKey|null */ protected $incomingForeignKey; /** - * @param ForeignKey $foreignKey - * @param Table $crossTable + * @param \Propel\Generator\Model\ForeignKey $foreignKey + * @param \Propel\Generator\Model\Table $crossTable */ public function __construct(ForeignKey $foreignKey, Table $crossTable) { @@ -83,7 +82,8 @@ public function __construct(ForeignKey $foreignKey, Table $crossTable) } /** - * @param ForeignKey|null $foreignKey + * @param \Propel\Generator\Model\ForeignKey|null $foreignKey + * * @return void */ public function setIncomingForeignKey($foreignKey) @@ -95,7 +95,7 @@ public function setIncomingForeignKey($foreignKey) /** * The foreign key from the middle-table to the target table. * - * @return ForeignKey|null + * @return \Propel\Generator\Model\ForeignKey|null */ public function getIncomingForeignKey() { @@ -110,12 +110,12 @@ public function getIncomingForeignKey() * * table (local primary keys -> foreignKey): * - * pk1 -> FK1 + * pk1 -> FK1 * pk2 * \ * -> FK2 * / - * pk3 -> FK3 + * pk3 -> FK3 * \ * -> FK4 * / @@ -128,7 +128,8 @@ public function getIncomingForeignKey() * isAtLeastOneLocalPrimaryKeyNotCovered(FK3) where FK1,FK2 is in our collection: false * isAtLeastOneLocalPrimaryKeyNotCovered(FK4) where FK1,FK2 is in our collection: true * - * @param ForeignKey $fk + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return bool */ public function isAtLeastOneLocalPrimaryKeyNotCovered(ForeignKey $fk) @@ -139,6 +140,7 @@ public function isAtLeastOneLocalPrimaryKeyNotCovered(ForeignKey $fk) foreach ($this->getCrossForeignKeys() as $crossFK) { if ($crossFK->hasLocalColumn($primaryKey)) { $covered = true; + break; } } @@ -154,7 +156,7 @@ public function isAtLeastOneLocalPrimaryKeyNotCovered(ForeignKey $fk) /** * Returns all primary keys of middle-table which are not already covered by at least on of our cross foreignKey collection. * - * @return Column[] + * @return \Propel\Generator\Model\Column[] */ public function getUnclassifiedPrimaryKeys() { @@ -169,6 +171,7 @@ public function getUnclassifiedPrimaryKeys() foreach ($this->getCrossForeignKeys() as $crossFK) { if ($crossFK->hasLocalColumn($pk)) { $unclassified = false; + break; } } @@ -182,7 +185,8 @@ public function getUnclassifiedPrimaryKeys() } /** - * @param ForeignKey $foreignKey + * @param \Propel\Generator\Model\ForeignKey $foreignKey + * * @return void */ public function addCrossForeignKey(ForeignKey $foreignKey) @@ -195,11 +199,12 @@ public function addCrossForeignKey(ForeignKey $foreignKey) */ public function hasCrossForeignKeys() { - return !!$this->crossForeignKeys; + return (bool)$this->crossForeignKeys; } /** - * @param ForeignKey[] $foreignKeys + * @param \Propel\Generator\Model\ForeignKey[] $foreignKeys + * * @return void */ public function setCrossForeignKeys(array $foreignKeys) @@ -210,7 +215,7 @@ public function setCrossForeignKeys(array $foreignKeys) /** * All other outgoing relations from the middle-table to other tables. * - * @return ForeignKey[] + * @return \Propel\Generator\Model\ForeignKey[] */ public function getCrossForeignKeys() { @@ -219,6 +224,7 @@ public function getCrossForeignKeys() /** * @param \Propel\Generator\Model\Table $foreignTable + * * @return void */ public function setMiddleTable(Table $foreignTable) @@ -229,7 +235,7 @@ public function setMiddleTable(Table $foreignTable) /** * The middle table (which has crossRef=true). * - * @return Table + * @return \Propel\Generator\Model\Table */ public function getMiddleTable() { @@ -238,6 +244,7 @@ public function getMiddleTable() /** * @param \Propel\Generator\Model\Table $table + * * @return void */ public function setTable(Table $table) @@ -248,11 +255,10 @@ public function setTable(Table $table) /** * The source table. * - * @return Table + * @return \Propel\Generator\Model\Table */ public function getTable() { return $this->table; } - } diff --git a/src/Propel/Generator/Model/Database.php b/src/Propel/Generator/Model/Database.php index 0fd2823099..5d5fa43988 100644 --- a/src/Propel/Generator/Model/Database.php +++ b/src/Propel/Generator/Model/Database.php @@ -10,7 +10,6 @@ namespace Propel\Generator\Model; -use Propel\Generator\Config\GeneratorConfigInterface; use Propel\Generator\Exception\EngineException; use Propel\Generator\Exception\InvalidArgumentException; use Propel\Generator\Platform\PlatformInterface; @@ -33,12 +32,12 @@ class Database extends ScopedMappingModel /** * The database's platform. * - * @var PlatformInterface|null + * @var \Propel\Generator\Platform\PlatformInterface|null */ private $platform; /** - * @var Table[] + * @var \Propel\Generator\Model\Table[] */ private $tables = []; @@ -96,27 +95,27 @@ class Database extends ScopedMappingModel private $heavyIndexing = false; /** - * @var boolean + * @var bool */ private $identifierQuoting = false; /** - * @var Schema + * @var \Propel\Generator\Model\Schema */ private $parentSchema; /** - * @var Table[] + * @var \Propel\Generator\Model\Table[] */ private $tablesByName = []; /** - * @var Table[] + * @var \Propel\Generator\Model\Table[] */ private $tablesByLowercaseName = []; /** - * @var Table[] + * @var \Propel\Generator\Model\Table[] */ private $tablesByPhpName = []; @@ -138,26 +137,26 @@ class Database extends ScopedMappingModel /** * Constructs a new Database object. * - * @param string|null $name The database's name - * @param PlatformInterface|null $platform The database's platform + * @param string|null $name The database's name + * @param \Propel\Generator\Platform\PlatformInterface|null $platform The database's platform */ - public function __construct($name = null, PlatformInterface $platform = null) + public function __construct($name = null, ?PlatformInterface $platform = null) { parent::__construct(); - if (null !== $name) { + if ($name !== null) { $this->setName($name); } - if (null !== $platform) { + if ($platform !== null) { $this->setPlatform($platform); } - $this->defaultPhpNamingMethod = NameGeneratorInterface::CONV_METHOD_UNDERSCORE; - $this->defaultIdMethod = IdMethod::NATIVE; - $this->defaultStringFormat = static::DEFAULT_STRING_FORMAT; + $this->defaultPhpNamingMethod = NameGeneratorInterface::CONV_METHOD_UNDERSCORE; + $this->defaultIdMethod = IdMethod::NATIVE; + $this->defaultStringFormat = static::DEFAULT_STRING_FORMAT; $this->defaultAccessorVisibility = static::VISIBILITY_PUBLIC; - $this->defaultMutatorVisibility = static::VISIBILITY_PUBLIC; + $this->defaultMutatorVisibility = static::VISIBILITY_PUBLIC; } /** @@ -181,7 +180,7 @@ protected function setupObject() /** * Returns the PlatformInterface implementation for this database. * - * @return PlatformInterface|null + * @return \Propel\Generator\Platform\PlatformInterface|null */ public function getPlatform() { @@ -191,10 +190,11 @@ public function getPlatform() /** * Sets the PlatformInterface implementation for this database. * - * @param PlatformInterface|null $platform A Platform implementation + * @param \Propel\Generator\Platform\PlatformInterface|null $platform A Platform implementation + * * @return void */ - public function setPlatform(PlatformInterface $platform = null) + public function setPlatform(?PlatformInterface $platform = null) { $this->platform = $platform; } @@ -202,7 +202,7 @@ public function setPlatform(PlatformInterface $platform = null) /** * Returns the max column name's length. * - * @return integer + * @return int */ public function getMaxColumnNameLength() { @@ -223,6 +223,7 @@ public function getName() * Sets the database name. * * @param string $name + * * @return void */ public function setName($name) @@ -257,6 +258,7 @@ public function getBaseQueryClass() * This parameter is overridden at the table level. * * @param string $class. + * * @return void */ public function setBaseClass($class) @@ -269,6 +271,7 @@ public function setBaseClass($class) * This parameter is overridden at the table level. * * @param string $class. + * * @return void */ public function setBaseQueryClass($class) @@ -292,6 +295,7 @@ public function getDefaultIdMethod() * This parameter can be overridden at the table level. * * @param string $strategy + * * @return void */ public function setDefaultIdMethod($strategy) @@ -315,6 +319,7 @@ public function getDefaultPhpNamingMethod() * Sets name of the default PHP naming method strategy. * * @param string $strategy + * * @return void */ public function setDefaultPhpNamingMethod($strategy) @@ -338,8 +343,10 @@ public static function getSupportedStringFormats() * * Any of 'XML', 'YAML', 'JSON', or 'CSV'. * - * @param string $format - * @throws InvalidArgumentException + * @param string $format + * + * @throws \Propel\Generator\Exception\InvalidArgumentException + * * @return void */ public function setDefaultStringFormat($format) @@ -370,7 +377,7 @@ public function getDefaultStringFormat() * * This is an alias for getHeavyIndexing(). * - * @return boolean + * @return bool */ public function isHeavyIndexing() { @@ -382,7 +389,7 @@ public function isHeavyIndexing() * * This is an alias for isHeavyIndexing(). * - * @return boolean + * @return bool */ public function getHeavyIndexing() { @@ -392,18 +399,19 @@ public function getHeavyIndexing() /** * Sets whether or not heavy indexing is enabled. * - * @param boolean $flag + * @param bool $flag + * * @return void */ public function setHeavyIndexing($flag = true) { - $this->heavyIndexing = (bool) $flag; + $this->heavyIndexing = (bool)$flag; } /** * Return the list of all tables. * - * @return Table[] + * @return \Propel\Generator\Model\Table[] */ public function getTables() { @@ -415,7 +423,7 @@ public function getTables() * * Read-only tables are excluded from the count. * - * @return integer + * @return int */ public function countTables() { @@ -432,7 +440,7 @@ public function countTables() /** * Returns the list of all tables that have a SQL representation. * - * @return Table[] + * @return \Propel\Generator\Model\Table[] */ public function getTablesForSql() { @@ -449,14 +457,15 @@ public function getTablesForSql() /** * Returns whether or not the database has a table. * - * @param string $name - * @param boolean $caseInsensitive - * @return boolean + * @param string $name + * @param bool $caseInsensitive + * + * @return bool */ public function hasTable($name, $caseInsensitive = false) { if ($caseInsensitive) { - return isset($this->tablesByLowercaseName[ strtolower($name) ]); + return isset($this->tablesByLowercaseName[strtolower($name)]); } return isset($this->tablesByName[$name]); @@ -465,14 +474,17 @@ public function hasTable($name, $caseInsensitive = false) /** * Returns the table with the specified name. * - * @param string $name - * @param boolean $caseInsensitive - * @return Table|null + * @param string $name + * @param bool $caseInsensitive + * + * @return \Propel\Generator\Model\Table|null */ public function getTable($name, $caseInsensitive = false) { - if ($this->getSchema() && $this->getPlatform()->supportsSchemas() - && false === strpos($name, $this->getPlatform()->getSchemaDelimiter())) { + if ( + $this->getSchema() && $this->getPlatform()->supportsSchemas() + && strpos($name, $this->getPlatform()->getSchemaDelimiter()) === false + ) { $name = $this->getSchema() . $this->getPlatform()->getSchemaDelimiter() . $name; } @@ -491,8 +503,9 @@ public function getTable($name, $caseInsensitive = false) * Returns whether or not the database has a table identified by its * PHP name. * - * @param string $phpName - * @return boolean + * @param string $phpName + * + * @return bool */ public function hasTableByPhpName($phpName) { @@ -502,8 +515,9 @@ public function hasTableByPhpName($phpName) /** * Returns the table object with the specified PHP name. * - * @param string $phpName - * @return Table|null + * @param string $phpName + * + * @return \Propel\Generator\Model\Table|null */ public function getTableByPhpName($phpName) { @@ -517,7 +531,8 @@ public function getTableByPhpName($phpName) /** * Adds several tables at once. * - * @param Table[] $tables An array of Table instances + * @param \Propel\Generator\Model\Table[] $tables An array of Table instances + * * @return void */ public function addTables(array $tables) @@ -535,7 +550,7 @@ public function addTables(array $tables) public function removeTable(Table $table) { if ($this->hasTable($table->getName(), true)) { - foreach($this->tables as $id => $tableExam) { + foreach ($this->tables as $id => $tableExam) { if ($table->getName() === $tableExam->getName()) { unset($this->tables[$id]); } @@ -550,8 +565,11 @@ public function removeTable(Table $table) /** * Adds a new table to this database. * - * @param Table|array $table - * @return Table + * @param \Propel\Generator\Model\Table|array $table + * + * @throws \Propel\Generator\Exception\EngineException + * + * @return \Propel\Generator\Model\Table */ public function addTable($table) { @@ -576,7 +594,7 @@ public function addTable($table) $this->computeTableNamespace($table); - if (null === $table->getPackage()) { + if ($table->getPackage() === null) { $table->setPackage($this->getPackage()); } @@ -585,6 +603,7 @@ public function addTable($table) /** * @param string[] $sequences + * * @return void */ public function setSequences($sequences) @@ -602,6 +621,7 @@ public function getSequences() /** * @param string $sequence + * * @return void */ public function addSequence($sequence) @@ -611,19 +631,21 @@ public function addSequence($sequence) /** * @param string $sequence + * * @return void */ public function removeSequence($sequence) { if ($this->sequences) { - if (false !== ($idx = array_search($sequence, $this->sequences))) { + if (($idx = array_search($sequence, $this->sequences)) !== false) { unset($this->sequences[$idx]); } } } /** - * @param string $sequence + * @param string $sequence + * * @return bool */ public function hasSequence($sequence) @@ -648,6 +670,7 @@ public function getSchemaDelimiter() * Sets the database's schema. * * @param string $schema + * * @return void */ public function setSchema($schema) @@ -658,12 +681,12 @@ public function setSchema($schema) $fixHash = function (&$array) use ($schema, $oldSchema, $schemaDelimiter) { foreach ($array as $k => $v) { if ($schema && $this->getPlatform()->supportsSchemas()) { - if (false === strpos($k, $schemaDelimiter)) { + if (strpos($k, $schemaDelimiter) === false) { $array[$schema . $schemaDelimiter . $k] = $v; unset($array[$k]); } } elseif ($oldSchema) { - if (false !== strpos($k, $schemaDelimiter)) { + if (strpos($k, $schemaDelimiter) !== false) { $array[explode($schemaDelimiter, $k)[1]] = $v; unset($array[$k]); } @@ -681,7 +704,8 @@ public function setSchema($schema) * Computes the table namespace based on the current relative or * absolute table namespace and the database namespace. * - * @param Table $table + * @param \Propel\Generator\Model\Table $table + * * @return string */ private function computeTableNamespace(Table $table) @@ -696,7 +720,7 @@ private function computeTableNamespace(Table $table) if ($namespace = $this->getNamespace()) { if ($table->getNamespace()) { - $namespace .= '\\'.$table->getNamespace(); + $namespace .= '\\' . $table->getNamespace(); } $table->setNamespace($namespace); @@ -708,7 +732,8 @@ private function computeTableNamespace(Table $table) /** * Sets the parent schema * - * @param Schema $parent The parent schema + * @param \Propel\Generator\Model\Schema $parent The parent schema + * * @return void */ public function setParentSchema(Schema $parent) @@ -719,7 +744,7 @@ public function setParentSchema(Schema $parent) /** * Returns the parent schema * - * @return Schema + * @return \Propel\Generator\Model\Schema */ public function getParentSchema() { @@ -729,8 +754,9 @@ public function getParentSchema() /** * Adds a domain object to this database. * - * @param Domain|array $data - * @return Domain + * @param \Propel\Generator\Model\Domain|array $data + * + * @return \Propel\Generator\Model\Domain */ public function addDomain($data) { @@ -752,8 +778,9 @@ public function addDomain($data) /** * Returns the already configured domain object by its name. * - * @param string $name - * @return Domain|null + * @param string $name + * + * @return \Propel\Generator\Model\Domain|null */ public function getDomain($name) { @@ -783,7 +810,8 @@ public function getGeneratorConfig() * * @see \Propel\Common\Config\ConfigurationManager::getConfigProperty() method * - * @param string $name + * @param string $name + * * @return string */ public function getBuildProperty($name) @@ -810,6 +838,7 @@ public function getTablePrefix() * Sets the tables' prefix. * * @param string $tablePrefix + * * @return void */ public function setTablePrefix($tablePrefix) @@ -821,7 +850,7 @@ public function setTablePrefix($tablePrefix) * Returns the next behavior on all tables, ordered by behavior priority, * and skipping the ones that were already executed. * - * @return Behavior + * @return \Propel\Generator\Model\Behavior */ public function getNextTableBehavior() { @@ -903,25 +932,27 @@ public function __toString() foreach ($this->getTables() as $table) { $columns = []; foreach ($table->getColumns() as $column) { - $columns[] = sprintf(" %s %s %s %s %s %s %s", + $columns[] = sprintf( + ' %s %s %s %s %s %s %s', $column->getName(), $column->getType(), $column->getSize() ? '(' . $column->getSize() . ')' : '', $column->isPrimaryKey() ? 'PK' : '', $column->isNotNull() ? 'NOT NULL' : '', - $column->getDefaultValueString() ? "'".$column->getDefaultValueString()."'" : '', + $column->getDefaultValueString() ? "'" . $column->getDefaultValueString() . "'" : '', $column->isAutoIncrement() ? 'AUTO_INCREMENT' : '' ); } $fks = []; foreach ($table->getForeignKeys() as $fk) { - $fks[] = sprintf(" %s to %s.%s (%s => %s)", + $fks[] = sprintf( + ' %s to %s.%s (%s => %s)', $fk->getName(), $fk->getForeignSchemaName(), $fk->getForeignTableCommonName(), - join(', ', $fk->getLocalColumns()), - join(', ', $fk->getForeignColumns()) + implode(', ', $fk->getLocalColumns()), + implode(', ', $fk->getForeignColumns()) ); } @@ -931,21 +962,24 @@ public function __toString() foreach ($index->getColumns() as $indexColumnName) { $indexColumns[] = sprintf('%s (%s)', $indexColumnName, $index->getColumnSize($indexColumnName)); } - $indices[] = sprintf(" %s (%s)", + $indices[] = sprintf( + ' %s (%s)', $index->getName(), - join(', ', $indexColumns) + implode(', ', $indexColumns) ); } $unices = []; foreach ($table->getUnices() as $index) { - $unices[] = sprintf(" %s (%s)", + $unices[] = sprintf( + ' %s (%s)', $index->getName(), - join(', ', $index->getColumns()) + implode(', ', $index->getColumns()) ); } - $tableDef = sprintf(" %s (%s):\n%s", + $tableDef = sprintf( + " %s (%s):\n%s", $table->getName(), $table->getCommonName(), implode("\n", $columns) @@ -960,14 +994,15 @@ public function __toString() } if ($unices) { - $tableDef .= "\n unices:\n". implode("\n", $unices); + $tableDef .= "\n unices:\n" . implode("\n", $unices); } $tables[] = $tableDef; } - return sprintf("%s:\n%s", - $this->getName() . ($this->getSchema() ? '.'. $this->getSchema() : ''), + return sprintf( + "%s:\n%s", + $this->getName() . ($this->getSchema() ? '.' . $this->getSchema() : ''), implode("\n", $tables) ); } @@ -976,6 +1011,7 @@ public function __toString() * Sets the default accessor visibility. * * @param string $defaultAccessorVisibility + * * @return void */ public function setDefaultAccessorVisibility($defaultAccessorVisibility) @@ -997,6 +1033,7 @@ public function getDefaultAccessorVisibility() * Sets the default mutator visibility. * * @param string $defaultMutatorVisibility + * * @return void */ public function setDefaultMutatorVisibility($defaultMutatorVisibility) @@ -1031,7 +1068,7 @@ public function __clone() } /** - * @return boolean + * @return bool */ public function isIdentifierQuotingEnabled() { @@ -1039,12 +1076,12 @@ public function isIdentifierQuotingEnabled() } /** - * @param boolean $identifierQuoting + * @param bool $identifierQuoting + * * @return void */ public function setIdentifierQuoting($identifierQuoting) { $this->identifierQuoting = $identifierQuoting; } - } diff --git a/src/Propel/Generator/Model/Diff/ColumnComparator.php b/src/Propel/Generator/Model/Diff/ColumnComparator.php index fd743434b1..ec99bf2db6 100644 --- a/src/Propel/Generator/Model/Diff/ColumnComparator.php +++ b/src/Propel/Generator/Model/Diff/ColumnComparator.php @@ -22,9 +22,10 @@ class ColumnComparator /** * Compute and return the difference between two column objects * - * @param Column $fromColumn - * @param Column $toColumn - * @return ColumnDiff|boolean return false if the two columns are similar + * @param \Propel\Generator\Model\Column $fromColumn + * @param \Propel\Generator\Model\Column $toColumn + * + * @return \Propel\Generator\Model\Diff\ColumnDiff|bool return false if the two columns are similar */ public static function computeDiff(Column $fromColumn, Column $toColumn) { diff --git a/src/Propel/Generator/Model/Diff/ColumnDiff.php b/src/Propel/Generator/Model/Diff/ColumnDiff.php index 93917de831..5ea74c01ca 100644 --- a/src/Propel/Generator/Model/Diff/ColumnDiff.php +++ b/src/Propel/Generator/Model/Diff/ColumnDiff.php @@ -29,30 +29,30 @@ class ColumnDiff /** * The original column definition. * - * @var Column|null + * @var \Propel\Generator\Model\Column|null */ protected $fromColumn; /** * The modified column definition. * - * @var Column|null + * @var \Propel\Generator\Model\Column|null */ protected $toColumn; /** * Constructor. * - * @param Column|null $fromColumn The original column - * @param Column|null $toColumn The modified column + * @param \Propel\Generator\Model\Column|null $fromColumn The original column + * @param \Propel\Generator\Model\Column|null $toColumn The modified column */ - public function __construct(Column $fromColumn = null, Column $toColumn = null) + public function __construct(?Column $fromColumn = null, ?Column $toColumn = null) { - if (null !== $fromColumn) { + if ($fromColumn !== null) { $this->setFromColumn($fromColumn); } - if (null !== $toColumn) { + if ($toColumn !== null) { $this->setToColumn($toColumn); } } @@ -61,6 +61,7 @@ public function __construct(Column $fromColumn = null, Column $toColumn = null) * Sets for the changed properties. * * @param array $properties + * * @return void */ public function setChangedProperties($properties) @@ -81,7 +82,8 @@ public function getChangedProperties() /** * Sets the fromColumn property. * - * @param Column $fromColumn + * @param \Propel\Generator\Model\Column $fromColumn + * * @return void */ public function setFromColumn(Column $fromColumn) @@ -92,7 +94,7 @@ public function setFromColumn(Column $fromColumn) /** * Returns the fromColumn property. * - * @return Column|null + * @return \Propel\Generator\Model\Column|null */ public function getFromColumn() { @@ -102,7 +104,8 @@ public function getFromColumn() /** * Sets the toColumn property. * - * @param Column $toColumn + * @param \Propel\Generator\Model\Column $toColumn + * * @return void */ public function setToColumn(Column $toColumn) @@ -113,7 +116,7 @@ public function setToColumn(Column $toColumn) /** * Returns the toColumn property. * - * @return Column|null + * @return \Propel\Generator\Model\Column|null */ public function getToColumn() { @@ -123,7 +126,7 @@ public function getToColumn() /** * Returns the reverse diff for this diff. * - * @return ColumnDiff + * @return \Propel\Generator\Model\Diff\ColumnDiff */ public function getReverseDiff() { diff --git a/src/Propel/Generator/Model/Diff/DatabaseComparator.php b/src/Propel/Generator/Model/Diff/DatabaseComparator.php index 137c070f1f..5c1c198264 100644 --- a/src/Propel/Generator/Model/Diff/DatabaseComparator.php +++ b/src/Propel/Generator/Model/Diff/DatabaseComparator.php @@ -21,17 +21,17 @@ class DatabaseComparator { /** - * @var DatabaseDiff + * @var \Propel\Generator\Model\Diff\DatabaseDiff */ protected $databaseDiff; /** - * @var Database + * @var \Propel\Generator\Model\Database */ protected $fromDatabase; /** - * @var Database + * @var \Propel\Generator\Model\Database */ protected $toDatabase; @@ -44,7 +44,7 @@ class DatabaseComparator protected $withRenaming = false; /** - * @var boolean + * @var bool */ protected $removeTable = true; @@ -58,7 +58,7 @@ class DatabaseComparator */ public function __construct($databaseDiff = null) { - $this->databaseDiff = (null === $databaseDiff) ? new DatabaseDiff() : $databaseDiff; + $this->databaseDiff = ($databaseDiff === null) ? new DatabaseDiff() : $databaseDiff; } /** @@ -72,7 +72,8 @@ public function getDatabaseDiff() /** * Sets the fromDatabase property. * - * @param Database $fromDatabase + * @param \Propel\Generator\Model\Database $fromDatabase + * * @return void */ public function setFromDatabase(Database $fromDatabase) @@ -83,7 +84,7 @@ public function setFromDatabase(Database $fromDatabase) /** * Returns the fromDatabase property. * - * @return Database + * @return \Propel\Generator\Model\Database */ public function getFromDatabase() { @@ -93,7 +94,8 @@ public function getFromDatabase() /** * Sets the toDatabase property. * - * @param Database $toDatabase + * @param \Propel\Generator\Model\Database $toDatabase + * * @return void */ public function setToDatabase(Database $toDatabase) @@ -104,7 +106,7 @@ public function setToDatabase(Database $toDatabase) /** * Returns the toDatabase property. * - * @return Database + * @return \Propel\Generator\Model\Database */ public function getToDatabase() { @@ -114,7 +116,8 @@ public function getToDatabase() /** * Set true to handle removed tables or false to ignore them * - * @param boolean $removeTable + * @param bool $removeTable + * * @return void */ public function setRemoveTable($removeTable) @@ -123,7 +126,7 @@ public function setRemoveTable($removeTable) } /** - * @return boolean + * @return bool */ public function getRemoveTable() { @@ -134,6 +137,7 @@ public function getRemoveTable() * Set the list of tables excluded from the comparison * * @param string[] $excludedTables set the list of table name + * * @return void */ public function setExcludedTables(array $excludedTables) @@ -154,13 +158,20 @@ public function getExcludedTables() /** * Returns the computed difference between two database objects. * - * @param Database $fromDatabase - * @param Database $toDatabase - * @param boolean $caseInsensitive - * @return DatabaseDiff|Boolean + * @param \Propel\Generator\Model\Database $fromDatabase + * @param \Propel\Generator\Model\Database $toDatabase + * @param bool $caseInsensitive + * + * @return \Propel\Generator\Model\Diff\DatabaseDiff|bool */ - public static function computeDiff(Database $fromDatabase, Database $toDatabase, $caseInsensitive = false, $withRenaming = false, $removeTable = true, $excludedTables = []) - { + public static function computeDiff( + Database $fromDatabase, + Database $toDatabase, + $caseInsensitive = false, + $withRenaming = false, + $removeTable = true, + $excludedTables = [] + ) { $databaseComparator = new self(); $databaseComparator->setFromDatabase($fromDatabase); $databaseComparator->setToDatabase($toDatabase); @@ -186,7 +197,8 @@ public static function computeDiff(Database $fromDatabase, Database $toDatabase, } /** - * @param boolean $withRenaming + * @param bool $withRenaming + * * @return void */ public function setWithRenaming($withRenaming) @@ -195,7 +207,7 @@ public function setWithRenaming($withRenaming) } /** - * @return boolean + * @return bool */ public function getWithRenaming() { @@ -208,8 +220,9 @@ public function getWithRenaming() * Compares the tables of the fromDatabase and the toDatabase, and modifies * the inner databaseDiff if necessary. * - * @param boolean $caseInsensitive - * @return integer + * @param bool $caseInsensitive + * + * @return int */ public function compareTables($caseInsensitive = false) { @@ -269,6 +282,7 @@ public function compareTables($caseInsensitive = false) } else { $this->databaseDiff->addPossibleRenamedTable($removedTableName, $addedTableName); } + // skip to the next added table break; } @@ -280,6 +294,7 @@ public function compareTables($caseInsensitive = false) /** * @param \Propel\Generator\Model\Table $table + * * @return bool */ protected function isTableExcluded(Table $table) @@ -290,10 +305,11 @@ protected function isTableExcluded(Table $table) } foreach ($this->excludedTables as $exclude_tablename) { - if (preg_match('/^'.str_replace('*', '.*', $exclude_tablename).'$/', $tablename)) { + if (preg_match('/^' . str_replace('*', '.*', $exclude_tablename) . '$/', $tablename)) { return true; } } return false; - }} + } +} diff --git a/src/Propel/Generator/Model/Diff/DatabaseDiff.php b/src/Propel/Generator/Model/Diff/DatabaseDiff.php index de5482eacf..ae0de7d0a3 100644 --- a/src/Propel/Generator/Model/Diff/DatabaseDiff.php +++ b/src/Propel/Generator/Model/Diff/DatabaseDiff.php @@ -24,18 +24,22 @@ class DatabaseDiff * @var \Propel\Generator\Model\Table[] */ protected $addedTables; + /** * @var \Propel\Generator\Model\Table[] */ protected $removedTables; + /** * @var \Propel\Generator\Model\Diff\TableDiff[] */ protected $modifiedTables; + /** * @var string[] */ protected $renamedTables; + /** * @var string[] */ @@ -43,17 +47,18 @@ class DatabaseDiff public function __construct() { - $this->addedTables = []; - $this->removedTables = []; + $this->addedTables = []; + $this->removedTables = []; $this->modifiedTables = []; - $this->renamedTables = []; - $this->possibleRenamedTables = []; + $this->renamedTables = []; + $this->possibleRenamedTables = []; } /** * Sets the added tables. * * @param array $tables + * * @return void */ public function setAddedTables($tables) @@ -65,7 +70,8 @@ public function setAddedTables($tables) * Adds an added table. * * @param string $name - * @param Table $table + * @param \Propel\Generator\Model\Table $table + * * @return void */ public function addAddedTable($name, Table $table) @@ -77,6 +83,7 @@ public function addAddedTable($name, Table $table) * Removes an added table. * * @param string $name + * * @return void */ public function removeAddedTable($name) @@ -97,6 +104,7 @@ public function getPossibleRenamedTables() * * @param string $fromName * @param string $toName + * * @return void */ public function addPossibleRenamedTable($fromName, $toName) @@ -107,7 +115,7 @@ public function addPossibleRenamedTable($fromName, $toName) /** * Returns the list of added tables. * - * @return Table[] + * @return \Propel\Generator\Model\Table[] */ public function getAddedTables() { @@ -117,7 +125,7 @@ public function getAddedTables() /** * Returns the number of added tables. * - * @return integer + * @return int */ public function countAddedTables() { @@ -140,6 +148,7 @@ public function getAddedTable($name) * Sets the removes tables. * * @param \Propel\Generator\Model\Table[] $tables + * * @return void */ public function setRemovedTables($tables) @@ -151,7 +160,8 @@ public function setRemovedTables($tables) * Adds a table to remove. * * @param string $name - * @param Table $table + * @param \Propel\Generator\Model\Table $table + * * @return void */ public function addRemovedTable($name, Table $table) @@ -163,6 +173,7 @@ public function addRemovedTable($name, Table $table) * Removes a removed table. * * @param string $name + * * @return void */ public function removeRemovedTable($name) @@ -173,7 +184,7 @@ public function removeRemovedTable($name) /** * Returns the list of removed tables. * - * @return Table[] + * @return \Propel\Generator\Model\Table[] */ public function getRemovedTables() { @@ -183,7 +194,7 @@ public function getRemovedTables() /** * Returns the number of removed tables. * - * @return integer + * @return int */ public function countRemovedTables() { @@ -206,6 +217,7 @@ public function getRemovedTable($name) * Sets the modified tables * * @param \Propel\Generator\Model\Diff\TableDiff[] $tables + * * @return void */ public function setModifiedTables($tables) @@ -216,8 +228,9 @@ public function setModifiedTables($tables) /** * Adds a table difference. * - * @param string $name - * @param TableDiff $difference + * @param string $name + * @param \Propel\Generator\Model\Diff\TableDiff $difference + * * @return void */ public function addModifiedTable($name, TableDiff $difference) @@ -228,7 +241,7 @@ public function addModifiedTable($name, TableDiff $difference) /** * Returns the number of modified tables. * - * @return integer + * @return int */ public function countModifiedTables() { @@ -238,7 +251,7 @@ public function countModifiedTables() /** * Returns the modified tables. * - * @return TableDiff[] + * @return \Propel\Generator\Model\Diff\TableDiff[] */ public function getModifiedTables() { @@ -249,6 +262,7 @@ public function getModifiedTables() * Sets the renamed tables. * * @param string[] $tables + * * @return void */ public function setRenamedTables($tables) @@ -261,6 +275,7 @@ public function setRenamedTables($tables) * * @param string $fromName * @param string $toName + * * @return void */ public function addRenamedTable($fromName, $toName) @@ -281,7 +296,7 @@ public function getRenamedTables() /** * Returns the number of renamed tables. * - * @return integer + * @return int */ public function countRenamedTables() { @@ -291,7 +306,7 @@ public function countRenamedTables() /** * Returns the reverse diff for this diff. * - * @return DatabaseDiff + * @return \Propel\Generator\Model\Diff\DatabaseDiff */ public function getReverseDiff() { diff --git a/src/Propel/Generator/Model/Diff/ForeignKeyComparator.php b/src/Propel/Generator/Model/Diff/ForeignKeyComparator.php index 5d42bacd2d..db8916ffc9 100644 --- a/src/Propel/Generator/Model/Diff/ForeignKeyComparator.php +++ b/src/Propel/Generator/Model/Diff/ForeignKeyComparator.php @@ -16,28 +16,25 @@ * Service class for comparing ForeignKey objects * Heavily inspired by Doctrine2's Migrations * (see http://github.com/doctrine/dbal/tree/master/lib/Doctrine/DBAL/Schema/) - * */ class ForeignKeyComparator { /** * Compute the difference between two Foreign key objects * - * @param ForeignKey $fromFk - * @param ForeignKey $toFk - * - * @param boolean $caseInsensitive Whether the comparison is case insensitive. - * False by default. + * @param \Propel\Generator\Model\ForeignKey $fromFk + * @param \Propel\Generator\Model\ForeignKey $toFk + * @param bool $caseInsensitive Whether the comparison is case insensitive. + * False by default. * - * @return boolean false if the two fks are similar, true if they have differences + * @return bool false if the two fks are similar, true if they have differences */ public static function computeDiff(ForeignKey $fromFk, ForeignKey $toFk, $caseInsensitive = false) { // Check for differences in local and remote table $test = $caseInsensitive ? strtolower($fromFk->getTableName()) !== strtolower($toFk->getTableName()) : - $fromFk->getTableName() !== $toFk->getTableName() - ; + $fromFk->getTableName() !== $toFk->getTableName(); if ($test) { return true; @@ -45,8 +42,7 @@ public static function computeDiff(ForeignKey $fromFk, ForeignKey $toFk, $caseIn $test = $caseInsensitive ? strtolower($fromFk->getForeignTableName()) !== strtolower($toFk->getForeignTableName()) : - $fromFk->getForeignTableName() !== $toFk->getForeignTableName() - ; + $fromFk->getForeignTableName() !== $toFk->getForeignTableName(); if ($test) { return true; @@ -79,5 +75,4 @@ public static function computeDiff(ForeignKey $fromFk, ForeignKey $toFk, $caseIn // compare skipSql return $fromFk->isSkipSql() !== $toFk->isSkipSql(); } - } diff --git a/src/Propel/Generator/Model/Diff/IndexComparator.php b/src/Propel/Generator/Model/Diff/IndexComparator.php index 1882e9253d..7a833ff4bf 100644 --- a/src/Propel/Generator/Model/Diff/IndexComparator.php +++ b/src/Propel/Generator/Model/Diff/IndexComparator.php @@ -22,10 +22,11 @@ class IndexComparator /** * Computes the difference between two index objects. * - * @param Index $fromIndex - * @param Index $toIndex - * @param boolean $caseInsensitive - * @return boolean + * @param \Propel\Generator\Model\Index $fromIndex + * @param \Propel\Generator\Model\Index $toIndex + * @param bool $caseInsensitive + * + * @return bool */ public static function computeDiff(Index $fromIndex, Index $toIndex, $caseInsensitive = false) { diff --git a/src/Propel/Generator/Model/Diff/TableComparator.php b/src/Propel/Generator/Model/Diff/TableComparator.php index ff89e5b78e..5880f8b881 100644 --- a/src/Propel/Generator/Model/Diff/TableComparator.php +++ b/src/Propel/Generator/Model/Diff/TableComparator.php @@ -22,24 +22,24 @@ class TableComparator /** * The table difference. * - * @var TableDiff + * @var \Propel\Generator\Model\Diff\TableDiff */ protected $tableDiff; /** * Constructor. * - * @param TableDiff $tableDiff + * @param \Propel\Generator\Model\Diff\TableDiff|null $tableDiff */ - public function __construct(TableDiff $tableDiff = null) + public function __construct(?TableDiff $tableDiff = null) { - $this->tableDiff = (null === $tableDiff) ? new TableDiff() : $tableDiff; + $this->tableDiff = ($tableDiff === null) ? new TableDiff() : $tableDiff; } /** * Returns the table difference. * - * @return TableDiff + * @return \Propel\Generator\Model\Diff\TableDiff */ public function getTableDiff() { @@ -50,6 +50,7 @@ public function getTableDiff() * Sets the table the comparator starts from. * * @param \Propel\Generator\Model\Table $fromTable + * * @return void */ public function setFromTable(Table $fromTable) @@ -60,7 +61,7 @@ public function setFromTable(Table $fromTable) /** * Returns the table the comparator starts from. * - * @return Table + * @return \Propel\Generator\Model\Table */ public function getFromTable() { @@ -71,6 +72,7 @@ public function getFromTable() * Sets the table the comparator goes to. * * @param \Propel\Generator\Model\Table $toTable + * * @return void */ public function setToTable(Table $toTable) @@ -81,7 +83,7 @@ public function setToTable(Table $toTable) /** * Returns the table the comparator goes to. * - * @return Table + * @return \Propel\Generator\Model\Table */ public function getToTable() { @@ -91,10 +93,11 @@ public function getToTable() /** * Returns the computed difference between two table objects. * - * @param Table $fromTable - * @param Table $toTable - * @param boolean $caseInsensitive - * @return TableDiff|Boolean + * @param \Propel\Generator\Model\Table $fromTable + * @param \Propel\Generator\Model\Table $toTable + * @param bool $caseInsensitive + * + * @return \Propel\Generator\Model\Diff\TableDiff|bool */ public static function computeDiff(Table $fromTable, Table $toTable, $caseInsensitive = false) { @@ -118,8 +121,9 @@ public static function computeDiff(Table $fromTable, Table $toTable, $caseInsens * Compares the columns of the fromTable and the toTable, * and modifies the inner tableDiff if necessary. * - * @param boolean $caseInsensitive - * @return integer + * @param bool $caseInsensitive + * + * @return int */ public function compareColumns($caseInsensitive = false) { @@ -164,6 +168,7 @@ public function compareColumns($caseInsensitive = false) $this->tableDiff->removeAddedColumn($addedColumnName); $this->tableDiff->removeRemovedColumn($removedColumnName); $columnDifferences--; + // skip to the next added column break; } @@ -179,8 +184,9 @@ public function compareColumns($caseInsensitive = false) * Compares the primary keys of the fromTable and the toTable, * and modifies the inner tableDiff if necessary. * - * @param boolean $caseInsensitive - * @return integer + * @param bool $caseInsensitive + * + * @return int */ public function comparePrimaryKeys($caseInsensitive = false) { @@ -190,8 +196,10 @@ public function comparePrimaryKeys($caseInsensitive = false) // check for new pk columns in $toTable foreach ($toTablePk as $column) { - if (!$this->getFromTable()->hasColumn($column->getName(), $caseInsensitive) || - !$this->getFromTable()->getColumn($column->getName(), $caseInsensitive)->isPrimaryKey()) { + if ( + !$this->getFromTable()->hasColumn($column->getName(), $caseInsensitive) || + !$this->getFromTable()->getColumn($column->getName(), $caseInsensitive)->isPrimaryKey() + ) { $this->tableDiff->addAddedPkColumn($column->getName(), $column); $pkDifferences++; } @@ -199,8 +207,10 @@ public function comparePrimaryKeys($caseInsensitive = false) // check for removed pk columns in $toTable foreach ($fromTablePk as $column) { - if (!$this->getToTable()->hasColumn($column->getName(), $caseInsensitive) || - !$this->getToTable()->getColumn($column->getName(), $caseInsensitive)->isPrimaryKey()) { + if ( + !$this->getToTable()->hasColumn($column->getName(), $caseInsensitive) || + !$this->getToTable()->getColumn($column->getName(), $caseInsensitive)->isPrimaryKey() + ) { $this->tableDiff->addRemovedPkColumn($column->getName(), $column); $pkDifferences++; } @@ -215,6 +225,7 @@ public function comparePrimaryKeys($caseInsensitive = false) $this->tableDiff->removeAddedPkColumn($addedColumnName); $this->tableDiff->removeRemovedPkColumn($removedColumnName); $pkDifferences--; + // skip to the next added column break; } @@ -230,8 +241,9 @@ public function comparePrimaryKeys($caseInsensitive = false) * Compare the indices and unique indices of the fromTable and the toTable, * and modifies the inner tableDiff if necessary. * - * @param boolean $caseInsensitive - * @return integer + * @param bool $caseInsensitive + * + * @return int */ public function compareIndices($caseInsensitive = false) { @@ -245,7 +257,7 @@ public function compareIndices($caseInsensitive = false) strtolower($fromTableIndex->getName()) == strtolower($toTableIndex->getName()) : $fromTableIndex->getName() == $toTableIndex->getName(); if ($sameName) { - if (false === IndexComparator::computeDiff($fromTableIndex, $toTableIndex, $caseInsensitive)) { + if (IndexComparator::computeDiff($fromTableIndex, $toTableIndex, $caseInsensitive) === false) { //no changes unset($fromTableIndices[$fromTableIndexPos]); unset($toTableIndices[$toTableIndexPos]); @@ -279,8 +291,9 @@ public function compareIndices($caseInsensitive = false) * Compare the foreign keys of the fromTable and the toTable, * and modifies the inner tableDiff if necessary. * - * @param boolean $caseInsensitive - * @return integer + * @param bool $caseInsensitive + * + * @return int */ public function compareForeignKeys($caseInsensitive = false) { @@ -294,7 +307,7 @@ public function compareForeignKeys($caseInsensitive = false) strtolower($fromTableFk->getName()) == strtolower($toTableFk->getName()) : $fromTableFk->getName() == $toTableFk->getName(); if ($sameName && !$toTableFk->isPolymorphic()) { - if (false === ForeignKeyComparator::computeDiff($fromTableFk, $toTableFk, $caseInsensitive)) { + if (ForeignKeyComparator::computeDiff($fromTableFk, $toTableFk, $caseInsensitive) === false) { unset($fromTableFks[$fromTableFkPos]); unset($toTableFks[$toTableFkPos]); } else { diff --git a/src/Propel/Generator/Model/Diff/TableDiff.php b/src/Propel/Generator/Model/Diff/TableDiff.php index 2dadaa9b01..932ed42026 100644 --- a/src/Propel/Generator/Model/Diff/TableDiff.php +++ b/src/Propel/Generator/Model/Diff/TableDiff.php @@ -26,35 +26,35 @@ class TableDiff /** * The first Table object. * - * @var Table|null + * @var \Propel\Generator\Model\Table|null */ protected $fromTable; /** * The second Table object. * - * @var Table|null + * @var \Propel\Generator\Model\Table|null */ protected $toTable; /** * The list of added columns. * - * @var Column[] + * @var \Propel\Generator\Model\Column[] */ protected $addedColumns; /** * The list of removed columns. * - * @var Column[] + * @var \Propel\Generator\Model\Column[] */ protected $removedColumns; /** * The list of modified columns. * - * @var ColumnDiff[] + * @var \Propel\Generator\Model\Diff\ColumnDiff[] */ protected $modifiedColumns; @@ -68,14 +68,14 @@ class TableDiff /** * The list of added primary key columns. * - * @var Column[] + * @var \Propel\Generator\Model\Column[] */ protected $addedPkColumns; /** * The list of removed primary key columns. * - * @var Column[] + * @var \Propel\Generator\Model\Column[] */ protected $removedPkColumns; @@ -117,7 +117,7 @@ class TableDiff /** * The list of removed foreign keys. * - * @var ForeignKey[] + * @var \Propel\Generator\Model\ForeignKey[] */ protected $removedFks; @@ -131,38 +131,39 @@ class TableDiff /** * Constructor. * - * @param \Propel\Generator\Model\Table $fromTable The first table - * @param \Propel\Generator\Model\Table $toTable The second table + * @param \Propel\Generator\Model\Table|null $fromTable The first table + * @param \Propel\Generator\Model\Table|null $toTable The second table */ - public function __construct(Table $fromTable = null, Table $toTable = null) + public function __construct(?Table $fromTable = null, ?Table $toTable = null) { - if (null !== $fromTable) { + if ($fromTable !== null) { $this->setFromTable($fromTable); } - if (null !== $toTable) { + if ($toTable !== null) { $this->setToTable($toTable); } - $this->addedColumns = []; - $this->removedColumns = []; - $this->modifiedColumns = []; - $this->renamedColumns = []; - $this->addedPkColumns = []; + $this->addedColumns = []; + $this->removedColumns = []; + $this->modifiedColumns = []; + $this->renamedColumns = []; + $this->addedPkColumns = []; $this->removedPkColumns = []; $this->renamedPkColumns = []; - $this->addedIndices = []; - $this->modifiedIndices = []; - $this->removedIndices = []; - $this->addedFks = []; - $this->modifiedFks = []; - $this->removedFks = []; + $this->addedIndices = []; + $this->modifiedIndices = []; + $this->removedIndices = []; + $this->addedFks = []; + $this->modifiedFks = []; + $this->removedFks = []; } /** * Sets the fromTable property. * * @param \Propel\Generator\Model\Table $fromTable + * * @return void */ public function setFromTable(Table $fromTable) @@ -173,7 +174,7 @@ public function setFromTable(Table $fromTable) /** * Returns the fromTable property. * - * @return Table|null + * @return \Propel\Generator\Model\Table|null */ public function getFromTable() { @@ -184,6 +185,7 @@ public function getFromTable() * Sets the toTable property. * * @param \Propel\Generator\Model\Table $toTable + * * @return void */ public function setToTable(Table $toTable) @@ -194,7 +196,7 @@ public function setToTable(Table $toTable) /** * Returns the toTable property. * - * @return Table + * @return \Propel\Generator\Model\Table */ public function getToTable() { @@ -204,7 +206,8 @@ public function getToTable() /** * Sets the added columns. * - * @param Column[] $columns + * @param \Propel\Generator\Model\Column[] $columns + * * @return void */ public function setAddedColumns(array $columns) @@ -219,7 +222,8 @@ public function setAddedColumns(array $columns) * Adds an added column. * * @param string $name - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function addAddedColumn($name, Column $column) @@ -231,6 +235,7 @@ public function addAddedColumn($name, Column $column) * Removes an added column. * * @param string $columnName + * * @return void */ public function removeAddedColumn($columnName) @@ -243,7 +248,7 @@ public function removeAddedColumn($columnName) /** * Returns the list of added columns * - * @return Column[] + * @return \Propel\Generator\Model\Column[] */ public function getAddedColumns() { @@ -253,8 +258,9 @@ public function getAddedColumns() /** * Returns an added column by its name. * - * @param string $columnName - * @return Column|null + * @param string $columnName + * + * @return \Propel\Generator\Model\Column|null */ public function getAddedColumn($columnName) { @@ -268,7 +274,8 @@ public function getAddedColumn($columnName) /** * Setter for the removedColumns property * - * @param Column[] $removedColumns + * @param \Propel\Generator\Model\Column[] $removedColumns + * * @return void */ public function setRemovedColumns(array $removedColumns) @@ -283,7 +290,8 @@ public function setRemovedColumns(array $removedColumns) * Adds a removed column. * * @param string $columnName - * @param Column $removedColumn + * @param \Propel\Generator\Model\Column $removedColumn + * * @return void */ public function addRemovedColumn($columnName, Column $removedColumn) @@ -295,6 +303,7 @@ public function addRemovedColumn($columnName, Column $removedColumn) * Removes a removed column. * * @param string $columnName + * * @return void */ public function removeRemovedColumn($columnName) @@ -305,7 +314,7 @@ public function removeRemovedColumn($columnName) /** * Getter for the removedColumns property. * - * @return Column[] + * @return \Propel\Generator\Model\Column[] */ public function getRemovedColumns() { @@ -317,7 +326,7 @@ public function getRemovedColumns() * * @param string $columnName * - * @return Column|null + * @return \Propel\Generator\Model\Column|null */ public function getRemovedColumn($columnName) { @@ -331,7 +340,8 @@ public function getRemovedColumn($columnName) /** * Sets the list of modified columns. * - * @param ColumnDiff[] $modifiedColumns An associative array of ColumnDiff objects + * @param \Propel\Generator\Model\Diff\ColumnDiff[] $modifiedColumns An associative array of ColumnDiff objects + * * @return void */ public function setModifiedColumns(array $modifiedColumns) @@ -345,8 +355,9 @@ public function setModifiedColumns(array $modifiedColumns) /** * Add a column difference * - * @param string $columnName - * @param ColumnDiff $modifiedColumn + * @param string $columnName + * @param \Propel\Generator\Model\Diff\ColumnDiff $modifiedColumn + * * @return void */ public function addModifiedColumn($columnName, ColumnDiff $modifiedColumn) @@ -357,7 +368,7 @@ public function addModifiedColumn($columnName, ColumnDiff $modifiedColumn) /** * Getter for the modifiedColumns property * - * @return ColumnDiff[] + * @return \Propel\Generator\Model\Diff\ColumnDiff[] */ public function getModifiedColumns() { @@ -368,13 +379,14 @@ public function getModifiedColumns() * Sets the list of renamed columns. * * @param array $renamedColumns + * * @return void */ public function setRenamedColumns(array $renamedColumns) { $this->renamedColumns = []; foreach ($renamedColumns as $columns) { - list($fromColumn, $toColumn) = $columns; + [$fromColumn, $toColumn] = $columns; $this->addRenamedColumn($fromColumn, $toColumn); } } @@ -382,8 +394,9 @@ public function setRenamedColumns(array $renamedColumns) /** * Add a renamed column * - * @param Column $fromColumn - * @param Column $toColumn + * @param \Propel\Generator\Model\Column $fromColumn + * @param \Propel\Generator\Model\Column $toColumn + * * @return void */ public function addRenamedColumn(Column $fromColumn, Column $toColumn) @@ -404,7 +417,8 @@ public function getRenamedColumns() /** * Sets the list of added primary key columns. * - * @param Column[] $addedPkColumns + * @param \Propel\Generator\Model\Column[] $addedPkColumns + * * @return void */ public function setAddedPkColumns(array $addedPkColumns) @@ -419,7 +433,10 @@ public function setAddedPkColumns(array $addedPkColumns) * Add an added Pk column * * @param string $columnName - * @param Column $addedPkColumn + * @param \Propel\Generator\Model\Column $addedPkColumn + * + * @throws \Propel\Generator\Exception\DiffException + * * @return void */ public function addAddedPkColumn($columnName, Column $addedPkColumn) @@ -435,6 +452,7 @@ public function addAddedPkColumn($columnName, Column $addedPkColumn) * Removes an added primary key column. * * @param string $columnName + * * @return void */ public function removeAddedPkColumn($columnName) @@ -457,7 +475,8 @@ public function getAddedPkColumns() /** * Sets the list of removed primary key columns. * - * @param Column[] $removedPkColumns + * @param \Propel\Generator\Model\Column[] $removedPkColumns + * * @return void */ public function setRemovedPkColumns(array $removedPkColumns) @@ -472,7 +491,8 @@ public function setRemovedPkColumns(array $removedPkColumns) * Add a removed Pk column * * @param string $columnName - * @param Column $removedPkColumn + * @param \Propel\Generator\Model\Column $removedPkColumn + * * @return void */ public function addRemovedPkColumn($columnName, Column $removedPkColumn) @@ -484,6 +504,7 @@ public function addRemovedPkColumn($columnName, Column $removedPkColumn) * Removes a removed primary key column. * * @param string $columnName + * * @return void */ public function removeRemovedPkColumn($columnName) @@ -506,14 +527,15 @@ public function getRemovedPkColumns() /** * Sets the list of all renamed primary key columns. * - * @param Column[][] $renamedPkColumns + * @param \Propel\Generator\Model\Column[][] $renamedPkColumns + * * @return void */ public function setRenamedPkColumns(array $renamedPkColumns) { $this->renamedPkColumns = []; foreach ($renamedPkColumns as $columns) { - list($fromColumn, $toColumn) = $columns; + [$fromColumn, $toColumn] = $columns; $this->addRenamedPkColumn($fromColumn, $toColumn); } } @@ -521,8 +543,9 @@ public function setRenamedPkColumns(array $renamedPkColumns) /** * Adds a renamed primary key column. * - * @param Column $fromColumn The original column - * @param Column $toColumn The renamed column + * @param \Propel\Generator\Model\Column $fromColumn The original column + * @param \Propel\Generator\Model\Column $toColumn The renamed column + * * @return void */ public function addRenamedPkColumn(Column $fromColumn, Column $toColumn) @@ -543,7 +566,7 @@ public function getRenamedPkColumns() /** * Whether the primary key was modified * - * @return boolean + * @return bool */ public function hasModifiedPk() { @@ -553,7 +576,8 @@ public function hasModifiedPk() /** * Sets the list of new added indices. * - * @param Index[] $addedIndices + * @param \Propel\Generator\Model\Index[] $addedIndices + * * @return void */ public function setAddedIndices(array $addedIndices) @@ -568,7 +592,8 @@ public function setAddedIndices(array $addedIndices) * Add an added index. * * @param string $indexName - * @param Index $addedIndex + * @param \Propel\Generator\Model\Index $addedIndex + * * @return void */ public function addAddedIndex($indexName, Index $addedIndex) @@ -579,7 +604,7 @@ public function addAddedIndex($indexName, Index $addedIndex) /** * Getter for the addedIndices property * - * @return Index[] + * @return \Propel\Generator\Model\Index[] */ public function getAddedIndices() { @@ -589,7 +614,8 @@ public function getAddedIndices() /** * Sets the list of removed indices. * - * @param Index[] $removedIndices + * @param \Propel\Generator\Model\Index[] $removedIndices + * * @return void */ public function setRemovedIndices(array $removedIndices) @@ -604,7 +630,8 @@ public function setRemovedIndices(array $removedIndices) * Adds a removed index. * * @param string $indexName - * @param Index $removedIndex + * @param \Propel\Generator\Model\Index $removedIndex + * * @return void */ public function addRemovedIndex($indexName, Index $removedIndex) @@ -615,7 +642,7 @@ public function addRemovedIndex($indexName, Index $removedIndex) /** * Getter for the removedIndices property * - * @return Index[] + * @return \Propel\Generator\Model\Index[] */ public function getRemovedIndices() { @@ -627,14 +654,15 @@ public function getRemovedIndices() * * Array must be [ [ Index $fromIndex, Index $toIndex ], [ ... ] ] * - * @param Index[][] $modifiedIndices An aray of modified indices + * @param \Propel\Generator\Model\Index[][] $modifiedIndices An aray of modified indices + * * @return void */ public function setModifiedIndices(array $modifiedIndices) { $this->modifiedIndices = []; foreach ($modifiedIndices as $indices) { - list($fromIndex, $toIndex) = $indices; + [$fromIndex, $toIndex] = $indices; $this->addModifiedIndex($fromIndex->getName(), $fromIndex, $toIndex); } } @@ -643,8 +671,9 @@ public function setModifiedIndices(array $modifiedIndices) * Add a modified index. * * @param string $indexName - * @param Index $fromIndex - * @param Index $toIndex + * @param \Propel\Generator\Model\Index $fromIndex + * @param \Propel\Generator\Model\Index $toIndex + * * @return void */ public function addModifiedIndex($indexName, Index $fromIndex, Index $toIndex) @@ -665,7 +694,8 @@ public function getModifiedIndices() /** * Sets the list of added foreign keys. * - * @param ForeignKey[] $addedFks + * @param \Propel\Generator\Model\ForeignKey[] $addedFks + * * @return void */ public function setAddedFks(array $addedFks) @@ -679,8 +709,9 @@ public function setAddedFks(array $addedFks) /** * Adds an added foreign key. * - * @param string $fkName - * @param ForeignKey $addedFk + * @param string $fkName + * @param \Propel\Generator\Model\ForeignKey $addedFk + * * @return void */ public function addAddedFk($fkName, ForeignKey $addedFk) @@ -692,6 +723,7 @@ public function addAddedFk($fkName, ForeignKey $addedFk) * Remove an added Fk column * * @param string $fkName + * * @return void */ public function removeAddedFk($fkName) @@ -704,7 +736,7 @@ public function removeAddedFk($fkName) /** * Getter for the addedFks property * - * @return ForeignKey[] + * @return \Propel\Generator\Model\ForeignKey[] */ public function getAddedFks() { @@ -714,7 +746,8 @@ public function getAddedFks() /** * Sets the list of removed foreign keys. * - * @param ForeignKey[] $removedFks + * @param \Propel\Generator\Model\ForeignKey[] $removedFks + * * @return void */ public function setRemovedFks(array $removedFks) @@ -728,8 +761,9 @@ public function setRemovedFks(array $removedFks) /** * Adds a removed foreign key column. * - * @param string $fkName - * @param ForeignKey $removedFk + * @param string $fkName + * @param \Propel\Generator\Model\ForeignKey $removedFk + * * @return void */ public function addRemovedFk($fkName, ForeignKey $removedFk) @@ -741,6 +775,7 @@ public function addRemovedFk($fkName, ForeignKey $removedFk) * Removes a removed foreign key. * * @param string $fkName + * * @return void */ public function removeRemovedFk($fkName) @@ -751,7 +786,7 @@ public function removeRemovedFk($fkName) /** * Returns the list of removed foreign keys. * - * @return ForeignKey[] + * @return \Propel\Generator\Model\ForeignKey[] */ public function getRemovedFks() { @@ -763,14 +798,15 @@ public function getRemovedFks() * * Array must be [ [ ForeignKey $fromFk, ForeignKey $toFk ], [ ... ] ] * - * @param ForeignKey[][] $modifiedFks + * @param \Propel\Generator\Model\ForeignKey[][] $modifiedFks + * * @return void */ public function setModifiedFks(array $modifiedFks) { $this->modifiedFks = []; foreach ($modifiedFks as $foreignKeys) { - list($fromForeignKey, $toForeignKey) = $foreignKeys; + [$fromForeignKey, $toForeignKey] = $foreignKeys; $this->addModifiedFk($fromForeignKey->getName(), $fromForeignKey, $toForeignKey); } } @@ -778,9 +814,10 @@ public function setModifiedFks(array $modifiedFks) /** * Adds a modified foreign key. * - * @param string $fkName - * @param ForeignKey $fromFk - * @param ForeignKey $toFk + * @param string $fkName + * @param \Propel\Generator\Model\ForeignKey $fromFk + * @param \Propel\Generator\Model\ForeignKey $toFk + * * @return void */ public function addModifiedFk($fkName, ForeignKey $fromFk, ForeignKey $toFk) @@ -802,7 +839,7 @@ public function getModifiedFks() * Returns whether or not there are * some modified foreign keys. * - * @return boolean + * @return bool */ public function hasModifiedFks() { @@ -813,7 +850,7 @@ public function hasModifiedFks() * Returns whether or not there are * some modified indices. * - * @return boolean + * @return bool */ public function hasModifiedIndices() { @@ -824,7 +861,7 @@ public function hasModifiedIndices() * Returns whether or not there are * some modified columns. * - * @return boolean + * @return bool */ public function hasModifiedColumns() { @@ -835,7 +872,7 @@ public function hasModifiedColumns() * Returns whether or not there are * some removed foreign keys. * - * @return boolean + * @return bool */ public function hasRemovedFks() { @@ -846,7 +883,7 @@ public function hasRemovedFks() * Returns whether or not there are * some removed indices. * - * @return boolean + * @return bool */ public function hasRemovedIndices() { @@ -857,7 +894,7 @@ public function hasRemovedIndices() * Returns whether or not there are * some renamed columns. * - * @return boolean + * @return bool */ public function hasRenamedColumns() { @@ -868,7 +905,7 @@ public function hasRenamedColumns() * Returns whether or not there are * some removed columns. * - * @return boolean + * @return bool */ public function hasRemovedColumns() { @@ -879,7 +916,7 @@ public function hasRemovedColumns() * Returns whether or not there are * some added columns. * - * @return boolean + * @return bool */ public function hasAddedColumns() { @@ -890,7 +927,7 @@ public function hasAddedColumns() * Returns whether or not there are * some added indices. * - * @return boolean + * @return bool */ public function hasAddedIndices() { @@ -901,7 +938,7 @@ public function hasAddedIndices() * Returns whether or not there are * some added foreign keys. * - * @return boolean + * @return bool */ public function hasAddedFks() { @@ -912,7 +949,7 @@ public function hasAddedFks() * Returns whether or not there are * some added primary key columns. * - * @return boolean + * @return bool */ public function hasAddedPkColumns() { @@ -923,7 +960,7 @@ public function hasAddedPkColumns() * Returns whether or not there are * some removed primary key columns. * - * @return boolean + * @return bool */ public function hasRemovedPkColumns() { @@ -934,7 +971,7 @@ public function hasRemovedPkColumns() * Returns whether or not there are * some renamed primary key columns. * - * @return boolean + * @return bool */ public function hasRenamedPkColumns() { @@ -944,7 +981,7 @@ public function hasRenamedPkColumns() /** * Returns the reverse diff for this diff. * - * @return TableDiff + * @return \Propel\Generator\Model\Diff\TableDiff */ public function getReverseDiff() { @@ -1072,13 +1109,13 @@ public function __toString() if ($modifiedColumns = $this->getModifiedColumns()) { $ret .= " modifiedColumns:\n"; foreach ($modifiedColumns as $colDiff) { - $ret .= (string) $colDiff; + $ret .= (string)$colDiff; } } if ($renamedColumns = $this->getRenamedColumns()) { $ret .= " renamedColumns:\n"; foreach ($renamedColumns as $columnRenaming) { - list($fromColumn, $toColumn) = $columnRenaming; + [$fromColumn, $toColumn] = $columnRenaming; $ret .= sprintf(" %s: %s\n", $fromColumn->getName(), $toColumn->getName()); } } @@ -1116,7 +1153,7 @@ public function __toString() $ret .= " modifiedFks:\n"; foreach ($modifiedFks as $fkName => $fkFromTo) { $ret .= sprintf(" %s:\n", $fkName); - list($fromFk, $toFk) = $fkFromTo; + [$fromFk, $toFk] = $fkFromTo; $fromLocalColumns = json_encode($fromFk->getLocalColumns()); $toLocalColumns = json_encode($toFk->getLocalColumns()); if ($fromLocalColumns != $toLocalColumns) { diff --git a/src/Propel/Generator/Model/Domain.php b/src/Propel/Generator/Model/Domain.php index 4315de685d..081d88b2a1 100644 --- a/src/Propel/Generator/Model/Domain.php +++ b/src/Propel/Generator/Model/Domain.php @@ -10,6 +10,8 @@ namespace Propel\Generator\Model; +use DOMDocument; +use DOMNode; use Propel\Generator\Exception\EngineException; /** @@ -22,15 +24,25 @@ class Domain extends MappingModel { private $name; + private $description; + private $size; + + /** + * @var int|null + */ private $scale; + private $mappingType; + private $sqlType; + /** - * @var ColumnDefaultValue|null + * @var \Propel\Generator\Model\ColumnDefaultValue|null */ private $defaultValue; + private $database; /** @@ -38,32 +50,33 @@ class Domain extends MappingModel * * If this domain needs a name, it must be specified manually. * - * @param string|null $type Propel type. - * @param string|null $sqlType SQL type. - * @param integer|null $size - * @param integer|null $scale + * @param string|null $type Propel type. + * @param string|null $sqlType SQL type. + * @param int|null $size + * @param int|null $scale */ public function __construct($type = null, $sqlType = null, $size = null, $scale = null) { - if (null !== $type) { + if ($type !== null) { $this->setType($type); } - if (null !== $size) { + if ($size !== null) { $this->setSize($size); } - if (null !== $scale) { + if ($scale !== null) { $this->setScale($scale); } - $this->setSqlType(null !== $sqlType ? $sqlType : $type); + $this->setSqlType($sqlType !== null ? $sqlType : $type); } /** * Copies the values from current object into passed-in Domain. * - * @param Domain $domain Domain to copy values into. + * @param \Propel\Generator\Model\Domain $domain Domain to copy values into. + * * @return void */ public function copy(Domain $domain) @@ -90,9 +103,9 @@ protected function setupObject() // Default value $defval = $this->getAttribute('defaultValue', $this->getAttribute('default')); - if (null !== $defval) { + if ($defval !== null) { $this->setDefaultValue(new ColumnDefaultValue($defval, ColumnDefaultValue::TYPE_VALUE)); - } elseif (null !== $this->getAttribute('defaultExpr')) { + } elseif ($this->getAttribute('defaultExpr') !== null) { $this->setDefaultValue(new ColumnDefaultValue($this->getAttribute('defaultExpr'), ColumnDefaultValue::TYPE_EXPR)); } @@ -104,7 +117,8 @@ protected function setupObject() /** * Sets the owning database object (if this domain is being setup via XML). * - * @param Database $database + * @param \Propel\Generator\Model\Database $database + * * @return void */ public function setDatabase(Database $database) @@ -115,7 +129,7 @@ public function setDatabase(Database $database) /** * Returns the owning database object (if this domain was setup via XML). * - * @return Database + * @return \Propel\Generator\Model\Database */ public function getDatabase() { @@ -136,6 +150,7 @@ public function getDescription() * Sets the domain description. * * @param string $description + * * @return void */ public function setDescription($description) @@ -157,6 +172,7 @@ public function getName() * Sets the domain name. * * @param string $name + * * @return void */ public function setName($name) @@ -167,7 +183,7 @@ public function setName($name) /** * Returns the scale value. * - * @return integer + * @return int|null */ public function getScale() { @@ -177,31 +193,33 @@ public function getScale() /** * Sets the scale value. * - * @param integer $scale + * @param int $scale + * * @return void */ public function setScale($scale) { - $this->scale = null === $scale ? null : (int) $scale; + $this->scale = $scale === null ? null : (int)$scale; } /** * Replaces the size if the new value is not null. * - * @param integer $scale + * @param int $scale + * * @return void */ public function replaceScale($scale) { - if (null !== $scale) { - $this->scale = (int) $scale; + if ($scale !== null) { + $this->scale = (int)$scale; } } /** * Returns the size. * - * @return integer + * @return int */ public function getSize() { @@ -211,24 +229,26 @@ public function getSize() /** * Sets the size. * - * @param integer|null $size + * @param int|null $size + * * @return void */ public function setSize($size) { - $this->size = null === $size ? null : (int) $size; + $this->size = $size === null ? null : (int)$size; } /** * Replaces the size if the new value is not null. * - * @param integer|null $size + * @param int|null $size + * * @return void */ public function replaceSize($size) { - if (null !== $size) { - $this->size = (int) $size; + if ($size !== null) { + $this->size = (int)$size; } } @@ -246,6 +266,7 @@ public function getType() * Sets the mapping type. * * @param string $mappingType + * * @return void */ public function setType($mappingType) @@ -257,11 +278,12 @@ public function setType($mappingType) * Replaces the mapping type if the new value is not null. * * @param string $mappingType + * * @return void */ public function replaceType($mappingType) { - if (null !== $mappingType) { + if ($mappingType !== null) { $this->mappingType = $mappingType; } } @@ -269,7 +291,7 @@ public function replaceType($mappingType) /** * Returns the default value object. * - * @return ColumnDefaultValue|null + * @return \Propel\Generator\Model\ColumnDefaultValue|null */ public function getDefaultValue() { @@ -279,11 +301,13 @@ public function getDefaultValue() /** * Returns the default value, type-casted for use in PHP OM. * + * @throws \Propel\Generator\Exception\EngineException + * * @return string|array|bool|null */ public function getPhpDefaultValue() { - if (null === $this->defaultValue) { + if ($this->defaultValue === null) { return null; } @@ -295,10 +319,10 @@ public function getPhpDefaultValue() return $this->booleanValue($this->defaultValue->getValue()); } - if (PropelTypes::PHP_ARRAY === $this->mappingType) { + if ($this->mappingType === PropelTypes::PHP_ARRAY) { return $this->getDefaultValueForArray($this->defaultValue->getValue()); } - if (PropelTypes::SET === $this->mappingType) { + if ($this->mappingType === PropelTypes::SET) { return $this->getDefaultValueForSet($this->defaultValue->getValue()); } @@ -308,7 +332,8 @@ public function getPhpDefaultValue() /** * Sets the default value. * - * @param ColumnDefaultValue $value + * @param \Propel\Generator\Model\ColumnDefaultValue $value + * * @return void */ public function setDefaultValue(ColumnDefaultValue $value) @@ -319,12 +344,13 @@ public function setDefaultValue(ColumnDefaultValue $value) /** * Replaces the default value if the new value is not null. * - * @param ColumnDefaultValue $value + * @param \Propel\Generator\Model\ColumnDefaultValue|null $value + * * @return void */ - public function replaceDefaultValue(ColumnDefaultValue $value = null) + public function replaceDefaultValue(?ColumnDefaultValue $value = null) { - if (null !== $value) { + if ($value !== null) { $this->defaultValue = $value; } } @@ -343,6 +369,7 @@ public function getSqlType() * Sets the SQL type. * * @param string $sqlType + * * @return void */ public function setSqlType($sqlType) @@ -354,11 +381,12 @@ public function setSqlType($sqlType) * Replaces the SQL type if the new value is not null. * * @param string|null $sqlType + * * @return void */ public function replaceSqlType($sqlType) { - if (null !== $sqlType) { + if ($sqlType !== null) { $this->sqlType = $sqlType; } } @@ -370,11 +398,11 @@ public function replaceSqlType($sqlType) */ public function getSizeDefinition() { - if (null === $this->size) { + if ($this->size === null) { return ''; } - if (null !== $this->scale) { + if ($this->scale !== null) { return sprintf('(%u,%u)', $this->size, $this->scale); } @@ -393,12 +421,14 @@ public function __clone() /** * @todo Remove? This method is never called. + * * @param \DOMNode $node + * * @return void */ - public function appendXml(\DOMNode $node) + public function appendXml(DOMNode $node) { - $doc = ($node instanceof \DOMDocument) ? $node : $node->ownerDocument; + $doc = ($node instanceof DOMDocument) ? $node : $node->ownerDocument; /** @var \DOMElement $domainNode */ $domainNode = $node->appendChild($doc->createElement('domain')); diff --git a/src/Propel/Generator/Model/ForeignKey.php b/src/Propel/Generator/Model/ForeignKey.php index 50f0578fac..4d48ab8713 100644 --- a/src/Propel/Generator/Model/ForeignKey.php +++ b/src/Propel/Generator/Model/ForeignKey.php @@ -10,7 +10,7 @@ namespace Propel\Generator\Model; -use Propel\Generator\Platform\PlatformInterface; +use RuntimeException; /** * A class for information about table foreign keys. @@ -26,14 +26,13 @@ class ForeignKey extends MappingModel /** * These constants are the uppercase equivalents of the onDelete / onUpdate * values in the schema definition. - * */ - const NONE = ''; // No 'ON [ DELETE | UPDATE]' behavior - const NOACTION = 'NO ACTION'; - const CASCADE = 'CASCADE'; - const RESTRICT = 'RESTRICT'; - const SETDEFAULT = 'SET DEFAULT'; - const SETNULL = 'SET NULL'; + public const NONE = ''; // No 'ON [ DELETE | UPDATE]' behavior + public const NOACTION = 'NO ACTION'; + public const CASCADE = 'CASCADE'; + public const RESTRICT = 'RESTRICT'; + public const SETDEFAULT = 'SET DEFAULT'; + public const SETNULL = 'SET NULL'; /** * @var string @@ -76,7 +75,7 @@ class ForeignKey extends MappingModel private $onDelete = ''; /** - * @var Table + * @var \Propel\Generator\Model\Table */ private $parentTable; @@ -117,12 +116,12 @@ class ForeignKey extends MappingModel */ public function __construct($name = null) { - if (null !== $name) { + if ($name !== null) { $this->setName($name); } - $this->onUpdate = self::NONE; - $this->onDelete = self::NONE; + $this->onUpdate = self::NONE; + $this->onDelete = self::NONE; } /** @@ -131,16 +130,16 @@ public function __construct($name = null) protected function setupObject() { $this->foreignTableCommonName = $this->parentTable->getDatabase()->getTablePrefix() . $this->getAttribute('foreignTable'); - $this->foreignSchemaName = $this->getAttribute('foreignSchema'); + $this->foreignSchemaName = $this->getAttribute('foreignSchema'); - $this->name = $this->getAttribute('name'); - $this->phpName = $this->getAttribute('phpName'); - $this->refPhpName = $this->getAttribute('refPhpName'); + $this->name = $this->getAttribute('name'); + $this->phpName = $this->getAttribute('phpName'); + $this->refPhpName = $this->getAttribute('refPhpName'); $this->defaultJoin = $this->getAttribute('defaultJoin'); - $this->interface = $this->getAttribute('interface'); - $this->onUpdate = $this->normalizeFKey($this->getAttribute('onUpdate')); - $this->onDelete = $this->normalizeFKey($this->getAttribute('onDelete')); - $this->skipSql = $this->booleanValue($this->getAttribute('skipSql')); + $this->interface = $this->getAttribute('interface'); + $this->onUpdate = $this->normalizeFKey($this->getAttribute('onUpdate')); + $this->onDelete = $this->normalizeFKey($this->getAttribute('onDelete')); + $this->skipSql = $this->booleanValue($this->getAttribute('skipSql')); } /** @@ -170,22 +169,23 @@ protected function doNaming() /** * Returns the normalized input of onDelete and onUpdate behaviors. * - * @param string|null $behavior + * @param string|null $behavior + * * @return string */ public function normalizeFKey($behavior) { - if (null === $behavior) { + if ($behavior === null) { return self::NONE; } $behavior = strtoupper($behavior); - if ('NONE' === $behavior) { + if ($behavior === 'NONE') { return self::NONE; } - if ('SETNULL' === $behavior) { + if ($behavior === 'SETNULL') { return self::SETNULL; } @@ -195,28 +195,29 @@ public function normalizeFKey($behavior) /** * Returns whether or not the onUpdate behavior is set. * - * @return boolean + * @return bool */ public function hasOnUpdate() { - return self::NONE !== $this->onUpdate; + return $this->onUpdate !== self::NONE; } /** * Returns whether or not the onDelete behavior is set. * - * @return boolean + * @return bool */ public function hasOnDelete() { - return self::NONE !== $this->onDelete; + return $this->onDelete !== self::NONE; } /** * Returns true if $column is in our local columns list. * - * @param Column $column - * @return boolean + * @param \Propel\Generator\Model\Column $column + * + * @return bool */ public function hasLocalColumn(Column $column) { @@ -247,6 +248,7 @@ public function getOnDelete() * Sets the onDelete behavior. * * @param string $behavior + * * @return void */ public function setOnDelete($behavior) @@ -258,6 +260,7 @@ public function setOnDelete($behavior) * Sets the onUpdate behavior. * * @param string|null $behavior + * * @return void */ public function setOnUpdate($behavior) @@ -281,6 +284,7 @@ public function getName() * Sets the foreign key name. * * @param string $name + * * @return void */ public function setName($name) @@ -299,6 +303,7 @@ public function getInterface() /** * @param string $interface + * * @return void */ public function setInterface($interface) @@ -320,6 +325,7 @@ public function getPhpName() * Sets a phpName to use for this foreign key. * * @param string $name + * * @return void */ public function setPhpName($name) @@ -341,6 +347,7 @@ public function getRefPhpName() * Sets a refPhpName to use for this foreign key. * * @param string $name + * * @return void */ public function setRefPhpName($name) @@ -362,6 +369,7 @@ public function getDefaultJoin() * Sets the default join strategy for this foreign key (if any). * * @param string $join + * * @return void */ public function setDefaultJoin($join) @@ -372,7 +380,7 @@ public function setDefaultJoin($join) /** * Returns the PlatformInterface instance. * - * @return PlatformInterface|null + * @return \Propel\Generator\Platform\PlatformInterface|null */ private function getPlatform() { @@ -382,7 +390,7 @@ private function getPlatform() /** * Returns the Database object of this Column. * - * @return Database|null + * @return \Propel\Generator\Model\Database|null */ public function getDatabase() { @@ -400,16 +408,14 @@ public function getForeignTableName() if ($this->foreignSchemaName && $platform->supportsSchemas()) { return $this->foreignSchemaName . $platform->getSchemaDelimiter() - . $this->foreignTableCommonName - ; + . $this->foreignTableCommonName; } $database = $this->getDatabase(); if ($database && ($schema = $this->parentTable->guessSchemaName()) && $platform->supportsSchemas()) { return $schema . $platform->getSchemaDelimiter() - . $this->foreignTableCommonName - ; + . $this->foreignTableCommonName; } return $this->foreignTableCommonName; @@ -429,6 +435,7 @@ public function getForeignTableCommonName() * Sets the foreign table common name of the FK. * * @param string $tableName + * * @return void */ public function setForeignTableCommonName($tableName) @@ -439,7 +446,7 @@ public function setForeignTableCommonName($tableName) /** * Returns the resolved foreign Table model object. * - * @return Table|null + * @return \Propel\Generator\Model\Table|null */ public function getForeignTable() { @@ -465,6 +472,7 @@ public function getForeignSchemaName() * Set the foreign schema name of the foreign key. * * @param string $schemaName + * * @return void */ public function setForeignSchemaName($schemaName) @@ -476,6 +484,7 @@ public function setForeignSchemaName($schemaName) * Sets the parent Table of the foreign key. * * @param \Propel\Generator\Model\Table $parent + * * @return void */ public function setTable(Table $parent) @@ -486,7 +495,7 @@ public function setTable(Table $parent) /** * Returns the parent Table of the foreign key. * - * @return Table + * @return \Propel\Generator\Model\Table */ public function getTable() { @@ -518,6 +527,7 @@ public function getSchemaName() * * @param mixed $ref1 A Column object or an associative array or a string * @param mixed $ref2 A Column object or a single string name + * * @return void */ public function addReference($ref1, $ref2 = null) @@ -551,7 +561,7 @@ public function addReference($ref1, $ref2 = null) $foreign = $ref2->getName(); $this->foreignColumns[] = $foreign; $this->localValues[] = null; - } else if ($ref1 instanceof Column) { + } elseif ($ref1 instanceof Column) { $this->foreignColumns[] = null; $this->localValues[] = $ref2; } @@ -564,7 +574,7 @@ public function addReference($ref1, $ref2 = null) */ public function clearReferences() { - $this->localColumns = []; + $this->localColumns = []; $this->foreignColumns = []; $this->localValues = []; } @@ -582,7 +592,7 @@ public function getLocalColumns() /** * Returns an array of local column objects. * - * @return Column[] + * @return \Propel\Generator\Model\Column[] */ public function getLocalColumnObjects() { @@ -597,7 +607,8 @@ public function getLocalColumnObjects() /** * Returns a local column name identified by a position. * - * @param integer $index + * @param int $index + * * @return string */ public function getLocalColumnName($index = 0) @@ -608,8 +619,9 @@ public function getLocalColumnName($index = 0) /** * Returns a local Column object identified by a position. * - * @param integer $index - * @return Column + * @param int $index + * + * @return \Propel\Generator\Model\Column */ public function getLocalColumn($index = 0) { @@ -661,7 +673,7 @@ public function getColumnObjectsMapping() $foreignTable = $this->getForeignTable(); for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) { $mapping[] = [ - 'local' => $this->parentTable->getColumn($this->localColumns[$i]), + 'local' => $this->parentTable->getColumn($this->localColumns[$i]), 'foreign' => $foreignTable->getColumn($this->foreignColumns[$i]), 'value' => $this->localValues[$i], ]; @@ -673,24 +685,28 @@ public function getColumnObjectsMapping() /** * Returns the foreign column name mapped to a specified local column. * - * @param string $local + * @param string $local + * * @return string */ public function getMappedForeignColumn($local) { $index = array_search($local, $this->localColumns); + return $this->foreignColumns[$index]; } /** * Returns the local column name mapped to a specified foreign column. * - * @param string $foreign + * @param string $foreign + * * @return string */ public function getMappedLocalColumn($foreign) { $index = array_search($foreign, $this->foreignColumns); + return $this->localColumns[$index]; } @@ -715,7 +731,7 @@ public function getForeignColumnObjects() $foreignTable = $this->getForeignTable(); foreach ($this->foreignColumns as $columnName) { $column = $foreignTable->getColumn($columnName); - if (null !== $column) { + if ($column !== null) { $columns[] = $column; } } @@ -726,7 +742,8 @@ public function getForeignColumnObjects() /** * Returns a foreign column name. * - * @param integer $index + * @param int $index + * * @return string */ public function getForeignColumnName($index = 0) @@ -737,7 +754,7 @@ public function getForeignColumnName($index = 0) /** * Returns a foreign column object. * - * @return Column + * @return \Propel\Generator\Model\Column */ public function getForeignColumn($index = 0) { @@ -747,7 +764,7 @@ public function getForeignColumn($index = 0) /** * Returns whether this foreign key uses only required local columns. * - * @return boolean + * @return bool */ public function isLocalColumnsRequired() { @@ -763,7 +780,7 @@ public function isLocalColumnsRequired() /** * Returns whether this foreign key uses at least one required local column. * - * @return boolean + * @return bool */ public function isAtLeastOneLocalColumnRequired() { @@ -779,7 +796,7 @@ public function isAtLeastOneLocalColumnRequired() /** * Returns whether this foreign key uses at least one required(notNull && no defaultValue) local primary key. * - * @return boolean + * @return bool */ public function isAtLeastOneLocalPrimaryKeyIsRequired() { @@ -796,7 +813,7 @@ public function isAtLeastOneLocalPrimaryKeyIsRequired() * Returns whether this foreign key is also the primary key of the foreign * table. * - * @return boolean Returns true if all columns inside this foreign key are primary keys of the foreign table + * @return bool Returns true if all columns inside this foreign key are primary keys of the foreign table */ public function isForeignPrimaryKey() { @@ -822,7 +839,7 @@ public function isForeignPrimaryKey() * Returns whether or not this foreign key relies on more than one * column binding. * - * @return boolean + * @return bool */ public function isComposite() { @@ -854,12 +871,12 @@ public function getNormalizedMap($mapping) * * At least one reference with a expression attribute set. * - * @return boolean + * @return bool */ public function isPolymorphic() { foreach ($this->localValues as $value) { - if (null !== $value) { + if ($value !== null) { return true; } } @@ -887,7 +904,7 @@ public function getLocalValues() * Returns whether or not this foreign key is also the primary key of * the local table. * - * @return boolean True if all local columns are at the same time a primary key + * @return bool True if all local columns are at the same time a primary key */ public function isLocalPrimaryKey() { @@ -903,19 +920,20 @@ public function isLocalPrimaryKey() * Sets whether or not this foreign key should have its creation SQL * generated. * - * @param boolean $skip + * @param bool $skip + * * @return void */ public function setSkipSql($skip) { - $this->skipSql = (boolean) $skip; + $this->skipSql = (bool)$skip; } /** * Returns whether or not the SQL generation must be skipped for this * foreign key. * - * @return boolean + * @return bool */ public function isSkipSql() { @@ -926,25 +944,28 @@ public function isSkipSql() * Whether this foreign key is matched by an inverted foreign key (on foreign table). * * This is to prevent duplicate columns being generated for a 1:1 relationship that is represented - * by foreign keys on both tables. I don't know if that's good practice ... but hell, why not + * by foreign keys on both tables. I don't know if that's good practice ... but hell, why not * support it. * - * @return boolean * @link http://propel.phpdb.org/trac/ticket/549 + * + * @return bool */ public function isMatchedByInverseFK() { - return (boolean) $this->getInverseFK(); + return (bool)$this->getInverseFK(); } /** + * @throws \RuntimeException + * * @return \Propel\Generator\Model\ForeignKey|null */ public function getInverseFK() { $foreignTable = $this->getForeignTable(); if (!$foreignTable) { - throw new \RuntimeException('No foreign table given'); + throw new RuntimeException('No foreign table given'); } $map = $this->getInverseMapping(); @@ -964,14 +985,14 @@ public function getInverseFK() * Returns the list of other foreign keys starting on the same table. * Used in many-to-many relationships. * - * @return ForeignKey[] + * @return \Propel\Generator\Model\ForeignKey[] */ public function getOtherFks() { $fks = []; foreach ($this->parentTable->getForeignKeys() as $fk) { if ($fk !== $this) { - $fks[]= $fk; + $fks[] = $fk; } } @@ -981,7 +1002,7 @@ public function getOtherFks() /** * Returns all local columns which are also a primary key of the local table. * - * @return Column[] + * @return \Propel\Generator\Model\Column[] */ public function getLocalPrimaryKeys() { @@ -1000,12 +1021,12 @@ public function getLocalPrimaryKeys() /** * Whether at least one local column is also a primary key. * - * @return boolean True if there is at least one column that is a primary key + * @return bool True if there is at least one column that is a primary key */ public function isAtLeastOneLocalPrimaryKey() { $cols = $this->getLocalPrimaryKeys(); - return 0 !== count($cols); + return count($cols) !== 0; } } diff --git a/src/Propel/Generator/Model/IdMethod.php b/src/Propel/Generator/Model/IdMethod.php index e1b63b3059..6b02669e0f 100644 --- a/src/Propel/Generator/Model/IdMethod.php +++ b/src/Propel/Generator/Model/IdMethod.php @@ -23,11 +23,11 @@ interface IdMethod * Key generation via database-specific ID method * (i.e. auto-increment for MySQL, sequence for Oracle, etc.). */ - const NATIVE = 'native'; + public const NATIVE = 'native'; /** * No RDBMS key generation (keys may be generated by the * application). */ - const NO_ID_METHOD = 'none'; + public const NO_ID_METHOD = 'none'; } diff --git a/src/Propel/Generator/Model/IdMethodParameter.php b/src/Propel/Generator/Model/IdMethodParameter.php index 0bba7c8ca3..2acbf2db04 100644 --- a/src/Propel/Generator/Model/IdMethodParameter.php +++ b/src/Propel/Generator/Model/IdMethodParameter.php @@ -31,7 +31,7 @@ class IdMethodParameter extends MappingModel private $value; /** - * @var Table + * @var \Propel\Generator\Model\Table */ private $parentTable; @@ -58,6 +58,7 @@ public function getName() * Sets the parameter name. * * @param string $name + * * @return void */ public function setName($name) @@ -79,6 +80,7 @@ public function getValue() * Sets the parameter value. * * @param mixed $value + * * @return void */ public function setValue($value) @@ -90,6 +92,7 @@ public function setValue($value) * Sets the parent table. * * @param \Propel\Generator\Model\Table $parent + * * @return void */ public function setTable(Table $parent) @@ -100,7 +103,7 @@ public function setTable(Table $parent) /** * Returns the parent table. * - * @return Table + * @return \Propel\Generator\Model\Table */ public function getTable() { diff --git a/src/Propel/Generator/Model/Index.php b/src/Propel/Generator/Model/Index.php index 0a4e627939..63b7ed369d 100644 --- a/src/Propel/Generator/Model/Index.php +++ b/src/Propel/Generator/Model/Index.php @@ -27,7 +27,7 @@ class Index extends MappingModel /** * The Table instance. * - * @var Table|null + * @var \Propel\Generator\Model\Table|null */ protected $table; @@ -37,7 +37,7 @@ class Index extends MappingModel protected $columns = []; /** - * @var Column[] + * @var \Propel\Generator\Model\Column[] */ protected $columnObjects = []; @@ -58,7 +58,7 @@ class Index extends MappingModel */ public function __construct($name = null) { - if (null !== $name) { + if ($name !== null) { $this->setName($name); } } @@ -66,7 +66,7 @@ public function __construct($name = null) /** * Returns the uniqueness of this index. * - * @return boolean + * @return bool */ public function isUnique() { @@ -77,6 +77,7 @@ public function isUnique() * Sets the index name. * * @param string $name + * * @return void */ public function setName($name) @@ -134,7 +135,8 @@ protected function doNaming() public function getFQName() { $table = $this->getTable(); - if ($table + if ( + $table && $table->getDatabase() && ($table->getSchema() || $table->getDatabase()->getSchema()) && $table->getDatabase()->getPlatform() @@ -150,6 +152,7 @@ public function getFQName() * Sets the index parent Table. * * @param \Propel\Generator\Model\Table $table + * * @return void */ public function setTable(Table $table) @@ -160,7 +163,7 @@ public function setTable(Table $table) /** * Returns the index parent table. * - * @return Table|null + * @return \Propel\Generator\Model\Table|null */ public function getTable() { @@ -180,7 +183,8 @@ public function getTableName() /** * Adds a new column to the index. * - * @param Column|array $data Column or attributes from XML. + * @param \Propel\Generator\Model\Column|array $data Column or attributes from XML. + * * @return void */ public function addColumn($data) @@ -204,7 +208,8 @@ public function addColumn($data) } /** - * @param string $name + * @param string $name + * * @return bool */ public function hasColumn($name) @@ -216,11 +221,12 @@ public function hasColumn($name) * Sets an array of columns to use for the index. * * @param array $columns array of array definitions $columns[]['name'] = 'columnName' + * * @return void */ public function setColumns(array $columns) { - $this->columns = []; + $this->columns = []; $this->columnsSize = []; foreach ($columns as $column) { $this->addColumn($column); @@ -230,8 +236,9 @@ public function setColumns(array $columns) /** * Returns whether or not there is a size for the specified column. * - * @param string $name - * @return boolean + * @param string $name + * + * @return bool */ public function hasColumnSize($name) { @@ -241,18 +248,20 @@ public function hasColumnSize($name) /** * Returns the size for the specified column. * - * @param string $name - * @param boolean $caseInsensitive + * @param string $name + * @param bool $caseInsensitive + * * @return int|null */ public function getColumnSize($name, $caseInsensitive = false) { if ($caseInsensitive) { foreach ($this->columnsSize as $forName => $size) { - if (0 === strcasecmp($forName, $name)) { + if (strcasecmp($forName, $name) === 0) { return $size; } } + return null; } @@ -263,6 +272,7 @@ public function getColumnSize($name, $caseInsensitive = false) * Resets the columns sizes. * * This method is useful for generated indices for FKs. + * * @return void */ public function resetColumnsSize() @@ -273,11 +283,12 @@ public function resetColumnsSize() /** * Returns whether or not this index has a given column at a given position. * - * @param integer $pos Position in the column list - * @param string $name Column name - * @param integer|null $size Optional size check - * @param boolean $caseInsensitive Whether or not the comparison is case insensitive (false by default) - * @return boolean + * @param int $pos Position in the column list + * @param string $name Column name + * @param int|null $size Optional size check + * @param bool $caseInsensitive Whether or not the comparison is case insensitive (false by default) + * + * @return bool */ public function hasColumnAtPosition($pos, $name, $size = null, $caseInsensitive = false) { @@ -286,7 +297,7 @@ public function hasColumnAtPosition($pos, $name, $size = null, $caseInsensitive } if ($caseInsensitive) { - $test = 0 === strcasecmp($this->columns[$pos], $name); + $test = strcasecmp($this->columns[$pos], $name) === 0; } else { $test = $this->columns[$pos] == $name; } @@ -305,7 +316,7 @@ public function hasColumnAtPosition($pos, $name, $size = null, $caseInsensitive /** * Returns whether or not the index has columns. * - * @return boolean + * @return bool */ public function hasColumns() { @@ -333,7 +344,7 @@ protected function setupObject() } /** - * @return Column[] + * @return \Propel\Generator\Model\Column[] */ public function getColumnObjects() { @@ -341,7 +352,8 @@ public function getColumnObjects() } /** - * @param Column[] $columnObjects + * @param \Propel\Generator\Model\Column[] $columnObjects + * * @return void */ public function setColumnObjects($columnObjects) diff --git a/src/Propel/Generator/Model/Inheritance.php b/src/Propel/Generator/Model/Inheritance.php index 785c4a4821..811969b028 100644 --- a/src/Propel/Generator/Model/Inheritance.php +++ b/src/Propel/Generator/Model/Inheritance.php @@ -23,20 +23,24 @@ class Inheritance extends MappingModel * @var string|null */ private $key; + /** * @var string|null */ private $className; + /** * @var string|null */ private $package; + /** * @var string|null */ private $ancestor; + /** - * @var Column|null + * @var \Propel\Generator\Model\Column|null */ private $column; @@ -58,6 +62,7 @@ public function getKey() public function getConstantSuffix() { $separator = PhpNameGenerator::STD_SEPARATOR_CHAR; + return strtoupper(rtrim(preg_replace('/(\W|_)+/', $separator, $this->key), $separator)); } @@ -65,6 +70,7 @@ public function getConstantSuffix() * Sets a key name. * * @param string $key + * * @return void */ public function setKey($key) @@ -75,7 +81,8 @@ public function setKey($key) /** * Sets the parent column * - * @param Column $column + * @param \Propel\Generator\Model\Column $column + * * @return void */ public function setColumn(Column $column) @@ -86,7 +93,7 @@ public function setColumn(Column $column) /** * Returns the parent column. * - * @return Column + * @return \Propel\Generator\Model\Column */ public function getColumn() { @@ -107,6 +114,7 @@ public function getClassName() * Sets the class name. * * @param string $name + * * @return void */ public function setClassName($name) @@ -128,6 +136,7 @@ public function getPackage() * Sets the package. * * @param string $package + * * @return void */ public function setPackage($package) @@ -149,6 +158,7 @@ public function getAncestor() * Sets the ancestor. * * @param string $ancestor + * * @return void */ public function setAncestor($ancestor) @@ -161,9 +171,9 @@ public function setAncestor($ancestor) */ protected function setupObject() { - $this->key = $this->getAttribute('key'); + $this->key = $this->getAttribute('key'); $this->className = $this->getAttribute('class'); - $this->package = $this->getAttribute('package'); - $this->ancestor = $this->getAttribute('extends'); + $this->package = $this->getAttribute('package'); + $this->ancestor = $this->getAttribute('extends'); } } diff --git a/src/Propel/Generator/Model/MappingModel.php b/src/Propel/Generator/Model/MappingModel.php index 7e73eae951..59957c0df5 100644 --- a/src/Propel/Generator/Model/MappingModel.php +++ b/src/Propel/Generator/Model/MappingModel.php @@ -29,7 +29,7 @@ abstract class MappingModel implements MappingModelInterface /** * The list of vendor's information. * - * @var VendorInfo[] + * @var \Propel\Generator\Model\VendorInfo[] */ protected $vendorInfos = []; @@ -37,6 +37,7 @@ abstract class MappingModel implements MappingModelInterface * Loads a mapping definition from an array. * * @param array $attributes + * * @return void */ public function loadMapping(array $attributes) @@ -72,8 +73,9 @@ public function getAttributes() * If the attribute is not set, then the second default value is * returned instead. * - * @param string $name - * @param mixed|null $default + * @param string $name + * @param mixed|null $default + * * @return mixed */ public function getAttribute($name, $default = null) @@ -91,8 +93,9 @@ public function getAttribute($name, $default = null) * * This is to support the default value when used with a boolean column. * - * @param mixed $value - * @return boolean + * @param mixed $value + * + * @return bool */ protected function booleanValue($value) { @@ -101,10 +104,10 @@ protected function booleanValue($value) } if (is_numeric($value)) { - return (bool) $value; + return (bool)$value; } - return in_array(strtolower($value), [ 'true', 't', 'y', 'yes' ], true); + return in_array(strtolower($value), [ 'true', 't', 'y', 'yes' ], true); } /** @@ -126,7 +129,7 @@ protected function getDefaultValueForArray($stringValue) } $value = implode(' | ', $values); - if (empty($value) || ' | ' === $value) { + if (empty($value) || $value === ' | ') { return null; } @@ -155,14 +158,16 @@ protected function getDefaultValueForSet($stringValue) if (count($values) === 0) { return null; } + return $values; } /** * Adds a new VendorInfo instance to this current model object. * - * @param VendorInfo|array $vendor - * @return VendorInfo + * @param \Propel\Generator\Model\VendorInfo|array $vendor + * + * @return \Propel\Generator\Model\VendorInfo */ public function addVendorInfo($vendor) { @@ -181,8 +186,9 @@ public function addVendorInfo($vendor) /** * Returns a VendorInfo object by its type. * - * @param string $type - * @return VendorInfo + * @param string $type + * + * @return \Propel\Generator\Model\VendorInfo */ public function getVendorInfoForType($type) { @@ -196,11 +202,10 @@ public function getVendorInfoForType($type) /** * Returns the list of all vendor information. * - * @return VendorInfo[] + * @return \Propel\Generator\Model\VendorInfo[] */ public function getVendorInformation() { return $this->vendorInfos; } - } diff --git a/src/Propel/Generator/Model/MappingModelInterface.php b/src/Propel/Generator/Model/MappingModelInterface.php index 9f80182891..b8737310db 100644 --- a/src/Propel/Generator/Model/MappingModelInterface.php +++ b/src/Propel/Generator/Model/MappingModelInterface.php @@ -17,10 +17,10 @@ */ interface MappingModelInterface { - const DEFAULT_STRING_FORMAT = 'YAML'; - const VISIBILITY_PUBLIC = 'public'; - const VISIBILITY_PRIVATE = 'private'; - const VISIBILITY_PROTECTED = 'protected'; + public const DEFAULT_STRING_FORMAT = 'YAML'; + public const VISIBILITY_PUBLIC = 'public'; + public const VISIBILITY_PRIVATE = 'private'; + public const VISIBILITY_PROTECTED = 'protected'; /** * Loads a model definition from an array. diff --git a/src/Propel/Generator/Model/NameFactory.php b/src/Propel/Generator/Model/NameFactory.php index 23e129202b..f91ef8cb4a 100644 --- a/src/Propel/Generator/Model/NameFactory.php +++ b/src/Propel/Generator/Model/NameFactory.php @@ -10,8 +10,6 @@ namespace Propel\Generator\Model; -use Propel\Generator\Exception\EngineException; - /** * A name generation factory. * @@ -24,14 +22,15 @@ class NameFactory /** * The class name of the PHP name generator. */ - const PHP_GENERATOR = '\Propel\Generator\Model\PhpNameGenerator'; + public const PHP_GENERATOR = '\Propel\Generator\Model\PhpNameGenerator'; /** * The fully qualified class name of the constraint name generator. */ - const CONSTRAINT_GENERATOR = '\Propel\Generator\Model\ConstraintNameGenerator'; + public const CONSTRAINT_GENERATOR = '\Propel\Generator\Model\ConstraintNameGenerator'; /** + * @var array * The cache of NameGeneratorInterface algorithms in use for * name generation, keyed by fully qualified class name. */ @@ -56,11 +55,11 @@ protected static function getAlgorithm($name) * Given a list of String objects, implements an * algorithm which produces a name. * - * @param string $algorithmName The fully qualified class name of the {@link NameGeneratorInterface} + * @param string $algorithmName The fully qualified class name of the {@link NameGeneratorInterface} * implementation to use to generate names. - * @param array $inputs Inputs used to generate a name. - * @return string The generated name. - * @throws EngineException + * @param array $inputs Inputs used to generate a name. + * + * @return string The generated name. */ public static function generateName($algorithmName, $inputs) { diff --git a/src/Propel/Generator/Model/NameGeneratorInterface.php b/src/Propel/Generator/Model/NameGeneratorInterface.php index 325f2b88ad..9219d8d660 100644 --- a/src/Propel/Generator/Model/NameGeneratorInterface.php +++ b/src/Propel/Generator/Model/NameGeneratorInterface.php @@ -10,8 +10,6 @@ namespace Propel\Generator\Model; -use Propel\Generator\Exception\EngineException; - /** * The generic interface to a name generation algorithm. * @@ -26,17 +24,17 @@ interface NameGeneratorInterface * The character used by most implementations as the separator * between name elements. */ - const STD_SEPARATOR_CHAR = '_'; + public const STD_SEPARATOR_CHAR = '_'; /** * Traditional method for converting schema table and column names - * to PHP names. The CONV_METHOD_XXX constants + * to PHP names. The CONV_METHOD_XXX constants * define how names for columns and tables in the database schema * will be converted to PHP source names. * * @see PhpNameGenerator::underscoreMethod() */ - const CONV_METHOD_UNDERSCORE = 'underscore'; + public const CONV_METHOD_UNDERSCORE = 'underscore'; /** * Heavier method for converting schema table and column names @@ -47,7 +45,7 @@ interface NameGeneratorInterface * constants define how names for columns and tales in the * database schema will be converted to PHP source names. */ - const CONV_METHOD_CLEAN = 'clean'; + public const CONV_METHOD_CLEAN = 'clean'; /** * Similar to {@link #CONV_METHOD_UNDERSCORE} except nothing is @@ -55,21 +53,23 @@ interface NameGeneratorInterface * * @see PhpNameGenerator::phpnameMethod() */ - const CONV_METHOD_PHPNAME = 'phpname'; + public const CONV_METHOD_PHPNAME = 'phpname'; /** * Specifies no modification when converting from a schema column * or table name to a PHP name. */ - const CONV_METHOD_NOCHANGE = 'nochange'; + public const CONV_METHOD_NOCHANGE = 'nochange'; /** * Given a list of String objects, implements an * algorithm which produces a name. * - * @param string[] $inputs Inputs used to generate a name. - * @return string The generated name. - * @throws EngineException + * @param string[] $inputs Inputs used to generate a name. + * + * @throws \Propel\Generator\Exception\EngineException + * + * @return string The generated name. */ public function generateName($inputs); } diff --git a/src/Propel/Generator/Model/PhpNameGenerator.php b/src/Propel/Generator/Model/PhpNameGenerator.php index 8fc90f237c..3a6e069bd3 100644 --- a/src/Propel/Generator/Model/PhpNameGenerator.php +++ b/src/Propel/Generator/Model/PhpNameGenerator.php @@ -32,15 +32,17 @@ class PhpNameGenerator implements NameGeneratorInterface * directly to php names without modification. * CONV_METHOD_UNDERSCORE will capitalize the first * letter, remove underscores, and capitalize each letter before - * an underscore. All other letters are lowercased. "phpname" + * an underscore. All other letters are lowercased. "phpname" * works the same as the CONV_METHOD_PHPNAME method * but will not lowercase any characters. * - * @param string[] $inputs List expected to contain two (optional: three) parameters, + * @see NameGenerator + * + * @param string[] $inputs List expected to contain two (optional: three) parameters, * element 0 contains name to convert, element 1 contains method for conversion, * optional element 2 contains prefix to be striped from name - * @return string The generated name. - * @see NameGenerator + * + * @return string The generated name. */ public function generateName($inputs) { @@ -59,12 +61,15 @@ public function generateName($inputs) switch ($method) { case self::CONV_METHOD_CLEAN: $phpName = $this->cleanMethod($schemaName); + break; case self::CONV_METHOD_PHPNAME: $phpName = $this->phpnameMethod($schemaName); + break; case self::CONV_METHOD_NOCHANGE: $phpName = $this->nochangeMethod($schemaName); + break; case self::CONV_METHOD_UNDERSCORE: default: @@ -84,16 +89,18 @@ public function generateName($inputs) * * my_CLASS_name -> MyClassName * - * @param string $schemaName name to be converted. - * @return string Converted name. * @see NameGenerator * @see #underscoreMethod() + * + * @param string $schemaName name to be converted. + * + * @return string Converted name. */ protected function underscoreMethod($schemaName) { $name = ''; $tok = strtok($schemaName, self::STD_SEPARATOR_CHAR); - while (false !== $tok) { + while ($tok !== false) { $name .= ucfirst(strtolower($tok)); $tok = strtok(self::STD_SEPARATOR_CHAR); } @@ -102,17 +109,19 @@ protected function underscoreMethod($schemaName) } /** - * Converts a database schema name to php object name. Removes + * Converts a database schema name to php object name. Removes * any character that is not a letter or a number and capitalizes * first letter of the name, the first letter of each alphanumeric * block and converts the rest of the letters to lowercase. * * T$NAMA$RFO_max => TNamaRfoMax * - * @param string $schemaName name to be converted. - * @return string Converted name. * @see NameGenerator * @see #underscoreMethod() + * + * @param string $schemaName name to be converted. + * + * @return string Converted name. */ protected function cleanMethod($schemaName) { @@ -131,22 +140,24 @@ protected function cleanMethod($schemaName) } /** - * Converts a database schema name to php object name. Operates + * Converts a database schema name to php object name. Operates * same as underscoreMethod but does not convert anything to * lowercase. * * my_CLASS_name -> MyCLASSName * - * @param string $schemaName name to be converted. - * @return string Converted name. * @see NameGenerator * @see #underscoreMethod(String) + * + * @param string $schemaName name to be converted. + * + * @return string Converted name. */ protected function phpnameMethod($schemaName) { $name = ''; $tok = strtok($schemaName, self::STD_SEPARATOR_CHAR); - while (false !== $tok) { + while ($tok !== false) { $name .= ucfirst($tok); $tok = strtok(self::STD_SEPARATOR_CHAR); } @@ -155,11 +166,12 @@ protected function phpnameMethod($schemaName) } /** - * Converts a database schema name to PHP object name. In this + * Converts a database schema name to PHP object name. In this * case no conversion is made. * - * @param string $name name to be converted. - * @return string The name parameter, unchanged. + * @param string $name name to be converted. + * + * @return string */ protected function nochangeMethod($name) { diff --git a/src/Propel/Generator/Model/PropelTypes.php b/src/Propel/Generator/Model/PropelTypes.php index b6cfd55136..95ca8f8e3e 100644 --- a/src/Propel/Generator/Model/PropelTypes.php +++ b/src/Propel/Generator/Model/PropelTypes.php @@ -10,6 +10,8 @@ namespace Propel\Generator\Model; +use PDO; + /** * A class that maps PropelTypes to PHP native types and PDO types. * @@ -21,69 +23,69 @@ */ class PropelTypes { - const CHAR = 'CHAR'; - const VARCHAR = 'VARCHAR'; - const LONGVARCHAR = 'LONGVARCHAR'; - const CLOB = 'CLOB'; - const CLOB_EMU = 'CLOB_EMU'; - const NUMERIC = 'NUMERIC'; - const DECIMAL = 'DECIMAL'; - const TINYINT = 'TINYINT'; - const SMALLINT = 'SMALLINT'; - const INTEGER = 'INTEGER'; - const BIGINT = 'BIGINT'; - const REAL = 'REAL'; - const FLOAT = 'FLOAT'; - const DOUBLE = 'DOUBLE'; - const BINARY = 'BINARY'; - const VARBINARY = 'VARBINARY'; - const LONGVARBINARY = 'LONGVARBINARY'; - const BLOB = 'BLOB'; - const DATE = 'DATE'; - const TIME = 'TIME'; - const TIMESTAMP = 'TIMESTAMP'; - const BU_DATE = 'BU_DATE'; - const BU_TIMESTAMP = 'BU_TIMESTAMP'; - const BOOLEAN = 'BOOLEAN'; - const BOOLEAN_EMU = 'BOOLEAN_EMU'; - const OBJECT = 'OBJECT'; - const PHP_ARRAY = 'ARRAY'; - const ENUM = 'ENUM'; - const SET = 'SET'; - const GEOMETRY = 'GEOMETRY'; - const JSON = 'JSON'; + public const CHAR = 'CHAR'; + public const VARCHAR = 'VARCHAR'; + public const LONGVARCHAR = 'LONGVARCHAR'; + public const CLOB = 'CLOB'; + public const CLOB_EMU = 'CLOB_EMU'; + public const NUMERIC = 'NUMERIC'; + public const DECIMAL = 'DECIMAL'; + public const TINYINT = 'TINYINT'; + public const SMALLINT = 'SMALLINT'; + public const INTEGER = 'INTEGER'; + public const BIGINT = 'BIGINT'; + public const REAL = 'REAL'; + public const FLOAT = 'FLOAT'; + public const DOUBLE = 'DOUBLE'; + public const BINARY = 'BINARY'; + public const VARBINARY = 'VARBINARY'; + public const LONGVARBINARY = 'LONGVARBINARY'; + public const BLOB = 'BLOB'; + public const DATE = 'DATE'; + public const TIME = 'TIME'; + public const TIMESTAMP = 'TIMESTAMP'; + public const BU_DATE = 'BU_DATE'; + public const BU_TIMESTAMP = 'BU_TIMESTAMP'; + public const BOOLEAN = 'BOOLEAN'; + public const BOOLEAN_EMU = 'BOOLEAN_EMU'; + public const OBJECT = 'OBJECT'; + public const PHP_ARRAY = 'ARRAY'; + public const ENUM = 'ENUM'; + public const SET = 'SET'; + public const GEOMETRY = 'GEOMETRY'; + public const JSON = 'JSON'; - const CHAR_NATIVE_TYPE = 'string'; - const VARCHAR_NATIVE_TYPE = 'string'; - const LONGVARCHAR_NATIVE_TYPE = 'string'; - const CLOB_NATIVE_TYPE = 'string'; - const CLOB_EMU_NATIVE_TYPE = 'resource'; - const NUMERIC_NATIVE_TYPE = 'string'; - const DECIMAL_NATIVE_TYPE = 'string'; - const TINYINT_NATIVE_TYPE = 'int'; - const SMALLINT_NATIVE_TYPE = 'int'; - const INTEGER_NATIVE_TYPE = 'int'; - const BIGINT_NATIVE_TYPE = 'string'; - const REAL_NATIVE_TYPE = 'double'; - const FLOAT_NATIVE_TYPE = 'double'; - const DOUBLE_NATIVE_TYPE = 'double'; - const BINARY_NATIVE_TYPE = 'string'; - const VARBINARY_NATIVE_TYPE = 'string'; - const LONGVARBINARY_NATIVE_TYPE = 'string'; - const BLOB_NATIVE_TYPE = 'resource'; - const BU_DATE_NATIVE_TYPE = 'string'; - const DATE_NATIVE_TYPE = 'string'; - const TIME_NATIVE_TYPE = 'string'; - const TIMESTAMP_NATIVE_TYPE = 'string'; - const BU_TIMESTAMP_NATIVE_TYPE = 'string'; - const BOOLEAN_NATIVE_TYPE = 'boolean'; - const BOOLEAN_EMU_NATIVE_TYPE = 'boolean'; - const OBJECT_NATIVE_TYPE = ''; - const PHP_ARRAY_NATIVE_TYPE = 'array'; - const ENUM_NATIVE_TYPE = 'int'; - const SET_NATIVE_TYPE = 'int'; - const GEOMETRY_NATIVE_TYPE = 'resource'; - const JSON_TYPE = 'string'; + public const CHAR_NATIVE_TYPE = 'string'; + public const VARCHAR_NATIVE_TYPE = 'string'; + public const LONGVARCHAR_NATIVE_TYPE = 'string'; + public const CLOB_NATIVE_TYPE = 'string'; + public const CLOB_EMU_NATIVE_TYPE = 'resource'; + public const NUMERIC_NATIVE_TYPE = 'string'; + public const DECIMAL_NATIVE_TYPE = 'string'; + public const TINYINT_NATIVE_TYPE = 'int'; + public const SMALLINT_NATIVE_TYPE = 'int'; + public const INTEGER_NATIVE_TYPE = 'int'; + public const BIGINT_NATIVE_TYPE = 'string'; + public const REAL_NATIVE_TYPE = 'double'; + public const FLOAT_NATIVE_TYPE = 'double'; + public const DOUBLE_NATIVE_TYPE = 'double'; + public const BINARY_NATIVE_TYPE = 'string'; + public const VARBINARY_NATIVE_TYPE = 'string'; + public const LONGVARBINARY_NATIVE_TYPE = 'string'; + public const BLOB_NATIVE_TYPE = 'resource'; + public const BU_DATE_NATIVE_TYPE = 'string'; + public const DATE_NATIVE_TYPE = 'string'; + public const TIME_NATIVE_TYPE = 'string'; + public const TIMESTAMP_NATIVE_TYPE = 'string'; + public const BU_TIMESTAMP_NATIVE_TYPE = 'string'; + public const BOOLEAN_NATIVE_TYPE = 'boolean'; + public const BOOLEAN_EMU_NATIVE_TYPE = 'boolean'; + public const OBJECT_NATIVE_TYPE = ''; + public const PHP_ARRAY_NATIVE_TYPE = 'array'; + public const ENUM_NATIVE_TYPE = 'int'; + public const SET_NATIVE_TYPE = 'int'; + public const GEOMETRY_NATIVE_TYPE = 'resource'; + public const JSON_TYPE = 'string'; /** * Propel mapping types. @@ -132,37 +134,37 @@ class PropelTypes * @var array */ private static $mappingToPHPNativeMap = [ - self::CHAR => self::CHAR_NATIVE_TYPE, - self::VARCHAR => self::VARCHAR_NATIVE_TYPE, - self::LONGVARCHAR => self::LONGVARCHAR_NATIVE_TYPE, - self::CLOB => self::CLOB_NATIVE_TYPE, - self::CLOB_EMU => self::CLOB_EMU_NATIVE_TYPE, - self::NUMERIC => self::NUMERIC_NATIVE_TYPE, - self::DECIMAL => self::DECIMAL_NATIVE_TYPE, - self::TINYINT => self::TINYINT_NATIVE_TYPE, - self::SMALLINT => self::SMALLINT_NATIVE_TYPE, - self::INTEGER => self::INTEGER_NATIVE_TYPE, - self::BIGINT => self::BIGINT_NATIVE_TYPE, - self::REAL => self::REAL_NATIVE_TYPE, - self::FLOAT => self::FLOAT_NATIVE_TYPE, - self::DOUBLE => self::DOUBLE_NATIVE_TYPE, - self::BINARY => self::BINARY_NATIVE_TYPE, - self::VARBINARY => self::VARBINARY_NATIVE_TYPE, + self::CHAR => self::CHAR_NATIVE_TYPE, + self::VARCHAR => self::VARCHAR_NATIVE_TYPE, + self::LONGVARCHAR => self::LONGVARCHAR_NATIVE_TYPE, + self::CLOB => self::CLOB_NATIVE_TYPE, + self::CLOB_EMU => self::CLOB_EMU_NATIVE_TYPE, + self::NUMERIC => self::NUMERIC_NATIVE_TYPE, + self::DECIMAL => self::DECIMAL_NATIVE_TYPE, + self::TINYINT => self::TINYINT_NATIVE_TYPE, + self::SMALLINT => self::SMALLINT_NATIVE_TYPE, + self::INTEGER => self::INTEGER_NATIVE_TYPE, + self::BIGINT => self::BIGINT_NATIVE_TYPE, + self::REAL => self::REAL_NATIVE_TYPE, + self::FLOAT => self::FLOAT_NATIVE_TYPE, + self::DOUBLE => self::DOUBLE_NATIVE_TYPE, + self::BINARY => self::BINARY_NATIVE_TYPE, + self::VARBINARY => self::VARBINARY_NATIVE_TYPE, self::LONGVARBINARY => self::LONGVARBINARY_NATIVE_TYPE, - self::BLOB => self::BLOB_NATIVE_TYPE, - self::DATE => self::DATE_NATIVE_TYPE, - self::BU_DATE => self::BU_DATE_NATIVE_TYPE, - self::TIME => self::TIME_NATIVE_TYPE, - self::TIMESTAMP => self::TIMESTAMP_NATIVE_TYPE, - self::BU_TIMESTAMP => self::BU_TIMESTAMP_NATIVE_TYPE, - self::BOOLEAN => self::BOOLEAN_NATIVE_TYPE, - self::BOOLEAN_EMU => self::BOOLEAN_EMU_NATIVE_TYPE, - self::OBJECT => self::OBJECT_NATIVE_TYPE, - self::PHP_ARRAY => self::PHP_ARRAY_NATIVE_TYPE, - self::ENUM => self::ENUM_NATIVE_TYPE, - self::SET => self::SET_NATIVE_TYPE, - self::GEOMETRY => self::GEOMETRY, - self::JSON => self::JSON_TYPE, + self::BLOB => self::BLOB_NATIVE_TYPE, + self::DATE => self::DATE_NATIVE_TYPE, + self::BU_DATE => self::BU_DATE_NATIVE_TYPE, + self::TIME => self::TIME_NATIVE_TYPE, + self::TIMESTAMP => self::TIMESTAMP_NATIVE_TYPE, + self::BU_TIMESTAMP => self::BU_TIMESTAMP_NATIVE_TYPE, + self::BOOLEAN => self::BOOLEAN_NATIVE_TYPE, + self::BOOLEAN_EMU => self::BOOLEAN_EMU_NATIVE_TYPE, + self::OBJECT => self::OBJECT_NATIVE_TYPE, + self::PHP_ARRAY => self::PHP_ARRAY_NATIVE_TYPE, + self::ENUM => self::ENUM_NATIVE_TYPE, + self::SET => self::SET_NATIVE_TYPE, + self::GEOMETRY => self::GEOMETRY, + self::JSON => self::JSON_TYPE, ]; /** @@ -172,56 +174,57 @@ class PropelTypes * @var array */ private static $mappingTypeToPDOTypeMap = [ - self::CHAR => \PDO::PARAM_STR, - self::VARCHAR => \PDO::PARAM_STR, - self::LONGVARCHAR => \PDO::PARAM_STR, - self::CLOB => \PDO::PARAM_STR, - self::CLOB_EMU => \PDO::PARAM_STR, - self::NUMERIC => \PDO::PARAM_INT, - self::DECIMAL => \PDO::PARAM_STR, - self::TINYINT => \PDO::PARAM_INT, - self::SMALLINT => \PDO::PARAM_INT, - self::INTEGER => \PDO::PARAM_INT, - self::BIGINT => \PDO::PARAM_INT, - self::REAL => \PDO::PARAM_STR, - self::FLOAT => \PDO::PARAM_STR, - self::DOUBLE => \PDO::PARAM_STR, - self::BINARY => \PDO::PARAM_STR, - self::VARBINARY => \PDO::PARAM_LOB, - self::LONGVARBINARY => \PDO::PARAM_LOB, - self::BLOB => \PDO::PARAM_LOB, - self::DATE => \PDO::PARAM_STR, - self::TIME => \PDO::PARAM_STR, - self::TIMESTAMP => \PDO::PARAM_STR, - self::BOOLEAN => \PDO::PARAM_BOOL, - self::BOOLEAN_EMU => \PDO::PARAM_INT, - self::OBJECT => \PDO::PARAM_LOB, - self::PHP_ARRAY => \PDO::PARAM_STR, - self::ENUM => \PDO::PARAM_INT, - self::SET => \PDO::PARAM_INT, - self::GEOMETRY => \PDO::PARAM_LOB, + self::CHAR => PDO::PARAM_STR, + self::VARCHAR => PDO::PARAM_STR, + self::LONGVARCHAR => PDO::PARAM_STR, + self::CLOB => PDO::PARAM_STR, + self::CLOB_EMU => PDO::PARAM_STR, + self::NUMERIC => PDO::PARAM_INT, + self::DECIMAL => PDO::PARAM_STR, + self::TINYINT => PDO::PARAM_INT, + self::SMALLINT => PDO::PARAM_INT, + self::INTEGER => PDO::PARAM_INT, + self::BIGINT => PDO::PARAM_INT, + self::REAL => PDO::PARAM_STR, + self::FLOAT => PDO::PARAM_STR, + self::DOUBLE => PDO::PARAM_STR, + self::BINARY => PDO::PARAM_STR, + self::VARBINARY => PDO::PARAM_LOB, + self::LONGVARBINARY => PDO::PARAM_LOB, + self::BLOB => PDO::PARAM_LOB, + self::DATE => PDO::PARAM_STR, + self::TIME => PDO::PARAM_STR, + self::TIMESTAMP => PDO::PARAM_STR, + self::BOOLEAN => PDO::PARAM_BOOL, + self::BOOLEAN_EMU => PDO::PARAM_INT, + self::OBJECT => PDO::PARAM_LOB, + self::PHP_ARRAY => PDO::PARAM_STR, + self::ENUM => PDO::PARAM_INT, + self::SET => PDO::PARAM_INT, + self::GEOMETRY => PDO::PARAM_LOB, // These are pre-epoch dates, which we need to map to String type // since they cannot be properly handled using strtotime() -- or even // numeric timestamps on Windows. - self::BU_DATE => \PDO::PARAM_STR, - self::BU_TIMESTAMP => \PDO::PARAM_STR, - self::JSON => \PDO::PARAM_STR, + self::BU_DATE => PDO::PARAM_STR, + self::BU_TIMESTAMP => PDO::PARAM_STR, + self::JSON => PDO::PARAM_STR, ]; private static $pdoTypeNames = [ - \PDO::PARAM_BOOL => 'PDO::PARAM_BOOL', - \PDO::PARAM_NULL => 'PDO::PARAM_NULL', - \PDO::PARAM_INT => 'PDO::PARAM_INT', - \PDO::PARAM_STR => 'PDO::PARAM_STR', - \PDO::PARAM_LOB => 'PDO::PARAM_LOB', + PDO::PARAM_BOOL => 'PDO::PARAM_BOOL', + PDO::PARAM_NULL => 'PDO::PARAM_NULL', + PDO::PARAM_INT => 'PDO::PARAM_INT', + PDO::PARAM_STR => 'PDO::PARAM_STR', + PDO::PARAM_LOB => 'PDO::PARAM_LOB', ]; /** * Returns the native PHP type which corresponds to the * mapping type provided. Use in the base object class generation. * - * @param string $mappingType + * @param string $mappingType + * * @return string */ public static function getPhpNative($mappingType) @@ -232,7 +235,7 @@ public static function getPhpNative($mappingType) /** * Returns the PDO type (PDO::PARAM_* constant) value. * - * @return integer + * @return int */ public static function getPDOType($type) { @@ -262,8 +265,9 @@ public static function getPropelTypes() /** * Returns whether or not the given type is a temporal type. * - * @param string $type - * @return boolean + * @param string $type + * + * @return bool */ public static function isTemporalType($type) { @@ -279,8 +283,9 @@ public static function isTemporalType($type) /** * Returns whether or not the given type is a text type. * - * @param string $mappingType - * @return boolean + * @param string $mappingType + * + * @return bool */ public static function isTextType($mappingType) { @@ -301,8 +306,9 @@ public static function isTextType($mappingType) /** * Returns whether or not the given type is a numeric type. * - * @param string $mappingType - * @return boolean + * @param string $mappingType + * + * @return bool */ public static function isNumericType($mappingType) { @@ -322,8 +328,9 @@ public static function isNumericType($mappingType) /** * Returns whether or not this column is a boolean type. * - * @param string $mappingType - * @return boolean + * @param string $mappingType + * + * @return bool */ public static function isBooleanType($mappingType) { @@ -333,8 +340,9 @@ public static function isBooleanType($mappingType) /** * Returns whether or not this column is a lob/blob type. * - * @param string $mappingType - * @return boolean + * @param string $mappingType + * + * @return bool */ public static function isLobType($mappingType) { @@ -344,8 +352,9 @@ public static function isLobType($mappingType) /** * Returns whether or not a passed-in PHP type is a primitive type. * - * @param string $phpType - * @return boolean + * @param string $phpType + * + * @return bool */ public static function isPhpPrimitiveType($phpType) { @@ -355,8 +364,9 @@ public static function isPhpPrimitiveType($phpType) /** * Returns whether or not a passed-in PHP type is a primitive numeric type. * - * @param string $phpType - * @return boolean + * @param string $phpType + * + * @return bool */ public static function isPhpPrimitiveNumericType($phpType) { @@ -366,8 +376,9 @@ public static function isPhpPrimitiveNumericType($phpType) /** * Returns whether or not a passed-in PHP type is an object. * - * @param string $phpType - * @return boolean + * @param string $phpType + * + * @return bool */ public static function isPhpObjectType($phpType) { @@ -377,8 +388,9 @@ public static function isPhpObjectType($phpType) /** * Convenience method to indicate whether a passed-in PHP type is an array. * - * @param string $phpType The PHP type to check - * @return boolean + * @param string $phpType The PHP type to check + * + * @return bool */ public static function isPhpArrayType($phpType) { diff --git a/src/Propel/Generator/Model/Schema.php b/src/Propel/Generator/Model/Schema.php index 24294ffd61..4bf87b7353 100644 --- a/src/Propel/Generator/Model/Schema.php +++ b/src/Propel/Generator/Model/Schema.php @@ -27,37 +27,42 @@ class Schema { /** - * @var Database[] + * @var \Propel\Generator\Model\Database[] */ private $databases; + /** - * @var PlatformInterface + * @var \Propel\Generator\Platform\PlatformInterface */ private $platform; + private $name; + private $isInitialized; + protected $generatorConfig; /** * Creates a new instance for the specified database type. * - * @param PlatformInterface $platform + * @param \Propel\Generator\Platform\PlatformInterface|null $platform */ - public function __construct(PlatformInterface $platform = null) + public function __construct(?PlatformInterface $platform = null) { - if (null !== $platform) { + if ($platform !== null) { $this->setPlatform($platform); } $this->isInitialized = false; - $this->databases = []; + $this->databases = []; } /** * Sets the platform object to use for any databases added to this * application schema. * - * @param PlatformInterface $platform + * @param \Propel\Generator\Platform\PlatformInterface $platform + * * @return void */ public function setPlatform(PlatformInterface $platform) @@ -69,7 +74,7 @@ public function setPlatform(PlatformInterface $platform) * Returns the platform object to use for any databases added to this * application schema. * - * @return PlatformInterface + * @return \Propel\Generator\Platform\PlatformInterface */ public function getPlatform() { @@ -79,7 +84,8 @@ public function getPlatform() /** * Sets the generator configuration * - * @param GeneratorConfigInterface $generatorConfig + * @param \Propel\Generator\Config\GeneratorConfigInterface $generatorConfig + * * @return void */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) @@ -90,7 +96,7 @@ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) /** * Returns the generator configuration * - * @return GeneratorConfigInterface + * @return \Propel\Generator\Config\GeneratorConfigInterface */ public function getGeneratorConfig() { @@ -101,6 +107,7 @@ public function getGeneratorConfig() * Sets the schema name. * * @param string $name + * * @return void */ public function setName($name) @@ -134,8 +141,9 @@ public function getShortName() * The first boolean parameter tells whether or not to run the * final initialization process. * - * @param boolean $doFinalInitialization - * @return Database[] + * @param bool $doFinalInitialization + * + * @return \Propel\Generator\Model\Database[] */ public function getDatabases($doFinalInitialization = true) { @@ -151,7 +159,7 @@ public function getDatabases($doFinalInitialization = true) /** * Returns whether or not this schema has multiple databases. * - * @return boolean + * @return bool */ public function hasMultipleDatabases() { @@ -161,9 +169,10 @@ public function hasMultipleDatabases() /** * Returns the database according to the specified name. * - * @param string $name - * @param boolean $doFinalInitialization - * @return Database + * @param string|null $name + * @param bool $doFinalInitialization + * + * @return \Propel\Generator\Model\Database */ public function getDatabase($name = null, $doFinalInitialization = true) { @@ -173,7 +182,7 @@ public function getDatabase($name = null, $doFinalInitialization = true) $this->doFinalInitialization(); } - if (null === $name) { + if ($name === null) { return $this->databases[0]; } @@ -181,6 +190,7 @@ public function getDatabase($name = null, $doFinalInitialization = true) foreach ($this->databases as $database) { if ($database->getName() === $name) { $db = $database; + break; } } @@ -192,8 +202,9 @@ public function getDatabase($name = null, $doFinalInitialization = true) * Returns whether or not a database with the specified name exists in this * schema. * - * @param string $name - * @return boolean + * @param string $name + * + * @return bool */ public function hasDatabase($name) { @@ -211,15 +222,16 @@ public function hasDatabase($name) * Schema. The database can be specified as a Database object or a * DOMNode object. * - * @param Database|array $database - * @return Database + * @param \Propel\Generator\Model\Database|array $database + * + * @return \Propel\Generator\Model\Database */ public function addDatabase($database) { if ($database instanceof Database) { $platform = null; $database->setParentSchema($this); - if (null === $database->getPlatform()) { + if ($database->getPlatform() === null) { if ($config = $this->getGeneratorConfig()) { $platform = $config->getConfiguredPlatform(null, $database->getName()); } @@ -257,7 +269,10 @@ public function doFinalInitialization() /** * Merge other Schema objects together into this Schema object. * - * @param Schema[] $schemas + * @param \Propel\Generator\Model\Schema[] $schemas + * + * @throws \Propel\Generator\Exception\EngineException + * * @return void */ public function joinSchemas(array $schemas) @@ -295,7 +310,7 @@ public function joinSchemas(array $schemas) /** * Returns the number of tables in all the databases of this Schema object. * - * @return integer + * @return int */ public function countTables() { diff --git a/src/Propel/Generator/Model/ScopedMappingModel.php b/src/Propel/Generator/Model/ScopedMappingModel.php index 49be74ab68..63e088c3b1 100644 --- a/src/Propel/Generator/Model/ScopedMappingModel.php +++ b/src/Propel/Generator/Model/ScopedMappingModel.php @@ -49,7 +49,7 @@ public function __construct() /** * Returns whether or not the package has been overriden. * - * @return boolean + * @return bool */ public function isPackageOverriden() { @@ -63,6 +63,9 @@ public function isPackageOverriden() */ abstract protected function getBuildProperty($name); + /** + * @return void + */ protected function setupObject() { $this->setPackage($this->getAttribute('package', $this->package)); @@ -107,12 +110,13 @@ public function setNamespace($namespace) * * A namespace is absolute if it starts with a "\". * - * @param string $namespace - * @return boolean + * @param string $namespace + * + * @return bool */ public function isAbsoluteNamespace($namespace) { - return 0 === strpos($namespace, '\\'); + return strpos($namespace, '\\') === 0; } /** @@ -129,6 +133,7 @@ public function getPackage() * Sets the package name. * * @param string $package + * * @return void */ public function setPackage($package) @@ -155,6 +160,7 @@ public function getSchema() * Sets the schema name. * * @param string $schema + * * @return void */ public function setSchema($schema) diff --git a/src/Propel/Generator/Model/Table.php b/src/Propel/Generator/Model/Table.php index 5fc749f9ac..2ad07ebce9 100644 --- a/src/Propel/Generator/Model/Table.php +++ b/src/Propel/Generator/Model/Table.php @@ -10,12 +10,10 @@ namespace Propel\Generator\Model; -use Propel\Generator\Config\GeneratorConfig; use Propel\Generator\Exception\BuildException; use Propel\Generator\Exception\EngineException; use Propel\Generator\Exception\InvalidArgumentException; use Propel\Generator\Platform\MysqlPlatform; -use Propel\Generator\Platform\PlatformInterface; use Propel\Runtime\Exception\RuntimeException; /** @@ -35,17 +33,17 @@ class Table extends ScopedMappingModel implements IdMethod use BehaviorableTrait; /** - * @var Column[] + * @var \Propel\Generator\Model\Column[] */ private $columns = []; /** - * @var ForeignKey[] + * @var \Propel\Generator\Model\ForeignKey[] */ private $foreignKeys = []; /** - * @var ForeignKey[] + * @var \Propel\Generator\Model\ForeignKey[] */ private $foreignKeysByName = []; @@ -55,33 +53,41 @@ class Table extends ScopedMappingModel implements IdMethod private $foreignTableNames = []; /** - * @var Index[] + * @var \Propel\Generator\Model\Index[] */ private $indices = []; /** - * @var Unique[] + * @var \Propel\Generator\Model\Unique[] */ private $unices = []; + /** - * @var IdMethodParameter[] + * @var \Propel\Generator\Model\IdMethodParameter[] */ private $idMethodParameters = []; + private $commonName; + private $originCommonName; + private $description; + private $phpName; + private $idMethod; + private $allowPkInsert = false; + private $phpNamingMethod; /** - * @var Database|null + * @var \Propel\Generator\Model\Database|null */ private $database; /** - * @var ForeignKey[] + * @var \Propel\Generator\Model\ForeignKey[] */ private $referrers = []; @@ -91,20 +97,30 @@ class Table extends ScopedMappingModel implements IdMethod private $containsForeignPK = false; /** - * @var Column|null + * @var \Propel\Generator\Model\Column|null */ private $inheritanceColumn; private $skipSql = false; + private $readOnly = false; + private $isAbstract = false; + private $alias; + private $interface; + private $baseClass; + private $baseQueryClass; + private $columnsByName = []; + private $columnsByLowercaseName = []; + private $columnsByPhpName = []; + private $needsTransactionInPostgres = false; /** @@ -169,13 +185,13 @@ public function __construct($name = null) { parent::__construct(); - if (null !== $name) { + if ($name !== null) { $this->setCommonName($name); } - $this->idMethod = IdMethod::NO_ID_METHOD; + $this->idMethod = IdMethod::NO_ID_METHOD; $this->defaultAccessorVisibility = static::VISIBILITY_PUBLIC; - $this->defaultMutatorVisibility = static::VISIBILITY_PUBLIC; + $this->defaultMutatorVisibility = static::VISIBILITY_PUBLIC; } /** @@ -227,7 +243,7 @@ public function setupObject() $this->heavyIndexing = ( $this->booleanValue($this->getAttribute('heavyIndexing')) || ( - 'false' !== $this->getAttribute('heavyIndexing') + $this->getAttribute('heavyIndexing') !== 'false' && $this->database->isHeavyIndexing() ) ); @@ -244,13 +260,14 @@ public function setupObject() $this->isCrossRef = $this->booleanValue($this->getAttribute('isCrossRef', false)); $this->defaultStringFormat = $this->getAttribute('defaultStringFormat'); $this->defaultAccessorVisibility = $this->getAttribute('defaultAccessorVisibility', $this->database->getAttribute('defaultAccessorVisibility', static::VISIBILITY_PUBLIC)); - $this->defaultMutatorVisibility = $this->getAttribute('defaultMutatorVisibility', $this->database->getAttribute('defaultMutatorVisibility', static::VISIBILITY_PUBLIC)); + $this->defaultMutatorVisibility = $this->getAttribute('defaultMutatorVisibility', $this->database->getAttribute('defaultMutatorVisibility', static::VISIBILITY_PUBLIC)); } /** * Returns a build property value for the database this table belongs to. * - * @param string $key + * @param string $key + * * @return string */ public function getBuildProperty($key) @@ -309,7 +326,7 @@ public function doFinalInitialization() $anyAutoInc = true; } } - if (IdMethod::NATIVE === $this->getIdMethod() && !$anyAutoInc) { + if ($this->getIdMethod() === IdMethod::NATIVE && !$anyAutoInc) { $this->setIdMethod(IdMethod::NO_ID_METHOD); } } @@ -412,7 +429,7 @@ public function addExtraIndices() // MySQL needs indices on any columns that serve as foreign keys. // These are not auto-created prior to 4.1.2. - $name = substr_replace($foreignKey->getName(), 'fi_', strrpos($foreignKey->getName(), 'fk_'), 3); + $name = substr_replace($foreignKey->getName(), 'fi_', strrpos($foreignKey->getName(), 'fk_'), 3); if ($this->hasIndex($name)) { // if we already have an index with this name, then it looks like the columns of this index have just // been changed, so remove it and inject it again. This is the case if a referenced table is handled @@ -428,9 +445,10 @@ public function addExtraIndices() /** * Creates a new index. * - * @param string $name The index name - * @param array $columns The list of columns to index - * @return Index $index The created index + * @param string $name The index name + * @param array $columns The list of columns to index + * + * @return \Propel\Generator\Model\Index The created index */ protected function createIndex($name, array $columns) { @@ -446,9 +464,10 @@ protected function createIndex($name, array $columns) /** * Helper function to collect indexed columns. * - * @param string $indexName The name of the index - * @param array $columns The column names or objects - * @param array $collectedIndexes The collected indexes + * @param string $indexName The name of the index + * @param array $columns The column names or objects + * @param array $collectedIndexes The collected indexes + * * @return void */ protected function collectIndexedColumns($indexName, $columns, &$collectedIndexes) @@ -475,8 +494,10 @@ protected function collectIndexedColumns($indexName, $columns, &$collectedIndexe * Returns a delimiter-delimited string list of column names. * * @see Platform::getColumnList() if quoting is required + * * @param array $columns - * @param string $delimiter + * @param string $delimiter + * * @return string */ public function getColumnList($columns, $delimiter = ',') @@ -500,11 +521,11 @@ public function getColumnList($columns, $delimiter = ',') */ public function getBaseClass() { - if ($this->isAlias() && null === $this->baseClass) { + if ($this->isAlias() && $this->baseClass === null) { return $this->alias; } - if (null === $this->baseClass) { + if ($this->baseClass === null) { return $this->database->getBaseClass(); } @@ -519,7 +540,7 @@ public function getBaseClass() */ public function getBaseQueryClass() { - if (null === $this->baseQueryClass) { + if ($this->baseQueryClass === null) { return $this->database->getBaseQueryClass(); } @@ -530,6 +551,7 @@ public function getBaseQueryClass() * Sets the base class name. * * @param string $class + * * @return void */ public function setBaseClass($class) @@ -541,6 +563,7 @@ public function setBaseClass($class) * Sets the base query class name. * * @param string $class + * * @return void */ public function setBaseQueryClass($class) @@ -551,14 +574,15 @@ public function setBaseQueryClass($class) /** * Adds a new column to the table. * - * @param Column|array $col - * @throws EngineException - * @return Column + * @param \Propel\Generator\Model\Column|array $col + * + * @throws \Propel\Generator\Exception\EngineException + * + * @return \Propel\Generator\Model\Column */ public function addColumn($col) { if ($col instanceof Column) { - if (isset($this->columnsByName[$col->getName()])) { throw new EngineException(sprintf('Column "%s" declared twice in table "%s"', $col->getName(), $this->getName())); } @@ -592,7 +616,8 @@ public function addColumn($col) /** * Adds several columns at once. * - * @param Column[] $columns An array of Column instance + * @param \Propel\Generator\Model\Column[] $columns An array of Column instance + * * @return void */ public function addColumns(array $columns) @@ -605,8 +630,10 @@ public function addColumns(array $columns) /** * Removes a column from the table. * - * @param Column|string $column The Column or its name - * @throws EngineException + * @param \Propel\Generator\Model\Column|string $column The Column or its name + * + * @throws \Propel\Generator\Exception\EngineException + * * @return void */ public function removeColumn($column) @@ -616,7 +643,7 @@ public function removeColumn($column) } $pos = $this->getColumnPosition($column); - if (false === $pos) { + if ($pos === false) { throw new EngineException(sprintf('No column named %s found in table %s.', $column->getName(), $this->getName())); } @@ -637,7 +664,7 @@ public function removeColumn($column) */ private function getColumnPosition(Column $column) { - $position = false; + $position = false; $nbColumns = $this->getNumColumns(); for ($pos = 0; $pos < $nbColumns; $pos++) { if ($this->columns[$pos] === $column) { @@ -663,8 +690,11 @@ public function adjustColumnPositions() /** * Adds a new foreign key to this table. * - * @param ForeignKey|array $foreignKey The foreign key mapping - * @return ForeignKey + * @param \Propel\Generator\Model\ForeignKey|array $foreignKey The foreign key mapping + * + * @throws \Propel\Generator\Exception\EngineException + * + * @return \Propel\Generator\Model\ForeignKey */ public function addForeignKey($foreignKey) { @@ -687,7 +717,7 @@ public function addForeignKey($foreignKey) return $fk; } - $fk = new ForeignKey(isset($foreignKey['name'])? $foreignKey['name'] :null ); + $fk = new ForeignKey(isset($foreignKey['name']) ? $foreignKey['name'] : null); $fk->setTable($this); $fk->loadMapping($foreignKey); @@ -697,7 +727,8 @@ public function addForeignKey($foreignKey) /** * Adds several foreign keys at once. * - * @param ForeignKey[] $foreignKeys An array of ForeignKey objects + * @param \Propel\Generator\Model\ForeignKey[] $foreignKeys An array of ForeignKey objects + * * @return void */ public function addForeignKeys(array $foreignKeys) @@ -711,7 +742,7 @@ public function addForeignKeys(array $foreignKeys) * Returns the column that subclasses the class representing this * table can be produced from. * - * @return Column|null + * @return \Propel\Generator\Model\Column|null */ public function getChildrenColumn() { @@ -725,8 +756,10 @@ public function getChildrenColumn() */ public function getChildrenNames() { - if (null === $this->inheritanceColumn - || !$this->inheritanceColumn->isEnumeratedClasses()) { + if ( + $this->inheritanceColumn === null + || !$this->inheritanceColumn->isEnumeratedClasses() + ) { return null; } @@ -741,7 +774,8 @@ public function getChildrenNames() /** * Adds the foreign key from another table that refers to this table. * - * @param ForeignKey $fk + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return void */ public function addReferrer(ForeignKey $fk) @@ -752,7 +786,7 @@ public function addReferrer(ForeignKey $fk) /** * Returns the list of references to this table. * - * @return ForeignKey[] + * @return \Propel\Generator\Model\ForeignKey[] */ public function getReferrers() { @@ -765,20 +799,21 @@ public function getReferrers() * adds the missing referrers and is non-destructive. * Warning: only use when all the tables were created. * - * @param boolean $throwErrors - * @throws BuildException + * @param bool $throwErrors + * + * @throws \Propel\Generator\Exception\BuildException + * * @return void */ public function setupReferrers($throwErrors = false) { foreach ($this->foreignKeys as $foreignKey) { - // table referrers $foreignTable = $this->database->getTable($foreignKey->getForeignTableName()); - if (null !== $foreignTable) { + if ($foreignTable !== null) { $referrers = $foreignTable->getReferrers(); - if (null === $referrers || !in_array($foreignKey, $referrers, true) ) { + if ($referrers === null || !in_array($foreignKey, $referrers, true)) { $foreignTable->addReferrer($foreignKey); } } elseif ($throwErrors) { @@ -793,7 +828,7 @@ public function setupReferrers($throwErrors = false) $localColumnNames = $foreignKey->getLocalColumns(); foreach ($localColumnNames as $localColumnName) { $localColumn = $this->getColumn($localColumnName); - if (null !== $localColumn) { + if ($localColumn !== null) { if ($localColumn->isPrimaryKey() && !$this->getContainsForeignPK()) { $this->setContainsForeignPK(true); } @@ -812,11 +847,11 @@ public function setupReferrers($throwErrors = false) // foreign column references $foreignColumnNames = $foreignKey->getForeignColumns(); foreach ($foreignColumnNames as $foreignColumnName) { - if (null === $foreignTable) { + if ($foreignTable === null) { continue; } $foreignColumn = $foreignTable->getColumn($foreignColumnName); - if (null !== $foreignColumn) { + if ($foreignColumn !== null) { if (!$foreignColumn->hasReferrer($foreignKey)) { $foreignColumn->addReferrer($foreignKey); } @@ -860,7 +895,7 @@ public function setupReferrers($throwErrors = false) /** * Returns the list of cross foreign keys. * - * @return CrossForeignKeys[] + * @return \Propel\Generator\Model\CrossForeignKeys[] */ public function getCrossFks() { @@ -869,8 +904,10 @@ public function getCrossFks() if ($refFK->getTable()->isCrossRef()) { $crossFK = new CrossForeignKeys($refFK, $this); foreach ($refFK->getOtherFks() as $fk) { - if ($fk->isAtLeastOneLocalPrimaryKeyIsRequired() && - $crossFK->isAtLeastOneLocalPrimaryKeyNotCovered($fk)) { + if ( + $fk->isAtLeastOneLocalPrimaryKeyIsRequired() && + $crossFK->isAtLeastOneLocalPrimaryKeyNotCovered($fk) + ) { $crossFK->addCrossForeignKey($fk); } } @@ -886,8 +923,9 @@ public function getCrossFks() /** * Returns all required(notNull && no defaultValue) primary keys which are not in $primaryKeys. * - * @param Column[] $primaryKeys - * @return Column[] + * @param \Propel\Generator\Model\Column[] $primaryKeys + * + * @return \Propel\Generator\Model\Column[] */ public function getOtherRequiredPrimaryKeys(array $primaryKeys) { @@ -905,17 +943,18 @@ public function getOtherRequiredPrimaryKeys(array $primaryKeys) * Sets whether or not this table contains a foreign primary key. * * @param bool $containsForeignPK + * * @return void */ public function setContainsForeignPK($containsForeignPK) { - $this->containsForeignPK = (bool) $containsForeignPK; + $this->containsForeignPK = (bool)$containsForeignPK; } /** * Returns whether or not this table contains a foreign primary key. * - * @return boolean + * @return bool */ public function getContainsForeignPK() { @@ -935,7 +974,7 @@ public function getForeignTableNames() /** * Return true if the column requires a transaction in Postgres. * - * @return boolean + * @return bool */ public function requiresTransactionInPostgres() { @@ -945,8 +984,9 @@ public function requiresTransactionInPostgres() /** * Adds a new parameter for the strategy that generates primary keys. * - * @param IdMethodParameter|array $idMethodParameter - * @return IdMethodParameter + * @param \Propel\Generator\Model\IdMethodParameter|array $idMethodParameter + * + * @return \Propel\Generator\Model\IdMethodParameter */ public function addIdMethodParameter($idMethodParameter) { @@ -968,6 +1008,7 @@ public function addIdMethodParameter($idMethodParameter) * Removes a index from the table. * * @param string $name + * * @return void */ public function removeIndex($name) @@ -985,8 +1026,9 @@ public function removeIndex($name) /** * Checks if the table has a index by name. * - * @param string $name - * @return boolean + * @param string $name + * + * @return bool */ public function hasIndex($name) { @@ -1003,10 +1045,13 @@ public function hasIndex($name) * Adds a new index to the indices list and set the * parent table of the column to the current table. * - * @param Index|array $index - * @return Index + * @throw InvalidArgumentException * - * @throw InvalidArgumentException + * @param \Propel\Generator\Model\Index|array $index + * + * @throws \Propel\Generator\Exception\InvalidArgumentException + * + * @return \Propel\Generator\Model\Index */ public function addIndex($index) { @@ -1026,7 +1071,7 @@ public function addIndex($index) $idx = new Index(); $idx->loadMapping($index); - foreach((array)@$index['columns'] as $column) { + foreach ((array)@$index['columns'] as $column) { $idx->addColumn($column); } @@ -1037,8 +1082,9 @@ public function addIndex($index) * Adds a new Unique index to the list of unique indices and set the * parent table of the column to the current table. * - * @param Unique|array $unique - * @return Unique + * @param \Propel\Generator\Model\Unique|array $unique + * + * @return \Propel\Generator\Model\Unique */ public function addUnique($unique) { @@ -1069,7 +1115,7 @@ public function getGeneratorConfig() /** * Returns whether or not the table behaviors offer additional builders. * - * @return boolean + * @return bool */ public function hasAdditionalBuilders() { @@ -1146,15 +1192,14 @@ public function guessSchemaName() /** * Returns whether or not this table is linked to a schema. * - * @return boolean + * @return bool */ private function hasSchema() { return $this->database && ($this->schema ?: $this->database->getSchema()) && ($platform = $this->getPlatform()) - && $platform->supportsSchemas() - ; + && $platform->supportsSchemas(); } /** @@ -1170,7 +1215,7 @@ public function getDescription() /** * Returns whether or not the table has a description. * - * @return boolean + * @return bool */ public function hasDescription() { @@ -1181,6 +1226,7 @@ public function hasDescription() * Sets the table description. * * @param string $description + * * @return void */ public function setDescription($description) @@ -1192,11 +1238,10 @@ public function setDescription($description) * Returns the name to use in PHP sources. * * @return string - * @throws EngineException */ public function getPhpName() { - if (null === $this->phpName) { + if ($this->phpName === null) { $this->phpName = $this->buildPhpName($this->getStdSeparatedName()); } @@ -1207,6 +1252,7 @@ public function getPhpName() * Sets the name to use in PHP sources. * * @param string $phpName + * * @return void */ public function setPhpName($phpName) @@ -1217,7 +1263,8 @@ public function setPhpName($phpName) /** * Returns the auto generated PHP name value for a given name. * - * @param string $name + * @param string $name + * * @return string */ private function buildPhpName($name) @@ -1251,6 +1298,7 @@ public function getCommonName() * Sets the table common name (without schema name). * * @param string $name + * * @return void */ public function setCommonName($name) @@ -1273,8 +1321,10 @@ public function getOriginCommonName() * * Any of 'XML', 'YAML', 'JSON', or 'CSV'. * - * @param string $format - * @throws InvalidArgumentException + * @param string $format + * + * @throws \Propel\Generator\Exception\InvalidArgumentException + * * @return void */ public function setDefaultStringFormat($format) @@ -1297,7 +1347,7 @@ public function setDefaultStringFormat($format) */ public function getDefaultStringFormat() { - if (null !== $this->defaultStringFormat) { + if ($this->defaultStringFormat !== null) { return $this->defaultStringFormat; } @@ -1321,7 +1371,7 @@ public function getIdMethod() * Returns whether we allow to insert primary keys on tables with * native id method. * - * @return boolean + * @return bool */ public function isAllowPkInsert() { @@ -1332,6 +1382,7 @@ public function isAllowPkInsert() * Sets the method strategy for generating primary keys. * * @param string $idMethod + * * @return void */ public function setIdMethod($idMethod) @@ -1343,7 +1394,7 @@ public function setIdMethod($idMethod) * Returns whether or not Propel has to skip DDL SQL generation for this * table (in the event it should not be created from scratch). * - * @return boolean + * @return bool */ public function isSkipSql() { @@ -1353,19 +1404,20 @@ public function isSkipSql() /** * Sets whether or not this table should have its SQL DDL code generated. * - * @param boolean $skip + * @param bool $skip + * * @return void */ public function setSkipSql($skip) { - $this->skipSql = (bool) $skip; + $this->skipSql = (bool)$skip; } /** * Returns whether or not this table is read-only. If yes, only only * accessors and relationship accessors and mutators will be generated. * - * @return boolean + * @return bool */ public function isReadOnly() { @@ -1375,17 +1427,19 @@ public function isReadOnly() /** * Makes this database in read-only mode. * - * @param boolean $flag True by default + * @param bool $flag True by default + * * @return void */ public function setReadOnly($flag = true) { - $this->readOnly = (boolean) $flag; + $this->readOnly = (bool)$flag; } /** * Whether to force object to reload on INSERT. - * @return boolean + * + * @return bool */ public function isReloadOnInsert() { @@ -1395,18 +1449,19 @@ public function isReloadOnInsert() /** * Makes this database reload on insert statement. * - * @param boolean $flag True by default + * @param bool $flag True by default + * * @return void */ public function setReloadOnInsert($flag = true) { - $this->reloadOnInsert = (boolean) $flag; + $this->reloadOnInsert = (bool)$flag; } /** * Returns whether or not to force object to reload on UPDATE. * - * @return boolean + * @return bool */ public function isReloadOnUpdate() { @@ -1416,12 +1471,13 @@ public function isReloadOnUpdate() /** * Makes this database reload on update statement. * - * @param boolean $flag True by default + * @param bool $flag True by default + * * @return void */ public function setReloadOnUpdate($flag = true) { - $this->reloadOnUpdate = (boolean) $flag; + $this->reloadOnUpdate = (bool)$flag; } /** @@ -1438,11 +1494,11 @@ public function getAlias() * Returns whether or not this table is specified in the schema or if there * is just a foreign key reference to it. * - * @return boolean + * @return bool */ public function isAlias() { - return null !== $this->alias; + return $this->alias !== null; } /** @@ -1450,6 +1506,7 @@ public function isAlias() * just a foreign key reference to it. * * @param string $alias + * * @return void */ public function setAlias($alias) @@ -1471,6 +1528,7 @@ public function getInterface() * Sets the interface objects of this table will implement. * * @param string $interface + * * @return void */ public function setInterface($interface) @@ -1484,7 +1542,7 @@ public function setInterface($interface) * "FOO", then the Foo business object class will be declared abstract. This * helps support class hierarchies * - * @return boolean + * @return bool */ public function isAbstract() { @@ -1497,18 +1555,19 @@ public function isAbstract() * table called "FOO", then the Foo business object class will be * declared abstract. This helps support class hierarchies * - * @param boolean $flag + * @param bool $flag + * * @return void */ public function setAbstract($flag = true) { - $this->isAbstract = (boolean) $flag; + $this->isAbstract = (bool)$flag; } /** * Returns an array containing all Column objects in the table. * - * @return Column[] + * @return \Propel\Generator\Model\Column[] */ public function getColumns() { @@ -1518,7 +1577,7 @@ public function getColumns() /** * Returns the number of columns in this table. * - * @return integer + * @return int */ public function getNumColumns() { @@ -1528,7 +1587,7 @@ public function getNumColumns() /** * Returns the number of lazy loaded columns in this table. * - * @return integer + * @return int */ public function getNumLazyLoadColumns() { @@ -1545,7 +1604,7 @@ public function getNumLazyLoadColumns() /** * Returns whether or not one of the columns is of type ENUM or SET. * - * @return boolean + * @return bool */ public function hasValueSetColumns() { @@ -1561,7 +1620,7 @@ public function hasValueSetColumns() /** * Returns the list of all foreign keys. * - * @return ForeignKey[] + * @return \Propel\Generator\Model\ForeignKey[] */ public function getForeignKeys() { @@ -1572,7 +1631,7 @@ public function getForeignKeys() * Returns a Collection of parameters relevant for the chosen * id generation method. * - * @return IdMethodParameter[] + * @return \Propel\Generator\Model\IdMethodParameter[] */ public function getIdMethodParameters() { @@ -1582,7 +1641,7 @@ public function getIdMethodParameters() /** * Returns the list of all indices of this table. * - * @return Index[] + * @return \Propel\Generator\Model\Index[] */ public function getIndices() { @@ -1592,7 +1651,7 @@ public function getIndices() /** * Returns the list of all unique indices of this table. * - * @return Unique[] + * @return \Propel\Generator\Model\Unique[] */ public function getUnices() { @@ -1603,19 +1662,20 @@ public function getUnices() * Checks if $keys are a unique constraint in the table. * (through primaryKey, through a regular unices constraints or for single keys when it has isUnique=true) * - * @param Column[]|string[] $keys - * @return boolean + * @param \Propel\Generator\Model\Column[]|string[] $keys + * + * @return bool */ public function isUnique(array $keys) { - if (1 === count($keys)) { + if (count($keys) === 1) { $column = $keys[0] instanceof Column ? $keys[0] : $this->getColumn($keys[0]); if ($column) { if ($column->isUnique()) { return true; } - if ($column->isPrimaryKey() && 1 === count($column->getTable()->getPrimaryKey())) { + if ($column->isPrimaryKey() && count($column->getTable()->getPrimaryKey()) === 1) { return true; } } @@ -1629,11 +1689,13 @@ public function isUnique(array $keys) if ($stringArray) { if (!in_array($pk->getName(), $keys)) { $allPk = false; + break; } } else { if (!in_array($pk, $keys)) { $allPk = false; + break; } } @@ -1652,6 +1714,7 @@ public function isUnique(array $keys) foreach ($keys as $key) { if (!$unique->hasColumn($key instanceof Column ? $key->getName() : $key)) { $allAvailable = false; + break; } } @@ -1670,8 +1733,9 @@ public function isUnique(array $keys) /** * Checks if a index exists with the given $keys. * - * @param array $keys - * @return boolean + * @param array $keys + * + * @return bool */ public function isIndex(array $keys) { @@ -1682,6 +1746,7 @@ public function isIndex(array $keys) foreach ($keys as $key) { if (!$index->hasColumn($key instanceof Column ? $key->getName() : $key)) { $allAvailable = false; + break; } } @@ -1698,9 +1763,10 @@ public function isIndex(array $keys) /** * Returns whether or not the table has a column. * - * @param Column|string $column The Column object or its name - * @param boolean $caseInsensitive Whether the check is case insensitive. - * @return boolean + * @param \Propel\Generator\Model\Column|string $column The Column object or its name + * @param bool $caseInsensitive Whether the check is case insensitive. + * + * @return bool */ public function hasColumn($column, $caseInsensitive = false) { @@ -1718,9 +1784,10 @@ public function hasColumn($column, $caseInsensitive = false) /** * Returns the Column object with the specified name. * - * @param string $name The name of the column (e.g. 'my_column') - * @param boolean $caseInsensitive Whether the check is case insensitive. - * @return Column|null + * @param string $name The name of the column (e.g. 'my_column') + * @param bool $caseInsensitive Whether the check is case insensitive. + * + * @return \Propel\Generator\Model\Column|null */ public function getColumn($name, $caseInsensitive = false) { @@ -1738,8 +1805,9 @@ public function getColumn($name, $caseInsensitive = false) /** * Returns a specified column by its php name. * - * @param string $phpName - * @return Column|null + * @param string $phpName + * + * @return \Propel\Generator\Model\Column|null */ public function getColumnByPhpName($phpName) { @@ -1754,7 +1822,8 @@ public function getColumnByPhpName($phpName) * Returns all foreign keys from this table that reference the table passed * in argument. * - * @param string $tableName + * @param string $tableName + * * @return \Propel\Generator\Model\ForeignKey[] */ public function getForeignKeysReferencingTable($tableName) @@ -1776,7 +1845,8 @@ public function getForeignKeysReferencingTable($tableName) * Eg. Foreign key (a, b, c) references tbl(x, y, z) will be returned of $column * is either a, b or c. * - * @param string $column Name of the column + * @param string $column Name of the column + * * @return \Propel\Generator\Model\ForeignKey[] */ public function getColumnForeignKeys($column) @@ -1794,7 +1864,8 @@ public function getColumnForeignKeys($column) /** * Set the database that contains this table. * - * @param Database $database + * @param \Propel\Generator\Model\Database $database + * * @return void */ public function setDatabase(Database $database) @@ -1805,7 +1876,7 @@ public function setDatabase(Database $database) /** * Get the database that contains this table. * - * @return Database|null + * @return \Propel\Generator\Model\Database|null */ public function getDatabase() { @@ -1815,7 +1886,7 @@ public function getDatabase() /** * Returns the Database platform. * - * @return PlatformInterface|null + * @return \Propel\Generator\Platform\PlatformInterface|null */ public function getPlatform() { @@ -1828,6 +1899,9 @@ public function getPlatform() * Needs a platform assigned to its database. * * @param string $text + * + * @throws \Propel\Runtime\Exception\RuntimeException + * * @return string */ public function quoteIdentifier($text) @@ -1848,7 +1922,7 @@ public function quoteIdentifier($text) * * Table will be skipped, if return true. * - * @return boolean|null + * @return bool|null */ public function isForReferenceOnly() { @@ -1859,19 +1933,20 @@ public function isForReferenceOnly() * Returns whether or not to determine if code/sql gets created for this table. * Table will be skipped, if set to true. * - * @param boolean $flag + * @param bool $flag + * * @return void */ public function setForReferenceOnly($flag = true) { - $this->forReferenceOnly = (boolean) $flag; + $this->forReferenceOnly = (bool)$flag; } /** * Returns the collection of Columns which make up the single primary * key for this table. * - * @return Column[] + * @return \Propel\Generator\Model\Column[] */ public function getPrimaryKey() { @@ -1888,7 +1963,7 @@ public function getPrimaryKey() /** * Returns whether or not this table has a primary key. * - * @return boolean + * @return bool */ public function hasPrimaryKey() { @@ -1898,7 +1973,7 @@ public function hasPrimaryKey() /** * Returns whether or not this table has a composite primary key. * - * @return boolean + * @return bool */ public function hasCompositePrimaryKey() { @@ -1910,7 +1985,7 @@ public function hasCompositePrimaryKey() * * Useful for tables with a PK using a single column. * - * @return Column|null + * @return \Propel\Generator\Model\Column|null */ public function getFirstPrimaryKeyColumn() { @@ -1942,21 +2017,21 @@ public function __clone() /** * Returns whether or not this table has any auto-increment primary keys. * - * @return boolean + * @return bool */ public function hasAutoIncrementPrimaryKey() { - return null !== $this->getAutoIncrementPrimaryKey(); + return $this->getAutoIncrementPrimaryKey() !== null; } /** * Returns the auto incremented primary key. * - * @return Column|null + * @return \Propel\Generator\Model\Column|null */ public function getAutoIncrementPrimaryKey() { - if (IdMethod::NO_ID_METHOD !== $this->getIdMethod()) { + if ($this->getIdMethod() !== IdMethod::NO_ID_METHOD) { foreach ($this->getPrimaryKey() as $pk) { if ($pk->isAutoIncrement()) { return $pk; @@ -1971,7 +2046,7 @@ public function getAutoIncrementPrimaryKey() * Returns whether or not there is a cross reference status for this foreign * key. * - * @return boolean + * @return bool */ public function getIsCrossRef() { @@ -1981,7 +2056,7 @@ public function getIsCrossRef() /** * Alias for Table::getIsCrossRef. * - * @return boolean + * @return bool */ public function isCrossRef() { @@ -1991,7 +2066,8 @@ public function isCrossRef() /** * Sets a cross reference status for this foreign key. * - * @param boolean $flag + * @param bool $flag + * * @return void */ public function setIsCrossRef($flag = true) @@ -2002,32 +2078,33 @@ public function setIsCrossRef($flag = true) /** * Sets a cross reference status for this foreign key. * - * @param boolean $flag + * @param bool $flag + * * @return void */ public function setCrossRef($flag = true) { - $this->isCrossRef = (boolean) $flag; + $this->isCrossRef = (bool)$flag; } /** * Returns whether or not the table has foreign keys. * - * @return boolean + * @return bool */ public function hasForeignKeys() { - return 0 !== count($this->foreignKeys); + return count($this->foreignKeys) !== 0; } /** * Returns whether the table has cross foreign keys or not. * - * @return boolean + * @return bool */ public function hasCrossForeignKeys() { - return 0 !== count($this->getCrossFks()); + return count($this->getCrossFks()) !== 0; } /** @@ -2044,6 +2121,7 @@ public function getPhpNamingMethod() * Sets the PHP naming method. * * @param string $phpNamingMethod + * * @return void */ public function setPhpNamingMethod($phpNamingMethod) @@ -2055,6 +2133,7 @@ public function setPhpNamingMethod($phpNamingMethod) * Sets the default accessor visibility. * * @param string $defaultAccessorVisibility + * * @return void */ public function setDefaultAccessorVisibility($defaultAccessorVisibility) @@ -2076,6 +2155,7 @@ public function getDefaultAccessorVisibility() * Sets the default mutator visibility. * * @param string $defaultMutatorVisibility + * * @return void */ public function setDefaultMutatorVisibility($defaultMutatorVisibility) @@ -2099,11 +2179,11 @@ public function getDefaultMutatorVisibility() * * Use getIdentifierQuoting() if you need the raw value. * - * @return boolean + * @return bool */ public function isIdentifierQuotingEnabled() { - return (null !== $this->identifierQuoting || !$this->database) ? $this->identifierQuoting : $this->database->isIdentifierQuotingEnabled(); + return ($this->identifierQuoting !== null || !$this->database) ? $this->identifierQuoting : $this->database->isIdentifierQuotingEnabled(); } /** @@ -2115,12 +2195,12 @@ public function getIdentifierQuoting() } /** - * @param boolean $identifierQuoting + * @param bool $identifierQuoting + * * @return void */ public function setIdentifierQuoting($identifierQuoting) { $this->identifierQuoting = $identifierQuoting; } - } diff --git a/src/Propel/Generator/Model/Unique.php b/src/Propel/Generator/Model/Unique.php index 04e793d55b..ef1a2dec06 100644 --- a/src/Propel/Generator/Model/Unique.php +++ b/src/Propel/Generator/Model/Unique.php @@ -11,9 +11,9 @@ namespace Propel\Generator\Model; /** - * Information about unique columns of a table. This class assumes + * Information about unique columns of a table. This class assumes * that in the underlying RDBMS, unique constraints and unique indices - * are roughly equivalent. For example, adding a unique constraint to + * are roughly equivalent. For example, adding a unique constraint to * a column also creates an index on that column (this is known to be * true for MySQL and Oracle). * @@ -33,5 +33,4 @@ public function isUnique() { return true; } - } diff --git a/src/Propel/Generator/Model/VendorInfo.php b/src/Propel/Generator/Model/VendorInfo.php index fc358f8fd7..623d68f12e 100644 --- a/src/Propel/Generator/Model/VendorInfo.php +++ b/src/Propel/Generator/Model/VendorInfo.php @@ -19,19 +19,20 @@ class VendorInfo extends MappingModel { private $type; + private $parameters; /** * Creates a new VendorInfo instance. * - * @param string|null $type RDBMS type (optional) - * @param array $parameters An associative array of vendor's parameters (optional) + * @param string|null $type RDBMS type (optional) + * @param array $parameters An associative array of vendor's parameters (optional) */ public function __construct($type = null, array $parameters = []) { $this->parameters = []; - if (null !== $type) { + if ($type !== null) { $this->setType($type); } @@ -44,6 +45,7 @@ public function __construct($type = null, array $parameters = []) * Sets the RDBMS type for this vendor specific information. * * @param string $type + * * @return void */ public function setType($type) @@ -64,8 +66,9 @@ public function getType() /** * Sets a parameter value. * - * @param string $name The parameter name - * @param mixed $value The parameter value + * @param string $name The parameter name + * @param mixed $value The parameter value + * * @return void */ public function setParameter($name, $value) @@ -76,7 +79,8 @@ public function setParameter($name, $value) /** * Returns a parameter value. * - * @param string $name The parameter name + * @param string $name The parameter name + * * @return mixed */ public function getParameter($name) @@ -87,8 +91,9 @@ public function getParameter($name) /** * Returns whether or not a parameter exists. * - * @param string $name - * @return boolean + * @param string $name + * + * @return bool */ public function hasParameter($name) { @@ -99,6 +104,7 @@ public function hasParameter($name) * Sets an associative array of parameters for vendor specific information. * * @param array $parameters Parameter data. + * * @return void */ public function setParameters(array $parameters = []) @@ -120,7 +126,7 @@ public function getParameters() /** * Returns whether or not this vendor info is empty. * - * @return boolean + * @return bool */ public function isEmpty() { @@ -130,8 +136,9 @@ public function isEmpty() /** * Returns a new VendorInfo object that combines two VendorInfo objects. * - * @param VendorInfo $info - * @return VendorInfo + * @param \Propel\Generator\Model\VendorInfo $info + * + * @return \Propel\Generator\Model\VendorInfo */ public function getMergedVendorInfo(VendorInfo $info) { diff --git a/src/Propel/Generator/Platform/DefaultPlatform.php b/src/Propel/Generator/Platform/DefaultPlatform.php index d302af337e..aed04a3dd4 100644 --- a/src/Propel/Generator/Platform/DefaultPlatform.php +++ b/src/Propel/Generator/Platform/DefaultPlatform.php @@ -12,8 +12,12 @@ use Propel\Common\Util\SetColumnConverter; use Propel\Generator\Config\GeneratorConfigInterface; +use Propel\Generator\Exception\EngineException; use Propel\Generator\Model\Column; use Propel\Generator\Model\Database; +use Propel\Generator\Model\Diff\ColumnDiff; +use Propel\Generator\Model\Diff\DatabaseDiff; +use Propel\Generator\Model\Diff\TableDiff; use Propel\Generator\Model\Domain; use Propel\Generator\Model\ForeignKey; use Propel\Generator\Model\IdMethod; @@ -21,11 +25,8 @@ use Propel\Generator\Model\PropelTypes; use Propel\Generator\Model\Table; use Propel\Generator\Model\Unique; -use Propel\Generator\Model\Diff\ColumnDiff; -use Propel\Generator\Model\Diff\DatabaseDiff; -use Propel\Generator\Model\Diff\TableDiff; -use Propel\Generator\Exception\EngineException; use Propel\Runtime\Connection\ConnectionInterface; +use ReflectionClass; /** * Default implementation for the PlatformInterface interface. @@ -34,18 +35,17 @@ */ class DefaultPlatform implements PlatformInterface { - /** * Mapping from Propel types to Domain objects. * - * @var Domain[] + * @var \Propel\Generator\Model\Domain[] */ protected $schemaDomainMap; /** * The database connection. * - * @var ConnectionInterface Database connection. + * @var \Propel\Runtime\Connection\ConnectionInterface Database connection. */ protected $con; @@ -55,13 +55,11 @@ class DefaultPlatform implements PlatformInterface protected $identifierQuoting = true; /** - * Default constructor. - * - * @param ConnectionInterface $con Optional database connection to use in this platform. + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con Optional database connection to use in this platform. */ - public function __construct(ConnectionInterface $con = null) + public function __construct(?ConnectionInterface $con = null) { - if (null !== $con) { + if ($con !== null) { $this->setConnection($con); } @@ -71,7 +69,8 @@ public function __construct(ConnectionInterface $con = null) /** * Returns the object builder class. * - * @param string $type + * @param string $type + * * @return string */ public function getObjectBuilderClass($type) @@ -82,10 +81,11 @@ public function getObjectBuilderClass($type) /** * Sets the database connection to use for this Platform class. * - * @param ConnectionInterface $con Database connection to use in this platform. + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con Database connection to use in this platform. + * * @return void */ - public function setConnection(ConnectionInterface $con = null) + public function setConnection(?ConnectionInterface $con = null) { $this->con = $con; } @@ -93,7 +93,7 @@ public function setConnection(ConnectionInterface $con = null) /** * Returns the database connection to use for this Platform class. * - * @return ConnectionInterface + * @return \Propel\Runtime\Connection\ConnectionInterface */ public function getConnection() { @@ -101,7 +101,7 @@ public function getConnection() } /** - * @return boolean + * @return bool */ public function isIdentifierQuotingEnabled() { @@ -109,7 +109,8 @@ public function isIdentifierQuotingEnabled() } /** - * @param boolean $enabled + * @param bool $enabled + * * @return void */ public function setIdentifierQuoting($enabled) @@ -120,7 +121,8 @@ public function setIdentifierQuoting($enabled) /** * Sets the GeneratorConfigInterface to use in the parsing. * - * @param GeneratorConfigInterface $generatorConfig + * @param \Propel\Generator\Config\GeneratorConfigInterface $generatorConfig + * * @return void */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) @@ -129,6 +131,7 @@ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) /** * Initialize the type -> Domain mapping. + * * @return void */ protected function initialize() @@ -147,7 +150,9 @@ protected function initialize() /** * Adds a mapping entry for specified Domain. - * @param Domain $domain + * + * @param \Propel\Generator\Model\Domain $domain + * * @return void */ protected function setSchemaDomainMapping(Domain $domain) @@ -158,11 +163,12 @@ protected function setSchemaDomainMapping(Domain $domain) /** * Returns the short name of the database type that this platform represents. * For example MysqlPlatform->getDatabaseType() returns 'mysql'. + * * @return string */ public function getDatabaseType() { - $reflClass = new \ReflectionClass($this); + $reflClass = new ReflectionClass($this); $clazz = $reflClass->getShortName(); $pos = strpos($clazz, 'Platform'); @@ -202,14 +208,17 @@ public function getNativeIdMethod() */ public function isNativeIdMethodAutoIncrement() { - return PlatformInterface::IDENTITY === $this->getNativeIdMethod(); + return $this->getNativeIdMethod() === PlatformInterface::IDENTITY; } /** * Returns the database specific domain for a mapping type. * * @param string $mappingType - * @return Domain + * + * @throws \Propel\Generator\Exception\EngineException + * + * @return \Propel\Generator\Model\Domain */ public function getDomainForType($mappingType) { @@ -223,7 +232,7 @@ public function getDomainForType($mappingType) /** * Returns the NOT NULL string for the configured RDBMS. * - * @return string. + * @return string */ public function getNullString($notNull) { @@ -233,7 +242,7 @@ public function getNullString($notNull) /** * Returns the auto increment strategy for the configured RDBMS. * - * @return string. + * @return string */ public function getAutoIncrement() { @@ -246,7 +255,7 @@ public function getAutoIncrement() * This will create a new name or use one specified in an * id-method-parameter tag, if specified. * - * @param Table $table + * @param \Propel\Generator\Model\Table $table * * @return string */ @@ -254,17 +263,17 @@ public function getSequenceName(Table $table) { static $longNamesMap = []; $result = null; - if (IdMethod::NATIVE === $table->getIdMethod()) { + if ($table->getIdMethod() === IdMethod::NATIVE) { $idMethodParams = $table->getIdMethodParameters(); $maxIdentifierLength = $this->getMaxColumnNameLength(); if (empty($idMethodParams)) { if (strlen($table->getName() . '_SEQ') > $maxIdentifierLength) { if (!isset($longNamesMap[$table->getName()])) { - $longNamesMap[$table->getName()] = strval(count($longNamesMap) + 1); + $longNamesMap[$table->getName()] = (string)(count($longNamesMap) + 1); } $result = substr($table->getName(), 0, $maxIdentifierLength - strlen('_SEQ_' . $longNamesMap[$table->getName()])) . '_SEQ_' . $longNamesMap[$table->getName()]; } else { - $result = substr($table->getName(), 0, $maxIdentifierLength -4) . '_SEQ'; + $result = substr($table->getName(), 0, $maxIdentifierLength - 4) . '_SEQ'; } } else { $result = substr($idMethodParams[0]->getValue(), 0, $maxIdentifierLength); @@ -322,6 +331,7 @@ public function getEndDDL() /** * Builds the DDL SQL to drop a table + * * @return string */ public function getDropTableDDL(Table $table) @@ -365,7 +375,8 @@ public function getAddTableDDL(Table $table) ); "; - return sprintf($pattern, + return sprintf( + $pattern, $tableDescription, $this->quoteIdentifier($table->getName()), implode($sep, $lines) @@ -374,6 +385,7 @@ public function getAddTableDDL(Table $table) /** * Builds the DDL SQL for a Column object. + * * @return string */ public function getColumnDDL(Column $col) @@ -402,13 +414,14 @@ public function getColumnDDL(Column $col) /** * Returns the SQL for the default value of a Column object + * * @return string */ public function getColumnDefaultValueDDL(Column $col) { $default = ''; $defaultValue = $col->getDefaultValue(); - if (null !== $defaultValue) { + if ($defaultValue !== null) { $default .= 'DEFAULT '; if ($defaultValue->isExpression()) { $default .= $defaultValue->getValue(); @@ -428,7 +441,7 @@ public function getColumnDefaultValueDDL(Column $col) $default .= SetColumnConverter::convertToInt($values, $col->getValueSet()); } elseif ($col->isPhpArrayType()) { $value = $this->getPhpArrayString($defaultValue->getValue()); - if (null === $value) { + if ($value === null) { $default = ''; } else { $default .= $value; @@ -444,12 +457,14 @@ public function getColumnDefaultValueDDL(Column $col) /** * Creates a delimiter-delimited string list of column names, quoted using quoteIdentifier(). + * * @example * * echo $platform->getColumnListDDL(array('foo', 'bar'); * // '"foo","bar"' * - * @param Column[] $columns + * + * @param \Propel\Generator\Model\Column[] $columns * @param string $delimiter The delimiter to use in separating the column names. * * @return string @@ -494,7 +509,8 @@ public function getPrimaryKeyDDL(Table $table) /** * Returns the DDL SQL to drop the primary key of a table. * - * @param Table $table + * @param \Propel\Generator\Model\Table $table + * * @return string */ public function getDropPrimaryKeyDDL(Table $table) @@ -507,7 +523,8 @@ public function getDropPrimaryKeyDDL(Table $table) ALTER TABLE %s DROP CONSTRAINT %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($table->getName()), $this->quoteIdentifier($this->getPrimaryKeyName($table)) ); @@ -516,7 +533,8 @@ public function getDropPrimaryKeyDDL(Table $table) /** * Returns the DDL SQL to add the primary key of a table. * - * @param Table $table From Table + * @param \Propel\Generator\Model\Table $table From Table + * * @return string */ public function getAddPrimaryKeyDDL(Table $table) @@ -529,7 +547,8 @@ public function getAddPrimaryKeyDDL(Table $table) ALTER TABLE %s ADD %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($table->getName()), $this->getPrimaryKeyDDL($table) ); @@ -538,7 +557,8 @@ public function getAddPrimaryKeyDDL(Table $table) /** * Returns the DDL SQL to add the indices of a table. * - * @param Table $table To Table + * @param \Propel\Generator\Model\Table $table To Table + * * @return string */ public function getAddIndicesDDL(Table $table) @@ -554,7 +574,8 @@ public function getAddIndicesDDL(Table $table) /** * Returns the DDL SQL to add an Index. * - * @param Index $index + * @param \Propel\Generator\Model\Index $index + * * @return string */ public function getAddIndexDDL(Index $index) @@ -563,7 +584,8 @@ public function getAddIndexDDL(Index $index) CREATE %sINDEX %s ON %s (%s); "; - return sprintf($pattern, + return sprintf( + $pattern, $index->isUnique() ? 'UNIQUE ' : '', $this->quoteIdentifier($index->getName()), $this->quoteIdentifier($index->getTable()->getName()), @@ -574,7 +596,8 @@ public function getAddIndexDDL(Index $index) /** * Builds the DDL SQL to drop an Index. * - * @param Index $index + * @param \Propel\Generator\Model\Index $index + * * @return string */ public function getDropIndexDDL(Index $index) @@ -583,7 +606,8 @@ public function getDropIndexDDL(Index $index) DROP INDEX %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($index->getFQName()) ); } @@ -591,12 +615,14 @@ public function getDropIndexDDL(Index $index) /** * Builds the DDL SQL for an Index object. * - * @param Index $index + * @param \Propel\Generator\Model\Index $index + * * @return string */ public function getIndexDDL(Index $index) { - return sprintf('%sINDEX %s (%s)', + return sprintf( + '%sINDEX %s (%s)', $index->isUnique() ? 'UNIQUE ' : '', $this->quoteIdentifier($index->getName()), $this->getColumnListDDL($index->getColumnObjects()) @@ -606,7 +632,8 @@ public function getIndexDDL(Index $index) /** * Builds the DDL SQL for a Unique constraint object. * - * @param Unique $unique + * @param \Propel\Generator\Model\Unique $unique + * * @return string */ public function getUniqueDDL(Unique $unique) @@ -617,7 +644,8 @@ public function getUniqueDDL(Unique $unique) /** * Builds the DDL SQL to add the foreign keys of a table. * - * @param Table $table + * @param \Propel\Generator\Model\Table $table + * * @return string */ public function getAddForeignKeysDDL(Table $table) @@ -633,7 +661,8 @@ public function getAddForeignKeysDDL(Table $table) /** * Builds the DDL SQL to add a foreign key. * - * @param ForeignKey $fk + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return string */ public function getAddForeignKeyDDL(ForeignKey $fk) @@ -645,7 +674,8 @@ public function getAddForeignKeyDDL(ForeignKey $fk) ALTER TABLE %s ADD %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($fk->getTable()->getName()), $this->getForeignKeyDDL($fk) ); @@ -654,7 +684,8 @@ public function getAddForeignKeyDDL(ForeignKey $fk) /** * Builds the DDL SQL to drop a foreign key. * - * @param ForeignKey $fk + * @param \Propel\Generator\Model\ForeignKey $fk + * * @return string|null */ public function getDropForeignKeyDDL(ForeignKey $fk) @@ -666,7 +697,8 @@ public function getDropForeignKeyDDL(ForeignKey $fk) ALTER TABLE %s DROP CONSTRAINT %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($fk->getTable()->getName()), $this->quoteIdentifier($fk->getName()) ); @@ -688,7 +720,8 @@ public function getForeignKeyDDL(ForeignKey $fk) $pattern = "CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)"; - $script = sprintf($pattern, + $script = sprintf( + $pattern, $this->quoteIdentifier($fk->getName()), $this->getColumnListDDL($fk->getLocalColumnObjects()), $this->quoteIdentifier($fk->getForeignTableName()), @@ -788,7 +821,8 @@ public function getRenameTableDDL($fromTableName, $toTableName) ALTER TABLE %s RENAME TO %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($fromTableName), $this->quoteIdentifier($toTableName) ); @@ -855,7 +889,9 @@ public function getModifyTableDDL(TableDiff $tableDiff) $columnChanges = []; foreach ($changes as $change) { - if (!trim($change)) continue; + if (!trim($change)) { + continue; + } $isCompatibleCall = preg_match( sprintf('/ALTER TABLE %s (?!RENAME)/', $this->quoteIdentifier($toTable->getName())), $change @@ -867,15 +903,18 @@ public function getModifyTableDDL(TableDiff $tableDiff) trim($change) ); } else { - $ret .= $change.";\n"; + $ret .= $change . ";\n"; } } if (0 < count($columnChanges)) { - $ret .= sprintf(" + $ret .= sprintf( + " ALTER TABLE %s%s; ", - $this->quoteIdentifier($toTable->getName()), implode(',', $columnChanges)); + $this->quoteIdentifier($toTable->getName()), + implode(',', $columnChanges) + ); } } @@ -1012,7 +1051,8 @@ public function getRemoveColumnDDL(Column $column) ALTER TABLE %s DROP COLUMN %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($column->getTable()->getName()), $this->quoteIdentifier($column->getName()) ); @@ -1032,7 +1072,8 @@ public function getRenameColumnDDL(Column $fromColumn, Column $toColumn) ALTER TABLE %s RENAME COLUMN %s TO %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($fromColumn->getTable()->getName()), $this->quoteIdentifier($fromColumn->getName()), $this->quoteIdentifier($toColumn->getName()) @@ -1053,7 +1094,8 @@ public function getModifyColumnDDL(ColumnDiff $columnDiff) ALTER TABLE %s MODIFY %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($toColumn->getTable()->getName()), $this->getColumnDDL($toColumn) ); @@ -1062,7 +1104,8 @@ public function getModifyColumnDDL(ColumnDiff $columnDiff) /** * Builds the DDL SQL to modify a list of columns * - * @param ColumnDiff[] $columnDiffs + * @param \Propel\Generator\Model\Diff\ColumnDiff[] $columnDiffs + * * @return string */ public function getModifyColumnsDDL($columnDiffs) @@ -1071,7 +1114,7 @@ public function getModifyColumnsDDL($columnDiffs) $table = null; foreach ($columnDiffs as $columnDiff) { $toColumn = $columnDiff->getToColumn(); - if (null === $table) { + if ($table === null) { $table = $toColumn->getTable(); } $lines[] = $this->getColumnDDL($toColumn); @@ -1087,7 +1130,8 @@ public function getModifyColumnsDDL($columnDiffs) ); "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($table->getName()), implode($sep, $lines) ); @@ -1106,7 +1150,8 @@ public function getAddColumnDDL(Column $column) ALTER TABLE %s ADD %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($column->getTable()->getName()), $this->getColumnDDL($column) ); @@ -1115,7 +1160,8 @@ public function getAddColumnDDL(Column $column) /** * Builds the DDL SQL to remove a list of columns * - * @param Column[] $columns + * @param \Propel\Generator\Model\Column[] $columns + * * @return string */ public function getAddColumnsDDL($columns) @@ -1123,7 +1169,7 @@ public function getAddColumnsDDL($columns) $lines = []; $table = null; foreach ($columns as $column) { - if (null === $table) { + if ($table === null) { $table = $column->getTable(); } $lines[] = $this->getColumnDDL($column); @@ -1139,7 +1185,8 @@ public function getAddColumnsDDL($columns) ); "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($table->getName()), implode($sep, $lines) ); @@ -1148,8 +1195,9 @@ public function getAddColumnsDDL($columns) /** * Returns if the RDBMS-specific SQL type has a size attribute. * - * @param string $sqlType the SQL type - * @return boolean True if the type has a size attribute + * @param string $sqlType the SQL type + * + * @return bool True if the type has a size attribute */ public function hasSize($sqlType) { @@ -1159,8 +1207,9 @@ public function hasSize($sqlType) /** * Returns if the RDBMS-specific SQL type has a scale attribute. * - * @param string $sqlType the SQL type - * @return boolean True if the type has a scale attribute + * @param string $sqlType the SQL type + * + * @return bool True if the type has a scale attribute */ public function hasScale($sqlType) { @@ -1169,7 +1218,9 @@ public function hasScale($sqlType) /** * Quote and escape needed characters in the string for underlying RDBMS. - * @param string $text + * + * @param string $text + * * @return string */ public function quote($text) @@ -1187,7 +1238,8 @@ public function quote($text) * The subclasses can implement this using string replacement functions * or native DB methods. * - * @param string $text Text that needs to be escaped. + * @param string $text Text that needs to be escaped. + * * @return string */ protected function disconnectedEscapeText($text) @@ -1199,7 +1251,8 @@ protected function disconnectedEscapeText($text) * Quotes identifiers used in database SQL if isIdentifierQuotingEnabled is true. * Calls doQuoting() when identifierQuoting is enabled. * - * @param string $text + * @param string $text + * * @return string Quoted identifier. */ protected function quoteIdentifier($text) @@ -1208,7 +1261,7 @@ protected function quoteIdentifier($text) } /** - * @inheritdoc + * @inheritDoc */ public function doQuoting($text) { @@ -1217,7 +1270,8 @@ public function doQuoting($text) /** * Whether RDBMS supports native ON DELETE triggers (e.g. ON DELETE CASCADE). - * @return boolean + * + * @return bool */ public function supportsNativeDeleteTrigger() { @@ -1226,7 +1280,8 @@ public function supportsNativeDeleteTrigger() /** * Whether RDBMS supports INSERT null values in autoincremented primary keys - * @return boolean + * + * @return bool */ public function supportsInsertNullPk() { @@ -1244,7 +1299,7 @@ public function supportsIndexSize() /** * Whether the underlying PDO driver for this platform returns BLOB columns as streams (instead of strings). * - * @return boolean + * @return bool */ public function hasStreamBlobImpl() { @@ -1253,6 +1308,7 @@ public function hasStreamBlobImpl() /** * @see Platform::supportsSchemas() + * * @return bool */ public function supportsSchemas() @@ -1262,6 +1318,7 @@ public function supportsSchemas() /** * @see Platform::supportsMigrations() + * * @return bool */ public function supportsMigrations() @@ -1276,6 +1333,7 @@ public function supportsVarcharWithoutSize() { return false; } + /** * Returns the Boolean value for the RDBMS. * @@ -1286,20 +1344,23 @@ public function supportsVarcharWithoutSize() * SQL. * * @param bool|int|string $b A Boolean or string representation of Boolean ('y', 'true'). + * * @return string */ public function getBooleanString($b) { - if (is_bool($b) && true === $b) { + if (is_bool($b) && $b === true) { return '1'; } - if (is_int($b) && 1 === $b) { + if (is_int($b) && $b === 1) { return '1'; } - if (is_string($b) - && in_array(strtolower($b), ['1', 'true', 'y', 'yes'])) { + if ( + is_string($b) + && in_array(strtolower($b), ['1', 'true', 'y', 'yes']) + ) { return '1'; } @@ -1324,7 +1385,7 @@ public function getPhpArrayString($stringValue) } $value = implode(' | ', $values); - if (empty($value) || ' | ' === $value) { + if (empty($value) || $value === ' | ') { return null; } @@ -1333,6 +1394,7 @@ public function getPhpArrayString($stringValue) /** * Gets the preferred timestamp formatter for setting date/time values. + * * @return string */ public function getTimestampFormatter() @@ -1342,6 +1404,7 @@ public function getTimestampFormatter() /** * Gets the preferred time formatter for setting date/time values. + * * @return string */ public function getTimeFormatter() @@ -1351,6 +1414,7 @@ public function getTimeFormatter() /** * Gets the preferred date formatter for setting date/time values. + * * @return string */ public function getDateFormatter() @@ -1370,11 +1434,11 @@ public function getDateFormatter() * * @return string */ - public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = " ") + public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = ' ') { $script = ''; if ($column->isTemporalType()) { - $columnValueAccessor = $columnValueAccessor . " ? " . $columnValueAccessor . "->format(\"" . $this->getTimeStampFormatter() . "\") : null"; + $columnValueAccessor = $columnValueAccessor . ' ? ' . $columnValueAccessor . '->format("' . $this->getTimeStampFormatter() . '") : null'; } elseif ($column->isLobType()) { // we always need to make sure that the stream is rewound, otherwise nothing will // get written to database. @@ -1413,7 +1477,7 @@ public function getColumnBindingPHP(Column $column, $identifier, $columnValueAcc * * @return string|string[]|null */ - public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = " ", $phpType = null) + public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = ' ', $phpType = null) { return sprintf( " @@ -1421,7 +1485,7 @@ public function getIdentifierPhp($columnValueMutator, $connectionVariableName = $tab, $columnValueMutator, $connectionVariableName, - $phpType ? '('.$phpType.') ' : '', + $phpType ? '(' . $phpType . ') ' : '', $sequenceName ? ("'" . $sequenceName . "'") : '' ); } @@ -1440,7 +1504,8 @@ public function getDefaultTypeSizes() * Returns the default size of a specific type. * * @param string $type - * @return integer + * + * @return int */ public function getDefaultTypeSize($type) { @@ -1455,7 +1520,8 @@ public function getDefaultTypeSize($type) * Useful for checking needed definitions/structures. E.g. Unique Indexes for ForeignKey columns, * which the most Platforms requires but which is not always explicitly defined in the table model. * - * @param Table $table The table object which gets modified. + * @param \Propel\Generator\Model\Table $table The table object which gets modified. + * * @return void */ public function normalizeTable(Table $table) @@ -1479,7 +1545,7 @@ public function normalizeTable(Table $table) foreach ($table->getColumns() as $column) { if ($column->getSize() && $defaultSize = $this->getDefaultTypeSize($column->getType())) { - if (null === $column->getScale() && intval($column->getSize()) === $defaultSize) { + if ($column->getScale() === null && (int)$column->getSize() === $defaultSize) { $column->setSize(null); } } diff --git a/src/Propel/Generator/Platform/MssqlPlatform.php b/src/Propel/Generator/Platform/MssqlPlatform.php index 839fcdd4b7..48fda53659 100644 --- a/src/Propel/Generator/Platform/MssqlPlatform.php +++ b/src/Propel/Generator/Platform/MssqlPlatform.php @@ -30,30 +30,31 @@ class MssqlPlatform extends DefaultPlatform /** * Initializes db specific domain mapping. + * * @return void */ protected function initialize() { parent::initialize(); - $this->setSchemaDomainMapping(new Domain(PropelTypes::INTEGER, "INT")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::BOOLEAN, "INT")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::DOUBLE, "FLOAT")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, "VARCHAR(MAX)")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::CLOB, "VARCHAR(MAX)")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::DATE, "DATE")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::BU_DATE, "DATE")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::TIME, "TIME")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::TIMESTAMP, "DATETIME2")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::BU_TIMESTAMP, "DATETIME2")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, "BINARY(7132)")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, "VARBINARY(MAX)")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, "VARBINARY(MAX)")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::BLOB, "VARBINARY(MAX)")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::OBJECT, "VARBINARY(MAX)")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::PHP_ARRAY, "VARCHAR(MAX)")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::ENUM, "TINYINT")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::SET, "INT")); + $this->setSchemaDomainMapping(new Domain(PropelTypes::INTEGER, 'INT')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::BOOLEAN, 'INT')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::DOUBLE, 'FLOAT')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, 'VARCHAR(MAX)')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::CLOB, 'VARCHAR(MAX)')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::DATE, 'DATE')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::BU_DATE, 'DATE')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::TIME, 'TIME')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::TIMESTAMP, 'DATETIME2')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::BU_TIMESTAMP, 'DATETIME2')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, 'BINARY(7132)')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, 'VARBINARY(MAX)')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, 'VARBINARY(MAX)')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::BLOB, 'VARBINARY(MAX)')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::OBJECT, 'VARBINARY(MAX)')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::PHP_ARRAY, 'VARCHAR(MAX)')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::ENUM, 'TINYINT')); + $this->setSchemaDomainMapping(new Domain(PropelTypes::SET, 'INT')); } /** @@ -129,7 +130,7 @@ public function getDropTableDDL(Table $table) foreach ($table->getForeignKeys() as $fk) { $ret .= " IF EXISTS (SELECT 1 FROM sysobjects WHERE type ='RI' AND name='" . $fk->getName() . "') - ALTER TABLE " . $this->quoteIdentifier($table->getName()) . " DROP CONSTRAINT " . $this->quoteIdentifier($fk->getName()) . "; + ALTER TABLE " . $this->quoteIdentifier($table->getName()) . ' DROP CONSTRAINT ' . $this->quoteIdentifier($fk->getName()) . "; "; } @@ -138,7 +139,7 @@ public function getDropTableDDL(Table $table) $ret .= " IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = '" . $table->getName() . "') BEGIN - DECLARE @reftable_" . self::$dropCount . " nvarchar(60), @constraintname_" . self::$dropCount . " nvarchar(60) + DECLARE @reftable_" . self::$dropCount . ' nvarchar(60), @constraintname_' . self::$dropCount . " nvarchar(60) DECLARE refcursor CURSOR FOR select reftables.name tablename, cons.name constraintname from sysobjects tables, @@ -150,11 +151,11 @@ public function getDropTableDDL(Table $table) and reftables.id = ref.fkeyid and tables.name = '" . $table->getName() . "' OPEN refcursor - FETCH NEXT from refcursor into @reftable_" . self::$dropCount . ", @constraintname_" . self::$dropCount . " + FETCH NEXT from refcursor into @reftable_" . self::$dropCount . ', @constraintname_' . self::$dropCount . " while @@FETCH_STATUS = 0 BEGIN exec ('alter table '+@reftable_" . self::$dropCount . "+' drop constraint '+@constraintname_" . self::$dropCount . ") - FETCH NEXT from refcursor into @reftable_" . self::$dropCount . ", @constraintname_" . self::$dropCount . " + FETCH NEXT from refcursor into @reftable_" . self::$dropCount . ', @constraintname_' . self::$dropCount . " END CLOSE refcursor DEALLOCATE refcursor @@ -175,7 +176,8 @@ public function getPrimaryKeyDDL(Table $table) if ($table->hasPrimaryKey()) { $pattern = 'CONSTRAINT %s PRIMARY KEY (%s)'; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($this->getPrimaryKeyName($table)), $this->getColumnListDDL($table->getPrimaryKey()) ); @@ -202,7 +204,8 @@ public function getAddForeignKeyDDL(ForeignKey $fk) ; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($fk->getTable()->getName()), $this->getForeignKeyDDL($fk) ); @@ -211,13 +214,16 @@ public function getAddForeignKeyDDL(ForeignKey $fk) /** * Builds the DDL SQL for a Unique constraint object. MS SQL Server CONTRAINT specific * - * @param Unique $unique + * @param \Propel\Generator\Model\Unique $unique + * * @return string */ public function getUniqueDDL(Unique $unique) { $pattern = 'CONSTRAINT %s UNIQUE NONCLUSTERED (%s) ON [PRIMARY]'; - return sprintf($pattern, + + return sprintf( + $pattern, $this->quoteIdentifier($unique->getName()), $this->getColumnListDDL($unique->getColumnObjects()) ); @@ -235,7 +241,8 @@ public function getForeignKeyDDL(ForeignKey $fk) } $pattern = 'CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)'; - $script = sprintf($pattern, + $script = sprintf( + $pattern, $this->quoteIdentifier($fk->getName()), $this->getColumnListDDL($fk->getLocalColumnObjects()), $this->quoteIdentifier($fk->getForeignTableName()), @@ -245,7 +252,7 @@ public function getForeignKeyDDL(ForeignKey $fk) $script .= ' ON UPDATE ' . $fk->getOnUpdate(); } if ($fk->hasOnDelete() && $fk->getOnDelete() != ForeignKey::SETNULL) { - $script .= ' ON DELETE '. $fk->getOnDelete(); + $script .= ' ON DELETE ' . $fk->getOnDelete(); } return $script; @@ -272,7 +279,7 @@ public function hasSize($sqlType) } /** - * @inheritdoc + * @inheritDoc */ public function doQuoting($text) { diff --git a/src/Propel/Generator/Platform/MysqlPlatform.php b/src/Propel/Generator/Platform/MysqlPlatform.php index eef38f83f2..fceec8f1e0 100644 --- a/src/Propel/Generator/Platform/MysqlPlatform.php +++ b/src/Propel/Generator/Platform/MysqlPlatform.php @@ -10,18 +10,19 @@ namespace Propel\Generator\Platform; +use PDO; use Propel\Generator\Config\GeneratorConfigInterface; use Propel\Generator\Exception\EngineException; use Propel\Generator\Model\Column; use Propel\Generator\Model\Database; +use Propel\Generator\Model\Diff\ColumnDiff; +use Propel\Generator\Model\Diff\DatabaseDiff; use Propel\Generator\Model\Domain; use Propel\Generator\Model\ForeignKey; use Propel\Generator\Model\Index; use Propel\Generator\Model\PropelTypes; use Propel\Generator\Model\Table; use Propel\Generator\Model\Unique; -use Propel\Generator\Model\Diff\ColumnDiff; -use Propel\Generator\Model\Diff\DatabaseDiff; /** * MySql PlatformInterface implementation. @@ -31,11 +32,16 @@ */ class MysqlPlatform extends DefaultPlatform { - protected $tableEngineKeyword = 'ENGINE'; // overwritten in propel config - protected $defaultTableEngine = 'InnoDB'; // overwritten in propel config + protected $tableEngineKeyword = 'ENGINE'; + + // overwritten in propel config + protected $defaultTableEngine = 'InnoDB'; + + // overwritten in propel config /** * Initializes db specific domain mapping. + * * @return void */ protected function initialize() @@ -76,6 +82,7 @@ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) * Setter for the tableEngineKeyword property * * @param string $tableEngineKeyword + * * @return void */ public function setTableEngineKeyword($tableEngineKeyword) @@ -97,6 +104,7 @@ public function getTableEngineKeyword() * Setter for the defaultTableEngine property * * @param string $defaultTableEngine + * * @return void */ public function setDefaultTableEngine($defaultTableEngine) @@ -211,7 +219,7 @@ public function getEndDDL() /** * Returns the SQL for the primary key of a Table object * - * @param Table $table + * @param \Propel\Generator\Model\Table $table * * @return string */ @@ -300,7 +308,8 @@ public function getAddTableDDL(Table $table) ) %s=%s%s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($table->getName()), implode($sep, $lines), $this->getTableEngineKeyword(), @@ -323,24 +332,24 @@ protected function getTableOptions(Table $table) // List of supported table options // see http://dev.mysql.com/doc/refman/5.5/en/create-table.html $supportedOptions = [ - 'AutoIncrement' => 'AUTO_INCREMENT', - 'AvgRowLength' => 'AVG_ROW_LENGTH', - 'Charset' => 'CHARACTER SET', - 'Checksum' => 'CHECKSUM', - 'Collate' => 'COLLATE', - 'Connection' => 'CONNECTION', - 'DataDirectory' => 'DATA DIRECTORY', + 'AutoIncrement' => 'AUTO_INCREMENT', + 'AvgRowLength' => 'AVG_ROW_LENGTH', + 'Charset' => 'CHARACTER SET', + 'Checksum' => 'CHECKSUM', + 'Collate' => 'COLLATE', + 'Connection' => 'CONNECTION', + 'DataDirectory' => 'DATA DIRECTORY', 'Delay_key_write' => 'DELAY_KEY_WRITE', - 'DelayKeyWrite' => 'DELAY_KEY_WRITE', - 'IndexDirectory' => 'INDEX DIRECTORY', - 'InsertMethod' => 'INSERT_METHOD', - 'KeyBlockSize' => 'KEY_BLOCK_SIZE', - 'MaxRows' => 'MAX_ROWS', - 'MinRows' => 'MIN_ROWS', - 'Pack_Keys' => 'PACK_KEYS', - 'PackKeys' => 'PACK_KEYS', - 'RowFormat' => 'ROW_FORMAT', - 'Union' => 'UNION', + 'DelayKeyWrite' => 'DELAY_KEY_WRITE', + 'IndexDirectory' => 'INDEX DIRECTORY', + 'InsertMethod' => 'INSERT_METHOD', + 'KeyBlockSize' => 'KEY_BLOCK_SIZE', + 'MaxRows' => 'MAX_ROWS', + 'MinRows' => 'MIN_ROWS', + 'Pack_Keys' => 'PACK_KEYS', + 'PackKeys' => 'PACK_KEYS', + 'RowFormat' => 'ROW_FORMAT', + 'Union' => 'UNION', ]; $noQuotedValue = array_flip([ @@ -360,13 +369,13 @@ protected function getTableOptions(Table $table) } // if we have a param value, then parse it out - if (!is_null($parameterValue)) { + if ($parameterValue !== null) { // if the value is numeric or is parameter is in $noQuotedValue, then there is no need for quotes if (!is_numeric($parameterValue) && !isset($noQuotedValue[$name])) { $parameterValue = $this->quote($parameterValue); } - $tableOptions [] = sprintf('%s=%s', $sqlName, $parameterValue); + $tableOptions[] = sprintf('%s=%s', $sqlName, $parameterValue); } } @@ -389,6 +398,7 @@ public function getDropTableDDL(Table $table) * @param \Propel\Generator\Model\Column $col * * @throws \Propel\Generator\Exception\EngineException + * * @return string */ public function getColumnDDL(Column $col) @@ -427,21 +437,23 @@ public function getColumnDDL(Column $col) if ($colinfo->hasParameter('Unsigned')) { $unsigned = $colinfo->getParameter('Unsigned'); switch (strtoupper($unsigned)) { - case 'FALSE': break; + case 'FALSE': + break; case 'TRUE': $ddl[] = 'UNSIGNED'; + break; default: - throw new EngineException('Unexpected value "'.$unsigned.'" for MySQL vendor column parameter "Unsigned", expecting "true" or "false".'); + throw new EngineException('Unexpected value "' . $unsigned . '" for MySQL vendor column parameter "Unsigned", expecting "true" or "false".'); } } if ($colinfo->hasParameter('Charset')) { - $ddl[] = 'CHARACTER SET '. $this->quote($colinfo->getParameter('Charset')); + $ddl[] = 'CHARACTER SET ' . $this->quote($colinfo->getParameter('Charset')); } if ($colinfo->hasParameter('Collation')) { - $ddl[] = 'COLLATE '. $this->quote($colinfo->getParameter('Collation')); + $ddl[] = 'COLLATE ' . $this->quote($colinfo->getParameter('Collation')); } elseif ($colinfo->hasParameter('Collate')) { - $ddl[] = 'COLLATE '. $this->quote($colinfo->getParameter('Collate')); + $ddl[] = 'COLLATE ' . $this->quote($colinfo->getParameter('Collate')); } if ($sqlType === 'TIMESTAMP') { if ($notNullString == '') { @@ -478,7 +490,9 @@ public function getColumnDDL(Column $col) * Creates a comma-separated list of column names for the index. * For MySQL unique indexes there is the option of specifying size, so we cannot simply use * the getColumnsList() method. - * @param Index $index + * + * @param \Propel\Generator\Model\Index $index + * * @return string */ protected function getIndexColumnListDDL(Index $index) @@ -494,7 +508,8 @@ protected function getIndexColumnListDDL(Index $index) /** * Builds the DDL SQL to drop the primary key of a table. * - * @param Table $table + * @param \Propel\Generator\Model\Table $table + * * @return string */ public function getDropPrimaryKeyDDL(Table $table) @@ -507,7 +522,8 @@ public function getDropPrimaryKeyDDL(Table $table) ALTER TABLE %s DROP PRIMARY KEY; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($table->getName()) ); } @@ -515,7 +531,8 @@ public function getDropPrimaryKeyDDL(Table $table) /** * Builds the DDL SQL to add an Index. * - * @param Index $index + * @param \Propel\Generator\Model\Index $index + * * @return string */ public function getAddIndexDDL(Index $index) @@ -524,7 +541,8 @@ public function getAddIndexDDL(Index $index) CREATE %sINDEX %s ON %s (%s); "; - return sprintf($pattern, + return sprintf( + $pattern, $this->getIndexType($index), $this->quoteIdentifier($index->getName()), $this->quoteIdentifier($index->getTable()->getName()), @@ -535,7 +553,8 @@ public function getAddIndexDDL(Index $index) /** * Builds the DDL SQL to drop an Index. * - * @param Index $index + * @param \Propel\Generator\Model\Index $index + * * @return string */ public function getDropIndexDDL(Index $index) @@ -544,7 +563,8 @@ public function getDropIndexDDL(Index $index) DROP INDEX %s ON %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($index->getName()), $this->quoteIdentifier($index->getTable()->getName()) ); @@ -552,11 +572,13 @@ public function getDropIndexDDL(Index $index) /** * Builds the DDL SQL for an Index object. + * * @return string */ public function getIndexDDL(Index $index) { - return sprintf('%sINDEX %s (%s)', + return sprintf( + '%sINDEX %s (%s)', $this->getIndexType($index), $this->quoteIdentifier($index->getName()), $this->getIndexColumnListDDL($index) @@ -588,7 +610,8 @@ protected function getIndexType(Index $index) */ public function getUniqueDDL(Unique $unique) { - return sprintf('UNIQUE INDEX %s (%s)', + return sprintf( + 'UNIQUE INDEX %s (%s)', $this->quoteIdentifier($unique->getName()), $this->getIndexColumnListDDL($unique) ); @@ -611,7 +634,7 @@ public function getAddForeignKeyDDL(ForeignKey $fk) /** * Builds the DDL SQL for a ForeignKey object. * - * @param ForeignKey $fk + * @param \Propel\Generator\Model\ForeignKey $fk * * @return string */ @@ -631,7 +654,9 @@ public function getForeignKeyDDL(ForeignKey $fk) */ public function getDropForeignKeyDDL(ForeignKey $fk) { - if (!$this->supportsForeignKeys($fk->getTable())) return ''; + if (!$this->supportsForeignKeys($fk->getTable())) { + return ''; + } if ($fk->isSkipSql() || $fk->isPolymorphic()) { return null; } @@ -639,7 +664,8 @@ public function getDropForeignKeyDDL(ForeignKey $fk) ALTER TABLE %s DROP FOREIGN KEY %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($fk->getTable()->getName()), $this->quoteIdentifier($fk->getName()) ); @@ -669,7 +695,6 @@ public function getCommentBlockDDL($comment) */ public function getModifyDatabaseDDL(DatabaseDiff $databaseDiff) { - $ret = ''; foreach ($databaseDiff->getRemovedTables() as $table) { @@ -697,6 +722,7 @@ public function getModifyDatabaseDDL(DatabaseDiff $databaseDiff) /** * Builds the DDL SQL to rename a table + * * @return string */ public function getRenameTableDDL($fromTableName, $toTableName) @@ -705,7 +731,8 @@ public function getRenameTableDDL($fromTableName, $toTableName) RENAME TABLE %s TO %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($fromTableName), $this->quoteIdentifier($toTableName) ); @@ -722,7 +749,8 @@ public function getRemoveColumnDDL(Column $column) ALTER TABLE %s DROP %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($column->getTable()->getName()), $this->quoteIdentifier($column->getName()) ); @@ -730,6 +758,7 @@ public function getRemoveColumnDDL(Column $column) /** * Builds the DDL SQL to rename a column + * * @return string */ public function getRenameColumnDDL(Column $fromColumn, Column $toColumn) @@ -749,6 +778,7 @@ public function getModifyColumnDDL(ColumnDiff $columnDiff) /** * Builds the DDL SQL to change a column + * * @return string */ public function getChangeColumnDDL(Column $fromColumn, Column $toColumn) @@ -757,12 +787,14 @@ public function getChangeColumnDDL(Column $fromColumn, Column $toColumn) ALTER TABLE %s CHANGE %s %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($fromColumn->getTable()->getName()), $this->quoteIdentifier($fromColumn->getName()), $this->getColumnDDL($toColumn) ); } + /** * Builds the DDL SQL to modify a list of columns * @@ -781,7 +813,7 @@ public function getModifyColumnsDDL($columnDiffs) /** * Builds the DDL SQL to add a column * - * @param Column $column + * @param \Propel\Generator\Model\Column $column * * @return string */ @@ -793,19 +825,21 @@ public function getAddColumnDDL(Column $column) $tableColumns = $column->getTable()->getColumns(); // Default to add first if no column is found before the current one - $insertPositionDDL = "FIRST"; + $insertPositionDDL = 'FIRST'; foreach ($tableColumns as $i => $tableColumn) { // We found the column, use the one before it if it's not the first if ($tableColumn->getName() == $column->getName()) { // We have a column that is not the first one if ($i > 0) { - $insertPositionDDL = "AFTER " . $this->quoteIdentifier($tableColumns[$i - 1]->getName()); + $insertPositionDDL = 'AFTER ' . $this->quoteIdentifier($tableColumns[$i - 1]->getName()); } + break; } } - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($column->getTable()->getName()), $this->getColumnDDL($column), $insertPositionDDL @@ -815,7 +849,7 @@ public function getAddColumnDDL(Column $column) /** * Builds the DDL SQL to add a list of columns * - * @param Column[] $columns + * @param \Propel\Generator\Model\Column[] $columns * * @return string */ @@ -859,18 +893,20 @@ public function hasSize($sqlType) public function getDefaultTypeSizes() { return [ - 'char' => 1, - 'tinyint' => 4, + 'char' => 1, + 'tinyint' => 4, 'smallint' => 6, - 'int' => 11, - 'bigint' => 20, - 'decimal' => 10, + 'int' => 11, + 'bigint' => 20, + 'decimal' => 10, ]; } /** * Escape the string for RDBMS. - * @param string $text + * + * @param string $text + * * @return string */ public function disconnectedEscapeText($text) @@ -879,13 +915,14 @@ public function disconnectedEscapeText($text) } /** - * {@inheritdoc} + * {@inheritDoc} * * MySQL documentation says that identifiers cannot contain '.'. Thus it * should be safe to split the string by '.' and quote each part individually * to allow for a .
or
. syntax. * - * @param string $text the identifier + * @param string $text the identifier + * * @return string the quoted identifier */ public function doQuoting($text) @@ -901,11 +938,11 @@ public function doQuoting($text) * * @return string */ - public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = " ") + public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = ' ') { // FIXME - This is a temporary hack to get around apparent bugs w/ PDO+MYSQL // See http://pecl.php.net/bugs/bug.php?id=9919 - if ($column->getPDOType() === \PDO::PARAM_BOOL) { + if ($column->getPDOType() === PDO::PARAM_BOOL) { return sprintf( " %s\$stmt->bindValue(%s, (int) %s, PDO::PARAM_INT);", diff --git a/src/Propel/Generator/Platform/OraclePlatform.php b/src/Propel/Generator/Platform/OraclePlatform.php index 689f94de73..6f2dba4914 100644 --- a/src/Propel/Generator/Platform/OraclePlatform.php +++ b/src/Propel/Generator/Platform/OraclePlatform.php @@ -32,6 +32,7 @@ class OraclePlatform extends DefaultPlatform { /** * Initializes db specific domain mapping. + * * @return void */ protected function initialize() @@ -159,7 +160,8 @@ public function getAddTableDDL(Table $table) %s )%s; "; - $ret = sprintf($pattern, + $ret = sprintf( + $pattern, $tableDescription, $this->quoteIdentifier($table->getName()), implode($sep, $lines), @@ -193,13 +195,14 @@ public function getAddPrimaryKeyDDL(Table $table) */ public function getAddSequencesDDL(Table $table) { - if ('native' === $table->getIdMethod()) { + if ($table->getIdMethod() === 'native') { $pattern = " CREATE SEQUENCE %s INCREMENT BY 1 START WITH 1 NOMAXVALUE NOCYCLE NOCACHE ORDER; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($this->getSequenceName($table)) ); } @@ -250,7 +253,8 @@ public function getPrimaryKeyDDL(Table $table) if ($table->hasPrimaryKey()) { $pattern = 'CONSTRAINT %s PRIMARY KEY (%s)%s'; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($this->getPrimaryKeyName($table)), $this->getColumnListDDL($table->getPrimaryKey()), $this->generateBlockStorage($table, true) @@ -267,7 +271,8 @@ public function getPrimaryKeyDDL(Table $table) */ public function getUniqueDDL(Unique $unique) { - return sprintf('CONSTRAINT %s UNIQUE (%s)', + return sprintf( + 'CONSTRAINT %s UNIQUE (%s)', $this->quoteIdentifier($unique->getName()), $this->getColumnListDDL($unique->getColumnObjects()) ); @@ -286,7 +291,8 @@ public function getForeignKeyDDL(ForeignKey $fk) $pattern = "CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)"; - $script = sprintf($pattern, + $script = sprintf( + $pattern, $this->quoteIdentifier($fk->getName()), $this->getColumnListDDL($fk->getLocalColumnObjects()), $this->quoteIdentifier($fk->getForeignTableName()), @@ -302,7 +308,8 @@ public function getForeignKeyDDL(ForeignKey $fk) /** * Whether the underlying PDO driver for this platform returns BLOB columns as streams (instead of strings). - * @return boolean + * + * @return bool */ public function hasStreamBlobImpl() { @@ -310,7 +317,7 @@ public function hasStreamBlobImpl() } /** - * @inheritdoc + * @inheritDoc */ public function doQuoting($text) { @@ -326,9 +333,10 @@ public function getTimestampFormatter() } /** - * @note While Oracle supports schemas, they're user-based and + * @note While Oracle supports schemas, they're user-based and * are really only good for creating a database layout in * one fell swoop. + * * @see Platform::supportsSchemas() */ public function supportsSchemas() @@ -339,8 +347,8 @@ public function supportsSchemas() /** * Generate oracle block storage * - * @param Table|Index $object object with vendor parameters - * @param boolean $isPrimaryKey is a primary key vendor part + * @param \Propel\Generator\Model\Table|\Propel\Generator\Model\Index $object object with vendor parameters + * @param bool $isPrimaryKey is a primary key vendor part * * @return string oracle vendor sql part */ @@ -355,41 +363,41 @@ public function generateBlockStorage($object, $isPrimaryKey = false) $physicalParameters = " USING INDEX "; - $prefix = "PK"; + $prefix = 'PK'; } else { $physicalParameters = "\n"; - $prefix = ""; + $prefix = ''; } - if ($vendorSpecific->hasParameter($prefix.'PCTFree')) { - $physicalParameters .= "PCTFREE " . $vendorSpecific->getParameter($prefix.'PCTFree') . " + if ($vendorSpecific->hasParameter($prefix . 'PCTFree')) { + $physicalParameters .= 'PCTFREE ' . $vendorSpecific->getParameter($prefix . 'PCTFree') . " "; } - if ($vendorSpecific->hasParameter($prefix.'InitTrans')) { - $physicalParameters .= "INITRANS " . $vendorSpecific->getParameter($prefix.'InitTrans') . " + if ($vendorSpecific->hasParameter($prefix . 'InitTrans')) { + $physicalParameters .= 'INITRANS ' . $vendorSpecific->getParameter($prefix . 'InitTrans') . " "; } - if ($vendorSpecific->hasParameter($prefix.'MinExtents') || $vendorSpecific->hasParameter($prefix.'MaxExtents') || $vendorSpecific->hasParameter($prefix.'PCTIncrease')) { + if ($vendorSpecific->hasParameter($prefix . 'MinExtents') || $vendorSpecific->hasParameter($prefix . 'MaxExtents') || $vendorSpecific->hasParameter($prefix . 'PCTIncrease')) { $physicalParameters .= "STORAGE ( "; - if ($vendorSpecific->hasParameter($prefix.'MinExtents')) { - $physicalParameters .= " MINEXTENTS " . $vendorSpecific->getParameter($prefix.'MinExtents') . " + if ($vendorSpecific->hasParameter($prefix . 'MinExtents')) { + $physicalParameters .= ' MINEXTENTS ' . $vendorSpecific->getParameter($prefix . 'MinExtents') . " "; } - if ($vendorSpecific->hasParameter($prefix.'MaxExtents')) { - $physicalParameters .= " MAXEXTENTS " . $vendorSpecific->getParameter($prefix.'MaxExtents') . " + if ($vendorSpecific->hasParameter($prefix . 'MaxExtents')) { + $physicalParameters .= ' MAXEXTENTS ' . $vendorSpecific->getParameter($prefix . 'MaxExtents') . " "; } - if ($vendorSpecific->hasParameter($prefix.'PCTIncrease')) { - $physicalParameters .= " PCTINCREASE " . $vendorSpecific->getParameter($prefix.'PCTIncrease') . " + if ($vendorSpecific->hasParameter($prefix . 'PCTIncrease')) { + $physicalParameters .= ' PCTINCREASE ' . $vendorSpecific->getParameter($prefix . 'PCTIncrease') . " "; } $physicalParameters .= ") "; } - if ($vendorSpecific->hasParameter($prefix.'Tablespace')) { - $physicalParameters .= "TABLESPACE " . $vendorSpecific->getParameter($prefix.'Tablespace'); + if ($vendorSpecific->hasParameter($prefix . 'Tablespace')) { + $physicalParameters .= 'TABLESPACE ' . $vendorSpecific->getParameter($prefix . 'Tablespace'); } return $physicalParameters; @@ -398,7 +406,8 @@ public function generateBlockStorage($object, $isPrimaryKey = false) /** * Builds the DDL SQL to add an Index. * - * @param Index $index + * @param \Propel\Generator\Model\Index $index + * * @return string */ public function getAddIndexDDL(Index $index) @@ -412,7 +421,8 @@ public function getAddIndexDDL(Index $index) CREATE %sINDEX %s ON %s (%s)%s; "; - return sprintf($pattern, + return sprintf( + $pattern, $index->isUnique() ? 'UNIQUE ' : '', $this->quoteIdentifier($index->getName()), $this->quoteIdentifier($index->getTable()->getName()), @@ -426,7 +436,7 @@ public function getAddIndexDDL(Index $index) * Warning: duplicates logic from OracleAdapter::bindValue(). * Any code modification here must be ported there. */ - public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = " ") + public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = ' ') { if ($column->getType() == PropelTypes::CLOB_EMU) { return sprintf( @@ -455,9 +465,10 @@ public function getColumnBindingPHP(Column $column, $identifier, $columnValueAcc * @param string|null $phpType * * @throws \Propel\Generator\Exception\EngineException + * * @return string|string[]|null */ - public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = " ", $phpType = null) + public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = ' ', $phpType = null) { if (!$sequenceName) { throw new EngineException('Oracle needs a sequence name to fetch primary keys'); @@ -465,11 +476,12 @@ public function getIdentifierPhp($columnValueMutator, $connectionVariableName = $snippet = " \$dataFetcher = %s->query('SELECT %s.nextval FROM dual'); %s = %s\$dataFetcher->fetchColumn();"; - $script = sprintf($snippet, + $script = sprintf( + $snippet, $connectionVariableName, $sequenceName, $columnValueMutator, - $phpType ? '('.$phpType.') ' : '' + $phpType ? '(' . $phpType . ') ' : '' ); return preg_replace('/^/m', $tab, $script); diff --git a/src/Propel/Generator/Platform/PgsqlPlatform.php b/src/Propel/Generator/Platform/PgsqlPlatform.php index 9e6a471c21..c36118e88b 100755 --- a/src/Propel/Generator/Platform/PgsqlPlatform.php +++ b/src/Propel/Generator/Platform/PgsqlPlatform.php @@ -13,15 +13,15 @@ use Propel\Generator\Exception\EngineException; use Propel\Generator\Model\Column; use Propel\Generator\Model\Database; +use Propel\Generator\Model\Diff\ColumnDiff; use Propel\Generator\Model\Diff\TableDiff; use Propel\Generator\Model\Domain; use Propel\Generator\Model\ForeignKey; -use Propel\Generator\Model\Index; use Propel\Generator\Model\IdMethod; +use Propel\Generator\Model\Index; use Propel\Generator\Model\PropelTypes; use Propel\Generator\Model\Table; use Propel\Generator\Model\Unique; -use Propel\Generator\Model\Diff\ColumnDiff; /** * Postgresql PlatformInterface implementation. @@ -39,6 +39,7 @@ class PgsqlPlatform extends DefaultPlatform /** * Initializes db specific domain mapping. + * * @return void */ protected function initialize() @@ -86,12 +87,12 @@ public function getAutoIncrement() public function getDefaultTypeSizes() { return [ - 'char' => 1, + 'char' => 1, 'character' => 1, - 'integer' => 32, - 'bigint' => 64, - 'smallint' => 16, - 'double precision' => 54 + 'integer' => 32, + 'bigint' => 64, + 'smallint' => 16, + 'double precision' => 54, ]; } @@ -129,7 +130,7 @@ public function supportsNativeDeleteTrigger() * Override to provide sequence names that conform to postgres' standard when * no id-method-parameter specified. * - * @param Table $table + * @param \Propel\Generator\Model\Table $table * * @return string */ @@ -145,6 +146,7 @@ public function getSequenceName(Table $table) foreach ($table->getColumns() as $col) { if ($col->isAutoIncrement()) { $result = $table->getName() . '_' . $col->getName() . '_seq'; + break; // there's only one auto-increment column allowed } } @@ -163,13 +165,16 @@ public function getSequenceName(Table $table) */ protected function getAddSequenceDDL(Table $table) { - if ($table->getIdMethod() == IdMethod::NATIVE - && $table->getIdMethodParameters() != null) { + if ( + $table->getIdMethod() == IdMethod::NATIVE + && $table->getIdMethodParameters() != null + ) { $pattern = " CREATE SEQUENCE %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier(strtolower($this->getSequenceName($table))) ); } @@ -184,13 +189,16 @@ protected function getAddSequenceDDL(Table $table) */ protected function getDropSequenceDDL(Table $table) { - if ($table->getIdMethod() == IdMethod::NATIVE - && $table->getIdMethodParameters() != null) { + if ( + $table->getIdMethod() == IdMethod::NATIVE + && $table->getIdMethodParameters() != null + ) { $pattern = " DROP SEQUENCE %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier(strtolower($this->getSequenceName($table))) ); } @@ -308,14 +316,15 @@ public function getAddTablesDDL(Database $database) * * @return string */ - public function getForeignKeyDDL(ForeignKey $fk) { + public function getForeignKeyDDL(ForeignKey $fk) + { $script = parent::getForeignKeyDDL($fk); $pgVendorInfo = $fk->getVendorInfoForType('pgsql'); - if($pgVendorInfo) { - if(filter_var($pgVendorInfo->getParameter('deferrable'), FILTER_VALIDATE_BOOLEAN)) { + if ($pgVendorInfo) { + if (filter_var($pgVendorInfo->getParameter('deferrable'), FILTER_VALIDATE_BOOLEAN)) { $script .= ' DEFERRABLE'; - if(filter_var($pgVendorInfo->getParameter("initiallyDeferred"), FILTER_VALIDATE_BOOLEAN)) { + if (filter_var($pgVendorInfo->getParameter('initiallyDeferred'), FILTER_VALIDATE_BOOLEAN)) { $script .= ' INITIALLY DEFERRED'; } } @@ -390,7 +399,8 @@ public function getAddTableDDL(Table $table) %s ); "; - $ret .= sprintf($pattern, + $ret .= sprintf( + $pattern, $this->quoteIdentifier($table->getName()), implode($sep, $lines) ); @@ -399,7 +409,8 @@ public function getAddTableDDL(Table $table) $pattern = " COMMENT ON TABLE %s IS %s; "; - $ret .= sprintf($pattern, + $ret .= sprintf( + $pattern, $this->quoteIdentifier($table->getName()), $this->quote($table->getDescription()) ); @@ -437,7 +448,8 @@ protected function getAddColumnComment(Column $column) COMMENT ON COLUMN %s.%s IS %s; "; if ($description = $column->getDescription()) { - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($column->getTable()->getName()), $this->quoteIdentifier($column->getName()), $this->quote($description) @@ -495,7 +507,7 @@ public function getColumnDDL(Column $col) } if ($this->hasSize($sqlType) && $col->isDefaultSqlType($this)) { if ($this->isNumber($sqlType)) { - if ('NUMERIC' === strtoupper($sqlType)) { + if (strtoupper($sqlType) === 'NUMERIC') { $ddl[] = $sqlType . $col->getSizeDefinition(); } else { $ddl[] = $sqlType; @@ -526,7 +538,8 @@ public function getColumnDDL(Column $col) */ public function getUniqueDDL(Unique $unique) { - return sprintf('CONSTRAINT %s UNIQUE (%s)', + return sprintf( + 'CONSTRAINT %s UNIQUE (%s)', $this->quoteIdentifier($unique->getName()), $this->getColumnListDDL($unique->getColumnObjects()) ); @@ -540,7 +553,7 @@ public function getUniqueDDL(Unique $unique) */ public function getRenameTableDDL($fromTableName, $toTableName) { - if (false !== ($pos = strpos($toTableName, '.'))) { + if (($pos = strpos($toTableName, '.')) !== false) { $toTableName = substr($toTableName, $pos + 1); } @@ -548,7 +561,8 @@ public function getRenameTableDDL($fromTableName, $toTableName) ALTER TABLE %s RENAME TO %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($fromTableName), $this->quoteIdentifier($toTableName) ); @@ -556,6 +570,7 @@ public function getRenameTableDDL($fromTableName, $toTableName) /** * @see Platform::supportsSchemas() + * * @return bool */ public function supportsSchemas() @@ -610,9 +625,11 @@ public function getModifyTableDDL(TableDiff $tableDiff) /** * Overrides the implementation from DefaultPlatform * - * @author Niklas Närhinen - * @return string + * @author Niklas Närhinen + * * @see DefaultPlatform::getModifyColumnDDL + * + * @return string */ public function getModifyColumnDDL(ColumnDiff $columnDiff) { @@ -637,14 +654,14 @@ public function getModifyColumnDDL(ColumnDiff $columnDiff) $seqName = "{$tableName}_{$colPlainName}_seq"; if ($toColumn->isAutoIncrement() && $table && $table->getIdMethodParameters() == null) { - $defaultValue = "nextval('$seqName'::regclass)"; $toColumn->setDefaultValue($defaultValue); $changedProperties['defaultValueValue'] = [null, $defaultValue]; //add sequence if (!$fromTable->getDatabase()->hasSequence($seqName)) { - $this->createOrDropSequences .= sprintf(" + $this->createOrDropSequences .= sprintf( + " CREATE SEQUENCE %s; ", $seqName @@ -659,7 +676,8 @@ public function getModifyColumnDDL(ColumnDiff $columnDiff) //remove sequence if ($fromTable->getDatabase()->hasSequence($seqName)) { - $this->createOrDropSequences .= sprintf(" + $this->createOrDropSequences .= sprintf( + " DROP SEQUENCE %s CASCADE; ", $seqName @@ -670,12 +688,11 @@ public function getModifyColumnDDL(ColumnDiff $columnDiff) } if (isset($changedProperties['size']) || isset($changedProperties['type']) || isset($changedProperties['sqlType']) || isset($changedProperties['scale'])) { - $sqlType = $toColumn->getDomain()->getSqlType(); if ($this->hasSize($sqlType) && $toColumn->isDefaultSqlType($this)) { if ($this->isNumber($sqlType)) { - if ('NUMERIC' === strtoupper($sqlType)) { + if (strtoupper($sqlType) === 'NUMERIC') { $sqlType .= $toColumn->getSizeDefinition(); } } else { @@ -686,7 +703,8 @@ public function getModifyColumnDDL(ColumnDiff $columnDiff) if ($using = $this->getUsingCast($fromColumn, $toColumn)) { $sqlType .= $using; } - $ret .= sprintf($pattern, + $ret .= sprintf( + $pattern, $this->quoteIdentifier($table->getName()), $colName . ' TYPE ' . $sqlType ); @@ -761,12 +779,12 @@ public function getUsingCast(Column $fromColumn, Column $toColumn) ELSE NULL END"; } - if ($this->isNumber($fromSqlType) && 'BYTEA' === $toSqlType) { + if ($this->isNumber($fromSqlType) && $toSqlType === 'BYTEA') { return " USING decode(CAST($name as text), 'escape')"; } - if ('DATE' === $fromSqlType && 'TIME' === $toSqlType) { - return " USING NULL"; + if ($fromSqlType === 'DATE' && $toSqlType === 'TIME') { + return ' USING NULL'; } if ($this->isNumber($fromSqlType) && $this->isNumber($toSqlType)) { @@ -777,15 +795,17 @@ public function getUsingCast(Column $fromColumn, Column $toColumn) return ''; } - return " USING NULL"; + return ' USING NULL'; } /** * Overrides the implementation from DefaultPlatform * - * @author Niklas Närhinen - * @return string + * @author Niklas Närhinen + * * @see DefaultPlatform::getModifyColumnsDDL + * + * @return string */ public function getModifyColumnsDDL($columnDiffs) { @@ -800,9 +820,11 @@ public function getModifyColumnsDDL($columnDiffs) /** * Overrides the implementation from DefaultPlatform * - * @author Niklas Närhinen - * @return string + * @author Niklas Närhinen + * * @see DefaultPlatform::getAddColumnsDLL + * + * @return string */ public function getAddColumnsDDL($columns) { @@ -817,9 +839,11 @@ public function getAddColumnsDDL($columns) /** * Overrides the implementation from DefaultPlatform * - * @author Niklas Närhinen - * @return string + * @author Niklas Närhinen + * * @see DefaultPlatform::getDropIndexDDL + * + * @return string */ public function getDropIndexDDL(Index $index) { @@ -828,7 +852,8 @@ public function getDropIndexDDL(Index $index) ALTER TABLE %s DROP CONSTRAINT %s; "; - return sprintf($pattern, + return sprintf( + $pattern, $this->quoteIdentifier($index->getTable()->getName()), $this->quoteIdentifier($index->getName()) ); @@ -849,9 +874,10 @@ public function getDropIndexDDL(Index $index) * @param string|null $phpType * * @throws \Propel\Generator\Exception\EngineException + * * @return string|string[]|null */ - public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = " ", $phpType = null) + public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = ' ', $phpType = null) { if (!$sequenceName) { throw new EngineException('PostgreSQL needs a sequence name to fetch primary keys'); @@ -859,11 +885,12 @@ public function getIdentifierPhp($columnValueMutator, $connectionVariableName = $snippet = " \$dataFetcher = %s->query(\"SELECT nextval('%s')\"); %s = %s\$dataFetcher->fetchColumn();"; - $script = sprintf($snippet, + $script = sprintf( + $snippet, $connectionVariableName, $sequenceName, $columnValueMutator, - $phpType ? '('.$phpType.') ' : '' + $phpType ? '(' . $phpType . ') ' : '' ); return preg_replace('/^/m', $tab, $script); diff --git a/src/Propel/Generator/Platform/PlatformInterface.php b/src/Propel/Generator/Platform/PlatformInterface.php index a3b4894503..3a3ee619f3 100644 --- a/src/Propel/Generator/Platform/PlatformInterface.php +++ b/src/Propel/Generator/Platform/PlatformInterface.php @@ -12,7 +12,6 @@ use Propel\Generator\Config\GeneratorConfigInterface; use Propel\Generator\Model\Column; -use Propel\Generator\Model\Domain; use Propel\Generator\Model\Table; use Propel\Runtime\Connection\ConnectionInterface; @@ -24,44 +23,46 @@ */ interface PlatformInterface { - /** * Constant for auto-increment id method. */ - const IDENTITY = "identity"; + public const IDENTITY = 'identity'; /** * Constant for sequence id method. */ - const SEQUENCE = "sequence"; + public const SEQUENCE = 'sequence'; /** * Constant for serial id method (postgresql). */ - const SERIAL = "serial"; + public const SERIAL = 'serial'; /** * Sets a database connection to use (for quoting, etc.). - * @param ConnectionInterface $con The database connection to use in this Platform class. + * + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con The database connection to use in this Platform class. */ - public function setConnection(ConnectionInterface $con = null); + public function setConnection(?ConnectionInterface $con = null); /** * Returns the database connection to use for this Platform class. - * @return ConnectionInterface The database connection or NULL if none has been set. + * + * @return \Propel\Runtime\Connection\ConnectionInterface The database connection or NULL if none has been set. */ public function getConnection(); /** * Sets the GeneratorConfigInterface which contains any generator build properties. * - * @param GeneratorConfigInterface $generatorConfig + * @param \Propel\Generator\Config\GeneratorConfigInterface $generatorConfig */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig); /** * Returns the short name of the database type that this platform represents. * For example MysqlPlatform->getDatabaseType() returns 'mysql'. + * * @return string */ public function getDatabaseType(); @@ -83,43 +84,52 @@ public function getMaxColumnNameLength(); /** * Returns the db specific domain for a propelType. * - * @param string $propelType the Propel type name. - * @return Domain The db specific domain. + * @param string $propelType the Propel type name. + * + * @return \Propel\Generator\Model\Domain The db specific domain. */ public function getDomainForType($propelType); /** - * @return string The RDBMS-specific SQL fragment for NULL - * or NOT NULL. + * Returns the RDBMS-specific SQL fragment for NULL + * or NOT NULL. + * + * @return string */ public function getNullString($notNull); /** - * @return string The RDBMS-specific SQL fragment for autoincrement. + * Returns the RDBMS-specific SQL fragment for autoincrement. + * + * @return string */ public function getAutoIncrement(); /** * Returns the DDL SQL for a Column object. + * * @return string */ public function getColumnDDL(Column $col); /** * Returns the SQL for the default value of a Column object. + * * @return string */ public function getColumnDefaultValueDDL(Column $col); /** * Creates a delimiter-delimited string list of column names, quoted using quoteIdentifier(). + * * @example * * echo $platform->getColumnListDDL(array('foo', 'bar'); * // '"foo","bar"' * - * @param Column[]|string[] $columns - * @param string $delimiter The delimiter to use in separating the column names. + * + * @param \Propel\Generator\Model\Column[]|string[] $columns + * @param string $delimiter The delimiter to use in separating the column names. * * @return string */ @@ -127,6 +137,7 @@ public function getColumnListDDL($columns, $delimiter = ','); /** * Returns the SQL for the primary key of a Table object + * * @return string */ public function getPrimaryKeyDDL(Table $table); @@ -134,22 +145,26 @@ public function getPrimaryKeyDDL(Table $table); /** * Returns if the RDBMS-specific SQL type has a size attribute. * - * @param string $sqlType the SQL type - * @return boolean True if the type has a size attribute + * @param string $sqlType the SQL type + * + * @return bool True if the type has a size attribute */ public function hasSize($sqlType); /** * Returns if the RDBMS-specific SQL type has a scale attribute. * - * @param string $sqlType the SQL type - * @return boolean True if the type has a scale attribute + * @param string $sqlType the SQL type + * + * @return bool True if the type has a scale attribute */ public function hasScale($sqlType); /** * Quote and escape needed characters in the string for underlying RDBMS. - * @param string $text + * + * @param string $text + * * @return string */ public function quote($text); @@ -158,43 +173,50 @@ public function quote($text); * Quotes a identifier. * * @param string $text + * * @return string */ public function doQuoting($text); /** * Whether RDBMS supports native index sizes. - * @return boolean + * + * @return bool */ public function supportsIndexSize(); /** * Whether RDBMS supports native ON DELETE triggers (e.g. ON DELETE CASCADE). - * @return boolean + * + * @return bool */ public function supportsNativeDeleteTrigger(); /** * Whether RDBMS supports INSERT null values in autoincremented primary keys - * @return boolean + * + * @return bool */ public function supportsInsertNullPk(); /** * Whether RDBMS supports native schemas for table layout. - * @return boolean + * + * @return bool */ public function supportsSchemas(); /** * Whether RDBMS supports migrations. - * @return boolean + * + * @return bool */ public function supportsMigrations(); /** * Whether RDBMS supports VARCHAR without explicit size - * @return boolean + * + * @return bool */ public function supportsVarcharWithoutSize(); @@ -207,31 +229,36 @@ public function supportsVarcharWithoutSize(); * This function is used to set default column values when building * SQL. * - * @param mixed $tf A boolean or string representation of boolean ('y', 'true'). + * @param mixed $tf A boolean or string representation of boolean ('y', 'true'). + * * @return string */ public function getBooleanString($tf); /** * Whether the underlying PDO driver for this platform returns BLOB columns as streams (instead of strings). - * @return boolean + * + * @return bool */ public function hasStreamBlobImpl(); /** * Gets the preferred timestamp formatter for setting date/time values. + * * @return string */ public function getTimestampFormatter(); /** * Gets the preferred date formatter for setting time values. + * * @return string */ public function getDateFormatter(); /** * Gets the preferred time formatter for setting time values. + * * @return string */ public function getTimeFormatter(); @@ -247,11 +274,10 @@ public function getSchemaDelimiter(); * Useful for checking needed definitions/structures. E.g. Unique Indexes for ForeignKey columns, * which the most Platforms requires but which is not always explicitly defined in the table model. * - * @param Table $table The table object which gets modified. + * @param \Propel\Generator\Model\Table $table The table object which gets modified. */ public function normalizeTable(Table $table); - /** * Get the PHP snippet for binding a value to a column. * Warning: duplicates logic from AdapterInterface::bindValue(). @@ -264,15 +290,15 @@ public function normalizeTable(Table $table); * * @return string */ - public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = " "); + public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = ' '); /** - * @return boolean + * @return bool */ public function isIdentifierQuotingEnabled(); /** - * @param boolean $enabled + * @param bool $enabled */ public function setIdentifierQuoting($enabled); } diff --git a/src/Propel/Generator/Platform/SqlitePlatform.php b/src/Propel/Generator/Platform/SqlitePlatform.php index 37808eb5b8..bbda38a4e0 100644 --- a/src/Propel/Generator/Platform/SqlitePlatform.php +++ b/src/Propel/Generator/Platform/SqlitePlatform.php @@ -21,6 +21,7 @@ use Propel\Generator\Model\PropelTypes; use Propel\Generator\Model\Table; use Propel\Generator\Model\Unique; +use SQLite3; /** * SQLite PlatformInterface implementation. @@ -35,7 +36,7 @@ class SqlitePlatform extends DefaultPlatform * * @var bool|null */ - protected $foreignKeySupport = null; + protected $foreignKeySupport; /** * If we should alter the table through creating a temporarily created table, @@ -47,13 +48,14 @@ class SqlitePlatform extends DefaultPlatform /** * Initializes db specific domain mapping. + * * @return void */ protected function initialize() { parent::initialize(); - $version = \SQLite3::version(); + $version = SQLite3::version(); $version = $version['versionString']; $this->foreignKeySupport = version_compare($version, '3.6.19') >= 0; @@ -86,34 +88,35 @@ public function getSchemaDelimiter() public function getDefaultTypeSizes() { return [ - 'char' => 1, + 'char' => 1, 'character' => 1, - 'integer' => 32, - 'bigint' => 64, - 'smallint' => 16, - 'double precision' => 54 + 'integer' => 32, + 'bigint' => 64, + 'smallint' => 16, + 'double precision' => 54, ]; } /** - * @inheritdoc + * @inheritDoc */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) { parent::setGeneratorConfig($generatorConfig); - if (null !== ($foreignKeySupport = $generatorConfig->getConfigProperty('database.adapter.sqlite.foreignKey'))) { - $this->foreignKeySupport = filter_var($foreignKeySupport, FILTER_VALIDATE_BOOLEAN);; + if (($foreignKeySupport = $generatorConfig->getConfigProperty('database.adapter.sqlite.foreignKey')) !== null) { + $this->foreignKeySupport = filter_var($foreignKeySupport, FILTER_VALIDATE_BOOLEAN); } - if (null !== ($tableAlteringWorkaround = $generatorConfig->getConfigProperty('database.adapter.sqlite.tableAlteringWorkaround'))) { - $this->tableAlteringWorkaround = filter_var($tableAlteringWorkaround, FILTER_VALIDATE_BOOLEAN);;; + if (($tableAlteringWorkaround = $generatorConfig->getConfigProperty('database.adapter.sqlite.tableAlteringWorkaround')) !== null) { + $this->tableAlteringWorkaround = filter_var($tableAlteringWorkaround, FILTER_VALIDATE_BOOLEAN); } } /** * Builds the DDL SQL to remove a list of columns * - * @param Column[] $columns + * @param \Propel\Generator\Model\Column[] $columns + * * @return string */ public function getAddColumnsDDL($columns) @@ -124,7 +127,8 @@ public function getAddColumnsDDL($columns) "; foreach ($columns as $column) { $tableName = $column->getTable()->getName(); - $ret .= sprintf($pattern, + $ret .= sprintf( + $pattern, $this->quoteIdentifier($tableName), $this->getColumnDDL($column) ); @@ -134,7 +138,7 @@ public function getAddColumnsDDL($columns) } /** - * @inheritdoc + * @inheritDoc */ public function getModifyTableDDL(TableDiff $tableDiff) { @@ -154,10 +158,8 @@ public function getModifyTableDDL(TableDiff $tableDiff) ); if ($this->tableAlteringWorkaround && !$changedNotEditableThroughDirectDDL && $tableDiff->hasAddedColumns()) { - $addedCols = $tableDiff->getAddedColumns(); foreach ($addedCols as $column) { - $sqlChangeNotSupported = false //The column may not have a PRIMARY KEY or UNIQUE constraint. @@ -166,19 +168,20 @@ public function getModifyTableDDL(TableDiff $tableDiff) //The column may not have a default value of CURRENT_TIME, CURRENT_DATE, CURRENT_TIMESTAMP, //or an expression in parentheses. - || false !== array_search( - $column->getDefaultValue(), ['CURRENT_TIME', 'CURRENT_DATE', 'CURRENT_TIMESTAMP']) + || array_search( + $column->getDefaultValue(), + ['CURRENT_TIME', 'CURRENT_DATE', 'CURRENT_TIMESTAMP'] + ) !== false || substr(trim($column->getDefaultValue()), 0, 1) === '(' //If a NOT NULL constraint is specified, then the column must have a default value other than NULL. - || ($column->isNotNull() && $column->getDefaultValue()->getValue() === 'NULL') - ; + || ($column->isNotNull() && $column->getDefaultValue()->getValue() === 'NULL'); if ($sqlChangeNotSupported) { $changedNotEditableThroughDirectDDL = true; + break; } - } } @@ -193,7 +196,8 @@ public function getModifyTableDDL(TableDiff $tableDiff) * Creates a temporarily created table with the new schema, * moves all items into it and drops the origin as well as renames the temp table to the origin then. * - * @param TableDiff $tableDiff + * @param \Propel\Generator\Model\Diff\TableDiff $tableDiff + * * @return string */ public function getMigrationTableDDL(TableDiff $tableDiff) @@ -206,15 +210,15 @@ public function getMigrationTableDDL(TableDiff $tableDiff) DROP TABLE %s; "; - $originTable = clone $tableDiff->getFromTable(); - $newTable = clone $tableDiff->getToTable(); + $originTable = clone $tableDiff->getFromTable(); + $newTable = clone $tableDiff->getToTable(); $originTableName = $originTable->getName(); - $tempTableName = $newTable->getCommonName().'__temp__'.uniqid(); + $tempTableName = $newTable->getCommonName() . '__temp__' . uniqid(); $originTableFields = $this->getColumnListDDL($originTable->getColumns()); - $fieldMap = []; /** struct: [ => ] */ + $fieldMap = []; //start with modified columns foreach ($tableDiff->getModifiedColumns() as $diff) { $fieldMap[$diff->getFromColumn()->getName()] = $diff->getToColumn()->getName(); @@ -231,13 +235,13 @@ public function getMigrationTableDDL(TableDiff $tableDiff) $fieldMap[$col->getName()] = $col->getName(); } } - } $createTable = $this->getAddTableDDL($newTable); $createTable .= $this->getAddIndicesDDL($newTable); - $sql = sprintf($pattern, + $sql = sprintf( + $pattern, $this->quoteIdentifier($tempTableName), //CREATE TEMPORARY TABLE %s $originTableFields, //select %s $this->quoteIdentifier($originTableName), //from %s @@ -299,7 +303,8 @@ public function getAddTablesDDL(Database $database) * so we have to flag both as NOT NULL and create in either way a UNIQUE constraint over pks since * those UNIQUE is otherwise automatically created by the sqlite engine. * - * @param Table $table + * @param \Propel\Generator\Model\Table $table + * * @return void */ public function normalizeTable(Table $table) @@ -312,12 +317,14 @@ public function normalizeTable(Table $table) foreach ($unique->getColumns() as $columnName) { if (!$table->getColumn($columnName)->isPrimaryKey()) { $coversAllPrimaryKeys = false; + break; } } if ($coversAllPrimaryKeys) { //there's already a unique constraint with the composite pk $pkUniqueExist = true; + break; } } @@ -349,6 +356,7 @@ public function normalizeTable(Table $table) /** * Returns the SQL for the primary key of a Table object + * * @return string */ public function getPrimaryKeyDDL(Table $table) @@ -361,7 +369,7 @@ public function getPrimaryKeyDDL(Table $table) } /** - * @inheritdoc + * @inheritDoc */ public function getRemoveColumnDDL(Column $column) { @@ -370,7 +378,7 @@ public function getRemoveColumnDDL(Column $column) } /** - * @inheritdoc + * @inheritDoc */ public function getRenameColumnDDL(Column $fromColumn, Column $toColumn) { @@ -379,7 +387,7 @@ public function getRenameColumnDDL(Column $fromColumn, Column $toColumn) } /** - * @inheritdoc + * @inheritDoc */ public function getModifyColumnDDL(ColumnDiff $columnDiff) { @@ -388,7 +396,7 @@ public function getModifyColumnDDL(ColumnDiff $columnDiff) } /** - * @inheritdoc + * @inheritDoc */ public function getModifyColumnsDDL($columnDiffs) { @@ -397,7 +405,7 @@ public function getModifyColumnsDDL($columnDiffs) } /** - * @inheritdoc + * @inheritDoc */ public function getDropPrimaryKeyDDL(Table $table) { @@ -406,7 +414,7 @@ public function getDropPrimaryKeyDDL(Table $table) } /** - * @inheritdoc + * @inheritDoc */ public function getAddPrimaryKeyDDL(Table $table) { @@ -415,7 +423,7 @@ public function getAddPrimaryKeyDDL(Table $table) } /** - * @inheritdoc + * @inheritDoc */ public function getAddForeignKeyDDL(ForeignKey $fk) { @@ -424,7 +432,7 @@ public function getAddForeignKeyDDL(ForeignKey $fk) } /** - * @inheritdoc + * @inheritDoc */ public function getDropForeignKeyDDL(ForeignKey $fk) { @@ -433,7 +441,8 @@ public function getDropForeignKeyDDL(ForeignKey $fk) } /** - * @link http://www.sqlite.org/autoinc.html + * @link http://www.sqlite.org/autoinc.html + * * @return string */ public function getAutoIncrement() @@ -461,9 +470,11 @@ public function getColumnDDL(Column $col) $col->setDomainForType('INTEGER'); } - if ($col->getDefaultValue() + if ( + $col->getDefaultValue() && $col->getDefaultValue()->isExpression() - && 'CURRENT_TIMESTAMP' === $col->getDefaultValue()->getValue()) { + && $col->getDefaultValue()->getValue() === 'CURRENT_TIMESTAMP' + ) { //sqlite use CURRENT_TIMESTAMP different than mysql/pgsql etc //we set it to the more common behavior $col->setDefaultValue( @@ -519,7 +530,8 @@ public function getAddTableDDL(Table $table) ); "; - return sprintf($pattern, + return sprintf( + $pattern, $tableDescription, $this->quoteIdentifier($table->getName()), implode($sep, $lines) @@ -537,9 +549,10 @@ public function getForeignKeyDDL(ForeignKey $fk) return ''; } - $pattern = "FOREIGN KEY (%s) REFERENCES %s (%s)"; + $pattern = 'FOREIGN KEY (%s) REFERENCES %s (%s)'; - $script = sprintf($pattern, + $script = sprintf( + $pattern, $this->getColumnListDDL($fk->getLocalColumnObjects()), $this->quoteIdentifier($fk->getForeignTableName()), $this->getColumnListDDL($fk->getForeignColumnObjects()) @@ -574,7 +587,7 @@ public function hasSize($sqlType) } /** - * @inheritdoc + * @inheritDoc */ public function doQuoting($text) { diff --git a/src/Propel/Generator/Reverse/AbstractSchemaParser.php b/src/Propel/Generator/Reverse/AbstractSchemaParser.php index 6826d9de9a..7852aa6cc0 100644 --- a/src/Propel/Generator/Reverse/AbstractSchemaParser.php +++ b/src/Propel/Generator/Reverse/AbstractSchemaParser.php @@ -24,7 +24,7 @@ abstract class AbstractSchemaParser implements SchemaParserInterface /** * The database connection. * - * @var ConnectionInterface + * @var \Propel\Runtime\Connection\ConnectionInterface */ protected $dbh; @@ -38,7 +38,7 @@ abstract class AbstractSchemaParser implements SchemaParserInterface /** * GeneratorConfig object holding build properties. * - * @var GeneratorConfigInterface + * @var \Propel\Generator\Config\GeneratorConfigInterface */ private $generatorConfig; @@ -74,11 +74,11 @@ abstract class AbstractSchemaParser implements SchemaParserInterface /** * Constructor. * - * @param ConnectionInterface $dbh Optional database connection + * @param \Propel\Runtime\Connection\ConnectionInterface|null $dbh Optional database connection */ - public function __construct(ConnectionInterface $dbh = null) + public function __construct(?ConnectionInterface $dbh = null) { - if (null !== $dbh) { + if ($dbh !== null) { $this->setConnection($dbh); } } @@ -86,7 +86,8 @@ public function __construct(ConnectionInterface $dbh = null) /** * Sets the database connection. * - * @param ConnectionInterface $dbh + * @param \Propel\Runtime\Connection\ConnectionInterface $dbh + * * @return void */ public function setConnection(ConnectionInterface $dbh) @@ -96,7 +97,8 @@ public function setConnection(ConnectionInterface $dbh) /** * Gets the database connection. - * @return ConnectionInterface + * + * @return \Propel\Runtime\Connection\ConnectionInterface */ public function getConnection() { @@ -107,6 +109,7 @@ public function getConnection() * Setter for the migrationTable property * * @param string $migrationTable + * * @return void */ public function setMigrationTable($migrationTable) @@ -128,6 +131,7 @@ public function getMigrationTable() * Pushes a message onto the stack of warnings. * * @param string $msg The warning message. + * * @return void */ protected function warn($msg) @@ -148,7 +152,8 @@ public function getWarnings() /** * Sets the GeneratorConfig to use in the parsing. * - * @param GeneratorConfigInterface $config + * @param \Propel\Generator\Config\GeneratorConfigInterface $config + * * @return void */ public function setGeneratorConfig(GeneratorConfigInterface $config) @@ -159,7 +164,7 @@ public function setGeneratorConfig(GeneratorConfigInterface $config) /** * Gets the GeneratorConfig option. * - * @return GeneratorConfigInterface + * @return \Propel\Generator\Config\GeneratorConfigInterface */ public function getGeneratorConfig() { @@ -176,12 +181,13 @@ abstract protected function getTypeMapping(); /** * Gets a mapped Propel type for specified native type. * - * @param string $nativeType + * @param string $nativeType + * * @return string|null The mapped Propel type. */ protected function getMappedPropelType($nativeType) { - if (null === $this->nativeToPropelTypeMap) { + if ($this->nativeToPropelTypeMap === null) { $this->nativeToPropelTypeMap = $this->getTypeMapping(); } @@ -195,12 +201,13 @@ protected function getMappedPropelType($nativeType) /** * Give a best guess at the native type. * - * @param string $propelType + * @param string $propelType + * * @return string The native SQL type that best matches the specified Propel type. */ protected function getMappedNativeType($propelType) { - if (null === $this->reverseTypeMap) { + if ($this->reverseTypeMap === null) { $this->reverseTypeMap = array_flip($this->getTypeMapping()); } @@ -239,7 +246,7 @@ public function setPlatform($platform) */ public function getPlatform() { - if (null === $this->platform) { + if ($this->platform === null) { $this->platform = $this->getGeneratorConfig()->getConfiguredPlatform(); } diff --git a/src/Propel/Generator/Reverse/MssqlSchemaParser.php b/src/Propel/Generator/Reverse/MssqlSchemaParser.php index 0a4abe47e5..6b8e3f862a 100644 --- a/src/Propel/Generator/Reverse/MssqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/MssqlSchemaParser.php @@ -11,14 +11,15 @@ namespace Propel\Generator\Reverse; // TODO: to remove +use PDO; use Propel\Generator\Model\Column; use Propel\Generator\Model\ColumnDefaultValue; +use Propel\Generator\Model\Database; use Propel\Generator\Model\ForeignKey; use Propel\Generator\Model\Index; -use Propel\Generator\Model\Unique; -use Propel\Generator\Model\Table; -use Propel\Generator\Model\Database; use Propel\Generator\Model\PropelTypes; +use Propel\Generator\Model\Table; +use Propel\Generator\Model\Unique; /** * Microsoft SQL Server database schema parser. @@ -30,46 +31,47 @@ class MssqlSchemaParser extends AbstractSchemaParser { /** * Map MSSQL native types to Propel types. + * * @var array */ private static $mssqlTypeMap = [ - 'binary' => PropelTypes::BINARY, - 'bit' => PropelTypes::BOOLEAN, - 'char' => PropelTypes::CHAR, - 'datetime' => PropelTypes::TIMESTAMP, + 'binary' => PropelTypes::BINARY, + 'bit' => PropelTypes::BOOLEAN, + 'char' => PropelTypes::CHAR, + 'datetime' => PropelTypes::TIMESTAMP, 'decimal() identity' => PropelTypes::DECIMAL, - 'decimal' => PropelTypes::DECIMAL, - 'image' => PropelTypes::LONGVARBINARY, - 'int' => PropelTypes::INTEGER, - 'int identity' => PropelTypes::INTEGER, - 'integer' => PropelTypes::INTEGER, - 'money' => PropelTypes::DECIMAL, - 'nchar' => PropelTypes::CHAR, - 'ntext' => PropelTypes::LONGVARCHAR, + 'decimal' => PropelTypes::DECIMAL, + 'image' => PropelTypes::LONGVARBINARY, + 'int' => PropelTypes::INTEGER, + 'int identity' => PropelTypes::INTEGER, + 'integer' => PropelTypes::INTEGER, + 'money' => PropelTypes::DECIMAL, + 'nchar' => PropelTypes::CHAR, + 'ntext' => PropelTypes::LONGVARCHAR, 'numeric() identity' => PropelTypes::NUMERIC, - 'numeric' => PropelTypes::NUMERIC, - 'nvarchar' => PropelTypes::VARCHAR, - 'real' => PropelTypes::REAL, - 'float' => PropelTypes::FLOAT, - 'smalldatetime' => PropelTypes::TIMESTAMP, - 'smallint' => PropelTypes::SMALLINT, - 'smallint identity' => PropelTypes::SMALLINT, - 'smallmoney' => PropelTypes::DECIMAL, - 'sysname' => PropelTypes::VARCHAR, - 'text' => PropelTypes::LONGVARCHAR, - 'timestamp' => PropelTypes::BINARY, - 'tinyint identity' => PropelTypes::TINYINT, - 'tinyint' => PropelTypes::TINYINT, - 'uniqueidentifier' => PropelTypes::CHAR, - 'varbinary' => PropelTypes::VARBINARY, - 'varbinary(max)' => PropelTypes::CLOB, - 'varchar' => PropelTypes::VARCHAR, - 'varchar(max)' => PropelTypes::CLOB, - 'geometry' => PropelTypes::GEOMETRY, + 'numeric' => PropelTypes::NUMERIC, + 'nvarchar' => PropelTypes::VARCHAR, + 'real' => PropelTypes::REAL, + 'float' => PropelTypes::FLOAT, + 'smalldatetime' => PropelTypes::TIMESTAMP, + 'smallint' => PropelTypes::SMALLINT, + 'smallint identity' => PropelTypes::SMALLINT, + 'smallmoney' => PropelTypes::DECIMAL, + 'sysname' => PropelTypes::VARCHAR, + 'text' => PropelTypes::LONGVARCHAR, + 'timestamp' => PropelTypes::BINARY, + 'tinyint identity' => PropelTypes::TINYINT, + 'tinyint' => PropelTypes::TINYINT, + 'uniqueidentifier' => PropelTypes::CHAR, + 'varbinary' => PropelTypes::VARBINARY, + 'varbinary(max)' => PropelTypes::CLOB, + 'varchar' => PropelTypes::VARCHAR, + 'varchar(max)' => PropelTypes::CLOB, + 'geometry' => PropelTypes::GEOMETRY, // SQL Server 2000 only - 'bigint identity' => PropelTypes::BIGINT, - 'bigint' => PropelTypes::BIGINT, - 'sql_variant' => PropelTypes::VARCHAR, + 'bigint identity' => PropelTypes::BIGINT, + 'bigint' => PropelTypes::BIGINT, + 'sql_variant' => PropelTypes::VARCHAR, ]; /** @@ -121,17 +123,17 @@ public function parse(Database $database, array $additionalTables = []) /** * Adds Columns to the specified table. * - * @param Table $table The Table model class to add columns to. + * @param \Propel\Generator\Model\Table $table The Table model class to add columns to. + * * @return void */ protected function addColumns(Table $table) { /** @var \Propel\Runtime\DataFetcher\PDODataFetcher $dataFetcher */ $dataFetcher = $this->dbh->query("sp_columns '" . $table->getName() . "'"); - $dataFetcher->setStyle(\PDO::FETCH_ASSOC); + $dataFetcher->setStyle(PDO::FETCH_ASSOC); foreach ($dataFetcher as $row) { - $name = $this->cleanDelimitedIdentifiers($row['COLUMN_NAME']); $type = $row['TYPE_NAME']; $size = $row['LENGTH']; @@ -168,6 +170,7 @@ protected function addColumns(Table $table) /** * Load foreign keys for this table. + * * @return void */ protected function addForeignKeys(Table $table) @@ -181,12 +184,11 @@ protected function addForeignKeys(Table $table) inner join sys.columns lcol on lcol.object_id = ref.parent_object_id and lcol.column_id = ref.parent_column_id inner join sys.columns rcol on rcol.object_id = ref.referenced_object_id and rcol.column_id = ref.referenced_column_id inner join sys.tables rtab on rtab.object_id = ref.referenced_object_id - where fk.parent_object_id = OBJECT_ID('".$table->getName()."')"); - $dataFetcher->setStyle(\PDO::FETCH_ASSOC); + where fk.parent_object_id = OBJECT_ID('" . $table->getName() . "')"); + $dataFetcher->setStyle(PDO::FETCH_ASSOC); $foreignKeys = []; // local store to avoid duplicates foreach ($dataFetcher as $row) { - $name = $this->cleanDelimitedIdentifiers($row['CONSTRAINT_NAME']); $lcol = $this->cleanDelimitedIdentifiers($row['COLUMN_NAME']); $ftbl = $this->cleanDelimitedIdentifiers($row['FK_TABLE_NAME']); @@ -194,7 +196,7 @@ protected function addForeignKeys(Table $table) $foreignTable = $database->getTable($ftbl); $foreignColumn = $foreignTable->getColumn($fcol); - $localColumn = $table->getColumn($lcol); + $localColumn = $table->getColumn($lcol); if (!isset($foreignKeys[$name])) { $fk = new ForeignKey($name); @@ -207,18 +209,18 @@ protected function addForeignKeys(Table $table) } $foreignKeys[$name]->addReference($localColumn, $foreignColumn); } - } /** * Load indexes for this table + * * @return void */ protected function addIndexes(Table $table) { /** @var \Propel\Runtime\DataFetcher\PDODataFetcher $dataFetcher */ $dataFetcher = $this->dbh->query("sp_indexes_rowset '" . $table->getName() . "'"); - $dataFetcher->setStyle(\PDO::FETCH_ASSOC); + $dataFetcher->setStyle(PDO::FETCH_ASSOC); $indexes = []; foreach ($dataFetcher as $row) { @@ -228,7 +230,7 @@ protected function addIndexes(Table $table) $isPk = $this->cleanDelimitedIdentifiers($row['PRIMARY_KEY']); $isUnique = $this->cleanDelimitedIdentifiers($row['UNIQUE']); - $localColumn = $table->getColumn($colName); + $localColumn = $table->getColumn($colName); // ignore PRIMARY index if ($isPk) { @@ -258,6 +260,7 @@ protected function addIndexes(Table $table) /** * Loads the primary key for this table. + * * @return void */ protected function addPrimaryKey(Table $table) @@ -267,7 +270,7 @@ protected function addPrimaryKey(Table $table) INNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ON INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_NAME = INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE.constraint_name WHERE (INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE = 'PRIMARY KEY') AND - (INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME = '".$table->getName()."')"); + (INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME = '" . $table->getName() . "')"); // Loop through the returned results, grouping the same key_name together // adding each column for that key. @@ -280,9 +283,11 @@ protected function addPrimaryKey(Table $table) /** * according to the identifier definition, we have to clean simple quote (') around the identifier name * returns by mssql + * * @see http://msdn.microsoft.com/library/ms175874.aspx * - * @param string $identifier + * @param string $identifier + * * @return string */ protected function cleanDelimitedIdentifiers($identifier) diff --git a/src/Propel/Generator/Reverse/MysqlSchemaParser.php b/src/Propel/Generator/Reverse/MysqlSchemaParser.php index 1797c0e2b4..e6d4e23b49 100644 --- a/src/Propel/Generator/Reverse/MysqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/MysqlSchemaParser.php @@ -10,14 +10,15 @@ namespace Propel\Generator\Reverse; +use PDO; use Propel\Generator\Model\Column; +use Propel\Generator\Model\ColumnDefaultValue; use Propel\Generator\Model\Database; use Propel\Generator\Model\ForeignKey; use Propel\Generator\Model\Index; +use Propel\Generator\Model\PropelTypes; use Propel\Generator\Model\Table; use Propel\Generator\Model\Unique; -use Propel\Generator\Model\PropelTypes; -use Propel\Generator\Model\ColumnDefaultValue; /** * Mysql database schema parser. @@ -27,53 +28,54 @@ class MysqlSchemaParser extends AbstractSchemaParser { /** - * @var boolean + * @var bool */ private $addVendorInfo = false; /** * Map MySQL native types to Propel types. + * * @var array */ private static $mysqlTypeMap = [ - 'tinyint' => PropelTypes::TINYINT, - 'smallint' => PropelTypes::SMALLINT, - 'mediumint' => PropelTypes::SMALLINT, - 'int' => PropelTypes::INTEGER, - 'integer' => PropelTypes::INTEGER, - 'bigint' => PropelTypes::BIGINT, - 'int24' => PropelTypes::BIGINT, - 'real' => PropelTypes::DOUBLE, - 'float' => PropelTypes::FLOAT, - 'decimal' => PropelTypes::DECIMAL, - 'numeric' => PropelTypes::NUMERIC, - 'double' => PropelTypes::DOUBLE, - 'char' => PropelTypes::CHAR, - 'varchar' => PropelTypes::VARCHAR, - 'date' => PropelTypes::DATE, - 'time' => PropelTypes::TIME, - 'year' => PropelTypes::INTEGER, - 'datetime' => PropelTypes::TIMESTAMP, - 'timestamp' => PropelTypes::TIMESTAMP, - 'tinyblob' => PropelTypes::BINARY, - 'blob' => PropelTypes::BLOB, + 'tinyint' => PropelTypes::TINYINT, + 'smallint' => PropelTypes::SMALLINT, + 'mediumint' => PropelTypes::SMALLINT, + 'int' => PropelTypes::INTEGER, + 'integer' => PropelTypes::INTEGER, + 'bigint' => PropelTypes::BIGINT, + 'int24' => PropelTypes::BIGINT, + 'real' => PropelTypes::DOUBLE, + 'float' => PropelTypes::FLOAT, + 'decimal' => PropelTypes::DECIMAL, + 'numeric' => PropelTypes::NUMERIC, + 'double' => PropelTypes::DOUBLE, + 'char' => PropelTypes::CHAR, + 'varchar' => PropelTypes::VARCHAR, + 'date' => PropelTypes::DATE, + 'time' => PropelTypes::TIME, + 'year' => PropelTypes::INTEGER, + 'datetime' => PropelTypes::TIMESTAMP, + 'timestamp' => PropelTypes::TIMESTAMP, + 'tinyblob' => PropelTypes::BINARY, + 'blob' => PropelTypes::BLOB, 'mediumblob' => PropelTypes::VARBINARY, - 'longblob' => PropelTypes::LONGVARBINARY, - 'longtext' => PropelTypes::CLOB, - 'tinytext' => PropelTypes::VARCHAR, + 'longblob' => PropelTypes::LONGVARBINARY, + 'longtext' => PropelTypes::CLOB, + 'tinytext' => PropelTypes::VARCHAR, 'mediumtext' => PropelTypes::LONGVARCHAR, - 'text' => PropelTypes::LONGVARCHAR, - 'enum' => PropelTypes::CHAR, - 'set' => PropelTypes::CHAR, + 'text' => PropelTypes::LONGVARCHAR, + 'enum' => PropelTypes::CHAR, + 'set' => PropelTypes::CHAR, ]; protected static $defaultTypeSizes = [ - 'char' => 1, - 'tinyint' => 4, + 'char' => 1, + 'tinyint' => 4, 'smallint' => 6, - 'int' => 11, - 'bigint' => 20, - 'decimal' => 10, + 'int' => 11, + 'bigint' => 20, + 'decimal' => 10, ]; /** @@ -87,13 +89,14 @@ protected function getTypeMapping() } /** - * @param Database $database - * @param Table[] $additionalTables + * @param \Propel\Generator\Model\Database $database + * @param \Propel\Generator\Model\Table[] $additionalTables + * * @return int */ public function parse(Database $database, array $additionalTables = []) { - if (null !== $this->getGeneratorConfig()) { + if ($this->getGeneratorConfig() !== null) { $this->addVendorInfo = $this->getGeneratorConfig()->get()['migrations']['addVendorInfo']; } @@ -134,7 +137,7 @@ protected function parseTables(Database $database, $filterTable = null) $sql .= ' FROM ' . $database->getPlatform()->doQuoting($schema); } $sql .= sprintf(" LIKE '%s'", $filterTable->getCommonName()); - } else if ($schema = $database->getSchema()) { + } elseif ($schema = $database->getSchema()) { $sql .= ' FROM ' . $database->getPlatform()->doQuoting($schema); } @@ -161,7 +164,8 @@ protected function parseTables(Database $database, $filterTable = null) /** * Adds Columns to the specified table. * - * @param Table $table The Table model class to add columns to. + * @param \Propel\Generator\Model\Table $table The Table model class to add columns to. + * * @return void */ protected function addColumns(Table $table) @@ -169,7 +173,7 @@ protected function addColumns(Table $table) /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query(sprintf('SHOW COLUMNS FROM %s', $this->getPlatform()->doQuoting($table->getName()))); - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $column = $this->getColumnFromRow($row, $table); $table->addColumn($column); } @@ -179,15 +183,16 @@ protected function addColumns(Table $table) * Factory method creating a Column object * based on a row from the 'show columns from ' MySQL query result. * - * @param array $row An associative array with the following keys: + * @param array $row An associative array with the following keys: * Field, Type, Null, Key, Default, Extra. - * @return Column + * + * @return \Propel\Generator\Model\Column */ public function getColumnFromRow($row, Table $table) { $name = $row['Field']; - $isNullable = ('YES' === $row['Null']); - $autoincrement = (false !== strpos($row['Extra'], 'auto_increment')); + $isNullable = ($row['Null'] === 'YES'); + $autoincrement = (strpos($row['Extra'], 'auto_increment') !== false); $size = null; $scale = null; $sqlType = false; @@ -203,17 +208,17 @@ public function getColumnFromRow($row, Table $table) if (preg_match($regexp, $row['Type'], $matches)) { $nativeType = $matches[1]; if ($matches[2]) { - if (false !== ($cpos = strpos($matches[2], ','))) { - $size = (int) substr($matches[2], 0, $cpos); - $scale = (int) substr($matches[2], $cpos + 1); + if (($cpos = strpos($matches[2], ',')) !== false) { + $size = (int)substr($matches[2], 0, $cpos); + $scale = (int)substr($matches[2], $cpos + 1); } else { - $size = (int) $matches[2]; + $size = (int)$matches[2]; } } if ($matches[3]) { $sqlType = $row['Type']; } - if (isset(static::$defaultTypeSizes[$nativeType]) && null == $scale && $size === static::$defaultTypeSizes[$nativeType]) { + if (isset(static::$defaultTypeSizes[$nativeType]) && $scale == null && $size === static::$defaultTypeSizes[$nativeType]) { $size = null; } } elseif (preg_match('/^(\w+)\(/', $row['Type'], $matches)) { @@ -232,11 +237,11 @@ public function getColumnFromRow($row, Table $table) if (!$propelType) { $propelType = Column::DEFAULT_TYPE; $sqlType = $row['Type']; - $this->warn("Column [" . $table->getName() . "." . $name. "] has a column type (".$nativeType.") that Propel does not support."); + $this->warn('Column [' . $table->getName() . '.' . $name . '] has a column type (' . $nativeType . ') that Propel does not support.'); } // Special case for TINYINT(1) which is a BOOLEAN - if (PropelTypes::TINYINT === $propelType && 1 === $size) { + if ($propelType === PropelTypes::TINYINT && $size === 1) { $propelType = PropelTypes::BOOLEAN; } @@ -278,6 +283,7 @@ public function getColumnFromRow($row, Table $table) /** * Load foreign keys for this table. + * * @return void */ protected function addForeignKeys(Table $table) @@ -294,11 +300,11 @@ protected function addForeignKeys(Table $table) if (preg_match_all($pattern, $row[1], $matches)) { $tmpArray = array_keys($matches[0]); foreach ($tmpArray as $curKey) { - $name = $matches[1][$curKey]; + $name = $matches[1][$curKey]; $rawlcol = $matches[2][$curKey]; - $ftbl = str_replace('`', '', $matches[3][$curKey]); + $ftbl = str_replace('`', '', $matches[3][$curKey]); $rawfcol = $matches[4][$curKey]; - $fkey = $matches[5][$curKey]; + $fkey = $matches[5][$curKey]; $lcols = []; foreach (preg_split('/`, `/', $rawlcol) as $piece) { @@ -329,14 +335,14 @@ protected function addForeignKeys(Table $table) // restrict is the default foreach ($fkactions as $key => $action) { - if (ForeignKey::RESTRICT === $action) { + if ($action === ForeignKey::RESTRICT) { $fkactions[$key] = null; } } $localColumns = []; $foreignColumns = []; - if ($table->guessSchemaName() != $database->getSchema() && false == strpos($ftbl, $database->getPlatform()->getSchemaDelimiter())) { + if ($table->guessSchemaName() != $database->getSchema() && strpos($ftbl, $database->getPlatform()->getSchemaDelimiter()) == false) { $ftbl = $table->guessSchemaName() . $database->getPlatform()->getSchemaDelimiter() . $ftbl; } @@ -375,6 +381,7 @@ protected function addForeignKeys(Table $table) /** * Load indexes for this table + * * @return void */ protected function addIndexes(Table $table) @@ -385,19 +392,19 @@ protected function addIndexes(Table $table) // Loop through the returned results, grouping the same key_name together // adding each column for that key. - /** @var Index[] $indexes */ + /** @var \Propel\Generator\Model\Index[] $indexes */ $indexes = []; - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $colName = $row['Column_name']; $colSize = $row['Sub_part']; $name = $row['Key_name']; - if ('PRIMARY' === $name) { + if ($name === 'PRIMARY') { continue; } if (!isset($indexes[$name])) { - $isUnique = (0 == $row['Non_unique']); + $isUnique = ($row['Non_unique'] == 0); if ($isUnique) { $indexes[$name] = new Unique($name); } else { @@ -412,7 +419,7 @@ protected function addIndexes(Table $table) $indexes[$name]->addColumn([ 'name' => $colName, - 'size' => $colSize + 'size' => $colSize, ]); } @@ -427,6 +434,7 @@ protected function addIndexes(Table $table) /** * Loads the primary key for this table. + * * @return void */ protected function addPrimaryKey(Table $table) @@ -436,9 +444,9 @@ protected function addPrimaryKey(Table $table) // Loop through the returned results, grouping the same key_name together // adding each column for that key. - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { // Skip any non-primary keys. - if ('PRIMARY' !== $row['Key_name']) { + if ($row['Key_name'] !== 'PRIMARY') { continue; } $name = $row['Column_name']; @@ -452,14 +460,15 @@ protected function addPrimaryKey(Table $table) /** * Adds vendor-specific info for table. * - * @param Table $table + * @param \Propel\Generator\Model\Table $table + * * @return void */ protected function addTableVendorInfo(Table $table) { /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query("SHOW TABLE STATUS LIKE '" . $table->getName() . "'"); - $row = $stmt->fetch(\PDO::FETCH_ASSOC); + $row = $stmt->fetch(PDO::FETCH_ASSOC); if (!$this->addVendorInfo) { // since we depend on `Engine` in the MysqlPlatform, we always have to extract this vendor information $row = ['Engine' => $row ? $row['Engine'] : null]; diff --git a/src/Propel/Generator/Reverse/OracleSchemaParser.php b/src/Propel/Generator/Reverse/OracleSchemaParser.php index 380a11645f..8c14356725 100644 --- a/src/Propel/Generator/Reverse/OracleSchemaParser.php +++ b/src/Propel/Generator/Reverse/OracleSchemaParser.php @@ -10,6 +10,7 @@ namespace Propel\Generator\Reverse; +use PDO; use Propel\Generator\Model\Column; use Propel\Generator\Model\ColumnDefaultValue; use Propel\Generator\Model\Database; @@ -45,21 +46,21 @@ class OracleSchemaParser extends AbstractSchemaParser * @var array */ private static $oracleTypeMap = [ - 'BLOB' => PropelTypes::BLOB, - 'CHAR' => PropelTypes::CHAR, - 'CLOB' => PropelTypes::CLOB, - 'DATE' => PropelTypes::TIMESTAMP, - 'BIGINT' => PropelTypes::BIGINT, - 'DECIMAL' => PropelTypes::DECIMAL, - 'DOUBLE' => PropelTypes::DOUBLE, - 'FLOAT' => PropelTypes::FLOAT, - 'LONG' => PropelTypes::LONGVARCHAR, - 'NCHAR' => PropelTypes::CHAR, - 'NCLOB' => PropelTypes::CLOB, - 'NUMBER' => PropelTypes::INTEGER, + 'BLOB' => PropelTypes::BLOB, + 'CHAR' => PropelTypes::CHAR, + 'CLOB' => PropelTypes::CLOB, + 'DATE' => PropelTypes::TIMESTAMP, + 'BIGINT' => PropelTypes::BIGINT, + 'DECIMAL' => PropelTypes::DECIMAL, + 'DOUBLE' => PropelTypes::DOUBLE, + 'FLOAT' => PropelTypes::FLOAT, + 'LONG' => PropelTypes::LONGVARCHAR, + 'NCHAR' => PropelTypes::CHAR, + 'NCLOB' => PropelTypes::CLOB, + 'NUMBER' => PropelTypes::INTEGER, 'NVARCHAR2' => PropelTypes::VARCHAR, 'TIMESTAMP' => PropelTypes::TIMESTAMP, - 'VARCHAR2' => PropelTypes::VARCHAR, + 'VARCHAR2' => PropelTypes::VARCHAR, ]; /** @@ -74,8 +75,9 @@ protected function getTypeMapping() /** * Searches for tables in the database. Maybe we want to search also the views. - * @param Database $database The Database model class to add tables to. - * @param Table[] $additionalTables + * + * @param \Propel\Generator\Model\Database $database The Database model class to add tables to. + * @param \Propel\Generator\Model\Table[] $additionalTables */ public function parse(Database $database, array $additionalTables = []) { @@ -86,8 +88,8 @@ public function parse(Database $database, array $additionalTables = []) $seqPattern = $this->getGeneratorConfig()->get()['database']['adapters']['oracle']['autoincrementSequencePattern']; // First load the tables (important that this happen before filling out details of tables) - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - if (false !== strpos($row['OBJECT_NAME'], '$')) { + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + if (strpos($row['OBJECT_NAME'], '$') !== false) { // this is an Oracle internal table or materialized view - prune continue; } @@ -103,13 +105,13 @@ public function parse(Database $database, array $additionalTables = []) $this->addIndexes($table); $pkColumns = $table->getPrimaryKey(); - if (1 === count($pkColumns) && $seqPattern) { + if (count($pkColumns) === 1 && $seqPattern) { $seqName = str_replace('${table}', $table->getName(), $seqPattern); $seqName = strtoupper($seqName); /** @var \PDOStatement $stmt2 */ $stmt2 = $this->dbh->query("SELECT * FROM USER_SEQUENCES WHERE SEQUENCE_NAME = '" . $seqName . "'"); - $hasSeq = $stmt2->fetch(\PDO::FETCH_ASSOC); + $hasSeq = $stmt2->fetch(PDO::FETCH_ASSOC); if ($hasSeq) { $pkColumns[0]->setAutoIncrement(true); @@ -132,15 +134,16 @@ public function parse(Database $database, array $additionalTables = []) /** * Adds Columns to the specified table. * - * @param Table $table The Table model class to add columns to. + * @param \Propel\Generator\Model\Table $table The Table model class to add columns to. + * * @return void */ protected function addColumns(Table $table) { /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query("SELECT COLUMN_NAME, DATA_TYPE, NULLABLE, DATA_LENGTH, DATA_PRECISION, DATA_SCALE, DATA_DEFAULT FROM USER_TAB_COLS WHERE TABLE_NAME = '" . $table->getName() . "'"); - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - if (false !== strpos($row['COLUMN_NAME'], '$')) { + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + if (strpos($row['COLUMN_NAME'], '$') !== false) { // this is an Oracle internal column - prune continue; } @@ -148,7 +151,7 @@ protected function addColumns(Table $table) $scale = $row['DATA_SCALE']; $default = $row['DATA_DEFAULT']; $type = $row['DATA_TYPE']; - $isNullable = ('Y' === $row['NULLABLE']); + $isNullable = ($row['NULLABLE'] === 'Y'); if ($type === 'NUMBER' && $row['DATA_SCALE'] > 0) { $type = 'DECIMAL'; } @@ -158,13 +161,13 @@ protected function addColumns(Table $table) if ($type === 'FLOAT' && $row['DATA_PRECISION'] == 126) { $type = 'DOUBLE'; } - if (false !== strpos($type, 'TIMESTAMP(')) { + if (strpos($type, 'TIMESTAMP(') !== false) { $type = substr($type, 0, strpos($type, '(')); $default = '0000-00-00 00:00:00'; $size = null; $scale = null; } - if ('DATE' === $type) { + if ($type === 'DATE') { $default = '0000-00-00'; $size = null; $scale = null; @@ -173,7 +176,7 @@ protected function addColumns(Table $table) $propelType = $this->getMappedPropelType($type); if (!$propelType) { $propelType = Column::DEFAULT_TYPE; - $this->warn('Column [' . $table->getName() . '.' . $row['COLUMN_NAME']. '] has a column type ('.$row['DATA_TYPE'].') that Propel does not support.'); + $this->warn('Column [' . $table->getName() . '.' . $row['COLUMN_NAME'] . '] has a column type (' . $row['DATA_TYPE'] . ') that Propel does not support.'); } $column = new Column($row['COLUMN_NAME']); @@ -189,13 +192,13 @@ protected function addColumns(Table $table) $column->setNotNull(!$isNullable); $table->addColumn($column); } - } /** * Adds Indexes to the specified table. * - * @param Table $table The Table model class to add columns to. + * @param \Propel\Generator\Model\Table $table The Table model class to add columns to. + * * @return void */ protected function addIndexes(Table $table) @@ -204,8 +207,8 @@ protected function addIndexes(Table $table) $stmt = $this->dbh->query("SELECT INDEX_NAME, COLUMN_NAME FROM USER_IND_COLUMNS WHERE TABLE_NAME = '" . $table->getName() . "' ORDER BY COLUMN_NAME"); $indices = []; - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $indices[$row['INDEX_NAME']][]= $row['COLUMN_NAME']; + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $indices[$row['INDEX_NAME']][] = $row['COLUMN_NAME']; } foreach ($indices as $indexName => $columnNames) { @@ -227,7 +230,8 @@ protected function addIndexes(Table $table) /** * Load foreign keys for this table. * - * @param Table $table The Table model class to add FKs to + * @param \Propel\Generator\Model\Table $table The Table model class to add FKs to + * * @return void */ protected function addForeignKeys(Table $table) @@ -235,23 +239,23 @@ protected function addForeignKeys(Table $table) // local store to avoid duplicates $foreignKeys = []; - /* @var \PDOStatement $stmt */ - $stmt = $this->dbh->query("SELECT CONSTRAINT_NAME, DELETE_RULE, R_CONSTRAINT_NAME FROM USER_CONSTRAINTS WHERE CONSTRAINT_TYPE = 'R' AND TABLE_NAME = '" . $table->getName(). "'"); - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + /** @var \PDOStatement $stmt */ + $stmt = $this->dbh->query("SELECT CONSTRAINT_NAME, DELETE_RULE, R_CONSTRAINT_NAME FROM USER_CONSTRAINTS WHERE CONSTRAINT_TYPE = 'R' AND TABLE_NAME = '" . $table->getName() . "'"); + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { // Local reference - /* @var \PDOStatement $stmt2 */ - $stmt2 = $this->dbh->query("SELECT COLUMN_NAME FROM USER_CONS_COLUMNS WHERE CONSTRAINT_NAME = '".$row['CONSTRAINT_NAME']."' AND TABLE_NAME = '" . $table->getName(). "'"); - $localReferenceInfo = $stmt2->fetch(\PDO::FETCH_ASSOC); + /** @var \PDOStatement $stmt2 */ + $stmt2 = $this->dbh->query("SELECT COLUMN_NAME FROM USER_CONS_COLUMNS WHERE CONSTRAINT_NAME = '" . $row['CONSTRAINT_NAME'] . "' AND TABLE_NAME = '" . $table->getName() . "'"); + $localReferenceInfo = $stmt2->fetch(PDO::FETCH_ASSOC); // Foreign reference /** @var \PDOStatement $stmt3 */ - $stmt3 = $this->dbh->query("SELECT TABLE_NAME, COLUMN_NAME FROM USER_CONS_COLUMNS WHERE CONSTRAINT_NAME = '".$row['R_CONSTRAINT_NAME']."'"); - $foreignReferenceInfo = $stmt3->fetch(\PDO::FETCH_ASSOC); + $stmt3 = $this->dbh->query("SELECT TABLE_NAME, COLUMN_NAME FROM USER_CONS_COLUMNS WHERE CONSTRAINT_NAME = '" . $row['R_CONSTRAINT_NAME'] . "'"); + $foreignReferenceInfo = $stmt3->fetch(PDO::FETCH_ASSOC); if (!isset($foreignKeys[$row['CONSTRAINT_NAME']])) { $fk = new ForeignKey($row['CONSTRAINT_NAME']); $fk->setForeignTableCommonName($foreignReferenceInfo['TABLE_NAME']); - $onDelete = ('NO ACTION' === $row['DELETE_RULE']) ? 'NONE' : $row['DELETE_RULE']; + $onDelete = ($row['DELETE_RULE'] === 'NO ACTION') ? 'NONE' : $row['DELETE_RULE']; $fk->setOnDelete($onDelete); $fk->setOnUpdate($onDelete); $fk->addReference(['local' => $localReferenceInfo['COLUMN_NAME'], 'foreign' => $foreignReferenceInfo['COLUMN_NAME']]); @@ -264,14 +268,15 @@ protected function addForeignKeys(Table $table) /** * Loads the primary key for this table. * - * @param Table $table The Table model class to add PK to. + * @param \Propel\Generator\Model\Table $table The Table model class to add PK to. + * * @return void */ protected function addPrimaryKey(Table $table) { /** @var \PDOStatement $stmt */ - $stmt = $this->dbh->query("SELECT COLS.COLUMN_NAME FROM USER_CONSTRAINTS CONS, USER_CONS_COLUMNS COLS WHERE CONS.CONSTRAINT_NAME = COLS.CONSTRAINT_NAME AND CONS.TABLE_NAME = '".$table->getName()."' AND CONS.CONSTRAINT_TYPE = 'P'"); - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + $stmt = $this->dbh->query("SELECT COLS.COLUMN_NAME FROM USER_CONSTRAINTS CONS, USER_CONS_COLUMNS COLS WHERE CONS.CONSTRAINT_NAME = COLS.CONSTRAINT_NAME AND CONS.TABLE_NAME = '" . $table->getName() . "' AND CONS.CONSTRAINT_TYPE = 'P'"); + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { // This fixes a strange behavior by PDO. Sometimes the // row values are inside an index 0 of an array if (isset($row[0])) { diff --git a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php index 1b423784ce..cb556ae4ca 100755 --- a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php @@ -10,6 +10,7 @@ namespace Propel\Generator\Reverse; +use PDO; use Propel\Generator\Model\Column; use Propel\Generator\Model\ColumnDefaultValue; use Propel\Generator\Model\Database; @@ -18,6 +19,7 @@ use Propel\Generator\Model\PropelTypes; use Propel\Generator\Model\Table; use Propel\Generator\Model\Unique; +use stdClass; /** * Postgresql database schema parser. @@ -28,45 +30,46 @@ class PgsqlSchemaParser extends AbstractSchemaParser { /** * Map PostgreSQL native types to Propel types. + * * @var array */ - /** Map MySQL native types to Propel (JDBC) types. */ + private static $pgsqlTypeMap = [ - 'bool' => PropelTypes::BOOLEAN, - 'boolean' => PropelTypes::BOOLEAN, - 'tinyint' => PropelTypes::TINYINT, - 'smallint' => PropelTypes::SMALLINT, - 'mediumint' => PropelTypes::SMALLINT, - 'int2' => PropelTypes::SMALLINT, - 'int' => PropelTypes::INTEGER, - 'int4' => PropelTypes::INTEGER, - 'serial4' => PropelTypes::INTEGER, - 'integer' => PropelTypes::INTEGER, - 'int8' => PropelTypes::BIGINT, - 'bigint' => PropelTypes::BIGINT, - 'bigserial' => PropelTypes::BIGINT, - 'serial8' => PropelTypes::BIGINT, - 'int24' => PropelTypes::BIGINT, - 'real' => PropelTypes::REAL, - 'float' => PropelTypes::FLOAT, - 'float4' => PropelTypes::REAL, - 'decimal' => PropelTypes::DECIMAL, - 'numeric' => PropelTypes::DECIMAL, - 'double' => PropelTypes::DOUBLE, - 'float8' => PropelTypes::DOUBLE, - 'char' => PropelTypes::CHAR, - 'character' => PropelTypes::CHAR, - 'character varying' => PropelTypes::VARCHAR, - 'varchar' => PropelTypes::VARCHAR, - 'date' => PropelTypes::DATE, - 'time' => PropelTypes::TIME, - 'timetz' => PropelTypes::TIME, + 'bool' => PropelTypes::BOOLEAN, + 'boolean' => PropelTypes::BOOLEAN, + 'tinyint' => PropelTypes::TINYINT, + 'smallint' => PropelTypes::SMALLINT, + 'mediumint' => PropelTypes::SMALLINT, + 'int2' => PropelTypes::SMALLINT, + 'int' => PropelTypes::INTEGER, + 'int4' => PropelTypes::INTEGER, + 'serial4' => PropelTypes::INTEGER, + 'integer' => PropelTypes::INTEGER, + 'int8' => PropelTypes::BIGINT, + 'bigint' => PropelTypes::BIGINT, + 'bigserial' => PropelTypes::BIGINT, + 'serial8' => PropelTypes::BIGINT, + 'int24' => PropelTypes::BIGINT, + 'real' => PropelTypes::REAL, + 'float' => PropelTypes::FLOAT, + 'float4' => PropelTypes::REAL, + 'decimal' => PropelTypes::DECIMAL, + 'numeric' => PropelTypes::DECIMAL, + 'double' => PropelTypes::DOUBLE, + 'float8' => PropelTypes::DOUBLE, + 'char' => PropelTypes::CHAR, + 'character' => PropelTypes::CHAR, + 'character varying' => PropelTypes::VARCHAR, + 'varchar' => PropelTypes::VARCHAR, + 'date' => PropelTypes::DATE, + 'time' => PropelTypes::TIME, + 'timetz' => PropelTypes::TIME, //'year' => PropelTypes::YEAR, PropelTypes::YEAR does not exist... does this need to be mapped to a different propel type? - 'datetime' => PropelTypes::TIMESTAMP, - 'timestamp' => PropelTypes::TIMESTAMP, + 'datetime' => PropelTypes::TIMESTAMP, + 'timestamp' => PropelTypes::TIMESTAMP, 'timestamptz' => PropelTypes::TIMESTAMP, - 'bytea' => PropelTypes::BLOB, - 'text' => PropelTypes::LONGVARCHAR, + 'bytea' => PropelTypes::BLOB, + 'text' => PropelTypes::LONGVARCHAR, 'time without time zone' => PropelTypes::TIME, 'time with time zone' => PropelTypes::TIME, 'timestamp without time zone' => PropelTypes::TIMESTAMP, @@ -76,12 +79,12 @@ class PgsqlSchemaParser extends AbstractSchemaParser ]; protected static $defaultTypeSizes = [ - 'char' => 1, + 'char' => 1, 'character' => 1, - 'integer' => 32, - 'bigint' => 64, - 'smallint' => 16, - 'double precision' => 54 + 'integer' => 32, + 'bigint' => 64, + 'smallint' => 16, + 'double precision' => 54, ]; /** @@ -97,9 +100,10 @@ protected function getTypeMapping() /** * Parses a database schema. * - * @param Database $database - * @param Table[] $additionalTables - * @return integer + * @param \Propel\Generator\Model\Database $database + * @param \Propel\Generator\Model\Table[] $additionalTables + * + * @return int */ public function parse(Database $database, array $additionalTables = []) { @@ -134,7 +138,7 @@ public function parse(Database $database, array $additionalTables = []) * * @return void */ - protected function parseTables(&$tableWraps, Database $database, Table $filterTable = null) + protected function parseTables(&$tableWraps, Database $database, ?Table $filterTable = null) { $stmt = null; @@ -156,13 +160,12 @@ protected function parseTables(&$tableWraps, Database $database, Table $filterTa $sql .= ' AND c.relname = ?'; $params[] = $filterTable->getCommonName(); - - } else if (!$database->getSchema()) { + } elseif (!$database->getSchema()) { /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query('SELECT schema_name FROM information_schema.schemata'); $searchPath = []; - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $searchPath[] = $row['schema_name']; } @@ -173,7 +176,6 @@ protected function parseTables(&$tableWraps, Database $database, Table $filterTa $searchPath = implode(', ', $searchPath); $sql .= " AND n.nspname IN ($searchPath)"; - } elseif ($database->getSchema()) { $sql .= " AND n.nspname = ?"; @@ -189,7 +191,7 @@ protected function parseTables(&$tableWraps, Database $database, Table $filterTa $stmt->execute($params); // First load the tables (important that this happen before filling out details of tables) - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $name = $row['relname']; $namespaceName = $row['nspname']; if ($name == $this->getMigrationTable()) { @@ -197,7 +199,7 @@ protected function parseTables(&$tableWraps, Database $database, Table $filterTa } $oid = $row['oid']; $table = new Table($name); - if ('public' !== $namespaceName) { + if ($namespaceName !== 'public') { $table->setSchema($namespaceName); } $table->setIdMethod($database->getDefaultIdMethod()); @@ -206,20 +208,20 @@ protected function parseTables(&$tableWraps, Database $database, Table $filterTa $database->addTable($table); // Create a wrapper to hold these tables and their associated OID - $wrap = new \stdClass; + $wrap = new stdClass(); $wrap->table = $table; $wrap->oid = $oid; $tableWraps[] = $wrap; } } - } /** * Adds Columns to the specified table. * - * @param Table $table The Table model class to add columns to. - * @param int $oid The table OID + * @param \Propel\Generator\Model\Table $table The Table model class to add columns to. + * @param int $oid The table OID + * * @return void */ protected function addColumns(Table $table, $oid) @@ -233,7 +235,7 @@ protected function addColumns(Table $table, $oid) if ($schema = $table->getSchema()) { $searchPath = '?'; $params = [$schema]; - } else if (!$table->getDatabase()->getSchema()) { + } elseif (!$table->getDatabase()->getSchema()) { $stmt = $this->dbh->query('SHOW search_path'); $searchPathString = $stmt->fetchColumn(); @@ -264,8 +266,7 @@ protected function addColumns(Table $table, $oid) $params[] = $table->getCommonName(); $stmt->execute($params); - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $size = $row['character_maximum_length']; if (!$size) { $size = $row['numeric_precision']; @@ -275,11 +276,12 @@ protected function addColumns(Table $table, $oid) $name = $row['column_name']; $type = $row['data_type']; $default = $row['column_default']; - $isNullable = (true === $row['is_nullable'] || 'YES' === strtoupper($row['is_nullable'])); + $isNullable = ($row['is_nullable'] === true || strtoupper($row['is_nullable']) === 'YES'); // Check to ensure that this column isn't an array data type - if ('ARRAY' === $type) { + if ($type === 'ARRAY') { $this->warn(sprintf('Array datatypes are not currently supported [%s.%s]', $table->getName(), $name)); + continue; } @@ -288,7 +290,7 @@ protected function addColumns(Table $table, $oid) // if column has a default if ((strlen(trim($default)) > 0)) { if (!preg_match('/^nextval\(/', $default)) { - $strDefault= preg_replace('/::[\W\D]*/', '', $default); + $strDefault = preg_replace('/::[\W\D]*/', '', $default); } else { $autoincrement = true; $default = null; @@ -300,14 +302,14 @@ protected function addColumns(Table $table, $oid) $propelType = $this->getMappedPropelType($type); if (!$propelType) { $propelType = Column::DEFAULT_TYPE; - $this->warn('Column [' . $table->getName() . '.' . $name. '] has a column type ('.$type.') that Propel does not support.'); + $this->warn('Column [' . $table->getName() . '.' . $name . '] has a column type (' . $type . ') that Propel does not support.'); } if (isset(static::$defaultTypeSizes[$type]) && $size == static::$defaultTypeSizes[$type]) { $size = null; } - if ('SERIAL' === substr(strtoupper($type), 0, 6)) { + if (substr(strtoupper($type), 0, 6) === 'SERIAL') { $autoincrement = true; $default = null; } @@ -320,7 +322,7 @@ protected function addColumns(Table $table, $oid) $column->getDomain()->replaceScale($scale); } - if (null !== $default) { + if ($default !== null) { if ($this->isColumnDefaultExpression($default)) { $defaultType = ColumnDefaultValue::TYPE_EXPR; } else { @@ -344,7 +346,7 @@ protected function addColumns(Table $table, $oid) */ protected function isColumnDefaultExpression($default) { - $containsFunctionCall = "'" !== substr($default, 0, 1) && strpos($default, '('); + $containsFunctionCall = substr($default, 0, 1) !== "'" && strpos($default, '('); if ($containsFunctionCall) { return true; @@ -352,7 +354,7 @@ protected function isColumnDefaultExpression($default) $defaultColumnValueExpressions = [ 'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP', - 'LOCALTIMESTAMP' => 'LOCALTIMESTAMP' + 'LOCALTIMESTAMP' => 'LOCALTIMESTAMP', ]; if (isset($defaultColumnValueExpressions[strtoupper($default)])) { @@ -364,6 +366,7 @@ protected function isColumnDefaultExpression($default) /** * Load foreign keys for this table. + * * @return void */ protected function addForeignKeys(Table $table, $oid) @@ -395,8 +398,7 @@ protected function addForeignKeys(Table $table, $oid) $stmt->execute(); $foreignKeys = []; - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $name = $row['conname']; $localTable = $row['fktab']; $localColumns = explode(',', trim($row['fkcols'], '{}')); @@ -407,45 +409,55 @@ protected function addForeignKeys(Table $table, $oid) switch ($row['confupdtype']) { case 'c': $onupdate = ForeignKey::CASCADE; + break; case 'd': $onupdate = ForeignKey::SETDEFAULT; + break; case 'n': $onupdate = ForeignKey::SETNULL; + break; case 'r': $onupdate = ForeignKey::RESTRICT; + break; default: case 'a': // NOACTION is the postgresql default $onupdate = ForeignKey::NONE; + break; } // On Delete switch ($row['confdeltype']) { case 'c': $ondelete = ForeignKey::CASCADE; + break; case 'd': $ondelete = ForeignKey::SETDEFAULT; + break; case 'n': $ondelete = ForeignKey::SETNULL; + break; case 'r': $ondelete = ForeignKey::RESTRICT; + break; default: case 'a': // NOACTION is the postgresql default $ondelete = ForeignKey::NONE; + break; } $foreignTable = $database->getTable($foreignTableName); - $localTable = $database->getTable($localTable); + $localTable = $database->getTable($localTable); if (!$foreignTable) { continue; @@ -475,6 +487,7 @@ protected function addForeignKeys(Table $table, $oid) /** * Load indexes for this table + * * @return void */ protected function addIndexes(Table $table, $oid) @@ -499,7 +512,7 @@ protected function addIndexes(Table $table, $oid) $indexes = []; - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $name = $row['idxname']; $unique = (in_array($row['indisunique'], ['t', true, 1, '1']) ? true : false); @@ -517,13 +530,12 @@ protected function addIndexes(Table $table, $oid) $stmt2->bindValue(2, $intColNum); $stmt2->execute(); - $row2 = $stmt2->fetch(\PDO::FETCH_ASSOC); + $row2 = $stmt2->fetch(PDO::FETCH_ASSOC); $indexes[$name]->setTable($table); $indexes[$name]->addColumn([ - "name" => $row2['attname'] + 'name' => $row2['attname'], ]); - } } @@ -538,11 +550,11 @@ protected function addIndexes(Table $table, $oid) /** * Loads the primary key for this table. + * * @return void */ protected function addPrimaryKey(Table $table, $oid) { - $stmt = $this->dbh->prepare("SELECT DISTINCT ON(cls.relname) cls.relname as idxname, @@ -557,7 +569,7 @@ protected function addPrimaryKey(Table $table, $oid) // Loop through the returned results, grouping the same key_name together // adding each column for that key. - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $arrColumns = explode(' ', $row['indkey']); foreach ($arrColumns as $intColNum) { $stmt2 = $this->dbh->prepare("SELECT a.attname @@ -568,7 +580,7 @@ protected function addPrimaryKey(Table $table, $oid) $stmt2->bindValue(2, $intColNum); $stmt2->execute(); - $row2 = $stmt2->fetch(\PDO::FETCH_ASSOC); + $row2 = $stmt2->fetch(PDO::FETCH_ASSOC); if (!$table->getColumn($row2['attname'])) { continue; } @@ -580,7 +592,8 @@ protected function addPrimaryKey(Table $table, $oid) /** * Adds the sequences for this database. * - * @param Database $database + * @param \Propel\Generator\Model\Database $database + * * @return void */ protected function addSequences(Database $database) @@ -611,7 +624,7 @@ protected function addSequences(Database $database) "); $stmt->execute($params); - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $name = $row['nspname'] . '.' . $row['relname']; $database->addSequence($name); } diff --git a/src/Propel/Generator/Reverse/SchemaParserInterface.php b/src/Propel/Generator/Reverse/SchemaParserInterface.php index 9457e02953..52b66ae9a6 100644 --- a/src/Propel/Generator/Reverse/SchemaParserInterface.php +++ b/src/Propel/Generator/Reverse/SchemaParserInterface.php @@ -12,7 +12,6 @@ use Propel\Generator\Config\GeneratorConfigInterface; use Propel\Generator\Model\Database; -use Propel\Generator\Model\Table; use Propel\Runtime\Connection\ConnectionInterface; /** @@ -24,26 +23,28 @@ interface SchemaParserInterface { /** * Gets the database connection. - * @return ConnectionInterface + * + * @return \Propel\Runtime\Connection\ConnectionInterface */ public function getConnection(); /** * Sets the database connection. * - * @param ConnectionInterface $dbh + * @param \Propel\Runtime\Connection\ConnectionInterface $dbh */ public function setConnection(ConnectionInterface $dbh); /** * Sets the GeneratorConfig to use in the parsing. * - * @param GeneratorConfigInterface $config + * @param \Propel\Generator\Config\GeneratorConfigInterface $config */ public function setGeneratorConfig(GeneratorConfigInterface $config); /** * Gets array of warning messages. + * * @return string[] */ public function getWarnings(); @@ -61,9 +62,10 @@ public function setPlatform($platform); /** * Parse the schema and populate passed-in Database model object. * - * @param Database $database - * @param Table[] $additionalTables additional tables to parse and add to $database - * @return int number of generated tables + * @param \Propel\Generator\Model\Database $database + * @param \Propel\Generator\Model\Table[] $additionalTables additional tables to parse and add to $database + * + * @return int number of generated tables */ public function parse(Database $database, array $additionalTables = []); } diff --git a/src/Propel/Generator/Reverse/SqliteSchemaParser.php b/src/Propel/Generator/Reverse/SqliteSchemaParser.php index 85c8217d38..1a05ce8e8f 100644 --- a/src/Propel/Generator/Reverse/SqliteSchemaParser.php +++ b/src/Propel/Generator/Reverse/SqliteSchemaParser.php @@ -10,13 +10,14 @@ namespace Propel\Generator\Reverse; +use PDO; use Propel\Generator\Model\Column; use Propel\Generator\Model\ColumnDefaultValue; use Propel\Generator\Model\Database; use Propel\Generator\Model\ForeignKey; use Propel\Generator\Model\Index; -use Propel\Generator\Model\Table; use Propel\Generator\Model\PropelTypes; +use Propel\Generator\Model\Table; use Propel\Generator\Model\Unique; /** @@ -37,35 +38,35 @@ class SqliteSchemaParser extends AbstractSchemaParser * @var string[] */ private static $sqliteTypeMap = [ - 'tinyint' => PropelTypes::TINYINT, - 'smallint' => PropelTypes::SMALLINT, - 'mediumint' => PropelTypes::SMALLINT, - 'int' => PropelTypes::INTEGER, - 'integer' => PropelTypes::INTEGER, - 'bigint' => PropelTypes::BIGINT, - 'int24' => PropelTypes::BIGINT, - 'real' => PropelTypes::REAL, - 'float' => PropelTypes::FLOAT, - 'decimal' => PropelTypes::DECIMAL, - 'numeric' => PropelTypes::NUMERIC, - 'double' => PropelTypes::DOUBLE, - 'char' => PropelTypes::CHAR, - 'varchar' => PropelTypes::VARCHAR, - 'date' => PropelTypes::DATE, - 'time' => PropelTypes::TIME, - 'year' => PropelTypes::INTEGER, - 'datetime' => PropelTypes::DATE, - 'timestamp' => PropelTypes::TIMESTAMP, - 'tinyblob' => PropelTypes::BINARY, - 'blob' => PropelTypes::BLOB, + 'tinyint' => PropelTypes::TINYINT, + 'smallint' => PropelTypes::SMALLINT, + 'mediumint' => PropelTypes::SMALLINT, + 'int' => PropelTypes::INTEGER, + 'integer' => PropelTypes::INTEGER, + 'bigint' => PropelTypes::BIGINT, + 'int24' => PropelTypes::BIGINT, + 'real' => PropelTypes::REAL, + 'float' => PropelTypes::FLOAT, + 'decimal' => PropelTypes::DECIMAL, + 'numeric' => PropelTypes::NUMERIC, + 'double' => PropelTypes::DOUBLE, + 'char' => PropelTypes::CHAR, + 'varchar' => PropelTypes::VARCHAR, + 'date' => PropelTypes::DATE, + 'time' => PropelTypes::TIME, + 'year' => PropelTypes::INTEGER, + 'datetime' => PropelTypes::DATE, + 'timestamp' => PropelTypes::TIMESTAMP, + 'tinyblob' => PropelTypes::BINARY, + 'blob' => PropelTypes::BLOB, 'mediumblob' => PropelTypes::VARBINARY, - 'longblob' => PropelTypes::LONGVARBINARY, - 'longtext' => PropelTypes::CLOB, - 'tinytext' => PropelTypes::VARCHAR, + 'longblob' => PropelTypes::LONGVARBINARY, + 'longtext' => PropelTypes::CLOB, + 'tinytext' => PropelTypes::VARCHAR, 'mediumtext' => PropelTypes::LONGVARCHAR, - 'text' => PropelTypes::LONGVARCHAR, - 'enum' => PropelTypes::CHAR, - 'set' => PropelTypes::CHAR, + 'text' => PropelTypes::LONGVARCHAR, + 'enum' => PropelTypes::CHAR, + 'set' => PropelTypes::CHAR, ]; /** @@ -80,7 +81,7 @@ protected function getTypeMapping() /** * @param \Propel\Generator\Model\Database $database - * @param Table[] $additionalTables + * @param \Propel\Generator\Model\Table[] $additionalTables * * @return int */ @@ -116,7 +117,7 @@ public function parse(Database $database, array $additionalTables = []) * * @return void */ - protected function parseTables(Database $database, Table $filterTable = null) + protected function parseTables(Database $database, ?Table $filterTable = null) { $sql = " SELECT name @@ -137,7 +138,7 @@ protected function parseTables(Database $database, Table $filterTable = null) $filter = sprintf(" AND name LIKE '%s§%%'", $schema); } $filter .= sprintf(" AND (name = '%s' OR name LIKE '%%§%1\$s')", $filterTable->getCommonName()); - } else if ($schema = $database->getSchema()) { + } elseif ($schema = $database->getSchema()) { $filter = sprintf(" AND name LIKE '%s§%%'", $schema); } @@ -150,11 +151,11 @@ protected function parseTables(Database $database, Table $filterTable = null) $tableName = $row[0]; $tableSchema = ''; - if ('sqlite_' === substr($tableName, 0, 7)) { + if (substr($tableName, 0, 7) === 'sqlite_') { continue; } - if (false !== ($pos = strpos($tableName, '§'))) { + if (($pos = strpos($tableName, '§')) !== false) { $tableSchema = substr($tableName, 0, $pos); $tableName = substr($tableName, $pos + 2); } @@ -182,7 +183,8 @@ protected function parseTables(Database $database, Table $filterTable = null) /** * Adds Columns to the specified table. * - * @param Table $table The Table model class to add columns to. + * @param \Propel\Generator\Model\Table $table The Table model class to add columns to. + * * @return void */ protected function addColumns(Table $table) @@ -192,7 +194,7 @@ protected function addColumns(Table $table) /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query("PRAGMA table_info('$tableName')"); - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $name = $row['name']; $fulltype = $row['type']; @@ -216,7 +218,7 @@ protected function addColumns(Table $table) if (!$propelType) { $propelType = Column::DEFAULT_TYPE; - $this->warn('Column [' . $table->getName() . '.' . $name. '] has a column type ('.$type.') that Propel does not support.'); + $this->warn('Column [' . $table->getName() . '.' . $name . '] has a column type (' . $type . ') that Propel does not support.'); } $column = new Column($name); @@ -227,12 +229,12 @@ protected function addColumns(Table $table) $column->getDomain()->replaceSize($size); $column->getDomain()->replaceScale($scale); - if (null !== $default) { - if ("'" !== substr($default, 0, 1) && strpos($default, '(')) { + if ($default !== null) { + if (substr($default, 0, 1) !== "'" && strpos($default, '(')) { $defaultType = ColumnDefaultValue::TYPE_EXPR; - if ('datetime(CURRENT_TIMESTAMP, \'localtime\')' === $default) { + if ($default === 'datetime(CURRENT_TIMESTAMP, \'localtime\')') { $default = 'CURRENT_TIMESTAMP'; - } + } } else { $defaultType = ColumnDefaultValue::TYPE_VALUE; $default = str_replace("'", '', $default); @@ -242,7 +244,7 @@ protected function addColumns(Table $table) $column->setNotNull($notNull); - if (0 < $row['pk']+0) { + if (0 < $row['pk'] + 0) { $column->setPrimaryKey(true); } @@ -258,7 +260,7 @@ protected function addColumns(Table $table) sql LIKE "%AUTOINCREMENT%" '); $autoIncrementStmt->execute([$table->getName()]); - $autoincrementRow = $autoIncrementStmt->fetch(\PDO::FETCH_ASSOC); + $autoincrementRow = $autoIncrementStmt->fetch(PDO::FETCH_ASSOC); if ($autoincrementRow && $autoincrementRow['tbl_name'] == $table->getName()) { $column->setAutoIncrement(true); } @@ -281,17 +283,17 @@ protected function addForeignKeys(Table $table) $stmt = $this->dbh->query('PRAGMA foreign_key_list("' . $table->getName() . '")'); $lastId = null; - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { if ($lastId !== $row['id']) { $fk = new ForeignKey(); $onDelete = $row['on_delete']; - if ($onDelete && 'NO ACTION' !== $onDelete) { + if ($onDelete && $onDelete !== 'NO ACTION') { $fk->setOnDelete($onDelete); } $onUpdate = $row['on_update']; - if ($onUpdate && 'NO ACTION' !== $onUpdate) { + if ($onUpdate && $onUpdate !== 'NO ACTION') { $fk->setOnUpdate($onUpdate); } @@ -319,6 +321,7 @@ protected function addForeignKeys(Table $table) /** * Load indexes for this table + * * @return void */ protected function addIndexes(Table $table) @@ -326,24 +329,24 @@ protected function addIndexes(Table $table) /** @var \PDOStatement $stmt */ $stmt = $this->dbh->query('PRAGMA index_list("' . $table->getName() . '")'); - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $name = $row['name']; $internalName = $name; - if (0 === strpos($name, 'sqlite_autoindex')) { + if (strpos($name, 'sqlite_autoindex') === 0) { $internalName = ''; } $index = $row['unique'] ? new Unique($internalName) : new Index($internalName); /** @var \PDOStatement $stmt2 */ - $stmt2 = $this->dbh->query("PRAGMA index_info('".$name."')"); - while ($row2 = $stmt2->fetch(\PDO::FETCH_ASSOC)) { + $stmt2 = $this->dbh->query("PRAGMA index_info('" . $name . "')"); + while ($row2 = $stmt2->fetch(PDO::FETCH_ASSOC)) { $colname = $row2['name']; $index->addColumn($table->getColumn($colname)); } - if (1 === count($table->getPrimaryKey()) && 1 === count($index->getColumns())) { + if (count($table->getPrimaryKey()) === 1 && count($index->getColumns()) === 1) { // exclude the primary unique index, since it's autogenerated by sqlite if ($table->getPrimaryKey()[0]->getName() === $index->getColumns()[0]) { continue; diff --git a/src/Propel/Generator/Schema/Dumper/DumperInterface.php b/src/Propel/Generator/Schema/Dumper/DumperInterface.php index 2cc8e00463..51566c4ff7 100644 --- a/src/Propel/Generator/Schema/Dumper/DumperInterface.php +++ b/src/Propel/Generator/Schema/Dumper/DumperInterface.php @@ -1,5 +1,13 @@ formatOutput = true; } @@ -56,8 +58,9 @@ public function __construct(\DOMDocument $document = null) /** * Dumps a single Database model into an XML formatted version. * - * @param Database $database The database model - * @return string The dumped XML formatted output + * @param \Propel\Generator\Model\Database $database The database model + * + * @return string The dumped XML formatted output */ public function dump(Database $database) { @@ -69,8 +72,9 @@ public function dump(Database $database) /** * Dumps a single Schema model into an XML formatted version. * - * @param Schema $schema The schema object - * @param boolean $doFinalInitialization Whether or not to validate the schema + * @param \Propel\Generator\Model\Schema $schema The schema object + * @param bool $doFinalInitialization Whether or not to validate the schema + * * @return string */ public function dumpSchema(Schema $schema, $doFinalInitialization = true) @@ -87,11 +91,12 @@ public function dumpSchema(Schema $schema, $doFinalInitialization = true) /** * Appends the generated XML node to its parent node. * - * @param Database $database The Database model instance + * @param \Propel\Generator\Model\Database $database The Database model instance * @param \DOMNode $parentNode The parent DOMNode object + * * @return void */ - private function appendDatabaseNode(Database $database, \DOMNode $parentNode) + private function appendDatabaseNode(Database $database, DOMNode $parentNode) { /** @var \DOMElement $databaseNode */ $databaseNode = $parentNode->appendChild($this->document->createElement('database')); @@ -133,7 +138,7 @@ private function appendDatabaseNode(Database $database, \DOMNode $parentNode) } $defaultStringFormat = $database->getDefaultStringFormat(); - if (Database::DEFAULT_STRING_FORMAT !== $defaultStringFormat) { + if ($defaultStringFormat !== Database::DEFAULT_STRING_FORMAT) { $databaseNode->setAttribute('defaultStringFormat', $defaultStringFormat); } @@ -170,11 +175,12 @@ private function appendDatabaseNode(Database $database, \DOMNode $parentNode) /** * Appends the generated XML node to its parent node. * - * @param VendorInfo $vendorInfo The VendorInfo model instance - * @param \DOMNode $parentNode The parent DOMNode object + * @param \Propel\Generator\Model\VendorInfo $vendorInfo The VendorInfo model instance + * @param \DOMNode $parentNode The parent DOMNode object + * * @return void */ - private function appendVendorInformationNode(VendorInfo $vendorInfo, \DOMNode $parentNode) + private function appendVendorInformationNode(VendorInfo $vendorInfo, DOMNode $parentNode) { /** @var \DOMElement $vendorNode */ $vendorNode = $parentNode->appendChild($this->document->createElement('vendor')); @@ -191,11 +197,12 @@ private function appendVendorInformationNode(VendorInfo $vendorInfo, \DOMNode $p /** * Appends the generated
XML node to its parent node. * - * @param Table $table The Table model instance + * @param \Propel\Generator\Model\Table $table The Table model instance * @param \DOMNode $parentNode The parent DOMNode object + * * @return void */ - private function appendTableNode(Table $table, \DOMNode $parentNode) + private function appendTableNode(Table $table, DOMNode $parentNode) { /** @var \DOMElement $tableNode */ $tableNode = $parentNode->appendChild($this->document->createElement('table')); @@ -207,7 +214,7 @@ private function appendTableNode(Table $table, \DOMNode $parentNode) $tableNode->setAttribute('schema', $schema); } - if (IdMethod::NO_ID_METHOD !== ($idMethod = $table->getIdMethod())) { + if (($idMethod = $table->getIdMethod()) !== IdMethod::NO_ID_METHOD) { $tableNode->setAttribute('idMethod', $idMethod); } @@ -265,7 +272,7 @@ private function appendTableNode(Table $table, \DOMNode $parentNode) $tableNode->setAttribute('reloadOnUpdate', 'true'); } - if (null !== ($referenceOnly = $table->isForReferenceOnly())) { + if (($referenceOnly = $table->isForReferenceOnly()) !== null) { $tableNode->setAttribute('forReferenceOnly', $referenceOnly ? 'true' : 'false'); } @@ -278,7 +285,7 @@ private function appendTableNode(Table $table, \DOMNode $parentNode) } $defaultStringFormat = $table->getDefaultStringFormat(); - if (Table::DEFAULT_STRING_FORMAT !== $defaultStringFormat) { + if ($defaultStringFormat !== Table::DEFAULT_STRING_FORMAT) { $tableNode->setAttribute('defaultStringFormat', $defaultStringFormat); } @@ -324,11 +331,12 @@ private function appendTableNode(Table $table, \DOMNode $parentNode) /** * Appends the generated XML node to its parent node. * - * @param Behavior $behavior The Behavior model instance + * @param \Propel\Generator\Model\Behavior $behavior The Behavior model instance * @param \DOMNode $parentNode The parent DOMNode object + * * @return void */ - private function appendBehaviorNode(Behavior $behavior, \DOMNode $parentNode) + private function appendBehaviorNode(Behavior $behavior, DOMNode $parentNode) { /** @var \DOMElement $behaviorNode */ $behaviorNode = $parentNode->appendChild($this->document->createElement('behavior')); @@ -348,11 +356,12 @@ private function appendBehaviorNode(Behavior $behavior, \DOMNode $parentNode) /** * Appends the generated XML node to its parent node. * - * @param Column $column The Column model instance + * @param \Propel\Generator\Model\Column $column The Column model instance * @param \DOMNode $parentNode The parent DOMNode object + * * @return void */ - private function appendColumnNode(Column $column, \DOMNode $parentNode) + private function appendColumnNode(Column $column, DOMNode $parentNode) { /** @var \DOMElement $columnNode */ $columnNode = $parentNode->appendChild($this->document->createElement('column')); @@ -369,7 +378,7 @@ private function appendColumnNode(Column $column, \DOMNode $parentNode) $columnNode->setAttribute('size', (string)$size); } - if (null !== ($scale = $domain->getScale())) { + if (($scale = $domain->getScale()) !== null) { $columnNode->setAttribute('scale', (string)$scale); } @@ -422,11 +431,12 @@ private function appendColumnNode(Column $column, \DOMNode $parentNode) /** * Appends the generated XML node to its parent node. * - * @param Inheritance $inheritance The Inheritance model instance - * @param \DOMNode $parentNode The parent DOMNode object + * @param \Propel\Generator\Model\Inheritance $inheritance The Inheritance model instance + * @param \DOMNode $parentNode The parent DOMNode object + * * @return void */ - private function appendInheritanceNode(Inheritance $inheritance, \DOMNode $parentNode) + private function appendInheritanceNode(Inheritance $inheritance, DOMNode $parentNode) { /** @var \DOMElement $inheritanceNode */ $inheritanceNode = $parentNode->appendChild($this->document->createElement('inheritance')); @@ -441,11 +451,12 @@ private function appendInheritanceNode(Inheritance $inheritance, \DOMNode $paren /** * Appends the generated XML node to its parent node. * - * @param ForeignKey $foreignKey The ForeignKey model instance - * @param \DOMNode $parentNode The parent DOMNode object + * @param \Propel\Generator\Model\ForeignKey $foreignKey The ForeignKey model instance + * @param \DOMNode $parentNode The parent DOMNode object + * * @return void */ - private function appendForeignKeyNode(ForeignKey $foreignKey, \DOMNode $parentNode) + private function appendForeignKeyNode(ForeignKey $foreignKey, DOMNode $parentNode) { /** @var \DOMElement $foreignKeyNode */ $foreignKeyNode = $parentNode->appendChild($this->document->createElement('foreign-key')); @@ -491,11 +502,12 @@ private function appendForeignKeyNode(ForeignKey $foreignKey, \DOMNode $parentNo /** * Appends the generated XML node to its parent node. * - * @param IdMethodParameter $parameter The IdMethodParameter model instance - * @param \DOMNode $parentNode The parent DOMNode object + * @param \Propel\Generator\Model\IdMethodParameter $parameter The IdMethodParameter model instance + * @param \DOMNode $parentNode The parent DOMNode object + * * @return void */ - private function appendIdMethodParameterNode(IdMethodParameter $parameter, \DOMNode $parentNode) + private function appendIdMethodParameterNode(IdMethodParameter $parameter, DOMNode $parentNode) { /** @var \DOMElement $idMethodParameterNode */ $idMethodParameterNode = $parentNode->appendChild($this->document->createElement('id-method-parameter')); @@ -508,11 +520,12 @@ private function appendIdMethodParameterNode(IdMethodParameter $parameter, \DOMN /** * Appends the generated XML node to its parent node. * - * @param Index $index The Index model instance + * @param \Propel\Generator\Model\Index $index The Index model instance * @param \DOMNode $parentNode The parent DOMNode object + * * @return void */ - private function appendIndexNode(Index $index, \DOMNode $parentNode) + private function appendIndexNode(Index $index, DOMNode $parentNode) { $this->appendGenericIndexNode('index', $index, $parentNode); } @@ -520,11 +533,12 @@ private function appendIndexNode(Index $index, \DOMNode $parentNode) /** * Appends the generated XML node to its parent node. * - * @param Unique $index The Unique model instance + * @param \Propel\Generator\Model\Unique $index The Unique model instance * @param \DOMNode $parentNode The parent DOMNode object + * * @return void */ - private function appendUniqueIndexNode(Unique $index, \DOMNode $parentNode) + private function appendUniqueIndexNode(Unique $index, DOMNode $parentNode) { $this->appendGenericIndexNode('unique', $index, $parentNode); } @@ -532,19 +546,20 @@ private function appendUniqueIndexNode(Unique $index, \DOMNode $parentNode) /** * Appends a generice or XML node to its parent node. * - * @param string $nodeType The node type (index or unique) - * @param Index $index The Index model instance + * @param string $nodeType The node type (index or unique) + * @param \Propel\Generator\Model\Index $index The Index model instance * @param \DOMNode $parentNode The parent DOMNode object + * * @return void */ - private function appendGenericIndexNode($nodeType, Index $index, \DOMNode $parentNode) + private function appendGenericIndexNode($nodeType, Index $index, DOMNode $parentNode) { /** @var \DOMElement $indexNode */ $indexNode = $parentNode->appendChild($this->document->createElement($nodeType)); $indexNode->setAttribute('name', $index->getName()); foreach ($index->getColumns() as $columnName) { - $indexColumnNode = $indexNode->appendChild($this->document->createElement($nodeType.'-column')); + $indexColumnNode = $indexNode->appendChild($this->document->createElement($nodeType . '-column')); $indexColumnNode->setAttribute('name', $columnName); if ($size = $index->getColumnSize($columnName)) { diff --git a/src/Propel/Generator/Util/BehaviorLocator.php b/src/Propel/Generator/Util/BehaviorLocator.php index 0ba0ca359d..28a5e6765d 100644 --- a/src/Propel/Generator/Util/BehaviorLocator.php +++ b/src/Propel/Generator/Util/BehaviorLocator.php @@ -1,43 +1,49 @@ generatorConfig = $config; - if (null !== $config) { + if ($config !== null) { $this->composerDir = $config->get()['paths']['composerDir']; } } @@ -46,11 +52,12 @@ public function __construct(GeneratorConfigInterface $config = null) * Searches a composer file * * @param string $fileName - * @return SplFileInfo|null The found composer file or null if composer file isn't found + * + * @return \Symfony\Component\Finder\SplFileInfo|null The found composer file or null if composer file isn't found */ private function findComposerFile($fileName) { - if (null !== $this->composerDir) { + if ($this->composerDir !== null) { $filePath = $this->composerDir . '/' . $fileName; if (file_exists($filePath)) { @@ -73,7 +80,7 @@ private function findComposerFile($fileName) /** * Searches the composer.lock file * - * @return SplFileInfo|null The found composer.lock or null if composer.lock isn't found + * @return \Symfony\Component\Finder\SplFileInfo|null The found composer.lock or null if composer.lock isn't found */ private function findComposerLock() { @@ -83,7 +90,7 @@ private function findComposerLock() /** * Searches the composer.json file * - * @return SplFileInfo|null the found composer.json or null if composer.json isn't found + * @return \Symfony\Component\Finder\SplFileInfo|null the found composer.json or null if composer.json isn't found */ private function findComposerJson() { @@ -101,7 +108,7 @@ private function getSearchDirs(): array getcwd(), getcwd() . '/../', // cwd is a subfolder __DIR__ . '/../../../../../../../', // vendor/propel/propel - __DIR__ . '/../../../../' // propel development environment + __DIR__ . '/../../../../', // propel development environment ]; } @@ -112,11 +119,11 @@ private function getSearchDirs(): array */ public function getBehaviors() { - if (null === $this->behaviors) { + if ($this->behaviors === null) { // find behaviors in composer.lock file $lock = $this->findComposerLock(); - if (null === $lock) { + if ($lock === null) { $this->behaviors = []; } else { $this->behaviors = $this->loadBehaviors($lock); @@ -125,10 +132,10 @@ public function getBehaviors() // find behavior in composer.json (useful when developing a behavior) $json = $this->findComposerJson(); - if (null !== $json) { + if ($json !== null) { $behavior = $this->loadBehavior(json_decode($json->getContents(), true)); - if (null !== $behavior) { + if ($behavior !== null) { $this->behaviors[$behavior['name']] = $behavior; } } @@ -140,13 +147,15 @@ public function getBehaviors() /** * Returns the class name for a given behavior name * - * @param string $name The behavior name (e.g. timetampable) - * @throws BehaviorNotFoundException when the behavior cannot be found - * @return string the class name + * @param string $name The behavior name (e.g. timetampable) + * + * @throws \Propel\Generator\Exception\BehaviorNotFoundException when the behavior cannot be found + * + * @return string the class name */ public function getBehavior($name) { - if (false !== strpos($name, '\\')) { + if (strpos($name, '\\') !== false) { $class = $name; } else { $class = $this->getCoreBehavior($name); @@ -170,7 +179,8 @@ public function getBehavior($name) * Searches for the given behavior name in the Propel\Generator\Behavior namespace as * \Propel\Generator\Behavior\[Bname]\[Bname]Behavior * - * @param string $name The behavior name (ie: timestampable) + * @param string $name The behavior name (ie: timestampable) + * * @return string The behavior fully qualified class name */ private function getCoreBehavior($name) @@ -184,7 +194,7 @@ private function getCoreBehavior($name) /** * Finds all behaviors by parsing composer.lock file * - * @param SplFileInfo $composerLock + * @param \Symfony\Component\Finder\SplFileInfo $composerLock * * @return array */ @@ -198,7 +208,7 @@ private function loadBehaviors($composerLock) foreach ($json['packages'] as $package) { $behavior = $this->loadBehavior($package); - if (null !== $behavior) { + if ($behavior !== null) { $behaviors[$behavior['name']] = $behavior; } } @@ -210,14 +220,15 @@ private function loadBehaviors($composerLock) /** * Reads the propel behavior data from a given composer package * - * @param array $package - * @throws BuildException + * @param array $package + * + * @throws \Propel\Generator\Exception\BuildException + * * @return array|null Behavior data */ private function loadBehavior($package) { if (isset($package['type']) && $package['type'] == self::BEHAVIOR_PACKAGE_TYPE) { - // find propel behavior information if (isset($package['extra'])) { $extra = $package['extra']; @@ -226,7 +237,7 @@ private function loadBehavior($package) return [ 'name' => $extra['name'], 'class' => $extra['class'], - 'package' => $package['name'] + 'package' => $package['name'], ]; } diff --git a/src/Propel/Generator/Util/PhpParser.php b/src/Propel/Generator/Util/PhpParser.php index 507454d4e4..630e3406c1 100644 --- a/src/Propel/Generator/Util/PhpParser.php +++ b/src/Propel/Generator/Util/PhpParser.php @@ -18,6 +18,7 @@ /** * Service class for parsing PHP code strings and editing them + * * @example Basic usage: * * $script = file_get_contents($fileName); @@ -40,14 +41,14 @@ class PhpParser * * @var (string|false)[] */ - private $knownMethodCache = array(); + private $knownMethodCache = []; /** * Parser constructor * - * @param string $code PHP code to parse - * @param boolean $isAddPhp Whether the supplied code needs a supplementary 'knownMethodCache[$methodName] = false; + return false; } @@ -192,7 +197,7 @@ public function removeMethod($methodName) * Parse the code looking for a method definition, and replaces the code if found * * @param string $methodName The name of the method to find, e.g. 'getAuthor' - * @param string $newCode The code to use in place of the old method definition + * @param string $newCode The code to use in place of the old method definition * * @return mixed false if not found, or the method code string if found */ @@ -212,14 +217,14 @@ public function replaceMethod($methodName, $newCode) * Parse the code looking for a method definition, and adds the code after if found * * @param string $methodName The name of the method to find, e.g. 'getAuthor' - * @param string $newCode The code to add to the class + * @param string $newCode The code to add to the class * * @return string|false false if not found, or the method code string if found */ public function addMethodAfter($methodName, $newCode) { if ($methodCode = $this->findMethod($methodName)) { - $this->code = str_replace($methodCode, $methodCode. $newCode, $this->code); + $this->code = str_replace($methodCode, $methodCode . $newCode, $this->code); return $methodCode; } @@ -231,7 +236,7 @@ public function addMethodAfter($methodName, $newCode) * Parse the code looking for a method definition, and adds the code before if found * * @param string $methodName The name of the method to find, e.g. 'getAuthor' - * @param string $newCode The code to add to the class + * @param string $newCode The code to add to the class * * @return string|false false if not found, or the method code string if found */ diff --git a/src/Propel/Generator/Util/QuickBuilder.php b/src/Propel/Generator/Util/QuickBuilder.php index 19e8ce32bd..b15658c168 100644 --- a/src/Propel/Generator/Util/QuickBuilder.php +++ b/src/Propel/Generator/Util/QuickBuilder.php @@ -10,6 +10,9 @@ namespace Propel\Generator\Util; +use Exception; +use PDO; +use PDOStatement; use Propel\Generator\Builder\Util\SchemaReader; use Propel\Generator\Config\GeneratorConfigInterface; use Propel\Generator\Config\QuickGeneratorConfig; @@ -17,13 +20,11 @@ use Propel\Generator\Model\Database; use Propel\Generator\Model\Diff\DatabaseComparator; use Propel\Generator\Model\Table; -use Propel\Generator\Platform\PlatformInterface; use Propel\Generator\Platform\SqlitePlatform; -use Propel\Generator\Reverse\SchemaParserInterface; use Propel\Runtime\Adapter\Pdo\SqliteAdapter; -use Propel\Runtime\Connection\PdoConnection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Connection\ConnectionWrapper; +use Propel\Runtime\Connection\PdoConnection; use Propel\Runtime\Propel; class QuickBuilder @@ -43,22 +44,22 @@ class QuickBuilder protected $schemaName; /** - * @var PlatformInterface + * @var \Propel\Generator\Platform\PlatformInterface */ protected $platform; /** - * @var GeneratorConfigInterface + * @var \Propel\Generator\Config\GeneratorConfigInterface */ protected $config; /** - * @var Database + * @var \Propel\Generator\Model\Database */ protected $database; /** - * @var SchemaParserInterface + * @var \Propel\Generator\Reverse\SchemaParserInterface */ protected $parser; @@ -76,6 +77,7 @@ class QuickBuilder /** * @param string $schema + * * @return void */ public function setSchema($schema) @@ -93,6 +95,7 @@ public function getSchema() /** * @param string $schemaName + * * @return void */ public function setSchemaName($schemaName) @@ -110,6 +113,7 @@ public function getSchemaName() /** * @param \Propel\Generator\Reverse\SchemaParserInterface $parser + * * @return void */ public function setParser($parser) @@ -128,7 +132,8 @@ public function getParser() /** * Setter for the platform property * - * @param PlatformInterface $platform + * @param \Propel\Generator\Platform\PlatformInterface $platform + * * @return void */ public function setPlatform($platform) @@ -139,11 +144,11 @@ public function setPlatform($platform) /** * Getter for the platform property * - * @return PlatformInterface + * @return \Propel\Generator\Platform\PlatformInterface */ public function getPlatform() { - if (null === $this->platform) { + if ($this->platform === null) { $this->platform = new SqlitePlatform(); } @@ -155,7 +160,8 @@ public function getPlatform() /** * Setter for the config property * - * @param GeneratorConfigInterface $config + * @param \Propel\Generator\Config\GeneratorConfigInterface $config + * * @return void */ public function setConfig(GeneratorConfigInterface $config) @@ -166,11 +172,11 @@ public function setConfig(GeneratorConfigInterface $config) /** * Getter for the config property * - * @return GeneratorConfigInterface + * @return \Propel\Generator\Config\GeneratorConfigInterface */ public function getConfig() { - if (null === $this->config) { + if ($this->config === null) { $this->config = new QuickGeneratorConfig(); } @@ -179,7 +185,7 @@ public function getConfig() public static function buildSchema($schema, $dsn = null, $user = null, $pass = null, $adapter = null) { - $builder = new self; + $builder = new self(); $builder->setSchema($schema); return $builder->build($dsn, $user, $pass, $adapter); @@ -194,21 +200,21 @@ public static function buildSchema($schema, $dsn = null, $user = null, $pass = n * * @return \Propel\Runtime\Connection\ConnectionWrapper */ - public function build($dsn = null, $user = null, $pass = null, $adapter = null, array $classTargets = null) + public function build($dsn = null, $user = null, $pass = null, $adapter = null, ?array $classTargets = null) { - if (null === $dsn) { + if ($dsn === null) { $dsn = 'sqlite::memory:'; } - if (null === $adapter) { + if ($adapter === null) { $adapter = new SqliteAdapter(); } - if (null === $classTargets) { + if ($classTargets === null) { $classTargets = $this->classTargets; } $pdo = new PdoConnection($dsn, $user, $pass); $con = new ConnectionWrapper($pdo); - $con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING); - /** @var SqliteAdapter $adapter */ + $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); + /** @var \Propel\Runtime\Adapter\Pdo\SqliteAdapter $adapter */ $adapter->initConnection($con, []); $this->buildSQL($con); $this->buildClasses($classTargets); @@ -224,7 +230,7 @@ public function build($dsn = null, $user = null, $pass = null, $adapter = null, */ public function getDatabase() { - if (null === $this->database) { + if ($this->database === null) { $xtad = new SchemaReader($this->getPlatform()); $xtad->setGeneratorConfig($this->getConfig()); $appData = $xtad->parseString($this->schema); @@ -238,6 +244,7 @@ public function getDatabase() * @param \Propel\Runtime\Connection\ConnectionInterface $con * * @throws \Exception + * * @return int */ public function buildSQL(ConnectionInterface $con) @@ -251,12 +258,12 @@ public function buildSQL(ConnectionInterface $con) } try { $stmt = $con->prepare($statement); - if ($stmt instanceof \PDOStatement) { + if ($stmt instanceof PDOStatement) { // only execute if has no error $stmt->execute(); } - } catch (\Exception $e) { - throw new \Exception('SQL failed: ' . $statement, 0, $e); + } catch (Exception $e) { + throw new Exception('SQL failed: ' . $statement, 0, $e); } } @@ -267,6 +274,7 @@ public function buildSQL(ConnectionInterface $con) * @param \Propel\Runtime\Connection\ConnectionInterface $con * * @throws \Propel\Generator\Exception\BuildException + * * @return \Propel\Generator\Model\Database|null */ public function updateDB(ConnectionInterface $con) @@ -274,7 +282,7 @@ public function updateDB(ConnectionInterface $con) $database = $this->readConnectedDatabase(); $diff = DatabaseComparator::computeDiff($database, $this->database); - if (false === $diff) { + if ($diff === false) { return null; } /** @var \Propel\Generator\Platform\DefaultPlatform $platform */ @@ -286,9 +294,10 @@ public function updateDB(ConnectionInterface $con) try { $stmt = $con->prepare($statement); $stmt->execute(); - } catch (\Exception $e) { + } catch (Exception $e) { //echo $sql; //uncomment for better debugging - throw new BuildException(sprintf("Can not execute SQL: \n%s\nFrom database: \n%s\n\nTo database: \n%s\n\nDiff:\n%s", + throw new BuildException(sprintf( + "Can not execute SQL: \n%s\nFrom database: \n%s\n\nTo database: \n%s\n\nDiff:\n%s", $statement, $this->database, $database, @@ -301,7 +310,7 @@ public function updateDB(ConnectionInterface $con) } /** - * @return Database + * @return \Propel\Generator\Model\Database */ public function readConnectedDatabase() { @@ -335,7 +344,9 @@ public function getBuildName($classTargets = null) { $tables = []; foreach ($this->getDatabase()->getTables() as $table) { - if (count($tables) > 3) break; + if (count($tables) > 3) { + break; + } $tables[] = $table->getName(); } $name = implode('_', $tables); @@ -350,15 +361,16 @@ public function getBuildName($classTargets = null) /** * @param string[]|null $classTargets array('tablemap', 'object', 'query', 'objectstub', 'querystub') - * @param bool $separate pass true to get for each class a own file. better for debugging. + * @param bool $separate pass true to get for each class a own file. better for debugging. + * * @return void */ - public function buildClasses(array $classTargets = null, $separate = false) + public function buildClasses(?array $classTargets = null, $separate = false) { $classes = $classTargets === null ? ['tablemap', 'object', 'query', 'objectstub', 'querystub'] : $classTargets; $dirHash = substr(sha1(getcwd()), 0, 10); - $dir = sys_get_temp_dir() . "/propelQuickBuild-" . Propel::VERSION . "-$dirHash/"; + $dir = sys_get_temp_dir() . '/propelQuickBuild-' . Propel::VERSION . "-$dirHash/"; if (!is_dir($dir)) { mkdir($dir); @@ -392,7 +404,7 @@ public function buildClasses(array $classTargets = null, $separate = false) include($tempFile); } } else { - $tempFile = $dir . join('_', $allCodeName).'.php'; + $tempFile = $dir . implode('_', $allCodeName) . '.php'; file_put_contents($tempFile, "getDatabase()->getTables() as $table) { @@ -419,9 +431,9 @@ public function getClasses(array $classTargets = null) * * @return string */ - public function getClassesForTable(Table $table, array $classTargets = null) + public function getClassesForTable(Table $table, ?array $classTargets = null) { - if (null === $classTargets) { + if ($classTargets === null) { $classTargets = $this->classTargets; } @@ -482,7 +494,7 @@ public function getClassesForTable(Table $table, array $classTargets = null) */ public static function debugClassesForTable($schema, $tableName) { - $builder = new self; + $builder = new self(); $builder->setSchema($schema); foreach ($builder->getDatabase()->getTables() as $table) { if ($table->getName() == $tableName) { @@ -513,7 +525,7 @@ public function fixNamespaceDeclarations($source) } elseif (in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) { // strip comments $output .= $token[1]; - } elseif (T_NAMESPACE === $token[0]) { + } elseif ($token[0] === T_NAMESPACE) { if ($inNamespace) { $output .= "}\n"; } @@ -523,7 +535,7 @@ public function fixNamespaceDeclarations($source) while (($t = $tokens[++$i]) && is_array($t) && in_array($t[0], [T_WHITESPACE, T_NS_SEPARATOR, T_STRING])) { $output .= $t[1]; } - if (is_string($t) && '{' === $t) { + if (is_string($t) && $t === '{') { $inNamespace = false; --$i; } else { @@ -545,18 +557,19 @@ public function fixNamespaceDeclarations($source) /** * Prevent generated class without namespace to fail. * - * @param string $code + * @param string $code + * * @return string */ protected function forceNamespace($code) { - if (0 === preg_match('/\nnamespace/', $code)) { - - $use = array_filter(explode(PHP_EOL, $code), function($string) { + if (preg_match('/\nnamespace/', $code) === 0) { + $use = array_filter(explode(PHP_EOL, $code), function ($string) { return substr($string, 0, 5) === 'use \\'; }); $code = str_replace($use, '', $code); + return "\nnamespace\n{\n" . $code . "\n}\n"; } @@ -564,7 +577,7 @@ protected function forceNamespace($code) } /** - * @return boolean + * @return bool */ public function isIdentifierQuotingEnabled() { @@ -572,12 +585,12 @@ public function isIdentifierQuotingEnabled() } /** - * @param boolean $identifierQuoting + * @param bool $identifierQuoting + * * @return void */ public function setIdentifierQuoting($identifierQuoting) { $this->identifierQuoting = $identifierQuoting; } - } diff --git a/src/Propel/Generator/Util/SchemaValidator.php b/src/Propel/Generator/Util/SchemaValidator.php index 2420856b90..9390a2658d 100644 --- a/src/Propel/Generator/Util/SchemaValidator.php +++ b/src/Propel/Generator/Util/SchemaValidator.php @@ -10,8 +10,8 @@ namespace Propel\Generator\Util; -use Propel\Generator\Model\Schema; use Propel\Generator\Model\Database; +use Propel\Generator\Model\Schema; use Propel\Generator\Model\Table; /** @@ -30,16 +30,28 @@ */ class SchemaValidator { + /** + * @var \Propel\Generator\Model\Schema + */ protected $schema; + + /** + * @var string[] + */ protected $errors = []; + /** + * SchemaValidator constructor. + * + * @param \Propel\Generator\Model\Schema $schema + */ public function __construct(Schema $schema) { $this->schema = $schema; } /** - * @return boolean true if valid, false otherwise + * @return bool true if valid, false otherwise */ public function validate() { @@ -47,7 +59,7 @@ public function validate() $this->validateDatabaseTables($database); } - return 0 === count($this->errors); + return count($this->errors) === 0; } /** @@ -106,7 +118,7 @@ protected function validateTableColumns(Table $table) if (in_array($column->getPhpName(), $phpNames)) { $this->errors[] = sprintf('Column "%s" declares a phpName already used in table "%s"', $column->getName(), $table->getName()); } - $phpNames[]= $column->getPhpName(); + $phpNames[] = $column->getPhpName(); } } diff --git a/src/Propel/Generator/Util/SqlParser.php b/src/Propel/Generator/Util/SqlParser.php index 272abc2a5a..fe2039fd65 100644 --- a/src/Propel/Generator/Util/SqlParser.php +++ b/src/Propel/Generator/Util/SqlParser.php @@ -10,7 +10,8 @@ namespace Propel\Generator\Util; -use \Propel\Runtime\Connection\ConnectionInterface; +use PDOStatement; +use Propel\Runtime\Connection\ConnectionInterface; /** * Service class for parsing a large SQL string into an array of SQL statements @@ -20,10 +21,13 @@ class SqlParser { protected $delimiter = ';'; + protected $delimiterLength = 1; protected $sql = ''; + protected $len = 0; + protected $pos = 0; /** @@ -31,6 +35,7 @@ class SqlParser * Also resets the parsing cursor (see getNextStatement) * * @param string $sql The SQL string to parse + * * @return void */ public function setSQL($sql) @@ -54,10 +59,10 @@ public function getSQL() * Execute a list of DDL statements based on a string * Does not use transactions since they are not supported in DDL statements * - * @param string $input The SQL statements - * @param ConnectionInterface $connection a connection object + * @param string $input The SQL statements + * @param \Propel\Runtime\Connection\ConnectionInterface $connection a connection object * - * @return integer the number of executed statements + * @return int the number of executed statements */ public static function executeString($input, ConnectionInterface $connection) { @@ -68,10 +73,10 @@ public static function executeString($input, ConnectionInterface $connection) * Execute a list of DDL statements based on the path to the SQL file * Does not use transactions since they are not supported in DDL statements * - * @param string $file the path to the SQL file - * @param ConnectionInterface $connection a connection object + * @param string $file the path to the SQL file + * @param \Propel\Runtime\Connection\ConnectionInterface $connection a connection object * - * @return integer the number of executed statements + * @return int the number of executed statements */ public static function executeFile($file, ConnectionInterface $connection) { @@ -82,10 +87,10 @@ public static function executeFile($file, ConnectionInterface $connection) * Execute a list of DDL statements based on an array * Does not use transactions since they are not supported in DDL statements * - * @param array $statements a list of SQL statements - * @param ConnectionInterface $connection a connection object + * @param array $statements a list of SQL statements + * @param \Propel\Runtime\Connection\ConnectionInterface $connection a connection object * - * @return integer the number of executed statements + * @return int the number of executed statements */ protected static function executeStatements($statements, ConnectionInterface $connection) { @@ -93,7 +98,7 @@ protected static function executeStatements($statements, ConnectionInterface $co foreach ($statements as $statement) { $stmt = $connection->prepare($statement); - if ($stmt instanceof \PDOStatement) { + if ($stmt instanceof PDOStatement) { // only execute if has no error $stmt->execute(); $executed++; @@ -105,6 +110,7 @@ protected static function executeStatements($statements, ConnectionInterface $co /** * Explodes a SQL string into an array of SQL statements. + * * @example * * echo SqlParser::parseString("-- Table foo @@ -116,14 +122,15 @@ protected static function executeStatements($statements, ConnectionInterface $co * ) ENGINE=InnoDB;"); * // results in * // array( - * // "DROP TABLE foo;", - * // "CREATE TABLE foo ( - * // id int(11) NOT NULL AUTO_INCREMENT, - * // title varchar(255) NOT NULL, - * // PRIMARY KEY (id), - * // ) ENGINE=InnoDB;" + * // "DROP TABLE foo;", + * // "CREATE TABLE foo ( + * // id int(11) NOT NULL AUTO_INCREMENT, + * // title varchar(255) NOT NULL, + * // PRIMARY KEY (id), + * // ) ENGINE=InnoDB;" * // ) * + * * @param string $input The SQL code to parse * * @return array A list of SQL statement strings @@ -140,19 +147,21 @@ public static function parseString($input) /** * Explodes a SQL file into an array of SQL statements. + * * @example * * echo SqlParser::parseFile('/var/tmp/foo.sql'); * // results in * // array( - * // "DROP TABLE foo;", - * // "CREATE TABLE foo ( - * // id int(11) NOT NULL AUTO_INCREMENT, - * // title varchar(255) NOT NULL, - * // PRIMARY KEY (id), - * // ) ENGINE=InnoDB;" + * // "DROP TABLE foo;", + * // "CREATE TABLE foo ( + * // id int(11) NOT NULL AUTO_INCREMENT, + * // title varchar(255) NOT NULL, + * // PRIMARY KEY (id), + * // ) ENGINE=InnoDB;" * // ) * + * * @param string $file The absolute path to the file to parse * * @return array A list of SQL statement strings @@ -181,7 +190,7 @@ public function stripSQLCommentLines() { $this->setSQL(preg_replace([ '#^\s*(//|--|\#).*(\n|$)#m', // //, --, or # style comments - '#^\s*/\*.*?\*/#s' // c-style comments + '#^\s*/\*.*?\*/#s', // c-style comments ], '', $this->sql)); } @@ -218,11 +227,12 @@ public function getNextStatement() $char = isset($this->sql[$this->pos]) ? $this->sql[$this->pos] : ''; // check flags for strings or escaper switch ($char) { - case "\\": + case '\\': $isAfterBackslash = true; + break; case "'": - case "\"": + case '"': if ($isInString && $stringQuotes == $char) { if (!$isAfterBackslash) { $isInString = false; @@ -231,14 +241,15 @@ public function getNextStatement() $stringQuotes = $char; $isInString = true; } + break; } $this->pos++; - if ($char !== "\\") { + if ($char !== '\\') { $isAfterBackslash = false; } if (!$isInString) { - if (false !== strpos($lowercaseString, 'delimiter ')) { + if (strpos($lowercaseString, 'delimiter ') !== false) { // remove DELIMITER from string because it's a command-line keyword only $parsedString = trim(str_ireplace('delimiter ', '', $parsedString)); // set new delimiter @@ -256,18 +267,22 @@ public function getNextStatement() } else { // reset helper variable $lowercaseString = ''; + continue; } } // get next characters if we have multiple characters in delimiter $nextChars = ''; for ($i = 0; $i < $this->delimiterLength - 1; $i++) { - if (!isset($this->sql[$this->pos + $i])) break; + if (!isset($this->sql[$this->pos + $i])) { + break; + } $nextChars .= $this->sql[$this->pos + $i]; } // check for end of statement - if ($char.$nextChars == $this->delimiter) { + if ($char . $nextChars == $this->delimiter) { $this->pos += $i; // increase position + return trim($parsedString); } // avoid using strtolower on the whole parsed string every time new character is added @@ -276,7 +291,7 @@ public function getNextStatement() } $parsedString .= $char; } + return trim($parsedString); } - } diff --git a/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php b/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php index 47d174e42a..1c23dbeb42 100644 --- a/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php @@ -2,13 +2,15 @@ namespace Propel\Runtime\ActiveQuery; -use Propel\Runtime\Propel; +use ArrayIterator; +use IteratorAggregate; use Propel\Runtime\Exception\InvalidArgumentException; use Propel\Runtime\Exception\LogicException; use Propel\Runtime\Formatter\AbstractFormatter; -use Propel\Runtime\Map\TableMap; +use Propel\Runtime\Propel; +use Traversable; -class BaseModelCriteria extends Criteria implements \IteratorAggregate +class BaseModelCriteria extends Criteria implements IteratorAggregate { protected $modelName; @@ -16,7 +18,9 @@ class BaseModelCriteria extends Criteria implements \IteratorAggregate protected $modelAlias; - /** @var TableMap */ + /** + * @var \Propel\Runtime\Map\TableMap + */ protected $tableMap; protected $formatter; @@ -29,8 +33,8 @@ class BaseModelCriteria extends Criteria implements \IteratorAggregate * Creates a new instance with the default capacity which corresponds to * the specified database. * - * @param string|null $dbName The dabase name - * @param string|null $modelName The phpName of a model, e.g. 'Book' + * @param string|null $dbName The dabase name + * @param string|null $modelName The phpName of a model, e.g. 'Book' * @param string|null $modelAlias The alias for the model in this query, e.g. 'b' */ public function __construct($dbName = null, $modelName = null, $modelAlias = null) @@ -46,7 +50,8 @@ public function __construct($dbName = null, $modelName = null, $modelAlias = nul * together with the main object. * * @see with() - * @return ModelWith[] + * + * @return \Propel\Runtime\ActiveQuery\ModelWith[] */ public function getWith() { @@ -76,10 +81,11 @@ public function setWith($with) * $c->setFormatter(ModelCriteria::FORMAT_ARRAY); * * - * @param string|AbstractFormatter $formatter a formatter class name, or a formatter instance - * @return $this The current object, for fluid interface + * @param string|\Propel\Runtime\Formatter\AbstractFormatter $formatter a formatter class name, or a formatter instance + * + * @throws \Propel\Runtime\Exception\InvalidArgumentException * - * @throws InvalidArgumentException + * @return $this The current object, for fluid interface */ public function setFormatter($formatter) { @@ -100,11 +106,11 @@ public function setFormatter($formatter) * Gets the formatter to use for the find() output * Defaults to an instance of ModelCriteria::$defaultFormatterClass, i.e. PropelObjectsFormatter * - * @return AbstractFormatter + * @return \Propel\Runtime\Formatter\AbstractFormatter */ public function getFormatter() { - if (null === $this->formatter) { + if ($this->formatter === null) { $formatterClass = $this->defaultFormatterClass; $this->formatter = new $formatterClass(); } @@ -132,7 +138,7 @@ public function getModelName() */ public function setModelName($modelName) { - if (0 === strpos($modelName, '\\')) { + if (strpos($modelName, '\\') === 0) { $this->modelName = substr($modelName, 1); } else { $this->modelName = $modelName; @@ -158,8 +164,8 @@ public function getFullyQualifiedModelName() /** * Sets the alias for the model in this query * - * @param string $modelAlias The model alias - * @param boolean $useAliasInSQL Whether to use the alias in the SQL code (false by default) + * @param string $modelAlias The model alias + * @param bool $useAliasInSQL Whether to use the alias in the SQL code (false by default) * * @return $this The current object, for fluid interface */ @@ -208,7 +214,7 @@ public function getModelShortName() /** * Returns the TableMap object for this Criteria * - * @return TableMap + * @return \Propel\Runtime\Map\TableMap */ public function getTableMap() { @@ -222,23 +228,23 @@ public function getTableMap() * constructed on a Propel\Runtime\Collection\PropelCollection. * Compulsory for implementation of \IteratorAggregate. * - * @return \Traversable + * @throws \Propel\Runtime\Exception\LogicException * - * @throws LogicException + * @return \Traversable */ public function getIterator() { $res = $this->find(null); // use the default connection - if ($res instanceof \IteratorAggregate) { + if ($res instanceof IteratorAggregate) { return $res->getIterator(); } - if ($res instanceof \Traversable) { + if ($res instanceof Traversable) { return $res; } if (is_array($res)) { - return new \ArrayIterator($res); + return new ArrayIterator($res); } + throw new LogicException('The current formatter doesn\'t return an iterable result'); } - } diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index 01d913e46f..86f54b3273 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -10,20 +10,19 @@ namespace Propel\Runtime\ActiveQuery; -use Propel\Runtime\Adapter\Pdo\PdoAdapter; -use Propel\Runtime\Connection\ConnectionInterface; -use Propel\Runtime\Exception\PropelException; -use Propel\Runtime\DataFetcher\DataFetcherInterface; -use Propel\Runtime\Propel; -use Propel\Runtime\Exception\LogicException; -use Propel\Runtime\Util\PropelConditionalProxy; +use Exception; use Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion; use Propel\Runtime\ActiveQuery\Criterion\BasicCriterion; -use Propel\Runtime\ActiveQuery\Criterion\InCriterion; +use Propel\Runtime\ActiveQuery\Criterion\BinaryCriterion; use Propel\Runtime\ActiveQuery\Criterion\CustomCriterion; +use Propel\Runtime\ActiveQuery\Criterion\InCriterion; use Propel\Runtime\ActiveQuery\Criterion\LikeCriterion; use Propel\Runtime\ActiveQuery\Criterion\RawCriterion; -use Propel\Runtime\ActiveQuery\Criterion\BinaryCriterion; +use Propel\Runtime\Connection\ConnectionInterface; +use Propel\Runtime\Exception\LogicException; +use Propel\Runtime\Exception\PropelException; +use Propel\Runtime\Propel; +use Propel\Runtime\Util\PropelConditionalProxy; /** * This is a utility class for holding criteria information for a query. @@ -39,120 +38,81 @@ */ class Criteria { + public const EQUAL = '='; - /** Comparison type. */ - const EQUAL = '='; - - /** Comparison type. */ - const NOT_EQUAL = '<>'; + public const NOT_EQUAL = '<>'; - /** Comparison type. */ - const ALT_NOT_EQUAL = '!='; + public const ALT_NOT_EQUAL = '!='; - /** Comparison type. */ - const GREATER_THAN = '>'; + public const GREATER_THAN = '>'; - /** Comparison type. */ - const LESS_THAN = '<'; + public const LESS_THAN = '<'; - /** Comparison type. */ - const GREATER_EQUAL = '>='; + public const GREATER_EQUAL = '>='; - /** Comparison type. */ - const LESS_EQUAL = '<='; + public const LESS_EQUAL = '<='; - /** Comparison type. */ - const LIKE = ' LIKE '; + public const LIKE = ' LIKE '; - /** Comparison type. */ - const NOT_LIKE = ' NOT LIKE '; + public const NOT_LIKE = ' NOT LIKE '; - /** Comparison for array column types */ - const CONTAINS_ALL = 'CONTAINS_ALL'; + public const CONTAINS_ALL = 'CONTAINS_ALL'; - /** Comparison for array column types */ - const CONTAINS_SOME = 'CONTAINS_SOME'; + public const CONTAINS_SOME = 'CONTAINS_SOME'; - /** Comparison for array column types */ - const CONTAINS_NONE = 'CONTAINS_NONE'; + public const CONTAINS_NONE = 'CONTAINS_NONE'; - /** PostgreSQL comparison type */ - const ILIKE = ' ILIKE '; + public const ILIKE = ' ILIKE '; - /** PostgreSQL comparison type */ - const NOT_ILIKE = ' NOT ILIKE '; + public const NOT_ILIKE = ' NOT ILIKE '; - /** Comparison type. */ - const CUSTOM = 'CUSTOM'; + public const CUSTOM = 'CUSTOM'; - /** Comparison type */ - const RAW = 'RAW'; + public const RAW = 'RAW'; - /** Comparison type for update */ - const CUSTOM_EQUAL = 'CUSTOM_EQUAL'; + public const CUSTOM_EQUAL = 'CUSTOM_EQUAL'; - /** Comparison type. */ - const DISTINCT = 'DISTINCT'; + public const DISTINCT = 'DISTINCT'; - /** Comparison type. */ - const IN = ' IN '; + public const IN = ' IN '; - /** Comparison type. */ - const NOT_IN = ' NOT IN '; + public const NOT_IN = ' NOT IN '; - /** Comparison type. */ - const ALL = 'ALL'; + public const ALL = 'ALL'; - /** Comparison type. */ - const JOIN = 'JOIN'; + public const JOIN = 'JOIN'; - /** Binary math operator: AND */ - const BINARY_AND = '&'; + public const BINARY_AND = '&'; - /** Binary math operator: OR */ - const BINARY_OR = '|'; + public const BINARY_OR = '|'; - /** Binary pseudo operator: ALL */ - const BINARY_ALL = 'BINARY_ALL'; + public const BINARY_ALL = 'BINARY_ALL'; - /** Binary pseudo operator: NOT IN */ - const BINARY_NONE = 'BINARY_NONE'; + public const BINARY_NONE = 'BINARY_NONE'; - /** 'Order by' qualifier - ascending */ - const ASC = 'ASC'; + public const ASC = 'ASC'; - /** 'Order by' qualifier - descending */ - const DESC = 'DESC'; + public const DESC = 'DESC'; - /** 'IS NULL' null comparison */ - const ISNULL = ' IS NULL '; + public const ISNULL = ' IS NULL '; - /** 'IS NOT NULL' null comparison */ - const ISNOTNULL = ' IS NOT NULL '; + public const ISNOTNULL = ' IS NOT NULL '; - /** 'CURRENT_DATE' ANSI SQL function */ - const CURRENT_DATE = 'CURRENT_DATE'; + public const CURRENT_DATE = 'CURRENT_DATE'; - /** 'CURRENT_TIME' ANSI SQL function */ - const CURRENT_TIME = 'CURRENT_TIME'; + public const CURRENT_TIME = 'CURRENT_TIME'; - /** 'CURRENT_TIMESTAMP' ANSI SQL function */ - const CURRENT_TIMESTAMP = 'CURRENT_TIMESTAMP'; + public const CURRENT_TIMESTAMP = 'CURRENT_TIMESTAMP'; - /** 'LEFT JOIN' SQL statement */ - const LEFT_JOIN = 'LEFT JOIN'; + public const LEFT_JOIN = 'LEFT JOIN'; - /** 'RIGHT JOIN' SQL statement */ - const RIGHT_JOIN = 'RIGHT JOIN'; + public const RIGHT_JOIN = 'RIGHT JOIN'; - /** 'INNER JOIN' SQL statement */ - const INNER_JOIN = 'INNER JOIN'; + public const INNER_JOIN = 'INNER JOIN'; - /** logical OR operator */ - const LOGICAL_OR = 'OR'; + public const LOGICAL_OR = 'OR'; - /** logical AND operator */ - const LOGICAL_AND = 'AND'; + public const LOGICAL_AND = 'AND'; protected $ignoreCase = false; @@ -160,59 +120,68 @@ class Criteria /** * Storage of select data. Collection of column names. + * * @var array */ protected $selectColumns = []; /** * Storage of aliased select data. Collection of column names. + * * @var string[] */ protected $asColumns = []; /** * Storage of select modifiers data. Collection of modifier names. + * * @var string[] */ protected $selectModifiers = []; /** * Storage of conditions data. Collection of Criterion objects. - * @var AbstractCriterion[] + * + * @var \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion[] */ protected $map = []; /** * Storage of ordering data. Collection of column names. + * * @var array */ protected $orderByColumns = []; /** * Storage of grouping data. Collection of column names. + * * @var array */ protected $groupByColumns = []; /** * Storage of having data. - * @var AbstractCriterion|null + * + * @var \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion|null */ protected $having; /** * Storage of join data. collection of Join objects. - * @var Join[] + * + * @var \Propel\Runtime\ActiveQuery\Join[] */ protected $joins = []; /** - * @var Criteria[] + * @var \Propel\Runtime\ActiveQuery\Criteria[] */ protected $selectQueries = []; /** * The name of the database. + * * @var string */ protected $dbName; @@ -221,31 +190,36 @@ class Criteria * The primary table for this Criteria. * Useful in cases where there are no select or where * columns. + * * @var string */ protected $primaryTableName; /** * The name of the database as given in the constructor. + * * @var string|null */ protected $originalDbName; /** - * To limit the number of rows to return. -1 means return all + * To limit the number of rows to return. -1 means return all * rows. + * * @var int */ protected $limit = -1; /** * To start the results at a row other than the first one. + * * @var int */ protected $offset = 0; /** * Comment to add to the SQL query + * * @var string */ protected $queryComment; @@ -256,26 +230,28 @@ class Criteria /** * Storage for Criterions expected to be combined - * @var AbstractCriterion[] + * + * @var \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion[] */ protected $namedCriterions = []; /** * Default operator for combination of criterions + * * @see addUsingOperator * @var string Criteria::LOGICAL_AND or Criteria::LOGICAL_OR */ protected $defaultCombineOperator = Criteria::LOGICAL_AND; /** - * @var PropelConditionalProxy|null + * @var \Propel\Runtime\Util\PropelConditionalProxy|null */ protected $conditionalProxy; /** * Whether identifier should be quoted. * - * @var boolean + * @var bool */ protected $identifierQuoting = false; @@ -298,7 +274,8 @@ public function __construct($dbName = null) /** * Get the criteria map, i.e. the array of Criterions - * @return AbstractCriterion[] + * + * @return \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion[] */ public function getMap() { @@ -309,6 +286,7 @@ public function getMap() * Brings this criteria back to its initial state, so that it * can be reused as if it was new. Except if the criteria has grown in * capacity, it is left at the current capacity. + * * @return void */ public function clear() @@ -342,7 +320,7 @@ public function clear() * * If the name already exists, it is replaced by the new clause. * - * @param string $name Wanted Name of the column (alias). + * @param string $name Wanted Name of the column (alias). * @param string $clause SQL clause to select from the table * * @return $this A modified Criteria object. @@ -368,8 +346,9 @@ public function getAsColumns() /** * Returns the column name associated with an alias (AS-column). * - * @param string $as Alias - * @return string|null $string + * @param string $as Alias + * + * @return string|null */ public function getColumnForAs($as) { @@ -423,8 +402,9 @@ public function getAliases() /** * Returns the table name associated with an alias. * - * @param string $alias - * @return string|null $string + * @param string $alias + * + * @return string|null */ public function getTableForAlias($alias) { @@ -440,8 +420,11 @@ public function getTableForAlias($alias) * Use this method to get the details of a table name that comes in a clause, * which can be either a table name or an alias name. * - * @param string $tableAliasOrName - * @return array($tableName, $tableAlias) + * Array($tableName, $tableAlias) + * + * @param string $tableAliasOrName + * + * @return array */ public function getTableNameAndAlias($tableAliasOrName) { @@ -469,8 +452,9 @@ public function keys() /** * Does this Criteria object contain the specified key? * - * @param string $column [table.]column - * @return boolean True if this Criteria object contain the specified key. + * @param string $column [table.]column + * + * @return bool True if this Criteria object contain the specified key. */ public function containsKey($column) { @@ -482,14 +466,15 @@ public function containsKey($column) /** * Does this Criteria object contain the specified key and does it have a value set for the key * - * @param string $column [table.]column - * @return boolean True if this Criteria object contain the specified key and a value for that key + * @param string $column [table.]column + * + * @return bool True if this Criteria object contain the specified key and a value for that key */ public function keyContainsValue($column) { // must use array_key_exists() because the key could // exist but have a NULL value (that'd be valid). - return isset($this->map[$column]) && null !== $this->map[$column]->getValue(); + return isset($this->map[$column]) && $this->map[$column]->getValue() !== null; } /** @@ -497,8 +482,9 @@ public function keyContainsValue($column) * * This counts conditions added with the add() method. * - * @return boolean * @see add() + * + * @return bool */ public function hasWhereClause() { @@ -507,21 +493,24 @@ public function hasWhereClause() /** * Will force the sql represented by this criteria to be executed within - * a transaction. This is here primarily to support the oid type in - * postgresql. Though it can be used to require any single sql statement + * a transaction. This is here primarily to support the oid type in + * postgresql. Though it can be used to require any single sql statement * to use a transaction. + * + * @param bool $v + * * @return void */ public function setUseTransaction($v) { - $this->useTransaction = (bool) $v; + $this->useTransaction = (bool)$v; } /** * Whether the sql command specified by this criteria must be wrapped * in a transaction. * - * @return boolean + * @return bool */ public function isUseTransaction() { @@ -534,8 +523,9 @@ public function isUseTransaction() * Make sure you call containsKey($column) prior to calling this method, * since no check on the existence of the $column is made in this method. * - * @param string $column Column name. - * @return AbstractCriterion A Criterion object. + * @param string $column Column name. + * + * @return \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion A Criterion object. */ public function getCriterion($column) { @@ -545,7 +535,7 @@ public function getCriterion($column) /** * Method to return the latest Criterion in a table. * - * @return AbstractCriterion|null A Criterion or null no Criterion is added. + * @return \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion|null A Criterion or null no Criterion is added. */ public function getLastCriterion() { @@ -561,13 +551,14 @@ public function getLastCriterion() /** * Method to return a Criterion that is not added automatically - * to this Criteria. This can be used to chain the + * to this Criteria. This can be used to chain the * Criterions to form a more complex where clause. * - * @param string $column Full name of column (for example TABLE.COLUMN). - * @param mixed|null $value - * @param string|int $comparison Criteria comparison constant or PDO binding type - * @return AbstractCriterion + * @param string $column Full name of column (for example TABLE.COLUMN). + * @param mixed|null $value + * @param string|int $comparison Criteria comparison constant or PDO binding type + * + * @return \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion */ public function getNewCriterion($column, $value = null, $comparison = self::EQUAL) { @@ -608,7 +599,8 @@ public function getNewCriterion($column, $value = null, $comparison = self::EQUA /** * Method to return a String table name. * - * @param string $name Name of the key. + * @param string $name Name of the key. + * * @return string|null The value of the object at key. */ public function getColumnName($name) @@ -625,7 +617,7 @@ public function getColumnName($name) * * print_r($c->getTablesColumns()); * => array( - * 'book' => array('book.price', 'book.title'), + * 'book' => array('book.price', 'book.title'), * 'author' => array('author.first_name') * ) * @@ -646,7 +638,8 @@ public function getTablesColumns() /** * Method to return a comparison String. * - * @param string $key String name of the key. + * @param string $key String name of the key. + * * @return string|null A String with the value of the object at key. */ public function getComparison($key) @@ -669,22 +662,23 @@ public function getDbName() } /** - * Set the DatabaseMap name. If null is supplied, uses value + * Set the DatabaseMap name. If null is supplied, uses value * provided by Configuration::getDefaultDatasource(). * - * @param string $dbName The Database (Map) name. + * @param string|null $dbName The Database (Map) name. + * * @return void */ public function setDbName($dbName = null) { - $this->dbName = (null === $dbName ? Propel::getServiceContainer()->getDefaultDatasource() : $dbName); + $this->dbName = ($dbName === null ? Propel::getServiceContainer()->getDefaultDatasource() : $dbName); } /** * Get the primary table for this Criteria. * * This is useful for cases where a Criteria may not contain - * any SELECT columns or WHERE columns. This must be explicitly + * any SELECT columns or WHERE columns. This must be explicitly * set, of course, in order to be useful. * * @return string @@ -698,10 +692,11 @@ public function getPrimaryTableName() * Sets the primary table for this Criteria. * * This is useful for cases where a Criteria may not contain - * any SELECT columns or WHERE columns. This must be explicitly + * any SELECT columns or WHERE columns. This must be explicitly * set, of course, in order to be useful. * * @param string $tableName + * * @return void */ public function setPrimaryTableName($tableName) @@ -712,7 +707,8 @@ public function setPrimaryTableName($tableName) /** * Method to return a String table name. * - * @param string $name The name of the key. + * @param string $name The name of the key. + * * @return string|null The value of table for criterion at key. */ public function getTableName($name) @@ -727,8 +723,9 @@ public function getTableName($name) /** * Method to return the value that was added to Criteria. * - * @param string $name A String with the name of the key. - * @return mixed The value of object at key. + * @param string $name A String with the name of the key. + * + * @return mixed The value of object at key. */ public function getValue($name) { @@ -742,8 +739,9 @@ public function getValue($name) /** * An alias to getValue() -- exposing a Hashtable-like interface. * - * @param string $key An Object. - * @return mixed The value within the Criterion (not the Criterion object). + * @param string $key An Object. + * + * @return mixed The value within the Criterion (not the Criterion object). */ public function get($key) { @@ -760,8 +758,9 @@ public function get($key) * throw a NPE. The reason for this is that none of the add() * methods support adding anything other than a String as a key. * - * @param string $key - * @param mixed $value + * @param string $key + * @param mixed $value + * * @return $this Instance of self. */ public function put($key, $value) @@ -778,6 +777,7 @@ public function put($key, $value) * Criteria, overwriting previous settings. * * @param mixed $t Mappings to be stored in this map. + * * @return void */ public function putAll($t) @@ -810,8 +810,8 @@ public function putAll($t) * The name of the table must be used implicitly in the column name, * so the Column name must be something like 'TABLE.id'. * - * @param string|AbstractCriterion $p1 The column to run the comparison on, or a Criterion object. - * @param mixed $value + * @param string|\Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion $p1 The column to run the comparison on, or a Criterion object. + * @param mixed $value * @param string|int|null $comparison A String. * * @return $this A modified Criteria object. @@ -851,10 +851,10 @@ public function __toString() * The name of the table must be used implicitly in the column name, * so the Column name must be something like 'TABLE.id'. * - * @param string $name name to combine the criterion later - * @param string $p1 The column to run the comparison on, or AbstractCriterion object. - * @param mixed $value - * @param string $comparison A String. + * @param string $name name to combine the criterion later + * @param string $p1 The column to run the comparison on, or AbstractCriterion object. + * @param mixed $value + * @param string|null $comparison A String. * * @return $this A modified Criteria object. */ @@ -868,18 +868,21 @@ public function addCond($name, $p1, $value = null, $comparison = null) /** * Combine several named criterions with a logical operator * - * @param array $criterions array of the name of the criterions to combine - * @param string $operator logical operator, either Criteria::LOGICAL_AND, or Criteria::LOGICAL_OR - * @param string $name optional name to combine the criterion later + * @param array $criterions array of the name of the criterions to combine + * @param string $operator logical operator, either Criteria::LOGICAL_AND, or Criteria::LOGICAL_OR + * @param string|null $name optional name to combine the criterion later + * + * @throws \Propel\Runtime\Exception\LogicException + * * @return $this */ public function combine($criterions = [], $operator = self::LOGICAL_AND, $name = null) { - $operatorMethod = (self::LOGICAL_AND === strtoupper($operator)) ? 'addAnd' : 'addOr'; + $operatorMethod = (strtoupper($operator) === self::LOGICAL_AND) ? 'addAnd' : 'addOr'; $namedCriterions = []; foreach ($criterions as $key) { if (array_key_exists($key, $this->namedCriterions)) { - $namedCriterions[]= $this->namedCriterions[$key]; + $namedCriterions[] = $this->namedCriterions[$key]; unset($this->namedCriterions[$key]); } else { throw new LogicException(sprintf('Cannot combine unknown condition %s', $key)); @@ -889,7 +892,7 @@ public function combine($criterions = [], $operator = self::LOGICAL_AND, $name = foreach ($namedCriterions as $criterion) { $firstCriterion->$operatorMethod($criterion); } - if (null === $name) { + if ($name === null) { $this->addAnd($firstCriterion, null, null); } else { $this->addCond($name, $firstCriterion, null, null); @@ -906,8 +909,8 @@ public function combine($criterions = [], $operator = self::LOGICAL_AND, $name = * // LEFT JOIN FOO ON (PROJECT.ID = FOO.PROJECT_ID) * * - * @param string|array $left A String with the left side of the join. - * @param string|array $right A String with the right side of the join. + * @param string|array $left A String with the left side of the join. + * @param string|array $right A String with the right side of the join. * @param string|null $joinType A String with the join operator * among Criteria::INNER_JOIN, Criteria::LEFT_JOIN, * and Criteria::RIGHT_JOIN @@ -942,8 +945,12 @@ public function addJoin($left, $right, $joinType = null) [$rightTableName, $rightTableAlias] = $this->getTableNameAndAlias($rightTableAlias); $join->addExplicitCondition( - $leftTableName, $leftColumnName, $leftTableAlias, - $rightTableName, $rightColumnName, $rightTableAlias, + $leftTableName, + $leftColumnName, + $leftTableAlias, + $rightTableName, + $rightColumnName, + $rightTableAlias, Join::EQUAL ); @@ -954,21 +961,22 @@ public function addJoin($left, $right, $joinType = null) /** * Add a join with multiple conditions + * * @deprecated use Join::setJoinCondition($criterion) instead * * @see http://propel.phpdb.org/trac/ticket/167, http://propel.phpdb.org/trac/ticket/606 * * Example usage: * $c->addMultipleJoin(array( - * array(LeftTableMap::LEFT_COLUMN, RightTableMap::RIGHT_COLUMN), // if no third argument, defaults to Criteria::EQUAL + * array(LeftTableMap::LEFT_COLUMN, RightTableMap::RIGHT_COLUMN), // if no third argument, defaults to Criteria::EQUAL * array(FoldersTableMap::alias( 'fo', FoldersTableMap::LFT ), FoldersTableMap::alias( 'parent', FoldersTableMap::RGT ), Criteria::LESS_EQUAL ) * ), * Criteria::LEFT_JOIN * ); - * * @see addJoin() - * @param array $conditions An array of conditions, each condition being an array (left, right, operator) - * @param string|null $joinType A String with the join operator. Defaults to an implicit join. + * + * @param array $conditions An array of conditions, each condition being an array (left, right, operator) + * @param string|null $joinType A String with the join operator. Defaults to an implicit join. * * @return $this A modified Criteria object. */ @@ -1013,9 +1021,9 @@ public function addMultipleJoin($conditions, $joinType = null) $conditionClause .= isset($condition[2]) ? $condition[2] : Join::EQUAL; $conditionClause .= $rightTableAlias ? $rightTableAlias . '.' : ($rightTableName ? $rightTableName . '.' : ''); $conditionClause .= $rightColumnName; - $criterion = $this->getNewCriterion($leftTableName.'.'.$leftColumnName, $conditionClause, Criteria::CUSTOM); + $criterion = $this->getNewCriterion($leftTableName . '.' . $leftColumnName, $conditionClause, Criteria::CUSTOM); - if (null === $joinCondition) { + if ($joinCondition === null) { $joinCondition = $criterion; } else { $joinCondition = $joinCondition->addAnd($criterion); @@ -1030,7 +1038,7 @@ public function addMultipleJoin($conditions, $joinType = null) /** * Add a join object to the Criteria * - * @param Join $join A join object + * @param \Propel\Runtime\ActiveQuery\Join $join A join object * * @return $this A modified Criteria object */ @@ -1045,7 +1053,8 @@ public function addJoinObject(Join $join) /** * Get the array of Joins. - * @return Join[] + * + * @return \Propel\Runtime\ActiveQuery\Join[] */ public function getJoins() { @@ -1057,7 +1066,7 @@ public function getJoins() * * @param string $name The name of the join clause * - * @return Join A join object + * @return \Propel\Runtime\ActiveQuery\Join A join object */ public function getJoin($name) { @@ -1077,14 +1086,14 @@ public function hasJoin($name) /** * Adds a Criteria as subQuery in the From Clause. * - * @param Criteria $subQueryCriteria Criteria to build the subquery from - * @param string|null $alias alias for the subQuery + * @param \Propel\Runtime\ActiveQuery\Criteria $subQueryCriteria Criteria to build the subquery from + * @param string|null $alias alias for the subQuery * * @return $this this modified Criteria object (Fluid API) */ public function addSelectQuery(Criteria $subQueryCriteria, $alias = null) { - if (null === $alias) { + if ($alias === null) { $alias = 'alias_' . ($subQueryCriteria->forgeSelectQueryAlias() + count($this->selectQueries)); } $this->selectQueries[$alias] = $subQueryCriteria; @@ -1095,17 +1104,17 @@ public function addSelectQuery(Criteria $subQueryCriteria, $alias = null) /** * Checks whether this Criteria has a subquery. * - * @return boolean + * @return bool */ public function hasSelectQueries() { - return (bool) $this->selectQueries; + return (bool)$this->selectQueries; } /** * Get the associative array of Criteria for the subQueries per alias. * - * @return Criteria[] + * @return \Propel\Runtime\ActiveQuery\Criteria[] */ public function getSelectQueries() { @@ -1115,8 +1124,9 @@ public function getSelectQueries() /** * Get the Criteria for a specific subQuery. * - * @param string $alias alias for the subQuery - * @return Criteria + * @param string $alias alias for the subQuery + * + * @return self */ public function getSelectQuery($alias) { @@ -1126,8 +1136,9 @@ public function getSelectQuery($alias) /** * checks if the Criteria for a specific subQuery is set. * - * @param string $alias alias for the subQuery - * @return boolean + * @param string $alias alias for the subQuery + * + * @return bool */ public function hasSelectQuery($alias) { @@ -1149,6 +1160,7 @@ public function forgeSelectQueryAlias() /** * Adds 'ALL' modifier to the SQL statement. + * * @return $this Modified Criteria object (for fluent API) */ public function setAll() @@ -1161,6 +1173,7 @@ public function setAll() /** * Adds 'DISTINCT' modifier to the SQL statement. + * * @return $this Modified Criteria object (for fluent API) */ public function setDistinct() @@ -1209,7 +1222,7 @@ public function removeSelectModifier($modifier) * * @param string $modifier The modifier to add * - * @return boolean + * @return bool */ public function hasSelectModifier($modifier) { @@ -1219,12 +1232,13 @@ public function hasSelectModifier($modifier) /** * Sets ignore case. * - * @param boolean $b True if case should be ignored. + * @param bool $b True if case should be ignored. + * * @return $this Modified Criteria object (for fluent API) */ public function setIgnoreCase($b) { - $this->ignoreCase = (bool) $b; + $this->ignoreCase = (bool)$b; return $this; } @@ -1232,7 +1246,7 @@ public function setIgnoreCase($b) /** * Is ignore case on or off? * - * @return boolean True if case is ignored. + * @return bool True if case is ignored. */ public function isIgnoreCase() { @@ -1240,20 +1254,21 @@ public function isIgnoreCase() } /** - * Set single record? Set this to true if you expect the query + * Set single record? Set this to true if you expect the query * to result in only a single result record (the default behaviour is to * throw a PropelException if multiple records are returned when the query - * is executed). This should be used in situations where returning multiple - * rows would indicate an error of some sort. If your query might return + * is executed). This should be used in situations where returning multiple + * rows would indicate an error of some sort. If your query might return * multiple records but you are only interested in the first one then you * should be using setLimit(1). * - * @param boolean $b Set to TRUE if you expect the query to select just one record. + * @param bool $b Set to TRUE if you expect the query to select just one record. + * * @return $this Modified Criteria object (for fluent API) */ public function setSingleRecord($b) { - $this->singleRecord = (bool) $b; + $this->singleRecord = (bool)$b; return $this; } @@ -1261,7 +1276,7 @@ public function setSingleRecord($b) /** * Is single record? * - * @return boolean True if a single record is being returned. + * @return bool True if a single record is being returned. */ public function isSingleRecord() { @@ -1271,12 +1286,13 @@ public function isSingleRecord() /** * Set limit. * - * @param int $limit An int with the value for limit. + * @param int $limit An int with the value for limit. + * * @return $this Modified Criteria object (for fluent API) */ public function setLimit($limit) { - $this->limit = (int) $limit; + $this->limit = (int)$limit; return $this; } @@ -1294,12 +1310,13 @@ public function getLimit() /** * Set offset. * - * @param int $offset An int with the value for offset. + * @param int $offset An int with the value for offset. + * * @return $this Modified Criteria object (for fluent API) */ public function setOffset($offset) { - $this->offset = (int) $offset; + $this->offset = (int)$offset; return $this; } @@ -1317,7 +1334,8 @@ public function getOffset() /** * Add select column. * - * @param string $name Name of the select column. + * @param string $name Name of the select column. + * * @return $this Modified Criteria object (for fluent API) */ public function addSelectColumn($name) @@ -1330,7 +1348,8 @@ public function addSelectColumn($name) /** * Set the query comment, that appears after the first verb in the SQL query * - * @param string $comment The comment to add to the query, without comment sign + * @param string|null $comment The comment to add to the query, without comment sign + * * @return $this Modified Criteria object (for fluent API) */ public function setComment($comment = null) @@ -1355,9 +1374,10 @@ public function getComment() * * This will include columns added with addAsColumn() method. * - * @return boolean * @see addAsColumn() * @see addSelectColumn() + * + * @return bool */ public function hasSelectClause() { @@ -1399,7 +1419,8 @@ public function getSelectModifiers() /** * Add group by column name. * - * @param string $groupBy The name of the column to group by. + * @param string $groupBy The name of the column to group by. + * * @return $this A modified Criteria object. */ public function addGroupByColumn($groupBy) @@ -1412,7 +1433,8 @@ public function addGroupByColumn($groupBy) /** * Add order by column name, explicitly specifying ascending. * - * @param string $name The name of the column to order by. + * @param string $name The name of the column to order by. + * * @return $this A modified Criteria object. */ public function addAscendingOrderByColumn($name) @@ -1425,7 +1447,8 @@ public function addAscendingOrderByColumn($name) /** * Add order by column name, explicitly specifying descending. * - * @param string $name The name of the column to order by. + * @param string $name The name of the column to order by. + * * @return $this Modified Criteria object (for fluent API) */ public function addDescendingOrderByColumn($name) @@ -1482,7 +1505,7 @@ public function getGroupByColumns() /** * Get Having Criterion. * - * @return AbstractCriterion|null A Criterion object that is the having clause. + * @return \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion|null A Criterion object that is the having clause. */ public function getHaving() { @@ -1492,8 +1515,9 @@ public function getHaving() /** * Remove an object from the criteria. * - * @param string $key A string with the key to be removed. - * @return mixed|null The removed value. + * @param string $key A string with the key to be removed. + * + * @return mixed|null The removed value. */ public function remove($key) { @@ -1501,7 +1525,7 @@ public function remove($key) return null; } - /** @var AbstractCriterion|null */ + /** @var \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion|null */ $removed = $this->map[$key]; unset($this->map[$key]); if ($removed instanceof AbstractCriterion) { @@ -1520,9 +1544,8 @@ public function toString() { $sb = 'Criteria:'; try { - $params = []; - $sb .= "\nSQL (may not be complete): ".$this->createSelectSql($params); + $sb .= "\nSQL (may not be complete): " . $this->createSelectSql($params); $sb .= "\nParams: "; $paramstr = []; @@ -1530,8 +1553,7 @@ public function toString() $paramstr[] = $param['table'] . '.' . $param['column'] . ' => ' . var_export($param['value'], true); } $sb .= implode(', ', $paramstr); - - } catch (\Exception $exc) { + } catch (Exception $exc) { $sb .= '(Error: ' . $exc->getMessage() . ')'; } @@ -1540,6 +1562,7 @@ public function toString() /** * Returns the size (count) of this criteria. + * * @return int */ public function size() @@ -1550,37 +1573,37 @@ public function size() /** * This method checks another Criteria to see if they contain * the same attributes and hashtable entries. - * @return boolean + * + * @return bool */ public function equals($crit) { - if (null === $crit || !($crit instanceof Criteria)) { + if ($crit === null || !($crit instanceof Criteria)) { return false; } - /** @var Criteria $crit */ + /** @var \Propel\Runtime\ActiveQuery\Criteria $crit */ if ($this === $crit) { return true; } if ($this->size() === $crit->size()) { - // Important: nested criterion objects are checked $criteria = $crit; // alias - if ($this->offset === $criteria->getOffset() - && $this->limit === $criteria->getLimit() - && $this->ignoreCase === $criteria->isIgnoreCase() - && $this->singleRecord === $criteria->isSingleRecord() - && $this->dbName === $criteria->getDbName() + if ( + $this->offset === $criteria->getOffset() + && $this->limit === $criteria->getLimit() + && $this->ignoreCase === $criteria->isIgnoreCase() + && $this->singleRecord === $criteria->isSingleRecord() + && $this->dbName === $criteria->getDbName() && $this->selectModifiers === $criteria->getSelectModifiers() - && $this->selectColumns === $criteria->getSelectColumns() - && $this->asColumns === $criteria->getAsColumns() - && $this->orderByColumns === $criteria->getOrderByColumns() - && $this->groupByColumns === $criteria->getGroupByColumns() - && $this->aliases === $criteria->getAliases() - ) // what about having ?? - { + && $this->selectColumns === $criteria->getSelectColumns() + && $this->asColumns === $criteria->getAsColumns() + && $this->orderByColumns === $criteria->getOrderByColumns() + && $this->groupByColumns === $criteria->getGroupByColumns() + && $this->aliases === $criteria->getAliases() + ) { // what about having ?? foreach ($criteria->keys() as $key) { if ($this->containsKey($key)) { $a = $this->getCriterion($key); @@ -1617,30 +1640,32 @@ public function equals($crit) * Add the content of a Criteria to the current Criteria * In case of conflict, the current Criteria keeps its properties * - * @param Criteria $criteria The criteria to read properties from - * @param string $operator The logical operator used to combine conditions + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria The criteria to read properties from + * @param string|null $operator The logical operator used to combine conditions * Defaults to Criteria::LOGICAL_AND, also accepts Criteria::LOGICAL_OR * This parameter is deprecated, use _or() instead * + * @throws \Propel\Runtime\Exception\LogicException + * * @return $this The current criteria object */ public function mergeWith(Criteria $criteria, $operator = null) { // merge limit $limit = $criteria->getLimit(); - if (0 != $limit && -1 === $this->getLimit()) { + if ($limit != 0 && $this->getLimit() === - 1) { $this->limit = $limit; } // merge offset $offset = $criteria->getOffset(); - if (0 != $offset && 0 === $this->getOffset()) { + if ($offset != 0 && $this->getOffset() === 0) { $this->offset = $offset; } // merge select modifiers $selectModifiers = $criteria->getSelectModifiers(); - if ($selectModifiers && ! $this->selectModifiers) { + if ($selectModifiers && !$this->selectModifiers) { $this->selectModifiers = $selectModifiers; } @@ -1663,12 +1688,12 @@ public function mergeWith(Criteria $criteria, $operator = null) $this->groupByColumns = array_unique($groupByColumns); // merge where conditions - if (Criteria::LOGICAL_OR === $operator) { + if ($operator === Criteria::LOGICAL_OR) { $this->_or(); } $isFirstCondition = true; foreach ($criteria->getMap() as $key => $criterion) { - if ($isFirstCondition && Criteria::LOGICAL_OR === $this->defaultCombineOperator) { + if ($isFirstCondition && $this->defaultCombineOperator === Criteria::LOGICAL_OR) { $this->addOr($criterion, null, null, false); $this->defaultCombineOperator = Criteria::LOGICAL_AND; } elseif ($this->containsKey($key)) { @@ -1714,8 +1739,8 @@ public function mergeWith(Criteria $criteria, $operator = null) * $crit->addHaving($c); * * - * @param mixed $p1 A Criterion, or a SQL clause with a question mark placeholder, or a column name - * @param mixed $value The value to bind in the condition + * @param mixed $p1 A Criterion, or a SQL clause with a question mark placeholder, or a column name + * @param mixed $value The value to bind in the condition * @param mixed $comparison A PDO::PARAM_ class constant * * @return $this A modified Criteria object. @@ -1742,11 +1767,11 @@ public function addHaving($p1, $value = null, $comparison = null) * - Otherwise, create a classic Criterion based on a column name and a comparison. * $c->getCriterionForCondition(BookTableMap::TITLE, 'War%', Criteria::LIKE); * - * @param mixed $p1 A Criterion, or a SQL clause with a question mark placeholder, or a column name - * @param mixed $value The value to bind in the condition + * @param mixed $p1 A Criterion, or a SQL clause with a question mark placeholder, or a column name + * @param mixed $value The value to bind in the condition * @param mixed $comparison A Criteria class constant, or a PDO::PARAM_ class constant * - * @return AbstractCriterion + * @return \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion */ protected function getCriterionForCondition($p1, $value = null, $comparison = null) { @@ -1806,6 +1831,7 @@ public function addAnd($p1, $p2 = null, $p3 = null, $preferColumnCondition = tru * @param mixed $p2 * @param mixed $p3 * @param bool $preferColumnCondition + * * @return $this A modified Criteria object. */ public function addOr($p1, $p2 = null, $p3 = null, $preferColumnCondition = true) @@ -1814,7 +1840,7 @@ public function addOr($p1, $p2 = null, $p3 = null, $preferColumnCondition = true $leftCriterion = $this->getLastCriterion(); - if (null !== $leftCriterion) { + if ($leftCriterion !== null) { // combine the given criterion with the existing one with an 'OR' $leftCriterion->addOr($rightCriterion); } else { @@ -1827,20 +1853,21 @@ public function addOr($p1, $p2 = null, $p3 = null, $preferColumnCondition = true /** * Overrides Criteria::add() to use the default combine operator + * * @see Criteria::add() * - * @param string|AbstractCriterion $p1 The column to run the comparison on (e.g. BookTableMap::ID), or Criterion object - * @param mixed $value - * @param string $operator A String, like Criteria::EQUAL. - * @param boolean $preferColumnCondition If true, the condition is combined with an existing condition on the same column - * (necessary for Propel 1.4 compatibility). - * If false, the condition is combined with the last existing condition. + * @param string|\Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion $p1 The column to run the comparison on (e.g. BookTableMap::ID), or Criterion object + * @param mixed $value + * @param string|null $operator A String, like Criteria::EQUAL. + * @param bool $preferColumnCondition If true, the condition is combined with an existing condition on the same column + * (necessary for Propel 1.4 compatibility). + * If false, the condition is combined with the last existing condition. * * @return $this A modified Criteria object. */ public function addUsingOperator($p1, $value = null, $operator = null, $preferColumnCondition = true) { - if (Criteria::LOGICAL_OR === $this->defaultCombineOperator) { + if ($this->defaultCombineOperator === Criteria::LOGICAL_OR) { $this->defaultCombineOperator = Criteria::LOGICAL_AND; return $this->addOr($p1, $value, $operator, $preferColumnCondition); @@ -1853,14 +1880,13 @@ public function addUsingOperator($p1, $value = null, $operator = null, $preferCo * Method to create an SQL query based on values in a Criteria. * * This method creates only prepared statement SQL (using ? where values - * will go). The second parameter ($params) stores the values that need - * to be set before the statement is executed. The reason we do it this way + * will go). The second parameter ($params) stores the values that need + * to be set before the statement is executed. The reason we do it this way * is to let the PDO layer handle all escaping & value formatting. * - * @param array $params Parameters that are to be replaced in prepared statement. - * @return string + * @param array $params Parameters that are to be replaced in prepared statement. * - * @throws \Propel\Runtime\Exception\PropelException Trouble creating the query string. + * @return string */ public function createSelectSql(&$params) { @@ -1912,8 +1938,10 @@ public function createSelectSql(&$params) $table = $tableName; } - if ($this->isIgnoreCase() && method_exists($attachedCriterion, 'setIgnoreCase') - && $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText()) { + if ( + $this->isIgnoreCase() && method_exists($attachedCriterion, 'setIgnoreCase') + && $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText() + ) { $attachedCriterion->setIgnoreCase(true); } } @@ -1941,7 +1969,7 @@ public function createSelectSql(&$params) $having = $this->getHaving(); $havingString = null; - if (null !== $having) { + if ($having !== null) { $sb = ''; $having->appendPsTo($sb, $params); $this->replaceNames($sb); @@ -1949,12 +1977,11 @@ public function createSelectSql(&$params) } if (!empty($orderBy)) { - foreach ($orderBy as $orderByColumn) { - // Add function expression as-is. if (strpos($orderByColumn, '(') !== false) { $orderByClause[] = $orderByColumn; + continue; } @@ -1995,7 +2022,7 @@ public function createSelectSql(&$params) if ($this->isIgnoreCase() && $column && $column->isText()) { $ignoreCaseColumn = $adapter->ignoreCaseInOrderBy("$tableAlias.$columnAlias"); $this->replaceNames($ignoreCaseColumn); - $orderByClause[] = $ignoreCaseColumn . $direction; + $orderByClause[] = $ignoreCaseColumn . $direction; $selectSql .= ', ' . $ignoreCaseColumn; } else { $this->replaceNames($orderByColumn); @@ -2011,7 +2038,7 @@ public function createSelectSql(&$params) // tables should not exist as alias of subQuery if ($this->hasSelectQueries()) { foreach ($fromClause as $key => $ftable) { - if (false !== strpos($ftable, ' ')) { + if (strpos($ftable, ' ') !== false) { [, $tableName] = explode(' ', $ftable); } else { $tableName = $ftable; @@ -2034,17 +2061,17 @@ public function createSelectSql(&$params) // build from-clause $from = ''; if (!empty($joinClause) && count($fromClause) > 1) { - $from .= implode(" CROSS JOIN ", $fromClause); + $from .= implode(' CROSS JOIN ', $fromClause); } else { - $from .= implode(", ", $fromClause); + $from .= implode(', ', $fromClause); } $from .= $joinClause ? ' ' . implode(' ', $joinClause) : ''; // Build the SQL from the arrays we compiled - $sql = $selectSql - .' FROM ' . $from - .($whereClause ? ' WHERE '.implode(' AND ', $whereClause) : ''); + $sql = $selectSql + . ' FROM ' . $from + . ($whereClause ? ' WHERE ' . implode(' AND ', $whereClause) : ''); $groupBy = $adapter->getGroupBy($this); if ($groupBy) { @@ -2052,8 +2079,8 @@ public function createSelectSql(&$params) $sql .= $groupBy; } - $sql .= ($havingString ? ' HAVING '.$havingString : '') - .($orderByClause ? ' ORDER BY '.implode(',', $orderByClause) : ''); + $sql .= ($havingString ? ' HAVING ' . $havingString : '') + . ($orderByClause ? ' ORDER BY ' . implode(',', $orderByClause) : ''); if ($this->getLimit() >= 0 || $this->getOffset()) { $adapter->applyLimit($sql, $this->getOffset(), $this->getLimit(), $this); @@ -2078,6 +2105,7 @@ protected function doReplaceNameInExpression($matches) * Quotes identifier based on $this->isIdentifierQuotingEnabled() and $tableMap->isIdentifierQuotingEnabled. * * @param string $string + * * @return string */ public function quoteIdentifier($string, $tableName = '') @@ -2089,7 +2117,7 @@ public function quoteIdentifier($string, $tableName = '') } //find table name and ask tableMap if quoting is enabled - if (!$tableName && false !== ($pos = strrpos($string, '.'))) { + if (!$tableName && ($pos = strrpos($string, '.')) !== false) { $tableName = substr($string, 0, $pos); } @@ -2118,7 +2146,7 @@ public function quoteIdentifier($string, $tableName = '') public function quoteIdentifierTable($string) { $realTableName = $string; - if (false !== ($pos = strrpos($string, ' '))) { + if (($pos = strrpos($string, ' ')) !== false) { $realTableName = substr($string, 0, $pos); } @@ -2151,7 +2179,7 @@ public function quoteIdentifierTable($string) * * @param string $sql SQL clause to inspect (modified by the method) * - * @return boolean Whether the method managed to find and replace at least one column name + * @return bool Whether the method managed to find and replace at least one column name */ public function replaceNames(&$sql) { @@ -2171,6 +2199,7 @@ public function replaceNames(&$sql) switch ($char) { case '\\': $isAfterBackslash = true; + break; case "'": case '"': @@ -2184,10 +2213,11 @@ public function replaceNames(&$sql) $stringQuotes = $char; $isInString = true; } + break; } - if ('\\' !== $char) { + if ($char !== '\\') { $isAfterBackslash = false; } @@ -2226,16 +2256,17 @@ public function replaceNames(&$sql) * If no primary key is defined for the table the values will be * inserted as specified in Criteria and null will be returned. * - * @param ConnectionInterface $con A ConnectionInterface connection. - * @return mixed The primary key for the new row if the primary key is auto-generated. Otherwise will return null. + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con A ConnectionInterface connection. * * @throws \Propel\Runtime\Exception\PropelException + * + * @return mixed The primary key for the new row if the primary key is auto-generated. Otherwise will return null. */ - public function doInsert(ConnectionInterface $con = null) + public function doInsert(?ConnectionInterface $con = null) { // The primary key $id = null; - if (null === $con) { + if ($con === null) { $con = Propel::getServiceContainer()->getWriteConnection($this->getDbName()); } $db = Propel::getServiceContainer()->getAdapter($this->getDbName()); @@ -2266,10 +2297,10 @@ public function doInsert(ConnectionInterface $con = null) // pk will be null if there is no primary key defined for the table // we're inserting into. - if (null !== $pk && $useIdGen && !$this->keyContainsValue($pk->getFullyQualifiedName()) && $db->isGetIdBeforeInsert()) { + if ($pk !== null && $useIdGen && !$this->keyContainsValue($pk->getFullyQualifiedName()) && $db->isGetIdBeforeInsert()) { try { $id = $db->getId($con, $keyInfo); - } catch (\Exception $e) { + } catch (Exception $e) { throw new PropelException('Unable to get sequence id.', 0, $e); } $this->add($pk->getFullyQualifiedName(), $id); @@ -2291,7 +2322,7 @@ public function doInsert(ConnectionInterface $con = null) . ' VALUES ('; // . substr(str_repeat("?,", count($columns)), 0, -1) . for ($p = 1, $cnt = count($columns); $p <= $cnt; $p++) { - $sql .= ':p'.$p; + $sql .= ':p' . $p; if ($p !== $cnt) { $sql .= ','; } @@ -2305,18 +2336,18 @@ public function doInsert(ConnectionInterface $con = null) $stmt = $con->prepare($sql); $db->bindValues($stmt, $params, $dbMap, $db); $stmt->execute(); - - } catch (\Exception $e) { + } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } // If the primary key column is auto-incremented, get the id now. - if (null !== $pk && $useIdGen && $db->isGetIdAfterInsert()) { + if ($pk !== null && $useIdGen && $db->isGetIdAfterInsert()) { try { $id = $db->getId($con, $keyInfo); - } catch (\Exception $e) { - throw new PropelException("Unable to get autoincrement id.", 0, $e); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); } } @@ -2328,7 +2359,7 @@ public function doInsert(ConnectionInterface $con = null) * * @return \Propel\Runtime\Map\ColumnMap|null */ - public function getPrimaryKey(Criteria $criteria = null) + public function getPrimaryKey(?Criteria $criteria = null) { if (!$criteria) { $criteria = $this; @@ -2353,7 +2384,7 @@ public function getPrimaryKey(Criteria $criteria = null) } /** - * Method used to update rows in the DB. Rows are selected based + * Method used to update rows in the DB. Rows are selected based * on selectCriteria and updated using values in updateValues. *

* Use this method for performing an update of the kind: @@ -2361,20 +2392,20 @@ public function getPrimaryKey(Criteria $criteria = null) * WHERE some_column = some value AND could_have_another_column = * another value AND so on. * - * @param Criteria $updateValues A Criteria object containing values used in set clause. - * @param ConnectionInterface $con The ConnectionInterface connection object to use. + * @param \Propel\Runtime\ActiveQuery\Criteria $updateValues A Criteria object containing values used in set clause. + * @param \Propel\Runtime\Connection\ConnectionInterface $con The ConnectionInterface connection object to use. + * + * @throws \Propel\Runtime\Exception\PropelException * * @return int The number of rows affected by last update statement. * For most uses there is only one update statement executed, so this number will * correspond to the number of rows affected by the call to this method. * Note that the return value does require that this information is returned * (supported) by the Propel db driver. - * - * @throws PropelException */ public function doUpdate($updateValues, ConnectionInterface $con) { - /** @var PdoAdapter $db */ + /** @var \Propel\Runtime\Adapter\Pdo\PdoAdapter $db */ $db = Propel::getServiceContainer()->getAdapter($this->getDbName()); $dbMap = Propel::getServiceContainer()->getDatabaseMap($this->getDbName()); @@ -2400,7 +2431,6 @@ public function doUpdate($updateValues, ConnectionInterface $con) $affectedRows = 0; // initialize this in case the next loop has no iterations. foreach ($tablesColumns as $tableName => $columns) { - $whereClause = []; $params = []; $stmt = null; @@ -2419,14 +2449,14 @@ public function doUpdate($updateValues, ConnectionInterface $con) $updateTable = $tableName; } $sql .= $this->quoteIdentifierTable($updateTable); - $sql .= " SET "; + $sql .= ' SET '; $p = 1; foreach ($updateTablesColumns[$tableName] as $col) { $updateColumnName = substr($col, strrpos($col, '.') + 1); // add identifiers for the actual database? $updateColumnName = $this->quoteIdentifier($updateColumnName, $tableName); if ($updateValues->getComparison($col) != Criteria::CUSTOM_EQUAL) { - $sql .= $updateColumnName . '=:p'.$p++.', '; + $sql .= $updateColumnName . '=:p' . $p++ . ', '; } else { $param = $updateValues->get($col); $sql .= $updateColumnName . ' = '; @@ -2437,14 +2467,14 @@ public function doUpdate($updateValues, ConnectionInterface $con) // parse the $params['raw'] for ? chars for ($r = 0, $len = strlen($raw); $r < $len; $r++) { if ($raw[$r] === '?') { - $rawcvt .= ':p'.$p++; + $rawcvt .= ':p' . $p++; } else { $rawcvt .= $raw[$r]; } } $sql .= $rawcvt . ', '; } else { - $sql .= ':p'.$p++.', '; + $sql .= ':p' . $p++ . ', '; } if (isset($param['value'])) { $updateValues->put($col, $param['value']); @@ -2466,7 +2496,7 @@ public function doUpdate($updateValues, ConnectionInterface $con) $this->replaceNames($sb); $whereClause[] = $sb; } - $sql .= ' WHERE ' . implode(' AND ', $whereClause); + $sql .= ' WHERE ' . implode(' AND ', $whereClause); } $db->cleanupSQL($sql, $params, $updateValues, $dbMap); @@ -2481,15 +2511,14 @@ public function doUpdate($updateValues, ConnectionInterface $con) $affectedRows = $stmt->rowCount(); $stmt = null; // close - - } catch (\Exception $e) { + } catch (Exception $e) { if ($stmt !== null) { $stmt = null; // close } Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute UPDATE statement [%s]', $sql), 0, $e); } - } // foreach table in the criteria return $affectedRows; @@ -2501,7 +2530,7 @@ public function doUpdate($updateValues, ConnectionInterface $con) * * @return array */ - public function buildParams($columns, Criteria $values = null) + public function buildParams($columns, ?Criteria $values = null) { if (!$values) { $values = $this; @@ -2513,7 +2542,7 @@ public function buildParams($columns, Criteria $values = null) $params[] = [ 'column' => $crit->getColumn(), 'table' => $crit->getTable(), - 'value' => $crit->getValue() + 'value' => $crit->getValue(), ]; } } @@ -2526,15 +2555,16 @@ public function buildParams($columns, Criteria $values = null) * * @throws \Propel\Runtime\Exception\LogicException * @throws \Propel\Runtime\Exception\PropelException + * * @return \Propel\Runtime\DataFetcher\DataFetcherInterface */ - public function doCount(ConnectionInterface $con = null) + public function doCount(?ConnectionInterface $con = null) { $dbMap = Propel::getServiceContainer()->getDatabaseMap($this->getDbName()); /** @var \Propel\Runtime\Adapter\SqlAdapterInterface $db */ $db = Propel::getServiceContainer()->getAdapter($this->getDbName()); - if (null === $con) { + if ($con === null) { $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } @@ -2543,8 +2573,7 @@ public function doCount(ConnectionInterface $con = null) || $this->getLimit() >= 0 || $this->getHaving() || in_array(Criteria::DISTINCT, $this->getSelectModifiers()) - || count($this->selectQueries) > 0 - ; + || count($this->selectQueries) > 0; $params = []; if ($needsComplexCount) { @@ -2565,8 +2594,9 @@ public function doCount(ConnectionInterface $con = null) $stmt = $con->prepare($sql); $db->bindValues($stmt, $params, $dbMap); $stmt->execute(); - } catch (\Exception $e) { + } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute COUNT statement [%s]', $sql), 0, $e); } @@ -2602,14 +2632,15 @@ public function needsSelectAliases() * Issue a DELETE query based on the current ModelCriteria * This method is called by ModelCriteria::delete() inside a transaction * - * @param ConnectionInterface $con a connection object + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con a connection object + * + * @throws \Propel\Runtime\Exception\PropelException * - * @return int the number of deleted rows - * @throws PropelException + * @return int the number of deleted rows */ - public function doDelete(ConnectionInterface $con = null) + public function doDelete(?ConnectionInterface $con = null) { - if (null === $con) { + if ($con === null) { $con = Propel::getServiceContainer()->getWriteConnection($this->getDbName()); } @@ -2625,13 +2656,12 @@ public function doDelete(ConnectionInterface $con = null) // be executed per table) $tables = $this->getTablesColumns(); if (empty($tables)) { - throw new PropelException("Cannot delete from an empty Criteria"); + throw new PropelException('Cannot delete from an empty Criteria'); } $affectedRows = 0; // initialize this in case the next loop has no iterations. foreach ($tables as $tableName => $columns) { - $whereClause = []; $params = []; $stmt = null; @@ -2644,18 +2674,18 @@ public function doDelete(ConnectionInterface $con = null) $this->replaceNames($sb); $whereClause[] = $sb; } - $sql .= ' WHERE ' . implode(' AND ', $whereClause); + $sql .= ' WHERE ' . implode(' AND ', $whereClause); $stmt = $con->prepare($sql); $adapter->bindValues($stmt, $params, $dbMap); $stmt->execute(); $affectedRows = $stmt->rowCount(); - } catch (\Exception $e) { + } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute DELETE statement [%s]', $sql), 0, $e); } - } // for each table return $affectedRows; @@ -2664,15 +2694,15 @@ public function doDelete(ConnectionInterface $con = null) /** * Builds, binds and executes a SELECT query based on the current object. * - * @param ConnectionInterface $con A connection object - * - * @return DataFetcherInterface A dataFetcher using the connection, ready to be fetched + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con A connection object * * @throws \Propel\Runtime\Exception\PropelException + * + * @return \Propel\Runtime\DataFetcher\DataFetcherInterface A dataFetcher using the connection, ready to be fetched */ - public function doSelect(ConnectionInterface $con = null) + public function doSelect(?ConnectionInterface $con = null) { - if (null === $con) { + if ($con === null) { $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $dbMap = Propel::getServiceContainer()->getDatabaseMap($this->getDbName()); @@ -2684,11 +2714,12 @@ public function doSelect(ConnectionInterface $con = null) $stmt = $con->prepare($sql); $db->bindValues($stmt, $params, $dbMap); $stmt->execute(); - } catch (\Exception $e) { + } catch (Exception $e) { if (isset($stmt)) { $stmt = null; // close } Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), null, $e); } @@ -2724,9 +2755,9 @@ public function _and() * or a PropelConditionalProxy instance otherwise. * Allows for conditional statements in a fluid interface. * - * @param boolean $cond + * @param bool $cond * - * @return PropelConditionalProxy|$this + * @return \Propel\Runtime\Util\PropelConditionalProxy|$this */ public function _if($cond) { @@ -2739,14 +2770,16 @@ public function _if($cond) * Returns a PropelConditionalProxy instance. * Allows for conditional statements in a fluid interface. * - * @param boolean $cond ignored + * @param bool $cond ignored + * + * @throws \Propel\Runtime\Exception\LogicException * - * @return PropelConditionalProxy|$this + * @return \Propel\Runtime\Util\PropelConditionalProxy|$this */ public function _elseif($cond) { if (!$this->conditionalProxy) { - throw new LogicException(__METHOD__ .' must be called after _if()'); + throw new LogicException(__METHOD__ . ' must be called after _if()'); } return $this->conditionalProxy->_elseif($cond); @@ -2756,12 +2789,14 @@ public function _elseif($cond) * Returns a PropelConditionalProxy instance. * Allows for conditional statements in a fluid interface. * - * @return PropelConditionalProxy|$this + * @throws \Propel\Runtime\Exception\LogicException + * + * @return \Propel\Runtime\Util\PropelConditionalProxy|$this */ public function _else() { if (!$this->conditionalProxy) { - throw new LogicException(__METHOD__ .' must be called after _if()'); + throw new LogicException(__METHOD__ . ' must be called after _if()'); } return $this->conditionalProxy->_else(); @@ -2771,12 +2806,14 @@ public function _else() * Returns the current object * Allows for conditional statements in a fluid interface. * + * @throws \Propel\Runtime\Exception\LogicException + * * @return $this */ public function _endif() { if (!$this->conditionalProxy) { - throw new LogicException(__METHOD__ .' must be called after _if()'); + throw new LogicException(__METHOD__ . ' must be called after _if()'); } $this->conditionalProxy = $this->conditionalProxy->getParentProxy(); @@ -2791,6 +2828,7 @@ public function _endif() /** * Ensures deep cloning of attached objects + * * @return void */ public function __clone() @@ -2803,13 +2841,13 @@ public function __clone() $this->joins[$key] = clone $join; } - if (null !== $this->having) { + if ($this->having !== null) { $this->having = clone $this->having; } } /** - * @return boolean + * @return bool */ public function isIdentifierQuotingEnabled() { @@ -2817,12 +2855,12 @@ public function isIdentifierQuotingEnabled() } /** - * @param boolean $identifierQuoting + * @param bool $identifierQuoting + * * @return void */ public function setIdentifierQuoting($identifierQuoting) { $this->identifierQuoting = $identifierQuoting; } - } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php index cff66f0642..e2a96b5ff0 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php @@ -10,11 +10,11 @@ namespace Propel\Runtime\ActiveQuery\Criterion; -use Propel\Runtime\Propel; +use Exception; use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Adapter\AdapterInterface; use Propel\Runtime\Map\ColumnMap; +use Propel\Runtime\Propel; /** * This is an "inner" class that describes an object in the criteria. @@ -25,32 +25,36 @@ */ abstract class AbstractCriterion { - const UND = " AND "; - const ODER = " OR "; + public const UND = ' AND '; + public const ODER = ' OR '; + - /** Value of the criterion */ protected $value; /** * Comparison value. + * * @var string */ protected $comparison; /** * Table name + * * @var string|null */ protected $table; /** * Real table name + * * @var string */ protected $realtable; /** * Column name + * * @var string */ protected $column; @@ -58,18 +62,22 @@ abstract class AbstractCriterion /** * The DBAdapter which might be used to get db specific * variations of sql. + * + * @var \Propel\Runtime\Adapter\AdapterInterface */ protected $db; /** * Other connected criterions - * @var AbstractCriterion[] + * + * @var \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion[] */ protected $clauses = []; /** * Operators for connected criterions * Only self::UND and self::ODER are accepted + * * @var string[] */ protected $conjunctions = []; @@ -77,22 +85,24 @@ abstract class AbstractCriterion /** * Create a new instance. * - * @param Criteria $outer The outer class (this is an "inner" class). - * @param string $column TABLE.COLUMN format. - * @param mixed $value - * @param string|null $comparison + * @param \Propel\Runtime\ActiveQuery\Criteria $outer The outer class (this is an "inner" class). + * @param string $column TABLE.COLUMN format. + * @param mixed $value + * @param string|null $comparison */ public function __construct(Criteria $outer, $column, $value, $comparison = null) { $this->value = $value; $this->setColumn($column); - $this->comparison = (null === $comparison) ? Criteria::EQUAL : $comparison; + $this->comparison = ($comparison === null) ? Criteria::EQUAL : $comparison; $this->init($outer); } /** * Init some properties with the help of outer class - * @param Criteria $criteria The outer class + * + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria The outer class + * * @return void */ public function init(Criteria $criteria) @@ -100,10 +110,10 @@ public function init(Criteria $criteria) try { $db = Propel::getServiceContainer()->getAdapter($criteria->getDbName()); $this->setAdapter($db); - } catch (\Exception $e) { + } catch (Exception $e) { // we are only doing this to allow easier debugging, so // no need to throw up the exception, just make note of it. - Propel::log("Could not get a AdapterInterface, sql may be wrong", Propel::LOG_ERR); + Propel::log('Could not get a AdapterInterface, sql may be wrong', Propel::LOG_ERR); } // init $this->realtable @@ -113,6 +123,7 @@ public function init(Criteria $criteria) /** * Set the $column and $table properties based on a column name or object + * * @return void */ protected function setColumn($column) @@ -146,7 +157,8 @@ public function getColumn() /** * Set the table name. * - * @param string $name A String with the table name. + * @param string $name A String with the table name. + * * @return void */ public function setTable($name) @@ -189,7 +201,8 @@ public function getValue() * * The AdapterInterface which might be used to get db specific * variations of sql. - * @return AdapterInterface value of db. + * + * @return \Propel\Runtime\Adapter\AdapterInterface value of db. */ public function getAdapter() { @@ -200,7 +213,9 @@ public function getAdapter() * Set the adapter. * * The AdapterInterface might be used to get db specific variations of sql. - * @param AdapterInterface $v Value to assign to db. + * + * @param \Propel\Runtime\Adapter\AdapterInterface $v Value to assign to db. + * * @return void */ public function setAdapter(AdapterInterface $v) @@ -213,6 +228,7 @@ public function setAdapter(AdapterInterface $v) /** * Get the list of clauses in this Criterion. + * * @return self[] */ public function getClauses() @@ -222,6 +238,7 @@ public function getClauses() /** * Get the list of conjunctions in this Criterion + * * @return array */ public function getConjunctions() @@ -232,7 +249,8 @@ public function getConjunctions() /** * Append an AND Criterion onto this Criterion's list. * - * @param AbstractCriterion $criterion + * @param \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion $criterion + * * @return $this */ public function addAnd(AbstractCriterion $criterion) @@ -246,7 +264,8 @@ public function addAnd(AbstractCriterion $criterion) /** * Append an OR Criterion onto this Criterion's list. * - * @param AbstractCriterion $criterion + * @param \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion $criterion + * * @return $this */ public function addOr(AbstractCriterion $criterion) @@ -261,16 +280,18 @@ public function addOr(AbstractCriterion $criterion) * Appends a Prepared Statement representation of the Criterion * onto the buffer. * - * @param string $sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended + * @param string $sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * * @return void - * @throws PropelException - if the expression builder cannot figure out how to turn a specified + * * expression into proper SQL. */ public function appendPsTo(&$sb, array &$params) { if (!$this->clauses) { $this->appendPsForUniqueClauseTo($sb, $params); + return; } @@ -293,14 +314,15 @@ public function __toString() $params = []; $this->appendPsTo($sb, $params); - return "" . $sb; + return '' . $sb; } /** * Appends a Prepared Statement representation of the Criterion onto the buffer * - * @param string $sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended + * @param string $sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * * @return void */ abstract protected function appendPsForUniqueClauseTo(&$sb, array &$params); @@ -308,7 +330,8 @@ abstract protected function appendPsForUniqueClauseTo(&$sb, array &$params); /** * This method checks another Criteria to see if they contain * the same attributes and hashtable entries. - * @return boolean + * + * @return bool */ public function equals($obj) { @@ -317,16 +340,16 @@ public function equals($obj) return true; } - if ((null === $obj) || !($obj instanceof AbstractCriterion)) { + if (($obj === null) || !($obj instanceof AbstractCriterion)) { return false; } - /** @var AbstractCriterion $crit */ + /** @var \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion $crit */ $crit = $obj; $isEquiv = ( - ((null === $this->table && null === $crit->getTable()) - || (null !== $this->table && $this->table === $crit->getTable())) + (($this->table === null && $crit->getTable() === null) + || ($this->table !== null && $this->table === $crit->getTable())) && $this->column === $crit->getColumn() && $this->comparison === $crit->getComparison() ); @@ -351,6 +374,7 @@ public function equals($obj) /** * Get all tables from nested criterion objects + * * @return array */ public function getAllTables() @@ -364,6 +388,7 @@ public function getAllTables() /** * method supporting recursion through all criterions to give * us a string array of tables from each criterion + * * @return void */ private function addCriterionTable(AbstractCriterion $c, array &$s) @@ -377,7 +402,8 @@ private function addCriterionTable(AbstractCriterion $c, array &$s) /** * get an array of all criterion attached to this * recursing through all sub criterion - * @return AbstractCriterion[] + * + * @return \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion[] */ public function getAttachedCriterion() { @@ -391,6 +417,7 @@ public function getAttachedCriterion() /** * Ensures deep cloning of attached objects + * * @return void */ public function __clone() diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php index a67cfbec1a..8faf098d30 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php @@ -11,25 +11,24 @@ namespace Propel\Runtime\ActiveQuery\Criterion; use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\Map\ColumnMap; /** * This is an "inner" class that describes an object in the criteria. * * @author Francois */ -Abstract class AbstractModelCriterion extends AbstractCriterion +abstract class AbstractModelCriterion extends AbstractCriterion { protected $clause = ''; /** * Create a new instance. * - * @param Criteria $outer The outer class (this is an "inner" class). - * @param string $clause A simple pseudo-SQL clause, e.g. 'foo.BAR LIKE ?' - * @param ColumnMap $column A Column object to help escaping the value - * @param mixed $value - * @param string|null $tableAlias optional table alias + * @param \Propel\Runtime\ActiveQuery\Criteria $outer The outer class (this is an "inner" class). + * @param string $clause A simple pseudo-SQL clause, e.g. 'foo.BAR LIKE ?' + * @param \Propel\Runtime\Map\ColumnMap $column A Column object to help escaping the value + * @param mixed $value + * @param string|null $tableAlias optional table alias */ public function __construct(Criteria $outer, $clause, $column, $value = null, $tableAlias = null) { @@ -53,7 +52,10 @@ public function getClause() /** * This method checks another Criteria to see if they contain * the same attributes and hashtable entries. - * @return boolean + * + * @param object|null $obj + * + * @return bool */ public function equals($obj) { @@ -62,17 +64,17 @@ public function equals($obj) return true; } - if (null === $obj || !($obj instanceof AbstractModelCriterion)) { + if ($obj === null || !($obj instanceof AbstractModelCriterion)) { return false; } - /** @var AbstractModelCriterion $crit */ + /** @var \Propel\Runtime\ActiveQuery\Criterion\AbstractModelCriterion $crit */ $crit = $obj; $isEquiv = ( ( - (null === $this->table && null === $crit->getTable()) - || (null !== $this->table && $crit->getTable() === $this->table) + ($this->table === null && $crit->getTable() === null) + || ($this->table !== null && $crit->getTable() === $this->table) ) && $this->clause === $crit->getClause() && $this->column === $crit->getColumn() diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php index bbea6fbde2..893b2b7ead 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php @@ -10,8 +10,8 @@ namespace Propel\Runtime\ActiveQuery\Criterion; -use Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException; /** * Specialized Criterion used for traditional expressions, @@ -19,16 +19,15 @@ */ class BasicCriterion extends AbstractCriterion { - /** flag to ignore case in comparison */ protected $ignoreStringCase = false; /** * Create a new instance. * - * @param Criteria $outer The outer class (this is an "inner" class). - * @param string $column ignored - * @param string $value The condition to be added to the query string - * @param string $comparison One of Criteria::LIKE and Criteria::NOT_LIKE + * @param \Propel\Runtime\ActiveQuery\Criteria $outer The outer class (this is an "inner" class). + * @param string $column ignored + * @param string $value The condition to be added to the query string + * @param string $comparison One of Criteria::LIKE and Criteria::NOT_LIKE */ public function __construct(Criteria $outer, $column, $value, $comparison = Criteria::EQUAL) { @@ -38,12 +37,13 @@ public function __construct(Criteria $outer, $column, $value, $comparison = Crit /** * Sets ignore case. * - * @param boolean $b True if case should be ignored. + * @param bool $b True if case should be ignored. + * * @return $this A modified Criterion object. */ public function setIgnoreCase($b) { - $this->ignoreStringCase = (bool) $b; + $this->ignoreStringCase = (bool)$b; return $this; } @@ -51,7 +51,7 @@ public function setIgnoreCase($b) /** * Is ignore case on or off? * - * @return boolean True if case is ignored. + * @return bool True if case is ignored. */ public function isIgnoreCase() { @@ -61,40 +61,39 @@ public function isIgnoreCase() /** * Appends a Prepared Statement representation of the Criterion onto the buffer * - * @param string $sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended + * @param string $sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * + * @throws \Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException + * * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { - $field = (null === $this->table) ? $this->column : $this->table . '.' . $this->column; + $field = ($this->table === null) ? $this->column : $this->table . '.' . $this->column; // NULL VALUES need special treatment because the SQL syntax is different // i.e. table.column IS NULL rather than table.column = null if ($this->value !== null) { - // ANSI SQL functions get inserted right into SQL (not escaped, etc.) - if (Criteria::CURRENT_DATE === $this->value || Criteria::CURRENT_TIME === $this->value || Criteria::CURRENT_TIMESTAMP === $this->value) { + if ($this->value === Criteria::CURRENT_DATE || $this->value === Criteria::CURRENT_TIME || $this->value === Criteria::CURRENT_TIMESTAMP) { $sb .= $field . $this->comparison . $this->value; } else { - $params[] = ['table' => $this->realtable, 'column' => $this->column, 'value' => $this->value]; // default case, it is a normal col = value expression; value // will be replaced w/ '?' and will be inserted later using PDO bindValue() if ($this->ignoreStringCase) { - $sb .= $this->getAdapter()->ignoreCase($field) . $this->comparison . $this->getAdapter()->ignoreCase(':p'.count($params)); + $sb .= $this->getAdapter()->ignoreCase($field) . $this->comparison . $this->getAdapter()->ignoreCase(':p' . count($params)); } else { - $sb .= $field . $this->comparison . ':p'.count($params); + $sb .= $field . $this->comparison . ':p' . count($params); } - } } else { - // value is null, which means it was either not specified or specifically // set to null. - if (Criteria::EQUAL === $this->comparison || Criteria::ISNULL === $this->comparison) { + if ($this->comparison === Criteria::EQUAL || $this->comparison === Criteria::ISNULL) { $sb .= $field . Criteria::ISNULL; - } elseif (Criteria::NOT_EQUAL === $this->comparison || Criteria::ISNOTNULL === $this->comparison) { + } elseif ($this->comparison === Criteria::NOT_EQUAL || $this->comparison === Criteria::ISNOTNULL) { $sb .= $field . Criteria::ISNOTNULL; } else { // for now throw an exception, because not sure how to interpret this @@ -102,5 +101,4 @@ protected function appendPsForUniqueClauseTo(&$sb, array &$params) } } } - } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php index 46533fb2a6..8eb24a5616 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BasicModelCriterion.php @@ -21,25 +21,27 @@ class BasicModelCriterion extends AbstractModelCriterion /** * Appends a Prepared Statement representation of the ModelCriterion onto the buffer * - * @param string $sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended + * @param string $sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * + * @throws \Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException + * * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { - if (null !== $this->value) { - if (false === strpos($this->clause, '?')) { + if ($this->value !== null) { + if (strpos($this->clause, '?') === false) { throw new InvalidClauseException('A clause must contain a question mark in order to be bound to a value'); } $params[] = [ - 'table' => $this->realtable, + 'table' => $this->realtable, 'column' => $this->column, - 'value' => $this->value + 'value' => $this->value, ]; - $sb .= str_replace('?', ':p'.count($params), $this->clause); + $sb .= str_replace('?', ':p' . count($params), $this->clause); } else { $sb .= $this->clause; } } - } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php index 1518160d6b..6179bef733 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryCriterion.php @@ -17,14 +17,13 @@ */ class BinaryCriterion extends AbstractCriterion { - /** * Create a new instance. * - * @param Criteria $outer The outer class (this is an "inner" class). - * @param string $column ignored - * @param string $value The condition to be added to the query string - * @param string $comparison One of Criteria::BINARY_NONE, Criteria::BINARY_ALL + * @param \Propel\Runtime\ActiveQuery\Criteria $outer The outer class (this is an "inner" class). + * @param string $column ignored + * @param string $value The condition to be added to the query string + * @param string $comparison One of Criteria::BINARY_NONE, Criteria::BINARY_ALL */ public function __construct(Criteria $outer, $column, $value, $comparison = Criteria::BINARY_ALL) { @@ -34,8 +33,9 @@ public function __construct(Criteria $outer, $column, $value, $comparison = Crit /** * Appends a Prepared Statement representation of the Criterion onto the buffer * - * @param string $sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended + * @param string $sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) @@ -58,5 +58,4 @@ protected function appendPsForUniqueClauseTo(&$sb, array &$params) $sb .= $this->comparison === Criteria::BINARY_ALL ? '1<>1' : '1=1'; } } - } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php index 8b09120827..85c4728c2c 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BinaryModelCriterion.php @@ -18,8 +18,9 @@ class BinaryModelCriterion extends AbstractModelCriterion /** * Appends a Prepared Statement representation of the ModelCriterion onto the buffer * - * @param string $sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended + * @param string $sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php index ca83a3792a..35d3f042d7 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php @@ -20,8 +20,8 @@ class CustomCriterion extends AbstractCriterion /** * Create a new instance. * - * @param Criteria $outer The outer class (this is an "inner" class). - * @param string $value The condition to be added to the query string + * @param \Propel\Runtime\ActiveQuery\Criteria $outer The outer class (this is an "inner" class). + * @param string $value The condition to be added to the query string */ public function __construct(Criteria $outer, $value) { @@ -32,15 +32,15 @@ public function __construct(Criteria $outer, $value) /** * Appends a Prepared Statement representation of the Criterion onto the buffer * - * @param string $sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended + * @param string $sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { - if ('' !== $this->value) { - $sb .= (string) $this->value; + if ($this->value !== '') { + $sb .= (string)$this->value; } } - } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php index 2ecd53514d..a8ff541374 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/InCriterion.php @@ -11,20 +11,20 @@ namespace Propel\Runtime\ActiveQuery\Criterion; use Propel\Runtime\ActiveQuery\Criteria; +use Traversable; /** * Specialized Criterion used for IN expressions, e.g. table.column IN (?, ?) or table.column NOT IN (?, ?) */ class InCriterion extends AbstractCriterion { - /** * Create a new instance. * - * @param Criteria $outer The outer class (this is an "inner" class). - * @param string $column ignored - * @param string $value The condition to be added to the query string - * @param string $comparison One of Criteria::IN and Criteria::NOT_IN + * @param \Propel\Runtime\ActiveQuery\Criteria $outer The outer class (this is an "inner" class). + * @param string $column ignored + * @param string $value The condition to be added to the query string + * @param string $comparison One of Criteria::IN and Criteria::NOT_IN */ public function __construct(Criteria $outer, $column, $value, $comparison = Criteria::IN) { @@ -34,15 +34,16 @@ public function __construct(Criteria $outer, $column, $value, $comparison = Crit /** * Appends a Prepared Statement representation of the Criterion onto the buffer * - * @param string $sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended + * @param string $sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { $bindParams = []; $index = count($params); // to avoid counting the number of parameters for each element in the array - $values = ($this->value instanceof \Traversable) ? iterator_to_array($this->value) : (array) $this->value; + $values = ($this->value instanceof Traversable) ? iterator_to_array($this->value) : (array)$this->value; foreach ($values as $value) { $params[] = ['table' => $this->realtable, 'column' => $this->column, 'value' => $value]; $index++; // increment this first to correct for wanting bind params to start with :p1 @@ -52,8 +53,7 @@ protected function appendPsForUniqueClauseTo(&$sb, array &$params) $field = ($this->table === null) ? $this->column : $this->table . '.' . $this->column; $sb .= $field . $this->comparison . '(' . implode(',', $bindParams) . ')'; } else { - $sb .= (Criteria::IN === $this->comparison) ? '1<>1' : '1=1'; + $sb .= ($this->comparison === Criteria::IN) ? '1<>1' : '1=1'; } } - } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php index 07804e8a5c..05e7a236b1 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/InModelCriterion.php @@ -10,6 +10,8 @@ namespace Propel\Runtime\ActiveQuery\Criterion; +use Traversable; + /** * Specialized ModelCriterion used for IN or NOT IN model clauses, * e.g. 'book.TITLE NOT IN ?' @@ -19,20 +21,21 @@ class InModelCriterion extends AbstractModelCriterion /** * Appends a Prepared Statement representation of the ModelCriterion onto the buffer * - * @param string $sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended + * @param string $sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { $bindParams = []; // the param names used in query building $index = count($params); - $values = ($this->value instanceof \Traversable) ? iterator_to_array($this->value) : (array) $this->value; + $values = ($this->value instanceof Traversable) ? iterator_to_array($this->value) : (array)$this->value; foreach ($values as $value) { $params[] = [ - 'table' => $this->realtable, + 'table' => $this->realtable, 'column' => $this->column, - 'value' => $value + 'value' => $value, ]; $index++; // increment this first to correct for wanting bind params to start with :p1 $bindParams[] = ':p' . $index; @@ -40,7 +43,7 @@ protected function appendPsForUniqueClauseTo(&$sb, array &$params) if (count($bindParams)) { $sb .= str_replace('?', '(' . implode(',', $bindParams) . ')', $this->clause); } else { - $sb .= (stripos($this->clause, ' NOT IN ') === false) ? "1<>1" : "1=1"; + $sb .= (stripos($this->clause, ' NOT IN ') === false) ? '1<>1' : '1=1'; } } } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php index fd9e68ead6..b72a0ab790 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php @@ -15,20 +15,19 @@ /** * Specialized Criterion used for LIKE expressions - * e.g. table.column LIKE ? or table.column NOT LIKE ? (or ILIKE for Postgres) + * e.g. table.column LIKE ? or table.column NOT LIKE ? (or ILIKE for Postgres) */ class LikeCriterion extends AbstractCriterion { - /** flag to ignore case in comparison */ protected $ignoreStringCase = false; /** * Create a new instance. * - * @param Criteria $outer The outer class (this is an "inner" class). - * @param string $column ignored - * @param string $value The condition to be added to the query string - * @param string $comparison One of Criteria::LIKE and Criteria::NOT_LIKE + * @param \Propel\Runtime\ActiveQuery\Criteria $outer The outer class (this is an "inner" class). + * @param string $column ignored + * @param string $value The condition to be added to the query string + * @param string $comparison One of Criteria::LIKE and Criteria::NOT_LIKE */ public function __construct(Criteria $outer, $column, $value, $comparison = Criteria::LIKE) { @@ -38,12 +37,13 @@ public function __construct(Criteria $outer, $column, $value, $comparison = Crit /** * Sets ignore case. * - * @param boolean $b True if case should be ignored. + * @param bool $b True if case should be ignored. + * * @return $this A modified Criterion object. */ public function setIgnoreCase($b) { - $this->ignoreStringCase = (bool) $b; + $this->ignoreStringCase = (bool)$b; return $this; } @@ -51,7 +51,7 @@ public function setIgnoreCase($b) /** * Is ignore case on or off? * - * @return boolean True if case is ignored. + * @return bool True if case is ignored. */ public function isIgnoreCase() { @@ -61,21 +61,22 @@ public function isIgnoreCase() /** * Appends a Prepared Statement representation of the Criterion onto the buffer * - * @param string $sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended + * @param string $sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { - $field = (null === $this->table) ? $this->column : $this->table . '.' . $this->column; + $field = ($this->table === null) ? $this->column : $this->table . '.' . $this->column; $db = $this->getAdapter(); // If selection is case insensitive use ILIKE for PostgreSQL or SQL // UPPER() function on column name for other databases. if ($this->ignoreStringCase) { if ($db instanceof PgsqlAdapter) { - if (Criteria::LIKE === $this->comparison) { + if ($this->comparison === Criteria::LIKE) { $this->comparison = Criteria::ILIKE; - } elseif (Criteria::NOT_LIKE === $this->comparison) { + } elseif ($this->comparison === Criteria::NOT_LIKE) { $this->comparison = Criteria::NOT_ILIKE; } } else { @@ -90,10 +91,9 @@ protected function appendPsForUniqueClauseTo(&$sb, array &$params) // If selection is case insensitive use SQL UPPER() function // on criteria or, if Postgres we are using ILIKE, so not necessary. if ($this->ignoreStringCase && !($db instanceof PgsqlAdapter)) { - $sb .= $db->ignoreCase(':p'.count($params)); + $sb .= $db->ignoreCase(':p' . count($params)); } else { - $sb .= ':p'.count($params); + $sb .= ':p' . count($params); } } - } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php index a3853a3d35..8f4b44dc0e 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php @@ -19,18 +19,18 @@ */ class LikeModelCriterion extends BasicModelCriterion { - /** flag to ignore case in comparison */ protected $ignoreStringCase = false; /** * Sets ignore case. * - * @param boolean $b True if case should be ignored. + * @param bool $b True if case should be ignored. + * * @return $this A modified Criterion object. */ public function setIgnoreCase($b) { - $this->ignoreStringCase = (bool) $b; + $this->ignoreStringCase = (bool)$b; return $this; } @@ -38,7 +38,7 @@ public function setIgnoreCase($b) /** * Is ignore case on or off? * - * @return boolean True if case is ignored. + * @return bool True if case is ignored. */ public function isIgnoreCase() { @@ -49,8 +49,11 @@ public function isIgnoreCase() * Appends a Prepared Statement representation of the ModelCriterion onto the buffer * Handles case insensitivity for VARCHAR columns * - * @param string $sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended + * @param string $sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * + * @throws \Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException + * * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) @@ -66,5 +69,4 @@ protected function appendPsForUniqueClauseTo(&$sb, array &$params) } parent::appendPsForUniqueClauseTo($sb, $params); } - } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php index 50202be91c..19f3fc6c54 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/RawCriterion.php @@ -10,19 +10,18 @@ namespace Propel\Runtime\ActiveQuery\Criterion; -use Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException; +use PDO; use Propel\Runtime\ActiveQuery\Criteria; - -use \PDO; +use Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException; /** * Specialized Criterion used for custom expressions with a typed binding, e.g. 'foobar = ?' */ class RawCriterion extends AbstractCriterion { - /** * Binding type to be used for Criteria::RAW comparison + * * @var int Any of the PDO::PARAM_ constant values */ protected $type; @@ -30,10 +29,10 @@ class RawCriterion extends AbstractCriterion /** * Create a new instance. * - * @param Criteria $outer The outer class (this is an "inner" class). - * @param string $column ignored - * @param string $value The condition to be added to the query string - * @param int $type A PDO type constant, e.g. PDO::PARAM_STR + * @param \Propel\Runtime\ActiveQuery\Criteria $outer The outer class (this is an "inner" class). + * @param string $column ignored + * @param string $value The condition to be added to the query string + * @param int $type A PDO type constant, e.g. PDO::PARAM_STR */ public function __construct(Criteria $outer, $column, $value, $type = PDO::PARAM_STR) { @@ -46,17 +45,19 @@ public function __construct(Criteria $outer, $column, $value, $type = PDO::PARAM /** * Appends a Prepared Statement representation of the Criterion onto the buffer * - * @param string $sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended + * @param string $sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * + * @throws \Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException + * * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { - if (1 !== substr_count($this->column, '?')) { + if (substr_count($this->column, '?') !== 1) { throw new InvalidClauseException(sprintf('Could not build SQL for expression "%s" because Criteria::RAW works only with a clause containing a single question mark placeholder', $this->column)); } $params[] = ['table' => null, 'type' => $this->type, 'value' => $this->value]; $sb .= str_replace('?', ':p' . count($params), $this->column); } - } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php index 1af8296311..27d60b3e2d 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/RawModelCriterion.php @@ -10,11 +10,9 @@ namespace Propel\Runtime\ActiveQuery\Criterion; -use Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException; +use PDO; use Propel\Runtime\ActiveQuery\Criteria; - -use \PDO; -use Propel\Runtime\Map\ColumnMap; +use Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException; /** * Specialized ModelCriterion used for custom expressions with a typed binding, @@ -24,6 +22,7 @@ class RawModelCriterion extends AbstractModelCriterion { /** * Binding type to be used for Criteria::RAW comparison + * * @var int Any of the PDO::PARAM_ constant values */ protected $type; @@ -31,12 +30,12 @@ class RawModelCriterion extends AbstractModelCriterion /** * Create a new instance. * - * @param Criteria $outer The outer class (this is an "inner" class). - * @param string $clause A simple pseudo-SQL clause, e.g. 'foo.BAR LIKE ?' - * @param ColumnMap $column A Column object to help escaping the value - * @param mixed $value - * @param string $tableAlias optional table alias - * @param int $type A PDO type constant, e.g. PDO::PARAM_STR + * @param \Propel\Runtime\ActiveQuery\Criteria $outer The outer class (this is an "inner" class). + * @param string $clause A simple pseudo-SQL clause, e.g. 'foo.BAR LIKE ?' + * @param \Propel\Runtime\Map\ColumnMap $column A Column object to help escaping the value + * @param mixed $value + * @param string|null $tableAlias optional table alias + * @param int $type A PDO type constant, e.g. PDO::PARAM_STR */ public function __construct(Criteria $outer, $clause, $column, $value = null, $tableAlias = null, $type = PDO::PARAM_STR) { @@ -47,21 +46,23 @@ public function __construct(Criteria $outer, $clause, $column, $value = null, $t /** * Appends a Prepared Statement representation of the ModelCriterion onto the buffer * - * @param string $sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended + * @param string $sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * + * @throws \Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException + * * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) { - if (1 !== substr_count($this->clause, '?')) { + if (substr_count($this->clause, '?') !== 1) { throw new InvalidClauseException(sprintf('Could not build SQL for expression "%s" because Criteria::MODEL_CLAUSE_RAW works only with a clause containing a single question mark placeholder', $this->column)); } $params[] = [ 'table' => null, - 'type' => $this->type, - 'value' => $this->value + 'type' => $this->type, + 'value' => $this->value, ]; $sb .= str_replace('?', ':p' . count($params), $this->clause); } - } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php index ea486493e9..afbd54d39e 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/SeveralModelCriterion.php @@ -20,8 +20,11 @@ class SeveralModelCriterion extends AbstractModelCriterion /** * Appends a Prepared Statement representation of the ModelCriterion onto the buffer * - * @param string $sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended + * @param string $sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * + * @throws \Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException + * * @return void */ protected function appendPsForUniqueClauseTo(&$sb, array &$params) @@ -31,18 +34,18 @@ protected function appendPsForUniqueClauseTo(&$sb, array &$params) } $clause = $this->clause; foreach ($this->value as $value) { - if (null === $value) { + if ($value === null) { // FIXME we eventually need to translate a BETWEEN to // something like WHERE (col < :p1 OR :p1 IS NULL) AND (col < :p2 OR :p2 IS NULL) // in order to support null values throw new InvalidValueException('Null values are not supported inside BETWEEN clauses'); } $params[] = [ - 'table' => $this->realtable, + 'table' => $this->realtable, 'column' => $this->column, - 'value' => $value + 'value' => $value, ]; - $clause = self::strReplaceOnce('?', ':p'.count($params), $clause); + $clause = self::strReplaceOnce('?', ':p' . count($params), $clause); } $sb .= $clause; } @@ -60,11 +63,11 @@ protected function appendPsForUniqueClauseTo(&$sb, array &$params) protected static function strReplaceOnce($search, $replace, $subject) { $firstChar = strpos($subject, $search); - if (false !== $firstChar) { + if ($firstChar !== false) { $beforeStr = substr($subject, 0, $firstChar); $afterStr = substr($subject, $firstChar + strlen($search)); - return $beforeStr.$replace.$afterStr; + return $beforeStr . $replace . $afterStr; } return $subject; diff --git a/src/Propel/Runtime/ActiveQuery/InstancePoolTrait.php b/src/Propel/Runtime/ActiveQuery/InstancePoolTrait.php index 5ff32bf89f..8fea5348fd 100644 --- a/src/Propel/Runtime/ActiveQuery/InstancePoolTrait.php +++ b/src/Propel/Runtime/ActiveQuery/InstancePoolTrait.php @@ -10,6 +10,7 @@ namespace Propel\Runtime\ActiveQuery; +use Countable; use Propel\Runtime\Propel; trait InstancePoolTrait @@ -28,7 +29,7 @@ trait InstancePoolTrait public static function addInstanceToPool($object, $key = null) { if (Propel::isInstancePoolingEnabled()) { - if (null === $key) { + if ($key === null) { $key = static::getInstanceKey($object); } @@ -45,17 +46,19 @@ public static function getInstanceKey($value) { if (!($value instanceof Criteria) && is_object($value)) { $pk = $value->getPrimaryKey(); - if (((is_array($pk) || $pk instanceof \Countable) && count($pk) > 1) - || is_object($pk)) { + if ( + ((is_array($pk) || $pk instanceof Countable) && count($pk) > 1) + || is_object($pk) + ) { $pk = serialize($pk); } - return (string) $pk; + return (string)$pk; } if (is_scalar($value)) { // assume we've been passed a primary key - return (string) $value; + return (string)$value; } } @@ -66,7 +69,7 @@ public static function getInstanceKey($value) */ public static function removeInstanceFromPool($value) { - if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (Propel::isInstancePoolingEnabled() && $value !== null) { $key = static::getInstanceKey($value); if ($key) { unset(self::$instances[$key]); diff --git a/src/Propel/Runtime/ActiveQuery/Join.php b/src/Propel/Runtime/ActiveQuery/Join.php index 9b2f1f3055..f5ab0d0f8e 100644 --- a/src/Propel/Runtime/ActiveQuery/Join.php +++ b/src/Propel/Runtime/ActiveQuery/Join.php @@ -33,13 +33,14 @@ class Join { // default comparison type - const EQUAL = '='; - const INNER_JOIN = 'INNER JOIN'; + public const EQUAL = '='; + public const INNER_JOIN = 'INNER JOIN'; // the left parts of the join condition protected $left = []; protected $leftValues = []; + protected $rightValues = []; // the right parts of the join condition @@ -72,7 +73,7 @@ class Join protected $joinCondition; /** - * @var boolean + * @var bool */ protected $identifierQuoting = false; @@ -81,16 +82,16 @@ class Join * Use it preferably with no arguments, and then use addCondition() and setJoinType() * Syntax with arguments used mainly for backwards compatibility * - * @param string|array|null $leftColumn The left column of the join condition + * @param string|array|null $leftColumn The left column of the join condition * (may contain an alias name) * @param string|array|null $rightColumn The right column of the join condition * (may contain an alias name) - * @param string|null $joinType The type of the join. Valid join types are null (implicit join), + * @param string|null $joinType The type of the join. Valid join types are null (implicit join), * Criteria::LEFT_JOIN, Criteria::RIGHT_JOIN, and Criteria::INNER_JOIN */ public function __construct($leftColumn = null, $rightColumn = null, $joinType = null) { - if (null !== $leftColumn) { + if ($leftColumn !== null) { if (is_array($leftColumn)) { // join with multiple conditions $this->addConditions($leftColumn, $rightColumn); @@ -100,7 +101,7 @@ public function __construct($leftColumn = null, $rightColumn = null, $joinType = } } - if (null !== $joinType) { + if ($joinType !== null) { $this->setJoinType($joinType); } } @@ -109,23 +110,24 @@ public function __construct($leftColumn = null, $rightColumn = null, $joinType = * Join condition definition. * Warning: doesn't support table aliases. Use the explicit methods to use aliases. * - * @param string $left The left column of the join condition + * @param string $left The left column of the join condition * (may contain an alias name) - * @param string $right The right column of the join condition + * @param string $right The right column of the join condition * (may contain an alias name) * @param string $operator The comparison operator of the join condition, default Join::EQUAL + * * @return void */ public function addCondition($left, $right, $operator = self::EQUAL) { if (strrpos($left, '.')) { - list($this->leftTableName, $this->left[]) = explode('.', $left); + [$this->leftTableName, $this->left[]] = explode('.', $left); } else { $this->left[] = $left; } if (strrpos($right, '.')) { - list($this->rightTableName, $this->right[]) = explode('.', $right); + [$this->rightTableName, $this->right[]] = explode('.', $right); } else { $this->right[] = $right; } @@ -139,10 +141,12 @@ public function addCondition($left, $right, $operator = self::EQUAL) /** * Join condition definition, for several conditions * - * @param array $lefts The left columns of the join condition - * @param array $rights The right columns of the join condition + * @param array $lefts The left columns of the join condition + * @param array $rights The right columns of the join condition * @param string[] $operators The comparison operators of the join condition, default Join::EQUAL + * * @throws \Propel\Runtime\Exception\LogicException + * * @return void */ public function addConditions($lefts, $rights, $operators = []) @@ -158,6 +162,7 @@ public function addConditions($lefts, $rights, $operators = []) /** * Join condition definition. + * * @example * * $join = new Join(); @@ -169,11 +174,12 @@ public function addConditions($lefts, $rights, $operators = []) * * @param string $leftTableName * @param string $leftColumnName - * @param string $leftTableAlias - * @param string $rightTableName - * @param string $rightColumnName - * @param string $rightTableAlias - * @param string $operator The comparison operator of the join condition, default Join::EQUAL + * @param string|null $leftTableAlias + * @param string|null $rightTableName + * @param string|null $rightColumnName + * @param string|null $rightTableAlias + * @param string $operator The comparison operator of the join condition, default Join::EQUAL + * * @return void */ public function addExplicitCondition( @@ -186,8 +192,8 @@ public function addExplicitCondition( $operator = self::EQUAL ) { $this->leftTableName = $leftTableName; - $this->leftTableAlias = $leftTableAlias; - $this->rightTableName = $rightTableName; + $this->leftTableAlias = $leftTableAlias; + $this->rightTableName = $rightTableName; $this->rightTableAlias = $rightTableAlias; $this->left[] = $leftColumnName; $this->leftValues[] = null; @@ -200,15 +206,16 @@ public function addExplicitCondition( /** * @param string $leftTableName * @param string $leftColumnName - * @param string|null $leftTableAlias - * @param mixed $leftColumnValue + * @param string|null $leftTableAlias + * @param mixed $leftColumnValue * @param string $operator + * * @return void */ public function addLocalValueCondition($leftTableName, $leftColumnName, $leftTableAlias, $leftColumnValue, $operator = self::EQUAL) { $this->leftTableName = $leftTableName; - $this->leftTableAlias = $leftTableAlias; + $this->leftTableAlias = $leftTableAlias; $this->left[] = $leftColumnName; $this->leftValues[] = $leftColumnValue; $this->rightValues[] = null; @@ -241,7 +248,7 @@ public function addForeignValueCondition($rightTableName, $rightColumnName, $rig /** * Retrieve the number of conditions in the join * - * @return integer The number of conditions in the join + * @return int The number of conditions in the join */ public function countConditions() { @@ -258,9 +265,9 @@ public function getConditions() $conditions = []; for ($i = 0; $i < $this->count; $i++) { $conditions[] = [ - 'left' => $this->getLeftColumn($i), + 'left' => $this->getLeftColumn($i), 'operator' => $this->getOperator($i), - 'right' => $this->getRightColumn($i) + 'right' => $this->getRightColumn($i), ]; } @@ -269,6 +276,7 @@ public function getConditions() /** * @param string $operator the comparison operator for the join condition + * * @return void */ public function addOperator($operator) @@ -278,6 +286,7 @@ public function addOperator($operator) /** * @param int $index + * * @return string the comparison operator for the join condition */ public function getOperator($index = 0) @@ -296,9 +305,10 @@ public function getOperators() /** * Set the join type * - * @param string $joinType The type of the join. Valid join types are + * @param string|null $joinType The type of the join. Valid join types are * null (adding the join condition to the where clause), * Criteria::LEFT_JOIN(), Criteria::RIGHT_JOIN(), and Criteria::INNER_JOIN() + * * @return void */ public function setJoinType($joinType = null) @@ -314,7 +324,7 @@ public function setJoinType($joinType = null) */ public function getJoinType() { - return null === $this->joinType ? self::INNER_JOIN : $this->joinType; + return $this->joinType === null ? self::INNER_JOIN : $this->joinType; } /** @@ -325,7 +335,9 @@ public function getJoinType() * $join->setLeftTableName('book'); * $join->addLeftColumnName('AUTHOR_ID'); * + * * @param string $left The name of the left column to add + * * @return void */ public function addLeftColumnName($left) @@ -336,7 +348,8 @@ public function addLeftColumnName($left) /** * Adds a value for a leftColumn. * - * @param string|number $value an actual value + * @param mixed $value an actual value + * * @return void */ public function addLeftValue($value) @@ -352,7 +365,9 @@ public function addLeftValue($value) * $join->addCondition('book.AUTHOR_ID', 'author.ID'); * echo $join->getLeftColumn(); // 'book.AUTHOR_ID' * - * @param integer $index The number of the condition to use + * + * @param int $index The number of the condition to use + * * @return string */ public function getLeftColumn($index = 0) @@ -370,7 +385,9 @@ public function getLeftColumn($index = 0) * $join->addCondition('book.AUTHOR_ID', 'author.ID'); * echo $join->getLeftColumnName(); // 'AUTHOR_ID' * - * @param integer $index The number of the condition to use + * + * @param int $index The number of the condition to use + * * @return string */ public function getLeftColumnName($index = 0) @@ -380,6 +397,7 @@ public function getLeftColumnName($index = 0) /** * Get the list of all the names of left columns of the join condition + * * @return array */ public function getLeftColumns() @@ -394,6 +412,7 @@ public function getLeftColumns() /** * @param string $leftTableName + * * @return $this */ public function setLeftTableName($leftTableName) @@ -404,7 +423,7 @@ public function setLeftTableName($leftTableName) } /** - * @return null|string + * @return string|null */ public function getLeftTableName() { @@ -413,6 +432,7 @@ public function getLeftTableName() /** * @param string $leftTableAlias + * * @return $this */ public function setLeftTableAlias($leftTableAlias) @@ -423,7 +443,7 @@ public function setLeftTableAlias($leftTableAlias) } /** - * @return null|string + * @return string|null */ public function getLeftTableAlias() { @@ -435,11 +455,11 @@ public function getLeftTableAlias() */ public function hasLeftTableAlias() { - return null !== $this->leftTableAlias; + return $this->leftTableAlias !== null; } /** - * @return null|string + * @return string|null */ public function getLeftTableAliasOrName() { @@ -462,7 +482,9 @@ public function getLeftTableWithAlias() * $join->setRightTableName('author'); * $join->addRightColumnName('ID'); * + * * @param string $right The name of the right column to add + * * @return void */ public function addRightColumnName($right) @@ -478,7 +500,9 @@ public function addRightColumnName($right) * $join->addCondition('book.AUTHOR_ID', 'author.ID'); * echo $join->getLeftColumn(); // 'author.ID' * - * @param integer $index The number of the condition to use + * + * @param int $index The number of the condition to use + * * @return string */ public function getRightColumn($index = 0) @@ -496,7 +520,9 @@ public function getRightColumn($index = 0) * $join->addCondition('book.AUTHOR_ID', 'author.ID'); * echo $join->getLeftColumn(); // 'ID' * - * @param integer $index The number of the condition to use + * + * @param int $index The number of the condition to use + * * @return string */ public function getRightColumnName($index = 0) @@ -519,6 +545,7 @@ public function getRightColumns() /** * @param string $rightTableName + * * @return $this */ public function setRightTableName($rightTableName) @@ -529,7 +556,7 @@ public function setRightTableName($rightTableName) } /** - * @return null|string + * @return string|null */ public function getRightTableName() { @@ -538,6 +565,7 @@ public function getRightTableName() /** * @param string $rightTableAlias + * * @return $this */ public function setRightTableAlias($rightTableAlias) @@ -548,7 +576,7 @@ public function setRightTableAlias($rightTableAlias) } /** - * @return null|string + * @return string|null */ public function getRightTableAlias() { @@ -560,11 +588,11 @@ public function getRightTableAlias() */ public function hasRightTableAlias() { - return null !== $this->rightTableAlias; + return $this->rightTableAlias !== null; } /** - * @return null|string + * @return string|null */ public function getRightTableAliasOrName() { @@ -584,7 +612,8 @@ public function getRightTableWithAlias() * * The AdapterInterface which might be used to get db specific * variations of sql. - * @return AdapterInterface value of db. + * + * @return \Propel\Runtime\Adapter\AdapterInterface value of db. */ public function getAdapter() { @@ -595,7 +624,9 @@ public function getAdapter() * Set the adapter. * * The AdapterInterface might be used to get db specific variations of sql. - * @param AdapterInterface $db Value to assign to db. + * + * @param \Propel\Runtime\Adapter\AdapterInterface $db Value to assign to db. + * * @return void */ public function setAdapter(AdapterInterface $db) @@ -606,7 +637,8 @@ public function setAdapter(AdapterInterface $db) /** * Set a custom join condition * - * @param AbstractCriterion $joinCondition a Join condition + * @param \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion $joinCondition a Join condition + * * @return void */ public function setJoinCondition(AbstractCriterion $joinCondition) @@ -617,7 +649,7 @@ public function setJoinCondition(AbstractCriterion $joinCondition) /** * Get the custom join condition, if previously set * - * @return AbstractCriterion + * @return \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion */ public function getJoinCondition() { @@ -627,12 +659,13 @@ public function getJoinCondition() /** * Set the custom join condition Criterion based on the conditions of this join * - * @param Criteria $c A Criteria object to get Criterions from + * @param \Propel\Runtime\ActiveQuery\Criteria $c A Criteria object to get Criterions from + * * @return void */ public function buildJoinCondition(Criteria $c) { - /** @var AbstractCriterion|null $joinCondition */ + /** @var \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion|null $joinCondition */ $joinCondition = null; for ($i = 0; $i < $this->count; $i++) { if ($this->leftValues[$i]) { @@ -641,7 +674,7 @@ public function buildJoinCondition(Criteria $c) $this->leftValues[$i], self::EQUAL ); - } else if ($this->rightValues[$i]) { + } elseif ($this->rightValues[$i]) { $criterion = $c->getNewCriterion( $this->getRightColumn($i), $this->rightValues[$i], @@ -654,7 +687,7 @@ public function buildJoinCondition(Criteria $c) Criteria::CUSTOM ); } - if (null === $joinCondition) { + if ($joinCondition === null) { $joinCondition = $criterion; } else { $joinCondition = $joinCondition->addAnd($criterion); @@ -667,6 +700,7 @@ public function buildJoinCondition(Criteria $c) /** * Get the join clause for this Join. * If the join condition needs binding, uses the passed params array. + * * @example * * $join = new Join(); @@ -682,12 +716,12 @@ public function buildJoinCondition(Criteria $c) */ public function getClause(&$params) { - if (null === $this->joinCondition) { + if ($this->joinCondition === null) { $conditions = []; for ($i = 0; $i < $this->count; $i++) { if ($this->leftValues[$i]) { $conditions[] = $this->getLeftColumn($i) . $this->getOperator($i) . var_export($this->leftValues[$i], true); - } else if ($this->rightValues[$i]) { + } elseif ($this->rightValues[$i]) { $conditions[] = $this->getRightColumn($i) . $this->getOperator($i) . var_export($this->rightValues[$i], true); } else { $conditions[] = $this->getLeftColumn($i) . $this->getOperator($i) . $this->getRightColumn($i); @@ -705,7 +739,8 @@ public function getClause(&$params) $rightTableName = $this->getAdapter()->quoteIdentifierTable($rightTableName); } - return sprintf('%s %s ON %s', + return sprintf( + '%s %s ON %s', $this->getJoinType(), $rightTableName, $joinCondition @@ -713,7 +748,8 @@ public function getClause(&$params) } /** - * @param null|Join $join + * @param \Propel\Runtime\ActiveQuery\Join|null $join + * * @return bool */ public function equals($join) @@ -721,12 +757,11 @@ public function equals($join) $parametersOfThisClauses = []; $parametersOfJoinClauses = []; - return null !== $join + return $join !== null && $join instanceof Join && $this->getJoinType() === $join->getJoinType() && $this->getConditions() == $join->getConditions() - && $this->getClause($parametersOfThisClauses) == $join->getClause($parametersOfJoinClauses) - ; + && $this->getClause($parametersOfThisClauses) == $join->getClause($parametersOfJoinClauses); } /** @@ -750,7 +785,7 @@ public function __toString() } /** - * @return boolean + * @return bool */ public function isIdentifierQuotingEnabled() { @@ -758,12 +793,12 @@ public function isIdentifierQuotingEnabled() } /** - * @param boolean $identifierQuoting + * @param bool $identifierQuoting + * * @return void */ public function setIdentifierQuoting($identifierQuoting) { $this->identifierQuoting = $identifierQuoting; } - } diff --git a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php index a3071715ec..703f6fe111 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php @@ -10,27 +10,15 @@ namespace Propel\Runtime\ActiveQuery; +use Exception; use Propel\Common\Exception\SetColumnConverterException; use Propel\Common\Util\SetColumnConverter; use Propel\Generator\Model\PropelTypes; -use Propel\Runtime\ActiveQuery\Criterion\BinaryModelCriterion; -use Propel\Runtime\ActiveRecord\ActiveRecordInterface; -use Propel\Runtime\Exception\EntityNotFoundException; -use Propel\Runtime\Exception\RuntimeException; -use Propel\Runtime\Propel; -use Propel\Runtime\Collection\ObjectCollection; -use Propel\Runtime\Connection\ConnectionInterface; -use Propel\Runtime\Exception\ClassNotFoundException; -use Propel\Runtime\Exception\PropelException; -use Propel\Runtime\Exception\UnexpectedValueException; -use Propel\Runtime\Map\ColumnMap; -use Propel\Runtime\Map\RelationMap; -use Propel\Runtime\Map\TableMap; -use Propel\Runtime\Util\PropelModelPager; use Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion; -use Propel\Runtime\ActiveQuery\Criterion\InModelCriterion; use Propel\Runtime\ActiveQuery\Criterion\BasicModelCriterion; +use Propel\Runtime\ActiveQuery\Criterion\BinaryModelCriterion; use Propel\Runtime\ActiveQuery\Criterion\CustomCriterion; +use Propel\Runtime\ActiveQuery\Criterion\InModelCriterion; use Propel\Runtime\ActiveQuery\Criterion\LikeModelCriterion; use Propel\Runtime\ActiveQuery\Criterion\RawCriterion; use Propel\Runtime\ActiveQuery\Criterion\RawModelCriterion; @@ -38,7 +26,16 @@ use Propel\Runtime\ActiveQuery\Exception\UnknownColumnException; use Propel\Runtime\ActiveQuery\Exception\UnknownModelException; use Propel\Runtime\ActiveQuery\Exception\UnknownRelationException; -use Propel\Runtime\DataFetcher\DataFetcherInterface; +use Propel\Runtime\Connection\ConnectionInterface; +use Propel\Runtime\Exception\ClassNotFoundException; +use Propel\Runtime\Exception\PropelException; +use Propel\Runtime\Exception\RuntimeException; +use Propel\Runtime\Exception\UnexpectedValueException; +use Propel\Runtime\Map\ColumnMap; +use Propel\Runtime\Map\RelationMap; +use Propel\Runtime\Map\TableMap; +use Propel\Runtime\Propel; +use Propel\Runtime\Util\PropelModelPager; /** * This class extends the Criteria by adding runtime introspection abilities @@ -49,18 +46,18 @@ * * magic methods: * - * @method ModelCriteria leftJoin($relation) Adds a LEFT JOIN clause to the query - * @method ModelCriteria rightJoin($relation) Adds a RIGHT JOIN clause to the query - * @method ModelCriteria innerJoin($relation) Adds a INNER JOIN clause to the query + * @method \Propel\Runtime\ActiveQuery\ModelCriteria leftJoin($relation) Adds a LEFT JOIN clause to the query + * @method \Propel\Runtime\ActiveQuery\ModelCriteria rightJoin($relation) Adds a RIGHT JOIN clause to the query + * @method \Propel\Runtime\ActiveQuery\ModelCriteria innerJoin($relation) Adds a INNER JOIN clause to the query * * @author François Zaninotto */ class ModelCriteria extends BaseModelCriteria { - const FORMAT_STATEMENT = '\Propel\Runtime\Formatter\StatementFormatter'; - const FORMAT_ARRAY = '\Propel\Runtime\Formatter\ArrayFormatter'; - const FORMAT_OBJECT = '\Propel\Runtime\Formatter\ObjectFormatter'; - const FORMAT_ON_DEMAND = '\Propel\Runtime\Formatter\OnDemandFormatter'; + public const FORMAT_STATEMENT = '\Propel\Runtime\Formatter\StatementFormatter'; + public const FORMAT_ARRAY = '\Propel\Runtime\Formatter\ArrayFormatter'; + public const FORMAT_OBJECT = '\Propel\Runtime\Formatter\ObjectFormatter'; + public const FORMAT_ON_DEMAND = '\Propel\Runtime\Formatter\OnDemandFormatter'; protected $useAliasInSQL = false; @@ -110,9 +107,9 @@ class ModelCriteria extends BaseModelCriteria * @see Criteria::add() * * @param string $conditionName A name to store the condition for a later combination with combine() - * @param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?' - * @param mixed $value A value for the condition - * @param mixed $bindingType A value for the condition + * @param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?' + * @param mixed $value A value for the condition + * @param mixed $bindingType A value for the condition * * @return $this The current object, for fluid interface */ @@ -133,8 +130,8 @@ public function condition($conditionName, $clause, $value = null, $bindingType = * * @see Criteria::add() * - * @param string $column A string representing thecolumn phpName, e.g. 'AuthorId' - * @param mixed $value A value for the condition + * @param string $column A string representing thecolumn phpName, e.g. 'AuthorId' + * @param mixed $value A value for the condition * @param string $comparison What to use for the column comparison, defaults to Criteria::EQUAL * * @return $this The current object, for fluid interface @@ -150,7 +147,7 @@ public function filterBy($column, $value, $comparison = Criteria::EQUAL) * Warning: recognizes only the phpNames of the main Model (not joined tables) * * $c->filterByArray(array( - * 'Title' => 'War And Peace', + * 'Title' => 'War And Peace', * 'Publisher' => $publisher * )); * @@ -186,7 +183,7 @@ public function filterByArray($conditions) * * @param mixed $clause A string representing the pseudo SQL clause, e.g. 'Book.AuthorId = ?' * Or an array of condition names - * @param mixed $value A value for the condition + * @param mixed $value A value for the condition * * @return $this The current object, for fluid interface */ @@ -221,7 +218,7 @@ public function where($clause, $value = null, $bindingType = null) * * @param mixed $clause A string representing the pseudo SQL clause, e.g. 'Book.AuthorId = ?' * Or an array of condition names - * @param mixed $value A value for the condition + * @param mixed $value A value for the condition * * @return $this The current object, for fluid interface */ @@ -251,7 +248,9 @@ public function having($clause, $value = null, $bindingType = null) * => $c->addDescendingOrderByColumn(BookTableMap::CATEGORY_ID) * * @param string $columnName The column to order by - * @param string $order The sorting order. Criteria::ASC by default, also accepts Criteria::DESC + * @param string $order The sorting order. Criteria::ASC by default, also accepts Criteria::DESC + * + * @throws \Propel\Runtime\Exception\UnexpectedValueException * * @return $this The current object, for fluid interface */ @@ -262,9 +261,11 @@ public function orderBy($columnName, $order = Criteria::ASC) switch ($order) { case Criteria::ASC: $this->addAscendingOrderByColumn($realColumnName); + break; case Criteria::DESC: $this->addDescendingOrderByColumn($realColumnName); + break; default: throw new UnexpectedValueException('ModelCriteria::orderBy() only accepts Criteria::ASC or Criteria::DESC as argument'); @@ -287,6 +288,8 @@ public function orderBy($columnName, $order = Criteria::ASC) * * @param mixed $columnName an array of columns name (e.g. array('Book.AuthorId', 'Book.AuthorName')) or a single column name (e.g. 'Book.AuthorId') * + * @throws \Propel\Runtime\Exception\PropelException + * * @return $this The current object, for fluid interface */ public function groupBy($columnName) @@ -296,7 +299,7 @@ public function groupBy($columnName) } if (!is_array($columnName)) { - $columnName = array($columnName); + $columnName = [$columnName]; } foreach ($columnName as $column) { @@ -318,6 +321,8 @@ public function groupBy($columnName) * * @param string $class The class name or alias * + * @throws \Propel\Runtime\Exception\ClassNotFoundException + * * @return $this The current object, for fluid interface */ public function groupByClass($class) @@ -406,6 +411,8 @@ public function offset($offset) * * @param mixed $columnArray A list of column names (e.g. array('Title', 'Category.Name', 'c.Content')) or a single column name (e.g. 'Name') * + * @throws \Propel\Runtime\Exception\PropelException + * * @return $this The current object, for fluid interface */ public function select($columnArray) @@ -414,10 +421,10 @@ public function select($columnArray) throw new PropelException('You must ask for at least one column'); } - if ('*' === $columnArray) { + if ($columnArray === '*') { $columnArray = []; foreach (call_user_func([$this->modelTableMapName, 'getFieldNames'], TableMap::TYPE_PHPNAME) as $column) { - $columnArray []= $this->modelName . '.' . $column; + $columnArray[] = $this->modelName . '.' . $column; } } @@ -428,6 +435,7 @@ public function select($columnArray) /** * Retrieves the columns defined by a previous call to select(). + * * @see select() * * @return array|string A list of column names (e.g. array('Title', 'Category.Name', 'c.Content')) or a single column name (e.g. 'Name') @@ -441,7 +449,7 @@ public function getSelect() * This method returns the previousJoin for this ModelCriteria, * by default this is null, but after useQuery this is set the to the join of that use * - * @return Join the previousJoin for this ModelCriteria + * @return \Propel\Runtime\ActiveQuery\Join the previousJoin for this ModelCriteria */ public function getPreviousJoin() { @@ -452,7 +460,8 @@ public function getPreviousJoin() * This method sets the previousJoin for this ModelCriteria, * by default this is null, but after useQuery this is set the to the join of that use * - * @param Join $previousJoin The previousJoin for this ModelCriteria + * @param \Propel\Runtime\ActiveQuery\Join $previousJoin The previousJoin for this ModelCriteria + * * @return void */ public function setPreviousJoin(Join $previousJoin) @@ -479,13 +488,16 @@ public function setPreviousJoin(Join $previousJoin) * @param string $relation Relation to use for the join * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * + * @throws \Propel\Runtime\Exception\PropelException + * @throws \Propel\Runtime\ActiveQuery\Exception\UnknownRelationException + * * @return $this The current object, for fluid interface */ public function join($relation, $joinType = Criteria::INNER_JOIN) { // relation looks like '$leftName.$relationName $relationAlias' [$fullName, $relationAlias] = self::getClassAndAlias($relation); - if (false === strpos($fullName, '.')) { + if (strpos($fullName, '.') === false) { // simple relation name, refers to the current table $leftName = $this->getModelAliasOrName(); $relationName = $fullName; @@ -519,13 +531,13 @@ public function join($relation, $joinType = Criteria::INNER_JOIN) // create a ModelJoin object for this join $join = new ModelJoin(); $join->setJoinType($joinType); - if (null !== $previousJoin) { + if ($previousJoin !== null) { $join->setPreviousJoin($previousJoin); } $join->setRelationMap($relationMap, $leftTableAlias, $relationAlias); // add the ModelJoin to the current object - if (null !== $relationAlias) { + if ($relationAlias !== null) { $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { @@ -537,16 +549,19 @@ public function join($relation, $joinType = Criteria::INNER_JOIN) /** * Add another condition to an already added join + * * @example * * $query->join('Book.Author'); * $query->addJoinCondition('Author', 'Book.Title LIKE ?', 'foo%'); * * - * @param string $name The relation name or alias on which the join was created - * @param string $clause SQL clause, may contain column and table phpNames - * @param mixed $value An optional value to bind to the clause - * @param string $operator The operator to use to add the condition. Defaults to 'AND' + * @param string $name The relation name or alias on which the join was created + * @param string $clause SQL clause, may contain column and table phpNames + * @param mixed $value An optional value to bind to the clause + * @param string|null $operator The operator to use to add the condition. Defaults to 'AND' + * + * @throws \Propel\Runtime\Exception\PropelException * * @return $this The current object, for fluid interface */ @@ -560,7 +575,7 @@ public function addJoinCondition($name, $clause, $value = null, $operator = null $join->buildJoinCondition($this); } $criterion = $this->getCriterionForClause($clause, $value, $bindingType); - $method = Criteria::LOGICAL_OR === $operator ? 'addOr' : 'addAnd'; + $method = $operator === Criteria::LOGICAL_OR ? 'addOr' : 'addAnd'; $join->getJoinCondition()->$method($criterion); return $this; @@ -568,6 +583,7 @@ public function addJoinCondition($name, $clause, $value = null, $operator = null /** * Replace the condition of an already added join + * * @example * * $query->join('Book.Author'); @@ -577,8 +593,10 @@ public function addJoinCondition($name, $clause, $value = null, $operator = null * $query->setJoinCondition('Author', 'cond3'); * * - * @param string $name The relation name or alias on which the join was created - * @param mixed $condition A Criterion object, or a condition name + * @param string $name The relation name or alias on which the join was created + * @param mixed $condition A Criterion object, or a condition name + * + * @throws \Propel\Runtime\Exception\PropelException * * @return $this The current object, for fluid interface */ @@ -601,15 +619,17 @@ public function setJoinCondition($name, $condition) /** * Add a join object to the Criteria + * * @see Criteria::addJoinObject() - * @param Join $join A join object + * + * @param \Propel\Runtime\ActiveQuery\Join $join A join object * * @return $this The current object, for fluid interface */ public function addJoinObject(Join $join, $name = null) { if (!in_array($join, $this->joins)) { // compare equality, NOT identity - if (null === $name) { + if ($name === null) { $this->joins[] = $join; } else { $this->joins[$name] = $join; @@ -660,6 +680,9 @@ public function joinWith($relation, $joinType = Criteria::INNER_JOIN) * * @param string $relation Relation to use for the join * + * @throws \Propel\Runtime\ActiveQuery\Exception\UnknownRelationException + * @throws \Propel\Runtime\Exception\PropelException + * * @return $this The current object, for fluid interface */ public function with($relation) @@ -669,9 +692,9 @@ public function with($relation) } $join = $this->joins[$relation]; - if (RelationMap::MANY_TO_MANY === $join->getRelationMap()->getType()) { - throw new PropelException(__METHOD__ .' does not allow hydration for many-to-many relationships'); - } elseif (RelationMap::ONE_TO_MANY === $join->getRelationMap()->getType()) { + if ($join->getRelationMap()->getType() === RelationMap::MANY_TO_MANY) { + throw new PropelException(__METHOD__ . ' does not allow hydration for many-to-many relationships'); + } elseif ($join->getRelationMap()->getType() === RelationMap::ONE_TO_MANY) { // For performance reasons, the formatters will use a special routine in this case $this->isWithOneToMany = true; } @@ -703,7 +726,7 @@ public function isWithOneToMany() * * @param string $clause The SQL clause with object model column names * e.g. 'UPPER(Author.FirstName)' - * @param string $name Optional alias for the added column + * @param string|null $name Optional alias for the added column * If no alias is provided, the clause is used as a column alias * This alias is used for retrieving the column via BaseObject::getVirtualColumn($alias) * @@ -711,7 +734,7 @@ public function isWithOneToMany() */ public function withColumn($clause, $name = null) { - if (null === $name) { + if ($name === null) { $name = str_replace(['.', '(', ')'], '', $clause); } @@ -730,10 +753,13 @@ public function withColumn($clause, $name = null) * Initializes a secondary ModelCriteria object, to be later merged with the current object * * @see ModelCriteria::endUse() - * @param string $relationName Relation name or alias - * @param string $secondaryCriteriaClass ClassName for the ModelCriteria to be used * - * @return ModelCriteria The secondary criteria object + * @param string $relationName Relation name or alias + * @param string|null $secondaryCriteriaClass ClassName for the ModelCriteria to be used + * + * @throws \Propel\Runtime\Exception\PropelException + * + * @return \Propel\Runtime\ActiveQuery\ModelCriteria The secondary criteria object */ public function useQuery($relationName, $secondaryCriteriaClass = null) { @@ -743,7 +769,7 @@ public function useQuery($relationName, $secondaryCriteriaClass = null) $className = $this->joins[$relationName]->getTableMap()->getClassName(); /** @var self $secondaryCriteriaClass */ - if (null === $secondaryCriteriaClass) { + if ($secondaryCriteriaClass === null) { $secondaryCriteria = PropelQuery::from($className); } else { $secondaryCriteria = new $secondaryCriteriaClass(); @@ -763,7 +789,7 @@ public function useQuery($relationName, $secondaryCriteriaClass = null) * * @see Criteria::mergeWith() * - * @return ModelCriteria The primary criteria object + * @return \Propel\Runtime\ActiveQuery\ModelCriteria The primary criteria object */ public function endUse() { @@ -780,10 +806,11 @@ public function endUse() /** * Add the content of a Criteria to the current Criteria * In case of conflict, the current Criteria keeps its properties + * * @see Criteria::mergeWith() * - * @param Criteria $criteria The criteria to read properties from - * @param string $operator The logical operator used to combine conditions + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria The criteria to read properties from + * @param string|null $operator The logical operator used to combine conditions * Defaults to Criteria::LOGICAL_AND, also accepts Criteria::LOGICAL_OR * * @return $this The primary criteria object @@ -817,11 +844,13 @@ public function clear() return $this; } + /** * Sets the primary Criteria for this secondary Criteria * - * @param ModelCriteria $criteria The primary criteria - * @param Join $previousJoin The previousJoin for this ModelCriteria + * @param \Propel\Runtime\ActiveQuery\ModelCriteria $criteria The primary criteria + * @param \Propel\Runtime\ActiveQuery\Join $previousJoin The previousJoin for this ModelCriteria + * * @return void */ public function setPrimaryCriteria(ModelCriteria $criteria, Join $previousJoin) @@ -833,7 +862,7 @@ public function setPrimaryCriteria(ModelCriteria $criteria, Join $previousJoin) /** * Gets the primary criteria for this secondary Criteria * - * @return ModelCriteria|null The primary criteria + * @return $this|null The primary criteria */ public function getPrimaryCriteria() { @@ -845,9 +874,9 @@ public function getPrimaryCriteria() * * @see Criteria::addSelectQuery() * - * @param Criteria $subQueryCriteria Criteria to build the subquery from - * @param string $alias alias for the subQuery - * @param boolean $addAliasAndSelectColumns Set to false if you want to manually add the aliased select columns + * @param \Propel\Runtime\ActiveQuery\Criteria $subQueryCriteria Criteria to build the subquery from + * @param string|null $alias alias for the subQuery + * @param bool $addAliasAndSelectColumns Set to false if you want to manually add the aliased select columns * * @return $this The current object, for fluid interface */ @@ -861,7 +890,7 @@ public function addSelectQuery(Criteria $subQueryCriteria, $alias = null, $addAl if ($addAliasAndSelectColumns) { // give this query-model same alias as subquery - if (null === $alias) { + if ($alias === null) { end($this->selectQueries); $alias = key($this->selectQueries); } @@ -877,6 +906,7 @@ public function addSelectQuery(Criteria $subQueryCriteria, $alias = null, $addAl * Adds the select columns for the current table * * @param bool $force To enforce adding columns for changed alias, set it to true (f.e. with sub selects) + * * @return $this The current object, for fluid interface */ public function addSelfSelectColumns($force = false) @@ -910,7 +940,7 @@ public function addRelationSelectColumns($relation) /** * Returns the class and alias of a string representing a model or a relation * e.g. 'Book b' => array('Book', 'b') - * e.g. 'Book' => array('Book', null) + * e.g. 'Book' => array('Book', null) * * @param string $class The classname to explode * @@ -918,12 +948,12 @@ public function addRelationSelectColumns($relation) */ public static function getClassAndAlias($class) { - if (false !== strpos($class, ' ')) { + if (strpos($class, ' ') !== false) { [$class, $alias] = explode(' ', $class); } else { $alias = null; } - if (0 === strpos($class, '\\')) { + if (strpos($class, '\\') === 0) { $class = substr($class, 1); } @@ -934,7 +964,8 @@ public static function getClassAndAlias($class) * Returns the name of a relation from a string. * The input looks like '$leftName.$relationName $relationAlias' * - * @param string $relation Relation to use for the join + * @param string $relation Relation to use for the join + * * @return string the relationName used in the join */ public static function getRelationName($relation) @@ -943,7 +974,7 @@ public static function getRelationName($relation) [$fullName, $relationAlias] = self::getClassAndAlias($relation); if ($relationAlias) { $relationName = $relationAlias; - } elseif (false === strpos($fullName, '.')) { + } elseif (strpos($fullName, '.') === false) { $relationName = $fullName; } else { [, $relationName] = explode('.', $fullName); @@ -958,13 +989,13 @@ public static function getRelationName($relation) * even though they modify it. If the query must be reused after termination, * you must call this method prior to termination. * - * @param boolean $isKeepQuery + * @param bool $isKeepQuery * * @return $this The current object, for fluid interface */ public function keepQuery($isKeepQuery = true) { - $this->isKeepQuery = (bool) $isKeepQuery; + $this->isKeepQuery = (bool)$isKeepQuery; return $this; } @@ -972,7 +1003,7 @@ public function keepQuery($isKeepQuery = true) /** * Checks whether the automated cloning on termination is enabled. * - * @return boolean true if cloning must be done before termination + * @return bool true if cloning must be done before termination */ public function isKeepQuery() { @@ -982,7 +1013,8 @@ public function isKeepQuery() /** * Code to execute before every SELECT statement * - * @param ConnectionInterface $con The connection object used by the query + * @param \Propel\Runtime\Connection\ConnectionInterface $con The connection object used by the query + * * @return void */ protected function basePreSelect(ConnectionInterface $con) @@ -1004,13 +1036,13 @@ protected function preSelect(ConnectionInterface $con) * and format the list of results with the current formatter * By default, returns an array of model objects * - * @param ConnectionInterface|null $con an optional connection object + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object * - * @return ObjectCollection|ActiveRecordInterface[]|array|mixed the list of results, formatted by the current formatter + * @return \Propel\Runtime\Collection\ObjectCollection|\Propel\Runtime\ActiveRecord\ActiveRecordInterface[]|mixed the list of results, formatted by the current formatter */ - public function find(ConnectionInterface $con = null) + public function find(?ConnectionInterface $con = null) { - if (null === $con) { + if ($con === null) { $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } @@ -1030,13 +1062,13 @@ public function find(ConnectionInterface $con = null) * * Does not work with ->with()s containing one-to-many relations. * - * @param ConnectionInterface|null $con an optional connection object + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object * * @return mixed the result, formatted by the current formatter */ - public function findOne(ConnectionInterface $con = null) + public function findOne(?ConnectionInterface $con = null) { - if (null === $con) { + if ($con === null) { $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } @@ -1056,20 +1088,21 @@ public function findOne(ConnectionInterface $con = null) * Behaves differently if the model has simple or composite primary key * * // simple primary key - * $book = $c->requirePk(12, $con); + * $book = $c->requirePk(12, $con); * // composite primary key * $bookOpinion = $c->requirePk(array(34, 634), $con); * * * Throws an exception when nothing was found. * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface|null $con an optional connection object + * @param mixed $key Primary key to use for the query + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object + * + * @throws \Propel\Runtime\Exception\EntityNotFoundException|\Exception When nothing is found * * @return mixed the result, formatted by the current formatter - * @throws EntityNotFoundException|\Exception When nothing is found */ - public function requirePk($key, ConnectionInterface $con = null) + public function requirePk($key, ?ConnectionInterface $con = null) { $result = $this->findPk($key, $con); @@ -1089,12 +1122,13 @@ public function requirePk($key, ConnectionInterface $con = null) * * Does not work with ->with()s containing one-to-many relations. * - * @param ConnectionInterface|null $con an optional connection object + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object + * + * @throws \Propel\Runtime\Exception\EntityNotFoundException|\Exception When nothing is found * * @return mixed the result, formatted by the current formatter - * @throws EntityNotFoundException|\Exception When nothing is found */ - public function requireOne(ConnectionInterface $con = null) + public function requireOne(?ConnectionInterface $con = null) { $result = $this->findOne($con); @@ -1113,14 +1147,15 @@ public function requireOne(ConnectionInterface $con = null) * @see filterBy() * @see findOne() * - * @param mixed $column A string representing the column phpName, e.g. 'AuthorId' - * @param mixed $value A value for the condition - * @param ConnectionInterface|null $con an optional connection object + * @param mixed $column A string representing the column phpName, e.g. 'AuthorId' + * @param mixed $value A value for the condition + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object + * + * @throws \Propel\Runtime\Exception\EntityNotFoundException|\Exception When nothing is found * * @return mixed the result, formatted by the current formatter - * @throws EntityNotFoundException|\Exception When nothing is found */ - public function requireOneBy($column, $value, ConnectionInterface $con = null) + public function requireOneBy($column, $value, ?ConnectionInterface $con = null) { $result = $this->findOneBy($column, $value, $con); @@ -1135,19 +1170,21 @@ public function requireOneBy($column, $value, ConnectionInterface $con = null) * Apply a list of conditions on columns and issues the SELECT ... LIMIT 1 query * * $c->requireOneByArray([ - * 'Title' => 'War And Peace', + * 'Title' => 'War And Peace', * 'Publisher' => $publisher * ], $con); * * * @see requireOne() * - * @param mixed $conditions An array of conditions, using column phpNames as key - * @param ConnectionInterface|null $con an optional connection object + * @param mixed $conditions An array of conditions, using column phpNames as key + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object + * + * @throws \Exception * * @return mixed the list of results, formatted by the current formatter */ - public function requireOneByArray($conditions, ConnectionInterface $con = null) + public function requireOneByArray($conditions, ?ConnectionInterface $con = null) { $result = $this->findOneByArray($conditions, $con); @@ -1160,12 +1197,13 @@ public function requireOneByArray($conditions, ConnectionInterface $con = null) /** * @throws \Propel\Runtime\Exception\PropelException + * * @return \Exception */ private function createEntityNotFoundException() { if (!isset($this->entityNotFoundExceptionClass)) { - throw new PropelException('Please define a entityNotFoundExceptionClass property with the name of your NotFoundException-class in ' . get_class($this)); + throw new PropelException('Please define a entityNotFoundExceptionClass property with the name of your NotFoundException-class in ' . static::class); } return new $this->entityNotFoundExceptionClass("{$this->getModelShortName()} could not be found"); @@ -1176,16 +1214,16 @@ private function createEntityNotFoundException() * and format the result with the current formatter * By default, returns a model object * - * @param ConnectionInterface|null $con an optional connection object + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object * - * @return mixed the result, formatted by the current formatter + * @throws \Propel\Runtime\Exception\PropelException * - * @throws PropelException + * @return mixed the result, formatted by the current formatter */ - public function findOneOrCreate(ConnectionInterface $con = null) + public function findOneOrCreate(?ConnectionInterface $con = null) { if ($this->joins) { - throw new PropelException(__METHOD__ .' cannot be used on a query with a join, because Propel cannot transform a SQL JOIN into a subquery. You should split the query in two queries to avoid joins.'); + throw new PropelException(__METHOD__ . ' cannot be used on a query with a join, because Propel cannot transform a SQL JOIN into a subquery. You should split the query in two queries to avoid joins.'); } $ret = $this->findOne($con); @@ -1206,18 +1244,19 @@ public function findOneOrCreate(ConnectionInterface $con = null) * Behaves differently if the model has simple or composite primary key * * // simple primary key - * $book = $c->findPk(12, $con); + * $book = $c->findPk(12, $con); * // composite primary key * $bookOpinion = $c->findPk(array(34, 634), $con); * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface|null $con an optional connection object + * + * @param mixed $key Primary key to use for the query + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object * * @return mixed the result, formatted by the current formatter */ - public function findPk($key, ConnectionInterface $con = null) + public function findPk($key, ?ConnectionInterface $con = null) { - if (null === $con) { + if ($con === null) { $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } @@ -1225,7 +1264,7 @@ public function findPk($key, ConnectionInterface $con = null) $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; $pkCols = array_values($this->getTableMap()->getPrimaryKeys()); - if (1 === count($pkCols)) { + if (count($pkCols) === 1) { // simple primary key $pkCol = $pkCols[0]; $criteria->add($pkCol->getFullyQualifiedName(), $key); @@ -1250,23 +1289,24 @@ public function findPk($key, ConnectionInterface $con = null) * // composite primary key * $bookOpinion = $c->findPks(array(array(34, 634), array(45, 518), array(34, 765)), $con); * - * @param array $keys Primary keys to use for the query - * @param ConnectionInterface|null $con an optional connection object * - * @return mixed the list of results, formatted by the current formatter + * @param array $keys Primary keys to use for the query + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object * - * @throws PropelException + * @throws \Propel\Runtime\Exception\PropelException + * + * @return mixed the list of results, formatted by the current formatter */ - public function findPks($keys, ConnectionInterface $con = null) + public function findPks($keys, ?ConnectionInterface $con = null) { - if (null === $con) { + if ($con === null) { $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } // As the query uses a PK condition, no limit(1) is necessary. $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; $pkCols = $this->getTableMap()->getPrimaryKeys(); - if (1 === count($pkCols)) { + if (count($pkCols) === 1) { // simple primary key $pkCol = array_shift($pkCols); $criteria->add($pkCol->getFullyQualifiedName(), $keys, Criteria::IN); @@ -1285,13 +1325,13 @@ public function findPks($keys, ConnectionInterface $con = null) * @see filterBy() * @see find() * - * @param string $column A string representing the column phpName, e.g. 'AuthorId' - * @param mixed $value A value for the condition - * @param ConnectionInterface|null $con An optional connection object + * @param string $column A string representing the column phpName, e.g. 'AuthorId' + * @param mixed $value A value for the condition + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con An optional connection object * * @return mixed the list of results, formatted by the current formatter */ - public function findBy($column, $value, ConnectionInterface $con = null) + public function findBy($column, $value, ?ConnectionInterface $con = null) { $method = 'filterBy' . $column; $this->$method($value); @@ -1303,7 +1343,7 @@ public function findBy($column, $value, ConnectionInterface $con = null) * Apply a list of conditions on columns and issues the SELECT query * * $c->findByArray(array( - * 'Title' => 'War And Peace', + * 'Title' => 'War And Peace', * 'Publisher' => $publisher * ), $con); * @@ -1311,12 +1351,12 @@ public function findBy($column, $value, ConnectionInterface $con = null) * @see filterByArray() * @see find() * - * @param mixed $conditions An array of conditions, using column phpNames as key - * @param ConnectionInterface|null $con an optional connection object + * @param mixed $conditions An array of conditions, using column phpNames as key + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object * * @return mixed the list of results, formatted by the current formatter */ - public function findByArray($conditions, ConnectionInterface $con = null) + public function findByArray($conditions, ?ConnectionInterface $con = null) { $this->filterByArray($conditions); @@ -1329,13 +1369,13 @@ public function findByArray($conditions, ConnectionInterface $con = null) * @see filterBy() * @see findOne() * - * @param mixed $column A string representing thecolumn phpName, e.g. 'AuthorId' - * @param mixed $value A value for the condition - * @param ConnectionInterface|null $con an optional connection object + * @param mixed $column A string representing thecolumn phpName, e.g. 'AuthorId' + * @param mixed $value A value for the condition + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object * * @return mixed the result, formatted by the current formatter */ - public function findOneBy($column, $value, ConnectionInterface $con = null) + public function findOneBy($column, $value, ?ConnectionInterface $con = null) { $method = 'filterBy' . $column; $this->$method($value); @@ -1347,7 +1387,7 @@ public function findOneBy($column, $value, ConnectionInterface $con = null) * Apply a list of conditions on columns and issues the SELECT ... LIMIT 1 query * * $c->findOneByArray(array( - * 'Title' => 'War And Peace', + * 'Title' => 'War And Peace', * 'Publisher' => $publisher * ), $con); * @@ -1355,12 +1395,12 @@ public function findOneBy($column, $value, ConnectionInterface $con = null) * @see filterByArray() * @see findOne() * - * @param mixed $conditions An array of conditions, using column phpNames as key - * @param ConnectionInterface|null $con an optional connection object + * @param mixed $conditions An array of conditions, using column phpNames as key + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object * * @return mixed the list of results, formatted by the current formatter */ - public function findOneByArray($conditions, ConnectionInterface $con = null) + public function findOneByArray($conditions, ?ConnectionInterface $con = null) { $this->filterByArray($conditions); @@ -1370,13 +1410,13 @@ public function findOneByArray($conditions, ConnectionInterface $con = null) /** * Issue a SELECT COUNT(*) query based on the current ModelCriteria * - * @param ConnectionInterface|null $con an optional connection object + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object * - * @return integer the number of results + * @return int the number of results */ - public function count(ConnectionInterface $con = null) + public function count(?ConnectionInterface $con = null) { - if (null === $con) { + if ($con === null) { $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } @@ -1393,7 +1433,7 @@ public function count(ConnectionInterface $con = null) $dataFetcher = $criteria->doCount($con); $row = $dataFetcher->fetch(); if ($row) { - $count = (int) current($row); + $count = (int)current($row); } else { $count = 0; // no rows returned; we infer that means 0 matches. } @@ -1407,7 +1447,7 @@ public function count(ConnectionInterface $con = null) * * @return \Propel\Runtime\DataFetcher\DataFetcherInterface */ - public function doCount(ConnectionInterface $con = null) + public function doCount(?ConnectionInterface $con = null) { $this->configureSelectColumns(); @@ -1422,13 +1462,13 @@ public function doCount(ConnectionInterface $con = null) /** * Issue an existence check on the current ModelCriteria * - * @param ConnectionInterface|null $con an optional connection object + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object * * @return bool column existence */ - public function exists(ConnectionInterface $con = null) + public function exists(?ConnectionInterface $con = null) { - if (null === $con) { + if ($con === null) { $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } @@ -1446,7 +1486,7 @@ public function exists(ConnectionInterface $con = null) $criteria->setPrimaryTableName(constant($this->modelTableMapName . '::TABLE_NAME')); $dataFetcher = $criteria->doSelect($con); - $exists = (boolean) $dataFetcher->fetchColumn(0); + $exists = (bool)$dataFetcher->fetchColumn(0); $dataFetcher->close(); return $exists; @@ -1457,13 +1497,13 @@ public function exists(ConnectionInterface $con = null) * and uses a page and a maximum number of results per page * to compute an offset and a limit. * - * @param int $page number of the page to start the pager on. Page 1 means no offset - * @param int $maxPerPage maximum number of results per page. Determines the limit - * @param ConnectionInterface|null $con an optional connection object + * @param int $page number of the page to start the pager on. Page 1 means no offset + * @param int $maxPerPage maximum number of results per page. Determines the limit + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object * - * @return PropelModelPager a pager object, supporting iteration + * @return \Propel\Runtime\Util\PropelModelPager a pager object, supporting iteration */ - public function paginate($page = 1, $maxPerPage = 10, ConnectionInterface $con = null) + public function paginate($page = 1, $maxPerPage = 10, ?ConnectionInterface $con = null) { $criteria = $this->isKeepQuery() ? clone $this : $this; $pager = new PropelModelPager($criteria, $maxPerPage); @@ -1476,7 +1516,8 @@ public function paginate($page = 1, $maxPerPage = 10, ConnectionInterface $con = /** * Code to execute before every DELETE statement * - * @param ConnectionInterface $con The connection object used by the query + * @param \Propel\Runtime\Connection\ConnectionInterface $con The connection object used by the query + * * @return int */ protected function basePreDelete(ConnectionInterface $con) @@ -1485,7 +1526,8 @@ protected function basePreDelete(ConnectionInterface $con) } /** - * @param ConnectionInterface $con + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * * @return int|null */ protected function preDelete(ConnectionInterface $con) @@ -1496,8 +1538,9 @@ protected function preDelete(ConnectionInterface $con) /** * Code to execute after every DELETE statement * - * @param int $affectedRows the number of deleted rows - * @param ConnectionInterface $con The connection object used by the query + * @param int $affectedRows the number of deleted rows + * @param \Propel\Runtime\Connection\ConnectionInterface $con The connection object used by the query + * * @return int */ protected function basePostDelete($affectedRows, ConnectionInterface $con) @@ -1507,7 +1550,8 @@ protected function basePostDelete($affectedRows, ConnectionInterface $con) /** * @param int $affectedRows - * @param ConnectionInterface $con + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * * @return int|null */ protected function postDelete($affectedRows, ConnectionInterface $con) @@ -1519,19 +1563,19 @@ protected function postDelete($affectedRows, ConnectionInterface $con) * Issue a DELETE query based on the current ModelCriteria * An optional hook on basePreDelete() can prevent the actual deletion * - * @param ConnectionInterface|null $con an optional connection object + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object * - * @return integer the number of deleted rows + * @throws \Propel\Runtime\Exception\PropelException * - * @throws PropelException + * @return int the number of deleted rows */ - public function delete(ConnectionInterface $con = null) + public function delete(?ConnectionInterface $con = null) { - if (0 === count($this->getMap())) { - throw new PropelException(__METHOD__ .' expects a Criteria with at least one condition. Use deleteAll() to delete all the rows of a table'); + if (count($this->getMap()) === 0) { + throw new PropelException(__METHOD__ . ' expects a Criteria with at least one condition. Use deleteAll() to delete all the rows of a table'); } - if (null === $con) { + if ($con === null) { $con = Propel::getServiceContainer()->getWriteConnection($this->getDbName()); } @@ -1549,7 +1593,7 @@ public function delete(ConnectionInterface $con = null) return $affectedRows; }); } catch (PropelException $e) { - throw new PropelException(__METHOD__ . ' is unable to delete. ', 0, $e); + throw new PropelException(__METHOD__ . ' is unable to delete. ', 0, $e); } } @@ -1557,15 +1601,15 @@ public function delete(ConnectionInterface $con = null) * Issue a DELETE query based on the current ModelCriteria deleting all rows in the table * An optional hook on basePreDelete() can prevent the actual deletion * - * @param ConnectionInterface|null $con an optional connection object + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object * - * @return integer the number of deleted rows + * @throws \Propel\Runtime\Exception\PropelException * - * @throws PropelException + * @return int the number of deleted rows */ - public function deleteAll(ConnectionInterface $con = null) + public function deleteAll(?ConnectionInterface $con = null) { - if (null === $con) { + if ($con === null) { $con = Propel::getServiceContainer()->getWriteConnection($this->getDbName()); } try { @@ -1578,7 +1622,7 @@ public function deleteAll(ConnectionInterface $con = null) return $affectedRows; }); } catch (PropelException $e) { - throw new PropelException(__METHOD__ . ' is unable to delete all. ', 0, $e); + throw new PropelException(__METHOD__ . ' is unable to delete all. ', 0, $e); } } @@ -1586,17 +1630,17 @@ public function deleteAll(ConnectionInterface $con = null) * Issue a DELETE query based on the current ModelCriteria deleting all rows in the table * This method is called by ModelCriteria::deleteAll() inside a transaction * - * @param ConnectionInterface|null $con a connection object + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con a connection object * - * @return integer the number of deleted rows + * @throws \Propel\Runtime\Exception\RuntimeException * - * @throws RuntimeException + * @return int the number of deleted rows */ - public function doDeleteAll(ConnectionInterface $con = null) + public function doDeleteAll(?ConnectionInterface $con = null) { $databaseName = $this->getDbName(); - if (null === $con) { + if ($con === null) { $con = Propel::getServiceContainer()->getWriteConnection($databaseName); } @@ -1605,21 +1649,22 @@ public function doDeleteAll(ConnectionInterface $con = null) throw new RuntimeException('Delete does not support join'); } - $this->setPrimaryTableName(constant($this->modelTableMapName.'::TABLE_NAME')); + $this->setPrimaryTableName(constant($this->modelTableMapName . '::TABLE_NAME')); $tableName = $this->getPrimaryTableName(); $affectedRows = 0; // initialize this in case the next loop has no iterations. try { $tableName = $this->quoteIdentifierTable($tableName); - $sql = "DELETE FROM " . $tableName; + $sql = 'DELETE FROM ' . $tableName; $stmt = $con->prepare($sql); $stmt->execute(); $affectedRows += $stmt->rowCount(); - } catch (\Exception $e) { + } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new RuntimeException(sprintf('Unable to execute DELETE ALL statement [%s]', $sql), 0, $e); } @@ -1629,9 +1674,10 @@ public function doDeleteAll(ConnectionInterface $con = null) /** * Code to execute before every UPDATE statement * - * @param array $values The associative array of columns and values for the update - * @param ConnectionInterface $con The connection object used by the query - * @param boolean $forceIndividualSaves If false (default), the resulting call is a Criteria::doUpdate(), otherwise it is a series of save() calls on all the found objects + * @param array $values The associative array of columns and values for the update + * @param \Propel\Runtime\Connection\ConnectionInterface $con The connection object used by the query + * @param bool $forceIndividualSaves If false (default), the resulting call is a Criteria::doUpdate(), otherwise it is a series of save() calls on all the found objects + * * @return int|null */ protected function basePreUpdate(&$values, ConnectionInterface $con, $forceIndividualSaves = false) @@ -1641,8 +1687,9 @@ protected function basePreUpdate(&$values, ConnectionInterface $con, $forceIndiv /** * @param array $values - * @param ConnectionInterface $con + * @param \Propel\Runtime\Connection\ConnectionInterface $con * @param bool $forceIndividualSaves + * * @return int|null */ protected function preUpdate(&$values, ConnectionInterface $con, $forceIndividualSaves = false) @@ -1653,8 +1700,9 @@ protected function preUpdate(&$values, ConnectionInterface $con, $forceIndividua /** * Code to execute after every UPDATE statement * - * @param int $affectedRows the number of updated rows - * @param ConnectionInterface $con The connection object used by the query + * @param int $affectedRows the number of updated rows + * @param \Propel\Runtime\Connection\ConnectionInterface $con The connection object used by the query + * * @return int|null */ protected function basePostUpdate($affectedRows, ConnectionInterface $con) @@ -1664,7 +1712,8 @@ protected function basePostUpdate($affectedRows, ConnectionInterface $con) /** * @param int $affectedRows - * @param ConnectionInterface $con + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * * @return int|null */ protected function postUpdate($affectedRows, ConnectionInterface $con) @@ -1678,32 +1727,32 @@ protected function postUpdate($affectedRows, ConnectionInterface $con) * Beware that behaviors based on hooks in the object's save() method * will only be triggered if you force individual saves, i.e. if you pass true as second argument. * - * @param mixed $values Associative array of keys and values to replace - * @param ConnectionInterface|null $con an optional connection object - * @param boolean $forceIndividualSaves If false (default), the resulting call is a Criteria::doUpdate(), otherwise it is a series of save() calls on all the found objects - * - * @return integer Number of updated rows + * @param mixed $values Associative array of keys and values to replace + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object + * @param bool $forceIndividualSaves If false (default), the resulting call is a Criteria::doUpdate(), otherwise it is a series of save() calls on all the found objects * * @throws \Propel\Runtime\Exception\PropelException * @throws \Exception|\Propel\Runtime\Exception\PropelException + * + * @return int Number of updated rows */ - public function update($values, ConnectionInterface $con = null, $forceIndividualSaves = false) + public function update($values, ?ConnectionInterface $con = null, $forceIndividualSaves = false) { if (!is_array($values) && !($values instanceof Criteria)) { - throw new PropelException(__METHOD__ .' expects an array or Criteria as first argument'); + throw new PropelException(__METHOD__ . ' expects an array or Criteria as first argument'); } if (count($this->getJoins())) { - throw new PropelException(__METHOD__ .' does not support multitable updates, please do not use join()'); + throw new PropelException(__METHOD__ . ' does not support multitable updates, please do not use join()'); } - if (null === $con) { + if ($con === null) { $con = Propel::getServiceContainer()->getWriteConnection($this->getDbName()); } $criteria = $this->isKeepQuery() ? clone $this : $this; if ($this->modelTableMapName) { - $criteria->setPrimaryTableName(constant($this->modelTableMapName.'::TABLE_NAME')); + $criteria->setPrimaryTableName(constant($this->modelTableMapName . '::TABLE_NAME')); } return $con->transaction(function () use ($con, $values, $criteria, $forceIndividualSaves) { @@ -1721,16 +1770,15 @@ public function update($values, ConnectionInterface $con = null, $forceIndividua * Issue an UPDATE query based the current ModelCriteria and a list of changes. * This method is called by ModelCriteria::update() inside a transaction. * - * @param array $values Associative array of keys and values to replace - * @param ConnectionInterface $con a connection object - * @param boolean $forceIndividualSaves If false (default), the resulting call is a Criteria::doUpdate(), otherwise it is a series of save() calls on all the found objects + * @param array $values Associative array of keys and values to replace + * @param \Propel\Runtime\Connection\ConnectionInterface $con a connection object + * @param bool $forceIndividualSaves If false (default), the resulting call is a Criteria::doUpdate(), otherwise it is a series of save() calls on all the found objects * - * @return integer Number of updated rows + * @return int Number of updated rows */ public function doUpdate($values, ConnectionInterface $con, $forceIndividualSaves = false) { if ($forceIndividualSaves) { - // Update rows one by one $objects = $this->setFormatter(ModelCriteria::FORMAT_OBJECT)->find($con); foreach ($objects as $object) { @@ -1740,9 +1788,7 @@ public function doUpdate($values, ConnectionInterface $con, $forceIndividualSave } $objects->save($con); $affectedRows = count($objects); - } else { - // update rows in a single query if ($values instanceof Criteria) { $set = $values; @@ -1770,14 +1816,14 @@ public function doUpdate($values, ConnectionInterface $con, $forceIndividualSave /** * Creates a Criterion object based on a list of existing condition names and a comparator * - * @param array $conditions The list of condition names, e.g. array('cond1', 'cond2') - * @param string|null $operator An operator, Criteria::LOGICAL_AND (default) or Criteria::LOGICAL_OR + * @param array $conditions The list of condition names, e.g. array('cond1', 'cond2') + * @param string|null $operator An operator, Criteria::LOGICAL_AND (default) or Criteria::LOGICAL_OR * - * @return AbstractCriterion A Criterion or ModelCriterion object + * @return \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion A Criterion or ModelCriterion object */ protected function getCriterionForConditions($conditions, $operator = null) { - $operator = (null === $operator) ? Criteria::LOGICAL_AND : $operator; + $operator = ($operator === null) ? Criteria::LOGICAL_AND : $operator; $this->combine($conditions, $operator, 'propel_temp_name'); $criterion = $this->namedCriterions['propel_temp_name']; unset($this->namedCriterions['propel_temp_name']); @@ -1795,7 +1841,7 @@ protected function getCriterionForConditions($conditions, $operator = null) * * @throws \Propel\Runtime\Exception\PropelException * - * @return AbstractCriterion a Criterion object + * @return \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion a Criterion object */ protected function getCriterionForClause($clause, $value, $bindingType = null) { @@ -1803,11 +1849,11 @@ protected function getCriterionForClause($clause, $value, $bindingType = null) if ($this->replaceNames($clause)) { // at least one column name was found and replaced in the clause // this is enough to determine the type to bind the parameter to - /** @var ColumnMap $colMap */ + /** @var \Propel\Runtime\Map\ColumnMap $colMap */ $colMap = $this->replacedColumns[0]; $value = $this->convertValueForColumn($value, $colMap); $clauseLen = strlen($clause); - if (null !== $bindingType) { + if ($bindingType !== null) { return new RawModelCriterion($this, $clause, $colMap, $value, $this->currentAlias, $bindingType); } if (stripos($clause, 'IN ?') == $clauseLen - 4) { @@ -1834,8 +1880,8 @@ protected function getCriterionForClause($clause, $value, $bindingType = null) return new BasicModelCriterion($this, $clause, $colMap, $value, $this->currentAlias); } // no column match in clause, must be an expression like '1=1' - if (false !== strpos($clause, '?')) { - if (null === $bindingType) { + if (strpos($clause, '?') !== false) { + if ($bindingType === null) { throw new PropelException(sprintf('Cannot determine the column to bind to the parameter in clause "%s".', $origin)); } @@ -1848,9 +1894,12 @@ protected function getCriterionForClause($clause, $value, $bindingType = null) /** * Converts value for some column types * - * @param mixed $value The value to convert - * @param ColumnMap $colMap The ColumnMap object - * @return mixed The converted value + * @param mixed $value The value to convert + * @param \Propel\Runtime\Map\ColumnMap $colMap The ColumnMap object + * + * @throws \Propel\Runtime\Exception\PropelException + * + * @return mixed The converted value */ protected function convertValueForColumn($value, ColumnMap $colMap) { @@ -1860,15 +1909,15 @@ protected function convertValueForColumn($value, ColumnMap $colMap) } else { $value = serialize($value); } - } elseif ('ARRAY' === $colMap->getType() && is_array($value)) { + } elseif ($colMap->getType() === 'ARRAY' && is_array($value)) { $value = '| ' . implode(' | ', $value) . ' |'; - } elseif (PropelTypes::ENUM === $colMap->getType() && !is_null($value)) { + } elseif ($colMap->getType() === PropelTypes::ENUM && $value !== null) { if (is_array($value)) { $value = array_map([$colMap, 'getValueSetKey'], $value); } else { $value = $colMap->getValueSetKey($value); } - } elseif ($colMap->isSetType() && !is_null($value)) { + } elseif ($colMap->isSetType() && $value !== null) { try { $value = SetColumnConverter::convertToInt($value, $colMap->getValueSet()); } catch (SetColumnConverterException $e) { @@ -1881,7 +1930,7 @@ protected function convertValueForColumn($value, ColumnMap $colMap) /** * Callback function to replace column names by their real name in a clause - * e.g. 'Book.Title IN ?' + * e.g. 'Book.Title IN ?' * => 'book.title IN ?' * * @param array $matches Matches found by preg_replace_callback @@ -1897,12 +1946,12 @@ protected function doReplaceNameInExpression($matches) $this->replacedColumns[] = $column; $this->foundMatch = true; - if (false !== strpos($key, '.')) { + if (strpos($key, '.') !== false) { [$tableName, $columnName] = explode('.', $key); $realColumnName = substr($realFullColumnName, strrpos($realFullColumnName, '.') + 1); if (isset($this->aliases[$tableName])) { //don't replace a alias with their real table name - return $this->quoteIdentifier($tableName.'.'.$realColumnName); + return $this->quoteIdentifier($tableName . '.' . $realColumnName); } } @@ -1926,11 +1975,14 @@ protected function doReplaceNameInExpression($matches) * * @param string $phpName String representing the column name in a pseudo SQL clause, e.g. 'Book.Title' * + * @throws \Propel\Runtime\ActiveQuery\Exception\UnknownModelException + * @throws \Propel\Runtime\ActiveQuery\Exception\UnknownColumnException + * * @return array List($columnMap, $realColumnName) */ protected function getColumnFromName($phpName, $failSilently = true) { - if (false === strpos($phpName, '.')) { + if (strpos($phpName, '.') === false) { $prefix = $this->getModelAliasOrName(); } else { // $prefix could be either class name or table name @@ -1992,9 +2044,10 @@ protected function getColumnFromName($phpName, $failSilently = true) /** * @param string $tableName * - * @return null|ModelJoin + * @return \Propel\Runtime\ActiveQuery\ModelJoin|null */ - public function getModelJoinByTableName($tableName) { + public function getModelJoinByTableName($tableName) + { foreach ($this->joins as $join) { if ($join instanceof ModelJoin && $join->getTableMap()->getName() == $tableName) { return $join; @@ -2007,17 +2060,15 @@ public function getModelJoinByTableName($tableName) { /** * Builds, binds and executes a SELECT query based on the current object. * - * @param ConnectionInterface $con A connection object + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con A connection object * - * @return DataFetcherInterface A dataFetcher using the connection, ready to be fetched - * - * @throws \Propel\Runtime\Exception\PropelException + * @return \Propel\Runtime\DataFetcher\DataFetcherInterface A dataFetcher using the connection, ready to be fetched */ - public function doSelect(ConnectionInterface $con = null) + public function doSelect(?ConnectionInterface $con = null) { $this->addSelfSelectColumns(); - if (null === $con) { + if ($con === null) { $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } @@ -2031,13 +2082,13 @@ public function doSelect(ConnectionInterface $con = null) */ public function configureSelectColumns() { - if (is_null($this->select)) { + if ($this->select === null) { // leave early return; } // select() needs the PropelSimpleArrayFormatter if no formatter given - if (is_null($this->formatter)) { + if ($this->formatter === null) { $this->setFormatter('\Propel\Runtime\Formatter\SimpleArrayFormatter'); } @@ -2058,12 +2109,11 @@ public function configureSelectColumns() if (!array_key_exists($columnName, $this->getAsColumns())) { $column = $this->getColumnFromName($columnName); // always put quotes around the columnName to be safe, we strip them in the formatter - $this->addAsColumn('"'.$columnName.'"', $column[1]); + $this->addAsColumn('"' . $columnName . '"', $column[1]); } } } - /** * Special case for subquery columns * @@ -2072,6 +2122,7 @@ public function configureSelectColumns() * @param bool $failSilently * * @throws \Propel\Runtime\Exception\PropelException + * * @return array List($columnMap, $realColumnName) */ protected function getColumnFromSubQuery($class, $phpName, $failSilently = true) @@ -2080,13 +2131,13 @@ protected function getColumnFromSubQuery($class, $phpName, $failSilently = true) $tableMap = $subQueryCriteria->getTableMap(); if ($tableMap->hasColumnByPhpName($phpName)) { $column = $tableMap->getColumnByPhpName($phpName); - $realColumnName = $class.'.'.$column->getName(); + $realColumnName = $class . '.' . $column->getName(); return [$column, $realColumnName]; } if (isset($subQueryCriteria->asColumns[$phpName])) { // aliased column - return [null, $class.'.'.$phpName]; + return [null, $class . '.' . $phpName]; } if ($failSilently) { return [null, null]; @@ -2103,6 +2154,8 @@ protected function getColumnFromSubQuery($class, $phpName, $failSilently = true) * * @param string $columnName the Column phpName, without the table name * + * @throws \Propel\Runtime\ActiveQuery\Exception\UnknownColumnException + * * @return string the fully qualified column name */ protected function getRealColumnName($columnName) @@ -2118,8 +2171,7 @@ protected function getRealColumnName($columnName) return $this ->getTableMap() ->getColumnByPhpName($columnName) - ->getFullyQualifiedName() - ; + ->getFullyQualifiedName(); } /** @@ -2158,8 +2210,9 @@ public static function getShortName($fullyQualifiedClassName) * Overrides Criteria::add() to force the use of a true table alias if it exists * * @see Criteria::add() - * @param string $column The colName of column to run the condition on (e.g. BookTableMap::ID) - * @param mixed $value + * + * @param string $column The colName of column to run the condition on (e.g. BookTableMap::ID) + * @param mixed $value * @param string|null $operator A String, like Criteria::EQUAL. * * @return $this A modified Criteria object. @@ -2182,13 +2235,12 @@ public function getParams() $dbMap = Propel::getServiceContainer()->getDatabaseMap($this->getDbName()); foreach ($this->getMap() as $criterion) { - $table = null; foreach ($criterion->getAttachedCriterion() as $attachedCriterion) { $tableName = $attachedCriterion->getTable(); $table = $this->getTableForAlias($tableName); - if (null === $table) { + if ($table === null) { $table = $tableName; } @@ -2205,7 +2257,7 @@ public function getParams() } $having = $this->getHaving(); - if (null !== $having) { + if ($having !== null) { $sb = ''; $having->appendPsTo($sb, $params); } @@ -2218,13 +2270,15 @@ public function getParams() * Supports findByXXX(), findOneByXXX(), requireOneByXXX(), filterByXXX(), orderByXXX(), and groupByXXX() methods, * where XXX is a column phpName. * Supports XXXJoin(), where XXX is a join direction (in 'left', 'right', 'inner') + * + * @throws \Propel\Runtime\Exception\PropelException */ public function __call($name, $arguments) { // Maybe it's a magic call to one of the methods supporting it, e.g. 'findByTitle' static $methods = ['findBy', 'findOneBy', 'requireOneBy', 'filterBy', 'orderBy', 'groupBy']; foreach ($methods as $method) { - if (0 === strpos($name, $method)) { + if (strpos($name, $method) === 0) { $columns = substr($name, strlen($method)); if (in_array($method, ['findBy', 'findOneBy', 'requireOneBy']) && strpos($columns, 'And') !== false) { $method = $method . 'Array'; @@ -2243,7 +2297,7 @@ public function __call($name, $arguments) } // Maybe it's a magic call to a qualified joinWith method, e.g. 'leftJoinWith' or 'joinWithAuthor' - if (false !== ($pos = stripos($name, 'joinWith'))) { + if (($pos = stripos($name, 'joinWith')) !== false) { $joinType = null; $type = substr($name, 0, $pos); @@ -2278,11 +2332,12 @@ public function __call($name, $arguments) } } - throw new PropelException(sprintf('Undefined method %s::%s()', __CLASS__, $name)); + throw new PropelException(sprintf('Undefined method %s::%s()', self::class, $name)); } /** * Ensures deep cloning of attached objects + * * @return void */ public function __clone() @@ -2293,7 +2348,7 @@ public function __clone() $this->with[$key] = clone $join; } - if (null !== $this->formatter) { + if ($this->formatter !== null) { $this->formatter = clone $this->formatter; } } @@ -2302,11 +2357,13 @@ public function __clone() * Override method to prevent an addition of self columns. * * @param string $name + * * @return $this */ public function addSelectColumn($name) { $this->isSelfSelected = true; + return parent::addSelectColumn($name); } } diff --git a/src/Propel/Runtime/ActiveQuery/ModelJoin.php b/src/Propel/Runtime/ActiveQuery/ModelJoin.php index ef2f572448..fd9452726f 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelJoin.php +++ b/src/Propel/Runtime/ActiveQuery/ModelJoin.php @@ -20,7 +20,9 @@ */ class ModelJoin extends Join { - /** @var RelationMap */ + /** + * @var \Propel\Runtime\Map\RelationMap + */ protected $relationMap; protected $tableMap; @@ -34,8 +36,8 @@ public function setRelationMap(RelationMap $relationMap, $leftTableAlias = null, $leftValues = $relationMap->getLocalValues(); $nbColumns = $relationMap->countColumnMappings(); - for ($i=0; $i < $nbColumns; $i++) { - if (null !== $leftValues[$i]) { + for ($i = 0; $i < $nbColumns; $i++) { + if ($leftValues[$i] !== null) { if ($relationMap->getType() === RelationMap::ONE_TO_MANY) { //one-to-many $this->addForeignValueCondition( @@ -73,7 +75,7 @@ public function setRelationMap(RelationMap $relationMap, $leftTableAlias = null, } /** - * @return RelationMap + * @return \Propel\Runtime\Map\RelationMap */ public function getRelationMap() { @@ -83,7 +85,7 @@ public function getRelationMap() /** * Sets the right tableMap for this join * - * @param TableMap $tableMap The table map to use + * @param \Propel\Runtime\Map\TableMap $tableMap The table map to use * * @return $this The current join object, for fluid interface */ @@ -97,11 +99,11 @@ public function setTableMap(TableMap $tableMap) /** * Gets the right tableMap for this join * - * @return TableMap The table map + * @return \Propel\Runtime\Map\TableMap The table map */ public function getTableMap() { - if (null === $this->tableMap && null !== $this->relationMap) { + if ($this->tableMap === null && $this->relationMap !== null) { $this->tableMap = $this->relationMap->getRightTable(); } @@ -121,7 +123,7 @@ public function setPreviousJoin(ModelJoin $join) } /** - * @return ModelJoin + * @return $this */ public function getPreviousJoin() { @@ -133,13 +135,13 @@ public function getPreviousJoin() */ public function isPrimary() { - return null === $this->previousJoin; + return $this->previousJoin === null; } /** * @param string $relationAlias * - * @return \Propel\Runtime\ActiveQuery\ModelJoin + * @return $this */ public function setRelationAlias($relationAlias) { @@ -178,8 +180,9 @@ public function isIdentifierQuotingEnabled() * This method only works if PreviousJoin has been defined, * which only happens when you provide dotted relations when calling join * - * @param Object $startObject the start object all joins originate from and which has already hydrated - * @return Object the base Object of this join + * @param object $startObject the start object all joins originate from and which has already hydrated + * + * @return object The base Object of this join */ public function getObjectToRelate($startObject) { @@ -206,8 +209,7 @@ public function equals($join) return parent::equals($join) && $this->relationMap == $join->getRelationMap() && $this->previousJoin == $join->getPreviousJoin() - && $this->rightTableAlias == $join->getRightTableAlias() - ; + && $this->rightTableAlias == $join->getRightTableAlias(); } /** diff --git a/src/Propel/Runtime/ActiveQuery/ModelWith.php b/src/Propel/Runtime/ActiveQuery/ModelWith.php index 273d4e6b94..2cd4e4a1a5 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelWith.php +++ b/src/Propel/Runtime/ActiveQuery/ModelWith.php @@ -75,9 +75,12 @@ class ModelWith */ protected $rightPhpName; - public function __construct(ModelJoin $join = null) + /** + * @param \Propel\Runtime\ActiveQuery\ModelJoin|null $join + */ + public function __construct(?ModelJoin $join = null) { - if (null !== $join) { + if ($join !== null) { $this->init($join); } } @@ -86,7 +89,8 @@ public function __construct(ModelJoin $join = null) * Define the joined hydration schema based on a join object. * Fills the ModelWith properties using a ModelJoin as source * - * @param ModelJoin $join + * @param \Propel\Runtime\ActiveQuery\ModelJoin $join + * * @return void */ public function init(ModelJoin $join) @@ -122,7 +126,7 @@ public function init(ModelJoin $join) */ public function setModelName($modelName) { - if (0 === strpos($modelName, '\\')) { + if (strpos($modelName, '\\') === 0) { $this->modelName = substr($modelName, 1); } else { $this->modelName = $modelName; @@ -314,7 +318,7 @@ public function getRightPhpName() */ public function isPrimary() { - return null === $this->leftPhpName; + return $this->leftPhpName === null; } /** diff --git a/src/Propel/Runtime/ActiveQuery/PropelQuery.php b/src/Propel/Runtime/ActiveQuery/PropelQuery.php index 1822dcab0e..250809f0dd 100644 --- a/src/Propel/Runtime/ActiveQuery/PropelQuery.php +++ b/src/Propel/Runtime/ActiveQuery/PropelQuery.php @@ -21,19 +21,21 @@ class PropelQuery { /** * @param string $queryClassAndAlias - * @return ModelCriteria + * * @throws \Propel\Runtime\Exception\ClassNotFoundException + * + * @return \Propel\Runtime\ActiveQuery\ModelCriteria */ public static function from($queryClassAndAlias) { - list($class, $alias) = ModelCriteria::getClassAndAlias($queryClassAndAlias); + [$class, $alias] = ModelCriteria::getClassAndAlias($queryClassAndAlias); $queryClass = $class . 'Query'; if (!class_exists($queryClass)) { throw new ClassNotFoundException('Cannot find a query class for ' . $class); } - /** @var ModelCriteria $query */ + /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ $query = new $queryClass(); - if (null !== $alias) { + if ($alias !== null) { $query->setModelAlias($alias); } diff --git a/src/Propel/Runtime/ActiveRecord/NestedSetRecursiveIterator.php b/src/Propel/Runtime/ActiveRecord/NestedSetRecursiveIterator.php index 9a798efb4c..03002db349 100644 --- a/src/Propel/Runtime/ActiveRecord/NestedSetRecursiveIterator.php +++ b/src/Propel/Runtime/ActiveRecord/NestedSetRecursiveIterator.php @@ -10,12 +10,14 @@ namespace Propel\Runtime\ActiveRecord; +use RecursiveIterator; + /** * Pre-order node iterator for Node objects. * * @author Heltem */ -class NestedSetRecursiveIterator implements \RecursiveIterator +class NestedSetRecursiveIterator implements RecursiveIterator { /** * @var object @@ -49,7 +51,7 @@ public function rewind() */ public function valid() { - return null !== $this->curNode; + return $this->curNode !== null; } /** @@ -82,8 +84,8 @@ public function next() $nextNode = null; $method = method_exists($this->curNode, 'retrieveNextSibling') ? 'retrieveNextSibling' : 'getNextSibling'; if ($this->valid()) { - while (null === $nextNode) { - if (null === $this->curNode) { + while ($nextNode === null) { + if ($this->curNode === null) { break; } diff --git a/src/Propel/Runtime/Adapter/AdapterFactory.php b/src/Propel/Runtime/Adapter/AdapterFactory.php index a1acbf2f9c..4e075e69b8 100644 --- a/src/Propel/Runtime/Adapter/AdapterFactory.php +++ b/src/Propel/Runtime/Adapter/AdapterFactory.php @@ -25,13 +25,14 @@ class AdapterFactory * for or a shorter form adapter key. * * @throws \Propel\Runtime\Exception\InvalidArgumentException If the adapter could not be instantiated. - * @return \Propel\Runtime\Adapter\AdapterInterface An instance of a Propel database adapter. + * + * @return \Propel\Runtime\Adapter\AdapterInterface An instance of a Propel database adapter. */ public static function create($driver) { if (!$driver) { $adapterClass = '\Propel\Runtime\Adapter\NoneAdapter'; - } elseif (false === strpos($driver, '\\')) { + } elseif (strpos($driver, '\\') === false) { if (!class_exists($adapterClass = '\Propel\Runtime\Adapter\Pdo\\' . ucfirst($driver) . 'Adapter')) { $adapterClass = '\Propel\Runtime\Adapter\\' . ucfirst($driver) . 'Adapter'; } @@ -41,6 +42,7 @@ public static function create($driver) if (class_exists($adapterClass)) { return new $adapterClass(); } + throw new InvalidArgumentException(sprintf('Unsupported Propel driver: "%s". Check your configuration file', $driver)); } } diff --git a/src/Propel/Runtime/Adapter/AdapterInterface.php b/src/Propel/Runtime/Adapter/AdapterInterface.php index 686c504134..ed91350767 100644 --- a/src/Propel/Runtime/Adapter/AdapterInterface.php +++ b/src/Propel/Runtime/Adapter/AdapterInterface.php @@ -16,20 +16,19 @@ /** * Interface for adapters. - * */ interface AdapterInterface { - const ID_METHOD_NONE = 0; - const ID_METHOD_AUTOINCREMENT = 1; - const ID_METHOD_SEQUENCE = 2; + public const ID_METHOD_NONE = 0; + public const ID_METHOD_AUTOINCREMENT = 1; + public const ID_METHOD_SEQUENCE = 2; /** * Build database connection * * @param array $conparams connection parameters * - * @return ConnectionInterface + * @return \Propel\Runtime\Connection\ConnectionInterface */ public function getConnection($conparams); @@ -41,8 +40,9 @@ public function getConnection($conparams); * * @see initConnection() * - * @param ConnectionInterface $con - * @param string $charset The $string charset encoding. + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * @param string $charset The $string charset encoding. + * * @return void */ public function setCharset(ConnectionInterface $con, $charset); @@ -53,7 +53,8 @@ public function setCharset(ConnectionInterface $con, $charset); * (Interbase for example) does not use the same SQL in ORDER BY * and other clauses. * - * @param string $in The string whose case to ignore. + * @param string $in The string whose case to ignore. + * * @return string The string in a case that can be ignored. */ public function ignoreCaseInOrderBy($in); @@ -80,9 +81,9 @@ public function concatString($s1, $s2); /** * Returns SQL which extracts a substring. * - * @param string $s String to extract from. - * @param integer $pos Offset to start from. - * @param integer $len Number of characters to extract. + * @param string $s String to extract from. + * @param int $pos Offset to start from. + * @param int $len Number of characters to extract. * * @return string */ @@ -91,14 +92,17 @@ public function subString($s, $pos, $len); /** * Returns SQL which calculates the length (in chars) of a string. * - * @param string $s String to calculate length of. + * @param string $s String to calculate length of. + * * @return string */ public function strLength($s); /** * Quotes database object identifiers (table names, col names, sequences, etc.). - * @param string $text The identifier to quote. + * + * @param string $text The identifier to quote. + * * @return string The quoted identifier. */ public function quoteIdentifier($text); @@ -109,7 +113,8 @@ public function quoteIdentifier($text); * separate schema names from table names. Adapters for RDBMs which support * schemas have to implement that in the platform-specific way. * - * @param string $table The table name to quo + * @param string $table The table name to quo + * * @return string The quoted table name */ public function quoteIdentifierTable($table); @@ -121,6 +126,7 @@ public function quoteIdentifierTable($table); * author_id => `author_id` * * @param string $text + * * @return string */ public function quote($text); @@ -128,22 +134,22 @@ public function quote($text); /** * Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT. * - * @return boolean + * @return bool */ public function isGetIdBeforeInsert(); /** * Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT. * - * @return boolean + * @return bool */ public function isGetIdAfterInsert(); /** * Returns the "DELETE FROM

[AS ]" part of DELETE query. * - * @param Criteria $criteria - * @param string $tableName + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria + * @param string $tableName * * @return string */ @@ -152,8 +158,8 @@ public function getDeleteFromClause(Criteria $criteria, $tableName); /** * Gets the generated ID (either last ID for autoincrement or next sequence ID). * - * @param ConnectionInterface $con - * @param string $name + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * @param string|null $name * * @return mixed */ @@ -162,8 +168,8 @@ public function getId(ConnectionInterface $con, $name = null); /** * Formats a temporal value before binding, given a ColumnMap object * - * @param mixed $value The temporal value - * @param ColumnMap $cMap + * @param mixed $value The temporal value + * @param \Propel\Runtime\Map\ColumnMap $cMap * * @return string The formatted temporal value */ @@ -191,10 +197,9 @@ public function getDateFormatter(); public function getTimeFormatter(); /** - * @param Criteria $criteria + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria * * @return string */ public function getGroupBy(Criteria $criteria); - } diff --git a/src/Propel/Runtime/Adapter/MSSQL/MssqlDebugPDO.php b/src/Propel/Runtime/Adapter/MSSQL/MssqlDebugPDO.php index 6a3b1f1b23..1ea26f239d 100644 --- a/src/Propel/Runtime/Adapter/MSSQL/MssqlDebugPDO.php +++ b/src/Propel/Runtime/Adapter/MSSQL/MssqlDebugPDO.php @@ -12,7 +12,6 @@ /** * dblib doesn't support transactions so we need to add a workaround for transactions, last insert ID, and quoting - * */ class MssqlDebugPDO extends MssqlPropelPDO { diff --git a/src/Propel/Runtime/Adapter/MSSQL/MssqlPropelPDO.php b/src/Propel/Runtime/Adapter/MSSQL/MssqlPropelPDO.php index ecf9b25625..3bdd44a607 100644 --- a/src/Propel/Runtime/Adapter/MSSQL/MssqlPropelPDO.php +++ b/src/Propel/Runtime/Adapter/MSSQL/MssqlPropelPDO.php @@ -16,7 +16,6 @@ /** * dblib doesn't support transactions so we need to add a workaround for * transactions, last insert ID, and quoting - * */ class MssqlPropelPDO extends PropelPDO { @@ -50,6 +49,8 @@ public function beginTransaction() * It is necessary to override the abstract PDO transaction functions here, as * the PDO driver for MSSQL does not support transactions. * + * @throws \Propel\Runtime\Exception\PropelException + * * @return bool */ public function commit() @@ -131,23 +132,24 @@ public function forceRollBack() } /** - * @param string|null $seqname - * @return integer + * @param string|null $seqname + * + * @return int */ public function lastInsertId($seqname = null) { $result = $this->query('SELECT SCOPE_IDENTITY()'); - return (int) $result->fetchColumn(); + return (int)$result->fetchColumn(); } /** - * @param string $text + * @param string $text + * * @return string */ public function quoteIdentifier($text) { return '[' . $text . ']'; } - } diff --git a/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php index 958923c63a..41f059f767 100644 --- a/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php @@ -10,13 +10,13 @@ namespace Propel\Runtime\Adapter\Pdo; -use Propel\Runtime\Adapter\SqlAdapterInterface; -use Propel\Runtime\Adapter\Exception\MalformedClauseException; +use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Adapter\Exception\ColumnNotFoundException; +use Propel\Runtime\Adapter\Exception\MalformedClauseException; +use Propel\Runtime\Adapter\SqlAdapterInterface; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\InvalidArgumentException; use Propel\Runtime\Map\DatabaseMap; -use Propel\Runtime\ActiveQuery\Criteria; /** * This is used to connect to a MSSQL database. @@ -30,8 +30,9 @@ class MssqlAdapter extends PdoAdapter implements SqlAdapterInterface * * @see AdapterInterface::setCharset() * - * @param ConnectionInterface $con - * @param string $charset + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * @param string $charset + * * @return void */ public function setCharset(ConnectionInterface $con, $charset) @@ -54,9 +55,9 @@ public function concatString($s1, $s2) /** * Returns SQL which extracts a substring. * - * @param string $s String to extract from. - * @param integer $pos Offset to start from. - * @param integer $len Number of characters to extract. + * @param string $s String to extract from. + * @param int $pos Offset to start from. + * @param int $len Number of characters to extract. * * @return string */ @@ -68,7 +69,8 @@ public function subString($s, $pos, $len) /** * Returns SQL which calculates the length (in chars) of a string. * - * @param string $s String to calculate length of. + * @param string $s String to calculate length of. + * * @return string */ public function strLength($s) @@ -81,13 +83,14 @@ public function strLength($s) */ public function compareRegex($left, $right) { - return sprintf("dbo.RegexMatch(%s, %s", $left, $right); + return sprintf('dbo.RegexMatch(%s, %s', $left, $right); } /** * @see AdapterInterface::quoteIdentifier() * - * @param string $text + * @param string $text + * * @return string */ public function quoteIdentifier($text) @@ -98,7 +101,8 @@ public function quoteIdentifier($text) /** * @see AdapterInterface::quoteIdentifierTable() * - * @param string $table + * @param string $table + * * @return string */ public function quoteIdentifierTable($table) @@ -110,12 +114,13 @@ public function quoteIdentifierTable($table) /** * @see AdapterInterface::random() * - * @param string $seed + * @param string|null $seed + * * @return string */ public function random($seed = null) { - return 'RAND(' . ((int) $seed) . ')'; + return 'RAND(' . ((int)$seed) . ')'; } /** @@ -124,12 +129,17 @@ public function random($seed = null) * This rewrites the $sql query to apply the offset and limit. * some of the ORDER BY logic borrowed from Doctrine MsSqlPlatform * + * @author Benjamin Runnels + * * @see AdapterInterface::applyLimit() - * @author Benjamin Runnels * - * @param string $sql - * @param integer $offset - * @param integer $limit + * @param string $sql + * @param int $offset + * @param int $limit + * + * @throws \Propel\Runtime\Exception\InvalidArgumentException + * @throws \Propel\Runtime\Adapter\Exception\ColumnNotFoundException + * @throws \Propel\Runtime\Adapter\Exception\MalformedClauseException * * @return void */ @@ -152,15 +162,16 @@ public function applyLimit(&$sql, $offset, $limit) $len = strlen($sql); for ($i = $selectTextLen; $i < $len; $i++) { - if ('(' === $sql[$i]) { + if ($sql[$i] === '(') { $parenthesisMatch++; - } else if (')' === $sql[$i]) { + } elseif ($sql[$i] === ')') { $parenthesisMatch--; - } else if (0 === $parenthesisMatch && $i === stripos($sql, ' from ', $i)) { + } elseif ($parenthesisMatch === 0 && $i === stripos($sql, ' from ', $i)) { // If we hit a 'from' clause outside of matching parenthesis, split the // query string into `SELECT $selectStatement FROM $fromStatement` $selectStatement = trim(substr($sql, $selectTextLen, $i - $selectTextLen)); $fromStatement = trim(substr($sql, $i + 6)); + break; } } @@ -176,7 +187,7 @@ public function applyLimit(&$sql, $offset, $limit) // if we're starting at offset 0 then there's no need to simulate limit, // just grab the top $limit number of rows - if (0 === $offset) { + if ($offset === 0) { $sql = $selectText . 'TOP ' . $limit . ' ' . $selectStatement . ' FROM ' . $fromStatement; return; @@ -186,7 +197,7 @@ public function applyLimit(&$sql, $offset, $limit) $orderStatement = stristr($fromStatement, 'ORDER BY'); $orders = ''; - if (false !== $orderStatement) { + if ($orderStatement !== false) { // remove order statement from the from statement $fromStatement = trim(str_replace($orderStatement, '', $fromStatement)); @@ -194,10 +205,10 @@ public function applyLimit(&$sql, $offset, $limit) $orders = explode(',', $order); $nbOrders = count($orders); - for ($i = 0; $i < $nbOrders; $i ++) { + for ($i = 0; $i < $nbOrders; $i++) { $orderArr[trim(preg_replace('/\s+(ASC|DESC)$/i', '', $orders[$i]))] = [ 'sort' => (stripos($orders[$i], ' DESC') !== false) ? 'DESC' : 'ASC', - 'key' => $i + 'key' => $i, ]; } } @@ -210,15 +221,15 @@ public function applyLimit(&$sql, $offset, $limit) $selColCount = count($selColArr) - 1; // make sure the current column isn't * or an aggregate - if ($selColArr[0] !== '*' && ! strstr($selColArr[0], '(')) { + if ($selColArr[0] !== '*' && !strstr($selColArr[0], '(')) { if (isset($orderArr[$selColArr[0]])) { $orders[$orderArr[$selColArr[0]]['key']] = $selColArr[0] . ' ' . $orderArr[$selColArr[0]]['sort']; } // use the alias if one was present otherwise use the column name - $alias = (! stristr($selCol, ' AS ')) ? $selColArr[0] : $selColArr[$selColCount]; + $alias = (!stristr($selCol, ' AS ')) ? $selColArr[0] : $selColArr[$selColCount]; // don't quote the identifier if it is already quoted - if ('[' !== $alias[0]) { + if ($alias[0] !== '[') { $alias = $this->quoteIdentifier($alias); } @@ -276,10 +287,11 @@ public function applyLimit(&$sql, $offset, $limit) /** * @see parent::cleanupSQL() * - * @param string $sql - * @param array $params - * @param Criteria $values - * @param DatabaseMap $dbMap + * @param string $sql + * @param array $params + * @param \Propel\Runtime\ActiveQuery\Criteria $values + * @param \Propel\Runtime\Map\DatabaseMap $dbMap + * * @return void */ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap) @@ -287,7 +299,7 @@ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $i = 1; $paramCols = []; foreach ($params as $param) { - if (null !== $param['table']) { + if ($param['table'] !== null) { $column = $dbMap->getTable($param['table'])->getColumn($param['column']); /* MSSQL pdo_dblib and pdo_mssql blob values must be converted to hex and then the hex added * to the query string directly. If it goes through PDOStatement::bindValue quotes will cause @@ -314,7 +326,7 @@ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap unset($paramCols); preg_match_all('/:p\d/', $sql, $matches); foreach ($matches[0] as $key => $match) { - $sql = str_replace($match, ':p'.($key+1), $sql); + $sql = str_replace($match, ':p' . ($key + 1), $sql); } } } diff --git a/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php index d80acb1140..790b544103 100644 --- a/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php @@ -10,8 +10,9 @@ namespace Propel\Runtime\Adapter\Pdo; +use PDO; +use PDOStatement; use Propel\Runtime\Adapter\SqlAdapterInterface; -use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Map\ColumnMap; /** @@ -24,7 +25,6 @@ */ class MysqlAdapter extends PdoAdapter implements SqlAdapterInterface { - /** * Returns SQL which concatenates the second string to the first. * @@ -41,9 +41,9 @@ public function concatString($s1, $s2) /** * Returns SQL which extracts a substring. * - * @param string $s String to extract from. - * @param integer $pos Offset to start from. - * @param integer $len Number of characters to extract. + * @param string $s String to extract from. + * @param int $pos Offset to start from. + * @param int $len Number of characters to extract. * * @return string */ @@ -55,7 +55,8 @@ public function subString($s, $pos, $len) /** * Returns SQL which calculates the length (in chars) of a string. * - * @param string $s String to calculate length of. + * @param string $s String to calculate length of. + * * @return string */ public function strLength($s) @@ -66,10 +67,9 @@ public function strLength($s) /** * Locks the specified table. * - * @param ConnectionInterface $con The Propel connection to use. - * @param string $table The name of the table to lock. + * @param \Propel\Runtime\Connection\ConnectionInterface $con The Propel connection to use. + * @param string $table The name of the table to lock. * - * @throws \PDOException No Statement could be created or executed. * @return void */ public function lockTable($con, $table) @@ -80,10 +80,9 @@ public function lockTable($con, $table) /** * Unlocks the specified table. * - * @param ConnectionInterface $con The Propel connection to use. - * @param string $table The name of the table to unlock. + * @param \Propel\Runtime\Connection\ConnectionInterface $con The Propel connection to use. + * @param string $table The name of the table to unlock. * - * @throws \PDOException No Statement could be created or executed. * @return void */ public function unlockTable($con, $table) @@ -94,7 +93,8 @@ public function unlockTable($con, $table) /** * @see AdapterInterface::quoteIdentifier() * - * @param string $text + * @param string $text + * * @return string */ public function quoteIdentifier($text) @@ -105,7 +105,8 @@ public function quoteIdentifier($text) /** * @see AdapterInterface::quoteIdentifierTable() * - * @param string $table + * @param string $table + * * @return string */ public function quoteIdentifierTable($table) @@ -117,15 +118,16 @@ public function quoteIdentifierTable($table) /** * @see AdapterInterface::applyLimit() * - * @param string $sql - * @param integer $offset - * @param integer $limit + * @param string $sql + * @param int $offset + * @param int $limit + * * @return void */ public function applyLimit(&$sql, $offset, $limit) { - $offset = (int) $offset; - $limit = (int) $limit; + $offset = (int)$offset; + $limit = (int)$limit; if ($limit >= 0) { $sql .= ' LIMIT ' . ($offset > 0 ? $offset . ', ' : '') . $limit; @@ -137,33 +139,34 @@ public function applyLimit(&$sql, $offset, $limit) /** * @see AdapterInterface::random() * - * @param string $seed + * @param string|null $seed + * * @return string */ public function random($seed = null) { - return 'rand('.((int) $seed).')'; + return 'rand(' . ((int)$seed) . ')'; } /** * @see AdapterInterface::bindValue() * * @param \PDOStatement $stmt - * @param string $parameter - * @param mixed $value - * @param ColumnMap $cMap - * @param null|integer $position + * @param string $parameter + * @param mixed $value + * @param \Propel\Runtime\Map\ColumnMap $cMap + * @param int|null $position * - * @return boolean + * @return bool */ - public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) { $pdoType = $cMap->getPdoType(); // FIXME - This is a temporary hack to get around apparent bugs w/ PDO+MYSQL // See http://pecl.php.net/bugs/bug.php?id=9919 - if (\PDO::PARAM_BOOL === $pdoType) { - $value = (int) $value; - $pdoType = \PDO::PARAM_INT; + if ($pdoType === PDO::PARAM_BOOL) { + $value = (int)$value; + $pdoType = PDO::PARAM_INT; return $stmt->bindValue($parameter, $value, $pdoType); } @@ -182,6 +185,7 @@ public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cM /** * Prepare the parameters for a PDO connection. * Protects MySQL from charset injection risk. + * * @see http://www.propelorm.org/ticket/1360 * * @param array $params the connection parameters from the configuration @@ -191,7 +195,7 @@ public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cM protected function prepareParams($params) { if (isset($params['settings']['charset'])) { - if (false === strpos($params['dsn'], ';charset=')) { + if (strpos($params['dsn'], ';charset=') === false) { $params['dsn'] .= ';charset=' . $params['settings']['charset']; unset($params['settings']['charset']); } diff --git a/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php b/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php index b8f054c57c..5e7d6563e8 100644 --- a/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php @@ -10,13 +10,14 @@ namespace Propel\Runtime\Adapter\Pdo; +use PDOStatement; +use Propel\Generator\Model\PropelTypes; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Adapter\AdapterInterface; use Propel\Runtime\Adapter\SqlAdapterInterface; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\InvalidArgumentException; use Propel\Runtime\Map\ColumnMap; -use Propel\Generator\Model\PropelTypes; /** * Oracle adapter. @@ -37,8 +38,9 @@ class OracleAdapter extends PdoAdapter implements SqlAdapterInterface * * @see parent::initConnection() * - * @param ConnectionInterface $con + * @param \Propel\Runtime\Connection\ConnectionInterface $con * @param array $settings + * * @return void */ public function initConnection(ConnectionInterface $con, array $settings) @@ -47,7 +49,7 @@ public function initConnection(ConnectionInterface $con, array $settings) $con->exec("ALTER SESSION SET NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SS'"); if (isset($settings['queries']) && is_array($settings['queries'])) { foreach ($settings['queries'] as $queries) { - foreach ((array) $queries as $query) { + foreach ((array)$queries as $query) { $con->exec($query); } } @@ -72,15 +74,15 @@ public function concatString($s1, $s2) */ public function compareRegex($left, $right) { - return sprintf("REGEXP_LIKE(%s, %s)", $left, $right); + return sprintf('REGEXP_LIKE(%s, %s)', $left, $right); } /** * Returns SQL which extracts a substring. * - * @param string $s String to extract from. - * @param integer $pos Offset to start from. - * @param integer $len Number of characters to extract. + * @param string $s String to extract from. + * @param int $pos Offset to start from. + * @param int $len Number of characters to extract. * * @return string */ @@ -92,7 +94,8 @@ public function subString($s, $pos, $len) /** * Returns SQL which calculates the length (in chars) of a string. * - * @param string $s String to calculate length of. + * @param string $s String to calculate length of. + * * @return string */ public function strLength($s) @@ -103,10 +106,11 @@ public function strLength($s) /** * @see AdapterInterface::applyLimit() * - * @param string $sql - * @param integer $offset - * @param integer $limit - * @param null|Criteria $criteria + * @param string $sql + * @param int $offset + * @param int $limit + * @param \Propel\Runtime\ActiveQuery\Criteria|null $criteria + * * @return void */ public function applyLimit(&$sql, $offset, $limit, $criteria = null) @@ -140,15 +144,16 @@ protected function getIdMethod() } /** - * @param ConnectionInterface $con - * @param string $name + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * @param string|null $name * * @throws \Propel\Runtime\Exception\InvalidArgumentException - * @return integer + * + * @return int */ public function getId(ConnectionInterface $con, $name = null) { - if (null === $name) { + if ($name === null) { throw new InvalidArgumentException('Unable to fetch next sequence ID without sequence name.'); } @@ -158,7 +163,8 @@ public function getId(ConnectionInterface $con, $name = null) } /** - * @param string $seed + * @param string|null $seed + * * @return string */ public function random($seed = null) @@ -172,8 +178,9 @@ public function random($seed = null) * * @see http://propel.phpdb.org/trac/ticket/795 * - * @param Criteria $criteria - * @return Criteria The input, with Select columns replaced by aliases + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria + * + * @return \Propel\Runtime\ActiveQuery\Criteria The input, with Select columns replaced by aliases */ public function turnSelectColumnsToAliases(Criteria $criteria) { @@ -185,7 +192,7 @@ public function turnSelectColumnsToAliases(Criteria $criteria) // add the select columns back foreach ($selectColumns as $id => $clause) { // Generate a unique alias - $baseAlias = "ORA_COL_ALIAS_".$id; + $baseAlias = 'ORA_COL_ALIAS_' . $id; $alias = $baseAlias; // If it already exists, add a unique suffix $i = 0; @@ -209,17 +216,17 @@ public function turnSelectColumnsToAliases(Criteria $criteria) * @see AdapterInterface::bindValue() * * @param \PDOStatement $stmt - * @param string $parameter - * @param mixed $value - * @param ColumnMap $cMap - * @param null|integer $position + * @param string $parameter + * @param mixed $value + * @param \Propel\Runtime\Map\ColumnMap $cMap + * @param int|null $position * - * @return boolean + * @return bool */ - public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) { - if (PropelTypes::CLOB_EMU === $cMap->getType()) { - return $stmt->bindParam(':p'.$position, $value, $cMap->getPdoType(), strlen($value)); + if ($cMap->getType() === PropelTypes::CLOB_EMU) { + return $stmt->bindParam(':p' . $position, $value, $cMap->getPdoType(), strlen($value)); } if ($cMap->isTemporal()) { @@ -237,6 +244,7 @@ public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cM * We need to replace oracle: to oci: in connection's dsn. * * @param array $params + * * @return array */ protected function prepareParams($params) diff --git a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php index 540ada0ca5..15d008a17c 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php @@ -10,6 +10,11 @@ namespace Propel\Runtime\Adapter\Pdo; +use PDO; +use PDOException; +use PDOStatement; +use Propel\Generator\Model\PropelTypes; +use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Adapter\AdapterInterface; use Propel\Runtime\Adapter\Exception\AdapterException; use Propel\Runtime\Connection\ConnectionInterface; @@ -17,25 +22,22 @@ use Propel\Runtime\Exception\InvalidArgumentException; use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\DatabaseMap; -use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Util\PropelDateTime; -use Propel\Generator\Model\PropelTypes; /** * Base for PDO database adapters. */ abstract class PdoAdapter { - /** * Build database connection * * @param array $conparams connection parameters * - * @return PdoConnection + * @throws \Propel\Runtime\Exception\InvalidArgumentException + * @throws \Propel\Runtime\Adapter\Exception\AdapterException * - * @throws InvalidArgumentException - * @throws AdapterException + * @return \Propel\Runtime\Connection\PdoConnection */ public function getConnection($conparams) { @@ -45,8 +47,8 @@ public function getConnection($conparams) throw new InvalidArgumentException('No dsn specified in your connection parameters'); } - $dsn = $conparams['dsn']; - $user = isset($conparams['user']) ? $conparams['user'] : null; + $dsn = $conparams['dsn']; + $user = isset($conparams['user']) ? $conparams['user'] : null; $password = isset($conparams['password']) ? $conparams['password'] : null; // load any driver options from the config file @@ -55,7 +57,7 @@ public function getConnection($conparams) if (isset($conparams['options']) && is_array($conparams['options'])) { foreach ($conparams['options'] as $option => $optiondata) { $value = $optiondata; - if (is_string($value) && false !== strpos($value, '::')) { + if (is_string($value) && strpos($value, '::') !== false) { if (!defined($value)) { throw new InvalidArgumentException(sprintf('Error processing driver options for dsn "%s"', $dsn)); } @@ -68,8 +70,8 @@ public function getConnection($conparams) try { $con = new PdoConnection($dsn, $user, $password, $driver_options); $this->initConnection($con, isset($conparams['settings']) && is_array($conparams['settings']) ? $conparams['settings'] : []); - } catch (\PDOException $e) { - throw new AdapterException("Unable to open PDO connection", 0, $e); + } catch (PDOException $e) { + throw new AdapterException('Unable to open PDO connection', 0, $e); } return $con; @@ -80,7 +82,7 @@ public function getConnection($conparams) */ public function compareRegex($left, $right) { - return sprintf("%s REGEXP %s", $left, $right); + return sprintf('%s REGEXP %s', $left, $right); } /** @@ -88,7 +90,7 @@ public function compareRegex($left, $right) */ public function getAdapterId() { - $class = str_replace('Adapter', '', get_called_class()); + $class = str_replace('Adapter', '', static::class); $lastSlash = strrpos($class, '\\'); return strtolower(substr($class, $lastSlash + 1)); @@ -117,8 +119,9 @@ protected function prepareParams($conparams) * * @see setCharset() * - * @param ConnectionInterface $con - * @param array $settings An array of settings. + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * @param array $settings An array of settings. + * * @return void */ public function initConnection(ConnectionInterface $con, array $settings) @@ -142,8 +145,9 @@ public function initConnection(ConnectionInterface $con, array $settings) * * @see initConnection() * - * @param ConnectionInterface $con - * @param string $charset The $string charset encoding. + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * @param string $charset The $string charset encoding. + * * @return void */ public function setCharset(ConnectionInterface $con, $charset) @@ -154,7 +158,8 @@ public function setCharset(ConnectionInterface $con, $charset) /** * This method is used to ignore case. * - * @param string $in The string to transform to upper case. + * @param string $in The string to transform to upper case. + * * @return string The upper case string. */ public function toUpperCase($in) @@ -165,7 +170,8 @@ public function toUpperCase($in) /** * This method is used to ignore case. * - * @param string $in The string whose case to ignore. + * @param string $in The string whose case to ignore. + * * @return string The string in a case that can be ignored. */ public function ignoreCase($in) @@ -179,7 +185,8 @@ public function ignoreCase($in) * (Interbase for example) does not use the same SQL in ORDER BY * and other clauses. * - * @param string $in The string whose case to ignore. + * @param string $in The string whose case to ignore. + * * @return string The string in a case that can be ignored. */ public function ignoreCaseInOrderBy($in) @@ -201,7 +208,9 @@ public function getStringDelimiter() /** * Quotes database object identifiers (table names, col names, sequences, etc.). - * @param string $text The identifier to quote. + * + * @param string $text The identifier to quote. + * * @return string The quoted identifier. */ public function quoteIdentifier($text) @@ -216,11 +225,12 @@ public function quoteIdentifier($text) * author_id => `author_id` * * @param string $text + * * @return string */ public function quote($text) { - if (false !== ($pos = strrpos($text, '.'))) { + if (($pos = strrpos($text, '.')) !== false) { $table = substr($text, 0, $pos); $column = substr($text, $pos + 1); } else { @@ -241,7 +251,8 @@ public function quote($text) * separate schema names from table names. Adapters for RDBMs which support * schemas have to implement that in the platform-specific way. * - * @param string $table The table name to quo + * @param string $table The table name to quo + * * @return string The quoted table name */ public function quoteIdentifierTable($table) @@ -252,7 +263,7 @@ public function quoteIdentifierTable($table) /** * Returns the native ID method for this RDBMS. * - * @return integer One of AdapterInterface:ID_METHOD_SEQUENCE, AdapterInterface::ID_METHOD_AUTOINCREMENT. + * @return int One of AdapterInterface:ID_METHOD_SEQUENCE, AdapterInterface::ID_METHOD_AUTOINCREMENT. */ protected function getIdMethod() { @@ -262,28 +273,28 @@ protected function getIdMethod() /** * Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT. * - * @return boolean + * @return bool */ public function isGetIdBeforeInsert() { - return AdapterInterface::ID_METHOD_SEQUENCE === $this->getIdMethod(); + return $this->getIdMethod() === AdapterInterface::ID_METHOD_SEQUENCE; } /** * Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT. * - * @return boolean + * @return bool */ public function isGetIdAfterInsert() { - return AdapterInterface::ID_METHOD_AUTOINCREMENT === $this->getIdMethod(); + return $this->getIdMethod() === AdapterInterface::ID_METHOD_AUTOINCREMENT; } /** * Gets the generated ID (either last ID for autoincrement or next sequence ID). * - * @param ConnectionInterface $con - * @param string $name + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * @param string|null $name * * @return mixed */ @@ -295,27 +306,30 @@ public function getId(ConnectionInterface $con, $name = null) /** * Formats a temporal value before binding, given a ColumnMap object * - * @param mixed $value The temporal value - * @param ColumnMap $cMap + * @param mixed $value The temporal value + * @param \Propel\Runtime\Map\ColumnMap $cMap * * @return string The formatted temporal value */ public function formatTemporalValue($value, ColumnMap $cMap) { - /** @var PropelDateTime|null $dt */ + /** @var \Propel\Runtime\Util\PropelDateTime|null $dt */ $dt = PropelDateTime::newInstance($value); if ($dt) { switch ($cMap->getType()) { case PropelTypes::TIMESTAMP: case PropelTypes::BU_TIMESTAMP: $value = $dt->format($this->getTimestampFormatter()); + break; case PropelTypes::DATE: case PropelTypes::BU_DATE: $value = $dt->format($this->getDateFormatter()); + break; case PropelTypes::TIME: $value = $dt->format($this->getTimeFormatter()); + break; } } @@ -334,7 +348,7 @@ public function getTimestampFormatter() } /** - * @param Criteria $criteria + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria * * @return string */ @@ -371,10 +385,11 @@ public function getTimeFormatter() /** * Allows manipulation of the query string before StatementPdo is instantiated. * - * @param string $sql The sql statement - * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) - * @param Criteria $values - * @param DatabaseMap $dbMap + * @param string $sql The sql statement + * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) + * @param \Propel\Runtime\ActiveQuery\Criteria $values + * @param \Propel\Runtime\Map\DatabaseMap $dbMap + * * @return void */ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap) @@ -384,8 +399,8 @@ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap /** * Returns the "DELETE FROM
[AS ]" part of DELETE query. * - * @param Criteria $criteria - * @param string $tableName + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria + * @param string $tableName * * @return string */ @@ -411,9 +426,9 @@ public function getDeleteFromClause(Criteria $criteria, $tableName) * Builds the SELECT part of a SQL statement based on a Criteria * taking into account select columns and 'as' columns (i.e. columns aliases) * - * @param Criteria $criteria - * @param array $fromClause - * @param boolean $aliasAll + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria + * @param array $fromClause + * @param bool $aliasAll * * @return string */ @@ -426,7 +441,6 @@ public function createSelectSqlPart(Criteria $criteria, &$fromClause, $aliasAll // no select columns after that, they are all aliases } else { foreach ($criteria->getSelectColumns() as $columnName) { - // expect every column to be of "table.column" formation // it could be a function: e.g. MAX(books.price) $tableName = null; @@ -436,8 +450,8 @@ public function createSelectSqlPart(Criteria $criteria, &$fromClause, $aliasAll $parenPos = strrpos($columnName, '('); $dotPos = strrpos($columnName, '.', ($parenPos !== false ? $parenPos : 0)); - if (false !== $dotPos) { - if (false === $parenPos) { // table.column + if ($dotPos !== false) { + if ($parenPos === false) { // table.column $tableName = substr($columnName, 0, $dotPos); } else { // FUNC(table.column) // functions may contain qualifiers so only take the last @@ -445,7 +459,7 @@ public function createSelectSqlPart(Criteria $criteria, &$fromClause, $aliasAll // COUNT(DISTINCT books.price) $tableName = substr($columnName, $parenPos + 1, $dotPos - ($parenPos + 1)); $lastSpace = strrpos($tableName, ' '); - if (false !== $lastSpace) { // COUNT(DISTINCT books.price) + if ($lastSpace !== false) { // COUNT(DISTINCT books.price) $tableName = substr($tableName, $lastSpace + 1); } } @@ -469,11 +483,10 @@ public function createSelectSqlPart(Criteria $criteria, &$fromClause, $aliasAll $queryComment = $criteria->getComment(); // Build the SQL from the arrays we compiled - $sql = 'SELECT ' + $sql = 'SELECT ' . ($queryComment ? '/* ' . $queryComment . ' */ ' : '') . ($selectModifiers ? (implode(' ', $selectModifiers) . ' ') : '') - . implode(', ', $selectClause) - ; + . implode(', ', $selectClause); return $sql; } @@ -481,20 +494,21 @@ public function createSelectSqlPart(Criteria $criteria, &$fromClause, $aliasAll /** * Returns all selected columns that are selected without a aggregate function. * - * @param Criteria $criteria + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria + * * @return string[] */ public function getPlainSelectedColumns(Criteria $criteria) { $selected = []; foreach ($criteria->getSelectColumns() as $columnName) { - if (false === strpos($columnName, '(')) { + if (strpos($columnName, '(') === false) { $selected[] = $columnName; } } foreach ($criteria->getAsColumns() as $alias => $col) { - if (false === strpos($col, '(') && !in_array($col, $selected)) { + if (strpos($col, '(') === false && !in_array($col, $selected)) { $selected[] = $col; } } @@ -508,8 +522,9 @@ public function getPlainSelectedColumns(Criteria $criteria) * * @see http://propel.phpdb.org/trac/ticket/795 * - * @param Criteria $criteria - * @return Criteria The input, with Select columns replaced by aliases + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria + * + * @return \Propel\Runtime\ActiveQuery\Criteria The input, with Select columns replaced by aliases */ public function turnSelectColumnsToAliases(Criteria $criteria) { @@ -558,25 +573,28 @@ public function turnSelectColumnsToAliases(Criteria $criteria) * * * @param \PDOStatement $stmt - * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) - * @param DatabaseMap $dbMap + * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) + * @param \Propel\Runtime\Map\DatabaseMap $dbMap + * * @return void */ - public function bindValues(\PDOStatement $stmt, array $params, DatabaseMap $dbMap) + public function bindValues(PDOStatement $stmt, array $params, DatabaseMap $dbMap) { $position = 0; foreach ($params as $param) { $position++; $parameter = ':p' . $position; $value = $param['value']; - if (null === $value) { - $stmt->bindValue($parameter, null, \PDO::PARAM_NULL); + if ($value === null) { + $stmt->bindValue($parameter, null, PDO::PARAM_NULL); + continue; } $tableName = $param['table']; - if (null === $tableName) { - $type = isset($param['type']) ? $param['type'] : \PDO::PARAM_STR; + if ($tableName === null) { + $type = isset($param['type']) ? $param['type'] : PDO::PARAM_STR; $stmt->bindValue($parameter, $value, $type); + continue; } $cMap = $dbMap->getTable($tableName)->getColumn($param['column']); @@ -588,15 +606,15 @@ public function bindValues(\PDOStatement $stmt, array $params, DatabaseMap $dbMa * Binds a value to a positioned parameter in a statement, * given a ColumnMap object to infer the binding type. * - * @param \PDOStatement $stmt The statement to bind - * @param string $parameter Parameter identifier - * @param mixed $value The value to bind - * @param ColumnMap $cMap The ColumnMap of the column to bind - * @param null|integer $position The position of the parameter to bind + * @param \PDOStatement $stmt The statement to bind + * @param string $parameter Parameter identifier + * @param mixed $value The value to bind + * @param \Propel\Runtime\Map\ColumnMap $cMap The ColumnMap of the column to bind + * @param int|null $position The position of the parameter to bind * - * @return boolean + * @return bool */ - public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) { if ($cMap->isTemporal()) { $value = $this->formatTemporalValue($value, $cMap); @@ -608,5 +626,4 @@ public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cM return $stmt->bindValue($parameter, $value, $cMap->getPdoType()); } - } diff --git a/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php index b68bfbd631..bac84c0601 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php @@ -10,14 +10,12 @@ namespace Propel\Runtime\Adapter\Pdo; -use PDOStatement; +use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Adapter\AdapterInterface; use Propel\Runtime\Adapter\SqlAdapterInterface; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\InvalidArgumentException; -use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Propel; -use Propel\Runtime\ActiveQuery\Criteria; /** * This is used to connect to PostgreSQL databases. @@ -45,27 +43,28 @@ public function concatString($s1, $s2) */ public function compareRegex($left, $right) { - return sprintf("%s ~* %s", $left, $right); + return sprintf('%s ~* %s', $left, $right); } /** * Returns SQL which extracts a substring. * - * @param string $s String to extract from. - * @param integer $pos Offset to start from. - * @param integer $len Number of characters to extract. + * @param string $s String to extract from. + * @param int $pos Offset to start from. + * @param int $len Number of characters to extract. * * @return string */ public function subString($s, $pos, $len) { - return "substring($s from $pos" . ($len > -1 ? "for $len" : "") . ")"; + return "substring($s from $pos" . ($len > -1 ? "for $len" : '') . ')'; } /** * Returns SQL which calculates the length (in chars) of a string. * - * @param string $s String to calculate length of. + * @param string $s String to calculate length of. + * * @return string */ public function strLength($s) @@ -76,7 +75,7 @@ public function strLength($s) /** * @see AdapterInterface::getIdMethod() * - * @return integer + * @return int */ protected function getIdMethod() { @@ -86,15 +85,17 @@ protected function getIdMethod() /** * Gets ID for specified sequence name. * - * @param ConnectionInterface $con - * @param string $name + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * @param string|null $name * - * @return integer + * @throws \Propel\Runtime\Exception\InvalidArgumentException + * + * @return int */ public function getId(ConnectionInterface $con, $name = null) { - if (null === $name) { - throw new InvalidArgumentException("Unable to fetch next sequence ID without sequence name."); + if ($name === null) { + throw new InvalidArgumentException('Unable to fetch next sequence ID without sequence name.'); } $dataFetcher = $con->query(sprintf('SELECT nextval(%s)', $con->quote($name))); @@ -103,6 +104,7 @@ public function getId(ConnectionInterface $con, $name = null) /** * Returns timestamp formatter string for use in date() function. + * * @return string */ public function getTimestampFormatter() @@ -123,9 +125,10 @@ public function getTimeFormatter() /** * @see AdapterInterface::applyLimit() * - * @param string $sql - * @param integer $offset - * @param integer $limit + * @param string $sql + * @param int $offset + * @param int $limit + * * @return void */ public function applyLimit(&$sql, $offset, $limit) @@ -139,7 +142,7 @@ public function applyLimit(&$sql, $offset, $limit) } /** - * @param Criteria $criteria + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria * * @return string */ @@ -154,7 +157,6 @@ public function getGroupBy(Criteria $criteria) foreach ($selected as $colName) { if (!in_array($colName, $groupBy)) { - // is a alias there that is grouped? if ($alias = array_search($colName, $asSelects)) { if (in_array($alias, $groupBy)) { @@ -176,7 +178,8 @@ public function getGroupBy(Criteria $criteria) /** * @see AdapterInterface::random() * - * @param string $seed + * @param string|null $seed + * * @return string */ public function random($seed = null) @@ -187,8 +190,8 @@ public function random($seed = null) /** * @see PdoAdapter::getDeleteFromClause() * - * @param Criteria $criteria - * @param string $tableName + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria + * @param string $tableName * * @return string */ @@ -212,7 +215,8 @@ public function getDeleteFromClause(Criteria $criteria, $tableName) /** * @see AdapterInterface::quoteIdentifierTable() * - * @param string $table + * @param string $table + * * @return string */ public function quoteIdentifierTable($table) @@ -224,11 +228,10 @@ public function quoteIdentifierTable($table) /** * Do Explain Plan for query object or query string * - * @param ConnectionInterface $con propel connection - * @param Criteria|string $query query the criteria or the query string + * @param \Propel\Runtime\Connection\ConnectionInterface $con propel connection + * @param \Propel\Runtime\ActiveQuery\Criteria|string $query query the criteria or the query string * - * @throws PropelException - * @return PDOStatement A PDO statement executed using the connection, ready to be fetched + * @return \PDOStatement A PDO statement executed using the connection, ready to be fetched */ public function doExplainPlan(ConnectionInterface $con, $query) { @@ -255,6 +258,7 @@ public function doExplainPlan(ConnectionInterface $con, $query) * Explain Plan compute query getter * * @param string $query query to explain + * * @return string */ public function getExplainPlanQuery($query) diff --git a/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php b/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php index a373eca88b..21be021c7a 100644 --- a/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php @@ -20,15 +20,13 @@ */ class SqliteAdapter extends PdoAdapter implements SqlAdapterInterface { - /** * For SQLite this method has no effect, since SQLite doesn't support specifying a character * set (or, another way to look at it, it doesn't require a single character set per DB). * - * @param ConnectionInterface $con A PDO connection instance. - * @param string $charset The charset encoding. + * @param \Propel\Runtime\Connection\ConnectionInterface $con A PDO connection instance. + * @param string $charset The charset encoding. * - * @throws \Propel\Runtime\Exception\PropelException If the specified charset doesn't match sqlite_libencoding() * @return void */ public function setCharset(ConnectionInterface $con, $charset) @@ -47,9 +45,10 @@ public function initConnection(ConnectionInterface $con, array $settings) parent::initConnection($con, $settings); //add regex support - $con->sqliteCreateFunction('regexp', function($pattern, $value) { + $con->sqliteCreateFunction('regexp', function ($pattern, $value) { mb_regex_encoding('UTF-8'); - return (false !== mb_ereg($pattern, $value)) ? 1 : 0; + + return (mb_ereg($pattern, $value) !== false) ? 1 : 0; }); } @@ -69,9 +68,9 @@ public function concatString($s1, $s2) /** * Returns SQL which extracts a substring. * - * @param string $s String to extract from. - * @param integer $pos Offset to start from. - * @param integer $len Number of characters to extract. + * @param string $s String to extract from. + * @param int $pos Offset to start from. + * @param int $len Number of characters to extract. * * @return string */ @@ -83,7 +82,8 @@ public function subString($s, $pos, $len) /** * Returns SQL which calculates the length (in chars) of a string. * - * @param string $s String to calculate length of. + * @param string $s String to calculate length of. + * * @return string */ public function strLength($s) @@ -94,7 +94,8 @@ public function strLength($s) /** * @see AdapterInterface::quoteIdentifier() * - * @param string $text + * @param string $text + * * @return string */ public function quoteIdentifier($text) @@ -105,9 +106,10 @@ public function quoteIdentifier($text) /** * @see AdapterInterface::applyLimit() * - * @param string $sql - * @param integer $offset - * @param integer $limit + * @param string $sql + * @param int $offset + * @param int $limit + * * @return void */ public function applyLimit(&$sql, $offset, $limit) @@ -120,7 +122,8 @@ public function applyLimit(&$sql, $offset, $limit) } /** - * @param string $seed + * @param string|null $seed + * * @return string */ public function random($seed = null) diff --git a/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php b/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php index 94f96aa79f..13ed387ddb 100644 --- a/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php @@ -10,10 +10,12 @@ namespace Propel\Runtime\Adapter\Pdo; -use Propel\Runtime\Adapter\SqlAdapterInterface; +use PDO; +use PDOStatement; +use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Adapter\Exception\UnsupportedEncodingException; +use Propel\Runtime\Adapter\SqlAdapterInterface; use Propel\Runtime\Connection\ConnectionInterface; -use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\DatabaseMap; @@ -27,14 +29,15 @@ class SqlsrvAdapter extends MssqlAdapter implements SqlAdapterInterface /** * @see parent::initConnection() * - * @param ConnectionInterface $con - * @param array $settings An array of settings. + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * @param array $settings An array of settings. + * * @return void */ public function initConnection(ConnectionInterface $con, array $settings) { - $con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - $con->setAttribute(\PDO::ATTR_STRINGIFY_FETCHES, false); + $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $con->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); parent::initConnection($con, $settings); } @@ -42,20 +45,23 @@ public function initConnection(ConnectionInterface $con, array $settings) /** * @see parent::setCharset() * - * @param ConnectionInterface $con - * @param string $charset + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * @param string $charset * * @throws \Propel\Runtime\Adapter\Exception\UnsupportedEncodingException + * * @return void */ public function setCharset(ConnectionInterface $con, $charset) { switch (strtolower($charset)) { case 'utf-8': - $con->setAttribute(\PDO::SQLSRV_ATTR_ENCODING, \PDO::SQLSRV_ENCODING_UTF8); + $con->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_UTF8); + break; case 'system': - $con->setAttribute(\PDO::SQLSRV_ATTR_ENCODING, \PDO::SQLSRV_ENCODING_SYSTEM); + $con->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_SYSTEM); + break; default: throw new UnsupportedEncodingException('only utf-8 or system encoding are supported by the pdo_sqlsrv driver'); @@ -65,10 +71,11 @@ public function setCharset(ConnectionInterface $con, $charset) /** * @see parent::cleanupSQL() * - * @param string $sql - * @param array $params - * @param Criteria $values - * @param DatabaseMap $dbMap + * @param string $sql + * @param array $params + * @param \Propel\Runtime\ActiveQuery\Criteria $values + * @param \Propel\Runtime\Map\DatabaseMap $dbMap + * * @return void */ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap) @@ -81,9 +88,9 @@ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap // this is to workaround for a bug with pdo_sqlsrv inserting or updating blobs with null values // http://social.msdn.microsoft.com/Forums/en-US/sqldriverforphp/thread/5a755bdd-41e9-45cb-9166-c9da4475bb94 - if (null !== $tableName) { + if ($tableName !== null) { $cMap = $dbMap->getTable($tableName)->getColumn($columnName); - if (null === $value && $cMap->isLob()) { + if ($value === null && $cMap->isLob()) { $sql = str_replace(":p$i", "CONVERT(VARBINARY(MAX), :p$i)", $sql); } } @@ -95,14 +102,14 @@ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap * @see AdapterInterface::bindValue() * * @param \PDOStatement $stmt - * @param string $parameter - * @param mixed $value - * @param ColumnMap $cMap - * @param null|integer $position + * @param string $parameter + * @param mixed $value + * @param \Propel\Runtime\Map\ColumnMap $cMap + * @param int|null $position * - * @return boolean + * @return bool */ - public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) { if ($cMap->isTemporal()) { $value = $this->formatTemporalValue($value, $cMap); @@ -114,10 +121,10 @@ public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cM // driver option can be utilized. This requires a unique blob parameter because the bindParam // value is passed by reference and if we didn't do this then the referenced parameter value // would change on the next loop - $blob = 'blob'.$position; + $blob = 'blob' . $position; $$blob = $value; - return $stmt->bindParam($parameter, ${$blob}, \PDO::PARAM_LOB, 0, \PDO::SQLSRV_ENCODING_BINARY); + return $stmt->bindParam($parameter, ${$blob}, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY); } return $stmt->bindValue($parameter, $value, $cMap->getPdoType()); diff --git a/src/Propel/Runtime/Adapter/SqlAdapterInterface.php b/src/Propel/Runtime/Adapter/SqlAdapterInterface.php index de7d3e9211..e1d7ebc377 100644 --- a/src/Propel/Runtime/Adapter/SqlAdapterInterface.php +++ b/src/Propel/Runtime/Adapter/SqlAdapterInterface.php @@ -10,21 +10,21 @@ namespace Propel\Runtime\Adapter; +use PDOStatement; +use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\DatabaseMap; -use Propel\Runtime\ActiveQuery\Criteria; /** * Interface for adapters. - * */ interface SqlAdapterInterface extends AdapterInterface { - /** * This method is used to ignore case. * - * @param string $in The string to transform to upper case. + * @param string $in The string to transform to upper case. + * * @return string The upper case string. */ public function toUpperCase($in); @@ -32,7 +32,8 @@ public function toUpperCase($in); /** * This method is used to ignore case. * - * @param string $in The string whose case to ignore. + * @param string $in The string whose case to ignore. + * * @return string The string in a case that can be ignored. */ public function ignoreCase($in); @@ -40,19 +41,19 @@ public function ignoreCase($in); /** * Allows manipulation of the query string before StatementPdo is instantiated. * - * @param string $sql The sql statement - * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) - * @param Criteria $values - * @param DatabaseMap $dbMap + * @param string $sql The sql statement + * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) + * @param \Propel\Runtime\ActiveQuery\Criteria $values + * @param \Propel\Runtime\Map\DatabaseMap $dbMap */ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap); /** * Modifies the passed-in SQL to add LIMIT and/or OFFSET. * - * @param string $sql - * @param integer $offset - * @param integer $limit + * @param string $sql + * @param int $offset + * @param int $limit */ public function applyLimit(&$sql, $offset, $limit); @@ -66,8 +67,8 @@ public function random($seed = null); /** * Returns the "DELETE FROM
[AS ]" part of DELETE query. * - * @param Criteria $criteria - * @param string $tableName + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria + * @param string $tableName * * @return string */ @@ -77,9 +78,9 @@ public function getDeleteFromClause(Criteria $criteria, $tableName); * Builds the SELECT part of a SQL statement based on a Criteria * taking into account select columns and 'as' columns (i.e. columns aliases) * - * @param Criteria $criteria - * @param array $fromClause - * @param boolean $aliasAll + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria + * @param array $fromClause + * @param bool $aliasAll * * @return string */ @@ -91,8 +92,9 @@ public function createSelectSqlPart(Criteria $criteria, &$fromClause, $aliasAll * * @see http://propel.phpdb.org/trac/ticket/795 * - * @param Criteria $criteria - * @return Criteria The input, with Select columns replaced by aliases + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria + * + * @return \Propel\Runtime\ActiveQuery\Criteria The input, with Select columns replaced by aliases */ public function turnSelectColumnsToAliases(Criteria $criteria); @@ -113,22 +115,22 @@ public function turnSelectColumnsToAliases(Criteria $criteria); * * * @param \PDOStatement $stmt - * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) - * @param DatabaseMap $dbMap + * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) + * @param \Propel\Runtime\Map\DatabaseMap $dbMap */ - public function bindValues(\PDOStatement $stmt, array $params, DatabaseMap $dbMap); + public function bindValues(PDOStatement $stmt, array $params, DatabaseMap $dbMap); /** * Binds a value to a positioned parameter in a statement, * given a ColumnMap object to infer the binding type. * - * @param \PDOStatement $stmt The statement to bind - * @param string $parameter Parameter identifier - * @param mixed $value The value to bind - * @param ColumnMap $cMap The ColumnMap of the column to bind - * @param null|integer $position The position of the parameter to bind + * @param \PDOStatement $stmt The statement to bind + * @param string $parameter Parameter identifier + * @param mixed $value The value to bind + * @param \Propel\Runtime\Map\ColumnMap $cMap The ColumnMap of the column to bind + * @param int|null $position The position of the parameter to bind * - * @return boolean + * @return bool */ - public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null); + public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null); } diff --git a/src/Propel/Runtime/Collection/ArrayCollection.php b/src/Propel/Runtime/Collection/ArrayCollection.php index fc8c9b35fa..82f80efb2a 100644 --- a/src/Propel/Runtime/Collection/ArrayCollection.php +++ b/src/Propel/Runtime/Collection/ArrayCollection.php @@ -10,10 +10,8 @@ namespace Propel\Runtime\Collection; -use Propel\Runtime\ActiveRecord\ActiveRecordInterface; use Propel\Runtime\Collection\Exception\ReadOnlyModelException; use Propel\Runtime\Exception\PropelException; -use Propel\Runtime\Connection\ConnectionInterface; /** * Class for iterating over a list of Propel objects stored as arrays @@ -30,10 +28,10 @@ class ArrayCollection extends Collection /** * Save all the elements in the collection * - * @param ConnectionInterface $con + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con + * + * @throws \Propel\Runtime\Collection\Exception\ReadOnlyModelException * - * @throws ReadOnlyModelException - * @throws PropelException * @return void */ public function save($con = null) @@ -41,7 +39,7 @@ public function save($con = null) if (!method_exists($this->getFullyQualifiedModel(), 'save')) { throw new ReadOnlyModelException('Cannot save objects on a read-only model'); } - if (null === $con) { + if ($con === null) { $con = $this->getWriteConnection(); } $con->transaction(function () use ($con) { @@ -58,10 +56,10 @@ public function save($con = null) /** * Delete all the elements in the collection * - * @param ConnectionInterface $con + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con + * + * @throws \Propel\Runtime\Collection\Exception\ReadOnlyModelException * - * @throws ReadOnlyModelException - * @throws PropelException * @return void */ public function delete($con = null) @@ -69,7 +67,7 @@ public function delete($con = null) if (!method_exists($this->getFullyQualifiedModel(), 'delete')) { throw new ReadOnlyModelException('Cannot delete objects on a read-only model'); } - if (null === $con) { + if ($con === null) { $con = $this->getWriteConnection(); } $con->transaction(function () use ($con) { @@ -85,16 +83,17 @@ public function delete($con = null) /** * Get an array of the primary keys of all the objects in the collection * - * @param boolean $usePrefix - * @return array The list of the primary keys of the collection + * @param bool $usePrefix + * + * @return array The list of the primary keys of the collection */ public function getPrimaryKeys($usePrefix = true) { - $ret = []; + $ret = []; $callable = [$this->getTableMapClass(), 'getPrimaryKeyFromRow']; foreach ($this as $key => $element) { - $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; + $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; $ret[$key] = call_user_func($callable, array_values($element)); } @@ -107,11 +106,12 @@ public function getPrimaryKeys($usePrefix = true) * Does not empty the collection before adding the data from the array * * @param array $arr + * * @return void */ public function fromArray($arr) { - $obj = $this->getWorkerObject(); + $obj = $this->getWorkerObject(); foreach ($arr as $element) { $obj->clear(); $obj->fromArray($element); @@ -123,26 +123,25 @@ public function fromArray($arr) * Get an array representation of the collection * This is not an alias for getData(), since it returns a copy of the data * - * @param string $keyColumn If null, the returned array uses an incremental index. + * @param string|null $keyColumn If null, the returned array uses an incremental index. * Otherwise, the array is indexed using the specified column - * @param boolean $usePrefix If true, the returned array prefixes keys - * with the model class name ('Article_0', 'Article_1', etc). - * + * @param bool $usePrefix If true, the returned array prefixes keys + * with the model class name ('Article_0', 'Article_1', etc). * * $bookCollection->toArray(); * array( - * 0 => array('Id' => 123, 'Title' => 'War And Peace'), - * 1 => array('Id' => 456, 'Title' => 'Don Juan'), + * 0 => array('Id' => 123, 'Title' => 'War And Peace'), + * 1 => array('Id' => 456, 'Title' => 'Don Juan'), * ) * $bookCollection->toArray('Id'); * array( - * 123 => array('Id' => 123, 'Title' => 'War And Peace'), - * 456 => array('Id' => 456, 'Title' => 'Don Juan'), + * 123 => array('Id' => 123, 'Title' => 'War And Peace'), + * 456 => array('Id' => 456, 'Title' => 'Don Juan'), * ) * $bookCollection->toArray(null, true); * array( - * 'Book_0' => array('Id' => 123, 'Title' => 'War And Peace'), - * 'Book_1' => array('Id' => 456, 'Title' => 'Don Juan'), + * 'Book_0' => array('Id' => 123, 'Title' => 'War And Peace'), + * 'Book_1' => array('Id' => 456, 'Title' => 'Don Juan'), * ) * * @@ -152,7 +151,7 @@ public function toArray($keyColumn = null, $usePrefix = false) { $ret = []; foreach ($this as $key => $element) { - $key = null === $keyColumn ? $key : $element[$keyColumn]; + $key = $keyColumn === null ? $key : $element[$keyColumn]; $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; $ret[$key] = $element; } @@ -163,14 +162,14 @@ public function toArray($keyColumn = null, $usePrefix = false) /** * Synonym for toArray(), to provide a similar interface to PropelObjectCollection * - * @param string $keyColumn - * @param boolean $usePrefix + * @param string|null $keyColumn + * @param bool $usePrefix * * @return array */ public function getArrayCopy($keyColumn = null, $usePrefix = false) { - if (null === $keyColumn && false === $usePrefix) { + if ($keyColumn === null && $usePrefix === false) { return parent::getArrayCopy(); } @@ -201,12 +200,13 @@ public function toKeyValue($keyColumn, $valueColumn) } /** - * @throws PropelException - * @return ActiveRecordInterface + * @throws \Propel\Runtime\Exception\PropelException + * + * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface */ protected function getWorkerObject() { - if (null === $this->workerObject) { + if ($this->workerObject === null) { $model = $this->getModel(); if (empty($model)) { throw new PropelException('You must set the collection model before interacting with it'); diff --git a/src/Propel/Runtime/Collection/Collection.php b/src/Propel/Runtime/Collection/Collection.php index 92d2b2b024..c3d74f3287 100644 --- a/src/Propel/Runtime/Collection/Collection.php +++ b/src/Propel/Runtime/Collection/Collection.php @@ -10,35 +10,36 @@ namespace Propel\Runtime\Collection; -use Propel\Common\Pluralizer\PluralizerInterface; +use ArrayAccess; +use Countable; +use IteratorAggregate; use Propel\Common\Pluralizer\StandardEnglishPluralizer; -use Propel\Runtime\Connection\ConnectionInterface; -use Propel\Runtime\Exception\RuntimeException; -use Propel\Runtime\Propel; use Propel\Runtime\Collection\Exception\ModelNotFoundException; use Propel\Runtime\Exception\BadMethodCallException; use Propel\Runtime\Exception\UnexpectedValueException; use Propel\Runtime\Formatter\AbstractFormatter; -use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Map\TableMap; +use Propel\Runtime\Parser\AbstractParser; +use Propel\Runtime\Propel; +use Serializable; /** * Class for iterating over a list of Propel elements * The collection keys must be integers - no associative array accepted * - * @method Collection fromXML(string $data) Populate the collection from an XML string - * @method Collection fromYAML(string $data) Populate the collection from a YAML string - * @method Collection fromJSON(string $data) Populate the collection from a JSON string - * @method Collection fromCSV(string $data) Populate the collection from a CSV string + * @method \Propel\Runtime\Collection\Collection fromXML(string $data) Populate the collection from an XML string + * @method \Propel\Runtime\Collection\Collection fromYAML(string $data) Populate the collection from a YAML string + * @method \Propel\Runtime\Collection\Collection fromJSON(string $data) Populate the collection from a JSON string + * @method \Propel\Runtime\Collection\Collection fromCSV(string $data) Populate the collection from a CSV string * - * @method string toXML(boolean $usePrefix = true, boolean $includeLazyLoadColumns = true) Export the collection to an XML string - * @method string toYAML(boolean $usePrefix = true, boolean $includeLazyLoadColumns = true) Export the collection to a YAML string - * @method string toJSON(boolean $usePrefix = true, boolean $includeLazyLoadColumns = true) Export the collection to a JSON string - * @method string toCSV(boolean $usePrefix = true, boolean $includeLazyLoadColumns = true) Export the collection to a CSV string + * @method string toXML(bool $usePrefix = true, bool $includeLazyLoadColumns = true) Export the collection to an XML string + * @method string toYAML(bool $usePrefix = true, bool $includeLazyLoadColumns = true) Export the collection to a YAML string + * @method string toJSON(bool $usePrefix = true, bool $includeLazyLoadColumns = true) Export the collection to a JSON string + * @method string toCSV(bool $usePrefix = true, bool $includeLazyLoadColumns = true) Export the collection to a CSV string * * @author Francois Zaninotto */ -class Collection implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable +class Collection implements ArrayAccess, IteratorAggregate, Countable, Serializable { /** * @var string @@ -53,7 +54,7 @@ class Collection implements \ArrayAccess, \IteratorAggregate, \Countable, \Seria protected $fullyQualifiedModel = ''; /** - * @var AbstractFormatter + * @var \Propel\Runtime\Formatter\AbstractFormatter */ protected $formatter; @@ -63,10 +64,13 @@ class Collection implements \ArrayAccess, \IteratorAggregate, \Countable, \Seria protected $data = []; /** - * @var PluralizerInterface|null + * @var \Propel\Common\Pluralizer\PluralizerInterface|null */ private $pluralizer; + /** + * @param array $data + */ public function __construct($data = []) { $this->data = $data; @@ -74,6 +78,7 @@ public function __construct($data = []) /** * @param mixed $value + * * @return void */ public function append($value) @@ -82,7 +87,8 @@ public function append($value) } /** - * @param mixed $offset + * @param mixed $offset + * * @return bool */ public function offsetExists($offset) @@ -91,7 +97,8 @@ public function offsetExists($offset) } /** - * @param mixed $offset + * @param mixed $offset + * * @return mixed */ public function &offsetGet($offset) @@ -104,11 +111,12 @@ public function &offsetGet($offset) /** * @param mixed $offset * @param mixed $value + * * @return void */ public function offsetSet($offset, $value) { - if (is_null($offset)) { + if ($offset === null) { $this->data[] = $value; } else { $this->data[$offset] = $value; @@ -117,6 +125,7 @@ public function offsetSet($offset, $value) /** * @param mixed $offset + * * @return void */ public function offsetUnset($offset) @@ -126,6 +135,7 @@ public function offsetUnset($offset) /** * @param array $input + * * @return void */ public function exchangeArray($input) @@ -155,6 +165,7 @@ public function getArrayCopy() * Set the data in the collection * * @param array $data + * * @return void */ public function setData($data) @@ -163,7 +174,7 @@ public function setData($data) } /** - * @return CollectionIterator + * @return \Propel\Runtime\Collection\CollectionIterator */ public function getIterator() { @@ -187,7 +198,7 @@ public function count() */ public function getFirst() { - if (0 === count($this->data)) { + if (count($this->data) === 0) { return null; } reset($this->data); @@ -202,7 +213,7 @@ public function getFirst() */ public function getLast() { - if (0 === $this->count()) { + if ($this->count() === 0) { return null; } @@ -214,18 +225,21 @@ public function getLast() /** * Check if the collection is empty * - * @return boolean + * @return bool */ public function isEmpty() { - return 0 === $this->count(); + return $this->count() === 0; } /** * Get an element from its key * Alias for ArrayObject::offsetGet() * - * @param mixed $key + * @param mixed $key + * + * @throws \Propel\Runtime\Exception\UnexpectedValueException + * * @return mixed The element */ public function get($key) @@ -244,7 +258,7 @@ public function get($key) */ public function pop() { - if (0 === $this->count()) { + if ($this->count() === 0) { return null; } @@ -272,9 +286,10 @@ public function shift() } /** - * Prepend one elements to the end of the collection + * Prepend one elements to the end of the collection * * @param mixed $value the element to prepend + * * @return void */ public function push($value) @@ -285,8 +300,9 @@ public function push($value) /** * Prepend one or more elements to the beginning of the collection * - * @param mixed $value the element to prepend - * @return integer The number of new elements in the array + * @param mixed $value the element to prepend + * + * @return int The number of new elements in the array */ public function prepend($value) { @@ -305,6 +321,7 @@ public function prepend($value) * * @param mixed $key * @param mixed $value + * * @return void */ public function set($key, $value) @@ -316,7 +333,10 @@ public function set($key, $value) * Removes a specified collection element * Alias for ArrayObject::offsetUnset() * - * @param mixed $key + * @param mixed $key + * + * @throws \Propel\Runtime\Exception\UnexpectedValueException + * * @return void */ public function remove($key) @@ -341,8 +361,9 @@ public function clear() /** * Whether or not this collection contains a specified element * - * @param mixed $element - * @return boolean + * @param mixed $element + * + * @return bool */ public function contains($element) { @@ -352,7 +373,8 @@ public function contains($element) /** * Search an element in the collection * - * @param mixed $element + * @param mixed $element + * * @return mixed Returns the key for the element if it is found in the collection, FALSE otherwise */ public function search($element) @@ -364,8 +386,9 @@ public function search($element) * Returns an array of objects present in the collection that * are not presents in the given collection. * - * @param Collection $collection A Propel collection. - * @return Collection An array of Propel objects from the collection that are not presents in the given collection. + * @param \Propel\Runtime\Collection\Collection $collection A Propel collection. + * + * @return \Propel\Runtime\Collection\Collection An array of Propel objects from the collection that are not presents in the given collection. */ public function diff(Collection $collection) { @@ -399,6 +422,7 @@ public function serialize() /** * @param string $data + * * @return void */ public function unserialize($data) @@ -415,6 +439,7 @@ public function unserialize($data) * Set the model of the elements in the collection * * @param string $model Name of the Propel object classes stored in the collection + * * @return void */ public function setModel($model) @@ -424,7 +449,7 @@ public function setModel($model) } else { $this->model = $model; } - $this->fullyQualifiedModel = ((0 === strpos($model, '\\')) ? '' : '\\') . $model; + $this->fullyQualifiedModel = ((strpos($model, '\\') === 0) ? '' : '\\') . $model; } /** @@ -449,6 +474,7 @@ public function getFullyQualifiedModel() /** * @throws \Propel\Runtime\Collection\Exception\ModelNotFoundException + * * @return string */ public function getTableMapClass() @@ -463,7 +489,8 @@ public function getTableMapClass() } /** - * @param AbstractFormatter $formatter + * @param \Propel\Runtime\Formatter\AbstractFormatter $formatter + * * @return void */ public function setFormatter(AbstractFormatter $formatter) @@ -472,7 +499,7 @@ public function setFormatter(AbstractFormatter $formatter) } /** - * @return AbstractFormatter + * @return \Propel\Runtime\Formatter\AbstractFormatter */ public function getFormatter() { @@ -482,7 +509,7 @@ public function getFormatter() /** * Get a write connection object for the database containing the elements of the collection * - * @return ConnectionInterface A ConnectionInterface connection object + * @return \Propel\Runtime\Connection\ConnectionInterface A ConnectionInterface connection object */ public function getWriteConnection() { @@ -499,8 +526,8 @@ public function getWriteConnection() * $coll->importFrom('JSON', '{{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}}'); * * - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param string $data The source data to import from + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from * * @return mixed The current object, for fluid interface */ @@ -523,15 +550,16 @@ public function importFrom($parser, $data) * * A OnDemandCollection cannot be exported. Any attempt will result in a PropelException being thrown. * - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param boolean $usePrefix (optional) If true, the returned element keys will be prefixed with the - * model class name ('Article_0', 'Article_1', etc). Defaults to TRUE. - * Not supported by ArrayCollection, as ArrayFormatter has - * already created the array used here with integers as keys. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. - * Not supported by ArrayCollection, as ArrayFormatter has - * already included lazy-load columns in the array used here. - * @return string The exported data + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param bool $usePrefix (optional) If true, the returned element keys will be prefixed with the + * model class name ('Article_0', 'Article_1', etc). Defaults to TRUE. + * Not supported by ArrayCollection, as ArrayFormatter has + * already created the array used here with integers as keys. + * @param bool $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * Not supported by ArrayCollection, as ArrayFormatter has + * already included lazy-load columns in the array used here. + * + * @return string The exported data */ public function exportTo($parser, $usePrefix = true, $includeLazyLoadColumns = true) { @@ -551,24 +579,27 @@ public function exportTo($parser, $usePrefix = true, $includeLazyLoadColumns = t * Allows to define default __call() behavior if you use a custom BaseObject * * @param string $name - * @param mixed $params + * @param mixed $params + * + * @throws \Propel\Runtime\Exception\BadMethodCallException * * @return array|string */ public function __call($name, $params) { - if (0 === strpos($name, 'from')) { + if (strpos($name, 'from') === 0) { $format = substr($name, 4); return $this->importFrom($format, reset($params)); } - if (0 === strpos($name, 'to')) { + if (strpos($name, 'to') === 0) { $format = substr($name, 2); $usePrefix = isset($params[0]) ? $params[0] : false; $includeLazyLoadColumns = isset($params[1]) ? $params[1] : true; return $this->exportTo($format, $usePrefix, $includeLazyLoadColumns); } + throw new BadMethodCallException('Call to undefined method: ' . $name); } @@ -581,11 +612,12 @@ public function __call($name, $params) */ public function __toString() { - return (string) $this->exportTo(constant($this->getTableMapClass() . '::DEFAULT_STRING_FORMAT'), false); + return (string)$this->exportTo(constant($this->getTableMapClass() . '::DEFAULT_STRING_FORMAT'), false); } /** * Creates clones of the containing data. + * * @return void */ public function __clone() @@ -612,7 +644,7 @@ protected function getPluralizer() /** * Overwrite this method if you want to use a custom pluralizer * - * @return PluralizerInterface + * @return \Propel\Common\Pluralizer\PluralizerInterface */ protected function createPluralizer() { diff --git a/src/Propel/Runtime/Collection/CollectionIterator.php b/src/Propel/Runtime/Collection/CollectionIterator.php index 43ed32b5c5..c217bf497e 100644 --- a/src/Propel/Runtime/Collection/CollectionIterator.php +++ b/src/Propel/Runtime/Collection/CollectionIterator.php @@ -10,21 +10,27 @@ namespace Propel\Runtime\Collection; +use ArrayIterator; + /** * Iterator class for iterating over Collection data */ -class CollectionIterator extends \ArrayIterator +class CollectionIterator extends ArrayIterator { - /** @var Collection */ + /** + * @var \Propel\Runtime\Collection\Collection + */ protected $collection; - /** @var array */ + /** + * @var array + */ protected $positions = []; /** * Constructor * - * @param Collection $collection + * @param \Propel\Runtime\Collection\Collection $collection */ public function __construct(Collection $collection) { @@ -37,7 +43,7 @@ public function __construct(Collection $collection) /** * Returns the collection instance * - * @return Collection + * @return \Propel\Runtime\Collection\Collection */ public function getCollection() { @@ -47,22 +53,22 @@ public function getCollection() /** * Check if the collection is empty * - * @return boolean + * @return bool */ public function isEmpty() { - return 0 === $this->count(); + return $this->count() === 0; } /** * Gets the position of the internal pointer * This position can be later used in seek() * - * @return integer + * @return int */ public function getPosition() { - if (null === $this->key()) { + if ($this->key() === null) { return 0; } @@ -88,11 +94,11 @@ public function getFirst() /** * Check whether the internal pointer is at the beginning of the list * - * @return boolean + * @return bool */ public function isFirst() { - return 0 === $this->getPosition(); + return $this->getPosition() === 0; } /** @@ -155,7 +161,7 @@ public function getLast() /** * Check whether the internal pointer is at the end of the list * - * @return boolean + * @return bool */ public function isLast() { @@ -170,17 +176,17 @@ public function isLast() /** * Check if the current index is an odd integer * - * @return boolean + * @return bool */ public function isOdd() { - return (boolean) ($this->getPosition() % 2); + return (bool)($this->getPosition() % 2); } /** * Check if the current index is an even integer * - * @return boolean + * @return bool */ public function isEven() { diff --git a/src/Propel/Runtime/Collection/ObjectCollection.php b/src/Propel/Runtime/Collection/ObjectCollection.php index 323ab6b8f0..1c9177f944 100644 --- a/src/Propel/Runtime/Collection/ObjectCollection.php +++ b/src/Propel/Runtime/Collection/ObjectCollection.php @@ -10,16 +10,13 @@ namespace Propel\Runtime\Collection; -use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\Propel; +use Propel\Runtime\ActiveQuery\PropelQuery; use Propel\Runtime\Collection\Exception\ReadOnlyModelException; use Propel\Runtime\Collection\Exception\UnsupportedRelationException; -use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\RuntimeException; use Propel\Runtime\Map\RelationMap; use Propel\Runtime\Map\TableMap; -use Propel\Runtime\ActiveQuery\PropelQuery; -use Propel\Runtime\ActiveRecord\ActiveRecordInterface; +use Propel\Runtime\Propel; /** * Class for iterating over a list of Propel objects @@ -28,8 +25,8 @@ */ class ObjectCollection extends Collection { - protected $index; + protected $indexSplHash; /** @@ -43,6 +40,7 @@ public function __construct($data = []) /** * @param array $input + * * @return void */ public function exchangeArray($input) @@ -61,10 +59,14 @@ public function setData($data) parent::setData($data); $this->rebuildIndex(); } + /** * Save all the elements in the collection * - * @param ConnectionInterface $con + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con + * + * @throws \Propel\Runtime\Collection\Exception\ReadOnlyModelException + * * @return void */ public function save($con = null) @@ -72,7 +74,7 @@ public function save($con = null) if (!method_exists($this->getFullyQualifiedModel(), 'save')) { throw new ReadOnlyModelException('Cannot save objects on a read-only model'); } - if (null === $con) { + if ($con === null) { $con = $this->getWriteConnection(); } $con->transaction(function () use ($con) { @@ -86,7 +88,10 @@ public function save($con = null) /** * Delete all the elements in the collection * - * @param ConnectionInterface $con + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con + * + * @throws \Propel\Runtime\Collection\Exception\ReadOnlyModelException + * * @return void */ public function delete($con = null) @@ -94,7 +99,7 @@ public function delete($con = null) if (!method_exists($this->getFullyQualifiedModel(), 'delete')) { throw new ReadOnlyModelException('Cannot delete objects on a read-only model'); } - if (null === $con) { + if ($con === null) { $con = $this->getWriteConnection(); } $con->transaction(function () use ($con) { @@ -108,8 +113,9 @@ public function delete($con = null) /** * Get an array of the primary keys of all the objects in the collection * - * @param boolean $usePrefix - * @return array The list of the primary keys of the collection + * @param bool $usePrefix + * + * @return array The list of the primary keys of the collection */ public function getPrimaryKeys($usePrefix = true) { @@ -130,6 +136,7 @@ public function getPrimaryKeys($usePrefix = true) * Does not empty the collection before adding the data from the array * * @param array $arr + * * @return void */ public function fromArray($arr) @@ -147,15 +154,15 @@ public function fromArray($arr) * Get an array representation of the collection * Each object is turned into an array and the result is returned * - * @param string $keyColumn If null, the returned array uses an incremental index. + * @param string|null $keyColumn If null, the returned array uses an incremental index. * Otherwise, the array is indexed using the specified column - * @param boolean $usePrefix If true, the returned array prefixes keys - * with the model class name ('Article_0', 'Article_1', etc). - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, + * @param bool $usePrefix If true, the returned array prefixes keys + * with the model class name ('Article_0', 'Article_1', etc). + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, * TableMap::TYPE_CAMELNAME, TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, * TableMap::TYPE_NUM. Defaults to TableMap::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param bool $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion * * * $bookCollection->toArray(); @@ -177,14 +184,19 @@ public function fromArray($arr) * * @return array */ - public function toArray($keyColumn = null, $usePrefix = false, $keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = []) - { + public function toArray( + $keyColumn = null, + $usePrefix = false, + $keyType = TableMap::TYPE_PHPNAME, + $includeLazyLoadColumns = true, + $alreadyDumpedObjects = [] + ) { $ret = []; $keyGetterMethod = 'get' . $keyColumn; /** @var \Propel\Runtime\ActiveRecord\ActiveRecordInterface $obj */ foreach ($this->data as $key => $obj) { - $key = null === $keyColumn ? $key : $obj->$keyGetterMethod(); + $key = $keyColumn === null ? $key : $obj->$keyGetterMethod(); $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; $ret[$key] = $obj->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } @@ -195,40 +207,39 @@ public function toArray($keyColumn = null, $usePrefix = false, $keyType = TableM /** * Get an array representation of the collection * - * @param string $keyColumn If null, the returned array uses an incremental index. + * @param string|null $keyColumn If null, the returned array uses an incremental index. * Otherwise, the array is indexed using the specified column - * @param boolean $usePrefix If true, the returned array prefixes keys - * with the model class name ('Article_0', 'Article_1', etc). - * + * @param bool $usePrefix If true, the returned array prefixes keys + * with the model class name ('Article_0', 'Article_1', etc). * - * $bookCollection->getArrayCopy(); - * array( - * 0 => $book0, - * 1 => $book1, - * ) - * $bookCollection->getArrayCopy('Id'); - * array( - * 123 => $book0, - * 456 => $book1, - * ) - * $bookCollection->getArrayCopy(null, true); - * array( - * 'Book_0' => $book0, - * 'Book_1' => $book1, - * ) + * $bookCollection->getArrayCopy(); + * array( + * 0 => $book0, + * 1 => $book1, + * ) + * $bookCollection->getArrayCopy('Id'); + * array( + * 123 => $book0, + * 456 => $book1, + * ) + * $bookCollection->getArrayCopy(null, true); + * array( + * 'Book_0' => $book0, + * 'Book_1' => $book1, + * ) * * * @return array */ public function getArrayCopy($keyColumn = null, $usePrefix = false) { - if (null === $keyColumn && false === $usePrefix) { + if ($keyColumn === null && $usePrefix === false) { return parent::getArrayCopy(); } $ret = []; $keyGetterMethod = 'get' . $keyColumn; foreach ($this as $key => $obj) { - $key = null === $keyColumn ? $key : $obj->$keyGetterMethod(); + $key = $keyColumn === null ? $key : $obj->$keyGetterMethod(); $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; $ret[$key] = $obj; } @@ -246,7 +257,7 @@ public function getArrayCopy($keyColumn = null, $usePrefix = false) * * * @param string $keyColumn - * @param string $valueColumn + * @param string|null $valueColumn * * @return array */ @@ -254,7 +265,7 @@ public function toKeyValue($keyColumn = 'PrimaryKey', $valueColumn = null) { $ret = []; $keyGetterMethod = 'get' . $keyColumn; - $valueGetterMethod = (null === $valueColumn) ? '__toString' : ('get' . $valueColumn); + $valueGetterMethod = ($valueColumn === null) ? '__toString' : ('get' . $valueColumn); foreach ($this as $obj) { $ret[$obj->$keyGetterMethod()] = $obj->$valueGetterMethod(); } @@ -323,16 +334,19 @@ public function getColumnValues($columnName = 'PrimaryKey') * Makes an additional query to populate the objects related to the collection objects * by a certain relation * - * @param string $relation Relation name (e.g. 'Book') - * @param Criteria $criteria Optional Criteria object to filter the related object collection - * @param ConnectionInterface $con Optional connection object + * @param string $relation Relation name (e.g. 'Book') + * @param \Propel\Runtime\ActiveQuery\Criteria|null $criteria Optional Criteria object to filter the related object collection + * @param \Propel\Runtime\Connection\ConnectionInterface|null $con Optional connection object * - * @return ObjectCollection The list of related objects + * @throws \Propel\Runtime\Exception\RuntimeException + * @throws \Propel\Runtime\Collection\Exception\UnsupportedRelationException + * + * @return \Propel\Runtime\Collection\ObjectCollection The list of related objects */ public function populateRelation($relation, $criteria = null, $con = null) { if (!Propel::isInstancePoolingEnabled()) { - throw new RuntimeException(__METHOD__ .' needs instance pooling to be enabled prior to populating the collection'); + throw new RuntimeException(__METHOD__ . ' needs instance pooling to be enabled prior to populating the collection'); } $relationMap = $this->getFormatter()->getTableMap()->getRelation($relation); if ($this->isEmpty()) { @@ -349,17 +363,16 @@ public function populateRelation($relation, $criteria = null, $con = null) $symRelationMap = $relationMap->getSymmetricalRelation(); $query = PropelQuery::from($relationMap->getRightTable()->getClassName()); - if (null !== $criteria) { + if ($criteria !== null) { $query->mergeWith($criteria); } // query the db for the related objects $filterMethod = 'filterBy' . $symRelationMap->getName(); $relatedObjects = $query ->$filterMethod($this) - ->find($con) - ; + ->find($con); - if (RelationMap::ONE_TO_MANY === $relationMap->getType()) { + if ($relationMap->getType() === RelationMap::ONE_TO_MANY) { // initialize the embedded collections of the main objects $relationName = $relationMap->getName(); foreach ($this as $mainObj) { @@ -372,18 +385,18 @@ public function populateRelation($relation, $criteria = null, $con = null) $mainObj = $object->$getMethod(); // instance pool is used here to avoid a query $mainObj->$addMethod($object); } - } elseif (RelationMap::MANY_TO_ONE === $relationMap->getType()) { + } elseif ($relationMap->getType() === RelationMap::MANY_TO_ONE) { // nothing to do; the instance pool will catch all calls to getRelatedObject() // and return the object in memory } else { - throw new UnsupportedRelationException(__METHOD__ .' does not support this relation type'); + throw new UnsupportedRelationException(__METHOD__ . ' does not support this relation type'); } return $relatedObjects; } /** - * @inheritdoc + * @inheritDoc */ public function search($element) { @@ -406,7 +419,7 @@ protected function rebuildIndex() { $this->index = []; $this->indexSplHash = []; - foreach ($this->data as $idx => $value){ + foreach ($this->data as $idx => $value) { $hashCode = $this->getHashCode($value); $this->index[$hashCode] = $idx; $this->indexSplHash[spl_object_hash($value)] = $hashCode; @@ -415,6 +428,7 @@ protected function rebuildIndex() /** * @param mixed $offset + * * @return void */ public function offsetUnset($offset) @@ -430,23 +444,26 @@ public function offsetUnset($offset) /** * @param mixed $element + * * @return void */ public function removeObject($element) { - if (false !== ($pos = $this->search($element))) { + if (($pos = $this->search($element)) !== false) { $this->remove($pos); } } /** * @param mixed $value + * * @return void */ public function append($value) { if (!is_object($value)) { parent::append($value); + return; } @@ -462,18 +479,20 @@ public function append($value) /** * @param mixed $offset * @param mixed $value + * * @return void */ public function offsetSet($offset, $value) { if (!is_object($value)) { parent::offsetSet($offset, $value); + return; } $hashCode = $this->getHashCode($value); - if (is_null($offset)) { + if ($offset === null) { $this->data[] = $value; end($this->data); $pos = key($this->data); @@ -493,7 +512,7 @@ public function offsetSet($offset, $value) } /** - * @inheritdoc + * @inheritDoc */ public function contains($element) { @@ -508,6 +527,7 @@ public function contains($element) * Returns the result of $object->hashCode() if available or uses spl_object_hash($object). * * @param mixed $object + * * @return string */ protected function getHashCode($object) diff --git a/src/Propel/Runtime/Collection/ObjectCombinationCollection.php b/src/Propel/Runtime/Collection/ObjectCombinationCollection.php index 135dc89815..fd4e673a69 100644 --- a/src/Propel/Runtime/Collection/ObjectCombinationCollection.php +++ b/src/Propel/Runtime/Collection/ObjectCombinationCollection.php @@ -10,7 +10,6 @@ namespace Propel\Runtime\Collection; -use Propel\Runtime\Propel; use Propel\Runtime\ActiveRecord\ActiveRecordInterface; /** @@ -20,12 +19,12 @@ */ class ObjectCombinationCollection extends ObjectCollection { - /** * Get an array of the primary keys of all the objects in the collection * - * @param boolean $usePrefix - * @return array The list of the primary keys of the collection + * @param bool $usePrefix + * + * @return array The list of the primary keys of the collection */ public function getPrimaryKeys($usePrefix = true) { @@ -44,7 +43,7 @@ public function getPrimaryKeys($usePrefix = true) } /** - * @inheritdoc + * @inheritDoc */ public function push($value) { @@ -55,6 +54,7 @@ public function push($value) * Returns all values from one position/column. * * @param int $position beginning with 1 + * * @return array */ public function getObjectsFromPosition($position = 1) @@ -63,11 +63,12 @@ public function getObjectsFromPosition($position = 1) foreach ($this as $array) { $result[] = $array[$position - 1]; } + return $result; } /** - * @inheritdoc + * @inheritDoc */ public function search($element) { @@ -85,13 +86,15 @@ public function search($element) foreach ($this as $pos => $combination) { $found = true; foreach ($combination as $idx => $obj) { - if (null === $obj) { + if ($obj === null) { if ($obj !== $hashes[$idx]) { $found = false; + break; } } elseif ($isActiveRecord[$idx] ? $obj->hashCode() !== $hashes[$idx] : $obj !== $hashes[$idx]) { $found = false; + break; } } @@ -104,21 +107,20 @@ public function search($element) } /** - * @inheritdoc + * @inheritDoc */ public function removeObject($element) { - if (false !== ($pos = call_user_func_array([$this, 'search'], func_get_args()))) { + if (($pos = call_user_func_array([$this, 'search'], func_get_args())) !== false) { $this->remove($pos); } } /** - * @inheritdoc + * @inheritDoc */ public function contains($element) { - return false !== call_user_func_array([$this, 'search'], func_get_args()); + return call_user_func_array([$this, 'search'], func_get_args()) !== false; } - } diff --git a/src/Propel/Runtime/Collection/OnDemandCollection.php b/src/Propel/Runtime/Collection/OnDemandCollection.php index e3f6aa3881..e2d2e5dc50 100644 --- a/src/Propel/Runtime/Collection/OnDemandCollection.php +++ b/src/Propel/Runtime/Collection/OnDemandCollection.php @@ -10,11 +10,10 @@ namespace Propel\Runtime\Collection; -use Propel\Runtime\ActiveRecord\ActiveRecordInterface; use Propel\Runtime\Collection\Exception\ReadOnlyModelException; +use Propel\Runtime\DataFetcher\DataFetcherInterface; use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Formatter\AbstractFormatter; -use Propel\Runtime\DataFetcher\DataFetcherInterface; use Propel\Runtime\Map\TableMap; /** @@ -30,8 +29,9 @@ class OnDemandCollection extends Collection private $lastIterator; /** - * @param \Propel\Runtime\Formatter\ObjectFormatter $formatter - * @param DataFetcherInterface $dataFetcher + * @param \Propel\Runtime\Formatter\ObjectFormatter $formatter + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface $dataFetcher + * * @return void */ public function initIterator(AbstractFormatter $formatter, DataFetcherInterface $dataFetcher) @@ -43,15 +43,15 @@ public function initIterator(AbstractFormatter $formatter, DataFetcherInterface * Get an array representation of the collection * Each object is turned into an array and the result is returned * - * @param string $keyColumn If null, the returned array uses an incremental index. + * @param string|null $keyColumn If null, the returned array uses an incremental index. * Otherwise, the array is indexed using the specified column - * @param boolean $usePrefix If true, the returned array prefixes keys - * with the model class name ('Article_0', 'Article_1', etc). - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, + * @param bool $usePrefix If true, the returned array prefixes keys + * with the model class name ('Article_0', 'Article_1', etc). + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, * TableMap::TYPE_CAMELNAME, TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, * TableMap::TYPE_NUM. Defaults to TableMap::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param bool $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion * * * $bookCollection->toArray(); @@ -73,14 +73,19 @@ public function initIterator(AbstractFormatter $formatter, DataFetcherInterface * * @return array */ - public function toArray($keyColumn = null, $usePrefix = false, $keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = []) - { + public function toArray( + $keyColumn = null, + $usePrefix = false, + $keyType = TableMap::TYPE_PHPNAME, + $includeLazyLoadColumns = true, + $alreadyDumpedObjects = [] + ) { $ret = []; $keyGetterMethod = 'get' . $keyColumn; /** @var \Propel\Runtime\ActiveRecord\ActiveRecordInterface $obj */ foreach ($this as $key => $obj) { - $key = null === $keyColumn ? $key : $obj->$keyGetterMethod(); + $key = $keyColumn === null ? $key : $obj->$keyGetterMethod(); $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; $ret[$key] = $obj->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } @@ -94,6 +99,9 @@ public function toArray($keyColumn = null, $usePrefix = false, $keyType = TableM * Does not empty the collection before adding the data from the array * * @param array $arr + * + * @throws \Propel\Runtime\Collection\Exception\ReadOnlyModelException + * * @return void */ public function fromArray($arr) @@ -104,7 +112,7 @@ public function fromArray($arr) // IteratorAggregate Interface /** - * @return OnDemandIterator + * @return \Propel\Runtime\Collection\OnDemandIterator */ public function getIterator() { @@ -114,10 +122,11 @@ public function getIterator() // ArrayAccess Interface /** + * @param int $offset + * * @throws \Propel\Runtime\Exception\PropelException - * @param integer $offset * - * @return boolean + * @return bool */ public function offsetExists($offset) { @@ -125,8 +134,9 @@ public function offsetExists($offset) } /** + * @param int $offset + * * @throws \Propel\Runtime\Exception\PropelException - * @param integer $offset * * @return mixed */ @@ -136,10 +146,11 @@ public function &offsetGet($offset) } /** + * @param int $offset + * @param mixed $value + * * @throws \Propel\Runtime\Collection\Exception\ReadOnlyModelException * - * @param integer $offset - * @param mixed $value * @return void */ public function offsetSet($offset, $value) @@ -148,8 +159,10 @@ public function offsetSet($offset, $value) } /** + * @param int $offset + * * @throws \Propel\Runtime\Collection\Exception\ReadOnlyModelException - * @param integer $offset + * * @return void */ public function offsetUnset($offset) @@ -161,6 +174,7 @@ public function offsetUnset($offset) /** * @throws \Propel\Runtime\Exception\PropelException + * * @return string */ public function serialize() @@ -169,8 +183,10 @@ public function serialize() } /** + * @param string $data + * * @throws \Propel\Runtime\Exception\PropelException - * @param string $data + * * @return void */ public function unserialize($data) @@ -183,7 +199,7 @@ public function unserialize($data) /** * Returns the number of rows in the resultset * - * @return integer Number of results + * @return int Number of results */ public function count() { @@ -196,6 +212,7 @@ public function count() * @param mixed $value * * @throws \Propel\Runtime\Collection\Exception\ReadOnlyModelException + * * @return void */ public function append($value) @@ -207,6 +224,7 @@ public function append($value) * @param mixed $value * * @throws \Propel\Runtime\Collection\Exception\ReadOnlyModelException + * * @return int */ public function prepend($value) @@ -218,6 +236,7 @@ public function prepend($value) * @param array $input * * @throws \Propel\Runtime\Collection\Exception\ReadOnlyModelException + * * @return void */ public function exchangeArray($input) @@ -227,6 +246,7 @@ public function exchangeArray($input) /** * @throws \Propel\Runtime\Exception\PropelException + * * @return array */ public function getArrayCopy() @@ -235,7 +255,9 @@ public function getArrayCopy() } /** - * @inheritdoc + * @inheritDoc + * + * @throws \Propel\Runtime\Exception\PropelException */ public function exportTo($parser, $usePrefix = true, $includeLazyLoadColumns = true) { diff --git a/src/Propel/Runtime/Collection/OnDemandIterator.php b/src/Propel/Runtime/Collection/OnDemandIterator.php index bd93bfe92a..7be446c1bb 100644 --- a/src/Propel/Runtime/Collection/OnDemandIterator.php +++ b/src/Propel/Runtime/Collection/OnDemandIterator.php @@ -10,27 +10,26 @@ namespace Propel\Runtime\Collection; -use Propel\Runtime\ActiveRecord\ActiveRecordInterface; +use Iterator; use Propel\Runtime\DataFetcher\DataFetcherInterface; -use Propel\Runtime\Formatter\ObjectFormatter; -use Propel\Runtime\Propel; use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Formatter\AbstractFormatter; +use Propel\Runtime\Propel; /** * Class for iterating over a statement and returning one Propel object at a time * * @author Francois Zaninotto */ -class OnDemandIterator implements \Iterator +class OnDemandIterator implements Iterator { /** - * @var ObjectFormatter + * @var \Propel\Runtime\Formatter\ObjectFormatter */ protected $formatter; /** - * @var DataFetcherInterface + * @var \Propel\Runtime\DataFetcher\DataFetcherInterface */ protected $dataFetcher; @@ -43,8 +42,8 @@ class OnDemandIterator implements \Iterator protected $enableInstancePoolingOnFinish; /** - * @param ObjectFormatter $formatter - * @param DataFetcherInterface $dataFetcher + * @param \Propel\Runtime\Formatter\ObjectFormatter $formatter + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface $dataFetcher */ public function __construct(AbstractFormatter $formatter, DataFetcherInterface $dataFetcher) { @@ -69,7 +68,7 @@ public function closeCursor() * Returns the number of rows in the resultset * Warning: this number is inaccurate for most databases. Do not rely on it for a portable application. * - * @return integer Number of results + * @return int Number of results */ public function count() { @@ -84,7 +83,7 @@ public function count() * * @see ObjectFormatter::getAllObjectsFromRow() * - * @return ActiveRecordInterface + * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface */ public function current() { @@ -104,13 +103,14 @@ public function key() /** * Advances the cursor in the statement * Closes the cursor if the end of the statement is reached + * * @return void */ public function next() { $this->currentRow = $this->dataFetcher->fetch(); $this->currentKey++; - $this->isValid = (bool) $this->currentRow; + $this->isValid = (bool)$this->currentRow; if (!$this->isValid) { $this->closeCursor(); } @@ -119,18 +119,21 @@ public function next() /** * Initializes the iterator by advancing to the first position * This method can only be called once (this is a NoRewindIterator) + * + * @throws \Propel\Runtime\Exception\PropelException + * * @return void */ public function rewind() { // check that the hydration can begin - if (null === $this->formatter) { + if ($this->formatter === null) { throw new PropelException('The On Demand collection requires a formatter. Add it by calling setFormatter()'); } - if (null === $this->dataFetcher) { + if ($this->dataFetcher === null) { throw new PropelException('The On Demand collection requires a dataFetcher. Add it by calling setDataFetcher()'); } - if (null !== $this->isValid) { + if ($this->isValid !== null) { throw new PropelException('The On Demand collection can only be iterated once'); } @@ -139,10 +142,10 @@ public function rewind() } /** - * @return boolean + * @return bool */ public function valid() { - return (bool) $this->isValid; + return (bool)$this->isValid; } } diff --git a/src/Propel/Runtime/Connection/ConnectionFactory.php b/src/Propel/Runtime/Connection/ConnectionFactory.php index 82cfca04a8..b51c2b28d5 100644 --- a/src/Propel/Runtime/Connection/ConnectionFactory.php +++ b/src/Propel/Runtime/Connection/ConnectionFactory.php @@ -17,18 +17,19 @@ class ConnectionFactory { - const DEFAULT_CONNECTION_CLASS = '\Propel\Runtime\Connection\ConnectionWrapper'; + public const DEFAULT_CONNECTION_CLASS = '\Propel\Runtime\Connection\ConnectionWrapper'; /** * Open a database connection based on a configuration. * - * @param array $configuration - * @param AdapterInterface $adapter - * @param string $defaultConnectionClass + * @param array $configuration + * @param \Propel\Runtime\Adapter\AdapterInterface $adapter + * @param string $defaultConnectionClass * - * @return ConnectionInterface * @throws \Propel\Runtime\Exception\InvalidArgumentException * @throws Exception\ConnectionException + * + * @return \Propel\Runtime\Connection\ConnectionInterface */ public static function create(array $configuration, AdapterInterface $adapter, $defaultConnectionClass = self::DEFAULT_CONNECTION_CLASS) { @@ -40,16 +41,16 @@ public static function create(array $configuration, AdapterInterface $adapter, $ try { $adapterConnection = $adapter->getConnection($configuration); } catch (AdapterException $e) { - throw new ConnectionException("Unable to open connection", 0, $e); + throw new ConnectionException('Unable to open connection', 0, $e); } - /** @var ConnectionInterface $connection */ + /** @var \Propel\Runtime\Connection\ConnectionInterface $connection */ $connection = new $connectionClass($adapterConnection); // load any connection options from the config file // connection attributes are those PDO flags that have to be set on the initialized connection if (isset($configuration['attributes']) && is_array($configuration['attributes'])) { foreach ($configuration['attributes'] as $option => $value) { - if (is_string($value) && false !== strpos($value, '::')) { + if (is_string($value) && strpos($value, '::') !== false) { if (!defined($value)) { throw new InvalidArgumentException(sprintf('Invalid class constant specified "%s" while processing connection attributes for datasource "%s"', $value, $connection->getName())); } diff --git a/src/Propel/Runtime/Connection/ConnectionInterface.php b/src/Propel/Runtime/Connection/ConnectionInterface.php index 16498a36df..136cf9ad0e 100644 --- a/src/Propel/Runtime/Connection/ConnectionInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionInterface.php @@ -10,9 +10,12 @@ namespace Propel\Runtime\Connection; +use PDO; + /** * Interface for Propel Connection object. * Based on the PDO interface. + * * @see http://php.net/manual/en/book.pdo.php * * @author Francois Zaninotto @@ -21,6 +24,7 @@ interface ConnectionInterface { /** * @param string $name The datasource name associated to this connection + * * @return void */ public function setName($name); @@ -39,7 +43,7 @@ public function getName(); * Calling Connection::rollBack() will roll back all changes to the database * and return the connection to autocommit mode. * - * @return boolean TRUE on success or FALSE on failure. + * @return bool TRUE on success or FALSE on failure. */ public function beginTransaction(); @@ -49,7 +53,7 @@ public function beginTransaction(); * commit() returns the database connection to autocommit mode until the * next call to connection::beginTransaction() starts a new transaction. * - * @return boolean TRUE on success or FALSE on failure. + * @return bool TRUE on success or FALSE on failure. */ public function commit(); @@ -61,7 +65,7 @@ public function commit(); * If the database was set to autocommit mode, this function will restore * autocommit mode after it has rolled back the transaction. * - * @return boolean TRUE on success or FALSE on failure. + * @return bool TRUE on success or FALSE on failure. */ public function rollBack(); @@ -87,7 +91,7 @@ public function getAttribute($attribute); * Set an attribute. * * @param string|int $attribute - * @param mixed $value + * @param mixed $value * * @return bool TRUE on success or FALSE on failure. */ @@ -134,9 +138,9 @@ public function getDataFetcher($data); * * @param callable $callable A callable to be wrapped in a transaction * - * @return mixed Returns the result of the callable. - * * @throws \Exception Re-throws a possible Exception triggered by the callable. + * + * @return mixed Returns the result of the callable. */ public function transaction(callable $callable); @@ -162,14 +166,14 @@ public function exec($statement); * these parameters to bind any user-input, do not include the user-input * directly in the query. * - * @param string $statement This must be a valid SQL statement for the target + * @param string $statement This must be a valid SQL statement for the target * database server. - * @param array $driver_options + * @param array|null $driver_options + * + * @throws \Propel\Runtime\Connection\Exception\ConnectionException depending on error handling. * * @return \PDOStatement|bool A Statement object if the database server * successfully prepares, FALSE otherwise. - - * @throws \Propel\Runtime\Connection\Exception\ConnectionException depending on error handling. */ public function prepare($statement, $driver_options = null); @@ -179,8 +183,9 @@ public function prepare($statement, $driver_options = null); * @param string $statement The SQL statement to prepare and execute. * Data inside the query should be properly escaped. * - * @return \Propel\Runtime\DataFetcher\DataFetcherInterface * @throws \Propel\Runtime\Connection\Exception\ConnectionException depending on error handling. + * + * @return \Propel\Runtime\DataFetcher\DataFetcherInterface */ public function query($statement); @@ -191,13 +196,13 @@ public function query($statement); * characters within the input string, using a quoting style appropriate to * the underlying driver. * - * @param string $string The string to be quoted. - * @param int $parameter_type Provides a data type hint for drivers that + * @param string $string The string to be quoted. + * @param int $parameterType Provides a data type hint for drivers that * have alternate quoting styles. * * @return string A quoted string that is theoretically safe to pass into an * SQL statement. Returns FALSE if the driver does not support * quoting in this way. */ - public function quote($string, $parameter_type = \PDO::PARAM_STR); + public function quote($string, $parameterType = PDO::PARAM_STR); } diff --git a/src/Propel/Runtime/Connection/ConnectionManagerInterface.php b/src/Propel/Runtime/Connection/ConnectionManagerInterface.php index 0e368ab7c7..e5a2ddaa28 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerInterface.php @@ -16,6 +16,7 @@ interface ConnectionManagerInterface { /** * @param string $name The datasource name associated to this connection + * * @return void */ public function setName($name); @@ -30,14 +31,14 @@ public function getName(); * * @return \Propel\Runtime\Connection\ConnectionInterface */ - public function getWriteConnection(AdapterInterface $adapter = null); + public function getWriteConnection(?AdapterInterface $adapter = null); /** * @param \Propel\Runtime\Adapter\AdapterInterface|null $adapter * * @return \Propel\Runtime\Connection\ConnectionInterface */ - public function getReadConnection(AdapterInterface $adapter = null); + public function getReadConnection(?AdapterInterface $adapter = null); public function closeConnections(); } diff --git a/src/Propel/Runtime/Connection/ConnectionManagerMasterSlave.php b/src/Propel/Runtime/Connection/ConnectionManagerMasterSlave.php index abd1c5f031..e7b8c4da13 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerMasterSlave.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerMasterSlave.php @@ -20,8 +20,9 @@ class ConnectionManagerMasterSlave extends ConnectionManagerPrimaryReplica /** * For replication, whether to always force the use of a master connection. * - * @return boolean * @deprecated Use isForcePrimaryConnection() instead. + * + * @return bool */ public function isForceMasterConnection() { @@ -31,8 +32,10 @@ public function isForceMasterConnection() /** * For replication, set whether to always force the use of a master connection. * - * @param boolean $isForceMasterConnection * @deprecated Use setForcePrimaryConnection() instead. + * + * @param bool $isForceMasterConnection + * * @return void */ public function setForceMasterConnection($isForceMasterConnection) diff --git a/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php b/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php index 57b135abb1..ae1594569d 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerPrimaryReplica.php @@ -43,12 +43,13 @@ class ConnectionManagerPrimaryReplica implements ConnectionManagerInterface protected $readConnection; /** - * @var boolean Whether a call to getReadConnection() always returns a write connection. + * @var bool Whether a call to getReadConnection() always returns a write connection. */ protected $isForcePrimaryConnection = false; /** * @param string $name The datasource name associated to this connection + * * @return void */ public function setName($name) @@ -67,7 +68,7 @@ public function getName() /** * For replication, whether to always force the use of a primary connection. * - * @return boolean + * @return bool */ public function isForcePrimaryConnection() { @@ -77,12 +78,13 @@ public function isForcePrimaryConnection() /** * For replication, set whether to always force the use of a primary connection. * - * @param boolean $isForceMasterConnection + * @param bool $isForceMasterConnection + * * @return void */ public function setForcePrimaryConnection($isForceMasterConnection) { - $this->isForcePrimaryConnection = (bool) $isForceMasterConnection; + $this->isForcePrimaryConnection = (bool)$isForceMasterConnection; } /** @@ -90,13 +92,14 @@ public function setForcePrimaryConnection($isForceMasterConnection) * * * $manager->setWriteConfiguration(array( - * 'dsn' => 'mysql:dbname=test_master', - * 'user' => 'mywriteuser', + * 'dsn' => 'mysql:dbname=test_master', + * 'user' => 'mywriteuser', * 'password' => 'S3cr3t' * )); * * * @param array $configuration + * * @return void */ public function setWriteConfiguration($configuration) @@ -111,19 +114,20 @@ public function setWriteConfiguration($configuration) * * $manager->setReadConfiguration(array( * array( - * 'dsn' => 'mysql:dbname=test_replica1', - * 'user' => 'myreaduser', + * 'dsn' => 'mysql:dbname=test_replica1', + * 'user' => 'myreaduser', * 'password' => 'F00baR' * ), * array( - * 'dsn' => 'mysql:dbname=test_replica2', - * 'user' => 'myreaduser', + * 'dsn' => 'mysql:dbname=test_replica2', + * 'user' => 'myreaduser', * 'password' => 'F00baR' * ) * )); * * * @param array $configuration + * * @return void */ public function setReadConfiguration($configuration) @@ -137,13 +141,13 @@ public function setReadConfiguration($configuration) * * If no master connection exist yet, open it using the write configuration. * - * @param \Propel\Runtime\Adapter\AdapterInterface $adapter + * @param \Propel\Runtime\Adapter\AdapterInterface|null $adapter * * @return \Propel\Runtime\Connection\ConnectionInterface */ - public function getWriteConnection(AdapterInterface $adapter = null) + public function getWriteConnection(?AdapterInterface $adapter = null) { - if (null === $this->writeConnection) { + if ($this->writeConnection === null) { $this->writeConnection = ConnectionFactory::create($this->writeConfiguration, $adapter); $this->writeConnection->setName($this->getName()); } @@ -161,7 +165,7 @@ public function getWriteConnection(AdapterInterface $adapter = null) * * @return \Propel\Runtime\Connection\ConnectionInterface */ - public function getReadConnection(AdapterInterface $adapter = null) + public function getReadConnection(?AdapterInterface $adapter = null) { if ($this->writeConnection && $this->writeConnection->inTransaction()) { return $this->writeConnection; @@ -170,8 +174,8 @@ public function getReadConnection(AdapterInterface $adapter = null) if ($this->isForcePrimaryConnection()) { return $this->getWriteConnection($adapter); } - if (null === $this->readConnection) { - if (null === $this->readConfiguration) { + if ($this->readConnection === null) { + if ($this->readConfiguration === null) { $this->readConnection = $this->getWriteConnection($adapter); } else { $keys = array_keys($this->readConfiguration); diff --git a/src/Propel/Runtime/Connection/ConnectionManagerSingle.php b/src/Propel/Runtime/Connection/ConnectionManagerSingle.php index d45a02d7af..41ee1f5e73 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerSingle.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerSingle.php @@ -10,6 +10,7 @@ namespace Propel\Runtime\Connection; +use InvalidArgumentException; use Propel\Runtime\Adapter\AdapterInterface; /** @@ -34,6 +35,7 @@ class ConnectionManagerSingle implements ConnectionManagerInterface /** * @param string $name The datasource name associated to this connection + * * @return void */ public function setName($name) @@ -82,13 +84,15 @@ public function setConfiguration($configuration) /** * @param \Propel\Runtime\Adapter\AdapterInterface|null $adapter * + * @throws \InvalidArgumentException + * * @return \Propel\Runtime\Connection\ConnectionInterface */ - public function getWriteConnection(AdapterInterface $adapter = null) + public function getWriteConnection(?AdapterInterface $adapter = null) { - if (null === $this->connection) { + if ($this->connection === null) { if ($adapter === null) { - throw new \InvalidArgumentException('$adapter not given'); + throw new InvalidArgumentException('$adapter not given'); } $this->connection = ConnectionFactory::create($this->configuration, $adapter); @@ -103,7 +107,7 @@ public function getWriteConnection(AdapterInterface $adapter = null) * * @return \Propel\Runtime\Connection\ConnectionInterface */ - public function getReadConnection(AdapterInterface $adapter = null) + public function getReadConnection(?AdapterInterface $adapter = null) { return $this->getWriteConnection($adapter); } diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index cd5b256f43..641df9f247 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -10,17 +10,17 @@ namespace Propel\Runtime\Connection; -use Propel\Runtime\Propel; use Propel\Runtime\Connection\Exception\RollbackException; use Propel\Runtime\Exception\InvalidArgumentException; -use Psr\Log\LoggerInterface; +use Propel\Runtime\Propel; use Psr\Log\LoggerAwareInterface; +use Psr\Log\LoggerInterface; /** * Wraps a Connection class, providing nested transactions, statement cache, and logging. * * This class was designed to work around the limitation in PDO where attempting to begin - * a transaction when one has already been begun will trigger a PDOException. Propel + * a transaction when one has already been begun will trigger a PDOException. Propel * relies on the ability to create nested transactions, even if the underlying layer * simply ignores these (because it doesn't support nested transactions). * @@ -28,7 +28,6 @@ * getNestedTransactionDepth() and isInTransaction() and the fact that beginTransaction() * will no longer throw a PDOException (or trigger an error) if a transaction is already * in-progress. - * */ class ConnectionWrapper implements ConnectionInterface, LoggerAwareInterface { @@ -37,7 +36,7 @@ class ConnectionWrapper implements ConnectionInterface, LoggerAwareInterface /** * Attribute to use to set whether to cache prepared statements. */ - const PROPEL_ATTR_CACHE_PREPARES = -1; + public const PROPEL_ATTR_CACHE_PREPARES = -1; /** * @var string The datasource name associated to this connection @@ -47,23 +46,26 @@ class ConnectionWrapper implements ConnectionInterface, LoggerAwareInterface /** * Whether or not the debug is enabled * - * @var boolean + * @var bool */ public $useDebug = false; /** * The wrapped connection class - * @var ConnectionInterface|null + * + * @var \Propel\Runtime\Connection\ConnectionInterface|null */ protected $connection; /** * The current transaction depth. - * @var integer + * + * @var int */ protected $nestedTransactionCount = 0; /** + * @var bool * Whether the final commit is possible * Is false if a nested transaction is rolled back */ @@ -72,7 +74,7 @@ class ConnectionWrapper implements ConnectionInterface, LoggerAwareInterface /** * Count of queries performed. * - * @var integer + * @var int */ protected $queryCount = 0; @@ -86,14 +88,14 @@ class ConnectionWrapper implements ConnectionInterface, LoggerAwareInterface /** * Cache of prepared statements (StatementWrapper) keyed by SQL. * - * @var array [sql => StatementWrapper] + * @var array [sql => StatementWrapper] */ protected $cachedPreparedStatements = []; /** * Whether to cache prepared statements. * - * @var boolean + * @var bool */ protected $isCachePreparedStatements = false; @@ -111,7 +113,7 @@ class ConnectionWrapper implements ConnectionInterface, LoggerAwareInterface /** * Configured logger. * - * @var LoggerInterface + * @var \Psr\Log\LoggerInterface */ protected $logger; @@ -130,6 +132,7 @@ public function __construct(ConnectionInterface $connection) /** * @param string $name The datasource name associated to this connection + * * @return void */ public function setName($name) @@ -156,7 +159,7 @@ public function getWrappedConnection() /** * Gets the current transaction depth. * - * @return integer + * @return int */ public function getNestedTransactionCount() { @@ -165,7 +168,9 @@ public function getNestedTransactionCount() /** * Set the current transaction depth. + * * @param int $v The new depth. + * * @return void */ protected function setNestedTransactionCount($v) @@ -177,7 +182,7 @@ protected function setNestedTransactionCount($v) * Is this PDO connection currently in-transaction? * This is equivalent to asking whether the current nested transaction count is greater than 0. * - * @return boolean + * @return bool */ public function isInTransaction() { @@ -188,7 +193,7 @@ public function isInTransaction() * Check whether the connection contains a transaction that can be committed. * To be used in an environment where Propelexceptions are caught. * - * @return boolean True if the connection is in a committable transaction + * @return bool True if the connection is in a committable transaction */ public function isCommitable() { @@ -198,7 +203,7 @@ public function isCommitable() /** * Overrides PDO::beginTransaction() to prevent errors due to already-in-progress transaction. * - * @return boolean + * @return bool */ public function beginTransaction() { @@ -219,7 +224,9 @@ public function beginTransaction() * Overrides PDO::commit() to only commit the transaction if we are in the outermost * transaction nesting level. * - * @return boolean + * @throws \Propel\Runtime\Connection\Exception\RollbackException + * + * @return bool */ public function commit() { @@ -227,7 +234,7 @@ public function commit() $opcount = $this->nestedTransactionCount; if ($opcount > 0) { - if (1 === $opcount) { + if ($opcount === 1) { if ($this->isUncommitable) { throw new RollbackException('Cannot commit because a nested transaction was rolled back'); } @@ -248,7 +255,7 @@ public function commit() * Overrides PDO::rollBack() to only rollback the transaction if we are in the outermost * transaction nesting level * - * @return boolean Whether operation was successful. + * @return bool Whether operation was successful. */ public function rollBack() { @@ -256,7 +263,7 @@ public function rollBack() $opcount = $this->nestedTransactionCount; if ($opcount > 0) { - if (1 === $opcount) { + if ($opcount === 1) { $return = $this->connection->rollBack(); if ($this->useDebug) { $this->log('Rollback transaction'); @@ -275,7 +282,7 @@ public function rollBack() * Rollback the whole transaction, even if this is a nested rollback * and reset the nested transaction count to 0. * - * @return boolean Whether operation was successful. + * @return bool Whether operation was successful. */ public function forceRollBack() { @@ -301,7 +308,7 @@ public function forceRollBack() /** * Checks if inside a transaction. * - * @return boolean TRUE if a transaction is currently active, and FALSE if not. + * @return bool TRUE if a transaction is currently active, and FALSE if not. */ public function inTransaction() { @@ -331,17 +338,20 @@ public function getAttribute($attribute) * Set an attribute. * * @param string $attribute The attribute name, or the constant name containing the attribute name (e.g. 'PDO::ATTR_CASE') - * @param mixed $value + * @param mixed $value + * + * @throws \Propel\Runtime\Exception\InvalidArgumentException + * * @return bool */ public function setAttribute($attribute, $value) { if (is_string($attribute)) { - if (false === strpos($attribute, '::')) { + if (strpos($attribute, '::') === false) { if (defined('\PDO::' . $attribute)) { $attribute = '\PDO::' . $attribute; } else { - $attribute = __CLASS__ . '::' . $attribute; + $attribute = self::class . '::' . $attribute; } } if (!defined($attribute)) { @@ -355,6 +365,7 @@ public function setAttribute($attribute, $value) switch ($attribute) { case self::PROPEL_ATTR_CACHE_PREPARES: $this->isCachePreparedStatements = $value; + break; default: $this->connection->setAttribute($attribute, $value); @@ -370,8 +381,8 @@ public function setAttribute($attribute, $value) * - Add logging and query counting if logging is true. * - Add query caching support if the PropelPDO::PROPEL_ATTR_CACHE_PREPARES was set to true. * - * @param string $statement This must be a valid SQL statement for the target database server. - * @param array $driver_options One $array or more key => value pairs to set attribute values + * @param string $statement This must be a valid SQL statement for the target database server. + * @param array|null $driver_options One $array or more key => value pairs to set attribute values * for the PDOStatement object that this method returns. * * @return \PDOStatement @@ -401,8 +412,9 @@ public function prepare($statement, $driver_options = null) * Execute an SQL statement and return the number of affected rows. * Overrides PDO::exec() to log queries when required * - * @param string $sql - * @return integer + * @param string $sql + * + * @return int */ public function exec($sql) { @@ -453,8 +465,8 @@ public function query($statement) * characters within the input string, using a quoting style appropriate to * the underlying driver. * - * @param string $string The string to be quoted. - * @param int $parameter_type Provides a data type hint for drivers that + * @param string $string The string to be quoted. + * @param int $parameter_type Provides a data type hint for drivers that * have alternate quoting styles. * * @return string A quoted string that is theoretically safe to pass into an @@ -487,7 +499,7 @@ public function getDataFetcher($data) * * @param string $sql A valid SQL statement * - * @return StatementWrapper + * @return \Propel\Runtime\Connection\StatementWrapper */ protected function createStatementWrapper($sql) { @@ -518,6 +530,7 @@ public function lastInsertId($name = null) /** * Clears any stored prepared statements for this connection. + * * @return void */ public function clearStatementCache() @@ -531,7 +544,7 @@ public function clearStatementCache() * When using DebugPDOStatement as the statement class, any queries by DebugPDOStatement instances * are counted as well. * - * @return integer + * @return int */ public function getQueryCount() { @@ -564,6 +577,7 @@ public function getLastExecutedQuery() * Set the SQL code for the latest query executed by Propel * * @param string $query Executable SQL code + * * @return void */ public function setLastExecutedQuery($query) @@ -574,7 +588,8 @@ public function setLastExecutedQuery($query) /** * Enable or disable the query debug features * - * @param boolean $value True to enable debug (default), false to disable it + * @param bool $value True to enable debug (default), false to disable it + * * @return void */ public function useDebug($value = true) @@ -590,6 +605,7 @@ public function useDebug($value = true) /** * @param array $logMethods + * * @return void */ public function setLogMethods($logMethods) @@ -617,6 +633,7 @@ protected function isLogEnabledForMethod($methodName) /** * {@inheritDoc} + * * @return void */ public function setLogger(LoggerInterface $logger) @@ -628,11 +645,11 @@ public function setLogger(LoggerInterface $logger) * Gets the logger to use for this connection. * If no logger was set, returns the default logger from the Service Container. * - * @return LoggerInterface A logger. + * @return \Psr\Log\LoggerInterface A logger. */ public function getLogger() { - if (null === $this->logger) { + if ($this->logger === null) { return Propel::getServiceContainer()->getLogger($this->getName()); } @@ -643,6 +660,7 @@ public function getLogger() * Logs the method call or the executed SQL statement. * * @param string $msg Message to log. + * * @return void */ public function log($msg) @@ -657,7 +675,7 @@ public function log($msg) do { $callingMethod = $backtrace[$i]['function']; $i++; - } while ($callingMethod == "log" && $i < $stackSize); + } while ($callingMethod == 'log' && $i < $stackSize); if (!$msg || !$this->isLogEnabledForMethod($callingMethod)) { return; diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index ddb2b010a0..2d244be2e8 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -10,13 +10,14 @@ namespace Propel\Runtime\Connection; -use Propel\Runtime\Exception\InvalidArgumentException; +use PDO; use Propel\Runtime\DataFetcher\PDODataFetcher; +use Propel\Runtime\Exception\InvalidArgumentException; /** * PDO extension that implements ConnectionInterface and builds \PDOStatement statements. */ -class PdoConnection extends \PDO implements ConnectionInterface +class PdoConnection extends PDO implements ConnectionInterface { use TransactionTrait; @@ -27,6 +28,7 @@ class PdoConnection extends \PDO implements ConnectionInterface /** * @param string $name The datasource name associated to this connection + * * @return void */ public function setName($name) @@ -50,7 +52,7 @@ public function getName() * @param string|null $password * @param array|null $options */ - public function __construct($dsn, $user = null, $password = null, array $options = null) + public function __construct($dsn, $user = null, $password = null, ?array $options = null) { // Convert option keys from a string to a \PDO:: constant $pdoOptions = []; @@ -63,7 +65,7 @@ public function __construct($dsn, $user = null, $password = null, array $options parent::__construct($dsn, $user, $password, $pdoOptions); - $this->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } /** @@ -71,15 +73,16 @@ public function __construct($dsn, $user = null, $password = null, array $options * * This is overridden here to allow names corresponding to PDO constant names. * - * @param integer $attribute The attribute to set (e.g. 'PDO::ATTR_CASE', or more simply 'ATTR_CASE'). - * @param mixed $value The attribute value. + * @param int $attribute The attribute to set (e.g. 'PDO::ATTR_CASE', or more simply 'ATTR_CASE'). + * @param mixed $value The attribute value. + * + * @throws \Propel\Runtime\Exception\InvalidArgumentException * * @return bool - * @throws InvalidArgumentException */ public function setAttribute($attribute, $value) { - if (is_string($attribute) && false === strpos($attribute, '::')) { + if (is_string($attribute) && strpos($attribute, '::') === false) { $attribute = '\PDO::' . $attribute; if (!defined($attribute)) { throw new InvalidArgumentException(sprintf('Invalid PDO option/attribute name specified: "%s"', $attribute)); @@ -137,7 +140,8 @@ public function inTransaction() /** * Overwrite. Fixes HHVM strict issue. * - * @param string|null $name + * @param string|null $name + * * @return string|int */ public function lastInsertId($name = null) @@ -148,8 +152,9 @@ public function lastInsertId($name = null) /** * Overwrite. Fixes HHVM strict issue. * - * @param string $statement - * @param array $driver_options + * @param string $statement + * @param array|null $driver_options + * * @return bool|\PDOStatement|void */ public function prepare($statement, $driver_options = null) @@ -160,12 +165,13 @@ public function prepare($statement, $driver_options = null) /** * Overwrite. Fixes HHVM strict issue. * - * @param string $string - * @param int $parameter_type + * @param string $string + * @param int $parameterType + * * @return string */ - public function quote($string, $parameter_type = \PDO::PARAM_STR) + public function quote($string, $parameterType = PDO::PARAM_STR) { - return parent::quote($string, $parameter_type); + return parent::quote($string, $parameterType); } } diff --git a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php index 55835165c3..cdca190fa9 100644 --- a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php @@ -21,7 +21,7 @@ class ProfilerConnectionWrapper extends ConnectionWrapper /** * Whether or not the debug is enabled * - * @var boolean + * @var bool */ public $useDebug = true; @@ -31,6 +31,7 @@ class ProfilerConnectionWrapper extends ConnectionWrapper protected $profiler; /** + * @var bool * Whether the logging is enabled only for slow queries. * The slow threshold is set on the profiler. */ @@ -38,6 +39,7 @@ class ProfilerConnectionWrapper extends ConnectionWrapper /** * @param \Propel\Runtime\Util\Profiler $profiler + * * @return void */ public function setProfiler(Profiler $profiler) @@ -50,7 +52,7 @@ public function setProfiler(Profiler $profiler) */ public function getProfiler() { - if (null === $this->profiler) { + if ($this->profiler === null) { $this->profiler = Propel::getServiceContainer()->getProfiler(); } @@ -61,7 +63,8 @@ public function getProfiler() * Overrides the parent setAttribute to support the isSlowOnly attribute. * * @param string $attribute The attribute name, or the constant name containing the attribute name (e.g. 'PDO::ATTR_CASE') - * @param mixed $value + * @param mixed $value + * * @return bool */ public function setAttribute($attribute, $value) @@ -71,6 +74,7 @@ public function setAttribute($attribute, $value) // Set whether the connection must only log slow queries. // The slow threshold must be set on the profiler (100ms by default). $this->isSlowOnly = $value; + return true; default: return parent::setAttribute($attribute, $value); diff --git a/src/Propel/Runtime/Connection/ProfilerStatementWrapper.php b/src/Propel/Runtime/Connection/ProfilerStatementWrapper.php index 16059df1db..5f5863e4f6 100644 --- a/src/Propel/Runtime/Connection/ProfilerStatementWrapper.php +++ b/src/Propel/Runtime/Connection/ProfilerStatementWrapper.php @@ -10,6 +10,8 @@ namespace Propel\Runtime\Connection; +use PDO; + /** * Statement class with profiling abilities. */ @@ -21,15 +23,15 @@ class ProfilerStatementWrapper extends StatementWrapper * as a reference and will only be evaluated at the time that PDOStatement::execute() is called. * Returns a boolean value indicating success. * - * @param integer $pos Parameter identifier (for determining what to replace in the query). - * @param mixed $value The value to bind to the parameter. - * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. - * @param integer $length Length of the data type. To indicate that a parameter is an OUT parameter from a stored procedure, you must explicitly set the length. - * @param mixed $driver_options + * @param int $pos Parameter identifier (for determining what to replace in the query). + * @param mixed $value The value to bind to the parameter. + * @param int $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. + * @param int|null $length Length of the data type. To indicate that a parameter is an OUT parameter from a stored procedure, you must explicitly set the length. + * @param mixed $driver_options * - * @return boolean + * @return bool */ - public function bindParam($pos, &$value, $type = \PDO::PARAM_STR, $length = 0, $driver_options = null) + public function bindParam($pos, &$value, $type = PDO::PARAM_STR, $length = 0, $driver_options = null) { $this->connection->getProfiler()->start(); @@ -40,13 +42,13 @@ public function bindParam($pos, &$value, $type = \PDO::PARAM_STR, $length = 0, $ * Binds a value to a corresponding named or question mark placeholder in the SQL statement * that was use to prepare the statement. Returns a boolean value indicating success. * - * @param integer $pos Parameter identifier (for determining what to replace in the query). - * @param mixed $value The value to bind to the parameter. - * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. + * @param int $pos Parameter identifier (for determining what to replace in the query). + * @param mixed $value The value to bind to the parameter. + * @param int $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. * - * @return boolean + * @return bool */ - public function bindValue($pos, $value, $type = \PDO::PARAM_STR) + public function bindValue($pos, $value, $type = PDO::PARAM_STR) { $this->connection->getProfiler()->start(); @@ -54,11 +56,12 @@ public function bindValue($pos, $value, $type = \PDO::PARAM_STR) } /** - * Executes a prepared statement. Returns a boolean value indicating success. + * Executes a prepared statement. Returns a boolean value indicating success. * Overridden for query counting and logging. * - * @param array|null $parameters - * @return boolean + * @param array|null $parameters + * + * @return bool */ public function execute($parameters = null) { diff --git a/src/Propel/Runtime/Connection/StatementWrapper.php b/src/Propel/Runtime/Connection/StatementWrapper.php index 4c95734311..fd192713db 100644 --- a/src/Propel/Runtime/Connection/StatementWrapper.php +++ b/src/Propel/Runtime/Connection/StatementWrapper.php @@ -10,22 +10,26 @@ namespace Propel\Runtime\Connection; +use IteratorAggregate; +use PDO; +use PDOStatement; + /** * Wraps a Statement class, providing logging. - * */ -class StatementWrapper extends \PDOStatement implements \IteratorAggregate +class StatementWrapper extends PDOStatement implements IteratorAggregate { - /** * The wrapped statement class + * * @var \PDOStatement */ protected $statement; /** * The connection wrapper generating this object - * @var ConnectionWrapper + * + * @var \Propel\Runtime\Connection\ConnectionWrapper */ protected $connection; @@ -37,15 +41,15 @@ class StatementWrapper extends \PDOStatement implements \IteratorAggregate * @var array */ protected static $typeMap = [ - 0 => 'PDO::PARAM_NULL', - 1 => 'PDO::PARAM_INT', - 2 => 'PDO::PARAM_STR', - 3 => 'PDO::PARAM_LOB', - 5 => 'PDO::PARAM_BOOL', + 0 => 'PDO::PARAM_NULL', + 1 => 'PDO::PARAM_INT', + 2 => 'PDO::PARAM_STR', + 3 => 'PDO::PARAM_LOB', + 5 => 'PDO::PARAM_BOOL', ]; /** - * @var array The values that have been bound + * @var array The values that have been bound */ protected $boundValues = []; @@ -57,8 +61,8 @@ class StatementWrapper extends \PDOStatement implements \IteratorAggregate /** * Creates a Statement instance * - * @param string $sql The SQL query for this statement - * @param ConnectionWrapper $connection The parent connection + * @param string $sql The SQL query for this statement + * @param \Propel\Runtime\Connection\ConnectionWrapper $connection The parent connection */ public function __construct($sql, ConnectionWrapper $connection) { @@ -67,7 +71,8 @@ public function __construct($sql, ConnectionWrapper $connection) } /** - * @param array $options Optional driver options + * @param array $options Optional driver options + * * @return $this */ public function prepare($options) @@ -95,19 +100,19 @@ public function query() * as a reference and will only be evaluated at the time that PDOStatement::execute() is called. * Returns a boolean value indicating success. * - * @param integer $pos Parameter identifier (for determining what to replace in the query). - * @param mixed $value The value to bind to the parameter. - * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. - * @param integer $length Length of the data type. To indicate that a parameter is an OUT parameter from a stored procedure, you must explicitly set the length. - * @param mixed $driver_options + * @param int $pos Parameter identifier (for determining what to replace in the query). + * @param mixed $value The value to bind to the parameter. + * @param int $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. + * @param int $length Length of the data type. To indicate that a parameter is an OUT parameter from a stored procedure, you must explicitly set the length. + * @param mixed $driver_options * - * @return boolean + * @return bool */ - public function bindParam($pos, &$value, $type = \PDO::PARAM_STR, $length = 0, $driver_options = null) + public function bindParam($pos, &$value, $type = PDO::PARAM_STR, $length = 0, $driver_options = null) { $return = $this->statement->bindParam($pos, $value, $type, $length, $driver_options); if ($this->connection->useDebug) { - $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)'; + $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)'; $valuestr = $length > 100 ? '[Large value]' : var_export($value, true); $this->boundValues[$pos] = $valuestr; $msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr); @@ -121,18 +126,18 @@ public function bindParam($pos, &$value, $type = \PDO::PARAM_STR, $length = 0, $ * Binds a value to a corresponding named or question mark placeholder in the SQL statement * that was use to prepare the statement. Returns a boolean value indicating success. * - * @param integer $pos Parameter identifier (for determining what to replace in the query). - * @param mixed $value The value to bind to the parameter. - * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. + * @param int $pos Parameter identifier (for determining what to replace in the query). + * @param mixed $value The value to bind to the parameter. + * @param int $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. * - * @return boolean + * @return bool */ - public function bindValue($pos, $value, $type = \PDO::PARAM_STR) + public function bindValue($pos, $value, $type = PDO::PARAM_STR) { $return = $this->statement->bindValue($pos, $value, $type); if ($this->connection->useDebug) { $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)'; - $valuestr = $type == \PDO::PARAM_LOB ? '[LOB value]' : var_export($value, true); + $valuestr = $type == PDO::PARAM_LOB ? '[LOB value]' : var_export($value, true); $this->boundValues[$pos] = $valuestr; $msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr); $this->connection->log($msg); @@ -153,7 +158,7 @@ public function bindValue($pos, $value, $type = \PDO::PARAM_STR) * has unfetched rows. If your database driver suffers from this limitation, * the problem may manifest itself in an out-of-sequence error. * - * @return boolean Returns TRUE on success or FALSE on failure. + * @return bool Returns TRUE on success or FALSE on failure. */ public function closeCursor() { @@ -173,9 +178,9 @@ public function closeCursor() * column count will not be available until you invoke Statement::execute(). * Returns the number of columns in the result set * - * @return integer Returns the number of columns in the result set represented - * by the PDOStatement object. If there is no result set, - * this method should return 0. + * @return int Returns the number of columns in the result set represented + * by the PDOStatement object. If there is no result set, + * this method should return 0. */ public function columnCount() { @@ -188,8 +193,9 @@ public function columnCount() * Returns a boolean value indicating success. * Overridden for query counting and logging. * - * @param array|null $input_parameters - * @return boolean + * @param array|null $input_parameters + * + * @return bool */ public function execute($input_parameters = null) { @@ -206,6 +212,7 @@ public function execute($input_parameters = null) /** * @param array|null $input_parameters + * * @return string */ public function getExecutedQueryString($input_parameters = null) @@ -214,12 +221,14 @@ public function getExecutedQueryString($input_parameters = null) $matches = []; if (preg_match_all('/(:p[0-9]+\b)/', $sql, $matches)) { $size = count($matches[1]); - for ($i = $size-1; $i >= 0; $i--) { + for ($i = $size - 1; $i >= 0; $i--) { $pos = $matches[1][$i]; - if (isset($this->boundValues[$pos])) + if (isset($this->boundValues[$pos])) { $sql = str_replace($pos, $this->boundValues[$pos], $sql); - if ($input_parameters && isset($input_parameters[$pos])) + } + if ($input_parameters && isset($input_parameters[$pos])) { $sql = str_replace($pos, $input_parameters[$pos], $sql); + } } } @@ -232,11 +241,11 @@ public function getExecutedQueryString($input_parameters = null) * Fetches a row from a result set associated with a Statement object. * The fetch_style parameter determines how the Connection returns the row. * - * @param integer $fetchStyle Controls how the next row will be returned to the caller. + * @param int $fetchStyle Controls how the next row will be returned to the caller. * * @return mixed */ - public function fetch($fetchStyle = \PDO::FETCH_BOTH, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0) + public function fetch($fetchStyle = PDO::FETCH_BOTH, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0) { return $this->statement->fetch($fetchStyle); } @@ -244,11 +253,11 @@ public function fetch($fetchStyle = \PDO::FETCH_BOTH, $cursorOrientation = \PDO: /** * Returns an array containing all of the result set rows. * - * @param integer $fetchStyle Controls the contents of the returned array as documented in fetch() + * @param int|null $fetchStyle Controls the contents of the returned array as documented in fetch() * * @return array */ - public function fetchAll($fetchStyle = \PDO::FETCH_BOTH, $fetchArgument = null, $ctorArgs = []) + public function fetchAll($fetchStyle = PDO::FETCH_BOTH, $fetchArgument = null, $ctorArgs = []) { return $this->statement->fetchAll($fetchStyle); } @@ -256,9 +265,9 @@ public function fetchAll($fetchStyle = \PDO::FETCH_BOTH, $fetchArgument = null, /** * Returns a single column from the next row of a result set. * - * @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no - * value is supplied, PDOStatement->fetchColumn() - * fetches the first column. + * @param int $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no + * value is supplied, PDOStatement->fetchColumn() + * fetches the first column. * * @return string A single column in the next row of a result set. */ @@ -278,7 +287,7 @@ public function fetchColumn($columnIndex = 0) * this behaviour is not guaranteed for all databases and should not be * relied on for portable applications. * - * @return integer The number of rows. + * @return int The number of rows. */ public function rowCount() { @@ -296,7 +305,7 @@ public function getIterator() } /** - * @return ConnectionWrapper + * @return \Propel\Runtime\Connection\ConnectionWrapper */ public function getConnection() { @@ -313,9 +322,10 @@ public function getStatement() /** * @param \PDOStatement $statement + * * @return void */ - public function setStatement(\PDOStatement $statement) + public function setStatement(PDOStatement $statement) { $this->statement = $statement; } @@ -338,5 +348,4 @@ public function __call($method, $args) { return call_user_func_array([$this->statement, $method], $args); } - } diff --git a/src/Propel/Runtime/Connection/TransactionTrait.php b/src/Propel/Runtime/Connection/TransactionTrait.php index e9996be5a2..b342b6c99e 100644 --- a/src/Propel/Runtime/Connection/TransactionTrait.php +++ b/src/Propel/Runtime/Connection/TransactionTrait.php @@ -10,6 +10,8 @@ namespace Propel\Runtime\Connection; +use Exception; + /** * Transaction helper trait */ @@ -23,9 +25,9 @@ trait TransactionTrait * * @param callable $callable A callable to be wrapped in a transaction * - * @return mixed Returns the result of the callable. - * * @throws \Exception Re-throws a possible Exception triggered by the callable. + * + * @return mixed Returns the result of the callable. */ public function transaction(callable $callable) { @@ -37,7 +39,7 @@ public function transaction(callable $callable) $this->commit(); return $result; - } catch (\Exception $e) { + } catch (Exception $e) { $this->rollBack(); throw $e; diff --git a/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php b/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php index be73091d52..7a36cdea43 100644 --- a/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php @@ -22,6 +22,7 @@ public function __construct($dataObject) /** * {@inheritDoc} + * * @return void */ public function setDataObject($dataObject) @@ -45,7 +46,7 @@ public function fetchColumn($index = null) $next = $this->fetch(); if ($next) { - return null === $index ? current($next) : (isset($next[$index]) ? $next[$index] : null); + return $index === null ? current($next) : (isset($next[$index]) ? $next[$index] : null); } } } diff --git a/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php b/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php index 275de5505b..3f77a09bca 100644 --- a/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php @@ -18,11 +18,12 @@ class ArrayDataFetcher extends AbstractDataFetcher /** * {@inheritDoc} + * * @return void */ public function next() { - if (null !== $this->dataObject) { + if ($this->dataObject !== null) { next($this->dataObject); } } @@ -32,7 +33,7 @@ public function next() */ public function current() { - return null === $this->dataObject ? null : current($this->dataObject); + return $this->dataObject === null ? null : current($this->dataObject); } /** @@ -51,7 +52,7 @@ public function fetch() */ public function key() { - return null === $this->dataObject ? null : key($this->dataObject); + return $this->dataObject === null ? null : key($this->dataObject); } /** @@ -59,11 +60,12 @@ public function key() */ public function valid() { - return (null !== $this->dataObject && null !== key($this->dataObject)); + return ($this->dataObject !== null && key($this->dataObject) !== null); } /** * {@inheritDoc} + * * @return void */ public function rewind() @@ -88,13 +90,14 @@ public function getIndexType() */ public function count() { - return null === $this->dataObject ? null : count($this->dataObject); + return $this->dataObject === null ? null : count($this->dataObject); } /** * Sets the current index type. * * @param string $indexType one of TableMap::TYPE_* + * * @return void */ public function setIndexType($indexType) @@ -104,6 +107,7 @@ public function setIndexType($indexType) /** * {@inheritDoc} + * * @return void */ public function close() diff --git a/src/Propel/Runtime/DataFetcher/DataFetcherInterface.php b/src/Propel/Runtime/DataFetcher/DataFetcherInterface.php index 3fb9c3c82e..822e03b33f 100644 --- a/src/Propel/Runtime/DataFetcher/DataFetcherInterface.php +++ b/src/Propel/Runtime/DataFetcher/DataFetcherInterface.php @@ -2,10 +2,13 @@ namespace Propel\Runtime\DataFetcher; +use Countable; +use Iterator; + /** * Interface class for DataFetcher. */ -interface DataFetcherInterface extends \Iterator, \Countable +interface DataFetcherInterface extends Iterator, Countable { /** * Sets the dataObject. @@ -25,6 +28,7 @@ public function getDataObject(); * Return the current element * * @link http://php.net/manual/en/iterator.current.php + * * @return mixed Can return any type. */ public function current(); @@ -33,6 +37,7 @@ public function current(); * Move forward to next element * * @link http://php.net/manual/en/iterator.next.php + * * @return void Any returned value is ignored. */ public function next(); @@ -41,6 +46,7 @@ public function next(); * Return the key of the current element * * @link http://php.net/manual/en/iterator.key.php + * * @return mixed scalar on success, or null on failure. */ public function key(); @@ -49,8 +55,9 @@ public function key(); * Checks if current position is valid * * @link http://php.net/manual/en/iterator.valid.php - * @return boolean The return value will be casted to boolean and then evaluated. - * Returns true on success or false on failure. + * + * @return bool The return value will be casted to boolean and then evaluated. + * Returns true on success or false on failure. */ public function valid(); @@ -58,6 +65,7 @@ public function valid(); * Rewind the Iterator to the first element * * @link http://php.net/manual/en/iterator.rewind.php + * * @return void Any returned value is ignored. */ public function rewind(); @@ -66,7 +74,7 @@ public function rewind(); * Returns the data of the first column of the next row, * based on this->fetch(); * - * @param int $index + * @param int|null $index * * @return mixed|null */ diff --git a/src/Propel/Runtime/DataFetcher/PDODataFetcher.php b/src/Propel/Runtime/DataFetcher/PDODataFetcher.php index 8a9653d321..2db0245ed5 100644 --- a/src/Propel/Runtime/DataFetcher/PDODataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/PDODataFetcher.php @@ -2,6 +2,7 @@ namespace Propel\Runtime\DataFetcher; +use PDO; use Propel\Runtime\Map\TableMap; /** @@ -25,31 +26,38 @@ class PDODataFetcher extends AbstractDataFetcher /** * For SQLITE rowCount emulation. - * @var integer + * + * @var int */ private $cachedCount; /** * fetch style (default FETCH_NUM) - * @var integer + * + * @var int */ - private $style = \PDO::FETCH_NUM; + private $style = PDO::FETCH_NUM; /** * Sets a new fetch style (FETCH_NUM, FETCH_ASSOC or FETCH_BOTH). Returns previous fetch style. - * @var integer + * + * @var int */ - public function setStyle($style) { + public function setStyle($style) + { $old_style = $this->style; $this->style = $style; + return $old_style; } /** * Returns current fetch style (FETCH_NUM, FETCH_ASSOC or FETCH_BOTH). - * @var integer + * + * @var int */ - public function getStyle() { + public function getStyle() + { return $this->style; } @@ -58,19 +66,21 @@ public function getStyle() { */ public function fetch($style = null) { - if (is_null($style)) { + if ($style === null) { $style = $this->style; } + return $this->getDataObject()->fetch($style); } /** * {@inheritDoc} + * * @return void */ public function next() { - if (null !== $this->dataObject) { + if ($this->dataObject !== null) { $this->current = $this->dataObject->fetch($this->style); if ($this->current) { $this->index++; @@ -99,23 +109,26 @@ public function key() */ public function valid() { - return null !== $this->current && false !== $this->current; + return $this->current !== null && $this->current !== false; } /** * Not supported in PDODataFetcher. * It actually fetches the first row, since a foreach in php triggers that * function as init. + * * @return void */ public function rewind() { - if ($this->dataObject) + if ($this->dataObject) { $this->current = $this->dataObject->fetch($this->style); + } } /** * {@inheritDoc} + * * @return void */ public function close() @@ -123,7 +136,7 @@ public function close() $this->getDataObject()->closeCursor(); $this->setDataObject(null); //so the connection can be garbage collected $this->current = null; - $this->index = -1; + $this->index = -1; } /** @@ -131,17 +144,17 @@ public function close() */ public function count() { - if ($this->dataObject && 'sqlite' === $this->dataObject->getConnection()->getAttribute(\PDO::ATTR_DRIVER_NAME)) { + if ($this->dataObject && $this->dataObject->getConnection()->getAttribute(PDO::ATTR_DRIVER_NAME) === 'sqlite') { $lastQuery = $this->dataObject->getStatement()->queryString; - if ('SELECT ' === substr(trim(strtoupper($lastQuery)), 0, 7)) { + if (substr(trim(strtoupper($lastQuery)), 0, 7) === 'SELECT ') { // SQLITE does not support rowCount() in 3.x on SELECTs anymore // so emulate it - if (null === $this->cachedCount) { - $sql = sprintf("SELECT COUNT(*) FROM (%s)", $lastQuery); + if ($this->cachedCount === null) { + $sql = sprintf('SELECT COUNT(*) FROM (%s)', $lastQuery); $stmt = $this->dataObject->getConnection()->prepare($sql); $stmt->execute($this->dataObject->getBoundValues()); $count = $stmt->fetchColumn(); - $this->cachedCount = $count+0; + $this->cachedCount = $count + 0; } return $this->cachedCount; @@ -166,14 +179,16 @@ public function getIndexType() * * @param mixed $column * @param mixed $param - * @param int $type - * @param int $maxlen + * @param int|null $type + * @param int|null $maxlen * @param mixed $driverdata + * * @return void */ public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null) { - if ($this->dataObject) + if ($this->dataObject) { $this->dataObject->bindColumn($column, $param, $type, $maxlen, $driverdata); + } } } diff --git a/src/Propel/Runtime/Exception/BadMethodCallException.php b/src/Propel/Runtime/Exception/BadMethodCallException.php index 74c0282b90..93583574f4 100644 --- a/src/Propel/Runtime/Exception/BadMethodCallException.php +++ b/src/Propel/Runtime/Exception/BadMethodCallException.php @@ -10,9 +10,11 @@ namespace Propel\Runtime\Exception; +use BadMethodCallException as CoreBadMethodCallException; + /** * @author William Durand */ -class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface +class BadMethodCallException extends CoreBadMethodCallException implements ExceptionInterface { } diff --git a/src/Propel/Runtime/Exception/InvalidArgumentException.php b/src/Propel/Runtime/Exception/InvalidArgumentException.php index 35ba3f593d..1ac2b73489 100644 --- a/src/Propel/Runtime/Exception/InvalidArgumentException.php +++ b/src/Propel/Runtime/Exception/InvalidArgumentException.php @@ -10,9 +10,11 @@ namespace Propel\Runtime\Exception; +use InvalidArgumentException as CoreInvalidArgumentException; + /** * @author William Durand */ -class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface +class InvalidArgumentException extends CoreInvalidArgumentException implements ExceptionInterface { } diff --git a/src/Propel/Runtime/Exception/LogicException.php b/src/Propel/Runtime/Exception/LogicException.php index f457b22fb8..631f79dbd2 100644 --- a/src/Propel/Runtime/Exception/LogicException.php +++ b/src/Propel/Runtime/Exception/LogicException.php @@ -10,9 +10,11 @@ namespace Propel\Runtime\Exception; +use LogicException as CoreLogicException; + /** * @author William Durand */ -class LogicException extends \LogicException implements ExceptionInterface +class LogicException extends CoreLogicException implements ExceptionInterface { } diff --git a/src/Propel/Runtime/Exception/PropelException.php b/src/Propel/Runtime/Exception/PropelException.php index 5573aab758..b298477f4f 100644 --- a/src/Propel/Runtime/Exception/PropelException.php +++ b/src/Propel/Runtime/Exception/PropelException.php @@ -10,9 +10,11 @@ namespace Propel\Runtime\Exception; +use Exception; + /** * @author Hans Lellelid */ -class PropelException extends \Exception implements ExceptionInterface +class PropelException extends Exception implements ExceptionInterface { } diff --git a/src/Propel/Runtime/Exception/RuntimeException.php b/src/Propel/Runtime/Exception/RuntimeException.php index 4a4f5457a9..14a6d18963 100644 --- a/src/Propel/Runtime/Exception/RuntimeException.php +++ b/src/Propel/Runtime/Exception/RuntimeException.php @@ -10,9 +10,11 @@ namespace Propel\Runtime\Exception; +use RuntimeException as CoreRuntimeException; + /** * @author William Durand */ -class RuntimeException extends \RuntimeException implements ExceptionInterface +class RuntimeException extends CoreRuntimeException implements ExceptionInterface { } diff --git a/src/Propel/Runtime/Exception/UnexpectedValueException.php b/src/Propel/Runtime/Exception/UnexpectedValueException.php index dfeec1fc34..71a6d1ca8c 100644 --- a/src/Propel/Runtime/Exception/UnexpectedValueException.php +++ b/src/Propel/Runtime/Exception/UnexpectedValueException.php @@ -10,9 +10,11 @@ namespace Propel\Runtime\Exception; +use UnexpectedValueException as CoreUnexpectedValueException; + /** * @author William Durand */ -class UnexpectedValueException extends \UnexpectedValueException implements ExceptionInterface +class UnexpectedValueException extends CoreUnexpectedValueException implements ExceptionInterface { } diff --git a/src/Propel/Runtime/Formatter/AbstractFormatter.php b/src/Propel/Runtime/Formatter/AbstractFormatter.php index 088c34619e..f0606575f4 100644 --- a/src/Propel/Runtime/Formatter/AbstractFormatter.php +++ b/src/Propel/Runtime/Formatter/AbstractFormatter.php @@ -10,13 +10,11 @@ namespace Propel\Runtime\Formatter; -use Propel\Runtime\ActiveQuery\ModelWith; -use Propel\Runtime\ActiveRecord\ActiveRecordInterface; -use Propel\Runtime\Collection\Collection; -use Propel\Runtime\Propel; -use Propel\Runtime\Exception\PropelException; use Propel\Runtime\ActiveQuery\BaseModelCriteria; +use Propel\Runtime\ActiveRecord\ActiveRecordInterface; use Propel\Runtime\DataFetcher\DataFetcherInterface; +use Propel\Runtime\Exception\PropelException; +use Propel\Runtime\Propel; /** * Abstract class for query formatter @@ -41,7 +39,7 @@ abstract class AbstractFormatter protected $tableMap; /** - * @var ModelWith[] $with + * @var \Propel\Runtime\ActiveQuery\ModelWith[] $with */ protected $with = []; @@ -56,12 +54,12 @@ abstract class AbstractFormatter protected $hasLimit = false; /** - * @var ActiveRecordInterface[] + * @var \Propel\Runtime\ActiveRecord\ActiveRecordInterface[] */ protected $currentObjects = []; /** - * @var DataFetcherInterface + * @var \Propel\Runtime\DataFetcher\DataFetcherInterface */ protected $dataFetcher; @@ -69,9 +67,9 @@ abstract class AbstractFormatter * @param \Propel\Runtime\ActiveQuery\BaseModelCriteria|null $criteria * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher */ - public function __construct(BaseModelCriteria $criteria = null, DataFetcherInterface $dataFetcher = null) + public function __construct(?BaseModelCriteria $criteria = null, ?DataFetcherInterface $dataFetcher = null) { - if (null !== $criteria) { + if ($criteria !== null) { $this->init($criteria, $dataFetcher); } } @@ -79,7 +77,8 @@ public function __construct(BaseModelCriteria $criteria = null, DataFetcherInter /** * Sets a DataFetcherInterface object. * - * @param DataFetcherInterface $dataFetcher + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface $dataFetcher + * * @return void */ public function setDataFetcher(DataFetcherInterface $dataFetcher) @@ -90,7 +89,7 @@ public function setDataFetcher(DataFetcherInterface $dataFetcher) /** * Returns the current DataFetcherInterface object. * - * @return DataFetcherInterface + * @return \Propel\Runtime\DataFetcher\DataFetcherInterface */ public function getDataFetcher() { @@ -101,12 +100,12 @@ public function getDataFetcher() * Define the hydration schema based on a query object. * Fills the Formatter's properties using a Criteria as source * - * @param BaseModelCriteria $criteria - * @param DataFetcherInterface $dataFetcher + * @param \Propel\Runtime\ActiveQuery\BaseModelCriteria $criteria + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher * * @return $this The current formatter object */ - public function init(BaseModelCriteria $criteria, DataFetcherInterface $dataFetcher = null) + public function init(BaseModelCriteria $criteria, ?DataFetcherInterface $dataFetcher = null) { $this->dbName = $criteria->getDbName(); $this->setClass($criteria->getModelName()); @@ -122,6 +121,11 @@ public function init(BaseModelCriteria $criteria, DataFetcherInterface $dataFetc // DataObject getters & setters + /** + * @param string $dbName + * + * @return void + */ public function setDbName($dbName) { $this->dbName = $dbName; @@ -142,8 +146,8 @@ public function getDbName() */ public function setClass($class) { - $this->class = $class; - $this->tableMap = constant($this->class . '::TABLE_MAP'); + $this->class = $class; + $this->tableMap = constant($this->class . '::TABLE_MAP'); } /** @@ -211,7 +215,7 @@ public function hasLimit() /** * Returns a Collection object or a simple array. * - * @return Collection|array + * @return \Propel\Runtime\Collection\Collection|array */ protected function getCollection() { @@ -219,7 +223,7 @@ protected function getCollection() $class = $this->getCollectionClassName(); if ($class) { - /** @var Collection $collection */ + /** @var \Propel\Runtime\Collection\Collection $collection */ $collection = new $class(); $collection->setModel($this->class); $collection->setFormatter($this); @@ -239,18 +243,28 @@ public function getCollectionClassName() /** * Formats an ActiveRecord object * - * @param ActiveRecordInterface $record the object to format + * @param \Propel\Runtime\ActiveRecord\ActiveRecordInterface|null $record the object to format * - * @return ActiveRecordInterface The original record + * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface The original record */ - public function formatRecord(ActiveRecordInterface $record = null) + public function formatRecord(?ActiveRecordInterface $record = null) { return $record; } - abstract public function format(DataFetcherInterface $dataFetcher = null); + /** + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher + * + * @return mixed + */ + abstract public function format(?DataFetcherInterface $dataFetcher = null); - abstract public function formatOne(DataFetcherInterface $dataFetcher = null); + /** + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher + * + * @return mixed + */ + abstract public function formatOne(?DataFetcherInterface $dataFetcher = null); /** * @return bool @@ -259,11 +273,12 @@ abstract public function isObjectFormatter(); /** * @throws \Propel\Runtime\Exception\PropelException + * * @return void */ public function checkInit() { - if (null === $this->tableMap) { + if ($this->tableMap === null) { throw new PropelException('You must initialize a formatter object before calling format() or formatOne()'); } } @@ -293,12 +308,12 @@ protected function isWithOneToMany() /** * Gets a Propel object hydrated from a selection of columns in statement row * - * @param array $row associative array indexed by column number, + * @param array $row associative array indexed by column number, * as returned by DataFetcher::fetch() * @param string $class The classname of the object to create - * @param int $col The start column for the hydration (modified) + * @param int $col The start column for the hydration (modified) * - * @return ActiveRecordInterface + * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface */ public function getSingleObjectFromRow($row, $class, &$col = 0) { diff --git a/src/Propel/Runtime/Formatter/ArrayFormatter.php b/src/Propel/Runtime/Formatter/ArrayFormatter.php index 061e9713b1..518ff127d8 100644 --- a/src/Propel/Runtime/Formatter/ArrayFormatter.php +++ b/src/Propel/Runtime/Formatter/ArrayFormatter.php @@ -11,8 +11,9 @@ namespace Propel\Runtime\Formatter; use Propel\Runtime\ActiveRecord\ActiveRecordInterface; -use Propel\Runtime\Exception\LogicException; use Propel\Runtime\DataFetcher\DataFetcherInterface; +use Propel\Runtime\Exception\LogicException; +use ReflectionClass; /** * Array formatter for Propel query @@ -22,11 +23,17 @@ */ class ArrayFormatter extends AbstractFormatter { + /** + * @var array + */ protected $alreadyHydratedObjects = []; + /** + * @var mixed + */ protected $emptyVariable; - public function format(DataFetcherInterface $dataFetcher = null) + public function format(?DataFetcherInterface $dataFetcher = null) { $this->checkInit(); @@ -46,7 +53,7 @@ public function format(DataFetcherInterface $dataFetcher = null) foreach ($dataFetcher as $row) { $object = &$this->getStructuredArrayFromRow($row); if ($object) { - $items[] =& $object; + $items[] = & $object; } } @@ -73,9 +80,10 @@ public function getCollectionClassName() * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher * * @throws \Propel\Runtime\Exception\LogicException + * * @return array|null */ - public function formatOne(DataFetcherInterface $dataFetcher = null) + public function formatOne(?DataFetcherInterface $dataFetcher = null) { $this->checkInit(); $result = null; @@ -106,11 +114,11 @@ public function formatOne(DataFetcherInterface $dataFetcher = null) /** * Formats an ActiveRecord object * - * @param ActiveRecordInterface|null $record the object to format + * @param \Propel\Runtime\ActiveRecord\ActiveRecordInterface|null $record the object to format * * @return array The original record turned into an array */ - public function formatRecord(ActiveRecordInterface $record = null) + public function formatRecord(?ActiveRecordInterface $record = null) { return $record ? $record->toArray() : []; } @@ -128,7 +136,7 @@ public function isObjectFormatter() * The first object to hydrate is the model of the Criteria * The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one * - * @param array $row associative array indexed by column number, + * @param array $row associative array indexed by column number, * as returned by DataFetcher::fetch() * * @return array @@ -154,13 +162,13 @@ public function &getStructuredArrayFromRow($row) // related objects added using with() foreach ($this->getWith() as $relAlias => $modelWith) { - // determine class to use if ($modelWith->isSingleTableInheritance()) { $class = call_user_func([$modelWith->getTableMap(), 'getOMClass'], $row, $col, false); - $refl = new \ReflectionClass($class); + $refl = new ReflectionClass($class); if ($refl->isAbstract()) { - $col += constant('Map\\'.$class . 'TableMap::NUM_COLUMNS'); + $col += constant('Map\\' . $class . 'TableMap::NUM_COLUMNS'); + continue; } } else { @@ -178,7 +186,6 @@ public function &getStructuredArrayFromRow($row) // in order to get the $col variable increased anyway $secondaryObject = $this->getSingleObjectFromRow($row, $class, $col); if (!isset($this->alreadyHydratedObjects[$relAlias][$key])) { - if ($secondaryObject->isPrimaryKeyNull()) { $this->alreadyHydratedObjects[$relAlias][$key] = []; } else { @@ -193,7 +200,8 @@ public function &getStructuredArrayFromRow($row) } if ($modelWith->isAdd()) { - if (!isset($arrayToAugment[$modelWith->getRelationName()]) || + if ( + !isset($arrayToAugment[$modelWith->getRelationName()]) || !in_array( $this->alreadyHydratedObjects[$relAlias][$key], $arrayToAugment[$modelWith->getRelationName()] diff --git a/src/Propel/Runtime/Formatter/ObjectFormatter.php b/src/Propel/Runtime/Formatter/ObjectFormatter.php index 4e4e522aee..0f3b6617ed 100644 --- a/src/Propel/Runtime/Formatter/ObjectFormatter.php +++ b/src/Propel/Runtime/Formatter/ObjectFormatter.php @@ -10,7 +10,6 @@ namespace Propel\Runtime\Formatter; -use Propel\Runtime\ActiveRecord\ActiveRecordInterface; use Propel\Runtime\DataFetcher\DataFetcherInterface; use Propel\Runtime\Exception\LogicException; @@ -22,13 +21,18 @@ */ class ObjectFormatter extends AbstractFormatter { - /** * @var array */ protected $objects = []; - public function format(DataFetcherInterface $dataFetcher = null) + /** + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher + * + * @throws \Propel\Runtime\Exception\LogicException + * @return array|\Propel\Runtime\Collection\Collection + */ + public function format(?DataFetcherInterface $dataFetcher = null) { $this->checkInit(); if ($dataFetcher) { @@ -45,7 +49,7 @@ public function format(DataFetcherInterface $dataFetcher = null) } foreach ($dataFetcher as $row) { $object = $this->getAllObjectsFromRow($row); - $pk = $object->getPrimaryKey(); + $pk = $object->getPrimaryKey(); $serializedPk = serialize($pk); if (!isset($this->objects[$serializedPk])) { @@ -76,9 +80,10 @@ public function getCollectionClassName() * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher * * @throws \Propel\Runtime\Exception\LogicException + * * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface|null */ - public function formatOne(DataFetcherInterface $dataFetcher = null) + public function formatOne(?DataFetcherInterface $dataFetcher = null) { $this->checkInit(); $result = null; @@ -116,7 +121,7 @@ public function isObjectFormatter() * @param array $row associative array indexed by column number, * as returned by DataFetcher::fetch() * - * @return ActiveRecordInterface + * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface */ public function getAllObjectsFromRow($row) { @@ -136,7 +141,7 @@ public function getAllObjectsFromRow($row) foreach ($this->getWith() as $modelWith) { [$endObject, $col] = $modelWith->getTableMap()->populateObject($row, $col, $this->getDataFetcher()->getIndexType()); - if (null !== $modelWith->getLeftPhpName() && !isset($hydrationChain[$modelWith->getLeftPhpName()])) { + if ($modelWith->getLeftPhpName() !== null && !isset($hydrationChain[$modelWith->getLeftPhpName()])) { continue; } @@ -150,10 +155,11 @@ public function getAllObjectsFromRow($row) // as we may be in a left join, the endObject may be empty // in which case it should not be related to the previous object - if (null === $endObject || $endObject->isPrimaryKeyNull()) { + if ($endObject === null || $endObject->isPrimaryKeyNull()) { if ($modelWith->isAdd()) { call_user_func([$startObject, $modelWith->getInitMethod()], false); } + continue; } if (isset($hydrationChain)) { diff --git a/src/Propel/Runtime/Formatter/OnDemandFormatter.php b/src/Propel/Runtime/Formatter/OnDemandFormatter.php index b65bceedf3..b1f31634ac 100644 --- a/src/Propel/Runtime/Formatter/OnDemandFormatter.php +++ b/src/Propel/Runtime/Formatter/OnDemandFormatter.php @@ -10,12 +10,10 @@ namespace Propel\Runtime\Formatter; -use Propel\Runtime\ActiveRecord\ActiveRecordInterface; -use Propel\Runtime\Collection\Collection; -use Propel\Runtime\Collection\OnDemandCollection; -use Propel\Runtime\Exception\LogicException; use Propel\Runtime\ActiveQuery\BaseModelCriteria; use Propel\Runtime\DataFetcher\DataFetcherInterface; +use Propel\Runtime\Exception\LogicException; +use ReflectionClass; /** * Object formatter for Propel query @@ -26,6 +24,9 @@ */ class OnDemandFormatter extends ObjectFormatter { + /** + * @var bool + */ protected $isSingleTableInheritance = false; /** @@ -34,7 +35,7 @@ class OnDemandFormatter extends ObjectFormatter * * @return $this */ - public function init(BaseModelCriteria $criteria = null, DataFetcherInterface $dataFetcher = null) + public function init(?BaseModelCriteria $criteria = null, ?DataFetcherInterface $dataFetcher = null) { parent::init($criteria, $dataFetcher); @@ -47,9 +48,10 @@ public function init(BaseModelCriteria $criteria = null, DataFetcherInterface $d * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher * * @throws \Propel\Runtime\Exception\LogicException + * * @return array|\Propel\Runtime\Collection\Collection|\Propel\Runtime\Collection\OnDemandCollection */ - public function format(DataFetcherInterface $dataFetcher = null) + public function format(?DataFetcherInterface $dataFetcher = null) { $this->checkInit(); if ($dataFetcher) { @@ -77,13 +79,13 @@ public function getCollectionClassName() } /** - * @return OnDemandCollection + * @return \Propel\Runtime\Collection\OnDemandCollection */ public function getCollection() { $class = $this->getCollectionClassName(); - /** @var OnDemandCollection $collection */ + /** @var \Propel\Runtime\Collection\OnDemandCollection $collection */ $collection = new $class(); $collection->setModel($this->class); @@ -95,9 +97,9 @@ public function getCollection() * The first object to hydrate is the model of the Criteria * The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one * - * @param array $row associative array with data + * @param array $row associative array with data * - * @return ActiveRecordInterface + * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface */ public function getAllObjectsFromRow($row) { @@ -110,9 +112,10 @@ public function getAllObjectsFromRow($row) foreach ($this->getWith() as $modelWith) { if ($modelWith->isSingleTableInheritance()) { $class = call_user_func([$modelWith->getTableMap(), 'getOMClass'], $row, $col, false); - $refl = new \ReflectionClass($class); + $refl = new ReflectionClass($class); if ($refl->isAbstract()) { $col += constant('Map\\' . $class . 'TableMap::NUM_COLUMNS'); + continue; } } else { @@ -132,6 +135,7 @@ public function getAllObjectsFromRow($row) if ($modelWith->isAdd()) { call_user_func([$startObject, $modelWith->getInitMethod()], false); } + continue; } if (isset($hydrationChain)) { diff --git a/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php b/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php index 6b38ba6313..b2567d7f08 100644 --- a/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php +++ b/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php @@ -27,9 +27,10 @@ class SimpleArrayFormatter extends AbstractFormatter * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher * * @throws \Propel\Runtime\Exception\LogicException + * * @return array|\Propel\Runtime\Collection\Collection */ - public function format(DataFetcherInterface $dataFetcher = null) + public function format(?DataFetcherInterface $dataFetcher = null) { $this->checkInit(); @@ -67,9 +68,10 @@ public function getCollectionClassName() * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher * * @throws \Propel\Runtime\Exception\LogicException + * * @return array|null */ - public function formatOne(DataFetcherInterface $dataFetcher = null) + public function formatOne(?DataFetcherInterface $dataFetcher = null) { $this->checkInit(); $result = null; @@ -97,11 +99,11 @@ public function formatOne(DataFetcherInterface $dataFetcher = null) /** * Formats an ActiveRecord object * - * @param ActiveRecordInterface|null $record the object to format + * @param \Propel\Runtime\ActiveRecord\ActiveRecordInterface|null $record the object to format * * @return array The original record turned into an array */ - public function formatRecord(ActiveRecordInterface $record = null) + public function formatRecord(?ActiveRecordInterface $record = null) { return $record ? $record->toArray() : []; } diff --git a/src/Propel/Runtime/Formatter/StatementFormatter.php b/src/Propel/Runtime/Formatter/StatementFormatter.php index 1f914692de..20ff8f863c 100644 --- a/src/Propel/Runtime/Formatter/StatementFormatter.php +++ b/src/Propel/Runtime/Formatter/StatementFormatter.php @@ -11,8 +11,8 @@ namespace Propel\Runtime\Formatter; use Propel\Runtime\ActiveRecord\ActiveRecordInterface; -use Propel\Runtime\Exception\PropelException; use Propel\Runtime\DataFetcher\DataFetcherInterface; +use Propel\Runtime\Exception\PropelException; /** * statement formatter for Propel query @@ -27,7 +27,7 @@ class StatementFormatter extends AbstractFormatter * * @return \Propel\Runtime\DataFetcher\DataFetcherInterface */ - public function format(DataFetcherInterface $dataFetcher = null) + public function format(?DataFetcherInterface $dataFetcher = null) { if ($dataFetcher) { $this->setDataFetcher($dataFetcher); @@ -43,7 +43,7 @@ public function format(DataFetcherInterface $dataFetcher = null) * * @return \Propel\Runtime\DataFetcher\DataFetcherInterface|null */ - public function formatOne(DataFetcherInterface $dataFetcher = null) + public function formatOne(?DataFetcherInterface $dataFetcher = null) { if ($dataFetcher) { $this->setDataFetcher($dataFetcher); @@ -58,9 +58,10 @@ public function formatOne(DataFetcherInterface $dataFetcher = null) * @param \Propel\Runtime\ActiveRecord\ActiveRecordInterface|null $record * * @throws \Propel\Runtime\Exception\PropelException - * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface|void|null + * + * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface|null|void */ - public function formatRecord(ActiveRecordInterface $record = null) + public function formatRecord(?ActiveRecordInterface $record = null) { throw new PropelException('The Statement formatter cannot transform a record into a statement'); } diff --git a/src/Propel/Runtime/Map/ColumnMap.php b/src/Propel/Runtime/Map/ColumnMap.php index 09fbb91c17..e7a90a6e0f 100644 --- a/src/Propel/Runtime/Map/ColumnMap.php +++ b/src/Propel/Runtime/Map/ColumnMap.php @@ -10,9 +10,9 @@ namespace Propel\Runtime\Map; +use Propel\Generator\Model\PropelTypes; use Propel\Runtime\Adapter\AdapterInterface; use Propel\Runtime\Map\Exception\ForeignKeyNotFoundException; -use Propel\Generator\Model\PropelTypes; /** * ColumnMap is used to model a column of a table in a database. @@ -20,7 +20,7 @@ * GENERAL NOTE * ------------ * The propel.map classes are abstract building-block classes for modeling - * the database at runtime. These classes are similar (a lite version) to the + * the database at runtime. These classes are similar (a lite version) to the * propel.engine.database.model classes, which are build-time modeling classes. * These classes in themselves do not do any database metadata lookups. * @@ -31,55 +31,71 @@ class ColumnMap { /** * Propel type of the column + * + * @var string */ protected $type; /** * Size of the column + * + * @var int */ protected $size = 0; /** * Is it a primary key? * - * @var boolean + * @var bool */ protected $pk = false; /** * Is null value allowed? * - * @var boolean + * @var bool */ protected $notNull = false; /** * The default value for this column + * + * @var mixed */ protected $defaultValue; /** * Name of the table that this column is related to + * + * @var string */ protected $relatedTableName = ''; /** * Name of the column that this column is related to + * + * @var string */ protected $relatedColumnName = ''; /** * The TableMap for this column + * + * @var \Propel\Runtime\Map\TableMap */ protected $table; /** * The name of the column + * + * @var string */ protected $columnName; /** * The php name of the column + * + * @var string */ protected $phpName; @@ -93,7 +109,7 @@ class ColumnMap /** * Is this a primaryString column? * - * @var boolean + * @var bool */ protected $isPkString = false; @@ -151,6 +167,7 @@ public function getFullyQualifiedName() * Set the php name of this column. * * @param string $phpName A string representing the PHP name. + * * @return void */ public function setPhpName($phpName) @@ -172,6 +189,7 @@ public function getPhpName() * Set the Propel type of this column. * * @param string $type A string representing the Propel type (e.g. PropelTypes::DATE). + * * @return void */ public function setType($type) @@ -202,7 +220,7 @@ public function getPdoType() /** * Whether this is a BLOB, LONGVARBINARY, or VARBINARY. * - * @return boolean + * @return bool */ public function isLob() { @@ -216,7 +234,7 @@ public function isLob() /** * Whether this is a DATE/TIME/TIMESTAMP column. * - * @return boolean + * @return bool */ public function isTemporal() { @@ -232,7 +250,7 @@ public function isTemporal() /** * Whether this column is numeric (int, decimal, bigint etc). * - * @return boolean + * @return bool */ public function isNumeric() { @@ -262,7 +280,7 @@ public function isSetType() /** * Whether this column is a text column (varchar, char, longvarchar). * - * @return boolean + * @return bool */ public function isText() { @@ -277,6 +295,7 @@ public function isText() * Set the size of this column. * * @param int $size An int specifying the size. + * * @return void */ public function setSize($size) @@ -297,18 +316,19 @@ public function getSize() /** * Set if this column is a primary key or not. * - * @param boolean $pk True if column is a primary key. + * @param bool $pk True if column is a primary key. + * * @return void */ public function setPrimaryKey($pk) { - $this->pk = (bool) $pk; + $this->pk = (bool)$pk; } /** * Is this column a primary key? * - * @return boolean True if column is a primary key. + * @return bool True if column is a primary key. */ public function isPrimaryKey() { @@ -318,18 +338,19 @@ public function isPrimaryKey() /** * Set if this column may be null. * - * @param boolean $nn True if column may be null. + * @param bool $nn True if column may be null. + * * @return void */ public function setNotNull($nn) { - $this->notNull = (bool) $nn; + $this->notNull = (bool)$nn; } /** * Is null value allowed ? * - * @return boolean True if column may not be null. + * @return bool True if column may not be null. */ public function isNotNull() { @@ -340,6 +361,7 @@ public function isNotNull() * Sets the default value for this column. * * @param mixed $defaultValue the default value for the column + * * @return void */ public function setDefaultValue($defaultValue) @@ -349,6 +371,7 @@ public function setDefaultValue($defaultValue) /** * Gets the default value for this column. + * * @return mixed String or NULL */ public function getDefaultValue() @@ -359,8 +382,9 @@ public function getDefaultValue() /** * Set the foreign key for this column. * - * @param string $tableName The name of the table that is foreign. + * @param string $tableName The name of the table that is foreign. * @param string $columnName The name of the column that is foreign. + * * @return void */ public function setForeignKey($tableName, $columnName) @@ -378,7 +402,7 @@ public function setForeignKey($tableName, $columnName) /** * Is this column a foreign key? * - * @return boolean True if column is a foreign key. + * @return bool True if column is a foreign key. */ public function isForeignKey() { @@ -397,9 +421,11 @@ public function getRelation() } foreach ($this->getTable()->getRelations() as $relation) { - if (RelationMap::MANY_TO_ONE === $relation->getType()) { - if ($relation->getForeignTable()->getName() === $this->getRelatedTableName() - && array_key_exists($this->getFullyQualifiedName(), $relation->getColumnMappings())) { + if ($relation->getType() === RelationMap::MANY_TO_ONE) { + if ( + $relation->getForeignTable()->getName() === $this->getRelatedTableName() + && array_key_exists($this->getFullyQualifiedName(), $relation->getColumnMappings()) + ) { return $relation; } } @@ -441,8 +467,9 @@ public function getRelatedColumnName() /** * Get the TableMap object that this column is related to. * - * @return \Propel\Runtime\Map\TableMap The related TableMap object * @throws \Propel\Runtime\Map\Exception\ForeignKeyNotFoundException when called on a column with no foreign key + * + * @return \Propel\Runtime\Map\TableMap The related TableMap object */ public function getRelatedTable() { @@ -456,8 +483,7 @@ public function getRelatedTable() /** * Get the TableMap object that this column is related to. * - * @return \Propel\Runtime\Map\ColumnMap The related ColumnMap object - * @throws \Propel\Runtime\Map\Exception\ForeignKeyNotFoundException when called on a column with no foreign key + * @return self The related ColumnMap object */ public function getRelatedColumn() { @@ -468,6 +494,7 @@ public function getRelatedColumn() * Set the valueSet of this column (only valid for ENUM and SET columns). * * @param array $values A list of allowed values + * * @return void */ public function setValueSet($values) @@ -498,7 +525,7 @@ public function isInValueSet($value) /** * @param mixed $value * - * @return false|int|string + * @return string|int|false */ public function getValueSetKey($value) { @@ -508,8 +535,9 @@ public function getValueSetKey($value) /** * Performs DB-specific ignore case, but only if the column type necessitates it. * - * @param string $str The expression we want to apply the ignore case formatting to (e.g. the column name). + * @param string $str The expression we want to apply the ignore case formatting to (e.g. the column name). * @param \Propel\Runtime\Adapter\AdapterInterface $db + * * @return string */ public function ignoreCase($str, AdapterInterface $db) @@ -526,14 +554,15 @@ public function ignoreCase($str, AdapterInterface $db) * * article.first_name becomes FIRST_NAME * - * @param string $name + * @param string $name + * * @return string Normalized column name. */ public static function normalizeName($name) { - if (false !== ($pos = strrpos($name, '.'))) { + if (($pos = strrpos($name, '.')) !== false) { $name = substr($name, $pos + 1); - $name = trim($name," \t\n\r\0\x0B`'()\"[]~!-{}%^&."); + $name = trim($name, " \t\n\r\0\x0B`'()\"[]~!-{}%^&."); } return strtoupper($name); @@ -542,18 +571,19 @@ public static function normalizeName($name) /** * Set this column to be a primaryString column. * - * @param boolean $pkString + * @param bool $pkString + * * @return void */ public function setPrimaryString($pkString) { - $this->isPkString = (bool) $pkString; + $this->isPkString = (bool)$pkString; } /** * Is this column a primaryString column? * - * @return boolean True, if this column is the primaryString column. + * @return bool True, if this column is the primaryString column. */ public function isPrimaryString() { diff --git a/src/Propel/Runtime/Map/DatabaseMap.php b/src/Propel/Runtime/Map/DatabaseMap.php index ea7f11f4af..097b5538d0 100644 --- a/src/Propel/Runtime/Map/DatabaseMap.php +++ b/src/Propel/Runtime/Map/DatabaseMap.php @@ -19,7 +19,7 @@ * GENERAL NOTE * ------------ * The propel.map classes are abstract building-block classes for modeling - * the database at runtime. These classes are similar (a lite version) to the + * the database at runtime. These classes are similar (a lite version) to the * propel.engine.database.model classes, which are build-time modeling classes. * These classes in themselves do not do any database metadata lookups. * @@ -39,14 +39,14 @@ class DatabaseMap /** * Tables in the database, using table name as key * - * @var TableMap[] + * @var \Propel\Runtime\Map\TableMap[] */ protected $tables = []; /** * Tables in the database, using table phpName as key * - * @var TableMap[] + * @var \Propel\Runtime\Map\TableMap[] */ protected $tablesByPhpName = []; @@ -71,7 +71,8 @@ public function getName() /** * Add a new table to the database by name. * - * @param string $tableName The name of the table. + * @param string $tableName The name of the table. + * * @return \Propel\Runtime\Map\TableMap The newly created TableMap. */ public function addTable($tableName) @@ -85,6 +86,7 @@ public function addTable($tableName) * Add a new table object to the database. * * @param \Propel\Runtime\Map\TableMap $table The table to add + * * @return void */ public function addTableObject(TableMap $table) @@ -92,7 +94,7 @@ public function addTableObject(TableMap $table) $table->setDatabaseMap($this); $this->tables[$table->getName()] = $table; $phpName = $table->getClassName(); - if ($phpName && '\\' !== $phpName[0]) { + if ($phpName && $phpName[0] !== '\\') { $phpName = '\\' . $phpName; } $this->tablesByPhpName[$phpName] = $table; @@ -101,7 +103,8 @@ public function addTableObject(TableMap $table) /** * Add a new table to the database, using the tablemap class name. * - * @param string $tableMapClass The name of the table map to add + * @param string $tableMapClass The name of the table map to add + * * @return \Propel\Runtime\Map\TableMap The TableMap object */ public function addTableFromMapClass($tableMapClass) @@ -119,8 +122,9 @@ public function addTableFromMapClass($tableMapClass) /** * Does this database contain this specific table? * - * @param string $name The String representation of the table. - * @return boolean True if the database contains the table. + * @param string $name The String representation of the table. + * + * @return bool True if the database contains the table. */ public function hasTable($name) { @@ -134,9 +138,11 @@ public function hasTable($name) /** * Get a TableMap for the table by name. * - * @param string $name Name of the table. - * @return \Propel\Runtime\Map\TableMap A TableMap + * @param string $name Name of the table. + * * @throws \Propel\Runtime\Map\Exception\TableNotFoundException If the table is undefined + * + * @return \Propel\Runtime\Map\TableMap A TableMap */ public function getTable($name) { @@ -150,7 +156,7 @@ public function getTable($name) /** * Get a TableMap[] of all of the tables in the database. * - * @return TableMap[] + * @return \Propel\Runtime\Map\TableMap[] */ public function getTables() { @@ -161,13 +167,13 @@ public function getTables() * Get a ColumnMap for the column by name. * Name must be fully qualified, e.g. book.AUTHOR_ID * - * @param string $qualifiedColumnName Name of the column. + * @param string $qualifiedColumnName Name of the column. + * * @return \Propel\Runtime\Map\ColumnMap A TableMap - * @throws TableNotFoundException If the table is undefined, or if the table is undefined */ public function getColumn($qualifiedColumnName) { - list($tableName, $columnName) = explode('.', $qualifiedColumnName); + [$tableName, $columnName] = explode('.', $qualifiedColumnName); return $this->getTable($tableName)->getColumn($columnName, false); } @@ -175,11 +181,13 @@ public function getColumn($qualifiedColumnName) /** * @param string $phpName * - * @return TableMap + * @throws \Propel\Runtime\Map\Exception\TableNotFoundException + * + * @return \Propel\Runtime\Map\TableMap */ public function getTableByPhpName($phpName) { - if ('\\' !== $phpName[0]) { + if ($phpName[0] !== '\\') { $phpName = '\\' . $phpName; } if (isset($this->tablesByPhpName[$phpName])) { @@ -192,8 +200,10 @@ public function getTableByPhpName($phpName) return $this->tablesByPhpName[$phpName]; } - if (class_exists($tmClass = substr_replace($phpName, '\\Map\\', strrpos($phpName, '\\'), 1) . 'TableMap') - || class_exists($tmClass = '\\Map\\' .$phpName . 'TableMap')) { + if ( + class_exists($tmClass = substr_replace($phpName, '\\Map\\', strrpos($phpName, '\\'), 1) . 'TableMap') + || class_exists($tmClass = '\\Map\\' . $phpName . 'TableMap') + ) { $this->addTableFromMapClass($tmClass); if (isset($this->tablesByPhpName[$phpName])) { @@ -210,6 +220,7 @@ public function getTableByPhpName($phpName) /** * Convenience method to get the AdapterInterface registered with Propel for this database. + * * @see Propel::getServiceContainer()->getAdapter(string) . * * @return \Propel\Runtime\Adapter\AdapterInterface diff --git a/src/Propel/Runtime/Map/RelationMap.php b/src/Propel/Runtime/Map/RelationMap.php index 9d977ea2fb..b488ea5ad6 100644 --- a/src/Propel/Runtime/Map/RelationMap.php +++ b/src/Propel/Runtime/Map/RelationMap.php @@ -10,16 +10,13 @@ namespace Propel\Runtime\Map; -use Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion; -use Propel\Runtime\ActiveQuery\ModelCriteria; - /** * RelationMap is used to model a database relationship. * * GENERAL NOTE * ------------ * The propel.map classes are abstract building-block classes for modeling - * the database at runtime. These classes are similar (a lite version) to the + * the database at runtime. These classes are similar (a lite version) to the * propel.engine.database.model classes, which are build-time modeling classes. * These classes in themselves do not do any database metadata lookups. * @@ -28,18 +25,18 @@ class RelationMap { // types - const MANY_TO_ONE = 1; + public const MANY_TO_ONE = 1; - const ONE_TO_MANY = 2; + public const ONE_TO_MANY = 2; - const ONE_TO_ONE = 3; + public const ONE_TO_ONE = 3; - const MANY_TO_MANY = 4; + public const MANY_TO_MANY = 4; // representations - const LOCAL_TO_FOREIGN = 0; + public const LOCAL_TO_FOREIGN = 0; - const LEFT_TO_RIGHT = 1; + public const LEFT_TO_RIGHT = 1; protected $name; @@ -54,7 +51,7 @@ class RelationMap protected $polymorphic = false; /** - * @var ColumnMap[] + * @var \Propel\Runtime\Map\ColumnMap[] */ protected $localColumns = []; @@ -83,7 +80,7 @@ public function __construct($name) } /** - * @return boolean + * @return bool */ public function isPolymorphic() { @@ -91,7 +88,8 @@ public function isPolymorphic() } /** - * @param boolean $polymorphic + * @param bool $polymorphic + * * @return void */ public function setPolymorphic($polymorphic) @@ -126,13 +124,14 @@ public function setPluralName($pluralName) */ public function getPluralName() { - return null !== $this->pluralName ? $this->pluralName : ($this->name . 's'); + return $this->pluralName !== null ? $this->pluralName : ($this->name . 's'); } /** * Set the type * * @param int $type The relation type (either self::MANY_TO_ONE, self::ONE_TO_MANY, or self::ONE_TO_ONE) + * * @return void */ public function setType($type) @@ -154,6 +153,7 @@ public function getType() * Set the local table * * @param \Propel\Runtime\Map\TableMap $table The local table for this relationship + * * @return void */ public function setLocalTable(TableMap $table) @@ -175,6 +175,7 @@ public function getLocalTable() * Set the foreign table * * @param \Propel\Runtime\Map\TableMap $table The foreign table for this relationship + * * @return void */ public function setForeignTable($table) @@ -199,7 +200,7 @@ public function getForeignTable() */ public function getLeftTable() { - return RelationMap::MANY_TO_ONE === $this->getType() ? $this->getLocalTable() : $this->getForeignTable(); + return $this->getType() === RelationMap::MANY_TO_ONE ? $this->getLocalTable() : $this->getForeignTable(); } /** @@ -209,14 +210,15 @@ public function getLeftTable() */ public function getRightTable() { - return RelationMap::MANY_TO_ONE === $this->getType() ? $this->getForeignTable() : $this->getLocalTable(); + return $this->getType() === RelationMap::MANY_TO_ONE ? $this->getForeignTable() : $this->getLocalTable(); } /** * Add a column mapping * - * @param ColumnMap $local The local column - * @param ColumnMap|mixed $foreign The foreign column or value + * @param \Propel\Runtime\Map\ColumnMap $local The local column + * @param \Propel\Runtime\Map\ColumnMap|mixed $foreign The foreign column or value + * * @return void */ public function addColumnMapping(ColumnMap $local, $foreign) @@ -238,19 +240,22 @@ public function addColumnMapping(ColumnMap $local, $foreign) * - If the value is RelationMap::LOCAL_TO_FOREIGN, then the returned array is local => foreign * - If the value is RelationMap::LEFT_TO_RIGHT, then the returned array is left => right * - * @param int $direction How the associative array must return columns + * @param int $direction How the associative array must return columns + * * @return array Associative array (local => foreign) of fully qualified column names */ public function getColumnMappings($direction = RelationMap::LOCAL_TO_FOREIGN) { $h = []; - if (RelationMap::LEFT_TO_RIGHT === $direction - && RelationMap::MANY_TO_ONE === $this->getType()) { + if ( + $direction === RelationMap::LEFT_TO_RIGHT + && $this->getType() === RelationMap::MANY_TO_ONE + ) { $direction = RelationMap::LOCAL_TO_FOREIGN; } for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) { - if (RelationMap::LOCAL_TO_FOREIGN === $direction) { + if ($direction === RelationMap::LOCAL_TO_FOREIGN) { $h[$this->localColumns[$i]->getFullyQualifiedName()] = $this->foreignColumns[$i]->getFullyQualifiedName(); } else { $h[$this->foreignColumns[$i]->getFullyQualifiedName()] = $this->localColumns[$i]->getFullyQualifiedName(); @@ -263,7 +268,7 @@ public function getColumnMappings($direction = RelationMap::LOCAL_TO_FOREIGN) /** * Returns true if the relation has more than one column mapping * - * @return boolean + * @return bool */ public function isComposite() { @@ -283,7 +288,7 @@ public function countColumnMappings() /** * Get the local columns * - * @return ColumnMap[] + * @return \Propel\Runtime\Map\ColumnMap[] */ public function getLocalColumns() { @@ -293,7 +298,7 @@ public function getLocalColumns() /** * Get the foreign columns * - * @return ColumnMap[] + * @return \Propel\Runtime\Map\ColumnMap[] */ public function getForeignColumns() { @@ -303,21 +308,21 @@ public function getForeignColumns() /** * Get the left columns of the relation * - * @return ColumnMap[] + * @return \Propel\Runtime\Map\ColumnMap[] */ public function getLeftColumns() { - return RelationMap::MANY_TO_ONE === $this->getType() ? $this->getLocalColumns() : $this->getForeignColumns(); + return $this->getType() === RelationMap::MANY_TO_ONE ? $this->getLocalColumns() : $this->getForeignColumns(); } /** * Get the right columns of the relation * - * @return ColumnMap[] + * @return \Propel\Runtime\Map\ColumnMap[] */ public function getRightColumns() { - return RelationMap::MANY_TO_ONE === $this->getType() ? $this->getForeignColumns() : $this->getLocalColumns(); + return $this->getType() === RelationMap::MANY_TO_ONE ? $this->getForeignColumns() : $this->getLocalColumns(); } /** @@ -332,6 +337,7 @@ public function getLocalValues() * Set the onUpdate behavior * * @param string $onUpdate + * * @return void */ public function setOnUpdate($onUpdate) @@ -342,7 +348,7 @@ public function setOnUpdate($onUpdate) /** * Get the onUpdate behavior * - * @return integer the relation type + * @return int the relation type */ public function getOnUpdate() { @@ -353,6 +359,7 @@ public function getOnUpdate() * Set the onDelete behavior * * @param string $onDelete + * * @return void */ public function setOnDelete($onDelete) diff --git a/src/Propel/Runtime/Map/TableMap.php b/src/Propel/Runtime/Map/TableMap.php index 25ef8020bb..1f19d6131e 100644 --- a/src/Propel/Runtime/Map/TableMap.php +++ b/src/Propel/Runtime/Map/TableMap.php @@ -10,10 +10,10 @@ namespace Propel\Runtime\Map; +use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Map\Exception\ColumnNotFoundException; use Propel\Runtime\Map\Exception\RelationNotFoundException; use Propel\Runtime\Propel; -use Propel\Runtime\ActiveQuery\Criteria; /** * TableMap is used to model a table in a database. @@ -29,50 +29,50 @@ class TableMap * phpname type * e.g. 'AuthorId' */ - const TYPE_PHPNAME = 'phpName'; + public const TYPE_PHPNAME = 'phpName'; /** * camelCase type * e.g. 'authorId' */ - const TYPE_CAMELNAME = 'camelName'; + public const TYPE_CAMELNAME = 'camelName'; /** * column (tableMap) name type * e.g. 'book.AUTHOR_ID' */ - const TYPE_COLNAME = 'colName'; + public const TYPE_COLNAME = 'colName'; /** * column fieldname type * e.g. 'author_id' */ - const TYPE_FIELDNAME = 'fieldName'; + public const TYPE_FIELDNAME = 'fieldName'; /** * num type * simply the numerical array index, e.g. 4 */ - const TYPE_NUM = 'num'; + public const TYPE_NUM = 'num'; /** * Columns in the table * - * @var ColumnMap[] + * @var \Propel\Runtime\Map\ColumnMap[] */ protected $columns = []; /** * Columns in the table, using table phpName as key * - * @var ColumnMap[] + * @var \Propel\Runtime\Map\ColumnMap[] */ protected $columnsByPhpName = []; /** * The database this table belongs to * - * @var DatabaseMap + * @var \Propel\Runtime\Map\DatabaseMap */ protected $dbMap; @@ -107,49 +107,49 @@ class TableMap /** * Whether to use an id generator for pkey * - * @var boolean + * @var bool */ protected $useIdGenerator = false; /** * Whether the table uses single table inheritance * - * @var boolean + * @var bool */ protected $isSingleTableInheritance = false; /** * Whether the table is a Many to Many table * - * @var boolean + * @var bool */ protected $isCrossRef = false; /** * The primary key columns in the table * - * @var ColumnMap[] + * @var \Propel\Runtime\Map\ColumnMap[] */ protected $primaryKeys = []; /** * The foreign key columns in the table * - * @var ColumnMap[] + * @var \Propel\Runtime\Map\ColumnMap[] */ protected $foreignKeys = []; /** * The relationships in the table * - * @var RelationMap[] + * @var \Propel\Runtime\Map\RelationMap[] */ protected $relations = []; /** * Relations are lazy loaded. This property tells if the relations are loaded or not * - * @var boolean + * @var bool */ protected $relationsBuilt = false; @@ -161,7 +161,7 @@ class TableMap protected $pkInfo; /** - * @var boolean + * @var bool */ protected $identifierQuoting = false; @@ -173,10 +173,10 @@ class TableMap */ public function __construct($name = null, $dbMap = null) { - if (null !== $name) { + if ($name !== null) { $this->setName($name); } - if (null !== $dbMap) { + if ($dbMap !== null) { $this->setDatabaseMap($dbMap); } $this->initialize(); @@ -195,7 +195,8 @@ public function initialize() /** * Set the DatabaseMap containing this TableMap. * - * @param DatabaseMap $dbMap A DatabaseMap. + * @param \Propel\Runtime\Map\DatabaseMap $dbMap A DatabaseMap. + * * @return void */ public function setDatabaseMap(DatabaseMap $dbMap) @@ -206,7 +207,7 @@ public function setDatabaseMap(DatabaseMap $dbMap) /** * Get the DatabaseMap containing this TableMap. * - * @return DatabaseMap A DatabaseMap. + * @return \Propel\Runtime\Map\DatabaseMap A DatabaseMap. */ public function getDatabaseMap() { @@ -217,6 +218,7 @@ public function getDatabaseMap() * Set the name of the Table. * * @param string $name The name of the table. + * * @return void */ public function setName($name) @@ -238,6 +240,7 @@ public function getName() * Set the PHP name of the Table. * * @param string $phpName The PHP Name for this table + * * @return void */ public function setPhpName($phpName) @@ -260,6 +263,7 @@ public function getPhpName() * tableMap and Object methods dynamically. * * @param string $classname The ClassName + * * @return void */ public function setClassName($classname) @@ -284,7 +288,7 @@ public function getClassName() */ public function getCollectionClassName() { - $collectionClass = $this->getClassName().'Collection'; + $collectionClass = $this->getClassName() . 'Collection'; if (class_exists($collectionClass)) { return $collectionClass; } @@ -296,6 +300,7 @@ public function getCollectionClassName() * Set the Package of the Table * * @param string $package The Package + * * @return void */ public function setPackage($package) @@ -316,7 +321,8 @@ public function getPackage() /** * Set whether or not to use Id generator for primary key. * - * @param boolean $bit + * @param bool $bit + * * @return void */ public function setUseIdGenerator($bit) @@ -327,7 +333,7 @@ public function setUseIdGenerator($bit) /** * Whether to use Id generator for primary key. * - * @return boolean + * @return bool */ public function isUseIdGenerator() { @@ -337,7 +343,8 @@ public function isUseIdGenerator() /** * Set whether or not to this table uses single table inheritance * - * @param boolean $bit + * @param bool $bit + * * @return void */ public function setSingleTableInheritance($bit) @@ -348,7 +355,7 @@ public function setSingleTableInheritance($bit) /** * Whether this table uses single table inheritance * - * @return boolean + * @return bool */ public function isSingleTableInheritance() { @@ -359,6 +366,7 @@ public function isSingleTableInheritance() * Sets the name of the sequence used to generate a key * * @param mixed $pkInfo information needed to generate a key + * * @return void */ public function setPrimaryKeyMethodInfo($pkInfo) @@ -380,10 +388,9 @@ public function getPrimaryKeyMethodInfo() * Helper method which returns the primary key contained * in the given Criteria object. * - * @param Criteria $criteria A Criteria. - * @return ColumnMap If the Criteria object contains a primary key, or null if it doesn't. + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria A Criteria. * - * @throws \Propel\Runtime\Exception\RuntimeException + * @return \Propel\Runtime\Map\ColumnMap If the Criteria object contains a primary key, or null if it doesn't. */ private static function getPrimaryKey(Criteria $criteria) { @@ -409,15 +416,16 @@ private static function getPrimaryKey(Criteria $criteria) /** * Add a column to the table. * - * @param string $name A String with the column name. - * @param string $phpName A string representing the PHP name. - * @param string $type A string specifying the Propel type. - * @param boolean $isNotNull Whether column does not allow NULL values. - * @param int $size An int specifying the size. - * @param boolean $pk True if column is a primary key. - * @param string $fkTable A String with the foreign key table name. - * @param string $fkColumn A String with the foreign key column name. - * @param string $defaultValue The default value for this column. + * @param string $name A String with the column name. + * @param string $phpName A string representing the PHP name. + * @param string $type A string specifying the Propel type. + * @param bool $isNotNull Whether column does not allow NULL values. + * @param int|null $size An int specifying the size. + * @param bool|null $pk True if column is a primary key. + * @param string|bool $fkTable A String with the foreign key table name. + * @param string|null $fkColumn A String with the foreign key column name. + * @param string|null $defaultValue The default value for this column. + * * @return \Propel\Runtime\Map\ColumnMap The newly created column. */ public function addColumn($name, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null, $pk = false, $fkTable = null, $fkColumn = null) @@ -449,7 +457,8 @@ public function addColumn($name, $phpName, $type, $isNotNull = false, $size = nu * Add a pre-created column to this table. It will replace any * existing column. * - * @param \Propel\Runtime\Map\ColumnMap $cmap A ColumnMap. + * @param \Propel\Runtime\Map\ColumnMap $cmap A ColumnMap. + * * @return \Propel\Runtime\Map\ColumnMap The added column map. */ public function addConfiguredColumn(ColumnMap $cmap) @@ -462,9 +471,10 @@ public function addConfiguredColumn(ColumnMap $cmap) /** * Does this table contain the specified column? * - * @param mixed $name name of the column or ColumnMap instance - * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME) - * @return boolean True if the table contains the column. + * @param mixed $name name of the column or ColumnMap instance + * @param bool $normalize Normalize the column name (if column name not like FIRST_NAME) + * + * @return bool True if the table contains the column. */ public function hasColumn($name, $normalize = true) { @@ -480,10 +490,12 @@ public function hasColumn($name, $normalize = true) /** * Get a ColumnMap for the table. * - * @param string $name A String with the name of the table. - * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME) - * @return \Propel\Runtime\Map\ColumnMap A ColumnMap. + * @param string $name A String with the name of the table. + * @param bool $normalize Normalize the column name (if column name not like FIRST_NAME) + * * @throws \Propel\Runtime\Map\Exception\ColumnNotFoundException If the column is undefined + * + * @return \Propel\Runtime\Map\ColumnMap A ColumnMap. */ public function getColumn($name, $normalize = true) { @@ -500,8 +512,9 @@ public function getColumn($name, $normalize = true) /** * Does this table contain the specified column? * - * @param mixed $phpName name of the column - * @return boolean True if the table contains the column. + * @param mixed $phpName name of the column + * + * @return bool True if the table contains the column. */ public function hasColumnByPhpName($phpName) { @@ -511,9 +524,11 @@ public function hasColumnByPhpName($phpName) /** * Get a ColumnMap for the table. * - * @param string $phpName A String with the name of the table. - * @return \Propel\Runtime\Map\ColumnMap A ColumnMap. + * @param string $phpName A String with the name of the table. + * * @throws \Propel\Runtime\Map\Exception\ColumnNotFoundException If the column is undefined + * + * @return \Propel\Runtime\Map\ColumnMap A ColumnMap. */ public function getColumnByPhpName($phpName) { @@ -527,7 +542,7 @@ public function getColumnByPhpName($phpName) /** * Get a ColumnMap[] of the columns in this table. * - * @return ColumnMap[] + * @return \Propel\Runtime\Map\ColumnMap[] */ public function getColumns() { @@ -537,12 +552,13 @@ public function getColumns() /** * Add a primary key column to this Table. * - * @param string $columnName A String with the column name. - * @param string $phpName A string representing the PHP name. - * @param string $type A string specifying the Propel type. - * @param boolean $isNotNull Whether column does not allow NULL values. - * @param int $size An int specifying the size. - * @param string $defaultValue The default value for this column. + * @param string $columnName A String with the column name. + * @param string $phpName A string representing the PHP name. + * @param string $type A string specifying the Propel type. + * @param bool $isNotNull Whether column does not allow NULL values. + * @param int|null $size An int specifying the size. + * @param string|null $defaultValue The default value for this column. + * * @return \Propel\Runtime\Map\ColumnMap Newly added PrimaryKey column. */ public function addPrimaryKey($columnName, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null) @@ -553,14 +569,15 @@ public function addPrimaryKey($columnName, $phpName, $type, $isNotNull = false, /** * Add a foreign key column to the table. * - * @param string $columnName A String with the column name. - * @param string $phpName A string representing the PHP name. - * @param string $type A string specifying the Propel type. - * @param string $fkTable A String with the foreign key table name. - * @param string $fkColumn A String with the foreign key column name. - * @param boolean $isNotNull Whether column does not allow NULL values. - * @param int $size An int specifying the size. - * @param string $defaultValue The default value for this column. + * @param string $columnName A String with the column name. + * @param string $phpName A string representing the PHP name. + * @param string $type A string specifying the Propel type. + * @param string $fkTable A String with the foreign key table name. + * @param string $fkColumn A String with the foreign key column name. + * @param bool $isNotNull Whether column does not allow NULL values. + * @param int $size An int specifying the size. + * @param string|null $defaultValue The default value for this column. + * * @return \Propel\Runtime\Map\ColumnMap Newly added ForeignKey column. */ public function addForeignKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size = 0, $defaultValue = null) @@ -571,14 +588,15 @@ public function addForeignKey($columnName, $phpName, $type, $fkTable, $fkColumn, /** * Add a foreign primary key column to the table. * - * @param string $columnName A String with the column name. - * @param string $phpName A string representing the PHP name. - * @param string $type A string specifying the Propel type. - * @param string $fkTable A String with the foreign key table name. - * @param string $fkColumn A String with the foreign key column name. - * @param boolean $isNotNull Whether column does not allow NULL values. - * @param int $size An int specifying the size. - * @param string $defaultValue The default value for this column. + * @param string $columnName A String with the column name. + * @param string $phpName A string representing the PHP name. + * @param string $type A string specifying the Propel type. + * @param string $fkTable A String with the foreign key table name. + * @param string $fkColumn A String with the foreign key column name. + * @param bool $isNotNull Whether column does not allow NULL values. + * @param int $size An int specifying the size. + * @param string|null $defaultValue The default value for this column. + * * @return \Propel\Runtime\Map\ColumnMap Newly created foreign pkey column. */ public function addForeignPrimaryKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size = 0, $defaultValue = null) @@ -587,7 +605,7 @@ public function addForeignPrimaryKey($columnName, $phpName, $type, $fkTable, $fk } /** - * @return boolean true if the table is a many to many + * @return bool true if the table is a many to many */ public function isCrossRef() { @@ -597,7 +615,8 @@ public function isCrossRef() /** * Set the isCrossRef - * @param boolean $isCrossRef + * @param bool $isCrossRef + * * @return void */ public function setIsCrossRef($isCrossRef) @@ -608,7 +627,7 @@ public function setIsCrossRef($isCrossRef) /** * Returns array of ColumnMap objects that make up the primary key for this table * - * @return ColumnMap[] + * @return \Propel\Runtime\Map\ColumnMap[] */ public function getPrimaryKeys() { @@ -618,7 +637,7 @@ public function getPrimaryKeys() /** * Returns array of ColumnMap objects that are foreign keys for this table * - * @return ColumnMap[] + * @return \Propel\Runtime\Map\ColumnMap[] */ public function getForeignKeys() { @@ -629,6 +648,7 @@ public function getForeignKeys() * Build relations * Relations are lazy loaded for performance reasons * This method should be overridden by descendants + * * @return void */ public function buildRelations() @@ -638,19 +658,27 @@ public function buildRelations() /** * Adds a RelationMap to the table * - * @param string $name The relation name - * @param string $tablePhpName The related table name - * @param integer $type The relation type (either RelationMap::MANY_TO_ONE, RelationMap::ONE_TO_MANY, or RelationMAp::ONE_TO_ONE) - * @param array $joinConditionMapping Arrays in array defining a normalize join condition [[':foreign_id', ':id', '='], [':foreign_type', 'value', '=']] - * @param string $onDelete SQL behavior upon deletion ('SET NULL', 'CASCADE', ...) - * @param string $onUpdate SQL behavior upon update ('SET NULL', 'CASCADE', ...) - * @param string $pluralName Optional plural name for *_TO_MANY relationships - * @param boolean $polymorphic Optional plural name for *_TO_MANY relationships - * - * @return RelationMap the built RelationMap object - */ - public function addRelation($name, $tablePhpName, $type, $joinConditionMapping = [], $onDelete = null, $onUpdate = null, $pluralName = null, $polymorphic = false) - { + * @param string $name The relation name + * @param string $tablePhpName The related table name + * @param int $type The relation type (either RelationMap::MANY_TO_ONE, RelationMap::ONE_TO_MANY, or RelationMAp::ONE_TO_ONE) + * @param array $joinConditionMapping Arrays in array defining a normalize join condition [[':foreign_id', ':id', '='], [':foreign_type', 'value', '=']] + * @param string|null $onDelete SQL behavior upon deletion ('SET NULL', 'CASCADE', ...) + * @param string|null $onUpdate SQL behavior upon update ('SET NULL', 'CASCADE', ...) + * @param string|null $pluralName Optional plural name for *_TO_MANY relationships + * @param bool $polymorphic Optional plural name for *_TO_MANY relationships + * + * @return \Propel\Runtime\Map\RelationMap the built RelationMap object + */ + public function addRelation( + $name, + $tablePhpName, + $type, + $joinConditionMapping = [], + $onDelete = null, + $onUpdate = null, + $pluralName = null, + $polymorphic = false + ) { // note: using phpName for the second table allows the use of DatabaseMap::getTableByPhpName() // and this method autoloads the TableMap if the table isn't loaded yet $relation = new RelationMap($name); @@ -659,11 +687,11 @@ public function addRelation($name, $tablePhpName, $type, $joinConditionMapping = $relation->setOnDelete($onDelete); $relation->setPolymorphic($polymorphic); - if (null !== $pluralName) { + if ($pluralName !== null) { $relation->setPluralName($pluralName); } // set tables - if (RelationMap::MANY_TO_ONE === $type) { + if ($type === RelationMap::MANY_TO_ONE) { $relation->setLocalTable($this); $relation->setForeignTable($this->dbMap->getTableByPhpName($tablePhpName)); } else { @@ -684,14 +712,14 @@ public function addRelation($name, $tablePhpName, $type, $joinConditionMapping = } /** - * @param string $value values with starting ':' mean a column name, otherwise a regular value. - * @param TableMap $table + * @param string $value values with starting ':' mean a column name, otherwise a regular value. + * @param \Propel\Runtime\Map\TableMap $table * - * @return ColumnMap|mixed + * @return \Propel\Runtime\Map\ColumnMap|mixed */ protected function getColumnOrValue($value, TableMap $table) { - if (':' === substr($value, 0, 1)) { + if (substr($value, 0, 1) === ':') { return $table->getColumn(substr($value, 1)); } else { return $value; @@ -702,8 +730,9 @@ protected function getColumnOrValue($value, TableMap $table) * Gets a RelationMap of the table by relation name * This method will build the relations if they are not built yet * - * @param string $name The relation name - * @return boolean true if the relation exists + * @param string $name The relation name + * + * @return bool true if the relation exists */ public function hasRelation($name) { @@ -714,9 +743,11 @@ public function hasRelation($name) * Gets a RelationMap of the table by relation name * This method will build the relations if they are not built yet * - * @param string $name The relation name - * @return \Propel\Runtime\Map\RelationMap The relation object + * @param string $name The relation name + * * @throws \Propel\Runtime\Map\Exception\RelationNotFoundException When called on an inexistent relation + * + * @return \Propel\Runtime\Map\RelationMap The relation object */ public function getRelation($name) { @@ -731,7 +762,7 @@ public function getRelation($name) * Gets the RelationMap objects of the table * This method will build the relations if they are not built yet * - * @return RelationMap[] list of RelationMap objects + * @return \Propel\Runtime\Map\RelationMap[] list of RelationMap objects */ public function getRelations() { @@ -744,7 +775,6 @@ public function getRelations() } /** - * * Gets the list of behaviors registered for this table * * @return array @@ -757,11 +787,11 @@ public function getBehaviors() /** * Does this table has a primaryString column? * - * @return boolean True if the table has a primaryString column. + * @return bool True if the table has a primaryString column. */ public function hasPrimaryStringColumn() { - return null !== $this->getPrimaryStringColumn(); + return $this->getPrimaryStringColumn() !== null; } /** @@ -782,21 +812,21 @@ public function getPrimaryStringColumn() public static function getFieldnamesForClass($classname, $type = TableMap::TYPE_PHPNAME) { - $callable = [$classname::TABLE_MAP, 'getFieldnames']; + $callable = [$classname::TABLE_MAP, 'getFieldnames']; return call_user_func($callable, $type); } public static function translateFieldnameForClass($classname, $fieldname, $fromType, $toType) { - $callable = [$classname::TABLE_MAP, 'translateFieldname']; - $args = [$fieldname, $fromType, $toType]; + $callable = [$classname::TABLE_MAP, 'translateFieldname']; + $args = [$fieldname, $fromType, $toType]; return call_user_func_array($callable, $args); } /** - * @return boolean + * @return bool */ public function isIdentifierQuotingEnabled() { @@ -804,7 +834,8 @@ public function isIdentifierQuotingEnabled() } /** - * @param boolean $identifierQuoting + * @param bool $identifierQuoting + * * @return void */ public function setIdentifierQuoting($identifierQuoting) @@ -829,7 +860,7 @@ public function extractPrimaryKey(Criteria $criteria) if ($criteria->containsKey($fqName)) { $value = $criteria->getValue($fqName); - } else if ($criteria->containsKey($name)) { + } elseif ($criteria->containsKey($name)) { $value = $criteria->getValue($name); } else { return null; @@ -840,5 +871,4 @@ public function extractPrimaryKey(Criteria $criteria) return $pk; } - } diff --git a/src/Propel/Runtime/Map/TableMapTrait.php b/src/Propel/Runtime/Map/TableMapTrait.php index eb9a8c6358..eecddc8d97 100644 --- a/src/Propel/Runtime/Map/TableMapTrait.php +++ b/src/Propel/Runtime/Map/TableMapTrait.php @@ -17,11 +17,13 @@ trait TableMapTrait /** * Returns an array of field names. * - * @param string $type The type of fieldnames to return: + * @param string $type The type of fieldnames to return: * One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - * @return array A list of field names - * @throws PropelException + * + * @throws \Propel\Runtime\Exception\PropelException + * + * @return array A list of field names */ public static function getFieldNames($type = TableMap::TYPE_PHPNAME) { @@ -35,18 +37,20 @@ public static function getFieldNames($type = TableMap::TYPE_PHPNAME) /** * Translates a fieldname to another type * - * @param string $name field name - * @param string $fromType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME + * @param string $name field name + * @param string $fromType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. + * @param string $toType One of the class type constants + * + * @throws \Propel\Runtime\Exception\PropelException - if the specified name could not be found in the fieldname mappings. + * + * @return string translated name of the field. */ public static function translateFieldName($name, $fromType, $toType) { $toNames = static::getFieldNames($toType); $key = isset(static::$fieldKeys[$fromType][$name]) ? static::$fieldKeys[$fromType][$name] : null; - if (null === $key) { + if ($key === null) { throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(static::$fieldKeys[$fromType], true)); } @@ -76,12 +80,14 @@ public static function translateFieldNames($row, $fromType, $toType) * $c->addAlias("alias1", TableTableMap::TABLE_NAME); * $c->addJoin(TableTableMap::alias("alias1", TableTableMap::PRIMARY_KEY_COLUMN), TableTableMap::PRIMARY_KEY_COLUMN); * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. BookTableMap::COLUMN_NAME). + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. BookTableMap::COLUMN_NAME). + * * @return string */ public static function alias($alias, $column) { - return str_replace(static::TABLE_NAME.'.', $alias.'.', $column); + return str_replace(static::TABLE_NAME . '.', $alias . '.', $column); } } diff --git a/src/Propel/Runtime/Parser/AbstractParser.php b/src/Propel/Runtime/Parser/AbstractParser.php index c85f00fa33..4bf6ca6125 100644 --- a/src/Propel/Runtime/Parser/AbstractParser.php +++ b/src/Propel/Runtime/Parser/AbstractParser.php @@ -10,8 +10,6 @@ namespace Propel\Runtime\Parser; -use Propel\Common\Pluralizer\PluralizerInterface; -use Propel\Common\Pluralizer\StandardEnglishPluralizer; use Propel\Runtime\Exception\FileNotFoundException; /** @@ -27,8 +25,9 @@ abstract class AbstractParser * * Override in the parser driver. * - * @param array $array Source data to convert + * @param array $array Source data to convert * @param string $rootKey The parser might use this for naming the root key of the parser format + * * @return mixed Converted data, depending on the parser format */ abstract public function fromArray($array, $rootKey = 'data'); @@ -38,8 +37,9 @@ abstract public function fromArray($array, $rootKey = 'data'); * * Override in the parser driver. * - * @param mixed $data Source data to convert, depending on the parser format + * @param mixed $data Source data to convert, depending on the parser format * @param string $rootKey The parser might use this name for converting from parser format + * * @return array Converted data */ abstract public function toArray($data, $rootKey = 'data'); @@ -71,6 +71,8 @@ public function listToArray($data, $rootKey = 'data') * * @param string $path Path to the file to load * + * @throws \Propel\Runtime\Exception\FileNotFoundException + * * @return string The file content processed by PHP */ public function load($path) @@ -90,12 +92,13 @@ public function load($path) * Dumps data to a file, or to STDOUT if no filename is given * * @param string $data The file content - * @param string $path Path of the file to create + * @param string|null $path Path of the file to create + * * @return mixed|null|void */ public function dump($data, $path = null) { - if (null !== $path) { + if ($path !== null) { return file_put_contents($path, $data); } @@ -107,7 +110,9 @@ public function dump($data, $path = null) * * @param string $type Parser type, amon 'XML', 'YAML', 'JSON', and 'CSV' * - * @return AbstractParser A PropelParser subclass instance + * @throws \Propel\Runtime\Exception\FileNotFoundException + * + * @return \Propel\Runtime\Parser\AbstractParser A PropelParser subclass instance */ public static function getParser($type = 'XML') { @@ -117,6 +122,6 @@ public static function getParser($type = 'XML') throw new FileNotFoundException(sprintf('Unknown parser class "%s"', $class)); } - return new $class; + return new $class(); } } diff --git a/src/Propel/Runtime/Parser/CsvParser.php b/src/Propel/Runtime/Parser/CsvParser.php index 13eedf8e38..80207a47da 100644 --- a/src/Propel/Runtime/Parser/CsvParser.php +++ b/src/Propel/Runtime/Parser/CsvParser.php @@ -19,17 +19,21 @@ */ class CsvParser extends AbstractParser { - const QUOTE_NONE = 0; - const QUOTE_ALL = 1; - const QUOTE_NONNUMERIC = 2; - const QUOTE_MINIMAL = 3; + public const QUOTE_NONE = 0; + public const QUOTE_ALL = 1; + public const QUOTE_NONNUMERIC = 2; + public const QUOTE_MINIMAL = 3; // these settings are predefined for Excel CSV format public $delimiter = ','; + public $lineTerminator = "\r\n"; + public $quotechar = '"'; - public $escapechar = "\\"; + + public $escapechar = '\\'; + public $quoting = self::QUOTE_MINIMAL; /** @@ -37,8 +41,8 @@ class CsvParser extends AbstractParser * * @param array $array Source data to convert * @param string|null $rootKey Will not be used for converting because csv is flat - * @param boolean $isList Whether the input data contains more than one row - * @param boolean $includeHeading Whether the output should contain a heading line + * @param bool $isList Whether the input data contains more than one row + * @param bool $includeHeading Whether the output should contain a heading line * * @return string Converted data, as a CSV string */ @@ -76,7 +80,8 @@ public function listFromArray($array, $rootKey = null) /** * Accepts a row of data and returns it formatted * - * @param array $row An array of data to be formatted for output to the file + * @param array $row An array of data to be formatted for output to the file + * * @return array The formatted array */ protected function formatRow($row) @@ -91,17 +96,20 @@ protected function formatRow($row) break; case self::QUOTE_ALL: $column = $this->quote($this->escape($column)); + break; case self::QUOTE_NONNUMERIC: if (preg_match('/[^0-9]/', $column)) { $column = $this->quote($this->escape($column)); } + break; case self::QUOTE_MINIMAL: default: if ($this->containsSpecialChars($column)) { $column = $this->quote($this->escape($column)); } + break; } } @@ -112,8 +120,9 @@ protected function formatRow($row) /** * Escapes a column (escapes quotechar with escapechar) * - * @param string $input A single value to be escaped for output - * @return string Escaped input value + * @param string $input A single value to be escaped for output + * + * @return string Escaped input value */ protected function escape($input) { @@ -127,7 +136,8 @@ protected function escape($input) /** * Quotes a column with quotechar * - * @param string $input A single value to be quoted for output + * @param string $input A single value to be quoted for output + * * @return string Quoted input value */ protected function quote($input) @@ -138,8 +148,9 @@ protected function quote($input) /** * Returns true if input contains quotechar, delimiter or any of the characters in lineTerminator * - * @param string $input A single value to be checked for special characters - * @return boolean True if contains any special characters + * @param string $input A single value to be checked for special characters + * + * @return bool True if contains any special characters */ protected function containsSpecialChars($input) { @@ -147,7 +158,7 @@ protected function containsSpecialChars($input) $special_chars[] = $this->quotechar; $special_chars[] = $this->delimiter; foreach ($special_chars as $char) { - if (false !== strpos($input, $char)) { + if (strpos($input, $char) !== false) { return true; } } @@ -158,7 +169,8 @@ protected function containsSpecialChars($input) /** * Serializes a value to place it into a CSV output * - * @param mixed $input + * @param mixed $input + * * @return string */ protected function serialize($input) @@ -169,9 +181,9 @@ protected function serialize($input) /** * Alias for CsvParser::fromArray() * - * @param array $array Source data to convert - * @param boolean $isList Whether the input data contains more than one row - * @param boolean $includeHeading Whether the output should contain a heading line + * @param array $array Source data to convert + * @param bool $isList Whether the input data contains more than one row + * @param bool $includeHeading Whether the output should contain a heading line * * @return string Converted data, as a CSV string */ @@ -185,8 +197,8 @@ public function toCSV($array, $isList = false, $includeHeading = true) * * @param string $data Source data to convert, as a CSV string * @param string|null $rootKey Will not be used for converting because csv is flat - * @param boolean $isList Whether the input data contains more than one row - * @param boolean $includeHeading Whether the input contains a heading line + * @param bool $isList Whether the input data contains more than one row + * @param bool $includeHeading Whether the input contains a heading line * * @return array Converted data */ @@ -204,7 +216,7 @@ public function toArray($data, $rootKey = null, $isList = false, $includeHeading foreach ($rows as $row) { $values = $this->cleanupRow($this->getColumns($row)); if ($values !== []) { - $array []= array_combine($keys, $values); + $array[] = array_combine($keys, $values); } } } else { @@ -250,7 +262,8 @@ protected function getColumns($row) /** * Accepts a formatted row of data and returns it raw * - * @param array $row An array of data from a CSV output + * @param array $row An array of data from a CSV output + * * @return array The cleaned up array */ protected function cleanupRow($row) @@ -262,7 +275,7 @@ protected function cleanupRow($row) if ($this->isSerialized($column)) { $column = $this->unserialize($column); } - if ('N;' === $column) { + if ($column === 'N;') { $column = null; } $row[$key] = $column; @@ -274,7 +287,7 @@ protected function cleanupRow($row) /** * @param string $input * - * @return false|int + * @return int|false */ protected function isQuoted($input) { @@ -312,7 +325,7 @@ protected function unquote($input) * * @param string $input * - * @return false|int + * @return int|false */ protected function isSerialized($input) { @@ -322,7 +335,8 @@ protected function isSerialized($input) /** * Unserializes a value from CSV output * - * @param string $input + * @param string $input + * * @return mixed */ protected function unserialize($input) @@ -333,9 +347,9 @@ protected function unserialize($input) /** * Alias for CsvParser::toArray() * - * @param string $data Source data to convert, as a CSV string - * @param boolean $isList Whether the input data contains more than one row - * @param boolean $includeHeading Whether the input contains a heading line + * @param string $data Source data to convert, as a CSV string + * @param bool $isList Whether the input data contains more than one row + * @param bool $includeHeading Whether the input contains a heading line * * @return array Converted data */ diff --git a/src/Propel/Runtime/Parser/JsonParser.php b/src/Propel/Runtime/Parser/JsonParser.php index 4028d47e59..382fab9c76 100644 --- a/src/Propel/Runtime/Parser/JsonParser.php +++ b/src/Propel/Runtime/Parser/JsonParser.php @@ -20,8 +20,9 @@ class JsonParser extends AbstractParser /** * Converts data from an associative array to JSON. * - * @param array $array Source data to convert - * @param string $rootKey + * @param array $array Source data to convert + * @param string|null $rootKey + * * @return string Converted data, as a JSON string */ public function fromArray($array, $rootKey = null) @@ -32,8 +33,9 @@ public function fromArray($array, $rootKey = null) /** * Alias for JsonParser::fromArray() * - * @param array $array Source data to convert - * @param string $rootKey + * @param array $array Source data to convert + * @param string|null $rootKey + * * @return string Converted data, as a JSON string */ public function toJSON($array, $rootKey = null) @@ -44,9 +46,10 @@ public function toJSON($array, $rootKey = null) /** * Converts data from JSON to an associative array. * - * @param string $data Source data to convert, as a JSON string - * @param string $rootKey - * @return array Converted data + * @param string $data Source data to convert, as a JSON string + * @param string|null $rootKey + * + * @return array Converted data */ public function toArray($data, $rootKey = null) { @@ -66,9 +69,10 @@ public function toArray($data, $rootKey = null) /** * Alias for JsonParser::toArray() * - * @param string $data Source data to convert, as a JSON string - * @param string $rootKey - * @return array Converted data + * @param string $data Source data to convert, as a JSON string + * @param string|null $rootKey + * + * @return array Converted data */ public function fromJSON($data, $rootKey = null) { diff --git a/src/Propel/Runtime/Parser/XmlParser.php b/src/Propel/Runtime/Parser/XmlParser.php index d0527099fb..e6c0522f3c 100644 --- a/src/Propel/Runtime/Parser/XmlParser.php +++ b/src/Propel/Runtime/Parser/XmlParser.php @@ -10,6 +10,11 @@ namespace Propel\Runtime\Parser; +use DateTime; +use DateTimeInterface; +use DOMDocument; +use DOMNode; + /** * XML parser. Converts data between associative array and XML formats * @@ -22,7 +27,7 @@ class XmlParser extends AbstractParser * * @param array $array Source data to convert * @param string $rootKey Will be used for naming the root node - * @param string $charset Character set of the input data. Defaults to UTF-8. + * @param string|null $charset Character set of the input data. Defaults to UTF-8. * * @return string Converted data, as an XML string */ @@ -58,7 +63,7 @@ public function listFromArray($array, $rootKey = 'data', $charset = null) */ protected function getRootNode($rootElementName) { - $xml = new \DOMDocument('1.0', 'UTF-8'); + $xml = new DOMDocument('1.0', 'UTF-8'); $xml->preserveWhiteSpace = false; $xml->formatOutput = true; $rootElement = $xml->createElement($rootElementName); @@ -70,9 +75,9 @@ protected function getRootNode($rootElementName) /** * Alias for XmlParser::fromArray() * - * @param array $array Source data to convert + * @param array $array Source data to convert * @param string $rootElementName Name of the root element of the XML document - * @param string $charset Character set of the input data. Defaults to UTF-8. + * @param string|null $charset Character set of the input data. Defaults to UTF-8. * * @return string Converted data, as an XML string */ @@ -84,9 +89,9 @@ public function toXML($array, $rootElementName = 'data', $charset = null) /** * Alias for XmlParser::listFromArray() * - * @param array $array Source data to convert + * @param array $array Source data to convert * @param string $rootElementName Name of the root element of the XML document - * @param string $charset Character set of the input data. Defaults to UTF-8. + * @param string|null $charset Character set of the input data. Defaults to UTF-8. * * @return string Converted data, as an XML string */ @@ -96,9 +101,9 @@ public function listToXML($array, $rootElementName = 'data', $charset = null) } /** - * @param array $array + * @param array $array * @param \DOMElement $rootElement - * @param string $charset + * @param string|null $charset * * @return \DOMElement */ @@ -127,9 +132,9 @@ protected function arrayToDOM($array, $rootElement, $charset = null) $value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); $child = $element->ownerDocument->createCDATASection($value); $element->appendChild($child); - } elseif ($value instanceof \DateTimeInterface) { + } elseif ($value instanceof DateTimeInterface) { $element->setAttribute('type', 'xsd:dateTime'); - $child = $element->ownerDocument->createTextNode($value->format(\DateTime::ISO8601)); + $child = $element->ownerDocument->createTextNode($value->format(DateTime::ISO8601)); $element->appendChild($child); } else { $child = $element->ownerDocument->createTextNode((string)$value); @@ -144,13 +149,14 @@ protected function arrayToDOM($array, $rootElement, $charset = null) /** * Converts data from XML to an associative array. * - * @param string $data Source data to convert, as an XML string + * @param string $data Source data to convert, as an XML string * @param string $rootKey - * @return array Converted data + * + * @return array Converted data */ public function toArray($data, $rootKey = 'data') { - $doc = new \DOMDocument('1.0', 'UTF-8'); + $doc = new DOMDocument('1.0', 'UTF-8'); $doc->loadXML($data); $element = $doc->documentElement; @@ -160,9 +166,10 @@ public function toArray($data, $rootKey = 'data') /** * Alias for XmlParser::toArray() * - * @param string $data Source data to convert, as an XML string + * @param string $data Source data to convert, as an XML string * @param string $rootKey - * @return array Converted data + * + * @return array Converted data */ public function fromXML($data, $rootKey = 'data') { @@ -170,10 +177,11 @@ public function fromXML($data, $rootKey = 'data') } /** - * @param \DOMNode $data + * @param \DOMNode $data + * * @return array */ - protected function convertDOMElementToArray(\DOMNode $data) + protected function convertDOMElementToArray(DOMNode $data) { $array = []; $elementNames = []; @@ -203,7 +211,7 @@ protected function convertDOMElementToArray(\DOMNode $data) } elseif (!$element->hasChildNodes()) { $array[$index] = null; } elseif ($element->hasAttribute('type') && $element->getAttribute('type') === 'xsd:dateTime') { - $array[$index] = new \DateTime($element->textContent); + $array[$index] = new DateTime($element->textContent); } else { $array[$index] = $element->textContent; } @@ -213,10 +221,11 @@ protected function convertDOMElementToArray(\DOMNode $data) } /** - * @param \DOMNode $node - * @return boolean + * @param \DOMNode $node + * + * @return bool */ - protected function hasOnlyTextNodes(\DOMNode $node) + protected function hasOnlyTextNodes(DOMNode $node) { foreach ($node->childNodes as $childNode) { if ($childNode->nodeType != XML_CDATA_SECTION_NODE && $childNode->nodeType != XML_TEXT_NODE) { diff --git a/src/Propel/Runtime/Parser/YamlParser.php b/src/Propel/Runtime/Parser/YamlParser.php index 90223f0afe..52f98084a3 100644 --- a/src/Propel/Runtime/Parser/YamlParser.php +++ b/src/Propel/Runtime/Parser/YamlParser.php @@ -22,8 +22,9 @@ class YamlParser extends AbstractParser /** * Converts data from an associative array to YAML. * - * @param array $array Source data to convert - * @param string $rootKey + * @param array $array Source data to convert + * @param string|null $rootKey + * * @return string Converted data, as a YAML string */ public function fromArray($array, $rootKey = null) @@ -34,8 +35,9 @@ public function fromArray($array, $rootKey = null) /** * Alias for YamlParser::fromArray() * - * @param array $array Source data to convert - * @param string $rootKey + * @param array $array Source data to convert + * @param string|null $rootKey + * * @return string Converted data, as a YAML string */ public function toYAML($array, $rootKey = null) @@ -46,9 +48,10 @@ public function toYAML($array, $rootKey = null) /** * Converts data from YAML to an associative array. * - * @param string $data Source data to convert, as a YAML string - * @param string $rootKey - * @return array Converted data + * @param string $data Source data to convert, as a YAML string + * @param string|null $rootKey + * + * @return array Converted data */ public function toArray($data, $rootKey = null) { @@ -68,9 +71,10 @@ public function toArray($data, $rootKey = null) /** * Alias for YamlParser::toArray() * - * @param string $data Source data to convert, as a YAML string - * @param string $rootKey - * @return array Converted data + * @param string $data Source data to convert, as a YAML string + * @param string|null $rootKey + * + * @return array Converted data */ public function fromYAML($data, $rootKey = null) { diff --git a/src/Propel/Runtime/Propel.php b/src/Propel/Runtime/Propel.php index 1538dacd1c..7e2879a58c 100644 --- a/src/Propel/Runtime/Propel.php +++ b/src/Propel/Runtime/Propel.php @@ -10,11 +10,8 @@ namespace Propel\Runtime; -use Propel\Runtime\Connection\ConnectionInterface; -use Propel\Runtime\Exception\PropelException; use Propel\Runtime\ServiceContainer\ServiceContainerInterface; use Propel\Runtime\ServiceContainer\StandardServiceContainer; -use Psr\Log\LoggerInterface; /** * Propel's main resource pool and initialization & configuration class. @@ -36,52 +33,52 @@ class Propel /** * The Propel version. */ - const VERSION = '2.0.0-dev'; + public const VERSION = '2.0.0-dev'; /** * A constant for default. */ - const DEFAULT_NAME = "default"; + public const DEFAULT_NAME = 'default'; /** * A constant defining 'System is unusable' logging level */ - const LOG_EMERG = 550; + public const LOG_EMERG = 550; /** * A constant defining 'Immediate action required' logging level */ - const LOG_ALERT = 550; + public const LOG_ALERT = 550; /** * A constant defining 'Critical conditions' logging level */ - const LOG_CRIT = 500; + public const LOG_CRIT = 500; /** * A constant defining 'Error conditions' logging level */ - const LOG_ERR = 400; + public const LOG_ERR = 400; /** * A constant defining 'Warning conditions' logging level */ - const LOG_WARNING = 300; + public const LOG_WARNING = 300; /** * A constant defining 'Normal but significant' logging level */ - const LOG_NOTICE = 200; + public const LOG_NOTICE = 200; /** * A constant defining 'Informational' logging level */ - const LOG_INFO = 200; + public const LOG_INFO = 200; /** * A constant defining 'Debug-level messages' logging level */ - const LOG_DEBUG = 100; + public const LOG_DEBUG = 100; /** * @var \Propel\Runtime\ServiceContainer\ServiceContainerInterface @@ -89,15 +86,17 @@ class Propel private static $serviceContainer; /** - * @var boolean Whether the object instance pooling is enabled + * @var bool Whether the object instance pooling is enabled */ private static $isInstancePoolingEnabled = true; /** * Configure Propel using the given config file. * - * @param string $configFile Path (absolute or relative to include_path) to config file. * @deprecated Why don't you just include the configuration file? + * + * @param string $configFile Path (absolute or relative to include_path) to config file. + * * @return void */ public static function init($configFile) @@ -115,7 +114,7 @@ public static function init($configFile) */ public static function getServiceContainer() { - if (null === self::$serviceContainer) { + if (self::$serviceContainer === null) { self::$serviceContainer = new StandardServiceContainer(); } @@ -126,6 +125,7 @@ public static function getServiceContainer() * Set the service container instance. * * @param \Propel\Runtime\ServiceContainer\ServiceContainerInterface $serviceContainer + * * @return void */ public static function setServiceContainer(ServiceContainerInterface $serviceContainer) @@ -146,7 +146,7 @@ public static function getDefaultDatasource() * * If the adapter does not yet exist, build it using the related adapterClass. * - * @param string $name The datasource name + * @param string|null $name The datasource name * * @return \Propel\Runtime\Adapter\AdapterInterface */ @@ -160,7 +160,7 @@ public static function getAdapter($name = null) * * The database maps are "registered" by the generated map builder classes. * - * @param string $name The datasource name + * @param string|null $name The datasource name * * @return \Propel\Runtime\Map\DatabaseMap */ @@ -198,7 +198,7 @@ public static function closeConnections() * If the connection has not been opened, open it using the related * connectionSettings. If the connection has already been opened, return it. * - * @param string $name The datasource name + * @param string|null $name The datasource name * @param string $mode The connection mode (this applies to replication systems). * * @return \Propel\Runtime\Connection\ConnectionInterface A database connection @@ -217,9 +217,7 @@ public static function getConnection($name = null, $mode = ServiceContainerInter * @param string $name The datasource name that is used to look up the DSN * from the runtime configuration file. Empty name not allowed. * - * @return ConnectionInterface A database connection - * - * @throws PropelException - if connection is not properly configured + * @return \Propel\Runtime\Connection\ConnectionInterface A database connection */ public static function getWriteConnection($name) { @@ -236,7 +234,7 @@ public static function getWriteConnection($name) * @param string $name The datasource name that is used to look up the DSN * from the runtime configuration file. Empty name not allowed. * - * @return ConnectionInterface A database connection + * @return \Propel\Runtime\Connection\ConnectionInterface A database connection */ public static function getReadConnection($name) { @@ -256,7 +254,7 @@ public static function getProfiler() /** * Get the configured logger. * - * @return LoggerInterface Configured log class + * @return \Psr\Log\LoggerInterface Configured log class */ public static function getLogger() { @@ -269,7 +267,7 @@ public static function getLogger() * logging message will be discarded without any further action * * @param string $message The message that will be logged. - * @param int $level The logging level. + * @param int $level The logging level. * * @return void */ @@ -280,24 +278,31 @@ public static function log($message, $level = self::LOG_DEBUG) switch ($level) { case self::LOG_EMERG: $logger->emergency($message); + break; case self::LOG_ALERT: $logger->alert($message); + break; case self::LOG_CRIT: $logger->critical($message); + break; case self::LOG_ERR: $logger->error($message); + break; case self::LOG_WARNING: $logger->warning($message); + break; case self::LOG_NOTICE: $logger->notice($message); + break; case self::LOG_INFO: $logger->info($message); + break; default: $logger->debug($message); @@ -307,8 +312,8 @@ public static function log($message, $level = self::LOG_DEBUG) /** * Disable instance pooling. * - * @return boolean true if the method changed the instance pooling state, - * false if it was already disabled + * @return bool true if the method changed the instance pooling state, + * false if it was already disabled */ public static function disableInstancePooling() { @@ -323,8 +328,8 @@ public static function disableInstancePooling() /** * Enable instance pooling (enabled by default). * - * @return boolean true if the method changed the instance pooling state, - * false if it was already enabled + * @return bool true if the method changed the instance pooling state, + * false if it was already enabled */ public static function enableInstancePooling() { @@ -339,7 +344,7 @@ public static function enableInstancePooling() /** * the instance pooling behaviour. True by default. * - * @return boolean Whether the pooling is enabled or not. + * @return bool Whether the pooling is enabled or not. */ public static function isInstancePoolingEnabled() { diff --git a/src/Propel/Runtime/ServiceContainer/ServiceContainerInterface.php b/src/Propel/Runtime/ServiceContainer/ServiceContainerInterface.php index f11601dd8e..b4de89f0b1 100644 --- a/src/Propel/Runtime/ServiceContainer/ServiceContainerInterface.php +++ b/src/Propel/Runtime/ServiceContainer/ServiceContainerInterface.php @@ -10,35 +10,32 @@ namespace Propel\Runtime\ServiceContainer; -use Propel\Runtime\Util\Profiler; -use Psr\Log\LoggerInterface; - interface ServiceContainerInterface { /** * Constant used to request a READ connection (applies to replication). */ - const CONNECTION_READ = 'read'; + public const CONNECTION_READ = 'read'; /** * Constant used to request a WRITE connection (applies to replication). */ - const CONNECTION_WRITE = 'write'; + public const CONNECTION_WRITE = 'write'; /** * The default DatabaseMap class created by getDatabaseMap() */ - const DEFAULT_DATABASE_MAP_CLASS = '\Propel\Runtime\Map\DatabaseMap'; + public const DEFAULT_DATABASE_MAP_CLASS = '\Propel\Runtime\Map\DatabaseMap'; /** * The name of the default datasource. */ - const DEFAULT_DATASOURCE_NAME = 'default'; + public const DEFAULT_DATASOURCE_NAME = 'default'; /** * The name of the default Profiler class created by getProfiler() */ - const DEFAULT_PROFILER_CLASS = '\Propel\Runtime\Util\Profiler'; + public const DEFAULT_PROFILER_CLASS = '\Propel\Runtime\Util\Profiler'; /** * @return string @@ -50,7 +47,7 @@ public function getDefaultDatasource(); * * If the adapter does not yet exist, build it using the related adapterClass. * - * @param string $name The datasource name + * @param string|null $name The datasource name * * @return \Propel\Runtime\Adapter\AdapterInterface */ @@ -59,7 +56,7 @@ public function getAdapter($name = null); /** * Get the adapter class for a given datasource. * - * @param string $name The datasource name + * @param string|null $name The datasource name * * @return string */ @@ -70,7 +67,7 @@ public function getAdapterClass($name = null); * * The database maps are "registered" by the generated map builder classes. * - * @param string $name The datasource name + * @param string|null $name The datasource name * * @return \Propel\Runtime\Map\DatabaseMap */ @@ -86,7 +83,7 @@ public function getConnectionManager($name); /** * @param string $name * - * @return boolean true if a connectionManager with $name has been registered + * @return bool true if a connectionManager with $name has been registered */ public function hasConnectionManager($name); @@ -106,7 +103,7 @@ public function closeConnections(); * If the connection has not been opened, open it using the related * connectionSettings. If the connection has already been opened, return it. * - * @param string $name The datasource name + * @param string|null $name The datasource name * @param string $mode The connection mode (this applies to replication systems). * * @return \Propel\Runtime\Connection\ConnectionInterface A database connection @@ -122,9 +119,9 @@ public function getConnection($name = null, $mode = self::CONNECTION_WRITE); * @param string $name The datasource name that is used to look up the DSN * from the runtime configuration file. Empty name not allowed. * - * @return \Propel\Runtime\Connection\ConnectionInterface A database connection - * * @throws \Propel\Runtime\Adapter\Exception\AdapterException - if connection is not properly configured + * + * @return \Propel\Runtime\Connection\ConnectionInterface A database connection */ public function getWriteConnection($name); @@ -145,15 +142,16 @@ public function getReadConnection($name); /** * Get a profiler instance. * - * @return Profiler + * @return \Propel\Runtime\Util\Profiler */ public function getProfiler(); /** * Get a logger for a given datasource, or the default logger. * - * @param string $name - * @return LoggerInterface + * @param string $name + * + * @return \Psr\Log\LoggerInterface */ public function getLogger($name = 'defaultLogger'); } diff --git a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php index 01d4c0d5f0..2a15c85740 100644 --- a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php +++ b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php @@ -10,17 +10,20 @@ namespace Propel\Runtime\ServiceContainer; +use Monolog\Handler\RotatingFileHandler; +use Monolog\Handler\StreamHandler; +use Monolog\Handler\SyslogHandler; +use Monolog\Logger; use Propel\Runtime\Adapter\AdapterFactory; use Propel\Runtime\Adapter\AdapterInterface; use Propel\Runtime\Adapter\Exception\AdapterException; -use Propel\Runtime\Exception\UnexpectedValueException; -use Propel\Runtime\Exception\RuntimeException; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Connection\ConnectionManagerInterface; use Propel\Runtime\Connection\ConnectionManagerSingle; +use Propel\Runtime\Exception\RuntimeException; +use Propel\Runtime\Exception\UnexpectedValueException; use Propel\Runtime\Map\DatabaseMap; use Propel\Runtime\Propel; -use Monolog\Logger; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; @@ -74,7 +77,7 @@ class StandardServiceContainer implements ServiceContainerInterface protected $profiler; /** - * @var LoggerInterface[] List of loggers + * @var \Psr\Log\LoggerInterface[] List of loggers */ protected $loggers = []; @@ -93,6 +96,7 @@ public function getDefaultDatasource() /** * @param string $defaultDatasource + * * @return void */ public function setDefaultDatasource($defaultDatasource) @@ -109,7 +113,7 @@ public function setDefaultDatasource($defaultDatasource) */ public function getAdapterClass($name = null) { - if (null === $name) { + if ($name === null) { $name = $this->getDefaultDatasource(); } @@ -121,8 +125,9 @@ public function getAdapterClass($name = null) * * This allows for lazy-loading adapter objects in getAdapter(). * - * @param string $name The datasource name + * @param string $name The datasource name * @param string $adapterClass + * * @return void */ public function setAdapterClass($name, $adapterClass) @@ -135,6 +140,7 @@ public function setAdapterClass($name, $adapterClass) * Reset existing adapters classes and set new classes for all datasources. * * @param string[] $adapterClasses A list of adapters + * * @return void */ public function setAdapterClasses($adapterClasses) @@ -148,15 +154,15 @@ public function setAdapterClasses($adapterClasses) * * If the adapter does not yet exist, build it using the related adapterClass. * - * @param string $name The datasource name + * @param string|null $name The datasource name * - * @return AdapterInterface + * @throws \Propel\Runtime\Adapter\Exception\AdapterException * - * @throws AdapterException + * @return \Propel\Runtime\Adapter\AdapterInterface */ public function getAdapter($name = null) { - if (null === $name) { + if ($name === null) { $name = $this->getDefaultDatasource(); } if (!isset($this->adapters[$name])) { @@ -172,8 +178,9 @@ public function getAdapter($name = null) /** * Set the adapter for a given datasource. * - * @param string $name The datasource name + * @param string $name The datasource name * @param \Propel\Runtime\Adapter\AdapterInterface $adapter + * * @return void */ public function setAdapter($name, AdapterInterface $adapter) @@ -186,6 +193,7 @@ public function setAdapter($name, AdapterInterface $adapter) * Reset existing adapters and set new adapters for all datasources. * * @param array $adapters A list of adapters + * * @return void */ public function setAdapters($adapters) @@ -202,6 +210,7 @@ public function setAdapters($adapters) * the propel runtime. * * @param string $generatorVersion + * * @return void */ public function checkVersion($generatorVersion) @@ -210,7 +219,7 @@ public function checkVersion($generatorVersion) return; } - $warning = "Version mismatch: The generated model was build using propel '" . $generatorVersion; + $warning = "Version mismatch: The generated model was build using propel '" . $generatorVersion; $warning .= " while the current runtime is at version '" . Propel::VERSION . "'"; $logger = $this->getLogger(); @@ -219,6 +228,7 @@ public function checkVersion($generatorVersion) /** * @param string $databaseMapClass + * * @return void */ public function setDatabaseMapClass($databaseMapClass) @@ -231,13 +241,13 @@ public function setDatabaseMapClass($databaseMapClass) * * The database maps are "registered" by the generated map builder classes. * - * @param string $name The datasource name + * @param string|null $name The datasource name * * @return \Propel\Runtime\Map\DatabaseMap */ public function getDatabaseMap($name = null) { - if (null === $name) { + if ($name === null) { $name = $this->getDefaultDatasource(); } if (!isset($this->databaseMaps[$name])) { @@ -251,8 +261,9 @@ public function getDatabaseMap($name = null) /** * Set the database map object to use for a given datasource. * - * @param string $name The datasource name + * @param string $name The datasource name * @param \Propel\Runtime\Map\DatabaseMap $databaseMap + * * @return void */ public function setDatabaseMap($name, DatabaseMap $databaseMap) @@ -261,8 +272,9 @@ public function setDatabaseMap($name, DatabaseMap $databaseMap) } /** - * @param string $name The datasource name + * @param string $name The datasource name * @param \Propel\Runtime\Connection\ConnectionManagerInterface $manager + * * @return void */ public function setConnectionManager($name, ConnectionManagerInterface $manager) @@ -279,8 +291,9 @@ public function setConnectionManager($name, ConnectionManagerInterface $manager) /** * @param string $name The datasource name * - * @return \Propel\Runtime\Connection\ConnectionManagerInterface * @throws \Propel\Runtime\Exception\RuntimeException - if the datasource doesn't exist + * + * @return \Propel\Runtime\Connection\ConnectionManagerInterface */ public function getConnectionManager($name) { @@ -294,7 +307,7 @@ public function getConnectionManager($name) /** * @param string $name * - * @return boolean true if a connectionManager with $name has been registered + * @return bool true if a connectionManager with $name has been registered */ public function hasConnectionManager($name) { @@ -330,18 +343,18 @@ public function closeConnections() * If the connection has not been opened, open it using the related * connectionSettings. If the connection has already been opened, return it. * - * @param string $name The datasource name + * @param string|null $name The datasource name * @param string $mode The connection mode (this applies to replication systems). * * @return \Propel\Runtime\Connection\ConnectionInterface A database connection */ public function getConnection($name = null, $mode = ServiceContainerInterface::CONNECTION_WRITE) { - if (null === $name) { + if ($name === null) { $name = $this->getDefaultDatasource(); } - if (ServiceContainerInterface::CONNECTION_READ === $mode) { + if ($mode === ServiceContainerInterface::CONNECTION_READ) { return $this->getReadConnection($name); } @@ -357,9 +370,7 @@ public function getConnection($name = null, $mode = ServiceContainerInterface::C * @param string $name The datasource name that is used to look up the DSN * from the runtime configuration file. Empty name not allowed. * - * @return ConnectionInterface A database connection - * - * @throws \Propel\Runtime\Adapter\Exception\AdapterException - if connection is not properly configured + * @return \Propel\Runtime\Connection\ConnectionInterface A database connection */ public function getWriteConnection($name) { @@ -376,7 +387,7 @@ public function getWriteConnection($name) * @param string $name The datasource name that is used to look up the DSN * from the runtime configuration file. Empty name not allowed. * - * @return ConnectionInterface A database connection + * @return \Propel\Runtime\Connection\ConnectionInterface A database connection */ public function getReadConnection($name) { @@ -388,6 +399,7 @@ public function getReadConnection($name) * * @param string $name The datasource name * @param \Propel\Runtime\Connection\ConnectionInterface $connection A database connection + * * @return void */ public function setConnection($name, ConnectionInterface $connection) @@ -404,6 +416,7 @@ public function setConnection($name, ConnectionInterface $connection) * getProfiler() is called. * * @param string $profilerClass + * * @return void */ public function setProfilerClass($profilerClass) @@ -414,9 +427,11 @@ public function setProfilerClass($profilerClass) /** * Set the profiler configuration. + * * @see \Propel\Runtime\Util\Profiler::setConfiguration() * * @param array $profilerConfiguration + * * @return void */ public function setProfilerConfiguration($profilerConfiguration) @@ -429,6 +444,7 @@ public function setProfilerConfiguration($profilerConfiguration) * Set the profiler instance. * * @param \Propel\Runtime\Util\Profiler $profiler + * * @return void */ public function setProfiler($profiler) @@ -445,7 +461,7 @@ public function setProfiler($profiler) */ public function getProfiler() { - if (null === $this->profiler) { + if ($this->profiler === null) { $class = $this->profilerClass; /** @var \Propel\Runtime\Util\Profiler $profiler */ $profiler = new $class(); @@ -461,7 +477,9 @@ public function getProfiler() /** * Get a logger instance * - * @return LoggerInterface + * @param string $name + * + * @return \Psr\Log\LoggerInterface */ public function getLogger($name = 'defaultLogger') { @@ -473,8 +491,9 @@ public function getLogger($name = 'defaultLogger') } /** - * @param string $name the name of the logger to be set - * @param LoggerInterface $logger A logger instance + * @param string $name the name of the logger to be set + * @param \Psr\Log\LoggerInterface $logger A logger instance + * * @return void */ public function setLogger($name, LoggerInterface $logger) @@ -486,39 +505,43 @@ public function setLogger($name, LoggerInterface $logger) * @param string $name * * @throws \Propel\Runtime\Exception\UnexpectedValueException + * * @return \Psr\Log\LoggerInterface */ protected function buildLogger($name = 'defaultLogger') { if (!isset($this->loggerConfigurations[$name])) { - return 'defaultLogger' !== $name ? $this->getLogger() : new NullLogger(); + return $name !== 'defaultLogger' ? $this->getLogger() : new NullLogger(); } - $logger = new Logger($name); + $logger = new Logger($name); $configuration = $this->loggerConfigurations[$name]; switch ($configuration['type']) { case 'stream': - $handler = new \Monolog\Handler\StreamHandler( + $handler = new StreamHandler( $configuration['path'], isset($configuration['level']) ? $configuration['level'] : null, isset($configuration['bubble']) ? $configuration['bubble'] : null ); + break; case 'rotating_file': - $handler = new \Monolog\Handler\RotatingFileHandler( + $handler = new RotatingFileHandler( $configuration['path'], isset($configuration['max_files']) ? $configuration['max_files'] : null, isset($configuration['level']) ? $configuration['level'] : null, isset($configuration['bubble']) ? $configuration['bubble'] : null ); + break; case 'syslog': - $handler = new \Monolog\Handler\SyslogHandler( + $handler = new SyslogHandler( $configuration['ident'], isset($configuration['facility']) ? $configuration['facility'] : null, isset($configuration['level']) ? $configuration['level'] : null, isset($configuration['bubble']) ? $configuration['bubble'] : null ); + break; default: throw new UnexpectedValueException(sprintf( @@ -547,7 +570,8 @@ protected function buildLogger($name = 'defaultLogger') * * * @param string $name - * @param array $loggerConfiguration + * @param array $loggerConfiguration + * * @return void */ public function setLoggerConfiguration($name, $loggerConfiguration) diff --git a/src/Propel/Runtime/Util/Profiler.php b/src/Propel/Runtime/Util/Profiler.php index 91ebd74bfc..e04843b908 100644 --- a/src/Propel/Runtime/Util/Profiler.php +++ b/src/Propel/Runtime/Util/Profiler.php @@ -9,6 +9,7 @@ */ namespace Propel\Runtime\Util; + use Propel\Common\Config\Exception\InvalidConfigurationException; /** @@ -26,24 +27,24 @@ class Profiler protected $details = [ 'time' => [ - 'name' => 'Time', + 'name' => 'Time', 'precision' => 3, - 'pad' => 8 + 'pad' => 8, ], 'mem' => [ - 'name' => 'Memory', + 'name' => 'Memory', 'precision' => 3, - 'pad' => 8 + 'pad' => 8, ], 'memDelta' => [ - 'name' => 'Memory Delta', + 'name' => 'Memory Delta', 'precision' => 3, - 'pad' => 8 + 'pad' => 8, ], 'memPeak' => [ - 'name' => 'Memory Peak', + 'name' => 'Memory Peak', 'precision' => 3, - 'pad' => 8 + 'pad' => 8, ], ]; @@ -55,14 +56,15 @@ class Profiler public function __construct($slowTreshold = 0.1, $innerGlue = ': ', $outerGlue = ' | ') { $this->slowTreshold = $slowTreshold; - $this->innerGlue = $innerGlue; - $this->outerGlue = $outerGlue; + $this->innerGlue = $innerGlue; + $this->outerGlue = $outerGlue; } /** * Set the duration which triggers the 'slow' label on details. * - * @param integer $slowTreshold duration in seconds + * @param int $slowTreshold duration in seconds + * * @return void */ public function setSlowTreshold($slowTreshold) @@ -74,6 +76,7 @@ public function setSlowTreshold($slowTreshold) * Set the list of details to be included in a profile. * * @param array $details + * * @return void */ public function setDetails($details) @@ -85,6 +88,7 @@ public function setDetails($details) * Set the inner glue for the details. * * @param string $innerGlue + * * @return void */ public function setInnerGlue($innerGlue) @@ -96,6 +100,7 @@ public function setInnerGlue($innerGlue) * Set the outer glue for the details. * * @param string $outerGlue + * * @return void */ public function setOuterGlue($outerGlue) @@ -138,6 +143,7 @@ public function setOuterGlue($outerGlue) * * * @param array $profilerConfiguration + * * @return void */ public function setConfiguration($profilerConfiguration) @@ -167,9 +173,9 @@ public function getConfiguration() { return [ 'slowTreshold' => $this->slowTreshold, - 'details' => $this->details, - 'innerGlue' => $this->innerGlue, - 'outerGlue' => $this->outerGlue, + 'details' => $this->details, + 'innerGlue' => $this->innerGlue, + 'outerGlue' => $this->outerGlue, ]; } @@ -207,7 +213,9 @@ public function getProfile() * @see self::getSnapshot() * * @param array $startSnapshot A snapshot, as returned by self::getSnapshot(). - * @param array $endSnapshot A snapshot, as returned by self::getSnapshot(). + * @param array $endSnapshot A snapshot, as returned by self::getSnapshot(). + * + * @throws \Propel\Common\Config\Exception\InvalidConfigurationException * * @return string */ @@ -228,16 +236,20 @@ public function getProfileBetween($startSnapshot, $endSnapshot) switch ($detailName) { case 'time': $value = self::formatDuration($endSnapshot['microtime'] - $startSnapshot['microtime'], $config['precision']); + break; case 'mem': $value = self::formatMemory($endSnapshot['memoryUsage'], $config['precision']); + break; case 'memDelta': $value = $endSnapshot['memoryUsage'] - $startSnapshot['memoryUsage']; $value = ($value > 0 ? '+' : '') . self::formatMemory($value, $config['precision']); + break; case 'memPeak': $value = self::formatMemory($endSnapshot['memoryPeakUsage'], $config['precision']); + break; default: throw new InvalidConfigurationException("`$detailName` isn't a valid profiler key (Section: propel.runtime.profiler)."); @@ -256,8 +268,8 @@ public function getProfileBetween($startSnapshot, $endSnapshot) public static function getSnapshot() { return [ - 'microtime' => microtime(true), - 'memoryUsage' => memory_get_usage(), + 'microtime' => microtime(true), + 'memoryUsage' => memory_get_usage(), 'memoryPeakUsage' => memory_get_peak_usage(), ]; } @@ -265,8 +277,8 @@ public static function getSnapshot() /** * Format a byte count into a human-readable representation. * - * @param integer $bytes Byte count to convert. Can be negative. - * @param integer $precision How many decimals to include. + * @param int $bytes Byte count to convert. Can be negative. + * @param int $precision How many decimals to include. * * @return string */ @@ -287,8 +299,8 @@ public static function formatMemory($bytes, $precision = 3) /** * Format a duration into a human-readable representation. * - * @param double $duration Duration to format, in seconds. - * @param integer $precision How many decimals to include. + * @param float $duration Duration to format, in seconds. + * @param int $precision How many decimals to include. * * @return string */ @@ -307,8 +319,8 @@ public static function formatDuration($duration, $precision = 3) /** * Rounding to significant digits (sort of like JavaScript's toPrecision()). * - * @param float|int $number Value to round - * @param integer $significantFigures Number of significant figures + * @param float|int $number Value to round + * @param int $significantFigures Number of significant figures * * @return string */ @@ -318,7 +330,7 @@ public static function toPrecision($number, $significantFigures = 3) return '0'; } - $significantDecimals = (int) floor($significantFigures - log10(abs($number))); + $significantDecimals = (int)floor($significantFigures - log10(abs($number))); $magnitude = pow(10, $significantDecimals); $shifted = round($number * $magnitude); diff --git a/src/Propel/Runtime/Util/PropelConditionalProxy.php b/src/Propel/Runtime/Util/PropelConditionalProxy.php index 2fa5a0add4..59ddb44ccd 100644 --- a/src/Propel/Runtime/Util/PropelConditionalProxy.php +++ b/src/Propel/Runtime/Util/PropelConditionalProxy.php @@ -19,23 +19,25 @@ * * @example * - * $c->_if(true) // returns $c - * ->doStuff() // executed - * ->_else() // returns a PropelConditionalProxy instance + * $c->_if(true) // returns $c + * ->doStuff() // executed + * ->_else() // returns a PropelConditionalProxy instance * ->doOtherStuff() // not executed - * ->_endif(); // returns $c - * $c->_if(false) // returns a PropelConditionalProxy instance - * ->doStuff() // not executed - * ->_else() // returns $c + * ->_endif(); // returns $c + * $c->_if(false) // returns a PropelConditionalProxy instance + * ->doStuff() // not executed + * ->_else() // returns $c * ->doOtherStuff() // executed - * ->_endif(); // returns $c + * ->_endif(); // returns $c * @see Criteria * * @author Francois Zaninotto */ class PropelConditionalProxy { - /** @var Criteria */ + /** + * @var \Propel\Runtime\ActiveQuery\Criteria + */ protected $criteria; protected $parent; @@ -49,16 +51,16 @@ class PropelConditionalProxy /** * @param \Propel\Runtime\ActiveQuery\Criteria $criteria * @param mixed $cond - * @param \Propel\Runtime\Util\PropelConditionalProxy|null $proxy + * @param \Propel\Runtime\Util\PropelConditionalProxy|self|null $proxy */ - public function __construct(Criteria $criteria, $cond, self $proxy = null) + public function __construct(Criteria $criteria, $cond, ?self $proxy = null) { $this->criteria = $criteria; $this->wasTrue = false; $this->setConditionalState($cond); $this->parent = $proxy; - if (null === $proxy) { + if ($proxy === null) { $this->parentState = true; } else { $this->parentState = $proxy->getConditionalState(); @@ -69,9 +71,9 @@ public function __construct(Criteria $criteria, $cond, self $proxy = null) * Returns a new level PropelConditionalProxy instance. * Allows for conditional statements in a fluid interface. * - * @param boolean $cond + * @param bool $cond * - * @return $this|PropelConditionalProxy|Criteria + * @return $this|$this|\Propel\Runtime\ActiveQuery\Criteria */ public function _if($cond) { @@ -81,9 +83,9 @@ public function _if($cond) /** * Allows for conditional statements in a fluid interface. * - * @param boolean $cond ignored + * @param bool $cond ignored * - * @return $this|PropelConditionalProxy|Criteria + * @return $this|$this|\Propel\Runtime\ActiveQuery\Criteria */ public function _elseif($cond) { @@ -93,7 +95,7 @@ public function _elseif($cond) /** * Allows for conditional statements in a fluid interface. * - * @return $this|PropelConditionalProxy|Criteria + * @return $this|$this|\Propel\Runtime\ActiveQuery\Criteria */ public function _else() { @@ -104,7 +106,7 @@ public function _else() * Returns the parent object * Allows for conditional statements in a fluid interface. * - * @return $this|PropelConditionalProxy|Criteria + * @return $this|$this|\Propel\Runtime\ActiveQuery\Criteria */ public function _endif() { @@ -114,7 +116,7 @@ public function _endif() /** * return the current conditional status * - * @return boolean + * @return bool */ protected function getConditionalState() { @@ -128,14 +130,14 @@ protected function getConditionalState() */ protected function setConditionalState($cond) { - $this->state = (bool) $cond; + $this->state = (bool)$cond; $this->wasTrue = $this->wasTrue || $this->state; return $this->getCriteriaOrProxy(); } /** - * @return \Propel\Runtime\Util\PropelConditionalProxy|null + * @return $this|null */ public function getParentProxy() { diff --git a/src/Propel/Runtime/Util/PropelDateTime.php b/src/Propel/Runtime/Util/PropelDateTime.php index 3a5b5971fb..452d6203c4 100644 --- a/src/Propel/Runtime/Util/PropelDateTime.php +++ b/src/Propel/Runtime/Util/PropelDateTime.php @@ -10,7 +10,10 @@ namespace Propel\Runtime\Util; -use \DateTimeZone; +use DateTime; +use DateTimeInterface; +use DateTimeZone; +use Exception; use Propel\Runtime\Exception\PropelException; /** @@ -20,16 +23,18 @@ * @author Soenke Ruempler * @author Hans Lellelid */ -class PropelDateTime extends \DateTime +class PropelDateTime extends DateTime { /** * A string representation of the date, for serialization. + * * @var string */ private $dateString; /** * A string representation of the time zone, for serialization. + * * @var string */ private $tzString; @@ -45,19 +50,19 @@ protected static function isTimestamp($value) return false; } - if (8 === strlen((string) $value)) { + if (strlen((string)$value) === 8) { return false; } $stamp = strtotime($value); - if (false === $stamp) { + if ($stamp === false) { return true; } $month = (int)date('m', $value); - $day = (int)date('d', $value); - $year = (int)date('Y', $value); + $day = (int)date('d', $value); + $year = (int)date('Y', $value); return checkdate($month, $day, $year); } @@ -67,15 +72,15 @@ protected static function isTimestamp($value) * * Usually `new \Datetime()` does not contain milliseconds so you need a method like this. * - * @param bool $time optional in seconds. floating point allowed. + * @param bool|null $time optional in seconds. floating point allowed. * * @return \DateTime */ public static function createHighPrecision($time = null) { - $dateTime = \DateTime::createFromFormat('U.u', $time ?: self::getMicrotime()); + $dateTime = DateTime::createFromFormat('U.u', $time ?: self::getMicrotime()); - $dateTime->setTimeZone(new \DateTimeZone(date_default_timezone_get())); + $dateTime->setTimeZone(new DateTimeZone(date_default_timezone_get())); return $dateTime; } @@ -96,17 +101,17 @@ public static function getMicrotime() /** * Factory method to get a DateTime object from a temporal input * - * @param mixed $value The value to convert (can be a string, a timestamp, or another DateTime) - * @param DateTimeZone $timeZone (optional) timezone - * @param string $dateTimeClass The class of the object to create, defaults to DateTime + * @param mixed $value The value to convert (can be a string, a timestamp, or another DateTime) + * @param \DateTimeZone|null $timeZone (optional) timezone + * @param string $dateTimeClass The class of the object to create, defaults to DateTime * - * @return mixed|null An instance of $dateTimeClass + * @throws \Propel\Runtime\Exception\PropelException * - * @throws PropelException + * @return mixed|null An instance of $dateTimeClass */ - public static function newInstance($value, DateTimeZone $timeZone = null, $dateTimeClass = 'DateTime') + public static function newInstance($value, ?DateTimeZone $timeZone = null, $dateTimeClass = 'DateTime') { - if ($value instanceof \DateTimeInterface) { + if ($value instanceof DateTimeInterface) { return $value; } if (empty($value)) { @@ -116,26 +121,25 @@ public static function newInstance($value, DateTimeZone $timeZone = null, $dateT } try { if (static::isTimestamp($value)) { // if it's a unix timestamp - $format = 'U'; if (strpos($value, '.')) { //with milliseconds $format = 'U.u'; } - $dateTimeObject = \DateTime::createFromFormat($format, $value, new \DateTimeZone('UTC')); + $dateTimeObject = DateTime::createFromFormat($format, $value, new DateTimeZone('UTC')); // timezone must be explicitly specified and then changed // because of a DateTime bug: http://bugs.php.net/bug.php?id=43003 - $dateTimeObject->setTimeZone(new \DateTimeZone(date_default_timezone_get())); + $dateTimeObject->setTimeZone(new DateTimeZone(date_default_timezone_get())); } else { - if (null === $timeZone) { + if ($timeZone === null) { // stupid DateTime constructor signature $dateTimeObject = new $dateTimeClass($value); } else { $dateTimeObject = new $dateTimeClass($value, $timeZone); } } - } catch (\Exception $e) { + } catch (Exception $e) { throw new PropelException('Error parsing date/time value: ' . var_export($value, true), 0, $e); } @@ -146,6 +150,7 @@ public static function newInstance($value, DateTimeZone $timeZone = null, $dateT * PHP "magic" function called when object is serialized. * Sets an internal property with the date string and returns properties * of class that should be serialized. + * * @return string[] */ public function __sleep() @@ -161,11 +166,12 @@ public function __sleep() /** * PHP "magic" function called when object is restored from serialized state. * Calls DateTime constructor with previously stored string value of date. + * * @return void */ public function __wakeup() { // @TODO I don't think we can call the constructor from within this method - parent::__construct($this->dateString, new \DateTimeZone($this->tzString)); + parent::__construct($this->dateString, new DateTimeZone($this->tzString)); } } diff --git a/src/Propel/Runtime/Util/PropelModelPager.php b/src/Propel/Runtime/Util/PropelModelPager.php index 4eba3b9f4a..c01d741ae5 100644 --- a/src/Propel/Runtime/Util/PropelModelPager.php +++ b/src/Propel/Runtime/Util/PropelModelPager.php @@ -10,8 +10,9 @@ namespace Propel\Runtime\Util; +use Countable; +use IteratorAggregate; use Propel\Runtime\ActiveQuery\ModelCriteria; -use Propel\Runtime\Collection\Collection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\BadMethodCallException; @@ -22,10 +23,10 @@ * @author Fabien Potencier * @author François Zaninotto */ -class PropelModelPager implements \IteratorAggregate, \Countable +class PropelModelPager implements IteratorAggregate, Countable { /** - * @var ModelCriteria + * @var \Propel\Runtime\ActiveQuery\ModelCriteria */ protected $query; @@ -60,12 +61,12 @@ class PropelModelPager implements \IteratorAggregate, \Countable protected $maxRecordLimit; /** - * @var Collection|array|mixed + * @var \Propel\Runtime\Collection\Collection|array|mixed */ protected $results; /** - * @var ConnectionInterface + * @var \Propel\Runtime\Connection\ConnectionInterface */ protected $con; @@ -108,7 +109,7 @@ public function getQuery() * * @return void */ - public function init(ConnectionInterface $con = null) + public function init(?ConnectionInterface $con = null) { $this->con = $con; $maxRecordLimit = $this->getMaxRecordLimit(); @@ -118,20 +119,18 @@ public function init(ConnectionInterface $con = null) $count = $qForCount ->offset(0) ->limit(-1) - ->count($this->con) - ; + ->count($this->con); $this->setNbResults($hasMaxRecordLimit ? min($count, $maxRecordLimit) : $count); $q = $this->getQuery() ->offset(0) - ->limit(-1) - ; + ->limit(-1); - if (0 === $this->getPage() || 0 === $this->getMaxPerPage()) { + if ($this->getPage() === 0 || $this->getMaxPerPage() === 0) { $this->setLastPage(0); } else { - $this->setLastPage((int) ceil($this->getNbResults() / $this->getMaxPerPage())); + $this->setLastPage((int)ceil($this->getNbResults() / $this->getMaxPerPage())); $offset = ($this->getPage() - 1) * $this->getMaxPerPage(); $q->offset($offset); @@ -152,11 +151,11 @@ public function init(ConnectionInterface $con = null) /** * Get the collection of results in the page * - * @return Collection A collection of results + * @return \Propel\Runtime\Collection\Collection A collection of results */ public function getResults() { - if (null === $this->results) { + if ($this->results === null) { $queryKey = method_exists($this->getQuery(), 'getQueryKey') ? $this->getQuery()->getQueryKey() : null; if ($queryKey) { $newQueryKey = sprintf('%s offset %s limit %s', $queryKey, $this->getQuery()->getOffset(), $this->getQuery()->getLimit()); @@ -164,8 +163,7 @@ public function getResults() } $this->results = $this->getQuery() - ->find($this->con) - ; + ->find($this->con); } return $this->results; @@ -205,12 +203,12 @@ public function setMaxRecordLimit($limit) public function getLinks($nbLinks = 5) { $links = []; - $tmp = $this->page - floor($nbLinks / 2); + $tmp = $this->page - floor($nbLinks / 2); $check = $this->lastPage - $nbLinks + 1; $limit = ($check > 0) ? $check : 1; $begin = ($tmp > 0) ? (($tmp > $limit) ? $limit : $tmp) : 1; - $i = (int) $begin; + $i = (int)$begin; while (($i < $begin + $nbLinks) && ($i <= $this->lastPage)) { $links[] = $i++; } @@ -223,11 +221,11 @@ public function getLinks($nbLinks = 5) /** * Test whether the number of results exceeds the max number of results per page * - * @return boolean true if the pager displays only a subset of the results + * @return bool true if the pager displays only a subset of the results */ public function haveToPaginate() { - return (0 !== $this->getMaxPerPage() && $this->getNbResults() > $this->getMaxPerPage()); + return ($this->getMaxPerPage() !== 0 && $this->getNbResults() > $this->getMaxPerPage()); } /** @@ -238,7 +236,7 @@ public function haveToPaginate() */ public function getFirstIndex() { - if (0 === $this->page) { + if ($this->page === 0) { return 1; } @@ -253,7 +251,7 @@ public function getFirstIndex() */ public function getLastIndex() { - if (0 === $this->page) { + if ($this->page === 0) { return $this->nbResults; } @@ -279,6 +277,7 @@ public function getNbResults() * Set the total number of results of the query * * @param int $nb + * * @return void */ protected function setNbResults($nb) @@ -289,7 +288,7 @@ protected function setNbResults($nb) /** * Check whether the current page is the first page * - * @return boolean true if the current page is the first page + * @return bool true if the current page is the first page */ public function isFirstPage() { @@ -309,7 +308,7 @@ public function getFirstPage() /** * Check whether the current page is the last page * - * @return boolean true if the current page is the last page + * @return bool true if the current page is the last page */ public function isLastPage() { @@ -330,6 +329,7 @@ public function getLastPage() * Set the number of the first page * * @param int $page + * * @return void */ protected function setLastPage($page) @@ -354,11 +354,12 @@ public function getPage() * Set the number of the current page * * @param int $page + * * @return void */ public function setPage($page) { - $this->page = (int) $page; + $this->page = (int)$page; if ($this->page <= 0 && $this->nbResults > 0) { // set first page, which depends on a maximum set $this->page = $this->getMaxPerPage() ? 1 : 0; @@ -399,21 +400,22 @@ public function getMaxPerPage() * Set the maximum number results per page * * @param int $max + * * @return void */ public function setMaxPerPage($max) { if ($max > 0) { $this->maxPerPage = $max; - if (0 === $this->page) { + if ($this->page === 0) { $this->page = 1; } - } elseif (0 === $max) { + } elseif ($max === 0) { $this->maxPerPage = 0; $this->page = 0; } else { $this->maxPerPage = 1; - if (0 === $this->page) { + if ($this->page === 0) { $this->page = 1; } } @@ -421,9 +423,10 @@ public function setMaxPerPage($max) /** * Check if the collection is empty + * * @see Collection * - * @return boolean + * @return bool */ public function isEmpty() { @@ -442,6 +445,7 @@ public function getIterator() * Returns the number of items in the result collection. * * @see Countable + * * @return int */ public function count() @@ -454,6 +458,7 @@ public function count() * @param array $params * * @throws \Propel\Runtime\Exception\BadMethodCallException + * * @return mixed */ public function __call($name, $params) @@ -464,5 +469,4 @@ public function __call($name, $params) throw new BadMethodCallException('Call to undefined method: ' . $name); } } - } diff --git a/src/Propel/Runtime/Validator/Constraints/Date.php b/src/Propel/Runtime/Validator/Constraints/Date.php index bed8dc6711..1f9d518ef8 100644 --- a/src/Propel/Runtime/Validator/Constraints/Date.php +++ b/src/Propel/Runtime/Validator/Constraints/Date.php @@ -14,5 +14,6 @@ class Date extends SymfonyDateConstraint { public $message = 'This value is not a valid date.'; + public $column = ''; } diff --git a/src/Propel/Runtime/Validator/Constraints/DateValidator.php b/src/Propel/Runtime/Validator/Constraints/DateValidator.php index 5487536a73..8cda6c93fb 100644 --- a/src/Propel/Runtime/Validator/Constraints/DateValidator.php +++ b/src/Propel/Runtime/Validator/Constraints/DateValidator.php @@ -9,8 +9,9 @@ namespace Propel\Runtime\Validator\Constraints; -use Symfony\Component\Validator\Constraints\DateValidator as SymfonyDateValidator; +use DateTimeInterface; use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\DateValidator as SymfonyDateValidator; /** * Validates Dates @@ -22,11 +23,12 @@ class DateValidator extends SymfonyDateValidator /** * @param mixed $value The value that should be validated * @param \Symfony\Component\Validator\Constraint $constraint + * * @return void */ public function validate($value, Constraint $constraint) { - if ($value instanceof \DateTimeInterface) { + if ($value instanceof DateTimeInterface) { return; } diff --git a/src/Propel/Runtime/Validator/Constraints/Unique.php b/src/Propel/Runtime/Validator/Constraints/Unique.php index bf2462f434..609b56a15e 100644 --- a/src/Propel/Runtime/Validator/Constraints/Unique.php +++ b/src/Propel/Runtime/Validator/Constraints/Unique.php @@ -13,6 +13,13 @@ class Unique extends Constraint { + /** + * @var string + */ public $message = 'This value is already stored in your database'; + + /** + * @var string + */ public $column = ''; } diff --git a/src/Propel/Runtime/Validator/Constraints/UniqueValidator.php b/src/Propel/Runtime/Validator/Constraints/UniqueValidator.php index 7580e2de92..c526044346 100644 --- a/src/Propel/Runtime/Validator/Constraints/UniqueValidator.php +++ b/src/Propel/Runtime/Validator/Constraints/UniqueValidator.php @@ -24,23 +24,21 @@ class UniqueValidator extends ConstraintValidator */ public function validate($value, Constraint $constraint) { - if (null === $value) { + if ($value === null) { return; } - $className = $this->context->getClassName(); - $tableMap = $className::TABLE_MAP; + $className = $this->context->getClassName(); + $tableMap = $className::TABLE_MAP; $queryClass = $className . 'Query'; - $filter = sprintf('filterBy%s', $tableMap::translateFieldName($this->context->getPropertyName(), TableMap::TYPE_FIELDNAME, TableMap::TYPE_PHPNAME)); - $matches = $queryClass::create()->$filter($value); + $filter = sprintf('filterBy%s', $tableMap::translateFieldName($this->context->getPropertyName(), TableMap::TYPE_FIELDNAME, TableMap::TYPE_PHPNAME)); + $matches = $queryClass::create()->$filter($value); $columnName = sprintf('%s.%s', $tableMap::TABLE_NAME, $this->context->getPropertyName()); if ($this->context->getObject()->isNew() && $matches->count() > 0) { $this->context->addViolation($constraint->message); - } - - else if ($this->context->getObject()->isModified() && $matches->count() > (in_array($columnName, $this->context->getObject()->getModifiedColumns()) ? 0 : 1)) { + } elseif ($this->context->getObject()->isModified() && $matches->count() > (in_array($columnName, $this->context->getObject()->getModifiedColumns()) ? 0 : 1)) { $this->context->addViolation($constraint->message); } } From 191e6ca48980863bbc093bbf642dfa29a7e4c927 Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 24 Jul 2020 02:32:17 +0200 Subject: [PATCH 126/208] Add more missing docblocks. --- config/phpcs.xml | 7 +++ .../Common/Config/ConfigurationManager.php | 2 +- .../Common/Config/Loader/IniFileLoader.php | 5 +- .../AggregateColumnBehavior.php | 6 +- .../AggregateColumnRelationBehavior.php | 9 ++- .../Archivable/ArchivableBehavior.php | 12 +++- .../Behavior/AutoAddPk/AutoAddPkBehavior.php | 6 +- .../ConcreteInheritanceBehavior.php | 6 +- .../ConcreteInheritanceParentBehavior.php | 6 +- .../Behavior/Delegate/DelegateBehavior.php | 9 ++- .../Generator/Behavior/I18n/I18nBehavior.php | 9 ++- .../Behavior/NestedSet/NestedSetBehavior.php | 12 +++- .../QueryCache/QueryCacheBehavior.php | 8 ++- .../Behavior/Sortable/SortableBehavior.php | 15 ++++- .../Timestampable/TimestampableBehavior.php | 3 + .../Behavior/Validate/ValidateBehavior.php | 6 +- .../Versionable/VersionableBehavior.php | 15 ++++- ...rsionableBehaviorObjectBuilderModifier.php | 4 ++ ...ersionableBehaviorQueryBuilderModifier.php | 4 ++ .../Generator/Builder/DataModelBuilder.php | 2 + .../Builder/Om/AbstractOMBuilder.php | 13 +++++ .../Builder/Om/AbstractObjectBuilder.php | 4 ++ .../Generator/Builder/Om/ClassTools.php | 7 +++ .../Builder/Om/ExtensionObjectBuilder.php | 2 + .../Builder/Om/ExtensionQueryBuilder.php | 3 + .../Om/ExtensionQueryInheritanceBuilder.php | 2 + .../Generator/Builder/Om/InterfaceBuilder.php | 4 +- .../Generator/Builder/Om/ObjectBuilder.php | 33 ++++++++--- .../Generator/Builder/Om/QueryBuilder.php | 16 ++++++ .../Builder/Om/QueryInheritanceBuilder.php | 2 + .../Generator/Builder/Om/TableMapBuilder.php | 4 +- .../Generator/Builder/Util/PropelTemplate.php | 2 + .../Generator/Builder/Util/SchemaReader.php | 12 ++++ .../Generator/Command/AbstractCommand.php | 5 +- .../Command/Console/Input/ArrayInput.php | 8 ++- .../Command/Helper/ConsoleHelper.php | 6 ++ .../Command/Helper/ConsoleHelperInterface.php | 5 ++ src/Propel/Generator/Command/InitCommand.php | 6 ++ .../Command/MigrationDiffCommand.php | 5 +- .../Generator/Command/SqlBuildCommand.php | 9 ++- .../Generator/Config/GeneratorConfig.php | 2 + .../Generator/Manager/AbstractManager.php | 2 +- src/Propel/Generator/Model/Column.php | 11 +++- src/Propel/Generator/Model/Database.php | 4 +- .../Generator/Model/Diff/ColumnComparator.php | 6 ++ .../Model/Diff/DatabaseComparator.php | 3 + src/Propel/Generator/Model/Domain.php | 19 ++++++- src/Propel/Generator/Model/ForeignKey.php | 2 + .../Generator/Model/MappingModelInterface.php | 2 + src/Propel/Generator/Model/NameFactory.php | 7 ++- src/Propel/Generator/Model/PropelTypes.php | 9 ++- src/Propel/Generator/Model/Schema.php | 2 + .../Generator/Model/ScopedMappingModel.php | 2 + src/Propel/Generator/Model/Table.php | 57 ++++++++++++++++++- src/Propel/Generator/Model/Unique.php | 2 +- src/Propel/Generator/Model/VendorInfo.php | 6 ++ .../Generator/Platform/DefaultPlatform.php | 22 +++++++ .../Generator/Platform/MssqlPlatform.php | 7 +++ .../Generator/Platform/MysqlPlatform.php | 30 +++++++++- .../Generator/Platform/OraclePlatform.php | 11 +++- .../Generator/Platform/PgsqlPlatform.php | 12 +++- .../Generator/Platform/PlatformInterface.php | 16 ++++++ .../Generator/Platform/SqlitePlatform.php | 4 +- .../Reverse/AbstractSchemaParser.php | 4 +- .../Generator/Reverse/MssqlSchemaParser.php | 10 +++- .../Generator/Reverse/MysqlSchemaParser.php | 14 ++++- .../Generator/Reverse/OracleSchemaParser.php | 6 +- .../Generator/Reverse/PgsqlSchemaParser.php | 17 +++++- .../Reverse/SchemaParserInterface.php | 8 ++- .../Generator/Reverse/SqliteSchemaParser.php | 5 ++ src/Propel/Generator/Util/BehaviorLocator.php | 6 ++ src/Propel/Generator/Util/PhpParser.php | 6 ++ src/Propel/Generator/Util/QuickBuilder.php | 13 +++++ src/Propel/Generator/Util/SchemaValidator.php | 2 - src/Propel/Generator/Util/SqlParser.php | 15 +++++ .../Runtime/ActiveQuery/BaseModelCriteria.php | 20 +++++++ src/Propel/Runtime/ActiveQuery/Criteria.php | 27 +++++++-- .../Criterion/AbstractCriterion.php | 11 +++- .../Criterion/AbstractModelCriterion.php | 3 + .../ActiveQuery/Criterion/BasicCriterion.php | 3 + .../ActiveQuery/Criterion/LikeCriterion.php | 3 + .../Criterion/LikeModelCriterion.php | 3 + src/Propel/Runtime/ActiveQuery/Join.php | 37 +++++++++++- .../Runtime/ActiveQuery/ModelCriteria.php | 16 +++++- src/Propel/Runtime/ActiveQuery/ModelJoin.php | 15 ++++- .../Runtime/Adapter/MSSQL/MssqlDebugPDO.php | 3 + .../Runtime/Adapter/SqlAdapterInterface.php | 8 +++ .../Runtime/Collection/ObjectCollection.php | 12 ++-- .../Runtime/Collection/OnDemandIterator.php | 12 ++++ .../Connection/ConnectionManagerInterface.php | 3 + .../Runtime/Connection/ConnectionWrapper.php | 7 ++- src/Propel/Runtime/Connection/DebugPDO.php | 3 + .../Runtime/Connection/StatementWrapper.php | 7 ++- .../Runtime/Connection/TransactionTrait.php | 9 +++ .../DataFetcher/AbstractDataFetcher.php | 4 +- .../Runtime/DataFetcher/ArrayDataFetcher.php | 6 -- .../DataFetcher/DataFetcherInterface.php | 4 ++ .../Runtime/DataFetcher/PDODataFetcher.php | 10 ++-- .../Runtime/Formatter/ArrayFormatter.php | 14 +++-- src/Propel/Runtime/Map/ColumnMap.php | 6 +- src/Propel/Runtime/Map/RelationMap.php | 28 ++++++++- src/Propel/Runtime/Map/TableMap.php | 18 +++++- src/Propel/Runtime/Map/TableMapTrait.php | 7 +++ src/Propel/Runtime/Parser/CsvParser.php | 15 +++++ .../StandardServiceContainer.php | 2 + src/Propel/Runtime/Util/Profiler.php | 17 +++++- .../Runtime/Util/PropelConditionalProxy.php | 22 +++++-- .../Runtime/Validator/Constraints/Date.php | 6 ++ 108 files changed, 883 insertions(+), 116 deletions(-) diff --git a/config/phpcs.xml b/config/phpcs.xml index 996d9bee87..43ebeb7fce 100644 --- a/config/phpcs.xml +++ b/config/phpcs.xml @@ -20,5 +20,12 @@ 0 + + 0 + + + + 0 + diff --git a/src/Propel/Common/Config/ConfigurationManager.php b/src/Propel/Common/Config/ConfigurationManager.php index b5fcb544b3..f020710d70 100644 --- a/src/Propel/Common/Config/ConfigurationManager.php +++ b/src/Propel/Common/Config/ConfigurationManager.php @@ -116,7 +116,7 @@ public function getConfigProperty($name) */ public function getConnectionParametersArray($section = 'runtime') { - if (!in_array($section, ['runtime', 'generator'])) { + if (!in_array($section, ['runtime', 'generator'], true)) { return null; } diff --git a/src/Propel/Common/Config/Loader/IniFileLoader.php b/src/Propel/Common/Config/Loader/IniFileLoader.php index 440c105f2f..362bb82b79 100644 --- a/src/Propel/Common/Config/Loader/IniFileLoader.php +++ b/src/Propel/Common/Config/Loader/IniFileLoader.php @@ -154,7 +154,8 @@ private function parseKey($key, $value, array &$config) if (!strlen($pieces[0]) || !strlen($pieces[1])) { throw new IniParseException(sprintf('Invalid key "%s"', $key)); - } elseif (!isset($config[$pieces[0]])) { + } + if (!isset($config[$pieces[0]])) { if ($pieces[0] === '0' && !empty($config)) { $config = [$pieces[0] => $config]; } else { @@ -168,7 +169,7 @@ private function parseKey($key, $value, array &$config) } $this->parseKey($pieces[1], $value, $config[$pieces[0]]); - } elseif (is_string($value) && in_array(strtolower($value), ['true', 'false'])) { + } elseif (is_string($value) && in_array(strtolower($value), ['true', 'false'], true)) { $config[$key] = (strtolower($value) === 'true'); } elseif ($value === (string)(int)$value) { $config[$key] = (int)$value; diff --git a/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php b/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php index b163329df0..3082df6244 100644 --- a/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php +++ b/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php @@ -21,7 +21,11 @@ */ class AggregateColumnBehavior extends Behavior { - // default parameters value + /** + * Default parameters value + * + * @var array + */ protected $parameters = [ 'name' => null, 'expression' => null, diff --git a/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnRelationBehavior.php b/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnRelationBehavior.php index b58c693078..c587a3c6d6 100644 --- a/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnRelationBehavior.php +++ b/src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnRelationBehavior.php @@ -19,13 +19,20 @@ */ class AggregateColumnRelationBehavior extends Behavior { - // default parameters value + /** + * Default parameters value + * + * @var string[] + */ protected $parameters = [ 'foreign_table' => '', 'update_method' => '', 'aggregate_name' => '', ]; + /** + * @return bool + */ public function allowMultiple() { return true; diff --git a/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php b/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php index 0331a83cbd..3988b8011c 100644 --- a/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php +++ b/src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php @@ -21,7 +21,11 @@ */ class ArchivableBehavior extends Behavior { - // default parameters value + /** + * Default parameters value + * + * @var array + */ protected $parameters = [ 'archive_table' => '', 'archive_phpname' => null, @@ -38,8 +42,14 @@ class ArchivableBehavior extends Behavior */ protected $archiveTable; + /** + * @var \Propel\Generator\Behavior\Archivable\ArchivableBehaviorObjectBuilderModifier|null + */ protected $objectBuilderModifier; + /** + * @var \Propel\Generator\Behavior\Archivable\ArchivableBehaviorQueryBuilderModifier|null + */ protected $queryBuilderModifier; /** diff --git a/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php b/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php index 3de65803e0..82ea61d7de 100644 --- a/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php +++ b/src/Propel/Generator/Behavior/AutoAddPk/AutoAddPkBehavior.php @@ -19,7 +19,11 @@ */ class AutoAddPkBehavior extends Behavior { - // default parameters value + /** + * Default parameters value + * + * @var string[] + */ protected $parameters = [ 'name' => 'id', 'autoIncrement' => 'true', diff --git a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php index 9aab2d4e8c..5a61bd6f86 100644 --- a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php +++ b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php @@ -30,7 +30,11 @@ class ConcreteInheritanceBehavior extends Behavior */ protected $builder; - // default parameters value + /** + * Default parameters value + * + * @var string[] + */ protected $parameters = [ 'extends' => '', 'descendant_column' => 'descendant_class', diff --git a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php index ddb5ab4202..a15500ddc4 100644 --- a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php +++ b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehavior.php @@ -26,7 +26,11 @@ class ConcreteInheritanceParentBehavior extends Behavior */ protected $builder; - // default parameters value + /** + * Default parameters value + * + * @var string[] + */ protected $parameters = [ 'descendant_column' => 'descendant_class', ]; diff --git a/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php b/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php index b1a3b7712e..10e036ad08 100644 --- a/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php +++ b/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php @@ -28,11 +28,18 @@ class DelegateBehavior extends Behavior public const ONE_TO_ONE = 1; public const MANY_TO_ONE = 2; - // default parameters value + /** + * Default parameters value + * + * @var string[] + */ protected $parameters = [ 'to' => '', ]; + /** + * @var int[] + */ protected $delegates = []; /** diff --git a/src/Propel/Generator/Behavior/I18n/I18nBehavior.php b/src/Propel/Generator/Behavior/I18n/I18nBehavior.php index aeab6c16f2..7d84701480 100644 --- a/src/Propel/Generator/Behavior/I18n/I18nBehavior.php +++ b/src/Propel/Generator/Behavior/I18n/I18nBehavior.php @@ -26,7 +26,11 @@ class I18nBehavior extends Behavior { public const DEFAULT_LOCALE = 'en_US'; - // default parameters value + /** + * Default parameters value + * + * @var array + */ protected $parameters = [ 'i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', @@ -38,6 +42,9 @@ class I18nBehavior extends Behavior 'locale_alias' => '', ]; + /** + * @var int + */ protected $tableModificationOrder = 70; /** diff --git a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php index 04ee7d1631..afe57f260c 100644 --- a/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php +++ b/src/Propel/Generator/Behavior/NestedSet/NestedSetBehavior.php @@ -19,7 +19,11 @@ */ class NestedSetBehavior extends Behavior { - // default parameters value + /** + * Default parameters value + * + * @var string[] + */ protected $parameters = [ 'left_column' => 'tree_left', 'right_column' => 'tree_right', @@ -29,8 +33,14 @@ class NestedSetBehavior extends Behavior 'method_proxies' => 'false', ]; + /** + * @var \Propel\Generator\Behavior\NestedSet\NestedSetBehaviorObjectBuilderModifier|null + */ protected $objectBuilderModifier; + /** + * @var \Propel\Generator\Behavior\NestedSet\NestedSetBehaviorQueryBuilderModifier|null + */ protected $queryBuilderModifier; /** diff --git a/src/Propel/Generator/Behavior/QueryCache/QueryCacheBehavior.php b/src/Propel/Generator/Behavior/QueryCache/QueryCacheBehavior.php index 72e31062dd..032fe57c30 100644 --- a/src/Propel/Generator/Behavior/QueryCache/QueryCacheBehavior.php +++ b/src/Propel/Generator/Behavior/QueryCache/QueryCacheBehavior.php @@ -19,10 +19,14 @@ */ class QueryCacheBehavior extends Behavior { - // default parameters value + /** + * Default parameters value + * + * @var string[] + */ protected $parameters = [ 'backend' => 'apc', - 'lifetime' => 3600, + 'lifetime' => '3600', ]; /** diff --git a/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php b/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php index 555b9c2b2d..8b94b50261 100644 --- a/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php +++ b/src/Propel/Generator/Behavior/Sortable/SortableBehavior.php @@ -22,17 +22,30 @@ */ class SortableBehavior extends Behavior { - // default parameters value + /** + * Default parameters value + * + * @var string[] + */ protected $parameters = [ 'rank_column' => 'sortable_rank', 'use_scope' => 'false', 'scope_column' => '', ]; + /** + * @var \Propel\Generator\Behavior\Sortable\SortableBehaviorObjectBuilderModifier|null + */ protected $objectBuilderModifier; + /** + * @var \Propel\Generator\Behavior\Sortable\SortableBehaviorQueryBuilderModifier|null + */ protected $queryBuilderModifier; + /** + * @var \Propel\Generator\Behavior\Sortable\SortableBehaviorTableMapBuilderModifier|null + */ protected $tableMapBuilderModifier; /** diff --git a/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php b/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php index 62e0576ad5..b6d5479ef2 100644 --- a/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php +++ b/src/Propel/Generator/Behavior/Timestampable/TimestampableBehavior.php @@ -20,6 +20,9 @@ */ class TimestampableBehavior extends Behavior { + /** + * @var string[] + */ protected $parameters = [ 'create_column' => 'created_at', 'update_column' => 'updated_at', diff --git a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php index 2f39c17b93..9019910c34 100644 --- a/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php +++ b/src/Propel/Generator/Behavior/Validate/ValidateBehavior.php @@ -23,13 +23,15 @@ class ValidateBehavior extends Behavior { /** - * @var object $builder The current builder + * @var \Propel\Generator\Builder\Om\ObjectBuilder $builder The current builder */ protected $builder; /** * Add behavior methods to model class * + * @param \Propel\Generator\Builder\Om\ObjectBuilder $builder + * * @throws \Propel\Generator\Exception\InvalidArgumentException * * @return string @@ -152,6 +154,8 @@ public function addRuleOnPk() * This method avoid that there are rules with the same name, when adding parameters programmatically. * Useful for Concrete Inheritance behavior. * + * @param array|null $params + * * @return void */ public function mergeParameters(?array $params = null) diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php index 5804de7543..9d011b14c4 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php @@ -20,7 +20,11 @@ */ class VersionableBehavior extends Behavior { - // default parameters value + /** + * Default parameters value + * + * @var string[] + */ protected $parameters = [ 'version_column' => 'version', 'version_table' => '', @@ -38,10 +42,19 @@ class VersionableBehavior extends Behavior */ protected $versionTable; + /** + * @var \Propel\Generator\Behavior\Versionable\VersionableBehaviorObjectBuilderModifier|null + */ protected $objectBuilderModifier; + /** + * @var \Propel\Generator\Behavior\Versionable\VersionableBehaviorQueryBuilderModifier|null + */ protected $queryBuilderModifier; + /** + * @var int + */ protected $tableModificationOrder = 80; /** diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php index aa538d5205..31be2452b7 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifier.php @@ -114,6 +114,8 @@ protected function setBuilder($builder) /** * Get the getter of the column of the behavior * + * @param string $name + * * @return string The related getter, e.g. 'getVersion' */ protected function getColumnGetter($name = 'version_column') @@ -124,6 +126,8 @@ protected function getColumnGetter($name = 'version_column') /** * Get the setter of the column of the behavior * + * @param string $name + * * @return string The related setter, e.g. 'setVersion' */ protected function getColumnSetter($name = 'version_column') diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php index 15f3f7aaba..2f0e0d91c4 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifier.php @@ -117,6 +117,8 @@ protected function setBuilder($builder) /** * Get the getter of the column of the behavior * + * @param string $name + * * @return string The related getter, e.g. 'getVersion' */ protected function getColumnGetter($name = 'version_column') @@ -127,6 +129,8 @@ protected function getColumnGetter($name = 'version_column') /** * Get the setter of the column of the behavior * + * @param string $name + * * @return string The related setter, e.g. 'setVersion' */ protected function getColumnSetter($name = 'version_column') diff --git a/src/Propel/Generator/Builder/DataModelBuilder.php b/src/Propel/Generator/Builder/DataModelBuilder.php index 937f0f2cdd..86aabf3361 100644 --- a/src/Propel/Generator/Builder/DataModelBuilder.php +++ b/src/Propel/Generator/Builder/DataModelBuilder.php @@ -541,6 +541,8 @@ public function getWarnings() * * @see OMBuilder#getClassName() * + * @param string $identifier + * * @return string */ public function prefixClassName($identifier) diff --git a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php index bb06aac731..f015640f2b 100644 --- a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php @@ -110,6 +110,9 @@ protected function validateModel() * Creates a $obj = new Book(); code snippet. Can be used by frameworks, for instance, to * extend this behavior, e.g. initialize the object after creating the instance or so. * + * @param string $objName + * @param string $clsName + * * @return string Some code */ public function buildObjectInstanceCreationCode($objName, $clsName) @@ -878,6 +881,8 @@ protected function getCrossFKVarName(ForeignKey $crossFK) * one column in a table that points to the same foreign table, then a 'RelatedByLocalColName' suffix * will be appended. * + * @param \Propel\Generator\Model\ForeignKey $fk + * * @throws \Propel\Generator\Exception\RuntimeException * * @return string @@ -937,6 +942,13 @@ public function getRefFKPhpNameAffix(ForeignKey $fk, $plural = false) return $className . $this->getRefRelatedBySuffix($fk); } + /** + * @param \Propel\Generator\Model\ForeignKey $fk + * + * @throws \Propel\Generator\Exception\RuntimeException + * + * @return string + */ protected static function getRefRelatedBySuffix(ForeignKey $fk) { $relCol = ''; @@ -995,6 +1007,7 @@ public function hasBehaviorModifier($hookName, $modifier) * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string $modifier The name of the modifier object providing the method in the behavior * @param string $script The script will be modified in this method. + * @param string $tab * * @return void */ diff --git a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php index 98f75176c5..fe4ca0516c 100644 --- a/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractObjectBuilder.php @@ -144,6 +144,8 @@ protected function getInterface() * Whether to add the generic mutator methods (setByName(), setByPosition(), fromArray()). * This is based on the build property propel.addGenericMutators, and also whether the * table is read-only or an alias. + * + * @return bool */ protected function isAddGenericMutators() { @@ -156,6 +158,8 @@ protected function isAddGenericMutators() * Whether to add the generic accessor methods (getByName(), getByPosition(), toArray()). * This is based on the build property propel.addGenericAccessors, and also whether the * table is an alias. + * + * @return bool */ protected function isAddGenericAccessors() { diff --git a/src/Propel/Generator/Builder/Om/ClassTools.php b/src/Propel/Generator/Builder/Om/ClassTools.php index 32f8bbb776..8a1d340c2f 100644 --- a/src/Propel/Generator/Builder/Om/ClassTools.php +++ b/src/Propel/Generator/Builder/Om/ClassTools.php @@ -64,6 +64,8 @@ public static function createFilePath($path, $classname = null, $extension = '.p /** * Gets the baseClass path if specified for table/db. * + * @param \Propel\Generator\Model\Table $table + * * @return string */ public static function getBaseClass(Table $table) @@ -74,6 +76,8 @@ public static function getBaseClass(Table $table) /** * Gets the interface path if specified for table. * + * @param \Propel\Generator\Model\Table $table + * * @return string */ public static function getInterface(Table $table) @@ -102,6 +106,9 @@ public static function getPhpReservedWords() ]; } + /** + * @return string[] + */ public static function getPropelReservedMethods() { return [ diff --git a/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php index 4ac5a062aa..b651c25339 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionObjectBuilder.php @@ -78,6 +78,8 @@ protected function addClassOpen(&$script) * * @see ObjectBuilder::addClassBody() * + * @param string $script + * * @return void */ protected function addClassBody(&$script) diff --git a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php index 30634edca9..539bc07fb9 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionQueryBuilder.php @@ -79,6 +79,8 @@ class " . $this->getUnqualifiedClassName() . " extends $baseClassName * * @see QueryBuilder::addClassBody() * + * @param string $script + * * @return void */ protected function addClassBody(&$script) @@ -104,6 +106,7 @@ protected function addClassClose(&$script) * Checks whether any registered behavior on that table has a modifier for a hook * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" + * @param string $modifier * * @return bool */ diff --git a/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php b/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php index c4c3147c7e..70be714739 100644 --- a/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php +++ b/src/Propel/Generator/Builder/Om/ExtensionQueryInheritanceBuilder.php @@ -25,6 +25,8 @@ class ExtensionQueryInheritanceBuilder extends AbstractOMBuilder { /** * The current child "object" we are operating on. + * + * @var \Propel\Generator\Model\Inheritance|null */ protected $child; diff --git a/src/Propel/Generator/Builder/Om/InterfaceBuilder.php b/src/Propel/Generator/Builder/Om/InterfaceBuilder.php index 94be15ec46..19b696749b 100644 --- a/src/Propel/Generator/Builder/Om/InterfaceBuilder.php +++ b/src/Propel/Generator/Builder/Om/InterfaceBuilder.php @@ -75,6 +75,8 @@ interface " . $this->getUnqualifiedClassName() . " * * @see ObjectBuilder::addClassBody() * + * @param string $script + * * @return void */ protected function addClassBody(&$script) @@ -95,4 +97,4 @@ protected function addClassClose(&$script) } // " . $this->getUnqualifiedClassName() . " "; } -} // ExtensionObjectBuilder +} diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index 8a708980f3..0500308522 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -1868,8 +1868,8 @@ protected function addMutatorCloseBody(&$script, Column $column) \$this->$varName = null; } "; - } // foreach fk - } /* if col is foreign key */ + } + } foreach ($column->getReferrers() as $refFK) { $tblFK = $this->getDatabase()->getTable($refFK->getForeignTableName()); @@ -1898,10 +1898,10 @@ protected function addMutatorCloseBody(&$script, Column $column) } } "; - } // if (isLocalPrimaryKey - } // foreach col->getPrimaryKeys() - } // if tablFk != table - } // foreach + } + } + } + } } /** @@ -2684,8 +2684,8 @@ protected function addHydrateBody(&$script) \$this->$clo = \$col;"; } $n++; - } // if col->isLazyLoad() - } /* foreach */ + } + } if ($this->getBuildProperty('generator.objectModel.addSaveMethod')) { $script .= " @@ -3032,6 +3032,12 @@ public function toArray(\$keyType = TableMap::$defaultKeyType, \$includeLazyLoad * Adds the switch-statement for looking up the array-key name for toArray * * @see toArray + * + * @param string $phpName + * @param \Propel\Generator\Model\Table $table + * @param bool $plural + * + * @return string */ protected function addToArrayKeyLookUp($phpName, Table $table, $plural) { @@ -4699,6 +4705,9 @@ public function get$relCol(Criteria \$criteria = null, ConnectionInterface \$con // addRefererGet() /** + * @param string $script + * @param \Propel\Generator\Model\ForeignKey $refFK + * * @return void */ protected function addRefFKSet(&$script, ForeignKey $refFK) @@ -5548,6 +5557,8 @@ public function create{$firstFkName}Query($signature, Criteria \$criteria = null /** * @param string $script * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * + * @return void */ protected function addCrossFKGet(&$script, CrossForeignKeys $crossFKs) { @@ -5826,11 +5837,13 @@ public function set{$relatedNamePlural}(Collection \${$inputCollection}, Connect /** * @param string $script * @param \Propel\Generator\Model\CrossForeignKeys $crossFKs + * + * @return void */ protected function addCrossFKCount(&$script, CrossForeignKeys $crossFKs) { $refFK = $crossFKs->getIncomingForeignKey(); - $selfRelationName = $this->getFKPhpNameAffix($refFK, $plural = false); + $selfRelationName = $this->getFKPhpNameAffix($refFK, false); $multi = 1 < count($crossFKs->getCrossForeignKeys()) || (bool)$crossFKs->getUnclassifiedPrimaryKeys(); @@ -6472,6 +6485,8 @@ protected function addDoInsertBodyWithIdMethod() * Boosts ActiveRecord::doInsert() by doing more calculations at buildtime. * * @throws \Propel\Runtime\Exception\PropelException + * + * @return string */ protected function addDoInsertBodyRaw() { diff --git a/src/Propel/Generator/Builder/Om/QueryBuilder.php b/src/Propel/Generator/Builder/Om/QueryBuilder.php index 8a777fb46a..0150524817 100644 --- a/src/Propel/Generator/Builder/Om/QueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryBuilder.php @@ -234,6 +234,8 @@ abstract class " . $this->getUnqualifiedClassName() . ' extends ' . $parentClass * * @see ObjectBuilder::addClassBody() * + * @param string $script + * * @return void */ protected function addClassBody(&$script) @@ -309,6 +311,8 @@ protected function addClassBody(&$script) * Adds the entityNotFoundExceptionClass property which is necessary for the `requireOne` method * of the `ModelCriteria` * + * @param string $script + * * @return void */ protected function addEntityNotFoundExceptionClass(&$script) @@ -1486,6 +1490,10 @@ protected function addJoinRefFk(&$script, ForeignKey $fk) * Adds a joinRelated method for this object. * * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\Table|null $fkTable + * @param string $queryClass + * @param string $relationName + * @param string $joinType * * @return void */ @@ -1568,6 +1576,10 @@ protected function addUseRefFkQuery(&$script, ForeignKey $fk) * Adds a useRelatedQuery method for this object. * * @param string $script The script will be modified in this method. + * @param \Propel\Generator\Model\Table $fkTable + * @param string $queryClass + * @param string $relationName + * @param string $joinType * * @return void */ @@ -1839,6 +1851,7 @@ protected function basePostUpdate(\$affectedRows, ConnectionInterface \$con) * Checks whether any registered behavior on that table has a modifier for a hook * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" + * @param string $modifier * * @return bool */ @@ -1852,6 +1865,9 @@ public function hasBehaviorModifier($hookName, $modifier = '') * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string $script The script will be modified in this method. + * @param string $tab + * + * @return string */ public function applyBehaviorModifier($hookName, &$script, $tab = ' ') { diff --git a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php index c92c6b3b8f..c3fec528ef 100644 --- a/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php @@ -26,6 +26,8 @@ class QueryInheritanceBuilder extends AbstractOMBuilder { /** * The current child "object" we are operating on. + * + * @var \Propel\Generator\Model\Inheritance|null */ protected $child; diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index a49d1fa6ba..a393ce19d3 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -1255,7 +1255,7 @@ public static function addSelectColumns(Criteria \$criteria, \$alias = null) $script .= " \$criteria->addSelectColumn({$col->getFQConstantName()});"; } // if !col->isLazyLoad - } // foreach + } $script .= " } else {"; foreach ($this->getTable()->getColumns() as $col) { @@ -1263,7 +1263,7 @@ public static function addSelectColumns(Criteria \$criteria, \$alias = null) $script .= " \$criteria->addSelectColumn(\$alias . '." . $col->getName() . "');"; } // if !col->isLazyLoad - } // foreach + } $script .= " }"; $script .= " diff --git a/src/Propel/Generator/Builder/Util/PropelTemplate.php b/src/Propel/Generator/Builder/Util/PropelTemplate.php index 4fb460f516..d5dd022e98 100644 --- a/src/Propel/Generator/Builder/Util/PropelTemplate.php +++ b/src/Propel/Generator/Builder/Util/PropelTemplate.php @@ -75,6 +75,8 @@ public function setTemplateFile($filePath) * * @param array $vars An associative array of arguments to be rendered * + * @throws InvalidArgumentException + * * @return string The rendered template */ public function render($vars = []) diff --git a/src/Propel/Generator/Builder/Util/SchemaReader.php b/src/Propel/Generator/Builder/Util/SchemaReader.php index e3f09d7f44..fcc39be53b 100644 --- a/src/Propel/Generator/Builder/Util/SchemaReader.php +++ b/src/Propel/Generator/Builder/Util/SchemaReader.php @@ -87,12 +87,24 @@ class SchemaReader */ private $currentPackage; + /** + * @var string|null + */ private $currentXmlFile; + /** + * @var string|null + */ private $defaultPackage; + /** + * @var bool + */ private $firstPass; + /** + * @var string + */ private $encoding; /** diff --git a/src/Propel/Generator/Command/AbstractCommand.php b/src/Propel/Generator/Command/AbstractCommand.php index a32434b598..003341efeb 100644 --- a/src/Propel/Generator/Command/AbstractCommand.php +++ b/src/Propel/Generator/Command/AbstractCommand.php @@ -29,6 +29,9 @@ abstract class AbstractCommand extends Command public const CODE_SUCCESS = 0; public const CODE_ERROR = 1; + /** + * @var \Symfony\Component\Filesystem\Filesystem|null + */ protected $filesystem; /** @@ -125,7 +128,7 @@ protected function createDirectory($directory) /** * Parse a connection string and return an array with name, dsn and extra informations * - * @parama string $connection The connection string + * @param string $connection The connection string * * @return array */ diff --git a/src/Propel/Generator/Command/Console/Input/ArrayInput.php b/src/Propel/Generator/Command/Console/Input/ArrayInput.php index 2659cc45d9..54bc277819 100644 --- a/src/Propel/Generator/Command/Console/Input/ArrayInput.php +++ b/src/Propel/Generator/Command/Console/Input/ArrayInput.php @@ -154,6 +154,9 @@ protected function parse() /** * Adds a short option value. * + * @param string $shortcut + * @param mixed|null $value + * * @throws \Symfony\Component\Console\Exception\InvalidOptionException When option given doesn't exist * * @return void @@ -170,9 +173,10 @@ private function addShortOption(string $shortcut, $value) /** * Adds a long option value. * - * @throws \Symfony\Component\Console\Exception\InvalidOptionException When option given doesn't exist - * @throws \Symfony\Component\Console\Exception\InvalidOptionException When a required value is missing + * @param string $name + * @param mixed|null $value * + * @throws \Symfony\Component\Console\Exception\InvalidOptionException When a required value is missing * @return void */ private function addLongOption(string $name, $value) diff --git a/src/Propel/Generator/Command/Helper/ConsoleHelper.php b/src/Propel/Generator/Command/Helper/ConsoleHelper.php index 55738b3383..730161380f 100644 --- a/src/Propel/Generator/Command/Helper/ConsoleHelper.php +++ b/src/Propel/Generator/Command/Helper/ConsoleHelper.php @@ -8,8 +8,14 @@ class ConsoleHelper extends Symfony23DialogHelper implements ConsoleHelperInterface { + /** + * @var \Symfony\Component\Console\Input\InputInterface + */ protected $input; + /** + * @var \Symfony\Component\Console\Output\OutputInterface + */ protected $output; /** diff --git a/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php b/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php index 55a8cf9bbc..5b059f3dbd 100644 --- a/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php +++ b/src/Propel/Generator/Command/Helper/ConsoleHelperInterface.php @@ -45,6 +45,11 @@ public function writeSection($text); */ public function writeBlock($text, $style = 'info'); + /** + * @param string[] $items + * + * @return void + */ public function writeSummary($items); /** diff --git a/src/Propel/Generator/Command/InitCommand.php b/src/Propel/Generator/Command/InitCommand.php index 00df1123ea..068c65845f 100644 --- a/src/Propel/Generator/Command/InitCommand.php +++ b/src/Propel/Generator/Command/InitCommand.php @@ -27,8 +27,14 @@ */ class InitCommand extends AbstractCommand { + /** + * @var string + */ private $defaultSchemaDir; + /** + * @var string + */ private $defaultPhpDir; /** diff --git a/src/Propel/Generator/Command/MigrationDiffCommand.php b/src/Propel/Generator/Command/MigrationDiffCommand.php index 8bf80f5d00..11761bb751 100644 --- a/src/Propel/Generator/Command/MigrationDiffCommand.php +++ b/src/Propel/Generator/Command/MigrationDiffCommand.php @@ -110,7 +110,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int foreach ($manager->getDatabases() as $appDatabase) { $name = $appDatabase->getName(); - if (!$params = @$connections[$name]) { + $params = $connections[$name] ?? []; + if (!$params) { $output->writeln(sprintf('No connection configured for database "%s"', $name)); } @@ -121,7 +122,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $conn = $manager->getAdapterConnection($name); $platform = $generatorConfig->getConfiguredPlatform($conn, $name); - if (!$platform->supportsMigrations()) { + if ($platform && !$platform->supportsMigrations()) { $output->writeln(sprintf('Skipping database "%s" since vendor "%s" does not support migrations', $name, $platform->getDatabaseType())); continue; diff --git a/src/Propel/Generator/Command/SqlBuildCommand.php b/src/Propel/Generator/Command/SqlBuildCommand.php index 8e3534e34f..08facd96b7 100644 --- a/src/Propel/Generator/Command/SqlBuildCommand.php +++ b/src/Propel/Generator/Command/SqlBuildCommand.php @@ -57,22 +57,27 @@ protected function execute(InputInterface $input, OutputInterface $output): int $configOptions['propel']['paths']['schemaDir'] = $option; break; + case 'output-dir': $configOptions['propel']['paths']['sqlDir'] = $option; break; - case 'schema-name'; + + case 'schema-name': $configOptions['propel']['generator']['schema']['basename'] = $option; break; + case 'table-prefix': $configOptions['propel']['generator']['tablePrefix'] = $option; break; - case 'mysql-engine'; + + case 'mysql-engine': $configOptions['propel']['database']['adapters']['mysql']['tableType'] = $option; break; + case 'composer-dir': $configOptions['propel']['paths']['composerDir'] = $option; diff --git a/src/Propel/Generator/Config/GeneratorConfig.php b/src/Propel/Generator/Config/GeneratorConfig.php index 773c7178f6..50de74e5fb 100644 --- a/src/Propel/Generator/Config/GeneratorConfig.php +++ b/src/Propel/Generator/Config/GeneratorConfig.php @@ -272,6 +272,8 @@ public function getBehaviorLocator() * @throws \Propel\Generator\Exception\ClassNotFoundException if the class doesn't exists * @throws \Propel\Generator\Exception\InvalidArgumentException if the interface doesn't exists * @throws \Propel\Generator\Exception\BuildException if the class isn't an implementation of the given interface + * + * @return object */ private function getInstance($className, $arguments = null, $interfaceName = null) { diff --git a/src/Propel/Generator/Manager/AbstractManager.php b/src/Propel/Generator/Manager/AbstractManager.php index 16bdd34ae1..f95555fdd6 100644 --- a/src/Propel/Generator/Manager/AbstractManager.php +++ b/src/Propel/Generator/Manager/AbstractManager.php @@ -223,7 +223,7 @@ public function getDatabase($name) { $dbs = $this->getDatabases(); - return @$dbs[$name]; + return $dbs[$name] ?? null; } /** diff --git a/src/Propel/Generator/Model/Column.php b/src/Propel/Generator/Model/Column.php index d7000dc75a..9533eaedb5 100644 --- a/src/Propel/Generator/Model/Column.php +++ b/src/Propel/Generator/Model/Column.php @@ -32,7 +32,14 @@ class Column extends MappingModel public const DEFAULT_VISIBILITY = 'public'; public const CONSTANT_PREFIX = 'COL_'; - public static $validVisibilities = [ 'public', 'protected', 'private' ]; + /** + * @var string[] + */ + public static $validVisibilities = [ + 'public', + 'protected', + 'private', + ]; /** * @var string|null @@ -1423,7 +1430,7 @@ public function setScale($scale) * * Example: (size[,scale]) <-> (10) or (10,2) * - * return string + * @return string */ public function getSizeDefinition() { diff --git a/src/Propel/Generator/Model/Database.php b/src/Propel/Generator/Model/Database.php index 5d5fa43988..d6150e3854 100644 --- a/src/Propel/Generator/Model/Database.php +++ b/src/Propel/Generator/Model/Database.php @@ -257,7 +257,7 @@ public function getBaseQueryClass() * Sets the name of the base super class inherited by active record objects. * This parameter is overridden at the table level. * - * @param string $class. + * @param string $class * * @return void */ @@ -270,7 +270,7 @@ public function setBaseClass($class) * Sets the name of the base super class inherited by query objects. * This parameter is overridden at the table level. * - * @param string $class. + * @param string $class * * @return void */ diff --git a/src/Propel/Generator/Model/Diff/ColumnComparator.php b/src/Propel/Generator/Model/Diff/ColumnComparator.php index ec99bf2db6..c1e29e2c21 100644 --- a/src/Propel/Generator/Model/Diff/ColumnComparator.php +++ b/src/Propel/Generator/Model/Diff/ColumnComparator.php @@ -45,6 +45,12 @@ public static function computeDiff(Column $fromColumn, Column $toColumn) return false; } + /** + * @param \Propel\Generator\Model\Column $fromColumn + * @param \Propel\Generator\Model\Column $toColumn + * + * @return array + */ public static function compareColumns(Column $fromColumn, Column $toColumn) { $changedProperties = []; diff --git a/src/Propel/Generator/Model/Diff/DatabaseComparator.php b/src/Propel/Generator/Model/Diff/DatabaseComparator.php index 5c1c198264..c5caf013ed 100644 --- a/src/Propel/Generator/Model/Diff/DatabaseComparator.php +++ b/src/Propel/Generator/Model/Diff/DatabaseComparator.php @@ -161,6 +161,9 @@ public function getExcludedTables() * @param \Propel\Generator\Model\Database $fromDatabase * @param \Propel\Generator\Model\Database $toDatabase * @param bool $caseInsensitive + * @param bool $withRenaming + * @param bool $removeTable + * @param array $excludedTables * * @return \Propel\Generator\Model\Diff\DatabaseDiff|bool */ diff --git a/src/Propel/Generator/Model/Domain.php b/src/Propel/Generator/Model/Domain.php index 081d88b2a1..810e06ffa9 100644 --- a/src/Propel/Generator/Model/Domain.php +++ b/src/Propel/Generator/Model/Domain.php @@ -23,10 +23,19 @@ */ class Domain extends MappingModel { + /** + * @var string + */ private $name; + /** + * @var string + */ private $description; + /** + * @var int|null + */ private $size; /** @@ -34,8 +43,14 @@ class Domain extends MappingModel */ private $scale; + /** + * @var string|null + */ private $mappingType; + /** + * @var string|null + */ private $sqlType; /** @@ -205,7 +220,7 @@ public function setScale($scale) /** * Replaces the size if the new value is not null. * - * @param int $scale + * @param int|null $scale * * @return void */ @@ -277,7 +292,7 @@ public function setType($mappingType) /** * Replaces the mapping type if the new value is not null. * - * @param string $mappingType + * @param string|null $mappingType * * @return void */ diff --git a/src/Propel/Generator/Model/ForeignKey.php b/src/Propel/Generator/Model/ForeignKey.php index 4d48ab8713..88e38acb8e 100644 --- a/src/Propel/Generator/Model/ForeignKey.php +++ b/src/Propel/Generator/Model/ForeignKey.php @@ -754,6 +754,8 @@ public function getForeignColumnName($index = 0) /** * Returns a foreign column object. * + * @param int $index + * * @return \Propel\Generator\Model\Column */ public function getForeignColumn($index = 0) diff --git a/src/Propel/Generator/Model/MappingModelInterface.php b/src/Propel/Generator/Model/MappingModelInterface.php index b8737310db..e1eb01c503 100644 --- a/src/Propel/Generator/Model/MappingModelInterface.php +++ b/src/Propel/Generator/Model/MappingModelInterface.php @@ -26,6 +26,8 @@ interface MappingModelInterface * Loads a model definition from an array. * * @param array $attributes + * + * @return void */ public function loadMapping(array $attributes); } diff --git a/src/Propel/Generator/Model/NameFactory.php b/src/Propel/Generator/Model/NameFactory.php index f91ef8cb4a..42d536df88 100644 --- a/src/Propel/Generator/Model/NameFactory.php +++ b/src/Propel/Generator/Model/NameFactory.php @@ -30,9 +30,10 @@ class NameFactory public const CONSTRAINT_GENERATOR = '\Propel\Generator\Model\ConstraintNameGenerator'; /** - * @var array * The cache of NameGeneratorInterface algorithms in use for * name generation, keyed by fully qualified class name. + * + * @var \Propel\Generator\Model\NameGeneratorInterface[] */ private static $algorithms = []; @@ -41,6 +42,8 @@ class NameFactory * * @param string $name The fully qualified class name of the name * generation algorithm to retrieve. + * + * @return \Propel\Generator\Model\NameGeneratorInterface */ protected static function getAlgorithm($name) { @@ -57,7 +60,7 @@ protected static function getAlgorithm($name) * * @param string $algorithmName The fully qualified class name of the {@link NameGeneratorInterface} * implementation to use to generate names. - * @param array $inputs Inputs used to generate a name. + * @param string[] $inputs Inputs used to generate a name. * * @return string The generated name. */ diff --git a/src/Propel/Generator/Model/PropelTypes.php b/src/Propel/Generator/Model/PropelTypes.php index 95ca8f8e3e..2027a55ec9 100644 --- a/src/Propel/Generator/Model/PropelTypes.php +++ b/src/Propel/Generator/Model/PropelTypes.php @@ -171,7 +171,7 @@ class PropelTypes * Mapping between mapping types and PDO type constants (for prepared * statement settings). * - * @var array + * @var int[] */ private static $mappingTypeToPDOTypeMap = [ self::CHAR => PDO::PARAM_STR, @@ -211,6 +211,9 @@ class PropelTypes self::JSON => PDO::PARAM_STR, ]; + /** + * @var string[] + */ private static $pdoTypeNames = [ PDO::PARAM_BOOL => 'PDO::PARAM_BOOL', PDO::PARAM_NULL => 'PDO::PARAM_NULL', @@ -235,6 +238,8 @@ public static function getPhpNative($mappingType) /** * Returns the PDO type (PDO::PARAM_* constant) value. * + * @param string $type + * * @return int */ public static function getPDOType($type) @@ -245,6 +250,8 @@ public static function getPDOType($type) /** * Returns the PDO type ('PDO::PARAM_*' constant) name. * + * @param string $type + * * @return string */ public static function getPdoTypeString($type) diff --git a/src/Propel/Generator/Model/Schema.php b/src/Propel/Generator/Model/Schema.php index 4bf87b7353..7365f98bed 100644 --- a/src/Propel/Generator/Model/Schema.php +++ b/src/Propel/Generator/Model/Schema.php @@ -339,6 +339,8 @@ public function toString() * Magic string method * * @see toString() + * + * @return string */ public function __toString() { diff --git a/src/Propel/Generator/Model/ScopedMappingModel.php b/src/Propel/Generator/Model/ScopedMappingModel.php index 63e088c3b1..b1493f8a37 100644 --- a/src/Propel/Generator/Model/ScopedMappingModel.php +++ b/src/Propel/Generator/Model/ScopedMappingModel.php @@ -60,6 +60,8 @@ public function isPackageOverriden() * Returns a build property by its name. * * @param string $name + * + * @return string */ abstract protected function getBuildProperty($name); diff --git a/src/Propel/Generator/Model/Table.php b/src/Propel/Generator/Model/Table.php index 2ad07ebce9..607bea7659 100644 --- a/src/Propel/Generator/Model/Table.php +++ b/src/Propel/Generator/Model/Table.php @@ -67,18 +67,39 @@ class Table extends ScopedMappingModel implements IdMethod */ private $idMethodParameters = []; + /** + * @var string + */ private $commonName; + /** + * @var string + */ private $originCommonName; + /** + * @var string + */ private $description; + /** + * @var string + */ private $phpName; + /** + * @var string + */ private $idMethod; + /** + * @var bool + */ private $allowPkInsert = false; + /** + * @var string|null + */ private $phpNamingMethod; /** @@ -101,26 +122,59 @@ class Table extends ScopedMappingModel implements IdMethod */ private $inheritanceColumn; + /** + * @var bool + */ private $skipSql = false; + /** + * @var bool + */ private $readOnly = false; + /** + * @var bool + */ private $isAbstract = false; + /** + * @var string|null + */ private $alias; + /** + * @var string|null + */ private $interface; + /** + * @var string|null + */ private $baseClass; + /** + * @var string|null + */ private $baseQueryClass; + /** + * @var array + */ private $columnsByName = []; + /** + * @var array + */ private $columnsByLowercaseName = []; + /** + * @var array + */ private $columnsByPhpName = []; + /** + * @var bool + */ private $needsTransactionInPostgres = false; /** @@ -1071,7 +1125,8 @@ public function addIndex($index) $idx = new Index(); $idx->loadMapping($index); - foreach ((array)@$index['columns'] as $column) { + $columns = !empty($index['columns']) ? (array)$index['columns'] : []; + foreach ($columns as $column) { $idx->addColumn($column); } diff --git a/src/Propel/Generator/Model/Unique.php b/src/Propel/Generator/Model/Unique.php index ef1a2dec06..1dbc96ffbe 100644 --- a/src/Propel/Generator/Model/Unique.php +++ b/src/Propel/Generator/Model/Unique.php @@ -27,7 +27,7 @@ class Unique extends Index /** * Returns whether or not this index is unique. * - * Returns Boolean + * @return bool */ public function isUnique() { diff --git a/src/Propel/Generator/Model/VendorInfo.php b/src/Propel/Generator/Model/VendorInfo.php index 623d68f12e..b62fd4487d 100644 --- a/src/Propel/Generator/Model/VendorInfo.php +++ b/src/Propel/Generator/Model/VendorInfo.php @@ -18,8 +18,14 @@ */ class VendorInfo extends MappingModel { + /** + * @var string|null + */ private $type; + /** + * @var array + */ private $parameters; /** diff --git a/src/Propel/Generator/Platform/DefaultPlatform.php b/src/Propel/Generator/Platform/DefaultPlatform.php index aed04a3dd4..ab136cf7bc 100644 --- a/src/Propel/Generator/Platform/DefaultPlatform.php +++ b/src/Propel/Generator/Platform/DefaultPlatform.php @@ -232,6 +232,8 @@ public function getDomainForType($mappingType) /** * Returns the NOT NULL string for the configured RDBMS. * + * @param bool $notNull + * * @return string */ public function getNullString($notNull) @@ -332,6 +334,8 @@ public function getEndDDL() /** * Builds the DDL SQL to drop a table * + * @param \Propel\Generator\Model\Table $table + * * @return string */ public function getDropTableDDL(Table $table) @@ -345,6 +349,8 @@ public function getDropTableDDL(Table $table) * Builds the DDL SQL to add a table * without index and foreign keys * + * @param \Propel\Generator\Model\Table $table + * * @return string */ public function getAddTableDDL(Table $table) @@ -386,6 +392,8 @@ public function getAddTableDDL(Table $table) /** * Builds the DDL SQL for a Column object. * + * @param \Propel\Generator\Model\Column $col + * * @return string */ public function getColumnDDL(Column $col) @@ -415,6 +423,8 @@ public function getColumnDDL(Column $col) /** * Returns the SQL for the default value of a Column object * + * @param \Propel\Generator\Model\Column $col + * * @return string */ public function getColumnDefaultValueDDL(Column $col) @@ -483,6 +493,8 @@ public function getColumnListDDL($columns, $delimiter = ',') /** * Returns the name of a table primary key. * + * @param \Propel\Generator\Model\Table $table + * * @return string */ public function getPrimaryKeyName(Table $table) @@ -495,6 +507,8 @@ public function getPrimaryKeyName(Table $table) /** * Returns the SQL for the primary key of a Table object. * + * @param \Propel\Generator\Model\Table $table + * * @return string */ public function getPrimaryKeyDDL(Table $table) @@ -941,6 +955,8 @@ public function getModifyTableDDL(TableDiff $tableDiff) * Builds the DDL SQL to alter a table * based on a TableDiff instance * + * @param \Propel\Generator\Model\Diff\TableDiff $tableDiff + * * @return string */ public function getModifyTableColumnsDDL(TableDiff $tableDiff) @@ -970,6 +986,8 @@ public function getModifyTableColumnsDDL(TableDiff $tableDiff) * Builds the DDL SQL to alter a table's primary key * based on a TableDiff instance * + * @param \Propel\Generator\Model\Diff\TableDiff $tableDiff + * * @return string */ public function getModifyTablePrimaryKeyDDL(TableDiff $tableDiff) @@ -988,6 +1006,8 @@ public function getModifyTablePrimaryKeyDDL(TableDiff $tableDiff) * Builds the DDL SQL to alter a table's indices * based on a TableDiff instance * + * @param \Propel\Generator\Model\Diff\TableDiff $tableDiff + * * @return string */ public function getModifyTableIndicesDDL(TableDiff $tableDiff) @@ -1015,6 +1035,8 @@ public function getModifyTableIndicesDDL(TableDiff $tableDiff) * Builds the DDL SQL to alter a table's foreign keys * based on a TableDiff instance * + * @param \Propel\Generator\Model\Diff\TableDiff $tableDiff + * * @return string */ public function getModifyTableForeignKeysDDL(TableDiff $tableDiff) diff --git a/src/Propel/Generator/Platform/MssqlPlatform.php b/src/Propel/Generator/Platform/MssqlPlatform.php index 48fda53659..4114ad7d4b 100644 --- a/src/Propel/Generator/Platform/MssqlPlatform.php +++ b/src/Propel/Generator/Platform/MssqlPlatform.php @@ -26,6 +26,9 @@ */ class MssqlPlatform extends DefaultPlatform { + /** + * @var int + */ protected static $dropCount = 0; /** @@ -97,6 +100,8 @@ public function supportsInsertNullPk() * Since MSSQL always checks it the tables in foreign key definitions exist, * the foreign key DDLs are moved after all tables are created * + * @param \Propel\Generator\Model\Database $database + * * @return string */ public function getAddTablesDDL(Database $database) @@ -260,6 +265,8 @@ public function getForeignKeyDDL(ForeignKey $fk) /** * @see Platform::supportsSchemas() + * + * @return bool */ public function supportsSchemas() { diff --git a/src/Propel/Generator/Platform/MysqlPlatform.php b/src/Propel/Generator/Platform/MysqlPlatform.php index fceec8f1e0..921623ab02 100644 --- a/src/Propel/Generator/Platform/MysqlPlatform.php +++ b/src/Propel/Generator/Platform/MysqlPlatform.php @@ -32,13 +32,16 @@ */ class MysqlPlatform extends DefaultPlatform { + /** + * @var string + */ protected $tableEngineKeyword = 'ENGINE'; - // overwritten in propel config + /** + * @var string + */ protected $defaultTableEngine = 'InnoDB'; - // overwritten in propel config - /** * Initializes db specific domain mapping. * @@ -573,6 +576,8 @@ public function getDropIndexDDL(Index $index) /** * Builds the DDL SQL for an Index object. * + * @param \Propel\Generator\Model\Index $index + * * @return string */ public function getIndexDDL(Index $index) @@ -691,6 +696,8 @@ public function getCommentBlockDDL($comment) * Builds the DDL SQL to modify a database * based on a DatabaseDiff instance * + * @param \Propel\Generator\Model\Diff\DatabaseDiff $databaseDiff + * * @return string */ public function getModifyDatabaseDDL(DatabaseDiff $databaseDiff) @@ -723,6 +730,9 @@ public function getModifyDatabaseDDL(DatabaseDiff $databaseDiff) /** * Builds the DDL SQL to rename a table * + * @param string $fromTableName + * @param string $toTableName + * * @return string */ public function getRenameTableDDL($fromTableName, $toTableName) @@ -741,6 +751,8 @@ public function getRenameTableDDL($fromTableName, $toTableName) /** * Builds the DDL SQL to remove a column * + * @param \Propel\Generator\Model\Column $column + * * @return string */ public function getRemoveColumnDDL(Column $column) @@ -759,6 +771,9 @@ public function getRemoveColumnDDL(Column $column) /** * Builds the DDL SQL to rename a column * + * @param \Propel\Generator\Model\Column $fromColumn + * @param \Propel\Generator\Model\Column $toColumn + * * @return string */ public function getRenameColumnDDL(Column $fromColumn, Column $toColumn) @@ -769,6 +784,8 @@ public function getRenameColumnDDL(Column $fromColumn, Column $toColumn) /** * Builds the DDL SQL to modify a column * + * @param \Propel\Generator\Model\Diff\ColumnDiff $columnDiff + * * @return string */ public function getModifyColumnDDL(ColumnDiff $columnDiff) @@ -779,6 +796,9 @@ public function getModifyColumnDDL(ColumnDiff $columnDiff) /** * Builds the DDL SQL to change a column * + * @param \Propel\Generator\Model\Column $fromColumn + * @param \Propel\Generator\Model\Column $toColumn + * * @return string */ public function getChangeColumnDDL(Column $fromColumn, Column $toColumn) @@ -798,6 +818,8 @@ public function getChangeColumnDDL(Column $fromColumn, Column $toColumn) /** * Builds the DDL SQL to modify a list of columns * + * @param \Propel\Generator\Model\Diff\ColumnDiff[] $columnDiffs + * * @return string */ public function getModifyColumnsDDL($columnDiffs) @@ -865,6 +887,8 @@ public function getAddColumnsDDL($columns) /** * @see Platform::supportsSchemas() + * + * @return bool */ public function supportsSchemas() { diff --git a/src/Propel/Generator/Platform/OraclePlatform.php b/src/Propel/Generator/Platform/OraclePlatform.php index 6f2dba4914..9590b4ccd2 100644 --- a/src/Propel/Generator/Platform/OraclePlatform.php +++ b/src/Propel/Generator/Platform/OraclePlatform.php @@ -338,6 +338,8 @@ public function getTimestampFormatter() * one fell swoop. * * @see Platform::supportsSchemas() + * + * @return bool */ public function supportsSchemas() { @@ -435,10 +437,17 @@ public function getAddIndexDDL(Index $index) * Get the PHP snippet for binding a value to a column. * Warning: duplicates logic from OracleAdapter::bindValue(). * Any code modification here must be ported there. + * + * @param \Propel\Generator\Model\Column $column + * @param string $identifier + * @param string $columnValueAccessor + * @param string $tab + * + * @return string */ public function getColumnBindingPHP(Column $column, $identifier, $columnValueAccessor, $tab = ' ') { - if ($column->getType() == PropelTypes::CLOB_EMU) { + if ($column->getType() === PropelTypes::CLOB_EMU) { return sprintf( "%s\$stmt->bindParam(%s, %s, %s, strlen(%s)); ", diff --git a/src/Propel/Generator/Platform/PgsqlPlatform.php b/src/Propel/Generator/Platform/PgsqlPlatform.php index c36118e88b..8bdf1b8af9 100755 --- a/src/Propel/Generator/Platform/PgsqlPlatform.php +++ b/src/Propel/Generator/Platform/PgsqlPlatform.php @@ -629,6 +629,8 @@ public function getModifyTableDDL(TableDiff $tableDiff) * * @see DefaultPlatform::getModifyColumnDDL * + * @param \Propel\Generator\Model\Diff\ColumnDiff $columnDiff + * * @return string */ public function getModifyColumnDDL(ColumnDiff $columnDiff) @@ -805,6 +807,8 @@ public function getUsingCast(Column $fromColumn, Column $toColumn) * * @see DefaultPlatform::getModifyColumnsDDL * + * @param \Propel\Generator\Model\Diff\ColumnDiff[] $columnDiffs + * * @return string */ public function getModifyColumnsDDL($columnDiffs) @@ -824,6 +828,8 @@ public function getModifyColumnsDDL($columnDiffs) * * @see DefaultPlatform::getAddColumnsDLL * + * @param \Propel\Generator\Model\Column[] $columns + * * @return string */ public function getAddColumnsDDL($columns) @@ -843,6 +849,8 @@ public function getAddColumnsDDL($columns) * * @see DefaultPlatform::getDropIndexDDL * + * @param \Propel\Generator\Model\Index $index + * * @return string */ public function getDropIndexDDL(Index $index) @@ -857,9 +865,9 @@ public function getDropIndexDDL(Index $index) $this->quoteIdentifier($index->getTable()->getName()), $this->quoteIdentifier($index->getName()) ); - } else { - return parent::getDropIndexDDL($index); } + + return parent::getDropIndexDDL($index); } /** diff --git a/src/Propel/Generator/Platform/PlatformInterface.php b/src/Propel/Generator/Platform/PlatformInterface.php index 3a3ee619f3..be743a0c3d 100644 --- a/src/Propel/Generator/Platform/PlatformInterface.php +++ b/src/Propel/Generator/Platform/PlatformInterface.php @@ -42,6 +42,8 @@ interface PlatformInterface * Sets a database connection to use (for quoting, etc.). * * @param \Propel\Runtime\Connection\ConnectionInterface|null $con The database connection to use in this Platform class. + * + * @return void */ public function setConnection(?ConnectionInterface $con = null); @@ -56,6 +58,8 @@ public function getConnection(); * Sets the GeneratorConfigInterface which contains any generator build properties. * * @param \Propel\Generator\Config\GeneratorConfigInterface $generatorConfig + * + * @return void */ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig); @@ -94,6 +98,8 @@ public function getDomainForType($propelType); * Returns the RDBMS-specific SQL fragment for NULL * or NOT NULL. * + * @param bool $notNull + * * @return string */ public function getNullString($notNull); @@ -108,6 +114,8 @@ public function getAutoIncrement(); /** * Returns the DDL SQL for a Column object. * + * @param \Propel\Generator\Model\Column $col + * * @return string */ public function getColumnDDL(Column $col); @@ -115,6 +123,8 @@ public function getColumnDDL(Column $col); /** * Returns the SQL for the default value of a Column object. * + * @param \Propel\Generator\Model\Column $col + * * @return string */ public function getColumnDefaultValueDDL(Column $col); @@ -138,6 +148,8 @@ public function getColumnListDDL($columns, $delimiter = ','); /** * Returns the SQL for the primary key of a Table object * + * @param \Propel\Generator\Model\Table $table + * * @return string */ public function getPrimaryKeyDDL(Table $table); @@ -275,6 +287,8 @@ public function getSchemaDelimiter(); * which the most Platforms requires but which is not always explicitly defined in the table model. * * @param \Propel\Generator\Model\Table $table The table object which gets modified. + * + * @return void */ public function normalizeTable(Table $table); @@ -299,6 +313,8 @@ public function isIdentifierQuotingEnabled(); /** * @param bool $enabled + * + * @return void */ public function setIdentifierQuoting($enabled); } diff --git a/src/Propel/Generator/Platform/SqlitePlatform.php b/src/Propel/Generator/Platform/SqlitePlatform.php index bbda38a4e0..caeb90dbcc 100644 --- a/src/Propel/Generator/Platform/SqlitePlatform.php +++ b/src/Propel/Generator/Platform/SqlitePlatform.php @@ -357,6 +357,8 @@ public function normalizeTable(Table $table) /** * Returns the SQL for the primary key of a Table object * + * @param \Propel\Generator\Model\Table $table + * * @return string */ public function getPrimaryKeyDDL(Table $table) @@ -583,7 +585,7 @@ public function hasSize($sqlType) 'BLOB', 'MEDIUMBLOB', 'LONGBLOB', - ]); + ], true); } /** diff --git a/src/Propel/Generator/Reverse/AbstractSchemaParser.php b/src/Propel/Generator/Reverse/AbstractSchemaParser.php index 7852aa6cc0..c4caedb0b2 100644 --- a/src/Propel/Generator/Reverse/AbstractSchemaParser.php +++ b/src/Propel/Generator/Reverse/AbstractSchemaParser.php @@ -174,7 +174,7 @@ public function getGeneratorConfig() /** * Gets a type mapping from native type to Propel type. * - * @return array The mapped Propel type. + * @return string[] The mapped Propel type. */ abstract protected function getTypeMapping(); @@ -218,6 +218,8 @@ protected function getMappedNativeType($propelType) * Gets a new VendorInfo object for this platform with specified params. * * @param array $params + * + * @return \Propel\Generator\Model\VendorInfo */ protected function getNewVendorInfoObject(array $params) { diff --git a/src/Propel/Generator/Reverse/MssqlSchemaParser.php b/src/Propel/Generator/Reverse/MssqlSchemaParser.php index 6b8e3f862a..ac2cfcd1e2 100644 --- a/src/Propel/Generator/Reverse/MssqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/MssqlSchemaParser.php @@ -32,7 +32,7 @@ class MssqlSchemaParser extends AbstractSchemaParser /** * Map MSSQL native types to Propel types. * - * @var array + * @var string[] */ private static $mssqlTypeMap = [ 'binary' => PropelTypes::BINARY, @@ -76,6 +76,8 @@ class MssqlSchemaParser extends AbstractSchemaParser /** * @see AbstractSchemaParser::getTypeMapping() + * + * @return string[] */ protected function getTypeMapping() { @@ -171,6 +173,8 @@ protected function addColumns(Table $table) /** * Load foreign keys for this table. * + * @param \Propel\Generator\Model\Table $table + * * @return void */ protected function addForeignKeys(Table $table) @@ -214,6 +218,8 @@ protected function addForeignKeys(Table $table) /** * Load indexes for this table * + * @param \Propel\Generator\Model\Table $table + * * @return void */ protected function addIndexes(Table $table) @@ -261,6 +267,8 @@ protected function addIndexes(Table $table) /** * Loads the primary key for this table. * + * @param \Propel\Generator\Model\Table $table + * * @return void */ protected function addPrimaryKey(Table $table) diff --git a/src/Propel/Generator/Reverse/MysqlSchemaParser.php b/src/Propel/Generator/Reverse/MysqlSchemaParser.php index e6d4e23b49..521cfa06e8 100644 --- a/src/Propel/Generator/Reverse/MysqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/MysqlSchemaParser.php @@ -35,7 +35,7 @@ class MysqlSchemaParser extends AbstractSchemaParser /** * Map MySQL native types to Propel types. * - * @var array + * @var string[] */ private static $mysqlTypeMap = [ 'tinyint' => PropelTypes::TINYINT, @@ -69,6 +69,9 @@ class MysqlSchemaParser extends AbstractSchemaParser 'set' => PropelTypes::CHAR, ]; + /** + * @var int[] + */ protected static $defaultTypeSizes = [ 'char' => 1, 'tinyint' => 4, @@ -81,7 +84,7 @@ class MysqlSchemaParser extends AbstractSchemaParser /** * Gets a type mapping from native types to Propel types * - * @return array + * @return string[] */ protected function getTypeMapping() { @@ -185,6 +188,7 @@ protected function addColumns(Table $table) * * @param array $row An associative array with the following keys: * Field, Type, Null, Key, Default, Extra. + * @param \Propel\Generator\Model\Table $table * * @return \Propel\Generator\Model\Column */ @@ -284,6 +288,8 @@ public function getColumnFromRow($row, Table $table) /** * Load foreign keys for this table. * + * @param \Propel\Generator\Model\Table $table + * * @return void */ protected function addForeignKeys(Table $table) @@ -382,6 +388,8 @@ protected function addForeignKeys(Table $table) /** * Load indexes for this table * + * @param \Propel\Generator\Model\Table $table + * * @return void */ protected function addIndexes(Table $table) @@ -435,6 +443,8 @@ protected function addIndexes(Table $table) /** * Loads the primary key for this table. * + * @param \Propel\Generator\Model\Table $table + * * @return void */ protected function addPrimaryKey(Table $table) diff --git a/src/Propel/Generator/Reverse/OracleSchemaParser.php b/src/Propel/Generator/Reverse/OracleSchemaParser.php index 8c14356725..e4923f5f67 100644 --- a/src/Propel/Generator/Reverse/OracleSchemaParser.php +++ b/src/Propel/Generator/Reverse/OracleSchemaParser.php @@ -43,7 +43,7 @@ class OracleSchemaParser extends AbstractSchemaParser * DECIMAL (NUMBER with scale), * DOUBLE (FLOAT with precision = 126) * - * @var array + * @var string[] */ private static $oracleTypeMap = [ 'BLOB' => PropelTypes::BLOB, @@ -66,7 +66,7 @@ class OracleSchemaParser extends AbstractSchemaParser /** * Gets a type mapping from native types to Propel types * - * @return array + * @return string[] */ protected function getTypeMapping() { @@ -78,6 +78,8 @@ protected function getTypeMapping() * * @param \Propel\Generator\Model\Database $database The Database model class to add tables to. * @param \Propel\Generator\Model\Table[] $additionalTables + * + * @return int */ public function parse(Database $database, array $additionalTables = []) { diff --git a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php index cb556ae4ca..dbfb3c64e2 100755 --- a/src/Propel/Generator/Reverse/PgsqlSchemaParser.php +++ b/src/Propel/Generator/Reverse/PgsqlSchemaParser.php @@ -31,9 +31,8 @@ class PgsqlSchemaParser extends AbstractSchemaParser /** * Map PostgreSQL native types to Propel types. * - * @var array + * @var string[] */ - private static $pgsqlTypeMap = [ 'bool' => PropelTypes::BOOLEAN, 'boolean' => PropelTypes::BOOLEAN, @@ -78,6 +77,9 @@ class PgsqlSchemaParser extends AbstractSchemaParser 'json' => PropelTypes::JSON, ]; + /** + * @var int[] + */ protected static $defaultTypeSizes = [ 'char' => 1, 'character' => 1, @@ -90,7 +92,7 @@ class PgsqlSchemaParser extends AbstractSchemaParser /** * Gets a type mapping from native types to Propel types * - * @return array + * @return string[] */ protected function getTypeMapping() { @@ -367,6 +369,9 @@ protected function isColumnDefaultExpression($default) /** * Load foreign keys for this table. * + * @param \Propel\Generator\Model\Table $table + * @param int $oid + * * @return void */ protected function addForeignKeys(Table $table, $oid) @@ -488,6 +493,9 @@ protected function addForeignKeys(Table $table, $oid) /** * Load indexes for this table * + * @param \Propel\Generator\Model\Table $table + * @param int $oid + * * @return void */ protected function addIndexes(Table $table, $oid) @@ -551,6 +559,9 @@ protected function addIndexes(Table $table, $oid) /** * Loads the primary key for this table. * + * @param \Propel\Generator\Model\Table $table + * @param int $oid + * * @return void */ protected function addPrimaryKey(Table $table, $oid) diff --git a/src/Propel/Generator/Reverse/SchemaParserInterface.php b/src/Propel/Generator/Reverse/SchemaParserInterface.php index 52b66ae9a6..800f84485f 100644 --- a/src/Propel/Generator/Reverse/SchemaParserInterface.php +++ b/src/Propel/Generator/Reverse/SchemaParserInterface.php @@ -32,6 +32,8 @@ public function getConnection(); * Sets the database connection. * * @param \Propel\Runtime\Connection\ConnectionInterface $dbh + * + * @return void */ public function setConnection(ConnectionInterface $dbh); @@ -39,6 +41,8 @@ public function setConnection(ConnectionInterface $dbh); * Sets the GeneratorConfig to use in the parsing. * * @param \Propel\Generator\Config\GeneratorConfigInterface $config + * + * @return void */ public function setGeneratorConfig(GeneratorConfigInterface $config); @@ -56,6 +60,8 @@ public function getPlatform(); /** * @param \Propel\Generator\Platform\PlatformInterface $platform + * + * @return void */ public function setPlatform($platform); @@ -65,7 +71,7 @@ public function setPlatform($platform); * @param \Propel\Generator\Model\Database $database * @param \Propel\Generator\Model\Table[] $additionalTables additional tables to parse and add to $database * - * @return int number of generated tables + * @return int Number of generated tables */ public function parse(Database $database, array $additionalTables = []); } diff --git a/src/Propel/Generator/Reverse/SqliteSchemaParser.php b/src/Propel/Generator/Reverse/SqliteSchemaParser.php index 1a05ce8e8f..ff13314b7e 100644 --- a/src/Propel/Generator/Reverse/SqliteSchemaParser.php +++ b/src/Propel/Generator/Reverse/SqliteSchemaParser.php @@ -27,6 +27,9 @@ */ class SqliteSchemaParser extends AbstractSchemaParser { + /** + * @var bool + */ protected $addVendorInfo; /** @@ -322,6 +325,8 @@ protected function addForeignKeys(Table $table) /** * Load indexes for this table * + * @param \Propel\Generator\Model\Table $table + * * @return void */ protected function addIndexes(Table $table) diff --git a/src/Propel/Generator/Util/BehaviorLocator.php b/src/Propel/Generator/Util/BehaviorLocator.php index 28a5e6765d..3e6759b38d 100644 --- a/src/Propel/Generator/Util/BehaviorLocator.php +++ b/src/Propel/Generator/Util/BehaviorLocator.php @@ -26,8 +26,14 @@ class BehaviorLocator { public const BEHAVIOR_PACKAGE_TYPE = 'propel-behavior'; + /** + * @var array|null + */ private $behaviors; + /** + * @var string|null + */ private $composerDir; /** diff --git a/src/Propel/Generator/Util/PhpParser.php b/src/Propel/Generator/Util/PhpParser.php index 630e3406c1..0ec989acde 100644 --- a/src/Propel/Generator/Util/PhpParser.php +++ b/src/Propel/Generator/Util/PhpParser.php @@ -32,8 +32,14 @@ */ class PhpParser { + /** + * @var string + */ protected $code; + /** + * @var bool + */ protected $isAddPhp; /** diff --git a/src/Propel/Generator/Util/QuickBuilder.php b/src/Propel/Generator/Util/QuickBuilder.php index b15658c168..5768a85c2c 100644 --- a/src/Propel/Generator/Util/QuickBuilder.php +++ b/src/Propel/Generator/Util/QuickBuilder.php @@ -183,6 +183,15 @@ public function getConfig() return $this->config; } + /** + * @param string $schema + * @param string|null $dsn + * @param string|null $user + * @param string|null $pass + * @param \Propel\Runtime\Adapter\AdapterInterface|null $adapter + * + * @return \Propel\Runtime\Connection\ConnectionWrapper + */ public static function buildSchema($schema, $dsn = null, $user = null, $pass = null, $adapter = null) { $builder = new self(); @@ -505,6 +514,10 @@ public static function debugClassesForTable($schema, $tableName) /** * @see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php + * + * @param string $source + * + * @return string */ public function fixNamespaceDeclarations($source) { diff --git a/src/Propel/Generator/Util/SchemaValidator.php b/src/Propel/Generator/Util/SchemaValidator.php index 9390a2658d..2ae675141d 100644 --- a/src/Propel/Generator/Util/SchemaValidator.php +++ b/src/Propel/Generator/Util/SchemaValidator.php @@ -41,8 +41,6 @@ class SchemaValidator protected $errors = []; /** - * SchemaValidator constructor. - * * @param \Propel\Generator\Model\Schema $schema */ public function __construct(Schema $schema) diff --git a/src/Propel/Generator/Util/SqlParser.php b/src/Propel/Generator/Util/SqlParser.php index fe2039fd65..aa9bcebc45 100644 --- a/src/Propel/Generator/Util/SqlParser.php +++ b/src/Propel/Generator/Util/SqlParser.php @@ -20,14 +20,29 @@ */ class SqlParser { + /** + * @var string + */ protected $delimiter = ';'; + /** + * @var int + */ protected $delimiterLength = 1; + /** + * @var string + */ protected $sql = ''; + /** + * @var int + */ protected $len = 0; + /** + * @var int + */ protected $pos = 0; /** diff --git a/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php b/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php index 1c23dbeb42..550751d321 100644 --- a/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php @@ -12,10 +12,19 @@ class BaseModelCriteria extends Criteria implements IteratorAggregate { + /** + * @var string|null + */ protected $modelName; + /** + * @var string|null + */ protected $modelTableMapName; + /** + * @var string|null + */ protected $modelAlias; /** @@ -23,10 +32,21 @@ class BaseModelCriteria extends Criteria implements IteratorAggregate */ protected $tableMap; + /** + * @var \Propel\Runtime\Formatter\AbstractFormatter|null + */ protected $formatter; + /** + * @var array + */ protected $with = []; + /** + * @phpstan-param class-string<\Propel\Runtime\Formatter\AbstractFormatter> + * + * @var string + */ protected $defaultFormatterClass = ModelCriteria::FORMAT_OBJECT; /** diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index 86f54b3273..87c62274f7 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -114,8 +114,14 @@ class Criteria public const LOGICAL_AND = 'AND'; + /** + * @var bool + */ protected $ignoreCase = false; + /** + * @var bool + */ protected $singleRecord = false; /** @@ -224,8 +230,14 @@ class Criteria */ protected $queryComment; + /** + * @var array + */ protected $aliases = []; + /** + * @var bool + */ protected $useTransaction = false; /** @@ -1525,7 +1537,7 @@ public function remove($key) return null; } - /** @var \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion|null */ + /** @var \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion|null $removed */ $removed = $this->map[$key]; unset($this->map[$key]); if ($removed instanceof AbstractCriterion) { @@ -1574,6 +1586,8 @@ public function size() * This method checks another Criteria to see if they contain * the same attributes and hashtable entries. * + * @param \Propel\Runtime\ActiveQuery\Criteria|null $crit + * * @return bool */ public function equals($crit) @@ -1582,7 +1596,6 @@ public function equals($crit) return false; } - /** @var \Propel\Runtime\ActiveQuery\Criteria $crit */ if ($this === $crit) { return true; } @@ -1797,6 +1810,11 @@ protected function getCriterionForCondition($p1, $value = null, $comparison = nu * - addAnd(column, value) * - addAnd(Criterion) * + * @param mixed $p1 + * @param mixed|null $p2 + * @param mixed|null $p3 + * @param bool $preferColumnCondition + * * @return $this A modified Criteria object. */ public function addAnd($p1, $p2 = null, $p3 = null, $preferColumnCondition = true) @@ -2105,6 +2123,7 @@ protected function doReplaceNameInExpression($matches) * Quotes identifier based on $this->isIdentifierQuotingEnabled() and $tableMap->isIdentifierQuotingEnabled. * * @param string $string + * @param string $tableName * * @return string */ @@ -2519,7 +2538,7 @@ public function doUpdate($updateValues, ConnectionInterface $con) throw new PropelException(sprintf('Unable to execute UPDATE statement [%s]', $sql), 0, $e); } - } // foreach table in the criteria + } return $affectedRows; } @@ -2686,7 +2705,7 @@ public function doDelete(?ConnectionInterface $con = null) throw new PropelException(sprintf('Unable to execute DELETE statement [%s]', $sql), 0, $e); } - } // for each table + } return $affectedRows; } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php index e2a96b5ff0..12207ae17c 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php @@ -28,7 +28,9 @@ abstract class AbstractCriterion public const UND = ' AND '; public const ODER = ' OR '; - + /** + * @var mixed + */ protected $value; /** @@ -124,6 +126,8 @@ public function init(Criteria $criteria) /** * Set the $column and $table properties based on a column name or object * + * @param ColumnMap|string $column + * * @return void */ protected function setColumn($column) @@ -331,6 +335,8 @@ abstract protected function appendPsForUniqueClauseTo(&$sb, array &$params); * This method checks another Criteria to see if they contain * the same attributes and hashtable entries. * + * @param object|null $obj + * * @return bool */ public function equals($obj) @@ -389,6 +395,9 @@ public function getAllTables() * method supporting recursion through all criterions to give * us a string array of tables from each criterion * + * @param \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion $c + * @param array $s + * * @return void */ private function addCriterionTable(AbstractCriterion $c, array &$s) diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php index 8faf098d30..911f77e99f 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractModelCriterion.php @@ -19,6 +19,9 @@ */ abstract class AbstractModelCriterion extends AbstractCriterion { + /** + * @var string + */ protected $clause = ''; /** diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php index 893b2b7ead..9c36f5d725 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php @@ -19,6 +19,9 @@ */ class BasicCriterion extends AbstractCriterion { + /** + * @var bool + */ protected $ignoreStringCase = false; /** diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php index b72a0ab790..5447df121d 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php @@ -19,6 +19,9 @@ */ class LikeCriterion extends AbstractCriterion { + /** + * @var bool + */ protected $ignoreStringCase = false; /** diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php index 8f4b44dc0e..aabf8f6235 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/LikeModelCriterion.php @@ -19,6 +19,9 @@ */ class LikeModelCriterion extends BasicModelCriterion { + /** + * @var bool + */ protected $ignoreStringCase = false; /** diff --git a/src/Propel/Runtime/ActiveQuery/Join.php b/src/Propel/Runtime/ActiveQuery/Join.php index f5ab0d0f8e..11d99bc556 100644 --- a/src/Propel/Runtime/ActiveQuery/Join.php +++ b/src/Propel/Runtime/ActiveQuery/Join.php @@ -39,8 +39,14 @@ class Join // the left parts of the join condition protected $left = []; + /** + * @var array + */ protected $leftValues = []; + /** + * @var array + */ protected $rightValues = []; // the right parts of the join condition @@ -53,23 +59,48 @@ class Join */ protected $operators = []; - // the type of the join (LEFT JOIN, ...) + /** + * The type of the join (LEFT JOIN, ...) + * + * @var string|null + */ protected $joinType; - // the number of conditions in the join + /** + * The number of conditions in the join + * + * @var int + */ protected $count = 0; - // the database adapter + /** + * @var \Propel\Runtime\Adapter\AdapterInterface|null + */ protected $db; + /** + * @var string|null + */ protected $leftTableName; + /** + * @var string|null + */ protected $rightTableName; + /** + * @var string|null + */ protected $leftTableAlias; + /** + * @var string|null + */ protected $rightTableAlias; + /** + * @var \Propel\Runtime\ActiveQuery\Criterion\AbstractCriterion|null + */ protected $joinCondition; /** diff --git a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php index 703f6fe111..0fe53266c2 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php @@ -182,8 +182,9 @@ public function filterByArray($conditions) * @see Criteria::add() * * @param mixed $clause A string representing the pseudo SQL clause, e.g. 'Book.AuthorId = ?' - * Or an array of condition names + * Or an array of condition names * @param mixed $value A value for the condition + * @param int|null $bindingType * * @return $this The current object, for fluid interface */ @@ -219,6 +220,7 @@ public function where($clause, $value = null, $bindingType = null) * @param mixed $clause A string representing the pseudo SQL clause, e.g. 'Book.AuthorId = ?' * Or an array of condition names * @param mixed $value A value for the condition + * @param int|null $bindingType * * @return $this The current object, for fluid interface */ @@ -560,6 +562,7 @@ public function join($relation, $joinType = Criteria::INNER_JOIN) * @param string $clause SQL clause, may contain column and table phpNames * @param mixed $value An optional value to bind to the clause * @param string|null $operator The operator to use to add the condition. Defaults to 'AND' + * @param int|null $bindingType * * @throws \Propel\Runtime\Exception\PropelException * @@ -623,6 +626,7 @@ public function setJoinCondition($name, $condition) * @see Criteria::addJoinObject() * * @param \Propel\Runtime\ActiveQuery\Join $join A join object + * @param string|null $name * * @return $this The current object, for fluid interface */ @@ -1974,9 +1978,10 @@ protected function doReplaceNameInExpression($matches) * * * @param string $phpName String representing the column name in a pseudo SQL clause, e.g. 'Book.Title' + * @param bool $failSilently * - * @throws \Propel\Runtime\ActiveQuery\Exception\UnknownModelException * @throws \Propel\Runtime\ActiveQuery\Exception\UnknownColumnException + * @throws \Propel\Runtime\ActiveQuery\Exception\UnknownModelException * * @return array List($columnMap, $realColumnName) */ @@ -2271,7 +2276,12 @@ public function getParams() * where XXX is a column phpName. * Supports XXXJoin(), where XXX is a join direction (in 'left', 'right', 'inner') * + * @param string $name + * @param array $arguments + * * @throws \Propel\Runtime\Exception\PropelException + * + * @return mixed */ public function __call($name, $arguments) { @@ -2280,7 +2290,7 @@ public function __call($name, $arguments) foreach ($methods as $method) { if (strpos($name, $method) === 0) { $columns = substr($name, strlen($method)); - if (in_array($method, ['findBy', 'findOneBy', 'requireOneBy']) && strpos($columns, 'And') !== false) { + if (in_array($method, ['findBy', 'findOneBy', 'requireOneBy'], true) && strpos($columns, 'And') !== false) { $method = $method . 'Array'; $columns = explode('And', $columns); $conditions = []; diff --git a/src/Propel/Runtime/ActiveQuery/ModelJoin.php b/src/Propel/Runtime/ActiveQuery/ModelJoin.php index fd9452726f..2cdb5c6e65 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelJoin.php +++ b/src/Propel/Runtime/ActiveQuery/ModelJoin.php @@ -25,10 +25,23 @@ class ModelJoin extends Join */ protected $relationMap; + /** + * @var \Propel\Runtime\Map\TableMap|null + */ protected $tableMap; + /** + * @var \Propel\Runtime\ActiveQuery\ModelJoin|null + */ protected $previousJoin; + /** + * @param \Propel\Runtime\Map\RelationMap $relationMap + * @param string|null $leftTableAlias + * @param string|null $relationAlias + * + * @return $this + */ public function setRelationMap(RelationMap $relationMap, $leftTableAlias = null, $relationAlias = null) { $leftCols = $relationMap->getLeftColumns(); @@ -123,7 +136,7 @@ public function setPreviousJoin(ModelJoin $join) } /** - * @return $this + * @return self */ public function getPreviousJoin() { diff --git a/src/Propel/Runtime/Adapter/MSSQL/MssqlDebugPDO.php b/src/Propel/Runtime/Adapter/MSSQL/MssqlDebugPDO.php index 1ea26f239d..a5341f1c5f 100644 --- a/src/Propel/Runtime/Adapter/MSSQL/MssqlDebugPDO.php +++ b/src/Propel/Runtime/Adapter/MSSQL/MssqlDebugPDO.php @@ -15,5 +15,8 @@ */ class MssqlDebugPDO extends MssqlPropelPDO { + /** + * @var bool + */ public $useDebug = true; } diff --git a/src/Propel/Runtime/Adapter/SqlAdapterInterface.php b/src/Propel/Runtime/Adapter/SqlAdapterInterface.php index e1d7ebc377..f2e21062a9 100644 --- a/src/Propel/Runtime/Adapter/SqlAdapterInterface.php +++ b/src/Propel/Runtime/Adapter/SqlAdapterInterface.php @@ -45,6 +45,8 @@ public function ignoreCase($in); * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) * @param \Propel\Runtime\ActiveQuery\Criteria $values * @param \Propel\Runtime\Map\DatabaseMap $dbMap + * + * @return void */ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap); @@ -54,6 +56,8 @@ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap * @param string $sql * @param int $offset * @param int $limit + * + * @return void */ public function applyLimit(&$sql, $offset, $limit); @@ -61,6 +65,8 @@ public function applyLimit(&$sql, $offset, $limit); * Gets the SQL string that this adapter uses for getting a random number. * * @param mixed $seed (optional) seed value for databases that support this + * + * @return string */ public function random($seed = null); @@ -117,6 +123,8 @@ public function turnSelectColumnsToAliases(Criteria $criteria); * @param \PDOStatement $stmt * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) * @param \Propel\Runtime\Map\DatabaseMap $dbMap + * + * @return void */ public function bindValues(PDOStatement $stmt, array $params, DatabaseMap $dbMap); diff --git a/src/Propel/Runtime/Collection/ObjectCollection.php b/src/Propel/Runtime/Collection/ObjectCollection.php index 1c9177f944..a782e29613 100644 --- a/src/Propel/Runtime/Collection/ObjectCollection.php +++ b/src/Propel/Runtime/Collection/ObjectCollection.php @@ -25,9 +25,15 @@ */ class ObjectCollection extends Collection { - protected $index; + /** + * @var array + */ + protected $index = []; - protected $indexSplHash; + /** + * @var array + */ + protected $indexSplHash = []; /** * @param array $data @@ -417,8 +423,6 @@ public function search($element) */ protected function rebuildIndex() { - $this->index = []; - $this->indexSplHash = []; foreach ($this->data as $idx => $value) { $hashCode = $this->getHashCode($value); $this->index[$hashCode] = $idx; diff --git a/src/Propel/Runtime/Collection/OnDemandIterator.php b/src/Propel/Runtime/Collection/OnDemandIterator.php index 7be446c1bb..d57ef45f3f 100644 --- a/src/Propel/Runtime/Collection/OnDemandIterator.php +++ b/src/Propel/Runtime/Collection/OnDemandIterator.php @@ -33,12 +33,24 @@ class OnDemandIterator implements Iterator */ protected $dataFetcher; + /** + * @var array|null + */ protected $currentRow; + /** + * @var int + */ protected $currentKey; + /** + * @var bool + */ protected $isValid; + /** + * @var bool + */ protected $enableInstancePoolingOnFinish; /** diff --git a/src/Propel/Runtime/Connection/ConnectionManagerInterface.php b/src/Propel/Runtime/Connection/ConnectionManagerInterface.php index e5a2ddaa28..b3a934e762 100644 --- a/src/Propel/Runtime/Connection/ConnectionManagerInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionManagerInterface.php @@ -40,5 +40,8 @@ public function getWriteConnection(?AdapterInterface $adapter = null); */ public function getReadConnection(?AdapterInterface $adapter = null); + /** + * @return void + */ public function closeConnections(); } diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index 641df9f247..2d13fb6cc1 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -632,7 +632,7 @@ protected function isLogEnabledForMethod($methodName) } /** - * {@inheritDoc} + * @param LoggerInterface $logger * * @return void */ @@ -686,6 +686,11 @@ public function log($msg) /** * Forward any call to a method not found to the wrapped connection. + * + * @param string $method + * @param mixed $args + * + * @return mixed */ public function __call($method, $args) { diff --git a/src/Propel/Runtime/Connection/DebugPDO.php b/src/Propel/Runtime/Connection/DebugPDO.php index 640b9f0881..ddab0241f1 100644 --- a/src/Propel/Runtime/Connection/DebugPDO.php +++ b/src/Propel/Runtime/Connection/DebugPDO.php @@ -17,5 +17,8 @@ */ class DebugPDO extends ConnectionWrapper { + /** + * @var bool + */ public $useDebug = true; } diff --git a/src/Propel/Runtime/Connection/StatementWrapper.php b/src/Propel/Runtime/Connection/StatementWrapper.php index fd192713db..5abc1fd7a4 100644 --- a/src/Propel/Runtime/Connection/StatementWrapper.php +++ b/src/Propel/Runtime/Connection/StatementWrapper.php @@ -38,7 +38,8 @@ class StatementWrapper extends PDOStatement implements IteratorAggregate * This is only used in logging the binding of variables. * * @see self::bindValue() - * @var array + * + * @var string[] */ protected static $typeMap = [ 0 => 'PDO::PARAM_NULL', @@ -242,6 +243,8 @@ public function getExecutedQueryString($input_parameters = null) * The fetch_style parameter determines how the Connection returns the row. * * @param int $fetchStyle Controls how the next row will be returned to the caller. + * @param int $cursorOrientation + * @param int $cursorOffset * * @return mixed */ @@ -254,6 +257,8 @@ public function fetch($fetchStyle = PDO::FETCH_BOTH, $cursorOrientation = PDO::F * Returns an array containing all of the result set rows. * * @param int|null $fetchStyle Controls the contents of the returned array as documented in fetch() + * @param mixed|null $fetchArgument + * @param array $ctorArgs * * @return array */ diff --git a/src/Propel/Runtime/Connection/TransactionTrait.php b/src/Propel/Runtime/Connection/TransactionTrait.php index b342b6c99e..aeb5d59d91 100644 --- a/src/Propel/Runtime/Connection/TransactionTrait.php +++ b/src/Propel/Runtime/Connection/TransactionTrait.php @@ -46,9 +46,18 @@ public function transaction(callable $callable) } } + /** + * @return bool + */ abstract public function beginTransaction(); + /** + * @return bool + */ abstract public function commit(); + /** + * @return bool + */ abstract public function rollBack(); } diff --git a/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php b/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php index 7a36cdea43..0375013d7b 100644 --- a/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php @@ -21,9 +21,7 @@ public function __construct($dataObject) } /** - * {@inheritDoc} - * - * @return void + * @inheritDoc */ public function setDataObject($dataObject) { diff --git a/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php b/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php index 3f77a09bca..a4c739c89a 100644 --- a/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/ArrayDataFetcher.php @@ -17,8 +17,6 @@ class ArrayDataFetcher extends AbstractDataFetcher protected $indexType = TableMap::TYPE_PHPNAME; /** - * {@inheritDoc} - * * @return void */ public function next() @@ -64,8 +62,6 @@ public function valid() } /** - * {@inheritDoc} - * * @return void */ public function rewind() @@ -106,8 +102,6 @@ public function setIndexType($indexType) } /** - * {@inheritDoc} - * * @return void */ public function close() diff --git a/src/Propel/Runtime/DataFetcher/DataFetcherInterface.php b/src/Propel/Runtime/DataFetcher/DataFetcherInterface.php index 822e03b33f..2780bffbb4 100644 --- a/src/Propel/Runtime/DataFetcher/DataFetcherInterface.php +++ b/src/Propel/Runtime/DataFetcher/DataFetcherInterface.php @@ -14,6 +14,8 @@ interface DataFetcherInterface extends Iterator, Countable * Sets the dataObject. * * @param mixed $dataObject + * + * @return void */ public function setDataObject($dataObject); @@ -90,6 +92,8 @@ public function fetch(); /** * Frees the resultSet. + * + * @return void */ public function close(); diff --git a/src/Propel/Runtime/DataFetcher/PDODataFetcher.php b/src/Propel/Runtime/DataFetcher/PDODataFetcher.php index 2db0245ed5..0dd20fb8a4 100644 --- a/src/Propel/Runtime/DataFetcher/PDODataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/PDODataFetcher.php @@ -41,7 +41,9 @@ class PDODataFetcher extends AbstractDataFetcher /** * Sets a new fetch style (FETCH_NUM, FETCH_ASSOC or FETCH_BOTH). Returns previous fetch style. * - * @var int + * @param int $style + * + * @return int */ public function setStyle($style) { @@ -54,7 +56,7 @@ public function setStyle($style) /** * Returns current fetch style (FETCH_NUM, FETCH_ASSOC or FETCH_BOTH). * - * @var int + * @return int */ public function getStyle() { @@ -74,8 +76,6 @@ public function fetch($style = null) } /** - * {@inheritDoc} - * * @return void */ public function next() @@ -127,8 +127,6 @@ public function rewind() } /** - * {@inheritDoc} - * * @return void */ public function close() diff --git a/src/Propel/Runtime/Formatter/ArrayFormatter.php b/src/Propel/Runtime/Formatter/ArrayFormatter.php index 518ff127d8..9762cf265c 100644 --- a/src/Propel/Runtime/Formatter/ArrayFormatter.php +++ b/src/Propel/Runtime/Formatter/ArrayFormatter.php @@ -33,6 +33,12 @@ class ArrayFormatter extends AbstractFormatter */ protected $emptyVariable; + /** + * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher + * + * @throws \Propel\Runtime\Exception\LogicException + * @return array|\Propel\Runtime\Collection\Collection + */ public function format(?DataFetcherInterface $dataFetcher = null) { $this->checkInit(); @@ -53,7 +59,7 @@ public function format(?DataFetcherInterface $dataFetcher = null) foreach ($dataFetcher as $row) { $object = &$this->getStructuredArrayFromRow($row); if ($object) { - $items[] = & $object; + $items[] = &$object; } } @@ -205,12 +211,12 @@ public function &getStructuredArrayFromRow($row) !in_array( $this->alreadyHydratedObjects[$relAlias][$key], $arrayToAugment[$modelWith->getRelationName()] - ) + , true) ) { - $arrayToAugment[$modelWith->getRelationName()][] = & $this->alreadyHydratedObjects[$relAlias][$key]; + $arrayToAugment[$modelWith->getRelationName()][] = &$this->alreadyHydratedObjects[$relAlias][$key]; } } else { - $arrayToAugment[$modelWith->getRelationName()] = & $this->alreadyHydratedObjects[$relAlias][$key]; + $arrayToAugment[$modelWith->getRelationName()] = &$this->alreadyHydratedObjects[$relAlias][$key]; } $hydrationChain[$modelWith->getRightPhpName()] = &$this->alreadyHydratedObjects[$relAlias][$key]; diff --git a/src/Propel/Runtime/Map/ColumnMap.php b/src/Propel/Runtime/Map/ColumnMap.php index e7a90a6e0f..5c2aa5aa8a 100644 --- a/src/Propel/Runtime/Map/ColumnMap.php +++ b/src/Propel/Runtime/Map/ColumnMap.php @@ -60,7 +60,7 @@ class ColumnMap /** * The default value for this column * - * @var mixed + * @var string|null */ protected $defaultValue; @@ -360,7 +360,7 @@ public function isNotNull() /** * Sets the default value for this column. * - * @param mixed $defaultValue the default value for the column + * @param string|null $defaultValue the default value for the column * * @return void */ @@ -372,7 +372,7 @@ public function setDefaultValue($defaultValue) /** * Gets the default value for this column. * - * @return mixed String or NULL + * @return string|null */ public function getDefaultValue() { diff --git a/src/Propel/Runtime/Map/RelationMap.php b/src/Propel/Runtime/Map/RelationMap.php index b488ea5ad6..797dd5f3e3 100644 --- a/src/Propel/Runtime/Map/RelationMap.php +++ b/src/Propel/Runtime/Map/RelationMap.php @@ -38,16 +38,34 @@ class RelationMap public const LEFT_TO_RIGHT = 1; + /** + * @var string + */ protected $name; + /** + * @var string + */ protected $pluralName; + /** + * @var int + */ protected $type; + /** + * @var \Propel\Runtime\Map\TableMap + */ protected $localTable; + /** + * @var \Propel\Runtime\Map\TableMap + */ protected $foreignTable; + /** + * @var bool + */ protected $polymorphic = false; /** @@ -67,8 +85,14 @@ class RelationMap */ protected $foreignColumns = []; + /** + * @var string|null + */ protected $onUpdate; + /** + * @var string|null + */ protected $onDelete; /** @@ -348,7 +372,7 @@ public function setOnUpdate($onUpdate) /** * Get the onUpdate behavior * - * @return int the relation type + * @return string|null */ public function getOnUpdate() { @@ -370,7 +394,7 @@ public function setOnDelete($onDelete) /** * Get the onDelete behavior * - * @return int the relation type + * @return string|null */ public function getOnDelete() { diff --git a/src/Propel/Runtime/Map/TableMap.php b/src/Propel/Runtime/Map/TableMap.php index 1f19d6131e..347b7a2c30 100644 --- a/src/Propel/Runtime/Map/TableMap.php +++ b/src/Propel/Runtime/Map/TableMap.php @@ -421,10 +421,10 @@ private static function getPrimaryKey(Criteria $criteria) * @param string $type A string specifying the Propel type. * @param bool $isNotNull Whether column does not allow NULL values. * @param int|null $size An int specifying the size. + * @param string|null $defaultValue * @param bool|null $pk True if column is a primary key. * @param string|bool $fkTable A String with the foreign key table name. * @param string|null $fkColumn A String with the foreign key column name. - * @param string|null $defaultValue The default value for this column. * * @return \Propel\Runtime\Map\ColumnMap The newly created column. */ @@ -810,6 +810,12 @@ public function getPrimaryStringColumn() return null; } + /** + * @param string $classname + * @param string $type + * + * @return mixed + */ public static function getFieldnamesForClass($classname, $type = TableMap::TYPE_PHPNAME) { $callable = [$classname::TABLE_MAP, 'getFieldnames']; @@ -817,6 +823,14 @@ public static function getFieldnamesForClass($classname, $type = TableMap::TYPE_ return call_user_func($callable, $type); } + /** + * @param string $classname + * @param string $fieldname + * @param string $fromType + * @param string $toType + * + * @return mixed + */ public static function translateFieldnameForClass($classname, $fieldname, $fromType, $toType) { $callable = [$classname::TABLE_MAP, 'translateFieldname']; @@ -844,6 +858,8 @@ public function setIdentifierQuoting($identifierQuoting) } /** + * @param \Propel\Runtime\ActiveQuery\Criteria $criteria + * * @return array|null null if not covered by only pk */ public function extractPrimaryKey(Criteria $criteria) diff --git a/src/Propel/Runtime/Map/TableMapTrait.php b/src/Propel/Runtime/Map/TableMapTrait.php index eecddc8d97..527e499647 100644 --- a/src/Propel/Runtime/Map/TableMapTrait.php +++ b/src/Propel/Runtime/Map/TableMapTrait.php @@ -57,6 +57,13 @@ public static function translateFieldName($name, $fromType, $toType) return $toNames[$key]; } + /** + * @param array $row + * @param string $fromType + * @param string $toType + * + * @return array + */ public static function translateFieldNames($row, $fromType, $toType) { $toNames = static::getFieldNames($toType); diff --git a/src/Propel/Runtime/Parser/CsvParser.php b/src/Propel/Runtime/Parser/CsvParser.php index 80207a47da..0e0133bf3c 100644 --- a/src/Propel/Runtime/Parser/CsvParser.php +++ b/src/Propel/Runtime/Parser/CsvParser.php @@ -26,14 +26,29 @@ class CsvParser extends AbstractParser // these settings are predefined for Excel CSV format + /** + * @var string + */ public $delimiter = ','; + /** + * @var string + */ public $lineTerminator = "\r\n"; + /** + * @var string + */ public $quotechar = '"'; + /** + * @var string + */ public $escapechar = '\\'; + /** + * @var int + */ public $quoting = self::QUOTE_MINIMAL; /** diff --git a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php index 2a15c85740..4ccb8a4ab6 100644 --- a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php +++ b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php @@ -45,6 +45,8 @@ class StandardServiceContainer implements ServiceContainerInterface protected $defaultDatasource = ServiceContainerInterface::DEFAULT_DATASOURCE_NAME; /** + * @phpstan-var class-string<\Propel\Runtime\Map\DatabaseMap> + * * @var string */ protected $databaseMapClass = ServiceContainerInterface::DEFAULT_DATABASE_MAP_CLASS; diff --git a/src/Propel/Runtime/Util/Profiler.php b/src/Propel/Runtime/Util/Profiler.php index e04843b908..0c4642261a 100644 --- a/src/Propel/Runtime/Util/Profiler.php +++ b/src/Propel/Runtime/Util/Profiler.php @@ -17,14 +17,29 @@ */ class Profiler { + /** + * @var float + */ protected $slowTreshold; + /** + * @var string + */ protected $innerGlue; + /** + * @var string + */ protected $outerGlue; - protected $snapshot; + /** + * @var array + */ + protected $snapshot = []; + /** + * @var array + */ protected $details = [ 'time' => [ 'name' => 'Time', diff --git a/src/Propel/Runtime/Util/PropelConditionalProxy.php b/src/Propel/Runtime/Util/PropelConditionalProxy.php index 59ddb44ccd..9c789f57da 100644 --- a/src/Propel/Runtime/Util/PropelConditionalProxy.php +++ b/src/Propel/Runtime/Util/PropelConditionalProxy.php @@ -40,12 +40,24 @@ class PropelConditionalProxy */ protected $criteria; + /** + * @var \Propel\Runtime\Util\PropelConditionalProxy|null + */ protected $parent; + /** + * @var bool + */ protected $state; + /** + * @var bool + */ protected $wasTrue; + /** + * @var bool + */ protected $parentState; /** @@ -73,7 +85,7 @@ public function __construct(Criteria $criteria, $cond, ?self $proxy = null) * * @param bool $cond * - * @return $this|$this|\Propel\Runtime\ActiveQuery\Criteria + * @return $this|\Propel\Runtime\ActiveQuery\Criteria */ public function _if($cond) { @@ -85,7 +97,7 @@ public function _if($cond) * * @param bool $cond ignored * - * @return $this|$this|\Propel\Runtime\ActiveQuery\Criteria + * @return $this|\Propel\Runtime\ActiveQuery\Criteria */ public function _elseif($cond) { @@ -95,7 +107,7 @@ public function _elseif($cond) /** * Allows for conditional statements in a fluid interface. * - * @return $this|$this|\Propel\Runtime\ActiveQuery\Criteria + * @return $this|\Propel\Runtime\ActiveQuery\Criteria */ public function _else() { @@ -106,7 +118,7 @@ public function _else() * Returns the parent object * Allows for conditional statements in a fluid interface. * - * @return $this|$this|\Propel\Runtime\ActiveQuery\Criteria + * @return $this|\Propel\Runtime\ActiveQuery\Criteria */ public function _endif() { @@ -137,7 +149,7 @@ protected function setConditionalState($cond) } /** - * @return $this|null + * @return self|null */ public function getParentProxy() { diff --git a/src/Propel/Runtime/Validator/Constraints/Date.php b/src/Propel/Runtime/Validator/Constraints/Date.php index 1f9d518ef8..2fdc291c29 100644 --- a/src/Propel/Runtime/Validator/Constraints/Date.php +++ b/src/Propel/Runtime/Validator/Constraints/Date.php @@ -13,7 +13,13 @@ class Date extends SymfonyDateConstraint { + /** + * @var string + */ public $message = 'This value is not a valid date.'; + /** + * @var string + */ public $column = ''; } From 1a67ef7e2d886b973439eb74b1aa83a90e7fd876 Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 28 Jul 2020 10:53:33 +0200 Subject: [PATCH 127/208] Fix more invalid inline assignments. --- .../Generator/Builder/Om/ObjectBuilder.php | 114 +++++++----------- .../Generator/Builder/Om/QueryBuilder.php | 16 +-- .../Generator/Builder/Om/TableMapBuilder.php | 4 +- .../Runtime/Collection/ObjectCollection.php | 2 + 4 files changed, 54 insertions(+), 82 deletions(-) diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index 0500308522..12b872323b 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -1953,8 +1953,6 @@ protected function addLobMutator(&$script, Column $col) $this->addMutatorClose($script, $col); } - // addLobMutatorSnippet - /** * Adds a setter method for date/time/timestamp columns. * @@ -3560,8 +3558,6 @@ protected function addDeleteClose(&$script) "; } - // addDelete() - /** * Adds a reload() method to re-fetch the data for this object from the database. * @@ -3786,8 +3782,6 @@ public function getPrimaryKey() "; } - // addetPrimaryKey_SingleFK - /** * Adds the setPrimaryKey() method for tables that contain a multi-column primary key. * @@ -3819,8 +3813,6 @@ public function getPrimaryKey() "; } - // addGetPrimaryKey_MultiFK() - /** * Adds the getPrimaryKey() method for objects that have no primary key. * This "feature" is deprecated, since the getPrimaryKey() method is not required @@ -3896,8 +3888,6 @@ public function setPrimaryKey(\$key) "; } - // addSetPrimaryKey_SinglePK - /** * Adds the setPrimaryKey() method for tables that contain a multi-columnprimary key. * @@ -4044,7 +4034,7 @@ protected function addFKMethods(&$script) $this->declareClassFromBuilder($this->getNewStubQueryBuilder($fk->getForeignTable())); $this->addFKMutator($script, $fk); $this->addFKAccessor($script, $fk); - } // foreach fk + } } /** @@ -4234,7 +4224,7 @@ public function get" . $this->getFKPhpNameAffix($fk, false) . "(ConnectionInterf } else { $script .= " \$this->$varName = " . $this->getClassNameFromBuilder($fkQueryBuilder) . "::create() - ->filterBy" . $this->getRefFKPhpNameAffix($fk, $plural = false) . "(\$this) // here + ->filterBy" . $this->getRefFKPhpNameAffix($fk, false) . "(\$this) // here ->findOne(\$con);"; } if ($fk->isLocalPrimaryKey()) { @@ -4260,8 +4250,6 @@ public function get" . $this->getFKPhpNameAffix($fk, false) . "(ConnectionInterf "; } - // addFKAccessor - /** * Adds the method that fetches fkey-related (referencing) objects but also joins in data from another table. * @@ -4332,8 +4320,6 @@ public function get" . $relCol . 'Join' . $relCol2 . "(Criteria \$criteria = nul } /* end foreach ($tblFK->getForeignKeys() as $fk2) { */ } - // function - /** * Adds the attributes used to store objects that have referrer fkey relationships to this object. * protected collVarName; @@ -4466,8 +4452,6 @@ public function clear$relCol() "; } - // addRefererClear() - /** * Adds the method that initializes the referrer fkey collection. * @@ -4508,8 +4492,6 @@ public function init$relCol(\$overrideExisting = true) "; } - // addRefererInit() - /** * Adds the method that adds an object into the referrer fkey collection. * @@ -4548,7 +4530,7 @@ public function add" . $this->getRefFKPhpNameAffix($refFK, false) . "($className } if (!\$this->{$collName}->contains(\$l)) { - \$this->doAdd" . $this->getRefFKPhpNameAffix($refFK, $plural = false) . "(\$l); + \$this->doAdd" . $this->getRefFKPhpNameAffix($refFK, false) . "(\$l); if (\$this->{$scheduledForDeletion} and \$this->{$scheduledForDeletion}->contains(\$l)) { \$this->{$scheduledForDeletion}->remove(\$this->{$scheduledForDeletion}->search(\$l)); @@ -4560,8 +4542,6 @@ public function add" . $this->getRefFKPhpNameAffix($refFK, false) . "($className "; } - // addRefererAdd - /** * Adds the method that returns the size of the referrer fkey collection. * @@ -4702,8 +4682,6 @@ public function get$relCol(Criteria \$criteria = null, ConnectionInterface \$con "; } - // addRefererGet() - /** * @param string $script * @param \Propel\Generator\Model\ForeignKey $refFK @@ -4721,7 +4699,7 @@ protected function addRefFKSet(&$script, ForeignKey $refFK) $inputCollectionEntry = lcfirst($this->getRefFKPhpNameAffix($refFK, false)); $collName = $this->getRefFKCollVarName($refFK); - $relCol = $this->getFKPhpNameAffix($refFK, $plural = false); + $relCol = $this->getFKPhpNameAffix($refFK, false); $script .= " /** @@ -4799,7 +4777,7 @@ protected function addRefFKDoAdd(&$script, ForeignKey $refFK) protected function doAdd{$relatedObjectClassName}($className \${$lowerRelatedObjectClassName}) { \$this->{$collName}[]= \${$lowerRelatedObjectClassName}; - \${$lowerRelatedObjectClassName}->set" . $this->getFKPhpNameAffix($refFK, $plural = false) . "(\$this); + \${$lowerRelatedObjectClassName}->set" . $this->getFKPhpNameAffix($refFK, false) . "(\$this); } "; } @@ -4821,12 +4799,12 @@ protected function addRefFKRemove(&$script, ForeignKey $refFK) } $relatedName = $this->getRefFKPhpNameAffix($refFK, $plural = true); - $relatedObjectClassName = $this->getRefFKPhpNameAffix($refFK, $plural = false); + $relatedObjectClassName = $this->getRefFKPhpNameAffix($refFK, false); $inputCollection = lcfirst($relatedName . 'ScheduledForDeletion'); $lowerRelatedObjectClassName = lcfirst($relatedObjectClassName); $collName = $this->getRefFKCollVarName($refFK); - $relCol = $this->getFKPhpNameAffix($refFK, $plural = false); + $relCol = $this->getFKPhpNameAffix($refFK, false); $localColumn = $refFK->getLocalColumn(); $script .= " @@ -4927,8 +4905,8 @@ public function set" . $this->getRefFKPhpNameAffix($refFK, false) . "($className \$this->$varName = \$v; // Make sure that that the passed-in $className isn't already associated with this object - if (\$v !== null && \$v->get" . $this->getFKPhpNameAffix($refFK, $plural = false) . "(null, false) === null) { - \$v->set" . $this->getFKPhpNameAffix($refFK, $plural = false) . "(\$this); + if (\$v !== null && \$v->get" . $this->getFKPhpNameAffix($refFK, false) . "(null, false) === null) { + \$v->set" . $this->getFKPhpNameAffix($refFK, false) . "(\$this); } return \$this; @@ -5233,7 +5211,7 @@ protected function addRefFkScheduledForDeletion(&$script, ForeignKey $refFK) { $relatedName = $this->getRefFKPhpNameAffix($refFK, $plural = true); $lowerRelatedName = lcfirst($relatedName); - $lowerSingleRelatedName = lcfirst($this->getRefFKPhpNameAffix($refFK, $plural = false)); + $lowerSingleRelatedName = lcfirst($this->getRefFKPhpNameAffix($refFK, false)); $queryClassName = $this->getNewStubQueryBuilder($refFK->getTable())->getClassname(); $script .= " @@ -5317,8 +5295,6 @@ public function clear{$relCol}() "; } - // addRefererClear() - /** * Adds the method that clears the referrer fkey collection. * @@ -5343,8 +5319,6 @@ public function resetPartial{$relCol}(\$v = true) "; } - // addRefFKPartial() - /** * Adds the method that initializes the referrer fkey collection. * @@ -5487,7 +5461,7 @@ protected function addCrossFKCreateQuery(&$script, CrossForeignKeys $crossFKs) } $refFK = $crossFKs->getIncomingForeignKey(); - $selfRelationName = $this->getFKPhpNameAffix($refFK, $plural = false); + $selfRelationName = $this->getFKPhpNameAffix($refFK, false); $firstFK = $crossFKs->getCrossForeignKeys()[0]; $firstFkName = $this->getFKPhpNameAffix($firstFK, true); @@ -5563,7 +5537,7 @@ public function create{$firstFkName}Query($signature, Criteria \$criteria = null protected function addCrossFKGet(&$script, CrossForeignKeys $crossFKs) { $refFK = $crossFKs->getIncomingForeignKey(); - $selfRelationName = $this->getFKPhpNameAffix($refFK, $plural = false); + $selfRelationName = $this->getFKPhpNameAffix($refFK, false); $crossRefTableName = $crossFKs->getMiddleTable()->getName(); if (1 < count($crossFKs->getCrossForeignKeys()) || $crossFKs->getUnclassifiedPrimaryKeys()) { @@ -5607,7 +5581,7 @@ public function get{$relatedName}(\$criteria = null, ConnectionInterface \$con = \$query = $relatedQueryClassName::create(null, \$criteria) ->filterBy{$selfRelationName}(\$this)"; foreach ($crossFKs->getCrossForeignKeys() as $fk) { - $varName = $this->getFKPhpNameAffix($fk, $plural = false); + $varName = $this->getFKPhpNameAffix($fk, false); $script .= " ->join{$varName}()"; } @@ -5622,7 +5596,7 @@ public function get{$relatedName}(\$criteria = null, ConnectionInterface \$con = "; foreach ($crossFKs->getCrossForeignKeys() as $fk) { - $varName = $this->getFKPhpNameAffix($fk, $plural = false); + $varName = $this->getFKPhpNameAffix($fk, false); $script .= " \$combination[] = \$item->get{$varName}();"; } @@ -5947,12 +5921,12 @@ protected function addCrossFKAdd(&$script, CrossForeignKeys $crossFKs) $refFK = $crossFKs->getIncomingForeignKey(); foreach ($crossFKs->getCrossForeignKeys() as $crossFK) { - $relSingleNamePlural = $this->getFKPhpNameAffix($crossFK, $plural = true); - $relSingleName = $this->getFKPhpNameAffix($crossFK, $plural = false); + $relSingleNamePlural = $this->getFKPhpNameAffix($crossFK, true); + $relSingleName = $this->getFKPhpNameAffix($crossFK, false); $collSingleName = $this->getCrossFKVarName($crossFK); - $relCombineNamePlural = $this->getCrossFKsPhpNameAffix($crossFKs, $plural = true); - $relCombineName = $this->getCrossFKsPhpNameAffix($crossFKs, $plural = false); + $relCombineNamePlural = $this->getCrossFKsPhpNameAffix($crossFKs, true); + $relCombineName = $this->getCrossFKsPhpNameAffix($crossFKs, false); $collCombinationVarName = 'combination' . ucfirst($this->getCrossFKsVarName($crossFKs)); $collName = 1 < count($crossFKs->getCrossForeignKeys()) || $crossFKs->getUnclassifiedPrimaryKeys() ? $collCombinationVarName : $collSingleName; @@ -6017,12 +5991,12 @@ protected function getCrossFKGetterSignature(CrossForeignKeys $crossFKs, $exclud */ protected function addCrossFKDoAdd(&$script, CrossForeignKeys $crossFKs) { - $selfRelationName = $this->getFKPhpNameAffix($crossFKs->getIncomingForeignKey(), $plural = false); - $selfRelationNamePlural = $this->getFKPhpNameAffix($crossFKs->getIncomingForeignKey(), $plural = true); - $relatedObjectClassName = $this->getCrossFKsPhpNameAffix($crossFKs, $plural = false); + $selfRelationName = $this->getFKPhpNameAffix($crossFKs->getIncomingForeignKey(), false); + $selfRelationNamePlural = $this->getFKPhpNameAffix($crossFKs->getIncomingForeignKey(), true); + $relatedObjectClassName = $this->getCrossFKsPhpNameAffix($crossFKs, false); $className = $this->getClassNameFromTable($crossFKs->getIncomingForeignKey()->getTable()); - $refKObjectClassName = $this->getRefFKPhpNameAffix($crossFKs->getIncomingForeignKey(), $plural = false); + $refKObjectClassName = $this->getRefFKPhpNameAffix($crossFKs->getIncomingForeignKey(), false); $tblFK = $crossFKs->getIncomingForeignKey()->getTable(); $foreignObjectName = '$' . $tblFK->getCamelCaseName(); @@ -6038,7 +6012,7 @@ protected function doAdd{$relatedObjectClassName}($signature) "; if (1 < count($crossFKs->getCrossForeignKeys()) || $crossFKs->getUnclassifiedPrimaryKeys()) { foreach ($crossFKs->getCrossForeignKeys() as $crossFK) { - $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, $plural = false); + $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, false); $lowerRelatedObjectClassName = lcfirst($relatedObjectClassName); $script .= " {$foreignObjectName}->set{$relatedObjectClassName}(\${$lowerRelatedObjectClassName});"; @@ -6052,7 +6026,7 @@ protected function doAdd{$relatedObjectClassName}($signature) } } else { $crossFK = $crossFKs->getCrossForeignKeys()[0]; - $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, $plural = false); + $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, false); $lowerRelatedObjectClassName = lcfirst($relatedObjectClassName); $script .= " {$foreignObjectName}->set{$relatedObjectClassName}(\${$lowerRelatedObjectClassName});"; @@ -6061,13 +6035,13 @@ protected function doAdd{$relatedObjectClassName}($signature) $refFK = $crossFKs->getIncomingForeignKey(); $script .= " - {$foreignObjectName}->set" . $this->getFKPhpNameAffix($refFK, $plural = false) . "(\$this); + {$foreignObjectName}->set" . $this->getFKPhpNameAffix($refFK, false) . "(\$this); \$this->add{$refKObjectClassName}({$foreignObjectName});\n"; if (1 < count($crossFKs->getCrossForeignKeys()) || $crossFKs->getUnclassifiedPrimaryKeys()) { foreach ($crossFKs->getCrossForeignKeys() as $crossFK) { - $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, $plural = false); + $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, false); $lowerRelatedObjectClassName = lcfirst($relatedObjectClassName); $getterName = $this->getCrossRefFKGetterName($crossFKs, $crossFK); @@ -6084,7 +6058,7 @@ protected function doAdd{$relatedObjectClassName}($signature) }\n"; } } else { - $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, $plural = false); + $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, false); $lowerRelatedObjectClassName = lcfirst($relatedObjectClassName); $getterSignature = $this->getCrossFKGetterSignature($crossFKs, '$' . $lowerRelatedObjectClassName); $script .= " @@ -6142,7 +6116,7 @@ protected function getCrossRefFKRemoveObjectNames(CrossForeignKeys $crossFKs, Fo */ protected function addCrossFKRemove(&$script, CrossForeignKeys $crossFKs) { - $relCol = $this->getCrossFKsPhpNameAffix($crossFKs, $plural = true); + $relCol = $this->getCrossFKsPhpNameAffix($crossFKs, true); if (1 < count($crossFKs->getCrossForeignKeys()) || $crossFKs->getUnclassifiedPrimaryKeys()) { $collName = 'combination' . ucfirst($this->getCrossFKsVarName($crossFKs)); } else { @@ -6152,13 +6126,13 @@ protected function addCrossFKRemove(&$script, CrossForeignKeys $crossFKs) $tblFK = $crossFKs->getIncomingForeignKey()->getTable(); $M2MScheduledForDeletion = $this->getCrossScheduledForDeletionVarName($crossFKs); - $relatedObjectClassName = $this->getCrossFKsPhpNameAffix($crossFKs, $plural = false); + $relatedObjectClassName = $this->getCrossFKsPhpNameAffix($crossFKs, false); [$signature, $shortSignature, $normalizedShortSignature, $phpDoc] = $this->getCrossFKAddMethodInformation($crossFKs); $names = str_replace('$', '', $normalizedShortSignature); $className = $this->getClassNameFromTable($crossFKs->getIncomingForeignKey()->getTable()); - $refKObjectClassName = $this->getRefFKPhpNameAffix($crossFKs->getIncomingForeignKey(), $plural = false); + $refKObjectClassName = $this->getRefFKPhpNameAffix($crossFKs->getIncomingForeignKey(), false); $foreignObjectName = '$' . $tblFK->getCamelCaseName(); $script .= " @@ -6173,10 +6147,10 @@ public function remove{$relatedObjectClassName}($signature) if (\$this->get{$relCol}()->contains({$shortSignature})) { {$foreignObjectName} = new {$className}();"; foreach ($crossFKs->getCrossForeignKeys() as $crossFK) { - $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, $plural = false); + $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, false); $lowerRelatedObjectClassName = lcfirst($relatedObjectClassName); - $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, $plural = false); + $relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, false); $script .= " {$foreignObjectName}->set{$relatedObjectClassName}(\${$lowerRelatedObjectClassName});"; @@ -6284,8 +6258,8 @@ protected function doSave(ConnectionInterface \$con" . ($reloadOnUpdate || $relo \$this->set" . $this->getFKPhpNameAffix($fk, false) . "(\$this->$aVarName); } "; - } // foreach foreign k - } // if (count(foreign keys)) + } + } $script .= " if (\$this->isNew() || \$this->isModified()) { @@ -6358,8 +6332,8 @@ protected function doSave(ConnectionInterface \$con" . ($reloadOnUpdate || $relo } } "; - } // if refFK->isLocalPrimaryKey() - } /* foreach getReferrers() */ + } + } $script .= " \$this->alreadyInSave = false; @@ -6927,17 +6901,15 @@ public function ensureConsistency() if (\$this->" . $varName . " !== null && \$this->$clo !== \$this->" . $varName . '->get' . $colFK->getPhpName() . "()) { \$this->$varName = null; }"; - } // foreach - } /* if col is foreign key */ - } // foreach + } + } + } $script .= " } // ensureConsistency "; } - // addCheckRelConsistency - /** * Adds the copy() method, which (in complex OM) includes the $deepCopy param for making copies of related objects. * @@ -7014,7 +6986,7 @@ public function copyInto(\$copyObj, \$deepCopy = false, \$makeNew = true) $script .= " \$copyObj->set" . $col->getPhpName() . '($this->get' . $col->getPhpName() . '());'; } - } // foreach + } // Avoid useless code by checking to see if there are any referrers // to this table: @@ -7050,7 +7022,7 @@ public function copyInto(\$copyObj, \$deepCopy = false, \$makeNew = true) } // HL: commenting out close of self-referential check // } /* if tblFK != table */ - } /* foreach */ + } $script .= " } // if (\$deepCopy) "; @@ -7067,15 +7039,13 @@ public function copyInto(\$copyObj, \$deepCopy = false, \$makeNew = true) $coldefval = var_export($coldefval, true); $script .= " \$copyObj->set" . $col->getPhpName() . "($coldefval); // this is a auto-increment column, so set to default value"; - } // foreach + } $script .= " } } "; } - // addCopyInto() - /** * Adds clear method * diff --git a/src/Propel/Generator/Builder/Om/QueryBuilder.php b/src/Propel/Generator/Builder/Om/QueryBuilder.php index 0150524817..a2d78eac89 100644 --- a/src/Propel/Generator/Builder/Om/QueryBuilder.php +++ b/src/Propel/Generator/Builder/Om/QueryBuilder.php @@ -1614,7 +1614,7 @@ public function use" . $relationName . 'Query($relationAlias = null, $joinType = */ protected function addFilterByCrossFK(&$script, CrossForeignKeys $crossFKs) { - $relationName = $this->getRefFKPhpNameAffix($crossFKs->getIncomingForeignKey(), $plural = false); + $relationName = $this->getRefFKPhpNameAffix($crossFKs->getIncomingForeignKey(), false); foreach ($crossFKs->getCrossForeignKeys() as $crossFK) { $queryClass = $this->getQueryClassName(); @@ -1622,7 +1622,7 @@ protected function addFilterByCrossFK(&$script, CrossForeignKeys $crossFKs) $foreignTable = $crossFK->getForeignTable(); $fkPhpName = $foreignTable->getPhpName(); $crossTableName = $crossRefTable->getName(); - $relName = $this->getFKPhpNameAffix($crossFK, $plural = false); + $relName = $this->getFKPhpNameAffix($crossFK, false); $objectName = '$' . $foreignTable->getCamelCaseName(); $script .= " /** @@ -2022,9 +2022,9 @@ protected function doOnDeleteCascade(ConnectionInterface \$con) $script .= " \$affectedRows += \$query->delete(\$con);"; - } // if cascade && fkey table name != curr table name - } // if not for ref only - } // foreach foreign keys + } + } + } $script .= " } @@ -2104,9 +2104,9 @@ protected function doOnDeleteSetNull(ConnectionInterface \$con) $script .= "\$query->update(\$updateValues, \$con); "; - } // if setnull && fkey table name != curr table name - } // if not for ref only - } // foreach foreign keys + } + } + } $script .= " } diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index a393ce19d3..0c1acd6e33 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -231,7 +231,7 @@ protected function addColumnNameConstants(&$script) */ const " . $col->getConstantName() . " = '" . $this->getTable()->getName() . '.' . $col->getName() . "'; "; - } // foreach + } } /** @@ -586,7 +586,7 @@ public function initialize() $script .= " \$this->getColumn('$columnName')->setPrimaryString(true);"; } - } // foreach + } $script .= " } // initialize() diff --git a/src/Propel/Runtime/Collection/ObjectCollection.php b/src/Propel/Runtime/Collection/ObjectCollection.php index a782e29613..390c3feb58 100644 --- a/src/Propel/Runtime/Collection/ObjectCollection.php +++ b/src/Propel/Runtime/Collection/ObjectCollection.php @@ -423,6 +423,8 @@ public function search($element) */ protected function rebuildIndex() { + $this->index = []; + $this->indexSplHash = []; foreach ($this->data as $idx => $value) { $hashCode = $this->getHashCode($value); $this->index[$hashCode] = $idx; From c6c3d37dffb0a85eef6755c09fa4cdadf8262078 Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 28 Jul 2020 01:23:43 +0200 Subject: [PATCH 128/208] More PHPStan fixes. --- composer.json | 5 ++-- phpstan-baseline.neon | 5 ---- .../Common/Config/Loader/FileLoader.php | 5 +++- .../ConcreteInheritanceBehavior.php | 2 +- .../Generator/Builder/Om/ObjectBuilder.php | 12 +++++----- .../Generator/Builder/Om/TableMapBuilder.php | 4 ++-- .../Generator/Builder/Util/PropelTemplate.php | 6 ++--- .../Generator/Command/AbstractCommand.php | 4 +++- .../Command/Console/Input/ArrayInput.php | 5 +++- .../Command/DatabaseReverseCommand.php | 2 +- .../Command/MigrationStatusCommand.php | 1 + .../Generator/Command/SqlBuildCommand.php | 5 ---- .../Generator/Command/TestPrepareCommand.php | 2 +- .../Generator/Config/GeneratorConfig.php | 11 +++++++-- src/Propel/Generator/Model/Column.php | 8 ++++--- src/Propel/Generator/Model/Domain.php | 13 ++++++---- src/Propel/Generator/Model/Schema.php | 9 +++++++ .../Runtime/ActiveQuery/BaseModelCriteria.php | 2 +- src/Propel/Runtime/ActiveQuery/Criteria.php | 6 ++--- .../Criterion/AbstractCriterion.php | 2 +- src/Propel/Runtime/ActiveQuery/Join.php | 12 ++++++++-- .../Runtime/ActiveQuery/ModelCriteria.php | 24 ++++++++++++++++--- src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php | 5 +++- .../Runtime/Collection/OnDemandIterator.php | 2 +- .../Runtime/Connection/ConnectionWrapper.php | 4 ++-- .../DataFetcher/AbstractDataFetcher.php | 2 +- .../Runtime/DataFetcher/PDODataFetcher.php | 4 +++- .../Runtime/Formatter/ArrayFormatter.php | 6 +++-- .../Runtime/Formatter/ObjectFormatter.php | 1 + src/Propel/Runtime/Map/TableMap.php | 2 +- .../StandardServiceContainer.php | 4 ++++ src/Propel/Runtime/Util/Profiler.php | 2 +- src/Propel/Runtime/Util/PropelModelPager.php | 5 +++- .../Validator/Constraints/UniqueValidator.php | 5 ++-- .../Builder/Om/GeneratedObjectRelTest.php | 6 +++++ .../Builder/Om/GeneratedObjectTest.php | 12 +++++----- .../Helpers/Bookstore/BookstoreTestBase.php | 1 + tests/Propel/Tests/TestCaseFixtures.php | 6 +++-- 38 files changed, 141 insertions(+), 71 deletions(-) diff --git a/composer.json b/composer.json index db87f98145..b575a762d9 100644 --- a/composer.json +++ b/composer.json @@ -48,9 +48,8 @@ "scripts": { "cs-check": "phpcs -p -s --standard=config/phpcs.xml src/", "cs-fix": "phpcbf -p --standard=config/phpcs.xml src/", - "stan": [ - "vendor/bin/phpstan analyze" - ] + "stan": "vendor/bin/phpstan analyze", + "stan-baseline": "vendor/bin/phpstan analyze --generate-baseline" }, "extra": { "branch-alias": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2dc63f3fc3..bb58a2f288 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -285,11 +285,6 @@ parameters: count: 1 path: src/Propel/Generator/Model/Domain.php - - - message: "#^Parameter \\#2 \\$value of method DOMElement\\:\\:setAttribute\\(\\) expects string, int\\<1, max\\>\\|int\\ given\\.$#" - count: 1 - path: src/Propel/Generator/Model/Domain.php - - message: "#^If condition is always true\\.$#" count: 1 diff --git a/src/Propel/Common/Config/Loader/FileLoader.php b/src/Propel/Common/Config/Loader/FileLoader.php index e75fdfbf2b..96363708c3 100644 --- a/src/Propel/Common/Config/Loader/FileLoader.php +++ b/src/Propel/Common/Config/Loader/FileLoader.php @@ -90,11 +90,14 @@ public function resolveParams(array $configuration) * * @throws \Propel\Common\Config\Exception\InputOutputException If the path isnot readable * - * @return array|string + * @return string */ protected function getPath($file) { $path = $this->locator->locate($file); + if (!is_string($path)) { + throw new InputOutputException("$file must return a single path."); + } if (!is_readable($path)) { throw new InputOutputException("You don't have permissions to access configuration file $file."); diff --git a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php index 5a61bd6f86..b15b349aeb 100644 --- a/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php +++ b/src/Propel/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehavior.php @@ -290,7 +290,7 @@ public function syncParentToChild($parentClass \$parent) if ($columns === true) { $columns = $parentTable->getColumns(); } else { - $columnNames = $columns; + $columnNames = $columns ?: []; $columns = []; foreach ($columnNames as $columnName) { $column = $this->getTable()->getColumn($columnName); diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index 12b872323b..d01cef62d9 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -198,9 +198,9 @@ protected function getDefaultValueString(Column $column) if (!in_array($val, $valueSet)) { throw new EngineException(sprintf('Default Value "%s" is not among the enumerated values', $val)); } - $defaultValue = array_search($val, $valueSet); + $defaultValue = (string)array_search($val, $valueSet); } elseif ($column->isSetType()) { - $defaultValue = SetColumnConverter::convertToInt($val, $column->getValueSet()); + $defaultValue = (string)SetColumnConverter::convertToInt($val, $column->getValueSet()); } elseif ($column->isPhpPrimitiveType()) { settype($val, $column->getPhpType()); $defaultValue = var_export($val, true); @@ -4186,9 +4186,9 @@ protected function addFKAccessor(&$script, ForeignKey $fk) if ($rightValueOrColumn instanceof Column) { $localColumns[$rightValueOrColumn->getPosition()] = '$this->' . $clo; - if ($cptype == 'int' || $cptype == 'float' || $cptype == 'double') { + if ($cptype === 'int' || $cptype === 'float' || $cptype === 'double') { $conditional .= $and . '$this->' . $clo . ' != 0'; - } elseif ($cptype == 'string') { + } elseif ($cptype === 'string') { $conditional .= $and . '($this->' . $clo . ' !== "" && $this->' . $clo . ' !== null)'; } else { $conditional .= $and . '$this->' . $clo . ' !== null'; @@ -6510,7 +6510,7 @@ protected function addDoInsertBodyRaw() } // if non auto-increment but using sequence, get the id first - if (!$platform->isNativeIdMethodAutoIncrement() && $table->getIdMethod() == 'native') { + if (!$platform->isNativeIdMethodAutoIncrement() && $table->getIdMethod() === 'native') { $column = $table->getFirstPrimaryKeyColumn(); if (!$column) { throw new PropelException('Cannot find primary key column in table `' . $table->getName() . '`.'); @@ -6571,7 +6571,7 @@ protected function addDoInsertBodyRaw() "; // if auto-increment, get the id after - if ($platform->isNativeIdMethodAutoIncrement() && $table->getIdMethod() == 'native') { + if ($platform->isNativeIdMethodAutoIncrement() && $table->getIdMethod() === 'native') { $script .= " try {"; $script .= $platform->getIdentifierPhp('$pk', '$con', $primaryKeyMethodInfo); diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index 0c1acd6e33..9b05167c1a 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -517,7 +517,7 @@ public function initialize() \$this->setIdentifierQuoting(" . ($table->isIdentifierQuotingEnabled() ? 'true' : 'false') . "); \$this->setClassName('" . addslashes($this->getStubObjectBuilder()->getFullyQualifiedClassName()) . "'); \$this->setPackage('" . parent::getPackage() . "');"; - if ($table->getIdMethod() == 'native') { + if ($table->getIdMethod() === 'native') { $script .= " \$this->setUseIdGenerator(true);"; } else { @@ -696,7 +696,7 @@ public function getBehaviors() /** * Adds the PHP code to return a instance pool key for the passed-in primary key variable names. * - * @param array $pkphp An array of PHP var names / method calls representing complete pk. + * @param string[]|string $pkphp An array of PHP var names / method calls representing complete pk. * * @return string */ diff --git a/src/Propel/Generator/Builder/Util/PropelTemplate.php b/src/Propel/Generator/Builder/Util/PropelTemplate.php index d5dd022e98..4600c97786 100644 --- a/src/Propel/Generator/Builder/Util/PropelTemplate.php +++ b/src/Propel/Generator/Builder/Util/PropelTemplate.php @@ -21,12 +21,12 @@ class PropelTemplate { /** - * @var string + * @var string|null */ protected $template; /** - * @var string + * @var string|null */ protected $templateFile; @@ -75,7 +75,7 @@ public function setTemplateFile($filePath) * * @param array $vars An associative array of arguments to be rendered * - * @throws InvalidArgumentException + * @throws \Propel\Generator\Exception\InvalidArgumentException * * @return string The rendered template */ diff --git a/src/Propel/Generator/Command/AbstractCommand.php b/src/Propel/Generator/Command/AbstractCommand.php index 003341efeb..6bd47fe982 100644 --- a/src/Propel/Generator/Command/AbstractCommand.php +++ b/src/Propel/Generator/Command/AbstractCommand.php @@ -35,7 +35,9 @@ abstract class AbstractCommand extends Command protected $filesystem; /** - * @inheritDoc + * {@inheritDoc} + * + * @return void */ protected function configure() { diff --git a/src/Propel/Generator/Command/Console/Input/ArrayInput.php b/src/Propel/Generator/Command/Console/Input/ArrayInput.php index 54bc277819..cd206121a9 100644 --- a/src/Propel/Generator/Command/Console/Input/ArrayInput.php +++ b/src/Propel/Generator/Command/Console/Input/ArrayInput.php @@ -133,7 +133,9 @@ public function __toString() } /** - * @inheritDoc + * {@inheritDoc} + * + * @return void */ protected function parse() { @@ -177,6 +179,7 @@ private function addShortOption(string $shortcut, $value) * @param mixed|null $value * * @throws \Symfony\Component\Console\Exception\InvalidOptionException When a required value is missing + * * @return void */ private function addLongOption(string $name, $value) diff --git a/src/Propel/Generator/Command/DatabaseReverseCommand.php b/src/Propel/Generator/Command/DatabaseReverseCommand.php index ee7d507752..f5cdcabff3 100644 --- a/src/Propel/Generator/Command/DatabaseReverseCommand.php +++ b/src/Propel/Generator/Command/DatabaseReverseCommand.php @@ -56,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $configOptions = []; - $connection = $input->getArgument('connection'); + $connection = (string)$input->getArgument('connection'); if (strpos($connection, ':') === false) { //treat it as connection name $configOptions['propel']['reverse']['connection'] = $connection; diff --git a/src/Propel/Generator/Command/MigrationStatusCommand.php b/src/Propel/Generator/Command/MigrationStatusCommand.php index 4a38cbc5a7..9a7e32ea91 100644 --- a/src/Propel/Generator/Command/MigrationStatusCommand.php +++ b/src/Propel/Generator/Command/MigrationStatusCommand.php @@ -59,6 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $manager->setGeneratorConfig($generatorConfig); $connections = []; + /** @var string[] $optionConnections */ $optionConnections = $input->getOption('connection'); if (!$optionConnections) { $connections = $generatorConfig->getBuildConnections(); diff --git a/src/Propel/Generator/Command/SqlBuildCommand.php b/src/Propel/Generator/Command/SqlBuildCommand.php index 08facd96b7..4e01f19181 100644 --- a/src/Propel/Generator/Command/SqlBuildCommand.php +++ b/src/Propel/Generator/Command/SqlBuildCommand.php @@ -57,27 +57,22 @@ protected function execute(InputInterface $input, OutputInterface $output): int $configOptions['propel']['paths']['schemaDir'] = $option; break; - case 'output-dir': $configOptions['propel']['paths']['sqlDir'] = $option; break; - case 'schema-name': $configOptions['propel']['generator']['schema']['basename'] = $option; break; - case 'table-prefix': $configOptions['propel']['generator']['tablePrefix'] = $option; break; - case 'mysql-engine': $configOptions['propel']['database']['adapters']['mysql']['tableType'] = $option; break; - case 'composer-dir': $configOptions['propel']['paths']['composerDir'] = $option; diff --git a/src/Propel/Generator/Command/TestPrepareCommand.php b/src/Propel/Generator/Command/TestPrepareCommand.php index 468754d0fc..eb1100a02c 100644 --- a/src/Propel/Generator/Command/TestPrepareCommand.php +++ b/src/Propel/Generator/Command/TestPrepareCommand.php @@ -69,7 +69,7 @@ public function __construct() { parent::__construct(); - $this->root = realpath(__DIR__ . '/../../../../'); + $this->root = (string)realpath(__DIR__ . '/../../../../'); } /** diff --git a/src/Propel/Generator/Config/GeneratorConfig.php b/src/Propel/Generator/Config/GeneratorConfig.php index 50de74e5fb..ff5c40ba8d 100644 --- a/src/Propel/Generator/Config/GeneratorConfig.php +++ b/src/Propel/Generator/Config/GeneratorConfig.php @@ -11,6 +11,7 @@ namespace Propel\Generator\Config; use Propel\Common\Config\ConfigurationManager; +use Propel\Common\Pluralizer\PluralizerInterface; use Propel\Generator\Exception\BuildException; use Propel\Generator\Exception\ClassNotFoundException; use Propel\Generator\Exception\InvalidArgumentException; @@ -29,6 +30,8 @@ */ class GeneratorConfig extends ConfigurationManager implements GeneratorConfigInterface { + protected const PLURALIZER = PluralizerInterface::class; + /** * @var \Propel\Generator\Util\BehaviorLocator */ @@ -156,6 +159,7 @@ public function getConfiguredBuilder(Table $table, $type) { $classname = $this->getConfigProperty('generator.objectModel.builders.' . $type); + /** @var \Propel\Generator\Builder\DataModelBuilder $builder */ $builder = $this->getInstance($classname, $table); $builder->setGeneratorConfig($this); @@ -171,7 +175,10 @@ public function getConfiguredPluralizer() { $classname = $this->get()['generator']['objectModel']['pluralizerClass']; - return $this->getInstance($classname, null, '\\Propel\\Common\\Pluralizer\\PluralizerInterface'); + /** @var \Propel\Common\Pluralizer\PluralizerInterface $pluralizer */ + $pluralizer = $this->getInstance($classname, null, static::PLURALIZER); + + return $pluralizer; } /** @@ -186,7 +193,7 @@ public function getBuildConnections() $connectionNames = $this->get()['generator']['connections']; $reverseConnection = $this->getConfigProperty('reverse.connection'); - if ($reverseConnection !== null && !in_array($reverseConnection, $connectionNames)) { + if ($reverseConnection !== null && !in_array($reverseConnection, $connectionNames, true)) { $connectionNames[] = $reverseConnection; } diff --git a/src/Propel/Generator/Model/Column.php b/src/Propel/Generator/Model/Column.php index 9533eaedb5..173ad295df 100644 --- a/src/Propel/Generator/Model/Column.php +++ b/src/Propel/Generator/Model/Column.php @@ -337,6 +337,7 @@ protected function setupObject() // Add type, size information to associated Domain object $domain->replaceSqlType($this->getAttribute('sqlType')); + if ( !$this->getAttribute('size') && $domain->getType() === 'VARCHAR' @@ -346,11 +347,12 @@ protected function setupObject() ) { $size = 255; } else { - $size = $this->getAttribute('size'); + $size = $this->getAttribute('size') ? (int)$this->getAttribute('size') : null; } - $domain->replaceSize($size); - $domain->replaceScale($this->getAttribute('scale')); + + $scale = $this->getAttribute('scale') ? (int)$this->getAttribute('scale') : null; + $domain->replaceScale($scale); $defval = $this->getAttribute('defaultValue', $this->getAttribute('default')); if ($defval !== null && strtolower($defval) !== 'null') { diff --git a/src/Propel/Generator/Model/Domain.php b/src/Propel/Generator/Model/Domain.php index 810e06ffa9..2d8599adea 100644 --- a/src/Propel/Generator/Model/Domain.php +++ b/src/Propel/Generator/Model/Domain.php @@ -29,7 +29,7 @@ class Domain extends MappingModel private $name; /** - * @var string + * @var string|null */ private $description; @@ -58,6 +58,9 @@ class Domain extends MappingModel */ private $defaultValue; + /** + * @var \Propel\Generator\Model\Database|null + */ private $database; /** @@ -124,8 +127,8 @@ protected function setupObject() $this->setDefaultValue(new ColumnDefaultValue($this->getAttribute('defaultExpr'), ColumnDefaultValue::TYPE_EXPR)); } - $this->size = $this->getAttribute('size'); - $this->scale = $this->getAttribute('scale'); + $this->size = $this->getAttribute('size') ? (int)$this->getAttribute('size') : null; + $this->scale = $this->getAttribute('scale') ? (int)$this->getAttribute('scale') : null; $this->description = $this->getAttribute('description'); } @@ -463,11 +466,11 @@ public function appendXml(DOMNode $node) } if ($this->size) { - $domainNode->setAttribute('size', $this->size); + $domainNode->setAttribute('size', (string)$this->size); } if ($this->scale) { - $domainNode->setAttribute('scale', $this->scale); + $domainNode->setAttribute('scale', (string)$this->scale); } if ($this->description) { diff --git a/src/Propel/Generator/Model/Schema.php b/src/Propel/Generator/Model/Schema.php index 7365f98bed..7c93534c9b 100644 --- a/src/Propel/Generator/Model/Schema.php +++ b/src/Propel/Generator/Model/Schema.php @@ -36,10 +36,19 @@ class Schema */ private $platform; + /** + * @var string + */ private $name; + /** + * @var bool + */ private $isInitialized; + /** + * @var \Propel\Generator\Config\GeneratorConfigInterface + */ protected $generatorConfig; /** diff --git a/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php b/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php index 550751d321..825bbd60cb 100644 --- a/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php @@ -43,7 +43,7 @@ class BaseModelCriteria extends Criteria implements IteratorAggregate protected $with = []; /** - * @phpstan-param class-string<\Propel\Runtime\Formatter\AbstractFormatter> + * @phpstan-var class-string<\Propel\Runtime\Formatter\AbstractFormatter> * * @var string */ diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index 87c62274f7..7ffaeb085a 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -231,7 +231,7 @@ class Criteria protected $queryComment; /** - * @var array + * @var string[] */ protected $aliases = []; @@ -1666,13 +1666,13 @@ public function mergeWith(Criteria $criteria, $operator = null) { // merge limit $limit = $criteria->getLimit(); - if ($limit != 0 && $this->getLimit() === - 1) { + if ($limit && $this->getLimit() === -1) { $this->limit = $limit; } // merge offset $offset = $criteria->getOffset(); - if ($offset != 0 && $this->getOffset() === 0) { + if ($offset && $this->getOffset() === 0) { $this->offset = $offset; } diff --git a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php index 12207ae17c..f72724e3b6 100644 --- a/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php +++ b/src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php @@ -126,7 +126,7 @@ public function init(Criteria $criteria) /** * Set the $column and $table properties based on a column name or object * - * @param ColumnMap|string $column + * @param \Propel\Runtime\Map\ColumnMap|string $column * * @return void */ diff --git a/src/Propel/Runtime/ActiveQuery/Join.php b/src/Propel/Runtime/ActiveQuery/Join.php index 11d99bc556..3b0c028db4 100644 --- a/src/Propel/Runtime/ActiveQuery/Join.php +++ b/src/Propel/Runtime/ActiveQuery/Join.php @@ -36,7 +36,11 @@ class Join public const EQUAL = '='; public const INNER_JOIN = 'INNER JOIN'; - // the left parts of the join condition + /** + * The left parts of the join condition + * + * @var array + */ protected $left = []; /** @@ -49,7 +53,11 @@ class Join */ protected $rightValues = []; - // the right parts of the join condition + /** + * The right parts of the join condition + * + * @var array + */ protected $right = []; /** diff --git a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php index 0fe53266c2..95f76e1c5b 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php @@ -59,6 +59,9 @@ class ModelCriteria extends BaseModelCriteria public const FORMAT_OBJECT = '\Propel\Runtime\Formatter\ObjectFormatter'; public const FORMAT_ON_DEMAND = '\Propel\Runtime\Formatter\OnDemandFormatter'; + /** + * @var bool + */ protected $useAliasInSQL = false; /** @@ -66,12 +69,23 @@ class ModelCriteria extends BaseModelCriteria */ protected $primaryCriteria; + /** + * @var bool + */ protected $isWithOneToMany = false; - // this is introduced to prevent useQuery->join from going wrong + /** + * This is introduced to prevent useQuery->join from going wrong + * + * @var \Propel\Runtime\ActiveQuery\Join|null + */ protected $previousJoin; - // whether to clone the current object before termination methods + /** + * Whether to clone the current object before termination methods + * + * @var bool + */ protected $isKeepQuery = true; // this is for the select method @@ -80,7 +94,11 @@ class ModelCriteria extends BaseModelCriteria */ protected $select; - // temporary property used in replaceNames + /** + * temporary property used in replaceNames + * + * @var string|null + */ protected $currentAlias; /** diff --git a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php index 15d008a17c..197a9753d1 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php @@ -78,7 +78,10 @@ public function getConnection($conparams) } /** - * @inheritDoc + * @param string $left + * @param string $right + * + * @return string */ public function compareRegex($left, $right) { diff --git a/src/Propel/Runtime/Collection/OnDemandIterator.php b/src/Propel/Runtime/Collection/OnDemandIterator.php index d57ef45f3f..a72d897495 100644 --- a/src/Propel/Runtime/Collection/OnDemandIterator.php +++ b/src/Propel/Runtime/Collection/OnDemandIterator.php @@ -105,7 +105,7 @@ public function current() /** * Gets the current key in the iterator * - * @return string + * @return int */ public function key() { diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index 2d13fb6cc1..b80beb5292 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -632,7 +632,7 @@ protected function isLogEnabledForMethod($methodName) } /** - * @param LoggerInterface $logger + * @param \Psr\Log\LoggerInterface $logger * * @return void */ @@ -675,7 +675,7 @@ public function log($msg) do { $callingMethod = $backtrace[$i]['function']; $i++; - } while ($callingMethod == 'log' && $i < $stackSize); + } while ($callingMethod === 'log' && $i < $stackSize); if (!$msg || !$this->isLogEnabledForMethod($callingMethod)) { return; diff --git a/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php b/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php index 0375013d7b..ba85d529e5 100644 --- a/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php @@ -29,7 +29,7 @@ public function setDataObject($dataObject) } /** - * @inheritDoc + * @return \Propel\Runtime\DataFetcher\PDODataFetcher */ public function getDataObject() { diff --git a/src/Propel/Runtime/DataFetcher/PDODataFetcher.php b/src/Propel/Runtime/DataFetcher/PDODataFetcher.php index 0dd20fb8a4..e02945419d 100644 --- a/src/Propel/Runtime/DataFetcher/PDODataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/PDODataFetcher.php @@ -64,7 +64,9 @@ public function getStyle() } /** - * @inheritDoc + * @param null $style + * + * @return array|null */ public function fetch($style = null) { diff --git a/src/Propel/Runtime/Formatter/ArrayFormatter.php b/src/Propel/Runtime/Formatter/ArrayFormatter.php index 9762cf265c..f416c663a5 100644 --- a/src/Propel/Runtime/Formatter/ArrayFormatter.php +++ b/src/Propel/Runtime/Formatter/ArrayFormatter.php @@ -37,6 +37,7 @@ class ArrayFormatter extends AbstractFormatter * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher * * @throws \Propel\Runtime\Exception\LogicException + * * @return array|\Propel\Runtime\Collection\Collection */ public function format(?DataFetcherInterface $dataFetcher = null) @@ -210,8 +211,9 @@ public function &getStructuredArrayFromRow($row) !isset($arrayToAugment[$modelWith->getRelationName()]) || !in_array( $this->alreadyHydratedObjects[$relAlias][$key], - $arrayToAugment[$modelWith->getRelationName()] - , true) + $arrayToAugment[$modelWith->getRelationName()], + true + ) ) { $arrayToAugment[$modelWith->getRelationName()][] = &$this->alreadyHydratedObjects[$relAlias][$key]; } diff --git a/src/Propel/Runtime/Formatter/ObjectFormatter.php b/src/Propel/Runtime/Formatter/ObjectFormatter.php index 0f3b6617ed..136e73258d 100644 --- a/src/Propel/Runtime/Formatter/ObjectFormatter.php +++ b/src/Propel/Runtime/Formatter/ObjectFormatter.php @@ -30,6 +30,7 @@ class ObjectFormatter extends AbstractFormatter * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher * * @throws \Propel\Runtime\Exception\LogicException + * * @return array|\Propel\Runtime\Collection\Collection */ public function format(?DataFetcherInterface $dataFetcher = null) diff --git a/src/Propel/Runtime/Map/TableMap.php b/src/Propel/Runtime/Map/TableMap.php index 347b7a2c30..360a2b4148 100644 --- a/src/Propel/Runtime/Map/TableMap.php +++ b/src/Propel/Runtime/Map/TableMap.php @@ -423,7 +423,7 @@ private static function getPrimaryKey(Criteria $criteria) * @param int|null $size An int specifying the size. * @param string|null $defaultValue * @param bool|null $pk True if column is a primary key. - * @param string|bool $fkTable A String with the foreign key table name. + * @param string|bool|null $fkTable A String with the foreign key table name. * @param string|null $fkColumn A String with the foreign key column name. * * @return \Propel\Runtime\Map\ColumnMap The newly created column. diff --git a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php index 4ccb8a4ab6..383988aad6 100644 --- a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php +++ b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php @@ -229,6 +229,8 @@ public function checkVersion($generatorVersion) } /** + * @phpstan-param class-string<\Propel\Runtime\Map\DatabaseMap> $databaseMapClass + * * @param string $databaseMapClass * * @return void @@ -417,6 +419,8 @@ public function setConnection($name, ConnectionInterface $connection) * The service container uses this class to instantiate a new profiler when * getProfiler() is called. * + * @phpstan-param class-string<\Propel\Runtime\Util\Profiler> $profilerClass + * * @param string $profilerClass * * @return void diff --git a/src/Propel/Runtime/Util/Profiler.php b/src/Propel/Runtime/Util/Profiler.php index 0c4642261a..46c57ea745 100644 --- a/src/Propel/Runtime/Util/Profiler.php +++ b/src/Propel/Runtime/Util/Profiler.php @@ -292,7 +292,7 @@ public static function getSnapshot() /** * Format a byte count into a human-readable representation. * - * @param int $bytes Byte count to convert. Can be negative. + * @param int|float $bytes Byte count to convert. Can be negative. * @param int $precision How many decimals to include. * * @return string diff --git a/src/Propel/Runtime/Util/PropelModelPager.php b/src/Propel/Runtime/Util/PropelModelPager.php index c01d741ae5..e77875259f 100644 --- a/src/Propel/Runtime/Util/PropelModelPager.php +++ b/src/Propel/Runtime/Util/PropelModelPager.php @@ -464,7 +464,10 @@ public function count() public function __call($name, $params) { try { - return call_user_func_array([$this->getResults(), $name], $params); + /** @var callable $callback */ + $callback = [$this->getResults(), $name]; + + return call_user_func_array($callback, $params); } catch (BadMethodCallException $exception) { throw new BadMethodCallException('Call to undefined method: ' . $name); } diff --git a/src/Propel/Runtime/Validator/Constraints/UniqueValidator.php b/src/Propel/Runtime/Validator/Constraints/UniqueValidator.php index c526044346..74e39caf07 100644 --- a/src/Propel/Runtime/Validator/Constraints/UniqueValidator.php +++ b/src/Propel/Runtime/Validator/Constraints/UniqueValidator.php @@ -36,9 +36,10 @@ public function validate($value, Constraint $constraint) $columnName = sprintf('%s.%s', $tableMap::TABLE_NAME, $this->context->getPropertyName()); - if ($this->context->getObject()->isNew() && $matches->count() > 0) { + $object = $this->context->getObject(); + if ($object->isNew() && $matches->count() > 0) { $this->context->addViolation($constraint->message); - } elseif ($this->context->getObject()->isModified() && $matches->count() > (in_array($columnName, $this->context->getObject()->getModifiedColumns()) ? 0 : 1)) { + } elseif ($object->isModified() && $matches->count() > (in_array($columnName, $object->getModifiedColumns()) ? 0 : 1)) { $this->context->addViolation($constraint->message); } } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectRelTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectRelTest.php index ce3d2bc826..d5d00e5202 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectRelTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectRelTest.php @@ -405,6 +405,9 @@ public function testRefFKAddReturnsCurrentObject() $this->assertSame($author, $ret); } + /** + * @return void + */ public function testSetterCollection() { // Ensure no data @@ -710,6 +713,9 @@ public function testSetterCollectionReplacesOldObjectsByNewObjects() $this->assertEquals(4, BookQuery::create()->count()); } + /** + * @return void + */ public function testSetterCollectionWithCustomNamedFKs() { // Ensure no data diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php index e254b7575a..2dde011975 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php @@ -1455,12 +1455,12 @@ public function testSetterOneToManyWithFkRequired() $this->assertEquals(1, BookQuery::create()->count()); $this->assertEquals(2, BookSummaryQuery::create()->count()); - $newBookSammary = new BookSummary(); - $newBookSammary->setSummary('My sammary'); + $newBookSummary = new BookSummary(); + $newBookSummary->setSummary('My summary'); // Kind of new collection $coll = clone $coll; - $coll[] = $newBookSammary; + $coll[] = $newBookSummary; $b->setBookSummaries($coll); $b->save(); @@ -1471,11 +1471,11 @@ public function testSetterOneToManyWithFkRequired() $this->assertEquals(3, BookSummaryQuery::create()->count()); // Add a new object - $newBookSammary1 = new BookSummary(); - $newBookSammary1->setSummary('My sammary 1'); + $newBookSummary1 = new BookSummary(); + $newBookSummary1->setSummary('My summary 1'); // Existing collection - The fix around reference is tested here. - $coll[] = $newBookSammary1; + $coll[] = $newBookSummary1; $b->setBookSummaries($coll); $b->save(); diff --git a/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php b/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php index 3c2026591a..26631967b1 100644 --- a/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php +++ b/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php @@ -23,6 +23,7 @@ abstract class BookstoreTestBase extends TestCaseFixturesDatabase * @var Boolean */ protected static $isInitialized = false; + /** * @var \PDO|\Propel\Runtime\Connection\ConnectionWrapper */ diff --git a/tests/Propel/Tests/TestCaseFixtures.php b/tests/Propel/Tests/TestCaseFixtures.php index e352626337..ee49ad0a3c 100644 --- a/tests/Propel/Tests/TestCaseFixtures.php +++ b/tests/Propel/Tests/TestCaseFixtures.php @@ -91,7 +91,9 @@ protected function setUp(): void $ns = '\\Propel\\Generator\\Command'; $r = new \ReflectionClass($ns.'\\'.$file->getBasename('.php')); if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract()) { - $app->add($r->newInstance()); + /** @var \Symfony\Component\Console\Command\Command $command */ + $command = $r->newInstance(); + $app->add($command); } } if (0 !== strpos($dsn, 'sqlite:')) { @@ -232,7 +234,7 @@ protected function getFixturesConnectionDsn() /** * Returns current database driver. * - * @return string[] + * @return string */ protected function getDriver() { From d739a691e5fef26c55ebe17d6170a2681d718388 Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 28 Jul 2020 12:06:08 +0200 Subject: [PATCH 129/208] PHPStan Level 6. --- phpstan.neon | 2 +- src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php | 8 +++++--- src/Propel/Runtime/DataFetcher/PDODataFetcher.php | 2 +- src/Propel/Runtime/Util/PropelDateTime.php | 10 ++++------ tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php | 6 ++++++ 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 443ac87a1d..8088d8b5e1 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,7 @@ includes: - phpstan-baseline.neon parameters: - level: 5 + level: 6 checkGenericClassInNonGenericObjectType: false checkMissingIterableValueType: false paths: diff --git a/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php b/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php index ba85d529e5..5e3e42f794 100644 --- a/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/AbstractDataFetcher.php @@ -8,7 +8,7 @@ abstract class AbstractDataFetcher implements DataFetcherInterface { /** - * @var mixed + * @var mixed|null */ protected $dataObject; @@ -21,7 +21,9 @@ public function __construct($dataObject) } /** - * @inheritDoc + * @param mixed|null $dataObject + * + * @return void */ public function setDataObject($dataObject) { @@ -29,7 +31,7 @@ public function setDataObject($dataObject) } /** - * @return \Propel\Runtime\DataFetcher\PDODataFetcher + * @return mixed */ public function getDataObject() { diff --git a/src/Propel/Runtime/DataFetcher/PDODataFetcher.php b/src/Propel/Runtime/DataFetcher/PDODataFetcher.php index e02945419d..3e762962c4 100644 --- a/src/Propel/Runtime/DataFetcher/PDODataFetcher.php +++ b/src/Propel/Runtime/DataFetcher/PDODataFetcher.php @@ -64,7 +64,7 @@ public function getStyle() } /** - * @param null $style + * @param int|null $style * * @return array|null */ diff --git a/src/Propel/Runtime/Util/PropelDateTime.php b/src/Propel/Runtime/Util/PropelDateTime.php index 452d6203c4..3025b19b55 100644 --- a/src/Propel/Runtime/Util/PropelDateTime.php +++ b/src/Propel/Runtime/Util/PropelDateTime.php @@ -49,20 +49,18 @@ protected static function isTimestamp($value) if (!is_numeric($value)) { return false; } - if (strlen((string)$value) === 8) { return false; } - $stamp = strtotime($value); - + $stamp = strtotime((string)$value); if ($stamp === false) { return true; } - $month = (int)date('m', $value); - $day = (int)date('d', $value); - $year = (int)date('Y', $value); + $month = (int)date('m', (int)$value); + $day = (int)date('d', (int)$value); + $year = (int)date('Y', (int)$value); return checkdate($month, $day, $year); } diff --git a/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php b/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php index a629a670b8..9c2f32d3f3 100644 --- a/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php +++ b/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php @@ -214,6 +214,7 @@ public function testIsTimestamp() { $this->assertEquals(false, TestPropelDateTime::isTimestamp('20110325')); $this->assertEquals(true, TestPropelDateTime::isTimestamp(1319580000)); + $this->assertEquals(true, TestPropelDateTime::isTimestamp('1319580000')); $this->assertEquals(false, TestPropelDateTime::isTimestamp('2011-07-20 00:00:00')); } @@ -246,6 +247,11 @@ public function testCreateHighPrecisioniTz() class TestPropelDateTime extends PropelDateTime { + /** + * @param mixed $value + * + * @return bool + */ public static function isTimestamp($value) { return parent::isTimestamp($value); From 5db98a5002fdbf6eb0cabfebf1e445216ba678ae Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 28 Jul 2020 12:49:04 +0200 Subject: [PATCH 130/208] Add CS check to travis. --- .travis.yml | 3 +-- config/phpcs.xml | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index de1819f81f..bf1476ba17 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,7 @@ language: php git: - strategy: clone depth: 1 - quiet: true dist: bionic @@ -488,6 +486,7 @@ jobs: - composer install --prefer-dist --no-interaction script: - composer stan + - composer cs-check allow_failures: - php: nightly diff --git a/config/phpcs.xml b/config/phpcs.xml index 43ebeb7fce..68ad039902 100644 --- a/config/phpcs.xml +++ b/config/phpcs.xml @@ -23,6 +23,15 @@ 0 + + 0 + + + 0 + + + 0 + 0 From 4b7c3f72a57542c0d0ce91e779070d058fef28be Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 29 Jul 2020 10:00:36 +0200 Subject: [PATCH 131/208] Fix the license header and add sniff rule. --- .gitattributes | 3 +++ .license | 4 +--- README.md | 17 +++++++++-------- config/phpcs.xml | 3 --- .../Common/Config/ConfigurationManager.php | 4 +--- .../Config/Exception/ExceptionInterface.php | 4 +--- .../Config/Exception/IniParseException.php | 4 +--- .../Config/Exception/InputOutputException.php | 4 +--- .../Exception/InvalidArgumentException.php | 4 +--- .../Exception/InvalidConfigurationException.php | 4 +--- .../Config/Exception/JsonParseException.php | 4 +--- .../Config/Exception/RuntimeException.php | 4 +--- .../Config/Exception/XmlParseException.php | 4 +--- src/Propel/Common/Config/FileLocator.php | 4 +--- .../Common/Config/Loader/DelegatingLoader.php | 4 +--- src/Propel/Common/Config/Loader/FileLoader.php | 4 +--- .../Common/Config/Loader/IniFileLoader.php | 4 +--- .../Common/Config/Loader/JsonFileLoader.php | 4 +--- .../Common/Config/Loader/LoaderResolver.php | 4 +--- .../Common/Config/Loader/PhpFileLoader.php | 4 +--- .../Common/Config/Loader/XmlFileLoader.php | 4 +--- .../Common/Config/Loader/YamlFileLoader.php | 4 +--- .../Common/Config/PropelConfiguration.php | 4 +--- .../Common/Config/XmlToArrayConverter.php | 4 +--- .../Exception/SetColumnConverterException.php | 5 ++--- .../Common/Pluralizer/PluralizerInterface.php | 4 +--- .../Pluralizer/SimpleEnglishPluralizer.php | 4 +--- .../Pluralizer/StandardEnglishPluralizer.php | 4 +--- src/Propel/Common/Util/SetColumnConverter.php | 4 +--- src/Propel/Generator/Application.php | 4 +--- .../AggregateColumn/AggregateColumnBehavior.php | 4 +--- .../AggregateColumnRelationBehavior.php | 4 +--- .../Behavior/Archivable/ArchivableBehavior.php | 4 +--- .../ArchivableBehaviorObjectBuilderModifier.php | 4 +--- .../ArchivableBehaviorQueryBuilderModifier.php | 4 +--- .../Behavior/AutoAddPk/AutoAddPkBehavior.php | 4 +--- .../ConcreteInheritanceBehavior.php | 4 +--- .../ConcreteInheritanceParentBehavior.php | 4 +--- .../Behavior/Delegate/DelegateBehavior.php | 4 +--- .../Generator/Behavior/I18n/I18nBehavior.php | 4 +--- .../I18n/I18nBehaviorObjectBuilderModifier.php | 4 +--- .../I18n/I18nBehaviorQueryBuilderModifier.php | 4 +--- .../Behavior/NestedSet/NestedSetBehavior.php | 4 +--- .../NestedSetBehaviorObjectBuilderModifier.php | 4 +--- .../NestedSetBehaviorQueryBuilderModifier.php | 4 +--- .../Behavior/QueryCache/QueryCacheBehavior.php | 4 +--- .../Behavior/Sluggable/SluggableBehavior.php | 4 +--- .../Behavior/Sortable/SortableBehavior.php | 4 +--- .../SortableBehaviorObjectBuilderModifier.php | 4 +--- .../SortableBehaviorQueryBuilderModifier.php | 4 +--- .../SortableBehaviorTableMapBuilderModifier.php | 4 +--- .../Timestampable/TimestampableBehavior.php | 4 +--- .../Behavior/Validate/ValidateBehavior.php | 4 +--- .../Versionable/VersionableBehavior.php | 4 +--- ...VersionableBehaviorObjectBuilderModifier.php | 4 +--- .../VersionableBehaviorQueryBuilderModifier.php | 4 +--- .../Generator/Builder/DataModelBuilder.php | 4 +--- .../Generator/Builder/Om/AbstractOMBuilder.php | 4 +--- .../Builder/Om/AbstractObjectBuilder.php | 4 +--- src/Propel/Generator/Builder/Om/ClassTools.php | 4 +--- .../Builder/Om/ExtensionObjectBuilder.php | 4 +--- .../Builder/Om/ExtensionQueryBuilder.php | 4 +--- .../Om/ExtensionQueryInheritanceBuilder.php | 4 +--- .../Generator/Builder/Om/InterfaceBuilder.php | 4 +--- .../Builder/Om/MultiExtendObjectBuilder.php | 4 +--- .../Generator/Builder/Om/ObjectBuilder.php | 4 +--- .../Generator/Builder/Om/QueryBuilder.php | 4 +--- .../Builder/Om/QueryInheritanceBuilder.php | 4 +--- .../Generator/Builder/Om/TableMapBuilder.php | 4 +--- .../Generator/Builder/Util/PropelTemplate.php | 4 +--- .../Generator/Builder/Util/SchemaReader.php | 4 +--- .../Generator/Command/AbstractCommand.php | 4 +--- .../Generator/Command/ConfigConvertCommand.php | 4 +--- .../Command/Console/Input/ArrayInput.php | 6 ++++++ .../Command/DatabaseReverseCommand.php | 4 +--- .../Command/GraphvizGenerateCommand.php | 4 +--- .../Generator/Command/Helper/ConsoleHelper.php | 6 ++++++ .../Generator/Command/Helper/ConsoleHelper3.php | 6 ++++++ .../Command/Helper/ConsoleHelperInterface.php | 6 ++++++ src/Propel/Generator/Command/InitCommand.php | 4 +--- .../Command/MigrationCreateCommand.php | 4 +--- .../Generator/Command/MigrationDiffCommand.php | 4 +--- .../Generator/Command/MigrationDownCommand.php | 4 +--- .../Command/MigrationMigrateCommand.php | 4 +--- .../Command/MigrationStatusCommand.php | 4 +--- .../Generator/Command/MigrationUpCommand.php | 4 +--- .../Generator/Command/ModelBuildCommand.php | 4 +--- .../Generator/Command/SqlBuildCommand.php | 4 +--- .../Generator/Command/SqlInsertCommand.php | 4 +--- .../Generator/Command/TestPrepareCommand.php | 4 +--- .../Generator/Config/ArrayToPhpConverter.php | 4 +--- src/Propel/Generator/Config/GeneratorConfig.php | 4 +--- .../Config/GeneratorConfigInterface.php | 4 +--- .../Generator/Config/QuickGeneratorConfig.php | 4 +--- .../Exception/BehaviorNotFoundException.php | 4 +--- .../Generator/Exception/BuildException.php | 4 +--- .../Exception/ClassNotFoundException.php | 4 +--- .../Exception/ConstraintNotFoundException.php | 4 +--- .../Generator/Exception/DiffException.php | 4 +--- .../Generator/Exception/EngineException.php | 4 +--- .../Generator/Exception/ExceptionInterface.php | 4 +--- .../Exception/InvalidArgumentException.php | 4 +--- .../Generator/Exception/LogicException.php | 4 +--- .../Generator/Exception/RuntimeException.php | 4 +--- .../Generator/Exception/SchemaException.php | 4 +--- .../Generator/Manager/AbstractManager.php | 4 +--- .../Generator/Manager/GraphvizManager.php | 4 +--- .../Generator/Manager/MigrationManager.php | 4 +--- src/Propel/Generator/Manager/ModelManager.php | 4 +--- src/Propel/Generator/Manager/ReverseManager.php | 4 +--- src/Propel/Generator/Manager/SqlManager.php | 4 +--- src/Propel/Generator/Model/Behavior.php | 4 +--- .../Generator/Model/BehaviorableTrait.php | 6 ++++++ src/Propel/Generator/Model/Column.php | 4 +--- .../Generator/Model/ColumnDefaultValue.php | 4 +--- .../Generator/Model/ConstraintNameGenerator.php | 4 +--- src/Propel/Generator/Model/CrossForeignKeys.php | 4 +--- src/Propel/Generator/Model/Database.php | 4 +--- .../Generator/Model/Diff/ColumnComparator.php | 4 +--- src/Propel/Generator/Model/Diff/ColumnDiff.php | 4 +--- .../Generator/Model/Diff/DatabaseComparator.php | 4 +--- .../Generator/Model/Diff/DatabaseDiff.php | 4 +--- .../Model/Diff/ForeignKeyComparator.php | 4 +--- .../Generator/Model/Diff/IndexComparator.php | 4 +--- .../Generator/Model/Diff/TableComparator.php | 4 +--- src/Propel/Generator/Model/Diff/TableDiff.php | 4 +--- src/Propel/Generator/Model/Domain.php | 4 +--- src/Propel/Generator/Model/ForeignKey.php | 4 +--- src/Propel/Generator/Model/IdMethod.php | 4 +--- .../Generator/Model/IdMethodParameter.php | 4 +--- src/Propel/Generator/Model/Index.php | 4 +--- src/Propel/Generator/Model/Inheritance.php | 4 +--- src/Propel/Generator/Model/MappingModel.php | 4 +--- .../Generator/Model/MappingModelInterface.php | 4 +--- src/Propel/Generator/Model/NameFactory.php | 4 +--- .../Generator/Model/NameGeneratorInterface.php | 4 +--- src/Propel/Generator/Model/PhpNameGenerator.php | 4 +--- src/Propel/Generator/Model/PropelTypes.php | 4 +--- src/Propel/Generator/Model/Schema.php | 4 +--- .../Generator/Model/ScopedMappingModel.php | 4 +--- src/Propel/Generator/Model/Table.php | 4 +--- src/Propel/Generator/Model/Unique.php | 4 +--- src/Propel/Generator/Model/VendorInfo.php | 4 +--- .../Generator/Platform/DefaultPlatform.php | 4 +--- src/Propel/Generator/Platform/MssqlPlatform.php | 4 +--- src/Propel/Generator/Platform/MysqlPlatform.php | 4 +--- .../Generator/Platform/OraclePlatform.php | 4 +--- src/Propel/Generator/Platform/PgsqlPlatform.php | 4 +--- .../Generator/Platform/PlatformInterface.php | 4 +--- .../Generator/Platform/SqlitePlatform.php | 4 +--- .../Generator/Platform/SqlsrvPlatform.php | 4 +--- .../Generator/Reverse/AbstractSchemaParser.php | 4 +--- .../Generator/Reverse/MssqlSchemaParser.php | 4 +--- .../Generator/Reverse/MysqlSchemaParser.php | 4 +--- .../Generator/Reverse/OracleSchemaParser.php | 4 +--- .../Generator/Reverse/PgsqlSchemaParser.php | 4 +--- .../Generator/Reverse/SchemaParserInterface.php | 4 +--- .../Generator/Reverse/SqliteSchemaParser.php | 4 +--- .../Generator/Reverse/SqlsrvSchemaParser.php | 4 +--- .../Generator/Schema/Dumper/DumperInterface.php | 4 +--- .../Generator/Schema/Dumper/XmlDumper.php | 4 +--- src/Propel/Generator/Util/BehaviorLocator.php | 4 +--- src/Propel/Generator/Util/PhpParser.php | 4 +--- src/Propel/Generator/Util/QuickBuilder.php | 4 +--- src/Propel/Generator/Util/SchemaValidator.php | 4 +--- src/Propel/Generator/Util/SqlParser.php | 4 +--- .../Runtime/ActiveQuery/BaseModelCriteria.php | 6 ++++++ src/Propel/Runtime/ActiveQuery/Criteria.php | 4 +--- .../ActiveQuery/Criterion/AbstractCriterion.php | 4 +--- .../Criterion/AbstractModelCriterion.php | 4 +--- .../ActiveQuery/Criterion/BasicCriterion.php | 4 +--- .../Criterion/BasicModelCriterion.php | 4 +--- .../ActiveQuery/Criterion/BinaryCriterion.php | 4 +--- .../Criterion/BinaryModelCriterion.php | 5 ++--- .../ActiveQuery/Criterion/CustomCriterion.php | 4 +--- .../Exception/InvalidClauseException.php | 4 +--- .../Exception/InvalidValueException.php | 4 +--- .../ActiveQuery/Criterion/InCriterion.php | 4 +--- .../ActiveQuery/Criterion/InModelCriterion.php | 4 +--- .../ActiveQuery/Criterion/LikeCriterion.php | 4 +--- .../Criterion/LikeModelCriterion.php | 4 +--- .../ActiveQuery/Criterion/RawCriterion.php | 4 +--- .../ActiveQuery/Criterion/RawModelCriterion.php | 4 +--- .../Criterion/SeveralModelCriterion.php | 4 +--- .../Exception/UnknownColumnException.php | 4 +--- .../Exception/UnknownModelException.php | 4 +--- .../Exception/UnknownRelationException.php | 4 +--- .../Runtime/ActiveQuery/InstancePoolTrait.php | 4 +--- src/Propel/Runtime/ActiveQuery/Join.php | 4 +--- .../Runtime/ActiveQuery/ModelCriteria.php | 4 +--- src/Propel/Runtime/ActiveQuery/ModelJoin.php | 4 +--- src/Propel/Runtime/ActiveQuery/ModelWith.php | 4 +--- src/Propel/Runtime/ActiveQuery/PropelQuery.php | 4 +--- .../ActiveRecord/ActiveRecordInterface.php | 4 +--- .../ActiveRecord/NestedSetRecursiveIterator.php | 4 +--- src/Propel/Runtime/Adapter/AdapterFactory.php | 4 +--- src/Propel/Runtime/Adapter/AdapterInterface.php | 4 +--- .../Adapter/Exception/AdapterException.php | 4 +--- .../Exception/ColumnNotFoundException.php | 4 +--- .../Exception/MalformedClauseException.php | 4 +--- .../Exception/UnsupportedEncodingException.php | 4 +--- .../Runtime/Adapter/MSSQL/MssqlDebugPDO.php | 4 +--- .../Runtime/Adapter/MSSQL/MssqlPropelPDO.php | 4 +--- src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php | 4 +--- src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php | 4 +--- .../Runtime/Adapter/Pdo/OracleAdapter.php | 4 +--- src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php | 4 +--- src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php | 4 +--- .../Runtime/Adapter/Pdo/SqliteAdapter.php | 4 +--- .../Runtime/Adapter/Pdo/SqlsrvAdapter.php | 4 +--- .../Runtime/Adapter/SqlAdapterInterface.php | 4 +--- .../Runtime/Collection/ArrayCollection.php | 4 +--- src/Propel/Runtime/Collection/Collection.php | 4 +--- .../Runtime/Collection/CollectionIterator.php | 4 +--- .../Exception/ModelNotFoundException.php | 4 +--- .../Exception/ReadOnlyModelException.php | 4 +--- .../Exception/UnsupportedRelationException.php | 4 +--- .../Runtime/Collection/ObjectCollection.php | 4 +--- .../Collection/ObjectCombinationCollection.php | 4 +--- .../Runtime/Collection/OnDemandCollection.php | 4 +--- .../Runtime/Collection/OnDemandIterator.php | 4 +--- .../Runtime/Connection/ConnectionFactory.php | 4 +--- .../Runtime/Connection/ConnectionInterface.php | 4 +--- .../Connection/ConnectionManagerInterface.php | 4 +--- .../Connection/ConnectionManagerMasterSlave.php | 4 +--- .../ConnectionManagerPrimaryReplica.php | 4 +--- .../Connection/ConnectionManagerSingle.php | 4 +--- .../Runtime/Connection/ConnectionWrapper.php | 4 +--- src/Propel/Runtime/Connection/DebugPDO.php | 4 +--- .../Exception/ConnectionException.php | 4 +--- .../Connection/Exception/RollbackException.php | 4 +--- src/Propel/Runtime/Connection/PdoConnection.php | 4 +--- .../Connection/ProfilerConnectionWrapper.php | 4 +--- .../Connection/ProfilerStatementWrapper.php | 4 +--- src/Propel/Runtime/Connection/PropelPDO.php | 4 +--- .../Runtime/Connection/StatementWrapper.php | 4 +--- .../Runtime/Connection/TransactionTrait.php | 4 +--- .../Runtime/DataFetcher/AbstractDataFetcher.php | 6 ++++++ .../Runtime/DataFetcher/ArrayDataFetcher.php | 6 ++++++ .../DataFetcher/DataFetcherInterface.php | 6 ++++++ .../Runtime/DataFetcher/PDODataFetcher.php | 6 ++++++ .../Exception/BadMethodCallException.php | 4 +--- .../Exception/ClassNotFoundException.php | 4 +--- .../Exception/EntityNotFoundException.php | 6 ++++++ .../Runtime/Exception/ExceptionInterface.php | 4 +--- .../Runtime/Exception/FileNotFoundException.php | 4 +--- .../Exception/InvalidArgumentException.php | 4 +--- src/Propel/Runtime/Exception/LogicException.php | 4 +--- .../Runtime/Exception/PropelException.php | 4 +--- .../Runtime/Exception/RuntimeException.php | 4 +--- .../Exception/UnexpectedValueException.php | 4 +--- .../Runtime/Formatter/AbstractFormatter.php | 4 +--- src/Propel/Runtime/Formatter/ArrayFormatter.php | 4 +--- .../Runtime/Formatter/ObjectFormatter.php | 4 +--- .../Runtime/Formatter/OnDemandFormatter.php | 4 +--- .../Runtime/Formatter/SimpleArrayFormatter.php | 4 +--- .../Runtime/Formatter/StatementFormatter.php | 4 +--- src/Propel/Runtime/Map/ColumnMap.php | 4 +--- src/Propel/Runtime/Map/DatabaseMap.php | 4 +--- .../Map/Exception/ColumnNotFoundException.php | 4 +--- .../Exception/ForeignKeyNotFoundException.php | 4 +--- .../Map/Exception/RelationNotFoundException.php | 4 +--- .../Map/Exception/TableNotFoundException.php | 4 +--- src/Propel/Runtime/Map/RelationMap.php | 4 +--- src/Propel/Runtime/Map/TableMap.php | 4 +--- src/Propel/Runtime/Map/TableMapTrait.php | 4 +--- src/Propel/Runtime/Parser/AbstractParser.php | 4 +--- src/Propel/Runtime/Parser/CsvParser.php | 4 +--- src/Propel/Runtime/Parser/JsonParser.php | 4 +--- src/Propel/Runtime/Parser/XmlParser.php | 4 +--- src/Propel/Runtime/Parser/YamlParser.php | 4 +--- src/Propel/Runtime/Propel.php | 4 +--- .../ServiceContainerInterface.php | 4 +--- .../StandardServiceContainer.php | 4 +--- src/Propel/Runtime/Util/Profiler.php | 4 +--- .../Runtime/Util/PropelConditionalProxy.php | 4 +--- src/Propel/Runtime/Util/PropelDateTime.php | 4 +--- src/Propel/Runtime/Util/PropelModelPager.php | 4 +--- .../Runtime/Validator/Constraints/Date.php | 5 ++--- .../Validator/Constraints/DateValidator.php | 5 ++--- .../Runtime/Validator/Constraints/Unique.php | 5 ++--- .../Validator/Constraints/UniqueValidator.php | 4 +--- 282 files changed, 351 insertions(+), 815 deletions(-) diff --git a/.gitattributes b/.gitattributes index ad4d8326b8..522faf62a9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -30,3 +30,6 @@ phpstan-baseline.neon export-ignore linguist-generated=true .editorconfig export-ignore .gitattributes export-ignore .gitignore export-ignore +.license export-ignore +phpunit.xml.dist export-ignore +pom.xml.dist export-ignore diff --git a/.license b/.license index 361217be36..ad11455f0b 100644 --- a/.license +++ b/.license @@ -1,7 +1,5 @@ /** - * This file is part of the Propel package. + * MIT License. This file is part of the Propel package. * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - * - * @license MIT License */ diff --git a/README.md b/README.md index bae5a275ab..9f92c05d9f 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,15 @@ Propel2 is an open-source Object-Relational Mapping (ORM) for PHP. Propel uses the following Symfony Components: -* [Console](https://github.com/symfony/Console) -* [Yaml](https://github.com/symfony/Yaml) -* [Finder](https://github.com/symfony/Finder) -* [Validator](https://github.com/symfony/Validator) -* [Filesystem](https://github.com/symfony/Filesystem) * [Config](https://github.com/symfony/config) - -Propel also relies on [**Composer**](https://github.com/composer/composer) to manage dependencies but you +* [Console](https://github.com/symfony/console) +* [Filesystem](https://github.com/symfony/filesystem) +* [Finder](https://github.com/symfony/finder) +* [Translation](https://github.com/symfony/translation) +* [Validator](https://github.com/symfony/validator) +* [Yaml](https://github.com/symfony/yaml) + +Propel primarily relies on [**Composer**](https://github.com/composer/composer) to manage dependencies, but you also can use [ClassLoader](https://github.com/symfony/ClassLoader) (see the `autoload.php.dist` file for instance). @@ -32,7 +33,7 @@ Read the [Propel documentation](http://propelorm.org/documentation/01-installati ## Contribute Everybody can contribute to Propel. Just fork it, and send Pull Requests. -You have to follow [Propel2 Coding Standards](https://github.com/propelorm/Propel2/wiki/Coding-Standards) and provides unit +You have to follow [Propel Coding Standards](https://github.com/propelorm/Propel2/wiki/Coding-Standards) and provides unit tests as much as possible. Also [check out the roadmap](https://github.com/propelorm/Propel2/wiki) to get an overview of what we are working on! Please see our [contribution guideline](http://propelorm.org/contribute.html). Thank you! diff --git a/config/phpcs.xml b/config/phpcs.xml index 68ad039902..771659aa31 100644 --- a/config/phpcs.xml +++ b/config/phpcs.xml @@ -11,9 +11,6 @@ */templates/* - - 0 - 0 diff --git a/src/Propel/Common/Config/ConfigurationManager.php b/src/Propel/Common/Config/ConfigurationManager.php index f020710d70..342a72b727 100644 --- a/src/Propel/Common/Config/ConfigurationManager.php +++ b/src/Propel/Common/Config/ConfigurationManager.php @@ -1,11 +1,9 @@ Date: Thu, 30 Jul 2020 12:24:46 +0200 Subject: [PATCH 132/208] Run CS sniffer over tests. --- .../Tests/Bookstore/AuthorCollection.php | 1 - tests/Propel/Tests/BookstoreLoggingTest.php | 13 +- tests/Propel/Tests/BookstoreTest.php | 184 +++-- tests/Propel/Tests/CharacterEncodingTest.php | 63 +- .../Tests/Common/Config/ConfigTestCase.php | 9 +- .../Config/ConfigurationManagerTest.php | 138 +++- .../Tests/Common/Config/DataProviderTrait.php | 67 +- .../Common/Config/Loader/FileLoaderTest.php | 112 ++- .../Config/Loader/IniFileLoaderTest.php | 45 +- .../Config/Loader/JsonFileLoaderTest.php | 26 +- .../Config/Loader/PhpFileLoaderTest.php | 31 +- .../Config/Loader/XmlFileLoaderTest.php | 24 +- .../Config/Loader/YamlFileLoaderTest.php | 28 +- .../Common/Config/XmlToArrayConverterTest.php | 19 + .../Pluralizer/EnglishPluralizerTest.php | 11 +- .../Common/Util/SetColumnConverterTest.php | 48 +- tests/Propel/Tests/FieldnameRelatedTest.php | 135 ++-- .../AddClass/AddClassBehaviorTest.php | 3 + .../AggregateColumnBehaviorTest.php | 63 +- .../AggregateColumnBehaviorWithSchemaTest.php | 11 +- .../AggregateColumnsBehaviorTestClasses.php | 17 +- ...vableBehaviorObjectBuilderModifierTest.php | 208 +++-- ...ivableBehaviorQueryBuilderModifierTest.php | 196 +++-- .../Archivable/ArchivableBehaviorTest.php | 88 +- .../Behavior/Archivable/FooArchive.php | 9 + .../AutoAddPk/AutoAddPkBehaviorTest.php | 20 +- .../Behavior/BehaviorLocatorTest.php | 13 +- .../ConcreteInheritanceBehaviorTest.php | 140 +++- ...tanceBehaviorWithBehaviorExclusionTest.php | 8 +- ...creteInheritanceBehaviorWithSchemaTest.php | 9 +- .../ConcreteInheritanceParentBehaviorTest.php | 10 +- .../Delegate/DelegateBehaviorTest.php | 78 +- .../I18nBehaviorQueryBuilderModifierTest.php | 132 ++- .../Behavior/I18n/I18nBehaviorTest.php | 37 +- .../NestedSet/Fixtures/PublicTable10.php | 9 +- .../NestedSet/Fixtures/PublicTable9.php | 21 +- ...edSetBehaviorObjectBuilderModifierTest.php | 426 +++++++--- ...viorObjectBuilderModifierWithScopeTest.php | 171 ++-- ...tedSetBehaviorQueryBuilderModifierTest.php | 246 +++--- ...aviorQueryBuilderModifierWithScopeTest.php | 164 ++-- .../NestedSet/NestedSetBehaviorTest.php | 14 +- .../Generator/Behavior/NestedSet/TestCase.php | 51 +- .../Generator/Behavior/ObjectBehaviorTest.php | 47 +- .../Generator/Behavior/QueryBehaviorTest.php | 18 +- .../Behavior/QueryCache/QueryCacheTest.php | 42 +- .../Sluggable/SluggableBehaviorTest.php | 74 +- ...tableBehaviorObjectBuilderModifierTest.php | 66 +- ...viorObjectBuilderModifierWithScopeTest.php | 142 +++- ...rtableBehaviorQueryBuilderModifierTest.php | 28 +- ...aviorQueryBuilderModifierWithScopeTest.php | 31 +- ...eBehaviorQueryUtilsBuilderModifierTest.php | 24 +- ...QueryUtilsBuilderModifierWithScopeTest.php | 33 +- .../Sortable/SortableBehaviorTest.php | 3 + .../SortableBehaviorWithEnumScopeTest.php | 8 +- .../SortableBehaviorWithSetScopeTest.php | 6 + .../Generator/Behavior/Sortable/TestCase.php | 23 +- .../Generator/Behavior/TableBehaviorTest.php | 6 + .../TimestampableBehaviorTest.php | 78 +- ...eInheritanceHandleValidateBehaviorTest.php | 54 +- .../Validate/UniqueConstraintTest.php | 20 +- .../Validate/ValidateBehaviorTest.php | 156 ++-- ...onableBehaviorQueryBuilderModifierTest.php | 17 +- .../Versionable/VersionableBehaviorTest.php | 49 +- .../Tests/Generator/Builder/NamespaceTest.php | 165 ++-- .../Om/AbstractOMBuilderNamespaceTest.php | 54 +- .../Om/AbstractOMBuilderRelatedByTest.php | 26 +- .../Builder/Om/AbstractOMBuilderTest.php | 35 +- ...ComplexColumnTypeEntityWithConstructor.php | 4 +- .../Om/GeneratedObjectArrayColumnTypeTest.php | 64 +- .../GeneratedObjectBooleanColumnTypeTest.php | 16 +- .../Om/GeneratedObjectEnumColumnTypeTest.php | 62 +- .../Om/GeneratedObjectJsonColumnTypeTest.php | 104 ++- .../Om/GeneratedObjectLazyLoadTest.php | 41 +- .../Builder/Om/GeneratedObjectLobTest.php | 91 ++- .../GeneratedObjectM2MRelationSimpleTest.php | 523 ++++++------ ...eneratedObjectM2MRelationThreePKs2Test.php | 369 +++++---- .../Om/GeneratedObjectMoreRelationTest.php | 121 +-- .../GeneratedObjectObjectColumnTypeTest.php | 38 +- .../Builder/Om/GeneratedObjectRelTest.php | 192 +++-- .../Om/GeneratedObjectSetColumnTypeTest.php | 69 +- .../GeneratedObjectTemporalColumnTypeTest.php | 111 ++- .../Builder/Om/GeneratedObjectTest.php | 555 ++++++++----- ...eratedObjectWithDateImmutableClassTest.php | 19 +- .../Om/GeneratedObjectWithFixturesTest.php | 120 +-- .../Om/GeneratedObjectWithInterfaceTest.php | 30 +- .../Om/GeneratedPKLessQueryBuilderTest.php | 54 +- .../Om/GeneratedPKLessTableMapTest.php | 9 +- .../Om/GeneratedQueryArrayColumnTypeTest.php | 96 ++- .../Builder/Om/GeneratedQueryDoDeleteTest.php | 191 +++-- .../Builder/Om/GeneratedQueryDoSelectTest.php | 156 ++-- .../Om/GeneratedQueryEnumColumnTypeTest.php | 41 +- .../Om/GeneratedQueryObjectColumnTypeTest.php | 43 +- .../Om/GeneratedQuerySetColumnTypeTest.php | 106 ++- .../GeneratedTableMapEnumColumnTypeTest.php | 20 +- .../Om/GeneratedTableMapLazyLoadTest.php | 50 +- .../Om/GeneratedTableMapSetColumnTypeTest.php | 19 +- .../Builder/Om/GeneratedTableMapTest.php | 39 +- .../Builder/Om/ObjectBuilderTest.php | 17 +- .../Builder/Om/PoisonedCacheBugTest.php | 35 +- .../Om/QueryBuilderInheritanceTest.php | 79 +- .../Generator/Builder/Om/QueryBuilderTest.php | 223 +++++- .../Builder/Om/QueryBuilderTestClasses.php | 7 +- .../Builder/Om/TableMapBuilderTest.php | 61 +- .../Builder/Util/PropelTemplateTest.php | 15 +- .../Util/SchemaReaderJoinSchemaTest.php | 5 +- .../Builder/Util/SchemaReaderTest.php | 28 +- .../Generator/Command/AbstractCommandTest.php | 20 +- .../Generator/Command/DatabaseReverseTest.php | 23 +- .../Command/GraphvizGenerateTest.php | 20 +- .../Generator/Command/InitCommandTest.php | 32 +- .../Tests/Generator/Command/MigrationTest.php | 80 +- .../Config/ArrayToPhpConverterTest.php | 57 +- .../Generator/Config/GeneratorConfigTest.php | 102 ++- .../Config/QuickGeneratorConfigTest.php | 46 +- .../Manager/MigrationManagerTest.php | 35 +- .../Tests/Generator/Migration/BaseTest.php | 28 +- .../Generator/Migration/ForeignKeyTest.php | 14 +- .../Tests/Generator/Migration/IndexTest.php | 19 +- .../Generator/Migration/MigrationTestCase.php | 60 +- .../Generator/Migration/PrimaryKeyAITest.php | 16 +- .../Generator/Migration/PrimaryKeyTest.php | 17 +- .../Tests/Generator/Model/BehaviorTest.php | 33 + .../Model/ColumnDefaultValueTest.php | 5 +- .../Tests/Generator/Model/ColumnTest.php | 381 +++++---- .../Generator/Model/ConstantNameTest.php | 22 +- .../Tests/Generator/Model/DatabaseTest.php | 140 +++- .../Model/Diff/ColumnComparatorTest.php | 66 +- .../Diff/DatabaseTableComparatorTest.php | 54 +- .../Model/Diff/ForeignKeyComparatorTest.php | 29 +- .../Model/Diff/IndexComparatorTest.php | 21 +- .../Diff/PropelTableColumnComparatorTest.php | 38 +- .../PropelTableForeignKeyComparatorTest.php | 30 +- .../Diff/PropelTableIndexComparatorTest.php | 29 +- .../PropelTablePkColumnComparatorTest.php | 30 +- .../Generator/Model/Diff/TableDiffTest.php | 122 ++- .../Tests/Generator/Model/DomainTest.php | 44 +- .../Tests/Generator/Model/ForeignKeyTest.php | 129 ++- .../Tests/Generator/Model/IndexTest.php | 29 +- .../Tests/Generator/Model/InheritanceTest.php | 9 +- .../Generator/Model/MappingModelTest.php | 8 + .../Tests/Generator/Model/ModelTestCase.php | 209 ++--- .../Tests/Generator/Model/NameFactoryTest.php | 66 +- .../Generator/Model/PhpNameGeneratorTest.php | 7 +- .../Tests/Generator/Model/SchemaTest.php | 63 +- .../Tests/Generator/Model/TableTest.php | 281 +++++-- .../Tests/Generator/Model/UniqueTest.php | 8 +- .../Tests/Generator/Model/VendorInfoTest.php | 15 + .../Platform/DefaultPlatformTest.php | 44 +- .../Generator/Platform/MssqlPlatformTest.php | 70 +- .../MysqlPlatformMigrationMyISAMTest.php | 42 +- .../Platform/MysqlPlatformMigrationTest.php | 44 +- .../MysqlPlatformMigrationTestProvider.php | 7 +- .../Platform/MysqlPlatformMyISAMTest.php | 120 ++- .../Generator/Platform/MysqlPlatformTest.php | 135 +++- .../Platform/OraclePlatformMigrationTest.php | 38 +- .../Generator/Platform/OraclePlatformTest.php | 73 +- .../Platform/PgsqlPlatformMigrationTest.php | 54 +- .../Generator/Platform/PgsqlPlatformTest.php | 95 ++- .../PlatformMigrationTestProvider.php | 12 +- .../Generator/Platform/PlatformTestBase.php | 2 - .../Platform/PlatformTestProvider.php | 18 +- .../Generator/Platform/SqlitePlatformTest.php | 69 +- .../Reverse/MssqlSchemaParserTest.php | 34 +- .../Reverse/MysqlSchemaParserTest.php | 5 +- .../Reverse/PgsqlSchemaParserTest.php | 19 +- .../Generator/Schema/Dumper/XmlDumperTest.php | 23 +- .../Tests/Generator/Util/PhpParserTest.php | 29 +- .../Tests/Generator/Util/QuickBuilderTest.php | 37 +- .../Generator/Util/SchemaValidatorTest.php | 39 +- .../Tests/Generator/Util/SqlParserTest.php | 24 +- tests/Propel/Tests/Helpers/BaseTestCase.php | 5 +- .../Behavior/AddClassBehaviorBuilder.php | 14 +- .../Helpers/Bookstore/Behavior/TestAuthor.php | 37 +- .../Behavior/TestAuthorDeleteFalse.php | 2 +- .../Behavior/TestAuthorSaveFalse.php | 2 +- .../Behavior/Testallhooksbehavior.php | 20 +- .../Bookstore/BookstoreDataPopulator.php | 95 +-- .../Bookstore/BookstoreEmptyTestBase.php | 3 +- .../Helpers/Bookstore/BookstoreTestBase.php | 11 +- .../Helpers/Namespaces/NamespacesTestBase.php | 6 + .../Helpers/PlatformDatabaseBuildTimeBase.php | 28 +- tests/Propel/Tests/Issues/Issue1033Book.php | 5 +- tests/Propel/Tests/Issues/Issue1033Test.php | 15 +- tests/Propel/Tests/Issues/Issue1133Test.php | 20 +- tests/Propel/Tests/Issues/Issue1192Test.php | 15 +- tests/Propel/Tests/Issues/Issue1463Test.php | 291 +++---- tests/Propel/Tests/Issues/Issue617Test.php | 23 +- tests/Propel/Tests/Issues/Issue646Test.php | 61 +- tests/Propel/Tests/Issues/Issue656Test.php | 14 +- tests/Propel/Tests/Issues/Issue675Test.php | 7 +- tests/Propel/Tests/Issues/Issue730Test.php | 17 +- tests/Propel/Tests/Issues/Issue733Test.php | 21 +- tests/Propel/Tests/Issues/Issue768Test.php | 86 +- tests/Propel/Tests/Issues/Issue829Test.php | 19 +- tests/Propel/Tests/Issues/Issue915Book.php | 8 +- tests/Propel/Tests/Issues/Issue915Test.php | 10 +- tests/Propel/Tests/Issues/Issue989Test.php | 22 +- tests/Propel/Tests/Resources/blog-schema.php | 1 - .../ActiveQuery/CriteriaCombineTest.php | 221 +++--- .../CriteriaFluidConditionTest.php | 23 +- .../ActiveQuery/CriteriaFluidOperatorTest.php | 24 +- .../Runtime/ActiveQuery/CriteriaMergeTest.php | 52 +- .../Runtime/ActiveQuery/CriteriaTest.php | 750 +++++++++++------- .../Criterion/BasicCriterionTest.php | 33 +- .../Criterion/BasicModelCriterionTest.php | 14 +- .../Criterion/CustomCriterionTest.php | 6 +- .../ActiveQuery/Criterion/InCriterionTest.php | 58 +- .../Criterion/InModelCriterionTest.php | 53 +- .../Criterion/LikeCriterionTest.php | 39 +- .../Criterion/LikeModelCriterionTest.php | 25 +- .../Criterion/RawCriterionTest.php | 19 +- .../Criterion/RawModelCriterionTest.php | 19 +- .../Criterion/SeveralModelCriterionTest.php | 13 +- .../Tests/Runtime/ActiveQuery/JoinTest.php | 68 +- .../ModelCriteriaGroupByArrayTest.php | 52 +- .../ActiveQuery/ModelCriteriaHooksTest.php | 41 +- .../ActiveQuery/ModelCriteriaSelectTest.php | 84 +- .../Runtime/ActiveQuery/ModelCriteriaTest.php | 623 +++++++++++++-- .../ModelCriteriaWithNamespaceTest.php | 12 +- .../ModelCriteriaWithSchemaTest.php | 18 +- .../Runtime/ActiveQuery/ModelJoinTest.php | 28 +- .../Runtime/ActiveQuery/ModelWithTest.php | 36 +- .../Runtime/ActiveQuery/PropelQueryTest.php | 44 +- .../ActiveQuery/PropelQueryTestClasses.php | 2 +- .../Tests/Runtime/ActiveQuery/QuotingTest.php | 114 +-- .../Runtime/ActiveQuery/SubQueryTest.php | 94 ++- .../ActiveQuery/TestableModelCriteria.php | 1 - .../Tests/Runtime/ActiveRecordConvertTest.php | 20 +- .../Runtime/ActiveRecordSerializeTest.php | 20 +- .../Propel/Tests/Runtime/ActiveRecordTest.php | 20 +- .../Runtime/Adapter/AbstractAdapterTest.php | 31 +- .../Runtime/Adapter/Pdo/MssqlAdapterTest.php | 28 +- .../Runtime/Adapter/Pdo/MysqlAdapterTest.php | 19 +- .../Runtime/Adapter/Pdo/OracleAdapterTest.php | 20 +- .../Runtime/Adapter/Pdo/PgsqlAdapter.php | 17 +- .../Collection/ArrayCollectionTest.php | 50 +- .../Collection/CollectionConvertTest.php | 39 +- .../Collection/CollectionIteratorTest.php | 38 +- .../Runtime/Collection/CollectionTest.php | 82 +- .../Collection/ObjectCollectionTest.php | 98 ++- .../ObjectCollectionWithFixturesTest.php | 63 +- .../Collection/OnDemandCollectionTest.php | 36 +- .../Collection/OnDemandIteratorTest.php | 17 +- .../Connection/ConnectionFactoryTest.php | 42 +- .../ConnectionManagerMasterSlaveTest.php | 55 +- .../ConnectionManagerPrimaryReplicaTest.php | 55 +- .../ConnectionManagerSingleTest.php | 28 +- .../Connection/TransactionTraitTest.php | 55 +- .../Runtime/Exception/PropelExceptionTest.php | 19 +- .../Runtime/Formatter/ArrayFormatterTest.php | 39 +- .../Formatter/ArrayFormatterWithTest.php | 77 +- .../Runtime/Formatter/DataFetcherTest.php | 30 +- .../ObjectFormatterInheritanceTest.php | 23 +- .../Runtime/Formatter/ObjectFormatterTest.php | 53 +- .../Formatter/ObjectFormatterWithTest.php | 109 ++- .../Formatter/OnDemandFormatterTest.php | 50 +- .../Formatter/OnDemandFormatterWithTest.php | 50 +- .../Formatter/SimpleArrayFormatterTest.php | 29 +- .../Formatter/StatementFormatterTest.php | 43 +- .../Tests/Runtime/Map/ColumnMapTest.php | 47 +- .../Tests/Runtime/Map/DatabaseMapTest.php | 44 +- .../Runtime/Map/GeneratedRelationMapTest.php | 18 +- .../GeneratedRelationMapWithSchemasTest.php | 24 +- .../Runtime/Map/RelatedMapSymmetricalTest.php | 16 +- .../RelatedMapSymmetricalWithSchemasTest.php | 17 +- .../Tests/Runtime/Map/RelationMapTest.php | 134 ++-- .../Propel/Tests/Runtime/Map/TableMapTest.php | 74 +- .../Runtime/Parser/AbstractParserTest.php | 14 +- .../Tests/Runtime/Parser/CsvParserTest.php | 12 + .../Tests/Runtime/Parser/JsonParserTest.php | 12 + .../Tests/Runtime/Parser/XmlParserTest.php | 20 +- .../Tests/Runtime/Parser/YamlParserTest.php | 28 +- tests/Propel/Tests/Runtime/PropelTest.php | 12 +- .../StandardServiceContainerTest.php | 209 ++++- tests/Propel/Tests/Runtime/TypeTest.php | 39 +- .../Runtime/TypeTests/DummyObjectClass.php | 13 +- .../Runtime/TypeTests/TypeObjectInterface.php | 6 +- .../Tests/Runtime/Util/ProfilerTest.php | 42 +- .../Util/PropelConditionalProxyTest.php | 100 +-- .../Tests/Runtime/Util/PropelDateTimeTest.php | 83 +- .../Runtime/Util/PropelModelPagerTest.php | 65 +- .../Runtime/Util/TableMapExceptionsTest.php | 23 +- .../Tests/Runtime/Util/TableMapTest.php | 104 ++- tests/Propel/Tests/TestCase.php | 17 +- tests/Propel/Tests/TestCaseFixtures.php | 47 +- .../Propel/Tests/TestCaseFixturesDatabase.php | 6 - tests/Propel/Tests/Ticket520Test.php | 101 ++- 287 files changed, 12664 insertions(+), 5038 deletions(-) diff --git a/tests/Propel/Tests/Bookstore/AuthorCollection.php b/tests/Propel/Tests/Bookstore/AuthorCollection.php index f90e6525c2..6d12f5a8e4 100644 --- a/tests/Propel/Tests/Bookstore/AuthorCollection.php +++ b/tests/Propel/Tests/Bookstore/AuthorCollection.php @@ -6,5 +6,4 @@ class AuthorCollection extends ObjectCollection { - } diff --git a/tests/Propel/Tests/BookstoreLoggingTest.php b/tests/Propel/Tests/BookstoreLoggingTest.php index 5494afea3a..a76972b665 100644 --- a/tests/Propel/Tests/BookstoreLoggingTest.php +++ b/tests/Propel/Tests/BookstoreLoggingTest.php @@ -11,7 +11,6 @@ namespace Propel\Tests; use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\AuthorQuery; use Propel\Tests\Bookstore\Book; @@ -32,6 +31,9 @@ */ class BookstoreLoggingTest extends BookstoreEmptyTestBase { + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -40,6 +42,9 @@ public function setUp(): void AuthorQuery::create()->deleteAll(); } + /** + * @return void + */ public function testSetterAndGetter() { $book = new Book(); @@ -69,6 +74,9 @@ public function testSetterAndGetter() $log->save(); } + /** + * @return void + */ public function testQueryFilter() { $book = new Book(); @@ -132,9 +140,10 @@ public function testQueryFilter() } /** - * * @group mysql * @group pgsql + * + * @return void */ public function testQueryJoins() { diff --git a/tests/Propel/Tests/BookstoreTest.php b/tests/Propel/Tests/BookstoreTest.php index eef2d7a450..834e318f51 100644 --- a/tests/Propel/Tests/BookstoreTest.php +++ b/tests/Propel/Tests/BookstoreTest.php @@ -10,31 +10,30 @@ namespace Propel\Tests; +use DateTime; +use Exception; use Propel\Runtime\ActiveQuery\Criteria; - use Propel\Runtime\Collection\Collection; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\AuthorQuery; use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\BookQuery; use Propel\Tests\Bookstore\BookClubList; -use Propel\Tests\Bookstore\BookListRelQuery; use Propel\Tests\Bookstore\BookClubListQuery; use Propel\Tests\Bookstore\BookListRel; -use Propel\Tests\Bookstore\Publisher; -use Propel\Tests\Bookstore\PublisherQuery; +use Propel\Tests\Bookstore\BookListRelQuery; +use Propel\Tests\Bookstore\BookQuery; use Propel\Tests\Bookstore\Map\AuthorTableMap; -use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\BookClubListTableMap; +use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\PublisherTableMap; use Propel\Tests\Bookstore\Media; use Propel\Tests\Bookstore\MediaQuery; +use Propel\Tests\Bookstore\Publisher; +use Propel\Tests\Bookstore\PublisherQuery; use Propel\Tests\Bookstore\Review; use Propel\Tests\Bookstore\ReviewQuery; use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; -use \DateTime; - /** * Tests a functional scenario using the Bookstore model * @@ -45,27 +44,30 @@ */ class BookstoreTest extends BookstoreEmptyTestBase { + /** + * @return void + */ public function testScenario() { // Add publisher records // --------------------- $scholastic = new Publisher(); - $scholastic->setName("Scholastic"); + $scholastic->setName('Scholastic'); // do not save, will do later to test cascade $morrow = new Publisher(); - $morrow->setName("William Morrow"); + $morrow->setName('William Morrow'); $morrow->save(); $morrow_id = $morrow->getId(); $penguin = new Publisher(); - $penguin->setName("Penguin"); + $penguin->setName('Penguin'); $penguin->save(); $penguin_id = $penguin->getId(); $vintage = new Publisher(); - $vintage->setName("Vintage"); + $vintage->setName('Vintage'); $vintage->save(); $vintage_id = $vintage->getId(); $this->assertTrue(true, 'Save Publisher records'); @@ -74,25 +76,25 @@ public function testScenario() // ------------------ $rowling = new Author(); - $rowling->setFirstName("J.K."); - $rowling->setLastName("Rowling"); + $rowling->setFirstName('J.K.'); + $rowling->setLastName('Rowling'); // do not save, will do later to test cascade $stephenson = new Author(); - $stephenson->setFirstName("Neal"); - $stephenson->setLastName("Stephenson"); + $stephenson->setFirstName('Neal'); + $stephenson->setLastName('Stephenson'); $stephenson->save(); $stephenson_id = $stephenson->getId(); $byron = new Author(); - $byron->setFirstName("George"); - $byron->setLastName("Byron"); + $byron->setFirstName('George'); + $byron->setLastName('Byron'); $byron->save(); $byron_id = $byron->getId(); $grass = new Author(); - $grass->setFirstName("Gunter"); - $grass->setLastName("Grass"); + $grass->setFirstName('Gunter'); + $grass->setLastName('Grass'); $grass->save(); $grass_id = $grass->getId(); $this->assertTrue(true, 'Save Author records'); @@ -101,8 +103,8 @@ public function testScenario() // ---------------- $phoenix = new Book(); - $phoenix->setTitle("Harry Potter and the Order of the Phoenix"); - $phoenix->setISBN("043935806X"); + $phoenix->setTitle('Harry Potter and the Order of the Phoenix'); + $phoenix->setISBN('043935806X'); $phoenix->setAuthor($rowling); $phoenix->setPublisher($scholastic); $phoenix->save(); @@ -111,24 +113,24 @@ public function testScenario() $this->assertFalse($scholastic->isNew(), 'saving book also saves related publisher'); $qs = new Book(); - $qs->setISBN("0380977427"); - $qs->setTitle("Quicksilver"); + $qs->setISBN('0380977427'); + $qs->setTitle('Quicksilver'); $qs->setAuthor($stephenson); $qs->setPublisher($morrow); $qs->save(); $qs_id = $qs->getId(); $dj = new Book(); - $dj->setISBN("0140422161"); - $dj->setTitle("Don Juan"); + $dj->setISBN('0140422161'); + $dj->setTitle('Don Juan'); $dj->setAuthor($byron); $dj->setPublisher($penguin); $dj->save(); $dj_id = $qs->getId(); $td = new Book(); - $td->setISBN("067972575X"); - $td->setTitle("The Tin Drum"); + $td->setISBN('067972575X'); + $td->setTitle('The Tin Drum'); $td->setAuthor($grass); $td->setPublisher($vintage); $td->save(); @@ -140,7 +142,7 @@ public function testScenario() $r1 = new Review(); $r1->setBook($phoenix); - $r1->setReviewedBy("Washington Post"); + $r1->setReviewedBy('Washington Post'); $r1->setRecommended(true); $r1->setReviewDate(time()); $r1->save(); @@ -148,7 +150,7 @@ public function testScenario() $r2 = new Review(); $r2->setBook($phoenix); - $r2->setReviewedBy("New York Times"); + $r2->setReviewedBy('New York Times'); $r2->setRecommended(false); $r2->setReviewDate(time()); $r2->save(); @@ -161,7 +163,7 @@ public function testScenario() $results = BookQuery::create()->filterByTitle('Harry%', Criteria::LIKE)->find(); $this->assertEquals(1, count($results)); - $results = BookQuery::create()->filterByISBN(["0380977427", "0140422161"], Criteria::IN)->find(); + $results = BookQuery::create()->filterByISBN(['0380977427', '0140422161'], Criteria::IN)->find(); $this->assertEquals(2, count($results)); // Perform a "limit" search @@ -171,8 +173,8 @@ public function testScenario() $this->assertEquals(2, count($results)); // we ordered on book title, so we expect to get - $this->assertEquals("Harry Potter and the Order of the Phoenix", $results[0]->getTitle()); - $this->assertEquals("Quicksilver", $results[1]->getTitle()); + $this->assertEquals('Harry Potter and the Order of the Phoenix', $results[0]->getTitle()); + $this->assertEquals('Quicksilver', $results[1]->getTitle()); // Perform a lookup & update! // -------------------------- @@ -182,7 +184,7 @@ public function testScenario() $qs_lookup = BookQuery::create()->findPk($qs_id); $this->assertNotNull($qs_lookup, 'just-created book can be found by pk'); - $new_title = "Quicksilver (".crc32(uniqid(rand())).")"; + $new_title = 'Quicksilver (' . crc32(uniqid(rand())) . ')'; // Attempting to update found object $qs_lookup->setTitle($new_title); $qs_lookup->save(); @@ -212,9 +214,9 @@ public function testScenario() // Handle BLOB/CLOB Columns // ------------------------ - $blob_path = __DIR__ . '/../../Fixtures/etc/lob/tin_drum.gif'; + $blob_path = __DIR__ . '/../../Fixtures/etc/lob/tin_drum.gif'; $blob2_path = __DIR__ . '/../../Fixtures/etc/lob/propel.gif'; - $clob_path = __DIR__ . '/../../Fixtures/etc/lob/tin_drum.txt'; + $clob_path = __DIR__ . '/../../Fixtures/etc/lob/tin_drum.txt'; $m1 = new Media(); $m1->setBook($phoenix); @@ -227,7 +229,7 @@ public function testScenario() $this->assertNotNull($m1_lookup, 'Can find just-created media item'); $this->assertEquals(md5(file_get_contents($blob_path)), md5(stream_get_contents($m1_lookup->getCoverImage())), 'BLOB was correctly updated'); - $this->assertEquals(file_get_contents($clob_path), (string) $m1_lookup->getExcerpt(), 'CLOB was correctly updated'); + $this->assertEquals(file_get_contents($clob_path), (string)$m1_lookup->getExcerpt(), 'CLOB was correctly updated'); // now update the BLOB column and save it & check the results $m1_lookup->setCoverImage(file_get_contents($blob2_path)); @@ -252,8 +254,8 @@ public function testScenario() // init book club list 1 with 2 books $blc1 = new BookClubList(); - $blc1->setGroupLeader("Crazyleggs"); - $blc1->setTheme("Happiness"); + $blc1->setGroupLeader('Crazyleggs'); + $blc1->setTheme('Happiness'); $brel1 = new BookListRel(); $brel1->setBook($phoenix); @@ -271,8 +273,8 @@ public function testScenario() // init book club list 2 with 1 book $blc2 = new BookClubList(); - $blc2->setGroupLeader("John Foo"); - $blc2->setTheme("Default"); + $blc2->setGroupLeader('John Foo'); + $blc2->setTheme('Default'); $brel3 = new BookListRel(); $brel3->setBook($phoenix); @@ -335,9 +337,9 @@ public function testScenario() // Attempting to delete books by complex criteria $c = new Criteria(); - $cn = $c->getNewCriterion(BookTableMap::COL_ISBN, "043935806X"); - $cn->addOr($c->getNewCriterion(BookTableMap::COL_ISBN, "0380977427")); - $cn->addOr($c->getNewCriterion(BookTableMap::COL_ISBN, "0140422161")); + $cn = $c->getNewCriterion(BookTableMap::COL_ISBN, '043935806X'); + $cn->addOr($c->getNewCriterion(BookTableMap::COL_ISBN, '0380977427')); + $cn->addOr($c->getNewCriterion(BookTableMap::COL_ISBN, '0140422161')); $c->add($cn); BookTableMap::doDelete($c); @@ -370,6 +372,9 @@ public function testScenario() $this->assertCount(0, BookListRelQuery::create()->find(), 'no records in [book_x_list] table'); } + /** + * @return void + */ public function testScenarioUsingQuery() { // Add publisher records @@ -377,25 +382,25 @@ public function testScenarioUsingQuery() try { $scholastic = new Publisher(); - $scholastic->setName("Scholastic"); + $scholastic->setName('Scholastic'); // do not save, will do later to test cascade $morrow = new Publisher(); - $morrow->setName("William Morrow"); + $morrow->setName('William Morrow'); $morrow->save(); $morrow_id = $morrow->getId(); $penguin = new Publisher(); - $penguin->setName("Penguin"); + $penguin->setName('Penguin'); $penguin->save(); $penguin_id = $penguin->getId(); $vintage = new Publisher(); - $vintage->setName("Vintage"); + $vintage->setName('Vintage'); $vintage->save(); $vintage_id = $vintage->getId(); $this->assertTrue(true, 'Save Publisher records'); - } catch (\Exception $e) { + } catch (Exception $e) { $this->fail('Save publisher records'); } @@ -404,29 +409,29 @@ public function testScenarioUsingQuery() try { $rowling = new Author(); - $rowling->setFirstName("J.K."); - $rowling->setLastName("Rowling"); + $rowling->setFirstName('J.K.'); + $rowling->setLastName('Rowling'); // do not save, will do later to test cascade $stephenson = new Author(); - $stephenson->setFirstName("Neal"); - $stephenson->setLastName("Stephenson"); + $stephenson->setFirstName('Neal'); + $stephenson->setLastName('Stephenson'); $stephenson->save(); $stephenson_id = $stephenson->getId(); $byron = new Author(); - $byron->setFirstName("George"); - $byron->setLastName("Byron"); + $byron->setFirstName('George'); + $byron->setLastName('Byron'); $byron->save(); $byron_id = $byron->getId(); $grass = new Author(); - $grass->setFirstName("Gunter"); - $grass->setLastName("Grass"); + $grass->setFirstName('Gunter'); + $grass->setLastName('Grass'); $grass->save(); $grass_id = $grass->getId(); $this->assertTrue(true, 'Save Author records'); - } catch (\Exception $e) { + } catch (Exception $e) { $this->fail('Save Author records'); } @@ -435,8 +440,8 @@ public function testScenarioUsingQuery() try { $phoenix = new Book(); - $phoenix->setTitle("Harry Potter and the Order of the Phoenix"); - $phoenix->setISBN("043935806X"); + $phoenix->setTitle('Harry Potter and the Order of the Phoenix'); + $phoenix->setISBN('043935806X'); $phoenix->setAuthor($rowling); $phoenix->setPublisher($scholastic); $phoenix->save(); @@ -445,30 +450,30 @@ public function testScenarioUsingQuery() $this->assertFalse($scholastic->isNew(), 'saving book also saves related publisher'); $qs = new Book(); - $qs->setISBN("0380977427"); - $qs->setTitle("Quicksilver"); + $qs->setISBN('0380977427'); + $qs->setTitle('Quicksilver'); $qs->setAuthor($stephenson); $qs->setPublisher($morrow); $qs->save(); $qs_id = $qs->getId(); $dj = new Book(); - $dj->setISBN("0140422161"); - $dj->setTitle("Don Juan"); + $dj->setISBN('0140422161'); + $dj->setTitle('Don Juan'); $dj->setAuthor($byron); $dj->setPublisher($penguin); $dj->save(); $dj_id = $qs->getId(); $td = new Book(); - $td->setISBN("067972575X"); - $td->setTitle("The Tin Drum"); + $td->setISBN('067972575X'); + $td->setTitle('The Tin Drum'); $td->setAuthor($grass); $td->setPublisher($vintage); $td->save(); $td_id = $td->getId(); $this->assertTrue(true, 'Save Book records'); - } catch (\Exception $e) { + } catch (Exception $e) { $this->fail('Save Author records'); } @@ -478,7 +483,7 @@ public function testScenarioUsingQuery() try { $r1 = new Review(); $r1->setBook($phoenix); - $r1->setReviewedBy("Washington Post"); + $r1->setReviewedBy('Washington Post'); $r1->setRecommended(true); $r1->setReviewDate(time()); $r1->save(); @@ -486,13 +491,13 @@ public function testScenarioUsingQuery() $r2 = new Review(); $r2->setBook($phoenix); - $r2->setReviewedBy("New York Times"); + $r2->setReviewedBy('New York Times'); $r2->setRecommended(false); $r2->setReviewDate(time()); $r2->save(); $r2_id = $r2->getId(); $this->assertTrue(true, 'Save Review records'); - } catch (\Exception $e) { + } catch (Exception $e) { $this->fail('Save Review records'); } @@ -505,7 +510,7 @@ public function testScenarioUsingQuery() $this->assertEquals(1, count($results)); $results = BookQuery::create() - ->where('Book.ISBN IN ?', ["0380977427", "0140422161"]) + ->where('Book.ISBN IN ?', ['0380977427', '0140422161']) ->find(); $this->assertEquals(2, count($results)); @@ -519,8 +524,8 @@ public function testScenarioUsingQuery() ->find(); $this->assertEquals(2, count($results)); // we ordered on book title, so we expect to get - $this->assertEquals("Harry Potter and the Order of the Phoenix", $results[0]->getTitle()); - $this->assertEquals("Quicksilver", $results[1]->getTitle()); + $this->assertEquals('Harry Potter and the Order of the Phoenix', $results[0]->getTitle()); + $this->assertEquals('Quicksilver', $results[1]->getTitle()); // Perform a lookup & update! // -------------------------- @@ -530,7 +535,7 @@ public function testScenarioUsingQuery() $qs_lookup = BookQuery::create()->findPk($qs_id); $this->assertNotNull($qs_lookup, 'just-created book can be found by pk'); - $new_title = "Quicksilver (".crc32(uniqid(rand())).")"; + $new_title = 'Quicksilver (' . crc32(uniqid(rand())) . ')'; // Attempting to update found object $qs_lookup->setTitle($new_title); $qs_lookup->save(); @@ -559,9 +564,9 @@ public function testScenarioUsingQuery() // Handle BLOB/CLOB Columns // ------------------------ - $blob_path = __DIR__ . '/../../Fixtures/etc/lob/tin_drum.gif'; + $blob_path = __DIR__ . '/../../Fixtures/etc/lob/tin_drum.gif'; $blob2_path = __DIR__ . '/../../Fixtures/etc/lob/propel.gif'; - $clob_path = __DIR__ . '/../../Fixtures/etc/lob/tin_drum.txt'; + $clob_path = __DIR__ . '/../../Fixtures/etc/lob/tin_drum.txt'; $m1 = new Media(); $m1->setBook($phoenix); @@ -574,7 +579,7 @@ public function testScenarioUsingQuery() $this->assertNotNull($m1_lookup, 'Can find just-created media item'); $this->assertEquals(md5(file_get_contents($blob_path)), md5(stream_get_contents($m1_lookup->getCoverImage())), 'BLOB was correctly updated'); - $this->assertEquals(file_get_contents($clob_path), (string) $m1_lookup->getExcerpt(), 'CLOB was correctly updated'); + $this->assertEquals(file_get_contents($clob_path), (string)$m1_lookup->getExcerpt(), 'CLOB was correctly updated'); // now update the BLOB column and save it & check the results $m1_lookup->setCoverImage(file_get_contents($blob2_path)); @@ -598,8 +603,8 @@ public function testScenarioUsingQuery() // init book club list 1 with 2 books $blc1 = new BookClubList(); - $blc1->setGroupLeader("Crazyleggs"); - $blc1->setTheme("Happiness"); + $blc1->setGroupLeader('Crazyleggs'); + $blc1->setTheme('Happiness'); $brel1 = new BookListRel(); $brel1->setBook($phoenix); @@ -617,8 +622,8 @@ public function testScenarioUsingQuery() // init book club list 2 with 1 book $blc2 = new BookClubList(); - $blc2->setGroupLeader("John Foo"); - $blc2->setTheme("Default"); + $blc2->setGroupLeader('John Foo'); + $blc2->setTheme('Default'); $brel3 = new BookListRel(); $brel3->setBook($phoenix); @@ -681,9 +686,9 @@ public function testScenarioUsingQuery() // Attempting to delete books by complex criteria BookQuery::create() - ->filterByISBN("043935806X") - ->_or()->where('Book.ISBN = ?', "0380977427") - ->_or()->where('Book.ISBN = ?', "0140422161") + ->filterByISBN('043935806X') + ->_or()->where('Book.ISBN = ?', '0380977427') + ->_or()->where('Book.ISBN = ?', '0140422161') ->delete(); // Attempting to delete book [id = $td_id] @@ -715,16 +720,19 @@ public function testScenarioUsingQuery() $this->assertCount(0, BookListRelQuery::create()->find(), 'no records in [book_x_list] table'); } + /** + * @return void + */ public function testIssue1493() { $review = new Review(); - $review->setReviewedBy("Reviewer"); + $review->setReviewedBy('Reviewer'); $review->setRecommended(true); $review->setReviewDate(time()); $review->save(); $review = new Review(); - $review->setReviewedBy("Reviewer"); + $review->setReviewedBy('Reviewer'); $review->setRecommended(true); $review->setReviewDate(time()); $review->save(); @@ -732,8 +740,8 @@ public function testIssue1493() $this->assertCount(2, ReviewQuery::create()->find(), 'reviews were saved to database'); $book = new Book(); - $book->setISBN("0140422161"); - $book->setTitle("Don Juan"); + $book->setISBN('0140422161'); + $book->setTitle('Don Juan'); $book->getReviews(); $book->setReviews(new Collection()); diff --git a/tests/Propel/Tests/CharacterEncodingTest.php b/tests/Propel/Tests/CharacterEncodingTest.php index a0b2317bf9..892b62de47 100644 --- a/tests/Propel/Tests/CharacterEncodingTest.php +++ b/tests/Propel/Tests/CharacterEncodingTest.php @@ -10,31 +10,28 @@ namespace Propel\Tests; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; - +use Exception; +use Propel\Runtime\Adapter\PgsqlAdapter; +use Propel\Runtime\Adapter\SqliteAdapter; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\Book; use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Publisher; - -use Propel\Runtime\Propel; -use Propel\Runtime\Adapter\PgsqlAdapter; -use Propel\Runtime\Adapter\SqliteAdapter; - -use \Exception; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Tests the character encoding support of the adapter. * - * This test assumes that the created database supports UTF-8. For this to work, + * This test assumes that the created database supports UTF-8. For this to work, * this file also has to be UTF-8. * - * The database is reloaded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same - * for each test method in this class. See the BookstoreDataPopulator::populate() + * for each test method in this class. See the BookstoreDataPopulator::populate() * method for the exact contents of the database. * - * @see BookstoreDataPopulator + * @see BookstoreDataPopulator * @author Hans Lellelid * * @group database @@ -43,49 +40,60 @@ class CharacterEncodingTest extends BookstoreTestBase { /** * Database adapter. + * * @var DBAdapter */ private $adapter; + /** + * @throws \Exception + * + * @return void + */ public function setUp(): void { parent::setUp(); if (!extension_loaded('iconv')) { - throw new Exception("Character-encoding tests require iconv extension to be loaded."); + throw new Exception('Character-encoding tests require iconv extension to be loaded.'); } } + /** + * @return void + */ public function testUtf8() { $this->markTestSkipped('Skipped because of weird behavior on some platforms'); $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME); - $title = "Смерть на брудершафт. Младенец и черт"; + $title = 'Смерть на брудершафт. Младенец и черт'; // 1234567890123456789012345678901234567 // 1 2 3 $a = new Author(); - $a->setFirstName("Б."); - $a->setLastName("АКУНИН"); + $a->setFirstName('Б.'); + $a->setLastName('АКУНИН'); $p = new Publisher(); - $p->setName("Детектив российский, остросюжетная проза"); + $p->setName('Детектив российский, остросюжетная проза'); $b = new Book(); $b->setTitle($title); - $b->setISBN("B-59246"); + $b->setISBN('B-59246'); $b->setAuthor($a); $b->setPublisher($p); $b->save(); $b->reload(); - $this->assertEquals(37, iconv_strlen($b->getTitle(), 'utf-8'), "Expected 37 characters (not bytes) in title."); - $this->assertTrue(strlen($b->getTitle()) > iconv_strlen($b->getTitle(), 'utf-8'), "Expected more bytes than characters in title."); - + $this->assertEquals(37, iconv_strlen($b->getTitle(), 'utf-8'), 'Expected 37 characters (not bytes) in title.'); + $this->assertTrue(strlen($b->getTitle()) > iconv_strlen($b->getTitle(), 'utf-8'), 'Expected more bytes than characters in title.'); } + /** + * @return void + */ public function testInvalidCharset() { $this->markTestSkipped('Skipped because of weird behavior on some platforms'); @@ -96,30 +104,27 @@ public function testInvalidCharset() } $a = new Author(); - $a->setFirstName("Б."); - $a->setLastName("АКУНИН"); + $a->setFirstName('Б.'); + $a->setLastName('АКУНИН'); $a->save(); - $authorNameWindows1251 = iconv("utf-8", "windows-1251", $a->getLastName()); + $authorNameWindows1251 = iconv('utf-8', 'windows-1251', $a->getLastName()); $a->setLastName($authorNameWindows1251); // Different databases seem to handle invalid data differently (no surprise, I guess...) if ($db instanceof PgsqlAdapter) { try { $a->save(); - $this->fail("Expected an exception when saving non-UTF8 data to database."); + $this->fail('Expected an exception when saving non-UTF8 data to database.'); } catch (Exception $x) { print $x; } - } else { - // No exception is thrown by MySQL ... (others need to be tested still) $a->save(); $a->reload(); - $this->assertEquals("",$a->getLastName(), "Expected last_name to be empty (after inserting invalid charset data)"); + $this->assertEquals('', $a->getLastName(), 'Expected last_name to be empty (after inserting invalid charset data)'); } - } } diff --git a/tests/Propel/Tests/Common/Config/ConfigTestCase.php b/tests/Propel/Tests/Common/Config/ConfigTestCase.php index 7733d6e9d4..4dbe49203d 100644 --- a/tests/Propel/Tests/Common/Config/ConfigTestCase.php +++ b/tests/Propel/Tests/Common/Config/ConfigTestCase.php @@ -21,9 +21,10 @@ class ConfigTestCase extends TestCase { /** + * @var null * Symfony\Component\Filesystem\Filesystem instance */ - private $fileSystem = null; + private $fileSystem; public function getFilesystem() { @@ -38,10 +39,12 @@ public function getFilesystem() * Create a temporary config file inside the system temporary directory * * @param string $filename File Name - * @param string $content File content + * @param string $content File content + * + * @return void */ public function dumpTempFile($filename, $content) { $this->getFilesystem()->dumpFile(sys_get_temp_dir() . '/' . $filename, $content); } -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php index 317b24c5b1..33bc307d56 100644 --- a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php +++ b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php @@ -11,6 +11,7 @@ namespace Propel\Tests\Common\Config; use Propel\Common\Config\ConfigurationManager; +use Propel\Common\Config\Exception\InvalidConfigurationException; class ConfigurationManagerTest extends ConfigTestCase { @@ -26,21 +27,30 @@ class ConfigurationManagerTest extends ConfigTestCase */ private $fixturesDir; + /** + * @return void + */ public function setUp(): void { $this->currentDir = getcwd(); - $this->fixturesDir = realpath( __DIR__ . '/../../../../Fixtures') . '/Configuration'; + $this->fixturesDir = realpath(__DIR__ . '/../../../../Fixtures') . '/Configuration'; $this->getFilesystem()->mkdir($this->fixturesDir); chdir($this->fixturesDir); } + /** + * @return void + */ public function tearDown(): void { chdir($this->currentDir); $this->getFileSystem()->remove($this->fixturesDir); } + /** + * @return void + */ public function testLoadConfigFileInCurrentDirectory() { $yamlConf = <<assertEquals('baz', $actual['bar']); } + /** + * @return void + */ public function testLoadConfigFileInConfigSubdirectory() { $yamlConf = <<assertEquals('baz', $actual['bar']); } + /** + * @return void + */ public function testLoadConfigFileInConfSubdirectory() { $yamlConf = <<assertEquals('baz', $actual['bar']); } + /** + * @return void + */ public function testNotExistingConfigFileLoadsDefaultSettingsAndDoesNotThrowExceptions() { $yamlConf = <<assertArrayNotHasKey('baz', $actual); } + /** + * @return void + */ public function testUnsupportedExtensionsAreIgnored() { $yamlConf = <<assertEquals('bbaz', $actual['bbar']); } + /** + * @return void + */ public function testLoadGivenConfigFile() { $yamlConf = <<assertEquals(['foo' => 'bar', 'bar' => 'baz'], $actual); } + /** + * @return void + */ public function testLoadAlsoDistConfigFile() { $yamlConf = <<assertEquals(['foo' => 'bar', 'bar' => 'baz'], $actual['runtime']); } + /** + * @return void + */ public function testLoadOnlyDistFile() { $yamlDistConf = <<assertEquals(['runtime' => ['foo' => 'bar', 'bar' => 'baz']], $actual); } + /** + * @return void + */ public function testLoadGivenFileAndDist() { $yamlConf = <<assertEquals(['bfoo' => 'bbar', 'bbar' => 'bbaz'], $actual['buildtime']); } + /** + * @return void + */ public function testLoadDistGivenFileOnly() { $yamlDistConf = <<assertEquals(['runtime' => ['foo' => 'bar', 'bar' => 'baz']], $actual); } + /** + * @return void + */ public function testLoadInGivenDirectory() { $yamlConf = <<assertEquals(['bfoo' => 'bbar', 'bbar' => 'bbaz'], $actual['buildtime']); } + /** + * @return void + */ public function testMergeExtraProperties() { $extraConf = [ 'buildtime' => [ - 'bfoo' => 'extrabar' + 'bfoo' => 'extrabar', ], 'extralevel' => [ 'extra1' => 'val1', - 'extra2' => 'val2' - ] + 'extra2' => 'val2', + ], ]; $yamlConf = <<expectException(\Propel\Common\Config\Exception\InvalidConfigurationException::class); + $this->expectException(InvalidConfigurationException::class); $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); new ConfigurationManager(); @@ -439,15 +505,20 @@ public function testRuntimeOrGeneratorConnectionIsNotInConfiguredConnectionsThro /** * @dataProvider providerForInvalidDefaultConnection + * + * @return void */ public function testRuntimeOrGeneratorDefaultConnectionIsNotInConfiguredConnectionsThrowsException($yamlConf, $section) { - $this->expectException(\Propel\Common\Config\Exception\InvalidConfigurationException::class); + $this->expectException(InvalidConfigurationException::class); $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); new ConfigurationManager(); } + /** + * @return void + */ public function testLoadValidConfigurationFile() { $yamlConf = <<assertEquals($actual['connections'], ['mysource', 'yoursource']); } + /** + * @return void + */ public function testSomeDeafults() { $yamlConf = <<assertEquals($actual['generator']['objectModel']['builders']['objectstub'], '\Propel\Generator\Builder\Om\ExtensionObjectBuilder'); } + /** + * @return void + */ public function testGetConfigProperty() { $yamlConf = <<getConfigProperty(10); } + /** + * @return void + */ public function testGetConfigPropertyBadName() { $yamlConf = <<assertNull($value); } + /** + * @return void + */ public function testProcessWithParam() { $configs = [ @@ -664,20 +749,20 @@ public function testProcessWithParam() 'password' => '', 'model_paths' => [ 'src', - 'vendor' - ] - ] - ] + 'vendor', + ], + ], + ], ], 'runtime' => [ 'defaultConnection' => 'default', - 'connections' => ['default'] + 'connections' => ['default'], ], 'generator' => [ 'defaultConnection' => 'default', - 'connections' => ['default'] - ] - ] + 'connections' => ['default'], + ], + ], ]; $manager = new NotLoadingConfigurationManager($configs); @@ -686,6 +771,9 @@ public function testProcessWithParam() $this->assertEquals($configs['propel']['database']['connections'], $actual); } + /** + * @return void + */ public function testProcessWrongParameter() { $manager = new NotLoadingConfigurationManager(null); @@ -693,6 +781,9 @@ public function testProcessWrongParameter() $this->assertEmpty($manager->get()); } + /** + * @return void + */ public function testGetConfigurationParametersArrayTest() { $yamlConf = << 'root', 'password' => '', 'model_paths' => [ - 'src' - ] + 'src', + ], ], 'yoursource' => [ 'adapter' => 'mysql', @@ -744,9 +835,9 @@ classname: Propel\Runtime\Connection\DebugPDO 'password' => '', 'model_paths' => [ 'src', - 'vendor' - ] - ] + 'vendor', + ], + ], ]; $expectedGenerator = [ @@ -757,9 +848,9 @@ classname: Propel\Runtime\Connection\DebugPDO 'user' => 'root', 'password' => '', 'model_paths' => [ - 'src' - ] - ] + 'src', + ], + ], ]; $manager = new ConfigurationManager(); @@ -769,6 +860,9 @@ classname: Propel\Runtime\Connection\DebugPDO $this->assertNull($manager->getConnectionParametersArray('bad_section')); } + /** + * @return void + */ public function testSetConnectionsIfNotDefined() { $yamlConf = <<false -XML - , ['movie' => [0 => ['title' => 'Star Wars', 'starred' => true], 1 => ['title' => 'The Lord Of The Rings', 'starred' => false]]] +XML, ['movie' => [0 => ['title' => 'Star Wars', 'starred' => true], 1 => ['title' => 'The Lord Of The Rings', 'starred' => false]]], ], [<<< XML @@ -210,8 +201,8 @@ public function providerForXmlToArrayConverter() -XML - , ['log' => [ +XML, [ + 'log' => [ 'logger' => [ [ 'type' => 'stream', @@ -225,7 +216,7 @@ public function providerForXmlToArrayConverter() 'name' => 'bookstore', ], ], - ]] + ]], ], [<< @@ -247,8 +238,8 @@ public function providerForXmlToArrayConverter() -EOF - , ['datasources' => [ +EOF, [ + 'datasources' => [ 'bookstore' => [ 'adapter' => 'mysql', 'connection' => ['dsn' => 'mysql:host=localhost;dbname=bookstore'], @@ -260,7 +251,7 @@ public function providerForXmlToArrayConverter() ], ], 'default' => 'bookstore', - ]] + ]], ], [<< @@ -274,8 +265,8 @@ public function providerForXmlToArrayConverter() -EOF - , ['datasources' => [ +EOF, [ + 'datasources' => [ 'bookstore' => [ 'adapter' => 'mysql', 'connection' => [ @@ -283,7 +274,7 @@ public function providerForXmlToArrayConverter() ], ], 'default' => 'bookstore', - ]] + ]], ], [<< @@ -298,8 +289,8 @@ public function providerForXmlToArrayConverter() | -EOF - , ['profiler' => [ +EOF, [ + 'profiler' => [ 'class' => '\Runtime\Runtime\Util\Profiler', 'slowTreshold' => 0.2, 'details' => [ @@ -307,13 +298,14 @@ public function providerForXmlToArrayConverter() 'mem' => ['name' => 'Memory', 'precision' => 3, 'pad' => '8'], ], 'innerGlue' => ': ', - 'outerGlue' => ' | ' - ]] - ] + 'outerGlue' => ' | ', + ]], + ], ]; } - public function providerForXmlToArrayConverterXmlInclusions() { + public function providerForXmlToArrayConverterXmlInclusions() + { return [ [ << -XML - , <<
-XML - , ['table' => [ +XML, [ + 'table' => [ 'name' => 'book', 'phpName' => 'Book', - ]] + ]], ], ]; } diff --git a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php index 09e9e5f0dd..c37d618738 100644 --- a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php @@ -17,6 +17,9 @@ class FileLoaderTest extends TestCase { private $loader; + /** + * @return void + */ public function setUp(): void { $this->loader = new TestableFileLoader(); @@ -28,91 +31,97 @@ public function resolveParamsProvider() [ ['foo'], ['foo'], - '->resolve() returns its argument unmodified if no placeholders are found' + '->resolve() returns its argument unmodified if no placeholders are found', ], [ ['foo' => 'bar', 'I\'m a %foo%'], ['foo' => 'bar', 'I\'m a bar'], - '->resolve() replaces placeholders by their values' + '->resolve() replaces placeholders by their values', ], [ ['foo' => 'bar', '%foo%' => '%foo%'], ['foo' => 'bar', 'bar' => 'bar'], - '->resolve() replaces placeholders in keys and values of arrays' + '->resolve() replaces placeholders in keys and values of arrays', ], [ ['foo' => 'bar', '%foo%' => ['%foo%' => ['%foo%' => '%foo%']]], ['foo' => 'bar', 'bar' => ['bar' => ['bar' => 'bar']]], - '->resolve() replaces placeholders in nested arrays' + '->resolve() replaces placeholders in nested arrays', ], [ ['foo' => 'bar', 'I\'m a %%foo%%'], ['foo' => 'bar', 'I\'m a %foo%'], - '->resolve() supports % escaping by doubling it' + '->resolve() supports % escaping by doubling it', ], [ ['foo' => 'bar', 'I\'m a %foo% %%foo %foo%'], ['foo' => 'bar', 'I\'m a bar %foo bar'], - '->resolve() supports % escaping by doubling it' + '->resolve() supports % escaping by doubling it', ], [ ['foo' => ['bar' => ['ding' => 'I\'m a bar %%foo %%bar']]], ['foo' => ['bar' => ['ding' => 'I\'m a bar %foo %bar']]], - '->resolve() supports % escaping by doubling it' + '->resolve() supports % escaping by doubling it', ], [ ['foo' => 'bar', 'baz' => '%%%foo% %foo%%% %%foo%% %%%foo%%%'], ['foo' => 'bar', 'baz' => '%bar bar% %foo% %bar%'], - '->resolve() replaces params placed besides escaped %' + '->resolve() replaces params placed besides escaped %', ], [ ['baz' => '%%s?%%s', '%baz%'], ['baz' => '%s?%s', '%s?%s'], - '->resolve() is not replacing greedily' + '->resolve() is not replacing greedily', ], [ ['host' => 'foo.bar', 'port' => 1337, '%host%:%port%'], ['host' => 'foo.bar', 'port' => 1337, 'foo.bar:1337'], - '' + '', ], [ ['foo' => 'bar', '%foo%'], ['foo' => 'bar', 'bar'], - 'Parameters must be wrapped by %.' + 'Parameters must be wrapped by %.', ], [ ['foo' => 'bar', '% foo %'], ['foo' => 'bar', '% foo %'], - 'Parameters should not have spaces.' + 'Parameters should not have spaces.', ], [ ['foo' => 'bar', '{% set my_template = "foo" %}'], ['foo' => 'bar', '{% set my_template = "foo" %}'], - 'Twig-like strings are not parameters.' + 'Twig-like strings are not parameters.', ], [ ['foo' => 'bar', '50% is less than 100%'], ['foo' => 'bar', '50% is less than 100%'], - 'Text between % signs is allowed, if there are spaces.' + 'Text between % signs is allowed, if there are spaces.', ], [ ['foo' => ['bar' => 'baz', '%bar%' => 'babar'], 'babaz' => '%foo%'], ['foo' => ['bar' => 'baz', 'baz' => 'babar'], 'babaz' => ['bar' => 'baz', 'baz' => 'babar']], - '' + '', ], [ ['foo' => ['bar' => 'baz'], 'babaz' => '%foo%'], ['foo' => ['bar' => 'baz'], 'babaz' => ['bar' => 'baz']], - '' - ] + '', + ], ]; } + /** + * @return void + */ public function testInitialResolveValueIsFalse() { $this->assertAttributeEquals(false, 'resolved', $this->loader); } + /** + * @return void + */ public function testResolveParams() { putenv('host=127.0.0.1'); @@ -129,11 +138,11 @@ public function testResolveParams() 'conf' => '%project%', 'schema' => '%project%/schema', 'template' => '%HoMe%/templates', - 'output%project%' => '/build' + 'output%project%' => '/build', ], '%HoMe%' => 4, 'host' => '%env.host%', - 'user' => '%env.user%' + 'user' => '%env.user%', ]; $expected = [ @@ -147,11 +156,11 @@ public function testResolveParams() 'conf' => 'myProject', 'schema' => 'myProject/schema', 'template' => 'myHome/templates', - 'outputmyProject' => '/build' + 'outputmyProject' => '/build', ], 'myHome' => 4, 'host' => '127.0.0.1', - 'user' => 'root' + 'user' => 'root', ]; $this->assertEquals($expected, $this->loader->resolveParams($config)); @@ -159,20 +168,24 @@ public function testResolveParams() //cleanup environment putenv('host'); putenv('user'); - } /** * @dataProvider resolveParamsProvider + * + * @return void */ public function testResolveValues($conf, $expected, $message) { $this->assertEquals($expected, $this->loader->resolveParams($conf), $message); } + /** + * @return void + */ public function testResolveReplaceWithoutCasting() { - $conf = $this->loader->resolveParams(['foo'=>true, 'expfoo' => '%foo%', 'bar' => null, 'expbar' => '%bar%']); + $conf = $this->loader->resolveParams(['foo' => true, 'expfoo' => '%foo%', 'bar' => null, 'expbar' => '%bar%']); $this->assertTrue($conf['expfoo'], '->resolve() replaces arguments that are just a placeholder by their value without casting them to strings'); $this->assertNull($conf['expbar'], '->resolve() replaces arguments that are just a placeholder by their value without casting them to strings'); @@ -181,6 +194,8 @@ public function testResolveReplaceWithoutCasting() /** * @expectedException Propel\Common\Config\Exception\InvalidArgumentException * @expectedExceptionMessage Parameter 'baz' not found in configuration file. + * + * @return void */ public function testResolveThrowsExceptionIfInvalidPlaceholder() { @@ -190,6 +205,8 @@ public function testResolveThrowsExceptionIfInvalidPlaceholder() /** * @expectedException Propel\Common\Config\Exception\InvalidArgumentException * @expectedExceptionMessage Parameter 'foobar' not found in configuration file. + * + * @return void */ public function testResolveThrowsExceptionIfNonExistentParameter() { @@ -199,6 +216,8 @@ public function testResolveThrowsExceptionIfNonExistentParameter() /** * @expectedException Propel\Common\Config\Exception\RuntimeException * @expectedExceptionMessage Circular reference detected for parameter 'bar'. + * + * @return void */ public function testResolveThrowsRuntimeExceptionIfCircularReference() { @@ -208,12 +227,17 @@ public function testResolveThrowsRuntimeExceptionIfCircularReference() /** * @expectedException Propel\Common\Config\Exception\RuntimeException * @expectedExceptionMessage Circular reference detected for parameter 'bar'. + * + * @return void */ public function testResolveThrowsRuntimeExceptionIfCircularReferenceMixed() { $this->loader->resolveParams(['foo' => 'a %bar%', 'bar' => 'a %foobar%', 'foobar' => 'a %foo%']); } + /** + * @return void + */ public function testResolveEnvironmentVariable() { putenv('home=myHome'); @@ -229,8 +253,8 @@ public function testResolveEnvironmentVariable() 'projects' => '%home%/projects', 'schema' => '%env.schema%', 'template' => '%home%/templates', - 'output%env.home%' => '/build' - ] + 'output%env.home%' => '/build', + ], ]; $expected = [ @@ -241,8 +265,8 @@ public function testResolveEnvironmentVariable() 'projects' => 'myHome/projects', 'schema' => 'mySchema', 'template' => 'myHome/templates', - 'outputmyHome' => '/build' - ] + 'outputmyHome' => '/build', + ], ]; $this->assertEquals($expected, $this->loader->resolveParams($config)); @@ -254,16 +278,19 @@ public function testResolveEnvironmentVariable() putenv('integer'); } + /** + * @return void + */ public function testResolveEmptyEnvironmentVariable() { putenv('home='); $config = [ - 'home' => '%env.home%' + 'home' => '%env.home%', ]; $expected = [ - 'home' => '' + 'home' => '', ]; $this->assertEquals($expected, $this->loader->resolveParams($config)); @@ -272,12 +299,18 @@ public function testResolveEmptyEnvironmentVariable() putenv('home'); } + /** + * @return void + */ public function testResourceNameIsNotStringReturnsFalse() { $this->assertFalse($this->loader->checkSupports('ini', null)); $this->assertFalse($this->loader->checkSupports('yaml', false)); } + /** + * @return void + */ public function testExtensionIsNotStringOrArrayReturnsFalse() { $this->assertFalse($this->loader->checkSupports('', '/tmp/propel.yaml')); @@ -287,6 +320,8 @@ public function testExtensionIsNotStringOrArrayReturnsFalse() /** * @expectedException \Propel\Common\Config\Exception\InvalidArgumentException * @expectedExceptionMessage Environment variable 'foo' is not defined. + * + * @return void */ public function testNonExistentEnvironmentVariableThrowsException() { @@ -303,23 +338,28 @@ public function testNonExistentEnvironmentVariableThrowsException() /** * @expectedException \Propel\Common\Config\Exception\RuntimeException * @expectedExceptionMessage A string value must be composed of strings and/or numbers, + * + * @return void */ public function testParameterIsNotStringOrNumber() { $config = [ 'foo' => 'a %bar%', 'bar' => [], - 'baz' => '%foo%' + 'baz' => '%foo%', ]; $this->loader->resolveParams($config); } + /** + * @return void + */ public function testCallResolveParamTwiceReturnsEmpty() { $config = [ 'foo' => 'bar', - 'baz' => '%foo%' + 'baz' => '%foo%', ]; $this->assertEquals(['foo' => 'bar', 'baz' => 'bar'], $this->loader->resolveParams($config)); @@ -329,19 +369,23 @@ public function testCallResolveParamTwiceReturnsEmpty() class TestableFileLoader extends BaseFileLoader { + /** + * @return void + */ public function load($file, $type = null) { - } + /** + * @return void + */ public function supports($resource, $type = null) { - } /** * @param string|string[] $ext - * @param false|string $resource + * @param string|false $resource * * @return bool */ diff --git a/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php index 5ebadba607..3872c169e1 100644 --- a/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php @@ -10,19 +10,25 @@ namespace Propel\Tests\Common\Config\Loader; -use Propel\Common\Config\Loader\IniFileLoader; use Propel\Common\Config\FileLocator; +use Propel\Common\Config\Loader\IniFileLoader; use Propel\Tests\Common\Config\ConfigTestCase; class IniFileLoaderTest extends ConfigTestCase { protected $loader; + /** + * @return void + */ protected function setUp(): void { $this->loader = new IniFileLoader(new FileLocator(sys_get_temp_dir())); } + /** + * @return void + */ public function testSupports() { $this->assertTrue($this->loader->supports('foo.ini'), '->supports() returns true if the resource is loadable'); @@ -33,6 +39,9 @@ public function testSupports() $this->assertFalse($this->loader->supports('foo.foo.dist'), '->supports() returns true if the resource is loadable'); } + /** + * @return void + */ public function testIniFileCanBeLoaded() { $content = <<loader->load('nonvalid.ini'); } + /** + * @return void + */ public function testIniFileIsEmpty() { $content = ''; @@ -82,6 +98,9 @@ public function testIniFileIsEmpty() $this->assertEquals([], $actual); } + /** + * @return void + */ public function testWithSections() { $content = <<assertEquals('Minnie', $actual['Cartoons']['Mickey']['love']); } + /** + * @return void + */ public function testNestedSections() { $content = <<assertEquals('blabar', $actual['bla']['bar']); } + /** + * @return void + */ public function testMixedNestedSections() { $content = <<loader->load('parameters.ini'); } + /** + * @return void + */ public function testSectionZero() { $content = <<loader->load('notreadable.ini'); $this->assertEquals('bar', $actual['foo']); $this->assertEquals('baz', $actual['bar']); - } } - diff --git a/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php index 7281d1ea06..7877e497f6 100644 --- a/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php @@ -10,19 +10,25 @@ namespace Propel\Tests\Common\Config\Loader; -use Propel\Common\Config\Loader\JsonFileLoader; use Propel\Common\Config\FileLocator; +use Propel\Common\Config\Loader\JsonFileLoader; use Propel\Tests\Common\Config\ConfigTestCase; class JsonFileLoaderTest extends ConfigTestCase { protected $loader; + /** + * @return void + */ protected function setUp(): void { $this->loader = new JsonFileLoader(new FileLocator(sys_get_temp_dir())); } + /** + * @return void + */ public function testSupports() { $this->assertTrue($this->loader->supports('foo.json'), '->supports() returns true if the resource is loadable'); @@ -31,6 +37,9 @@ public function testSupports() $this->assertFalse($this->loader->supports('foo.bar.dist'), '->supports() returns true if the resource is loadable'); } + /** + * @return void + */ public function testJsonFileCanBeLoaded() { $content = <<loader->load('nonvalid.json'); } + /** + * @return void + */ public function testJsonFileIsEmpty() { $content = ''; @@ -83,7 +99,10 @@ public function testJsonFileIsEmpty() /** * @expectedException Propel\Common\Config\Exception\InputOutputException * @expectedExceptionMessage You don't have permissions to access configuration file notreadable.json. + * * @requires OS ^(?!Win.*) + * + * @return void */ public function testJsonFileNotReadableThrowsException() { @@ -100,6 +119,5 @@ public function testJsonFileNotReadableThrowsException() $actual = $this->loader->load('notreadable.json'); $this->assertEquals('bar', $actual['foo']); $this->assertEquals('baz', $actual['bar']); - } } diff --git a/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php index 3aeb4319f0..b76e0979f0 100644 --- a/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php @@ -10,19 +10,25 @@ namespace Propel\Tests\Common\Config\Loader; -use Propel\Common\Config\Loader\PhpFileLoader; use Propel\Common\Config\FileLocator; +use Propel\Common\Config\Loader\PhpFileLoader; use Propel\Tests\Common\Config\ConfigTestCase; class PhpFileLoaderTest extends ConfigTestCase { protected $loader; + /** + * @return void + */ protected function setUp(): void { $this->loader = new PhpFileLoader(new FileLocator(sys_get_temp_dir())); } + /** + * @return void + */ public function testSupports() { $this->assertTrue($this->loader->supports('foo.php'), '->supports() returns true if the resource is loadable'); @@ -33,6 +39,9 @@ public function testSupports() $this->assertFalse($this->loader->supports('foo.foo.dist'), '->supports() returns true if the resource is loadable'); } + /** + * @return void + */ public function testPhpFileCanBeLoaded() { $content = <<loader->load('notreadable.php'); $this->assertEquals('bar', $actual['foo']); $this->assertEquals('baz', $actual['bar']); - } } diff --git a/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php index e12dddfb78..16b0e3d135 100644 --- a/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php @@ -18,11 +18,17 @@ class XmlFileLoaderTest extends ConfigTestCase { protected $loader; + /** + * @return void + */ protected function setUp(): void { $this->loader = new XmlFileLoader(new FileLocator(sys_get_temp_dir())); } + /** + * @return void + */ public function testSupports() { $this->assertTrue($this->loader->supports('foo.xml'), '->supports() returns true if the resource is loadable'); @@ -32,6 +38,9 @@ public function testSupports() $this->assertFalse($this->loader->supports('foo.bar.dist'), '->supports() returns true if the resource is loadable'); } + /** + * @return void + */ public function testXmlFileCanBeLoaded() { $content = <<< XML @@ -49,8 +58,10 @@ public function testXmlFileCanBeLoaded() } /** - * @expectedException \InvalidArgumentException + * @expectedException \InvalidArgumentException * @expectedExceptionMessage The file "inexistent.xml" does not exist (in: + * + * @return void */ public function testXmlFileDoesNotExist() { @@ -58,8 +69,10 @@ public function testXmlFileDoesNotExist() } /** - * @expectedException Propel\Common\Config\Exception\InvalidArgumentException + * @expectedException Propel\Common\Config\Exception\InvalidArgumentException * @expectedExceptionMessage Invalid xml content + * + * @return void */ public function testXmlFileHasInvalidContent() { @@ -73,6 +86,9 @@ public function testXmlFileHasInvalidContent() @$this->loader->load('nonvalid.xml'); } + /** + * @return void + */ public function testXmlFileIsEmpty() { $content = ''; @@ -86,7 +102,10 @@ public function testXmlFileIsEmpty() /** * @expectedException Propel\Common\Config\Exception\InputOutputException * @expectedExceptionMessage You don't have permissions to access configuration file notreadable.xml. + * * @requires OS ^(?!Win.*) + * + * @return void */ public function testXmlFileNotReadableThrowsException() { @@ -104,6 +123,5 @@ public function testXmlFileNotReadableThrowsException() $actual = $this->loader->load('notreadable.xml'); $this->assertEquals('bar', $actual['foo']); $this->assertEquals('baz', $actual['bar']); - } } diff --git a/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php index 72731c822d..455c6e1712 100644 --- a/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php @@ -10,20 +10,25 @@ namespace Propel\Tests\Common\Config\Loader; -use Propel\Common\Config\Loader\YamlFileLoader; use Propel\Common\Config\FileLocator; +use Propel\Common\Config\Loader\YamlFileLoader; use Propel\Tests\Common\Config\ConfigTestCase; -use Symfony\Component\Yaml\Exception\ParseException; class YamlFileLoaderTest extends ConfigTestCase { protected $loader; + /** + * @return void + */ protected function setUp(): void { $this->loader = new YamlFileLoader(new FileLocator(sys_get_temp_dir())); } + /** + * @return void + */ public function testSupports() { $this->assertTrue($this->loader->supports('foo.yaml'), '->supports() returns true if the resource is loadable'); @@ -34,6 +39,9 @@ public function testSupports() $this->assertFalse($this->loader->supports('foo.bar.dist'), '->supports() returns true if the resource is loadable'); } + /** + * @return void + */ public function testYamlFileCanBeLoaded() { $content = <<loader->load('nonvalid.yaml'); } - + /** + * @return void + */ public function testYamlFileIsEmpty() { $content = ''; @@ -86,7 +100,10 @@ public function testYamlFileIsEmpty() /** * @expectedException Propel\Common\Config\Exception\InputOutputException * @expectedExceptionMessage You don't have permissions to access configuration file notreadable.yaml. + * * @requires OS ^(?!Win.*) + * + * @return void */ public function testYamlFileNotReadableThrowsException() { @@ -101,6 +118,5 @@ public function testYamlFileNotReadableThrowsException() $actual = $this->loader->load('notreadable.yaml'); $this->assertEquals('bar', $actual['foo']); $this->assertEquals('baz', $actual['bar']); - } } diff --git a/tests/Propel/Tests/Common/Config/XmlToArrayConverterTest.php b/tests/Propel/Tests/Common/Config/XmlToArrayConverterTest.php index 340b3105c5..1ad649d63c 100644 --- a/tests/Propel/Tests/Common/Config/XmlToArrayConverterTest.php +++ b/tests/Propel/Tests/Common/Config/XmlToArrayConverterTest.php @@ -18,6 +18,8 @@ class XmlToArrayConverterTest extends ConfigTestCase /** * @dataProvider providerForXmlToArrayConverter + * + * @return void */ public function testConvertFromString($xml, $expected) { @@ -28,6 +30,8 @@ public function testConvertFromString($xml, $expected) /** * @dataProvider providerForXmlToArrayConverter + * + * @return void */ public function testConvertFromFile($xml, $expected) { @@ -39,6 +43,8 @@ public function testConvertFromFile($xml, $expected) /** * @dataProvider providerForXmlToArrayConverterXmlInclusions + * + * @return void */ public function testConvertFromFileWithXmlInclusion($xmlLoad, $xmlInclude, $expected) { @@ -51,6 +57,8 @@ public function testConvertFromFileWithXmlInclusion($xmlLoad, $xmlInclude, $expe /** * @expectedException \Propel\Common\Config\Exception\InvalidArgumentException * @expectedExceptionMessage XmlToArrayConverter::convert method expects an xml file to parse, or a string containing valid xml + * + * @return void */ public function testInvalidFileNameThrowsException() { @@ -60,6 +68,8 @@ public function testInvalidFileNameThrowsException() /** * @expectedException \Propel\Common\Config\Exception\InvalidArgumentException * @expectedExceptionMessage Invalid xml content + * + * @return void */ public function testInexistentFileThrowsException() { @@ -69,6 +79,8 @@ public function testInexistentFileThrowsException() /** * @expectedException \Propel\Common\Config\Exception\InvalidArgumentException * @expectedExceptionMessage Invalid xml content + * + * @return void */ public function testInvalidXmlThrowsException() { @@ -83,6 +95,8 @@ public function testInvalidXmlThrowsException() /** * @expectedException \Propel\Common\Config\Exception\XmlParseException * @expectedExceptionMessage An error occurred while parsing XML configuration file: + * + * @return void */ public function testErrorInXmlThrowsException() { @@ -106,6 +120,8 @@ public function testErrorInXmlThrowsException() - Fatal Error 76: Opening and ending tag mismatch: titles line 4 and title - Fatal Error 73: expected '>' - Fatal Error 5: Extra content at the end of the document + * + * @return void */ public function testMultipleErrorsInXmlThrowsException() { @@ -123,6 +139,9 @@ public function testMultipleErrorsInXmlThrowsException() XmlToArrayConverter::convert($xmlWithErrors); } + /** + * @return void + */ public function testEmptyFileReturnsEmptyArray() { $this->dumpTempFile('empty.xml', ''); diff --git a/tests/Propel/Tests/Common/Pluralizer/EnglishPluralizerTest.php b/tests/Propel/Tests/Common/Pluralizer/EnglishPluralizerTest.php index 4248e016a2..a5e3afc588 100644 --- a/tests/Propel/Tests/Common/Pluralizer/EnglishPluralizerTest.php +++ b/tests/Propel/Tests/Common/Pluralizer/EnglishPluralizerTest.php @@ -10,14 +10,14 @@ namespace Propel\Tests\Common\Pluralizer; +use PHPUnit\Framework\TestCase; use Propel\Common\Pluralizer\SimpleEnglishPluralizer; use Propel\Common\Pluralizer\StandardEnglishPluralizer; /** * Tests for the StandardEnglishPluralizer class - * */ -class EnglishPluralizerTest extends \PHPUnit\Framework\TestCase +class EnglishPluralizerTest extends TestCase { public function getPluralFormDataProvider() { @@ -94,18 +94,23 @@ public function getPluralFormDataProvider() /** * @dataProvider getPluralFormDataProvider + * + * @return void */ public function testStandardPluralForm($input, $output) { $pluralizer = new StandardEnglishPluralizer(); $this->assertEquals($output, $pluralizer->getPluralForm($input)); } + /** * @dataProvider getPluralFormDataProvider + * + * @return void */ public function testSimplePluralForm($input) { $pluralizer = new SimpleEnglishPluralizer(); - $this->assertEquals($input.'s', $pluralizer->getPluralForm($input)); + $this->assertEquals($input . 's', $pluralizer->getPluralForm($input)); } } diff --git a/tests/Propel/Tests/Common/Util/SetColumnConverterTest.php b/tests/Propel/Tests/Common/Util/SetColumnConverterTest.php index 665fcba1cd..154de01107 100644 --- a/tests/Propel/Tests/Common/Util/SetColumnConverterTest.php +++ b/tests/Propel/Tests/Common/Util/SetColumnConverterTest.php @@ -10,77 +10,95 @@ namespace Propel\Tests\Common\Util; +use PHPUnit\Framework\TestCase; use Propel\Common\Util\SetColumnConverter; /** * Tests for SetColumnConverter class. - * - * @author Moritz Schroeder + * + * @author Moritz Schroeder */ -class SetColumnConverterTest extends \PHPUnit\Framework\TestCase +class SetColumnConverterTest extends TestCase { /** - * @param array $values - * @param string $validInteger - * * @dataProvider convertValuesProvider + * + * @param array $values + * @param string $validInteger + * + * @return void */ public function testConvertToIntValidValues(array $values, $validInteger) { - $valueSet = ['a','b','c','d','e','f']; + $valueSet = ['a', 'b', 'c', 'd', 'e', 'f']; $intValue = SetColumnConverter::convertToInt($values, $valueSet); $this->assertEquals($validInteger, $intValue); } + /** + * @return void + */ public function testConvertToIntStringValue() { - $valueSet = ['a','b','c','d','e','f']; + $valueSet = ['a', 'b', 'c', 'd', 'e', 'f']; $intValue = SetColumnConverter::convertToInt('c', $valueSet); $this->assertEquals('4', $intValue); } + /** + * @return void + */ public function testConvertToIntNullValue() { - $valueSet = ['a','b','c','d','e','f']; + $valueSet = ['a', 'b', 'c', 'd', 'e', 'f']; $intValue = SetColumnConverter::convertToInt(null, $valueSet); $this->assertEquals('0', $intValue); } /** * @expectedException \Propel\Common\Exception\SetColumnConverterException + * + * @return void */ public function testConvertToIntValueNotInSet() { - $valueSet = ['a','b','c','d','e','f']; + $valueSet = ['a', 'b', 'c', 'd', 'e', 'f']; SetColumnConverter::convertToInt(['g'], $valueSet); } /** - * @param array $validArray + * @dataProvider convertValuesProvider + * + * @param array $validArray * @param string $intValue * - * @dataProvider convertValuesProvider + * @return void */ public function testConvertIntToArrayValidValues(array $validArray, $intValue) { - $valueSet = ['a','b','c','d','e','f']; + $valueSet = ['a', 'b', 'c', 'd', 'e', 'f']; $arrayValue = SetColumnConverter::convertIntToArray($intValue, $valueSet); $this->assertEquals($validArray, $arrayValue); } + /** + * @return void + */ public function testConvertIntToArrayNullValue() { - $valueSet = ['a','b','c','d','e','f']; + $valueSet = ['a', 'b', 'c', 'd', 'e', 'f']; $arrayValue = SetColumnConverter::convertIntToArray(null, $valueSet); $this->assertEquals([], $arrayValue); } /** * @expectedException \Propel\Common\Exception\SetColumnConverterException + * + * @return void */ public function testConvertIntToArrayIntOutOfRange() { - $valueSet = ['a','b','c','d','e','f']; + $valueSet = ['a', 'b', 'c', 'd', 'e', 'f']; SetColumnConverter::convertIntToArray('65', $valueSet); } diff --git a/tests/Propel/Tests/FieldnameRelatedTest.php b/tests/Propel/Tests/FieldnameRelatedTest.php index d0f58ea4ff..a78fb1add2 100644 --- a/tests/Propel/Tests/FieldnameRelatedTest.php +++ b/tests/Propel/Tests/FieldnameRelatedTest.php @@ -10,11 +10,9 @@ namespace Propel\Tests; -use Propel\Tests\Bookstore\Map\BookTableMap; - use Propel\Runtime\Map\TableMap; use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\Map\ReviewTableMap; +use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Review; /** @@ -39,8 +37,10 @@ class FieldnameRelatedTest extends TestCaseFixtures { /** * Tests if fieldname type constants are defined + * + * @return void */ - public function testFieldNameTypeConstants () + public function testFieldNameTypeConstants() { $result = defined('\Propel\Runtime\Map\TableMap::TYPE_PHPNAME'); $this->assertTrue($result); @@ -48,15 +48,17 @@ public function testFieldNameTypeConstants () /** * Tests the Base[Object]TableMap::getFieldNames() method + * + * @return void */ - public function testGetFieldNames () + public function testGetFieldNames() { $types = [ TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, - TableMap::TYPE_NUM + TableMap::TYPE_NUM, ]; $expecteds = [ TableMap::TYPE_PHPNAME => [ @@ -65,7 +67,7 @@ public function testGetFieldNames () 2 => 'ISBN', 3 => 'Price', 4 => 'PublisherId', - 5 => 'AuthorId' + 5 => 'AuthorId', ], TableMap::TYPE_CAMELNAME => [ 0 => 'id', @@ -73,7 +75,7 @@ public function testGetFieldNames () 2 => 'iSBN', 3 => 'price', 4 => 'publisherId', - 5 => 'authorId' + 5 => 'authorId', ], TableMap::TYPE_COLNAME => [ 0 => 'book.id', @@ -81,7 +83,7 @@ public function testGetFieldNames () 2 => 'book.isbn', 3 => 'book.price', 4 => 'book.publisher_id', - 5 => 'book.author_id' + 5 => 'book.author_id', ], TableMap::TYPE_FIELDNAME => [ 0 => 'id', @@ -89,7 +91,7 @@ public function testGetFieldNames () 2 => 'isbn', 3 => 'price', 4 => 'publisher_id', - 5 => 'author_id' + 5 => 'author_id', ], TableMap::TYPE_NUM => [ 0 => 0, @@ -97,8 +99,8 @@ public function testGetFieldNames () 2 => 2, 3 => 3, 4 => 4, - 5 => 5 - ] + 5 => 5, + ], ]; foreach ($types as $type) { @@ -114,15 +116,17 @@ public function testGetFieldNames () /** * Tests the Base[Object]TableMap::translateFieldName() method + * + * @return void */ - public function testTranslateFieldName () + public function testTranslateFieldName() { $types = [ TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, - TableMap::TYPE_NUM + TableMap::TYPE_NUM, ]; $expecteds = [ TableMap::TYPE_PHPNAME => 'AuthorId', @@ -143,15 +147,17 @@ public function testTranslateFieldName () /** * Tests the BaseTableMap::getFieldNames() method + * + * @return void */ - public function testGetFieldNamesStatic () + public function testGetFieldNamesStatic() { $types = [ TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, - TableMap::TYPE_NUM + TableMap::TYPE_NUM, ]; $expecteds = [ TableMap::TYPE_PHPNAME => [ @@ -160,7 +166,7 @@ public function testGetFieldNamesStatic () 2 => 'ISBN', 3 => 'Price', 4 => 'PublisherId', - 5 => 'AuthorId' + 5 => 'AuthorId', ], TableMap::TYPE_CAMELNAME => [ 0 => 'id', @@ -168,7 +174,7 @@ public function testGetFieldNamesStatic () 2 => 'iSBN', 3 => 'price', 4 => 'publisherId', - 5 => 'authorId' + 5 => 'authorId', ], TableMap::TYPE_COLNAME => [ 0 => 'book.id', @@ -176,7 +182,7 @@ public function testGetFieldNamesStatic () 2 => 'book.isbn', 3 => 'book.price', 4 => 'book.publisher_id', - 5 => 'book.author_id' + 5 => 'book.author_id', ], TableMap::TYPE_FIELDNAME => [ 0 => 'id', @@ -184,7 +190,7 @@ public function testGetFieldNamesStatic () 2 => 'isbn', 3 => 'price', 4 => 'publisher_id', - 5 => 'author_id' + 5 => 'author_id', ], TableMap::TYPE_NUM => [ 0 => 0, @@ -192,8 +198,8 @@ public function testGetFieldNamesStatic () 2 => 2, 3 => 3, 4 => 4, - 5 => 5 - ] + 5 => 5, + ], ]; foreach ($types as $type) { @@ -209,15 +215,17 @@ public function testGetFieldNamesStatic () /** * Tests the BaseTableMap::translateFieldName() method + * + * @return void */ - public function testTranslateFieldNameStatic () + public function testTranslateFieldNameStatic() { $types = [ TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, - TableMap::TYPE_NUM + TableMap::TYPE_NUM, ]; $expecteds = [ TableMap::TYPE_PHPNAME => 'AuthorId', @@ -238,6 +246,8 @@ public function testTranslateFieldNameStatic () /** * Tests the Base[Object]::getByName() method + * + * @return void */ public function testGetByName() { @@ -246,7 +256,7 @@ public function testGetByName() TableMap::TYPE_CAMELNAME => 'title', TableMap::TYPE_COLNAME => 'book.title', TableMap::TYPE_FIELDNAME => 'title', - TableMap::TYPE_NUM => 1 + TableMap::TYPE_NUM => 1, ]; $book = new Book(); @@ -261,6 +271,8 @@ public function testGetByName() /** * Tests the Base[Object]::setByName() method + * + * @return void */ public function testSetByName() { @@ -270,7 +282,7 @@ public function testSetByName() TableMap::TYPE_CAMELNAME => 'title', TableMap::TYPE_COLNAME => 'book.title', TableMap::TYPE_FIELDNAME => 'title', - TableMap::TYPE_NUM => 1 + TableMap::TYPE_NUM => 1, ]; $title = 'Harry Potter and the Order of the Phoenix'; @@ -285,6 +297,8 @@ public function testSetByName() * Tests the Base[Object]::fromArray() method * * this also tests populateFromArray() because that's an alias + * + * @return void */ public function testFromArray() { @@ -293,29 +307,29 @@ public function testFromArray() TableMap::TYPE_CAMELNAME, TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, - TableMap::TYPE_NUM + TableMap::TYPE_NUM, ]; $expecteds = [ TableMap::TYPE_PHPNAME => [ 'Title' => 'Harry Potter and the Order of the Phoenix', - 'ISBN' => '043935806X' + 'ISBN' => '043935806X', ], TableMap::TYPE_CAMELNAME => [ 'title' => 'Harry Potter and the Order of the Phoenix', - 'iSBN' => '043935806X' + 'iSBN' => '043935806X', ], TableMap::TYPE_COLNAME => [ 'book.title' => 'Harry Potter and the Order of the Phoenix', - 'book.isbn' => '043935806X' + 'book.isbn' => '043935806X', ], TableMap::TYPE_FIELDNAME => [ 'title' => 'Harry Potter and the Order of the Phoenix', - 'isbn' => '043935806X' + 'isbn' => '043935806X', ], TableMap::TYPE_NUM => [ '1' => 'Harry Potter and the Order of the Phoenix', - '2' => '043935806X' - ] + '2' => '043935806X', + ], ]; $book = new Book(); @@ -338,6 +352,8 @@ public function testFromArray() /** * Tests the Base[Object]::toArray() method + * + * @return void */ public function testToArray() { @@ -346,36 +362,36 @@ public function testToArray() TableMap::TYPE_CAMELNAME, TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, - TableMap::TYPE_NUM + TableMap::TYPE_NUM, ]; $book = new Book(); $book->fromArray([ 'Title' => 'Harry Potter and the Order of the Phoenix', - 'ISBN' => '043935806X' + 'ISBN' => '043935806X', ]); $expecteds = [ TableMap::TYPE_PHPNAME => [ 'Title' => 'Harry Potter and the Order of the Phoenix', - 'ISBN' => '043935806X' + 'ISBN' => '043935806X', ], TableMap::TYPE_CAMELNAME => [ 'title' => 'Harry Potter and the Order of the Phoenix', - 'iSBN' => '043935806X' + 'iSBN' => '043935806X', ], TableMap::TYPE_COLNAME => [ 'book.title' => 'Harry Potter and the Order of the Phoenix', - 'book.isbn' => '043935806X' + 'book.isbn' => '043935806X', ], TableMap::TYPE_FIELDNAME => [ 'title' => 'Harry Potter and the Order of the Phoenix', - 'isbn' => '043935806X' + 'isbn' => '043935806X', ], TableMap::TYPE_NUM => [ '1' => 'Harry Potter and the Order of the Phoenix', - '2' => '043935806X' - ] + '2' => '043935806X', + ], ]; foreach ($types as $type) { @@ -394,6 +410,8 @@ public function testToArray() /** * @see https://github.com/propelorm/Propel2/issues/648 + * + * @return void */ public function testToArrayWithForeignObjectsDoesNotHavePrefix() { @@ -407,6 +425,9 @@ public function testToArrayWithForeignObjectsDoesNotHavePrefix() $this->assertArrayHasKey(0, $array['Reviews']); } + /** + * @return void + */ public function testToArrayWithForeignObjects() { $types = [ @@ -414,7 +435,7 @@ public function testToArrayWithForeignObjects() TableMap::TYPE_CAMELNAME, TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, - TableMap::TYPE_NUM + TableMap::TYPE_NUM, ]; $review = new Review(); @@ -442,9 +463,9 @@ public function testToArrayWithForeignObjects() 'Recommended' => true, 'Status' => null, 'BookId' => null, - 'Book' => '*RECURSION*' - ] - ] + 'Book' => '*RECURSION*', + ], + ], ], TableMap::TYPE_CAMELNAME => [ 'id' => null, @@ -461,9 +482,9 @@ public function testToArrayWithForeignObjects() 'recommended' => true, 'status' => null, 'bookId' => null, - 'book' => '*RECURSION*' - ] - ] + 'book' => '*RECURSION*', + ], + ], ], TableMap::TYPE_COLNAME => [ 'book.id' => null, @@ -480,9 +501,9 @@ public function testToArrayWithForeignObjects() 'review.recommended' => true, 'review.status' => null, 'review.book_id' => null, - 'Book' => '*RECURSION*' - ] - ] + 'Book' => '*RECURSION*', + ], + ], ], TableMap::TYPE_FIELDNAME => [ 'id' => null, @@ -499,9 +520,9 @@ public function testToArrayWithForeignObjects() 'recommended' => true, 'status' => null, 'book_id' => null, - 'book' => '*RECURSION*' - ] - ] + 'book' => '*RECURSION*', + ], + ], ], TableMap::TYPE_NUM => [ '0' => null, @@ -519,9 +540,9 @@ public function testToArrayWithForeignObjects() '4' => null, '5' => null, 'Book' => '*RECURSION*', - ] - ] - ] + ], + ], + ], ]; foreach ($types as $type) { diff --git a/tests/Propel/Tests/Generator/Behavior/AddClass/AddClassBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/AddClass/AddClassBehaviorTest.php index 42494b1158..be2b1fbe36 100644 --- a/tests/Propel/Tests/Generator/Behavior/AddClass/AddClassBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/AddClass/AddClassBehaviorTest.php @@ -20,6 +20,9 @@ */ class AddClassBehaviorTest extends TestCaseFixtures { + /** + * @return void + */ public function testClassExists() { $t = new AddClassTableFooClass(); diff --git a/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnBehaviorTest.php index e7f64c93db..8df3fe817b 100644 --- a/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnBehaviorTest.php @@ -10,20 +10,17 @@ namespace Propel\Tests\Generator\Behavior\AggregateColumn; -use Propel\Runtime\Propel; -use Propel\Tests\Bookstore\Behavior\AggregateColumn; use Propel\Tests\Bookstore\Behavior\AggregateComment; use Propel\Tests\Bookstore\Behavior\AggregateCommentQuery; -use Propel\Tests\Bookstore\Behavior\AggregatePost; -use Propel\Tests\Bookstore\Behavior\AggregatePostQuery; -use Propel\Tests\Bookstore\Behavior\Map\AggregatePostTableMap; use Propel\Tests\Bookstore\Behavior\AggregateItem; use Propel\Tests\Bookstore\Behavior\AggregateItemQuery; use Propel\Tests\Bookstore\Behavior\AggregatePoll; use Propel\Tests\Bookstore\Behavior\AggregatePollQuery; +use Propel\Tests\Bookstore\Behavior\AggregatePost; +use Propel\Tests\Bookstore\Behavior\AggregatePostQuery; +use Propel\Tests\Bookstore\Behavior\Map\AggregatePostTableMap; use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; - /** * Tests for AggregateColumnBehavior class * @@ -33,12 +30,18 @@ */ class AggregateColumnBehaviorTest extends BookstoreTestBase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); - include_once(__DIR__.'/AggregateColumnsBehaviorTestClasses.php'); + include_once(__DIR__ . '/AggregateColumnsBehaviorTestClasses.php'); } + /** + * @return void + */ public function testParameters() { $postTable = AggregatePostTableMap::getTableMap(); @@ -46,6 +49,9 @@ public function testParameters() $this->assertTrue(method_exists('Propel\Tests\Bookstore\Behavior\AggregatePost', 'getNbComments')); } + /** + * @return void + */ public function testCompute() { AggregateCommentQuery::create()->deleteAll($this->con); @@ -65,6 +71,9 @@ public function testCompute() $this->assertEquals(1, $post->computeNbComments($this->con), 'The compute method computes the aggregate function on related objects'); } + /** + * @return void + */ public function testUpdate() { AggregateCommentQuery::create()->deleteAll($this->con); @@ -83,6 +92,9 @@ public function testUpdate() $this->assertEquals(0, $post->getNbComments(), 'The update method updates the aggregate column'); } + /** + * @return void + */ public function testCreateRelated() { AggregateCommentQuery::create()->deleteAll($this->con); @@ -102,9 +114,12 @@ public function testCreateRelated() $this->assertEquals(2, $post->getNbComments(), 'Adding a new related object updates the aggregate column'); } + /** + * @return void + */ public function testUpdateRelated() { - list($poll, $item1, $item2) = $this->populatePoll(); + [$poll, $item1, $item2] = $this->populatePoll(); $this->assertEquals(19, $poll->getTotalScore()); $this->assertEquals(2, $poll->getNbVotes()); $item1->setScore(10); @@ -113,9 +128,12 @@ public function testUpdateRelated() $this->assertEquals(2, $poll->getNbVotes()); } + /** + * @return void + */ public function testDeleteRelated() { - list($poll, $item1, $item2) = $this->populatePoll(); + [$poll, $item1, $item2] = $this->populatePoll(); $this->assertEquals(19, $poll->getTotalScore()); $this->assertEquals(2, $poll->getNbVotes()); $item1->delete($this->con); @@ -126,9 +144,12 @@ public function testDeleteRelated() $this->assertEquals(0, $poll->getNbVotes()); } + /** + * @return void + */ public function testUpdateRelatedWithQuery() { - list($poll, $item1, $item2) = $this->populatePoll(); + [$poll, $item1, $item2] = $this->populatePoll(); $this->assertEquals(19, $poll->getTotalScore()); $this->assertEquals(2, $poll->getNbVotes()); AggregateItemQuery::create() @@ -137,9 +158,12 @@ public function testUpdateRelatedWithQuery() $this->assertEquals(2, $poll->getNbVotes()); } + /** + * @return void + */ public function testUpdateRelatedWithQueryUsingAlias() { - list($poll, $item1, $item2) = $this->populatePoll(); + [$poll, $item1, $item2] = $this->populatePoll(); $this->assertEquals(19, $poll->getTotalScore()); $this->assertEquals(2, $poll->getNbVotes()); AggregateItemQuery::create() @@ -149,9 +173,12 @@ public function testUpdateRelatedWithQueryUsingAlias() $this->assertEquals(2, $poll->getNbVotes()); } + /** + * @return void + */ public function testDeleteRelatedWithQuery() { - list($poll, $item1, $item2) = $this->populatePoll(); + [$poll, $item1, $item2] = $this->populatePoll(); $this->assertEquals(19, $poll->getTotalScore()); $this->assertEquals(2, $poll->getNbVotes()); AggregateItemQuery::create() @@ -160,9 +187,12 @@ public function testDeleteRelatedWithQuery() $this->assertEquals(0, $poll->getNbVotes()); } + /** + * @return void + */ public function testDeleteRelatedWithQueryUsingAlias() { - list($poll, $item1, $item2) = $this->populatePoll(); + [$poll, $item1, $item2] = $this->populatePoll(); $this->assertEquals(19, $poll->getTotalScore()); $this->assertEquals(2, $poll->getNbVotes()); @@ -178,6 +208,9 @@ public function testDeleteRelatedWithQueryUsingAlias() $this->assertEquals(1, $poll->getNbVotes()); } + /** + * @return void + */ public function testRemoveRelation() { AggregateCommentQuery::create()->deleteAll($this->con); @@ -196,6 +229,9 @@ public function testRemoveRelation() $this->assertEquals(1, $post->getNbComments(), 'Removing a relation changes the related object aggregate column'); } + /** + * @return void + */ public function testReplaceRelation() { AggregateCommentQuery::create()->deleteAll($this->con); @@ -232,5 +268,4 @@ protected function populatePoll() return [$poll, $item1, $item2]; } - } diff --git a/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnBehaviorWithSchemaTest.php b/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnBehaviorWithSchemaTest.php index f919e830c0..d51cc0db3c 100644 --- a/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnBehaviorWithSchemaTest.php +++ b/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnBehaviorWithSchemaTest.php @@ -10,17 +10,16 @@ namespace Propel\Tests\Generator\Behavior\AggregateColumn; +use Propel\Runtime\Propel; use Propel\Tests\BookstoreSchemas\Bookstore; use Propel\Tests\BookstoreSchemas\BookstoreContest; use Propel\Tests\BookstoreSchemas\BookstoreContestEntry; use Propel\Tests\BookstoreSchemas\BookstoreContestEntryQuery; use Propel\Tests\BookstoreSchemas\BookstoreContestQuery; use Propel\Tests\BookstoreSchemas\BookstoreQuery; -use Propel\Tests\BookstoreSchemas\Map\BookstoreTableMap; use Propel\Tests\BookstoreSchemas\Customer; use Propel\Tests\BookstoreSchemas\CustomerQuery; - -use Propel\Runtime\Propel; +use Propel\Tests\BookstoreSchemas\Map\BookstoreTableMap; use Propel\Tests\TestCaseFixturesDatabase; /** @@ -32,6 +31,9 @@ */ class AggregateColumnBehaviorWithSchemaTest extends TestCaseFixturesDatabase { + /** + * @return void + */ public function testParametersWithSchema() { $storeTable = BookstoreTableMap::getTableMap(); @@ -39,6 +41,9 @@ public function testParametersWithSchema() $this->assertTrue(method_exists('Propel\Tests\BookstoreSchemas\Bookstore', 'getTotalContestEntries')); } + /** + * @return void + */ public function testComputeWithSchema() { $con = Propel::getServiceContainer()->getConnection(BookstoreTableMap::DATABASE_NAME); diff --git a/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnsBehaviorTestClasses.php b/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnsBehaviorTestClasses.php index 61c646330e..e531e6bd49 100644 --- a/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnsBehaviorTestClasses.php +++ b/tests/Propel/Tests/Generator/Behavior/AggregateColumn/AggregateColumnsBehaviorTestClasses.php @@ -5,8 +5,6 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\PropelException; -use Propel\Runtime\Propel; -use Propel\Tests\Bookstore\Behavior\AggregateColumn; use Propel\Tests\Bookstore\Behavior\AggregateComment; use Propel\Tests\Bookstore\Behavior\AggregateCommentQuery; use Propel\Tests\Bookstore\Behavior\Map\AggregateCommentTableMap; @@ -14,7 +12,8 @@ class TestableComment extends AggregateComment { // overrides the parent save() to bypass behavior hooks - public function save(ConnectionInterface $con = null) + + public function save(?ConnectionInterface $con = null) { $con->beginTransaction(); try { @@ -25,12 +24,16 @@ public function save(ConnectionInterface $con = null) return $affectedRows; } catch (PropelException $e) { $con->rollBack(); + throw $e; } } // overrides the parent delete() to bypass behavior hooks - public function delete(ConnectionInterface $con = null) + /** + * @return void + */ + public function delete(?ConnectionInterface $con = null) { $con->beginTransaction(); try { @@ -41,20 +44,21 @@ public function delete(ConnectionInterface $con = null) $this->setDeleted(true); } catch (PropelException $e) { $con->rollBack(); + throw $e; } } - } class TestableAggregateCommentQuery extends AggregateCommentQuery { - public static function create($modelAlias = null, Criteria $criteria = null) + public static function create($modelAlias = null, ?Criteria $criteria = null) { return new TestableAggregateCommentQuery(); } // overrides the parent basePreDelete() to bypass behavior hooks + protected function basePreDelete(ConnectionInterface $con) { return $this->preDelete($con); @@ -65,5 +69,4 @@ protected function basePostDelete($affectedRows, ConnectionInterface $con) { return $this->postDelete($affectedRows, $con); } - } diff --git a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php index 2540b7a34d..7aee8ab708 100644 --- a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php @@ -11,10 +11,14 @@ namespace Propel\Tests\Generator\Behavior\Archivable; +use ArchivableTest10; +use ArchivableTest10Archive; +use ArchivableTest10ArchiveQuery; +use ArchivableTest10Query; +use ArchivableTest30; +use ArchivableTest40; +use MyOldArchivableTest30Query; use Propel\Generator\Util\QuickBuilder; -use Propel\Generator\Behavior\Archivable\ArchivableBehavior; - -use Propel\Runtime\Propel; use Propel\Tests\TestCase; /** @@ -24,6 +28,9 @@ */ class ArchivableBehaviorObjectBuilderModifierTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('\ArchivableTest10')) { @@ -85,53 +92,71 @@ public function setUp(): void } } + /** + * @return void + */ public function testHasGetArchiveMethod() { $this->assertTrue(method_exists('\ArchivableTest10', 'getArchive')); } + /** + * @return void + */ public function testGetArchiveReturnsNullOnNewObjects() { - $a = new \ArchivableTest10(); + $a = new ArchivableTest10(); $this->assertNull($a->getArchive()); } + /** + * @return void + */ public function testGetArchiveReturnsNullWhenNoArchiveIsFound() { - $a = new \ArchivableTest10(); + $a = new ArchivableTest10(); $a->setTitle('foo'); $a->setAge(12); $a->save(); $this->assertNull($a->getArchive()); } + /** + * @return void + */ public function testGetArchiveReturnsExistingArchive() { - $a = new \ArchivableTest10(); + $a = new ArchivableTest10(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - $archive = new \ArchivableTest10Archive(); + $archive = new ArchivableTest10Archive(); $archive->setId($a->getId()); $archive->setTitle('bar'); $archive->save(); $this->assertSame($archive, $a->getArchive()); } + /** + * @return void + */ public function testHasArchiveMethod() { $this->assertTrue(method_exists('\ArchivableTest10', 'archive')); } + /** + * @return void + */ public function testArchiveCreatesACopyByDefault() { - \ArchivableTest10ArchiveQuery::create()->deleteAll(); - $a = new \ArchivableTest10(); + ArchivableTest10ArchiveQuery::create()->deleteAll(); + $a = new ArchivableTest10(); $a->setTitle('foo'); $a->setAge(12); $a->save(); $a->archive(); - $archive = \ArchivableTest10ArchiveQuery::create() + $archive = ArchivableTest10ArchiveQuery::create() ->filterById($a->getId()) ->findOne(); $this->assertInstanceOf('\ArchivableTest10Archive', $archive); @@ -139,25 +164,31 @@ public function testArchiveCreatesACopyByDefault() $this->assertEquals(12, $archive->getAge()); } + /** + * @return void + */ public function testArchiveUpdatesExistingArchive() { - \ArchivableTest10ArchiveQuery::create()->deleteAll(); - $a = new \ArchivableTest10(); + ArchivableTest10ArchiveQuery::create()->deleteAll(); + $a = new ArchivableTest10(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - $b = new \ArchivableTest10Archive(); + $b = new ArchivableTest10Archive(); $b->setId($a->getId()); $b->setTitle('bar'); $b->save(); $a->archive(); - $this->assertEquals(1, \ArchivableTest10ArchiveQuery::create()->count()); + $this->assertEquals(1, ArchivableTest10ArchiveQuery::create()->count()); $this->assertEquals('foo', $b->getTitle()); } + /** + * @return void + */ public function testArchiveUsesArchiveClassIfSpecified() { - $a = new \ArchivableTest40(); + $a = new ArchivableTest40(); $a->setTitle('foo'); $a->setAge(12); $a->save(); @@ -168,9 +199,12 @@ public function testArchiveUsesArchiveClassIfSpecified() $this->assertEquals(12, $archive->age); } + /** + * @return void + */ public function testArchiveReturnsArchivedObject() { - $a = new \ArchivableTest10(); + $a = new ArchivableTest10(); $a->setTitle('foo'); $a->save(); $ret = $a->archive(); @@ -181,13 +215,18 @@ public function testArchiveReturnsArchivedObject() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testArchiveThrowsExceptionOnNewObjects() { - $a = new \ArchivableTest10(); + $a = new ArchivableTest10(); $a->archive(); } + /** + * @return void + */ public function testHasRestoreFromArchiveMethod() { $this->assertTrue(method_exists('\ArchivableTest10', 'restoreFromArchive')); @@ -195,23 +234,28 @@ public function testHasRestoreFromArchiveMethod() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testRestoreFromArchiveThrowsExceptionOnUnarchivedObjects() { - $a = new \ArchivableTest10(); + $a = new ArchivableTest10(); $a->setTitle('foo'); $a->setAge(12); $a->save(); $a->restoreFromArchive(); } + /** + * @return void + */ public function testRestoreFromArchiveChangesStateToTheArchiveState() { - $a = new \ArchivableTest10(); + $a = new ArchivableTest10(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - $archive = new \ArchivableTest10Archive(); + $archive = new ArchivableTest10Archive(); $archive->setId($a->getId()); $archive->setTitle('bar'); $archive->setAge(15); @@ -221,57 +265,72 @@ public function testRestoreFromArchiveChangesStateToTheArchiveState() $this->assertEquals(15, $a->getAge()); } + /** + * @return void + */ public function testHasPopulateFromArchiveMethod() { $this->assertTrue(method_exists('\ArchivableTest10', 'populateFromArchive')); } + /** + * @return void + */ public function testPopulateFromArchiveReturnsCurrentObject() { - $archive = new \ArchivableTest10Archive(); - $a = new \ArchivableTest10(); + $archive = new ArchivableTest10Archive(); + $a = new ArchivableTest10(); $ret = $a->populateFromArchive($archive); $this->assertSame($ret, $a); } + /** + * @return void + */ public function testPopulateFromArchive() { - \ArchivableTest10ArchiveQuery::create()->deleteAll(); - \ArchivableTest10Query::create()->deleteAllWithoutArchive(); - $archive = new \ArchivableTest10Archive(); + ArchivableTest10ArchiveQuery::create()->deleteAll(); + ArchivableTest10Query::create()->deleteAllWithoutArchive(); + $archive = new ArchivableTest10Archive(); $archive->setId(123); // not autoincremented $archive->setTitle('foo'); $archive->setAge(12); $archive->save(); - $a = new \ArchivableTest10(); + $a = new ArchivableTest10(); $a->populateFromArchive($archive); $this->assertNotEquals(123, $a->getId()); $this->assertEquals('foo', $a->getTitle()); $this->assertEquals(12, $a->getAge()); - $b = new \ArchivableTest10(); + $b = new ArchivableTest10(); $b->populateFromArchive($archive, true); $this->assertEquals(123, $b->getId()); } + /** + * @return void + */ public function testInsertDoesNotCreateArchiveByDefault() { - $a = new \ArchivableTest10(); + $a = new ArchivableTest10(); $a->setTitle('foo'); $a->setAge(12); - \ArchivableTest10ArchiveQuery::create()->deleteAll(); + ArchivableTest10ArchiveQuery::create()->deleteAll(); $a->save(); - $this->assertEquals(0, \ArchivableTest10ArchiveQuery::create()->count()); + $this->assertEquals(0, ArchivableTest10ArchiveQuery::create()->count()); } + /** + * @return void + */ public function testInsertCreatesArchiveIfSpecified() { - $a = new \ArchivableTest30(); + $a = new ArchivableTest30(); $a->setTitle('foo'); $a->setAge(12); - \MyOldArchivableTest30Query::create()->deleteAll(); + MyOldArchivableTest30Query::create()->deleteAll(); $a->save(); - $this->assertEquals(1, \MyOldArchivableTest30Query::create()->count()); - $archive = \MyOldArchivableTest30Query::create() + $this->assertEquals(1, MyOldArchivableTest30Query::create()->count()); + $archive = MyOldArchivableTest30Query::create() ->filterById($a->getId()) ->findOne(); $this->assertInstanceOf('\MyOldArchivableTest30', $archive); @@ -279,29 +338,35 @@ public function testInsertCreatesArchiveIfSpecified() $this->assertEquals(12, $archive->getAge()); } + /** + * @return void + */ public function testUpdateDoesNotCreateArchiveByDefault() { - $a = new \ArchivableTest10(); + $a = new ArchivableTest10(); $a->setTitle('foo'); $a->setAge(12); $a->save(); $a->setTitle('bar'); - \ArchivableTest10ArchiveQuery::create()->deleteAll(); + ArchivableTest10ArchiveQuery::create()->deleteAll(); $a->save(); - $this->assertEquals(0, \ArchivableTest10ArchiveQuery::create()->count()); + $this->assertEquals(0, ArchivableTest10ArchiveQuery::create()->count()); } + /** + * @return void + */ public function testUpdateCreatesArchiveIfSpecified() { - $a = new \ArchivableTest30(); + $a = new ArchivableTest30(); $a->setTitle('foo'); $a->setAge(12); $a->save(); $a->setTitle('bar'); - \MyOldArchivableTest30Query::create()->deleteAll(); + MyOldArchivableTest30Query::create()->deleteAll(); $a->save(); - $this->assertEquals(1, \MyOldArchivableTest30Query::create()->count()); - $archive = \MyOldArchivableTest30Query::create() + $this->assertEquals(1, MyOldArchivableTest30Query::create()->count()); + $archive = MyOldArchivableTest30Query::create() ->filterById($a->getId()) ->findOne(); $this->assertInstanceOf('\MyOldArchivableTest30', $archive); @@ -309,16 +374,19 @@ public function testUpdateCreatesArchiveIfSpecified() $this->assertEquals(12, $archive->getAge()); } + /** + * @return void + */ public function testDeleteCreatesArchiveByDefault() { - $a = new \ArchivableTest10(); + $a = new ArchivableTest10(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - \ArchivableTest10ArchiveQuery::create()->deleteAll(); + ArchivableTest10ArchiveQuery::create()->deleteAll(); $a->delete(); - $this->assertEquals(1, \ArchivableTest10ArchiveQuery::create()->count()); - $archive = \ArchivableTest10ArchiveQuery::create() + $this->assertEquals(1, ArchivableTest10ArchiveQuery::create()->count()); + $archive = ArchivableTest10ArchiveQuery::create() ->filterById($a->getId()) ->findOne(); $this->assertInstanceOf('\ArchivableTest10Archive', $archive); @@ -326,69 +394,89 @@ public function testDeleteCreatesArchiveByDefault() $this->assertEquals(12, $archive->getAge()); } + /** + * @return void + */ public function testDeleteDoesNotCreateArchiveIfSpecified() { - $a = new \ArchivableTest30(); + $a = new ArchivableTest30(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - \MyOldArchivableTest30Query::create()->deleteAll(); + MyOldArchivableTest30Query::create()->deleteAll(); $a->delete(); - $this->assertEquals(0, \MyOldArchivableTest30Query::create()->count()); + $this->assertEquals(0, MyOldArchivableTest30Query::create()->count()); } + /** + * @return void + */ public function testHasSaveWithoutArchiveMethod() { $this->assertTrue(method_exists('\ArchivableTest30', 'saveWithoutArchive')); } + /** + * @return void + */ public function testSaveWithoutArchiveDoesNotCreateArchiveOnInsert() { - $a = new \ArchivableTest30(); + $a = new ArchivableTest30(); $a->setTitle('foo'); $a->setAge(12); - \MyOldArchivableTest30Query::create()->deleteAll(); + MyOldArchivableTest30Query::create()->deleteAll(); $a->saveWithoutArchive(); - $this->assertEquals(0, \MyOldArchivableTest30Query::create()->count()); + $this->assertEquals(0, MyOldArchivableTest30Query::create()->count()); } + /** + * @return void + */ public function testSaveWithoutArchiveDoesNotCreateArchiveOnUpdate() { - $a = new \ArchivableTest30(); + $a = new ArchivableTest30(); $a->setTitle('foo'); $a->setAge(12); $a->save(); $a->setTitle('bar'); - \MyOldArchivableTest30Query::create()->deleteAll(); - $this->assertEquals(0, \MyOldArchivableTest30Query::create()->count()); + MyOldArchivableTest30Query::create()->deleteAll(); + $this->assertEquals(0, MyOldArchivableTest30Query::create()->count()); $a->saveWithoutArchive(); - $this->assertEquals(0, \MyOldArchivableTest30Query::create()->count()); + $this->assertEquals(0, MyOldArchivableTest30Query::create()->count()); } + /** + * @return void + */ public function testHasDeleteWithoutArchiveMethod() { $this->assertTrue(method_exists('\ArchivableTest10', 'deleteWithoutArchive')); } + /** + * @return void + */ public function testDeleteWithoutArchiveDoesNotCreateArchive() { - $a = new \ArchivableTest10(); + $a = new ArchivableTest10(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - \ArchivableTest10ArchiveQuery::create()->deleteAll(); + ArchivableTest10ArchiveQuery::create()->deleteAll(); $a->deleteWithoutArchive(); - $this->assertEquals(0, \ArchivableTest10ArchiveQuery::create()->count()); + $this->assertEquals(0, ArchivableTest10ArchiveQuery::create()->count()); } + /** + * @return void + */ public function testArchiveSetArchivedAtToTheCurrentTime() { - $a = new \ArchivableTest10(); + $a = new ArchivableTest10(); $a->setTitle('foo'); $a->save(); $ret = $a->archive(); // time without seconds $this->assertEquals(date('Y-m-d H:i'), $ret->getArchivedAt('Y-m-d H:i')); } - } diff --git a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifierTest.php index 8cf6ba7372..82afef1c79 100644 --- a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifierTest.php @@ -11,10 +11,14 @@ namespace Propel\Tests\Generator\Behavior\Archivable; +use ArchivableTest100; +use ArchivableTest100Archive; +use ArchivableTest100ArchiveQuery; +use ArchivableTest100Query; +use ArchivableTest300; +use ArchivableTest300Query; +use MyOldArchivableTest300Query; use Propel\Generator\Util\QuickBuilder; -use Propel\Generator\Behavior\Archivable\ArchivableBehavior; - -use Propel\Runtime\Propel; use Propel\Tests\TestCase; /** @@ -24,6 +28,9 @@ */ class ArchivableBehaviorQueryBuilderModifierTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('\ArchivableTest100')) { @@ -85,23 +92,29 @@ public function setUp(): void } } + /** + * @return void + */ public function testHasArchiveMethod() { $this->assertTrue(method_exists('\ArchivableTest100Query', 'archive')); } + /** + * @return void + */ public function testArchiveCreatesACopyByDefault() { - \ArchivableTest100Query::create()->deleteAllWithoutArchive(); - $a = new \ArchivableTest100(); + ArchivableTest100Query::create()->deleteAllWithoutArchive(); + $a = new ArchivableTest100(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - \ArchivableTest100ArchiveQuery::create()->deleteAll(); - \ArchivableTest100Query::create() + ArchivableTest100ArchiveQuery::create()->deleteAll(); + ArchivableTest100Query::create() ->filterById($a->getId()) ->archive(); - $archive = \ArchivableTest100ArchiveQuery::create() + $archive = ArchivableTest100ArchiveQuery::create() ->filterById($a->getId()) ->findOne(); $this->assertInstanceOf('\ArchivableTest100Archive', $archive); @@ -109,174 +122,213 @@ public function testArchiveCreatesACopyByDefault() $this->assertEquals(12, $archive->getAge()); } + /** + * @return void + */ public function testArchiveUpdatesExistingArchive() { - \ArchivableTest100ArchiveQuery::create()->deleteAll(); - $a = new \ArchivableTest100(); + ArchivableTest100ArchiveQuery::create()->deleteAll(); + $a = new ArchivableTest100(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - \ArchivableTest100ArchiveQuery::create()->deleteAll(); - $b = new \ArchivableTest100Archive(); + ArchivableTest100ArchiveQuery::create()->deleteAll(); + $b = new ArchivableTest100Archive(); $b->setId($a->getId()); $b->setTitle('bar'); $b->save(); - \ArchivableTest100Query::create() + ArchivableTest100Query::create() ->filterById($a->getId()) ->archive(null, false); - $this->assertEquals(1, \ArchivableTest100ArchiveQuery::create()->count()); + $this->assertEquals(1, ArchivableTest100ArchiveQuery::create()->count()); $this->assertEquals('foo', $b->getTitle()); } + /** + * @return void + */ public function testArchiveReturnsNumberOfArchivedObjectsObject() { - \ArchivableTest100Query::create()->deleteAllWithoutArchive(); - $this->assertEquals(0, \ArchivableTest100Query::create()->archive()); - $a = new \ArchivableTest100(); + ArchivableTest100Query::create()->deleteAllWithoutArchive(); + $this->assertEquals(0, ArchivableTest100Query::create()->archive()); + $a = new ArchivableTest100(); $a->save(); - $this->assertEquals(1, \ArchivableTest100Query::create()->archive()); + $this->assertEquals(1, ArchivableTest100Query::create()->archive()); } + /** + * @return void + */ public function testUpdateDoesNotCreateArchivesByDefault() { - \ArchivableTest100Query::create()->deleteAllWithoutArchive(); - $a = new \ArchivableTest100(); + ArchivableTest100Query::create()->deleteAllWithoutArchive(); + $a = new ArchivableTest100(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - \ArchivableTest100ArchiveQuery::create()->deleteAll(); - \ArchivableTest100Query::create() + ArchivableTest100ArchiveQuery::create()->deleteAll(); + ArchivableTest100Query::create() ->filterById($a->getId()) ->update(['Title' => 'bar']); - $this->assertEquals(1, \ArchivableTest100Query::create()->filterByTitle('bar')->count()); - $this->assertEquals(0, \ArchivableTest100ArchiveQuery::create()->count()); + $this->assertEquals(1, ArchivableTest100Query::create()->filterByTitle('bar')->count()); + $this->assertEquals(0, ArchivableTest100ArchiveQuery::create()->count()); } + /** + * @return void + */ public function testUpdateCreatesArchivesIfSpecified() { - \ArchivableTest300Query::create()->deleteAll(); - $a = new \ArchivableTest300(); + ArchivableTest300Query::create()->deleteAll(); + $a = new ArchivableTest300(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - \MyOldArchivableTest300Query::create()->deleteAll(); - \ArchivableTest300Query::create() + MyOldArchivableTest300Query::create()->deleteAll(); + ArchivableTest300Query::create() ->filterById($a->getId()) ->update(['Title' => 'bar']); - $this->assertEquals(1, \ArchivableTest300Query::create()->filterByTitle('bar')->count()); - $this->assertEquals(1, \MyOldArchivableTest300Query::create()->count()); + $this->assertEquals(1, ArchivableTest300Query::create()->filterByTitle('bar')->count()); + $this->assertEquals(1, MyOldArchivableTest300Query::create()->count()); } + /** + * @return void + */ public function testDeleteCreatesArchivesByDefault() { - \ArchivableTest100Query::create()->deleteAllWithoutArchive(); - $a = new \ArchivableTest100(); + ArchivableTest100Query::create()->deleteAllWithoutArchive(); + $a = new ArchivableTest100(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - \ArchivableTest100ArchiveQuery::create()->deleteAll(); - \ArchivableTest100Query::create() + ArchivableTest100ArchiveQuery::create()->deleteAll(); + ArchivableTest100Query::create() ->filterById($a->getId()) ->delete(); - $this->assertEquals(0, \ArchivableTest100Query::create()->count()); - $this->assertEquals(1, \ArchivableTest100ArchiveQuery::create()->count()); + $this->assertEquals(0, ArchivableTest100Query::create()->count()); + $this->assertEquals(1, ArchivableTest100ArchiveQuery::create()->count()); } + /** + * @return void + */ public function testDeleteAllCreatesArchivesByDefault() { - \ArchivableTest100Query::create()->deleteAllWithoutArchive(); - $a = new \ArchivableTest100(); + ArchivableTest100Query::create()->deleteAllWithoutArchive(); + $a = new ArchivableTest100(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - \ArchivableTest100ArchiveQuery::create()->deleteAll(); - \ArchivableTest100Query::create() + ArchivableTest100ArchiveQuery::create()->deleteAll(); + ArchivableTest100Query::create() ->deleteAll(); - $this->assertEquals(0, \ArchivableTest100Query::create()->count()); - $this->assertEquals(1, \ArchivableTest100ArchiveQuery::create()->count()); + $this->assertEquals(0, ArchivableTest100Query::create()->count()); + $this->assertEquals(1, ArchivableTest100ArchiveQuery::create()->count()); } + /** + * @return void + */ public function testDeleteDoesNotCreateArchivesIfSpecified() { - \ArchivableTest300Query::create()->deleteAll(); - $a = new \ArchivableTest300(); + ArchivableTest300Query::create()->deleteAll(); + $a = new ArchivableTest300(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - \MyOldArchivableTest300Query::create()->deleteAll(); - \ArchivableTest300Query::create() + MyOldArchivableTest300Query::create()->deleteAll(); + ArchivableTest300Query::create() ->filterById($a->getId()) ->delete(); - $this->assertEquals(0, \ArchivableTest300Query::create()->count()); - $this->assertEquals(0, \MyOldArchivableTest300Query::create()->count()); + $this->assertEquals(0, ArchivableTest300Query::create()->count()); + $this->assertEquals(0, MyOldArchivableTest300Query::create()->count()); } + /** + * @return void + */ public function testDeleteAllDoesNotCreateArchivesIfSpecified() { - \ArchivableTest300Query::create()->deleteAll(); - $a = new \ArchivableTest300(); + ArchivableTest300Query::create()->deleteAll(); + $a = new ArchivableTest300(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - \MyOldArchivableTest300Query::create()->deleteAll(); - \ArchivableTest300Query::create() + MyOldArchivableTest300Query::create()->deleteAll(); + ArchivableTest300Query::create() ->deleteAll(); - $this->assertEquals(0, \ArchivableTest300Query::create()->count()); - $this->assertEquals(0, \MyOldArchivableTest300Query::create()->count()); + $this->assertEquals(0, ArchivableTest300Query::create()->count()); + $this->assertEquals(0, MyOldArchivableTest300Query::create()->count()); } + /** + * @return void + */ public function testHasUpdateWithoutArchiveMethod() { $this->assertTrue(method_exists('\ArchivableTest300Query', 'updateWithoutArchive')); } + /** + * @return void + */ public function testUpdateWithoutArchiveDoesNotCreateArchives() { - \ArchivableTest300Query::create()->deleteAll(); - $a = new \ArchivableTest300(); + ArchivableTest300Query::create()->deleteAll(); + $a = new ArchivableTest300(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - \MyOldArchivableTest300Query::create()->deleteAll(); - \ArchivableTest300Query::create() + MyOldArchivableTest300Query::create()->deleteAll(); + ArchivableTest300Query::create() ->filterById($a->getId()) ->updateWithoutArchive(['Title' => 'bar']); - $this->assertEquals(1, \ArchivableTest300Query::create()->filterByTitle('bar')->count()); - $this->assertEquals(0, \MyOldArchivableTest300Query::create()->count()); + $this->assertEquals(1, ArchivableTest300Query::create()->filterByTitle('bar')->count()); + $this->assertEquals(0, MyOldArchivableTest300Query::create()->count()); } + /** + * @return void + */ public function testHasDeleteWithoutArchiveMethods() { $this->assertTrue(method_exists('\ArchivableTest100Query', 'deleteWithoutArchive')); $this->assertTrue(method_exists('\ArchivableTest100Query', 'deleteAllWithoutArchive')); } + /** + * @return void + */ public function testDeleteWithoutArchiveDoesNotCreateArchivesByDefault() { - \ArchivableTest100Query::create()->deleteAllWithoutArchive(); - $a = new \ArchivableTest100(); + ArchivableTest100Query::create()->deleteAllWithoutArchive(); + $a = new ArchivableTest100(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - \ArchivableTest100ArchiveQuery::create()->deleteAll(); - \ArchivableTest100Query::create() + ArchivableTest100ArchiveQuery::create()->deleteAll(); + ArchivableTest100Query::create() ->filterById($a->getId()) ->deleteWithoutArchive(); - $this->assertEquals(0, \ArchivableTest100Query::create()->count()); - $this->assertEquals(0, \ArchivableTest100ArchiveQuery::create()->count()); + $this->assertEquals(0, ArchivableTest100Query::create()->count()); + $this->assertEquals(0, ArchivableTest100ArchiveQuery::create()->count()); } + /** + * @return void + */ public function testDeleteAllWithoutArchiveDoesNotCreateArchivesByDefault() { - \ArchivableTest100Query::create()->deleteAllWithoutArchive(); - $a = new \ArchivableTest100(); + ArchivableTest100Query::create()->deleteAllWithoutArchive(); + $a = new ArchivableTest100(); $a->setTitle('foo'); $a->setAge(12); $a->save(); - \ArchivableTest100ArchiveQuery::create()->deleteAll(); - \ArchivableTest100Query::create() + ArchivableTest100ArchiveQuery::create()->deleteAll(); + ArchivableTest100Query::create() ->deleteAllWithoutArchive(); - $this->assertEquals(0, \ArchivableTest100Query::create()->count()); - $this->assertEquals(0, \ArchivableTest100ArchiveQuery::create()->count()); + $this->assertEquals(0, ArchivableTest100Query::create()->count()); + $this->assertEquals(0, ArchivableTest100ArchiveQuery::create()->count()); } } diff --git a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorTest.php index 81ba2f8f22..7c3be49798 100644 --- a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorTest.php @@ -11,9 +11,15 @@ namespace Propel\Tests\Generator\Behavior\Archivable; +use Map\ArchivableTest1ArchiveTableMap; +use Map\ArchivableTest1TableMap; +use Map\ArchivableTest2ArchiveTableMap; +use Map\ArchivableTest2TableMap; +use Map\ArchivableTest3TableMap; +use Map\ArchivableTest4TableMap; +use Map\ArchivableTest5TableMap; +use Map\MyOldArchivableTest3TableMap; use Propel\Generator\Util\QuickBuilder; -use Propel\Generator\Behavior\Archivable\ArchivableBehavior; -use Propel\Runtime\Propel; use Propel\Tests\TestCase; /** @@ -25,6 +31,9 @@ class ArchivableBehaviorTest extends TestCase { protected static $generatedSQL; + /** + * @return void + */ public function setUp(): void { if (!class_exists('\ArchivableTest1')) { @@ -100,42 +109,60 @@ public function setUp(): void } } + /** + * @return void + */ public function testCreatesArchiveTable() { - $table = \Map\ArchivableTest1TableMap::getTableMap(); + $table = ArchivableTest1TableMap::getTableMap(); $this->assertTrue($table->getDatabaseMap()->hasTable('archivable_test_1_archive')); - $this->assertSame("ArchivableTest1Archive", $table->getDatabaseMap()->getTable('archivable_test_1_archive')->getPhpName()); + $this->assertSame('ArchivableTest1Archive', $table->getDatabaseMap()->getTable('archivable_test_1_archive')->getPhpName()); } + /** + * @return void + */ public function testDoesNotCreateCustomArchiveTableIfExists() { - $table = \Map\ArchivableTest2TableMap::getTableMap(); + $table = ArchivableTest2TableMap::getTableMap(); $this->assertTrue($table->getDatabaseMap()->hasTable('archivable_test_2_archive')); } + /** + * @return void + */ public function testCanCreateCustomArchiveTableName() { - $table = \Map\ArchivableTest3TableMap::getTableMap(); + $table = ArchivableTest3TableMap::getTableMap(); $this->assertTrue($table->getDatabaseMap()->hasTable('my_old_archivable_test_3')); - $this->assertSame("MyOldArchivableTest3", $table->getDatabaseMap()->getTable('my_old_archivable_test_3')->getPhpName()); + $this->assertSame('MyOldArchivableTest3', $table->getDatabaseMap()->getTable('my_old_archivable_test_3')->getPhpName()); } + /** + * @return void + */ public function testDoesNotCreateCustomArchiveTableIfArchiveClassIsSpecified() { - $table = \Map\ArchivableTest4TableMap::getTableMap(); + $table = ArchivableTest4TableMap::getTableMap(); $this->assertFalse($table->getDatabaseMap()->hasTable('archivable_test_4_archive')); } + /** + * @return void + */ public function testCanCreateCustomArchiveTableNameAndPhpName() { - $table = \Map\ArchivableTest5TableMap::getTableMap(); + $table = ArchivableTest5TableMap::getTableMap(); $this->assertTrue($table->getDatabaseMap()->hasTable('archivable_test_5_backup')); - $this->assertSame("ArchivableTest5MyBackup", $table->getDatabaseMap()->getTable('archivable_test_5_backup')->getPhpName()); + $this->assertSame('ArchivableTest5MyBackup', $table->getDatabaseMap()->getTable('archivable_test_5_backup')->getPhpName()); } + /** + * @return void + */ public function testCopiesColumnsToArchiveTable() { - $table = \Map\ArchivableTest1ArchiveTableMap::getTableMap(); + $table = ArchivableTest1ArchiveTableMap::getTableMap(); $this->assertTrue($table->hasColumn('id')); $this->assertContains('id INTEGER NOT NULL,', self::$generatedSQL, 'copied columns are not autoincremented'); $this->assertTrue($table->hasColumn('title')); @@ -143,38 +170,56 @@ public function testCopiesColumnsToArchiveTable() $this->assertTrue($table->hasColumn('foo_id')); } + /** + * @return void + */ public function testDoesNotCopyForeignKeys() { - $table = \Map\ArchivableTest1ArchiveTableMap::getTableMap(); + $table = ArchivableTest1ArchiveTableMap::getTableMap(); $this->assertEquals([], $table->getRelations()); } + /** + * @return void + */ public function testCopiesIndices() { - $table = \Map\ArchivableTest1ArchiveTableMap::getTableMap(); - $expected = "CREATE INDEX archivable_test_1_archive_i_6c947f ON archivable_test_1_archive (title,age);"; + $table = ArchivableTest1ArchiveTableMap::getTableMap(); + $expected = 'CREATE INDEX archivable_test_1_archive_i_6c947f ON archivable_test_1_archive (title,age);'; $this->assertContains($expected, self::$generatedSQL); } + /** + * @return void + */ public function testCopiesUniquesToIndices() { - $table = \Map\ArchivableTest2ArchiveTableMap::getTableMap(); - $expected = "CREATE INDEX my_old_archivable_test_3_i_639136 ON my_old_archivable_test_3 (title);"; + $table = ArchivableTest2ArchiveTableMap::getTableMap(); + $expected = 'CREATE INDEX my_old_archivable_test_3_i_639136 ON my_old_archivable_test_3 (title);'; $this->assertContains($expected, self::$generatedSQL); } + /** + * @return void + */ public function testAddsArchivedAtColumnToArchiveTableByDefault() { - $table = \Map\ArchivableTest1ArchiveTableMap::getTableMap(); + $table = ArchivableTest1ArchiveTableMap::getTableMap(); $this->assertTrue($table->hasColumn('archived_at')); } + /** + * @return void + */ public function testDoesNotAddArchivedAtColumnToArchiveTableIfSpecified() { - $table = \Map\MyOldArchivableTest3TableMap::getTableMap(); + $table = MyOldArchivableTest3TableMap::getTableMap(); $this->assertFalse($table->hasColumn('archived_at')); } + /** + * @return void + */ public function testDatabaseLevelBehavior() { $schema = <<setSchema($schema); $builder->buildClasses(); - foreach ($expectClasses as $expectClass) - { + foreach ($expectClasses as $expectClass) { $this->assertTrue(class_exists($expectClass), sprintf('expect class "%s" is not exists', $expectClass)); } } diff --git a/tests/Propel/Tests/Generator/Behavior/Archivable/FooArchive.php b/tests/Propel/Tests/Generator/Behavior/Archivable/FooArchive.php index 5f348a5163..0ff5bf7d36 100644 --- a/tests/Propel/Tests/Generator/Behavior/Archivable/FooArchive.php +++ b/tests/Propel/Tests/Generator/Behavior/Archivable/FooArchive.php @@ -6,16 +6,25 @@ class FooArchive { public $id, $title, $age; + /** + * @return void + */ public function setId($value) { $this->id = $value; } + /** + * @return void + */ public function setTitle($value) { $this->title = $value; } + /** + * @return void + */ public function setAge($value) { $this->age = $value; diff --git a/tests/Propel/Tests/Generator/Behavior/AutoAddPk/AutoAddPkBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/AutoAddPk/AutoAddPkBehaviorTest.php index 7807cda1f2..b3a3ce53a9 100644 --- a/tests/Propel/Tests/Generator/Behavior/AutoAddPk/AutoAddPkBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/AutoAddPk/AutoAddPkBehaviorTest.php @@ -10,14 +10,12 @@ namespace Propel\Tests\Generator\Behavior\AutoAddPk; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; - -use Propel\Tests\Bookstore\Behavior\Table6; use Propel\Tests\Bookstore\Behavior\Map\Table6TableMap; -use Propel\Tests\Bookstore\Behavior\Table7; use Propel\Tests\Bookstore\Behavior\Map\Table7TableMap; -use Propel\Tests\Bookstore\Behavior\Table8; use Propel\Tests\Bookstore\Behavior\Map\Table8TableMap; +use Propel\Tests\Bookstore\Behavior\Table6; +use Propel\Tests\Bookstore\Behavior\Table8; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Tests for AutoAddPkBehavior class @@ -28,6 +26,9 @@ */ class AutoAddPkBehaviorTest extends BookstoreTestBase { + /** + * @return void + */ public function testDefault() { $table6 = Table6TableMap::getTableMap(); @@ -41,6 +42,9 @@ public function testDefault() $this->assertTrue($table6->isUseIdGenerator(), 'auto_add_pk adds an autoIncrement column by default'); } + /** + * @return void + */ public function testNoTrigger() { $table7 = Table7TableMap::getTableMap(); @@ -51,6 +55,9 @@ public function testNoTrigger() $this->assertEquals($pk->getName(), 'foo', 'auto_add_pk does not change an existing primary key'); } + /** + * @return void + */ public function testParameters() { $table8 = Table8TableMap::getTableMap(); @@ -63,6 +70,9 @@ public function testParameters() $this->assertFalse($table8->isUseIdGenerator(), 'auto_add_pk accepts customization of pk column autoIncrement'); } + /** + * @return void + */ public function testForeignKey() { $t6 = new Table6(); diff --git a/tests/Propel/Tests/Generator/Behavior/BehaviorLocatorTest.php b/tests/Propel/Tests/Generator/Behavior/BehaviorLocatorTest.php index 3fed021eba..bc4262dbd0 100644 --- a/tests/Propel/Tests/Generator/Behavior/BehaviorLocatorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/BehaviorLocatorTest.php @@ -10,9 +10,9 @@ namespace Propel\Tests\Generator\Behavior; -use Propel\Tests\TestCase; -use Propel\Generator\Util\BehaviorLocator; use Propel\Generator\Config\QuickGeneratorConfig; +use Propel\Generator\Util\BehaviorLocator; +use Propel\Tests\TestCase; /** * Tests the table structure behavior hooks. @@ -21,6 +21,9 @@ */ class BehaviorLocatorTest extends TestCase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -28,6 +31,9 @@ protected function setUp(): void require_once(__DIR__ . '/../../../../Fixtures/behavior-development/src/CollectionBehavior.php'); } + /** + * @return void + */ public function testBehaviorLocatorWithComposerLock() { $configOptions['propel']['paths']['composerDir'] = __DIR__ . '/../../../../Fixtures/behavior-installer'; @@ -45,6 +51,9 @@ public function testBehaviorLocatorWithComposerLock() $this->assertSame('\\gossi\\propel\\behavior\\l10n\\L10nBehavior', $locator->getBehavior('l10n')); } + /** + * @return void + */ public function testBehaviorLocatorWithComposerJson() { $configOptions['propel']['paths']['composerDir'] = __DIR__ . '/../../../../Fixtures/behavior-development'; diff --git a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorTest.php index 4c237873af..91e68714b1 100644 --- a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorTest.php @@ -10,26 +10,28 @@ namespace Propel\Tests\Generator\Behavior; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; - +use ConcreteArticleSetPk; +use ConcreteArticleSetPkQuery; +use ConcreteContentSetPk; +use ConcreteContentSetPkQuery; +use Propel\Generator\Util\QuickBuilder; +use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Exception\PropelException; +use Propel\Runtime\Map\RelationMap; use Propel\Tests\Bookstore\Behavior\ConcreteArticle; use Propel\Tests\Bookstore\Behavior\ConcreteArticleQuery; -use Propel\Tests\Bookstore\Behavior\Map\ConcreteArticleTableMap; -use Propel\Tests\Bookstore\Behavior\Map\ConcreteAuthorTableMap; use Propel\Tests\Bookstore\Behavior\ConcreteCategory; use Propel\Tests\Bookstore\Behavior\ConcreteCategoryQuery; use Propel\Tests\Bookstore\Behavior\ConcreteContent; use Propel\Tests\Bookstore\Behavior\ConcreteContentQuery; -use Propel\Tests\Bookstore\Behavior\Map\ConcreteContentTableMap; use Propel\Tests\Bookstore\Behavior\ConcreteQuizz; -use Propel\Tests\Bookstore\Behavior\Map\ConcreteQuizzTableMap; use Propel\Tests\Bookstore\Behavior\ConcreteQuizzQuery; - -use Propel\Runtime\Exception\PropelException; -use Propel\Runtime\Map\RelationMap; -use Propel\Runtime\ActiveQuery\Criteria; - -use Propel\Generator\Util\QuickBuilder; +use Propel\Tests\Bookstore\Behavior\Map\ConcreteArticleTableMap; +use Propel\Tests\Bookstore\Behavior\Map\ConcreteAuthorTableMap; +use Propel\Tests\Bookstore\Behavior\Map\ConcreteContentTableMap; +use Propel\Tests\Bookstore\Behavior\Map\ConcreteQuizzTableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use ReflectionClass; /** * Tests for ConcreteInheritanceBehavior class @@ -40,6 +42,9 @@ */ class ConcreteInheritanceBehaviorTest extends BookstoreTestBase { + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -69,9 +74,12 @@ public function setUp(): void } } + /** + * @return void + */ public function testCopyToChild() { - $article = new \ConcreteArticleSetPk(); + $article = new ConcreteArticleSetPk(); $this->assertTrue(method_exists($article, 'getSyncParent')); $this->assertTrue(method_exists($article, 'syncParentToChild')); $parent = $article->getSyncParent(); @@ -82,6 +90,9 @@ public function testCopyToChild() $this->assertEquals('test title', $article->getTitle()); } + /** + * @return void + */ public function testParentBehavior() { $behaviors = ConcreteContentTableMap::getTableMap()->getBehaviors(); @@ -89,6 +100,9 @@ public function testParentBehavior() $this->assertEquals('descendant_class', $behaviors['concrete_inheritance_parent']['descendant_column'], 'modifyTable() passed the descendant_column parameter to the parent behavior'); } + /** + * @return void + */ public function testModifyTableAddsParentColumn() { $contentColumns = ['id', 'title', 'category_id']; @@ -100,6 +114,9 @@ public function testModifyTableAddsParentColumn() $this->assertEquals(3, count($quizz->getColumns()), 'modifyTable() does not add a column of the parent table if a similar column exists'); } + /** + * @return void + */ public function testModifyTableCopyDataAddsOneToOneRelationships() { $article = ConcreteArticleTableMap::getTableMap(); @@ -111,17 +128,23 @@ public function testModifyTableCopyDataAddsOneToOneRelationships() $this->assertEquals(RelationMap::ONE_TO_ONE, $relation->getType(), 'modifyTable adds a one-to-one relationship'); } + /** + * @return void + */ public function testModifyTableNoCopyDataNoParentRelationship() { $quizz = ConcreteQuizzTableMap::getTableMap(); $this->assertFalse($quizz->hasRelation('ConcreteContent'), 'modifyTable() does not add a relationship to the parent when copy_data is false'); } + /** + * @return void + */ public function testModifyTableCopyDataRemovesAutoIncrement() { $content = new ConcreteContent(); $content->save(); - $c = new Criteria; + $c = new Criteria(); $c->add(ConcreteArticleTableMap::COL_ID, $content->getId()); try { ConcreteArticleTableMap::doInsert($c); @@ -131,22 +154,31 @@ public function testModifyTableCopyDataRemovesAutoIncrement() } } + /** + * @return void + */ public function testModifyTableNoCopyDataKeepsAutoIncrement() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); $content = new ConcreteContent(); $content->save(); - $c = new Criteria; + $c = new Criteria(); $c->add(ConcreteQuizzTableMap::COL_ID, $content->getId()); ConcreteQuizzTableMap::doInsert($c); } + /** + * @return void + */ public function testModifyTableAddsForeignKeys() { $article = ConcreteArticleTableMap::getTableMap(); $this->assertTrue($article->hasRelation('ConcreteCategory'), 'modifyTable() copies relationships from parent table'); } + /** + * @return void + */ public function testModifyTableAddsForeignKeysWithoutDuplicates() { $article = ConcreteAuthorTableMap::getTableMap(); @@ -155,22 +187,31 @@ public function testModifyTableAddsForeignKeysWithoutDuplicates() // no way to test copying of indices and uniques, except by reverse engineering the db... + /** + * @return void + */ public function testParentObjectClass() { - $r = new \ReflectionClass('Propel\Tests\Bookstore\Behavior\Base\ConcreteArticle'); + $r = new ReflectionClass('Propel\Tests\Bookstore\Behavior\Base\ConcreteArticle'); $this->assertEquals('Propel\Tests\Bookstore\Behavior\ConcreteContent', $r->getParentClass()->getName(), 'concrete_inheritance changes the parent class of the Model Object to the parent object class'); - $r = new \ReflectionClass('Propel\Tests\Bookstore\Behavior\Base\ConcreteQuizz'); + $r = new ReflectionClass('Propel\Tests\Bookstore\Behavior\Base\ConcreteQuizz'); $this->assertEquals('Propel\Tests\Bookstore\Behavior\ConcreteContent', $r->getParentClass()->getName(), 'concrete_inheritance changes the parent class of the Model Object to the parent object class'); } + /** + * @return void + */ public function testParentQueryClass() { - $r = new \ReflectionClass('Propel\Tests\Bookstore\Behavior\Base\ConcreteArticleQuery'); + $r = new ReflectionClass('Propel\Tests\Bookstore\Behavior\Base\ConcreteArticleQuery'); $this->assertEquals('Propel\Tests\Bookstore\Behavior\ConcreteContentQuery', $r->getParentClass()->getName(), 'concrete_inheritance changes the parent class of the Query Object to the parent object class'); - $r = new \ReflectionClass('Propel\Tests\Bookstore\Behavior\Base\ConcreteQuizzQuery'); + $r = new ReflectionClass('Propel\Tests\Bookstore\Behavior\Base\ConcreteQuizzQuery'); $this->assertEquals('Propel\Tests\Bookstore\Behavior\ConcreteContentQuery', $r->getParentClass()->getName(), 'concrete_inheritance changes the parent class of the Query Object to the parent object class'); } + /** + * @return void + */ public function testPreSaveCopyData() { ConcreteArticleQuery::create()->deleteAll(); @@ -189,6 +230,9 @@ public function testPreSaveCopyData() $this->assertEquals($category->getId(), $content->getCategoryId()); } + /** + * @return void + */ public function testPreSaveNoCopyData() { ConcreteArticleQuery::create()->deleteAll(); @@ -201,6 +245,9 @@ public function testPreSaveNoCopyData() $this->assertNull($content); } + /** + * @return void + */ public function testGetParentOrCreateNew() { $article = new ConcreteArticle(); @@ -210,6 +257,9 @@ public function testGetParentOrCreateNew() $this->assertEquals('Propel\Tests\Bookstore\Behavior\ConcreteArticle', $content->getDescendantClass(), 'getParentOrCreate() correctly sets the descendant_class of the parent object'); } + /** + * @return void + */ public function testGetParentOrCreateExisting() { $article = new ConcreteArticle(); @@ -221,6 +271,9 @@ public function testGetParentOrCreateExisting() $this->assertEquals($article->getId(), $content->getId(), 'getParentOrCreate() returns the parent object related to the current object'); } + /** + * @return void + */ public function testGetParentOrCreateExistingParent() { ConcreteContentQuery::create()->deleteAll(); @@ -236,6 +289,9 @@ public function testGetParentOrCreateExistingParent() $this->assertEquals(1, ConcreteContentQuery::create()->count(), 'getParentOrCreate() creates no new parent entry'); } + /** + * @return void + */ public function testGetSyncParent() { $category = new ConcreteCategory(); @@ -248,6 +304,9 @@ public function testGetSyncParent() $this->assertEquals($category, $content->getConcreteCategory(), 'getSyncParent() returns a synchronized parent object'); } + /** + * @return void + */ public function testPostDeleteCopyData() { ConcreteArticleQuery::create()->deleteAll(); @@ -264,42 +323,51 @@ public function testPostDeleteCopyData() $this->assertNull(ConcreteContentQuery::create()->findPk($id), 'delete() removes the parent record as well'); } + /** + * @return void + */ public function testGetParentOrCreateNewWithPK() { - \ConcreteContentSetPkQuery::create()->deleteAll(); - \ConcreteArticleSetPkQuery::create()->deleteAll(); - $article = new \ConcreteArticleSetPk(); + ConcreteContentSetPkQuery::create()->deleteAll(); + ConcreteArticleSetPkQuery::create()->deleteAll(); + $article = new ConcreteArticleSetPk(); $article->setId(5); $content = $article->getParentOrCreate(); $this->assertEquals(5, $article->getId(), 'getParentOrCreate() keeps manually set pk'); - $this->assertTrue($content instanceof \ConcreteContentSetPk, 'getParentOrCreate() returns an instance of the parent class'); + $this->assertTrue($content instanceof ConcreteContentSetPk, 'getParentOrCreate() returns an instance of the parent class'); $this->assertTrue($content->isNew(), 'getParentOrCreate() returns a new instance of the parent class if the object is new'); - $this->assertEquals(5,$content->getId(), 'getParentOrCreate() returns a instance of the parent class with pk set'); + $this->assertEquals(5, $content->getId(), 'getParentOrCreate() returns a instance of the parent class with pk set'); $this->assertEquals('ConcreteArticleSetPk', $content->getDescendantClass(), 'getParentOrCreate() correctly sets the descendant_class of the parent object'); } + /** + * @return void + */ public function testSetPKOnNewObject() { - \ConcreteContentSetPkQuery::create()->deleteAll(); - \ConcreteArticleSetPkQuery::create()->deleteAll(); - $article = new \ConcreteArticleSetPk(); + ConcreteContentSetPkQuery::create()->deleteAll(); + ConcreteArticleSetPkQuery::create()->deleteAll(); + $article = new ConcreteArticleSetPk(); $article->setId(2); $article->save(); $this->assertEquals(2, $article->getId(), 'getParentOrCreate() keeps manually set pk after save'); - $this->assertEquals(1, \ConcreteContentSetPkQuery::create()->count(), 'getParentOrCreate() creates a parent entry'); - $articledb = \ConcreteArticleSetPkQuery::create()->findOneById(2); + $this->assertEquals(1, ConcreteContentSetPkQuery::create()->count(), 'getParentOrCreate() creates a parent entry'); + $articledb = ConcreteArticleSetPkQuery::create()->findOneById(2); $this->assertEquals(2, $articledb->getId(), 'getParentOrCreate() keeps manually set pk after save and reload from db'); } + /** + * @return void + */ public function testSetPKOnNewObjectWithPkAlreadyInParentTable() { - \ConcreteContentSetPkQuery::create()->deleteAll(); - \ConcreteArticleSetPkQuery::create()->deleteAll(); + ConcreteContentSetPkQuery::create()->deleteAll(); + ConcreteArticleSetPkQuery::create()->deleteAll(); try { - $article = new \ConcreteArticleSetPk(); + $article = new ConcreteArticleSetPk(); $article->setId(4); $article->save(); - $article = new \ConcreteArticleSetPk(); + $article = new ConcreteArticleSetPk(); $article->setId(4); $article->save(); $this->fail('getParentOrCreate() returns a new parent object on new child objects with pk set'); @@ -308,6 +376,9 @@ public function testSetPKOnNewObjectWithPkAlreadyInParentTable() } } + /** + * @return void + */ public function testSetPkAllowPkInsertIsFalse() { ConcreteContentQuery::create()->deleteAll(); @@ -321,5 +392,4 @@ public function testSetPkAllowPkInsertIsFalse() $this->assertTrue(true, 'SetPk fails when allowPkInsert is false'); } } - } diff --git a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithBehaviorExclusionTest.php b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithBehaviorExclusionTest.php index 733930b490..f3f8f1a85b 100644 --- a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithBehaviorExclusionTest.php +++ b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithBehaviorExclusionTest.php @@ -11,7 +11,6 @@ namespace Propel\Tests\Generator\Behavior; use ConcreteInheritanceBehaviorWithBehaviorExclusionTest\Map\ConcreteInheritanceChildTableMap; - use Propel\Generator\Util\QuickBuilder; use Propel\Tests\TestCase; @@ -22,6 +21,9 @@ */ class ConcreteInheritanceBehaviorWithBehaviorExclusionTest extends TestCase { + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -56,11 +58,13 @@ public function setUp(): void } } + /** + * @return void + */ public function testParentBehaviorExclusion() { $behaviors = ConcreteInheritanceChildTableMap::getTableMap()->getBehaviors(); $this->assertFalse(array_key_exists('sluggable', $behaviors), ''); $this->assertTrue(array_key_exists('timestampable', $behaviors), ''); } - } diff --git a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithSchemaTest.php b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithSchemaTest.php index e2bdab2072..1c69f6bec2 100644 --- a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithSchemaTest.php +++ b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithSchemaTest.php @@ -12,8 +12,8 @@ namespace Propel\Tests\Generator\Behavior; use Propel\Tests\BookstoreSchemas\Book; -use Propel\Tests\BookstoreSchemas\SecondHandBook; use Propel\Tests\BookstoreSchemas\Map\BookTableMap; +use Propel\Tests\BookstoreSchemas\SecondHandBook; use Propel\Tests\TestCaseFixturesDatabase; /** @@ -25,6 +25,9 @@ */ class ConcreteInheritanceBehaviorWithSchemaTest extends TestCaseFixturesDatabase { + /** + * @return void + */ public function testParentBehaviorWithSchemas() { $behaviors = BookTableMap::getTableMap()->getBehaviors(); @@ -32,6 +35,9 @@ public function testParentBehaviorWithSchemas() $this->assertEquals('descendant_class', $behaviors['concrete_inheritance_parent']['descendant_column'], 'modifyTable() passed the descendant_column parameter to the parent behavior'); } + /** + * @return void + */ public function testGetParentOrCreateNewWithSchemas() { $second_hand_book = new SecondHandBook(); @@ -40,5 +46,4 @@ public function testGetParentOrCreateNewWithSchemas() $this->assertTrue($book->isNew(), 'getParentOrCreate() returns a new instance of the parent class if the object is new'); $this->assertEquals('Propel\Tests\BookstoreSchemas\SecondHandBook', $book->getDescendantClass(), 'getParentOrCreate() correctly sets the descendant_class of the parent object'); } - } diff --git a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehaviorTest.php index bb7b7eacc3..178a5638eb 100644 --- a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceParentBehaviorTest.php @@ -11,13 +11,12 @@ namespace Propel\Tests\Generator\Behavior\ConcreteInheritance; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; - use Propel\Tests\Bookstore\Behavior\ConcreteArticle; use Propel\Tests\Bookstore\Behavior\ConcreteArticleQuery; use Propel\Tests\Bookstore\Behavior\ConcreteContent; use Propel\Tests\Bookstore\Behavior\ConcreteContentQuery; use Propel\Tests\Bookstore\Behavior\ConcreteQuizzQuery; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Tests for ConcreteInheritanceParentBehavior class @@ -28,6 +27,9 @@ */ class ConcreteInheritanceParentBehaviorTest extends BookstoreTestBase { + /** + * @return void + */ public function testHasChildObject() { ConcreteArticleQuery::create()->deleteAll(); @@ -43,6 +45,9 @@ public function testHasChildObject() $this->assertTrue($content->hasChildObject()); } + /** + * @return void + */ public function testGetChildObject() { ConcreteArticleQuery::create()->deleteAll(); @@ -58,5 +63,4 @@ public function testGetChildObject() $content = $article->getConcreteContent(); $this->assertEquals($article, $content->getChildObject()); } - } diff --git a/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php index f31fda22e5..f769a4e376 100644 --- a/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php @@ -10,11 +10,15 @@ namespace Propel\Tests\Generator\Behavior\Delegate; -use Propel\Generator\Behavior\Delegate\DelegateBehavior; +use DelegateBasketballer; +use DelegateDelegate; +use DelegateFootballer; +use DelegateMain; +use Map\DelegateDelegateTableMap; use Propel\Generator\Util\QuickBuilder; - -use Propel\Runtime\Propel; use Propel\Tests\TestCase; +use SecondDelegateDelegate; +use TestTablePrefixSameDatabaseMain; /** * Tests for DelegateBehavior class @@ -23,7 +27,9 @@ */ class DelegateBehaviorTest extends TestCase { - + /** + * @return void + */ public function setUp(): void { if (!class_exists('DelegateDelegate')) { @@ -105,18 +111,24 @@ public function setUp(): void } } + /** + * @return void + */ public function testModifyTableRelatesOneToOneDelegate() { - $delegateTable = \Map\DelegateDelegateTableMap::getTableMap(); + $delegateTable = DelegateDelegateTableMap::getTableMap(); $this->assertEquals(2, count($delegateTable->getColumns())); $this->assertEquals(1, count($delegateTable->getRelations())); $this->assertTrue(method_exists('DelegateMain', 'getDelegateDelegate')); $this->assertTrue(method_exists('DelegateDelegate', 'getDelegateMain')); } + /** + * @return void + */ public function testOneToOneDelegationCreatesANewDelegateIfNoneExists() { - $main = new \DelegateMain(); + $main = new DelegateMain(); $main->setSubtitle('foo'); $delegate = $main->getDelegateDelegate(); $this->assertInstanceOf('DelegateDelegate', $delegate); @@ -125,9 +137,12 @@ public function testOneToOneDelegationCreatesANewDelegateIfNoneExists() $this->assertEquals('foo', $main->getSubtitle()); } + /** + * @return void + */ public function testManyToOneDelegationCreatesANewDelegateIfNoneExists() { - $main = new \DelegateMain(); + $main = new DelegateMain(); $main->setSummary('foo'); $delegate = $main->getSecondDelegateDelegate(); $this->assertInstanceOf('SecondDelegateDelegate', $delegate); @@ -136,27 +151,36 @@ public function testManyToOneDelegationCreatesANewDelegateIfNoneExists() $this->assertEquals('foo', $main->getSummary()); } + /** + * @return void + */ public function testOneToOneDelegationUsesExistingDelegateIfExists() { - $main = new \DelegateMain(); - $delegate = new \DelegateDelegate(); + $main = new DelegateMain(); + $delegate = new DelegateDelegate(); $delegate->setSubtitle('bar'); $main->setDelegateDelegate($delegate); $this->assertEquals('bar', $main->getSubtitle()); } + /** + * @return void + */ public function testManyToOneDelegationUsesExistingDelegateIfExists() { - $main = new \DelegateMain(); - $delegate = new \SecondDelegateDelegate(); + $main = new DelegateMain(); + $delegate = new SecondDelegateDelegate(); $delegate->setSummary('bar'); $main->setSecondDelegateDelegate($delegate); $this->assertEquals('bar', $main->getSummary()); } + /** + * @return void + */ public function testAModelCanHaveSeveralDelegates() { - $main = new \DelegateMain(); + $main = new DelegateMain(); $main->setSubtitle('foo'); $main->setSummary('bar'); $delegate = $main->getDelegateDelegate(); @@ -173,17 +197,22 @@ public function testAModelCanHaveSeveralDelegates() /** * @expectedException \Propel\Runtime\Exception\BadMethodCallException + * + * @return void */ public function testAModelCannotHaveCascadingDelegates() { - $main = new \DelegateMain(); + $main = new DelegateMain(); $main->setSummary('bar'); $main->setBody('baz'); } + /** + * @return void + */ public function testOneToOneDelegatesCanBePersisted() { - $main = new \DelegateMain(); + $main = new DelegateMain(); $main->setSubtitle('foo'); $main->save(); $this->assertFalse($main->isNew()); @@ -191,9 +220,12 @@ public function testOneToOneDelegatesCanBePersisted() $this->assertNull($main->getSecondDelegateDelegate()); } + /** + * @return void + */ public function testManyToOneDelegatesCanBePersisted() { - $main = new \DelegateMain(); + $main = new DelegateMain(); $main->setSummary('foo'); $main->save(); $this->assertFalse($main->isNew()); @@ -201,9 +233,12 @@ public function testManyToOneDelegatesCanBePersisted() $this->assertNull($main->getDelegateDelegate()); } + /** + * @return void + */ public function testDelegateSimulatesClassTableInheritance() { - $basketballer = new \DelegateBasketballer(); + $basketballer = new DelegateBasketballer(); $basketballer->setPoints(101); $basketballer->setFieldGoals(47); $this->assertNull($basketballer->getDelegatePlayer()); @@ -215,9 +250,12 @@ public function testDelegateSimulatesClassTableInheritance() $basketballer->save(); // should not throw exception } + /** + * @return void + */ public function testDelegateSimulatesMultipleClassTableInheritance() { - $footballer = new \DelegateFootballer(); + $footballer = new DelegateFootballer(); $footballer->setGoalsScored(43); $footballer->setFoulsCommitted(4); $this->assertNull($footballer->getDelegatePlayer()); @@ -234,6 +272,9 @@ public function testDelegateSimulatesMultipleClassTableInheritance() $footballer->save(); // should not throw exception } + /** + * @return void + */ public function testTablePrefixSameDatabase() { $schema = << EOF; QuickBuilder::buildSchema($schema); - $main = new \TestTablePrefixSameDatabaseMain(); + $main = new TestTablePrefixSameDatabaseMain(); $main->setSubtitle('bar'); $delegate = $main->getTestTablePrefixSameDatabaseDelegate(); $this->assertInstanceOf('TestTablePrefixSameDatabaseDelegate', $delegate); @@ -267,5 +308,4 @@ public function testTablePrefixSameDatabase() $this->assertEquals('bar', $delegate->getSubtitle()); $this->assertEquals('bar', $main->getSubtitle()); } - } diff --git a/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifierTest.php index 944ea5f8b5..52d5fb00f4 100644 --- a/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifierTest.php @@ -10,10 +10,14 @@ namespace Propel\Tests\Generator\Behavior\I18n; +use I18nBehaviorTest11; +use I18nBehaviorTest11I18nQuery; +use I18nBehaviorTest11Query; +use Map\I18nBehaviorTest11I18nTableMap; +use Map\I18nBehaviorTest11TableMap; use Propel\Generator\Util\QuickBuilder; -use Propel\Generator\Behavior\I18n\I18nBehavior; -use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Propel; use Propel\Tests\TestCase; /** @@ -24,7 +28,9 @@ */ class I18nBehaviorQueryBuilderModifierTest extends TestCase { - + /** + * @return void + */ public function setUp(): void { if (!class_exists('\I18nBehaviorTest11')) { @@ -57,9 +63,12 @@ public function setUp(): void } } + /** + * @return void + */ public function testJoinI18nUsesDefaultLocaleInJoinCondition() { - $q = \I18nBehaviorTest11Query::create(); + $q = I18nBehaviorTest11Query::create(); $q->joinI18n(); $params = []; @@ -69,9 +78,12 @@ public function testJoinI18nUsesDefaultLocaleInJoinCondition() $this->assertEquals('en_US', $params[0]['value']); } + /** + * @return void + */ public function testJoinI18nUsesLocaleInJoinCondition() { - $q = \I18nBehaviorTest11Query::create() + $q = I18nBehaviorTest11Query::create() ->joinI18n('fr_FR'); $params = []; $sql = $q->createSelectSQL($params); @@ -80,9 +92,12 @@ public function testJoinI18nUsesLocaleInJoinCondition() $this->assertEquals('fr_FR', $params[0]['value']); } + /** + * @return void + */ public function testJoinI18nAcceptsARelationAlias() { - $q = \I18nBehaviorTest11Query::create() + $q = I18nBehaviorTest11Query::create() ->joinI18n('en_US', 'I18n'); $params = []; $sql = $q->createSelectSQL($params); @@ -91,9 +106,12 @@ public function testJoinI18nAcceptsARelationAlias() $this->assertEquals('en_US', $params[0]['value']); } + /** + * @return void + */ public function testJoinI18nAcceptsAJoinType() { - $q = \I18nBehaviorTest11Query::create() + $q = I18nBehaviorTest11Query::create() ->joinI18n('en_US', null, Criteria::INNER_JOIN); $params = []; $sql = $q->createSelectSQL($params); @@ -102,11 +120,14 @@ public function testJoinI18nAcceptsAJoinType() $this->assertEquals('en_US', $params[0]['value']); } + /** + * @return void + */ public function testJoinI18nCreatesACorrectQuery() { - $con = Propel::getServiceContainer()->getConnection(\Map\I18nBehaviorTest11TableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getConnection(I18nBehaviorTest11TableMap::DATABASE_NAME); $con->useDebug(true); - \I18nBehaviorTest11Query::create() + I18nBehaviorTest11Query::create() ->joinI18n('fr_FR') ->find($con); $expected = $this->getSql("SELECT `i18n_behavior_test_11`.`id`, `i18n_behavior_test_11`.`foo` FROM `i18n_behavior_test_11` LEFT JOIN `i18n_behavior_test_11_i18n` ON (`i18n_behavior_test_11`.`id`=`i18n_behavior_test_11_i18n`.`id` AND `i18n_behavior_test_11_i18n`.`locale` = 'fr_FR')"); @@ -114,9 +135,12 @@ public function testJoinI18nCreatesACorrectQuery() $con->useDebug(false); } + /** + * @return void + */ public function testUseI18nQueryAddsTheProperJoin() { - $q = \I18nBehaviorTest11Query::create() + $q = I18nBehaviorTest11Query::create() ->useI18nQuery('fr_FR') ->filterByBar('bar') ->endUse(); @@ -128,9 +152,12 @@ public function testUseI18nQueryAddsTheProperJoin() $this->assertEquals('bar', $params[1]['value']); } + /** + * @return void + */ public function testUseI18nQueryAcceptsARelationAlias() { - $q = \I18nBehaviorTest11Query::create() + $q = I18nBehaviorTest11Query::create() ->useI18nQuery('fr_FR', 'I18n') ->filterByBar('bar') ->endUse(); @@ -142,11 +169,14 @@ public function testUseI18nQueryAcceptsARelationAlias() $this->assertEquals('bar', $params[1]['value']); } + /** + * @return void + */ public function testUseI18nQueryCreatesACorrectQuery() { - $con = Propel::getServiceContainer()->getConnection(\Map\I18nBehaviorTest11TableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getConnection(I18nBehaviorTest11TableMap::DATABASE_NAME); $con->useDebug(true); - \I18nBehaviorTest11Query::create() + I18nBehaviorTest11Query::create() ->useI18nQuery('fr_FR') ->filterByBar('bar') ->endUse() @@ -156,9 +186,12 @@ public function testUseI18nQueryCreatesACorrectQuery() $con->useDebug(false); } + /** + * @return void + */ public function testJoinWithI18nAddsTheI18nColumns() { - $q = \I18nBehaviorTest11Query::create() + $q = I18nBehaviorTest11Query::create() ->joinWithI18n(); $params = []; $sql = $q->createSelectSQL($params); @@ -167,48 +200,57 @@ public function testJoinWithI18nAddsTheI18nColumns() $this->assertEquals('en_US', $params[0]['value']); } + /** + * @return void + */ public function testJoinWithI18nDoesNotPruneResultsWithoutTranslation() { - \I18nBehaviorTest11Query::create()->deleteAll(); - \I18nBehaviorTest11I18nQuery::create()->deleteAll(); - $o = new \I18nBehaviorTest11(); + I18nBehaviorTest11Query::create()->deleteAll(); + I18nBehaviorTest11I18nQuery::create()->deleteAll(); + $o = new I18nBehaviorTest11(); $o->setFoo(123); $o->save(); - $res = \I18nBehaviorTest11Query::create() + $res = I18nBehaviorTest11Query::create() ->joinWithI18n('en_US') ->findOne(); $this->assertEquals($o, $res); } + /** + * @return void + */ public function testJoinWithI18nPrunesResultsWithoutTranslationWhenUsingInnerJoin() { - \I18nBehaviorTest11Query::create()->deleteAll(); - \I18nBehaviorTest11I18nQuery::create()->deleteAll(); - $o = new \I18nBehaviorTest11(); + I18nBehaviorTest11Query::create()->deleteAll(); + I18nBehaviorTest11I18nQuery::create()->deleteAll(); + $o = new I18nBehaviorTest11(); $o->setFoo(123); $o->save(); - $res = \I18nBehaviorTest11Query::create() + $res = I18nBehaviorTest11Query::create() ->joinWithI18n('en_US', Criteria::INNER_JOIN) ->findOne(); $this->assertNull($res); } + /** + * @return void + */ public function testJoinWithI18nHydratesRelatedObject() { - $con = Propel::getServiceContainer()->getConnection(\Map\I18nBehaviorTest11TableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getConnection(I18nBehaviorTest11TableMap::DATABASE_NAME); $con->useDebug(true); - \I18nBehaviorTest11Query::create()->deleteAll(); - \I18nBehaviorTest11I18nQuery::create()->deleteAll(); - $o = new \I18nBehaviorTest11(); + I18nBehaviorTest11Query::create()->deleteAll(); + I18nBehaviorTest11I18nQuery::create()->deleteAll(); + $o = new I18nBehaviorTest11(); $o->setFoo(123); $o->setLocale('en_US'); $o->setBar('hello'); $o->setLocale('fr_FR'); $o->setBar('bonjour'); $o->save(); - \Map\I18nBehaviorTest11TableMap::clearInstancePool(); - \Map\I18nBehaviorTest11I18nTableMap::clearInstancePool(); - $o = \I18nBehaviorTest11Query::create() + I18nBehaviorTest11TableMap::clearInstancePool(); + I18nBehaviorTest11I18nTableMap::clearInstancePool(); + $o = I18nBehaviorTest11Query::create() ->joinWithI18n('en_US') ->findOne($con); $count = $con->getQueryCount(); @@ -217,30 +259,36 @@ public function testJoinWithI18nHydratesRelatedObject() $this->assertEquals('hello', $translation->getBar()); } + /** + * @return void + */ public function testJoinWithI18nSetsTheLocaleOnResults() { - \I18nBehaviorTest11Query::create()->deleteAll(); - \I18nBehaviorTest11I18nQuery::create()->deleteAll(); - $o = new \I18nBehaviorTest11(); + I18nBehaviorTest11Query::create()->deleteAll(); + I18nBehaviorTest11I18nQuery::create()->deleteAll(); + $o = new I18nBehaviorTest11(); $o->setFoo(123); $o->setLocale('en_US'); $o->setBar('hello'); $o->setLocale('fr_FR'); $o->setBar('bonjour'); $o->save(); - $o1 = \I18nBehaviorTest11Query::create() + $o1 = I18nBehaviorTest11Query::create() ->joinWithI18n('en_US') ->findOne(); $this->assertEquals('en_US', $o1->getLocale()); - $o2 = \I18nBehaviorTest11Query::create() + $o2 = I18nBehaviorTest11Query::create() ->joinWithI18n('fr_FR') ->findOne(); $this->assertEquals('fr_FR', $o2->getLocale()); } + /** + * @return void + */ public function testJoinWithI18nAndLimitDoesNotThrowException() { - $res = \I18nBehaviorTest11Query::create() + $res = I18nBehaviorTest11Query::create() ->joinWithI18n('en_US') ->limit(2) ->find(); @@ -256,22 +304,24 @@ public function testJoinWithI18nAndLimitDoesNotThrowException() // $o->setTranslation($t2, 'en_US'); // this is what happens during joined hydration // now the translation collection exists // $t2 = $o->getTranslation('fr_FR'); // we MUST issue a query here + /** + * @return void + */ public function testJoinWithI18nDoesNotExecuteAdditionalQueryWhenNoTranslationIsFound() { $this->markTestSkipped(); - $con = Propel::getServiceContainer()->getConnection(\Map\I18nBehaviorTest11TableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getConnection(I18nBehaviorTest11TableMap::DATABASE_NAME); $con->useDebug(true); - \I18nBehaviorTest11Query::create()->deleteAll(); - \I18nBehaviorTest11I18nQuery::create()->deleteAll(); - $o = new \I18nBehaviorTest11(); + I18nBehaviorTest11Query::create()->deleteAll(); + I18nBehaviorTest11I18nQuery::create()->deleteAll(); + $o = new I18nBehaviorTest11(); $o->save(); - $o = \I18nBehaviorTest11Query::create() + $o = I18nBehaviorTest11Query::create() ->joinWithI18n('en_US') ->findOne($con); $count = $con->getQueryCount(); $translation = $o->getTranslation('en_US', $con); $this->assertEquals($count, $con->getQueryCount()); } - } diff --git a/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorTest.php index e97f843242..7dbc3d7f00 100644 --- a/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorTest.php @@ -11,9 +11,6 @@ namespace Propel\Tests\Generator\Behavior\I18n; use Propel\Generator\Util\QuickBuilder; -use Propel\Generator\Behavior\I18n\I18nBehavior; - -use Propel\Runtime\Propel; use Propel\Tests\TestCase; /** @@ -23,6 +20,9 @@ */ class I18nBehaviorTest extends TestCase { + /** + * @return void + */ public function testModifyDatabaseOverridesDefaultLocale() { $schema = <<assertContains($expected, $builder->getSQL()); } + /** + * @return void + */ public function testModifyDatabaseDoesNotOverrideTableLocale() { $schema = <<assertContains($expected, $builder->getSQL()); } + /** + * @return void + */ public function testSkipSqlParameterOnParentTable() { $schema = <<assertContains($expected, $builder->getSQL()); } + /** + * @return void + */ public function testModiFyTableUsesCustomI18nTableName() { $schema = <<assertContains($expected, $builder->getSQL()); } + /** + * @return void + */ public function testModiFyTableUsesCustomLocaleColumnName() { $schema = <<assertContains($expected, $builder->getSQL()); } + /** + * @return void + */ public function testModiFyTableUsesCustomLocaleDefault() { $schema = <<assertContains($expected, $builder->getSQL()); } + /** + * @return void + */ public function testModiFyTableUsesCustomI18nLocaleLength() { $schema = <<assertContains($expected, $builder->getSQL()); } - } diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/Fixtures/PublicTable10.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/Fixtures/PublicTable10.php index 70f9087dc0..5fdc6d1b5d 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/Fixtures/PublicTable10.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/Fixtures/PublicTable10.php @@ -2,8 +2,11 @@ namespace Propel\Tests\Generator\Behavior\NestedSet\Fixtures; -class PublicTable10 extends \NestedSetTable10 +use NestedSetTable10; + +class PublicTable10 extends NestedSetTable10 { - public $hasParentNode = null; - public $parentNode = null; + public $hasParentNode; + + public $parentNode; } diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/Fixtures/PublicTable9.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/Fixtures/PublicTable9.php index 8ca3dfc02f..04bd08145e 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/Fixtures/PublicTable9.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/Fixtures/PublicTable9.php @@ -2,12 +2,19 @@ namespace Propel\Tests\Generator\Behavior\NestedSet\Fixtures; -class PublicTable9 extends \NestedSetTable9 +use NestedSetTable9; + +class PublicTable9 extends NestedSetTable9 { - public $hasParentNode = null; - public $parentNode = null; - public $hasPrevSibling = null; - public $prevSibling = null; - public $hasNextSibling = null; - public $nextSibling = null; + public $hasParentNode; + + public $parentNode; + + public $hasPrevSibling; + + public $prevSibling; + + public $hasNextSibling; + + public $nextSibling; } diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php index 5df4e11434..720b983226 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php @@ -10,20 +10,29 @@ namespace Propel\Tests\Generator\Behavior\NestedSet; -use Propel\Runtime\Propel; -use Propel\Runtime\Collection\ObjectCollection; -use Propel\Runtime\Exception\PropelException; +use Exception; +use Fixtures\PublicTable9; +use Map\NestedSetTable9TableMap; +use NestedSetTable10; +use NestedSetTable9; +use NestedSetTable9Query; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveRecord\NestedSetRecursiveIterator; +use Propel\Runtime\Collection\ObjectCollection; +use Propel\Runtime\Exception\PropelException; +use Propel\Runtime\Propel; /** * Tests for NestedSetBehaviorObjectBuilderModifier class */ class NestedSetBehaviorObjectBuilderModifierTest extends TestCase { + /** + * @return void + */ public function testDefault() { - $t = new \NestedSetTable9(); + $t = new NestedSetTable9(); $t->setTreeLeft('123'); $this->assertEquals($t->getLeftValue(), '123', 'nested_set adds a getLeftValue() method'); $t->setTreeRight('456'); @@ -32,9 +41,12 @@ public function testDefault() $this->assertEquals($t->getLevel(), '789', 'nested_set adds a getLevel() method'); } + /** + * @return void + */ public function testParameters() { - $t = new \NestedSetTable10(); + $t = new NestedSetTable10(); $t->setMyLeftColumn('123'); $this->assertEquals($t->getLeftValue(), '123', 'nested_set adds a getLeftValue() method'); $t->setMyRightColumn('456'); @@ -45,6 +57,9 @@ public function testParameters() $this->assertEquals($t->getScopeValue(), '012', 'nested_set adds a getScopeValue() method'); } + /** + * @return void + */ public function testObjectAttributes() { $expectedAttributes = ['nestedSetQueries']; @@ -53,10 +68,13 @@ public function testObjectAttributes() } } + /** + * @return void + */ public function testSaveOutOfTree() { - \Map\NestedSetTable9TableMap::doDeleteAll(); - $t1 = new \NestedSetTable9(); + NestedSetTable9TableMap::doDeleteAll(); + $t1 = new NestedSetTable9(); $t1->setTitle('t1'); try { $t1->save(); @@ -71,7 +89,7 @@ public function testSaveOutOfTree() $this->fail('A saved node can be turned into root'); } $t1->save(); - $t2 = new \NestedSetTable9(); + $t2 = new NestedSetTable9(); $t2->setTitle('t1'); $t2->save(); try { @@ -90,33 +108,41 @@ public function testSaveOutOfTree() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testSaveRootInTreeWithExistingRoot() { - \Map\NestedSetTable9TableMap::doDeleteAll(); - $t1 = new \NestedSetTable9(); + NestedSetTable9TableMap::doDeleteAll(); + $t1 = new NestedSetTable9(); $t1->makeRoot(); $t1->save(); - $t2 = new \NestedSetTable9(); + $t2 = new NestedSetTable9(); $t2->makeRoot(); $t2->save(); } + /** + * @return void + */ public function testPreUpdate() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); $t3->setLeftValue(null); try { $t3->save(); $this->fail('Trying to save a node incorrectly updated throws an exception'); - } catch (\Exception $e) { + } catch (Exception $e) { $this->assertTrue(true, 'Trying to save a node incorrectly updated throws an exception'); } } + /** + * @return void + */ public function testDelete() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -135,32 +161,38 @@ public function testDelete() 't4' => [5, 6, 2], ]; $this->assertEquals($expected, $this->dumpTree(), 'delete() deletes all descendants and shifts the entire subtree correctly'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); try { $t1->delete(); $this->fail('delete() throws an exception when called on a root node'); } catch (PropelException $e) { $this->assertTrue(true, 'delete() throws an exception when called on a root node'); } - $this->assertNotEquals([], \NestedSetTable9Query::create()->find(), 'delete() called on the root node does not delete the whole tree'); + $this->assertNotEquals([], NestedSetTable9Query::create()->find(), 'delete() called on the root node does not delete the whole tree'); } + /** + * @return void + */ public function testDeleteNotInTree() { - $t1 = new \NestedSetTable9(); + $t1 = new NestedSetTable9(); $t1->save(); $t1->delete(); $this->assertTrue($t1->isDeleted()); } + /** + * @return void + */ public function testMakeRoot() { - $t = new \NestedSetTable9(); + $t = new NestedSetTable9(); $t->makeRoot(); $this->assertEquals($t->getLeftValue(), 1, 'makeRoot() initializes left_column to 1'); $this->assertEquals($t->getRightValue(), 2, 'makeRoot() initializes right_column to 2'); $this->assertEquals($t->getLevel(), 0, 'makeRoot() initializes right_column to 0'); - $t = new \NestedSetTable9(); + $t = new NestedSetTable9(); $t->setLeftValue(12); try { $t->makeRoot(); @@ -170,9 +202,12 @@ public function testMakeRoot() } } + /** + * @return void + */ public function testIsInTree() { - $t1 = new \NestedSetTable9(); + $t1 = new NestedSetTable9(); $this->assertFalse($t1->isInTree(), 'inInTree() returns false for nodes with no left and right value'); $t1->save(); $this->assertFalse($t1->isInTree(), 'inInTree() returns false for saved nodes with no left and right value'); @@ -188,9 +223,12 @@ public function testIsInTree() $this->assertFalse($t1->isInTree(), 'inInTree() returns false for nodes with left > right value'); } + /** + * @return void + */ public function testIsRoot() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -205,9 +243,12 @@ public function testIsRoot() $this->assertFalse($t3->isRoot(), 'node is not seen as root'); } + /** + * @return void + */ public function testIsLeaf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -222,9 +263,12 @@ public function testIsLeaf() $this->assertFalse($t3->isLeaf(), 'node is not seen as leaf'); } + /** + * @return void + */ public function testIsDescendantOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -242,9 +286,12 @@ public function testIsDescendantOf() $this->assertFalse($t3->isDescendantOf($t5), 'node is not seen as a descendant of its parent'); } + /** + * @return void + */ public function testIsAncestorOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -262,15 +309,18 @@ public function testIsAncestorOf() $this->assertFalse($t5->isAncestorOf($t3), 'child is not seen as an ancestor of its parent'); } + /** + * @return void + */ public function testHasParent() { - \Map\NestedSetTable9TableMap::doDeleteAll(); - $t0 = new \NestedSetTable9(); - $t1 = new \NestedSetTable9(); + NestedSetTable9TableMap::doDeleteAll(); + $t0 = new NestedSetTable9(); + $t1 = new NestedSetTable9(); $t1->setTitle('t1')->setLeftValue(1)->setRightValue(6)->setLevel(0)->save(); - $t2 = new \NestedSetTable9(); + $t2 = new NestedSetTable9(); $t2->setTitle('t2')->setLeftValue(2)->setRightValue(5)->setLevel(1)->save(); - $t3 = new \NestedSetTable9(); + $t3 = new NestedSetTable9(); $t3->setTitle('t3')->setLeftValue(3)->setRightValue(4)->setLevel(2)->save(); $this->assertFalse($t0->hasParent(), 'empty node has no parent'); $this->assertFalse($t1->hasParent(), 'root node has no parent'); @@ -278,18 +328,21 @@ public function testHasParent() $this->assertTrue($t3->hasParent(), 'leaf node has a parent'); } + /** + * @return void + */ public function testGetParent() { - \Map\NestedSetTable9TableMap::doDeleteAll(); - $t0 = new \NestedSetTable9(); + NestedSetTable9TableMap::doDeleteAll(); + $t0 = new NestedSetTable9(); $this->assertFalse($t0->hasParent(), 'empty node has no parent'); - $t1 = new \NestedSetTable9(); + $t1 = new NestedSetTable9(); $t1->setTitle('t1')->setLeftValue(1)->setRightValue(8)->setLevel(0)->save(); - $t2 = new \NestedSetTable9(); + $t2 = new NestedSetTable9(); $t2->setTitle('t2')->setLeftValue(2)->setRightValue(7)->setLevel(1)->save(); - $t3 = new \NestedSetTable9(); + $t3 = new NestedSetTable9(); $t3->setTitle('t3')->setLeftValue(3)->setRightValue(4)->setLevel(2)->save(); - $t4 = new \NestedSetTable9(); + $t4 = new NestedSetTable9(); $t4->setTitle('t4')->setLeftValue(5)->setRightValue(6)->setLevel(2)->save(); $this->assertNull($t1->getParent($this->con), 'getParent() return null for root nodes'); $this->assertEquals($t2->getParent($this->con), $t1, 'getParent() correctly retrieves parent for nodes'); @@ -297,9 +350,12 @@ public function testGetParent() $this->assertEquals($t4->getParent($this->con), $t2, 'getParent() retrieves the same parent for two siblings'); } + /** + * @return void + */ public function testGetParentCache() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -309,10 +365,10 @@ public function testGetParentCache() | \ t6 t7 */ - $con = Propel::getServiceContainer()->getReadConnection(\Map\NestedSetTable9TableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(NestedSetTable9TableMap::DATABASE_NAME); $con->useDebug(); - $count = $con->getQueryCount(); + $count = $con->getQueryCount(); $parent = $t5->getParent($con); $parent = $t5->getParent($con); @@ -320,15 +376,18 @@ public function testGetParentCache() $this->assertEquals('t3', $parent->getTitle(), 'getParent() returns the parent Node'); } + /** + * @return void + */ public function testHasPrevSibling() { - \Map\NestedSetTable9TableMap::doDeleteAll(); - $t0 = new \NestedSetTable9(); - $t1 = new \NestedSetTable9(); + NestedSetTable9TableMap::doDeleteAll(); + $t0 = new NestedSetTable9(); + $t1 = new NestedSetTable9(); $t1->setTitle('t1')->setLeftValue(1)->setRightValue(6)->save(); - $t2 = new \NestedSetTable9(); + $t2 = new NestedSetTable9(); $t2->setTitle('t2')->setLeftValue(2)->setRightValue(3)->save(); - $t3 = new \NestedSetTable9(); + $t3 = new NestedSetTable9(); $t3->setTitle('t3')->setLeftValue(4)->setRightValue(5)->save(); $this->assertFalse($t0->hasPrevSibling(), 'empty node has no previous sibling'); $this->assertFalse($t1->hasPrevSibling(), 'root node has no previous sibling'); @@ -336,9 +395,12 @@ public function testHasPrevSibling() $this->assertTrue($t3->hasPrevSibling(), 'not first sibling has a previous sibling'); } + /** + * @return void + */ public function testGetPrevSibling() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -355,15 +417,18 @@ public function testGetPrevSibling() $this->assertEquals($t7->getPrevSibling($this->con), $t6, 'getPrevSibling() correctly retrieves prev sibling'); } + /** + * @return void + */ public function testHasNextSibling() { - \Map\NestedSetTable9TableMap::doDeleteAll(); - $t0 = new \NestedSetTable9(); - $t1 = new \NestedSetTable9(); + NestedSetTable9TableMap::doDeleteAll(); + $t0 = new NestedSetTable9(); + $t1 = new NestedSetTable9(); $t1->setTitle('t1')->setLeftValue(1)->setRightValue(6)->save(); - $t2 = new \NestedSetTable9(); + $t2 = new NestedSetTable9(); $t2->setTitle('t2')->setLeftValue(2)->setRightValue(3)->save(); - $t3 = new \NestedSetTable9(); + $t3 = new NestedSetTable9(); $t3->setTitle('t3')->setLeftValue(4)->setRightValue(5)->save(); $this->assertFalse($t0->hasNextSibling(), 'empty node has no next sibling'); $this->assertFalse($t1->hasNextSibling(), 'root node has no next sibling'); @@ -371,9 +436,12 @@ public function testHasNextSibling() $this->assertFalse($t3->hasNextSibling(), 'last sibling has no next sibling'); } + /** + * @return void + */ public function testGetNextSibling() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -390,11 +458,14 @@ public function testGetNextSibling() $this->assertNull($t7->getNextSibling($this->con), 'getNextSibling() returns null for last siblings'); } + /** + * @return void + */ public function testAddNestedSetChildren() { - $t0 = new \NestedSetTable9(); - $t1 = new \NestedSetTable9(); - $t2 = new \NestedSetTable9(); + $t0 = new NestedSetTable9(); + $t1 = new NestedSetTable9(); + $t2 = new NestedSetTable9(); $t0->addNestedSetChild($t1); $t0->addNestedSetChild($t2); $this->assertEquals(2, $t0->countChildren(), 'addNestedSetChild() adds the object to the internal children collection'); @@ -402,9 +473,12 @@ public function testAddNestedSetChildren() $this->assertEquals($t0, $t2->getParent(), 'addNestedSetChild() sets the object as th parent of the parameter'); } + /** + * @return void + */ public function testHasChildren() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -419,9 +493,12 @@ public function testHasChildren() $this->assertTrue($t3->hasChildren(), 'node has children'); } + /** + * @return void + */ public function testGetChildren() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -431,7 +508,7 @@ public function testGetChildren() | \ t6 t7 */ - $this->assertTrue($t2->getChildren() instanceof ObjectCollection, 'getChildren() returns a collection'); + $this->assertTrue($t2->getChildren() instanceof ObjectCollection, 'getChildren() returns a collection'); $this->assertEquals(0, count($t2->getChildren()), 'getChildren() returns an empty collection for leafs'); $children = $t3->getChildren(); $expected = [ @@ -440,7 +517,7 @@ public function testGetChildren() ]; $this->assertEquals($expected, $this->dumpNodes($children, true), 'getChildren() returns a collection of children'); $c = new Criteria(); - $c->add(\Map\NestedSetTable9TableMap::COL_TITLE, 't5'); + $c->add(NestedSetTable9TableMap::COL_TITLE, 't5'); $children = $t3->getChildren($c); $expected = [ 't5' => [7, 12, 2], @@ -448,10 +525,13 @@ public function testGetChildren() $this->assertEquals($expected, $this->dumpNodes($children, true), 'getChildren() accepts a criteria as parameter'); } + /** + * @return void + */ public function testGetChildrenCache() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - $con = Propel::getServiceContainer()->getReadConnection(\Map\NestedSetTable9TableMap::DATABASE_NAME); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); + $con = Propel::getServiceContainer()->getReadConnection(NestedSetTable9TableMap::DATABASE_NAME); $count = $con->getQueryCount(); $children = $t3->getChildren(null, $con); $children = $t3->getChildren(null, $con); @@ -463,7 +543,7 @@ public function testGetChildrenCache() $this->assertEquals($expected, $this->dumpNodes($children, true), 'getChildren() returns a collection of children'); // when using criteria, cache is not used $c = new Criteria(); - $c->add(\Map\NestedSetTable9TableMap::COL_TITLE, 't5'); + $c->add(NestedSetTable9TableMap::COL_TITLE, 't5'); $children = $t3->getChildren($c, $con); $this->assertEquals($count + 2, $con->getQueryCount(), 'getChildren() issues a new query when âssed a non-null Criteria'); $expected = [ @@ -477,12 +557,15 @@ public function testGetChildrenCache() 't4' => [5, 6, 2], 't5' => [7, 12, 2], ]; - $this->assertEquals($expected, $this->dumpNodes($children, true), 'getChildren() returns a collection of children'); + $this->assertEquals($expected, $this->dumpNodes($children, true), 'getChildren() returns a collection of children'); } + /** + * @return void + */ public function testCountChildren() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -495,13 +578,16 @@ public function testCountChildren() $this->assertEquals(0, $t2->countChildren(), 'countChildren() returns 0 for leafs'); $this->assertEquals(2, $t3->countChildren(), 'countChildren() returns the number of children'); $c = new Criteria(); - $c->add(\Map\NestedSetTable9TableMap::COL_TITLE, 't5'); + $c->add(NestedSetTable9TableMap::COL_TITLE, 't5'); $this->assertEquals(1, $t3->countChildren($c), 'countChildren() accepts a criteria as parameter'); } + /** + * @return void + */ public function testCountChildrenCache() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -511,10 +597,10 @@ public function testCountChildrenCache() | \ t6 t7 */ - $con = Propel::getServiceContainer()->getReadConnection(\Map\NestedSetTable9TableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(NestedSetTable9TableMap::DATABASE_NAME); $count = $con->getQueryCount(); - $children = $t3->getChildren(null, $con); + $children = $t3->getChildren(null, $con); $nbChildren = $t3->countChildren(null, $con); $this->assertEquals($count + 1, $con->getQueryCount(), 'countChildren() uses the internal collection when passed no Criteria'); @@ -522,9 +608,12 @@ public function testCountChildrenCache() $this->assertEquals($count + 2, $con->getQueryCount(), 'countChildren() issues a new query when passed a Criteria'); } + /** + * @return void + */ public function testGetFirstChild() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); $t5->moveToNextSiblingOf($t3); /* Results in t1 @@ -537,9 +626,12 @@ public function testGetFirstChild() $this->assertNull($t2->getFirstChild(), 'getFirstChild() returns null for leaf'); } + /** + * @return void + */ public function testGetLastChild() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); $t5->moveToNextSiblingOf($t3); /* Results in t1 @@ -552,9 +644,12 @@ public function testGetLastChild() $this->assertNull($t2->getLastChild(), 'getLastChild() returns null for leaf'); } + /** + * @return void + */ public function testGetSiblings() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -573,7 +668,7 @@ public function testGetSiblings() $siblings = $t5->getSiblings(true); $expected = [ 't4' => [5, 6, 2], - 't5' => [7, 12, 2] + 't5' => [7, 12, 2], ]; $this->assertEquals($expected, $this->dumpNodes($siblings), 'getSiblings(true) includes the current node'); $t5->moveToNextSiblingOf($t3); @@ -595,9 +690,12 @@ public function testGetSiblings() $this->assertEquals('t5', $siblings[1]->getTitle(), 'getSiblings() returns siblings in natural order'); } + /** + * @return void + */ public function testGetDescendants() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -617,7 +715,7 @@ public function testGetDescendants() ]; $this->assertEquals($expected, $this->dumpNodes($descendants), 'getDescendants() returns an array of descendants'); $c = new Criteria(); - $c->add(\Map\NestedSetTable9TableMap::COL_TITLE, 't5'); + $c->add(NestedSetTable9TableMap::COL_TITLE, 't5'); $descendants = $t3->getDescendants($c); $expected = [ 't5' => [7, 12, 2], @@ -625,9 +723,12 @@ public function testGetDescendants() $this->assertEquals($expected, $this->dumpNodes($descendants), 'getDescendants() accepts a criteria as parameter'); } + /** + * @return void + */ public function testCountDescendants() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -640,13 +741,16 @@ public function testCountDescendants() $this->assertEquals(0, $t2->countDescendants(), 'countDescendants() returns 0 for leafs'); $this->assertEquals(4, $t3->countDescendants(), 'countDescendants() returns the number of descendants'); $c = new Criteria(); - $c->add(\Map\NestedSetTable9TableMap::COL_TITLE, 't5'); + $c->add(NestedSetTable9TableMap::COL_TITLE, 't5'); $this->assertEquals(1, $t3->countDescendants($c), 'countDescendants() accepts a criteria as parameter'); } + /** + * @return void + */ public function testGetBranch() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -667,15 +771,18 @@ public function testGetBranch() ]; $this->assertEquals($expected, $this->dumpNodes($descendants), 'getBranch() returns an array of descendants, including the current node'); $c = new Criteria(); - $c->add(\Map\NestedSetTable9TableMap::COL_TITLE, 't3', Criteria::NOT_EQUAL); + $c->add(NestedSetTable9TableMap::COL_TITLE, 't3', Criteria::NOT_EQUAL); $descendants = $t3->getBranch($c); unset($expected['t3']); $this->assertEquals($expected, $this->dumpNodes($descendants), 'getBranch() accepts a criteria as first parameter'); } + /** + * @return void + */ public function testGetAncestors() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -693,7 +800,7 @@ public function testGetAncestors() ]; $this->assertEquals($expected, $this->dumpNodes($ancestors), 'getAncestors() returns an array of ancestors'); $c = new Criteria(); - $c->add(\Map\NestedSetTable9TableMap::COL_TITLE, 't3'); + $c->add(NestedSetTable9TableMap::COL_TITLE, 't3'); $ancestors = $t5->getAncestors($c); $expected = [ 't3' => [4, 13, 1], @@ -701,22 +808,25 @@ public function testGetAncestors() $this->assertEquals($expected, $this->dumpNodes($ancestors), 'getAncestors() accepts a criteria as parameter'); } + /** + * @return void + */ public function testAddChild() { - \Map\NestedSetTable9TableMap::doDeleteAll(); - $t1 = new \NestedSetTable9(); + NestedSetTable9TableMap::doDeleteAll(); + $t1 = new NestedSetTable9(); $t1->setTitle('t1'); $t1->makeRoot(); $t1->save(); - $t2 = new \NestedSetTable9(); + $t2 = new NestedSetTable9(); $t2->setTitle('t2'); $t1->addChild($t2); $t2->save(); - $t3 = new \NestedSetTable9(); + $t3 = new NestedSetTable9(); $t3->setTitle('t3'); $t1->addChild($t3); $t3->save(); - $t4 = new \NestedSetTable9(); + $t4 = new NestedSetTable9(); $t4->setTitle('t4'); $t2->addChild($t4); $t4->save(); @@ -729,10 +839,13 @@ public function testAddChild() $this->assertEquals($expected, $this->dumpTree(), 'addChild() adds the child and saves it'); } + /** + * @return void + */ public function testInsertAsFirstChildOf() { $this->assertTrue(method_exists('NestedSetTable9', 'insertAsFirstChildOf'), 'nested_set adds a insertAsFirstChildOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -742,7 +855,7 @@ public function testInsertAsFirstChildOf() | \ t6 t7 */ - $t8 = new Fixtures\PublicTable9(); + $t8 = new PublicTable9(); $t8->setTitle('t8'); $t = $t8->insertAsFirstChildOf($t3); $this->assertEquals($t8, $t, 'insertAsFirstChildOf() returns the object it was called on'); @@ -759,7 +872,7 @@ public function testInsertAsFirstChildOf() 't5' => [9, 14, 2], 't6' => [10, 11, 3], 't7' => [12, 13, 3], - 't8' => [5, 6, 2] + 't8' => [5, 6, 2], ]; $this->assertEquals($expected, $this->dumpTree(), 'insertAsFirstChildOf() shifts the other nodes correctly'); try { @@ -770,16 +883,19 @@ public function testInsertAsFirstChildOf() } } + /** + * @return void + */ public function testInsertAsFirstChildOfExistingObject() { - \NestedSetTable9Query::create()->deleteAll(); - $t = new \NestedSetTable9(); + NestedSetTable9Query::create()->deleteAll(); + $t = new NestedSetTable9(); $t->makeRoot(); $t->save(); $this->assertEquals(1, $t->getLeftValue()); $this->assertEquals(2, $t->getRightValue()); $this->assertEquals(0, $t->getLevel()); - $t1 = new \NestedSetTable9(); + $t1 = new NestedSetTable9(); $t1->save(); $t1->insertAsFirstChildOf($t); $this->assertEquals(2, $t1->getLeftValue()); @@ -794,10 +910,13 @@ public function testInsertAsFirstChildOfExistingObject() $this->assertEquals(1, $t1->getLevel()); } + /** + * @return void + */ public function testInsertAsLastChildOf() { $this->assertTrue(method_exists('NestedSetTable9', 'insertAsLastChildOf'), 'nested_set adds a insertAsLastChildOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -807,7 +926,7 @@ public function testInsertAsLastChildOf() | \ t6 t7 */ - $t8 = new Fixtures\PublicTable9(); + $t8 = new PublicTable9(); $t8->setTitle('t8'); $t = $t8->insertAsLastChildOf($t3); $this->assertEquals($t8, $t, 'insertAsLastChildOf() returns the object it was called on'); @@ -824,7 +943,7 @@ public function testInsertAsLastChildOf() 't5' => [7, 12, 2], 't6' => [8, 9, 3], 't7' => [10, 11, 3], - 't8' => [13, 14, 2] + 't8' => [13, 14, 2], ]; $this->assertEquals($expected, $this->dumpTree(), 'insertAsLastChildOf() shifts the other nodes correctly'); try { @@ -835,16 +954,19 @@ public function testInsertAsLastChildOf() } } + /** + * @return void + */ public function testInsertAsLastChildOfExistingObject() { - \NestedSetTable9Query::create()->deleteAll(); - $t = new \NestedSetTable9(); + NestedSetTable9Query::create()->deleteAll(); + $t = new NestedSetTable9(); $t->makeRoot(); $t->save(); $this->assertEquals(1, $t->getLeftValue()); $this->assertEquals(2, $t->getRightValue()); $this->assertEquals(0, $t->getLevel()); - $t1 = new \NestedSetTable9(); + $t1 = new NestedSetTable9(); $t1->save(); $t1->insertAsLastChildOf($t); $this->assertEquals(2, $t1->getLeftValue()); @@ -859,10 +981,13 @@ public function testInsertAsLastChildOfExistingObject() $this->assertEquals(1, $t1->getLevel()); } + /** + * @return void + */ public function testInsertAsPrevSiblingOf() { $this->assertTrue(method_exists('NestedSetTable9', 'insertAsPrevSiblingOf'), 'nested_set adds a insertAsPrevSiblingOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -872,7 +997,7 @@ public function testInsertAsPrevSiblingOf() | \ t6 t7 */ - $t8 = new Fixtures\PublicTable9(); + $t8 = new PublicTable9(); $t8->setTitle('t8'); $t = $t8->insertAsPrevSiblingOf($t3); $this->assertEquals($t8, $t, 'insertAsPrevSiblingOf() returns the object it was called on'); @@ -889,7 +1014,7 @@ public function testInsertAsPrevSiblingOf() 't5' => [9, 14, 2], 't6' => [10, 11, 3], 't7' => [12, 13, 3], - 't8' => [4, 5, 1] + 't8' => [4, 5, 1], ]; $this->assertEquals($expected, $this->dumpTree(), 'insertAsPrevSiblingOf() shifts the other nodes correctly'); try { @@ -900,13 +1025,16 @@ public function testInsertAsPrevSiblingOf() } } + /** + * @return void + */ public function testInsertAsPrevSiblingOfExistingObject() { - \NestedSetTable9Query::create()->deleteAll(); - $t = new \NestedSetTable9(); + NestedSetTable9Query::create()->deleteAll(); + $t = new NestedSetTable9(); $t->makeRoot(); $t->save(); - $t1 = new \NestedSetTable9(); + $t1 = new NestedSetTable9(); $t1->insertAsFirstChildOf($t); $t1->save(); $this->assertEquals(1, $t->getLeftValue()); @@ -915,7 +1043,7 @@ public function testInsertAsPrevSiblingOfExistingObject() $this->assertEquals(2, $t1->getLeftValue()); $this->assertEquals(3, $t1->getRightValue()); $this->assertEquals(1, $t1->getLevel()); - $t2 = new \NestedSetTable9(); + $t2 = new NestedSetTable9(); $t2->save(); $t2->insertAsPrevSiblingOf($t1); $this->assertEquals(2, $t2->getLeftValue()); @@ -933,10 +1061,13 @@ public function testInsertAsPrevSiblingOfExistingObject() $this->assertEquals(1, $t2->getLevel()); } + /** + * @return void + */ public function testInsertAsNextSiblingOf() { $this->assertTrue(method_exists('NestedSetTable9', 'insertAsNextSiblingOf'), 'nested_set adds a insertAsNextSiblingOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -946,7 +1077,7 @@ public function testInsertAsNextSiblingOf() | \ t6 t7 */ - $t8 = new Fixtures\PublicTable9(); + $t8 = new PublicTable9(); $t8->setTitle('t8'); $t = $t8->insertAsNextSiblingOf($t3); $this->assertEquals($t8, $t, 'insertAsNextSiblingOf() returns the object it was called on'); @@ -963,7 +1094,7 @@ public function testInsertAsNextSiblingOf() 't5' => [7, 12, 2], 't6' => [8, 9, 3], 't7' => [10, 11, 3], - 't8' => [14, 15, 1] + 't8' => [14, 15, 1], ]; $this->assertEquals($expected, $this->dumpTree(), 'insertAsNextSiblingOf() shifts the other nodes correctly'); try { @@ -974,13 +1105,16 @@ public function testInsertAsNextSiblingOf() } } + /** + * @return void + */ public function testInsertAsNextSiblingOfExistingObject() { - \NestedSetTable9Query::create()->deleteAll(); - $t = new \NestedSetTable9(); + NestedSetTable9Query::create()->deleteAll(); + $t = new NestedSetTable9(); $t->makeRoot(); $t->save(); - $t1 = new \NestedSetTable9(); + $t1 = new NestedSetTable9(); $t1->insertAsFirstChildOf($t); $t1->save(); $this->assertEquals(1, $t->getLeftValue()); @@ -989,7 +1123,7 @@ public function testInsertAsNextSiblingOfExistingObject() $this->assertEquals(2, $t1->getLeftValue()); $this->assertEquals(3, $t1->getRightValue()); $this->assertEquals(1, $t1->getLevel()); - $t2 = new \NestedSetTable9(); + $t2 = new NestedSetTable9(); $t2->save(); $t2->insertAsNextSiblingOf($t1); $this->assertEquals(4, $t2->getLeftValue()); @@ -1007,10 +1141,13 @@ public function testInsertAsNextSiblingOfExistingObject() $this->assertEquals(1, $t2->getLevel()); } + /** + * @return void + */ public function testMoveToFirstChildOf() { $this->assertTrue(method_exists('NestedSetTable9', 'moveToFirstChildOf'), 'nested_set adds a moveToFirstChildOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -1040,7 +1177,7 @@ public function testMoveToFirstChildOf() ]; $this->assertEquals($expected, $this->dumpTree(), 'moveToFirstChildOf() moves the entire subtree down correctly'); // moving up - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); $t5->moveToFirstChildOf($t1); $expected = [ 't1' => [1, 14, 0], @@ -1053,7 +1190,7 @@ public function testMoveToFirstChildOf() ]; $this->assertEquals($expected, $this->dumpTree(), 'moveToFirstChildOf() moves the entire subtree up correctly'); // moving to the same level - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); $t5->moveToFirstChildOf($t3); $expected = [ 't1' => [1, 14, 0], @@ -1067,9 +1204,12 @@ public function testMoveToFirstChildOf() $this->assertEquals($expected, $this->dumpTree(), 'moveToFirstChildOf() moves the entire subtree to the same level correctly'); } + /** + * @return void + */ public function testMoveToFirstChildOfAndChildrenCache() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -1098,10 +1238,13 @@ public function testMoveToFirstChildOfAndChildrenCache() $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToFirstChildOf() reinitializes the child collection of all concerned nodes'); } + /** + * @return void + */ public function testMoveToLastChildOf() { $this->assertTrue(method_exists('NestedSetTable9', 'moveToLastChildOf'), 'nested_set adds a moveToLastChildOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -1131,7 +1274,7 @@ public function testMoveToLastChildOf() ]; $this->assertEquals($expected, $this->dumpTree(), 'moveToLastChildOf() moves the entire subtree up correctly'); // moving down - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); $t3->moveToLastChildOf($t2); $expected = [ 't1' => [1, 14, 0], @@ -1144,7 +1287,7 @@ public function testMoveToLastChildOf() ]; $this->assertEquals($expected, $this->dumpTree(), 'moveToLastChildOf() moves the entire subtree down correctly'); // moving to the same level - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); $t4->moveToLastChildOf($t3); $expected = [ 't1' => [1, 14, 0], @@ -1158,9 +1301,12 @@ public function testMoveToLastChildOf() $this->assertEquals($expected, $this->dumpTree(), 'moveToLastChildOf() moves the entire subtree to the same level correctly'); } + /** + * @return void + */ public function testMoveToLastChildOfAndChildrenCache() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -1189,10 +1335,13 @@ public function testMoveToLastChildOfAndChildrenCache() $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToLastChildOf() reinitializes the child collection of all concerned nodes'); } + /** + * @return void + */ public function testMoveToPrevSiblingOf() { $this->assertTrue(method_exists('NestedSetTable9', 'moveToPrevSiblingOf'), 'nested_set adds a moveToPrevSiblingOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -1278,9 +1427,12 @@ public function testMoveToPrevSiblingOf() $this->assertEquals($expected, $this->dumpTree(), 'moveToPrevSiblingOf() moves the entire subtree at the same level correctly'); } + /** + * @return void + */ public function testMoveToPrevSiblingOfAndChildrenCache() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -1309,9 +1461,12 @@ public function testMoveToPrevSiblingOfAndChildrenCache() $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToPrevSiblingOf() reinitializes the child collection of all concerned nodes'); } + /** + * @return void + */ public function testMoveToNextSiblingOfAndChildrenCache() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -1340,10 +1495,13 @@ public function testMoveToNextSiblingOfAndChildrenCache() $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToNextSiblingOf() reinitializes the child collection of all concerned nodes'); } + /** + * @return void + */ public function testMoveToNextSiblingOf() { $this->assertTrue(method_exists('NestedSetTable9', 'moveToNextSiblingOf'), 'nested_set adds a moveToNextSiblingOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -1429,9 +1587,12 @@ public function testMoveToNextSiblingOf() $this->assertEquals($expected, $this->dumpTree(), 'moveToNextSiblingOf() moves the entire subtree at the same level correctly'); } + /** + * @return void + */ public function testDeleteDescendants() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -1451,7 +1612,7 @@ public function testDeleteDescendants() 't3' => [4, 5, 1], ]; $this->assertEquals($expected, $this->dumpTree(), 'deleteDescendants() shifts the entire subtree correctly'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -1468,11 +1629,14 @@ public function testDeleteDescendants() $this->assertEquals($expected, $this->dumpTree(), 'deleteDescendants() can delete all descendants of the root node'); } + /** + * @return void + */ public function testGetIterator() { $fixtures = $this->initTree(); $this->assertTrue(method_exists('NestedSetTable9', 'getIterator'), 'nested_set adds a getIterator() method'); - $root = \NestedSetTable9Query::retrieveRoot(); + $root = NestedSetTable9Query::retrieveRoot(); $iterator = $root->getIterator(); $this->assertTrue($iterator instanceof NestedSetRecursiveIterator, 'getIterator() returns a NestedSetRecursiveIterator'); foreach ($iterator as $node) { @@ -1481,9 +1645,12 @@ public function testGetIterator() } } + /** + * @return void + */ public function testGetAncestors2() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -1506,10 +1673,13 @@ public function testGetAncestors2() $this->assertEquals($expected, $this->dumpNodes($path), 'getAncestors() returns path from the current scope only'); } + /** + * @return void + */ public function testConstants() { - $this->assertEquals(\NestedSetTable9::LEFT_COL, 'nested_set_table9.tree_left', 'nested_set adds a LEFT_COL constant'); - $this->assertEquals(\NestedSetTable9::RIGHT_COL, 'nested_set_table9.tree_right', 'nested_set adds a RIGHT_COL constant'); - $this->assertEquals(\NestedSetTable9::LEVEL_COL, 'nested_set_table9.tree_level', 'nested_set adds a LEVEL_COL constant'); + $this->assertEquals(NestedSetTable9::LEFT_COL, 'nested_set_table9.tree_left', 'nested_set adds a LEFT_COL constant'); + $this->assertEquals(NestedSetTable9::RIGHT_COL, 'nested_set_table9.tree_right', 'nested_set adds a RIGHT_COL constant'); + $this->assertEquals(NestedSetTable9::LEVEL_COL, 'nested_set_table9.tree_level', 'nested_set adds a LEVEL_COL constant'); } } diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php index 987186afc6..6d50f1f9d5 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php @@ -10,7 +10,10 @@ namespace Propel\Tests\Generator\Behavior\NestedSet; -use Propel\Runtime\Exception\PropelException; +use Fixtures\PublicTable10; +use Map\NestedSetTable10TableMap; +use NestedSetTable10; +use NestedSetTable10Query; /** * Tests for NestedSetBehaviorObjectBuilderModifier class @@ -21,42 +24,50 @@ class NestedSetBehaviorObjectBuilderModifierWithScopeTest extends TestCase { protected function getByTitle($title) { - return \NestedSetTable10Query::create()->filterByTitle($title)->findOne(); + return NestedSetTable10Query::create()->filterByTitle($title)->findOne(); } /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testSaveRootInTreeWithExistingRootWithSameScope() { - \Map\NestedSetTable10TableMap::doDeleteAll(); - $t1 = new \NestedSetTable10(); + NestedSetTable10TableMap::doDeleteAll(); + $t1 = new NestedSetTable10(); $t1->setScopeValue(1); $t1->makeRoot(); $t1->save(); - $t2 = new \NestedSetTable10(); + $t2 = new NestedSetTable10(); $t2->setScopeValue(1); $t2->makeRoot(); $t2->save(); } + /** + * @return void + */ public function testSaveRootInTreeWithExistingRootWithDifferentScope() { - \Map\NestedSetTable10TableMap::doDeleteAll(); - $t1 = new \NestedSetTable10(); + NestedSetTable10TableMap::doDeleteAll(); + $t1 = new NestedSetTable10(); $t1->setScopeValue(1); $t1->makeRoot(); $t1->save(); - $t2 = new \NestedSetTable10(); + $t2 = new NestedSetTable10(); $t2->setScopeValue(2); $t2->makeRoot(); $t2->save(); $this->assertTrue(!$t2->isNew()); } + /** + * @return void + */ public function testDelete() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -87,9 +98,12 @@ public function testDelete() $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'delete() does not delete anything out of the scope'); } + /** + * @return void + */ public function testIsDescendantOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -110,6 +124,9 @@ public function testIsDescendantOf() $this->assertFalse($t2->isDescendantOf($t8), 'is false, since both are in different scopes'); } + /** + * @return void + */ public function testGetParent() { $this->initTreeWithScope(); @@ -123,9 +140,12 @@ public function testGetParent() $this->assertEquals($t4->getParent($this->con), $t3, 'getParent() retrieves the same parent for nodes'); } + /** + * @return void + */ public function testGetPrevSibling() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -147,9 +167,12 @@ public function testGetPrevSibling() $this->assertEquals($t7->getPrevSibling($this->con), $t6, 'getPrevSibling() correctly retrieves prev sibling'); } + /** + * @return void + */ public function testGetNextSibling() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -171,9 +194,12 @@ public function testGetNextSibling() $this->assertNull($t7->getNextSibling($this->con), 'getNextSibling() returns null for last siblings'); } + /** + * @return void + */ public function testGetDescendants() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -198,9 +224,12 @@ public function testGetDescendants() $this->assertEquals($expected, $this->dumpNodes($descendants), 'getDescendants() returns descendants from the current scope only'); } + /** + * @return void + */ public function testGetAncestors() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -224,6 +253,9 @@ public function testGetAncestors() $this->assertEquals($expected, $this->dumpNodes($ancestors), 'getAncestors() returns ancestors from the current scope only'); } + /** + * @return void + */ public function testInsertAsFirstChildOf() { $this->assertTrue( @@ -246,7 +278,7 @@ public function testInsertAsFirstChildOf() | \ t9 t10 */ - $t11 = new Fixtures\PublicTable10(); + $t11 = new PublicTable10(); $t11->setTitle('t11'); $t11->insertAsFirstChildOf($fixtures[2]); // first child of t3 $this->assertEquals(1, $t11->getScopeValue(), 'insertAsFirstChildOf() sets the scope value correctly'); @@ -259,7 +291,7 @@ public function testInsertAsFirstChildOf() 't5' => [9, 14, 2], 't6' => [10, 11, 3], 't7' => [12, 13, 3], - 't11' => [5, 6, 2] + 't11' => [5, 6, 2], ]; $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'insertAsFirstChildOf() shifts the other nodes correctly'); $expected = [ @@ -270,17 +302,20 @@ public function testInsertAsFirstChildOf() $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'insertAsFirstChildOf() does not shift anything out of the scope'); } + /** + * @return void + */ public function testInsertAsFirstChildOfExistingObject() { - \NestedSetTable10Query::create()->deleteAll(); - $t = new \NestedSetTable10(); + NestedSetTable10Query::create()->deleteAll(); + $t = new NestedSetTable10(); $t->setScopeValue(34); $t->makeRoot(); $t->save(); $this->assertEquals(1, $t->getLeftValue()); $this->assertEquals(2, $t->getRightValue()); $this->assertEquals(0, $t->getLevel()); - $t1 = new \NestedSetTable10(); + $t1 = new NestedSetTable10(); $t1->save(); $t1->insertAsFirstChildOf($t); $this->assertEquals(2, $t1->getLeftValue()); @@ -297,6 +332,9 @@ public function testInsertAsFirstChildOfExistingObject() $this->assertEquals(1, $t1->getLevel()); } + /** + * @return void + */ public function testInsertAsLastChildOf() { $this->assertTrue( @@ -319,7 +357,7 @@ public function testInsertAsLastChildOf() | \ t9 t10 */ - $t11 = new Fixtures\PublicTable10(); + $t11 = new PublicTable10(); $t11->setTitle('t11'); $t11->insertAsLastChildOf($fixtures[2]); // last child of t3 $this->assertEquals(1, $t11->getScopeValue(), 'insertAsLastChildOf() sets the scope value correctly'); @@ -332,7 +370,7 @@ public function testInsertAsLastChildOf() 't5' => [7, 12, 2], 't6' => [8, 9, 3], 't7' => [10, 11, 3], - 't11' => [13, 14, 2] + 't11' => [13, 14, 2], ]; $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'insertAsLastChildOf() shifts the other nodes correctly'); $expected = [ @@ -343,17 +381,20 @@ public function testInsertAsLastChildOf() $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'insertAsLastChildOf() does not shift anything out of the scope'); } + /** + * @return void + */ public function testInsertAsLastChildOfExistingObject() { - \NestedSetTable10Query::create()->deleteAll(); - $t = new \NestedSetTable10(); + NestedSetTable10Query::create()->deleteAll(); + $t = new NestedSetTable10(); $t->setScopeValue(34); $t->makeRoot(); $t->save(); $this->assertEquals(1, $t->getLeftValue()); $this->assertEquals(2, $t->getRightValue()); $this->assertEquals(0, $t->getLevel()); - $t1 = new \NestedSetTable10(); + $t1 = new NestedSetTable10(); $t1->save(); $t1->insertAsLastChildOf($t); $this->assertEquals(2, $t1->getLeftValue()); @@ -370,6 +411,9 @@ public function testInsertAsLastChildOfExistingObject() $this->assertEquals(1, $t1->getLevel()); } + /** + * @return void + */ public function testInsertAsPrevSiblingOf() { $this->assertTrue( @@ -392,7 +436,7 @@ public function testInsertAsPrevSiblingOf() | \ t9 t10 */ - $t11 = new Fixtures\PublicTable10(); + $t11 = new PublicTable10(); $t11->setTitle('t11'); $t11->insertAsPrevSiblingOf($fixtures[2]); // prev sibling of t3 $this->assertEquals(1, $t11->getScopeValue(), 'insertAsPrevSiblingOf() sets the scope value correctly'); @@ -405,7 +449,7 @@ public function testInsertAsPrevSiblingOf() 't5' => [9, 14, 2], 't6' => [10, 11, 3], 't7' => [12, 13, 3], - 't11' => [4, 5, 1] + 't11' => [4, 5, 1], ]; $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'insertAsPrevSiblingOf() shifts the other nodes correctly'); $expected = [ @@ -416,14 +460,17 @@ public function testInsertAsPrevSiblingOf() $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'insertAsPrevSiblingOf() does not shift anything out of the scope'); } + /** + * @return void + */ public function testInsertAsPrevSiblingOfExistingObject() { - \NestedSetTable10Query::create()->deleteAll(); - $t = new \NestedSetTable10(); + NestedSetTable10Query::create()->deleteAll(); + $t = new NestedSetTable10(); $t->setScopeValue(34); $t->makeRoot(); $t->save(); - $t1 = new \NestedSetTable10(); + $t1 = new NestedSetTable10(); $t1->insertAsFirstChildOf($t); $t1->save(); $this->assertEquals(1, $t->getLeftValue()); @@ -433,7 +480,7 @@ public function testInsertAsPrevSiblingOfExistingObject() $this->assertEquals(3, $t1->getRightValue()); $this->assertEquals(34, $t1->getScopeValue()); $this->assertEquals(1, $t1->getLevel()); - $t2 = new \NestedSetTable10(); + $t2 = new NestedSetTable10(); $t2->save(); $t2->insertAsPrevSiblingOf($t1); $this->assertEquals(2, $t2->getLeftValue()); @@ -454,6 +501,9 @@ public function testInsertAsPrevSiblingOfExistingObject() $this->assertEquals(1, $t2->getLevel()); } + /** + * @return void + */ public function testInsertAsNextSiblingOf() { $this->assertTrue( @@ -476,7 +526,7 @@ public function testInsertAsNextSiblingOf() | \ t9 t10 */ - $t11 = new Fixtures\PublicTable10(); + $t11 = new PublicTable10(); $t11->setTitle('t11'); $t11->insertAsNextSiblingOf($fixtures[2]); // next sibling of t3 $this->assertEquals(1, $t11->getScopeValue(), 'insertAsNextSiblingOf() sets the scope value correctly'); @@ -489,7 +539,7 @@ public function testInsertAsNextSiblingOf() 't5' => [7, 12, 2], 't6' => [8, 9, 3], 't7' => [10, 11, 3], - 't11' => [14, 15, 1] + 't11' => [14, 15, 1], ]; $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'insertAsNextSiblingOf() shifts the other nodes correctly'); $expected = [ @@ -500,14 +550,17 @@ public function testInsertAsNextSiblingOf() $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'insertAsNextSiblingOf() does not shift anything out of the scope'); } + /** + * @return void + */ public function testInsertAsNextSiblingOfExistingObject() { - \NestedSetTable10Query::create()->deleteAll(); - $t = new \NestedSetTable10(); + NestedSetTable10Query::create()->deleteAll(); + $t = new NestedSetTable10(); $t->setScopeValue(34); $t->makeRoot(); $t->save(); - $t1 = new \NestedSetTable10(); + $t1 = new NestedSetTable10(); $t1->insertAsFirstChildOf($t); $t1->save(); $this->assertEquals(1, $t->getLeftValue()); @@ -517,7 +570,7 @@ public function testInsertAsNextSiblingOfExistingObject() $this->assertEquals(3, $t1->getRightValue()); $this->assertEquals(34, $t1->getScopeValue()); $this->assertEquals(1, $t1->getLevel()); - $t2 = new \NestedSetTable10(); + $t2 = new NestedSetTable10(); $t2->save(); $t2->insertAsNextSiblingOf($t1); $this->assertEquals(4, $t2->getLeftValue()); @@ -538,9 +591,12 @@ public function testInsertAsNextSiblingOfExistingObject() $this->assertEquals(1, $t2->getLevel()); } + /** + * @return void + */ public function testMoveToFirstChildOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -591,18 +647,21 @@ public function testMoveToFirstChildOf() $t8->moveToFirstChildOf($t3); - $this->assertEquals($t3->getLeftValue()+1, $t8->getLeftValue(), 't8 has been moved to first children of t3'); + $this->assertEquals($t3->getLeftValue() + 1, $t8->getLeftValue(), 't8 has been moved to first children of t3'); $this->assertEquals(19, $t3->getRightValue(), 't3 was extended for 3 more children, from 13+(3*2) to 19'); - $this->assertEquals($oldt4Left+(2*3), $t4->getLeftValue(), 't4 was moved by 3 items before it'); + $this->assertEquals($oldt4Left + (2 * 3), $t4->getLeftValue(), 't4 was moved by 3 items before it'); $this->assertEquals(3, $t9->getLevel(), 'New level is 3'); $expected = []; $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'root of scope 2 to scope 1, therefore scope 2 is empty'); } + /** + * @return void + */ public function testMoveToLastChildOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -657,9 +716,12 @@ public function testMoveToLastChildOf() $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'root of scope 2 to scope 1, therefore scope 2 is empty'); } + /** + * @return void + */ public function testMoveToPrevSiblingOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -717,9 +779,12 @@ public function testMoveToPrevSiblingOf() $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'root of scope 2 to scope 1, therefore scope 2 is empty'); } + /** + * @return void + */ public function testMoveToNextSiblingOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -768,24 +833,27 @@ public function testMoveToNextSiblingOf() $this->assertEquals(6, $t8->getRightValue(), 't8 extended by 1 item, 4+2 => 6'); $this->assertEquals(1, $t7->getLevel(), 'New level is 1'); - $this->assertEquals($t9->getRightValue()+1, $t7->getLeftValue(), 'Moved after t9, so we have t9.right+1 as left'); + $this->assertEquals($t9->getRightValue() + 1, $t7->getLeftValue(), 'Moved after t9, so we have t9.right+1 as left'); //dispose scope 2 $oldT1Right = $t1->getRightValue(); $t8->moveToNextSiblingOf($t3); - $this->assertEquals($oldT1Right+(2*3), $t1->getRightValue(), 't1 has been extended by 3 items'); + $this->assertEquals($oldT1Right + (2 * 3), $t1->getRightValue(), 't1 has been extended by 3 items'); $this->assertEquals(13, $t3->getRightValue(), 't3 has no change.'); $this->assertEquals(1, $t8->getLevel(), 'New level is 1'); $this->assertEquals(2, $t9->getLevel(), 'New level is 2'); $expected = []; $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'root of scope 2 to scope 1, therefore scope 2 is empty'); -} + } + /** + * @return void + */ public function testDeleteDescendants() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -815,11 +883,14 @@ public function testDeleteDescendants() $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'deleteDescendants() does not delete anything out of the scope'); } + /** + * @return void + */ public function testConstants() { - $this->assertEquals(\NestedSetTable10::LEFT_COL, 'nested_set_table10.my_left_column'); - $this->assertEquals(\NestedSetTable10::RIGHT_COL, 'nested_set_table10.my_right_column'); - $this->assertEquals(\NestedSetTable10::LEVEL_COL, 'nested_set_table10.my_level_column'); - $this->assertEquals(\NestedSetTable10::SCOPE_COL, 'nested_set_table10.my_scope_column'); + $this->assertEquals(NestedSetTable10::LEFT_COL, 'nested_set_table10.my_left_column'); + $this->assertEquals(NestedSetTable10::RIGHT_COL, 'nested_set_table10.my_right_column'); + $this->assertEquals(NestedSetTable10::LEVEL_COL, 'nested_set_table10.my_level_column'); + $this->assertEquals(NestedSetTable10::SCOPE_COL, 'nested_set_table10.my_scope_column'); } } diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifierTest.php index ad780c7033..8e2550ff19 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifierTest.php @@ -10,6 +10,9 @@ namespace Propel\Tests\Generator\Behavior\NestedSet; +use Map\NestedSetTable9TableMap; +use NestedSetTable9; +use NestedSetTable9Query; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Collection\ObjectCollection; @@ -20,9 +23,12 @@ */ class NestedSetBehaviorQueryBuilderModifierTest extends TestCase { + /** + * @return void + */ public function testDescendantsOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -32,21 +38,24 @@ public function testDescendantsOf() | \ t6 t7 */ - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->descendantsOf($t7) ->orderByBranch() ->find(); $this->assertEquals([], iterator_to_array($objs), 'descendantsOf() filters by descendants'); - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->descendantsOf($t3) ->orderByBranch() ->find(); $this->assertEquals([$t4, $t5, $t6, $t7], iterator_to_array($objs), 'descendantsOf() filters by descendants'); } + /** + * @return void + */ public function testBranchOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -56,17 +65,17 @@ public function testBranchOf() | \ t6 t7 */ - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->branchOf($t7) ->orderByBranch() ->find(); $this->assertEquals([$t7], iterator_to_array($objs), 'branchOf() filters by descendants and includes object passed as parameter'); - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->branchOf($t3) ->orderByBranch() ->find(); $this->assertEquals([$t3, $t4, $t5, $t6, $t7], iterator_to_array($objs), 'branchOf() filters by descendants and includes object passed as parameter'); - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->branchOf($t1) ->orderByBranch() ->find(); @@ -74,9 +83,12 @@ public function testBranchOf() $this->assertEquals([$t1, $t2, $t3, $t4, $t5, $t6, $t7], iterator_to_array($objs), 'branchOf() returns the whole tree for the root node'); } + /** + * @return void + */ public function testChildrenOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -86,26 +98,29 @@ public function testChildrenOf() | \ t6 t7 */ - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->childrenOf($t6) ->orderByBranch() ->find(); $this->assertEquals([], iterator_to_array($objs), 'childrenOf() returns empty collection for leaf nodes'); - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->childrenOf($t5) ->orderByBranch() ->find(); $this->assertEquals([$t6, $t7], iterator_to_array($objs), 'childrenOf() filters by children'); - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->childrenOf($t3) ->orderByBranch() ->find(); $this->assertEquals([$t4, $t5], iterator_to_array($objs), 'childrenOf() filters by children and not by descendants'); } + /** + * @return void + */ public function testSiblingsOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -115,21 +130,24 @@ public function testSiblingsOf() | \ t6 t7 */ - $desc = \NestedSetTable9Query::create() + $desc = NestedSetTable9Query::create() ->siblingsOf($t1) ->orderByBranch() ->find(); $this->assertEquals([], iterator_to_array($desc), 'siblingsOf() returns empty collection for the root node'); - $desc = \NestedSetTable9Query::create() + $desc = NestedSetTable9Query::create() ->siblingsOf($t3) ->orderByBranch() ->find(); $this->assertEquals([$t2], iterator_to_array($desc), 'siblingsOf() filters by siblings'); } + /** + * @return void + */ public function testAncestorsOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -139,26 +157,29 @@ public function testAncestorsOf() | \ t6 t7 */ - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->ancestorsOf($t1) ->orderByBranch() ->find(); $this->assertEquals([], iterator_to_array($objs), 'ancestorsOf() returns empty collection for root node'); - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->ancestorsOf($t3) ->orderByBranch() ->find(); $this->assertEquals([$t1], iterator_to_array($objs), 'ancestorsOf() filters by ancestors'); - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->ancestorsOf($t7) ->orderByBranch() ->find(); $this->assertEquals([$t1, $t3, $t5], iterator_to_array($objs), 'childrenOf() filters by ancestors'); } + /** + * @return void + */ public function testRootsOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -168,26 +189,29 @@ public function testRootsOf() | \ t6 t7 */ - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->rootsOf($t1) ->orderByBranch() ->find(); $this->assertEquals([$t1], iterator_to_array($objs), 'rootsOf() returns the root node for root node'); - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->rootsOf($t3) ->orderByBranch() ->find(); $this->assertEquals([$t1, $t3], iterator_to_array($objs), 'rootsOf() filters by ancestors and includes the node passed as parameter'); - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->rootsOf($t7) ->orderByBranch() ->find(); $this->assertEquals([$t1, $t3, $t5, $t7], iterator_to_array($objs), 'rootsOf() filters by ancestors and includes the node passed as parameter'); } + /** + * @return void + */ public function testOrderByBranch() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); $t5->moveToPrevSiblingOf($t4); /* Results in t1 @@ -198,19 +222,22 @@ public function testOrderByBranch() | \ t6 t7 */ - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->orderByBranch() ->find(); $this->assertEquals([$t1, $t2, $t3, $t5, $t6, $t7, $t4], iterator_to_array($objs), 'orderByBranch() orders by branch left to right'); - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->orderByBranch(true) ->find(); $this->assertEquals([$t4, $t7, $t6, $t5, $t3, $t2, $t1], iterator_to_array($objs), 'orderByBranch(true) orders by branch right to left'); } + /** + * @return void + */ public function testOrderByLevel() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); $t5->moveToPrevSiblingOf($t4); /* Results in t1 @@ -221,45 +248,51 @@ public function testOrderByLevel() | \ t6 t7 */ - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->orderByLevel() ->find(); $this->assertEquals([$t1, $t2, $t3, $t5, $t4, $t6, $t7], iterator_to_array($objs), 'orderByLevel() orders by level, from the root to the leaf'); - $objs = \NestedSetTable9Query::create() + $objs = NestedSetTable9Query::create() ->orderByLevel(true) ->find(); $this->assertEquals([$t7, $t6, $t4, $t5, $t3, $t2, $t1], iterator_to_array($objs), 'orderByLevel() orders by level, from the root to the leaf'); } + /** + * @return void + */ public function testFindRoot() { $this->assertTrue(method_exists('NestedSetTable9Query', 'findRoot'), 'nested_set adds a findRoot() method'); - \NestedSetTable9Query::create()->deleteAll(); - $this->assertNull(\NestedSetTable9Query::create()->findRoot(), 'findRoot() returns null as long as no root node is defined'); + NestedSetTable9Query::create()->deleteAll(); + $this->assertNull(NestedSetTable9Query::create()->findRoot(), 'findRoot() returns null as long as no root node is defined'); - $t1 = new \NestedSetTable9(); + $t1 = new NestedSetTable9(); $t1->setLeftValue(123); $t1->setRightValue(456); $t1->save(); - $this->assertNull(\NestedSetTable9Query::create()->findRoot(), 'findRoot() returns null as long as no root node is defined'); + $this->assertNull(NestedSetTable9Query::create()->findRoot(), 'findRoot() returns null as long as no root node is defined'); - $t2 = new \NestedSetTable9(); + $t2 = new NestedSetTable9(); $t2->setLeftValue(1); $t2->setRightValue(2); $t2->save(); - $this->assertEquals(\NestedSetTable9Query::create()->findRoot(), $t2, 'findRoot() retrieves the root node'); + $this->assertEquals(NestedSetTable9Query::create()->findRoot(), $t2, 'findRoot() retrieves the root node'); } + /** + * @return void + */ public function testfindTree() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - $tree = \NestedSetTable9Query::create()->findTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); + $tree = NestedSetTable9Query::create()->findTree(); $this->assertEquals([$t1, $t2, $t3, $t4, $t5, $t6, $t7], iterator_to_array($tree), 'findTree() retrieves the whole tree, ordered by branch'); } @@ -272,6 +305,9 @@ protected function buildCollection($arr) return $coll; } + /** + * @return void + */ public function testRetrieveRoot() { $this->assertTrue( @@ -279,64 +315,76 @@ public function testRetrieveRoot() 'nested_set adds a retrieveRoot() method' ); - \Map\NestedSetTable9TableMap::doDeleteAll(); - $this->assertNull(\NestedSetTable9Query::retrieveRoot(), 'retrieveRoot() returns null as long as no root node is defined'); + NestedSetTable9TableMap::doDeleteAll(); + $this->assertNull(NestedSetTable9Query::retrieveRoot(), 'retrieveRoot() returns null as long as no root node is defined'); - $t1 = new \NestedSetTable9(); + $t1 = new NestedSetTable9(); $t1->setLeftValue(123); $t1->setRightValue(456); $t1->save(); - $this->assertNull(\NestedSetTable9Query::retrieveRoot(), 'retrieveRoot() returns null as long as no root node is defined'); + $this->assertNull(NestedSetTable9Query::retrieveRoot(), 'retrieveRoot() returns null as long as no root node is defined'); - $t2 = new \NestedSetTable9(); + $t2 = new NestedSetTable9(); $t2->setLeftValue(1); $t2->setRightValue(2); $t2->save(); - $this->assertEquals(\NestedSetTable9Query::retrieveRoot(), $t2, 'retrieveRoot() retrieves the root node'); + $this->assertEquals(NestedSetTable9Query::retrieveRoot(), $t2, 'retrieveRoot() retrieves the root node'); } + /** + * @return void + */ public function testRetrieveTree() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - $tree = \NestedSetTable9Query::retrieveTree()->getArrayCopy(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); + $tree = NestedSetTable9Query::retrieveTree()->getArrayCopy(); $this->assertEquals([$t1, $t2, $t3, $t4, $t5, $t6, $t7], $tree, 'retrieveTree() retrieves the whole tree'); $c = new Criteria(); - $c->add(\NestedSetTable9::LEFT_COL, 4, Criteria::GREATER_EQUAL); - $tree = \NestedSetTable9Query::retrieveTree($c)->getArrayCopy(); + $c->add(NestedSetTable9::LEFT_COL, 4, Criteria::GREATER_EQUAL); + $tree = NestedSetTable9Query::retrieveTree($c)->getArrayCopy(); $this->assertEquals([$t3, $t4, $t5, $t6, $t7], $tree, 'retrieveTree() accepts a Criteria as first parameter'); } + /** + * @return void + */ public function testIsValid() { $this->assertTrue(method_exists('NestedSetTable9Query', 'isValid'), 'nested_set adds an isValid() method'); - $this->assertFalse(\NestedSetTable9Query::isValid(null), 'isValid() returns false when passed null '); - $t1 = new \NestedSetTable9(); - $this->assertFalse(\NestedSetTable9Query::isValid($t1), 'isValid() returns false when passed an empty node object'); - $t2 = new \NestedSetTable9(); + $this->assertFalse(NestedSetTable9Query::isValid(null), 'isValid() returns false when passed null '); + $t1 = new NestedSetTable9(); + $this->assertFalse(NestedSetTable9Query::isValid($t1), 'isValid() returns false when passed an empty node object'); + $t2 = new NestedSetTable9(); $t2->setLeftValue(5)->setRightValue(2); - $this->assertFalse(\NestedSetTable9Query::isValid($t2), 'isValid() returns false when passed a node object with left > right'); - $t3 = new \NestedSetTable9(); + $this->assertFalse(NestedSetTable9Query::isValid($t2), 'isValid() returns false when passed a node object with left > right'); + $t3 = new NestedSetTable9(); $t3->setLeftValue(5)->setRightValue(5); - $this->assertFalse(\NestedSetTable9Query::isValid($t3), 'isValid() returns false when passed a node object with left = right'); - $t4 = new \NestedSetTable9(); + $this->assertFalse(NestedSetTable9Query::isValid($t3), 'isValid() returns false when passed a node object with left = right'); + $t4 = new NestedSetTable9(); $t4->setLeftValue(2)->setRightValue(5); - $this->assertTrue(\NestedSetTable9Query::isValid($t4), 'isValid() returns true when passed a node object with left < right'); + $this->assertTrue(NestedSetTable9Query::isValid($t4), 'isValid() returns true when passed a node object with left < right'); } + /** + * @return void + */ public function testDeleteTree() { $this->initTree(); - \NestedSetTable9Query::deleteTree(); - $this->assertCount(0, \NestedSetTable9Query::create()->find(), 'deleteTree() deletes the whole tree'); + NestedSetTable9Query::deleteTree(); + $this->assertCount(0, NestedSetTable9Query::create()->find(), 'deleteTree() deletes the whole tree'); } + /** + * @return void + */ public function testShiftRLValuesDelta() { $this->initTree(); - \NestedSetTable9Query::shiftRLValues($delta = 1, $left = 1); - \Map\NestedSetTable9TableMap::clearInstancePool(); + NestedSetTable9Query::shiftRLValues($delta = 1, $left = 1); + NestedSetTable9TableMap::clearInstancePool(); $expected = [ 't1' => [2, 15, 0], 't2' => [3, 4, 1], @@ -348,8 +396,8 @@ public function testShiftRLValuesDelta() ]; $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts all nodes with a positive amount'); $this->initTree(); - \NestedSetTable9Query::shiftRLValues($delta = -1, $left = 1); - \Map\NestedSetTable9TableMap::clearInstancePool(); + NestedSetTable9Query::shiftRLValues($delta = -1, $left = 1); + NestedSetTable9TableMap::clearInstancePool(); $expected = [ 't1' => [0, 13, 0], 't2' => [1, 2, 1], @@ -361,10 +409,10 @@ public function testShiftRLValuesDelta() ]; $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues can shift all nodes with a negative amount'); $this->initTree(); - \NestedSetTable9Query::shiftRLValues($delta = 3, $left = 1); - \Map\NestedSetTable9TableMap::clearInstancePool(); + NestedSetTable9Query::shiftRLValues($delta = 3, $left = 1); + NestedSetTable9TableMap::clearInstancePool(); $expected = [ - 't1'=> [4, 17, 0], + 't1' => [4, 17, 0], 't2' => [5, 6, 1], 't3' => [7, 16, 1], 't4' => [8, 9, 2], @@ -373,8 +421,8 @@ public function testShiftRLValuesDelta() 't7' => [13, 14, 3], ]; $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts all nodes several units to the right'); - \NestedSetTable9Query::shiftRLValues($delta = -3, $left = 1); - \Map\NestedSetTable9TableMap::clearInstancePool(); + NestedSetTable9Query::shiftRLValues($delta = -3, $left = 1); + NestedSetTable9TableMap::clearInstancePool(); $expected = [ 't1' => [1, 14, 0], 't2' => [2, 3, 1], @@ -387,11 +435,14 @@ public function testShiftRLValuesDelta() $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts all nodes several units to the left'); } + /** + * @return void + */ public function testShiftRLValuesLeftLimit() { $this->initTree(); - \NestedSetTable9Query::shiftRLValues($delta = 1, $left = 15); - \Map\NestedSetTable9TableMap::clearInstancePool(); + NestedSetTable9Query::shiftRLValues($delta = 1, $left = 15); + NestedSetTable9TableMap::clearInstancePool(); $expected = [ 't1' => [1, 14, 0], 't2' => [2, 3, 1], @@ -403,8 +454,8 @@ public function testShiftRLValuesLeftLimit() ]; $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues does not shift anything when the left parameter is higher than the highest right value'); $this->initTree(); - \NestedSetTable9Query::shiftRLValues($delta = 1, $left = 5); - \Map\NestedSetTable9TableMap::clearInstancePool(); + NestedSetTable9Query::shiftRLValues($delta = 1, $left = 5); + NestedSetTable9TableMap::clearInstancePool(); $expected = [ 't1' => [1, 15, 0], 't2' => [2, 3, 1], @@ -416,10 +467,10 @@ public function testShiftRLValuesLeftLimit() ]; $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts only the nodes having a LR value higher than the given left parameter'); $this->initTree(); - \NestedSetTable9Query::shiftRLValues($delta = 1, $left = 1); - \Map\NestedSetTable9TableMap::clearInstancePool(); + NestedSetTable9Query::shiftRLValues($delta = 1, $left = 1); + NestedSetTable9TableMap::clearInstancePool(); $expected = [ - 't1'=> [2, 15, 0], + 't1' => [2, 15, 0], 't2' => [3, 4, 1], 't3' => [5, 14, 1], 't4' => [6, 7, 2], @@ -430,11 +481,14 @@ public function testShiftRLValuesLeftLimit() $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts all nodes when the left parameter is 1'); } + /** + * @return void + */ public function testShiftRLValuesRightLimit() { $this->initTree(); - \NestedSetTable9Query::shiftRLValues($delta = 1, $left = 1, $right = 0); - \Map\NestedSetTable9TableMap::clearInstancePool(); + NestedSetTable9Query::shiftRLValues($delta = 1, $left = 1, $right = 0); + NestedSetTable9TableMap::clearInstancePool(); $expected = [ 't1' => [1, 14, 0], 't2' => [2, 3, 1], @@ -446,8 +500,8 @@ public function testShiftRLValuesRightLimit() ]; $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues does not shift anything when the right parameter is 0'); $this->initTree(); - \NestedSetTable9Query::shiftRLValues($delta = 1, $left = 1, $right = 5); - \Map\NestedSetTable9TableMap::clearInstancePool(); + NestedSetTable9Query::shiftRLValues($delta = 1, $left = 1, $right = 5); + NestedSetTable9TableMap::clearInstancePool(); $expected = [ 't1' => [2, 14, 0], 't2' => [3, 4, 1], @@ -459,10 +513,10 @@ public function testShiftRLValuesRightLimit() ]; $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shiftRLValues shifts only the nodes having a LR value lower than the given right parameter'); $this->initTree(); - \NestedSetTable9Query::shiftRLValues($delta = 1, $left = 1, $right = 15); - \Map\NestedSetTable9TableMap::clearInstancePool(); + NestedSetTable9Query::shiftRLValues($delta = 1, $left = 1, $right = 15); + NestedSetTable9TableMap::clearInstancePool(); $expected = [ - 't1'=> [2, 15, 0], + 't1' => [2, 15, 0], 't2' => [3, 4, 1], 't3' => [5, 14, 1], 't4' => [6, 7, 2], @@ -473,6 +527,9 @@ public function testShiftRLValuesRightLimit() $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts all nodes when the right parameter is higher than the highest right value'); } + /** + * @return void + */ public function testShiftLevel() { /* Tree used for tests @@ -485,8 +542,8 @@ public function testShiftLevel() t6 t7 */ $this->initTree(); - \NestedSetTable9Query::shiftLevel($delta = 1, $first = 7, $last = 12); - \Map\NestedSetTable9TableMap::clearInstancePool(); + NestedSetTable9Query::shiftLevel($delta = 1, $first = 7, $last = 12); + NestedSetTable9TableMap::clearInstancePool(); $expected = [ 't1' => [1, 14, 0], 't2' => [2, 3, 1], @@ -498,8 +555,8 @@ public function testShiftLevel() ]; $this->assertEquals($this->dumpTree(), $expected, 'shiftLevel shifts all nodes with a left value between the first and last'); $this->initTree(); - \NestedSetTable9Query::shiftLevel($delta = -1, $first = 7, $last = 12); - \Map\NestedSetTable9TableMap::clearInstancePool(); + NestedSetTable9Query::shiftLevel($delta = -1, $first = 7, $last = 12); + NestedSetTable9TableMap::clearInstancePool(); $expected = [ 't1' => [1, 14, 0], 't2' => [2, 3, 1], @@ -512,11 +569,14 @@ public function testShiftLevel() $this->assertEquals($this->dumpTree(), $expected, 'shiftLevel shifts all nodes wit ha negative amount'); } + /** + * @return void + */ public function testUpdateLoadedNodes() { $this->assertTrue(method_exists('NestedSetTable9Query', 'updateLoadedNodes'), 'nested_set adds a updateLoadedNodes() method'); $fixtures = $this->initTree(); - \NestedSetTable9Query::shiftRLValues(1, 5); + NestedSetTable9Query::shiftRLValues(1, 5); $expected = [ 't1' => [1, 14], 't2' => [2, 3], @@ -531,7 +591,7 @@ public function testUpdateLoadedNodes() $actual[$t->getTitle()] = [$t->getLeftValue(), $t->getRightValue()]; } $this->assertEquals($actual, $expected, 'Loaded nodes are not in sync before calling updateLoadedNodes()'); - \NestedSetTable9Query::updateLoadedNodes(); + NestedSetTable9Query::updateLoadedNodes(); $expected = [ 't1' => [1, 15], 't2' => [2, 3], @@ -548,10 +608,13 @@ public function testUpdateLoadedNodes() $this->assertEquals($actual, $expected, 'Loaded nodes are in sync after calling updateLoadedNodes()'); } + /** + * @return void + */ public function testMakeRoomForLeaf() { $this->assertTrue(method_exists('NestedSetTable9Query', 'makeRoomForLeaf'), 'nested_set adds a makeRoomForLeaf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7] = $this->initTree(); /* Tree used for tests t1 | \ @@ -561,7 +624,7 @@ public function testMakeRoomForLeaf() | \ t6 t7 */ - $t = \NestedSetTable9Query::makeRoomForLeaf(5); // first child of t3 + $t = NestedSetTable9Query::makeRoomForLeaf(5); // first child of t3 $expected = [ 't1' => [1, 16, 0], 't2' => [2, 3, 1], @@ -577,6 +640,9 @@ public function testMakeRoomForLeaf() } } + /** + * @return void + */ public function testFixLevels() { $fixtures = $this->initTree(); @@ -585,7 +651,7 @@ public function testFixLevels() $node->setLevel(null)->save(); } // fix the levels - \NestedSetTable9Query::fixLevels(); + NestedSetTable9Query::fixLevels(); $expected = [ 't1' => [1, 14, 0], 't2' => [2, 3, 1], @@ -597,7 +663,7 @@ public function testFixLevels() ]; $this->assertEquals($expected, $this->dumpTree(), 'fixLevels() fixes the levels correctly'); - \NestedSetTable9Query::fixLevels(); + NestedSetTable9Query::fixLevels(); $this->assertEquals($expected, $this->dumpTree(), 'fixLevels() can be called several times'); } } diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifierWithScopeTest.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifierWithScopeTest.php index d81158d9d4..86a6616f43 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifierWithScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifierWithScopeTest.php @@ -10,6 +10,9 @@ namespace Propel\Tests\Generator\Behavior\NestedSet; +use Map\NestedSetTable10TableMap; +use NestedSetTable10; +use NestedSetTable10Query; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Collection\ObjectCollection; @@ -20,9 +23,12 @@ */ class NestedSetBehaviorQueryBuilderModifierWithScopeTest extends TestCase { + /** + * @return void + */ public function testTreeRoots() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -37,15 +43,18 @@ public function testTreeRoots() | \ t9 t10 */ - $objs = \NestedSetTable10Query::create() + $objs = NestedSetTable10Query::create() ->treeRoots() ->find(); $this->assertEquals([$t1, $t8], iterator_to_array($objs), 'treeRoots() filters by roots'); } + /** + * @return void + */ public function testInTree() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -60,21 +69,24 @@ public function testInTree() | \ t9 t10 */ - $tree = \NestedSetTable10Query::create() + $tree = NestedSetTable10Query::create() ->inTree(1) ->orderByBranch() ->find(); $this->assertEquals([$t1, $t2, $t3, $t4, $t5, $t6, $t7], iterator_to_array($tree), 'inTree() filters by node'); - $tree = \NestedSetTable10Query::create() + $tree = NestedSetTable10Query::create() ->inTree(2) ->orderByBranch() ->find(); $this->assertEquals([$t8, $t9, $t10], iterator_to_array($tree), 'inTree() filters by node'); } + /** + * @return void + */ public function testDescendantsOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -89,16 +101,19 @@ public function testDescendantsOf() | \ t9 t10 */ - $objs = \NestedSetTable10Query::create() + $objs = NestedSetTable10Query::create() ->descendantsOf($t1) ->orderByBranch() ->find(); $this->assertEquals([$t2, $t3, $t4, $t5, $t6, $t7], iterator_to_array($objs), 'descendantsOf() filters by descendants of the same scope'); } + /** + * @return void + */ public function testBranchOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -113,17 +128,19 @@ public function testBranchOf() | \ t9 t10 */ - $objs = \NestedSetTable10Query::create() + $objs = NestedSetTable10Query::create() ->branchOf($t1) ->orderByBranch() ->find(); $this->assertEquals([$t1, $t2, $t3, $t4, $t5, $t6, $t7], iterator_to_array($objs), 'branchOf() filters by branch of the same scope'); - } + /** + * @return void + */ public function testChildrenOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -138,16 +155,19 @@ public function testChildrenOf() | \ t9 t10 */ - $objs = \NestedSetTable10Query::create() + $objs = NestedSetTable10Query::create() ->childrenOf($t1) ->orderByBranch() ->find(); $this->assertEquals([$t2, $t3], iterator_to_array($objs), 'childrenOf() filters by children of the same scope'); } + /** + * @return void + */ public function testSiblingsOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -162,7 +182,7 @@ public function testSiblingsOf() | \ t9 t10 */ - $desc = \NestedSetTable10Query::create() + $desc = NestedSetTable10Query::create() ->siblingsOf($t3) ->orderByBranch() ->find(); @@ -171,10 +191,12 @@ public function testSiblingsOf() /** * @todo, fix this test + * + * @return void */ public function testAncestorsOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -189,7 +211,7 @@ public function testAncestorsOf() | \ t9 t10 */ - $objs = \NestedSetTable10Query::create() + $objs = NestedSetTable10Query::create() ->ancestorsOf($t5) ->orderByBranch() ->find(); @@ -198,10 +220,12 @@ public function testAncestorsOf() /** * @todo, fix this test + * + * @return void */ public function testRootsOf() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -216,19 +240,22 @@ public function testRootsOf() | \ t9 t10 */ - $objs = \NestedSetTable10Query::create() + $objs = NestedSetTable10Query::create() ->rootsOf($t5) ->orderByBranch() ->find(); $coll = $this->buildCollection([$t1, $t3, $t5], 'rootsOf() filters by ancestors of the same scope'); } + /** + * @return void + */ public function testFindRoot() { $this->assertTrue(method_exists('NestedSetTable10Query', 'findRoot'), 'nested_set adds a findRoot() method'); - \NestedSetTable10Query::create()->deleteAll(); - $this->assertNull(\NestedSetTable10Query::create()->findRoot(1), 'findRoot() returns null as long as no root node is defined'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + NestedSetTable10Query::create()->deleteAll(); + $this->assertNull(NestedSetTable10Query::create()->findRoot(1), 'findRoot() returns null as long as no root node is defined'); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -243,13 +270,16 @@ public function testFindRoot() | \ t9 t10 */ - $this->assertEquals($t1, \NestedSetTable10Query::create()->findRoot(1), 'findRoot() returns a tree root'); - $this->assertEquals($t8, \NestedSetTable10Query::create()->findRoot(2), 'findRoot() returns a tree root'); + $this->assertEquals($t1, NestedSetTable10Query::create()->findRoot(1), 'findRoot() returns a tree root'); + $this->assertEquals($t8, NestedSetTable10Query::create()->findRoot(2), 'findRoot() returns a tree root'); } + /** + * @return void + */ public function testFindRoots() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -264,14 +294,17 @@ public function testFindRoots() | \ t9 t10 */ - $objs = \NestedSetTable10Query::create() + $objs = NestedSetTable10Query::create() ->findRoots(); $this->assertEquals([$t1, $t8], iterator_to_array($objs), 'findRoots() returns all root objects'); } + /** + * @return void + */ public function testFindTree() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -286,9 +319,9 @@ public function testFindTree() | \ t9 t10 */ - $tree = \NestedSetTable10Query::create()->findTree(1); + $tree = NestedSetTable10Query::create()->findTree(1); $this->assertEquals([$t1, $t2, $t3, $t4, $t5, $t6, $t7], iterator_to_array($tree), 'findTree() retrieves the tree of a scope, ordered by branch'); - $tree = \NestedSetTable10Query::create()->findTree(2); + $tree = NestedSetTable10Query::create()->findTree(2); $this->assertEquals([$t8, $t9, $t10], iterator_to_array($tree), 'findTree() retrieves the tree of a scope, ordered by branch'); } @@ -301,6 +334,9 @@ protected function buildCollection($arr) return $coll; } + /** + * @return void + */ public function testRetrieveRoots() { $this->assertTrue( @@ -312,7 +348,7 @@ public function testRetrieveRoots() "nested_set does not add a retrieveRoots() method for trees that don't use scope" ); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -327,37 +363,43 @@ public function testRetrieveRoots() | \ t9 t10 */ - $this->assertEquals([$t1, $t8], \NestedSetTable10Query::retrieveRoots()->getArrayCopy(), 'retrieveRoots() returns the tree roots'); + $this->assertEquals([$t1, $t8], NestedSetTable10Query::retrieveRoots()->getArrayCopy(), 'retrieveRoots() returns the tree roots'); $c = new Criteria(); - $c->add(\Map\NestedSetTable10TableMap::COL_TITLE, 't1'); - $this->assertEquals([$t1], \NestedSetTable10Query::retrieveRoots($c)->getArrayCopy(), 'retrieveRoots() accepts a Criteria as first parameter'); + $c->add(NestedSetTable10TableMap::COL_TITLE, 't1'); + $this->assertEquals([$t1], NestedSetTable10Query::retrieveRoots($c)->getArrayCopy(), 'retrieveRoots() accepts a Criteria as first parameter'); } + /** + * @return void + */ public function testRetrieveRoot() { $this->assertTrue(method_exists('NestedSetTable10Query', 'retrieveRoot'), 'nested_set adds a retrieveRoot() method'); - \Map\NestedSetTable10TableMap::doDeleteAll(); + NestedSetTable10TableMap::doDeleteAll(); - $t1 = new \NestedSetTable10(); + $t1 = new NestedSetTable10(); $t1->setLeftValue(1); $t1->setRightValue(2); $t1->setScopeValue(2); $t1->save(); - $this->assertNull(\NestedSetTable10Query::retrieveRoot(1), 'retrieveRoot() returns null as long as no root node is defined in the required scope'); + $this->assertNull(NestedSetTable10Query::retrieveRoot(1), 'retrieveRoot() returns null as long as no root node is defined in the required scope'); - $t2 = new \NestedSetTable10(); + $t2 = new NestedSetTable10(); $t2->setLeftValue(1); $t2->setRightValue(2); $t2->setScopeValue(1); $t2->save(); - $this->assertEquals(\NestedSetTable10Query::retrieveRoot(1), $t2, 'retrieveRoot() retrieves the root node in the required scope'); + $this->assertEquals(NestedSetTable10Query::retrieveRoot(1), $t2, 'retrieveRoot() retrieves the root node in the required scope'); } + /** + * @return void + */ public function testRetrieveTree() { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + [$t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10] = $this->initTreeWithScope(); /* Tree used for tests Scope 1 t1 @@ -372,20 +414,23 @@ public function testRetrieveTree() | \ t9 t10 */ - $tree = \NestedSetTable10Query::retrieveTree(1); + $tree = NestedSetTable10Query::retrieveTree(1); $this->assertEquals([$t1, $t2, $t3, $t4, $t5, $t6, $t7], $tree->getArrayCopy(), 'retrieveTree() retrieves the scoped tree'); - $tree = \NestedSetTable10Query::retrieveTree(2); + $tree = NestedSetTable10Query::retrieveTree(2); $this->assertEquals([$t8, $t9, $t10], $tree->getArrayCopy(), 'retrieveTree() retrieves the scoped tree'); $c = new Criteria(); - $c->add(\NestedSetTable10::LEFT_COL, 4, Criteria::GREATER_EQUAL); - $tree = \NestedSetTable10Query::retrieveTree(1, $c); + $c->add(NestedSetTable10::LEFT_COL, 4, Criteria::GREATER_EQUAL); + $tree = NestedSetTable10Query::retrieveTree(1, $c); $this->assertEquals([$t3, $t4, $t5, $t6, $t7], $tree->getArrayCopy(), 'retrieveTree() accepts a Criteria as first parameter'); } + /** + * @return void + */ public function testDeleteTree() { $this->initTreeWithScope(); - \NestedSetTable10Query::deleteTree(1); + NestedSetTable10Query::deleteTree(1); $expected = [ 't8' => [1, 6, 0], 't9' => [2, 3, 1], @@ -394,12 +439,15 @@ public function testDeleteTree() $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'deleteTree() does not delete anything out of the scope'); } + /** + * @return void + */ public function testShiftRLValues() { $this->assertTrue(method_exists('NestedSetTable10Query', 'shiftRLValues'), 'nested_set adds a shiftRLValues() method'); $this->initTreeWithScope(); - \NestedSetTable10Query::shiftRLValues(1, 100, null, 1); - \Map\NestedSetTable10TableMap::clearInstancePool(); + NestedSetTable10Query::shiftRLValues(1, 100, null, 1); + NestedSetTable10TableMap::clearInstancePool(); $expected = [ 't1' => [1, 14, 0], 't2' => [2, 3, 1], @@ -417,8 +465,8 @@ public function testShiftRLValues() ]; $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'shiftRLValues does not shift anything out of the scope'); $this->initTreeWithScope(); - \NestedSetTable10Query::shiftRLValues(1, 1, null, 1); - \Map\NestedSetTable10TableMap::clearInstancePool(); + NestedSetTable10Query::shiftRLValues(1, 1, null, 1); + NestedSetTable10TableMap::clearInstancePool(); $expected = [ 't1' => [2, 15, 0], 't2' => [3, 4, 1], @@ -436,8 +484,8 @@ public function testShiftRLValues() ]; $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'shiftRLValues does not shift anything out of the scope'); $this->initTreeWithScope(); - \NestedSetTable10Query::shiftRLValues(-1, 1, null, 1); - \Map\NestedSetTable10TableMap::clearInstancePool(); + NestedSetTable10Query::shiftRLValues(-1, 1, null, 1); + NestedSetTable10TableMap::clearInstancePool(); $expected = [ 't1' => [0, 13, 0], 't2' => [1, 2, 1], @@ -447,7 +495,7 @@ public function testShiftRLValues() 't6' => [7, 8, 3], 't7' => [9, 10, 3], ]; - $this->assertEquals($expected, $this->dumpTreeWithScope(1),'shiftRLValues can shift all nodes to the left'); + $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'shiftRLValues can shift all nodes to the left'); $expected = [ 't8' => [1, 6, 0], 't9' => [2, 3, 1], @@ -455,8 +503,8 @@ public function testShiftRLValues() ]; $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'shiftRLValues does not shift anything out of the scope'); $this->initTreeWithScope(); - \NestedSetTable10Query::shiftRLValues(1, 5, null, 1); - \Map\NestedSetTable10TableMap::clearInstancePool(); + NestedSetTable10Query::shiftRLValues(1, 5, null, 1); + NestedSetTable10TableMap::clearInstancePool(); $expected = [ 't1' => [1, 15, 0], 't2' => [2, 3, 1], @@ -475,11 +523,14 @@ public function testShiftRLValues() $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'shiftRLValues does not shift anything out of the scope'); } + /** + * @return void + */ public function testShiftLevel() { $this->initTreeWithScope(); - \NestedSetTable10Query::shiftLevel($delta = 1, $first = 7, $last = 12, $scope = 1); - \Map\NestedSetTable10TableMap::clearInstancePool(); + NestedSetTable10Query::shiftLevel($delta = 1, $first = 7, $last = 12, $scope = 1); + NestedSetTable10TableMap::clearInstancePool(); $expected = [ 't1' => [1, 14, 0], 't2' => [2, 3, 1], @@ -498,6 +549,9 @@ public function testShiftLevel() $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'shiftLevel does not shift anything out of the scope'); } + /** + * @return void + */ public function testMakeRoomForLeaf() { $this->assertTrue(method_exists('NestedSetTable10Query', 'makeRoomForLeaf'), 'nested_set adds a makeRoomForLeaf() method'); @@ -516,7 +570,7 @@ public function testMakeRoomForLeaf() | \ t9 t10 */ - $t = \NestedSetTable10Query::makeRoomForLeaf(5, 1); // first child of t3 + $t = NestedSetTable10Query::makeRoomForLeaf(5, 1); // first child of t3 $expected = [ 't1' => [1, 16, 0], 't2' => [2, 3, 1], diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorTest.php index 8564fad260..a3f161dc37 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorTest.php @@ -10,6 +10,9 @@ namespace Propel\Tests\Generator\Behavior\NestedSet; +use Map\NestedSetTable10TableMap; +use Map\NestedSetTable9TableMap; + /** * Tests for NestedSetBehavior class * @@ -17,9 +20,12 @@ */ class NestedSetBehaviorTest extends TestCase { + /** + * @return void + */ public function testDefault() { - $table9 = \Map\NestedSetTable9TableMap::getTableMap(); + $table9 = NestedSetTable9TableMap::getTableMap(); $this->assertEquals(count($table9->getColumns()), 5, 'nested_set adds three column by default'); $this->assertTrue(method_exists('NestedSetTable9', 'getTreeLeft'), 'nested_set adds a tree_left column by default'); @@ -30,12 +36,14 @@ public function testDefault() $this->assertTrue(method_exists('NestedSetTable9', 'getLevel'), 'nested_set maps the level getter with the tree_level column'); $this->assertFalse(method_exists('NestedSetTable9', 'getTreeScope'), 'nested_set does not add a tree_scope column by default'); $this->assertFalse(method_exists('NestedSetTable9', 'getScopeValue'), 'nested_set does not map the scope_value getter with the tree_scope column by default'); - } + /** + * @return void + */ public function testParameters() { - $table10 = \Map\NestedSetTable10TableMap::getTableMap(); + $table10 = NestedSetTable10TableMap::getTableMap(); $this->assertEquals(count($table10->getColumns()), 6, 'nested_set does not add columns when they already exist'); $this->assertTrue(method_exists('NestedSetTable10', 'getLeftValue'), 'nested_set maps the left_value getter with the tree_left column'); diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/TestCase.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/TestCase.php index a9f170448d..ca86683640 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/TestCase.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/TestCase.php @@ -10,6 +10,12 @@ namespace Propel\Tests\Generator\Behavior\NestedSet; +use Fixtures\PublicTable10; +use Fixtures\PublicTable9; +use Map\NestedSetTable10TableMap; +use Map\NestedSetTable9TableMap; +use NestedSetTable10Query; +use NestedSetTable9Query; use Propel\Generator\Util\QuickBuilder; use Propel\Tests\TestCase as BaseTestCase; @@ -20,6 +26,9 @@ class TestCase extends BaseTestCase { protected $con; + /** + * @return void + */ public function setUp(): void { if (!class_exists('NestedSetTable9')) { @@ -57,31 +66,31 @@ public function setUp(): void protected function initTreeWithScope() { - \Map\NestedSetTable10TableMap::doDeleteAll(); + NestedSetTable10TableMap::doDeleteAll(); $ret = []; $fixtures = [ - 't1' => [1, 14, 0, 1], - 't2' => [2, 3, 1, 1], - 't3' => [4, 13, 1, 1], - 't4' => [5, 6, 2, 1], - 't5' => [7, 12, 2, 1], - 't6' => [8, 9, 3, 1], - 't7' => [10, 11, 3, 1], - 't8' => [1, 6, 0, 2], - 't9' => [2, 3, 1, 2], - 't10' => [4, 5, 1, 2], + 't1' => [1, 14, 0, 1], + 't2' => [2, 3, 1, 1], + 't3' => [4, 13, 1, 1], + 't4' => [5, 6, 2, 1], + 't5' => [7, 12, 2, 1], + 't6' => [8, 9, 3, 1], + 't7' => [10, 11, 3, 1], + 't8' => [1, 6, 0, 2], + 't9' => [2, 3, 1, 2], + 't10' => [4, 5, 1, 2], ]; foreach ($fixtures as $key => $data) { - $t = new Fixtures\PublicTable10(); + $t = new PublicTable10(); $t->setTitle($key); $t->setLeftValue($data[0]); $t->setRightValue($data[1]); $t->setLevel($data[2]); $t->setScopeValue($data[3]); $t->save(); - $ret []= $t; + $ret[] = $t; } return $ret; @@ -90,16 +99,16 @@ protected function initTreeWithScope() /** * Tree used for tests * t1 - * | \ + * | \ * t2 t3 - * | \ + * | \ * t4 t5 - * | \ + * | \ * t6 t7 */ protected function initTree() { - \Map\NestedSetTable9TableMap::doDeleteAll(); + NestedSetTable9TableMap::doDeleteAll(); $ret = []; // shuffling the results so the db order is not the natural one @@ -122,13 +131,13 @@ protected function initTree() 't7' => array(10, 11, 3), */ foreach ($fixtures as $key => $data) { - $t = new Fixtures\PublicTable9(); + $t = new PublicTable9(); $t->setTitle($key); $t->setLeftValue($data[0]); $t->setRightValue($data[1]); $t->setLevel($data[2]); $t->save(); - $ret[$key]= $t; + $ret[$key] = $t; } // reordering the results in the fixtures ksort($ret); @@ -138,7 +147,7 @@ protected function initTree() protected function dumpTree() { - return $this->dumpNodes(\NestedSetTable9Query::create()->orderByTitle()->find()); + return $this->dumpNodes(NestedSetTable9Query::create()->orderByTitle()->find()); } protected function dumpNodes($nodes) @@ -157,6 +166,6 @@ protected function dumpNodes($nodes) protected function dumpTreeWithScope($scope) { - return $this->dumpNodes(\NestedSetTable10Query::create()->filterByMyScopeColumn($scope)->orderByTitle()->find()); + return $this->dumpNodes(NestedSetTable10Query::create()->filterByMyScopeColumn($scope)->orderByTitle()->find()); } } diff --git a/tests/Propel/Tests/Generator/Behavior/ObjectBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/ObjectBehaviorTest.php index 145f105c1e..83af4e8ddd 100644 --- a/tests/Propel/Tests/Generator/Behavior/ObjectBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/ObjectBehaviorTest.php @@ -10,6 +10,7 @@ namespace Propel\Tests\Generator\Behavior; +use Propel\Tests\Bookstore\Behavior\Base\testObjectFilter; use Propel\Tests\Bookstore\Behavior\Table3; use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; @@ -22,6 +23,9 @@ */ class ObjectBehaviorTest extends BookstoreTestBase { + /** + * @return void + */ protected function setUp(): void { //prevent issue DSN not Found @@ -29,12 +33,18 @@ protected function setUp(): void parent::setUp(); } + /** + * @return void + */ public function testObjectAttributes() { $t = new Table3(); $this->assertEquals($t->customAttribute, 1, 'objectAttributes hook is called when adding attributes'); } + /** + * @return void + */ public function testPreSave() { $t = new Table3(); @@ -49,6 +59,9 @@ public function testPreSave() $this->assertEquals($t->preSave, 1, 'preSave hook is called on object modification'); } + /** + * @return void + */ public function testPostSave() { $t = new Table3(); @@ -63,6 +76,9 @@ public function testPostSave() $this->assertEquals($t->postSave, 1, 'postSave hook is called on object modification'); } + /** + * @return void + */ public function testObjectBuilderPreInsert() { $t = new Table3(); @@ -77,6 +93,9 @@ public function testObjectBuilderPreInsert() $this->assertEquals($t->preInsert, 0, 'preInsert hook is not called on object modification'); } + /** + * @return void + */ public function testPostInsert() { $t = new Table3(); @@ -91,6 +110,9 @@ public function testPostInsert() $this->assertEquals($t->postInsert, 0, 'postInsert hook is not called on object modification'); } + /** + * @return void + */ public function testPreUpdate() { $t = new Table3(); @@ -105,6 +127,9 @@ public function testPreUpdate() $this->assertFalse($t->preUpdateIsAfterSave, 'preUpdate hook is called before save'); } + /** + * @return void + */ public function testPostUpdate() { $t = new Table3(); @@ -119,6 +144,9 @@ public function testPostUpdate() $this->assertTrue($t->postUpdateIsAfterSave, 'postUpdate hook is called after save'); } + /** + * @return void + */ public function testPreDelete() { $t = new Table3(); @@ -130,6 +158,9 @@ public function testPreDelete() $this->assertTrue($t->preDeleteIsBeforeDelete, 'preDelete hook is called before deletion'); } + /** + * @return void + */ public function testPostDelete() { $t = new Table3(); @@ -141,6 +172,9 @@ public function testPostDelete() $this->assertFalse($t->postDeleteIsBeforeDelete, 'postDelete hook is called before deletion'); } + /** + * @return void + */ public function testObjectMethods() { $t = new Table3(); @@ -148,19 +182,28 @@ public function testObjectMethods() $this->assertEquals('Propel\Generator\Builder\Om\ObjectBuilder', $t->hello(), 'objectMethods hook is called with the object builder as parameter'); } + /** + * @return void + */ public function testObjectCall() { $t = new Table3(); $this->assertEquals('bar', $t->foo(), 'objectCall hook is called when building the magic __call()'); } + /** + * @return void + */ public function testObjectFilter() { $t = new Table3(); - $this->assertTrue(class_exists('Propel\Tests\Bookstore\Behavior\Base\testObjectFilter'), + $this->assertTrue( + class_exists('Propel\Tests\Bookstore\Behavior\Base\testObjectFilter'), 'objectFilter hook allows complete manipulation of the generated script' ); - $this->assertEquals('Propel\Generator\Builder\Om\ObjectBuilder', \Propel\Tests\Bookstore\Behavior\Base\testObjectFilter::FOO, + $this->assertEquals( + 'Propel\Generator\Builder\Om\ObjectBuilder', + testObjectFilter::FOO, 'objectFilter hook is called with the object builder as parameter' ); } diff --git a/tests/Propel/Tests/Generator/Behavior/QueryBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/QueryBehaviorTest.php index d8a64dc52d..22376aad9e 100644 --- a/tests/Propel/Tests/Generator/Behavior/QueryBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/QueryBehaviorTest.php @@ -10,7 +10,7 @@ namespace Propel\Tests\Generator\Behavior; -use Propel\Runtime\Propel; +use Propel\Tests\Bookstore\Behavior\Base\testQueryFilter; use Propel\Tests\Bookstore\Behavior\Table3Query; use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; @@ -23,6 +23,9 @@ */ class QueryBehaviorTest extends BookstoreTestBase { + /** + * @return void + */ public function testStaticAttributes() { $this->assertEquals(Table3Query::$customStaticAttribute, 1, 'staticAttributes hook is called when adding attributes'); @@ -33,6 +36,9 @@ public function testStaticAttributes() ); } + /** + * @return void + */ public function testStaticMethods() { $this->assertTrue( @@ -46,13 +52,19 @@ public function testStaticMethods() ); } + /** + * @return void + */ public function testQueryFilter() { class_exists('Propel\Tests\Bookstore\Behavior\Table3Query'); //trigger autoload - $this->assertTrue(class_exists('Propel\Tests\Bookstore\Behavior\Base\testQueryFilter'), + $this->assertTrue( + class_exists('Propel\Tests\Bookstore\Behavior\Base\testQueryFilter'), 'queryFilter hook allows complete manipulation of the generated script' ); - $this->assertEquals('Propel\Generator\Builder\Om\QueryBuilder', \Propel\Tests\Bookstore\Behavior\Base\testQueryFilter::FOO, + $this->assertEquals( + 'Propel\Generator\Builder\Om\QueryBuilder', + testQueryFilter::FOO, 'queryFilter hook is called with the query builder as parameter' ); } diff --git a/tests/Propel/Tests/Generator/Behavior/QueryCache/QueryCacheTest.php b/tests/Propel/Tests/Generator/Behavior/QueryCache/QueryCacheTest.php index 8259a3c201..8ffcf15866 100644 --- a/tests/Propel/Tests/Generator/Behavior/QueryCache/QueryCacheTest.php +++ b/tests/Propel/Tests/Generator/Behavior/QueryCache/QueryCacheTest.php @@ -10,8 +10,10 @@ namespace Propel\Tests\Generator\Behavior\QueryCache; -use Propel\Runtime\Util\PropelModelPager; +use Exception; use Propel\Runtime\Collection\ObjectCollection; +use Propel\Runtime\Propel; +use Propel\Runtime\Util\PropelModelPager; use Propel\Tests\Bookstore\Behavior\QuerycacheTable1; use Propel\Tests\Bookstore\Behavior\QuerycacheTable1Query; use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; @@ -25,6 +27,9 @@ */ class QueryCacheTest extends BookstoreTestBase { + /** + * @return void + */ protected function setUp(): void { //prevent issue DSN not Found @@ -32,6 +37,9 @@ protected function setUp(): void parent::setUp(); } + /** + * @return void + */ public function testExistingKey() { $cacheTest = QuerycacheTable1Query::create() @@ -42,6 +50,9 @@ public function testExistingKey() $this->assertTrue(QuerycacheTable1Query::create()->cacheContains('test'), ' cache contains "test" key'); } + /** + * @return void + */ public function testPublicApiExists() { $this->assertTrue(method_exists('Propel\Tests\Bookstore\Behavior\QuerycacheTable1Query', 'setQueryKey'), 'setQueryKey method exists'); @@ -51,45 +62,53 @@ public function testPublicApiExists() $this->assertTrue(method_exists('Propel\Tests\Bookstore\Behavior\QuerycacheTable1Query', 'cacheStore'), 'cacheStore method exists'); } + /** + * @return void + */ public function testCacheGeneratedSql() { $q = QuerycacheTable1Query::create() ->setQueryKey('test2') - ->filterByTitle('bar') - ; + ->filterByTitle('bar'); $exec = $q->find(); - $expectedSql = $this->getSql("SELECT querycache_table1.id, querycache_table1.title FROM querycache_table1 WHERE querycache_table1.title=:p1"); + $expectedSql = $this->getSql('SELECT querycache_table1.id, querycache_table1.title FROM querycache_table1 WHERE querycache_table1.title=:p1'); $params = []; $this->assertTrue(QuerycacheTable1Query::create()->cacheContains('test2'), ' cache contains "test2" key'); $this->assertEquals($expectedSql, $q->cacheFetch('test2')); } + /** + * @return void + */ public function testSimpleCountSql() { - $con = \Propel\Runtime\Propel::getConnection(); + $con = Propel::getConnection(); $con->useDebug(true); $exec = QuerycacheTable1Query::create() ->count($con); - $expectedSql = $this->getSql("SELECT COUNT(*) FROM querycache_table1"); - $renderedSql = \Propel\Runtime\Propel::getConnection()->getLastExecutedQuery(); + $expectedSql = $this->getSql('SELECT COUNT(*) FROM querycache_table1'); + $renderedSql = Propel::getConnection()->getLastExecutedQuery(); $this->assertEquals($expectedSql, $renderedSql); } + /** + * @return void + */ public function testWithPaginate() { QuerycacheTable1Query::create()->deleteAll(); $coll = new ObjectCollection(); $coll->setModel('\Propel\Tests\Bookstore\Behavior\QuerycacheTable1'); - for ($i=0; $i < 5; $i++) { + for ($i = 0; $i < 5; $i++) { $b = new QuerycacheTable1(); $b->setTitle('Title' . $i); - $coll[]= $b; + $coll[] = $b; } $coll->save(); @@ -111,13 +130,16 @@ public function testWithPaginate() $this->assertEquals('Title4', $results[0]->getTitle()); } + /** + * @return void + */ public function testQueryIsNotCachedIfExceptionIsThrown() { $q = QuerycacheTable1Query::create()->setQueryKey('test4')->filterByTitle('bar'); try { $q->withField('wrongField')->find(); - } catch (\Exception $e) { + } catch (Exception $e) { $this->assertTrue(true, 'The exception is correctly thrown'); } diff --git a/tests/Propel/Tests/Generator/Behavior/Sluggable/SluggableBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Sluggable/SluggableBehaviorTest.php index 6aa82c99c1..3f2dcc432e 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sluggable/SluggableBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sluggable/SluggableBehaviorTest.php @@ -10,19 +10,19 @@ namespace Propel\Tests\Generator\Behavior\Sluggable; +use Exception; use Propel\Runtime\Adapter\Pdo\PgsqlAdapter; +use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Propel; -use Propel\Tests\Bookstore\Map\BookTableMap; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; - +use Propel\Tests\Bookstore\Behavior\Map\Table13TableMap; +use Propel\Tests\Bookstore\Behavior\Map\Table14TableMap; use Propel\Tests\Bookstore\Behavior\Table13; use Propel\Tests\Bookstore\Behavior\Table13Query; -use Propel\Tests\Bookstore\Behavior\Map\Table13TableMap; use Propel\Tests\Bookstore\Behavior\Table14; use Propel\Tests\Bookstore\Behavior\Table14Query; -use Propel\Tests\Bookstore\Behavior\Map\Table14TableMap; use Propel\Tests\Bookstore\Behavior\TableWithScope; use Propel\Tests\Bookstore\Behavior\TableWithScopeQuery; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Tests for SluggableBehavior class @@ -33,15 +33,20 @@ */ class SluggableBehaviorTest extends BookstoreTestBase { + /** + * @return void + */ protected function setUp(): void { //prevent issue DSN not Found self::$isInitialized = false; parent::setUp(); - include_once(__DIR__.'/SluggableBehaviorTestClasses.php'); + include_once(__DIR__ . '/SluggableBehaviorTestClasses.php'); } - + /** + * @return void + */ public function testParameters() { $table13 = Table13TableMap::getTableMap(); @@ -53,6 +58,9 @@ public function testParameters() $this->assertTrue(method_exists('\Propel\Tests\Bookstore\Behavior\Table14', 'getSlug'), 'Sluggable adds a standard getter for the slug column'); } + /** + * @return void + */ public function testObjectGetter() { $this->assertTrue(method_exists('\Propel\Tests\Bookstore\Behavior\Table13', 'getSlug'), 'Sluggable adds a getter for the slug column'); @@ -65,6 +73,9 @@ public function testObjectGetter() $this->assertEquals('foo', $t->getSlug(), 'getSlug() returns the object slug'); } + /** + * @return void + */ public function testObjectSetter() { $this->assertTrue(method_exists('\Propel\Tests\Bookstore\Behavior\Table13', 'setSlug'), 'Sluggable adds a setter for the slug column'); @@ -77,6 +88,9 @@ public function testObjectSetter() $this->assertEquals('foo', $t->getUrl(), 'setSlug() sets the object slug'); } + /** + * @return void + */ public function testObjectCreateRawSlug() { $t = new TestableTable13(); @@ -107,6 +121,8 @@ public static function cleanupSlugProvider() /** * @dataProvider cleanupSlugProvider + * + * @return void */ public function testObjectCleanupSlugPart($in, $out) { @@ -129,6 +145,8 @@ public static function limitSlugSizeProvider() /** * @dataProvider limitSlugSizeProvider + * + * @return void */ public function testObjectLimitSlugSize($in, $out) { @@ -136,6 +154,9 @@ public function testObjectLimitSlugSize($in, $out) $this->assertEquals($out, $t->limitSlugSize($in), 'limitSlugsize() limits the slug size'); } + /** + * @return void + */ public function testObjectMakeSlugUnique() { Table13Query::create()->deleteAll(); @@ -155,6 +176,9 @@ public function testObjectMakeSlugUnique() $this->assertEquals('foo-2', $t->makeSlugUnique('foo'), 'makeSlugUnique() returns an incremented input when it already exists'); } + /** + * @return void + */ public function testObjectCreateSlug() { Table13Query::create()->deleteAll(); @@ -180,6 +204,9 @@ public function testObjectCreateSlug() $this->assertEquals('/foo/hello-world/bar/1', $t->createSlug(), 'createSlug() returns a unique slug'); } + /** + * @return void + */ public function testObjectPreSave() { Table14Query::create()->deleteAll(); @@ -206,6 +233,9 @@ public function testObjectPreSave() $this->assertEquals('/foo/custom/bar/1', $t->getSlug(), 'preSave() uses the given slug if it exists and makes it unique'); } + /** + * @return void + */ public function testObjectSlugLifecycle() { Table13Query::create()->deleteAll(); @@ -231,6 +261,9 @@ public function testObjectSlugLifecycle() $this->assertEquals('/foo/hello-world2/bar', $t->getSlug(), 'setSlug(null) relaunches the slug generation'); } + /** + * @return void + */ public function testObjectSlugAutoUpdate() { Table13Query::create()->deleteAll(); @@ -247,6 +280,9 @@ public function testObjectSlugAutoUpdate() $this->assertEquals('hello-bar', $t->getSlug(), 'preSave() does not autoupdate slug when it was set by the user'); } + /** + * @return void + */ public function testObjectSlugAutoUpdatePermanent() { Table14Query::create()->deleteAll(); @@ -262,6 +298,9 @@ public function testObjectSlugAutoUpdatePermanent() $this->assertEquals('hello-bar', $t->getSlug(), 'setSlug() still works for permanent slugs'); } + /** + * @return void + */ public function testQueryFindOneBySlug() { $this->assertFalse(method_exists('\Propel\Tests\Bookstore\Behavior\Table13Query', 'findOneBySlug'), 'The generated query does not provide a findOneBySlug() method if the slug column is "slug".'); @@ -278,6 +317,9 @@ public function testQueryFindOneBySlug() $this->assertEquals($t1, $t, 'findOneBySlug() returns a single object matching the slug'); } + /** + * @return void + */ public function testUniqueViolationWithoutScope() { $this->markTestSkipped('Skipping...'); @@ -288,14 +330,16 @@ public function testUniqueViolationWithoutScope() $t->save(); $this->assertEquals('hello-world', $t->getSlug()); - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); $t = new TableWithScope(); $t->setTitle('Hello, World'); $t->save(); - } + /** + * @return void + */ public function testNoUniqueViolationWithScope() { TableWithScopeQuery::create()->deleteAll(); @@ -311,11 +355,14 @@ public function testNoUniqueViolationWithScope() $t->save(); $this->assertEquals('hello-world', $t->getSlug()); - } catch (\Exception $e) { + } catch (Exception $e) { $this->fail($e->getMessage()); } } + /** + * @return void + */ public function testNumberOfQueriesForMakeUniqSlug() { Table13Query::create()->deleteAll(); @@ -327,7 +374,7 @@ public function testNumberOfQueriesForMakeUniqSlug() $expectedCount++; //because of the SELECT nextval(...) query } - for ($i=0; $i < 5; $i++) { + for ($i = 0; $i < 5; $i++) { $nbQuery = $con->getQueryCount(); $t = new Table13(); @@ -338,12 +385,15 @@ public function testNumberOfQueriesForMakeUniqSlug() } } + /** + * @return void + */ public function testSlugRegexp() { Table13Query::create()->deleteAll(); $con = Propel::getServiceContainer()->getConnection(Table13TableMap::DATABASE_NAME); - for ($i=0; $i < 3; $i++) { + for ($i = 0; $i < 3; $i++) { $t = new Table13(); $t->setTitle('Hello, World'); $t->save($con); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierTest.php index 0c04400542..b458d67e84 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierTest.php @@ -10,9 +10,9 @@ namespace Propel\Tests\Generator\Behavior\Sortable; -use Propel\Tests\Bookstore\Behavior\SortableTable11Query; use Propel\Tests\Bookstore\Behavior\Map\SortableTable11TableMap; use Propel\Tests\Bookstore\Behavior\SortableTable11 as Table11; +use Propel\Tests\Bookstore\Behavior\SortableTable11Query; /** * Tests for SortableBehavior class @@ -23,6 +23,9 @@ */ class SortableBehaviorObjectBuilderModifierTest extends TestCase { + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -30,6 +33,9 @@ public function setUp(): void $this->populateTable11(); } + /** + * @return void + */ public function testPreInsert() { SortableTable11TableMap::doDeleteAll(); @@ -42,6 +48,9 @@ public function testPreInsert() $this->assertEquals($t2->getRank(), 2, 'Sortable inserts new line in last position'); } + /** + * @return void + */ public function testPreDelete() { $max = SortableTable11Query::create()->getMaxRank(); @@ -52,6 +61,9 @@ public function testPreDelete() $this->assertEquals(3, $t4->getRank(), 'Sortable rearrange subsequent rows on delete'); } + /** + * @return void + */ public function testIsFirst() { $first = SortableTable11Query::retrieveByRank(1); @@ -62,6 +74,9 @@ public function testIsFirst() $this->assertFalse($last->isFirst(), 'isFirst() returns false for the last in the rank'); } + /** + * @return void + */ public function testIsLast() { $first = SortableTable11Query::retrieveByRank(1); @@ -72,6 +87,9 @@ public function testIsLast() $this->assertTrue($last->isLast(), 'isLast() returns true for the last in the rank'); } + /** + * @return void + */ public function testGetNext() { $t = SortableTable11Query::retrieveByRank(3); @@ -81,6 +99,9 @@ public function testGetNext() $this->assertNull($t->getNext(), 'getNext() returns null for the last object'); } + /** + * @return void + */ public function testGetPrevious() { $t = SortableTable11Query::retrieveByRank(3); @@ -90,6 +111,9 @@ public function testGetPrevious() $this->assertNull($t->getPrevious(), 'getPrevious() returns null for the first object'); } + /** + * @return void + */ public function testInsertAtRank() { $t = new Table11(); @@ -102,6 +126,9 @@ public function testInsertAtRank() $this->assertEquals($expected, $this->getFixturesArray(), 'insertAtRank() shifts the entire suite'); } + /** + * @return void + */ public function testInsertAtMaxRankPlusOne() { $t = new Table11(); @@ -115,6 +142,8 @@ public function testInsertAtMaxRankPlusOne() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testInsertAtNegativeRank() { @@ -124,6 +153,8 @@ public function testInsertAtNegativeRank() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testInsertAtOverMaxRank() { @@ -131,6 +162,9 @@ public function testInsertAtOverMaxRank() $t->insertAtRank(6); } + /** + * @return void + */ public function testInsertAtBottom() { $t = new Table11(); @@ -143,6 +177,9 @@ public function testInsertAtBottom() $this->assertEquals($expected, $this->getFixturesArray(), 'insertAtBottom() does not shift the entire suite'); } + /** + * @return void + */ public function testInsertAtTop() { $t = new Table11(); @@ -155,6 +192,9 @@ public function testInsertAtTop() $this->assertEquals($expected, $this->getFixturesArray(), 'insertAtTop() shifts the entire suite'); } + /** + * @return void + */ public function testMoveToRank() { $t2 = SortableTable11Query::retrieveByRank(2); @@ -174,6 +214,8 @@ public function testMoveToRank() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testMoveToNewObject() { @@ -183,6 +225,8 @@ public function testMoveToNewObject() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testMoveToNegativeRank() { @@ -192,6 +236,8 @@ public function testMoveToNegativeRank() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testMoveToOverMaxRank() { @@ -199,6 +245,9 @@ public function testMoveToOverMaxRank() $t->moveToRank(5); } + /** + * @return void + */ public function testSwapWith() { $t2 = SortableTable11Query::retrieveByRank(2); @@ -208,6 +257,9 @@ public function testSwapWith() $this->assertEquals($expected, $this->getFixturesArray(), 'swapWith() swaps ranks of the two objects and leaves the other ranks unchanged'); } + /** + * @return void + */ public function testMoveUp() { $t3 = SortableTable11Query::retrieveByRank(3); @@ -223,6 +275,9 @@ public function testMoveUp() $this->assertEquals($expected, $this->getFixturesArray(), 'moveUp() changes nothing when called on the object at the top'); } + /** + * @return void + */ public function testMoveDown() { $t2 = SortableTable11Query::retrieveByRank(2); @@ -238,6 +293,9 @@ public function testMoveDown() $this->assertEquals($expected, $this->getFixturesArray(), 'moveDown() changes nothing when called on the object at the bottom'); } + /** + * @return void + */ public function testMoveToTop() { $t3 = SortableTable11Query::retrieveByRank(3); @@ -250,6 +308,9 @@ public function testMoveToTop() $this->assertEquals($expected, $this->getFixturesArray(), 'moveToTop() changes nothing when called on the top node'); } + /** + * @return void + */ public function testMoveToBottom() { $t2 = SortableTable11Query::retrieveByRank(2); @@ -263,6 +324,9 @@ public function testMoveToBottom() $this->assertEquals($expected, $this->getFixturesArray(), 'moveToBottom() changes nothing when called on the bottom node'); } + /** + * @return void + */ public function testRemoveFromList() { $t2 = SortableTable11Query::retrieveByRank(2); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php index 0cb8c33a1a..067db7e6fc 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php @@ -10,14 +10,13 @@ namespace Propel\Tests\Generator\Behavior\Sortable; -use Propel\Tests\Bookstore\Behavior\SortableMultiScopes; +use Propel\Tests\Bookstore\Behavior\Map\SortableMultiCommaScopesTableMap; use Propel\Tests\Bookstore\Behavior\Map\SortableMultiScopesTableMap; +use Propel\Tests\Bookstore\Behavior\Map\SortableTable12TableMap; use Propel\Tests\Bookstore\Behavior\SortableMultiCommaScopes; -use Propel\Tests\Bookstore\Behavior\Map\SortableMultiCommaScopesTableMap; - +use Propel\Tests\Bookstore\Behavior\SortableMultiScopes; use Propel\Tests\Bookstore\Behavior\SortableTable12 as Table12; use Propel\Tests\Bookstore\Behavior\SortableTable12Query; -use Propel\Tests\Bookstore\Behavior\Map\SortableTable12TableMap; /** * Tests for SortableBehavior class @@ -28,6 +27,9 @@ */ class SortableBehaviorObjectBuilderModifierWithScopeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -35,6 +37,9 @@ public function setUp(): void $this->populateTable12(); } + /** + * @return void + */ public function testPreInsert() { SortableTable12TableMap::doDeleteAll(); @@ -52,6 +57,9 @@ public function testPreInsert() $this->assertEquals($t2->getRank(), 1, 'Sortable inserts new line in last position'); } + /** + * @return void + */ public function testPreDelete() { $max = SortableTable12Query::create()->getMaxRank(1); @@ -64,6 +72,9 @@ public function testPreDelete() $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'delete() leaves other suites unchanged'); } + /** + * @return void + */ public function testIsFirst() { $first = SortableTable12Query::retrieveByRank(1, 1); @@ -78,6 +89,9 @@ public function testIsFirst() $this->assertFalse($last->isFirst(), 'isFirst() returns false for the last in the rank'); } + /** + * @return void + */ public function testIsLast() { $first = SortableTable12Query::retrieveByRank(1, 1); @@ -92,6 +106,9 @@ public function testIsLast() $this->assertTrue($last->isLast(), 'isLast() returns true for the last in the rank'); } + /** + * @return void + */ public function testGetNext() { $t = SortableTable12Query::retrieveByRank(1, 1); @@ -106,6 +123,9 @@ public function testGetNext() $this->assertNull($t->getNext(), 'getNext() returns null for the last object'); } + /** + * @return void + */ public function testGetPrevious() { $t = SortableTable12Query::retrieveByRank(2, 1); @@ -120,6 +140,9 @@ public function testGetPrevious() $this->assertNull($t->getPrevious(), 'getPrevious() returns null for the first object'); } + /** + * @return void + */ public function testInsertAtRank() { $t = new Table12(); @@ -135,6 +158,9 @@ public function testInsertAtRank() $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'insertAtRank() leaves other suites unchanged'); } + /** + * @return void + */ public function testInsertAtRankNoScope() { $t = new Table12(); @@ -153,6 +179,8 @@ public function testInsertAtRankNoScope() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testInsertAtNegativeRank() { @@ -163,6 +191,8 @@ public function testInsertAtNegativeRank() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testInsertAtOverMaxRank() { @@ -171,6 +201,9 @@ public function testInsertAtOverMaxRank() $t->insertAtRank(6); } + /** + * @return void + */ public function testInsertAtBottom() { $t = new Table12(); @@ -186,6 +219,9 @@ public function testInsertAtBottom() $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'insertAtBottom() leaves other suites unchanged'); } + /** + * @return void + */ public function testInsertAtBottomNoScope() { $t = new Table12(); @@ -202,6 +238,9 @@ public function testInsertAtBottomNoScope() $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'insertAtRank() leaves other suites unchanged'); } + /** + * @return void + */ public function testInsertAtTop() { $t = new Table12(); @@ -217,6 +256,9 @@ public function testInsertAtTop() $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'insertAtTop() leaves other suites unchanged'); } + /** + * @return void + */ public function testInsertAtTopNoScope() { $t = new Table12(); @@ -233,6 +275,9 @@ public function testInsertAtTopNoScope() $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'insertAtRank() leaves other suites unchanged'); } + /** + * @return void + */ public function testMoveToRank() { $t2 = SortableTable12Query::retrieveByRank(2, 1); @@ -252,6 +297,9 @@ public function testMoveToRank() $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToRank() can move down'); } + /** + * @return void + */ public function testMoveToRankNoScope() { $t2 = SortableTable12Query::retrieveByRank(2); @@ -275,6 +323,8 @@ public function testMoveToRankNoScope() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testMoveToNewObject() { @@ -284,6 +334,8 @@ public function testMoveToNewObject() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testMoveToNegativeRank() { @@ -293,6 +345,8 @@ public function testMoveToNegativeRank() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testMoveToOverMaxRank() { @@ -300,6 +354,9 @@ public function testMoveToOverMaxRank() $t->moveToRank(5); } + /** + * @return void + */ public function testSwapWith() { $t2 = SortableTable12Query::retrieveByRank(2, 1); @@ -311,6 +368,9 @@ public function testSwapWith() $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'swapWith() leaves other suites unchanged'); } + /** + * @return void + */ public function testSwapWithBetweenScopes() { $t2 = SortableTable12Query::retrieveByRank(2, 1); @@ -324,6 +384,9 @@ public function testSwapWithBetweenScopes() $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'swapWith() leaves rest of suites unchanged'); } + /** + * @return void + */ public function testMoveUp() { $t3 = SortableTable12Query::retrieveByRank(3, 1); @@ -341,6 +404,9 @@ public function testMoveUp() $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveUp() changes nothing when called on the object at the top'); } + /** + * @return void + */ public function testMoveDown() { $t2 = SortableTable12Query::retrieveByRank(2, 1); @@ -358,6 +424,9 @@ public function testMoveDown() $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveDown() changes nothing when called on the object at the bottom'); } + /** + * @return void + */ public function testMoveToTop() { $t3 = SortableTable12Query::retrieveByRank(3, 1); @@ -372,6 +441,9 @@ public function testMoveToTop() $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToTop() changes nothing when called on the top node'); } + /** + * @return void + */ public function testMoveToBottom() { $t2 = SortableTable12Query::retrieveByRank(2, 1); @@ -386,6 +458,9 @@ public function testMoveToBottom() $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToBottom() changes nothing when called on the bottom node'); } + /** + * @return void + */ public function testRemoveFromList() { $t2 = SortableTable12Query::retrieveByRank(2, 1); @@ -406,6 +481,8 @@ public function testRemoveFromList() /** * @expectedException Propel\Runtime\Exception\PropelException + * + * @return void */ public function testRemoveFromListNoScope() { @@ -414,7 +491,7 @@ public function testRemoveFromListNoScope() } /** - * @return SortableMultiScopes[] + * @return \Propel\Tests\Bookstore\Behavior\SortableMultiScopes[] */ private function generateMultipleScopeEntries() { @@ -425,11 +502,11 @@ private function generateMultipleScopeEntries() [ 1, 1, 'item 1'], //1 [ 2, 1, 'item 2'], //1 [ 3, 1, 'item 3'], //1 - [ 3, 1, 'item 3.1'],//2 - [ 1, 1, 'item 1.1'],//2 - [ 1, 1, 'item 1.2'],//3 - [ 1, 2, 'item 1.3'],//1 - [ 1, 2, 'item 1.4'],//2 + [ 3, 1, 'item 3.1'], //2 + [ 1, 1, 'item 1.1'], //2 + [ 1, 1, 'item 1.2'], //3 + [ 1, 2, 'item 1.3'], //1 + [ 1, 2, 'item 1.4'], //2 ]; $result = []; @@ -444,8 +521,9 @@ private function generateMultipleScopeEntries() return $result; } + /** - * @return SortableMultiCommaScopes[] + * @return \Propel\Tests\Bookstore\Behavior\SortableMultiCommaScopes[] */ private function generateMultipleCommaScopeEntries() { @@ -456,11 +534,11 @@ private function generateMultipleCommaScopeEntries() [ 1, 1, 'item 1'], //1 [ 2, 1, 'item 2'], //1 [ 3, 1, 'item 3'], //1 - [ 3, 1, 'item 3.1'],//2 - [ 1, 1, 'item 1.1'],//2 - [ 1, 1, 'item 1.2'],//3 - [ 1, 2, 'item 1.3'],//1 - [ 1, 2, 'item 1.4'],//2 + [ 3, 1, 'item 3.1'], //2 + [ 1, 1, 'item 1.1'], //2 + [ 1, 1, 'item 1.2'], //3 + [ 1, 2, 'item 1.3'], //1 + [ 1, 2, 'item 1.4'], //2 ]; $result = []; @@ -476,9 +554,12 @@ private function generateMultipleCommaScopeEntries() return $result; } + /** + * @return void + */ public function testMultipleScopes() { - list($t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4) = $this->generateMultipleScopeEntries(); + [$t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4] = $this->generateMultipleScopeEntries(); $this->assertEquals($t1->getRank(), 1); $this->assertEquals($t2->getRank(), 1); @@ -490,12 +571,14 @@ public function testMultipleScopes() $this->assertEquals($t1_2->getRank(), 3); $this->assertEquals($t1_3->getRank(), 1); $this->assertEquals($t1_4->getRank(), 2); - } + /** + * @return void + */ public function testMoveMultipleScopes() { - list($t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4) = $this->generateMultipleScopeEntries(); + [$t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4] = $this->generateMultipleScopeEntries(); $this->assertEquals($t1->getRank(), 1); $this->assertEquals($t1_1->getRank(), 2); @@ -522,9 +605,12 @@ public function testMoveMultipleScopes() $this->assertEquals($t1_2->getRank(), 1); } + /** + * @return void + */ public function testDeleteMultipleScopes() { - list($t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4) = $this->generateMultipleScopeEntries(); + [$t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4] = $this->generateMultipleScopeEntries(); $this->assertEquals($t1->getRank(), 1); $this->assertEquals($t1_1->getRank(), 2); @@ -538,9 +624,12 @@ public function testDeleteMultipleScopes() $this->assertEquals($t1_2->getRank(), 2); } + /** + * @return void + */ public function testMultipleCommaScopes() { - list($t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4) = $this->generateMultipleCommaScopeEntries(); + [$t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4] = $this->generateMultipleCommaScopeEntries(); $this->assertEquals($t1->getRank(), 1); $this->assertEquals($t2->getRank(), 1); @@ -554,9 +643,12 @@ public function testMultipleCommaScopes() $this->assertEquals($t1_4->getRank(), 2); } + /** + * @return void + */ public function testMoveMultipleCommaScopes() { - list($t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4) = $this->generateMultipleCommaScopeEntries(); + [$t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4] = $this->generateMultipleCommaScopeEntries(); $this->assertEquals($t1->getRank(), 1); $this->assertEquals($t1_1->getRank(), 2); @@ -583,9 +675,12 @@ public function testMoveMultipleCommaScopes() $this->assertEquals($t1_2->getRank(), 1); } + /** + * @return void + */ public function testDeleteMultipleCommaScopes() { - list($t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4) = $this->generateMultipleCommaScopeEntries(); + [$t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4] = $this->generateMultipleCommaScopeEntries(); $this->assertEquals($t1->getRank(), 1); $this->assertEquals($t1_1->getRank(), 2); @@ -598,5 +693,4 @@ public function testDeleteMultipleCommaScopes() $this->assertEquals($t1_1->getRank(), 1); $this->assertEquals($t1_2->getRank(), 2); } - } diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierTest.php index a905d4bed5..137cd5986e 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierTest.php @@ -12,10 +12,9 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Collection\ObjectCollection; - -use Propel\Tests\Bookstore\Behavior\SortableTable11Query; use Propel\Tests\Bookstore\Behavior\Map\SortableTable11TableMap; use Propel\Tests\Bookstore\Behavior\SortableTable11 as Table11; +use Propel\Tests\Bookstore\Behavior\SortableTable11Query; /** * Tests for SortableBehavior class query modifier @@ -26,6 +25,9 @@ */ class SortableBehaviorQueryBuilderModifierTest extends TestCase { + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -33,6 +35,9 @@ public function setUp(): void $this->populateTable11(); } + /** + * @return void + */ public function testFilterByRank() { $this->assertTrue(SortableTable11Query::create()->filterByRank(1) instanceof SortableTable11Query, 'filterByRank() returns the current query object'); @@ -41,6 +46,9 @@ public function testFilterByRank() $this->assertNull(SortableTable11Query::create()->filterByRank(5)->findOne(), 'filterByRank() filters on the rank, which makes the query return no result on a non-existent rank'); } + /** + * @return void + */ public function testOrderByRank() { $this->assertTrue(SortableTable11Query::create()->orderByRank() instanceof SortableTable11Query, 'orderByRank() returns the current query object'); @@ -60,12 +68,17 @@ public function testOrderByRank() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testOrderByRankIncorrectDirection() { SortableTable11Query::create()->orderByRank('foo'); } + /** + * @return void + */ public function testFindList() { $ts = SortableTable11Query::create()->findList(); @@ -77,6 +90,9 @@ public function testFindList() $this->assertEquals('row4', $ts[3]->getTitle(), 'findList() returns an ordered list'); } + /** + * @return void + */ public function testFindOneByRank() { $this->assertTrue(SortableTable11Query::create()->findOneByRank(1) instanceof Table11, 'findOneByRank() returns an instance of the model object'); @@ -85,6 +101,9 @@ public function testFindOneByRank() $this->assertNull(SortableTable11Query::create()->findOneByRank(5), 'findOneByRank() returns no result on a non-existent rank'); } + /** + * @return void + */ public function testGetMaxRank() { $this->assertEquals(4, SortableTable11Query::create()->getMaxRank(), 'getMaxRank() returns the maximum rank'); @@ -105,12 +124,15 @@ public function testGetMaxRank() $this->assertEquals(1, SortableTable11Query::create()->getMaxRank(), 'getMaxRank() returns the maximum rank'); } + /** + * @return void + */ public function testReorder() { $objects = SortableTable11Query::create()->find(); $ids = []; foreach ($objects as $object) { - $ids[]= $object->getPrimaryKey(); + $ids[] = $object->getPrimaryKey(); } $ranks = [4, 3, 2, 1]; $order = array_combine($ids, $ranks); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierWithScopeTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierWithScopeTest.php index 72cb7090ec..f9725d6e22 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierWithScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierWithScopeTest.php @@ -12,10 +12,9 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Collection\ObjectCollection; - -use Propel\Tests\Bookstore\Behavior\SortableTable12Query; -use Propel\Tests\Bookstore\Behavior\SortableTable12; use Propel\Tests\Bookstore\Behavior\Map\SortableTable12TableMap; +use Propel\Tests\Bookstore\Behavior\SortableTable12; +use Propel\Tests\Bookstore\Behavior\SortableTable12Query; /** * Tests for SortableBehavior class query modifier when the scope is enabled @@ -26,6 +25,9 @@ */ class SortableBehaviorQueryBuilderModifierWithScopeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -33,6 +35,9 @@ public function setUp(): void $this->populateTable12(); } + /** + * @return void + */ public function testInList() { /* List used for tests @@ -52,6 +57,9 @@ public function testInList() $this->assertEquals(2, $query->count(), 'inList() filters the query by scope'); } + /** + * @return void + */ public function testFilterByRank() { /* List used for tests @@ -67,6 +75,9 @@ public function testFilterByRank() $this->assertNull(SortableTable12Query::create()->filterByRank(4, 2)->findOne(), 'filterByRank() filters on the rank and the scope, which makes the query return no result on a non-existent rank'); } + /** + * @return void + */ public function testOrderByRank() { $this->assertTrue(SortableTable12Query::create()->orderByRank() instanceof SortableTable12Query, 'orderByRank() returns the current query object'); @@ -84,6 +95,9 @@ public function testOrderByRank() $this->assertEquals($expectedQuery, $query, 'orderByRank() orders the query by rank, using the argument as sort direction'); } + /** + * @return void + */ public function testFindList() { $ts = SortableTable12Query::create()->findList(1); @@ -99,6 +113,9 @@ public function testFindList() $this->assertEquals('row6', $ts[1]->getTitle(), 'findList() returns an ordered scoped list'); } + /** + * @return void + */ public function testFindOneByRank() { $this->assertTrue(SortableTable12Query::create()->findOneByRank(1, 1) instanceof SortableTable12, 'findOneByRank() returns an instance of the model object'); @@ -108,6 +125,9 @@ public function testFindOneByRank() $this->assertNull(SortableTable12Query::create()->findOneByRank(4, 2), 'findOneByRank() returns no result on a non-existent rank and scope'); } + /** + * @return void + */ public function testGetMaxRank() { $this->assertEquals(4, SortableTable12Query::create()->getMaxRank(1), 'getMaxRank() returns the maximum rank in the scope'); @@ -131,12 +151,15 @@ public function testGetMaxRank() $this->assertEquals(1, SortableTable12Query::create()->getMaxRank(1), 'getMaxRank() returns the maximum rank'); } + /** + * @return void + */ public function testReorder() { $objects = SortableTable12Query::create()->findList(1); $ids = []; foreach ($objects as $object) { - $ids[]= $object->getPrimaryKey(); + $ids[] = $object->getPrimaryKey(); } $ranks = [4, 3, 2, 1]; $order = array_combine($ids, $ranks); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierTest.php index 905212a684..a91b12d1c2 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierTest.php @@ -11,9 +11,8 @@ namespace Propel\Tests\Generator\Behavior\Sortable; use Propel\Runtime\ActiveQuery\Criteria; - -use Propel\Tests\Bookstore\Behavior\SortableTable11Query; use Propel\Tests\Bookstore\Behavior\Map\SortableTable11TableMap; +use Propel\Tests\Bookstore\Behavior\SortableTable11Query; /** * Tests for SortableBehavior class @@ -24,6 +23,9 @@ */ class SortableBehaviorQueryUtilsBuilderModifierTest extends TestCase { + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -31,11 +33,17 @@ public function setUp(): void $this->populateTable11(); } + /** + * @return void + */ public function testStaticAttributes() { $this->assertEquals('sortable_table11.sortable_rank', SortableTable11TableMap::RANK_COL); } + /** + * @return void + */ public function testGetMaxRank() { $this->assertEquals(4, SortableTable11Query::create()->getMaxRank(), 'getMaxRank() returns the maximum rank'); @@ -45,6 +53,10 @@ public function testGetMaxRank() SortableTable11TableMap::doDeleteAll(); $this->assertNull(SortableTable11Query::create()->getMaxRank(), 'getMaxRank() returns null for empty tables'); } + + /** + * @return void + */ public function testRetrieveByRank() { $t = SortableTable11Query::retrieveByRank(5); @@ -54,12 +66,15 @@ public function testRetrieveByRank() $this->assertEquals('row3', $t3->getTitle(), 'retrieveByRank() returns the object with the required rank'); } + /** + * @return void + */ public function testReorder() { $objects = SortableTable11Query::create()->find(); $ids = []; foreach ($objects as $object) { - $ids[]= $object->getPrimaryKey(); + $ids[] = $object->getPrimaryKey(); } $ranks = [4, 3, 2, 1]; $order = array_combine($ids, $ranks); @@ -68,6 +83,9 @@ public function testReorder() $this->assertEquals($expected, $this->getFixturesArray(), 'reorder() reorders the suite'); } + /** + * @return void + */ public function testDoSelectOrderByRank() { $objects = SortableTable11Query::doSelectOrderByRank()->getArrayCopy(); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierWithScopeTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierWithScopeTest.php index 24d0928ca7..2d4e6189e2 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierWithScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryUtilsBuilderModifierWithScopeTest.php @@ -11,9 +11,8 @@ namespace Propel\Tests\Generator\Behavior\Sortable; use Propel\Runtime\ActiveQuery\Criteria; - -use Propel\Tests\Bookstore\Behavior\SortableTable12Query; use Propel\Tests\Bookstore\Behavior\Map\SortableTable12TableMap; +use Propel\Tests\Bookstore\Behavior\SortableTable12Query; /** * Tests for SortableBehavior class @@ -24,6 +23,9 @@ */ class SortableBehaviorQueryUtilsBuilderModifierWithScopeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -31,12 +33,18 @@ public function setUp(): void $this->populateTable12(); } + /** + * @return void + */ public function testStaticAttributes() { $this->assertEquals('sortable_table12.position', SortableTable12TableMap::RANK_COL); $this->assertEquals('sortable_table12.my_scope_column', SortableTable12TableMap::SCOPE_COL); } + /** + * @return void + */ public function testGetMaxRank() { $this->assertEquals(4, SortableTable12Query::create()->getMaxRank(1), 'getMaxRank() returns the maximum rank of the suite'); @@ -47,6 +55,10 @@ public function testGetMaxRank() SortableTable12TableMap::doDeleteAll(); $this->assertNull(SortableTable12Query::create()->getMaxRank(1), 'getMaxRank() returns null for empty tables'); } + + /** + * @return void + */ public function testRetrieveByRank() { $t = SortableTable12Query::retrieveByRank(5, 1); @@ -59,6 +71,9 @@ public function testRetrieveByRank() $this->assertEquals('row6', $t6->getTitle(), 'retrieveByRank() returns the object with the required rank in the required suite'); } + /** + * @return void + */ public function testReorder() { $c = new Criteria(); @@ -66,7 +81,7 @@ public function testReorder() $objects = SortableTable12Query::doSelectOrderByRank($c); $ids = []; foreach ($objects as $object) { - $ids[]= $object->getPrimaryKey(); + $ids[] = $object->getPrimaryKey(); } $ranks = [4, 3, 2, 1]; $order = array_combine($ids, $ranks); @@ -77,6 +92,9 @@ public function testReorder() $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'reorder() leaves other suites unchanged'); } + /** + * @return void + */ public function testDoSelectOrderByRank() { $c = new Criteria(); @@ -97,6 +115,9 @@ public function testDoSelectOrderByRank() } } + /** + * @return void + */ public function testRetrieveList() { $this->assertEquals(4, count(SortableTable12Query::retrieveList(null)), 'retrieveList() returns the list of objects in the scope'); @@ -104,6 +125,9 @@ public function testRetrieveList() $this->assertEquals(2, count(SortableTable12Query::retrieveList(2)), 'retrieveList() returns the list of objects in the scope'); } + /** + * @return void + */ public function testCountList() { $this->assertEquals(4, SortableTable12Query::countList(null), 'countList() returns the list of objects in the scope'); @@ -111,6 +135,9 @@ public function testCountList() $this->assertEquals(2, SortableTable12Query::countList(2), 'countList() returns the list of objects in the scope'); } + /** + * @return void + */ public function testDeleteList() { $this->assertEquals(4, SortableTable12Query::deleteList(null), 'deleteList() returns the list of deleted objects in the scope'); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorTest.php index eb9767480a..994f4c26a1 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorTest.php @@ -23,6 +23,9 @@ */ class SortableBehaviorTest extends TestCase { + /** + * @return void + */ public function testParameters() { $table11 = SortableTable11TableMap::getTableMap(); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithEnumScopeTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithEnumScopeTest.php index 1ed6036b3b..f4d1a414fe 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithEnumScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithEnumScopeTest.php @@ -11,8 +11,6 @@ namespace Propel\Tests\Generator\Behavior\Sortable; use Propel\Tests\Bookstore\Behavior\SortableTable13Query; -use Propel\Tests\Bookstore\Behavior\Map\SortableTable13TableMap; -use Propel\Tests\Bookstore\Behavior\SortableTable13 as Table13; /** * Tests for SortableBehavior class @@ -23,6 +21,9 @@ */ class SortableBehaviorWithEnumScopeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -30,6 +31,9 @@ public function setUp(): void $this->populateTable13(); } + /** + * @return void + */ public function testEnumRank() { $entries = SortableTable13Query::create()->find(); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithSetScopeTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithSetScopeTest.php index 1e0e051c4e..70831615d3 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithSetScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorWithSetScopeTest.php @@ -21,6 +21,9 @@ */ class SortableBehaviorWithSetScopeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -28,6 +31,9 @@ public function setUp(): void $this->populateTable14(); } + /** + * @return void + */ public function testEnumRank() { $entries = SortableTable14Query::create()->find(); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/TestCase.php b/tests/Propel/Tests/Generator/Behavior/Sortable/TestCase.php index 01c581840c..aff08d39b4 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/TestCase.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/TestCase.php @@ -11,17 +11,15 @@ namespace Propel\Tests\Generator\Behavior\Sortable; use Propel\Runtime\ActiveQuery\Criteria; - +use Propel\Tests\Bookstore\Behavior\Map\SortableTable11TableMap; +use Propel\Tests\Bookstore\Behavior\Map\SortableTable12TableMap; +use Propel\Tests\Bookstore\Behavior\Map\SortableTable13TableMap; use Propel\Tests\Bookstore\Behavior\Map\SortableTable14TableMap; use Propel\Tests\Bookstore\Behavior\SortableTable11; use Propel\Tests\Bookstore\Behavior\SortableTable11Query; use Propel\Tests\Bookstore\Behavior\SortableTable12; use Propel\Tests\Bookstore\Behavior\SortableTable12Query; use Propel\Tests\Bookstore\Behavior\SortableTable13; -use Propel\Tests\Bookstore\Behavior\SortableTable13Query; -use Propel\Tests\Bookstore\Behavior\Map\SortableTable13TableMap; -use Propel\Tests\Bookstore\Behavior\Map\SortableTable12TableMap; -use Propel\Tests\Bookstore\Behavior\Map\SortableTable11TableMap; use Propel\Tests\Bookstore\Behavior\SortableTable14; use Propel\Tests\TestCaseFixturesDatabase; @@ -30,7 +28,9 @@ */ class TestCase extends TestCaseFixturesDatabase { - + /** + * @return void + */ protected function populateTable11() { SortableTable11TableMap::doDeleteAll(); @@ -56,6 +56,9 @@ protected function populateTable11() $t4->save(); } + /** + * @return void + */ protected function populateTable12() { /* List used for tests @@ -122,6 +125,9 @@ protected function populateTable12() $t10->save(); } + /** + * @return void + */ protected function populateTable13() { SortableTable13TableMap::doDeleteAll(); @@ -147,6 +153,9 @@ protected function populateTable13() $t4->save(); } + /** + * @return void + */ protected function populateTable14() { SortableTable14TableMap::doDeleteAll(); @@ -187,7 +196,7 @@ protected function getFixturesArrayWithScope($scope = null) { $c = new Criteria(); $c->add(SortableTable12TableMap::SCOPE_COL, $scope); - $ts = SortableTable12Query::create(null, $c)->orderByPosition()->find(); + $ts = SortableTable12Query::create(null, $c)->orderByPosition()->find(); $ret = []; foreach ($ts as $t) { diff --git a/tests/Propel/Tests/Generator/Behavior/TableBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/TableBehaviorTest.php index 7aeaa336f4..8c257b0e2e 100644 --- a/tests/Propel/Tests/Generator/Behavior/TableBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/TableBehaviorTest.php @@ -20,11 +20,17 @@ */ class TableBehaviorTest extends TestCase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); } + /** + * @return void + */ public function testModifyTable() { $t = Table3TableMap::getTableMap(); diff --git a/tests/Propel/Tests/Generator/Behavior/Timestampable/TimestampableBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Timestampable/TimestampableBehaviorTest.php index 89a27c2bb4..66bd2471dd 100644 --- a/tests/Propel/Tests/Generator/Behavior/Timestampable/TimestampableBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Timestampable/TimestampableBehaviorTest.php @@ -11,15 +11,14 @@ namespace Propel\Tests\Generator\Behavior\Timestampable; use Propel\Generator\Util\QuickBuilder; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; - -use Propel\Tests\Bookstore\Behavior\Table1; +use Propel\Runtime\Collection\ObjectCollection; use Propel\Tests\Bookstore\Behavior\Map\Table1TableMap; -use Propel\Tests\Bookstore\Behavior\Table2; use Propel\Tests\Bookstore\Behavior\Map\Table2TableMap; +use Propel\Tests\Bookstore\Behavior\Table2; use Propel\Tests\Bookstore\Behavior\Table2Query; - -use Propel\Runtime\Collection\ObjectCollection; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use TableWithoutCreatedAt; +use TableWithoutUpdatedAt; /** * Tests for TimestampableBehavior class @@ -30,6 +29,9 @@ */ class TimestampableBehaviorTest extends BookstoreTestBase { + /** + * @return void + */ public static function setUpBeforeClass(): void { static::$isInitialized = false; @@ -49,6 +51,9 @@ private function assertTimeEquals($expected, $actual, $message = '') ); } + /** + * @return void + */ public function testParameters() { $table2 = Table2TableMap::getTableMap(); @@ -61,6 +66,9 @@ public function testParameters() $this->assertTrue(method_exists('\Propel\Tests\Bookstore\Behavior\Table1', 'getUpdatedOn'), 'Timestampable allows customization of update_column name'); } + /** + * @return void + */ public function testPreSave() { $t1 = new Table2(); @@ -78,6 +86,9 @@ public function testPreSave() $this->assertTimeEquals($tupdate, $t1->getUpdatedAt('U'), 'Timestampable changes updated_column to time() on update'); } + /** + * @return void + */ public function testPreSaveNoChange() { $t1 = new Table2(); @@ -91,6 +102,9 @@ public function testPreSaveNoChange() $this->assertTimeEquals($tsave, $t1->getUpdatedAt('U'), 'Timestampable only changes updated_column if the object was modified'); } + /** + * @return void + */ public function testPreSaveManuallyUpdated() { $t1 = new Table2(); @@ -107,6 +121,9 @@ public function testPreSaveManuallyUpdated() $this->assertLessThan($tupdate, $t1->getUpdatedAt('U'), 'Timestampable does not change updated_column to time() on update when it is set by the user'); } + /** + * @return void + */ public function testPreInsert() { $t1 = new Table2(); @@ -121,6 +138,9 @@ public function testPreInsert() $this->assertTimeEquals($tsave, $t1->getCreatedAt('U'), 'Timestampable does not update created_column on update'); } + /** + * @return void + */ public function testPreInsertManuallyUpdated() { $t1 = new Table2(); @@ -130,6 +150,9 @@ public function testPreInsertManuallyUpdated() $this->assertLessThan($tsave, $t1->getCreatedAt('U'), 'Timestampable does not set created_column to time() on creation when it is set by the user'); } + /** + * @return void + */ public function testObjectKeepUpdateDateUnchanged() { $t1 = new Table2(); @@ -155,38 +178,46 @@ public function testObjectKeepUpdateDateUnchanged() $tsave = time(); $t1->save(); $this->assertLessThan($tsave, $t1->getUpdatedAt('U'), 'keepUpdateDateUnchanged() prevents the behavior from updating the update date'); - } + /** + * @return void + */ protected function populateUpdatedAt() { Table2Query::create()->deleteAll(); $ts = new ObjectCollection(); $ts->setModel('\Propel\Tests\Bookstore\Behavior\Table2'); - for ($i=0; $i < 10; $i++) { + for ($i = 0; $i < 10; $i++) { $t = new Table2(); $t->setTitle('UpdatedAt' . $i); /* additional -30 in case the check is done in the same second (which we can't guarantee, so no assert(8 ...) below).*/ $t->setUpdatedAt(time() - $i * 24 * 60 * 60 - 30); - $ts[]= $t; + $ts[] = $t; } $ts->save(); } + /** + * @return void + */ protected function populateCreatedAt() { Table2Query::create()->deleteAll(); $ts = new ObjectCollection(); $ts->setModel('\Propel\Tests\Bookstore\Behavior\Table2'); - for ($i=0; $i < 10; $i++) { + for ($i = 0; $i < 10; $i++) { $t = new Table2(); $t->setTitle('CreatedAt' . $i); $t->setCreatedAt(time() - $i * 24 * 60 * 60 - 30); - $ts[]= $t; + $ts[] = $t; } $ts->save(); } + /** + * @return void + */ public function testQueryRecentlyUpdated() { $q = Table2Query::create()->recentlyUpdated(); @@ -198,6 +229,9 @@ public function testQueryRecentlyUpdated() $this->assertEquals(5, $ts, 'recentlyUpdated() accepts a number of days as parameter'); } + /** + * @return void + */ public function testQueryRecentlyCreated() { $q = Table2Query::create()->recentlyCreated(); @@ -209,6 +243,9 @@ public function testQueryRecentlyCreated() $this->assertEquals(5, $ts, 'recentlyCreated() accepts a number of days as parameter'); } + /** + * @return void + */ public function testQueryLastUpdatedFirst() { $q = Table2Query::create()->lastUpdatedFirst(); @@ -218,6 +255,9 @@ public function testQueryLastUpdatedFirst() $this->assertEquals('UpdatedAt0', $t->getTitle(), 'lastUpdatedFirst() returns element with most recent update date first'); } + /** + * @return void + */ public function testQueryFirstUpdatedFirst() { $q = Table2Query::create()->firstUpdatedFirst(); @@ -227,6 +267,9 @@ public function testQueryFirstUpdatedFirst() $this->assertEquals('UpdatedAt9', $t->getTitle(), 'firstUpdatedFirst() returns the element with oldest updated date first'); } + /** + * @return void + */ public function testQueryLastCreatedFirst() { $q = Table2Query::create()->lastCreatedFirst(); @@ -236,6 +279,9 @@ public function testQueryLastCreatedFirst() $this->assertEquals('CreatedAt0', $t->getTitle(), 'lastCreatedFirst() returns element with most recent create date first'); } + /** + * @return void + */ public function testQueryFirstCreatedFirst() { $q = Table2Query::create()->firstCreatedFirst(); @@ -245,6 +291,9 @@ public function testQueryFirstCreatedFirst() $this->assertEquals('CreatedAt9', $t->getTitle(), 'firstCreatedFirst() returns the element with oldest create date first'); } + /** + * @return void + */ public function testDisableUpdatedAt() { $schema = <<assertFalse(method_exists('TableWithoutUpdatedAt', 'getUpdatedAt')); $this->assertFalse(method_exists('TableWithoutUpdatedAt', 'setUpdatedAt')); - $obj = new \TableWithoutUpdatedAt(); + $obj = new TableWithoutUpdatedAt(); $obj->setName('Peter'); $this->assertNull($obj->getCreatedAt()); $this->assertEquals(1, $obj->save()); $this->assertNotNull($obj->getCreatedAt()); } + /** + * @return void + */ public function testDisableCreatedAt() { $schema = <<assertTrue(method_exists('TableWithoutCreatedAt', 'getUpdatedAt')); $this->assertTrue(method_exists('TableWithoutCreatedAt', 'setUpdatedAt')); - $obj = new \TableWithoutCreatedAt(); + $obj = new TableWithoutCreatedAt(); $obj->setName('Peter'); $this->assertNull($obj->getUpdatedAt()); $this->assertEquals(1, $obj->save()); diff --git a/tests/Propel/Tests/Generator/Behavior/Validate/I18nConcreteInheritanceHandleValidateBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Validate/I18nConcreteInheritanceHandleValidateBehaviorTest.php index 6b47267934..99af4fdabc 100644 --- a/tests/Propel/Tests/Generator/Behavior/Validate/I18nConcreteInheritanceHandleValidateBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Validate/I18nConcreteInheritanceHandleValidateBehaviorTest.php @@ -11,6 +11,11 @@ namespace Propel\Tests\Generator\Behavior\Validate; use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use ReflectionMethod; +use Symfony\Component\Validator\Constraints\NotNull; +use Symfony\Component\Validator\Constraints\Regex; +use Symfony\Component\Validator\Constraints\Type; +use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory; use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader; /** @@ -25,11 +30,17 @@ class I18nConcreteInheritanceHandleValidateBehaviorTest extends BookstoreTestBas { protected $metadataFactory; + /** + * @return void + */ public function assertPreConditions(): void { - $this->metadataFactory = new \Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory(new StaticMethodLoader()); + $this->metadataFactory = new LazyLoadingMetadataFactory(new StaticMethodLoader()); } + /** + * @return void + */ public function testI18nBehaviorHandlesValidateBehavior() { $class = 'Propel\Tests\Bookstore\Behavior\ValidateTriggerBook'; @@ -63,6 +74,9 @@ public function testI18nBehaviorHandlesValidateBehavior() $this->assertInstanceOf('Symfony\Component\Validator\Constraints\NotNull', $i18nConstraints[0]); } + /** + * @return void + */ public function testConcreteInheritanceBehaviorHandlesValidateBehavior() { $fiction = 'Propel\Tests\Bookstore\Behavior\ValidateTriggerFiction'; @@ -80,18 +94,18 @@ public function testConcreteInheritanceBehaviorHandlesValidateBehavior() // I'm not sure if this is needed. We should not care about validator internals $this->assertCount(2, $fictionMetadatas); - $expectedValidatorGroups = array( + $expectedValidatorGroups = [ 'ValidateTriggerFiction', 'ValidateTriggerBook', - ); + ]; // iterate over metadatas and constarints. // If constraint match with expected constraint -> remove it form expectations list // We are looking for our regex validations foreach ($fictionMetadatas as $fictionmetadata) { - /* @var $constraint \Symfony\Component\Validator\Mapping\PropertyMetadata */ + /** @var \Symfony\Component\Validator\Mapping\PropertyMetadata $constraint */ foreach ($fictionmetadata->getConstraints() as $constraint) { - if ($constraint instanceof \Symfony\Component\Validator\Constraints\Regex) { + if ($constraint instanceof Regex) { $expectedValidatorGroups = array_diff($expectedValidatorGroups, $constraint->groups); } } @@ -109,18 +123,18 @@ public function testConcreteInheritanceBehaviorHandlesValidateBehavior() $this->assertTrue(in_array('bar', $comicMetadata->getConstrainedProperties(), true)); $comicMetadatas['isbn'] = $comicMetadata->getPropertyMetadata('isbn'); - $comicMetadatas['bar'] = $comicMetadata->getPropertyMetadata('bar'); + $comicMetadatas['bar'] = $comicMetadata->getPropertyMetadata('bar'); - $expectedComicValidators = array( + $expectedComicValidators = [ 'ValidateTriggerComic', 'ValidateTriggerComic', 'ValidateTriggerBook', - ); + ]; foreach ($comicMetadatas['isbn'] as $metadata) { - /* @var $metadata \Symfony\Component\Validator\Mapping\PropertyMetadata */ + /** @var \Symfony\Component\Validator\Mapping\PropertyMetadata $metadata */ foreach ($metadata->getConstraints() as $constraint) { - if ($constraint instanceof \Symfony\Component\Validator\Constraints\Regex) { + if ($constraint instanceof Regex) { $expectedComicValidators = array_diff($expectedComicValidators, $constraint->groups); } } @@ -130,16 +144,16 @@ public function testConcreteInheritanceBehaviorHandlesValidateBehavior() $comicMetadataBar = $comicMetadatas['bar']; - $expectedComicBarValidatorTypes = array( + $expectedComicBarValidatorTypes = [ 0 => 'Symfony\Component\Validator\Constraints\NotNull', 1 => 'Symfony\Component\Validator\Constraints\Type', - ); + ]; foreach ($comicMetadataBar as $metadata) { $constraints = $metadata->getConstraints(); foreach ($constraints as $constraint) { - if ($constraint instanceof \Symfony\Component\Validator\Constraints\NotNull) { + if ($constraint instanceof NotNull) { unset($expectedComicBarValidatorTypes[0]); - } elseif ($constraint instanceof \Symfony\Component\Validator\Constraints\Type) { + } elseif ($constraint instanceof Type) { unset($expectedComicBarValidatorTypes[1]); } } @@ -148,14 +162,17 @@ public function testConcreteInheritanceBehaviorHandlesValidateBehavior() $this->assertEmpty($expectedComicBarValidatorTypes); } + /** + * @return void + */ public function testConcreteInheritanceAndI18nBehaviorHandlesValidateBehavior() { $classes = ['ValidateTriggerFictionI18n', 'ValidateTriggerComicI18n']; foreach ($classes as $class) { - $this->checkClassHasValidateBehavior('Propel\Tests\Bookstore\Behavior\\'.$class); + $this->checkClassHasValidateBehavior('Propel\Tests\Bookstore\Behavior\\' . $class); - $classMetadata = $this->metadataFactory->getMetadataFor('Propel\Tests\Bookstore\Behavior\\'.$class); + $classMetadata = $this->metadataFactory->getMetadataFor('Propel\Tests\Bookstore\Behavior\\' . $class); $this->assertCount(1, $classMetadata->getConstrainedProperties()); $this->assertTrue(in_array('title', $classMetadata->getConstrainedProperties(), true)); @@ -169,6 +186,9 @@ public function testConcreteInheritanceAndI18nBehaviorHandlesValidateBehavior() } } + /** + * @return void + */ protected function checkClassHasValidateBehavior($class) { $this->assertTrue(method_exists($class, 'validate'), "Class $class has no validate() method"); @@ -176,7 +196,7 @@ protected function checkClassHasValidateBehavior($class) $this->assertTrue(method_exists($class, 'loadValidatorMetadata'), "Class $class has no loadValidatorMetadata() method"); $this->assertClassHasAttribute('alreadyInValidation', $class, "Class $class has no 'alreadyInValidation' property"); $this->assertClassHasAttribute('validationFailures', $class, "Class $class has no 'validationFailures' property"); - $method = new \ReflectionMethod($class, 'loadValidatorMetadata'); + $method = new ReflectionMethod($class, 'loadValidatorMetadata'); $this->assertTrue($method->isStatic(), "Method loadValidatorMetadata() of class $class isn't static"); } } diff --git a/tests/Propel/Tests/Generator/Behavior/Validate/UniqueConstraintTest.php b/tests/Propel/Tests/Generator/Behavior/Validate/UniqueConstraintTest.php index 1d2255d47a..759d0cfd74 100644 --- a/tests/Propel/Tests/Generator/Behavior/Validate/UniqueConstraintTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Validate/UniqueConstraintTest.php @@ -23,6 +23,9 @@ */ class UniqueConstraintTest extends BookstoreTestBase { + /** + * @return void + */ public function testUniqueValidatorPass() { $publisher = new Publisher(); @@ -32,6 +35,9 @@ public function testUniqueValidatorPass() $this->assertTrue($isValid); } + /** + * @return void + */ public function testUniqueValidatorIgnoresItself() { $publisher = new Publisher(); @@ -45,6 +51,9 @@ public function testUniqueValidatorIgnoresItself() $publisher->delete(); } + /** + * @return void + */ public function testUniqueValidatorFail() { $publisher = new Publisher(); @@ -65,17 +74,23 @@ public function testUniqueValidatorFail() $publisher->delete(); } + /** + * @return void + */ public function testUniqueValidatorPassIfNull() { $book = new Book(); - $book->setTitle("The return of Sherlock Holmes"); + $book->setTitle('The return of Sherlock Holmes'); $this->assertTrue($book->validate()); } + /** + * @return void + */ public function testUniqueValidatorAlwaysPassIfNull() { $book = new Book(); - $book->setTitle("The return of Sherlock Holmes"); + $book->setTitle('The return of Sherlock Holmes'); $book->save(); $book1 = new Book(); @@ -85,5 +100,4 @@ public function testUniqueValidatorAlwaysPassIfNull() $book->delete(); } - } diff --git a/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php index 233e6a2b1d..29346adadc 100755 --- a/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php @@ -10,13 +10,15 @@ namespace Propel\Tests\Generator\Behavior\Validate; -use Propel\Generator\Behavior\Validate\ValidateBehavior; +use Exception; use Propel\Generator\Util\QuickBuilder; use Propel\Tests\Bookstore\Behavior\ValidateAuthor; use Propel\Tests\Bookstore\Behavior\ValidateBook; use Propel\Tests\Bookstore\Behavior\ValidatePublisher; use Propel\Tests\Bookstore\Behavior\ValidateReader; use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use ReflectionMethod; +use ReflectionObject; /** * Tests for ValidateBehavior class @@ -28,15 +30,20 @@ class ValidateBehaviorTest extends BookstoreTestBase { /** - * @private array The names of ValidateAuthor, ValidateBook, ValidatePublisher, ValidateReader classes. + * @private array The names of ValidateAuthor, ValidateBook, ValidatePublisher, ValidateReader classes. * This classes are created by test:prepare command */ private $classes; + /** + * @throws \Exception + * + * @return void + */ public function assertPreConditions(): void { if (!class_exists('Propel\Tests\Bookstore\Behavior\ValidateAuthor')) { - throw new \Exception('Please, run \'bin/propel test:prepare\' command before starting to test this behavior'); + throw new Exception('Please, run \'bin/propel test:prepare\' command before starting to test this behavior'); } $this->classes[] = 'Propel\Tests\Bookstore\Behavior\ValidateAuthor'; @@ -46,6 +53,9 @@ public function assertPreConditions(): void $this->classes[] = 'Propel\Tests\Bookstore\Behavior\ValidateReaderBook'; } + /** + * @return void + */ public function testHasValidateMethod() { foreach ($this->classes as $class) { @@ -53,6 +63,9 @@ public function testHasValidateMethod() } } + /** + * @return void + */ public function testHasLoadValidatorMetadataMethod() { foreach ($this->classes as $class) { @@ -60,6 +73,9 @@ public function testHasLoadValidatorMetadataMethod() } } + /** + * @return void + */ public function testHasAlreadyInValidationAttribute() { foreach ($this->classes as $class) { @@ -67,6 +83,9 @@ public function testHasAlreadyInValidationAttribute() } } + /** + * @return void + */ public function testHasValidationFailuresAttribute() { foreach ($this->classes as $class) { @@ -74,17 +93,22 @@ public function testHasValidationFailuresAttribute() } } + /** + * @return void + */ public function testLoadValidatorMetadataMethodIsStatic() { foreach ($this->classes as $class) { - $method = new \ReflectionMethod($class, 'loadValidatorMetadata'); + $method = new ReflectionMethod($class, 'loadValidatorMetadata'); $this->assertTrue($method->isStatic()); } } /** - * @expectedException Propel\Generator\Exception\InvalidArgumentException - * @expectedExceptionMessage Please, define your rules for validation. + * @expectedException Propel\Generator\Exception\InvalidArgumentException + * @expectedExceptionMessage Please, define your rules for validation. + * + * @return void */ public function testParametersNotDefined() { @@ -101,8 +125,10 @@ public function testParametersNotDefined() } /** - * @expectedException Propel\Generator\Exception\InvalidArgumentException - * @expectedExceptionMessage Please, define the column to validate. + * @expectedException Propel\Generator\Exception\InvalidArgumentException + * @expectedExceptionMessage Please, define the column to validate. + * + * @return void */ public function testColumnNameNotDefined() { @@ -122,8 +148,10 @@ public function testColumnNameNotDefined() } /** - * @expectedException Propel\Generator\Exception\InvalidArgumentException - * @expectedExceptionMessage Please, define the validator constraint. + * @expectedException Propel\Generator\Exception\InvalidArgumentException + * @expectedExceptionMessage Please, define the validator constraint. + * + * @return void */ public function testValidatorNameNotDefined() { @@ -143,8 +171,10 @@ public function testValidatorNameNotDefined() } /** - * @expectedException Propel\Generator\Exception\ConstraintNotFoundException - * @expectedExceptionMessage The constraint class MaximumLength does not exist. + * @expectedException Propel\Generator\Exception\ConstraintNotFoundException + * @expectedExceptionMessage The constraint class MaximumLength does not exist. + * + * @return void */ public function testConstraintNameNotValid() { @@ -164,8 +194,10 @@ public function testConstraintNameNotValid() } /** - * @expectedException Propel\Generator\Exception\InvalidArgumentException - * @expectedExceptionMessage The options value, in tag must be an array + * @expectedException Propel\Generator\Exception\InvalidArgumentException + * @expectedExceptionMessage The options value, in tag must be an array + * + * @return void */ public function testConstraintOptionsNotValid() { @@ -184,6 +216,9 @@ public function testConstraintOptionsNotValid() QuickBuilder::buildSchema($schema); } + /** + * @return void + */ public function testSimpleValidationSuccess() { $author = new ValidateAuthor(); @@ -197,6 +232,9 @@ public function testSimpleValidationSuccess() $this->assertTrue($res, 'Expected validation is successful'); } + /** + * @return void + */ public function testComplexValidationSuccess() { $author = new ValidateAuthor(); @@ -233,55 +271,64 @@ public function testComplexValidationSuccess() $this->assertTrue($res, 'Expected validation is successful'); } + /** + * @return void + */ public function testSingleValidationFailure() { - $reader = new ValidateReader(); - $reader->setId(14); - $reader->setFirstName('Felicity'); - $reader->setLastName('Stamm'); - $reader->setEmail('f.stamm@'); //failure - $reader->setBirthday('1989-07-24'); + $reader = new ValidateReader(); + $reader->setId(14); + $reader->setFirstName('Felicity'); + $reader->setLastName('Stamm'); + $reader->setEmail('f.stamm@'); //failure + $reader->setBirthday('1989-07-24'); - $res = $reader->validate(); + $res = $reader->validate(); - $this->assertFalse($res, 'This validation expected to fail'); + $this->assertFalse($res, 'This validation expected to fail'); - $failures = $reader->getValidationFailures(); + $failures = $reader->getValidationFailures(); - $this->assertInstanceOf('Symfony\Component\Validator\ConstraintViolationList', $failures); - $this->assertEquals(1, count($failures), 'Only one constraint violation object'); + $this->assertInstanceOf('Symfony\Component\Validator\ConstraintViolationList', $failures); + $this->assertEquals(1, count($failures), 'Only one constraint violation object'); - $failure = $failures[0]; - $this->assertInstanceOf('Symfony\Component\Validator\ConstraintViolation', $failure); - $this->assertEquals('email', $failure->getPropertyPath(), 'email property expected to fail'); + $failure = $failures[0]; + $this->assertInstanceOf('Symfony\Component\Validator\ConstraintViolation', $failure); + $this->assertEquals('email', $failure->getPropertyPath(), 'email property expected to fail'); } + /** + * @return void + */ public function testMultipleValidationFailures() { - $reader = new ValidateReader(); - $reader->setId(18); - $reader->setFirstName('Bo'); //failure: less than 4 chars - $reader->setLastName(null); //failure - $reader->setEmail('zora.null@'); //failure - $reader->setBirthday('1983-09-22'); + $reader = new ValidateReader(); + $reader->setId(18); + $reader->setFirstName('Bo'); //failure: less than 4 chars + $reader->setLastName(null); //failure + $reader->setEmail('zora.null@'); //failure + $reader->setBirthday('1983-09-22'); - $failedProperties = ['last_name', 'first_name', 'email']; + $failedProperties = ['last_name', 'first_name', 'email']; - $res = $reader->validate(); + $res = $reader->validate(); - $this->assertFalse($res, 'This validation expected to fail'); + $this->assertFalse($res, 'This validation expected to fail'); - $failures = $reader->getValidationFailures(); + $failures = $reader->getValidationFailures(); - $this->assertInstanceOf('Symfony\Component\Validator\ConstraintViolationList', $failures); - $this->assertEquals(3, count($failures), 'Three constraint violation objects expected'); + $this->assertInstanceOf('Symfony\Component\Validator\ConstraintViolationList', $failures); + $this->assertEquals(3, count($failures), 'Three constraint violation objects expected'); - foreach ($failures as $failure) { - $this->assertInstanceOf('Symfony\Component\Validator\ConstraintViolation', $failure); - $this->assertTrue(in_array($failure->getPropertyPath(), $failedProperties)); - } + foreach ($failures as $failure) { + $this->assertInstanceOf('Symfony\Component\Validator\ConstraintViolation', $failure); + $this->assertTrue(in_array($failure->getPropertyPath(), $failedProperties)); + } } + /** + * @return void + */ public function testComplexValidationSingleFailure() { $author = new ValidateAuthor(); @@ -324,6 +371,9 @@ public function testComplexValidationSingleFailure() $this->assertEquals('title', $failure->getPropertyPath(), 'title property expected to fail'); } + /** + * @return void + */ public function testComplexValidationRelatedObjectsSingleFailure() { $author = new ValidateAuthor(); @@ -364,21 +414,24 @@ public function testComplexValidationRelatedObjectsSingleFailure() $failure = $failures[0]; $this->assertInstanceOf('Symfony\Component\Validator\ConstraintViolation', $failure); - $failObject = new \ReflectionObject($failure->getRoot()); + $failObject = new ReflectionObject($failure->getRoot()); $this->assertEquals('Propel\Tests\Bookstore\Behavior\ValidatePublisher', $failObject->getName(), 'Instance of ValidatePublisher expected to fail'); $this->assertEquals('website', $failure->getPropertyPath(), 'website property expected to fail'); } + /** + * @return void + */ public function testComplexValidationMultipleFailures() { //Array of expected failures. key: property failed, value: Class in wich the property has failed $failedProperties = [ 'first_name' => 'Propel\Tests\Bookstore\Behavior\ValidateAuthor', - 'website' => 'Propel\Tests\Bookstore\Behavior\ValidatePublisher', - 'title' => 'Propel\Tests\Bookstore\Behavior\ValidateBook', - 'email' => 'Propel\Tests\Bookstore\Behavior\ValidateReader', - 'last_name' => 'Propel\Tests\Bookstore\Behavior\ValidateReader' + 'website' => 'Propel\Tests\Bookstore\Behavior\ValidatePublisher', + 'title' => 'Propel\Tests\Bookstore\Behavior\ValidateBook', + 'email' => 'Propel\Tests\Bookstore\Behavior\ValidateReader', + 'last_name' => 'Propel\Tests\Bookstore\Behavior\ValidateReader', ]; $author = new ValidateAuthor(); @@ -398,7 +451,7 @@ public function testComplexValidationMultipleFailures() $book->setValidateAuthor($author); $book->setValidatePublisher($publisher); $book->setTitle(null); //failed - $book->setPrice(12,90); + $book->setPrice(12, 90); $reader1 = new ValidateReader(); $reader1->setId(1); @@ -428,11 +481,10 @@ public function testComplexValidationMultipleFailures() foreach ($failures as $failure) { $this->assertInstanceOf('Symfony\Component\Validator\ConstraintViolation', $failure); - $failObject = new \ReflectionObject($failure->getRoot()); + $failObject = new ReflectionObject($failure->getRoot()); $this->assertTrue(in_array($failure->getPropertyPath(), array_keys($failedProperties))); $this->assertEquals($failedProperties[$failure->getPropertyPath()], $failObject->getName()); } } - } diff --git a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifierTest.php index 031918fa60..e4b11d2ef0 100644 --- a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifierTest.php @@ -11,6 +11,7 @@ namespace Propel\Tests\Generator\Behavior\Versionable; use Propel\Generator\Util\QuickBuilder; +use VersionableBehaviorTest10Query; /** * Tests for VersionableBehavior class @@ -19,6 +20,9 @@ */ class VersionableBehaviorQueryBuilderModifierTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('VersionableBehaviorTest10')) { @@ -35,12 +39,15 @@ public function setUp(): void } } + /** + * @return void + */ public function testIsVersioningEnabled() { - $this->assertTrue(\VersionableBehaviorTest10Query::isVersioningEnabled()); - \VersionableBehaviorTest10Query::disableVersioning(); - $this->assertFalse(\VersionableBehaviorTest10Query::isVersioningEnabled()); - \VersionableBehaviorTest10Query::enableVersioning(); - $this->assertTrue(\VersionableBehaviorTest10Query::isVersioningEnabled()); + $this->assertTrue(VersionableBehaviorTest10Query::isVersioningEnabled()); + VersionableBehaviorTest10Query::disableVersioning(); + $this->assertFalse(VersionableBehaviorTest10Query::isVersioningEnabled()); + VersionableBehaviorTest10Query::enableVersioning(); + $this->assertTrue(VersionableBehaviorTest10Query::isVersioningEnabled()); } } diff --git a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorTest.php index 8fad26fbe5..c25fc5ae60 100644 --- a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorTest.php @@ -36,6 +36,8 @@ public function basicSchemaDataProvider() /** * @dataProvider basicSchemaDataProvider + * + * @return void */ public function testModifyTableAddsVersionColumn($schema) { @@ -59,6 +61,9 @@ public function testModifyTableAddsVersionColumn($schema) $this->assertContains($expected, $builder->getSQL()); } + /** + * @return void + */ public function testModifyTableAddsVersionColumnCustomName() { $schema = <<assertContains($expected, $builder->getSQL()); } + /** + * @return void + */ public function testModifyTableDoesNotAddVersionColumnIfExists() { $schema = <<assertContains($expected, $builder->getSQL()); } + /** + * @return void + */ public function testModifyTableAddsVersionTableCustomName() { $schema = <<assertContains($expected, $builder->getSQL()); } + /** + * @return void + */ public function testModifyTableDoesNotAddVersionTableIfExists() { $schema = <<assertContains($expected, $builder->getSQL()); } + /** + * @return void + */ public function testDatabaseLevelBehavior() { $schema = <<assertContains($expected, $builder->getSQL()); } + /** + * @return void + */ public function testIndicesParameter() { $schema = <<assertContains($expected, $builder->getSQL()); } + /** + * @return void + */ public function testSkipSqlParameterOnParentTable() { $schema = <<assertEmpty($builder->getSQL()); } - public function tablePrefixSchemaDataProvider() { + public function tablePrefixSchemaDataProvider() + { $schema = <<
@@ -533,16 +567,17 @@ public function tablePrefixSchemaDataProvider() {
XML; + return [[$schema]]; } - /** * @dataProvider tablePrefixSchemaDataProvider + * + * @return void */ public function testModifyTableAddsVersionColumnWithPrefix($schema) { - $builder = new QuickBuilder(); $builder->setSchema($schema); $expected = <<assertContains($expected, $builder->getSQL()); } + /** * @dataProvider tablePrefixSchemaDataProvider + * + * @return void */ - public function testModifyTableAddsVersionTableWithPrefix($schema) { - + public function testModifyTableAddsVersionTableWithPrefix($schema) + { $builder = new QuickBuilder(); $builder->setSchema($schema); $expected = <<assertContains($expected, $builder->getSQL()); } - } diff --git a/tests/Propel/Tests/Generator/Builder/NamespaceTest.php b/tests/Propel/Tests/Generator/Builder/NamespaceTest.php index a870326a84..7b0dff1ef2 100644 --- a/tests/Propel/Tests/Generator/Builder/NamespaceTest.php +++ b/tests/Propel/Tests/Generator/Builder/NamespaceTest.php @@ -10,8 +10,19 @@ namespace Propel\Tests\Generator\Builder; +use Baz\Map\NamespacedPublisherTableMap; +use Baz\NamespacedPublisher; +use Baz\NamespacedPublisherQuery; +use Foo\Bar\Map\NamespacedAuthorTableMap; +use Foo\Bar\Map\NamespacedBookTableMap; +use Foo\Bar\NamespacedAuthor; +use Foo\Bar\NamespacedAuthorQuery; +use Foo\Bar\NamespacedBook; +use Foo\Bar\NamespacedBookQuery; +use Foo\Bar\NamespacedBookstoreEmployeeQuery; use Propel\Runtime\Propel; use Propel\Tests\TestCaseFixturesDatabase; +use Foo\Bar\NamespacedBookstoreEmployee; /** * Tests for Namespaces in generated classes class @@ -33,23 +44,29 @@ class NamespaceTest extends TestCaseFixturesDatabase // Propel::init(dirname(__FILE__) . '/../../../../Fixtures/bookstore/build/conf/bookstore-conf.php'); // } + /** + * @return void + */ public function testInsert() { - $book = new \Foo\Bar\NamespacedBook(); + $book = new NamespacedBook(); $book->setTitle('foo'); $book->setISBN('something'); $book->save(); $this->assertFalse($book->isNew()); - $publisher = new \Baz\NamespacedPublisher(); + $publisher = new NamespacedPublisher(); $publisher->save(); $this->assertFalse($publisher->isNew()); } + /** + * @return void + */ public function testUpdate() { - \Foo\Bar\Map\NamespacedBookTableMap::getTableMap(); - $book = new \Foo\Bar\NamespacedBook(); + NamespacedBookTableMap::getTableMap(); + $book = new NamespacedBook(); $book->setTitle('foo'); $book->setISBN('something'); $book->save(); @@ -58,12 +75,15 @@ public function testUpdate() $this->assertFalse($book->isNew()); } + /** + * @return void + */ public function testRelate() { - $author = new \Foo\Bar\NamespacedAuthor(); + $author = new NamespacedAuthor(); $author->setFirstName('Chuck'); $author->setLastname('Norris'); - $book = new \Foo\Bar\NamespacedBook(); + $book = new NamespacedBook(); $book->setNamespacedAuthor($author); $book->setTitle('foo'); $book->setISBN('something'); @@ -71,10 +91,10 @@ public function testRelate() $this->assertFalse($book->isNew()); $this->assertFalse($author->isNew()); - $author = new \Foo\Bar\NamespacedAuthor(); + $author = new NamespacedAuthor(); $author->setFirstName('Henning'); $author->setLastname('Mankell'); - $book = new \Foo\Bar\NamespacedBook(); + $book = new NamespacedBook(); $book->setTitle('Mördare utan ansikte'); $book->setISBN('1234'); $author->addNamespacedBook($book); @@ -82,8 +102,8 @@ public function testRelate() $this->assertFalse($book->isNew()); $this->assertFalse($author->isNew()); - $publisher = new \Baz\NamespacedPublisher(); - $book = new \Foo\Bar\NamespacedBook(); + $publisher = new NamespacedPublisher(); + $book = new NamespacedBook(); $book->setTitle('Där vi en gång gått'); $book->setISBN('1234'); $book->setNamespacedPublisher($publisher); @@ -92,109 +112,130 @@ public function testRelate() $this->assertFalse($publisher->isNew()); } + /** + * @return void + */ public function testBasicQuery() { - \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); - \Baz\NamespacedPublisherQuery::create()->deleteAll(); - $noNamespacedBook = \Foo\Bar\NamespacedBookQuery::create()->findOne(); + NamespacedBookQuery::create()->deleteAll(); + NamespacedPublisherQuery::create()->deleteAll(); + $noNamespacedBook = NamespacedBookQuery::create()->findOne(); $this->assertNull($noNamespacedBook); - $noPublisher = \Baz\NamespacedPublisherQuery::create()->findOne(); + $noPublisher = NamespacedPublisherQuery::create()->findOne(); $this->assertNull($noPublisher); } + /** + * @return void + */ public function testFind() { - \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); - $book = new \Foo\Bar\NamespacedBook(); + NamespacedBookQuery::create()->deleteAll(); + $book = new NamespacedBook(); $book->setTitle('War And Peace'); $book->setISBN('1234'); $book->save(); - $book2 = \Foo\Bar\NamespacedBookQuery::create()->findPk($book->getId()); + $book2 = NamespacedBookQuery::create()->findPk($book->getId()); $this->assertEquals($book, $book2); - $book3 = \Foo\Bar\NamespacedBookQuery::create()->findOneByTitle($book->getTitle()); + $book3 = NamespacedBookQuery::create()->findOneByTitle($book->getTitle()); $this->assertEquals($book, $book3); } + /** + * @return void + */ public function testGetRelatedManyToOne() { - \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); - \Baz\NamespacedPublisherQuery::create()->deleteAll(); - $publisher = new \Baz\NamespacedPublisher(); - $book = new \Foo\Bar\NamespacedBook(); + NamespacedBookQuery::create()->deleteAll(); + NamespacedPublisherQuery::create()->deleteAll(); + $publisher = new NamespacedPublisher(); + $book = new NamespacedBook(); $book->setTitle('Something'); $book->setISBN('1234'); $book->setNamespacedPublisher($publisher); $book->save(); - \Foo\Bar\Map\NamespacedBookTableMap::clearInstancePool(); - \Baz\Map\NamespacedPublisherTableMap::clearInstancePool(); - $book2 = \Foo\Bar\NamespacedBookQuery::create()->findPk($book->getId()); + NamespacedBookTableMap::clearInstancePool(); + NamespacedPublisherTableMap::clearInstancePool(); + $book2 = NamespacedBookQuery::create()->findPk($book->getId()); $publisher2 = $book2->getNamespacedPublisher(); $this->assertEquals($publisher->getId(), $publisher2->getId()); } + /** + * @return void + */ public function testGetRelatedOneToMany() { - \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); - \Baz\NamespacedPublisherQuery::create()->deleteAll(); - $author = new \Foo\Bar\NamespacedAuthor(); + NamespacedBookQuery::create()->deleteAll(); + NamespacedPublisherQuery::create()->deleteAll(); + $author = new NamespacedAuthor(); $author->setFirstName('Foo'); $author->setLastName('Bar'); - $book = new \Foo\Bar\NamespacedBook(); + $book = new NamespacedBook(); $book->setTitle('Quux'); $book->setISBN('1235'); $book->setNamespacedAuthor($author); $book->save(); - \Foo\Bar\Map\NamespacedBookTableMap::clearInstancePool(); - \Foo\Bar\Map\NamespacedAuthorTableMap::clearInstancePool(); - $author2 = \Foo\Bar\NamespacedAuthorQuery::create()->findPk($author->getId()); + NamespacedBookTableMap::clearInstancePool(); + NamespacedAuthorTableMap::clearInstancePool(); + $author2 = NamespacedAuthorQuery::create()->findPk($author->getId()); $book2 = $author2->getNamespacedBooks()->getFirst(); $this->assertEquals($book->getId(), $book2->getId()); } + /** + * @return void + */ public function testFindWithManyToOne() { - \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); - \Baz\NamespacedPublisherQuery::create()->deleteAll(); - $publisher = new \Baz\NamespacedPublisher(); - $book = new \Foo\Bar\NamespacedBook(); + NamespacedBookQuery::create()->deleteAll(); + NamespacedPublisherQuery::create()->deleteAll(); + $publisher = new NamespacedPublisher(); + $book = new NamespacedBook(); $book->setTitle('asdf'); $book->setISBN('something'); $book->setNamespacedPublisher($publisher); $book->save(); - \Foo\Bar\Map\NamespacedBookTableMap::clearInstancePool(); - \Baz\Map\NamespacedPublisherTableMap::clearInstancePool(); - $book2 = \Foo\Bar\NamespacedBookQuery::create() + NamespacedBookTableMap::clearInstancePool(); + NamespacedPublisherTableMap::clearInstancePool(); + $book2 = NamespacedBookQuery::create() ->joinWith('NamespacedPublisher') ->findPk($book->getId()); $publisher2 = $book2->getNamespacedPublisher(); $this->assertEquals($publisher->getId(), $publisher2->getId()); } + /** + * @return void + */ public function testFindWithOneToMany() { - \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); - \Foo\Bar\NamespacedAuthorQuery::create()->deleteAll(); - $author = new \Foo\Bar\NamespacedAuthor(); + NamespacedBookQuery::create()->deleteAll(); + NamespacedAuthorQuery::create()->deleteAll(); + $author = new NamespacedAuthor(); $author->setFirstName('Foo'); $author->setLastName('Bar'); - $book = new \Foo\Bar\NamespacedBook(); + $book = new NamespacedBook(); $book->setTitle('asdf'); $book->setISBN('something'); $book->setNamespacedAuthor($author); $book->save(); - \Foo\Bar\Map\NamespacedBookTableMap::clearInstancePool(); - \Foo\Bar\Map\NamespacedAuthorTableMap::clearInstancePool(); - $author2 = \Foo\Bar\NamespacedAuthorQuery::create() + NamespacedBookTableMap::clearInstancePool(); + NamespacedAuthorTableMap::clearInstancePool(); + $author2 = NamespacedAuthorQuery::create() ->joinWith('NamespacedBook') ->findPk($author->getId()); $book2 = $author2->getNamespacedBooks()->getFirst(); $this->assertEquals($book->getId(), $book2->getId()); } + /** + * @return void + */ public function testSingleTableInheritance() { - \Foo\Bar\NamespacedBookstoreEmployeeQuery::create()->deleteAll(); - $emp = new \Foo\Bar\NamespacedBookstoreEmployee(); + NamespacedBookstoreEmployeeQuery::create()->deleteAll(); + $emp = new NamespacedBookstoreEmployee(); $emp->setName('Henry'); $emp->save(); $man = new \Foo\Bar\NamespacedBookstoreManager(); @@ -203,28 +244,31 @@ public function testSingleTableInheritance() $cas = new \Foo\Bar\NamespacedBookstoreCashier(); $cas->setName('William'); $cas->save(); - $emps = \Foo\Bar\NamespacedBookstoreEmployeeQuery::create() + $emps = NamespacedBookstoreEmployeeQuery::create() ->orderByName() ->find(); $this->assertEquals(3, count($emps)); - $this->assertTrue($emps[0] instanceof \Foo\Bar\NamespacedBookstoreEmployee); - $this->assertTrue($emps[1] instanceof \Foo\Bar\NamespacedBookstoreManager); - $this->assertTrue($emps[2] instanceof \Foo\Bar\NamespacedBookstoreCashier); + $this->assertTrue($emps[0] instanceof NamespacedBookstoreEmployee); + $this->assertTrue($emps[1] instanceof NamespacedBookstoreManager); + $this->assertTrue($emps[2] instanceof NamespacedBookstoreCashier); $nbMan = \Foo\Bar\NamespacedBookstoreManagerQuery::create() ->count(); $this->assertEquals(1, $nbMan); } + /** + * @return void + */ public function testManyToMany() { - \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); + NamespacedBookQuery::create()->deleteAll(); \Baz\NamespacedBookClubQuery::create()->deleteAll(); \Baz\NamespacedBookListRelQuery::create()->deleteAll(); - $book1 = new \Foo\Bar\NamespacedBook(); + $book1 = new NamespacedBook(); $book1->setTitle('bar'); $book1->setISBN('1234'); $book1->save(); - $book2 = new \Foo\Bar\NamespacedBook(); + $book2 = new NamespacedBook(); $book2->setTitle('foo'); $book2->setISBN('4567'); $book2->save(); @@ -233,25 +277,28 @@ public function testManyToMany() $bookClub1->addNamespacedBook($book2); $bookClub1->setGroupLeader('Someone1'); $bookClub1->save(); - $bookClub2 = new \Baz\NamespacedBookClub(); + $bookClub2 = new NamespacedBookClub(); $bookClub2->addNamespacedBook($book1); $bookClub2->setGroupLeader('Someone2'); $bookClub2->save(); $this->assertEquals(2, $book1->countNamespacedBookClubs()); $this->assertEquals(1, $book2->countNamespacedBookClubs()); - $nbRels = \Baz\NamespacedBookListRelQuery::create()->count(); + $nbRels = NamespacedBookListRelQuery::create()->count(); $this->assertEquals(3, $nbRels); $con = Propel::getServiceContainer()->getConnection(\Baz\Map\NamespacedBookListRelTableMap::DATABASE_NAME); - $books = \Foo\Bar\NamespacedBookQuery::create() + $books = NamespacedBookQuery::create() ->orderByTitle() ->joinWith('NamespacedBookListRel') ->joinWith('NamespacedBookListRel.NamespacedBookClub') ->find($con); } + /** + * @return void + */ public function testUseQuery() { - $book = \Foo\Bar\NamespacedBookQuery::create() + $book = NamespacedBookQuery::create() ->useNamespacedPublisherQuery() ->filterByName('foo') ->endUse() diff --git a/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderNamespaceTest.php b/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderNamespaceTest.php index 417897353d..95482bc01f 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderNamespaceTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderNamespaceTest.php @@ -10,20 +10,23 @@ namespace Propel\Tests\Generator\Builder\Om; +use Propel\Generator\Builder\Om\AbstractOMBuilder; use Propel\Generator\Model\Database; use Propel\Generator\Model\ForeignKey; use Propel\Generator\Model\Table; -use Propel\Generator\Builder\Om\AbstractOMBuilder; use Propel\Tests\TestCase; /** * Test class for OMBuilder. * * @author François Zaninotto - * @version $Id: OMBuilderBuilderTest.php 1347 2009-12-03 21:06:36Z francois $ + * @version $Id: OMBuilderBuilderTest.php 1347 2009-12-03 21:06:36Z francois $ */ class AbstractOMBuilderNamespaceTest extends TestCase { + /** + * @return void + */ public function testNoNamespace() { $d = new Database('fooDb'); @@ -33,6 +36,9 @@ public function testNoNamespace() $this->assertNull($builder->getNamespace(), 'Builder namespace is null when neither the db nor the table have namespace'); } + /** + * @return void + */ public function testDbNamespace() { $d = new Database('fooDb'); @@ -43,6 +49,9 @@ public function testDbNamespace() $this->assertEquals('Foo\\Bar', $builder->getNamespace(), 'Builder namespace is the database namespace when no table namespace is set'); } + /** + * @return void + */ public function testTableNamespace() { $d = new Database('fooDb'); @@ -53,6 +62,9 @@ public function testTableNamespace() $this->assertEquals('Foo\\Bar', $builder->getNamespace(), 'Builder namespace is the table namespace when no database namespace is set'); } + /** + * @return void + */ public function testAbsoluteTableNamespace() { $d = new Database('fooDb'); @@ -63,6 +75,9 @@ public function testAbsoluteTableNamespace() $this->assertEquals('Foo\\Bar', $builder->getNamespace(), 'Builder namespace is the table namespace when it is set as absolute'); } + /** + * @return void + */ public function testAbsoluteTableNamespaceAndDbNamespace() { $d = new Database('fooDb'); @@ -74,6 +89,9 @@ public function testAbsoluteTableNamespaceAndDbNamespace() $this->assertEquals('Foo\\Bar', $builder->getNamespace(), 'Builder namespace is the table namespace when it is set as absolute'); } + /** + * @return void + */ public function testTableNamespaceAndDbNamespace() { $d = new Database('fooDb'); @@ -85,6 +103,9 @@ public function testTableNamespaceAndDbNamespace() $this->assertEquals('Baz\\Foo\\Bar', $builder->getNamespace(), 'Builder namespace is composed from the database and table namespaces when both are set'); } + /** + * @return void + */ public function testDeclareClassNamespace() { $builder = new TestableOMBuilder2(new Table('fooTable')); @@ -107,6 +128,8 @@ public function testDeclareClassNamespace() /** * @expectedException \Propel\Generator\Exception\LogicException + * + * @return void */ public function testDeclareClassNamespaceDuplicateException() { @@ -115,6 +138,9 @@ public function testDeclareClassNamespaceDuplicateException() $builder->declareClassNamespace('Bar', 'Foo'); } + /** + * @return void + */ public function testGetDeclareClass() { $builder = new TestableOMBuilder2(new Table('fooTable')); @@ -132,14 +158,17 @@ public function testGetDeclareClass() $this->assertEquals(['World' => 'World'], $builder->getDeclaredClasses('Hello')); } + /** + * @return void + */ public function testDeclareClasses() { $builder = new TestableOMBuilder2(new Table('fooTable')); $builder->declareClasses('Foo', '\\Bar', 'Baz\\Baz', 'Hello\\Cruel\\World'); $expected = [ - '' => ['Foo' => 'Foo', 'Bar' => 'Bar'], - 'Baz' => ['Baz' => 'Baz'], - 'Hello\\Cruel' => ['World' => 'World'] + '' => ['Foo' => 'Foo', 'Bar' => 'Bar'], + 'Baz' => ['Baz' => 'Baz'], + 'Hello\\Cruel' => ['World' => 'World'], ]; $this->assertEquals($expected, $builder->getDeclaredClasses()); } @@ -157,22 +186,31 @@ public static function getRefRelatedBySuffix(ForeignKey $fk) return parent::getRefRelatedBySuffix($fk); } + /** + * @return void + */ public function getUnprefixedClassName() { } + /** + * @return void + */ protected function addClassOpen(&$script) { - } + /** + * @return void + */ protected function addClassBody(&$script) { - } + /** + * @return void + */ protected function addClassClose(&$script) { - } } diff --git a/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderRelatedByTest.php b/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderRelatedByTest.php index 069e72477a..5cd5beb82a 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderRelatedByTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderRelatedByTest.php @@ -10,9 +10,9 @@ namespace Propel\Tests\Generator\Builder\Om; -use Propel\Generator\Model\ForeignKey; use Propel\Generator\Builder\Om\AbstractOMBuilder; use Propel\Generator\Builder\Util\SchemaReader; +use Propel\Generator\Model\ForeignKey; use Propel\Generator\Platform\DefaultPlatform; use Propel\Tests\TestCase; @@ -20,19 +20,22 @@ * Test class for OMBuilder. * * @author François Zaninotto - * @version $Id: OMBuilderBuilderTest.php 1347 2009-12-03 21:06:36Z francois $ + * @version $Id: OMBuilderBuilderTest.php 1347 2009-12-03 21:06:36Z francois $ */ class AbstractOMBuilderRelatedByTest extends TestCase { public static $database; + /** + * @return void + */ public function setUp(): void { // run only once to save execution time if (null == self::$database) { $schemaReader = new SchemaReader(new DefaultPlatform()); $appData = $schemaReader->parseFile(realpath(__DIR__ . '/../../../../../Fixtures/bookstore/schema.xml')); - self::$database = $appData->getDatabase("bookstore"); + self::$database = $appData->getDatabase('bookstore'); } } @@ -60,6 +63,8 @@ public static function getRelatedBySuffixDataProvider() /** * @dataProvider getRelatedBySuffixDataProvider + * + * @return void */ public function testGetRelatedBySuffix($table, $index, $expectedSuffix, $expectedReverseSuffix) { @@ -81,22 +86,31 @@ public static function getRefRelatedBySuffix(ForeignKey $fk) return parent::getRefRelatedBySuffix($fk); } + /** + * @return void + */ public function getUnprefixedClassName() { } + /** + * @return void + */ protected function addClassOpen(&$script) { - } + /** + * @return void + */ protected function addClassBody(&$script) { - } + /** + * @return void + */ protected function addClassClose(&$script) { - } } diff --git a/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderTest.php b/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderTest.php index 3ab583c48b..f4e01bcd0e 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderTest.php @@ -11,7 +11,6 @@ namespace Propel\Tests\Generator\Builder\Om; use Propel\Generator\Builder\Om\AbstractOMBuilder; - use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\Book; use Propel\Tests\Bookstore\Publisher; @@ -21,11 +20,13 @@ * Test class for OMBuilder. * * @author François Zaninotto - * @version $Id: OMBuilderBuilderTest.php 1347 2009-12-03 21:06:36Z francois $ + * @version $Id: OMBuilderBuilderTest.php 1347 2009-12-03 21:06:36Z francois $ */ class AbstractOMBuilderTest extends TestCase { - + /** + * @return void + */ public function testClear() { $b = new Book(); @@ -38,6 +39,9 @@ public function testClear() $this->assertFalse($b->isDeleted(), 'clear() sets the object to not deleted'); } + /** + * @return void + */ public function testToStringUsesDefaultStringFormat() { $author = new Author(); @@ -51,7 +55,7 @@ public function testToStringUsesDefaultStringFormat() Age: null EOF; - $this->assertEquals($expected, (string) $author, 'generated __toString() uses default string format and exportTo()'); + $this->assertEquals($expected, (string)$author, 'generated __toString() uses default string format and exportTo()'); $publisher = new Publisher(); $publisher->setId(345345); @@ -64,11 +68,13 @@ public function testToStringUsesDefaultStringFormat() EOF; - $this->assertEquals($expected, (string) $publisher, 'generated __toString() uses default string format and exportTo()'); + $this->assertEquals($expected, (string)$publisher, 'generated __toString() uses default string format and exportTo()'); } /** * @dataProvider dataGetPackagePath + * + * @return void */ public function testGetPackagePath($package, $expectedPath) { @@ -100,7 +106,6 @@ public function dataGetPackagePath() ['foo.bar/baz.map', 'foo.bar/baz/map'], ]; } - } class OMBuilderMock extends AbstractOMBuilder @@ -111,6 +116,9 @@ public function __construct() { } + /** + * @return void + */ public function setPackage($pkg) { $this->pkg = $pkg; @@ -121,22 +129,31 @@ public function getPackage() return $this->pkg; } + /** + * @return void + */ public function getUnprefixedClassName() { } + /** + * @return void + */ protected function addClassOpen(&$script) { - } + /** + * @return void + */ protected function addClassBody(&$script) { - } + /** + * @return void + */ protected function addClassClose(&$script) { - } } diff --git a/tests/Propel/Tests/Generator/Builder/Om/Fixtures/ComplexColumnTypeEntityWithConstructor.php b/tests/Propel/Tests/Generator/Builder/Om/Fixtures/ComplexColumnTypeEntityWithConstructor.php index a5f7c36492..54feff9235 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/Fixtures/ComplexColumnTypeEntityWithConstructor.php +++ b/tests/Propel/Tests/Generator/Builder/Om/Fixtures/ComplexColumnTypeEntityWithConstructor.php @@ -10,7 +10,9 @@ namespace Propel\Tests\Generator\Builder\Om\Fixtures; -class ComplexColumnTypeEntityWithConstructor extends \MyNameSpace\Base\ComplexColumnTypeEntityWithConstructor +use MyNameSpace\Base\ComplexColumnTypeEntityWithConstructor as MyNameSpaceComplexColumnTypeEntityWithConstructor; + +class ComplexColumnTypeEntityWithConstructor extends MyNameSpaceComplexColumnTypeEntityWithConstructor { public function __construct() { diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectArrayColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectArrayColumnTypeTest.php index 6fe28114ce..706c8da5a7 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectArrayColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectArrayColumnTypeTest.php @@ -7,16 +7,16 @@ * * @license MIT License */ + namespace Propel\Tests\Generator\Builder\Om; use MyNameSpace\ComplexColumnTypeEntity2; use MyNameSpace\ComplexColumnTypeEntity2Query; -use MyNameSpace\Map\ComplexColumnTypeEntity2TableMap; use MyNameSpace\ComplexColumnTypeEntityWithConstructorQuery; - +use MyNameSpace\Map\ComplexColumnTypeEntity2TableMap; use Propel\Generator\Util\QuickBuilder; -use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\Propel; use Propel\Tests\Generator\Builder\Om\Fixtures\ComplexColumnTypeEntityWithConstructor; use Propel\Tests\TestCase; @@ -27,6 +27,9 @@ */ class GeneratedObjectArrayColumnTypeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('MyNameSpace\\ComplexColumnTypeEntity2')) { @@ -47,6 +50,9 @@ public function setUp(): void ComplexColumnTypeEntity2TableMap::doDeleteAll(); } + /** + * @return void + */ public function testActiveRecordMethods() { $this->assertTrue(method_exists('MyNameSpace\ComplexColumnTypeEntity2', 'getTags')); @@ -62,24 +68,36 @@ public function testActiveRecordMethods() $this->assertFalse(method_exists('MyNameSpace\ComplexColumnTypeEntity2', 'removeValueSet')); } + /** + * @return void + */ public function testGetterDefaultValue() { $e = new ComplexColumnTypeEntity2(); $this->assertEquals([], $e->getTags(), 'array columns return an empty array by default'); } + /** + * @return void + */ public function testGetterDefaultValueWithData() { $e = new ComplexColumnTypeEntity2(); $this->assertEquals(['FOO'], $e->getDefaults()); } + /** + * @return void + */ public function testGetterDefaultValueWithMultipleData() { $e = new ComplexColumnTypeEntity2(); $this->assertEquals(['FOO', 'BAR', 'BAZ'], $e->getMultipleDefaults()); } + /** + * @return void + */ public function testAdderAddsNewValueToExistingData() { $e = new ComplexColumnTypeEntity2(); @@ -88,6 +106,9 @@ public function testAdderAddsNewValueToExistingData() $this->assertEquals(['FOO', 'bar'], $e->getDefaults()); } + /** + * @return void + */ public function testAdderAddsNewValueToMultipleExistingData() { $e = new ComplexColumnTypeEntity2(); @@ -96,6 +117,9 @@ public function testAdderAddsNewValueToMultipleExistingData() $this->assertEquals(['FOO', 'BAR', 'BAZ', 'bar'], $e->getMultipleDefaults()); } + /** + * @return void + */ public function testDefaultValuesAreWellPersisted() { $e = new ComplexColumnTypeEntity2(); @@ -107,6 +131,9 @@ public function testDefaultValuesAreWellPersisted() $this->assertEquals(['FOO'], $e->getDefaults()); } + /** + * @return void + */ public function testMultipleDefaultValuesAreWellPersisted() { $e = new ComplexColumnTypeEntity2(); @@ -118,6 +145,9 @@ public function testMultipleDefaultValuesAreWellPersisted() $this->assertEquals(['FOO', 'BAR', 'BAZ'], $e->getMultipleDefaults()); } + /** + * @return void + */ public function testSetterArrayValue() { $e = new ComplexColumnTypeEntity2(); @@ -126,6 +156,9 @@ public function testSetterArrayValue() $this->assertEquals($value, $e->getTags(), 'array columns can store arrays'); } + /** + * @return void + */ public function testGetterForArrayWithOnlyOneZeroValue() { $e = new ComplexColumnTypeEntity2(); @@ -134,6 +167,9 @@ public function testGetterForArrayWithOnlyOneZeroValue() $this->assertEquals($value, $e->getTags()); } + /** + * @return void + */ public function testSetterResetValue() { $e = new ComplexColumnTypeEntity2(); @@ -143,6 +179,9 @@ public function testSetterResetValue() $this->assertEquals([], $e->getTags(), 'object columns can be reset'); } + /** + * @return void + */ public function testTester() { $e = new ComplexColumnTypeEntity2(); @@ -156,6 +195,9 @@ public function testTester() $this->assertFalse($e->hasTag(12)); } + /** + * @return void + */ public function testAdder() { $e = new ComplexColumnTypeEntity2(); @@ -170,6 +212,9 @@ public function testAdder() $this->assertEquals([12, 34, 'foo'], $e->getTags()); } + /** + * @return void + */ public function testRemover() { $e = new ComplexColumnTypeEntity2(); @@ -187,6 +232,9 @@ public function testRemover() $this->assertEquals([12, 34], $e->getTags()); } + /** + * @return void + */ public function testValueIsPersisted() { $e = new ComplexColumnTypeEntity2(); @@ -198,16 +246,19 @@ public function testValueIsPersisted() $this->assertEquals($value, $e->getTags(), 'array columns are persisted'); } + /** + * @return void + */ public function testGetterDoesNotKeepValueBetweenTwoHydrationsWhenUsingOnDemandFormatter() { ComplexColumnTypeEntity2Query::create()->deleteAll(); $e = new ComplexColumnTypeEntity2(); - $e->setTags([1,2]); + $e->setTags([1, 2]); $e->save(); $e = new ComplexColumnTypeEntity2(); - $e->setTags([3,4]); + $e->setTags([3, 4]); $e->save(); $q = ComplexColumnTypeEntity2Query::create() @@ -221,6 +272,9 @@ public function testGetterDoesNotKeepValueBetweenTwoHydrationsWhenUsingOnDemandF $this->assertNotEquals($tags[0], $tags[1]); } + /** + * @return void + */ public function testHydrateOverwritePreviousValues() { $schema = <<assertTrue(method_exists('ComplexColumnTypeEntity4', 'isBar')); @@ -73,6 +77,8 @@ public function providerForSetter() /** * @dataProvider providerForSetter + * + * @return void */ public function testSetterBooleanValue($value, $expected) { @@ -87,6 +93,9 @@ public function testSetterBooleanValue($value, $expected) } } + /** + * @return void + */ public function testDefaultValue() { $e = new ComplexColumnTypeEntity4(); @@ -94,5 +103,4 @@ public function testDefaultValue() $this->assertTrue($e->getTrueBar()); $this->assertFalse($e->getFalseBar()); } - } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php index 74a4d95c74..df2b93c0d7 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php @@ -10,10 +10,12 @@ namespace Propel\Tests\Generator\Builder\Om; +use ComplexColumnTypeEntity3; +use ComplexColumnTypeEntity3Query; +use Map\ComplexColumnTypeEntity3TableMap; use Propel\Generator\Util\QuickBuilder; - -use Propel\Runtime\Propel; use Propel\Tests\TestCase; +use PublicComplexColumnTypeEntity3; /** * Tests the generated objects for enum column types accessor & mutator @@ -22,6 +24,9 @@ */ class GeneratedObjectEnumColumnTypeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('ComplexColumnTypeEntity3')) { @@ -46,12 +51,15 @@ class PublicComplexColumnTypeEntity3 extends ComplexColumnTypeEntity3 } } + /** + * @return void + */ public function testGetter() { $this->assertTrue(method_exists('ComplexColumnTypeEntity3', 'getBar')); - $e = new \ComplexColumnTypeEntity3(); + $e = new ComplexColumnTypeEntity3(); $this->assertNull($e->getBar()); - $e = new \PublicComplexColumnTypeEntity3(); + $e = new PublicComplexColumnTypeEntity3(); $e->bar = 0; $this->assertEquals('foo', $e->getBar()); $e->bar = 3; @@ -62,24 +70,32 @@ public function testGetter() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testGetterThrowsExceptionOnUnknownKey() { - $e = new \PublicComplexColumnTypeEntity3(); + $e = new PublicComplexColumnTypeEntity3(); $e->bar = 156; $e->getBar(); } + /** + * @return void + */ public function testGetterDefaultValue() { - $e = new \PublicComplexColumnTypeEntity3(); + $e = new PublicComplexColumnTypeEntity3(); $this->assertEquals('bar', $e->getBar2()); } + /** + * @return void + */ public function testSetter() { $this->assertTrue(method_exists('\ComplexColumnTypeEntity3', 'setBar')); - $e = new \PublicComplexColumnTypeEntity3(); + $e = new PublicComplexColumnTypeEntity3(); $e->setBar('foo'); $this->assertEquals(0, $e->bar); $e->setBar(1); @@ -92,38 +108,48 @@ public function testSetter() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testSetterThrowsExceptionOnUnknownValue() { - $e = new \ComplexColumnTypeEntity3(); + $e = new ComplexColumnTypeEntity3(); $e->setBar('bazz'); } + /** + * @return void + */ public function testValueIsPersisted() { - $e = new \ComplexColumnTypeEntity3(); + $e = new ComplexColumnTypeEntity3(); $e->setBar('baz'); $e->save(); - \Map\ComplexColumnTypeEntity3TableMap::clearInstancePool(); - $e = \ComplexColumnTypeEntity3Query::create()->findOne(); + ComplexColumnTypeEntity3TableMap::clearInstancePool(); + $e = ComplexColumnTypeEntity3Query::create()->findOne(); $this->assertEquals('baz', $e->getBar()); } + /** + * @return void + */ public function testValueIsCopied() { - $e1 = new \ComplexColumnTypeEntity3(); + $e1 = new ComplexColumnTypeEntity3(); $e1->setBar('baz'); - $e2 = new \ComplexColumnTypeEntity3(); + $e2 = new ComplexColumnTypeEntity3(); $e1->copyInto($e2); $this->assertEquals('baz', $e2->getBar()); } /** * @see https://github.com/propelorm/Propel/issues/139 + * + * @return void */ public function testSetterWithSameValueDoesNotUpdateObject() { - $e = new \ComplexColumnTypeEntity3(); + $e = new ComplexColumnTypeEntity3(); $e->setBar('baz'); $e->resetModified(); $e->setBar('baz'); @@ -132,15 +158,17 @@ public function testSetterWithSameValueDoesNotUpdateObject() /** * @see https://github.com/propelorm/Propel/issues/139 + * + * @return void */ public function testSetterWithSameValueDoesNotUpdateHydratedObject() { - $e = new \ComplexColumnTypeEntity3(); + $e = new ComplexColumnTypeEntity3(); $e->setBar('baz'); $e->save(); // force hydration - \Map\ComplexColumnTypeEntity3TableMap::clearInstancePool(); - $e = \ComplexColumnTypeEntity3Query::create()->findPk($e->getPrimaryKey()); + ComplexColumnTypeEntity3TableMap::clearInstancePool(); + $e = ComplexColumnTypeEntity3Query::create()->findPk($e->getPrimaryKey()); $e->setBar('baz'); $this->assertFalse($e->isModified()); } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectJsonColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectJsonColumnTypeTest.php index 4541237f73..c8c2f8bb2c 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectJsonColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectJsonColumnTypeTest.php @@ -10,10 +10,12 @@ namespace Propel\Tests\Generator\Builder\Om; +use ComplexColumnTypeJsonEntity; +use ComplexColumnTypeJsonEntityQuery; +use Map\ComplexColumnTypeJsonEntityTableMap; use Propel\Generator\Util\QuickBuilder; - -use Propel\Runtime\Propel; use Propel\Tests\TestCase; +use PublicComplexColumnTypeJsonEntity; /** * Tests the generated objects for enum column types accessor & mutator @@ -22,6 +24,9 @@ */ class GeneratedObjectJsonColumnTypeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('ComplexColumnTypeJsonEntity')) { @@ -45,82 +50,97 @@ class PublicComplexColumnTypeJsonEntity extends ComplexColumnTypeJsonEntity } } + /** + * @return void + */ public function testGetter() { $this->assertTrue(method_exists('ComplexColumnTypeJsonEntity', 'getBar')); - $e = new \ComplexColumnTypeJsonEntity(); + $e = new ComplexColumnTypeJsonEntity(); $this->assertInstanceOf('stdClass', $e->getBar(false)); - $e = new \PublicComplexColumnTypeJsonEntity(); + $e = new PublicComplexColumnTypeJsonEntity(); $e->bar = '{"key":"value"}'; $this->assertInstanceOf('stdClass', $e->getBar(false)); $this->assertEquals('value', $e->getBar(false)->key); $this->assertEquals('value', $e->getBar()['key']); } + /** + * @return void + */ public function testSetter() { $this->assertTrue(method_exists('ComplexColumnTypeJsonEntity', 'setBar')); - $e = new \PublicComplexColumnTypeJsonEntity(); - $e->setBar(array( - 'key' => 'value' - )); + $e = new PublicComplexColumnTypeJsonEntity(); + $e->setBar([ + 'key' => 'value', + ]); $this->assertEquals('{"key":"value"}', $e->bar); $e->setBar(null); $this->assertNull($e->getBar()); } + /** + * @return void + */ public function testIsModified() { - $this->assertTrue(method_exists('ComplexColumnTypeJsonEntity', 'setBar')); - $e = new \PublicComplexColumnTypeJsonEntity(); - $e->setBar(array( - 'key' => 'value' - )); - $this->assertTrue($e->isModified()); + $this->assertTrue(method_exists('ComplexColumnTypeJsonEntity', 'setBar')); + $e = new PublicComplexColumnTypeJsonEntity(); + $e->setBar([ + 'key' => 'value', + ]); + $this->assertTrue($e->isModified()); - $e = new \PublicComplexColumnTypeJsonEntity(); - $e->setBar(array( - 'defaultKey' => 'defaultValue' - )); - $this->assertFalse($e->isModified()); + $e = new PublicComplexColumnTypeJsonEntity(); + $e->setBar([ + 'defaultKey' => 'defaultValue', + ]); + $this->assertFalse($e->isModified()); - $e->setBar('{"defaultKey":"defaultValue"}'); - $this->assertFalse($e->isModified()); + $e->setBar('{"defaultKey":"defaultValue"}'); + $this->assertFalse($e->isModified()); - $e->setBar('{"defaultKey" : "defaultValue"}'); - $this->assertFalse($e->isModified()); + $e->setBar('{"defaultKey" : "defaultValue"}'); + $this->assertFalse($e->isModified()); - $e->setBar((object)array( - 'defaultKey' => 'defaultValue' - )); - $this->assertFalse($e->isModified()); + $e->setBar((object)[ + 'defaultKey' => 'defaultValue', + ]); + $this->assertFalse($e->isModified()); - $e->setBar((object)array( - 'key' => 'value' - )); - $this->assertTrue($e->isModified()); + $e->setBar((object)[ + 'key' => 'value', + ]); + $this->assertTrue($e->isModified()); } + /** + * @return void + */ public function testValueIsPersisted() { - $e = new \ComplexColumnTypeJsonEntity(); - $e->setBar(array( - 'key' => 'value' - )); + $e = new ComplexColumnTypeJsonEntity(); + $e->setBar([ + 'key' => 'value', + ]); $e->save(); - \Map\ComplexColumnTypeJsonEntityTableMap::clearInstancePool(); - $e = \ComplexColumnTypeJsonEntityQuery::create()->findOne(); + ComplexColumnTypeJsonEntityTableMap::clearInstancePool(); + $e = ComplexColumnTypeJsonEntityQuery::create()->findOne(); $this->assertEquals('value', $e->getBar(false)->key); $this->assertEquals('value', $e->getBar()['key']); } + /** + * @return void + */ public function testValueIsCopied() { - $e1 = new \ComplexColumnTypeJsonEntity(); - $e1->setBar(array( - 'key' => 'value' - )); - $e2 = new \ComplexColumnTypeJsonEntity(); + $e1 = new ComplexColumnTypeJsonEntity(); + $e1->setBar([ + 'key' => 'value', + ]); + $e2 = new ComplexColumnTypeJsonEntity(); $e1->copyInto($e2); $this->assertEquals('value', $e2->getBar()['key']); $this->assertEquals('value', $e2->getBar(false)->key); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLazyLoadTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLazyLoadTest.php index d5b177f080..18d1a1ff0b 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLazyLoadTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLazyLoadTest.php @@ -10,17 +10,21 @@ namespace Propel\Tests\Generator\Builder\Om; +use LazyLoadActiveRecord; +use LazyLoadActiveRecordQuery; +use Map\LazyLoadActiveRecordTableMap; use Propel\Generator\Util\QuickBuilder; - use Propel\Runtime\Propel; use Propel\Tests\TestCase; /** * Tests the generated Object classes for lazy load columns. - * */ class GeneratedObjectLazyLoadTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('LazyLoadActiveRecord')) { @@ -39,43 +43,52 @@ public function setUp(): void } } + /** + * @return void + */ public function testNormalColumnsRequireNoQueryOnGetter() { - $con = Propel::getServiceContainer()->getConnection(\Map\LazyLoadActiveRecordTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getConnection(LazyLoadActiveRecordTableMap::DATABASE_NAME); $con->useDebug(true); - $obj = new \LazyLoadActiveRecord(); + $obj = new LazyLoadActiveRecord(); $obj->setFoo('hello'); $obj->save($con); - \Map\LazyLoadActiveRecordTableMap::clearInstancePool(); - $obj2 = \LazyLoadActiveRecordQuery::create()->findPk($obj->getId(), $con); + LazyLoadActiveRecordTableMap::clearInstancePool(); + $obj2 = LazyLoadActiveRecordQuery::create()->findPk($obj->getId(), $con); $count = $con->getQueryCount(); $this->assertEquals('hello', $obj2->getFoo()); $this->assertEquals($count, $con->getQueryCount()); } + /** + * @return void + */ public function testLazyLoadedColumnsRequireAnAdditionalQueryOnGetter() { - $con = Propel::getServiceContainer()->getConnection(\Map\LazyLoadActiveRecordTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getConnection(LazyLoadActiveRecordTableMap::DATABASE_NAME); $con->useDebug(true); - $obj = new \LazyLoadActiveRecord(); + $obj = new LazyLoadActiveRecord(); $obj->setBar('hello'); $obj->save($con); - \Map\LazyLoadActiveRecordTableMap::clearInstancePool(); - $obj2 = \LazyLoadActiveRecordQuery::create()->findPk($obj->getId(), $con); + LazyLoadActiveRecordTableMap::clearInstancePool(); + $obj2 = LazyLoadActiveRecordQuery::create()->findPk($obj->getId(), $con); $count = $con->getQueryCount(); $this->assertEquals('hello', $obj2->getBar($con)); $this->assertEquals($count + 1, $con->getQueryCount()); } + /** + * @return void + */ public function testLazyLoadedColumnsWithDefaultRequireAnAdditionalQueryOnGetter() { - $con = Propel::getServiceContainer()->getConnection(\Map\LazyLoadActiveRecordTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getConnection(LazyLoadActiveRecordTableMap::DATABASE_NAME); $con->useDebug(true); - $obj = new \LazyLoadActiveRecord(); + $obj = new LazyLoadActiveRecord(); $obj->setBaz('hello'); $obj->save($con); - \Map\LazyLoadActiveRecordTableMap::clearInstancePool(); - $obj2 = \LazyLoadActiveRecordQuery::create()->findPk($obj->getId(), $con); + LazyLoadActiveRecordTableMap::clearInstancePool(); + $obj2 = LazyLoadActiveRecordQuery::create()->findPk($obj->getId(), $con); $count = $con->getQueryCount(); $this->assertEquals('hello', $obj2->getBaz($con)); $this->assertEquals($count + 1, $con->getQueryCount()); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLobTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLobTest.php index 232b9af9c0..c6b6a0fba8 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLobTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLobTest.php @@ -10,12 +10,12 @@ namespace Propel\Tests\Generator\Builder\Om; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; -use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; use Propel\Tests\Bookstore\BookQuery; +use Propel\Tests\Bookstore\Map\MediaTableMap; use Propel\Tests\Bookstore\Media; use Propel\Tests\Bookstore\MediaQuery; -use Propel\Tests\Bookstore\Map\MediaTableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; if (!defined('TESTS_BASE_DIR')) { define('TESTS_BASE_DIR', realpath(__DIR__ . '/../../../../..')); @@ -25,22 +25,21 @@ * Tests the generated Object classes and LOB behavior. * * This test uses generated Bookstore classes to test the behavior of various - * object operations. The _idea_ here is to test every possible generated method + * object operations. The _idea_ here is to test every possible generated method * from Object.tpl; if necessary, bookstore will be expanded to accommodate this. * - * The database is reloaded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same - * for each test method in this class. See the BookstoreDataPopulator::populate() + * for each test method in this class. See the BookstoreDataPopulator::populate() * method for the exact contents of the database. * - * @see BookstoreDataPopulator + * @see BookstoreDataPopulator * @author Hans Lellelid * * @group database */ class GeneratedObjectLobTest extends BookstoreEmptyTestBase { - /** * Array of filenames pointing to blob/clob files indexed by the basename. * @@ -48,21 +47,26 @@ class GeneratedObjectLobTest extends BookstoreEmptyTestBase */ protected $sampleLobFiles = []; + /** + * @return void + */ protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate(); $this->sampleLobFiles['tin_drum.gif'] = TESTS_BASE_DIR . '/Fixtures/etc/lob/tin_drum.gif'; $this->sampleLobFiles['tin_drum.txt'] = TESTS_BASE_DIR . '/Fixtures/etc/lob/tin_drum.txt'; - $this->sampleLobFiles['propel.gif'] = TESTS_BASE_DIR . '/Fixtures/etc/lob/propel.gif'; + $this->sampleLobFiles['propel.gif'] = TESTS_BASE_DIR . '/Fixtures/etc/lob/propel.gif'; } /** * Gets a LOB filename. * - * @param string $basename Basename of LOB filename to return (if left blank, will choose random file). - * @return string + * @param string|null $basename Basename of LOB filename to return (if left blank, will choose random file). + * * @throws Exception - if specified basename doesn't correspond to a registered LOB filename + * + * @return string */ protected function getLobFile($basename = null) { @@ -79,10 +83,11 @@ protected function getLobFile($basename = null) /** * Test the LOB results returned in a resultset. + * + * @return void */ public function testLobResults() { - $blob_path = $this->getLobFile('tin_drum.gif'); $clob_path = $this->getLobFile('tin_drum.txt'); @@ -100,14 +105,14 @@ public function testLobResults() $img = $m1->getCoverImage(); $txt = $m1->getExcerpt(); - $this->assertInternalType('resource', $img, "Expected results of BLOB method to be a resource."); - $this->assertInternalType('string', $txt, "Expected results of CLOB method to be a string."); + $this->assertInternalType('resource', $img, 'Expected results of BLOB method to be a resource.'); + $this->assertInternalType('string', $txt, 'Expected results of CLOB method to be a string.'); $stat = fstat($img); $size = $stat['size']; - $this->assertEquals(filesize($blob_path), $size, "Expected filesize to match stat(blobrsc)"); - $this->assertEquals(filesize($clob_path), strlen($txt), "Expected filesize to match clob strlen"); + $this->assertEquals(filesize($blob_path), $size, 'Expected filesize to match stat(blobrsc)'); + $this->assertEquals(filesize($clob_path), strlen($txt), 'Expected filesize to match clob strlen'); } /** @@ -119,7 +124,9 @@ public function testLobResults() * * This does test the rewind-after-save functionality, however. * - * @link http://propel.phpdb.org/trac/ticket/531 + * @link http://propel.phpdb.org/trac/ticket/531 + * + * @return void */ public function testLobRepeatRead() { @@ -138,26 +145,28 @@ public function testLobRepeatRead() // 1) Assert that this resource has been rewound. - $this->assertEquals(0, ftell($img), "Expected position of cursor in file pointer to be 0"); + $this->assertEquals(0, ftell($img), 'Expected position of cursor in file pointer to be 0'); // 1) Assert that we've got a valid stream to start with - $this->assertInternalType('resource', $img, "Expected results of BLOB method to be a resource."); + $this->assertInternalType('resource', $img, 'Expected results of BLOB method to be a resource.'); // read first 100 bytes $firstBytes = fread($img, 100); $img2 = $m1->getCoverImage(); - $this->assertSame($img, $img2, "Assert that the two resources are the same."); + $this->assertSame($img, $img2, 'Assert that the two resources are the same.'); // read next 100 bytes $nextBytes = fread($img, 100); - $this->assertNotEquals(bin2hex($firstBytes), bin2hex($nextBytes), "Expected the first 100 and next 100 bytes to not be identical."); + $this->assertNotEquals(bin2hex($firstBytes), bin2hex($nextBytes), 'Expected the first 100 and next 100 bytes to not be identical.'); } /** * Tests the setting of null LOBs + * + * @return void */ public function testLobNulls() { @@ -165,7 +174,7 @@ public function testLobNulls() $m1 = new Media(); $m1->setBook($book); - $this->assertTrue($m1->getCoverImage() === null, "Initial LOB value for a new object should be null."); + $this->assertTrue($m1->getCoverImage() === null, 'Initial LOB value for a new object should be null.'); $m1->save(); $m1_id = $m1->getId(); @@ -173,20 +182,22 @@ public function testLobNulls() $m2 = new Media(); $m2->setBook($book); $m2->setCoverImage(null); - $this->assertTrue($m2->getCoverImage() === null, "Setting a LOB to null should cause accessor to return null."); + $this->assertTrue($m2->getCoverImage() === null, 'Setting a LOB to null should cause accessor to return null.'); $m2->save(); $m2_id = $m2->getId(); $m1->reload(); - $this->assertTrue($m1->getCoverImage() === null, "Default null LOB value should be null after a reload."); + $this->assertTrue($m1->getCoverImage() === null, 'Default null LOB value should be null after a reload.'); $m2->reload(); - $this->assertTrue($m2->getCoverImage() === null, "LOB value set to null should be null after a reload."); + $this->assertTrue($m2->getCoverImage() === null, 'LOB value set to null should be null after a reload.'); } /** * Tests the setting of LOB (BLOB and CLOB) values. + * + * @return void */ public function testLobSetting() { @@ -205,25 +216,25 @@ public function testLobSetting() // 1) Assert that we've got a valid stream to start with $img = $m1->getCoverImage(); - $this->assertInternalType('resource', $img, "Expected results of BLOB method to be a resource."); + $this->assertInternalType('resource', $img, 'Expected results of BLOB method to be a resource.'); // 2) Test setting a BLOB column with file contents $m1->setCoverImage(file_get_contents($blob2_path)); - $this->assertInternalType('resource', $m1->getCoverImage(), "Expected to get a resource back after setting BLOB with file contents."); + $this->assertInternalType('resource', $m1->getCoverImage(), 'Expected to get a resource back after setting BLOB with file contents.'); // commit those changes & reload $m1->save(); // 3) Verify that we've got a valid resource after reload $m1->reload(); - $this->assertInternalType('resource', $m1->getCoverImage(), "Expected to get a resource back after setting reloading object."); + $this->assertInternalType('resource', $m1->getCoverImage(), 'Expected to get a resource back after setting reloading object.'); // 4) Test isModified() behavior - $fp = fopen("php://temp", "r+"); + $fp = fopen('php://temp', 'r+'); fwrite($fp, file_get_contents($blob2_path)); $m1->setCoverImage($fp); - $this->assertTrue($m1->isModified(), "Expected Media object to be modified, despite fact that stream is to same data"); + $this->assertTrue($m1->isModified(), 'Expected Media object to be modified, despite fact that stream is to same data'); // 5) Test external modification of the stream (and re-setting it into the object) $stream = $m1->getCoverImage(); @@ -231,7 +242,7 @@ public function testLobSetting() $m1->setCoverImage($stream); - $this->assertTrue($m1->isModified(), "Expected Media object to be modified when stream contents changed."); + $this->assertTrue($m1->isModified(), 'Expected Media object to be modified when stream contents changed.'); $this->assertNotEquals(file_get_contents($blob2_path), stream_get_contents($m1->getCoverImage())); $m1->save(); @@ -241,20 +252,22 @@ public function testLobSetting() $m1->reload(); // start with a fresh copy from db // Ensure that object is set up correctly - $this->assertNotEquals(file_get_contents($blob_path), stream_get_contents($m1->getCoverImage()), "The object is not correctly set up to verify the stream-setting test."); + $this->assertNotEquals(file_get_contents($blob_path), stream_get_contents($m1->getCoverImage()), 'The object is not correctly set up to verify the stream-setting test.'); - $fp = fopen($blob_path, "r"); + $fp = fopen($blob_path, 'r'); $m1->setCoverImage($fp); $m1->save(); $m1->reload(); // refresh from db // Assert that we've updated the db - $this->assertEquals(md5(file_get_contents($blob_path)), md5(stream_get_contents($m1->getCoverImage())), "Expected the updated BLOB value after setting with a stream."); + $this->assertEquals(md5(file_get_contents($blob_path)), md5(stream_get_contents($m1->getCoverImage())), 'Expected the updated BLOB value after setting with a stream.'); // 7) Assert that 'w' mode works - } + /** + * @return void + */ public function testLobSetting_WriteMode() { $blob_path = $this->getLobFile('tin_drum.gif'); @@ -276,7 +289,7 @@ public function testLobSetting_WriteMode() // now attempt to assign a temporary stream, opened in 'w' mode, to the db - $stream = fopen("php://memory", 'w'); + $stream = fopen('php://memory', 'w'); fwrite($stream, file_get_contents($blob2_path)); $m2->setCoverImage($stream); $m2->save(); @@ -285,17 +298,15 @@ public function testLobSetting_WriteMode() $m2->reload(); $this->assertEquals(md5(file_get_contents($blob2_path)), md5(stream_get_contents($m2->getCoverImage())), "Expected contents to match when setting stream w/ 'w' mode"); - $stream2 = fopen("php://memory", 'w+'); + $stream2 = fopen('php://memory', 'w+'); fwrite($stream2, file_get_contents($blob_path)); rewind($stream2); - $this->assertEquals(md5(file_get_contents($blob_path)), md5(stream_get_contents($stream2)), "Expecting setup to be correct"); + $this->assertEquals(md5(file_get_contents($blob_path)), md5(stream_get_contents($stream2)), 'Expecting setup to be correct'); $m2->setCoverImage($stream2); $m2->save(); $m2->reload(); $this->assertEquals(md5(file_get_contents($blob_path)), md5(stream_get_contents($m2->getCoverImage())), "Expected contents to match when setting stream w/ 'w+' mode"); - } - } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationSimpleTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationSimpleTest.php index d88271ac42..550b1b6764 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationSimpleTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationSimpleTest.php @@ -2,11 +2,12 @@ namespace Propel\Tests\Generator\Builder\Om; -use Propel\Generator\Platform\MysqlPlatform; -use Propel\Generator\Util\QuickBuilder; +use Map\Relation1UserTableMap; use Propel\Runtime\Collection\ObjectCollection; -use Propel\Runtime\Collection\ObjectCombinationCollection; use Propel\Tests\Helpers\PlatformDatabaseBuildTimeBase; +use Relation1User; +use Relation1UserFriendQuery; +use Relation1UserQuery; /** * @group database @@ -14,8 +15,12 @@ class GeneratedObjectM2MRelationSimpleTest extends PlatformDatabaseBuildTimeBase { protected $databaseName = 'migration'; + protected $connected = false; + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -48,29 +53,31 @@ public function setUp(): void } /** - * * addFriend | removeFriend | setFriends | getFriends * +--------------------------------------------------- - * addFriend | 1 2 3 4 - * removeFriend | 5 6 7 8 - * setFriends | 9 10 11 12 - * + * addFriend | 1 2 3 4 + * removeFriend | 5 6 7 8 + * setFriends | 9 10 11 12 */ /* * #################################### * 1. addFriend, addFriend */ + + /** + * @return void + */ public function test1() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); - $friend1 = (new \Relation1User())->setName('Friend 1'); - $friend2 = (new \Relation1User())->setName('Friend 2'); + $friend1 = (new Relation1User())->setName('Friend 1'); + $friend2 = (new Relation1User())->setName('Friend 2'); $hans->addFriend($friend1); $this->assertCount(1, $hans->getFriends(), 'one friend'); @@ -78,35 +85,38 @@ public function test1() $this->assertCount(2, $hans->getFriends(), 'two friends'); $hans->save(); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(2, \Relation1UserFriendQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(2, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); - + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(2, Relation1UserFriendQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(2, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); } /* * #################################### * 2. addFriend, removeFriend */ + + /** + * @return void + */ public function test2() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); - $friend1 = (new \Relation1User())->setName('Friend 1'); - $friend2 = (new \Relation1User())->setName('Friend 2'); + $friend1 = (new Relation1User())->setName('Friend 1'); + $friend2 = (new Relation1User())->setName('Friend 2'); $hans->addFriend($friend1); $hans->addFriend($friend2); $this->assertEquals($hans, $friend1->getWhos()->getFirst(), 'Hans is friend1\'s friend.'); $this->assertEquals($hans, $friend2->getWhos()->getFirst(), 'Hans is friend2\'s friend.'); $hans->save(); $this->assertCount(1, $friend1->getWhos(), 'Friend 1 is from one guy (hans) a friend'); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(2, \Relation1UserFriendQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(2, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(2, Relation1UserFriendQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(2, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); $hans->removeFriend($friend1); $this->assertCount(0, $friend1->getWhos(), 'Friend 1 is from nobody a friend'); @@ -117,111 +127,118 @@ public function test2() $this->assertCount(0, $friend1->getWhos(), 'Friend 1 is from nobody a friend'); $this->assertEquals($hans, $friend2->getWhos()->getFirst(), 'Hans is friend2\'s friend.'); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(1, \Relation1UserFriendQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); - $this->assertEquals($friend2, \Relation1UserQuery::create()->filterByWho($hans)->findOne(), 'Hans has Friend 2 as friend'); - + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(1, Relation1UserFriendQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); + $this->assertEquals($friend2, Relation1UserQuery::create()->filterByWho($hans)->findOne(), 'Hans has Friend 2 as friend'); } /* * #################################### * 3. addFriend, setFriends */ + + /** + * @return void + */ public function test3() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); - $friend1 = (new \Relation1User())->setName('Friend 1'); + $friend1 = (new Relation1User())->setName('Friend 1'); $hans->addFriend($friend1); $hans->save(); - $this->assertEquals(2, \Relation1UserQuery::create()->count(), 'We have two users.'); - $this->assertEquals(1, \Relation1UserFriendQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); - $this->assertEquals($friend1, \Relation1UserQuery::create()->filterByWho($hans)->findOne(), 'Hans has Friend 1 as friend'); + $this->assertEquals(2, Relation1UserQuery::create()->count(), 'We have two users.'); + $this->assertEquals(1, Relation1UserFriendQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); + $this->assertEquals($friend1, Relation1UserQuery::create()->filterByWho($hans)->findOne(), 'Hans has Friend 1 as friend'); $friends = new ObjectCollection(); $friends[] = $friend1; - $friends[] = $friend2 = (new \Relation1User())->setName('Friend 2'); + $friends[] = $friend2 = (new Relation1User())->setName('Friend 2'); $hans->setFriends($friends); $this->assertCount(2, $hans->getFriends(), 'two friends'); $hans->save(); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(2, \Relation1UserFriendQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(2, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); - + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(2, Relation1UserFriendQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(2, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); } /* * #################################### * 4. addFriend, getFriend */ + + /** + * @return void + */ public function test4() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); - $friend1 = (new \Relation1User())->setName('Friend 1'); + $friend1 = (new Relation1User())->setName('Friend 1'); $hans->addFriend($friend1); $this->assertCount(1, $hans->getFriends()); $hans->save(); - $this->assertEquals(2, \Relation1UserQuery::create()->count(), 'We have two users.'); - $this->assertEquals(1, \Relation1UserFriendQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); + $this->assertEquals(2, Relation1UserQuery::create()->count(), 'We have two users.'); + $this->assertEquals(1, Relation1UserFriendQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); $this->assertCount(1, $hans->getFriends()); - } /* * #################################### * 5. removeFriend, addFriend */ + + /** + * @return void + */ public function test5() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); - $friend1 = (new \Relation1User())->setName('Friend 1'); + $friend1 = (new Relation1User())->setName('Friend 1'); $hans->addFriend($friend1); $this->assertCount(1, $hans->getFriends()); $hans->save(); - $this->assertEquals(2, \Relation1UserQuery::create()->count(), 'We have two users.'); - $this->assertEquals(1, \Relation1UserFriendQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); - $this->assertEquals($friend1, \Relation1UserQuery::create()->filterByWho($hans)->findOne(), 'Hans has Friend 1 as friend'); + $this->assertEquals(2, Relation1UserQuery::create()->count(), 'We have two users.'); + $this->assertEquals(1, Relation1UserFriendQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); + $this->assertEquals($friend1, Relation1UserQuery::create()->filterByWho($hans)->findOne(), 'Hans has Friend 1 as friend'); $this->assertCount(1, $hans->getFriends()); - //db prepared. - $friend2 = (new \Relation1User())->setName('Friend 2'); + $friend2 = (new Relation1User())->setName('Friend 2'); $hans->removeFriend($friend1); $this->assertCount(0, $hans->getFriends()); $hans->addFriend($friend2); $this->assertCount(1, $hans->getFriends()); $hans->save(); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(1, \Relation1UserFriendQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); - $this->assertEquals($friend2, \Relation1UserQuery::create()->filterByWho($hans)->findOne(), 'Hans has Friend 2 as friend'); - + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(1, Relation1UserFriendQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); + $this->assertEquals($friend2, Relation1UserQuery::create()->filterByWho($hans)->findOne(), 'Hans has Friend 2 as friend'); //same with new instances. - \Map\Relation1UserTableMap::clearInstancePool(); + Relation1UserTableMap::clearInstancePool(); /** @var \Relation1User $newHansObject */ - $newHansObject = \Relation1UserQuery::create()->findOneByName('hans'); - $friend1 = \Relation1UserQuery::create()->findOneByName('Friend 1'); - $friend2 = \Relation1UserQuery::create()->findOneByName('Friend 2'); + $newHansObject = Relation1UserQuery::create()->findOneByName('hans'); + $friend1 = Relation1UserQuery::create()->findOneByName('Friend 1'); + $friend2 = Relation1UserQuery::create()->findOneByName('Friend 2'); $this->assertSame($friend2, $newHansObject->getFriends()->getFirst()); $this->assertCount(1, $newHansObject->getFriends()); @@ -233,137 +250,145 @@ public function test5() $this->assertCount(1, $newHansObject->getFriends()); $newHansObject->save(); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(1, \Relation1UserFriendQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \Relation1UserQuery::create()->filterByWho($newHansObject)->count(), 'Hans has one friend.'); - $this->assertEquals($friend1, \Relation1UserQuery::create()->filterByWho($newHansObject)->findOne(), 'Hans has Friend 2 as friend'); - + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(1, Relation1UserFriendQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, Relation1UserQuery::create()->filterByWho($newHansObject)->count(), 'Hans has one friend.'); + $this->assertEquals($friend1, Relation1UserQuery::create()->filterByWho($newHansObject)->findOne(), 'Hans has Friend 2 as friend'); } /* * #################################### * 6. removeFriend, removeFriend */ + + /** + * @return void + */ public function test6() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); - $friend1 = (new \Relation1User())->setName('Friend 1'); - $friend2 = (new \Relation1User())->setName('Friend 2'); + $friend1 = (new Relation1User())->setName('Friend 1'); + $friend2 = (new Relation1User())->setName('Friend 2'); $hans->addFriend($friend1); $hans->addFriend($friend2); $this->assertCount(2, $hans->getFriends()); $hans->save(); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(2, \Relation1UserFriendQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(2, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(2, Relation1UserFriendQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(2, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); $this->assertCount(2, $hans->getFriends()); //db prepared, work now with new objects. - \Map\Relation1UserTableMap::clearInstancePool(); + Relation1UserTableMap::clearInstancePool(); /** @var \Relation1User $newHansObject */ - $newHansObject = \Relation1UserQuery::create()->findOneByName('hans'); - $friend1 = \Relation1UserQuery::create()->findOneByName('Friend 1'); - $friend2 = \Relation1UserQuery::create()->findOneByName('Friend 2'); + $newHansObject = Relation1UserQuery::create()->findOneByName('hans'); + $friend1 = Relation1UserQuery::create()->findOneByName('Friend 1'); + $friend2 = Relation1UserQuery::create()->findOneByName('Friend 2'); $newHansObject->removeFriend($friend1); $this->assertCount(1, $newHansObject->getFriends()); $newHansObject->save(); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(1, \Relation1UserFriendQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \Relation1UserQuery::create()->filterByWho($newHansObject)->count(), 'Hans has one friend.'); - $this->assertEquals($friend2, \Relation1UserQuery::create()->filterByWho($newHansObject)->findOne(), 'Hans has Friend 2 as friend'); - + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(1, Relation1UserFriendQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, Relation1UserQuery::create()->filterByWho($newHansObject)->count(), 'Hans has one friend.'); + $this->assertEquals($friend2, Relation1UserQuery::create()->filterByWho($newHansObject)->findOne(), 'Hans has Friend 2 as friend'); $newHansObject->removeFriend($friend2); $this->assertCount(0, $newHansObject->getFriends()); $newHansObject->save(); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(0, \Relation1UserFriendQuery::create()->count(), 'We have zero connections.'); - $this->assertEquals(0, \Relation1UserQuery::create()->filterByWho($newHansObject)->count(), 'Hans has zero friends.'); - + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(0, Relation1UserFriendQuery::create()->count(), 'We have zero connections.'); + $this->assertEquals(0, Relation1UserQuery::create()->filterByWho($newHansObject)->count(), 'Hans has zero friends.'); } /* * #################################### * 7. removeFriend, setFriends */ + + /** + * @return void + */ public function test7() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); - $friend1 = (new \Relation1User())->setName('Friend 1'); + $friend1 = (new Relation1User())->setName('Friend 1'); $hans->addFriend($friend1); $this->assertCount(1, $hans->getFriends()); $hans->save(); - $this->assertEquals(2, \Relation1UserQuery::create()->count(), 'We have two users.'); - $this->assertEquals(1, \Relation1UserFriendQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); - $this->assertEquals($friend1, \Relation1UserQuery::create()->filterByWho($hans)->findOne(), 'Hans has Friend 1 as friend'); + $this->assertEquals(2, Relation1UserQuery::create()->count(), 'We have two users.'); + $this->assertEquals(1, Relation1UserFriendQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); + $this->assertEquals($friend1, Relation1UserQuery::create()->filterByWho($hans)->findOne(), 'Hans has Friend 1 as friend'); $this->assertCount(1, $hans->getFriends()); //db prepared, work now with new objects. - \Map\Relation1UserTableMap::clearInstancePool(); + Relation1UserTableMap::clearInstancePool(); /** @var \Relation1User $newHansObject */ - $newHansObject = \Relation1UserQuery::create()->findOneByName('hans'); - $friend1 = \Relation1UserQuery::create()->findOneByName('Friend 1'); + $newHansObject = Relation1UserQuery::create()->findOneByName('hans'); + $friend1 = Relation1UserQuery::create()->findOneByName('Friend 1'); $newHansObject->removeFriend($friend1); $this->assertCount(0, $newHansObject->getFriends()); $newHansObject->save(); - $this->assertEquals(2, \Relation1UserQuery::create()->count(), 'We have two users.'); - $this->assertEquals(0, \Relation1UserFriendQuery::create()->count(), 'We have zero connections.'); - $this->assertEquals(0, \Relation1UserQuery::create()->filterByWho($newHansObject)->count(), 'Hans has zero friends.'); + $this->assertEquals(2, Relation1UserQuery::create()->count(), 'We have two users.'); + $this->assertEquals(0, Relation1UserFriendQuery::create()->count(), 'We have zero connections.'); + $this->assertEquals(0, Relation1UserQuery::create()->filterByWho($newHansObject)->count(), 'Hans has zero friends.'); $friends = new ObjectCollection(); $friends[] = $friend1; - $friends[] = $friend2 = (new \Relation1User())->setName('Friend 2'); + $friends[] = $friend2 = (new Relation1User())->setName('Friend 2'); $newHansObject->setFriends($friends); $this->assertCount(2, $newHansObject->getFriends()); $newHansObject->save(); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(2, \Relation1UserFriendQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(2, \Relation1UserQuery::create()->filterByWho($newHansObject)->count(), 'Hans has two friends.'); - + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(2, Relation1UserFriendQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(2, Relation1UserQuery::create()->filterByWho($newHansObject)->count(), 'Hans has two friends.'); } /* * #################################### * 8. removeFriend, getFriends */ + + /** + * @return void + */ public function test8() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); - $friend1 = (new \Relation1User())->setName('Friend 1'); - $friend2 = (new \Relation1User())->setName('Friend 2'); + $friend1 = (new Relation1User())->setName('Friend 1'); + $friend2 = (new Relation1User())->setName('Friend 2'); $hans->addFriend($friend1); $hans->addFriend($friend2); $this->assertCount(2, $hans->getFriends()); $hans->save(); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(2, \Relation1UserFriendQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(2, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(2, Relation1UserFriendQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(2, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); $this->assertCount(2, $hans->getFriends()); //db prepared, work now with new objects. - \Map\Relation1UserTableMap::clearInstancePool(); + Relation1UserTableMap::clearInstancePool(); /** @var \Relation1User $newHansObject */ - $newHansObject = \Relation1UserQuery::create()->findOneByName('hans'); - $friend1 = \Relation1UserQuery::create()->findOneByName('Friend 1'); - $friend2 = \Relation1UserQuery::create()->findOneByName('Friend 2'); + $newHansObject = Relation1UserQuery::create()->findOneByName('hans'); + $friend1 = Relation1UserQuery::create()->findOneByName('Friend 1'); + $friend2 = Relation1UserQuery::create()->findOneByName('Friend 2'); $this->assertCount(2, $newHansObject->getFriends()); $newHansObject->removeFriend($friend1); @@ -371,240 +396,257 @@ public function test8() $this->assertEquals($friend2, $newHansObject->getFriends()->getFirst()); $newHansObject->save(); - \Map\Relation1UserTableMap::clearInstancePool(); - $newHansObject = \Relation1UserQuery::create()->findOneByName('hans'); + Relation1UserTableMap::clearInstancePool(); + $newHansObject = Relation1UserQuery::create()->findOneByName('hans'); $this->assertCount(1, $newHansObject->getFriends()); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(1, \Relation1UserFriendQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \Relation1UserQuery::create()->filterByWho($newHansObject)->count(), 'Hans has one friend.'); - $this->assertEquals('Friend 2', \Relation1UserQuery::create()->filterByWho($newHansObject)->findOne()->getName(), 'Hans has Friend 2 as friend'); - + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(1, Relation1UserFriendQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, Relation1UserQuery::create()->filterByWho($newHansObject)->count(), 'Hans has one friend.'); + $this->assertEquals('Friend 2', Relation1UserQuery::create()->filterByWho($newHansObject)->findOne()->getName(), 'Hans has Friend 2 as friend'); } /* * #################################### * 9. setFriends, addFriend */ + + /** + * @return void + */ public function test9() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); $friends = new ObjectCollection(); - $friends[] = $friend1 = (new \Relation1User())->setName('Friend 1'); - $friends[] = $friend2 = (new \Relation1User())->setName('Friend 2'); + $friends[] = $friend1 = (new Relation1User())->setName('Friend 1'); + $friends[] = $friend2 = (new Relation1User())->setName('Friend 2'); $hans->setFriends($friends); $this->assertCount(2, $hans->getFriends(), 'two friends'); $hans->save(); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(2, \Relation1UserFriendQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(2, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(2, Relation1UserFriendQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(2, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); - $friend3 = (new \Relation1User())->setName('Friend 3'); + $friend3 = (new Relation1User())->setName('Friend 3'); $hans->addFriend($friend3); $hans->save(); - $this->assertEquals(4, \Relation1UserQuery::create()->count(), 'We have four users.'); - $this->assertEquals(3, \Relation1UserFriendQuery::create()->count(), 'We have three connections.'); - $this->assertEquals(3, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has three friends.');; - + $this->assertEquals(4, Relation1UserQuery::create()->count(), 'We have four users.'); + $this->assertEquals(3, Relation1UserFriendQuery::create()->count(), 'We have three connections.'); + $this->assertEquals(3, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has three friends.'); } /* * #################################### * 10. setFriends, removeFriend */ + + /** + * @return void + */ public function test10() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); $friends = new ObjectCollection(); - $friends[] = $friend1 = (new \Relation1User())->setName('Friend 1'); - $friends[] = $friend2 = (new \Relation1User())->setName('Friend 2'); + $friends[] = $friend1 = (new Relation1User())->setName('Friend 1'); + $friends[] = $friend2 = (new Relation1User())->setName('Friend 2'); $hans->setFriends($friends); $this->assertCount(2, $hans->getFriends(), 'two friends'); $hans->save(); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(2, \Relation1UserFriendQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(2, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(2, Relation1UserFriendQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(2, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); $hans->removeFriend($friend1); $hans->save(); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(1, \Relation1UserFriendQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); - + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(1, Relation1UserFriendQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); } /* * #################################### * 11. setFriends, setFriends */ + + /** + * @return void + */ public function test11() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); $friends = new ObjectCollection(); - $friends[] = $friend1 = (new \Relation1User())->setName('Friend 1'); - $friends[] = $friend2 = (new \Relation1User())->setName('Friend 2'); + $friends[] = $friend1 = (new Relation1User())->setName('Friend 1'); + $friends[] = $friend2 = (new Relation1User())->setName('Friend 2'); $hans->setFriends($friends); $this->assertCount(2, $hans->getFriends(), 'two friends'); $hans->save(); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(2, \Relation1UserFriendQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(2, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); - $this->assertEquals($friends->getArrayCopy(), \Relation1UserQuery::create()->filterByWho($hans)->find()->getArrayCopy()); - + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(2, Relation1UserFriendQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(2, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); + $this->assertEquals($friends->getArrayCopy(), Relation1UserQuery::create()->filterByWho($hans)->find()->getArrayCopy()); $friends = new ObjectCollection(); - $friends[] = $friend3 = (new \Relation1User())->setName('Friend 3'); - $friends[] = $friend4 = (new \Relation1User())->setName('Friend 4'); + $friends[] = $friend3 = (new Relation1User())->setName('Friend 3'); + $friends[] = $friend4 = (new Relation1User())->setName('Friend 4'); $hans->setFriends($friends); $this->assertCount(2, $hans->getFriends(), 'two friends'); $hans->save(); - $this->assertEquals(5, \Relation1UserQuery::create()->count(), 'We have five users.'); - $this->assertEquals(2, \Relation1UserFriendQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(2, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); - $this->assertEquals($friends->getArrayCopy(), \Relation1UserQuery::create()->filterByWho($hans)->find()->getArrayCopy()); - + $this->assertEquals(5, Relation1UserQuery::create()->count(), 'We have five users.'); + $this->assertEquals(2, Relation1UserFriendQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(2, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); + $this->assertEquals($friends->getArrayCopy(), Relation1UserQuery::create()->filterByWho($hans)->find()->getArrayCopy()); } /* * #################################### * 12. setFriends, getFriends */ + + /** + * @return void + */ public function test12() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); $friends = new ObjectCollection(); - $friends[] = $friend1 = (new \Relation1User())->setName('Friend 1'); - $friends[] = $friend2 = (new \Relation1User())->setName('Friend 2'); + $friends[] = $friend1 = (new Relation1User())->setName('Friend 1'); + $friends[] = $friend2 = (new Relation1User())->setName('Friend 2'); $hans->setFriends($friends); $this->assertCount(2, $hans->getFriends(), 'two friends'); $hans->save(); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have three users.'); - $this->assertEquals(2, \Relation1UserFriendQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(2, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); - $this->assertEquals('Friend 1', \Relation1UserQuery::create()->filterByWho($hans)->findOne()->getName(), 'Hans\'s first friend is Friend 1.'); + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have three users.'); + $this->assertEquals(2, Relation1UserFriendQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(2, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); + $this->assertEquals('Friend 1', Relation1UserQuery::create()->filterByWho($hans)->findOne()->getName(), 'Hans\'s first friend is Friend 1.'); - \Map\Relation1UserTableMap::clearInstancePool(); - $newHansObject = \Relation1UserQuery::create()->findOneByName('hans'); + Relation1UserTableMap::clearInstancePool(); + $newHansObject = Relation1UserQuery::create()->findOneByName('hans'); $this->assertCount(2, $newHansObject->getFriends(), 'two friends'); $friends = new ObjectCollection(); - $friends[] = $friend3 = (new \Relation1User())->setName('Friend 3'); - $friends[] = $friend4 = (new \Relation1User())->setName('Friend 4'); + $friends[] = $friend3 = (new Relation1User())->setName('Friend 3'); + $friends[] = $friend4 = (new Relation1User())->setName('Friend 4'); $newHansObject->setFriends($friends); $newHansObject->save(); - $this->assertEquals(5, \Relation1UserQuery::create()->count(), 'We have five users.'); - $this->assertEquals(2, \Relation1UserFriendQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(2, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); - $this->assertEquals('Friend 3', \Relation1UserQuery::create()->filterByWho($hans)->findOne()->getName(), 'Hans\'s first friend is Friend 3.'); - + $this->assertEquals(5, Relation1UserQuery::create()->count(), 'We have five users.'); + $this->assertEquals(2, Relation1UserFriendQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(2, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has two friends.'); + $this->assertEquals('Friend 3', Relation1UserQuery::create()->filterByWho($hans)->findOne()->getName(), 'Hans\'s first friend is Friend 3.'); } /* * #################################### * Special: Add friend to db and fire addFriend on a new instance. */ + + /** + * @return void + */ public function testAddOnNewInstance() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); - $friend1 = (new \Relation1User())->setName('Friend 1'); + $friend1 = (new Relation1User())->setName('Friend 1'); $hans->addFriend($friend1); $hans->save(); - $this->assertEquals(2, \Relation1UserQuery::create()->count(), 'We have two users.'); - $this->assertEquals(1, \Relation1UserFriendQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); + $this->assertEquals(2, Relation1UserQuery::create()->count(), 'We have two users.'); + $this->assertEquals(1, Relation1UserFriendQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); //get new instance of $hans and fire addFriend - \Map\Relation1UserTableMap::clearInstancePool(); - /** @var $newHansObject \Relation1User */ - $newHansObject = \Relation1UserQuery::create()->findOneByName('hans'); - $friend2 = (new \Relation1User())->setName('Friend 2'); + Relation1UserTableMap::clearInstancePool(); + /** @var \Relation1User $newHansObject */ + $newHansObject = Relation1UserQuery::create()->findOneByName('hans'); + $friend2 = (new Relation1User())->setName('Friend 2'); $friend2->save(); $newHansObject->addFriend($friend2); $this->assertCount(2, $newHansObject->getFriends(), 'two friends'); $newHansObject->save(); - $this->assertEquals(3, \Relation1UserQuery::create()->count(), 'We have two users.'); - $this->assertEquals(2, \Relation1UserFriendQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(2, \Relation1UserQuery::create()->filterByWho($newHansObject)->count(), 'Hans has two friends.'); - + $this->assertEquals(3, Relation1UserQuery::create()->count(), 'We have two users.'); + $this->assertEquals(2, Relation1UserFriendQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(2, Relation1UserQuery::create()->filterByWho($newHansObject)->count(), 'Hans has two friends.'); } /* * #################################### * Special: addFriend same friend as the one in the database. */ + + /** + * @return void + */ public function testAddAfterDB() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); - $friend1 = (new \Relation1User())->setName('Friend 1'); + $friend1 = (new Relation1User())->setName('Friend 1'); $hans->addFriend($friend1); $hans->save(); - $this->assertEquals(2, \Relation1UserQuery::create()->count(), 'We have two users.'); - $this->assertEquals(1, \Relation1UserFriendQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); + $this->assertEquals(2, Relation1UserQuery::create()->count(), 'We have two users.'); + $this->assertEquals(1, Relation1UserFriendQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); //check if next addFriend $hans->addFriend($friend1); $this->assertCount(1, $hans->getFriends(), 'one friend'); $hans->save(); - $this->assertEquals(2, \Relation1UserQuery::create()->count(), 'We have two users.'); - $this->assertEquals(1, \Relation1UserFriendQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); - + $this->assertEquals(2, Relation1UserQuery::create()->count(), 'We have two users.'); + $this->assertEquals(1, Relation1UserFriendQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); } /** * #################################### * Special: addFriend, addFriend, removeFriend * + * @return void */ public function testAddAddRemove() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); - $friend1 = (new \Relation1User())->setName('Friend 1'); - $friend2 = (new \Relation1User())->setName('Friend 2'); + $friend1 = (new Relation1User())->setName('Friend 1'); + $friend2 = (new Relation1User())->setName('Friend 2'); $hans->addFriend($friend1); $this->assertCount(1, $hans->getFriends(), 'one friend'); @@ -615,27 +657,29 @@ public function testAddAddRemove() $this->assertCount(1, $hans->getFriends(), 'one friend'); $hans->save(); - $this->assertEquals(2, \Relation1UserQuery::create()->count(), 'We have two users.'); - $this->assertEquals(1, \Relation1UserFriendQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); - $this->assertEquals($friend2, \Relation1UserQuery::create()->filterByWho($hans)->findOne(), 'Hans has Friend 2 as friend'); - + $this->assertEquals(2, Relation1UserQuery::create()->count(), 'We have two users.'); + $this->assertEquals(1, Relation1UserFriendQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); + $this->assertEquals($friend2, Relation1UserQuery::create()->filterByWho($hans)->findOne(), 'Hans has Friend 2 as friend'); } /* * #################################### * Special: addFriend, addFriend, removeFriend different order */ + /** + * @return void + */ public function testAddAddRemoveDiffOrder() { - \Relation1UserFriendQuery::create()->deleteAll(); - \Relation1UserQuery::create()->deleteAll(); + Relation1UserFriendQuery::create()->deleteAll(); + Relation1UserQuery::create()->deleteAll(); - $hans = new \Relation1User(); + $hans = new Relation1User(); $hans->setName('hans'); - $friend1 = (new \Relation1User())->setName('Friend 1'); - $friend2 = (new \Relation1User())->setName('Friend 2'); + $friend1 = (new Relation1User())->setName('Friend 1'); + $friend2 = (new Relation1User())->setName('Friend 2'); $hans->addFriend($friend1); $hans->addFriend($friend2); $this->assertCount(2, $hans->getFriends(), 'two friends'); @@ -644,10 +688,9 @@ public function testAddAddRemoveDiffOrder() $this->assertCount(1, $hans->getFriends(), 'one friend'); $hans->save(); - $this->assertEquals(2, \Relation1UserQuery::create()->count(), 'We have two users.'); - $this->assertEquals(1, \Relation1UserFriendQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); - $this->assertEquals($friend1, \Relation1UserQuery::create()->filterByWho($hans)->findOne(), 'Hans has Friend 1 as friend'); - + $this->assertEquals(2, Relation1UserQuery::create()->count(), 'We have two users.'); + $this->assertEquals(1, Relation1UserFriendQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, Relation1UserQuery::create()->filterByWho($hans)->count(), 'Hans has one friend.'); + $this->assertEquals($friend1, Relation1UserQuery::create()->filterByWho($hans)->findOne(), 'Hans has Friend 1 as friend'); } } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKs2Test.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKs2Test.php index f8f138c79c..473200cf92 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKs2Test.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKs2Test.php @@ -3,11 +3,14 @@ namespace Propel\Tests\Generator\Builder\Om; use Base\RelationpkUserGroupQuery; -use Propel\Generator\Platform\MysqlPlatform; -use Propel\Generator\Util\QuickBuilder; -use Propel\Runtime\Collection\ObjectCollection; +use Map\RelationpkUserTableMap; use Propel\Runtime\Collection\ObjectCombinationCollection; use Propel\Tests\Helpers\PlatformDatabaseBuildTimeBase; +use RelationpkGroup; +use RelationpkGroupQuery; +use RelationpkUser; +use RelationpkUserGroupQuery as RelationpkUserGroupQueryRelationpkUserGroupQuery; +use RelationpkUserQuery; /** * Tests for a M2M relation with three pks where first two are FKs and third not. @@ -19,6 +22,9 @@ class GeneratedObjectM2MRelationThreePKs2Test extends PlatformDatabaseBuildTimeB { protected $databaseName = 'migration'; + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -61,32 +67,31 @@ public function setUp(): void } /** - * - * add | remove | set | get + * add | remove | set | get * +--------------------------------------------------- - * add | 1 2 3 4 - * remove | 5 6 7 8 - * set | 9 10 11 12 - * + * add | 1 2 3 4 + * remove | 5 6 7 8 + * set | 9 10 11 12 */ - - /* * #################################### * 1. add, add */ + + /** + * @return void + */ public function test1() { + RelationpkUserQuery::create()->deleteAll(); + RelationpkGroupQuery::create()->deleteAll(); + RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->deleteAll(); - \RelationpkUserQuery::create()->deleteAll(); - \RelationpkGroupQuery::create()->deleteAll(); - \RelationpkUserGroupQuery::create()->deleteAll(); - - $hans = new \RelationpkUser(); + $hans = new RelationpkUser(); $hans->setName('hans'); - $admins = new \RelationpkGroup(); + $admins = new RelationpkGroup(); $admins->setName('Admins'); $hans->addGroup($admins, 'standard'); @@ -99,23 +104,23 @@ public function test1() $hans->save(); $this->assertEquals([$admins], iterator_to_array($hans->getGroups('standard'))); - $this->assertEquals(1, \RelationpkUserGroupQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(1, \RelationpkGroupQuery::create()->count(), 'We have one group.'); + $this->assertEquals(1, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(1, RelationpkGroupQuery::create()->count(), 'We have one group.'); $hans->addGroup($admins, 'lead'); $this->assertCount(2, $hans->getGroupPositions()); $this->assertCount(2, $admins->getUserPositions()); $hans->save(); - $this->assertEquals(2, \RelationpkUserGroupQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(1, \RelationpkGroupQuery::create()->count(), 'We have one group.'); + $this->assertEquals(2, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(1, RelationpkGroupQuery::create()->count(), 'We have one group.'); //try to add the same combination on a new instance - \Map\RelationpkUserTableMap::clearInstancePool(); - /** @var $newHansObject \RelationpkUser */ - $newHansObject = \RelationpkUserQuery::create()->findOneByName('hans'); + RelationpkUserTableMap::clearInstancePool(); + /** @var \RelationpkUser $newHansObject */ + $newHansObject = RelationpkUserQuery::create()->findOneByName('hans'); $newHansObject->addGroup($admins, 'lead'); $this->assertCount(2, $newHansObject->getGroupPositions()); @@ -136,10 +141,10 @@ public function test1() $this->assertEquals(2, $newHansObject->countGroups()); $this->assertEquals('Admins', $newHansObject->getGroups('lead')->getFirst()->getName()); - $this->assertCount(2, \RelationpkUserQuery::create()->filterByGroup($admins)->find()); + $this->assertCount(2, RelationpkUserQuery::create()->filterByGroup($admins)->find()); $this->assertCount( 1, - \RelationpkUserQuery::create() + RelationpkUserQuery::create() ->useRelationpkUserGroupQuery() ->filterByPosition('lead') ->endUse() @@ -147,7 +152,7 @@ public function test1() ); $this->assertCount( 1, - \RelationpkUserQuery::create() + RelationpkUserQuery::create() ->useRelationpkUserGroupQuery() ->filterByPosition('standard') ->endUse() @@ -155,7 +160,7 @@ public function test1() ); $this->assertEquals( 'hans', - \RelationpkUserQuery::create() + RelationpkUserQuery::create() ->useRelationpkUserGroupQuery() ->filterByPosition('standard') ->endUse() @@ -165,156 +170,170 @@ public function test1() ); $this->assertCount( 0, - \RelationpkUserQuery::create() + RelationpkUserQuery::create() ->useRelationpkUserGroupQuery() ->filterByPosition('not existent') ->endUse() ->find() ); - $this->assertCount(1, \RelationpkUserGroupQuery::create() + $this->assertCount(1, RelationpkUserGroupQueryRelationpkUserGroupQuery::create() ->filterByPosition('lead') ->filterByGroup($admins) ->find()); - $this->assertCount(2, \RelationpkUserGroupQuery::create() + $this->assertCount(2, RelationpkUserGroupQueryRelationpkUserGroupQuery::create() ->filterByGroup($admins) ->find()); - $this->assertEquals(2, \RelationpkUserGroupQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(1, \RelationpkGroupQuery::create()->count(), 'We have one group.'); + $this->assertEquals(2, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(1, RelationpkGroupQuery::create()->count(), 'We have one group.'); } - /* * #################################### * 2. add, remove */ + + /** + * @return void + */ public function test2() { - \RelationpkUserQuery::create()->deleteAll(); - \RelationpkGroupQuery::create()->deleteAll(); - \RelationpkUserGroupQuery::create()->deleteAll(); + RelationpkUserQuery::create()->deleteAll(); + RelationpkGroupQuery::create()->deleteAll(); + RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->deleteAll(); - $hans = new \RelationpkUser(); + $hans = new RelationpkUser(); $hans->setName('hans'); - $admins = new \RelationpkGroup(); + $admins = new RelationpkGroup(); $admins->setName('Admins'); $hans->addGroup($admins, 'trainee'); $this->assertCount(1, $hans->getGroupPositions()); $hans->save(); - $this->assertEquals(1, \RelationpkUserGroupQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(1, \RelationpkGroupQuery::create()->count(), 'We have one group.'); + $this->assertEquals(1, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(1, RelationpkGroupQuery::create()->count(), 'We have one group.'); $hans->removeGroupPosition($admins, 'trainee'); $this->assertCount(0, $hans->getGroupPositions()); $hans->save(); - $this->assertEquals(0, \RelationpkUserGroupQuery::create()->count(), 'We have zero connections.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(1, \RelationpkGroupQuery::create()->count(), 'We have one group.'); - + $this->assertEquals(0, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have zero connections.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(1, RelationpkGroupQuery::create()->count(), 'We have one group.'); } /* * #################################### * 3. add, set */ + + /** + * @return void + */ public function test3() { - \RelationpkUserQuery::create()->deleteAll(); - \RelationpkGroupQuery::create()->deleteAll(); - \RelationpkUserGroupQuery::create()->deleteAll(); + RelationpkUserQuery::create()->deleteAll(); + RelationpkGroupQuery::create()->deleteAll(); + RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->deleteAll(); - $hans = new \RelationpkUser(); + $hans = new RelationpkUser(); $hans->setName('hans'); - $admins = new \RelationpkGroup(); + $admins = new RelationpkGroup(); $admins->setName('Admins'); $hans->addGroup($admins, 'trainee'); $this->assertCount(1, $hans->getGroupPositions()); $hans->save(); - $this->assertEquals(1, \RelationpkUserGroupQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(1, \RelationpkGroupQuery::create()->count(), 'We have one group.'); + $this->assertEquals(1, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(1, RelationpkGroupQuery::create()->count(), 'We have one group.'); $emptyColl = new ObjectCombinationCollection(); $hans->setGroupPositions($emptyColl); $this->assertCount(0, $hans->getGroupPositions()); $hans->save(); - $this->assertEquals(0, \RelationpkUserGroupQuery::create()->count(), 'We have zero connections.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(1, \RelationpkGroupQuery::create()->count(), 'We have one group.'); + $this->assertEquals(0, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have zero connections.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(1, RelationpkGroupQuery::create()->count(), 'We have one group.'); } /* * #################################### * 4. and 5. add, get */ + + /** + * @return void + */ public function test4_5() { - \RelationpkUserQuery::create()->deleteAll(); - \RelationpkGroupQuery::create()->deleteAll(); - \RelationpkUserGroupQuery::create()->deleteAll(); + RelationpkUserQuery::create()->deleteAll(); + RelationpkGroupQuery::create()->deleteAll(); + RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->deleteAll(); - $hans = new \RelationpkUser(); + $hans = new RelationpkUser(); $hans->setName('hans'); - $admins = new \RelationpkGroup(); + $admins = new RelationpkGroup(); $admins->setName('Admins'); $hans->addGroup($admins, 'trainee'); $this->assertCount(1, $hans->getGroupPositions()); $hans->save(); - $this->assertEquals(1, \RelationpkUserGroupQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(1, \RelationpkGroupQuery::create()->count(), 'We have one group.'); + $this->assertEquals(1, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(1, RelationpkGroupQuery::create()->count(), 'We have one group.'); - \Map\RelationpkUserTableMap::clearInstancePool(); - $newHansObject = \RelationpkUserQuery::create()->findOneByName('hans'); + RelationpkUserTableMap::clearInstancePool(); + $newHansObject = RelationpkUserQuery::create()->findOneByName('hans'); $this->assertCount(1, $newHansObject->getGroupPositions(), 'Makes a extra query and returns the correct one group list'); - \Map\RelationpkUserTableMap::clearInstancePool(); - $newHansObject = \RelationpkUserQuery::create()->findOneByName('hans'); + RelationpkUserTableMap::clearInstancePool(); + $newHansObject = RelationpkUserQuery::create()->findOneByName('hans'); - $cleaner = new \RelationpkGroup(); + $cleaner = new RelationpkGroup(); $cleaner->setName('Cleaner'); $newHansObject->addGroup($cleaner, 'chef'); $this->assertCount(2, $newHansObject->getGroupPositions(), 'getGroupPositions makes a query and adds then the added group, thus we have 2'); $newHansObject->save(); - $this->assertEquals(2, \RelationpkUserGroupQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(2, \RelationpkGroupQuery::create()->count(), 'We have two groups.'); + $this->assertEquals(2, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(2, RelationpkGroupQuery::create()->count(), 'We have two groups.'); } /* * #################################### * 6. remove, remove */ + + /** + * @return void + */ public function test6() { - \RelationpkUserQuery::create()->deleteAll(); - \RelationpkGroupQuery::create()->deleteAll(); - \RelationpkUserGroupQuery::create()->deleteAll(); + RelationpkUserQuery::create()->deleteAll(); + RelationpkGroupQuery::create()->deleteAll(); + RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->deleteAll(); - $hans = new \RelationpkUser(); + $hans = new RelationpkUser(); $hans->setName('hans'); - $admins = new \RelationpkGroup(); + $admins = new RelationpkGroup(); $admins->setName('Admins'); - $cleaner = new \RelationpkGroup(); + $cleaner = new RelationpkGroup(); $cleaner->setName('Cleaner'); $hans->addGroup($admins, 'trainee'); @@ -322,84 +341,86 @@ public function test6() $this->assertCount(2, $hans->getGroupPositions()); $hans->save(); - $this->assertEquals(2, \RelationpkUserGroupQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(2, \RelationpkGroupQuery::create()->count(), 'We have two groups.'); + $this->assertEquals(2, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(2, RelationpkGroupQuery::create()->count(), 'We have two groups.'); $hans->removeGroupPosition($admins, 'trainee'); $this->assertCount(1, $hans->getGroupPositions()); $hans->save(); - $this->assertEquals(1, \RelationpkUserGroupQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(2, \RelationpkGroupQuery::create()->count(), 'We have two groups.'); + $this->assertEquals(1, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(2, RelationpkGroupQuery::create()->count(), 'We have two groups.'); $hans->removeGroupPosition($cleaner, 'chef'); $this->assertCount(0, $hans->getGroupPositions()); $hans->save(); - $this->assertEquals(0, \RelationpkUserGroupQuery::create()->count(), 'We have zero connections.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(2, \RelationpkGroupQuery::create()->count(), 'We have two groups.'); + $this->assertEquals(0, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have zero connections.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(2, RelationpkGroupQuery::create()->count(), 'We have two groups.'); //add two groupPositions again and made the same removing with a complete new object instance each time $hans->addGroup($admins, 'trainee'); $hans->addGroup($cleaner, 'chef'); $this->assertCount(2, $hans->getGroupPositions()); $hans->save(); - $this->assertEquals(2, \RelationpkUserGroupQuery::create()->count(), 'We have two connections.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(2, \RelationpkGroupQuery::create()->count(), 'We have two groups.'); + $this->assertEquals(2, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have two connections.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(2, RelationpkGroupQuery::create()->count(), 'We have two groups.'); - \Map\RelationpkUserTableMap::clearInstancePool(); - $newHansObject = \RelationpkUserQuery::create()->findOneByName('hans'); + RelationpkUserTableMap::clearInstancePool(); + $newHansObject = RelationpkUserQuery::create()->findOneByName('hans'); $newHansObject->removeGroupPosition($admins, 'trainee'); $this->assertCount(1, $newHansObject->getGroupPositions()); $newHansObject->save(); - $this->assertEquals(1, \RelationpkUserGroupQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(2, \RelationpkGroupQuery::create()->count(), 'We have two groups.'); + $this->assertEquals(1, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(2, RelationpkGroupQuery::create()->count(), 'We have two groups.'); - \Map\RelationpkUserTableMap::clearInstancePool(); - /** @var $newHansObject \RelationpkUser */ - $newHansObject = \RelationpkUserQuery::create()->findOneByName('hans'); + RelationpkUserTableMap::clearInstancePool(); + /** @var \RelationpkUser $newHansObject */ + $newHansObject = RelationpkUserQuery::create()->findOneByName('hans'); $newHansObject->removeGroupPosition($cleaner, 'chef'); $this->assertCount(0, $newHansObject->getGroupPositions()); $newHansObject->save(); - $this->assertEquals(0, \RelationpkUserGroupQuery::create()->count(), 'We have zero connections.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(2, \RelationpkGroupQuery::create()->count(), 'We have two groups.'); + $this->assertEquals(0, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have zero connections.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(2, RelationpkGroupQuery::create()->count(), 'We have two groups.'); } /** * 7. remove, set + * + * @return void */ - public function test7(){ - - \RelationpkUserQuery::create()->deleteAll(); - \RelationpkGroupQuery::create()->deleteAll(); - \RelationpkUserGroupQuery::create()->deleteAll(); + public function test7() + { + RelationpkUserQuery::create()->deleteAll(); + RelationpkGroupQuery::create()->deleteAll(); + RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->deleteAll(); - $hans = new \RelationpkUser(); + $hans = new RelationpkUser(); $hans->setName('hans'); - $admins = new \RelationpkGroup(); + $admins = new RelationpkGroup(); $admins->setName('Admins'); $hans->addGroup($admins, 'trainee'); $this->assertCount(1, $hans->getGroupPositions()); $hans->save(); - $this->assertEquals(1, \RelationpkUserGroupQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(1, \RelationpkGroupQuery::create()->count(), 'We have one group.'); + $this->assertEquals(1, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(1, RelationpkGroupQuery::create()->count(), 'We have one group.'); $hans->removeGroupPosition($admins, 'trainee'); - $cleaner = new \RelationpkGroup(); + $cleaner = new RelationpkGroup(); $cleaner->setName('Cleaner'); $col = new ObjectCombinationCollection(); @@ -409,31 +430,33 @@ public function test7(){ $this->assertEquals([$cleaner, 'chef'], $hans->getGroupPositions()->getFirst()); $hans->save(); - $this->assertEquals(1, \RelationpkUserGroupQuery::create()->count(), 'We have still one connection.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(2, \RelationpkGroupQuery::create()->count(), 'We have two groups.'); + $this->assertEquals(1, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have still one connection.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(2, RelationpkGroupQuery::create()->count(), 'We have two groups.'); - $userGroup = \RelationpkUserGroupQuery::create()->filterByUser($hans)->findOne(); + $userGroup = RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->filterByUser($hans)->findOne(); $this->assertEquals('chef', $userGroup->getPosition()); $this->assertEquals($cleaner->getId(), $userGroup->getGroupId()); } /** * 8. remove, get + * + * @return void */ - public function test8(){ - - \RelationpkUserQuery::create()->deleteAll(); - \RelationpkGroupQuery::create()->deleteAll(); - \RelationpkUserGroupQuery::create()->deleteAll(); + public function test8() + { + RelationpkUserQuery::create()->deleteAll(); + RelationpkGroupQuery::create()->deleteAll(); + RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->deleteAll(); - $hans = new \RelationpkUser(); + $hans = new RelationpkUser(); $hans->setName('hans'); - $admins = new \RelationpkGroup(); + $admins = new RelationpkGroup(); $admins->setName('Admins'); - $cleaner = new \RelationpkGroup(); + $cleaner = new RelationpkGroup(); $cleaner->setName('Cleaner'); $hans->addGroup($admins, 'trainee'); @@ -441,34 +464,36 @@ public function test8(){ $this->assertCount(2, $hans->getGroupPositions()); $hans->save(); - $this->assertEquals(2, \RelationpkUserGroupQuery::create()->count(), 'We have still two connections.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(2, \RelationpkGroupQuery::create()->count(), 'We have two groups.'); + $this->assertEquals(2, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have still two connections.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(2, RelationpkGroupQuery::create()->count(), 'We have two groups.'); $hans->removeGroupPosition($admins, 'trainee'); $hans->save(); - \Map\RelationpkUserTableMap::clearInstancePool(); - $newHansObject = \RelationpkUserQuery::create()->findOneByName('hans'); + RelationpkUserTableMap::clearInstancePool(); + $newHansObject = RelationpkUserQuery::create()->findOneByName('hans'); $this->assertCount(1, $newHansObject->getGroupPositions()); } /** * 9. set, add + * + * @return void */ - public function test9(){ - - \RelationpkUserQuery::create()->deleteAll(); - \RelationpkGroupQuery::create()->deleteAll(); - \RelationpkUserGroupQuery::create()->deleteAll(); + public function test9() + { + RelationpkUserQuery::create()->deleteAll(); + RelationpkGroupQuery::create()->deleteAll(); + RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->deleteAll(); - $hans = new \RelationpkUser(); + $hans = new RelationpkUser(); $hans->setName('hans'); - $admins = new \RelationpkGroup(); + $admins = new RelationpkGroup(); $admins->setName('Admins'); - $cleaner = new \RelationpkGroup(); + $cleaner = new RelationpkGroup(); $cleaner->setName('Cleaner'); $col = new ObjectCombinationCollection(); @@ -478,27 +503,29 @@ public function test9(){ $this->assertCount(2, $hans->getGroupPositions()); $hans->save(); - $this->assertEquals(2, \RelationpkUserGroupQuery::create()->count(), 'We have still two connections.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(2, \RelationpkGroupQuery::create()->count(), 'We have two groups.'); + $this->assertEquals(2, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have still two connections.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(2, RelationpkGroupQuery::create()->count(), 'We have two groups.'); } /** * 10. set, remove + * + * @return void */ - public function test10(){ - - \RelationpkUserQuery::create()->deleteAll(); - \RelationpkGroupQuery::create()->deleteAll(); - \RelationpkUserGroupQuery::create()->deleteAll(); + public function test10() + { + RelationpkUserQuery::create()->deleteAll(); + RelationpkGroupQuery::create()->deleteAll(); + RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->deleteAll(); - $hans = new \RelationpkUser(); + $hans = new RelationpkUser(); $hans->setName('hans'); - $admins = new \RelationpkGroup(); + $admins = new RelationpkGroup(); $admins->setName('Admins'); - $cleaner = new \RelationpkGroup(); + $cleaner = new RelationpkGroup(); $cleaner->setName('Cleaner'); $col = new ObjectCombinationCollection(); @@ -510,24 +537,26 @@ public function test10(){ $this->assertCount(1, $hans->getGroupPositions()); $hans->save(); - $this->assertEquals(1, \RelationpkUserGroupQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(1, \RelationpkGroupQuery::create()->count(), 'We have one group.'); + $this->assertEquals(1, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(1, RelationpkGroupQuery::create()->count(), 'We have one group.'); } /** * 11-12. set, set - set, get + * + * @return void */ - public function test11_12(){ - - \RelationpkUserQuery::create()->deleteAll(); - \RelationpkGroupQuery::create()->deleteAll(); - \RelationpkUserGroupQuery::create()->deleteAll(); + public function test11_12() + { + RelationpkUserQuery::create()->deleteAll(); + RelationpkGroupQuery::create()->deleteAll(); + RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->deleteAll(); - $hans = new \RelationpkUser(); + $hans = new RelationpkUser(); $hans->setName('hans'); - $admins = new \RelationpkGroup(); + $admins = new RelationpkGroup(); $admins->setName('Admins'); $col = new ObjectCombinationCollection(); @@ -536,11 +565,11 @@ public function test11_12(){ $this->assertCount(1, $hans->getGroupPositions()); $hans->save(); - $this->assertEquals(1, \RelationpkUserGroupQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(1, \RelationpkGroupQuery::create()->count(), 'We have one group.'); + $this->assertEquals(1, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(1, RelationpkGroupQuery::create()->count(), 'We have one group.'); - $cleaner = new \RelationpkGroup(); + $cleaner = new RelationpkGroup(); $cleaner->setName('Cleaner'); $col = new ObjectCombinationCollection(); @@ -549,11 +578,11 @@ public function test11_12(){ $this->assertCount(1, $hans->getGroupPositions()); $hans->save(); - $this->assertEquals(1, \RelationpkUserGroupQuery::create()->count(), 'We have one connection.'); - $this->assertEquals(1, \RelationpkUserQuery::create()->count(), 'We have one user.'); - $this->assertEquals(2, \RelationpkGroupQuery::create()->count(), 'We have two groups.'); + $this->assertEquals(1, RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->count(), 'We have one connection.'); + $this->assertEquals(1, RelationpkUserQuery::create()->count(), 'We have one user.'); + $this->assertEquals(2, RelationpkGroupQuery::create()->count(), 'We have two groups.'); - $userGroup = \RelationpkUserGroupQuery::create()->filterByUser($hans)->findOne(); + $userGroup = RelationpkUserGroupQueryRelationpkUserGroupQuery::create()->filterByUser($hans)->findOne(); $this->assertEquals('chef', $userGroup->getPosition()); $this->assertEquals($cleaner->getId(), $userGroup->getGroupId()); } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectMoreRelationTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectMoreRelationTest.php index d48604419c..267556bba9 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectMoreRelationTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectMoreRelationTest.php @@ -10,8 +10,17 @@ namespace Propel\Tests\Generator\Builder\Om; -use Propel\Runtime\Collection\ObjectCollection; +use MoreRelationTest\Comment; +use MoreRelationTest\CommentQuery; +use MoreRelationTest\Content; +use MoreRelationTest\ContentComment; +use MoreRelationTest\ContentCommentQuery; +use MoreRelationTest\ContentQuery; +use MoreRelationTest\Map\PageTableMap; +use MoreRelationTest\Page; +use MoreRelationTest\PageQuery; use Propel\Generator\Util\QuickBuilder; +use Propel\Runtime\Collection\ObjectCollection; use Propel\Tests\TestCase; /** @@ -23,6 +32,8 @@ class GeneratedObjectMoreRelationTest extends TestCase { /** * Setup schema und some default data + * + * @return void */ public function setUp(): void { @@ -73,47 +84,47 @@ public function setUp(): void $builder->build(); } - \MoreRelationTest\ContentCommentQuery::create()->doDeleteAll(); - \MoreRelationTest\ContentQuery::create()->doDeleteAll(); - \MoreRelationTest\CommentQuery::create()->doDeleteAll(); - \MoreRelationTest\PageQuery::create()->doDeleteAll(); - - for ($i=1;$i<=2;$i++) { + ContentCommentQuery::create()->doDeleteAll(); + ContentQuery::create()->doDeleteAll(); + CommentQuery::create()->doDeleteAll(); + PageQuery::create()->doDeleteAll(); - $page = new \MoreRelationTest\Page(); + for ($i = 1; $i <= 2; $i++) { + $page = new Page(); - $page->setTitle('Page '.$i); - for ($j=1;$j<=3;$j++) { - - $content = new \MoreRelationTest\Content(); - $content->setTitle('Content '.$j); + $page->setTitle('Page ' . $i); + for ($j = 1; $j <= 3; $j++) { + $content = new Content(); + $content->setTitle('Content ' . $j); $content->setContent(str_repeat('Content', $j)); $page->addContent($content); - $comment = new \MoreRelationTest\Comment(); + $comment = new Comment(); $comment->setUserId($j); $comment->setComment(str_repeat('Comment', $j)); $page->addComment($comment); - $comment = new \MoreRelationTest\ContentComment(); - $comment->setContentId($i*$j); - $comment->setComment(str_repeat('Comment-'.$j.', ', $j)); + $comment = new ContentComment(); + $comment->setContentId($i * $j); + $comment->setComment(str_repeat('Comment-' . $j . ', ', $j)); $content->addContentComment($comment); - } $page->save(); } } + /** + * @return void + */ public function testRefRelation() { - /** @var $page \MoreRelationTest\Page */ - $page = \MoreRelationTest\PageQuery::create()->findOne(); + /** @var \MoreRelationTest\Page $page */ + $page = PageQuery::create()->findOne(); $comments = $page->getComments(); $count = count($comments); - $comment = new \MoreRelationTest\Comment(); + $comment = new Comment(); $comment->setComment('Comment 1'); $comment->setUserId(123); $comment->setPage($page); @@ -127,15 +138,18 @@ public function testRefRelation() $this->assertCount($count, $page->getComments()); } + /** + * @return void + */ public function testDuplicate() { - $page = \MoreRelationTest\PageQuery::create()->findOne(); - $pageComment = \MoreRelationTest\CommentQuery::create()->filterByPage($page)->findOne(); + $page = PageQuery::create()->findOne(); + $pageComment = CommentQuery::create()->filterByPage($page)->findOne(); $currentCount = count($page->getComments()); - \MoreRelationTest\Map\PageTableMap::clearInstancePool(); - /** @var $newPageObject \MoreRelationTest\Page */ - $newPageObject = \MoreRelationTest\PageQuery::create()->findOne(); //resets the cached comments through getComments() + PageTableMap::clearInstancePool(); + /** @var \MoreRelationTest\Page $newPageObject */ + $newPageObject = PageQuery::create()->findOne(); //resets the cached comments through getComments() $newPageObject->addComment($pageComment); $this->assertCount($currentCount, $newPageObject->getComments(), 'same count as before'); @@ -144,65 +158,69 @@ public function testDuplicate() /** * Composite PK deletion of a 1-to-n relation through set() and remove() * where the PK is at the same time a FK. + * + * @return void */ public function testCommentsDeletion() { $commentCollection = new ObjectCollection(); $commentCollection->setModel('MoreRelationTest\\Comment'); - $comment = new \MoreRelationTest\Comment(); + $comment = new Comment(); $comment->setComment('I should be alone :-('); $comment->setUserId(123); $commentCollection[] = $comment; - $page = \MoreRelationTest\PageQuery::create()->findOne(); + $page = PageQuery::create()->findOne(); $id = $page->getId(); - $count = \MoreRelationTest\CommentQuery::create()->filterByPageId($id)->count(); + $count = CommentQuery::create()->filterByPageId($id)->count(); $this->assertEquals(3, $count, 'We created for each page 3 comments.'); $page->setComments($commentCollection); $page->save(); - $count = \MoreRelationTest\CommentQuery::create()->filterByPageId($id)->count(); + $count = CommentQuery::create()->filterByPageId($id)->count(); $this->assertEquals(1, $count, 'We assigned a collection of only one item.'); - $count = \MoreRelationTest\CommentQuery::create()->filterByPageId(NULL)->count(); + $count = CommentQuery::create()->filterByPageId(null)->count(); $this->assertEquals(0, $count, 'There should be no unassigned comment.'); $page->removeComment($comment); $page->save(); - $count = \MoreRelationTest\CommentQuery::create()->filterByPageId($id)->count(); + $count = CommentQuery::create()->filterByPageId($id)->count(); $this->assertEquals(0, $count); - $count = \MoreRelationTest\CommentQuery::create()->filterByPageId(NULL)->count(); + $count = CommentQuery::create()->filterByPageId(null)->count(); $this->assertEquals(0, $count); } /** * Deletion of a 1-to-n relation through set() * with onDelete=setnull + * + * @return void */ public function testContentCommentDeletion() { $commentCollection = new ObjectCollection(); $commentCollection->setModel('MoreRelationTest\\ContentComment'); - $comment = new \MoreRelationTest\ContentComment(); + $comment = new ContentComment(); $comment->setComment('I\'m Mario'); $commentCollection[] = $comment; - $comment2 = new \MoreRelationTest\ContentComment(); + $comment2 = new ContentComment(); $comment2->setComment('I\'m Mario\'s friend'); $commentCollection[] = $comment2; - $content = \MoreRelationTest\ContentQuery::create()->findOne(); + $content = ContentQuery::create()->findOne(); $id = $content->getId(); - $count = \MoreRelationTest\ContentCommentQuery::create()->filterByContentId($id)->count(); + $count = ContentCommentQuery::create()->filterByContentId($id)->count(); $this->assertEquals(1, $count, 'We created for each page 1 comments.'); $content->setContentComments($commentCollection); @@ -210,32 +228,32 @@ public function testContentCommentDeletion() unset($content); - $count = \MoreRelationTest\ContentCommentQuery::create()->filterByContentId($id)->count(); + $count = ContentCommentQuery::create()->filterByContentId($id)->count(); $this->assertEquals(2, $count, 'We assigned a collection of two items.'); - $count = \MoreRelationTest\ContentCommentQuery::create()->filterByContentId(NULL)->count(); + $count = ContentCommentQuery::create()->filterByContentId(null)->count(); $this->assertEquals(1, $count, 'There should be one unassigned contentComment.'); - } /** * Basic deletion of a 1-to-n relation through set(). * + * @return void */ public function testContentsDeletion() { $contentCollection = new ObjectCollection(); $contentCollection->setModel('MoreRelationTest\\Content'); - $content = new \MoreRelationTest\Content(); + $content = new Content(); $content->setTitle('I should be alone :-('); $contentCollection[] = $content; - $page = \MoreRelationTest\PageQuery::create()->findOne(); + $page = PageQuery::create()->findOne(); $id = $page->getId(); - $count = \MoreRelationTest\ContentQuery::create()->filterByPageId($id)->count(); + $count = ContentQuery::create()->filterByPageId($id)->count(); $this->assertEquals(3, $count, 'We created for each page 3 contents.'); $page->setContents($contentCollection); @@ -243,29 +261,32 @@ public function testContentsDeletion() unset($page); - $count = \MoreRelationTest\ContentQuery::create()->filterByPageId($id)->count(); + $count = ContentQuery::create()->filterByPageId($id)->count(); $this->assertEquals(1, $count, 'We assigned a collection of only one item.'); } + /** + * @return void + */ public function testOnDeleteCascadeNotRequired() { - \MoreRelationTest\PageQuery::create()->doDeleteAll(); - \MoreRelationTest\ContentQuery::create()->doDeleteAll(); + PageQuery::create()->doDeleteAll(); + ContentQuery::create()->doDeleteAll(); - $page = new \MoreRelationTest\Page(); + $page = new Page(); $page->setTitle('Some important Page'); - $content = new \MoreRelationTest\Content(); + $content = new Content(); $content->setTitle('Content'); $page->addContent($content); $page->save(); - $this->assertEquals(1, \MoreRelationTest\ContentQuery::create()->count()); + $this->assertEquals(1, ContentQuery::create()->count()); $page->removeContent($content); $page->save(); - $this->assertEquals(0, \MoreRelationTest\ContentQuery::create()->count()); + $this->assertEquals(0, ContentQuery::create()->count()); } } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectObjectColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectObjectColumnTypeTest.php index e5a56a1440..26b93c22a1 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectObjectColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectObjectColumnTypeTest.php @@ -10,9 +10,10 @@ namespace Propel\Tests\Generator\Builder\Om; +use ComplexColumnTypeEntity1; +use ComplexColumnTypeEntity1Query; +use Map\ComplexColumnTypeEntity1TableMap; use Propel\Generator\Util\QuickBuilder; - -use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Tests\TestCase; @@ -23,6 +24,9 @@ */ class GeneratedObjectObjectColumnTypeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('ComplexColumnTypeEntity1')) { @@ -38,9 +42,12 @@ public function setUp(): void } } + /** + * @return void + */ public function testObjectColumnType() { - $e = new \ComplexColumnTypeEntity1(); + $e = new ComplexColumnTypeEntity1(); $this->assertNull($e->getBar(), 'object columns are null by default'); $c = new FooColumnValue(); $c->bar = 1234; @@ -50,29 +57,32 @@ public function testObjectColumnType() $this->assertNull($e->getBar(), 'object columns are nullable'); $e->setBar($c); $e->save(); - \Map\ComplexColumnTypeEntity1TableMap::clearInstancePool(); - $e = \ComplexColumnTypeEntity1Query::create()->findOne(); + ComplexColumnTypeEntity1TableMap::clearInstancePool(); + $e = ComplexColumnTypeEntity1Query::create()->findOne(); $this->assertEquals($c, $e->getBar(), 'object columns are persisted'); } + /** + * @return void + */ public function testGetterDoesNotKeepValueBetweenTwoHydrationsWhenUsingOnDemandFormatter() { - \ComplexColumnTypeEntity1Query::create()->deleteAll(); - $e = new \ComplexColumnTypeEntity1(); - $e->setBar((object) [ - 'a' =>1, - 'b' => 2 + ComplexColumnTypeEntity1Query::create()->deleteAll(); + $e = new ComplexColumnTypeEntity1(); + $e->setBar((object)[ + 'a' => 1, + 'b' => 2, ]); $e->save(); - $e = new \ComplexColumnTypeEntity1(); - $e->setBar((object) [ + $e = new ComplexColumnTypeEntity1(); + $e->setBar((object)[ 'a' => 3, - 'b' => 4 + 'b' => 4, ]); $e->save(); - $q = \ComplexColumnTypeEntity1Query::create() + $q = ComplexColumnTypeEntity1Query::create() ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) ->find(); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectRelTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectRelTest.php index d5d00e5202..3376f7b2dc 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectRelTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectRelTest.php @@ -10,43 +10,42 @@ namespace Propel\Tests\Generator\Builder\Om; -use Propel\Runtime\Propel; +use DateTime; use Propel\Runtime\Collection\ObjectCollection; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\AuthorQuery; -use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\BookQuery; -use Propel\Tests\Bookstore\BookSummary; -use Propel\Tests\Bookstore\BookSummaryQuery; -use Propel\Tests\Bookstore\Map\BookTableMap; -use Propel\Tests\Bookstore\Bookstore; use Propel\Tests\Bookstore\BookClubList; use Propel\Tests\Bookstore\BookClubListQuery; +use Propel\Tests\Bookstore\BookListFavoriteQuery; use Propel\Tests\Bookstore\BookListRel; use Propel\Tests\Bookstore\BookListRelQuery; -use Propel\Tests\Bookstore\BookListFavoriteQuery; +use Propel\Tests\Bookstore\BookQuery; +use Propel\Tests\Bookstore\Bookstore; use Propel\Tests\Bookstore\BookstoreContest; use Propel\Tests\Bookstore\BookstoreContestEntry; +use Propel\Tests\Bookstore\BookSummary; +use Propel\Tests\Bookstore\BookSummaryQuery; use Propel\Tests\Bookstore\Contest; use Propel\Tests\Bookstore\Customer; +use Propel\Tests\Bookstore\Map\AuthorTableMap; +use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\PublisherTableMap; use Propel\Tests\Bookstore\Review; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; - -use \DateTime; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Tests relationships between generated Object classes. * * This test uses generated Bookstore classes to test the behavior of various - * object operations. The _idea_ here is to test every possible generated method + * object operations. The _idea_ here is to test every possible generated method * from Object.tpl; if necessary, bookstore will be expanded to accommodate this. * - * The database is reloaded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same - * for each test method in this class. See the BookstoreDataPopulator::populate() + * for each test method in this class. See the BookstoreDataPopulator::populate() * method for the exact contents of the database. * * @author Hans Lellelid @@ -57,6 +56,8 @@ class GeneratedObjectRelTest extends BookstoreEmptyTestBase { /** * Tests one side of a bi-directional setting of many-to-many relationships. + * + * @return void */ public function testManyToMany_Dir1() { @@ -65,7 +66,7 @@ public function testManyToMany_Dir1() // No save ... $book = new Book(); - $book->setTitle( "Jungle Expedition Handbook" ); + $book->setTitle('Jungle Expedition Handbook'); $book->setISBN('TEST'); // No save ... @@ -86,11 +87,12 @@ public function testManyToMany_Dir1() $this->assertCount(1, $list->getBookListRels()); $this->assertCount(1, $book->getBookListRels()); $this->assertCount(1, BookListRelQuery::create()->find()); - } /** * Tests reverse setting of one of many-to-many relationship, with all saves cascaded. + * + * @return void */ public function testManyToMany_Dir2_Unsaved() { @@ -99,7 +101,7 @@ public function testManyToMany_Dir2_Unsaved() // No save ... $book = new Book(); - $book->setTitle( "Jungle Expedition Handbook" ); + $book->setTitle('Jungle Expedition Handbook'); $book->setISBN('TEST'); // No save (yet) ... @@ -123,7 +125,10 @@ public function testManyToMany_Dir2_Unsaved() /** * Tests reverse setting of relationships, saving one of the objects first. - * @link http://propel.phpdb.org/trac/ticket/508 + * + * @link http://propel.phpdb.org/trac/ticket/508 + * + * @return void */ public function testManyToMany_Dir2_Saved() { @@ -132,7 +137,7 @@ public function testManyToMany_Dir2_Saved() $list->save(); $book = new Book(); - $book->setTitle( "Jungle Expedition Handbook" ); + $book->setTitle('Jungle Expedition Handbook'); $book->setISBN('TEST'); // No save (yet) ... @@ -154,15 +159,20 @@ public function testManyToMany_Dir2_Saved() $this->assertCount(1, $list->getBookListRels()); $this->assertCount(1, $book->getBookListRels()); $this->assertCount(1, BookListRelQuery::create()->find()); - } + /** + * @return void + */ public function testManyToManyGetterExists() { $this->assertTrue(method_exists('Propel\Tests\Bookstore\BookClubList', 'getBooks'), 'Object generator correctly adds getter for the crossRefFk'); $this->assertFalse(method_exists('Propel\Tests\Bookstore\BookClubList', 'getBookClubLists'), 'Object generator correctly adds getter for the crossRefFk'); } + /** + * @return void + */ public function testManyToManyGetterNewObject() { $blc1 = new BookClubList(); @@ -176,6 +186,9 @@ public function testManyToManyGetterNewObject() $this->assertEquals(0, count($books), 'getCrossRefFK() accepts a query as first parameter'); } + /** + * @return void + */ public function testManyToManyGetter() { BookstoreDataPopulator::populate(); @@ -190,12 +203,18 @@ public function testManyToManyGetter() $this->assertEquals(1, count($books), 'getCrossRefFK() accepts a query as first parameter'); } + /** + * @return void + */ public function testManyToManyCounterExists() { $this->assertTrue(method_exists('Propel\Tests\Bookstore\BookClubList', 'countBooks'), 'Object generator correctly adds counter for the crossRefFk'); $this->assertFalse(method_exists('Propel\Tests\Bookstore\BookClubList', 'countBookClubLists'), 'Object generator correctly adds counter for the crossRefFk'); } + /** + * @return void + */ public function testManyToManyCounterNewObject() { $blc1 = new BookClubList(); @@ -207,10 +226,13 @@ public function testManyToManyCounterNewObject() $this->assertEquals(0, $nbBooks, 'countCrossRefFK() accepts a query as first parameter'); } + /** + * @return void + */ public function testManyToManyCounter() { BookstoreDataPopulator::populate(); - /** @var $blc1 BookClubList */ + /** @var \Propel\Tests\Bookstore\BookClubList $blc1 */ $blc1 = BookClubListQuery::create()->findOneByGroupLeader('Crazyleggs'); $nbBooks = $blc1->countBooks(); $this->assertEquals(2, $nbBooks, 'countCrossRefFK() returns the correct list of objects'); @@ -235,13 +257,16 @@ public function testManyToManyCounter() $this->assertEquals(1, $nbBooks, 'countCrossRefFK() accepts a query as first parameter'); } + /** + * @return void + */ public function testManyToManyAdd() { $list = new BookClubList(); $list->setGroupLeader('Archimedes Q. Porter'); $book = new Book(); - $book->setTitle( "Jungle Expedition Handbook" ); + $book->setTitle('Jungle Expedition Handbook'); $book->setISBN('TEST'); $list->addBook($book); @@ -263,18 +288,21 @@ public function testManyToManyAdd() /** * Test behavior of columns that are implicated in multiple foreign keys. - * @link http://propel.phpdb.org/trac/ticket/228 + * + * @link http://propel.phpdb.org/trac/ticket/228 + * + * @return void */ public function testMultiFkImplication() { BookstoreDataPopulator::populate(); // Create a new bookstore, contest, bookstore_contest, and bookstore_contest_entry $b = new Bookstore(); - $b->setStoreName("Foo!"); + $b->setStoreName('Foo!'); $b->save(); $c = new Contest(); - $c->setName("Bookathon Contest"); + $c->setName('Bookathon Contest'); $c->save(); $bc = new BookstoreContest(); @@ -283,7 +311,7 @@ public function testMultiFkImplication() $bc->save(); $c = new Customer(); - $c->setName("Happy Customer"); + $c->setName('Happy Customer'); $c->save(); $bce = new BookstoreContestEntry(); @@ -300,33 +328,39 @@ public function testMultiFkImplication() /** * Test the clearing of related object collection. - * @link http://www.propelorm.org/ticket/529 + * + * @link http://www.propelorm.org/ticket/529 + * + * @return void */ public function testClearRefFk() { BookstoreDataPopulator::populate(); $book = new Book(); - $book->setISBN("Foo-bar-baz"); - $book->setTitle("The book title"); + $book->setISBN('Foo-bar-baz'); + $book->setTitle('The book title'); // No save ... $r = new Review(); $r->setReviewedBy('Me'); - $r->setReviewDate(new DateTime("now")); + $r->setReviewDate(new DateTime('now')); $book->addReview($r); // No save (yet) ... - $this->assertEquals(1, count($book->getReviews()) ); + $this->assertEquals(1, count($book->getReviews())); $book->clearReviews(); $this->assertEquals(0, count($book->getReviews())); } /** * Test the clearing of related object collection via a many-to-many association. - * @link http://www.propelorm.org/ticket/1374 + * + * @link http://www.propelorm.org/ticket/1374 + * + * @return void */ public function testClearCrossFk() { @@ -340,34 +374,40 @@ public function testClearCrossFk() /** * This tests to see whether modified objects are being silently overwritten by calls to fk accessor methods. - * @link http://propel.phpdb.org/trac/ticket/509#comment:5 + * + * @link http://propel.phpdb.org/trac/ticket/509#comment:5 + * + * @return void */ public function testModifiedObjectOverwrite() { BookstoreDataPopulator::populate(); $author = new Author(); - $author->setFirstName("John"); - $author->setLastName("Public"); + $author->setFirstName('John'); + $author->setLastName('Public'); $books = $author->getBooks(); // empty, of course - $this->assertEquals(0, count($books), "Expected empty collection."); + $this->assertEquals(0, count($books), 'Expected empty collection.'); $book = new Book(); - $book->setTitle("A sample book"); - $book->setISBN("INITIAL ISBN"); + $book->setTitle('A sample book'); + $book->setISBN('INITIAL ISBN'); $author->addBook($book); $author->save(); - $book->setISBN("MODIFIED ISBN"); + $book->setISBN('MODIFIED ISBN'); $books = $author->getBooks(); - $this->assertEquals(1, count($books), "Expected 1 book."); - $this->assertSame($book, $books[0], "Expected the same object to be returned by fk accessor."); - $this->assertEquals("MODIFIED ISBN", $books[0]->getISBN(), "Expected the modified value NOT to have been overwritten."); + $this->assertEquals(1, count($books), 'Expected 1 book.'); + $this->assertSame($book, $books[0], 'Expected the same object to be returned by fk accessor.'); + $this->assertEquals('MODIFIED ISBN', $books[0]->getISBN(), 'Expected the modified value NOT to have been overwritten.'); } + /** + * @return void + */ public function testFKGetterUseInstancePool() { BookstoreDataPopulator::populate(); @@ -382,6 +422,9 @@ public function testFKGetterUseInstancePool() $this->assertEquals($sql, $con->getLastExecutedQuery(), 'refFK getter uses instance pool if possible'); } + /** + * @return void + */ public function testRefFKGetJoin() { BookstoreDataPopulator::populate(); @@ -397,6 +440,9 @@ public function testRefFKGetJoin() $this->assertEquals($sql, $con->getLastExecutedQuery(), 'refFK getter uses instance pool if possible'); } + /** + * @return void + */ public function testRefFKAddReturnsCurrentObject() { $author = new Author(); @@ -432,7 +478,7 @@ public function testSetterCollection() $bookClubList1->save(); $this->assertEquals(10, $bookClubList1->getBooks()->count()); - $this->assertEquals(1, BookClubListQuery::create()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); $this->assertEquals(10, BookQuery::create()->count()); $this->assertEquals(10, BookListRelQuery::create()->count()); @@ -460,7 +506,7 @@ public function testSetterCollection() $newBook->setIsbn(1234); // Kind of new collection - $books = clone $books; + $books = clone $books; $books[] = $newBook; $bookClubList1->setBooks($books); @@ -468,7 +514,7 @@ public function testSetterCollection() $this->assertEquals(10, $books->count()); $this->assertEquals(10, $bookClubList1->getBooks()->count()); - $this->assertEquals(1, BookClubListQuery::create()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); $this->assertEquals(10, BookListRelQuery::create()->count()); $this->assertEquals(11, BookQuery::create()->count()); @@ -494,7 +540,7 @@ public function testSetterCollection() $this->assertEquals(11, $books->count()); $this->assertEquals(11, $bookClubList1->getBooks()->count()); - $this->assertEquals(1, BookClubListQuery::create()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); $this->assertEquals(11, BookListRelQuery::create()->count()); $this->assertEquals(12, BookQuery::create()->count()); @@ -506,11 +552,14 @@ public function testSetterCollection() $this->assertEquals(11, $books->count()); $this->assertEquals(11, $bookClubList1->getBooks()->count()); - $this->assertEquals(1, BookClubListQuery::create()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); $this->assertEquals(11, BookListRelQuery::create()->count()); $this->assertEquals(12, BookQuery::create()->count()); } + /** + * @return void + */ public function testSetterCollectionWithNoData() { // Ensure no data @@ -533,6 +582,9 @@ public function testSetterCollectionWithNoData() $this->assertEquals(0, BookListRelQuery::create()->count()); } + /** + * @return void + */ public function testSetterCollectionSavesForeignObjects() { // Ensure no data @@ -571,6 +623,9 @@ public function testSetterCollectionSavesForeignObjects() $this->assertSame('My Title', $result); } + /** + * @return void + */ public function testSetterCollectionWithNewObjects() { // Ensure no data @@ -602,6 +657,9 @@ public function testSetterCollectionWithNewObjects() $this->assertEquals(3, BookListRelQuery::create()->count()); } + /** + * @return void + */ public function testSetterCollectionWithExistingObjects() { // Ensure no data @@ -635,6 +693,9 @@ public function testSetterCollectionWithExistingObjects() } } + /** + * @return void + */ public function testSetterCollectionWithEmptyCollection() { // Ensure no data @@ -654,6 +715,9 @@ public function testSetterCollectionWithEmptyCollection() $this->assertEquals(0, BookListRelQuery::create()->count()); } + /** + * @return void + */ public function testSetterCollectionReplacesOldObjectsByNewObjects() { // Ensure no data @@ -702,13 +766,11 @@ public function testSetterCollectionReplacesOldObjectsByNewObjects() $this->assertEquals(1, BookListRelQuery::create() ->filterByBookClubList($bookClubList) ->filterByBook($books[0]) - ->count() - ); + ->count()); $this->assertEquals(1, BookListRelQuery::create() ->filterByBookClubList($bookClubList) ->filterByBook($books[1]) - ->count() - ); + ->count()); $this->assertEquals(4, BookQuery::create()->count()); } @@ -754,6 +816,9 @@ public function testSetterCollectionWithCustomNamedFKs() $this->assertCount(2, $bookClubList->getFavoriteBooks()); } + /** + * @return void + */ public function testSetterCollectionWithManyToManyModifiedByReferenceWithANewObject() { // Ensure no data @@ -782,6 +847,9 @@ public function testSetterCollectionWithManyToManyModifiedByReferenceWithANewObj $this->assertEquals(1, BookClubListQuery::create()->count()); } + /** + * @return void + */ public function testSetterCollectionWithManyToManyModifiedByReferenceWithAnExistingObject() { // Ensure no data @@ -811,6 +879,9 @@ public function testSetterCollectionWithManyToManyModifiedByReferenceWithAnExist $this->assertEquals(1, BookClubListQuery::create()->count()); } + /** + * @return void + */ public function testRemoveObjectFromCollection() { $list = new BookClubList(); @@ -821,7 +892,7 @@ public function testRemoveObjectFromCollection() // No save ... $book = new Book(); - $book->setTitle( "Jungle Expedition Handbook" ); + $book->setTitle('Jungle Expedition Handbook'); $book->setISBN('TEST'); // No save ... $this->assertCount(0, $book->getBookClubLists(), 'No BookClubList'); @@ -834,6 +905,9 @@ public function testRemoveObjectFromCollection() $this->assertCount(1, $book->getBookClubLists(), 'One BookClubList has been remove'); } + /** + * @return void + */ public function testRemoveObjectStoredInDBFromCollection() { BookQuery::create()->deleteAll(); @@ -847,7 +921,7 @@ public function testRemoveObjectStoredInDBFromCollection() // No save ... $book = new Book(); - $book->setTitle( "Jungle Expedition Handbook" ); + $book->setTitle('Jungle Expedition Handbook'); $book->setISBN('TEST'); $book->addBookClubList($list); $book->addBookClubList($list2); @@ -865,6 +939,9 @@ public function testRemoveObjectStoredInDBFromCollection() $this->assertEquals(1, BookListRelQuery::create()->count(), 'One BookClubList has been remove'); } + /** + * @return void + */ public function testSymfonyFormManyToOne() { BookQuery::create()->deleteAll(); @@ -898,6 +975,9 @@ public function testSymfonyFormManyToOne() $this->assertCount(1, $books); } + /** + * @return void + */ public function testRemoveObjectOneToMany() { BookQuery::create()->deleteAll(); @@ -946,6 +1026,9 @@ public function testRemoveObjectOneToMany() $this->assertEquals(2, BookQuery::create()->count(), 'Two Book because FK is not required so book is not delete when removed from author\'s book collection'); } + /** + * @return void + */ public function testRemoveObjectOneToManyWithFkRequired() { BookSummaryQuery::create()->deleteAll(); @@ -992,6 +1075,9 @@ public function testRemoveObjectOneToManyWithFkRequired() $this->assertEquals(1, BookSummaryQuery::create()->count(), 'One Book summary because FK is required so book summary is deleted when book is saved'); } + /** + * @return void + */ public function testManyToManySetterIsNotLoosingAnyReference() { $list1 = new BookClubList(); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php index b1f6780ada..06fa972c47 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php @@ -7,16 +7,16 @@ * * @license MIT License */ + namespace Propel\Tests\Generator\Builder\Om; use MyNameSpace\ComplexColumnTypeEntitySet; use MyNameSpace\ComplexColumnTypeEntitySetQuery; use MyNameSpace\Map\ComplexColumnTypeEntitySetTableMap; -use MyNameSpace\ComplexColumnTypeEntityWithConstructorQuery; - use Propel\Generator\Util\QuickBuilder; use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Tests\TestCase; +use PublicComplexColumnTypeEntitySet; /** * Tests the generated objects for SET columns types accessor & mutator @@ -25,6 +25,9 @@ */ class GeneratedObjectSetColumnTypeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('MyNameSpace\\ComplexColumnTypeEntitySet')) { @@ -55,6 +58,9 @@ class PublicComplexColumnTypeEntitySet extends MyNameSpace\ComplexColumnTypeEnti ComplexColumnTypeEntitySetTableMap::doDeleteAll(); } + /** + * @return void + */ public function testActiveRecordMethods() { $this->assertTrue(method_exists('MyNameSpace\ComplexColumnTypeEntitySet', 'getTags')); @@ -70,41 +76,58 @@ public function testActiveRecordMethods() $this->assertFalse(method_exists('MyNameSpace\ComplexColumnTypeEntitySet', 'removeBar')); } + /** + * @return void + */ public function testGetterDefaultValue() { $e = new ComplexColumnTypeEntitySet(); $this->assertEquals([], $e->getTags(), 'array columns return an empty array by default'); } + /** + * @return void + */ public function testGetterDefaultValueWithData() { $e = new ComplexColumnTypeEntitySet(); $this->assertSame(['bar'], $e->getDefaults()); } + /** + * @return void + */ public function testGetterDefaultValueWithMultipleData() { $e = new ComplexColumnTypeEntitySet(); $this->assertEquals(['bar', 'baz'], $e->getBears()); } + /** + * @return void + */ public function testGetterValidValue() { - $e = new \PublicComplexColumnTypeEntitySet(); + $e = new PublicComplexColumnTypeEntitySet(); $e->tags = 5; $this->assertEquals(['foo', 'baz'], $e->getTags()); } /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testGetterThrowsExceptionOnUnknownKey() { - $e = new \PublicComplexColumnTypeEntitySet(); + $e = new PublicComplexColumnTypeEntitySet(); $e->bar = 156; $e->getBar(); } + /** + * @return void + */ public function testAdderAddsNewValueToExistingData() { $e = new ComplexColumnTypeEntitySet(); @@ -113,6 +136,9 @@ public function testAdderAddsNewValueToExistingData() $this->assertEquals(['bar', 'foo baz'], $e->getDefaults()); } + /** + * @return void + */ public function testAdderAddsNewValueToMultipleExistingData() { $e = new ComplexColumnTypeEntitySet(); @@ -121,6 +147,9 @@ public function testAdderAddsNewValueToMultipleExistingData() $this->assertEquals(['bar', 'baz', 'kevin'], $e->getBears()); } + /** + * @return void + */ public function testDefaultValuesAreWellPersisted() { $e = new ComplexColumnTypeEntitySet(); @@ -132,6 +161,9 @@ public function testDefaultValuesAreWellPersisted() $this->assertEquals(['bar'], $e->getDefaults()); } + /** + * @return void + */ public function testMultipleDefaultValuesAreWellPersisted() { $e = new ComplexColumnTypeEntitySet(); @@ -143,9 +175,12 @@ public function testMultipleDefaultValuesAreWellPersisted() $this->assertEquals(['bar', 'baz'], $e->getBears()); } + /** + * @return void + */ public function testSetterArrayValue() { - $e = new \PublicComplexColumnTypeEntitySet(); + $e = new PublicComplexColumnTypeEntitySet(); $value = ['foo', '1']; $e->setTags($value); $this->assertEquals($value, $e->getTags(), 'array columns can store arrays'); @@ -153,6 +188,9 @@ public function testSetterArrayValue() $this->assertEquals(9, $e->tags); } + /** + * @return void + */ public function testSetterResetValue() { $e = new ComplexColumnTypeEntitySet(); @@ -164,6 +202,8 @@ public function testSetterResetValue() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testSetterThrowsExceptionOnUnknownValue() { @@ -171,6 +211,9 @@ public function testSetterThrowsExceptionOnUnknownValue() $e->setBar(['bazz']); } + /** + * @return void + */ public function testTester() { $e = new ComplexColumnTypeEntitySet(); @@ -184,6 +227,9 @@ public function testTester() $this->assertFalse($e->hasTag('4')); } + /** + * @return void + */ public function testAdder() { $e = new ComplexColumnTypeEntitySet(); @@ -198,6 +244,9 @@ public function testAdder() $this->assertEquals(['foo', '4', 'foo bar'], $e->getTags()); } + /** + * @return void + */ public function testRemover() { $e = new ComplexColumnTypeEntitySet(); @@ -215,6 +264,9 @@ public function testRemover() $this->assertEquals(['baz', '1'], $e->getTags()); } + /** + * @return void + */ public function testValueIsPersisted() { $e = new ComplexColumnTypeEntitySet(); @@ -226,16 +278,19 @@ public function testValueIsPersisted() $this->assertEquals($value, $e->getTags(), 'array columns are persisted'); } + /** + * @return void + */ public function testGetterDoesNotKeepValueBetweenTwoHydrationsWhenUsingOnDemandFormatter() { ComplexColumnTypeEntitySetQuery::create()->deleteAll(); $e = new ComplexColumnTypeEntitySet(); - $e->setTags(['foo','bar']); + $e->setTags(['foo', 'bar']); $e->save(); $e = new ComplexColumnTypeEntitySet(); - $e->setTags(['baz','1']); + $e->setTags(['baz', '1']); $e->save(); $q = ComplexColumnTypeEntitySetQuery::create() diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php index 4bb9175483..47682e13bd 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php @@ -10,10 +10,13 @@ namespace Propel\Tests\Generator\Builder\Om; -use Propel\Generator\Util\QuickBuilder; +use ComplexColumnTypeEntity5; +use ComplexColumnTypeEntity5Query; +use ComplexColumnTypeEntity6; +use DateTime; +use Map\ComplexColumnTypeEntity5TableMap; use Propel\Generator\Platform\MysqlPlatform; - -use Propel\Runtime\Propel; +use Propel\Generator\Util\QuickBuilder; use Propel\Tests\TestCase; /** @@ -23,6 +26,9 @@ */ class GeneratedObjectTemporalColumnTypeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('ComplexColumnTypeEntity5')) { @@ -41,30 +47,38 @@ public function setUp(): void } } + /** + * @return void + */ public function testNullValue() { - $r = new \ComplexColumnTypeEntity5(); + $r = new ComplexColumnTypeEntity5(); $this->assertNull($r->getBar1()); - $r->setBar1(new \DateTime('2011-12-02')); + $r->setBar1(new DateTime('2011-12-02')); $this->assertNotNull($r->getBar1()); $r->setBar1(null); $this->assertNull($r->getBar1()); } /** - * @link http://propel.phpdb.org/trac/ticket/586 + * @link http://propel.phpdb.org/trac/ticket/586 + * + * @return void */ public function testEmptyValue() { - $r = new \ComplexColumnTypeEntity5(); + $r = new ComplexColumnTypeEntity5(); $r->setBar1(''); $this->assertNull($r->getBar1()); } + /** + * @return void + */ public function testPreEpochValue() { - $r = new \ComplexColumnTypeEntity5(); - $r->setBar1(new \DateTime('1602-02-02')); + $r = new ComplexColumnTypeEntity5(); + $r->setBar1(new DateTime('1602-02-02')); $this->assertEquals('1602-02-02', $r->getBar1(null)->format('Y-m-d')); $r->setBar1('1702-02-02'); @@ -74,62 +88,79 @@ public function testPreEpochValue() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testInvalidValueThrowsPropelException() { - $r = new \ComplexColumnTypeEntity5(); - $r->setBar1("Invalid Date"); + $r = new ComplexColumnTypeEntity5(); + $r->setBar1('Invalid Date'); } + /** + * @return void + */ public function testUnixTimestampValue() { - $r = new \ComplexColumnTypeEntity5(); + $r = new ComplexColumnTypeEntity5(); $r->setBar1(time()); $this->assertEquals(date('Y-m-d'), $r->getBar1('Y-m-d')); - $r = new \ComplexColumnTypeEntity5(); + $r = new ComplexColumnTypeEntity5(); $r->setBar2(strtotime('12:55')); $this->assertEquals('12:55', $r->getBar2(null)->format('H:i')); - $r = new \ComplexColumnTypeEntity5(); + $r = new ComplexColumnTypeEntity5(); $r->setBar3(time()); $this->assertEquals(date('Y-m-d H:i'), $r->getBar3('Y-m-d H:i')); } + /** + * @return void + */ public function testDatePersistence() { - $r = new \ComplexColumnTypeEntity5(); - $r->setBar1(new \DateTime('1999-12-20')); + $r = new ComplexColumnTypeEntity5(); + $r->setBar1(new DateTime('1999-12-20')); $r->save(); - \Map\ComplexColumnTypeEntity5TableMap::clearInstancePool(); - $r1 = \ComplexColumnTypeEntity5Query::create()->findPk($r->getId()); + ComplexColumnTypeEntity5TableMap::clearInstancePool(); + $r1 = ComplexColumnTypeEntity5Query::create()->findPk($r->getId()); $this->assertEquals('1999-12-20', $r1->getBar1(null)->format('Y-m-d')); } + /** + * @return void + */ public function testTimePersistence() { - $r = new \ComplexColumnTypeEntity5(); + $r = new ComplexColumnTypeEntity5(); $r->setBar2(strtotime('12:55')); $r->save(); - \Map\ComplexColumnTypeEntity5TableMap::clearInstancePool(); - $r1 = \ComplexColumnTypeEntity5Query::create()->findPk($r->getId()); + ComplexColumnTypeEntity5TableMap::clearInstancePool(); + $r1 = ComplexColumnTypeEntity5Query::create()->findPk($r->getId()); $this->assertEquals('12:55', $r1->getBar2(null)->format('H:i')); } + /** + * @return void + */ public function testTimestampPersistence() { - $r = new \ComplexColumnTypeEntity5(); - $r->setBar3(new \DateTime('1999-12-20 12:55')); + $r = new ComplexColumnTypeEntity5(); + $r->setBar3(new DateTime('1999-12-20 12:55')); $r->save(); - \Map\ComplexColumnTypeEntity5TableMap::clearInstancePool(); - $r1 = \ComplexColumnTypeEntity5Query::create()->findPk($r->getId()); + ComplexColumnTypeEntity5TableMap::clearInstancePool(); + $r1 = ComplexColumnTypeEntity5Query::create()->findPk($r->getId()); $this->assertEquals('1999-12-20 12:55', $r1->getBar3(null)->format('Y-m-d H:i')); } + /** + * @return void + */ public function testDateTimeGetterReturnsADateTime() { - $r = new \ComplexColumnTypeEntity5(); - $r->setBar3(new \DateTime()); + $r = new ComplexColumnTypeEntity5(); + $r->setBar3(new DateTime()); $r->save(); $this->assertInstanceOf('DateTime', $r->getBar3()); @@ -140,21 +171,30 @@ public function testDateTimeGetterReturnsADateTime() $this->assertInstanceOf('DateTime', $r->getBar3()); } + /** + * @return void + */ public function testDateTimeGetterReturnsAReference() { - $r = new \ComplexColumnTypeEntity5(); - $r->setBar3(new \DateTime('2011-11-23')); + $r = new ComplexColumnTypeEntity5(); + $r->setBar3(new DateTime('2011-11-23')); $r->getBar3()->modify('+1 days'); $this->assertEquals('2011-11-24', $r->getBar3('Y-m-d')); } + /** + * @return void + */ public function testHasOnlyDefaultValues() { - $r = new \ComplexColumnTypeEntity5(); + $r = new ComplexColumnTypeEntity5(); $this->assertEquals('2011-12-09', $r->getBar4('Y-m-d')); $this->assertTrue($r->hasOnlyDefaultValues()); } + /** + * @return void + */ public function testHydrateWithMysqlInvalidDate() { $schema = <<setSchema($schema); $builder->setPlatform(new MysqlPlatform()); $builder->buildClasses(); - $r = new \ComplexColumnTypeEntity6(); + $r = new ComplexColumnTypeEntity6(); $r->hydrate([ 123, '0000-00-00', '00:00:00', - '0000-00-00 00:00:00' + '0000-00-00 00:00:00', ]); $this->assertNull($r->getBar1()); $this->assertEquals('00:00:00', $r->getBar2()->format('H:i:s')); $this->assertNull($r->getBar3()); } + /** + * @return void + */ public function testDateTimesSerialize() { - $r = new \ComplexColumnTypeEntity5(); - $r->setBar3(new \DateTime('2011-11-23')); + $r = new ComplexColumnTypeEntity5(); + $r->setBar3(new DateTime('2011-11-23')); $str = serialize($r); $r2 = unserialize($str); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php index 2dde011975..8045be7e7b 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php @@ -10,70 +10,71 @@ namespace Propel\Tests\Generator\Builder\Om; +use DateTime; +use Exception; +use MyNameSpace\TestKeyTypeTable; use Propel\Generator\Config\QuickGeneratorConfig; -use Propel\Runtime\Adapter\Pdo\SqliteAdapter; -use Propel\Tests\Bookstore\BookstoreQuery; use Propel\Generator\Util\QuickBuilder; -use Propel\Runtime\Propel; -use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Adapter\Pdo\SqliteAdapter; +use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Map\TableMap; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\AcctAuditLog; use Propel\Tests\Bookstore\AcctAuditLogQuery; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\AuthorQuery; -use Propel\Tests\Bookstore\ContestQuery; -use Propel\Tests\Bookstore\CountryQuery; -use Propel\Tests\Bookstore\CountryTranslationQuery; -use Propel\Tests\Bookstore\Map\AuthorTableMap; -use Propel\Tests\Bookstore\Map\AcctAuditLogTableMap; use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\BookSummary; -use Propel\Tests\Bookstore\BookQuery; -use Propel\Tests\Bookstore\Map\BookTableMap; -use Propel\Tests\Bookstore\BookReader; use Propel\Tests\Bookstore\BookOpinion; use Propel\Tests\Bookstore\BookOpinionQuery; +use Propel\Tests\Bookstore\BookQuery; +use Propel\Tests\Bookstore\BookReader; use Propel\Tests\Bookstore\Bookstore; use Propel\Tests\Bookstore\BookstoreContest; +use Propel\Tests\Bookstore\BookstoreContestEntry; use Propel\Tests\Bookstore\BookstoreEmployee; -use Propel\Tests\Bookstore\BookstoreEmployeeQuery; -use Propel\Tests\Bookstore\Map\BookstoreEmployeeTableMap; use Propel\Tests\Bookstore\BookstoreEmployeeAccount; use Propel\Tests\Bookstore\BookstoreEmployeeAccountQuery; -use Propel\Tests\Bookstore\Map\BookstoreEmployeeAccountTableMap; -use Propel\Tests\Bookstore\BookstoreContestEntry; +use Propel\Tests\Bookstore\BookstoreEmployeeQuery; +use Propel\Tests\Bookstore\BookstoreQuery; use Propel\Tests\Bookstore\BookstoreSale; +use Propel\Tests\Bookstore\BookSummary; use Propel\Tests\Bookstore\BookSummaryQuery; use Propel\Tests\Bookstore\Contest; +use Propel\Tests\Bookstore\ContestQuery; use Propel\Tests\Bookstore\Country; +use Propel\Tests\Bookstore\CountryQuery; +use Propel\Tests\Bookstore\CountryTranslationQuery; use Propel\Tests\Bookstore\Customer; +use Propel\Tests\Bookstore\CustomerQuery; +use Propel\Tests\Bookstore\Map\AcctAuditLogTableMap; +use Propel\Tests\Bookstore\Map\AuthorTableMap; +use Propel\Tests\Bookstore\Map\BookstoreEmployeeAccountTableMap; +use Propel\Tests\Bookstore\Map\BookstoreEmployeeTableMap; +use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\ContestTableMap; use Propel\Tests\Bookstore\Map\CustomerTableMap; -use Propel\Tests\Bookstore\CustomerQuery; +use Propel\Tests\Bookstore\Map\PublisherTableMap; +use Propel\Tests\Bookstore\Map\ReviewTableMap; use Propel\Tests\Bookstore\Publisher; use Propel\Tests\Bookstore\PublisherQuery; use Propel\Tests\Bookstore\Review; -use Propel\Tests\Bookstore\Map\ReviewTableMap; -use Propel\Tests\Bookstore\Map\PublisherTableMap; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; use Propel\Tests\Helpers\Bookstore\Behavior\TestAuthor; use Propel\Tests\Helpers\Bookstore\Behavior\TestAuthorDeleteFalse; use Propel\Tests\Helpers\Bookstore\Behavior\TestAuthorSaveFalse; - -use \DateTime; -use MyNameSpace\TestKeyTypeTable; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use ReflectionMethod; /** * Tests the generated Object classes. * * This test uses generated Bookstore classes to test the behavior of various - * object operations. The _idea_ here is to test every possible generated method + * object operations. The _idea_ here is to test every possible generated method * from Object.tpl; if necessary, bookstore will be expanded to accommodate this. * - * The database is reloaded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same - * for each test method in this class. See the BookstoreDataPopulator::populate() + * for each test method in this class. See the BookstoreDataPopulator::populate() * method for the exact contents of the database. * * @author Hans Lellelid @@ -84,6 +85,8 @@ class GeneratedObjectTest extends BookstoreTestBase { /** * Test saving an object after setting default values for it. + * + * @return void */ public function testSaveWithDefaultValues() { @@ -95,18 +98,19 @@ public function testSaveWithDefaultValues() $pub = new Publisher(); $pub->setName('Penguin'); $pub->save(); - $this->assertTrue($pub->getId() !== null, "Expect Publisher to have been saved when default value set."); + $this->assertTrue($pub->getId() !== null, 'Expect Publisher to have been saved when default value set.'); // 2) check date/time values $review = new Review(); // note that this is different from how it's represented in schema, but should resolve to same unix timestamp $review->setReviewDate('2001-01-01'); $this->assertTrue($review->isModified(), "Expect Review to have been marked 'modified' after default date/time value set."); - } /** * Test isModified() to be false after setting default value second time + * + * @return void */ public function testDefaultValueSetTwice() { @@ -120,9 +124,12 @@ public function testDefaultValueSetTwice() $pub2 = PublisherQuery::create()->findPk($pubId); $pub2->setName('Penguin'); - $this->assertFalse($pub2->isModified(), "Expect Publisher to be not modified after setting default value second time."); + $this->assertFalse($pub2->isModified(), 'Expect Publisher to be not modified after setting default value second time.'); } + /** + * @return void + */ public function testHasApplyDefaultValues() { $this->assertTrue(method_exists('\Propel\Tests\Bookstore\Publisher', 'applyDefaultValues'), 'Tables with default values should have an applyDefaultValues() method'); @@ -131,63 +138,67 @@ public function testHasApplyDefaultValues() /** * Test default return values. + * + * @return void */ public function testDefaultValues() { $r = new Review(); $this->assertEquals('2001-01-01', $r->getReviewDate('Y-m-d')); - $this->assertFalse($r->isModified(), "expected isModified() to be false"); + $this->assertFalse($r->isModified(), 'expected isModified() to be false'); $acct = new BookstoreEmployeeAccount(); $this->assertEquals(true, $acct->getEnabled()); $this->assertFalse($acct->isModified()); - $acct->setLogin("testuser"); - $acct->setPassword("testpass"); + $acct->setLogin('testuser'); + $acct->setPassword('testpass'); $this->assertTrue($acct->isModified()); } /** * Tests the use of default expressions and the reloadOnInsert and reloadOnUpdate attributes. * - * @link http://propel.phpdb.org/trac/ticket/378 - * @link http://propel.phpdb.org/trac/ticket/555 + * @link http://propel.phpdb.org/trac/ticket/378 + * @link http://propel.phpdb.org/trac/ticket/555 + * + * @return void */ public function testDefaultExpressions() { if (Propel::getServiceContainer()->getAdapter(BookstoreEmployeeTableMap::DATABASE_NAME) instanceof SqliteAdapter) { - $this->markTestSkipped("Cannot test default expressions with SQLite"); + $this->markTestSkipped('Cannot test default expressions with SQLite'); } BookstoreEmployeeAccountTableMap::doDeleteAll(); $b = new Bookstore(); - $b->setStoreName("Foo!"); + $b->setStoreName('Foo!'); $b->save(); $employee = new BookstoreEmployee(); - $employee->setName("Johnny Walker"); + $employee->setName('Johnny Walker'); $acct = new BookstoreEmployeeAccount(); $acct->setBookstoreEmployee($employee); - $acct->setLogin("test-login"); + $acct->setLogin('test-login'); - $this->assertNull($acct->getCreated(), "Expected created column to be NULL."); - $this->assertNull($acct->getAuthenticator(), "Expected authenticator column to be NULL."); + $this->assertNull($acct->getCreated(), 'Expected created column to be NULL.'); + $this->assertNull($acct->getAuthenticator(), 'Expected authenticator column to be NULL.'); $acct->save(); $acct = BookstoreEmployeeAccountQuery::create()->findPk($acct->getEmployeeId()); - $this->assertNotNull($acct->getAuthenticator(), "Expected a valid (non-NULL) authenticator column after save."); + $this->assertNotNull($acct->getAuthenticator(), 'Expected a valid (non-NULL) authenticator column after save.'); $this->assertEquals('Password', $acct->getAuthenticator(), "Expected authenticator='Password' after save."); - $this->assertNotNull($acct->getCreated(), "Expected a valid date after retrieving saved object."); + $this->assertNotNull($acct->getCreated(), 'Expected a valid date after retrieving saved object.'); - $now = new DateTime("now"); - $this->assertEquals($now->format("Y-m-d"), $acct->getCreated("Y-m-d")); + $now = new DateTime('now'); + $this->assertEquals($now->format('Y-m-d'), $acct->getCreated('Y-m-d')); $acct->setCreated($now); - $this->assertEquals($now->format("Y-m-d"), $acct->getCreated("Y-m-d")); + $this->assertEquals($now->format('Y-m-d'), $acct->getCreated('Y-m-d')); // Unfortunately we can't really test the conjunction of reloadOnInsert and reloadOnUpdate when using just // default values. (At least not in a cross-db way.) @@ -196,23 +207,25 @@ public function testDefaultExpressions() /** * Tests the use of default expressions and the reloadOnInsert attribute. * - * @link http://propel.phpdb.org/trac/ticket/378 - * @link http://propel.phpdb.org/trac/ticket/555 + * @link http://propel.phpdb.org/trac/ticket/378 + * @link http://propel.phpdb.org/trac/ticket/555 + * + * @return void */ public function testDefaultExpressions_ReloadOnInsert() { if (Propel::getServiceContainer()->getAdapter(BookstoreEmployeeTableMap::DATABASE_NAME) instanceof SqliteAdapter) { - $this->markTestSkipped("Cannot test default date expressions with SQLite"); + $this->markTestSkipped('Cannot test default date expressions with SQLite'); } // Create a new bookstore, contest, bookstore_contest, and bookstore_contest_entry $b = new Bookstore(); - $b->setStoreName("Barnes & Noble"); + $b->setStoreName('Barnes & Noble'); $b->save(); $c = new Contest(); - $c->setName("Bookathon Contest"); + $c->setName('Bookathon Contest'); $c->save(); $bc = new BookstoreContest(); @@ -221,7 +234,7 @@ public function testDefaultExpressions_ReloadOnInsert() $bc->save(); $c = new Customer(); - $c->setName("Happy Customer"); + $c->setName('Happy Customer'); $c->save(); $bce = new BookstoreContestEntry(); @@ -230,28 +243,30 @@ public function testDefaultExpressions_ReloadOnInsert() $bce->setCustomer($c); $bce->save(); - $this->assertNotNull($bce->getEntryDate(), "Expected a non-null entry_date after save."); + $this->assertNotNull($bce->getEntryDate(), 'Expected a non-null entry_date after save.'); } /** * Tests the overriding reloadOnInsert at runtime. * - * @link http://propel.phpdb.org/trac/ticket/378 - * @link http://propel.phpdb.org/trac/ticket/555 + * @link http://propel.phpdb.org/trac/ticket/378 + * @link http://propel.phpdb.org/trac/ticket/555 + * + * @return void */ public function testDefaultExpressions_ReloadOnInsert_Override() { if (Propel::getServiceContainer()->getAdapter(BookstoreEmployeeTableMap::DATABASE_NAME) instanceof SqliteAdapter) { - $this->markTestSkipped("Cannot test default date expressions with SQLite"); + $this->markTestSkipped('Cannot test default date expressions with SQLite'); } // Create a new bookstore, contest, bookstore_contest, and bookstore_contest_entry $b = new Bookstore(); - $b->setStoreName("Barnes & Noble"); + $b->setStoreName('Barnes & Noble'); $b->save(); $c = new Contest(); - $c->setName("Bookathon Contest"); + $c->setName('Bookathon Contest'); $c->save(); $bc = new BookstoreContest(); @@ -260,74 +275,80 @@ public function testDefaultExpressions_ReloadOnInsert_Override() $bc->save(); $c = new Customer(); - $c->setName("Happy Customer"); + $c->setName('Happy Customer'); $c->save(); $bce = new BookstoreContestEntry(); $bce->setBookstore($b); $bce->setBookstoreContest($bc); $bce->setCustomer($c); - $bce->save(null, $skipReload=true); + $bce->save(null, $skipReload = true); - $this->assertNull($bce->getEntryDate(), "Expected a NULL entry_date after save."); + $this->assertNull($bce->getEntryDate(), 'Expected a NULL entry_date after save.'); } /** * Tests the use of default expressions and the reloadOnUpdate attribute. * - * @link http://propel.phpdb.org/trac/ticket/555 + * @link http://propel.phpdb.org/trac/ticket/555 + * + * @return void */ public function testDefaultExpressions_ReloadOnUpdate() { $b = new Bookstore(); - $b->setStoreName("Foo!"); + $b->setStoreName('Foo!'); $b->save(); $sale = new BookstoreSale(); $sale->setBookstore(BookstoreQuery::create()->findOne()); - $sale->setSaleName("Spring Sale"); + $sale->setSaleName('Spring Sale'); $sale->save(); // Expect that default values are set, but not default expressions - $this->assertNull($sale->getDiscount(), "Expected discount to be NULL."); + $this->assertNull($sale->getDiscount(), 'Expected discount to be NULL.'); - $sale->setSaleName("Winter Clearance"); + $sale->setSaleName('Winter Clearance'); $sale->save(); // Since reloadOnUpdate = true, we expect the discount to be set now. - $this->assertNotNull($sale->getDiscount(), "Expected discount to be non-NULL after save."); + $this->assertNotNull($sale->getDiscount(), 'Expected discount to be non-NULL after save.'); } /** * Tests the overriding reloadOnUpdate at runtime. * - * @link http://propel.phpdb.org/trac/ticket/378 - * @link http://propel.phpdb.org/trac/ticket/555 + * @link http://propel.phpdb.org/trac/ticket/378 + * @link http://propel.phpdb.org/trac/ticket/555 + * + * @return void */ public function testDefaultExpressions_ReloadOnUpdate_Override() { $b = new Bookstore(); - $b->setStoreName("Foo!"); + $b->setStoreName('Foo!'); $b->save(); $sale = new BookstoreSale(); $sale->setBookstore(BookstoreQuery::create()->findOne()); - $sale->setSaleName("Spring Sale"); + $sale->setSaleName('Spring Sale'); $sale->save(); // Expect that default values are set, but not default expressions - $this->assertNull($sale->getDiscount(), "Expected discount to be NULL."); + $this->assertNull($sale->getDiscount(), 'Expected discount to be NULL.'); - $sale->setSaleName("Winter Clearance"); - $sale->save(null, $skipReload=true); + $sale->setSaleName('Winter Clearance'); + $sale->save(null, $skipReload = true); // Since reloadOnUpdate = true, we expect the discount to be set now. - $this->assertNull($sale->getDiscount(), "Expected NULL value for discount after save."); + $this->assertNull($sale->getDiscount(), 'Expected NULL value for discount after save.'); } /** * Testing creating & saving new object & instance pool. + * + * @return void */ public function testObjectInstances_New() { @@ -337,11 +358,12 @@ public function testObjectInstances_New() $id = $emp->getId(); $retrieved = BookstoreEmployeeQuery::create()->findPk($id); - $this->assertSame($emp, $retrieved, "Expected same object (from instance pool)"); + $this->assertSame($emp, $retrieved, 'Expected same object (from instance pool)'); } + /** - * + * @return void */ public function testObjectInstances_Fkeys() { @@ -358,8 +380,8 @@ public function testObjectInstances_Fkeys() $pub2->save(); $book = new Book(); - $book->setTitle("Book Title"); - $book->setISBN("1234"); + $book->setTitle('Book Title'); + $book->setISBN('1234'); $book->setPublisher($pub1); $book->save(); @@ -367,110 +389,112 @@ public function testObjectInstances_Fkeys() // now change values behind the scenes $con = Propel::getServiceContainer()->getConnection(BookstoreEmployeeAccountTableMap::DATABASE_NAME); - $con->exec("UPDATE " . BookTableMap::TABLE_NAME . " SET " - . " publisher_id = " . $pub2->getId() - . " WHERE id = " . $book->getId()); + $con->exec('UPDATE ' . BookTableMap::TABLE_NAME . ' SET ' + . ' publisher_id = ' . $pub2->getId() + . ' WHERE id = ' . $book->getId()); $book2 = BookQuery::create()->findPk($book->getId()); - $this->assertSame($book, $book2, "Expected same book object instance"); + $this->assertSame($book, $book2, 'Expected same book object instance'); - $this->assertEquals($pub1->getId(), $book->getPublisherId(), "Expected book to have OLD publisher id before reload()"); + $this->assertEquals($pub1->getId(), $book->getPublisherId(), 'Expected book to have OLD publisher id before reload()'); $book->reload(); - $this->assertEquals($pub2->getId(), $book->getPublisherId(), "Expected book to have new publisher id"); - $this->assertSame($pub2, $book->getPublisher(), "Expected book to have new publisher object associated."); + $this->assertEquals($pub2->getId(), $book->getPublisherId(), 'Expected book to have new publisher id'); + $this->assertSame($pub2, $book->getPublisher(), 'Expected book to have new publisher object associated.'); // Now let's set it back, just to be double sure ... - $con->exec("UPDATE " . BookTableMap::TABLE_NAME . " SET " - . " publisher_id = " . $pub1->getId() - . " WHERE id = " . $book->getId()); + $con->exec('UPDATE ' . BookTableMap::TABLE_NAME . ' SET ' + . ' publisher_id = ' . $pub1->getId() + . ' WHERE id = ' . $book->getId()); $book->reload(); - $this->assertEquals($pub1->getId(), $book->getPublisherId(), "Expected book to have old publisher id (again)."); - $this->assertSame($pub1, $book->getPublisher(), "Expected book to have old publisher object associated (again)."); - + $this->assertEquals($pub1->getId(), $book->getPublisherId(), 'Expected book to have old publisher id (again).'); + $this->assertSame($pub1, $book->getPublisher(), 'Expected book to have old publisher object associated (again).'); } /** * Test the effect of typecast on primary key values and instance pool retrieval. + * + * @return void */ public function testObjectInstancePoolTypecasting() { $reader = new BookReader(); - $reader->setName("Tester"); + $reader->setName('Tester'); $reader->save(); $readerId = $reader->getId(); $book = new Book(); - $book->setTitle("BookTest"); - $book->setISBN("TEST"); + $book->setTitle('BookTest'); + $book->setISBN('TEST'); $book->save(); $bookId = $book->getId(); $opinion = new BookOpinion(); - $opinion->setBookId((string) $bookId); - $opinion->setReaderId((string) $readerId); + $opinion->setBookId((string)$bookId); + $opinion->setReaderId((string)$readerId); $opinion->setRating(5); $opinion->setRecommendToFriend(false); $opinion->save(); - $opinion2 = BookOpinionQuery::create()->findPk([$bookId, $readerId]); - $this->assertSame($opinion, $opinion2, "Expected same object to be retrieved from differently type-casted primary key values."); - + $this->assertSame($opinion, $opinion2, 'Expected same object to be retrieved from differently type-casted primary key values.'); } /** * Test saving an object and getting correct number of affected rows from save(). * This includes tests of cascading saves to fk-related objects. + * + * @return void */ public function testSaveReturnValues() { - $author = new Author(); - $author->setFirstName("Mark"); - $author->setLastName("Kurlansky"); + $author->setFirstName('Mark'); + $author->setLastName('Kurlansky'); // do not save $pub = new Publisher(); - $pub->setName("Penguin Books"); + $pub->setName('Penguin Books'); // do not save $book = new Book(); - $book->setTitle("Salt: A World History"); - $book->setISBN("0142001619"); + $book->setTitle('Salt: A World History'); + $book->setISBN('0142001619'); $book->setAuthor($author); $book->setPublisher($pub); $affected = $book->save(); - $this->assertEquals(3, $affected, "Expected 3 affected rows when saving book + publisher + author."); + $this->assertEquals(3, $affected, 'Expected 3 affected rows when saving book + publisher + author.'); // change nothing ... $affected = $book->save(); - $this->assertEquals(0, $affected, "Expected 0 affected rows when saving already-saved book."); + $this->assertEquals(0, $affected, 'Expected 0 affected rows when saving already-saved book.'); // modify the book (UPDATE) - $book->setTitle("Salt A World History"); + $book->setTitle('Salt A World History'); $affected = $book->save(); - $this->assertEquals(1, $affected, "Expected 1 affected row when saving modified book."); + $this->assertEquals(1, $affected, 'Expected 1 affected row when saving modified book.'); // modify the related author - $author->setLastName("Kurlanski"); + $author->setLastName('Kurlanski'); $affected = $book->save(); - $this->assertEquals(1, $affected, "Expected 1 affected row when saving book with updated author."); + $this->assertEquals(1, $affected, 'Expected 1 affected row when saving book with updated author.'); // modify both the related author and the book - $author->setLastName("Kurlansky"); - $book->setTitle("Salt: A World History"); + $author->setLastName('Kurlansky'); + $book->setTitle('Salt: A World History'); $affected = $book->save(); - $this->assertEquals(2, $affected, "Expected 2 affected rows when saving updated book with updated author."); - + $this->assertEquals(2, $affected, 'Expected 2 affected rows when saving updated book with updated author.'); } + /** + * @return void + */ public function testSaveCanInsertNonEmptyObjects() { $b = new Book(); @@ -481,8 +505,9 @@ public function testSaveCanInsertNonEmptyObjects() $this->assertNotNull($b->getId()); } + /** - * + * @return void */ public function testNoColsModified() { @@ -498,15 +523,20 @@ public function testNoColsModified() $super->addSubordinate($e2); $affected = $super->save(); - } + /** + * @return void + */ public function testIsModifiedIsFalseForNewObjects() { $a = new Author(); $this->assertFalse($a->isModified()); } + /** + * @return void + */ public function testIsModifiedIsTrueForNewObjectsWithModifications() { $a = new Author(); @@ -514,6 +544,9 @@ public function testIsModifiedIsTrueForNewObjectsWithModifications() $this->assertTrue($a->isModified()); } + /** + * @return void + */ public function testIsModifiedIsFalseForNewObjectsWithNullModifications() { $a = new Author(); @@ -521,6 +554,9 @@ public function testIsModifiedIsFalseForNewObjectsWithNullModifications() $this->assertFalse($a->isModified()); } + /** + * @return void + */ public function testIsModifiedIsFalseForObjectsAfterResetModified() { $a = new Author(); @@ -529,6 +565,9 @@ public function testIsModifiedIsFalseForObjectsAfterResetModified() $this->assertFalse($a->isModified()); } + /** + * @return void + */ public function testIsModifiedIsFalseForSavedObjects() { $a = new Author(); @@ -538,6 +577,9 @@ public function testIsModifiedIsFalseForSavedObjects() $this->assertFalse($a->isModified()); } + /** + * @return void + */ public function testIsModifiedIsTrueForSavedObjectsWithModifications() { $a = new Author(); @@ -549,6 +591,9 @@ public function testIsModifiedIsTrueForSavedObjectsWithModifications() $this->assertTrue($a->isModified()); } + /** + * @return void + */ public function testIsModifiedIsFalseAfterSetToDefaultValueOnNewObject() { $p = new Publisher(); @@ -556,6 +601,9 @@ public function testIsModifiedIsFalseAfterSetToDefaultValueOnNewObject() $this->assertFalse($p->isModified()); } + /** + * @return void + */ public function testIsModifiedIsTrueAfterModifyingOnNonDefaultValueOnNewObject() { $p = new Publisher(); @@ -563,6 +611,9 @@ public function testIsModifiedIsTrueAfterModifyingOnNonDefaultValueOnNewObject() $this->assertTrue($p->isModified()); } + /** + * @return void + */ public function testIsModifiedIsTrueAfterSetToDefaultValueOnModifiedObject() { $p = new Publisher(); @@ -572,6 +623,9 @@ public function testIsModifiedIsTrueAfterSetToDefaultValueOnModifiedObject() $this->assertTrue($p->isModified()); } + /** + * @return void + */ public function testIsModifiedIsFalseAfterChangingColumnTypeButNotValue() { $a = new Author(); @@ -586,6 +640,9 @@ public function testIsModifiedIsFalseAfterChangingColumnTypeButNotValue() $this->assertFalse($a->isModified()); } + /** + * @return void + */ public function testIsModifiedAndNullValues() { $a = new Author(); @@ -595,21 +652,24 @@ public function testIsModifiedAndNullValues() $a->save(); $a->setFirstName(null); - $this->assertTrue($a->isModified(), "Expected Author to be modified after changing empty string column value to NULL."); + $this->assertTrue($a->isModified(), 'Expected Author to be modified after changing empty string column value to NULL.'); $a->setAge(null); - $this->assertTrue($a->isModified(), "Expected Author to be modified after changing 0-value int column to NULL."); + $this->assertTrue($a->isModified(), 'Expected Author to be modified after changing 0-value int column to NULL.'); $a->setFirstName(''); - $this->assertTrue($a->isModified(), "Expected Author to be modified after changing NULL column value to empty string."); + $this->assertTrue($a->isModified(), 'Expected Author to be modified after changing NULL column value to empty string.'); $a->setAge(0); - $this->assertTrue($a->isModified(), "Expected Author to be modified after changing NULL column to 0-value int."); + $this->assertTrue($a->isModified(), 'Expected Author to be modified after changing NULL column to 0-value int.'); } /** * Test checking for non-default values. + * * @see http://propel.phpdb.org/trac/ticket/331 + * + * @return void */ public function testHasOnlyDefaultValues() { @@ -620,41 +680,44 @@ public function testHasOnlyDefaultValues() $acct = new BookstoreEmployeeAccount(); $acct->setBookstoreEmployee($emp); - $acct->setLogin("foo"); - $acct->setPassword("bar"); + $acct->setLogin('foo'); + $acct->setPassword('bar'); $acct->save(); - $this->assertFalse($acct->isModified(), "Expected BookstoreEmployeeAccount NOT to be modified after save()."); + $this->assertFalse($acct->isModified(), 'Expected BookstoreEmployeeAccount NOT to be modified after save().'); $acct->setEnabled(true); $acct->setPassword($acct2->getPassword()); - $this->assertTrue($acct->isModified(), "Expected BookstoreEmployeeAccount to be modified after setting default values."); + $this->assertTrue($acct->isModified(), 'Expected BookstoreEmployeeAccount to be modified after setting default values.'); - $this->assertTrue($acct->hasOnlyDefaultValues(), "Expected BookstoreEmployeeAccount to not have only default values."); + $this->assertTrue($acct->hasOnlyDefaultValues(), 'Expected BookstoreEmployeeAccount to not have only default values.'); - $acct->setPassword("bar"); - $this->assertFalse($acct->hasOnlyDefaultValues(), "Expected BookstoreEmployeeAccount to have at one non-default value after setting one value to non-default."); + $acct->setPassword('bar'); + $this->assertFalse($acct->hasOnlyDefaultValues(), 'Expected BookstoreEmployeeAccount to have at one non-default value after setting one value to non-default.'); // Test a default date/time value $r = new Review(); - $r->setReviewDate(new DateTime("now")); + $r->setReviewDate(new DateTime('now')); $this->assertFalse($r->hasOnlyDefaultValues()); } + /** + * @return void + */ public function testCountRefFk() { $book = new Book(); - $book->setTitle("Test Book"); - $book->setISBN("TT-EE-SS-TT"); + $book->setTitle('Test Book'); + $book->setISBN('TT-EE-SS-TT'); $num = 5; - for ($i=2; $i < $num + 2; $i++) { + for ($i = 2; $i < $num + 2; $i++) { $r = new Review(); $r->setReviewedBy('Hans ' . $num); - $dt = new DateTime("now"); - $dt->modify("-".$i." weeks"); + $dt = new DateTime('now'); + $dt->modify('-' . $i . ' weeks'); $r->setReviewDate($dt); $r->setRecommended(($i % 2) == 0); $book->addReview($r); @@ -675,30 +738,33 @@ public function testCountRefFk() // Now set different criteria and expect different results $c = new Criteria(); $c->add(ReviewTableMap::COL_RECOMMENDED, false); - $this->assertEquals(floor($num/2), $book->countReviews($c), "Expected " . floor($num/2) . " results from countReviews(recomm=false)"); + $this->assertEquals(floor($num / 2), $book->countReviews($c), 'Expected ' . floor($num / 2) . ' results from countReviews(recomm=false)'); // Change Criteria, run again -- expect different. $c = new Criteria(); $c->add(ReviewTableMap::COL_RECOMMENDED, true); - $this->assertEquals(ceil($num/2), count($book->getReviews($c)), "Expected " . ceil($num/2) . " results from getReviews(recomm=true)"); + $this->assertEquals(ceil($num / 2), count($book->getReviews($c)), 'Expected ' . ceil($num / 2) . ' results from getReviews(recomm=true)'); $this->assertEquals($num, $book->countReviews(), "Expected countReviews to return $num with new empty Criteria"); } /** * Test copying when an object has composite primary key. + * * @link http://propel.phpdb.org/trac/ticket/618 + * + * @return void */ public function testCopy_CompositePK() { $br = new BookReader(); - $br->setName("TestReader"); + $br->setName('TestReader'); $br->save(); $br->copy(); $b = new Book(); - $b->setTitle("TestBook"); - $b->setISBN("XX-XX-XX-XX"); + $b->setTitle('TestBook'); + $b->setISBN('XX-XX-XX-XX'); $b->save(); $op = new BookOpinion(); @@ -713,7 +779,7 @@ public function testCopy_CompositePK() $this->assertNull($br2->getId()); $opinions = $br2->getBookOpinions(); - $this->assertEquals(1, count($opinions), "Expected to have a related BookOpinion after copy()"); + $this->assertEquals(1, count($opinions), 'Expected to have a related BookOpinion after copy()'); // We DO expect the reader_id to be null $this->assertNull($opinions[0]->getReaderId()); @@ -721,6 +787,9 @@ public function testCopy_CompositePK() $this->assertEquals($op->getBookId(), $opinions[0]->getBookId()); } + /** + * @return void + */ public function testToArray() { $b = new Book(); @@ -733,15 +802,18 @@ public function testToArray() 'ISBN', 'Price', 'PublisherId', - 'AuthorId' + 'AuthorId', ]; $this->assertEquals($expectedKeys, array_keys($arr1), 'toArray() returns an associative array with TableMap::TYPE_PHPNAME keys by default'); $this->assertEquals('Don Juan', $arr1['Title'], 'toArray() returns an associative array representation of the object'); } + /** + * @return void + */ public function testToArrayDateTimeAsString() { - $date = new \DateTime('2015-01-04T16:00:02Z'); + $date = new DateTime('2015-01-04T16:00:02Z'); $review = new Review(); $review->setReviewDate($date); @@ -749,6 +821,9 @@ public function testToArrayDateTimeAsString() $this->assertEquals('2015-01-04T16:00:02+00:00', $review->toArray()['ReviewDate'], 'toArray() format temporal colums as ISO8601'); } + /** + * @return void + */ public function testWithColumn() { $book = BookQuery::create()->withColumn('Title', 'TitleCopy')->findOne(); @@ -756,6 +831,9 @@ public function testWithColumn() $this->assertEquals($book->getTitleCopy(), $bookArray['TitleCopy']); } + /** + * @return void + */ public function testToArrayKeyType() { $b = new Book(); @@ -768,12 +846,15 @@ public function testToArrayKeyType() BookTableMap::COL_ISBN, BookTableMap::COL_PRICE, BookTableMap::COL_PUBLISHER_ID, - BookTableMap::COL_AUTHOR_ID + BookTableMap::COL_AUTHOR_ID, ]; $this->assertEquals($expectedKeys, array_keys($arr1), 'toArray() accepts a $keyType parameter to change the result keys'); $this->assertEquals('Don Juan', $arr1[BookTableMap::COL_TITLE], 'toArray() returns an associative array representation of the object'); } + /** + * @return void + */ public function testToArrayKeyTypePreDefined() { $schema = <<setId(1); - $b->setStoreName("Test"); + $b->setStoreName('Test'); try { $b->save(); - $this->fail("Expected setting auto-increment primary key to result in Exception"); - } catch (\Exception $x) { + $this->fail('Expected setting auto-increment primary key to result in Exception'); + } catch (Exception $x) { $this->assertInstanceOf('\Propel\Runtime\Exception\PropelException', $x); } @@ -821,11 +904,11 @@ public function testSettingAutoIncrementPK() // the same as "not set" in PHP world. $b = new Bookstore(); $b->setId(null); - $b->setStoreName("Test2"); + $b->setStoreName('Test2'); try { $b->save(); - } catch (\Exception $x) { - $this->fail("Expected no exception when setting auto-increment primary key to NULL"); + } catch (Exception $x) { + $this->fail('Expected no exception when setting auto-increment primary key to NULL'); } // success ... @@ -838,11 +921,13 @@ public function testSettingAutoIncrementPK() * * saves the object, gets it from data-source again and then compares * them for equality (thus the instance pool is also checked) + * + * @return void */ public function testAllowPkInsertOnIdMethodNativeTable() { CustomerTableMap::doDeleteAll(); - $cu = new Customer; + $cu = new Customer(); $cu->setPrimaryKey(100000); $cu->save(); @@ -855,6 +940,8 @@ public function testAllowPkInsertOnIdMethodNativeTable() /** * Checks if it is allowed to save new, empty objects with a auto increment column + * + * @return void */ public function testAllowEmptyWithAutoIncrement() { @@ -866,18 +953,21 @@ public function testAllowEmptyWithAutoIncrement() /** * Test foreign key relationships based on references to unique cols but not PK. - * @link http://propel.phpdb.org/trac/ticket/691 + * + * @link http://propel.phpdb.org/trac/ticket/691 + * + * @return void */ public function testUniqueFkRel() { BookstoreEmployeeAccountTableMap::doDeleteAll(); $employee = new BookstoreEmployee(); - $employee->setName("Johnny Walker"); + $employee->setName('Johnny Walker'); $acct = new BookstoreEmployeeAccount(); $acct->setBookstoreEmployee($employee); - $acct->setLogin("test-login"); + $acct->setLogin('test-login'); $acct->save(); $acctId = $acct->getEmployeeId(); @@ -891,16 +981,19 @@ public function testUniqueFkRel() AcctAuditLogTableMap::clearInstancePool(); $al2 = AcctAuditLogQuery::create()->findPk($alId); - /* @var $al2 AcctAuditLog */ + /** @var \Propel\Tests\Bookstore\AcctAuditLog $al2 */ $mapacct = $al2->getBookstoreEmployeeAccount(); $lookupacct = BookstoreEmployeeAccountQuery::create()->findPk($acctId); $logs = $lookupacct->getAcctAuditLogs(); - $this->assertTrue(count($logs) == 1, "Expected 1 audit log result."); - $this->assertEquals($logs[0]->getId(), $al->getId(), "Expected returned audit log to match created audit log."); + $this->assertTrue(count($logs) == 1, 'Expected 1 audit log result.'); + $this->assertEquals($logs[0]->getId(), $al->getId(), 'Expected returned audit log to match created audit log.'); } + /** + * @return void + */ public function testIsPrimaryKeyNull() { $b = new Book(); @@ -911,6 +1004,9 @@ public function testIsPrimaryKeyNull() $this->assertTrue($b->isPrimaryKeyNull()); } + /** + * @return void + */ public function testIsPrimaryKeyNullComposite() { $b = new BookOpinion(); @@ -925,6 +1021,9 @@ public function testIsPrimaryKeyNullComposite() $this->assertTrue($b->isPrimaryKeyNull()); } + /** + * @return void + */ public function testAddToStringDefault() { $this->assertTrue(method_exists('\Propel\Tests\Bookstore\Author', '__toString'), 'addPrimaryString() adds a __toString() method even if no column has the primaryString attribute'); @@ -939,73 +1038,94 @@ public function testAddToStringDefault() Age: null EOF; - $this->assertEquals($expected, (string) $author, 'addPrimaryString() adds a __toString() method returning the YAML representation of the object where no column is defined as primaryString'); + $this->assertEquals($expected, (string)$author, 'addPrimaryString() adds a __toString() method returning the YAML representation of the object where no column is defined as primaryString'); } + /** + * @return void + */ public function testAddToStringPrimaryString() { $this->assertTrue(method_exists('\Propel\Tests\Bookstore\Book', '__toString'), 'addPrimaryString() adds a __toString() method if a column has the primaryString attribute'); $book = new Book(); $book->setTitle('foo'); - $this->assertEquals('foo', (string) $book, 'addPrimaryString() adds a __toString() method returning the value of the the first column where primaryString is true'); + $this->assertEquals('foo', (string)$book, 'addPrimaryString() adds a __toString() method returning the value of the the first column where primaryString is true'); } + /** + * @return void + */ public function testPreInsert() { $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); + $author->setFirstName('bogus'); + $author->setLastName('Lastname'); $author->save(); $this->assertEquals('PreInsertedFirstname', $author->getFirstName()); } + /** + * @return void + */ public function testPreUpdate() { $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); + $author->setFirstName('bogus'); + $author->setLastName('Lastname'); $author->save(); $author->setNew(false); $author->save(); $this->assertEquals('PreUpdatedFirstname', $author->getFirstName()); } + /** + * @return void + */ public function testPostInsert() { $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); + $author->setFirstName('bogus'); + $author->setLastName('Lastname'); $author->save(); $this->assertEquals('PostInsertedLastName', $author->getLastName()); } + /** + * @return void + */ public function testPostUpdate() { $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); + $author->setFirstName('bogus'); + $author->setLastName('Lastname'); $author->save(); $author->setNew(false); $author->save(); $this->assertEquals('PostUpdatedLastName', $author->getLastName()); } + /** + * @return void + */ public function testPreSave() { $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); + $author->setFirstName('bogus'); + $author->setLastName('Lastname'); $author->save(); $this->assertEquals('pre@save.com', $author->getEmail()); } + /** + * @return void + */ public function testPreSaveFalse() { $con = Propel::getServiceContainer()->getConnection(AuthorTableMap::DATABASE_NAME); $nbNestedTransactions = $con->getNestedTransactionCount(); $author = new TestAuthorSaveFalse(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); + $author->setFirstName('bogus'); + $author->setLastName('Lastname'); $res = $author->save($con); $this->assertEquals(0, $res); $this->assertEquals('pre@save.com', $author->getEmail()); @@ -1014,49 +1134,64 @@ public function testPreSaveFalse() $this->assertEquals($nbNestedTransactions, $con->getNestedTransactionCount()); } + /** + * @return void + */ public function testPostSave() { $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); + $author->setFirstName('bogus'); + $author->setLastName('Lastname'); $author->save(); $this->assertEquals(115, $author->getAge()); } + /** + * @return void + */ public function testPreDelete() { $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); + $author->setFirstName('bogus'); + $author->setLastName('Lastname'); $author->save(); $author->delete(); - $this->assertEquals("Pre-Deleted", $author->getFirstName()); + $this->assertEquals('Pre-Deleted', $author->getFirstName()); } + /** + * @return void + */ public function testPreDeleteFalse() { $con = Propel::getServiceContainer()->getConnection(AuthorTableMap::DATABASE_NAME); $author = new TestAuthorDeleteFalse(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); + $author->setFirstName('bogus'); + $author->setLastName('Lastname'); $author->save($con); $author->delete($con); - $this->assertEquals("Pre-Deleted", $author->getFirstName()); - $this->assertNotEquals("Post-Deleted", $author->getLastName()); + $this->assertEquals('Pre-Deleted', $author->getFirstName()); + $this->assertNotEquals('Post-Deleted', $author->getLastName()); $this->assertFalse($author->isDeleted()); $this->assertEquals(1, $con->getNestedTransactionCount()); } + /** + * @return void + */ public function testPostDelete() { $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); + $author->setFirstName('bogus'); + $author->setLastName('Lastname'); $author->save(); $author->delete(); - $this->assertEquals("Post-Deleted", $author->getLastName()); + $this->assertEquals('Post-Deleted', $author->getLastName()); } + /** + * @return void + */ public function testMagicVirtualColumnGetter() { $book = new Book(); @@ -1069,6 +1204,8 @@ public function testMagicVirtualColumnGetter() /** * @expectedException \Propel\Runtime\Exception\BadMethodCallException + * + * @return void */ public function testMagicCallUndefined() { @@ -1083,7 +1220,7 @@ public static function conditionsForTestReadOnly() ['delete'], ['save'], ['doSave'], - ['importFrom'] + ['importFrom'], ]; } @@ -1091,23 +1228,27 @@ public static function conditionsForTestVisibility() { return [ ['setCode'], - ['setCapital'] + ['setCapital'], ]; } /** * @dataProvider conditionsForTestVisibility + * + * @return void */ public function testMethodVisibility($method) { $cv = new Country(); - $reflectionMethod = new \ReflectionMethod($cv, $method); + $reflectionMethod = new ReflectionMethod($cv, $method); $this->assertTrue($reflectionMethod->isProtected(), 'readOnly tables end up with no callable `' . $method . '` method in the generated object class'); } /** * @dataProvider conditionsForTestReadOnly + * + * @return void */ public function testReadOnly($method) { @@ -1115,6 +1256,9 @@ public function testReadOnly($method) $this->assertFalse(method_exists($cv, $method), 'readOnly tables end up with no ' . $method . ' method in the generated object class'); } + /** + * @return void + */ public function testReadOnlyRelations() { //add countries @@ -1147,7 +1291,9 @@ public function testReadOnlyRelations() $this->assertEquals('France', $translations[0]->getLabel()); } - + /** + * @return void + */ public function testSetterOneToMany() { // Ensure no data @@ -1233,6 +1379,9 @@ public function testSetterOneToMany() $this->assertEquals(5, BookQuery::create()->count()); } + /** + * @return void + */ public function testSetterOneToManyWithNoData() { // Ensure no data @@ -1254,6 +1403,9 @@ public function testSetterOneToManyWithNoData() $this->assertEquals(0, BookQuery::create()->count()); } + /** + * @return void + */ public function testSetterOneToManySavesForeignObjects() { // Ensure no data @@ -1291,6 +1443,9 @@ public function testSetterOneToManySavesForeignObjects() $this->assertSame('My Title', $result); } + /** + * @return void + */ public function testSetterOneToManyWithNewObjects() { // Ensure no data @@ -1321,6 +1476,9 @@ public function testSetterOneToManyWithNewObjects() $this->assertEquals(3, BookQuery::create()->count()); } + /** + * @return void + */ public function testSetterOneToManyWithExistingObjects() { // Ensure no data @@ -1353,6 +1511,9 @@ public function testSetterOneToManyWithExistingObjects() } } + /** + * @return void + */ public function testSetterOneToManyWithEmptyCollection() { // Ensure no data @@ -1371,6 +1532,9 @@ public function testSetterOneToManyWithEmptyCollection() $this->assertEquals(1, AuthorQuery::create()->count()); } + /** + * @return void + */ public function testSetterOneToManyReplacesOldObjectsByNewObjects() { // Ensure no data @@ -1417,6 +1581,9 @@ public function testSetterOneToManyReplacesOldObjectsByNewObjects() $this->assertEquals(4, BookQuery::create()->count()); } + /** + * @return void + */ public function testSetterOneToManyWithFkRequired() { // Ensure no data @@ -1497,6 +1664,9 @@ public function testSetterOneToManyWithFkRequired() $this->assertEquals(4, BookSummaryQuery::create()->count()); } + /** + * @return void + */ public function testSetterOneToManyReplacesOldObjectsByNewObjectsWithFkRequired() { // Ensure no data @@ -1538,6 +1708,9 @@ public function testSetterOneToManyReplacesOldObjectsByNewObjectsWithFkRequired( $this->assertEquals(2, BookSummaryQuery::create()->count()); } + /** + * @return void + */ public function testUnsavedObjectCallingHashCodeIsNotChangingObject() { $book1 = new Book(); @@ -1555,6 +1728,9 @@ public function testUnsavedObjectCallingHashCodeIsNotChangingObject() $this->assertEquals($author, $a); } + /** + * @return void + */ public function testSavedObjectCallingHashCodeIsNotChangingObject() { $book1 = new Book(); @@ -1573,6 +1749,9 @@ public function testSavedObjectCallingHashCodeIsNotChangingObject() $this->assertEquals($author, $a); } + /** + * @return void + */ public function testUnsavedObjectCreatesNotSameHashForIdenticalObjects() { $book1 = new Book(); @@ -1594,6 +1773,8 @@ public function testUnsavedObjectCreatesNotSameHashForIdenticalObjects() /** * Primary key should differ + * + * @return void */ public function testSavedObjectCreatesDifferentHashForIdenticalObjects() { diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithDateImmutableClassTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithDateImmutableClassTest.php index fd79bddba0..0490174de2 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithDateImmutableClassTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithDateImmutableClassTest.php @@ -10,11 +10,13 @@ use Propel\Generator\Config\QuickGeneratorConfig; use Propel\Generator\Util\QuickBuilder; -use Propel\Runtime\Propel; use Propel\Tests\TestCase; class GeneratedObjectWithDateImmutableClassTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('Foo\SomeTableA')) { @@ -33,9 +35,9 @@ public function setUp(): void 'generator' => [ 'dateTime' => [ 'dateTimeClass' => 'DateTimeImmutable', - ] - ] - ] + ], + ], + ], ]); $builder->setSchema($schema); $builder->setConfig($config); @@ -55,6 +57,9 @@ public function setUp(): void } } + /** + * @return void + */ public function testDateTimeInterface() { $ModelA = new \Foo\SomeTableA(); @@ -66,6 +71,9 @@ public function testDateTimeInterface() $this->assertInstanceOf('\DateTimeInterface', $ModelB->getCreatedAt()); } + /** + * @return void + */ public function testFieldTypes() { $ModelA = new \Foo\SomeTableA(); @@ -77,6 +85,9 @@ public function testFieldTypes() $this->assertInstanceOf('\DateTime', $ModelB->getCreatedAt()); } + /** + * @return void + */ public function testWithDateTimeToArrayWorks() { $Date = new DateTime('now'); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithFixturesTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithFixturesTest.php index 182cd2aa67..5ed271bfe9 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithFixturesTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithFixturesTest.php @@ -10,38 +10,39 @@ namespace Propel\Tests\Generator\Builder\Om; -use Propel\Runtime\Exception\PropelException; +use Exception; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\AuthorQuery; use Propel\Tests\Bookstore\Book; use Propel\Tests\Bookstore\BookQuery; -use Propel\Tests\Bookstore\BookstoreQuery; -use Propel\Tests\Bookstore\BookstoreSale; use Propel\Tests\Bookstore\BookstoreEmployee; use Propel\Tests\Bookstore\BookstoreEmployeeAccount; use Propel\Tests\Bookstore\BookstoreEmployeeQuery; +use Propel\Tests\Bookstore\BookstoreQuery; +use Propel\Tests\Bookstore\BookstoreSale; use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\MediaTableMap; -use Propel\Tests\Bookstore\MediaQuery; use Propel\Tests\Bookstore\Map\PublisherTableMap; +use Propel\Tests\Bookstore\Map\ReviewTableMap; +use Propel\Tests\Bookstore\MediaQuery; use Propel\Tests\Bookstore\Review; use Propel\Tests\Bookstore\ReviewQuery; -use Propel\Tests\Bookstore\Map\ReviewTableMap; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Tests the generated Object classes. * - * The database is reloaded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same - * for each test method in this class. See the BookstoreDataPopulator::populate() + * for each test method in this class. See the BookstoreDataPopulator::populate() * method for the exact contents of the database. * - * @see BookstoreDataPopulator + * @see BookstoreDataPopulator * @author Hans Lellelid * * @group database @@ -50,6 +51,8 @@ class GeneratedObjectWithFixturesTest extends BookstoreEmptyTestBase { /** * Test the reload() method. + * + * @return void */ public function testReload() { @@ -67,11 +70,12 @@ public function testReload() $this->assertEquals($origName, $a->getFirstName()); $this->assertFalse($a->isModified()); - } /** * Test reload(deep=true) method. + * + * @return void */ public function testReloadDeep() { @@ -87,17 +91,19 @@ public function testReloadDeep() $b->setAuthor($a); - $this->assertNotEquals($origAuthor, $b->getAuthor(), "Expected just-set object to be different from obj from DB"); + $this->assertNotEquals($origAuthor, $b->getAuthor(), 'Expected just-set object to be different from obj from DB'); $this->assertTrue($b->isModified()); - $b->reload($deep=true); + $b->reload($deep = true); - $this->assertEquals($origAuthor, $b->getAuthor(), "Expected object in DB to be restored"); + $this->assertEquals($origAuthor, $b->getAuthor(), 'Expected object in DB to be restored'); $this->assertFalse($a->isModified()); } /** * Test deleting an object using the delete() method. + * + * @return void */ public function testDelete() { @@ -112,19 +118,21 @@ public function testDelete() // 3) make sure it can't be save()d now that it's deleted try { - $book->setTitle("Will Fail"); + $book->setTitle('Will Fail'); $book->save(); - $this->fail("Expect an exception to be thrown when attempting to save() a deleted object."); - } catch (PropelException $e) {} + $this->fail('Expect an exception to be thrown when attempting to save() a deleted object.'); + } catch (PropelException $e) { + } // 4) make sure that it doesn't exist in db $book = BookQuery::create()->findPk($bookId); - $this->assertNull($book, "Expect NULL from retrieveByPK on deleted Book."); - + $this->assertNull($book, 'Expect NULL from retrieveByPK on deleted Book.'); } /** * Tests new one-to-one functionality. + * + * @return void */ public function testOneToOne() { @@ -134,15 +142,16 @@ public function testOneToOne() $acct = new BookstoreEmployeeAccount(); $acct->setBookstoreEmployee($emp); - $acct->setLogin("testuser"); - $acct->setPassword("testpass"); + $acct->setLogin('testuser'); + $acct->setPassword('testpass'); - $this->assertSame($emp->getBookstoreEmployeeAccount(), $acct, "Expected same object instance."); + $this->assertSame($emp->getBookstoreEmployeeAccount(), $acct, 'Expected same object instance.'); } /** * Test the type sensitivity of the returning columns. * + * @return void */ public function testTypeSensitive() { @@ -151,7 +160,7 @@ public function testTypeSensitive() $book = BookQuery::create()->findOne(); $r = new Review(); - $r->setReviewedBy("testTypeSensitive Tester"); + $r->setReviewedBy('testTypeSensitive Tester'); $r->setReviewDate(time()); $r->setBook($book); $r->setRecommended(true); @@ -167,18 +176,19 @@ public function testTypeSensitive() // reload and verify that the types are the same $r2 = ReviewQuery::create()->findPk($id); - $this->assertInternalType('integer', $r2->getId(), "Expected getId() to return an integer."); - $this->assertInternalType('string', $r2->getReviewedBy(), "Expected getReviewedBy() to return a string."); - $this->assertInternalType('boolean', $r2->getRecommended(), "Expected getRecommended() to return a boolean."); - $this->assertInstanceOf('\Propel\Tests\Bookstore\Book', $r2->getBook(), "Expected getBook() to return a Book."); - $this->assertInternalType('float', $r2->getBook()->getPrice(), "Expected Book->getPrice() to return a float."); - $this->assertInstanceOf('\DateTime', $r2->getReviewDate(null), "Expected Book->getReviewDate() to return a DateTime."); - + $this->assertInternalType('integer', $r2->getId(), 'Expected getId() to return an integer.'); + $this->assertInternalType('string', $r2->getReviewedBy(), 'Expected getReviewedBy() to return a string.'); + $this->assertInternalType('boolean', $r2->getRecommended(), 'Expected getRecommended() to return a boolean.'); + $this->assertInstanceOf('\Propel\Tests\Bookstore\Book', $r2->getBook(), 'Expected getBook() to return a Book.'); + $this->assertInternalType('float', $r2->getBook()->getPrice(), 'Expected Book->getPrice() to return a float.'); + $this->assertInstanceOf('\DateTime', $r2->getReviewDate(null), 'Expected Book->getReviewDate() to return a DateTime.'); } /** * This is a test for expected exceptions when saving UNIQUE. * See http://propel.phpdb.org/trac/ticket/2 + * + * @return void */ public function testSaveUnique() { @@ -190,8 +200,8 @@ public function testSaveUnique() $acct = new BookstoreEmployeeAccount(); $acct->setBookstoreEmployee($emp); - $acct->setLogin("foo"); - $acct->setPassword("bar"); + $acct->setLogin('foo'); + $acct->setPassword('bar'); $acct->save(); // now attempt to create a new acct @@ -199,18 +209,18 @@ public function testSaveUnique() try { $acct2->save(); - $this->fail("Expected PropelException in first attempt to save object with duplicate value for UNIQUE constraint."); - } catch (\Exception $x) { + $this->fail('Expected PropelException in first attempt to save object with duplicate value for UNIQUE constraint.'); + } catch (Exception $x) { try { // attempt to save it again $acct3 = $acct->copy(); $acct3->save(); - $this->fail("Expected PropelException in second attempt to save object with duplicate value for UNIQUE constraint."); - } catch (\Exception $x) { + $this->fail('Expected PropelException in second attempt to save object with duplicate value for UNIQUE constraint.'); + } catch (Exception $x) { // this is expected. } // now let's double check that it can succeed if we're not violating the constraint. - $acct3->setLogin("foo2"); + $acct3->setLogin('foo2'); $acct3->save(); } @@ -219,6 +229,8 @@ public function testSaveUnique() /** * Test the BaseObject#equals(). + * + * @return void */ public function testEquals() { @@ -227,34 +239,39 @@ public function testEquals() $b = BookQuery::create()->findOne(); $c = new Book(); $c->setId($b->getId()); - $this->assertTrue($b->equals($c), "Expected Book objects to be equal()"); + $this->assertTrue($b->equals($c), 'Expected Book objects to be equal()'); $a = new Author(); $a->setId($b->getId()); - $this->assertFalse($b->equals($a), "Expected Book and Author with same primary key NOT to match."); + $this->assertFalse($b->equals($a), 'Expected Book and Author with same primary key NOT to match.'); } + /** + * @return void + */ public function testDefaultFkColVal() { BookstoreDataPopulator::populate(); $sale = new BookstoreSale(); - $this->assertEquals(1, $sale->getBookstoreId(), "Expected BookstoreSale object to have a default bookstore_id of 1."); + $this->assertEquals(1, $sale->getBookstoreId(), 'Expected BookstoreSale object to have a default bookstore_id of 1.'); $bookstore = BookstoreQuery::create()->findOne(); $sale->setBookstore($bookstore); - $this->assertEquals($bookstore->getId(), $sale->getBookstoreId(), "Expected FK id to have changed when assigned a valid FK."); + $this->assertEquals($bookstore->getId(), $sale->getBookstoreId(), 'Expected FK id to have changed when assigned a valid FK.'); $sale->setBookstore(null); - $this->assertEquals(1, $sale->getBookstoreId(), "Expected BookstoreSale object to have reset to default ID."); + $this->assertEquals(1, $sale->getBookstoreId(), 'Expected BookstoreSale object to have reset to default ID.'); $sale->setPublisher(null); - $this->assertEquals(null, $sale->getPublisherId(), "Expected BookstoreSale object to have reset to NULL publisher ID."); + $this->assertEquals(null, $sale->getPublisherId(), 'Expected BookstoreSale object to have reset to NULL publisher ID.'); } /** * Test copyInto method. + * + * @return void */ public function testCopyInto_Deep() { @@ -284,7 +301,10 @@ public function testCopyInto_Deep() /** * Test the toArray() method with new lazyLoad param. - * @link http://propel.phpdb.org/trac/ticket/527 + * + * @link http://propel.phpdb.org/trac/ticket/527 + * + * @return void */ public function testToArrayLazyLoad() { @@ -293,10 +313,9 @@ public function testToArrayLazyLoad() $m = MediaQuery::create() ->filterByCoverImage(null, Criteria::NOT_EQUAL) ->filterByExcerpt(null, Criteria::NOT_EQUAL) - ->findOne() - ; + ->findOne(); if ($m === null) { - $this->fail("Test requires at least one media row w/ cover_image and excerpt NOT NULL"); + $this->fail('Test requires at least one media row w/ cover_image and excerpt NOT NULL'); } $arr1 = $m->toArray(TableMap::TYPE_COLNAME); @@ -314,6 +333,9 @@ public function testToArrayLazyLoad() $this->assertEquals($expectedDiff, $diffKeys); } + /** + * @return void + */ public function testToArrayIncludesForeignObjects() { BookstoreDataPopulator::populate(); @@ -334,12 +356,15 @@ public function testToArrayIncludesForeignObjects() 'Price', 'PublisherId', 'AuthorId', - 'Author' + 'Author', ]; $this->assertEquals($expectedKeys, array_keys($arr1), 'toArray() can return sub arrays for hydrated related objects'); $this->assertEquals('George', $arr1['Author']['FirstName'], 'toArray() can return sub arrays for hydrated related objects'); } + /** + * @return void + */ public function testToArrayIncludesForeignReferrers() { $a1 = new Author(); @@ -360,5 +385,4 @@ public function testToArrayIncludesForeignReferrers() $this->assertEquals('Anna Karenina', $arr['Books'][1]['Title']); $this->assertEquals('*RECURSION*', $arr['Books'][0]['Author']); } - } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithInterfaceTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithInterfaceTest.php index e49b47ec30..840022640a 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithInterfaceTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithInterfaceTest.php @@ -9,16 +9,17 @@ */ use Propel\Generator\Util\QuickBuilder; - -use Propel\Runtime\Propel; -use \Propel\Tests\TestCase; +use Propel\Tests\TestCase; class GeneratedObjectWithInterfaceTest extends TestCase { - public function setUp(): void - { - if (!class_exists('Foo\MyClassWithInterface')) { - $schema = << @@ -27,11 +28,14 @@ public function setUp(): void EOF; QuickBuilder::buildSchema($schema); - } - } + } + } - public function testClassHasInterface() - { - $this->assertInstanceOf('Foo\MyInterface', new \Foo\MyClassWithInterface()); - } + /** + * @return void + */ + public function testClassHasInterface() + { + $this->assertInstanceOf('Foo\MyInterface', new \Foo\MyClassWithInterface()); + } } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php index 25b2f9a035..012cc365ec 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php @@ -10,14 +10,20 @@ namespace Propel\Tests\Generator\Builder\Om; +use Map\StuffTableMap; use Propel\Generator\Util\QuickBuilder; use Propel\Tests\TestCase; +use Stuff; +use StuffQuery; /** * @author Kévin Gomez */ class GeneratedPKLessQueryBuilderTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (class_exists('Stuff')) { @@ -37,57 +43,69 @@ public function setUp(): void } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * @expectedExceptionMessage The Stuff object has no primary key + * @expectedException \Propel\Runtime\Exception\LogicException + * @expectedExceptionMessage The Stuff object has no primary key + * + * @return void */ public function testFindPkThrowsAnError() { - \StuffQuery::create()->findPk(42); + StuffQuery::create()->findPk(42); } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * @expectedExceptionMessage The Stuff object has no primary key + * @expectedException \Propel\Runtime\Exception\LogicException + * @expectedExceptionMessage The Stuff object has no primary key + * + * @return void */ public function testBuildPkeyCriteria() { - $stuff = new \Stuff(); + $stuff = new Stuff(); $stuff->buildPkeyCriteria(); } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * @expectedExceptionMessage The Stuff object has no primary key + * @expectedException \Propel\Runtime\Exception\LogicException + * @expectedExceptionMessage The Stuff object has no primary key + * + * @return void */ public function testTableMapDoDelete() { - \Map\StuffTableMap::doDelete([]); + StuffTableMap::doDelete([]); } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * @expectedExceptionMessage The Stuff object has no primary key + * @expectedException \Propel\Runtime\Exception\LogicException + * @expectedExceptionMessage The Stuff object has no primary key + * + * @return void */ public function testFindPksThrowsAnError() { - \StuffQuery::create()->findPks([42, 24]); + StuffQuery::create()->findPks([42, 24]); } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * @expectedExceptionMessage The Stuff object has no primary key + * @expectedException \Propel\Runtime\Exception\LogicException + * @expectedExceptionMessage The Stuff object has no primary key + * + * @return void */ public function testFilterByPrimaryKeyThrowsAnError() { - \StuffQuery::create()->filterByPrimaryKey(42); + StuffQuery::create()->filterByPrimaryKey(42); } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * @expectedExceptionMessage The Stuff object has no primary key + * @expectedException \Propel\Runtime\Exception\LogicException + * @expectedExceptionMessage The Stuff object has no primary key + * + * @return void */ public function testFilterByPrimaryKeysThrowsAnError() { - \StuffQuery::create()->filterByPrimaryKeys(42); + StuffQuery::create()->filterByPrimaryKeys(42); } } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessTableMapTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessTableMapTest.php index 555f5278d7..c96b134d70 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessTableMapTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessTableMapTest.php @@ -10,6 +10,7 @@ namespace Propel\Tests\Generator\Builder\Om; +use Map\StuffTableMap; use Propel\Generator\Util\QuickBuilder; use Propel\Tests\TestCase; @@ -18,6 +19,9 @@ */ class GeneratedPKLessTableMapTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (class_exists('Stuff')) { @@ -36,8 +40,11 @@ public function setUp(): void QuickBuilder::buildSchema($schema); } + /** + * @return void + */ public function testGetPrimaryKeyHashFromRowReturnsNull() { - $this->assertNull(\Map\StuffTableMap::getPrimaryKeyHashFromRow($row = [])); + $this->assertNull(StuffTableMap::getPrimaryKeyHashFromRow($row = [])); } } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryArrayColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryArrayColumnTypeTest.php index ab53e80f42..2514bc1ffc 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryArrayColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryArrayColumnTypeTest.php @@ -10,9 +10,10 @@ namespace Propel\Tests\Generator\Builder\Om; +use ComplexColumnTypeEntity11; +use ComplexColumnTypeEntity11Query; +use PHPUnit\Framework\TestCase; use Propel\Generator\Util\QuickBuilder; - -use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\Criteria; /** @@ -20,8 +21,11 @@ * * @author Francois Zaninotto */ -class GeneratedQueryArrayColumnTypeTest extends \PHPUnit\Framework\TestCase +class GeneratedQueryArrayColumnTypeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('\ComplexColumnTypeEntity11')) { @@ -35,20 +39,23 @@ public function setUp(): void EOF; QuickBuilder::buildSchema($schema); - $e0 = new \ComplexColumnTypeEntity11(); + $e0 = new ComplexColumnTypeEntity11(); $e0->save(); - $e1 = new \ComplexColumnTypeEntity11(); + $e1 = new ComplexColumnTypeEntity11(); $e1->setTags(['foo', 'bar', 'baz']); $e1->save(); - $e2 = new \ComplexColumnTypeEntity11(); + $e2 = new ComplexColumnTypeEntity11(); $e2->setTags(['bar']); $e2->save(); - $e3 = new \ComplexColumnTypeEntity11(); + $e3 = new ComplexColumnTypeEntity11(); $e3->setTags(['bar23']); $e3->save(); } } + /** + * @return void + */ public function testActiveQueryMethods() { $this->assertTrue(method_exists('\ComplexColumnTypeEntity11Query', 'filterByTags')); @@ -57,96 +64,111 @@ public function testActiveQueryMethods() $this->assertTrue(method_exists('\ComplexColumnTypeEntity11Query', 'filterByValueSet')); } + /** + * @return void + */ public function testColumnHydration() { - $e = \ComplexColumnTypeEntity11Query::create()->orderById()->offset(1)->findOne(); + $e = ComplexColumnTypeEntity11Query::create()->orderById()->offset(1)->findOne(); $this->assertEquals(['foo', 'bar', 'baz'], $e->getTags(), 'array columns are correctly hydrated'); } + /** + * @return void + */ public function testWhere() { - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->where('ComplexColumnTypeEntity11.Tags LIKE ?', '%| bar23 |%') ->find(); $this->assertEquals(1, $e->count()); $this->assertEquals(['bar23'], $e[0]->getTags(), 'array columns are searchable by serialized object using where()'); - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->where('ComplexColumnTypeEntity11.Tags = ?', ['bar23']) ->find(); $this->assertEquals(1, $e->count()); $this->assertEquals(['bar23'], $e[0]->getTags(), 'array columns are searchable by object using where()'); } + /** + * @return void + */ public function testFilterByColumn() { - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags(['bar']) ->orderById() ->find(); $this->assertEquals(['foo', 'bar', 'baz'], $e[0]->getTags(), 'array columns are searchable by element'); $this->assertEquals(['bar'], $e[1]->getTags(), 'array columns are searchable by element'); $this->assertEquals(2, $e->count(), 'array columns do not return false positives'); - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags(['bar23']) ->findOne(); $this->assertEquals(['bar23'], $e->getTags(), 'array columns are searchable by element'); } + /** + * @return void + */ public function testFilterByColumnUsingContainsAll() { - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags([], Criteria::CONTAINS_ALL) ->find(); $this->assertEquals(4, $e->count()); - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags(['bar'], Criteria::CONTAINS_ALL) ->orderById() ->find(); $this->assertEquals(2, $e->count()); $this->assertEquals(['foo', 'bar', 'baz'], $e[0]->getTags()); $this->assertEquals(['bar'], $e[1]->getTags()); - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags(['bar23'], Criteria::CONTAINS_ALL) ->find(); $this->assertEquals(1, $e->count()); $this->assertEquals(['bar23'], $e[0]->getTags()); - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags(['foo', 'bar'], Criteria::CONTAINS_ALL) ->find(); $this->assertEquals(1, $e->count()); $this->assertEquals(['foo', 'bar', 'baz'], $e[0]->getTags()); - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags(['foo', 'bar23'], Criteria::CONTAINS_ALL) ->find(); $this->assertEquals(0, $e->count()); } + /** + * @return void + */ public function testFilterByColumnUsingContainsSome() { - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags([], Criteria::CONTAINS_SOME) ->find(); $this->assertEquals(4, $e->count()); - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags(['bar'], Criteria::CONTAINS_SOME) ->orderById() ->find(); $this->assertEquals(2, $e->count()); $this->assertEquals(['foo', 'bar', 'baz'], $e[0]->getTags()); $this->assertEquals(['bar'], $e[1]->getTags()); - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags(['bar23'], Criteria::CONTAINS_SOME) ->find(); $this->assertEquals(1, $e->count()); $this->assertEquals(['bar23'], $e[0]->getTags()); - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags(['foo', 'bar'], Criteria::CONTAINS_SOME) ->orderById() ->find(); $this->assertEquals(2, $e->count()); $this->assertEquals(['foo', 'bar', 'baz'], $e[0]->getTags()); $this->assertEquals(['bar'], $e[1]->getTags()); - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags(['foo', 'bar23'], Criteria::CONTAINS_SOME) ->find(); $this->assertEquals(2, $e->count()); @@ -154,35 +176,38 @@ public function testFilterByColumnUsingContainsSome() $this->assertEquals(['bar23'], $e[1]->getTags()); } + /** + * @return void + */ public function testFilterByColumnUsingContainsNone() { - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags([], Criteria::CONTAINS_NONE) ->find(); $this->assertEquals(1, $e->count()); $this->assertEquals([], $e[0]->getTags()); - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags(['bar'], Criteria::CONTAINS_NONE) ->orderById() ->find(); $this->assertEquals(2, $e->count()); $this->assertEquals([], $e[0]->getTags()); $this->assertEquals(['bar23'], $e[1]->getTags()); - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags(['bar23'], Criteria::CONTAINS_NONE) ->find(); $this->assertEquals(3, $e->count()); $this->assertEquals([], $e[0]->getTags()); $this->assertEquals(['foo', 'bar', 'baz'], $e[1]->getTags()); $this->assertEquals(['bar'], $e[2]->getTags()); - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags(['foo', 'bar'], Criteria::CONTAINS_NONE) ->orderById() ->find(); $this->assertEquals(2, $e->count()); $this->assertEquals([], $e[0]->getTags()); $this->assertEquals(['bar23'], $e[1]->getTags()); - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTags(['foo', 'bar23'], Criteria::CONTAINS_NONE) ->find(); $this->assertEquals(2, $e->count()); @@ -190,24 +215,30 @@ public function testFilterByColumnUsingContainsNone() $this->assertEquals(['bar'], $e[1]->getTags()); } + /** + * @return void + */ public function testFilterBySingularColumn() { - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTag('bar') ->orderById() ->find(); $this->assertEquals(['foo', 'bar', 'baz'], $e[0]->getTags(), 'array columns are searchable by element'); $this->assertEquals(['bar'], $e[1]->getTags(), 'array columns are searchable by element'); $this->assertEquals(2, $e->count(), 'array columns do not return false positives'); - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTag('bar23') ->findOne(); $this->assertEquals(['bar23'], $e->getTags(), 'array columns are searchable by element'); } + /** + * @return void + */ public function testFilterBySingularColumnUsingContainsAll() { - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTag('bar', Criteria::CONTAINS_ALL) ->orderById() ->find(); @@ -216,9 +247,12 @@ public function testFilterBySingularColumnUsingContainsAll() $this->assertEquals(['bar'], $e[1]->getTags(), 'array columns are searchable by element using Criteria::CONTAINS_ALL'); } + /** + * @return void + */ public function testFilterBySingularColumnUsingContainsNone() { - $e = \ComplexColumnTypeEntity11Query::create() + $e = ComplexColumnTypeEntity11Query::create() ->filterByTag('bar', Criteria::CONTAINS_NONE) ->orderById() ->find(); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryDoDeleteTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryDoDeleteTest.php index c636f1a01b..729857307d 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryDoDeleteTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryDoDeleteTest.php @@ -10,33 +10,32 @@ namespace Propel\Tests\Generator\Builder\Om; -use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\Criteria; - +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\AuthorQuery; -use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\BookQuery; -use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\BookOpinion; +use Propel\Tests\Bookstore\BookQuery; use Propel\Tests\Bookstore\BookReader; use Propel\Tests\Bookstore\BookReaderQuery; -use Propel\Tests\Bookstore\Map\BookReaderTableMap; use Propel\Tests\Bookstore\Bookstore; use Propel\Tests\Bookstore\BookstoreContest; -use Propel\Tests\Bookstore\Map\BookstoreContestTableMap; use Propel\Tests\Bookstore\BookstoreContestEntry; use Propel\Tests\Bookstore\BookstoreContestEntryQuery; -use Propel\Tests\Bookstore\Customer; use Propel\Tests\Bookstore\Contest; +use Propel\Tests\Bookstore\Customer; +use Propel\Tests\Bookstore\Map\AuthorTableMap; +use Propel\Tests\Bookstore\Map\BookReaderTableMap; +use Propel\Tests\Bookstore\Map\BookstoreContestTableMap; +use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Bookstore\Map\PublisherTableMap; +use Propel\Tests\Bookstore\Map\ReaderFavoriteTableMap; use Propel\Tests\Bookstore\MediaQuery; use Propel\Tests\Bookstore\Publisher; use Propel\Tests\Bookstore\PublisherQuery; -use Propel\Tests\Bookstore\Map\PublisherTableMap; -use Propel\Tests\Bookstore\ReviewQuery; use Propel\Tests\Bookstore\ReaderFavorite; use Propel\Tests\Bookstore\ReaderFavoriteQuery; -use Propel\Tests\Bookstore\Map\ReaderFavoriteTableMap; +use Propel\Tests\Bookstore\ReviewQuery; use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; @@ -46,18 +45,21 @@ * This test uses generated Bookstore classes to test the behavior of various * query operations. * - * The database is reloaded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same - * for each test method in this class. See the BookstoreDataPopulator::populate() + * for each test method in this class. See the BookstoreDataPopulator::populate() * method for the exact contents of the database. * - * @see BookstoreDataPopulator + * @see BookstoreDataPopulator * @author Hans Lellelid * * @group database */ class GeneratedQueryDoDeleteTest extends BookstoreEmptyTestBase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -66,10 +68,12 @@ protected function setUp(): void /** * Test ability to delete multiple rows via single Criteria object. + * + * @return void */ public function testDoDelete_MultiTable() { - $hp = BookQuery::create()->filterByTitle("Harry Potter and the Order of the Phoenix")->findOne(); + $hp = BookQuery::create()->filterByTitle('Harry Potter and the Order of the Phoenix')->findOne(); // print "Attempting to delete [multi-table] by found pk: "; $c = new Criteria(); @@ -83,21 +87,23 @@ public function testDoDelete_MultiTable() BookTableMap::doDelete($c); // check to make sure the right # of records was removed - $this->assertCount(3, AuthorQuery::create()->find(), "Expected 3 authors after deleting."); - $this->assertCount(3, PublisherQuery::create()->find(), "Expected 3 publishers after deleting."); - $this->assertCount(3, BookQuery::create()->find(), "Expected 3 books after deleting."); + $this->assertCount(3, AuthorQuery::create()->find(), 'Expected 3 authors after deleting.'); + $this->assertCount(3, PublisherQuery::create()->find(), 'Expected 3 publishers after deleting.'); + $this->assertCount(3, BookQuery::create()->find(), 'Expected 3 books after deleting.'); } /** * Test using a complex criteria to delete multiple rows from a single table. + * + * @return void */ public function testDoDelete_ComplexCriteria() { //print "Attempting to delete books by complex criteria: "; $c = new Criteria(); - $cn = $c->getNewCriterion(BookTableMap::COL_ISBN, "043935806X"); - $cn->addOr($c->getNewCriterion(BookTableMap::COL_ISBN, "0380977427")); - $cn->addOr($c->getNewCriterion(BookTableMap::COL_ISBN, "0140422161")); + $cn = $c->getNewCriterion(BookTableMap::COL_ISBN, '043935806X'); + $cn->addOr($c->getNewCriterion(BookTableMap::COL_ISBN, '0380977427')); + $cn->addOr($c->getNewCriterion(BookTableMap::COL_ISBN, '0140422161')); $c->add($cn); BookTableMap::doDelete($c); @@ -105,16 +111,17 @@ public function testDoDelete_ComplexCriteria() $books = BookQuery::create()->find(); - $this->assertEquals(1, count($books), "Expected 1 book remaining after deleting."); - $this->assertEquals("The Tin Drum", $books[0]->getTitle(), "Expect the only remaining book to be 'The Tin Drum'"); + $this->assertEquals(1, count($books), 'Expected 1 book remaining after deleting.'); + $this->assertEquals('The Tin Drum', $books[0]->getTitle(), "Expect the only remaining book to be 'The Tin Drum'"); } /** * Test that cascading deletes are happening correctly (whether emulated or native). + * + * @return void */ public function testDoDelete_Cascade_Simple() { - // The 'media' table will cascade from book deletes // 1) Assert the row exists right now @@ -132,37 +139,38 @@ public function testDoDelete_Cascade_Simple() // 3) Assert that the media row is now also gone $obj = MediaQuery::create()->findPk($mediaId); - $this->assertNull($obj, "Expect NULL when retrieving on no matching Media."); - + $this->assertNull($obj, 'Expect NULL when retrieving on no matching Media.'); } /** * Test that cascading deletes are happening correctly for composite pk. - * @link http://propel.phpdb.org/trac/ticket/544 + * + * @link http://propel.phpdb.org/trac/ticket/544 + * + * @return void */ public function testDoDelete_Cascade_CompositePK() { - $origBceCount = BookstoreContestEntryQuery::create()->count(); $cust1 = new Customer(); - $cust1->setName("Cust1"); + $cust1->setName('Cust1'); $cust1->save(); $cust2 = new Customer(); - $cust2->setName("Cust2"); + $cust2->setName('Cust2'); $cust2->save(); $c1 = new Contest(); - $c1->setName("Contest1"); + $c1->setName('Contest1'); $c1->save(); $c2 = new Contest(); - $c2->setName("Contest2"); + $c2->setName('Contest2'); $c2->save(); $store1 = new Bookstore(); - $store1->setStoreName("Store1"); + $store1->setStoreName('Store1'); $store1->save(); $bc1 = new BookstoreContest(); @@ -176,13 +184,13 @@ public function testDoDelete_Cascade_CompositePK() $bc2->save(); $bce1 = new BookstoreContestEntry(); - $bce1->setEntryDate("now"); + $bce1->setEntryDate('now'); $bce1->setCustomer($cust1); $bce1->setBookstoreContest($bc1); $bce1->save(); $bce2 = new BookstoreContestEntry(); - $bce2->setEntryDate("now"); + $bce2->setEntryDate('now'); $bce2->setCustomer($cust1); $bce2->setBookstoreContest($bc2); $bce2->save(); @@ -193,18 +201,19 @@ public function testDoDelete_Cascade_CompositePK() $newCount = BookstoreContestEntryQuery::create()->count(); - $this->assertEquals($origBceCount + 1, $newCount, "Expected new number of rows in BCE to be orig + 1"); + $this->assertEquals($origBceCount + 1, $newCount, 'Expected new number of rows in BCE to be orig + 1'); $bcetest = BookstoreContestEntryQuery::create()->findPk([$store1->getId(), $c1->getId(), $cust1->getId()]); - $this->assertNull($bcetest, "Expected BCE for store1 to be cascade deleted."); + $this->assertNull($bcetest, 'Expected BCE for store1 to be cascade deleted.'); $bcetest2 = BookstoreContestEntryQuery::create()->findPk([$store1->getId(), $c2->getId(), $cust1->getId()]); - $this->assertNotNull($bcetest2, "Expected BCE for store2 to NOT be cascade deleted."); - + $this->assertNotNull($bcetest2, 'Expected BCE for store2 to NOT be cascade deleted.'); } /** * Test that onDelete="SETNULL" is happening correctly (whether emulated or native). + * + * @return void */ public function testDoDelete_SetNull() { @@ -222,12 +231,13 @@ public function testDoDelete_SetNull() // 3) Assert that the book.author_id column is now NULL $book = BookQuery::create()->findPk($bookId); - $this->assertNull($book->getAuthorId(), "Expect the book.author_id to be NULL after the author was removed."); - + $this->assertNull($book->getAuthorId(), 'Expect the book.author_id to be NULL after the author was removed.'); } /** * Test deleting a row by passing in the primary key to the doDelete() method. + * + * @return void */ public function testDoDelete_ByPK() { @@ -240,10 +250,12 @@ public function testDoDelete_ByPK() // 3) now make sure it's gone $obj = BookQuery::create()->findPk($bookId); - $this->assertNull($obj, "Expect NULL when retrieving on no matching Book."); - + $this->assertNull($obj, 'Expect NULL when retrieving on no matching Book.'); } + /** + * @return void + */ public function testDoDelete_ByPks() { // 1) get all of the books @@ -261,11 +273,13 @@ public function testDoDelete_ByPks() BookTableMap::doDelete([$book1->getId(), $book2->getId()]); // 5) we should have two less books than before - $this->assertEquals($bookCount-2, BookQuery::create()->count(), 'Two books deleted successfully.'); + $this->assertEquals($bookCount - 2, BookQuery::create()->count(), 'Two books deleted successfully.'); } /** * Test deleting a row by passing the generated object to doDelete(). + * + * @return void */ public function testDoDelete_ByObj() { @@ -278,21 +292,24 @@ public function testDoDelete_ByObj() // 3) now make sure it's gone $obj = BookQuery::create()->findPk($bookId); - $this->assertNull($obj, "Expect NULL when retrieving on no matching Book."); - + $this->assertNull($obj, 'Expect NULL when retrieving on no matching Book.'); } /** * Test the doDeleteAll() method for single table. + * + * @return void */ public function testDoDeleteAll() { BookTableMap::doDeleteAll(); - $this->assertCount(0, BookQuery::create()->find(), "Expect all book rows to have been deleted."); + $this->assertCount(0, BookQuery::create()->find(), 'Expect all book rows to have been deleted.'); } /** * Test the state of the instance pool after a doDeleteAll() call. + * + * @return void */ public function testDoDeleteAllInstancePool() { @@ -305,16 +322,20 @@ public function testDoDeleteAllInstancePool() /** * Test the doDeleteAll() method when onDelete="CASCADE". + * + * @return void */ public function testDoDeleteAll_Cascade() { BookTableMap::doDeleteAll(); - $this->assertCount(0, MediaQuery::create()->find(), "Expect all media rows to have been cascade deleted."); - $this->assertCount(0, ReviewQuery::create()->find(), "Expect all review rows to have been cascade deleted."); + $this->assertCount(0, MediaQuery::create()->find(), 'Expect all media rows to have been cascade deleted.'); + $this->assertCount(0, ReviewQuery::create()->find(), 'Expect all review rows to have been cascade deleted.'); } /** * Test the doDeleteAll() method when onDelete="SETNULL". + * + * @return void */ public function testDoDeleteAll_SetNull() { @@ -322,17 +343,19 @@ public function testDoDeleteAll_SetNull() $c->add(BookTableMap::COL_AUTHOR_ID, null, Criteria::NOT_EQUAL); // 1) make sure there are some books with valid authors - $this->assertGreaterThan(0, count(BookQuery::create()->filterByAuthorId(null, Criteria::NOT_EQUAL)->find()) > 0, "Expect some book.author_id columns that are not NULL."); + $this->assertGreaterThan(0, count(BookQuery::create()->filterByAuthorId(null, Criteria::NOT_EQUAL)->find()) > 0, 'Expect some book.author_id columns that are not NULL.'); // 2) delete all the authors AuthorTableMap::doDeleteAll(); // 3) now verify that the book.author_id columns are all null - $this->assertCount(0, BookQuery::create()->filterByAuthorId(null, Criteria::NOT_EQUAL)->find(), "Expect all book.author_id columns to be NULL."); + $this->assertCount(0, BookQuery::create()->filterByAuthorId(null, Criteria::NOT_EQUAL)->find(), 'Expect all book.author_id columns to be NULL.'); } /** - * @link http://propel.phpdb.org/trac/ticket/519 + * @link http://propel.phpdb.org/trac/ticket/519 + * + * @return void */ public function testDoDeleteCompositePK() { @@ -348,8 +371,8 @@ public function testDoDeleteCompositePK() $this->createReaderWithId(1); $this->createReaderWithId(2); - for ($i=1; $i <= 3; $i++) { - for ($j=1; $j <= 2; $j++) { + for ($i = 1; $i <= 3; $i++) { + for ($j = 1; $j <= 2; $j++) { $bo = new BookOpinion(); $bo->setBookId($i); $bo->setReaderId($j); @@ -366,66 +389,72 @@ public function testDoDeleteCompositePK() // Now delete 2 of those rows (2 is special in that it is the number of rows // being deleted, as well as the number of things in the primary key) - ReaderFavoriteTableMap::doDelete([[1,1], [2,2]]); + ReaderFavoriteTableMap::doDelete([[1, 1], [2, 2]]); $this->assertEquals(4, ReaderFavoriteQuery::create()->count()); //Note: these composite PK's are pairs of (BookId, ReaderId) - $this->assertNotNull(ReaderFavoriteQuery::create()->findPk([2,1])); - $this->assertNotNull(ReaderFavoriteQuery::create()->findPk([1,2])); - $this->assertNotNull(ReaderFavoriteQuery::create()->findPk([3,1])); - $this->assertNotNull(ReaderFavoriteQuery::create()->findPk([3,2])); - $this->assertNull(ReaderFavoriteQuery::create()->findPk([1,1])); - $this->assertNull(ReaderFavoriteQuery::create()->findPk([2,2])); + $this->assertNotNull(ReaderFavoriteQuery::create()->findPk([2, 1])); + $this->assertNotNull(ReaderFavoriteQuery::create()->findPk([1, 2])); + $this->assertNotNull(ReaderFavoriteQuery::create()->findPk([3, 1])); + $this->assertNotNull(ReaderFavoriteQuery::create()->findPk([3, 2])); + $this->assertNull(ReaderFavoriteQuery::create()->findPk([1, 1])); + $this->assertNull(ReaderFavoriteQuery::create()->findPk([2, 2])); //test deletion of a single composite PK - ReaderFavoriteTableMap::doDelete([3,1]); + ReaderFavoriteTableMap::doDelete([3, 1]); $this->assertEquals(3, ReaderFavoriteQuery::create()->count()); - $this->assertNotNull(ReaderFavoriteQuery::create()->findPk([2,1])); - $this->assertNotNull(ReaderFavoriteQuery::create()->findPk([1,2])); - $this->assertNotNull(ReaderFavoriteQuery::create()->findPk([3,2])); - $this->assertNull(ReaderFavoriteQuery::create()->findPk([1,1])); - $this->assertNull(ReaderFavoriteQuery::create()->findPk([2,2])); - $this->assertNull(ReaderFavoriteQuery::create()->findPk([3,1])); + $this->assertNotNull(ReaderFavoriteQuery::create()->findPk([2, 1])); + $this->assertNotNull(ReaderFavoriteQuery::create()->findPk([1, 2])); + $this->assertNotNull(ReaderFavoriteQuery::create()->findPk([3, 2])); + $this->assertNull(ReaderFavoriteQuery::create()->findPk([1, 1])); + $this->assertNull(ReaderFavoriteQuery::create()->findPk([2, 2])); + $this->assertNull(ReaderFavoriteQuery::create()->findPk([3, 1])); //test deleting the last three - ReaderFavoriteTableMap::doDelete([[2,1], [1,2], [3,2]]); + ReaderFavoriteTableMap::doDelete([[2, 1], [1, 2], [3, 2]]); $this->assertEquals(0, ReaderFavoriteQuery::create()->count()); } /** * Test the doInsert() method when passed a Criteria object. + * + * @return void */ public function testDoInsert_Criteria() { - $name = "A Sample Publisher - " . time(); + $name = 'A Sample Publisher - ' . time(); $values = new Criteria(); $values->add(PublisherTableMap::COL_NAME, $name); PublisherTableMap::doInsert($values); $matches = PublisherQuery::create()->filterByName($name)->find(); - $this->assertCount(1, $matches, "Expect there to be exactly 1 publisher just-inserted."); - $this->assertTrue( 1 != $matches[0]->getId(), "Expected to have different ID than one put in values Criteria."); + $this->assertCount(1, $matches, 'Expect there to be exactly 1 publisher just-inserted.'); + $this->assertTrue(1 != $matches[0]->getId(), 'Expected to have different ID than one put in values Criteria.'); } /** * Test the doInsert() method when passed a generated object. + * + * @return void */ public function testDoInsert_Obj() { - $name = "A Sample Publisher - " . time(); + $name = 'A Sample Publisher - ' . time(); $values = new Publisher(); $values->setName($name); PublisherTableMap::doInsert($values); $matches = PublisherQuery::create()->filterByName($name)->find(); - $this->assertCount(1, $matches, "Expect there to be exactly 1 publisher just-inserted."); - $this->assertTrue( 1 != $matches[0]->getId(), "Expected to have different ID than one put in values Criteria."); + $this->assertCount(1, $matches, 'Expect there to be exactly 1 publisher just-inserted.'); + $this->assertTrue(1 != $matches[0]->getId(), 'Expected to have different ID than one put in values Criteria.'); } /** * Test passing null values to removeInstanceFromPool(). + * + * @return void */ public function testRemoveInstanceFromPool_Null() { @@ -433,12 +462,14 @@ public function testRemoveInstanceFromPool_Null() try { BookTableMap::removeInstanceFromPool(null); } catch (Exception $x) { - $this->fail("Expected to get no exception when removing an instance from the pool."); + $this->fail('Expected to get no exception when removing an instance from the pool.'); } } /** * @see testDoDeleteCompositePK() + * + * @return void */ private function createBookWithId($id) { @@ -448,7 +479,7 @@ private function createBookWithId($id) $b = new Book(); $b->setTitle("Book$id")->setISBN("BookISBN$id")->save(); $b1Id = $b->getId(); - $sql = "UPDATE " . BookTableMap::TABLE_NAME . " SET id = ? WHERE id = ?"; + $sql = 'UPDATE ' . BookTableMap::TABLE_NAME . ' SET id = ? WHERE id = ?'; $stmt = $con->prepare($sql); $stmt->bindValue(1, $id); $stmt->bindValue(2, $b1Id); @@ -458,6 +489,8 @@ private function createBookWithId($id) /** * @see testDoDeleteCompositePK() + * + * @return void */ private function createReaderWithId($id) { @@ -465,9 +498,9 @@ private function createReaderWithId($id) $r = BookReaderQuery::create()->findPk($id); if (!$r) { $r = new BookReader(); - $r->setName('Reader'.$id)->save(); + $r->setName('Reader' . $id)->save(); $r1Id = $r->getId(); - $sql = "UPDATE " . BookReaderTableMap::TABLE_NAME . " SET id = ? WHERE id = ?"; + $sql = 'UPDATE ' . BookReaderTableMap::TABLE_NAME . ' SET id = ? WHERE id = ?'; $stmt = $con->prepare($sql); $stmt->bindValue(1, $id); $stmt->bindValue(2, $r1Id); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryDoSelectTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryDoSelectTest.php index 9fb6baf8e1..beeaba72f4 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryDoSelectTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryDoSelectTest.php @@ -10,39 +10,37 @@ namespace Propel\Tests\Generator\Builder\Om; -use Propel\Tests\Bookstore\BookstoreEmployeeAccountQuery; - -use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Map\TableMap; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\AcctAccessRole; -use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\AuthorQuery; use Propel\Tests\Bookstore\Book; +use Propel\Tests\Bookstore\BookOpinion; use Propel\Tests\Bookstore\BookQuery; -use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Bookstore\BookReader; use Propel\Tests\Bookstore\Bookstore; -use Propel\Tests\Bookstore\BookstoreEmployee; -use Propel\Tests\Bookstore\BookstoreEmployeeQuery; -use Propel\Tests\Bookstore\Map\BookstoreEmployeeTableMap; -use Propel\Tests\Bookstore\BookstoreEmployeeAccount; -use Propel\Tests\Bookstore\Map\BookstoreEmployeeAccountTableMap; use Propel\Tests\Bookstore\BookstoreCashier; -use Propel\Tests\Bookstore\BookstoreManager; -use Propel\Tests\Bookstore\BookOpinion; -use Propel\Tests\Bookstore\BookReader; use Propel\Tests\Bookstore\BookstoreContest; -use Propel\Tests\Bookstore\Map\BookstoreContestTableMap; use Propel\Tests\Bookstore\BookstoreContestEntry; use Propel\Tests\Bookstore\BookstoreContestEntryQuery; -use Propel\Tests\Bookstore\Map\BookstoreContestEntryTableMap; +use Propel\Tests\Bookstore\BookstoreEmployee; +use Propel\Tests\Bookstore\BookstoreEmployeeAccount; +use Propel\Tests\Bookstore\BookstoreEmployeeAccountQuery; +use Propel\Tests\Bookstore\BookstoreEmployeeQuery; +use Propel\Tests\Bookstore\BookstoreManager; use Propel\Tests\Bookstore\Contest; use Propel\Tests\Bookstore\Customer; +use Propel\Tests\Bookstore\Map\BookstoreContestEntryTableMap; +use Propel\Tests\Bookstore\Map\BookstoreContestTableMap; +use Propel\Tests\Bookstore\Map\BookstoreEmployeeAccountTableMap; +use Propel\Tests\Bookstore\Map\BookstoreEmployeeTableMap; +use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Bookstore\Map\ReaderFavoriteTableMap; use Propel\Tests\Bookstore\ReaderFavorite; use Propel\Tests\Bookstore\ReaderFavoriteQuery; -use Propel\Tests\Bookstore\Map\ReaderFavoriteTableMap; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Tests the generated Query classes. @@ -50,16 +48,19 @@ * This test uses generated Bookstore classes to test the behavior of various * query operations. * - * The database is reloaded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same - * for each test method in this class. See the BookstoreDataPopulator::populate() + * for each test method in this class. See the BookstoreDataPopulator::populate() * method for the exact contents of the database. * - * @see BookstoreDataPopulator + * @see BookstoreDataPopulator * @author Hans Lellelid */ class GeneratedQueryDoSelectTest extends BookstoreEmptyTestBase { + /** + * @return void + */ protected function setUp(): void { $this->markTestSkipped('not used anymore look if all tests are present in Query'); @@ -67,6 +68,9 @@ protected function setUp(): void BookstoreDataPopulator::populate(); } + /** + * @return void + */ public function testDoSelect() { $books = BookQuery::create()->doSelect(new Criteria()); @@ -92,13 +96,15 @@ public function testDoSelect() /** * Tests performing doSelect() and doSelectJoin() using LIMITs. + * + * @return void */ public function testDoSelect_Limit() { // 1) get the total number of items in a particular table $count = BookQuery::create()->count(); - $this->assertTrue($count > 1, "Need more than 1 record in books table to perform this test."); + $this->assertTrue($count > 1, 'Need more than 1 record in books table to perform this test.'); $limitcount = $count - 1; @@ -115,15 +121,15 @@ public function testDoSelect_Limit() $results2 = BookQuery::create(null, $lc2)->joinWith('Author')->find(); $this->assertEquals($limitcount, count($results2), "Expected $limitcount results from BookQuery::doSelectJoinAuthor()"); - } /** * Test the basic functionality of the doSelectJoin*() methods. + * + * @return void */ public function testDoSelectJoin() { - BookTableMap::clearInstancePool(); $c = new Criteria(); @@ -139,13 +145,16 @@ public function testDoSelectJoin() $obj2Array = $obj2->toArray(TableMap::TYPE_PHPNAME, true, [], true); // $joinSize = strlen(serialize($obj2)); - $this->assertEquals(count($books), count($joinBooks), "Expected to find same number of rows in doSelectJoin*() call as doSelect() call."); + $this->assertEquals(count($books), count($joinBooks), 'Expected to find same number of rows in doSelectJoin*() call as doSelect() call.'); // $this->assertTrue($joinSize > $size, "Expected a serialized join object to be larger than a non-join object."); $this->assertTrue(array_key_exists('Author', $obj2Array)); } + /** + * @return void + */ public function testObjectInstances() { $sample = BookQuery::create()->findOne(); @@ -158,13 +167,13 @@ public function testObjectInstances() $sampleval = md5(microtime()); - $this->assertTrue($b1 === $b2, "Expected object instances to match for calls with same retrieveByPK() method signature."); + $this->assertTrue($b1 === $b2, 'Expected object instances to match for calls with same retrieveByPK() method signature.'); // 2) make sure that calls to doSelect also return references to the same objects. $allbooks = BookQuery::create()->doSelect(new Criteria()); foreach ($allbooks as $testb) { if ($testb->getPrimaryKey() == $b1->getPrimaryKey()) { - $this->assertTrue($testb === $b1, "Expected same object instance from doSelect() as from retrieveByPK()"); + $this->assertTrue($testb === $b1, 'Expected same object instance from doSelect() as from retrieveByPK()'); } } @@ -175,53 +184,54 @@ public function testObjectInstances() $author = AuthorQuery::create()->findPk($bookauthor->getId()); - $this->assertTrue($bookauthor === $author, "Expected same object instance when calling fk object accessor as retrieveByPK()"); + $this->assertTrue($bookauthor === $author, 'Expected same object instance when calling fk object accessor as retrieveByPK()'); // 4) test a doSelectJoin() $morebooks = BookQuery::create()->joinWith('Author')->find(); - for ($i=0,$j=0; $j < count($morebooks); $i++, $j++) { + for ($i = 0, $j = 0; $j < count($morebooks); $i++, $j++) { $testb1 = $allbooks[$i]; $testb2 = $allbooks[$j]; - $this->assertTrue($testb1 === $testb2, "Expected the same objects from consecutive doSelect() calls."); + $this->assertTrue($testb1 === $testb2, 'Expected the same objects from consecutive doSelect() calls.'); // we could probably also test this by just verifying that $book & $testb are the same if ($testb1->getPrimaryKey() === $book) { - $this->assertTrue($book->getAuthor() === $testb1->getAuthor(), "Expected same author object in calls to pkey-matching books."); + $this->assertTrue($book->getAuthor() === $testb1->getAuthor(), 'Expected same author object in calls to pkey-matching books.'); } } // 5) test creating a new object, saving it, and then retrieving that object (should all be same instance) $b = new BookstoreEmployee(); - $b->setName("Testing"); - $b->setJobTitle("Testing"); + $b->setName('Testing'); + $b->setJobTitle('Testing'); $b->save(); $empId = $b->getId(); - $this->assertSame($b, BookstoreEmployeeQuery::create()->findPk($empId), "Expected newly saved object to be same instance as pooled."); - + $this->assertSame($b, BookstoreEmployeeQuery::create()->findPk($empId), 'Expected newly saved object to be same instance as pooled.'); } /** * Test inheritance features. + * + * @return void */ public function testInheritance() { $manager = new BookstoreManager(); - $manager->setName("Manager 1"); - $manager->setJobTitle("Warehouse Manager"); + $manager->setName('Manager 1'); + $manager->setJobTitle('Warehouse Manager'); $manager->save(); $managerId = $manager->getId(); $employee = new BookstoreEmployee(); - $employee->setName("Employee 1"); - $employee->setJobTitle("Janitor"); + $employee->setName('Employee 1'); + $employee->setJobTitle('Janitor'); $employee->setSupervisorId($managerId); $employee->save(); $empId = $employee->getId(); $cashier = new BookstoreCashier(); - $cashier->setName("Cashier 1"); - $cashier->setJobTitle("Cashier"); + $cashier->setName('Cashier 1'); + $cashier->setJobTitle('Cashier'); $cashier->save(); $cashierId = $cashier->getId(); @@ -232,9 +242,9 @@ public function testInheritance() $objects = BookstoreEmployeeQuery::create()->doSelect($c); - $this->assertEquals(3, count($objects), "Expected 3 objects to be returned."); + $this->assertEquals(3, count($objects), 'Expected 3 objects to be returned.'); - list($o1, $o2, $o3) = $objects; + [$o1, $o2, $o3] = $objects; $this->assertSame($o1, $manager); $this->assertSame($o2, $employee); @@ -243,17 +253,19 @@ public function testInheritance() // 2) test a forced reload from database BookstoreEmployeeTableMap::clearInstancePool(); - list($o1,$o2,$o3) = BookstoreEmployeeQuery::create()->doSelect($c); - - $this->assertTrue($o1 instanceof BookstoreManager, "Expected BookstoreManager object, got " . get_class($o1)); - $this->assertTrue($o2 instanceof BookstoreEmployee, "Expected BookstoreEmployee object, got " . get_class($o2)); - $this->assertTrue($o3 instanceof BookstoreCashier, "Expected BookstoreCashier object, got " . get_class($o3)); + [$o1, $o2, $o3] = BookstoreEmployeeQuery::create()->doSelect($c); + $this->assertTrue($o1 instanceof BookstoreManager, 'Expected BookstoreManager object, got ' . get_class($o1)); + $this->assertTrue($o2 instanceof BookstoreEmployee, 'Expected BookstoreEmployee object, got ' . get_class($o2)); + $this->assertTrue($o3 instanceof BookstoreCashier, 'Expected BookstoreCashier object, got ' . get_class($o3)); } /** * Test hydration of joined rows that contain lazy load columns. - * @link http://propel.phpdb.org/trac/ticket/464 + * + * @link http://propel.phpdb.org/trac/ticket/464 + * + * @return void */ public function testHydrationJoinLazyLoad() { @@ -262,18 +274,18 @@ public function testHydrationJoinLazyLoad() AcctAccessRoleTableMap::doDeleteAll(); $bemp2 = new BookstoreEmployee(); - $bemp2->setName("Pieter"); - $bemp2->setJobTitle("Clerk"); + $bemp2->setName('Pieter'); + $bemp2->setJobTitle('Clerk'); $bemp2->save(); $role = new AcctAccessRole(); - $role->setName("Admin"); + $role->setName('Admin'); $bempacct = new BookstoreEmployeeAccount(); $bempacct->setBookstoreEmployee($bemp2); $bempacct->setAcctAccessRole($role); - $bempacct->setLogin("john"); - $bempacct->setPassword("johnp4ss"); + $bempacct->setLogin('john'); + $bempacct->setPassword('johnp4ss'); $bempacct->save(); $results = BookstoreEmployeeAccountQuery::create()->find(); @@ -284,7 +296,10 @@ public function testHydrationJoinLazyLoad() /** * Testing foreign keys with multiple referrer columns. - * @link http://propel.phpdb.org/trac/ticket/606 + * + * @link http://propel.phpdb.org/trac/ticket/606 + * + * @return void */ public function testMultiColFk() { @@ -293,12 +308,12 @@ public function testMultiColFk() ReaderFavoriteTableMap::doDeleteAll(); $b1 = new Book(); - $b1->setTitle("Book1"); - $b1->setISBN("ISBN-1"); + $b1->setTitle('Book1'); + $b1->setISBN('ISBN-1'); $b1->save(); $r1 = new BookReader(); - $r1-> setName("Me"); + $r1->setName('Me'); $r1->save(); $bo1 = new BookOpinion(); @@ -318,12 +333,15 @@ public function testMultiColFk() $c->add(ReaderFavoriteTableMap::READER_ID, $r1->getId()); $results = ReaderFavoriteQuery::create(null, $c)->joinWith('BookOpinion')->find(); - $this->assertEquals(1, count($results), "Expected 1 result"); + $this->assertEquals(1, count($results), 'Expected 1 result'); } /** * Testing foreign keys with multiple referrer columns. - * @link http://propel.phpdb.org/trac/ticket/606 + * + * @link http://propel.phpdb.org/trac/ticket/606 + * + * @return void */ public function testMultiColJoin() { @@ -331,34 +349,34 @@ public function testMultiColJoin() BookstoreContestEntryTableMap::doDeleteAll(); $bs = new Bookstore(); - $bs->setStoreName("Test1"); + $bs->setStoreName('Test1'); $bs->setPopulationServed(5); $bs->save(); $bs1Id = $bs->getId(); $bs2 = new Bookstore(); - $bs2->setStoreName("Test2"); + $bs2->setStoreName('Test2'); $bs2->setPopulationServed(5); $bs2->save(); $bs2Id = $bs2->getId(); $ct1 = new Contest(); - $ct1->setName("Contest1!"); + $ct1->setName('Contest1!'); $ct1->save(); $ct1Id = $ct1->getId(); $ct2 = new Contest(); - $ct2->setName("Contest2!"); + $ct2->setName('Contest2!'); $ct2->save(); $ct2Id = $ct2->getId(); $cmr = new Customer(); - $cmr->setName("Customer1"); + $cmr->setName('Customer1'); $cmr->save(); $cmr1Id = $cmr->getId(); $cmr2 = new Customer(); - $cmr2->setName("Customer2"); + $cmr2->setName('Customer2'); $cmr2->save(); $cmr2Id = $cmr2->getId(); @@ -399,13 +417,13 @@ public function testMultiColJoin() */ $c = new Criteria(); - $c->addJoin([BookstoreContestEntryTableMap::BOOKSTORE_ID, BookstoreContestEntryTableMap::CONTEST_ID], [BookstoreContestTableMap::BOOKSTORE_ID, BookstoreContestTableMap::CONTEST_ID] ); + $c->addJoin([BookstoreContestEntryTableMap::BOOKSTORE_ID, BookstoreContestEntryTableMap::CONTEST_ID], [BookstoreContestTableMap::BOOKSTORE_ID, BookstoreContestTableMap::CONTEST_ID]); $results = BookstoreContestEntryQuery::create(null, $c)->find(); - $this->assertEquals(2, count($results) ); + $this->assertEquals(2, count($results)); foreach ($results as $result) { - $this->assertEquals($bs1Id, $result->getBookstoreId() ); - $this->assertEquals($ct1Id, $result->getContestId() ); + $this->assertEquals($bs1Id, $result->getBookstoreId()); + $this->assertEquals($ct1Id, $result->getContestId()); } } } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryEnumColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryEnumColumnTypeTest.php index a5f43c8c54..e7c50d9cb2 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryEnumColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryEnumColumnTypeTest.php @@ -10,9 +10,10 @@ namespace Propel\Tests\Generator\Builder\Om; +use ComplexColumnTypeEntity13; +use ComplexColumnTypeEntity13Query; +use Map\ComplexColumnTypeEntity13TableMap; use Propel\Generator\Util\QuickBuilder; - -use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Tests\TestCase; @@ -23,6 +24,9 @@ */ class GeneratedQueryEnumColumnTypeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('\ComplexColumnTypeEntity13')) { @@ -36,59 +40,68 @@ public function setUp(): void EOF; QuickBuilder::buildSchema($schema); - $e0 = new \ComplexColumnTypeEntity13(); + $e0 = new ComplexColumnTypeEntity13(); $e0->save(); - $e1 = new \ComplexColumnTypeEntity13(); + $e1 = new ComplexColumnTypeEntity13(); $e1->setBar('baz'); $e1->save(); - $e2 = new \ComplexColumnTypeEntity13(); + $e2 = new ComplexColumnTypeEntity13(); $e2->setBar('4'); $e2->save(); - \Map\ComplexColumnTypeEntity13TableMap::clearInstancePool(); + ComplexColumnTypeEntity13TableMap::clearInstancePool(); } } + /** + * @return void + */ public function testColumnHydration() { - $e = \ComplexColumnTypeEntity13Query::create() + $e = ComplexColumnTypeEntity13Query::create() ->orderById() ->offset(1) ->findOne(); $this->assertEquals('baz', $e->getBar(), 'enum columns are correctly hydrated'); } + /** + * @return void + */ public function testWhere() { - $e = \ComplexColumnTypeEntity13Query::create() + $e = ComplexColumnTypeEntity13Query::create() ->where('ComplexColumnTypeEntity13.Bar = ?', 'baz') ->find(); $this->assertEquals(1, $e->count(), 'object columns are searchable by enumerated value using where()'); $this->assertEquals('baz', $e[0]->getBar(), 'object columns are searchable by enumerated value using where()'); - $e = \ComplexColumnTypeEntity13Query::create() + $e = ComplexColumnTypeEntity13Query::create() ->where('ComplexColumnTypeEntity13.Bar IN ?', ['baz', 4]) ->find(); $this->assertEquals(2, $e->count(), 'object columns are searchable by enumerated value using where()'); } + /** + * @return void + */ public function testFilterByColumn() { - $e = \ComplexColumnTypeEntity13Query::create() + $e = ComplexColumnTypeEntity13Query::create() ->filterByBar('4') ->findOne(); $this->assertEquals('4', $e->getBar(), 'enum columns are searchable by enumerated value'); - $e = \ComplexColumnTypeEntity13Query::create() + $e = ComplexColumnTypeEntity13Query::create() ->filterByBar('baz') ->findOne(); $this->assertEquals('baz', $e->getBar(), 'enum columns are searchable by enumerated value'); - $e = \ComplexColumnTypeEntity13Query::create() + $e = ComplexColumnTypeEntity13Query::create() ->filterByBar('baz', Criteria::NOT_EQUAL) ->findOne(); $this->assertEquals('4', $e->getBar(), 'enum columns are searchable by enumerated value'); - $nb = \ComplexColumnTypeEntity13Query::create() + $nb = ComplexColumnTypeEntity13Query::create() ->filterByBar(['baz', '4'], Criteria::IN) ->count(); $this->assertEquals(2, $nb, 'enum columns are searchable by enumerated value'); - $nb = \ComplexColumnTypeEntity13Query::create() + $nb = ComplexColumnTypeEntity13Query::create() ->filterByBar(['baz', '4']) ->count(); $this->assertEquals(2, $nb, 'enum columns filters default to Criteria IN when passed an array'); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryObjectColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryObjectColumnTypeTest.php index 242f5274dd..eccecc39dc 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryObjectColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryObjectColumnTypeTest.php @@ -10,9 +10,11 @@ namespace Propel\Tests\Generator\Builder\Om; +use ComplexColumnTypeEntity10; +use ComplexColumnTypeEntity10Query; +use Map\ComplexColumnTypeEntity10TableMap; +use PHPUnit\Framework\TestCase; use Propel\Generator\Util\QuickBuilder; - -use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\Criteria; /** @@ -20,10 +22,13 @@ * * @author Francois Zaninotto */ -class GeneratedQueryObjectColumnTypeTest extends \PHPUnit\Framework\TestCase +class GeneratedQueryObjectColumnTypeTest extends TestCase { protected $c1, $c2; + /** + * @return void + */ public function setUp(): void { $this->c1 = new FooColumnValue2(); @@ -41,31 +46,36 @@ public function setUp(): void EOF; QuickBuilder::buildSchema($schema); - $e0 = new \ComplexColumnTypeEntity10(); + $e0 = new ComplexColumnTypeEntity10(); $e0->save(); - $e1 = new \ComplexColumnTypeEntity10(); + $e1 = new ComplexColumnTypeEntity10(); $e1->setBar($this->c1); $e1->save(); - $e2 = new \ComplexColumnTypeEntity10(); + $e2 = new ComplexColumnTypeEntity10(); $e2->setBar($this->c2); $e2->save(); - \Map\ComplexColumnTypeEntity10TableMap::clearInstancePool(); + ComplexColumnTypeEntity10TableMap::clearInstancePool(); } } + /** + * @return void + */ public function testColumnHydration() { - $e = \ComplexColumnTypeEntity10Query::create() + $e = ComplexColumnTypeEntity10Query::create() ->orderById() ->offset(1) ->findOne(); $this->assertEquals($this->c1, $e->getBar(), 'object columns are correctly hydrated'); } + /** + * @return void + */ public function testWhere() { - - $e = \ComplexColumnTypeEntity10Query::create() + $e = ComplexColumnTypeEntity10Query::create() ->where('ComplexColumnTypeEntity10.Bar = ?', $this->c1) ->findOne(); $this->assertEquals($this->c1, $e->getBar(), 'object columns are searchable by object using where()'); @@ -73,28 +83,33 @@ public function testWhere() /** * Recover this undocumented functionality + * + * @return void */ public function testWhereLike() { $this->markTestSkipped('There are inconsistencies regarding the handling of this statement on different platforms.'); - $nb = \ComplexColumnTypeEntity10Query::create() + $nb = ComplexColumnTypeEntity10Query::create() ->where('ComplexColumnTypeEntity10.Bar LIKE ?', '%1234%') ->count(); $this->assertEquals(1, $nb, 'object columns are searchable by serialized object using where()'); } + /** + * @return void + */ public function testFilterByColumn() { - $e = \ComplexColumnTypeEntity10Query::create() + $e = ComplexColumnTypeEntity10Query::create() ->filterByBar($this->c1) ->findOne(); $this->assertEquals($this->c1, $e->getBar(), 'object columns are searchable by object'); - $e = \ComplexColumnTypeEntity10Query::create() + $e = ComplexColumnTypeEntity10Query::create() ->filterByBar($this->c2) ->findOne(); $this->assertEquals($this->c2, $e->getBar(), 'object columns are searchable by object'); - $e = \ComplexColumnTypeEntity10Query::create() + $e = ComplexColumnTypeEntity10Query::create() ->filterByBar($this->c1, Criteria::NOT_EQUAL) ->findOne(); $this->assertEquals($this->c2, $e->getBar(), 'object columns are searchable by object'); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php index df068319d7..7821562843 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php @@ -10,6 +10,9 @@ namespace Propel\Tests\Generator\Builder\Om; +use ComplexColumnTypeEntitySet2; +use ComplexColumnTypeEntitySet2Query; +use PHPUnit\Framework\TestCase; use Propel\Generator\Util\QuickBuilder; use Propel\Runtime\ActiveQuery\Criteria; @@ -18,8 +21,11 @@ * * @author Francois Zaninotto */ -class GeneratedQuerySetColumnTypeTest extends \PHPUnit\Framework\TestCase +class GeneratedQuerySetColumnTypeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('\ComplexColumnTypeEntitySet2')) { @@ -33,20 +39,23 @@ public function setUp(): void EOF; QuickBuilder::buildSchema($schema); - $e0 = new \ComplexColumnTypeEntitySet2(); + $e0 = new ComplexColumnTypeEntitySet2(); $e0->save(); - $e1 = new \ComplexColumnTypeEntitySet2(); + $e1 = new ComplexColumnTypeEntitySet2(); $e1->setTags(['foo', 'bar', 'baz']); $e1->save(); - $e2 = new \ComplexColumnTypeEntitySet2(); + $e2 = new ComplexColumnTypeEntitySet2(); $e2->setTags(['bar']); $e2->save(); - $e3 = new \ComplexColumnTypeEntitySet2(); + $e3 = new ComplexColumnTypeEntitySet2(); $e3->setTags(['bar23']); $e3->save(); } } + /** + * @return void + */ public function testActiveQueryMethods() { $this->assertTrue(method_exists('\ComplexColumnTypeEntitySet2Query', 'filterByTags')); @@ -55,42 +64,48 @@ public function testActiveQueryMethods() $this->assertTrue(method_exists('\ComplexColumnTypeEntitySet2Query', 'filterByValueSet')); } + /** + * @return void + */ public function testColumnHydration() { - $e = \ComplexColumnTypeEntitySet2Query::create()->orderById()->offset(1)->findOne(); + $e = ComplexColumnTypeEntitySet2Query::create()->orderById()->offset(1)->findOne(); $this->assertEquals(['foo', 'bar', 'baz'], $e->getTags(), 'array columns are correctly hydrated'); } + /** + * @return void + */ public function testWhere() { - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->where('ComplexColumnTypeEntitySet2.Tags LIKE ?', 'bar23') ->find(); $this->assertEquals(1, $e->count()); $this->assertEquals(['bar23'], $e[0]->getTags(), 'set columns are searchable by single value using where()'); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->where('ComplexColumnTypeEntitySet2.Tags LIKE ?', ['foo', 'bar', 'baz']) ->find(); $this->assertEquals(1, $e->count()); $this->assertEquals(['foo', 'bar', 'baz'], $e[0]->getTags(), 'set columns are searchable by multiple values using where()'); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->where('ComplexColumnTypeEntitySet2.Tags IN ?', ['baz', 'bar23']) ->find(); $this->assertEquals(2, $e->count(), 'set columns are searchable by multiple values using where()'); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->where('ComplexColumnTypeEntitySet2.Tags NOT IN ?', ['baz', 'bar23']) ->find(); $this->assertEquals(1, $e->count(), 'set columns are searchable by multiple values using where()'); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->where('ComplexColumnTypeEntitySet2.Tags NOT IN ?', null) ->find(); $this->assertEquals(4, $e->count(), 'set columns are searchable by multiple values using where()'); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->where('ComplexColumnTypeEntitySet2.Tags IN ?', null) ->find(); $this->assertEquals(0, $e->count(), 'set columns are searchable by multiple values using where()'); @@ -98,84 +113,95 @@ public function testWhere() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testWhereInvalidValueThrowsException() { - \ComplexColumnTypeEntitySet2Query::create() + ComplexColumnTypeEntitySet2Query::create() ->where('ComplexColumnTypeEntitySet2.Tags LIKE ?', 'bar231') ->find(); } + /** + * @return void + */ public function testFilterByColumn() { - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags(['bar']) ->orderById() ->find(); $this->assertEquals(2, $e->count(), 'array columns do not return false positives'); $this->assertEquals(['foo', 'bar', 'baz'], $e[0]->getTags(), 'array columns are searchable by element'); $this->assertEquals(['bar'], $e[1]->getTags(), 'array columns are searchable by element'); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags(['bar23']) ->findOne(); $this->assertEquals(['bar23'], $e->getTags(), 'array columns are searchable by element'); } + /** + * @return void + */ public function testFilterByColumnUsingContainsAll() { - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags([], Criteria::CONTAINS_ALL) ->find(); $this->assertEquals(4, $e->count()); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags(['bar'], Criteria::CONTAINS_ALL) ->orderById() ->find(); $this->assertEquals(2, $e->count()); $this->assertEquals(['foo', 'bar', 'baz'], $e[0]->getTags()); $this->assertEquals(['bar'], $e[1]->getTags()); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags(['bar23'], Criteria::CONTAINS_ALL) ->find(); $this->assertEquals(1, $e->count()); $this->assertEquals(['bar23'], $e[0]->getTags()); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags(['foo', 'bar'], Criteria::CONTAINS_ALL) ->find(); $this->assertEquals(1, $e->count()); $this->assertEquals(['foo', 'bar', 'baz'], $e[0]->getTags()); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags(['foo', 'bar23'], Criteria::CONTAINS_ALL) ->find(); $this->assertEquals(0, $e->count()); } + /** + * @return void + */ public function testFilterByColumnUsingContainsSome() { - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags([], Criteria::CONTAINS_SOME) ->find(); $this->assertEquals(4, $e->count()); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags(['bar'], Criteria::CONTAINS_SOME) ->orderById() ->find(); $this->assertEquals(2, $e->count()); $this->assertEquals(['foo', 'bar', 'baz'], $e[0]->getTags()); $this->assertEquals(['bar'], $e[1]->getTags()); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags(['bar23'], Criteria::CONTAINS_SOME) ->find(); $this->assertEquals(1, $e->count()); $this->assertEquals(['bar23'], $e[0]->getTags()); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags(['foo', 'bar'], Criteria::CONTAINS_SOME) ->orderById() ->find(); $this->assertEquals(2, $e->count()); $this->assertEquals(['foo', 'bar', 'baz'], $e[0]->getTags()); $this->assertEquals(['bar'], $e[1]->getTags()); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags(['foo', 'bar23'], Criteria::CONTAINS_SOME) ->find(); $this->assertEquals(2, $e->count()); @@ -183,35 +209,38 @@ public function testFilterByColumnUsingContainsSome() $this->assertEquals(['bar23'], $e[1]->getTags()); } + /** + * @return void + */ public function testFilterByColumnUsingContainsNone() { - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags([], Criteria::CONTAINS_NONE) ->find(); $this->assertEquals(1, $e->count()); $this->assertEquals([], $e[0]->getTags()); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags(['bar'], Criteria::CONTAINS_NONE) ->orderById() ->find(); $this->assertEquals(2, $e->count()); $this->assertEquals([], $e[0]->getTags()); $this->assertEquals(['bar23'], $e[1]->getTags()); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags(['bar23'], Criteria::CONTAINS_NONE) ->find(); $this->assertEquals(3, $e->count()); $this->assertEquals([], $e[0]->getTags()); $this->assertEquals(['foo', 'bar', 'baz'], $e[1]->getTags()); $this->assertEquals(['bar'], $e[2]->getTags()); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags(['foo', 'bar'], Criteria::CONTAINS_NONE) ->orderById() ->find(); $this->assertEquals(2, $e->count()); $this->assertEquals([], $e[0]->getTags()); $this->assertEquals(['bar23'], $e[1]->getTags()); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTags(['foo', 'bar23'], Criteria::CONTAINS_NONE) ->find(); $this->assertEquals(2, $e->count()); @@ -219,24 +248,30 @@ public function testFilterByColumnUsingContainsNone() $this->assertEquals(['bar'], $e[1]->getTags()); } + /** + * @return void + */ public function testFilterBySingularColumn() { - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTag('bar') ->orderById() ->find(); $this->assertEquals(['foo', 'bar', 'baz'], $e[0]->getTags(), 'array columns are searchable by element'); $this->assertEquals(['bar'], $e[1]->getTags(), 'array columns are searchable by element'); $this->assertEquals(2, $e->count(), 'array columns do not return false positives'); - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTag('bar23') ->findOne(); $this->assertEquals(['bar23'], $e->getTags(), 'array columns are searchable by element'); } + /** + * @return void + */ public function testFilterBySingularColumnUsingContainsAll() { - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTag('bar', Criteria::CONTAINS_ALL) ->orderById() ->find(); @@ -245,9 +280,12 @@ public function testFilterBySingularColumnUsingContainsAll() $this->assertEquals(['bar'], $e[1]->getTags(), 'array columns are searchable by element using Criteria::CONTAINS_ALL'); } + /** + * @return void + */ public function testFilterBySingularColumnUsingContainsNone() { - $e = \ComplexColumnTypeEntitySet2Query::create() + $e = ComplexColumnTypeEntitySet2Query::create() ->filterByTag('bar', Criteria::CONTAINS_NONE) ->orderById() ->find(); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapEnumColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapEnumColumnTypeTest.php index 99fdcaf3ab..5e31652578 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapEnumColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapEnumColumnTypeTest.php @@ -10,9 +10,8 @@ namespace Propel\Tests\Generator\Builder\Om; +use Map\ComplexColumnTypeEntity103TableMap; use Propel\Generator\Util\QuickBuilder; - -use Propel\Runtime\Propel; use Propel\Tests\TestCase; /** @@ -22,6 +21,9 @@ */ class GeneratedTableMapEnumColumnTypeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('ComplexColumnTypeEntity103')) { @@ -52,6 +54,8 @@ public function valueSetConstantProvider() /** * @dataProvider valueSetConstantProvider + * + * @return void */ public function testValueSetConstants($constantName, $value) { @@ -59,15 +63,21 @@ public function testValueSetConstants($constantName, $value) $this->assertEquals($value, constant($constantName)); } + /** + * @return void + */ public function testGetValueSets() { - $expected = [\Map\ComplexColumnTypeEntity103TableMap::COL_BAR => ['foo', 'bar', 'baz', '1', '4', '(', 'foo bar']]; - $this->assertEquals($expected, \Map\ComplexColumnTypeEntity103TableMap::getValueSets()); + $expected = [ComplexColumnTypeEntity103TableMap::COL_BAR => ['foo', 'bar', 'baz', '1', '4', '(', 'foo bar']]; + $this->assertEquals($expected, ComplexColumnTypeEntity103TableMap::getValueSets()); } + /** + * @return void + */ public function testGetValueSet() { $expected = ['foo', 'bar', 'baz', '1', '4', '(', 'foo bar']; - $this->assertEquals($expected, \Map\ComplexColumnTypeEntity103TableMap::getValueSet(\Map\ComplexColumnTypeEntity103TableMap::COL_BAR)); + $this->assertEquals($expected, ComplexColumnTypeEntity103TableMap::getValueSet(ComplexColumnTypeEntity103TableMap::COL_BAR)); } } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapLazyLoadTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapLazyLoadTest.php index eb494d6073..188d5f456d 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapLazyLoadTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapLazyLoadTest.php @@ -10,17 +10,19 @@ namespace Propel\Tests\Generator\Builder\Om; +use LazyLoadActiveRecord2; +use Map\LazyLoadActiveRecord2TableMap; use Propel\Generator\Util\QuickBuilder; - -use Propel\Runtime\Propel; use Propel\Tests\TestCase; /** * Tests the generated TableMap classes for lazy load columns. - * */ class GeneratedTableMapLazyLoadTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('\LazyLoadActiveRecord2')) { @@ -38,17 +40,23 @@ public function setUp(): void } } + /** + * @return void + */ public function testNumHydrateColumns() { - $this->assertEquals(3, \Map\LazyLoadActiveRecord2TableMap::NUM_HYDRATE_COLUMNS); + $this->assertEquals(3, LazyLoadActiveRecord2TableMap::NUM_HYDRATE_COLUMNS); } + /** + * @return void + */ public function testPopulateObjectNotInPool() { - \Map\LazyLoadActiveRecord2TableMap::clearInstancePool(); + LazyLoadActiveRecord2TableMap::clearInstancePool(); $values = [123, 'fooValue', 'bazValue']; $col = 0; - list($obj, $col) = \Map\LazyLoadActiveRecord2TableMap::populateObject($values, $col); + [$obj, $col] = LazyLoadActiveRecord2TableMap::populateObject($values, $col); $this->assertEquals(3, $col); $this->assertEquals(123, $obj->getId()); $this->assertEquals('fooValue', $obj->getFoo()); @@ -56,18 +64,21 @@ public function testPopulateObjectNotInPool() $this->assertEquals('bazValue', $obj->getBaz()); } + /** + * @return void + */ public function testPopulateObjectInPool() { - \Map\LazyLoadActiveRecord2TableMap::clearInstancePool(); - $ar = new \LazyLoadActiveRecord2(); + LazyLoadActiveRecord2TableMap::clearInstancePool(); + $ar = new LazyLoadActiveRecord2(); $ar->setId(123); $ar->setFoo('fooValue'); $ar->setBaz('bazValue'); $ar->setNew(false); - \Map\LazyLoadActiveRecord2TableMap::addInstanceToPool($ar, 123); + LazyLoadActiveRecord2TableMap::addInstanceToPool($ar, 123); $values = [123, 'fooValue', 'bazValue']; $col = 0; - list($obj, $col) = \Map\LazyLoadActiveRecord2TableMap::populateObject($values, $col); + [$obj, $col] = LazyLoadActiveRecord2TableMap::populateObject($values, $col); $this->assertEquals(3, $col); $this->assertEquals(123, $obj->getId()); $this->assertEquals('fooValue', $obj->getFoo()); @@ -75,12 +86,15 @@ public function testPopulateObjectInPool() $this->assertEquals('bazValue', $obj->getBaz()); } + /** + * @return void + */ public function testPopulateObjectNotInPoolStartColGreaterThanOne() { - \Map\LazyLoadActiveRecord2TableMap::clearInstancePool(); + LazyLoadActiveRecord2TableMap::clearInstancePool(); $values = ['dummy', 'dummy', 123, 'fooValue', 'bazValue', 'dummy']; $col = 2; - list($obj, $col) = \Map\LazyLoadActiveRecord2TableMap::populateObject($values, $col); + [$obj, $col] = LazyLoadActiveRecord2TableMap::populateObject($values, $col); $this->assertEquals(5, $col); $this->assertEquals(123, $obj->getId()); $this->assertEquals('fooValue', $obj->getFoo()); @@ -88,23 +102,25 @@ public function testPopulateObjectNotInPoolStartColGreaterThanOne() $this->assertEquals('bazValue', $obj->getBaz()); } + /** + * @return void + */ public function testPopulateObjectInPoolStartColGreaterThanOne() { - \Map\LazyLoadActiveRecord2TableMap::clearInstancePool(); - $ar = new \LazyLoadActiveRecord2(); + LazyLoadActiveRecord2TableMap::clearInstancePool(); + $ar = new LazyLoadActiveRecord2(); $ar->setId(123); $ar->setFoo('fooValue'); $ar->setBaz('bazValue'); $ar->setNew(false); - \Map\LazyLoadActiveRecord2TableMap::addInstanceToPool($ar, 123); + LazyLoadActiveRecord2TableMap::addInstanceToPool($ar, 123); $values = ['dummy', 'dummy', 123, 'fooValue', 'bazValue', 'dummy']; $col = 2; - list($obj, $col) = \Map\LazyLoadActiveRecord2TableMap::populateObject($values, $col); + [$obj, $col] = LazyLoadActiveRecord2TableMap::populateObject($values, $col); $this->assertEquals(5, $col); $this->assertEquals(123, $obj->getId()); $this->assertEquals('fooValue', $obj->getFoo()); $this->assertNull($obj->getBar()); $this->assertEquals('bazValue', $obj->getBaz()); } - } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapSetColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapSetColumnTypeTest.php index 4d07babab6..bf305d2e6d 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapSetColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapSetColumnTypeTest.php @@ -10,8 +10,8 @@ namespace Propel\Tests\Generator\Builder\Om; +use Map\ComplexColumnTypeEntity103TableMap; use Propel\Generator\Util\QuickBuilder; - use Propel\Tests\TestCase; /** @@ -21,6 +21,9 @@ */ class GeneratedTableMapSetColumnTypeTest extends TestCase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('ComplexColumnTypeEntity103')) { @@ -51,6 +54,8 @@ public function valueSetConstantProvider() /** * @dataProvider valueSetConstantProvider + * + * @return void */ public function testValueSetConstants($constantName, $value) { @@ -58,15 +63,21 @@ public function testValueSetConstants($constantName, $value) $this->assertEquals($value, constant($constantName)); } + /** + * @return void + */ public function testGetValueSets() { - $expected = [\Map\ComplexColumnTypeEntity103TableMap::COL_BAR => ['foo', 'bar', 'baz', '1', '4', '(', 'foo bar']]; - $this->assertEquals($expected, \Map\ComplexColumnTypeEntity103TableMap::getValueSets()); + $expected = [ComplexColumnTypeEntity103TableMap::COL_BAR => ['foo', 'bar', 'baz', '1', '4', '(', 'foo bar']]; + $this->assertEquals($expected, ComplexColumnTypeEntity103TableMap::getValueSets()); } + /** + * @return void + */ public function testGetValueSet() { $expected = ['foo', 'bar', 'baz', '1', '4', '(', 'foo bar']; - $this->assertEquals($expected, \Map\ComplexColumnTypeEntity103TableMap::getValueSet(\Map\ComplexColumnTypeEntity103TableMap::COL_BAR)); + $this->assertEquals($expected, ComplexColumnTypeEntity103TableMap::getValueSet(ComplexColumnTypeEntity103TableMap::COL_BAR)); } } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapTest.php index 1a8b09310b..928f790cc2 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapTest.php @@ -10,15 +10,13 @@ namespace Propel\Tests\Generator\Builder\Om; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; - +use Propel\Runtime\ActiveQuery\Criteria; use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\EssayTableMap; use Propel\Tests\Bookstore\Map\MediaTableMap; use Propel\Tests\Bookstore\Map\PublisherTableMap; - -use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Tests the generated TableMap classes. @@ -26,18 +24,21 @@ * This test uses generated Bookstore classes to test the behavior of various * TableMap operations. * - * The database is reloaded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same - * for each test method in this class. See the BookstoreDataPopulator::populate() + * for each test method in this class. See the BookstoreDataPopulator::populate() * method for the exact contents of the database. * - * @see BookstoreDataPopulator + * @see BookstoreDataPopulator * @author Hans Lellelid * * @group database */ class GeneratedTableMapTest extends BookstoreTestBase { + /** + * @return void + */ public function testAlias() { $this->assertEquals('foo.id', BookTableMap::alias('foo', BookTableMap::COL_ID), 'alias() returns a column name using the table alias'); @@ -46,6 +47,9 @@ public function testAlias() $this->assertEquals('foo.subtitle', EssayTableMap::alias('foo', EssayTableMap::COL_SUBTITLE), 'alias() also works for columns with custom phpName'); } + /** + * @return void + */ public function testAddSelectColumns() { $c = new Criteria(); @@ -56,22 +60,28 @@ public function testAddSelectColumns() BookTableMap::COL_ISBN, BookTableMap::COL_PRICE, BookTableMap::COL_PUBLISHER_ID, - BookTableMap::COL_AUTHOR_ID + BookTableMap::COL_AUTHOR_ID, ]; $this->assertEquals($expected, $c->getSelectColumns(), 'addSelectColumns() adds the columns of the model to the criteria'); } + /** + * @return void + */ public function testAddSelectColumnsLazyLoad() { $c = new Criteria(); MediaTableMap::addSelectColumns($c); $expected = [ MediaTableMap::COL_ID, - MediaTableMap::COL_BOOK_ID + MediaTableMap::COL_BOOK_ID, ]; $this->assertEquals($expected, $c->getSelectColumns(), 'addSelectColumns() does not add lazy loaded columns'); } + /** + * @return void + */ public function testAddSelectColumnsAlias() { $c = new Criteria(); @@ -82,27 +92,32 @@ public function testAddSelectColumnsAlias() 'foo.isbn', 'foo.price', 'foo.publisher_id', - 'foo.author_id' + 'foo.author_id', ]; $this->assertEquals($expected, $c->getSelectColumns(), 'addSelectColumns() uses the second parameter as a table alias'); } + /** + * @return void + */ public function testAddSelectColumnsAliasLazyLoad() { $c = new Criteria(); MediaTableMap::addSelectColumns($c, 'bar'); $expected = [ 'bar.id', - 'bar.book_id' + 'bar.book_id', ]; $this->assertEquals($expected, $c->getSelectColumns(), 'addSelectColumns() does not add lazy loaded columns but uses the second parameter as an alias'); } + /** + * @return void + */ public function testDefaultStringFormatConstant() { $this->assertTrue(defined('Propel\Tests\Bookstore\Map\BookTableMap::DEFAULT_STRING_FORMAT'), 'every TableMap class has the DEFAULT_STRING_FORMAT constant'); $this->assertEquals('YAML', AuthorTableMap::DEFAULT_STRING_FORMAT, 'default string format is YAML by default'); $this->assertEquals('XML', PublisherTableMap::DEFAULT_STRING_FORMAT, 'default string format can be customized using the defaultStringFormat attribute in the schema'); } - } diff --git a/tests/Propel/Tests/Generator/Builder/Om/ObjectBuilderTest.php b/tests/Propel/Tests/Generator/Builder/Om/ObjectBuilderTest.php index 0561628e1a..aef27c2450 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/ObjectBuilderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/ObjectBuilderTest.php @@ -11,23 +11,26 @@ namespace Propel\Tests\Generator\Builder\Om; use Propel\Generator\Builder\Om\ObjectBuilder; -use Propel\Generator\Platform\MysqlPlatform; use Propel\Generator\Model\Column; use Propel\Generator\Model\ColumnDefaultValue; use Propel\Generator\Model\Domain; use Propel\Generator\Model\Table; +use Propel\Generator\Platform\MysqlPlatform; use Propel\Tests\TestCase; /** * Test class for ObjectBuilder. * * @author François Zaninotto - * @version $Id$ + * @version $Id$ */ class ObjectBuilderTest extends TestCase { protected $builder; + /** + * @return void + */ public function setUp(): void { $builder = new TestableObjectBuilder(new Table('Foo')); @@ -44,11 +47,11 @@ public static function getDefaultValueStringProvider() $col2 = new Column('Bar'); $col2->setDomain(new Domain('INTEGER')); $col2->setDefaultValue(new ColumnDefaultValue(1234, ColumnDefaultValue::TYPE_VALUE)); - $val2 = "1234"; + $val2 = '1234'; $col3 = new Column('Bar'); $col3->setDomain(new Domain('DATE')); $col3->setDefaultValue(new ColumnDefaultValue('0000-00-00', ColumnDefaultValue::TYPE_VALUE)); - $val3 = "NULL"; + $val3 = 'NULL'; return [ [$col1, $val1], @@ -59,17 +62,21 @@ public static function getDefaultValueStringProvider() /** * @dataProvider getDefaultValueStringProvider + * + * @return void */ public function testGetDefaultValueString($column, $value) { $this->assertEquals($value, $this->builder->getDefaultValueString($column)); } + /** + * @return void + */ public function testGetDefaultKeyType() { $this->assertEquals('TYPE_PHPNAME', $this->builder->getDefaultKeyType()); } - } class TestableObjectBuilder extends ObjectBuilder diff --git a/tests/Propel/Tests/Generator/Builder/Om/PoisonedCacheBugTest.php b/tests/Propel/Tests/Generator/Builder/Om/PoisonedCacheBugTest.php index 4b9e3dfa17..83e32f237a 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/PoisonedCacheBugTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/PoisonedCacheBugTest.php @@ -14,9 +14,9 @@ use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\AuthorQuery; -use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Book; use Propel\Tests\Bookstore\BookQuery; +use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; @@ -26,30 +26,33 @@ class PoisonedCacheBugTest extends BookstoreTestBase { /** - * @var Author + * @var \Propel\Tests\Bookstore\Author */ private $author; /** - * @var Book[] + * @var \Propel\Tests\Bookstore\Book[] */ private $books; + /** + * @return void + */ public function setUp(): void { parent::setUp(); $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + $a->setFirstName('Douglas'); + $a->setLastName('Adams'); $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $b1->setTitle('The Hitchhikers Guide To The Galaxy'); $b1->setISBN('01234'); $a->addBook($b1); $b2 = new Book(); - $b2->setTitle("The Restaurant At The End Of The Universe"); + $b2->setTitle('The Restaurant At The End Of The Universe'); $b2->setISBN('5678'); $a->addBook($b2); @@ -64,6 +67,9 @@ public function setUp(): void AuthorTableMap::clearInstancePool(); } + /** + * @return void + */ public function testSetUp() { $this->assertTrue(Propel::isInstancePoolingEnabled()); @@ -74,6 +80,8 @@ public function testSetUp() /** * Very common use case where fetching a book, and showing other books by the author + * + * @return void */ public function testPoisonedCacheWhenDoSelectJoinAuthor() { @@ -88,6 +96,8 @@ public function testPoisonedCacheWhenDoSelectJoinAuthor() /** * To illustrate that instance pooling makes no difference + * + * @return void */ public function testPoisonedCacheWithJoinInstancePoolingDisabled() { @@ -96,6 +106,9 @@ public function testPoisonedCacheWithJoinInstancePoolingDisabled() $this->testPoisonedCacheWhenDoSelectJoinAuthor(); } + /** + * @return void + */ public function testPoisonedCacheWhenSavingABook() { $b1 = BookQuery::create()->findPk($this->books[0]->getId()); @@ -113,18 +126,24 @@ public function testPoisonedCacheWhenSavingABook() $this->assertEquals(2, $author->countBooks()); } + /** + * @return void + */ public function testAddingABook() { $author = AuthorQuery::create()->findPk($this->author->getId()); $c1 = new Book(); - $c1->setTitle("ORM 101"); + $c1->setTitle('ORM 101'); $author->addBook($c1); $this->assertEquals(3, count($author->getBooks())); $this->assertEquals(3, $author->countBooks()); } + /** + * @return void + */ public function testModifiedObjectsRemainInTheCollection() { $c = new Criteria(); diff --git a/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderInheritanceTest.php b/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderInheritanceTest.php index 014356b83c..70af17f9f8 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderInheritanceTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderInheritanceTest.php @@ -10,9 +10,7 @@ namespace Propel\Tests\Generator\Builder\Om; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; -use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; - +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\BookstoreCashier; use Propel\Tests\Bookstore\BookstoreCashierQuery; use Propel\Tests\Bookstore\BookstoreEmployee; @@ -20,12 +18,12 @@ use Propel\Tests\Bookstore\BookstoreManager; use Propel\Tests\Bookstore\BookstoreManagerQuery; use Propel\Tests\Bookstore\DistributionManager; +use Propel\Tests\Bookstore\DistributionQuery; use Propel\Tests\Bookstore\DistributionStore; use Propel\Tests\Bookstore\DistributionVirtualStore; -use Propel\Tests\Bookstore\DistributionQuery; use Propel\Tests\Bookstore\Map\DistributionTableMap; - -use Propel\Runtime\Propel; +use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Test class for MultiExtensionQueryBuilder. @@ -51,6 +49,8 @@ public function constructProvider() /** * @dataProvider constructProvider + * + * @return void */ public function testConstruct($class) { @@ -59,6 +59,9 @@ public function testConstruct($class) $this->assertTrue($query instanceof $class, 'the create() factory returns an instance of the correct class'); } + /** + * @return void + */ public function testFindFilter() { BookstoreDataPopulator::depopulate($this->con); @@ -78,6 +81,9 @@ public function testFindFilter() $this->assertEquals(2, $nbCash, 'find() in sub query returns only child results'); } + /** + * @return void + */ public function testUpdateFilter() { BookstoreDataPopulator::depopulate($this->con); @@ -94,6 +100,9 @@ public function testUpdateFilter() $this->assertEquals(1, $nbMan, 'Update in sub query affects only child results'); } + /** + * @return void + */ public function testDeleteFilter() { BookstoreDataPopulator::depopulate($this->con); @@ -110,6 +119,9 @@ public function testDeleteFilter() $this->assertEquals(2, $nbCash, 'Delete in sub query affects only child results'); } + /** + * @return void + */ public function testDeleteAllFilter() { BookstoreDataPopulator::depopulate($this->con); @@ -124,6 +136,9 @@ public function testDeleteAllFilter() $this->assertEquals(2, $nbCash, 'Delete in sub query affects only child results'); } + /** + * @return void + */ public function testFindPkSimpleWithSingleTableInheritanceReturnCorrectClass() { Propel::disableInstancePooling(); @@ -137,18 +152,33 @@ public function testFindPkSimpleWithSingleTableInheritanceReturnCorrectClass() $cashier2 = new BookstoreCashier(); $cashier2->save($this->con); - $this->assertInstanceOf('\Propel\Tests\Bookstore\BookstoreEmployee', BookstoreEmployeeQuery::create()->findPk($employee->getId()), - 'findPk() return right object : BookstoreEmployee'); - $this->assertInstanceOf('\Propel\Tests\Bookstore\BookstoreManager', BookstoreEmployeeQuery::create()->findPk($manager->getId()), - 'findPk() return right object : BookstoreManager'); - $this->assertInstanceOf('\Propel\Tests\Bookstore\BookstoreCashier', BookstoreEmployeeQuery::create()->findPk($cashier1->getId()), - 'findPk() return right object : BookstoreCashier'); - $this->assertInstanceOf('\Propel\Tests\Bookstore\BookstoreCashier', BookstoreEmployeeQuery::create()->findPk($cashier2->getId()), - 'findPk() return right object : BookstoreCashier'); + $this->assertInstanceOf( + '\Propel\Tests\Bookstore\BookstoreEmployee', + BookstoreEmployeeQuery::create()->findPk($employee->getId()), + 'findPk() return right object : BookstoreEmployee' + ); + $this->assertInstanceOf( + '\Propel\Tests\Bookstore\BookstoreManager', + BookstoreEmployeeQuery::create()->findPk($manager->getId()), + 'findPk() return right object : BookstoreManager' + ); + $this->assertInstanceOf( + '\Propel\Tests\Bookstore\BookstoreCashier', + BookstoreEmployeeQuery::create()->findPk($cashier1->getId()), + 'findPk() return right object : BookstoreCashier' + ); + $this->assertInstanceOf( + '\Propel\Tests\Bookstore\BookstoreCashier', + BookstoreEmployeeQuery::create()->findPk($cashier2->getId()), + 'findPk() return right object : BookstoreCashier' + ); Propel::enableInstancePooling(); } + /** + * @return void + */ public function testGetCorrectTableMapClassWithAbstractSingleTableInheritance() { $this->assertInstanceOf('\Propel\Tests\Bookstore\Map\DistributionTableMap', DistributionTableMap::getTableMap(), 'getTableMap should return the right table map'); @@ -156,6 +186,8 @@ public function testGetCorrectTableMapClassWithAbstractSingleTableInheritance() /** * This test prove failure with propel.emulateForeignKeyConstraints = true + * + * @return void */ public function testDeleteCascadeWithAbstractSingleTableInheritance() { @@ -165,7 +197,10 @@ public function testDeleteCascadeWithAbstractSingleTableInheritance() $manager->delete(); } - public function testFindPkSimpleWithAbstractSingleTableInheritanceReturnCorrectClass() + /** + * @return void + */ + public function testFindPkSimpleWithAbstractSingleTableInheritanceReturnCorrectClass() { Propel::disableInstancePooling(); @@ -183,10 +218,16 @@ public function testFindPkSimpleWithAbstractSingleTableInheritanceReturnCorrect $distributionVirtualStore->setDistributionManager($manager); $distributionVirtualStore->save(); - $this->assertInstanceOf('Propel\Tests\Bookstore\DistributionStore', DistributionQuery::create()->findPk($distributionStore->getId()), - 'findPk() return right object : DistributionStore'); - $this->assertInstanceOf('Propel\Tests\Bookstore\DistributionVirtualStore', DistributionQuery::create()->findPk($distributionVirtualStore->getId()), - 'findPk() return right object : DistributionVirtualStore'); + $this->assertInstanceOf( + 'Propel\Tests\Bookstore\DistributionStore', + DistributionQuery::create()->findPk($distributionStore->getId()), + 'findPk() return right object : DistributionStore' + ); + $this->assertInstanceOf( + 'Propel\Tests\Bookstore\DistributionVirtualStore', + DistributionQuery::create()->findPk($distributionVirtualStore->getId()), + 'findPk() return right object : DistributionVirtualStore' + ); Propel::enableInstancePooling(); } diff --git a/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php b/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php index 53573b277d..44e11c651e 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php @@ -13,34 +13,32 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveQuery\ModelJoin; -use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Propel; use Propel\Tests\Bookstore\AuthorQuery; -use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\BookQuery; -use Propel\Tests\Bookstore\Map\BookTableMap; -use Propel\Tests\Bookstore\BookstoreEmployeeAccountQuery; -use Propel\Tests\Bookstore\Map\BookstoreEmployeeAccountTableMap; use Propel\Tests\Bookstore\BookClubListQuery; -use Propel\Tests\Bookstore\BookOpinionQuery; use Propel\Tests\Bookstore\BookListRelQuery; -use Propel\Tests\Bookstore\Map\BookListRelTableMap; +use Propel\Tests\Bookstore\BookOpinionQuery; +use Propel\Tests\Bookstore\BookQuery; +use Propel\Tests\Bookstore\BookstoreEmployeeAccountQuery; use Propel\Tests\Bookstore\BookSummaryQuery; use Propel\Tests\Bookstore\EssayQuery; -use Propel\Tests\Bookstore\ReviewQuery; +use Propel\Tests\Bookstore\Map\AuthorTableMap; +use Propel\Tests\Bookstore\Map\BookListRelTableMap; +use Propel\Tests\Bookstore\Map\BookstoreEmployeeAccountTableMap; +use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Bookstore\Map\PublisherTableMap; +use Propel\Tests\Bookstore\Map\RecordLabelTableMap; +use Propel\Tests\Bookstore\Map\ReleasePoolTableMap; use Propel\Tests\Bookstore\Map\ReviewTableMap; use Propel\Tests\Bookstore\ReaderFavoriteQuery; -use Propel\Tests\Bookstore\Map\PublisherTableMap; use Propel\Tests\Bookstore\RecordLabelQuery; -use Propel\Tests\Bookstore\Map\RecordLabelTableMap; use Propel\Tests\Bookstore\ReleasePoolQuery; -use Propel\Tests\Bookstore\Map\ReleasePoolTableMap; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use Propel\Tests\Bookstore\ReviewQuery; use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; - -use \ReflectionMethod; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use ReflectionMethod; /** * Test class for QueryBuilder. @@ -51,19 +49,27 @@ */ class QueryBuilderTest extends BookstoreTestBase { - + /** + * @return void + */ protected function setUp(): void { parent::setUp(); - include_once(__DIR__.'/QueryBuilderTestClasses.php'); + include_once(__DIR__ . '/QueryBuilderTestClasses.php'); } + /** + * @return void + */ public function testExtends() { $q = new BookQuery(); $this->assertTrue($q instanceof ModelCriteria, 'Model query extends ModelCriteria'); } + /** + * @return void + */ public function testConstructor() { $query = new BookQuery(); @@ -71,6 +77,9 @@ public function testConstructor() $this->assertEquals('Propel\Tests\Bookstore\Book', $query->getModelName(), 'Constructor sets model name'); } + /** + * @return void + */ public function testCreate() { $query = BookQuery::create(); @@ -84,6 +93,9 @@ public function testCreate() $this->assertEquals('foo', $query->getModelAlias(), 'create() can set the model alias'); } + /** + * @return void + */ public function testCreateCustom() { // see the myBookQuery class definition at the end of this file @@ -99,6 +111,9 @@ public function testCreateCustom() $this->assertEquals('foo', $query->getModelAlias(), 'create() can set the model alias'); } + /** + * @return void + */ public function testBasePreSelect() { $method = new ReflectionMethod('\Propel\Tests\Bookstore\Behavior\Table2Query', 'basePreSelect'); @@ -108,6 +123,9 @@ public function testBasePreSelect() $this->assertEquals('Propel\Tests\Bookstore\Behavior\Base\Table3Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides basePreSelect() when a behavior is registered'); } + /** + * @return void + */ public function testBasePreDelete() { $method = new ReflectionMethod('\Propel\Tests\Bookstore\Behavior\Table2Query', 'basePreDelete'); @@ -117,6 +135,9 @@ public function testBasePreDelete() $this->assertEquals('Propel\Tests\Bookstore\Behavior\Base\Table3Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides basePreDelete() when a behavior is registered'); } + /** + * @return void + */ public function testBasePostDelete() { $method = new ReflectionMethod('\Propel\Tests\Bookstore\Behavior\Table2Query', 'basePostDelete'); @@ -126,6 +147,9 @@ public function testBasePostDelete() $this->assertEquals('Propel\Tests\Bookstore\Behavior\Base\Table3Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides basePostDelete() when a behavior is registered'); } + /** + * @return void + */ public function testBasePreUpdate() { $method = new ReflectionMethod('\Propel\Tests\Bookstore\Behavior\Table2Query', 'basePreUpdate'); @@ -135,6 +159,9 @@ public function testBasePreUpdate() $this->assertEquals('Propel\Tests\Bookstore\Behavior\Base\Table3Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides basePreUpdate() when a behavior is registered'); } + /** + * @return void + */ public function testBasePostUpdate() { $method = new ReflectionMethod('\Propel\Tests\Bookstore\Behavior\Table2Query', 'basePostUpdate'); @@ -144,6 +171,9 @@ public function testBasePostUpdate() $this->assertEquals('Propel\Tests\Bookstore\Behavior\Base\Table3Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides basePostUpdate() when a behavior is registered'); } + /** + * @return void + */ public function testQuery() { BookstoreDataPopulator::depopulate(); @@ -159,12 +189,18 @@ public function testQuery() $this->assertEquals('Don Juan', $book->getTitle()); } + /** + * @return void + */ public function testFindPk() { $method = new ReflectionMethod('\Propel\Tests\Bookstore\BookQuery', 'findPk'); $this->assertEquals('Propel\Tests\Bookstore\Base\BookQuery', $method->getDeclaringClass()->getName(), 'BaseQuery overrides findPk()'); } + /** + * @return void + */ public function testFindPkReturnsCorrectObjectForSimplePrimaryKey() { $b = new Book(); @@ -177,9 +213,12 @@ public function testFindPkReturnsCorrectObjectForSimplePrimaryKey() $book = BookQuery::create()->findPk($b->getId(), $this->con); $this->assertEquals($b, $book); - $this->assertEquals($count+1, $this->con->getQueryCount(), 'findPk() issues a database query when instance is not in pool'); + $this->assertEquals($count + 1, $this->con->getQueryCount(), 'findPk() issues a database query when instance is not in pool'); } + /** + * @return void + */ public function testFindPkUsesInstancePoolingForSimplePrimaryKey() { $b = new Book(); @@ -193,6 +232,9 @@ public function testFindPkUsesInstancePoolingForSimplePrimaryKey() $this->assertEquals($count, $this->con->getQueryCount(), 'findPk() does not issue a database query when instance is in pool'); } + /** + * @return void + */ public function testFindPkReturnsCorrectObjectForCompositePrimaryKey() { BookstoreDataPopulator::depopulate(); @@ -217,6 +259,9 @@ public function testFindPkReturnsCorrectObjectForCompositePrimaryKey() $this->assertEquals($bookListRelTest, $bookListRel, 'BaseQuery overrides findPk() for composite primary keysto make it faster'); } + /** + * @return void + */ public function testFindPkUsesFindPkSimpleOnEmptyQueries() { BookQuery::create()->findPk(123, $this->con); @@ -224,6 +269,9 @@ public function testFindPkUsesFindPkSimpleOnEmptyQueries() $this->assertEquals($expected, $this->con->getLastExecutedQuery()); } + /** + * @return void + */ public function testFindPkSimpleAddsObjectToInstancePool() { $b = new Book(); @@ -240,6 +288,9 @@ public function testFindPkSimpleAddsObjectToInstancePool() $this->assertEquals($count, $this->con->getQueryCount()); } + /** + * @return void + */ public function testFindPkUsesFindPkComplexOnNonEmptyQueries() { BookQuery::create('b')->findPk(123, $this->con); @@ -247,6 +298,9 @@ public function testFindPkUsesFindPkComplexOnNonEmptyQueries() $this->assertEquals($expected, $this->con->getLastExecutedQuery()); } + /** + * @return void + */ public function testFindPkNotUsesInstancePoolingForNonEmptyQueries() { $b = new Book(); @@ -261,6 +315,9 @@ public function testFindPkNotUsesInstancePoolingForNonEmptyQueries() $this->assertNull($book); } + /** + * @return void + */ public function testFindPkComplexAddsObjectToInstancePool() { $b = new Book(); @@ -277,6 +334,9 @@ public function testFindPkComplexAddsObjectToInstancePool() $this->assertEquals($count, $this->con->getQueryCount()); } + /** + * @return void + */ public function testFindPkCallsPreSelect() { $q = new mySecondBookQuery(); @@ -285,12 +345,18 @@ public function testFindPkCallsPreSelect() $this->assertTrue($q::$preSelectWasCalled); } + /** + * @return void + */ public function testFindPks() { $method = new ReflectionMethod('\Propel\Tests\Bookstore\BookQuery', 'findPks'); $this->assertEquals('Propel\Tests\Bookstore\Base\BookQuery', $method->getDeclaringClass()->getName(), 'BaseQuery overrides findPks()'); } + /** + * @return void + */ public function testFindPksSimpleKey() { BookstoreDataPopulator::depopulate(); @@ -310,6 +376,9 @@ public function testFindPksSimpleKey() $this->assertEquals([$testBook1, $testBook2], $books->getData(), 'BaseQuery overrides findPks() to make it faster'); } + /** + * @return void + */ public function testFindPksCompositeKey() { BookstoreDataPopulator::depopulate(); @@ -329,7 +398,7 @@ public function testFindPksCompositeKey() $bookListRelTest = $c->find(); $search = []; foreach ($bookListRelTest as $obj) { - $search[]= $obj->getPrimaryKey(); + $search[] = $obj->getPrimaryKey(); } $q = new BookListRelQuery(); @@ -337,6 +406,9 @@ public function testFindPksCompositeKey() $this->assertEquals($bookListRelTest->getArrayCopy(), $objs->getArrayCopy(), 'BaseQuery overrides findPks() for composite primary keys to make it work'); } + /** + * @return void + */ public function testFilterBy() { foreach (BookTableMap::getFieldNames(TableMap::TYPE_PHPNAME) as $colName) { @@ -347,6 +419,9 @@ public function testFilterBy() } } + /** + * @return void + */ public function testFilterByPrimaryKeySimpleKey() { $q = BookQuery::create()->filterByPrimaryKey(12); @@ -358,6 +433,9 @@ public function testFilterByPrimaryKeySimpleKey() $this->assertEquals($q1, $q, 'filterByPrimaryKey() uses true table alias if set'); } + /** + * @return void + */ public function testFilterByPrimaryKeyCompositeKey() { BookstoreDataPopulator::depopulate(); @@ -386,6 +464,9 @@ public function testFilterByPrimaryKeyCompositeKey() $this->assertEquals($q1, $q, 'filterByPrimaryKey() translates to a Criteria::EQUAL in the PK columns'); } + /** + * @return void + */ public function testFilterByPrimaryKeysSimpleKey() { $q = BookQuery::create()->filterByPrimaryKeys([10, 11, 12]); @@ -397,6 +478,9 @@ public function testFilterByPrimaryKeysSimpleKey() $this->assertEquals($q1, $q, 'filterByPrimaryKeys() uses true table alias if set'); } + /** + * @return void + */ public function testFilterByPrimaryKeysCompositeKey() { BookstoreDataPopulator::depopulate(); @@ -416,7 +500,7 @@ public function testFilterByPrimaryKeysCompositeKey() $bookListRelTest = $c->find(); $search = []; foreach ($bookListRelTest as $obj) { - $search[]= $obj->getPrimaryKey(); + $search[] = $obj->getPrimaryKey(); } $q = new BookListRelQuery(); @@ -437,9 +521,11 @@ public function testFilterByPrimaryKeysCompositeKey() $q1 = BookListRelQuery::create(); $q1->add(null, '1<>1', Criteria::CUSTOM); $this->assertEquals($q1, $q, 'filterByPrimaryKeys() translates to an always failing test on empty arrays'); - } + /** + * @return void + */ public function testFilterByIntegerPk() { $q = BookQuery::create()->filterById(12); @@ -463,6 +549,9 @@ public function testFilterByIntegerPk() $this->assertEquals($q1, $q, 'filterByPkColumn() accepts a comparison when passed a simple array key'); } + /** + * @return void + */ public function testFilterByNumber() { $q = BookQuery::create()->filterByPrice(12); @@ -500,6 +589,9 @@ public function testFilterByNumber() $this->assertEquals($q1, $q, 'filterByNumColumn() translates to a between when passed both a \'min\' and a \'max\' key'); } + /** + * @return void + */ public function testFilterByTimestamp() { $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(12); @@ -529,6 +621,9 @@ public function testFilterByTimestamp() $this->assertEquals($q1, $q, 'filterByDateColumn() translates to a between when passed both a \'min\' and a \'max\' key'); } + /** + * @return void + */ public function testFilterByString() { $q = BookQuery::create()->filterByTitle('foo'); @@ -564,6 +659,9 @@ public function testFilterByString() $this->assertEquals($q1, $q, 'filterByStringColumn() accepts a comparison when passed a string with a % wildcard'); } + /** + * @return void + */ public function testFilterByBoolean() { $q = ReviewQuery::create()->filterByRecommended(true); @@ -609,9 +707,11 @@ public function testFilterByBoolean() $q = ReviewQuery::create()->filterByRecommended(''); $q1 = ReviewQuery::create()->add(ReviewTableMap::COL_RECOMMENDED, false, Criteria::EQUAL); $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = false when passed an empty string'); - } + /** + * @return void + */ public function testFilterByFk() { $this->assertTrue(method_exists('\Propel\Tests\Bookstore\BookQuery', 'filterByAuthor'), 'QueryBuilder adds filterByFk() methods'); @@ -621,6 +721,9 @@ public function testFilterByFk() $this->assertTrue(method_exists('\Propel\Tests\Bookstore\EssayQuery', 'filterBySecondAuthor'), 'QueryBuilder adds filterByFk() methods for several fkeys on the same table'); } + /** + * @return void + */ public function testFilterByFkSimpleKey() { BookstoreDataPopulator::depopulate(); @@ -646,6 +749,9 @@ public function testFilterByFkSimpleKey() $this->assertEquals($q1, $q, 'filterByFk() accepts an optional comparison operator'); } + /** + * @return void + */ public function testFilterByFkCompositeKey() { BookstoreDataPopulator::depopulate(); @@ -664,6 +770,9 @@ public function testFilterByFkCompositeKey() $this->assertEquals($testFavorite, $favorite, 'Generated query handles filterByFk() methods correctly for composite fkeys'); } + /** + * @return void + */ public function testFilterByFkObjectCollection() { BookstoreDataPopulator::depopulate($this->con); @@ -687,7 +796,10 @@ public function testFilterByFkObjectCollection() $this->assertEquals($q2, $q1, 'filterByFk() accepts a collection and results to an IN query'); } - public function testFilterByRefFk() + /** + * @return void + */ + public function testFilterByRefFk() { $this->assertTrue(method_exists('\Propel\Tests\Bookstore\BookQuery', 'filterByReview'), 'QueryBuilder adds filterByRefFk() methods'); $this->assertTrue(method_exists('\Propel\Tests\Bookstore\BookQuery', 'filterByMedia'), 'QueryBuilder adds filterByRefFk() methods for all fkeys'); @@ -696,6 +808,9 @@ public function testFilterByRefFk() $this->assertTrue(method_exists('\Propel\Tests\Bookstore\AuthorQuery', 'filterByEssayRelatedBySecondAuthorId'), 'QueryBuilder adds filterByRefFk() methods for several fkeys on the same table'); } + /** + * @return void + */ public function testFilterByRefFkSimpleKey() { BookstoreDataPopulator::depopulate(); @@ -721,6 +836,9 @@ public function testFilterByRefFkSimpleKey() $this->assertEquals($q1, $q, 'filterByRefFk() accepts an optional comparison operator'); } + /** + * @return void + */ public function testFilterByRelationNameCompositePk() { BookstoreDataPopulator::depopulate(); @@ -747,8 +865,9 @@ public function testFilterByRelationNameCompositePk() } /** - * @throws \Propel\Runtime\Exception\PropelException * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testFilterUsingCollectionByRelationNameCompositePk() { @@ -767,6 +886,9 @@ public function testFilterUsingCollectionByRelationNameCompositePk() $this->fail('Expected PropelException : filterBy{RelationName}() only accepts arguments of type {RelationName}'); } + /** + * @return void + */ public function testFilterByRefFkCompositeKey() { BookstoreDataPopulator::depopulate(); @@ -785,6 +907,9 @@ public function testFilterByRefFkCompositeKey() $this->assertEquals($testOpinion, $opinion, 'Generated query handles filterByRefFk() methods correctly for composite fkeys'); } + /** + * @return void + */ public function testFilterByRefFkObjectCollection() { BookstoreDataPopulator::depopulate($this->con); @@ -809,6 +934,9 @@ public function testFilterByRefFkObjectCollection() $this->assertEquals($q2, $q1, 'filterByRefFk() accepts a collection and results to an IN query in the joined table'); } + /** + * @return void + */ public function testFilterByCrossFK() { $this->assertTrue(method_exists('\Propel\Tests\Bookstore\BookQuery', 'filterByBookClubList'), 'Generated query handles filterByCrossRefFK() for many-to-many relationships'); @@ -822,6 +950,9 @@ public function testFilterByCrossFK() $this->assertEquals(2, $nbBooks, 'Generated query handles filterByCrossRefFK() methods correctly'); } + /** + * @return void + */ public function testJoinFk() { $q = BookQuery::create() @@ -851,10 +982,13 @@ public function testJoinFk() $q = EssayQuery::create() ->innerJoinSecondAuthor(); $q1 = EssayQuery::create() - ->join('Essay.SecondAuthor', "INNER JOIN"); + ->join('Essay.SecondAuthor', 'INNER JOIN'); $this->assertTrue($q->equals($q1), 'joinFk() translates to a "INNER JOIN" when this is defined as defaultJoin in the schema'); } + /** + * @return void + */ public function testJoinFkAlias() { $q = BookQuery::create('b') @@ -872,6 +1006,9 @@ public function testJoinFkAlias() $this->assertTrue($q->equals($q1), 'joinFk() works fine with true table aliases'); } + /** + * @return void + */ public function testJoinRefFk() { $q = AuthorQuery::create() @@ -905,6 +1042,9 @@ public function testJoinRefFk() $this->assertTrue($q->equals($q1), 'joinRefFk() translates to a "INNER JOIN" when this is defined as defaultJoin in the schema'); } + /** + * @return void + */ public function testUseFkQuerySimple() { $q = BookQuery::create() @@ -926,6 +1066,9 @@ public function testUseFkQuerySimple() $this->assertTrue($q->equals($q1), 'useFkQuery() translates to a condition on an inner join on required columns'); } + /** + * @return void + */ public function testUseFkQueryJoinType() { $q = BookQuery::create() @@ -938,6 +1081,9 @@ public function testUseFkQueryJoinType() $this->assertTrue($q->equals($q1), 'useFkQuery() accepts a join type as second parameter'); } + /** + * @return void + */ public function testUseFkQueryAlias() { $q = BookQuery::create() @@ -956,6 +1102,9 @@ public function testUseFkQueryAlias() $this->assertTrue($q->equals($q1), 'useFkQuery() uses the first argument as a table alias'); } + /** + * @return void + */ public function testUseFkQueryMixed() { $q = BookQuery::create() @@ -970,6 +1119,9 @@ public function testUseFkQueryMixed() $this->assertTrue($q->equals($q1), 'useFkQuery() allows combining conditions on main and related query'); } + /** + * @return void + */ public function testUseFkQueryTwice() { $q = BookQuery::create() @@ -986,6 +1138,9 @@ public function testUseFkQueryTwice() $this->assertTrue($q->equals($q1), 'useFkQuery() called twice on the same relation does not create two joins'); } + /** + * @return void + */ public function testUseFkQueryTwiceTwoAliases() { $q = BookQuery::create() @@ -1015,6 +1170,9 @@ public function testUseFkQueryTwiceTwoAliases() $this->assertTrue($q->equals($q1), 'useFkQuery() called twice on the same relation with two aliases creates two joins'); } + /** + * @return void + */ public function testUseFkQueryNested() { $q = ReviewQuery::create() @@ -1037,6 +1195,9 @@ public function testUseFkQueryNested() $this->assertEquals($expectedResult, $result, 'useFkQuery() called nested creates two joins'); } + /** + * @return void + */ public function testUseFkQueryTwoRelations() { $q = BookQuery::create() @@ -1054,6 +1215,9 @@ public function testUseFkQueryTwoRelations() $this->assertTrue($q->equals($q1), 'useFkQuery() called twice on two relations creates two joins'); } + /** + * @return void + */ public function testUseFkQueryNoAliasThenWith() { $con = Propel::getServiceContainer()->getReadConnection(BookTableMap::DATABASE_NAME); @@ -1072,12 +1236,18 @@ public function testUseFkQueryNoAliasThenWith() $this->assertEquals($q1, $q2, 'with() can be used after a call to useFkQuery() with no alias'); } + /** + * @return void + */ public function testPrune() { $q = BookQuery::create()->prune(); $this->assertTrue($q instanceof BookQuery, 'prune() returns the current Query object'); } + /** + * @return void + */ public function testPruneSimpleKey() { BookstoreDataPopulator::depopulate(); @@ -1091,6 +1261,9 @@ public function testPruneSimpleKey() $this->assertEquals(3, $nbBooks, 'prune() removes an object from the result'); } + /** + * @return void + */ public function testPruneCompositeKey() { BookstoreDataPopulator::depopulate(); diff --git a/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTestClasses.php b/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTestClasses.php index f845faf8e0..3ebafe075a 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTestClasses.php +++ b/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTestClasses.php @@ -14,10 +14,9 @@ use Propel\Runtime\Connection\ConnectionInterface; use Propel\Tests\Bookstore\BookQuery; - class myCustomBookQuery extends BookQuery { - public static function create($modelAlias = null, Criteria $criteria = null) + public static function create($modelAlias = null, ?Criteria $criteria = null) { if ($criteria instanceof myCustomBookQuery) { return $criteria; @@ -32,7 +31,6 @@ public static function create($modelAlias = null, Criteria $criteria = null) return $query; } - } class mySecondBookQuery extends BookQuery @@ -45,6 +43,9 @@ public function __construct($dbName = 'bookstore', $modelName = '\Propel\Tests\B parent::__construct($dbName, $modelName, $modelAlias); } + /** + * @return void + */ public function preSelect(ConnectionInterface $con) { self::$preSelectWasCalled = true; diff --git a/tests/Propel/Tests/Generator/Builder/Om/TableMapBuilderTest.php b/tests/Propel/Tests/Generator/Builder/Om/TableMapBuilderTest.php index dc0fc12ebf..a3c06b5d85 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/TableMapBuilderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/TableMapBuilderTest.php @@ -10,10 +10,10 @@ namespace Propel\Tests\Generator\Builder\Om; -use Propel\Runtime\Propel; use Propel\Runtime\Map\RelationMap; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Behavior\Map\Table1TableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Test class for TableMapBuilder. @@ -26,12 +26,18 @@ class TableMapBuilderTest extends BookstoreTestBase { protected $databaseMap; + /** + * @return void + */ protected function setUp(): void { parent::setUp(); $this->databaseMap = Propel::getServiceContainer()->getDatabaseMap('bookstore'); } + /** + * @return void + */ public function testColumnDefaultValue() { $table = $this->databaseMap->getTableByPhpName('\Propel\Tests\Bookstore\BookstoreEmployeeAccount'); @@ -60,6 +66,9 @@ public function testColumnDefaultValue() ); } + /** + * @return void + */ public function testRelationCount() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -70,6 +79,9 @@ public function testRelationCount() ); } + /** + * @return void + */ public function testSimpleRelationName() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -83,6 +95,9 @@ public function testSimpleRelationName() ); } + /** + * @return void + */ public function testAliasRelationName() { $bookEmpTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\BookstoreEmployee'); @@ -96,6 +111,9 @@ public function testAliasRelationName() ); } + /** + * @return void + */ public function testDuplicateRelationName() { $essayTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Essay'); @@ -109,6 +127,9 @@ public function testDuplicateRelationName() ); } + /** + * @return void + */ public function testRelationDirectionManyToOne() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -124,6 +145,9 @@ public function testRelationDirectionManyToOne() ); } + /** + * @return void + */ public function testRelationDirectionOneToMany() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -159,6 +183,9 @@ public function testRelationDirectionOneToMany() ); } + /** + * @return void + */ public function testRelationDirectionOneToOne() { $bookEmpTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\BookstoreEmployee'); @@ -169,6 +196,9 @@ public function testRelationDirectionOneToOne() ); } + /** + * @return void + */ public function testRelationDirectionManyToMAny() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -179,6 +209,9 @@ public function testRelationDirectionManyToMAny() ); } + /** + * @return void + */ public function testRelationsColumns() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -204,7 +237,7 @@ public function testRelationsColumns() $rfTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\ReaderFavorite'); $expectedMapping = [ 'reader_favorite.book_id' => 'book_opinion.book_id', - 'reader_favorite.reader_id' => 'book_opinion.reader_id' + 'reader_favorite.reader_id' => 'book_opinion.reader_id', ]; $this->assertEquals( $expectedMapping, @@ -219,6 +252,9 @@ public function testRelationsColumns() ); } + /** + * @return void + */ public function testRelationOnDelete() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -229,6 +265,9 @@ public function testRelationOnDelete() ); } + /** + * @return void + */ public function testRelationOnUpdate() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -243,6 +282,9 @@ public function testRelationOnUpdate() ); } + /** + * @return void + */ public function testBehaviors() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -265,8 +307,8 @@ public function testBehaviors() 'create_column' => 'created_on', 'update_column' => 'updated_on', 'disable_created_at' => 'false', - 'disable_updated_at' => 'false' - ] + 'disable_updated_at' => 'false', + ], ]; $this->assertEquals( $tmap->getBehaviors(), @@ -275,6 +317,9 @@ public function testBehaviors() ); } + /** + * @return void + */ public function testSingleTableInheritance() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -290,6 +335,9 @@ public function testSingleTableInheritance() ); } + /** + * @return void + */ public function testPrimaryString() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -301,6 +349,9 @@ public function testPrimaryString() ); } + /** + * @return void + */ public function testIsCrossRef() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); diff --git a/tests/Propel/Tests/Generator/Builder/Util/PropelTemplateTest.php b/tests/Propel/Tests/Generator/Builder/Util/PropelTemplateTest.php index be9ee1e2f1..62d36891a9 100644 --- a/tests/Propel/Tests/Generator/Builder/Util/PropelTemplateTest.php +++ b/tests/Propel/Tests/Generator/Builder/Util/PropelTemplateTest.php @@ -15,10 +15,12 @@ /** * Tests for PropelTemplate class - * */ class PropelTemplateTest extends TestCase { + /** + * @return void + */ public function testRenderStringNoParam() { $t = new PropelTemplate(); @@ -27,6 +29,9 @@ public function testRenderStringNoParam() $this->assertEquals('Hello, 3', $res); } + /** + * @return void + */ public function testRenderStringOneParam() { $t = new PropelTemplate(); @@ -35,6 +40,9 @@ public function testRenderStringOneParam() $this->assertEquals('Hello, John', $res); } + /** + * @return void + */ public function testRenderStringParams() { $time = time(); @@ -44,10 +52,13 @@ public function testRenderStringParams() $this->assertEquals('Hello, John, it is ' . $time . ' to go!', $res); } + /** + * @return void + */ public function testRenderFile() { $t = new PropelTemplate(); - $t->setTemplateFile(dirname(__FILE__).'/template.php'); + $t->setTemplateFile(dirname(__FILE__) . '/template.php'); $res = $t->render(['name' => 'John']); $this->assertEquals('Hello, John', $res); } diff --git a/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderJoinSchemaTest.php b/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderJoinSchemaTest.php index 1ba6c4ff2e..0ce83eea3d 100644 --- a/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderJoinSchemaTest.php +++ b/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderJoinSchemaTest.php @@ -11,11 +11,14 @@ namespace Propel\Tests\Generator\Builder\Util; use Propel\Generator\Builder\Util\SchemaReader; -use Propel\Tests\TestCase; use Propel\Generator\Platform\PgsqlPlatform; +use Propel\Tests\TestCase; class SchemaReaderJoinSchemaTest extends TestCase { + /** + * @return void + */ public function testJoinXmlSchemaWithMultipleDatabaseSchema() { $expectedSchema = <<assertEquals($xml, $schema->toString()); } + /** + * @return void + */ public function testParseStringSchemaWithoutXmlDeclaration() { if (defined('HHVM_VERSION')) { @@ -55,12 +61,17 @@ public function testParseStringSchemaWithoutXmlDeclaration() /** * @expectedException \Propel\Generator\Exception\SchemaException + * + * @return void */ public function testParseStringIncorrectSchema() { $this->reader->parseString(''); } + /** + * @return void + */ public function testParseStringDatabase() { $schema = $this->reader->parseString(''); @@ -75,6 +86,9 @@ public function testParseStringDatabase() $this->assertEquals($expectedSchema, $schema->toString()); } + /** + * @return void + */ public function testParseStringTable() { $xmlSchema = '
'; @@ -95,6 +109,9 @@ public function testParseStringTable() $this->assertEquals($expectedSchema, $schema->toString()); } + /** + * @return void + */ public function testParseFile() { $schema = $this->reader->parseFile($this->getSchemaFile('testSchema.xml')); @@ -111,6 +128,9 @@ public function testParseFile() $this->assertEquals($expectedSchema, $schema->toString()); } + /** + * @return void + */ public function testParseFileExternalSchema() { $schema = $this->reader->parseFile($this->getSchemaFile('outerSchema.xml')); @@ -130,11 +150,17 @@ public function testParseFileExternalSchema() $this->assertEquals($expectedSchema, $schema->toString()); } + /** + * @return void + */ protected function setUp(): void { $this->reader = new SchemaReader(); } + /** + * @return void + */ protected function tearDown(): void { $this->reader = null; diff --git a/tests/Propel/Tests/Generator/Command/AbstractCommandTest.php b/tests/Propel/Tests/Generator/Command/AbstractCommandTest.php index d0d5064cc8..9ece2e5445 100644 --- a/tests/Propel/Tests/Generator/Command/AbstractCommandTest.php +++ b/tests/Propel/Tests/Generator/Command/AbstractCommandTest.php @@ -24,11 +24,17 @@ class AbstractCommandTest extends TestCase { protected $command; + /** + * @return void + */ public function setUp(): void { $this->command = new TestableAbstractCommand(); } + /** + * @return void + */ public function testParseConnection() { $password = 'H7{“Qj1n>\%28=;P'; @@ -42,6 +48,9 @@ public function testParseConnection() $this->assertEquals($password, $result[2]['password']); } + /** + * @return void + */ public function testRecursiveSearch() { $app = new Application(); @@ -52,8 +61,8 @@ public function testRecursiveSearch() $tester->execute( [ 'command' => 'testable-command', - '--config-dir' => realpath(__DIR__ . '/../../../../Fixtures/recursive'), - '--recursive' => true + '--config-dir' => realpath(__DIR__ . '/../../../../Fixtures/recursive'), + '--recursive' => true, ] ); @@ -62,8 +71,8 @@ public function testRecursiveSearch() $tester->execute( [ 'command' => 'testable-command', - '--config-dir' => realpath(__DIR__ . '/../../../../Fixtures/recursive'), - '--recursive' => false + '--config-dir' => realpath(__DIR__ . '/../../../../Fixtures/recursive'), + '--recursive' => false, ] ); @@ -73,6 +82,9 @@ public function testRecursiveSearch() class TestableAbstractCommand extends AbstractCommand { + /** + * @return void + */ protected function configure() { parent::configure(); diff --git a/tests/Propel/Tests/Generator/Command/DatabaseReverseTest.php b/tests/Propel/Tests/Generator/Command/DatabaseReverseTest.php index 8a38e3d451..72c520da7d 100644 --- a/tests/Propel/Tests/Generator/Command/DatabaseReverseTest.php +++ b/tests/Propel/Tests/Generator/Command/DatabaseReverseTest.php @@ -7,12 +7,17 @@ use Propel\Runtime\Propel; use Propel\Tests\TestCaseFixturesDatabase; use Symfony\Component\Console\Application; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Output\StreamOutput; /** * @group database */ class DatabaseReverseTest extends TestCaseFixturesDatabase { + /** + * @return void + */ public function testCommandWithoutNamespace() { $app = new Application('Propel', Propel::VERSION); @@ -24,16 +29,16 @@ public function testCommandWithoutNamespace() chdir(__DIR__ . '/../../../../Fixtures/bookstore'); - $input = new \Symfony\Component\Console\Input\ArrayInput([ + $input = new ArrayInput([ 'command' => 'database:reverse', '--database-name' => 'reverse-test', '--output-dir' => $outputDir, '--verbose' => true, '--platform' => ucfirst($this->getDriver()) . 'Platform', - 'connection' => $this->getConnectionDsn('bookstore-schemas', true) + 'connection' => $this->getConnectionDsn('bookstore-schemas', true), ]); - $output = new \Symfony\Component\Console\Output\StreamOutput(fopen("php://temp", 'r+')); + $output = new StreamOutput(fopen('php://temp', 'r+')); $app->setAutoExit(false); $result = $app->run($input, $output); @@ -48,7 +53,7 @@ public function testCommandWithoutNamespace() $databaseXml = simplexml_load_file($outputDir . '/schema.xml'); $this->assertEquals('reverse-test', $databaseXml['name']); - $this->assertGreaterThan(20, $databaseXml->xpath("table")); + $this->assertGreaterThan(20, $databaseXml->xpath('table')); $table = $databaseXml->xpath("table[@name='acct_access_role']"); $this->assertCount(1, $table); @@ -58,6 +63,9 @@ public function testCommandWithoutNamespace() $this->assertCount(2, $table->xpath('column')); } + /** + * @return void + */ public function testCommandWithNamespace() { $app = new Application('Propel', Propel::VERSION); @@ -70,17 +78,17 @@ public function testCommandWithNamespace() chdir(__DIR__ . '/../../../../Fixtures/bookstore'); - $input = new \Symfony\Component\Console\Input\ArrayInput([ + $input = new ArrayInput([ 'command' => 'database:reverse', '--database-name' => 'reverse-test', '--output-dir' => $outputDir, '--verbose' => true, '--platform' => ucfirst($this->getDriver()) . 'Platform', '--namespace' => $testNamespace, - 'connection' => $this->getConnectionDsn('bookstore-schemas', true) + 'connection' => $this->getConnectionDsn('bookstore-schemas', true), ]); - $output = new \Symfony\Component\Console\Output\StreamOutput(fopen("php://temp", 'r+')); + $output = new StreamOutput(fopen('php://temp', 'r+')); $app->setAutoExit(false); $result = $app->run($input, $output); @@ -95,5 +103,4 @@ public function testCommandWithNamespace() $databaseXml = simplexml_load_file($outputDir . '/schema.xml'); $this->assertEquals($testNamespace, $databaseXml['namespace']); } - } diff --git a/tests/Propel/Tests/Generator/Command/GraphvizGenerateTest.php b/tests/Propel/Tests/Generator/Command/GraphvizGenerateTest.php index d6eca72d56..b0f4451005 100644 --- a/tests/Propel/Tests/Generator/Command/GraphvizGenerateTest.php +++ b/tests/Propel/Tests/Generator/Command/GraphvizGenerateTest.php @@ -6,26 +6,31 @@ use Propel\Runtime\Propel; use Propel\Tests\TestCaseFixtures; use Symfony\Component\Console\Application; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Output\StreamOutput; class GraphvizGenerateTest extends TestCaseFixtures { + /** + * @return void + */ public function testCommand() { $app = new Application('Propel', Propel::VERSION); $command = new GraphvizGenerateCommand(); $app->add($command); - $outputDir = __DIR__.'/../../../../graphviztest'; + $outputDir = __DIR__ . '/../../../../graphviztest'; - $input = new \Symfony\Component\Console\Input\ArrayInput([ + $input = new ArrayInput([ 'command' => 'graphviz:generate', '--schema-dir' => __DIR__ . '/../../../../Fixtures/bookstore', '--config-dir' => __DIR__ . '/../../../../Fixtures/bookstore', '--output-dir' => $outputDir, - '--verbose' => true + '--verbose' => true, ]); - $output = new \Symfony\Component\Console\Output\StreamOutput(fopen("php://temp", 'r+')); + $output = new StreamOutput(fopen('php://temp', 'r+')); $app->setAutoExit(false); $result = $app->run($input, $output); @@ -36,9 +41,8 @@ public function testCommand() $this->assertEquals(0, $result, 'graphviz:generate tests exited successfully'); - $this->assertFileExists($outputDir.'/bookstore.schema.dot'); - $content = file_get_contents($outputDir.'/bookstore.schema.dot'); + $this->assertFileExists($outputDir . '/bookstore.schema.dot'); + $content = file_get_contents($outputDir . '/bookstore.schema.dot'); $this->assertContains('digraph G {', $content); } - -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Generator/Command/InitCommandTest.php b/tests/Propel/Tests/Generator/Command/InitCommandTest.php index aafa014992..2a6854f1a2 100644 --- a/tests/Propel/Tests/Generator/Command/InitCommandTest.php +++ b/tests/Propel/Tests/Generator/Command/InitCommandTest.php @@ -25,18 +25,25 @@ */ class InitCommandTest extends TestCaseFixtures { - /** @var string */ + /** + * @var string + */ private $dir; - /** @var string */ + /** + * @var string + */ private $currentDir; + /** + * @return void + */ public function setUp(): void { parent::setUp(); - $this->dir = sys_get_temp_dir() . "/propel_init"; - $filesystem= new Filesystem(); + $this->dir = sys_get_temp_dir() . '/propel_init'; + $filesystem = new Filesystem(); if ($filesystem->exists($this->dir)) { $filesystem->remove($this->dir); } @@ -46,6 +53,9 @@ public function setUp(): void chdir($this->dir); } + /** + * @return void + */ public function testExecute() { if (!method_exists(CommandTester::class, 'setInputs')) { @@ -57,7 +67,7 @@ public function testExecute() new InitCommand(), new ModelBuildCommand(), new SqlBuildCommand(), - new ConfigConvertCommand() + new ConfigConvertCommand(), ]); $command = $app->find('init'); @@ -77,6 +87,9 @@ public function testExecute() $this->assertTrue(file_exists($this->dir . '/generated-sql/default.sql'), 'Sql file from example schema created.'); } + /** + * @return void + */ public function testExecuteAborted() { if (!method_exists(CommandTester::class, 'setInputs')) { @@ -88,13 +101,13 @@ public function testExecuteAborted() new InitCommand(), new ModelBuildCommand(), new SqlBuildCommand(), - new ConfigConvertCommand() + new ConfigConvertCommand(), ]); $command = $app->find('init'); $commandTester = new CommandTester($command); $commandTester->setInputs($this->getInputsArray('no')); - $commandTester->execute(['command' => $command->getName()]); + $commandTester->execute(['command' => $command->getName()]); $this->assertContains('Process aborted', $commandTester->getDisplay()); } @@ -112,13 +125,12 @@ private function getInputsArray($lastAnswer = 'yes') } return $element; - }, $dsnArray); $inputs = []; $firstDsnElement = array_shift($dsnArray); if ($firstDsnElement) { - $inputs[] = $firstDsnElement; + $inputs[] = $firstDsnElement; } if ($this->getDriver() !== 'sqlite') { @@ -135,7 +147,7 @@ private function getInputsArray($lastAnswer = 'yes') $this->dir . '/Model/', 'Init\\Command\\Namespace', 'yml', - $lastAnswer + $lastAnswer, ]); return $inputs; diff --git a/tests/Propel/Tests/Generator/Command/MigrationTest.php b/tests/Propel/Tests/Generator/Command/MigrationTest.php index 08cafdf818..7cd3f1fb04 100644 --- a/tests/Propel/Tests/Generator/Command/MigrationTest.php +++ b/tests/Propel/Tests/Generator/Command/MigrationTest.php @@ -2,14 +2,16 @@ namespace Propel\Tests\Generator\Command; +use Propel\Generator\Command\MigrationCreateCommand; use Propel\Generator\Command\MigrationDiffCommand; use Propel\Generator\Command\MigrationDownCommand; use Propel\Generator\Command\MigrationMigrateCommand; use Propel\Generator\Command\MigrationUpCommand; -use Propel\Generator\Command\MigrationCreateCommand; use Propel\Runtime\Propel; use Propel\Tests\TestCaseFixturesDatabase; use Symfony\Component\Console\Application; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Output\StreamOutput; /** * @group database @@ -19,20 +21,29 @@ class MigrationTest extends TestCaseFixturesDatabase protected static $output = '/../../../../migrationdiff'; protected $connectionOption; + protected $configDir; + protected $schemaDir; + protected $outputDir; + /** + * @return void + */ public function setUp(): void { parent::setUp(); - $this->connectionOption = ['migration_command=' . $this->getConnectionDsn('bookstore', true)]; + $this->connectionOption = ['migration_command=' . $this->getConnectionDsn('bookstore', true)]; $this->connectionOption = str_replace('dbname=test', 'dbname=migration', $this->connectionOption); $this->configDir = __DIR__ . '/../../../../Fixtures/migration-command'; $this->schemaDir = __DIR__ . '/../../../../Fixtures/migration-command'; $this->outputDir = __DIR__ . self::$output; } + /** + * @return void + */ public function testDiffCommand() { $app = new Application('Propel', Propel::VERSION); @@ -44,17 +55,17 @@ public function testDiffCommand() unlink($file); } - $input = new \Symfony\Component\Console\Input\ArrayInput([ + $input = new ArrayInput([ 'command' => 'migration:diff', '--schema-dir' => $this->schemaDir, '--config-dir' => $this->configDir, '--output-dir' => $this->outputDir, '--platform' => ucfirst($this->getDriver()) . 'Platform', '--connection' => $this->connectionOption, - '--verbose' => true + '--verbose' => true, ]); - $output = new \Symfony\Component\Console\Output\StreamOutput(fopen("php://temp", 'r+')); + $output = new StreamOutput(fopen('php://temp', 'r+')); $app->setAutoExit(false); $result = $app->run($input, $output); @@ -70,10 +81,13 @@ public function testDiffCommand() $file = $files[0]; $content = file_get_contents($file); - $this->assertGreaterThanOrEqual(2, substr_count($content, "CREATE TABLE ")); + $this->assertGreaterThanOrEqual(2, substr_count($content, 'CREATE TABLE ')); $this->assertContains('CREATE TABLE ', $content); } + /** + * @return void + */ public function testDiffCommandUsingSuffix() { $app = new Application('Propel', Propel::VERSION); @@ -85,7 +99,7 @@ public function testDiffCommandUsingSuffix() unlink($file); } - $input = new \Symfony\Component\Console\Input\ArrayInput([ + $input = new ArrayInput([ 'command' => 'migration:diff', '--schema-dir' => $this->schemaDir, '--config-dir' => $this->configDir, @@ -93,10 +107,10 @@ public function testDiffCommandUsingSuffix() '--platform' => ucfirst($this->getDriver()) . 'Platform', '--connection' => $this->connectionOption, '--suffix' => 'an_explanatory_filename_suffix', - '--verbose' => true + '--verbose' => true, ]); - $output = new \Symfony\Component\Console\Output\StreamOutput(fopen("php://temp", 'r+')); + $output = new StreamOutput(fopen('php://temp', 'r+')); $app->setAutoExit(false); $result = $app->run($input, $output); @@ -112,26 +126,29 @@ public function testDiffCommandUsingSuffix() $file = $files[0]; $content = file_get_contents($file); - $this->assertGreaterThanOrEqual(2, substr_count($content, "CREATE TABLE ")); + $this->assertGreaterThanOrEqual(2, substr_count($content, 'CREATE TABLE ')); $this->assertContains('CREATE TABLE ', $content); } + /** + * @return void + */ public function testUpCommand() { $app = new Application('Propel', Propel::VERSION); $command = new MigrationUpCommand(); $app->add($command); - $input = new \Symfony\Component\Console\Input\ArrayInput([ + $input = new ArrayInput([ 'command' => 'migration:up', '--config-dir' => $this->configDir, '--output-dir' => $this->outputDir, '--platform' => ucfirst($this->getDriver()) . 'Platform', '--connection' => $this->connectionOption, - '--verbose' => true + '--verbose' => true, ]); - $output = new \Symfony\Component\Console\Output\StreamOutput(fopen("php://temp", 'r+')); + $output = new StreamOutput(fopen('php://temp', 'r+')); $app->setAutoExit(false); $result = $app->run($input, $output); @@ -145,22 +162,25 @@ public function testUpCommand() $this->assertContains('Migration complete.', $outputString); } + /** + * @return void + */ public function testDownCommand() { $app = new Application('Propel', Propel::VERSION); $command = new MigrationDownCommand(); $app->add($command); - $input = new \Symfony\Component\Console\Input\ArrayInput([ + $input = new ArrayInput([ 'command' => 'migration:down', '--config-dir' => $this->configDir, '--output-dir' => $this->outputDir, '--platform' => ucfirst($this->getDriver()) . 'Platform', '--connection' => $this->connectionOption, - '--verbose' => true + '--verbose' => true, ]); - $output = new \Symfony\Component\Console\Output\StreamOutput(fopen("php://temp", 'r+')); + $output = new StreamOutput(fopen('php://temp', 'r+')); $app->setAutoExit(false); $result = $app->run($input, $output); @@ -174,22 +194,25 @@ public function testDownCommand() $this->assertContains('Reverse migration complete.', $outputString); } + /** + * @return void + */ public function testMigrateCommand() { $app = new Application('Propel', Propel::VERSION); $command = new MigrationMigrateCommand(); $app->add($command); - $input = new \Symfony\Component\Console\Input\ArrayInput([ + $input = new ArrayInput([ 'command' => 'migration:migrate', '--config-dir' => $this->configDir, '--output-dir' => $this->outputDir, '--platform' => ucfirst($this->getDriver()) . 'Platform', '--connection' => $this->connectionOption, - '--verbose' => true + '--verbose' => true, ]); - $output = new \Symfony\Component\Console\Output\StreamOutput(fopen("php://temp", 'r+')); + $output = new StreamOutput(fopen('php://temp', 'r+')); $app->setAutoExit(false); $result = $app->run($input, $output); @@ -206,6 +229,9 @@ public function testMigrateCommand() $this->testDownCommand(); } + /** + * @return void + */ public function testCreateCommand() { $app = new Application('Propel', Propel::VERSION); @@ -217,17 +243,17 @@ public function testCreateCommand() unlink($file); } - $input = new \Symfony\Component\Console\Input\ArrayInput([ + $input = new ArrayInput([ 'command' => 'migration:create', '--schema-dir' => $this->schemaDir, '--config-dir' => $this->configDir, '--output-dir' => $this->outputDir, '--platform' => ucfirst($this->getDriver()) . 'Platform', '--connection' => $this->connectionOption, - '--verbose' => true + '--verbose' => true, ]); - $output = new \Symfony\Component\Console\Output\StreamOutput(fopen("php://temp", 'r+')); + $output = new StreamOutput(fopen('php://temp', 'r+')); $app->setAutoExit(false); $result = $app->run($input, $output); @@ -246,6 +272,9 @@ public function testCreateCommand() $this->assertNotContains('CREATE TABLE ', $content); } + /** + * @return void + */ public function testCreateCommandUsingSuffix() { $app = new Application('Propel', Propel::VERSION); @@ -257,7 +286,7 @@ public function testCreateCommandUsingSuffix() unlink($file); } - $input = new \Symfony\Component\Console\Input\ArrayInput([ + $input = new ArrayInput([ 'command' => 'migration:create', '--schema-dir' => $this->schemaDir, '--config-dir' => $this->configDir, @@ -265,10 +294,10 @@ public function testCreateCommandUsingSuffix() '--platform' => ucfirst($this->getDriver()) . 'Platform', '--connection' => $this->connectionOption, '--suffix' => 'an_explanatory_filename_suffix', - '--verbose' => true + '--verbose' => true, ]); - $output = new \Symfony\Component\Console\Output\StreamOutput(fopen("php://temp", 'r+')); + $output = new StreamOutput(fopen('php://temp', 'r+')); $app->setAutoExit(false); $result = $app->run($input, $output); @@ -286,5 +315,4 @@ public function testCreateCommandUsingSuffix() $content = file_get_contents($file); $this->assertNotContains('CREATE TABLE ', $content); } - } diff --git a/tests/Propel/Tests/Generator/Config/ArrayToPhpConverterTest.php b/tests/Propel/Tests/Generator/Config/ArrayToPhpConverterTest.php index 7dce137387..032424cd9d 100644 --- a/tests/Propel/Tests/Generator/Config/ArrayToPhpConverterTest.php +++ b/tests/Propel/Tests/Generator/Config/ArrayToPhpConverterTest.php @@ -15,6 +15,9 @@ class ArrayToPhpConverterTest extends TestCase { + /** + * @return void + */ public function testConvertConvertsSimpleDatasourceSection() { $conf = [ @@ -25,10 +28,10 @@ public function testConvertConvertsSimpleDatasourceSection() 'dsn' => 'mysql:host=localhost;dbname=bookstore', 'user' => 'testuser', 'password' => 'password', - 'options' => ['ATTR_PERSISTENT' => false], - 'attributes' => ['ATTR_EMULATE_PREPARES' => true] - ] - ] + 'options' => ['ATTR_PERSISTENT' => false], + 'attributes' => ['ATTR_EMULATE_PREPARES' => true], + ], + ], ]; $expected = <<assertEquals($expected, ArrayToPhpConverter::convert($conf)); } + /** + * @return void + */ public function testConvertConvertsMasterSlaveDatasourceSection() { $conf = [ @@ -65,10 +71,10 @@ public function testConvertConvertsMasterSlaveDatasourceSection() 'dsn' => 'mysql:host=localhost;dbname=bookstore', 'slaves' => [ ['dsn' => 'mysql:host=slave-server1; dbname=bookstore'], - ['dsn' => 'mysql:host=slave-server2; dbname=bookstore'] - ] - ] - ] + ['dsn' => 'mysql:host=slave-server2; dbname=bookstore'], + ], + ], + ], ]; $expected = <<<'EOF' $serviceContainer = \Propel\Runtime\Propel::getServiceContainer(); @@ -95,15 +101,19 @@ public function testConvertConvertsMasterSlaveDatasourceSection() $this->assertEquals($expected, ArrayToPhpConverter::convert($conf)); } + /** + * @return void + */ public function testConvertConvertsProfilerSection() { - $conf = ['profiler' => [ + $conf = [ + 'profiler' => [ 'classname' => '\Propel\Runtime\Util\Profiler', 'slowTreshold' => 0.2, 'time' => ['precision' => 3, 'pad' => '8'], 'memory' => ['precision' => 3, 'pad' => '8'], 'innerGlue' => ': ', - 'outerGlue' => ' | ' + 'outerGlue' => ' | ', ]]; $expected = <<<'EOF' $serviceContainer = \Propel\Runtime\Propel::getServiceContainer(); @@ -128,9 +138,14 @@ public function testConvertConvertsProfilerSection() $this->assertEquals($expected, ArrayToPhpConverter::convert($conf)); } + /** + * @return void + */ public function testConvertConvertsLogSection() { - $conf = ['log' => ['defaultLogger' => [ + $conf = [ + 'log' => [ + 'defaultLogger' => [ 'type' => 'stream', 'level' => '300', 'path' => '/var/log/propel.log', @@ -147,18 +162,22 @@ public function testConvertConvertsLogSection() $this->assertEquals($expected, ArrayToPhpConverter::convert($conf)); } + /** + * @return void + */ public function testConvertConvertsLogSectionWithMultipleLoggers() { - $conf = ['log' => [ + $conf = [ + 'log' => [ 'defaultLogger' => [ 'type' => 'stream', 'path' => '/var/log/propel.log', - 'level' => '300' + 'level' => '300', ], 'bookstoreLogger' => [ 'type' => 'stream', 'path' => '/var/log/propel_bookstore.log', - ] + ], ]]; $expected = <<<'EOF' $serviceContainer = \Propel\Runtime\Propel::getServiceContainer(); @@ -176,10 +195,14 @@ public function testConvertConvertsLogSectionWithMultipleLoggers() $this->assertEquals($expected, ArrayToPhpConverter::convert($conf)); } + /** + * @return void + */ public function testConvertConvertsCompleteConfiguration() { $conf = [ - 'log' => ['defaultLogger' => [ + 'log' => [ + 'defaultLogger' => [ 'type' => 'stream', 'level' => '300', 'path' => '/var/log/propel.log', @@ -210,7 +233,7 @@ public function testConvertConvertsCompleteConfiguration() ], ], ], - 'defaultConnection' => 'bookstore' + 'defaultConnection' => 'bookstore', ]; $expected = <<<'EOF' $serviceContainer = \Propel\Runtime\Propel::getServiceContainer(); @@ -263,4 +286,4 @@ public function testConvertConvertsCompleteConfiguration() EOF; $this->assertEquals($expected, ArrayToPhpConverter::convert($conf)); } -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php b/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php index 0d7de13b9f..49837cfdfd 100644 --- a/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php +++ b/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php @@ -12,24 +12,31 @@ use Propel\Generator\Config\GeneratorConfig; use Propel\Tests\Common\Config\ConfigTestCase; +use ReflectionClass; /** * @author William Durand * @author Cristiano Cinotti - * @package propel.generator.config + * @package propel.generator.config */ class GeneratorConfigTest extends ConfigTestCase { protected $generatorConfig; + /** + * @return void + */ public function setConfig($config) { - $ref = new \ReflectionClass('\\Propel\\Common\\Config\\ConfigurationManager'); + $ref = new ReflectionClass('\\Propel\\Common\\Config\\ConfigurationManager'); $refProp = $ref->getProperty('config'); $refProp->setAccessible(true); $refProp->setValue($this->generatorConfig, $config); } + /** + * @return void + */ public function setUp(): void { $php = " @@ -78,6 +85,9 @@ public function setUp(): void $this->generatorConfig = new GeneratorConfig(sys_get_temp_dir() . '/propel.php.dist'); } + /** + * @return void + */ public function testGetConfiguredPlatformDeafult() { $actual = $this->generatorConfig->getConfiguredPlatform(); @@ -85,6 +95,9 @@ public function testGetConfiguredPlatformDeafult() $this->assertInstanceOf('\\Propel\\Generator\\Platform\\MysqlPlatform', $actual); } + /** + * @return void + */ public function testGetConfiguredPlatformGivenDatabaseName() { $actual = $this->generatorConfig->getConfiguredPlatform(null, 'mysource'); @@ -92,6 +105,9 @@ public function testGetConfiguredPlatformGivenDatabaseName() $this->assertInstanceOf('\\Propel\\Generator\\Platform\\SqlitePlatform', $actual); } + /** + * @return void + */ public function testGetConfiguredPlatform() { $this->setConfig(['generator' => ['platformClass' => '\\Propel\\Generator\\Platform\\PgsqlPlatform']]); @@ -102,12 +118,17 @@ public function testGetConfiguredPlatform() /** * @expectedException Propel\Generator\Exception\InvalidArgumentException * @expectedExceptionMessage Invalid database name: no configured connection named `badsource`. + * + * @return void */ public function testGetConfiguredPlatformGivenBadDatabaseNameThrowsException() { $this->generatorConfig->getConfiguredPlatform(null, 'badsource'); } + /** + * @return void + */ public function testGetConfiguredPlatformGivenPlatform() { $this->setConfig(['generator' => ['platformClass' => '\\Propel\\Generator\\Platform\\PgsqlPlatform']]); @@ -116,6 +137,9 @@ public function testGetConfiguredPlatformGivenPlatform() $this->assertInstanceOf('\\Propel\\Generator\\Platform\\PgsqlPlatform', $actual); } + /** + * @return void + */ public function testGetConfiguredSchemaParserDefaultClass() { $stubCon = $this->getMockBuilder('\\Propel\\Runtime\\Connection\\ConnectionWrapper') @@ -126,12 +150,16 @@ public function testGetConfiguredSchemaParserDefaultClass() $this->assertInstanceOf('\\Propel\\Generator\\Reverse\\SqliteSchemaParser', $actual); } + /** + * @return void + */ public function testGetConfiguredSchemaParserGivenClass() { $this->setConfig( - ['migrations' => [ + [ + 'migrations' => [ 'tableName' => 'propel_migration', - 'parserClass' => '\\Propel\\Generator\\Reverse\\PgsqlSchemaParser' + 'parserClass' => '\\Propel\\Generator\\Reverse\\PgsqlSchemaParser', ]] ); $stubCon = $this->getMockBuilder('\\Propel\\Runtime\\Connection\\ConnectionWrapper') @@ -145,13 +173,16 @@ public function testGetConfiguredSchemaParserGivenClass() /** * @expectedException Propel\Generator\Exception\BuildException * @expectedExceptionMessage Specified class (\Propel\Generator\Platform\MysqlPlatform) does not implement \Propel\Generator\Reverse\SchemaParserInterface interface. + * + * @return void */ public function testGetConfiguredSchemaParserGivenNonSchemaParserClass() { $this->setConfig( - ['migrations' => [ + [ + 'migrations' => [ 'tableName' => 'propel_migration', - 'parserClass' => '\\Propel\\Generator\\Platform\\MysqlPlatform' + 'parserClass' => '\\Propel\\Generator\\Platform\\MysqlPlatform', ]] ); @@ -163,13 +194,16 @@ public function testGetConfiguredSchemaParserGivenNonSchemaParserClass() /** * @expectedException Propel\Generator\Exception\ClassNotFoundException * @expectedExceptionMessage Reverse SchemaParser class for `\Propel\Generator\Reverse\BadSchemaParser` not found. + * + * @return void */ public function testGetConfiguredSchemaParserGivenBadClass() { $this->setConfig( - ['migrations' => [ + [ + 'migrations' => [ 'tableName' => 'propel_migration', - 'parserClass' => '\\Propel\\Generator\\Reverse\\BadSchemaParser' + 'parserClass' => '\\Propel\\Generator\\Reverse\\BadSchemaParser', ]] ); @@ -178,6 +212,9 @@ public function testGetConfiguredSchemaParserGivenBadClass() $this->assertInstanceOf('\\Propel\\Generator\\Reverse\\PgsqlSchemaParser', $actual); } + /** + * @return void + */ public function testGetConfiguredBuilder() { $stubTable = $this->getMockBuilder('\\Propel\\Generator\\Model\\Table')->getMock(); @@ -188,6 +225,8 @@ public function testGetConfiguredBuilder() /** * @expectedException Propel\Generator\Exception\ClassNotFoundException + * + * @return void */ public function testGetConfiguredBuilderWrongTypeThrowsException() { @@ -195,6 +234,9 @@ public function testGetConfiguredBuilderWrongTypeThrowsException() $actual = $this->generatorConfig->getConfiguredBuilder($stubTable, 'bad_type'); } + /** + * @return void + */ public function testGetConfiguredPluralizer() { $actual = $this->generatorConfig->getConfiguredPluralizer(); @@ -210,6 +252,8 @@ public function testGetConfiguredPluralizer() /** * @expectedException Propel\Generator\Exception\ClassNotFoundException * @expectedExceptionMessage Class \Propel\Common\Pluralizer\WrongEnglishPluralizer not found. + * + * @return void */ public function testGetConfiguredPluralizerNonExistentClassThrowsException() { @@ -222,6 +266,8 @@ public function testGetConfiguredPluralizerNonExistentClassThrowsException() /** * @expectedException Propel\Generator\Exception\BuildException * @expectedExceptionMessage Specified class (\Propel\Common\Config\PropelConfiguration) does not implement + * + * @return void */ public function testGetConfiguredPluralizerWrongClassThrowsException() { @@ -231,6 +277,9 @@ public function testGetConfiguredPluralizerWrongClassThrowsException() $actual = $this->generatorConfig->getConfiguredPluralizer(); } + /** + * @return void + */ public function testGetBuildConnections() { $expected = [ @@ -242,8 +291,8 @@ public function testGetBuildConnections() 'password' => '', 'model_paths' => [ 'src', - 'vendor' - ] + 'vendor', + ], ], 'yoursource' => [ 'adapter' => 'mysql', @@ -253,9 +302,9 @@ public function testGetBuildConnections() 'password' => '', 'model_paths' => [ 'src', - 'vendor' - ] - ] + 'vendor', + ], + ], ]; $actual = $this->generatorConfig->getBuildConnections(); @@ -263,6 +312,9 @@ public function testGetBuildConnections() $this->assertEquals($expected, $actual); } + /** + * @return void + */ public function testGetBuildConnection() { $expected = [ @@ -273,8 +325,8 @@ public function testGetBuildConnection() 'password' => '', 'model_paths' => [ 'src', - 'vendor' - ] + 'vendor', + ], ]; $actual = $this->generatorConfig->getBuildConnection(); @@ -282,6 +334,9 @@ public function testGetBuildConnection() $this->assertEquals($expected, $actual); } + /** + * @return void + */ public function testGetBuildConnectionGivenDatabase() { $expected = [ @@ -292,8 +347,8 @@ public function testGetBuildConnectionGivenDatabase() 'password' => '', 'model_paths' => [ 'src', - 'vendor' - ] + 'vendor', + ], ]; $actual = $this->generatorConfig->getBuildConnection('yoursource'); @@ -304,12 +359,17 @@ public function testGetBuildConnectionGivenDatabase() /** * @expectedException Propel\Generator\Exception\InvalidArgumentException * @expectedExceptionMessage Invalid database name: no configured connection named `wrongsource`. + * + * @return void */ public function testGetBuildConnectionGivenWrongDatabaseThrowsException() { $actual = $this->generatorConfig->getBuildConnection('wrongsource'); } + /** + * @return void + */ public function testGetConnectionDefault() { $actual = $this->generatorConfig->getConnection(); @@ -317,6 +377,9 @@ public function testGetConnectionDefault() $this->assertInstanceOf('\\Propel\\Runtime\\Connection\\ConnectionWrapper', $actual); } + /** + * @return void + */ public function testGetConnection() { $actual = $this->generatorConfig->getConnection('mysource'); @@ -327,12 +390,17 @@ public function testGetConnection() /** * @expectedException Propel\Generator\Exception\InvalidArgumentException * @expectedExceptionMessage Invalid database name: no configured connection named `badsource`. + * + * @return void */ public function testGetConnectionWrongDatabaseThrowsException() { $actual = $this->generatorConfig->getConnection('badsource'); } + /** + * @return void + */ public function testGetBehaviorLocator() { $actual = $this->generatorConfig->getBehaviorLocator(); diff --git a/tests/Propel/Tests/Generator/Config/QuickGeneratorConfigTest.php b/tests/Propel/Tests/Generator/Config/QuickGeneratorConfigTest.php index 645d78c8a1..172e18231b 100644 --- a/tests/Propel/Tests/Generator/Config/QuickGeneratorConfigTest.php +++ b/tests/Propel/Tests/Generator/Config/QuickGeneratorConfigTest.php @@ -17,11 +17,17 @@ class QuickGeneratorConfigTest extends TestCase { protected $generatorConfig; + /** + * @return void + */ public function setUp(): void { $this->generatorConfig = new QuickGeneratorConfig(); } + /** + * @return void + */ public function testGetConfiguredBuilder() { $stubTable = $this->getMockBuilder('\\Propel\\Generator\\Model\\Table')->getMock(); @@ -33,6 +39,8 @@ public function testGetConfiguredBuilder() /** * @expectedException Propel\Generator\Exception\InvalidArgumentException * @expectedExceptionMessage Invalid data model builder type `bad_type` + * + * @return void */ public function testGetConfiguredBuilderWrongTypeThrowsException() { @@ -40,6 +48,9 @@ public function testGetConfiguredBuilderWrongTypeThrowsException() $actual = $this->generatorConfig->getConfiguredBuilder($stubTable, 'bad_type'); } + /** + * @return void + */ public function testGetConfiguredPluralizer() { $actual = $this->generatorConfig->getConfiguredPluralizer(); @@ -47,11 +58,17 @@ public function testGetConfiguredPluralizer() $this->assertInstanceOf('\\Propel\\Common\\Pluralizer\\StandardEnglishPluralizer', $actual); } + /** + * @return void + */ public function testGetConfiguredPlatform() { $this->assertNull($this->generatorConfig->getConfiguredPlatform()); } + /** + * @return void + */ public function testGetBehaviorLocator() { $actual = $this->generatorConfig->getBehaviorLocator(); @@ -59,6 +76,9 @@ public function testGetBehaviorLocator() $this->assertInstanceOf('\\Propel\\Generator\\Util\\BehaviorLocator', $actual); } + /** + * @return void + */ public function testPassExtraConfigProperties() { $extraConf = [ @@ -68,23 +88,23 @@ public function testPassExtraConfigProperties() 'fakeConn' => [ 'adapter' => 'sqlite', 'dsn' => 'sqlite:fakeDb.sqlite', - 'user'=> '', + 'user' => '', 'password' => '', 'model_paths' => [ 'src', - 'vendor' - ] - ] - ] + 'vendor', + ], + ], + ], ], 'runtime' => [ 'defaultConnection' => 'fakeConn', - 'connections' => ['fakeConn', 'default'] + 'connections' => ['fakeConn', 'default'], ], 'paths' => [ - 'composerDir' => 'path/to/composer' - ] - ] + 'composerDir' => 'path/to/composer', + ], + ], ]; $generatorConfig = new QuickGeneratorConfig($extraConf); @@ -100,8 +120,8 @@ public function testPassExtraConfigProperties() 'password' => '', 'model_paths' => [ 'src', - 'vendor' - ] + 'vendor', + ], ], $generatorConfig->get()['database']['connections']['fakeConn'] ); @@ -114,8 +134,8 @@ public function testPassExtraConfigProperties() 'password' => '', 'model_paths' => [ 'src', - 'vendor' - ] + 'vendor', + ], ], $generatorConfig->get()['database']['connections']['default'] ); diff --git a/tests/Propel/Tests/Generator/Manager/MigrationManagerTest.php b/tests/Propel/Tests/Generator/Manager/MigrationManagerTest.php index 08bf6e616f..dbb2cb029c 100644 --- a/tests/Propel/Tests/Generator/Manager/MigrationManagerTest.php +++ b/tests/Propel/Tests/Generator/Manager/MigrationManagerTest.php @@ -3,7 +3,6 @@ namespace Propel\Tests\Generator\Manager; use Propel\Generator\Config\GeneratorConfig; -use Propel\Generator\Manager\MigrationManager; use Propel\Tests\TestCase; /** @@ -12,7 +11,7 @@ class MigrationManagerTest extends TestCase { /** - * @return MigrationManager + * @return \Propel\Generator\Manager\MigrationManager */ private function createMigrationManager(array $migrationTimestamps) { @@ -37,6 +36,9 @@ private function createMigrationManager(array $migrationTimestamps) return $migrationManager; } + /** + * @return void + */ public function testMigrationTableWillBeCreated() { $migrationManager = $this->createMigrationManager([]); @@ -46,6 +48,9 @@ public function testMigrationTableWillBeCreated() $this->assertTrue($migrationManager->migrationTableExists('migration')); } + /** + * @return void + */ public function testGetAllDatabaseVersions() { $databaseVersions = [1, 2, 3]; @@ -59,6 +64,9 @@ public function testGetAllDatabaseVersions() $this->assertEquals($databaseVersions, $migrationManager->getAllDatabaseVersions()); } + /** + * @return void + */ public function testGetValidMigrationTimestamps() { $localTimestamps = [1, 2, 3, 4]; @@ -75,6 +83,9 @@ public function testGetValidMigrationTimestamps() $this->assertEquals($expectedMigrationTimestamps, $migrationManager->getValidMigrationTimestamps()); } + /** + * @return void + */ public function testRemoveMigrationTimestamp() { $localTimestamps = [1, 2]; @@ -92,6 +103,9 @@ public function testRemoveMigrationTimestamp() $this->assertEquals([2], $migrationManager->getValidMigrationTimestamps()); } + /** + * @return void + */ public function testGetAlreadyExecutedTimestamps() { $timestamps = [1, 2]; @@ -108,6 +122,9 @@ public function testGetAlreadyExecutedTimestamps() $this->assertEquals($timestamps, $migrationManager->getAlreadyExecutedMigrationTimestamps()); } + /** + * @return void + */ public function testIsPending() { $localTimestamps = [1, 2]; @@ -122,6 +139,9 @@ public function testIsPending() $this->assertFalse($migrationManager->hasPendingMigrations()); } + /** + * @return void + */ public function testGetOldestDatabaseVersion() { $timestamps = [1, 2]; @@ -135,6 +155,9 @@ public function testGetOldestDatabaseVersion() $this->assertEquals(2, $migrationManager->getOldestDatabaseVersion()); } + /** + * @return void + */ public function testGetFirstUpMigrationTimestamp() { $migrationManager = $this->createMigrationManager([1, 2, 3]); @@ -145,6 +168,9 @@ public function testGetFirstUpMigrationTimestamp() $this->assertEquals(2, $migrationManager->getFirstUpMigrationTimestamp()); } + /** + * @return void + */ public function testGetFirstDownMigrationTimestamp() { $migrationManager = $this->createMigrationManager([1, 2, 3]); @@ -156,11 +182,14 @@ public function testGetFirstDownMigrationTimestamp() $this->assertEquals(2, $migrationManager->getFirstDownMigrationTimestamp()); } + /** + * @return void + */ public function testGetCommentMigrationManager() { $migrationManager = $this->createMigrationManager([1, 2, 3]); - $body = $migrationManager->getMigrationClassBody("foo", "bar", 4, "migration comment"); + $body = $migrationManager->getMigrationClassBody('foo', 'bar', 4, 'migration comment'); $this->assertContains('public $comment = \'migration comment\';', $body); } diff --git a/tests/Propel/Tests/Generator/Migration/BaseTest.php b/tests/Propel/Tests/Generator/Migration/BaseTest.php index 8bad22b810..002e2a4c8e 100644 --- a/tests/Propel/Tests/Generator/Migration/BaseTest.php +++ b/tests/Propel/Tests/Generator/Migration/BaseTest.php @@ -7,6 +7,9 @@ */ class BaseTest extends MigrationTestCase { + /** + * @return void + */ public function testSimpleAdd() { $originXml = ' @@ -29,6 +32,9 @@ public function testSimpleAdd() $this->applyXmlAndTest($targetXml); } + /** + * @return void + */ public function testSimpleSize() { $originXml = ' @@ -52,6 +58,9 @@ public function testSimpleSize() $this->applyXmlAndTest($targetXml); } + /** + * @return void + */ public function testCharToChar() { $originXml = ' @@ -76,6 +85,9 @@ public function testCharToChar() $this->applyXmlAndTest($targetXml); } + /** + * @return void + */ public function testScale() { $originXml = ' @@ -112,6 +124,9 @@ public function testScale() $this->applyXmlAndTest($target2Xml); } + /** + * @return void + */ public function testColumnRequireChange() { $originXml = ' @@ -135,6 +150,9 @@ public function testColumnRequireChange() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testColumnTypeChangeSimple() { $originXml = ' @@ -159,6 +177,9 @@ public function testColumnTypeChangeSimple() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testColumnTypeChangeComplex() { $originXml = ' @@ -194,6 +215,9 @@ public function testColumnTypeChangeComplex() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testColumnTypeChangeMoreComplex() { $originXml = ' @@ -248,6 +272,9 @@ public function testColumnTypeChangeMoreComplex() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testColumnChangePrimaryKey() { $originXml = ' @@ -310,5 +337,4 @@ public function testColumnChangePrimaryKey() $this->applyXmlAndTest($target4Xml); $this->applyXmlAndTest($target5Xml); } - } diff --git a/tests/Propel/Tests/Generator/Migration/ForeignKeyTest.php b/tests/Propel/Tests/Generator/Migration/ForeignKeyTest.php index 9994cbca58..8b15fdc1bd 100644 --- a/tests/Propel/Tests/Generator/Migration/ForeignKeyTest.php +++ b/tests/Propel/Tests/Generator/Migration/ForeignKeyTest.php @@ -7,7 +7,9 @@ */ class ForeignKeyTest extends MigrationTestCase { - + /** + * @return void + */ public function testAdd() { $originXml = ' @@ -43,6 +45,9 @@ public function testAdd() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testAddNotUnique() { $originXml = ' @@ -74,6 +79,9 @@ public function testAddNotUnique() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testRemove() { $originXml = ' @@ -109,6 +117,9 @@ public function testRemove() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testChange() { $originXml = ' @@ -148,5 +159,4 @@ public function testChange() '; $this->migrateAndTest($originXml, $targetXml); } - } diff --git a/tests/Propel/Tests/Generator/Migration/IndexTest.php b/tests/Propel/Tests/Generator/Migration/IndexTest.php index dcb2d69e3c..5fe2282537 100644 --- a/tests/Propel/Tests/Generator/Migration/IndexTest.php +++ b/tests/Propel/Tests/Generator/Migration/IndexTest.php @@ -7,7 +7,9 @@ */ class IndexTest extends MigrationTestCase { - + /** + * @return void + */ public function testAdd() { $originXml = ' @@ -33,6 +35,9 @@ public function testAdd() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testRemove() { $originXml = ' @@ -58,6 +63,9 @@ public function testRemove() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testChange() { $originXml = ' @@ -86,6 +94,9 @@ public function testChange() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testChangeName() { $originXml = ' @@ -120,6 +131,8 @@ public function testChangeName() /** * @group mysql + * + * @return void */ public function testChangeSize() { @@ -149,6 +162,9 @@ public function testChangeSize() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testSameIndex() { $originXml = ' @@ -185,5 +201,4 @@ public function testSameIndex() '; $this->migrateAndTest($originXml, $targetXml); } - } diff --git a/tests/Propel/Tests/Generator/Migration/MigrationTestCase.php b/tests/Propel/Tests/Generator/Migration/MigrationTestCase.php index 18161c7bd6..596bca86dd 100644 --- a/tests/Propel/Tests/Generator/Migration/MigrationTestCase.php +++ b/tests/Propel/Tests/Generator/Migration/MigrationTestCase.php @@ -2,6 +2,7 @@ namespace Propel\Tests\Generator\Migration; +use Exception; use Propel\Generator\Config\QuickGeneratorConfig; use Propel\Generator\Exception\BuildException; use Propel\Generator\Model\Database; @@ -13,14 +14,13 @@ class MigrationTestCase extends TestCaseFixturesDatabase { - /** * @var \Propel\Runtime\Connection\ConnectionInterface */ protected $con; /** - * @var Database + * @var \Propel\Generator\Model\Database */ protected $database; @@ -34,6 +34,9 @@ class MigrationTestCase extends TestCaseFixturesDatabase */ protected $platform; + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -62,7 +65,9 @@ public function setUp(): void /** * @param string $xml * - * @return Database|boolean + * @throws \Propel\Generator\Exception\BuildException + * + * @return \Propel\Generator\Model\Database|bool */ public function applyXml($xml, $changeRequired = false) { @@ -81,7 +86,8 @@ public function applyXml($xml, $changeRequired = false) if (false === $diff) { if ($changeRequired) { - throw new BuildException(sprintf("No changes in schema to current database: \nSchema database:\n%s\n\nCurrent Database:\n%s", + throw new BuildException(sprintf( + "No changes in schema to current database: \nSchema database:\n%s\n\nCurrent Database:\n%s", $database, $this->database )); @@ -94,9 +100,11 @@ public function applyXml($xml, $changeRequired = false) $this->con->beginTransaction(); if (!$sql) { throw new BuildException( - sprintf('Ooops. There is a diff between current database and schema xml but no SQL has been generated. Change: %s', - $diff - )); + sprintf( + 'Ooops. There is a diff between current database and schema xml but no SQL has been generated. Change: %s', + $diff + ) + ); } $statements = SqlParser::parseString($sql); @@ -104,8 +112,9 @@ public function applyXml($xml, $changeRequired = false) try { $stmt = $this->con->prepare($statement); $stmt->execute(); - } catch (\Exception $e) { - throw new BuildException(sprintf("Can not execute SQL: \n%s\nFrom database: \n%s\n\nTo database: \n%s\n", + } catch (Exception $e) { + throw new BuildException(sprintf( + "Can not execute SQL: \n%s\nFrom database: \n%s\n\nTo database: \n%s\n", $statement, $this->database, $database @@ -117,6 +126,9 @@ public function applyXml($xml, $changeRequired = false) return $database; } + /** + * @return void + */ public function readDatabase() { $this->database = new Database(); @@ -131,6 +143,10 @@ public function readDatabase() * * @param string $originXml * @param string $targetXml + * + * @throws \Propel\Generator\Exception\BuildException + * + * @return void */ public function migrateAndTest($originXml, $targetXml) { @@ -144,12 +160,14 @@ public function migrateAndTest($originXml, $targetXml) $this->applyXmlAndTest($targetXml, true); } catch (BuildException $e) { throw new BuildException('There was a exception in applying the second(target) schema', 0, $e); - } + } } /** * @param string $xml - * @param bool $changeRequired + * @param bool $changeRequired + * + * @return void */ public function applyXmlAndTest($xml, $changeRequired = false) { @@ -162,8 +180,11 @@ public function applyXmlAndTest($xml, $changeRequired = false) /** * Compares the current database with $database. * - * @param Database $database - * @throws BuildException if a difference has been found between $database and the real database + * @param \Propel\Generator\Model\Database $database + * + * @throws \Propel\Generator\Exception\BuildException if a difference has been found between $database and the real database + * + * @return void */ public function compareCurrentDatabase(Database $database) { @@ -171,13 +192,14 @@ public function compareCurrentDatabase(Database $database) $diff = DatabaseComparator::computeDiff($this->database, $database); if (false !== $diff) { $sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff); + throw new BuildException(sprintf( - "There are unexpected diffs (real to model): \n%s\n-----%s-----\nCurrent Database: \n%s\nTo XML Database: \n%s\n", - $diff, - $sql, - $this->database, - $database) - ); + "There are unexpected diffs (real to model): \n%s\n-----%s-----\nCurrent Database: \n%s\nTo XML Database: \n%s\n", + $diff, + $sql, + $this->database, + $database + )); } $this->assertFalse($diff, 'no changes.'); } diff --git a/tests/Propel/Tests/Generator/Migration/PrimaryKeyAITest.php b/tests/Propel/Tests/Generator/Migration/PrimaryKeyAITest.php index 6eeba1216d..e6d69dc023 100644 --- a/tests/Propel/Tests/Generator/Migration/PrimaryKeyAITest.php +++ b/tests/Propel/Tests/Generator/Migration/PrimaryKeyAITest.php @@ -7,7 +7,9 @@ */ class PrimaryKeyAITest extends MigrationTestCase { - + /** + * @return void + */ public function testAdd() { $originXml = ' @@ -30,6 +32,9 @@ public function testAdd() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testRemove() { $originXml = ' @@ -52,6 +57,9 @@ public function testRemove() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testChange() { $originXml = ' @@ -76,6 +84,9 @@ public function testChange() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testChangeName() { $originXml = ' @@ -100,6 +111,8 @@ public function testChangeName() /** * @group mysql + * + * @return void */ public function testChangeSize() { @@ -122,5 +135,4 @@ public function testChangeSize() '; $this->migrateAndTest($originXml, $targetXml); } - } diff --git a/tests/Propel/Tests/Generator/Migration/PrimaryKeyTest.php b/tests/Propel/Tests/Generator/Migration/PrimaryKeyTest.php index 5eb2124f17..e283b628f8 100644 --- a/tests/Propel/Tests/Generator/Migration/PrimaryKeyTest.php +++ b/tests/Propel/Tests/Generator/Migration/PrimaryKeyTest.php @@ -7,7 +7,9 @@ */ class PrimaryKeyTest extends MigrationTestCase { - + /** + * @return void + */ public function testAdd() { $originXml = ' @@ -30,6 +32,9 @@ public function testAdd() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testRemove() { $originXml = ' @@ -52,6 +57,9 @@ public function testRemove() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testChange() { $originXml = ' @@ -76,6 +84,9 @@ public function testChange() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testChangeName() { $originXml = ' @@ -98,6 +109,9 @@ public function testChangeName() $this->migrateAndTest($originXml, $targetXml); } + /** + * @return void + */ public function testChangeSize() { $originXml = ' @@ -119,5 +133,4 @@ public function testChangeSize() '; $this->migrateAndTest($originXml, $targetXml); } - } diff --git a/tests/Propel/Tests/Generator/Model/BehaviorTest.php b/tests/Propel/Tests/Generator/Model/BehaviorTest.php index f4a6d1460b..eec00e6be5 100644 --- a/tests/Propel/Tests/Generator/Model/BehaviorTest.php +++ b/tests/Propel/Tests/Generator/Model/BehaviorTest.php @@ -21,8 +21,12 @@ class BehaviorTest extends TestCase { private $schemaReader; + private $appData; + /** + * @return void + */ public function testSetupObject() { $b = new Behavior(); @@ -30,6 +34,9 @@ public function testSetupObject() $this->assertEquals($b->getName(), 'foo', 'setupObject() sets the Behavior name from XML attributes'); } + /** + * @return void + */ public function testSetupObjectWithMultipleBehaviorWithNoId() { $b = new Propel\Tests\Helpers\MultipleBehavior(); @@ -39,6 +46,9 @@ public function testSetupObjectWithMultipleBehaviorWithNoId() $this->assertEquals($b->getId(), 'foo', 'setupObject() sets the Behavior id from its name when no explicit id is given'); } + /** + * @return void + */ public function testSetupObjectWithMultipleBehaviorWithId() { $b = new Propel\Tests\Helpers\MultipleBehavior(); @@ -50,6 +60,8 @@ public function testSetupObjectWithMultipleBehaviorWithId() /** * @expectedException Propel\Generator\Exception\LogicException + * + * @return void */ public function testSetupObjectFailIfIdGivenOnNotMultipleBehavior() { @@ -57,6 +69,9 @@ public function testSetupObjectFailIfIdGivenOnNotMultipleBehavior() $b->loadMapping(['name' => 'foo', 'id' => 'lala']); } + /** + * @return void + */ public function testName() { $b = new Behavior(); @@ -65,6 +80,9 @@ public function testName() $this->assertEquals($b->getName(), 'foo', 'setName() sets the name, and getName() gets it'); } + /** + * @return void + */ public function testTable() { $b = new Behavior(); @@ -75,6 +93,9 @@ public function testTable() $this->assertEquals($b->getTable(), $t, 'setTable() sets the name, and getTable() gets it'); } + /** + * @return void + */ public function testParameters() { $b = new Behavior(); @@ -93,6 +114,7 @@ public function testParameters() /** * test if the tables get the package name from the properties file * + * @return void */ public function testSchemaReader() { @@ -126,6 +148,8 @@ public function testSchemaReader() /** * @expectedException \Propel\Generator\Exception\BehaviorNotFoundException + * + * @return void */ public function testUnknownBehavior() { @@ -141,6 +165,9 @@ public function testUnknownBehavior() $appData = $schemaReader->parseString($schema); } + /** + * @return void + */ public function testModifyTable() { $schemaReader = new SchemaReader(); @@ -158,6 +185,9 @@ public function testModifyTable() $this->assertEquals(count($table->getColumns()), 4, 'A behavior can modify its table by implementing modifyTable()'); } + /** + * @return void + */ public function testModifyDatabase() { $schemaReader = new SchemaReader(); @@ -174,6 +204,9 @@ public function testModifyDatabase() $this->assertTrue(array_key_exists('timestampable', $table->getBehaviors()), 'A database behavior is automatically copied to all its table'); } + /** + * @return void + */ public function testGetColumnForParameter() { $schemaReader = new SchemaReader(); diff --git a/tests/Propel/Tests/Generator/Model/ColumnDefaultValueTest.php b/tests/Propel/Tests/Generator/Model/ColumnDefaultValueTest.php index 8b81875869..0d1e58efae 100644 --- a/tests/Propel/Tests/Generator/Model/ColumnDefaultValueTest.php +++ b/tests/Propel/Tests/Generator/Model/ColumnDefaultValueTest.php @@ -9,11 +9,10 @@ */ use Propel\Generator\Model\ColumnDefaultValue; -use \Propel\Tests\TestCase; +use Propel\Tests\TestCase; /** * Tests for ColumnDefaultValue class. - * */ class ColumnDefaultValueTest extends TestCase { @@ -30,6 +29,8 @@ public function equalsProvider() /** * @dataProvider equalsProvider + * + * @return void */ public function testEquals($def1, $def2, $test) { diff --git a/tests/Propel/Tests/Generator/Model/ColumnTest.php b/tests/Propel/Tests/Generator/Model/ColumnTest.php index 177d5f633e..51945bf730 100644 --- a/tests/Propel/Tests/Generator/Model/ColumnTest.php +++ b/tests/Propel/Tests/Generator/Model/ColumnTest.php @@ -7,8 +7,11 @@ * * @license MIT License */ + namespace Propel\Tests\Generator\Model; +use PDO; +use Propel\Generator\Exception\EngineException; use Propel\Generator\Model\Column; use Propel\Generator\Model\PropelTypes; @@ -19,6 +22,9 @@ */ class ColumnTest extends ModelTestCase { + /** + * @return void + */ public function testCreateNewColumn() { $column = new Column('title'); @@ -46,6 +52,9 @@ public function testCreateNewColumn() $this->assertFalse($column->requiresTransactionInPostgres()); } + /** + * @return void + */ public function testSetupObjectWithoutPlatformTypeAndDomain() { $database = $this->getDatabaseMock('bookstore'); @@ -60,6 +69,9 @@ public function testSetupObjectWithoutPlatformTypeAndDomain() $this->assertSame('VARCHAR', $column->getDomain()->getType()); } + /** + * @return void + */ public function testSetupObjectWithPlatformOnly() { $database = $this->getDatabaseMock('bookstore'); @@ -68,13 +80,11 @@ public function testSetupObjectWithPlatformOnly() ->expects($this->once()) ->method('getDomainForType') ->with($this->equalTo('VARCHAR')) - ->will($this->returnValue($this->getDomainMock('VARCHAR'))) - ; + ->will($this->returnValue($this->getDomainMock('VARCHAR'))); $platform ->expects($this->any()) ->method('supportsVarcharWithoutSize') - ->will($this->returnValue(false)) - ; + ->will($this->returnValue(false)); $table = $this->getTableMock('books', [ 'database' => $database, @@ -85,8 +95,7 @@ public function testSetupObjectWithPlatformOnly() $domain ->expects($this->any()) ->method('getType') - ->will($this->returnValue('VARCHAR')) - ; + ->will($this->returnValue('VARCHAR')); $column = new Column(); $column->setTable($table); @@ -96,6 +105,9 @@ public function testSetupObjectWithPlatformOnly() $this->assertSame('title', $column->getName()); } + /** + * @return void + */ public function testSetupObjectWithPlatformAndType() { $database = $this->getDatabaseMock('bookstore'); @@ -104,8 +116,7 @@ public function testSetupObjectWithPlatformAndType() ->expects($this->once()) ->method('getDomainForType') ->with($this->equalTo('DATE')) - ->will($this->returnValue($this->getDomainMock('DATE'))) - ; + ->will($this->returnValue($this->getDomainMock('DATE'))); $table = $this->getTableMock('books', [ 'database' => $database, @@ -116,14 +127,17 @@ public function testSetupObjectWithPlatformAndType() $column->setTable($table); $column->setDomain($this->getDomainMock('VARCHAR')); $column->loadMapping([ - 'type' => 'date', - 'name' => 'created_at', + 'type' => 'date', + 'name' => 'created_at', 'defaultExpr' => 'NOW()', ]); $this->assertSame('created_at', $column->getName()); } + /** + * @return void + */ public function testSetupObjectWithDomain() { $database = $this->getDatabaseMock('bookstore'); @@ -131,8 +145,7 @@ public function testSetupObjectWithDomain() ->expects($this->once()) ->method('getDomain') ->with($this->equalTo('BOOLEAN')) - ->will($this->returnValue($this->getDomainMock('INTEGER'))) - ; + ->will($this->returnValue($this->getDomainMock('INTEGER'))); $table = $this->getTableMock('books', ['database' => $database]); @@ -140,27 +153,27 @@ public function testSetupObjectWithDomain() $column->setTable($table); $column->setDomain($this->getDomainMock('BOOLEAN')); $column->loadMapping([ - 'domain' => 'BOOLEAN', - 'name' => 'is_published', - 'phpName' => 'IsPublished', - 'phpType' => 'boolean', - 'tableMapName' => 'IS_PUBLISHED', - 'prefix' => 'col_', + 'domain' => 'BOOLEAN', + 'name' => 'is_published', + 'phpName' => 'IsPublished', + 'phpType' => 'boolean', + 'tableMapName' => 'IS_PUBLISHED', + 'prefix' => 'col_', 'accessorVisibility' => 'public', - 'mutatorVisibility' => 'public', - 'primaryString' => 'false', - 'primaryKey' => 'false', - 'nodeKey' => 'false', - 'nestedSetLeftKey' => 'false', - 'nestedSetRightKey' => 'false', - 'treeScopeKey' => 'false', - 'required' => 'false', - 'autoIncrement' => 'false', - 'lazyLoad' => 'true', - 'sqlType' => 'TINYINT', - 'size' => 1, - 'defaultValue' => 'true', - 'valueSet' => 'FOO, BAR, BAZ', + 'mutatorVisibility' => 'public', + 'primaryString' => 'false', + 'primaryKey' => 'false', + 'nodeKey' => 'false', + 'nestedSetLeftKey' => 'false', + 'nestedSetRightKey' => 'false', + 'treeScopeKey' => 'false', + 'required' => 'false', + 'autoIncrement' => 'false', + 'lazyLoad' => 'true', + 'sqlType' => 'TINYINT', + 'size' => 1, + 'defaultValue' => 'true', + 'valueSet' => 'FOO, BAR, BAZ', ]); $this->assertSame('is_published', $column->getName()); @@ -179,6 +192,9 @@ public function testSetupObjectWithDomain() $this->assertCount(3, $column->getValueSet()); } + /** + * @return void + */ public function testSetPosition() { $column = new Column(); @@ -187,14 +203,16 @@ public function testSetPosition() $this->assertSame(2, $column->getPosition()); } + /** + * @return void + */ public function testGetNullDefaultValueString() { $domain = $this->getDomainMock(); $domain ->expects($this->any()) ->method('getDefaultValue') - ->will($this->returnValue(null)) - ; + ->will($this->returnValue(null)); $column = new Column(); $column->setDomain($domain); @@ -204,36 +222,33 @@ public function testGetNullDefaultValueString() /** * @dataProvider provideDefaultValues + * + * @return void */ public function testGetDefaultValueString($mappingType, $value, $expected) { $defaultValue = $this ->getMockBuilder('Propel\Generator\Model\ColumnDefaultValue') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); $defaultValue ->expects($this->any()) ->method('getValue') - ->will($this->returnValue($value)) - ; + ->will($this->returnValue($value)); $domain = $this->getDomainMock(); $domain ->expects($this->any()) ->method('getDefaultValue') - ->will($this->returnValue($defaultValue)) - ; + ->will($this->returnValue($defaultValue)); $domain ->expects($this->any()) - ->method('setDefaultValue') - ; + ->method('setDefaultValue'); $domain ->expects($this->any()) ->method('getType') - ->will($this->returnValue($mappingType)) - ; + ->will($this->returnValue($mappingType)); $column = new Column(); $column->setDomain($domain); @@ -255,6 +270,9 @@ public function provideDefaultValues() ]; } + /** + * @return void + */ public function testAddInheritance() { $column = new Column(); @@ -262,13 +280,11 @@ public function testAddInheritance() $inheritance = $this ->getMockBuilder('Propel\Generator\Model\Inheritance') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); $inheritance ->expects($this->any()) ->method('setColumn') - ->with($this->equalTo($column)) - ; + ->with($this->equalTo($column)); $column->addInheritance($inheritance); @@ -279,6 +295,9 @@ public function testAddInheritance() $this->assertCount(0, $column->getChildren()); } + /** + * @return void + */ public function testAddArrayInheritance() { $column = new Column(); @@ -300,6 +319,9 @@ public function testAddArrayInheritance() $this->assertCount(2, $column->getChildren()); } + /** + * @return void + */ public function testClearForeignKeys() { $fks = [ @@ -312,8 +334,7 @@ public function testClearForeignKeys() ->expects($this->any()) ->method('getColumnForeignKeys') ->with('author_id') - ->will($this->returnValue($fks)) - ; + ->will($this->returnValue($fks)); $column = new Column('author_id'); $column->setTable($table); @@ -334,43 +355,41 @@ public function testClearForeignKeys() $this->assertCount(0, $clone->getReferrers()); } + /** + * @return void + */ public function testIsDefaultSqlTypeFromDomain() { $toCopy = $this->getDomainMock(); $toCopy ->expects($this->once()) ->method('getSqlType') - ->will($this->returnValue('INTEGER')) - ; + ->will($this->returnValue('INTEGER')); $platform = $this->getPlatformMock(); $platform ->expects($this->any()) ->method('getDomainForType') ->with($this->equalTo('BOOLEAN')) - ->will($this->returnValue($toCopy)) - ; + ->will($this->returnValue($toCopy)); $domain = $this->getDomainMock(); $domain ->expects($this->once()) ->method('copy') - ->with($this->equalTo($toCopy)) - ; + ->with($this->equalTo($toCopy)); $domain ->expects($this->once()) ->method('getType') - ->will($this->returnValue('BOOLEAN')) - ; + ->will($this->returnValue('BOOLEAN')); $domain ->expects($this->any()) ->method('getSqlType') - ->will($this->returnValue('INTEGER')) - ; + ->will($this->returnValue('INTEGER')); $column = new Column(); $column->setTable($this->getTableMock('books', [ - 'platform' => $platform + 'platform' => $platform, ])); $column->setDomain($domain); $column->setDomainForType('BOOLEAN'); @@ -378,6 +397,9 @@ public function testIsDefaultSqlTypeFromDomain() $this->assertTrue($column->isDefaultSqlType($platform)); } + /** + * @return void + */ public function testIsDefaultSqlType() { $column = new Column(); @@ -385,14 +407,16 @@ public function testIsDefaultSqlType() $this->assertTrue($column->isDefaultSqlType()); } + /** + * @return void + */ public function testGetNotNullString() { $platform = $this->getPlatformMock(); $platform ->expects($this->once()) ->method('getNullString') - ->will($this->returnValue('NOT NULL')) - ; + ->will($this->returnValue('NOT NULL')); $table = $this->getTableMock('books', ['platform' => $platform]); @@ -406,6 +430,7 @@ public function testGetNotNullString() /** * @dataProvider providePdoTypes * + * @return void */ public function testGetPdoType($mappingType, $pdoType) { @@ -413,8 +438,7 @@ public function testGetPdoType($mappingType, $pdoType) $domain ->expects($this->any()) ->method('getType') - ->will($this->returnValue($mappingType)) - ; + ->will($this->returnValue($mappingType)); $column = new Column(); $column->setDomain($domain); @@ -426,45 +450,47 @@ public function testGetPdoType($mappingType, $pdoType) public function providePdoTypes() { return [ - ['CHAR', \PDO::PARAM_STR], - ['VARCHAR', \PDO::PARAM_STR], - ['LONGVARCHAR', \PDO::PARAM_STR], - ['CLOB', \PDO::PARAM_STR], - ['CLOB_EMU', \PDO::PARAM_STR], - ['NUMERIC', \PDO::PARAM_INT], - ['DECIMAL', \PDO::PARAM_STR], - ['TINYINT', \PDO::PARAM_INT], - ['SMALLINT', \PDO::PARAM_INT], - ['INTEGER', \PDO::PARAM_INT], - ['BIGINT', \PDO::PARAM_INT], - ['REAL', \PDO::PARAM_STR], - ['FLOAT', \PDO::PARAM_STR], - ['DOUBLE', \PDO::PARAM_STR], - ['BINARY', \PDO::PARAM_STR], - ['VARBINARY', \PDO::PARAM_LOB], - ['LONGVARBINARY', \PDO::PARAM_LOB], - ['BLOB', \PDO::PARAM_LOB], - ['DATE', \PDO::PARAM_STR], - ['TIME', \PDO::PARAM_STR], - ['TIMESTAMP', \PDO::PARAM_STR], - ['BOOLEAN', \PDO::PARAM_BOOL], - ['BOOLEAN_EMU', \PDO::PARAM_INT], - ['OBJECT', \PDO::PARAM_LOB], - ['ARRAY', \PDO::PARAM_STR], - ['ENUM', \PDO::PARAM_INT], - ['BU_DATE', \PDO::PARAM_STR], - ['BU_TIMESTAMP', \PDO::PARAM_STR], + ['CHAR', PDO::PARAM_STR], + ['VARCHAR', PDO::PARAM_STR], + ['LONGVARCHAR', PDO::PARAM_STR], + ['CLOB', PDO::PARAM_STR], + ['CLOB_EMU', PDO::PARAM_STR], + ['NUMERIC', PDO::PARAM_INT], + ['DECIMAL', PDO::PARAM_STR], + ['TINYINT', PDO::PARAM_INT], + ['SMALLINT', PDO::PARAM_INT], + ['INTEGER', PDO::PARAM_INT], + ['BIGINT', PDO::PARAM_INT], + ['REAL', PDO::PARAM_STR], + ['FLOAT', PDO::PARAM_STR], + ['DOUBLE', PDO::PARAM_STR], + ['BINARY', PDO::PARAM_STR], + ['VARBINARY', PDO::PARAM_LOB], + ['LONGVARBINARY', PDO::PARAM_LOB], + ['BLOB', PDO::PARAM_LOB], + ['DATE', PDO::PARAM_STR], + ['TIME', PDO::PARAM_STR], + ['TIMESTAMP', PDO::PARAM_STR], + ['BOOLEAN', PDO::PARAM_BOOL], + ['BOOLEAN_EMU', PDO::PARAM_INT], + ['OBJECT', PDO::PARAM_LOB], + ['ARRAY', PDO::PARAM_STR], + ['ENUM', PDO::PARAM_INT], + ['BU_DATE', PDO::PARAM_STR], + ['BU_TIMESTAMP', PDO::PARAM_STR], ]; } + /** + * @return void + */ public function testEnumType() { $domain = $this->getDomainMock(); $domain ->expects($this->any()) ->method('getType') - ->will($this->returnValue('ENUM')) - ; + ->will($this->returnValue('ENUM')); $column = new Column(); $column->setDomain($domain); @@ -478,14 +504,16 @@ public function testEnumType() $this->assertContains('BAR', $column->getValueSet()); } + /** + * @return void + */ public function testSetType() { $domain = $this->getDomainMock(); $domain ->expects($this->any()) ->method('getType') - ->will($this->returnValue('SET')) - ; + ->will($this->returnValue('SET')); $column = new Column(); $column->setDomain($domain); @@ -499,6 +527,9 @@ public function testSetType() $this->assertContains('BAR', $column->getValueSet()); } + /** + * @return void + */ public function testSetStringValueSet() { $column = new Column(); @@ -509,14 +540,16 @@ public function testSetStringValueSet() $this->assertContains('BAZ', $column->getValueSet()); } + /** + * @return void + */ public function testPhpObjectType() { $domain = $this->getDomainMock(); $domain ->expects($this->any()) ->method('getType') - ->will($this->returnValue('OBJECT')) - ; + ->will($this->returnValue('OBJECT')); $column = new Column(); $column->setDomain($domain); @@ -528,6 +561,8 @@ public function testPhpObjectType() /** * @dataProvider provideMappingTemporalTypes + * + * @return void */ public function testTemporalType($mappingType) { @@ -535,14 +570,12 @@ public function testTemporalType($mappingType) $domain ->expects($this->once()) ->method('setType') - ->with($this->equalTo($mappingType)) - ; + ->with($this->equalTo($mappingType)); $domain ->expects($this->any()) ->method('getType') - ->will($this->returnValue($mappingType)) - ; + ->will($this->returnValue($mappingType)); $column = new Column(); $column->setDomain($domain); @@ -566,6 +599,8 @@ public function provideMappingTemporalTypes() /** * @dataProvider provideMappingLobTypes + * + * @return void */ public function testLobType($mappingType, $phpType, $isPhpPrimitiveType) { @@ -573,14 +608,12 @@ public function testLobType($mappingType, $phpType, $isPhpPrimitiveType) $domain ->expects($this->once()) ->method('setType') - ->with($this->equalTo($mappingType)) - ; + ->with($this->equalTo($mappingType)); $domain ->expects($this->any()) ->method('getType') - ->will($this->returnValue($mappingType)) - ; + ->will($this->returnValue($mappingType)); $column = new Column(); $column->setDomain($domain); @@ -602,6 +635,8 @@ public function provideMappingLobTypes() /** * @dataProvider provideMappingBooleanTypes + * + * @return void */ public function testBooleanType($mappingType) { @@ -609,14 +644,12 @@ public function testBooleanType($mappingType) $domain ->expects($this->once()) ->method('setType') - ->with($this->equalTo($mappingType)) - ; + ->with($this->equalTo($mappingType)); $domain ->expects($this->any()) ->method('getType') - ->will($this->returnValue($mappingType)) - ; + ->will($this->returnValue($mappingType)); $column = new Column(); $column->setDomain($domain); @@ -637,6 +670,8 @@ public function provideMappingBooleanTypes() /** * @dataProvider provideMappingNumericTypes + * + * @return void */ public function testNumericType($mappingType, $phpType, $isPrimitiveNumericType) { @@ -644,14 +679,12 @@ public function testNumericType($mappingType, $phpType, $isPrimitiveNumericType) $domain ->expects($this->once()) ->method('setType') - ->with($this->equalTo($mappingType)) - ; + ->with($this->equalTo($mappingType)); $domain ->expects($this->any()) ->method('getType') - ->will($this->returnValue($mappingType)) - ; + ->will($this->returnValue($mappingType)); $column = new Column(); $column->setDomain($domain); @@ -680,6 +713,8 @@ public function provideMappingNumericTypes() /** * @dataProvider provideMappingTextTypes + * + * @return void */ public function testTextType($mappingType) { @@ -687,14 +722,12 @@ public function testTextType($mappingType) $domain ->expects($this->once()) ->method('setType') - ->with($this->equalTo($mappingType)) - ; + ->with($this->equalTo($mappingType)); $domain ->expects($this->any()) ->method('getType') - ->will($this->returnValue($mappingType)) - ; + ->will($this->returnValue($mappingType)); $column = new Column(); $column->setDomain($domain); @@ -720,14 +753,16 @@ public function provideMappingTextTypes() ]; } + /** + * @return void + */ public function testGetSizeDefinition() { $domain = $this->getDomainMock(); $domain ->expects($this->once()) ->method('getSizeDefinition') - ->will($this->returnValue('(10,2)')) - ; + ->will($this->returnValue('(10,2)')); $column = new Column(); $column->setDomain($domain); @@ -735,14 +770,16 @@ public function testGetSizeDefinition() $this->assertSame('(10,2)', $column->getSizeDefinition()); } + /** + * @return void + */ public function testGetConstantName() { $table = $this->getTableMock('article'); $table ->expects($this->once()) ->method('getPhpName') - ->will($this->returnValue('Article')) - ; + ->will($this->returnValue('Article')); $column = new Column('created_at'); $column->setTable($table); @@ -753,6 +790,9 @@ public function testGetConstantName() $this->assertSame('ArticleTableMap::COL_CREATED_AT', $column->getFQConstantName()); } + /** + * @return void + */ public function testSetDefaultPhpName() { $column = new Column('created_at'); @@ -761,6 +801,9 @@ public function testSetDefaultPhpName() $this->assertSame('createdAt', $column->getCamelCaseName()); } + /** + * @return void + */ public function testSetCustomPhpName() { $column = new Column('created_at'); @@ -770,6 +813,9 @@ public function testSetCustomPhpName() $this->assertSame('createdAt', $column->getCamelCaseName()); } + /** + * @return void + */ public function testSetDefaultMutatorAndAccessorMethodsVisibility() { $column = new Column(); @@ -780,6 +826,9 @@ public function testSetDefaultMutatorAndAccessorMethodsVisibility() $this->assertSame('public', $column->getMutatorVisibility()); } + /** + * @return void + */ public function testSetMutatorAndAccessorMethodsVisibility() { $column = new Column(); @@ -790,14 +839,16 @@ public function testSetMutatorAndAccessorMethodsVisibility() $this->assertSame('private', $column->getMutatorVisibility()); } + /** + * @return void + */ public function testGetPhpDefaultValue() { $domain = $this->getDomainMock(); $domain ->expects($this->once()) ->method('getPhpDefaultValue') - ->will($this->returnValue(true)) - ; + ->will($this->returnValue(true)); $column = new Column(); $column->setDomain($domain); @@ -805,16 +856,18 @@ public function testGetPhpDefaultValue() $this->assertTrue($column->getPhpDefaultValue()); } + /** + * @return void + */ public function testGetAutoIncrementStringThrowsEngineException() { - $this->expectException(\Propel\Generator\Exception\EngineException::class); + $this->expectException(EngineException::class); $table = $this->getTableMock('books'); $table ->expects($this->once()) ->method('getIdMethod') - ->will($this->returnValue('none')) - ; + ->will($this->returnValue('none')); $column = new Column(); $column->setTable($table); @@ -822,21 +875,22 @@ public function testGetAutoIncrementStringThrowsEngineException() $column->getAutoIncrementString(); } + /** + * @return void + */ public function testGetNativeAutoIncrementString() { $platform = $this->getPlatformMock(); $platform ->expects($this->once()) ->method('getAutoIncrement') - ->will($this->returnValue('AUTO_INCREMENT')) - ; + ->will($this->returnValue('AUTO_INCREMENT')); $table = $this->getTableMock('books', ['platform' => $platform]); $table ->expects($this->once()) ->method('getIdMethod') - ->will($this->returnValue('native')) - ; + ->will($this->returnValue('native')); $column = new Column(); $column->setAutoIncrement(true); @@ -845,6 +899,9 @@ public function testGetNativeAutoIncrementString() $this->assertEquals('AUTO_INCREMENT', $column->getAutoIncrementString()); } + /** + * @return void + */ public function testGetFullyQualifiedName() { $column = new Column('title'); @@ -853,6 +910,9 @@ public function testGetFullyQualifiedName() $this->assertSame('books.TITLE', $column->getFullyQualifiedName()); } + /** + * @return void + */ public function testHasPlatform() { $table = $this->getTableMock('books', [ @@ -866,6 +926,9 @@ public function testHasPlatform() $this->assertInstanceOf('Propel\Generator\Platform\PlatformInterface', $column->getPlatform()); } + /** + * @return void + */ public function testIsPhpArrayType() { $column = new Column(); @@ -875,19 +938,20 @@ public function testIsPhpArrayType() $this->assertTrue($column->isPhpArrayType()); } + /** + * @return void + */ public function testSetSize() { $domain = $this->getDomainMock(); $domain ->expects($this->once()) ->method('setSize') - ->with($this->equalTo(50)) - ; + ->with($this->equalTo(50)); $domain ->expects($this->once()) ->method('getSize') - ->will($this->returnValue(50)) - ; + ->will($this->returnValue(50)); $column = new Column(); $column->setDomain($domain); @@ -896,19 +960,20 @@ public function testSetSize() $this->assertSame(50, $column->getSize()); } + /** + * @return void + */ public function testSetScale() { $domain = $this->getDomainMock(); $domain ->expects($this->once()) ->method('setScale') - ->with($this->equalTo(2)) - ; + ->with($this->equalTo(2)); $domain ->expects($this->once()) ->method('getScale') - ->will($this->returnValue(2)) - ; + ->will($this->returnValue(2)); $column = new Column(); $column->setDomain($domain); @@ -917,6 +982,9 @@ public function testSetScale() $this->assertSame(2, $column->getScale()); } + /** + * @return void + */ public function testGetDefaultDomain() { $column = new Column(); @@ -924,6 +992,9 @@ public function testGetDefaultDomain() $this->assertInstanceOf('Propel\Generator\Model\Domain', $column->getDomain()); } + /** + * @return void + */ public function testGetSingularName() { $column = new Column('titles'); @@ -932,6 +1003,9 @@ public function testGetSingularName() $this->assertTrue($column->isNamePlural()); } + /** + * @return void + */ public function testSetTable() { $column = new Column(); @@ -941,6 +1015,9 @@ public function testSetTable() $this->assertSame('books', $column->getTableName()); } + /** + * @return void + */ public function testSetDomain() { $column = new Column(); @@ -949,6 +1026,9 @@ public function testSetDomain() $this->assertInstanceOf('Propel\Generator\Model\Domain', $column->getDomain()); } + /** + * @return void + */ public function testSetDescription() { $column = new Column(); @@ -957,6 +1037,9 @@ public function testSetDescription() $this->assertSame('Some description', $column->getDescription()); } + /** + * @return void + */ public function testSetNestedSetLeftKey() { $column = new Column(); @@ -969,6 +1052,9 @@ public function testSetNestedSetLeftKey() $this->assertSame(',', $column->getNodeKeySep()); } + /** + * @return void + */ public function testSetNestedSetRightKey() { $column = new Column(); @@ -977,6 +1063,9 @@ public function testSetNestedSetRightKey() $this->assertTrue($column->isNestedSetRightKey()); } + /** + * @return void + */ public function testSetTreeScopeKey() { $column = new Column(); @@ -985,6 +1074,9 @@ public function testSetTreeScopeKey() $this->assertTrue($column->isTreeScopeKey()); } + /** + * @return void + */ public function testSetAutoIncrement() { $column = new Column(); @@ -993,6 +1085,9 @@ public function testSetAutoIncrement() $this->assertTrue($column->isAutoIncrement()); } + /** + * @return void + */ public function testSetPrimaryString() { $column = new Column(); @@ -1001,6 +1096,9 @@ public function testSetPrimaryString() $this->assertTrue($column->isPrimaryString()); } + /** + * @return void + */ public function testSetNotNull() { $column = new Column(); @@ -1009,6 +1107,9 @@ public function testSetNotNull() $this->assertTrue($column->isNotNull()); } + /** + * @return void + */ public function testPhpSingularName() { $column = new Column(); diff --git a/tests/Propel/Tests/Generator/Model/ConstantNameTest.php b/tests/Propel/Tests/Generator/Model/ConstantNameTest.php index 8d084aa3af..17005023bc 100644 --- a/tests/Propel/Tests/Generator/Model/ConstantNameTest.php +++ b/tests/Propel/Tests/Generator/Model/ConstantNameTest.php @@ -10,8 +10,11 @@ namespace Propel\Tests\Generator\Model; -use Propel\Tests\TestCase; +use ConstantNameTest1\Map\UserCheck1TableMap; +use ConstantNameTest2\Map\UserCheck2TableMap; +use ConstantNameTest3\Map\UserCheck3TableMap; use Propel\Generator\Util\QuickBuilder; +use Propel\Tests\TestCase; /** * Tests for generated constants' names. @@ -22,6 +25,8 @@ class ConstantNameTest extends TestCase { /** * Test normal string as single inheritance key + * + * @return void */ public function testSingleInheritanceKeyNormalString() { @@ -40,13 +45,14 @@ public function testSingleInheritanceKeyNormalString() $this->assertTrue(class_exists('ConstantNameTest1\UserCheck1Expiration')); $this->assertTrue(class_exists('ConstantNameTest1\Map\UserCheck1TableMap')); $this->assertTrue(defined('\ConstantNameTest1\Map\UserCheck1TableMap::CLASSKEY_EXPIRATION')); - $this->assertEquals('Expiration', \ConstantNameTest1\Map\UserCheck1TableMap::CLASSKEY_EXPIRATION); + $this->assertEquals('Expiration', UserCheck1TableMap::CLASSKEY_EXPIRATION); } /** * Test string with dashes as single inheritance key (original cause for this whole test) + * + * @return void */ - public function testSingleInheritanceKeyStringWithDashes() { $schema = <<assertTrue(class_exists('ConstantNameTest2\UserCheck2MacAddress')); $this->assertTrue(class_exists('ConstantNameTest2\Map\UserCheck2TableMap')); $this->assertTrue(defined('\ConstantNameTest2\Map\UserCheck2TableMap::CLASSKEY_CALLING_STATION_ID')); - $this->assertEquals('Calling-Station-Id', \ConstantNameTest2\Map\UserCheck2TableMap::CLASSKEY_CALLING_STATION_ID); + $this->assertEquals('Calling-Station-Id', UserCheck2TableMap::CLASSKEY_CALLING_STATION_ID); } /** * Test string with special characters as single inheritance key + * + * @return void */ - public function testSingleInheritanceKeyStringWithSpecialChars() { $schema = <<assertTrue(class_exists('ConstantNameTest3\UserCheck3MacAddress')); $this->assertTrue(class_exists('ConstantNameTest3\Map\UserCheck3TableMap')); $this->assertTrue(defined('\ConstantNameTest3\Map\UserCheck3TableMap::CLASSKEY_KEY')); - $this->assertEquals('Key.-_:*', \ConstantNameTest3\Map\UserCheck3TableMap::CLASSKEY_KEY); + $this->assertEquals('Key.-_:*', UserCheck3TableMap::CLASSKEY_KEY); } + /** + * @return void + */ protected function buildClasses($schema) { $builder = new QuickBuilder(); diff --git a/tests/Propel/Tests/Generator/Model/DatabaseTest.php b/tests/Propel/Tests/Generator/Model/DatabaseTest.php index 2815f50a9b..ca018f396d 100644 --- a/tests/Propel/Tests/Generator/Model/DatabaseTest.php +++ b/tests/Propel/Tests/Generator/Model/DatabaseTest.php @@ -11,12 +11,15 @@ namespace Propel\Tests\Generator\Model; use Propel\Generator\Config\GeneratorConfig; +use Propel\Generator\Exception\BehaviorNotFoundException; +use Propel\Generator\Exception\EngineException; +use Propel\Generator\Exception\InvalidArgumentException; use Propel\Generator\Model\Database; +use Propel\Generator\Model\Schema; use Propel\Generator\Model\Table; use Propel\Generator\Platform\MysqlPlatform; use Propel\Generator\Platform\PgsqlPlatform; use Symfony\Component\Filesystem\Filesystem; -use Propel\Generator\Model\Schema; /** * Unit test suite for Database model class. @@ -25,6 +28,9 @@ */ class DatabaseTest extends ModelTestCase { + /** + * @return void + */ public function testCreateNewDatabase() { $database = new Database('bookstore'); @@ -47,18 +53,21 @@ public function testCreateNewDatabase() $this->assertNull($database->getBehavior('foo')); } + /** + * @return void + */ public function testSetupObject() { $database = new Database(); $database->loadMapping([ - 'name' => 'bookstore', - 'baseClass' => 'CustomBaseObject', - 'baseQueryClass' => 'CustomBaseQueryObject', - 'defaultIdMethod' => 'native', + 'name' => 'bookstore', + 'baseClass' => 'CustomBaseObject', + 'baseQueryClass' => 'CustomBaseQueryObject', + 'defaultIdMethod' => 'native', 'defaultPhpNamingMethod' => 'underscore', - 'heavyIndexing' => 'true', - 'tablePrefix' => 'acme_', - 'defaultStringFormat' => 'XML', + 'heavyIndexing' => 'true', + 'tablePrefix' => 'acme_', + 'defaultStringFormat' => 'XML', ]); $this->assertSame('bookstore', $database->getName()); @@ -72,27 +81,28 @@ public function testSetupObject() $this->assertTrue($database->getHeavyIndexing()); } + /** + * @return void + */ public function testDoFinalization() { $config = $this->getMockBuilder('Propel\Generator\Config\GeneratorConfig') ->disableOriginalConstructor()->getMock(); $schema = $this->getSchemaMock('bookstore', [ - 'generator_config' => $config + 'generator_config' => $config, ]); $platform = $this->getPlatformMock(); $platform ->expects($this->any()) ->method('getMaxColumnNameLength') - ->will($this->returnValue(64)) - ; + ->will($this->returnValue(64)); $platform ->expects($this->any()) ->method('getDomainForType') ->with($this->equalTo('TIMESTAMP')) - ->will($this->returnValue($this->getDomainMock('TIMESTAMP'))) - ; + ->will($this->returnValue($this->getDomainMock('TIMESTAMP'))); $database = new Database(); $database->setPlatform($platform); @@ -105,6 +115,9 @@ public function testDoFinalization() $this->assertSame(2, $database->countTables()); } + /** + * @return void + */ public function testSetParentSchema() { $database = new Database(); @@ -113,6 +126,9 @@ public function testSetParentSchema() $this->assertInstanceOf('Propel\Generator\Model\Schema', $database->getParentSchema()); } + /** + * @return void + */ public function testAddBehavior() { $behavior = $this->getBehaviorMock('foo'); @@ -124,9 +140,12 @@ public function testAddBehavior() $this->assertTrue($database->hasBehavior('foo')); } + /** + * @return void + */ public function testCantAddInvalidBehavior() { - $this->expectException(\Propel\Generator\Exception\BehaviorNotFoundException::class); + $this->expectException(BehaviorNotFoundException::class); $database = new Database(); $behavior = $database->addBehavior(['name' => 'foo']); @@ -135,6 +154,7 @@ public function testCantAddInvalidBehavior() /** * @dataProvider provideBehaviors * + * @return void */ public function testAddArrayBehavior($name, $class) { @@ -150,23 +170,28 @@ public function testAddArrayBehavior($name, $class) $this->assertInstanceOf($type, $behavior); } + /** + * @return void + */ public function testGetNextTableBehavior() { - $table1 = $this->getTableMock('books', ['behaviors' => [ + $table1 = $this->getTableMock('books', [ + 'behaviors' => [ $this->getBehaviorMock('foo', [ - 'is_table_modified' => false, + 'is_table_modified' => false, 'modification_order' => 2, ]), $this->getBehaviorMock('bar', [ - 'is_table_modified' => false, + 'is_table_modified' => false, 'modification_order' => 1, ]), - $this->getBehaviorMock('baz', ['is_table_modified' => true]), + $this->getBehaviorMock('baz', ['is_table_modified' => true]), ]]); - $table2 = $this->getTableMock('authors', ['behaviors' => [ + $table2 = $this->getTableMock('authors', [ + 'behaviors' => [ $this->getBehaviorMock('mix', [ - 'is_table_modified' => false, + 'is_table_modified' => false, 'modification_order' => 1, ]), ]]); @@ -181,9 +206,13 @@ public function testGetNextTableBehavior() $this->assertSame('bar', $behavior->getName()); } + /** + * @return void + */ public function testCantGetNextTableBehavior() { - $table1 = $this->getTableMock('books', ['behaviors' => [ + $table1 = $this->getTableMock('books', [ + 'behaviors' => [ $this->getBehaviorMock('foo', ['is_table_modified' => true]), ]]); @@ -195,6 +224,9 @@ public function testCantGetNextTableBehavior() $this->assertNull($database->getNextTableBehavior()); } + /** + * @return void + */ public function testCantGetTable() { $database = new Database(); @@ -205,6 +237,9 @@ public function testCantGetTable() $this->assertFalse($database->hasTableByPhpName('foo')); } + /** + * @return void + */ public function testAddNamespacedTable() { $table = $this->getTableMock('books', ['namespace' => '\Acme']); @@ -215,6 +250,9 @@ public function testAddNamespacedTable() $this->assertTrue($database->hasTable('books')); } + /** + * @return void + */ public function testAddTable() { $table = $this->getTableMock('books', [ @@ -235,9 +273,11 @@ public function testAddTable() $this->assertTrue($database->hasTableByPhpName('Books')); $this->assertSame($table, $database->getTable('books')); $this->assertSame($table, $database->getTableByPhpName('Books')); - } + /** + * @return void + */ public function testAddArrayTable() { $database = new Database(); @@ -260,9 +300,12 @@ public function testAddArrayTable() $this->assertCount(3, $database->getTablesForSql()); } + /** + * @return void + */ public function testAddSameTableTwice() { - $this->expectException(\Propel\Generator\Exception\EngineException::class); + $this->expectException(EngineException::class); $database = new Database(); $database->addTable(['name' => 'authors']); @@ -286,13 +329,16 @@ public function provideBehaviors() ]; } + /** + * @return void + */ public function testGetGeneratorConfig() { $config = $this->getMockBuilder('Propel\Generator\Config\GeneratorConfig') ->disableOriginalConstructor()->getMock(); $schema = $this->getSchemaMock('bookstore', [ - 'generator_config' => $config + 'generator_config' => $config, ]); $database = new Database(); @@ -301,6 +347,9 @@ public function testGetGeneratorConfig() $this->assertInstanceOf('Propel\Generator\Config\GeneratorConfig', $database->getGeneratorConfig()); } + /** + * @return void + */ public function testGetBuildProperty() { $config = $this->getMockBuilder('Propel\Generator\Config\GeneratorConfig') @@ -310,11 +359,10 @@ public function testGetBuildProperty() ->expects($this->once()) ->method('getConfigProperty') ->with($this->equalTo('generator.database.adapters.mysql.tableType')) - ->will($this->returnValue('InnoDB')) - ; + ->will($this->returnValue('InnoDB')); $schema = $this->getSchemaMock('bookstore', [ - 'generator_config' => $config + 'generator_config' => $config, ]); $database = new Database(); @@ -323,6 +371,9 @@ public function testGetBuildProperty() $this->assertSame('InnoDB', $database->getBuildProperty('generator.database.adapters.mysql.tableType')); } + /** + * @return void + */ public function testAddArrayDomain() { $copiedDomain = $this->getDomainMock('original'); @@ -331,19 +382,21 @@ public function testAddArrayDomain() $platform ->expects($this->once()) ->method('getDomainForType') - ->will($this->returnValue($copiedDomain)) - ; + ->will($this->returnValue($copiedDomain)); $database = new Database(); $database->setPlatform($platform); - $domain1 = $database->addDomain(['name' => 'foo']); + $domain1 = $database->addDomain(['name' => 'foo']); $this->assertInstanceOf('Propel\Generator\Model\Domain', $domain1); $this->assertSame($domain1, $database->getDomain('foo')); $this->assertNull($database->getDomain('baz')); } + /** + * @return void + */ public function testAddDomain() { $domain1 = $this->getDomainMock('foo'); @@ -358,9 +411,12 @@ public function testAddDomain() $this->assertNull($database->getDomain('baz')); } + /** + * @return void + */ public function testSetInvalidDefaultStringFormat() { - $this->expectException(\Propel\Generator\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $database = new Database(); $database->setDefaultStringFormat('FOO'); @@ -369,6 +425,7 @@ public function testSetInvalidDefaultStringFormat() /** * @dataProvider provideSupportedFormats * + * @return void */ public function testSetDefaultStringFormat($format) { @@ -388,6 +445,9 @@ public function provideSupportedFormats() ]; } + /** + * @return void + */ public function testSetHeavyIndexing() { $database = new Database(); @@ -397,6 +457,9 @@ public function testSetHeavyIndexing() $this->assertTrue($database->getHeavyIndexing()); } + /** + * @return void + */ public function testSetBaseClasses() { $database = new Database(); @@ -405,6 +468,9 @@ public function testSetBaseClasses() $this->assertSame('CustomBaseObject', $database->getBaseClass()); } + /** + * @return void + */ public function testSetBaseQueryClasses() { $database = new Database(); @@ -413,6 +479,9 @@ public function testSetBaseQueryClasses() $this->assertSame('CustomBaseQueryObject', $database->getBaseQueryClass()); } + /** + * @return void + */ public function testSetDefaultIdMethod() { $database = new Database(); @@ -421,6 +490,9 @@ public function testSetDefaultIdMethod() $this->assertSame('native', $database->getDefaultIdMethod()); } + /** + * @return void + */ public function testSetDefaultPhpNamingMethodStrategy() { $database = new Database(); @@ -429,6 +501,9 @@ public function testSetDefaultPhpNamingMethodStrategy() $this->assertSame('foo', $database->getDefaultPhpNamingMethod()); } + /** + * @return void + */ public function testAddTableWithSameNameOnDifferentSchema() { $db = new Database(); @@ -444,6 +519,9 @@ public function testAddTableWithSameNameOnDifferentSchema() $this->assertEquals('bis.t1', $t1b->getName()); } + /** + * @return void + */ public function testAutoNamespaceToDatabaseSchemaName() { $yamlConf = <<platform = new MysqlPlatform(); } + /** + * @return void + */ public function testCompareNoDifference() { $c1 = new Column(); @@ -43,6 +48,9 @@ public function testCompareNoDifference() $this->assertEquals([], ColumnComparator::compareColumns($c1, $c2)); } + /** + * @return void + */ public function testCompareType() { $c1 = new Column(); @@ -50,12 +58,15 @@ public function testCompareType() $c2 = new Column(); $c2->getDomain()->copy($this->platform->getDomainForType('LONGVARCHAR')); $expectedChangedProperties = [ - 'type' => ['VARCHAR', 'LONGVARCHAR'], + 'type' => ['VARCHAR', 'LONGVARCHAR'], 'sqlType' => ['VARCHAR', 'TEXT'], ]; $this->assertEquals($expectedChangedProperties, ColumnComparator::compareColumns($c1, $c2)); } + /** + * @return void + */ public function testCompareScale() { $c1 = new Column(); @@ -66,6 +77,9 @@ public function testCompareScale() $this->assertEquals($expectedChangedProperties, ColumnComparator::compareColumns($c1, $c2)); } + /** + * @return void + */ public function testCompareSize() { $c1 = new Column(); @@ -76,6 +90,9 @@ public function testCompareSize() $this->assertEquals($expectedChangedProperties, ColumnComparator::compareColumns($c1, $c2)); } + /** + * @return void + */ public function testCompareSqlType() { $c1 = new Column(); @@ -87,6 +104,9 @@ public function testCompareSqlType() $this->assertEquals($expectedChangedProperties, ColumnComparator::compareColumns($c1, $c2)); } + /** + * @return void + */ public function testCompareNotNull() { $c1 = new Column(); @@ -97,6 +117,9 @@ public function testCompareNotNull() $this->assertEquals($expectedChangedProperties, ColumnComparator::compareColumns($c1, $c2)); } + /** + * @return void + */ public function testCompareDefaultValueToNull() { $c1 = new Column(); @@ -104,11 +127,14 @@ public function testCompareDefaultValueToNull() $c2 = new Column(); $expectedChangedProperties = [ 'defaultValueType' => [ColumnDefaultValue::TYPE_VALUE, null], - 'defaultValueValue' => [123, null] + 'defaultValueValue' => [123, null], ]; $this->assertEquals($expectedChangedProperties, ColumnComparator::compareColumns($c1, $c2)); } + /** + * @return void + */ public function testCompareDefaultValueFromNull() { $c1 = new Column(); @@ -116,11 +142,14 @@ public function testCompareDefaultValueFromNull() $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); $expectedChangedProperties = [ 'defaultValueType' => [null, ColumnDefaultValue::TYPE_VALUE], - 'defaultValueValue' => [null, 123] + 'defaultValueValue' => [null, 123], ]; $this->assertEquals($expectedChangedProperties, ColumnComparator::compareColumns($c1, $c2)); } + /** + * @return void + */ public function testCompareDefaultValueValue() { $c1 = new Column(); @@ -128,11 +157,14 @@ public function testCompareDefaultValueValue() $c2 = new Column(); $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(456, ColumnDefaultValue::TYPE_VALUE)); $expectedChangedProperties = [ - 'defaultValueValue' => [123, 456] + 'defaultValueValue' => [123, 456], ]; $this->assertEquals($expectedChangedProperties, ColumnComparator::compareColumns($c1, $c2)); } + /** + * @return void + */ public function testCompareDefaultValueType() { $c1 = new Column(); @@ -140,23 +172,28 @@ public function testCompareDefaultValueType() $c2 = new Column(); $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_EXPR)); $expectedChangedProperties = [ - 'defaultValueType' => [ColumnDefaultValue::TYPE_VALUE, ColumnDefaultValue::TYPE_EXPR] + 'defaultValueType' => [ColumnDefaultValue::TYPE_VALUE, ColumnDefaultValue::TYPE_EXPR], ]; $this->assertEquals($expectedChangedProperties, ColumnComparator::compareColumns($c1, $c2)); } /** * @see http://www.propelorm.org/ticket/1141 + * + * @return void */ public function testCompareDefaultExrpCurrentTimestamp() { $c1 = new Column(); - $c1->getDomain()->setDefaultValue(new ColumnDefaultValue("NOW()", ColumnDefaultValue::TYPE_EXPR)); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue('NOW()', ColumnDefaultValue::TYPE_EXPR)); $c2 = new Column(); - $c2->getDomain()->setDefaultValue(new ColumnDefaultValue("CURRENT_TIMESTAMP", ColumnDefaultValue::TYPE_EXPR)); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue('CURRENT_TIMESTAMP', ColumnDefaultValue::TYPE_EXPR)); $this->assertEquals([], ColumnComparator::compareColumns($c1, $c2)); } + /** + * @return void + */ public function testCompareAutoincrement() { $c1 = new Column(); @@ -167,6 +204,9 @@ public function testCompareAutoincrement() $this->assertEquals($expectedChangedProperties, ColumnComparator::compareColumns($c1, $c2)); } + /** + * @return void + */ public function testCompareMultipleDifferences() { $c1 = new Column(); @@ -181,11 +221,11 @@ public function testCompareMultipleDifferences() $expectedChangedProperties = [ 'type' => ['INTEGER', 'DOUBLE'], 'sqlType' => ['INTEGER', 'DOUBLE'], - 'scale' => [NULL, 2], - 'size' => [NULL, 3], + 'scale' => [null, 2], + 'size' => [null, 3], 'notNull' => [false, true], - 'defaultValueType' => [NULL, ColumnDefaultValue::TYPE_VALUE], - 'defaultValueValue' => [NULL, 123] + 'defaultValueType' => [null, ColumnDefaultValue::TYPE_VALUE], + 'defaultValueValue' => [null, 123], ]; $this->assertEquals($expectedChangedProperties, ColumnComparator::compareColumns($c1, $c2)); } diff --git a/tests/Propel/Tests/Generator/Model/Diff/DatabaseTableComparatorTest.php b/tests/Propel/Tests/Generator/Model/Diff/DatabaseTableComparatorTest.php index c45db367ec..7cbfb6c29a 100644 --- a/tests/Propel/Tests/Generator/Model/Diff/DatabaseTableComparatorTest.php +++ b/tests/Propel/Tests/Generator/Model/Diff/DatabaseTableComparatorTest.php @@ -13,24 +13,29 @@ use Propel\Generator\Model\Column; use Propel\Generator\Model\ColumnDefaultValue; use Propel\Generator\Model\Database; -use Propel\Generator\Model\Table; use Propel\Generator\Model\Diff\DatabaseComparator; use Propel\Generator\Model\Diff\DatabaseDiff; use Propel\Generator\Model\Diff\TableComparator; +use Propel\Generator\Model\Table; use Propel\Generator\Platform\MysqlPlatform; use Propel\Tests\TestCase; /** * Tests for the Table method of the DatabaseComparator service class. - * */ class PropelDatabaseTableComparatorTest extends TestCase { + /** + * @return void + */ public function setUp(): void { $this->platform = new MysqlPlatform(); } + /** + * @return void + */ public function testCompareSameTables() { $d1 = new Database(); @@ -62,6 +67,9 @@ public function testCompareSameTables() $this->assertFalse(DatabaseComparator::computeDiff($d1, $d2)); } + /** + * @return void + */ public function testCompareNotSameTables() { $d1 = new Database(); @@ -75,6 +83,9 @@ public function testCompareNotSameTables() $this->assertTrue($diff instanceof DatabaseDiff); } + /** + * @return void + */ public function testCompareCaseInsensitive() { $d1 = new Database(); @@ -87,6 +98,9 @@ public function testCompareCaseInsensitive() $this->assertFalse(DatabaseComparator::computeDiff($d1, $d2, true)); } + /** + * @return void + */ public function testCompareAddedTable() { $d1 = new Database(); @@ -123,6 +137,9 @@ public function testCompareAddedTable() $this->assertEquals(['Bar' => $t4], $databaseDiff->getAddedTables()); } + /** + * @return void + */ public function testCompareAddedTableSkipSql() { $d1 = new Database(); @@ -158,6 +175,9 @@ public function testCompareAddedTableSkipSql() $this->assertEquals(0, $nbDiffs); } + /** + * @return void + */ public function testCompareRemovedTable() { $d1 = new Database(); @@ -194,6 +214,9 @@ public function testCompareRemovedTable() $this->assertEquals(['Bar' => $t2], $databaseDiff->getRemovedTables()); } + /** + * @return void + */ public function testCompareRemovedTableSkipSql() { $d1 = new Database(); @@ -229,6 +252,9 @@ public function testCompareRemovedTableSkipSql() $this->assertEquals(0, $nbDiffs); } + /** + * @return void + */ public function testCompareModifiedTable() { $d1 = new Database(); @@ -271,6 +297,9 @@ public function testCompareModifiedTable() $this->assertEquals(['Foo_Table' => $tableDiff], $databaseDiff->getModifiedTables()); } + /** + * @return void + */ public function testCompareRenamedTable() { $d1 = new Database(); @@ -312,7 +341,9 @@ public function testCompareRenamedTable() $this->assertEquals([], $databaseDiff->getRemovedTables()); } - + /** + * @return void + */ public function testCompareSeveralTableDifferences() { $d1 = new Database(); @@ -368,6 +399,9 @@ public function testCompareSeveralTableDifferences() $this->assertEquals(['Foo_Table' => $tableDiff], $databaseDiff->getModifiedTables()); } + /** + * @return void + */ public function testCompareSeveralRenamedSameTables() { $d1 = new Database(); @@ -417,7 +451,9 @@ public function testCompareSeveralRenamedSameTables() $this->assertEquals(['table1', 'table2'], array_keys($databaseDiff->getRemovedTables())); } - + /** + * @return void + */ public function testRemoveTable() { $dc = new DatabaseComparator(); @@ -434,7 +470,6 @@ public function testRemoveTable() $d1->addTable($t1); $d2 = new Database(); - // with renaming false and remove false $diff = DatabaseComparator::computeDiff($d1, $d2, false, false, false); $this->assertFalse($diff); @@ -452,6 +487,9 @@ public function testRemoveTable() $this->assertInstanceOf('Propel\Generator\Model\Diff\DatabaseDiff', $diff); } + /** + * @return void + */ public function testExcludedTablesWithoutRenaming() { $dc = new DatabaseComparator(); @@ -487,7 +525,6 @@ public function testExcludedTablesWithoutRenaming() $diff = DatabaseComparator::computeDiff($d1, $d2, false, false, true, ['Bar']); $this->assertInstanceOf('Propel\Generator\Model\Diff\DatabaseDiff', $diff); - $d1 = new Database(); $t1 = new Table('Foo'); $c1 = new Column('col1'); @@ -504,6 +541,9 @@ public function testExcludedTablesWithoutRenaming() $this->assertInstanceOf('Propel\Generator\Model\Diff\DatabaseDiff', $diff); } + /** + * @return void + */ public function testExcludedTablesWithRenaming() { $dc = new DatabaseComparator(); @@ -539,7 +579,6 @@ public function testExcludedTablesWithRenaming() $diff = DatabaseComparator::computeDiff($d1, $d2, false, true, true, ['Bar']); $this->assertInstanceOf('Propel\Generator\Model\Diff\DatabaseDiff', $diff); - $d1 = new Database(); $t1 = new Table('Foo'); $c1 = new Column('col1'); @@ -555,5 +594,4 @@ public function testExcludedTablesWithRenaming() $diff = DatabaseComparator::computeDiff($d1, $d2, false, true, true, ['Bar']); $this->assertInstanceOf('Propel\Generator\Model\Diff\DatabaseDiff', $diff); } - } diff --git a/tests/Propel/Tests/Generator/Model/Diff/ForeignKeyComparatorTest.php b/tests/Propel/Tests/Generator/Model/Diff/ForeignKeyComparatorTest.php index d8c3e14fb8..ca78034aea 100644 --- a/tests/Propel/Tests/Generator/Model/Diff/ForeignKeyComparatorTest.php +++ b/tests/Propel/Tests/Generator/Model/Diff/ForeignKeyComparatorTest.php @@ -10,17 +10,19 @@ */ use Propel\Generator\Model\Column; +use Propel\Generator\Model\Diff\ForeignKeyComparator; use Propel\Generator\Model\ForeignKey; use Propel\Generator\Model\Table; -use Propel\Generator\Model\Diff\ForeignKeyComparator; -use \Propel\Tests\TestCase; +use Propel\Tests\TestCase; /** * Tests for the ColumnComparator service class. - * */ class PropelForeignComparatorTest extends TestCase { + /** + * @return void + */ public function testCompareNoDifference() { $c1 = new Column('Foo'); @@ -38,6 +40,9 @@ public function testCompareNoDifference() $this->assertFalse(ForeignKeyComparator::computeDiff($fk1, $fk2)); } + /** + * @return void + */ public function testCompareCaseInsensitive() { $c1 = new Column('Foo'); @@ -55,6 +60,9 @@ public function testCompareCaseInsensitive() $this->assertFalse(ForeignKeyComparator::computeDiff($fk1, $fk2, true)); } + /** + * @return void + */ public function testCompareLocalColumn() { $c1 = new Column('Foo'); @@ -72,6 +80,9 @@ public function testCompareLocalColumn() $this->assertTrue(ForeignKeyComparator::computeDiff($fk1, $fk2)); } + /** + * @return void + */ public function testCompareForeignColumn() { $c1 = new Column('Foo'); @@ -89,6 +100,9 @@ public function testCompareForeignColumn() $this->assertTrue(ForeignKeyComparator::computeDiff($fk1, $fk2)); } + /** + * @return void + */ public function testCompareColumnMappings() { $c1 = new Column('Foo'); @@ -109,6 +123,9 @@ public function testCompareColumnMappings() $this->assertTrue(ForeignKeyComparator::computeDiff($fk1, $fk2)); } + /** + * @return void + */ public function testCompareOnUpdate() { $c1 = new Column('Foo'); @@ -128,6 +145,9 @@ public function testCompareOnUpdate() $this->assertTrue(ForeignKeyComparator::computeDiff($fk1, $fk2)); } + /** + * @return void + */ public function testCompareOnDelete() { $c1 = new Column('Foo'); @@ -147,6 +167,9 @@ public function testCompareOnDelete() $this->assertTrue(ForeignKeyComparator::computeDiff($fk1, $fk2)); } + /** + * @return void + */ public function testCompareSort() { $c1 = new Column('Foo'); diff --git a/tests/Propel/Tests/Generator/Model/Diff/IndexComparatorTest.php b/tests/Propel/Tests/Generator/Model/Diff/IndexComparatorTest.php index 091a99bfa4..f7dd35f225 100644 --- a/tests/Propel/Tests/Generator/Model/Diff/IndexComparatorTest.php +++ b/tests/Propel/Tests/Generator/Model/Diff/IndexComparatorTest.php @@ -10,17 +10,19 @@ */ use Propel\Generator\Model\Column; +use Propel\Generator\Model\Diff\IndexComparator; use Propel\Generator\Model\Index; use Propel\Generator\Model\Unique; -use Propel\Generator\Model\Diff\IndexComparator; -use \Propel\Tests\TestCase; +use Propel\Tests\TestCase; /** * Tests for the ColumnComparator service class. - * */ class IndexComparatorTest extends TestCase { + /** + * @return void + */ public function testCompareNoDifference() { $c1 = new Column('Foo'); @@ -44,6 +46,9 @@ public function testCompareNoDifference() $this->assertFalse(IndexComparator::computeDiff($i1, $i2)); } + /** + * @return void + */ public function testCompareCaseInsensitive() { $c1 = new Column('Foo'); @@ -55,6 +60,9 @@ public function testCompareCaseInsensitive() $this->assertFalse(IndexComparator::computeDiff($i1, $i2, true)); } + /** + * @return void + */ public function testCompareType() { $c1 = new Column('Foo'); @@ -66,6 +74,9 @@ public function testCompareType() $this->assertTrue(IndexComparator::computeDiff($i1, $i2)); } + /** + * @return void + */ public function testCompareDifferentColumns() { $c1 = new Column('Foo'); @@ -76,6 +87,9 @@ public function testCompareDifferentColumns() $this->assertTrue(IndexComparator::computeDiff($i1, $i2)); } + /** + * @return void + */ public function testCompareDifferentOrder() { $c1 = new Column('Foo'); @@ -90,5 +104,4 @@ public function testCompareDifferentOrder() $i2->addColumn($c3); $this->assertTrue(IndexComparator::computeDiff($i1, $i2)); } - } diff --git a/tests/Propel/Tests/Generator/Model/Diff/PropelTableColumnComparatorTest.php b/tests/Propel/Tests/Generator/Model/Diff/PropelTableColumnComparatorTest.php index c574e2521c..6f67e9bb5a 100644 --- a/tests/Propel/Tests/Generator/Model/Diff/PropelTableColumnComparatorTest.php +++ b/tests/Propel/Tests/Generator/Model/Diff/PropelTableColumnComparatorTest.php @@ -11,24 +11,29 @@ use Propel\Generator\Model\Column; use Propel\Generator\Model\ColumnDefaultValue; -use Propel\Generator\Model\Table; +use Propel\Generator\Model\Diff\ColumnComparator; use Propel\Generator\Model\Diff\TableComparator; use Propel\Generator\Model\Diff\TableDiff; -use Propel\Generator\Model\Diff\ColumnComparator; +use Propel\Generator\Model\Table; use Propel\Generator\Platform\MysqlPlatform; -use \Propel\Tests\TestCase; +use Propel\Tests\TestCase; /** * Tests for the Column methods of the TableComparator service class. - * */ class PropelTableColumnComparatorTest extends TestCase { + /** + * @return void + */ public function setUp(): void { $this->platform = new MysqlPlatform(); } + /** + * @return void + */ public function testCompareSameColumns() { $t1 = new Table(); @@ -51,6 +56,9 @@ public function testCompareSameColumns() $this->assertFalse(TableComparator::computeDiff($t1, $t2)); } + /** + * @return void + */ public function testCompareNotSameColumns() { $t1 = new Table(); @@ -64,6 +72,9 @@ public function testCompareNotSameColumns() $this->assertTrue($diff instanceof TableDiff); } + /** + * @return void + */ public function testCompareCaseInsensitive() { $t1 = new Table(); @@ -79,6 +90,9 @@ public function testCompareCaseInsensitive() $this->assertFalse(TableComparator::computeDiff($t1, $t2, true)); } + /** + * @return void + */ public function testCompareAddedColumn() { $t1 = new Table(); @@ -101,6 +115,9 @@ public function testCompareAddedColumn() $this->assertEquals(['Foo' => $c2], $tableDiff->getAddedColumns()); } + /** + * @return void + */ public function testCompareRemovedColumn() { $t1 = new Table(); @@ -123,6 +140,9 @@ public function testCompareRemovedColumn() $this->assertEquals(['Bar' => $c1], $tableDiff->getRemovedColumns()); } + /** + * @return void + */ public function testCompareModifiedColumn() { $t1 = new Table(); @@ -151,6 +171,9 @@ public function testCompareModifiedColumn() $this->assertEquals(['Foo' => $columnDiff], $tableDiff->getModifiedColumns()); } + /** + * @return void + */ public function testCompareRenamedColumn() { $t1 = new Table(); @@ -182,6 +205,9 @@ public function testCompareRenamedColumn() $this->assertEquals([], $tableDiff->getRemovedColumns()); } + /** + * @return void + */ public function testCompareSeveralColumnDifferences() { $t1 = new Table(); @@ -230,6 +256,9 @@ public function testCompareSeveralColumnDifferences() $this->assertEquals(['col1' => $columnDiff], $tableDiff->getModifiedColumns()); } + /** + * @return void + */ public function testCompareSeveralRenamedSameColumns() { $t1 = new Table(); @@ -272,5 +301,4 @@ public function testCompareSeveralRenamedSameColumns() $this->assertEquals([], $tableDiff->getRemovedColumns()); $this->assertEquals([], $tableDiff->getModifiedColumns()); } - } diff --git a/tests/Propel/Tests/Generator/Model/Diff/PropelTableForeignKeyComparatorTest.php b/tests/Propel/Tests/Generator/Model/Diff/PropelTableForeignKeyComparatorTest.php index 8c24a148be..9bcf3539d0 100644 --- a/tests/Propel/Tests/Generator/Model/Diff/PropelTableForeignKeyComparatorTest.php +++ b/tests/Propel/Tests/Generator/Model/Diff/PropelTableForeignKeyComparatorTest.php @@ -10,25 +10,30 @@ */ use Propel\Generator\Model\Column; -use Propel\Generator\Model\ForeignKey; -use Propel\Generator\Model\Table; +use Propel\Generator\Model\Database; use Propel\Generator\Model\Diff\TableComparator; use Propel\Generator\Model\Diff\TableDiff; +use Propel\Generator\Model\ForeignKey; +use Propel\Generator\Model\Table; use Propel\Generator\Platform\MysqlPlatform; -use Propel\Generator\Model\Database; -use \Propel\Tests\TestCase; +use Propel\Tests\TestCase; /** * Tests for the Column methods of the TableComparator service class. - * */ class PropelTableForeignKeyComparatorTest extends TestCase { + /** + * @return void + */ public function setUp(): void { $this->platform = new MysqlPlatform(); } + /** + * @return void + */ public function testCompareSameFks() { $c1 = new Column('Foo'); @@ -47,6 +52,9 @@ public function testCompareSameFks() $this->assertFalse(TableComparator::computeDiff($t1, $t2)); } + /** + * @return void + */ public function testCompareNotSameFks() { $c1 = new Column('Foo'); @@ -62,6 +70,9 @@ public function testCompareNotSameFks() $this->assertTrue($diff instanceof TableDiff); } + /** + * @return void + */ public function testCaseInsensitive() { $t1 = new Table('Baz'); @@ -82,6 +93,9 @@ public function testCaseInsensitive() $this->assertFalse($diff); } + /** + * @return void + */ public function testCompareAddedFks() { $db1 = new Database(); @@ -109,6 +123,9 @@ public function testCompareAddedFks() $this->assertEquals(['Baz_fk_9c94ed' => $fk2], $tableDiff->getAddedFks()); } + /** + * @return void + */ public function testCompareRemovedFks() { $db1 = new Database(); @@ -136,6 +153,9 @@ public function testCompareRemovedFks() $this->assertEquals(['Baz_fk_9c94ed' => $fk1], $tableDiff->getRemovedFks()); } + /** + * @return void + */ public function testCompareModifiedFks() { $db1 = new Database(); diff --git a/tests/Propel/Tests/Generator/Model/Diff/PropelTableIndexComparatorTest.php b/tests/Propel/Tests/Generator/Model/Diff/PropelTableIndexComparatorTest.php index 23c35570da..7a334aaeec 100644 --- a/tests/Propel/Tests/Generator/Model/Diff/PropelTableIndexComparatorTest.php +++ b/tests/Propel/Tests/Generator/Model/Diff/PropelTableIndexComparatorTest.php @@ -11,25 +11,30 @@ use Propel\Generator\Model\Column; use Propel\Generator\Model\ColumnDefaultValue; +use Propel\Generator\Model\Diff\TableComparator; +use Propel\Generator\Model\Diff\TableDiff; use Propel\Generator\Model\Index; use Propel\Generator\Model\Table; use Propel\Generator\Model\Unique; -use Propel\Generator\Model\Diff\TableComparator; -use Propel\Generator\Model\Diff\TableDiff; use Propel\Generator\Platform\MysqlPlatform; -use \Propel\Tests\TestCase; +use Propel\Tests\TestCase; /** * Tests for the Column methods of the TableComparator service class. - * */ class PropelTableIndexComparatorTest extends TestCase { + /** + * @return void + */ public function setUp(): void { $this->platform = new MysqlPlatform(); } + /** + * @return void + */ public function testCompareSameIndices() { $t1 = new Table(); @@ -58,6 +63,9 @@ public function testCompareSameIndices() $this->assertFalse(TableComparator::computeDiff($t1, $t2)); } + /** + * @return void + */ public function testCompareNotSameIndices() { $t1 = new Table(); @@ -87,6 +95,9 @@ public function testCompareNotSameIndices() $this->assertTrue($diff instanceof TableDiff); } + /** + * @return void + */ public function testCompareCaseInsensitive() { $t1 = new Table(); @@ -117,6 +128,9 @@ public function testCompareCaseInsensitive() $this->assertNotFalse(TableComparator::computeDiff($t1, $t2, $caseInsensitive = false)); } + /** + * @return void + */ public function testCompareAddedIndices() { $t1 = new Table(); @@ -142,6 +156,9 @@ public function testCompareAddedIndices() $this->assertEquals(['Foo_Index' => $i2], $tableDiff->getAddedIndices()); } + /** + * @return void + */ public function testCompareRemovedIndices() { $t1 = new Table(); @@ -167,6 +184,9 @@ public function testCompareRemovedIndices() $this->assertEquals(['Bar_Index' => $i1], $tableDiff->getRemovedIndices()); } + /** + * @return void + */ public function testCompareModifiedIndices() { $t1 = new Table(); @@ -199,5 +219,4 @@ public function testCompareModifiedIndices() $this->assertEquals(1, count($tableDiff->getModifiedIndices())); $this->assertEquals(['Foo_Index' => [$i1, $i2]], $tableDiff->getModifiedIndices()); } - } diff --git a/tests/Propel/Tests/Generator/Model/Diff/PropelTablePkColumnComparatorTest.php b/tests/Propel/Tests/Generator/Model/Diff/PropelTablePkColumnComparatorTest.php index 065b4199e6..609868be47 100644 --- a/tests/Propel/Tests/Generator/Model/Diff/PropelTablePkColumnComparatorTest.php +++ b/tests/Propel/Tests/Generator/Model/Diff/PropelTablePkColumnComparatorTest.php @@ -11,23 +11,28 @@ use Propel\Generator\Model\Column; use Propel\Generator\Model\ColumnDefaultValue; -use Propel\Generator\Model\Table; use Propel\Generator\Model\Diff\TableComparator; use Propel\Generator\Model\Diff\TableDiff; +use Propel\Generator\Model\Table; use Propel\Generator\Platform\MysqlPlatform; -use \Propel\Tests\TestCase; +use Propel\Tests\TestCase; /** * Tests for the Column methods of the TableComparator service class. - * */ class PropelTablePkColumnComparatorTest extends TestCase { + /** + * @return void + */ public function setUp(): void { $this->platform = new MysqlPlatform(); } + /** + * @return void + */ public function testCompareSamePks() { $t1 = new Table(); @@ -44,6 +49,9 @@ public function testCompareSamePks() $this->assertFalse(TableComparator::computeDiff($t1, $t2)); } + /** + * @return void + */ public function testCompareNotSamePks() { $t1 = new Table(); @@ -58,6 +66,9 @@ public function testCompareNotSamePks() $this->assertTrue($diff instanceof TableDiff); } + /** + * @return void + */ public function testCompareAddedPkColumn() { $t1 = new Table(); @@ -80,6 +91,9 @@ public function testCompareAddedPkColumn() $this->assertEquals(['Foo' => $c2], $tableDiff->getAddedPkColumns()); } + /** + * @return void + */ public function testCompareRemovedPkColumn() { $t1 = new Table(); @@ -102,6 +116,9 @@ public function testCompareRemovedPkColumn() $this->assertEquals(['Foo' => $c1], $tableDiff->getRemovedPkColumns()); } + /** + * @return void + */ public function testCompareRenamedPkColumn() { $t1 = new Table(); @@ -135,6 +152,9 @@ public function testCompareRenamedPkColumn() $this->assertEquals([], $tableDiff->getRemovedPkColumns()); } + /** + * @return void + */ public function testCompareSeveralPrimaryKeyDifferences() { $t1 = new Table(); @@ -185,6 +205,9 @@ public function testCompareSeveralPrimaryKeyDifferences() $this->assertEquals(['col3' => $c3], $tableDiff->getRemovedPkColumns()); } + /** + * @return void + */ public function testCompareSeveralRenamedSamePrimaryKeys() { $t1 = new Table(); @@ -232,5 +255,4 @@ public function testCompareSeveralRenamedSamePrimaryKeys() $this->assertEquals([], $tableDiff->getAddedPkColumns()); $this->assertEquals([], $tableDiff->getRemovedPkColumns()); } - } diff --git a/tests/Propel/Tests/Generator/Model/Diff/TableDiffTest.php b/tests/Propel/Tests/Generator/Model/Diff/TableDiffTest.php index 8ad8cd8b66..dffaab2504 100644 --- a/tests/Propel/Tests/Generator/Model/Diff/TableDiffTest.php +++ b/tests/Propel/Tests/Generator/Model/Diff/TableDiffTest.php @@ -2,6 +2,7 @@ namespace Propel\Tests\Generator\Model\Diff; +use PHPUnit\Framework\TestCase; use Propel\Generator\Model\Column; use Propel\Generator\Model\Database; use Propel\Generator\Model\Diff\ColumnDiff; @@ -9,15 +10,17 @@ use Propel\Generator\Model\ForeignKey; use Propel\Generator\Model\Index; use Propel\Generator\Model\Table; -use Propel\Generator\Model\Unique; use Propel\Generator\Platform\DefaultPlatform; -class TableDiffTest extends \PHPUnit\Framework\TestCase +class TableDiffTest extends TestCase { + /** + * @return void + */ public function testDefaultObjectState() { $fromTable = new Table('article'); - $toTable = new Table('article'); + $toTable = new Table('article'); $diff = $this->createTableDiff($fromTable, $toTable); @@ -39,6 +42,9 @@ public function testDefaultObjectState() $this->assertFalse($diff->hasRenamedPkColumns()); } + /** + * @return void + */ public function testSetAddedColumns() { $column = new Column('is_published', 'boolean'); @@ -51,6 +57,9 @@ public function testSetAddedColumns() $this->assertTrue($diff->hasAddedColumns()); } + /** + * @return void + */ public function testRemoveAddedColumn() { $diff = $this->createTableDiff(); @@ -62,6 +71,9 @@ public function testRemoveAddedColumn() $this->assertFalse($diff->hasAddedColumns()); } + /** + * @return void + */ public function testSetRemovedColumns() { $column = new Column('is_active'); @@ -74,6 +86,9 @@ public function testSetRemovedColumns() $this->assertTrue($diff->hasRemovedColumns()); } + /** + * @return void + */ public function testSetRemoveRemovedColumn() { $diff = $this->createTableDiff(); @@ -86,6 +101,9 @@ public function testSetRemoveRemovedColumn() $this->assertFalse($diff->hasRemovedColumns()); } + /** + * @return void + */ public function testSetModifiedColumns() { $columnDiff = new ColumnDiff(); @@ -97,10 +115,13 @@ public function testSetModifiedColumns() $this->assertTrue($diff->hasModifiedColumns()); } + /** + * @return void + */ public function testAddRenamedColumn() { $fromColumn = new Column('is_published', 'boolean'); - $toColumn = new Column('is_active', 'boolean'); + $toColumn = new Column('is_active', 'boolean'); $diff = $this->createTableDiff(); $diff->setRenamedColumns([ [ $fromColumn, $toColumn ] ]); @@ -109,6 +130,9 @@ public function testAddRenamedColumn() $this->assertTrue($diff->hasRenamedColumns()); } + /** + * @return void + */ public function testSetAddedPkColumns() { $column = new Column('id', 'integer', 7); @@ -122,6 +146,9 @@ public function testSetAddedPkColumns() $this->assertTrue($diff->hasModifiedPk()); } + /** + * @return void + */ public function testRemoveAddedPkColumn() { $column = new Column('id', 'integer', 7); @@ -137,6 +164,8 @@ public function testRemoveAddedPkColumn() /** * @expectedException \Propel\Generator\Exception\DiffException + * + * @return void */ public function testCantAddNonPrimaryKeyColumn() { @@ -144,6 +173,9 @@ public function testCantAddNonPrimaryKeyColumn() $diff->addAddedPkColumn('id', new Column('id', 'integer')); } + /** + * @return void + */ public function testSetRemovedPkColumns() { $column = new Column('id', 'integer'); @@ -156,6 +188,9 @@ public function testSetRemovedPkColumns() $this->assertTrue($diff->hasModifiedPk()); } + /** + * @return void + */ public function testRemoveRemovedPkColumn() { $diff = $this->createTableDiff(); @@ -165,6 +200,9 @@ public function testRemoveRemovedPkColumn() $this->assertEmpty($diff->getRemovedPkColumns()); } + /** + * @return void + */ public function testSetRenamedPkColumns() { $diff = $this->createTableDiff(); @@ -174,6 +212,9 @@ public function testSetRenamedPkColumns() $this->assertTrue($diff->hasModifiedPk()); } + /** + * @return void + */ public function testSetAddedIndices() { $table = new Table(); @@ -189,6 +230,9 @@ public function testSetAddedIndices() $this->assertTrue($diff->hasAddedIndices()); } + /** + * @return void + */ public function testSetRemovedIndices() { $table = new Table(); @@ -204,6 +248,9 @@ public function testSetRemovedIndices() $this->assertTrue($diff->hasRemovedIndices()); } + /** + * @return void + */ public function testSetModifiedIndices() { $table = new Table('users'); @@ -224,6 +271,9 @@ public function testSetModifiedIndices() $this->assertTrue($diff->hasModifiedIndices()); } + /** + * @return void + */ public function testSetAddedFks() { $fk = new ForeignKey('fk_blog_author'); @@ -235,6 +285,9 @@ public function testSetAddedFks() $this->assertTrue($diff->hasAddedFks()); } + /** + * @return void + */ public function testRemoveAddedFk() { $diff = $this->createTableDiff(); @@ -245,6 +298,9 @@ public function testRemoveAddedFk() $this->assertFalse($diff->hasAddedFks()); } + /** + * @return void + */ public function testSetRemovedFk() { $diff = $this->createTableDiff(); @@ -254,6 +310,9 @@ public function testSetRemovedFk() $this->assertTrue($diff->hasRemovedFks()); } + /** + * @return void + */ public function testRemoveRemovedFk() { $diff = $this->createTableDiff(); @@ -264,6 +323,9 @@ public function testRemoveRemovedFk() $this->assertFalse($diff->hasRemovedFks()); } + /** + * @return void + */ public function testSetModifiedFks() { $diff = $this->createTableDiff(); @@ -273,6 +335,9 @@ public function testSetModifiedFks() $this->assertTrue($diff->hasModifiedFks()); } + /** + * @return void + */ public function testGetSimpleReverseDiff() { $tableA = new Table('users'); @@ -286,6 +351,9 @@ public function testGetSimpleReverseDiff() $this->assertSame($tableB, $reverseDiff->getFromTable()); } + /** + * @return void + */ public function testReverseDiffHasModifiedColumns() { $c1 = new Column('title', 'varchar', 50); @@ -302,6 +370,9 @@ public function testReverseDiffHasModifiedColumns() $this->assertEquals([ 'title' => $reverseColumnDiff ], $reverseDiff->getModifiedColumns()); } + /** + * @return void + */ public function testReverseDiffHasRemovedColumns() { $column = new Column('slug', 'varchar', 100); @@ -314,6 +385,9 @@ public function testReverseDiffHasRemovedColumns() $this->assertSame($column, $reverseDiff->getRemovedColumn('slug')); } + /** + * @return void + */ public function testReverseDiffHasAddedColumns() { $column = new Column('slug', 'varchar', 100); @@ -326,6 +400,9 @@ public function testReverseDiffHasAddedColumns() $this->assertSame($column, $reverseDiff->getAddedColumn('slug')); } + /** + * @return void + */ public function testReverseDiffHasRenamedColumns() { $columnA = new Column('login', 'varchar', 15); @@ -338,6 +415,9 @@ public function testReverseDiffHasRenamedColumns() $this->assertSame([ [ $columnB, $columnA ] ], $reverseDiff->getRenamedColumns()); } + /** + * @return void + */ public function testReverseDiffHasAddedPkColumns() { $column = new Column('client_id', 'integer'); @@ -351,6 +431,9 @@ public function testReverseDiffHasAddedPkColumns() $this->assertTrue($reverseDiff->hasAddedPkColumns()); } + /** + * @return void + */ public function testReverseDiffHasRemovedPkColumns() { $column = new Column('client_id', 'integer'); @@ -364,6 +447,9 @@ public function testReverseDiffHasRemovedPkColumns() $this->assertTrue($reverseDiff->hasRemovedPkColumns()); } + /** + * @return void + */ public function testReverseDiffHasRenamedPkColumn() { $fromColumn = new Column('post_id', 'integer'); @@ -380,6 +466,9 @@ public function testReverseDiffHasRenamedPkColumn() $this->assertSame([[ $toColumn, $fromColumn ]], $reverseDiff->getRenamedPkColumns()); } + /** + * @return void + */ public function testReverseDiffHasAddedIndices() { $table = new Table(); @@ -396,6 +485,9 @@ public function testReverseDiffHasAddedIndices() $this->assertCount(1, $reverseDiff->getAddedIndices()); } + /** + * @return void + */ public function testReverseDiffHasRemovedIndices() { $table = new Table(); @@ -412,6 +504,9 @@ public function testReverseDiffHasRemovedIndices() $this->assertCount(1, $reverseDiff->getRemovedIndices()); } + /** + * @return void + */ public function testReverseDiffHasModifiedIndices() { $table = new Table(); @@ -432,6 +527,9 @@ public function testReverseDiffHasModifiedIndices() $this->assertSame([ 'i1' => [ $toIndex, $fromIndex ]], $reverseDiff->getModifiedIndices()); } + /** + * @return void + */ public function testReverseDiffHasRemovedFks() { $diff = $this->createTableDiff(); @@ -442,6 +540,9 @@ public function testReverseDiffHasRemovedFks() $this->assertCount(1, $reverseDiff->getRemovedFks()); } + /** + * @return void + */ public function testReverseDiffHasAddedFks() { $diff = $this->createTableDiff(); @@ -452,6 +553,9 @@ public function testReverseDiffHasAddedFks() $this->assertCount(1, $reverseDiff->getAddedFks()); } + /** + * @return void + */ public function testReverseDiffHasModifiedFks() { $fromFk = new ForeignKey('fk_1'); @@ -465,7 +569,7 @@ public function testReverseDiffHasModifiedFks() $this->assertSame([ 'fk_1' => [ $toFk, $fromFk ]], $reverseDiff->getModifiedFks()); } - private function createTableDiff(Table $fromTable = null, Table $toTable = null) + private function createTableDiff(?Table $fromTable = null, ?Table $toTable = null) { if (null === $fromTable) { $fromTable = new Table('users'); @@ -478,6 +582,9 @@ private function createTableDiff(Table $fromTable = null, Table $toTable = null) return new TableDiff($fromTable, $toTable); } + /** + * @return void + */ public function testToString() { $tableA = new Table('A'); @@ -521,7 +628,7 @@ public function testToString() $diff->addModifiedIndex('test_index', $index, $indexChanged); $diff->addRemovedIndex('test_index', $index); - $string = (string) $diff; + $string = (string)$diff; $expected = ' A: addedColumns: @@ -554,6 +661,9 @@ public function testToString() $this->assertEquals($expected, $string); } + /** + * @return void + */ public function testMagicClone() { $diff = new TableDiff(new Table('A'), new Table('B')); diff --git a/tests/Propel/Tests/Generator/Model/DomainTest.php b/tests/Propel/Tests/Generator/Model/DomainTest.php index 54151b6f1e..1663867f00 100644 --- a/tests/Propel/Tests/Generator/Model/DomainTest.php +++ b/tests/Propel/Tests/Generator/Model/DomainTest.php @@ -10,6 +10,7 @@ namespace Propel\Tests\Generator\Model; +use Propel\Generator\Exception\EngineException; use Propel\Generator\Model\Domain; /** @@ -19,6 +20,9 @@ */ class DomainTest extends ModelTestCase { + /** + * @return void + */ public function testCreateNewDomain() { $domain = new Domain('FLOAT', 'DOUBLE', 10, 2); @@ -32,6 +36,7 @@ public function testCreateNewDomain() /** * @dataProvider provideDomainData * + * @return void */ public function testSetupObject($default, $expression) { @@ -39,12 +44,11 @@ public function testSetupObject($default, $expression) $platform ->expects($this->any()) ->method('getDomainForType') - ->will($this->returnValue(new Domain('BOOLEAN'))) - ; + ->will($this->returnValue(new Domain('BOOLEAN'))); $domain = new Domain(); $domain->setDatabase($this->getDatabaseMock('bookstore', [ - 'platform' => $platform + 'platform' => $platform, ])); $domain->loadMapping([ 'type' => 'BOOLEAN', @@ -72,6 +76,9 @@ public function provideDomainData() ]; } + /** + * @return void + */ public function testSetDatabase() { $domain = new Domain(); @@ -80,6 +87,9 @@ public function testSetDatabase() $this->assertInstanceOf('Propel\Generator\Model\Database', $domain->getDatabase()); } + /** + * @return void + */ public function testReplaceMappingAndSqlTypes() { $value = $this->getColumnDefaultValueMock(); @@ -94,6 +104,9 @@ public function testReplaceMappingAndSqlTypes() $this->assertInstanceOf('Propel\Generator\Model\ColumnDefaultValue', $value); } + /** + * @return void + */ public function testGetNoPhpDefaultValue() { $domain = new Domain(); @@ -101,14 +114,16 @@ public function testGetNoPhpDefaultValue() $this->assertNull($domain->getPhpDefaultValue()); } + /** + * @return void + */ public function testGetPhpDefaultValue() { $value = $this->getColumnDefaultValueMock(); $value ->expects($this->once()) ->method('getValue') - ->will($this->returnValue('foo')) - ; + ->will($this->returnValue('foo')); $domain = new Domain('VARCHAR'); $domain->setDefaultValue($value); @@ -119,6 +134,7 @@ public function testGetPhpDefaultValue() /** * @dataProvider provideBooleanValues * + * @return void */ public function testGetBooleanValue($mappingType, $booleanAsString, $expected) { @@ -126,8 +142,7 @@ public function testGetBooleanValue($mappingType, $booleanAsString, $expected) $value ->expects($this->once()) ->method('getValue') - ->will($this->returnValue($booleanAsString)) - ; + ->will($this->returnValue($booleanAsString)); $domain = new Domain($mappingType); $domain->setDefaultValue($value); @@ -153,25 +168,28 @@ public function provideBooleanValues() ]; } + /** + * @return void + */ public function testCantGetPhpDefaultValue() { $value = $this->getColumnDefaultValueMock(); $value ->expects($this->once()) ->method('isExpression') - ->will($this->returnValue(true)) - ; + ->will($this->returnValue(true)); $domain = new Domain(); $domain->setDefaultValue($value); - $this->expectException(\Propel\Generator\Exception\EngineException::class); + $this->expectException(EngineException::class); $domain->getPhpDefaultValue(); } /** * @dataProvider provideSizeDefinitions * + * @return void */ public function testGetSizeDefinition($size, $scale, $definition) { @@ -189,6 +207,9 @@ public function provideSizeDefinitions() ]; } + /** + * @return void + */ public function testCopyDomain() { $value = $this->getColumnDefaultValueMock(); @@ -219,8 +240,7 @@ private function getColumnDefaultValueMock() $value = $this ->getMockBuilder('Propel\Generator\Model\ColumnDefaultValue') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); return $value; } diff --git a/tests/Propel/Tests/Generator/Model/ForeignKeyTest.php b/tests/Propel/Tests/Generator/Model/ForeignKeyTest.php index 9d96ed4082..f33b4117bf 100644 --- a/tests/Propel/Tests/Generator/Model/ForeignKeyTest.php +++ b/tests/Propel/Tests/Generator/Model/ForeignKeyTest.php @@ -19,6 +19,9 @@ */ class ForeignKeyTest extends ModelTestCase { + /** + * @return void + */ public function testCreateNewForeignKey() { $fk = new ForeignKey('book_author'); @@ -30,46 +33,45 @@ public function testCreateNewForeignKey() $this->assertFalse($fk->isSkipSql()); } + /** + * @return void + */ public function testForeignKeyIsForeignPrimaryKey() { - $database = $this->getDatabaseMock('bookstore'); - $platform = $this->getPlatformMock(); + $database = $this->getDatabaseMock('bookstore'); + $platform = $this->getPlatformMock(); $foreignTable = $this->getTableMock('authors'); - $localTable = $this->getTableMock('books', [ + $localTable = $this->getTableMock('books', [ 'platform' => $platform, - 'database' => $database + 'database' => $database, ]); - $idColumn = $this->getColumnMock('id'); + $idColumn = $this->getColumnMock('id'); $authorIdColumn = $this->getColumnMock('author_id'); $database ->expects($this->any()) ->method('getTable') ->with($this->equalTo('authors')) - ->will($this->returnValue($foreignTable)) - ; + ->will($this->returnValue($foreignTable)); $foreignTable ->expects($this->once()) ->method('getPrimaryKey') - ->will($this->returnValue([$idColumn])) - ; + ->will($this->returnValue([$idColumn])); $foreignTable ->expects($this->any()) ->method('getColumn') ->with($this->equalTo('id')) - ->will($this->returnValue($idColumn)) - ; + ->will($this->returnValue($idColumn)); $localTable ->expects($this->any()) ->method('getColumn') ->with($this->equalTo('author_id')) - ->will($this->returnValue($authorIdColumn)) - ; + ->will($this->returnValue($authorIdColumn)); $fk = new ForeignKey(); $fk->setTable($localTable); @@ -85,22 +87,23 @@ public function testForeignKeyIsForeignPrimaryKey() $this->assertSame($idColumn, $fk->getForeignColumn(0)); } + /** + * @return void + */ public function testForeignKeyDoesNotUseRequiredColumns() { $column = $this->getColumnMock('author_id'); $column ->expects($this->once()) ->method('isNotNull') - ->will($this->returnValue(false)) - ; + ->will($this->returnValue(false)); $table = $this->getTableMock('books'); $table ->expects($this->once()) ->method('getColumn') ->with($this->equalTo('author_id')) - ->will($this->returnValue($column)) - ; + ->will($this->returnValue($column)); $fk = new ForeignKey(); $fk->setTable($table); @@ -109,22 +112,23 @@ public function testForeignKeyDoesNotUseRequiredColumns() $this->assertFalse($fk->isLocalColumnsRequired()); } + /** + * @return void + */ public function testForeignKeyUsesRequiredColumns() { $column = $this->getColumnMock('author_id'); $column ->expects($this->once()) ->method('isNotNull') - ->will($this->returnValue(true)) - ; + ->will($this->returnValue(true)); $table = $this->getTableMock('books'); $table ->expects($this->once()) ->method('getColumn') ->with($this->equalTo('author_id')) - ->will($this->returnValue($column)) - ; + ->will($this->returnValue($column)); $fk = new ForeignKey(); $fk->setTable($table); @@ -133,6 +137,9 @@ public function testForeignKeyUsesRequiredColumns() $this->assertTrue($fk->isLocalColumnsRequired()); } + /** + * @return void + */ public function testCantGetInverseForeignKey() { $database = $this->getDatabaseMock('bookstore'); @@ -141,15 +148,14 @@ public function testCantGetInverseForeignKey() $localTable = $this->getTableMock('books', [ 'platform' => $platform, - 'database' => $database + 'database' => $database, ]); $database ->expects($this->any()) ->method('getTable') ->with($this->equalTo('authors')) - ->will($this->returnValue($foreignTable)) - ; + ->will($this->returnValue($foreignTable)); $inversedFk = new ForeignKey(); $inversedFk->addReference('id', 'author_id'); @@ -158,8 +164,7 @@ public function testCantGetInverseForeignKey() $foreignTable ->expects($this->any()) ->method('getForeignKeys') - ->will($this->returnValue([])) - ; + ->will($this->returnValue([])); $fk = new ForeignKey(); $fk->setTable($localTable); @@ -172,6 +177,9 @@ public function testCantGetInverseForeignKey() $this->assertFalse($fk->isMatchedByInverseFK()); } + /** + * @return void + */ public function testGetInverseForeignKey() { $database = $this->getDatabaseMock('bookstore'); @@ -180,15 +188,14 @@ public function testGetInverseForeignKey() $localTable = $this->getTableMock('books', [ 'platform' => $platform, - 'database' => $database + 'database' => $database, ]); $database ->expects($this->any()) ->method('getTable') ->with($this->equalTo('bookstore.authors')) - ->will($this->returnValue($foreignTable)) - ; + ->will($this->returnValue($foreignTable)); $inversedFk = new ForeignKey(); $inversedFk->addReference('id', 'author_id'); @@ -199,8 +206,7 @@ public function testGetInverseForeignKey() $foreignTable ->expects($this->any()) ->method('getForeignKeys') - ->will($this->returnValue([$inversedFk])) - ; + ->will($this->returnValue([$inversedFk])); $fk = new ForeignKey(); $fk->setTable($localTable); @@ -215,6 +221,9 @@ public function testGetInverseForeignKey() $this->assertTrue($fk->isMatchedByInverseFK()); } + /** + * @return void + */ public function testGetLocalColumn() { $column = $this->getColumnMock('id'); @@ -224,8 +233,7 @@ public function testGetLocalColumn() ->expects($this->any()) ->method('getColumn') ->with($this->equalTo('author_id')) - ->will($this->returnValue($column)) - ; + ->will($this->returnValue($column)); $fk = new ForeignKey(); $fk->setTable($table); @@ -235,6 +243,9 @@ public function testGetLocalColumn() $this->assertInstanceOf('Propel\Generator\Model\Column', $fk->getLocalColumn(0)); } + /** + * @return void + */ public function testForeignKeyIsNotLocalPrimaryKey() { $pks = [$this->getColumnMock('id')]; @@ -243,8 +254,7 @@ public function testForeignKeyIsNotLocalPrimaryKey() $table ->expects($this->once()) ->method('getPrimaryKey') - ->will($this->returnValue($pks)) - ; + ->will($this->returnValue($pks)); $fk = new ForeignKey(); $fk->setTable($table); @@ -253,6 +263,9 @@ public function testForeignKeyIsNotLocalPrimaryKey() $this->assertFalse($fk->isLocalPrimaryKey()); } + /** + * @return void + */ public function testForeignKeyIsLocalPrimaryKey() { $pks = [ @@ -264,8 +277,7 @@ public function testForeignKeyIsLocalPrimaryKey() $table ->expects($this->once()) ->method('getPrimaryKey') - ->will($this->returnValue($pks)) - ; + ->will($this->returnValue($pks)); $fk = new ForeignKey(); $fk->setTable($table); @@ -275,6 +287,9 @@ public function testForeignKeyIsLocalPrimaryKey() $this->assertTrue($fk->isLocalPrimaryKey()); } + /** + * @return void + */ public function testGetOtherForeignKeys() { $fk = new ForeignKey(); @@ -287,14 +302,16 @@ public function testGetOtherForeignKeys() $table ->expects($this->once()) ->method('getForeignKeys') - ->will($this->returnValue($fks)) - ; + ->will($this->returnValue($fks)); $fk->setTable($table); $this->assertCount(2, $fk->getOtherFks()); } + /** + * @return void + */ public function testSetForeignSchemaName() { $fk = new ForeignKey(); @@ -303,6 +320,9 @@ public function testSetForeignSchemaName() $this->assertSame('authors', $fk->getForeignSchemaName()); } + /** + * @return void + */ public function testClearReferences() { $fk = new ForeignKey(); @@ -314,6 +334,9 @@ public function testClearReferences() $this->assertCount(0, $fk->getForeignColumns()); } + /** + * @return void + */ public function testAddMultipleReferences() { $fk = new ForeignKey(); @@ -333,6 +356,9 @@ public function testAddMultipleReferences() $this->assertSame('id', $fk->getMappedForeignColumn('author_id')); } + /** + * @return void + */ public function testAddSingleStringReference() { $fk = new ForeignKey(); @@ -345,6 +371,9 @@ public function testAddSingleStringReference() $this->assertSame('author_id', $fk->getMappedLocalColumn('id')); } + /** + * @return void + */ public function testAddSingleArrayReference() { $reference = ['local' => 'author_id', 'foreign' => 'id']; @@ -359,6 +388,9 @@ public function testAddSingleArrayReference() $this->assertSame($reference['local'], $fk->getMappedLocalColumn($reference['foreign'])); } + /** + * @return void + */ public function testAddSingleColumnReference() { $fk = new ForeignKey(); @@ -374,14 +406,16 @@ public function testAddSingleColumnReference() $this->assertSame('author_id', $fk->getMappedLocalColumn('id')); } + /** + * @return void + */ public function testSetTable() { $table = $this->getTableMock('book'); $table ->expects($this->once()) ->method('getSchema') - ->will($this->returnValue('books')) - ; + ->will($this->returnValue('books')); $fk = new ForeignKey(); $fk->setTable($table); @@ -391,6 +425,9 @@ public function testSetTable() $this->assertSame('book', $fk->getTableName()); } + /** + * @return void + */ public function testSetDefaultJoin() { $fk = new ForeignKey(); @@ -399,6 +436,9 @@ public function testSetDefaultJoin() $this->assertSame('INNER', $fk->getDefaultJoin()); } + /** + * @return void + */ public function testSetNames() { $fk = new ForeignKey(); @@ -411,6 +451,9 @@ public function testSetNames() $this->assertSame('Books', $fk->getRefPhpName()); } + /** + * @return void + */ public function testSkipSql() { $fk = new ForeignKey(); @@ -419,6 +462,9 @@ public function testSkipSql() $this->assertTrue($fk->isSkipSql()); } + /** + * @return void + */ public function testGetOnActionBehaviors() { $fk = new ForeignKey(); @@ -435,6 +481,7 @@ public function testGetOnActionBehaviors() /** * @dataProvider provideOnActionBehaviors * + * @return void */ public function testNormalizeForeignKey($behavior, $normalized) { diff --git a/tests/Propel/Tests/Generator/Model/IndexTest.php b/tests/Propel/Tests/Generator/Model/IndexTest.php index f5ce6da894..3862ffc83a 100644 --- a/tests/Propel/Tests/Generator/Model/IndexTest.php +++ b/tests/Propel/Tests/Generator/Model/IndexTest.php @@ -19,6 +19,9 @@ */ class IndexTest extends ModelTestCase { + /** + * @return void + */ public function testCreateNamedIndex() { $index = new Index('foo_idx'); @@ -32,6 +35,9 @@ public function testCreateNamedIndex() $this->assertFalse($index->hasColumns()); } + /** + * @return void + */ public function testSetupObject() { $index = new Index(); @@ -44,6 +50,7 @@ public function testSetupObject() /** * @dataProvider provideTableSpecificAttributes * + * @return void */ public function testCreateDefaultIndexName($tableName, $maxColumnNameLength, $indexName) { @@ -51,13 +58,12 @@ public function testCreateDefaultIndexName($tableName, $maxColumnNameLength, $in $database ->expects($this->any()) ->method('getMaxColumnNameLength') - ->will($this->returnValue($maxColumnNameLength)) - ; + ->will($this->returnValue($maxColumnNameLength)); $table = $this->getTableMock($tableName, [ 'common_name' => $tableName, - 'indices' => [ new Index(), new Index() ], - 'database' => $database, + 'indices' => [ new Index(), new Index() ], + 'database' => $database, ]); $index = new Index(); @@ -77,6 +83,7 @@ public function provideTableSpecificAttributes() /** * @dataProvider provideColumnDefinitions * + * @return void */ public function testAddIndexedColumns($columns) { @@ -112,6 +119,9 @@ public function provideColumnDefinitions() return $dataset; } + /** + * @return void + */ public function testResetColumnsSize() { $columns[] = $this->getColumnMock('foo', [ 'size' => 100 ]); @@ -128,6 +138,9 @@ public function testResetColumnsSize() $this->assertFalse($index->hasColumnSize('bar')); } + /** + * @return void + */ public function testNoColumnAtFirstPosition() { $index = new Index(); @@ -137,6 +150,8 @@ public function testNoColumnAtFirstPosition() /** * @dataProvider provideColumnAttributes + * + * @return void */ public function testNoColumnAtPositionCaseSensitivity($name, $case) { @@ -154,6 +169,9 @@ public function provideColumnAttributes() ]; } + /** + * @return void + */ public function testNoSizedColumnAtPosition() { $size = 5; @@ -165,6 +183,9 @@ public function testNoSizedColumnAtPosition() $this->assertFalse($index->hasColumnAtPosition(0, 'foo', $size)); } + /** + * @return void + */ public function testHasColumnAtFirstPosition() { $index = new Index(); diff --git a/tests/Propel/Tests/Generator/Model/InheritanceTest.php b/tests/Propel/Tests/Generator/Model/InheritanceTest.php index 3824243f97..71ccbe2394 100644 --- a/tests/Propel/Tests/Generator/Model/InheritanceTest.php +++ b/tests/Propel/Tests/Generator/Model/InheritanceTest.php @@ -20,13 +20,15 @@ */ class InheritanceTest extends TestCase { + /** + * @return void + */ public function testCreateNewInheritance() { $column = $this ->getMockBuilder('Propel\Generator\Model\Column') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); $inheritance = new Inheritance(); $inheritance->setPackage('Foo'); @@ -42,6 +44,9 @@ public function testCreateNewInheritance() $this->assertSame('Foo\Bar', $inheritance->getClassName()); } + /** + * @return void + */ public function testSetupObject() { $inheritance = new Inheritance(); diff --git a/tests/Propel/Tests/Generator/Model/MappingModelTest.php b/tests/Propel/Tests/Generator/Model/MappingModelTest.php index cfa658b240..811ba68338 100644 --- a/tests/Propel/Tests/Generator/Model/MappingModelTest.php +++ b/tests/Propel/Tests/Generator/Model/MappingModelTest.php @@ -20,6 +20,8 @@ class MappingModelTest extends TestCase { /** * @dataProvider providerForGetDefaultValueForArray + * + * @return void */ public function testGetDefaultValueForArray($value, $expected) { @@ -49,10 +51,16 @@ public function getDefaultValueForArray($value) return parent::getDefaultValueForArray($value); } + /** + * @return void + */ public function appendXml(DOMNode $node) { } + /** + * @return void + */ protected function setupObject() { } diff --git a/tests/Propel/Tests/Generator/Model/ModelTestCase.php b/tests/Propel/Tests/Generator/Model/ModelTestCase.php index 6c954ee4ac..14e3f1c4f6 100644 --- a/tests/Propel/Tests/Generator/Model/ModelTestCase.php +++ b/tests/Propel/Tests/Generator/Model/ModelTestCase.php @@ -9,7 +9,7 @@ */ namespace Propel\Tests\Generator\Model; -use Propel\Generator\Model\Index; + use Propel\Tests\TestCase; /** @@ -22,16 +22,17 @@ abstract class ModelTestCase extends TestCase /** * Returns a dummy Behavior object. * - * @param string $name The behavior name - * @param array $options An array of options + * @param string $name The behavior name + * @param array $options An array of options + * * @return Behavior */ protected function getBehaviorMock($name, array $options = []) { $defaults = [ 'additional_builders' => [], - 'is_table_modified' => false, - 'modification_order' => 0, + 'is_table_modified' => false, + 'modification_order' => 0, ]; $options = array_merge($defaults, $options); @@ -39,49 +40,41 @@ protected function getBehaviorMock($name, array $options = []) $behavior = $this ->getMockBuilder('Propel\Generator\Model\Behavior') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); $behavior ->expects($this->any()) - ->method('setTable') - ; + ->method('setTable'); $behavior ->expects($this->any()) ->method('getName') - ->will($this->returnValue($name)) - ; + ->will($this->returnValue($name)); $behavior ->expects($this->any()) ->method('getId') - ->will($this->returnValue($name)) - ; + ->will($this->returnValue($name)); $behavior ->expects($this->any()) ->method('getAdditionalBuilders') - ->will($this->returnValue($options['additional_builders'])) - ; + ->will($this->returnValue($options['additional_builders'])); $behavior ->expects($this->any()) ->method('hasAdditionalBuilders') - ->will($this->returnValue(count($options['additional_builders']) > 0)) - ; + ->will($this->returnValue(count($options['additional_builders']) > 0)); $behavior ->expects($this->any()) ->method('isTableModified') - ->will($this->returnValue($options['is_table_modified'])) - ; + ->will($this->returnValue($options['is_table_modified'])); $behavior ->expects($this->any()) ->method('getTableModificationOrder') - ->will($this->returnValue($options['modification_order'])) - ; + ->will($this->returnValue($options['modification_order'])); return $behavior; } @@ -89,8 +82,9 @@ protected function getBehaviorMock($name, array $options = []) /** * Returns a dummy ForeignKey object. * - * @param string $name The foreign key name - * @param array $options An array of options + * @param string|null $name The foreign key name + * @param array $options An array of options + * * @return ForeignKey */ protected function getForeignKeyMock($name = null, array $options = []) @@ -107,38 +101,32 @@ protected function getForeignKeyMock($name = null, array $options = []) $fk = $this ->getMockBuilder('Propel\Generator\Model\ForeignKey') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); $fk ->expects($this->any()) ->method('getName') - ->will($this->returnValue($name)) - ; + ->will($this->returnValue($name)); $fk ->expects($this->any()) ->method('getTable') - ->will($this->returnValue($options['table'])) - ; + ->will($this->returnValue($options['table'])); $fk ->expects($this->any()) ->method('getForeignTableName') - ->will($this->returnValue($options['foreign_table_name'])) - ; + ->will($this->returnValue($options['foreign_table_name'])); $fk ->expects($this->any()) ->method('getLocalColumns') - ->will($this->returnValue($options['local_columns'])) - ; + ->will($this->returnValue($options['local_columns'])); $fk ->expects($this->any()) ->method('getOtherFks') - ->will($this->returnValue($options['other_fks'])) - ; + ->will($this->returnValue($options['other_fks'])); return $fk; } @@ -146,9 +134,10 @@ protected function getForeignKeyMock($name = null, array $options = []) /** * Returns a dummy Index object. * - * @param string $name The index name - * @param array $options An array of options - * @return Index + * @param string|null $name The index name + * @param array $options An array of options + * + * @return \Propel\Generator\Model\Index */ protected function getIndexMock($name = null, array $options = []) { @@ -161,17 +150,14 @@ protected function getIndexMock($name = null, array $options = []) $index = $this ->getMockBuilder('Propel\Generator\Model\Index') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); $index ->expects($this->once()) - ->method('setTable') - ; + ->method('setTable'); $index ->expects($this->any()) ->method('getName') - ->will($this->returnValue($name)) - ; + ->will($this->returnValue($name)); return $index; } @@ -179,8 +165,9 @@ protected function getIndexMock($name = null, array $options = []) /** * Returns a dummy Unique object. * - * @param string $name The unique index name - * @param array $options An array of options + * @param string|null $name The unique index name + * @param array $options An array of options + * * @return Unique */ protected function getUniqueIndexMock($name = null, array $options = []) @@ -188,17 +175,14 @@ protected function getUniqueIndexMock($name = null, array $options = []) $unique = $this ->getMockBuilder('Propel\Generator\Model\Unique') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); $unique ->expects($this->once()) - ->method('setTable') - ; + ->method('setTable'); $unique ->expects($this->once()) ->method('getName') - ->will($this->returnValue($name)) - ; + ->will($this->returnValue($name)); return $unique; } @@ -206,8 +190,9 @@ protected function getUniqueIndexMock($name = null, array $options = []) /** * Returns a dummy Schema object. * - * @param string $name The schema name - * @param array $options An array of options + * @param string|null $name The schema name + * @param array $options An array of options + * * @return Schema */ protected function getSchemaMock($name = null, array $options = []) @@ -221,18 +206,15 @@ protected function getSchemaMock($name = null, array $options = []) $schema = $this ->getMockBuilder('Propel\Generator\Model\Schema') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); $schema ->expects($this->any()) ->method('getName') - ->will($this->returnValue($name)) - ; + ->will($this->returnValue($name)); $schema ->expects($this->any()) ->method('getGeneratorConfig') - ->will($this->returnValue($options['generator_config'])) - ; + ->will($this->returnValue($options['generator_config'])); return $schema; } @@ -240,9 +222,10 @@ protected function getSchemaMock($name = null, array $options = []) /** * Returns a dummy Platform object. * - * @param boolean $supportsSchemas Whether or not the platform supports schemas - * @param array $options An array of options - * @param string $schemaDelimiter + * @param bool $supportsSchemas Whether or not the platform supports schemas + * @param array $options An array of options + * @param string $schemaDelimiter + * * @return PlatformInterface */ protected function getPlatformMock($supportsSchemas = true, array $options = [], $schemaDelimiter = '.') @@ -256,26 +239,22 @@ protected function getPlatformMock($supportsSchemas = true, array $options = [], $platform = $this ->getMockBuilder('Propel\Generator\Platform\DefaultPlatform') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); $platform ->expects($this->any()) ->method('supportsSchemas') - ->will($this->returnValue($supportsSchemas)) - ; + ->will($this->returnValue($supportsSchemas)); $platform ->expects($this->any()) ->method('getSchemaDelimiter') - ->will($this->returnValue($schemaDelimiter)) - ; + ->will($this->returnValue($schemaDelimiter)); $platform ->expects($this->any()) ->method('getMaxColumnNameLength') - ->will($this->returnValue($options['max_column_name_length'])) - ; + ->will($this->returnValue($options['max_column_name_length'])); return $platform; } @@ -283,8 +262,9 @@ protected function getPlatformMock($supportsSchemas = true, array $options = [], /** * Returns a dummy Domain object. * - * @param string $name - * @param array $options An array of options + * @param string|null $name + * @param array $options An array of options + * * @return Domain */ protected function getDomainMock($name = null, array $options = []) @@ -296,14 +276,12 @@ protected function getDomainMock($name = null, array $options = []) $domain = $this ->getMockBuilder('Propel\Generator\Model\Domain') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); $domain ->expects($this->any()) ->method('getName') - ->will($this->returnValue($name)) - ; + ->will($this->returnValue($name)); return $domain; } @@ -311,21 +289,22 @@ protected function getDomainMock($name = null, array $options = []) /** * Returns a dummy Table object. * - * @param string $name The table name - * @param array $options An array of options + * @param string $name The table name + * @param array $options An array of options + * * @return Table */ protected function getTableMock($name, array $options = []) { $defaults = [ - 'php_name' => str_replace(' ', '', ucwords(str_replace('_', ' ', $name))), - 'namespace' => null, - 'database' => null, - 'platform' => null, + 'php_name' => str_replace(' ', '', ucwords(str_replace('_', ' ', $name))), + 'namespace' => null, + 'database' => null, + 'platform' => null, 'common_name' => $name, - 'behaviors' => [], - 'indices' => [], - 'unices' => [], + 'behaviors' => [], + 'indices' => [], + 'unices' => [], ]; $options = array_merge($defaults, $options); @@ -333,62 +312,52 @@ protected function getTableMock($name, array $options = []) $table = $this ->getMockBuilder('Propel\Generator\Model\Table') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); $table ->expects($this->any()) ->method('getName') - ->will($this->returnValue($name)) - ; + ->will($this->returnValue($name)); $table ->expects($this->any()) ->method('getCommonName') - ->will($this->returnValue($options['common_name'])) - ; + ->will($this->returnValue($options['common_name'])); $table ->expects($this->any()) ->method('getPhpName') - ->will($this->returnValue($options['php_name'])) - ; + ->will($this->returnValue($options['php_name'])); $table ->expects($this->any()) ->method('getPlatform') - ->will($this->returnValue($options['platform'])) - ; + ->will($this->returnValue($options['platform'])); $table ->expects($this->any()) ->method('getNamespace') - ->will($this->returnValue($options['namespace'])) - ; + ->will($this->returnValue($options['namespace'])); $table ->expects($this->any()) ->method('getBehaviors') - ->will($this->returnValue($options['behaviors'])) - ; + ->will($this->returnValue($options['behaviors'])); $table ->expects($this->any()) ->method('getIndices') - ->will($this->returnValue($options['indices'])) - ; + ->will($this->returnValue($options['indices'])); $table ->expects($this->any()) ->method('getUnices') - ->will($this->returnValue($options['unices'])) - ; + ->will($this->returnValue($options['unices'])); $table ->expects($this->any()) ->method('getDatabase') - ->will($this->returnValue($options['database'])) - ; + ->will($this->returnValue($options['database'])); return $table; } @@ -396,8 +365,9 @@ protected function getTableMock($name, array $options = []) /** * Returns a dummy Database object. * - * @param string $name The database name - * @param array $options An array of options + * @param string $name The database name + * @param array $options An array of options + * * @return Database */ protected function getDatabaseMock($name, array $options = []) @@ -411,18 +381,15 @@ protected function getDatabaseMock($name, array $options = []) $database = $this ->getMockBuilder('Propel\Generator\Model\Database') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); $database ->expects($this->any()) ->method('getName') - ->will($this->returnValue($name)) - ; + ->will($this->returnValue($name)); $database ->expects($this->any()) ->method('getPlatform') - ->will($this->returnValue($options['platform'])) - ; + ->will($this->returnValue($options['platform'])); return $database; } @@ -430,8 +397,9 @@ protected function getDatabaseMock($name, array $options = []) /** * Returns a dummy Column object. * - * @param string $name The column name - * @param array $options An array of options + * @param string $name The column name + * @param array $options An array of options + * * @return Column */ protected function getColumnMock($name, array $options = []) @@ -445,20 +413,17 @@ protected function getColumnMock($name, array $options = []) $column = $this ->getMockBuilder('Propel\Generator\Model\Column') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); $column ->expects($this->any()) ->method('getName') - ->will($this->returnValue($name)) - ; + ->will($this->returnValue($name)); $column ->expects($this->any()) ->method('getSize') - ->will($this->returnValue($options['size'])) - ; + ->will($this->returnValue($options['size'])); return $column; } diff --git a/tests/Propel/Tests/Generator/Model/NameFactoryTest.php b/tests/Propel/Tests/Generator/Model/NameFactoryTest.php index ca41332875..978b6e35db 100644 --- a/tests/Propel/Tests/Generator/Model/NameFactoryTest.php +++ b/tests/Propel/Tests/Generator/Model/NameFactoryTest.php @@ -10,12 +10,11 @@ namespace Propel\Tests\Generator\Model; -use Propel\Generator\Model\Schema; use Propel\Generator\Model\Database; use Propel\Generator\Model\NameFactory; use Propel\Generator\Model\NameGeneratorInterface; +use Propel\Generator\Model\Schema; use Propel\Generator\Platform\MysqlPlatform; - use Propel\Tests\Helpers\BaseTestCase; /** @@ -27,18 +26,18 @@ * the makeInputs() method.

* *

This test assumes that it's being run using the MySQL database - * adapter, DBMM. MySQL has a column length limit of 64 + * adapter, DBMM. MySQL has a column length limit of 64 * characters.

* * @author Daniel Rall - * @version $Id$ + * @version $Id$ */ class NameFactoryTest extends BaseTestCase { - /** The database to mimic in generating the SQL. */ - const DATABASE_TYPE = "mysql"; + public const DATABASE_TYPE = 'mysql'; /** + * @var array * The list of known name generation algorithms, specified as the * fully qualified class names to NameGeneratorInterface * implementations. @@ -46,12 +45,13 @@ class NameFactoryTest extends BaseTestCase private static $ALGORITHMS = [NameFactory::CONSTRAINT_GENERATOR, NameFactory::PHP_GENERATOR]; /** + * @var array * Two dimensional arrays of inputs for each algorithm. */ private $inputs = []; - /** + * @var array * Given the known inputs, the expected name outputs. */ private $outputs = []; @@ -63,11 +63,12 @@ class NameFactoryTest extends BaseTestCase /** * Creates a string of the specified length consisting entirely of - * the character A. Useful for simulating table + * the character A. Useful for simulating table * names, etc. * - * @param int $len the number of characters to include in the string - * @return a string of length len with every character an 'A' + * @param int $len the number of characters to include in the string + * + * @return a string of length len with every character an 'A' */ private static function makeString($len) { @@ -79,41 +80,45 @@ private static function makeString($len) return $buf; } - /** Sets up the Propel model. */ + + /** + * @return void + */ public function setUp(): void { $this->inputs = [ [ - [self::makeString(61), "I", 1], - [self::makeString(61), "I", 2], - [self::makeString(65), "I", 3], - [self::makeString(4), "FK", 1], - [self::makeString(5), "FK", 2] + [self::makeString(61), 'I', 1], + [self::makeString(61), 'I', 2], + [self::makeString(65), 'I', 3], + [self::makeString(4), 'FK', 1], + [self::makeString(5), 'FK', 2], ], [ - ["MY_USER", NameGeneratorInterface::CONV_METHOD_UNDERSCORE], - ["MY_USER", NameGeneratorInterface::CONV_METHOD_PHPNAME], - ["MY_USER", NameGeneratorInterface::CONV_METHOD_NOCHANGE] - ] + ['MY_USER', NameGeneratorInterface::CONV_METHOD_UNDERSCORE], + ['MY_USER', NameGeneratorInterface::CONV_METHOD_PHPNAME], + ['MY_USER', NameGeneratorInterface::CONV_METHOD_NOCHANGE], + ], ]; $this->outputs = [ [ - self::makeString(60) . "_I_1", - self::makeString(60) . "_I_2", - self::makeString(60) . "_I_3", - self::makeString(4) . "_FK_1", - self::makeString(5) . "_FK_2" + self::makeString(60) . '_I_1', + self::makeString(60) . '_I_2', + self::makeString(60) . '_I_3', + self::makeString(4) . '_FK_1', + self::makeString(5) . '_FK_2', ], - ["MyUser", "MYUSER", "MY_USER"] + ['MyUser', 'MYUSER', 'MY_USER'], ]; $schema = new Schema(new MysqlPlatform()); $this->database = new Database(); $schema->addDatabase($this->database); } + /** - * @throws Exception on fail + * @return void */ public function testNames() { @@ -126,7 +131,7 @@ public function testNames() $inputs = $this->makeInputs($algo, $algoInputs[$i]); $generated = NameFactory::generateName($algo, $inputs); $expected = $this->outputs[$algoIndex][$i]; - $this->assertEquals($expected, $generated, "Algorithm " . $algo . " failed to generate an unique name"); + $this->assertEquals($expected, $generated, 'Algorithm ' . $algo . ' failed to generate an unique name'); } } } @@ -135,10 +140,11 @@ public function testNames() * Creates the list of arguments to pass to the specified type of * NameGeneratorInterface implementation. * - * @param algo The class name of the NameGeneratorInterface to + * @param algo The class name of the NameGeneratorInterface to * create an argument list for. - * @param inputs The (possibly partial) list inputs from which to + * @param inputs The (possibly partial) list inputs from which to * generate the final list. + * * @return the list of arguments to pass to the NameGeneratorInterface */ private function makeInputs($algo, $inputs) diff --git a/tests/Propel/Tests/Generator/Model/PhpNameGeneratorTest.php b/tests/Propel/Tests/Generator/Model/PhpNameGeneratorTest.php index df9dda499f..98ad6e9f20 100644 --- a/tests/Propel/Tests/Generator/Model/PhpNameGeneratorTest.php +++ b/tests/Propel/Tests/Generator/Model/PhpNameGeneratorTest.php @@ -9,7 +9,7 @@ */ use Propel\Generator\Model\PhpNameGenerator; -use \Propel\Tests\TestCase; +use Propel\Tests\TestCase; /** * Tests for PhpNameGenerator @@ -34,6 +34,8 @@ public static function phpnameMethodDataProvider() /** * @dataProvider phpnameMethodDataProvider + * + * @return void */ public function testPhpnameMethod($input, $output) { @@ -57,13 +59,14 @@ public static function underscoreMethodDataProvider() /** * @dataProvider underscoreMethodDataProvider + * + * @return void */ public function testUnderscoreMethod($input, $output) { $generator = new TestablePhpNameGenerator(); $this->assertEquals($output, $generator->underscoreMethod($input)); } - } class TestablePhpNameGenerator extends PhpNameGenerator diff --git a/tests/Propel/Tests/Generator/Model/SchemaTest.php b/tests/Propel/Tests/Generator/Model/SchemaTest.php index 492a44a5d8..556fa349c2 100644 --- a/tests/Propel/Tests/Generator/Model/SchemaTest.php +++ b/tests/Propel/Tests/Generator/Model/SchemaTest.php @@ -10,6 +10,7 @@ namespace Propel\Tests\Generator\Model; +use Propel\Generator\Exception\EngineException; use Propel\Generator\Model\Schema; /** @@ -19,6 +20,9 @@ */ class SchemaTest extends ModelTestCase { + /** + * @return void + */ public function testCreateNewSchema() { $platform = $this->getPlatformMock(); @@ -29,6 +33,9 @@ public function testCreateNewSchema() $this->assertFalse($schema->hasMultipleDatabases()); } + /** + * @return void + */ public function testJoinMultipleSchemasWithSameTableTwice() { $booksTable = $this->getTableMock('books'); @@ -37,8 +44,7 @@ public function testJoinMultipleSchemasWithSameTableTwice() $database1 ->expects($this->any()) ->method('getTables') - ->will($this->returnValue([$booksTable])) - ; + ->will($this->returnValue([$booksTable])); $database2 = $this->getDatabaseMock('bookstore'); $database2 @@ -47,14 +53,12 @@ public function testJoinMultipleSchemasWithSameTableTwice() ->will($this->returnValue([ $booksTable, $this->getTableMock('authors'), - ])) - ; + ])); $database2 ->expects($this->any()) ->method('getTable') ->with($this->equalTo('books')) - ->will($this->returnValue(true)) - ; + ->will($this->returnValue(true)); $subSchema1 = new Schema($this->getPlatformMock()); $subSchema1->addDatabase($database1); @@ -62,11 +66,14 @@ public function testJoinMultipleSchemasWithSameTableTwice() $schema = new Schema($this->getPlatformMock()); $schema->addDatabase($database2); - $this->expectException(\Propel\Generator\Exception\EngineException::class); + $this->expectException(EngineException::class); $schema->joinSchemas([$subSchema1]); } + /** + * @return void + */ public function testJoinMultipleSchemasWithSameDatabase() { $behavior = $this->getBehaviorMock('sluggable'); @@ -78,18 +85,15 @@ public function testJoinMultipleSchemasWithSameDatabase() $database ->expects($this->any()) ->method('countTables') - ->will($this->returnValue(count($tables))) - ; + ->will($this->returnValue(count($tables))); $database ->expects($this->any()) ->method('getTables') - ->will($this->returnValue($tables)) - ; + ->will($this->returnValue($tables)); $database ->expects($this->any()) ->method('getBehaviors') - ->will($this->returnValue([$behavior])) - ; + ->will($this->returnValue([$behavior])); $subSchema1 = new Schema($this->getPlatformMock()); $subSchema1->addDatabase($database); @@ -103,6 +107,9 @@ public function testJoinMultipleSchemasWithSameDatabase() $this->assertSame(2, $schema->countTables()); } + /** + * @return void + */ public function testJoinMultipleSchemasWithoutTables() { $subSchema1 = new Schema($this->getPlatformMock()); @@ -124,6 +131,9 @@ public function testJoinMultipleSchemasWithoutTables() $this->assertTrue($schema->hasDatabase('skatestore')); } + /** + * @return void + */ public function testGetFirstDatabase() { $schema = new Schema($this->getPlatformMock()); @@ -132,6 +142,9 @@ public function testGetFirstDatabase() $this->assertSame($db, $schema->getDatabase()); } + /** + * @return void + */ public function testGetDatabase() { $schema = new Schema($this->getPlatformMock()); @@ -142,6 +155,9 @@ public function testGetDatabase() $this->assertTrue($schema->hasDatabase('bookstore')); } + /** + * @return void + */ public function testGetNoDatabase() { $schema = new Schema($this->getPlatformMock()); @@ -149,19 +165,20 @@ public function testGetNoDatabase() $this->assertNull($schema->getDatabase('shoestore', false)); } + /** + * @return void + */ public function testAddArrayDatabase() { $config = $this ->getMockBuilder('Propel\Generator\Config\GeneratorConfig') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); $config ->expects($this->any()) ->method('getConfiguredPlatform') ->with($this->equalTo(null), $this->equalTo('bookstore')) - ->will($this->returnValue($this->getPlatformMock())) - ; + ->will($this->returnValue($this->getPlatformMock())); $schema = new Schema($this->getPlatformMock()); $schema->setGeneratorConfig($config); @@ -173,6 +190,9 @@ public function testAddArrayDatabase() $this->assertFalse($schema->hasMultipleDatabases()); } + /** + * @return void + */ public function testAddArrayDatabaseWithDefaultPlatform() { $schema = new Schema($this->getPlatformMock()); @@ -184,6 +204,9 @@ public function testAddArrayDatabaseWithDefaultPlatform() $this->assertFalse($schema->hasMultipleDatabases()); } + /** + * @return void + */ public function testAddDatabase() { $database1 = $this->getDatabaseMock('bookstore'); @@ -203,6 +226,9 @@ public function testAddDatabase() $this->assertTrue($schema->hasMultipleDatabases()); } + /** + * @return void + */ public function testSetName() { $schema = new Schema(); @@ -212,6 +238,9 @@ public function testSetName() $this->assertSame('bookstore', $schema->getShortName()); } + /** + * @return void + */ public function testSetGeneratorConfig() { $config = $this->getMockBuilder('Propel\Generator\Config\GeneratorConfig') diff --git a/tests/Propel/Tests/Generator/Model/TableTest.php b/tests/Propel/Tests/Generator/Model/TableTest.php index 5cd89bc8c5..ec462b371b 100644 --- a/tests/Propel/Tests/Generator/Model/TableTest.php +++ b/tests/Propel/Tests/Generator/Model/TableTest.php @@ -10,6 +10,8 @@ namespace Propel\Tests\Generator\Model; +use Propel\Generator\Exception\EngineException; +use Propel\Generator\Exception\InvalidArgumentException; use Propel\Generator\Model\Column; use Propel\Generator\Model\Database; use Propel\Generator\Model\Index; @@ -23,6 +25,9 @@ */ class TableTest extends ModelTestCase { + /** + * @return void + */ public function testCreateNewTable() { $table = new Table('books'); @@ -42,6 +47,7 @@ public function testCreateNewTable() /** * @dataProvider provideNamespaces * + * @return void */ public function testSetNamespace($namespace, $expected) { @@ -63,6 +69,9 @@ public function provideNamespaces() ]; } + /** + * @return void + */ public function testGetGeneratorConfig() { $config = $this->getMockBuilder('Propel\Generator\Config\GeneratorConfig') @@ -72,8 +81,7 @@ public function testGetGeneratorConfig() $database ->expects($this->once()) ->method('getGeneratorConfig') - ->will($this->returnValue($config)) - ; + ->will($this->returnValue($config)); $table = new Table(); $table->setDatabase($database); @@ -81,6 +89,9 @@ public function testGetGeneratorConfig() $this->assertSame($config, $table->getGeneratorConfig()); } + /** + * @return void + */ public function testGetBuildProperty() { $table = new Table(); @@ -91,44 +102,45 @@ public function testGetBuildProperty() ->expects($this->once()) ->method('getBuildProperty') ->with('propel.foo.bar') - ->will($this->returnValue('baz')) - ; + ->will($this->returnValue('baz')); $table->setDatabase($database); $this->assertSame('baz', $table->getBuildProperty('propel.foo.bar')); } + /** + * @return void + */ public function testApplyBehaviors() { $behavior = $this->getBehaviorMock('foo'); $behavior ->expects($this->once()) ->method('isTableModified') - ->will($this->returnValue(false)) - ; + ->will($this->returnValue(false)); $behavior ->expects($this->once()) ->method('getTableModifier') - ->will($this->returnValue($behavior)) - ; + ->will($this->returnValue($behavior)); $behavior ->expects($this->once()) - ->method('modifyTable') - ; + ->method('modifyTable'); $behavior ->expects($this->once()) ->method('setTableModified') - ->with($this->equalTo(true)) - ; + ->with($this->equalTo(true)); $table = new Table(); $table->addBehavior($behavior); $table->applyBehaviors(); } + /** + * @return void + */ public function testGetAdditionalBuilders() { $additionalBehaviors = [ @@ -148,6 +160,9 @@ public function testGetAdditionalBuilders() $this->assertTrue($table->hasAdditionalBuilders()); } + /** + * @return void + */ public function testHasNoAdditionalBuilders() { $table = new Table(); @@ -157,6 +172,9 @@ public function testHasNoAdditionalBuilders() $this->assertFalse($table->hasAdditionalBuilders()); } + /** + * @return void + */ public function testGetColumnList() { $columns = [ @@ -170,6 +188,9 @@ public function testGetColumnList() $this->assertSame('foo|bar|baz', $table->getColumnList($columns, '|')); } + /** + * @return void + */ public function testGetNameWithoutPlatform() { $table = new Table('books'); @@ -180,6 +201,7 @@ public function testGetNameWithoutPlatform() /** * @dataProvider provideSchemaNames * + * @return void */ public function testGetNameWithPlatform($supportsSchemas, $schemaName, $expectedName) { @@ -190,8 +212,7 @@ public function testGetNameWithPlatform($supportsSchemas, $schemaName, $expected $database ->expects($supportsSchemas ? $this->once() : $this->never()) ->method('getSchemaDelimiter') - ->will($this->returnValue('.')) - ; + ->will($this->returnValue('.')); $table = new Table('books'); $table->setSchema($schemaName); @@ -209,6 +230,9 @@ public function provideSchemaNames() ]; } + /** + * @return void + */ public function testSetDefaultPhpName() { $table = new Table('created_at'); @@ -217,6 +241,9 @@ public function testSetDefaultPhpName() $this->assertSame('createdAt', $table->getCamelCaseName()); } + /** + * @return void + */ public function testSetCustomPhpName() { $table = new Table('created_at'); @@ -226,6 +253,9 @@ public function testSetCustomPhpName() $this->assertSame('createdAt', $table->getCamelCaseName()); } + /** + * @return void + */ public function testSetDescription() { $table = new Table(); @@ -237,22 +267,27 @@ public function testSetDescription() $this->assertSame('Some description', $table->getDescription()); } + /** + * @return void + */ public function testSetInvalidDefaultStringFormat() { - $this->expectException(\Propel\Generator\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $table = new Table(); $table->setDefaultStringFormat('FOO'); } + /** + * @return void + */ public function testGetDefaultStringFormatFromDatabase() { $database = $this->getDatabaseMock('bookstore'); $database ->expects($this->once()) ->method('getDefaultStringFormat') - ->will($this->returnValue('XML')) - ; + ->will($this->returnValue('XML')); $table = new Table(); $table->setDatabase($database); @@ -263,6 +298,7 @@ public function testGetDefaultStringFormatFromDatabase() /** * @dataProvider provideStringFormats * + * @return void */ public function testGetDefaultStringFormat($format) { @@ -282,17 +318,23 @@ public function provideStringFormats() ]; } + /** + * @return void + */ public function testAddSameColumnTwice() { $table = new Table('books'); $column = $this->getColumnMock('created_at', ['phpName' => 'CreatedAt']); - $this->expectException(\Propel\Generator\Exception\EngineException::class); + $this->expectException(EngineException::class); $table->addColumn($column); $table->addColumn($column); } + /** + * @return void + */ public function testGetChildrenNames() { $column = $this->getColumnMock('created_at', ['inheritance' => true]); @@ -300,8 +342,7 @@ public function testGetChildrenNames() $column ->expects($this->any()) ->method('isEnumeratedClasses') - ->will($this->returnValue(true)) - ; + ->will($this->returnValue(true)); $children[] = $this->getMockBuilder('Propel\Generator\Model\Inheritance')->getMock(); $children[] = $this->getMockBuilder('Propel\Generator\Model\Inheritance')->getMock(); @@ -309,8 +350,7 @@ public function testGetChildrenNames() $column ->expects($this->any()) ->method('getChildren') - ->will($this->returnValue($children)) - ; + ->will($this->returnValue($children)); $table = new Table('books'); $table->addColumn($column); @@ -318,10 +358,13 @@ public function testGetChildrenNames() $names = $table->getChildrenNames(); $this->assertCount(2, $names); - $this->assertSame('Propel\Generator\Model\Inheritance', get_parent_class ($names[0])); - $this->assertSame('Propel\Generator\Model\Inheritance', get_parent_class ($names[1])); + $this->assertSame('Propel\Generator\Model\Inheritance', get_parent_class($names[0])); + $this->assertSame('Propel\Generator\Model\Inheritance', get_parent_class($names[1])); } + /** + * @return void + */ public function testCantGetChildrenNames() { $column = $this->getColumnMock('created_at', ['inheritance' => true]); @@ -329,8 +372,7 @@ public function testCantGetChildrenNames() $column ->expects($this->any()) ->method('isEnumeratedClasses') - ->will($this->returnValue(false)) - ; + ->will($this->returnValue(false)); $table = new Table('books'); $table->addColumn($column); @@ -338,6 +380,9 @@ public function testCantGetChildrenNames() $this->assertNull($table->getChildrenNames()); } + /** + * @return void + */ public function testAddInheritanceColumn() { $table = new Table('books'); @@ -352,6 +397,9 @@ public function testAddInheritanceColumn() $this->assertTrue($table->requiresTransactionInPostgres()); } + /** + * @return void + */ public function testHasBehaviors() { $behavior1 = $this->getBehaviorMock('Foo'); @@ -375,6 +423,9 @@ public function testHasBehaviors() $this->assertSame($behavior3, $table->getBehavior('Baz')); } + /** + * @return void + */ public function testAddColumn() { $table = new Table('books'); @@ -390,9 +441,12 @@ public function testAddColumn() $this->assertSame(1, $table->getNumColumns()); } + /** + * @return void + */ public function testCantRemoveColumnWhichIsNotInTable() { - $this->expectException(\Propel\Generator\Exception\EngineException::class); + $this->expectException(EngineException::class); $column1 = $this->getColumnMock('title'); @@ -400,6 +454,9 @@ public function testCantRemoveColumnWhichIsNotInTable() $table->removeColumn($column1); } + /** + * @return void + */ public function testRemoveColumnByName() { $column1 = $this->getColumnMock('id'); @@ -418,6 +475,9 @@ public function testRemoveColumnByName() $this->assertFalse($table->hasColumn('title')); } + /** + * @return void + */ public function testRemoveColumn() { $column1 = $this->getColumnMock('id'); @@ -436,6 +496,9 @@ public function testRemoveColumn() $this->assertFalse($table->hasColumn('title')); } + /** + * @return void + */ public function testGetNumLazyLoadColumns() { $column1 = $this->getColumnMock('created_at'); @@ -451,6 +514,9 @@ public function testGetNumLazyLoadColumns() $this->assertSame(2, $table->getNumLazyLoadColumns()); } + /** + * @return void + */ public function testHasValueSetColumns() { $column1 = $this->getColumnMock('created_at'); @@ -459,14 +525,12 @@ public function testHasValueSetColumns() $column1 ->expects($this->any()) ->method('isValueSetType') - ->will($this->returnValue(false)) - ; + ->will($this->returnValue(false)); $column2 ->expects($this->any()) ->method('isValueSetType') - ->will($this->returnValue(true)) - ; + ->will($this->returnValue(true)); $table = new Table('books'); @@ -477,6 +541,9 @@ public function testHasValueSetColumns() $this->assertTrue($table->hasValueSetColumns()); } + /** + * @return void + */ public function testCantGetColumn() { $table = new Table('books'); @@ -486,6 +553,9 @@ public function testCantGetColumn() $this->assertNull($table->getColumnByPhpName('Foo')); } + /** + * @return void + */ public function testSetAbstract() { $table = new Table(); @@ -495,6 +565,9 @@ public function testSetAbstract() $this->assertTrue($table->isAbstract()); } + /** + * @return void + */ public function testSetInterface() { $table = new Table(); @@ -503,6 +576,9 @@ public function testSetInterface() $this->assertSame('ActiveRecordInterface', $table->getInterface()); } + /** + * @return void + */ public function testAddIndex() { $table = new Table(); @@ -515,6 +591,8 @@ public function testAddIndex() /** * @expectedException \Propel\Generator\Exception\InvalidArgumentException + * + * @return void */ public function testAddEmptyIndex() { @@ -524,6 +602,9 @@ public function testAddEmptyIndex() $this->assertCount(1, $table->getIndices()); } + /** + * @return void + */ public function testAddArrayIndex() { $table = new Table(); @@ -532,6 +613,9 @@ public function testAddArrayIndex() $this->assertCount(1, $table->getIndices()); } + /** + * @return void + */ public function testIsIndex() { $table = new Table(); @@ -550,6 +634,9 @@ public function testIsIndex() $this->assertFalse($table->isIndex(['asd'])); } + /** + * @return void + */ public function testAddUniqueIndex() { $table = new Table(); @@ -558,6 +645,9 @@ public function testAddUniqueIndex() $this->assertCount(1, $table->getUnices()); } + /** + * @return void + */ public function testAddArrayUnique() { $table = new Table(); @@ -566,6 +656,9 @@ public function testAddArrayUnique() $this->assertCount(1, $table->getUnices()); } + /** + * @return void + */ public function testGetCompositePrimaryKey() { $column1 = $this->getColumnMock('book_id', ['primary' => true]); @@ -586,6 +679,9 @@ public function testGetCompositePrimaryKey() $this->assertSame($column1, $table->getFirstPrimaryKeyColumn()); } + /** + * @return void + */ public function testGetSinglePrimaryKey() { $column1 = $this->getColumnMock('id', ['primary' => true]); @@ -606,6 +702,9 @@ public function testGetSinglePrimaryKey() $this->assertSame($column1, $table->getFirstPrimaryKeyColumn()); } + /** + * @return void + */ public function testGetNoPrimaryKey() { $column1 = $this->getColumnMock('id'); @@ -626,11 +725,14 @@ public function testGetNoPrimaryKey() $this->assertNull($table->getFirstPrimaryKeyColumn()); } + /** + * @return void + */ public function testGetAutoIncrementPrimaryKey() { $column1 = $this->getColumnMock('id', [ 'primary' => true, - 'auto_increment' => true + 'auto_increment' => true, ]); $column2 = $this->getColumnMock('title'); @@ -648,17 +750,18 @@ public function testGetAutoIncrementPrimaryKey() $this->assertSame($column1, $table->getAutoIncrementPrimaryKey()); } + /** + * @return void + */ public function testAddIdMethodParameter() { $parameter = $this ->getMockBuilder('Propel\Generator\Model\IdMethodParameter') ->disableOriginalConstructor() - ->getMock() - ; + ->getMock(); $parameter ->expects($this->once()) - ->method('setTable') - ; + ->method('setTable'); $table = new Table(); $table->addIdMethodParameter($parameter); @@ -666,6 +769,9 @@ public function testAddIdMethodParameter() $this->assertCount(1, $table->getIdMethodParameters()); } + /** + * @return void + */ public function testAddArrayIdMethodParameter() { $table = new Table(); @@ -674,6 +780,9 @@ public function testAddArrayIdMethodParameter() $this->assertCount(1, $table->getIdMethodParameters()); } + /** + * @return void + */ public function testAddReferrerForeignKey() { $table = new Table('books'); @@ -682,6 +791,9 @@ public function testAddReferrerForeignKey() $this->assertCount(1, $table->getReferrers()); } + /** + * @return void + */ public function testAddForeignKey() { $fk = $this->getForeignKeyMock('fk_author_id', [ @@ -696,16 +808,19 @@ public function testAddForeignKey() $this->assertContains('authors', $table->getForeignTableNames()); } + /** + * @return void + */ public function testAddArrayForeignKey() { $table = new Table('books'); $table->setDatabase($this->getDatabaseMock('bookstore')); $fk = $table->addForeignKey([ - 'name' => 'fk_author_id', - 'phpName' => 'Author', - 'refPhpName' => 'Books', - 'onDelete' => 'CASCADE', + 'name' => 'fk_author_id', + 'phpName' => 'Author', + 'refPhpName' => 'Books', + 'onDelete' => 'CASCADE', 'foreignTable' => 'authors', ]); @@ -716,6 +831,9 @@ public function testAddArrayForeignKey() $this->assertContains('authors', $table->getForeignTableNames()); } + /** + * @return void + */ public function testGetForeignKeysReferencingTable() { $fk1 = $this->getForeignKeyMock('fk1', ['foreign_table_name' => 'authors']); @@ -730,6 +848,9 @@ public function testGetForeignKeysReferencingTable() $this->assertCount(2, $table->getForeignKeysReferencingTable('authors')); } + /** + * @return void + */ public function testGetForeignKeysReferencingTableMoreThenOnce() { $fk1 = $this->getForeignKeyMock('fk1', ['foreign_table_name' => 'authors']); @@ -740,19 +861,22 @@ public function testGetForeignKeysReferencingTableMoreThenOnce() $table->addForeignKey($fk1); $table->addForeignKey($fk2); - $this->expectException(\Propel\Generator\Exception\EngineException::class); + $this->expectException(EngineException::class); $table->addForeignKey($fk3); $this->fail('Expected to throw an EngineException due to duplicate foreign key.'); } + /** + * @return void + */ public function testGetColumnForeignKeys() { $fk1 = $this->getForeignKeyMock('fk1', [ - 'local_columns' => ['foo', 'author_id', 'bar'] + 'local_columns' => ['foo', 'author_id', 'bar'], ]); $fk2 = $this->getForeignKeyMock('fk2', [ - 'local_columns' => ['foo', 'bar'] + 'local_columns' => ['foo', 'bar'], ]); $table = new Table(); @@ -763,6 +887,9 @@ public function testGetColumnForeignKeys() $this->assertContains($fk1, $table->getColumnForeignKeys('author_id')); } + /** + * @return void + */ public function testSetBaseClasses() { $table = new Table(); @@ -771,14 +898,16 @@ public function testSetBaseClasses() $this->assertSame('BaseObject', $table->getBaseClass()); } + /** + * @return void + */ public function testGetBaseClassesFromDatabase() { $database = $this->getDatabaseMock('bookstore'); $database ->expects($this->once()) ->method('getBaseClass') - ->will($this->returnValue('BaseObject')) - ; + ->will($this->returnValue('BaseObject')); $table = new Table(); $table->setDatabase($database); @@ -786,6 +915,9 @@ public function testGetBaseClassesFromDatabase() $this->assertSame('BaseObject', $table->getBaseClass()); } + /** + * @return void + */ public function testGetBaseClassesWithAlias() { $table = new Table('books'); @@ -794,6 +926,9 @@ public function testGetBaseClassesWithAlias() $this->assertSame('Book', $table->getBaseClass()); } + /** + * @return void + */ public function testSetAlias() { $table = new Table('books'); @@ -805,26 +940,32 @@ public function testSetAlias() $this->assertSame('Book', $table->getAlias()); } + /** + * @return void + */ public function testTablePrefix() { $database = new Database(); $database->loadMapping([ - 'name' => 'bookstore', - 'defaultIdMethod' => 'native', + 'name' => 'bookstore', + 'defaultIdMethod' => 'native', 'defaultPhpNamingMethod' => 'underscore', - 'tablePrefix' => 'acme_', - 'defaultStringFormat' => 'XML', + 'tablePrefix' => 'acme_', + 'defaultStringFormat' => 'XML', ]); $table = new Table(); $database->addTable($table); $table->loadMapping([ - 'name' => 'books' + 'name' => 'books', ]); $this->assertEquals('Books', $table->getPhpName()); $this->assertEquals('acme_books', $table->getCommonName()); } + /** + * @return void + */ public function testSetContainsForeignPK() { $table = new Table(); @@ -833,6 +974,9 @@ public function testSetContainsForeignPK() $this->assertTrue($table->getContainsForeignPK()); } + /** + * @return void + */ public function testSetCrossReference() { $table = new Table('books'); @@ -845,6 +989,9 @@ public function testSetCrossReference() $this->assertTrue($table->isCrossRef()); } + /** + * @return void + */ public function testSetSkipSql() { $table = new Table('books'); @@ -853,6 +1000,9 @@ public function testSetSkipSql() $this->assertTrue($table->isSkipSql()); } + /** + * @return void + */ public function testSetForReferenceOnly() { $table = new Table('books'); @@ -864,9 +1014,10 @@ public function testSetForReferenceOnly() /** * Returns a dummy Column object. * - * @param string $name The column name - * @param array $options An array of options - * @return Column + * @param string $name The column name + * @param array $options An array of options + * + * @return \Propel\Generator\Model\Column */ protected function getColumnMock($name, array $options = []) { @@ -886,49 +1037,41 @@ protected function getColumnMock($name, array $options = []) $column ->expects($this->any()) - ->method('setTable') - ; + ->method('setTable'); $column ->expects($this->any()) - ->method('setPosition') - ; + ->method('setPosition'); $column ->expects($this->any()) ->method('isPrimaryKey') - ->will($this->returnValue($options['primary'])) - ; + ->will($this->returnValue($options['primary'])); $column ->expects($this->any()) ->method('isAutoIncrement') - ->will($this->returnValue($options['auto_increment'])) - ; + ->will($this->returnValue($options['auto_increment'])); $column ->expects($this->any()) ->method('isInheritance') - ->will($this->returnValue($options['inheritance'])) - ; + ->will($this->returnValue($options['inheritance'])); $column ->expects($this->any()) ->method('isLazyLoad') - ->will($this->returnValue($options['lazy'])) - ; + ->will($this->returnValue($options['lazy'])); $column ->expects($this->any()) ->method('getPhpName') - ->will($this->returnValue($options['phpName'])) - ; + ->will($this->returnValue($options['phpName'])); $column ->expects($this->any()) ->method('requiresTransactionInPostgres') - ->will($this->returnValue($options['pg_transaction'])) - ; + ->will($this->returnValue($options['pg_transaction'])); return $column; } diff --git a/tests/Propel/Tests/Generator/Model/UniqueTest.php b/tests/Propel/Tests/Generator/Model/UniqueTest.php index 3b2930a7f4..50d3773358 100644 --- a/tests/Propel/Tests/Generator/Model/UniqueTest.php +++ b/tests/Propel/Tests/Generator/Model/UniqueTest.php @@ -22,6 +22,7 @@ class UniqueTest extends ModelTestCase /** * @dataProvider provideTableSpecificAttributes * + * @return void */ public function testCreateDefaultUniqueIndexName($tableName, $maxColumnNameLength, $indexName) { @@ -29,13 +30,12 @@ public function testCreateDefaultUniqueIndexName($tableName, $maxColumnNameLengt $database ->expects($this->any()) ->method('getMaxColumnNameLength') - ->will($this->returnValue($maxColumnNameLength)) - ; + ->will($this->returnValue($maxColumnNameLength)); $table = $this->getTableMock($tableName, [ 'common_name' => $tableName, - 'unices' => [ new Unique(), new Unique() ], - 'database' => $database, + 'unices' => [ new Unique(), new Unique() ], + 'database' => $database, ]); $index = new Unique(); diff --git a/tests/Propel/Tests/Generator/Model/VendorInfoTest.php b/tests/Propel/Tests/Generator/Model/VendorInfoTest.php index a68f2617f4..b63cf02043 100644 --- a/tests/Propel/Tests/Generator/Model/VendorInfoTest.php +++ b/tests/Propel/Tests/Generator/Model/VendorInfoTest.php @@ -20,6 +20,9 @@ */ class VendorInfoTest extends TestCase { + /** + * @return void + */ public function testSetupObject() { $info = new VendorInfo(); @@ -28,6 +31,9 @@ public function testSetupObject() $this->assertSame('foo', $info->getType()); } + /** + * @return void + */ public function testGetSetType() { $info = new VendorInfo('foo'); @@ -36,6 +42,9 @@ public function testGetSetType() $this->assertTrue($info->isEmpty()); } + /** + * @return void + */ public function testSetParameter() { $info = new VendorInfo(); @@ -46,6 +55,9 @@ public function testSetParameter() $this->assertSame('bar', $info->getParameter('foo')); } + /** + * @return void + */ public function testSetParameters() { $info = new VendorInfo(); @@ -56,6 +68,9 @@ public function testSetParameters() $this->assertArrayHasKey('baz', $info->getParameters()); } + /** + * @return void + */ public function testMergeVendorInfo() { $current = new VendorInfo('mysql'); diff --git a/tests/Propel/Tests/Generator/Platform/DefaultPlatformTest.php b/tests/Propel/Tests/Generator/Platform/DefaultPlatformTest.php index 9d1c2b0ec6..399af21aa0 100644 --- a/tests/Propel/Tests/Generator/Platform/DefaultPlatformTest.php +++ b/tests/Propel/Tests/Generator/Platform/DefaultPlatformTest.php @@ -11,8 +11,7 @@ use Propel\Generator\Model\Column; use Propel\Generator\Model\PropelTypes; use Propel\Generator\Platform\DefaultPlatform; -use Propel\Runtime\Propel; -use \Propel\Tests\TestCase; +use Propel\Tests\TestCase; class DefaultPlatformTest extends TestCase { @@ -32,6 +31,9 @@ protected function getPlatform() return $this->platform; } + /** + * @return void + */ protected function tearDown(): void { $this->platform = null; @@ -40,6 +42,7 @@ protected function tearDown(): void /** * @dataProvider provideValidBooleanValues * + * @return void */ public function testGetBooleanString($value) { @@ -66,6 +69,7 @@ public function provideValidBooleanValues() /** * @dataProvider provideInvalidBooleanValues * + * @return void */ public function testGetNonBooleanString($value) { @@ -90,11 +94,14 @@ public function provideInvalidBooleanValues() ]; } + /** + * @return void + */ public function testQuote() { $p = $this->getPlatform(); - $unquoted = "Nice"; + $unquoted = 'Nice'; $quoted = $p->quote($unquoted); $this->assertEquals("'$unquoted'", $quoted); @@ -137,31 +144,32 @@ public function createSetColumn($defaultValues, $defaultValue) public function getColumnDefaultValueDDLDataProvider() { return [ - [$this->createColumn(PropelTypes::INTEGER, 0), "DEFAULT 0"], - [$this->createColumn(PropelTypes::INTEGER, '0'), "DEFAULT 0"], + [$this->createColumn(PropelTypes::INTEGER, 0), 'DEFAULT 0'], + [$this->createColumn(PropelTypes::INTEGER, '0'), 'DEFAULT 0'], [$this->createColumn(PropelTypes::VARCHAR, 'foo'), "DEFAULT 'foo'"], [$this->createColumn(PropelTypes::VARCHAR, 0), "DEFAULT '0'"], - [$this->createColumn(PropelTypes::BOOLEAN, true), "DEFAULT 1"], - [$this->createColumn(PropelTypes::BOOLEAN, false), "DEFAULT 0"], - [$this->createColumn(PropelTypes::BOOLEAN, 'true'), "DEFAULT 1"], - [$this->createColumn(PropelTypes::BOOLEAN, 'false'), "DEFAULT 0"], - [$this->createColumn(PropelTypes::BOOLEAN, 'TRUE'), "DEFAULT 1"], - [$this->createColumn(PropelTypes::BOOLEAN, 'FALSE'), "DEFAULT 0"], - [$this->createEnumColumn(['foo', 'bar', 'baz'], 'foo'), "DEFAULT 0"], - [$this->createEnumColumn(['foo', 'bar', 'baz'], 'bar'), "DEFAULT 1"], - [$this->createEnumColumn(['foo', 'bar', 'baz'], 'baz'), "DEFAULT 2"], - [$this->createSetColumn(['foo', 'bar', 'baz'], 'foo'), "DEFAULT 1"], - [$this->createSetColumn(['foo', 'bar', 'baz'], 'bar'), "DEFAULT 2"], - [$this->createSetColumn(['foo', 'bar', 'baz'], 'baz'), "DEFAULT 4"], + [$this->createColumn(PropelTypes::BOOLEAN, true), 'DEFAULT 1'], + [$this->createColumn(PropelTypes::BOOLEAN, false), 'DEFAULT 0'], + [$this->createColumn(PropelTypes::BOOLEAN, 'true'), 'DEFAULT 1'], + [$this->createColumn(PropelTypes::BOOLEAN, 'false'), 'DEFAULT 0'], + [$this->createColumn(PropelTypes::BOOLEAN, 'TRUE'), 'DEFAULT 1'], + [$this->createColumn(PropelTypes::BOOLEAN, 'FALSE'), 'DEFAULT 0'], + [$this->createEnumColumn(['foo', 'bar', 'baz'], 'foo'), 'DEFAULT 0'], + [$this->createEnumColumn(['foo', 'bar', 'baz'], 'bar'), 'DEFAULT 1'], + [$this->createEnumColumn(['foo', 'bar', 'baz'], 'baz'), 'DEFAULT 2'], + [$this->createSetColumn(['foo', 'bar', 'baz'], 'foo'), 'DEFAULT 1'], + [$this->createSetColumn(['foo', 'bar', 'baz'], 'bar'), 'DEFAULT 2'], + [$this->createSetColumn(['foo', 'bar', 'baz'], 'baz'), 'DEFAULT 4'], ]; } /** * @dataProvider getColumnDefaultValueDDLDataProvider + * + * @return void */ public function testGetColumnDefaultValueDDL($column, $default) { $this->assertEquals($default, $this->getPlatform()->getColumnDefaultValueDDL($column)); } - } diff --git a/tests/Propel/Tests/Generator/Platform/MssqlPlatformTest.php b/tests/Propel/Tests/Generator/Platform/MssqlPlatformTest.php index 435890e414..fc7d5829ba 100644 --- a/tests/Propel/Tests/Generator/Platform/MssqlPlatformTest.php +++ b/tests/Propel/Tests/Generator/Platform/MssqlPlatformTest.php @@ -17,21 +17,21 @@ use Propel\Generator\Model\Table; use Propel\Generator\Platform\MssqlPlatform; -/** - * - */ class MssqlPlatformTest extends PlatformTestProvider { /** * Get the Platform object for this class * - * @return MssqlPlatform + * @return \Propel\Generator\Platform\MssqlPlatform */ protected function getPlatform() { return new MssqlPlatform(); } + /** + * @return void + */ public function testGetSequenceNameDefault() { $table = new Table('foo'); @@ -40,6 +40,9 @@ public function testGetSequenceNameDefault() $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); } + /** + * @return void + */ public function testGetSequenceNameCustom() { $table = new Table('foo'); @@ -54,6 +57,8 @@ public function testGetSequenceNameCustom() /** * @dataProvider providerForTestGetAddTablesDDL + * + * @return void */ public function testGetAddTablesDDL($schema) { @@ -150,6 +155,8 @@ public function testGetAddTablesDDL($schema) /** * @dataProvider providerForTestGetAddTablesDDLSchema + * + * @return void */ public function testGetAddTablesDDLSchemas($schema) { @@ -291,6 +298,8 @@ public function testGetAddTablesDDLSchemas($schema) /** * @dataProvider providerForTestGetAddTablesSkipSQLDDL + * + * @return void */ public function testGetAddTablesSkipSQLDDL($schema) { @@ -301,6 +310,8 @@ public function testGetAddTablesSkipSQLDDL($schema) /** * @dataProvider providerForTestGetAddTableDDLSimplePK + * + * @return void */ public function testGetAddTableDDLSimplePK($schema) { @@ -319,6 +330,8 @@ public function testGetAddTableDDLSimplePK($schema) /** * @dataProvider providerForTestGetAddTableDDLCompositePK + * + * @return void */ public function testGetAddTableDDLCompositePK($schema) { @@ -337,6 +350,8 @@ public function testGetAddTableDDLCompositePK($schema) /** * @dataProvider providerForTestGetAddTableDDLUniqueIndex + * + * @return void */ public function testGetAddTableDDLUniqueIndex($schema) { @@ -355,6 +370,8 @@ public function testGetAddTableDDLUniqueIndex($schema) /** * @dataProvider providerForTestGetAddTableDDLSchema + * + * @return void */ public function testGetAddTableDDLSchema($schema) { @@ -370,6 +387,9 @@ public function testGetAddTableDDLSchema($schema) $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetDropTableDDL() { $table = new Table('foo'); @@ -404,6 +424,8 @@ public function testGetDropTableDDL() /** * @dataProvider providerForTestGetAddTableDDLSchema + * + * @return void */ public function testGetDropTableDDLSchema($schema) { @@ -437,6 +459,9 @@ public function testGetDropTableDDLSchema($schema) $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); } + /** + * @return void + */ public function testGetColumnDDLCustomSqlType() { $column = new Column('foo'); @@ -450,6 +475,9 @@ public function testGetColumnDDLCustomSqlType() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetPrimaryKeyDDLSimpleKey() { $table = new Table('foo'); @@ -460,6 +488,9 @@ public function testGetPrimaryKeyDDLSimpleKey() $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); } + /** + * @return void + */ public function testGetPrimaryKeyDDLCompositeKey() { $table = new Table('foo'); @@ -475,6 +506,8 @@ public function testGetPrimaryKeyDDLCompositeKey() /** * @dataProvider providerForTestPrimaryKeyDDL + * + * @return void */ public function testGetDropPrimaryKeyDDL($table) { @@ -486,6 +519,8 @@ public function testGetDropPrimaryKeyDDL($table) /** * @dataProvider providerForTestPrimaryKeyDDL + * + * @return void */ public function testGetAddPrimaryKeyDDL($table) { @@ -497,6 +532,8 @@ public function testGetAddPrimaryKeyDDL($table) /** * @dataProvider providerForTestGetIndicesDDL + * + * @return void */ public function testAddIndicesDDL($table) { @@ -510,6 +547,8 @@ public function testAddIndicesDDL($table) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testAddIndexDDL($index) { @@ -521,6 +560,8 @@ public function testAddIndexDDL($index) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testDropIndexDDL($index) { @@ -532,6 +573,8 @@ public function testDropIndexDDL($index) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testGetIndexDDL($index) { @@ -541,6 +584,8 @@ public function testGetIndexDDL($index) /** * @dataProvider providerForTestGetUniqueDDL + * + * @return void */ public function testGetUniqueDDL($index) { @@ -550,6 +595,8 @@ public function testGetUniqueDDL($index) /** * @dataProvider providerForTestGetForeignKeysDDL + * + * @return void */ public function testGetAddForeignKeysDDL($table) { @@ -569,6 +616,8 @@ public function testGetAddForeignKeysDDL($table) /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetAddForeignKeyDDL($fk) { @@ -583,6 +632,8 @@ public function testGetAddForeignKeyDDL($fk) /** * @dataProvider providerForTestGetForeignKeySkipSqlDDL + * + * @return void */ public function testGetAddForeignKeySkipSqlDDL($fk) { @@ -592,6 +643,8 @@ public function testGetAddForeignKeySkipSqlDDL($fk) /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetDropForeignKeyDDL($fk) { @@ -603,6 +656,8 @@ public function testGetDropForeignKeyDDL($fk) /** * @dataProvider providerForTestGetForeignKeySkipSqlDDL + * + * @return void */ public function testGetDropForeignKeySkipSqlDDL($fk) { @@ -612,6 +667,8 @@ public function testGetDropForeignKeySkipSqlDDL($fk) /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetForeignKeyDDL($fk) { @@ -621,6 +678,8 @@ public function testGetForeignKeyDDL($fk) /** * @dataProvider providerForTestGetForeignKeySkipSqlDDL + * + * @return void */ public function testGetForeignKeySkipSqlDDL($fk) { @@ -628,6 +687,9 @@ public function testGetForeignKeySkipSqlDDL($fk) $this->assertEquals($expected, $this->getPlatform()->getForeignKeyDDL($fk)); } + /** + * @return void + */ public function testGetCommentBlockDDL() { $expected = " diff --git a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php index c644757bd5..42a759a512 100644 --- a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php +++ b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php @@ -11,12 +11,8 @@ namespace Propel\Tests\Generator\Platform; use Propel\Generator\Config\GeneratorConfig; -use Propel\Generator\Model\Column; use Propel\Generator\Platform\MysqlPlatform; -/** - * - */ class MysqlPlatformMigrationMyISAMTest extends PlatformMigrationTestProvider { protected $platform; @@ -55,7 +51,7 @@ classname: \Propel\Runtime\Connection\DebugPDO - bookstore EOF; - $configFile = sys_get_temp_dir().'/propel.yaml'; + $configFile = sys_get_temp_dir() . '/propel.yaml'; file_put_contents($configFile, $configFileContent); $config = new GeneratorConfig($configFile); @@ -67,6 +63,8 @@ classname: \Propel\Runtime\Connection\DebugPDO /** * @dataProvider providerForTestGetModifyDatabaseDDL + * + * @return void */ public function testRenameTableDDL($databaseDiff) { @@ -103,6 +101,8 @@ public function testRenameTableDDL($databaseDiff) /** * @dataProvider providerForTestGetRenameTableDDL + * + * @return void */ public function testGetRenameTableDDL($fromName, $toName) { @@ -114,6 +114,8 @@ public function testGetRenameTableDDL($fromName, $toName) /** * @dataProvider providerForTestGetModifyTableDDL + * + * @return void */ public function testGetModifyTableDDL($tableDiff) { @@ -141,6 +143,8 @@ public function testGetModifyTableDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableColumnsDDL + * + * @return void */ public function testGetModifyTableColumnsDDL($tableDiff) { @@ -156,6 +160,8 @@ public function testGetModifyTableColumnsDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTablePrimaryKeysDDL + * + * @return void */ public function testGetModifyTablePrimaryKeysDDL($tableDiff) { @@ -169,6 +175,8 @@ public function testGetModifyTablePrimaryKeysDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableIndicesDDL + * + * @return void */ public function testGetModifyTableIndicesDDL($tableDiff) { @@ -190,26 +198,32 @@ public function testGetModifyTableIndicesDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableForeignKeysDDL + * + * @return void */ public function testGetModifyTableForeignKeysDDL($tableDiff) { - $expected = ""; + $expected = ''; $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff)); } /** * @dataProvider providerForTestGetModifyTableForeignKeysSkipSqlDDL + * + * @return void */ public function testGetModifyTableForeignKeysSkipSqlDDL($tableDiff) { - $expected = ""; + $expected = ''; $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff)); - $expected = ""; + $expected = ''; $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff->getReverseDiff())); } /** * @dataProvider providerForTestGetModifyTableForeignKeysSkipSql2DDL + * + * @return void */ public function testGetModifyTableForeignKeysSkipSql2DDL($tableDiff) { @@ -221,6 +235,8 @@ public function testGetModifyTableForeignKeysSkipSql2DDL($tableDiff) /** * @dataProvider providerForTestGetRemoveColumnDDL + * + * @return void */ public function testGetRemoveColumnDDL($column) { @@ -232,6 +248,8 @@ public function testGetRemoveColumnDDL($column) /** * @dataProvider providerForTestGetRenameColumnDDL + * + * @return void */ public function testGetRenameColumnDDL($fromColumn, $toColumn) { @@ -243,6 +261,8 @@ public function testGetRenameColumnDDL($fromColumn, $toColumn) /** * @dataProvider providerForTestGetModifyColumnDDL + * + * @return void */ public function testGetModifyColumnDDL($columnDiff) { @@ -254,6 +274,8 @@ public function testGetModifyColumnDDL($columnDiff) /** * @dataProvider providerForTestGetModifyColumnsDDL + * + * @return void */ public function testGetModifyColumnsDDL($columnDiffs) { @@ -267,6 +289,8 @@ public function testGetModifyColumnsDDL($columnDiffs) /** * @dataProvider providerForTestGetAddColumnDDL + * + * @return void */ public function testGetAddColumnDDL($column) { @@ -278,6 +302,8 @@ public function testGetAddColumnDDL($column) /** * @dataProvider providerForTestGetAddColumnsDDL + * + * @return void */ public function testGetAddColumnsDDL($columns) { diff --git a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php index 2a222aaf6e..693ce05f98 100644 --- a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php +++ b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php @@ -11,13 +11,9 @@ namespace Propel\Tests\Generator\Platform; use Propel\Generator\Config\GeneratorConfig; -use Propel\Generator\Model\Column; use Propel\Generator\Model\Diff\DatabaseComparator; use Propel\Generator\Platform\MysqlPlatform; -/** - * - */ class MysqlPlatformMigrationTest extends MysqlPlatformMigrationTestProvider { protected $platform; @@ -56,7 +52,7 @@ classname: \Propel\Runtime\Connection\DebugPDO - bookstore EOF; - $configFile = sys_get_temp_dir().'/propel.yaml'; + $configFile = sys_get_temp_dir() . '/propel.yaml'; file_put_contents($configFile, $configFileContent); $config = new GeneratorConfig($configFile); @@ -68,6 +64,8 @@ classname: \Propel\Runtime\Connection\DebugPDO /** * @dataProvider providerForTestGetModifyDatabaseDDL + * + * @return void */ public function testRenameTableDDL($databaseDiff) { @@ -104,6 +102,8 @@ public function testRenameTableDDL($databaseDiff) /** * @dataProvider providerForTestGetRenameTableDDL + * + * @return void */ public function testGetRenameTableDDL($fromName, $toName) { @@ -115,6 +115,8 @@ public function testGetRenameTableDDL($fromName, $toName) /** * @dataProvider providerForTestGetModifyTableDDL + * + * @return void */ public function testGetModifyTableDDL($tableDiff) { @@ -150,6 +152,8 @@ public function testGetModifyTableDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableColumnsDDL + * + * @return void */ public function testGetModifyTableColumnsDDL($tableDiff) { @@ -165,6 +169,8 @@ public function testGetModifyTableColumnsDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTablePrimaryKeysDDL + * + * @return void */ public function testGetModifyTablePrimaryKeysDDL($tableDiff) { @@ -178,6 +184,8 @@ public function testGetModifyTablePrimaryKeysDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableIndicesDDL + * + * @return void */ public function testGetModifyTableIndicesDDL($tableDiff) { @@ -199,6 +207,8 @@ public function testGetModifyTableIndicesDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableForeignKeysDDL + * + * @return void */ public function testGetModifyTableForeignKeysDDL($tableDiff) { @@ -220,6 +230,8 @@ public function testGetModifyTableForeignKeysDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableForeignKeysSkipSqlDDL + * + * @return void */ public function testGetModifyTableForeignKeysSkipSqlDDL($tableDiff) { @@ -237,6 +249,8 @@ public function testGetModifyTableForeignKeysSkipSqlDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableForeignKeysSkipSql2DDL + * + * @return void */ public function testGetModifyTableForeignKeysSkipSql2DDL($tableDiff) { @@ -248,6 +262,8 @@ public function testGetModifyTableForeignKeysSkipSql2DDL($tableDiff) /** * @dataProvider providerForTestGetRemoveColumnDDL + * + * @return void */ public function testGetRemoveColumnDDL($column) { @@ -259,6 +275,8 @@ public function testGetRemoveColumnDDL($column) /** * @dataProvider providerForTestGetRenameColumnDDL + * + * @return void */ public function testGetRenameColumnDDL($fromColumn, $toColumn) { @@ -270,6 +288,8 @@ public function testGetRenameColumnDDL($fromColumn, $toColumn) /** * @dataProvider providerForTestGetModifyColumnDDL + * + * @return void */ public function testGetModifyColumnDDL($columnDiff) { @@ -281,6 +301,8 @@ public function testGetModifyColumnDDL($columnDiff) /** * @dataProvider providerForTestGetModifyColumnsDDL + * + * @return void */ public function testGetModifyColumnsDDL($columnDiffs) { @@ -294,6 +316,8 @@ public function testGetModifyColumnsDDL($columnDiffs) /** * @dataProvider providerForTestGetAddColumnDDL + * + * @return void */ public function testGetAddColumnDDL($column) { @@ -305,6 +329,8 @@ public function testGetAddColumnDDL($column) /** * @dataProvider providerForTestGetAddColumnFirstDDL + * + * @return void */ public function testGetAddColumnFirstDDL($column) { @@ -316,6 +342,8 @@ public function testGetAddColumnFirstDDL($column) /** * @dataProvider providerForTestGetAddColumnsDDL + * + * @return void */ public function testGetAddColumnsDDL($columns) { @@ -327,6 +355,9 @@ public function testGetAddColumnsDDL($columns) $this->assertEquals($expected, $this->getPlatform()->getAddColumnsDDL($columns)); } + /** + * @return void + */ public function testColumnRenaming() { $schema1 = ' @@ -370,6 +401,9 @@ public function testColumnRenaming() $this->assertEquals('bar_la2', $secondPair[1]->getName()); } + /** + * @return void + */ public function testTableRenaming() { $schema1 = ' diff --git a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTestProvider.php b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTestProvider.php index 24ad6f26d2..7b0a79520d 100644 --- a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTestProvider.php +++ b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTestProvider.php @@ -13,9 +13,8 @@ /** * provider for mysql platform migration unit tests */ -class MysqlPlatformMigrationTestProvider extends PlatformMigrationTestProvider { - - +class MysqlPlatformMigrationTestProvider extends PlatformMigrationTestProvider +{ public function providerForTestGetAddColumnFirstDDL() { $schema = <<assertEquals($expected, $this->getPlatform()->getSequenceName($table)); } + /** + * @return void + */ public function testGetSequenceNameCustom() { $table = new Table('foo'); @@ -70,6 +73,8 @@ public function testGetSequenceNameCustom() /** * @dataProvider providerForTestGetAddTablesDDLSchema + * + * @return void */ public function testGetAddTablesDDLSchema($schema) { @@ -134,6 +139,8 @@ public function testGetAddTablesDDLSchema($schema) /** * @dataProvider providerForTestGetAddTablesDDL + * + * @return void */ public function testGetAddTablesDDL($schema) { @@ -183,16 +190,20 @@ public function testGetAddTablesDDL($schema) /** * @dataProvider providerForTestGetAddTablesSkipSQLDDL + * + * @return void */ public function testGetAddTablesSkipSQLDDL($schema) { $database = $this->getDatabaseFromSchema($schema); - $expected = ""; + $expected = ''; $this->assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); } /** * @dataProvider providerForTestGetAddTableDDLSimplePK + * + * @return void */ public function testGetAddTableDDLSimplePK($schema) { @@ -210,6 +221,8 @@ public function testGetAddTableDDLSimplePK($schema) /** * @dataProvider providerForTestGetAddTableDDLCompositePK + * + * @return void */ public function testGetAddTableDDLCompositePK($schema) { @@ -228,6 +241,8 @@ public function testGetAddTableDDLCompositePK($schema) /** * @dataProvider providerForTestGetAddTableDDLUniqueIndex + * + * @return void */ public function testGetAddTableDDLUniqueIndex($schema) { @@ -244,6 +259,9 @@ public function testGetAddTableDDLUniqueIndex($schema) $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetAddTableDDLIndex() { $schema = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetAddTableDDLForeignKey() { $schema = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetAddTableDDLForeignKeySkipSql() { $schema = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetAddTableDDLEngine() { $schema = <<assertEquals($expected, $platform->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetAddTableDDLVendor() { $schema = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetDropTableDDL() { $table = new Table('foo'); @@ -407,6 +442,8 @@ public function testGetDropTableDDL() /** * @dataProvider providerForTestGetAddTableDDLSchema + * + * @return void */ public function testGetDropTableDDLSchema($schema) { @@ -417,6 +454,9 @@ public function testGetDropTableDDLSchema($schema) $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); } + /** + * @return void + */ public function testGetColumnDDL() { $column = new Column('foo'); @@ -429,6 +469,9 @@ public function testGetColumnDDL() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetColumnDDLCharsetVendor() { $column = new Column('foo'); @@ -440,6 +483,9 @@ public function testGetColumnDDLCharsetVendor() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetColumnDDLCharsetCollation() { $column = new Column('foo'); @@ -459,6 +505,9 @@ public function testGetColumnDDLCharsetCollation() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetColumnDDLComment() { $column = new Column('foo'); @@ -468,6 +517,9 @@ public function testGetColumnDDLComment() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetColumnDDLCharsetNotNull() { $column = new Column('foo'); @@ -480,6 +532,9 @@ public function testGetColumnDDLCharsetNotNull() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetColumnDDLCustomSqlType() { $column = new Column('foo'); @@ -493,6 +548,9 @@ public function testGetColumnDDLCustomSqlType() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetPrimaryKeyDDLSimpleKey() { $table = new Table('foo'); @@ -504,6 +562,9 @@ public function testGetPrimaryKeyDDLSimpleKey() $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); } + /** + * @return void + */ public function testGetPrimaryKeyDDLCompositeKey() { $table = new Table('foo'); @@ -520,6 +581,8 @@ public function testGetPrimaryKeyDDLCompositeKey() /** * @dataProvider providerForTestPrimaryKeyDDL + * + * @return void */ public function testGetDropPrimaryKeyDDL($table) { @@ -531,6 +594,8 @@ public function testGetDropPrimaryKeyDDL($table) /** * @dataProvider providerForTestPrimaryKeyDDL + * + * @return void */ public function testGetAddPrimaryKeyDDL($table) { @@ -542,6 +607,8 @@ public function testGetAddPrimaryKeyDDL($table) /** * @dataProvider providerForTestGetIndicesDDL + * + * @return void */ public function testAddIndicesDDL($table) { @@ -555,6 +622,8 @@ public function testAddIndicesDDL($table) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testAddIndexDDL($index) { @@ -566,6 +635,8 @@ public function testAddIndexDDL($index) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testDropIndexDDL($index) { @@ -577,6 +648,8 @@ public function testDropIndexDDL($index) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testGetIndexDDL($index) { @@ -584,6 +657,9 @@ public function testGetIndexDDL($index) $this->assertEquals($expected, $this->getPlatform()->getIndexDDL($index)); } + /** + * @return void + */ public function testGetIndexDDLKeySize() { $table = new Table('foo'); @@ -599,6 +675,9 @@ public function testGetIndexDDLKeySize() $this->assertEquals($expected, $this->getPlatform()->getIndexDDL($index)); } + /** + * @return void + */ public function testGetIndexDDLFulltext() { $table = new Table('foo'); @@ -618,6 +697,8 @@ public function testGetIndexDDLFulltext() /** * @dataProvider providerForTestGetUniqueDDL + * + * @return void */ public function testGetUniqueDDL($index) { @@ -627,24 +708,30 @@ public function testGetUniqueDDL($index) /** * @dataProvider providerForTestGetForeignKeysDDL + * + * @return void */ public function testGetAddForeignKeysDDL($table) { - $expected = ""; + $expected = ''; $this->assertEquals($expected, $this->getPlatform()->getAddForeignKeysDDL($table)); } /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetAddForeignKeyDDL($fk) { - $expected = ""; + $expected = ''; $this->assertEquals($expected, $this->getPlatform()->getAddForeignKeyDDL($fk)); } /** * @dataProvider providerForTestGetForeignKeySkipSqlDDL + * + * @return void */ public function testGetAddForeignKeySkipSqlDDL($fk) { @@ -654,15 +741,19 @@ public function testGetAddForeignKeySkipSqlDDL($fk) /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetDropForeignKeyDDL($fk) { - $expected = ""; + $expected = ''; $this->assertEquals($expected, $this->getPlatform()->getDropForeignKeyDDL($fk)); } /** * @dataProvider providerForTestGetForeignKeySkipSqlDDL + * + * @return void */ public function testGetDropForeignKeySkipSqlDDL($fk) { @@ -672,15 +763,19 @@ public function testGetDropForeignKeySkipSqlDDL($fk) /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetForeignKeyDDL($fk) { - $expected = ""; + $expected = ''; $this->assertEquals($expected, $this->getPlatform()->getForeignKeyDDL($fk)); } /** * @dataProvider providerForTestGetForeignKeySkipSqlDDL + * + * @return void */ public function testGetForeignKeySkipSqlDDL($fk) { @@ -688,6 +783,9 @@ public function testGetForeignKeySkipSqlDDL($fk) $this->assertEquals($expected, $this->getPlatform()->getForeignKeyDDL($fk)); } + /** + * @return void + */ public function testGetCommentBlockDDL() { $expected = " @@ -698,6 +796,9 @@ public function testGetCommentBlockDDL() $this->assertEquals($expected, $this->getPlatform()->getCommentBlockDDL('foo bar')); } + /** + * @return void + */ public function testAddExtraIndicesForeignKeys() { $schema = ' @@ -737,5 +838,4 @@ public function testAddExtraIndicesForeignKeys() $this->assertEquals($expectedRelationSql, $relationTableSql); } - } diff --git a/tests/Propel/Tests/Generator/Platform/MysqlPlatformTest.php b/tests/Propel/Tests/Generator/Platform/MysqlPlatformTest.php index b24ce4d96f..062536286b 100644 --- a/tests/Propel/Tests/Generator/Platform/MysqlPlatformTest.php +++ b/tests/Propel/Tests/Generator/Platform/MysqlPlatformTest.php @@ -21,15 +21,12 @@ use Propel\Generator\Model\VendorInfo; use Propel\Generator\Platform\MysqlPlatform; -/** - * - */ class MysqlPlatformTest extends PlatformTestProvider { /** * Get the Platform object for this class * - * @return MysqlPlatform + * @return \Propel\Generator\Platform\MysqlPlatform */ protected function getPlatform() { @@ -47,6 +44,9 @@ protected function getPlatform() return $platform; } + /** + * @return void + */ public function testGetSequenceNameDefault() { $table = new Table('foo'); @@ -55,6 +55,9 @@ public function testGetSequenceNameDefault() $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); } + /** + * @return void + */ public function testGetSequenceNameCustom() { $table = new Table('foo'); @@ -69,6 +72,8 @@ public function testGetSequenceNameCustom() /** * @dataProvider providerForTestGetAddTablesDDLSchema + * + * @return void */ public function testGetAddTablesDDLSchema($schema) { @@ -140,6 +145,8 @@ public function testGetAddTablesDDLSchema($schema) /** * @dataProvider providerForTestGetAddTablesDDL + * + * @return void */ public function testGetAddTablesDDL($schema) { @@ -192,16 +199,20 @@ public function testGetAddTablesDDL($schema) /** * @dataProvider providerForTestGetAddTablesSkipSQLDDL + * + * @return void */ public function testGetAddTablesSkipSQLDDL($schema) { $database = $this->getDatabaseFromSchema($schema); - $expected = ""; + $expected = ''; $this->assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); } /** * @dataProvider providerForTestGetAddTableDDLSimplePK + * + * @return void */ public function testGetAddTableDDLSimplePK($schema) { @@ -219,6 +230,8 @@ public function testGetAddTableDDLSimplePK($schema) /** * @dataProvider providerForTestGetAddTableDDLCompositePK + * + * @return void */ public function testGetAddTableDDLCompositePK($schema) { @@ -237,6 +250,8 @@ public function testGetAddTableDDLCompositePK($schema) /** * @dataProvider providerForTestGetAddTableDDLUniqueIndex + * + * @return void */ public function testGetAddTableDDLUniqueIndex($schema) { @@ -253,6 +268,9 @@ public function testGetAddTableDDLUniqueIndex($schema) $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetAddTableDDLIndex() { $schema = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetAddTableDDLForeignKey() { $schema = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetAddTableDDLForeignKeySkipSql() { $schema = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetAddTableDDLEngine() { $schema = <<assertEquals($expected, $platform->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetAddTableDDLVendor() { $schema = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetDropTableDDL() { $table = new Table('foo'); @@ -419,6 +454,8 @@ public function testGetDropTableDDL() /** * @dataProvider providerForTestGetAddTableDDLSchema + * + * @return void */ public function testGetDropTableDDLSchema($schema) { @@ -429,6 +466,9 @@ public function testGetDropTableDDLSchema($schema) $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); } + /** + * @return void + */ public function testGetColumnDDL() { $column = new Column('foo'); @@ -441,6 +481,9 @@ public function testGetColumnDDL() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetColumnDDLCharsetVendor() { $column = new Column('foo'); @@ -452,6 +495,9 @@ public function testGetColumnDDLCharsetVendor() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetColumnDDLCharsetCollation() { $column = new Column('foo'); @@ -471,6 +517,9 @@ public function testGetColumnDDLCharsetCollation() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetColumnDDLComment() { $column = new Column('foo'); @@ -480,6 +529,9 @@ public function testGetColumnDDLComment() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetColumnDDLCharsetNotNull() { $column = new Column('foo'); @@ -492,6 +544,9 @@ public function testGetColumnDDLCharsetNotNull() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetColumnDDLCustomSqlType() { $column = new Column('foo'); @@ -505,6 +560,9 @@ public function testGetColumnDDLCustomSqlType() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetPrimaryKeyDDLSimpleKey() { $table = new Table('foo'); @@ -516,6 +574,9 @@ public function testGetPrimaryKeyDDLSimpleKey() $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); } + /** + * @return void + */ public function testGetPrimaryKeyDDLCompositeKey() { $table = new Table('foo'); @@ -532,6 +593,8 @@ public function testGetPrimaryKeyDDLCompositeKey() /** * @dataProvider providerForTestPrimaryKeyDDL + * + * @return void */ public function testGetDropPrimaryKeyDDL($table) { @@ -543,6 +606,8 @@ public function testGetDropPrimaryKeyDDL($table) /** * @dataProvider providerForTestPrimaryKeyDDL + * + * @return void */ public function testGetAddPrimaryKeyDDL($table) { @@ -554,6 +619,8 @@ public function testGetAddPrimaryKeyDDL($table) /** * @dataProvider providerForTestGetIndicesDDL + * + * @return void */ public function testAddIndicesDDL($table) { @@ -567,6 +634,8 @@ public function testAddIndicesDDL($table) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testAddIndexDDL($index) { @@ -578,6 +647,8 @@ public function testAddIndexDDL($index) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testDropIndexDDL($index) { @@ -589,6 +660,8 @@ public function testDropIndexDDL($index) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testGetIndexDDL($index) { @@ -596,6 +669,9 @@ public function testGetIndexDDL($index) $this->assertEquals($expected, $this->getPlatform()->getIndexDDL($index)); } + /** + * @return void + */ public function testGetIndexDDLKeySize() { $table = new Table('foo'); @@ -611,6 +687,9 @@ public function testGetIndexDDLKeySize() $this->assertEquals($expected, $this->getPlatform()->getIndexDDL($index)); } + /** + * @return void + */ public function testGetIndexDDLFulltext() { $table = new Table('foo'); @@ -630,6 +709,8 @@ public function testGetIndexDDLFulltext() /** * @dataProvider providerForTestGetUniqueDDL + * + * @return void */ public function testGetUniqueDDL($index) { @@ -639,6 +720,8 @@ public function testGetUniqueDDL($index) /** * @dataProvider providerForTestGetForeignKeysDDL + * + * @return void */ public function testGetAddForeignKeysDDL($table) { @@ -658,6 +741,8 @@ public function testGetAddForeignKeysDDL($table) /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetAddForeignKeyDDL($fk) { @@ -672,6 +757,8 @@ public function testGetAddForeignKeyDDL($fk) /** * @dataProvider providerForTestGetForeignKeySkipSqlDDL + * + * @return void */ public function testGetAddForeignKeySkipSqlDDL($fk) { @@ -681,6 +768,8 @@ public function testGetAddForeignKeySkipSqlDDL($fk) /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetDropForeignKeyDDL($fk) { @@ -692,6 +781,8 @@ public function testGetDropForeignKeyDDL($fk) /** * @dataProvider providerForTestGetForeignKeySkipSqlDDL + * + * @return void */ public function testGetDropForeignKeySkipSqlDDL($fk) { @@ -701,6 +792,8 @@ public function testGetDropForeignKeySkipSqlDDL($fk) /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetForeignKeyDDL($fk) { @@ -713,6 +806,8 @@ public function testGetForeignKeyDDL($fk) /** * @dataProvider providerForTestGetForeignKeySkipSqlDDL + * + * @return void */ public function testGetForeignKeySkipSqlDDL($fk) { @@ -720,6 +815,9 @@ public function testGetForeignKeySkipSqlDDL($fk) $this->assertEquals($expected, $this->getPlatform()->getForeignKeyDDL($fk)); } + /** + * @return void + */ public function testGetCommentBlockDDL() { $expected = " @@ -730,6 +828,9 @@ public function testGetCommentBlockDDL() $this->assertEquals($expected, $this->getPlatform()->getCommentBlockDDL('foo bar')); } + /** + * @return void + */ public function testAddExtraIndicesForeignKeys() { $schema = ' @@ -773,9 +874,12 @@ public function testAddExtraIndicesForeignKeys() $this->assertEquals($expectedRelationSql, $relationTableSql); } + /** + * @return void + */ public function testGetAddTableDDLComplexPK() { - $schema = << @@ -785,7 +889,7 @@ public function testGetAddTableDDLComplexPK()
EOF; - $table = $this->getTableFromSchema($schema); + $table = $this->getTableFromSchema($schema); $expected = " CREATE TABLE `foo` ( @@ -799,10 +903,12 @@ public function testGetAddTableDDLComplexPK() $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testVendorOptionsQuoting() { - - $schema = << @@ -828,7 +934,7 @@ public function testVendorOptionsQuoting()
EOF; - $table = $this->getTableFromSchema($schema); + $table = $this->getTableFromSchema($schema); $expected = " CREATE TABLE `foo` ( @@ -839,7 +945,9 @@ public function testVendorOptionsQuoting() $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } - + /** + * @return void + */ public function testNormalizeTable() { $column = new Column('price', 'DECIMAL'); @@ -849,9 +957,6 @@ public function testNormalizeTable() $table = new Table('prices'); $table->addColumns([$column]); $this->getPlatform()->normalizeTable($table); - $this->assertEquals("`price` DECIMAL(10,3)", $this->getPlatform()->getColumnDDL($column)); + $this->assertEquals('`price` DECIMAL(10,3)', $this->getPlatform()->getColumnDDL($column)); } - - - } diff --git a/tests/Propel/Tests/Generator/Platform/OraclePlatformMigrationTest.php b/tests/Propel/Tests/Generator/Platform/OraclePlatformMigrationTest.php index d687641050..92908672cc 100644 --- a/tests/Propel/Tests/Generator/Platform/OraclePlatformMigrationTest.php +++ b/tests/Propel/Tests/Generator/Platform/OraclePlatformMigrationTest.php @@ -10,13 +10,9 @@ namespace Propel\Tests\Generator\Platform; -use Propel\Generator\Model\Column; use Propel\Generator\Model\Diff\DatabaseComparator; use Propel\Generator\Platform\OraclePlatform; -/** - * - */ class OraclePlatformMigrationTest extends PlatformMigrationTestProvider { /** @@ -31,6 +27,8 @@ protected function getPlatform() /** * @dataProvider providerForTestGetModifyDatabaseDDL + * + * @return void */ public function testGetModifyDatabaseDDL($databaseDiff) { @@ -75,6 +73,8 @@ public function testGetModifyDatabaseDDL($databaseDiff) /** * @dataProvider providerForTestGetRenameTableDDL + * + * @return void */ public function testGetRenameTableDDL($fromName, $toName) { @@ -86,6 +86,8 @@ public function testGetRenameTableDDL($fromName, $toName) /** * @dataProvider providerForTestGetModifyTableDDL + * + * @return void */ public function testGetModifyTableDDL($tableDiff) { @@ -124,6 +126,8 @@ public function testGetModifyTableDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableColumnsDDL + * + * @return void */ public function testGetModifyTableColumnsDDL($tableDiff) { @@ -145,6 +149,8 @@ public function testGetModifyTableColumnsDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTablePrimaryKeysDDL + * + * @return void */ public function testGetModifyTablePrimaryKeysDDL($tableDiff) { @@ -158,6 +164,8 @@ public function testGetModifyTablePrimaryKeysDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableIndicesDDL + * + * @return void */ public function testGetModifyTableIndicesDDL($tableDiff) { @@ -179,6 +187,8 @@ public function testGetModifyTableIndicesDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableForeignKeysDDL + * + * @return void */ public function testGetModifyTableForeignKeysDDL($tableDiff) { @@ -198,6 +208,8 @@ public function testGetModifyTableForeignKeysDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableForeignKeysSkipSqlDDL + * + * @return void */ public function testGetModifyTableForeignKeysSkipSqlDDL($tableDiff) { @@ -214,6 +226,8 @@ public function testGetModifyTableForeignKeysSkipSqlDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableForeignKeysSkipSql2DDL + * + * @return void */ public function testGetModifyTableForeignKeysSkipSql2DDL($tableDiff) { @@ -225,6 +239,8 @@ public function testGetModifyTableForeignKeysSkipSql2DDL($tableDiff) /** * @dataProvider providerForTestGetRemoveColumnDDL + * + * @return void */ public function testGetRemoveColumnDDL($column) { @@ -236,6 +252,8 @@ public function testGetRemoveColumnDDL($column) /** * @dataProvider providerForTestGetRenameColumnDDL + * + * @return void */ public function testGetRenameColumnDDL($fromColumn, $toColumn) { @@ -247,6 +265,8 @@ public function testGetRenameColumnDDL($fromColumn, $toColumn) /** * @dataProvider providerForTestGetModifyColumnDDL + * + * @return void */ public function testGetModifyColumnDDL($columnDiff) { @@ -258,6 +278,8 @@ public function testGetModifyColumnDDL($columnDiff) /** * @dataProvider providerForTestGetModifyColumnsDDL + * + * @return void */ public function testGetModifyColumnsDDL($columnDiffs) { @@ -273,6 +295,8 @@ public function testGetModifyColumnsDDL($columnDiffs) /** * @dataProvider providerForTestGetAddColumnDDL + * + * @return void */ public function testGetAddColumnDDL($column) { @@ -284,6 +308,8 @@ public function testGetAddColumnDDL($column) /** * @dataProvider providerForTestGetAddColumnsDDL + * + * @return void */ public function testGetAddColumnsDDL($columns) { @@ -297,6 +323,9 @@ public function testGetAddColumnsDDL($columns) $this->assertEquals($expected, $this->getPlatform()->getAddColumnsDDL($columns)); } + /** + * @return void + */ public function testGetModifyDatabaseWithBlockStorageDDL() { $schema1 = <<assertEquals($expected, $this->getPlatform()->getModifyDatabaseDDL($databaseDiff)); } - } diff --git a/tests/Propel/Tests/Generator/Platform/OraclePlatformTest.php b/tests/Propel/Tests/Generator/Platform/OraclePlatformTest.php index 1f207c30ee..e866e59725 100644 --- a/tests/Propel/Tests/Generator/Platform/OraclePlatformTest.php +++ b/tests/Propel/Tests/Generator/Platform/OraclePlatformTest.php @@ -17,9 +17,6 @@ use Propel\Generator\Model\Table; use Propel\Generator\Platform\OraclePlatform; -/** - * - */ class OraclePlatformTest extends PlatformTestProvider { /** @@ -32,6 +29,9 @@ protected function getPlatform() return new OraclePlatform(); } + /** + * @return void + */ public function testGetSequenceNameDefault() { $table = new Table('foo'); @@ -40,6 +40,9 @@ public function testGetSequenceNameDefault() $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); } + /** + * @return void + */ public function testGetSequenceNameCustom() { $table = new Table('foo'); @@ -54,6 +57,8 @@ public function testGetSequenceNameCustom() /** * @dataProvider providerForTestGetAddTablesDDL + * + * @return void */ public function testGetAddTablesDDL($schema) { @@ -118,6 +123,8 @@ public function testGetAddTablesDDL($schema) /** * @dataProvider providerForTestGetAddTablesSkipSQLDDL + * + * @return void */ public function testGetAddTablesSkipSQLDDL($schema) { @@ -131,6 +138,8 @@ public function testGetAddTablesSkipSQLDDL($schema) /** * @dataProvider providerForTestGetAddTableDDLSimplePK + * + * @return void */ public function testGetAddTableDDLSimplePK($schema) { @@ -153,6 +162,8 @@ public function testGetAddTableDDLSimplePK($schema) /** * @dataProvider providerForTestGetAddTableDDLCompositePK + * + * @return void */ public function testGetAddTableDDLCompositePK($schema) { @@ -172,6 +183,8 @@ public function testGetAddTableDDLCompositePK($schema) /** * @dataProvider providerForTestGetAddTableDDLUniqueIndex + * + * @return void */ public function testGetAddTableDDLUniqueIndex($schema) { @@ -192,6 +205,9 @@ public function testGetAddTableDDLUniqueIndex($schema) $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetDropTableDDL() { $table = new Table('foo'); @@ -201,6 +217,9 @@ public function testGetDropTableDDL() $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); } + /** + * @return void + */ public function testGetDropTableWithSequenceDDL() { $table = new Table('foo'); @@ -216,6 +235,9 @@ public function testGetDropTableWithSequenceDDL() $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); } + /** + * @return void + */ public function testGetColumnDDLCustomSqlType() { $column = new Column('foo'); @@ -231,13 +253,18 @@ public function testGetColumnDDLCustomSqlType() /** * @dataProvider providerForTestPrimaryKeyDDL + * + * @return void */ public function testGetPrimaryKeyDDLSimpleKey($table) { - $expected ='CONSTRAINT foo_pk PRIMARY KEY (bar)'; + $expected = 'CONSTRAINT foo_pk PRIMARY KEY (bar)'; $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); } + /** + * @return void + */ public function testGetPrimaryKeyDDLLongTableName() { $table = new Table('this_table_has_a_very_long_name'); @@ -248,6 +275,9 @@ public function testGetPrimaryKeyDDLLongTableName() $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); } + /** + * @return void + */ public function testGetPrimaryKeyDDLCompositeKey() { $table = new Table('foo'); @@ -263,6 +293,8 @@ public function testGetPrimaryKeyDDLCompositeKey() /** * @dataProvider providerForTestPrimaryKeyDDL + * + * @return void */ public function testGetDropPrimaryKeyDDL($table) { @@ -274,6 +306,8 @@ public function testGetDropPrimaryKeyDDL($table) /** * @dataProvider providerForTestPrimaryKeyDDL + * + * @return void */ public function testGetAddPrimaryKeyDDL($table) { @@ -285,6 +319,8 @@ public function testGetAddPrimaryKeyDDL($table) /** * @dataProvider providerForTestGetIndicesDDL + * + * @return void */ public function testAddIndicesDDL($table) { @@ -298,6 +334,8 @@ public function testAddIndicesDDL($table) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testAddIndexDDL($index) { @@ -309,6 +347,8 @@ public function testAddIndexDDL($index) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testDropIndexDDL($index) { @@ -320,6 +360,8 @@ public function testDropIndexDDL($index) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testGetIndexDDL($index) { @@ -329,6 +371,8 @@ public function testGetIndexDDL($index) /** * @dataProvider providerForTestGetUniqueDDL + * + * @return void */ public function testGetUniqueDDL($index) { @@ -338,6 +382,8 @@ public function testGetUniqueDDL($index) /** * @dataProvider providerForTestGetForeignKeysDDL + * + * @return void */ public function testGetAddForeignKeysDDL($table) { @@ -355,6 +401,8 @@ public function testGetAddForeignKeysDDL($table) /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetAddForeignKeyDDL($fk) { @@ -368,6 +416,8 @@ public function testGetAddForeignKeyDDL($fk) /** * @dataProvider providerForTestGetForeignKeySkipSqlDDL + * + * @return void */ public function testGetAddForeignKeySkipSqlDDL($fk) { @@ -377,6 +427,8 @@ public function testGetAddForeignKeySkipSqlDDL($fk) /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetDropForeignKeyDDL($fk) { @@ -388,6 +440,8 @@ public function testGetDropForeignKeyDDL($fk) /** * @dataProvider providerForTestGetForeignKeySkipSqlDDL + * + * @return void */ public function testGetDropForeignKeySkipSqlDDL($fk) { @@ -397,6 +451,8 @@ public function testGetDropForeignKeySkipSqlDDL($fk) /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetForeignKeyDDL($fk) { @@ -408,6 +464,8 @@ public function testGetForeignKeyDDL($fk) /** * @dataProvider providerForTestGetForeignKeySkipSqlDDL + * + * @return void */ public function testGetForeignKeySkipSqlDDL($fk) { @@ -415,6 +473,9 @@ public function testGetForeignKeySkipSqlDDL($fk) $this->assertEquals($expected, $this->getPLatform()->getForeignKeyDDL($fk)); } + /** + * @return void + */ public function testGetCommentBlockDDL() { $expected = " @@ -425,6 +486,9 @@ public function testGetCommentBlockDDL() $this->assertEquals($expected, $this->getPLatform()->getCommentBlockDDL('foo bar')); } + /** + * @return void + */ public function testGetOracleBlockStorageDDL() { $schema = <<assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); } - } diff --git a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php index 0823134177..020023e932 100755 --- a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php +++ b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php @@ -13,16 +13,12 @@ use Propel\Generator\Builder\Util\SchemaReader; use Propel\Generator\Model\Column; use Propel\Generator\Model\ColumnDefaultValue; -use Propel\Generator\Model\Table; use Propel\Generator\Model\Diff\ColumnComparator; +use Propel\Generator\Model\Table; use Propel\Generator\Platform\PgsqlPlatform; -/** - * - */ class PgsqlPlatformMigrationTest extends PlatformMigrationTestProvider { - /** * Get the Platform object for this class * @@ -35,6 +31,8 @@ protected function getPlatform() /** * @dataProvider providerForTestGetModifyDatabaseDDL + * + * @return void */ public function testGetModifyDatabaseDDL($databaseDiff) { @@ -70,6 +68,8 @@ public function testGetModifyDatabaseDDL($databaseDiff) /** * @dataProvider providerForTestGetRenameTableDDL + * + * @return void */ public function testGetRenameTableDDL($fromName, $toName) { @@ -81,6 +81,8 @@ public function testGetRenameTableDDL($fromName, $toName) /** * @dataProvider providerForTestGetModifyTableDDL + * + * @return void */ public function testGetModifyTableDDL($tableDiff) { @@ -116,6 +118,8 @@ public function testGetModifyTableDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableColumnsDDL + * + * @return void */ public function testGetModifyTableColumnsDDL($tableDiff) { @@ -133,6 +137,8 @@ public function testGetModifyTableColumnsDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTablePrimaryKeysDDL + * + * @return void */ public function testGetModifyTablePrimaryKeysDDL($tableDiff) { @@ -148,6 +154,8 @@ public function testGetModifyTablePrimaryKeysDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableIndicesDDL + * + * @return void */ public function testGetModifyTableIndicesDDL($tableDiff) { @@ -171,6 +179,8 @@ public function testGetModifyTableIndicesDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableForeignKeysDDL + * + * @return void */ public function testGetModifyTableForeignKeysDDL($tableDiff) { @@ -194,6 +204,8 @@ public function testGetModifyTableForeignKeysDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableForeignKeysSkipSqlDDL + * + * @return void */ public function testGetModifyTableForeignKeysSkipSqlDDL($tableDiff) { @@ -215,6 +227,8 @@ public function testGetModifyTableForeignKeysSkipSqlDDL($tableDiff) /** * @dataProvider providerForTestGetModifyTableForeignKeysSkipSql2DDL + * + * @return void */ public function testGetModifyTableForeignKeysSkipSql2DDL($tableDiff) { @@ -226,6 +240,8 @@ public function testGetModifyTableForeignKeysSkipSql2DDL($tableDiff) /** * @dataProvider providerForTestGetRemoveColumnDDL + * + * @return void */ public function testGetRemoveColumnDDL($column) { @@ -237,6 +253,8 @@ public function testGetRemoveColumnDDL($column) /** * @dataProvider providerForTestGetRenameColumnDDL + * + * @return void */ public function testGetRenameColumnDDL($fromColumn, $toColumn) { @@ -248,6 +266,8 @@ public function testGetRenameColumnDDL($fromColumn, $toColumn) /** * @dataProvider providerForTestGetModifyColumnDDL + * + * @return void */ public function testGetModifyColumnDDL($columnDiff) { @@ -257,6 +277,9 @@ public function testGetModifyColumnDDL($columnDiff) $this->assertEquals($expected, $this->getPlatform()->getModifyColumnDDL($columnDiff)); } + /** + * @return void + */ public function testGetModifyColumnDDLWithChangedTypeAndDefault() { $t1 = new Table('foo'); @@ -285,6 +308,8 @@ public function testGetModifyColumnDDLWithChangedTypeAndDefault() /** * @dataProvider providerForTestGetModifyColumnsDDL + * + * @return void */ public function testGetModifyColumnsDDL($columnDiffs) { @@ -300,6 +325,8 @@ public function testGetModifyColumnsDDL($columnDiffs) /** * @dataProvider providerForTestGetAddColumnDDL + * + * @return void */ public function testGetAddColumnDDL($column) { @@ -311,6 +338,8 @@ public function testGetAddColumnDDL($column) /** * @dataProvider providerForTestGetAddColumnsDDL + * + * @return void */ public function testGetAddColumnsDDL($columns) { @@ -324,6 +353,9 @@ public function testGetAddColumnsDDL($columns) $this->assertEquals($expected, $this->getPlatform()->getAddColumnsDDL($columns)); } + /** + * @return void + */ public function testGetModifyColumnDDLWithVarcharWithoutSize() { $t1 = new Table('foo'); @@ -351,7 +383,10 @@ public function testGetModifyColumnDDLWithVarcharWithoutSize() $this->assertSame($expected, $columnDiff); } -public function testGetModifyColumnDDLWithVarcharWithoutSizeAndPlatform() + /** + * @return void + */ + public function testGetModifyColumnDDLWithVarcharWithoutSizeAndPlatform() { $t1 = new Table('foo'); $t1->setIdentifierQuoting(true); @@ -383,6 +418,8 @@ public function testGetModifyColumnDDLWithVarcharWithoutSizeAndPlatform() /** * @dataProvider providerForTestGetModifyColumnRemoveDefaultValueDDL + * + * @return void */ public function testGetModifyColumnRemoveDefaultValueDDL($columnDiffs) { @@ -396,6 +433,8 @@ public function testGetModifyColumnRemoveDefaultValueDDL($columnDiffs) /** * @dataProvider providerForTestGetModifyTableForeignKeysSkipSql3DDL + * + * @return void */ public function testGetModifyTableForeignKeysSkipSql3DDL($databaseDiff) { @@ -404,10 +443,11 @@ public function testGetModifyTableForeignKeysSkipSql3DDL($databaseDiff) /** * @dataProvider providerForTestGetModifyTableForeignKeysSkipSql4DDL + * + * @return void */ public function testGetModifyTableForeignKeysSkipSql4DDL($databaseDiff) { $this->assertFalse($databaseDiff); } - } diff --git a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php index 56089b2cbc..59aaed0680 100755 --- a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php +++ b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php @@ -20,21 +20,21 @@ use Propel\Generator\Model\Unique; use Propel\Generator\Platform\PgsqlPlatform; -/** - * - */ class PgsqlPlatformTest extends PlatformTestProvider { /** * Get the Platform object for this class * - * @return PgsqlPlatform + * @return \Propel\Generator\Platform\PgsqlPlatform */ protected function getPlatform() { return new PgsqlPlatform(); } + /** + * @return void + */ public function testGetSequenceNameDefault() { $table = new Table('foo'); @@ -47,6 +47,9 @@ public function testGetSequenceNameDefault() $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); } + /** + * @return void + */ public function testGetSequenceNameCustom() { $table = new Table('foo'); @@ -65,6 +68,8 @@ public function testGetSequenceNameCustom() /** * @dataProvider providerForTestGetAddTablesDDL + * + * @return void */ public function testGetAddTablesDDL($schema) { @@ -115,6 +120,8 @@ public function testGetAddTablesDDL($schema) /** * @dataProvider providerForTestGetAddTablesSkipSQLDDL + * + * @return void */ public function testGetAddTablesDDLSkipSQL($schema) { @@ -123,6 +130,9 @@ public function testGetAddTablesDDLSkipSQL($schema) $this->assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); } + /** + * @return void + */ public function testGetAddTablesDDLSchemasVendor() { $schema = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetAddTableDDLSchemaVendor() { $schema = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetAddTableDDLSequence() { $schema = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetAddTableDDLColumnComments() { $schema = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetDropTableDDL() { $table = new Table('foo'); @@ -451,6 +483,9 @@ public function testGetDropTableDDL() $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); } + /** + * @return void + */ public function testGetDropTableDDLSchemaVendor() { $schema = <<assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); } + /** + * @return void + */ public function testGetDropTableWithSequenceDDL() { $table = new Table('foo'); @@ -505,6 +545,9 @@ public function testGetDropTableWithSequenceDDL() $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); } + /** + * @return void + */ public function testGetColumnDDL() { $c = new Column('foo'); @@ -517,6 +560,9 @@ public function testGetColumnDDL() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($c)); } + /** + * @return void + */ public function testGetColumnDDLAutoIncrement() { $database = new Database(); @@ -532,6 +578,9 @@ public function testGetColumnDDLAutoIncrement() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetColumnDDLCustomSqlType() { $column = new Column('foo'); @@ -545,6 +594,9 @@ public function testGetColumnDDLCustomSqlType() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetPrimaryKeyDDLSimpleKey() { $table = new Table('foo'); @@ -555,6 +607,9 @@ public function testGetPrimaryKeyDDLSimpleKey() $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); } + /** + * @return void + */ public function testGetPrimaryKeyDDLCompositeKey() { $table = new Table('foo'); @@ -570,6 +625,8 @@ public function testGetPrimaryKeyDDLCompositeKey() /** * @dataProvider providerForTestPrimaryKeyDDL + * + * @return void */ public function testGetDropPrimaryKeyDDL($table) { @@ -581,6 +638,8 @@ public function testGetDropPrimaryKeyDDL($table) /** * @dataProvider providerForTestPrimaryKeyDDL + * + * @return void */ public function testGetAddPrimaryKeyDDL($table) { @@ -592,6 +651,8 @@ public function testGetAddPrimaryKeyDDL($table) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testAddIndexDDL($index) { @@ -618,6 +679,8 @@ public function testAddUniqueIndexDDL(Unique $index): void /** * @dataProvider providerForTestGetIndicesDDL + * + * @return void */ public function testAddIndicesDDL($table) { @@ -631,6 +694,8 @@ public function testAddIndicesDDL($table) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testDropIndexDDL($index) { @@ -642,6 +707,8 @@ public function testDropIndexDDL($index) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testGetIndexDDL($index) { @@ -651,6 +718,8 @@ public function testGetIndexDDL($index) /** * @dataProvider providerForTestGetUniqueDDL + * + * @return void */ public function testGetUniqueDDL($index) { @@ -660,6 +729,8 @@ public function testGetUniqueDDL($index) /** * @dataProvider providerForTestGetForeignKeysDDL + * + * @return void */ public function testGetAddForeignKeysDDL($table) { @@ -679,6 +750,8 @@ public function testGetAddForeignKeysDDL($table) /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetAddForeignKeyDDL($fk) { @@ -693,6 +766,8 @@ public function testGetAddForeignKeyDDL($fk) /** * @dataProvider providerForTestGetForeignKeySkipSqlDDL + * + * @return void */ public function testGetAddForeignKeySkipSqlDDL($fk) { @@ -702,6 +777,8 @@ public function testGetAddForeignKeySkipSqlDDL($fk) /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetDropForeignKeyDDL($fk) { @@ -713,6 +790,8 @@ public function testGetDropForeignKeyDDL($fk) /** * @dataProvider providerForTestGetForeignKeySkipSqlDDL + * + * @return void */ public function testGetDropForeignKeySkipSqlDDL($fk) { @@ -722,6 +801,8 @@ public function testGetDropForeignKeySkipSqlDDL($fk) /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetForeignKeyDDL($fk) { @@ -734,6 +815,8 @@ public function testGetForeignKeyDDL($fk) /** * @dataProvider providerForTestGetForeignKeySkipSqlDDL + * + * @return void */ public function testGetForeignKeySkipSqlDDL($fk) { @@ -741,6 +824,9 @@ public function testGetForeignKeySkipSqlDDL($fk) $this->assertEquals($expected, $this->getPlatform()->getForeignKeyDDL($fk)); } + /** + * @return void + */ public function testGetCommentBlockDDL() { $expected = " @@ -750,5 +836,4 @@ public function testGetCommentBlockDDL() "; $this->assertEquals($expected, $this->getPlatform()->getCommentBlockDDL('foo bar')); } - } diff --git a/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php b/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php index 451a71c1b2..721fe4d134 100644 --- a/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php +++ b/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php @@ -11,17 +11,16 @@ namespace Propel\Tests\Generator\Platform; use Propel\Generator\Model\Column; -use Propel\Generator\Model\Table; -use Propel\Generator\Model\Diff\DatabaseComparator; use Propel\Generator\Model\Diff\ColumnComparator; +use Propel\Generator\Model\Diff\DatabaseComparator; use Propel\Generator\Model\Diff\TableComparator; +use Propel\Generator\Model\Table; /** * provider for platform migration unit tests */ abstract class PlatformMigrationTestProvider extends PlatformTestBase { - public function providerForTestGetModifyDatabaseDDL() { $schema1 = <<getDatabaseFromSchema($schema1)->getTable('foo'); $t2 = $this->getDatabaseFromSchema($schema2)->getTable('foo'); - return [[TableComparator::computeDiff($t1,$t2)]]; + return [[TableComparator::computeDiff($t1, $t2)]]; } public function providerForTestGetModifyTableColumnsDDL() @@ -457,8 +456,8 @@ public function providerForTestGetModifyColumnsDDL() $t2->addColumn($c4); return [[[ - ColumnComparator::computeDiff($c1, $c3), - ColumnComparator::computeDiff($c2, $c4) + ColumnComparator::computeDiff($c1, $c3), + ColumnComparator::computeDiff($c2, $c4), ]]]; } @@ -579,5 +578,4 @@ public function providerForTestGetModifyTableForeignKeysSkipSql4DDL() return [[$diff]]; } - } diff --git a/tests/Propel/Tests/Generator/Platform/PlatformTestBase.php b/tests/Propel/Tests/Generator/Platform/PlatformTestBase.php index cc62487446..46e82df92f 100644 --- a/tests/Propel/Tests/Generator/Platform/PlatformTestBase.php +++ b/tests/Propel/Tests/Generator/Platform/PlatformTestBase.php @@ -18,7 +18,6 @@ */ abstract class PlatformTestBase extends TestCase { - protected function getDatabaseFromSchema($schema) { $xtad = new SchemaReader($this->getPlatform()); @@ -31,5 +30,4 @@ protected function getTableFromSchema($schema, $tableName = 'foo') { return $this->getDatabaseFromSchema($schema)->getTable($tableName); } - } diff --git a/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php b/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php index c690f13bc6..52632e2fb6 100644 --- a/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php +++ b/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php @@ -23,7 +23,6 @@ */ abstract class PlatformTestProvider extends PlatformTestBase { - public function providerForTestGetAddTablesDDL() { $schema = <<addUnique($index); return [ - [$index] + [$index], ]; } @@ -223,7 +222,7 @@ public function providerForTestGetIndicesDDL() $table->addIndex($index2); return [ - [$table] + [$table], ]; } @@ -243,7 +242,7 @@ public function providerForTestGetIndexDDL() $table->addIndex($index); return [ - [$index] + [$index], ]; } @@ -262,7 +261,7 @@ public function providerForTestGetUniqueIndexDDL(): array $table->addIndex($index); return [ - [$index] + [$index], ]; } @@ -275,7 +274,7 @@ public function providerForTestPrimaryKeyDDL() $table->addColumn($column); return [ - [$table] + [$table], ]; } @@ -303,7 +302,7 @@ public function providerForTestGetForeignKeyDDL() $table1->addForeignKey($fk); return [ - [$fk] + [$fk], ]; } @@ -314,7 +313,7 @@ public function providerForTestGetForeignKeySkipSqlDDL() $fk->setSkipSql(true); return [ - [$fk] + [$fk], ]; } @@ -357,8 +356,7 @@ public function providerForTestGetForeignKeysDDL() $table1->addForeignKey($fk); return [ - [$table1] + [$table1], ]; } - } diff --git a/tests/Propel/Tests/Generator/Platform/SqlitePlatformTest.php b/tests/Propel/Tests/Generator/Platform/SqlitePlatformTest.php index 8b80f69051..1030e322c3 100644 --- a/tests/Propel/Tests/Generator/Platform/SqlitePlatformTest.php +++ b/tests/Propel/Tests/Generator/Platform/SqlitePlatformTest.php @@ -19,9 +19,6 @@ use Propel\Runtime\Adapter\AdapterFactory; use Propel\Runtime\Connection\ConnectionFactory; -/** - * - */ class SqlitePlatformTest extends PlatformTestProvider { /** @@ -34,6 +31,9 @@ protected function getPlatform() return new SqlitePlatform(); } + /** + * @return void + */ public function testQuoteConnected() { $p = $this->getPlatform(); @@ -46,6 +46,9 @@ public function testQuoteConnected() $this->assertEquals($expected, $quoted); } + /** + * @return void + */ public function testGetSequenceNameDefault() { $table = new Table('foo'); @@ -54,6 +57,9 @@ public function testGetSequenceNameDefault() $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); } + /** + * @return void + */ public function testGetSequenceNameCustom() { $table = new Table('foo'); @@ -68,6 +74,8 @@ public function testGetSequenceNameCustom() /** * @dataProvider providerForTestGetAddTablesDDL + * + * @return void */ public function testGetAddTablesDDL($schema) { @@ -111,6 +119,8 @@ public function testGetAddTablesDDL($schema) /** * @dataProvider providerForTestGetAddTablesSkipSQLDDL + * + * @return void */ public function testGetAddTablesSkipSQLDDL($schema) { @@ -121,6 +131,8 @@ public function testGetAddTablesSkipSQLDDL($schema) /** * @dataProvider providerForTestGetAddTableDDLSimplePK + * + * @return void */ public function testGetAddTableDDLSimplePK($schema) { @@ -138,6 +150,8 @@ public function testGetAddTableDDLSimplePK($schema) /** * @dataProvider providerForTestGetAddTableDDLNonIntegerPK + * + * @return void */ public function testGetAddTableDDLNonIntegerPK($schema) { @@ -156,6 +170,8 @@ public function testGetAddTableDDLNonIntegerPK($schema) /** * @dataProvider providerForTestGetAddTableDDLCompositePK + * + * @return void */ public function testGetAddTableDDLCompositePK($schema) { @@ -174,6 +190,8 @@ public function testGetAddTableDDLCompositePK($schema) /** * @dataProvider providerForTestGetAddTableDDLUniqueIndex + * + * @return void */ public function testGetAddTableDDLUniqueIndex($schema) { @@ -189,6 +207,9 @@ public function testGetAddTableDDLUniqueIndex($schema) $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); } + /** + * @return void + */ public function testGetDropTableDDL() { $table = new Table('foo'); @@ -198,6 +219,9 @@ public function testGetDropTableDDL() $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); } + /** + * @return void + */ public function testGetColumnDDL() { $c = new Column('foo'); @@ -210,6 +234,9 @@ public function testGetColumnDDL() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($c)); } + /** + * @return void + */ public function testGetColumnDDLCustomSqlType() { $column = new Column('foo'); @@ -223,6 +250,9 @@ public function testGetColumnDDLCustomSqlType() $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); } + /** + * @return void + */ public function testGetPrimaryKeyDDLCompositeKeyWithAutoIncrement() { $table = new Table('foo'); @@ -241,6 +271,9 @@ public function testGetPrimaryKeyDDLCompositeKeyWithAutoIncrement() $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); } + /** + * @return void + */ public function testGetPrimaryKeyDDLCompositeKey() { $table = new Table('foo'); @@ -256,6 +289,8 @@ public function testGetPrimaryKeyDDLCompositeKey() /** * @dataProvider providerForTestPrimaryKeyDDL + * + * @return void */ public function testGetDropPrimaryKeyDDL($table) { @@ -266,6 +301,8 @@ public function testGetDropPrimaryKeyDDL($table) /** * @dataProvider providerForTestPrimaryKeyDDL + * + * @return void */ public function testGetAddPrimaryKeyDDL($table) { @@ -276,6 +313,8 @@ public function testGetAddPrimaryKeyDDL($table) /** * @dataProvider providerForTestGetIndicesDDL + * + * @return void */ public function testAddIndicesDDL($table) { @@ -289,6 +328,8 @@ public function testAddIndicesDDL($table) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testAddIndexDDL($index) { @@ -300,6 +341,8 @@ public function testAddIndexDDL($index) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testDropIndexDDL($index) { @@ -311,6 +354,8 @@ public function testDropIndexDDL($index) /** * @dataProvider providerForTestGetIndexDDL + * + * @return void */ public function testGetIndexDDL($index) { @@ -320,6 +365,8 @@ public function testGetIndexDDL($index) /** * @dataProvider providerForTestGetUniqueDDL + * + * @return void */ public function testGetUniqueDDL($index) { @@ -329,24 +376,30 @@ public function testGetUniqueDDL($index) /** * @dataProvider providerForTestGetForeignKeysDDL + * + * @return void */ public function testGetAddForeignKeysDDL($table) { - $expected = ""; + $expected = ''; $this->assertEquals($expected, $this->getPlatform()->getAddForeignKeysDDL($table)); } /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetAddForeignKeyDDL($fk) { - $expected = ""; + $expected = ''; $this->assertEquals($expected, $this->getPlatform()->getAddForeignKeyDDL($fk)); } /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetDropForeignKeyDDL($fk) { @@ -356,6 +409,8 @@ public function testGetDropForeignKeyDDL($fk) /** * @dataProvider providerForTestGetForeignKeyDDL + * + * @return void */ public function testGetForeignKeyDDL($fk) { @@ -364,6 +419,9 @@ public function testGetForeignKeyDDL($fk) $this->assertEquals($expected, $this->getPlatform()->getForeignKeyDDL($fk)); } + /** + * @return void + */ public function testGetCommentBlockDDL() { $expected = " @@ -373,5 +431,4 @@ public function testGetCommentBlockDDL() "; $this->assertEquals($expected, $this->getPlatform()->getCommentBlockDDL('foo bar')); } - } diff --git a/tests/Propel/Tests/Generator/Reverse/MssqlSchemaParserTest.php b/tests/Propel/Tests/Generator/Reverse/MssqlSchemaParserTest.php index ff8270ddf5..10d0e5dfaf 100644 --- a/tests/Propel/Tests/Generator/Reverse/MssqlSchemaParserTest.php +++ b/tests/Propel/Tests/Generator/Reverse/MssqlSchemaParserTest.php @@ -20,43 +20,45 @@ */ class MssqlSchemaParserTest extends TestCase { + /** + * @return void + */ public function testCleanDelimitedIdentifiers() { $parser = new TestableMssqlSchemaParser(null); $expected = 'this is a tablename'; - $tested = $parser->cleanDelimitedIdentifiers('\''.$expected.'\''); + $tested = $parser->cleanDelimitedIdentifiers('\'' . $expected . '\''); $this->assertEquals($expected, $tested); - $tested = $parser->cleanDelimitedIdentifiers('\''.$expected); - $this->assertEquals('\''.$expected, $tested); + $tested = $parser->cleanDelimitedIdentifiers('\'' . $expected); + $this->assertEquals('\'' . $expected, $tested); - $tested = $parser->cleanDelimitedIdentifiers($expected.'\''); - $this->assertEquals($expected.'\'', $tested); + $tested = $parser->cleanDelimitedIdentifiers($expected . '\''); + $this->assertEquals($expected . '\'', $tested); $expected = 'this is a tabl\'ename'; - $tested = $parser->cleanDelimitedIdentifiers('\''.$expected.'\''); + $tested = $parser->cleanDelimitedIdentifiers('\'' . $expected . '\''); $this->assertEquals($expected, $tested); - $tested = $parser->cleanDelimitedIdentifiers('\''.$expected); - $this->assertEquals('\''.$expected, $tested); + $tested = $parser->cleanDelimitedIdentifiers('\'' . $expected); + $this->assertEquals('\'' . $expected, $tested); - $tested = $parser->cleanDelimitedIdentifiers($expected.'\''); - $this->assertEquals($expected.'\'', $tested); + $tested = $parser->cleanDelimitedIdentifiers($expected . '\''); + $this->assertEquals($expected . '\'', $tested); $expected = 'this is a\'tabl\'ename'; - $tested = $parser->cleanDelimitedIdentifiers('\''.$expected.'\''); + $tested = $parser->cleanDelimitedIdentifiers('\'' . $expected . '\''); $this->assertEquals($expected, $tested); - $tested = $parser->cleanDelimitedIdentifiers('\''.$expected); - $this->assertEquals('\''.$expected, $tested); - - $tested = $parser->cleanDelimitedIdentifiers($expected.'\''); - $this->assertEquals($expected.'\'', $tested); + $tested = $parser->cleanDelimitedIdentifiers('\'' . $expected); + $this->assertEquals('\'' . $expected, $tested); + $tested = $parser->cleanDelimitedIdentifiers($expected . '\''); + $this->assertEquals($expected . '\'', $tested); } } diff --git a/tests/Propel/Tests/Generator/Reverse/MysqlSchemaParserTest.php b/tests/Propel/Tests/Generator/Reverse/MysqlSchemaParserTest.php index 2b411d06d4..e71106ff32 100644 --- a/tests/Propel/Tests/Generator/Reverse/MysqlSchemaParserTest.php +++ b/tests/Propel/Tests/Generator/Reverse/MysqlSchemaParserTest.php @@ -14,7 +14,6 @@ use Propel\Generator\Model\Database; use Propel\Generator\Platform\DefaultPlatform; use Propel\Generator\Reverse\MysqlSchemaParser; - use Propel\Runtime\Propel; use Propel\Tests\TestCaseFixturesDatabase; @@ -27,7 +26,9 @@ */ class MysqlSchemaParserTest extends TestCaseFixturesDatabase { - + /** + * @return void + */ public function testParse() { $this->markTestSkipped('Skipped as we now use one database for the whole test suite'); diff --git a/tests/Propel/Tests/Generator/Reverse/PgsqlSchemaParserTest.php b/tests/Propel/Tests/Generator/Reverse/PgsqlSchemaParserTest.php index ce52351ae7..49d5def7e3 100644 --- a/tests/Propel/Tests/Generator/Reverse/PgsqlSchemaParserTest.php +++ b/tests/Propel/Tests/Generator/Reverse/PgsqlSchemaParserTest.php @@ -10,6 +10,7 @@ namespace Propel\Tests\Generator\Reverse; +use PDO; use Propel\Generator\Config\QuickGeneratorConfig; use Propel\Generator\Model\ColumnDefaultValue; use Propel\Generator\Model\Database; @@ -27,6 +28,9 @@ */ class PgsqlSchemaParserTest extends TestCaseFixturesDatabase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -35,11 +39,14 @@ protected function setUp(): void $this->con = Propel::getConnection('reverse-bookstore'); $this->con->beginTransaction(); - if ('pgsql' !== $this->con->getAttribute(\PDO::ATTR_DRIVER_NAME)) { + if ('pgsql' !== $this->con->getAttribute(PDO::ATTR_DRIVER_NAME)) { $this->markTestSkipped('This test is designed for PostgreSQL'); } } + /** + * @return void + */ protected function tearDown(): void { if ($this->con) { @@ -54,15 +61,17 @@ public function parseDataProvider() { return [ // columnDDL, expectedColumnPhpName, expectedColumnDefaultType, expectedColumnDefaultValue, expectedSize, expectedScale - ["my_column varchar(20) default null", "MyColumn", ColumnDefaultValue::TYPE_VALUE, "NULL", 20, null], - ["my_column varchar(20) default ''", "MyColumn", ColumnDefaultValue::TYPE_VALUE, "", 20, null], - ["my_column numeric(11,0) default 0", "MyColumn", ColumnDefaultValue::TYPE_VALUE, 0, 11, 0], - ["my_column numeric(55,8) default 0", "MyColumn", ColumnDefaultValue::TYPE_VALUE, 0, 55, 8], + ['my_column varchar(20) default null', 'MyColumn', ColumnDefaultValue::TYPE_VALUE, 'NULL', 20, null], + ["my_column varchar(20) default ''", 'MyColumn', ColumnDefaultValue::TYPE_VALUE, '', 20, null], + ['my_column numeric(11,0) default 0', 'MyColumn', ColumnDefaultValue::TYPE_VALUE, 0, 11, 0], + ['my_column numeric(55,8) default 0', 'MyColumn', ColumnDefaultValue::TYPE_VALUE, 0, 55, 8], ]; } /** * @dataProvider parseDataProvider + * + * @return void */ public function testParse($columnDDL, $expectedColumnPhpName, $expectedColumnDefaultType, $expectedColumnDefaultValue, $expectedSize, $expectedScale) { diff --git a/tests/Propel/Tests/Generator/Schema/Dumper/XmlDumperTest.php b/tests/Propel/Tests/Generator/Schema/Dumper/XmlDumperTest.php index 28aa1dd43c..77316f0877 100644 --- a/tests/Propel/Tests/Generator/Schema/Dumper/XmlDumperTest.php +++ b/tests/Propel/Tests/Generator/Schema/Dumper/XmlDumperTest.php @@ -2,41 +2,54 @@ namespace Propel\Tests\Generator\Schema\Dumper; +use PHPUnit\Framework\TestCase; use Propel\Generator\Schema\Dumper\XmlDumper; -class XmlDumperTest extends \PHPUnit\Framework\TestCase +class XmlDumperTest extends TestCase { /** * The XmlDumper instance. * - * @var XmlDumper + * @var \Propel\Generator\Schema\Dumper\XmlDumper */ private $dumper; + /** + * @return void + */ public function testDumpDatabaseSchema() { - $database = include realpath(__DIR__.'/../../../Resources/blog-database.php'); + $database = include realpath(__DIR__ . '/../../../Resources/blog-database.php'); $this->assertSame($this->getExpectedXml('blog-database.xml'), $this->dumper->dump($database)); } + /** + * @return void + */ public function testDumpSchema() { - $schema = include realpath(__DIR__.'/../../../Resources/blog-schema.php'); + $schema = include realpath(__DIR__ . '/../../../Resources/blog-schema.php'); $this->assertSame($this->getExpectedXml('blog-schema.xml'), $this->dumper->dumpSchema($schema, true)); } protected function getExpectedXml($filename) { - return trim(file_get_contents(realpath(__DIR__.'/../../../Resources/'.$filename))); + return trim(file_get_contents(realpath(__DIR__ . '/../../../Resources/' . $filename))); } + /** + * @return void + */ protected function setUp(): void { $this->dumper = new XmlDumper(); } + /** + * @return void + */ protected function tearDown(): void { $this->dumper = null; diff --git a/tests/Propel/Tests/Generator/Util/PhpParserTest.php b/tests/Propel/Tests/Generator/Util/PhpParserTest.php index 14e5bc7f65..c4f8b54ba2 100644 --- a/tests/Propel/Tests/Generator/Util/PhpParserTest.php +++ b/tests/Propel/Tests/Generator/Util/PhpParserTest.php @@ -8,12 +8,11 @@ * @license MIT License */ +namespace Propel\Tests\Generator\Util; + use Propel\Generator\Util\PhpParser; -use \Propel\Tests\TestCase; +use Propel\Tests\TestCase; -/** - * - */ class PhpParserTest extends TestCase { public function basicClassCodeProvider() @@ -55,6 +54,8 @@ public function bar4() /** * @dataProvider basicClassCodeProvider + * + * @return void */ public function testFindMethodNotExistsReturnsFalse($code) { @@ -64,6 +65,8 @@ public function testFindMethodNotExistsReturnsFalse($code) /** * @dataProvider basicClassCodeProvider + * + * @return void */ public function testFindMethodNReturnsMethod($code) { @@ -80,6 +83,8 @@ public function bar1() /** * @dataProvider basicClassCodeProvider + * + * @return void */ public function testFindMethodPrecededByAttribute($code) { @@ -97,6 +102,8 @@ public function bar2() /** * @dataProvider basicClassCodeProvider + * + * @return void */ public function testFindMethodPrecededByComment($code) { @@ -117,6 +124,8 @@ public function bar3() /** * @dataProvider basicClassCodeProvider + * + * @return void */ public function testFindMethodWithWrongCurlyBraces($code) { @@ -135,6 +144,8 @@ public function bar4() /** * @dataProvider basicClassCodeProvider + * + * @return void */ public function testRemoveMethodNotExistsReturnsFalse($code) { @@ -144,6 +155,8 @@ public function testRemoveMethodNotExistsReturnsFalse($code) /** * @dataProvider basicClassCodeProvider + * + * @return void */ public function testRemoveMethodReturnsMethod($code) { @@ -160,6 +173,8 @@ public function bar1() /** * @dataProvider basicClassCodeProvider + * + * @return void */ public function testRemoveMethodRemovesMethod($code) { @@ -197,6 +212,8 @@ public function bar4() /** * @dataProvider basicClassCodeProvider + * + * @return void */ public function testReplaceMethodNotExistsReturnsFalse($code) { @@ -206,6 +223,8 @@ public function testReplaceMethodNotExistsReturnsFalse($code) /** * @dataProvider basicClassCodeProvider + * + * @return void */ public function testReplaceMethodReturnsMethod($code) { @@ -222,6 +241,8 @@ public function bar1() /** * @dataProvider basicClassCodeProvider + * + * @return void */ public function testReplaceMethodReplacesMethod($code) { diff --git a/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php b/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php index 793a8c1b8b..542638175b 100644 --- a/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php +++ b/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php @@ -8,26 +8,23 @@ * @license MIT License */ -use Propel\Generator\Platform\MysqlPlatform; -use Propel\Generator\Platform\SqlitePlatform; -use Propel\Generator\Util\QuickBuilder; - -use Propel\Runtime\ActiveRecord\ActiveRecordInterface; -use Propel\Runtime\Propel; +namespace Propel\Tests\Generator\Util; -use MyNameSpace\QuickBuildFoo1; -use MyNameSpace\QuickBuildFoo1Query; use MyNameSpace\Map\QuickBuildFoo1TableMap; - +use MyNameSpace\QuickBuildFoo1; use MyNameSpace2\QuickBuildFoo2; use MyNameSpace2\QuickBuildFoo2Query; -use \Propel\Tests\TestCase; +use Propel\Generator\Platform\MysqlPlatform; +use Propel\Generator\Platform\SqlitePlatform; +use Propel\Generator\Util\QuickBuilder; +use Propel\Runtime\ActiveRecord\ActiveRecordInterface; +use Propel\Tests\TestCase; -/** - * - */ class QuickBuilderTest extends TestCase { + /** + * @return void + */ public function testGetPlatform() { $builder = new QuickBuilder(); @@ -55,6 +52,8 @@ public function simpleSchemaProvider() /** * @dataProvider simpleSchemaProvider + * + * @return void */ public function testGetDatabase($builder) { @@ -66,6 +65,8 @@ public function testGetDatabase($builder) /** * @dataProvider simpleSchemaProvider + * + * @return void */ public function testGetSQL($builder) { @@ -90,6 +91,8 @@ public function testGetSQL($builder) /** * @dataProvider simpleSchemaProvider + * + * @return void */ public function testGetClasses($builder) { @@ -102,6 +105,8 @@ public function testGetClasses($builder) /** * @dataProvider simpleSchemaProvider + * + * @return void */ public function testGetClassesLimitedClassTargets($builder) { @@ -114,6 +119,8 @@ public function testGetClassesLimitedClassTargets($builder) /** * @dataProvider simpleSchemaProvider + * + * @return void */ public function testBuildClasses($builder) { @@ -123,6 +130,9 @@ public function testBuildClasses($builder) $this->assertTrue(QuickBuildFoo1TableMap::getTableMap() instanceof \MyNameSpace\Map\QuickBuildFoo1TableMap); } + /** + * @return void + */ public function testBuild() { $xmlSchema = <<assertEquals(1, QuickBuildFoo2Query::create()->count()); $this->assertEquals($foo, QuickBuildFoo2Query::create()->findOne()); } - } diff --git a/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php b/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php index a3961ab831..7d5688ec84 100644 --- a/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php +++ b/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php @@ -10,12 +10,13 @@ namespace Propel\Tests\Generator\Util; -use Propel\Generator\Util\SchemaValidator; -use Propel\Generator\Util\QuickBuilder; -use Propel\Generator\Model\Schema; +use DomDocument; use Propel\Generator\Model\Column; use Propel\Generator\Model\Database; +use Propel\Generator\Model\Schema; use Propel\Generator\Model\Table; +use Propel\Generator\Util\QuickBuilder; +use Propel\Generator\Util\SchemaValidator; use Propel\Tests\TestCase; class SchemaValidatorTest extends TestCase @@ -31,6 +32,9 @@ protected function getSchemaForTable($table) return $schema; } + /** + * @return void + */ public function testValidateReturnsTrueForEmptySchema() { $schema = new Schema(); @@ -38,6 +42,9 @@ public function testValidateReturnsTrueForEmptySchema() $this->assertTrue($validator->validate()); } + /** + * @return void + */ public function testValidateReturnsTrueForValidSchema() { $xmlSchema = <<assertTrue($validator->validate()); } + /** + * @return void + */ public function testDatabasePackageName() { - $schema = << @@ -71,12 +80,15 @@ public function testDatabasePackageName()
EOF; - $dom = new \DomDocument('1.0', 'UTF-8'); + $dom = new DomDocument('1.0', 'UTF-8'); $dom->loadXML($schema); - $this->assertTrue($dom->schemaValidate(__DIR__.'/../../../../../resources/xsd/database.xsd')); + $this->assertTrue($dom->schemaValidate(__DIR__ . '/../../../../../resources/xsd/database.xsd')); } + /** + * @return void + */ public function testValidateReturnsFalseWhenTwoTablesHaveSamePhpName() { $table1 = new Table('foo'); @@ -96,6 +108,9 @@ public function testValidateReturnsFalseWhenTwoTablesHaveSamePhpName() $this->assertContains('Table "bar" declares a phpName already used in another table', $validator->getErrors()); } + /** + * @return void + */ public function testValidateReturnsTrueWhenTwoTablesHaveSamePhpNameInDifferentNamespaces() { $column1 = new Column('id'); @@ -125,6 +140,9 @@ public function testValidateReturnsTrueWhenTwoTablesHaveSamePhpNameInDifferentNa $this->assertTrue($validator->validate()); } + /** + * @return void + */ public function testValidateReturnsFalseWhenTableHasNoPk() { $schema = $this->getSchemaForTable(new Table('foo')); @@ -134,6 +152,9 @@ public function testValidateReturnsFalseWhenTableHasNoPk() $this->assertContains('Table "foo" does not have a primary key defined. Propel requires all tables to have a primary key.', $validator->getErrors()); } + /** + * @return void + */ public function testValidateReturnsTrueWhenTableHasNoPkButIsAView() { $table = new Table('foo'); @@ -145,6 +166,9 @@ public function testValidateReturnsTrueWhenTableHasNoPkButIsAView() $this->assertTrue($validator->validate()); } + /** + * @return void + */ public function testValidateReturnsFalseWhenTableHasAReservedName() { $schema = $this->getSchemaForTable(new Table('TABLE_NAME')); @@ -154,6 +178,9 @@ public function testValidateReturnsFalseWhenTableHasAReservedName() $this->assertContains('Table "TABLE_NAME" uses a reserved keyword as name', $validator->getErrors()); } + /** + * @return void + */ public function testValidateReturnsFalseWhenTwoColumnsHaveSamePhpName() { $column1 = new Column('foo'); diff --git a/tests/Propel/Tests/Generator/Util/SqlParserTest.php b/tests/Propel/Tests/Generator/Util/SqlParserTest.php index 0181e488a3..3c5ecd3d4a 100644 --- a/tests/Propel/Tests/Generator/Util/SqlParserTest.php +++ b/tests/Propel/Tests/Generator/Util/SqlParserTest.php @@ -1,5 +1,7 @@ (Propel) @@ -24,5 +25,5 @@ abstract class BaseTestCase extends TestCase /** * Conditional compilation flag. */ - const DEBUG = false; + public const DEBUG = false; } diff --git a/tests/Propel/Tests/Helpers/Bookstore/Behavior/AddClassBehaviorBuilder.php b/tests/Propel/Tests/Helpers/Bookstore/Behavior/AddClassBehaviorBuilder.php index 27161e78b4..bc0d69de8c 100644 --- a/tests/Propel/Tests/Helpers/Bookstore/Behavior/AddClassBehaviorBuilder.php +++ b/tests/Propel/Tests/Helpers/Bookstore/Behavior/AddClassBehaviorBuilder.php @@ -15,6 +15,7 @@ public function getPackage() /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassName() @@ -24,7 +25,10 @@ public function getUnprefixedClassName() /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. + * + * @return void */ protected function addClassOpen(&$script) { @@ -35,7 +39,7 @@ protected function addClassOpen(&$script) * Test class for Additional builder enabled on the '$tableName' table. * */ -class ".$this->getUnqualifiedClassName()." +class " . $this->getUnqualifiedClassName() . " { "; } @@ -43,16 +47,22 @@ class ".$this->getUnqualifiedClassName()." /** * Specifies the methods that are added as part of the basic OM class. * This can be overridden by subclasses that wish to add more methods. + * * @see ObjectBuilder::addClassBody() + * + * @return void */ protected function addClassBody(&$script) { - $script .= " // no code"; + $script .= ' // no code'; } /** * Closes class. + * * @param string &$script The script will be modified in this method. + * + * @return void */ protected function addClassClose(&$script) { diff --git a/tests/Propel/Tests/Helpers/Bookstore/Behavior/TestAuthor.php b/tests/Propel/Tests/Helpers/Bookstore/Behavior/TestAuthor.php index 7817f86f28..1fdeeea059 100644 --- a/tests/Propel/Tests/Helpers/Bookstore/Behavior/TestAuthor.php +++ b/tests/Propel/Tests/Helpers/Bookstore/Behavior/TestAuthor.php @@ -10,13 +10,12 @@ namespace Propel\Tests\Helpers\Bookstore\Behavior; -use Propel\Tests\Bookstore\Author; - use Propel\Runtime\Connection\ConnectionInterface; +use Propel\Tests\Bookstore\Author; class TestAuthor extends Author { - public function preInsert(ConnectionInterface $con = null) + public function preInsert(?ConnectionInterface $con = null) { parent::preInsert($con); $this->setFirstName('PreInsertedFirstname'); @@ -24,13 +23,16 @@ public function preInsert(ConnectionInterface $con = null) return true; } - public function postInsert(ConnectionInterface $con = null) + /** + * @return void + */ + public function postInsert(?ConnectionInterface $con = null) { parent::postInsert($con); $this->setLastName('PostInsertedLastName'); } - public function preUpdate(ConnectionInterface $con = null) + public function preUpdate(?ConnectionInterface $con = null) { parent::preUpdate($con); $this->setFirstName('PreUpdatedFirstname'); @@ -38,37 +40,46 @@ public function preUpdate(ConnectionInterface $con = null) return true; } - public function postUpdate(ConnectionInterface $con = null) + /** + * @return void + */ + public function postUpdate(?ConnectionInterface $con = null) { parent::postUpdate($con); $this->setLastName('PostUpdatedLastName'); } - public function preSave(ConnectionInterface $con = null) + public function preSave(?ConnectionInterface $con = null) { parent::preSave($con); - $this->setEmail("pre@save.com"); + $this->setEmail('pre@save.com'); return true; } - public function postSave(ConnectionInterface $con = null) + /** + * @return void + */ + public function postSave(?ConnectionInterface $con = null) { parent::postSave($con); $this->setAge(115); } - public function preDelete(ConnectionInterface $con = null) + public function preDelete(?ConnectionInterface $con = null) { parent::preDelete($con); - $this->setFirstName("Pre-Deleted"); + $this->setFirstName('Pre-Deleted'); return true; } - public function postDelete(ConnectionInterface $con = null) + /** + * @return void + */ + public function postDelete(?ConnectionInterface $con = null) { parent::postDelete($con); - $this->setLastName("Post-Deleted"); + $this->setLastName('Post-Deleted'); } } diff --git a/tests/Propel/Tests/Helpers/Bookstore/Behavior/TestAuthorDeleteFalse.php b/tests/Propel/Tests/Helpers/Bookstore/Behavior/TestAuthorDeleteFalse.php index a8e9e29dae..e0508e0c66 100644 --- a/tests/Propel/Tests/Helpers/Bookstore/Behavior/TestAuthorDeleteFalse.php +++ b/tests/Propel/Tests/Helpers/Bookstore/Behavior/TestAuthorDeleteFalse.php @@ -6,7 +6,7 @@ class TestAuthorDeleteFalse extends TestAuthor { - public function preDelete(ConnectionInterface $con = null) + public function preDelete(?ConnectionInterface $con = null) { parent::preDelete($con); $this->setFirstName('Pre-Deleted'); diff --git a/tests/Propel/Tests/Helpers/Bookstore/Behavior/TestAuthorSaveFalse.php b/tests/Propel/Tests/Helpers/Bookstore/Behavior/TestAuthorSaveFalse.php index b682e5e1ac..9d4744045b 100644 --- a/tests/Propel/Tests/Helpers/Bookstore/Behavior/TestAuthorSaveFalse.php +++ b/tests/Propel/Tests/Helpers/Bookstore/Behavior/TestAuthorSaveFalse.php @@ -6,7 +6,7 @@ class TestAuthorSaveFalse extends TestAuthor { - public function preSave(ConnectionInterface $con = null) + public function preSave(?ConnectionInterface $con = null) { parent::preSave($con); $this->setEmail('pre@save.com'); diff --git a/tests/Propel/Tests/Helpers/Bookstore/Behavior/Testallhooksbehavior.php b/tests/Propel/Tests/Helpers/Bookstore/Behavior/Testallhooksbehavior.php index 0560a0ae01..3ad8d363d0 100644 --- a/tests/Propel/Tests/Helpers/Bookstore/Behavior/Testallhooksbehavior.php +++ b/tests/Propel/Tests/Helpers/Bookstore/Behavior/Testallhooksbehavior.php @@ -18,7 +18,7 @@ class TestAllHooksBehavior extends Behavior public function getTableModifier() { - if (is_null($this->tableModifier)) { + if ($this->tableModifier === null) { $this->tableModifier = new TestAllHooksTableModifier($this); } @@ -27,7 +27,7 @@ public function getTableModifier() public function getObjectBuilderModifier() { - if (is_null($this->objectBuilderModifier)) { + if ($this->objectBuilderModifier === null) { $this->objectBuilderModifier = new TestAllHooksObjectBuilderModifier($this); } @@ -36,7 +36,7 @@ public function getObjectBuilderModifier() public function getQueryBuilderModifier() { - if (is_null($this->queryBuilderModifier)) { + if ($this->queryBuilderModifier === null) { $this->queryBuilderModifier = new TestAllHooksQueryBuilderModifier($this); } @@ -54,11 +54,14 @@ public function __construct($behavior) $this->table = $behavior->getTable(); } + /** + * @return void + */ public function modifyTable() { $this->table->addColumn([ 'name' => 'test', - 'type' => 'TIMESTAMP' + 'type' => 'TIMESTAMP', ]); } } @@ -112,7 +115,7 @@ public function postDelete($builder) public function objectMethods($builder) { - return 'public function hello() { return "' . get_class($builder) .'"; }'; + return 'public function hello() { return "' . get_class($builder) . '"; }'; } public function objectCall($builder) @@ -120,6 +123,9 @@ public function objectCall($builder) return 'if ($name == "foo") return "bar";'; } + /** + * @return void + */ public function objectFilter(&$string, $builder) { $string .= 'class testObjectFilter { const FOO = "' . get_class($builder) . '"; }'; @@ -128,7 +134,6 @@ public function objectFilter(&$string, $builder) class TestAllHooksQueryBuilderModifier { - public function staticAttributes($builder) { return 'static public $customStaticAttribute = 1;public static $staticAttributeBuilder = "' . get_class($builder) . '";'; @@ -139,6 +144,9 @@ public function staticMethods($builder) return 'static public function hello() { return "' . get_class($builder) . '"; }'; } + /** + * @return void + */ public function queryFilter(&$string, $builder) { $string .= 'class testQueryFilter { const FOO = "' . get_class($builder) . '"; }'; diff --git a/tests/Propel/Tests/Helpers/Bookstore/BookstoreDataPopulator.php b/tests/Propel/Tests/Helpers/Bookstore/BookstoreDataPopulator.php index 60073b2076..d63df4575d 100644 --- a/tests/Propel/Tests/Helpers/Bookstore/BookstoreDataPopulator.php +++ b/tests/Propel/Tests/Helpers/Bookstore/BookstoreDataPopulator.php @@ -11,27 +11,25 @@ namespace Propel\Tests\Helpers\Bookstore; use Propel\Runtime\Propel; - use Propel\Tests\Bookstore\AcctAccessRole; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\BookQuery; -use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\BookClubList; use Propel\Tests\Bookstore\BookListRel; use Propel\Tests\Bookstore\BookOpinion; +use Propel\Tests\Bookstore\BookQuery; use Propel\Tests\Bookstore\BookReader; -use Propel\Tests\Bookstore\BookSummary; use Propel\Tests\Bookstore\Bookstore; use Propel\Tests\Bookstore\BookstoreEmployee; use Propel\Tests\Bookstore\BookstoreEmployeeAccount; +use Propel\Tests\Bookstore\BookSummary; +use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Media; use Propel\Tests\Bookstore\Publisher; use Propel\Tests\Bookstore\ReaderFavorite; -use Propel\Tests\Bookstore\Review; - use Propel\Tests\Bookstore\RecordLabel; use Propel\Tests\Bookstore\ReleasePool; +use Propel\Tests\Bookstore\Review; define('_LOB_SAMPLE_FILE_PATH', __DIR__ . '/../../../../Fixtures/etc/lob'); @@ -39,14 +37,16 @@ * Populates data needed by the bookstore unit tests. * * This classes uses the actual Propel objects to do the population rather than - * inserting directly into the database. This will have a performance hit, but will + * inserting directly into the database. This will have a performance hit, but will * benefit from increased flexibility (as does anything using Propel). * * @author Hans Lellelid */ class BookstoreDataPopulator { - + /** + * @return void + */ public static function populate($con = null) { if ($con === null) { @@ -58,50 +58,50 @@ public static function populate($con = null) // --------------------- $scholastic = new Publisher(); - $scholastic->setName("Scholastic"); + $scholastic->setName('Scholastic'); // do not save, will do later to test cascade $morrow = new Publisher(); - $morrow->setName("William Morrow"); + $morrow->setName('William Morrow'); $morrow->save($con); $morrow_id = $morrow->getId(); $penguin = new Publisher(); - $penguin->setName("Penguin"); + $penguin->setName('Penguin'); $penguin->save(); $penguin_id = $penguin->getId(); $vintage = new Publisher(); - $vintage->setName("Vintage"); + $vintage->setName('Vintage'); $vintage->save($con); $vintage_id = $vintage->getId(); $rowling = new Author(); - $rowling->setFirstName("J.K."); - $rowling->setLastName("Rowling"); + $rowling->setFirstName('J.K.'); + $rowling->setLastName('Rowling'); // no save() $stephenson = new Author(); - $stephenson->setFirstName("Neal"); - $stephenson->setLastName("Stephenson"); + $stephenson->setFirstName('Neal'); + $stephenson->setLastName('Stephenson'); $stephenson->save($con); $stephenson_id = $stephenson->getId(); $byron = new Author(); - $byron->setFirstName("George"); - $byron->setLastName("Byron"); + $byron->setFirstName('George'); + $byron->setLastName('Byron'); $byron->save($con); $byron_id = $byron->getId(); $grass = new Author(); - $grass->setFirstName("Gunter"); - $grass->setLastName("Grass"); + $grass->setFirstName('Gunter'); + $grass->setLastName('Grass'); $grass->save($con); $grass_id = $grass->getId(); $phoenix = new Book(); - $phoenix->setTitle("Harry Potter and the Order of the Phoenix"); - $phoenix->setISBN("043935806X"); + $phoenix->setTitle('Harry Potter and the Order of the Phoenix'); + $phoenix->setISBN('043935806X'); $phoenix->setAuthor($rowling); $phoenix->setPublisher($scholastic); $phoenix->setPrice(10.99); @@ -109,8 +109,8 @@ public static function populate($con = null) $phoenix_id = $phoenix->getId(); $qs = new Book(); - $qs->setISBN("0380977427"); - $qs->setTitle("Quicksilver"); + $qs->setISBN('0380977427'); + $qs->setTitle('Quicksilver'); $qs->setPrice(11.99); $qs->setAuthor($stephenson); $qs->setPublisher($morrow); @@ -118,8 +118,8 @@ public static function populate($con = null) $qs_id = $qs->getId(); $dj = new Book(); - $dj->setISBN("0140422161"); - $dj->setTitle("Don Juan"); + $dj->setISBN('0140422161'); + $dj->setTitle('Don Juan'); $dj->setPrice(12.99); $dj->setAuthor($byron); $dj->setPublisher($penguin); @@ -127,8 +127,8 @@ public static function populate($con = null) $dj_id = $dj->getId(); $td = new Book(); - $td->setISBN("067972575X"); - $td->setTitle("The Tin Drum"); + $td->setISBN('067972575X'); + $td->setTitle('The Tin Drum'); $td->setPrice(13.99); $td->setAuthor($grass); $td->setPublisher($vintage); @@ -137,7 +137,7 @@ public static function populate($con = null) $r1 = new Review(); $r1->setBook($phoenix); - $r1->setReviewedBy("Washington Post"); + $r1->setReviewedBy('Washington Post'); $r1->setRecommended(true); $r1->setReviewDate(time()); $r1->save($con); @@ -145,20 +145,20 @@ public static function populate($con = null) $r2 = new Review(); $r2->setBook($phoenix); - $r2->setReviewedBy("New York Times"); + $r2->setReviewedBy('New York Times'); $r2->setRecommended(false); $r2->setReviewDate(time()); $r2->save($con); $r2_id = $r2->getId(); $blob_path = _LOB_SAMPLE_FILE_PATH . '/tin_drum.gif'; - $clob_path = _LOB_SAMPLE_FILE_PATH . '/tin_drum.txt'; + $clob_path = _LOB_SAMPLE_FILE_PATH . '/tin_drum.txt'; $m1 = new Media(); $m1->setBook($td); $m1->setCoverImage(file_get_contents($blob_path)); // CLOB is broken in PDO OCI, see http://pecl.php.net/bugs/bug.php?id=7943 - if (get_class(Propel::getServiceContainer()->getAdapter()) != "OracleAdapter") { + if (get_class(Propel::getServiceContainer()->getAdapter()) != 'OracleAdapter') { $m1->setExcerpt(file_get_contents($clob_path)); } $m1->save($con); @@ -168,8 +168,8 @@ public static function populate($con = null) // (this is for many-to-many tests) $blc1 = new BookClubList(); - $blc1->setGroupLeader("Crazyleggs"); - $blc1->setTheme("Happiness"); + $blc1->setGroupLeader('Crazyleggs'); + $blc1->setTheme('Happiness'); $brel1 = new BookListRel(); $brel1->setBook($phoenix); @@ -183,42 +183,42 @@ public static function populate($con = null) $blc1->save(); $bemp1 = new BookstoreEmployee(); - $bemp1->setName("John"); - $bemp1->setJobTitle("Manager"); + $bemp1->setName('John'); + $bemp1->setJobTitle('Manager'); $bemp2 = new BookstoreEmployee(); - $bemp2->setName("Pieter"); - $bemp2->setJobTitle("Clerk"); + $bemp2->setName('Pieter'); + $bemp2->setJobTitle('Clerk'); $bemp2->setSupervisor($bemp1); $bemp2->save($con); $role = new AcctAccessRole(); - $role->setName("Admin"); + $role->setName('Admin'); $bempacct = new BookstoreEmployeeAccount(); $bempacct->setBookstoreEmployee($bemp1); $bempacct->setAcctAccessRole($role); - $bempacct->setLogin("john"); - $bempacct->setPassword("johnp4ss"); + $bempacct->setLogin('john'); + $bempacct->setPassword('johnp4ss'); $bempacct->save($con); // Add bookstores $store = new Bookstore(); - $store->setStoreName("Amazon"); + $store->setStoreName('Amazon'); $store->setPopulationServed(5000000000); // world population $store->setTotalBooks(300); $store->save($con); $store = new Bookstore(); - $store->setStoreName("Local Store"); + $store->setStoreName('Local Store'); $store->setPopulationServed(20); $store->setTotalBooks(500000); $store->save($con); $summary = new BookSummary(); $summary->setSummarizedBook($phoenix); - $summary->setSummary("Harry Potter does some amazing magic!"); + $summary->setSummary('Harry Potter does some amazing magic!'); $summary->save(); // Add release_pool and record_label @@ -255,6 +255,9 @@ public static function populate($con = null) $con->commit(); } + /** + * @return void + */ public static function populateOpinionFavorite($con = null) { if ($con === null) { @@ -278,6 +281,9 @@ public static function populateOpinionFavorite($con = null) $con->commit(); } + /** + * @return void + */ public static function depopulate($con = null) { $tableMapClasses = [ @@ -311,5 +317,4 @@ public static function depopulate($con = null) $tableMapClass::doDeleteAll($con); } } - } diff --git a/tests/Propel/Tests/Helpers/Bookstore/BookstoreEmptyTestBase.php b/tests/Propel/Tests/Helpers/Bookstore/BookstoreEmptyTestBase.php index 84a5b7f48f..6f699860c4 100644 --- a/tests/Propel/Tests/Helpers/Bookstore/BookstoreEmptyTestBase.php +++ b/tests/Propel/Tests/Helpers/Bookstore/BookstoreEmptyTestBase.php @@ -17,6 +17,8 @@ abstract class BookstoreEmptyTestBase extends BookstoreTestBase { /** * This is run before each unit test; it empties the database. + * + * @return void */ protected function setUp(): void { @@ -25,5 +27,4 @@ protected function setUp(): void BookstoreDataPopulator::depopulate($this->con); } } - } diff --git a/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php b/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php index 26631967b1..e636ee0bf7 100644 --- a/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php +++ b/tests/Propel/Tests/Helpers/Bookstore/BookstoreTestBase.php @@ -20,7 +20,7 @@ abstract class BookstoreTestBase extends TestCaseFixturesDatabase { /** - * @var Boolean + * @var bool */ protected static $isInitialized = false; @@ -31,10 +31,12 @@ abstract class BookstoreTestBase extends TestCaseFixturesDatabase /** * This is run before each unit test; it populates the database. + * + * @return void */ protected function setUp(): void { - parent::setUp(); + parent::setUp(); if (true !== self::$isInitialized) { $file = __DIR__ . '/../../../../Fixtures/bookstore/build/conf/bookstore-conf.php'; if (!file_exists($file)) { @@ -49,6 +51,8 @@ protected function setUp(): void /** * This is run after each unit test. It empties the database. + * + * @return void */ protected function tearDown(): void { @@ -65,6 +69,9 @@ protected function tearDown(): void } } + /** + * @return void + */ public static function tearDownAfterClass(): void { Propel::getServiceContainer()->closeConnections(); diff --git a/tests/Propel/Tests/Helpers/Namespaces/NamespacesTestBase.php b/tests/Propel/Tests/Helpers/Namespaces/NamespacesTestBase.php index 0774b61b87..4ef7f1c109 100644 --- a/tests/Propel/Tests/Helpers/Namespaces/NamespacesTestBase.php +++ b/tests/Propel/Tests/Helpers/Namespaces/NamespacesTestBase.php @@ -18,6 +18,9 @@ */ abstract class NamespacesTestBase extends TestCase { + /** + * @return void + */ protected function setUp(): void { if (!file_exists(__DIR__ . '/../../../../Fixtures/namespaced/build/conf/bookstore_namespaced-conf.php')) { @@ -25,6 +28,9 @@ protected function setUp(): void } } + /** + * @return void + */ protected function tearDown(): void { Propel::init(__DIR__ . '/../../../../Fixtures/bookstore/build/conf/bookstore-conf.php'); diff --git a/tests/Propel/Tests/Helpers/PlatformDatabaseBuildTimeBase.php b/tests/Propel/Tests/Helpers/PlatformDatabaseBuildTimeBase.php index 6d5a7a7bd5..5ea45814ed 100644 --- a/tests/Propel/Tests/Helpers/PlatformDatabaseBuildTimeBase.php +++ b/tests/Propel/Tests/Helpers/PlatformDatabaseBuildTimeBase.php @@ -5,29 +5,25 @@ use Propel\Generator\Config\QuickGeneratorConfig; use Propel\Generator\Model\Database; use Propel\Generator\Model\Diff\DatabaseComparator; -use Propel\Generator\Platform\MysqlPlatform; -use Propel\Generator\Reverse\MysqlSchemaParser; use Propel\Generator\Util\QuickBuilder; use Propel\Generator\Util\SqlParser; use Propel\Runtime\Propel; -use Propel\Tests\TestCase; use Propel\Tests\TestCaseFixtures; class PlatformDatabaseBuildTimeBase extends TestCaseFixtures { - /** - * @var Database + * @var \Propel\Generator\Model\Database */ public $database; /** - * @var MysqlSchemaParser + * @var \Propel\Generator\Reverse\MysqlSchemaParser */ public $parser; /** - * @var MysqlPlatform + * @var \Propel\Generator\Platform\MysqlPlatform */ public $platform; @@ -41,6 +37,9 @@ class PlatformDatabaseBuildTimeBase extends TestCaseFixtures */ public $con; + /** + * @return void + */ protected function setUp(): void { $config = sprintf('%s-conf.php', $this->databaseName); @@ -57,6 +56,9 @@ protected function setUp(): void parent::setUp(); } + /** + * @return void + */ public function readDatabase() { $this->database = new Database(); @@ -69,11 +71,13 @@ public function readDatabase() * Builds all classes and migrates the database. * * @param string $schema xml schema + * + * @return void */ public function buildAndMigrate($schema) { $builder = new QuickBuilder(); - $platform = $this->getPlatform(); + $platform = $this->getPlatform(); $builder->setPlatform($platform); $builder->setParser($this->getParser($this->con)); @@ -88,11 +92,13 @@ public function buildAndMigrate($schema) * Migrates the database. * * @param string $schema xml schema + * + * @return void */ public function migrate($schema) { $builder = new QuickBuilder(); - $platform = $this->getPlatform(); + $platform = $this->getPlatform(); $builder->setPlatform($platform); $builder->setParser($this->getParser($this->con)); @@ -106,7 +112,9 @@ public function migrate($schema) * Detects the differences between current connected database and $pDatabase * and updates the schema. This does not DROP tables. * - * @param Database $pDatabase + * @param \Propel\Generator\Model\Database $pDatabase + * + * @return void */ public function updateSchema($pDatabase) { diff --git a/tests/Propel/Tests/Issues/Issue1033Book.php b/tests/Propel/Tests/Issues/Issue1033Book.php index 364a6f1e49..7133ffcebf 100644 --- a/tests/Propel/Tests/Issues/Issue1033Book.php +++ b/tests/Propel/Tests/Issues/Issue1033Book.php @@ -2,10 +2,9 @@ namespace Propel\Tests\Issues; +use Base\Issue1033Book as BaseIssue1033Book; -class Issue1033Book extends \Base\Issue1033Book +class Issue1033Book extends BaseIssue1033Book { - protected static $protectedStatic = true; - } diff --git a/tests/Propel/Tests/Issues/Issue1033Test.php b/tests/Propel/Tests/Issues/Issue1033Test.php index bffc1689f8..46f4656501 100644 --- a/tests/Propel/Tests/Issues/Issue1033Test.php +++ b/tests/Propel/Tests/Issues/Issue1033Test.php @@ -2,17 +2,20 @@ namespace Propel\Tests\Issues; +use Exception; use Propel\Generator\Util\QuickBuilder; use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; - - /** * This test proves the bug described in https://github.com/propelorm/Propel2/issues/1033. + * * @group database */ class Issue1033Test extends BookstoreTestBase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('\Base\Issue1033Book')) { @@ -30,17 +33,19 @@ public function setUp(): void } } + /** + * @return void + */ public function testSerialize() { try { $o = new Issue1033Book(); $unserializedBook = unserialize(serialize($o)); $noExceptionThrown = true; - } catch (\Exception $e) { + } catch (Exception $e) { $noExceptionThrown = false; - } + } $this->assertTrue($noExceptionThrown); } - } diff --git a/tests/Propel/Tests/Issues/Issue1133Test.php b/tests/Propel/Tests/Issues/Issue1133Test.php index 5d4a19b0e2..45f377f6c6 100644 --- a/tests/Propel/Tests/Issues/Issue1133Test.php +++ b/tests/Propel/Tests/Issues/Issue1133Test.php @@ -2,8 +2,8 @@ namespace Propel\Tests\Issues; -use Propel\Tests\TestCase; use Propel\Runtime\Collection\ObjectCollection; +use Propel\Tests\TestCase; class DummyObject { @@ -32,14 +32,15 @@ public function hashCode() */ class Issue1133Test extends TestCase { - + /** + * @return void + */ public function testIssue1133Append() { - $testCollection = new ObjectCollection; + $testCollection = new ObjectCollection(); $testCollection->setModel(DummyObject::class); - for ($i = 0; $i < 3; $i++) - { + for ($i = 0; $i < 3; $i++) { $testCollection->append(new DummyObject($i)); } @@ -56,13 +57,15 @@ public function testIssue1133Append() $this->assertNotContains($objectThatWillBeRemoved, $testCollection, 'ObjectCollection contains item that should be removed.'); } + /** + * @return void + */ public function testIssue1133OffsetSet() { - $testCollection = new ObjectCollection; + $testCollection = new ObjectCollection(); $testCollection->setModel(DummyObject::class); - for ($i = 0; $i < 3; $i++) - { + for ($i = 0; $i < 3; $i++) { $testCollection->append(new DummyObject($i)); } @@ -79,6 +82,5 @@ public function testIssue1133OffsetSet() $this->assertContains($objectThatShouldNotBeRemoved, $testCollection, 'ObjectCollection does not contain item that should be in collection.'); $this->assertNotContains($objectThatWillBeRemoved, $testCollection, 'ObjectCollection contains item that should be removed.'); - } } diff --git a/tests/Propel/Tests/Issues/Issue1192Test.php b/tests/Propel/Tests/Issues/Issue1192Test.php index ee25d08397..f4d7081c29 100644 --- a/tests/Propel/Tests/Issues/Issue1192Test.php +++ b/tests/Propel/Tests/Issues/Issue1192Test.php @@ -2,9 +2,9 @@ namespace Propel\Tests\Issues; +use Issue1192ItemQuery; use Propel\Generator\Util\QuickBuilder; use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Adapter\Pdo\MysqlAdapter; use Propel\Runtime\Propel; use Propel\Tests\TestCase; @@ -16,7 +16,9 @@ */ class Issue1192Test extends TestCase { - + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -40,15 +42,18 @@ public function setUp(): void /** * Verifies that the correct SQL and Params are generated for queries that use `Criteria::BINARY_ALL`. + * + * @return void */ public function testCriteriaBinaryAll() { - /** @var ModelCriteria $query */ - $query = \Issue1192ItemQuery::create()->filterByTarget(1, Criteria::BINARY_ALL); + /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ + $query = Issue1192ItemQuery::create()->filterByTarget(1, Criteria::BINARY_ALL); $params = []; $actualSql = $query->createSelectSql($params); - $this->assertSame("SELECT FROM issue_1192_item WHERE issue_1192_item.target & :p1 = :p2", + $this->assertSame( + 'SELECT FROM issue_1192_item WHERE issue_1192_item.target & :p1 = :p2', $actualSql, 'Generated SQL does not match expected SQL' ); diff --git a/tests/Propel/Tests/Issues/Issue1463Test.php b/tests/Propel/Tests/Issues/Issue1463Test.php index 77f472858c..9cdbed3f7b 100644 --- a/tests/Propel/Tests/Issues/Issue1463Test.php +++ b/tests/Propel/Tests/Issues/Issue1463Test.php @@ -2,12 +2,12 @@ namespace Propel\Tests\Issues; -use Propel\Runtime\Adapter\Pdo\MysqlAdapter; +use Issue1463ItemQuery; use Propel\Generator\Util\QuickBuilder; +use Propel\Runtime\Adapter\Pdo\MysqlAdapter; use Propel\Runtime\Propel; use Propel\Tests\TestCase; - /** * Regression tests for a SQL injection vulnerability with `limit()`. * @@ -15,7 +15,9 @@ */ class Issue1463Test extends TestCase { - + /** + * @return void + */ public function setUp(): void { parent::setUp(); @@ -42,10 +44,12 @@ public function setUp(): void * Verifies that the correct SQL is generated for queries that use `limit()`. * * @dataProvider dataLimit + * + * @return void */ public function testLimit($limit, $expectedSql) { - $query = \Issue1463ItemQuery::create()->limit($limit); + $query = Issue1463ItemQuery::create()->limit($limit); $params = []; $actualSql = $query->createSelectSql($params); @@ -55,71 +59,73 @@ public function testLimit($limit, $expectedSql) public function dataLimit() { - return array( + return [ /* Valid limits */ - 'Zero' => array( - 'limit' => 0, - 'expectedSql' => 'SELECT FROM LIMIT 0' - ), - - 'Small integer' => array( - 'limit' => 38427, - 'expectedSql' => 'SELECT FROM LIMIT 38427' - ), - 'Small integer as a string' => array( - 'limit' => '38427', - 'expectedSql' => 'SELECT FROM LIMIT 38427' - ), - - 'Large integer' => array( - 'limit' => 9223372036854775807, - 'expectedSql' => 'SELECT FROM LIMIT 9223372036854775807' - ), - 'Large integer as a string' => array( - 'limit' => '9223372036854775807', - 'expectedSql' => 'SELECT FROM LIMIT 9223372036854775807' - ), - - 'Decimal value' => array( - 'limit' => 123.9, - 'expectedSql' => 'SELECT FROM LIMIT 123' - ), - 'Decimal value as a string' => array( - 'limit' => '123.9', - 'expectedSql' => 'SELECT FROM LIMIT 123' - ), + 'Zero' => [ + 'limit' => 0, + 'expectedSql' => 'SELECT FROM LIMIT 0', + ], + + 'Small integer' => [ + 'limit' => 38427, + 'expectedSql' => 'SELECT FROM LIMIT 38427', + ], + 'Small integer as a string' => [ + 'limit' => '38427', + 'expectedSql' => 'SELECT FROM LIMIT 38427', + ], + + 'Large integer' => [ + 'limit' => 9223372036854775807, + 'expectedSql' => 'SELECT FROM LIMIT 9223372036854775807', + ], + 'Large integer as a string' => [ + 'limit' => '9223372036854775807', + 'expectedSql' => 'SELECT FROM LIMIT 9223372036854775807', + ], + + 'Decimal value' => [ + 'limit' => 123.9, + 'expectedSql' => 'SELECT FROM LIMIT 123', + ], + 'Decimal value as a string' => [ + 'limit' => '123.9', + 'expectedSql' => 'SELECT FROM LIMIT 123', + ], /* Invalid limits */ - 'Negative value' => array( - 'limit' => -1, - 'expectedSql' => 'SELECT FROM ' - ), - 'Non-numeric string' => array( - 'limit' => 'foo', - 'expectedSql' => 'SELECT FROM LIMIT 0' - ), - 'Injected SQL' => array( - 'limit' => '3;DROP TABLE abc', - 'expectedSql' => 'SELECT FROM LIMIT 3' - ), - ); + 'Negative value' => [ + 'limit' => -1, + 'expectedSql' => 'SELECT FROM ', + ], + 'Non-numeric string' => [ + 'limit' => 'foo', + 'expectedSql' => 'SELECT FROM LIMIT 0', + ], + 'Injected SQL' => [ + 'limit' => '3;DROP TABLE abc', + 'expectedSql' => 'SELECT FROM LIMIT 3', + ], + ]; } /** * Verifies that the correct SQL is generated for queries that use `offset()`. * * @dataProvider dataOffset + * + * @return void */ public function testOffset($offset, $expectedSql) { - $query = \Issue1463ItemQuery::create()->offset($offset); + $query = Issue1463ItemQuery::create()->offset($offset); $params = []; $actualSql = $query->createSelectSql($params); @@ -129,71 +135,73 @@ public function testOffset($offset, $expectedSql) public function dataOffset() { - return array( + return [ /* Valid offsets */ - 'Zero' => array( - 'offset' => 0, - 'expectedSql' => 'SELECT FROM ' - ), - - 'Small integer' => array( - 'offset' => 38427, - 'expectedSql' => 'SELECT FROM LIMIT 38427, 18446744073709551615' - ), - 'Small integer as a string' => array( - 'offset' => '38427', - 'expectedSql' => 'SELECT FROM LIMIT 38427, 18446744073709551615' - ), - - 'Large integer' => array( - 'offset' => 9223372036854775807, - 'expectedSql' => 'SELECT FROM LIMIT 9223372036854775807, 18446744073709551615' - ), - 'Large integer as a string' => array( - 'offset' => '9223372036854775807', - 'expectedSql' => 'SELECT FROM LIMIT 9223372036854775807, 18446744073709551615' - ), - - 'Decimal value' => array( - 'offset' => 123.9, - 'expectedSql' => 'SELECT FROM LIMIT 123, 18446744073709551615' - ), - 'Decimal value as a string' => array( - 'offset' => '123.9', - 'expectedSql' => 'SELECT FROM LIMIT 123, 18446744073709551615' - ), + 'Zero' => [ + 'offset' => 0, + 'expectedSql' => 'SELECT FROM ', + ], + + 'Small integer' => [ + 'offset' => 38427, + 'expectedSql' => 'SELECT FROM LIMIT 38427, 18446744073709551615', + ], + 'Small integer as a string' => [ + 'offset' => '38427', + 'expectedSql' => 'SELECT FROM LIMIT 38427, 18446744073709551615', + ], + + 'Large integer' => [ + 'offset' => 9223372036854775807, + 'expectedSql' => 'SELECT FROM LIMIT 9223372036854775807, 18446744073709551615', + ], + 'Large integer as a string' => [ + 'offset' => '9223372036854775807', + 'expectedSql' => 'SELECT FROM LIMIT 9223372036854775807, 18446744073709551615', + ], + + 'Decimal value' => [ + 'offset' => 123.9, + 'expectedSql' => 'SELECT FROM LIMIT 123, 18446744073709551615', + ], + 'Decimal value as a string' => [ + 'offset' => '123.9', + 'expectedSql' => 'SELECT FROM LIMIT 123, 18446744073709551615', + ], /* Invalid offsets */ - 'Negative value' => array( - 'offset' => -1, - 'expectedSql' => 'SELECT FROM ' - ), - 'Non-numeric string' => array( - 'offset' => 'foo', - 'expectedSql' => 'SELECT FROM ' - ), - 'Injected SQL' => array( - 'offset' => '3;DROP TABLE abc', - 'expectedSql' => 'SELECT FROM LIMIT 3, 18446744073709551615' - ), - ); + 'Negative value' => [ + 'offset' => -1, + 'expectedSql' => 'SELECT FROM ', + ], + 'Non-numeric string' => [ + 'offset' => 'foo', + 'expectedSql' => 'SELECT FROM ', + ], + 'Injected SQL' => [ + 'offset' => '3;DROP TABLE abc', + 'expectedSql' => 'SELECT FROM LIMIT 3, 18446744073709551615', + ], + ]; } /** * Verifies that the correct SQL is generated for queries that use both `offset()` and `limit()`. * * @dataProvider dataOffsetAndLimit + * + * @return void */ public function testOffsetAndLimit($offset, $expectedSql) { - $query = \Issue1463ItemQuery::create()->offset($offset)->limit(999); + $query = Issue1463ItemQuery::create()->offset($offset)->limit(999); $params = []; $actualSql = $query->createSelectSql($params); @@ -203,61 +211,60 @@ public function testOffsetAndLimit($offset, $expectedSql) public function dataOffsetAndLimit() { - return array( + return [ /* Valid offsets */ - 'Zero' => array( - 'offset' => 0, - 'expectedSql' => 'SELECT FROM LIMIT 999' - ), - - 'Small integer' => array( - 'offset' => 38427, - 'expectedSql' => 'SELECT FROM LIMIT 38427, 999' - ), - 'Small integer as a string' => array( - 'offset' => '38427', - 'expectedSql' => 'SELECT FROM LIMIT 38427, 999' - ), - - 'Large integer' => array( - 'offset' => 9223372036854775807, - 'expectedSql' => 'SELECT FROM LIMIT 9223372036854775807, 999' - ), - 'Large integer as a string' => array( - 'offset' => '9223372036854775807', - 'expectedSql' => 'SELECT FROM LIMIT 9223372036854775807, 999' - ), - - 'Decimal value' => array( - 'offset' => 123.9, - 'expectedSql' => 'SELECT FROM LIMIT 123, 999' - ), - 'Decimal value as a string' => array( - 'offset' => '123.9', - 'expectedSql' => 'SELECT FROM LIMIT 123, 999' - ), + 'Zero' => [ + 'offset' => 0, + 'expectedSql' => 'SELECT FROM LIMIT 999', + ], + + 'Small integer' => [ + 'offset' => 38427, + 'expectedSql' => 'SELECT FROM LIMIT 38427, 999', + ], + 'Small integer as a string' => [ + 'offset' => '38427', + 'expectedSql' => 'SELECT FROM LIMIT 38427, 999', + ], + + 'Large integer' => [ + 'offset' => 9223372036854775807, + 'expectedSql' => 'SELECT FROM LIMIT 9223372036854775807, 999', + ], + 'Large integer as a string' => [ + 'offset' => '9223372036854775807', + 'expectedSql' => 'SELECT FROM LIMIT 9223372036854775807, 999', + ], + + 'Decimal value' => [ + 'offset' => 123.9, + 'expectedSql' => 'SELECT FROM LIMIT 123, 999', + ], + 'Decimal value as a string' => [ + 'offset' => '123.9', + 'expectedSql' => 'SELECT FROM LIMIT 123, 999', + ], /* Invalid offsets */ - 'Negative value' => array( - 'offset' => -1, - 'expectedSql' => 'SELECT FROM LIMIT 999' - ), - 'Non-numeric string' => array( - 'offset' => 'foo', - 'expectedSql' => 'SELECT FROM LIMIT 999' - ), - 'Injected SQL' => array( - 'offset' => '3;DROP TABLE abc', - 'expectedSql' => 'SELECT FROM LIMIT 3, 999' - ), - ); + 'Negative value' => [ + 'offset' => -1, + 'expectedSql' => 'SELECT FROM LIMIT 999', + ], + 'Non-numeric string' => [ + 'offset' => 'foo', + 'expectedSql' => 'SELECT FROM LIMIT 999', + ], + 'Injected SQL' => [ + 'offset' => '3;DROP TABLE abc', + 'expectedSql' => 'SELECT FROM LIMIT 3, 999', + ], + ]; } - } diff --git a/tests/Propel/Tests/Issues/Issue617Test.php b/tests/Propel/Tests/Issues/Issue617Test.php index a6c6155f29..db57e6f532 100644 --- a/tests/Propel/Tests/Issues/Issue617Test.php +++ b/tests/Propel/Tests/Issues/Issue617Test.php @@ -19,16 +19,23 @@ class Issue617Test extends PlatformDatabaseBuildTimeBase { /** * Contains the builder instance of the updated schema (removed FK) - * @var QuickBuilder + * + * @var \Propel\Generator\Util\QuickBuilder */ private $updatedBuilder; + /** + * @return void + */ protected function setUp(): void { parent::setUp(); $this->removeTables(); } + /** + * @return void + */ protected function tearDown(): void { $this->removeTables(); @@ -37,6 +44,8 @@ protected function tearDown(): void /** * Remove issue617 tables. + * + * @return void */ public function removeTables() { @@ -46,6 +55,8 @@ public function removeTables() /** * Setups the initial schema. + * + * @return void */ private function setupInitSchema() { @@ -112,12 +123,13 @@ private function setupInitSchema() $this->assertContains($expected, $sql); $this->updateSchema($builder->getDatabase()); - } /** * Drop the foreign key in the `_user` table and check whether it generates * the correct `DROP` SQL. + * + * @return void */ private function dropForeignKey() { @@ -169,6 +181,10 @@ private function dropForeignKey() /* * Checks if FKs are really deleted. */ + + /** + * @return void + */ private function checkDeletedFk() { $this->readDatabase(); @@ -183,6 +199,8 @@ private function checkDeletedFk() /** * Checks if a changed schema with removed FK does really delete the FK. * Based on a real use-case, reverse classes and `computeDiff`. + * + * @return void */ public function testDropForeignKey() { @@ -191,6 +209,5 @@ public function testDropForeignKey() $this->setupInitSchema(); $this->dropForeignKey(); $this->checkDeletedFk(); - } } diff --git a/tests/Propel/Tests/Issues/Issue646Test.php b/tests/Propel/Tests/Issues/Issue646Test.php index 88108c7a57..e614f9a68f 100644 --- a/tests/Propel/Tests/Issues/Issue646Test.php +++ b/tests/Propel/Tests/Issues/Issue646Test.php @@ -6,8 +6,16 @@ * * @license MIT License */ + namespace Propel\Tests\Issues; +use DateTime; +use PkDate; +use PkDateQuery; +use PkTime; +use PkTimeQuery; +use PkTimestamp; +use PkTimestampQuery; use Propel\Generator\Util\QuickBuilder; use Propel\Tests\TestCaseFixtures; @@ -20,7 +28,9 @@ */ class Issue646Test extends TestCaseFixtures { - + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -42,54 +52,61 @@ protected function setUp(): void '; QuickBuilder::buildSchema($schema); } - } + /** + * @return void + */ protected function tearDown(): void { parent::tearDown(); - \PkDateQuery::create()->deleteAll(); - \PkTimeQuery::create()->deleteAll(); - \PkTimestampQuery::create()->deleteAll(); + PkDateQuery::create()->deleteAll(); + PkTimeQuery::create()->deleteAll(); + PkTimestampQuery::create()->deleteAll(); } + /** + * @return void + */ public function testInsertRowWithPkDate() { //make sure that DateTime can be inserted when used as Primary Key - $date = new \PkDate(); - $date->setName("First") - ->setCreatedAt(new \DateTime('2014-01-01')); + $date = new PkDate(); + $date->setName('First') + ->setCreatedAt(new DateTime('2014-01-01')); - $time = new \PkTime(); - $time->setName("First") - ->setCreatedAt(new \DateTime('20:00:10')); + $time = new PkTime(); + $time->setName('First') + ->setCreatedAt(new DateTime('20:00:10')); - $timestamp = new \PkTimestamp(); - $timestamp->setName("First") - ->setCreatedAt(new \DateTime('2014-01-01 20:00:10')); + $timestamp = new PkTimestamp(); + $timestamp->setName('First') + ->setCreatedAt(new DateTime('2014-01-01 20:00:10')); $this->assertEquals(1, $date->save()); $this->assertEquals(1, $time->save()); $this->assertEquals(1, $timestamp->save()); } + /** + * @return void + */ public function testToArrayWithPkDate() { //makes sure that ObjectCollection returns a valid array when Primar Key is a DateTime object. - $date1 = new \PkDate(); - $date1->setName("First") - ->setCreatedAt(new \DateTime('2014-01-01')) + $date1 = new PkDate(); + $date1->setName('First') + ->setCreatedAt(new DateTime('2014-01-01')) ->save(); - $date2 = new \PkDate(); - $date2->setName("Second") - ->setCreatedAt(new \DateTime('2014-02-01')) + $date2 = new PkDate(); + $date2->setName('Second') + ->setCreatedAt(new DateTime('2014-02-01')) ->save(); - $dates = \PkDateQuery::create()->find(); + $dates = PkDateQuery::create()->find(); $this->assertInternalType('array', $dates->toArray()); - } } diff --git a/tests/Propel/Tests/Issues/Issue656Test.php b/tests/Propel/Tests/Issues/Issue656Test.php index 04c1871cc0..a85405affc 100644 --- a/tests/Propel/Tests/Issues/Issue656Test.php +++ b/tests/Propel/Tests/Issues/Issue656Test.php @@ -2,17 +2,19 @@ namespace Propel\Tests\Issues; +use Issue656TestObject; use Propel\Generator\Util\QuickBuilder; use Propel\Runtime\Collection\ObjectCollection; use Propel\Tests\TestCase; - /** * Regression test for https://github.com/propelorm/Propel2/issues/656 */ class Issue656Test extends TestCase { - + /** + * @return void + */ public function setUp(): void { if (!class_exists('\Issue656TestObject')) { @@ -40,12 +42,15 @@ public function setUp(): void } } + /** + * @return void + */ public function testGetGetterRelatedBy() { - $objectA = new \Issue656TestObject(); + $objectA = new Issue656TestObject(); $objectA->setName('A'); - $objectB = new \Issue656TestObject(); + $objectB = new Issue656TestObject(); $objectB->setName('B'); $collection = new ObjectCollection(); @@ -55,5 +60,4 @@ public function testGetGetterRelatedBy() $this->assertEquals($collection, $objectA->getIssue656TestObjectsRelatedByTo()); } - } diff --git a/tests/Propel/Tests/Issues/Issue675Test.php b/tests/Propel/Tests/Issues/Issue675Test.php index e859af4cf1..71950bbdbe 100644 --- a/tests/Propel/Tests/Issues/Issue675Test.php +++ b/tests/Propel/Tests/Issues/Issue675Test.php @@ -6,6 +6,7 @@ * * @license MIT License */ + namespace Propel\Tests\Issues; use Propel\Generator\Util\QuickBuilder; @@ -15,13 +16,17 @@ * Test : Propel should not allow incomplete foreign key references when foreign table has a composite primary key * Issue described in https://github.com/propelorm/Propel2/issues/675. * Originally described in http://stackoverflow.com/questions/7947085/are-incomplete-key-references-in-propel-useful + * * @group model */ class Issue675Test extends TestCaseFixtures { /** * Test incomplete foreign key references + * * @expectedException \Propel\Generator\Exception\BuildException + * + * @return void */ public function testIncompleteForeignReference() { @@ -57,4 +62,4 @@ public function testIncompleteForeignReference() // Explanation $this->fail('Expected to throw a BuildException due to incomplete foreign key reference.'); } -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Issues/Issue730Test.php b/tests/Propel/Tests/Issues/Issue730Test.php index d18aaf29c4..95d44d0be9 100644 --- a/tests/Propel/Tests/Issues/Issue730Test.php +++ b/tests/Propel/Tests/Issues/Issue730Test.php @@ -6,16 +6,21 @@ * * @license MIT License */ + namespace Propel\Tests\Issues; +use Issue730DepartmentGroup; +use Issue730DepartmentGroupQuery; +use Issue730Group; use Propel\Generator\Platform\SqlitePlatform; use Propel\Generator\Util\QuickBuilder; use Propel\Tests\TestCaseFixtures; -/** - */ class Issue730Test extends TestCaseFixtures { + /** + * @return void + */ public function testNamespace() { $schema = <<build(); - $groupA = new \Issue730Group(); + $groupA = new Issue730Group(); $groupA->setName('groupA'); - $departmentGroup = new \Issue730DepartmentGroup(); + $departmentGroup = new Issue730DepartmentGroup(); $departmentGroup->setName('my department'); $departmentGroup->setIssue730Group($groupA); @@ -60,9 +65,9 @@ public function testNamespace() $groupA->save(); - $departmentGroups = \Issue730DepartmentGroupQuery::create()->filterByIssue730Group($groupA)->find(); + $departmentGroups = Issue730DepartmentGroupQuery::create()->filterByIssue730Group($groupA)->find(); $this->assertCount(1, $departmentGroups); $this->assertEquals($departmentGroup, $departmentGroups->getFirst()); $this->assertEquals('my department', $departmentGroups->getFirst()->getName()); } -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Issues/Issue733Test.php b/tests/Propel/Tests/Issues/Issue733Test.php index c12f74e321..543040e2ef 100644 --- a/tests/Propel/Tests/Issues/Issue733Test.php +++ b/tests/Propel/Tests/Issues/Issue733Test.php @@ -2,10 +2,11 @@ namespace Propel\Tests\Issues; +use Issue733Test1; +use Issue733Test2; use Propel\Generator\Util\QuickBuilder; use Propel\Tests\TestCase; - /** * This test proves the bug described in https://github.com/propelorm/Propel2/issues/733. * @@ -13,7 +14,9 @@ */ class Issue733Test extends TestCase { - + /** + * @return void + */ public function setUp(): void { if (!class_exists('\Issue733Test1')) { @@ -44,10 +47,12 @@ public function setUp(): void } } - + /** + * @return void + */ public function testGetColumnTranslation() { - $o = new \Issue733Test1(); + $o = new Issue733Test1(); // name of the column set in locale_column parameter $o->setLanguage('cs_CZ'); @@ -57,10 +62,12 @@ public function testGetColumnTranslation() $this->assertEquals($o->getBar(), 'test'); } - + /** + * @return void + */ public function testGetColumnTranslationWithAlias() { - $o = new \Issue733Test2(); + $o = new Issue733Test2(); // name of the column set in locale_alias // before the fix, this would throw an exception @@ -71,7 +78,5 @@ public function testGetColumnTranslationWithAlias() // before the fix, this would throw an exception $this->assertEquals($o->getCulture(), $o->getLanguage()); - } - } diff --git a/tests/Propel/Tests/Issues/Issue768Test.php b/tests/Propel/Tests/Issues/Issue768Test.php index 21e1993e6e..0f01aec0d6 100644 --- a/tests/Propel/Tests/Issues/Issue768Test.php +++ b/tests/Propel/Tests/Issues/Issue768Test.php @@ -6,10 +6,13 @@ * * @license MIT License */ + namespace Propel\Tests\Issues; +use DateTime; use Propel\Generator\Util\QuickBuilder; use Propel\Tests\TestCase; +use Timing; /** * Regression test for https://github.com/propelorm/Propel2/issues/768 @@ -18,6 +21,9 @@ */ class Issue768Test extends TestCase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -39,52 +45,55 @@ protected function setUp(): void /* * Test if the time was set correctly and in which case it will be modified */ + + /** + * @return void + */ public function testTimeModified() { - $time = "17:37:19"; + $time = '17:37:19'; - $timeObject = new \DateTime($time); + $timeObject = new DateTime($time); - $test = new \Timing(); + $test = new Timing(); $test ->setId(1) - ->setTime($time) - ; + ->setTime($time); - $this->asserttrue($test->isModified(), "The time has been set the first time and need to be modified!"); + $this->asserttrue($test->isModified(), 'The time has been set the first time and need to be modified!'); $test->save(); $test->setTime($time); - $this->assertfalse($test->isModified(), "The time has been marked as modified, although it was provided with the same time string as before!"); + $this->assertfalse($test->isModified(), 'The time has been marked as modified, although it was provided with the same time string as before!'); $timeObject->modify('+1 days'); $test->setTime($timeObject); - $this->assertfalse($test->isModified(), "The date was modified, but not the time!"); + $this->assertfalse($test->isModified(), 'The date was modified, but not the time!'); $timeObject->modify('+7 hours'); $test->setTime($timeObject); - $this->asserttrue($test->isModified(), "The time has not been modified!"); + $this->asserttrue($test->isModified(), 'The time has not been modified!'); $test->save(); $test->setTime(null); - $this->asserttrue($test->isModified(), "The time has not been modified and not set to null!"); + $this->asserttrue($test->isModified(), 'The time has not been modified and not set to null!'); $test->save(); - $this->assertnull($test->getTime(), "The time was not set to null!"); + $this->assertnull($test->getTime(), 'The time was not set to null!'); $test->setTime($timeObject); - $this->asserttrue($test->isModified(), "The time has not been modified!"); + $this->asserttrue($test->isModified(), 'The time has not been modified!'); $test->save(); } @@ -92,52 +101,55 @@ public function testTimeModified() /* * Test if the date was set correctly and in which case it will be modified */ + + /** + * @return void + */ public function testDateModified() { - $date = "2015-03-28"; + $date = '2015-03-28'; - $dateObject = new \DateTime($date); + $dateObject = new DateTime($date); - $test = new \Timing(); + $test = new Timing(); $test ->setId(2) - ->setDate($date) - ; + ->setDate($date); - $this->asserttrue($test->isModified(), "The date has been set the first time and need to be modified!"); + $this->asserttrue($test->isModified(), 'The date has been set the first time and need to be modified!'); $test->save(); $test->setDate($date); - $this->assertfalse($test->isModified(), "The date has been marked as modified, although it was provided with the same date string as before!"); + $this->assertfalse($test->isModified(), 'The date has been marked as modified, although it was provided with the same date string as before!'); $dateObject->modify('+4 hours'); $test->setDate($dateObject); - $this->assertfalse($test->isModified(), "The time was modified, but not the date!"); + $this->assertfalse($test->isModified(), 'The time was modified, but not the date!'); $dateObject->modify('+7 days'); $test->setDate($dateObject); - $this->asserttrue($test->isModified(), "The date has been not modified!"); + $this->asserttrue($test->isModified(), 'The date has been not modified!'); $test->save(); $test->setDate(null); - $this->asserttrue($test->isModified(), "The date has been not modified and not set to null!"); + $this->asserttrue($test->isModified(), 'The date has been not modified and not set to null!'); $test->save(); - $this->assertnull($test->getDate(), "The date was not set to null!"); + $this->assertnull($test->getDate(), 'The date was not set to null!'); $test->setDate($dateObject); - $this->asserttrue($test->isModified(), "The date has not been modified!"); + $this->asserttrue($test->isModified(), 'The date has not been modified!'); $test->save(); } @@ -145,32 +157,34 @@ public function testDateModified() /* * Test if the time and date was set correctly and in which case it will be modified */ + /** + * @return void + */ public function testDateTimeModified() { - $dateTime = "2015-09-27 17:37:19"; + $dateTime = '2015-09-27 17:37:19'; - $dateTimeObject = new \DateTime($dateTime); + $dateTimeObject = new DateTime($dateTime); - $test = new \Timing(); + $test = new Timing(); $test ->setId(3) - ->setDateTime($dateTime) - ; + ->setDateTime($dateTime); - $this->asserttrue($test->isModified(), "The datetime has been set the first time and need to be modified!"); + $this->asserttrue($test->isModified(), 'The datetime has been set the first time and need to be modified!'); $test->save(); $test->setDateTime($dateTime); - $this->assertfalse($test->isModified(), "The datetime has been marked as modified, although it was provided with the same datetime string as before!"); + $this->assertfalse($test->isModified(), 'The datetime has been marked as modified, although it was provided with the same datetime string as before!'); $dateTimeObject->modify('+4 hours'); $test->setDateTime($dateTimeObject); - $this->asserttrue($test->isModified(), "The time has been not modified!"); + $this->asserttrue($test->isModified(), 'The time has been not modified!'); $test->save(); @@ -178,21 +192,21 @@ public function testDateTimeModified() $test->setDateTime($dateTimeObject); - $this->asserttrue($test->isModified(), "The date has been not modified!"); + $this->asserttrue($test->isModified(), 'The date has been not modified!'); $test->save(); $test->setDateTime(null); - $this->asserttrue($test->isModified(), "The datetime has been not modified and not set to null!"); + $this->asserttrue($test->isModified(), 'The datetime has been not modified and not set to null!'); $test->save(); - $this->assertnull($test->getDateTime(), "The datetime was not set to null!"); + $this->assertnull($test->getDateTime(), 'The datetime was not set to null!'); $test->setDateTime($dateTimeObject); - $this->asserttrue($test->isModified(), "The datetime has not been modified!"); + $this->asserttrue($test->isModified(), 'The datetime has not been modified!'); $test->save(); } diff --git a/tests/Propel/Tests/Issues/Issue829Test.php b/tests/Propel/Tests/Issues/Issue829Test.php index 240e01a357..566d3811da 100644 --- a/tests/Propel/Tests/Issues/Issue829Test.php +++ b/tests/Propel/Tests/Issues/Issue829Test.php @@ -6,10 +6,14 @@ * * @license MIT License */ + namespace Propel\Tests\Issues; +use DateTime; +use Map\Table829TableMap; use Propel\Generator\Util\QuickBuilder; use Propel\Tests\TestCase; +use Table829; /** * Regression test for https://github.com/propelorm/Propel2/issues/829 @@ -18,6 +22,9 @@ */ class Issue829Test extends TestCase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -38,16 +45,18 @@ protected function setUp(): void * Test if adding to instance pool doesn't throw an exception when primary key is composed of fields of types * that can be serialized but cannot be casted to a string (f.in. \DateTime) */ + /** + * @return void + */ public function testAddingToInstancePool() { - $date = new \DateTime; - $test = new \Table829(); + $date = new DateTime(); + $test = new Table829(); $test ->setId(1) - ->setDate($date) - ; + ->setDate($date); - \Map\Table829TableMap::addInstanceToPool($test); + Table829TableMap::addInstanceToPool($test); } } diff --git a/tests/Propel/Tests/Issues/Issue915Book.php b/tests/Propel/Tests/Issues/Issue915Book.php index fdbbe5ce5f..e12d717bcf 100644 --- a/tests/Propel/Tests/Issues/Issue915Book.php +++ b/tests/Propel/Tests/Issues/Issue915Book.php @@ -2,11 +2,15 @@ namespace Propel\Tests\Issues; +use Base\Issue915Book as BaseIssue915Book; -class Issue915Book extends \Base\Issue915Book +class Issue915Book extends BaseIssue915Book { private $color; + /** + * @return void + */ public function setColor($color) { $this->color = $color; @@ -16,4 +20,4 @@ public function getColor() { return $this->color; } -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Issues/Issue915Test.php b/tests/Propel/Tests/Issues/Issue915Test.php index 53db728fb3..52de0c416d 100644 --- a/tests/Propel/Tests/Issues/Issue915Test.php +++ b/tests/Propel/Tests/Issues/Issue915Test.php @@ -5,14 +5,16 @@ use Propel\Generator\Util\QuickBuilder; use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; - - /** * This test proves the bug described in https://github.com/propelorm/Propel2/issues/915. + * * @group database */ class Issue915Test extends BookstoreTestBase { + /** + * @return void + */ public function setUp(): void { if (!class_exists('\Base\Issue915Book')) { @@ -30,6 +32,9 @@ public function setUp(): void } } + /** + * @return void + */ public function testSerialize() { $o = new Issue915Book(); @@ -38,5 +43,4 @@ public function testSerialize() $unserializedBook = unserialize(serialize($o)); $this->assertEquals('blue', $unserializedBook->getColor()); } - } diff --git a/tests/Propel/Tests/Issues/Issue989Test.php b/tests/Propel/Tests/Issues/Issue989Test.php index 4744db00ce..de7f4efaef 100644 --- a/tests/Propel/Tests/Issues/Issue989Test.php +++ b/tests/Propel/Tests/Issues/Issue989Test.php @@ -2,8 +2,12 @@ namespace Propel\Tests\Issues; -use Propel\Tests\TestCase; +use Nature; use Propel\Generator\Util\QuickBuilder; +use Propel\Runtime\Collection\ObjectCollection; +use Propel\Tests\TestCase; +use Recherche; +use RechercheNature; /** * This test proves the bug described in https://github.com/propelorm/Propel2/issues/989. @@ -12,6 +16,9 @@ */ class Issue989Test extends TestCase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -42,22 +49,25 @@ protected function setUp(): void } } + /** + * @return void + */ public function testIssue989() { - $nature = new \Nature(); + $nature = new Nature(); $nature->save(); // RechercheNature - $rechercheNature = new \RechercheNature(); + $rechercheNature = new RechercheNature(); $rechercheNature->setNatureId($nature->getId()); // Collection - $collection = new \Propel\Runtime\Collection\ObjectCollection(); + $collection = new ObjectCollection(); $collection->setModel('\RechercheNature'); - $collection->setData(array($rechercheNature)); + $collection->setData([$rechercheNature]); // Recherche - $recherche = new \Recherche(); + $recherche = new Recherche(); $recherche->setRechercheNatures($collection); $countBeforeSave = $recherche->countRechercheNatures(); diff --git a/tests/Propel/Tests/Resources/blog-schema.php b/tests/Propel/Tests/Resources/blog-schema.php index f18564e310..51caec19f4 100644 --- a/tests/Propel/Tests/Resources/blog-schema.php +++ b/tests/Propel/Tests/Resources/blog-schema.php @@ -10,4 +10,3 @@ $schema->addDatabase($database); return $schema; - diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaCombineTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaCombineTest.php index 8557134d4b..a0e8cc2b60 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaCombineTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaCombineTest.php @@ -10,26 +10,25 @@ namespace Propel\Tests\Runtime\ActiveQuery; -use Propel\Runtime\Exception\PropelException; -use Propel\Tests\Helpers\BaseTestCase; - -use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Adapter\Pdo\SqliteAdapter; +use Propel\Runtime\Exception\PropelException; +use Propel\Runtime\Propel; +use Propel\Tests\Helpers\BaseTestCase; /** * Test class for Criteria combinations. * * @author Francois Zaninotto - * @version $Id$ + * @version $Id$ */ class CriteriaCombineTest extends BaseTestCase { - /** * The criteria to use in the test. - * @var Criteria + * + * @var \Propel\Runtime\ActiveQuery\Criteria */ private $c; @@ -40,6 +39,9 @@ class CriteriaCombineTest extends BaseTestCase */ private $savedAdapter; + /** + * @return void + */ protected function setUp(): void { Propel::init(__DIR__ . '/../../../../Fixtures/bookstore/build/conf/bookstore-conf.php'); @@ -55,6 +57,9 @@ protected function getDriver() return 'sqlite'; } + /** + * @return void + */ protected function tearDown(): void { Propel::getServiceContainer()->setAdapter(Propel::getServiceContainer()->getDefaultDatasource(), $this->savedAdapter); @@ -63,27 +68,29 @@ protected function tearDown(): void /** * test various properties of Criterion and nested criterion + * + * @return void */ public function testNestedCriterion() { - $table2 = "myTable2"; - $column2 = "myColumn2"; - $value2 = "myValue2"; + $table2 = 'myTable2'; + $column2 = 'myColumn2'; + $value2 = 'myValue2'; $key2 = "$table2.$column2"; - $table3 = "myTable3"; - $column3 = "myColumn3"; - $value3 = "myValue3"; + $table3 = 'myTable3'; + $column3 = 'myColumn3'; + $value3 = 'myValue3'; $key3 = "$table3.$column3"; - $table4 = "myTable4"; - $column4 = "myColumn4"; - $value4 = "myValue4"; + $table4 = 'myTable4'; + $column4 = 'myColumn4'; + $value4 = 'myValue4'; $key4 = "$table4.$column4"; - $table5 = "myTable5"; - $column5 = "myColumn5"; - $value5 = "myValue5"; + $table5 = 'myTable5'; + $column5 = 'myColumn5'; + $value5 = 'myValue5'; $key5 = "$table5.$column5"; $crit2 = $this->c->getNewCriterion($key2, $value2, Criteria::EQUAL); @@ -92,10 +99,10 @@ public function testNestedCriterion() $crit5 = $this->c->getNewCriterion($key5, $value5, Criteria::EQUAL); $crit2->addAnd($crit3)->addOr($crit4->addAnd($crit5)); - $expect = "((myTable2.myColumn2=:p1 AND myTable3.myColumn3=:p2) " - . "OR (myTable4.myColumn4=:p3 AND myTable5.myColumn5=:p4))"; + $expect = '((myTable2.myColumn2=:p1 AND myTable3.myColumn3=:p2) ' + . 'OR (myTable4.myColumn4=:p3 AND myTable5.myColumn5=:p4))'; - $sb = ""; + $sb = ''; $params = []; $crit2->appendPsTo($sb, $params); @@ -115,10 +122,10 @@ public function testNestedCriterion() $crit9 = $this->c->getNewCriterion($key5, $value5, Criteria::EQUAL); $crit6->addAnd($crit7)->addOr($crit8)->addAnd($crit9); - $expect = "(((myTable2.myColumn2=:p1 AND myTable3.myColumn3=:p2) " - . "OR myTable4.myColumn4=:p3) AND myTable5.myColumn5=:p4)"; + $expect = '(((myTable2.myColumn2=:p1 AND myTable3.myColumn3=:p2) ' + . 'OR myTable4.myColumn4=:p3) AND myTable5.myColumn5=:p4)'; - $sb = ""; + $sb = ''; $params = []; $crit6->appendPsTo($sb, $params); @@ -151,14 +158,16 @@ public function testNestedCriterion() /** * Tests <= and >=. + * + * @return void */ public function testBetweenCriterion() { - $cn1 = $this->c->getNewCriterion("INVOICE.COST", 1000, Criteria::GREATER_EQUAL); - $cn2 = $this->c->getNewCriterion("INVOICE.COST", 5000, Criteria::LESS_EQUAL); + $cn1 = $this->c->getNewCriterion('INVOICE.COST', 1000, Criteria::GREATER_EQUAL); + $cn2 = $this->c->getNewCriterion('INVOICE.COST', 5000, Criteria::LESS_EQUAL); $this->c->add($cn1->addAnd($cn2)); - $expect = $this->getSql("SELECT FROM INVOICE WHERE (INVOICE.COST>=:p1 AND INVOICE.COST<=:p2)"); + $expect = $this->getSql('SELECT FROM INVOICE WHERE (INVOICE.COST>=:p1 AND INVOICE.COST<=:p2)'); $expect_params = [ ['table' => 'INVOICE', 'column' => 'COST', 'value' => 1000], ['table' => 'INVOICE', 'column' => 'COST', 'value' => 5000], @@ -168,7 +177,7 @@ public function testBetweenCriterion() $params = []; $result = $this->c->createSelectSql($params); } catch (PropelException $e) { - $this->fail("PropelException thrown in Criteria->createSelectSql(): ".$e->getMessage()); + $this->fail('PropelException thrown in Criteria->createSelectSql(): ' . $e->getMessage()); } $this->assertEquals($expect, $result); @@ -177,17 +186,19 @@ public function testBetweenCriterion() /** * Verify that AND and OR criterion are nested correctly. + * + * @return void */ public function testPrecedence() { - $cn1 = $this->c->getNewCriterion("INVOICE.COST", "1000", Criteria::GREATER_EQUAL); - $cn2 = $this->c->getNewCriterion("INVOICE.COST", "2000", Criteria::LESS_EQUAL); - $cn3 = $this->c->getNewCriterion("INVOICE.COST", "8000", Criteria::GREATER_EQUAL); - $cn4 = $this->c->getNewCriterion("INVOICE.COST", "9000", Criteria::LESS_EQUAL); + $cn1 = $this->c->getNewCriterion('INVOICE.COST', '1000', Criteria::GREATER_EQUAL); + $cn2 = $this->c->getNewCriterion('INVOICE.COST', '2000', Criteria::LESS_EQUAL); + $cn3 = $this->c->getNewCriterion('INVOICE.COST', '8000', Criteria::GREATER_EQUAL); + $cn4 = $this->c->getNewCriterion('INVOICE.COST', '9000', Criteria::LESS_EQUAL); $this->c->add($cn1->addAnd($cn2)); $this->c->addOr($cn3->addAnd($cn4)); - $expect = $this->getSql("SELECT FROM INVOICE WHERE ((INVOICE.COST>=:p1 AND INVOICE.COST<=:p2) OR (INVOICE.COST>=:p3 AND INVOICE.COST<=:p4))"); + $expect = $this->getSql('SELECT FROM INVOICE WHERE ((INVOICE.COST>=:p1 AND INVOICE.COST<=:p2) OR (INVOICE.COST>=:p3 AND INVOICE.COST<=:p4))'); $expect_params = [ ['table' => 'INVOICE', 'column' => 'COST', 'value' => '1000'], @@ -197,23 +208,26 @@ public function testPrecedence() ]; try { - $params=[]; + $params = []; $result = $this->c->createSelectSql($params); } catch (PropelException $e) { - $this->fail("PropelException thrown in Criteria::createSelectSql()"); + $this->fail('PropelException thrown in Criteria::createSelectSql()'); } $this->assertEquals($expect, $result); $this->assertEquals($expect_params, $params); } + /** + * @return void + */ public function testCombineCriterionAndSimple() { - $this->c->addCond('cond1', "INVOICE.COST", "1000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond2', "INVOICE.COST", "2000", Criteria::LESS_EQUAL); + $this->c->addCond('cond1', 'INVOICE.COST', '1000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond2', 'INVOICE.COST', '2000', Criteria::LESS_EQUAL); $this->c->combine(['cond1', 'cond2'], Criteria::LOGICAL_AND); - $expect = $this->getSql("SELECT FROM INVOICE WHERE (INVOICE.COST>=:p1 AND INVOICE.COST<=:p2)"); + $expect = $this->getSql('SELECT FROM INVOICE WHERE (INVOICE.COST>=:p1 AND INVOICE.COST<=:p2)'); $expect_params = [ ['table' => 'INVOICE', 'column' => 'COST', 'value' => '1000'], ['table' => 'INVOICE', 'column' => 'COST', 'value' => '2000'], @@ -226,15 +240,18 @@ public function testCombineCriterionAndSimple() $this->assertEquals($expect_params, $params); } + /** + * @return void + */ public function testCombineCriterionAndLessSimple() { - $this->c->addCond('cond1', "INVOICE.COST1", "1000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL); - $this->c->add("INVOICE.COST3", "8000", Criteria::GREATER_EQUAL); + $this->c->addCond('cond1', 'INVOICE.COST1', '1000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond2', 'INVOICE.COST2', '2000', Criteria::LESS_EQUAL); + $this->c->add('INVOICE.COST3', '8000', Criteria::GREATER_EQUAL); $this->c->combine(['cond1', 'cond2'], Criteria::LOGICAL_AND); - $this->c->add("INVOICE.COST4", "9000", Criteria::LESS_EQUAL); + $this->c->add('INVOICE.COST4', '9000', Criteria::LESS_EQUAL); - $expect = $this->getSql("SELECT FROM INVOICE WHERE INVOICE.COST3>=:p1 AND (INVOICE.COST1>=:p2 AND INVOICE.COST2<=:p3) AND INVOICE.COST4<=:p4"); + $expect = $this->getSql('SELECT FROM INVOICE WHERE INVOICE.COST3>=:p1 AND (INVOICE.COST1>=:p2 AND INVOICE.COST2<=:p3) AND INVOICE.COST4<=:p4'); $expect_params = [ ['table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'], ['table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'], @@ -249,15 +266,18 @@ public function testCombineCriterionAndLessSimple() $this->assertEquals($expect_params, $params); } + /** + * @return void + */ public function testCombineCriterionAndMultiple() { - $this->c->addCond('cond1',"INVOICE.COST1", "1000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL); - $this->c->addCond('cond3', "INVOICE.COST3", "8000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond4', "INVOICE.COST4", "9000", Criteria::LESS_EQUAL); + $this->c->addCond('cond1', 'INVOICE.COST1', '1000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond2', 'INVOICE.COST2', '2000', Criteria::LESS_EQUAL); + $this->c->addCond('cond3', 'INVOICE.COST3', '8000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond4', 'INVOICE.COST4', '9000', Criteria::LESS_EQUAL); $this->c->combine(['cond1', 'cond2', 'cond3', 'cond4'], Criteria::LOGICAL_AND); - $expect = $this->getSql("SELECT FROM INVOICE WHERE (((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) AND INVOICE.COST3>=:p3) AND INVOICE.COST4<=:p4)"); + $expect = $this->getSql('SELECT FROM INVOICE WHERE (((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) AND INVOICE.COST3>=:p3) AND INVOICE.COST4<=:p4)'); $expect_params = [ ['table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'], ['table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'], @@ -272,13 +292,16 @@ public function testCombineCriterionAndMultiple() $this->assertEquals($expect_params, $params); } + /** + * @return void + */ public function testCombineCriterionOrSimple() { - $this->c->addCond('cond1', "INVOICE.COST", "1000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond2', "INVOICE.COST", "2000", Criteria::LESS_EQUAL); + $this->c->addCond('cond1', 'INVOICE.COST', '1000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond2', 'INVOICE.COST', '2000', Criteria::LESS_EQUAL); $this->c->combine(['cond1', 'cond2'], Criteria::LOGICAL_OR); - $expect = $this->getSql("SELECT FROM INVOICE WHERE (INVOICE.COST>=:p1 OR INVOICE.COST<=:p2)"); + $expect = $this->getSql('SELECT FROM INVOICE WHERE (INVOICE.COST>=:p1 OR INVOICE.COST<=:p2)'); $expect_params = [ ['table' => 'INVOICE', 'column' => 'COST', 'value' => '1000'], ['table' => 'INVOICE', 'column' => 'COST', 'value' => '2000'], @@ -291,15 +314,18 @@ public function testCombineCriterionOrSimple() $this->assertEquals($expect_params, $params); } + /** + * @return void + */ public function testCombineCriterionOrLessSimple() { - $this->c->addCond('cond1', "INVOICE.COST1", "1000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL); - $this->c->add("INVOICE.COST3", "8000", Criteria::GREATER_EQUAL); + $this->c->addCond('cond1', 'INVOICE.COST1', '1000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond2', 'INVOICE.COST2', '2000', Criteria::LESS_EQUAL); + $this->c->add('INVOICE.COST3', '8000', Criteria::GREATER_EQUAL); $this->c->combine(['cond1', 'cond2'], Criteria::LOGICAL_OR); - $this->c->addOr("INVOICE.COST4", "9000", Criteria::LESS_EQUAL); + $this->c->addOr('INVOICE.COST4', '9000', Criteria::LESS_EQUAL); - $expect = $this->getSql("SELECT FROM INVOICE WHERE INVOICE.COST3>=:p1 AND ((INVOICE.COST1>=:p2 OR INVOICE.COST2<=:p3) OR INVOICE.COST4<=:p4)"); + $expect = $this->getSql('SELECT FROM INVOICE WHERE INVOICE.COST3>=:p1 AND ((INVOICE.COST1>=:p2 OR INVOICE.COST2<=:p3) OR INVOICE.COST4<=:p4)'); $expect_params = [ ['table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'], ['table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'], @@ -314,15 +340,18 @@ public function testCombineCriterionOrLessSimple() $this->assertEquals($expect_params, $params); } + /** + * @return void + */ public function testCombineCriterionOrMultiple() { - $this->c->addCond('cond1',"INVOICE.COST1", "1000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL); - $this->c->addCond('cond3', "INVOICE.COST3", "8000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond4', "INVOICE.COST4", "9000", Criteria::LESS_EQUAL); + $this->c->addCond('cond1', 'INVOICE.COST1', '1000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond2', 'INVOICE.COST2', '2000', Criteria::LESS_EQUAL); + $this->c->addCond('cond3', 'INVOICE.COST3', '8000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond4', 'INVOICE.COST4', '9000', Criteria::LESS_EQUAL); $this->c->combine(['cond1', 'cond2', 'cond3', 'cond4'], Criteria::LOGICAL_OR); - $expect = $this->getSql("SELECT FROM INVOICE WHERE (((INVOICE.COST1>=:p1 OR INVOICE.COST2<=:p2) OR INVOICE.COST3>=:p3) OR INVOICE.COST4<=:p4)"); + $expect = $this->getSql('SELECT FROM INVOICE WHERE (((INVOICE.COST1>=:p1 OR INVOICE.COST2<=:p2) OR INVOICE.COST3>=:p3) OR INVOICE.COST4<=:p4)'); $expect_params = [ ['table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'], ['table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'], @@ -337,17 +366,20 @@ public function testCombineCriterionOrMultiple() $this->assertEquals($expect_params, $params); } + /** + * @return void + */ public function testCombineNamedCriterions() { - $this->c->addCond('cond1', "INVOICE.COST1", "1000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL); + $this->c->addCond('cond1', 'INVOICE.COST1', '1000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond2', 'INVOICE.COST2', '2000', Criteria::LESS_EQUAL); $this->c->combine(['cond1', 'cond2'], Criteria::LOGICAL_AND, 'cond12'); - $this->c->addCond('cond3', "INVOICE.COST3", "8000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond4', "INVOICE.COST4", "9000", Criteria::LESS_EQUAL); + $this->c->addCond('cond3', 'INVOICE.COST3', '8000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond4', 'INVOICE.COST4', '9000', Criteria::LESS_EQUAL); $this->c->combine(['cond3', 'cond4'], Criteria::LOGICAL_AND, 'cond34'); $this->c->combine(['cond12', 'cond34'], Criteria::LOGICAL_OR); - $expect = $this->getSql("SELECT FROM INVOICE WHERE ((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) OR (INVOICE.COST3>=:p3 AND INVOICE.COST4<=:p4))"); + $expect = $this->getSql('SELECT FROM INVOICE WHERE ((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) OR (INVOICE.COST3>=:p3 AND INVOICE.COST4<=:p4))'); $expect_params = [ ['table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'], ['table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'], @@ -362,17 +394,20 @@ public function testCombineNamedCriterions() $this->assertEquals($expect_params, $params); } + /** + * @return void + */ public function testCombineDirtyOperators() { - $this->c->addCond('cond1', "INVOICE.COST1", "1000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL); + $this->c->addCond('cond1', 'INVOICE.COST1', '1000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond2', 'INVOICE.COST2', '2000', Criteria::LESS_EQUAL); $this->c->combine(['cond1', 'cond2'], 'AnD', 'cond12'); - $this->c->addCond('cond3', "INVOICE.COST3", "8000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond4', "INVOICE.COST4", "9000", Criteria::LESS_EQUAL); + $this->c->addCond('cond3', 'INVOICE.COST3', '8000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond4', 'INVOICE.COST4', '9000', Criteria::LESS_EQUAL); $this->c->combine(['cond3', 'cond4'], 'aNd', 'cond34'); $this->c->combine(['cond12', 'cond34'], 'oR'); - $expect = $this->getSql("SELECT FROM INVOICE WHERE ((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) OR (INVOICE.COST3>=:p3 AND INVOICE.COST4<=:p4))"); + $expect = $this->getSql('SELECT FROM INVOICE WHERE ((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) OR (INVOICE.COST3>=:p3 AND INVOICE.COST4<=:p4))'); $expect_params = [ ['table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'], ['table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'], @@ -387,19 +422,21 @@ public function testCombineDirtyOperators() $this->assertEquals($expect_params, $params); } + /** + * @return void + */ public function testClonedCriteriaNotAffected() { - - $this->c->addCond('cond1', "INVOICE.COST1", "1000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL); + $this->c->addCond('cond1', 'INVOICE.COST1', '1000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond2', 'INVOICE.COST2', '2000', Criteria::LESS_EQUAL); $this->c->combine(['cond1', 'cond2'], Criteria::LOGICAL_AND, 'cond12'); - $this->c->addCond('cond3', "INVOICE.COST3", "8000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond4', "INVOICE.COST4", "9000", Criteria::LESS_EQUAL); + $this->c->addCond('cond3', 'INVOICE.COST3', '8000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond4', 'INVOICE.COST4', '9000', Criteria::LESS_EQUAL); $this->c->combine(['cond3', 'cond4'], Criteria::LOGICAL_AND, 'cond34'); $clonedCriteria = clone $this->c; - $expect1 = $this->getSql("SELECT FROM "); + $expect1 = $this->getSql('SELECT FROM '); $params1 = []; $result1 = $this->c->createSelectSql($params1); @@ -408,7 +445,7 @@ public function testClonedCriteriaNotAffected() $this->c->combine(['cond12', 'cond34'], Criteria::LOGICAL_OR); - $expect2 = $this->getSql("SELECT FROM INVOICE WHERE ((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) OR (INVOICE.COST3>=:p3 AND INVOICE.COST4<=:p4))"); + $expect2 = $this->getSql('SELECT FROM INVOICE WHERE ((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) OR (INVOICE.COST3>=:p3 AND INVOICE.COST4<=:p4))'); $expect_params = [ ['table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'], ['table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'], @@ -428,32 +465,33 @@ public function testClonedCriteriaNotAffected() $result3 = $clonedCriteria->createSelectSql($params3); $this->assertEquals($expect1, $result3); - } - - public function testClonedCriteriaNotAffected2() { - - $this->c->addCond('cond1', "INVOICE.COST1", "1000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL); + /** + * @return void + */ + public function testClonedCriteriaNotAffected2() + { + $this->c->addCond('cond1', 'INVOICE.COST1', '1000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond2', 'INVOICE.COST2', '2000', Criteria::LESS_EQUAL); $this->c->combine(['cond1', 'cond2'], Criteria::LOGICAL_AND, 'cond12'); - $this->c->addCond('cond3', "INVOICE.COST3", "8000", Criteria::GREATER_EQUAL); - $this->c->addCond('cond4', "INVOICE.COST4", "9000", Criteria::LESS_EQUAL); + $this->c->addCond('cond3', 'INVOICE.COST3', '8000', Criteria::GREATER_EQUAL); + $this->c->addCond('cond4', 'INVOICE.COST4', '9000', Criteria::LESS_EQUAL); $this->c->combine(['cond3', 'cond4'], Criteria::LOGICAL_AND, 'cond34'); $clonedCriteria = clone $this->c; - $expect1 = $this->getSql("SELECT FROM "); + $expect1 = $this->getSql('SELECT FROM '); $params1 = []; $result1 = $this->c->createSelectSql($params1); $this->assertEquals($expect1, $result1); - $this->c->addCond('cond5', "INVOICE.COST5", "5000", Criteria::GREATER_EQUAL); + $this->c->addCond('cond5', 'INVOICE.COST5', '5000', Criteria::GREATER_EQUAL); $this->c->combine(['cond34', 'cond5'], Criteria::LOGICAL_AND); - $expect2 = $this->getSql("SELECT FROM INVOICE WHERE ((INVOICE.COST3>=:p1 AND INVOICE.COST4<=:p2) AND INVOICE.COST5>=:p3)"); + $expect2 = $this->getSql('SELECT FROM INVOICE WHERE ((INVOICE.COST3>=:p1 AND INVOICE.COST4<=:p2) AND INVOICE.COST5>=:p3)'); $expect_params2 = [ ['table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'], ['table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000'], @@ -471,7 +509,7 @@ public function testClonedCriteriaNotAffected2() { $clonedCriteria->combine(['cond12', 'cond34'], Criteria::LOGICAL_OR); - $expect3 = $this->getSql("SELECT FROM INVOICE WHERE ((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) OR (INVOICE.COST3>=:p3 AND INVOICE.COST4<=:p4))"); + $expect3 = $this->getSql('SELECT FROM INVOICE WHERE ((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) OR (INVOICE.COST3>=:p3 AND INVOICE.COST4<=:p4))'); $expect_params3 = [ ['table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'], ['table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'], @@ -484,6 +522,5 @@ public function testClonedCriteriaNotAffected2() { $this->assertEquals($expect3, $result3); $this->assertEquals($expect_params3, $params3); - } } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaFluidConditionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaFluidConditionTest.php index 3e24d7fbc2..2c77390105 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaFluidConditionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaFluidConditionTest.php @@ -10,18 +10,20 @@ namespace Propel\Tests\Runtime\ActiveQuery; -use Propel\Tests\Helpers\BaseTestCase; - use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Tests\Helpers\BaseTestCase; /** * Test class for Criteria fluid conditions. * * @author Francois Zaninotto - * @version $Id: CriteriaCombineTest.php 1347 2009-12-03 21:06:36Z francois $ + * @version $Id: CriteriaCombineTest.php 1347 2009-12-03 21:06:36Z francois $ */ class CriteriaFluidConditionTest extends BaseTestCase { + /** + * @return void + */ public function testIf() { $f = new TestableCriteria(); @@ -52,6 +54,9 @@ public function testIf() $this->assertFalse($f->getTest(), '_if() does not execute the next methods until _endif() if the test is false'); } + /** + * @return void + */ public function testNestedIf() { $f = new TestableCriteria(); @@ -136,6 +141,9 @@ public function testNestedIf() $this->assertFalse($f->getTest(), '_if() can be nested on 3 levels'); } + /** + * @return void + */ public function testElseIf() { $f = new TestableCriteria(); @@ -184,6 +192,9 @@ public function testElseIf() $this->assertFalse($f->getTest(), '_elseif() does not executes the next method if the main test is true and the elseif test is true'); } + /** + * @return void + */ public function testElse() { $f = new TestableCriteria(); @@ -227,6 +238,9 @@ public function testElse() $this->assertTrue($f->getTest(), '_else() executes the next method if all the previous tests are false'); } + /** + * @return void + */ public function testEndif() { $f = new TestableCriteria(); @@ -255,6 +269,9 @@ public function testEndif() $this->assertTrue($f->getTest(), '_endif() stops the condition check'); } + /** + * @return void + */ public function testHierarchy() { $f = new TestableCriteria(); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaFluidOperatorTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaFluidOperatorTest.php index 6a4da73553..97839ad7b7 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaFluidOperatorTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaFluidOperatorTest.php @@ -10,9 +10,8 @@ namespace Propel\Tests\Runtime\ActiveQuery; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; - use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Test class for Criteria fluid operators. @@ -23,6 +22,9 @@ */ class CriteriaFluidOperatorTest extends BookstoreTestBase { + /** + * @return void + */ public function testDefault() { $c = new Criteria(); @@ -35,6 +37,9 @@ public function testDefault() $this->assertEquals($expected, $result); } + /** + * @return void + */ public function testDefaultOperatorIsAnd() { $c = new Criteria(); @@ -48,6 +53,9 @@ public function testDefaultOperatorIsAnd() $this->assertEquals($expected, $result); } + /** + * @return void + */ public function testOrOverridesDefaultOperator() { $c = new Criteria(); @@ -62,6 +70,9 @@ public function testOrOverridesDefaultOperator() $this->assertEquals($expected, $result); } + /** + * @return void + */ public function testOrWithNoExistingCriterionIsAnd() { $c = new Criteria(); @@ -75,6 +86,9 @@ public function testOrWithNoExistingCriterionIsAnd() $this->assertEquals($expected, $result); } + /** + * @return void + */ public function testOrWithNoExistingCriterionIsAnd2() { $c = new Criteria(); @@ -89,6 +103,9 @@ public function testOrWithNoExistingCriterionIsAnd2() $this->assertEquals($expected, $result); } + /** + * @return void + */ public function testOrCanBeCalledSeveralTimes() { $c = new Criteria(); @@ -105,6 +122,9 @@ public function testOrCanBeCalledSeveralTimes() $this->assertEquals($expected, $result); } + /** + * @return void + */ public function testaddUsingOperatorResetsDefaultOperator() { $c = new Criteria(); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaMergeTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaMergeTest.php index e3d2a955e5..6d40d7c021 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaMergeTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaMergeTest.php @@ -10,10 +10,10 @@ namespace Propel\Tests\Runtime\ActiveQuery; +use Propel\Runtime\ActiveQuery\Criteria; use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\PublisherTableMap; -use Propel\Runtime\ActiveQuery\Criteria; use Propel\Tests\TestCaseFixtures; /** @@ -24,6 +24,9 @@ */ class CriteriaMergeTest extends TestCaseFixtures { + /** + * @return void + */ protected function assertCriteriaTranslation($criteria, $expectedSql, $message = '') { $params = []; @@ -31,6 +34,9 @@ protected function assertCriteriaTranslation($criteria, $expectedSql, $message = $this->assertEquals($expectedSql, $result, $message); } + /** + * @return void + */ public function testMergeWithLimit() { $c1 = new Criteria(); @@ -51,6 +57,9 @@ public function testMergeWithLimit() $this->assertEquals(456, $c1->getLimit(), 'mergeWith() does not merge the limit in case of conflict'); } + /** + * @return void + */ public function testMergeWithOffset() { $c1 = new Criteria(); @@ -71,6 +80,9 @@ public function testMergeWithOffset() $this->assertEquals(456, $c1->getOffset(), 'mergeWith() does not merge the offset in case of conflict'); } + /** + * @return void + */ public function testMergeWithSelectModifiers() { $c1 = new Criteria(); @@ -97,6 +109,9 @@ public function testMergeWithSelectModifiers() $this->assertEquals([Criteria::ALL], $c1->getSelectModifiers(), 'mergeWith() does not merge the select modifiers in case of conflict'); } + /** + * @return void + */ public function testMergeWithSelectColumns() { $c1 = new Criteria(); @@ -125,6 +140,9 @@ public function testMergeWithSelectColumns() $this->assertEquals([BookTableMap::COL_TITLE, BookTableMap::COL_TITLE], $c1->getSelectColumns(), 'mergeWith() merges the select columns to an existing select, even if duplicated'); } + /** + * @return void + */ public function testMergeWithAsColumns() { $c1 = new Criteria(); @@ -149,6 +167,8 @@ public function testMergeWithAsColumns() /** * @expectedException \Propel\Runtime\Exception\LogicException + * + * @return void */ public function testMergeWithAsColumnsThrowsException() { @@ -159,6 +179,9 @@ public function testMergeWithAsColumnsThrowsException() $c1->mergeWith($c2); } + /** + * @return void + */ public function testMergeWithOrderByColumns() { $c1 = new Criteria(); @@ -193,6 +216,9 @@ public function testMergeWithOrderByColumns() $this->assertEquals([BookTableMap::COL_TITLE . ' ASC', BookTableMap::COL_TITLE . ' DESC'], $c1->getOrderByColumns(), 'mergeWith() merges duplicated orderby columns with inverse direction'); } + /** + * @return void + */ public function testMergeWithGroupByColumns() { $c1 = new Criteria(); @@ -221,6 +247,9 @@ public function testMergeWithGroupByColumns() $this->assertEquals([BookTableMap::COL_TITLE], $c1->getGroupByColumns(), 'mergeWith() does not merge duplicated groupby columns'); } + /** + * @return void + */ public function testMergeWithWhereConditions() { $c1 = new Criteria(); @@ -259,6 +288,9 @@ public function testMergeWithWhereConditions() $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the different tables'); } + /** + * @return void + */ public function testMergeOrWithWhereConditions() { $c1 = new Criteria(); @@ -297,6 +329,9 @@ public function testMergeOrWithWhereConditions() $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the different tables'); } + /** + * @return void + */ public function testMerge_OrWithWhereConditions() { $c1 = new Criteria(); @@ -340,6 +375,9 @@ public function testMerge_OrWithWhereConditions() $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the different tables'); } + /** + * @return void + */ public function testMergeWithHavingConditions() { $c1 = new Criteria(); @@ -367,6 +405,9 @@ public function testMergeWithHavingConditions() $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() combines having with AND'); } + /** + * @return void + */ public function testMergeWithAliases() { $c1 = new Criteria(); @@ -389,6 +430,8 @@ public function testMergeWithAliases() /** * @expectedException \Propel\Runtime\Exception\LogicException + * + * @return void */ public function testMergeWithAliasesThrowsException() { @@ -399,6 +442,9 @@ public function testMergeWithAliasesThrowsException() $c1->mergeWith($c2); } + /** + * @return void + */ public function testMergeWithJoins() { $c1 = new Criteria(); @@ -426,6 +472,9 @@ public function testMergeWithJoins() $this->assertEquals('INNER JOIN publisher ON (book.publisher_id=publisher.id)', $joins[1]->toString(), 'mergeWith() merge joins to an empty join'); } + /** + * @return void + */ public function testMergeWithFurtherModified() { $c1 = new Criteria(); @@ -436,5 +485,4 @@ public function testMergeWithFurtherModified() $c2->setLimit(456); $this->assertEquals(123, $c1->getLimit(), 'further modifying a merged criteria does not affect the merger'); } - } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaTest.php index 2047f75a94..06a0b9fe02 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaTest.php @@ -10,17 +10,17 @@ namespace Propel\Tests\Runtime\ActiveQuery; -use Propel\Runtime\Exception\PropelException; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; -use Propel\Tests\Bookstore\Map\BookTableMap; -use Propel\Tests\Bookstore\BookQuery; - -use Propel\Runtime\Propel; -use Propel\Runtime\Adapter\Pdo\MysqlAdapter; -use Propel\Runtime\Adapter\Pdo\PgsqlAdapter; +use PDO; use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveQuery\Join; +use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\Adapter\Pdo\MysqlAdapter; +use Propel\Runtime\Adapter\Pdo\PgsqlAdapter; +use Propel\Runtime\Exception\PropelException; +use Propel\Runtime\Propel; +use Propel\Tests\Bookstore\BookQuery; +use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Test class for Criteria. @@ -32,10 +32,10 @@ */ class CriteriaTest extends BookstoreTestBase { - /** * The criteria to use in the test. - * @var Criteria + * + * @var \Propel\Runtime\ActiveQuery\Criteria */ private $c; @@ -46,6 +46,9 @@ class CriteriaTest extends BookstoreTestBase // */ // private $savedAdapter; + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -54,12 +57,14 @@ protected function setUp(): void /** * Test basic adding of strings. + * + * @return void */ public function testAddString() { - $table = "myTable"; - $column = "myColumn"; - $value = "myValue"; + $table = 'myTable'; + $column = 'myColumn'; + $value = 'myValue'; // Add the string $this->c->add($table . '.' . $column, $value); @@ -73,12 +78,14 @@ public function testAddString() /** * Test basic adding of strings for table with explicit schema. + * + * @return void */ public function testAddStringWithSchemas() { - $table = "mySchema.myTable"; - $column = "myColumn"; - $value = "myValue"; + $table = 'mySchema.myTable'; + $column = 'myColumn'; + $value = 'myValue'; // Add the string $this->c->add($table . '.' . $column, $value); @@ -90,22 +97,25 @@ public function testAddStringWithSchemas() $this->assertTrue($this->c->getValue($table . '.' . $column) === $value); } + /** + * @return void + */ public function testAddAndSameColumns() { - $table1 = "myTable1"; - $column1 = "myColumn1"; - $value1 = "myValue1"; + $table1 = 'myTable1'; + $column1 = 'myColumn1'; + $value1 = 'myValue1'; $key1 = "$table1.$column1"; - $table2 = "myTable1"; - $column2 = "myColumn1"; - $value2 = "myValue2"; + $table2 = 'myTable1'; + $column2 = 'myColumn1'; + $value2 = 'myValue2'; $key2 = "$table2.$column2"; $this->c->add($key1, $value1, Criteria::EQUAL); $this->c->addAnd($key2, $value2, Criteria::EQUAL); - $expect = $this->getSql("SELECT FROM myTable1 WHERE (myTable1.myColumn1=:p1 AND myTable1.myColumn1=:p2)"); + $expect = $this->getSql('SELECT FROM myTable1 WHERE (myTable1.myColumn1=:p1 AND myTable1.myColumn1=:p2)'); $params = []; $result = $this->c->createSelectSql($params); @@ -119,28 +129,31 @@ public function testAddAndSameColumns() $this->assertEquals($expect_params, $params, 'addAnd() called on an existing column creates a combined criterion'); } + /** + * @return void + */ public function testAddAndSameColumnsPropel14Compatibility() { - $table1 = "myTable1"; - $column1 = "myColumn1"; - $value1 = "myValue1"; + $table1 = 'myTable1'; + $column1 = 'myColumn1'; + $value1 = 'myValue1'; $key1 = "$table1.$column1"; - $table2 = "myTable1"; - $column2 = "myColumn1"; - $value2 = "myValue2"; + $table2 = 'myTable1'; + $column2 = 'myColumn1'; + $value2 = 'myValue2'; $key2 = "$table2.$column2"; - $table3 = "myTable3"; - $column3 = "myColumn3"; - $value3 = "myValue3"; + $table3 = 'myTable3'; + $column3 = 'myColumn3'; + $value3 = 'myValue3'; $key3 = "$table3.$column3"; $this->c->add($key1, $value1, Criteria::EQUAL); $this->c->add($key3, $value3, Criteria::EQUAL); $this->c->addAnd($key2, $value2, Criteria::EQUAL); - $expect = $this->getSql("SELECT FROM myTable1, myTable3 WHERE (myTable1.myColumn1=:p1 AND myTable1.myColumn1=:p2) AND myTable3.myColumn3=:p3"); + $expect = $this->getSql('SELECT FROM myTable1, myTable3 WHERE (myTable1.myColumn1=:p1 AND myTable1.myColumn1=:p2) AND myTable3.myColumn3=:p3'); $params = []; $result = $this->c->createSelectSql($params); @@ -155,22 +168,25 @@ public function testAddAndSameColumnsPropel14Compatibility() $this->assertEquals($expect_params, $params, 'addAnd() called on an existing column creates a combined criterion'); } + /** + * @return void + */ public function testAddAndDistinctColumns() { - $table1 = "myTable1"; - $column1 = "myColumn1"; - $value1 = "myValue1"; + $table1 = 'myTable1'; + $column1 = 'myColumn1'; + $value1 = 'myValue1'; $key1 = "$table1.$column1"; - $table2 = "myTable2"; - $column2 = "myColumn2"; - $value2 = "myValue2"; + $table2 = 'myTable2'; + $column2 = 'myColumn2'; + $value2 = 'myValue2'; $key2 = "$table2.$column2"; $this->c->add($key1, $value1, Criteria::EQUAL); $this->c->addAnd($key2, $value2, Criteria::EQUAL); - $expect = $this->getSql("SELECT FROM myTable1, myTable2 WHERE myTable1.myColumn1=:p1 AND myTable2.myColumn2=:p2"); + $expect = $this->getSql('SELECT FROM myTable1, myTable2 WHERE myTable1.myColumn1=:p1 AND myTable2.myColumn2=:p2'); $params = []; $result = $this->c->createSelectSql($params); @@ -184,22 +200,25 @@ public function testAddAndDistinctColumns() $this->assertEquals($expect_params, $params, 'addAnd() called on a distinct column adds a criterion to the criteria'); } + /** + * @return void + */ public function testAddOrSameColumns() { - $table1 = "myTable1"; - $column1 = "myColumn1"; - $value1 = "myValue1"; + $table1 = 'myTable1'; + $column1 = 'myColumn1'; + $value1 = 'myValue1'; $key1 = "$table1.$column1"; - $table2 = "myTable1"; - $column2 = "myColumn1"; - $value2 = "myValue2"; + $table2 = 'myTable1'; + $column2 = 'myColumn1'; + $value2 = 'myValue2'; $key2 = "$table2.$column2"; $this->c->add($key1, $value1, Criteria::EQUAL); $this->c->addOr($key2, $value2, Criteria::EQUAL); - $expect = $this->getSql("SELECT FROM myTable1 WHERE (myTable1.myColumn1=:p1 OR myTable1.myColumn1=:p2)"); + $expect = $this->getSql('SELECT FROM myTable1 WHERE (myTable1.myColumn1=:p1 OR myTable1.myColumn1=:p2)'); $params = []; $result = $this->c->createSelectSql($params); @@ -213,22 +232,25 @@ public function testAddOrSameColumns() $this->assertEquals($expect_params, $params, 'addOr() called on an existing column creates a combined criterion'); } + /** + * @return void + */ public function testAddOrDistinctColumns() { - $table1 = "myTable1"; - $column1 = "myColumn1"; - $value1 = "myValue1"; + $table1 = 'myTable1'; + $column1 = 'myColumn1'; + $value1 = 'myValue1'; $key1 = "$table1.$column1"; - $table2 = "myTable2"; - $column2 = "myColumn2"; - $value2 = "myValue2"; + $table2 = 'myTable2'; + $column2 = 'myColumn2'; + $value2 = 'myValue2'; $key2 = "$table2.$column2"; $this->c->add($key1, $value1, Criteria::EQUAL); $this->c->addOr($key2, $value2, Criteria::EQUAL); - $expect = $this->getSql("SELECT FROM myTable1, myTable2 WHERE (myTable1.myColumn1=:p1 OR myTable2.myColumn2=:p2)"); + $expect = $this->getSql('SELECT FROM myTable1, myTable2 WHERE (myTable1.myColumn1=:p1 OR myTable2.myColumn2=:p2)'); $params = []; $result = $this->c->createSelectSql($params); @@ -242,16 +264,19 @@ public function testAddOrDistinctColumns() $this->assertEquals($expect_params, $params, 'addOr() called on a distinct column adds a criterion to the latest criterion'); } + /** + * @return void + */ public function testAddOrEmptyCriteria() { - $table1 = "myTable1"; - $column1 = "myColumn1"; - $value1 = "myValue1"; + $table1 = 'myTable1'; + $column1 = 'myColumn1'; + $value1 = 'myValue1'; $key1 = "$table1.$column1"; $this->c->addOr($key1, $value1, Criteria::EQUAL); - $expect = $this->getSql("SELECT FROM myTable1 WHERE myTable1.myColumn1=:p1"); + $expect = $this->getSql('SELECT FROM myTable1 WHERE myTable1.myColumn1=:p1'); $params = []; $result = $this->c->createSelectSql($params); @@ -268,32 +293,36 @@ public function testAddOrEmptyCriteria() * Test Criterion.setIgnoreCase(). * As the output is db specific the test just prints the result to * System.out + * + * @return void */ public function testCriterionIgnoreCase() { $originalDB = Propel::getServiceContainer()->getAdapter(); $adapters = [new MysqlAdapter(), new PgsqlAdapter()]; - $expectedIgnore = ["UPPER(TABLE.COLUMN) LIKE UPPER(:p1)", "TABLE.COLUMN ILIKE :p1"]; + $expectedIgnore = ['UPPER(TABLE.COLUMN) LIKE UPPER(:p1)', 'TABLE.COLUMN ILIKE :p1']; - $i =0; + $i = 0; foreach ($adapters as $adapter) { - Propel::getServiceContainer()->setAdapter(Propel::getServiceContainer()->getDefaultDatasource(), $adapter); $myCriteria = new Criteria(); $myCriterion = $myCriteria->getNewCriterion( - "TABLE.COLUMN", "FoObAr", Criteria::LIKE); - $sb = ""; - $params=[]; + 'TABLE.COLUMN', + 'FoObAr', + Criteria::LIKE + ); + $sb = ''; + $params = []; $myCriterion->appendPsTo($sb, $params); - $expected = "TABLE.COLUMN LIKE :p1"; + $expected = 'TABLE.COLUMN LIKE :p1'; $this->assertEquals($expected, $sb); $ignoreCriterion = $myCriterion->setIgnoreCase(true); - $sb = ""; - $params=[]; + $sb = ''; + $params = []; $ignoreCriterion->appendPsTo($sb, $params); // $expected = "UPPER(TABLE.COLUMN) LIKE UPPER(?)"; $this->assertEquals($expectedIgnore[$i], $sb); @@ -302,6 +331,9 @@ public function testCriterionIgnoreCase() Propel::getServiceContainer()->setAdapter(Propel::getServiceContainer()->getDefaultDatasource(), $originalDB); } + /** + * @return void + */ public function testOrderByIgnoreCase() { $originalDB = Propel::getServiceContainer()->getAdapter(); @@ -322,34 +354,41 @@ public function testOrderByIgnoreCase() /** * Test that true is evaluated correctly. + * + * @return void */ public function testBoolean() { $this->c = new Criteria(); - $this->c->add("TABLE.COLUMN", true); + $this->c->add('TABLE.COLUMN', true); - $expect = $this->getSql("SELECT FROM TABLE WHERE TABLE.COLUMN=:p1"); - $expect_params = [ ['table' => 'TABLE', 'column' => 'COLUMN', 'value' => true], + $expect = $this->getSql('SELECT FROM TABLE WHERE TABLE.COLUMN=:p1'); + $expect_params = [ [ + 'table' => 'TABLE', + 'column' => 'COLUMN', + 'value' => true], ]; try { $params = []; $result = $this->c->createSelectSql($params); } catch (PropelException $e) { - $this->fail("PropelException thrown in Criteria->createSelectSql(): ". $e->getMessage()); + $this->fail('PropelException thrown in Criteria->createSelectSql(): ' . $e->getMessage()); } - $this->assertEquals($expect, $result, "Boolean test failed."); + $this->assertEquals($expect, $result, 'Boolean test failed.'); $this->assertEquals($expect_params, $params); - } + /** + * @return void + */ public function testCurrentDate() { $this->c = new Criteria(); - $this->c->add("TABLE.TIME_COLUMN", Criteria::CURRENT_TIME); - $this->c->add("TABLE.DATE_COLUMN", Criteria::CURRENT_DATE); + $this->c->add('TABLE.TIME_COLUMN', Criteria::CURRENT_TIME); + $this->c->add('TABLE.DATE_COLUMN', Criteria::CURRENT_DATE); - $expect = $this->getSql("SELECT FROM TABLE WHERE TABLE.TIME_COLUMN=CURRENT_TIME AND TABLE.DATE_COLUMN=CURRENT_DATE"); + $expect = $this->getSql('SELECT FROM TABLE WHERE TABLE.TIME_COLUMN=CURRENT_TIME AND TABLE.DATE_COLUMN=CURRENT_DATE'); $result = null; try { @@ -357,21 +396,23 @@ public function testCurrentDate() $result = $this->c->createSelectSql($params); } catch (PropelException $e) { print $e->getTraceAsString(); - $this->fail("PropelException thrown in Criteria->createSelectSql(): ". $e->getMessage()); + $this->fail('PropelException thrown in Criteria->createSelectSql(): ' . $e->getMessage()); } - $this->assertEquals($expect, $result, "Current date test failed!"); - + $this->assertEquals($expect, $result, 'Current date test failed!'); } + /** + * @return void + */ public function testCountAster() { $this->c = new Criteria(); - $this->c->addSelectColumn("COUNT(*)"); - $this->c->add("TABLE.TIME_COLUMN", Criteria::CURRENT_TIME); - $this->c->add("TABLE.DATE_COLUMN", Criteria::CURRENT_DATE); + $this->c->addSelectColumn('COUNT(*)'); + $this->c->add('TABLE.TIME_COLUMN', Criteria::CURRENT_TIME); + $this->c->add('TABLE.DATE_COLUMN', Criteria::CURRENT_DATE); - $expect = $this->getSql("SELECT COUNT(*) FROM TABLE WHERE TABLE.TIME_COLUMN=CURRENT_TIME AND TABLE.DATE_COLUMN=CURRENT_DATE"); + $expect = $this->getSql('SELECT COUNT(*) FROM TABLE WHERE TABLE.TIME_COLUMN=CURRENT_TIME AND TABLE.DATE_COLUMN=CURRENT_DATE'); $result = null; try { @@ -379,91 +420,103 @@ public function testCountAster() $result = $this->c->createSelectSql($params); } catch (PropelException $e) { print $e->getTraceAsString(); - $this->fail("PropelException thrown in Criteria->createSelectSql(): ". $e->getMessage()); + $this->fail('PropelException thrown in Criteria->createSelectSql(): ' . $e->getMessage()); } $this->assertEquals($expect, $result); - } + /** + * @return void + */ public function testInOperator() { $c = new Criteria(); - $c->addSelectColumn("*"); - $c->add("TABLE.SOME_COLUMN", [], Criteria::IN); - $c->add("TABLE.OTHER_COLUMN", [1, 2, 3], Criteria::IN); + $c->addSelectColumn('*'); + $c->add('TABLE.SOME_COLUMN', [], Criteria::IN); + $c->add('TABLE.OTHER_COLUMN', [1, 2, 3], Criteria::IN); - $expect = $this->getSql("SELECT * FROM TABLE WHERE 1<>1 AND TABLE.OTHER_COLUMN IN (:p1,:p2,:p3)"); + $expect = $this->getSql('SELECT * FROM TABLE WHERE 1<>1 AND TABLE.OTHER_COLUMN IN (:p1,:p2,:p3)'); try { $params = []; $result = $c->createSelectSql($params); } catch (PropelException $e) { print $e->getTraceAsString(); - $this->fail("PropelException thrown in Criteria->createSelectSql(): ". $e->getMessage()); + $this->fail('PropelException thrown in Criteria->createSelectSql(): ' . $e->getMessage()); } $this->assertEquals($expect, $result); } + /** + * @return void + */ public function testInOperatorEmptyAfterFull() { $c = new Criteria(); - $c->addSelectColumn("*"); - $c->add("TABLE.OTHER_COLUMN", [1, 2, 3], Criteria::IN); - $c->add("TABLE.SOME_COLUMN", [], Criteria::IN); + $c->addSelectColumn('*'); + $c->add('TABLE.OTHER_COLUMN', [1, 2, 3], Criteria::IN); + $c->add('TABLE.SOME_COLUMN', [], Criteria::IN); - $expect = $this->getSql("SELECT * FROM TABLE WHERE TABLE.OTHER_COLUMN IN (:p1,:p2,:p3) AND 1<>1"); + $expect = $this->getSql('SELECT * FROM TABLE WHERE TABLE.OTHER_COLUMN IN (:p1,:p2,:p3) AND 1<>1'); try { $params = []; $result = $c->createSelectSql($params); } catch (PropelException $e) { print $e->getTraceAsString(); - $this->fail("PropelException thrown in Criteria->createSelectSql(): ". $e->getMessage()); + $this->fail('PropelException thrown in Criteria->createSelectSql(): ' . $e->getMessage()); } $this->assertEquals($expect, $result); } + /** + * @return void + */ public function testInOperatorNested() { // now do a nested logic test, just for sanity (not that this should be any surprise) $c = new Criteria(); - $c->addSelectColumn("*"); - $myCriterion = $c->getNewCriterion("TABLE.COLUMN", [], Criteria::IN); - $myCriterion->addOr($c->getNewCriterion("TABLE.COLUMN2", [1,2], Criteria::IN)); + $c->addSelectColumn('*'); + $myCriterion = $c->getNewCriterion('TABLE.COLUMN', [], Criteria::IN); + $myCriterion->addOr($c->getNewCriterion('TABLE.COLUMN2', [1, 2], Criteria::IN)); $c->add($myCriterion); - $expect = $this->getSql("SELECT * FROM TABLE WHERE (1<>1 OR TABLE.COLUMN2 IN (:p1,:p2))"); + $expect = $this->getSql('SELECT * FROM TABLE WHERE (1<>1 OR TABLE.COLUMN2 IN (:p1,:p2))'); try { $params = []; $result = $c->createSelectSql($params); } catch (PropelException $e) { print $e->getTraceAsString(); - $this->fail("PropelException thrown in Criteria->createSelectSql(): ". $e->getMessage()); + $this->fail('PropelException thrown in Criteria->createSelectSql(): ' . $e->getMessage()); } $this->assertEquals($expect, $result); - } /** * Test the Criteria::RAW behavior. + * + * @return void */ public function testRaw() { $c = new Criteria(); $c->addSelectColumn('A.COL'); $c->addAsColumn('foo', 'B.COL'); - $c->add('foo = ?', 123, \PDO::PARAM_STR); + $c->add('foo = ?', 123, PDO::PARAM_STR); $params = []; $result = $c->createSelectSql($params); - $expected = $this->getSql("SELECT A.COL, B.COL AS foo FROM A WHERE foo = :p1"); + $expected = $this->getSql('SELECT A.COL, B.COL AS foo FROM A WHERE foo = :p1'); $this->assertEquals($expected, $result); $expected = [ - ['table' => null, 'type' => \PDO::PARAM_STR, 'value' => 123] + ['table' => null, 'type' => PDO::PARAM_STR, 'value' => 123], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testJoinObject() { $j = new Join('TABLE_A.COL_1', 'TABLE_B.COL_2'); @@ -497,27 +550,33 @@ public function testJoinObject() $this->assertEquals('TABLE_B.COL_2', $j->getRightColumn(1)); } - public function testAddStraightJoin () + /** + * @return void + */ + public function testAddStraightJoin() { $c = new Criteria(); - $c->addSelectColumn("*"); + $c->addSelectColumn('*'); $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1'); // straight join - $expect = $this->getSql("SELECT * FROM TABLE_A INNER JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1)"); + $expect = $this->getSql('SELECT * FROM TABLE_A INNER JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1)'); try { $params = []; $result = $c->createSelectSql($params); } catch (PropelException $e) { print $e->getTraceAsString(); - $this->fail("PropelException thrown in Criteria->createSelectSql(): ". $e->getMessage()); + $this->fail('PropelException thrown in Criteria->createSelectSql(): ' . $e->getMessage()); } $this->assertEquals($expect, $result); } - public function testAddSeveralJoins () + /** + * @return void + */ + public function testAddSeveralJoins() { $c = new Criteria(); - $c->addSelectColumn("*"); + $c->addSelectColumn('*'); $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1'); $c->addJoin('TABLE_B.COL_X', 'TABLE_D.COL_X'); @@ -528,30 +587,36 @@ public function testAddSeveralJoins () $result = $c->createSelectSql($params); } catch (PropelException $e) { print $e->getTraceAsString(); - $this->fail("PropelException thrown in Criteria->createSelectSql(): ". $e->getMessage()); + $this->fail('PropelException thrown in Criteria->createSelectSql(): ' . $e->getMessage()); } $this->assertEquals($expect, $result); } - public function testAddLeftJoin () + /** + * @return void + */ + public function testAddLeftJoin() { $c = new Criteria(); - $c->addSelectColumn("TABLE_A.*"); - $c->addSelectColumn("TABLE_B.*"); + $c->addSelectColumn('TABLE_A.*'); + $c->addSelectColumn('TABLE_B.*'); $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_2', Criteria::LEFT_JOIN); - $expect = $this->getSql("SELECT TABLE_A.*, TABLE_B.* FROM TABLE_A LEFT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_2)"); + $expect = $this->getSql('SELECT TABLE_A.*, TABLE_B.* FROM TABLE_A LEFT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_2)'); try { $params = []; $result = $c->createSelectSql($params); } catch (PropelException $e) { print $e->getTraceAsString(); - $this->fail("PropelException thrown in Criteria->createSelectSql(): ". $e->getMessage()); + $this->fail('PropelException thrown in Criteria->createSelectSql(): ' . $e->getMessage()); } $this->assertEquals($expect, $result); } - public function testAddSeveralLeftJoins () + /** + * @return void + */ + public function testAddSeveralLeftJoins() { // Fails.. Suspect answer in the chunk starting at BaseTableMap:605 $c = new Criteria(); @@ -560,36 +625,42 @@ public function testAddSeveralLeftJoins () $c->addJoin('TABLE_A.COL_2', 'TABLE_C.COL_2', Criteria::LEFT_JOIN); $expect = $this->getSql('SELECT * FROM TABLE_A ' - .'LEFT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1) ' - .'LEFT JOIN TABLE_C ON (TABLE_A.COL_2=TABLE_C.COL_2)'); + . 'LEFT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1) ' + . 'LEFT JOIN TABLE_C ON (TABLE_A.COL_2=TABLE_C.COL_2)'); try { $params = []; $result = $c->createSelectSql($params); } catch (PropelException $e) { print $e->getTraceAsString(); - $this->fail("PropelException thrown in Criteria->createSelectSql(): ". $e->getMessage()); + $this->fail('PropelException thrown in Criteria->createSelectSql(): ' . $e->getMessage()); } $this->assertEquals($expect, $result); } - public function testAddRightJoin () + /** + * @return void + */ + public function testAddRightJoin() { $c = new Criteria(); - $c->addSelectColumn("*"); + $c->addSelectColumn('*'); $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_2', Criteria::RIGHT_JOIN); - $expect = $this->getSql("SELECT * FROM TABLE_A RIGHT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_2)"); + $expect = $this->getSql('SELECT * FROM TABLE_A RIGHT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_2)'); try { $params = []; $result = $c->createSelectSql($params); } catch (PropelException $e) { print $e->getTraceAsString(); - $this->fail("PropelException thrown in Criteria->createSelectSql(): ". $e->getMessage()); + $this->fail('PropelException thrown in Criteria->createSelectSql(): ' . $e->getMessage()); } $this->assertEquals($expect, $result); } - public function testAddSeveralRightJoins () + /** + * @return void + */ + public function testAddSeveralRightJoins() { // Fails.. Suspect answer in the chunk starting at BaseTableMap:605 $c = new Criteria(); @@ -598,66 +669,74 @@ public function testAddSeveralRightJoins () $c->addJoin('TABLE_A.COL_2', 'TABLE_C.COL_2', Criteria::RIGHT_JOIN); $expect = $this->getSql('SELECT * FROM TABLE_A ' - .'RIGHT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1) ' - .'RIGHT JOIN TABLE_C ON (TABLE_A.COL_2=TABLE_C.COL_2)'); + . 'RIGHT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1) ' + . 'RIGHT JOIN TABLE_C ON (TABLE_A.COL_2=TABLE_C.COL_2)'); try { $params = []; $result = $c->createSelectSql($params); } catch (PropelException $e) { print $e->getTraceAsString(); - $this->fail("PropelException thrown in Criteria->createSelectSql(): ". $e->getMessage()); + $this->fail('PropelException thrown in Criteria->createSelectSql(): ' . $e->getMessage()); } $this->assertEquals($expect, $result); } - public function testAddInnerJoin () + /** + * @return void + */ + public function testAddInnerJoin() { $c = new Criteria(); - $c->addSelectColumn("*"); + $c->addSelectColumn('*'); $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::INNER_JOIN); - $expect = $this->getSql("SELECT * FROM TABLE_A INNER JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1)"); + $expect = $this->getSql('SELECT * FROM TABLE_A INNER JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1)'); try { $params = []; $result = $c->createSelectSql($params); } catch (PropelException $e) { print $e->getTraceAsString(); - $this->fail("PropelException thrown in Criteria->createSelectSql(): ". $e->getMessage()); + $this->fail('PropelException thrown in Criteria->createSelectSql(): ' . $e->getMessage()); } $this->assertEquals($expect, $result); } - public function testAddSeveralInnerJoin () + /** + * @return void + */ + public function testAddSeveralInnerJoin() { $c = new Criteria(); - $c->addSelectColumn("*"); + $c->addSelectColumn('*'); $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::INNER_JOIN); $c->addJoin('TABLE_B.COL_1', 'TABLE_C.COL_1', Criteria::INNER_JOIN); $expect = $this->getSql('SELECT * FROM TABLE_A ' - .'INNER JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1) ' - .'INNER JOIN TABLE_C ON (TABLE_B.COL_1=TABLE_C.COL_1)'); + . 'INNER JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1) ' + . 'INNER JOIN TABLE_C ON (TABLE_B.COL_1=TABLE_C.COL_1)'); try { $params = []; $result = $c->createSelectSql($params); } catch (PropelException $e) { print $e->getTraceAsString(); - $this->fail("PropelException thrown in Criteria->createSelectSql(): ". $e->getMessage()); + $this->fail('PropelException thrown in Criteria->createSelectSql(): ' . $e->getMessage()); } $this->assertEquals($expect, $result); } /** - * @link http://www.propelorm.org/ticket/451 - * @link http://www.propelorm.org/ticket/283#comment:8 + * @link http://www.propelorm.org/ticket/451 + * @link http://www.propelorm.org/ticket/283#comment:8 + * + * @return void */ public function testSeveralMixedJoinOrders() { $c = new Criteria(); $c->clearSelectColumns()-> - addJoin("TABLE_A.FOO_ID", "TABLE_B.id", Criteria::LEFT_JOIN)-> - addJoin("TABLE_A.BAR_ID", "TABLE_C.id")-> - addSelectColumn("TABLE_A.id"); + addJoin('TABLE_A.FOO_ID', 'TABLE_B.id', Criteria::LEFT_JOIN)-> + addJoin('TABLE_A.BAR_ID', 'TABLE_C.id')-> + addSelectColumn('TABLE_A.id'); $expect = $this->getSql('SELECT TABLE_A.id FROM TABLE_A LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID=TABLE_B.id) INNER JOIN TABLE_C ON (TABLE_A.BAR_ID=TABLE_C.id)'); $params = []; @@ -666,14 +745,16 @@ public function testSeveralMixedJoinOrders() } /** - * @link http://propel.phpdb.org/trac/ticket/606 + * @link http://propel.phpdb.org/trac/ticket/606 + * + * @return void */ public function testAddJoinArray() { $c = new Criteria(); $c->clearSelectColumns()-> addJoin(['TABLE_A.FOO_ID'], ['TABLE_B.id'], Criteria::LEFT_JOIN)-> - addSelectColumn("TABLE_A.id"); + addSelectColumn('TABLE_A.id'); $expect = $this->getSql('SELECT TABLE_A.id FROM TABLE_A LEFT JOIN TABLE_B ON TABLE_A.FOO_ID=TABLE_B.id'); $params = []; @@ -682,7 +763,9 @@ public function testAddJoinArray() } /** - * @link http://propel.phpdb.org/trac/ticket/606 + * @link http://propel.phpdb.org/trac/ticket/606 + * + * @return void */ public function testAddJoinArrayMultiple() { @@ -691,8 +774,9 @@ public function testAddJoinArrayMultiple() addJoin( ['TABLE_A.FOO_ID', 'TABLE_A.BAR'], ['TABLE_B.id', 'TABLE_B.BAZ'], - Criteria::LEFT_JOIN)-> - addSelectColumn("TABLE_A.id"); + Criteria::LEFT_JOIN + )-> + addSelectColumn('TABLE_A.id'); $expect = $this->getSql('SELECT TABLE_A.id FROM TABLE_A LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID=TABLE_B.id AND TABLE_A.BAR=TABLE_B.BAZ)'); $params = []; @@ -703,7 +787,9 @@ public function testAddJoinArrayMultiple() /** * Test the Criteria::addJoinMultiple() method with an implicit join * - * @link http://propel.phpdb.org/trac/ticket/606 + * @link http://propel.phpdb.org/trac/ticket/606 + * + * @return void */ public function testAddJoinMultiple() { @@ -713,7 +799,7 @@ public function testAddJoinMultiple() addMultipleJoin([ ['TABLE_A.FOO_ID', 'TABLE_B.id'], ['TABLE_A.BAR', 'TABLE_B.BAZ']])-> - addSelectColumn("TABLE_A.id"); + addSelectColumn('TABLE_A.id'); $expect = $this->getSql('SELECT TABLE_A.id FROM TABLE_A INNER JOIN TABLE_B ' . 'ON (TABLE_A.FOO_ID=TABLE_B.id AND TABLE_A.BAR=TABLE_B.BAZ)'); @@ -725,7 +811,9 @@ public function testAddJoinMultiple() /** * Test the Criteria::addJoinMultiple() method with a value as second argument * - * @link http://propel.phpdb.org/trac/ticket/606 + * @link http://propel.phpdb.org/trac/ticket/606 + * + * @return void */ public function testAddJoinMultipleValue() { @@ -735,7 +823,7 @@ public function testAddJoinMultipleValue() addMultipleJoin([ ['TABLE_A.FOO_ID', 'TABLE_B.id'], ['TABLE_A.BAR', 3]])-> - addSelectColumn("TABLE_A.id"); + addSelectColumn('TABLE_A.id'); $expect = $this->getSql('SELECT TABLE_A.id FROM TABLE_A INNER JOIN TABLE_B ' . 'ON (TABLE_A.FOO_ID=TABLE_B.id AND TABLE_A.BAR=3)'); @@ -747,18 +835,22 @@ public function testAddJoinMultipleValue() /** * Test the Criteria::addJoinMultiple() method with a joinType * - * @link http://propel.phpdb.org/trac/ticket/606 + * @link http://propel.phpdb.org/trac/ticket/606 + * + * @return void */ public function testAddJoinMultipleWithJoinType() { $c = new Criteria(); $c-> clearSelectColumns()-> - addMultipleJoin([ + addMultipleJoin( + [ ['TABLE_A.FOO_ID', 'TABLE_B.id'], ['TABLE_A.BAR', 'TABLE_B.BAZ']], - Criteria::LEFT_JOIN)-> - addSelectColumn("TABLE_A.id"); + Criteria::LEFT_JOIN + )-> + addSelectColumn('TABLE_A.id'); $expect = $this->getSql('SELECT TABLE_A.id FROM TABLE_A ' . 'LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID=TABLE_B.id AND TABLE_A.BAR=TABLE_B.BAZ)'); @@ -770,7 +862,9 @@ public function testAddJoinMultipleWithJoinType() /** * Test the Criteria::addJoinMultiple() method with operator * - * @link http://propel.phpdb.org/trac/ticket/606 + * @link http://propel.phpdb.org/trac/ticket/606 + * + * @return void */ public function testAddJoinMultipleWithOperator() { @@ -780,7 +874,7 @@ public function testAddJoinMultipleWithOperator() addMultipleJoin([ ['TABLE_A.FOO_ID', 'TABLE_B.id', Criteria::GREATER_EQUAL], ['TABLE_A.BAR', 'TABLE_B.BAZ', Criteria::LESS_THAN]])-> - addSelectColumn("TABLE_A.id"); + addSelectColumn('TABLE_A.id'); $expect = $this->getSql('SELECT TABLE_A.id FROM TABLE_A INNER JOIN TABLE_B ' . 'ON (TABLE_A.FOO_ID>=TABLE_B.id AND TABLE_A.BAR clearSelectColumns()-> - addMultipleJoin([ + addMultipleJoin( + [ ['TABLE_A.FOO_ID', 'TABLE_B.id', Criteria::GREATER_EQUAL], ['TABLE_A.BAR', 'TABLE_B.BAZ', Criteria::LESS_THAN]], - Criteria::LEFT_JOIN)-> - addSelectColumn("TABLE_A.id"); + Criteria::LEFT_JOIN + )-> + addSelectColumn('TABLE_A.id'); $expect = $this->getSql('SELECT TABLE_A.id FROM TABLE_A ' . 'LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID>=TABLE_B.id AND TABLE_A.BARaddJoin("tbl.COL1", "tbl.COL2", Criteria::LEFT_JOIN); - $c->addJoin("tbl.COL1", "tbl.COL2", Criteria::LEFT_JOIN); - $this->assertEquals(1, count($c->getJoins()), "Expected not to have duplicate LJOIN added."); - - $c->addJoin("tbl.COL1", "tbl.COL2", Criteria::RIGHT_JOIN); - $c->addJoin("tbl.COL1", "tbl.COL2", Criteria::RIGHT_JOIN); - $this->assertEquals(2, count($c->getJoins()), "Expected 1 new right join to be added."); + $c->addJoin('tbl.COL1', 'tbl.COL2', Criteria::LEFT_JOIN); + $c->addJoin('tbl.COL1', 'tbl.COL2', Criteria::LEFT_JOIN); + $this->assertEquals(1, count($c->getJoins()), 'Expected not to have duplicate LJOIN added.'); - $c->addJoin("tbl.COL1", "tbl.COL2"); - $c->addJoin("tbl.COL1", "tbl.COL2"); - $this->assertEquals(3, count($c->getJoins()), "Expected 1 new implicit join to be added."); + $c->addJoin('tbl.COL1', 'tbl.COL2', Criteria::RIGHT_JOIN); + $c->addJoin('tbl.COL1', 'tbl.COL2', Criteria::RIGHT_JOIN); + $this->assertEquals(2, count($c->getJoins()), 'Expected 1 new right join to be added.'); - $c->addJoin("tbl.COL3", "tbl.COL4"); - $this->assertEquals(4, count($c->getJoins()), "Expected new col join to be added."); + $c->addJoin('tbl.COL1', 'tbl.COL2'); + $c->addJoin('tbl.COL1', 'tbl.COL2'); + $this->assertEquals(3, count($c->getJoins()), 'Expected 1 new implicit join to be added.'); + $c->addJoin('tbl.COL3', 'tbl.COL4'); + $this->assertEquals(4, count($c->getJoins()), 'Expected new col join to be added.'); } /** - * @link http://propel.phpdb.org/trac/ticket/634 + * @link http://propel.phpdb.org/trac/ticket/634 + * + * @return void */ public function testHasSelectClause() { $c = new Criteria(); - $c->addSelectColumn("foo"); + $c->addSelectColumn('foo'); $this->assertTrue($c->hasSelectClause()); $c = new Criteria(); - $c->addAsColumn("foo", "bar"); + $c->addAsColumn('foo', 'bar'); $this->assertTrue($c->hasSelectClause()); } /** * Tests including aliases in criterion objects. - * @link http://propel.phpdb.org/trac/ticket/636 + * + * @link http://propel.phpdb.org/trac/ticket/636 + * + * @return void */ public function testAliasInCriterion() { $c = new Criteria(); - $c->addAsColumn("column_alias", "tbl.COL1"); - $crit = $c->getNewCriterion("column_alias", "FOO"); + $c->addAsColumn('column_alias', 'tbl.COL1'); + $crit = $c->getNewCriterion('column_alias', 'FOO'); $this->assertNull($crit->getTable()); - $this->assertEquals("column_alias", $crit->getColumn()); + $this->assertEquals('column_alias', $crit->getColumn()); } /** * @group mysql + * + * @return void */ public function testHavingAlias() { @@ -900,6 +1009,9 @@ public function testHavingAlias() $this->assertEquals($expected, $this->con->getLastExecutedQuery()); } + /** + * @return void + */ public function testHaving() { $c = new Criteria(); @@ -920,13 +1032,15 @@ public function testHaving() /** * @group mysql + * + * @return void */ public function testHavingAliasRaw() { $c = new Criteria(); $c->addSelectColumn(BookTableMap::COL_TITLE); - $c->addAsColumn("isb_n", BookTableMap::COL_ISBN); - $c->addHaving('isb_n = ?', '1234567890123', \PDO::PARAM_STR); + $c->addAsColumn('isb_n', BookTableMap::COL_ISBN); + $c->addHaving('isb_n = ?', '1234567890123', PDO::PARAM_STR); $expected = $this->getSql('SELECT book.title, book.isbn AS isb_n FROM book HAVING isb_n = :p1'); $params = []; $result = $c->createSelectSql($params); @@ -938,7 +1052,10 @@ public function testHavingAliasRaw() /** * Test whether GROUP BY is being respected in equals() check. - * @link http://propel.phpdb.org/trac/ticket/674 + * + * @link http://propel.phpdb.org/trac/ticket/674 + * + * @return void */ public function testEqualsGroupBy() { @@ -948,18 +1065,21 @@ public function testEqualsGroupBy() $c2 = new Criteria(); $c2->addGroupByColumn('GBY2'); - $this->assertFalse($c2->equals($c1), "Expected Criteria NOT to be the same with different GROUP BY columns"); + $this->assertFalse($c2->equals($c1), 'Expected Criteria NOT to be the same with different GROUP BY columns'); $c3 = new Criteria(); $c3->addGroupByColumn('GBY1'); $c4 = new Criteria(); $c4->addGroupByColumn('GBY1'); - $this->assertTrue($c4->equals($c3), "Expected Criteria objects to match."); + $this->assertTrue($c4->equals($c3), 'Expected Criteria objects to match.'); } /** * Test whether calling setDistinct twice puts in two distinct keywords or not. - * @link http://propel.phpdb.org/trac/ticket/716 + * + * @link http://propel.phpdb.org/trac/ticket/716 + * + * @return void */ public function testDoubleSelectModifiers() { @@ -980,6 +1100,9 @@ public function testDoubleSelectModifiers() $this->assertEquals([Criteria::ALL], $c2->getSelectModifiers(), 'Initial setAll works'); } + /** + * @return void + */ public function testAddSelectModifier() { $c = new Criteria(); @@ -993,6 +1116,9 @@ public function testAddSelectModifier() $this->assertEquals('SELECT DISTINCT SQL_CALC_FOUND_ROWS FROM ', $result, 'addSelectModifier() adds a modifier to the final query'); } + /** + * @return void + */ public function testClone() { $c1 = new Criteria(); @@ -1008,6 +1134,9 @@ public function testClone() $this->assertEquals(1, $nbCrit, 'cloning a Criteria clones its Criterions'); } + /** + * @return void + */ public function testComment() { $c = new Criteria(); @@ -1019,6 +1148,9 @@ public function testComment() $this->assertNull($c->getComment(), 'Comment is reset by setComment(null)'); } + /** + * @return void + */ public function testClear() { $c = new CriteriaForClearTest(); @@ -1064,6 +1196,9 @@ public function testClear() $this->assertFalse($c->getUseTransaction(), 'useTransaction is false by default'); } + /** + * @return void + */ public function testDefaultLimit() { $c = new Criteria(); @@ -1072,6 +1207,8 @@ public function testDefaultLimit() /** * @dataProvider dataLimit + * + * @return void */ public function testLimit($limit, $expected) { @@ -1084,63 +1221,66 @@ public function testLimit($limit, $expected) public function dataLimit() { - return array( - 'Negative value' => array( - 'limit' => -1, - 'expected' => -1 - ), - 'Zero' => array( - 'limit' => 0, - 'expected' => 0 - ), - - 'Small integer' => array( - 'limit' => 38427, - 'expected' => 38427 - ), - 'Small integer as a string' => array( - 'limit' => '38427', - 'expected' => 38427 - ), - - 'Largest 32-bit integer' => array( - 'limit' => 2147483647, - 'expected' => 2147483647 - ), - 'Largest 32-bit integer as a string' => array( - 'limit' => '2147483647', - 'expected' => 2147483647 - ), - - 'Largest 64-bit integer' => array( - 'limit' => 9223372036854775807, - 'expected' => 9223372036854775807 - ), - 'Largest 64-bit integer as a string' => array( - 'limit' => '9223372036854775807', - 'expected' => 9223372036854775807 - ), - - 'Decimal value' => array( - 'limit' => 123.9, - 'expected' => 123 - ), - 'Decimal value as a string' => array( - 'limit' => '123.9', - 'expected' => 123 - ), - - 'Non-numeric string' => array( - 'limit' => 'foo', - 'expected' => 0 - ), - 'Injected SQL' => array( - 'limit' => '3;DROP TABLE abc', - 'expected' => 3 - ), - ); + return [ + 'Negative value' => [ + 'limit' => -1, + 'expected' => -1, + ], + 'Zero' => [ + 'limit' => 0, + 'expected' => 0, + ], + + 'Small integer' => [ + 'limit' => 38427, + 'expected' => 38427, + ], + 'Small integer as a string' => [ + 'limit' => '38427', + 'expected' => 38427, + ], + + 'Largest 32-bit integer' => [ + 'limit' => 2147483647, + 'expected' => 2147483647, + ], + 'Largest 32-bit integer as a string' => [ + 'limit' => '2147483647', + 'expected' => 2147483647, + ], + + 'Largest 64-bit integer' => [ + 'limit' => 9223372036854775807, + 'expected' => 9223372036854775807, + ], + 'Largest 64-bit integer as a string' => [ + 'limit' => '9223372036854775807', + 'expected' => 9223372036854775807, + ], + + 'Decimal value' => [ + 'limit' => 123.9, + 'expected' => 123, + ], + 'Decimal value as a string' => [ + 'limit' => '123.9', + 'expected' => 123, + ], + + 'Non-numeric string' => [ + 'limit' => 'foo', + 'expected' => 0, + ], + 'Injected SQL' => [ + 'limit' => '3;DROP TABLE abc', + 'expected' => 3, + ], + ]; } + /** + * @return void + */ public function testDefaultOffset() { $c = new Criteria(); @@ -1149,6 +1289,8 @@ public function testDefaultOffset() /** * @dataProvider dataOffset + * + * @return void */ public function testOffset($offset, $expected) { @@ -1161,67 +1303,70 @@ public function testOffset($offset, $expected) public function dataOffset() { - return array( - 'Negative value' => array( - 'offset' => -1, - 'expected' => -1 - ), - 'Zero' => array( - 'offset' => 0, - 'expected' => 0 - ), - - 'Small integer' => array( - 'offset' => 38427, - 'expected' => 38427 - ), - 'Small integer as a string' => array( - 'offset' => '38427', - 'expected' => 38427 - ), - - 'Largest 32-bit integer' => array( - 'offset' => 2147483647, - 'expected' => 2147483647 - ), - 'Largest 32-bit integer as a string' => array( - 'offset' => '2147483647', - 'expected' => 2147483647 - ), - - 'Largest 64-bit integer' => array( - 'offset' => 9223372036854775807, - 'expected' => 9223372036854775807 - ), - 'Largest 64-bit integer as a string' => array( - 'offset' => '9223372036854775807', - 'expected' => 9223372036854775807 - ), - - 'Decimal value' => array( - 'offset' => 123.9, - 'expected' => 123 - ), - 'Decimal value as a string' => array( - 'offset' => '123.9', - 'expected' => 123 - ), - - 'Non-numeric string' => array( - 'offset' => 'foo', - 'expected' => 0 - ), - 'Injected SQL' => array( - 'offset' => '3;DROP TABLE abc', - 'expected' => 3 - ), - ); + return [ + 'Negative value' => [ + 'offset' => -1, + 'expected' => -1, + ], + 'Zero' => [ + 'offset' => 0, + 'expected' => 0, + ], + + 'Small integer' => [ + 'offset' => 38427, + 'expected' => 38427, + ], + 'Small integer as a string' => [ + 'offset' => '38427', + 'expected' => 38427, + ], + + 'Largest 32-bit integer' => [ + 'offset' => 2147483647, + 'expected' => 2147483647, + ], + 'Largest 32-bit integer as a string' => [ + 'offset' => '2147483647', + 'expected' => 2147483647, + ], + + 'Largest 64-bit integer' => [ + 'offset' => 9223372036854775807, + 'expected' => 9223372036854775807, + ], + 'Largest 64-bit integer as a string' => [ + 'offset' => '9223372036854775807', + 'expected' => 9223372036854775807, + ], + + 'Decimal value' => [ + 'offset' => 123.9, + 'expected' => 123, + ], + 'Decimal value as a string' => [ + 'offset' => '123.9', + 'expected' => 123, + ], + + 'Non-numeric string' => [ + 'offset' => 'foo', + 'expected' => 0, + ], + 'Injected SQL' => [ + 'offset' => '3;DROP TABLE abc', + 'expected' => 3, + ], + ]; } + /** + * @return void + */ public function testCombineAndFilterBy() { $params = []; - $sql = $this->getSql("SELECT FROM book WHERE ((book.title LIKE :p1 OR book.isbn LIKE :p2) AND book.title LIKE :p3)"); + $sql = $this->getSql('SELECT FROM book WHERE ((book.title LIKE :p1 OR book.isbn LIKE :p2) AND book.title LIKE :p3)'); $c = BookQuery::create() ->condition('u1', 'book.title LIKE ?', '%test1%') ->condition('u2', 'book.isbn LIKE ?', '%test2%') @@ -1231,7 +1376,7 @@ public function testCombineAndFilterBy() $this->assertEquals($sql, $result); $params = []; - $sql = $this->getSql("SELECT FROM book WHERE (book.title LIKE :p1 AND (book.title LIKE :p2 OR book.isbn LIKE :p3))"); + $sql = $this->getSql('SELECT FROM book WHERE (book.title LIKE :p1 AND (book.title LIKE :p2 OR book.isbn LIKE :p3))'); $c = BookQuery::create() ->filterByTitle('%test3%', Criteria::LIKE) ->condition('u1', 'book.title LIKE ?', '%test1%') @@ -1241,6 +1386,9 @@ public function testCombineAndFilterBy() $this->assertEquals($sql, $result); } + /** + * @return void + */ public function testGroupBy() { $params = []; @@ -1251,7 +1399,7 @@ public function testGroupBy() $result = $c->createSelectSql($params); - if ($this->runningOnPostgreSQL()){ + if ($this->runningOnPostgreSQL()) { $sql = 'SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, COUNT(review.id) AS Count FROM book LEFT JOIN review ON (book.id=review.book_id) GROUP BY book.id,book.title,book.isbn,book.price,book.publisher_id,book.author_id'; } else { $sql = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, COUNT(review.id) AS Count FROM book LEFT JOIN review ON (book.id=review.book_id) GROUP BY book.id'); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicCriterionTest.php index 0bc744d8e4..159662bcee 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicCriterionTest.php @@ -10,11 +10,10 @@ namespace Propel\Tests\Runtime\ActiveQuery\Criterion; -use Propel\Tests\Helpers\BaseTestCase; - use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criterion\BasicCriterion; use Propel\Runtime\Adapter\Pdo\SqliteAdapter; +use Propel\Tests\Helpers\BaseTestCase; /** * Test class for BasicCriterion. @@ -23,7 +22,9 @@ */ class BasicCriterionTest extends BaseTestCase { - + /** + * @return void + */ public function testAppendPsToCreatesAnEqualConditionByDefault() { $cton = new BasicCriterion(new Criteria(), 'A.COL', 'foo'); @@ -34,11 +35,14 @@ public function testAppendPsToCreatesAnEqualConditionByDefault() $this->assertEquals('A.COL=:p1', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToAcceptsAComparisonType() { $cton = new BasicCriterion(new Criteria(), 'A.COL', 'foo', Criteria::GREATER_THAN); @@ -49,11 +53,14 @@ public function testAppendPsToAcceptsAComparisonType() $this->assertEquals('A.COL>:p1', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToCreatesACaseInsensitiveComparisonIfSpecified() { $cton = new BasicCriterion(new Criteria(), 'A.COL', 'foo'); @@ -66,7 +73,7 @@ public function testAppendPsToCreatesACaseInsensitiveComparisonIfSpecified() $this->assertEquals('UPPER(A.COL)=UPPER(:p1)', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo'], ]; $this->assertEquals($expected, $params); } @@ -76,12 +83,14 @@ public static function supportedANSIFunctions() return [ [Criteria::CURRENT_DATE], [Criteria::CURRENT_TIME], - [Criteria::CURRENT_TIMESTAMP] + [Criteria::CURRENT_TIMESTAMP], ]; } /** * @dataProvider supportedANSIFunctions + * + * @return void */ public function testAppendPsToAcceptsAnANSIDateFunctionForValue($ansiFunction) { @@ -95,6 +104,9 @@ public function testAppendPsToAcceptsAnANSIDateFunctionForValue($ansiFunction) $this->assertEquals([], $params); } + /** + * @return void + */ public function testAppendPsCanHandleEqualToNull() { $cton = new BasicCriterion(new Criteria(), 'A.COL', null); @@ -107,6 +119,9 @@ public function testAppendPsCanHandleEqualToNull() $this->assertEquals([], $params); } + /** + * @return void + */ public function testAppendPsCanHandleNotEqualToNull() { $cton = new BasicCriterion(new Criteria(), 'A.COL', null, Criteria::NOT_EQUAL); @@ -121,6 +136,8 @@ public function testAppendPsCanHandleNotEqualToNull() /** * @expectedException Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException + * + * @return void */ public function testAppendPsThrowsExceptionWhenValueIsNullAndComparisonIsComplex() { @@ -129,7 +146,5 @@ public function testAppendPsThrowsExceptionWhenValueIsNullAndComparisonIsComplex $params = []; $ps = ''; $cton->appendPsTo($ps, $params); - } - } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicModelCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicModelCriterionTest.php index 2c8fee5c67..5019dd01af 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicModelCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicModelCriterionTest.php @@ -10,10 +10,9 @@ namespace Propel\Tests\Runtime\ActiveQuery\Criterion; -use Propel\Tests\Helpers\BaseTestCase; - use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criterion\BasicModelCriterion; +use Propel\Tests\Helpers\BaseTestCase; /** * Test class for BasicModelCriterion. @@ -22,6 +21,9 @@ */ class BasicModelCriterionTest extends BaseTestCase { + /** + * @return void + */ public function testAppendPsToAddsBindingInfoForNotNullValues() { $cton = new BasicModelCriterion(new Criteria(), 'A.COL = ?', 'A.COL', 'foo'); @@ -32,13 +34,15 @@ public function testAppendPsToAddsBindingInfoForNotNullValues() $this->assertEquals('A.COL = :p1', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo'], ]; $this->assertEquals($expected, $params); } /** * @expectedException Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException + * + * @return void */ public function testAppendPsToThrowsExceptionWhenBindingAValueToAClauseWithNoQuestionMark() { @@ -49,6 +53,9 @@ public function testAppendPsToThrowsExceptionWhenBindingAValueToAClauseWithNoQue $cton->appendPsTo($ps, $params); } + /** + * @return void + */ public function testAppendPsToAddsClauseWithoutBindingForNullValues() { $cton = new BasicModelCriterion(new Criteria(), 'A.COL IS NULL', 'A.COL', null); @@ -60,5 +67,4 @@ public function testAppendPsToAddsClauseWithoutBindingForNullValues() $this->assertEquals('A.COL IS NULL', $ps); $this->assertEquals([], $params); } - } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/CustomCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/CustomCriterionTest.php index efb22c902d..c5fb2ac145 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/CustomCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/CustomCriterionTest.php @@ -10,10 +10,9 @@ namespace Propel\Tests\Runtime\ActiveQuery\Criterion; -use Propel\Tests\Helpers\BaseTestCase; - use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criterion\CustomCriterion; +use Propel\Tests\Helpers\BaseTestCase; /** * Test class for CustomCriterion. @@ -22,6 +21,9 @@ */ class CustomCriterionTest extends BaseTestCase { + /** + * @return void + */ public function testAppendPsToConcatenatesTheValue() { $cton = new CustomCriterion(new Criteria(), 'date_part(\'YYYY\', A.COL) = \'2007\''); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/InCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/InCriterionTest.php index d10d3f0f2c..ebb3785845 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/InCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/InCriterionTest.php @@ -10,11 +10,10 @@ namespace Propel\Tests\Runtime\ActiveQuery\Criterion; -use Propel\Runtime\Collection\ArrayCollection; -use Propel\Tests\Helpers\BaseTestCase; - use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criterion\InCriterion; +use Propel\Runtime\Collection\ArrayCollection; +use Propel\Tests\Helpers\BaseTestCase; /** * Test class for InCriterion. @@ -23,7 +22,9 @@ */ class InCriterionTest extends BaseTestCase { - + /** + * @return void + */ public function testAppendPsToCreatesAnInConditionByDefault() { $cton = new InCriterion(new Criteria(), 'A.COL', ['foo']); @@ -34,11 +35,14 @@ public function testAppendPsToCreatesAnInConditionByDefault() $this->assertEquals('A.COL IN (:p1)', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToCreatesANotInConditionWhenSpecified() { $cton = new InCriterion(new Criteria(), 'A.COL', ['foo'], Criteria::NOT_IN); @@ -49,11 +53,14 @@ public function testAppendPsToCreatesANotInConditionWhenSpecified() $this->assertEquals('A.COL NOT IN (:p1)', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToCreatesAnInConditionUsingAColumnAlias() { $cton = new InCriterion(new Criteria(), 'my_alias', ['foo']); @@ -64,11 +71,14 @@ public function testAppendPsToCreatesAnInConditionUsingAColumnAlias() $this->assertEquals('my_alias IN (:p1)', $ps); $expected = [ - ['table' => null, 'column' => 'my_alias', 'value' => 'foo'] + ['table' => null, 'column' => 'my_alias', 'value' => 'foo'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToCreatesAnInConditionUsingATableAlias() { $c = new Criteria(); @@ -81,11 +91,14 @@ public function testAppendPsToCreatesAnInConditionUsingATableAlias() $this->assertEquals('bar_alias.COL IN (:p1)', $ps); $expected = [ - ['table' => 'bar', 'column' => 'COL', 'value' => 'foo'] + ['table' => 'bar', 'column' => 'COL', 'value' => 'foo'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToWithArrayValueCreatesAnInCondition() { $cton = new InCriterion(new Criteria(), 'A.COL', ['foo', 'bar']); @@ -97,11 +110,14 @@ public function testAppendPsToWithArrayValueCreatesAnInCondition() $this->assertEquals('A.COL IN (:p1,:p2)', $ps); $expected = [ ['table' => 'A', 'column' => 'COL', 'value' => 'foo'], - ['table' => 'A', 'column' => 'COL', 'value' => 'bar'] + ['table' => 'A', 'column' => 'COL', 'value' => 'bar'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToWithScalarValueCreatesAnInCondition() { $cton = new InCriterion(new Criteria(), 'A.COL', 'foo'); @@ -112,7 +128,7 @@ public function testAppendPsToWithScalarValueCreatesAnInCondition() $this->assertEquals('A.COL IN (:p1)', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo'], ]; $this->assertEquals($expected, $params); } @@ -123,12 +139,14 @@ public static function providerForNotEmptyValues() [''], [0], [true], - [false] + [false], ]; } /** * @dataProvider providerForNotEmptyValues + * + * @return void */ public function testAppendPsToWithNotEmptyValueCreatesAnInCondition($notEmptyValue) { @@ -140,7 +158,7 @@ public function testAppendPsToWithNotEmptyValueCreatesAnInCondition($notEmptyVal $this->assertEquals('A.COL IN (:p1)', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => $notEmptyValue] + ['table' => 'A', 'column' => 'COL', 'value' => $notEmptyValue], ]; $this->assertEquals($expected, $params); } @@ -149,12 +167,14 @@ public static function providerForEmptyValues() { return [ [[]], - [null] + [null], ]; } /** * @dataProvider providerForEmptyValues + * + * @return void */ public function testAppendPsToWithInAndEmptyValueCreatesAnAlwaysFalseCondition($emptyValue) { @@ -170,8 +190,10 @@ public function testAppendPsToWithInAndEmptyValueCreatesAnAlwaysFalseCondition($ } /** - * @dataProvider providerForEmptyValues - */ + * @dataProvider providerForEmptyValues + * + * @return void + */ public function testAppendPsToWithNotInAndEmptyValueCreatesAnAlwaysTrueCondition($emptyValue) { $cton = new InCriterion(new Criteria(), 'A.COL', $emptyValue, Criteria::NOT_IN); @@ -185,6 +207,9 @@ public function testAppendPsToWithNotInAndEmptyValueCreatesAnAlwaysTrueCondition $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToWithArrayCollection() { $collection = new ArrayCollection(['foo']); @@ -196,9 +221,8 @@ public function testAppendPsToWithArrayCollection() $this->assertEquals('A.COL IN (:p1)', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo'], ]; $this->assertEquals($expected, $params); } - } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/InModelCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/InModelCriterionTest.php index 8a559e8565..53b7669e59 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/InModelCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/InModelCriterionTest.php @@ -10,11 +10,10 @@ namespace Propel\Tests\Runtime\ActiveQuery\Criterion; -use Propel\Runtime\Collection\ArrayCollection; -use Propel\Tests\Helpers\BaseTestCase; - use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criterion\InModelCriterion; +use Propel\Runtime\Collection\ArrayCollection; +use Propel\Tests\Helpers\BaseTestCase; /** * Test class for InModelCriterion. @@ -23,6 +22,9 @@ */ class InModelCriterionTest extends BaseTestCase { + /** + * @return void + */ public function testAppendPsToCreatesAnInConditionByDefault() { $cton = new InModelCriterion(new Criteria(), 'A.COL IN ?', 'A.COL', ['foo']); @@ -33,11 +35,14 @@ public function testAppendPsToCreatesAnInConditionByDefault() $this->assertEquals('A.COL IN (:p1)', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToCreatesANotInConditionWhenSpecified() { $cton = new InModelCriterion(new Criteria(), 'A.COL NOT IN ?', 'A.COL', ['foo']); @@ -48,11 +53,14 @@ public function testAppendPsToCreatesANotInConditionWhenSpecified() $this->assertEquals('A.COL NOT IN (:p1)', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToWithArrayValueCreatesAnInCondition() { $cton = new InModelCriterion(new Criteria(), 'A.COL IN ?', 'A.COL', ['foo', 'bar']); @@ -64,11 +72,14 @@ public function testAppendPsToWithArrayValueCreatesAnInCondition() $this->assertEquals('A.COL IN (:p1,:p2)', $ps); $expected = [ ['table' => 'A', 'column' => 'COL', 'value' => 'foo'], - ['table' => 'A', 'column' => 'COL', 'value' => 'bar'] + ['table' => 'A', 'column' => 'COL', 'value' => 'bar'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToWithScalarValueCreatesAnInCondition() { $cton = new InModelCriterion(new Criteria(), 'A.COL IN ?', 'A.COL', 'foo'); @@ -79,7 +90,7 @@ public function testAppendPsToWithScalarValueCreatesAnInCondition() $this->assertEquals('A.COL IN (:p1)', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo'], ]; $this->assertEquals($expected, $params); } @@ -90,12 +101,14 @@ public static function providerForNotEmptyValues() [''], [0], [true], - [false] + [false], ]; } /** * @dataProvider providerForNotEmptyValues + * + * @return void */ public function testAppendPsToWithNotEmptyValueCreatesAnInCondition($notEmptyValue) { @@ -107,7 +120,7 @@ public function testAppendPsToWithNotEmptyValueCreatesAnInCondition($notEmptyVal $this->assertEquals('A.COL IN (:p1)', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => $notEmptyValue] + ['table' => 'A', 'column' => 'COL', 'value' => $notEmptyValue], ]; $this->assertEquals($expected, $params); } @@ -116,12 +129,14 @@ public static function providerForEmptyValues() { return [ [[]], - [null] + [null], ]; } /** * @dataProvider providerForEmptyValues + * + * @return void */ public function testAppendPsToWithInAndEmptyValueCreatesAnAlwaysFalseCondition($emptyValue) { @@ -137,8 +152,10 @@ public function testAppendPsToWithInAndEmptyValueCreatesAnAlwaysFalseCondition($ } /** - * @dataProvider providerForEmptyValues - */ + * @dataProvider providerForEmptyValues + * + * @return void + */ public function testAppendPsToWithNotInAndEmptyValueCreatesAnAlwaysTrueCondition($emptyValue) { $cton = new InModelCriterion(new Criteria(), 'A.COL NOT IN ?', 'A.COL', $emptyValue); @@ -153,8 +170,10 @@ public function testAppendPsToWithNotInAndEmptyValueCreatesAnAlwaysTrueCondition } /** - * @dataProvider providerForEmptyValues - */ + * @dataProvider providerForEmptyValues + * + * @return void + */ public function testAppendPsToWithNotInAndEmptyValueIsCaseInsensitive($emptyValue) { $cton = new InModelCriterion(new Criteria(), 'A.COL not in ?', 'A.COL', $emptyValue); @@ -168,6 +187,9 @@ public function testAppendPsToWithNotInAndEmptyValueIsCaseInsensitive($emptyValu $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToWithArrayCollection() { $collection = new ArrayCollection(['foo']); @@ -179,9 +201,8 @@ public function testAppendPsToWithArrayCollection() $this->assertEquals('A.COL IN (:p1)', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo'], ]; $this->assertEquals($expected, $params); } - } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeCriterionTest.php index d8afc78c26..ec68f8e49f 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeCriterionTest.php @@ -10,12 +10,11 @@ namespace Propel\Tests\Runtime\ActiveQuery\Criterion; -use Propel\Tests\Helpers\BaseTestCase; - use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criterion\LikeCriterion; use Propel\Runtime\Adapter\Pdo\PgsqlAdapter; use Propel\Runtime\Adapter\Pdo\SqliteAdapter; +use Propel\Tests\Helpers\BaseTestCase; /** * Test class for LikeCriterion. @@ -24,6 +23,9 @@ */ class LikeCriterionTest extends BaseTestCase { + /** + * @return void + */ public function testAppendPsToCreatesALikeConditionByDefault() { $cton = new LikeCriterion(new Criteria(), 'A.COL', 'foo%', Criteria::LIKE); @@ -34,11 +36,14 @@ public function testAppendPsToCreatesALikeConditionByDefault() $this->assertEquals('A.COL LIKE :p1', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToCreatesANotLikeConditionIfSpecified() { $cton = new LikeCriterion(new Criteria(), 'A.COL', 'foo%', Criteria::NOT_LIKE); @@ -49,11 +54,14 @@ public function testAppendPsToCreatesANotLikeConditionIfSpecified() $this->assertEquals('A.COL NOT LIKE :p1', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToCreatesACaseInsensitiveLikeConditionIfSpecified() { $cton = new LikeCriterion(new Criteria(), 'A.COL', 'foo%', Criteria::LIKE); @@ -65,11 +73,14 @@ public function testAppendPsToCreatesACaseInsensitiveLikeConditionIfSpecified() $this->assertEquals('UPPER(A.COL) LIKE UPPER(:p1)', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToCreatesACaseInsensitiveNotLikeConditionIfSpecified() { $cton = new LikeCriterion(new Criteria(), 'A.COL', 'foo%', Criteria::NOT_LIKE); @@ -81,11 +92,14 @@ public function testAppendPsToCreatesACaseInsensitiveNotLikeConditionIfSpecified $this->assertEquals('UPPER(A.COL) NOT LIKE UPPER(:p1)', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToBehavesTheSameOnPostgreSQLByDefault() { $cton = new LikeCriterion(new Criteria(), 'A.COL', 'foo%', Criteria::LIKE); @@ -96,11 +110,14 @@ public function testAppendPsToBehavesTheSameOnPostgreSQLByDefault() $this->assertEquals('A.COL LIKE :p1', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToWithCaseInsensitiveAndPostgreSQLUsesILIKE() { $cton = new LikeCriterion(new Criteria(), 'A.COL', 'foo%', Criteria::LIKE); @@ -112,11 +129,14 @@ public function testAppendPsToWithCaseInsensitiveAndPostgreSQLUsesILIKE() $this->assertEquals('A.COL ILIKE :p1', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToWithCaseInsensitiveAndPostgreSQLUsesNOTILIKE() { $cton = new LikeCriterion(new Criteria(), 'A.COL', 'foo%', Criteria::NOT_LIKE); @@ -128,9 +148,8 @@ public function testAppendPsToWithCaseInsensitiveAndPostgreSQLUsesNOTILIKE() $this->assertEquals('A.COL NOT ILIKE :p1', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'], ]; $this->assertEquals($expected, $params); } - } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeModelCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeModelCriterionTest.php index 3c893adde4..a087f46c35 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeModelCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeModelCriterionTest.php @@ -10,12 +10,11 @@ namespace Propel\Tests\Runtime\ActiveQuery\Criterion; -use Propel\Tests\Helpers\BaseTestCase; - use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criterion\LikeModelCriterion; use Propel\Runtime\Adapter\Pdo\PgsqlAdapter; use Propel\Runtime\Adapter\Pdo\SqliteAdapter; +use Propel\Tests\Helpers\BaseTestCase; /** * Test class for LikeModelCriterion. @@ -24,6 +23,9 @@ */ class LikeModelCriterionTest extends BaseTestCase { + /** + * @return void + */ public function testAppendPsToCreatesALikeConditionByDefault() { $cton = new LikeModelCriterion(new Criteria(), 'A.COL LIKE ?', 'A.COL', 'foo%'); @@ -34,11 +36,14 @@ public function testAppendPsToCreatesALikeConditionByDefault() $this->assertEquals('A.COL LIKE :p1', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToCreatesANotLikeConditionIfSpecified() { $cton = new LikeModelCriterion(new Criteria(), 'A.COL NOT LIKE ?', 'A.COL', 'foo%'); @@ -49,13 +54,15 @@ public function testAppendPsToCreatesANotLikeConditionIfSpecified() $this->assertEquals('A.COL NOT LIKE :p1', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'], ]; $this->assertEquals($expected, $params); } /** * @expectedException Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException + * + * @return void */ public function testAppendPsToWithACaseInsensitiveLikeConditionThrowsAnException() { @@ -67,6 +74,9 @@ public function testAppendPsToWithACaseInsensitiveLikeConditionThrowsAnException $cton->appendPsTo($ps, $params); } + /** + * @return void + */ public function testAppendPsToCreatesACaseInsensitiveLikeConditionIfSpecifiedOnPgSQL() { $cton = new LikeModelCriterion(new Criteria(), 'A.COL LIKE ?', 'A.COL', 'foo%'); @@ -78,11 +88,14 @@ public function testAppendPsToCreatesACaseInsensitiveLikeConditionIfSpecifiedOnP $this->assertEquals('A.COL ILIKE :p1', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToWithCaseInsensitiveAndPostgreSQLUsesNOTILIKE() { $cton = new LikeModelCriterion(new Criteria(), 'A.COL NOT LIKE ?', 'A.COL', 'foo%'); @@ -94,7 +107,7 @@ public function testAppendPsToWithCaseInsensitiveAndPostgreSQLUsesNOTILIKE() $this->assertEquals('A.COL NOT ILIKE :p1', $ps); $expected = [ - ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'] + ['table' => 'A', 'column' => 'COL', 'value' => 'foo%'], ]; $this->assertEquals($expected, $params); } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawCriterionTest.php index 7ee59c896b..69e5fe56da 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawCriterionTest.php @@ -10,12 +10,10 @@ namespace Propel\Tests\Runtime\ActiveQuery\Criterion; -use Propel\Tests\Helpers\BaseTestCase; - +use PDO; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criterion\RawCriterion; - -use \PDO; +use Propel\Tests\Helpers\BaseTestCase; /** * Test class for RawCriterion. @@ -26,6 +24,8 @@ class RawCriterionTest extends BaseTestCase { /** * @expectedException Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException + * + * @return void */ public function testAppendPsToThrowsExceptionWhenClauseHasNoQuestionMark() { @@ -36,6 +36,9 @@ public function testAppendPsToThrowsExceptionWhenClauseHasNoQuestionMark() $cton->appendPsTo($ps, $params); } + /** + * @return void + */ public function testAppendPsToCreatesAPDOClauseyDefault() { $cton = new RawCriterion(new Criteria(), 'A.COL = ?', 1, PDO::PARAM_INT); @@ -46,11 +49,14 @@ public function testAppendPsToCreatesAPDOClauseyDefault() $this->assertEquals('A.COL = :p1', $ps); $expected = [ - ['table' => null, 'value' => 1, 'type' => PDO::PARAM_INT] + ['table' => null, 'value' => 1, 'type' => PDO::PARAM_INT], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToUsesParamStrByDefault() { $cton = new RawCriterion(new Criteria(), 'A.COL = ?', 1); @@ -61,9 +67,8 @@ public function testAppendPsToUsesParamStrByDefault() $this->assertEquals('A.COL = :p1', $ps); $expected = [ - ['table' => null, 'value' => 1, 'type' => PDO::PARAM_STR] + ['table' => null, 'value' => 1, 'type' => PDO::PARAM_STR], ]; $this->assertEquals($expected, $params); } - } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawModelCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawModelCriterionTest.php index f136fcfa2a..9896877862 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawModelCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawModelCriterionTest.php @@ -10,12 +10,10 @@ namespace Propel\Tests\Runtime\ActiveQuery\Criterion; -use Propel\Tests\Helpers\BaseTestCase; - +use PDO; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criterion\RawModelCriterion; - -use \PDO; +use Propel\Tests\Helpers\BaseTestCase; /** * Test class for RawModelCriterion. @@ -26,6 +24,8 @@ class RawModelCriterionTest extends BaseTestCase { /** * @expectedException Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException + * + * @return void */ public function testAppendPsToThrowsExceptionWhenClauseHasNoQuestionMark() { @@ -36,6 +36,9 @@ public function testAppendPsToThrowsExceptionWhenClauseHasNoQuestionMark() $cton->appendPsTo($ps, $params); } + /** + * @return void + */ public function testAppendPsToCreatesAPDOClauseByDefault() { $cton = new RawModelCriterion(new Criteria(), 'A.COL = ?', 'A.COL', 1, null, PDO::PARAM_INT); @@ -46,11 +49,14 @@ public function testAppendPsToCreatesAPDOClauseByDefault() $this->assertEquals('A.COL = :p1', $ps); $expected = [ - ['table' => null, 'value' => 1, 'type' => PDO::PARAM_INT] + ['table' => null, 'value' => 1, 'type' => PDO::PARAM_INT], ]; $this->assertEquals($expected, $params); } + /** + * @return void + */ public function testAppendPsToUsesParamStrByDefault() { $cton = new RawModelCriterion(new Criteria(), 'A.COL = ?', 'A.COL', 1); @@ -61,9 +67,8 @@ public function testAppendPsToUsesParamStrByDefault() $this->assertEquals('A.COL = :p1', $ps); $expected = [ - ['table' => null, 'value' => 1, 'type' => PDO::PARAM_STR] + ['table' => null, 'value' => 1, 'type' => PDO::PARAM_STR], ]; $this->assertEquals($expected, $params); } - } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/SeveralModelCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/SeveralModelCriterionTest.php index 01d50941b3..c9ad9f99eb 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/SeveralModelCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/SeveralModelCriterionTest.php @@ -10,10 +10,9 @@ namespace Propel\Tests\Runtime\ActiveQuery\Criterion; -use Propel\Tests\Helpers\BaseTestCase; - use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criterion\SeveralModelCriterion; +use Propel\Tests\Helpers\BaseTestCase; /** * Test class for SeveralModelCriterion. @@ -22,6 +21,9 @@ */ class SeveralModelCriterionTest extends BaseTestCase { + /** + * @return void + */ public function testAppendPsToAddsBindingInfoForNotNullValues() { $cton = new SeveralModelCriterion(new Criteria(), 'A.COL BETWEEN ? AND ?', 'A.COL', ['foo', 'bar']); @@ -33,13 +35,15 @@ public function testAppendPsToAddsBindingInfoForNotNullValues() $this->assertEquals('A.COL BETWEEN :p1 AND :p2', $ps); $expected = [ ['table' => 'A', 'column' => 'COL', 'value' => 'foo'], - ['table' => 'A', 'column' => 'COL', 'value' => 'bar'] + ['table' => 'A', 'column' => 'COL', 'value' => 'bar'], ]; $this->assertEquals($expected, $params); } /** * @expectedException Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException + * + * @return void */ public function testAppendPsToThrowsExceptionWhenOneOfTheValuesIsNull() { @@ -52,6 +56,8 @@ public function testAppendPsToThrowsExceptionWhenOneOfTheValuesIsNull() /** * @expectedException Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException + * + * @return void */ public function testAppendPsToThrowsExceptionWhenTheValueIsNull() { @@ -61,5 +67,4 @@ public function testAppendPsToThrowsExceptionWhenTheValueIsNull() $ps = ''; $cton->appendPsTo($ps, $params); } - } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/JoinTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/JoinTest.php index 0132a9f846..a848d4d886 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/JoinTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/JoinTest.php @@ -10,18 +10,17 @@ namespace Propel\Tests\Runtime\ActiveQuery; -use Propel\Tests\Helpers\BaseTestCase; - -use Propel\Runtime\Propel; -use Propel\Runtime\Adapter\Pdo\SqliteAdapter; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Join; +use Propel\Runtime\Adapter\Pdo\SqliteAdapter; +use Propel\Runtime\Propel; +use Propel\Tests\Helpers\BaseTestCase; /** * Test class for Join. * * @author François Zaninotto - * @version $Id$ + * @version $Id$ */ class JoinTest extends BaseTestCase { @@ -32,6 +31,9 @@ class JoinTest extends BaseTestCase */ private $savedAdapter; + /** + * @return void + */ protected function setUp(): void { Propel::init(dirname(__FILE__) . '/../../../../Fixtures/bookstore/build/conf/bookstore-conf.php'); @@ -41,18 +43,27 @@ protected function setUp(): void Propel::getServiceContainer()->setAdapter(null, new SqliteAdapter()); } + /** + * @return void + */ protected function tearDown(): void { Propel::getServiceContainer()->setAdapter(null, $this->savedAdapter); parent::tearDown(); } + /** + * @return void + */ public function testEmptyConditions() { $j = new Join(); $this->assertEquals([], $j->getConditions()); } + /** + * @return void + */ public function testAddCondition() { $j = new Join(); @@ -62,6 +73,9 @@ public function testAddCondition() $this->assertEquals('bar', $j->getRightColumn()); } + /** + * @return void + */ public function testGetConditions() { $j = new Join(); @@ -70,6 +84,9 @@ public function testGetConditions() $this->assertEquals($expect, $j->getConditions()); } + /** + * @return void + */ public function testAddConditionWithOperator() { $j = new Join(); @@ -78,6 +95,9 @@ public function testAddConditionWithOperator() $this->assertEquals($expect, $j->getConditions()); } + /** + * @return void + */ public function testAddConditions() { $j = new Join(); @@ -85,7 +105,7 @@ public function testAddConditions() $j->addCondition('baz', 'bal'); $expect = [ ['left' => 'foo', 'operator' => '=', 'right' => 'bar'], - ['left' => 'baz', 'operator' => '=', 'right' => 'bal'] + ['left' => 'baz', 'operator' => '=', 'right' => 'bal'], ]; $this->assertEquals(['=', '='], $j->getOperators()); $this->assertEquals(['foo', 'baz'], $j->getLeftColumns()); @@ -93,6 +113,9 @@ public function testAddConditions() $this->assertEquals($expect, $j->getConditions()); } + /** + * @return void + */ public function testAddExplicitConditionWithoutAlias() { $j = new Join(); @@ -107,6 +130,9 @@ public function testAddExplicitConditionWithoutAlias() $this->assertEquals(1, $j->countConditions()); } + /** + * @return void + */ public function testAddExplicitconditionWithOneAlias() { $j = new Join(); @@ -117,6 +143,10 @@ public function testAddExplicitconditionWithOneAlias() } //used in polymorphic relation + + /** + * @return void + */ public function testConditionalJoin() { $j = new Join(); @@ -127,6 +157,9 @@ public function testConditionalJoin() $this->assertEquals('LEFT JOIN author a ON (log.AUTHOR_ID=a.ID AND log.target_type=\'author\')', $j->getClause($params)); } + /** + * @return void + */ public function testAddExplicitConditionWithAlias() { $j = new Join(); @@ -140,6 +173,9 @@ public function testAddExplicitConditionWithAlias() $this->assertEquals('Blias', $j->getRightTableAlias()); } + /** + * @return void + */ public function testAddExplicitConditionWithOperator() { $j = new Join(); @@ -149,12 +185,18 @@ public function testAddExplicitConditionWithOperator() $this->assertEquals('b.bar', $j->getRightColumn()); } + /** + * @return void + */ public function testEmptyJoinType() { $j = new Join(); $this->assertEquals(Join::INNER_JOIN, $j->getJoinType()); } + /** + * @return void + */ public function testSetJoinType() { $j = new Join(); @@ -162,6 +204,9 @@ public function testSetJoinType() $this->assertEquals('foo', $j->getJoinType()); } + /** + * @return void + */ public function testSimpleConstructor() { $j = new Join('foo', 'bar', 'LEFT JOIN'); @@ -170,17 +215,23 @@ public function testSimpleConstructor() $this->assertEquals('LEFT JOIN', $j->getJoinType()); } + /** + * @return void + */ public function testCompositeConstructor() { $j = new Join(['foo1', 'foo2'], ['bar1', 'bar2'], 'LEFT JOIN'); $expect = [ ['left' => 'foo1', 'operator' => '=', 'right' => 'bar1'], - ['left' => 'foo2', 'operator' => '=', 'right' => 'bar2'] + ['left' => 'foo2', 'operator' => '=', 'right' => 'bar2'], ]; $this->assertEquals($expect, $j->getConditions()); $this->assertEquals('LEFT JOIN', $j->getJoinType()); } + /** + * @return void + */ public function testCountConditions() { $j = new Join(); @@ -191,6 +242,9 @@ public function testCountConditions() $this->assertEquals(2, $j->countConditions()); } + /** + * @return void + */ public function testEquality() { $j1 = new Join('foo', 'bar', 'INNER JOIN'); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaGroupByArrayTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaGroupByArrayTest.php index 029ba01903..5e917ee2ee 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaGroupByArrayTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaGroupByArrayTest.php @@ -10,10 +10,10 @@ namespace Propel\Tests\Runtime\ActiveQuery; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; -use Propel\Tests\Bookstore\Book; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\AuthorQuery; +use Propel\Tests\Bookstore\Book; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * @group database @@ -22,60 +22,66 @@ class ModelCriteriaGroupByArrayTest extends BookstoreEmptyTestBase { /** * @dataProvider dataForTestException + * * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testGroupByArrayThrowException($groupBy) { $authors = AuthorQuery::create() ->leftJoinBook() - ->select(array('FirstName', 'LastName')) + ->select(['FirstName', 'LastName']) ->withColumn('COUNT(Book.Id)', 'nbBooks') ->groupBy($groupBy) ->orderByLastName() ->find(); } + /** + * @return void + */ public function testGroupByArray() { $stephenson = new Author(); - $stephenson->setFirstName("Neal"); - $stephenson->setLastName("Stephenson"); + $stephenson->setFirstName('Neal'); + $stephenson->setLastName('Stephenson'); $stephenson->save(); $byron = new Author(); - $byron->setFirstName("George"); - $byron->setLastName("Byron"); + $byron->setFirstName('George'); + $byron->setLastName('Byron'); $byron->save(); $phoenix = new Book(); - $phoenix->setTitle("Harry Potter and the Order of the Phoenix"); - $phoenix->setISBN("043935806X"); + $phoenix->setTitle('Harry Potter and the Order of the Phoenix'); + $phoenix->setISBN('043935806X'); $phoenix->setAuthor($stephenson); $phoenix->save(); $qs = new Book(); - $qs->setISBN("0380977427"); - $qs->setTitle("Quicksilver"); + $qs->setISBN('0380977427'); + $qs->setTitle('Quicksilver'); $qs->setAuthor($stephenson); $qs->save(); $dj = new Book(); - $dj->setISBN("0140422161"); - $dj->setTitle("Don Juan"); + $dj->setISBN('0140422161'); + $dj->setTitle('Don Juan'); $dj->setAuthor($stephenson); $dj->save(); $td = new Book(); - $td->setISBN("067972575X"); - $td->setTitle("The Tin Drum"); + $td->setISBN('067972575X'); + $td->setTitle('The Tin Drum'); $td->setAuthor($byron); $td->save(); $authors = AuthorQuery::create() ->leftJoinBook() - ->select(array('FirstName', 'LastName')) + ->select(['FirstName', 'LastName']) ->withColumn('COUNT(Book.Id)', 'nbBooks') - ->groupBy(array('FirstName', 'LastName')) + ->groupBy(['FirstName', 'LastName']) ->orderByLastName() ->find(); @@ -94,10 +100,10 @@ public function testGroupByArray() public function dataForTestException() { - return array( - 'empty string' => array(''), - 'null' => array(null), - 'array' => array(array()) - ); + return [ + 'empty string' => [''], + 'null' => [null], + 'array' => [[]], + ]; } -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaHooksTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaHooksTest.php index d72d0b24e2..0c0c6ea53d 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaHooksTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaHooksTest.php @@ -10,11 +10,10 @@ namespace Propel\Tests\Runtime\ActiveQuery; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; -use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; - use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Connection\ConnectionInterface; +use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Test class for ModelCriteria. @@ -25,6 +24,9 @@ */ class ModelCriteriaHooksTest extends BookstoreTestBase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -32,6 +34,9 @@ protected function setUp(): void BookstoreDataPopulator::populate(); } + /** + * @return void + */ public function testPreSelect() { $c = new ModelCriteriaWithPreSelectHook('bookstore', '\Propel\Tests\Bookstore\Book'); @@ -43,6 +48,9 @@ public function testPreSelect() $this->assertEquals(1, $nbBooks, 'preSelect() can modify the Criteria before count() fires the query'); } + /** + * @return void + */ public function testPreDelete() { $c = new ModelCriteria('bookstore', '\Propel\Tests\Bookstore\Book'); @@ -68,6 +76,9 @@ public function testPreDelete() $this->assertEquals($count, $nbBooks, 'preDelete() can bypass the row deletion'); } + /** + * @return void + */ public function testPostDelete() { $c = new ModelCriteria('bookstore', '\Propel\Tests\Bookstore\Book'); @@ -89,6 +100,9 @@ public function testPostDelete() $this->assertEquals(3, $this->con->lastAffectedRows, 'postDelete() is called after deleteAll()'); } + /** + * @return void + */ public function testPreAndPostDelete() { $c = new ModelCriteria('bookstore', '\Propel\Tests\Bookstore\Book'); @@ -110,6 +124,9 @@ public function testPreAndPostDelete() $this->assertEquals(12, $this->con->lastAffectedRows, 'postDelete() is called after deleteAll() even if preDelete() returns not null'); } + /** + * @return void + */ public function testPreUpdate() { $c = new ModelCriteriaWithPreUpdateHook('bookstore', '\Propel\Tests\Bookstore\Book', 'b'); @@ -123,6 +140,9 @@ public function testPreUpdate() $this->assertEquals('1234', $book->getISBN(), 'preUpdate() can modify the values'); } + /** + * @return void + */ public function testPostUpdate() { $this->con->lastAffectedRows = 0; @@ -133,6 +153,9 @@ public function testPostUpdate() $this->assertEquals(1, $this->con->lastAffectedRows, 'postUpdate() is called after update()'); } + /** + * @return void + */ public function testPreAndPostUpdate() { $this->con->lastAffectedRows = 0; @@ -146,6 +169,9 @@ public function testPreAndPostUpdate() class ModelCriteriaWithPreSelectHook extends ModelCriteria { + /** + * @return void + */ public function preSelect(ConnectionInterface $con) { $this->where($this->getModelAliasOrName() . '.Title = ?', 'Don Juan'); @@ -162,6 +188,9 @@ public function preDelete(ConnectionInterface $con) class ModelCriteriaWithPostDeleteHook extends ModelCriteria { + /** + * @return void + */ public function postDelete($affectedRows, ConnectionInterface $con) { $con->lastAffectedRows = $affectedRows; @@ -178,6 +207,9 @@ public function preDelete(ConnectionInterface $con) class ModelCriteriaWithPreUpdateHook extends ModelCriteria { + /** + * @return void + */ public function preUpdate(&$values, ConnectionInterface $con, $forceIndividualSaves = false) { $values['ISBN'] = '1234'; @@ -186,6 +218,9 @@ public function preUpdate(&$values, ConnectionInterface $con, $forceIndividualSa class ModelCriteriaWithPostUpdateHook extends ModelCriteria { + /** + * @return void + */ public function postUpdate($affectedRows, ConnectionInterface $con) { $con->lastAffectedRows = $affectedRows; diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaSelectTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaSelectTest.php index 2882f77736..e9a7a1ee66 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaSelectTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaSelectTest.php @@ -10,13 +10,13 @@ namespace Propel\Tests\Runtime\ActiveQuery; +use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Collection\Collection; -use Propel\Tests\Bookstore\Map\AuthorTableMap; +use Propel\Runtime\Formatter\OnDemandFormatter; use Propel\Tests\Bookstore\BookQuery; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; - -use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Test class for ModelCriteria select() method. @@ -29,6 +29,8 @@ class ModelCriteriaSelectTest extends BookstoreTestBase { /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testSelectThrowsExceptionWhenCalledWithAnEmptyString() { @@ -38,6 +40,8 @@ public function testSelectThrowsExceptionWhenCalledWithAnEmptyString() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testSelectThrowsExceptionWhenCalledWithAnEmptyArray() { @@ -45,6 +49,9 @@ public function testSelectThrowsExceptionWhenCalledWithAnEmptyArray() $c->select([]); } + /** + * @return void + */ public function testSelectStringNoResult() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -62,9 +69,12 @@ public function testSelectStringNoResult() $c->where('Propel\Tests\Bookstore\Book.title = ?', 'kdjfhlkdsh'); $c->select('Title'); $title = $c->findOne(); - $this->assertTrue(is_null($title), 'findOne() called after select(string) returns null when no record is found'); + $this->assertTrue($title === null, 'findOne() called after select(string) returns null when no record is found'); } + /** + * @return void + */ public function testSelectStringAcceptsColumnNames() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -86,6 +96,9 @@ public function testSelectStringAcceptsColumnNames() $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'select() accepts complete column names with table aliases'); } + /** + * @return void + */ public function testSelectStringFind() { BookstoreDataPopulator::depopulate($this->con); @@ -107,6 +120,9 @@ public function testSelectStringFind() $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'find() called after select(string) allows for where() statements'); } + /** + * @return void + */ public function testSelectStringFindOne() { BookstoreDataPopulator::depopulate($this->con); @@ -117,7 +133,7 @@ public function testSelectStringFindOne() $title = $c->findOne($this->con); $expectedSQL = $this->getSql('SELECT book.title AS "Title" FROM book LIMIT 1'); $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'findOne() called after select(string) selects a single column and requests a single row'); - $this->assertTrue(is_string($title),'findOne() called after select(string) returns a string'); + $this->assertTrue(is_string($title), 'findOne() called after select(string) returns a string'); $this->assertEquals($title, 'Harry Potter and the Order of the Phoenix', 'findOne() called after select(string) returns the column value of the first row matching the query'); $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author'); @@ -131,7 +147,7 @@ public function testSelectStringFindOne() $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author'); $c->select(AuthorTableMap::COL_FIRST_NAME); $author = $c->find($this->con); - $expectedSQL = $this->getSql("SELECT author.first_name AS \"author.first_name\" FROM author"); + $expectedSQL = $this->getSql('SELECT author.first_name AS "author.first_name" FROM author'); $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'select(string) accepts model TableMap Constants'); } @@ -140,6 +156,8 @@ public function testSelectStringFindOne() * So, we check the query fails here. * * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testSelectStringFindCalledWithNonExistingColumn() { @@ -151,6 +169,9 @@ public function testSelectStringFindCalledWithNonExistingColumn() $author = $c->find($this->con); } + /** + * @return void + */ public function testSelectStringJoin() { BookstoreDataPopulator::depopulate($this->con); @@ -189,6 +210,9 @@ public function testSelectStringJoin() $this->assertEquals($title, 'Neal', 'findOne() called after select(string) will return values from the joined table using complete column names'); } + /** + * @return void + */ public function testSelectStringWildcard() { BookstoreDataPopulator::depopulate($this->con); @@ -203,6 +227,9 @@ public function testSelectStringWildcard() $this->assertEquals(['Propel\Tests\Bookstore\Book.Id', 'Propel\Tests\Bookstore\Book.Title', 'Propel\Tests\Bookstore\Book.ISBN', 'Propel\Tests\Bookstore\Book.Price', 'Propel\Tests\Bookstore\Book.PublisherId', 'Propel\Tests\Bookstore\Book.AuthorId'], array_keys($book), 'select(\'*\') returns all the columns from the main object, in complete form'); } + /** + * @return void + */ public function testSelectArrayFind() { BookstoreDataPopulator::depopulate($this->con); @@ -223,6 +250,9 @@ public function testSelectArrayFind() $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'find() called after select(array) allows for where() statements'); } + /** + * @return void + */ public function testSelectArrayFindOne() { BookstoreDataPopulator::depopulate($this->con); @@ -237,6 +267,9 @@ public function testSelectArrayFindOne() $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'findOne() called after select(array) allows for where() statements'); } + /** + * @return void + */ public function testSelectArrayJoin() { BookstoreDataPopulator::depopulate($this->con); @@ -275,6 +308,9 @@ public function testSelectArrayJoin() $this->assertEquals(array_values($title), ['Neal', 'Stephenson'], 'findOne() called after select(array) will return values from the joined table using complete column names'); } + /** + * @return void + */ public function testSelectArrayRelation() { BookstoreDataPopulator::depopulate($this->con); @@ -333,11 +369,14 @@ public function testSelectArrayRelation() [ 'Author.LastName' => 'Grass', 'Book.title' => 'The Tin Drum', - ] + ], ]; $this->assertEquals(serialize($rows->getData()), serialize($expectedRows), 'find() called after select(array) returns columns from several tables (many-to-one'); } + /** + * @return void + */ public function testSelectArrayWithColumn() { BookstoreDataPopulator::depopulate($this->con); @@ -373,6 +412,9 @@ public function testSelectArrayWithColumn() $this->assertEquals(serialize($rows->getData()), serialize($expectedRows), 'find() called after select(array) can cope with a column added with withColumn()'); } + /** + * @return void + */ public function testSelectAllWithColumn() { BookstoreDataPopulator::depopulate($this->con); @@ -387,9 +429,11 @@ public function testSelectAllWithColumn() $expectedSQL = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, author.last_name AS authorLastName FROM book INNER JOIN author ON (book.author_id=author.id)'); $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'Rest of table after column added with withColumn() is not properly loaded'); - } + /** + * @return void + */ public function testSelectArrayPaginate() { BookstoreDataPopulator::depopulate($this->con); @@ -405,12 +449,18 @@ public function testSelectArrayPaginate() } } + /** + * @return void + */ public function testGetSelectReturnsNullByDefault() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $this->assertNull($c->getSelect()); } + /** + * @return void + */ public function testGetSelectReturnsStringWhenSelectingASingleColumn() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -418,6 +468,9 @@ public function testGetSelectReturnsStringWhenSelectingASingleColumn() $this->assertEquals('Title', $c->getSelect()); } + /** + * @return void + */ public function testGetSelectReturnsArrayWhenSelectingSeveralColumns() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -425,6 +478,9 @@ public function testGetSelectReturnsArrayWhenSelectingSeveralColumns() $this->assertEquals(['Id', 'Title'], $c->getSelect()); } + /** + * @return void + */ public function testGetSelectReturnsArrayWhenSelectingASingleColumnAsArray() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -432,6 +488,9 @@ public function testGetSelectReturnsArrayWhenSelectingASingleColumnAsArray() $this->assertEquals(['Title'], $c->getSelect()); } + /** + * @return void + */ public function testGetSelectReturnsArrayWhenSelectingAllColumns() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -442,10 +501,13 @@ public function testGetSelectReturnsArrayWhenSelectingAllColumns() 'Propel\Tests\Bookstore\Book.ISBN', 'Propel\Tests\Bookstore\Book.Price', 'Propel\Tests\Bookstore\Book.PublisherId', - 'Propel\Tests\Bookstore\Book.AuthorId' + 'Propel\Tests\Bookstore\Book.AuthorId', ], $c->getSelect()); } + /** + * @return void + */ public function testFormatterWithSelect() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -454,6 +516,6 @@ public function testFormatterWithSelect() $c->select(['Id', 'Title']); $rows = $c->find($this->con); - $this->assertTrue($c->getFormatter() instanceof \Propel\Runtime\Formatter\OnDemandFormatter, 'The formatter is preserved'); + $this->assertTrue($c->getFormatter() instanceof OnDemandFormatter, 'The formatter is preserved'); } } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php index aeccd1db78..5d360f0d28 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php @@ -10,36 +10,33 @@ namespace Propel\Tests\Runtime\ActiveQuery; -use Propel\Tests\Bookstore\BookstoreEmployeeQuery; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; -use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; - -use Propel\Tests\Bookstore\Author; +use PDO; +use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\ActiveQuery\Exception\UnknownColumnException; +use Propel\Runtime\ActiveQuery\Exception\UnknownRelationException; +use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\Collection\Collection; +use Propel\Runtime\Exception\EntityNotFoundException; +use Propel\Runtime\Exception\InvalidArgumentException; +use Propel\Runtime\Exception\PropelException; +use Propel\Runtime\Exception\UnexpectedValueException; +use Propel\Runtime\Formatter\AbstractFormatter; +use Propel\Runtime\Formatter\ArrayFormatter; +use Propel\Runtime\Formatter\StatementFormatter; +use Propel\Runtime\Propel; +use Propel\Runtime\Util\PropelModelPager; use Propel\Tests\Bookstore\AuthorQuery; use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\BookQuery; use Propel\Tests\Bookstore\Book2; use Propel\Tests\Bookstore\Book2Query; -use Propel\Tests\Bookstore\Publisher; +use Propel\Tests\Bookstore\BookQuery; +use Propel\Tests\Bookstore\BookstoreEmployeeQuery; use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\PublisherTableMap; use Propel\Tests\Bookstore\Map\ReviewTableMap; - -use Propel\Runtime\Propel; -use Propel\Runtime\Collection\Collection; -use Propel\Runtime\Exception\InvalidArgumentException; -use Propel\Runtime\Exception\PropelException; -use Propel\Runtime\Exception\UnexpectedValueException; -use Propel\Runtime\Formatter\AbstractFormatter; -use Propel\Runtime\Formatter\StatementFormatter; -use Propel\Runtime\Formatter\ArrayFormatter; -use Propel\Runtime\Map\TableMap; -use Propel\Runtime\Util\PropelModelPager; -use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\ActiveQuery\Exception\UnknownColumnException; -use Propel\Runtime\ActiveQuery\Exception\UnknownRelationException; -use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Test class for ModelCriteria. @@ -50,6 +47,9 @@ */ class ModelCriteriaTest extends BookstoreTestBase { + /** + * @return void + */ protected function assertCriteriaTranslation($criteria, $expectedSql, $expectedParams, $message = '') { $params = []; @@ -59,6 +59,9 @@ protected function assertCriteriaTranslation($criteria, $expectedSql, $expectedP $this->assertEquals($expectedParams, $params, $message); } + /** + * @return void + */ public function testGetModelName() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -68,6 +71,9 @@ public function testGetModelName() $this->assertEquals('Propel\Tests\Bookstore\Book', $c->getModelName(), 'getModelName() returns the name of the class associated to the model class'); } + /** + * @return void + */ public function testGetFullyQualifiedModelName() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -77,6 +83,9 @@ public function testGetFullyQualifiedModelName() $this->assertEquals('\Propel\Tests\Bookstore\Book', $c->getFullyQualifiedModelName(), 'getFullyQualifiedModelName() returns the name of the class associated to the model class'); } + /** + * @return void + */ public function testFormatter() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -104,7 +113,6 @@ public function testFormatter() } catch (InvalidArgumentException $e) { $this->assertTrue(true, 'setFormatter() throws an exception when passed an object not extending AbstractFormatter'); } - } public static function conditionsForTestReplaceNames() @@ -140,6 +148,8 @@ public static function conditionsForTestReplaceNames() /** * @dataProvider conditionsForTestReplaceNames + * + * @return void */ public function testReplaceNames($origClause, $columnPhpName, $modifiedClause) { @@ -147,6 +157,9 @@ public function testReplaceNames($origClause, $columnPhpName, $modifiedClause) $this->doTestReplaceNames($c, BookTableMap::getTableMap(), $origClause, $columnPhpName, $modifiedClause); } + /** + * @return void + */ public function doTestReplaceNames(Criteria $c, $tableMap, $origClause, $columnPhpName, $modifiedClause) { $c->replaceNames($origClause); @@ -169,6 +182,8 @@ public static function conditionsForTestReplaceMultipleNames() /** * @dataProvider conditionsForTestReplaceMultipleNames + * + * @return void */ public function testReplaceMultipleNames($origClause, $expectedColumns, $modifiedClause) { @@ -182,13 +197,16 @@ public function testReplaceMultipleNames($origClause, $expectedColumns, $modifie $this->assertEquals($modifiedClause, $origClause); } + /** + * @return void + */ public function testTableAlias() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $c->setModelAlias('b'); $c->where('b.Title = ?', 'foo'); - $sql = $this->getSql("SELECT FROM book WHERE book.title = :p1"); + $sql = $this->getSql('SELECT FROM book WHERE book.title = :p1'); $params = [ ['table' => 'book', 'column' => 'title', 'value' => 'foo'], ]; @@ -197,13 +215,16 @@ public function testTableAlias() $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); $c->where('b.Title = ?', 'foo'); - $sql = $this->getSql("SELECT FROM book WHERE book.title = :p1"); + $sql = $this->getSql('SELECT FROM book WHERE book.title = :p1'); $params = [ ['table' => 'book', 'column' => 'title', 'value' => 'foo'], ]; $this->assertCriteriaTranslation($c, $sql, $params, 'A ModelCriteria accepts a model name with an alias'); } + /** + * @return void + */ public function testTrueTableAlias() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -212,7 +233,7 @@ public function testTrueTableAlias() $c->join('b.Author a'); $c->where('a.FirstName = ?', 'john'); - $sql = $this->getSql("SELECT FROM book b INNER JOIN author a ON (b.author_id=a.id) WHERE b.title = :p1 AND a.first_name = :p2"); + $sql = $this->getSql('SELECT FROM book b INNER JOIN author a ON (b.author_id=a.id) WHERE b.title = :p1 AND a.first_name = :p2'); $params = [ ['table' => 'book', 'column' => 'title', 'value' => 'foo'], @@ -221,6 +242,9 @@ public function testTrueTableAlias() $this->assertCriteriaTranslation($c, $sql, $params, 'setModelAlias() allows the definition of a true SQL alias after construction'); } + /** + * @return void + */ public function testCondition() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -228,7 +252,7 @@ public function testCondition() $c->condition('cond2', 'Propel\Tests\Bookstore\Book.Title like ?', '%bar%'); $c->combine(['cond1', 'cond2'], 'or'); - $sql = $this->getSql("SELECT FROM book WHERE (book.title <> :p1 OR book.title like :p2)"); + $sql = $this->getSql('SELECT FROM book WHERE (book.title <> :p1 OR book.title like :p2)'); $params = [ ['table' => 'book', 'column' => 'title', 'value' => 'foo'], @@ -237,19 +261,22 @@ public function testCondition() $this->assertCriteriaTranslation($c, $sql, $params, 'condition() can store condition for later combination'); } + /** + * @return void + */ public function testConditionCustomOperator() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $c->withColumn('SUBSTRING(Book.Title, 1, 4)', 'title_start'); $c->condition('cond1', 'Book.Title <> ?', 'foo'); - $c->condition('cond2', 'title_start like ?', '%bar%', \PDO::PARAM_STR); + $c->condition('cond2', 'title_start like ?', '%bar%', PDO::PARAM_STR); $c->combine(['cond1', 'cond2'], 'or'); - $sql = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, SUBSTRING(book.title, 1, 4) AS title_start FROM book WHERE (book.title <> :p1 OR title_start like :p2)"); + $sql = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, SUBSTRING(book.title, 1, 4) AS title_start FROM book WHERE (book.title <> :p1 OR title_start like :p2)'); $params = [ ['table' => 'book', 'column' => 'title', 'value' => 'foo'], - ['table' => null, 'type' => \PDO::PARAM_STR, 'value' => '%bar%'], + ['table' => null, 'type' => PDO::PARAM_STR, 'value' => '%bar%'], ]; $this->assertCriteriaTranslation($c, $sql, $params, 'condition() accepts RAW sql parameters'); } @@ -273,6 +300,8 @@ public static function conditionsForTestWhere() /** * @dataProvider conditionsForTestWhere + * + * @return void */ public function testWhere($clause, $value, $sql, $params) { @@ -284,6 +313,9 @@ public function testWhere($clause, $value, $sql, $params) $this->assertCriteriaTranslation($c, $sql, $params, 'where() accepts a string clause'); } + /** + * @return void + */ public function testWhereUsesDefaultOperator() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -300,6 +332,9 @@ public function testWhereUsesDefaultOperator() $this->assertCriteriaTranslation($c, $sql, $params, 'where() uses the default operator'); } + /** + * @return void + */ public function testWhereTwiceSameColumn() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -317,6 +352,9 @@ public function testWhereTwiceSameColumn() $this->assertCriteriaTranslation($c, $sql, $params, 'where() adds clauses on the same column correctly'); } + /** + * @return void + */ public function testWhereConditions() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -324,7 +362,7 @@ public function testWhereConditions() $c->condition('cond2', 'Propel\Tests\Bookstore\Book.Title like ?', '%bar%'); $c->where(['cond1', 'cond2']); - $sql = $this->getSql("SELECT FROM book WHERE (book.title <> :p1 AND book.title like :p2)"); + $sql = $this->getSql('SELECT FROM book WHERE (book.title <> :p1 AND book.title like :p2)'); $params = [ ['table' => 'book', 'column' => 'title', 'value' => 'foo'], @@ -337,18 +375,21 @@ public function testWhereConditions() $c->condition('cond2', 'Propel\Tests\Bookstore\Book.Title like ?', '%bar%'); $c->where(['cond1', 'cond2'], Criteria::LOGICAL_OR); - $sql = $this->getSql("SELECT FROM book WHERE (book.title <> :p1 OR book.title like :p2)"); + $sql = $this->getSql('SELECT FROM book WHERE (book.title <> :p1 OR book.title like :p2)'); $this->assertCriteriaTranslation($c, $sql, $params, 'where() accepts an array of named conditions with operator'); } + /** + * @return void + */ public function testWhereNoReplacement() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); $c->where('b.Title = ?', 'foo'); $c->where('1=1'); - $sql = $this->getSql("SELECT FROM book WHERE book.title = :p1 AND 1=1"); + $sql = $this->getSql('SELECT FROM book WHERE book.title = :p1 AND 1=1'); $params = [ ['table' => 'book', 'column' => 'title', 'value' => 'foo'], @@ -364,12 +405,15 @@ public function testWhereNoReplacement() } } + /** + * @return void + */ public function testWhereFunction() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); $c->where('UPPER(b.Title) = ?', 'foo'); - $sql = $this->getSql("SELECT FROM book WHERE UPPER(book.title) = :p1"); + $sql = $this->getSql('SELECT FROM book WHERE UPPER(book.title) = :p1'); $params = [ ['table' => 'book', 'column' => 'title', 'value' => 'foo'], @@ -379,16 +423,18 @@ public function testWhereFunction() /** * @group mysql + * + * @return void */ public function testWhereTypeValue() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); - $c->where('LOCATE(\'foo\', b.Title) = ?', true, \PDO::PARAM_BOOL); + $c->where('LOCATE(\'foo\', b.Title) = ?', true, PDO::PARAM_BOOL); $sql = $this->getSql("SELECT FROM book WHERE LOCATE('foo', book.title) = :p1"); $params = [ - ['table' => null, 'type' => \PDO::PARAM_BOOL, 'value' => true], + ['table' => null, 'type' => PDO::PARAM_BOOL, 'value' => true], ]; $this->assertCriteriaTranslation($c, $sql, $params, 'where() accepts a complex calculation'); $c->find($this->con); @@ -398,13 +444,16 @@ public function testWhereTypeValue() $this->assertEquals($expected, $this->con->getLastExecutedQuery()); } + /** + * @return void + */ public function testOrWhere() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $c->where('Propel\Tests\Bookstore\Book.Title <> ?', 'foo'); $c->_or()->where('Propel\Tests\Bookstore\Book.Title like ?', '%bar%'); - $sql = $this->getSql("SELECT FROM book WHERE (book.title <> :p1 OR book.title like :p2)"); + $sql = $this->getSql('SELECT FROM book WHERE (book.title <> :p1 OR book.title like :p2)'); $params = [ ['table' => 'book', 'column' => 'title', 'value' => 'foo'], @@ -413,6 +462,9 @@ public function testOrWhere() $this->assertCriteriaTranslation($c, $sql, $params, 'orWhere() combines the clause with the previous one using OR'); } + /** + * @return void + */ public function testOrWhereConditions() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -421,7 +473,7 @@ public function testOrWhereConditions() $c->condition('cond2', 'Propel\Tests\Bookstore\Book.Title like ?', '%bar%'); $c->_or()->where(['cond1', 'cond2']); - $sql = $this->getSql("SELECT FROM book WHERE (book.id = :p1 OR (book.title <> :p2 AND book.title like :p3))"); + $sql = $this->getSql('SELECT FROM book WHERE (book.id = :p1 OR (book.title <> :p2 AND book.title like :p3))'); $params = [ ['table' => 'book', 'column' => 'id', 'value' => 12], @@ -436,11 +488,14 @@ public function testOrWhereConditions() $c->condition('cond2', 'Propel\Tests\Bookstore\Book.Title like ?', '%bar%'); $c->_or()->where(['cond1', 'cond2'], Criteria::LOGICAL_OR); - $sql = $this->getSql("SELECT FROM book WHERE (book.id = :p1 OR (book.title <> :p2 OR book.title like :p3))"); + $sql = $this->getSql('SELECT FROM book WHERE (book.id = :p1 OR (book.title <> :p2 OR book.title like :p3))'); $this->assertCriteriaTranslation($c, $sql, $params, 'orWhere() accepts an array of named conditions with operator'); } + /** + * @return void + */ public function testMixedCriteria() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -449,14 +504,17 @@ public function testMixedCriteria() $sql = $this->getSql('SELECT FROM book WHERE book.title = :p1 AND book.id IN (:p2,:p3)'); - $params = [ + $params = [ ['table' => 'book', 'column' => 'title', 'value' => 'foo'], ['table' => 'book', 'column' => 'id', 'value' => 1], - ['table' => 'book', 'column' => 'id', 'value' => 2] + ['table' => 'book', 'column' => 'id', 'value' => 2], ]; $this->assertCriteriaTranslation($c, $sql, $params, 'ModelCriteria accepts Criteria operators'); } + /** + * @return void + */ public function testFilterBy() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -493,15 +551,17 @@ public function testFilterBy() $params, 'filterBy() accepts a simple column name, even if initialized with an alias' ); - } + /** + * @return void + */ public function testGetParams() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $c->filterBy('Title', 'foo'); - $expectedParams = [ + $expectedParams = [ ['table' => 'book', 'column' => 'title', 'value' => 'foo'], ]; @@ -512,26 +572,31 @@ public function testGetParams() $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $c->filterBy('Title', 'foo', Criteria::LIKE); - $expectedParams = [ + $expectedParams = [ ['table' => 'book', 'column' => 'title', 'value' => 'foo'], ]; $this->assertEquals($expectedParams, $params, 'test getting parameters with Specialized Criterion used for LIKE expressions'); - } + /** + * @return void + */ public function testHaving() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $c->having('Propel\Tests\Bookstore\Book.Title <> ?', 'foo'); - $sql = "SELECT FROM HAVING book.title <> :p1"; + $sql = 'SELECT FROM HAVING book.title <> :p1'; $params = [ ['table' => 'book', 'column' => 'title', 'value' => 'foo'], ]; $this->assertCriteriaTranslation($c, $sql, $params, 'having() accepts a string clause'); } + /** + * @return void + */ public function testHavingConditions() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -539,7 +604,7 @@ public function testHavingConditions() $c->condition('cond2', 'Propel\Tests\Bookstore\Book.Title like ?', '%bar%'); $c->having(['cond1', 'cond2']); - $sql = "SELECT FROM HAVING (book.title <> :p1 AND book.title like :p2)"; + $sql = 'SELECT FROM HAVING (book.title <> :p1 AND book.title like :p2)'; $params = [ ['table' => 'book', 'column' => 'title', 'value' => 'foo'], ['table' => 'book', 'column' => 'title', 'value' => '%bar%'], @@ -551,18 +616,20 @@ public function testHavingConditions() $c->condition('cond2', 'Propel\Tests\Bookstore\Book.Title like ?', '%bar%'); $c->having(['cond1', 'cond2'], Criteria::LOGICAL_OR); - $sql = "SELECT FROM HAVING (book.title <> :p1 OR book.title like :p2)"; + $sql = 'SELECT FROM HAVING (book.title <> :p1 OR book.title like :p2)'; $this->assertCriteriaTranslation($c, $sql, $params, 'having() accepts an array of named conditions with an operator'); } /** * @group mysql + * + * @return void */ public function testHavingWithColumn() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $c->withColumn('SUBSTRING(Book.Title, 1, 4)', 'title_start'); - $c->having('title_start = ?', 'foo', \PDO::PARAM_STR); + $c->having('title_start = ?', 'foo', PDO::PARAM_STR); $sql = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, SUBSTRING(book.title, 1, 4) AS title_start FROM book HAVING title_start = :p1'); @@ -577,6 +644,9 @@ public function testHavingWithColumn() $this->assertEquals($expected, $this->con->getLastExecutedQuery()); } + /** + * @return void + */ public function testOrderBy() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -608,6 +678,9 @@ public function testOrderBy() } } + /** + * @return void + */ public function testOrderBySimpleColumn() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -618,6 +691,9 @@ public function testOrderBySimpleColumn() $this->assertCriteriaTranslation($c, $sql, $params, 'orderBy() accepts a simple column name and adds an ORDER BY clause'); } + /** + * @return void + */ public function testOrderByAlias() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -629,6 +705,9 @@ public function testOrderByAlias() $this->assertCriteriaTranslation($c, $sql, $params, 'orderBy() accepts a column alias and adds an ORDER BY clause'); } + /** + * @return void + */ public function testGroupBy() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -647,6 +726,9 @@ public function testGroupBy() } } + /** + * @return void + */ public function testGroupBySimpleColumn() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -657,6 +739,9 @@ public function testGroupBySimpleColumn() $this->assertCriteriaTranslation($c, $sql, $params, 'groupBy() accepts a simple column name and adds a GROUP BY clause'); } + /** + * @return void + */ public function testGroupByAlias() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -670,6 +755,8 @@ public function testGroupByAlias() /** * @expectedException \Propel\Runtime\Exception\ClassNotFoundException + * + * @return void */ public function testGroupByClassThrowsExceptionOnUnknownClass() { @@ -677,6 +764,9 @@ public function testGroupByClassThrowsExceptionOnUnknownClass() $c->groupByClass('Author'); } + /** + * @return void + */ public function testGroupByClass() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -687,6 +777,9 @@ public function testGroupByClass() $this->assertCriteriaTranslation($c, $sql, $params, 'groupByClass() accepts a class name and adds a GROUP BY clause for all columns of the class'); } + /** + * @return void + */ public function testGroupByClassAlias() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); @@ -697,6 +790,9 @@ public function testGroupByClassAlias() $this->assertCriteriaTranslation($c, $sql, $params, 'groupByClass() accepts a class alias and adds a GROUP BY clause for all columns of the class'); } + /** + * @return void + */ public function testGroupByClassTrueAlias() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -708,6 +804,9 @@ public function testGroupByClassTrueAlias() $this->assertCriteriaTranslation($c, $sql, $params, 'groupByClass() accepts a true class alias and adds a GROUP BY clause for all columns of the class'); } + /** + * @return void + */ public function testGroupByClassJoinedModel() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author'); @@ -719,6 +818,9 @@ public function testGroupByClassJoinedModel() $this->assertCriteriaTranslation($c, $sql, $params, 'groupByClass() accepts the class name of a joined model'); } + /** + * @return void + */ public function testGroupByClassJoinedModelWithAlias() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author'); @@ -730,6 +832,9 @@ public function testGroupByClassJoinedModelWithAlias() $this->assertCriteriaTranslation($c, $sql, $params, 'groupByClass() accepts the alias of a joined model'); } + /** + * @return void + */ public function testDistinct() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -739,6 +844,9 @@ public function testDistinct() $this->assertCriteriaTranslation($c, $sql, $params, 'distinct() adds a DISTINCT clause'); } + /** + * @return void + */ public function testLimit() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -751,9 +859,11 @@ public function testLimit() $sql = 'SELECT FROM LIMIT 0'; $params = []; $this->assertCriteriaTranslation($c, $sql, $params, 'limit() adds a LIMIT clause'); - } + /** + * @return void + */ public function testOffset() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -768,6 +878,9 @@ public function testOffset() $this->assertCriteriaTranslation($c, $sql, $params, 'offset() adds an OFFSET clause'); } + /** + * @return void + */ public function testAddJoin() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -778,6 +891,9 @@ public function testAddJoin() $this->assertCriteriaTranslation($c, $sql, $params, 'addJoin() works the same as in Criteria'); } + /** + * @return void + */ public function testJoin() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -813,6 +929,9 @@ public function testJoin() $this->assertCriteriaTranslation($c, $sql, $params, 'join() uses the current model name when given a simple relation name'); } + /** + * @return void + */ public function testJoinQuery() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -828,6 +947,9 @@ public function testJoinQuery() $this->assertEquals(1, count($books), 'join() issues a real JOIN query'); } + /** + * @return void + */ public function testJoinRelationName() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\BookstoreEmployee'); @@ -837,6 +959,9 @@ public function testJoinRelationName() $this->assertCriteriaTranslation($c, $sql, $params, 'join() uses relation names as defined in schema.xml'); } + /** + * @return void + */ public function testJoinComposite() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\ReaderFavorite'); @@ -846,6 +971,9 @@ public function testJoinComposite() $this->assertCriteriaTranslation($c, $sql, $params, 'join() knows how to create a JOIN clause for relationships with composite fkeys'); } + /** + * @return void + */ public function testJoinType() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -879,6 +1007,9 @@ public function testJoinType() $this->assertCriteriaTranslation($c, $sql, $params, 'join() accepts any join string'); } + /** + * @return void + */ public function testJoinDirection() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -906,6 +1037,9 @@ public function testJoinDirection() $this->assertCriteriaTranslation($c, $sql, $params, 'join() adds a JOIN clause correctly for one to one relationship'); } + /** + * @return void + */ public function testJoinSeveral() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author'); @@ -919,6 +1053,9 @@ public function testJoinSeveral() $this->assertCriteriaTranslation($c, $sql, $params, 'join() can guess relationships from related tables'); } + /** + * @return void + */ public function testJoinAlias() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); @@ -966,6 +1103,9 @@ public function testJoinAlias() $this->assertCriteriaTranslation($c, $sql, $params, 'join() allows the use of relation alias in further join()'); } + /** + * @return void + */ public function testJoinTrueTableAlias() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -983,6 +1123,9 @@ public function testJoinTrueTableAlias() $this->assertCriteriaTranslation($c, $sql, $params, 'join() supports relation without alias name on true table alias'); } + /** + * @return void + */ public function testJoinOnSameTable() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\BookstoreEmployee', 'be'); @@ -996,6 +1139,9 @@ public function testJoinOnSameTable() $this->assertCriteriaTranslation($c, $sql, $params, 'join() allows two joins on the same table thanks to aliases'); } + /** + * @return void + */ public function testJoinAliasQuery() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -1015,6 +1161,9 @@ public function testJoinAliasQuery() $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'join() allows the use of relation alias in further joins()'); } + /** + * @return void + */ public function testAddJoinConditionSimple() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -1022,10 +1171,13 @@ public function testAddJoinConditionSimple() $c->join('Propel\Tests\Bookstore\Book.Author', Criteria::INNER_JOIN); $c->addJoinCondition('Author', 'Propel\Tests\Bookstore\Book.Title IS NOT NULL'); $books = BookQuery::create(null, $c)->find($con); - $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book INNER JOIN author ON (book.author_id=author.id AND book.title IS NOT NULL)"); + $expectedSQL = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book INNER JOIN author ON (book.author_id=author.id AND book.title IS NOT NULL)'); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of custom conditions'); } + /** + * @return void + */ public function testAddJoinConditionBinding() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -1037,6 +1189,9 @@ public function testAddJoinConditionBinding() $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of custom conditions with values to bind'); } + /** + * @return void + */ public function testAddJoinConditionSeveral() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -1049,6 +1204,9 @@ public function testAddJoinConditionSeveral() $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of several custom conditions'); } + /** + * @return void + */ public function testAddJoinConditionBindingAndWhere() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -1061,6 +1219,9 @@ public function testAddJoinConditionBindingAndWhere() $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of custom conditions with values and lives well with WHERE conditions'); } + /** + * @return void + */ public function testAddJoinConditionAlias() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -1068,10 +1229,13 @@ public function testAddJoinConditionAlias() $c->join('Propel\Tests\Bookstore\Book.Author a', Criteria::INNER_JOIN); $c->addJoinCondition('a', 'Book.Title IS NOT NULL'); $books = BookQuery::create(null, $c)->find($con); - $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book INNER JOIN author a ON (book.author_id=a.id AND book.title IS NOT NULL)"); + $expectedSQL = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book INNER JOIN author a ON (book.author_id=a.id AND book.title IS NOT NULL)'); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of custom conditions even on aliased relations'); } + /** + * @return void + */ public function testAddJoinConditionOperator() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -1079,10 +1243,13 @@ public function testAddJoinConditionOperator() $c->join('Propel\Tests\Bookstore\Book.Author', Criteria::INNER_JOIN); $c->addJoinCondition('Author', 'Propel\Tests\Bookstore\Book.Title IS NOT NULL', null, Criteria::LOGICAL_OR); $books = BookQuery::create(null, $c)->find($con); - $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book INNER JOIN author ON (book.author_id=author.id OR book.title IS NOT NULL)"); + $expectedSQL = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book INNER JOIN author ON (book.author_id=author.id OR book.title IS NOT NULL)'); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of custom conditions with a custom operator'); } + /** + * @return void + */ public function testSetJoinConditionCriterion() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -1091,10 +1258,13 @@ public function testSetJoinConditionCriterion() $criterion = $c->getNewCriterion(BookTableMap::COL_TITLE, BookTableMap::COL_TITLE . ' = ' . AuthorTableMap::COL_FIRST_NAME, Criteria::CUSTOM); $c->setJoinCondition('Author', $criterion); $books = BookQuery::create(null, $c)->find($con); - $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book INNER JOIN author ON book.title = author.first_name"); + $expectedSQL = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book INNER JOIN author ON book.title = author.first_name'); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'setJoinCondition() can override a previous join condition with a Criterion'); } + /** + * @return void + */ public function testSetJoinConditionNamedCondition() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -1103,19 +1273,25 @@ public function testSetJoinConditionNamedCondition() $c->condition('cond1', 'Propel\Tests\Bookstore\Book.Title = Author.FirstName'); $c->setJoinCondition('Author', 'cond1'); $books = BookQuery::create(null, $c)->find($con); - $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book INNER JOIN author ON book.title = author.first_name"); + $expectedSQL = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book INNER JOIN author ON book.title = author.first_name'); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'setJoinCondition() can override a previous join condition with a named condition'); } + /** + * @return void + */ public function testGetJoin() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $c->join('Propel\Tests\Bookstore\Book.Author'); $joins = $c->getJoins(); - $this->assertEquals($joins['Author'], $c->getJoin('Author'), "getJoin() returns a specific Join from the ModelCriteria"); + $this->assertEquals($joins['Author'], $c->getJoin('Author'), 'getJoin() returns a specific Join from the ModelCriteria'); } + /** + * @return void + */ public function testWith() { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -1128,6 +1304,8 @@ public function testWith() /** * @expectedException \Propel\Runtime\ActiveQuery\Exception\UnknownRelationException + * + * @return void */ public function testWithThrowsExceptionWhenJoinLacks() { @@ -1135,6 +1313,9 @@ public function testWithThrowsExceptionWhenJoinLacks() $c->with('Propel\Tests\Bookstore\Author'); } + /** + * @return void + */ public function testWithAlias() { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -1146,6 +1327,8 @@ public function testWithAlias() /** * @expectedException \Propel\Runtime\ActiveQuery\Exception\UnknownRelationException + * + * @return void */ public function testWithThrowsExceptionWhenNotUsingAlias() { @@ -1154,6 +1337,9 @@ public function testWithThrowsExceptionWhenNotUsingAlias() $c->with('Propel\Tests\Bookstore\Author'); } + /** + * @return void + */ public function testWithAddsSelectColumns() { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -1171,11 +1357,14 @@ public function testWithAddsSelectColumns() AuthorTableMap::COL_FIRST_NAME, AuthorTableMap::COL_LAST_NAME, AuthorTableMap::COL_EMAIL, - AuthorTableMap::COL_AGE + AuthorTableMap::COL_AGE, ]; $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the related table'); } + /** + * @return void + */ public function testWithAliasAddsSelectColumns() { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -1193,11 +1382,14 @@ public function testWithAliasAddsSelectColumns() 'a.first_name', 'a.last_name', 'a.email', - 'a.age' + 'a.age', ]; $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the related table'); } + /** + * @return void + */ public function testWithAddsSelectColumnsOfMainTable() { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -1214,11 +1406,14 @@ public function testWithAddsSelectColumnsOfMainTable() AuthorTableMap::COL_FIRST_NAME, AuthorTableMap::COL_LAST_NAME, AuthorTableMap::COL_EMAIL, - AuthorTableMap::COL_AGE + AuthorTableMap::COL_AGE, ]; $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the main table if required'); } + /** + * @return void + */ public function testWithAliasAddsSelectColumnsOfMainTable() { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -1236,11 +1431,14 @@ public function testWithAliasAddsSelectColumnsOfMainTable() 'a.first_name', 'a.last_name', 'a.email', - 'a.age' + 'a.age', ]; $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the main table with an alias if required'); } + /** + * @return void + */ public function testWithOneToManyAddsSelectColumns() { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author'); @@ -1263,6 +1461,9 @@ public function testWithOneToManyAddsSelectColumns() $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the related table even in a one-to-many relationship'); } + /** + * @return void + */ public function testJoinWith() { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -1278,7 +1479,7 @@ public function testJoinWith() AuthorTableMap::COL_FIRST_NAME, AuthorTableMap::COL_LAST_NAME, AuthorTableMap::COL_EMAIL, - AuthorTableMap::COL_AGE + AuthorTableMap::COL_AGE, ]; $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWith() adds the join'); $joins = $c->getJoins(); @@ -1286,6 +1487,9 @@ public function testJoinWith() $this->assertEquals(Criteria::INNER_JOIN, $join->getJoinType(), 'joinWith() adds an INNER JOIN by default'); } + /** + * @return void + */ public function testJoinWithType() { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -1295,6 +1499,9 @@ public function testJoinWithType() $this->assertEquals(Criteria::LEFT_JOIN, $join->getJoinType(), 'joinWith() accepts a join type as second parameter'); } + /** + * @return void + */ public function testJoinWithAlias() { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -1310,11 +1517,14 @@ public function testJoinWithAlias() 'a.first_name', 'a.last_name', 'a.email', - 'a.age' + 'a.age', ]; $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWith() adds the join with the alias'); } + /** + * @return void + */ public function testJoinWithSeveral() { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Review'); @@ -1340,7 +1550,7 @@ public function testJoinWithSeveral() AuthorTableMap::COL_EMAIL, AuthorTableMap::COL_AGE, PublisherTableMap::COL_ID, - PublisherTableMap::COL_NAME + PublisherTableMap::COL_NAME, ]; $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWith() adds the with'); $joins = $c->getJoins(); @@ -1348,6 +1558,9 @@ public function testJoinWithSeveral() $this->assertEquals($expectedJoinKeys, array_keys($joins), 'joinWith() adds the join'); } + /** + * @return void + */ public function testJoinWithTwice() { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -1391,6 +1604,8 @@ public static function conditionsForTestWithColumn() /** * @dataProvider conditionsForTestWithColumn + * + * @return void */ public function testWithColumn($clause, $alias, $selectTranslation) { @@ -1419,6 +1634,8 @@ public static function conditionsForTestWithColumnAndQuotes() /** * @dataProvider conditionsForTestWithColumnAndQuotes + * + * @return void */ public function testWithColumnAndQuotes($clause, $alias, $selectTranslation) { @@ -1429,6 +1646,9 @@ public function testWithColumnAndQuotes($clause, $alias, $selectTranslation) $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() adds a calculated column using quotes to the select clause'); } + /** + * @return void + */ public function testWithColumnAndSelectColumns() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -1461,6 +1681,9 @@ public function testWithColumnAndSelectColumns() $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() called repeatedly adds several as columns'); } + /** + * @return void + */ public function testKeepQuery() { $c = BookQuery::create(); @@ -1471,6 +1694,9 @@ public function testKeepQuery() $this->assertTrue($c->isKeepQuery(), 'keepQuery() enables the keepQuery property'); } + /** + * @return void + */ public function testKeepQueryFind() { $c = BookQuery::create(); @@ -1486,6 +1712,9 @@ public function testKeepQueryFind() $this->assertEquals($expected, $c->getSelectColumns(), 'keepQuery(false) forces find() to use the original query'); } + /** + * @return void + */ public function testKeepQueryFindOne() { $c = BookQuery::create(); @@ -1500,6 +1729,9 @@ public function testKeepQueryFindOne() $this->assertEquals(1, $c->getLimit(), 'keepQuery(false) forces findOne() to use the original query'); } + /** + * @return void + */ public function testKeepQueryFindPk() { $c = BookQuery::create(); @@ -1513,6 +1745,9 @@ public function testKeepQueryFindPk() $this->assertEquals($expected, $c->getSelectColumns(), 'keepQuery(false) forces findPk() to use the original query'); } + /** + * @return void + */ public function testKeepQueryCount() { $c = BookQuery::create(); @@ -1527,6 +1762,9 @@ public function testKeepQueryCount() $this->assertEquals([], $c->getOrderByColumns(), 'keepQuery() forces count() to use the original query'); } + /** + * @return void + */ public function testFind() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); @@ -1546,25 +1784,34 @@ public function testFind() $this->assertEquals('Quicksilver', $book->getTitle(), 'find() returns the model objects matching the query'); } + /** + * @return void + */ public function testFindAddsSelectColumns() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $books = $c->find($con); - $sql = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book"); + $sql = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book'); $this->assertEquals($sql, $con->getLastExecutedQuery(), 'find() adds the select columns of the current model'); } + /** + * @return void + */ public function testFindTrueAliasAddsSelectColumns() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $c->setModelAlias('b', true); $books = $c->find($con); - $sql = $this->getSql("SELECT b.id, b.title, b.isbn, b.price, b.publisher_id, b.author_id FROM book b"); + $sql = $this->getSql('SELECT b.id, b.title, b.isbn, b.price, b.publisher_id, b.author_id FROM book b'); $this->assertEquals($sql, $con->getLastExecutedQuery(), 'find() uses the true model alias if available'); } + /** + * @return void + */ public function testFindOne() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); @@ -1579,6 +1826,9 @@ public function testFindOne() $this->assertEquals('Don Juan', $book->getTitle(), 'find() returns the model objects matching the query'); } + /** + * @return void + */ public function testFindOneOrCreateNotExists() { BookQuery::create()->deleteAll(); @@ -1592,6 +1842,9 @@ public function testFindOneOrCreateNotExists() $this->assertEquals(125, $book->getPrice(), 'findOneOrCreate() returns a populated objects based on the conditions'); } + /** + * @return void + */ public function testFindOneOrCreateNotExistsFormatter() { BookQuery::create()->deleteAll(); @@ -1605,6 +1858,9 @@ public function testFindOneOrCreateNotExistsFormatter() $this->assertEquals(125, $book['Price'], 'findOneOrCreate() returns a populated array based on the conditions'); } + /** + * @return void + */ public function testFindOneOrCreateExists() { BookQuery::create()->deleteAll(); @@ -1625,6 +1881,8 @@ public function testFindOneOrCreateExists() /** * @expectedException Propel\Runtime\Exception\PropelException + * + * @return void */ public function testFindOneOrCreateThrowsExceptionWhenQueryContainsJoin() { @@ -1636,6 +1894,9 @@ public function testFindOneOrCreateThrowsExceptionWhenQueryContainsJoin() ->findOneOrCreate(); } + /** + * @return void + */ public function testFindOneOrCreateMakesOneQueryWhenRecordNotExists() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -1647,6 +1908,9 @@ public function testFindOneOrCreateMakesOneQueryWhenRecordNotExists() $this->assertEquals($count + 1, $con->getQueryCount(), 'findOneOrCreate() makes only a single query when the record doesn\'t exist'); } + /** + * @return void + */ public function testFindOneOrCreateMakesOneQueryWhenRecordExists() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -1663,6 +1927,9 @@ public function testFindOneOrCreateMakesOneQueryWhenRecordExists() $this->assertEquals($count + 1, $con->getQueryCount(), 'findOneOrCreate() makes only a single query when the record exists'); } + /** + * @return void + */ public function testFindOneOrCreateWithEnums() { Book2Query::create()->deleteAll(); @@ -1693,6 +1960,9 @@ public function testFindOneOrCreateWithEnums() $this->assertEquals('novel', $book->getStyle(), 'findOneOrCreate() returns a populated objects based on the conditions'); } + /** + * @return void + */ public function testFindOneOrCreateWithSets() { Book2Query::create()->deleteAll(); @@ -1723,6 +1993,9 @@ public function testFindOneOrCreateWithSets() $this->assertEquals(['novel', 'essay'], $book->getStyle2(), 'findOneOrCreate() returns a populated objects based on the conditions'); } + /** + * @return void + */ public function testFindOneOrCreateWithArrays() { Book2Query::create()->deleteAll(); @@ -1744,6 +2017,9 @@ public function testFindOneOrCreateWithArrays() $this->assertSame(['poetry'], $book->getTags(), 'findOneOrCreate() returns a populated objects based on the conditions'); } + /** + * @return void + */ public function testFindPkSimpleKey() { BookstoreDataPopulator::depopulate(); @@ -1763,6 +2039,9 @@ public function testFindPkSimpleKey() $this->assertEquals($testBook, $book, 'findPk() returns a model object corresponding to the pk'); } + /** + * @return void + */ public function testFindPksSimpleKey() { BookstoreDataPopulator::depopulate(); @@ -1785,6 +2064,9 @@ public function testFindPksSimpleKey() $this->assertEquals([$testBook2, $testBook1], $books->getData(), 'findPks() returns an array of model objects corresponding to the pks'); } + /** + * @return void + */ public function testFindPkCompositeKey() { BookstoreDataPopulator::depopulate(); @@ -1815,14 +2097,18 @@ public function testFindPkCompositeKey() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testFindPksCompositeKey() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\BookListRel'); $bookListRel = $c->findPks([[1, 2]]); - } + /** + * @return void + */ public function testFindBy() { try { @@ -1845,6 +2131,9 @@ public function testFindBy() $this->assertEquals('Don Juan', $book->getTitle(), 'findBy() returns the model objects matching the query'); } + /** + * @return void + */ public function testFindByArray() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -1854,6 +2143,9 @@ public function testFindByArray() $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findByArray() adds multiple column conditions'); } + /** + * @return void + */ public function testFindOneBy() { try { @@ -1873,6 +2165,9 @@ public function testFindOneBy() $this->assertEquals('Don Juan', $book->getTitle(), 'findOneBy() returns the model object matching the query'); } + /** + * @return void + */ public function testFindOneByArray() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -1882,12 +2177,18 @@ public function testFindOneByArray() $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findOneBy() adds multiple column conditions'); } + /** + * @return void + */ public function testGetIteratorReturnsATraversable() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $this->assertInstanceOf('Traversable', $c->getIterator()); } + /** + * @return void + */ public function testGetIteratorAllowsTraversingQueryObjects() { BookstoreDataPopulator::depopulate(); @@ -1900,6 +2201,9 @@ public function testGetIteratorAllowsTraversingQueryObjects() $this->assertEquals(4, $nbResults); } + /** + * @return void + */ public function testGetIteratorReturnsATraversableWithArrayFormatter() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -1907,6 +2211,9 @@ public function testGetIteratorReturnsATraversableWithArrayFormatter() $this->assertInstanceOf('Traversable', $c->getIterator()); } + /** + * @return void + */ public function testGetIteratorAllowsTraversingQueryObjectsWithArrayFormatter() { BookstoreDataPopulator::depopulate(); @@ -1920,6 +2227,9 @@ public function testGetIteratorAllowsTraversingQueryObjectsWithArrayFormatter() $this->assertEquals(4, $nbResults); } + /** + * @return void + */ public function testGetIteratorReturnsATraversableWithOnDemandFormatter() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -1929,6 +2239,9 @@ public function testGetIteratorReturnsATraversableWithOnDemandFormatter() $it->closeCursor(); } + /** + * @return void + */ public function testGetIteratorAllowsTraversingQueryObjectsWithOnDemandFormatter() { BookstoreDataPopulator::depopulate(); @@ -1942,6 +2255,9 @@ public function testGetIteratorAllowsTraversingQueryObjectsWithOnDemandFormatter $this->assertEquals(4, $nbResults); } + /** + * @return void + */ public function testGetIteratorReturnsATraversableWithStatementFormatter() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -1949,6 +2265,9 @@ public function testGetIteratorReturnsATraversableWithStatementFormatter() $this->assertInstanceOf('Traversable', $c->getIterator()); } + /** + * @return void + */ public function testGetIteratorAllowsTraversingQueryObjectsWithStatementFormatter() { BookstoreDataPopulator::depopulate(); @@ -1962,6 +2281,9 @@ public function testGetIteratorAllowsTraversingQueryObjectsWithStatementFormatte $this->assertEquals(4, $nbResults); } + /** + * @return void + */ public function testGetIteratorReturnsATraversableWithSimpleArrayFormatter() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -1969,6 +2291,9 @@ public function testGetIteratorReturnsATraversableWithSimpleArrayFormatter() $this->assertInstanceOf('Traversable', $c->getIterator()); } + /** + * @return void + */ public function testGetIteratorAllowsTraversingQueryObjectsWithSimpleArrayFormatter() { BookstoreDataPopulator::depopulate(); @@ -1982,6 +2307,9 @@ public function testGetIteratorAllowsTraversingQueryObjectsWithSimpleArrayFormat $this->assertEquals(4, $nbResults); } + /** + * @return void + */ public function testCount() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); @@ -1998,6 +2326,9 @@ public function testCount() $this->assertEquals(1, $nbBooks, 'count() returns the number of results in the query'); } + /** + * @return void + */ public function testExists() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); @@ -2012,6 +2343,9 @@ public function testExists() $this->assertTrue($booksExists, 'exists() returns true when there are matching results'); } + /** + * @return void + */ public function testPaginate() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); @@ -2025,6 +2359,9 @@ public function testPaginate() } } + /** + * @return void + */ public function testDelete() { BookstoreDataPopulator::depopulate(); @@ -2055,6 +2392,9 @@ public function testDelete() $this->assertEquals(3, $nbBooks, 'delete() deletes rows in the database'); } + /** + * @return void + */ public function testDeleteUsingTableAlias() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -2080,6 +2420,9 @@ public function testDeleteUsingTableAlias() } } + /** + * @return void + */ public function testDeleteAll() { BookstoreDataPopulator::depopulate(); @@ -2099,6 +2442,9 @@ public function testDeleteAll() $this->assertEquals(4, $nbBooks, 'deleteAll() ignores conditions on the criteria'); } + /** + * @return void + */ public function testUpdate() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -2132,6 +2478,9 @@ public function testUpdate() $this->assertEquals('3456', $book->getISBN(), 'update() updates only the records matching the criteria'); } + /** + * @return void + */ public function testUpdateUsingTableAlias() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -2153,6 +2502,9 @@ public function testUpdateUsingTableAlias() } } + /** + * @return void + */ public function testUpdateOneByOne() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -2212,12 +2564,17 @@ public static function conditionsForTestGetRelationName() /** * @dataProvider conditionsForTestGetRelationName + * + * @return void */ public function testGetRelationName($relation, $relationName) { $this->assertEquals($relationName, ModelCriteria::getrelationName($relation)); } + /** + * @return void + */ public function testMagicJoin() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -2273,9 +2630,11 @@ public function testMagicJoin() $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book LEFT JOIN author ON (book.author_id=author.id) WHERE author.first_name = 'Leo' LIMIT 1"); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'leftJoinX() is turned into join($x, Criteria::LEFT_JOIN)'); } - } + /** + * @return void + */ public function testMagicJoinWith() { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -2291,7 +2650,7 @@ public function testMagicJoinWith() 'a.first_name', 'a.last_name', 'a.email', - 'a.age' + 'a.age', ]; $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'leftJoinWith() adds the join with the alias'); $joins = $c->getJoins(); @@ -2299,6 +2658,9 @@ public function testMagicJoinWith() $this->assertEquals(Criteria::LEFT_JOIN, $join->getJoinType(), 'leftJoinWith() adds a LEFT JOIN'); } + /** + * @return void + */ public function testMagicJoinWithRelation() { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -2314,7 +2676,7 @@ public function testMagicJoinWithRelation() AuthorTableMap::COL_FIRST_NAME, AuthorTableMap::COL_LAST_NAME, AuthorTableMap::COL_EMAIL, - AuthorTableMap::COL_AGE + AuthorTableMap::COL_AGE, ]; $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWithXXX() adds the join with the XXX relation'); $joins = $c->getJoins(); @@ -2322,6 +2684,9 @@ public function testMagicJoinWithRelation() $this->assertEquals(Criteria::INNER_JOIN, $join->getJoinType(), 'joinWithXXX() adds an INNER JOIN'); } + /** + * @return void + */ public function testMagicJoinWithTypeAndRelation() { $c = new TestableModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -2337,7 +2702,7 @@ public function testMagicJoinWithTypeAndRelation() AuthorTableMap::COL_FIRST_NAME, AuthorTableMap::COL_LAST_NAME, AuthorTableMap::COL_EMAIL, - AuthorTableMap::COL_AGE + AuthorTableMap::COL_AGE, ]; $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'leftJoinWithXXX() adds the join with the XXX relation'); $joins = $c->getJoins(); @@ -2345,6 +2710,9 @@ public function testMagicJoinWithTypeAndRelation() $this->assertEquals(Criteria::LEFT_JOIN, $join->getJoinType(), 'leftJoinWithXXX() adds an INNER JOIN'); } + /** + * @return void + */ public function testMagicFind() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -2370,6 +2738,9 @@ public function testMagicFind() $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findOneByXXX($value) is turned into findOneBy(XXX, $value)'); } + /** + * @return void + */ public function testMagicFilterBy() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -2380,21 +2751,27 @@ public function testMagicFilterBy() $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'filterByXXX($value) is turned into filterBy(XXX, $value)'); } + /** + * @return void + */ public function testMagicOrderBy() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $books = $c->orderByTitle()->find($con); - $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book ORDER BY book.title ASC"); + $expectedSQL = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book ORDER BY book.title ASC'); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'orderByXXX() is turned into orderBy(XXX)'); $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $books = $c->orderByTitle(Criteria::DESC)->find($con); - $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book ORDER BY book.title DESC"); + $expectedSQL = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book ORDER BY book.title DESC'); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'orderByXXX($direction) is turned into orderBy(XXX, $direction)'); } + /** + * @return void + */ public function testMagicGroupBy() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -2403,14 +2780,17 @@ public function testMagicGroupBy() $books = $c->groupByTitle()->find($con); if ($this->isDb('pgsql')) { - $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book GROUP BY book.title,book.id,book.isbn,book.price,book.publisher_id,book.author_id"; + $expectedSQL = 'SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book GROUP BY book.title,book.id,book.isbn,book.price,book.publisher_id,book.author_id'; } else { - $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book GROUP BY book.title"); + $expectedSQL = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book GROUP BY book.title'); } $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'groupByXXX() is turned into groupBy(XXX)'); } + /** + * @return void + */ public function testUseQuery() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); @@ -2434,7 +2814,6 @@ public function testUseQuery() if (!$this->runningOnMySQL()) { $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book LEFT JOIN author ON (book.author_id=author.id) WHERE book.title = 'foo' AND author.first_name = 'john' LIMIT 5 OFFSET 10"); - } else { $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book LEFT JOIN author ON (book.author_id=author.id) WHERE book.title = 'foo' AND author.first_name = 'john' LIMIT 10, 5"); } @@ -2442,6 +2821,9 @@ public function testUseQuery() $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and endUse() allow to merge a secondary criteria'); } + /** + * @return void + */ public function testUseQueryAlias() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); @@ -2466,7 +2848,6 @@ public function testUseQueryAlias() if (!$this->runningOnMySQL()) { $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book LEFT JOIN author a ON (book.author_id=a.id) WHERE book.title = 'foo' AND a.first_name = 'john' LIMIT 5 OFFSET 10"); - } else { $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book LEFT JOIN author a ON (book.author_id=a.id) WHERE book.title = 'foo' AND a.first_name = 'john' LIMIT 10, 5"); } @@ -2474,6 +2855,9 @@ public function testUseQueryAlias() $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and endUse() allow to merge a secondary criteria'); } + /** + * @return void + */ public function testUseQueryCustomClass() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); @@ -2493,6 +2877,9 @@ public function testUseQueryCustomClass() $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and endUse() allow to merge a custom secondary criteria'); } + /** + * @return void + */ public function testUseQueryJoinWithFind() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Review'); @@ -2512,11 +2899,14 @@ public function testUseQueryJoinWithFind() $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); $c->find($con); - $expectedSQL = $this->getSql("SELECT review.id, review.reviewed_by, review.review_date, review.recommended, review.status, review.book_id, book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, author.id, author.first_name, author.last_name, author.email, author.age FROM review INNER JOIN book ON (review.book_id=book.id) INNER JOIN author ON (book.author_id=author.id)"); + $expectedSQL = $this->getSql('SELECT review.id, review.reviewed_by, review.review_date, review.recommended, review.status, review.book_id, book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, author.id, author.first_name, author.last_name, author.email, author.age FROM review INNER JOIN book ON (review.book_id=book.id) INNER JOIN author ON (book.author_id=author.id)'); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and joinWith() can be used together and form a correct query'); } + /** + * @return void + */ public function testUseQueryCustomRelationPhpName() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\BookstoreContest'); @@ -2538,6 +2928,9 @@ public function testUseQueryCustomRelationPhpName() $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and endUse() allow to merge a secondary criteria'); } + /** + * @return void + */ public function testUseQueryCustomRelationPhpNameAndAlias() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\BookstoreContest'); @@ -2559,6 +2952,9 @@ public function testUseQueryCustomRelationPhpNameAndAlias() $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and endUse() allow to merge a secondary criteria'); } + /** + * @return void + */ public function testMergeWithJoins() { $c1 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); @@ -2587,6 +2983,9 @@ public function testMergeWithJoins() $this->assertEquals('INNER JOIN publisher p ON (book.publisher_id=p.id)', $joins['p']->toString(), 'mergeWith() merge joins to an empty join'); } + /** + * @return void + */ public function testMergeWithWiths() { $c1 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); @@ -2622,9 +3021,11 @@ public function testMergeWithWiths() $this->assertEquals(2, count($with), 'mergeWith() merge joins to an existing join'); $this->assertEquals('modelName: Propel\Tests\Bookstore\Author, relationName: Author, relationMethod: setAuthor, leftPhpName: , rightPhpName: a', $with['a']->__toString(), 'mergeWith() merge joins to an empty join'); $this->assertEquals('modelName: Propel\Tests\Bookstore\Publisher, relationName: Publisher, relationMethod: setPublisher, leftPhpName: , rightPhpName: p', $with['p']->__toString(), 'mergeWith() merge joins to an empty join'); - } + /** + * @return void + */ public function testGetAliasedColName() { $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -2639,6 +3040,9 @@ public function testGetAliasedColName() $this->assertEquals('foo.title', $c->getAliasedColName(BookTableMap::COL_TITLE), 'getAliasedColName() returns the column name with table alias when the table has a true alias'); } + /** + * @return void + */ public function testAddUsingAliasNoAlias() { $c1 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -2648,6 +3052,9 @@ public function testAddUsingAliasNoAlias() $this->assertEquals($c2, $c1, 'addUsingalias() translates to add() when the table has no alias'); } + /** + * @return void + */ public function testAddUsingAliasQueryAlias() { $c1 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); @@ -2657,6 +3064,9 @@ public function testAddUsingAliasQueryAlias() $this->assertEquals($c2, $c1, 'addUsingalias() translates the colname using the table alias before calling add() when the table has a true alias'); } + /** + * @return void + */ public function testAddUsingAliasTrueAlias() { $c1 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -2668,6 +3078,9 @@ public function testAddUsingAliasTrueAlias() $this->assertEquals($c2, $c1, 'addUsingalias() translates to add() when the table has a true alias'); } + /** + * @return void + */ public function testAddUsingAliasTwice() { $c1 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -2679,6 +3092,9 @@ public function testAddUsingAliasTwice() $this->assertEquals($c2, $c1, 'addUsingalias() translates to addAnd() when the table already has a condition on the column'); } + /** + * @return void + */ public function testAddUsingAliasTrueAliasTwice() { $c1 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); @@ -2692,6 +3108,9 @@ public function testAddUsingAliasTrueAliasTwice() $this->assertEquals($c2, $c1, 'addUsingalias() translates to addAnd() when the table already has a condition on the column'); } + /** + * @return void + */ public function testCloneCopiesConditions() { $bookQuery1 = BookQuery::create() @@ -2707,6 +3126,9 @@ public function testCloneCopiesConditions() $this->assertEquals($expected, $sql, 'conditions applied on a cloned query don\'t get applied on the original query'); } + /** + * @return void + */ public function testCloneCopiesFormatter() { $formatter1 = new ArrayFormatter(); @@ -2720,6 +3142,9 @@ public function testCloneCopiesFormatter() $this->assertFalse($formatter1->test); } + /** + * @return void + */ public function testCloneCopiesSelect() { $bookQuery1 = BookQuery::create(); @@ -2729,6 +3154,9 @@ public function testCloneCopiesSelect() $this->assertEquals(['Id', 'Title'], $bookQuery1->getSelect()); } + /** + * @return void + */ public function testMagicFindByObject() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -2737,7 +3165,7 @@ public function testMagicFindByObject() $q = BookQuery::create() ->findByAuthor($testAuthor); - $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.author_id=" . $testAuthor->getId()); + $expectedSQL = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.author_id=' . $testAuthor->getId()); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findByXXX($value) is turned into findBy(XXX, $value)'); @@ -2745,10 +3173,13 @@ public function testMagicFindByObject() $testAuthor = $c->findOne(); $q = BookQuery::create() ->findByAuthorAndISBN($testAuthor, 1234); - $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.author_id=" . $testAuthor->getId() . " AND book.isbn=1234"); + $expectedSQL = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.author_id=' . $testAuthor->getId() . ' AND book.isbn=1234'); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findByXXXAndYYY($value) is turned into findBy(array(XXX, YYY), $value)'); } + /** + * @return void + */ public function testRequirePkReturnsModel() { // retrieve the test data @@ -2759,52 +3190,76 @@ public function testRequirePkReturnsModel() $this->assertInstanceOf(BookTableMap::OM_CLASS, $book); } + /** + * @return void + */ public function testRequirePkThrowsException() { - $this->expectException(\Propel\Runtime\Exception\EntityNotFoundException::class); + $this->expectException(EntityNotFoundException::class); BookQuery::create()->requirePk(-1337); } + /** + * @return void + */ public function testRequireOneReturnsModel() { $book = BookQuery::create()->orderByTitle()->requireOne(); $this->assertInstanceOf(BookTableMap::OM_CLASS, $book); } + /** + * @return void + */ public function testRequireOneThrowsException() { - $this->expectException(\Propel\Runtime\Exception\EntityNotFoundException::class); + $this->expectException(EntityNotFoundException::class); BookQuery::create()->filterByTitle('Not existing title')->requireOne(); } + /** + * @return void + */ public function testMagicRequireOneReturnsModel() { $book = BookQuery::create()->requireOneByTitle('Harry Potter and the Order of the Phoenix'); $this->assertInstanceOf(BookTableMap::OM_CLASS, $book); } + /** + * @return void + */ public function testMagicRequireOneThrowsException() { - $this->expectException(\Propel\Runtime\Exception\EntityNotFoundException::class); + $this->expectException(EntityNotFoundException::class); BookQuery::create()->requireOneById(-1337); } + /** + * @return void + */ public function testMagicRequireOneWithAndReturnsModel() { $book = BookQuery::create()->requireOneByIsbnAndTitle('043935806X', 'Harry Potter and the Order of the Phoenix'); $this->assertInstanceOf(BookTableMap::OM_CLASS, $book); } + /** + * @return void + */ public function testMagicRequireOneWithAndThrowsException() { - $this->expectException(\Propel\Runtime\Exception\EntityNotFoundException::class); + $this->expectException(EntityNotFoundException::class); BookQuery::create()->requireOneByTitleAndId('Not Existing Book', -1337); } + /** + * @return void + */ public function testJoinSelectColumn() { BookQuery::create() diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithNamespaceTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithNamespaceTest.php index b5df54acdc..2c643ce4e5 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithNamespaceTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithNamespaceTest.php @@ -10,9 +10,9 @@ namespace Propel\Tests\Runtime\ActiveQuery; -use Propel\Tests\Helpers\Namespaces\NamespacesTestBase; - +use Foo\Bar\Map\NamespacedBookTableMap; use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Tests\Helpers\Namespaces\NamespacesTestBase; /** * Test class for ModelCriteria with namespaces. @@ -39,13 +39,18 @@ public static function conditionsForTestReplaceNamesWithNamespaces() /** * @dataProvider conditionsForTestReplaceNamesWithNamespaces + * + * @return void */ public function testReplaceNamesWithNamespaces($origClause, $columnPhpName, $modifiedClause) { $c = new TestableModelCriteriaWithNamespace('bookstore_namespaced', 'Foo\\Bar\\NamespacedBook'); - $this->doTestReplaceNames($c, \Foo\Bar\Map\NamespacedBookTableMap::getTableMap(), $origClause, $columnPhpName, $modifiedClause); + $this->doTestReplaceNames($c, NamespacedBookTableMap::getTableMap(), $origClause, $columnPhpName, $modifiedClause); } + /** + * @return void + */ public function doTestReplaceNames($c, $tableMap, $origClause, $columnPhpName, $modifiedClause) { $c->replaceNames($origClause); @@ -55,7 +60,6 @@ public function doTestReplaceNames($c, $tableMap, $origClause, $columnPhpName, $ } $this->assertEquals($modifiedClause, $origClause); } - } class TestableModelCriteriaWithNamespace extends ModelCriteria diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithSchemaTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithSchemaTest.php index fa220eb7f5..b89104aac6 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithSchemaTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaWithSchemaTest.php @@ -10,9 +10,8 @@ namespace Propel\Tests\Runtime\ActiveQuery; -use Propel\Tests\BookstoreSchemas\Map\BookstoreContestTableMap; - use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Tests\BookstoreSchemas\Map\BookstoreContestTableMap; use Propel\Tests\TestCaseFixturesDatabase; /** @@ -24,7 +23,9 @@ */ class ModelCriteriaWithSchemaTest extends TestCaseFixturesDatabase { - + /** + * @return void + */ protected function assertCriteriaTranslation($criteria, $expectedSql, $expectedParams, $message = '') { $params = []; @@ -42,19 +43,24 @@ public static function conditionsForTestReplaceNamesWithSchemas() ['BookstoreContest.Id<= ?', 'Id', 'contest.bookstore_contest.id<= ?'], // with non-equal comparator ['BookstoreContest.BookstoreId LIKE ?', 'BookstoreId', 'contest.bookstore_contest.bookstore_id LIKE ?'], // with SQL keyword separator ['(BookstoreContest.BookstoreId) LIKE ?', 'BookstoreId', '(contest.bookstore_contest.bookstore_id) LIKE ?'], // with parenthesis - ['(BookstoreContest.Id*1.5)=1', 'Id', '(contest.bookstore_contest.id*1.5)=1'] // ignore numbers + ['(BookstoreContest.Id*1.5)=1', 'Id', '(contest.bookstore_contest.id*1.5)=1'], // ignore numbers ]; } /** * @dataProvider conditionsForTestReplaceNamesWithSchemas + * + * @return void */ public function testReplaceNamesWithSchemas($origClause, $columnPhpName, $modifiedClause) { $c = new TestableModelCriteriaWithSchema('bookstore-schemas', '\Propel\Tests\BookstoreSchemas\BookstoreContest'); - $this->doTestReplaceNames($c, BookstoreContestTableMap::getTableMap(), $origClause, $columnPhpName, $modifiedClause); + $this->doTestReplaceNames($c, BookstoreContestTableMap::getTableMap(), $origClause, $columnPhpName, $modifiedClause); } + /** + * @return void + */ public function doTestReplaceNames($c, $tableMap, $origClause, $columnPhpName, $modifiedClause) { $c->replaceNames($origClause); @@ -65,7 +71,6 @@ public function doTestReplaceNames($c, $tableMap, $origClause, $columnPhpName, $ $modifiedClause = preg_replace('/^(\(?)contest\./', '$1contest' . $this->getPlatform()->getSchemaDelimiter(), $modifiedClause); $this->assertEquals($modifiedClause, $origClause); } - } class TestableModelCriteriaWithSchema extends ModelCriteria @@ -76,5 +81,4 @@ public function replaceNames(&$sql) { return parent::replaceNames($sql); } - } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelJoinTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelJoinTest.php index 0adb12b2e8..a31dac37d2 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelJoinTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelJoinTest.php @@ -10,15 +10,12 @@ namespace Propel\Tests\Runtime\ActiveQuery; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; - +use Propel\Runtime\ActiveQuery\ModelJoin; +use Propel\Runtime\Map\TableMap; use Propel\Tests\Bookstore\Map\AuthorTableMap; -use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\BookOpinionTableMap; +use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\ReaderFavoriteTableMap; - -use Propel\Runtime\ActiveQuery\ModelJoin; -use Propel\Runtime\Map\TableMap; use Propel\Tests\TestCaseFixtures; /** @@ -28,6 +25,9 @@ */ class ModelJoinTest extends TestCaseFixtures { + /** + * @return void + */ public function testTableMap() { $join = new ModelJoin(); @@ -40,6 +40,9 @@ public function testTableMap() $this->assertEquals($tmap, $join->getTableMap(), 'getTableMap() returns the TableMap previously set by setTableMap()'); } + /** + * @return void + */ public function testSetRelationMap() { $join = new ModelJoin(); @@ -50,6 +53,9 @@ public function testSetRelationMap() $this->assertEquals($relationMap, $join->getRelationMap(), 'getRelationMap() returns the RelationMap previously set by setRelationMap()'); } + /** + * @return void + */ public function testSetRelationMapDefinesJoinColumns() { $bookTable = BookTableMap::getTableMap(); @@ -60,6 +66,9 @@ public function testSetRelationMapDefinesJoinColumns() $this->assertEquals([AuthorTableMap::COL_ID], $join->getRightColumns(), 'setRelationMap() automatically sets the right columns'); } + /** + * @return void + */ public function testSetRelationMapLeftAlias() { $bookTable = BookTableMap::getTableMap(); @@ -70,6 +79,9 @@ public function testSetRelationMapLeftAlias() $this->assertEquals([AuthorTableMap::COL_ID], $join->getRightColumns(), 'setRelationMap() automatically sets the right columns'); } + /** + * @return void + */ public function testSetRelationMapRightAlias() { $bookTable = BookTableMap::getTableMap(); @@ -80,6 +92,9 @@ public function testSetRelationMapRightAlias() $this->assertEquals(['a.id'], $join->getRightColumns(), 'setRelationMap() automatically sets the right columns using the right table alias'); } + /** + * @return void + */ public function testSetRelationMapComposite() { $table = ReaderFavoriteTableMap::getTableMap(); @@ -89,5 +104,4 @@ public function testSetRelationMapComposite() $this->assertEquals([ReaderFavoriteTableMap::COL_BOOK_ID, ReaderFavoriteTableMap::COL_READER_ID], $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns for composite relationships'); $this->assertEquals([BookOpinionTableMap::COL_BOOK_ID, BookOpinionTableMap::COL_READER_ID], $join->getRightColumns(), 'setRelationMap() automatically sets the right columns for composite relationships'); } - } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelWithTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelWithTest.php index 69f52311ef..f5f6180179 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelWithTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelWithTest.php @@ -10,17 +10,13 @@ namespace Propel\Tests\Runtime\ActiveQuery; -use Propel\Tests\Bookstore\Author; +use Propel\Runtime\ActiveQuery\ModelWith; use Propel\Tests\Bookstore\AuthorQuery; -use Propel\Tests\Bookstore\Book; use Propel\Tests\Bookstore\BookQuery; -use Propel\Tests\Bookstore\BookstoreEmployeeQuery; -use Propel\Tests\Bookstore\BookstoreEmployeeAccount; use Propel\Tests\Bookstore\BookReaderQuery; +use Propel\Tests\Bookstore\BookstoreEmployeeQuery; use Propel\Tests\Bookstore\BookSummaryQuery; use Propel\Tests\Bookstore\ReviewQuery; - -use Propel\Runtime\ActiveQuery\ModelWith; use Propel\Tests\TestCaseFixtures; /** @@ -30,7 +26,9 @@ */ class ModelWithTest extends TestCaseFixtures { - + /** + * @return void + */ public function testModelNameManyToOne() { $q = BookQuery::create() @@ -41,6 +39,9 @@ public function testModelNameManyToOne() $this->assertEquals('Propel\Tests\Bookstore\Author', $with->getModelName(), 'A ModelWith computes the model name from the join'); } + /** + * @return void + */ public function testModelNameOneToMany() { $q = AuthorQuery::create() @@ -51,6 +52,9 @@ public function testModelNameOneToMany() $this->assertEquals('Propel\Tests\Bookstore\Book', $with->getModelName(), 'A ModelWith computes the model name from the join'); } + /** + * @return void + */ public function testModelNameAlias() { $q = BookQuery::create() @@ -61,6 +65,9 @@ public function testModelNameAlias() $this->assertEquals('Propel\Tests\Bookstore\Author', $with->getModelName(), 'A ModelWith computes the model name from the join'); } + /** + * @return void + */ public function testRelationManyToOne() { $q = BookQuery::create() @@ -73,6 +80,9 @@ public function testRelationManyToOne() $this->assertFalse($with->isAdd(), 'A ModelWith computes the relation cardinality from the join'); } + /** + * @return void + */ public function testRelationOneToMany() { $q = AuthorQuery::create() @@ -85,6 +95,9 @@ public function testRelationOneToMany() $this->assertTrue($with->isAdd(), 'A ModelWith computes the relation cardinality from the join'); } + /** + * @return void + */ public function testRelationOneToOne() { $q = BookstoreEmployeeQuery::create() @@ -97,6 +110,9 @@ public function testRelationOneToOne() $this->assertFalse($with->isAdd(), 'A ModelWith computes the relation cardinality from the join'); } + /** + * @return void + */ public function testIsPrimary() { $q = AuthorQuery::create() @@ -123,6 +139,9 @@ public function testIsPrimary() $this->assertFalse($with->isPrimary(), 'A ModelWith initialized from a non-primary join is not primary'); } + /** + * @return void + */ public function testGetLeftPhpName() { $q = AuthorQuery::create() @@ -196,6 +215,9 @@ public function testGetLeftPhpName() $this->assertEquals('SummarizedBook', $with->getLeftPhpName(), 'A ModelWith uses the previous join relation name as left phpName'); } + /** + * @return void + */ public function testGetRightPhpName() { $q = AuthorQuery::create() diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/PropelQueryTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/PropelQueryTest.php index 28cfb37112..7524633c1e 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/PropelQueryTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/PropelQueryTest.php @@ -10,15 +10,15 @@ namespace Propel\Tests\Runtime\ActiveQuery; -use Propel\Runtime\Exception\ClassNotFoundException; use Propel\Runtime\ActiveQuery\PropelQuery; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; -use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; -use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\BookQuery; +use Propel\Runtime\Exception\ClassNotFoundException; +use Propel\Tests\Bookstore\Behavior\Map\Table6TableMap; use Propel\Tests\Bookstore\Behavior\Table6; use Propel\Tests\Bookstore\Behavior\Table6Query; -use Propel\Tests\Bookstore\Behavior\Map\Table6TableMap; +use Propel\Tests\Bookstore\Book; +use Propel\Tests\Bookstore\BookQuery; +use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Test class for PropelQuery @@ -29,13 +29,18 @@ */ class PropelQueryTest extends BookstoreTestBase { - + /** + * @return void + */ protected function setUp(): void { parent::setUp(); - include_once(__DIR__.'/PropelQueryTestClasses.php'); + include_once(__DIR__ . '/PropelQueryTestClasses.php'); } + /** + * @return void + */ public function testFrom() { $q = PropelQuery::from('\Propel\Tests\Bookstore\Book'); @@ -59,6 +64,9 @@ public function testFrom() } } + /** + * @return void + */ public function testQuery() { BookstoreDataPopulator::depopulate(); @@ -70,7 +78,6 @@ public function testQuery() ->findOne(); $this->assertTrue($book instanceof Book); $this->assertEquals('Don Juan', $book->getTitle()); - } /** @@ -79,6 +86,7 @@ public function testQuery() * Various test for filterById functions * Id's are autoincrement so we have to use a Select to get current ID's * + * @return void */ public function testFilterById() { @@ -112,7 +120,8 @@ public function testFilterById() $booksIn = BookQuery::create() ->filterById( - ['min' => $booksAll[2]->getId()]) + ['min' => $booksAll[2]->getId()] + ) ->find(); $this->assertTrue($booksIn[1] == $booksAll[3]); @@ -122,7 +131,8 @@ public function testFilterById() $booksIn = BookQuery::create() ->filterById( - ['max' => $booksAll[1]->getId()] ) + ['max' => $booksAll[1]->getId()] + ) ->find(); $this->assertTrue($booksIn[1] == $booksAll[1]); @@ -134,22 +144,26 @@ public function testFilterById() $minMax = BookQuery::create() ->filterById( - ['min' => $booksAll[1]->getId(), + [ + 'min' => $booksAll[1]->getId(), 'max' => $booksAll[2]->getId()] - ) + ) ->find(); $In = BookQuery::create() ->filterById( - [$booksAll[1]->getId(), + [$booksAll[1]->getId(), $booksAll[2]->getId()] - ) + ) ->find(); $this->assertTrue($minMax[0] === $In[0]); $this->assertTrue(count($minMax->getData()) === count($In->getData())); } + /** + * @return void + */ public function testInstancePool() { $object = new Table6(); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/PropelQueryTestClasses.php b/tests/Propel/Tests/Runtime/ActiveQuery/PropelQueryTestClasses.php index 00642056dd..1a73c9b7f7 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/PropelQueryTestClasses.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/PropelQueryTestClasses.php @@ -14,4 +14,4 @@ class myBookQuery extends BookQuery { -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/QuotingTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/QuotingTest.php index fccbf04fae..c179f16eb2 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/QuotingTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/QuotingTest.php @@ -10,8 +10,11 @@ namespace Propel\Tests\Runtime\ActiveQuery; -use Propel\Runtime\Connection\ConnectionWrapper; use Propel\Runtime\Propel; +use Propel\Tests\Quoting\AuthorQuery; +use Propel\Tests\Quoting\Group; +use Propel\Tests\Quoting\GroupQuery; +use Propel\Tests\Quoting\Map\GroupTableMap; use Propel\Tests\TestCaseFixturesDatabase; /** @@ -21,17 +24,20 @@ */ class QuotingTest extends TestCaseFixturesDatabase { - protected function getLastQuery() { - /** @var ConnectionWrapper $con */ - $con = Propel::getServiceContainer()->getWriteConnection(\Propel\Tests\Quoting\Map\GroupTableMap::DATABASE_NAME); + /** @var \Propel\Runtime\Connection\ConnectionWrapper $con */ + $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME); + return $con->getLastExecutedQuery(); } + /** + * @return void + */ public function testInsertQuery() { - $group = new \Propel\Tests\Quoting\Group(); + $group = new Group(); $group->setTitle('Test Group'); $group->setAs(3); $group->save(); @@ -46,39 +52,48 @@ public function testInsertQuery() $this->assertEquals($expected, $this->getLastQuery()); } + /** + * @return void + */ public function testDeleteQuery() { - $group = new \Propel\Tests\Quoting\Group(); + $group = new Group(); $group->setTitle('Test Group'); $group->setAs(4); $group->save(); $group->delete(); - $expected = $this->getSql("DELETE FROM `group` WHERE `group`.`id`=" . $group->getId()); + $expected = $this->getSql('DELETE FROM `group` WHERE `group`.`id`=' . $group->getId()); $this->assertEquals($expected, $this->getLastQuery()); } + /** + * @return void + */ public function testUpdateQuery() { - $group = new \Propel\Tests\Quoting\Group(); + $group = new Group(); $group->setTitle('Test Group'); $group->setAs(1); $group->save(); $group->setAs(2); $group->save(); - $expected = $this->getSql("UPDATE `group` SET `as`=2 WHERE `group`.`id`=" . $group->getId()); + $expected = $this->getSql('UPDATE `group` SET `as`=2 WHERE `group`.`id`=' . $group->getId()); $this->assertEquals($expected, $this->getLastQuery()); } + /** + * @return void + */ public function testJoinWithNonQuotingQuery() { - $groupQuery = \Propel\Tests\Quoting\GroupQuery::create(); + $groupQuery = GroupQuery::create(); $groupQuery ->joinAuthor() ->useAuthorQuery() - ->filterByName('Author filter') + ->filterByName('Author filter') ->endUse() ->with('Author') ->find(); @@ -87,15 +102,17 @@ public function testJoinWithNonQuotingQuery() $this->assertEquals($expected, $this->getLastQuery()); } - + /** + * @return void + */ public function testJoinWithQuotingQuery() { - $authorQuery = \Propel\Tests\Quoting\AuthorQuery::create(); + $authorQuery = AuthorQuery::create(); $authorQuery ->joinAuthorType() ->useAuthorTypeQuery() - ->filterByTitle('Author type title') + ->filterByTitle('Author type title') ->endUse() ->with('AuthorType') ->find(); @@ -104,61 +121,64 @@ public function testJoinWithQuotingQuery() $this->assertEquals($expected, $this->getLastQuery()); } + /** + * @return void + */ public function testAlias() { - \Propel\Tests\Quoting\GroupQuery::create() - ->setModelAlias('g', true) - ->where('g.Id > 0') - ->orderBy('g.As') - ->orderBy('AuthorId') - ->find(); - - $expected = $this->getSql("SELECT `g`.`id`, `g`.`title`, `g`.`by`, `g`.`as`, `g`.`author_id` FROM `group` `g` WHERE `g`.`id` > 0 ORDER BY `g`.`as` ASC,`g`.`author_id` ASC"); + GroupQuery::create() + ->setModelAlias('g', true) + ->where('g.Id > 0') + ->orderBy('g.As') + ->orderBy('AuthorId') + ->find(); + + $expected = $this->getSql('SELECT `g`.`id`, `g`.`title`, `g`.`by`, `g`.`as`, `g`.`author_id` FROM `group` `g` WHERE `g`.`id` > 0 ORDER BY `g`.`as` ASC,`g`.`author_id` ASC'); $this->assertEquals($expected, $this->getLastQuery()); - \Propel\Tests\Quoting\AuthorQuery::create('g') - ->setModelAlias('g', true) - ->groupBy('g.Id') - ->having('g.Id > 0') - ->find(); + AuthorQuery::create('g') + ->setModelAlias('g', true) + ->groupBy('g.Id') + ->having('g.Id > 0') + ->find(); if ($this->runningOnPostgreSQL()) { - $expected = $this->getSql("SELECT g.id, g.name, g.type_id FROM quoting_author g GROUP BY g.id,g.name,g.type_id HAVING g.id > 0"); + $expected = $this->getSql('SELECT g.id, g.name, g.type_id FROM quoting_author g GROUP BY g.id,g.name,g.type_id HAVING g.id > 0'); } else { - $expected = $this->getSql( "SELECT g.id, g.name, g.type_id FROM quoting_author g GROUP BY g.id HAVING g.id > 0"); + $expected = $this->getSql('SELECT g.id, g.name, g.type_id FROM quoting_author g GROUP BY g.id HAVING g.id > 0'); } $this->assertEquals($expected, $this->getLastQuery()); - \Propel\Tests\Quoting\GroupQuery::create('g') - ->where('g.As > 0') - ->find(); + GroupQuery::create('g') + ->where('g.As > 0') + ->find(); - $expected = $this->getSql("SELECT `group`.`id`, `group`.`title`, `group`.`by`, `group`.`as`, `group`.`author_id` FROM `group` WHERE `group`.`as` > 0"); + $expected = $this->getSql('SELECT `group`.`id`, `group`.`title`, `group`.`by`, `group`.`as`, `group`.`author_id` FROM `group` WHERE `group`.`as` > 0'); $this->assertEquals($expected, $this->getLastQuery()); - \Propel\Tests\Quoting\AuthorQuery::create('g') - ->where('g.Id > 0') - ->find(); + AuthorQuery::create('g') + ->where('g.Id > 0') + ->find(); - $expected = $this->getSql("SELECT quoting_author.id, quoting_author.name, quoting_author.type_id FROM quoting_author WHERE quoting_author.id > 0"); + $expected = $this->getSql('SELECT quoting_author.id, quoting_author.name, quoting_author.type_id FROM quoting_author WHERE quoting_author.id > 0'); $this->assertEquals($expected, $this->getLastQuery()); } + /** + * @return void + */ public function testHaving() { - \Propel\Tests\Quoting\GroupQuery::create() - ->groupBy('group.As') - ->having('group.As > 0') - ->find(); + GroupQuery::create() + ->groupBy('group.As') + ->having('group.As > 0') + ->find(); if ($this->runningOnPostgreSQL()) { - $expected = $this->getSql("SELECT `group`.`id`, `group`.`title`, `group`.`by`, `group`.`as`, `group`.`author_id` FROM `group` GROUP BY `group`.`as`,`group`.`id`,`group`.`title`,`group`.`by`,`group`.`author_id` HAVING `group`.`as` > 0"); + $expected = $this->getSql('SELECT `group`.`id`, `group`.`title`, `group`.`by`, `group`.`as`, `group`.`author_id` FROM `group` GROUP BY `group`.`as`,`group`.`id`,`group`.`title`,`group`.`by`,`group`.`author_id` HAVING `group`.`as` > 0'); } else { - $expected = $this->getSql("SELECT `group`.`id`, `group`.`title`, `group`.`by`, `group`.`as`, `group`.`author_id` FROM `group` GROUP BY `group`.`as` HAVING `group`.`as` > 0"); + $expected = $this->getSql('SELECT `group`.`id`, `group`.`title`, `group`.`by`, `group`.`as`, `group`.`author_id` FROM `group` GROUP BY `group`.`as` HAVING `group`.`as` > 0'); } $this->assertEquals($expected, $this->getLastQuery()); - } - - -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/SubQueryTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/SubQueryTest.php index b99581195a..f16ee964b3 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/SubQueryTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/SubQueryTest.php @@ -10,12 +10,11 @@ namespace Propel\Tests\Runtime\ActiveQuery; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\BookQuery; use Propel\Tests\Bookstore\Map\BookTableMap; - -use Propel\Runtime\Propel; -use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Test class for SubQueryTest. @@ -26,12 +25,18 @@ */ class SubQueryTest extends BookstoreTestBase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); - include_once(__DIR__.'/SubQueryTestClasses.php'); + include_once(__DIR__ . '/SubQueryTestClasses.php'); } + /** + * @return void + */ protected function assertCriteriaTranslation($criteria, $expectedSql, $expectedParams, $message = '') { $params = []; @@ -41,6 +46,9 @@ protected function assertCriteriaTranslation($criteria, $expectedSql, $expectedP $this->assertEquals($expectedParams, $params, $message); } + /** + * @return void + */ public function testSubQueryExplicit() { $subCriteria = new BookQuery(); @@ -53,15 +61,18 @@ public function testSubQueryExplicit() $c->groupBy('subCriteriaAlias.AuthorId'); if ($this->isDb('pgsql')) { - $sql = $this->getSql("SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book ORDER BY book.title ASC) AS subCriteriaAlias GROUP BY subCriteriaAlias.author_id,subCriteriaAlias.id,subCriteriaAlias.title,subCriteriaAlias.isbn,subCriteriaAlias.price,subCriteriaAlias.publisher_id"); + $sql = $this->getSql('SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book ORDER BY book.title ASC) AS subCriteriaAlias GROUP BY subCriteriaAlias.author_id,subCriteriaAlias.id,subCriteriaAlias.title,subCriteriaAlias.isbn,subCriteriaAlias.price,subCriteriaAlias.publisher_id'); } else { - $sql = $this->getSql("SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book ORDER BY book.title ASC) AS subCriteriaAlias GROUP BY subCriteriaAlias.author_id"); + $sql = $this->getSql('SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book ORDER BY book.title ASC) AS subCriteriaAlias GROUP BY subCriteriaAlias.author_id'); } $params = []; $this->assertCriteriaTranslation($c, $sql, $params, 'addSubQueryCriteriaInFrom() combines two queries successfully'); } + /** + * @return void + */ public function testSubQueryWithoutSelect() { $subCriteria = new BookQuery(); @@ -71,7 +82,7 @@ public function testSubQueryWithoutSelect() $c->addSelectQuery($subCriteria, 'subCriteriaAlias'); $c->filterByPrice(20, Criteria::LESS_THAN); - $sql = $this->getSql("SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book) AS subCriteriaAlias WHERE subCriteriaAlias.price<:p1"); + $sql = $this->getSql('SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book) AS subCriteriaAlias WHERE subCriteriaAlias.price<:p1'); $params = [ ['table' => 'book', 'column' => 'price', 'value' => 20], @@ -79,6 +90,9 @@ public function testSubQueryWithoutSelect() $this->assertCriteriaTranslation($c, $sql, $params, 'addSelectQuery() adds select columns if none given'); } + /** + * @return void + */ public function testSubQueryWithoutAlias() { $subCriteria = new BookQuery(); @@ -88,7 +102,7 @@ public function testSubQueryWithoutAlias() $c->addSelectQuery($subCriteria); // no alias $c->filterByPrice(20, Criteria::LESS_THAN); - $sql = $this->getSql("SELECT alias_1.id, alias_1.title, alias_1.isbn, alias_1.price, alias_1.publisher_id, alias_1.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book) AS alias_1 WHERE alias_1.price<:p1"); + $sql = $this->getSql('SELECT alias_1.id, alias_1.title, alias_1.isbn, alias_1.price, alias_1.publisher_id, alias_1.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book) AS alias_1 WHERE alias_1.price<:p1'); $params = [ ['table' => 'book', 'column' => 'price', 'value' => 20], @@ -96,6 +110,9 @@ public function testSubQueryWithoutAlias() $this->assertCriteriaTranslation($c, $sql, $params, 'addSelectQuery() forges a unique alias if none is given'); } + /** + * @return void + */ public function testSubQueryWithoutAliasAndSelect() { $subCriteria = new BookQuery(); @@ -105,7 +122,7 @@ public function testSubQueryWithoutAliasAndSelect() $c->addSelectQuery($subCriteria); // no alias $c->filterByPrice(20, Criteria::LESS_THAN); - $sql = $this->getSql("SELECT alias_1.id, alias_1.title, alias_1.isbn, alias_1.price, alias_1.publisher_id, alias_1.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book) AS alias_1 WHERE alias_1.price<:p1"); + $sql = $this->getSql('SELECT alias_1.id, alias_1.title, alias_1.isbn, alias_1.price, alias_1.publisher_id, alias_1.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book) AS alias_1 WHERE alias_1.price<:p1'); $params = [ ['table' => 'book', 'column' => 'price', 'value' => 20], @@ -113,6 +130,9 @@ public function testSubQueryWithoutAliasAndSelect() $this->assertCriteriaTranslation($c, $sql, $params, 'addSelectQuery() forges a unique alias and adds select columns by default'); } + /** + * @return void + */ public function testSubQueryWithoutAliasSeveral() { $c1 = new BookQuery(); @@ -126,7 +146,7 @@ public function testSubQueryWithoutAliasSeveral() $c3->addSelectQuery($c2); // no alias $c3->filterByTitle('War%', Criteria::LIKE); - $sql = $this->getSql("SELECT alias_1.id, alias_1.title, alias_1.isbn, alias_1.price, alias_1.publisher_id, alias_1.author_id, alias_2.id, alias_2.title, alias_2.isbn, alias_2.price, alias_2.publisher_id, alias_2.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.price>:p2) AS alias_1, (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.price<:p3) AS alias_2 WHERE alias_2.title LIKE :p1"); + $sql = $this->getSql('SELECT alias_1.id, alias_1.title, alias_1.isbn, alias_1.price, alias_1.publisher_id, alias_1.author_id, alias_2.id, alias_2.title, alias_2.isbn, alias_2.price, alias_2.publisher_id, alias_2.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.price>:p2) AS alias_1, (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.price<:p3) AS alias_2 WHERE alias_2.title LIKE :p1'); $params = [ ['table' => 'book', 'column' => 'title', 'value' => 'War%'], @@ -137,6 +157,9 @@ public function testSubQueryWithoutAliasSeveral() $this->assertCriteriaTranslation($c3, $sql, $params, 'addSelectQuery() forges a unique alias if none is given'); } + /** + * @return void + */ public function testSubQueryWithoutAliasRecursive() { $c1 = new BookQuery(); @@ -149,7 +172,7 @@ public function testSubQueryWithoutAliasRecursive() $c3->addSelectQuery($c2); // no alias $c3->filterByTitle('War%', Criteria::LIKE); - $sql = $this->getSql("SELECT alias_2.id, alias_2.title, alias_2.isbn, alias_2.price, alias_2.publisher_id, alias_2.author_id FROM (SELECT alias_1.id, alias_1.title, alias_1.isbn, alias_1.price, alias_1.publisher_id, alias_1.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book) AS alias_1 WHERE alias_1.price<:p2) AS alias_2 WHERE alias_2.title LIKE :p1"); + $sql = $this->getSql('SELECT alias_2.id, alias_2.title, alias_2.isbn, alias_2.price, alias_2.publisher_id, alias_2.author_id FROM (SELECT alias_1.id, alias_1.title, alias_1.isbn, alias_1.price, alias_1.publisher_id, alias_1.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book) AS alias_1 WHERE alias_1.price<:p2) AS alias_2 WHERE alias_2.title LIKE :p1'); $params = [ ['table' => 'book', 'column' => 'title', 'value' => 'War%'], @@ -158,6 +181,9 @@ public function testSubQueryWithoutAliasRecursive() $this->assertCriteriaTranslation($c3, $sql, $params, 'addSelectQuery() forges a unique alias if none is given'); } + /** + * @return void + */ public function testSubQueryWithJoin() { $c1 = BookQuery::create() @@ -169,7 +195,7 @@ public function testSubQueryWithJoin() $c2->addSelectQuery($c1, 'subQuery'); $c2->filterByPrice(20, Criteria::LESS_THAN); - $sql = $this->getSql("SELECT subQuery.id, subQuery.title, subQuery.isbn, subQuery.price, subQuery.publisher_id, subQuery.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book LEFT JOIN author ON (book.author_id=author.id) WHERE author.last_name=:p2) AS subQuery WHERE subQuery.price<:p1"); + $sql = $this->getSql('SELECT subQuery.id, subQuery.title, subQuery.isbn, subQuery.price, subQuery.publisher_id, subQuery.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book LEFT JOIN author ON (book.author_id=author.id) WHERE author.last_name=:p2) AS subQuery WHERE subQuery.price<:p1'); $params = [ ['table' => 'book', 'column' => 'price', 'value' => 20], @@ -178,6 +204,9 @@ public function testSubQueryWithJoin() $this->assertCriteriaTranslation($c2, $sql, $params, 'addSelectQuery() can add a select query with a join'); } + /** + * @return void + */ public function testSubQueryParameters() { $subCriteria = new BookQuery(); @@ -188,7 +217,7 @@ public function testSubQueryParameters() // and use filterByPrice method! $c->filterByPrice(20, Criteria::LESS_THAN); - $sql = $this->getSql("SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.author_id=:p2) AS subCriteriaAlias WHERE subCriteriaAlias.price<:p1"); + $sql = $this->getSql('SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.author_id=:p2) AS subCriteriaAlias WHERE subCriteriaAlias.price<:p1'); $params = [ ['table' => 'book', 'column' => 'price', 'value' => 20], @@ -197,6 +226,9 @@ public function testSubQueryParameters() $this->assertCriteriaTranslation($c, $sql, $params, 'addSubQueryCriteriaInFrom() combines two queries successfully'); } + /** + * @return void + */ public function testSubQueryRecursive() { // sort the books (on date, if equal continue with id), filtered by a publisher @@ -217,19 +249,19 @@ public function testSubQueryRecursive() $c->filterByPrice(12, Criteria::LESS_THAN); if ($this->isDb('pgsql')) { - $sql = $this->getSql("SELECT latestBookQuery.id, latestBookQuery.title, latestBookQuery.isbn, latestBookQuery.price, latestBookQuery.publisher_id, latestBookQuery.author_id ". - "FROM (SELECT sortedBookQuery.id, sortedBookQuery.title, sortedBookQuery.isbn, sortedBookQuery.price, sortedBookQuery.publisher_id, sortedBookQuery.author_id FROM ". - "(SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.publisher_id=:p2 ORDER BY book.title DESC,book.id DESC) AS sortedBookQuery ". - "GROUP BY sortedBookQuery.author_id,sortedBookQuery.id,sortedBookQuery.title,sortedBookQuery.isbn,sortedBookQuery.price,sortedBookQuery.publisher_id) AS latestBookQuery WHERE latestBookQuery.price<:p1"); + $sql = $this->getSql('SELECT latestBookQuery.id, latestBookQuery.title, latestBookQuery.isbn, latestBookQuery.price, latestBookQuery.publisher_id, latestBookQuery.author_id ' . + 'FROM (SELECT sortedBookQuery.id, sortedBookQuery.title, sortedBookQuery.isbn, sortedBookQuery.price, sortedBookQuery.publisher_id, sortedBookQuery.author_id FROM ' . + '(SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.publisher_id=:p2 ORDER BY book.title DESC,book.id DESC) AS sortedBookQuery ' . + 'GROUP BY sortedBookQuery.author_id,sortedBookQuery.id,sortedBookQuery.title,sortedBookQuery.isbn,sortedBookQuery.price,sortedBookQuery.publisher_id) AS latestBookQuery WHERE latestBookQuery.price<:p1'); } else { - $sql = $this->getSql("SELECT latestBookQuery.id, latestBookQuery.title, latestBookQuery.isbn, latestBookQuery.price, latestBookQuery.publisher_id, latestBookQuery.author_id ". - "FROM (SELECT sortedBookQuery.id, sortedBookQuery.title, sortedBookQuery.isbn, sortedBookQuery.price, sortedBookQuery.publisher_id, sortedBookQuery.author_id ". - "FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id ". - "FROM book ". - "WHERE book.publisher_id=:p2 ". - "ORDER BY book.title DESC,book.id DESC) AS sortedBookQuery ". - "GROUP BY sortedBookQuery.author_id) AS latestBookQuery ". - "WHERE latestBookQuery.price<:p1"); + $sql = $this->getSql('SELECT latestBookQuery.id, latestBookQuery.title, latestBookQuery.isbn, latestBookQuery.price, latestBookQuery.publisher_id, latestBookQuery.author_id ' . + 'FROM (SELECT sortedBookQuery.id, sortedBookQuery.title, sortedBookQuery.isbn, sortedBookQuery.price, sortedBookQuery.publisher_id, sortedBookQuery.author_id ' . + 'FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id ' . + 'FROM book ' . + 'WHERE book.publisher_id=:p2 ' . + 'ORDER BY book.title DESC,book.id DESC) AS sortedBookQuery ' . + 'GROUP BY sortedBookQuery.author_id) AS latestBookQuery ' . + 'WHERE latestBookQuery.price<:p1'); } $params = [ @@ -239,6 +271,9 @@ public function testSubQueryRecursive() $this->assertCriteriaTranslation($c, $sql, $params, 'addSubQueryCriteriaInFrom() combines two queries successfully'); } + /** + * @return void + */ public function testSubQueryWithSelectColumns() { $subCriteria = new BookQuery(); @@ -248,12 +283,15 @@ public function testSubQueryWithSelectColumns() $c->select(['alias1.Id']); $c->configureSelectColumns(); - $sql = $this->getSql("SELECT alias1.id AS \"alias1.Id\" FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book) AS alias1"); + $sql = $this->getSql('SELECT alias1.id AS "alias1.Id" FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book) AS alias1'); $params = []; $this->assertCriteriaTranslation($c, $sql, $params, 'addSelectQuery() forges a unique alias and adds select columns by default'); } + /** + * @return void + */ public function testSubQueryCount() { $subCriteria = new BookQuery(); @@ -265,7 +303,7 @@ public function testSubQueryCount() $query = Propel::getConnection()->getLastExecutedQuery(); - $sql = $this->getSql("SELECT COUNT(*) FROM (SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book) AS subCriteriaAlias WHERE subCriteriaAlias.price<20) propelmatch4cnt"); + $sql = $this->getSql('SELECT COUNT(*) FROM (SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book) AS subCriteriaAlias WHERE subCriteriaAlias.price<20) propelmatch4cnt'); $this->assertEquals($sql, $query, 'addSelectQuery() doCount is defined as complexQuery'); } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/TestableModelCriteria.php b/tests/Propel/Tests/Runtime/ActiveQuery/TestableModelCriteria.php index 8f507abaf4..6fa5c15558 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/TestableModelCriteria.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/TestableModelCriteria.php @@ -12,5 +12,4 @@ public function replaceNames(&$sql) { return parent::replaceNames($sql); } - } diff --git a/tests/Propel/Tests/Runtime/ActiveRecordConvertTest.php b/tests/Propel/Tests/Runtime/ActiveRecordConvertTest.php index bc0b8b7302..acf2649284 100644 --- a/tests/Propel/Tests/Runtime/ActiveRecordConvertTest.php +++ b/tests/Propel/Tests/Runtime/ActiveRecordConvertTest.php @@ -24,6 +24,9 @@ class ActiveRecordConvertTest extends TestCaseFixtures { private $book; + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -81,6 +84,8 @@ public function toXmlDataProvider() /** * @dataProvider toXmlDataProvider + * + * @return void */ public function testToXML($expected) { @@ -89,6 +94,8 @@ public function testToXML($expected) /** * @dataProvider toXmlDataProvider + * + * @return void */ public function testFromXML($expected) { @@ -137,6 +144,8 @@ public function toYamlDataProvider() /** * @dataProvider toYamlDataProvider + * + * @return void */ public function testToYAML($expected) { @@ -145,6 +154,8 @@ public function testToYAML($expected) /** * @dataProvider toYamlDataProvider + * + * @return void */ public function testFromYAML($expected) { @@ -174,6 +185,8 @@ public function toJsonDataProvider() /** * @dataProvider toJsonDataProvider + * + * @return void */ public function testToJSON($expected) { @@ -182,6 +195,8 @@ public function testToJSON($expected) /** * @dataProvider toJsonDataProvider + * + * @return void */ public function testfromJSON($expected) { @@ -209,6 +224,8 @@ public function toCsvDataProvider() /** * @dataProvider toCsvDataProvider + * + * @return void */ public function testToCSV($expected) { @@ -217,6 +234,8 @@ public function testToCSV($expected) /** * @dataProvider toCsvDataProvider + * + * @return void */ public function testfromCSV($expected) { @@ -234,5 +253,4 @@ public function testfromCSV($expected) $this->assertEquals($this->book, $book); } - } diff --git a/tests/Propel/Tests/Runtime/ActiveRecordSerializeTest.php b/tests/Propel/Tests/Runtime/ActiveRecordSerializeTest.php index 9fdda29154..623cc40b1b 100644 --- a/tests/Propel/Tests/Runtime/ActiveRecordSerializeTest.php +++ b/tests/Propel/Tests/Runtime/ActiveRecordSerializeTest.php @@ -10,11 +10,11 @@ namespace Propel\Tests\Runtime\ActiveRecord; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\Book; use Propel\Tests\Bookstore\BookQuery; use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Test class for ActiveRecord serialization. @@ -25,6 +25,9 @@ */ class ActiveRecordSerializeTest extends BookstoreTestBase { + /** + * @return void + */ public function testSerializeEmptyObject() { $book = new Book(); @@ -32,6 +35,9 @@ public function testSerializeEmptyObject() $this->assertEquals($book, unserialize($sb)); } + /** + * @return void + */ public function testSerializePopulatedObject() { $book = new Book(); @@ -41,6 +47,9 @@ public function testSerializePopulatedObject() $this->assertEquals($book, unserialize($sb)); } + /** + * @return void + */ public function testSerializePersistedObject() { $book = new Book(); @@ -51,6 +60,9 @@ public function testSerializePersistedObject() $this->assertEquals($book, unserialize($sb)); } + /** + * @return void + */ public function testSerializeHydratedObject() { $book = new Book(); @@ -64,6 +76,9 @@ public function testSerializeHydratedObject() $this->assertEquals($book, unserialize($sb)); } + /** + * @return void + */ public function testSerializeObjectWithRelations() { $author = new Author(); @@ -80,6 +95,9 @@ public function testSerializeObjectWithRelations() $this->assertEquals($book, unserialize($sb)); } + /** + * @return void + */ public function testSerializeObjectWithCollections() { $book1 = new Book(); diff --git a/tests/Propel/Tests/Runtime/ActiveRecordTest.php b/tests/Propel/Tests/Runtime/ActiveRecordTest.php index a4c15ff856..5c7bd362d7 100644 --- a/tests/Propel/Tests/Runtime/ActiveRecordTest.php +++ b/tests/Propel/Tests/Runtime/ActiveRecordTest.php @@ -10,7 +10,6 @@ namespace Propel\Tests\Runtime\ActiveRecord; -use Propel\Tests\Bookstore\Book; use Propel\Tests\TestCase; /** @@ -20,12 +19,18 @@ */ class ActiveRecordTest extends TestCase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); - include_once(__DIR__.'/ActiveRecordTestClasses.php'); + include_once(__DIR__ . '/ActiveRecordTestClasses.php'); } + /** + * @return void + */ public function testGetVirtualColumns() { $b = new TestableActiveRecord(); @@ -34,6 +39,9 @@ public function testGetVirtualColumns() $this->assertEquals(['foo' => 'bar'], $b->getVirtualColumns(), 'getVirtualColumns() returns an associative array of virtual columns'); } + /** + * @return void + */ public function testHasVirtualColumn() { $b = new TestableActiveRecord(); @@ -46,6 +54,8 @@ public function testHasVirtualColumn() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testGetVirtualColumnWrongKey() { @@ -53,6 +63,9 @@ public function testGetVirtualColumnWrongKey() $b->getVirtualColumn('foo'); } + /** + * @return void + */ public function testGetVirtualColumn() { $b = new TestableActiveRecord(); @@ -60,6 +73,9 @@ public function testGetVirtualColumn() $this->assertEquals('bar', $b->getVirtualColumn('foo'), 'getVirtualColumn() returns a virtual column value based on its key'); } + /** + * @return void + */ public function testSetVirtualColumn() { $b = new TestableActiveRecord(); diff --git a/tests/Propel/Tests/Runtime/Adapter/AbstractAdapterTest.php b/tests/Propel/Tests/Runtime/Adapter/AbstractAdapterTest.php index e0721f6c9b..e2edd4d981 100644 --- a/tests/Propel/Tests/Runtime/Adapter/AbstractAdapterTest.php +++ b/tests/Propel/Tests/Runtime/Adapter/AbstractAdapterTest.php @@ -10,19 +10,22 @@ namespace Propel\Tests\Runtime\Adapter; -use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\TestCaseFixtures; /** * Tests the DbOracle adapter * - * @see BookstoreDataPopulator + * @see BookstoreDataPopulator * @author Francois EZaninotto */ class AbstractAdapterTest extends TestCaseFixtures { + /** + * @return void + */ public function testTurnSelectColumnsToAliases() { $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME); @@ -35,6 +38,9 @@ public function testTurnSelectColumnsToAliases() $this->assertTrue($c1->equals($c2)); } + /** + * @return void + */ public function testTurnSelectColumnsToAliasesPreservesAliases() { $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME); @@ -49,6 +55,9 @@ public function testTurnSelectColumnsToAliasesPreservesAliases() $this->assertTrue($c1->equals($c2)); } + /** + * @return void + */ public function testTurnSelectColumnsToAliasesExisting() { $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME); @@ -63,6 +72,9 @@ public function testTurnSelectColumnsToAliasesExisting() $this->assertTrue($c1->equals($c2)); } + /** + * @return void + */ public function testTurnSelectColumnsToAliasesDuplicate() { $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME); @@ -77,6 +89,9 @@ public function testTurnSelectColumnsToAliasesDuplicate() $this->assertTrue($c1->equals($c2)); } + /** + * @return void + */ public function testCreateSelectSqlPart() { $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME); @@ -89,18 +104,24 @@ public function testCreateSelectSqlPart() $this->assertEquals(['book'], $fromClause, 'createSelectSqlPart() adds the tables from the select columns to the from clause'); } + /** + * @return void + */ public function testCreateSelectSqlPartWithFnc() { $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME); $c = new Criteria(); $c->addSelectColumn(BookTableMap::COL_ID); - $c->addAsColumn('book_id', 'IF(1, '.BookTableMap::COL_ID.', '.BookTableMap::COL_TITLE.')'); + $c->addAsColumn('book_id', 'IF(1, ' . BookTableMap::COL_ID . ', ' . BookTableMap::COL_TITLE . ')'); $fromClause = []; $selectSql = $db->createSelectSqlPart($c, $fromClause); $this->assertEquals('SELECT book.id, IF(1, book.id, book.title) AS book_id', $selectSql, 'createSelectSqlPart() returns a SQL SELECT clause with both select and as columns'); $this->assertEquals(['book'], $fromClause, 'createSelectSqlPart() adds the tables from the select columns to the from clause'); } + /** + * @return void + */ public function testCreateSelectSqlPartSelectModifier() { $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME); @@ -114,6 +135,9 @@ public function testCreateSelectSqlPartSelectModifier() $this->assertEquals(['book'], $fromClause, 'createSelectSqlPart() adds the tables from the select columns to the from clause'); } + /** + * @return void + */ public function testCreateSelectSqlPartAliasAll() { $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME); @@ -125,5 +149,4 @@ public function testCreateSelectSqlPartAliasAll() $this->assertEquals('SELECT book.id AS book_id_1, book.id AS book_id', $selectSql, 'createSelectSqlPart() aliases all columns if passed true as last parameter'); $this->assertEquals([], $fromClause, 'createSelectSqlPart() does not add the tables from an all-aliased list of select columns'); } - } diff --git a/tests/Propel/Tests/Runtime/Adapter/Pdo/MssqlAdapterTest.php b/tests/Propel/Tests/Runtime/Adapter/Pdo/MssqlAdapterTest.php index 50fc2a0770..5fad166b4f 100644 --- a/tests/Propel/Tests/Runtime/Adapter/Pdo/MssqlAdapterTest.php +++ b/tests/Propel/Tests/Runtime/Adapter/Pdo/MssqlAdapterTest.php @@ -10,14 +10,12 @@ namespace Propel\Tests\Runtime\Adapter\Pdo; -use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Adapter\Pdo\MssqlAdapter; - -use Propel\Tests\TestCase; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Map\BookTableMap; -use Propel\Tests\Bookstore\BookQuery; +use Propel\Tests\TestCase; /** * Tests the MSSQL adapter @@ -29,7 +27,7 @@ class MssqlAdapterTest extends TestCase /** * The criteria to use in the test. * - * @var Criteria + * @var \Propel\Runtime\ActiveQuery\Criteria */ private $c; @@ -40,6 +38,9 @@ class MssqlAdapterTest extends TestCase */ private $savedAdapter; + /** + * @return void + */ protected function setUp(): void { Propel::init(__DIR__ . '/../../../../../Fixtures/bookstore/build/conf/bookstore-conf.php'); @@ -58,6 +59,9 @@ protected function setUp(): void ); } + /** + * @return void + */ protected function tearDown(): void { Propel::getServiceContainer()->setAdapter( @@ -75,6 +79,8 @@ protected function getDriver() /** * Test `applyLimit` with no offsetting + * + * @return void */ public function testApplyLimitZeroOffset() { @@ -95,6 +101,8 @@ public function testApplyLimitZeroOffset() /** * Test `applyLimit` with page offsetting + * + * @return void */ public function testApplyLimitOffset() { @@ -115,6 +123,8 @@ public function testApplyLimitOffset() /** * Test `applyLimit` with no offsetting and additional virtual columns + * + * @return void */ public function testApplyLimitZeroOffsetWithVirtualColumns() { @@ -140,6 +150,8 @@ public function testApplyLimitZeroOffsetWithVirtualColumns() /** * Test `applyLimit` with page offsetting and additional virtual columns + * + * @return void */ public function testApplyLimitOffsetWithVirtualColumns() { @@ -165,6 +177,8 @@ public function testApplyLimitOffsetWithVirtualColumns() /** * Test `applyLimit` with no offsetting and a subquery in the WHERE clause + * + * @return void */ public function testApplyLimitZeroOffsetWithSubquery() { @@ -186,6 +200,8 @@ public function testApplyLimitZeroOffsetWithSubquery() /** * Test `applyLimit` with page offsetting and a subquery in the WHERE clause + * + * @return void */ public function testApplyLimitOffsetWithSubquery() { @@ -208,6 +224,8 @@ public function testApplyLimitOffsetWithSubquery() /** * Regression: Ensure correct parsing when `from` is used as a non-keyword * e.g. as a column name + * + * @return void */ public function testApplyLimitWithFromNonKeyword() { diff --git a/tests/Propel/Tests/Runtime/Adapter/Pdo/MysqlAdapterTest.php b/tests/Propel/Tests/Runtime/Adapter/Pdo/MysqlAdapterTest.php index 17b6355f69..9f3f3899ae 100644 --- a/tests/Propel/Tests/Runtime/Adapter/Pdo/MysqlAdapterTest.php +++ b/tests/Propel/Tests/Runtime/Adapter/Pdo/MysqlAdapterTest.php @@ -10,16 +10,13 @@ namespace Propel\Tests\Runtime\Adapter\Pdo; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; - -use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Adapter\Pdo\MysqlAdapter; use Propel\Tests\TestCaseFixtures; /** * Tests the DbMySQL adapter * - * @see BookstoreDataPopulator + * @see BookstoreDataPopulator * @author William Durand */ class MysqlAdapterTest extends TestCaseFixtures @@ -31,15 +28,17 @@ public static function getConParams() [ 'dsn' => 'dsn=my_dsn', 'settings' => [ - 'charset' => 'foobar' - ] - ] - ] + 'charset' => 'foobar', + ], + ], + ], ]; } /** * @dataProvider getConParams + * + * @return void */ public function testPrepareParamsThrowsException($conparams) { @@ -49,6 +48,8 @@ public function testPrepareParamsThrowsException($conparams) /** * @dataProvider getConParams + * + * @return void */ public function testPrepareParams($conparams) { @@ -62,6 +63,8 @@ public function testPrepareParams($conparams) /** * @dataProvider getConParams + * + * @return void */ public function testNoSetNameQueryExecuted($conparams) { diff --git a/tests/Propel/Tests/Runtime/Adapter/Pdo/OracleAdapterTest.php b/tests/Propel/Tests/Runtime/Adapter/Pdo/OracleAdapterTest.php index c3d755f5c1..38a9da1c9e 100644 --- a/tests/Propel/Tests/Runtime/Adapter/Pdo/OracleAdapterTest.php +++ b/tests/Propel/Tests/Runtime/Adapter/Pdo/OracleAdapterTest.php @@ -10,10 +10,9 @@ namespace Propel\Tests\Runtime\Adapter\Pdo; -use Propel\Runtime\Propel; -use Propel\Runtime\Adapter\Pdo\OracleAdapter; use Propel\Runtime\ActiveQuery\Criteria; - +use Propel\Runtime\Adapter\Pdo\OracleAdapter; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\TestCaseFixtures; @@ -21,11 +20,14 @@ /** * Tests the DbOracle adapter * - * @see BookstoreDataPopulator + * @see BookstoreDataPopulator * @author Francois EZaninotto */ class OracleAdapterTest extends TestCaseFixtures { + /** + * @return void + */ public function testApplyLimitSimple() { Propel::getServiceContainer()->setAdapter('oracle', new OracleAdapter()); @@ -38,6 +40,9 @@ public function testApplyLimitSimple() $this->assertEquals('SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book) A ) B WHERE B.PROPEL_ROWNUM <= 1', $sql, 'applyLimit() creates a subselect with the original column names by default'); } + /** + * @return void + */ public function testApplyLimitDuplicateColumnName() { Propel::getServiceContainer()->setAdapter('oracle', new OracleAdapter()); @@ -51,6 +56,9 @@ public function testApplyLimitDuplicateColumnName() $this->assertEquals('SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.id AS ORA_COL_ALIAS_0, book.title AS ORA_COL_ALIAS_1, book.isbn AS ORA_COL_ALIAS_2, book.price AS ORA_COL_ALIAS_3, book.publisher_id AS ORA_COL_ALIAS_4, book.author_id AS ORA_COL_ALIAS_5, author.id AS ORA_COL_ALIAS_6, author.first_name AS ORA_COL_ALIAS_7, author.last_name AS ORA_COL_ALIAS_8, author.email AS ORA_COL_ALIAS_9, author.age AS ORA_COL_ALIAS_10 FROM book, author) A ) B WHERE B.PROPEL_ROWNUM <= 1', $sql, 'applyLimit() creates a subselect with aliased column names when a duplicate column name is found'); } + /** + * @return void + */ public function testApplyLimitDuplicateColumnNameWithColumn() { Propel::getServiceContainer()->setAdapter('oracle', new OracleAdapter()); @@ -67,6 +75,9 @@ public function testApplyLimitDuplicateColumnNameWithColumn() $this->assertEquals($asColumns, $c->getAsColumns(), 'createSelectSql supplementary add alias column'); } + /** + * @return void + */ public function testCreateSelectSqlPart() { Propel::getServiceContainer()->setAdapter('oracle', new OracleAdapter()); @@ -79,5 +90,4 @@ public function testCreateSelectSqlPart() $this->assertEquals('SELECT book.id, book.id AS book_ID', $selectSql, 'createSelectSqlPart() returns a SQL SELECT clause with both select and as columns'); $this->assertEquals(['book'], $fromClause, 'createSelectSqlPart() adds the tables from the select columns to the from clause'); } - } diff --git a/tests/Propel/Tests/Runtime/Adapter/Pdo/PgsqlAdapter.php b/tests/Propel/Tests/Runtime/Adapter/Pdo/PgsqlAdapter.php index bc2963d0f9..b97a9af814 100644 --- a/tests/Propel/Tests/Runtime/Adapter/Pdo/PgsqlAdapter.php +++ b/tests/Propel/Tests/Runtime/Adapter/Pdo/PgsqlAdapter.php @@ -20,12 +20,15 @@ */ class PgsqlAdapterTest extends TestCase { - public function testGetExplainPlanQuery() - { - $db = new PgsqlAdapter(); - $query = 'SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.ID AS ORA_COL_ALIAS_0, book.TITLE AS ORA_COL_ALIAS_1, book.ISBN AS ORA_COL_ALIAS_2, book.PRICE AS ORA_COL_ALIAS_3, book.PUBLISHER_ID AS ORA_COL_ALIAS_4, book.AUTHOR_ID AS ORA_COL_ALIAS_5, author.ID AS ORA_COL_ALIAS_6, author.FIRST_NAME AS ORA_COL_ALIAS_7, author.LAST_NAME AS ORA_COL_ALIAS_8, author.EMAIL AS ORA_COL_ALIAS_9, author.AGE AS ORA_COL_ALIAS_10, book.PRICE AS BOOK_PRICE FROM book, author) A ) B WHERE B.PROPEL_ROWNUM <= 1'; - $expected = 'EXPLAIN SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.ID AS ORA_COL_ALIAS_0, book.TITLE AS ORA_COL_ALIAS_1, book.ISBN AS ORA_COL_ALIAS_2, book.PRICE AS ORA_COL_ALIAS_3, book.PUBLISHER_ID AS ORA_COL_ALIAS_4, book.AUTHOR_ID AS ORA_COL_ALIAS_5, author.ID AS ORA_COL_ALIAS_6, author.FIRST_NAME AS ORA_COL_ALIAS_7, author.LAST_NAME AS ORA_COL_ALIAS_8, author.EMAIL AS ORA_COL_ALIAS_9, author.AGE AS ORA_COL_ALIAS_10, book.PRICE AS BOOK_PRICE FROM book, author) A ) B WHERE B.PROPEL_ROWNUM <= 1'; + /** + * @return void + */ + public function testGetExplainPlanQuery() + { + $db = new PgsqlAdapter(); + $query = 'SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.ID AS ORA_COL_ALIAS_0, book.TITLE AS ORA_COL_ALIAS_1, book.ISBN AS ORA_COL_ALIAS_2, book.PRICE AS ORA_COL_ALIAS_3, book.PUBLISHER_ID AS ORA_COL_ALIAS_4, book.AUTHOR_ID AS ORA_COL_ALIAS_5, author.ID AS ORA_COL_ALIAS_6, author.FIRST_NAME AS ORA_COL_ALIAS_7, author.LAST_NAME AS ORA_COL_ALIAS_8, author.EMAIL AS ORA_COL_ALIAS_9, author.AGE AS ORA_COL_ALIAS_10, book.PRICE AS BOOK_PRICE FROM book, author) A ) B WHERE B.PROPEL_ROWNUM <= 1'; + $expected = 'EXPLAIN SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.ID AS ORA_COL_ALIAS_0, book.TITLE AS ORA_COL_ALIAS_1, book.ISBN AS ORA_COL_ALIAS_2, book.PRICE AS ORA_COL_ALIAS_3, book.PUBLISHER_ID AS ORA_COL_ALIAS_4, book.AUTHOR_ID AS ORA_COL_ALIAS_5, author.ID AS ORA_COL_ALIAS_6, author.FIRST_NAME AS ORA_COL_ALIAS_7, author.LAST_NAME AS ORA_COL_ALIAS_8, author.EMAIL AS ORA_COL_ALIAS_9, author.AGE AS ORA_COL_ALIAS_10, book.PRICE AS BOOK_PRICE FROM book, author) A ) B WHERE B.PROPEL_ROWNUM <= 1'; - $this->assertEquals($expected, $db->getExplainPlanQuery($query), 'getExplainPlanQuery() returns a SQL Explain query'); - } + $this->assertEquals($expected, $db->getExplainPlanQuery($query), 'getExplainPlanQuery() returns a SQL Explain query'); + } } diff --git a/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php b/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php index 77d7c8bd69..370e37710d 100644 --- a/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php +++ b/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php @@ -10,12 +10,9 @@ namespace Propel\Tests\Runtime\Collection; - use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveQuery\PropelQuery; use Propel\Runtime\Collection\ArrayCollection; -use Propel\Runtime\Collection\ObjectCollection; -use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\Book; @@ -33,12 +30,18 @@ */ class ArrayCollectionTest extends BookstoreEmptyTestBase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate($this->con); } + /** + * @return void + */ public function testSave() { $books = PropelQuery::from('Propel\Tests\Bookstore\Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find(); @@ -56,16 +59,21 @@ public function testSave() /** * @expectedException \Propel\Runtime\Exception\BadMethodCallException + * + * @return void */ public function testSaveOnReadOnlyEntityThrowsException() { $col = new ArrayCollection(); $col->setModel('Country'); $cv = new Country(); - $col []= $cv; + $col[] = $cv; $col->save(); } + /** + * @return void + */ public function testDelete() { $books = PropelQuery::from('Propel\Tests\Bookstore\Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find(); @@ -78,6 +86,8 @@ public function testDelete() /** * @expectedException \Propel\Runtime\Exception\BadMethodCallException + * + * @return void */ public function testDeleteOnReadOnlyEntityThrowsException() { @@ -85,10 +95,13 @@ public function testDeleteOnReadOnlyEntityThrowsException() $col->setModel('Country'); $cv = new Country(); $cv->setNew(false); - $col []= $cv; + $col[] = $cv; $col->delete(); } + /** + * @return void + */ public function testGetPrimaryKeys() { $books = PropelQuery::from('Propel\Tests\Bookstore\Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find(); @@ -99,7 +112,7 @@ public function testGetPrimaryKeys() 'Book_0', 'Book_1', 'Book_2', - 'Book_3' + 'Book_3', ]; $this->assertEquals($keys, array_keys($pks)); @@ -113,6 +126,9 @@ public function testGetPrimaryKeys() } } + /** + * @return void + */ public function testFromArray() { $author = new Author(); @@ -121,7 +137,7 @@ public function testFromArray() $author->save(); $books = [ ['Title' => 'Mansfield Park', 'ISBN' => 'FA404-A', 'AuthorId' => $author->getId()], - ['Title' => 'Pride And Prejudice', 'ISBN' => 'FA404-B', 'AuthorId' => $author->getId()] + ['Title' => 'Pride And Prejudice', 'ISBN' => 'FA404-B', 'AuthorId' => $author->getId()], ]; $col = new ArrayCollection(); $col->setModel('Propel\Tests\Bookstore\Book'); @@ -138,6 +154,9 @@ public function testFromArray() $this->assertEquals(2, $booksByJane); } + /** + * @return void + */ public function testToArray() { $books = PropelQuery::from('Propel\Tests\Bookstore\Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find(); @@ -158,7 +177,7 @@ public function testToArray() 'Book_0', 'Book_1', 'Book_2', - 'Book_3' + 'Book_3', ]; $this->assertEquals($keys, array_keys($booksArray)); @@ -171,11 +190,14 @@ public function testToArray() 'Book_Harry Potter and the Order of the Phoenix', 'Book_Quicksilver', 'Book_Don Juan', - 'Book_The Tin Drum' + 'Book_The Tin Drum', ]; $this->assertEquals($keys, array_keys($booksArray)); } + /** + * @return void + */ public function testToArrayDeep() { $author = new Author(); @@ -191,7 +213,7 @@ public function testToArrayDeep() $coll = new ArrayCollection(); $coll->setModel('Propel\Tests\Bookstore\Book'); - $coll[]= $book->toArray(TableMap::TYPE_PHPNAME, true, [], true); + $coll[] = $book->toArray(TableMap::TYPE_PHPNAME, true, [], true); $expected = [[ 'Id' => 9012, 'Title' => 'Don Juan', @@ -207,12 +229,15 @@ public function testToArrayDeep() 'Age' => null, 'Books' => [ 0 => '*RECURSION*', - ] + ], ], ]]; $this->assertEquals($expected, $coll->toArray()); } + /** + * @return void + */ public function getWorkerObject() { $col = new TestableArrayCollection(); @@ -225,13 +250,14 @@ public function getWorkerObject() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testGetWorkerObjectNoModel() { $col = new TestableArrayCollection(); $col->getWorkerObject(); } - } class TestableArrayCollection extends ArrayCollection diff --git a/tests/Propel/Tests/Runtime/Collection/CollectionConvertTest.php b/tests/Propel/Tests/Runtime/Collection/CollectionConvertTest.php index a62d86308b..6c00f10d0d 100644 --- a/tests/Propel/Tests/Runtime/Collection/CollectionConvertTest.php +++ b/tests/Propel/Tests/Runtime/Collection/CollectionConvertTest.php @@ -10,9 +10,7 @@ namespace Propel\Tests\Runtime\Collection; -use Propel\Runtime\Collection\Collection; use Propel\Runtime\Collection\ObjectCollection; - use Propel\Tests\Bookstore\Book; use Propel\Tests\Bookstore\Publisher; use Propel\Tests\TestCaseFixtures; @@ -21,12 +19,15 @@ * Test class for Collection. * * @author Francois Zaninotto - * @version $Id: CollectionTest.php 1348 2009-12-03 21:49:00Z francois $ + * @version $Id: CollectionTest.php 1348 2009-12-03 21:49:00Z francois $ */ class CollectionConvertTest extends TestCaseFixtures { private $coll; + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -47,8 +48,8 @@ protected function setUp(): void $this->coll = new ObjectCollection(); $this->coll->setModel('\Propel\Tests\Bookstore\Book'); - $this->coll[]= $book1; - $this->coll[]= $book2; + $this->coll[] = $book1; + $this->coll[] = $book2; } public function toXmlDataProvider() @@ -81,6 +82,8 @@ public function toXmlDataProvider() /** * @dataProvider toXmlDataProvider + * + * @return void */ public function testToXML($expected) { @@ -89,6 +92,8 @@ public function testToXML($expected) /** * @dataProvider toXmlDataProvider + * + * @return void */ public function testFromXML($expected) { @@ -129,6 +134,8 @@ public function toYamlDataProvider() /** * @dataProvider toYamlDataProvider + * + * @return void */ public function testToYAML($expected) { @@ -137,6 +144,8 @@ public function testToYAML($expected) /** * @dataProvider toYamlDataProvider + * + * @return void */ public function testFromYAML($expected) { @@ -162,6 +171,8 @@ public function toJsonDataProvider() /** * @dataProvider toJsonDataProvider + * + * @return void */ public function testToJSON($expected) { @@ -170,6 +181,8 @@ public function testToJSON($expected) /** * @dataProvider toJsonDataProvider + * + * @return void */ public function testfromJSON($expected) { @@ -193,6 +206,8 @@ public function toCsvDataProvider() /** * @dataProvider toCsvDataProvider + * + * @return void */ public function testToCSV($expected) { @@ -201,6 +216,8 @@ public function testToCSV($expected) /** * @dataProvider toCsvDataProvider + * + * @return void */ public function testfromCSV($expected) { @@ -217,12 +234,17 @@ public function testfromCSV($expected) /** * @dataProvider toYamlDataProvider + * + * @return void */ public function testToStringUsesDefaultStringFormat($expected) { - $this->assertEquals($expected, (string) $this->coll, 'Collection::__toString() uses the YAML representation by default'); + $this->assertEquals($expected, (string)$this->coll, 'Collection::__toString() uses the YAML representation by default'); } + /** + * @return void + */ public function testToStringUsesCustomStringFormat() { $coll = new ObjectCollection(); @@ -230,7 +252,7 @@ public function testToStringUsesCustomStringFormat() $publisher = new Publisher(); $publisher->setId(12345); $publisher->setName('Penguinoo'); - $coll[]= $publisher; + $coll[] = $publisher; $expected = << @@ -241,7 +263,6 @@ public function testToStringUsesCustomStringFormat() EOF; - $this->assertEquals($expected, (string) $coll); + $this->assertEquals($expected, (string)$coll); } - } diff --git a/tests/Propel/Tests/Runtime/Collection/CollectionIteratorTest.php b/tests/Propel/Tests/Runtime/Collection/CollectionIteratorTest.php index fbd12e1c67..f5694eeb70 100644 --- a/tests/Propel/Tests/Runtime/Collection/CollectionIteratorTest.php +++ b/tests/Propel/Tests/Runtime/Collection/CollectionIteratorTest.php @@ -19,6 +19,9 @@ */ class CollectionIteratorTest extends BookstoreTestBase { + /** + * @return void + */ public function testIsEmpty() { $iterator = new CollectionIterator(new Collection()); @@ -28,6 +31,9 @@ public function testIsEmpty() $this->assertFalse($iterator->isEmpty(), 'isEmpty() returns false on a non empty collection'); } + /** + * @return void + */ public function testGetPosition() { $iterator = new CollectionIterator(new Collection()); @@ -41,6 +47,9 @@ public function testGetPosition() } } + /** + * @return void + */ public function testGetFirst() { $iterator = new CollectionIterator(new Collection()); @@ -50,6 +59,9 @@ public function testGetFirst() $this->assertEquals('bar1', $iterator->getFirst(), 'getFirst() returns value of the first element in the collection'); } + /** + * @return void + */ public function testIsFirst() { $iterator = new CollectionIterator(new Collection()); @@ -64,6 +76,9 @@ public function testIsFirst() } } + /** + * @return void + */ public function testGetPrevious() { $iterator = new CollectionIterator(new Collection()); @@ -76,6 +91,9 @@ public function testGetPrevious() $this->assertEquals('bar1', $iterator->getCurrent(), 'getPrevious() decrements the internal pointer'); } + /** + * @return void + */ public function testGetCurrent() { $iterator = new CollectionIterator(new Collection()); @@ -88,6 +106,9 @@ public function testGetCurrent() } } + /** + * @return void + */ public function testGetNext() { $iterator = new CollectionIterator(new Collection()); @@ -100,6 +121,9 @@ public function testGetNext() $this->assertNull($iterator->getNext(), 'getNext() returns null when the internal pointer is at the end of the list'); } + /** + * @return void + */ public function testGetLast() { $iterator = new CollectionIterator(new Collection()); @@ -110,6 +134,9 @@ public function testGetLast() $this->assertEquals('bar3', $iterator->getCurrent(), 'getLast() moves the internal pointer to the last element'); } + /** + * @return void + */ public function testIsLast() { $iterator = new CollectionIterator(new Collection()); @@ -123,6 +150,9 @@ public function testIsLast() } } + /** + * @return void + */ public function testIsOdd() { $iterator = new CollectionIterator(new Collection()); @@ -130,10 +160,13 @@ public function testIsOdd() $data = ['bar1', 'bar2', 'bar3']; $iterator = new CollectionIterator(new Collection($data)); foreach ($iterator as $key => $value) { - $this->assertEquals((boolean) ($key % 2), $iterator->isOdd(), 'isOdd() returns true only when the key is odd'); + $this->assertEquals((bool)($key % 2), $iterator->isOdd(), 'isOdd() returns true only when the key is odd'); } } + /** + * @return void + */ public function testIsEven() { $iterator = new CollectionIterator(new Collection()); @@ -141,8 +174,7 @@ public function testIsEven() $data = ['bar1', 'bar2', 'bar3']; $iterator = new CollectionIterator(new Collection($data)); foreach ($iterator as $key => $value) { - $this->assertEquals(!(boolean) ($key % 2), $iterator->isEven(), 'isEven() returns true only when the key is even'); + $this->assertEquals(!(bool)($key % 2), $iterator->isEven(), 'isEven() returns true only when the key is even'); } } - } diff --git a/tests/Propel/Tests/Runtime/Collection/CollectionTest.php b/tests/Propel/Tests/Runtime/Collection/CollectionTest.php index db4ff5d666..d0afce0800 100644 --- a/tests/Propel/Tests/Runtime/Collection/CollectionTest.php +++ b/tests/Propel/Tests/Runtime/Collection/CollectionTest.php @@ -10,11 +10,11 @@ namespace Propel\Tests\Runtime\collection; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use Propel\Runtime\Collection\Collection; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Book; use Propel\Tests\Bookstore\Map\BookTableMap; -use Propel\Runtime\Propel; -use Propel\Runtime\Collection\Collection; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Test class for Collection. @@ -25,6 +25,9 @@ */ class CollectionTest extends BookstoreTestBase { + /** + * @return void + */ public function testClone() { $col = new Collection(['Bar1']); @@ -35,6 +38,9 @@ public function testClone() $this->assertCount(2, $colCloned); } + /** + * @return void + */ public function testArrayAccess() { $data = ['bar1', 'bar2', 'bar3']; @@ -44,6 +50,9 @@ public function testArrayAccess() $this->assertEquals('bar3', $col[2], 'Collection allows access via $foo[$index]'); } + /** + * @return void + */ public function testGetData() { $col = new Collection(); @@ -55,6 +64,9 @@ public function testGetData() $this->assertEquals('bar1', $data[0], 'getData() returns a copy of the collection data'); } + /** + * @return void + */ public function testSetData() { $col = new Collection(); @@ -67,6 +79,9 @@ public function testSetData() $this->assertEquals($data, $col->getArrayCopy(), 'setData() sets the collection data'); } + /** + * @return void + */ public function testIsEmpty() { $col = new Collection(); @@ -76,6 +91,9 @@ public function testIsEmpty() $this->assertFalse($col->isEmpty(), 'isEmpty() returns false on a non empty collection'); } + /** + * @return void + */ public function testCallIteratorMethods() { $methods = ['getPosition', 'isFirst', 'isLast', 'isOdd', 'isEven']; @@ -92,6 +110,9 @@ public function testCallIteratorMethods() } } + /** + * @return void + */ public function testNestedIteration() { $data = ['bar1', 'bar2', 'bar3']; @@ -106,6 +127,9 @@ public function testNestedIteration() $this->assertEquals('i0;k0;k1;k2;i1;k0;k1;k2;i2;k0;k1;k2;', $sequence); } + /** + * @return void + */ public function testGet() { $col = new Collection(['foo', 'bar']); @@ -114,6 +138,8 @@ public function testGet() /** * @expectedException \UnexpectedValueException + * + * @return void */ public function testGetUnknownOffset() { @@ -121,6 +147,9 @@ public function testGetUnknownOffset() $bar = $col->get('foo'); } + /** + * @return void + */ public function testPop() { $col = new Collection(); @@ -131,6 +160,9 @@ public function testPop() $this->assertEquals(['bar1', 'bar2'], $col->getData(), 'pop() removes the last element of the collection'); } + /** + * @return void + */ public function testShift() { $col = new Collection(); @@ -141,6 +173,9 @@ public function testShift() $this->assertEquals(['bar2', 'bar3'], $col->getData(), 'shift() removes the first element of the collection'); } + /** + * @return void + */ public function testPrepend() { $col = new Collection(); @@ -151,6 +186,9 @@ public function testPrepend() $this->assertEquals(['bar4', 'bar1', 'bar2', 'bar3'], $col->getData(), 'prepend() adds new element to the beginning of the collection'); } + /** + * @return void + */ public function testSet() { $col = new Collection(); @@ -163,6 +201,9 @@ public function testSet() $this->assertEquals(['foo', 'bar'], $col->getData(), 'set() adds an element to the collection without a key'); } + /** + * @return void + */ public function testRemove() { $col = new Collection(); @@ -174,6 +215,8 @@ public function testRemove() /** * @expectedException \UnexpectedValueException + * + * @return void */ public function testRemoveUnknownOffset() { @@ -181,6 +224,9 @@ public function testRemoveUnknownOffset() $col->remove(2); } + /** + * @return void + */ public function testClear() { $col = new Collection(); @@ -192,6 +238,9 @@ public function testClear() $this->assertEquals([], $col->getData(), 'clear() empties the collection'); } + /** + * @return void + */ public function testContains() { $col = new Collection(); @@ -202,6 +251,9 @@ public function testContains() $this->assertFalse($col->contains('bar4'), 'contains() returns false when the key does not exist'); } + /** + * @return void + */ public function testSearch() { $col = new Collection(); @@ -212,6 +264,9 @@ public function testSearch() $this->assertFalse($col->search('bar4'), 'search() returns false when the element does not exist'); } + /** + * @return void + */ public function testSerializable() { $data = ['bar1', 'bar2', 'bar3']; @@ -225,6 +280,8 @@ public function testSerializable() /** * @database + * + * @return void */ public function testGetWriteConnection() { @@ -236,6 +293,8 @@ public function testGetWriteConnection() /** * @expectedException \Propel\Runtime\Exception\BadMethodCallException + * + * @return void */ public function testGetConnectionNoModel() { @@ -243,6 +302,9 @@ public function testGetConnectionNoModel() $col->getConnection(); } + /** + * @return void + */ public function testDiffWithEmptyCollectionReturnsCurrentCollection() { $col1 = new Collection(); @@ -258,6 +320,9 @@ public function testDiffWithEmptyCollectionReturnsCurrentCollection() $this->assertSame($b, $result[0]); } + /** + * @return void + */ public function testDiffWithEmptyCollections() { $col1 = new Collection(); @@ -269,6 +334,9 @@ public function testDiffWithEmptyCollections() $this->assertEquals(0, count($result)); } + /** + * @return void + */ public function testDiffWithASimilarCollectionReturnsAnEmptyCollection() { $col1 = new Collection(); @@ -284,12 +352,15 @@ public function testDiffWithASimilarCollectionReturnsAnEmptyCollection() $this->assertEquals(0, count($result)); } + /** + * @return void + */ public function testDiffWithNonEmptyCollectionReturnsObjectsInTheFirstCollectionWhichAreNotInTheSecondCollection() { $col1 = new Collection(); $col2 = new Collection(); - $b = new Book(); + $b = new Book(); $b1 = new Book(); $col1[] = $b; $col1[] = $b1; @@ -302,6 +373,9 @@ public function testDiffWithNonEmptyCollectionReturnsObjectsInTheFirstCollection $this->assertSame($b1, $result[0]); } + /** + * @return void + */ public function testDiffWithACollectionHavingObjectsNotPresentInTheFirstCollection() { $col1 = new Collection(); diff --git a/tests/Propel/Tests/Runtime/Collection/ObjectCollectionTest.php b/tests/Propel/Tests/Runtime/Collection/ObjectCollectionTest.php index e1e2c3df91..2b6cf998ec 100644 --- a/tests/Propel/Tests/Runtime/Collection/ObjectCollectionTest.php +++ b/tests/Propel/Tests/Runtime/Collection/ObjectCollectionTest.php @@ -10,16 +10,17 @@ namespace Propel\Tests\Runtime\Collection; +use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Formatter\ObjectFormatter; -use Propel\Runtime\ActiveQuery\ModelCriteria; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Author; -use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Country; -use Propel\Runtime\Propel; +use Propel\Tests\Bookstore\Map\AuthorTableMap; +use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; + /** * Test class for ObjectCollection. * @@ -29,6 +30,9 @@ */ class ObjectCollectionTest extends BookstoreTestBase { + /** + * @return void + */ public function testContains() { $col = new ObjectCollection(); @@ -39,25 +43,29 @@ public function testContains() $col = new ObjectCollection(); $this->assertFalse($col->contains($book1)); $this->assertFalse($col->contains($book2)); - $col []= $book1; + $col[] = $book1; $this->assertTrue($col->contains($book1)); $this->assertFalse($col->contains($book2)); } /** * @expectedException \Propel\Runtime\Exception\BadMethodCallException + * + * @return void */ public function testSaveOnReadOnlyEntityThrowsException() { $col = new ObjectCollection(); $col->setModel('Propel\Tests\Bookstore\Country'); $cv = new Country(); - $col []= $cv; + $col[] = $cv; $col->save(); } /** * @expectedException \Propel\Runtime\Exception\BadMethodCallException + * + * @return void */ public function testDeleteOnReadOnlyEntityThrowsException() { @@ -65,21 +73,24 @@ public function testDeleteOnReadOnlyEntityThrowsException() $col->setModel('Propel\Tests\Bookstore\Country'); $cv = new Country(); $cv->setNew(false); - $col []= $cv; + $col[] = $cv; $col->delete(); } + /** + * @return void + */ public function testGetPrimaryKeys() { $books = new ObjectCollection(); $books->setModel('Propel\Tests\Bookstore\Book'); - for ($i=0; $i < 4; $i++) { + for ($i = 0; $i < 4; $i++) { $book = new Book(); $book->setTitle('Title' . $i); $book->setISBN($i); $book->save($this->con); - $books []= $book; + $books[] = $book; } $pks = $books->getPrimaryKeys(); @@ -89,7 +100,7 @@ public function testGetPrimaryKeys() 'Book_0', 'Book_1', 'Book_2', - 'Book_3' + 'Book_3', ]; $this->assertEquals($keys, array_keys($pks)); @@ -102,6 +113,9 @@ public function testGetPrimaryKeys() } } + /** + * @return void + */ public function testToArrayDeep() { $author = new Author(); @@ -117,7 +131,7 @@ public function testToArrayDeep() $coll = new ObjectCollection(); $coll->setModel('Propel\Tests\Bookstore\Book'); - $coll[]= $book; + $coll[] = $book; $expected = [[ 'Id' => 9012, 'Title' => 'Don Juan', @@ -133,12 +147,15 @@ public function testToArrayDeep() 'Age' => null, 'Books' => [ 0 => '*RECURSION*', - ] + ], ], ]]; $this->assertEquals($expected, $coll->toArray()); } + /** + * @return void + */ public function testPopulateRelationOneToManyWithEmptyCollection() { $author = new Author(); @@ -149,7 +166,7 @@ public function testPopulateRelationOneToManyWithEmptyCollection() BookTableMap::clearInstancePool(); $coll = new ObjectCollection(); $coll->setFormatter(new ObjectFormatter(new ModelCriteria(null, '\Propel\Tests\Bookstore\Author'))); - $coll []= $author; + $coll[] = $author; $books = $coll->populateRelation('Book', null, $this->con); $this->assertEquals(0, $books->count()); $count = $this->con->getQueryCount(); @@ -160,6 +177,8 @@ public function testPopulateRelationOneToManyWithEmptyCollection() /** * @expectedException \Propel\Runtime\Exception\RuntimeException * @expectedExceptionMessage Propel\Runtime\Collection\ObjectCollection::populateRelation needs instance pooling to be enabled prior to populating the collection + * + * @return void */ public function testPopulateRelationWhenInstancePoolingIsDisabled() { @@ -169,12 +188,15 @@ public function testPopulateRelationWhenInstancePoolingIsDisabled() $coll->populateRelation('Book'); } + /** + * @return void + */ public function testContainsWithClassicBehavior() { $col = new ObjectCollection(); - $b1 = new Book(); + $b1 = new Book(); $b1->setTitle('Bar'); - $b2 = new Book(); + $b2 = new Book(); $b2->setTitle('Foo'); $this->assertFalse($col->contains($b1), 'contains() returns false on an empty collection'); @@ -185,12 +207,15 @@ public function testContainsWithClassicBehavior() $this->assertFalse($col->contains($b2), 'contains() returns false when the key does not exist'); } + /** + * @return void + */ public function testSearchWithClassicBehavior() { $col = new ObjectCollection(); - $b1 = new Book(); + $b1 = new Book(); $b1->setTitle('Bar'); - $b2 = new Book(); + $b2 = new Book(); $b2->setTitle('Foo'); $this->assertFalse($col->search($b1), 'search() returns false on an empty collection'); @@ -200,15 +225,18 @@ public function testSearchWithClassicBehavior() $this->assertFalse($col->search($b2), 'search() returns false when the element does not exist'); } + /** + * @return void + */ public function testContainsMatchesSimilarObjects() { $col = new ObjectCollection(); - $b1 = new Book(); + $b1 = new Book(); $b1->setTitle('Bar'); $b1->setISBN('012345'); $b1->save(); - $b2 = clone $b1; + $b2 = clone $b1; $this->assertFalse($col->contains($b1), 'contains() returns false on an empty collection'); @@ -218,15 +246,18 @@ public function testContainsMatchesSimilarObjects() $this->assertTrue($col->contains($b2)); } + /** + * @return void + */ public function testSearchMatchesSimilarObjects() { $col = new ObjectCollection(); - $b1 = new Book(); + $b1 = new Book(); $b1->setTitle('Bar'); $b1->setISBN('012345'); $b1->save(); - $b2 = clone $b1; + $b2 = clone $b1; $this->assertFalse($col->search($b1), 'search() returns false on an empty collection'); @@ -235,13 +266,16 @@ public function testSearchMatchesSimilarObjects() $this->assertTrue(0 === $col->search($b2)); } + /** + * @return void + */ public function testContainsMatchesNotSimilarNewObjects() { $col = new ObjectCollection(); - $b1 = new Book(); + $b1 = new Book(); $b1->setTitle('Bar'); $b1->setISBN('012345'); - $b2 = clone $b1; + $b2 = clone $b1; $this->assertFalse($col->contains($b1), 'contains() returns false on an empty collection'); @@ -251,13 +285,16 @@ public function testContainsMatchesNotSimilarNewObjects() $this->assertFalse($col->contains($b2)); } + /** + * @return void + */ public function testSearchMatchesNotSimilarNewObjects() { $col = new ObjectCollection(); - $b1 = new Book(); + $b1 = new Book(); $b1->setTitle('Bar'); $b1->setISBN('012345'); - $b2 = clone $b1; + $b2 = clone $b1; $this->assertFalse($col->search($b1), 'search() returns false on an empty collection'); @@ -266,13 +303,16 @@ public function testSearchMatchesNotSimilarNewObjects() $this->assertFalse(0 === $col->search($b2)); } + /** + * @return void + */ public function testObjectCollectionOfObjectCollections() { $col1 = new ObjectCollection(); - $b1 = new Book(); + $b1 = new Book(); $b1->setTitle('Bar'); $b1->setISBN('012345'); - $col2 = clone $b1; + $col2 = clone $b1; $col = new ObjectCollection([$col1]); @@ -282,6 +322,8 @@ public function testObjectCollectionOfObjectCollections() /** * @afterClass + * + * @return void */ public static function enableInstancePooling() { diff --git a/tests/Propel/Tests/Runtime/Collection/ObjectCollectionWithFixturesTest.php b/tests/Propel/Tests/Runtime/Collection/ObjectCollectionWithFixturesTest.php index 7182ac811d..6fd84bfd0f 100644 --- a/tests/Propel/Tests/Runtime/Collection/ObjectCollectionWithFixturesTest.php +++ b/tests/Propel/Tests/Runtime/Collection/ObjectCollectionWithFixturesTest.php @@ -10,17 +10,17 @@ namespace Propel\Tests\Runtime\collection; -use Propel\Runtime\Propel; -use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\PropelQuery; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; -use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Runtime\Collection\ObjectCollection; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Author; -use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\AuthorQuery; use Propel\Tests\Bookstore\BookQuery; +use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Test class for ObjectCollection. @@ -31,12 +31,18 @@ */ class ObjectCollectionWithFixturesTest extends BookstoreEmptyTestBase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate($this->con); } + /** + * @return void + */ public function testSave() { $books = PropelQuery::from('Propel\Tests\Bookstore\Book')->find(); @@ -56,6 +62,9 @@ public function testSave() } } + /** + * @return void + */ public function testDelete() { $books = PropelQuery::from('Propel\Tests\Bookstore\Book')->find(); @@ -70,6 +79,9 @@ public function testDelete() $this->assertEquals(0, count($books)); } + /** + * @return void + */ public function testFromArray() { $author = new Author(); @@ -78,7 +90,7 @@ public function testFromArray() $author->save(); $books = [ ['Title' => 'Mansfield Park', 'ISBN' => 'FA404', 'AuthorId' => $author->getId()], - ['Title' => 'Pride And Prejudice', 'ISBN' => 'FA404', 'AuthorId' => $author->getId()] + ['Title' => 'Pride And Prejudice', 'ISBN' => 'FA404', 'AuthorId' => $author->getId()], ]; $col = new ObjectCollection(); $col->setModel('Propel\Tests\Bookstore\Book'); @@ -95,6 +107,9 @@ public function testFromArray() $this->assertEquals(2, $booksByJane); } + /** + * @return void + */ public function testToArray() { BookTableMap::clearInstancePool(); @@ -115,7 +130,7 @@ public function testToArray() 'Book_0', 'Book_1', 'Book_2', - 'Book_3' + 'Book_3', ]; $this->assertEquals($keys, array_keys($booksArray)); @@ -128,11 +143,14 @@ public function testToArray() 'Book_Harry Potter and the Order of the Phoenix', 'Book_Quicksilver', 'Book_Don Juan', - 'Book_The Tin Drum' + 'Book_The Tin Drum', ]; $this->assertEquals($keys, array_keys($booksArray)); } + /** + * @return void + */ public function testGetArrayCopy() { $books = PropelQuery::from('Propel\Tests\Bookstore\Book')->find(); @@ -152,7 +170,7 @@ public function testGetArrayCopy() 'Book_0', 'Book_1', 'Book_2', - 'Book_3' + 'Book_3', ]; $this->assertEquals($keys, array_keys($booksArray)); @@ -165,11 +183,14 @@ public function testGetArrayCopy() 'Book_Harry Potter and the Order of the Phoenix', 'Book_Quicksilver', 'Book_Don Juan', - 'Book_The Tin Drum' + 'Book_The Tin Drum', ]; $this->assertEquals($keys, array_keys($booksArray)); } + /** + * @return void + */ public function testToKeyValue() { $books = PropelQuery::from('Propel\Tests\Bookstore\Book')->find(); @@ -197,6 +218,9 @@ public function testToKeyValue() $this->assertEquals($expected, $booksArray, 'toKeyValue() uses primary key for the key and __toString() for the value if no field name is passed'); } + /** + * @return void + */ public function testToKeyIndex() { $books = PropelQuery::from('Propel\Tests\Bookstore\Book')->find(); @@ -227,6 +251,10 @@ public function testToKeyIndex() $booksArray = $books->toKeyIndex(); $this->assertEquals($expected, $booksArray, 'toKeyIndex() uses primary key for the key'); } + + /** + * @return void + */ public function testGetColumnValues() { $books = PropelQuery::from('Propel\Tests\Bookstore\Book')->find(); @@ -256,6 +284,9 @@ public function testGetColumnValues() $this->assertEquals($expected, $booksArray, 'getColumnValues() uses primary key for the key'); } + /** + * @return void + */ public function testPopulateRelation() { AuthorTableMap::clearInstancePool(); @@ -268,6 +299,9 @@ public function testPopulateRelation() $this->assertEquals(4, count($books), 'populateRelation() the list of related objects'); } + /** + * @return void + */ public function testPopulateRelationCriteria() { AuthorTableMap::clearInstancePool(); @@ -279,6 +313,9 @@ public function testPopulateRelationCriteria() $this->assertEquals(3, count($books), 'populateRelation() accepts an optional criteria object to filter the query'); } + /** + * @return void + */ public function testPopulateRelationEmpty() { AuthorTableMap::clearInstancePool(); @@ -295,6 +332,9 @@ public function testPopulateRelationEmpty() $this->assertEquals($count, $this->con->getQueryCount(), 'populateRelation() doesn\'t issue a new query on empty collections'); } + /** + * @return void + */ public function testPopulateRelationOneToMany() { AuthorTableMap::clearInstancePool(); @@ -310,6 +350,9 @@ public function testPopulateRelationOneToMany() $this->assertEquals($count + 1, $this->con->getQueryCount(), 'populateRelation() populates a one-to-many relationship with a single supplementary query'); } + /** + * @return void + */ public function testPopulateRelationManyToOne() { $con = Propel::getServiceContainer()->getReadConnection(BookTableMap::DATABASE_NAME); diff --git a/tests/Propel/Tests/Runtime/Collection/OnDemandCollectionTest.php b/tests/Propel/Tests/Runtime/Collection/OnDemandCollectionTest.php index 45569d8c96..aa6a2bd784 100644 --- a/tests/Propel/Tests/Runtime/Collection/OnDemandCollectionTest.php +++ b/tests/Propel/Tests/Runtime/Collection/OnDemandCollectionTest.php @@ -10,14 +10,12 @@ namespace Propel\Tests\Runtime\Collection; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; -use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; - -use Propel\Runtime\Propel; -use Propel\Runtime\Collection\OnDemandCollection; -use Propel\Runtime\Exception\PropelException; use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveQuery\PropelQuery; +use Propel\Runtime\Collection\OnDemandCollection; +use Propel\Runtime\Propel; +use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Test class for OnDemandCollection. @@ -28,6 +26,9 @@ */ class OnDemandCollectionTest extends BookstoreEmptyTestBase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -36,6 +37,9 @@ protected function setUp(): void $this->books = PropelQuery::from('\Propel\Tests\Bookstore\Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find(); } + /** + * @return void + */ protected function tearDown(): void { $this->books = null; @@ -43,12 +47,18 @@ protected function tearDown(): void Propel::enableInstancePooling(); } + /** + * @return void + */ public function testSetFormatter() { $this->assertTrue($this->books instanceof OnDemandCollection); $this->assertEquals(4, count($this->books)); } + /** + * @return void + */ public function testKeys() { $i = 0; @@ -60,6 +70,8 @@ public function testKeys() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testoffsetExists() { @@ -68,6 +80,8 @@ public function testoffsetExists() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testoffsetGet() { @@ -76,6 +90,8 @@ public function testoffsetGet() /** * @expectedException \Propel\Runtime\Exception\BadMethodCallException + * + * @return void */ public function testoffsetSet() { @@ -84,12 +100,17 @@ public function testoffsetSet() /** * @expectedException \Propel\Runtime\Exception\BadMethodCallException + * + * @return void */ public function testoffsetUnset() { $this->books->offsetUnset(2); } + /** + * @return void + */ public function testToArray() { $this->assertNotEquals([], $this->books->toArray()); @@ -98,10 +119,11 @@ public function testToArray() /** * @expectedException \Propel\Runtime\Exception\BadMethodCallException + * + * @return void */ public function testFromArray() { $this->books->fromArray([]); } - } diff --git a/tests/Propel/Tests/Runtime/Collection/OnDemandIteratorTest.php b/tests/Propel/Tests/Runtime/Collection/OnDemandIteratorTest.php index 2493eaf116..e5ea2bf5b8 100644 --- a/tests/Propel/Tests/Runtime/Collection/OnDemandIteratorTest.php +++ b/tests/Propel/Tests/Runtime/Collection/OnDemandIteratorTest.php @@ -10,12 +10,11 @@ namespace Propel\Tests\Runtime\collection; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; -use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; - -use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveQuery\PropelQuery; +use Propel\Runtime\Propel; +use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Test class for OnDemandIterator. @@ -26,12 +25,18 @@ */ class OnDemandIteratorTest extends BookstoreEmptyTestBase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate($this->con); } + /** + * @return void + */ public function testInstancePoolingDisabled() { Propel::enableInstancePooling(); @@ -43,6 +48,9 @@ public function testInstancePoolingDisabled() } } + /** + * @return void + */ public function testInstancePoolingReenabled() { Propel::enableInstancePooling(); @@ -62,5 +70,4 @@ public function testInstancePoolingReenabled() $this->assertFalse(Propel::isInstancePoolingEnabled()); Propel::enableInstancePooling(); } - } diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionFactoryTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionFactoryTest.php index a4d82fa555..0201652fe5 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionFactoryTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionFactoryTest.php @@ -10,48 +10,63 @@ namespace Propel\Tests\Runtime\Connection; -use Propel\Tests\Helpers\BaseTestCase; - -use Propel\Runtime\Connection\ConnectionFactory; +use PDO; use Propel\Runtime\Adapter\Pdo\SqliteAdapter; +use Propel\Runtime\Connection\ConnectionFactory; use Propel\Runtime\Connection\ConnectionWrapper; - -use \PDO; +use Propel\Tests\Helpers\BaseTestCase; class ConnectionFactoryTest extends BaseTestCase { /** * @expectedException \Propel\Runtime\Exception\InvalidArgumentException + * + * @return void */ public function testCreateFailsIfGivenIncorrectConfiguration() { $con = ConnectionFactory::create([], new SqliteAdapter()); } + /** + * @return void + */ public function testCreateReturnsAConnectionWrapperByDefault() { $con = ConnectionFactory::create(['dsn' => 'sqlite::memory:'], new SqliteAdapter()); $this->assertInstanceOf('Propel\Runtime\Connection\ConnectionWrapper', $con); } + /** + * @return void + */ public function testCreateReturnsACustomConnectionClassIfPassedAsThirdArgument() { $con = ConnectionFactory::create(['dsn' => 'sqlite::memory:'], new SqliteAdapter(), 'Propel\Tests\Runtime\Connection\MyConnectionForFactoryTest1'); $this->assertInstanceOf('Propel\Tests\Runtime\Connection\MyConnectionForFactoryTest1', $con); } + /** + * @return void + */ public function testCreateReturnsACustomConnectionClassIfPassedInConfiguration() { $con = ConnectionFactory::create(['dsn' => 'sqlite::memory:', 'classname' => 'Propel\Tests\Runtime\Connection\MyConnectionForFactoryTest2'], new SqliteAdapter()); $this->assertInstanceOf('Propel\Tests\Runtime\Connection\MyConnectionForFactoryTest2', $con); } + /** + * @return void + */ public function testCreatePreferablyUsesCustomConnectionClassFromConfiguration() { $con = ConnectionFactory::create(['dsn' => 'sqlite::memory:', 'classname' => 'Propel\Tests\Runtime\Connection\MyConnectionForFactoryTest2'], new SqliteAdapter(), 'Propel\Tests\Runtime\Connection\MyConnectionForFactoryTest1'); $this->assertInstanceOf('Propel\Tests\Runtime\Connection\MyConnectionForFactoryTest2', $con); } + /** + * @return void + */ public function testCreateReturnsWrappedConnectionBuildByTheAdapter() { $con = ConnectionFactory::create(['dsn' => 'sqlite::memory:'], new SqliteAdapter()); @@ -59,6 +74,9 @@ public function testCreateReturnsWrappedConnectionBuildByTheAdapter() $this->assertInstanceOf('Propel\Runtime\Connection\PdoConnection', $pdo); } + /** + * @return void + */ public function testCreateSetsAttributesAfterConnection() { $con = ConnectionFactory::create(['dsn' => 'sqlite::memory:', 'attributes' => [PDO::ATTR_CASE => PDO::CASE_LOWER]], new SqliteAdapter()); @@ -66,6 +84,9 @@ public function testCreateSetsAttributesAfterConnection() $this->assertEquals(PDO::CASE_LOWER, $pdo->getAttribute(PDO::ATTR_CASE)); } + /** + * @return void + */ public function testCreateSetsAttributesAfterConnectionAndExpandsConstantNames() { $con = ConnectionFactory::create(['dsn' => 'sqlite::memory:', 'attributes' => ['ATTR_CASE' => PDO::CASE_LOWER]], new SqliteAdapter()); @@ -75,13 +96,18 @@ public function testCreateSetsAttributesAfterConnectionAndExpandsConstantNames() /** * @expectedException \Propel\Runtime\Exception\InvalidArgumentException + * + * @return void */ public function testCreateFailsWhenPassedAnIncorrectAttributeName() { $con = ConnectionFactory::create(['dsn' => 'sqlite::memory:', 'attributes' => ['ATTR_CAE' => PDO::CASE_LOWER]], new SqliteAdapter()); } - } -class MyConnectionForFactoryTest1 extends ConnectionWrapper {} -class MyConnectionForFactoryTest2 extends ConnectionWrapper {} +class MyConnectionForFactoryTest1 extends ConnectionWrapper +{ +} +class MyConnectionForFactoryTest2 extends ConnectionWrapper +{ +} diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php index 1b9ac7e695..7ef9868fab 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php @@ -10,24 +10,28 @@ namespace Propel\Tests\Runtime\Connection; -use Propel\Tests\Helpers\BaseTestCase; - -use Propel\Runtime\Connection\ConnectionManagerMasterSlave; +use PDO; use Propel\Runtime\Adapter\Pdo\SqliteAdapter; - -use \PDO; +use Propel\Runtime\Connection\ConnectionManagerMasterSlave; +use Propel\Tests\Helpers\BaseTestCase; /** * @deprecated Will be removed with the deprecated class. */ class ConnectionManagerMasterSlaveTest extends BaseTestCase { + /** + * @return void + */ public function testGetNameReturnsNullByDefault() { $manager = new ConnectionManagerMasterSlave(); $this->assertNull($manager->getName()); } + /** + * @return void + */ public function testGetNameReturnsNameSetUsingSetName() { $manager = new ConnectionManagerMasterSlave(); @@ -37,6 +41,8 @@ public function testGetNameReturnsNameSetUsingSetName() /** * @expectedException \Propel\Runtime\Exception\InvalidArgumentException + * + * @return void */ public function testGetWriteConnectionFailsIfManagerIsNotConfigured() { @@ -44,6 +50,9 @@ public function testGetWriteConnectionFailsIfManagerIsNotConfigured() $con = $manager->getWriteConnection(new SqliteAdapter()); } + /** + * @return void + */ public function testGetWriteConnectionBuildsConnectionBasedOnWriteConfiguration() { $manager = new ConnectionManagerMasterSlave(); @@ -54,6 +63,9 @@ public function testGetWriteConnectionBuildsConnectionBasedOnWriteConfiguration( $this->assertInstanceOf('Propel\Runtime\Connection\PdoConnection', $pdo); } + /** + * @return void + */ public function testGetWriteConnectionBuildsConnectionNotBasedOnReadConfiguration() { $manager = new ConnectionManagerMasterSlave(); @@ -64,6 +76,9 @@ public function testGetWriteConnectionBuildsConnectionNotBasedOnReadConfiguratio $this->assertEquals(PDO::CASE_UPPER, $pdo->getAttribute(PDO::ATTR_CASE)); } + /** + * @return void + */ public function testGetWriteConnectionReturnsAConnectionNamedAfterTheManager() { $manager = new ConnectionManagerMasterSlave(); @@ -73,6 +88,9 @@ public function testGetWriteConnectionReturnsAConnectionNamedAfterTheManager() $this->assertEquals('foo', $con->getName()); } + /** + * @return void + */ public function testGetReadConnectionBuildsConnectionBasedOnReadConfiguration() { $manager = new ConnectionManagerMasterSlave(); @@ -83,6 +101,9 @@ public function testGetReadConnectionBuildsConnectionBasedOnReadConfiguration() $this->assertInstanceOf('Propel\Runtime\Connection\PdoConnection', $pdo); } + /** + * @return void + */ public function testGetReadConnectionBuildsConnectionNotBasedOnWriteConfiguration() { $manager = new ConnectionManagerMasterSlave(); @@ -93,21 +114,27 @@ public function testGetReadConnectionBuildsConnectionNotBasedOnWriteConfiguratio $this->assertEquals(PDO::CASE_LOWER, $pdo->getAttribute(PDO::ATTR_CASE)); } + /** + * @return void + */ public function testGetReadConnectionReturnsWriteConnectionIfNoReadConnectionIsSet() { $manager = new ConnectionManagerMasterSlave(); $manager->setWriteConfiguration(['dsn' => 'sqlite::memory:']); $writeCon = $manager->getWriteConnection(new SqliteAdapter()); - $readCon = $manager->getReadConnection(new SqliteAdapter()); + $readCon = $manager->getReadConnection(new SqliteAdapter()); $this->assertSame($writeCon, $readCon); } + /** + * @return void + */ public function testGetReadConnectionBuildsConnectionBasedOnARandomReadConfiguration() { $manager = new ConnectionManagerMasterSlave(); $manager->setReadConfiguration([ ['dsn' => 'sqlite::memory:', 'attributes' => ['ATTR_CASE' => PDO::CASE_LOWER]], - ['dsn' => 'sqlite::memory:', 'attributes' => ['ATTR_CASE' => PDO::CASE_UPPER]] + ['dsn' => 'sqlite::memory:', 'attributes' => ['ATTR_CASE' => PDO::CASE_UPPER]], ]); $con = $manager->getReadConnection(new SqliteAdapter()); $pdo = $con->getWrappedConnection(); @@ -115,6 +142,9 @@ public function testGetReadConnectionBuildsConnectionBasedOnARandomReadConfigura $this->assertContains($pdo->getAttribute(PDO::ATTR_CASE), $expected); } + /** + * @return void + */ public function testGetReadConnectionReturnsAConnectionNamedAfterTheManager() { $manager = new ConnectionManagerMasterSlave(); @@ -124,12 +154,18 @@ public function testGetReadConnectionReturnsAConnectionNamedAfterTheManager() $this->assertEquals('foo', $con->getName()); } + /** + * @return void + */ public function testIsForceMasterConnectionFalseByDefault() { $manager = new ConnectionManagerMasterSlave(); $this->assertFalse($manager->isForceMasterConnection()); } + /** + * @return void + */ public function testSetForceMasterConnection() { $manager = new ConnectionManagerMasterSlave(); @@ -139,6 +175,9 @@ public function testSetForceMasterConnection() $this->assertFalse($manager->isForceMasterConnection()); } + /** + * @return void + */ public function testForceMasterConnectionForcesMasterConnectionOnRead() { $manager = new ConnectionManagerMasterSlave(); @@ -153,6 +192,8 @@ public function testForceMasterConnectionForcesMasterConnectionOnRead() /** * When master is in transaction then we need to return the master connection for getReadConnection, * otherwise lookup queries fail + * + * @return void */ public function testReadConnectionWhenMasterIsInTransaction() { diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php index acf934f22a..5b35d6bedf 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php @@ -10,21 +10,25 @@ namespace Propel\Tests\Runtime\Connection; -use Propel\Tests\Helpers\BaseTestCase; - -use Propel\Runtime\Connection\ConnectionManagerPrimaryReplica; +use PDO; use Propel\Runtime\Adapter\Pdo\SqliteAdapter; - -use \PDO; +use Propel\Runtime\Connection\ConnectionManagerPrimaryReplica; +use Propel\Tests\Helpers\BaseTestCase; class ConnectionManagerPrimaryReplicaTest extends BaseTestCase { + /** + * @return void + */ public function testGetNameReturnsNullByDefault() { $manager = new ConnectionManagerPrimaryReplica(); $this->assertNull($manager->getName()); } + /** + * @return void + */ public function testGetNameReturnsNameSetUsingSetName() { $manager = new ConnectionManagerPrimaryReplica(); @@ -34,6 +38,8 @@ public function testGetNameReturnsNameSetUsingSetName() /** * @expectedException \Propel\Runtime\Exception\InvalidArgumentException + * + * @return void */ public function testGetWriteConnectionFailsIfManagerIsNotConfigured() { @@ -41,6 +47,9 @@ public function testGetWriteConnectionFailsIfManagerIsNotConfigured() $manager->getWriteConnection(new SqliteAdapter()); } + /** + * @return void + */ public function testGetWriteConnectionBuildsConnectionBasedOnWriteConfiguration() { $manager = new ConnectionManagerPrimaryReplica(); @@ -51,6 +60,9 @@ public function testGetWriteConnectionBuildsConnectionBasedOnWriteConfiguration( $this->assertInstanceOf('Propel\Runtime\Connection\PdoConnection', $pdo); } + /** + * @return void + */ public function testGetWriteConnectionBuildsConnectionNotBasedOnReadConfiguration() { $manager = new ConnectionManagerPrimaryReplica(); @@ -61,6 +73,9 @@ public function testGetWriteConnectionBuildsConnectionNotBasedOnReadConfiguratio $this->assertEquals(PDO::CASE_UPPER, $pdo->getAttribute(PDO::ATTR_CASE)); } + /** + * @return void + */ public function testGetWriteConnectionReturnsAConnectionNamedAfterTheManager() { $manager = new ConnectionManagerPrimaryReplica(); @@ -70,6 +85,9 @@ public function testGetWriteConnectionReturnsAConnectionNamedAfterTheManager() $this->assertEquals('foo', $con->getName()); } + /** + * @return void + */ public function testGetReadConnectionBuildsConnectionBasedOnReadConfiguration() { $manager = new ConnectionManagerPrimaryReplica(); @@ -80,6 +98,9 @@ public function testGetReadConnectionBuildsConnectionBasedOnReadConfiguration() $this->assertInstanceOf('Propel\Runtime\Connection\PdoConnection', $pdo); } + /** + * @return void + */ public function testGetReadConnectionBuildsConnectionNotBasedOnWriteConfiguration() { $manager = new ConnectionManagerPrimaryReplica(); @@ -90,21 +111,27 @@ public function testGetReadConnectionBuildsConnectionNotBasedOnWriteConfiguratio $this->assertEquals(PDO::CASE_LOWER, $pdo->getAttribute(PDO::ATTR_CASE)); } + /** + * @return void + */ public function testGetReadConnectionReturnsWriteConnectionIfNoReadConnectionIsSet() { $manager = new ConnectionManagerPrimaryReplica(); $manager->setWriteConfiguration(['dsn' => 'sqlite::memory:']); $writeCon = $manager->getWriteConnection(new SqliteAdapter()); - $readCon = $manager->getReadConnection(new SqliteAdapter()); + $readCon = $manager->getReadConnection(new SqliteAdapter()); $this->assertSame($writeCon, $readCon); } + /** + * @return void + */ public function testGetReadConnectionBuildsConnectionBasedOnARandomReadConfiguration() { $manager = new ConnectionManagerPrimaryReplica(); $manager->setReadConfiguration([ ['dsn' => 'sqlite::memory:', 'attributes' => ['ATTR_CASE' => PDO::CASE_LOWER]], - ['dsn' => 'sqlite::memory:', 'attributes' => ['ATTR_CASE' => PDO::CASE_UPPER]] + ['dsn' => 'sqlite::memory:', 'attributes' => ['ATTR_CASE' => PDO::CASE_UPPER]], ]); $con = $manager->getReadConnection(new SqliteAdapter()); $pdo = $con->getWrappedConnection(); @@ -112,6 +139,9 @@ public function testGetReadConnectionBuildsConnectionBasedOnARandomReadConfigura $this->assertContains($pdo->getAttribute(PDO::ATTR_CASE), $expected); } + /** + * @return void + */ public function testGetReadConnectionReturnsAConnectionNamedAfterTheManager() { $manager = new ConnectionManagerPrimaryReplica(); @@ -121,12 +151,18 @@ public function testGetReadConnectionReturnsAConnectionNamedAfterTheManager() $this->assertEquals('foo', $con->getName()); } + /** + * @return void + */ public function testIsForcePrimaryConnectionFalseByDefault() { $manager = new ConnectionManagerPrimaryReplica(); $this->assertFalse($manager->isForcePrimaryConnection()); } + /** + * @return void + */ public function testSetForcePrimaryConnection() { $manager = new ConnectionManagerPrimaryReplica(); @@ -136,6 +172,9 @@ public function testSetForcePrimaryConnection() $this->assertFalse($manager->isForcePrimaryConnection()); } + /** + * @return void + */ public function testForcePrimaryConnectionForcesMasterConnectionOnRead() { $manager = new ConnectionManagerPrimaryReplica(); @@ -150,6 +189,8 @@ public function testForcePrimaryConnectionForcesMasterConnectionOnRead() /** * When master is in transaction then we need to return the master connection for getReadConnection, * otherwise lookup queries fail + * + * @return void */ public function testReadConnectionWhenMasterIsInTransaction() { diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerSingleTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerSingleTest.php index d8d3df7d27..e460e04184 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerSingleTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerSingleTest.php @@ -10,20 +10,25 @@ namespace Propel\Tests\Runtime\Connection; -use Propel\Tests\Helpers\BaseTestCase; - +use Propel\Runtime\Adapter\Pdo\SqliteAdapter; use Propel\Runtime\Connection\ConnectionManagerSingle; use Propel\Runtime\Connection\PdoConnection; -use Propel\Runtime\Adapter\Pdo\SqliteAdapter; +use Propel\Tests\Helpers\BaseTestCase; class ConnectionManagerSingleTest extends BaseTestCase { + /** + * @return void + */ public function testGetNameReturnsNullByDefault() { $manager = new ConnectionManagerSingle(); $this->assertNull($manager->getName()); } + /** + * @return void + */ public function testGetNameReturnsNameSetUsingSetName() { $manager = new ConnectionManagerSingle(); @@ -33,6 +38,8 @@ public function testGetNameReturnsNameSetUsingSetName() /** * @expectedException \Propel\Runtime\Exception\InvalidArgumentException + * + * @return void */ public function testGetWriteConnectionFailsIfManagerIsNotConfigured() { @@ -40,6 +47,9 @@ public function testGetWriteConnectionFailsIfManagerIsNotConfigured() $con = $manager->getWriteConnection(new SqliteAdapter()); } + /** + * @return void + */ public function testGetWriteConnectionBuildsConnectionBasedOnConfiguration() { $manager = new ConnectionManagerSingle(); @@ -50,6 +60,9 @@ public function testGetWriteConnectionBuildsConnectionBasedOnConfiguration() $this->assertInstanceOf('Propel\Runtime\Connection\PdoConnection', $pdo); } + /** + * @return void + */ public function testGetWriteConnectionReturnsAConnectionNamedAfterTheManager() { $manager = new ConnectionManagerSingle(); @@ -59,15 +72,21 @@ public function testGetWriteConnectionReturnsAConnectionNamedAfterTheManager() $this->assertEquals('foo', $con->getName()); } + /** + * @return void + */ public function testGetReadConnectionReturnsWriteConnection() { $manager = new ConnectionManagerSingle(); $manager->setConfiguration(['dsn' => 'sqlite::memory:']); $writeCon = $manager->getWriteConnection(new SqliteAdapter()); - $readCon = $manager->getReadConnection(new SqliteAdapter()); + $readCon = $manager->getReadConnection(new SqliteAdapter()); $this->assertSame($writeCon, $readCon); } + /** + * @return void + */ public function testSetConnection() { $connection = new PdoConnection('sqlite::memory:'); @@ -76,5 +95,4 @@ public function testSetConnection() $conn = $manager->getWriteConnection(); $this->assertSame($connection, $conn); } - } diff --git a/tests/Propel/Tests/Runtime/Connection/TransactionTraitTest.php b/tests/Propel/Tests/Runtime/Connection/TransactionTraitTest.php index 81a4014aad..b792f886d2 100644 --- a/tests/Propel/Tests/Runtime/Connection/TransactionTraitTest.php +++ b/tests/Propel/Tests/Runtime/Connection/TransactionTraitTest.php @@ -10,6 +10,7 @@ namespace Propel\Tests\Runtime\Connection; +use Exception; use Propel\Tests\TestCase; /** @@ -19,6 +20,11 @@ */ class TransactionTraitTest extends TestCase { + /** + * @throws \Exception + * + * @return void + */ public function testTransactionRollback() { $con = $this->getMockForTrait('Propel\Runtime\Connection\TransactionTrait'); @@ -28,15 +34,18 @@ public function testTransactionRollback() $con->expects($this->never())->method('commit'); try { - $con->transaction(function() { - throw new \Exception("boom"); + $con->transaction(function () { + throw new Exception('boom'); }); $this->fail('missing exception'); - } catch (\Exception $e) { - $this->assertEquals("boom", $e->getMessage(), "exception was rethrown"); + } catch (Exception $e) { + $this->assertEquals('boom', $e->getMessage(), 'exception was rethrown'); } } + /** + * @return void + */ public function testTransactionCommit() { $con = $this->getMockForTrait('Propel\Runtime\Connection\TransactionTrait'); @@ -45,9 +54,9 @@ public function testTransactionCommit() $con->expects($this->never())->method('rollback'); $con->expects($this->once())->method('commit'); - $this->assertNull($con->transaction(function() { + $this->assertNull($con->transaction(function () { // do nothing - }), "transaction() returns null by default"); + }), 'transaction() returns null by default'); } public function testTransactionChaining() @@ -58,11 +67,14 @@ public function testTransactionChaining() $con->expects($this->never())->method('rollback'); $con->expects($this->once())->method('commit'); - $this->assertSame("myval", $con->transaction(function() { - return "myval"; - }), "transaction() returns the returned value from the Closure"); + $this->assertSame('myval', $con->transaction(function () { + return 'myval'; + }), 'transaction() returns the returned value from the Closure'); } + /** + * @return void + */ public function testTransactionNestedCommit() { $con = $this->getMockForTrait('Propel\Runtime\Connection\TransactionTrait'); @@ -71,13 +83,18 @@ public function testTransactionNestedCommit() $con->expects($this->never())->method('rollback'); $con->expects($this->exactly(2))->method('commit'); - $this->assertNull($con->transaction(function() use ($con) { - $this->assertNull($con->transaction(function() { + $this->assertNull($con->transaction(function () use ($con) { + $this->assertNull($con->transaction(function () { // do nothing - }), "transaction() returns null by default"); - }), "transaction() returns null by default"); + }), 'transaction() returns null by default'); + }), 'transaction() returns null by default'); } + /** + * @throws \Exception + * + * @return void + */ public function testTransactionNestedException() { $con = $this->getMockForTrait('Propel\Runtime\Connection\TransactionTrait'); @@ -87,14 +104,14 @@ public function testTransactionNestedException() $con->expects($this->never())->method('commit'); try { - $con->transaction(function() use ($con) { - $con->transaction(function() { - throw new \Exception("boooom"); + $con->transaction(function () use ($con) { + $con->transaction(function () { + throw new Exception('boooom'); }); }); - $this->fail("expecting a nested exception to be re-thrown"); - } catch (\Exception $e) { - $this->assertEquals("boooom", $e->getMessage()); + $this->fail('expecting a nested exception to be re-thrown'); + } catch (Exception $e) { + $this->assertEquals('boooom', $e->getMessage()); } } } diff --git a/tests/Propel/Tests/Runtime/Exception/PropelExceptionTest.php b/tests/Propel/Tests/Runtime/Exception/PropelExceptionTest.php index 6b8ffd1d9d..c6d34065b9 100644 --- a/tests/Propel/Tests/Runtime/Exception/PropelExceptionTest.php +++ b/tests/Propel/Tests/Runtime/Exception/PropelExceptionTest.php @@ -10,6 +10,7 @@ namespace Propel\Tests\Runtime\Exception; +use Exception; use Propel\Runtime\Exception\PropelException; use Propel\Tests\TestCase; @@ -20,13 +21,19 @@ */ class PropelExceptionTest extends TestCase { + /** + * @return void + */ public function testSimpleConstructor() { $e = new PropelException('this is an error'); - $this->assertTrue($e instanceof \Exception); + $this->assertTrue($e instanceof Exception); $this->assertEquals('this is an error', $e->getMessage()); } + /** + * @return void + */ public function testCompositeConstructor() { $e1 = new FooException('real cause'); @@ -36,13 +43,19 @@ public function testCompositeConstructor() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testIsThrowable() { $e = new PropelException('this is an error'); + throw $e; } + /** + * @return void + */ public function testGetPrevious() { $e1 = new FooException('real cause'); @@ -51,4 +64,6 @@ public function testGetPrevious() } } -class FooException extends \Exception {} +class FooException extends Exception +{ +} diff --git a/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterTest.php b/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterTest.php index b5484e7738..b989e979bb 100644 --- a/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterTest.php @@ -10,14 +10,14 @@ namespace Propel\Tests\Runtime\Formatter; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; -use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; -use Propel\Tests\Bookstore\Map\BookTableMap; -use Propel\Runtime\Propel; +use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Collection\Collection; use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Formatter\ArrayFormatter; -use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\Propel; +use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Test class for ArrayFormatter. @@ -28,12 +28,18 @@ */ class ArrayFormatterTest extends BookstoreEmptyTestBase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate(); } + /** + * @return void + */ public function testFormatNoCriteria() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -44,10 +50,13 @@ public function testFormatNoCriteria() $books = $formatter->format($dataFetcher); $this->fail('ArrayFormatter::format() throws an exception when called with no valid criteria'); } catch (PropelException $e) { - $this->assertTrue(true,'ArrayFormatter::format() throws an exception when called with no valid criteria'); + $this->assertTrue(true, 'ArrayFormatter::format() throws an exception when called with no valid criteria'); } } + /** + * @return void + */ public function testFormatManyResults() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -64,6 +73,9 @@ public function testFormatManyResults() } } + /** + * @return void + */ public function testFormatOneResult() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -82,6 +94,9 @@ public function testFormatOneResult() $this->assertEquals($expected, array_keys($book), 'ArrayFormatter::format() returns an associative array with column phpNames as keys'); } + /** + * @return void + */ public function testFormatNoResult() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -95,6 +110,9 @@ public function testFormatNoResult() $this->assertEquals(0, count($books), 'ArrayFormatter::format() returns as many rows as the results in the query'); } + /** + * @return void + */ public function testFormatOneNoCriteria() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -105,10 +123,13 @@ public function testFormatOneNoCriteria() $book = $formatter->formatOne($dataFetcher); $this->fail('ArrayFormatter::formatOne() throws an exception when called with no valid criteria'); } catch (PropelException $e) { - $this->assertTrue(true,'ArrayFormatter::formatOne() throws an exception when called with no valid criteria'); + $this->assertTrue(true, 'ArrayFormatter::formatOne() throws an exception when called with no valid criteria'); } } + /** + * @return void + */ public function testFormatOneManyResults() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -122,6 +143,9 @@ public function testFormatOneManyResults() $this->assertEquals(['Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId'], array_keys($book), 'ArrayFormatter::formatOne() returns a single row even if the query has many results'); } + /** + * @return void + */ public function testFormatOneNoResult() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -133,5 +157,4 @@ public function testFormatOneNoResult() $this->assertNull($book, 'ArrayFormatter::formatOne() returns null when no result'); } - } diff --git a/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterWithTest.php b/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterWithTest.php index 7a3b1cc7f6..0ba83f3cf6 100644 --- a/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterWithTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterWithTest.php @@ -10,21 +10,21 @@ namespace Propel\Tests\Runtime\Formatter; -use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\ModelCriteria; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; -use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\AuthorQuery; use Propel\Tests\Bookstore\Book; use Propel\Tests\Bookstore\BookQuery; use Propel\Tests\Bookstore\Essay; -use Propel\Tests\Bookstore\Review; use Propel\Tests\Bookstore\Map\AuthorTableMap; -use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\BookstoreEmployeeTableMap; +use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\EssayTableMap; use Propel\Tests\Bookstore\Map\ReviewTableMap; +use Propel\Tests\Bookstore\Review; +use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Test class for ArrayFormatter when Criteria uses with(). @@ -35,6 +35,9 @@ */ class ArrayFormatterWithTest extends BookstoreEmptyTestBase { + /** + * @return void + */ protected function assertCorrectHydration1($c, $msg) { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -47,6 +50,9 @@ protected function assertCorrectHydration1($c, $msg) $this->assertEquals($publisher['Name'], 'Penguin', 'Related object is correctly hydrated ' . $msg); } + /** + * @return void + */ public function testFindOneWith() { BookstoreDataPopulator::populate(); @@ -62,6 +68,9 @@ public function testFindOneWith() $this->assertCorrectHydration1($c, 'without instance pool'); } + /** + * @return void + */ public function testFindOneWithAlias() { BookstoreDataPopulator::populate(); @@ -77,6 +86,9 @@ public function testFindOneWithAlias() $this->assertCorrectHydration1($c, 'with alias'); } + /** + * @return void + */ public function testFindOneWithMainAlias() { BookstoreDataPopulator::populate(); @@ -93,6 +105,9 @@ public function testFindOneWithMainAlias() $this->assertCorrectHydration1($c, 'with main alias'); } + /** + * @return void + */ public function testFindOneWithUsingInstancePool() { BookstoreDataPopulator::populate(); @@ -107,6 +122,9 @@ public function testFindOneWithUsingInstancePool() $this->assertCorrectHydration1($c, 'with instance pool'); } + /** + * @return void + */ public function testFindOneWithEmptyLeftJoin() { // save a book with no author @@ -126,6 +144,9 @@ public function testFindOneWithEmptyLeftJoin() $this->assertEquals([], $author, 'Related object is not hydrated if empty'); } + /** + * @return void + */ public function testFindOneWithRelationName() { BookstoreDataPopulator::populate(); @@ -143,6 +164,8 @@ public function testFindOneWithRelationName() /** * @see http://www.propelorm.org/ticket/959 + * + * @return void */ public function testFindOneWithSameRelatedObject() { @@ -178,6 +201,9 @@ public function testFindOneWithSameRelatedObject() $this->assertTrue(isset($secondBook['Author'])); } + /** + * @return void + */ public function testFindOneWithDuplicateRelation() { EssayTableMap::doDeleteAll(); @@ -209,6 +235,9 @@ public function testFindOneWithDuplicateRelation() $this->assertFalse(array_key_exists('SecondAuthor', $essay), 'Only related object specified in with() is hydrated'); } + /** + * @return void + */ public function testFindOneWithDistantClass() { BookstoreDataPopulator::populate(); @@ -230,6 +259,9 @@ public function testFindOneWithDistantClass() $this->assertEquals('J.K.', $author['FirstName'], 'Related object is correctly hydrated'); } + /** + * @return void + */ public function testFindOneWithDistantClassRenamedRelation() { BookstoreDataPopulator::populate(); @@ -255,6 +287,8 @@ public function testFindOneWithDistantClassRenamedRelation() /** * @expectedException \Propel\Runtime\Exception\LogicException + * + * @return void */ public function testFindOneWithOneToManyAndLimit() { @@ -267,6 +301,9 @@ public function testFindOneWithOneToManyAndLimit() $books = $c->find(); } + /** + * @return void + */ public function testFindOneWithOneToMany() { BookstoreDataPopulator::populate(); @@ -291,6 +328,9 @@ public function testFindOneWithOneToMany() $this->assertEquals(['Id', 'ReviewedBy', 'ReviewDate', 'Recommended', 'Status', 'BookId'], array_keys($review1), 'with() Related objects are correctly hydrated'); } + /** + * @return void + */ public function testFindOneWithOneToManyCustomOrder() { $author1 = new Author(); @@ -323,6 +363,9 @@ public function testFindOneWithOneToManyCustomOrder() $this->assertEquals(2, count($authors), 'with() used on a many-to-many doesn\'t change the main object count'); } + /** + * @return void + */ public function testFindOneWithOneToManyThenManyToOne() { BookstoreDataPopulator::populate(); @@ -347,6 +390,9 @@ public function testFindOneWithOneToManyThenManyToOne() $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); } + /** + * @return void + */ public function testFindOneWithOneToManyThenManyToOneUsingAlias() { BookstoreDataPopulator::populate(); @@ -371,14 +417,17 @@ public function testFindOneWithOneToManyThenManyToOneUsingAlias() $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); } + /** + * @return void + */ public function testFindWithLeftJoinWithOneToManyAndNullObject() { BookTableMap::clearInstancePool(); AuthorTableMap::clearInstancePool(); ReviewTableMap::clearInstancePool(); $freud = new Author(); - $freud->setFirstName("Sigmund"); - $freud->setLastName("Freud"); + $freud->setFirstName('Sigmund'); + $freud->setLastName('Freud'); $freud->save($this->con); $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author'); $c->setFormatter(ModelCriteria::FORMAT_ARRAY); @@ -390,6 +439,9 @@ public function testFindWithLeftJoinWithOneToManyAndNullObject() $this->assertTrue(true); } + /** + * @return void + */ public function testFindWithLeftJoinWithManyToOneAndNullObject() { if (!$this->runningOnSQLite()) { @@ -400,7 +452,7 @@ public function testFindWithLeftJoinWithManyToOneAndNullObject() AuthorTableMap::clearInstancePool(); ReviewTableMap::clearInstancePool(); $review = new Review(); - $review->setReviewedBy("Peter"); + $review->setReviewedBy('Peter'); $review->setRecommended(true); $review->save($this->con); $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Review'); @@ -412,6 +464,9 @@ public function testFindWithLeftJoinWithManyToOneAndNullObject() $this->assertTrue(true); } + /** + * @return void + */ public function testFindOneWithColumn() { BookstoreDataPopulator::populate(); @@ -432,6 +487,9 @@ public function testFindOneWithColumn() $this->assertEquals('Grass', $book['AuthorName2'], 'ArrayFormatter correctly hydrates all as columns'); } + /** + * @return void + */ public function testFindOneWithClassAndColumn() { BookstoreDataPopulator::populate(); @@ -454,6 +512,9 @@ public function testFindOneWithClassAndColumn() $this->assertEquals('Grass', $book['AuthorName2'], 'ArrayFormatter correctly hydrates all as columns'); } + /** + * @return void + */ public function testFindPkWithOneToMany() { BookstoreDataPopulator::populate(); diff --git a/tests/Propel/Tests/Runtime/Formatter/DataFetcherTest.php b/tests/Propel/Tests/Runtime/Formatter/DataFetcherTest.php index 20937427ec..a0d8c9015f 100644 --- a/tests/Propel/Tests/Runtime/Formatter/DataFetcherTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/DataFetcherTest.php @@ -11,11 +11,11 @@ namespace Propel\Tests\Runtime\Formatter; use Propel\Runtime\DataFetcher\ArrayDataFetcher; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; -use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; -use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Propel; +use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Test class for DataFetcher. @@ -24,15 +24,21 @@ */ class DataFetcherTest extends BookstoreEmptyTestBase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate(); } + /** + * @return void + */ public function testGeneral() { - $items = [5, 22, 33]; + $items = [5, 22, 33]; $items2 = [882, 34]; $dataFetcher = new ArrayDataFetcher($items); @@ -42,6 +48,9 @@ public function testGeneral() $this->assertEquals($items2, $dataFetcher->getDataObject()); } + /** + * @return void + */ public function testPDODataFetcher() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -74,13 +83,13 @@ public function testPDODataFetcher() $this->assertEquals('Quicksilver', $dataFetcher->fetchColumn(1)); $dataFetcher = $con->query('SELECT id, title, isbn, price, publisher_id, author_id FROM book'); - $rows = []; - $last = null; - $i = -1; + $rows = []; + $last = null; + $i = -1; foreach ($dataFetcher as $k => $row) { $rows[] = $row; - $last = $row; + $last = $row; $i++; $this->assertNotNull($row); $this->assertEquals($i, $k); @@ -89,11 +98,14 @@ public function testPDODataFetcher() $this->assertEquals('The Tin Drum', $last[1]); } + /** + * @return void + */ public function testArrayDataFetcher() { $items = [ ['col1' => 'Peter', 'col2' => 'Mueller'], - ['col1' => 'Sergey', 'col2' => 'Sayer'] + ['col1' => 'Sergey', 'col2' => 'Sayer'], ]; $dataFetcher = new ArrayDataFetcher($items); diff --git a/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterInheritanceTest.php b/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterInheritanceTest.php index 0361c390b0..b0ddb22f64 100644 --- a/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterInheritanceTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterInheritanceTest.php @@ -10,15 +10,15 @@ namespace Propel\Tests\Runtime\Formatter; -use Propel\Runtime\Propel; -use Propel\Runtime\Formatter\ObjectFormatter; use Propel\Runtime\ActiveQuery\ModelCriteria; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; -use Propel\Tests\Bookstore\Map\BookTableMap; -use Propel\Tests\Bookstore\BookstoreEmployee; +use Propel\Runtime\Formatter\ObjectFormatter; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\BookstoreCashier; +use Propel\Tests\Bookstore\BookstoreEmployee; use Propel\Tests\Bookstore\BookstoreManager; use Propel\Tests\Bookstore\Map\BookstoreEmployeeTableMap; +use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Test class for ObjectFormatter. @@ -29,6 +29,9 @@ */ class ObjectFormatterInheritanceTest extends BookstoreEmptyTestBase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -43,6 +46,9 @@ protected function setUp(): void $b3->save(); } + /** + * @return void + */ public function testFormat() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -53,13 +59,12 @@ public function testFormat() $formatter->init(new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\BookstoreEmployee')); $emps = $formatter->format($stmt); $expectedClass = [ - 'b1' =>'Propel\Tests\Bookstore\BookstoreEmployee', - 'b2' =>'Propel\Tests\Bookstore\BookstoreManager', - 'b3' =>'Propel\Tests\Bookstore\BookstoreCashier' + 'b1' => 'Propel\Tests\Bookstore\BookstoreEmployee', + 'b2' => 'Propel\Tests\Bookstore\BookstoreManager', + 'b3' => 'Propel\Tests\Bookstore\BookstoreCashier', ]; foreach ($emps as $emp) { $this->assertEquals($expectedClass[$emp->getName()], get_class($emp), 'format() creates objects of the correct class when using inheritance'); } } - } diff --git a/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterTest.php b/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterTest.php index cf08ae909a..347027adbb 100644 --- a/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterTest.php @@ -10,19 +10,17 @@ namespace Propel\Tests\Runtime\Formatter; -use Propel\Tests\Bookstore\AuthorCollection; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; -use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; - -use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\Map\BookTableMap; - -use Propel\Runtime\Propel; -use Propel\Runtime\Exception\PropelException; +use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Collection\Collection; use Propel\Runtime\Collection\ObjectCollection; +use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Formatter\ObjectFormatter; -use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\Propel; +use Propel\Tests\Bookstore\AuthorCollection; +use Propel\Tests\Bookstore\Book; +use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Test class for ObjectFormatter. @@ -33,12 +31,18 @@ */ class ObjectFormatterTest extends BookstoreEmptyTestBase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate(); } + /** + * @return void + */ public function testFormatNoCriteria() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -49,10 +53,13 @@ public function testFormatNoCriteria() $books = $formatter->format($stmt); $this->fail('ObjectFormatter::format() trows an exception when called with no valid criteria'); } catch (PropelException $e) { - $this->assertTrue(true,'ObjectFormatter::format() trows an exception when called with no valid criteria'); + $this->assertTrue(true, 'ObjectFormatter::format() trows an exception when called with no valid criteria'); } } + /** + * @return void + */ public function testFormatValidClass() { $stmt = $this->con->query('SELECT * FROM book'); @@ -63,6 +70,9 @@ public function testFormatValidClass() $this->assertEquals(4, $books->count()); } + /** + * @return void + */ public function testFormatValidClassCustomCollection() { $stmt = $this->con->query('SELECT * FROM author'); @@ -72,6 +82,9 @@ public function testFormatValidClassCustomCollection() $this->assertTrue($authors instanceof AuthorCollection); } + /** + * @return void + */ public function testFormatManyResults() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -88,6 +101,9 @@ public function testFormatManyResults() } } + /** + * @return void + */ public function testFormatOneResult() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -104,6 +120,9 @@ public function testFormatOneResult() $this->assertEquals('Quicksilver', $book->getTitle(), 'ObjectFormatter::format() returns the model objects matching the query'); } + /** + * @return void + */ public function testFormatNoResult() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -117,6 +136,9 @@ public function testFormatNoResult() $this->assertEquals(0, count($books), 'ObjectFormatter::format() returns as many rows as the results in the query'); } + /** + * @return void + */ public function testFormatOneNoCriteria() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -127,10 +149,13 @@ public function testFormatOneNoCriteria() $book = $formatter->formatOne($stmt); $this->fail('ObjectFormatter::formatOne() throws an exception when called with no valid criteria'); } catch (PropelException $e) { - $this->assertTrue(true,'ObjectFormatter::formatOne() throws an exception when called with no valid criteria'); + $this->assertTrue(true, 'ObjectFormatter::formatOne() throws an exception when called with no valid criteria'); } } + /** + * @return void + */ public function testFormatOneManyResults() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -143,6 +168,9 @@ public function testFormatOneManyResults() $this->assertTrue($book instanceof Book, 'ObjectFormatter::formatOne() returns a model object'); } + /** + * @return void + */ public function testFormatOneNoResult() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -154,5 +182,4 @@ public function testFormatOneNoResult() $this->assertNull($book, 'ObjectFormatter::formatOne() returns null when no result'); } - } diff --git a/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterWithTest.php b/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterWithTest.php index 11c06a7868..f7db57dddb 100644 --- a/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterWithTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterWithTest.php @@ -10,28 +10,25 @@ namespace Propel\Tests\Runtime\Formatter; -use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\AuthorQuery; use Propel\Tests\Bookstore\Book; use Propel\Tests\Bookstore\BookQuery; -use Propel\Tests\Bookstore\BookstoreEmployee; -use Propel\Tests\Bookstore\BookOpinion; -use Propel\Tests\Bookstore\BookReader; use Propel\Tests\Bookstore\Essay; -use Propel\Tests\Bookstore\Publisher; -use Propel\Tests\Bookstore\Review; use Propel\Tests\Bookstore\Map\AuthorTableMap; -use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Bookstore\Map\BookOpinionTableMap; +use Propel\Tests\Bookstore\Map\BookReaderTableMap; use Propel\Tests\Bookstore\Map\BookstoreEmployeeTableMap; +use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\EssayTableMap; use Propel\Tests\Bookstore\Map\ReviewTableMap; -use Propel\Tests\Bookstore\Map\BookOpinionTableMap; -use Propel\Tests\Bookstore\Map\BookReaderTableMap; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; +use Propel\Tests\Bookstore\Publisher; +use Propel\Tests\Bookstore\Review; use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Test class for ObjectFormatter when Criteria uses with(). @@ -42,6 +39,9 @@ */ class ObjectFormatterWithTest extends BookstoreEmptyTestBase { + /** + * @return void + */ protected function assertCorrectHydration1($c, $msg) { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -56,6 +56,9 @@ protected function assertCorrectHydration1($c, $msg) $this->assertEquals($publisher->getName(), 'Penguin', 'Related object is correctly hydrated ' . $msg); } + /** + * @return void + */ public function testOneToManyRelationHydration() { BookstoreDataPopulator::populate(); @@ -65,16 +68,19 @@ public function testOneToManyRelationHydration() ->filterByISBN('043935806X'); //Harry Potter Propel::disableInstancePooling(); - /** @var Book $books */ + /** @var \Propel\Tests\Bookstore\Book $books */ $book = $bookQuery->find()[0]; $this->assertCount(2, $book->getReviews()); Propel::enableInstancePooling(); - /** @var Book $books */ + /** @var \Propel\Tests\Bookstore\Book $books */ $book = $bookQuery->find()[0]; $this->assertCount(2, $book->getReviews()); } + /** + * @return void + */ public function testFindOneWith() { BookstoreDataPopulator::populate(); @@ -89,6 +95,9 @@ public function testFindOneWith() $this->assertCorrectHydration1($c, 'without instance pool'); } + /** + * @return void + */ public function testFindOneWithAlias() { BookstoreDataPopulator::populate(); @@ -103,6 +112,9 @@ public function testFindOneWithAlias() $this->assertCorrectHydration1($c, 'with alias'); } + /** + * @return void + */ public function testFindOneWithMainAlias() { BookstoreDataPopulator::populate(); @@ -118,6 +130,9 @@ public function testFindOneWithMainAlias() $this->assertCorrectHydration1($c, 'with main alias'); } + /** + * @return void + */ public function testFindOneWithUsingInstancePool() { BookstoreDataPopulator::populate(); @@ -131,6 +146,9 @@ public function testFindOneWithUsingInstancePool() $this->assertCorrectHydration1($c, 'with instance pool'); } + /** + * @return void + */ public function testFindOneWithoutUsingInstancePool() { BookstoreDataPopulator::populate(); @@ -145,6 +163,9 @@ public function testFindOneWithoutUsingInstancePool() Propel::enableInstancePooling(); } + /** + * @return void + */ public function testFindOneWithEmptyLeftJoin() { // save a book with no author @@ -164,6 +185,9 @@ public function testFindOneWithEmptyLeftJoin() $this->assertEquals($count, $con->getQueryCount()); } + /** + * @return void + */ public function testFindOneWithEmptyLeftJoinOneToMany() { // non-empty relation @@ -203,6 +227,9 @@ public function testFindOneWithEmptyLeftJoinOneToMany() $this->assertEquals($count, $con->getQueryCount()); } + /** + * @return void + */ public function testFindOneWithRelationName() { BookstoreDataPopulator::populate(); @@ -220,6 +247,9 @@ public function testFindOneWithRelationName() $this->assertEquals($sup->getName(), 'John', 'Related object is correctly hydrated'); } + /** + * @return void + */ public function testFindOneWithDuplicateRelation() { EssayTableMap::doDeleteAll(); @@ -254,6 +284,9 @@ public function testFindOneWithDuplicateRelation() $this->assertEquals($count + 1, $con->getQueryCount(), 'with() does not hydrate objects not in with'); } + /** + * @return void + */ public function testFindOneWithEmptyDuplicateRelation() { EssayTableMap::doDeleteAll(); @@ -276,6 +309,9 @@ public function testFindOneWithEmptyDuplicateRelation() $this->assertTrue(true); } + /** + * @return void + */ public function testFindOneWithDistantClass() { BookstoreDataPopulator::populate(); @@ -301,6 +337,9 @@ public function testFindOneWithDistantClass() $this->assertEquals('J.K.', $author->getFirstName(), 'Related object is correctly hydrated'); } + /** + * @return void + */ public function testFindOneWithDistantClassRenamedRelation() { BookstoreDataPopulator::populate(); @@ -325,6 +364,8 @@ public function testFindOneWithDistantClassRenamedRelation() /** * @expectedException \Propel\Runtime\Exception\LogicException + * + * @return void */ public function testFindOneWithOneToManyAndLimit() { @@ -336,6 +377,9 @@ public function testFindOneWithOneToManyAndLimit() $books = $c->find(); } + /** + * @return void + */ public function testFindOneWithOneToMany() { BookstoreDataPopulator::populate(); @@ -362,6 +406,9 @@ public function testFindOneWithOneToMany() } } + /** + * @return void + */ public function testFindOneWithOneToManyCustomOrder() { $author1 = new Author(); @@ -393,6 +440,9 @@ public function testFindOneWithOneToManyCustomOrder() $this->assertEquals(2, count($authors), 'with() used on a many-to-many doesn\'t change the main object count'); } + /** + * @return void + */ public function testFindOneWithOneToManyThenManyToOne() { BookstoreDataPopulator::populate(); @@ -419,14 +469,17 @@ public function testFindOneWithOneToManyThenManyToOne() $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); } + /** + * @return void + */ public function testFindWithLeftJoinWithOneToManyAndNullObject() { BookTableMap::clearInstancePool(); AuthorTableMap::clearInstancePool(); ReviewTableMap::clearInstancePool(); $freud = new Author(); - $freud->setFirstName("Sigmund"); - $freud->setLastName("Freud"); + $freud->setFirstName('Sigmund'); + $freud->setLastName('Freud'); $freud->save($this->con); $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author'); $c->add(AuthorTableMap::COL_LAST_NAME, 'Freud'); @@ -437,6 +490,9 @@ public function testFindWithLeftJoinWithOneToManyAndNullObject() $this->assertTrue(true); } + /** + * @return void + */ public function testFindWithLeftJoinWithManyToOneAndNullObject() { if (!$this->runningOnSQLite()) { @@ -458,6 +514,9 @@ public function testFindWithLeftJoinWithManyToOneAndNullObject() $this->assertTrue(true); } + /** + * @return void + */ public function testFindOneWithOneToManyThenManyToOneUsingJoinRelated() { BookstoreDataPopulator::populate(); @@ -489,6 +548,9 @@ public function testFindOneWithOneToManyThenManyToOneUsingJoinRelated() $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); } + /** + * @return void + */ public function testFindOneWithOneToManyThenManyToOneUsingAlias() { BookstoreDataPopulator::populate(); @@ -515,6 +577,9 @@ public function testFindOneWithOneToManyThenManyToOneUsingAlias() $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); } + /** + * @return void + */ public function testFindOneWithColumn() { BookstoreDataPopulator::populate(); @@ -535,6 +600,9 @@ public function testFindOneWithColumn() $this->assertEquals('Gunter', $book->getAuthorName(), 'ObjectFormatter adds withColumns as virtual columns'); } + /** + * @return void + */ public function testFindOneWithColumnAndAlias() { BookstoreDataPopulator::populate(); @@ -559,6 +627,9 @@ public function testFindOneWithColumnAndAlias() $this->assertEquals('J.K.', $book->getVirtualColumn('AuthorName'), 'ObjectFormatter adds withColumns as virtual columns'); } + /** + * @return void + */ public function testFindOneWithClassAndColumn() { BookstoreDataPopulator::populate(); @@ -581,6 +652,9 @@ public function testFindOneWithClassAndColumn() $this->assertEquals('Grass', $book->getVirtualColumn('AuthorName2'), 'ObjectFormatter correctly hydrates all virtual columns'); } + /** + * @return void + */ public function testFindPkWithOneToMany() { BookstoreDataPopulator::populate(); @@ -601,6 +675,9 @@ public function testFindPkWithOneToMany() $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); } + /** + * @return void + */ public function testFindOneWithLeftJoinWithOneToManyAndNullObjectsAndWithAdditionalJoins() { BookTableMap::clearInstancePool(); @@ -609,8 +686,8 @@ public function testFindOneWithLeftJoinWithOneToManyAndNullObjectsAndWithAdditio BookReaderTableMap::clearInstancePool(); $freud = new Author(); - $freud->setFirstName("Sigmund"); - $freud->setLastName("Freud"); + $freud->setFirstName('Sigmund'); + $freud->setLastName('Freud'); $freud->save($this->con); $publisher = new Publisher(); diff --git a/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterTest.php b/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterTest.php index dbca79711c..081f1975bb 100644 --- a/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterTest.php @@ -10,18 +10,15 @@ namespace Propel\Tests\Runtime\Formatter; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; -use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; - -use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\Map\BookTableMap; - -use Propel\Runtime\Propel; -use Propel\Runtime\Collection\Collection; +use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Collection\OnDemandCollection; use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Formatter\OnDemandFormatter; -use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\Propel; +use Propel\Tests\Bookstore\Book; +use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Test class for OnDemandFormatter. @@ -32,6 +29,9 @@ */ class OnDemandFormatterTest extends BookstoreEmptyTestBase { + /** + * @return void + */ public function testFormatterReenablesInstancePoolAfterIteration() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -50,6 +50,9 @@ public function testFormatterReenablesInstancePoolAfterIteration() $this->assertTrue(Propel::isInstancePoolingEnabled()); } + /** + * @return void + */ public function testFormatterReenablesInstancePoolAfterClosingCursor() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -65,6 +68,9 @@ public function testFormatterReenablesInstancePoolAfterClosingCursor() $this->assertTrue(Propel::isInstancePoolingEnabled()); } + /** + * @return void + */ public function testFormatterDoesNotReenableInstancePoolIfItWasInitiallyDisabled() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -81,6 +87,9 @@ public function testFormatterDoesNotReenableInstancePoolIfItWasInitiallyDisabled Propel::enableInstancePooling(); } + /** + * @return void + */ public function testFormatNoCriteria() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -91,10 +100,13 @@ public function testFormatNoCriteria() $books = $formatter->format($stmt); $this->fail('OnDemandFormatter::format() trows an exception when called with no valid criteria'); } catch (PropelException $e) { - $this->assertTrue(true,'OnDemandFormatter::format() trows an exception when called with no valid criteria'); + $this->assertTrue(true, 'OnDemandFormatter::format() trows an exception when called with no valid criteria'); } } + /** + * @return void + */ public function testFormatManyResults() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -114,6 +126,8 @@ public function testFormatManyResults() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testFormatManyResultsIteratedTwice() { @@ -133,13 +147,16 @@ public function testFormatManyResultsIteratedTwice() } } + /** + * @return void + */ public function testFormatALotOfResults() { $nbBooks = 50; $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); Propel::disableInstancePooling(); $book = new Book(); - for ($i=0; $i < $nbBooks; $i++) { + for ($i = 0; $i < $nbBooks; $i++) { $book->clear(); $book->setTitle('BookTest' . $i); $book->setISBN('FA404-' . $i); @@ -162,7 +179,9 @@ public function testFormatALotOfResults() Propel::enableInstancePooling(); } - + /** + * @return void + */ public function testFormatOneResult() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -181,6 +200,9 @@ public function testFormatOneResult() } } + /** + * @return void + */ public function testFormatNoResult() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -197,6 +219,9 @@ public function testFormatNoResult() } } + /** + * @return void + */ public function testFormatOneManyResults() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -209,5 +234,4 @@ public function testFormatOneManyResults() $this->assertTrue($book instanceof Book, 'OnDemandFormatter::formatOne() returns a model object'); } - } diff --git a/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterWithTest.php b/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterWithTest.php index 62af8c7cab..69a06bc3fb 100644 --- a/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterWithTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterWithTest.php @@ -10,20 +10,19 @@ namespace Propel\Tests\Runtime\Formatter; -use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\BookstoreEmployee; use Propel\Tests\Bookstore\Essay; -use Propel\Tests\Bookstore\Review; use Propel\Tests\Bookstore\Map\AuthorTableMap; -use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\BookstoreEmployeeTableMap; +use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\EssayTableMap; use Propel\Tests\Bookstore\Map\ReviewTableMap; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; +use Propel\Tests\Bookstore\Review; use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Test class for OnDemandFormatter when Criteria uses with(). @@ -34,6 +33,9 @@ */ class OnDemandFormatterWithTest extends BookstoreEmptyTestBase { + /** + * @return void + */ protected function assertCorrectHydration1($c, $msg) { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -52,6 +54,9 @@ protected function assertCorrectHydration1($c, $msg) $this->assertEquals($publisher->getName(), 'Penguin', 'Related object is correctly hydrated ' . $msg); } + /** + * @return void + */ public function testFindOneWith() { BookstoreDataPopulator::populate(); @@ -67,6 +72,9 @@ public function testFindOneWith() $this->assertCorrectHydration1($c, 'without instance pool'); } + /** + * @return void + */ public function testFindOneWithAlias() { BookstoreDataPopulator::populate(); @@ -82,6 +90,9 @@ public function testFindOneWithAlias() $this->assertCorrectHydration1($c, 'with alias'); } + /** + * @return void + */ public function testFindOneWithMainAlias() { BookstoreDataPopulator::populate(); @@ -98,6 +109,9 @@ public function testFindOneWithMainAlias() $this->assertCorrectHydration1($c, 'with main alias'); } + /** + * @return void + */ public function testFindOneWithUsingInstancePool() { BookstoreDataPopulator::populate(); @@ -112,6 +126,9 @@ public function testFindOneWithUsingInstancePool() $this->assertCorrectHydration1($c, 'with instance pool'); } + /** + * @return void + */ public function testFindOneWithEmptyLeftJoin() { // save a book with no author @@ -135,6 +152,9 @@ public function testFindOneWithEmptyLeftJoin() $this->assertNull($author, 'Related object is not hydrated if empty'); } + /** + * @return void + */ public function testFindOneWithRelationName() { BookstoreDataPopulator::populate(); @@ -156,6 +176,9 @@ public function testFindOneWithRelationName() $this->assertEquals($sup->getName(), 'John', 'Related object is correctly hydrated'); } + /** + * @return void + */ public function testFindOneWithDuplicateRelation() { EssayTableMap::doDeleteAll(); @@ -195,6 +218,9 @@ public function testFindOneWithDuplicateRelation() $this->assertEquals($count + 1, $con->getQueryCount(), 'with() does not hydrate objects not in with'); } + /** + * @return void + */ public function testFindOneWithDistantClass() { BookstoreDataPopulator::populate(); @@ -224,6 +250,9 @@ public function testFindOneWithDistantClass() $this->assertEquals('J.K.', $author->getFirstName(), 'Related object is correctly hydrated'); } + /** + * @return void + */ public function testFindOneWithDistantClassRenamedRelation() { BookstoreDataPopulator::populate(); @@ -249,6 +278,8 @@ public function testFindOneWithDistantClassRenamedRelation() /** * @expectedException \Propel\Runtime\Exception\LogicException + * + * @return void */ public function testFindOneWithOneToMany() { @@ -264,6 +295,9 @@ public function testFindOneWithOneToMany() $books = $c->find(); } + /** + * @return void + */ public function testFindWithLeftJoinWithManyToOneAndNullObject() { if (!$this->runningOnSQLite()) { @@ -286,6 +320,9 @@ public function testFindWithLeftJoinWithManyToOneAndNullObject() $this->assertTrue(true); } + /** + * @return void + */ public function testFindOneWithColumn() { BookstoreDataPopulator::populate(); @@ -311,6 +348,9 @@ public function testFindOneWithColumn() $this->assertEquals('Gunter', $book->getAuthorName(), 'ObjectFormatter adds withColumns as virtual columns'); } + /** + * @return void + */ public function testFindOneWithClassAndColumn() { BookstoreDataPopulator::populate(); diff --git a/tests/Propel/Tests/Runtime/Formatter/SimpleArrayFormatterTest.php b/tests/Propel/Tests/Runtime/Formatter/SimpleArrayFormatterTest.php index 7d2fb8f4c8..a42dd7fad0 100644 --- a/tests/Propel/Tests/Runtime/Formatter/SimpleArrayFormatterTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/SimpleArrayFormatterTest.php @@ -10,24 +10,30 @@ namespace Propel\Tests\Runtime\Formatter; -use Propel\Runtime\Propel; -use Propel\Runtime\Formatter\SimpleArrayFormatter; use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\Formatter\SimpleArrayFormatter; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Map\BookTableMap; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * @group database */ class SimpleArrayFormatterTest extends BookstoreEmptyTestBase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate(); } + /** + * @return void + */ public function testFormatWithOneRowAndValueIsNotZero() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -39,9 +45,12 @@ public function testFormatWithOneRowAndValueIsNotZero() $books = $formatter->format($stmt); $this->assertInstanceOf('\Propel\Runtime\Collection\Collection', $books); $this->assertCount(4, $books); - $this->assertSame(1, $books[0]+0); + $this->assertSame(1, $books[0] + 0); } + /** + * @return void + */ public function testFormatWithOneRowAndValueEqualsZero() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -53,9 +62,12 @@ public function testFormatWithOneRowAndValueEqualsZero() $books = $formatter->format($stmt); $this->assertInstanceOf('\Propel\Runtime\Collection\Collection', $books); $this->assertCount(4, $books); - $this->assertSame(0, $books[0]+0); + $this->assertSame(0, $books[0] + 0); } + /** + * @return void + */ public function testFormatOneWithOneRowAndValueIsNotZero() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -69,9 +81,12 @@ public function testFormatOneWithOneRowAndValueIsNotZero() $formatter->init(new ModelCriteria('bookstore', '\Propel\Tests\Bookstore\Book')); $book = $formatter->formatOne($stmt); - $this->assertSame(1, $book+0); + $this->assertSame(1, $book + 0); } + /** + * @return void + */ public function testFormatOneWithOneRowAndValueEqualsZero() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -85,6 +100,6 @@ public function testFormatOneWithOneRowAndValueEqualsZero() $formatter->init(new ModelCriteria('bookstore', '\Propel\Tests\Bookstore\Book')); $book = $formatter->formatOne($stmt); - $this->assertSame(0, $book+0); + $this->assertSame(0, $book + 0); } } diff --git a/tests/Propel/Tests/Runtime/Formatter/StatementFormatterTest.php b/tests/Propel/Tests/Runtime/Formatter/StatementFormatterTest.php index 272519e46c..74be4b7b75 100644 --- a/tests/Propel/Tests/Runtime/Formatter/StatementFormatterTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/StatementFormatterTest.php @@ -10,20 +10,14 @@ namespace Propel\Tests\Runtime\Formatter; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; -use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; - -use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\Map\BookTableMap; - -use Propel\Runtime\Propel; +use PDO; +use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Formatter\StatementFormatter; -use Propel\Runtime\ActiveQuery\ModelCriteria; - -use Propel\Runtime\DataFetcher\PDODataFetcher; - -use \PDO; +use Propel\Runtime\Propel; +use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Test class for StatementFormatter. @@ -34,12 +28,18 @@ */ class StatementFormatterTest extends BookstoreEmptyTestBase { + /** + * @return void + */ protected function setUp(): void { parent::setUp(); BookstoreDataPopulator::populate(); } + /** + * @return void + */ public function testFormatNoCriteria() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -54,6 +54,9 @@ public function testFormatNoCriteria() } } + /** + * @return void + */ public function testFormatManyResults() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -70,6 +73,9 @@ public function testFormatManyResults() } } + /** + * @return void + */ public function testFormatOneResult() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -85,6 +91,9 @@ public function testFormatOneResult() $this->assertEquals('Quicksilver', $book['title'], 'StatementFormatter::format() returns the rows matching the query'); } + /** + * @return void + */ public function testFormatNoResult() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -98,6 +107,9 @@ public function testFormatNoResult() $this->assertEquals(0, $books->count(), 'StatementFormatter::format() returns as many rows as the results in the query'); } + /** + * @return void + */ public function testFormatoneNoCriteria() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -112,6 +124,9 @@ public function testFormatoneNoCriteria() } } + /** + * @return void + */ public function testFormatOneManyResults() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -124,6 +139,9 @@ public function testFormatOneManyResults() $this->assertInstanceOf('Propel\Runtime\DataFetcher\PDODataFetcher', $book, 'StatementFormatter::formatOne() returns a PDODataFetcher'); } + /** + * @return void + */ public function testFormatOneNoResult() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -135,5 +153,4 @@ public function testFormatOneNoResult() $this->assertNull($book, 'StatementFormatter::formatOne() returns null when no result'); } - } diff --git a/tests/Propel/Tests/Runtime/Map/ColumnMapTest.php b/tests/Propel/Tests/Runtime/Map/ColumnMapTest.php index 2aff732c15..71ab5a8c52 100644 --- a/tests/Propel/Tests/Runtime/Map/ColumnMapTest.php +++ b/tests/Propel/Tests/Runtime/Map/ColumnMapTest.php @@ -10,13 +10,12 @@ namespace Propel\Tests\Runtime\Map; -use Propel\Tests\Bookstore\Map\BookTableMap; -use Propel\Tests\Bookstore\Map\BookstoreEmployeeTableMap; - use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\DatabaseMap; -use Propel\Runtime\Map\TableMap; use Propel\Runtime\Map\Exception\ForeignKeyNotFoundException; +use Propel\Runtime\Map\TableMap; +use Propel\Tests\Bookstore\Map\BookstoreEmployeeTableMap; +use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\TestCaseFixtures; /** @@ -28,6 +27,9 @@ class ColumnMapTest extends TestCaseFixtures { protected $databaseMap; + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -37,12 +39,18 @@ protected function setUp(): void $this->cmap = new ColumnMap($this->columnName, $this->tmap); } + /** + * @return void + */ protected function tearDown(): void { // nothing to do for now parent::tearDown(); } + /** + * @return void + */ public function testConstructor() { $this->assertEquals($this->columnName, $this->cmap->getName(), 'constructor sets the column name'); @@ -50,6 +58,9 @@ public function testConstructor() $this->assertNull($this->cmap->getType(), 'A new column map has no type'); } + /** + * @return void + */ public function testPhpName() { $this->assertNull($this->cmap->getPhpName(), 'phpName is empty until set'); @@ -57,6 +68,9 @@ public function testPhpName() $this->assertEquals('FooBar', $this->cmap->getPhpName(), 'phpName is set by setPhpName()'); } + /** + * @return void + */ public function testType() { $this->assertNull($this->cmap->getType(), 'type is empty until set'); @@ -64,6 +78,9 @@ public function testType() $this->assertEquals('FooBar', $this->cmap->getType(), 'type is set by setType()'); } + /** + * @return void + */ public function tesSize() { $this->assertEquals(0, $this->cmap->getSize(), 'size is empty until set'); @@ -71,6 +88,9 @@ public function tesSize() $this->assertEquals(123, $this->cmap->getSize(), 'size is set by setSize()'); } + /** + * @return void + */ public function testPrimaryKey() { $this->assertFalse($this->cmap->isPrimaryKey(), 'primaryKey is false by default'); @@ -78,6 +98,9 @@ public function testPrimaryKey() $this->assertTrue($this->cmap->isPrimaryKey(), 'primaryKey is set by setPrimaryKey()'); } + /** + * @return void + */ public function testNotNull() { $this->assertFalse($this->cmap->isNotNull(), 'notNull is false by default'); @@ -85,6 +108,9 @@ public function testNotNull() $this->assertTrue($this->cmap->isNotNull(), 'notNull is set by setPrimaryKey()'); } + /** + * @return void + */ public function testDefaultValue() { $this->assertNull($this->cmap->getDefaultValue(), 'defaultValue is empty until set'); @@ -92,6 +118,9 @@ public function testDefaultValue() $this->assertEquals('FooBar', $this->cmap->getDefaultValue(), 'defaultValue is set by setDefaultValue()'); } + /** + * @return void + */ public function testGetForeignKey() { $this->assertFalse($this->cmap->isForeignKey(), 'foreignKey is false by default'); @@ -116,6 +145,9 @@ public function testGetForeignKey() $this->assertEquals($relatedCmap, $this->cmap->getRelatedColumn(), 'getRelatedColumn returns the related ColumnMap object'); } + /** + * @return void + */ public function testGetRelation() { $bookTable = BookTableMap::getTableMap(); @@ -126,9 +158,11 @@ public function testGetRelation() $bookstoreTable = BookstoreEmployeeTableMap::getTableMap(); $supervisorColumn = $bookstoreTable->getColumn('SUPERVISOR_ID'); $this->assertEquals($supervisorColumn->getRelation(), $supervisorColumn->getRelation('Supervisor'), 'getRelation() returns the RelationMap object even whit ha specific refPhpName'); - } + /** + * @return void + */ public function testNormalizeName() { $this->assertEquals('', ColumnMap::normalizeName(''), 'normalizeColumnName() returns an empty string when passed an empty string'); @@ -139,6 +173,9 @@ public function testNormalizeName() $this->assertEquals('BAR_BAZ', ColumnMap::normalizeName('foo.bar_baz'), 'normalizeColumnName() can do all the above at the same time'); } + /** + * @return void + */ public function testIsPrimaryString() { $bookTable = BookTableMap::getTableMap(); diff --git a/tests/Propel/Tests/Runtime/Map/DatabaseMapTest.php b/tests/Propel/Tests/Runtime/Map/DatabaseMapTest.php index 428c7d995e..59d3b8aee8 100644 --- a/tests/Propel/Tests/Runtime/Map/DatabaseMapTest.php +++ b/tests/Propel/Tests/Runtime/Map/DatabaseMapTest.php @@ -10,12 +10,12 @@ namespace Propel\Tests\Runtime\Map; -use Propel\Runtime\Propel; use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\DatabaseMap; -use Propel\Runtime\Map\TableMap; use Propel\Runtime\Map\Exception\ColumnNotFoundException; use Propel\Runtime\Map\Exception\TableNotFoundException; +use Propel\Runtime\Map\TableMap; +use Propel\Runtime\Propel; use Propel\Tests\TestCaseFixtures; /** @@ -27,6 +27,9 @@ class DatabaseMapTest extends TestCaseFixtures { protected $databaseMap; + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -34,17 +37,26 @@ protected function setUp(): void $this->databaseMap = TestDatabaseBuilder::getDmap(); } + /** + * @return void + */ protected function tearDown(): void { // nothing to do for now parent::tearDown(); } + /** + * @return void + */ public function testConstructor() { $this->assertEquals($this->databaseName, $this->databaseMap->getName(), 'constructor sets the table name'); } + /** + * @return void + */ public function testAddTable() { $this->assertFalse($this->databaseMap->hasTable('foo'), 'tables are empty by default'); @@ -59,6 +71,9 @@ public function testAddTable() $this->assertEquals($tmap, $this->databaseMap->getTable('foo'), 'getTable() returns a table by name when the table was added by way of addTable()'); } + /** + * @return void + */ public function testAddTableObject() { $this->assertFalse($this->databaseMap->hasTable('foo2'), 'tables are empty by default'); @@ -74,6 +89,9 @@ public function testAddTableObject() $this->assertEquals($tmap, $this->databaseMap->getTable('foo2'), 'getTable() returns a table by name when the table was added by way of addTableObject()'); } + /** + * @return void + */ public function testAddTableFromMapClass() { $table1 = $this->databaseMap->addTableFromMapClass('\Propel\Tests\Runtime\Map\BazTableMap'); @@ -85,6 +103,9 @@ public function testAddTableFromMapClass() } } + /** + * @return void + */ public function testGetColumn() { try { @@ -104,6 +125,9 @@ public function testGetColumn() $this->assertEquals($column, $this->databaseMap->getColumn('foo.BAR'), 'getColumn() returns a ColumnMap object based on a fully qualified name'); } + /** + * @return void + */ public function testGetTableByPhpName() { try { @@ -125,29 +149,38 @@ public function testGetTableByPhpName() $this->assertEquals($tmap2, $this->databaseMap->getTableByPhpName('Foo2'), 'getTableByPhpName() returns tableMap when phpName was set by way of TableMap::setPhpName()'); } + /** + * @return void + */ public function testGetTableByPhpNameNotLoaded() { $this->assertEquals('book', Propel::getServiceContainer()->getDatabaseMap('bookstore')->getTableByPhpName('Propel\Tests\Bookstore\Book')->getName(), 'getTableByPhpName() can autoload a TableMap when the class is generated and autoloaded'); } - } class TestDatabaseBuilder { protected static $dmap = null; + protected static $tmap = null; + public static function getDmap() { - if (is_null(self::$dmap)) { + if ((self::$dmap === null)) { self::$dmap = new DatabaseMap('foodb'); } return self::$dmap; } + + /** + * @return void + */ public static function setTmap($tmap) { self::$tmap = $tmap; } + public static function getTmap() { return self::$tmap; @@ -156,6 +189,9 @@ public static function getTmap() class BazTableMap extends TableMap { + /** + * @return void + */ public function initialize() { $this->setName('baz'); diff --git a/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapTest.php b/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapTest.php index f7be5c3f26..4c5466c6b8 100644 --- a/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapTest.php +++ b/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapTest.php @@ -10,8 +10,8 @@ namespace Propel\Tests\Runtime\Map; -use Propel\Runtime\Propel; use Propel\Runtime\Map\RelationMap; +use Propel\Runtime\Propel; use Propel\Tests\TestCaseFixtures; /** @@ -21,12 +21,18 @@ class GeneratedRelationMapTest extends TestCaseFixtures { protected $databaseMap; + /** + * @return void + */ protected function setUp(): void { parent::setUp(); $this->databaseMap = Propel::getServiceContainer()->getDatabaseMap('bookstore'); } + /** + * @return void + */ public function testGetRightTable() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -39,6 +45,9 @@ public function testGetRightTable() $this->assertEquals($bookEmpTable, $bookEmpAccTable->getRelation('BookstoreEmployee')->getRightTable(), 'getRightTable() returns correct table when called on a one to one relationship'); } + /** + * @return void + */ public function testColumnMappings() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -54,6 +63,9 @@ public function testColumnMappings() $this->assertEquals(['bookstore_employee.id' => 'bookstore_employee_account.employee_id'], $bookEmpTable->getRelation('BookstoreEmployeeAccount')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns foreign to local when asked left to right for a one to one relationship'); } + /** + * @return void + */ public function testCountColumnMappings() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -63,6 +75,9 @@ public function testCountColumnMappings() $this->assertEquals(2, $rfTable->getRelation('BookOpinion')->countColumnMappings()); } + /** + * @return void + */ public function testIsComposite() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -71,5 +86,4 @@ public function testIsComposite() $rfTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\ReaderFavorite'); $this->assertTrue($rfTable->getRelation('BookOpinion')->isComposite()); } - } diff --git a/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapWithSchemasTest.php b/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapWithSchemasTest.php index 13f3196200..79369d1add 100644 --- a/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapWithSchemasTest.php +++ b/tests/Propel/Tests/Runtime/Map/GeneratedRelationMapWithSchemasTest.php @@ -10,8 +10,8 @@ namespace Propel\Tests\Runtime\Map; -use Propel\Runtime\Propel; use Propel\Runtime\Map\RelationMap; +use Propel\Runtime\Propel; use Propel\Tests\TestCaseFixturesDatabase; /** @@ -26,12 +26,18 @@ class GeneratedRelationMapWithSchemasTest extends TestCaseFixturesDatabase */ protected $databaseMap; + /** + * @return void + */ protected function setUp(): void { parent::setUp(); $this->databaseMap = Propel::getServiceContainer()->getDatabaseMap('bookstore-schemas'); } + /** + * @return void + */ public function testGetRightTable() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\BookstoreSchemas\Bookstore'); @@ -60,20 +66,22 @@ public function testGetRightTable() ); } + /** + * @return void + */ public function testColumnMappings() { $contestTable = $this->databaseMap->getTableByPhpName('Propel\Tests\BookstoreSchemas\BookstoreContest'); $del = $this->getPlatform()->getSchemaDelimiter(); - $this->assertEquals(['contest'.$del.'bookstore_contest.bookstore_id' => 'bookstore_schemas'.$del.'bookstore.id'], $contestTable->getRelation('Bookstore')->getColumnMappings(), 'getColumnMappings returns local to foreign by default'); - $this->assertEquals(['contest'.$del.'bookstore_contest.bookstore_id' => 'bookstore_schemas'.$del.'bookstore.id'], $contestTable->getRelation('Bookstore')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns local to foreign when asked left to right for a many to one relationship'); + $this->assertEquals(['contest' . $del . 'bookstore_contest.bookstore_id' => 'bookstore_schemas' . $del . 'bookstore.id'], $contestTable->getRelation('Bookstore')->getColumnMappings(), 'getColumnMappings returns local to foreign by default'); + $this->assertEquals(['contest' . $del . 'bookstore_contest.bookstore_id' => 'bookstore_schemas' . $del . 'bookstore.id'], $contestTable->getRelation('Bookstore')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns local to foreign when asked left to right for a many to one relationship'); $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\BookstoreSchemas\Bookstore'); - $this->assertEquals(['contest'.$del.'bookstore_contest.bookstore_id' => 'bookstore_schemas'.$del.'bookstore.id'], $bookTable->getRelation('BookstoreContest')->getColumnMappings(), 'getColumnMappings returns local to foreign by default'); - $this->assertEquals(['bookstore_schemas'.$del.'bookstore.id' => 'contest'.$del.'bookstore_contest.bookstore_id'], $bookTable->getRelation('BookstoreContest')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns foreign to local when asked left to right for a one to many relationship'); + $this->assertEquals(['contest' . $del . 'bookstore_contest.bookstore_id' => 'bookstore_schemas' . $del . 'bookstore.id'], $bookTable->getRelation('BookstoreContest')->getColumnMappings(), 'getColumnMappings returns local to foreign by default'); + $this->assertEquals(['bookstore_schemas' . $del . 'bookstore.id' => 'contest' . $del . 'bookstore_contest.bookstore_id'], $bookTable->getRelation('BookstoreContest')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns foreign to local when asked left to right for a one to many relationship'); $bookCustomerTable = $this->databaseMap->getTableByPhpName('Propel\Tests\BookstoreSchemas\Customer'); - $this->assertEquals(['bookstore_schemas'.$del.'customer_account.customer_id' => 'bookstore_schemas'.$del.'customer.id'], $bookCustomerTable->getRelation('CustomerAccount')->getColumnMappings(), 'getColumnMappings returns local to foreign by default'); - $this->assertEquals(['bookstore_schemas'.$del.'customer.id' => 'bookstore_schemas'.$del.'customer_account.customer_id'], $bookCustomerTable->getRelation('CustomerAccount')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns foreign to local when asked left to right for a one to one relationship'); + $this->assertEquals(['bookstore_schemas' . $del . 'customer_account.customer_id' => 'bookstore_schemas' . $del . 'customer.id'], $bookCustomerTable->getRelation('CustomerAccount')->getColumnMappings(), 'getColumnMappings returns local to foreign by default'); + $this->assertEquals(['bookstore_schemas' . $del . 'customer.id' => 'bookstore_schemas' . $del . 'customer_account.customer_id'], $bookCustomerTable->getRelation('CustomerAccount')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns foreign to local when asked left to right for a one to one relationship'); } - } diff --git a/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalTest.php b/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalTest.php index c82d6bf0b2..e9423fb6ce 100644 --- a/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalTest.php +++ b/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalTest.php @@ -22,12 +22,18 @@ class RelatedMapSymmetricalTest extends TestCaseFixtures { protected $databaseMap; + /** + * @return void + */ protected function setUp(): void { parent::setUp(); $this->databaseMap = Propel::getServiceContainer()->getDatabaseMap('bookstore'); } + /** + * @return void + */ public function testOneToMany() { $bookTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Book'); @@ -38,6 +44,9 @@ public function testOneToMany() $this->assertEquals($bookToAuthor, $authorToBook->getSymmetricalRelation()); } + /** + * @return void + */ public function testOneToOne() { $accountTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\BookstoreEmployeeAccount'); @@ -48,6 +57,9 @@ public function testOneToOne() $this->assertEquals($employeeToAccount, $accountToEmployee->getSymmetricalRelation()); } + /** + * @return void + */ public function testSeveralRelationsOnSameTable() { $authorTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\Author'); @@ -58,6 +70,9 @@ public function testSeveralRelationsOnSameTable() $this->assertEquals($essayToAuthor, $authorToEssay->getSymmetricalRelation()); } + /** + * @return void + */ public function testCompositeForeignKey() { $favoriteTable = $this->databaseMap->getTableByPhpName('Propel\Tests\Bookstore\ReaderFavorite'); @@ -67,5 +82,4 @@ public function testCompositeForeignKey() $this->assertEquals($favoriteToOpinion, $opinionToFavorite->getSymmetricalRelation()); $this->assertEquals($opinionToFavorite, $favoriteToOpinion->getSymmetricalRelation()); } - } diff --git a/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalWithSchemasTest.php b/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalWithSchemasTest.php index b3514c2b01..e133f7bfca 100644 --- a/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalWithSchemasTest.php +++ b/tests/Propel/Tests/Runtime/Map/RelatedMapSymmetricalWithSchemasTest.php @@ -22,14 +22,20 @@ */ class RelatedMapSymmetricalWithSchemasTest extends TestCaseFixturesDatabase { - protected $databaseMap; + protected $databaseMap; + /** + * @return void + */ protected function setUp(): void { parent::setUp(); $this->databaseMap = Propel::getServiceContainer()->getDatabaseMap('bookstore-schemas'); } + /** + * @return void + */ public function testOneToMany() { // passes on its own, but not with the full tests suite @@ -43,6 +49,9 @@ public function testOneToMany() $this->assertEquals($contestToBookstore->getName(), $bookstoreToContest->getSymmetricalRelation()->getName()); } + /** + * @return void + */ public function testOneToOne() { $accountTable = $this->databaseMap->getTableByPhpName('Propel\Tests\BookstoreSchemas\CustomerAccount'); @@ -55,6 +64,9 @@ public function testOneToOne() $this->assertEquals($customerToAccount, $accountToCustomer->getSymmetricalRelation()); } + /** + * @return void + */ public function testSeveralRelationsOnSameTable() { $contestTable = $this->databaseMap->getTableByPhpName('Propel\Tests\BookstoreSchemas\BookstoreContest'); @@ -67,6 +79,9 @@ public function testSeveralRelationsOnSameTable() $this->assertEquals($customerToContest, $contestToCustomer->getSymmetricalRelation()); } + /** + * @return void + */ public function testCompositeForeignKey() { $entryTable = $this->databaseMap->getTableByPhpName('Propel\Tests\BookstoreSchemas\BookstoreContestEntry'); diff --git a/tests/Propel/Tests/Runtime/Map/RelationMapTest.php b/tests/Propel/Tests/Runtime/Map/RelationMapTest.php index f48a92275c..61efbd297a 100644 --- a/tests/Propel/Tests/Runtime/Map/RelationMapTest.php +++ b/tests/Propel/Tests/Runtime/Map/RelationMapTest.php @@ -19,72 +19,90 @@ * Test class for RelationMap. * * @author François Zaninotto - * @version $Id$ + * @version $Id$ */ class RelationMapTest extends TestCase { - protected $databaseMap, $relationName, $rmap; + protected $databaseMap, $relationName, $rmap; - protected function setUp(): void - { - parent::setUp(); - $this->databaseMap = new DatabaseMap('foodb'); - $this->relationName = 'foo'; - $this->rmap = new RelationMap($this->relationName); - } + /** + * @return void + */ + protected function setUp(): void + { + parent::setUp(); + $this->databaseMap = new DatabaseMap('foodb'); + $this->relationName = 'foo'; + $this->rmap = new RelationMap($this->relationName); + } - public function testConstructor() - { - $this->assertEquals($this->relationName, $this->rmap->getName(), 'constructor sets the relation name'); - } + /** + * @return void + */ + public function testConstructor() + { + $this->assertEquals($this->relationName, $this->rmap->getName(), 'constructor sets the relation name'); + } - public function testLocalTable() - { - $this->assertNull($this->rmap->getLocalTable(), 'A new relation has no local table'); - $tmap1 = new TableMap('foo', $this->databaseMap); - $this->rmap->setLocalTable($tmap1); - $this->assertEquals($tmap1, $this->rmap->getLocalTable(), 'The local table is set by setLocalTable()'); - } + /** + * @return void + */ + public function testLocalTable() + { + $this->assertNull($this->rmap->getLocalTable(), 'A new relation has no local table'); + $tmap1 = new TableMap('foo', $this->databaseMap); + $this->rmap->setLocalTable($tmap1); + $this->assertEquals($tmap1, $this->rmap->getLocalTable(), 'The local table is set by setLocalTable()'); + } - public function testForeignTable() - { - $this->assertNull($this->rmap->getForeignTable(), 'A new relation has no foreign table'); - $tmap2 = new TableMap('bar', $this->databaseMap); - $this->rmap->setForeignTable($tmap2); - $this->assertEquals($tmap2, $this->rmap->getForeignTable(), 'The foreign table is set by setForeignTable()'); - } + /** + * @return void + */ + public function testForeignTable() + { + $this->assertNull($this->rmap->getForeignTable(), 'A new relation has no foreign table'); + $tmap2 = new TableMap('bar', $this->databaseMap); + $this->rmap->setForeignTable($tmap2); + $this->assertEquals($tmap2, $this->rmap->getForeignTable(), 'The foreign table is set by setForeignTable()'); + } - public function testProperties() - { - $properties = ['type', 'onUpdate', 'onDelete']; - foreach ($properties as $property) { - $getter = 'get' . ucfirst($property); - $setter = 'set' . ucfirst($property); - $this->assertNull($this->rmap->$getter(), "A new relation has no $property"); - $this->rmap->$setter('foo_value'); - $this->assertEquals('foo_value', $this->rmap->$getter(), "The $property is set by setType()"); + /** + * @return void + */ + public function testProperties() + { + $properties = ['type', 'onUpdate', 'onDelete']; + foreach ($properties as $property) { + $getter = 'get' . ucfirst($property); + $setter = 'set' . ucfirst($property); + $this->assertNull($this->rmap->$getter(), "A new relation has no $property"); + $this->rmap->$setter('foo_value'); + $this->assertEquals('foo_value', $this->rmap->$getter(), "The $property is set by setType()"); + } } - } - public function testColumns() - { - $this->assertEquals([], $this->rmap->getLocalColumns(), 'A new relation has no local columns'); - $this->assertEquals([], $this->rmap->getForeignColumns(), 'A new relation has no foreign columns'); - $tmap1 = new TableMap('foo', $this->databaseMap); - $col1 = $tmap1->addColumn('FOO1', 'Foo1PhpName', 'INTEGER'); - $tmap2 = new TableMap('bar', $this->databaseMap); - $col2 = $tmap2->addColumn('BAR1', 'Bar1PhpName', 'INTEGER'); - $this->rmap->addColumnMapping($col1, $col2); - $this->assertEquals([$col1], $this->rmap->getLocalColumns(), 'addColumnMapping() adds a local table'); - $this->assertEquals([$col2], $this->rmap->getForeignColumns(), 'addColumnMapping() adds a foreign table'); - $expected = ['foo.FOO1' => 'bar.BAR1']; - $this->assertEquals($expected, $this->rmap->getColumnMappings(), 'getColumnMappings() returns an associative array of column mappings'); - $col3 = $tmap1->addColumn('FOOFOO', 'FooFooPhpName', 'INTEGER'); - $col4 = $tmap2->addColumn('BARBAR', 'BarBarPhpName', 'INTEGER'); - $this->rmap->addColumnMapping($col3, $col4); - $this->assertEquals([$col1, $col3], $this->rmap->getLocalColumns(), 'addColumnMapping() adds a local table'); - $this->assertEquals([$col2, $col4], $this->rmap->getForeignColumns(), 'addColumnMapping() adds a foreign table'); - $expected = ['foo.FOO1' => 'bar.BAR1', 'foo.FOOFOO' => 'bar.BARBAR']; - $this->assertEquals($expected, $this->rmap->getColumnMappings(), 'getColumnMappings() returns an associative array of column mappings'); - } + /** + * @return void + */ + public function testColumns() + { + $this->assertEquals([], $this->rmap->getLocalColumns(), 'A new relation has no local columns'); + $this->assertEquals([], $this->rmap->getForeignColumns(), 'A new relation has no foreign columns'); + $tmap1 = new TableMap('foo', $this->databaseMap); + $col1 = $tmap1->addColumn('FOO1', 'Foo1PhpName', 'INTEGER'); + $tmap2 = new TableMap('bar', $this->databaseMap); + $col2 = $tmap2->addColumn('BAR1', 'Bar1PhpName', 'INTEGER'); + $this->rmap->addColumnMapping($col1, $col2); + $this->assertEquals([$col1], $this->rmap->getLocalColumns(), 'addColumnMapping() adds a local table'); + $this->assertEquals([$col2], $this->rmap->getForeignColumns(), 'addColumnMapping() adds a foreign table'); + $expected = ['foo.FOO1' => 'bar.BAR1']; + $this->assertEquals($expected, $this->rmap->getColumnMappings(), 'getColumnMappings() returns an associative array of column mappings'); + $col3 = $tmap1->addColumn('FOOFOO', 'FooFooPhpName', 'INTEGER'); + $col4 = $tmap2->addColumn('BARBAR', 'BarBarPhpName', 'INTEGER'); + $this->rmap->addColumnMapping($col3, $col4); + $this->assertEquals([$col1, $col3], $this->rmap->getLocalColumns(), 'addColumnMapping() adds a local table'); + $this->assertEquals([$col2, $col4], $this->rmap->getForeignColumns(), 'addColumnMapping() adds a foreign table'); + $expected = ['foo.FOO1' => 'bar.BAR1', 'foo.FOOFOO' => 'bar.BARBAR']; + $this->assertEquals($expected, $this->rmap->getColumnMappings(), 'getColumnMappings() returns an associative array of column mappings'); + } } diff --git a/tests/Propel/Tests/Runtime/Map/TableMapTest.php b/tests/Propel/Tests/Runtime/Map/TableMapTest.php index 7088f04cf3..bba72a88f8 100644 --- a/tests/Propel/Tests/Runtime/Map/TableMapTest.php +++ b/tests/Propel/Tests/Runtime/Map/TableMapTest.php @@ -10,23 +10,27 @@ namespace Propel\Tests\Runtime\Map; +use Propel\Runtime\Collection\ObjectCollection; +use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\DatabaseMap; +use Propel\Runtime\Map\Exception\ColumnNotFoundException; use Propel\Runtime\Map\RelationMap; -use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\TableMap; -use Propel\Runtime\Map\Exception\ColumnNotFoundException; use Propel\Tests\TestCase; /** * Test class for TableMap. * * @author François Zaninotto - * @version $Id$ + * @version $Id$ */ class TableMapTest extends TestCase { protected $databaseMap; + /** + * @return void + */ protected function setUp(): void { parent::setUp(); @@ -35,12 +39,18 @@ protected function setUp(): void $this->tmap = new TableMap($this->tableName, $this->databaseMap); } + /** + * @return void + */ protected function tearDown(): void { // nothing to do for now parent::tearDown(); } + /** + * @return void + */ public function testConstructor() { $this->assertEquals([], $this->tmap->getColumns(), 'A new table map has no columns'); @@ -54,6 +64,9 @@ public function testConstructor() } } + /** + * @return void + */ public function testProperties() { $tmap = new TableMap(); @@ -67,6 +80,9 @@ public function testProperties() } } + /** + * @return void + */ public function testHasColumn() { $this->assertFalse($this->tmap->hasColumn('BAR'), 'hascolumn() returns false when the column is not in the table map'); @@ -78,6 +94,9 @@ public function testHasColumn() $this->assertTrue($this->tmap->hasColumn($column), 'hascolumn() accepts a ColumnMap object as parameter'); } + /** + * @return void + */ public function testGetColumn() { $column = $this->tmap->addColumn('BAR', 'Bar', 'INTEGER'); @@ -85,7 +104,8 @@ public function testGetColumn() try { $this->tmap->getColumn('FOO'); $this->fail('getColumn throws an exception when called on an inexistent column'); - } catch (ColumnNotFoundException $e) {} + } catch (ColumnNotFoundException $e) { + } $this->assertEquals($column, $this->tmap->getColumn('foo.bar'), 'getColumn accepts a denormalized column name'); try { $this->tmap->getColumn('foo.bar', false); @@ -94,6 +114,9 @@ public function testGetColumn() } } + /** + * @return void + */ public function testGetColumnByPhpName() { $column = $this->tmap->addColumn('BAR_BAZ', 'BarBaz', 'INTEGER'); @@ -105,6 +128,9 @@ public function testGetColumnByPhpName() } } + /** + * @return void + */ public function testGetColumns() { $this->assertEquals([], $this->tmap->getColumns(), 'getColumns returns an empty array when no columns were added'); @@ -113,6 +139,9 @@ public function testGetColumns() $this->assertEquals(['BAR' => $column1, 'BAZ' => $column2], $this->tmap->getColumns(), 'getColumns returns the columns indexed by name'); } + /** + * @return void + */ public function testAddPrimaryKey() { $column1 = $this->tmap->addPrimaryKey('BAR', 'Bar', 'INTEGER'); @@ -127,6 +156,9 @@ public function testAddPrimaryKey() $this->assertTrue($column5->isPrimaryKey(), 'Columns added by way of addForeignPrimaryKey() are primary keys'); } + /** + * @return void + */ public function testGetPrimaryKeys() { $this->assertEquals([], $this->tmap->getPrimaryKeys(), 'getPrimaryKeys() returns an empty array by default'); @@ -136,6 +168,9 @@ public function testGetPrimaryKeys() $this->assertEquals($expected, $this->tmap->getPrimaryKeys(), 'getPrimaryKeys() returns an array of the table primary keys'); } + /** + * @return void + */ public function testAddForeignKey() { $column1 = $this->tmap->addForeignKey('BAR', 'Bar', 'INTEGER', 'Table1', 'column1'); @@ -150,6 +185,9 @@ public function testAddForeignKey() $this->assertTrue($column5->isForeignKey(), 'Columns added by way of addForeignPrimaryKey() are foreign keys'); } + /** + * @return void + */ public function testGetForeignKeys() { $this->assertEquals([], $this->tmap->getForeignKeys(), 'getForeignKeys() returns an empty array by default'); @@ -161,12 +199,17 @@ public function testGetForeignKeys() /** * @expectedException \Propel\Runtime\Map\Exception\RelationNotFoundException + * + * @return void */ public function testLoadWrongRelations() { $this->tmap->getRelation('Bar'); } + /** + * @return void + */ public function testLazyLoadRelations() { $foreigntmap = new BarTableMap(); @@ -177,6 +220,9 @@ public function testLazyLoadRelations() $this->assertEquals($rmap, $localtmap->rmap, 'getRelation() returns the relations lazy loaded by buildRelations()'); } + /** + * @return void + */ public function testAddRelation() { $foreigntmap1 = new TableMap('bar'); @@ -201,6 +247,9 @@ public function testAddRelation() $this->assertEquals($expectedRelations, $this->tmap->getRelations(), 'getRelations() returns an associative array of all the relations'); } + /** + * @return void + */ public function testPrimaryStringAddColumn() { $this->assertFalse($this->tmap->hasPrimaryStringColumn(), 'hasPrimaryStringColumn() returns false while none set.'); @@ -216,6 +265,9 @@ public function testPrimaryStringAddColumn() $this->assertEquals($column, $this->tmap->getPrimaryStringColumn(), 'getPrimaryStringColumn() returns correct column.'); } + /** + * @return void + */ public function testPrimaryStringAddConfiguredColumn() { $this->assertFalse($this->tmap->hasPrimaryStringColumn(), 'hasPrimaryStringColumn() returns false while none set.'); @@ -230,6 +282,9 @@ public function testPrimaryStringAddConfiguredColumn() $this->assertEquals($column, $this->tmap->getPrimaryStringColumn(), 'getPrimaryStringColumn() returns correct column.'); } + /** + * @return void + */ public function testGetCollectionClassName() { $this->assertEquals('\Propel\Runtime\Collection\ObjectCollection', $this->tmap->getCollectionClassName()); @@ -239,7 +294,9 @@ public function testGetCollectionClassName() } } -class TestCollection extends \Propel\Runtime\Collection\ObjectCollection {} +class TestCollection extends ObjectCollection +{ +} class TestableTableMap extends TableMap { @@ -257,6 +314,10 @@ public function removePrefix($data) class FooTableMap extends TableMap { public $rmap; + + /** + * @return void + */ public function buildRelations() { $this->rmap = $this->addRelation('Bar', 'Bar', RelationMap::MANY_TO_ONE); @@ -265,6 +326,9 @@ public function buildRelations() class BarTableMap extends TableMap { + /** + * @return void + */ public function initialize() { $this->setName('bar'); diff --git a/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php b/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php index 65df95cb5e..633743eea4 100644 --- a/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php +++ b/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php @@ -21,6 +21,9 @@ */ class AbstractParserTest extends TestCase { + /** + * @return void + */ public function testGetParser() { $parser = AbstractParser::getParser('XML'); @@ -29,12 +32,17 @@ public function testGetParser() /** * @expectedException \Propel\Runtime\Exception\FileNotFoundException + * + * @return void */ public function testGetParserThrowsExceptionOnWrongParser() { $parser = AbstractParser::getParser('Foo'); } + /** + * @return void + */ public function testLoad() { $fixtureFile = __DIR__ . '/fixtures/test_data.xml'; @@ -51,9 +59,12 @@ public function testLoad() $this->assertEquals($expectedContent, $content, 'AbstractParser::load() executes PHP code in files'); } + /** + * @return void + */ public function testDump() { - $testContent = "Foo Content"; + $testContent = 'Foo Content'; $testFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'propel_test_' . microtime(); $parser = AbstractParser::getParser('XML'); $parser->dump($testContent, $testFile); @@ -61,5 +72,4 @@ public function testDump() $this->assertEquals($testContent, $content); unlink($testFile); } - } diff --git a/tests/Propel/Tests/Runtime/Parser/CsvParserTest.php b/tests/Propel/Tests/Runtime/Parser/CsvParserTest.php index 2b1df2ee0e..aa7e15ee93 100644 --- a/tests/Propel/Tests/Runtime/Parser/CsvParserTest.php +++ b/tests/Propel/Tests/Runtime/Parser/CsvParserTest.php @@ -35,6 +35,8 @@ public static function arrayCsvConversionDataProvider() /** * @dataProvider arrayCsvConversionDataProvider + * + * @return void */ public function testFromArray($arrayData, $csvData, $type) { @@ -44,6 +46,8 @@ public function testFromArray($arrayData, $csvData, $type) /** * @dataProvider arrayCsvConversionDataProvider + * + * @return void */ public function testToCSV($arrayData, $csvData, $type) { @@ -53,6 +57,8 @@ public function testToCSV($arrayData, $csvData, $type) /** * @dataProvider arrayCsvConversionDataProvider + * + * @return void */ public function testToArray($arrayData, $csvData, $type) { @@ -62,6 +68,8 @@ public function testToArray($arrayData, $csvData, $type) /** * @dataProvider arrayCsvConversionDataProvider + * + * @return void */ public function testFromCSV($arrayData, $csvData, $type) { @@ -92,6 +100,8 @@ public static function listToCSVDataProvider() /** * @dataProvider listToCSVDataProvider + * + * @return void */ public function testListToCSV($list, $heading, $csv) { @@ -104,6 +114,8 @@ public function testListToCSV($list, $heading, $csv) /** * @dataProvider listToCSVDataProvider + * + * @return void */ public function testCSVToList($list, $heading, $csv) { diff --git a/tests/Propel/Tests/Runtime/Parser/JsonParserTest.php b/tests/Propel/Tests/Runtime/Parser/JsonParserTest.php index b56557940c..2a4128a1aa 100644 --- a/tests/Propel/Tests/Runtime/Parser/JsonParserTest.php +++ b/tests/Propel/Tests/Runtime/Parser/JsonParserTest.php @@ -39,6 +39,8 @@ public static function arrayJsonConversionDataProvider() /** * @dataProvider arrayJsonConversionDataProvider + * + * @return void */ public function testFromArray($arrayData, $jsonData, $type) { @@ -48,6 +50,8 @@ public function testFromArray($arrayData, $jsonData, $type) /** * @dataProvider arrayJsonConversionDataProvider + * + * @return void */ public function testToJSON($arrayData, $jsonData, $type) { @@ -57,6 +61,8 @@ public function testToJSON($arrayData, $jsonData, $type) /** * @dataProvider arrayJsonConversionDataProvider + * + * @return void */ public function testToArray($arrayData, $jsonData, $type) { @@ -66,6 +72,8 @@ public function testToArray($arrayData, $jsonData, $type) /** * @dataProvider arrayJsonConversionDataProvider + * + * @return void */ public function testFromJSON($arrayData, $jsonData, $type) { @@ -89,6 +97,8 @@ public static function listToJSONDataProvider() /** * @dataProvider listToJSONDataProvider + * + * @return void */ public function testListToJSON($list, $json) { @@ -98,6 +108,8 @@ public function testListToJSON($list, $json) /** * @dataProvider listToJSONDataProvider + * + * @return void */ public function testJSONToList($list, $json) { diff --git a/tests/Propel/Tests/Runtime/Parser/XmlParserTest.php b/tests/Propel/Tests/Runtime/Parser/XmlParserTest.php index f04e71e244..9ad1b5911a 100644 --- a/tests/Propel/Tests/Runtime/Parser/XmlParserTest.php +++ b/tests/Propel/Tests/Runtime/Parser/XmlParserTest.php @@ -10,6 +10,7 @@ namespace Propel\Tests\Runtime\Parser; +use DateTime; use Propel\Runtime\Parser\XmlParser; use Propel\Tests\TestCase; @@ -77,16 +78,18 @@ public static function arrayXmlConversionDataProvider() 2 ", 'keys with numbers'], - [['time' => new \DateTime('2014-07-23T22:27:17+0200')], " + [['time' => new DateTime('2014-07-23T22:27:17+0200')], " -", '\\DateTime objects'] +", '\\DateTime objects'], ]; } /** * @dataProvider arrayXmlConversionDataProvider + * + * @return void */ public function testFromArray($arrayData, $xmlData, $type) { @@ -96,6 +99,8 @@ public function testFromArray($arrayData, $xmlData, $type) /** * @dataProvider arrayXmlConversionDataProvider + * + * @return void */ public function testToXML($arrayData, $xmlData, $type) { @@ -105,6 +110,8 @@ public function testToXML($arrayData, $xmlData, $type) /** * @dataProvider arrayXmlConversionDataProvider + * + * @return void */ public function testToArray($arrayData, $xmlData, $type) { @@ -114,6 +121,8 @@ public function testToArray($arrayData, $xmlData, $type) /** * @dataProvider arrayXmlConversionDataProvider + * + * @return void */ public function testFromXML($arrayData, $xmlData, $type) { @@ -121,6 +130,9 @@ public function testFromXML($arrayData, $xmlData, $type) $this->assertEquals($arrayData, $parser->fromXML($xmlData), 'XmlParser::fromXML() converts to ' . $type . ' correctly'); } + /** + * @return void + */ public function testToArrayRespectsNullValues() { $xmlData = " @@ -186,6 +198,8 @@ public static function listToXMLDataProvider() /** * @dataProvider listToXMLDataProvider + * + * @return void */ public function testListToXML($list, $xml) { @@ -195,6 +209,8 @@ public function testListToXML($list, $xml) /** * @dataProvider listToXMLDataProvider + * + * @return void */ public function testXMLToList($list, $xml) { diff --git a/tests/Propel/Tests/Runtime/Parser/YamlParserTest.php b/tests/Propel/Tests/Runtime/Parser/YamlParserTest.php index 706e9fda1c..5189859076 100644 --- a/tests/Propel/Tests/Runtime/Parser/YamlParserTest.php +++ b/tests/Propel/Tests/Runtime/Parser/YamlParserTest.php @@ -25,24 +25,24 @@ public static function arrayYAMLConversionDataProvider() return [ [[], '{ }', 'empty array'], [[1, 2, 3], -"- 1 + "- 1 - 2 - 3 ", 'regular array'], [[1, '2', 3], -"- 1 + "- 1 - '2' - 3 ", 'array with strings'], [[1, 2, [3, 4]], -"- 1 + "- 1 - 2 - - 3 - 4 ", 'nested arrays'], [['a' => 1, 'b' => 2], -"a: 1 + "a: 1 b: 2 ", 'associative array'], [['a' => 0, 'b' => null, 'c' => ''], "a: 0 @@ -50,19 +50,19 @@ public static function arrayYAMLConversionDataProvider() c: '' ", 'associative array with empty values'], [['a' => 1, 'b' => 'bar'], -"a: 1 + "a: 1 b: bar ", 'associative array with strings'], [['a' => '

Hello, World!

'], -"a: '

Hello, World!

' + "a: '

Hello, World!

' ", 'associative array with code'], [['a' => 1, 'b' => ['foo' => 2]], -"a: 1 + "a: 1 b: foo: 2 ", 'nested associative arrays'], [['Id' => 123, 'Title' => 'Pride and Prejudice', 'AuthorId' => 456, 'ISBN' => '0553213105', 'Author' => ['Id' => 456, 'FirstName' => 'Jane', 'LastName' => 'Austen']], -"Id: 123 + "Id: 123 Title: 'Pride and Prejudice' AuthorId: 456 ISBN: '0553213105' @@ -79,6 +79,8 @@ public static function arrayYAMLConversionDataProvider() /** * @dataProvider arrayYAMLConversionDataProvider + * + * @return void */ public function testFromArray($arrayData, $YAMLData, $type) { @@ -88,6 +90,8 @@ public function testFromArray($arrayData, $YAMLData, $type) /** * @dataProvider arrayYAMLConversionDataProvider + * + * @return void */ public function testToYAML($arrayData, $YAMLData, $type) { @@ -97,6 +101,8 @@ public function testToYAML($arrayData, $YAMLData, $type) /** * @dataProvider arrayYAMLConversionDataProvider + * + * @return void */ public function testToArray($arrayData, $YAMLData, $type) { @@ -106,6 +112,8 @@ public function testToArray($arrayData, $YAMLData, $type) /** * @dataProvider arrayYAMLConversionDataProvider + * + * @return void */ public function testFromYAML($arrayData, $YAMLData, $type) { @@ -156,6 +164,8 @@ public static function listToYAMLDataProvider() /** * @dataProvider listToYAMLDataProvider + * + * @return void */ public function testListToYAML($list, $yaml) { @@ -165,6 +175,8 @@ public function testListToYAML($list, $yaml) /** * @dataProvider listToYAMLDataProvider + * + * @return void */ public function testYAMLToList($list, $yaml) { diff --git a/tests/Propel/Tests/Runtime/PropelTest.php b/tests/Propel/Tests/Runtime/PropelTest.php index ee28d300d0..42d27c0e0f 100644 --- a/tests/Propel/Tests/Runtime/PropelTest.php +++ b/tests/Propel/Tests/Runtime/PropelTest.php @@ -10,18 +10,23 @@ namespace Propel\Tests\Runtime; -use Propel\Tests\Helpers\BaseTestCase; - use Propel\Runtime\Propel; use Propel\Runtime\ServiceContainer\StandardServiceContainer; +use Propel\Tests\Helpers\BaseTestCase; class PropelTest extends BaseTestCase { + /** + * @return void + */ public function testGetServiceContainerReturnsAServiceContainer() { $this->assertInstanceOf('\Propel\Runtime\ServiceContainer\ServiceContainerInterface', Propel::getServiceContainer()); } + /** + * @return void + */ public function testGetServiceContainerAlwaysReturnsTheSameInstance() { $sc1 = Propel::getServiceContainer(); @@ -30,6 +35,9 @@ public function testGetServiceContainerAlwaysReturnsTheSameInstance() $this->assertSame($sc1, $sc2); } + /** + * @return void + */ public function testSetServiceContainerOverridesTheExistingServiceContainer() { $oldSC = Propel::getServiceContainer(); diff --git a/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php b/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php index aece2086e3..6140968921 100644 --- a/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php +++ b/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php @@ -10,19 +10,18 @@ namespace Propel\Tests\Runtime\ServiceContainer; -use Propel\Tests\Helpers\BaseTestCase; - -use Propel\Runtime\ServiceContainer\StandardServiceContainer; -use Propel\Runtime\ServiceContainer\ServiceContainerInterface; +use Monolog\Logger; use Propel\Runtime\Adapter\AdapterInterface; -use Propel\Runtime\Adapter\Pdo\SqliteAdapter; use Propel\Runtime\Adapter\Pdo\MysqlAdapter; -use Propel\Runtime\Map\DatabaseMap; +use Propel\Runtime\Adapter\Pdo\SqliteAdapter; use Propel\Runtime\Connection\ConnectionManagerSingle; use Propel\Runtime\Connection\PdoConnection; -use Propel\Runtime\Util\Profiler; -use Monolog\Logger; +use Propel\Runtime\Map\DatabaseMap; use Propel\Runtime\Propel; +use Propel\Runtime\ServiceContainer\ServiceContainerInterface; +use Propel\Runtime\ServiceContainer\StandardServiceContainer; +use Propel\Runtime\Util\Profiler; +use Propel\Tests\Helpers\BaseTestCase; class StandardServiceContainerTest extends BaseTestCase { @@ -31,22 +30,34 @@ class StandardServiceContainerTest extends BaseTestCase */ protected $sc; + /** + * @return void + */ protected function setUp(): void { - $this->sc = new StandardServiceContainer; + $this->sc = new StandardServiceContainer(); } + /** + * @return void + */ protected function tearDown(): void { $this->sc = null; } + /** + * @return void + */ public function testDefaultDatasourceIsDefault() { $defaultDatasource = $this->sc->getDefaultDatasource(); $this->assertEquals('default', $defaultDatasource); } + /** + * @return void + */ public function testSetDefaultDatasourceUpdatesDefaultDatasource() { $this->sc->setDefaultDatasource('bookstore'); @@ -54,6 +65,9 @@ public function testSetDefaultDatasourceUpdatesDefaultDatasource() $this->assertEquals('bookstore', $defaultDatasource); } + /** + * @return void + */ public function testGetAdapterClassUsesDefaultDatasource() { $this->sc->setAdapterClasses(['default' => 'bar1', 'foo' => 'bar2']); @@ -62,12 +76,18 @@ public function testGetAdapterClassUsesDefaultDatasource() $this->assertEquals('bar2', $this->sc->getAdapterClass()); } + /** + * @return void + */ public function testSetAdapterClassSetsTheAdapterClassForAGivenDatasource() { $this->sc->setAdapterClass('foo', 'bar'); $this->assertEquals('bar', $this->sc->getAdapterClass('foo')); } + /** + * @return void + */ public function testSetAdapterClassesSetsAdapterClassForAllDatasources() { $this->sc->setAdapterClasses(['foo1' => 'bar1', 'foo2' => 'bar2']); @@ -75,14 +95,20 @@ public function testSetAdapterClassesSetsAdapterClassForAllDatasources() $this->assertEquals('bar2', $this->sc->getAdapterClass('foo2')); } + /** + * @return void + */ public function testSetAdapterClassesRemovesExistingAdapterClassesForAllDatasources() { - $sc = new TestableServiceContainer; + $sc = new TestableServiceContainer(); $sc->setAdapterClass('foo', 'bar'); $sc->setAdapterClasses(['foo1' => 'bar1', 'foo2' => 'bar2']); $this->assertEquals(['foo1' => 'bar1', 'foo2' => 'bar2'], $sc->adapterClasses); } + /** + * @return void + */ public function testSetAdapterClassAllowsToReplaceExistingAdapter() { $this->sc->setAdapter('foo', new SqliteAdapter()); @@ -90,6 +116,9 @@ public function testSetAdapterClassAllowsToReplaceExistingAdapter() $this->assertInstanceof('\Propel\Runtime\Adapter\Pdo\MysqlAdapter', $this->sc->getAdapter('foo')); } + /** + * @return void + */ public function getAdapterReturnsSetAdapter() { $adapter = new SqliteAdapter(); @@ -98,52 +127,70 @@ public function getAdapterReturnsSetAdapter() $this->assertSame($adapter, $this->sc->getAdapter('foo')); } + /** + * @return void + */ public function getAdapterCreatesAdapterBasedOnAdapterClass() { $this->sc->setAdapterClass('foo', '\Propel\Runtime\Adapter\Pdo\MysqlAdapter'); $this->assertInstanceof('\Propel\Runtime\Adapter\Pdo\MysqlAdapter', $this->sc->getAdapter('foo')); } + /** + * @return void + */ public function testGetAdapterUsesDefaultDatasource() { $this->sc->setAdapterClasses([ 'default' => '\Propel\Runtime\Adapter\Pdo\SqliteAdapter', - 'foo' => '\Propel\Runtime\Adapter\Pdo\MysqlAdapter']); + 'foo' => '\Propel\Runtime\Adapter\Pdo\MysqlAdapter']); $this->assertInstanceof('\Propel\Runtime\Adapter\Pdo\SqliteAdapter', $this->sc->getAdapter()); $this->sc->setDefaultDatasource('foo'); $this->assertInstanceof('\Propel\Runtime\Adapter\Pdo\MysqlAdapter', $this->sc->getAdapter()); } + /** + * @return void + */ public function testSetAdapterUpdatesAdapterClass() { $this->sc->setAdapter('foo', new SqliteAdapter()); $this->assertEquals('Propel\Runtime\Adapter\Pdo\SqliteAdapter', $this->sc->getAdapterClass('foo')); } + /** + * @return void + */ public function testSetAdaptersSetsAllAdapters() { $this->sc->setAdapters([ 'foo1' => new SqliteAdapter(), - 'foo2' => new MysqlAdapter() + 'foo2' => new MysqlAdapter(), ]); $this->assertEquals('Propel\Runtime\Adapter\Pdo\SqliteAdapter', $this->sc->getAdapterClass('foo1')); $this->assertEquals('Propel\Runtime\Adapter\Pdo\MysqlAdapter', $this->sc->getAdapterClass('foo2')); } - public function testSetAdaptersRemovesExistingAdaptersForAllDatasources($value='') + /** + * @return void + */ + public function testSetAdaptersRemovesExistingAdaptersForAllDatasources($value = '') { - $sc = new TestableServiceContainer; + $sc = new TestableServiceContainer(); $sc->setAdapter('foo', new SqliteAdapter()); $sc->setAdapters([ 'foo1' => new SqliteAdapter(), - 'foo2' => new MysqlAdapter() + 'foo2' => new MysqlAdapter(), ]); $this->assertEquals([ 'foo1' => new SqliteAdapter(), - 'foo2' => new MysqlAdapter() + 'foo2' => new MysqlAdapter(), ], $sc->adapters); } + /** + * @return void + */ public function testCheckInvalidVersion() { $logger = $this->getMockBuilder('Monolog\Logger') @@ -156,6 +203,9 @@ public function testCheckInvalidVersion() $this->sc->checkVersion('1.0.0-invalid'); } + /** + * @return void + */ public function testCheckValidVersion() { $logger = $this->getMockBuilder('Monolog\Logger') @@ -168,18 +218,27 @@ public function testCheckValidVersion() $this->sc->checkVersion(Propel::VERSION); } + /** + * @return void + */ public function testGetDatabaseMapReturnsADatabaseMap() { $map = $this->sc->getDatabaseMap('foo'); $this->assertInstanceOf('\Propel\Runtime\Map\DatabaseMap', $map); } + /** + * @return void + */ public function testGetDatabaseMapReturnsADatabaseMapForTheGivenDatasource() { $map = $this->sc->getDatabaseMap('foo'); $this->assertEquals('foo', $map->getName()); } + /** + * @return void + */ public function testGetDatabaseMapReturnsADatabaseMapForTheDefaultDatasourceByDefault() { $map = $this->sc->getDatabaseMap(); @@ -189,18 +248,27 @@ public function testGetDatabaseMapReturnsADatabaseMapForTheDefaultDatasourceByDe $this->assertEquals('foo', $map->getName()); } + /** + * @return void + */ public function testGetDatabaseMapReturnsAlwaysTheSameDatabaseMapForAGivenDatasource() { $map = $this->sc->getDatabaseMap('foo'); $this->assertSame($map, $this->sc->getDatabaseMap('foo')); } + /** + * @return void + */ public function testGetDatabaseMapReturnsDifferentDatabaseMapForTwoDatasources() { $map = $this->sc->getDatabaseMap('foo1'); $this->assertNotSame($map, $this->sc->getDatabaseMap('foo2')); } + /** + * @return void + */ public function testGetDatabaseMapUsesDatabaseMapClass() { $this->sc->setDatabaseMapClass('Propel\Tests\Runtime\ServiceContainer\MyDatabaseMap'); @@ -208,6 +276,9 @@ public function testGetDatabaseMapUsesDatabaseMapClass() $this->assertInstanceOf('Propel\Tests\Runtime\ServiceContainer\MyDatabaseMap', $map); } + /** + * @return void + */ public function testSetDatabaseMapSetsTheDatabaseMapForAGivenDatasource() { $map = new DatabaseMap('foo'); @@ -215,6 +286,9 @@ public function testSetDatabaseMapSetsTheDatabaseMapForAGivenDatasource() $this->assertSame($map, $this->sc->getDatabaseMap('foo')); } + /** + * @return void + */ public function testSetConnectionManagerSetsTheConnectionManagerForAGivenDatasource() { $manager1 = new ConnectionManagerSingle(); @@ -225,6 +299,9 @@ public function testSetConnectionManagerSetsTheConnectionManagerForAGivenDatasou $this->assertSame($manager2, $this->sc->getConnectionManager('foo2')); } + /** + * @return void + */ public function testSetConnectionManagerClosesExistingConnectionManagerForTheSameDatasource() { $manager = new TestableConnectionManagerSingle(); @@ -235,6 +312,9 @@ public function testSetConnectionManagerClosesExistingConnectionManagerForTheSam $this->assertNull($manager->connection); } + /** + * @return void + */ public function testGetConnectionManagersReturnsConnectionManagersForAllDatasources() { $manager1 = new ConnectionManagerSingle(); @@ -243,19 +323,24 @@ public function testGetConnectionManagersReturnsConnectionManagersForAllDatasour $this->sc->setConnectionManager('foo2', $manager2); $expected = [ 'foo1' => $manager1, - 'foo2' => $manager2 + 'foo2' => $manager2, ]; $this->assertEquals($expected, $this->sc->getConnectionManagers()); } /** * @expectedException \Propel\Runtime\Exception\RuntimeException + * + * @return void */ public function testGetConnectionManagerWithUnknownDatasource() { $this->sc->getConnectionManager('unknown'); } + /** + * @return void + */ public function testHasConnectionManager() { $this->sc->setConnectionManager('single', new TestableConnectionManagerSingle()); @@ -263,6 +348,9 @@ public function testHasConnectionManager() $this->assertFalse($this->sc->hasConnectionManager('single_not_existing')); } + /** + * @return void + */ public function testCloseConnectionsClosesConnectionsOnAllConnectionManagers() { $manager1 = new TestableConnectionManagerSingle(); @@ -276,6 +364,9 @@ public function testCloseConnectionsClosesConnectionsOnAllConnectionManagers() $this->assertNull($manager2->connection); } + /** + * @return void + */ public function testGetConnectionReturnsWriteConnectionByDefault() { $this->sc->setConnectionManager('foo', new TestableConnectionManagerSingle()); @@ -283,6 +374,9 @@ public function testGetConnectionReturnsWriteConnectionByDefault() $this->assertEquals('write', $this->sc->getConnection('foo')); } + /** + * @return void + */ public function testGetConnectionReturnsWriteConnectionWhenAskedExplicitly() { $this->sc->setConnectionManager('foo', new TestableConnectionManagerSingle()); @@ -290,6 +384,9 @@ public function testGetConnectionReturnsWriteConnectionWhenAskedExplicitly() $this->assertEquals('write', $this->sc->getConnection('foo', ServiceContainerInterface::CONNECTION_WRITE)); } + /** + * @return void + */ public function testGetConnectionReturnsReadConnectionWhenAskedExplicitly() { $this->sc->setConnectionManager('foo', new TestableConnectionManagerSingle()); @@ -297,6 +394,9 @@ public function testGetConnectionReturnsReadConnectionWhenAskedExplicitly() $this->assertEquals('read', $this->sc->getConnection('foo', ServiceContainerInterface::CONNECTION_READ)); } + /** + * @return void + */ public function testGetConnectionReturnsConnectionForDefaultDatasourceByDefault() { $this->sc->setConnectionManager('default', new TestableConnectionManagerSingle()); @@ -304,6 +404,9 @@ public function testGetConnectionReturnsConnectionForDefaultDatasourceByDefault( $this->assertEquals('write', $this->sc->getConnection()); } + /** + * @return void + */ public function testGetWriteConnectionReturnsWriteConnectionForAGivenDatasource() { $this->sc->setConnectionManager('foo', new TestableConnectionManagerSingle()); @@ -311,6 +414,9 @@ public function testGetWriteConnectionReturnsWriteConnectionForAGivenDatasource( $this->assertEquals('write', $this->sc->getWriteConnection('foo')); } + /** + * @return void + */ public function testGetReadConnectionReturnsReadConnectionForAGivenDatasource() { $this->sc->setConnectionManager('foo', new TestableConnectionManagerSingle()); @@ -318,12 +424,18 @@ public function testGetReadConnectionReturnsReadConnectionForAGivenDatasource() $this->assertEquals('read', $this->sc->getReadConnection('foo')); } + /** + * @return void + */ public function testSetConnectionAddsAConnectionManagerSingle() { $this->sc->setConnection('foo', new PdoConnection('sqlite::memory:')); $this->assertInstanceOf('Propel\Runtime\Connection\ConnectionManagerSingle', $this->sc->getConnectionManager('foo')); } + /** + * @return void + */ public function testSetConnectionAddsAConnectionWhichCanBeRetrievedByGetConnection() { $con = new PdoConnection('sqlite::memory:'); @@ -332,12 +444,18 @@ public function testSetConnectionAddsAConnectionWhichCanBeRetrievedByGetConnecti $this->assertSame($con, $this->sc->getConnection('foo')); } + /** + * @return void + */ public function testGetProfilerReturnsAProfiler() { $profiler = $this->sc->getProfiler(); $this->assertInstanceOf('\Propel\Runtime\Util\Profiler', $profiler); } + /** + * @return void + */ public function testGetProfilerUsesProfilerClass() { $this->sc->setProfilerClass('\Propel\Tests\Runtime\ServiceContainer\myProfiler'); @@ -345,58 +463,73 @@ public function testGetProfilerUsesProfilerClass() $this->assertInstanceOf('\Propel\Tests\Runtime\ServiceContainer\myProfiler', $profiler); } + /** + * @return void + */ public function testGetProfilerUsesDefaultConfiguration() { $config = $this->sc->getProfiler()->getConfiguration(); $expected = [ 'details' => [ 'time' => [ - 'name' => 'Time', + 'name' => 'Time', 'precision' => 3, - 'pad' => 8 + 'pad' => 8, ], 'mem' => [ - 'name' => 'Memory', + 'name' => 'Memory', 'precision' => 3, - 'pad' => 8 + 'pad' => 8, ], 'memDelta' => [ - 'name' => 'Memory Delta', + 'name' => 'Memory Delta', 'precision' => 3, - 'pad' => 8 + 'pad' => 8, ], 'memPeak' => [ - 'name' => 'Memory Peak', + 'name' => 'Memory Peak', 'precision' => 3, - 'pad' => 8 + 'pad' => 8, ], ], - 'innerGlue' => ': ', - 'outerGlue' => ' | ', - 'slowTreshold' => 0.1 + 'innerGlue' => ': ', + 'outerGlue' => ' | ', + 'slowTreshold' => 0.1, ]; $this->assertEquals($expected, $config); } + /** + * @return void + */ public function testGetProfilerUsesProfilerConfigurationWhenGiven() { $this->sc->setProfilerConfiguration([ - 'slowTreshold' => 22 + 'slowTreshold' => 22, ]); $config = $this->sc->getProfiler()->getConfiguration(); $this->assertEquals(22, $config['slowTreshold']); } + /** + * @return void + */ public function testGetLoggerReturnsNullLoggerByDefault() { $this->assertInstanceOf('Psr\Log\NullLogger', $this->sc->getLogger()); } + /** + * @return void + */ public function testGetLoggerReturnsNullLoggerForConnectionNamesByDefault() { $this->assertInstanceOf('Psr\Log\NullLogger', $this->sc->getLogger('book')); } + /** + * @return void + */ public function testGetLoggerReturnsLoggerPreviouslySet() { $logger = new Logger('book'); @@ -404,6 +537,9 @@ public function testGetLoggerReturnsLoggerPreviouslySet() $this->assertEquals($logger, $this->sc->getLogger('book')); } + /** + * @return void + */ public function testGetLoggerWithNoArgumentReturnsDefaultLogger() { $logger = new Logger('defaultLogger'); @@ -411,6 +547,9 @@ public function testGetLoggerWithNoArgumentReturnsDefaultLogger() $this->assertEquals($logger, $this->sc->getLogger()); } + /** + * @return void + */ public function testGetLoggerWithAnArgumentReturnsLoggerSetOnThatArgument() { $logger1 = new Logger('defaultLogger'); @@ -420,6 +559,9 @@ public function testGetLoggerWithAnArgumentReturnsLoggerSetOnThatArgument() $this->assertEquals($logger2, $this->sc->getLogger('book')); } + /** + * @return void + */ public function testGetLoggerWithAnArgumentReturnsDefaultLoggerOnFallback() { $logger = new Logger('defaultLogger'); @@ -427,6 +569,9 @@ public function testGetLoggerWithAnArgumentReturnsDefaultLoggerOnFallback() $this->assertEquals($logger, $this->sc->getLogger('book')); } + /** + * @return void + */ public function testGetLoggerLazyLoadsLoggerFromConfiguration() { $this->sc->setLoggerConfiguration('defaultLogger', [ @@ -438,12 +583,12 @@ public function testGetLoggerLazyLoadsLoggerFromConfiguration() $handler = $logger->popHandler(); $this->assertInstanceOf('\Monolog\Handler\StreamHandler', $handler); } - } class TestableServiceContainer extends StandardServiceContainer { public $adapterClasses = []; + public $adapters = []; } @@ -459,12 +604,12 @@ class TestableConnectionManagerSingle extends ConnectionManagerSingle { public $connection; - public function getWriteConnection(AdapterInterface $adapter = null) + public function getWriteConnection(?AdapterInterface $adapter = null) { return 'write'; } - public function getReadConnection(AdapterInterface $adapter = null) + public function getReadConnection(?AdapterInterface $adapter = null) { return 'read'; } diff --git a/tests/Propel/Tests/Runtime/TypeTest.php b/tests/Propel/Tests/Runtime/TypeTest.php index 88a8f4e7ae..358159f4cf 100644 --- a/tests/Propel/Tests/Runtime/TypeTest.php +++ b/tests/Propel/Tests/Runtime/TypeTest.php @@ -1,12 +1,12 @@ getMethod('setDummyObject'); $param = $method->getParameters()[0]; @@ -30,9 +35,12 @@ public function testTypeHintClass() $this->assertTrue($param->allowsNull()); } + /** + * @return void + */ public function testTypeHintArray() { - $reflection = new \ReflectionClass('Propel\Tests\Bookstore\TypeObject'); + $reflection = new ReflectionClass('Propel\Tests\Bookstore\TypeObject'); $method = $reflection->getMethod('setSomeArray'); $param = $method->getParameters()[0]; @@ -40,9 +48,12 @@ public function testTypeHintArray() $this->assertTrue($param->allowsNull()); } + /** + * @return void + */ public function testInterface() { - $reflection = new \ReflectionClass('Propel\Tests\Bookstore\TypeObject'); + $reflection = new ReflectionClass('Propel\Tests\Bookstore\TypeObject'); $method = $reflection->getMethod('setTypeObject'); $param = $method->getParameters()[0]; @@ -50,6 +61,9 @@ public function testInterface() $this->assertTrue($param->allowsNull()); } + /** + * @return void + */ public function testObjectType() { TypeObjectQuery::create()->deleteAll(); @@ -58,7 +72,7 @@ public function testObjectType() $b = '3456&*(]['; $c = "_$%^xxx\0d2"; - $objectInstance = new TypeTests\DummyObjectClass(); + $objectInstance = new DummyObjectClass(); $objectInstance->setPropPublic($a); $objectInstance->setPropProtected($b); $objectInstance->setPropPrivate($c); @@ -77,7 +91,6 @@ public function testObjectType() $typeObjectEntity->setDetails($objectInstance); $this->assertFalse($typeObjectEntity->isModified('details')); - $clone = clone $objectInstance; $clone->setPropPublic('changed'); @@ -104,7 +117,6 @@ public function testObjectType() $this->assertEquals($detailsObject, $typeObjectEntity->getDetails()); $this->assertEquals('changed', $typeObjectEntity->getDetails()->getPropPublic()); - // same but with a more complex object $q = TypeObjectQuery::create(); $typeObjectEntity->setDetails($q); @@ -117,5 +129,4 @@ public function testObjectType() $this->assertEquals($q, $typeObjectEntity->getDetails()); } - -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Runtime/TypeTests/DummyObjectClass.php b/tests/Propel/Tests/Runtime/TypeTests/DummyObjectClass.php index 38365d2633..e23aa8c10e 100644 --- a/tests/Propel/Tests/Runtime/TypeTests/DummyObjectClass.php +++ b/tests/Propel/Tests/Runtime/TypeTests/DummyObjectClass.php @@ -2,8 +2,8 @@ namespace Propel\Tests\Runtime\TypeTests; -class DummyObjectClass { - +class DummyObjectClass +{ public $propPublic; protected $propProtected; @@ -12,6 +12,8 @@ class DummyObjectClass { /** * @param mixed $propPrivate + * + * @return void */ public function setPropPrivate($propPrivate) { @@ -28,6 +30,8 @@ public function getPropPrivate() /** * @param mixed $propProtected + * + * @return void */ public function setPropProtected($propProtected) { @@ -44,6 +48,8 @@ public function getPropProtected() /** * @param mixed $propPublic + * + * @return void */ public function setPropPublic($propPublic) { @@ -57,5 +63,4 @@ public function getPropPublic() { return $this->propPublic; } - -} \ No newline at end of file +} diff --git a/tests/Propel/Tests/Runtime/TypeTests/TypeObjectInterface.php b/tests/Propel/Tests/Runtime/TypeTests/TypeObjectInterface.php index 2b7b841be0..f47275f3a3 100644 --- a/tests/Propel/Tests/Runtime/TypeTests/TypeObjectInterface.php +++ b/tests/Propel/Tests/Runtime/TypeTests/TypeObjectInterface.php @@ -2,6 +2,6 @@ namespace Propel\Tests\Runtime\TypeTests; -interface TypeObjectInterface { - -} \ No newline at end of file +interface TypeObjectInterface +{ +} diff --git a/tests/Propel/Tests/Runtime/Util/ProfilerTest.php b/tests/Propel/Tests/Runtime/Util/ProfilerTest.php index 9dce69e418..a492b5ce35 100644 --- a/tests/Propel/Tests/Runtime/Util/ProfilerTest.php +++ b/tests/Propel/Tests/Runtime/Util/ProfilerTest.php @@ -10,12 +10,14 @@ namespace Propel\Tests\Runtime\Util; -use Propel\Tests\Helpers\BaseTestCase; - use Propel\Runtime\Util\Profiler; +use Propel\Tests\Helpers\BaseTestCase; class ProfilerTest extends BaseTestCase { + /** + * @return void + */ public function testGetProfileBetweenAddsSlowTreshold() { $profiler = new Profiler(); @@ -27,6 +29,9 @@ public function testGetProfileBetweenAddsSlowTreshold() $this->assertSame('SLOW ', $res); } + /** + * @return void + */ public function testGetProfileBetweenDoesNotAddSlowTresholdWhenValueIsNull() { $profiler = new Profiler(); @@ -38,6 +43,9 @@ public function testGetProfileBetweenDoesNotAddSlowTresholdWhenValueIsNull() $this->assertSame('', $res); } + /** + * @return void + */ public function testGetProfileBetweenAddsTime() { $profiler = new Profiler(); @@ -49,6 +57,9 @@ public function testGetProfileBetweenAddsTime() $this->assertEquals('Time: 1.11s | ', $res); } + /** + * @return void + */ public function testGetProfileBetweenAddsMemoryUsage() { $profiler = new Profiler(); @@ -60,6 +71,9 @@ public function testGetProfileBetweenAddsMemoryUsage() $this->assertEquals('Memory: 68.4GB | ', $res); } + /** + * @return void + */ public function testGetProfileBetweenAddsMemoryDeltaUsage() { $profiler = new Profiler(); @@ -73,6 +87,9 @@ public function testGetProfileBetweenAddsMemoryDeltaUsage() $this->assertEquals('Delta: -68.2GB | ', $res); } + /** + * @return void + */ public function testGetProfileBetweenAddsMemoryPeakUsage() { $profiler = new Profiler(); @@ -84,14 +101,17 @@ public function testGetProfileBetweenAddsMemoryPeakUsage() $this->assertEquals('Peak: 68.4GB | ', $res); } + /** + * @return void + */ public function testGetProfileBetweenCombinesDetails() { $profiler = new Profiler(); $profiler->setDetails([ - 'time' => ['name' => 'Time', 'precision' => 3, 'pad' => 3], - 'mem' => ['name' => 'Memory', 'precision' => 3, 'pad' => 3], + 'time' => ['name' => 'Time', 'precision' => 3, 'pad' => 3], + 'mem' => ['name' => 'Memory', 'precision' => 3, 'pad' => 3], 'memDelta' => ['name' => 'Delta', 'precision' => 3, 'pad' => 3], - 'memPeak' => ['name' => 'Peak', 'precision' => 3, 'pad' => 3], + 'memPeak' => ['name' => 'Peak', 'precision' => 3, 'pad' => 3], ]); $res = $profiler->getProfileBetween( ['microtime' => 1.234, 'memoryUsage' => 343245, 'memoryPeakUsage' => 314357], @@ -123,6 +143,8 @@ public function providerForTestFormatMemory() /** * @dataProvider providerForTestFormatMemory + * + * @return void */ public function testFormatMemory($input, $output) { @@ -143,6 +165,8 @@ public function providerForTestFormatMemoryPrecision() /** * @dataProvider providerForTestFormatMemoryPrecision + * + * @return void */ public function testFormatMemoryPrecision($input, $output) { @@ -170,6 +194,8 @@ public function providerForTestFormatDuration() /** * @dataProvider providerForTestFormatDuration + * + * @return void */ public function testFormatDuration($input, $output) { @@ -190,6 +216,8 @@ public function providerForTestFormatDurationPrecision() /** * @dataProvider providerForTestFormatDurationPrecision + * + * @return void */ public function testFormatDurationPrecision($input, $output) { @@ -222,6 +250,8 @@ public function providerForTestToPrecision() /** * @dataProvider providerForTestToPrecision + * + * @return void */ public function testToPrecision($input, $output) { @@ -243,6 +273,8 @@ public function providerForTestToPrecisionPrecision() /** * @dataProvider providerForTestToPrecisionPrecision + * + * @return void */ public function testToPrecisionPrecision($input, $output) { diff --git a/tests/Propel/Tests/Runtime/Util/PropelConditionalProxyTest.php b/tests/Propel/Tests/Runtime/Util/PropelConditionalProxyTest.php index 438aedd874..35418c8eaa 100644 --- a/tests/Propel/Tests/Runtime/Util/PropelConditionalProxyTest.php +++ b/tests/Propel/Tests/Runtime/Util/PropelConditionalProxyTest.php @@ -10,86 +10,90 @@ namespace Propel\Tests\Runtime\Util; -use Propel\Tests\Helpers\BaseTestCase; - -use Propel\Runtime\Util\PropelConditionalProxy; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Util\PropelConditionalProxy; +use Propel\Tests\Helpers\BaseTestCase; /** * Test class for PropelConditionalProxy. * * @author Julien Muetton - * @version $Id: CriteriaCombineTest.php 1347 2009-12-03 21:06:36Z francois $ + * @version $Id: CriteriaCombineTest.php 1347 2009-12-03 21:06:36Z francois $ */ class PropelConditionalProxyTest extends BaseTestCase { - public function testFluidInterface() - { - $criteria = new ProxyTestCriteria(); - $p = new TestPropelConditionalProxy($criteria, false); - - $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface'); + /** + * @return void + */ + public function testFluidInterface() + { + $criteria = new ProxyTestCriteria(); + $p = new TestPropelConditionalProxy($criteria, false); - $this->assertEquals($p->_elseif(true), $criteria, '_elseif returns fluid interface'); + $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface'); - $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface'); + $this->assertEquals($p->_elseif(true), $criteria, '_elseif returns fluid interface'); - $this->assertEquals($p->_else(), $p, '_else returns fluid interface'); + $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface'); - $criteria = new ProxyTestCriteria(); + $this->assertEquals($p->_else(), $p, '_else returns fluid interface'); - $p = new TestPropelConditionalProxy($criteria, true); + $criteria = new ProxyTestCriteria(); - $this->assertEquals($p->_elseif(true), $p, '_elseif returns fluid interface'); + $p = new TestPropelConditionalProxy($criteria, true); - $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface'); + $this->assertEquals($p->_elseif(true), $p, '_elseif returns fluid interface'); - $this->assertEquals($p->_else(), $p, '_else returns fluid interface'); + $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface'); - $criteria = new ProxyTestCriteria(); - $p = new TestPropelConditionalProxy($criteria, false); + $this->assertEquals($p->_else(), $p, '_else returns fluid interface'); - $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface'); + $criteria = new ProxyTestCriteria(); + $p = new TestPropelConditionalProxy($criteria, false); - $this->assertEquals($p->_else(), $criteria, '_else returns fluid interface'); + $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface'); - } + $this->assertEquals($p->_else(), $criteria, '_else returns fluid interface'); + } - public function testHierarchy() - { - $criteria = new ProxyTestCriteria(); - $p = new TestPropelConditionalProxy($criteria, true); + /** + * @return void + */ + public function testHierarchy() + { + $criteria = new ProxyTestCriteria(); + $p = new TestPropelConditionalProxy($criteria, true); - $this->assertEquals($p->getCriteria(), $criteria, 'main object is the given one'); + $this->assertEquals($p->getCriteria(), $criteria, 'main object is the given one'); - $this->assertInstanceOf('\Propel\Runtime\Util\PropelConditionalProxy', $p2 = $p->_if(true), '_if returns fluid interface'); + $this->assertInstanceOf('\Propel\Runtime\Util\PropelConditionalProxy', $p2 = $p->_if(true), '_if returns fluid interface'); - $this->assertEquals($p2->getCriteria(), $criteria, 'main object is the given one, even with nested proxies'); + $this->assertEquals($p2->getCriteria(), $criteria, 'main object is the given one, even with nested proxies'); - $this->assertEquals($p2->getParentProxy(), $p, 'nested proxy is respected'); + $this->assertEquals($p2->getParentProxy(), $p, 'nested proxy is respected'); - $p = new PropelConditionalProxy($criteria, true); + $p = new PropelConditionalProxy($criteria, true); - $this->assertEquals($criteria, $p->_if(true), '_if returns fluid interface'); - } + $this->assertEquals($criteria, $p->_if(true), '_if returns fluid interface'); + } } class TestPropelConditionalProxy extends PropelConditionalProxy { - public function _if($cond) - { - return new TestPropelConditionalProxy($this->criteria, $cond, $this); - } - - public function getParentProxy() - { - return $this->parent; - } - - public function getCriteria() - { - return $this->criteria; - } + public function _if($cond) + { + return new TestPropelConditionalProxy($this->criteria, $cond, $this); + } + + public function getParentProxy() + { + return $this->parent; + } + + public function getCriteria() + { + return $this->criteria; + } } class ProxyTestCriteria extends Criteria diff --git a/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php b/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php index 9c2f32d3f3..ccd1bd2f73 100644 --- a/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php +++ b/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php @@ -10,58 +10,66 @@ namespace Propel\Tests\Runtime\Util; +use DateTime; +use DateTimeImmutable; +use DateTimeZone; +use PHPUnit\Framework\TestCase; use Propel\Runtime\Util\PropelDateTime; -use \DateTime; -use \DateTimeZone; - /** * Test for DateTime subclass to support serialization. * * @author Alan Pinstein * @author Soenke Ruempler */ -class PropelDateTimeTest extends \PHPUnit\Framework\TestCase +class PropelDateTimeTest extends TestCase { - /** * Assert that two dates are identical (equal and have same time zone). + * + * @return void */ - protected function assertDatesIdentical(DateTime $dt1, DateTime $dt2, $msg = "Expected DateTime1 IDENTICAL to DateTime2: %s") + protected function assertDatesIdentical(DateTime $dt1, DateTime $dt2, $msg = 'Expected DateTime1 IDENTICAL to DateTime2: %s') { - $this->assertEquals($dt1->format('Y-m-d H:i:s'), $dt1->format('Y-m-d H:i:s'), sprintf($msg, "Dates w/ no timezone resolution were not the same.")); - $this->assertEquals($dt1->getTimeZone()->getName(), $dt2->getTimeZone()->getName(), sprintf($msg, "timezones were not the same.")); + $this->assertEquals($dt1->format('Y-m-d H:i:s'), $dt1->format('Y-m-d H:i:s'), sprintf($msg, 'Dates w/ no timezone resolution were not the same.')); + $this->assertEquals($dt1->getTimeZone()->getName(), $dt2->getTimeZone()->getName(), sprintf($msg, 'timezones were not the same.')); // We do this last, because a PHP bug will make this true while the dates // may not truly be equal. // See: http://bugs.php.net/bug.php?id=40743 - $this->assertTrue($dt1 == $dt2, sprintf($msg, "dates did not pass equality check (==).")); + $this->assertTrue($dt1 == $dt2, sprintf($msg, 'dates did not pass equality check (==).')); } /** * Assert that two dates are equal. + * + * @return void */ - protected function assertDatesEqual(DateTime $dt1, DateTime $dt2, $msg = "Expected DateTime1 == DateTime2: %s") + protected function assertDatesEqual(DateTime $dt1, DateTime $dt2, $msg = 'Expected DateTime1 == DateTime2: %s') { if ($dt1 != $dt2) { if ($dt1->getTimeZone()->getName() != $dt2->getTimeZone()->getName()) { - $this->fail(sprintf($msg, "Timezones were not the same.")); + $this->fail(sprintf($msg, 'Timezones were not the same.')); } else { - $this->fail(sprintf($msg, "Timezones were the same, but date values were different.")); + $this->fail(sprintf($msg, 'Timezones were the same, but date values were different.')); } } } /** * Assert that two dates are not equal. + * + * @return void */ - protected function assertDatesNotEqual(DateTime $dt1, DateTime $dt2, $msg = "Expected DateTime1 != DateTime2: %s") + protected function assertDatesNotEqual(DateTime $dt1, DateTime $dt2, $msg = 'Expected DateTime1 != DateTime2: %s') { $this->assertTrue($dt1 != $dt2, $msg); } /** * Ensure that our constructor matches DateTime constructor signature. + * + * @return void */ public function testConstruct() { @@ -70,21 +78,22 @@ public function testConstruct() } // Because of a PHP bug () - // we cannot use a timestamp format that includes a timezone. It gets weird. :) + // we cannot use a timestamp format that includes a timezone. It gets weird. :) $now = date('Y-m-d H:i:s'); $dt = new DateTime($now); $pdt = new PropelDateTime($now); - $this->assertDatesEqual($dt, $pdt, "Expected DateTime == PropelDateTime: %s"); + $this->assertDatesEqual($dt, $pdt, 'Expected DateTime == PropelDateTime: %s'); $dt = new DateTime($now, new DateTimeZone('UTC')); $pdt = new PropelDateTime($now, new DateTimeZone('America/New_York')); - $this->assertDatesNotEqual($dt, $pdt, "Expected DateTime != PropelDateTime: %s"); - + $this->assertDatesNotEqual($dt, $pdt, 'Expected DateTime != PropelDateTime: %s'); } /** * Tests the ability to serialize() a PropelDateTime object. + * + * @return void */ public function testSerialize_NoTZ() { @@ -108,6 +117,8 @@ public function testSerialize_NoTZ() /** * Tests the ability to serialize() a PropelDateTime object. + * + * @return void */ public function testSerialize_SameTZ() { @@ -131,6 +142,8 @@ public function testSerialize_SameTZ() /** * Tests the ability to serialize() a PropelDateTime object. + * + * @return void */ public function testSerialize_DiffTZ() { @@ -150,6 +163,8 @@ public function testSerialize_DiffTZ() /** * @dataProvider provideValidNewInstanceValues + * + * @return void */ public function testNewInstance($value, $expected) { @@ -164,6 +179,8 @@ public function testNewInstance($value, $expected) /** * @dataProvider provideValidNewInstanceValuesGmt1 + * + * @return void */ public function testNewInstanceGmt1($value, $expected) { @@ -178,6 +195,8 @@ public function testNewInstanceGmt1($value, $expected) /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testNewInstanceInvalidValue() { @@ -187,14 +206,14 @@ public function testNewInstanceInvalidValue() public function provideValidNewInstanceValues() { return [ - 'Y-m-d' => ['2011-08-10', '2011-08-10 00:00:00'], + 'Y-m-d' => ['2011-08-10', '2011-08-10 00:00:00'], // 1312960848 : Wed, 10 Aug 2011 07:20:48 GMT - 'unix_timestamp' => ['1312960848', '2011-08-10 07:20:48'], - 'Y-m-d H:is' => ['2011-08-10 10:22:15', '2011-08-10 10:22:15'], - 'Ymd' => ['20110810', '2011-08-10 00:00:00'], - 'Ymd' => ['20110720', '2011-07-20 00:00:00'], + 'unix_timestamp' => ['1312960848', '2011-08-10 07:20:48'], + 'Y-m-d H:is' => ['2011-08-10 10:22:15', '2011-08-10 10:22:15'], + 'Ymd' => ['20110810', '2011-08-10 00:00:00'], + 'Ymd' => ['20110720', '2011-07-20 00:00:00'], 'datetime_object' => [new DateTime('2011-08-10 10:23:10'), '2011-08-10 10:23:10'], - 'datetimeimmutable_object' => [new \DateTimeImmutable('2011-08-10 10:23:10'), '2011-08-10 10:23:10'], + 'datetimeimmutable_object' => [new DateTimeImmutable('2011-08-10 10:23:10'), '2011-08-10 10:23:10'], ]; } @@ -203,13 +222,16 @@ public function provideValidNewInstanceValuesGmt1() return [ // "1312960848" : Wed, 10 Aug 2011 07:20:48 GMT // "2011-08-10 09:20:48" : GMT+1 DST (= GMT +2) - 'unix_timestamp' => ['1312960848', '2011-08-10 09:20:48'], + 'unix_timestamp' => ['1312960848', '2011-08-10 09:20:48'], // "1323517115" : Sat, 10 Dec 2011 11:38:35 GMT // "2011-12-10 12:38:35" : GMT +1 - 'unix_timestamp' => ['1323517115', '2011-12-10 12:38:35'], + 'unix_timestamp' => ['1323517115', '2011-12-10 12:38:35'], ]; } + /** + * @return void + */ public function testIsTimestamp() { $this->assertEquals(false, TestPropelDateTime::isTimestamp('20110325')); @@ -218,6 +240,9 @@ public function testIsTimestamp() $this->assertEquals(false, TestPropelDateTime::isTimestamp('2011-07-20 00:00:00')); } + /** + * @return void + */ public function testCreateHighPrecision() { $createHP = PropelDateTime::createHighPrecision(); @@ -228,6 +253,9 @@ public function testCreateHighPrecision() $this->assertInstanceOf(DateTime::class, $createHP); } + /** + * @return void + */ public function testCreateHighPrecisioniTz() { $originalTimezone = date_default_timezone_get(); @@ -235,14 +263,13 @@ public function testCreateHighPrecisioniTz() $createHP = PropelDateTime::createHighPrecision(); - $dt = new \DateTime(); - $dt->setTimezone(new \DateTimeZone('America/New_York')); + $dt = new DateTime(); + $dt->setTimezone(new DateTimeZone('America/New_York')); $this->assertEquals(date_timezone_get($dt), date_timezone_get($createHP)); date_default_timezone_set($originalTimezone); } - } class TestPropelDateTime extends PropelDateTime diff --git a/tests/Propel/Tests/Runtime/Util/PropelModelPagerTest.php b/tests/Propel/Tests/Runtime/Util/PropelModelPagerTest.php index 080bec4dcb..bad723a106 100644 --- a/tests/Propel/Tests/Runtime/Util/PropelModelPagerTest.php +++ b/tests/Propel/Tests/Runtime/Util/PropelModelPagerTest.php @@ -10,14 +10,13 @@ namespace Propel\Tests\Runtime\Util; -use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; -use Propel\Tests\Bookstore\Book; -use Propel\Tests\Bookstore\BookQuery; - +use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Collection\ArrayCollection; use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Util\PropelModelPager; -use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Tests\Bookstore\Book; +use Propel\Tests\Bookstore\BookQuery; +use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; /** * Test the utility class PropelModelPager @@ -29,19 +28,23 @@ class PropelModelPagerTest extends BookstoreEmptyTestBase { private $authorId; + private $books; + /** + * @return void + */ protected function createBooks($nb = 15, $con = null) { BookQuery::create()->deleteAll($con); $books = new ObjectCollection(); $books->setModel('\Propel\Tests\Bookstore\Book'); - for ($i=0; $i < $nb; $i++) { + for ($i = 0; $i < $nb; $i++) { $b = new Book(); $b->setTitle('Book' . $i); $b->setISBN('FA404-' . $i); - $books[]= $b; + $books[] = $b; } $books->save($con); } @@ -55,6 +58,9 @@ protected function getPager($maxPerPage, $page = 1) return $pager; } + /** + * @return void + */ public function testHaveToPaginate() { BookQuery::create()->deleteAll(); @@ -66,6 +72,9 @@ public function testHaveToPaginate() $this->assertEquals(false, $this->getPager(5)->haveToPaginate(), 'haveToPaginate() returns false when the maxPerPage is equal to the number of results'); } + /** + * @return void + */ public function testGetNbResults() { BookQuery::create()->deleteAll(); @@ -84,6 +93,9 @@ public function testGetNbResults() $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results'); } + /** + * @return void + */ public function testGetResults() { $this->createBooks(5); @@ -96,6 +108,9 @@ public function testGetResults() $this->assertEquals(1, count($pager->getResults()), 'getResults() returns the results of the last page when called on nonexistent pages'); } + /** + * @return void + */ public function testGetResultsRespectsFormatter() { $this->createBooks(5); @@ -107,6 +122,9 @@ public function testGetResultsRespectsFormatter() $this->assertTrue($pager->getResults() instanceof ArrayCollection, 'getResults() returns a PropelArrayCollection if the query uses array hydration'); } + /** + * @return void + */ public function testGetIterator() { $this->createBooks(5); @@ -120,6 +138,9 @@ public function testGetIterator() $this->assertEquals(4, $i, 'getIterator() uses the results collection'); } + /** + * @return void + */ public function testIterateTwice() { $this->createBooks(5); @@ -140,6 +161,9 @@ public function testIterateTwice() $this->assertEquals(4, $i, 'getIterator() can be called several times'); } + /** + * @return void + */ public function testSetPage() { $this->createBooks(5); @@ -152,6 +176,9 @@ public function testSetPage() $this->assertEquals(4, $i, 'setPage() doesn\'t change the page count'); } + /** + * @return void + */ public function testIsFirstPage() { $this->createBooks(5); @@ -161,6 +188,9 @@ public function testIsFirstPage() $this->assertFalse($pager->isFirstPage(), 'isFirstPage() returns false when not on the first page'); } + /** + * @return void + */ public function testIsLastPage() { $this->createBooks(5); @@ -170,6 +200,9 @@ public function testIsLastPage() $this->assertTrue($pager->isLastPage(), 'isLastPage() returns true on the last page'); } + /** + * @return void + */ public function testGetLastPage() { $this->createBooks(5); @@ -178,12 +211,18 @@ public function testGetLastPage() $this->assertInternalType('integer', $pager->getLastPage(), 'getLastPage() returns an integer'); } + /** + * @return void + */ public function testIsEmptyIsTrueOnEmptyPagers() { $pager = $this->getPager(4, 1); $this->assertTrue($pager->isEmpty()); } + /** + * @return void + */ public function testIsEmptyIsFalseOnNonEmptyPagers() { $this->createBooks(1); @@ -191,6 +230,9 @@ public function testIsEmptyIsFalseOnNonEmptyPagers() $this->assertFalse($pager->isEmpty()); } + /** + * @return void + */ public function testCountableInterface() { BookQuery::create()->deleteAll(); @@ -205,15 +247,21 @@ public function testCountableInterface() $this->assertCount(5, $pager); } + /** + * @return void + */ public function testZeroOnNoResult() { $pager = $this->getPager(1, 100); $this->assertEquals(0, $pager->getNbResults()); - $this->assertEquals(0, $pager->getPage()); + $this->assertEquals(0, $pager->getPage()); $this->assertEquals(0, $pager->getFirstPage()); $this->assertEquals(0, $pager->getLastPage()); } + /** + * @return void + */ public function testCallIteratorMethods() { $this->createBooks(5); @@ -229,5 +277,4 @@ public function testCallIteratorMethods() } } } - } diff --git a/tests/Propel/Tests/Runtime/Util/TableMapExceptionsTest.php b/tests/Propel/Tests/Runtime/Util/TableMapExceptionsTest.php index c348897015..5a97961a44 100644 --- a/tests/Propel/Tests/Runtime/Util/TableMapExceptionsTest.php +++ b/tests/Propel/Tests/Runtime/Util/TableMapExceptionsTest.php @@ -10,12 +10,11 @@ namespace Propel\Tests\Runtime\Util; -use Propel\Runtime\Propel; -use Propel\Runtime\Exception\PropelException; use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\Map\TableMap; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use Propel\Runtime\Exception\PropelException; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Tests the exceptions thrown by the TableMap classes. @@ -27,6 +26,9 @@ */ class TableMapExceptionsTest extends BookstoreTestBase { + /** + * @return void + */ public function testDoSelect() { try { @@ -40,6 +42,9 @@ public function testDoSelect() } } + /** + * @return void + */ public function testDoCount() { try { @@ -53,6 +58,9 @@ public function testDoCount() } } + /** + * @return void + */ public function testDoDelete() { try { @@ -66,6 +74,9 @@ public function testDoDelete() } } + /** + * @return void + */ public function testDoUpdate() { try { @@ -82,6 +93,9 @@ public function testDoUpdate() } } + /** + * @return void + */ public function testDoInsert() { $con = Propel::getServiceContainer()->getWriteConnection(BookTableMap::DATABASE_NAME); @@ -101,7 +115,6 @@ public function testDoInsert() } else { $this->assertContains($this->getSql('[INSERT INTO book (author_id) VALUES (:p1)]'), $e->getMessage(), 'SQL query is written in the exception message'); } - } } } diff --git a/tests/Propel/Tests/Runtime/Util/TableMapTest.php b/tests/Propel/Tests/Runtime/Util/TableMapTest.php index 19e6c45fda..8fe75db3d1 100644 --- a/tests/Propel/Tests/Runtime/Util/TableMapTest.php +++ b/tests/Propel/Tests/Runtime/Util/TableMapTest.php @@ -10,17 +10,16 @@ namespace Propel\Tests\Runtime\Util; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Exception\PropelException; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\BookQuery; use Propel\Tests\Bookstore\Bookstore; use Propel\Tests\Bookstore\BookstoreQuery; use Propel\Tests\Bookstore\Map\AuthorTableMap; -use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\BookstoreTableMap; -use Propel\Runtime\Propel; -use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\Exception\PropelException; -use Propel\Runtime\Map\TableMap; +use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Tests the TableMap classes. @@ -32,9 +31,10 @@ */ class TableMapTest extends BookstoreTestBase { - /** * @link http://propel.phpdb.org/trac/ticket/425 + * + * @return void */ public function testMultipleFunctionInCriteria() { @@ -43,16 +43,19 @@ public function testMultipleFunctionInCriteria() $c = new Criteria(); $c->setDistinct(); if ($db instanceof PgsqlAdapter) { - $c->addSelectColumn("substring(".BookTableMap::TITLE." from position('Potter' in ".BookTableMap::TITLE.")) AS col"); + $c->addSelectColumn('substring(' . BookTableMap::TITLE . " from position('Potter' in " . BookTableMap::TITLE . ')) AS col'); } else { $this->markTestSkipped('Configured database vendor is not PostgreSQL'); } $obj = BookQuery::create(null, $c)->find(); } catch (PropelException $x) { - $this->fail("Paring of nested functions failed: " . $x->getMessage()); + $this->fail('Paring of nested functions failed: ' . $x->getMessage()); } } + /** + * @return void + */ public function testNeedsSelectAliases() { $c = new Criteria(); @@ -73,6 +76,9 @@ public function testNeedsSelectAliases() $this->assertTrue($c->needsSelectAliases(), 'Criterias with common column names do need aliases'); } + /** + * @return void + */ public function testDoCountDuplicateColumnName() { $con = Propel::getServiceContainer()->getReadConnection(BookTableMap::DATABASE_NAME); @@ -88,22 +94,25 @@ public function testDoCountDuplicateColumnName() } } + /** + * @return void + */ public function testBigIntIgnoreCaseOrderBy() { BookstoreTableMap::doDeleteAll(); // Some sample data $b = new Bookstore(); - $b->setStoreName("SortTest1")->setPopulationServed(2000)->save(); + $b->setStoreName('SortTest1')->setPopulationServed(2000)->save(); $b = new Bookstore(); - $b->setStoreName("SortTest2")->setPopulationServed(201)->save(); + $b->setStoreName('SortTest2')->setPopulationServed(201)->save(); $b = new Bookstore(); - $b->setStoreName("SortTest3")->setPopulationServed(302)->save(); + $b->setStoreName('SortTest3')->setPopulationServed(302)->save(); $b = new Bookstore(); - $b->setStoreName("SortTest4")->setPopulationServed(10000000)->save(); + $b->setStoreName('SortTest4')->setPopulationServed(10000000)->save(); $c = new Criteria(); $c->setIgnoreCase(true); @@ -117,8 +126,9 @@ public function testBigIntIgnoreCaseOrderBy() $this->assertEquals('SortTest4', $rows[3]->getStoreName()); } + /** - * + * @return void */ public function testMixedJoinOrder() { @@ -133,14 +143,17 @@ public function testMixedJoinOrder() $params = []; $sql = $c->createSelectSql($params); - $expectedSql = "SELECT book.id, book.title FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.id), author WHERE book.AUTHOR_ID=author.id"; + $expectedSql = 'SELECT book.id, book.title FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.id), author WHERE book.AUTHOR_ID=author.id'; $this->assertEquals($expectedSql, $sql); } + /** + * @return void + */ public function testMssqlApplyLimitNoOffset() { $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME); - if (! ($db instanceof MssqlAdapter)) { + if (!($db instanceof MssqlAdapter)) { $this->markTestSkipped('Configured database vendor is not MsSQL'); } @@ -148,7 +161,7 @@ public function testMssqlApplyLimitNoOffset() $c->addSelectColumn(BookTableMap::COL_ID); $c->addSelectColumn(BookTableMap::COL_TITLE); $c->addSelectColumn(PublisherTableMap::COL_NAME); - $c->addAsColumn('PublisherName','(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID)'); + $c->addAsColumn('PublisherName', '(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID)'); $c->addJoin(BookTableMap::COL_PUBLISHER_ID, PublisherTableMap::COL_ID, Criteria::LEFT_JOIN); @@ -158,14 +171,17 @@ public function testMssqlApplyLimitNoOffset() $params = []; $sql = $c->createSelectSql($params); - $expectedSql = "SELECT TOP 20 book.id, book.title, publisher.NAME, (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) AS PublisherName FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.id)"; + $expectedSql = 'SELECT TOP 20 book.id, book.title, publisher.NAME, (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) AS PublisherName FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.id)'; $this->assertEquals($expectedSql, $sql); } + /** + * @return void + */ public function testMssqlApplyLimitWithOffset() { $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME); - if (! ($db instanceof MssqlAdapter)) { + if (!($db instanceof MssqlAdapter)) { $this->markTestSkipped('Configured database vendor is not MsSQL'); } @@ -173,22 +189,25 @@ public function testMssqlApplyLimitWithOffset() $c->addSelectColumn(BookTableMap::COL_ID); $c->addSelectColumn(BookTableMap::COL_TITLE); $c->addSelectColumn(PublisherTableMap::COL_NAME); - $c->addAsColumn('PublisherName','(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID)'); + $c->addAsColumn('PublisherName', '(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID)'); $c->addJoin(BookTableMap::COL_PUBLISHER_ID, PublisherTableMap::COL_ID, Criteria::LEFT_JOIN); $c->setOffset(20); $c->setLimit(20); $params = []; - $expectedSql = "SELECT [book.id], [book.title], [publisher.NAME], [PublisherName] FROM (SELECT ROW_NUMBER() OVER(ORDER BY book.id) AS [RowNumber], book.id AS [book.id], book.title AS [book.title], publisher.NAME AS [publisher.NAME], (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) AS [PublisherName] FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.id)) AS derivedb WHERE RowNumber BETWEEN 21 AND 40"; + $expectedSql = 'SELECT [book.id], [book.title], [publisher.NAME], [PublisherName] FROM (SELECT ROW_NUMBER() OVER(ORDER BY book.id) AS [RowNumber], book.id AS [book.id], book.title AS [book.title], publisher.NAME AS [publisher.NAME], (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) AS [PublisherName] FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.id)) AS derivedb WHERE RowNumber BETWEEN 21 AND 40'; $sql = $c->createSelectSql($params); $this->assertEquals($expectedSql, $sql); } + /** + * @return void + */ public function testMssqlApplyLimitWithOffsetOrderByAggregate() { $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME); - if (! ($db instanceof MssqlAdapter)) { + if (!($db instanceof MssqlAdapter)) { $this->markTestSkipped('Configured database vendor is not MsSQL'); } @@ -196,7 +215,7 @@ public function testMssqlApplyLimitWithOffsetOrderByAggregate() $c->addSelectColumn(BookTableMap::COL_ID); $c->addSelectColumn(BookTableMap::COL_TITLE); $c->addSelectColumn(PublisherTableMap::COL_NAME); - $c->addAsColumn('PublisherName','(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID)'); + $c->addAsColumn('PublisherName', '(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID)'); $c->addJoin(BookTableMap::COL_PUBLISHER_ID, PublisherTableMap::COL_ID, Criteria::LEFT_JOIN); $c->addDescendingOrderByColumn('PublisherName'); $c->setOffset(20); @@ -204,15 +223,18 @@ public function testMssqlApplyLimitWithOffsetOrderByAggregate() $params = []; - $expectedSql = "SELECT [book.id], [book.title], [publisher.NAME], [PublisherName] FROM (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) DESC) AS [RowNumber], book.id AS [book.id], book.title AS [book.title], publisher.NAME AS [publisher.NAME], (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) AS [PublisherName] FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.id)) AS derivedb WHERE RowNumber BETWEEN 21 AND 40"; + $expectedSql = 'SELECT [book.id], [book.title], [publisher.NAME], [PublisherName] FROM (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) DESC) AS [RowNumber], book.id AS [book.id], book.title AS [book.title], publisher.NAME AS [publisher.NAME], (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) AS [PublisherName] FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.id)) AS derivedb WHERE RowNumber BETWEEN 21 AND 40'; $sql = $c->createSelectSql($params); $this->assertEquals($expectedSql, $sql); } + /** + * @return void + */ public function testMssqlApplyLimitWithOffsetMultipleOrderBy() { $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME); - if (! ($db instanceof MssqlAdapter)) { + if (!($db instanceof MssqlAdapter)) { $this->markTestSkipped('Configured database vendor is not MsSQL'); } @@ -220,7 +242,7 @@ public function testMssqlApplyLimitWithOffsetMultipleOrderBy() $c->addSelectColumn(BookTableMap::COL_ID); $c->addSelectColumn(BookTableMap::COL_TITLE); $c->addSelectColumn(PublisherTableMap::COL_NAME); - $c->addAsColumn('PublisherName','(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID)'); + $c->addAsColumn('PublisherName', '(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID)'); $c->addJoin(BookTableMap::COL_PUBLISHER_ID, PublisherTableMap::COL_ID, Criteria::LEFT_JOIN); $c->addDescendingOrderByColumn('PublisherName'); $c->addAscendingOrderByColumn(BookTableMap::COL_TITLE); @@ -229,13 +251,15 @@ public function testMssqlApplyLimitWithOffsetMultipleOrderBy() $params = []; - $expectedSql = "SELECT [book.id], [book.title], [publisher.NAME], [PublisherName] FROM (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) DESC, book.title ASC) AS [RowNumber], book.id AS [book.id], book.title AS [book.title], publisher.NAME AS [publisher.NAME], (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) AS [PublisherName] FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.id)) AS derivedb WHERE RowNumber BETWEEN 21 AND 40"; + $expectedSql = 'SELECT [book.id], [book.title], [publisher.NAME], [PublisherName] FROM (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) DESC, book.title ASC) AS [RowNumber], book.id AS [book.id], book.title AS [book.title], publisher.NAME AS [publisher.NAME], (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) AS [PublisherName] FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.id)) AS derivedb WHERE RowNumber BETWEEN 21 AND 40'; $sql = $c->createSelectSql($params); $this->assertEquals($expectedSql, $sql); } /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testDoDeleteNoCondition() { @@ -246,6 +270,8 @@ public function testDoDeleteNoCondition() /** * @expectedException \Propel\Runtime\Exception\PropelException + * + * @return void */ public function testDoDeleteJoin() { @@ -256,6 +282,9 @@ public function testDoDeleteJoin() $c->doDelete($con); } + /** + * @return void + */ public function testDoDeleteSimpleCondition() { $con = Propel::getServiceContainer()->getWriteConnection(BookTableMap::DATABASE_NAME); @@ -266,6 +295,9 @@ public function testDoDeleteSimpleCondition() $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'doDelete() translates a condition into a WHERE'); } + /** + * @return void + */ public function testDoDeleteSeveralConditions() { $con = Propel::getServiceContainer()->getWriteConnection(BookTableMap::DATABASE_NAME); @@ -277,6 +309,9 @@ public function testDoDeleteSeveralConditions() $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'doDelete() combines conditions in WHERE with an AND'); } + /** + * @return void + */ public function testDoDeleteTableAlias() { if ($this->runningOnSQLite()) { @@ -299,7 +334,10 @@ public function testDoDeleteTableAlias() /** * Not documented anywhere, and probably wrong + * * @see http://www.propelorm.org/ticket/952 + * + * @return void */ public function testDoDeleteSeveralTables() { @@ -322,6 +360,9 @@ public function testDoDeleteSeveralTables() $this->assertEquals($count + 4, $con->getQueryCount(), 'doDelete() issues two DELETE queries when passed conditions on two tables'); } + /** + * @return void + */ public function testCommentDoSelect() { $c = new Criteria(); @@ -332,6 +373,9 @@ public function testCommentDoSelect() $this->assertEquals($expected, $c->createSelectSQL($params), 'Criteria::setComment() adds a comment to select queries'); } + /** + * @return void + */ public function testCommentDoUpdate() { $c1 = new Criteria(); @@ -345,6 +389,9 @@ public function testCommentDoUpdate() $this->assertEquals($expected, $con->getLastExecutedQuery(), 'Criteria::setComment() adds a comment to update queries'); } + /** + * @return void + */ public function testCommentDoDelete() { $c = new Criteria(); @@ -356,6 +403,9 @@ public function testCommentDoDelete() $this->assertEquals($expected, $con->getLastExecutedQuery(), 'Criteria::setComment() adds a comment to delete queries'); } + /** + * @return void + */ public function testIneffectualUpdateUsingBookObject() { $con = Propel::getConnection(BookTableMap::DATABASE_NAME); diff --git a/tests/Propel/Tests/TestCase.php b/tests/Propel/Tests/TestCase.php index ec44e8d50e..adc69aa66d 100644 --- a/tests/Propel/Tests/TestCase.php +++ b/tests/Propel/Tests/TestCase.php @@ -10,8 +10,9 @@ namespace Propel\Tests; +use PHPUnit\Framework\TestCase as PHPUnitTestCase; -class TestCase extends \PHPUnit\Framework\TestCase +class TestCase extends PHPUnitTestCase { protected function getDriver() { @@ -22,9 +23,10 @@ protected function getDriver() * Makes the sql compatible with the current database. * Means: replaces ` etc. * - * @param string $sql - * @param string $source - * @param string $target + * @param string $sql + * @param string $source + * @param string|null $target + * * @return mixed */ protected function getSql($sql, $source = 'mysql', $target = null) @@ -49,7 +51,8 @@ protected function getSql($sql, $source = 'mysql', $target = null) /** * Returns true if the current driver in the connection ($this->con) is $db. * - * @param string $db + * @param string $db + * * @return bool */ protected function isDb($db = 'mysql') @@ -104,7 +107,7 @@ protected function getPlatform() { $className = sprintf('\\Propel\\Generator\\Platform\\%sPlatform', ucfirst($this->getDriver())); - return new $className; + return new $className(); } /** @@ -114,7 +117,7 @@ protected function getParser($con) { $className = sprintf('\\Propel\\Generator\\Reverse\\%sSchemaParser', ucfirst($this->getDriver())); - $obj = new $className($con); + $obj = new $className($con); return $obj; } diff --git a/tests/Propel/Tests/TestCaseFixtures.php b/tests/Propel/Tests/TestCaseFixtures.php index ee49ad0a3c..b741e17ba9 100644 --- a/tests/Propel/Tests/TestCaseFixtures.php +++ b/tests/Propel/Tests/TestCaseFixtures.php @@ -10,10 +10,12 @@ namespace Propel\Tests; -use Propel\Generator\Command\TestPrepareCommand; +use PDO; use Propel\Runtime\Propel; +use ReflectionClass; use Symfony\Component\Console\Application; -use Propel\Runtime\Connection\ConnectionInterface; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Finder\Finder; /** @@ -35,16 +37,20 @@ class TestCaseFixtures extends TestCase * Depending on this type we return the correct runninOn* results, * also getSql() and getDriver() is based on that. * - * @var ConnectionInterface + * @var \Propel\Runtime\Connection\ConnectionInterface */ protected $con; public static $lastBuildDsn; + public static $lastBuildMode; + public static $lastReadConfigs; /** * Setup fixture. Needed here because we want to have a realistic code coverage value. + * + * @return void */ protected function setUp(): void { @@ -54,7 +60,7 @@ protected function setUp(): void 'command' => 'test:prepare', '--vendor' => $this->getDriver(), '--dsn' => $dsn, - '--verbose' => true + '--verbose' => true, ]; if (!static::$withDatabaseSchema) { @@ -77,19 +83,20 @@ protected function setUp(): void if ($skip) { $this->readAllRuntimeConfigs(); + //skip, as we've already created all fixtures for current database connection. return; } } $finder = new Finder(); - $finder->files()->name('*.php')->in(__DIR__.'/../../../src/Propel/Generator/Command')->depth(0); + $finder->files()->name('*.php')->in(__DIR__ . '/../../../src/Propel/Generator/Command')->depth(0); $app = new Application('Propel', Propel::VERSION); foreach ($finder as $file) { $ns = '\\Propel\\Generator\\Command'; - $r = new \ReflectionClass($ns.'\\'.$file->getBasename('.php')); + $r = new ReflectionClass($ns . '\\' . $file->getBasename('.php')); if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract()) { /** @var \Symfony\Component\Console\Command\Command $command */ $command = $r->newInstance(); @@ -104,18 +111,20 @@ protected function setUp(): void $options['--password'] = getenv('DB_PW'); } - $input = new \Symfony\Component\Console\Input\ArrayInput($options); + $input = new ArrayInput($options); - $output = new \Symfony\Component\Console\Output\BufferedOutput(); + $output = new BufferedOutput(); $app->setAutoExit(false); if (0 !== $app->run($input, $output)) { echo $output->fetch(); $this->fail('Can not initialize fixtures.'); + return; } $builtInfo = __DIR__ . '/../../Fixtures/fixtures_built'; - file_put_contents($builtInfo, + file_put_contents( + $builtInfo, "$dsn\n$mode\nFixtures has been created. Delete this file to let the test suite regenerate all fixtures." ); @@ -136,27 +145,30 @@ protected function getLastBuildMode() if (file_exists($builtInfo) && ($h = fopen($builtInfo, 'r'))) { fgets($h); $secondLine = fgets($h); + return static::$lastBuildMode = trim($secondLine); } } /** * Reads and includes all *-conf.php of Fixtures/ folder. + * + * @return void */ protected function readAllRuntimeConfigs() { - if (static::$lastReadConfigs === static::$lastBuildMode.':'.static::$lastBuildDsn) { + if (static::$lastReadConfigs === static::$lastBuildMode . ':' . static::$lastBuildDsn) { return; } $finder = new Finder(); - $finder->files()->name('*-conf.php')->in(__DIR__.'/../../Fixtures/'); + $finder->files()->name('*-conf.php')->in(__DIR__ . '/../../Fixtures/'); foreach ($finder as $file) { include_once($file->getPathname()); } - static::$lastReadConfigs = static::$lastBuildMode.':'.static::$lastBuildDsn; + static::$lastReadConfigs = static::$lastBuildMode . ':' . static::$lastBuildDsn; } /** @@ -180,13 +192,14 @@ protected function getBuiltDsn() * Returns the current connection DSN. * * @param string $database - * @param boolean $withCredentials + * @param bool $withCredentials + * * @return string */ protected function getConnectionDsn($database = 'bookstore', $withCredentials = false) { - $serviceContainer = \Propel\Runtime\Propel::getServiceContainer(); - /** @var $manager \Propel\Runtime\Connection\ConnectionManagerSingle */ + $serviceContainer = Propel::getServiceContainer(); + /** @var \Propel\Runtime\Connection\ConnectionManagerSingle $manager */ $manager = $serviceContainer->getConnectionManager($database); $configuration = $manager->getConfiguration(); $dsn = $configuration['dsn']; @@ -216,6 +229,7 @@ protected function getFixturesConnectionDsn() if (!file_exists($path)) { touch($path); } + return 'sqlite:' . realpath($path); } @@ -230,7 +244,6 @@ protected function getFixturesConnectionDsn() return $dsn; } - /** * Returns current database driver. * @@ -238,7 +251,7 @@ protected function getFixturesConnectionDsn() */ protected function getDriver() { - $driver = $this->con ? $this->con->getAttribute(\PDO::ATTR_DRIVER_NAME) : null; + $driver = $this->con ? $this->con->getAttribute(PDO::ATTR_DRIVER_NAME) : null; if (null === $driver && $currentDSN = $this->getBuiltDsn()) { $driver = explode(':', $currentDSN)[0]; diff --git a/tests/Propel/Tests/TestCaseFixturesDatabase.php b/tests/Propel/Tests/TestCaseFixturesDatabase.php index d80467b4ed..b12c5c4e8b 100644 --- a/tests/Propel/Tests/TestCaseFixturesDatabase.php +++ b/tests/Propel/Tests/TestCaseFixturesDatabase.php @@ -10,12 +10,6 @@ namespace Propel\Tests; -use Propel\Generator\Command\TestPrepareCommand; -use Propel\Runtime\Propel; -use Symfony\Component\Console\Application; -use Propel\Runtime\Connection\ConnectionInterface; -use Symfony\Component\Finder\Finder; - /** * The same as TestCaseFixtures but makes additional sure that * database schema has been updated. diff --git a/tests/Propel/Tests/Ticket520Test.php b/tests/Propel/Tests/Ticket520Test.php index 8e431d8ba9..01275562aa 100644 --- a/tests/Propel/Tests/Ticket520Test.php +++ b/tests/Propel/Tests/Ticket520Test.php @@ -21,18 +21,21 @@ */ class Ticket520Test extends BookstoreTestBase { + /** + * @return void + */ public function testNewObjectsAvailableWhenSaveNotCalled() { $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + $a->setFirstName('Douglas'); + $a->setLastName('Adams'); $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $b1->setTitle('The Hitchhikers Guide To The Galaxy'); $a->addBook($b1); $b2 = new Book(); - $b2->setTitle("The Restaurant At The End Of The Universe"); + $b2->setTitle('The Restaurant At The End Of The Universe'); $a->addBook($b2); // Passing no Criteria means "use the internal collection or query the database" @@ -41,43 +44,49 @@ public function testNewObjectsAvailableWhenSaveNotCalled() $this->assertEquals(2, count($books)); } + /** + * @return void + */ public function testNewObjectsNotAvailableWithCriteria() { $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + $a->setFirstName('Douglas'); + $a->setLastName('Adams'); $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $b1->setTitle('The Hitchhikers Guide To The Galaxy'); $a->addBook($b1); $b2 = new Book(); - $b2->setTitle("The Restaurant At The End Of The Universe"); + $b2->setTitle('The Restaurant At The End Of The Universe'); $a->addBook($b2); $c = new Criteria(); - $c->add(BookTableMap::COL_TITLE, "%Hitchhiker%", Criteria::LIKE); + $c->add(BookTableMap::COL_TITLE, '%Hitchhiker%', Criteria::LIKE); $guides = $a->getBooks($c); $this->assertEquals(0, count($guides), 'Passing a Criteria means "force a database query"'); } + /** + * @return void + */ public function testNewObjectsAvailableAfterCriteria() { $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + $a->setFirstName('Douglas'); + $a->setLastName('Adams'); $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $b1->setTitle('The Hitchhikers Guide To The Galaxy'); $a->addBook($b1); $b2 = new Book(); - $b2->setTitle("The Restaurant At The End Of The Universe"); + $b2->setTitle('The Restaurant At The End Of The Universe'); $a->addBook($b2); $c = new Criteria(); - $c->add(BookTableMap::COL_TITLE, "%Hitchhiker%", Criteria::LIKE); + $c->add(BookTableMap::COL_TITLE, '%Hitchhiker%', Criteria::LIKE); $guides = $a->getBooks($c); @@ -85,24 +94,27 @@ public function testNewObjectsAvailableAfterCriteria() $this->assertEquals(2, count($books), 'A previous query with a Criteria does not erase the internal collection'); } + /** + * @return void + */ public function testSavedObjectsWithCriteria() { $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + $a->setFirstName('Douglas'); + $a->setLastName('Adams'); $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $b1->setTitle('The Hitchhikers Guide To The Galaxy'); $b1->setISBN('FA404-1'); $a->addBook($b1); $b2 = new Book(); - $b2->setTitle("The Restaurant At The End Of The Universe"); + $b2->setTitle('The Restaurant At The End Of The Universe'); $b2->setISBN('FA404-2'); $a->addBook($b2); $c = new Criteria(); - $c->add(BookTableMap::COL_TITLE, "%Hitchhiker%", Criteria::LIKE); + $c->add(BookTableMap::COL_TITLE, '%Hitchhiker%', Criteria::LIKE); $guides = $a->getBooks($c); @@ -111,16 +123,19 @@ public function testSavedObjectsWithCriteria() $this->assertEquals(1, count($booksAfterSave), 'A previous query with a Criteria is not cached'); } + /** + * @return void + */ public function testAddNewObjectAfterSave() { $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + $a->setFirstName('Douglas'); + $a->setLastName('Adams'); $a->save(); $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $b1->setTitle('The Hitchhikers Guide To The Galaxy'); $b1->setISBN('FA404-1'); $a->addBook($b1); @@ -135,6 +150,9 @@ public function testAddNewObjectAfterSave() $this->assertFalse($b1->isNew(), 'related objects are also saved after fetching them'); } + /** + * @return void + */ public function testAddNewObjectAfterSaveWithPoisonedCache() { /* This is like testAddNewObjectAfterSave(), @@ -142,14 +160,14 @@ public function testAddNewObjectAfterSaveWithPoisonedCache() before adding the book by calling getBooks(). */ $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + $a->setFirstName('Douglas'); + $a->setLastName('Adams'); $a->save(); $a->getBooks(); $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $b1->setTitle('The Hitchhikers Guide To The Galaxy'); $b1->setISBN('FA404-1'); $a->addBook($b1); @@ -158,24 +176,27 @@ public function testAddNewObjectAfterSaveWithPoisonedCache() $this->assertTrue($books->contains($b1), 'new related objects not deleted after fetching them'); } + /** + * @return void + */ public function testCachePoisoning() { /* Like testAddNewObjectAfterSaveWithPoisonedCache, emphasizing cache poisoning. */ $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + $a->setFirstName('Douglas'); + $a->setLastName('Adams'); $a->save(); $c = new Criteria(); - $c->add(BookTableMap::COL_TITLE, "%Restaurant%", Criteria::LIKE); + $c->add(BookTableMap::COL_TITLE, '%Restaurant%', Criteria::LIKE); $this->assertEquals(0, count($a->getBooks($c))); $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $b1->setTitle('The Hitchhikers Guide To The Galaxy'); $b1->setISBN('FA404-1'); $a->addBook($b1); @@ -188,21 +209,24 @@ public function testCachePoisoning() $this->assertEquals(0, count($a->getBooks($c))); } + /** + * @return void + */ public function testDeletedBookDisappears() { $this->markTestSkipped(); $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + $a->setFirstName('Douglas'); + $a->setLastName('Adams'); $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $b1->setTitle('The Hitchhikers Guide To The Galaxy'); $b1->setISBN('FA404-1'); $a->addBook($b1); $b2 = new Book(); - $b2->setTitle("The Restaurant At The End Of The Universe"); + $b2->setTitle('The Restaurant At The End Of The Universe'); $b1->setISBN('FA404-2'); $a->addBook($b2); @@ -221,6 +245,9 @@ public function testDeletedBookDisappears() $a's $colBooks field. */ } + /** + * @return void + */ public function testNewObjectsGetLostOnJoin() { /* While testNewObjectsAvailableWhenSaveNotCalled passed as of @@ -231,20 +258,20 @@ public function testNewObjectsGetLostOnJoin() $this->markTestSkipped(); $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + $a->setFirstName('Douglas'); + $a->setLastName('Adams'); $p = new Publisher(); $p->setName('Pan Books Ltd.'); $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $b1->setTitle('The Hitchhikers Guide To The Galaxy'); $b1->setISBN('FA404-1'); $b1->setPublisher($p); // uh... did not check that :^) $a->addBook($b1); $b2 = new Book(); - $b2->setTitle("The Restaurant At The End Of The Universe"); + $b2->setTitle('The Restaurant At The End Of The Universe'); $b1->setISBN('FA404-2'); $b2->setPublisher($p); $a->addBook($b2); From 2a79b12096c8c2b51fb6373d5d9db87885e4319f Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 30 Jul 2020 13:39:32 +0200 Subject: [PATCH 133/208] Run CS sniffer over tests. --- .../Tests/Common/Config/DataProviderTrait.php | 24 ++- .../Tests/Generator/Builder/NamespaceTest.php | 23 ++- .../Tests/Generator/Util/QuickBuilderTest.php | 2 +- .../ActiveQuery/CriteriaCombineTest.php | 3 + .../Runtime/Connection/PropelPDOTest.php | 161 +++++++++++------- tests/Propel/Tests/TestCase.php | 5 + 6 files changed, 141 insertions(+), 77 deletions(-) diff --git a/tests/Propel/Tests/Common/Config/DataProviderTrait.php b/tests/Propel/Tests/Common/Config/DataProviderTrait.php index adb4a6fa8f..1698e455ab 100644 --- a/tests/Propel/Tests/Common/Config/DataProviderTrait.php +++ b/tests/Propel/Tests/Common/Config/DataProviderTrait.php @@ -306,9 +306,7 @@ public function providerForXmlToArrayConverter() public function providerForXmlToArrayConverterXmlInclusions() { - return [ - [ - << -XML, << -XML, [ - 'table' => [ - 'name' => 'book', - 'phpName' => 'Book', - ]], +XML; + + return [ + [ + $xmlOne, + $xmlTwo, + [ + 'table' => [ + 'name' => 'book', + 'phpName' => 'Book', + ] + ], ], ]; } diff --git a/tests/Propel/Tests/Generator/Builder/NamespaceTest.php b/tests/Propel/Tests/Generator/Builder/NamespaceTest.php index 7b0dff1ef2..c123bd0766 100644 --- a/tests/Propel/Tests/Generator/Builder/NamespaceTest.php +++ b/tests/Propel/Tests/Generator/Builder/NamespaceTest.php @@ -10,7 +10,11 @@ namespace Propel\Tests\Generator\Builder; +use Baz\Map\NamespacedBookListRelTableMap; use Baz\Map\NamespacedPublisherTableMap; +use Baz\NamespacedBookClub; +use Baz\NamespacedBookClubQuery; +use Baz\NamespacedBookListRelQuery; use Baz\NamespacedPublisher; use Baz\NamespacedPublisherQuery; use Foo\Bar\Map\NamespacedAuthorTableMap; @@ -19,10 +23,13 @@ use Foo\Bar\NamespacedAuthorQuery; use Foo\Bar\NamespacedBook; use Foo\Bar\NamespacedBookQuery; +use Foo\Bar\NamespacedBookstoreCashier; +use Foo\Bar\NamespacedBookstoreEmployee; use Foo\Bar\NamespacedBookstoreEmployeeQuery; +use Foo\Bar\NamespacedBookstoreManager; +use Foo\Bar\NamespacedBookstoreManagerQuery; use Propel\Runtime\Propel; use Propel\Tests\TestCaseFixturesDatabase; -use Foo\Bar\NamespacedBookstoreEmployee; /** * Tests for Namespaces in generated classes class @@ -238,10 +245,10 @@ public function testSingleTableInheritance() $emp = new NamespacedBookstoreEmployee(); $emp->setName('Henry'); $emp->save(); - $man = new \Foo\Bar\NamespacedBookstoreManager(); + $man = new NamespacedBookstoreManager(); $man->setName('John'); $man->save(); - $cas = new \Foo\Bar\NamespacedBookstoreCashier(); + $cas = new NamespacedBookstoreCashier(); $cas->setName('William'); $cas->save(); $emps = NamespacedBookstoreEmployeeQuery::create() @@ -251,7 +258,7 @@ public function testSingleTableInheritance() $this->assertTrue($emps[0] instanceof NamespacedBookstoreEmployee); $this->assertTrue($emps[1] instanceof NamespacedBookstoreManager); $this->assertTrue($emps[2] instanceof NamespacedBookstoreCashier); - $nbMan = \Foo\Bar\NamespacedBookstoreManagerQuery::create() + $nbMan = NamespacedBookstoreManagerQuery::create() ->count(); $this->assertEquals(1, $nbMan); } @@ -262,8 +269,8 @@ public function testSingleTableInheritance() public function testManyToMany() { NamespacedBookQuery::create()->deleteAll(); - \Baz\NamespacedBookClubQuery::create()->deleteAll(); - \Baz\NamespacedBookListRelQuery::create()->deleteAll(); + NamespacedBookClubQuery::create()->deleteAll(); + NamespacedBookListRelQuery::create()->deleteAll(); $book1 = new NamespacedBook(); $book1->setTitle('bar'); $book1->setISBN('1234'); @@ -272,7 +279,7 @@ public function testManyToMany() $book2->setTitle('foo'); $book2->setISBN('4567'); $book2->save(); - $bookClub1 = new \Baz\NamespacedBookClub(); + $bookClub1 = new NamespacedBookClub(); $bookClub1->addNamespacedBook($book1); $bookClub1->addNamespacedBook($book2); $bookClub1->setGroupLeader('Someone1'); @@ -285,7 +292,7 @@ public function testManyToMany() $this->assertEquals(1, $book2->countNamespacedBookClubs()); $nbRels = NamespacedBookListRelQuery::create()->count(); $this->assertEquals(3, $nbRels); - $con = Propel::getServiceContainer()->getConnection(\Baz\Map\NamespacedBookListRelTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getConnection(NamespacedBookListRelTableMap::DATABASE_NAME); $books = NamespacedBookQuery::create() ->orderByTitle() ->joinWith('NamespacedBookListRel') diff --git a/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php b/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php index 542638175b..3a12790d1b 100644 --- a/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php +++ b/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php @@ -127,7 +127,7 @@ public function testBuildClasses($builder) $builder->buildClasses(); $foo = new QuickBuildFoo1(); $this->assertTrue($foo instanceof ActiveRecordInterface); - $this->assertTrue(QuickBuildFoo1TableMap::getTableMap() instanceof \MyNameSpace\Map\QuickBuildFoo1TableMap); + $this->assertTrue(QuickBuildFoo1TableMap::getTableMap() instanceof QuickBuildFoo1TableMap); } /** diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaCombineTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaCombineTest.php index a0e8cc2b60..fde83979e6 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaCombineTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaCombineTest.php @@ -52,6 +52,9 @@ protected function setUp(): void Propel::getServiceContainer()->setAdapter($defaultDatasource, new SqliteAdapter()); } + /** + * @return string + */ protected function getDriver() { return 'sqlite'; diff --git a/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php b/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php index 86ed68dd83..447d5931bc 100644 --- a/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php +++ b/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php @@ -10,23 +10,21 @@ namespace Propel\Tests\Runtime\Connection; -use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use Exception; +use Monolog\Handler\AbstractHandler; +use Monolog\Logger; +use PDO; +use PDOException; +use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Connection\Exception\RollbackException; +use Propel\Runtime\Connection\PropelPDO; +use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\AuthorQuery; use Propel\Tests\Bookstore\BookQuery; use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Map\BookTableMap; - -use Propel\Runtime\Propel; -use Propel\Runtime\Connection\Exception\RollbackException; -use Propel\Runtime\Connection\PropelPDO; -use Propel\Runtime\ActiveQuery\Criteria; -use Monolog\Logger; -use Monolog\Handler\AbstractHandler; - -use \PDO; -use \PDOException; -use \Exception; +use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; /** * Test for PropelPDO subclass. @@ -35,15 +33,24 @@ */ class PropelPDOTest extends BookstoreTestBase { + /** + * @return void + */ protected function setUp(): void { $this->con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); } + /** + * @return void + */ protected function tearDown(): void { } + /** + * @return void + */ public function testSetAttribute() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -55,6 +62,9 @@ public function testSetAttribute() $this->assertEquals(PDO::CASE_LOWER, $con->getAttribute(PDO::ATTR_CASE)); } + /** + * @return void + */ public function testCommitBeforeFetch() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -73,30 +83,36 @@ public function testCommitBeforeFetch() $i = 0; try { - $row = $stmt->fetch( PDO::FETCH_NUM ); + $row = $stmt->fetch(PDO::FETCH_NUM); $stmt->closeCursor(); $this->assertEquals($authorArr, $row, 'PDO driver supports calling $stmt->fetch after the transaction has been closed'); } catch (PDOException $e) { - $this->fail("PDO driver does not support calling \$stmt->fetch after the transaction has been closed.\nFails with error ".$e->getMessage()); + $this->fail("PDO driver does not support calling \$stmt->fetch after the transaction has been closed.\nFails with error " . $e->getMessage()); } } - public function testPdoSignature() - { - $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); - $stmt = $con->prepare('SELECT author.FIRST_NAME, author.LAST_NAME FROM author'); - $stmt->execute(); - $stmt->fetchAll(\PDO::FETCH_COLUMN, 0); // should not throw exception: Third parameter not allowed for PDO::FETCH_COLUMN + /** + * @return void + */ + public function testPdoSignature() + { + $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); + $stmt = $con->prepare('SELECT author.FIRST_NAME, author.LAST_NAME FROM author'); + $stmt->execute(); + $stmt->fetchAll(PDO::FETCH_COLUMN, 0); // should not throw exception: Third parameter not allowed for PDO::FETCH_COLUMN - $stmt = $con->prepare('SELECT author.FIRST_NAME, author.LAST_NAME FROM author'); - $stmt->execute(); - $stmt->fetchAll(\PDO::FETCH_ASSOC); // should not throw exception + $stmt = $con->prepare('SELECT author.FIRST_NAME, author.LAST_NAME FROM author'); + $stmt->execute(); + $stmt->fetchAll(PDO::FETCH_ASSOC); // should not throw exception - $stmt = $con->prepare('SELECT author.FIRST_NAME, author.LAST_NAME FROM author'); - $stmt->execute(); - $stmt->fetchAll(); // should not throw exception - } + $stmt = $con->prepare('SELECT author.FIRST_NAME, author.LAST_NAME FROM author'); + $stmt->execute(); + $stmt->fetchAll(); // should not throw exception + } + /** + * @return void + */ public function testCommitAfterFetch() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -113,12 +129,15 @@ public function testCommitAfterFetch() $authorArr = [0 => 'Test', 1 => 'User']; $i = 0; - $row = $stmt->fetch( PDO::FETCH_NUM ); + $row = $stmt->fetch(PDO::FETCH_NUM); $stmt->closeCursor(); $con->commit(); $this->assertEquals($authorArr, $row, 'PDO driver supports calling $stmt->fetch before the transaction has been closed'); } + /** + * @return void + */ public function testNestedTransactionCommit() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -133,13 +152,12 @@ public function testNestedTransactionCommit() $this->assertTrue($con->isInTransaction(), 'PropelPDO is in transaction after main transaction begin'); try { - $a = new Author(); $a->setFirstName('Test'); $a->setLastName('User'); $a->save($con); $authorId = $a->getId(); - $this->assertNotNull($authorId, "Expected valid new author ID"); + $this->assertNotNull($authorId, 'Expected valid new author ID'); $con->beginTransaction(); @@ -147,21 +165,20 @@ public function testNestedTransactionCommit() $this->assertTrue($con->isInTransaction(), 'PropelPDO is in transaction after nested transaction begin'); try { - $a2 = new Author(); $a2->setFirstName('Test2'); $a2->setLastName('User2'); $a2->save($con); $authorId2 = $a2->getId(); - $this->assertNotNull($authorId2, "Expected valid new author ID"); + $this->assertNotNull($authorId2, 'Expected valid new author ID'); $con->commit(); $this->assertEquals(1, $con->getNestedTransactionCount(), 'nested transaction decremented after nested transaction commit'); $this->assertTrue($con->isInTransaction(), 'PropelPDO is in transaction after main transaction commit'); - } catch (Exception $e) { $con->rollBack(); + throw $e; } @@ -169,21 +186,23 @@ public function testNestedTransactionCommit() $this->assertEquals(0, $con->getNestedTransactionCount(), 'nested transaction decremented after main transaction commit'); $this->assertFalse($con->isInTransaction(), 'PropelPDO is not in transaction after main transaction commit'); - } catch (Exception $e) { $con->rollBack(); + throw $e; } AuthorTableMap::clearInstancePool(); $at = AuthorQuery::create()->findPk($authorId); - $this->assertNotNull($at, "Committed transaction is persisted in database"); + $this->assertNotNull($at, 'Committed transaction is persisted in database'); $at2 = AuthorQuery::create()->findPk($authorId2); - $this->assertNotNull($at2, "Committed transaction is persisted in database"); + $this->assertNotNull($at2, 'Committed transaction is persisted in database'); } /** - * @link http://propel.phpdb.org/trac/ticket/699 + * @link http://propel.phpdb.org/trac/ticket/699 + * + * @return void */ public function testNestedTransactionRollBackRethrow() { @@ -192,14 +211,13 @@ public function testNestedTransactionRollBackRethrow() $con->beginTransaction(); try { - $a = new Author(); $a->setFirstName('Test'); $a->setLastName('User'); $a->save($con); $authorId = $a->getId(); - $this->assertNotNull($authorId, "Expected valid new author ID"); + $this->assertNotNull($authorId, 'Expected valid new author ID'); $con->beginTransaction(); @@ -208,7 +226,7 @@ public function testNestedTransactionRollBackRethrow() try { $con->exec('INVALID SQL'); - $this->fail("Expected exception on invalid SQL"); + $this->fail('Expected exception on invalid SQL'); } catch (PDOException $x) { $con->rollBack(); @@ -219,7 +237,7 @@ public function testNestedTransactionRollBackRethrow() } $con->commit(); - $this->fail("Commit should never been reached, because of invalid nested SQL!"); + $this->fail('Commit should never been reached, because of invalid nested SQL!'); } catch (Exception $x) { $con->rollBack(); // do not re-throw... we are already at the toplevel @@ -230,12 +248,15 @@ public function testNestedTransactionRollBackRethrow() AuthorTableMap::clearInstancePool(); $at = AuthorQuery::create()->findPk($authorId); - $this->assertNull($at, "Rolled back transaction is not persisted in database"); + $this->assertNull($at, 'Rolled back transaction is not persisted in database'); } /** * @link http://trac.propelorm.org/ticket/699 + * * @group mysql + * + * @return void */ public function testNestedTransactionRollBackSwallow() { @@ -244,27 +265,25 @@ public function testNestedTransactionRollBackSwallow() $con->beginTransaction(); try { - $a = new Author(); $a->setFirstName('Test'); $a->setLastName('User'); $a->save($con); $authorId = $a->getId(); - $this->assertNotNull($authorId, "Expected valid new author ID"); + $this->assertNotNull($authorId, 'Expected valid new author ID'); $con->beginTransaction(); try { - $a2 = new Author(); $a2->setFirstName('Test2'); $a2->setLastName('User2'); $a2->save($con); $authorId2 = $a2->getId(); - $this->assertNotNull($authorId2, "Expected valid new author ID"); + $this->assertNotNull($authorId2, 'Expected valid new author ID'); $con->exec('INVALID SQL'); - $this->fail("Expected exception on invalid SQL"); + $this->fail('Expected exception on invalid SQL'); } catch (PDOException $e) { $con->rollBack(); // NO RETHROW @@ -276,24 +295,27 @@ public function testNestedTransactionRollBackSwallow() $a3->save($con); $authorId3 = $a3->getId(); - $this->assertNotNull($authorId3, "Expected valid new author ID"); + $this->assertNotNull($authorId3, 'Expected valid new author ID'); $con->commit(); - $this->fail("Commit fails after a nested rollback"); + $this->fail('Commit fails after a nested rollback'); } catch (RollbackException $e) { - $this->assertTrue(true, "Commit fails after a nested rollback"); + $this->assertTrue(true, 'Commit fails after a nested rollback'); $con->rollback(); } AuthorTableMap::clearInstancePool(); $at = AuthorQuery::create()->findPk($authorId); - $this->assertNull($at, "Rolled back transaction is not persisted in database"); + $this->assertNull($at, 'Rolled back transaction is not persisted in database'); $at2 = AuthorQuery::create()->findPk($authorId2); - $this->assertNull($at2, "Rolled back transaction is not persisted in database"); + $this->assertNull($at2, 'Rolled back transaction is not persisted in database'); $at3 = AuthorQuery::create()->findPk($authorId3); - $this->assertNull($at3, "Rolled back nested transaction is not persisted in database"); + $this->assertNull($at3, 'Rolled back nested transaction is not persisted in database'); } + /** + * @return void + */ public function testNestedTransactionForceRollBack() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -325,11 +347,14 @@ public function testNestedTransactionForceRollBack() AuthorTableMap::clearInstancePool(); $at = AuthorQuery::create()->findPk($authorId); - $this->assertNull($at, "Rolled back transaction is not persisted in database"); + $this->assertNull($at, 'Rolled back transaction is not persisted in database'); $at2 = AuthorQuery::create()->findPk($authorId2); - $this->assertNull($at2, "Forced Rolled back nested transaction is not persisted in database"); + $this->assertNull($at2, 'Forced Rolled back nested transaction is not persisted in database'); } + /** + * @return void + */ public function testLatestQuery() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -337,16 +362,22 @@ public function testLatestQuery() $this->assertEquals(123, $con->getLastExecutedQuery(), 'PropelPDO has getter and setter for last executed query'); } + /** + * @return void + */ public function testLatestQueryMoreThanTenArgs() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); $c = new Criteria(); $c->add(BookTableMap::COL_ID, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], Criteria::IN); $books = BookQuery::create(null, $c)->find($con); - $expected = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.id IN (1,1,1,1,1,1,1,1,1,1,1,1)"); + $expected = $this->getSql('SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.id IN (1,1,1,1,1,1,1,1,1,1,1,1)'); $this->assertEquals($expected, $con->getLastExecutedQuery(), 'PropelPDO correctly replaces arguments in queries'); } + /** + * @return void + */ public function testQueryCount() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -355,6 +386,9 @@ public function testQueryCount() $this->assertEquals($count + 1, $con->getQueryCount(), 'PropelPDO has getter and incrementer for query count'); } + /** + * @return void + */ public function testUseDebug() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -368,6 +402,9 @@ public function testUseDebug() $this->assertEquals($expectedClass, $stmtClass[0], 'Statement is Propel Statement when debug is true'); } + /** + * @return void + */ public function testDebugLatestQuery() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -386,7 +423,7 @@ public function testDebugLatestQuery() $this->assertEquals($latestExecutedQuery, $con->getLastExecutedQuery(), 'PropelPDO updates the last executed query when useLogging is true'); BookTableMap::doDeleteAll($con); - $latestExecutedQuery = $this->getSql("DELETE FROM book"); + $latestExecutedQuery = $this->getSql('DELETE FROM book'); $this->assertEquals($latestExecutedQuery, $con->getLastExecutedQuery(), 'PropelPDO updates the last executed query on delete operations'); $sql = 'DELETE FROM book WHERE 1=1'; @@ -408,6 +445,9 @@ public function testDebugLatestQuery() $con->useDebug(true); } + /** + * @return void + */ public function testDebugQueryCount() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -446,6 +486,9 @@ public function testDebugQueryCount() $con->useDebug(true); } + /** + * @return void + */ public function testDebugLog() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); @@ -501,7 +544,7 @@ public function testDebugLog() $this->assertEquals($latestExecutedQuery, $handler->latestMessage, 'PropelPDO logs queries and populates bound parameters in debug mode'); BookTableMap::doDeleteAll($con); - $latestExecutedQuery = $this->getSql("DELETE FROM book"); + $latestExecutedQuery = $this->getSql('DELETE FROM book'); $this->assertEquals($latestExecutedQuery, $handler->latestMessage, 'PropelPDO logs deletion queries in debug mode'); $latestExecutedQuery = 'DELETE FROM book WHERE 1=1'; @@ -522,7 +565,7 @@ class LastMessageHandler extends AbstractHandler public function handle(array $record) { - $this->latestMessage = (string) $record['message']; + $this->latestMessage = (string)$record['message']; return false === $this->bubble; } diff --git a/tests/Propel/Tests/TestCase.php b/tests/Propel/Tests/TestCase.php index adc69aa66d..3a859c0a54 100644 --- a/tests/Propel/Tests/TestCase.php +++ b/tests/Propel/Tests/TestCase.php @@ -14,6 +14,9 @@ class TestCase extends PHPUnitTestCase { + /** + * @return string + */ protected function getDriver() { return 'sqlite'; @@ -111,6 +114,8 @@ protected function getPlatform() } /** + * @param \Propel\Runtime\Connection\ConnectionInterface $con + * * @return \Propel\Generator\Reverse\SchemaParserInterface */ protected function getParser($con) From a5d0e52586f33a8bb8785f7d1844ac869b2c7ea0 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 30 Jul 2020 13:54:43 +0200 Subject: [PATCH 134/208] Run CS sniffer over tests. --- .../Propel/Tests/Common/Config/DataProviderTrait.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/Propel/Tests/Common/Config/DataProviderTrait.php b/tests/Propel/Tests/Common/Config/DataProviderTrait.php index 1698e455ab..9fa0fd9528 100644 --- a/tests/Propel/Tests/Common/Config/DataProviderTrait.php +++ b/tests/Propel/Tests/Common/Config/DataProviderTrait.php @@ -15,6 +15,9 @@ */ trait DataProviderTrait { + /** + * @return string[][] + */ public function providerForInvalidConnections() { return [ @@ -109,6 +112,9 @@ classname: Propel\Runtime\Connection\DebugPDO ]; } + /** + * @return string[][] + */ public function providerForInvalidDefaultConnection() { return [ @@ -169,6 +175,9 @@ classname: Propel\Runtime\Connection\DebugPDO ]; } + /** + * @return array + */ public function providerForXmlToArrayConverter() { return [ @@ -304,6 +313,9 @@ public function providerForXmlToArrayConverter() ]; } + /** + * @return array + */ public function providerForXmlToArrayConverterXmlInclusions() { $xmlOne = << Date: Thu, 30 Jul 2020 15:59:11 +0200 Subject: [PATCH 135/208] Fix use statement. --- .../NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php index 720b983226..27bdc1f31a 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php @@ -11,7 +11,6 @@ namespace Propel\Tests\Generator\Behavior\NestedSet; use Exception; -use Fixtures\PublicTable9; use Map\NestedSetTable9TableMap; use NestedSetTable10; use NestedSetTable9; @@ -21,6 +20,7 @@ use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Propel; +use Propel\Tests\Generator\Behavior\NestedSet\Fixtures\PublicTable9; /** * Tests for NestedSetBehaviorObjectBuilderModifier class From 0f2f9f9f28e871a58ae36ffd5993d94735b6ccf0 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 30 Jul 2020 19:02:00 +0200 Subject: [PATCH 136/208] Fix use statement. --- .../NestedSetBehaviorObjectBuilderModifierWithScopeTest.php | 2 +- tests/Propel/Tests/Generator/Behavior/NestedSet/TestCase.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php index 6d50f1f9d5..091738cd49 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php @@ -10,10 +10,10 @@ namespace Propel\Tests\Generator\Behavior\NestedSet; -use Fixtures\PublicTable10; use Map\NestedSetTable10TableMap; use NestedSetTable10; use NestedSetTable10Query; +use Propel\Tests\Generator\Behavior\NestedSet\Fixtures\PublicTable10; /** * Tests for NestedSetBehaviorObjectBuilderModifier class diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/TestCase.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/TestCase.php index ca86683640..b5172a05a1 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/TestCase.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/TestCase.php @@ -10,13 +10,13 @@ namespace Propel\Tests\Generator\Behavior\NestedSet; -use Fixtures\PublicTable10; -use Fixtures\PublicTable9; use Map\NestedSetTable10TableMap; use Map\NestedSetTable9TableMap; use NestedSetTable10Query; use NestedSetTable9Query; use Propel\Generator\Util\QuickBuilder; +use Propel\Tests\Generator\Behavior\NestedSet\Fixtures\PublicTable10; +use Propel\Tests\Generator\Behavior\NestedSet\Fixtures\PublicTable9; use Propel\Tests\TestCase as BaseTestCase; /** From 4eaff6fdd96e913d012175086c76806c11c91629 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 30 Jul 2020 19:45:50 +0200 Subject: [PATCH 137/208] Fix FQCN statement. --- tests/Propel/Tests/Runtime/PropelTest.php | 3 ++- tests/Propel/Tests/Runtime/TypeTest.php | 17 +++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/Propel/Tests/Runtime/PropelTest.php b/tests/Propel/Tests/Runtime/PropelTest.php index 42d27c0e0f..bdf2947d04 100644 --- a/tests/Propel/Tests/Runtime/PropelTest.php +++ b/tests/Propel/Tests/Runtime/PropelTest.php @@ -11,6 +11,7 @@ namespace Propel\Tests\Runtime; use Propel\Runtime\Propel; +use Propel\Runtime\ServiceContainer\ServiceContainerInterface; use Propel\Runtime\ServiceContainer\StandardServiceContainer; use Propel\Tests\Helpers\BaseTestCase; @@ -21,7 +22,7 @@ class PropelTest extends BaseTestCase */ public function testGetServiceContainerReturnsAServiceContainer() { - $this->assertInstanceOf('\Propel\Runtime\ServiceContainer\ServiceContainerInterface', Propel::getServiceContainer()); + $this->assertInstanceOf(ServiceContainerInterface::class, Propel::getServiceContainer()); } /** diff --git a/tests/Propel/Tests/Runtime/TypeTest.php b/tests/Propel/Tests/Runtime/TypeTest.php index 358159f4cf..6888d0b0db 100644 --- a/tests/Propel/Tests/Runtime/TypeTest.php +++ b/tests/Propel/Tests/Runtime/TypeTest.php @@ -14,8 +14,9 @@ use Propel\Tests\Bookstore\TypeObject; use Propel\Tests\Bookstore\TypeObjectQuery; use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use Propel\Tests\Runtime\TypeTests\TypeObjectInterface; use ReflectionClass; -use TypeTests\DummyObjectClass; +use Propel\Tests\Runtime\TypeTests\DummyObjectClass; /** * @group database @@ -27,11 +28,11 @@ class TypeTest extends BookstoreTestBase */ public function testTypeHintClass() { - $reflection = new ReflectionClass('Propel\Tests\Bookstore\TypeObject'); + $reflection = new ReflectionClass(TypeObject::class); $method = $reflection->getMethod('setDummyObject'); $param = $method->getParameters()[0]; - $this->assertEquals('Propel\Tests\Runtime\TypeTests\DummyObjectClass', $param->getClass()->name); + $this->assertEquals(DummyObjectClass::class, $param->getClass()->name); $this->assertTrue($param->allowsNull()); } @@ -40,7 +41,7 @@ public function testTypeHintClass() */ public function testTypeHintArray() { - $reflection = new ReflectionClass('Propel\Tests\Bookstore\TypeObject'); + $reflection = new ReflectionClass(TypeObject::class); $method = $reflection->getMethod('setSomeArray'); $param = $method->getParameters()[0]; @@ -53,11 +54,11 @@ public function testTypeHintArray() */ public function testInterface() { - $reflection = new ReflectionClass('Propel\Tests\Bookstore\TypeObject'); + $reflection = new ReflectionClass(TypeObject::class); $method = $reflection->getMethod('setTypeObject'); $param = $method->getParameters()[0]; - $this->assertEquals('Propel\Tests\Runtime\TypeTests\TypeObjectInterface', $param->getClass()->name); + $this->assertEquals(TypeObjectInterface::class, $param->getClass()->name); $this->assertTrue($param->allowsNull()); } @@ -87,7 +88,7 @@ public function testObjectType() $this->assertEquals($c, $typeObjectEntity->getDetails()->getPropPrivate()); $typeObjectEntity->save(); - + $typeObjectEntity->setDetails($objectInstance); $this->assertFalse($typeObjectEntity->isModified('details')); @@ -96,7 +97,7 @@ public function testObjectType() $typeObjectEntity->setDetails($clone); $this->assertTrue($typeObjectEntity->isModified('details')); - + TypeObjectTableMap::clearInstancePool(); $typeObjectEntity = TypeObjectQuery::create()->findOne(); From 85de55da1323723be38da223cd610e4d8e78adf4 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 30 Jul 2020 19:57:45 +0200 Subject: [PATCH 138/208] Fix XML heredoc --- .../Tests/Common/Config/DataProviderTrait.php | 168 ++++++++++-------- 1 file changed, 92 insertions(+), 76 deletions(-) diff --git a/tests/Propel/Tests/Common/Config/DataProviderTrait.php b/tests/Propel/Tests/Common/Config/DataProviderTrait.php index 9fa0fd9528..039fd7124d 100644 --- a/tests/Propel/Tests/Common/Config/DataProviderTrait.php +++ b/tests/Propel/Tests/Common/Config/DataProviderTrait.php @@ -180,8 +180,7 @@ classname: Propel\Runtime\Connection\DebugPDO */ public function providerForXmlToArrayConverter() { - return [ - [<<< XML + $moviesXml = << @@ -193,9 +192,9 @@ public function providerForXmlToArrayConverter() false -XML, ['movie' => [0 => ['title' => 'Star Wars', 'starred' => true], 1 => ['title' => 'The Lord Of The Rings', 'starred' => false]]], - ], - [<<< XML +EOF; + + $loggerXml = << @@ -210,24 +209,9 @@ public function providerForXmlToArrayConverter() -XML, [ - 'log' => [ - 'logger' => [ - [ - 'type' => 'stream', - 'path' => '/var/log/propel.log', - 'level' => '300', - 'name' => 'defaultLogger', - ], - [ - 'type' => 'stream', - 'path' => '/var/log/propel_bookstore.log', - 'name' => 'bookstore', - ], - ], - ]], - ], - [<< @@ -247,22 +231,8 @@ public function providerForXmlToArrayConverter() -EOF, [ - 'datasources' => [ - 'bookstore' => [ - 'adapter' => 'mysql', - 'connection' => ['dsn' => 'mysql:host=localhost;dbname=bookstore'], - 'slaves' => [ - 'connection' => [ - ['dsn' => 'mysql:host=slave-server1; dbname=bookstore'], - ['dsn' => 'mysql:host=slave-server2; dbname=bookstore'], - ], - ], - ], - 'default' => 'bookstore', - ]], - ], - [<< @@ -274,41 +244,86 @@ public function providerForXmlToArrayConverter() -EOF, [ - 'datasources' => [ - 'bookstore' => [ - 'adapter' => 'mysql', - 'connection' => [ - 'dsn' => 'mysql:host=localhost;dbname=bookstore', - ], - ], - 'default' => 'bookstore', - ]], - ], - [<< 0.2
-
: |
-
-EOF, [ - 'profiler' => [ - 'class' => '\Runtime\Runtime\Util\Profiler', - 'slowTreshold' => 0.2, - 'details' => [ - 'time' => ['name' => 'Time', 'precision' => 3, 'pad' => '8'], - 'mem' => ['name' => 'Memory', 'precision' => 3, 'pad' => '8'], - ], - 'innerGlue' => ': ', - 'outerGlue' => ' | ', - ]], + +EOF; + + return [ + [ + $moviesXml, + ['movie' => [0 => ['title' => 'Star Wars', 'starred' => true], 1 => ['title' => 'The Lord Of The Rings', 'starred' => false]]], + ], + [ + $loggerXml, [ + 'log' => [ + 'logger' => [ + [ + 'type' => 'stream', + 'path' => '/var/log/propel.log', + 'level' => '300', + 'name' => 'defaultLogger', + ], + [ + 'type' => 'stream', + 'path' => '/var/log/propel_bookstore.log', + 'name' => 'bookstore', + ], + ], + ]], + ], + [ + $bookstoreXml, [ + 'datasources' => [ + 'bookstore' => [ + 'adapter' => 'mysql', + 'connection' => ['dsn' => 'mysql:host=localhost;dbname=bookstore'], + 'slaves' => [ + 'connection' => [ + ['dsn' => 'mysql:host=slave-server1; dbname=bookstore'], + ['dsn' => 'mysql:host=slave-server2; dbname=bookstore'], + ], + ], + ], + 'default' => 'bookstore', + ]], + ], + [ + $bookstore2Xml, [ + 'datasources' => [ + 'bookstore' => [ + 'adapter' => 'mysql', + 'connection' => [ + 'dsn' => 'mysql:host=localhost;dbname=bookstore', + ], + ], + 'default' => 'bookstore', + ]], + ], + [ + $profilerXml, [ + 'profiler' => [ + 'class' => '\Runtime\Runtime\Util\Profiler', + 'slowTreshold' => 0.2, + 'details' => [ + 'time' => ['name' => 'Time', 'precision' => 3, 'pad' => '8'], + 'mem' => ['name' => 'Memory', 'precision' => 3, 'pad' => '8'], + ], + 'innerGlue' => ': ', + 'outerGlue' => ' | ', + ]], ], ]; } @@ -318,32 +333,33 @@ public function providerForXmlToArrayConverter() */ public function providerForXmlToArrayConverterXmlInclusions() { - $xmlOne = << + /> -XML; - $xmlTwo = <<
-XML; +EOF; + $array = [ + 'table' => [ + 'name' => 'book', + 'phpName' => 'Book', + ] + ]; return [ [ $xmlOne, $xmlTwo, - [ - 'table' => [ - 'name' => 'book', - 'phpName' => 'Book', - ] - ], + $array, ], ]; } From e674526231bb9ce10ac903505e6e06fe9c2ec50f Mon Sep 17 00:00:00 2001 From: mscherer Date: Mon, 3 Aug 2020 18:38:46 +0200 Subject: [PATCH 139/208] Move non autoloadable into Fixtures dir and add conv. const for easier test writing --- .../generator/builder}/barSchema.xml | 0 .../generator/builder}/fooSchema.xml | 0 .../generator/builder}/innerSchema.xml | 0 .../generator/builder}/outerSchema.xml | 2 +- .../generator/builder}/template.php | 0 .../generator/builder}/testSchema.xml | 0 .../Generator/Builder/Util/PropelTemplateTest.php | 2 +- .../Builder/Util/SchemaReaderJoinSchemaTest.php | 15 ++++++++++----- .../Generator/Builder/Util/SchemaReaderTest.php | 7 ++++++- tests/bootstrap.php | 5 ++++- 10 files changed, 22 insertions(+), 9 deletions(-) rename tests/{Propel/Tests/Generator/Builder/Util => Fixtures/generator/builder}/barSchema.xml (100%) rename tests/{Propel/Tests/Generator/Builder/Util => Fixtures/generator/builder}/fooSchema.xml (100%) rename tests/{Propel/Tests/Generator/Builder/Util => Fixtures/generator/builder}/innerSchema.xml (100%) rename tests/{Propel/Tests/Generator/Builder/Util => Fixtures/generator/builder}/outerSchema.xml (80%) rename tests/{Propel/Tests/Generator/Builder/Util => Fixtures/generator/builder}/template.php (100%) rename tests/{Propel/Tests/Generator/Builder/Util => Fixtures/generator/builder}/testSchema.xml (100%) diff --git a/tests/Propel/Tests/Generator/Builder/Util/barSchema.xml b/tests/Fixtures/generator/builder/barSchema.xml similarity index 100% rename from tests/Propel/Tests/Generator/Builder/Util/barSchema.xml rename to tests/Fixtures/generator/builder/barSchema.xml diff --git a/tests/Propel/Tests/Generator/Builder/Util/fooSchema.xml b/tests/Fixtures/generator/builder/fooSchema.xml similarity index 100% rename from tests/Propel/Tests/Generator/Builder/Util/fooSchema.xml rename to tests/Fixtures/generator/builder/fooSchema.xml diff --git a/tests/Propel/Tests/Generator/Builder/Util/innerSchema.xml b/tests/Fixtures/generator/builder/innerSchema.xml similarity index 100% rename from tests/Propel/Tests/Generator/Builder/Util/innerSchema.xml rename to tests/Fixtures/generator/builder/innerSchema.xml diff --git a/tests/Propel/Tests/Generator/Builder/Util/outerSchema.xml b/tests/Fixtures/generator/builder/outerSchema.xml similarity index 80% rename from tests/Propel/Tests/Generator/Builder/Util/outerSchema.xml rename to tests/Fixtures/generator/builder/outerSchema.xml index ec492d5281..166e4253ad 100644 --- a/tests/Propel/Tests/Generator/Builder/Util/outerSchema.xml +++ b/tests/Fixtures/generator/builder/outerSchema.xml @@ -3,5 +3,5 @@
- +
diff --git a/tests/Propel/Tests/Generator/Builder/Util/template.php b/tests/Fixtures/generator/builder/template.php similarity index 100% rename from tests/Propel/Tests/Generator/Builder/Util/template.php rename to tests/Fixtures/generator/builder/template.php diff --git a/tests/Propel/Tests/Generator/Builder/Util/testSchema.xml b/tests/Fixtures/generator/builder/testSchema.xml similarity index 100% rename from tests/Propel/Tests/Generator/Builder/Util/testSchema.xml rename to tests/Fixtures/generator/builder/testSchema.xml diff --git a/tests/Propel/Tests/Generator/Builder/Util/PropelTemplateTest.php b/tests/Propel/Tests/Generator/Builder/Util/PropelTemplateTest.php index 62d36891a9..d5d8f3f53b 100644 --- a/tests/Propel/Tests/Generator/Builder/Util/PropelTemplateTest.php +++ b/tests/Propel/Tests/Generator/Builder/Util/PropelTemplateTest.php @@ -58,7 +58,7 @@ public function testRenderStringParams() public function testRenderFile() { $t = new PropelTemplate(); - $t->setTemplateFile(dirname(__FILE__) . '/template.php'); + $t->setTemplateFile(FIXTURES . 'generator' . DS . 'builder' . DS . 'template.php'); $res = $t->render(['name' => 'John']); $this->assertEquals('Hello, John', $res); } diff --git a/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderJoinSchemaTest.php b/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderJoinSchemaTest.php index 0ce83eea3d..ab87b8255e 100644 --- a/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderJoinSchemaTest.php +++ b/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderJoinSchemaTest.php @@ -38,19 +38,24 @@ public function testJoinXmlSchemaWithMultipleDatabaseSchema() EOF; - + $fooReader = new SchemaReader(new PgsqlPlatform()); $barReader = new SchemaReader(new PgsqlPlatform()); - + $fooSchema = $fooReader->parseFile($this->getSchemaFile('fooSchema.xml')); $barSchema = $barReader->parseFile($this->getSchemaFile('barSchema.xml')); $fooSchema->joinSchemas([$barSchema]); - + $this->assertEquals($expectedSchema, $fooSchema->toString()); } - + + /** + * @param string $filename + * + * @return string + */ protected function getSchemaFile($filename) { - return realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . $filename); + return realpath(FIXTURES . 'generator' . DS . 'builder' . DS . $filename); } } diff --git a/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php b/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php index 571672ae26..87d664ec3f 100644 --- a/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php @@ -166,8 +166,13 @@ protected function tearDown(): void $this->reader = null; } + /** + * @param string $filename + * + * @return string + */ protected function getSchemaFile($filename) { - return realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . $filename); + return realpath(FIXTURES . 'generator' . DS . 'builder' . DS . $filename); } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index bfc7390b49..faf9e67366 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,12 +2,15 @@ require_once __DIR__.'/../autoload.php.dist'; -// check if user is root and +// check if user is root and if (function_exists("posix_getuid")) { if (posix_getuid() == 0) die("You must run tests suite with an unprivileged user."); } +define('DS', DIRECTORY_SEPARATOR); +define('FIXTURES', __DIR__ . DS . 'Fixtures' . DS); + echo sprintf("Tests started in temp %s.\n", sys_get_temp_dir()); /** * fix var_export behavior with floating number precision since PHP 5.4.22 From e7526801014a2d0165ddebf0ffdf5ae4a2dcf45c Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 4 Aug 2020 11:01:03 +0200 Subject: [PATCH 140/208] Fix more CS. --- config/phpcs.xml | 4 - resources/dtd/database.dtd | 1 - .../Generator/Builder/Util/SchemaReader.php | 15 +- .../Command/Console/Input/ArrayInput.php | 2 +- src/Propel/Generator/Util/BehaviorLocator.php | 2 + src/Propel/Runtime/ActiveQuery/Criteria.php | 30 +- .../Runtime/ActiveQuery/ModelCriteria.php | 8 +- src/Propel/Runtime/ActiveQuery/ModelJoin.php | 4 +- tests/Propel/Tests/CharacterEncodingTest.php | 7 - .../Tests/Common/Config/ConfigTestCase.php | 6 +- .../Config/ConfigurationManagerTest.php | 13 +- .../Tests/Common/Config/DataProviderTrait.php | 2 +- .../Common/Config/Loader/FileLoaderTest.php | 8 +- .../Config/Loader/IniFileLoaderTest.php | 4 +- .../Config/Loader/JsonFileLoaderTest.php | 4 +- .../Config/Loader/PhpFileLoaderTest.php | 6 +- .../Config/Loader/XmlFileLoaderTest.php | 4 +- .../Config/Loader/YamlFileLoaderTest.php | 4 +- .../Archivable/ArchivableBehaviorTest.php | 7 +- ...creteInheritanceBehaviorWithSchemaTest.php | 3 +- .../ConcreteInheritanceParentBehaviorTest.php | 3 +- .../I18nBehaviorObjectBuilderModifierTest.php | 237 ++++--- .../I18nBehaviorQueryBuilderModifierTest.php | 2 +- ...aviorQueryBuilderModifierWithScopeTest.php | 29 +- .../Behavior/QueryCache/QueryCacheTest.php | 2 +- .../Sluggable/SluggableBehaviorTest.php | 9 + ...viorObjectBuilderModifierWithScopeTest.php | 2 +- .../Validate/ValidateBehaviorTest.php | 10 +- ...nableBehaviorObjectBuilderModifierTest.php | 402 ++++++++---- .../Tests/Generator/Builder/NamespaceTest.php | 6 + .../Om/AbstractOMBuilderNamespaceTest.php | 1 - .../Om/AbstractOMBuilderRelatedByTest.php | 1 - .../Builder/Om/AbstractOMBuilderTest.php | 1 - .../GeneratedObjectBooleanColumnTypeTest.php | 6 + .../Builder/Om/GeneratedObjectLobTest.php | 7 +- ...GeneratedObjectM2MRelationThreePKsTest.php | 585 ++++++++++-------- .../Om/GeneratedObjectMoreRelationTest.php | 2 +- ...eratedObjectWithDateImmutableClassTest.php | 17 +- .../Om/GeneratedObjectWithInterfaceTest.php | 2 + .../Generator/Builder/Om/QueryBuilderTest.php | 10 +- .../Builder/Om/QueryBuilderTestClasses.php | 8 +- .../Generator/Command/InitCommandTest.php | 5 + .../Generator/Config/GeneratorConfigTest.php | 16 +- .../Config/QuickGeneratorConfigTest.php | 2 +- .../Generator/Migration/MigrationTestCase.php | 1 + .../Tests/Generator/Model/BehaviorTest.php | 15 +- .../Model/ColumnDefaultValueTest.php | 2 + .../Generator/Model/ConstantNameTest.php | 2 + .../Model/Diff/ColumnComparatorTest.php | 5 +- .../Diff/DatabaseTableComparatorTest.php | 4 +- .../Model/Diff/ForeignKeyComparatorTest.php | 7 +- .../Model/Diff/IndexComparatorTest.php | 5 +- .../Diff/PropelTableColumnComparatorTest.php | 5 +- .../PropelTableForeignKeyComparatorTest.php | 5 +- .../Diff/PropelTableIndexComparatorTest.php | 5 +- .../PropelTablePkColumnComparatorTest.php | 5 +- .../Tests/Generator/Model/ModelTestCase.php | 18 +- .../Tests/Generator/Model/NameFactoryTest.php | 16 +- .../Generator/Model/PhpNameGeneratorTest.php | 2 + .../Tests/Generator/Model/UniqueTest.php | 7 + .../Platform/DefaultPlatformTest.php | 4 +- .../MysqlPlatformMigrationMyISAMTest.php | 2 +- .../Platform/MysqlPlatformMigrationTest.php | 5 +- .../MysqlPlatformMigrationTestProvider.php | 3 + .../Platform/OraclePlatformMigrationTest.php | 2 +- .../Generator/Platform/OraclePlatformTest.php | 2 +- .../Platform/PgsqlPlatformMigrationTest.php | 2 +- .../PlatformMigrationTestProvider.php | 3 + .../Platform/PlatformTestProvider.php | 3 + .../Generator/Platform/SqlitePlatformTest.php | 2 +- .../Generator/Schema/Dumper/XmlDumperTest.php | 5 + .../Propel/Tests/Helpers/MultipleBehavior.php | 3 + tests/Propel/Tests/Issues/Issue1133Test.php | 12 + .../ActiveQuery/CriteriaCombineTest.php | 2 +- .../CriteriaFluidConditionTest.php | 1 - .../Criterion/BasicCriterionTest.php | 2 +- .../Criterion/BasicModelCriterionTest.php | 2 +- .../Criterion/LikeModelCriterionTest.php | 2 +- .../Criterion/RawCriterionTest.php | 2 +- .../Criterion/RawModelCriterionTest.php | 2 +- .../Criterion/SeveralModelCriterionTest.php | 4 +- .../Runtime/ActiveQuery/ModelCriteriaTest.php | 2 +- .../Runtime/Adapter/Pdo/MssqlAdapterTest.php | 12 +- .../Runtime/Adapter/Pdo/MysqlAdapterTest.php | 14 +- .../Collection/CollectionConvertTest.php | 1 - .../Runtime/Exception/PropelExceptionTest.php | 2 + .../StandardServiceContainerTest.php | 6 +- tests/Propel/Tests/Runtime/TypeTest.php | 3 +- .../Util/PropelConditionalProxyTest.php | 1 - .../Propel/Tests/TestCaseFixturesDatabase.php | 3 + 90 files changed, 1068 insertions(+), 644 deletions(-) diff --git a/config/phpcs.xml b/config/phpcs.xml index 771659aa31..492d13a5d3 100644 --- a/config/phpcs.xml +++ b/config/phpcs.xml @@ -30,8 +30,4 @@ 0 - - 0 - - diff --git a/resources/dtd/database.dtd b/resources/dtd/database.dtd index 684ec39d5e..ae83f9169a 100644 --- a/resources/dtd/database.dtd +++ b/resources/dtd/database.dtd @@ -1,6 +1,5 @@ - + - +
- +
- +
- +
- +
- +
- - - + + +
diff --git a/tests/Fixtures/bookstore/behavior-aggregate-schema.xml b/tests/Fixtures/bookstore/behavior-aggregate-schema.xml index b039190960..08af39e1a3 100644 --- a/tests/Fixtures/bookstore/behavior-aggregate-schema.xml +++ b/tests/Fixtures/bookstore/behavior-aggregate-schema.xml @@ -2,44 +2,44 @@ - + - - - + + +
- - + + - +
- + - - - + + + - - - + + +
- - - + + + - +
diff --git a/tests/Fixtures/bookstore/behavior-auto-add-pk-schema.xml b/tests/Fixtures/bookstore/behavior-auto-add-pk-schema.xml index c6cab1b1ef..883188b2ba 100644 --- a/tests/Fixtures/bookstore/behavior-auto-add-pk-schema.xml +++ b/tests/Fixtures/bookstore/behavior-auto-add-pk-schema.xml @@ -2,26 +2,26 @@ - - + +
- - - + + +
- + - + - - - + + +
diff --git a/tests/Fixtures/bookstore/behavior-concrete-inheritance-schema.xml b/tests/Fixtures/bookstore/behavior-concrete-inheritance-schema.xml index 9bbfc2557f..fdc287cb5d 100644 --- a/tests/Fixtures/bookstore/behavior-concrete-inheritance-schema.xml +++ b/tests/Fixtures/bookstore/behavior-concrete-inheritance-schema.xml @@ -2,63 +2,63 @@ - - + +
- - - + + + - + - +
- - + + - + - +
- - + +
- +
- + - - + +
- - - - - - + + + + + + - +
diff --git a/tests/Fixtures/bookstore/behavior-query_cache-schema.xml b/tests/Fixtures/bookstore/behavior-query_cache-schema.xml index 9ac53b9231..32c99dcb63 100644 --- a/tests/Fixtures/bookstore/behavior-query_cache-schema.xml +++ b/tests/Fixtures/bookstore/behavior-query_cache-schema.xml @@ -2,11 +2,11 @@ - - + + - +
diff --git a/tests/Fixtures/bookstore/behavior-schema.xml b/tests/Fixtures/bookstore/behavior-schema.xml index a083df062b..594c7099be 100644 --- a/tests/Fixtures/bookstore/behavior-schema.xml +++ b/tests/Fixtures/bookstore/behavior-schema.xml @@ -2,13 +2,13 @@ - + - - - + + +
diff --git a/tests/Fixtures/bookstore/behavior-sluggable-schema.xml b/tests/Fixtures/bookstore/behavior-sluggable-schema.xml index dea18f144f..ff2d88c09d 100644 --- a/tests/Fixtures/bookstore/behavior-sluggable-schema.xml +++ b/tests/Fixtures/bookstore/behavior-sluggable-schema.xml @@ -2,30 +2,30 @@ - - - + + +
- - + + - - - - - + + + + +
- - - + + + - +
diff --git a/tests/Fixtures/bookstore/behavior-sortable-schema.xml b/tests/Fixtures/bookstore/behavior-sortable-schema.xml index bfe4afe344..52fe40f8b9 100644 --- a/tests/Fixtures/bookstore/behavior-sortable-schema.xml +++ b/tests/Fixtures/bookstore/behavior-sortable-schema.xml @@ -2,70 +2,70 @@ - - + + - +
- - - + + + - - - + + +
- - - + + + - - + +
- - - + + + - - + +
- - - - - + + + + + - - - - + + + +
- - - - - + + + + + - - - + + +
diff --git a/tests/Fixtures/bookstore/behavior-timestampable-schema.xml b/tests/Fixtures/bookstore/behavior-timestampable-schema.xml index 3ef43b7120..0859f889ef 100644 --- a/tests/Fixtures/bookstore/behavior-timestampable-schema.xml +++ b/tests/Fixtures/bookstore/behavior-timestampable-schema.xml @@ -2,20 +2,20 @@ - - - - + + + + - - + +
- - - + + +
diff --git a/tests/Fixtures/bookstore/behavior-validate-schema.xml b/tests/Fixtures/bookstore/behavior-validate-schema.xml index 51be0e52b3..9bf030c19d 100644 --- a/tests/Fixtures/bookstore/behavior-validate-schema.xml +++ b/tests/Fixtures/bookstore/behavior-validate-schema.xml @@ -2,65 +2,65 @@ - - - - - - + + + + + + - + - + - - - + + +
- - - + + + - - - + + +
- - - - - + + + + + - - - - - - + + + + + +
- - - - - + + + + + - - - - - - + + + + + +
@@ -74,10 +74,10 @@ - - - - + + + + diff --git a/tests/Fixtures/bookstore/behavior-validate-triggers-schema.xml b/tests/Fixtures/bookstore/behavior-validate-triggers-schema.xml index 438f63d602..5213d5f0e4 100644 --- a/tests/Fixtures/bookstore/behavior-validate-triggers-schema.xml +++ b/tests/Fixtures/bookstore/behavior-validate-triggers-schema.xml @@ -2,36 +2,36 @@ - - - - - - + + + + + + - - + + - +
- +
- + - - + +
diff --git a/tests/Fixtures/bookstore/schema.xml b/tests/Fixtures/bookstore/schema.xml index c441770391..282252bab6 100644 --- a/tests/Fixtures/bookstore/schema.xml +++ b/tests/Fixtures/bookstore/schema.xml @@ -4,86 +4,86 @@ namespace="Propel\Tests\Bookstore"> - - - - - - + + + + + + - + - +
- - + +
- - - - - + + + + +
- - - + + + - +
- - - - - - + + + + + + - +
- - - - - - + + + + + + - + - + - +
- - - - + + + + - + - +
@@ -106,139 +106,139 @@ - - - - + + + + - +
- - - - + + + +
- - + + - + - +
- - + + - + - +
- + - - - + + + - - - - + + + + - +
- - - - - - - - + + + + + + + + - + - + - +
- - - + + + - + - - + + - - + +
- - + +
- - + +
- - - - + + + + - + - +
- - + + - + - + @@ -250,156 +250,156 @@
- - - - - - + + + + + +
- - - - - + + + + + - + - +
- - - + + +
- - - + + + - +
- - - - + + + + - +
- - + +
- - - + + + - + - + - +
- - - - + + + + - + - + - - + +
- - - - - + + + + +
- - + + - - - + + + - +
- - + +
- + - +
- + - + - - + +
- - - + + + - - + + - - + +
diff --git a/tests/Fixtures/bookstore/types-schema.xml b/tests/Fixtures/bookstore/types-schema.xml index 4626dba7c4..aff4b0a9e6 100644 --- a/tests/Fixtures/bookstore/types-schema.xml +++ b/tests/Fixtures/bookstore/types-schema.xml @@ -2,15 +2,15 @@ - + - - + + - +
diff --git a/tests/Fixtures/etc/xsl/coverage-frames.xsl b/tests/Fixtures/etc/xsl/coverage-frames.xsl index a6d5af1ca6..ea7cec45f5 100644 --- a/tests/Fixtures/etc/xsl/coverage-frames.xsl +++ b/tests/Fixtures/etc/xsl/coverage-frames.xsl @@ -3,7 +3,7 @@ xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="exsl date"> - + - + diff --git a/tests/Fixtures/etc/xsl/phpunit-noframes.xsl b/tests/Fixtures/etc/xsl/phpunit-noframes.xsl index 76fa46029d..7392d4fa23 100644 --- a/tests/Fixtures/etc/xsl/phpunit-noframes.xsl +++ b/tests/Fixtures/etc/xsl/phpunit-noframes.xsl @@ -5,8 +5,8 @@ extension-element-prefixes="exsl str date"> - + doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/> + - + - + - + - + - - + + - + - - + + - + @@ -61,40 +61,40 @@ - - + + - + - + - - + + - - + + - - + + - - + + - + - - + + - - + + @@ -102,4 +102,4 @@ - \ No newline at end of file + diff --git a/tests/Fixtures/generator/builder/barSchema.xml b/tests/Fixtures/generator/builder/barSchema.xml index f4cb02f9f1..731ec292df 100644 --- a/tests/Fixtures/generator/builder/barSchema.xml +++ b/tests/Fixtures/generator/builder/barSchema.xml @@ -4,7 +4,7 @@ - +
diff --git a/tests/Fixtures/migration-command/schema.xml b/tests/Fixtures/migration-command/schema.xml index 0e24c9adda..70c1bcc4c9 100644 --- a/tests/Fixtures/migration-command/schema.xml +++ b/tests/Fixtures/migration-command/schema.xml @@ -2,18 +2,18 @@ - - - + + + - +
- - - + + +
diff --git a/tests/Fixtures/namespaced/schema.xml b/tests/Fixtures/namespaced/schema.xml index 66e036d1da..6103c9aaea 100644 --- a/tests/Fixtures/namespaced/schema.xml +++ b/tests/Fixtures/namespaced/schema.xml @@ -5,66 +5,66 @@ xsi:noNamespaceSchemaLocation="../../../resources/xsd/database.xsd"> - - - - - - + + + + + + - + - +
- - + +
- - - - - + + + + +
- - - - + + + +
- - + + - + - +
- + - - - + + + - - - - + + + + - +
diff --git a/tests/Fixtures/quoting/schema.xml b/tests/Fixtures/quoting/schema.xml index 0e04207485..3bec408724 100644 --- a/tests/Fixtures/quoting/schema.xml +++ b/tests/Fixtures/quoting/schema.xml @@ -6,7 +6,7 @@ - + @@ -15,7 +15,7 @@ - + diff --git a/tests/Fixtures/schemas/schema.xml b/tests/Fixtures/schemas/schema.xml index 25d5f2fe73..4c41ec2b8a 100644 --- a/tests/Fixtures/schemas/schema.xml +++ b/tests/Fixtures/schemas/schema.xml @@ -6,35 +6,35 @@ namespace="Propel\Tests\BookstoreSchemas">
- - - - + + + +
- - - - - - + + + + + + - - - - + + + +
- + - - + + @@ -45,58 +45,58 @@
- - - - + + + + - +
- - + +
- - - + + + - +
- + - - + +
- - - - + + + + - + - + - - + +
- - + +
diff --git a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php index 92fe8662ea..278e5ec539 100644 --- a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php @@ -44,51 +44,51 @@ public function setUp(): void - - - - + + + + - + - - + + - +
- - - + + +
- - + +
- - - - + + + + - - - - - + + + + +
- - - + + + - +
diff --git a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifierTest.php index 82d3bb46b3..e371e017e3 100644 --- a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorQueryBuilderModifierTest.php @@ -44,51 +44,51 @@ public function setUp(): void - - - - + + + + - + - - + + - +
- - - + + +
- - + +
- - - - + + + + - - - - - + + + + +
- - - + + + - +
diff --git a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorTest.php index 2108e954c4..db5ad0d9b0 100644 --- a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorTest.php @@ -47,62 +47,62 @@ public function setUp(): void - - - - + + + + - + - - + + - +
- - - + + +
- - + +
- - - - + + + + - + - - - - - + + + + +
- - - + + + - +
- + - - + +
@@ -230,11 +230,11 @@ public function testDatabaseLevelBehavior() { $schema = << - + - - - + + +
EOF; @@ -253,9 +253,9 @@ public function tablePrefixDataProvider() $schema = << - - - + + +
XML; diff --git a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorTest.php index f0f4d122a3..94b3ae52bf 100644 --- a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorTest.php @@ -51,18 +51,18 @@ public function setUp(): void $schema = << - - + + - +
- - + + - - + +
diff --git a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithBehaviorExclusionTest.php b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithBehaviorExclusionTest.php index a57a07b4e9..f73cda43e5 100644 --- a/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithBehaviorExclusionTest.php +++ b/tests/Propel/Tests/Generator/Behavior/ConcreteInheritance/ConcreteInheritanceBehaviorWithBehaviorExclusionTest.php @@ -30,23 +30,23 @@ public function setUp(): void $schema = << - - + + - + - + - +
- - + + - - - + + +
diff --git a/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php index 563a35e687..7fa5e4c559 100644 --- a/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php @@ -35,71 +35,71 @@ public function setUp(): void - - - + + + - + - +
- +
- - + + - +
- +
- - - + + +
- - - - + + + + - + - +
- - + +
- - - - + + + + - + - + - + - +
@@ -279,20 +279,20 @@ public function testTablePrefixSameDatabase() - - - + + + - + - +
- - + +
diff --git a/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifierTest.php index 66185640b1..7a3a1c7982 100644 --- a/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifierTest.php @@ -40,57 +40,57 @@ public function setUp(): void $schema = << - - - + + + - +
- - - - - - + + + + + + - - - + + +
- - - + + + - - + +
- - - + + + - - + + - + - +
- - - + + + - - + +
diff --git a/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifierTest.php index d8c690d31f..14d1307cb5 100644 --- a/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorQueryBuilderModifierTest.php @@ -35,24 +35,24 @@ public function setUp(): void $schema = << - - - + + + - +
- - - - - - + + + + + + - - - + + +
diff --git a/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorTest.php index d57c29fdf5..243234eb32 100644 --- a/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorTest.php @@ -26,11 +26,11 @@ public function testModifyDatabaseOverridesDefaultLocale() $schema = << - + - - + +
EOF; @@ -64,12 +64,12 @@ public function testModifyDatabaseDoesNotOverrideTableLocale() $schema = << - + - + - +
@@ -104,11 +104,11 @@ public function testSkipSqlParameterOnParentTable() $schema = << - - - + + + - +
@@ -124,11 +124,11 @@ public function schemaDataProvider() $schema1 = << - - - + + + - +
@@ -136,16 +136,16 @@ public function schemaDataProvider() $schema2 = << - - - + + +
- - - + + + - +
@@ -258,9 +258,9 @@ public function testModiFyTableUsesCustomI18nTableName() $schema = << - + - +
@@ -295,9 +295,9 @@ public function testModiFyTableUsesCustomLocaleColumnName() $schema = << - + - +
@@ -332,9 +332,9 @@ public function testModiFyTableUsesCustomLocaleDefault() $schema = << - + - +
@@ -369,9 +369,9 @@ public function testModiFyTableUsesCustomI18nLocaleLength() $schema = << - + - +
@@ -403,12 +403,12 @@ public function customPkSchemaDataProvider() $schema1 = << - - - + + + - - + +
@@ -416,16 +416,16 @@ public function customPkSchemaDataProvider() $schema2 = << - - - + + +
- - - + + + - +
diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/TestCase.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/TestCase.php index bdab1286de..7e0e179dfa 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/TestCase.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/TestCase.php @@ -33,27 +33,27 @@ public function setUp(): void $schema = << - - + + - +
- - + + - - - - - - + + + + + +
diff --git a/tests/Propel/Tests/Generator/Behavior/Timestampable/TimestampableBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Timestampable/TimestampableBehaviorTest.php index 1c3ed7474f..035469a5cb 100644 --- a/tests/Propel/Tests/Generator/Behavior/Timestampable/TimestampableBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Timestampable/TimestampableBehaviorTest.php @@ -297,11 +297,11 @@ public function testDisableUpdatedAt() $schema = << - - + + - +
@@ -331,11 +331,11 @@ public function testDisableCreatedAt() $schema = << - - + + - +
diff --git a/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php index 42b4cecfeb..6b860f21b5 100755 --- a/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php @@ -113,9 +113,9 @@ public function testParametersNotDefined() $schema = << - - - + + +
EOF; @@ -133,11 +133,11 @@ public function testColumnNameNotDefined() $schema = << - - + + - - + +
@@ -156,11 +156,11 @@ public function testValidatorNameNotDefined() $schema = << - - + + - - + +
@@ -179,11 +179,11 @@ public function testConstraintNameNotValid() $schema = << - - + + - - + +
@@ -202,11 +202,11 @@ public function testConstraintOptionsNotValid() $schema = << - - + + - - + +
diff --git a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php index 9f57bfbc34..6bcef3cd8b 100644 --- a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php @@ -56,41 +56,41 @@ public static function setUpBeforeClass(): void $schema = << - - - + + +
- - + + - +
- - + + - +
- - + + - - - + + +
- - - + + + - + - +
EOF; @@ -99,30 +99,30 @@ public static function setUpBeforeClass(): void $schema2 = << - - + + - - - + + +
- - + + - - + + - - - + + + - - - + + +
@@ -132,15 +132,15 @@ public static function setUpBeforeClass(): void $schema3 = << - - + + - - - + + + - +
EOF; @@ -149,30 +149,30 @@ public static function setUpBeforeClass(): void $schema4 = << - - + + - +
- - + +
- - - - + + + + - + - + - +
@@ -187,7 +187,7 @@ public static function setUpBeforeClass(): void - +
@@ -196,7 +196,7 @@ public static function setUpBeforeClass(): void - +
XML; @@ -206,8 +206,8 @@ public static function setUpBeforeClass(): void - - + + @@ -215,16 +215,16 @@ public static function setUpBeforeClass(): void
- - - + + + - +
diff --git a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifierTest.php index 30e5d6e72a..071576c2af 100644 --- a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorQueryBuilderModifierTest.php @@ -27,9 +27,9 @@ public function setUp(): void $schema = << - - - + + +
> EOF; diff --git a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorTest.php index bfb2bdef0c..0f596adcc6 100644 --- a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorTest.php @@ -22,9 +22,9 @@ public function basicSchemaDataProvider() $schema = << - - - + + +
EOF; @@ -67,10 +67,10 @@ public function testModifyTableAddsVersionColumnCustomName() $schema = << - - + + - +
@@ -103,10 +103,10 @@ public function testModifyTableDoesNotAddVersionColumnIfExists() $schema = << - - - - + + + +
EOF; @@ -135,18 +135,18 @@ public function foreignTableSchemaDataProvider() $schema = << - - - + + + - + - +
- - - + + +
EOF; @@ -292,10 +292,10 @@ public function testModifyTableAddsVersionTableCustomName() $schema = << - - + + - +
@@ -331,13 +331,13 @@ public function testModifyTableDoesNotAddVersionTableIfExists() $schema = << - - - + + +
- - + +
EOF; @@ -381,12 +381,12 @@ public function logSchemaDataProvider() $schema = << - - + + - - - + + +
@@ -465,10 +465,10 @@ public function testDatabaseLevelBehavior() { $schema = << - + - - + +
EOF; @@ -503,13 +503,13 @@ public function testIndicesParameter() $schema = << - - + + - +
@@ -541,9 +541,9 @@ public function testSkipSqlParameterOnParentTable() $schema = << - - - + + +
EOF; @@ -559,9 +559,9 @@ public function tablePrefixSchemaDataProvider() $schema = << - - - + + +
XML; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectArrayColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectArrayColumnTypeTest.php index 29c2b57cd6..41c436dd6c 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectArrayColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectArrayColumnTypeTest.php @@ -34,11 +34,11 @@ public function setUp(): void $schema = << - - - - - + + + + +
EOF; @@ -278,8 +278,8 @@ public function testHydrateOverwritePreviousValues() $schema = << - - + +
EOF; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectBooleanColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectBooleanColumnTypeTest.php index 278196b292..7815032859 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectBooleanColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectBooleanColumnTypeTest.php @@ -28,12 +28,12 @@ public function setUp(): void $schema = << - - - - - - + + + + + +
EOF; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php index b5af167644..913fd382fa 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php @@ -31,9 +31,9 @@ public function setUp(): void $schema = << - - - + + +
EOF; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectJsonColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectJsonColumnTypeTest.php index 165a477701..8c1e43e970 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectJsonColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectJsonColumnTypeTest.php @@ -31,7 +31,7 @@ public function setUp(): void $schema = << - +
diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLazyLoadTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLazyLoadTest.php index a1e822387f..27171289f5 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLazyLoadTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLazyLoadTest.php @@ -29,10 +29,10 @@ public function setUp(): void $schema = << - - - - + + + +
EOF; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKs2Test.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKs2Test.php index 3799ba1395..b2a16ebacd 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKs2Test.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKs2Test.php @@ -56,13 +56,13 @@ public function setUp(): void - +
- +
diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKsTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKsTest.php index e162d9fd3f..d7e6e792d5 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKsTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectM2MRelationThreePKsTest.php @@ -80,17 +80,17 @@ public function setUp(): void - +
- +
- +
'; @@ -667,18 +667,18 @@ public function testRelationThree3() - +
- +
- +
'; @@ -745,13 +745,13 @@ public function testRelationThree4() - +
- +
@@ -815,13 +815,13 @@ public function testRelationThree5() - +
- +
@@ -884,13 +884,13 @@ public function testRelationThree6() - +
- +
diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectMoreRelationTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectMoreRelationTest.php index 294fc8f08e..f2d7341e2a 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectMoreRelationTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectMoreRelationTest.php @@ -42,33 +42,33 @@ public function setUp(): void - - + +
- - - - + + + +
- - - + + +
- - - + + + diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectObjectColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectObjectColumnTypeTest.php index 939b396204..b0ab811365 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectObjectColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectObjectColumnTypeTest.php @@ -31,8 +31,8 @@ public function setUp(): void $schema = <<
- - + +
EOF; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php index 94a6c6e424..b41745149f 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php @@ -32,11 +32,11 @@ public function setUp(): void $schema = << - - - - - + + + + +
diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php index 75e9d9634e..4b8d386ef8 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php @@ -33,11 +33,11 @@ public function setUp(): void $schema = << - - - - - + + + + +
EOF; @@ -198,10 +198,10 @@ public function testHydrateWithMysqlInvalidDate() $schema = << - - - - + + + +
EOF; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php index 4346ecbfb5..4c582e63e3 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php @@ -857,8 +857,8 @@ public function testToArrayKeyTypePreDefined() $schema = << - - + +
EOF; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithInterfaceTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithInterfaceTest.php index a8bbcd6fab..c25facb1cc 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithInterfaceTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithInterfaceTest.php @@ -23,8 +23,8 @@ public function setUp(): void $schema = << - - + +
EOF; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php index 1b18536205..59c15b7b1b 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php @@ -31,8 +31,8 @@ public function setUp(): void $schema = << - - + +
SCHEMA; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessTableMapTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessTableMapTest.php index b1584b4314..e8607766f1 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessTableMapTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessTableMapTest.php @@ -29,8 +29,8 @@ public function setUp(): void $schema = << - - + +
SCHEMA; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryArrayColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryArrayColumnTypeTest.php index d93212666f..7011372abb 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryArrayColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryArrayColumnTypeTest.php @@ -30,9 +30,9 @@ public function setUp(): void $schema = << - - - + + +
EOF; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryEnumColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryEnumColumnTypeTest.php index 6818caa018..2223dd7b35 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryEnumColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryEnumColumnTypeTest.php @@ -31,9 +31,9 @@ public function setUp(): void $schema = << - - - + + +
EOF; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryObjectColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryObjectColumnTypeTest.php index 2c9c723215..d06315a34f 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryObjectColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQueryObjectColumnTypeTest.php @@ -38,8 +38,8 @@ public function setUp(): void $schema = << - - + +
EOF; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php index 51652c1e85..10c13978d4 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php @@ -30,9 +30,9 @@ public function setUp(): void $schema = << - - - + + +
EOF; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapEnumColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapEnumColumnTypeTest.php index 188090dea9..51bcb06b68 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapEnumColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapEnumColumnTypeTest.php @@ -28,8 +28,8 @@ public function setUp(): void $schema = << - - + +
EOF; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapLazyLoadTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapLazyLoadTest.php index 00f0f0bcb7..55ce41b67d 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapLazyLoadTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapLazyLoadTest.php @@ -27,10 +27,10 @@ public function setUp(): void $schema = << - - - - + + + +
EOF; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapSetColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapSetColumnTypeTest.php index 75e1dc8674..1a5f6fb602 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapSetColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedTableMapSetColumnTypeTest.php @@ -28,8 +28,8 @@ public function setUp(): void $schema = << - - + +
EOF; diff --git a/tests/Propel/Tests/Generator/Migration/BaseTest.php b/tests/Propel/Tests/Generator/Migration/BaseTest.php index 79c22f9d13..9995977cee 100644 --- a/tests/Propel/Tests/Generator/Migration/BaseTest.php +++ b/tests/Propel/Tests/Generator/Migration/BaseTest.php @@ -21,7 +21,7 @@ public function testSimpleAdd() $originXml = ' - +
'; @@ -29,8 +29,8 @@ public function testSimpleAdd() $targetXml = ' - - + +
'; @@ -46,8 +46,8 @@ public function testSimpleSize() $originXml = ' - - + +
'; @@ -55,8 +55,8 @@ public function testSimpleSize() $targetXml = ' - - + +
'; @@ -72,8 +72,8 @@ public function testCharToChar() $originXml = ' - - + +
'; @@ -81,8 +81,8 @@ public function testCharToChar() $targetXml = ' - - + +
'; @@ -99,7 +99,7 @@ public function testScale() $originXml = ' - +
@@ -109,7 +109,7 @@ public function testScale() $targetXml = ' - +
@@ -119,7 +119,7 @@ public function testScale() $target2Xml = ' - +
@@ -138,8 +138,8 @@ public function testColumnRequireChange() $originXml = ' - - + +
'; @@ -147,8 +147,8 @@ public function testColumnRequireChange() $targetXml = ' - - + +
'; @@ -164,9 +164,9 @@ public function testColumnTypeChangeSimple() $originXml = ' - - - + + +
'; @@ -174,9 +174,9 @@ public function testColumnTypeChangeSimple() $targetXml = ' - - - + + +
'; @@ -191,16 +191,16 @@ public function testColumnTypeChangeComplex() $originXml = ' - - - + + + - - - - + + + + - +
'; @@ -208,13 +208,13 @@ public function testColumnTypeChangeComplex() $targetXml = ' - + - - - + + + - +
'; @@ -229,24 +229,24 @@ public function testColumnTypeChangeMoreComplex() $originXml = ' - + - - - - - + + + + + - - - - + + + + - - - + + + - +
'; @@ -254,24 +254,24 @@ public function testColumnTypeChangeMoreComplex() $targetXml = ' - + - - - - - + + + + + - - - - + + + + - - - + + + - +
'; @@ -286,8 +286,8 @@ public function testColumnChangePrimaryKey() $originXml = ' - - + +
'; @@ -295,8 +295,8 @@ public function testColumnChangePrimaryKey() $targetXml = ' - - + +
'; @@ -304,8 +304,8 @@ public function testColumnChangePrimaryKey() $target2Xml = ' - - + +
'; @@ -313,8 +313,8 @@ public function testColumnChangePrimaryKey() $target3Xml = ' - - + +
'; @@ -322,8 +322,8 @@ public function testColumnChangePrimaryKey() $target4Xml = ' - - + +
'; @@ -331,8 +331,8 @@ public function testColumnChangePrimaryKey() $target5Xml = ' - - + +
'; diff --git a/tests/Propel/Tests/Generator/Migration/ForeignKeyTest.php b/tests/Propel/Tests/Generator/Migration/ForeignKeyTest.php index e5f0ad2f16..a254da2e30 100644 --- a/tests/Propel/Tests/Generator/Migration/ForeignKeyTest.php +++ b/tests/Propel/Tests/Generator/Migration/ForeignKeyTest.php @@ -21,13 +21,13 @@ public function testAdd() $originXml = ' - - + +
- - - + + +
'; @@ -35,15 +35,15 @@ public function testAdd() $targetXml = ' - - + +
- - - + + + - +
@@ -59,8 +59,8 @@ public function testAddNotUnique() $originXml = ' - - + +
'; @@ -68,16 +68,16 @@ public function testAddNotUnique() $targetXml = ' - + - +
- - - + + + - +
@@ -93,15 +93,15 @@ public function testRemove() $originXml = ' - - + +
- - - + + + - +
@@ -110,13 +110,13 @@ public function testRemove() $targetXml = ' - - + +
- - - + + +
'; @@ -131,18 +131,18 @@ public function testChange() $originXml = ' - + - +
- - - - + + + + - - + +
@@ -151,15 +151,15 @@ public function testChange() $targetXml = ' - + - +
- - - - + + + +
'; diff --git a/tests/Propel/Tests/Generator/Migration/IndexTest.php b/tests/Propel/Tests/Generator/Migration/IndexTest.php index 2cbb05bd20..27ec129ec6 100644 --- a/tests/Propel/Tests/Generator/Migration/IndexTest.php +++ b/tests/Propel/Tests/Generator/Migration/IndexTest.php @@ -21,8 +21,8 @@ public function testAdd() $originXml = ' - - + +
'; @@ -30,10 +30,10 @@ public function testAdd() $targetXml = ' - - + + - +
@@ -49,10 +49,10 @@ public function testRemove() $originXml = ' - - + + - +
@@ -61,8 +61,8 @@ public function testRemove() $targetXml = ' - - + +
'; @@ -77,12 +77,12 @@ public function testChange() $originXml = ' - - - + + + - - + +
@@ -91,9 +91,9 @@ public function testChange() $targetXml = ' - - - + + +
'; @@ -108,12 +108,12 @@ public function testChangeName() $originXml = ' - - - + + + - - + +
@@ -122,12 +122,12 @@ public function testChangeName() $targetXml = ' - - - + + + - - + +
@@ -145,10 +145,10 @@ public function testChangeSize() $originXml = ' - - + + - +
@@ -157,10 +157,10 @@ public function testChangeSize() $targetXml = ' - - + + - +
@@ -176,13 +176,13 @@ public function testSameIndex() $originXml = ' - - + + - + - +
@@ -191,16 +191,16 @@ public function testSameIndex() $targetXml = ' - - + + - + - + - +
diff --git a/tests/Propel/Tests/Generator/Migration/PrimaryKeyAITest.php b/tests/Propel/Tests/Generator/Migration/PrimaryKeyAITest.php index ea6b46049a..5d50b310ae 100644 --- a/tests/Propel/Tests/Generator/Migration/PrimaryKeyAITest.php +++ b/tests/Propel/Tests/Generator/Migration/PrimaryKeyAITest.php @@ -22,7 +22,7 @@ public function testAdd() - +
'; @@ -31,7 +31,7 @@ public function testAdd() - +
'; @@ -47,7 +47,7 @@ public function testRemove() - +
'; @@ -56,7 +56,7 @@ public function testRemove() - +
'; @@ -72,8 +72,8 @@ public function testChange() - - + +
'; @@ -82,8 +82,8 @@ public function testChange() - - + +
'; @@ -99,7 +99,7 @@ public function testChangeName() - +
'; @@ -108,7 +108,7 @@ public function testChangeName() - +
'; @@ -126,7 +126,7 @@ public function testChangeSize() - +
'; @@ -135,7 +135,7 @@ public function testChangeSize() - +
'; diff --git a/tests/Propel/Tests/Generator/Migration/PrimaryKeyTest.php b/tests/Propel/Tests/Generator/Migration/PrimaryKeyTest.php index 02ee05f10c..9a4dc925f3 100644 --- a/tests/Propel/Tests/Generator/Migration/PrimaryKeyTest.php +++ b/tests/Propel/Tests/Generator/Migration/PrimaryKeyTest.php @@ -22,7 +22,7 @@ public function testAdd() - +
'; @@ -31,7 +31,7 @@ public function testAdd() - +
'; @@ -47,7 +47,7 @@ public function testRemove() - +
'; @@ -56,7 +56,7 @@ public function testRemove() - +
'; @@ -72,8 +72,8 @@ public function testChange() - - + +
'; @@ -82,8 +82,8 @@ public function testChange() - - + +
'; @@ -99,7 +99,7 @@ public function testChangeName() - +
'; @@ -108,7 +108,7 @@ public function testChangeName() - +
'; @@ -124,7 +124,7 @@ public function testChangeSize() - +
'; @@ -133,7 +133,7 @@ public function testChangeSize() - +
'; diff --git a/tests/Propel/Tests/Generator/Model/BehaviorTest.php b/tests/Propel/Tests/Generator/Model/BehaviorTest.php index 273c5ad4d1..aafda52b5f 100644 --- a/tests/Propel/Tests/Generator/Model/BehaviorTest.php +++ b/tests/Propel/Tests/Generator/Model/BehaviorTest.php @@ -119,13 +119,13 @@ public function testSchemaReader() $schema = << - - - - + + + + - - + +
@@ -154,8 +154,8 @@ public function testUnknownBehavior() $schema = << - - + +
EOF; @@ -171,9 +171,9 @@ public function testModifyTable() $schema = << - - - + + +
EOF; @@ -190,9 +190,9 @@ public function testModifyDatabase() $schemaReader = new SchemaReader(); $schema = << - + - +
EOF; @@ -210,13 +210,13 @@ public function testGetColumnForParameter() $schema = << - - - - + + + + - - + +
diff --git a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php index c95a222a93..a26fca14a4 100644 --- a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php +++ b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php @@ -364,18 +364,18 @@ public function testColumnRenaming() $schema1 = ' - - - + + +
'; $schema2 = ' - - - + + +
'; @@ -410,28 +410,28 @@ public function testTableRenaming() $schema1 = ' - - - + + +
- - - + + +
'; $schema2 = ' - - - + + +
- - - + + +
'; diff --git a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTestProvider.php b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTestProvider.php index f56039d9ba..5c6591f01d 100644 --- a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTestProvider.php +++ b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTestProvider.php @@ -21,8 +21,8 @@ public function providerForTestGetAddColumnFirstDDL() $schema = << - - + +
EOF; diff --git a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMyISAMTest.php b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMyISAMTest.php index 886346a2c1..43b2cdd2b9 100644 --- a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMyISAMTest.php +++ b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMyISAMTest.php @@ -265,10 +265,10 @@ public function testGetAddTableDDLIndex() $schema = << - - + + - +
@@ -294,14 +294,14 @@ public function testGetAddTableDDLForeignKey() $schema = << - - + + - +
- +
EOF; @@ -326,14 +326,14 @@ public function testGetAddTableDDLForeignKeySkipSql() $schema = << - - + + - +
- +
EOF; @@ -358,7 +358,7 @@ public function testGetAddTableDDLEngine() $schema = << - +
EOF; @@ -386,7 +386,7 @@ public function testGetAddTableDDLVendor() $schema = << - + diff --git a/tests/Propel/Tests/Generator/Platform/MysqlPlatformTest.php b/tests/Propel/Tests/Generator/Platform/MysqlPlatformTest.php index e6532bf323..c2192377b1 100644 --- a/tests/Propel/Tests/Generator/Platform/MysqlPlatformTest.php +++ b/tests/Propel/Tests/Generator/Platform/MysqlPlatformTest.php @@ -274,10 +274,10 @@ public function testGetAddTableDDLIndex() $schema = <<
- - + + - +
@@ -303,14 +303,14 @@ public function testGetAddTableDDLForeignKey() $schema = << - - + + - +
- +
EOF; @@ -338,14 +338,14 @@ public function testGetAddTableDDLForeignKeySkipSql() $schema = << - - + + - +
- +
EOF; @@ -370,7 +370,7 @@ public function testGetAddTableDDLEngine() $schema = << - +
EOF; @@ -398,7 +398,7 @@ public function testGetAddTableDDLVendor() $schema = << - + @@ -881,9 +881,9 @@ public function testGetAddTableDDLComplexPK()
- - - + + +
EOF; @@ -911,23 +911,23 @@ public function testVendorOptionsQuoting() - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + +
diff --git a/tests/Propel/Tests/Generator/Platform/OraclePlatformMigrationTest.php b/tests/Propel/Tests/Generator/Platform/OraclePlatformMigrationTest.php index 3e74ab1d79..177593b53d 100644 --- a/tests/Propel/Tests/Generator/Platform/OraclePlatformMigrationTest.php +++ b/tests/Propel/Tests/Generator/Platform/OraclePlatformMigrationTest.php @@ -329,27 +329,27 @@ public function testGetModifyDatabaseWithBlockStorageDDL() $schema1 = << - - + +
- - - + + +
- - + +
EOF; $schema2 = << - - - - + + + + @@ -366,8 +366,8 @@ public function testGetModifyDatabaseWithBlockStorageDDL()
- - + + @@ -384,9 +384,9 @@ public function testGetModifyDatabaseWithBlockStorageDDL()
- - - + + + diff --git a/tests/Propel/Tests/Generator/Platform/OraclePlatformTest.php b/tests/Propel/Tests/Generator/Platform/OraclePlatformTest.php index 1857956ccb..b207878474 100644 --- a/tests/Propel/Tests/Generator/Platform/OraclePlatformTest.php +++ b/tests/Propel/Tests/Generator/Platform/OraclePlatformTest.php @@ -492,10 +492,10 @@ public function testGetOracleBlockStorageDDL() $schema = <<
- - + + - + @@ -507,7 +507,7 @@ public function testGetOracleBlockStorageDDL() - + @@ -525,9 +525,9 @@ public function testGetOracleBlockStorageDDL()
- - - + + + diff --git a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php index 398c12f715..c09ce4516e 100755 --- a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php +++ b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformMigrationTest.php @@ -368,8 +368,8 @@ public function testGetModifyColumnDDLWithVarcharWithoutSize() $schema = <<
- - + +
EOF; @@ -398,7 +398,7 @@ public function testGetModifyColumnDDLWithVarcharWithoutSizeAndPlatform() $schema = << - +
diff --git a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php index e840e3dd84..6d9a6ac269 100755 --- a/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php +++ b/tests/Propel/Tests/Generator/Platform/PgsqlPlatformTest.php @@ -136,16 +136,16 @@ public function testGetAddTablesDDLSchemasVendor() $schema = << - +
- +
- + @@ -365,7 +365,7 @@ public function testGetAddTableDDLSchemaVendor() $schema = <<
- + @@ -418,7 +418,7 @@ public function testGetAddTableDDLSequence() $schema = <<
- +
@@ -489,7 +489,7 @@ public function testGetDropTableDDLSchemaVendor() $schema = << - + diff --git a/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php b/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php index 1b18b34d3b..28c6ec934e 100644 --- a/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php +++ b/tests/Propel/Tests/Generator/Platform/PlatformMigrationTestProvider.php @@ -27,36 +27,36 @@ public function providerForTestGetModifyDatabaseDDL() $schema1 = <<
- - + +
- - - + + +
- - + +
EOF; $schema2 = << - - - - + + + +
- - + +
- - - + + +
EOF; @@ -76,14 +76,14 @@ public function providerForTestGetModifyTableDDL() $schema1 = << - - - + + + - + - + @@ -94,21 +94,21 @@ public function providerForTestGetModifyTableDDL()
- - - + + +
EOF; $schema2 = << - - - - + + + + - + @@ -118,9 +118,9 @@ public function providerForTestGetModifyTableDDL()
- - - + + +
EOF; @@ -135,19 +135,19 @@ public function providerForTestGetModifyTableColumnsDDL() $schema1 = << - - - + + +
EOF; $schema2 = << - - - - + + + +
EOF; @@ -166,18 +166,18 @@ public function providerForTestGetModifyTablePrimaryKeysDDL() $schema1 = << - - - + + +
EOF; $schema2 = << - - - + + +
EOF; @@ -196,10 +196,10 @@ public function providerForTestGetModifyTableIndicesDDL() $schema1 = << - - - - + + + + @@ -216,11 +216,11 @@ public function providerForTestGetModifyTableIndicesDDL() $schema2 = <<
- - - - - + + + + + @@ -251,42 +251,42 @@ public function providerForTestGetModifyTableForeignKeysDDL() $schema1 = <<
- - - + + + - + - - + +
- - - + + +
EOF; $schema2 = << - - - + + + - - + + - +
- - - + + +
EOF; @@ -305,30 +305,30 @@ public function providerForTestGetModifyTableForeignKeysSkipSqlDDL() $schema1 = << - - + + - +
- - + +
EOF; $schema2 = << - - + + - +
- - + +
EOF; @@ -347,27 +347,27 @@ public function providerForTestGetModifyTableForeignKeysSkipSql2DDL() $schema1 = << - - + + - +
- - + +
EOF; $schema2 = << - - + +
- - + +
EOF; @@ -467,8 +467,8 @@ public function providerForTestGetAddColumnDDL() $schema = << - - + +
EOF; @@ -482,9 +482,9 @@ public function providerForTestGetAddColumnsDDL() $schema = << - - - + + +
EOF; @@ -517,25 +517,25 @@ public function providerForTestGetModifyTableForeignKeysSkipSql3DDL() $schema1 = << - + - +
- +
EOF; $schema2 = << - +
- +
EOF; @@ -551,25 +551,25 @@ public function providerForTestGetModifyTableForeignKeysSkipSql4DDL() $schema1 = << - + - +
- +
EOF; $schema2 = << - +
- +
EOF; diff --git a/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php b/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php index 037063e4b6..995ab21f05 100644 --- a/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php +++ b/tests/Propel/Tests/Generator/Platform/PlatformTestProvider.php @@ -29,20 +29,20 @@ public function providerForTestGetAddTablesDDL() $schema = << - - + + - + - +
- - - + + +
EOF; @@ -55,27 +55,27 @@ public function providerForTestGetAddTablesDDLSchema() $schema = << - - + + - + - +
- - - + + +
- - - + + + - +
@@ -89,20 +89,20 @@ public function providerForTestGetAddTablesSkipSQLDDL() $schema = << - - + + - + - +
- - - + + +
EOF; @@ -115,8 +115,8 @@ public function providerForTestGetAddTableDDLSimplePK() $schema = << - - + +
EOF; @@ -129,8 +129,8 @@ public function providerForTestGetAddTableDDLNonIntegerPK() $schema = << - - + +
EOF; @@ -143,9 +143,9 @@ public function providerForTestGetAddTableDDLCompositePK() $schema = << - - - + + +
EOF; @@ -158,10 +158,10 @@ public function providerForTestGetAddTableDDLUniqueIndex() $schema = << - - + + - +
@@ -175,8 +175,8 @@ public function providerForTestGetAddTableDDLSchema() $schema = << - - + +
EOF; diff --git a/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php b/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php index 1b0d46e998..b5ef5378a6 100644 --- a/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php +++ b/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php @@ -37,8 +37,8 @@ public function simpleSchemaProvider() $xmlSchema = << - - + +
EOF; @@ -136,8 +136,8 @@ public function testBuild() $xmlSchema = << - - + +
EOF; diff --git a/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php b/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php index bcd81128f8..d294e69a60 100644 --- a/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php +++ b/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php @@ -48,8 +48,8 @@ public function testValidateReturnsTrueForValidSchema() $xmlSchema = << - - + +
EOF; @@ -73,8 +73,8 @@ public function testDatabasePackageName() $schema = << - - + +
EOF; diff --git a/tests/Propel/Tests/Issues/Issue1033Test.php b/tests/Propel/Tests/Issues/Issue1033Test.php index 22f12a5db9..4bbf7affc4 100644 --- a/tests/Propel/Tests/Issues/Issue1033Test.php +++ b/tests/Propel/Tests/Issues/Issue1033Test.php @@ -28,8 +28,8 @@ public function setUp(): void $schema = << - - + +
EOF; diff --git a/tests/Propel/Tests/Issues/Issue1192Test.php b/tests/Propel/Tests/Issues/Issue1192Test.php index aab75ae9c4..5ec7a00e98 100644 --- a/tests/Propel/Tests/Issues/Issue1192Test.php +++ b/tests/Propel/Tests/Issues/Issue1192Test.php @@ -36,7 +36,7 @@ public function setUp(): void $schema = << - +
END; diff --git a/tests/Propel/Tests/Issues/Issue1463Test.php b/tests/Propel/Tests/Issues/Issue1463Test.php index 75970fa4b7..91aea76046 100644 --- a/tests/Propel/Tests/Issues/Issue1463Test.php +++ b/tests/Propel/Tests/Issues/Issue1463Test.php @@ -35,8 +35,8 @@ public function setUp(): void $schema = << - - + +
END; diff --git a/tests/Propel/Tests/Issues/Issue617Test.php b/tests/Propel/Tests/Issues/Issue617Test.php index 13ca8966a4..5c04a93225 100644 --- a/tests/Propel/Tests/Issues/Issue617Test.php +++ b/tests/Propel/Tests/Issues/Issue617Test.php @@ -76,13 +76,13 @@ private function setupInitSchema() - - + + - + - + @@ -91,8 +91,8 @@ private function setupInitSchema() - - + + '; @@ -147,8 +147,8 @@ private function dropForeignKey() - - + + @@ -156,8 +156,8 @@ private function dropForeignKey() - - + +
'; diff --git a/tests/Propel/Tests/Issues/Issue646Test.php b/tests/Propel/Tests/Issues/Issue646Test.php index 98a0e213c5..e7d2c103ae 100644 --- a/tests/Propel/Tests/Issues/Issue646Test.php +++ b/tests/Propel/Tests/Issues/Issue646Test.php @@ -37,15 +37,15 @@ protected function setUp(): void $schema = ' - +
- +
- +
'; diff --git a/tests/Propel/Tests/Issues/Issue675Test.php b/tests/Propel/Tests/Issues/Issue675Test.php index f353301eb5..5d7a115e84 100644 --- a/tests/Propel/Tests/Issues/Issue675Test.php +++ b/tests/Propel/Tests/Issues/Issue675Test.php @@ -33,20 +33,20 @@ public function testIncompleteForeignReference() - - - + + + - +
- - - + + +
EOF; diff --git a/tests/Propel/Tests/Issues/Issue733Test.php b/tests/Propel/Tests/Issues/Issue733Test.php index 7d223e1e46..6843504678 100644 --- a/tests/Propel/Tests/Issues/Issue733Test.php +++ b/tests/Propel/Tests/Issues/Issue733Test.php @@ -29,22 +29,22 @@ public function setUp(): void $schema = << - - - + + + - - + +
- - - + + + - - - + + +
diff --git a/tests/Propel/Tests/Issues/Issue768Test.php b/tests/Propel/Tests/Issues/Issue768Test.php index b8db3e8e77..a354108e51 100644 --- a/tests/Propel/Tests/Issues/Issue768Test.php +++ b/tests/Propel/Tests/Issues/Issue768Test.php @@ -30,10 +30,10 @@ protected function setUp(): void $schema = ' - - - - + + + +
'; diff --git a/tests/Propel/Tests/Issues/Issue829Test.php b/tests/Propel/Tests/Issues/Issue829Test.php index 8ffffec95c..839a40082f 100644 --- a/tests/Propel/Tests/Issues/Issue829Test.php +++ b/tests/Propel/Tests/Issues/Issue829Test.php @@ -31,8 +31,8 @@ protected function setUp(): void $schema = ' - - + +
'; diff --git a/tests/Propel/Tests/Issues/Issue915Test.php b/tests/Propel/Tests/Issues/Issue915Test.php index 05fb913c15..81f15dd45f 100644 --- a/tests/Propel/Tests/Issues/Issue915Test.php +++ b/tests/Propel/Tests/Issues/Issue915Test.php @@ -27,8 +27,8 @@ public function setUp(): void $schema = << - - + +
EOF; From 7868a56c9af7b6200213f535c9db16cafeadad06 Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 12 Aug 2020 12:42:37 +0200 Subject: [PATCH 146/208] Fix table name logging for ReverseManager --- src/Propel/Generator/Manager/ReverseManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Generator/Manager/ReverseManager.php b/src/Propel/Generator/Manager/ReverseManager.php index df9054fa53..d55afcd1d5 100644 --- a/src/Propel/Generator/Manager/ReverseManager.php +++ b/src/Propel/Generator/Manager/ReverseManager.php @@ -251,7 +251,7 @@ protected function buildModel() continue; } - $tableNames[] = $table; + $tableNames[] = $tableName; $database->removeTable($table); } From c233dcf29a13395dd3f26e866427c22bfe444f0c Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 18 Aug 2020 12:02:30 +0200 Subject: [PATCH 147/208] Fix NULL to null for object builder. --- src/Propel/Generator/Builder/Om/ObjectBuilder.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index 3cebac2919..4488504752 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -885,7 +885,7 @@ public function addTemporalAccessorComment(&$script, Column $column) * {$column->getDescription()} * * @param string|null \$format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw $dateTimeClass object will be returned. + * If format is NULL, then the raw $dateTimeClass object will be returned. * * @return string|$dateTimeClass Formatted date/time value as string or $dateTimeClass object (if format is NULL), NULL if column is NULL" . ($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : '') . " * @@ -921,8 +921,13 @@ public function addTemporalAccessorOpen(&$script, Column $column) $defaultfmt = null; } + $format = var_export($defaultfmt, true); + if ($format === 'NULL') { + $format = 'null'; + } + $script .= " - " . $visibility . " function get$cfc(\$format = " . var_export($defaultfmt, true) . ''; + " . $visibility . " function get$cfc(\$format = " . $format . ''; if ($column->isLazyLoad()) { $script .= ', $con = null'; } From 564b4aac437a93824e43ba846d5d16e47a4c76ca Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 18 Aug 2020 12:04:17 +0200 Subject: [PATCH 148/208] Fix CS. --- src/Propel/Generator/Builder/Om/ObjectBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index 4488504752..7a9bcfe7b1 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -884,7 +884,7 @@ public function addTemporalAccessorComment(&$script, Column $column) * Get the [optionally formatted] temporal [$clo] column value. * {$column->getDescription()} * - * @param string|null \$format The date/time format string (either date()-style or strftime()-style). + * @param string|null \$format The date/time format string (either date()-style or strftime()-style). * If format is NULL, then the raw $dateTimeClass object will be returned. * * @return string|$dateTimeClass Formatted date/time value as string or $dateTimeClass object (if format is NULL), NULL if column is NULL" . ($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : '') . " From cf0bd0d9a76550f5800ef6c1276becb018b2b6b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C3=B3jcik?= Date: Wed, 9 Sep 2020 15:25:32 +0200 Subject: [PATCH 149/208] tests --- .../Connection/TransactionTraitTest.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/Propel/Tests/Runtime/Connection/TransactionTraitTest.php b/tests/Propel/Tests/Runtime/Connection/TransactionTraitTest.php index 4891e83253..f3a0e05e79 100644 --- a/tests/Propel/Tests/Runtime/Connection/TransactionTraitTest.php +++ b/tests/Propel/Tests/Runtime/Connection/TransactionTraitTest.php @@ -8,8 +8,10 @@ namespace Propel\Tests\Runtime\Connection; +use Error; use Exception; use Propel\Tests\TestCase; +use Throwable; /** * Tests the PdoConnection class @@ -41,6 +43,29 @@ public function testTransactionRollback() } } + /** + * @throws \Throwable + * + * @return void + */ + public function testTransactionRollbackOnThrowable() + { + $con = $this->getMockForTrait('Propel\Runtime\Connection\TransactionTrait'); + + $con->expects($this->once())->method('beginTransaction'); + $con->expects($this->once())->method('rollback'); + $con->expects($this->never())->method('commit'); + + try { + $con->transaction(function () { + throw new Error('boom'); + }); + $this->fail('missing throwable'); + } catch (Throwable $e) { + $this->assertEquals('boom', $e->getMessage(), 'exception was rethrown'); + } + } + /** * @return void */ @@ -112,4 +137,29 @@ public function testTransactionNestedException() $this->assertEquals('boooom', $e->getMessage()); } } + + /** + * @throws \Exception + * + * @return void + */ + public function testTransactionNestedThrowable() + { + $con = $this->getMockForTrait('Propel\Runtime\Connection\TransactionTrait'); + + $con->expects($this->exactly(2))->method('beginTransaction'); + $con->expects($this->exactly(2))->method('rollback'); + $con->expects($this->never())->method('commit'); + + try { + $con->transaction(function () use ($con) { + $con->transaction(function () { + throw new Error('boooom'); + }); + }); + $this->fail('expecting a nested throwable to be re-thrown'); + } catch (Throwable $e) { + $this->assertEquals('boooom', $e->getMessage()); + } + } } From 881c90b592e1889d125a43a36019cb682f871442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C3=B3jcik?= Date: Wed, 9 Sep 2020 16:25:26 +0200 Subject: [PATCH 150/208] fix --- src/Propel/Runtime/Connection/TransactionTrait.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Propel/Runtime/Connection/TransactionTrait.php b/src/Propel/Runtime/Connection/TransactionTrait.php index a609d25cce..26937ad64e 100644 --- a/src/Propel/Runtime/Connection/TransactionTrait.php +++ b/src/Propel/Runtime/Connection/TransactionTrait.php @@ -8,7 +8,7 @@ namespace Propel\Runtime\Connection; -use Exception; +use Throwable; /** * Transaction helper trait @@ -19,11 +19,11 @@ trait TransactionTrait * Executes the given callable within a transaction. * This helper method takes care to commit or rollback the transaction. * - * In case you want the transaction to rollback just throw an Exception of any type. + * In case you want the transaction to rollback just throw an Throwable of any type. * * @param callable $callable A callable to be wrapped in a transaction * - * @throws \Exception Re-throws a possible Exception triggered by the callable. + * @throws \Throwable Re-throws a possible Throwable triggered by the callable. * * @return mixed Returns the result of the callable. */ @@ -37,7 +37,7 @@ public function transaction(callable $callable) $this->commit(); return $result; - } catch (Exception $e) { + } catch (Throwable $e) { $this->rollBack(); throw $e; From 2a74711977a135df135f8eb4ac25a772a3d71f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C3=B3jcik?= Date: Wed, 9 Sep 2020 17:28:57 +0200 Subject: [PATCH 151/208] CS fix --- src/Propel/Common/Util/SetColumnConverter.php | 2 +- src/Propel/Generator/Builder/Om/AbstractOMBuilder.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Propel/Common/Util/SetColumnConverter.php b/src/Propel/Common/Util/SetColumnConverter.php index 172021fa56..b56e9b955a 100644 --- a/src/Propel/Common/Util/SetColumnConverter.php +++ b/src/Propel/Common/Util/SetColumnConverter.php @@ -43,7 +43,7 @@ public static function convertToInt($val, array $valueSet) $bitValueArr[array_search($value, $valueSet)] = '1'; } - return base_convert(implode(array_reverse($bitValueArr)), 2, 10); + return base_convert(implode('', array_reverse($bitValueArr)), 2, 10); } /** diff --git a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php index 557cfe5044..8c54934d92 100644 --- a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php @@ -688,7 +688,7 @@ protected function getCrossFKsPhpNameAffix(CrossForeignKeys $crossFKs, $plural = $names[] = $this->getFKPhpNameAffix($fk, $needPlural); } - return implode($names); + return implode('', $names); } } else { // no plural, so $plural=false @@ -701,7 +701,7 @@ protected function getCrossFKsPhpNameAffix(CrossForeignKeys $crossFKs, $plural = $names[] = $pk->getPhpName(); } - $name = implode($names); + $name = implode('', $names); return ($plural === true ? $this->getPluralizer()->getPluralForm($name) : $name); } @@ -728,7 +728,7 @@ protected function getCrossRefFKGetterName(CrossForeignKeys $crossFKs, ForeignKe $names[] = $pk->getPhpName(); } - $name = implode($names); + $name = implode('', $names); return $this->getPluralizer()->getPluralForm($name); } @@ -757,7 +757,7 @@ protected function getCrossFKInformation(CrossForeignKeys $crossFKs) } $names = implode(', ', $names) . (1 < count($names) ? ' combination' : ''); - $phpDoc = implode($phpDoc); + $phpDoc = implode('', $phpDoc); $signatures = implode(', ', $signatures); $shortSignature = implode(', ', $shortSignature); From e82b0a0b309a8483572128d09222f1832b4a1a84 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 10 Sep 2020 10:29:51 +0200 Subject: [PATCH 152/208] Fix CS. --- composer.json | 2 +- config/phpcs.xml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b575a762d9..cc921b1f98 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "monolog/monolog": "^1.3", "phpstan/phpstan": "^0.12.4", "phpunit/phpunit": "^7.5.15", - "spryker/code-sniffer": "^0.15.4" + "spryker/code-sniffer": "^0.15.6" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." diff --git a/config/phpcs.xml b/config/phpcs.xml index 492d13a5d3..2c9b34fb9c 100644 --- a/config/phpcs.xml +++ b/config/phpcs.xml @@ -10,6 +10,11 @@ */templates/* + + + 0 + + 0 From 2b7bd482a3f6d3b1f1c5af332be3382089218952 Mon Sep 17 00:00:00 2001 From: FranciszekKrasowski <43750184+FranciszekKrasowski@users.noreply.github.com> Date: Mon, 28 Sep 2020 01:33:46 +0200 Subject: [PATCH 153/208] Update composer.json --- composer.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index cc921b1f98..d94199bf4a 100644 --- a/composer.json +++ b/composer.json @@ -17,13 +17,13 @@ ], "require": { "php": ">=7.2", - "symfony/yaml": "^3.4.0||^4.3.0||^5.0.0", - "symfony/config": "^3.4.0||^4.3.0||^5.0.0", - "symfony/console": "^3.4.0||^4.3.0||^5.0.0", - "symfony/filesystem": "^3.4.0||^4.3.0||^5.0.0", - "symfony/finder": "^3.4.0||^4.3.0||^5.0.0", - "symfony/translation": "^3.4.0||^4.3.0||^5.0.0", - "symfony/validator": "^3.4.0||^4.3.0||^5.0.0", + "symfony/yaml": "^3.4.0||^4.0.0||^5.0.0", + "symfony/config": "^3.4.0||^4.0.0||^5.0.0", + "symfony/console": "^3.4.0||^4.0.0||^5.0.0", + "symfony/filesystem": "^3.4.0||^4.0.0||^5.0.0", + "symfony/finder": "^3.4.0||^4.0.0||^5.0.0", + "symfony/translation": "^3.4.0||^4.0.0||^5.0.0", + "symfony/validator": "^3.4.0||^4.0.0||^5.0.0", "psr/log": "^1.0" }, "require-dev": { From b15cb41f4097d43e67a1de35fc4bd64336ed0e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C3=B3jcik?= Date: Fri, 29 Sep 2017 16:07:57 +0200 Subject: [PATCH 154/208] reproduction --- tests/Propel/Tests/Issues/Issue1420Test.php | 105 ++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 tests/Propel/Tests/Issues/Issue1420Test.php diff --git a/tests/Propel/Tests/Issues/Issue1420Test.php b/tests/Propel/Tests/Issues/Issue1420Test.php new file mode 100644 index 0000000000..4ac71221b5 --- /dev/null +++ b/tests/Propel/Tests/Issues/Issue1420Test.php @@ -0,0 +1,105 @@ + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+
+XML; + QuickBuilder::buildSchema($schema); + } + } + + protected function tearDown() + { + parent::tearDown(); + \Table1420CQuery::create()->deleteAll(); + \Table1420BQuery::create()->deleteAll(); + \Table1420AQuery::create()->deleteAll(); + } + + /* + * Test whether hydration works properly for all the models + */ + public function testValidHydration() + { + // Set up 3 models in relations A hasMany B, A hasMany C + // A: id=1, a_field=a_value + // B: id=2, b_field=b_value (referenced to A:1) + // C: id=3, c_field=c_value (referenced to A:1) + (new \Table1420A)->setId(1)->setAField('a_value')->save(); + (new \Table1420B)->setId(2)->setTable1420AId(1)->setBField('b_value')->save(); + (new \Table1420C)->setId(3)->setTable1420AId(1)->setCField('c_value')->save(); + + // querying for A models together with B models hydrated + $aQuery = (new \Table1420AQuery)->leftJoinWith('Table1420B'); + + // merged criteria has with model and adds self columns (because it's primary criteria) + $mergeWith = (new \Table1420AQuery)->leftJoinWith('Table1420C'); + + // merging queries together results produces these columns in SELECT part: + // A columns, B columns (base criteria), A columns again, C columns + // "A columns again" causes the further models be hydrated with wrong data + // (here C is hydrated partially from A columns) + $aQuery->mergeWith($mergeWith); + + $a = $aQuery->find()->getFirst(); + + $this->assertSame(1, $a->getId()); + $this->assertSame('a_value', $a->getAField()); + + $b = $a->getTable1420Bs()->getFirst(); + $this->assertSame(2, $b->getId()); + $this->assertSame(1, $b->getTable1420AId()); + $this->assertSame('b_value', $b->getBField()); + + $c = $a->getTable1420Cs()->getFirst(); + $this->assertSame(3, $c->getId()); + $this->assertSame(1, $c->getTable1420AId()); + $this->assertSame('c_value', $c->getCField()); + } +} From 061a5f1829e560c4d88ebfa32cb6de116df0fbe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C3=B3jcik?= Date: Wed, 9 Sep 2020 17:24:45 +0200 Subject: [PATCH 155/208] fix + tests --- .../Generator/Builder/Om/TableMapBuilder.php | 48 +++++++++++++++++++ src/Propel/Runtime/ActiveQuery/Criteria.php | 16 +++++++ .../Runtime/ActiveQuery/ModelCriteria.php | 42 ++++++++++++++++ .../Runtime/ActiveQuery/ModelCriteriaTest.php | 4 ++ 4 files changed, 110 insertions(+) diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index 0d18706f09..d2024acaf7 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -190,6 +190,7 @@ protected function addClassBody(&$script) protected function addSelectMethods(&$script) { $this->addAddSelectColumns($script); + $this->addRemoveSelectColumns($script); } /** @@ -1271,6 +1272,53 @@ public static function addSelectColumns(Criteria \$criteria, \$alias = null) // addAddSelectColumns() + /** + * Adds the removeSelectColumns() method. + * + * @param string &$script The script will be modified in this method. + * + * @return void + */ + protected function addRemoveSelectColumns(&$script) + { + $script .= " + /** + * Remove all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad=\"true\" in the + * XML schema will not be removed as they are only loaded on demand. + * + * @param Criteria \$criteria object containing the columns to remove. + * @param string \$alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function removeSelectColumns(Criteria \$criteria, \$alias = null) + { + if (null === \$alias) {"; + foreach ($this->getTable()->getColumns() as $col) { + if (!$col->isLazyLoad()) { + $script .= " + \$criteria->removeSelectColumn({$col->getFQConstantName()});"; + } // if !col->isLazyLoad + } // foreach + $script .= " + } else {"; + foreach ($this->getTable()->getColumns() as $col) { + if (!$col->isLazyLoad()) { + $script .= " + \$criteria->removeSelectColumn(\$alias . '." . $col->getName() . "');"; + } // if !col->isLazyLoad + } // foreach + $script .= " + }"; + $script .= " + } +"; + } + + // addRemoveSelectColumns() + /** * Adds the getTableMap() method which is a convenience method for apps to get DB metadata. * diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index 3d164ebee7..9e87162bb4 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -1363,6 +1363,22 @@ public function addSelectColumn($name) return $this; } + /** + * Remove select column. + * + * @param string $name Name of the select column. + * + * @return $this Modified Criteria object (for fluent API) + */ + public function removeSelectColumn($name) + { + while (false !== ($key = array_search($name, $this->selectColumns, true))) { + unset($this->selectColumns[$key]); + } + + return $this; + } + /** * Set the query comment, that appears after the first verb in the SQL query * diff --git a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php index 84411f1e4d..529de5e716 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php @@ -843,6 +843,18 @@ public function endUse() */ public function mergeWith(Criteria $criteria, $operator = null) { + if ( + $criteria instanceof ModelCriteria + && !$criteria->getPrimaryCriteria() + && $criteria->isSelfColumnsSelected() + && $criteria->getWith() + ) { + if (!$this->isSelfColumnsSelected()) { + $this->addSelfSelectColumns(); + } + $criteria->removeSelfSelectColumns(); + } + parent::mergeWith($criteria, $operator); // merge with @@ -948,6 +960,36 @@ public function addSelfSelectColumns($force = false) return $this; } + /** + * Removes the select columns for the current table + * + * @param bool $force To enforce removing columns for changed alias, set it to true (f.e. with sub selects) + * + * @return $this The current object, for fluid interface + */ + public function removeSelfSelectColumns($force = false) + { + if (!$this->isSelfSelected && !$force) { + return $this; + } + + $tableMap = $this->modelTableMapName; + $tableMap::removeSelectColumns($this, $this->useAliasInSQL ? $this->modelAlias : null); + $this->isSelfSelected = false; + + return $this; + } + + /** + * Returns whether select columns for the current table are included + * + * @return bool + */ + public function isSelfColumnsSelected() + { + return $this->isSelfSelected; + } + /** * Adds the select columns for a relation * diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php index 6c4eadd19f..5f9d9d7036 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php @@ -2990,6 +2990,7 @@ public function testMergeWithWiths() $c1->leftJoinWith('b.Author a'); $c2 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Author'); $c1->mergeWith($c2); + $this->assertCount(1, array_filter($c1->getSelectColumns(), function($v) { return BookTableMap::COL_ID == $v; }), '$c1 criteria has selected Book columns twice'); $with = $c1->getWith(); $this->assertEquals(1, count($with), 'mergeWith() does not remove an existing join'); $this->assertEquals('modelName: Propel\Tests\Bookstore\Author, relationName: Author, relationMethod: setAuthor, leftPhpName: , rightPhpName: a', $with['a']->__toString(), 'mergeWith() does not remove an existing join'); @@ -2998,6 +2999,7 @@ public function testMergeWithWiths() $c1->leftJoinWith('b.Author a'); $c2 = new ModelCriteria('bookstore', '\Propel\Tests\Bookstore\Author'); $c1->mergeWith($c2); + $this->assertCount(1, array_filter($c1->getSelectColumns(), function($v) { return BookTableMap::COL_ID == $v; }), '$c1 criteria has selected Book columns twice'); $with = $c1->getWith(); $this->assertEquals(1, count($with), 'mergeWith() does not remove an existing join'); $this->assertEquals('modelName: Propel\Tests\Bookstore\Author, relationName: Author, relationMethod: setAuthor, leftPhpName: , rightPhpName: a', $with['a']->__toString(), 'mergeWith() does not remove an existing join'); @@ -3006,6 +3008,7 @@ public function testMergeWithWiths() $c2 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); $c2->leftJoinWith('b.Author a'); $c1->mergeWith($c2); + $this->assertCount(1, array_filter($c1->getSelectColumns(), function($v) { return BookTableMap::COL_ID == $v; }), '$c1 criteria has selected Book columns twice'); $with = $c1->getWith(); $this->assertEquals(1, count($with), 'mergeWith() merge joins to an empty join'); $this->assertEquals('modelName: Propel\Tests\Bookstore\Author, relationName: Author, relationMethod: setAuthor, leftPhpName: , rightPhpName: a', $with['a']->__toString(), 'mergeWith() merge joins to an empty join'); @@ -3015,6 +3018,7 @@ public function testMergeWithWiths() $c2 = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book', 'b'); $c2->innerJoinWith('b.Publisher p'); $c1->mergeWith($c2); + $this->assertCount(1, array_filter($c1->getSelectColumns(), function($v) { return BookTableMap::COL_ID == $v; }), '$c1 criteria has selected Book columns twice'); $with = $c1->getWith(); $this->assertEquals(2, count($with), 'mergeWith() merge joins to an existing join'); $this->assertEquals('modelName: Propel\Tests\Bookstore\Author, relationName: Author, relationMethod: setAuthor, leftPhpName: , rightPhpName: a', $with['a']->__toString(), 'mergeWith() merge joins to an empty join'); From 755fbe6e5ce0de8e1432cb576071619d4f8d2955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C3=B3jcik?= Date: Wed, 14 Oct 2020 00:05:59 +0200 Subject: [PATCH 156/208] CS fix --- src/Propel/Generator/Builder/Om/TableMapBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index d2024acaf7..0d1b4a8bc9 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -1275,7 +1275,7 @@ public static function addSelectColumns(Criteria \$criteria, \$alias = null) /** * Adds the removeSelectColumns() method. * - * @param string &$script The script will be modified in this method. + * @param string $script The script will be modified in this method. * * @return void */ From 56edf9a68fd216b2a084e8502771663b028cc33c Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Wed, 21 Oct 2020 23:27:43 +0300 Subject: [PATCH 157/208] Adapt StatementWrapper for PHP8/PHP7, fix minor issues --- src/Propel/Generator/Util/QuickBuilder.php | 3 +- src/Propel/Generator/Util/SqlParser.php | 3 +- src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php | 21 +- .../Runtime/Adapter/SqlAdapterInterface.php | 21 +- .../Runtime/Connection/PdoConnection.php | 12 +- .../Runtime/Connection/StatementInterface.php | 376 ++++++++++++++++++ .../Runtime/Connection/StatementWrapper.php | 86 +++- .../StandardServiceContainer.php | 2 +- tests/bin/phpunit.pgsql.sh | 2 +- 9 files changed, 494 insertions(+), 32 deletions(-) create mode 100644 src/Propel/Runtime/Connection/StatementInterface.php diff --git a/src/Propel/Generator/Util/QuickBuilder.php b/src/Propel/Generator/Util/QuickBuilder.php index d8a98f55a2..706a3088a9 100644 --- a/src/Propel/Generator/Util/QuickBuilder.php +++ b/src/Propel/Generator/Util/QuickBuilder.php @@ -24,6 +24,7 @@ use Propel\Runtime\Connection\PdoConnection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Connection\ConnectionWrapper; +use Propel\Runtime\Connection\StatementWrapper; use Propel\Runtime\Propel; class QuickBuilder @@ -227,7 +228,7 @@ public function buildSQL(ConnectionInterface $con) } try { $stmt = $con->prepare($statement); - if ($stmt instanceof \PDOStatement) { + if ($stmt instanceof StatementWrapper) { // only execute if has no error $stmt->execute(); } diff --git a/src/Propel/Generator/Util/SqlParser.php b/src/Propel/Generator/Util/SqlParser.php index 1a2b75a259..0f12595fea 100644 --- a/src/Propel/Generator/Util/SqlParser.php +++ b/src/Propel/Generator/Util/SqlParser.php @@ -11,6 +11,7 @@ namespace Propel\Generator\Util; use \Propel\Runtime\Connection\ConnectionInterface; +use \Propel\Runtime\Connection\StatementInterface; /** * Service class for parsing a large SQL string into an array of SQL statements @@ -92,7 +93,7 @@ protected static function executeStatements($statements, ConnectionInterface $co foreach ($statements as $statement) { $stmt = $connection->prepare($statement); - if ($stmt instanceof \PDOStatement) { + if ($stmt instanceof StatementInterface) { // only execute if has no error $stmt->execute(); $executed++; diff --git a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php index cdac51083a..cccae4f2cb 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php @@ -14,6 +14,7 @@ use Propel\Runtime\Adapter\Exception\AdapterException; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Connection\PdoConnection; +use Propel\Runtime\Connection\StatementWrapper; use Propel\Runtime\Exception\InvalidArgumentException; use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\DatabaseMap; @@ -551,11 +552,11 @@ public function turnSelectColumnsToAliases(Criteria $criteria) * $stmt->execute(); * * - * @param \PDOStatement $stmt - * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) - * @param DatabaseMap $dbMap + * @param StatementWrapper $stmt + * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) + * @param DatabaseMap $dbMap */ - public function bindValues(\PDOStatement $stmt, array $params, DatabaseMap $dbMap) + public function bindValues(StatementWrapper $stmt, array $params, DatabaseMap $dbMap) { $position = 0; foreach ($params as $param) { @@ -581,15 +582,15 @@ public function bindValues(\PDOStatement $stmt, array $params, DatabaseMap $dbMa * Binds a value to a positioned parameter in a statement, * given a ColumnMap object to infer the binding type. * - * @param \PDOStatement $stmt The statement to bind - * @param string $parameter Parameter identifier - * @param mixed $value The value to bind - * @param ColumnMap $cMap The ColumnMap of the column to bind - * @param null|integer $position The position of the parameter to bind + * @param StatementWrapper $stmt The statement to bind + * @param string $parameter Parameter identifier + * @param mixed $value The value to bind + * @param ColumnMap $cMap The ColumnMap of the column to bind + * @param null|integer $position The position of the parameter to bind * * @return boolean */ - public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(StatementWrapper $stmt, $parameter, $value, ColumnMap $cMap, $position = null) { if ($cMap->isTemporal()) { $value = $this->formatTemporalValue($value, $cMap); diff --git a/src/Propel/Runtime/Adapter/SqlAdapterInterface.php b/src/Propel/Runtime/Adapter/SqlAdapterInterface.php index de7d3e9211..b6d74b3483 100644 --- a/src/Propel/Runtime/Adapter/SqlAdapterInterface.php +++ b/src/Propel/Runtime/Adapter/SqlAdapterInterface.php @@ -10,6 +10,7 @@ namespace Propel\Runtime\Adapter; +use Propel\Runtime\Connection\StatementWrapper; use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\DatabaseMap; use Propel\Runtime\ActiveQuery\Criteria; @@ -112,23 +113,23 @@ public function turnSelectColumnsToAliases(Criteria $criteria); * $stmt->execute(); * * - * @param \PDOStatement $stmt - * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) - * @param DatabaseMap $dbMap + * @param StatementWrapper $stmt + * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) + * @param DatabaseMap $dbMap */ - public function bindValues(\PDOStatement $stmt, array $params, DatabaseMap $dbMap); + public function bindValues(StatementWrapper $stmt, array $params, DatabaseMap $dbMap); /** * Binds a value to a positioned parameter in a statement, * given a ColumnMap object to infer the binding type. * - * @param \PDOStatement $stmt The statement to bind - * @param string $parameter Parameter identifier - * @param mixed $value The value to bind - * @param ColumnMap $cMap The ColumnMap of the column to bind - * @param null|integer $position The position of the parameter to bind + * @param StatementWrapper $stmt The statement to bind + * @param string $parameter Parameter identifier + * @param mixed $value The value to bind + * @param ColumnMap $cMap The ColumnMap of the column to bind + * @param null|integer $position The position of the parameter to bind * * @return boolean */ - public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null); + public function bindValue(StatementWrapper $stmt, $parameter, $value, ColumnMap $cMap, $position = null); } diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index 7a98edd0a4..d797d4b952 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -98,7 +98,7 @@ public function setAttribute($attribute, $value) $attribute = constant($attribute); } - $this->pdo->setAttribute($attribute, $value); + return $this->pdo->setAttribute($attribute, $value); } /** @@ -122,7 +122,7 @@ public function getSingleDataFetcher($data) */ public function query($statement) { - $this->pdo->query($statement); + return $this->pdo->query($statement); } /** @@ -135,11 +135,17 @@ public function exec($statement) return $this->getDataFetcher($stmt); } + /** + * {@inheritDoc} + */ public function inTransaction() { - // TODO: Implement inTransaction() method. + return $this->pdo->inTransaction(); } + /** + * {@inheritDoc} + */ public function getAttribute(int $attribute) { return $this->pdo->getAttribute($attribute); diff --git a/src/Propel/Runtime/Connection/StatementInterface.php b/src/Propel/Runtime/Connection/StatementInterface.php new file mode 100644 index 0000000000..6852fbdebd --- /dev/null +++ b/src/Propel/Runtime/Connection/StatementInterface.php @@ -0,0 +1,376 @@ + + * An array of values with as many elements as there are bound + * parameters in the SQL statement being executed. + * All values are treated as PDO::PARAM_STR. + *

+ *

+ * You cannot bind multiple values to a single parameter; for example, + * you cannot bind two values to a single named parameter in an IN() + * clause. + *

+ *

+ * You cannot bind more values than specified; if more keys exist in + * input_parameters than in the SQL specified + * in the PDO::prepare, then the statement will + * fail and an error is emitted. + *

+ * @return bool TRUE on success or FALSE on failure. + * @throws \PDOException On error if PDO::ERRMODE_EXCEPTION option is true. + */ + public function execute($input_parameters = null); + + /** + * Fetches the next row from a result set + * @param int $fetch_style [optional]

+ * Controls how the next row will be returned to the caller. This value + * must be one of the PDO::FETCH_* constants, + * defaulting to value of PDO::ATTR_DEFAULT_FETCH_MODE + * (which defaults to PDO::FETCH_BOTH). + *

+ * PDO::FETCH_ASSOC: returns an array indexed by column + * name as returned in your result set + *

+ * @param int $cursor_orientation [optional]

+ * For a PDOStatement object representing a scrollable cursor, this + * value determines which row will be returned to the caller. This value + * must be one of the PDO::FETCH_ORI_* constants, + * defaulting to PDO::FETCH_ORI_NEXT. To request a + * scrollable cursor for your PDOStatement object, you must set the + * PDO::ATTR_CURSOR attribute to + * PDO::CURSOR_SCROLL when you prepare the SQL + * statement with PDO::prepare. + *

+ * @param int $cursor_offset [optional] + * @return mixed The return value of this function on success depends on the fetch type. In + * all cases, FALSE is returned on failure. + */ + public function fetch($fetch_style = null, $cursor_orientation = PDO::FETCH_ORI_NEXT, $cursor_offset = 0); + + /** + * Binds a parameter to the specified variable name + * @param mixed $parameter

+ * Parameter identifier. For a prepared statement using named + * placeholders, this will be a parameter name of the form + * :name. For a prepared statement using + * question mark placeholders, this will be the 1-indexed position of + * the parameter. + *

+ * @param mixed $variable

+ * Name of the PHP variable to bind to the SQL statement parameter. + *

+ * @param int $data_type [optional]

+ * Explicit data type for the parameter using the PDO::PARAM_* + * constants. + * To return an INOUT parameter from a stored procedure, + * use the bitwise OR operator to set the PDO::PARAM_INPUT_OUTPUT bits + * for the data_type parameter. + *

+ * @param int $length [optional]

+ * Length of the data type. To indicate that a parameter is an OUT + * parameter from a stored procedure, you must explicitly set the + * length. + *

+ * @param mixed $driver_options [optional]

+ *

+ * @return bool TRUE on success or FALSE on failure. + */ + public function bindParam($parameter, &$variable, $data_type = PDO::PARAM_STR, $length = null, $driver_options = null); + + /** + * Bind a column to a PHP variable + * @param mixed $column

+ * Number of the column (1-indexed) or name of the column in the result set. + * If using the column name, be aware that the name should match the + * case of the column, as returned by the driver. + *

+ * @param mixed $param

+ * Name of the PHP variable to which the column will be bound. + *

+ * @param int $type [optional]

+ * Data type of the parameter, specified by the PDO::PARAM_* constants. + *

+ * @param int $maxlen [optional]

+ * A hint for pre-allocation. + *

+ * @param mixed $driverdata [optional]

+ * Optional parameter(s) for the driver. + *

+ * @return bool TRUE on success or FALSE on failure. + */ + public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null); + + /** + * Binds a value to a parameter + * @param mixed $parameter

+ * Parameter identifier. For a prepared statement using named + * placeholders, this will be a parameter name of the form + * :name. For a prepared statement using + * question mark placeholders, this will be the 1-indexed position of + * the parameter. + *

+ * @param mixed $value

+ * The value to bind to the parameter. + *

+ * @param int $data_type [optional]

+ * Explicit data type for the parameter using the PDO::PARAM_* + * constants. + *

+ * @return bool TRUE on success or FALSE on failure. + */ + public function bindValue($parameter, $value, $data_type = PDO::PARAM_STR); + + /** + * Returns the number of rows affected by the last SQL statement + * @return int the number of rows. + */ + public function rowCount(); + + /** + * Returns a single column from the next row of a result set + * @param int $column_number [optional]

+ * 0-indexed number of the column you wish to retrieve from the row. If + * no value is supplied, PDOStatement::fetchColumn + * fetches the first column. + *

+ * @return mixed Returns a single column from the next row of a result + * set or FALSE if there are no more rows. + *

+ *

+ * There is no way to return another column from the same row if you + * use PDOStatement::fetchColumn to retrieve data. + */ + public function fetchColumn($column_number = 0); + + /** + * Returns an array containing all of the result set rows + * @param int $fetch_style [optional]

+ * Controls the contents of the returned array as documented in + * PDOStatement::fetch. + * Defaults to value of PDO::ATTR_DEFAULT_FETCH_MODE + * (which defaults to PDO::FETCH_BOTH) + *

+ *

+ * To return an array consisting of all values of a single column from + * the result set, specify PDO::FETCH_COLUMN. You + * can specify which column you want with the + * column-index parameter. + *

+ *

+ * To fetch only the unique values of a single column from the result set, + * bitwise-OR PDO::FETCH_COLUMN with + * PDO::FETCH_UNIQUE. + *

+ *

+ * To return an associative array grouped by the values of a specified + * column, bitwise-OR PDO::FETCH_COLUMN with + * PDO::FETCH_GROUP. + *

+ * @param mixed $fetch_argument [optional]

+ * This argument have a different meaning depending on the value of + * the fetch_style parameter: + *

+ * PDO::FETCH_COLUMN: Returns the indicated 0-indexed + * column. + *

+ * @param array $ctor_args [optional]

+ * Arguments of custom class constructor when the fetch_style + * parameter is PDO::FETCH_CLASS. + *

+ * @return array PDOStatement::fetchAll returns an array containing + * all of the remaining rows in the result set. The array represents each + * row as either an array of column values or an object with properties + * corresponding to each column name. + *

+ *

+ * Using this method to fetch large result sets will result in a heavy + * demand on system and possibly network resources. Rather than retrieving + * all of the data and manipulating it in PHP, consider using the database + * server to manipulate the result sets. For example, use the WHERE and + * ORDER BY clauses in SQL to restrict results before retrieving and + * processing them with PHP. + */ + public function fetchAll($fetch_style = null, $fetch_argument = null, array $ctor_args = array()); + + /** + * Fetches the next row and returns it as an object. + * @param string $class_name [optional]

+ * Name of the created class. + *

+ * @param array $ctor_args [optional]

+ * Elements of this array are passed to the constructor. + *

+ * @return mixed an instance of the required class with property names that + * correspond to the column names or FALSE on failure. + */ + public function fetchObject($class_name = "stdClass", array $ctor_args = array()); + + /** + * Fetch the SQLSTATE associated with the last operation on the statement handle + * @return string Identical to PDO::errorCode, except that + * PDOStatement::errorCode only retrieves error codes + * for operations performed with PDOStatement objects. + */ + public function errorCode(); + + /** + * Fetch extended error information associated with the last operation on the statement handle + * @return array PDOStatement::errorInfo returns an array of + * error information about the last operation performed by this + * statement handle. The array consists of the following fields: + * + * Element + * Information + * + * + * 0 + * SQLSTATE error code (a five characters alphanumeric identifier defined + * in the ANSI SQL standard). + * + * + * 1 + * Driver specific error code. + * + * + * 2 + * Driver specific error message. + * + */ + public function errorInfo(); + + /** + * Set a statement attribute + * @param int $attribute + * @param mixed $value + * @return bool TRUE on success or FALSE on failure. + */ + public function setAttribute($attribute, $value); + + /** + * Retrieve a statement attribute + * @param int $attribute + * @return mixed the attribute value. + */ + public function getAttribute($attribute); + + /** + * Returns the number of columns in the result set + * @return int the number of columns in the result set represented by the + * StatementInterface object. If there is no result set, + * StatementInterface::columnCount returns 0. + */ + public function columnCount(); + + /** + * Returns metadata for a column in a result set + * @param int $column

+ * The 0-indexed column in the result set. + *

+ * @return array|false an associative array containing the following values representing + * the metadata for a single column: + *

+ * + * Column metadata + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
NameValue
native_typeThe PHP native type used to represent the column value.
driver:decl_typeThe SQL type used to represent the column value in the database. + * If the column in the result set is the result of a function, this value + * is not returned by PDOStatement::getColumnMeta. + *
flagsAny flags set for this column.
nameThe name of this column as returned by the database.
tableThe name of this column's table as returned by the database.
lenThe length of this column. Normally -1 for + * types other than floating point decimals.
precisionThe numeric precision of this column. Normally + * 0 for types other than floating point + * decimals.
pdo_typeThe type of this column as represented by the + * PDO::PARAM_* constants.
+ *

+ * Returns FALSE if the requested column does not exist in the result set, + * or if no result set exists. + */ + public function getColumnMeta($column); + + /** + * Set the default fetch mode for this statement + * @param int $mode

+ * The fetch mode must be one of the PDO::FETCH_* constants. + *

+ * @param string|object $classNameObject [optional]

+ * Class name or object + *

+ * @param array $ctorarfg [optional]

Constructor arguments.

+ * @return bool TRUE on success or FALSE on failure. + */ + public function setFetchMode($mode, $classNameObject = null, array $ctorarfg = array()); + + /** + * Advances to the next rowset in a multi-rowset statement handle + * @return bool TRUE on success or FALSE on failure. + */ + public function nextRowset(); + + /** + * Closes the cursor, enabling the statement to be executed again. + * @return bool TRUE on success or FALSE on failure. + */ + public function closeCursor(); + + /** + * Dump an SQL prepared command + * @return bool No value is returned. + */ + public function debugDumpParams(); +} diff --git a/src/Propel/Runtime/Connection/StatementWrapper.php b/src/Propel/Runtime/Connection/StatementWrapper.php index 7bbfe0bff9..3008239ab5 100644 --- a/src/Propel/Runtime/Connection/StatementWrapper.php +++ b/src/Propel/Runtime/Connection/StatementWrapper.php @@ -14,7 +14,7 @@ * Wraps a Statement class, providing logging. * */ -class StatementWrapper extends \PDOStatement implements \IteratorAggregate +class StatementWrapper implements StatementInterface, \IteratorAggregate { /** @@ -82,9 +82,11 @@ public function prepare($options) */ public function query() { - $this->statement = $this->connection->getWrappedConnection()->query($this->sql); + $wrapped_connection = $this->connection->getWrappedConnection(); - return $this->connection->getWrappedConnection()->getDataFetcher($this); + $this->statement = $wrapped_connection->query($this->sql); + + return $wrapped_connection->getDataFetcher($this); } /** @@ -324,9 +326,83 @@ public function getBoundValues() return $this->boundValues; } - public function __call($method, $args) + /** + * {@inheritDoc} + */ + public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null) + { + return $this->statement->bindColumn($column, $param, $type, $maxlen, $driverdata); + } + + /** + * {@inheritDoc} + */ + public function fetchObject($class_name = "stdClass", array $ctor_args = array()) + { + return $this->statement->fetchObject($class_name, $ctor_args); + } + + /** + * {@inheritDoc} + */ + public function errorCode() + { + return $this->statement->errorCode(); + } + + /** + * {@inheritDoc} + */ + public function errorInfo() + { + return $this->statement->errorInfo(); + } + + /** + * {@inheritDoc} + */ + public function setAttribute($attribute, $value) { - return call_user_func_array([$this->statement, $method], $args); + return $this->statement->setAttribute($attribute, $value); } + /** + * {@inheritDoc} + */ + public function getAttribute($attribute) + { + return $this->statement->getAttribute($attribute); + } + + /** + * {@inheritDoc} + */ + public function getColumnMeta($column) + { + return $this->statement->getColumnMeta($column); + } + + /** + * {@inheritDoc} + */ + public function setFetchMode($mode, $classNameObject = null, array $ctorarfg = array()) + { + return $this->statement->setFetchMode($mode, $classNameObject, $ctorarfg); + } + + /** + * {@inheritDoc} + */ + public function nextRowset() + { + return $this->statement->nextRowset(); + } + + /** + * {@inheritDoc} + */ + public function debugDumpParams() + { + return $this->statement->debugDumpParams(); + } } diff --git a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php index 6f5616c487..8b4e172d09 100644 --- a/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php +++ b/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php @@ -532,7 +532,7 @@ public function setLoggerConfiguration($name, $loggerConfiguration) $this->loggerConfigurations[$name] = $loggerConfiguration; } - final private function __clone() + private function __clone() { } } diff --git a/tests/bin/phpunit.pgsql.sh b/tests/bin/phpunit.pgsql.sh index 74f4691504..0a0735c8a8 100755 --- a/tests/bin/phpunit.pgsql.sh +++ b/tests/bin/phpunit.pgsql.sh @@ -1,3 +1,3 @@ #!/bin/sh -./vendor/bin/phpunit -c tests/pgsql.phpunit.xml $@ \ No newline at end of file +./vendor/bin/phpunit -c tests/pgsql.phpunit.xml $@ From 778a2bd73d78a4b8815904ed3c4ec4080d5acd43 Mon Sep 17 00:00:00 2001 From: Chuong Nguyen Date: Thu, 22 Oct 2020 15:21:50 +0700 Subject: [PATCH 158/208] #1659 skip incomplete check for non-primary foreign key --- src/Propel/Generator/Model/ForeignKey.php | 24 ++++ src/Propel/Generator/Model/Table.php | 2 +- .../Generator/Builder/Om/QueryBuilderTest.php | 23 ++++ .../Tests/Generator/Model/ForeignKeyTest.php | 55 +++++++++ tests/Propel/Tests/Issues/Issue1659Test.php | 106 ++++++++++++++++++ 5 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 tests/Propel/Tests/Issues/Issue1659Test.php diff --git a/src/Propel/Generator/Model/ForeignKey.php b/src/Propel/Generator/Model/ForeignKey.php index a356189848..bb5c73090b 100644 --- a/src/Propel/Generator/Model/ForeignKey.php +++ b/src/Propel/Generator/Model/ForeignKey.php @@ -835,6 +835,30 @@ public function isForeignPrimaryKey() && !array_diff($foreignPKCols, $foreignCols)); } + /** + * Returns whether this foreign key is not the primary key of the foreign + * table. + * + * @return bool Returns true if all columns inside this foreign key are not primary keys of the foreign table + */ + public function isForeignNonPrimaryKey() + { + $foreignTable = $this->getForeignTable(); + + $foreignPKCols = []; + foreach ($foreignTable->getPrimaryKey() as $fPKCol) { + $foreignPKCols[] = $fPKCol->getName(); + } + + $foreignCols = []; + foreach ($this->localColumns as $idx => $colName) { + if ($this->foreignColumns[$idx]) { + $foreignCols[] = $foreignTable->getColumn($this->foreignColumns[$idx])->getName(); + } + } + return (bool)array_diff($foreignCols, $foreignPKCols); + } + /** * Returns whether or not this foreign key relies on more than one * column binding. diff --git a/src/Propel/Generator/Model/Table.php b/src/Propel/Generator/Model/Table.php index 23a0364a9e..1b91e685ec 100644 --- a/src/Propel/Generator/Model/Table.php +++ b/src/Propel/Generator/Model/Table.php @@ -921,7 +921,7 @@ public function setupReferrers($throwErrors = false) // check for incomplete foreign key references when foreign table // has a composite primary key - if ($foreignTable->hasCompositePrimaryKey()) { + if ($foreignTable->hasCompositePrimaryKey() && !$foreignKey->isForeignNonPrimaryKey()) { // get composite foreign key's keys $foreignPrimaryKeys = $foreignTable->getPrimaryKey(); // check all keys are referenced in foreign key diff --git a/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php b/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php index 112fa38235..b5723e34e9 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php @@ -13,15 +13,18 @@ use Propel\Runtime\ActiveQuery\ModelJoin; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Propel; +use Propel\Tests\Bookstore\AcctAuditLogQuery; use Propel\Tests\Bookstore\AuthorQuery; use Propel\Tests\Bookstore\Book; use Propel\Tests\Bookstore\BookClubListQuery; use Propel\Tests\Bookstore\BookListRelQuery; use Propel\Tests\Bookstore\BookOpinionQuery; use Propel\Tests\Bookstore\BookQuery; +use Propel\Tests\Bookstore\BookstoreEmployeeAccount; use Propel\Tests\Bookstore\BookstoreEmployeeAccountQuery; use Propel\Tests\Bookstore\BookSummaryQuery; use Propel\Tests\Bookstore\EssayQuery; +use Propel\Tests\Bookstore\Map\AcctAuditLogTableMap; use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Map\BookListRelTableMap; use Propel\Tests\Bookstore\Map\BookstoreEmployeeAccountTableMap; @@ -884,6 +887,26 @@ public function testFilterUsingCollectionByRelationNameCompositePk() $this->fail('Expected PropelException : filterBy{RelationName}() only accepts arguments of type {RelationName}'); } + /** + * @return void + */ + public function testFilterByRefNonPrimaryFKey() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + $testBookstoreEmployeeAccount = BookstoreEmployeeAccountQuery::create() + ->findOne(); + $testAccAuditLog = $testBookstoreEmployeeAccount->getAcctAuditLogs(); + + $result = AcctAuditLogQuery::create() + ->addJoin(AcctAuditLogTableMap::COL_UID, BookstoreEmployeeAccountTableMap::COL_LOGIN) + ->filterByBookstoreEmployeeAccount($testBookstoreEmployeeAccount) + ->find($this->con); + + $this->assertEquals($testAccAuditLog, $result, 'Generated query handles filterByRefFk() methods correctly for non primary fkeys'); + } + /** * @return void */ diff --git a/tests/Propel/Tests/Generator/Model/ForeignKeyTest.php b/tests/Propel/Tests/Generator/Model/ForeignKeyTest.php index 89f3cdabd7..e151c81bd8 100644 --- a/tests/Propel/Tests/Generator/Model/ForeignKeyTest.php +++ b/tests/Propel/Tests/Generator/Model/ForeignKeyTest.php @@ -85,6 +85,61 @@ public function testForeignKeyIsForeignPrimaryKey() $this->assertSame($idColumn, $fk->getForeignColumn(0)); } + /** + * @return void + */ + public function testForeignKeyIsForeignNonPrimaryKey() + { + $database = $this->getDatabaseMock('bookstore'); + $platform = $this->getPlatformMock(); + $foreignTable = $this->getTableMock('bookstore_employee_account'); + + $localTable = $this->getTableMock('acct_audit_log', [ + 'platform' => $platform, + 'database' => $database, + ]); + + $idColumn = $this->getColumnMock('id'); + $secondaryColumn = $this->getColumnMock('secondary'); + $loginColumn = $this->getColumnMock('login'); + $uidColumn = $this->getColumnMock('uid'); + + $database + ->expects($this->any()) + ->method('getTable') + ->with($this->equalTo('bookstore_employee_account')) + ->will($this->returnValue($foreignTable)); + + $foreignTable + ->expects($this->any()) + ->method('getPrimaryKey') + ->will($this->returnValue([$idColumn, $secondaryColumn])); + + $foreignTable + ->expects($this->any()) + ->method('getColumn') + ->with($this->equalTo('login')) + ->will($this->returnValue($loginColumn)); + + $localTable + ->expects($this->any()) + ->method('getColumn') + ->with($this->equalTo('uid')) + ->will($this->returnValue($uidColumn)); + + $fk = new ForeignKey(); + $fk->setTable($localTable); + $fk->setForeignTableCommonName('bookstore_employee_account'); + $fk->addReference('uid', 'login'); + + $fkMapping = $fk->getColumnObjectsMapping(); + $this->assertFalse($fk->isForeignPrimaryKey()); + $this->assertTrue($fk->isForeignNonPrimaryKey()); + $this->assertCount(1, $fk->getForeignColumnObjects()); + $this->assertSame($uidColumn, $fkMapping[0]['local']); + $this->assertSame($loginColumn, $fkMapping[0]['foreign']); + $this->assertSame($loginColumn, $fk->getForeignColumn(0)); + } /** * @return void */ diff --git a/tests/Propel/Tests/Issues/Issue1659Test.php b/tests/Propel/Tests/Issues/Issue1659Test.php new file mode 100644 index 0000000000..0dd4c1e383 --- /dev/null +++ b/tests/Propel/Tests/Issues/Issue1659Test.php @@ -0,0 +1,106 @@ + + + + + + + + + + + +
+ + + + + + + + + +
+
+EOF; + $builder = new QuickBuilder(); + $builder->setSchema($schema); + $builder->buildClasses(null, true); + + //should build without exception + $this->assertTrue(class_exists('FkNonPrimary\Event')); + $this->assertTrue(class_exists('FkNonPrimary\Organiser')); + } + + /** + * Test non-primary foreign key references + * foreign table have single primary key + * + * @return void + */ + public function testFkNonPrimaryForeignNonCompositeReference() + { + $schema = << + + + + + + + + + + +
+ + + + + + + + +
+
+EOF; + $builder = new QuickBuilder(); + $builder->setSchema($schema); + $builder->buildClasses(null, true); + + //should build without exception + $this->assertTrue(class_exists('FkNonPrimaryFNonComposite\Event')); + $this->assertTrue(class_exists('FkNonPrimaryFNonComposite\Organiser')); + } +} From 3af1a231767f61dcbf4018fb843e2fbf50bc73e5 Mon Sep 17 00:00:00 2001 From: Chuong Nguyen Date: Thu, 22 Oct 2020 22:02:33 +0700 Subject: [PATCH 159/208] \#1659 refactor removed unused import fix code standard --- src/Propel/Generator/Model/ForeignKey.php | 1 + tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Generator/Model/ForeignKey.php b/src/Propel/Generator/Model/ForeignKey.php index bb5c73090b..c713d06877 100644 --- a/src/Propel/Generator/Model/ForeignKey.php +++ b/src/Propel/Generator/Model/ForeignKey.php @@ -856,6 +856,7 @@ public function isForeignNonPrimaryKey() $foreignCols[] = $foreignTable->getColumn($this->foreignColumns[$idx])->getName(); } } + return (bool)array_diff($foreignCols, $foreignPKCols); } diff --git a/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php b/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php index b5723e34e9..b21289e75d 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php @@ -20,7 +20,6 @@ use Propel\Tests\Bookstore\BookListRelQuery; use Propel\Tests\Bookstore\BookOpinionQuery; use Propel\Tests\Bookstore\BookQuery; -use Propel\Tests\Bookstore\BookstoreEmployeeAccount; use Propel\Tests\Bookstore\BookstoreEmployeeAccountQuery; use Propel\Tests\Bookstore\BookSummaryQuery; use Propel\Tests\Bookstore\EssayQuery; From 5f74d4e8b0fe1bb07caaf11392d360ae9b3d0deb Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Thu, 22 Oct 2020 20:02:22 +0300 Subject: [PATCH 160/208] Fixed compatibility issues and phpdocs --- src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php | 6 +++--- .../Runtime/Adapter/Pdo/OracleAdapter.php | 6 +++--- src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php | 17 ++++++++--------- .../Runtime/Adapter/Pdo/SqlsrvAdapter.php | 6 +++--- src/Propel/Runtime/Connection/PdoConnection.php | 7 ++++++- .../Runtime/Connection/StatementWrapper.php | 11 +++++++++++ 6 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php index 597ade5b84..315890c103 100644 --- a/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php @@ -9,8 +9,8 @@ namespace Propel\Runtime\Adapter\Pdo; use PDO; -use PDOStatement; use Propel\Runtime\Adapter\SqlAdapterInterface; +use Propel\Runtime\Connection\StatementInterface; use Propel\Runtime\Map\ColumnMap; /** @@ -149,7 +149,7 @@ public function random($seed = null) /** * @see AdapterInterface::bindValue() * - * @param \PDOStatement $stmt + * @param \Propel\Runtime\Connection\StatementInterface $stmt * @param string $parameter * @param mixed $value * @param \Propel\Runtime\Map\ColumnMap $cMap @@ -157,7 +157,7 @@ public function random($seed = null) * * @return bool */ - public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(StatementInterface $stmt, $parameter, $value, ColumnMap $cMap, $position = null) { $pdoType = $cMap->getPdoType(); // FIXME - This is a temporary hack to get around apparent bugs w/ PDO+MYSQL diff --git a/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php b/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php index 1fbab0c54c..c77a8a8a1b 100644 --- a/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php @@ -8,12 +8,12 @@ namespace Propel\Runtime\Adapter\Pdo; -use PDOStatement; use Propel\Generator\Model\PropelTypes; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Adapter\AdapterInterface; use Propel\Runtime\Adapter\SqlAdapterInterface; use Propel\Runtime\Connection\ConnectionInterface; +use Propel\Runtime\Connection\StatementInterface; use Propel\Runtime\Exception\InvalidArgumentException; use Propel\Runtime\Map\ColumnMap; @@ -213,7 +213,7 @@ public function turnSelectColumnsToAliases(Criteria $criteria) /** * @see AdapterInterface::bindValue() * - * @param \PDOStatement $stmt + * @param \Propel\Runtime\Connection\StatementInterface $stmt * @param string $parameter * @param mixed $value * @param \Propel\Runtime\Map\ColumnMap $cMap @@ -221,7 +221,7 @@ public function turnSelectColumnsToAliases(Criteria $criteria) * * @return bool */ - public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(StatementInterface $stmt, $parameter, $value, ColumnMap $cMap, $position = null) { if ($cMap->getType() === PropelTypes::CLOB_EMU) { return $stmt->bindParam(':p' . $position, $value, $cMap->getPdoType(), strlen($value)); diff --git a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php index b6dba1d0fb..aae8937042 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php @@ -10,14 +10,13 @@ use PDO; use PDOException; -use PDOStatement; use Propel\Generator\Model\PropelTypes; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Adapter\AdapterInterface; use Propel\Runtime\Adapter\Exception\AdapterException; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Connection\PdoConnection; -use Propel\Runtime\Connection\StatementWrapper; +use Propel\Runtime\Connection\StatementInterface; use Propel\Runtime\Exception\InvalidArgumentException; use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\DatabaseMap; @@ -574,13 +573,13 @@ public function turnSelectColumnsToAliases(Criteria $criteria) * $stmt->execute(); * * - * @param StatementWrapper $stmt - * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) - * @param DatabaseMap $dbMap - * + * @param \Propel\Runtime\Connection\StatementInterface $stmt + * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) + * @param \Propel\Runtime\Map\DatabaseMap $dbMap + * * @return void */ - public function bindValues(StatementWrapper $stmt, array $params, DatabaseMap $dbMap) + public function bindValues(StatementInterface $stmt, array $params, DatabaseMap $dbMap) { $position = 0; foreach ($params as $param) { @@ -608,7 +607,7 @@ public function bindValues(StatementWrapper $stmt, array $params, DatabaseMap $d * Binds a value to a positioned parameter in a statement, * given a ColumnMap object to infer the binding type. * - * @param StatementWrapper $stmt The statement to bind + * @param \Propel\Runtime\Connection\StatementInterface $stmt The statement to bind * @param string $parameter Parameter identifier * @param mixed $value The value to bind * @param \Propel\Runtime\Map\ColumnMap $cMap The ColumnMap of the column to bind @@ -616,7 +615,7 @@ public function bindValues(StatementWrapper $stmt, array $params, DatabaseMap $d * * @return bool */ - public function bindValue(StatementWrapper $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(StatementInterface $stmt, $parameter, $value, ColumnMap $cMap, $position = null) { if ($cMap->isTemporal()) { $value = $this->formatTemporalValue($value, $cMap); diff --git a/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php b/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php index 2a5dbd9794..d1fd50ff8b 100644 --- a/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php @@ -9,11 +9,11 @@ namespace Propel\Runtime\Adapter\Pdo; use PDO; -use PDOStatement; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Adapter\Exception\UnsupportedEncodingException; use Propel\Runtime\Adapter\SqlAdapterInterface; use Propel\Runtime\Connection\ConnectionInterface; +use Propel\Runtime\Connection\StatementInterface; use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\DatabaseMap; @@ -99,7 +99,7 @@ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap /** * @see AdapterInterface::bindValue() * - * @param \PDOStatement $stmt + * @param \Propel\Runtime\Connection\StatementInterface $stmt * @param string $parameter * @param mixed $value * @param \Propel\Runtime\Map\ColumnMap $cMap @@ -107,7 +107,7 @@ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap * * @return bool */ - public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(StatementInterface $stmt, $parameter, $value, ColumnMap $cMap, $position = null) { if ($cMap->isTemporal()) { $value = $this->formatTemporalValue($value, $cMap); diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index 22cc9da7db..1d9d0ff884 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -13,7 +13,7 @@ use Propel\Runtime\Exception\InvalidArgumentException; /** - * PDO extension that implements ConnectionInterface and builds \PDOStatement statements. + * PDO extension that implements ConnectionInterface and builds StatementInterface statements. */ class PdoConnection implements ConnectionInterface { @@ -31,6 +31,11 @@ class PdoConnection implements ConnectionInterface /** * Forward any call to a method not found to the proxied connection. + * + * @param $method + * @param $args + * + * @return mixed */ public function __call($method, $args) { diff --git a/src/Propel/Runtime/Connection/StatementWrapper.php b/src/Propel/Runtime/Connection/StatementWrapper.php index 183c40fde9..2a7d30c6e7 100644 --- a/src/Propel/Runtime/Connection/StatementWrapper.php +++ b/src/Propel/Runtime/Connection/StatementWrapper.php @@ -419,4 +419,15 @@ public function debugDumpParams() { return $this->statement->debugDumpParams(); } + + /** + * @param $method + * @param $args + * + * @return mixed + */ + public function __call($method, $args) + { + return call_user_func_array([$this->statement, $method], $args); + } } From 17ec222c93960daf9bf5d6d723efd158ec0409f2 Mon Sep 17 00:00:00 2001 From: Chuong Nguyen Date: Fri, 23 Oct 2020 14:07:57 +0700 Subject: [PATCH 161/208] #1659 add function return typehint --- src/Propel/Generator/Model/ForeignKey.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Generator/Model/ForeignKey.php b/src/Propel/Generator/Model/ForeignKey.php index c713d06877..dd9f2425f3 100644 --- a/src/Propel/Generator/Model/ForeignKey.php +++ b/src/Propel/Generator/Model/ForeignKey.php @@ -841,7 +841,7 @@ public function isForeignPrimaryKey() * * @return bool Returns true if all columns inside this foreign key are not primary keys of the foreign table */ - public function isForeignNonPrimaryKey() + public function isForeignNonPrimaryKey(): bool { $foreignTable = $this->getForeignTable(); From 8cf7fe5a5c7986ddc473b88ceb43379fa2067da5 Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Fri, 23 Oct 2020 10:39:52 +0300 Subject: [PATCH 162/208] Fixed method signatures --- src/Propel/Runtime/Adapter/SqlAdapterInterface.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Propel/Runtime/Adapter/SqlAdapterInterface.php b/src/Propel/Runtime/Adapter/SqlAdapterInterface.php index 38a9db74c8..02a025b4df 100644 --- a/src/Propel/Runtime/Adapter/SqlAdapterInterface.php +++ b/src/Propel/Runtime/Adapter/SqlAdapterInterface.php @@ -8,7 +8,7 @@ namespace Propel\Runtime\Adapter; -use Propel\Runtime\Connection\StatementWrapper; +use Propel\Runtime\Connection\StatementInterface; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\DatabaseMap; @@ -118,19 +118,19 @@ public function turnSelectColumnsToAliases(Criteria $criteria); * $stmt->execute(); * * - * @param StatementWrapper $stmt + * @param \Propel\Runtime\Connection\StatementInterface $stmt * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) * @param \Propel\Runtime\Map\DatabaseMap $dbMap - * + * * @return void */ - public function bindValues(StatementWrapper $stmt, array $params, DatabaseMap $dbMap); + public function bindValues(StatementInterface $stmt, array $params, DatabaseMap $dbMap); /** * Binds a value to a positioned parameter in a statement, * given a ColumnMap object to infer the binding type. * - * @param StatementWrapper $stmt The statement to bind + * @param \Propel\Runtime\Connection\StatementInterface $stmt The statement to bind * @param string $parameter Parameter identifier * @param mixed $value The value to bind * @param \Propel\Runtime\Map\ColumnMap $cMap The ColumnMap of the column to bind @@ -138,5 +138,5 @@ public function bindValues(StatementWrapper $stmt, array $params, DatabaseMap $d * * @return bool */ - public function bindValue(StatementWrapper $stmt, $parameter, $value, ColumnMap $cMap, $position = null); + public function bindValue(StatementInterface $stmt, $parameter, $value, ColumnMap $cMap, $position = null); } From 68b5764d7e3f5d736b5d25f8460873eada569d49 Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Fri, 23 Oct 2020 10:53:19 +0300 Subject: [PATCH 163/208] Travis temp commit --- .travis.yml | 887 ++++++++++++++++++++++++++-------------------------- 1 file changed, 444 insertions(+), 443 deletions(-) diff --git a/.travis.yml b/.travis.yml index bf1476ba17..87d01e1da5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,14 +9,15 @@ php: - 7.2 - 7.3 - 7.4 + - nightly env: global: - PGPORT=5432 jobs: - DB=agnostic #only database agnostic tests - - DB=mysql # TODO we should cover multiple specific versions of mysql. - - DB=sqlite +# - DB=mysql # TODO we should cover multiple specific versions of mysql. +# - DB=sqlite services: - mysql @@ -37,182 +38,182 @@ script: jobs: include: - - php: 7.2 - dist: trusty - env: DB=mysql MARIADB=10.1 - services: - addons: - mariadb: 10.1 - - php: 7.3 - dist: trusty - env: DB=mysql MARIADB=10.1 - services: - addons: - mariadb: 10.1 - - php: 7.4 - dist: trusty - env: DB=mysql MARIADB=10.1 - services: - addons: - mariadb: 10.1 +# - php: 7.2 +# dist: trusty +# env: DB=mysql MARIADB=10.1 +# services: +# addons: +# mariadb: 10.1 +# - php: 7.3 +# dist: trusty +# env: DB=mysql MARIADB=10.1 +# services: +# addons: +# mariadb: 10.1 +# - php: 7.4 +# dist: trusty +# env: DB=mysql MARIADB=10.1 +# services: +# addons: +# mariadb: 10.1 +# +# - php: 7.2 +# env: DB=mysql MARIADB=10.2 +# addons: +# mariadb: 10.2 +# - php: 7.3 +# env: DB=mysql MARIADB=10.2 +# addons: +# mariadb: 10.2 +# - php: 7.4 +# env: DB=mysql MARIADB=10.2 +# addons: +# mariadb: 10.2 - - php: 7.2 - env: DB=mysql MARIADB=10.2 - addons: - mariadb: 10.2 - - php: 7.3 - env: DB=mysql MARIADB=10.2 - addons: - mariadb: 10.2 - - php: 7.4 - env: DB=mysql MARIADB=10.2 - addons: - mariadb: 10.2 - - - php: 7.2 - env: DB=mysql MARIADB=10.3 - addons: - mariadb: 10.3 - - php: 7.3 - env: DB=mysql MARIADB=10.3 - addons: - mariadb: 10.3 - - php: 7.4 - env: DB=mysql MARIADB=10.3 - addons: - mariadb: 10.3 - - - php: 7.2 - env: DB=mysql MARIADB=10.4 DB_USER=travis - addons: - mariadb: 10.4 - before_script: - - sudo mysql -e 'drop user if exists travis@localhost;' - - sudo mysql -e 'create user travis@localhost;' - - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; - - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; - - ./tests/bin/setup.$DB.sh - - php: 7.3 - env: DB=mysql MARIADB=10.4 DB_USER=travis - addons: - mariadb: 10.4 - before_script: - - sudo mysql -e 'drop user if exists travis@localhost;' - - sudo mysql -e 'create user travis@localhost;' - - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; - - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; - - ./tests/bin/setup.$DB.sh - - php: 7.4 - env: DB=mysql MARIADB=10.4 DB_USER=travis - addons: - mariadb: 10.4 - before_script: - - sudo mysql -e 'drop user if exists travis@localhost;' - - sudo mysql -e 'create user travis@localhost;' - - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; - - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; - - ./tests/bin/setup.$DB.sh - - - php: 7.2 - env: DB=pgsql POSTGRES=9.5 - addons: - postgresql: 9.5 - - php: 7.3 - env: DB=pgsql POSTGRES=9.5 - addons: - postgresql: 9.5 - - php: 7.4 - env: DB=pgsql POSTGRES=9.5 - addons: - postgresql: 9.5 - - - php: 7.2 - env: DB=pgsql POSTGRES=9.6 - addons: - postgresql: 9.6 - - php: 7.3 - env: DB=pgsql POSTGRES=9.6 - addons: - postgresql: 9.6 - - php: 7.4 - env: DB=pgsql POSTGRES=9.6 - addons: - postgresql: 9.6 - - - php: 7.2 - env: DB=pgsql POSTGRES=10 - addons: - postgresql: 10 - - php: 7.3 - env: DB=pgsql POSTGRES=10 - addons: - postgresql: 10 - - php: 7.4 - env: DB=pgsql POSTGRES=10 - addons: - postgresql: 10 - - - php: 7.2 - env: DB=pgsql POSTGRES=11 - addons: - postgresql: 11 - - php: 7.3 - env: DB=pgsql POSTGRES=11 - addons: - postgresql: 11 - - php: 7.4 - env: DB=pgsql POSTGRES=11 - addons: - postgresql: 11 - - - php: 7.2 - env: DB=pgsql POSTGRES=12 PGPORT=5432 - addons: - postgresql: 12 - apt: - packages: - - postgresql-12 - - postgresql-client-12 - install: - - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf - - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf - - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf - - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - composer install -v - - composer show - - php: 7.3 - env: DB=pgsql POSTGRES=12 PGPORT=5432 - addons: - postgresql: 12 - apt: - packages: - - postgresql-12 - - postgresql-client-12 - install: - - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf - - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf - - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf - - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - composer install -v - - composer show - - php: 7.4 - env: DB=pgsql POSTGRES=12 PGPORT=5432 - addons: - postgresql: 12 - apt: - packages: - - postgresql-12 - - postgresql-client-12 - install: - - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf - - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf - - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf - - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - composer install -v - - composer show +# - php: 7.2 +# env: DB=mysql MARIADB=10.3 +# addons: +# mariadb: 10.3 +# - php: 7.3 +# env: DB=mysql MARIADB=10.3 +# addons: +# mariadb: 10.3 +# - php: 7.4 +# env: DB=mysql MARIADB=10.3 +# addons: +# mariadb: 10.3 +# +# - php: 7.2 +# env: DB=mysql MARIADB=10.4 DB_USER=travis +# addons: +# mariadb: 10.4 +# before_script: +# - sudo mysql -e 'drop user if exists travis@localhost;' +# - sudo mysql -e 'create user travis@localhost;' +# - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; +# - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; +# - ./tests/bin/setup.$DB.sh +# - php: 7.3 +# env: DB=mysql MARIADB=10.4 DB_USER=travis +# addons: +# mariadb: 10.4 +# before_script: +# - sudo mysql -e 'drop user if exists travis@localhost;' +# - sudo mysql -e 'create user travis@localhost;' +# - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; +# - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; +# - ./tests/bin/setup.$DB.sh +# - php: 7.4 +# env: DB=mysql MARIADB=10.4 DB_USER=travis +# addons: +# mariadb: 10.4 +# before_script: +# - sudo mysql -e 'drop user if exists travis@localhost;' +# - sudo mysql -e 'create user travis@localhost;' +# - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; +# - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; +# - ./tests/bin/setup.$DB.sh +# +# - php: 7.2 +# env: DB=pgsql POSTGRES=9.5 +# addons: +# postgresql: 9.5 +# - php: 7.3 +# env: DB=pgsql POSTGRES=9.5 +# addons: +# postgresql: 9.5 +# - php: 7.4 +# env: DB=pgsql POSTGRES=9.5 +# addons: +# postgresql: 9.5 +# +# - php: 7.2 +# env: DB=pgsql POSTGRES=9.6 +# addons: +# postgresql: 9.6 +# - php: 7.3 +# env: DB=pgsql POSTGRES=9.6 +# addons: +# postgresql: 9.6 +# - php: 7.4 +# env: DB=pgsql POSTGRES=9.6 +# addons: +# postgresql: 9.6 +# +# - php: 7.2 +# env: DB=pgsql POSTGRES=10 +# addons: +# postgresql: 10 +# - php: 7.3 +# env: DB=pgsql POSTGRES=10 +# addons: +# postgresql: 10 +# - php: 7.4 +# env: DB=pgsql POSTGRES=10 +# addons: +# postgresql: 10 +# +# - php: 7.2 +# env: DB=pgsql POSTGRES=11 +# addons: +# postgresql: 11 +# - php: 7.3 +# env: DB=pgsql POSTGRES=11 +# addons: +# postgresql: 11 +# - php: 7.4 +# env: DB=pgsql POSTGRES=11 +# addons: +# postgresql: 11 +# +# - php: 7.2 +# env: DB=pgsql POSTGRES=12 PGPORT=5432 +# addons: +# postgresql: 12 +# apt: +# packages: +# - postgresql-12 +# - postgresql-client-12 +# install: +# - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf +# - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf +# - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf +# - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - composer install -v +# - composer show +# - php: 7.3 +# env: DB=pgsql POSTGRES=12 PGPORT=5432 +# addons: +# postgresql: 12 +# apt: +# packages: +# - postgresql-12 +# - postgresql-client-12 +# install: +# - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf +# - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf +# - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf +# - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - composer install -v +# - composer show +# - php: 7.4 +# env: DB=pgsql POSTGRES=12 PGPORT=5432 +# addons: +# postgresql: 12 +# apt: +# packages: +# - postgresql-12 +# - postgresql-client-12 +# install: +# - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf +# - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf +# - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf +# - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - composer install -v +# - composer show - php: nightly env: DB=agnostic @@ -221,272 +222,272 @@ jobs: - COMPOSER=./tests/composer/composer-php8.json composer install --ignore-platform-reqs - composer show - - name: "PHP 7.4, Agnostic, Symfony ~3" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - - composer show - - name: "PHP 7.4, Agnostic, Symfony ^3" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - - composer show - - name: "PHP 7.4, Agnostic, Symfony ~4" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - - composer show - - name: "PHP 7.4, Agnostic, Symfony ^4" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - - composer show - - name: "PHP 7.4, Agnostic, Symfony ~5" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - - composer show - - name: "PHP 7.4, Agnostic, Symfony ^5" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - - composer show - - - name: "PHP 7.4, MySql, Symfony ~3" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - - composer show - - name: "PHP 7.4, MySql, Symfony ^3" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - - composer show - - name: "PHP 7.4, MySql, Symfony ~4" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - - composer show - - name: "PHP 7.4, MySql, Symfony ^4" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - - composer show - - name: "PHP 7.4, MySql, Symfony ~5" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - - composer show - - name: "PHP 7.4, MySql, Symfony ^5" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - - composer show - - - name: "PHP 7.3, Agnostic, Symfony ~3" - php: 7.3 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - - composer show - - name: "PHP 7.3, Agnostic, Symfony ^3" - php: 7.3 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - - composer show - - name: "PHP 7.3, Agnostic, Symfony ~4" - php: 7.3 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - - composer show - - name: "PHP 7.3, Agnostic, Symfony ^4" - php: 7.3 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - - composer show - - name: "PHP 7.3, Agnostic, Symfony ~5" - php: 7.3 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - - composer show - - name: "PHP 7.3, Agnostic, Symfony ^5" - php: 7.3 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - - composer show - - - name: "PHP 7.3, MySql, Symfony ~3" - php: 7.3 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - - composer show - - name: "PHP 7.3, MySql, Symfony ^3" - php: 7.3 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - - composer show - - name: "PHP 7.3, MySql, Symfony ~4" - php: 7.3 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - - composer show - - name: "PHP 7.3, MySql, Symfony ^4" - php: 7.3 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - - composer show - - name: "PHP 7.3, MySql, Symfony ~5" - php: 7.3 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - - composer show - - name: "PHP 7.3, MySql, Symfony ^5" - php: 7.3 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - - composer show - - - name: "PHP 7.2, Agnostic, Symfony ~3" - php: 7.2 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - - composer show - - name: "PHP 7.2, Agnostic, Symfony ^3" - php: 7.2 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - - composer show - - name: "PHP 7.2, Agnostic, Symfony ~4" - php: 7.2 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - - composer show - - name: "PHP 7.2, Agnostic, Symfony ^4" - php: 7.2 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - - composer show - - name: "PHP 7.2, Agnostic, Symfony ~5" - php: 7.2 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - - composer show - - name: "PHP 7.2, Agnostic, Symfony ^5" - php: 7.2 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - - composer show - - - name: "PHP 7.2, MySql, Symfony ~3" - php: 7.2 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - - composer show - - name: "PHP 7.2, MySql, Symfony ^3" - php: 7.2 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - - composer show - - name: "PHP 7.2, MySql, Symfony ~4" - php: 7.2 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - - composer show - - name: "PHP 7.2, MySql, Symfony ^4" - php: 7.2 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - - composer show - - name: "PHP 7.2, MySql, Symfony ~5" - php: 7.2 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - - composer show - - name: "PHP 7.2, MySql, Symfony ^5" - php: 7.2 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - - composer show - - - name: Checks - php: 7.4 - env: DB=agnostic CHECKS=1 - install: - - composer install --prefer-dist --no-interaction - script: - - composer stan - - composer cs-check +# - name: "PHP 7.4, Agnostic, Symfony ~3" +# php: 7.4 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony3-min.json composer install +# - composer show +# - name: "PHP 7.4, Agnostic, Symfony ^3" +# php: 7.4 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony3-max.json composer install +# - composer show +# - name: "PHP 7.4, Agnostic, Symfony ~4" +# php: 7.4 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony4-min.json composer install +# - composer show +# - name: "PHP 7.4, Agnostic, Symfony ^4" +# php: 7.4 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony4-max.json composer install +# - composer show +# - name: "PHP 7.4, Agnostic, Symfony ~5" +# php: 7.4 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony5-min.json composer install +# - composer show +# - name: "PHP 7.4, Agnostic, Symfony ^5" +# php: 7.4 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony5-max.json composer install +# - composer show +# +# - name: "PHP 7.4, MySql, Symfony ~3" +# php: 7.4 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony3-min.json composer install +# - composer show +# - name: "PHP 7.4, MySql, Symfony ^3" +# php: 7.4 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony3-max.json composer install +# - composer show +# - name: "PHP 7.4, MySql, Symfony ~4" +# php: 7.4 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony4-min.json composer install +# - composer show +# - name: "PHP 7.4, MySql, Symfony ^4" +# php: 7.4 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony4-max.json composer install +# - composer show +# - name: "PHP 7.4, MySql, Symfony ~5" +# php: 7.4 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony5-min.json composer install +# - composer show +# - name: "PHP 7.4, MySql, Symfony ^5" +# php: 7.4 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony5-max.json composer install +# - composer show +# +# - name: "PHP 7.3, Agnostic, Symfony ~3" +# php: 7.3 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony3-min.json composer install +# - composer show +# - name: "PHP 7.3, Agnostic, Symfony ^3" +# php: 7.3 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony3-max.json composer install +# - composer show +# - name: "PHP 7.3, Agnostic, Symfony ~4" +# php: 7.3 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony4-min.json composer install +# - composer show +# - name: "PHP 7.3, Agnostic, Symfony ^4" +# php: 7.3 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony4-max.json composer install +# - composer show +# - name: "PHP 7.3, Agnostic, Symfony ~5" +# php: 7.3 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony5-min.json composer install +# - composer show +# - name: "PHP 7.3, Agnostic, Symfony ^5" +# php: 7.3 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony5-max.json composer install +# - composer show +# +# - name: "PHP 7.3, MySql, Symfony ~3" +# php: 7.3 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony3-min.json composer install +# - composer show +# - name: "PHP 7.3, MySql, Symfony ^3" +# php: 7.3 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony3-max.json composer install +# - composer show +# - name: "PHP 7.3, MySql, Symfony ~4" +# php: 7.3 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony4-min.json composer install +# - composer show +# - name: "PHP 7.3, MySql, Symfony ^4" +# php: 7.3 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony4-max.json composer install +# - composer show +# - name: "PHP 7.3, MySql, Symfony ~5" +# php: 7.3 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony5-min.json composer install +# - composer show +# - name: "PHP 7.3, MySql, Symfony ^5" +# php: 7.3 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony5-max.json composer install +# - composer show +# +# - name: "PHP 7.2, Agnostic, Symfony ~3" +# php: 7.2 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony3-min.json composer install +# - composer show +# - name: "PHP 7.2, Agnostic, Symfony ^3" +# php: 7.2 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony3-max.json composer install +# - composer show +# - name: "PHP 7.2, Agnostic, Symfony ~4" +# php: 7.2 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony4-min.json composer install +# - composer show +# - name: "PHP 7.2, Agnostic, Symfony ^4" +# php: 7.2 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony4-max.json composer install +# - composer show +# - name: "PHP 7.2, Agnostic, Symfony ~5" +# php: 7.2 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony5-min.json composer install +# - composer show +# - name: "PHP 7.2, Agnostic, Symfony ^5" +# php: 7.2 +# env: DB=agnostic +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony5-max.json composer install +# - composer show +# +# - name: "PHP 7.2, MySql, Symfony ~3" +# php: 7.2 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony3-min.json composer install +# - composer show +# - name: "PHP 7.2, MySql, Symfony ^3" +# php: 7.2 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony3-max.json composer install +# - composer show +# - name: "PHP 7.2, MySql, Symfony ~4" +# php: 7.2 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony4-min.json composer install +# - composer show +# - name: "PHP 7.2, MySql, Symfony ^4" +# php: 7.2 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony4-max.json composer install +# - composer show +# - name: "PHP 7.2, MySql, Symfony ~5" +# php: 7.2 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony5-min.json composer install +# - composer show +# - name: "PHP 7.2, MySql, Symfony ^5" +# php: 7.2 +# env: DB=mysql +# install: +# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini +# - COMPOSER=./tests/composer/composer-symfony5-max.json composer install +# - composer show +# +# - name: Checks +# php: 7.4 +# env: DB=agnostic CHECKS=1 +# install: +# - composer install --prefer-dist --no-interaction +# script: +# - composer stan +# - composer cs-check allow_failures: - php: nightly From 730e76673b13ecdef35950de37b7ba5aaea4a1fc Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Fri, 23 Oct 2020 11:58:36 +0300 Subject: [PATCH 164/208] Another temp commit --- .travis.yml | 1 - src/Propel/Generator/Util/QuickBuilder.php | 1 + src/Propel/Runtime/Connection/PdoConnection.php | 10 ++++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 87d01e1da5..b3c91f46bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ php: - 7.2 - 7.3 - 7.4 - - nightly env: global: diff --git a/src/Propel/Generator/Util/QuickBuilder.php b/src/Propel/Generator/Util/QuickBuilder.php index e679748b93..88c39c0178 100644 --- a/src/Propel/Generator/Util/QuickBuilder.php +++ b/src/Propel/Generator/Util/QuickBuilder.php @@ -23,6 +23,7 @@ use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Connection\ConnectionWrapper; use Propel\Runtime\Connection\StatementWrapper; +use Propel\Runtime\Connection\PdoConnection; use Propel\Runtime\Propel; class QuickBuilder diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index 1d9d0ff884..a576d34ca0 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -31,11 +31,11 @@ class PdoConnection implements ConnectionInterface /** * Forward any call to a method not found to the proxied connection. - * + * * @param $method * @param $args - * - * @return mixed + * + * @return mixed */ public function __call($method, $args) { @@ -79,6 +79,8 @@ public function __construct(string $dsn, ?string $user = null, ?string $password } } + //var_dump($dsn, $user, $password, $pdoOptions); + $this->pdo = new \PDO($dsn, $user, $password, $pdoOptions); $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); } @@ -170,7 +172,7 @@ public function lastInsertId($name = null) /** * Overwrite. Fixes HHVM strict issue. - * + * * @param string $statement * @param array $driver_options * From 9babbcac4714f15b3172cf40ee239da118be546e Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Sat, 24 Oct 2020 01:33:52 +0300 Subject: [PATCH 165/208] PHP8: Disallow failures for PHP8, updated phpunit version --- .travis.yml | 3 --- tests/composer/composer-php8.json | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index b3c91f46bc..26b771d075 100644 --- a/.travis.yml +++ b/.travis.yml @@ -488,9 +488,6 @@ jobs: # - composer stan # - composer cs-check - allow_failures: - - php: nightly - fast_finish: true cache: diff --git a/tests/composer/composer-php8.json b/tests/composer/composer-php8.json index 618b59c9b7..9330febf20 100644 --- a/tests/composer/composer-php8.json +++ b/tests/composer/composer-php8.json @@ -30,7 +30,7 @@ }, "require-dev": { "monolog/monolog": "^1.3", - "phpunit/phpunit": "9.3.x-dev" + "phpunit/phpunit": "9.5.x-dev" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." From 42f5085e3bab27fd9de59cd01a95c2baccbdf1f9 Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Tue, 27 Oct 2020 20:37:22 +0200 Subject: [PATCH 166/208] PHP8: BC check --- .travis.yml | 743 +++++++----------- composer.json | 2 +- .../Behavior/Delegate/DelegateBehavior.php | 2 +- src/Propel/Generator/Util/QuickBuilder.php | 9 +- .../Config/ConfigurationManagerTest.php | 35 +- .../Common/Config/Loader/FileLoaderTest.php | 44 +- .../Config/Loader/IniFileLoaderTest.php | 36 +- .../Config/Loader/JsonFileLoaderTest.php | 16 +- .../Config/Loader/PhpFileLoaderTest.php | 24 +- .../Config/Loader/XmlFileLoaderTest.php | 18 +- .../Config/Loader/YamlFileLoaderTest.php | 18 +- .../Common/Config/XmlToArrayConverterTest.php | 33 +- .../Common/Util/SetColumnConverterTest.php | 10 +- ...vableBehaviorObjectBuilderModifierTest.php | 8 +- .../Archivable/ArchivableBehaviorTest.php | 6 +- .../Delegate/DelegateBehaviorTest.php | 4 +- .../Behavior/I18n/I18nBehaviorTest.php | 24 +- ...edSetBehaviorObjectBuilderModifierTest.php | 4 +- ...viorObjectBuilderModifierWithScopeTest.php | 4 +- ...nableBehaviorObjectBuilderModifierTest.php | 4 +- .../Versionable/VersionableBehaviorTest.php | 30 +- .../Om/AbstractOMBuilderNamespaceTest.php | 4 +- .../Om/GeneratedObjectEnumColumnTypeTest.php | 8 +- .../Om/GeneratedObjectSetColumnTypeTest.php | 8 +- .../GeneratedObjectTemporalColumnTypeTest.php | 4 +- .../Om/GeneratedPKLessQueryBuilderTest.php | 36 +- .../Om/GeneratedQuerySetColumnTypeTest.php | 4 +- .../Builder/Util/SchemaReaderTest.php | 4 +- .../Command/GraphvizGenerateTest.php | 2 +- .../Generator/Config/GeneratorConfigTest.php | 46 +- .../Config/QuickGeneratorConfigTest.php | 6 +- .../Tests/Generator/Model/BehaviorTest.php | 8 +- .../Generator/Model/Diff/TableDiffTest.php | 10 +- .../Tests/Generator/Model/TableTest.php | 4 +- .../Tests/Generator/Util/QuickBuilderTest.php | 16 +- tests/Propel/Tests/Issues/Issue675Test.php | 4 +- .../Runtime/ActiveQuery/CriteriaMergeTest.php | 8 +- .../Criterion/BasicCriterionTest.php | 4 +- .../Criterion/BasicModelCriterionTest.php | 4 +- .../Criterion/LikeModelCriterionTest.php | 4 +- .../Criterion/RawCriterionTest.php | 4 +- .../Criterion/RawModelCriterionTest.php | 4 +- .../Criterion/SeveralModelCriterionTest.php | 8 +- .../Propel/Tests/Runtime/ActiveRecordTest.php | 4 +- .../Connection/ConnectionFactoryTest.php | 8 +- .../ConnectionManagerMasterSlaveTest.php | 4 +- .../ConnectionManagerPrimaryReplicaTest.php | 4 +- .../ConnectionManagerSingleTest.php | 4 +- .../Runtime/Exception/PropelExceptionTest.php | 4 +- .../Propel/Tests/Runtime/Map/TableMapTest.php | 4 +- .../Runtime/Parser/AbstractParserTest.php | 4 +- .../StandardServiceContainerTest.php | 4 +- .../Tests/Runtime/Util/PropelDateTimeTest.php | 4 +- tests/composer/composer-php8.json | 2 +- 54 files changed, 584 insertions(+), 736 deletions(-) diff --git a/.travis.yml b/.travis.yml index 26b771d075..bf1f463936 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,17 +6,17 @@ git: dist: bionic php: - - 7.2 - 7.3 - 7.4 + - nightly env: global: - PGPORT=5432 jobs: - DB=agnostic #only database agnostic tests -# - DB=mysql # TODO we should cover multiple specific versions of mysql. -# - DB=sqlite + - DB=mysql # TODO we should cover multiple specific versions of mysql. + - DB=sqlite services: - mysql @@ -37,456 +37,307 @@ script: jobs: include: -# - php: 7.2 -# dist: trusty -# env: DB=mysql MARIADB=10.1 -# services: -# addons: -# mariadb: 10.1 -# - php: 7.3 -# dist: trusty -# env: DB=mysql MARIADB=10.1 -# services: -# addons: -# mariadb: 10.1 -# - php: 7.4 -# dist: trusty -# env: DB=mysql MARIADB=10.1 -# services: -# addons: -# mariadb: 10.1 -# -# - php: 7.2 -# env: DB=mysql MARIADB=10.2 -# addons: -# mariadb: 10.2 -# - php: 7.3 -# env: DB=mysql MARIADB=10.2 -# addons: -# mariadb: 10.2 -# - php: 7.4 -# env: DB=mysql MARIADB=10.2 -# addons: -# mariadb: 10.2 + - php: 7.3 + dist: trusty + env: DB=mysql MARIADB=10.1 + services: + addons: + mariadb: 10.1 + - php: 7.4 + dist: trusty + env: DB=mysql MARIADB=10.1 + services: + addons: + mariadb: 10.1 -# - php: 7.2 -# env: DB=mysql MARIADB=10.3 -# addons: -# mariadb: 10.3 -# - php: 7.3 -# env: DB=mysql MARIADB=10.3 -# addons: -# mariadb: 10.3 -# - php: 7.4 -# env: DB=mysql MARIADB=10.3 -# addons: -# mariadb: 10.3 -# -# - php: 7.2 -# env: DB=mysql MARIADB=10.4 DB_USER=travis -# addons: -# mariadb: 10.4 -# before_script: -# - sudo mysql -e 'drop user if exists travis@localhost;' -# - sudo mysql -e 'create user travis@localhost;' -# - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; -# - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; -# - ./tests/bin/setup.$DB.sh -# - php: 7.3 -# env: DB=mysql MARIADB=10.4 DB_USER=travis -# addons: -# mariadb: 10.4 -# before_script: -# - sudo mysql -e 'drop user if exists travis@localhost;' -# - sudo mysql -e 'create user travis@localhost;' -# - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; -# - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; -# - ./tests/bin/setup.$DB.sh -# - php: 7.4 -# env: DB=mysql MARIADB=10.4 DB_USER=travis -# addons: -# mariadb: 10.4 -# before_script: -# - sudo mysql -e 'drop user if exists travis@localhost;' -# - sudo mysql -e 'create user travis@localhost;' -# - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; -# - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; -# - ./tests/bin/setup.$DB.sh -# -# - php: 7.2 -# env: DB=pgsql POSTGRES=9.5 -# addons: -# postgresql: 9.5 -# - php: 7.3 -# env: DB=pgsql POSTGRES=9.5 -# addons: -# postgresql: 9.5 -# - php: 7.4 -# env: DB=pgsql POSTGRES=9.5 -# addons: -# postgresql: 9.5 -# -# - php: 7.2 -# env: DB=pgsql POSTGRES=9.6 -# addons: -# postgresql: 9.6 -# - php: 7.3 -# env: DB=pgsql POSTGRES=9.6 -# addons: -# postgresql: 9.6 -# - php: 7.4 -# env: DB=pgsql POSTGRES=9.6 -# addons: -# postgresql: 9.6 -# -# - php: 7.2 -# env: DB=pgsql POSTGRES=10 -# addons: -# postgresql: 10 -# - php: 7.3 -# env: DB=pgsql POSTGRES=10 -# addons: -# postgresql: 10 -# - php: 7.4 -# env: DB=pgsql POSTGRES=10 -# addons: -# postgresql: 10 -# -# - php: 7.2 -# env: DB=pgsql POSTGRES=11 -# addons: -# postgresql: 11 -# - php: 7.3 -# env: DB=pgsql POSTGRES=11 -# addons: -# postgresql: 11 -# - php: 7.4 -# env: DB=pgsql POSTGRES=11 -# addons: -# postgresql: 11 -# -# - php: 7.2 -# env: DB=pgsql POSTGRES=12 PGPORT=5432 -# addons: -# postgresql: 12 -# apt: -# packages: -# - postgresql-12 -# - postgresql-client-12 -# install: -# - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf -# - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf -# - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf -# - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - composer install -v -# - composer show -# - php: 7.3 -# env: DB=pgsql POSTGRES=12 PGPORT=5432 -# addons: -# postgresql: 12 -# apt: -# packages: -# - postgresql-12 -# - postgresql-client-12 -# install: -# - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf -# - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf -# - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf -# - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - composer install -v -# - composer show -# - php: 7.4 -# env: DB=pgsql POSTGRES=12 PGPORT=5432 -# addons: -# postgresql: 12 -# apt: -# packages: -# - postgresql-12 -# - postgresql-client-12 -# install: -# - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf -# - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf -# - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf -# - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - composer install -v -# - composer show + - php: 7.3 + env: DB=mysql MARIADB=10.2 + addons: + mariadb: 10.2 + - php: 7.4 + env: DB=mysql MARIADB=10.2 + addons: + mariadb: 10.2 - - php: nightly + - php: 7.3 + env: DB=mysql MARIADB=10.3 + addons: + mariadb: 10.3 + - php: 7.4 + env: DB=mysql MARIADB=10.3 + addons: + mariadb: 10.3 + + - php: 7.3 + env: DB=mysql MARIADB=10.4 DB_USER=travis + addons: + mariadb: 10.4 + before_script: + - sudo mysql -e 'drop user if exists travis@localhost;' + - sudo mysql -e 'create user travis@localhost;' + - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; + - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; + - ./tests/bin/setup.$DB.sh + - php: 7.4 + env: DB=mysql MARIADB=10.4 DB_USER=travis + addons: + mariadb: 10.4 + before_script: + - sudo mysql -e 'drop user if exists travis@localhost;' + - sudo mysql -e 'create user travis@localhost;' + - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; + - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; + - ./tests/bin/setup.$DB.sh + + - php: 7.3 + env: DB=pgsql POSTGRES=9.5 + addons: + postgresql: 9.5 + - php: 7.4 + env: DB=pgsql POSTGRES=9.5 + addons: + postgresql: 9.5 + + - php: 7.3 + env: DB=pgsql POSTGRES=9.6 + addons: + postgresql: 9.6 + - php: 7.4 + env: DB=pgsql POSTGRES=9.6 + addons: + postgresql: 9.6 + + - php: 7.3 + env: DB=pgsql POSTGRES=10 + addons: + postgresql: 10 + - php: 7.4 + env: DB=pgsql POSTGRES=10 + addons: + postgresql: 10 + + - php: 7.3 + env: DB=pgsql POSTGRES=11 + addons: + postgresql: 11 + - php: 7.4 + env: DB=pgsql POSTGRES=11 + addons: + postgresql: 11 + + - php: 7.3 + env: DB=pgsql POSTGRES=12 PGPORT=5432 + addons: + postgresql: 12 + apt: + packages: + - postgresql-12 + - postgresql-client-12 + install: + - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf + - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf + - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf + - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - composer install -v + - composer show + - php: 7.4 + env: DB=pgsql POSTGRES=12 PGPORT=5432 + addons: + postgresql: 12 + apt: + packages: + - postgresql-12 + - postgresql-client-12 + install: + - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf + - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf + - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf + - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - composer install -v + - composer show + + - name: "PHP 7.4, Agnostic, Symfony ~3" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-min.json composer install + - composer show + - name: "PHP 7.4, Agnostic, Symfony ^3" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-max.json composer install + - composer show + - name: "PHP 7.4, Agnostic, Symfony ~4" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-min.json composer install + - composer show + - name: "PHP 7.4, Agnostic, Symfony ^4" + php: 7.4 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-php8.json composer install --ignore-platform-reqs + - COMPOSER=./tests/composer/composer-symfony4-max.json composer install + - composer show + - name: "PHP 7.4, Agnostic, Symfony ~5" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-min.json composer install + - composer show + - name: "PHP 7.4, Agnostic, Symfony ^5" + php: 7.4 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show -# - name: "PHP 7.4, Agnostic, Symfony ~3" -# php: 7.4 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony3-min.json composer install -# - composer show -# - name: "PHP 7.4, Agnostic, Symfony ^3" -# php: 7.4 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony3-max.json composer install -# - composer show -# - name: "PHP 7.4, Agnostic, Symfony ~4" -# php: 7.4 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony4-min.json composer install -# - composer show -# - name: "PHP 7.4, Agnostic, Symfony ^4" -# php: 7.4 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony4-max.json composer install -# - composer show -# - name: "PHP 7.4, Agnostic, Symfony ~5" -# php: 7.4 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony5-min.json composer install -# - composer show -# - name: "PHP 7.4, Agnostic, Symfony ^5" -# php: 7.4 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony5-max.json composer install -# - composer show -# -# - name: "PHP 7.4, MySql, Symfony ~3" -# php: 7.4 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony3-min.json composer install -# - composer show -# - name: "PHP 7.4, MySql, Symfony ^3" -# php: 7.4 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony3-max.json composer install -# - composer show -# - name: "PHP 7.4, MySql, Symfony ~4" -# php: 7.4 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony4-min.json composer install -# - composer show -# - name: "PHP 7.4, MySql, Symfony ^4" -# php: 7.4 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony4-max.json composer install -# - composer show -# - name: "PHP 7.4, MySql, Symfony ~5" -# php: 7.4 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony5-min.json composer install -# - composer show -# - name: "PHP 7.4, MySql, Symfony ^5" -# php: 7.4 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony5-max.json composer install -# - composer show -# -# - name: "PHP 7.3, Agnostic, Symfony ~3" -# php: 7.3 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony3-min.json composer install -# - composer show -# - name: "PHP 7.3, Agnostic, Symfony ^3" -# php: 7.3 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony3-max.json composer install -# - composer show -# - name: "PHP 7.3, Agnostic, Symfony ~4" -# php: 7.3 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony4-min.json composer install -# - composer show -# - name: "PHP 7.3, Agnostic, Symfony ^4" -# php: 7.3 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony4-max.json composer install -# - composer show -# - name: "PHP 7.3, Agnostic, Symfony ~5" -# php: 7.3 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony5-min.json composer install -# - composer show -# - name: "PHP 7.3, Agnostic, Symfony ^5" -# php: 7.3 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony5-max.json composer install -# - composer show -# -# - name: "PHP 7.3, MySql, Symfony ~3" -# php: 7.3 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony3-min.json composer install -# - composer show -# - name: "PHP 7.3, MySql, Symfony ^3" -# php: 7.3 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony3-max.json composer install -# - composer show -# - name: "PHP 7.3, MySql, Symfony ~4" -# php: 7.3 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony4-min.json composer install -# - composer show -# - name: "PHP 7.3, MySql, Symfony ^4" -# php: 7.3 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony4-max.json composer install -# - composer show -# - name: "PHP 7.3, MySql, Symfony ~5" -# php: 7.3 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony5-min.json composer install -# - composer show -# - name: "PHP 7.3, MySql, Symfony ^5" -# php: 7.3 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony5-max.json composer install -# - composer show -# -# - name: "PHP 7.2, Agnostic, Symfony ~3" -# php: 7.2 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony3-min.json composer install -# - composer show -# - name: "PHP 7.2, Agnostic, Symfony ^3" -# php: 7.2 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony3-max.json composer install -# - composer show -# - name: "PHP 7.2, Agnostic, Symfony ~4" -# php: 7.2 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony4-min.json composer install -# - composer show -# - name: "PHP 7.2, Agnostic, Symfony ^4" -# php: 7.2 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony4-max.json composer install -# - composer show -# - name: "PHP 7.2, Agnostic, Symfony ~5" -# php: 7.2 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony5-min.json composer install -# - composer show -# - name: "PHP 7.2, Agnostic, Symfony ^5" -# php: 7.2 -# env: DB=agnostic -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony5-max.json composer install -# - composer show -# -# - name: "PHP 7.2, MySql, Symfony ~3" -# php: 7.2 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony3-min.json composer install -# - composer show -# - name: "PHP 7.2, MySql, Symfony ^3" -# php: 7.2 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony3-max.json composer install -# - composer show -# - name: "PHP 7.2, MySql, Symfony ~4" -# php: 7.2 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony4-min.json composer install -# - composer show -# - name: "PHP 7.2, MySql, Symfony ^4" -# php: 7.2 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony4-max.json composer install -# - composer show -# - name: "PHP 7.2, MySql, Symfony ~5" -# php: 7.2 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony5-min.json composer install -# - composer show -# - name: "PHP 7.2, MySql, Symfony ^5" -# php: 7.2 -# env: DB=mysql -# install: -# - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini -# - COMPOSER=./tests/composer/composer-symfony5-max.json composer install -# - composer show -# -# - name: Checks -# php: 7.4 -# env: DB=agnostic CHECKS=1 -# install: -# - composer install --prefer-dist --no-interaction -# script: -# - composer stan -# - composer cs-check + - name: "PHP 7.4, MySql, Symfony ~3" + php: 7.4 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-min.json composer install + - composer show + - name: "PHP 7.4, MySql, Symfony ^3" + php: 7.4 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-max.json composer install + - composer show + - name: "PHP 7.4, MySql, Symfony ~4" + php: 7.4 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-min.json composer install + - composer show + - name: "PHP 7.4, MySql, Symfony ^4" + php: 7.4 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-max.json composer install + - composer show + - name: "PHP 7.4, MySql, Symfony ~5" + php: 7.4 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-min.json composer install + - composer show + - name: "PHP 7.4, MySql, Symfony ^5" + php: 7.4 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-max.json composer install + - composer show + + - name: "PHP 7.3, Agnostic, Symfony ~3" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-min.json composer install + - composer show + - name: "PHP 7.3, Agnostic, Symfony ^3" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-max.json composer install + - composer show + - name: "PHP 7.3, Agnostic, Symfony ~4" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-min.json composer install + - composer show + - name: "PHP 7.3, Agnostic, Symfony ^4" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-max.json composer install + - composer show + - name: "PHP 7.3, Agnostic, Symfony ~5" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-min.json composer install + - composer show + - name: "PHP 7.3, Agnostic, Symfony ^5" + php: 7.3 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-max.json composer install + - composer show + + - name: "PHP 7.3, MySql, Symfony ~3" + php: 7.3 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-min.json composer install + - composer show + - name: "PHP 7.3, MySql, Symfony ^3" + php: 7.3 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-max.json composer install + - composer show + - name: "PHP 7.3, MySql, Symfony ~4" + php: 7.3 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-min.json composer install + - composer show + - name: "PHP 7.3, MySql, Symfony ^4" + php: 7.3 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-max.json composer install + - composer show + - name: "PHP 7.3, MySql, Symfony ~5" + php: 7.3 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-min.json composer install + - composer show + - name: "PHP 7.3, MySql, Symfony ^5" + php: 7.3 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-max.json composer install + - composer show + + - name: Checks + php: 7.4 + env: DB=agnostic CHECKS=1 + install: + - composer install --prefer-dist --no-interaction + script: + - composer stan + - composer cs-check fast_finish: true diff --git a/composer.json b/composer.json index cc921b1f98..99c3561fa9 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "ext-json": "*", "monolog/monolog": "^1.3", "phpstan/phpstan": "^0.12.4", - "phpunit/phpunit": "^7.5.15", + "phpunit/phpunit": "9.4.2", "spryker/code-sniffer": "^0.15.6" }, "suggest": { diff --git a/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php b/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php index d5f63ac9eb..83d66bd7d1 100644 --- a/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php +++ b/src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php @@ -159,7 +159,7 @@ public function objectCall($builder) $relationName = $builder->getFKPhpNameAffix($fk); } $script .= " -if (is_callable(array('$ARFQCN', \$name))) { +if (method_exists({$ARFQCN}::class, \$name)) { \$delegate = \$this->get$relationName(); if (!\$delegate) { \$delegate = new $ARClassName(); diff --git a/src/Propel/Generator/Util/QuickBuilder.php b/src/Propel/Generator/Util/QuickBuilder.php index 88c39c0178..33c4c0bec1 100644 --- a/src/Propel/Generator/Util/QuickBuilder.php +++ b/src/Propel/Generator/Util/QuickBuilder.php @@ -520,6 +520,13 @@ public static function debugClassesForTable($schema, $tableName) */ public function fixNamespaceDeclarations($source) { + + $cooperativeLexems = [T_WHITESPACE, T_NS_SEPARATOR, T_STRING]; + + if (PHP_VERSION_ID >= 80000) { + $cooperativeLexems = array_merge($cooperativeLexems, [T_NAME_FULLY_QUALIFIED, T_NAME_QUALIFIED]); + } + $source = $this->forceNamespace($source); if (!function_exists('token_get_all')) { @@ -544,7 +551,7 @@ public function fixNamespaceDeclarations($source) $output .= $token[1]; // namespace name and whitespaces - while (($t = $tokens[++$i]) && is_array($t) && in_array($t[0], [T_WHITESPACE, T_NS_SEPARATOR, T_STRING])) { + while (($t = $tokens[++$i]) && is_array($t) && in_array($t[0], $cooperativeLexems)) { $output .= $t[1]; } if (is_string($t) && $t === '{') { diff --git a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php index d1ce1b94a5..c48e04857b 100644 --- a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php +++ b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php @@ -153,14 +153,13 @@ public function testUnsupportedExtensionsAreIgnored() } /** - * @expectedException \Propel\Common\Config\Exception\InvalidArgumentException - * - * @exceptionMessage Propel expects only one configuration file - * * @return void */ public function testMoreThanOneConfigurationFileInSameDirectoryThrowsException() { + $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Propel expects only one configuration file'); + $yamlConf = <<expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Propel expects only one configuration file'); + $yamlConf = <<expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); + $this->expectExceptionMessage('Unrecognized options "foo, bar" under "propel"'); + $yamlConf = <<expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); + $this->expectExceptionMessage('The child node "database" at path "propel" must be configured'); + $yamlConf = <<expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); + $this->expectExceptionMessage('Dots are not allowed in connection names'); + $yamlConf = <<expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid configuration property name'); + $yamlConf = <<assertAttributeEquals(false, 'resolved', $this->loader); - } - /** * @return void */ @@ -190,46 +182,46 @@ public function testResolveReplaceWithoutCasting() } /** - * @expectedException \Propel\Common\Config\Exception\InvalidArgumentException - * @expectedExceptionMessage Parameter 'baz' not found in configuration file. - * * @return void */ public function testResolveThrowsExceptionIfInvalidPlaceholder() { + $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage("Parameter 'baz' not found in configuration file."); + $this->loader->resolveParams(['foo' => 'bar', '%baz%']); } /** - * @expectedException \Propel\Common\Config\Exception\InvalidArgumentException - * @expectedExceptionMessage Parameter 'foobar' not found in configuration file. - * * @return void */ public function testResolveThrowsExceptionIfNonExistentParameter() { + $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage("Parameter 'foobar' not found in configuration file."); + $this->loader->resolveParams(['foo %foobar% bar']); } /** - * @expectedException \Propel\Common\Config\Exception\RuntimeException - * @expectedExceptionMessage Circular reference detected for parameter 'bar'. - * * @return void */ public function testResolveThrowsRuntimeExceptionIfCircularReference() { + $this->expectException(\Propel\Common\Config\Exception\RuntimeException::class); + $this->expectExceptionMessage("Circular reference detected for parameter 'bar'."); + $this->loader->resolveParams(['foo' => '%bar%', 'bar' => '%foobar%', 'foobar' => '%foo%']); } /** - * @expectedException \Propel\Common\Config\Exception\RuntimeException - * @expectedExceptionMessage Circular reference detected for parameter 'bar'. - * * @return void */ public function testResolveThrowsRuntimeExceptionIfCircularReferenceMixed() { + $this->expectException(\Propel\Common\Config\Exception\RuntimeException::class); + $this->expectExceptionMessage("Circular reference detected for parameter 'bar'."); + $this->loader->resolveParams(['foo' => 'a %bar%', 'bar' => 'a %foobar%', 'foobar' => 'a %foo%']); } @@ -316,13 +308,13 @@ public function testExtensionIsNotStringOrArrayReturnsFalse() } /** - * @expectedException \Propel\Common\Config\Exception\InvalidArgumentException - * @expectedExceptionMessage Environment variable 'foo' is not defined. - * * @return void */ public function testNonExistentEnvironmentVariableThrowsException() { + $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage("Environment variable 'foo' is not defined."); + putenv('home=myHome'); $config = [ @@ -334,13 +326,13 @@ public function testNonExistentEnvironmentVariableThrowsException() } /** - * @expectedException \Propel\Common\Config\Exception\RuntimeException - * @expectedExceptionMessage A string value must be composed of strings and/or numbers, - * * @return void */ public function testParameterIsNotStringOrNumber() { + $this->expectException(\Propel\Common\Config\Exception\RuntimeException::class); + $this->expectExceptionMessage("A string value must be composed of strings and/or numbers,"); + $config = [ 'foo' => 'a %bar%', 'bar' => [], diff --git a/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php index d1969ffbb3..1b092ded53 100644 --- a/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php @@ -55,24 +55,24 @@ public function testIniFileCanBeLoaded() } /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The file "inexistent.ini" does not exist (in: - * * @return void */ public function testIniFileDoesNotExist() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('The file "inexistent.ini" does not exist (in:'); + $this->loader->load('inexistent.ini'); } /** - * @expectedException \Propel\Common\Config\Exception\InvalidArgumentException - * @expectedExceptionMessage The configuration file 'nonvalid.ini' has invalid content. - * * @return void */ public function testIniFileHasInvalidContent() { + $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage("The configuration file 'nonvalid.ini' has invalid content."); + $content = <<expectException(\Propel\Common\Config\Exception\IniParseException::class); + $this->expectExceptionMessage('Invalid key ".foo"'); + $content = <<expectException(\Propel\Common\Config\Exception\IniParseException::class); + $this->expectExceptionMessage('Invalid key "foo."'); + $content = <<expectException(\Propel\Common\Config\Exception\IniParseException::class); + $this->expectExceptionMessage('Cannot create sub-key for "foo", as key already exists'); + $content = <<expectException(\Propel\Common\Config\Exception\InputOutputException::class); + $this->expectExceptionMessage("You don't have permissions to access configuration file notreadable.ini."); + $content = <<expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('The file "inexistent.json" does not exist (in:'); + $this->loader->load('inexistent.json'); } /** - * @expectedException \Propel\Common\Config\Exception\JsonParseException - * * @return void */ public function testJsonFileHasInvalidContent() { + $this->expectException(\Propel\Common\Config\Exception\JsonParseException::class); + $content = <<expectException(\Propel\Common\Config\Exception\InputOutputException::class); + $this->expectExceptionMessage("You don't have permissions to access configuration file notreadable.json."); + $content = <<expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('The file "inexistent.php" does not exist (in:'); + $this->loader->load('inexistent.php'); } /** - * @expectedException \Propel\Common\Config\Exception\InvalidArgumentException - * @expectedExceptionMessage The configuration file 'nonvalid.php' has invalid content. - * * @return void */ public function testPhpFileHasInvalidContent() { + $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage("The configuration file 'nonvalid.php' has invalid content."); + $content = <<expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage("The configuration file 'empty.php' has invalid content."); + $content = ''; $this->dumpTempFile('empty.php', $content); @@ -97,15 +97,15 @@ public function testPhpFileIsEmpty() } /** - * @expectedException \Propel\Common\Config\Exception\InputOutputException - * @expectedExceptionMessage You don't have permissions to access configuration file notreadable.php. - * * @requires OS ^(?!Win.*) * * @return void */ public function testConfigFileNotReadableThrowsException() { + $this->expectException(\Propel\Common\Config\Exception\InputOutputException::class); + $this->expectExceptionMessage("You don't have permissions to access configuration file notreadable.php."); + $content = <<expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('The file "inexistent.xml" does not exist (in:'); + $this->loader->load('inexistent.xml'); } /** - * @expectedException \Propel\Common\Config\Exception\InvalidArgumentException - * @expectedExceptionMessage Invalid xml content - * * @return void */ public function testXmlFileHasInvalidContent() { + $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage("Invalid xml content"); + $content = <<expectException(\Propel\Common\Config\Exception\InputOutputException::class); + $this->expectExceptionMessage("You don't have permissions to access configuration file notreadable.xml."); + $content = <<< XML diff --git a/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php index f4e194a09b..88e4dcb503 100644 --- a/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php @@ -55,24 +55,24 @@ public function testYamlFileCanBeLoaded() } /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The file "inexistent.yaml" does not exist (in: - * * @return void */ public function testYamlFileDoesNotExist() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('The file "inexistent.yaml" does not exist (in:'); + $this->loader->load('inexistent.yaml'); } /** - * @expectedException \Symfony\Component\Yaml\Exception\ParseException - * @expectedExceptionMessage Unable to parse - * * @return void */ public function testYamlFileHasInvalidContent() { + $this->expectException(\Symfony\Component\Yaml\Exception\ParseException::class); + $this->expectExceptionMessage('Unable to parse'); + $content = <<expectException(\Propel\Common\Config\Exception\InputOutputException::class); + $this->expectExceptionMessage("You don't have permissions to access configuration file notreadable.yaml."); + $content = <<expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage("XmlToArrayConverter::convert method expects an xml file to parse, or a string containing valid xml"); + XmlToArrayConverter::convert(1); } /** - * @expectedException \Propel\Common\Config\Exception\InvalidArgumentException - * @expectedExceptionMessage Invalid xml content - * * @return void */ public function testInexistentFileThrowsException() { + $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage("Invalid xml content"); + XmlToArrayConverter::convert('nonexistent.xml'); } /** - * @expectedException \Propel\Common\Config\Exception\InvalidArgumentException - * @expectedExceptionMessage Invalid xml content - * * @return void */ public function testInvalidXmlThrowsException() { + $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage("Invalid xml content"); + $invalidXml = <<< XML No xml only plain text @@ -91,13 +91,13 @@ public function testInvalidXmlThrowsException() } /** - * @expectedException \Propel\Common\Config\Exception\XmlParseException - * @expectedExceptionMessage An error occurred while parsing XML configuration file: - * * @return void */ public function testErrorInXmlThrowsException() { + $this->expectException(\Propel\Common\Config\Exception\XmlParseException::class); + $this->expectExceptionMessage("An error occurred while parsing XML configuration file:"); + $xmlWithError = <<< XML @@ -113,16 +113,13 @@ public function testErrorInXmlThrowsException() } /** - * @expectedException \Propel\Common\Config\Exception\XmlParseException - * @expectedExceptionMessage Some errors occurred while parsing XML configuration file: - - Fatal Error 76: Opening and ending tag mismatch: titles line 4 and title - - Fatal Error 73: expected '>' - - Fatal Error 5: Extra content at the end of the document - * * @return void */ public function testMultipleErrorsInXmlThrowsException() { + $this->expectException(\Propel\Common\Config\Exception\XmlParseException::class); + $this->expectExceptionMessage("Some errors occurred while parsing XML configuration file:"); + $xmlWithErrors = <<< XML diff --git a/tests/Propel/Tests/Common/Util/SetColumnConverterTest.php b/tests/Propel/Tests/Common/Util/SetColumnConverterTest.php index 091f9c30ef..d226d09018 100644 --- a/tests/Propel/Tests/Common/Util/SetColumnConverterTest.php +++ b/tests/Propel/Tests/Common/Util/SetColumnConverterTest.php @@ -54,12 +54,12 @@ public function testConvertToIntNullValue() } /** - * @expectedException \Propel\Common\Exception\SetColumnConverterException - * * @return void */ public function testConvertToIntValueNotInSet() { + $this->expectException(\Propel\Common\Exception\SetColumnConverterException::class); + $valueSet = ['a', 'b', 'c', 'd', 'e', 'f']; SetColumnConverter::convertToInt(['g'], $valueSet); } @@ -90,16 +90,16 @@ public function testConvertIntToArrayNullValue() } /** - * @expectedException \Propel\Common\Exception\SetColumnConverterException - * * @return void */ public function testConvertIntToArrayIntOutOfRange() { + $this->expectException(\Propel\Common\Exception\SetColumnConverterException::class); + $valueSet = ['a', 'b', 'c', 'd', 'e', 'f']; SetColumnConverter::convertIntToArray('65', $valueSet); } - + public function convertValuesProvider() { return [ diff --git a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php index 92fe8662ea..643efd901a 100644 --- a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php @@ -220,12 +220,12 @@ public function testArchiveReturnsArchivedObject() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testArchiveThrowsExceptionOnNewObjects() { + $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $a = new ArchivableTest10(); $a->archive(); } @@ -239,12 +239,12 @@ public function testHasRestoreFromArchiveMethod() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testRestoreFromArchiveThrowsExceptionOnUnarchivedObjects() { + $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $a = new ArchivableTest10(); $a->setTitle('foo'); $a->setAge(12); diff --git a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorTest.php index 2108e954c4..0a740d3cd4 100644 --- a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorTest.php @@ -170,7 +170,7 @@ public function testCopiesColumnsToArchiveTable() { $table = ArchivableTest1ArchiveTableMap::getTableMap(); $this->assertTrue($table->hasColumn('id')); - $this->assertContains('id INTEGER NOT NULL,', self::$generatedSQL, 'copied columns are not autoincremented'); + $this->assertStringContainsString('id INTEGER NOT NULL,', self::$generatedSQL, 'copied columns are not autoincremented'); $this->assertTrue($table->hasColumn('title')); $this->assertTrue($table->hasColumn('age')); $this->assertTrue($table->hasColumn('foo_id')); @@ -192,7 +192,7 @@ public function testCopiesIndices() { $table = ArchivableTest1ArchiveTableMap::getTableMap(); $expected = 'CREATE INDEX archivable_test_1_archive_i_6c947f ON archivable_test_1_archive (title,age);'; - $this->assertContains($expected, self::$generatedSQL); + $this->assertStringContainsString($expected, self::$generatedSQL); } /** @@ -202,7 +202,7 @@ public function testCopiesUniquesToIndices() { $table = ArchivableTest2ArchiveTableMap::getTableMap(); $expected = 'CREATE INDEX my_old_archivable_test_3_i_639136 ON my_old_archivable_test_3 (title);'; - $this->assertContains($expected, self::$generatedSQL); + $this->assertStringContainsString($expected, self::$generatedSQL); } /** diff --git a/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php index 563a35e687..fdf5a2f182 100644 --- a/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php @@ -194,12 +194,12 @@ public function testAModelCanHaveSeveralDelegates() } /** - * @expectedException \Propel\Runtime\Exception\BadMethodCallException - * * @return void */ public function testAModelCannotHaveCascadingDelegates() { + $this->expectException(\Propel\Runtime\Exception\BadMethodCallException::class); + $main = new DelegateMain(); $main->setSummary('bar'); $main->setBody('baz'); diff --git a/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorTest.php index d57c29fdf5..5f98467b86 100644 --- a/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorTest.php @@ -53,7 +53,7 @@ public function testModifyDatabaseOverridesDefaultLocale() ON DELETE CASCADE ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -93,7 +93,7 @@ public function testModifyDatabaseDoesNotOverrideTableLocale() ON DELETE CASCADE ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -172,7 +172,7 @@ public function testModifyTableAddsI18nTable($schema) CREATE TABLE i18n_behavior_test_0_i18n EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -187,7 +187,7 @@ public function testModifyTableRelatesI18nTableToMainTable($schema) $expected = <<assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -205,7 +205,7 @@ public function testModifyTableAddsLocaleColumnToI18n($schema) id INTEGER NOT NULL, locale VARCHAR(5) DEFAULT 'en_US' NOT NULL, EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -227,7 +227,7 @@ public function testModifyTableMovesI18nColumns($schema) UNIQUE (id,locale), FOREIGN KEY (id) REFERENCES i18n_behavior_test_0 (id) EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -247,7 +247,7 @@ public function testModifyTableDoesNotMoveNonI18nColumns($schema) UNIQUE (id) ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -284,7 +284,7 @@ public function testModiFyTableUsesCustomI18nTableName() ON DELETE CASCADE ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -321,7 +321,7 @@ public function testModiFyTableUsesCustomLocaleColumnName() ON DELETE CASCADE ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -358,7 +358,7 @@ public function testModiFyTableUsesCustomLocaleDefault() ON DELETE CASCADE ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -395,7 +395,7 @@ public function testModiFyTableUsesCustomI18nLocaleLength() ON DELETE CASCADE ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } public function customPkSchemaDataProvider() @@ -459,6 +459,6 @@ public function testModifyTableRelatesI18nTableToMainTableWithCustomPk($schema) UNIQUE (custom_id,locale), FOREIGN KEY (custom_id) REFERENCES i18n_behavior_test_custom_pk_0 (id) EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } } diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php index bc65f0c1fe..ea755cefbb 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php @@ -105,12 +105,12 @@ public function testSaveOutOfTree() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testSaveRootInTreeWithExistingRoot() { + $this->expectException(\Propel\Runtime\Exception\PropelException::class); + NestedSetTable9TableMap::doDeleteAll(); $t1 = new NestedSetTable9(); $t1->makeRoot(); diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php index 0b0e779778..1ded92a7a1 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php @@ -26,12 +26,12 @@ protected function getByTitle($title) } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testSaveRootInTreeWithExistingRootWithSameScope() { + $this->expectException(\Propel\Runtime\Exception\PropelException::class); + NestedSetTable10TableMap::doDeleteAll(); $t1 = new NestedSetTable10(); $t1->setScopeValue(1); diff --git a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php index 9f57bfbc34..a2e018108d 100644 --- a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php @@ -587,12 +587,12 @@ public function testToVersionAllowsFurtherSave() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testToVersionThrowsExceptionOnIncorrectVersion() { + $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $o = new VersionableBehaviorTest1(); $o->setBar(123); // version 1 $o->save(); diff --git a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorTest.php index bfb2bdef0c..46fb340dd6 100644 --- a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorTest.php @@ -56,7 +56,7 @@ public function testModifyTableAddsVersionColumn($schema) UNIQUE (id) ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -92,7 +92,7 @@ public function testModifyTableAddsVersionColumnCustomName() UNIQUE (id) ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -127,7 +127,7 @@ public function testModifyTableDoesNotAddVersionColumnIfExists() UNIQUE (id) ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } public function foreignTableSchemaDataProvider() @@ -180,7 +180,7 @@ public function testModifyTableAddsVersionColumnForForeignKeysIfForeignTableIsVe FOREIGN KEY (foreign_id) REFERENCES versionable_behavior_test_1 (id) ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); $expected = <<assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -229,7 +229,7 @@ public function testModifyTableAddsVersionColumnForReferrersIfForeignTableIsVers UNIQUE (id) ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); $expected = <<assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -281,7 +281,7 @@ public function testModifyTableAddsVersionTable($schema) ON DELETE CASCADE ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -320,7 +320,7 @@ public function testModifyTableAddsVersionTableCustomName() ON DELETE CASCADE ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -422,7 +422,7 @@ public function testModifyTableAddsLogColumns($schema) UNIQUE (id) ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -455,7 +455,7 @@ public function testModifyTableAddsVersionTableLogColumns($schema) ON DELETE CASCADE ); EOF; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -492,7 +492,7 @@ public function testDatabaseLevelBehavior() EOF; $builder = new QuickBuilder(); $builder->setSchema($schema); - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -530,7 +530,7 @@ public function testIndicesParameter() EOF; $builder = new QuickBuilder(); $builder->setSchema($schema); - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -593,7 +593,7 @@ public function testModifyTableAddsVersionColumnWithPrefix($schema) UNIQUE (id) ); SQL; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } /** @@ -623,6 +623,6 @@ public function testModifyTableAddsVersionTableWithPrefix($schema) ON DELETE CASCADE ); SQL; - $this->assertContains($expected, $builder->getSQL()); + $this->assertStringContainsString($expected, $builder->getSQL()); } } diff --git a/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderNamespaceTest.php b/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderNamespaceTest.php index 96b5d0c25d..a7a679dbb7 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderNamespaceTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderNamespaceTest.php @@ -124,12 +124,12 @@ public function testDeclareClassNamespace() } /** - * @expectedException \Propel\Generator\Exception\LogicException - * * @return void */ public function testDeclareClassNamespaceDuplicateException() { + $this->expectException(\Propel\Generator\Exception\LogicException::class); + $builder = new TestableOMBuilder2(new Table('fooTable')); $builder->declareClassNamespace('Bar'); $builder->declareClassNamespace('Bar', 'Foo'); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php index b5af167644..f90d89ef67 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php @@ -67,12 +67,12 @@ public function testGetter() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testGetterThrowsExceptionOnUnknownKey() { + $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $e = new PublicComplexColumnTypeEntity3(); $e->bar = 156; $e->getBar(); @@ -105,12 +105,12 @@ public function testSetter() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testSetterThrowsExceptionOnUnknownValue() { + $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $e = new ComplexColumnTypeEntity3(); $e->setBar('bazz'); } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php index 94a6c6e424..8078967cdb 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php @@ -112,12 +112,12 @@ public function testGetterValidValue() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testGetterThrowsExceptionOnUnknownKey() { + $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $e = new PublicComplexColumnTypeEntitySet(); $e->bar = 156; $e->getBar(); @@ -199,12 +199,12 @@ public function testSetterResetValue() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testSetterThrowsExceptionOnUnknownValue() { + $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $e = new ComplexColumnTypeEntitySet(); $e->setBar(['bazz']); } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php index 75e9d9634e..aa73e3a1a9 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php @@ -85,12 +85,12 @@ public function testPreEpochValue() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testInvalidValueThrowsPropelException() { + $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $r = new ComplexColumnTypeEntity5(); $r->setBar1('Invalid Date'); } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php index 1b18536205..c90d9469b6 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php @@ -41,69 +41,69 @@ public function setUp(): void } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * @expectedExceptionMessage The Stuff object has no primary key - * * @return void */ public function testFindPkThrowsAnError() { + $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $this->expectExceptionMessage('The Stuff object has no primary key'); + StuffQuery::create()->findPk(42); } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * @expectedExceptionMessage The Stuff object has no primary key - * * @return void */ public function testBuildPkeyCriteria() { + $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $this->expectExceptionMessage('The Stuff object has no primary key'); + $stuff = new Stuff(); $stuff->buildPkeyCriteria(); } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * @expectedExceptionMessage The Stuff object has no primary key - * * @return void */ public function testTableMapDoDelete() { + $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $this->expectExceptionMessage('The Stuff object has no primary key'); + StuffTableMap::doDelete([]); } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * @expectedExceptionMessage The Stuff object has no primary key - * * @return void */ public function testFindPksThrowsAnError() { + $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $this->expectExceptionMessage('The Stuff object has no primary key'); + StuffQuery::create()->findPks([42, 24]); } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * @expectedExceptionMessage The Stuff object has no primary key - * * @return void */ public function testFilterByPrimaryKeyThrowsAnError() { + $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $this->expectExceptionMessage('The Stuff object has no primary key'); + StuffQuery::create()->filterByPrimaryKey(42); } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * @expectedExceptionMessage The Stuff object has no primary key - * * @return void */ public function testFilterByPrimaryKeysThrowsAnError() { + $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $this->expectExceptionMessage('The Stuff object has no primary key'); + StuffQuery::create()->filterByPrimaryKeys(42); } } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php index 51652c1e85..f065bf5933 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php @@ -110,12 +110,12 @@ public function testWhere() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testWhereInvalidValueThrowsException() { + $this->expectException(\Propel\Runtime\Exception\PropelException::class); + ComplexColumnTypeEntitySet2Query::create() ->where('ComplexColumnTypeEntitySet2.Tags LIKE ?', 'bar231') ->find(); diff --git a/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php b/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php index f0fe544271..0fceb95bcf 100644 --- a/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php @@ -58,12 +58,12 @@ public function testParseStringSchemaWithoutXmlDeclaration() } /** - * @expectedException \Propel\Generator\Exception\SchemaException - * * @return void */ public function testParseStringIncorrectSchema() { + $this->expectException(\Propel\Generator\Exception\SchemaException::class); + $this->reader->parseString(''); } diff --git a/tests/Propel/Tests/Generator/Command/GraphvizGenerateTest.php b/tests/Propel/Tests/Generator/Command/GraphvizGenerateTest.php index 6fabc5daa4..937a5f9bde 100644 --- a/tests/Propel/Tests/Generator/Command/GraphvizGenerateTest.php +++ b/tests/Propel/Tests/Generator/Command/GraphvizGenerateTest.php @@ -49,6 +49,6 @@ public function testCommand() $this->assertFileExists($outputDir . '/bookstore.schema.dot'); $content = file_get_contents($outputDir . '/bookstore.schema.dot'); - $this->assertContains('digraph G {', $content); + $this->assertStringContainsString('digraph G {', $content); } } diff --git a/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php b/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php index fa87628135..6f514c05e2 100644 --- a/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php +++ b/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php @@ -114,13 +114,13 @@ public function testGetConfiguredPlatform() } /** - * @expectedException \Propel\Generator\Exception\InvalidArgumentException - * @expectedExceptionMessage Invalid database name: no configured connection named `badsource`. - * * @return void */ public function testGetConfiguredPlatformGivenBadDatabaseNameThrowsException() { + $this->expectException(\Propel\Generator\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid database name: no configured connection named `badsource`.'); + $this->generatorConfig->getConfiguredPlatform(null, 'badsource'); } @@ -169,13 +169,13 @@ public function testGetConfiguredSchemaParserGivenClass() } /** - * @expectedException \Propel\Generator\Exception\BuildException - * @expectedExceptionMessage Specified class (\Propel\Generator\Platform\MysqlPlatform) does not implement \Propel\Generator\Reverse\SchemaParserInterface interface. - * * @return void */ public function testGetConfiguredSchemaParserGivenNonSchemaParserClass() { + $this->expectException(\Propel\Generator\Exception\BuildException::class); + $this->expectExceptionMessage('Specified class (\Propel\Generator\Platform\MysqlPlatform) does not implement \Propel\Generator\Reverse\SchemaParserInterface interface.'); + $this->setConfig( [ 'migrations' => [ @@ -190,13 +190,13 @@ public function testGetConfiguredSchemaParserGivenNonSchemaParserClass() } /** - * @expectedException \Propel\Generator\Exception\ClassNotFoundException - * @expectedExceptionMessage Reverse SchemaParser class for `\Propel\Generator\Reverse\BadSchemaParser` not found. - * * @return void */ public function testGetConfiguredSchemaParserGivenBadClass() { + $this->expectException(\Propel\Generator\Exception\ClassNotFoundException::class); + $this->expectExceptionMessage('Reverse SchemaParser class for `\Propel\Generator\Reverse\BadSchemaParser` not found.'); + $this->setConfig( [ 'migrations' => [ @@ -222,12 +222,12 @@ public function testGetConfiguredBuilder() } /** - * @expectedException \Propel\Generator\Exception\ClassNotFoundException - * * @return void */ public function testGetConfiguredBuilderWrongTypeThrowsException() { + $this->expectException(\Propel\Generator\Exception\ClassNotFoundException::class); + $stubTable = $this->getMockBuilder('\\Propel\\Generator\\Model\\Table')->getMock(); $actual = $this->generatorConfig->getConfiguredBuilder($stubTable, 'bad_type'); } @@ -248,13 +248,13 @@ public function testGetConfiguredPluralizer() } /** - * @expectedException \Propel\Generator\Exception\ClassNotFoundException - * @expectedExceptionMessage Class \Propel\Common\Pluralizer\WrongEnglishPluralizer not found. - * * @return void */ public function testGetConfiguredPluralizerNonExistentClassThrowsException() { + $this->expectException(\Propel\Generator\Exception\ClassNotFoundException::class); + $this->expectExceptionMessage('Class \Propel\Common\Pluralizer\WrongEnglishPluralizer not found.'); + $config['generator']['objectModel']['pluralizerClass'] = '\\Propel\\Common\\Pluralizer\\WrongEnglishPluralizer'; $this->setConfig($config); @@ -262,13 +262,13 @@ public function testGetConfiguredPluralizerNonExistentClassThrowsException() } /** - * @expectedException \Propel\Generator\Exception\BuildException - * @expectedExceptionMessage Specified class (\Propel\Common\Config\PropelConfiguration) does not implement - * * @return void */ public function testGetConfiguredPluralizerWrongClassThrowsException() { + $this->expectException(\Propel\Generator\Exception\BuildException::class); + $this->expectExceptionMessage('Specified class (\Propel\Common\Config\PropelConfiguration) does not implement'); + $config['generator']['objectModel']['pluralizerClass'] = '\\Propel\\Common\\Config\\PropelConfiguration'; $this->setConfig($config); @@ -355,13 +355,13 @@ public function testGetBuildConnectionGivenDatabase() } /** - * @expectedException \Propel\Generator\Exception\InvalidArgumentException - * @expectedExceptionMessage Invalid database name: no configured connection named `wrongsource`. - * * @return void */ public function testGetBuildConnectionGivenWrongDatabaseThrowsException() { + $this->expectException(\Propel\Generator\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid database name: no configured connection named `wrongsource`.'); + $actual = $this->generatorConfig->getBuildConnection('wrongsource'); } @@ -386,13 +386,13 @@ public function testGetConnection() } /** - * @expectedException \Propel\Generator\Exception\InvalidArgumentException - * @expectedExceptionMessage Invalid database name: no configured connection named `badsource`. - * * @return void */ public function testGetConnectionWrongDatabaseThrowsException() { + $this->expectException(\Propel\Generator\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid database name: no configured connection named `badsource`.'); + $actual = $this->generatorConfig->getConnection('badsource'); } diff --git a/tests/Propel/Tests/Generator/Config/QuickGeneratorConfigTest.php b/tests/Propel/Tests/Generator/Config/QuickGeneratorConfigTest.php index 75df11501c..bc905d04e4 100644 --- a/tests/Propel/Tests/Generator/Config/QuickGeneratorConfigTest.php +++ b/tests/Propel/Tests/Generator/Config/QuickGeneratorConfigTest.php @@ -35,13 +35,13 @@ public function testGetConfiguredBuilder() } /** - * @expectedException \Propel\Generator\Exception\InvalidArgumentException - * @expectedExceptionMessage Invalid data model builder type `bad_type` - * * @return void */ public function testGetConfiguredBuilderWrongTypeThrowsException() { + $this->expectException(\Propel\Generator\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid data model builder type `bad_type`'); + $stubTable = $this->getMockBuilder('\\Propel\\Generator\\Model\\Table')->getMock(); $actual = $this->generatorConfig->getConfiguredBuilder($stubTable, 'bad_type'); } diff --git a/tests/Propel/Tests/Generator/Model/BehaviorTest.php b/tests/Propel/Tests/Generator/Model/BehaviorTest.php index 273c5ad4d1..1c71c0077e 100644 --- a/tests/Propel/Tests/Generator/Model/BehaviorTest.php +++ b/tests/Propel/Tests/Generator/Model/BehaviorTest.php @@ -56,12 +56,12 @@ public function testSetupObjectWithMultipleBehaviorWithId() } /** - * @expectedException \Propel\Generator\Exception\LogicException - * * @return void */ public function testSetupObjectFailIfIdGivenOnNotMultipleBehavior() { + $this->expectException(\Propel\Generator\Exception\LogicException::class); + $b = new Behavior(); $b->loadMapping(['name' => 'foo', 'id' => 'lala']); } @@ -144,12 +144,12 @@ public function testSchemaReader() } /** - * @expectedException \Propel\Generator\Exception\BehaviorNotFoundException - * * @return void */ public function testUnknownBehavior() { + $this->expectException(\Propel\Generator\Exception\BehaviorNotFoundException::class); + $schemaReader = new SchemaReader(); $schema = << diff --git a/tests/Propel/Tests/Generator/Model/Diff/TableDiffTest.php b/tests/Propel/Tests/Generator/Model/Diff/TableDiffTest.php index b27ec8a77e..d57ff2208e 100644 --- a/tests/Propel/Tests/Generator/Model/Diff/TableDiffTest.php +++ b/tests/Propel/Tests/Generator/Model/Diff/TableDiffTest.php @@ -29,7 +29,7 @@ public function testDefaultObjectState() $toTable = new Table('article'); $diff = $this->createTableDiff($fromTable, $toTable); - + $this->assertSame($fromTable, $diff->getFromTable()); $this->assertSame($toTable, $diff->getToTable()); $this->assertFalse($diff->hasAddedColumns()); @@ -169,12 +169,12 @@ public function testRemoveAddedPkColumn() } /** - * @expectedException \Propel\Generator\Exception\DiffException - * * @return void */ public function testCantAddNonPrimaryKeyColumn() { + $this->expectException(\Propel\Generator\Exception\DiffException::class); + $diff = $this->createTableDiff(); $diff->addAddedPkColumn('id', new Column('id', 'integer')); } @@ -370,7 +370,7 @@ public function testReverseDiffHasModifiedColumns() $diff = $this->createTableDiff(); $diff->addModifiedColumn('title', $columnDiff); - + $reverseDiff = $diff->getReverseDiff(); $this->assertTrue($reverseDiff->hasModifiedColumns()); $this->assertEquals([ 'title' => $reverseColumnDiff ], $reverseDiff->getModifiedColumns()); @@ -574,7 +574,7 @@ public function testReverseDiffHasModifiedFks() $this->assertTrue($reverseDiff->hasModifiedFks()); $this->assertSame([ 'fk_1' => [ $toFk, $fromFk ]], $reverseDiff->getModifiedFks()); } - + private function createTableDiff(?Table $fromTable = null, ?Table $toTable = null) { if (null === $fromTable) { diff --git a/tests/Propel/Tests/Generator/Model/TableTest.php b/tests/Propel/Tests/Generator/Model/TableTest.php index 56a9857941..8e3ebacba5 100644 --- a/tests/Propel/Tests/Generator/Model/TableTest.php +++ b/tests/Propel/Tests/Generator/Model/TableTest.php @@ -588,12 +588,12 @@ public function testAddIndex() } /** - * @expectedException \Propel\Generator\Exception\InvalidArgumentException - * * @return void */ public function testAddEmptyIndex() { + $this->expectException(\Propel\Generator\Exception\InvalidArgumentException::class); + $table = new Table(); $table->addIndex(new Index()); diff --git a/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php b/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php index 1b0d46e998..6fb4c2e501 100644 --- a/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php +++ b/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php @@ -95,10 +95,10 @@ public function testGetSQL($builder) public function testGetClasses($builder) { $script = $builder->getClasses(); - $this->assertContains('class QuickBuildFoo1 extends BaseQuickBuildFoo1', $script); - $this->assertContains('class QuickBuildFoo1Query extends BaseQuickBuildFoo1Query', $script); - $this->assertContains('class QuickBuildFoo1 implements ActiveRecordInterface', $script); - $this->assertContains('class QuickBuildFoo1Query extends ModelCriteria', $script); + $this->assertStringContainsString('class QuickBuildFoo1 extends BaseQuickBuildFoo1', $script); + $this->assertStringContainsString('class QuickBuildFoo1Query extends BaseQuickBuildFoo1Query', $script); + $this->assertStringContainsString('class QuickBuildFoo1 implements ActiveRecordInterface', $script); + $this->assertStringContainsString('class QuickBuildFoo1Query extends ModelCriteria', $script); } /** @@ -109,10 +109,10 @@ public function testGetClasses($builder) public function testGetClassesLimitedClassTargets($builder) { $script = $builder->getClasses(['tablemap', 'object', 'query']); - $this->assertNotContains('class QuickBuildFoo1 extends BaseQuickBuildFoo1', $script); - $this->assertNotContains('class QuickBuildFoo1Query extends BaseQuickBuildFoo1Query', $script); - $this->assertContains('class QuickBuildFoo1 implements ActiveRecordInterface', $script); - $this->assertContains('class QuickBuildFoo1Query extends ModelCriteria', $script); + $this->assertStringNotContainsString('class QuickBuildFoo1 extends BaseQuickBuildFoo1', $script); + $this->assertStringNotContainsString('class QuickBuildFoo1Query extends BaseQuickBuildFoo1Query', $script); + $this->assertStringContainsString('class QuickBuildFoo1 implements ActiveRecordInterface', $script); + $this->assertStringContainsString('class QuickBuildFoo1Query extends ModelCriteria', $script); } /** diff --git a/tests/Propel/Tests/Issues/Issue675Test.php b/tests/Propel/Tests/Issues/Issue675Test.php index f353301eb5..7c5144dc3b 100644 --- a/tests/Propel/Tests/Issues/Issue675Test.php +++ b/tests/Propel/Tests/Issues/Issue675Test.php @@ -23,12 +23,12 @@ class Issue675Test extends TestCaseFixtures /** * Test incomplete foreign key references * - * @expectedException \Propel\Generator\Exception\BuildException - * * @return void */ public function testIncompleteForeignReference() { + $this->expectException(\Propel\Generator\Exception\BuildException::class); + $schema = << diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaMergeTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaMergeTest.php index 2894c36c3c..5f4fbf38a7 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaMergeTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaMergeTest.php @@ -164,12 +164,12 @@ public function testMergeWithAsColumns() } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * * @return void */ public function testMergeWithAsColumnsThrowsException() { + $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $c1 = new Criteria(); $c1->addAsColumn('foo', BookTableMap::COL_TITLE); $c2 = new Criteria(); @@ -427,12 +427,12 @@ public function testMergeWithAliases() } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * * @return void */ public function testMergeWithAliasesThrowsException() { + $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $c1 = new Criteria(); $c1->addAlias('b', BookTableMap::TABLE_NAME); $c2 = new Criteria(); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicCriterionTest.php index 862ce1296c..817d7a3125 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicCriterionTest.php @@ -133,12 +133,12 @@ public function testAppendPsCanHandleNotEqualToNull() } /** - * @expectedException \Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException - * * @return void */ public function testAppendPsThrowsExceptionWhenValueIsNullAndComparisonIsComplex() { + $this->expectException(\Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException::class); + $cton = new BasicCriterion(new Criteria(), 'A.COL', null, Criteria::GREATER_THAN); $params = []; diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicModelCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicModelCriterionTest.php index 8f2fc9d126..6260b598f8 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicModelCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicModelCriterionTest.php @@ -38,12 +38,12 @@ public function testAppendPsToAddsBindingInfoForNotNullValues() } /** - * @expectedException \Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException - * * @return void */ public function testAppendPsToThrowsExceptionWhenBindingAValueToAClauseWithNoQuestionMark() { + $this->expectException(\Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException::class); + $cton = new BasicModelCriterion(new Criteria(), 'A.COL = B.COL', 'A.COL', 'foo'); $params = []; diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeModelCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeModelCriterionTest.php index 836ffe47e9..08a6342393 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeModelCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeModelCriterionTest.php @@ -58,12 +58,12 @@ public function testAppendPsToCreatesANotLikeConditionIfSpecified() } /** - * @expectedException \Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException - * * @return void */ public function testAppendPsToWithACaseInsensitiveLikeConditionThrowsAnException() { + $this->expectException(\Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException::class); + $cton = new LikeModelCriterion(new Criteria(), 'A.COL LIKE ?', 'A.COL', 'foo%'); $cton->setAdapter(new SqliteAdapter()); $cton->setIgnoreCase(true); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawCriterionTest.php index b86e07afd0..310d063a0e 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawCriterionTest.php @@ -21,12 +21,12 @@ class RawCriterionTest extends BaseTestCase { /** - * @expectedException \Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException - * * @return void */ public function testAppendPsToThrowsExceptionWhenClauseHasNoQuestionMark() { + $this->expectException(\Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException::class); + $cton = new RawCriterion(new Criteria(), 'A.COL = BAR', 1, PDO::PARAM_INT); $params = []; diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawModelCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawModelCriterionTest.php index ebdd8929c7..0ca75cdeab 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawModelCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawModelCriterionTest.php @@ -21,12 +21,12 @@ class RawModelCriterionTest extends BaseTestCase { /** - * @expectedException \Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException - * * @return void */ public function testAppendPsToThrowsExceptionWhenClauseHasNoQuestionMark() { + $this->expectException(\Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException::class); + $cton = new RawModelCriterion(new Criteria(), 'A.COL = BAR', 'A.COL', 1, null, PDO::PARAM_INT); $params = []; diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/SeveralModelCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/SeveralModelCriterionTest.php index 01b1bf5b56..6949334632 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/SeveralModelCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/SeveralModelCriterionTest.php @@ -39,12 +39,12 @@ public function testAppendPsToAddsBindingInfoForNotNullValues() } /** - * @expectedException \Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException - * * @return void */ public function testAppendPsToThrowsExceptionWhenOneOfTheValuesIsNull() { + $this->expectException(\Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException::class); + $cton = new SeveralModelCriterion(new Criteria(), 'A.COL BETWEEN ? AND ?', 'A.COL', ['foo', null]); $params = []; @@ -53,12 +53,12 @@ public function testAppendPsToThrowsExceptionWhenOneOfTheValuesIsNull() } /** - * @expectedException \Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException - * * @return void */ public function testAppendPsToThrowsExceptionWhenTheValueIsNull() { + $this->expectException(\Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException::class); + $cton = new SeveralModelCriterion(new Criteria(), 'A.COL BETWEEN ? AND ?', 'A.COL', null); $params = []; diff --git a/tests/Propel/Tests/Runtime/ActiveRecordTest.php b/tests/Propel/Tests/Runtime/ActiveRecordTest.php index da6ced00b7..4f0a6a0f8b 100644 --- a/tests/Propel/Tests/Runtime/ActiveRecordTest.php +++ b/tests/Propel/Tests/Runtime/ActiveRecordTest.php @@ -51,12 +51,12 @@ public function testHasVirtualColumn() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testGetVirtualColumnWrongKey() { + $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $b = new TestableActiveRecord(); $b->getVirtualColumn('foo'); } diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionFactoryTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionFactoryTest.php index 06515a3e0e..23f556d9bb 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionFactoryTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionFactoryTest.php @@ -17,12 +17,12 @@ class ConnectionFactoryTest extends BaseTestCase { /** - * @expectedException \Propel\Runtime\Exception\InvalidArgumentException - * * @return void */ public function testCreateFailsIfGivenIncorrectConfiguration() { + $this->expectException(\Propel\Runtime\Exception\InvalidArgumentException::class); + $con = ConnectionFactory::create([], new SqliteAdapter()); } @@ -93,12 +93,12 @@ public function testCreateSetsAttributesAfterConnectionAndExpandsConstantNames() } /** - * @expectedException \Propel\Runtime\Exception\InvalidArgumentException - * * @return void */ public function testCreateFailsWhenPassedAnIncorrectAttributeName() { + $this->expectException(\Propel\Runtime\Exception\InvalidArgumentException::class); + $con = ConnectionFactory::create(['dsn' => 'sqlite::memory:', 'attributes' => ['ATTR_CAE' => PDO::CASE_LOWER]], new SqliteAdapter()); } } diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php index 97c3689742..5e5909c3fd 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php @@ -38,12 +38,12 @@ public function testGetNameReturnsNameSetUsingSetName() } /** - * @expectedException \Propel\Runtime\Exception\InvalidArgumentException - * * @return void */ public function testGetWriteConnectionFailsIfManagerIsNotConfigured() { + $this->expectException(\Propel\Runtime\Exception\InvalidArgumentException::class); + $manager = new ConnectionManagerMasterSlave(); $con = $manager->getWriteConnection(new SqliteAdapter()); } diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php index 9189d89c78..b36e75febc 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php @@ -35,12 +35,12 @@ public function testGetNameReturnsNameSetUsingSetName() } /** - * @expectedException \Propel\Runtime\Exception\InvalidArgumentException - * * @return void */ public function testGetWriteConnectionFailsIfManagerIsNotConfigured() { + $this->expectException(\Propel\Runtime\Exception\InvalidArgumentException::class); + $manager = new ConnectionManagerPrimaryReplica(); $manager->getWriteConnection(new SqliteAdapter()); } diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerSingleTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerSingleTest.php index 346cd283b0..01eb85d8d9 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerSingleTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerSingleTest.php @@ -35,12 +35,12 @@ public function testGetNameReturnsNameSetUsingSetName() } /** - * @expectedException \Propel\Runtime\Exception\InvalidArgumentException - * * @return void */ public function testGetWriteConnectionFailsIfManagerIsNotConfigured() { + $this->expectException(\Propel\Runtime\Exception\InvalidArgumentException::class); + $manager = new ConnectionManagerSingle(); $con = $manager->getWriteConnection(new SqliteAdapter()); } diff --git a/tests/Propel/Tests/Runtime/Exception/PropelExceptionTest.php b/tests/Propel/Tests/Runtime/Exception/PropelExceptionTest.php index a806f8d1aa..b9809cffd3 100644 --- a/tests/Propel/Tests/Runtime/Exception/PropelExceptionTest.php +++ b/tests/Propel/Tests/Runtime/Exception/PropelExceptionTest.php @@ -40,14 +40,14 @@ public function testCompositeConstructor() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @throws \Propel\Runtime\Exception\PropelException * * @return void */ public function testIsThrowable() { + $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $e = new PropelException('this is an error'); throw $e; diff --git a/tests/Propel/Tests/Runtime/Map/TableMapTest.php b/tests/Propel/Tests/Runtime/Map/TableMapTest.php index e5875f7e83..36d1e3e78f 100644 --- a/tests/Propel/Tests/Runtime/Map/TableMapTest.php +++ b/tests/Propel/Tests/Runtime/Map/TableMapTest.php @@ -196,12 +196,12 @@ public function testGetForeignKeys() } /** - * @expectedException \Propel\Runtime\Map\Exception\RelationNotFoundException - * * @return void */ public function testLoadWrongRelations() { + $this->expectException(\Propel\Runtime\Map\Exception\RelationNotFoundException::class); + $this->tmap->getRelation('Bar'); } diff --git a/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php b/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php index a89c544ba1..6e5594824b 100644 --- a/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php +++ b/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php @@ -29,12 +29,12 @@ public function testGetParser() } /** - * @expectedException \Propel\Runtime\Exception\FileNotFoundException - * * @return void */ public function testGetParserThrowsExceptionOnWrongParser() { + $this->expectException(\Propel\Runtime\Exception\FileNotFoundException::class); + $parser = AbstractParser::getParser('Foo'); } diff --git a/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php b/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php index 70399d8e3d..88ee49ec45 100644 --- a/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php +++ b/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php @@ -327,12 +327,12 @@ public function testGetConnectionManagersReturnsConnectionManagersForAllDatasour } /** - * @expectedException \Propel\Runtime\Exception\RuntimeException - * * @return void */ public function testGetConnectionManagerWithUnknownDatasource() { + $this->expectException(\Propel\Runtime\Exception\RuntimeException::class); + $this->sc->getConnectionManager('unknown'); } diff --git a/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php b/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php index a6e5880036..8a4c80496f 100644 --- a/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php +++ b/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php @@ -192,12 +192,12 @@ public function testNewInstanceGmt1($value, $expected) } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testNewInstanceInvalidValue() { + $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $dt = PropelDateTime::newInstance('some string'); } diff --git a/tests/composer/composer-php8.json b/tests/composer/composer-php8.json index 9330febf20..6001d40f83 100644 --- a/tests/composer/composer-php8.json +++ b/tests/composer/composer-php8.json @@ -30,7 +30,7 @@ }, "require-dev": { "monolog/monolog": "^1.3", - "phpunit/phpunit": "9.5.x-dev" + "phpunit/phpunit": "9.4.2" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." From 907d845c7780efa6bb86ce8a5143546aa6bef3f2 Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Wed, 28 Oct 2020 12:50:52 +0200 Subject: [PATCH 167/208] Fixed constant class reference for PDO connections --- src/Propel/Runtime/Connection/PdoConnection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index a576d34ca0..2b190bae2f 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -74,7 +74,7 @@ public function __construct(string $dsn, ?string $user = null, ?string $password $pdoOptions = []; if (is_array($options)) { foreach ($options as $key => $option) { - $index = (is_numeric($key)) ? $key : constant('self::' . $key); + $index = (is_numeric($key)) ? $key : constant('\PDO::' . $key); $pdoOptions[$index] = $option; } } From 17c379ac2a28d0d14941de89e120107614420805 Mon Sep 17 00:00:00 2001 From: Kaspars Jaudzems Date: Thu, 29 Oct 2020 11:29:06 +0200 Subject: [PATCH 168/208] fix identifierQuoting for Versionable behaviour --- .../Generator/Behavior/Versionable/VersionableBehavior.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php b/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php index 4cede1e21a..d4444d393a 100644 --- a/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php +++ b/src/Propel/Generator/Behavior/Versionable/VersionableBehavior.php @@ -146,6 +146,7 @@ protected function addVersionTable() 'schema' => $table->getSchema(), 'namespace' => $table->getNamespace() ? '\\' . $table->getNamespace() : null, 'skipSql' => $table->isSkipSql(), + 'identifierQuoting' => $table->isIdentifierQuotingEnabled(), ]); $versionTable->isVersionTable = true; // every behavior adding a table should re-execute database behaviors From a46f9047038c5ed0b804d208eb765a223be09802 Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Thu, 29 Oct 2020 18:50:42 +0200 Subject: [PATCH 169/208] PHP8 PHP8 and PHPUnit compatibility fixes --- .../Behavior/Sluggable/SluggableBehavior.php | 6 ++++ .../Validate/templates/objectValidate.php | 2 +- .../Config/ConfigurationManagerTest.php | 13 ++++---- ...tableBehaviorObjectBuilderModifierTest.php | 21 ++++++------ ...viorObjectBuilderModifierWithScopeTest.php | 25 ++++++++------- ...rtableBehaviorQueryBuilderModifierTest.php | 5 +-- .../Validate/ValidateBehaviorTest.php | 32 ++++++++++--------- .../Builder/Om/GeneratedObjectLobTest.php | 12 +++---- .../Builder/Om/GeneratedObjectTest.php | 5 +-- .../Om/GeneratedObjectWithFixturesTest.php | 10 +++--- .../Generator/Builder/Om/QueryBuilderTest.php | 7 ++-- .../Generator/Command/InitCommandTest.php | 4 +-- .../Tests/Generator/Command/MigrationTest.php | 14 ++++---- .../Manager/MigrationManagerTest.php | 2 +- .../Tests/Generator/Model/ColumnTest.php | 14 ++++---- .../Tests/Generator/Model/TableTest.php | 6 ++-- .../Generator/Util/SchemaValidatorTest.php | 8 ++--- tests/Propel/Tests/Issues/Issue617Test.php | 6 ++-- tests/Propel/Tests/Issues/Issue646Test.php | 2 +- .../ModelCriteriaGroupByArrayTest.php | 25 ++++++++------- .../ActiveQuery/ModelCriteriaSelectTest.php | 13 ++++---- .../Runtime/ActiveQuery/ModelCriteriaTest.php | 21 ++++++------ .../Collection/ArrayCollectionTest.php | 14 ++++---- .../Runtime/Collection/CollectionTest.php | 13 ++++---- .../Collection/ObjectCollectionTest.php | 16 ++++++---- .../Collection/OnDemandCollectionTest.php | 22 +++++++------ .../ConnectionManagerMasterSlaveTest.php | 2 +- .../ConnectionManagerPrimaryReplicaTest.php | 2 +- .../Formatter/ArrayFormatterWithTest.php | 5 +-- .../Formatter/ObjectFormatterWithTest.php | 5 +-- .../Formatter/OnDemandFormatterTest.php | 4 +-- .../Formatter/OnDemandFormatterWithTest.php | 5 +-- .../Runtime/Util/PropelModelPagerTest.php | 2 +- .../Runtime/Util/TableMapExceptionsTest.php | 12 +++---- .../Tests/Runtime/Util/TableMapTest.php | 8 ++--- tests/Propel/Tests/Ticket520Test.php | 4 +-- 36 files changed, 197 insertions(+), 170 deletions(-) diff --git a/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php b/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php index 72e568fdc4..ba1253a773 100644 --- a/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php +++ b/src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php @@ -260,6 +260,10 @@ public function addCleanupSlugPart(&$script) */ protected static function cleanupSlugPart(\$slug, \$replacement = '" . $this->getParameter('replacement') . "') { + // set locale explicitly + \$localeOrigin = setlocale(LC_CTYPE, 0); + setlocale(LC_CTYPE, 'C.UTF-8'); + // transliterate if (function_exists('iconv')) { \$slug = iconv('utf-8', 'us-ascii//TRANSLIT', \$slug); @@ -281,6 +285,8 @@ protected static function cleanupSlugPart(\$slug, \$replacement = '" . $this->ge // trim \$slug = trim(\$slug, \$replacement); + setlocale(LC_CTYPE, \$localeOrigin); + if (empty(\$slug)) { return 'n-a'; } diff --git a/src/Propel/Generator/Behavior/Validate/templates/objectValidate.php b/src/Propel/Generator/Behavior/Validate/templates/objectValidate.php index 888e32c69e..71b0cf7f64 100644 --- a/src/Propel/Generator/Behavior/Validate/templates/objectValidate.php +++ b/src/Propel/Generator/Behavior/Validate/templates/objectValidate.php @@ -30,7 +30,7 @@ public function validate(ValidatorInterface $validator = null) // If validate() method exists, the validate-behavior is configured for related object - if (method_exists($this->, 'validate')) { + if (is_object($this->) and method_exists($this->, 'validate')) { if (!$this->->validate($validator)) { $failureMap->addAll($this->->getValidationFailures()); } diff --git a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php index c48e04857b..5a059e5847 100644 --- a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php +++ b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php @@ -10,6 +10,7 @@ use Propel\Common\Config\ConfigurationManager; use Propel\Common\Config\Exception\InvalidConfigurationException; +use Propel\Common\Config\Exception\InvalidArgumentException; class ConfigurationManagerTest extends ConfigTestCase { @@ -157,7 +158,7 @@ public function testUnsupportedExtensionsAreIgnored() */ public function testMoreThanOneConfigurationFileInSameDirectoryThrowsException() { - $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Propel expects only one configuration file'); $yamlConf = <<expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Propel expects only one configuration file'); $yamlConf = <<expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); + $this->expectException(InvalidConfigurationException::class); $this->expectExceptionMessage('Unrecognized options "foo, bar" under "propel"'); $yamlConf = <<expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); + $this->expectException(InvalidConfigurationException::class); $this->expectExceptionMessage('The child node "database" at path "propel" must be configured'); $yamlConf = <<expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); + $this->expectException(InvalidConfigurationException::class); $this->expectExceptionMessage('Dots are not allowed in connection names'); $yamlConf = <<expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid configuration property name'); $yamlConf = <<expectException(PropelException::class); + $t = new Table11(); $t->insertAtRank(0); } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testInsertAtOverMaxRank() { + $this->expectException(PropelException::class); + $t = new Table11(); $t->insertAtRank(6); } @@ -211,34 +212,34 @@ public function testMoveToRank() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testMoveToNewObject() { + $this->expectException(PropelException::class); + $t = new Table11(); $t->moveToRank(2); } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testMoveToNegativeRank() { + $this->expectException(PropelException::class); + $t = SortableTable11Query::retrieveByRank(2); $t->moveToRank(0); } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testMoveToOverMaxRank() { + $this->expectException(PropelException::class); + $t = SortableTable11Query::retrieveByRank(2); $t->moveToRank(5); } diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php index 95ec71ef3d..60a1bbf546 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php @@ -8,6 +8,7 @@ namespace Propel\Tests\Generator\Behavior\Sortable; +use Propel\Runtime\Exception\PropelException; use Propel\Tests\Bookstore\Behavior\Map\SortableMultiCommaScopesTableMap; use Propel\Tests\Bookstore\Behavior\Map\SortableMultiScopesTableMap; use Propel\Tests\Bookstore\Behavior\Map\SortableTable12TableMap; @@ -176,24 +177,24 @@ public function testInsertAtRankNoScope() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testInsertAtNegativeRank() { + $this->expectException(PropelException::class); + $t = new Table12(); $t->setScopeValue(1); $t->insertAtRank(0); } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testInsertAtOverMaxRank() { + $this->expectException(PropelException::class); + $t = new Table12(); $t->setScopeValue(1); $t->insertAtRank(6); @@ -320,34 +321,34 @@ public function testMoveToRankNoScope() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testMoveToNewObject() { + $this->expectException(PropelException::class); + $t = new Table12(); $t->moveToRank(2); } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testMoveToNegativeRank() { + $this->expectException(PropelException::class); + $t = SortableTable12Query::retrieveByRank(2, 1); $t->moveToRank(0); } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testMoveToOverMaxRank() { + $this->expectException(PropelException::class); + $t = SortableTable12Query::retrieveByRank(2, 1); $t->moveToRank(5); } @@ -478,12 +479,12 @@ public function testRemoveFromList() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testRemoveFromListNoScope() { + $this->expectException(PropelException::class); + $t2 = SortableTable12Query::retrieveByRank(2); $t2->removeFromList(); } diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierTest.php index e260071fd0..97b4abefe0 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifierTest.php @@ -10,6 +10,7 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Collection\ObjectCollection; +use Propel\Runtime\Exception\PropelException; use Propel\Tests\Bookstore\Behavior\Map\SortableTable11TableMap; use Propel\Tests\Bookstore\Behavior\SortableTable11 as Table11; use Propel\Tests\Bookstore\Behavior\SortableTable11Query; @@ -65,12 +66,12 @@ public function testOrderByRank() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testOrderByRankIncorrectDirection() { + $this->expectException(PropelException::class); + SortableTable11Query::create()->orderByRank('foo'); } diff --git a/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php index 42b4cecfeb..b240388e83 100755 --- a/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Validate/ValidateBehaviorTest.php @@ -9,6 +9,8 @@ namespace Propel\Tests\Generator\Behavior\Validate; use Exception; +use Propel\Generator\Exception\ConstraintNotFoundException; +use Propel\Generator\Exception\InvalidArgumentException; use Propel\Generator\Util\QuickBuilder; use Propel\Tests\Bookstore\Behavior\ValidateAuthor; use Propel\Tests\Bookstore\Behavior\ValidateBook; @@ -103,13 +105,13 @@ public function testLoadValidatorMetadataMethodIsStatic() } /** - * @expectedException \Propel\Generator\Exception\InvalidArgumentException - * @expectedExceptionMessage Please, define your rules for validation. - * * @return void */ public function testParametersNotDefined() { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Please, define your rules for validation.'); + $schema = << @@ -123,13 +125,13 @@ public function testParametersNotDefined() } /** - * @expectedException \Propel\Generator\Exception\InvalidArgumentException - * @expectedExceptionMessage Please, define the column to validate. - * * @return void */ public function testColumnNameNotDefined() { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Please, define the column to validate.'); + $schema = <<
@@ -146,13 +148,13 @@ public function testColumnNameNotDefined() } /** - * @expectedException \Propel\Generator\Exception\InvalidArgumentException - * @expectedExceptionMessage Please, define the validator constraint. - * * @return void */ public function testValidatorNameNotDefined() { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Please, define the validator constraint.'); + $schema = <<
@@ -169,13 +171,13 @@ public function testValidatorNameNotDefined() } /** - * @expectedException \Propel\Generator\Exception\ConstraintNotFoundException - * @expectedExceptionMessage The constraint class MaximumLength does not exist. - * * @return void */ public function testConstraintNameNotValid() { + $this->expectException(ConstraintNotFoundException::class); + $this->expectExceptionMessage('The constraint class MaximumLength does not exist.'); + $schema = <<
@@ -192,13 +194,13 @@ public function testConstraintNameNotValid() } /** - * @expectedException \Propel\Generator\Exception\InvalidArgumentException - * @expectedExceptionMessage The options value, in tag must be an array - * * @return void */ public function testConstraintOptionsNotValid() { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('The options value, in tag must be an array'); + $schema = <<
diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLobTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLobTest.php index aa99ed6773..eb1d75d363 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLobTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectLobTest.php @@ -104,8 +104,8 @@ public function testLobResults() $img = $m1->getCoverImage(); $txt = $m1->getExcerpt(); - $this->assertInternalType('resource', $img, 'Expected results of BLOB method to be a resource.'); - $this->assertInternalType('string', $txt, 'Expected results of CLOB method to be a string.'); + $this->assertIsResource($img, 'Expected results of BLOB method to be a resource.'); + $this->assertIsString($txt, 'Expected results of CLOB method to be a string.'); $stat = fstat($img); $size = $stat['size']; @@ -148,7 +148,7 @@ public function testLobRepeatRead() // 1) Assert that we've got a valid stream to start with - $this->assertInternalType('resource', $img, 'Expected results of BLOB method to be a resource.'); + $this->assertIsResource($img, 'Expected results of BLOB method to be a resource.'); // read first 100 bytes $firstBytes = fread($img, 100); @@ -215,18 +215,18 @@ public function testLobSetting() // 1) Assert that we've got a valid stream to start with $img = $m1->getCoverImage(); - $this->assertInternalType('resource', $img, 'Expected results of BLOB method to be a resource.'); + $this->assertIsResource($img, 'Expected results of BLOB method to be a resource.'); // 2) Test setting a BLOB column with file contents $m1->setCoverImage(file_get_contents($blob2_path)); - $this->assertInternalType('resource', $m1->getCoverImage(), 'Expected to get a resource back after setting BLOB with file contents.'); + $this->assertIsResource($m1->getCoverImage(), 'Expected to get a resource back after setting BLOB with file contents.'); // commit those changes & reload $m1->save(); // 3) Verify that we've got a valid resource after reload $m1->reload(); - $this->assertInternalType('resource', $m1->getCoverImage(), 'Expected to get a resource back after setting reloading object.'); + $this->assertIsResource($m1->getCoverImage(), 'Expected to get a resource back after setting reloading object.'); // 4) Test isModified() behavior $fp = fopen('php://temp', 'r+'); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php index 4346ecbfb5..40523e5a4c 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php @@ -16,6 +16,7 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Adapter\Pdo\SqliteAdapter; use Propel\Runtime\Collection\ObjectCollection; +use \Propel\Runtime\Exception\BadMethodCallException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Propel; use Propel\Tests\Bookstore\AcctAuditLog; @@ -1200,12 +1201,12 @@ public function testMagicVirtualColumnGetter() } /** - * @expectedException \Propel\Runtime\Exception\BadMethodCallException - * * @return void */ public function testMagicCallUndefined() { + $this->expectException(BadMethodCallException::class); + $book = new Book(); $book->fooMethodName(); } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithFixturesTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithFixturesTest.php index 28caed39a1..0ee58c5285 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithFixturesTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectWithFixturesTest.php @@ -174,11 +174,11 @@ public function testTypeSensitive() // reload and verify that the types are the same $r2 = ReviewQuery::create()->findPk($id); - $this->assertInternalType('integer', $r2->getId(), 'Expected getId() to return an integer.'); - $this->assertInternalType('string', $r2->getReviewedBy(), 'Expected getReviewedBy() to return a string.'); - $this->assertInternalType('boolean', $r2->getRecommended(), 'Expected getRecommended() to return a boolean.'); + $this->assertIsInt($r2->getId(), 'Expected getId() to return an integer.'); + $this->assertIsString($r2->getReviewedBy(), 'Expected getReviewedBy() to return a string.'); + $this->assertIsBool($r2->getRecommended(), 'Expected getRecommended() to return a boolean.'); $this->assertInstanceOf('\Propel\Tests\Bookstore\Book', $r2->getBook(), 'Expected getBook() to return a Book.'); - $this->assertInternalType('float', $r2->getBook()->getPrice(), 'Expected Book->getPrice() to return a float.'); + $this->assertIsFloat($r2->getBook()->getPrice(), 'Expected Book->getPrice() to return a float.'); $this->assertInstanceOf('\DateTime', $r2->getReviewDate(null), 'Expected Book->getReviewDate() to return a DateTime.'); } @@ -318,7 +318,7 @@ public function testToArrayLazyLoad() $arr1 = $m->toArray(TableMap::TYPE_COLNAME); $this->assertNotNull($arr1[MediaTableMap::COL_COVER_IMAGE]); - $this->assertInternalType('resource', $arr1[MediaTableMap::COL_COVER_IMAGE]); + $this->assertIsResource($arr1[MediaTableMap::COL_COVER_IMAGE]); $arr2 = $m->toArray(TableMap::TYPE_COLNAME, false); $this->assertNull($arr2[MediaTableMap::COL_COVER_IMAGE]); diff --git a/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php b/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php index 112fa38235..f0760a3b40 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/QueryBuilderTest.php @@ -11,6 +11,7 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveQuery\ModelJoin; +use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Propel; use Propel\Tests\Bookstore\AuthorQuery; @@ -307,7 +308,7 @@ public function testFindPkNotUsesInstancePoolingForNonEmptyQueries() $b->save($this->con); $book = BookQuery::create()->select(['Book.Title', 'Book.ISBN'])->findPk($b->getId(), $this->con); - $this->assertInternalType('array', $book); + $this->assertIsArray($book); $book = BookQuery::create()->filterByTitle('bar')->findPk($b->getId(), $this->con); $this->assertNull($book); @@ -863,12 +864,12 @@ public function testFilterByRelationNameCompositePk() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testFilterUsingCollectionByRelationNameCompositePk() { + $this->expectException(PropelException::class); + BookstoreDataPopulator::depopulate(); BookstoreDataPopulator::populate(); diff --git a/tests/Propel/Tests/Generator/Command/InitCommandTest.php b/tests/Propel/Tests/Generator/Command/InitCommandTest.php index eeeb60a70c..8aaa6670ec 100644 --- a/tests/Propel/Tests/Generator/Command/InitCommandTest.php +++ b/tests/Propel/Tests/Generator/Command/InitCommandTest.php @@ -74,7 +74,7 @@ public function testExecute() $commandTester->setInputs($this->getInputsArray()); $commandTester->execute(['command' => $command->getName()]); - $this->assertContains('Propel 2 is ready to be used!', $commandTester->getDisplay()); + $this->assertStringContainsString('Propel 2 is ready to be used!', $commandTester->getDisplay()); $this->assertTrue(file_exists($this->dir . '/schema.xml'), 'Example schema file created.'); $this->assertTrue(file_exists($this->dir . '/propel.yml'), 'Configuration file created.'); $this->assertTrue(file_exists($this->dir . '/propel.yml.dist'), 'Dist configuration file created.'); @@ -107,7 +107,7 @@ public function testExecuteAborted() $commandTester->setInputs($this->getInputsArray('no')); $commandTester->execute(['command' => $command->getName()]); - $this->assertContains('Process aborted', $commandTester->getDisplay()); + $this->assertStringContainsString('Process aborted', $commandTester->getDisplay()); } /** diff --git a/tests/Propel/Tests/Generator/Command/MigrationTest.php b/tests/Propel/Tests/Generator/Command/MigrationTest.php index 9c810530b9..7bc56aad8b 100644 --- a/tests/Propel/Tests/Generator/Command/MigrationTest.php +++ b/tests/Propel/Tests/Generator/Command/MigrationTest.php @@ -88,7 +88,7 @@ public function testDiffCommand() $content = file_get_contents($file); $this->assertGreaterThanOrEqual(2, substr_count($content, 'CREATE TABLE ')); - $this->assertContains('CREATE TABLE ', $content); + $this->assertStringContainsString('CREATE TABLE ', $content); } /** @@ -133,7 +133,7 @@ public function testDiffCommandUsingSuffix() $content = file_get_contents($file); $this->assertGreaterThanOrEqual(2, substr_count($content, 'CREATE TABLE ')); - $this->assertContains('CREATE TABLE ', $content); + $this->assertStringContainsString('CREATE TABLE ', $content); } /** @@ -165,7 +165,7 @@ public function testUpCommand() $this->assertEquals(0, $result, 'migration:up tests exited successfully'); $outputString = stream_get_contents($output->getStream()); - $this->assertContains('Migration complete.', $outputString); + $this->assertStringContainsString('Migration complete.', $outputString); } /** @@ -197,7 +197,7 @@ public function testDownCommand() $this->assertEquals(0, $result, 'migration:down tests exited successfully'); $outputString = stream_get_contents($output->getStream()); - $this->assertContains('Reverse migration complete.', $outputString); + $this->assertStringContainsString('Reverse migration complete.', $outputString); } /** @@ -229,7 +229,7 @@ public function testMigrateCommand() $this->assertEquals(0, $result, 'migration:down tests exited successfully'); $outputString = stream_get_contents($output->getStream()); - $this->assertContains('Migration complete.', $outputString); + $this->assertStringContainsString('Migration complete.', $outputString); //revert this migration change so we have the same database structure as before this test $this->testDownCommand(); @@ -275,7 +275,7 @@ public function testCreateCommand() $file = $files[0]; $content = file_get_contents($file); - $this->assertNotContains('CREATE TABLE ', $content); + $this->assertStringNotContainsString('CREATE TABLE ', $content); } /** @@ -319,6 +319,6 @@ public function testCreateCommandUsingSuffix() $file = $files[0]; $content = file_get_contents($file); - $this->assertNotContains('CREATE TABLE ', $content); + $this->assertStringNotContainsString('CREATE TABLE ', $content); } } diff --git a/tests/Propel/Tests/Generator/Manager/MigrationManagerTest.php b/tests/Propel/Tests/Generator/Manager/MigrationManagerTest.php index d2d24546a1..583b8d6e31 100644 --- a/tests/Propel/Tests/Generator/Manager/MigrationManagerTest.php +++ b/tests/Propel/Tests/Generator/Manager/MigrationManagerTest.php @@ -197,6 +197,6 @@ public function testGetCommentMigrationManager() $body = $migrationManager->getMigrationClassBody('foo', 'bar', 4, 'migration comment'); - $this->assertContains('public $comment = \'migration comment\';', $body); + $this->assertStringContainsString('public $comment = \'migration comment\';', $body); } } diff --git a/tests/Propel/Tests/Generator/Model/ColumnTest.php b/tests/Propel/Tests/Generator/Model/ColumnTest.php index 2617b4d5c6..cba354fb6d 100644 --- a/tests/Propel/Tests/Generator/Model/ColumnTest.php +++ b/tests/Propel/Tests/Generator/Model/ColumnTest.php @@ -498,8 +498,8 @@ public function testEnumType() $this->assertSame('int', $column->getPhpType()); $this->assertTrue($column->isPhpPrimitiveType()); $this->assertTrue($column->isEnumType()); - $this->assertContains('FOO', $column->getValueSet()); - $this->assertContains('BAR', $column->getValueSet()); + $this->assertStringContainsString('FOO', $column->getValueSet()); + $this->assertStringContainsString('BAR', $column->getValueSet()); } /** @@ -521,8 +521,8 @@ public function testSetType() $this->assertSame('int', $column->getPhpType()); $this->assertTrue($column->isPhpPrimitiveType()); $this->assertTrue($column->isSetType()); - $this->assertContains('FOO', $column->getValueSet()); - $this->assertContains('BAR', $column->getValueSet()); + $this->assertStringContainsString('FOO', $column->getValueSet()); + $this->assertStringContainsString('BAR', $column->getValueSet()); } /** @@ -533,9 +533,9 @@ public function testSetStringValueSet() $column = new Column(); $column->setValueSet(' FOO , BAR , BAZ'); - $this->assertContains('FOO', $column->getValueSet()); - $this->assertContains('BAR', $column->getValueSet()); - $this->assertContains('BAZ', $column->getValueSet()); + $this->assertStringContainsString('FOO', $column->getValueSet()); + $this->assertStringContainsString('BAR', $column->getValueSet()); + $this->assertStringContainsString('BAZ', $column->getValueSet()); } /** diff --git a/tests/Propel/Tests/Generator/Model/TableTest.php b/tests/Propel/Tests/Generator/Model/TableTest.php index 8e3ebacba5..80626fbaea 100644 --- a/tests/Propel/Tests/Generator/Model/TableTest.php +++ b/tests/Propel/Tests/Generator/Model/TableTest.php @@ -803,7 +803,7 @@ public function testAddForeignKey() $this->assertInstanceOf('Propel\Generator\Model\ForeignKey', $table->addForeignKey($fk)); $this->assertCount(1, $table->getForeignKeys()); $this->assertTrue($table->hasForeignKeys()); - $this->assertContains('authors', $table->getForeignTableNames()); + $this->assertStringContainsString('authors', $table->getForeignTableNames()); } /** @@ -826,7 +826,7 @@ public function testAddArrayForeignKey() $this->assertCount(1, $table->getForeignKeys()); $this->assertTrue($table->hasForeignKeys()); - $this->assertContains('authors', $table->getForeignTableNames()); + $this->assertStringContainsString('authors', $table->getForeignTableNames()); } /** @@ -882,7 +882,7 @@ public function testGetColumnForeignKeys() $table->addForeignKey($fk2); $this->assertCount(1, $table->getColumnForeignKeys('author_id')); - $this->assertContains($fk1, $table->getColumnForeignKeys('author_id')); + $this->assertStringContainsString($fk1, $table->getColumnForeignKeys('author_id')); } /** diff --git a/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php b/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php index bcd81128f8..f15070da6a 100644 --- a/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php +++ b/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php @@ -103,7 +103,7 @@ public function testValidateReturnsFalseWhenTwoTablesHaveSamePhpName() $validator = new SchemaValidator($schema); $this->assertFalse($validator->validate()); - $this->assertContains('Table "bar" declares a phpName already used in another table', $validator->getErrors()); + $this->assertStringContainsString('Table "bar" declares a phpName already used in another table', $validator->getErrors()); } /** @@ -147,7 +147,7 @@ public function testValidateReturnsFalseWhenTableHasNoPk() $validator = new SchemaValidator($schema); $this->assertFalse($validator->validate()); - $this->assertContains('Table "foo" does not have a primary key defined. Propel requires all tables to have a primary key.', $validator->getErrors()); + $this->assertStringContainsString('Table "foo" does not have a primary key defined. Propel requires all tables to have a primary key.', $validator->getErrors()); } /** @@ -173,7 +173,7 @@ public function testValidateReturnsFalseWhenTableHasAReservedName() $validator = new SchemaValidator($schema); $this->assertFalse($validator->validate()); - $this->assertContains('Table "TABLE_NAME" uses a reserved keyword as name', $validator->getErrors()); + $this->assertStringContainsString('Table "TABLE_NAME" uses a reserved keyword as name', $validator->getErrors()); } /** @@ -194,6 +194,6 @@ public function testValidateReturnsFalseWhenTwoColumnsHaveSamePhpName() $validator = new SchemaValidator($schema); $this->assertFalse($validator->validate()); - $this->assertContains('Column "bar" declares a phpName already used in table "foo_table"', $validator->getErrors()); + $this->assertStringContainsString('Column "bar" declares a phpName already used in table "foo_table"', $validator->getErrors()); } } diff --git a/tests/Propel/Tests/Issues/Issue617Test.php b/tests/Propel/Tests/Issues/Issue617Test.php index 13ca8966a4..f22fb39e95 100644 --- a/tests/Propel/Tests/Issues/Issue617Test.php +++ b/tests/Propel/Tests/Issues/Issue617Test.php @@ -127,7 +127,7 @@ private function setupInitSchema() ) ENGINE=InnoDB CHARACTER SET=\'utf8\'; '; - $this->assertContains($expected, $sql); + $this->assertStringContainsString($expected, $sql); $this->updateSchema($builder->getDatabase()); } @@ -180,7 +180,7 @@ private function dropForeignKey() DROP `group_id`; '; - $this->assertContains($expected, $sql); + $this->assertStringContainsString($expected, $sql); $this->updateSchema($this->updatedBuilder->getDatabase()); } @@ -199,7 +199,7 @@ private function checkDeletedFk() $expected = 'issue617_user'; - $this->assertNotContains($expected, $sql); + $this->assertStringNotContainsString($expected, $sql); } /** diff --git a/tests/Propel/Tests/Issues/Issue646Test.php b/tests/Propel/Tests/Issues/Issue646Test.php index 98a0e213c5..bf3d62d723 100644 --- a/tests/Propel/Tests/Issues/Issue646Test.php +++ b/tests/Propel/Tests/Issues/Issue646Test.php @@ -106,6 +106,6 @@ public function testToArrayWithPkDate() $dates = PkDateQuery::create()->find(); - $this->assertInternalType('array', $dates->toArray()); + $this->assertIsArray($dates->toArray()); } } diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaGroupByArrayTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaGroupByArrayTest.php index 1c4c41f0ad..af6f24ac25 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaGroupByArrayTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaGroupByArrayTest.php @@ -8,6 +8,7 @@ namespace Propel\Tests\Runtime\ActiveQuery; +use Propel\Runtime\Exception\PropelException; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\AuthorQuery; use Propel\Tests\Bookstore\Book; @@ -21,12 +22,12 @@ class ModelCriteriaGroupByArrayTest extends BookstoreEmptyTestBase /** * @dataProvider dataForTestException * - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testGroupByArrayThrowException($groupBy) { + $this->expectException(PropelException::class); + $authors = AuthorQuery::create() ->leftJoinBook() ->select(['FirstName', 'LastName']) @@ -35,7 +36,7 @@ public function testGroupByArrayThrowException($groupBy) ->orderByLastName() ->find(); } - + /** * @return void */ @@ -50,13 +51,13 @@ public function testGroupByArray() $byron->setFirstName('George'); $byron->setLastName('Byron'); $byron->save(); - + $phoenix = new Book(); $phoenix->setTitle('Harry Potter and the Order of the Phoenix'); $phoenix->setISBN('043935806X'); $phoenix->setAuthor($stephenson); $phoenix->save(); - + $qs = new Book(); $qs->setISBN('0380977427'); $qs->setTitle('Quicksilver'); @@ -74,7 +75,7 @@ public function testGroupByArray() $td->setTitle('The Tin Drum'); $td->setAuthor($byron); $td->save(); - + $authors = AuthorQuery::create() ->leftJoinBook() ->select(['FirstName', 'LastName']) @@ -82,20 +83,20 @@ public function testGroupByArray() ->groupBy(['FirstName', 'LastName']) ->orderByLastName() ->find(); - + $expectedSql = 'SELECT COUNT(book.id) AS nbBooks, author.first_name AS "FirstName", author.last_name AS "LastName" FROM author LEFT JOIN book ON (author.id=book.author_id) GROUP BY author.first_name,author.last_name ORDER BY author.last_name ASC'; - + $this->assertEquals($expectedSql, $this->con->getLastExecutedQuery()); - + $this->assertEquals(2, count($authors)); - + $this->assertEquals('George', $authors[0]['FirstName']); $this->assertEquals(1, $authors[0]['nbBooks']); - + $this->assertEquals('Neal', $authors[1]['FirstName']); $this->assertEquals(3, $authors[1]['nbBooks']); } - + public function dataForTestException() { return [ diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaSelectTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaSelectTest.php index 2221a8b323..ab2c8fb076 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaSelectTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaSelectTest.php @@ -10,6 +10,7 @@ use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Collection\Collection; +use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Formatter\OnDemandFormatter; use Propel\Tests\Bookstore\BookQuery; use Propel\Tests\Bookstore\Map\AuthorTableMap; @@ -26,23 +27,23 @@ class ModelCriteriaSelectTest extends BookstoreTestBase { /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testSelectThrowsExceptionWhenCalledWithAnEmptyString() { + $this->expectException(PropelException::class); + $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $c->select(''); } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testSelectThrowsExceptionWhenCalledWithAnEmptyArray() { + $this->expectException(PropelException::class); + $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $c->select([]); } @@ -153,12 +154,12 @@ public function testSelectStringFindOne() * As $failSilently is true by default, it doesn't throw any exception, just returns null. * So, we check the query fails here. * - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testSelectStringFindCalledWithNonExistingColumn() { + $this->expectException(PropelException::class); + BookstoreDataPopulator::depopulate($this->con); BookstoreDataPopulator::populate($this->con); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php index 6c4eadd19f..b8d2f68a06 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/ModelCriteriaTest.php @@ -14,6 +14,7 @@ use Propel\Runtime\ActiveQuery\Exception\UnknownRelationException; use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Collection\Collection; +use Propel\Runtime\Exception\ClassNotFoundException; use Propel\Runtime\Exception\EntityNotFoundException; use Propel\Runtime\Exception\InvalidArgumentException; use Propel\Runtime\Exception\PropelException; @@ -752,12 +753,12 @@ public function testGroupByAlias() } /** - * @expectedException \Propel\Runtime\Exception\ClassNotFoundException - * * @return void */ public function testGroupByClassThrowsExceptionOnUnknownClass() { + $this->expectException(ClassNotFoundException::class); + $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $c->groupByClass('Author'); } @@ -1301,12 +1302,12 @@ public function testWith() } /** - * @expectedException \Propel\Runtime\ActiveQuery\Exception\UnknownRelationException - * * @return void */ public function testWithThrowsExceptionWhenJoinLacks() { + $this->expectException(UnknownRelationException::class); + $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $c->with('Propel\Tests\Bookstore\Author'); } @@ -1324,12 +1325,12 @@ public function testWithAlias() } /** - * @expectedException \Propel\Runtime\ActiveQuery\Exception\UnknownRelationException - * * @return void */ public function testWithThrowsExceptionWhenNotUsingAlias() { + $this->expectException(UnknownRelationException::class); + $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $c->join('Propel\Tests\Bookstore\Book.Author a'); $c->with('Propel\Tests\Bookstore\Author'); @@ -1878,12 +1879,12 @@ public function testFindOneOrCreateExists() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testFindOneOrCreateThrowsExceptionWhenQueryContainsJoin() { + $this->expectException(PropelException::class); + $book = BookQuery::create('b') ->filterByPrice(125) ->useAuthorQuery() @@ -2094,12 +2095,12 @@ public function testFindPkCompositeKey() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testFindPksCompositeKey() { + $this->expectException(PropelException::class); + $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\BookListRel'); $bookListRel = $c->findPks([[1, 2]]); } diff --git a/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php b/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php index b02165588b..66aee0b76d 100644 --- a/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php +++ b/tests/Propel/Tests/Runtime/Collection/ArrayCollectionTest.php @@ -11,6 +11,8 @@ use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveQuery\PropelQuery; use Propel\Runtime\Collection\ArrayCollection; +use Propel\Runtime\Exception\BadMethodCallException; +use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\Book; @@ -56,12 +58,12 @@ public function testSave() } /** - * @expectedException \Propel\Runtime\Exception\BadMethodCallException - * * @return void */ public function testSaveOnReadOnlyEntityThrowsException() { + $this->expectException(BadMethodCallException::class); + $col = new ArrayCollection(); $col->setModel('Country'); $cv = new Country(); @@ -83,12 +85,12 @@ public function testDelete() } /** - * @expectedException \Propel\Runtime\Exception\BadMethodCallException - * * @return void */ public function testDeleteOnReadOnlyEntityThrowsException() { + $this->expectException(BadMethodCallException::class); + $col = new ArrayCollection(); $col->setModel('Country'); $cv = new Country(); @@ -247,12 +249,12 @@ public function getWorkerObject() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testGetWorkerObjectNoModel() { + $this->expectException(PropelException::class); + $col = new TestableArrayCollection(); $col->getWorkerObject(); } diff --git a/tests/Propel/Tests/Runtime/Collection/CollectionTest.php b/tests/Propel/Tests/Runtime/Collection/CollectionTest.php index b8b0bfaea9..888a3b44dc 100644 --- a/tests/Propel/Tests/Runtime/Collection/CollectionTest.php +++ b/tests/Propel/Tests/Runtime/Collection/CollectionTest.php @@ -9,6 +9,7 @@ namespace Propel\Tests\Runtime\collection; use Propel\Runtime\Collection\Collection; +use Propel\Runtime\Exception\BadMethodCallException; use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Book; use Propel\Tests\Bookstore\Map\BookTableMap; @@ -135,12 +136,12 @@ public function testGet() } /** - * @expectedException \UnexpectedValueException - * * @return void */ public function testGetUnknownOffset() { + $this->expectException(\UnexpectedValueException::class); + $col = new Collection(); $bar = $col->get('foo'); } @@ -212,12 +213,12 @@ public function testRemove() } /** - * @expectedException \UnexpectedValueException - * * @return void */ public function testRemoveUnknownOffset() { + $this->expectException(\UnexpectedValueException::class); + $col = new Collection(); $col->remove(2); } @@ -290,12 +291,12 @@ public function testGetWriteConnection() } /** - * @expectedException \Propel\Runtime\Exception\BadMethodCallException - * * @return void */ public function testGetConnectionNoModel() { + $this->expectException(BadMethodCallException::class); + $col = new Collection(); $col->getConnection(); } diff --git a/tests/Propel/Tests/Runtime/Collection/ObjectCollectionTest.php b/tests/Propel/Tests/Runtime/Collection/ObjectCollectionTest.php index 9c911e03f8..3e5c4eed9a 100644 --- a/tests/Propel/Tests/Runtime/Collection/ObjectCollectionTest.php +++ b/tests/Propel/Tests/Runtime/Collection/ObjectCollectionTest.php @@ -10,7 +10,9 @@ use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Collection\ObjectCollection; +use Propel\Runtime\Exception\BadMethodCallException; use Propel\Runtime\Formatter\ObjectFormatter; +use Propel\Runtime\Exception\RuntimeException; use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\Book; @@ -47,12 +49,12 @@ public function testContains() } /** - * @expectedException \Propel\Runtime\Exception\BadMethodCallException - * * @return void */ public function testSaveOnReadOnlyEntityThrowsException() { + $this->expectException(BadMethodCallException::class); + $col = new ObjectCollection(); $col->setModel('Propel\Tests\Bookstore\Country'); $cv = new Country(); @@ -61,12 +63,12 @@ public function testSaveOnReadOnlyEntityThrowsException() } /** - * @expectedException \Propel\Runtime\Exception\BadMethodCallException - * * @return void */ public function testDeleteOnReadOnlyEntityThrowsException() { + $this->expectException(BadMethodCallException::class); + $col = new ObjectCollection(); $col->setModel('Propel\Tests\Bookstore\Country'); $cv = new Country(); @@ -173,13 +175,13 @@ public function testPopulateRelationOneToManyWithEmptyCollection() } /** - * @expectedException \Propel\Runtime\Exception\RuntimeException - * @expectedExceptionMessage Propel\Runtime\Collection\ObjectCollection::populateRelation needs instance pooling to be enabled prior to populating the collection - * * @return void */ public function testPopulateRelationWhenInstancePoolingIsDisabled() { + $this->expectException(RuntimeException::class); + $this->expectExceptionMessage('Propel\Runtime\Collection\ObjectCollection::populateRelation needs instance pooling to be enabled prior to populating the collection'); + $coll = new ObjectCollection(); Propel::disableInstancePooling(); diff --git a/tests/Propel/Tests/Runtime/Collection/OnDemandCollectionTest.php b/tests/Propel/Tests/Runtime/Collection/OnDemandCollectionTest.php index 438f63778d..012d9acb0e 100644 --- a/tests/Propel/Tests/Runtime/Collection/OnDemandCollectionTest.php +++ b/tests/Propel/Tests/Runtime/Collection/OnDemandCollectionTest.php @@ -11,6 +11,8 @@ use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveQuery\PropelQuery; use Propel\Runtime\Collection\OnDemandCollection; +use Propel\Runtime\Exception\BadMethodCallException; +use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Propel; use Propel\Tests\Helpers\Bookstore\BookstoreDataPopulator; use Propel\Tests\Helpers\Bookstore\BookstoreEmptyTestBase; @@ -67,42 +69,42 @@ public function testKeys() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testoffsetExists() { + $this->expectException(PropelException::class); + $this->books->offsetExists(2); } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testoffsetGet() { + $this->expectException(PropelException::class); + $this->books->offsetGet(2); } /** - * @expectedException \Propel\Runtime\Exception\BadMethodCallException - * * @return void */ public function testoffsetSet() { + $this->expectException(BadMethodCallException::class); + $this->books->offsetSet(2, 'foo'); } /** - * @expectedException \Propel\Runtime\Exception\BadMethodCallException - * * @return void */ public function testoffsetUnset() { + $this->expectException(BadMethodCallException::class); + $this->books->offsetUnset(2); } @@ -116,12 +118,12 @@ public function testToArray() } /** - * @expectedException \Propel\Runtime\Exception\BadMethodCallException - * * @return void */ public function testFromArray() { + $this->expectException(BadMethodCallException::class); + $this->books->fromArray([]); } } diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php index 5e5909c3fd..e2123c7c50 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php @@ -137,7 +137,7 @@ public function testGetReadConnectionBuildsConnectionBasedOnARandomReadConfigura $con = $manager->getReadConnection(new SqliteAdapter()); $pdo = $con->getWrappedConnection(); $expected = [PDO::CASE_LOWER, PDO::CASE_UPPER]; - $this->assertContains($pdo->getAttribute(PDO::ATTR_CASE), $expected); + $this->assertStringContainsString($pdo->getAttribute(PDO::ATTR_CASE), $expected); } /** diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php index b36e75febc..64171c552d 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php @@ -134,7 +134,7 @@ public function testGetReadConnectionBuildsConnectionBasedOnARandomReadConfigura $con = $manager->getReadConnection(new SqliteAdapter()); $pdo = $con->getWrappedConnection(); $expected = [PDO::CASE_LOWER, PDO::CASE_UPPER]; - $this->assertContains($pdo->getAttribute(PDO::ATTR_CASE), $expected); + $this->assertStringContainsString($pdo->getAttribute(PDO::ATTR_CASE), $expected); } /** diff --git a/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterWithTest.php b/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterWithTest.php index a1f6f7cc58..48b108dc10 100644 --- a/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterWithTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/ArrayFormatterWithTest.php @@ -9,6 +9,7 @@ namespace Propel\Tests\Runtime\Formatter; use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\Exception\LogicException; use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\AuthorQuery; @@ -284,12 +285,12 @@ public function testFindOneWithDistantClassRenamedRelation() } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * * @return void */ public function testFindOneWithOneToManyAndLimit() { + $this->expectException(LogicException::class); + $c = new ModelCriteria('bookstore', '\Propel\Tests\Bookstore\Book'); $c->setFormatter(ModelCriteria::FORMAT_ARRAY); $c->add(BookTableMap::COL_ISBN, '043935806X'); diff --git a/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterWithTest.php b/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterWithTest.php index 07c5980b38..71b405b8f1 100644 --- a/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterWithTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/ObjectFormatterWithTest.php @@ -10,6 +10,7 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\Exception\LogicException; use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\AuthorQuery; @@ -361,12 +362,12 @@ public function testFindOneWithDistantClassRenamedRelation() } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * * @return void */ public function testFindOneWithOneToManyAndLimit() { + $this->expectException(LogicException::class); + $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book'); $c->add(BookTableMap::COL_ISBN, '043935806X'); $c->leftJoin('Book.Review'); diff --git a/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterTest.php b/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterTest.php index fdc417922b..2025df19a7 100644 --- a/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterTest.php @@ -123,12 +123,12 @@ public function testFormatManyResults() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testFormatManyResultsIteratedTwice() { + $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); BookstoreDataPopulator::populate($con); diff --git a/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterWithTest.php b/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterWithTest.php index a8941f5f2f..3b7d755151 100644 --- a/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterWithTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterWithTest.php @@ -9,6 +9,7 @@ namespace Propel\Tests\Runtime\Formatter; use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\Exception\LogicException; use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\Book; @@ -275,12 +276,12 @@ public function testFindOneWithDistantClassRenamedRelation() } /** - * @expectedException \Propel\Runtime\Exception\LogicException - * * @return void */ public function testFindOneWithOneToMany() { + $this->expectException(LogicException::class); + BookstoreDataPopulator::populate(); BookTableMap::clearInstancePool(); AuthorTableMap::clearInstancePool(); diff --git a/tests/Propel/Tests/Runtime/Util/PropelModelPagerTest.php b/tests/Propel/Tests/Runtime/Util/PropelModelPagerTest.php index 17e22e7964..8934f818bf 100644 --- a/tests/Propel/Tests/Runtime/Util/PropelModelPagerTest.php +++ b/tests/Propel/Tests/Runtime/Util/PropelModelPagerTest.php @@ -206,7 +206,7 @@ public function testGetLastPage() $this->createBooks(5); $pager = $this->getPager(4, 1); $this->assertEquals(2, $pager->getLastPage(), 'getLastPage() returns the last page number'); - $this->assertInternalType('integer', $pager->getLastPage(), 'getLastPage() returns an integer'); + $this->assertIsInt($pager->getLastPage(), 'getLastPage() returns an integer'); } /** diff --git a/tests/Propel/Tests/Runtime/Util/TableMapExceptionsTest.php b/tests/Propel/Tests/Runtime/Util/TableMapExceptionsTest.php index 4fa80bca16..007a2f0ccd 100644 --- a/tests/Propel/Tests/Runtime/Util/TableMapExceptionsTest.php +++ b/tests/Propel/Tests/Runtime/Util/TableMapExceptionsTest.php @@ -36,7 +36,7 @@ public function testDoSelect() $c->doSelect(); $this->fail('Missing expected exception on BAD SQL'); } catch (PropelException $e) { - $this->assertContains($this->getSql('[SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.id BAD SQL:p1]'), $e->getMessage(), 'SQL query is written in the exception message'); + $this->assertStringContainsString($this->getSql('[SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.id BAD SQL:p1]'), $e->getMessage(), 'SQL query is written in the exception message'); } } @@ -52,7 +52,7 @@ public function testDoCount() $c->doCount(); $this->fail('Missing expected exception on BAD SQL'); } catch (PropelException $e) { - $this->assertContains($this->getSql('[SELECT COUNT(*) FROM book WHERE book.id BAD SQL:p1]'), $e->getMessage(), 'SQL query is written in the exception message'); + $this->assertStringContainsString($this->getSql('[SELECT COUNT(*) FROM book WHERE book.id BAD SQL:p1]'), $e->getMessage(), 'SQL query is written in the exception message'); } } @@ -68,7 +68,7 @@ public function testDoDelete() $c->doDelete(Propel::getServiceContainer()->getWriteConnection(BookTableMap::DATABASE_NAME)); $this->fail('Missing expected exception on BAD SQL'); } catch (PropelException $e) { - $this->assertContains($this->getSql('[DELETE FROM book WHERE book.id BAD SQL:p1]'), $e->getMessage(), 'SQL query is written in the exception message'); + $this->assertStringContainsString($this->getSql('[DELETE FROM book WHERE book.id BAD SQL:p1]'), $e->getMessage(), 'SQL query is written in the exception message'); } } @@ -87,7 +87,7 @@ public function testDoUpdate() $c1->doUpdate($c2, Propel::getServiceContainer()->getWriteConnection(BookTableMap::DATABASE_NAME)); $this->fail('Missing expected exception on BAD SQL'); } catch (PropelException $e) { - $this->assertContains($this->getSql('[UPDATE book SET title=:p1 WHERE book.id BAD SQL:p2]'), $e->getMessage(), 'SQL query is written in the exception message'); + $this->assertStringContainsString($this->getSql('[UPDATE book SET title=:p1 WHERE book.id BAD SQL:p2]'), $e->getMessage(), 'SQL query is written in the exception message'); } } @@ -109,9 +109,9 @@ public function testDoInsert() $this->fail('Missing expected exception on BAD SQL'); } catch (PropelException $e) { if ($db->isGetIdBeforeInsert()) { - $this->assertContains($this->getSql('[INSERT INTO book (author_id,id) VALUES (:p1,:p2)]'), $e->getMessage(), 'SQL query is written in the exception message'); + $this->assertStringContainsString($this->getSql('[INSERT INTO book (author_id,id) VALUES (:p1,:p2)]'), $e->getMessage(), 'SQL query is written in the exception message'); } else { - $this->assertContains($this->getSql('[INSERT INTO book (author_id) VALUES (:p1)]'), $e->getMessage(), 'SQL query is written in the exception message'); + $this->assertStringContainsString($this->getSql('[INSERT INTO book (author_id) VALUES (:p1)]'), $e->getMessage(), 'SQL query is written in the exception message'); } } } diff --git a/tests/Propel/Tests/Runtime/Util/TableMapTest.php b/tests/Propel/Tests/Runtime/Util/TableMapTest.php index 5dda42f249..a435a1ef30 100644 --- a/tests/Propel/Tests/Runtime/Util/TableMapTest.php +++ b/tests/Propel/Tests/Runtime/Util/TableMapTest.php @@ -254,24 +254,24 @@ public function testMssqlApplyLimitWithOffsetMultipleOrderBy() } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testDoDeleteNoCondition() { + $this->expectException(PropelException::class); + $con = Propel::getServiceContainer()->getWriteConnection(BookTableMap::DATABASE_NAME); $c = new Criteria(BookTableMap::DATABASE_NAME); $c->doDelete($con); } /** - * @expectedException \Propel\Runtime\Exception\PropelException - * * @return void */ public function testDoDeleteJoin() { + $this->expectException(PropelException::class); + $con = Propel::getServiceContainer()->getWriteConnection(BookTableMap::DATABASE_NAME); $c = new Criteria(BookTableMap::DATABASE_NAME); $c->add(BookTableMap::COL_TITLE, 'War And Peace'); diff --git a/tests/Propel/Tests/Ticket520Test.php b/tests/Propel/Tests/Ticket520Test.php index f08bb934a0..c3b87ce5e4 100644 --- a/tests/Propel/Tests/Ticket520Test.php +++ b/tests/Propel/Tests/Ticket520Test.php @@ -276,8 +276,8 @@ public function testNewObjectsGetLostOnJoin() $books = $a->getBooksJoinPublisher(); $this->assertEquals(2, count($books)); - $this->assertContains($b1, $books); - $this->assertContains($b2, $books); + $this->assertStringContainsString($b1, $books); + $this->assertStringContainsString($b2, $books); $a->save(); $this->assertFalse($b1->isNew()); From dc89c017e350ef948964dea236fd26a2729b1ac6 Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Fri, 30 Oct 2020 20:14:18 +0200 Subject: [PATCH 170/208] PHP8 CodeStyle and tests fixes --- phpstan-baseline.neon | 5 ---- .../Runtime/Adapter/Pdo/PgsqlAdapter.php | 2 +- .../Runtime/Collection/CollectionIterator.php | 6 +++-- .../Connection/ConnectionInterface.php | 9 ++++---- .../Runtime/Connection/ConnectionWrapper.php | 10 ++++---- .../Runtime/Connection/PdoConnection.php | 11 ++++++++- .../Runtime/Connection/StatementInterface.php | 6 +++-- .../Runtime/Connection/StatementWrapper.php | 23 +++++++++++-------- .../Config/ConfigurationManagerTest.php | 2 +- .../Tests/Generator/Model/ColumnTest.php | 14 +++++------ .../Tests/Generator/Model/TableTest.php | 6 ++--- .../Generator/Util/SchemaValidatorTest.php | 8 +++---- .../ConnectionManagerMasterSlaveTest.php | 2 +- .../ConnectionManagerPrimaryReplicaTest.php | 2 +- tests/Propel/Tests/Runtime/TypeTest.php | 6 ++--- 15 files changed, 61 insertions(+), 51 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index afd7954863..807897e3d5 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -390,11 +390,6 @@ parameters: count: 1 path: src/Propel/Generator/Util/BehaviorLocator.php - - - message: "#^Parameter \\#1 \\$attribute of method Propel\\\\Runtime\\\\Connection\\\\ConnectionWrapper\\:\\:setAttribute\\(\\) expects string, int given\\.$#" - count: 1 - path: src/Propel/Generator/Util/QuickBuilder.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ServiceContainer\\\\ServiceContainerInterface\\:\\:setAdapter\\(\\)\\.$#" count: 1 diff --git a/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php index 16c20ef614..463eb887ac 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php @@ -229,7 +229,7 @@ public function quoteIdentifierTable($table) * @param \Propel\Runtime\Connection\ConnectionInterface $con propel connection * @param \Propel\Runtime\ActiveQuery\Criteria|string $query query the criteria or the query string * - * @return \PDOStatement A PDO statement executed using the connection, ready to be fetched + * @return \Propel\Runtime\Connection\StatementInterface A PDO statement executed using the connection, ready to be fetched */ public function doExplainPlan(ConnectionInterface $con, $query) { diff --git a/src/Propel/Runtime/Collection/CollectionIterator.php b/src/Propel/Runtime/Collection/CollectionIterator.php index fd4f18eae5..775f237a4e 100644 --- a/src/Propel/Runtime/Collection/CollectionIterator.php +++ b/src/Propel/Runtime/Collection/CollectionIterator.php @@ -230,22 +230,24 @@ public function append($value) /** * @param int $sort_flags - * + * * @return void */ public function asort($sort_flags = SORT_REGULAR) { + /* @phpstan-ignore-next-line */ parent::asort($sort_flags); $this->refreshPositions(); } /** * @param int $sort_flags - * + * * @return void */ public function ksort($sort_flags = SORT_REGULAR) { + /* @phpstan-ignore-next-line */ parent::ksort($sort_flags); $this->refreshPositions(); } diff --git a/src/Propel/Runtime/Connection/ConnectionInterface.php b/src/Propel/Runtime/Connection/ConnectionInterface.php index c6d3bd7c3c..542a05e91f 100644 --- a/src/Propel/Runtime/Connection/ConnectionInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionInterface.php @@ -77,7 +77,7 @@ public function inTransaction(); /** * Retrieve a database connection attribute. * - * @param string|int $attribute The name of the attribute to retrieve, + * @param int $attribute The name of the attribute to retrieve, * e.g. PDO::ATTR_AUTOCOMMIT * * @return mixed A successful call returns the value of the requested attribute. @@ -88,7 +88,7 @@ public function getAttribute(int $attribute); /** * Set an attribute. * - * @param string|int $attribute + * @param int|string $attribute * @param mixed $value * * @return bool TRUE on success or FALSE on failure. @@ -166,12 +166,11 @@ public function exec($statement); * * @param string $statement This must be a valid SQL statement for the target * database server. - * @param array|null $driver_options + * @param array $driver_options * * @throws \Propel\Runtime\Connection\Exception\ConnectionException depending on error handling. * - * @return \PDOStatement|bool A Statement object if the database server - * successfully prepares, FALSE otherwise. + * @return \Propel\Runtime\Connection\StatementInterface|\PDOStatement|bool */ public function prepare(string $statement, array $driver_options = []); diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index 42cfcaee01..fcdd49e3eb 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -231,7 +231,7 @@ public function commit() $return = true; $opcount = $this->nestedTransactionCount; - if ($opcount > 0) { + if ($opcount > 0 and $this->inTransaction()) { if ($opcount === 1) { if ($this->isUncommitable) { throw new RollbackException('Cannot commit because a nested transaction was rolled back'); @@ -260,7 +260,7 @@ public function rollBack() $return = true; $opcount = $this->nestedTransactionCount; - if ($opcount > 0) { + if ($opcount > 0 and $this->inTransaction()) { if ($opcount === 1) { $return = $this->connection->rollBack(); if ($this->useDebug) { @@ -335,7 +335,7 @@ public function getAttribute(int $attribute) /** * Set an attribute. * - * @param string|int $attribute The attribute name, or the constant name containing the attribute name (e.g. 'PDO::ATTR_CASE') + * @param int|string $attribute The attribute name, or the constant name containing the attribute name (e.g. 'PDO::ATTR_CASE') * @param mixed $value * * @throws \Propel\Runtime\Exception\InvalidArgumentException @@ -380,10 +380,10 @@ public function setAttribute($attribute, $value) * - Add query caching support if the PropelPDO::PROPEL_ATTR_CACHE_PREPARES was set to true. * * @param string $statement This must be a valid SQL statement for the target database server. - * @param array|null $driver_options One $array or more key => value pairs to set attribute values + * @param array $driver_options One $array or more key => value pairs to set attribute values * for the PDOStatement object that this method returns. * - * @return \PDOStatement + * @return \Propel\Runtime\Connection\StatementInterface|bool */ public function prepare(string $statement, array $driver_options = []) { diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index 2b190bae2f..ba5e8e4b20 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -176,7 +176,7 @@ public function lastInsertId($name = null) * @param string $statement * @param array $driver_options * - * @return bool|\PDOStatement + * @return \PDOStatement|bool */ public function prepare(string $statement, array $driver_options = []) { @@ -196,16 +196,25 @@ public function quote($string, $parameter_type = \PDO::PARAM_STR) return $this->pdo->quote($string, $parameter_type); } + /** + * @return bool + */ public function beginTransaction() { return $this->pdo->beginTransaction(); } + /** + * @return bool + */ public function commit() { return $this->pdo->commit(); } + /** + * @return bool + */ public function rollBack() { return $this->pdo->rollBack(); diff --git a/src/Propel/Runtime/Connection/StatementInterface.php b/src/Propel/Runtime/Connection/StatementInterface.php index 6852fbdebd..a975376f74 100644 --- a/src/Propel/Runtime/Connection/StatementInterface.php +++ b/src/Propel/Runtime/Connection/StatementInterface.php @@ -10,8 +10,10 @@ namespace Propel\Runtime\Connection; +use PDO; + /** - * Interface for Propel StatementWrapper object. + * Interface for Propel Statement object. * Based on the PDOStatement interface. * @see http://php.net/manual/en/book.pdo.php * @@ -370,7 +372,7 @@ public function closeCursor(); /** * Dump an SQL prepared command - * @return bool No value is returned. + * @return void No value is returned. */ public function debugDumpParams(); } diff --git a/src/Propel/Runtime/Connection/StatementWrapper.php b/src/Propel/Runtime/Connection/StatementWrapper.php index 2a7d30c6e7..03469f058c 100644 --- a/src/Propel/Runtime/Connection/StatementWrapper.php +++ b/src/Propel/Runtime/Connection/StatementWrapper.php @@ -76,7 +76,9 @@ public function __construct($sql, ConnectionWrapper $connection) */ public function prepare($options) { - $this->statement = $this->connection->getWrappedConnection()->prepare($this->sql, $options); + /** @var \PDOStatement $statement */ + $statement = $this->connection->getWrappedConnection()->prepare($this->sql, $options); + $this->statement = $statement; return $this; } @@ -86,10 +88,11 @@ public function prepare($options) */ public function query() { - $wrapped_connection = $this->connection->getWrappedConnection(); - $this->statement = $wrapped_connection->query($this->sql); + /** @var \PDOStatement $statement */ + $statement = $this->connection->getWrappedConnection()->query($this->sql); + $this->statement = $statement; - return $wrapped_connection->getDataFetcher($this); + return $this->connection->getWrappedConnection()->getDataFetcher($this); } /** @@ -301,7 +304,7 @@ public function rowCount() * * @return \Traversable */ - public function getIterator(): \Iterator + public function getIterator(): \Traversable { return $this->statement; } @@ -415,18 +418,18 @@ public function nextRowset() /** * {@inheritDoc} */ - public function debugDumpParams() + public function debugDumpParams(): void { - return $this->statement->debugDumpParams(); + $this->statement->debugDumpParams(); } /** - * @param $method - * @param $args + * @param string $method + * @param mixed $args * * @return mixed */ - public function __call($method, $args) + public function __call(string $method, $args) { return call_user_func_array([$this->statement, $method], $args); } diff --git a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php index 5a059e5847..373f7cbb4f 100644 --- a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php +++ b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php @@ -9,8 +9,8 @@ namespace Propel\Tests\Common\Config; use Propel\Common\Config\ConfigurationManager; -use Propel\Common\Config\Exception\InvalidConfigurationException; use Propel\Common\Config\Exception\InvalidArgumentException; +use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; class ConfigurationManagerTest extends ConfigTestCase { diff --git a/tests/Propel/Tests/Generator/Model/ColumnTest.php b/tests/Propel/Tests/Generator/Model/ColumnTest.php index cba354fb6d..2617b4d5c6 100644 --- a/tests/Propel/Tests/Generator/Model/ColumnTest.php +++ b/tests/Propel/Tests/Generator/Model/ColumnTest.php @@ -498,8 +498,8 @@ public function testEnumType() $this->assertSame('int', $column->getPhpType()); $this->assertTrue($column->isPhpPrimitiveType()); $this->assertTrue($column->isEnumType()); - $this->assertStringContainsString('FOO', $column->getValueSet()); - $this->assertStringContainsString('BAR', $column->getValueSet()); + $this->assertContains('FOO', $column->getValueSet()); + $this->assertContains('BAR', $column->getValueSet()); } /** @@ -521,8 +521,8 @@ public function testSetType() $this->assertSame('int', $column->getPhpType()); $this->assertTrue($column->isPhpPrimitiveType()); $this->assertTrue($column->isSetType()); - $this->assertStringContainsString('FOO', $column->getValueSet()); - $this->assertStringContainsString('BAR', $column->getValueSet()); + $this->assertContains('FOO', $column->getValueSet()); + $this->assertContains('BAR', $column->getValueSet()); } /** @@ -533,9 +533,9 @@ public function testSetStringValueSet() $column = new Column(); $column->setValueSet(' FOO , BAR , BAZ'); - $this->assertStringContainsString('FOO', $column->getValueSet()); - $this->assertStringContainsString('BAR', $column->getValueSet()); - $this->assertStringContainsString('BAZ', $column->getValueSet()); + $this->assertContains('FOO', $column->getValueSet()); + $this->assertContains('BAR', $column->getValueSet()); + $this->assertContains('BAZ', $column->getValueSet()); } /** diff --git a/tests/Propel/Tests/Generator/Model/TableTest.php b/tests/Propel/Tests/Generator/Model/TableTest.php index 80626fbaea..8e3ebacba5 100644 --- a/tests/Propel/Tests/Generator/Model/TableTest.php +++ b/tests/Propel/Tests/Generator/Model/TableTest.php @@ -803,7 +803,7 @@ public function testAddForeignKey() $this->assertInstanceOf('Propel\Generator\Model\ForeignKey', $table->addForeignKey($fk)); $this->assertCount(1, $table->getForeignKeys()); $this->assertTrue($table->hasForeignKeys()); - $this->assertStringContainsString('authors', $table->getForeignTableNames()); + $this->assertContains('authors', $table->getForeignTableNames()); } /** @@ -826,7 +826,7 @@ public function testAddArrayForeignKey() $this->assertCount(1, $table->getForeignKeys()); $this->assertTrue($table->hasForeignKeys()); - $this->assertStringContainsString('authors', $table->getForeignTableNames()); + $this->assertContains('authors', $table->getForeignTableNames()); } /** @@ -882,7 +882,7 @@ public function testGetColumnForeignKeys() $table->addForeignKey($fk2); $this->assertCount(1, $table->getColumnForeignKeys('author_id')); - $this->assertStringContainsString($fk1, $table->getColumnForeignKeys('author_id')); + $this->assertContains($fk1, $table->getColumnForeignKeys('author_id')); } /** diff --git a/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php b/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php index 1ad1598960..d294e69a60 100644 --- a/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php +++ b/tests/Propel/Tests/Generator/Util/SchemaValidatorTest.php @@ -103,7 +103,7 @@ public function testValidateReturnsFalseWhenTwoTablesHaveSamePhpName() $validator = new SchemaValidator($schema); $this->assertFalse($validator->validate()); - $this->assertStringContainsString('Table "bar" declares a phpName already used in another table', $validator->getErrors()); + $this->assertContains('Table "bar" declares a phpName already used in another table', $validator->getErrors()); } /** @@ -147,7 +147,7 @@ public function testValidateReturnsFalseWhenTableHasNoPk() $validator = new SchemaValidator($schema); $this->assertFalse($validator->validate()); - $this->assertStringContainsString('Table "foo" does not have a primary key defined. Propel requires all tables to have a primary key.', $validator->getErrors()); + $this->assertContains('Table "foo" does not have a primary key defined. Propel requires all tables to have a primary key.', $validator->getErrors()); } /** @@ -173,7 +173,7 @@ public function testValidateReturnsFalseWhenTableHasAReservedName() $validator = new SchemaValidator($schema); $this->assertFalse($validator->validate()); - $this->assertStringContainsString('Table "TABLE_NAME" uses a reserved keyword as name', $validator->getErrors()); + $this->assertContains('Table "TABLE_NAME" uses a reserved keyword as name', $validator->getErrors()); } /** @@ -194,6 +194,6 @@ public function testValidateReturnsFalseWhenTwoColumnsHaveSamePhpName() $validator = new SchemaValidator($schema); $this->assertFalse($validator->validate()); - $this->assertStringContainsString('Column "bar" declares a phpName already used in table "foo_table"', $validator->getErrors()); + $this->assertContains('Column "bar" declares a phpName already used in table "foo_table"', $validator->getErrors()); } } diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php index e2123c7c50..5e5909c3fd 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php @@ -137,7 +137,7 @@ public function testGetReadConnectionBuildsConnectionBasedOnARandomReadConfigura $con = $manager->getReadConnection(new SqliteAdapter()); $pdo = $con->getWrappedConnection(); $expected = [PDO::CASE_LOWER, PDO::CASE_UPPER]; - $this->assertStringContainsString($pdo->getAttribute(PDO::ATTR_CASE), $expected); + $this->assertContains($pdo->getAttribute(PDO::ATTR_CASE), $expected); } /** diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php index 64171c552d..b36e75febc 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php @@ -134,7 +134,7 @@ public function testGetReadConnectionBuildsConnectionBasedOnARandomReadConfigura $con = $manager->getReadConnection(new SqliteAdapter()); $pdo = $con->getWrappedConnection(); $expected = [PDO::CASE_LOWER, PDO::CASE_UPPER]; - $this->assertStringContainsString($pdo->getAttribute(PDO::ATTR_CASE), $expected); + $this->assertContains($pdo->getAttribute(PDO::ATTR_CASE), $expected); } /** diff --git a/tests/Propel/Tests/Runtime/TypeTest.php b/tests/Propel/Tests/Runtime/TypeTest.php index b460fb9fbf..028a279655 100644 --- a/tests/Propel/Tests/Runtime/TypeTest.php +++ b/tests/Propel/Tests/Runtime/TypeTest.php @@ -30,7 +30,7 @@ public function testTypeHintClass() $method = $reflection->getMethod('setDummyObject'); $param = $method->getParameters()[0]; - $this->assertEquals(DummyObjectClass::class, $param->getClass()->name); + $this->assertEquals(DummyObjectClass::class, $param->getType()->getName()); $this->assertTrue($param->allowsNull()); } @@ -43,7 +43,7 @@ public function testTypeHintArray() $method = $reflection->getMethod('setSomeArray'); $param = $method->getParameters()[0]; - $this->assertTrue($param->isArray()); + $this->assertTrue($param->getType() && $param->getType()->getName() === 'array'); $this->assertTrue($param->allowsNull()); } @@ -56,7 +56,7 @@ public function testInterface() $method = $reflection->getMethod('setTypeObject'); $param = $method->getParameters()[0]; - $this->assertEquals(TypeObjectInterface::class, $param->getClass()->name); + $this->assertEquals(TypeObjectInterface::class, $param->getType()->getName()); $this->assertTrue($param->allowsNull()); } From 3c347c328c0db6f07a557494ce348ebefa23e762 Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Fri, 30 Oct 2020 20:20:39 +0200 Subject: [PATCH 171/208] PHP8 CS fixes --- src/Propel/Runtime/Connection/PdoConnection.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index ba5e8e4b20..653513ddcf 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -79,8 +79,6 @@ public function __construct(string $dsn, ?string $user = null, ?string $password } } - //var_dump($dsn, $user, $password, $pdoOptions); - $this->pdo = new \PDO($dsn, $user, $password, $pdoOptions); $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); } From f8458a248a0166e7db364f931c16c55d0c0e41cf Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Sat, 31 Oct 2020 13:24:46 +0200 Subject: [PATCH 172/208] PHP8 fixed CS --- src/Propel/Generator/Util/QuickBuilder.php | 4 +- src/Propel/Generator/Util/SqlParser.php | 4 +- src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php | 2 +- .../Runtime/Adapter/SqlAdapterInterface.php | 2 +- .../Connection/ConnectionInterface.php | 9 +- .../Runtime/Connection/ConnectionWrapper.php | 16 +- .../Runtime/Connection/PdoConnection.php | 28 +- .../Connection/ProfilerConnectionWrapper.php | 8 +- .../Runtime/Connection/StatementInterface.php | 341 +++++------------- .../Runtime/Connection/StatementWrapper.php | 27 +- .../Config/ConfigurationManagerTest.php | 3 - .../Common/Config/Loader/FileLoaderTest.php | 16 +- .../Config/Loader/IniFileLoaderTest.php | 16 +- .../Config/Loader/JsonFileLoaderTest.php | 9 +- .../Config/Loader/PhpFileLoaderTest.php | 11 +- .../Config/Loader/XmlFileLoaderTest.php | 11 +- .../Config/Loader/YamlFileLoaderTest.php | 9 +- .../Common/Config/XmlToArrayConverterTest.php | 22 +- .../Common/Util/SetColumnConverterTest.php | 5 +- ...vableBehaviorObjectBuilderModifierTest.php | 5 +- .../Delegate/DelegateBehaviorTest.php | 3 +- ...edSetBehaviorObjectBuilderModifierTest.php | 2 +- ...viorObjectBuilderModifierWithScopeTest.php | 3 +- ...tableBehaviorObjectBuilderModifierTest.php | 2 +- ...nableBehaviorObjectBuilderModifierTest.php | 3 +- .../Om/AbstractOMBuilderNamespaceTest.php | 3 +- .../Om/GeneratedObjectEnumColumnTypeTest.php | 7 +- .../Om/GeneratedObjectSetColumnTypeTest.php | 5 +- .../GeneratedObjectTemporalColumnTypeTest.php | 3 +- .../Builder/Om/GeneratedObjectTest.php | 2 +- .../Om/GeneratedPKLessQueryBuilderTest.php | 13 +- .../Om/GeneratedQuerySetColumnTypeTest.php | 3 +- .../Builder/Util/SchemaReaderTest.php | 3 +- .../Generator/Config/GeneratorConfigTest.php | 19 +- .../Config/QuickGeneratorConfigTest.php | 3 +- .../Tests/Generator/Model/BehaviorTest.php | 6 +- .../Generator/Model/Diff/TableDiffTest.php | 3 +- .../Tests/Generator/Model/TableTest.php | 2 +- tests/Propel/Tests/Issues/Issue1659Test.php | 1 - tests/Propel/Tests/Issues/Issue675Test.php | 3 +- .../Runtime/ActiveQuery/CriteriaMergeTest.php | 5 +- .../Criterion/BasicCriterionTest.php | 3 +- .../Criterion/BasicModelCriterionTest.php | 3 +- .../Criterion/LikeModelCriterionTest.php | 3 +- .../Criterion/RawCriterionTest.php | 3 +- .../Criterion/RawModelCriterionTest.php | 3 +- .../Criterion/SeveralModelCriterionTest.php | 5 +- .../Propel/Tests/Runtime/ActiveRecordTest.php | 3 +- .../Runtime/Collection/CollectionTest.php | 5 +- .../Collection/ObjectCollectionTest.php | 2 +- .../Connection/ConnectionFactoryTest.php | 5 +- .../ConnectionManagerMasterSlaveTest.php | 3 +- .../ConnectionManagerPrimaryReplicaTest.php | 3 +- .../ConnectionManagerSingleTest.php | 3 +- .../Connection/TransactionTraitTest.php | 4 - .../Runtime/Exception/PropelExceptionTest.php | 2 +- .../Formatter/OnDemandFormatterTest.php | 2 +- .../Propel/Tests/Runtime/Map/TableMapTest.php | 3 +- .../Runtime/Parser/AbstractParserTest.php | 3 +- .../StandardServiceContainerTest.php | 3 +- .../Tests/Runtime/Util/PropelDateTimeTest.php | 3 +- 61 files changed, 287 insertions(+), 419 deletions(-) diff --git a/src/Propel/Generator/Util/QuickBuilder.php b/src/Propel/Generator/Util/QuickBuilder.php index 33c4c0bec1..e7b65f2734 100644 --- a/src/Propel/Generator/Util/QuickBuilder.php +++ b/src/Propel/Generator/Util/QuickBuilder.php @@ -10,7 +10,6 @@ use Exception; use PDO; -use PDOStatement; use Propel\Generator\Builder\Util\SchemaReader; use Propel\Generator\Config\GeneratorConfigInterface; use Propel\Generator\Config\QuickGeneratorConfig; @@ -22,8 +21,8 @@ use Propel\Runtime\Adapter\Pdo\SqliteAdapter; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Connection\ConnectionWrapper; -use Propel\Runtime\Connection\StatementWrapper; use Propel\Runtime\Connection\PdoConnection; +use Propel\Runtime\Connection\StatementWrapper; use Propel\Runtime\Propel; class QuickBuilder @@ -520,7 +519,6 @@ public static function debugClassesForTable($schema, $tableName) */ public function fixNamespaceDeclarations($source) { - $cooperativeLexems = [T_WHITESPACE, T_NS_SEPARATOR, T_STRING]; if (PHP_VERSION_ID >= 80000) { diff --git a/src/Propel/Generator/Util/SqlParser.php b/src/Propel/Generator/Util/SqlParser.php index b2771287e5..0b08edf94f 100644 --- a/src/Propel/Generator/Util/SqlParser.php +++ b/src/Propel/Generator/Util/SqlParser.php @@ -8,8 +8,8 @@ namespace Propel\Generator\Util; -use \Propel\Runtime\Connection\ConnectionInterface; -use \Propel\Runtime\Connection\StatementInterface; +use Propel\Runtime\Connection\ConnectionInterface; +use Propel\Runtime\Connection\StatementInterface; /** * Service class for parsing a large SQL string into an array of SQL statements diff --git a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php index aae8937042..03e711b014 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php @@ -611,7 +611,7 @@ public function bindValues(StatementInterface $stmt, array $params, DatabaseMap * @param string $parameter Parameter identifier * @param mixed $value The value to bind * @param \Propel\Runtime\Map\ColumnMap $cMap The ColumnMap of the column to bind - * @param null|int $position The position of the parameter to bind + * @param int|null $position The position of the parameter to bind * * @return bool */ diff --git a/src/Propel/Runtime/Adapter/SqlAdapterInterface.php b/src/Propel/Runtime/Adapter/SqlAdapterInterface.php index 02a025b4df..d652749fae 100644 --- a/src/Propel/Runtime/Adapter/SqlAdapterInterface.php +++ b/src/Propel/Runtime/Adapter/SqlAdapterInterface.php @@ -8,8 +8,8 @@ namespace Propel\Runtime\Adapter; -use Propel\Runtime\Connection\StatementInterface; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Connection\StatementInterface; use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\DatabaseMap; diff --git a/src/Propel/Runtime/Connection/ConnectionInterface.php b/src/Propel/Runtime/Connection/ConnectionInterface.php index 542a05e91f..597c7d790a 100644 --- a/src/Propel/Runtime/Connection/ConnectionInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionInterface.php @@ -11,7 +11,7 @@ use PDO; /** - * Interface for Propel Connection object. + * Interface for Propel Connection class. * Based on the PDO interface. * * @see http://php.net/manual/en/book.pdo.php @@ -164,15 +164,14 @@ public function exec($statement); * these parameters to bind any user-input, do not include the user-input * directly in the query. * - * @param string $statement This must be a valid SQL statement for the target - * database server. - * @param array $driver_options + * @param string $statement This must be a valid SQL statement for the target database server. + * @param array $driverOptions * * @throws \Propel\Runtime\Connection\Exception\ConnectionException depending on error handling. * * @return \Propel\Runtime\Connection\StatementInterface|\PDOStatement|bool */ - public function prepare(string $statement, array $driver_options = []); + public function prepare(string $statement, array $driverOptions = []); /** * Executes an SQL statement, returning a result set as a Statement object. diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index fcdd49e3eb..754cec484f 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -231,7 +231,7 @@ public function commit() $return = true; $opcount = $this->nestedTransactionCount; - if ($opcount > 0 and $this->inTransaction()) { + if ($opcount > 0 && $this->inTransaction()) { if ($opcount === 1) { if ($this->isUncommitable) { throw new RollbackException('Cannot commit because a nested transaction was rolled back'); @@ -260,7 +260,7 @@ public function rollBack() $return = true; $opcount = $this->nestedTransactionCount; - if ($opcount > 0 and $this->inTransaction()) { + if ($opcount > 0 && $this->inTransaction()) { if ($opcount === 1) { $return = $this->connection->rollBack(); if ($this->useDebug) { @@ -380,12 +380,12 @@ public function setAttribute($attribute, $value) * - Add query caching support if the PropelPDO::PROPEL_ATTR_CACHE_PREPARES was set to true. * * @param string $statement This must be a valid SQL statement for the target database server. - * @param array $driver_options One $array or more key => value pairs to set attribute values + * @param array $driverOptions One $array or more key => value pairs to set attribute values * for the PDOStatement object that this method returns. * * @return \Propel\Runtime\Connection\StatementInterface|bool */ - public function prepare(string $statement, array $driver_options = []) + public function prepare(string $statement, array $driverOptions = []) { $statementWrapper = null; @@ -393,7 +393,7 @@ public function prepare(string $statement, array $driver_options = []) $statementWrapper = $this->cachedPreparedStatements[$statement]; } else { $statementWrapper = $this->createStatementWrapper($statement); - $statementWrapper->prepare($driver_options); + $statementWrapper->prepare($driverOptions); if ($this->isCachePreparedStatements) { $this->cachedPreparedStatements[$statement] = $statementWrapper; } @@ -464,16 +464,16 @@ public function query($statement) * the underlying driver. * * @param string $string The string to be quoted. - * @param int $parameter_type Provides a data type hint for drivers that + * @param int $parameterType Provides a data type hint for drivers that * have alternate quoting styles. * * @return string A quoted string that is theoretically safe to pass into an * SQL statement. Returns FALSE if the driver does not support * quoting in this way. */ - public function quote($string, $parameter_type = 2) + public function quote($string, $parameterType = 2) { - return $this->connection->quote($string, $parameter_type); + return $this->connection->quote($string, $parameterType); } /** diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index 653513ddcf..930bb67a2c 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -32,12 +32,12 @@ class PdoConnection implements ConnectionInterface /** * Forward any call to a method not found to the proxied connection. * - * @param $method - * @param $args + * @param string $method + * @param mixed $args * * @return mixed */ - public function __call($method, $args) + public function __call(string $method, $args) { return call_user_func_array([$this->pdo, $method], $args); } @@ -70,17 +70,17 @@ public function getName() */ public function __construct(string $dsn, ?string $user = null, ?string $password = null, ?array $options = null) { - // Convert option keys from a string to a \PDO:: constant + // Convert option keys from a string to a PDO:: constant $pdoOptions = []; if (is_array($options)) { foreach ($options as $key => $option) { - $index = (is_numeric($key)) ? $key : constant('\PDO::' . $key); + $index = (is_numeric($key)) ? $key : constant('PDO::' . $key); $pdoOptions[$index] = $option; } } - $this->pdo = new \PDO($dsn, $user, $password, $pdoOptions); - $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + $this->pdo = new PDO($dsn, $user, $password, $pdoOptions); + $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } /** @@ -143,7 +143,7 @@ public function exec($statement) } /** - * {@inheritDoc} + * @inheritDoc */ public function inTransaction() { @@ -151,7 +151,7 @@ public function inTransaction() } /** - * {@inheritDoc} + * @inheritDoc */ public function getAttribute(int $attribute) { @@ -172,13 +172,13 @@ public function lastInsertId($name = null) * Overwrite. Fixes HHVM strict issue. * * @param string $statement - * @param array $driver_options + * @param array $driverOptions * * @return \PDOStatement|bool */ - public function prepare(string $statement, array $driver_options = []) + public function prepare(string $statement, array $driverOptions = []) { - return $this->pdo->prepare($statement, $driver_options); + return $this->pdo->prepare($statement, $driverOptions); } /** @@ -189,9 +189,9 @@ public function prepare(string $statement, array $driver_options = []) * * @return string */ - public function quote($string, $parameter_type = \PDO::PARAM_STR) + public function quote($string, $parameterType = PDO::PARAM_STR) { - return $this->pdo->quote($string, $parameter_type); + return $this->pdo->quote($string, $parameterType); } /** diff --git a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php index 3d3c2b22c6..335dd50030 100644 --- a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php @@ -61,8 +61,8 @@ public function getProfiler() * Overrides the parent setAttribute to support the isSlowOnly attribute. * * @param int|string $attribute The attribute name, or the constant name containing the attribute name (e.g. 'PDO::ATTR_CASE') - * @param mixed $value - * + * @param mixed $value + * * @return bool */ public function setAttribute($attribute, $value) @@ -82,11 +82,11 @@ public function setAttribute($attribute, $value) /** * @inheritDoc */ - public function prepare(string $statement, array $driver_options = []) + public function prepare(string $statement, array $driverOptions = []) { $this->getProfiler()->start(); - return parent::prepare($statement, $driver_options); + return parent::prepare($statement, $driverOptions); } /** diff --git a/src/Propel/Runtime/Connection/StatementInterface.php b/src/Propel/Runtime/Connection/StatementInterface.php index a975376f74..22c9a1427f 100644 --- a/src/Propel/Runtime/Connection/StatementInterface.php +++ b/src/Propel/Runtime/Connection/StatementInterface.php @@ -1,11 +1,9 @@ - * An array of values with as many elements as there are bound - * parameters in the SQL statement being executed. - * All values are treated as PDO::PARAM_STR. - *

- *

- * You cannot bind multiple values to a single parameter; for example, - * you cannot bind two values to a single named parameter in an IN() - * clause. - *

- *

- * You cannot bind more values than specified; if more keys exist in - * input_parameters than in the SQL specified - * in the PDO::prepare, then the statement will - * fail and an error is emitted. - *

- * @return bool TRUE on success or FALSE on failure. + * + * @param array|null $input_parameters + * * @throws \PDOException On error if PDO::ERRMODE_EXCEPTION option is true. + * + * @return bool TRUE on success or FALSE on failure. */ public function execute($input_parameters = null); /** * Fetches the next row from a result set - * @param int $fetch_style [optional]

- * Controls how the next row will be returned to the caller. This value - * must be one of the PDO::FETCH_* constants, - * defaulting to value of PDO::ATTR_DEFAULT_FETCH_MODE - * (which defaults to PDO::FETCH_BOTH). - *

- * PDO::FETCH_ASSOC: returns an array indexed by column - * name as returned in your result set - *

- * @param int $cursor_orientation [optional]

- * For a PDOStatement object representing a scrollable cursor, this - * value determines which row will be returned to the caller. This value - * must be one of the PDO::FETCH_ORI_* constants, - * defaulting to PDO::FETCH_ORI_NEXT. To request a - * scrollable cursor for your PDOStatement object, you must set the - * PDO::ATTR_CURSOR attribute to - * PDO::CURSOR_SCROLL when you prepare the SQL - * statement with PDO::prepare. - *

- * @param int $cursor_offset [optional] - * @return mixed The return value of this function on success depends on the fetch type. In - * all cases, FALSE is returned on failure. + * + * @param int|null $fetch_style Controls how the next row will be returned to the caller. + * @param int $cursor_orientation This value determines which row will be returned to the caller. + * @param int $cursor_offset + * + * @return mixed */ public function fetch($fetch_style = null, $cursor_orientation = PDO::FETCH_ORI_NEXT, $cursor_offset = 0); /** * Binds a parameter to the specified variable name - * @param mixed $parameter

- * Parameter identifier. For a prepared statement using named - * placeholders, this will be a parameter name of the form - * :name. For a prepared statement using - * question mark placeholders, this will be the 1-indexed position of - * the parameter. - *

- * @param mixed $variable

- * Name of the PHP variable to bind to the SQL statement parameter. - *

- * @param int $data_type [optional]

- * Explicit data type for the parameter using the PDO::PARAM_* - * constants. - * To return an INOUT parameter from a stored procedure, - * use the bitwise OR operator to set the PDO::PARAM_INPUT_OUTPUT bits - * for the data_type parameter. - *

- * @param int $length [optional]

- * Length of the data type. To indicate that a parameter is an OUT - * parameter from a stored procedure, you must explicitly set the - * length. - *

- * @param mixed $driver_options [optional]

- *

- * @return bool TRUE on success or FALSE on failure. + * + * @param mixed $parameter Parameter identifier. + * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter. + * @param int $data_type Explicit data type for the parameter using the PDO::PARAM_* constants. + * @param int|null $length Length of the data type. + * @param mixed $driver_options + * + * @return bool TRUE on success or FALSE on failure. */ public function bindParam($parameter, &$variable, $data_type = PDO::PARAM_STR, $length = null, $driver_options = null); /** * Bind a column to a PHP variable - * @param mixed $column

- * Number of the column (1-indexed) or name of the column in the result set. - * If using the column name, be aware that the name should match the - * case of the column, as returned by the driver. - *

- * @param mixed $param

- * Name of the PHP variable to which the column will be bound. - *

- * @param int $type [optional]

- * Data type of the parameter, specified by the PDO::PARAM_* constants. - *

- * @param int $maxlen [optional]

- * A hint for pre-allocation. - *

- * @param mixed $driverdata [optional]

- * Optional parameter(s) for the driver. - *

- * @return bool TRUE on success or FALSE on failure. + * + * @param mixed $column Number of the column (1-indexed) or name of the column in the result set. + * @param mixed $param Name of the PHP variable to which the column will be bound. + * @param int|null $type Data type of the parameter, specified by the PDO::PARAM_* constants. + * @param int|null $maxlen A hint for pre-allocation. + * @param mixed|null $driverdata Optional parameter(s) for the driver. + * + * @return bool TRUE on success or FALSE on failure. */ public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null); /** * Binds a value to a parameter - * @param mixed $parameter

- * Parameter identifier. For a prepared statement using named - * placeholders, this will be a parameter name of the form - * :name. For a prepared statement using - * question mark placeholders, this will be the 1-indexed position of - * the parameter. - *

- * @param mixed $value

- * The value to bind to the parameter. - *

- * @param int $data_type [optional]

- * Explicit data type for the parameter using the PDO::PARAM_* - * constants. - *

- * @return bool TRUE on success or FALSE on failure. + * + * @param mixed $parameter Parameter identifier. + * @param mixed $value The value to bind to the parameter. + * @param int $data_type Explicit data type for the parameter using the PDO::PARAM_* constants. + * + * @return bool TRUE on success or FALSE on failure. */ public function bindValue($parameter, $value, $data_type = PDO::PARAM_STR); /** * Returns the number of rows affected by the last SQL statement + * * @return int the number of rows. */ public function rowCount(); /** * Returns a single column from the next row of a result set - * @param int $column_number [optional]

- * 0-indexed number of the column you wish to retrieve from the row. If - * no value is supplied, PDOStatement::fetchColumn - * fetches the first column. - *

- * @return mixed Returns a single column from the next row of a result - * set or FALSE if there are no more rows. - *

- *

- * There is no way to return another column from the same row if you - * use PDOStatement::fetchColumn to retrieve data. + * + * @param int $column_number 0-indexed number of the column you wish to retrieve from the row. + * + * @return mixed Returns a single column from the next row of a result set or FALSE if there are no more rows. */ public function fetchColumn($column_number = 0); /** * Returns an array containing all of the result set rows - * @param int $fetch_style [optional]

- * Controls the contents of the returned array as documented in - * PDOStatement::fetch. - * Defaults to value of PDO::ATTR_DEFAULT_FETCH_MODE - * (which defaults to PDO::FETCH_BOTH) - *

- *

- * To return an array consisting of all values of a single column from - * the result set, specify PDO::FETCH_COLUMN. You - * can specify which column you want with the - * column-index parameter. - *

- *

- * To fetch only the unique values of a single column from the result set, - * bitwise-OR PDO::FETCH_COLUMN with - * PDO::FETCH_UNIQUE. - *

- *

- * To return an associative array grouped by the values of a specified - * column, bitwise-OR PDO::FETCH_COLUMN with - * PDO::FETCH_GROUP. - *

- * @param mixed $fetch_argument [optional]

- * This argument have a different meaning depending on the value of - * the fetch_style parameter: - *

- * PDO::FETCH_COLUMN: Returns the indicated 0-indexed - * column. - *

- * @param array $ctor_args [optional]

- * Arguments of custom class constructor when the fetch_style - * parameter is PDO::FETCH_CLASS. - *

- * @return array PDOStatement::fetchAll returns an array containing - * all of the remaining rows in the result set. The array represents each - * row as either an array of column values or an object with properties - * corresponding to each column name. - *

- *

- * Using this method to fetch large result sets will result in a heavy - * demand on system and possibly network resources. Rather than retrieving - * all of the data and manipulating it in PHP, consider using the database - * server to manipulate the result sets. For example, use the WHERE and - * ORDER BY clauses in SQL to restrict results before retrieving and - * processing them with PHP. + * + * @param int|null $fetch_style Controls the contents of the returned array as documented in PDOStatement::fetch. + * @param mixed $fetch_argument This argument have a different meaning depending on the value of the fetch_style + * @param array $ctor_args Arguments of custom class constructor when the fetch_style parameter is PDO::FETCH_CLASS. + * + * @return array returns an array containing all of the remaining rows in the result set. */ - public function fetchAll($fetch_style = null, $fetch_argument = null, array $ctor_args = array()); + public function fetchAll($fetch_style = null, $fetch_argument = null, array $ctor_args = []); /** * Fetches the next row and returns it as an object. - * @param string $class_name [optional]

- * Name of the created class. - *

- * @param array $ctor_args [optional]

- * Elements of this array are passed to the constructor. - *

- * @return mixed an instance of the required class with property names that - * correspond to the column names or FALSE on failure. + * + * @param string $class_name Name of the created class. + * @param array $ctor_args Elements of this array are passed to the constructor. + * + * @return mixed */ - public function fetchObject($class_name = "stdClass", array $ctor_args = array()); + public function fetchObject($class_name = 'stdClass', array $ctor_args = []); /** * Fetch the SQLSTATE associated with the last operation on the statement handle - * @return string Identical to PDO::errorCode, except that - * PDOStatement::errorCode only retrieves error codes - * for operations performed with PDOStatement objects. + * + * @return string */ public function errorCode(); /** * Fetch extended error information associated with the last operation on the statement handle - * @return array PDOStatement::errorInfo returns an array of - * error information about the last operation performed by this - * statement handle. The array consists of the following fields: - *
- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * + * + * @return array returns an array of error information about the last operation performed by this statement handle. */ public function errorInfo(); /** * Set a statement attribute + * * @param int $attribute * @param mixed $value - * @return bool TRUE on success or FALSE on failure. + * + * @return bool TRUE on success or FALSE on failure. */ public function setAttribute($attribute, $value); /** * Retrieve a statement attribute + * * @param int $attribute + * * @return mixed the attribute value. */ public function getAttribute($attribute); /** * Returns the number of columns in the result set - * @return int the number of columns in the result set represented by the - * StatementInterface object. If there is no result set, - * StatementInterface::columnCount returns 0. + * + * @return int the number of columns in the result set represented by the StatementInterface object. */ public function columnCount(); /** * Returns metadata for a column in a result set - * @param int $column

- * The 0-indexed column in the result set. - *

- * @return array|false an associative array containing the following values representing - * the metadata for a single column: - *

- *
ElementInformation
0SQLSTATE error code (a five characters alphanumeric identifier defined - * in the ANSI SQL standard).
1Driver specific error code.
2Driver specific error message.
- * Column metadata - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
NameValue
native_typeThe PHP native type used to represent the column value.
driver:decl_typeThe SQL type used to represent the column value in the database. - * If the column in the result set is the result of a function, this value - * is not returned by PDOStatement::getColumnMeta. - *
flagsAny flags set for this column.
nameThe name of this column as returned by the database.
tableThe name of this column's table as returned by the database.
lenThe length of this column. Normally -1 for - * types other than floating point decimals.
precisionThe numeric precision of this column. Normally - * 0 for types other than floating point - * decimals.
pdo_typeThe type of this column as represented by the - * PDO::PARAM_* constants.
- *

- * Returns FALSE if the requested column does not exist in the result set, - * or if no result set exists. + * + * @param int $column The 0-indexed column in the result set. + * + * @return array|false */ public function getColumnMeta($column); /** * Set the default fetch mode for this statement - * @param int $mode

- * The fetch mode must be one of the PDO::FETCH_* constants. - *

- * @param string|object $classNameObject [optional]

- * Class name or object - *

- * @param array $ctorarfg [optional]

Constructor arguments.

- * @return bool TRUE on success or FALSE on failure. + * + * @param int $mode The fetch mode must be one of the PDO::FETCH_* constants. + * @param string|object|null $classNameObject Class name or object + * @param array $ctorarfg Constructor arguments. + * + * @return bool TRUE on success or FALSE on failure. */ - public function setFetchMode($mode, $classNameObject = null, array $ctorarfg = array()); + public function setFetchMode($mode, $classNameObject = null, array $ctorarfg = []); /** * Advances to the next rowset in a multi-rowset statement handle - * @return bool TRUE on success or FALSE on failure. + * + * @return bool TRUE on success or FALSE on failure. */ public function nextRowset(); /** * Closes the cursor, enabling the statement to be executed again. - * @return bool TRUE on success or FALSE on failure. + * + * @return bool TRUE on success or FALSE on failure. */ public function closeCursor(); /** * Dump an SQL prepared command + * * @return void No value is returned. */ public function debugDumpParams(); diff --git a/src/Propel/Runtime/Connection/StatementWrapper.php b/src/Propel/Runtime/Connection/StatementWrapper.php index 03469f058c..eb61f5bbdc 100644 --- a/src/Propel/Runtime/Connection/StatementWrapper.php +++ b/src/Propel/Runtime/Connection/StatementWrapper.php @@ -11,6 +11,7 @@ use IteratorAggregate; use PDO; use PDOStatement; +use Traversable; /** * Wraps a Statement class, providing logging. @@ -304,7 +305,7 @@ public function rowCount() * * @return \Traversable */ - public function getIterator(): \Traversable + public function getIterator(): Traversable { return $this->statement; } @@ -344,7 +345,7 @@ public function getBoundValues() } /** - * {@inheritDoc} + * @inheritDoc */ public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null) { @@ -352,15 +353,15 @@ public function bindColumn($column, &$param, $type = null, $maxlen = null, $driv } /** - * {@inheritDoc} + * @inheritDoc */ - public function fetchObject($class_name = "stdClass", array $ctor_args = array()) + public function fetchObject($class_name = 'stdClass', array $ctor_args = []) { return $this->statement->fetchObject($class_name, $ctor_args); } /** - * {@inheritDoc} + * @inheritDoc */ public function errorCode() { @@ -368,7 +369,7 @@ public function errorCode() } /** - * {@inheritDoc} + * @inheritDoc */ public function errorInfo() { @@ -376,7 +377,7 @@ public function errorInfo() } /** - * {@inheritDoc} + * @inheritDoc */ public function setAttribute($attribute, $value) { @@ -384,7 +385,7 @@ public function setAttribute($attribute, $value) } /** - * {@inheritDoc} + * @inheritDoc */ public function getAttribute($attribute) { @@ -392,7 +393,7 @@ public function getAttribute($attribute) } /** - * {@inheritDoc} + * @inheritDoc */ public function getColumnMeta($column) { @@ -400,15 +401,15 @@ public function getColumnMeta($column) } /** - * {@inheritDoc} + * @inheritDoc */ - public function setFetchMode($mode, $classNameObject = null, array $ctorarfg = array()) + public function setFetchMode($mode, $classNameObject = null, array $ctorarfg = []) { return $this->statement->setFetchMode($mode, $classNameObject, $ctorarfg); } /** - * {@inheritDoc} + * @inheritDoc */ public function nextRowset() { @@ -416,7 +417,7 @@ public function nextRowset() } /** - * {@inheritDoc} + * @inheritDoc */ public function debugDumpParams(): void { diff --git a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php index 373f7cbb4f..9db6695917 100644 --- a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php +++ b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php @@ -437,7 +437,6 @@ classname: Propel\Runtime\Connection\ConnectionWrapper } /** - * * @return void */ public function testNotDefineDatabaseSectionTrowsException() @@ -457,7 +456,6 @@ public function testNotDefineDatabaseSectionTrowsException() } /** - * * @return void */ public function testDotInConnectionNamesArentAccepted() @@ -648,7 +646,6 @@ classname: Propel\Runtime\Connection\DebugPDO } /** - * * @return void */ public function testGetConfigPropertyBadNameThrowsException() diff --git a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php index e457afd19f..2e39afdf16 100644 --- a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php @@ -8,6 +8,8 @@ namespace Propel\Tests\Common\Config\Loader; +use Propel\Common\Config\Exception\InvalidArgumentException; +use Propel\Common\Config\Exception\RuntimeException; use Propel\Common\Config\Loader\FileLoader as BaseFileLoader; use Propel\Tests\TestCase; @@ -186,7 +188,7 @@ public function testResolveReplaceWithoutCasting() */ public function testResolveThrowsExceptionIfInvalidPlaceholder() { - $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Parameter 'baz' not found in configuration file."); $this->loader->resolveParams(['foo' => 'bar', '%baz%']); @@ -197,7 +199,7 @@ public function testResolveThrowsExceptionIfInvalidPlaceholder() */ public function testResolveThrowsExceptionIfNonExistentParameter() { - $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Parameter 'foobar' not found in configuration file."); $this->loader->resolveParams(['foo %foobar% bar']); @@ -208,7 +210,7 @@ public function testResolveThrowsExceptionIfNonExistentParameter() */ public function testResolveThrowsRuntimeExceptionIfCircularReference() { - $this->expectException(\Propel\Common\Config\Exception\RuntimeException::class); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage("Circular reference detected for parameter 'bar'."); $this->loader->resolveParams(['foo' => '%bar%', 'bar' => '%foobar%', 'foobar' => '%foo%']); @@ -219,7 +221,7 @@ public function testResolveThrowsRuntimeExceptionIfCircularReference() */ public function testResolveThrowsRuntimeExceptionIfCircularReferenceMixed() { - $this->expectException(\Propel\Common\Config\Exception\RuntimeException::class); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage("Circular reference detected for parameter 'bar'."); $this->loader->resolveParams(['foo' => 'a %bar%', 'bar' => 'a %foobar%', 'foobar' => 'a %foo%']); @@ -312,7 +314,7 @@ public function testExtensionIsNotStringOrArrayReturnsFalse() */ public function testNonExistentEnvironmentVariableThrowsException() { - $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Environment variable 'foo' is not defined."); putenv('home=myHome'); @@ -330,8 +332,8 @@ public function testNonExistentEnvironmentVariableThrowsException() */ public function testParameterIsNotStringOrNumber() { - $this->expectException(\Propel\Common\Config\Exception\RuntimeException::class); - $this->expectExceptionMessage("A string value must be composed of strings and/or numbers,"); + $this->expectException(RuntimeException::class); + $this->expectExceptionMessage('A string value must be composed of strings and/or numbers,'); $config = [ 'foo' => 'a %bar%', diff --git a/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php index 1b092ded53..c1d05d180a 100644 --- a/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php @@ -8,6 +8,10 @@ namespace Propel\Tests\Common\Config\Loader; +use InvalidArgumentException; +use Propel\Common\Config\Exception\IniParseException; +use Propel\Common\Config\Exception\InputOutputException; +use Propel\Common\Config\Exception\InvalidArgumentException as PropelInvalidArgumentException; use Propel\Common\Config\FileLocator; use Propel\Common\Config\Loader\IniFileLoader; use Propel\Tests\Common\Config\ConfigTestCase; @@ -59,7 +63,7 @@ public function testIniFileCanBeLoaded() */ public function testIniFileDoesNotExist() { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The file "inexistent.ini" does not exist (in:'); $this->loader->load('inexistent.ini'); @@ -70,7 +74,7 @@ public function testIniFileDoesNotExist() */ public function testIniFileHasInvalidContent() { - $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectException(PropelInvalidArgumentException::class); $this->expectExceptionMessage("The configuration file 'nonvalid.ini' has invalid content."); $content = <<expectException(\Propel\Common\Config\Exception\IniParseException::class); + $this->expectException(IniParseException::class); $this->expectExceptionMessage('Invalid key ".foo"'); $content = <<expectException(\Propel\Common\Config\Exception\IniParseException::class); + $this->expectException(IniParseException::class); $this->expectExceptionMessage('Invalid key "foo."'); $content = <<expectException(\Propel\Common\Config\Exception\IniParseException::class); + $this->expectException(IniParseException::class); $this->expectExceptionMessage('Cannot create sub-key for "foo", as key already exists'); $content = <<expectException(\Propel\Common\Config\Exception\InputOutputException::class); + $this->expectException(InputOutputException::class); $this->expectExceptionMessage("You don't have permissions to access configuration file notreadable.ini."); $content = <<expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The file "inexistent.json" does not exist (in:'); $this->loader->load('inexistent.json'); @@ -69,7 +72,7 @@ public function testJsonFileDoesNotExist() */ public function testJsonFileHasInvalidContent() { - $this->expectException(\Propel\Common\Config\Exception\JsonParseException::class); + $this->expectException(JsonParseException::class); $content = <<expectException(\Propel\Common\Config\Exception\InputOutputException::class); + $this->expectException(InputOutputException::class); $this->expectExceptionMessage("You don't have permissions to access configuration file notreadable.json."); $content = <<expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The file "inexistent.php" does not exist (in:'); $this->loader->load('inexistent.php'); @@ -70,7 +73,7 @@ public function testPhpFileDoesNotExist() */ public function testPhpFileHasInvalidContent() { - $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectException(PropelInvalidArgumentException::class); $this->expectExceptionMessage("The configuration file 'nonvalid.php' has invalid content."); $content = <<expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); + $this->expectException(PropelInvalidArgumentException::class); $this->expectExceptionMessage("The configuration file 'empty.php' has invalid content."); $content = ''; @@ -103,7 +106,7 @@ public function testPhpFileIsEmpty() */ public function testConfigFileNotReadableThrowsException() { - $this->expectException(\Propel\Common\Config\Exception\InputOutputException::class); + $this->expectException(InputOutputException::class); $this->expectExceptionMessage("You don't have permissions to access configuration file notreadable.php."); $content = <<expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The file "inexistent.xml" does not exist (in:'); $this->loader->load('inexistent.xml'); @@ -71,8 +74,8 @@ public function testXmlFileDoesNotExist() */ public function testXmlFileHasInvalidContent() { - $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); - $this->expectExceptionMessage("Invalid xml content"); + $this->expectException(PropelInvalidArgumentException::class); + $this->expectExceptionMessage('Invalid xml content'); $content = <<expectException(\Propel\Common\Config\Exception\InputOutputException::class); + $this->expectException(InputOutputException::class); $this->expectExceptionMessage("You don't have permissions to access configuration file notreadable.xml."); $content = <<< XML diff --git a/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php index 88e4dcb503..22b31b6cf8 100644 --- a/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php @@ -8,9 +8,12 @@ namespace Propel\Tests\Common\Config\Loader; +use InvalidArgumentException; +use Propel\Common\Config\Exception\InputOutputException; use Propel\Common\Config\FileLocator; use Propel\Common\Config\Loader\YamlFileLoader; use Propel\Tests\Common\Config\ConfigTestCase; +use Symfony\Component\Yaml\Exception\ParseException; class YamlFileLoaderTest extends ConfigTestCase { @@ -59,7 +62,7 @@ public function testYamlFileCanBeLoaded() */ public function testYamlFileDoesNotExist() { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The file "inexistent.yaml" does not exist (in:'); $this->loader->load('inexistent.yaml'); @@ -70,7 +73,7 @@ public function testYamlFileDoesNotExist() */ public function testYamlFileHasInvalidContent() { - $this->expectException(\Symfony\Component\Yaml\Exception\ParseException::class); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Unable to parse'); $content = <<expectException(\Propel\Common\Config\Exception\InputOutputException::class); + $this->expectException(InputOutputException::class); $this->expectExceptionMessage("You don't have permissions to access configuration file notreadable.yaml."); $content = <<expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); - $this->expectExceptionMessage("XmlToArrayConverter::convert method expects an xml file to parse, or a string containing valid xml"); + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('XmlToArrayConverter::convert method expects an xml file to parse, or a string containing valid xml'); XmlToArrayConverter::convert(1); } @@ -68,8 +70,8 @@ public function testInvalidFileNameThrowsException() */ public function testInexistentFileThrowsException() { - $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); - $this->expectExceptionMessage("Invalid xml content"); + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid xml content'); XmlToArrayConverter::convert('nonexistent.xml'); } @@ -79,8 +81,8 @@ public function testInexistentFileThrowsException() */ public function testInvalidXmlThrowsException() { - $this->expectException(\Propel\Common\Config\Exception\InvalidArgumentException::class); - $this->expectExceptionMessage("Invalid xml content"); + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid xml content'); $invalidXml = <<< XML No xml @@ -95,8 +97,8 @@ public function testInvalidXmlThrowsException() */ public function testErrorInXmlThrowsException() { - $this->expectException(\Propel\Common\Config\Exception\XmlParseException::class); - $this->expectExceptionMessage("An error occurred while parsing XML configuration file:"); + $this->expectException(XmlParseException::class); + $this->expectExceptionMessage('An error occurred while parsing XML configuration file:'); $xmlWithError = <<< XML @@ -117,8 +119,8 @@ public function testErrorInXmlThrowsException() */ public function testMultipleErrorsInXmlThrowsException() { - $this->expectException(\Propel\Common\Config\Exception\XmlParseException::class); - $this->expectExceptionMessage("Some errors occurred while parsing XML configuration file:"); + $this->expectException(XmlParseException::class); + $this->expectExceptionMessage('Some errors occurred while parsing XML configuration file:'); $xmlWithErrors = <<< XML diff --git a/tests/Propel/Tests/Common/Util/SetColumnConverterTest.php b/tests/Propel/Tests/Common/Util/SetColumnConverterTest.php index d226d09018..c9a2d42832 100644 --- a/tests/Propel/Tests/Common/Util/SetColumnConverterTest.php +++ b/tests/Propel/Tests/Common/Util/SetColumnConverterTest.php @@ -9,6 +9,7 @@ namespace Propel\Tests\Common\Util; use PHPUnit\Framework\TestCase; +use Propel\Common\Exception\SetColumnConverterException; use Propel\Common\Util\SetColumnConverter; /** @@ -58,7 +59,7 @@ public function testConvertToIntNullValue() */ public function testConvertToIntValueNotInSet() { - $this->expectException(\Propel\Common\Exception\SetColumnConverterException::class); + $this->expectException(SetColumnConverterException::class); $valueSet = ['a', 'b', 'c', 'd', 'e', 'f']; SetColumnConverter::convertToInt(['g'], $valueSet); @@ -94,7 +95,7 @@ public function testConvertIntToArrayNullValue() */ public function testConvertIntToArrayIntOutOfRange() { - $this->expectException(\Propel\Common\Exception\SetColumnConverterException::class); + $this->expectException(SetColumnConverterException::class); $valueSet = ['a', 'b', 'c', 'd', 'e', 'f']; SetColumnConverter::convertIntToArray('65', $valueSet); diff --git a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php index cc81b9748c..bb5ced2aa4 100644 --- a/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifierTest.php @@ -25,6 +25,7 @@ use ArchivableTest40; use MyOldArchivableTest30Query; use Propel\Generator\Util\QuickBuilder; +use Propel\Runtime\Exception\PropelException; use Propel\Tests\TestCase; /** @@ -224,7 +225,7 @@ public function testArchiveReturnsArchivedObject() */ public function testArchiveThrowsExceptionOnNewObjects() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); $a = new ArchivableTest10(); $a->archive(); @@ -243,7 +244,7 @@ public function testHasRestoreFromArchiveMethod() */ public function testRestoreFromArchiveThrowsExceptionOnUnarchivedObjects() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); $a = new ArchivableTest10(); $a->setTitle('foo'); diff --git a/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php b/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php index 4223b0449f..15bc79fd83 100644 --- a/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Delegate/DelegateBehaviorTest.php @@ -14,6 +14,7 @@ use DelegateMain; use Map\DelegateDelegateTableMap; use Propel\Generator\Util\QuickBuilder; +use Propel\Runtime\Exception\BadMethodCallException; use Propel\Tests\TestCase; use SecondDelegateDelegate; use TestTablePrefixSameDatabaseMain; @@ -198,7 +199,7 @@ public function testAModelCanHaveSeveralDelegates() */ public function testAModelCannotHaveCascadingDelegates() { - $this->expectException(\Propel\Runtime\Exception\BadMethodCallException::class); + $this->expectException(BadMethodCallException::class); $main = new DelegateMain(); $main->setSummary('bar'); diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php index ea755cefbb..53fbc781f8 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierTest.php @@ -109,7 +109,7 @@ public function testSaveOutOfTree() */ public function testSaveRootInTreeWithExistingRoot() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); NestedSetTable9TableMap::doDeleteAll(); $t1 = new NestedSetTable9(); diff --git a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php index 1ded92a7a1..9129e6efb9 100644 --- a/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php +++ b/tests/Propel/Tests/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php @@ -11,6 +11,7 @@ use Map\NestedSetTable10TableMap; use NestedSetTable10; use NestedSetTable10Query; +use Propel\Runtime\Exception\PropelException; use Propel\Tests\Generator\Behavior\NestedSet\Fixtures\PublicTable10; /** @@ -30,7 +31,7 @@ protected function getByTitle($title) */ public function testSaveRootInTreeWithExistingRootWithSameScope() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); NestedSetTable10TableMap::doDeleteAll(); $t1 = new NestedSetTable10(); diff --git a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierTest.php index 667fab1cb4..7c45b6f040 100644 --- a/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifierTest.php @@ -8,10 +8,10 @@ namespace Propel\Tests\Generator\Behavior\Sortable; +use Propel\Runtime\Exception\PropelException; use Propel\Tests\Bookstore\Behavior\Map\SortableTable11TableMap; use Propel\Tests\Bookstore\Behavior\SortableTable11 as Table11; use Propel\Tests\Bookstore\Behavior\SortableTable11Query; -use Propel\Runtime\Exception\PropelException; /** * Tests for SortableBehavior class diff --git a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php index 4170c47e41..36d25d5f12 100644 --- a/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php +++ b/tests/Propel/Tests/Generator/Behavior/Versionable/VersionableBehaviorObjectBuilderModifierTest.php @@ -10,6 +10,7 @@ use Propel\Generator\Util\QuickBuilder; use Propel\Runtime\Collection\ObjectCollection; +use Propel\Runtime\Exception\PropelException; use VersionableBehaviorTest1; use VersionableBehaviorTest10; use VersionableBehaviorTest11; @@ -591,7 +592,7 @@ public function testToVersionAllowsFurtherSave() */ public function testToVersionThrowsExceptionOnIncorrectVersion() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); $o = new VersionableBehaviorTest1(); $o->setBar(123); // version 1 diff --git a/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderNamespaceTest.php b/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderNamespaceTest.php index a7a679dbb7..0a194c928c 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderNamespaceTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/AbstractOMBuilderNamespaceTest.php @@ -9,6 +9,7 @@ namespace Propel\Tests\Generator\Builder\Om; use Propel\Generator\Builder\Om\AbstractOMBuilder; +use Propel\Generator\Exception\LogicException; use Propel\Generator\Model\Database; use Propel\Generator\Model\ForeignKey; use Propel\Generator\Model\Table; @@ -128,7 +129,7 @@ public function testDeclareClassNamespace() */ public function testDeclareClassNamespaceDuplicateException() { - $this->expectException(\Propel\Generator\Exception\LogicException::class); + $this->expectException(LogicException::class); $builder = new TestableOMBuilder2(new Table('fooTable')); $builder->declareClassNamespace('Bar'); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php index 362d7e5bd2..cbf110c484 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectEnumColumnTypeTest.php @@ -12,6 +12,7 @@ use ComplexColumnTypeEntity3Query; use Map\ComplexColumnTypeEntity3TableMap; use Propel\Generator\Util\QuickBuilder; +use Propel\Runtime\Exception\PropelException; use Propel\Tests\TestCase; use PublicComplexColumnTypeEntity3; @@ -71,7 +72,7 @@ public function testGetter() */ public function testGetterThrowsExceptionOnUnknownKey() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); $e = new PublicComplexColumnTypeEntity3(); $e->bar = 156; @@ -109,8 +110,8 @@ public function testSetter() */ public function testSetterThrowsExceptionOnUnknownValue() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); - + $this->expectException(PropelException::class); + $e = new ComplexColumnTypeEntity3(); $e->setBar('bazz'); } diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php index 3f2b0f7ff0..b120b57a80 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectSetColumnTypeTest.php @@ -13,6 +13,7 @@ use MyNameSpace\Map\ComplexColumnTypeEntitySetTableMap; use Propel\Generator\Util\QuickBuilder; use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\Exception\PropelException; use Propel\Tests\TestCase; use PublicComplexColumnTypeEntitySet; @@ -116,7 +117,7 @@ public function testGetterValidValue() */ public function testGetterThrowsExceptionOnUnknownKey() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); $e = new PublicComplexColumnTypeEntitySet(); $e->bar = 156; @@ -203,7 +204,7 @@ public function testSetterResetValue() */ public function testSetterThrowsExceptionOnUnknownValue() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); $e = new ComplexColumnTypeEntitySet(); $e->setBar(['bazz']); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php index e5a0fd8b4b..e65be786d1 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTemporalColumnTypeTest.php @@ -15,6 +15,7 @@ use Map\ComplexColumnTypeEntity5TableMap; use Propel\Generator\Platform\MysqlPlatform; use Propel\Generator\Util\QuickBuilder; +use Propel\Runtime\Exception\PropelException; use Propel\Tests\TestCase; /** @@ -89,7 +90,7 @@ public function testPreEpochValue() */ public function testInvalidValueThrowsPropelException() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); $r = new ComplexColumnTypeEntity5(); $r->setBar1('Invalid Date'); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php index 8e11b78606..b605f360ab 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php @@ -16,7 +16,7 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Adapter\Pdo\SqliteAdapter; use Propel\Runtime\Collection\ObjectCollection; -use \Propel\Runtime\Exception\BadMethodCallException; +use Propel\Runtime\Exception\BadMethodCallException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Propel; use Propel\Tests\Bookstore\AcctAuditLog; diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php index 34fcb52c26..830c24997e 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedPKLessQueryBuilderTest.php @@ -10,6 +10,7 @@ use Map\StuffTableMap; use Propel\Generator\Util\QuickBuilder; +use Propel\Runtime\Exception\LogicException; use Propel\Tests\TestCase; use Stuff; use StuffQuery; @@ -45,7 +46,7 @@ public function setUp(): void */ public function testFindPkThrowsAnError() { - $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $this->expectException(LogicException::class); $this->expectExceptionMessage('The Stuff object has no primary key'); StuffQuery::create()->findPk(42); @@ -56,7 +57,7 @@ public function testFindPkThrowsAnError() */ public function testBuildPkeyCriteria() { - $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $this->expectException(LogicException::class); $this->expectExceptionMessage('The Stuff object has no primary key'); $stuff = new Stuff(); @@ -68,7 +69,7 @@ public function testBuildPkeyCriteria() */ public function testTableMapDoDelete() { - $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $this->expectException(LogicException::class); $this->expectExceptionMessage('The Stuff object has no primary key'); StuffTableMap::doDelete([]); @@ -79,7 +80,7 @@ public function testTableMapDoDelete() */ public function testFindPksThrowsAnError() { - $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $this->expectException(LogicException::class); $this->expectExceptionMessage('The Stuff object has no primary key'); StuffQuery::create()->findPks([42, 24]); @@ -90,7 +91,7 @@ public function testFindPksThrowsAnError() */ public function testFilterByPrimaryKeyThrowsAnError() { - $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $this->expectException(LogicException::class); $this->expectExceptionMessage('The Stuff object has no primary key'); StuffQuery::create()->filterByPrimaryKey(42); @@ -101,7 +102,7 @@ public function testFilterByPrimaryKeyThrowsAnError() */ public function testFilterByPrimaryKeysThrowsAnError() { - $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $this->expectException(LogicException::class); $this->expectExceptionMessage('The Stuff object has no primary key'); StuffQuery::create()->filterByPrimaryKeys(42); diff --git a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php index 3648948abb..2dbc3a3209 100644 --- a/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php +++ b/tests/Propel/Tests/Generator/Builder/Om/GeneratedQuerySetColumnTypeTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Propel\Generator\Util\QuickBuilder; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Exception\PropelException; /** * Tests the generated queries for array column types filters @@ -114,7 +115,7 @@ public function testWhere() */ public function testWhereInvalidValueThrowsException() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); ComplexColumnTypeEntitySet2Query::create() ->where('ComplexColumnTypeEntitySet2.Tags LIKE ?', 'bar231') diff --git a/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php b/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php index 0fceb95bcf..7bc381c8ba 100644 --- a/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php +++ b/tests/Propel/Tests/Generator/Builder/Util/SchemaReaderTest.php @@ -9,6 +9,7 @@ namespace Propel\Tests\Generator\Builder\Util; use Propel\Generator\Builder\Util\SchemaReader; +use Propel\Generator\Exception\SchemaException; use Propel\Tests\TestCase; class SchemaReaderTest extends TestCase @@ -62,7 +63,7 @@ public function testParseStringSchemaWithoutXmlDeclaration() */ public function testParseStringIncorrectSchema() { - $this->expectException(\Propel\Generator\Exception\SchemaException::class); + $this->expectException(SchemaException::class); $this->reader->parseString(''); } diff --git a/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php b/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php index 6f514c05e2..567b2be9bb 100644 --- a/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php +++ b/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php @@ -9,6 +9,9 @@ namespace Propel\Tests\Generator\Config; use Propel\Generator\Config\GeneratorConfig; +use Propel\Generator\Exception\BuildException; +use Propel\Generator\Exception\ClassNotFoundException; +use Propel\Generator\Exception\InvalidArgumentException; use Propel\Tests\Common\Config\ConfigTestCase; use ReflectionClass; @@ -118,7 +121,7 @@ public function testGetConfiguredPlatform() */ public function testGetConfiguredPlatformGivenBadDatabaseNameThrowsException() { - $this->expectException(\Propel\Generator\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid database name: no configured connection named `badsource`.'); $this->generatorConfig->getConfiguredPlatform(null, 'badsource'); @@ -173,7 +176,7 @@ public function testGetConfiguredSchemaParserGivenClass() */ public function testGetConfiguredSchemaParserGivenNonSchemaParserClass() { - $this->expectException(\Propel\Generator\Exception\BuildException::class); + $this->expectException(BuildException::class); $this->expectExceptionMessage('Specified class (\Propel\Generator\Platform\MysqlPlatform) does not implement \Propel\Generator\Reverse\SchemaParserInterface interface.'); $this->setConfig( @@ -194,7 +197,7 @@ public function testGetConfiguredSchemaParserGivenNonSchemaParserClass() */ public function testGetConfiguredSchemaParserGivenBadClass() { - $this->expectException(\Propel\Generator\Exception\ClassNotFoundException::class); + $this->expectException(ClassNotFoundException::class); $this->expectExceptionMessage('Reverse SchemaParser class for `\Propel\Generator\Reverse\BadSchemaParser` not found.'); $this->setConfig( @@ -226,7 +229,7 @@ public function testGetConfiguredBuilder() */ public function testGetConfiguredBuilderWrongTypeThrowsException() { - $this->expectException(\Propel\Generator\Exception\ClassNotFoundException::class); + $this->expectException(ClassNotFoundException::class); $stubTable = $this->getMockBuilder('\\Propel\\Generator\\Model\\Table')->getMock(); $actual = $this->generatorConfig->getConfiguredBuilder($stubTable, 'bad_type'); @@ -252,7 +255,7 @@ public function testGetConfiguredPluralizer() */ public function testGetConfiguredPluralizerNonExistentClassThrowsException() { - $this->expectException(\Propel\Generator\Exception\ClassNotFoundException::class); + $this->expectException(ClassNotFoundException::class); $this->expectExceptionMessage('Class \Propel\Common\Pluralizer\WrongEnglishPluralizer not found.'); $config['generator']['objectModel']['pluralizerClass'] = '\\Propel\\Common\\Pluralizer\\WrongEnglishPluralizer'; @@ -266,7 +269,7 @@ public function testGetConfiguredPluralizerNonExistentClassThrowsException() */ public function testGetConfiguredPluralizerWrongClassThrowsException() { - $this->expectException(\Propel\Generator\Exception\BuildException::class); + $this->expectException(BuildException::class); $this->expectExceptionMessage('Specified class (\Propel\Common\Config\PropelConfiguration) does not implement'); $config['generator']['objectModel']['pluralizerClass'] = '\\Propel\\Common\\Config\\PropelConfiguration'; @@ -359,7 +362,7 @@ public function testGetBuildConnectionGivenDatabase() */ public function testGetBuildConnectionGivenWrongDatabaseThrowsException() { - $this->expectException(\Propel\Generator\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid database name: no configured connection named `wrongsource`.'); $actual = $this->generatorConfig->getBuildConnection('wrongsource'); @@ -390,7 +393,7 @@ public function testGetConnection() */ public function testGetConnectionWrongDatabaseThrowsException() { - $this->expectException(\Propel\Generator\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid database name: no configured connection named `badsource`.'); $actual = $this->generatorConfig->getConnection('badsource'); diff --git a/tests/Propel/Tests/Generator/Config/QuickGeneratorConfigTest.php b/tests/Propel/Tests/Generator/Config/QuickGeneratorConfigTest.php index bc905d04e4..5d31e5bd77 100644 --- a/tests/Propel/Tests/Generator/Config/QuickGeneratorConfigTest.php +++ b/tests/Propel/Tests/Generator/Config/QuickGeneratorConfigTest.php @@ -9,6 +9,7 @@ namespace Propel\Tests\Generator\Config; use Propel\Generator\Config\QuickGeneratorConfig; +use Propel\Generator\Exception\InvalidArgumentException; use Propel\Tests\TestCase; class QuickGeneratorConfigTest extends TestCase @@ -39,7 +40,7 @@ public function testGetConfiguredBuilder() */ public function testGetConfiguredBuilderWrongTypeThrowsException() { - $this->expectException(\Propel\Generator\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid data model builder type `bad_type`'); $stubTable = $this->getMockBuilder('\\Propel\\Generator\\Model\\Table')->getMock(); diff --git a/tests/Propel/Tests/Generator/Model/BehaviorTest.php b/tests/Propel/Tests/Generator/Model/BehaviorTest.php index f1e4ba859e..6dbcd4637e 100644 --- a/tests/Propel/Tests/Generator/Model/BehaviorTest.php +++ b/tests/Propel/Tests/Generator/Model/BehaviorTest.php @@ -9,6 +9,8 @@ namespace Propel\Tests\Generator\Model; use Propel\Generator\Builder\Util\SchemaReader; +use Propel\Generator\Exception\BehaviorNotFoundException; +use Propel\Generator\Exception\LogicException; use Propel\Generator\Model\Behavior; use Propel\Generator\Model\Table; use Propel\Tests\Helpers\MultipleBehavior; @@ -60,7 +62,7 @@ public function testSetupObjectWithMultipleBehaviorWithId() */ public function testSetupObjectFailIfIdGivenOnNotMultipleBehavior() { - $this->expectException(\Propel\Generator\Exception\LogicException::class); + $this->expectException(LogicException::class); $b = new Behavior(); $b->loadMapping(['name' => 'foo', 'id' => 'lala']); @@ -148,7 +150,7 @@ public function testSchemaReader() */ public function testUnknownBehavior() { - $this->expectException(\Propel\Generator\Exception\BehaviorNotFoundException::class); + $this->expectException(BehaviorNotFoundException::class); $schemaReader = new SchemaReader(); $schema = <<expectException(\Propel\Generator\Exception\DiffException::class); + $this->expectException(DiffException::class); $diff = $this->createTableDiff(); $diff->addAddedPkColumn('id', new Column('id', 'integer')); diff --git a/tests/Propel/Tests/Generator/Model/TableTest.php b/tests/Propel/Tests/Generator/Model/TableTest.php index 8e3ebacba5..139b8c36cc 100644 --- a/tests/Propel/Tests/Generator/Model/TableTest.php +++ b/tests/Propel/Tests/Generator/Model/TableTest.php @@ -592,7 +592,7 @@ public function testAddIndex() */ public function testAddEmptyIndex() { - $this->expectException(\Propel\Generator\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $table = new Table(); $table->addIndex(new Index()); diff --git a/tests/Propel/Tests/Issues/Issue1659Test.php b/tests/Propel/Tests/Issues/Issue1659Test.php index 0dd4c1e383..6850c96c3a 100644 --- a/tests/Propel/Tests/Issues/Issue1659Test.php +++ b/tests/Propel/Tests/Issues/Issue1659Test.php @@ -20,7 +20,6 @@ */ class Issue1659Test extends TestCaseFixtures { - /** * Test non-primary foreign key references * foreign table have composite primary key diff --git a/tests/Propel/Tests/Issues/Issue675Test.php b/tests/Propel/Tests/Issues/Issue675Test.php index 97ac2b12f1..514a7ab11d 100644 --- a/tests/Propel/Tests/Issues/Issue675Test.php +++ b/tests/Propel/Tests/Issues/Issue675Test.php @@ -8,6 +8,7 @@ namespace Propel\Tests\Issues; +use Propel\Generator\Exception\BuildException; use Propel\Generator\Util\QuickBuilder; use Propel\Tests\TestCaseFixtures; @@ -27,7 +28,7 @@ class Issue675Test extends TestCaseFixtures */ public function testIncompleteForeignReference() { - $this->expectException(\Propel\Generator\Exception\BuildException::class); + $this->expectException(BuildException::class); $schema = << diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaMergeTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaMergeTest.php index 5f4fbf38a7..fe89968de5 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaMergeTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaMergeTest.php @@ -9,6 +9,7 @@ namespace Propel\Tests\Runtime\ActiveQuery; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Exception\LogicException; use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Bookstore\Map\PublisherTableMap; @@ -168,7 +169,7 @@ public function testMergeWithAsColumns() */ public function testMergeWithAsColumnsThrowsException() { - $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $this->expectException(LogicException::class); $c1 = new Criteria(); $c1->addAsColumn('foo', BookTableMap::COL_TITLE); @@ -431,7 +432,7 @@ public function testMergeWithAliases() */ public function testMergeWithAliasesThrowsException() { - $this->expectException(\Propel\Runtime\Exception\LogicException::class); + $this->expectException(LogicException::class); $c1 = new Criteria(); $c1->addAlias('b', BookTableMap::TABLE_NAME); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicCriterionTest.php index 817d7a3125..53bfae9bdc 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicCriterionTest.php @@ -10,6 +10,7 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criterion\BasicCriterion; +use Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException; use Propel\Runtime\Adapter\Pdo\SqliteAdapter; use Propel\Tests\Helpers\BaseTestCase; @@ -137,7 +138,7 @@ public function testAppendPsCanHandleNotEqualToNull() */ public function testAppendPsThrowsExceptionWhenValueIsNullAndComparisonIsComplex() { - $this->expectException(\Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException::class); + $this->expectException(InvalidValueException::class); $cton = new BasicCriterion(new Criteria(), 'A.COL', null, Criteria::GREATER_THAN); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicModelCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicModelCriterionTest.php index 6260b598f8..23c4b6c7e3 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicModelCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/BasicModelCriterionTest.php @@ -10,6 +10,7 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criterion\BasicModelCriterion; +use Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException; use Propel\Tests\Helpers\BaseTestCase; /** @@ -42,7 +43,7 @@ public function testAppendPsToAddsBindingInfoForNotNullValues() */ public function testAppendPsToThrowsExceptionWhenBindingAValueToAClauseWithNoQuestionMark() { - $this->expectException(\Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException::class); + $this->expectException(InvalidClauseException::class); $cton = new BasicModelCriterion(new Criteria(), 'A.COL = B.COL', 'A.COL', 'foo'); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeModelCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeModelCriterionTest.php index 08a6342393..149f01652d 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeModelCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/LikeModelCriterionTest.php @@ -9,6 +9,7 @@ namespace Propel\Tests\Runtime\ActiveQuery\Criterion; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException; use Propel\Runtime\ActiveQuery\Criterion\LikeModelCriterion; use Propel\Runtime\Adapter\Pdo\PgsqlAdapter; use Propel\Runtime\Adapter\Pdo\SqliteAdapter; @@ -62,7 +63,7 @@ public function testAppendPsToCreatesANotLikeConditionIfSpecified() */ public function testAppendPsToWithACaseInsensitiveLikeConditionThrowsAnException() { - $this->expectException(\Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException::class); + $this->expectException(InvalidClauseException::class); $cton = new LikeModelCriterion(new Criteria(), 'A.COL LIKE ?', 'A.COL', 'foo%'); $cton->setAdapter(new SqliteAdapter()); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawCriterionTest.php index 310d063a0e..faf9f8154e 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawCriterionTest.php @@ -10,6 +10,7 @@ use PDO; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException; use Propel\Runtime\ActiveQuery\Criterion\RawCriterion; use Propel\Tests\Helpers\BaseTestCase; @@ -25,7 +26,7 @@ class RawCriterionTest extends BaseTestCase */ public function testAppendPsToThrowsExceptionWhenClauseHasNoQuestionMark() { - $this->expectException(\Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException::class); + $this->expectException(InvalidClauseException::class); $cton = new RawCriterion(new Criteria(), 'A.COL = BAR', 1, PDO::PARAM_INT); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawModelCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawModelCriterionTest.php index 0ca75cdeab..772746ceae 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawModelCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/RawModelCriterionTest.php @@ -10,6 +10,7 @@ use PDO; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException; use Propel\Runtime\ActiveQuery\Criterion\RawModelCriterion; use Propel\Tests\Helpers\BaseTestCase; @@ -25,7 +26,7 @@ class RawModelCriterionTest extends BaseTestCase */ public function testAppendPsToThrowsExceptionWhenClauseHasNoQuestionMark() { - $this->expectException(\Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidClauseException::class); + $this->expectException(InvalidClauseException::class); $cton = new RawModelCriterion(new Criteria(), 'A.COL = BAR', 'A.COL', 1, null, PDO::PARAM_INT); diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/SeveralModelCriterionTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/SeveralModelCriterionTest.php index 6949334632..6aa9a08c13 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/SeveralModelCriterionTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/Criterion/SeveralModelCriterionTest.php @@ -9,6 +9,7 @@ namespace Propel\Tests\Runtime\ActiveQuery\Criterion; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException; use Propel\Runtime\ActiveQuery\Criterion\SeveralModelCriterion; use Propel\Tests\Helpers\BaseTestCase; @@ -43,7 +44,7 @@ public function testAppendPsToAddsBindingInfoForNotNullValues() */ public function testAppendPsToThrowsExceptionWhenOneOfTheValuesIsNull() { - $this->expectException(\Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException::class); + $this->expectException(InvalidValueException::class); $cton = new SeveralModelCriterion(new Criteria(), 'A.COL BETWEEN ? AND ?', 'A.COL', ['foo', null]); @@ -57,7 +58,7 @@ public function testAppendPsToThrowsExceptionWhenOneOfTheValuesIsNull() */ public function testAppendPsToThrowsExceptionWhenTheValueIsNull() { - $this->expectException(\Propel\Runtime\ActiveQuery\Criterion\Exception\InvalidValueException::class); + $this->expectException(InvalidValueException::class); $cton = new SeveralModelCriterion(new Criteria(), 'A.COL BETWEEN ? AND ?', 'A.COL', null); diff --git a/tests/Propel/Tests/Runtime/ActiveRecordTest.php b/tests/Propel/Tests/Runtime/ActiveRecordTest.php index 4f0a6a0f8b..b30e2c9386 100644 --- a/tests/Propel/Tests/Runtime/ActiveRecordTest.php +++ b/tests/Propel/Tests/Runtime/ActiveRecordTest.php @@ -8,6 +8,7 @@ namespace Propel\Tests\Runtime\ActiveRecord; +use Propel\Runtime\Exception\PropelException; use Propel\Tests\TestCase; /** @@ -55,7 +56,7 @@ public function testHasVirtualColumn() */ public function testGetVirtualColumnWrongKey() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); $b = new TestableActiveRecord(); $b->getVirtualColumn('foo'); diff --git a/tests/Propel/Tests/Runtime/Collection/CollectionTest.php b/tests/Propel/Tests/Runtime/Collection/CollectionTest.php index 888a3b44dc..39dd373a94 100644 --- a/tests/Propel/Tests/Runtime/Collection/CollectionTest.php +++ b/tests/Propel/Tests/Runtime/Collection/CollectionTest.php @@ -14,6 +14,7 @@ use Propel\Tests\Bookstore\Book; use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\Helpers\Bookstore\BookstoreTestBase; +use UnexpectedValueException; /** * Test class for Collection. @@ -140,7 +141,7 @@ public function testGet() */ public function testGetUnknownOffset() { - $this->expectException(\UnexpectedValueException::class); + $this->expectException(UnexpectedValueException::class); $col = new Collection(); $bar = $col->get('foo'); @@ -217,7 +218,7 @@ public function testRemove() */ public function testRemoveUnknownOffset() { - $this->expectException(\UnexpectedValueException::class); + $this->expectException(UnexpectedValueException::class); $col = new Collection(); $col->remove(2); diff --git a/tests/Propel/Tests/Runtime/Collection/ObjectCollectionTest.php b/tests/Propel/Tests/Runtime/Collection/ObjectCollectionTest.php index 3e5c4eed9a..2363cd5a4d 100644 --- a/tests/Propel/Tests/Runtime/Collection/ObjectCollectionTest.php +++ b/tests/Propel/Tests/Runtime/Collection/ObjectCollectionTest.php @@ -11,8 +11,8 @@ use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Exception\BadMethodCallException; -use Propel\Runtime\Formatter\ObjectFormatter; use Propel\Runtime\Exception\RuntimeException; +use Propel\Runtime\Formatter\ObjectFormatter; use Propel\Runtime\Propel; use Propel\Tests\Bookstore\Author; use Propel\Tests\Bookstore\Book; diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionFactoryTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionFactoryTest.php index 23f556d9bb..55df75dec2 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionFactoryTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionFactoryTest.php @@ -12,6 +12,7 @@ use Propel\Runtime\Adapter\Pdo\SqliteAdapter; use Propel\Runtime\Connection\ConnectionFactory; use Propel\Runtime\Connection\ConnectionWrapper; +use Propel\Runtime\Exception\InvalidArgumentException; use Propel\Tests\Helpers\BaseTestCase; class ConnectionFactoryTest extends BaseTestCase @@ -21,7 +22,7 @@ class ConnectionFactoryTest extends BaseTestCase */ public function testCreateFailsIfGivenIncorrectConfiguration() { - $this->expectException(\Propel\Runtime\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $con = ConnectionFactory::create([], new SqliteAdapter()); } @@ -97,7 +98,7 @@ public function testCreateSetsAttributesAfterConnectionAndExpandsConstantNames() */ public function testCreateFailsWhenPassedAnIncorrectAttributeName() { - $this->expectException(\Propel\Runtime\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $con = ConnectionFactory::create(['dsn' => 'sqlite::memory:', 'attributes' => ['ATTR_CAE' => PDO::CASE_LOWER]], new SqliteAdapter()); } diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php index 5e5909c3fd..531cc14cbb 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerMasterSlaveTest.php @@ -11,6 +11,7 @@ use PDO; use Propel\Runtime\Adapter\Pdo\SqliteAdapter; use Propel\Runtime\Connection\ConnectionManagerMasterSlave; +use Propel\Runtime\Exception\InvalidArgumentException; use Propel\Tests\Helpers\BaseTestCase; /** @@ -42,7 +43,7 @@ public function testGetNameReturnsNameSetUsingSetName() */ public function testGetWriteConnectionFailsIfManagerIsNotConfigured() { - $this->expectException(\Propel\Runtime\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $manager = new ConnectionManagerMasterSlave(); $con = $manager->getWriteConnection(new SqliteAdapter()); diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php index b36e75febc..7c0878eec0 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerPrimaryReplicaTest.php @@ -11,6 +11,7 @@ use PDO; use Propel\Runtime\Adapter\Pdo\SqliteAdapter; use Propel\Runtime\Connection\ConnectionManagerPrimaryReplica; +use Propel\Runtime\Exception\InvalidArgumentException; use Propel\Tests\Helpers\BaseTestCase; class ConnectionManagerPrimaryReplicaTest extends BaseTestCase @@ -39,7 +40,7 @@ public function testGetNameReturnsNameSetUsingSetName() */ public function testGetWriteConnectionFailsIfManagerIsNotConfigured() { - $this->expectException(\Propel\Runtime\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $manager = new ConnectionManagerPrimaryReplica(); $manager->getWriteConnection(new SqliteAdapter()); diff --git a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerSingleTest.php b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerSingleTest.php index 01eb85d8d9..85e07f70ee 100644 --- a/tests/Propel/Tests/Runtime/Connection/ConnectionManagerSingleTest.php +++ b/tests/Propel/Tests/Runtime/Connection/ConnectionManagerSingleTest.php @@ -11,6 +11,7 @@ use Propel\Runtime\Adapter\Pdo\SqliteAdapter; use Propel\Runtime\Connection\ConnectionManagerSingle; use Propel\Runtime\Connection\PdoConnection; +use Propel\Runtime\Exception\InvalidArgumentException; use Propel\Tests\Helpers\BaseTestCase; class ConnectionManagerSingleTest extends BaseTestCase @@ -39,7 +40,7 @@ public function testGetNameReturnsNameSetUsingSetName() */ public function testGetWriteConnectionFailsIfManagerIsNotConfigured() { - $this->expectException(\Propel\Runtime\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $manager = new ConnectionManagerSingle(); $con = $manager->getWriteConnection(new SqliteAdapter()); diff --git a/tests/Propel/Tests/Runtime/Connection/TransactionTraitTest.php b/tests/Propel/Tests/Runtime/Connection/TransactionTraitTest.php index f3a0e05e79..ae2fc5aae8 100644 --- a/tests/Propel/Tests/Runtime/Connection/TransactionTraitTest.php +++ b/tests/Propel/Tests/Runtime/Connection/TransactionTraitTest.php @@ -44,8 +44,6 @@ public function testTransactionRollback() } /** - * @throws \Throwable - * * @return void */ public function testTransactionRollbackOnThrowable() @@ -139,8 +137,6 @@ public function testTransactionNestedException() } /** - * @throws \Exception - * * @return void */ public function testTransactionNestedThrowable() diff --git a/tests/Propel/Tests/Runtime/Exception/PropelExceptionTest.php b/tests/Propel/Tests/Runtime/Exception/PropelExceptionTest.php index b9809cffd3..9d40331adc 100644 --- a/tests/Propel/Tests/Runtime/Exception/PropelExceptionTest.php +++ b/tests/Propel/Tests/Runtime/Exception/PropelExceptionTest.php @@ -46,7 +46,7 @@ public function testCompositeConstructor() */ public function testIsThrowable() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); $e = new PropelException('this is an error'); diff --git a/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterTest.php b/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterTest.php index 2025df19a7..5f95d7850c 100644 --- a/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterTest.php +++ b/tests/Propel/Tests/Runtime/Formatter/OnDemandFormatterTest.php @@ -127,7 +127,7 @@ public function testFormatManyResults() */ public function testFormatManyResultsIteratedTwice() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); BookstoreDataPopulator::populate($con); diff --git a/tests/Propel/Tests/Runtime/Map/TableMapTest.php b/tests/Propel/Tests/Runtime/Map/TableMapTest.php index 36d1e3e78f..78f6839447 100644 --- a/tests/Propel/Tests/Runtime/Map/TableMapTest.php +++ b/tests/Propel/Tests/Runtime/Map/TableMapTest.php @@ -12,6 +12,7 @@ use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\DatabaseMap; use Propel\Runtime\Map\Exception\ColumnNotFoundException; +use Propel\Runtime\Map\Exception\RelationNotFoundException; use Propel\Runtime\Map\RelationMap; use Propel\Runtime\Map\TableMap; use Propel\Tests\TestCase; @@ -200,7 +201,7 @@ public function testGetForeignKeys() */ public function testLoadWrongRelations() { - $this->expectException(\Propel\Runtime\Map\Exception\RelationNotFoundException::class); + $this->expectException(RelationNotFoundException::class); $this->tmap->getRelation('Bar'); } diff --git a/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php b/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php index 6e5594824b..b7413ad820 100644 --- a/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php +++ b/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php @@ -8,6 +8,7 @@ namespace Propel\Tests\Runtime\Parser; +use Propel\Runtime\Exception\FileNotFoundException; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Parser\XmlParser; use Propel\Tests\TestCase; @@ -33,7 +34,7 @@ public function testGetParser() */ public function testGetParserThrowsExceptionOnWrongParser() { - $this->expectException(\Propel\Runtime\Exception\FileNotFoundException::class); + $this->expectException(FileNotFoundException::class); $parser = AbstractParser::getParser('Foo'); } diff --git a/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php b/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php index 88ee49ec45..192fe5cb2b 100644 --- a/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php +++ b/tests/Propel/Tests/Runtime/ServiceContainer/StandardServiceContainerTest.php @@ -14,6 +14,7 @@ use Propel\Runtime\Adapter\Pdo\SqliteAdapter; use Propel\Runtime\Connection\ConnectionManagerSingle; use Propel\Runtime\Connection\PdoConnection; +use Propel\Runtime\Exception\RuntimeException; use Propel\Runtime\Map\DatabaseMap; use Propel\Runtime\Propel; use Propel\Runtime\ServiceContainer\ServiceContainerInterface; @@ -331,7 +332,7 @@ public function testGetConnectionManagersReturnsConnectionManagersForAllDatasour */ public function testGetConnectionManagerWithUnknownDatasource() { - $this->expectException(\Propel\Runtime\Exception\RuntimeException::class); + $this->expectException(RuntimeException::class); $this->sc->getConnectionManager('unknown'); } diff --git a/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php b/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php index 8a4c80496f..61af05bb05 100644 --- a/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php +++ b/tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php @@ -12,6 +12,7 @@ use DateTimeImmutable; use DateTimeZone; use PHPUnit\Framework\TestCase; +use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Util\PropelDateTime; /** @@ -196,7 +197,7 @@ public function testNewInstanceGmt1($value, $expected) */ public function testNewInstanceInvalidValue() { - $this->expectException(\Propel\Runtime\Exception\PropelException::class); + $this->expectException(PropelException::class); $dt = PropelDateTime::newInstance('some string'); } From a56b5da6f6118f7d8156a74fb5a9b6a71da88d61 Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Sun, 1 Nov 2020 14:00:13 +0200 Subject: [PATCH 173/208] PHP8 revert PHP7.2 travis checks --- .travis.yml | 215 ++++++++++++++++++++++++++++++++++++++++---------- composer.json | 2 +- 2 files changed, 176 insertions(+), 41 deletions(-) diff --git a/.travis.yml b/.travis.yml index bf1f463936..9d0a9af552 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ git: dist: bionic php: - - 7.3 + - 7.2 - 7.4 - nightly @@ -37,7 +37,7 @@ script: jobs: include: - - php: 7.3 + - php: 7.2 dist: trusty env: DB=mysql MARIADB=10.1 services: @@ -50,7 +50,7 @@ jobs: addons: mariadb: 10.1 - - php: 7.3 + - php: 7.2 env: DB=mysql MARIADB=10.2 addons: mariadb: 10.2 @@ -58,8 +58,17 @@ jobs: env: DB=mysql MARIADB=10.2 addons: mariadb: 10.2 - - - php: 7.3 + - php: 7.4 + dist: trusty + env: DB=mysql MARIADB=10.1 + services: + addons: + mariadb: 10.1 + - php: 7.4 + env: DB=mysql MARIADB=10.2 + addons: + mariadb: 10.2 + - php: 7.2 env: DB=mysql MARIADB=10.3 addons: mariadb: 10.3 @@ -67,8 +76,7 @@ jobs: env: DB=mysql MARIADB=10.3 addons: mariadb: 10.3 - - - php: 7.3 + - php: 7.2 env: DB=mysql MARIADB=10.4 DB_USER=travis addons: mariadb: 10.4 @@ -89,7 +97,7 @@ jobs: - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; - ./tests/bin/setup.$DB.sh - - php: 7.3 + - php: 7.2 env: DB=pgsql POSTGRES=9.5 addons: postgresql: 9.5 @@ -98,7 +106,7 @@ jobs: addons: postgresql: 9.5 - - php: 7.3 + - php: 7.2 env: DB=pgsql POSTGRES=9.6 addons: postgresql: 9.6 @@ -106,8 +114,7 @@ jobs: env: DB=pgsql POSTGRES=9.6 addons: postgresql: 9.6 - - - php: 7.3 + - php: 7.2 env: DB=pgsql POSTGRES=10 addons: postgresql: 10 @@ -115,8 +122,7 @@ jobs: env: DB=pgsql POSTGRES=10 addons: postgresql: 10 - - - php: 7.3 + - php: 7.2 env: DB=pgsql POSTGRES=11 addons: postgresql: 11 @@ -124,8 +130,7 @@ jobs: env: DB=pgsql POSTGRES=11 addons: postgresql: 11 - - - php: 7.3 + - php: 7.2 env: DB=pgsql POSTGRES=12 PGPORT=5432 addons: postgresql: 12 @@ -157,6 +162,52 @@ jobs: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - composer install -v - composer show + - php: 7.4 + env: DB=mysql MARIADB=10.3 + addons: + mariadb: 10.3 + - php: 7.4 + env: DB=mysql MARIADB=10.4 DB_USER=travis + addons: + mariadb: 10.4 + before_script: + - sudo mysql -e 'drop user if exists travis@localhost;' + - sudo mysql -e 'create user travis@localhost;' + - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; + - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; + - ./tests/bin/setup.$DB.sh + - php: 7.4 + env: DB=pgsql POSTGRES=9.5 + addons: + postgresql: 9.5 + - php: 7.4 + env: DB=pgsql POSTGRES=9.6 + addons: + postgresql: 9.6 + - php: 7.4 + env: DB=pgsql POSTGRES=10 + addons: + postgresql: 10 + - php: 7.4 + env: DB=pgsql POSTGRES=11 + addons: + postgresql: 11 + - php: 7.4 + env: DB=pgsql POSTGRES=12 PGPORT=5432 + addons: + postgresql: 12 + apt: + packages: + - postgresql-12 + - postgresql-client-12 + install: + - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf + - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf + - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf + - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - composer install -v + - composer show - name: "PHP 7.4, Agnostic, Symfony ~3" php: 7.4 @@ -243,93 +294,177 @@ jobs: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show - - - name: "PHP 7.3, Agnostic, Symfony ~3" - php: 7.3 + - name: "PHP 7.4, Agnostic, Symfony ~3" + php: 7.4 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - composer show - - name: "PHP 7.3, Agnostic, Symfony ^3" - php: 7.3 + - name: "PHP 7.4, Agnostic, Symfony ^3" + php: 7.4 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show - - name: "PHP 7.3, Agnostic, Symfony ~4" - php: 7.3 + - name: "PHP 7.4, Agnostic, Symfony ~4" + php: 7.4 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - composer show - - name: "PHP 7.3, Agnostic, Symfony ^4" - php: 7.3 + - name: "PHP 7.4, Agnostic, Symfony ^4" + php: 7.4 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show - - name: "PHP 7.3, Agnostic, Symfony ~5" - php: 7.3 + - name: "PHP 7.4, Agnostic, Symfony ~5" + php: 7.4 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - composer show - - name: "PHP 7.3, Agnostic, Symfony ^5" - php: 7.3 + - name: "PHP 7.4, Agnostic, Symfony ^5" + php: 7.4 env: DB=agnostic install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show - - name: "PHP 7.3, MySql, Symfony ~3" - php: 7.3 + - name: "PHP 7.4, MySql, Symfony ~3" + php: 7.4 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - composer show - - name: "PHP 7.3, MySql, Symfony ^3" - php: 7.3 + - name: "PHP 7.4, MySql, Symfony ^3" + php: 7.4 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show - - name: "PHP 7.3, MySql, Symfony ~4" - php: 7.3 + - name: "PHP 7.4, MySql, Symfony ~4" + php: 7.4 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - composer show - - name: "PHP 7.3, MySql, Symfony ^4" - php: 7.3 + - name: "PHP 7.4, MySql, Symfony ^4" + php: 7.4 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show - - name: "PHP 7.3, MySql, Symfony ~5" - php: 7.3 + - name: "PHP 7.4, MySql, Symfony ~5" + php: 7.4 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - composer show - - name: "PHP 7.3, MySql, Symfony ^5" - php: 7.3 + - name: "PHP 7.4, MySql, Symfony ^5" + php: 7.4 env: DB=mysql install: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show + - name: "PHP 7.2, Agnostic, Symfony ~3" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-min.json composer install + - composer show + - name: "PHP 7.2, Agnostic, Symfony ^3" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-max.json composer install + - composer show + - name: "PHP 7.2, Agnostic, Symfony ~4" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-min.json composer install + - composer show + - name: "PHP 7.2, Agnostic, Symfony ^4" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-max.json composer install + - composer show + - name: "PHP 7.2, Agnostic, Symfony ~5" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-min.json composer install + - composer show + - name: "PHP 7.2, Agnostic, Symfony ^5" + php: 7.2 + env: DB=agnostic + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-max.json composer install + - composer show + + - name: "PHP 7.2, MySql, Symfony ~3" + php: 7.2 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-min.json composer install + - composer show + - name: "PHP 7.2, MySql, Symfony ^3" + php: 7.2 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony3-max.json composer install + - composer show + - name: "PHP 7.2, MySql, Symfony ~4" + php: 7.2 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-min.json composer install + - composer show + - name: "PHP 7.2, MySql, Symfony ^4" + php: 7.2 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony4-max.json composer install + - composer show + - name: "PHP 7.2, MySql, Symfony ~5" + php: 7.2 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-min.json composer install + - composer show + - name: "PHP 7.2, MySql, Symfony ^5" + php: 7.2 + env: DB=mysql + install: + - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + - COMPOSER=./tests/composer/composer-symfony5-max.json composer install + - composer show - name: Checks php: 7.4 env: DB=agnostic CHECKS=1 diff --git a/composer.json b/composer.json index d3dfda25da..47bd5b8707 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "ext-json": "*", "monolog/monolog": "^1.3", "phpstan/phpstan": "^0.12.4", - "phpunit/phpunit": "9.4.2", + "phpunit/phpunit": "^8.0.0||^9.0.0", "spryker/code-sniffer": "^0.15.6" }, "suggest": { From aa91c1325303d72e5fe39a555215c129e08d6503 Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Sun, 1 Nov 2020 15:14:01 +0200 Subject: [PATCH 174/208] PHP8 added nightly builds for every db type --- .travis.yml | 175 ++++++++++++++++------------------------------------ 1 file changed, 52 insertions(+), 123 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9d0a9af552..693259940d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,6 +49,12 @@ jobs: services: addons: mariadb: 10.1 + - php: nightly + dist: trusty + env: DB=mysql MARIADB=10.1 + services: + addons: + mariadb: 10.1 - php: 7.2 env: DB=mysql MARIADB=10.2 @@ -58,16 +64,11 @@ jobs: env: DB=mysql MARIADB=10.2 addons: mariadb: 10.2 - - php: 7.4 - dist: trusty - env: DB=mysql MARIADB=10.1 - services: - addons: - mariadb: 10.1 - - php: 7.4 + - php: nightly env: DB=mysql MARIADB=10.2 addons: mariadb: 10.2 + - php: 7.2 env: DB=mysql MARIADB=10.3 addons: @@ -76,6 +77,11 @@ jobs: env: DB=mysql MARIADB=10.3 addons: mariadb: 10.3 + - php: nightly + env: DB=mysql MARIADB=10.3 + addons: + mariadb: 10.3 + - php: 7.2 env: DB=mysql MARIADB=10.4 DB_USER=travis addons: @@ -96,6 +102,16 @@ jobs: - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; - ./tests/bin/setup.$DB.sh + - php: nightly + env: DB=mysql MARIADB=10.4 DB_USER=travis + addons: + mariadb: 10.4 + before_script: + - sudo mysql -e 'drop user if exists travis@localhost;' + - sudo mysql -e 'create user travis@localhost;' + - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; + - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; + - ./tests/bin/setup.$DB.sh - php: 7.2 env: DB=pgsql POSTGRES=9.5 @@ -105,6 +121,10 @@ jobs: env: DB=pgsql POSTGRES=9.5 addons: postgresql: 9.5 + - php: nightly + env: DB=pgsql POSTGRES=9.5 + addons: + postgresql: 9.5 - php: 7.2 env: DB=pgsql POSTGRES=9.6 @@ -114,6 +134,11 @@ jobs: env: DB=pgsql POSTGRES=9.6 addons: postgresql: 9.6 + - php: nightly + env: DB=pgsql POSTGRES=9.6 + addons: + postgresql: 9.6 + - php: 7.2 env: DB=pgsql POSTGRES=10 addons: @@ -122,6 +147,11 @@ jobs: env: DB=pgsql POSTGRES=10 addons: postgresql: 10 + - php: nightly + env: DB=pgsql POSTGRES=10 + addons: + postgresql: 10 + - php: 7.2 env: DB=pgsql POSTGRES=11 addons: @@ -130,6 +160,11 @@ jobs: env: DB=pgsql POSTGRES=11 addons: postgresql: 11 + - php: nightly + env: DB=pgsql POSTGRES=11 + addons: + postgresql: 11 + - php: 7.2 env: DB=pgsql POSTGRES=12 PGPORT=5432 addons: @@ -162,37 +197,7 @@ jobs: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - composer install -v - composer show - - php: 7.4 - env: DB=mysql MARIADB=10.3 - addons: - mariadb: 10.3 - - php: 7.4 - env: DB=mysql MARIADB=10.4 DB_USER=travis - addons: - mariadb: 10.4 - before_script: - - sudo mysql -e 'drop user if exists travis@localhost;' - - sudo mysql -e 'create user travis@localhost;' - - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; - - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; - - ./tests/bin/setup.$DB.sh - - php: 7.4 - env: DB=pgsql POSTGRES=9.5 - addons: - postgresql: 9.5 - - php: 7.4 - env: DB=pgsql POSTGRES=9.6 - addons: - postgresql: 9.6 - - php: 7.4 - env: DB=pgsql POSTGRES=10 - addons: - postgresql: 10 - - php: 7.4 - env: DB=pgsql POSTGRES=11 - addons: - postgresql: 11 - - php: 7.4 + - php: nightly env: DB=pgsql POSTGRES=12 PGPORT=5432 addons: postgresql: 12 @@ -223,91 +228,7 @@ jobs: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show - - name: "PHP 7.4, Agnostic, Symfony ~4" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - - composer show - - name: "PHP 7.4, Agnostic, Symfony ^4" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - - composer show - - name: "PHP 7.4, Agnostic, Symfony ~5" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - - composer show - - name: "PHP 7.4, Agnostic, Symfony ^5" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - - composer show - - name: "PHP 7.4, MySql, Symfony ~3" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - - composer show - - name: "PHP 7.4, MySql, Symfony ^3" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - - composer show - - name: "PHP 7.4, MySql, Symfony ~4" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - - composer show - - name: "PHP 7.4, MySql, Symfony ^4" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - - composer show - - name: "PHP 7.4, MySql, Symfony ~5" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - - composer show - - name: "PHP 7.4, MySql, Symfony ^5" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - - composer show - - name: "PHP 7.4, Agnostic, Symfony ~3" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - - composer show - - name: "PHP 7.4, Agnostic, Symfony ^3" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - - composer show - name: "PHP 7.4, Agnostic, Symfony ~4" php: 7.4 env: DB=agnostic @@ -322,6 +243,7 @@ jobs: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show + - name: "PHP 7.4, Agnostic, Symfony ~5" php: 7.4 env: DB=agnostic @@ -351,6 +273,7 @@ jobs: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show + - name: "PHP 7.4, MySql, Symfony ~4" php: 7.4 env: DB=mysql @@ -365,6 +288,7 @@ jobs: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show + - name: "PHP 7.4, MySql, Symfony ~5" php: 7.4 env: DB=mysql @@ -379,6 +303,7 @@ jobs: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show + - name: "PHP 7.2, Agnostic, Symfony ~3" php: 7.2 env: DB=agnostic @@ -393,6 +318,7 @@ jobs: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show + - name: "PHP 7.2, Agnostic, Symfony ~4" php: 7.2 env: DB=agnostic @@ -407,6 +333,7 @@ jobs: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show + - name: "PHP 7.2, Agnostic, Symfony ~5" php: 7.2 env: DB=agnostic @@ -436,6 +363,7 @@ jobs: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - composer show + - name: "PHP 7.2, MySql, Symfony ~4" php: 7.2 env: DB=mysql @@ -443,7 +371,6 @@ jobs: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - composer show - - name: "PHP 7.2, MySql, Symfony ^4" php: 7.2 env: DB=mysql @@ -451,6 +378,7 @@ jobs: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - composer show + - name: "PHP 7.2, MySql, Symfony ~5" php: 7.2 env: DB=mysql @@ -465,6 +393,7 @@ jobs: - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show + - name: Checks php: 7.4 env: DB=agnostic CHECKS=1 From e29f99e5f459e723aeb9318a748ddac2aa541607 Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Sun, 1 Nov 2020 17:21:59 +0200 Subject: [PATCH 175/208] PHP8 Fixes after Psalm --- psalm.xml | 28 +++++++++ .../Common/Config/Loader/IniFileLoader.php | 10 ++-- .../Common/Config/Loader/JsonFileLoader.php | 6 +- .../Common/Config/Loader/PhpFileLoader.php | 10 ++-- .../Common/Config/Loader/XmlFileLoader.php | 6 +- .../Common/Config/Loader/YamlFileLoader.php | 10 ++-- src/Propel/Runtime/ActiveQuery/Criteria.php | 2 +- .../Runtime/ActiveQuery/ModelCriteria.php | 12 ++-- .../Runtime/Adapter/Pdo/PgsqlAdapter.php | 2 +- .../Connection/ConnectionInterface.php | 5 +- .../Runtime/Connection/PdoConnection.php | 4 ++ .../Connection/ProfilerStatementWrapper.php | 20 +++---- .../Runtime/Connection/StatementInterface.php | 40 ++++++------- .../Runtime/Connection/StatementWrapper.php | 58 +++++++++---------- src/Propel/Runtime/Parser/AbstractParser.php | 6 +- .../Common/Config/Loader/FileLoaderTest.php | 2 +- 16 files changed, 125 insertions(+), 96 deletions(-) create mode 100644 psalm.xml diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000000..e79004ae5e --- /dev/null +++ b/psalm.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/Propel/Common/Config/Loader/IniFileLoader.php b/src/Propel/Common/Config/Loader/IniFileLoader.php index 723f696e99..65c962ee0b 100644 --- a/src/Propel/Common/Config/Loader/IniFileLoader.php +++ b/src/Propel/Common/Config/Loader/IniFileLoader.php @@ -44,20 +44,20 @@ public function supports($resource, $type = null) /** * Loads a resource, merge it with the default configuration array and resolve its parameters. * - * @param string $file The resource + * @param string $resource The resource * @param string|null $type The resource type * - * @throws \InvalidArgumentException if configuration file not found * @throws \Propel\Common\Config\Exception\InvalidArgumentException When ini file is not valid + * @throws \InvalidArgumentException if configuration file not found * * @return array The configuration array */ - public function load($file, $type = null) + public function load($resource, $type = null) { - $ini = parse_ini_file($this->getPath($file), true, INI_SCANNER_RAW); + $ini = parse_ini_file($this->getPath($resource), true, INI_SCANNER_RAW); if ($ini === false) { - throw new InvalidArgumentException("The configuration file '$file' has invalid content."); + throw new InvalidArgumentException("The configuration file '$resource' has invalid content."); } $ini = $this->parse($ini); //Parse for nested sections diff --git a/src/Propel/Common/Config/Loader/JsonFileLoader.php b/src/Propel/Common/Config/Loader/JsonFileLoader.php index 6692fd9bc1..82cb5b664b 100644 --- a/src/Propel/Common/Config/Loader/JsonFileLoader.php +++ b/src/Propel/Common/Config/Loader/JsonFileLoader.php @@ -20,16 +20,16 @@ class JsonFileLoader extends FileLoader /** * Loads an Json file. * - * @param string $file The resource + * @param string $resource The resource * @param string|null $type The resource type * * @throws \Propel\Common\Config\Exception\JsonParseException if invalid json file * * @return array */ - public function load($file, $type = null) + public function load($resource, $type = null) { - $json = file_get_contents($this->getPath($file)); + $json = file_get_contents($this->getPath($resource)); $content = []; diff --git a/src/Propel/Common/Config/Loader/PhpFileLoader.php b/src/Propel/Common/Config/Loader/PhpFileLoader.php index 84d4260e07..b2cdfac383 100644 --- a/src/Propel/Common/Config/Loader/PhpFileLoader.php +++ b/src/Propel/Common/Config/Loader/PhpFileLoader.php @@ -29,17 +29,17 @@ class PhpFileLoader extends FileLoader /** * Loads a PHP file. * - * @param string $file The resource + * @param string $resource The resource * @param string|null $type The resource type * - * @throws \InvalidArgumentException if configuration file not found * @throws \Propel\Common\Config\Exception\InvalidArgumentException if invalid json file + * @throws \InvalidArgumentException if configuration file not found * * @return array */ - public function load($file, $type = null) + public function load($resource, $type = null) { - $path = $this->getPath($file); + $path = $this->getPath($resource); //Use output buffering because in case $file contains invalid non-php content (i.e. plain text), include() function //write it on stdoutput @@ -48,7 +48,7 @@ public function load($file, $type = null) ob_end_clean(); if (!is_array($content)) { - throw new InvalidArgumentException("The configuration file '$file' has invalid content."); + throw new InvalidArgumentException("The configuration file '$resource' has invalid content."); } $content = $this->resolveParams($content); //Resolve parameter placeholders (%name%) diff --git a/src/Propel/Common/Config/Loader/XmlFileLoader.php b/src/Propel/Common/Config/Loader/XmlFileLoader.php index 525d96583a..911bc40c6d 100644 --- a/src/Propel/Common/Config/Loader/XmlFileLoader.php +++ b/src/Propel/Common/Config/Loader/XmlFileLoader.php @@ -20,14 +20,14 @@ class XmlFileLoader extends FileLoader /** * Loads an Xml file. * - * @param string $file The resource + * @param string $resource The resource * @param string|null $type The resource type * * @return array */ - public function load($file, $type = null) + public function load($resource, $type = null) { - $content = XmlToArrayConverter::convert($this->getPath($file)); + $content = XmlToArrayConverter::convert($this->getPath($resource)); $content = $this->resolveParams($content); //Resolve parameter placeholders (%name%) return $content; diff --git a/src/Propel/Common/Config/Loader/YamlFileLoader.php b/src/Propel/Common/Config/Loader/YamlFileLoader.php index 2c24d5826b..215cc49082 100644 --- a/src/Propel/Common/Config/Loader/YamlFileLoader.php +++ b/src/Propel/Common/Config/Loader/YamlFileLoader.php @@ -22,20 +22,20 @@ class YamlFileLoader extends FileLoader /** * Loads a Yaml file. * - * @param string $file The resource + * @param string $resource The resource * @param string|null $type The resource type * - * @throws \Symfony\Component\Yaml\Exception\ParseException if something goes wrong in parsing file * @throws \Propel\Common\Config\Exception\InputOutputException if configuration file is not readable + * @throws \Symfony\Component\Yaml\Exception\ParseException if something goes wrong in parsing file * * @return array */ - public function load($file, $type = null) + public function load($resource, $type = null) { - $path = $this->locator->locate($file); + $path = $this->locator->locate($resource); if (!is_readable($path)) { - throw new InputOutputException("You don't have permissions to access configuration file $file."); + throw new InputOutputException("You don't have permissions to access configuration file $resource."); } $content = Yaml::parse(file_get_contents($path)); diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index 3d164ebee7..be98e9aff2 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -2421,7 +2421,7 @@ public function getPrimaryKey(?Criteria $criteria = null) * WHERE some_column = some value AND could_have_another_column = * another value AND so on. * - * @param \Propel\Runtime\ActiveQuery\Criteria $updateValues A Criteria object containing values used in set clause. + * @param array|\Propel\Runtime\ActiveQuery\Criteria $updateValues A Criteria object containing values used in set clause. * @param \Propel\Runtime\Connection\ConnectionInterface $con The ConnectionInterface connection object to use. * * @throws \Propel\Runtime\Exception\PropelException diff --git a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php index 84411f1e4d..131471db97 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php @@ -1797,19 +1797,19 @@ public function update($values, ?ConnectionInterface $con = null, $forceIndividu * Issue an UPDATE query based the current ModelCriteria and a list of changes. * This method is called by ModelCriteria::update() inside a transaction. * - * @param array $values Associative array of keys and values to replace + * @param array|\Propel\Runtime\ActiveQuery\Criteria $updateValues Associative array of keys and values to replace * @param \Propel\Runtime\Connection\ConnectionInterface $con a connection object * @param bool $forceIndividualSaves If false (default), the resulting call is a Criteria::doUpdate(), otherwise it is a series of save() calls on all the found objects * * @return int Number of updated rows */ - public function doUpdate($values, ConnectionInterface $con, $forceIndividualSaves = false) + public function doUpdate($updateValues, ConnectionInterface $con, $forceIndividualSaves = false) { if ($forceIndividualSaves) { // Update rows one by one $objects = $this->setFormatter(ModelCriteria::FORMAT_OBJECT)->find($con); foreach ($objects as $object) { - foreach ($values as $key => $value) { + foreach ($updateValues as $key => $value) { $object->setByName($key, $value); } } @@ -1817,11 +1817,11 @@ public function doUpdate($values, ConnectionInterface $con, $forceIndividualSave $affectedRows = count($objects); } else { // update rows in a single query - if ($values instanceof Criteria) { - $set = $values; + if ($updateValues instanceof Criteria) { + $set = $updateValues; } else { $set = new Criteria($this->getDbName()); - foreach ($values as $columnName => $value) { + foreach ($updateValues as $columnName => $value) { $realColumnName = $this->getTableMap()->getColumnByPhpName($columnName)->getFullyQualifiedName(); $set->add($realColumnName, $value); } diff --git a/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php index 463eb887ac..883d3f011d 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php @@ -229,7 +229,7 @@ public function quoteIdentifierTable($table) * @param \Propel\Runtime\Connection\ConnectionInterface $con propel connection * @param \Propel\Runtime\ActiveQuery\Criteria|string $query query the criteria or the query string * - * @return \Propel\Runtime\Connection\StatementInterface A PDO statement executed using the connection, ready to be fetched + * @return \Propel\Runtime\Connection\StatementInterface|\PDOStatement|bool A PDO statement executed using the connection, ready to be fetched */ public function doExplainPlan(ConnectionInterface $con, $query) { diff --git a/src/Propel/Runtime/Connection/ConnectionInterface.php b/src/Propel/Runtime/Connection/ConnectionInterface.php index 597c7d790a..236a3a4c20 100644 --- a/src/Propel/Runtime/Connection/ConnectionInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionInterface.php @@ -148,8 +148,7 @@ public function transaction(callable $callable); * @param string $statement The SQL statement to prepare and execute. * Data inside the query should be properly escaped. * - * @return int The number of rows that were modified or deleted by the SQL - * statement you issued. If no rows were affected, returns 0. + * @return mixed The number of rows that were modified or deleted. */ public function exec($statement); @@ -181,7 +180,7 @@ public function prepare(string $statement, array $driverOptions = []); * * @throws \Propel\Runtime\Connection\Exception\ConnectionException depending on error handling. * - * @return \Propel\Runtime\DataFetcher\DataFetcherInterface + * @return \Propel\Runtime\DataFetcher\DataFetcherInterface|\PDOStatement|bool */ public function query($statement); diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index 930bb67a2c..7637debaa9 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -126,6 +126,8 @@ public function getSingleDataFetcher($data) /** * @inheritDoc + * + * @return \PDOStatement|bool */ public function query($statement) { @@ -134,6 +136,8 @@ public function query($statement) /** * @inheritDoc + * + * @return \Propel\Runtime\DataFetcher\DataFetcherInterface */ public function exec($statement) { diff --git a/src/Propel/Runtime/Connection/ProfilerStatementWrapper.php b/src/Propel/Runtime/Connection/ProfilerStatementWrapper.php index 576064970c..8992e7ce7d 100644 --- a/src/Propel/Runtime/Connection/ProfilerStatementWrapper.php +++ b/src/Propel/Runtime/Connection/ProfilerStatementWrapper.php @@ -21,36 +21,36 @@ class ProfilerStatementWrapper extends StatementWrapper * as a reference and will only be evaluated at the time that PDOStatement::execute() is called. * Returns a boolean value indicating success. * - * @param int $pos Parameter identifier (for determining what to replace in the query). - * @param mixed $value The value to bind to the parameter. - * @param int $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. + * @param int $parameter Parameter identifier (for determining what to replace in the query). + * @param mixed $variable The value to bind to the parameter. + * @param int $dataType Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. * @param int|null $length Length of the data type. To indicate that a parameter is an OUT parameter from a stored procedure, you must explicitly set the length. - * @param mixed $driver_options + * @param mixed $driverOptions * * @return bool */ - public function bindParam($pos, &$value, $type = PDO::PARAM_STR, $length = 0, $driver_options = null) + public function bindParam($parameter, &$variable, $dataType = PDO::PARAM_STR, $length = 0, $driverOptions = null) { $this->connection->getProfiler()->start(); - return parent::bindParam($pos, $value, $type, $length, $driver_options); + return parent::bindParam($parameter, $variable, $dataType, $length, $driverOptions); } /** * Binds a value to a corresponding named or question mark placeholder in the SQL statement * that was use to prepare the statement. Returns a boolean value indicating success. * - * @param int $pos Parameter identifier (for determining what to replace in the query). + * @param int $parameter Parameter identifier (for determining what to replace in the query). * @param mixed $value The value to bind to the parameter. - * @param int $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. + * @param int $dataType Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. * * @return bool */ - public function bindValue($pos, $value, $type = PDO::PARAM_STR) + public function bindValue($parameter, $value, $dataType = PDO::PARAM_STR) { $this->connection->getProfiler()->start(); - return parent::bindValue($pos, $value, $type); + return parent::bindValue($parameter, $value, $dataType); } /** diff --git a/src/Propel/Runtime/Connection/StatementInterface.php b/src/Propel/Runtime/Connection/StatementInterface.php index 22c9a1427f..6a4a0b760f 100644 --- a/src/Propel/Runtime/Connection/StatementInterface.php +++ b/src/Propel/Runtime/Connection/StatementInterface.php @@ -23,37 +23,35 @@ interface StatementInterface /** * Executes a prepared statement * - * @param array|null $input_parameters - * - * @throws \PDOException On error if PDO::ERRMODE_EXCEPTION option is true. + * @param array|null $inputParameters * * @return bool TRUE on success or FALSE on failure. */ - public function execute($input_parameters = null); + public function execute($inputParameters = null); /** * Fetches the next row from a result set * - * @param int|null $fetch_style Controls how the next row will be returned to the caller. - * @param int $cursor_orientation This value determines which row will be returned to the caller. - * @param int $cursor_offset + * @param int|null $fetchStyle Controls how the next row will be returned to the caller. + * @param int $cursorOrientation This value determines which row will be returned to the caller. + * @param int $cursorOffset * * @return mixed */ - public function fetch($fetch_style = null, $cursor_orientation = PDO::FETCH_ORI_NEXT, $cursor_offset = 0); + public function fetch($fetchStyle = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0); /** * Binds a parameter to the specified variable name * * @param mixed $parameter Parameter identifier. * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter. - * @param int $data_type Explicit data type for the parameter using the PDO::PARAM_* constants. + * @param int $dataType Explicit data type for the parameter using the PDO::PARAM_* constants. * @param int|null $length Length of the data type. - * @param mixed $driver_options + * @param mixed $driverOptions * * @return bool TRUE on success or FALSE on failure. */ - public function bindParam($parameter, &$variable, $data_type = PDO::PARAM_STR, $length = null, $driver_options = null); + public function bindParam($parameter, &$variable, $dataType = PDO::PARAM_STR, $length = null, $driverOptions = null); /** * Bind a column to a PHP variable @@ -73,11 +71,11 @@ public function bindColumn($column, &$param, $type = null, $maxlen = null, $driv * * @param mixed $parameter Parameter identifier. * @param mixed $value The value to bind to the parameter. - * @param int $data_type Explicit data type for the parameter using the PDO::PARAM_* constants. + * @param int $dataType Explicit data type for the parameter using the PDO::PARAM_* constants. * * @return bool TRUE on success or FALSE on failure. */ - public function bindValue($parameter, $value, $data_type = PDO::PARAM_STR); + public function bindValue($parameter, $value, $dataType = PDO::PARAM_STR); /** * Returns the number of rows affected by the last SQL statement @@ -91,30 +89,30 @@ public function rowCount(); * * @param int $column_number 0-indexed number of the column you wish to retrieve from the row. * - * @return mixed Returns a single column from the next row of a result set or FALSE if there are no more rows. + * @return string|null Returns a single column from the next row of a result set or FALSE if there are no more rows. */ public function fetchColumn($column_number = 0); /** * Returns an array containing all of the result set rows * - * @param int|null $fetch_style Controls the contents of the returned array as documented in PDOStatement::fetch. - * @param mixed $fetch_argument This argument have a different meaning depending on the value of the fetch_style - * @param array $ctor_args Arguments of custom class constructor when the fetch_style parameter is PDO::FETCH_CLASS. + * @param int|null $fetchStyle Controls the contents of the returned array as documented in PDOStatement::fetch. + * @param mixed $fetchArgument This argument have a different meaning depending on the value of the fetch_style + * @param array $ctorArgs Arguments of custom class constructor when the fetch_style parameter is PDO::FETCH_CLASS. * * @return array returns an array containing all of the remaining rows in the result set. */ - public function fetchAll($fetch_style = null, $fetch_argument = null, array $ctor_args = []); + public function fetchAll($fetchStyle = null, $fetchArgument = null, array $ctorArgs = []); /** * Fetches the next row and returns it as an object. * - * @param string $class_name Name of the created class. - * @param array $ctor_args Elements of this array are passed to the constructor. + * @param string $className Name of the created class. + * @param array $ctorArgs Elements of this array are passed to the constructor. * * @return mixed */ - public function fetchObject($class_name = 'stdClass', array $ctor_args = []); + public function fetchObject($className = 'stdClass', array $ctorArgs = []); /** * Fetch the SQLSTATE associated with the last operation on the statement handle diff --git a/src/Propel/Runtime/Connection/StatementWrapper.php b/src/Propel/Runtime/Connection/StatementWrapper.php index eb61f5bbdc..269605417c 100644 --- a/src/Propel/Runtime/Connection/StatementWrapper.php +++ b/src/Propel/Runtime/Connection/StatementWrapper.php @@ -102,22 +102,22 @@ public function query() * as a reference and will only be evaluated at the time that PDOStatement::execute() is called. * Returns a boolean value indicating success. * - * @param int $pos Parameter identifier (for determining what to replace in the query). - * @param mixed $value The value to bind to the parameter. - * @param int $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. + * @param int $parameter Parameter identifier (for determining what to replace in the query). + * @param mixed $variable The value to bind to the parameter. + * @param int $dataType Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. * @param int $length Length of the data type. To indicate that a parameter is an OUT parameter from a stored procedure, you must explicitly set the length. - * @param mixed $driver_options + * @param mixed $driverOptions * * @return bool */ - public function bindParam($pos, &$value, $type = PDO::PARAM_STR, $length = 0, $driver_options = null) + public function bindParam($parameter, &$variable, $dataType = PDO::PARAM_STR, $length = 0, $driverOptions = null) { - $return = $this->statement->bindParam($pos, $value, $type, $length, $driver_options); + $return = $this->statement->bindParam($parameter, $variable, $dataType, $length, $driverOptions); if ($this->connection->useDebug) { - $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)'; - $valuestr = $length > 100 ? '[Large value]' : var_export($value, true); - $this->boundValues[$pos] = $valuestr; - $msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr); + $typestr = isset(self::$typeMap[$dataType]) ? self::$typeMap[$dataType] : '(default)'; + $valuestr = $length > 100 ? '[Large value]' : var_export($variable, true); + $this->boundValues[$parameter] = $valuestr; + $msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $parameter, $typestr); $this->connection->log($msg); } @@ -128,20 +128,20 @@ public function bindParam($pos, &$value, $type = PDO::PARAM_STR, $length = 0, $d * Binds a value to a corresponding named or question mark placeholder in the SQL statement * that was use to prepare the statement. Returns a boolean value indicating success. * - * @param int $pos Parameter identifier (for determining what to replace in the query). + * @param int $parameter Parameter identifier (for determining what to replace in the query). * @param mixed $value The value to bind to the parameter. - * @param int $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. + * @param int $dataType Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. * * @return bool */ - public function bindValue($pos, $value, $type = PDO::PARAM_STR) + public function bindValue($parameter, $value, $dataType = PDO::PARAM_STR) { - $return = $this->statement->bindValue($pos, $value, $type); + $return = $this->statement->bindValue($parameter, $value, $dataType); if ($this->connection->useDebug) { - $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)'; - $valuestr = $type == PDO::PARAM_LOB ? '[LOB value]' : var_export($value, true); - $this->boundValues[$pos] = $valuestr; - $msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr); + $typestr = isset(self::$typeMap[$dataType]) ? self::$typeMap[$dataType] : '(default)'; + $valuestr = $dataType == PDO::PARAM_LOB ? '[LOB value]' : var_export($value, true); + $this->boundValues[$parameter] = $valuestr; + $msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $parameter, $typestr); $this->connection->log($msg); } @@ -195,15 +195,15 @@ public function columnCount() * Returns a boolean value indicating success. * Overridden for query counting and logging. * - * @param array|null $input_parameters + * @param array|null $inputParameters * * @return bool */ - public function execute($input_parameters = null) + public function execute($inputParameters = null) { - $return = $this->statement->execute($input_parameters); + $return = $this->statement->execute($inputParameters); if ($this->connection->useDebug) { - $sql = $this->getExecutedQueryString($input_parameters); + $sql = $this->getExecutedQueryString($inputParameters); $this->connection->log($sql); $this->connection->setLastExecutedQuery($sql); $this->connection->incrementQueryCount(); @@ -213,11 +213,11 @@ public function execute($input_parameters = null) } /** - * @param array|null $input_parameters + * @param array|null $inputParameters * * @return string */ - public function getExecutedQueryString($input_parameters = null) + public function getExecutedQueryString($inputParameters = null) { $sql = $this->statement->queryString; $matches = []; @@ -228,8 +228,8 @@ public function getExecutedQueryString($input_parameters = null) if (isset($this->boundValues[$pos])) { $sql = str_replace($pos, $this->boundValues[$pos], $sql); } - if ($input_parameters && isset($input_parameters[$pos])) { - $sql = str_replace($pos, $input_parameters[$pos], $sql); + if ($inputParameters && isset($inputParameters[$pos])) { + $sql = str_replace($pos, $inputParameters[$pos], $sql); } } } @@ -275,7 +275,7 @@ public function fetchAll($fetchStyle = PDO::FETCH_BOTH, $fetchArgument = null, $ * value is supplied, PDOStatement->fetchColumn() * fetches the first column. * - * @return string A single column in the next row of a result set. + * @return string|null A single column in the next row of a result set. */ public function fetchColumn($columnIndex = 0) { @@ -355,9 +355,9 @@ public function bindColumn($column, &$param, $type = null, $maxlen = null, $driv /** * @inheritDoc */ - public function fetchObject($class_name = 'stdClass', array $ctor_args = []) + public function fetchObject($className = 'stdClass', array $ctorArgs = []) { - return $this->statement->fetchObject($class_name, $ctor_args); + return $this->statement->fetchObject($className, $ctorArgs); } /** diff --git a/src/Propel/Runtime/Parser/AbstractParser.php b/src/Propel/Runtime/Parser/AbstractParser.php index 6471a8c936..4737d5025e 100644 --- a/src/Propel/Runtime/Parser/AbstractParser.php +++ b/src/Propel/Runtime/Parser/AbstractParser.php @@ -43,14 +43,14 @@ abstract public function fromArray($array, $rootKey = 'data'); abstract public function toArray($data, $rootKey = 'data'); /** - * @param array $data + * @param array $array * @param string|null $rootKey * * @return string */ - public function listFromArray($data, $rootKey = 'data') + public function listFromArray($array, $rootKey = 'data') { - return $this->fromArray($data, $rootKey); + return $this->fromArray($array, $rootKey); } /** diff --git a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php index 2e39afdf16..626f9c1279 100644 --- a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php @@ -364,7 +364,7 @@ class TestableFileLoader extends BaseFileLoader /** * @return void */ - public function load($file, $type = null) + public function load($resource, $type = null) { } From b8f3c83a874835699d2e9711e05705ee7a26c559 Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Sun, 1 Nov 2020 18:45:57 +0200 Subject: [PATCH 176/208] PHP8 excluded travis tests nightly with mariadb10.1 onboard --- .travis.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 693259940d..eba9a7ad00 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,12 +49,13 @@ jobs: services: addons: mariadb: 10.1 - - php: nightly - dist: trusty - env: DB=mysql MARIADB=10.1 - services: - addons: - mariadb: 10.1 +# @todo: This job is failinig due to old Travis nightly image +# - php: nightly +# dist: trusty +# env: DB=mysql MARIADB=10.1 +# services: +# addons: +# mariadb: 10.1 - php: 7.2 env: DB=mysql MARIADB=10.2 From 886219b2e68408a91406e2e8f8e5e76686dc14dd Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Sun, 1 Nov 2020 21:50:34 +0200 Subject: [PATCH 177/208] PHP8 stan baseline update --- phpstan-baseline.neon | 15 +++++---------- psalm.xml | 28 ---------------------------- 2 files changed, 5 insertions(+), 38 deletions(-) delete mode 100644 psalm.xml diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 807897e3d5..d0eb6672e3 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -290,6 +290,11 @@ parameters: count: 1 path: src/Propel/Generator/Model/ForeignKey.php + - + message: "#^Strict comparison using \\=\\=\\= between int\\<1, max\\> and 0 will always evaluate to false\\.$#" + count: 1 + path: src/Propel/Generator/Model/MappingModel.php + - message: "#^If condition is always true\\.$#" count: 1 @@ -525,16 +530,6 @@ parameters: count: 1 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - - message: "#^Parameter \\#1 \\$values \\(array\\) of method Propel\\\\Runtime\\\\ActiveQuery\\\\ModelCriteria\\:\\:doUpdate\\(\\) should be compatible with parameter \\$updateValues \\(Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\) of method Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:doUpdate\\(\\)$#" - count: 1 - path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - - - message: "#^Instanceof between array and Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria will always evaluate to false\\.$#" - count: 1 - path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php - - message: "#^Call to function is_array\\(\\) with object will always evaluate to false\\.$#" count: 1 diff --git a/psalm.xml b/psalm.xml deleted file mode 100644 index e79004ae5e..0000000000 --- a/psalm.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - From 10aad379794eef121d4a39b6de2d947a76dfbb26 Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Mon, 2 Nov 2020 10:57:48 +0200 Subject: [PATCH 178/208] PHP8 fixes on review --- src/Propel/Generator/Util/QuickBuilder.php | 4 +-- .../Connection/ConnectionInterface.php | 10 +++--- .../Runtime/Connection/ConnectionWrapper.php | 7 +--- .../Runtime/Connection/PdoConnection.php | 2 +- .../Runtime/Connection/StatementInterface.php | 34 +++++++++---------- 5 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/Propel/Generator/Util/QuickBuilder.php b/src/Propel/Generator/Util/QuickBuilder.php index e7b65f2734..a4a75f8d49 100644 --- a/src/Propel/Generator/Util/QuickBuilder.php +++ b/src/Propel/Generator/Util/QuickBuilder.php @@ -22,7 +22,7 @@ use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Connection\ConnectionWrapper; use Propel\Runtime\Connection\PdoConnection; -use Propel\Runtime\Connection\StatementWrapper; +use Propel\Runtime\Connection\StatementInterface; use Propel\Runtime\Propel; class QuickBuilder @@ -265,7 +265,7 @@ public function buildSQL(ConnectionInterface $con) } try { $stmt = $con->prepare($statement); - if ($stmt instanceof StatementWrapper) { + if ($stmt instanceof StatementInterface) { // only execute if has no error $stmt->execute(); } diff --git a/src/Propel/Runtime/Connection/ConnectionInterface.php b/src/Propel/Runtime/Connection/ConnectionInterface.php index 236a3a4c20..1487ceac48 100644 --- a/src/Propel/Runtime/Connection/ConnectionInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionInterface.php @@ -21,14 +21,14 @@ interface ConnectionInterface { /** - * @param string $name The datasource name associated to this connection + * @param string $name The datasource name associated to this connection. * * @return void */ public function setName($name); /** - * @return string The datasource name associated to this connection + * @return string The datasource name associated to this connection. */ public function getName(); @@ -78,7 +78,7 @@ public function inTransaction(); * Retrieve a database connection attribute. * * @param int $attribute The name of the attribute to retrieve, - * e.g. PDO::ATTR_AUTOCOMMIT + * e.g. PDO::ATTR_AUTOCOMMIT. * * @return mixed A successful call returns the value of the requested attribute. * An unsuccessful call returns null. @@ -134,7 +134,7 @@ public function getDataFetcher($data); * * In case you want the transaction to rollback just throw an Exception of any type. * - * @param callable $callable A callable to be wrapped in a transaction + * @param callable $callable A callable to be wrapped in a transaction. * * @throws \Exception Re-throws a possible Exception triggered by the callable. * @@ -148,7 +148,7 @@ public function transaction(callable $callable); * @param string $statement The SQL statement to prepare and execute. * Data inside the query should be properly escaped. * - * @return mixed The number of rows that were modified or deleted. + * @return \Propel\Runtime\DataFetcher\DataFetcherInterface The number of rows that were modified or deleted. */ public function exec($statement); diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index 754cec484f..204155df50 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -407,12 +407,7 @@ public function prepare(string $statement, array $driverOptions = []) } /** - * Execute an SQL statement and return the number of affected rows. - * Overrides PDO::exec() to log queries when required - * - * @param string $sql - * - * @return int + * @inehritDoc */ public function exec($sql) { diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index 7637debaa9..6f4cae5c52 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -30,7 +30,7 @@ class PdoConnection implements ConnectionInterface protected $pdo; /** - * Forward any call to a method not found to the proxied connection. + * Forward any calls to an inaccessible method to the proxied connection. * * @param string $method * @param mixed $args diff --git a/src/Propel/Runtime/Connection/StatementInterface.php b/src/Propel/Runtime/Connection/StatementInterface.php index 6a4a0b760f..8a823b001e 100644 --- a/src/Propel/Runtime/Connection/StatementInterface.php +++ b/src/Propel/Runtime/Connection/StatementInterface.php @@ -21,7 +21,7 @@ interface StatementInterface { /** - * Executes a prepared statement + * Executes a prepared statement. * * @param array|null $inputParameters * @@ -30,7 +30,7 @@ interface StatementInterface public function execute($inputParameters = null); /** - * Fetches the next row from a result set + * Fetches the next row from a result set. * * @param int|null $fetchStyle Controls how the next row will be returned to the caller. * @param int $cursorOrientation This value determines which row will be returned to the caller. @@ -41,7 +41,7 @@ public function execute($inputParameters = null); public function fetch($fetchStyle = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0); /** - * Binds a parameter to the specified variable name + * Binds a parameter to the specified variable name. * * @param mixed $parameter Parameter identifier. * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter. @@ -54,7 +54,7 @@ public function fetch($fetchStyle = null, $cursorOrientation = PDO::FETCH_ORI_NE public function bindParam($parameter, &$variable, $dataType = PDO::PARAM_STR, $length = null, $driverOptions = null); /** - * Bind a column to a PHP variable + * Bind a column to a PHP variable. * * @param mixed $column Number of the column (1-indexed) or name of the column in the result set. * @param mixed $param Name of the PHP variable to which the column will be bound. @@ -78,14 +78,14 @@ public function bindColumn($column, &$param, $type = null, $maxlen = null, $driv public function bindValue($parameter, $value, $dataType = PDO::PARAM_STR); /** - * Returns the number of rows affected by the last SQL statement + * Returns the number of rows affected by the last SQL statement. * * @return int the number of rows. */ public function rowCount(); /** - * Returns a single column from the next row of a result set + * Returns a single column from the next row of a result set. * * @param int $column_number 0-indexed number of the column you wish to retrieve from the row. * @@ -94,7 +94,7 @@ public function rowCount(); public function fetchColumn($column_number = 0); /** - * Returns an array containing all of the result set rows + * Returns an array containing all of the result set rows. * * @param int|null $fetchStyle Controls the contents of the returned array as documented in PDOStatement::fetch. * @param mixed $fetchArgument This argument have a different meaning depending on the value of the fetch_style @@ -115,21 +115,21 @@ public function fetchAll($fetchStyle = null, $fetchArgument = null, array $ctorA public function fetchObject($className = 'stdClass', array $ctorArgs = []); /** - * Fetch the SQLSTATE associated with the last operation on the statement handle + * Fetch the SQLSTATE associated with the last operation on the statement handle. * * @return string */ public function errorCode(); /** - * Fetch extended error information associated with the last operation on the statement handle + * Fetch extended error information associated with the last operation on the statement handle. * * @return array returns an array of error information about the last operation performed by this statement handle. */ public function errorInfo(); /** - * Set a statement attribute + * Set a statement attribute. * * @param int $attribute * @param mixed $value @@ -139,7 +139,7 @@ public function errorInfo(); public function setAttribute($attribute, $value); /** - * Retrieve a statement attribute + * Retrieve a statement attribute. * * @param int $attribute * @@ -148,14 +148,14 @@ public function setAttribute($attribute, $value); public function getAttribute($attribute); /** - * Returns the number of columns in the result set + * Returns the number of columns in the result set. * * @return int the number of columns in the result set represented by the StatementInterface object. */ public function columnCount(); /** - * Returns metadata for a column in a result set + * Returns metadata for a column in a result set. * * @param int $column The 0-indexed column in the result set. * @@ -164,10 +164,10 @@ public function columnCount(); public function getColumnMeta($column); /** - * Set the default fetch mode for this statement + * Set the default fetch mode for this statement. * * @param int $mode The fetch mode must be one of the PDO::FETCH_* constants. - * @param string|object|null $classNameObject Class name or object + * @param string|object|null $classNameObject Class name or object. * @param array $ctorarfg Constructor arguments. * * @return bool TRUE on success or FALSE on failure. @@ -175,7 +175,7 @@ public function getColumnMeta($column); public function setFetchMode($mode, $classNameObject = null, array $ctorarfg = []); /** - * Advances to the next rowset in a multi-rowset statement handle + * Advances to the next rowset in a multi-rowset statement handle. * * @return bool TRUE on success or FALSE on failure. */ @@ -189,7 +189,7 @@ public function nextRowset(); public function closeCursor(); /** - * Dump an SQL prepared command + * Dump an SQL prepared command. * * @return void No value is returned. */ From 1dd1adb0f2a45dcb2253d89cca8cd01ff5f1ad9a Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Mon, 2 Nov 2020 11:21:11 +0200 Subject: [PATCH 179/208] PHP8 added psalm --- .travis.yml | 1 + composer.json | 9 +- psalm-baseline.xml | 739 +++++++++++++++++++++++++++++++++++++++++++++ psalm.xml | 27 ++ 4 files changed, 774 insertions(+), 2 deletions(-) create mode 100644 psalm-baseline.xml create mode 100644 psalm.xml diff --git a/.travis.yml b/.travis.yml index eba9a7ad00..bfb0b354d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -402,6 +402,7 @@ jobs: - composer install --prefer-dist --no-interaction script: - composer stan + - composer psalm - composer cs-check fast_finish: true diff --git a/composer.json b/composer.json index 47bd5b8707..703bb96e74 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,8 @@ "monolog/monolog": "^1.3", "phpstan/phpstan": "^0.12.4", "phpunit/phpunit": "^8.0.0||^9.0.0", - "spryker/code-sniffer": "^0.15.6" + "spryker/code-sniffer": "^0.15.6", + "psalm/phar": "^4.1.0" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." @@ -49,7 +50,11 @@ "cs-check": "phpcs -p -s --standard=config/phpcs.xml src/", "cs-fix": "phpcbf -p --standard=config/phpcs.xml src/", "stan": "vendor/bin/phpstan analyze", - "stan-baseline": "vendor/bin/phpstan analyze --generate-baseline" + "stan-baseline": "vendor/bin/phpstan analyze --generate-baseline", + "psalm": "vendor/bin/psalm.phar --show-info=false", + "psalm-update-baseline": "vendor/bin/psalm.phar --update-baseline", + "psalm-set-baseline": "vendor/bin/psalm.phar --set-baseline=psalm-baseline.xml", + "psalm-update-report": "vendor/bin/psalm.phar --report=psalm-report.xml" }, "extra": { "branch-alias": { diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 0000000000..93840e7a5a --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,739 @@ + + + + + new TreeBuilder() + + + + + $column + $column + $sql + $bindings + + + + + $column + $column + $column + $column + + + + + $relationName + $relationName + $aggregateName + $variableName + $relationName + $variableName + $updateMethodName + $relationName + $aggregateName + $relationName + $aggregateName + $updateMethodName + $relationName + $aggregateName + + + + + $foreignTable + $relationName + $aggregateName + $variableName + $foreignQueryName + $refRelationName + + + + + $relationName + $aggregateName + $variableName + $variableName + $variableName + $updateMethodName + $variableName + + + + + $archiveTable->isArchiveTable + + + + + $archiveTablePhpName + $hasArchiveClass + $archiveTablePhpName + $archivedAtColumn + + + + + $objectClassName + + + + + $archiveTablePhpName + $archiveTableQueryName + + + + + $archiveTablePhpName + $usesAutoIncrement + $objectClassName + $columns + $columns + + + + + $isAddHooks + $queryClassName + $queryClassName + + + + + $objectClassName + $isArchiveOnInsert + $isArchiveOnUpdate + + + + + $archiveTablePhpName + $modelTableMap + + + + + $fk->isParentChild + + + + + $fieldName + $phpName + $fieldName + $phpName + $fieldName + $phpName + $fieldName + $childClassName + $phpName + $tablePhpName + $phpName + $phpName + $tablePhpName + $phpName + + + + + $columns + + + \Propel\Generator\Model\Column[] + + + + + $defaultLocale + $objectClassName + + + + + $defaultLocale + + + + + $i18nTablePhpName + $localeColumnName + + + + + $localeColumnName + + + + + $alias + $localeColumnName + + + + + $i18nTablePhpName + $defaultLocale + $i18nListVariable + $i18nListVariable + $localeColumnName + $i18nTablePhpName + $localeColumnName + $i18nQueryName + $i18nSetterMethod + + + + + $i18nQueryName + $objectClassName + + + + + $defaultLocale + $i18nQueryName + $i18nCollection + $localeColumnName + $i18nCollection + + + + + $localeColumnName + $defaultLocale + + + + + $objectClassName + $alias + $defaultLocale + $localeColumnName + + + + + $i18nTablePhpName + $defaultLocale + $localeColumnName + $i18nTablePhpName + + + + + $comment + $functionStatement + $columnPhpName + $params + + + + + $comment + $functionStatement + $columnPhpName + $params + + + + + $queryClass + $defaultLocale + $i18nRelationName + $i18nRelationName + $localeColumn + + + + + $defaultLocale + $i18nRelationName + $i18nRelationName + + + + + $queryClass + $defaultLocale + $i18nRelationName + $namespacedQueryClass + + + + + $defaultLocale + + + + + $objectClassName + $objectClassName + $objectClassName + $objectClassName + $useScope + $queryClassName + + + + + $objectClassName + $leftColumn + + + + + $tableName + $rankColumn + $useScope + $multiScope + $scope + + + + + $constraints + + + + + $hasForeignKeys + $aVarNames + $collVarNames + + + + + $versionTable->isVersionTable + + + + + $this + + + + + addTemporalAccessor + addObjectAccessor + addArrayAccessor + addHasArrayElement + addJsonAccessor + addEnumAccessor + addSetAccessor + addHasArrayElement + addDefaultAccessor + addBooleanAccessor + addDefaultAccessor + addLazyLoader + addObjectMutator + addLobMutator + addTemporalMutator + addArrayMutator + addAddArrayElement + addRemoveArrayElement + addJsonMutator + addEnumMutator + addSetMutator + addAddArrayElement + addRemoveArrayElement + addBooleanMutator + addDefaultMutator + + + + + $preSave + $hasBaseClass + $postSave + $hasBaseClass + $preInsert + $hasBaseClass + $postInsert + $hasBaseClass + $preUpdate + $hasBaseClass + $postUpdate + $hasBaseClass + $preDelete + $hasBaseClass + $postDelete + $hasBaseClass + + + + + $behaviorCallScript + + + + + $className + $className + $className + + + + + $tableName + $relatedClassNames + + + + + $className + $dbName + $tableName + $tablePhpName + $classPath + $nbColumns + $nbLazyLoadColumns + $nbHydrateColumns + $columns + $tableName + $stringFormat + + + + + $fieldNamesPhpName + $fieldNamesCamelCaseName + $fieldNamesColname + $fieldNamesFieldName + $fieldNamesNum + $fieldKeysPhpName + $fieldKeysCamelCaseName + $fieldKeysColname + $fieldKeysFieldName + $fieldKeysNum + + + + + $objectClassName + $objectClassName + $addInstancePoolKeySnippet + $objectClassName + $objectClassName + $removeInstancePoolKeySnippetObjects + $countPks + $removeInstancePoolKeySnippetPks + $objectClassName + + + + + 'startElement' + 'endElement' + + + + + $key[0] + $param[0] + + + + + Symfony23DialogHelper + + + + + writeSection + writeBlock + + + + + $helper + + + \Propel\Generator\Command\Helper\ConsoleHelperInterface + + + ConsoleHelper + + + $e + + + + + $schemaDir + $phpDir + $rdbms + $dsn + $user + $charset + + + + + $rdbms + $dsn + $user + $password + $charset + + + + + $schemaDir + $phpDir + + + + + $rdbms + $dsn + $user + $password + $charset + + + + + $schemaDir + $phpDir + $rdbms + $dsn + $user + $charset + + + + + $rdbms + $dsn + $user + $password + $charset + + + + + $schemaDir + $phpDir + $rdbms + $dsn + $user + $charset + + + + + $rdbms + $dsn + $user + $password + $charset + + + + + $schemaDir + $phpDir + $rdbms + $dsn + $user + $charset + + + + + $rdbms + $dsn + $user + $password + $charset + + + + + $rdbms + $namespace + $schemaDir + + + + + XsltProcessor + $xsl + $xsl + + + getLocation + + + + + $migrationTimestamps + + + int[] + + + + + [ $name, $phpNamingMethod, $namePrefix ] + + + + + $columns + + + \Propel\Generator\Model\Column[] + + + + + $this->columnObjects + + + + + [ $name, $this->phpNamingMethod ] + + + $pks + + + \Propel\Generator\Model\Column[] + + + isEarly + + + + + $column->getDefaultValue() + + + + + $row[0] + + + + + null + + + T_NAME_FULLY_QUALIFIED + T_NAME_QUALIFIED + + + + + static::getShortName($this->modelName) + find + + + + + $joinClause + + + $this->conditionalProxy->getCriteriaOrProxy() + + + $this|\Propel\Runtime\ActiveQuery\Criteria + + + null + + + + + new $secondaryCriteriaClass() + $tableMap::addSelectColumns($this, $this->useAliasInSQL ? $this->modelAlias : null) + + + getTableMap + getTableMap + getTableMap + getRelationMap + addSelfSelectColumns + addSelectColumns + getTableMap + getTableMap + getTableMap + setIgnoreCase + + + + + $dataFetcher->fetchColumn() + + + + + $dataFetcher->fetchColumn() + + + + + PDO::SQLSRV_ATTR_ENCODING + PDO::SQLSRV_ENCODING_UTF8 + PDO::SQLSRV_ATTR_ENCODING + PDO::SQLSRV_ENCODING_SYSTEM + PDO::SQLSRV_ENCODING_BINARY + + + + + $cmp_function + $cmp_function + + + + + $this->statement->fetchColumn($columnIndex) + + + string|null + + + + + $tableMap::getPrimaryKeyHashFromRow($row, 0, $this->getDataFetcher()->getIndexType()) + + + $tableMap::getPrimaryKeyHashFromRow($row, 0, $this->getDataFetcher()->getIndexType()) + + + + + populateObject + populateObject + + + + + new $class() + + + + + $this->foreignColumns + + + \Propel\Runtime\Map\ColumnMap[] + + + + + self::LOG_ALERT + self::LOG_INFO + + + + + $this->results + + + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000000..26fe338948 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + From f5c9293dbabf56f60950a6aef9e5d7715e132934 Mon Sep 17 00:00:00 2001 From: Bezpiatov Date: Tue, 3 Nov 2020 11:08:17 +0200 Subject: [PATCH 180/208] PHP8 CS fix --- src/Propel/Runtime/Connection/ConnectionWrapper.php | 12 ++++++------ .../Runtime/Connection/ProfilerConnectionWrapper.php | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index 204155df50..f28cd7d434 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -407,15 +407,15 @@ public function prepare(string $statement, array $driverOptions = []) } /** - * @inehritDoc + * @inheritDoc */ - public function exec($sql) + public function exec($statement) { - $return = $this->connection->exec($sql); + $return = $this->connection->exec($statement); if ($this->useDebug) { - $this->log($sql); - $this->setLastExecutedQuery($sql); + $this->log($statement); + $this->setLastExecutedQuery($statement); $this->incrementQueryCount(); } @@ -433,7 +433,7 @@ public function exec($sql) * @param string $statement The SQL statement to prepare and execute. * Data inside the query should be properly escaped. * - * @return \PDOStatement + * @return \Propel\Runtime\DataFetcher\DataFetcherInterface */ public function query($statement) { diff --git a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php index 335dd50030..da38b912b5 100644 --- a/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ProfilerConnectionWrapper.php @@ -92,11 +92,11 @@ public function prepare(string $statement, array $driverOptions = []) /** * @inheritDoc */ - public function exec($sql) + public function exec($statement) { $this->getProfiler()->start(); - return parent::exec($sql); + return parent::exec($statement); } /** From 409bfe2012ebd3d0fa06827173cecea372c9df0f Mon Sep 17 00:00:00 2001 From: Dirk Nederveen Date: Tue, 3 Nov 2020 15:14:41 +0100 Subject: [PATCH 181/208] Add null-typehint for nullable property accessors/mutators --- .../Generator/Builder/Om/ObjectBuilder.php | 43 ++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index 7a9bcfe7b1..e4c48d3975 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -501,6 +501,8 @@ protected function addColumnAttributeComment(&$script, Column $column) } $clo = $column->getLowercasedName(); + $orNull = $column->isNotNull() ? '' : '|null'; + $script .= " /** * The value for the $clo field. @@ -515,7 +517,7 @@ protected function addColumnAttributeComment(&$script, Column $column) } } $script .= " - * @var $cptype + * @var $cptype{$orNull} */"; } @@ -879,6 +881,8 @@ public function addTemporalAccessorComment(&$script, Column $column) // 00:00:00 is a valid time, so no need to check for that. } + $orNull = $column->isNotNull() ? '' : '|null'; + $script .= " /** * Get the [optionally formatted] temporal [$clo] column value. @@ -887,7 +891,7 @@ public function addTemporalAccessorComment(&$script, Column $column) * @param string|null \$format The date/time format string (either date()-style or strftime()-style). * If format is NULL, then the raw $dateTimeClass object will be returned. * - * @return string|$dateTimeClass Formatted date/time value as string or $dateTimeClass object (if format is NULL), NULL if column is NULL" . ($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : '') . " + * @return string|{$dateTimeClass}{$orNull} Formatted date/time value as string or $dateTimeClass object (if format is NULL), NULL if column is NULL" . ($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : '') . " * * @throws PropelException - if unable to parse/validate the date/time value. */"; @@ -1086,6 +1090,8 @@ public function addJsonAccessorComment(&$script, Column $column) { $clo = $column->getLowercasedName(); + $orNull = $column->isNotNull() ? '' : '|null'; + $script .= " /** * Get the [$clo] column value. @@ -1097,7 +1103,7 @@ public function addJsonAccessorComment(&$script, Column $column) * @param ConnectionInterface \$con An optional ConnectionInterface connection to use for fetching this lazy-loaded column."; } $script .= " - * @return object + * @return object|array{$orNull} */"; } @@ -1292,6 +1298,8 @@ public function addEnumAccessorComment(&$script, Column $column) { $clo = $column->getLowercasedName(); + $orNull = $column->isNotNull() ? '' : '|null'; + $script .= " /** * Get the [$clo] column value. @@ -1301,7 +1309,7 @@ public function addEnumAccessorComment(&$script, Column $column) * @param ConnectionInterface An optional ConnectionInterface connection to use for fetching this lazy-loaded column."; } $script .= " - * @return string + * @return string{$orNull} * @throws \\Propel\\Runtime\\Exception\\PropelException */"; } @@ -1483,6 +1491,8 @@ public function addDefaultAccessorComment(&$script, Column $column) { $clo = $column->getLowercasedName(); + $orNull = $column->isNotNull() ? '' : '|null'; + $script .= " /** * Get the [$clo] column value. @@ -1492,7 +1502,7 @@ public function addDefaultAccessorComment(&$script, Column $column) * @param ConnectionInterface \$con An optional ConnectionInterface connection to use for fetching this lazy-loaded column."; } $script .= " - * @return " . ($column->getTypeHint() ?: ($column->getPhpType() ?: 'mixed')) . " + * @return " . ($column->getTypeHint() ?: ($column->getPhpType() ?: 'mixed')) . $orNull . " */"; } @@ -1738,11 +1748,14 @@ protected function addJsonMutatorOpen(&$script, Column $column) public function addJsonMutatorComment(&$script, Column $column) { $clo = $column->getLowercasedName(); + + $orNull = $column->isNotNull() ? '' : '|null'; + $script .= " /** * Set the value of [$clo] column. * " . $column->getDescription() . " - * @param string|array|object \$v new value + * @param string|array|object{$orNull} \$v new value * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) */"; } @@ -2026,11 +2039,13 @@ public function addTemporalMutatorComment(&$script, Column $col) { $clo = $col->getLowercasedName(); + $orNull = $col->isNotNull() ? '' : '|null'; + $script .= " /** * Sets the value of [$clo] column to a normalized version of the date/time value specified. * " . $col->getDescription() . " - * @param mixed \$v string, integer (timestamp), or \DateTimeInterface value. + * @param string|integer|\DateTimeInterface{$orNull} \$v string, integer (timestamp), or \DateTimeInterface value. * Empty strings are treated as NULL. * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) */"; @@ -2264,11 +2279,14 @@ protected function addEnumMutator(&$script, Column $col) public function addEnumMutatorComment(&$script, Column $column) { $clo = $column->getLowercasedName(); + + $orNull = $column->isNotNull() ? '' : '|null'; + $script .= " /** * Set the value of [$clo] column. * " . $column->getDescription() . " - * @param string \$v new value + * @param string{$orNull} \$v new value * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) * @throws \\Propel\\Runtime\\Exception\\PropelException */"; @@ -2326,11 +2344,14 @@ protected function addSetMutator(&$script, Column $col) public function addSetMutatorComment(&$script, Column $column) { $clo = $column->getLowercasedName(); + + $orNull = $column->isNotNull() ? '' : '|null'; + $script .= " /** * Set the value of [$clo] column. * " . $column->getDescription() . " - * @param array \$v new value + * @param array{$orNull} \$v new value * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) * @throws \\Propel\\Runtime\\Exception\\PropelException */"; @@ -2381,6 +2402,8 @@ public function addBooleanMutatorComment(&$script, Column $col) { $clo = $col->getLowercasedName(); + $orNull = $col->isNotNull() ? '' : '|null'; + $script .= " /** * Sets the value of the [$clo] column. @@ -2389,7 +2412,7 @@ public function addBooleanMutatorComment(&$script, Column $col) * * 0, '0', 'false', 'off', and 'no' are converted to boolean false * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). * " . $col->getDescription() . " - * @param boolean|integer|string \$v The new value + * @param boolean|integer|string{$orNull} \$v The new value * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) */"; } From f0802baeb2164c290e35217989ee9b65f3af0907 Mon Sep 17 00:00:00 2001 From: Dirk Nederveen Date: Tue, 3 Nov 2020 15:41:29 +0100 Subject: [PATCH 182/208] Nullable related object --- src/Propel/Generator/Builder/Om/ObjectBuilder.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Propel/Generator/Builder/Om/ObjectBuilder.php b/src/Propel/Generator/Builder/Om/ObjectBuilder.php index e4c48d3975..65ef45f0c7 100644 --- a/src/Propel/Generator/Builder/Om/ObjectBuilder.php +++ b/src/Propel/Generator/Builder/Om/ObjectBuilder.php @@ -4105,11 +4105,13 @@ protected function addFKMutator(&$script, ForeignKey $fk) $varName = $this->getFKVarName($fk); + $orNull = $fk->getLocalColumn()->isNotNull() ? '' : '|null'; + $script .= " /** * Declares an association between this object and a $className object. * - * @param $className \$v + * @param {$className}{$orNull} \$v * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support) * @throws PropelException */ @@ -4231,13 +4233,15 @@ protected function addFKAccessor(&$script, ForeignKey $fk) $localColumns = count($localColumns) > 1 ? ('array(' . implode(', ', $localColumns) . ')') : reset($localColumns); + $orNull = $fk->getLocalColumn()->isNotNull() ? '' : '|null'; + $script .= " /** * Get the associated $className object * * @param ConnectionInterface \$con Optional Connection object. - * @return $className $returnDesc + * @return {$className}{$orNull} $returnDesc * @throws PropelException */ public function get" . $this->getFKPhpNameAffix($fk, false) . "(ConnectionInterface \$con = null) From d04d9d032cbb9c10bf5470173985ac960ea02fe1 Mon Sep 17 00:00:00 2001 From: Dirk Nederveen Date: Thu, 5 Nov 2020 13:14:27 +0100 Subject: [PATCH 183/208] Remove dead code This dead section was correctly identified by PHPstan: empty `$stringValue` arguments would have been handled by the section in line 148-150, and `explode` with any string value will always return an array with at least one element. Minimal example: ```php php > var_dump(explode(',', '')); array(1) { [0]=> string(0) "" } ``` --- src/Propel/Generator/Model/MappingModel.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Propel/Generator/Model/MappingModel.php b/src/Propel/Generator/Model/MappingModel.php index 308c9396a0..fc597523dd 100644 --- a/src/Propel/Generator/Model/MappingModel.php +++ b/src/Propel/Generator/Model/MappingModel.php @@ -153,9 +153,6 @@ protected function getDefaultValueForSet($stringValue) foreach (explode(',', $stringValue) as $v) { $values[] = trim($v); } - if (count($values) === 0) { - return null; - } return $values; } From 81b6cbe612bb73a34494e0680626dcf1510fd3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C3=B3jcik?= Date: Mon, 12 Oct 2020 20:34:16 +0200 Subject: [PATCH 184/208] Read locks (SELECT ... [FOR SHARE | FOR UPDATE]) --- phpstan-baseline.neon | 5 + src/Propel/Runtime/ActiveQuery/Criteria.php | 96 +++++++++++++++ src/Propel/Runtime/ActiveQuery/Lock.php | 114 ++++++++++++++++++ .../Runtime/Adapter/Pdo/MssqlAdapter.php | 13 ++ .../Runtime/Adapter/Pdo/MysqlAdapter.php | 20 +++ .../Runtime/Adapter/Pdo/OracleAdapter.php | 20 +++ .../Runtime/Adapter/Pdo/PgsqlAdapter.php | 30 +++++ .../Runtime/Adapter/Pdo/SqliteAdapter.php | 13 ++ .../Runtime/Adapter/SqlAdapterInterface.php | 11 ++ .../Runtime/ActiveQuery/CriteriaTest.php | 41 +++++++ .../Runtime/Adapter/Pdo/MysqlAdapterTest.php | 74 ++++++++++++ .../Runtime/Adapter/Pdo/OracleAdapterTest.php | 47 ++++++++ .../Runtime/Adapter/Pdo/PgsqlAdapterTest.php | 78 +++++++++++- 13 files changed, 560 insertions(+), 2 deletions(-) create mode 100644 src/Propel/Runtime/ActiveQuery/Lock.php diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d0eb6672e3..c3e6558878 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -450,6 +450,11 @@ parameters: count: 1 path: src/Propel/Runtime/ActiveQuery/Criteria.php + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:applyLock\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/Criteria.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:bindValues\\(\\)\\.$#" count: 3 diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index be98e9aff2..bedffb2884 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -143,6 +143,13 @@ class Criteria */ protected $selectModifiers = []; + /** + * Lock to be used to retrieve rows (if any). + * + * @var \Propel\Runtime\ActiveQuery\Lock|null + */ + protected $lock; + /** * Storage of conditions data. Collection of Criterion objects. * @@ -306,6 +313,7 @@ public function clear() $this->ignoreCase = false; $this->singleRecord = false; $this->selectModifiers = []; + $this->lock = null; $this->selectColumns = []; $this->orderByColumns = []; $this->groupByColumns = []; @@ -1247,6 +1255,75 @@ public function hasSelectModifier($modifier) return in_array($modifier, $this->selectModifiers); } + /** + * @return \Propel\Runtime\ActiveQuery\Lock|null Get read lock value. + */ + public function getLock(): ?Lock + { + return $this->lock; + } + + /** + * Apply a shared read lock to be used to retrieve rows. + * + * @param string[] $tableNames + * @param bool $noWait + * + * @return $this Modified Criteria object (for fluent API) + */ + public function lockForShare(array $tableNames = [], bool $noWait = false) + { + $this->withLock(Lock::SHARED, $tableNames, $noWait); + + return $this; + } + + /** + * Apply an exclusive read lock to be used to retrieve rows. + * + * @param string[] $tableNames + * @param bool $noWait + * + * @return $this Modified Criteria object (for fluent API) + */ + public function lockForUpdate(array $tableNames = [], bool $noWait = false) + { + $this->withLock(Lock::EXCLUSIVE, $tableNames, $noWait); + + return $this; + } + + /** + * Apply a read lock to be used to retrieve rows. + * + * @see Lock::SHARED + * @see Lock::EXCLUSIVE + * + * @param string $lockType + * @param string[] $tableNames + * @param bool $noWait + * + * @return $this Modified Criteria object (for fluent API) + */ + protected function withLock(string $lockType, array $tableNames = [], bool $noWait = false) + { + $this->lock = new Lock($lockType, $tableNames, $noWait); + + return $this; + } + + /** + * Retrieve rows without any read locking. + * + * @return $this Modified Criteria object (for fluent API) + */ + public function withoutLock() + { + $this->lock = null; + + return $this; + } + /** * Sets ignore case. * @@ -1646,6 +1723,15 @@ public function equals($crit) } } + $aLock = $this->lock; + $bLock = $criteria->getLock(); + if ($aLock instanceof Lock && !$aLock->equals($bLock)) { + return false; + } + if ($bLock instanceof Lock && !$bLock->equals($aLock)) { + return false; + } + return true; } else { return false; @@ -1688,6 +1774,12 @@ public function mergeWith(Criteria $criteria, $operator = null) $this->selectModifiers = $selectModifiers; } + // merge lock + $lock = $criteria->getLock(); + if ($lock && !$this->lock) { + $this->lock = $lock; + } + // merge select columns $this->selectColumns = array_merge($this->getSelectColumns(), $criteria->getSelectColumns()); @@ -2114,6 +2206,10 @@ public function createSelectSql(&$params) $adapter->applyLimit($sql, $this->getOffset(), $this->getLimit(), $this); } + if (null !== $this->lock) { + $adapter->applyLock($sql, $this->lock); + } + return $sql; } diff --git a/src/Propel/Runtime/ActiveQuery/Lock.php b/src/Propel/Runtime/ActiveQuery/Lock.php new file mode 100644 index 0000000000..b05cc5b280 --- /dev/null +++ b/src/Propel/Runtime/ActiveQuery/Lock.php @@ -0,0 +1,114 @@ + + */ +class Lock +{ + public const SHARED = 'SHARED'; + + public const EXCLUSIVE = 'EXCLUSIVE'; + + /** + * Lock type, either shared or exclusive + * + * @see self::SHARED + * @see self::EXCLUSIVE + * + * @var string + */ + protected $type; + + /** + * Table names to lock + * + * @var string[] + */ + protected $tableNames; + + /** + * Whether to issue a non-blocking lock + * + * @var bool + */ + protected $noWait; + + /** + * @param string $type Lock type + * @param array $tableNames Table names to lock + * @param bool $noWait Whether to issue a non-blocking lock + */ + public function __construct(string $type, array $tableNames = [], bool $noWait = false) + { + $this->type = $type; + $this->tableNames = $tableNames; + $this->noWait = $noWait; + } + + /** + * Lock type + * + * @see self::SHARED + * @see self::EXCLUSIVE + * + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * Returns table names to lock + * + * @return string[] + */ + public function getTableNames(): array + { + return $this->tableNames; + } + + /** + * Whether to issue a non-blocking lock + * + * @return bool + */ + public function isNoWait(): bool + { + return $this->noWait; + } + + /** + * Checks whether a lock equals another lock object + * + * @param \Propel\Runtime\ActiveQuery\Lock|mixed $lock + * + * @return bool + */ + public function equals($lock): bool + { + if (!($lock instanceof self)) { + return false; + } + + $aTableNames = $this->getTableNames(); + $bTableNames = $lock->getTableNames(); + + return $this->getType() === $lock->getType() + && $this->isNoWait() === $lock->isNoWait() + && $aTableNames === array_intersect($aTableNames, $bTableNames) + && $bTableNames === array_intersect($bTableNames, $aTableNames); + } +} diff --git a/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php index d78a2a4daf..02fb21976f 100644 --- a/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php @@ -9,6 +9,7 @@ namespace Propel\Runtime\Adapter\Pdo; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\ActiveQuery\Lock; use Propel\Runtime\Adapter\Exception\ColumnNotFoundException; use Propel\Runtime\Adapter\Exception\MalformedClauseException; use Propel\Runtime\Adapter\SqlAdapterInterface; @@ -328,4 +329,16 @@ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap } } } + + /** + * @see AdapterInterface::applyLock() + * + * @param string $sql + * @param \Propel\Runtime\ActiveQuery\Lock $lock + * + * @return void + */ + public function applyLock(&$sql, Lock $lock): void + { + } } diff --git a/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php index 315890c103..85a6a2356a 100644 --- a/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php @@ -9,6 +9,7 @@ namespace Propel\Runtime\Adapter\Pdo; use PDO; +use Propel\Runtime\ActiveQuery\Lock; use Propel\Runtime\Adapter\SqlAdapterInterface; use Propel\Runtime\Connection\StatementInterface; use Propel\Runtime\Map\ColumnMap; @@ -201,4 +202,23 @@ protected function prepareParams($params) return parent::prepareParams($params); } + + /** + * @see AdapterInterface::applyLock() + * + * @param string $sql + * @param \Propel\Runtime\ActiveQuery\Lock $lock + * + * @return void + */ + public function applyLock(&$sql, Lock $lock): void + { + $type = $lock->getType(); + + if (Lock::SHARED === $type) { + $sql .= ' LOCK IN SHARE MODE'; + } elseif (Lock::EXCLUSIVE === $type) { + $sql .= ' FOR UPDATE'; + } + } } diff --git a/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php b/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php index c77a8a8a1b..ed5dbda302 100644 --- a/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php @@ -10,6 +10,7 @@ use Propel\Generator\Model\PropelTypes; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\ActiveQuery\Lock; use Propel\Runtime\Adapter\AdapterInterface; use Propel\Runtime\Adapter\SqlAdapterInterface; use Propel\Runtime\Connection\ConnectionInterface; @@ -253,4 +254,23 @@ protected function prepareParams($params) return parent::prepareParams($params); } + + /** + * @see AdapterInterface::applyLock() + * + * @param string $sql + * @param \Propel\Runtime\ActiveQuery\Lock $lock + * + * @return void + */ + public function applyLock(&$sql, Lock $lock): void + { + $type = $lock->getType(); + + if (Lock::SHARED === $type) { + $sql .= ' LOCK IN SHARE MODE'; + } elseif (Lock::EXCLUSIVE === $type) { + $sql .= ' FOR UPDATE'; + } + } } diff --git a/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php index 883d3f011d..d72d5e4b3f 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php @@ -9,6 +9,7 @@ namespace Propel\Runtime\Adapter\Pdo; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\ActiveQuery\Lock; use Propel\Runtime\Adapter\AdapterInterface; use Propel\Runtime\Adapter\SqlAdapterInterface; use Propel\Runtime\Connection\ConnectionInterface; @@ -263,4 +264,33 @@ public function getExplainPlanQuery($query) { return 'EXPLAIN ' . $query; } + + /** + * @see AdapterInterface::applyLock() + * + * @param string $sql + * @param \Propel\Runtime\ActiveQuery\Lock $lock + * + * @return void + */ + public function applyLock(&$sql, Lock $lock): void + { + $type = $lock->getType(); + + if (Lock::SHARED === $type) { + $sql .= ' FOR SHARE'; + } elseif (Lock::EXCLUSIVE === $type) { + $sql .= ' FOR UPDATE'; + } + + $tableNames = $lock->getTableNames(); + if (!empty($tableNames)) { + $tableNames = array_map([$this, 'quoteIdentifier'], array_unique($tableNames)); + $sql .= ' OF ' . implode(', ', $tableNames); + } + + if ($lock->isNoWait()) { + $sql .= ' NOWAIT'; + } + } } diff --git a/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php b/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php index ce53e98a64..9858196956 100644 --- a/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php @@ -8,6 +8,7 @@ namespace Propel\Runtime\Adapter\Pdo; +use Propel\Runtime\ActiveQuery\Lock; use Propel\Runtime\Adapter\SqlAdapterInterface; use Propel\Runtime\Connection\ConnectionInterface; @@ -128,4 +129,16 @@ public function random($seed = null) { return 'random()'; } + + /** + * @see AdapterInterface::applyLock() + * + * @param string $sql + * @param \Propel\Runtime\ActiveQuery\Lock $lock + * + * @return void + */ + public function applyLock(&$sql, Lock $lock): void + { + } } diff --git a/src/Propel/Runtime/Adapter/SqlAdapterInterface.php b/src/Propel/Runtime/Adapter/SqlAdapterInterface.php index d652749fae..14f37b2308 100644 --- a/src/Propel/Runtime/Adapter/SqlAdapterInterface.php +++ b/src/Propel/Runtime/Adapter/SqlAdapterInterface.php @@ -9,6 +9,7 @@ namespace Propel\Runtime\Adapter; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\ActiveQuery\Lock; use Propel\Runtime\Connection\StatementInterface; use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\DatabaseMap; @@ -59,6 +60,16 @@ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap */ public function applyLimit(&$sql, $offset, $limit); + /** + * Modifies the passed-in SQL to add locking capabilities + * + * @param string $sql + * @param \Propel\Runtime\ActiveQuery\Lock $lock + * + * @return void + */ + public function applyLock(&$sql, Lock $lock): void; + /** * Gets the SQL string that this adapter uses for getting a random number. * diff --git a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaTest.php b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaTest.php index 47cd089bbe..d16ecce0bd 100644 --- a/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaTest.php +++ b/tests/Propel/Tests/Runtime/ActiveQuery/CriteriaTest.php @@ -11,6 +11,7 @@ use PDO; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Join; +use Propel\Runtime\ActiveQuery\Lock; use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\Adapter\Pdo\MysqlAdapter; use Propel\Runtime\Adapter\Pdo\PgsqlAdapter; @@ -1114,6 +1115,44 @@ public function testAddSelectModifier() $this->assertEquals('SELECT DISTINCT SQL_CALC_FOUND_ROWS FROM ', $result, 'addSelectModifier() adds a modifier to the final query'); } + /** + * @return void + */ + public function testWithSimpleLock() + { + $c = new Criteria(); + $c->lockForShare(); + $this->assertInstanceOf(Lock::class, $c->getLock(), 'lockForShare() adds a shared read lock to the Criteria'); + $this->assertSame(Lock::SHARED, $c->getLock()->getType()); + $this->assertEmpty($c->getLock()->getTableNames()); + $this->assertFalse($c->getLock()->isNoWait()); + } + + /** + * @return void + */ + public function testWithComplexLock() + { + $c = new Criteria(); + $c->lockForUpdate(['tableA', 'tableB'], true); + $this->assertInstanceOf(Lock::class, $c->getLock(), 'lockForUpdate() adds an exclusive read lock to the Criteria'); + $this->assertSame(Lock::EXCLUSIVE, $c->getLock()->getType()); + $this->assertSame(['tableA', 'tableB'], $c->getLock()->getTableNames()); + $this->assertTrue($c->getLock()->isNoWait()); + } + + /** + * @return void + */ + public function testWithoutLock() + { + $c = new Criteria(); + $c->lockForShare(); + $this->assertInstanceOf(Lock::class, $c->getLock(), 'lockForShare() adds a shared read lock to the Criteria'); + $c->withoutLock(); + $this->assertNull($c->getLock(), 'withoutLock() removes read lock from the Criteria'); + } + /** * @return void */ @@ -1192,6 +1231,8 @@ public function testClear() $this->assertEquals(0, count($c->getAliases()), 'aliases is empty by default'); $this->assertFalse($c->getUseTransaction(), 'useTransaction is false by default'); + + $this->assertNull($c->getLock(), 'lock is null by default'); } /** diff --git a/tests/Propel/Tests/Runtime/Adapter/Pdo/MysqlAdapterTest.php b/tests/Propel/Tests/Runtime/Adapter/Pdo/MysqlAdapterTest.php index 637cf3a21d..424057fae3 100644 --- a/tests/Propel/Tests/Runtime/Adapter/Pdo/MysqlAdapterTest.php +++ b/tests/Propel/Tests/Runtime/Adapter/Pdo/MysqlAdapterTest.php @@ -9,6 +9,8 @@ namespace Propel\Tests\Runtime\Adapter\Pdo; use Propel\Runtime\Adapter\Pdo\MysqlAdapter; +use Propel\Tests\Bookstore\BookQuery; +use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\TestCaseFixtures; /** @@ -36,6 +38,14 @@ public static function getConParams() ]; } + /** + * @return string + */ + protected function getDriver() + { + return 'mysql'; + } + /** * @dataProvider getConParams * @@ -95,6 +105,70 @@ protected function getPdoMock() return $con; } + + /** + * Test `applyLock` + * + * @return void + * + * @group mysql + */ + public function testSimpleLock(): void + { + $c = new BookQuery(); + $c->addSelectColumn(BookTableMap::COL_ID); + $c->lockForShare(); + + $params = []; + $result = $c->createSelectSql($params); + + $expected = 'SELECT book.id FROM book LOCK IN SHARE MODE'; + + $this->assertEquals($expected, $result); + } + + /** + * Test `applyLock` + * + * @return void + * + * @group mysql + */ + public function testComplexLock(): void + { + $c = new BookQuery(); + $c->addSelectColumn(BookTableMap::COL_ID); + $c->lockForUpdate([BookTableMap::TABLE_NAME], true); + + $params = []; + $result = $c->createSelectSql($params); + + $expected = 'SELECT book.id FROM book FOR UPDATE'; + + $this->assertEquals($expected, $result); + } + + /** + * @return void + * + * @group mysql + */ + public function testSubQueryWithSharedLock() + { + $subCriteria = new BookQuery(); + $subCriteria->addSelectColumn(BookTableMap::COL_ID); + $subCriteria->lockForShare([BookTableMap::TABLE_NAME]); + + $c = new BookQuery(); + $c->addSelectColumn(BookTableMap::COL_ID); + $c->addSelectQuery($subCriteria, 'subCriteriaAlias', false); + $c->lockForShare([BookTableMap::TABLE_NAME], true); + + $expected ='SELECT subCriteriaAlias.id FROM (SELECT book.id FROM book LOCK IN SHARE MODE) AS subCriteriaAlias LOCK IN SHARE MODE'; + + $params = []; + $this->assertSame($expected, $c->createSelectSql($params), 'Subquery contains shared read lock'); + } } class TestableMysqlAdapter extends MysqlAdapter diff --git a/tests/Propel/Tests/Runtime/Adapter/Pdo/OracleAdapterTest.php b/tests/Propel/Tests/Runtime/Adapter/Pdo/OracleAdapterTest.php index f674e0e31b..b671129162 100644 --- a/tests/Propel/Tests/Runtime/Adapter/Pdo/OracleAdapterTest.php +++ b/tests/Propel/Tests/Runtime/Adapter/Pdo/OracleAdapterTest.php @@ -11,6 +11,7 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Adapter\Pdo\OracleAdapter; use Propel\Runtime\Propel; +use Propel\Tests\Bookstore\BookQuery; use Propel\Tests\Bookstore\Map\AuthorTableMap; use Propel\Tests\Bookstore\Map\BookTableMap; use Propel\Tests\TestCaseFixtures; @@ -23,6 +24,14 @@ */ class OracleAdapterTest extends TestCaseFixtures { + /** + * @return string + */ + protected function getDriver() + { + return 'oracle'; + } + /** * @return void */ @@ -88,4 +97,42 @@ public function testCreateSelectSqlPart() $this->assertEquals('SELECT book.id, book.id AS book_ID', $selectSql, 'createSelectSqlPart() returns a SQL SELECT clause with both select and as columns'); $this->assertEquals(['book'], $fromClause, 'createSelectSqlPart() adds the tables from the select columns to the from clause'); } + + /** + * Test `applyLock` + * + * @return void + */ + public function testSimpleLock(): void + { + $c = new BookQuery(); + $c->addSelectColumn(BookTableMap::COL_ID); + $c->lockForShare(); + + $params = []; + $result = $c->createSelectSql($params); + + $expected = 'SELECT book.id FROM book LOCK IN SHARE MODE'; + + $this->assertEquals($expected, $result); + } + + /** + * Test `applyLock` + * + * @return void + */ + public function testComplexLock(): void + { + $c = new BookQuery(); + $c->addSelectColumn(BookTableMap::COL_ID); + $c->lockForUpdate([BookTableMap::TABLE_NAME], true); + + $params = []; + $result = $c->createSelectSql($params); + + $expected = 'SELECT book.id FROM book FOR UPDATE'; + + $this->assertEquals($expected, $result); + } } diff --git a/tests/Propel/Tests/Runtime/Adapter/Pdo/PgsqlAdapterTest.php b/tests/Propel/Tests/Runtime/Adapter/Pdo/PgsqlAdapterTest.php index dfce6a1600..e04eab2471 100644 --- a/tests/Propel/Tests/Runtime/Adapter/Pdo/PgsqlAdapterTest.php +++ b/tests/Propel/Tests/Runtime/Adapter/Pdo/PgsqlAdapterTest.php @@ -9,15 +9,25 @@ namespace Propel\Tests\Runtime\Adapter\Pdo; use Propel\Runtime\Adapter\Pdo\PgsqlAdapter; -use Propel\Tests\TestCase; +use Propel\Tests\Bookstore\BookQuery; +use Propel\Tests\Bookstore\Map\BookTableMap; +use Propel\Tests\TestCaseFixtures; /** * Tests the Pgsql adapter * * @author Kévin Gomez */ -class PgsqlAdapterTest extends TestCase +class PgsqlAdapterTest extends TestCaseFixtures { + /** + * @return string + */ + protected function getDriver() + { + return 'pgsql'; + } + /** * @return void */ @@ -29,4 +39,68 @@ public function testGetExplainPlanQuery() $this->assertEquals($expected, $db->getExplainPlanQuery($query), 'getExplainPlanQuery() returns a SQL Explain query'); } + + /** + * Test `applyLock` + * + * @return void + * + * @group pgsql + */ + public function testSimpleLock(): void + { + $c = new BookQuery(); + $c->addSelectColumn(BookTableMap::COL_ID); + $c->lockForShare(); + + $params = []; + $result = $c->createSelectSql($params); + + $expected = 'SELECT book.id FROM book FOR SHARE'; + + $this->assertEquals($expected, $result); + } + + /** + * Test `applyLock` + * + * @return void + * + * @group pgsql + */ + public function testComplexLock(): void + { + $c = new BookQuery(); + $c->addSelectColumn(BookTableMap::COL_ID); + $c->lockForUpdate([BookTableMap::TABLE_NAME], true); + + $params = []; + $result = $c->createSelectSql($params); + + $expected = 'SELECT book.id FROM book FOR UPDATE OF "book" NOWAIT'; + + $this->assertEquals($expected, $result); + } + + /** + * @return void + * + * @group pgsql + */ + public function testSubQueryWithSharedLock() + { + $subCriteria = new BookQuery(); + $subCriteria->addSelectColumn(BookTableMap::COL_ID); + $subCriteria->lockForShare([BookTableMap::TABLE_NAME]); + + $c = new BookQuery(); + $c->addSelectColumn(BookTableMap::COL_ID); + $c->addSelectQuery($subCriteria, 'subCriteriaAlias', false); + $c->lockForShare([BookTableMap::TABLE_NAME], true); + + $expected ='SELECT subCriteriaAlias.id FROM (SELECT book.id FROM book FOR SHARE of "book") AS subCriteriaAlias FOR SHARE OF "book" NOWAIT'; + + $params = []; + $this->assertSame($expected, $c->createSelectSql($params), 'Subquery contains shared read lock'); + } } From 087081146221f5b5c4afba24c11a6befc8a1af74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C3=B3jcik?= Date: Mon, 9 Nov 2020 22:26:51 +0100 Subject: [PATCH 185/208] PdoStatement::setFetchMode compatibility --- tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php b/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php index 5ec4b1fb8f..abf9f02257 100644 --- a/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php +++ b/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php @@ -106,6 +106,11 @@ public function testPdoSignature() $stmt = $con->prepare('SELECT author.FIRST_NAME, author.LAST_NAME FROM author'); $stmt->execute(); $stmt->fetchAll(); // should not throw exception + + $stmt = $con->prepare('SELECT author.FIRST_NAME, author.LAST_NAME FROM author'); + $stmt->execute(); + $stmt->setFetchMode(PDO::FETCH_ASSOC); // should not throw exception + $stmt->fetchAll(); } /** From 2660419e77932402fc767eec1dbe1a97c4340d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C3=B3jcik?= Date: Mon, 9 Nov 2020 23:34:54 +0100 Subject: [PATCH 186/208] Fix --- src/Propel/Runtime/Connection/StatementWrapper.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Propel/Runtime/Connection/StatementWrapper.php b/src/Propel/Runtime/Connection/StatementWrapper.php index 269605417c..8cbdeb1592 100644 --- a/src/Propel/Runtime/Connection/StatementWrapper.php +++ b/src/Propel/Runtime/Connection/StatementWrapper.php @@ -405,7 +405,16 @@ public function getColumnMeta($column) */ public function setFetchMode($mode, $classNameObject = null, array $ctorarfg = []) { - return $this->statement->setFetchMode($mode, $classNameObject, $ctorarfg); + switch (func_num_args()) { + case 1: + return $this->statement->setFetchMode($mode); + case 2: + return $this->statement->setFetchMode($mode, $classNameObject); + case 3: + return $this->statement->setFetchMode($mode, $classNameObject, $ctorarfg); + default: + return call_user_func_array([$this->statement, 'setFetchMode'], func_get_args()); + } } /** From 2a10fb03f33826092a5d5270db6a0dc24da5833d Mon Sep 17 00:00:00 2001 From: Dirk Nederveen Date: Fri, 27 Nov 2020 11:06:06 +0100 Subject: [PATCH 187/208] Update psalm-baseline.xml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Command and output: ``` $ vendor/bin/psalm.phar --update-baseline=psalm-baseline.xml Scanning files... Analyzing files... ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 60 / 342 (17%) ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 120 / 342 (35%) ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 180 / 342 (52%) ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 240 / 342 (70%) ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 300 / 342 (87%) ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ------------------------------ 3 errors fixed ERROR: UndefinedClass - src/Propel/Generator/Platform/SqlitePlatform.php:56:20 - Class or interface SQLite3 does not exist (see https://psalm.dev/019) $version = SQLite3::version(); ------------------------------ 1 errors found ------------------------------ 1540 other issues found. You can display them with --show-info=true ------------------------------ Psalm can automatically fix 76 of these issues. Run Psalm again with --alter --issues=InvalidNullableReturnType,InvalidReturnType,InvalidFalsableReturnType --dry-run to see what it can fix. ------------------------------ Checks took 3.36 seconds and used 328.892MB of memory Psalm was able to infer types for 93.0727% of the codebase ``` Note that the error about missing class SQLite3 is because I don't have ext-sqlite3 installed. It's also missing from `composer.json`. The `--update-baseline` command flag doesn't add any new errors, but only removes/reorders. To add error-ignores, the `--set-baseline=` flag should be used. --- psalm-baseline.xml | 255 ++++++++++++++++++++++----------------------- 1 file changed, 125 insertions(+), 130 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 93840e7a5a..972f2fce99 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + new TreeBuilder() @@ -7,10 +7,10 @@ + $bindings $column $column $sql - $bindings @@ -23,40 +23,40 @@ + $aggregateName + $aggregateName + $aggregateName + $aggregateName $relationName $relationName - $aggregateName - $variableName $relationName - $variableName - $updateMethodName $relationName - $aggregateName $relationName - $aggregateName - $updateMethodName $relationName - $aggregateName + $updateMethodName + $updateMethodName + $variableName + $variableName - $foreignTable - $relationName $aggregateName - $variableName $foreignQueryName + $foreignTable $refRelationName + $relationName + $variableName - $relationName $aggregateName + $relationName + $updateMethodName $variableName $variableName $variableName - $updateMethodName $variableName @@ -68,9 +68,9 @@ $archiveTablePhpName - $hasArchiveClass $archiveTablePhpName $archivedAtColumn + $hasArchiveClass @@ -87,10 +87,10 @@ $archiveTablePhpName - $usesAutoIncrement - $objectClassName $columns $columns + $objectClassName + $usesAutoIncrement @@ -102,9 +102,9 @@ - $objectClassName $isArchiveOnInsert $isArchiveOnUpdate + $objectClassName @@ -120,20 +120,20 @@ + $childClassName $fieldName - $phpName $fieldName - $phpName $fieldName - $phpName $fieldName - $childClassName $phpName - $tablePhpName $phpName $phpName - $tablePhpName $phpName + $phpName + $phpName + $phpName + $tablePhpName + $tablePhpName @@ -174,15 +174,15 @@ - $i18nTablePhpName $defaultLocale $i18nListVariable $i18nListVariable - $localeColumnName - $i18nTablePhpName - $localeColumnName $i18nQueryName $i18nSetterMethod + $i18nTablePhpName + $i18nTablePhpName + $localeColumnName + $localeColumnName @@ -194,57 +194,57 @@ $defaultLocale - $i18nQueryName $i18nCollection - $localeColumnName $i18nCollection + $i18nQueryName + $localeColumnName - $localeColumnName $defaultLocale + $localeColumnName - $objectClassName $alias $defaultLocale $localeColumnName + $objectClassName - $i18nTablePhpName $defaultLocale - $localeColumnName $i18nTablePhpName + $i18nTablePhpName + $localeColumnName + $columnPhpName $comment $functionStatement - $columnPhpName $params + $columnPhpName $comment $functionStatement - $columnPhpName $params - $queryClass $defaultLocale $i18nRelationName $i18nRelationName $localeColumn + $queryClass @@ -256,10 +256,10 @@ - $queryClass $defaultLocale $i18nRelationName $namespacedQueryClass + $queryClass @@ -273,23 +273,23 @@ $objectClassName $objectClassName $objectClassName - $useScope $queryClassName + $useScope - $objectClassName $leftColumn + $objectClassName - $tableName - $rankColumn - $useScope $multiScope + $rankColumn $scope + $tableName + $useScope @@ -299,9 +299,9 @@ - $hasForeignKeys $aVarNames $collVarNames + $hasForeignKeys @@ -316,51 +316,51 @@ - addTemporalAccessor - addObjectAccessor + addAddArrayElement + addAddArrayElement addArrayAccessor - addHasArrayElement - addJsonAccessor - addEnumAccessor - addSetAccessor - addHasArrayElement - addDefaultAccessor + addArrayMutator addBooleanAccessor + addBooleanMutator addDefaultAccessor + addDefaultAccessor + addDefaultMutator + addEnumAccessor + addEnumMutator + addHasArrayElement + addHasArrayElement + addJsonAccessor + addJsonMutator addLazyLoader - addObjectMutator addLobMutator - addTemporalMutator - addArrayMutator - addAddArrayElement + addObjectAccessor + addObjectMutator addRemoveArrayElement - addJsonMutator - addEnumMutator - addSetMutator - addAddArrayElement addRemoveArrayElement - addBooleanMutator - addDefaultMutator + addSetAccessor + addSetMutator + addTemporalAccessor + addTemporalMutator - $preSave $hasBaseClass - $postSave $hasBaseClass - $preInsert $hasBaseClass - $postInsert $hasBaseClass - $preUpdate $hasBaseClass - $postUpdate $hasBaseClass - $preDelete $hasBaseClass - $postDelete $hasBaseClass + $postDelete + $postInsert + $postSave + $postUpdate + $preDelete + $preInsert + $preSave + $preUpdate @@ -377,56 +377,56 @@ - $tableName $relatedClassNames + $tableName $className - $dbName - $tableName - $tablePhpName $classPath + $columns + $dbName $nbColumns - $nbLazyLoadColumns $nbHydrateColumns - $columns - $tableName + $nbLazyLoadColumns $stringFormat + $tableName + $tableName + $tablePhpName - $fieldNamesPhpName - $fieldNamesCamelCaseName - $fieldNamesColname - $fieldNamesFieldName - $fieldNamesNum - $fieldKeysPhpName $fieldKeysCamelCaseName $fieldKeysColname $fieldKeysFieldName $fieldKeysNum + $fieldKeysPhpName + $fieldNamesCamelCaseName + $fieldNamesColname + $fieldNamesFieldName + $fieldNamesNum + $fieldNamesPhpName + $addInstancePoolKeySnippet + $countPks + $objectClassName $objectClassName $objectClassName - $addInstancePoolKeySnippet $objectClassName $objectClassName $removeInstancePoolKeySnippetObjects - $countPks $removeInstancePoolKeySnippetPks - $objectClassName - 'startElement' 'endElement' + 'startElement' @@ -442,8 +442,8 @@ - writeSection writeBlock + writeSection @@ -462,108 +462,103 @@ - $schemaDir + $charset + $dsn $phpDir $rdbms - $dsn + $schemaDir $user - $charset - $rdbms + $charset $dsn - $user $password - $charset + $rdbms + $user - $schemaDir $phpDir + $schemaDir - $rdbms + $charset $dsn - $user $password - $charset + $rdbms + $user - $schemaDir + $charset + $dsn $phpDir $rdbms - $dsn + $schemaDir $user - $charset - $rdbms + $charset $dsn - $user $password - $charset + $rdbms + $user - $schemaDir + $charset + $dsn $phpDir $rdbms - $dsn + $schemaDir $user - $charset - $rdbms + $charset $dsn - $user $password - $charset + $rdbms + $user - $schemaDir + $charset + $dsn $phpDir $rdbms - $dsn + $schemaDir $user - $charset - $rdbms + $charset $dsn - $user $password - $charset + $rdbms + $user - $rdbms $namespace + $rdbms $schemaDir - - XsltProcessor - $xsl - $xsl - getLocation @@ -629,8 +624,8 @@ - static::getShortName($this->modelName) find + static::getShortName($this->modelName) @@ -649,16 +644,16 @@ - new $secondaryCriteriaClass() $tableMap::addSelectColumns($this, $this->useAliasInSQL ? $this->modelAlias : null) + new $secondaryCriteriaClass() + addSelectColumns + addSelfSelectColumns + getRelationMap getTableMap getTableMap getTableMap - getRelationMap - addSelfSelectColumns - addSelectColumns getTableMap getTableMap getTableMap @@ -678,10 +673,10 @@ PDO::SQLSRV_ATTR_ENCODING - PDO::SQLSRV_ENCODING_UTF8 PDO::SQLSRV_ATTR_ENCODING - PDO::SQLSRV_ENCODING_SYSTEM PDO::SQLSRV_ENCODING_BINARY + PDO::SQLSRV_ENCODING_SYSTEM + PDO::SQLSRV_ENCODING_UTF8 From 4ec5ee6abb206140fc76af0533258944a8af984f Mon Sep 17 00:00:00 2001 From: Brekeke Date: Tue, 1 Dec 2020 16:44:18 +0100 Subject: [PATCH 188/208] Update StatementInterface.php Using of fetch and fetchAll was not compatible with interface methods. Not sure about this issue, but my application just thrown error about incompatibility between interface declaration and implementation. --- src/Propel/Runtime/Connection/StatementInterface.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Propel/Runtime/Connection/StatementInterface.php b/src/Propel/Runtime/Connection/StatementInterface.php index 8a823b001e..1e36506131 100644 --- a/src/Propel/Runtime/Connection/StatementInterface.php +++ b/src/Propel/Runtime/Connection/StatementInterface.php @@ -38,7 +38,7 @@ public function execute($inputParameters = null); * * @return mixed */ - public function fetch($fetchStyle = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0); + public function fetch($fetchStyle = PDO::FETCH_BOTH, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0); /** * Binds a parameter to the specified variable name. @@ -102,7 +102,7 @@ public function fetchColumn($column_number = 0); * * @return array returns an array containing all of the remaining rows in the result set. */ - public function fetchAll($fetchStyle = null, $fetchArgument = null, array $ctorArgs = []); + public function fetchAll($fetchStyle = PDO::FETCH_BOTH, $fetchArgument = null, array $ctorArgs = []); /** * Fetches the next row and returns it as an object. From d5c407a5c03b95b9e96dba3c21ed528a4ef98293 Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 1 Dec 2020 17:26:27 +0100 Subject: [PATCH 189/208] Update baseline --- phpstan-baseline.neon | 5 ----- 1 file changed, 5 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c3e6558878..509d92ed18 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -290,11 +290,6 @@ parameters: count: 1 path: src/Propel/Generator/Model/ForeignKey.php - - - message: "#^Strict comparison using \\=\\=\\= between int\\<1, max\\> and 0 will always evaluate to false\\.$#" - count: 1 - path: src/Propel/Generator/Model/MappingModel.php - - message: "#^If condition is always true\\.$#" count: 1 From ef22f4cc1fc34e2fc6ce6be51e14c5dc86281872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Klatt?= Date: Wed, 2 Dec 2020 13:27:48 +0100 Subject: [PATCH 190/208] Moved checks to GA. --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 10 ---------- 2 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..093ecc52ac --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: PropelORM CI + +on: [ + push, + pull_request +] + +jobs: + code-style-and-static-analysis: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 1 + + - name: Composer get cache directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Composer cache + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Composer validate + run: composer validate + + - name: Composer install + run: composer install --prefer-dist --no-interaction + + - name: Code Style + run: composer cs-check + + - name: PHPStan + run: composer stan + + - name: Psalm + run: composer psalm diff --git a/.travis.yml b/.travis.yml index bfb0b354d6..baa78271a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -395,16 +395,6 @@ jobs: - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - composer show - - name: Checks - php: 7.4 - env: DB=agnostic CHECKS=1 - install: - - composer install --prefer-dist --no-interaction - script: - - composer stan - - composer psalm - - composer cs-check - fast_finish: true cache: From 47058dddfc701bbcf862918f56bfcd7d281f2b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Klatt?= Date: Wed, 2 Dec 2020 13:36:27 +0100 Subject: [PATCH 191/208] Added badge. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index aa4d6e8155..dea89bf73c 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Propel2 is an open-source Object-Relational Mapping (ORM) for PHP. [![Build Status](https://travis-ci.org/propelorm/Propel2.svg?branch=master)](https://travis-ci.org/propelorm/Propel2) +[![Github actions Status](https://github.com/propelorm/Propel2/workflows/PropelORM%20CI/badge.svg?branch=master)](https://github.com/propelorm/Propel2/actions?query=workflow%3APropelORM%20CI+branch%3Amaster) [![Code Climate](https://codeclimate.com/github/propelorm/Propel2/badges/gpa.svg)](https://codeclimate.com/github/propelorm/Propel2) [![Minimum PHP Version](http://img.shields.io/badge/php-%3E%3D%207.2-8892BF.svg)](https://php.net/) [![License](https://poser.pugx.org/propel/propel/license.svg)](https://packagist.org/packages/propel/propel) From 20c9ac925241da73f3bb8ed8cef90b5d5f472814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Klatt?= Date: Wed, 2 Dec 2020 13:42:47 +0100 Subject: [PATCH 192/208] Run only for pull requests. --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 093ecc52ac..26cdf3e4d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,6 @@ name: PropelORM CI on: [ - push, pull_request ] From 69425dbc3be6769ca8df45e620f28d37df3d4608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Klatt?= Date: Wed, 2 Dec 2020 13:44:50 +0100 Subject: [PATCH 193/208] Renamed workflow. --- .github/workflows/ci.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26cdf3e4d7..6a5b5de318 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: PropelORM CI +name: CI on: [ pull_request diff --git a/README.md b/README.md index dea89bf73c..47da8fbffb 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Propel2 is an open-source Object-Relational Mapping (ORM) for PHP. [![Build Status](https://travis-ci.org/propelorm/Propel2.svg?branch=master)](https://travis-ci.org/propelorm/Propel2) -[![Github actions Status](https://github.com/propelorm/Propel2/workflows/PropelORM%20CI/badge.svg?branch=master)](https://github.com/propelorm/Propel2/actions?query=workflow%3APropelORM%20CI+branch%3Amaster) +[![Github actions Status](https://github.com/propelorm/Propel2/workflows/CI/badge.svg?branch=master)](https://github.com/propelorm/Propel2/actions?query=workflow%3ACI+branch%3Amaster) [![Code Climate](https://codeclimate.com/github/propelorm/Propel2/badges/gpa.svg)](https://codeclimate.com/github/propelorm/Propel2) [![Minimum PHP Version](http://img.shields.io/badge/php-%3E%3D%207.2-8892BF.svg)](https://php.net/) [![License](https://poser.pugx.org/propel/propel/license.svg)](https://packagist.org/packages/propel/propel) From cf41ae1b59ce99ac169f9547f84035ad1854072d Mon Sep 17 00:00:00 2001 From: Mark Sch Date: Mon, 14 Dec 2020 16:07:54 +0100 Subject: [PATCH 194/208] Clarify license type. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 47da8fbffb..1840d28c03 100644 --- a/README.md +++ b/README.md @@ -41,4 +41,4 @@ Please see our [contribution guideline](http://propelorm.org/contribute.html). T ## License -See the `LICENSE` file. +MIT. See the `LICENSE` file for details. From b0f8707a88efd12802612fff332194862d6ddf51 Mon Sep 17 00:00:00 2001 From: mscherer Date: Mon, 14 Dec 2020 16:52:11 +0100 Subject: [PATCH 195/208] Add missing gitignore. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 592c498c56..1ebd33db39 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ composer.phar /composer.lock autoload.php phpunit.xml +.phpunit.result.cache pom.xml php-cs-fixer.phar @@ -41,3 +42,4 @@ tests/Fixtures/fixtures_built tests/graphviztest/ tests/migrationdiff/ tests/reversecommand/ +tests/test.sq3 From 0baa51e4a051607076b6d46ce72083dc16a340f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Paj=C4=85k?= Date: Wed, 16 Dec 2020 09:33:40 +0100 Subject: [PATCH 196/208] Docblock for transaction function is up to date with implementation --- src/Propel/Runtime/Connection/ConnectionInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Runtime/Connection/ConnectionInterface.php b/src/Propel/Runtime/Connection/ConnectionInterface.php index 1487ceac48..cc8757df78 100644 --- a/src/Propel/Runtime/Connection/ConnectionInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionInterface.php @@ -136,7 +136,7 @@ public function getDataFetcher($data); * * @param callable $callable A callable to be wrapped in a transaction. * - * @throws \Exception Re-throws a possible Exception triggered by the callable. + * @throws \Throwable Re-throws a possible Throwable triggered by the callable. * * @return mixed Returns the result of the callable. */ From ca21f83be09ef9b75fd9c043c4378eb95974d0e6 Mon Sep 17 00:00:00 2001 From: Cristiano Cinotti Date: Tue, 8 Dec 2020 16:35:33 +0100 Subject: [PATCH 197/208] Move continuous integration to Github Actions --- .github/workflows/tests.yml | 83 +++++++++++++++++++ .../Config/ConfigurationManagerTest.php | 3 +- tests/bin/setup.pgsql.sh | 12 +-- 3 files changed, 92 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000000..285e312c14 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,83 @@ +name: Propel Test Suite + +on: [push, pull_request] + +jobs: + testsuite: + runs-on: ubuntu-18.04 + strategy: + fail-fast: false + matrix: + php-version: ['7.2', '7.4'] + db-type: [sqlite, mysql, pgsql, agnostic] + symfony-version: [ '3-min', '3-max', '4-min', '4-max', '5-min', '5-max' ] + steps: + - name: Install PostgreSQL latest + if: matrix.db-type == 'pgsql' && matrix.php-version == '7.4' + uses: CasperWA/postgresql-action@v1.2 + with: + postgresql db: 'propel-tests' + postgresql user: 'postgres' + postgresql password: 'postgres' + + - name: Install PostgreSQL min + if: matrix.db-type == 'pgsql' && matrix.php-version == '7.2' + uses: CasperWA/postgresql-action@v1.2 + with: + postgresql version: 9 + postgresql db: 'propel-tests' + postgresql user: 'postgres' + postgresql password: 'postgres' + + - name: Install MariaDb latest + if: matrix.db-type == 'mysql' && matrix.php-version == '7.4' + uses: getong/mariadb-action@v1.1 + + - name: Install MariaDb min + if: matrix.db-type == 'mysql' && matrix.php-version == '7.2' + uses: getong/mariadb-action@v1.1 + with: + mariadb version: '10.2' + + - name: Checkout + uses: actions/checkout@v2 + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: json, libxml, pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, sqlite3 + coverage: none + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache composer dependencies + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + - name: Move specific composer.json (Symfony version ${{ matrix.symfony-version }}) + run: mv tests/composer/composer-symfony${{ matrix.symfony-version }}.json composer.json + - name: Install dependencies (Symfony version ${{ matrix.symfony-version }}) + run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader + - name: Setup Postgresql dabase for test suite + if: matrix.db-type == 'pgsql' + run: tests/bin/setup.pgsql.sh + env: + PGPASSWORD: 'postgres' + DB_NAME: 'propel-tests' + DB_USER: 'postgres' + DB_PW: 'postgres' + - name: Setup the dabase for test suite + if: matrix.db-type != 'agnostic' && matrix.db-type != 'pgsql' + run: tests/bin/setup.${{ matrix.db-type }}.sh + - name: Run Postgresql tests + if: matrix.db-type == 'pgsql' + run: tests/bin/phpunit.pgsql.sh + env: + DB_NAME: 'propel-tests' + DB_USER: 'postgres' + DB_PW: 'postgres' + - name: Run tests + if: matrix.db-type != 'pgsql' + run: tests/bin/phpunit.${{ matrix.db-type }}.sh diff --git a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php index 9db6695917..2695b8aeba 100644 --- a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php +++ b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php @@ -442,7 +442,8 @@ classname: Propel\Runtime\Connection\ConnectionWrapper public function testNotDefineDatabaseSectionTrowsException() { $this->expectException(InvalidConfigurationException::class); - $this->expectExceptionMessage('The child node "database" at path "propel" must be configured'); + //Starting from Symfony Config 5.2, the following message changed + //$this->expectExceptionMessage('The child node "database" at path "propel" must be configured'); $yamlConf = << Date: Mon, 14 Dec 2020 16:24:46 +0100 Subject: [PATCH 198/208] Merged ci and test workflows, removed .travis.yml. Updated badges. Updated composer.json files to install phpunit 8 or higher for coverage. --- .github/workflows/ci.yml | 104 +++++ .github/workflows/tests.yml | 83 ---- .gitignore | 1 + .travis.yml | 407 ------------------ README.md | 2 +- composer.json | 2 +- phpunit.xml.dist | 68 ++- psalm-baseline.xml | 100 +---- psalm.xml | 3 + .../Common/Config/PropelConfiguration.php | 2 - src/Propel/Generator/Manager/SqlManager.php | 2 - src/Propel/Runtime/Parser/CsvParser.php | 2 - .../Generator/Command/InitCommandTest.php | 1 + tests/agnostic.phpunit.xml | 66 +-- tests/bin/phpunit.agnostic.sh | 3 - tests/bin/phpunit.mysql.sh | 3 - tests/bin/phpunit.pgsql.sh | 3 - tests/bin/phpunit.sqlite.sh | 3 - tests/composer/composer-symfony3-max.json | 6 +- tests/composer/composer-symfony3-min.json | 6 +- tests/composer/composer-symfony4-max.json | 6 +- tests/composer/composer-symfony4-min.json | 6 +- tests/composer/composer-symfony5-max.json | 6 +- tests/composer/composer-symfony5-min.json | 6 +- tests/mysql.phpunit.xml | 90 ++-- tests/pgsql.phpunit.xml | 92 ++-- tests/sqlite.phpunit.xml | 90 ++-- 27 files changed, 343 insertions(+), 820 deletions(-) delete mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml delete mode 100755 tests/bin/phpunit.agnostic.sh delete mode 100755 tests/bin/phpunit.mysql.sh delete mode 100755 tests/bin/phpunit.pgsql.sh delete mode 100755 tests/bin/phpunit.sqlite.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a5b5de318..f6a73e827c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,110 @@ on: [ ] jobs: + testsuite: + runs-on: ubuntu-18.04 + strategy: + fail-fast: false + matrix: + php-version: [ '7.2', '7.4' ] + db-type: [ sqlite, mysql, pgsql, agnostic ] + symfony-version: [ '3-min', '3-max', '4-min', '4-max', '5-min', '5-max' ] + steps: + - name: Install PostgreSQL latest + if: matrix.db-type == 'pgsql' && matrix.php-version == '7.4' + uses: CasperWA/postgresql-action@v1.2 + with: + postgresql db: 'propel-tests' + postgresql user: 'postgres' + postgresql password: 'postgres' + + - name: Install PostgreSQL min + if: matrix.db-type == 'pgsql' && matrix.php-version == '7.2' + uses: CasperWA/postgresql-action@v1.2 + with: + postgresql version: 9 + postgresql db: 'propel-tests' + postgresql user: 'postgres' + postgresql password: 'postgres' + + - name: Install MariaDb latest + if: matrix.db-type == 'mysql' && matrix.php-version == '7.4' + uses: getong/mariadb-action@v1.1 + + - name: Install MariaDb min + if: matrix.db-type == 'mysql' && matrix.php-version == '7.2' + uses: getong/mariadb-action@v1.1 + with: + mariadb version: '10.2' + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: json, libxml, pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, sqlite3 + coverage: pcov + + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Composer get cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Composer cache dependencies + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Move specific composer.json (Symfony version ${{ matrix.symfony-version }}) + run: mv tests/composer/composer-symfony${{ matrix.symfony-version }}.json composer.json + + - name: Composer install (Symfony version ${{ matrix.symfony-version }}) + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Setup Postgresql database for test suite + if: matrix.db-type == 'pgsql' + run: tests/bin/setup.pgsql.sh + env: + PGPASSWORD: 'postgres' + DB_NAME: 'propel-tests' + DB_USER: 'postgres' + DB_PW: 'postgres' + + - name: Setup the database for test suite + if: matrix.db-type != 'agnostic' && matrix.db-type != 'pgsql' + run: tests/bin/setup.${{ matrix.db-type }}.sh + + - name: Run PostgreSQL tests + if: matrix.db-type == 'pgsql' + shell: 'script -q -e -c "bash {0}"' + run: vendor/bin/phpunit -c tests/pgsql.phpunit.xml + env: + DB_NAME: 'propel-tests' + DB_USER: 'postgres' + DB_PW: 'postgres' + + - name: Run ${{ matrix.db-type }} tests + if: matrix.db-type != 'pgsql' + shell: 'script -q -e -c "bash {0}"' + run: | + if [[ ${{ matrix.php-version }} == '7.4' && ${{ matrix.symfony-version == '5-max' }} ]]; then + export CODECOVERAGE=1 && vendor/bin/phpunit -c tests/${{ matrix.db-type }}.phpunit.xml --verbose --coverage-clover=tests/coverage.xml + else + vendor/bin/phpunit -c tests/${{ matrix.db-type }}.phpunit.xml + fi + + - name: Code Coverage Report + if: success() && matrix.db-type == 'mysql' && matrix.php-version == '7.4' && matrix.symfony-version == '5-max' + uses: codecov/codecov-action@v1 + with: + flags: ${{ matrix.php-version }}, ${{ matrix.db-type }}, ${{ matrix.symfony-version }} + file: tests/coverage.xml + code-style-and-static-analysis: runs-on: ubuntu-18.04 steps: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 285e312c14..0000000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Propel Test Suite - -on: [push, pull_request] - -jobs: - testsuite: - runs-on: ubuntu-18.04 - strategy: - fail-fast: false - matrix: - php-version: ['7.2', '7.4'] - db-type: [sqlite, mysql, pgsql, agnostic] - symfony-version: [ '3-min', '3-max', '4-min', '4-max', '5-min', '5-max' ] - steps: - - name: Install PostgreSQL latest - if: matrix.db-type == 'pgsql' && matrix.php-version == '7.4' - uses: CasperWA/postgresql-action@v1.2 - with: - postgresql db: 'propel-tests' - postgresql user: 'postgres' - postgresql password: 'postgres' - - - name: Install PostgreSQL min - if: matrix.db-type == 'pgsql' && matrix.php-version == '7.2' - uses: CasperWA/postgresql-action@v1.2 - with: - postgresql version: 9 - postgresql db: 'propel-tests' - postgresql user: 'postgres' - postgresql password: 'postgres' - - - name: Install MariaDb latest - if: matrix.db-type == 'mysql' && matrix.php-version == '7.4' - uses: getong/mariadb-action@v1.1 - - - name: Install MariaDb min - if: matrix.db-type == 'mysql' && matrix.php-version == '7.2' - uses: getong/mariadb-action@v1.1 - with: - mariadb version: '10.2' - - - name: Checkout - uses: actions/checkout@v2 - - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - extensions: json, libxml, pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, sqlite3 - coverage: none - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Cache composer dependencies - uses: actions/cache@v1 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-composer- - - name: Move specific composer.json (Symfony version ${{ matrix.symfony-version }}) - run: mv tests/composer/composer-symfony${{ matrix.symfony-version }}.json composer.json - - name: Install dependencies (Symfony version ${{ matrix.symfony-version }}) - run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader - - name: Setup Postgresql dabase for test suite - if: matrix.db-type == 'pgsql' - run: tests/bin/setup.pgsql.sh - env: - PGPASSWORD: 'postgres' - DB_NAME: 'propel-tests' - DB_USER: 'postgres' - DB_PW: 'postgres' - - name: Setup the dabase for test suite - if: matrix.db-type != 'agnostic' && matrix.db-type != 'pgsql' - run: tests/bin/setup.${{ matrix.db-type }}.sh - - name: Run Postgresql tests - if: matrix.db-type == 'pgsql' - run: tests/bin/phpunit.pgsql.sh - env: - DB_NAME: 'propel-tests' - DB_USER: 'postgres' - DB_PW: 'postgres' - - name: Run tests - if: matrix.db-type != 'pgsql' - run: tests/bin/phpunit.${{ matrix.db-type }}.sh diff --git a/.gitignore b/.gitignore index 1ebd33db39..dc07bc3328 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store .idea/ vendor/ composer.phar diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index baa78271a8..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,407 +0,0 @@ -language: php - -git: - depth: 1 - -dist: bionic - -php: - - 7.2 - - 7.4 - - nightly - -env: - global: - - PGPORT=5432 - jobs: - - DB=agnostic #only database agnostic tests - - DB=mysql # TODO we should cover multiple specific versions of mysql. - - DB=sqlite - -services: - - mysql - -install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - composer install -v - - composer show - - php --ini - - php --modules - - sqlite3 --version - -before_script: - - if [[ $DB != 'agnostic' && $DB != 'sqlite' ]]; then ./tests/bin/setup.$DB.sh; fi - -script: - - vendor/bin/phpunit -v -c tests/$DB.phpunit.xml - -jobs: - include: - - php: 7.2 - dist: trusty - env: DB=mysql MARIADB=10.1 - services: - addons: - mariadb: 10.1 - - php: 7.4 - dist: trusty - env: DB=mysql MARIADB=10.1 - services: - addons: - mariadb: 10.1 -# @todo: This job is failinig due to old Travis nightly image -# - php: nightly -# dist: trusty -# env: DB=mysql MARIADB=10.1 -# services: -# addons: -# mariadb: 10.1 - - - php: 7.2 - env: DB=mysql MARIADB=10.2 - addons: - mariadb: 10.2 - - php: 7.4 - env: DB=mysql MARIADB=10.2 - addons: - mariadb: 10.2 - - php: nightly - env: DB=mysql MARIADB=10.2 - addons: - mariadb: 10.2 - - - php: 7.2 - env: DB=mysql MARIADB=10.3 - addons: - mariadb: 10.3 - - php: 7.4 - env: DB=mysql MARIADB=10.3 - addons: - mariadb: 10.3 - - php: nightly - env: DB=mysql MARIADB=10.3 - addons: - mariadb: 10.3 - - - php: 7.2 - env: DB=mysql MARIADB=10.4 DB_USER=travis - addons: - mariadb: 10.4 - before_script: - - sudo mysql -e 'drop user if exists travis@localhost;' - - sudo mysql -e 'create user travis@localhost;' - - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; - - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; - - ./tests/bin/setup.$DB.sh - - php: 7.4 - env: DB=mysql MARIADB=10.4 DB_USER=travis - addons: - mariadb: 10.4 - before_script: - - sudo mysql -e 'drop user if exists travis@localhost;' - - sudo mysql -e 'create user travis@localhost;' - - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; - - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; - - ./tests/bin/setup.$DB.sh - - php: nightly - env: DB=mysql MARIADB=10.4 DB_USER=travis - addons: - mariadb: 10.4 - before_script: - - sudo mysql -e 'drop user if exists travis@localhost;' - - sudo mysql -e 'create user travis@localhost;' - - sudo mysql -e "GRANT ALL PRIVILEGES ON db.* TO 'travis'@'localhost'"; - - sudo mysql -e "GRANT ALL ON *.* to travis@localhost;"; - - ./tests/bin/setup.$DB.sh - - - php: 7.2 - env: DB=pgsql POSTGRES=9.5 - addons: - postgresql: 9.5 - - php: 7.4 - env: DB=pgsql POSTGRES=9.5 - addons: - postgresql: 9.5 - - php: nightly - env: DB=pgsql POSTGRES=9.5 - addons: - postgresql: 9.5 - - - php: 7.2 - env: DB=pgsql POSTGRES=9.6 - addons: - postgresql: 9.6 - - php: 7.4 - env: DB=pgsql POSTGRES=9.6 - addons: - postgresql: 9.6 - - php: nightly - env: DB=pgsql POSTGRES=9.6 - addons: - postgresql: 9.6 - - - php: 7.2 - env: DB=pgsql POSTGRES=10 - addons: - postgresql: 10 - - php: 7.4 - env: DB=pgsql POSTGRES=10 - addons: - postgresql: 10 - - php: nightly - env: DB=pgsql POSTGRES=10 - addons: - postgresql: 10 - - - php: 7.2 - env: DB=pgsql POSTGRES=11 - addons: - postgresql: 11 - - php: 7.4 - env: DB=pgsql POSTGRES=11 - addons: - postgresql: 11 - - php: nightly - env: DB=pgsql POSTGRES=11 - addons: - postgresql: 11 - - - php: 7.2 - env: DB=pgsql POSTGRES=12 PGPORT=5432 - addons: - postgresql: 12 - apt: - packages: - - postgresql-12 - - postgresql-client-12 - install: - - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf - - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf - - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf - - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - composer install -v - - composer show - - php: 7.4 - env: DB=pgsql POSTGRES=12 PGPORT=5432 - addons: - postgresql: 12 - apt: - packages: - - postgresql-12 - - postgresql-client-12 - install: - - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf - - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf - - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf - - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - composer install -v - - composer show - - php: nightly - env: DB=pgsql POSTGRES=12 PGPORT=5432 - addons: - postgresql: 12 - apt: - packages: - - postgresql-12 - - postgresql-client-12 - install: - - sudo sed -i 's/md5/trust/g' /etc/postgresql/12/main/pg_hba.conf - - sudo sed -i 's/peer/trust/g' /etc/postgresql/12/main/pg_hba.conf - - sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf - - sudo pg_ctlcluster --skip-systemctl-redirect 12 main restart - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - composer install -v - - composer show - - - name: "PHP 7.4, Agnostic, Symfony ~3" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - - composer show - - name: "PHP 7.4, Agnostic, Symfony ^3" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - - composer show - - - name: "PHP 7.4, Agnostic, Symfony ~4" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - - composer show - - name: "PHP 7.4, Agnostic, Symfony ^4" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - - composer show - - - name: "PHP 7.4, Agnostic, Symfony ~5" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - - composer show - - name: "PHP 7.4, Agnostic, Symfony ^5" - php: 7.4 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - - composer show - - - name: "PHP 7.4, MySql, Symfony ~3" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - - composer show - - name: "PHP 7.4, MySql, Symfony ^3" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - - composer show - - - name: "PHP 7.4, MySql, Symfony ~4" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - - composer show - - name: "PHP 7.4, MySql, Symfony ^4" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - - composer show - - - name: "PHP 7.4, MySql, Symfony ~5" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - - composer show - - name: "PHP 7.4, MySql, Symfony ^5" - php: 7.4 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - - composer show - - - name: "PHP 7.2, Agnostic, Symfony ~3" - php: 7.2 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - - composer show - - name: "PHP 7.2, Agnostic, Symfony ^3" - php: 7.2 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - - composer show - - - name: "PHP 7.2, Agnostic, Symfony ~4" - php: 7.2 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - - composer show - - name: "PHP 7.2, Agnostic, Symfony ^4" - php: 7.2 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - - composer show - - - name: "PHP 7.2, Agnostic, Symfony ~5" - php: 7.2 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - - composer show - - name: "PHP 7.2, Agnostic, Symfony ^5" - php: 7.2 - env: DB=agnostic - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - - composer show - - - name: "PHP 7.2, MySql, Symfony ~3" - php: 7.2 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-min.json composer install - - composer show - - name: "PHP 7.2, MySql, Symfony ^3" - php: 7.2 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony3-max.json composer install - - composer show - - - name: "PHP 7.2, MySql, Symfony ~4" - php: 7.2 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-min.json composer install - - composer show - - name: "PHP 7.2, MySql, Symfony ^4" - php: 7.2 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony4-max.json composer install - - composer show - - - name: "PHP 7.2, MySql, Symfony ~5" - php: 7.2 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-min.json composer install - - composer show - - name: "PHP 7.2, MySql, Symfony ^5" - php: 7.2 - env: DB=mysql - install: - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - - COMPOSER=./tests/composer/composer-symfony5-max.json composer install - - composer show - - fast_finish: true - -cache: - directories: - - $HOME/.composer/cache - -notifications: - webhooks: - - http://propel.jarves.io/build.php - - https://webhooks.gitter.im/e/206efe76e183f9ade489 diff --git a/README.md b/README.md index 1840d28c03..18cb6dfa44 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ Propel2 is an open-source Object-Relational Mapping (ORM) for PHP. -[![Build Status](https://travis-ci.org/propelorm/Propel2.svg?branch=master)](https://travis-ci.org/propelorm/Propel2) [![Github actions Status](https://github.com/propelorm/Propel2/workflows/CI/badge.svg?branch=master)](https://github.com/propelorm/Propel2/actions?query=workflow%3ACI+branch%3Amaster) +[![codecov](https://codecov.io/gh/propelorm/Propel2/branch/master/graph/badge.svg?token=L1thFB9nOG)](https://codecov.io/gh/propelorm/Propel2) [![Code Climate](https://codeclimate.com/github/propelorm/Propel2/badges/gpa.svg)](https://codeclimate.com/github/propelorm/Propel2) [![Minimum PHP Version](http://img.shields.io/badge/php-%3E%3D%207.2-8892BF.svg)](https://php.net/) [![License](https://poser.pugx.org/propel/propel/license.svg)](https://packagist.org/packages/propel/propel) diff --git a/composer.json b/composer.json index 703bb96e74..b8043e9f47 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "phpstan/phpstan": "^0.12.4", "phpunit/phpunit": "^8.0.0||^9.0.0", "spryker/code-sniffer": "^0.15.6", - "psalm/phar": "^4.1.0" + "psalm/phar": "4.2.1" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5490e725b7..d019749985 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,43 +1,39 @@ - + - - - tests/Propel/Tests/ - - + + + tests/Propel/Tests/ + + - - - pgsql - mysql - - + + + pgsql + mysql + + - - - - - + + + + + - - - - + + + + + + + src/Propel/ + + - - - src/Propel/ - - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 972f2fce99..0401880d75 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + new TreeBuilder() @@ -460,104 +460,6 @@ $e - - - $charset - $dsn - $phpDir - $rdbms - $schemaDir - $user - - - - - $charset - $dsn - $password - $rdbms - $user - - - - - $phpDir - $schemaDir - - - - - $charset - $dsn - $password - $rdbms - $user - - - - - $charset - $dsn - $phpDir - $rdbms - $schemaDir - $user - - - - - $charset - $dsn - $password - $rdbms - $user - - - - - $charset - $dsn - $phpDir - $rdbms - $schemaDir - $user - - - - - $charset - $dsn - $password - $rdbms - $user - - - - - $charset - $dsn - $phpDir - $rdbms - $schemaDir - $user - - - - - $charset - $dsn - $password - $rdbms - $user - - - - - $namespace - $rdbms - $schemaDir - - getLocation diff --git a/psalm.xml b/psalm.xml index 26fe338948..97136d8432 100644 --- a/psalm.xml +++ b/psalm.xml @@ -11,6 +11,9 @@ > + + + diff --git a/src/Propel/Common/Config/PropelConfiguration.php b/src/Propel/Common/Config/PropelConfiguration.php index 48d84b4f76..214adb3c1e 100644 --- a/src/Propel/Common/Config/PropelConfiguration.php +++ b/src/Propel/Common/Config/PropelConfiguration.php @@ -96,8 +96,6 @@ protected function addPathsSection(ArrayNodeDefinition $node) /** * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node * - * @throws \InvalidArgumentException - * * @return void */ protected function addDatabaseSection(ArrayNodeDefinition $node) diff --git a/src/Propel/Generator/Manager/SqlManager.php b/src/Propel/Generator/Manager/SqlManager.php index 467c6ef8d1..77ed287a92 100644 --- a/src/Propel/Generator/Manager/SqlManager.php +++ b/src/Propel/Generator/Manager/SqlManager.php @@ -147,8 +147,6 @@ public function existSqlMap() /** * @param string|null $datasource A datasource name. * - * @throws \Exception - * * @return bool */ public function insertSql($datasource = null) diff --git a/src/Propel/Runtime/Parser/CsvParser.php b/src/Propel/Runtime/Parser/CsvParser.php index 5bdfd17e4b..dec4c8428b 100644 --- a/src/Propel/Runtime/Parser/CsvParser.php +++ b/src/Propel/Runtime/Parser/CsvParser.php @@ -22,8 +22,6 @@ class CsvParser extends AbstractParser public const QUOTE_NONNUMERIC = 2; public const QUOTE_MINIMAL = 3; - // these settings are predefined for Excel CSV format - /** * @var string */ diff --git a/tests/Propel/Tests/Generator/Command/InitCommandTest.php b/tests/Propel/Tests/Generator/Command/InitCommandTest.php index 8aaa6670ec..117a7b2c4e 100644 --- a/tests/Propel/Tests/Generator/Command/InitCommandTest.php +++ b/tests/Propel/Tests/Generator/Command/InitCommandTest.php @@ -15,6 +15,7 @@ use Propel\Runtime\Propel; use Propel\Tests\TestCaseFixtures; use Symfony\Component\Console\Application; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Filesystem\Filesystem; diff --git a/tests/agnostic.phpunit.xml b/tests/agnostic.phpunit.xml index c6cec9d876..b5ca33aef7 100644 --- a/tests/agnostic.phpunit.xml +++ b/tests/agnostic.phpunit.xml @@ -1,43 +1,43 @@ - - - Propel/Tests/ - - + + + Propel/Tests/ + + - - - database - pgsql - mysql - - + + + database + pgsql + mysql + + - - - ../src/Propel/ - - ../src/Propel/Generator/Builder/SQL/Mssql - ../src/Propel/Generator/Builder/SQL/Oracle - ../src/Propel/Generator/Builder/SQL/Sqlsrv + + + ../src/Propel/ + + ../src/Propel/Generator/Builder/SQL/Mssql + ../src/Propel/Generator/Builder/SQL/Oracle + ../src/Propel/Generator/Builder/SQL/Sqlsrv - ../src/Propel/Generator/Platform/MssqlPlatform.php - ../src/Propel/Generator/Platform/OraclePlatform.php - ../src/Propel/Generator/Platform/SqlsrvPlatform.php + ../src/Propel/Generator/Platform/MssqlPlatform.php + ../src/Propel/Generator/Platform/OraclePlatform.php + ../src/Propel/Generator/Platform/SqlsrvPlatform.php - ../src/Propel/Generator/Reverse/MssqlSchemaParser.php - ../src/Propel/Generator/Reverse/OracleSchemaParser.php - ../src/Propel/Generator/Reverse/SqlsrvSchemaParser.php + ../src/Propel/Generator/Reverse/MssqlSchemaParser.php + ../src/Propel/Generator/Reverse/OracleSchemaParser.php + ../src/Propel/Generator/Reverse/SqlsrvSchemaParser.php - ../src/Propel/Runtime/Adapter/MSSQL - ../src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php - ../src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php - ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php + ../src/Propel/Runtime/Adapter/MSSQL + ../src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php + ../src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php + ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php - ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php - - - + ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php + + + diff --git a/tests/bin/phpunit.agnostic.sh b/tests/bin/phpunit.agnostic.sh deleted file mode 100755 index dd62a66228..0000000000 --- a/tests/bin/phpunit.agnostic.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -./vendor/bin/phpunit -c tests/agnostic.phpunit.xml $@ \ No newline at end of file diff --git a/tests/bin/phpunit.mysql.sh b/tests/bin/phpunit.mysql.sh deleted file mode 100755 index ad3bcb0471..0000000000 --- a/tests/bin/phpunit.mysql.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -./vendor/bin/phpunit -c tests/mysql.phpunit.xml $@ \ No newline at end of file diff --git a/tests/bin/phpunit.pgsql.sh b/tests/bin/phpunit.pgsql.sh deleted file mode 100755 index 0a0735c8a8..0000000000 --- a/tests/bin/phpunit.pgsql.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -./vendor/bin/phpunit -c tests/pgsql.phpunit.xml $@ diff --git a/tests/bin/phpunit.sqlite.sh b/tests/bin/phpunit.sqlite.sh deleted file mode 100755 index 0122f4a6df..0000000000 --- a/tests/bin/phpunit.sqlite.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -./vendor/bin/phpunit -c tests/sqlite.phpunit.xml $@ \ No newline at end of file diff --git a/tests/composer/composer-symfony3-max.json b/tests/composer/composer-symfony3-max.json index e2185069fc..6b63ce42bd 100644 --- a/tests/composer/composer-symfony3-max.json +++ b/tests/composer/composer-symfony3-max.json @@ -27,9 +27,13 @@ "psr/log": "^1.0" }, "require-dev": { + "ext-pdo": "*", + "ext-json": "*", "monolog/monolog": "^1.3", "phpstan/phpstan": "^0.12.4", - "phpunit/phpunit": "^7.5.15" + "phpunit/phpunit": "^8.0.0||^9.0.0", + "spryker/code-sniffer": "^0.15.6", + "psalm/phar": "^4.1.0" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." diff --git a/tests/composer/composer-symfony3-min.json b/tests/composer/composer-symfony3-min.json index 7e29e38ef9..90c16c95e4 100644 --- a/tests/composer/composer-symfony3-min.json +++ b/tests/composer/composer-symfony3-min.json @@ -27,9 +27,13 @@ "psr/log": "^1.0" }, "require-dev": { + "ext-pdo": "*", + "ext-json": "*", "monolog/monolog": "^1.3", "phpstan/phpstan": "^0.12.4", - "phpunit/phpunit": "^7.5.15" + "phpunit/phpunit": "^8.0.0||^9.0.0", + "spryker/code-sniffer": "^0.15.6", + "psalm/phar": "^4.1.0" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." diff --git a/tests/composer/composer-symfony4-max.json b/tests/composer/composer-symfony4-max.json index f8d63c2c57..67792d4352 100644 --- a/tests/composer/composer-symfony4-max.json +++ b/tests/composer/composer-symfony4-max.json @@ -27,9 +27,13 @@ "psr/log": "^1.0" }, "require-dev": { + "ext-pdo": "*", + "ext-json": "*", "monolog/monolog": "^1.3", "phpstan/phpstan": "^0.12.4", - "phpunit/phpunit": "^7.5.15" + "phpunit/phpunit": "^8.0.0||^9.0.0", + "spryker/code-sniffer": "^0.15.6", + "psalm/phar": "^4.1.0" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." diff --git a/tests/composer/composer-symfony4-min.json b/tests/composer/composer-symfony4-min.json index d3e3b9c65f..bb71a903d6 100644 --- a/tests/composer/composer-symfony4-min.json +++ b/tests/composer/composer-symfony4-min.json @@ -27,9 +27,13 @@ "psr/log": "^1.0" }, "require-dev": { + "ext-pdo": "*", + "ext-json": "*", "monolog/monolog": "^1.3", "phpstan/phpstan": "^0.12.4", - "phpunit/phpunit": "^7.5.15" + "phpunit/phpunit": "^8.0.0||^9.0.0", + "spryker/code-sniffer": "^0.15.6", + "psalm/phar": "^4.1.0" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." diff --git a/tests/composer/composer-symfony5-max.json b/tests/composer/composer-symfony5-max.json index 62046f4b57..77b9b57c33 100644 --- a/tests/composer/composer-symfony5-max.json +++ b/tests/composer/composer-symfony5-max.json @@ -27,9 +27,13 @@ "psr/log": "^1.0" }, "require-dev": { + "ext-pdo": "*", + "ext-json": "*", "monolog/monolog": "^1.3", "phpstan/phpstan": "^0.12.4", - "phpunit/phpunit": "^7.5.15" + "phpunit/phpunit": "^8.0.0||^9.0.0", + "spryker/code-sniffer": "^0.15.6", + "psalm/phar": "^4.1.0" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." diff --git a/tests/composer/composer-symfony5-min.json b/tests/composer/composer-symfony5-min.json index 6521c86c09..3c4f799aff 100644 --- a/tests/composer/composer-symfony5-min.json +++ b/tests/composer/composer-symfony5-min.json @@ -27,9 +27,13 @@ "psr/log": "^1.0" }, "require-dev": { + "ext-pdo": "*", + "ext-json": "*", "monolog/monolog": "^1.3", "phpstan/phpstan": "^0.12.4", - "phpunit/phpunit": "^7.5.15" + "phpunit/phpunit": "^8.0.0||^9.0.0", + "spryker/code-sniffer": "^0.15.6", + "psalm/phar": "^4.1.0" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." diff --git a/tests/mysql.phpunit.xml b/tests/mysql.phpunit.xml index 3d814faa2e..f03c15dae7 100644 --- a/tests/mysql.phpunit.xml +++ b/tests/mysql.phpunit.xml @@ -1,49 +1,49 @@ - - - Propel/Tests/ - - - - - - database - - - pgsql - - - - - - - - - - - ../src/Propel/ - - ../src/Propel/Generator/Builder/SQL/Mssql - ../src/Propel/Generator/Builder/SQL/Oracle - ../src/Propel/Generator/Builder/SQL/Sqlsrv - - ../src/Propel/Generator/Platform/MssqlPlatform.php - ../src/Propel/Generator/Platform/OraclePlatform.php - ../src/Propel/Generator/Platform/SqlsrvPlatform.php - - ../src/Propel/Generator/Reverse/MssqlSchemaParser.php - ../src/Propel/Generator/Reverse/OracleSchemaParser.php - ../src/Propel/Generator/Reverse/SqlsrvSchemaParser.php - - ../src/Propel/Runtime/Adapter/MSSQL - ../src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php - ../src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php - ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php - - ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php - - - + + + Propel/Tests/ + + + + + + database + + + pgsql + + + + + + + + + + + ../src/Propel/ + + ../src/Propel/Generator/Builder/SQL/Mssql + ../src/Propel/Generator/Builder/SQL/Oracle + ../src/Propel/Generator/Builder/SQL/Sqlsrv + + ../src/Propel/Generator/Platform/MssqlPlatform.php + ../src/Propel/Generator/Platform/OraclePlatform.php + ../src/Propel/Generator/Platform/SqlsrvPlatform.php + + ../src/Propel/Generator/Reverse/MssqlSchemaParser.php + ../src/Propel/Generator/Reverse/OracleSchemaParser.php + ../src/Propel/Generator/Reverse/SqlsrvSchemaParser.php + + ../src/Propel/Runtime/Adapter/MSSQL + ../src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php + ../src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php + ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php + + ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php + + + diff --git a/tests/pgsql.phpunit.xml b/tests/pgsql.phpunit.xml index a30aad53f9..cbdadb5dcd 100644 --- a/tests/pgsql.phpunit.xml +++ b/tests/pgsql.phpunit.xml @@ -1,50 +1,50 @@ - - - Propel/Tests/ - - - - - - database - - - mysql - - - - - - - - - - - - ../src/Propel/ - - ../src/Propel/Generator/Builder/SQL/Mssql - ../src/Propel/Generator/Builder/SQL/Oracle - ../src/Propel/Generator/Builder/SQL/Sqlsrv - - ../src/Propel/Generator/Platform/MssqlPlatform.php - ../src/Propel/Generator/Platform/OraclePlatform.php - ../src/Propel/Generator/Platform/SqlsrvPlatform.php - - ../src/Propel/Generator/Reverse/MssqlSchemaParser.php - ../src/Propel/Generator/Reverse/OracleSchemaParser.php - ../src/Propel/Generator/Reverse/SqlsrvSchemaParser.php - - ../src/Propel/Runtime/Adapter/MSSQL - ../src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php - ../src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php - ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php - - ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php - - - + + + Propel/Tests/ + + + + + + database + + + mysql + + + + + + + + + + + + ../src/Propel/ + + ../src/Propel/Generator/Builder/SQL/Mssql + ../src/Propel/Generator/Builder/SQL/Oracle + ../src/Propel/Generator/Builder/SQL/Sqlsrv + + ../src/Propel/Generator/Platform/MssqlPlatform.php + ../src/Propel/Generator/Platform/OraclePlatform.php + ../src/Propel/Generator/Platform/SqlsrvPlatform.php + + ../src/Propel/Generator/Reverse/MssqlSchemaParser.php + ../src/Propel/Generator/Reverse/OracleSchemaParser.php + ../src/Propel/Generator/Reverse/SqlsrvSchemaParser.php + + ../src/Propel/Runtime/Adapter/MSSQL + ../src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php + ../src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php + ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php + + ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php + + + diff --git a/tests/sqlite.phpunit.xml b/tests/sqlite.phpunit.xml index 268a20cc37..de776ea1a6 100644 --- a/tests/sqlite.phpunit.xml +++ b/tests/sqlite.phpunit.xml @@ -1,49 +1,49 @@ - - - Propel/Tests/ - - - - - - database - - - pgsql - mysql - - - - - - - - - - ../src/Propel/ - - ../src/Propel/Generator/Builder/SQL/Mssql - ../src/Propel/Generator/Builder/SQL/Oracle - ../src/Propel/Generator/Builder/SQL/Sqlsrv - - ../src/Propel/Generator/Platform/MssqlPlatform.php - ../src/Propel/Generator/Platform/OraclePlatform.php - ../src/Propel/Generator/Platform/SqlsrvPlatform.php - - ../src/Propel/Generator/Reverse/MssqlSchemaParser.php - ../src/Propel/Generator/Reverse/OracleSchemaParser.php - ../src/Propel/Generator/Reverse/SqlsrvSchemaParser.php - - ../src/Propel/Runtime/Adapter/MSSQL - ../src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php - ../src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php - ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php - - ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php - - - + + + Propel/Tests/ + + + + + + database + + + pgsql + mysql + + + + + + + + + + ../src/Propel/ + + ../src/Propel/Generator/Builder/SQL/Mssql + ../src/Propel/Generator/Builder/SQL/Oracle + ../src/Propel/Generator/Builder/SQL/Sqlsrv + + ../src/Propel/Generator/Platform/MssqlPlatform.php + ../src/Propel/Generator/Platform/OraclePlatform.php + ../src/Propel/Generator/Platform/SqlsrvPlatform.php + + ../src/Propel/Generator/Reverse/MssqlSchemaParser.php + ../src/Propel/Generator/Reverse/OracleSchemaParser.php + ../src/Propel/Generator/Reverse/SqlsrvSchemaParser.php + + ../src/Propel/Runtime/Adapter/MSSQL + ../src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php + ../src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php + ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php + + ../src/Propel/Runtime/Adapter/Pdo/SqlsrvAdapter.php + + + From 01e834ab7f8ab100514494ba7a9317944335f6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Klatt?= Date: Thu, 17 Dec 2020 12:02:44 +0000 Subject: [PATCH 199/208] Updated phpstan baseliine --- phpstan-baseline.neon | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 509d92ed18..e02566ea77 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -431,22 +431,22 @@ parameters: path: src/Propel/Runtime/ActiveQuery/Criteria.php - - message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:\\$currentAlias\\.$#" + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:applyLock\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/Criteria.php - - message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:\\$foundMatch\\.$#" + message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:\\$currentAlias\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/Criteria.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:cleanupSQL\\(\\)\\.$#" + message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:\\$foundMatch\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/Criteria.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:applyLock\\(\\)\\.$#" + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:cleanupSQL\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/Criteria.php From 1ecc77ae3f15f0bfeeb499e63f375930019c9cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Klatt?= Date: Thu, 17 Dec 2020 12:16:06 +0000 Subject: [PATCH 200/208] Setup PHP. --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6a73e827c..c1db52cc2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,6 +112,13 @@ jobs: code-style-and-static-analysis: runs-on: ubuntu-18.04 steps: + - name: Setup PHP 7.4 + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + extensions: json, libxml, pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, sqlite3 + coverage: pcov + - uses: actions/checkout@v1 with: fetch-depth: 1 From 033946697b63a8c6f538624aa112f6cb3464ec7f Mon Sep 17 00:00:00 2001 From: Mark Sch Date: Thu, 17 Dec 2020 13:29:11 +0100 Subject: [PATCH 201/208] Update ci.yml --- .github/workflows/ci.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1db52cc2c..ae270919bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,12 @@ name: CI -on: [ - pull_request -] +on: + push: + pull_request: + schedule: + - cron: "0 0 * * *" + branches: + - master jobs: testsuite: From 70d2d98a14ff76ce40b7a890a060a71292239c02 Mon Sep 17 00:00:00 2001 From: Cristiano Cinotti Date: Thu, 17 Dec 2020 15:19:41 +0100 Subject: [PATCH 202/208] Upload code coverage report for all dbms --- .github/workflows/ci.yml | 9 +++++++-- README.md | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae270919bf..96195fd939 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,7 +90,12 @@ jobs: - name: Run PostgreSQL tests if: matrix.db-type == 'pgsql' shell: 'script -q -e -c "bash {0}"' - run: vendor/bin/phpunit -c tests/pgsql.phpunit.xml + run: | + if [[ ${{ matrix.php-version }} == '7.4' && ${{ matrix.symfony-version == '5-max' }} ]]; then + export CODECOVERAGE=1 && vendor/bin/phpunit -c tests/pgsql.phpunit.xml --verbose --coverage-clover=tests/coverage.xml + else + vendor/bin/phpunit -c tests/pgsql.phpunit.xml + fi env: DB_NAME: 'propel-tests' DB_USER: 'postgres' @@ -107,7 +112,7 @@ jobs: fi - name: Code Coverage Report - if: success() && matrix.db-type == 'mysql' && matrix.php-version == '7.4' && matrix.symfony-version == '5-max' + if: success() && matrix.php-version == '7.4' && matrix.symfony-version == '5-max' uses: codecov/codecov-action@v1 with: flags: ${{ matrix.php-version }}, ${{ matrix.db-type }}, ${{ matrix.symfony-version }} diff --git a/README.md b/README.md index 18cb6dfa44..9c0e61370e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ Propel2 is an open-source Object-Relational Mapping (ORM) for PHP. [![Code Climate](https://codeclimate.com/github/propelorm/Propel2/badges/gpa.svg)](https://codeclimate.com/github/propelorm/Propel2) [![Minimum PHP Version](http://img.shields.io/badge/php-%3E%3D%207.2-8892BF.svg)](https://php.net/) [![License](https://poser.pugx.org/propel/propel/license.svg)](https://packagist.org/packages/propel/propel) - [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/propelorm/Propel) ## Requirements From bdacd54bf88035a1bf5fe38cfeab8acad9b28179 Mon Sep 17 00:00:00 2001 From: Cristiano Cinotti Date: Mon, 21 Dec 2020 08:19:32 +0100 Subject: [PATCH 203/208] Introduce PHP 8 --- .github/workflows/ci.yml | 9 +++-- composer.json | 10 +++++- phpstan-baseline.neon | 35 ++++++------------- .../Runtime/Collection/CollectionIterator.php | 2 -- 4 files changed, 25 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96195fd939..d232138124 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,12 +14,15 @@ jobs: strategy: fail-fast: false matrix: - php-version: [ '7.2', '7.4' ] + php-version: [ '7.2', '7.4', '8.0' ] db-type: [ sqlite, mysql, pgsql, agnostic ] symfony-version: [ '3-min', '3-max', '4-min', '4-max', '5-min', '5-max' ] + exclude: + - php-version: '8.0' + symfony-version: '4-min' steps: - name: Install PostgreSQL latest - if: matrix.db-type == 'pgsql' && matrix.php-version == '7.4' + if: matrix.db-type == 'pgsql' && matrix.php-version != '7.2' uses: CasperWA/postgresql-action@v1.2 with: postgresql db: 'propel-tests' @@ -36,7 +39,7 @@ jobs: postgresql password: 'postgres' - name: Install MariaDb latest - if: matrix.db-type == 'mysql' && matrix.php-version == '7.4' + if: matrix.db-type == 'mysql' && matrix.php-version != '7.2' uses: getong/mariadb-action@v1.1 - name: Install MariaDb min diff --git a/composer.json b/composer.json index b8043e9f47..64e43610c6 100644 --- a/composer.json +++ b/composer.json @@ -54,11 +54,19 @@ "psalm": "vendor/bin/psalm.phar --show-info=false", "psalm-update-baseline": "vendor/bin/psalm.phar --update-baseline", "psalm-set-baseline": "vendor/bin/psalm.phar --set-baseline=psalm-baseline.xml", - "psalm-update-report": "vendor/bin/psalm.phar --report=psalm-report.xml" + "psalm-update-report": "vendor/bin/psalm.phar --report=psalm-report.xml", + "test": "phpunit --colors=always", + "test:agnostic": "@test -c tests/agnostic.phpunit.xml", + "test:mysql": "@test -c tests/mysql.phpunit.xml", + "test:sqlite": "@test -c tests/sqlite.phpunit.xml", + "test:pgsql": "@test -c tests/pgsql.phpunit.xml" }, "extra": { "branch-alias": { "dev-master": "2.0-dev" } + }, + "config": { + "process-timeout": 0 } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e02566ea77..2381e9e67e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -45,21 +45,6 @@ parameters: count: 1 path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php - - - message: "#^Variable \\$paramsDoc might not be defined\\.$#" - count: 4 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php - - - - message: "#^Variable \\$methodSignature might not be defined\\.$#" - count: 10 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php - - - - message: "#^Variable \\$buildScope might not be defined\\.$#" - count: 1 - path: src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php - - message: "#^Access to an undefined property Propel\\\\Generator\\\\Model\\\\Table\\:\\:\\$isVersionTable\\.$#" count: 1 @@ -555,16 +540,6 @@ parameters: count: 1 path: src/Propel/Runtime/Adapter/Pdo/MssqlAdapter.php - - - message: "#^Variable \\$dbMap might not be defined\\.$#" - count: 1 - path: src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php - - - - message: "#^Variable \\$params might not be defined\\.$#" - count: 1 - path: src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\Connection\\\\ConnectionInterface\\:\\:sqliteCreateFunction\\(\\)\\.$#" count: 1 @@ -610,6 +585,16 @@ parameters: count: 1 path: src/Propel/Runtime/Collection/ArrayCollection.php + - + message: "#^Method ArrayIterator\\\\:\\:asort\\(\\) invoked with 1 parameter, 0 required\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/CollectionIterator.php + + - + message: "#^Method ArrayIterator\\\\:\\:ksort\\(\\) invoked with 1 parameter, 0 required\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/CollectionIterator.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:save\\(\\)\\.$#" count: 1 diff --git a/src/Propel/Runtime/Collection/CollectionIterator.php b/src/Propel/Runtime/Collection/CollectionIterator.php index 775f237a4e..db3f4716b5 100644 --- a/src/Propel/Runtime/Collection/CollectionIterator.php +++ b/src/Propel/Runtime/Collection/CollectionIterator.php @@ -235,7 +235,6 @@ public function append($value) */ public function asort($sort_flags = SORT_REGULAR) { - /* @phpstan-ignore-next-line */ parent::asort($sort_flags); $this->refreshPositions(); } @@ -247,7 +246,6 @@ public function asort($sort_flags = SORT_REGULAR) */ public function ksort($sort_flags = SORT_REGULAR) { - /* @phpstan-ignore-next-line */ parent::ksort($sort_flags); $this->refreshPositions(); } From 9c8306532f1163b2598562681b95ca7f0856b540 Mon Sep 17 00:00:00 2001 From: Cristiano Cinotti Date: Sun, 27 Dec 2020 13:28:05 +0100 Subject: [PATCH 204/208] Speed up some tests Speed up some tests by mocking filesystem, with `mikey176/vfsstream` library. --- composer.json | 3 +- .../Tests/Common/Config/ConfigTestCase.php | 50 ------ .../Config/ConfigurationManagerTest.php | 168 +++++++----------- .../Common/Config/Loader/FileLoaderTest.php | 1 + .../Config/Loader/IniFileLoaderTest.php | 46 ++--- .../Config/Loader/JsonFileLoaderTest.php | 21 +-- .../Config/Loader/PhpFileLoaderTest.php | 20 ++- .../Config/Loader/XmlFileLoaderTest.php | 20 ++- .../Config/Loader/YamlFileLoaderTest.php | 21 +-- .../Common/Config/XmlToArrayConverterTest.php | 20 ++- .../Generator/Config/GeneratorConfigTest.php | 10 +- tests/Propel/Tests/VfsTrait.php | 83 +++++++++ tests/composer/composer-php8.json | 3 +- tests/composer/composer-symfony3-max.json | 3 +- tests/composer/composer-symfony3-min.json | 3 +- tests/composer/composer-symfony4-max.json | 3 +- tests/composer/composer-symfony4-min.json | 3 +- tests/composer/composer-symfony5-max.json | 3 +- tests/composer/composer-symfony5-min.json | 3 +- 19 files changed, 255 insertions(+), 229 deletions(-) delete mode 100644 tests/Propel/Tests/Common/Config/ConfigTestCase.php create mode 100644 tests/Propel/Tests/VfsTrait.php diff --git a/composer.json b/composer.json index 64e43610c6..906294d3dc 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,8 @@ "phpstan/phpstan": "^0.12.4", "phpunit/phpunit": "^8.0.0||^9.0.0", "spryker/code-sniffer": "^0.15.6", - "psalm/phar": "4.2.1" + "psalm/phar": "4.2.1", + "mikey179/vfsstream": "^1.6" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." diff --git a/tests/Propel/Tests/Common/Config/ConfigTestCase.php b/tests/Propel/Tests/Common/Config/ConfigTestCase.php deleted file mode 100644 index 38e4d04e44..0000000000 --- a/tests/Propel/Tests/Common/Config/ConfigTestCase.php +++ /dev/null @@ -1,50 +0,0 @@ -fileSystem) { - $this->fileSystem = new Filesystem(); - } - - return $this->fileSystem; - } - - /** - * Create a temporary config file inside the system temporary directory - * - * @param string $filename File Name - * @param string $content File content - * - * @return void - */ - public function dumpTempFile($filename, $content) - { - $this->getFilesystem()->dumpFile(sys_get_temp_dir() . '/' . $filename, $content); - } -} diff --git a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php index 2695b8aeba..8461b103e4 100644 --- a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php +++ b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php @@ -8,45 +8,18 @@ namespace Propel\Tests\Common\Config; +use org\bovigo\vfs\vfsStream; use Propel\Common\Config\ConfigurationManager; use Propel\Common\Config\Exception\InvalidArgumentException; +use Propel\Tests\TestCase; +use Propel\Tests\VfsTrait; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; -class ConfigurationManagerTest extends ConfigTestCase +class ConfigurationManagerTest extends TestCase { + use VfsTrait; use DataProviderTrait; - /** - * Current working directory - */ - private $currentDir; - - /** - * Directory in which to create temporary fixtures - */ - private $fixturesDir; - - /** - * @return void - */ - public function setUp(): void - { - $this->currentDir = getcwd(); - $this->fixturesDir = realpath(__DIR__ . '/../../../../Fixtures') . '/Configuration'; - - $this->getFilesystem()->mkdir($this->fixturesDir); - chdir($this->fixturesDir); - } - - /** - * @return void - */ - public function tearDown(): void - { - chdir($this->currentDir); - $this->getFileSystem()->remove($this->fixturesDir); - } - /** * @return void */ @@ -56,9 +29,9 @@ public function testLoadConfigFileInCurrentDirectory() foo: bar bar: baz EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); + $this->newFile('propel.yaml', $yamlConf); - $manager = new TestableConfigurationManager(); + $manager = new TestableConfigurationManager($this->getRoot()->url()); $actual = $manager->get(); $this->assertEquals('bar', $actual['foo']); @@ -74,9 +47,8 @@ public function testLoadConfigFileInConfigSubdirectory() foo: bar bar: baz EOF; - $this->getFilesystem()->dumpFile('config/propel.yaml', $yamlConf); - - $manager = new TestableConfigurationManager(); + $this->newFile('config/propel.yaml', $yamlConf); + $manager = new TestableConfigurationManager($this->getRoot()->url()); $actual = $manager->get(); $this->assertEquals('bar', $actual['foo']); @@ -92,9 +64,8 @@ public function testLoadConfigFileInConfSubdirectory() foo: bar bar: baz EOF; - $this->getFilesystem()->dumpFile('conf/propel.yaml', $yamlConf); - - $manager = new TestableConfigurationManager(); + $this->newFile('conf/propel.yaml', $yamlConf); + $manager = new TestableConfigurationManager($this->getRoot()->url()); $actual = $manager->get(); $this->assertEquals('bar', $actual['foo']); @@ -110,10 +81,10 @@ public function testNotExistingConfigFileLoadsDefaultSettingsAndDoesNotThrowExce foo: bar bar: baz EOF; - $this->getFilesystem()->dumpFile('doctrine.yaml', $yamlConf); + $this->newFile('doctrine.yaml', $yamlConf); - $manager = new TestableConfigurationManager(); - $this->assertInstanceOf(ConfigurationManager::class, $manager); + $manager = new TestableConfigurationManager($this->getRoot()->url()); + $this->assertNull($manager->getConfigProperty('general.version')); } /** @@ -125,10 +96,10 @@ public function testBackupConfigFilesAreIgnored() foo: bar bar: baz EOF; - $this->getFilesystem()->dumpFile('propel.yaml.bak', $yamlConf); - $this->getFilesystem()->dumpFile('propel.yaml~', $yamlConf); + $this->newFile('propel.yaml.bak', $yamlConf); + $this->newFile('propel.yaml~', $yamlConf); - $manager = new TestableConfigurationManager(); + $manager = new TestableConfigurationManager($this->getRoot()->url()); $actual = $manager->get(); $this->assertArrayNotHasKey('bar', $actual); @@ -144,9 +115,9 @@ public function testUnsupportedExtensionsAreIgnored() foo: bar bar: baz EOF; - $this->getFilesystem()->dumpFile('propel.log', $yamlConf); + $this->newFile('propel.log', $yamlConf); - $manager = new TestableConfigurationManager(); + $manager = new TestableConfigurationManager($this->getRoot()->url()); $actual = $manager->get(); $this->assertArrayNotHasKey('bar', $actual); @@ -169,10 +140,10 @@ public function testMoreThanOneConfigurationFileInSameDirectoryThrowsException() foo = bar bar = baz EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); - $this->getFilesystem()->dumpFile('propel.ini', $iniConf); + $this->newFile('propel.yaml', $yamlConf); + $this->newFile('propel.ini', $iniConf); - $manager = new TestableConfigurationManager(); + $manager = new TestableConfigurationManager($this->getRoot()->url()); } /** @@ -191,10 +162,10 @@ public function testMoreThanOneConfigurationFileInDifferentDirectoriesThrowsExce foo = bar bar = baz EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); - $this->getFilesystem()->dumpFile('conf/propel.ini', $iniConf); + $this->newFile('propel.yaml', $yamlConf); + $this->newFile('conf/propel.ini', $iniConf); - $manager = new TestableConfigurationManager(); + $manager = new TestableConfigurationManager($this->getRoot()->url()); } /** @@ -210,9 +181,9 @@ public function testGetSection() bfoo: bbar bbar: bbaz EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); + $this->newFile('propel.yaml', $yamlConf); - $manager = new TestableConfigurationManager(); + $manager = new TestableConfigurationManager($this->getRoot()->url()); $actual = $manager->getSection('buildtime'); $this->assertEquals('bbar', $actual['bfoo']); @@ -228,9 +199,9 @@ public function testLoadGivenConfigFile() foo: bar bar: baz EOF; - $this->getFilesystem()->dumpFile('myDir/mySubdir/myConfigFile.yaml', $yamlConf); + $file = $this->newFile('myDir/mySubdir/myConfigFile.yaml', $yamlConf); - $manager = new TestableConfigurationManager('myDir/mySubdir/myConfigFile.yaml'); + $manager = new TestableConfigurationManager($file->url()); $actual = $manager->get(); $this->assertEquals(['foo' => 'bar', 'bar' => 'baz'], $actual); @@ -252,10 +223,10 @@ public function testLoadAlsoDistConfigFile() bar: baz EOF; - $this->getFilesystem()->dumpFile('propel.yaml.dist', $yamlDistConf); - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); + $this->newFile('propel.yaml.dist', $yamlDistConf); + $this->newFile('propel.yaml', $yamlConf); - $manager = new TestableConfigurationManager(); + $manager = new TestableConfigurationManager($this->getRoot()->url()); $actual = $manager->get(); $this->assertEquals(['bfoo' => 'bbar', 'bbar' => 'bbaz'], $actual['buildtime']); @@ -273,9 +244,9 @@ public function testLoadOnlyDistFile() bar: baz EOF; - $this->getFilesystem()->dumpFile('propel.yaml.dist', $yamlDistConf); + $this->newFile('propel.yaml.dist', $yamlDistConf); - $manager = new TestableConfigurationManager(); + $manager = new TestableConfigurationManager($this->getRoot()->url()); $actual = $manager->get(); $this->assertEquals(['runtime' => ['foo' => 'bar', 'bar' => 'baz']], $actual); @@ -296,10 +267,10 @@ public function testLoadGivenFileAndDist() foo: bar bar: baz EOF; - $this->getFilesystem()->dumpFile('myDir/mySubdir/myConfigFile.yaml', $yamlConf); - $this->getFilesystem()->dumpFile('myDir/mySubdir/myConfigFile.yaml.dist', $yamlDistConf); + $file = $this->newFile('myDir/mySubdir/myConfigFile.yaml', $yamlConf); + $this->newFile('myDir/mySubdir/myConfigFile.yaml.dist', $yamlDistConf); - $manager = new TestableConfigurationManager('myDir/mySubdir/myConfigFile.yaml'); + $manager = new TestableConfigurationManager($file->url()); $actual = $manager->get(); $this->assertEquals(['foo' => 'bar', 'bar' => 'baz'], $actual['runtime']); @@ -316,9 +287,9 @@ public function testLoadDistGivenFileOnly() foo: bar bar: baz EOF; - $this->getFilesystem()->dumpFile('myDir/mySubdir/myConfigFile.yaml.dist', $yamlDistConf); + $file = $this->newFile('myDir/mySubdir/myConfigFile.yaml.dist', $yamlDistConf); - $manager = new TestableConfigurationManager('myDir/mySubdir/myConfigFile.yaml.dist'); + $manager = new TestableConfigurationManager($file->url()); $actual = $manager->get(); $this->assertEquals(['runtime' => ['foo' => 'bar', 'bar' => 'baz']], $actual); @@ -339,10 +310,9 @@ public function testLoadInGivenDirectory() foo: bar bar: baz EOF; - $this->getFilesystem()->dumpFile('myDir/mySubdir/propel.yaml', $yamlConf); - $this->getFilesystem()->dumpFile('myDir/mySubdir/propel.yaml.dist', $yamlDistConf); - - $manager = new TestableConfigurationManager('myDir/mySubdir/'); + $this->newFile('myDir/mySubdir/propel.yaml', $yamlConf); + $this->newFile('myDir/mySubdir/propel.yaml.dist', $yamlDistConf); + $manager = new TestableConfigurationManager(vfsStream::url('root/myDir/mySubdir/')); $actual = $manager->get(); $this->assertEquals(['foo' => 'bar', 'bar' => 'baz'], $actual['runtime']); @@ -372,9 +342,9 @@ public function testMergeExtraProperties() bfoo: bbar bbar: bbaz EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); + $this->newFile('propel.yaml', $yamlConf); - $manager = new TestableConfigurationManager(null, $extraConf); + $manager = new TestableConfigurationManager($this->getRoot()->url(), $extraConf); $actual = $manager->get(); $this->assertEquals($actual['runtime'], ['foo' => 'bar', 'bar' => 'baz']); @@ -398,9 +368,9 @@ public function testInvalidHierarchyTrowsException() bfoo: bbar bbar: bbaz EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); + $this->newFile('propel.yaml', $yamlConf); - new ConfigurationManager(); + $manager = new ConfigurationManager($this->getRoot()->url()); } /** @@ -422,9 +392,9 @@ classname: Propel\Runtime\Connection\ConnectionWrapper user: password: EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); + $this->newFile('propel.yaml', $yamlConf); - $manager = new ConfigurationManager(); + $manager = new ConfigurationManager($this->getRoot()->url()); $this->assertArrayHasKey('runtime', $manager->get()); $this->assertArrayHasKey('generator', $manager->get()); @@ -451,9 +421,9 @@ public function testNotDefineDatabaseSectionTrowsException() project: MyAwesomeProject version: 2.0.0-dev EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); + $this->newFile('propel.yaml', $yamlConf); - new ConfigurationManager(); + $manager = new ConfigurationManager($this->getRoot()->url()); } /** @@ -484,9 +454,9 @@ classname: Propel\Runtime\Connection\DebugPDO connections: - mysource EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); + $this->newFile('propel.yaml', $yamlConf); - new ConfigurationManager(); + $manager = new ConfigurationManager($this->getRoot()->url()); } /** @@ -498,8 +468,8 @@ public function testRuntimeOrGeneratorConnectionIsNotInConfiguredConnectionsThro { $this->expectException(InvalidConfigurationException::class); - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); - new ConfigurationManager(); + $this->newFile('propel.yaml', $yamlConf); + $manager = new ConfigurationManager($this->getRoot()->url()); } /** @@ -511,8 +481,8 @@ public function testRuntimeOrGeneratorDefaultConnectionIsNotInConfiguredConnecti { $this->expectException(InvalidConfigurationException::class); - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); - new ConfigurationManager(); + $this->newFile('propel.yaml', $yamlConf); + $manager = new ConfigurationManager($this->getRoot()->url()); } /** @@ -549,9 +519,9 @@ classname: Propel\Runtime\Connection\DebugPDO - mysource - yoursource EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); + $this->newFile('propel.yaml', $yamlConf); - $manager = new ConfigurationManager(); + $manager = new ConfigurationManager($this->getRoot()->url()); $actual = $manager->getSection('runtime'); $this->assertEquals($actual['defaultConnection'], 'mysource'); @@ -592,9 +562,9 @@ classname: Propel\Runtime\Connection\DebugPDO - mysource - yoursource EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); + $this->newFile('propel.yaml', $yamlConf); - $manager = new ConfigurationManager(); + $manager = new ConfigurationManager($this->getRoot()->url()); $actual = $manager->get(); $this->assertTrue($actual['generator']['namespaceAutoPackage']); @@ -638,9 +608,9 @@ classname: Propel\Runtime\Connection\DebugPDO - mysource - yoursource EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); + $this->newFile('propel.yaml', $yamlConf); - $manager = new ConfigurationManager(); + $manager = new ConfigurationManager($this->getRoot()->url()); $this->assertEquals('mysource', $manager->getConfigProperty('runtime.defaultConnection')); $this->assertEquals('yoursource', $manager->getConfigProperty('runtime.connections.1')); $this->assertEquals('root', $manager->getConfigProperty('database.connections.mysource.user')); @@ -683,7 +653,7 @@ classname: Propel\Runtime\Connection\DebugPDO - mysource - yoursource EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); + $this->newFile('propel.yaml', $yamlConf); $manager = new ConfigurationManager(); $manager->getConfigProperty(10); @@ -723,9 +693,9 @@ classname: Propel\Runtime\Connection\DebugPDO - mysource - yoursource EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); + $this->newFile('propel.yaml', $yamlConf); - $manager = new ConfigurationManager(); + $manager = new ConfigurationManager($this->getRoot()->url()); $value = $manager->getConfigProperty('database.connections.adapter'); $this->assertNull($value); @@ -813,7 +783,7 @@ classname: Propel\Runtime\Connection\DebugPDO connections: - mysource EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); + $this->newFile('propel.yaml', $yamlConf); $expectedRuntime = [ 'mysource' => [ @@ -852,7 +822,7 @@ classname: Propel\Runtime\Connection\DebugPDO ], ]; - $manager = new ConfigurationManager(); + $manager = new ConfigurationManager($this->getRoot()->url()); $this->assertEquals($expectedRuntime, $manager->getConnectionParametersArray('runtime')); $this->assertEquals($expectedRuntime, $manager->getConnectionParametersArray()); //default `runtime` $this->assertEquals($expectedGenerator, $manager->getConnectionParametersArray('generator')); @@ -881,8 +851,8 @@ classname: Propel\Runtime\Connection\DebugPDO user: root password: EOF; - $this->getFilesystem()->dumpFile('propel.yaml', $yamlConf); - $manager = new ConfigurationManager(); + $this->newFile('propel.yaml', $yamlConf); + $manager = new ConfigurationManager($this->getRoot()->url()); $this->assertEquals('mysource', $manager->getSection('generator')['defaultConnection']); $this->assertEquals('mysource', $manager->getSection('runtime')['defaultConnection']); diff --git a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php index 626f9c1279..81b6518c40 100644 --- a/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php @@ -15,6 +15,7 @@ class FileLoaderTest extends TestCase { + /** @var TestableFileLoader */ private $loader; /** diff --git a/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php index c1d05d180a..0b66e16cfc 100644 --- a/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php @@ -8,16 +8,20 @@ namespace Propel\Tests\Common\Config\Loader; -use InvalidArgumentException; use Propel\Common\Config\Exception\IniParseException; use Propel\Common\Config\Exception\InputOutputException; -use Propel\Common\Config\Exception\InvalidArgumentException as PropelInvalidArgumentException; -use Propel\Common\Config\FileLocator; +use Propel\Common\Config\Exception\InvalidArgumentException; use Propel\Common\Config\Loader\IniFileLoader; -use Propel\Tests\Common\Config\ConfigTestCase; +use Propel\Common\Config\FileLocator; +use Propel\Tests\TestCase; +use Propel\Tests\VfsTrait; +use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException; -class IniFileLoaderTest extends ConfigTestCase +class IniFileLoaderTest extends TestCase { + use VfsTrait; + + /** @var IniFileLoader */ protected $loader; /** @@ -25,7 +29,7 @@ class IniFileLoaderTest extends ConfigTestCase */ protected function setUp(): void { - $this->loader = new IniFileLoader(new FileLocator(sys_get_temp_dir())); + $this->loader = new IniFileLoader(new FileLocator($this->getRoot()->url())); } /** @@ -51,7 +55,7 @@ public function testIniFileCanBeLoaded() foo = bar bar = baz EOF; - $this->dumpTempFile('parameters.ini', $content); + $this->newFile('parameters.ini', $content); $test = $this->loader->load('parameters.ini'); $this->assertEquals('bar', $test['foo']); @@ -63,7 +67,7 @@ public function testIniFileCanBeLoaded() */ public function testIniFileDoesNotExist() { - $this->expectException(InvalidArgumentException::class); + $this->expectException(FileLocatorFileNotFoundException::class); $this->expectExceptionMessage('The file "inexistent.ini" does not exist (in:'); $this->loader->load('inexistent.ini'); @@ -74,7 +78,7 @@ public function testIniFileDoesNotExist() */ public function testIniFileHasInvalidContent() { - $this->expectException(PropelInvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The configuration file 'nonvalid.ini' has invalid content."); $content = <<dumpTempFile('nonvalid.ini', $content); - + $this->newFile('nonvalid.ini', $content); @$this->loader->load('nonvalid.ini'); } @@ -92,8 +95,7 @@ public function testIniFileHasInvalidContent() */ public function testIniFileIsEmpty() { - $content = ''; - $this->dumpTempFile('empty.ini', $content); + $this->newFile('empty.ini'); $actual = $this->loader->load('empty.ini'); @@ -113,7 +115,7 @@ public function testWithSections() Donald[] = Louie Mickey[love] = Minnie EOF; - $this->dumpTempFile('section.ini', $content); + $this->newFile('section.ini', $content); $actual = $this->loader->load('section.ini'); $this->assertEquals('Pluto', $actual['Cartoons']['Dog']); @@ -134,7 +136,7 @@ public function testNestedSections() bla.foo = blafoo bla.bar = blabar EOF; - $this->dumpTempFile('nested.ini', $content); + $this->newFile('nested.ini', $content); $actual = $this->loader->load('nested.ini'); $this->assertEquals('foobar', $actual['foo']['bar']['baz']); @@ -155,7 +157,7 @@ public function testMixedNestedSections() bla.foo.baz[] = foobaz2 EOF; - $this->dumpTempFile('mixnested.ini', $content); + $this->newFile('mixnested.ini', $content); $actual = $this->loader->load('mixnested.ini'); $this->assertEquals('foobar', $actual['bla']['foo']['bar']); @@ -176,7 +178,7 @@ public function testInvalidSectionThrowsException() .foo = bar bar = baz EOF; - $this->dumpTempFile('parameters.ini', $content); + $this->newFile('parameters.ini', $content); $test = $this->loader->load('parameters.ini'); } @@ -193,7 +195,7 @@ public function testInvalidParamThrowsException() foo. = bar bar = baz EOF; - $this->dumpTempFile('parameters.ini', $content); + $this->newFile('parameters.ini', $content); $test = $this->loader->load('parameters.ini'); } @@ -210,7 +212,7 @@ public function testAlreadyExistentParamThrowsException() foo = bar foo.babar = baz EOF; - $this->dumpTempFile('parameters.ini', $content); + $this->newFile('parameters.ini', $content); $test = $this->loader->load('parameters.ini'); } @@ -224,7 +226,7 @@ public function testSectionZero() foo = bar 0.babar = baz EOF; - $this->dumpTempFile('parameters.ini', $content); + $this->newFile('parameters.ini', $content); $this->assertEquals(['0' => ['foo' => 'bar', 'babar' => 'baz']], $this->loader->load('parameters.ini')); } @@ -243,9 +245,7 @@ public function testIniFileNotReadableThrowsException() foo = bar bar = baz EOF; - - $this->dumpTempFile('notreadable.ini', $content); - $this->getFilesystem()->chmod(sys_get_temp_dir() . '/notreadable.ini', 0200); + $this->newFile('notreadable.ini', $content)->chmod(200); $actual = $this->loader->load('notreadable.ini'); $this->assertEquals('bar', $actual['foo']); diff --git a/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php index 11c1362fa3..bb852fceb1 100644 --- a/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php @@ -13,10 +13,14 @@ use Propel\Common\Config\Exception\JsonParseException; use Propel\Common\Config\FileLocator; use Propel\Common\Config\Loader\JsonFileLoader; -use Propel\Tests\Common\Config\ConfigTestCase; +use Propel\Tests\TestCase; +use Propel\Tests\VfsTrait; -class JsonFileLoaderTest extends ConfigTestCase +class JsonFileLoaderTest extends TestCase { + use VfsTrait; + + /** @var JsonFileLoader */ protected $loader; /** @@ -24,7 +28,7 @@ class JsonFileLoaderTest extends ConfigTestCase */ protected function setUp(): void { - $this->loader = new JsonFileLoader(new FileLocator(sys_get_temp_dir())); + $this->loader = new JsonFileLoader(new FileLocator($this->getRoot()->url())); } /** @@ -49,7 +53,7 @@ public function testJsonFileCanBeLoaded() "bar": "baz" } EOF; - $this->dumpTempFile('parameters.json', $content); + $this->newFile('parameters.json', $content); $actual = $this->loader->load('parameters.json'); $this->assertEquals('bar', $actual['foo']); @@ -79,7 +83,7 @@ public function testJsonFileHasInvalidContent() only plain text EOF; - $this->dumpTempFile('nonvalid.json', $content); + $this->newFile('nonvalid.json', $content); $this->loader->load('nonvalid.json'); } @@ -89,8 +93,7 @@ public function testJsonFileHasInvalidContent() */ public function testJsonFileIsEmpty() { - $content = ''; - $this->dumpTempFile('empty.json', $content); + $this->newFile('empty.json'); $actual = $this->loader->load('empty.json'); @@ -113,9 +116,7 @@ public function testJsonFileNotReadableThrowsException() "bar": "baz" } EOF; - - $this->dumpTempFile('notreadable.json', $content); - $this->getFilesystem()->chmod(sys_get_temp_dir() . '/notreadable.json', 0200); + $this->newFile('notreadable.json', $content)->chmod(200); $actual = $this->loader->load('notreadable.json'); $this->assertEquals('bar', $actual['foo']); diff --git a/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php index a472824488..133c06a934 100644 --- a/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php @@ -13,10 +13,14 @@ use Propel\Common\Config\Exception\InvalidArgumentException as PropelInvalidArgumentException; use Propel\Common\Config\FileLocator; use Propel\Common\Config\Loader\PhpFileLoader; -use Propel\Tests\Common\Config\ConfigTestCase; +use Propel\Tests\TestCase; +use Propel\Tests\VfsTrait; -class PhpFileLoaderTest extends ConfigTestCase +class PhpFileLoaderTest extends TestCase { + use VfsTrait; + + /** @var PhpFileLoader */ protected $loader; /** @@ -24,7 +28,7 @@ class PhpFileLoaderTest extends ConfigTestCase */ protected function setUp(): void { - $this->loader = new PhpFileLoader(new FileLocator(sys_get_temp_dir())); + $this->loader = new PhpFileLoader(new FileLocator($this->getRoot()->url())); } /** @@ -51,7 +55,7 @@ public function testPhpFileCanBeLoaded() return array('foo' => 'bar', 'bar' => 'baz'); EOF; - $this->dumpTempFile('parameters.php', $content); + $this->newFile('parameters.php', $content); $test = $this->loader->load('parameters.php'); $this->assertEquals('bar', $test['foo']); $this->assertEquals('baz', $test['bar']); @@ -81,7 +85,7 @@ public function testPhpFileHasInvalidContent() only plain text EOF; - $this->dumpTempFile('nonvalid.php', $content); + $this->newFile('nonvalid.php', $content); $this->loader->load('nonvalid.php'); } @@ -93,8 +97,7 @@ public function testPhpFileIsEmpty() $this->expectException(PropelInvalidArgumentException::class); $this->expectExceptionMessage("The configuration file 'empty.php' has invalid content."); - $content = ''; - $this->dumpTempFile('empty.php', $content); + $this->newFile('empty.php'); $this->loader->load('empty.php'); } @@ -116,8 +119,7 @@ public function testConfigFileNotReadableThrowsException() EOF; - $this->dumpTempFile('notreadable.php', $content); - $this->getFilesystem()->chmod(sys_get_temp_dir() . '/notreadable.php', 0200); + $this->newFile('notreadable.php', $content)->chmod(200); $actual = $this->loader->load('notreadable.php'); $this->assertEquals('bar', $actual['foo']); diff --git a/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php index d5e393aa57..b0329cc5ce 100644 --- a/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php @@ -13,10 +13,14 @@ use Propel\Common\Config\Exception\InvalidArgumentException as PropelInvalidArgumentException; use Propel\Common\Config\FileLocator; use Propel\Common\Config\Loader\XmlFileLoader; -use Propel\Tests\Common\Config\ConfigTestCase; +use Propel\Tests\TestCase; +use Propel\Tests\VfsTrait; -class XmlFileLoaderTest extends ConfigTestCase +class XmlFileLoaderTest extends TestCase { + use VfsTrait; + + /** @var XmlFileLoader */ protected $loader; /** @@ -24,7 +28,7 @@ class XmlFileLoaderTest extends ConfigTestCase */ protected function setUp(): void { - $this->loader = new XmlFileLoader(new FileLocator(sys_get_temp_dir())); + $this->loader = new XmlFileLoader(new FileLocator($this->getRoot()->url())); } /** @@ -51,7 +55,7 @@ public function testXmlFileCanBeLoaded() baz
XML; - $this->dumpTempFile('parameters.xml', $content); + $this->newFile('parameters.xml', $content); $test = $this->loader->load('parameters.xml'); $this->assertEquals('bar', $test['foo']); @@ -82,7 +86,7 @@ public function testXmlFileHasInvalidContent() only plain text EOF; - $this->dumpTempFile('nonvalid.xml', $content); + $this->newFile('nonvalid.xml', $content); @$this->loader->load('nonvalid.xml'); } @@ -92,8 +96,7 @@ public function testXmlFileHasInvalidContent() */ public function testXmlFileIsEmpty() { - $content = ''; - $this->dumpTempFile('empty.xml', $content); + $this->newFile('empty.xml', ''); $actual = $this->loader->load('empty.xml'); @@ -118,8 +121,7 @@ public function testXmlFileNotReadableThrowsException() XML; - $this->dumpTempFile('notreadable.xml', $content); - $this->getFilesystem()->chmod(sys_get_temp_dir() . '/notreadable.xml', 0200); + $this->newFile('notreadable.xml', $content)->chmod(200); $actual = $this->loader->load('notreadable.xml'); $this->assertEquals('bar', $actual['foo']); diff --git a/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php index 22b31b6cf8..a76fe7cb75 100644 --- a/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php @@ -12,11 +12,15 @@ use Propel\Common\Config\Exception\InputOutputException; use Propel\Common\Config\FileLocator; use Propel\Common\Config\Loader\YamlFileLoader; -use Propel\Tests\Common\Config\ConfigTestCase; +use Propel\Tests\TestCase; +use Propel\Tests\VfsTrait; use Symfony\Component\Yaml\Exception\ParseException; -class YamlFileLoaderTest extends ConfigTestCase +class YamlFileLoaderTest extends TestCase { + use VfsTrait; + + /** @var YamlFileLoader */ protected $loader; /** @@ -24,7 +28,7 @@ class YamlFileLoaderTest extends ConfigTestCase */ protected function setUp(): void { - $this->loader = new YamlFileLoader(new FileLocator(sys_get_temp_dir())); + $this->loader = new YamlFileLoader(new FileLocator($this->getRoot()->url())); } /** @@ -50,7 +54,7 @@ public function testYamlFileCanBeLoaded() foo: bar bar: baz EOF; - $this->dumpTempFile('parameters.yaml', $content); + $this->newFile('parameters.yaml', $content); $test = $this->loader->load('parameters.yaml'); $this->assertEquals('bar', $test['foo']); @@ -81,7 +85,7 @@ public function testYamlFileHasInvalidContent() only plain text EOF; - $this->dumpTempFile('nonvalid.yaml', $content); + $this->newFile('nonvalid.yaml', $content); $this->loader->load('nonvalid.yaml'); } @@ -90,8 +94,7 @@ public function testYamlFileHasInvalidContent() */ public function testYamlFileIsEmpty() { - $content = ''; - $this->dumpTempFile('empty.yaml', $content); + $this->newFile('empty.yaml', ''); $actual = $this->loader->load('empty.yaml'); @@ -112,9 +115,7 @@ public function testYamlFileNotReadableThrowsException() foo: bar bar: baz EOF; - - $this->dumpTempFile('notreadable.yaml', $content); - $this->getFilesystem()->chmod(sys_get_temp_dir() . '/notreadable.yaml', 0200); + $this->newFile('notreadable.yaml', $content)->chmod(200); $actual = $this->loader->load('notreadable.yaml'); $this->assertEquals('bar', $actual['foo']); diff --git a/tests/Propel/Tests/Common/Config/XmlToArrayConverterTest.php b/tests/Propel/Tests/Common/Config/XmlToArrayConverterTest.php index 02fda95436..15b4803ce6 100644 --- a/tests/Propel/Tests/Common/Config/XmlToArrayConverterTest.php +++ b/tests/Propel/Tests/Common/Config/XmlToArrayConverterTest.php @@ -8,12 +8,16 @@ namespace Propel\Tests\Common\Config; +use org\bovigo\vfs\vfsStream; use Propel\Common\Config\Exception\InvalidArgumentException; use Propel\Common\Config\Exception\XmlParseException; use Propel\Common\Config\XmlToArrayConverter; +use Propel\Tests\TestCase; +use Propel\Tests\VfsTrait; -class XmlToArrayConverterTest extends ConfigTestCase +class XmlToArrayConverterTest extends TestCase { + use VfsTrait; use DataProviderTrait; /** @@ -35,8 +39,8 @@ public function testConvertFromString($xml, $expected) */ public function testConvertFromFile($xml, $expected) { - $this->dumpTempFile('testconvert.xml', $xml); - $actual = XmlToArrayConverter::convert(sys_get_temp_dir() . '/testconvert.xml'); + $file = $this->newFile('testconvert.xml', $xml); + $actual = XmlToArrayConverter::convert($file->url()); $this->assertEquals($expected, $actual); } @@ -48,9 +52,9 @@ public function testConvertFromFile($xml, $expected) */ public function testConvertFromFileWithXmlInclusion($xmlLoad, $xmlInclude, $expected) { - $this->dumpTempFile('testconvert.xml', $xmlLoad); - $this->dumpTempFile('testconvert_include.xml', $xmlInclude); - $actual = XmlToArrayConverter::convert(sys_get_temp_dir() . '/testconvert.xml'); + $this->newFile('testconvert.xml', $xmlLoad); + $this->newFile('testconvert_include.xml', $xmlInclude); + $actual = XmlToArrayConverter::convert(vfsStream::url('root/testconvert.xml')); $this->assertEquals($expected, $actual); } @@ -141,8 +145,8 @@ public function testMultipleErrorsInXmlThrowsException() */ public function testEmptyFileReturnsEmptyArray() { - $this->dumpTempFile('empty.xml', ''); - $actual = XmlToArrayConverter::convert(sys_get_temp_dir() . '/empty.xml'); + $file = $this->newFile('empty.xml', ''); + $actual = XmlToArrayConverter::convert($file->url()); $this->assertEquals([], $actual); } diff --git a/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php b/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php index 567b2be9bb..53d37b1f7b 100644 --- a/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php +++ b/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php @@ -13,6 +13,8 @@ use Propel\Generator\Exception\ClassNotFoundException; use Propel\Generator\Exception\InvalidArgumentException; use Propel\Tests\Common\Config\ConfigTestCase; +use Propel\Tests\TestCase; +use Propel\Tests\VfsTrait; use ReflectionClass; /** @@ -20,8 +22,10 @@ * @author Cristiano Cinotti * @package propel.generator.config */ -class GeneratorConfigTest extends ConfigTestCase +class GeneratorConfigTest extends TestCase { + use VfsTrait; + protected $generatorConfig; /** @@ -81,9 +85,9 @@ public function setUp(): void ) ); "; - $this->dumpTempFile('propel.php.dist', $php); + $file = $this->newFile('propel.php.dist', $php); - $this->generatorConfig = new GeneratorConfig(sys_get_temp_dir() . '/propel.php.dist'); + $this->generatorConfig = new GeneratorConfig($file->url()); } /** diff --git a/tests/Propel/Tests/VfsTrait.php b/tests/Propel/Tests/VfsTrait.php new file mode 100644 index 0000000000..409c74d875 --- /dev/null +++ b/tests/Propel/Tests/VfsTrait.php @@ -0,0 +1,83 @@ +root) { + $this->root = vfsStream::setup(); + } + + return $this->root; + } + + /** + * Add a new file to the filesystem. + * If the path of the file contains a directory structure, or a directory not present in + * the virtual file system, it'll be created. + * + * @param string $filename + * @param string $content + * + * @return vfsStreamFile + */ + public function newFile(string $filename, string $content = ''): vfsStreamFile + { + $path = pathinfo($filename); + $dir = $this->getDir($path['dirname']); + + return vfsStream::newFile($filename)->at($dir)->setContent($content); + } + + /** + * Return the directory on which append a file. + * If the directory does not exists, it'll be created. If the directory name represents + * a structure (e.g. dir/sub_dir/sub_sub_dir) the structure is created. + * + * @param string $dirname + * + * @return vfsStreamDirectory + */ + private function getDir(string $dirname): vfsStreamDirectory + { + if ('.' === $dirname) { + return $this->getRoot(); + } + + $dirs = explode('/', $dirname); + $parent = $this->getRoot(); + foreach ($dirs as $dir) { + $current = $parent->getChild($dir); + if (null === $current) { + $current = vfsStream::newDirectory($dir)->at($parent); + } + $parent = $current; + } + + return $parent; + } +} diff --git a/tests/composer/composer-php8.json b/tests/composer/composer-php8.json index 6001d40f83..47900b47c9 100644 --- a/tests/composer/composer-php8.json +++ b/tests/composer/composer-php8.json @@ -30,7 +30,8 @@ }, "require-dev": { "monolog/monolog": "^1.3", - "phpunit/phpunit": "9.4.2" + "phpunit/phpunit": "9.4.2", + "mikey179/vfsstream": "^1.6" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." diff --git a/tests/composer/composer-symfony3-max.json b/tests/composer/composer-symfony3-max.json index 6b63ce42bd..627fa3e9ab 100644 --- a/tests/composer/composer-symfony3-max.json +++ b/tests/composer/composer-symfony3-max.json @@ -33,7 +33,8 @@ "phpstan/phpstan": "^0.12.4", "phpunit/phpunit": "^8.0.0||^9.0.0", "spryker/code-sniffer": "^0.15.6", - "psalm/phar": "^4.1.0" + "psalm/phar": "^4.1.0", + "mikey179/vfsstream": "^1.6" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." diff --git a/tests/composer/composer-symfony3-min.json b/tests/composer/composer-symfony3-min.json index 90c16c95e4..3d2967996c 100644 --- a/tests/composer/composer-symfony3-min.json +++ b/tests/composer/composer-symfony3-min.json @@ -33,7 +33,8 @@ "phpstan/phpstan": "^0.12.4", "phpunit/phpunit": "^8.0.0||^9.0.0", "spryker/code-sniffer": "^0.15.6", - "psalm/phar": "^4.1.0" + "psalm/phar": "^4.1.0", + "mikey179/vfsstream": "^1.6" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." diff --git a/tests/composer/composer-symfony4-max.json b/tests/composer/composer-symfony4-max.json index 67792d4352..1d93789765 100644 --- a/tests/composer/composer-symfony4-max.json +++ b/tests/composer/composer-symfony4-max.json @@ -33,7 +33,8 @@ "phpstan/phpstan": "^0.12.4", "phpunit/phpunit": "^8.0.0||^9.0.0", "spryker/code-sniffer": "^0.15.6", - "psalm/phar": "^4.1.0" + "psalm/phar": "^4.1.0", + "mikey179/vfsstream": "^1.6" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." diff --git a/tests/composer/composer-symfony4-min.json b/tests/composer/composer-symfony4-min.json index bb71a903d6..7166798a1a 100644 --- a/tests/composer/composer-symfony4-min.json +++ b/tests/composer/composer-symfony4-min.json @@ -33,7 +33,8 @@ "phpstan/phpstan": "^0.12.4", "phpunit/phpunit": "^8.0.0||^9.0.0", "spryker/code-sniffer": "^0.15.6", - "psalm/phar": "^4.1.0" + "psalm/phar": "^4.1.0", + "mikey179/vfsstream": "^1.6" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." diff --git a/tests/composer/composer-symfony5-max.json b/tests/composer/composer-symfony5-max.json index 77b9b57c33..1575afe33b 100644 --- a/tests/composer/composer-symfony5-max.json +++ b/tests/composer/composer-symfony5-max.json @@ -33,7 +33,8 @@ "phpstan/phpstan": "^0.12.4", "phpunit/phpunit": "^8.0.0||^9.0.0", "spryker/code-sniffer": "^0.15.6", - "psalm/phar": "^4.1.0" + "psalm/phar": "^4.1.0", + "mikey179/vfsstream": "^1.6" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." diff --git a/tests/composer/composer-symfony5-min.json b/tests/composer/composer-symfony5-min.json index 3c4f799aff..1a278ea34e 100644 --- a/tests/composer/composer-symfony5-min.json +++ b/tests/composer/composer-symfony5-min.json @@ -33,7 +33,8 @@ "phpstan/phpstan": "^0.12.4", "phpunit/phpunit": "^8.0.0||^9.0.0", "spryker/code-sniffer": "^0.15.6", - "psalm/phar": "^4.1.0" + "psalm/phar": "^4.1.0", + "mikey179/vfsstream": "^1.6" }, "suggest": { "monolog/monolog": "The recommended logging library to use with Propel." From bbe861eec4d2861c779527037a97a3937f5732df Mon Sep 17 00:00:00 2001 From: Cristiano Cinotti Date: Sun, 27 Dec 2020 18:43:47 +0100 Subject: [PATCH 205/208] Continue mocking filesystem Move some other tests from physical to virtual filesystem. --- .../Tests/Generator/Model/DatabaseTest.php | 10 ++++---- .../MysqlPlatformMigrationMyISAMTest.php | 8 ++++--- .../Platform/MysqlPlatformMigrationTest.php | 8 ++++--- .../Runtime/Parser/AbstractParserTest.php | 24 ++++++++++++++----- .../Runtime/Parser/fixtures/test_data.xml | 6 ----- 5 files changed, 33 insertions(+), 23 deletions(-) delete mode 100644 tests/Propel/Tests/Runtime/Parser/fixtures/test_data.xml diff --git a/tests/Propel/Tests/Generator/Model/DatabaseTest.php b/tests/Propel/Tests/Generator/Model/DatabaseTest.php index c08a487850..e6c2047f1d 100644 --- a/tests/Propel/Tests/Generator/Model/DatabaseTest.php +++ b/tests/Propel/Tests/Generator/Model/DatabaseTest.php @@ -17,6 +17,7 @@ use Propel\Generator\Model\Table; use Propel\Generator\Platform\MysqlPlatform; use Propel\Generator\Platform\PgsqlPlatform; +use Propel\Tests\VfsTrait; use Symfony\Component\Filesystem\Filesystem; /** @@ -26,6 +27,8 @@ */ class DatabaseTest extends ModelTestCase { + use VfsTrait; + /** * @return void */ @@ -537,13 +540,10 @@ classname: Propel\Runtime\Connection\DebugPDO autoNamespace: true EOF; - $configFilename = sys_get_temp_dir() . '/propel.yml'; - - $filesystem = new Filesystem(); - $filesystem->dumpFile($configFilename, $yamlConf); + $configFile = $this->newFile('propel.yml', $yamlConf); $schema = 'TestSchema'; - $config = new GeneratorConfig($configFilename); + $config = new GeneratorConfig($configFile->url()); $platform = new MysqlPlatform(); $parentSchema = new Schema($platform); $parentSchema->setGeneratorConfig($config); diff --git a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php index 29cc0f0585..ea16e927a7 100644 --- a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php +++ b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php @@ -10,9 +10,12 @@ use Propel\Generator\Config\GeneratorConfig; use Propel\Generator\Platform\MysqlPlatform; +use Propel\Tests\VfsTrait; class MysqlPlatformMigrationMyISAMTest extends PlatformMigrationTestProvider { + use VfsTrait; + protected $platform; /** @@ -49,9 +52,8 @@ classname: \Propel\Runtime\Connection\DebugPDO - bookstore EOF; - $configFile = sys_get_temp_dir() . '/propel.yaml'; - file_put_contents($configFile, $configFileContent); - $config = new GeneratorConfig($configFile); + $configFile = $this->newFile('propel.yaml', $configFileContent); + $config = new GeneratorConfig($configFile->url()); $this->platform->setGeneratorConfig($config); } diff --git a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php index a26fca14a4..2b94a18a9f 100644 --- a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php +++ b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php @@ -11,9 +11,12 @@ use Propel\Generator\Config\GeneratorConfig; use Propel\Generator\Model\Diff\DatabaseComparator; use Propel\Generator\Platform\MysqlPlatform; +use Propel\Tests\VfsTrait; class MysqlPlatformMigrationTest extends MysqlPlatformMigrationTestProvider { + use VfsTrait; + /** * @var \Propel\Generator\Platform\PlatformInterface|null */ @@ -53,9 +56,8 @@ classname: \Propel\Runtime\Connection\DebugPDO - bookstore EOF; - $configFile = sys_get_temp_dir() . '/propel.yaml'; - file_put_contents($configFile, $configFileContent); - $config = new GeneratorConfig($configFile); + $configFile = $this->newFile('propel.yaml', $configFileContent); + $config = new GeneratorConfig($configFile->url()); $this->platform->setGeneratorConfig($config); } diff --git a/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php b/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php index b7413ad820..42200567c9 100644 --- a/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php +++ b/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php @@ -12,6 +12,7 @@ use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Parser\XmlParser; use Propel\Tests\TestCase; +use Propel\Tests\VfsTrait; /** * Test for JsonParser class @@ -20,6 +21,8 @@ */ class AbstractParserTest extends TestCase { + use VfsTrait; + /** * @return void */ @@ -44,9 +47,18 @@ public function testGetParserThrowsExceptionOnWrongParser() */ public function testLoad() { - $fixtureFile = __DIR__ . '/fixtures/test_data.xml'; + $file = $this->newFile('test_data.xml', <<' . "\\n" ?> + + + + + + +XML +); $parser = AbstractParser::getParser('XML'); - $content = $parser->load($fixtureFile); + $content = $parser->load($file->url()); $expectedContent = << @@ -64,11 +76,11 @@ public function testLoad() public function testDump() { $testContent = 'Foo Content'; - $testFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'propel_test_' . microtime(); + + $testFile = $this->newFile('propel_test'); $parser = AbstractParser::getParser('XML'); - $parser->dump($testContent, $testFile); - $content = file_get_contents($testFile); + $parser->dump($testContent, $testFile->url()); + $content = file_get_contents($testFile->url()); $this->assertEquals($testContent, $content); - unlink($testFile); } } diff --git a/tests/Propel/Tests/Runtime/Parser/fixtures/test_data.xml b/tests/Propel/Tests/Runtime/Parser/fixtures/test_data.xml deleted file mode 100644 index 4ec1f65e49..0000000000 --- a/tests/Propel/Tests/Runtime/Parser/fixtures/test_data.xml +++ /dev/null @@ -1,6 +0,0 @@ -' . "\n" ?> - - - - - From 65b1db8b382f84d15cf3b6f6e416b5f6e9b01bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Klatt?= Date: Wed, 6 Jan 2021 13:27:04 +0000 Subject: [PATCH 206/208] Updated TableMap generator to add column name map for normalization, updated TableMap class to make use of the new column name normalization. --- .../Generator/Builder/Om/TableMapBuilder.php | 59 +++++++++++++++++++ src/Propel/Runtime/Map/TableMap.php | 23 +++++++- 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index 0d18706f09..11d4c30792 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -146,6 +146,7 @@ protected function addClassBody(&$script) $this->addAttributes($script); $script .= $this->addFieldsAttributes(); + $this->addNormalizedColumnNameMap($script); if ($table->hasValueSetColumns()) { $this->addValueSetColumnAttributes($script); @@ -444,6 +445,64 @@ protected function addFieldsAttributes() ]); } + /** + * @param string $script + * + * @return void + */ + protected function addNormalizedColumnNameMap(&$script): void + { + $script .= ' + /** + * Holds a list of column names to be normalized + * + * @var string[] + */ + protected $normalizedColumnNameMap = [' . PHP_EOL; + + $table = $this->getTable(); + $tableColumns = $table->getColumns(); + + foreach ($tableColumns as $num => $column) { + $normalizedName = strtoupper($column->getName()); + + // ColumnName => COLUMN_NAME + $script .= ' + \'' . $column->getPhpName() . '\' => \'' . $normalizedName . '\','; + + // TableName.ColumnName => COLUMN_NAME + $script .= ' + \'' . $table->getPhpName() . '.' . $column->getPhpName() . '\' => \'' . $normalizedName . '\','; + + // columnName => COLUMN_NAME + $script .= ' + \'' . $column->getCamelCaseName() . '\' => \'' . $normalizedName . '\','; + + // tableName.columnName => COLUMN_NAME + $script .= ' + \'' . $table->getCamelCaseName() . '.' . $column->getCamelCaseName() . '\' => \'' . $normalizedName . '\','; + + // TableNameTableMap::COL_COLUMN_NAME => COLUMN_NAME + $script .= ' + \'' . $this->getColumnConstant($column, $this->getTableMapClass()) . '\' => \'' . $normalizedName . '\','; + + // COL_COLUMN_NAME => COLUMN_NAME + $script .= ' + \'' . $column->getConstantName() . '\' => \'' . $normalizedName . '\','; + + // column_name => COLUMN_NAME + $script .= ' + \'' . $column->getName() . '\' => \'' . $normalizedName . '\','; + + // table_name.column_name => COLUMN_NAME + $script .= ' + \'' . $table->getName() . '.' . $column->getName() . '\' => \'' . $normalizedName . '\','; + } + + $script .= ' + ];' . PHP_EOL; + } + /** * Closes class. * diff --git a/src/Propel/Runtime/Map/TableMap.php b/src/Propel/Runtime/Map/TableMap.php index 5175239d5d..c4eee4d0ad 100644 --- a/src/Propel/Runtime/Map/TableMap.php +++ b/src/Propel/Runtime/Map/TableMap.php @@ -67,6 +67,13 @@ class TableMap */ protected $columnsByPhpName = []; + /** + * Map of normalized column names + * + * @var string[] + */ + protected $normalizedColumnNameMap = []; + /** * The database this table belongs to * @@ -411,6 +418,16 @@ private static function getPrimaryKey(Criteria $criteria) return $pk; } + /** + * @param string $columnName + * + * @return string + */ + protected function getNormalizedColumnName(string $columnName): string + { + return $this->normalizedColumnNameMap[$columnName] ?? ColumnMap::normalizeName($columnName); + } + /** * Add a column to the table. * @@ -445,7 +462,7 @@ public function addColumn($name, $phpName, $type, $isNotNull = false, $size = nu $this->foreignKeys[$name] = $col; } - $this->columns[ColumnMap::normalizeName($name)] = $col; + $this->columns[$this->getNormalizedColumnName($name)] = $col; $this->columnsByPhpName[$phpName] = $col; return $col; @@ -479,7 +496,7 @@ public function hasColumn($name, $normalize = true) if ($name instanceof ColumnMap) { $name = $name->getName(); } elseif ($normalize) { - $name = ColumnMap::normalizeName($name); + $name = $this->getNormalizedColumnName($name); } return isset($this->columns[$name]); @@ -498,7 +515,7 @@ public function hasColumn($name, $normalize = true) public function getColumn($name, $normalize = true) { if ($normalize) { - $name = ColumnMap::normalizeName($name); + $name = $this->getNormalizedColumnName($name); } if (!$this->hasColumn($name, false)) { throw new ColumnNotFoundException(sprintf('Cannot fetch ColumnMap for undefined column: %s in table %s.', $name, $this->getName())); From e2bb05091876097a9f9577c3e19f89e5defa14e3 Mon Sep 17 00:00:00 2001 From: Cristiano Cinotti Date: Tue, 29 Dec 2020 08:09:26 +0100 Subject: [PATCH 207/208] QuickBuilder refactor Refactor`QuickBuilder` to build classes on virtual filesystem, by default. It's still possible to optionally generate them on physical filesystem, for debugging purpose. --- src/Propel/Generator/Util/QuickBuilder.php | 255 +++++++++++------- .../Propel/Generator/Util}/VfsTrait.php | 23 +- .../Config/ConfigurationManagerTest.php | 2 +- .../Config/Loader/IniFileLoaderTest.php | 2 +- .../Config/Loader/JsonFileLoaderTest.php | 2 +- .../Config/Loader/PhpFileLoaderTest.php | 2 +- .../Config/Loader/XmlFileLoaderTest.php | 2 +- .../Config/Loader/YamlFileLoaderTest.php | 2 +- .../Common/Config/XmlToArrayConverterTest.php | 2 +- .../Generator/Config/GeneratorConfigTest.php | 2 +- .../Tests/Generator/Model/DatabaseTest.php | 2 +- .../MysqlPlatformMigrationMyISAMTest.php | 2 +- .../Platform/MysqlPlatformMigrationTest.php | 2 +- .../Tests/Generator/Util/QuickBuilderTest.php | 46 +++- .../Runtime/Parser/AbstractParserTest.php | 2 +- 15 files changed, 212 insertions(+), 136 deletions(-) rename {tests/Propel/Tests => src/Propel/Generator/Util}/VfsTrait.php (79%) diff --git a/src/Propel/Generator/Util/QuickBuilder.php b/src/Propel/Generator/Util/QuickBuilder.php index a4a75f8d49..93353412fe 100644 --- a/src/Propel/Generator/Util/QuickBuilder.php +++ b/src/Propel/Generator/Util/QuickBuilder.php @@ -1,4 +1,4 @@ -schema = $schema; } @@ -86,7 +99,7 @@ public function setSchema($schema) /** * @return string */ - public function getSchema() + public function getSchema(): string { return $this->schema; } @@ -96,7 +109,7 @@ public function getSchema() * * @return void */ - public function setSchemaName($schemaName) + public function setSchemaName(string $schemaName): void { $this->schemaName = $schemaName; } @@ -104,7 +117,7 @@ public function setSchemaName($schemaName) /** * @return string */ - public function getSchemaName() + public function getSchemaName(): string { return $this->schemaName; } @@ -114,15 +127,15 @@ public function getSchemaName() * * @return void */ - public function setParser($parser) + public function setParser(SchemaParserInterface $parser): void { $this->parser = $parser; } /** - * @return \Propel\Generator\Reverse\SchemaParserInterface + * @return \Propel\Generator\Reverse\SchemaParserInterface|null */ - public function getParser() + public function getParser(): ?SchemaParserInterface { return $this->parser; } @@ -134,7 +147,7 @@ public function getParser() * * @return void */ - public function setPlatform($platform) + public function setPlatform(PlatformInterface $platform): void { $this->platform = $platform; } @@ -144,7 +157,7 @@ public function setPlatform($platform) * * @return \Propel\Generator\Platform\PlatformInterface */ - public function getPlatform() + public function getPlatform(): PlatformInterface { if ($this->platform === null) { $this->platform = new SqlitePlatform(); @@ -162,7 +175,7 @@ public function getPlatform() * * @return void */ - public function setConfig(GeneratorConfigInterface $config) + public function setConfig(GeneratorConfigInterface $config): void { $this->config = $config; } @@ -181,19 +194,45 @@ public function getConfig() return $this->config; } + /** + * @return bool + */ + public function isVfs(): bool + { + return $this->vfs; + } + + /** + * @param bool $vfs + * + * @return void + */ + public function setVfs(bool $vfs): void + { + $this->vfs = $vfs; + } + /** * @param string $schema * @param string|null $dsn * @param string|null $user * @param string|null $pass * @param \Propel\Runtime\Adapter\AdapterInterface|null $adapter + * @param bool $vfs * * @return \Propel\Runtime\Connection\ConnectionWrapper */ - public static function buildSchema($schema, $dsn = null, $user = null, $pass = null, $adapter = null) - { + public static function buildSchema( + string $schema, + ?string $dsn = null, + ?string $user = null, + ?string $pass = null, + ?AdapterInterface $adapter = null, + bool $vfs = true + ): ConnectionWrapper { $builder = new self(); $builder->setSchema($schema); + $builder->setVfs($vfs); return $builder->build($dsn, $user, $pass, $adapter); } @@ -207,17 +246,17 @@ public static function buildSchema($schema, $dsn = null, $user = null, $pass = n * * @return \Propel\Runtime\Connection\ConnectionWrapper */ - public function build($dsn = null, $user = null, $pass = null, $adapter = null, ?array $classTargets = null) - { - if ($dsn === null) { - $dsn = 'sqlite::memory:'; - } - if ($adapter === null) { - $adapter = new SqliteAdapter(); - } - if ($classTargets === null) { - $classTargets = $this->classTargets; - } + public function build( + ?string $dsn = null, + ?string $user = null, + ?string $pass = null, + ?AdapterInterface $adapter = null, + ?array $classTargets = null + ): ConnectionWrapper { + $dsn = $dsn ?? 'sqlite::memory:'; + $adapter = $adapter ?? new SqliteAdapter(); + $classTargets = $classTargets ?? $this->classTargets; + $pdo = new PdoConnection($dsn, $user, $pass); $con = new ConnectionWrapper($pdo); $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); @@ -235,7 +274,7 @@ public function build($dsn = null, $user = null, $pass = null, $adapter = null, /** * @return \Propel\Generator\Model\Database|null */ - public function getDatabase() + public function getDatabase(): ?Database { if ($this->database === null) { $xtad = new SchemaReader($this->getPlatform()); @@ -252,9 +291,9 @@ public function getDatabase() * * @throws \Exception * - * @return int + * @return int the number of statements executed */ - public function buildSQL(ConnectionInterface $con) + public function buildSQL(ConnectionInterface $con): int { $sql = $this->getSQL(); $statements = SqlParser::parseString($sql); @@ -284,7 +323,7 @@ public function buildSQL(ConnectionInterface $con) * * @return \Propel\Generator\Model\Database|null */ - public function updateDB(ConnectionInterface $con) + public function updateDB(ConnectionInterface $con): ?Database { $database = $this->readConnectedDatabase(); $diff = DatabaseComparator::computeDiff($database, $this->database); @@ -319,7 +358,7 @@ public function updateDB(ConnectionInterface $con) /** * @return \Propel\Generator\Model\Database */ - public function readConnectedDatabase() + public function readConnectedDatabase(): Database { $this->getDatabase(); $database = new Database(); @@ -334,7 +373,7 @@ public function readConnectedDatabase() /** * @return string */ - public function getSQL() + public function getSQL(): string { /** @var \Propel\Generator\Platform\DefaultPlatform $platform */ $platform = $this->getPlatform(); @@ -343,11 +382,11 @@ public function getSQL() } /** - * @param string[]|null $classTargets + * @param array|null $classTargets * * @return string */ - public function getBuildName($classTargets = null) + public function getBuildName(?array $classTargets = null): string { $tables = []; foreach ($this->getDatabase()->getTables() as $table) { @@ -367,52 +406,24 @@ public function getBuildName($classTargets = null) } /** + * Build the classes files and include them. + * + * When generated to virtual filesystem, the classes reside in a unique file. When they're are built to + * physical filesystem, which is supposed to be for debugging purpose, the classes reside on separate file, + * for easier debug. + * * @param string[]|null $classTargets array('tablemap', 'object', 'query', 'objectstub', 'querystub') - * @param bool $separate pass true to get for each class a own file. better for debugging. * * @return void */ - public function buildClasses(?array $classTargets = null, $separate = false) + public function buildClasses(?array $classTargets = null): void { - $classes = $classTargets === null ? ['tablemap', 'object', 'query', 'objectstub', 'querystub'] : $classTargets; - - $dirHash = substr(sha1(getcwd()), 0, 10); - $dir = sys_get_temp_dir() . '/propelQuickBuild-' . Propel::VERSION . "-$dirHash/"; + $classes = $classTargets ?? ['tablemap', 'object', 'query', 'objectstub', 'querystub']; - if (!is_dir($dir)) { - mkdir($dir); - } - - $includes = []; - $allCode = ''; - $allCodeName = []; - foreach ($this->getDatabase()->getTables() as $table) { - if (5 > count($allCodeName)) { - $allCodeName[] = $table->getPhpName(); - } + $includes = $this->isVfs() ? $this->buildClassesToVirtual($classes, $this->getDatabase()->getTables()) + : $this->buildClassesToPhysical($classes, $this->getDatabase()->getTables()); - if ($separate) { - foreach ($classes as $class) { - $code = $this->getClassesForTable($table, [$class]); - $tempFile = $dir - . str_replace('\\', '-', $table->getPhpName()) - . "-$class" - . '.php'; - file_put_contents($tempFile, "getClassesForTable($table, $classes); - $allCode .= $code; - } - } - if ($separate) { - foreach ($includes as $tempFile) { - include($tempFile); - } - } else { - $tempFile = $dir . implode('_', $allCodeName) . '.php'; - file_put_contents($tempFile, "getDatabase()->getTables() as $table) { @@ -438,12 +449,9 @@ public function getClasses(?array $classTargets = null) * * @return string */ - public function getClassesForTable(Table $table, ?array $classTargets = null) + public function getClassesForTable(Table $table, ?array $classTargets = null): string { - if ($classTargets === null) { - $classTargets = $this->classTargets; - } - + $classTargets = $classTargets ?? $this->classTargets; $script = ''; foreach ($classTargets as $target) { @@ -493,23 +501,6 @@ public function getClassesForTable(Table $table, ?array $classTargets = null) return $script; } - /** - * @param string $schema - * @param string $tableName - * - * @return void - */ - public static function debugClassesForTable($schema, $tableName) - { - $builder = new self(); - $builder->setSchema($schema); - foreach ($builder->getDatabase()->getTables() as $table) { - if ($table->getName() == $tableName) { - echo $builder->getClassesForTable($table); - } - } - } - /** * @see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php * @@ -517,7 +508,7 @@ public static function debugClassesForTable($schema, $tableName) * * @return string */ - public function fixNamespaceDeclarations($source) + public function fixNamespaceDeclarations(string $source): string { $cooperativeLexems = [T_WHITESPACE, T_NS_SEPARATOR, T_STRING]; @@ -578,7 +569,7 @@ public function fixNamespaceDeclarations($source) * * @return string */ - protected function forceNamespace($code) + protected function forceNamespace(string $code): string { if (preg_match('/\nnamespace/', $code) === 0) { $use = array_filter(explode(PHP_EOL, $code), function ($string) { @@ -596,7 +587,7 @@ protected function forceNamespace($code) /** * @return bool */ - public function isIdentifierQuotingEnabled() + public function isIdentifierQuotingEnabled(): bool { return $this->identifierQuoting; } @@ -606,8 +597,64 @@ public function isIdentifierQuotingEnabled() * * @return void */ - public function setIdentifierQuoting($identifierQuoting) + public function setIdentifierQuoting(bool $identifierQuoting): void { $this->identifierQuoting = $identifierQuoting; } + + /** + * Create separate classes to write to physical filesystem. + * + * @param string[] $classes + * @param \Propel\Generator\Model\Table[] $tables Array of Table objects + * + * @return string[] The files to include + */ + private function buildClassesToPhysical(array $classes, array $tables): array + { + $includes = []; + $dirName = sys_get_temp_dir() + . '/propelQuickBuild-' . Propel::VERSION . '-' . substr(sha1(getcwd()), 0, 10) . '/'; + if (!is_dir($dirName)) { + mkdir($dirName); + } + foreach ($tables as $table) { + foreach ($classes as $class) { + $code = $this->getClassesForTable($table, [$class]); + $tempFile = $dirName . str_replace('\\', '-', $table->getPhpName()) . "-$class.php"; + file_put_contents($tempFile, " count($allCodeName)) { + $allCodeName[] = $table->getPhpName(); + } + $allCode .= $this->getClassesForTable($table, $classes); + } + + $tempFile = $this->newFile('propelQuickBuild/' . implode('_', $allCodeName) . '.php'); + file_put_contents($tempFile->url(), "url(); + + return $includes; + } } diff --git a/tests/Propel/Tests/VfsTrait.php b/src/Propel/Generator/Util/VfsTrait.php similarity index 79% rename from tests/Propel/Tests/VfsTrait.php rename to src/Propel/Generator/Util/VfsTrait.php index 409c74d875..da1ca744c3 100644 --- a/tests/Propel/Tests/VfsTrait.php +++ b/src/Propel/Generator/Util/VfsTrait.php @@ -1,13 +1,12 @@ -root) { + if ($this->root === null) { $this->root = vfsStream::setup(); } @@ -43,14 +44,14 @@ public function getRoot(): vfsStreamDirectory * @param string $filename * @param string $content * - * @return vfsStreamFile + * @return \org\bovigo\vfs\vfsStreamFile */ public function newFile(string $filename, string $content = ''): vfsStreamFile { $path = pathinfo($filename); $dir = $this->getDir($path['dirname']); - return vfsStream::newFile($filename)->at($dir)->setContent($content); + return vfsStream::newFile($path['basename'])->at($dir)->setContent($content); } /** @@ -60,7 +61,7 @@ public function newFile(string $filename, string $content = ''): vfsStreamFile * * @param string $dirname * - * @return vfsStreamDirectory + * @return \org\bovigo\vfs\vfsStreamDirectory */ private function getDir(string $dirname): vfsStreamDirectory { diff --git a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php index 8461b103e4..8707b1e493 100644 --- a/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php +++ b/tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php @@ -12,7 +12,7 @@ use Propel\Common\Config\ConfigurationManager; use Propel\Common\Config\Exception\InvalidArgumentException; use Propel\Tests\TestCase; -use Propel\Tests\VfsTrait; +use Propel\Generator\Util\VfsTrait; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; class ConfigurationManagerTest extends TestCase diff --git a/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php index 0b66e16cfc..29df8b1f65 100644 --- a/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/IniFileLoaderTest.php @@ -14,7 +14,7 @@ use Propel\Common\Config\Loader\IniFileLoader; use Propel\Common\Config\FileLocator; use Propel\Tests\TestCase; -use Propel\Tests\VfsTrait; +use Propel\Generator\Util\VfsTrait; use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException; class IniFileLoaderTest extends TestCase diff --git a/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php index bb852fceb1..bf16fb5f22 100644 --- a/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/JsonFileLoaderTest.php @@ -14,7 +14,7 @@ use Propel\Common\Config\FileLocator; use Propel\Common\Config\Loader\JsonFileLoader; use Propel\Tests\TestCase; -use Propel\Tests\VfsTrait; +use Propel\Generator\Util\VfsTrait; class JsonFileLoaderTest extends TestCase { diff --git a/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php index 133c06a934..54d567863b 100644 --- a/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/PhpFileLoaderTest.php @@ -14,7 +14,7 @@ use Propel\Common\Config\FileLocator; use Propel\Common\Config\Loader\PhpFileLoader; use Propel\Tests\TestCase; -use Propel\Tests\VfsTrait; +use Propel\Generator\Util\VfsTrait; class PhpFileLoaderTest extends TestCase { diff --git a/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php index b0329cc5ce..1c60eee599 100644 --- a/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/XmlFileLoaderTest.php @@ -14,7 +14,7 @@ use Propel\Common\Config\FileLocator; use Propel\Common\Config\Loader\XmlFileLoader; use Propel\Tests\TestCase; -use Propel\Tests\VfsTrait; +use Propel\Generator\Util\VfsTrait; class XmlFileLoaderTest extends TestCase { diff --git a/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php b/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php index a76fe7cb75..70855600e3 100644 --- a/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php +++ b/tests/Propel/Tests/Common/Config/Loader/YamlFileLoaderTest.php @@ -13,7 +13,7 @@ use Propel\Common\Config\FileLocator; use Propel\Common\Config\Loader\YamlFileLoader; use Propel\Tests\TestCase; -use Propel\Tests\VfsTrait; +use Propel\Generator\Util\VfsTrait; use Symfony\Component\Yaml\Exception\ParseException; class YamlFileLoaderTest extends TestCase diff --git a/tests/Propel/Tests/Common/Config/XmlToArrayConverterTest.php b/tests/Propel/Tests/Common/Config/XmlToArrayConverterTest.php index 15b4803ce6..a9d37541d1 100644 --- a/tests/Propel/Tests/Common/Config/XmlToArrayConverterTest.php +++ b/tests/Propel/Tests/Common/Config/XmlToArrayConverterTest.php @@ -13,7 +13,7 @@ use Propel\Common\Config\Exception\XmlParseException; use Propel\Common\Config\XmlToArrayConverter; use Propel\Tests\TestCase; -use Propel\Tests\VfsTrait; +use Propel\Generator\Util\VfsTrait; class XmlToArrayConverterTest extends TestCase { diff --git a/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php b/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php index 53d37b1f7b..876150e25b 100644 --- a/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php +++ b/tests/Propel/Tests/Generator/Config/GeneratorConfigTest.php @@ -14,7 +14,7 @@ use Propel\Generator\Exception\InvalidArgumentException; use Propel\Tests\Common\Config\ConfigTestCase; use Propel\Tests\TestCase; -use Propel\Tests\VfsTrait; +use Propel\Generator\Util\VfsTrait; use ReflectionClass; /** diff --git a/tests/Propel/Tests/Generator/Model/DatabaseTest.php b/tests/Propel/Tests/Generator/Model/DatabaseTest.php index e6c2047f1d..73b039f82c 100644 --- a/tests/Propel/Tests/Generator/Model/DatabaseTest.php +++ b/tests/Propel/Tests/Generator/Model/DatabaseTest.php @@ -17,7 +17,7 @@ use Propel\Generator\Model\Table; use Propel\Generator\Platform\MysqlPlatform; use Propel\Generator\Platform\PgsqlPlatform; -use Propel\Tests\VfsTrait; +use Propel\Generator\Util\VfsTrait; use Symfony\Component\Filesystem\Filesystem; /** diff --git a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php index ea16e927a7..e83dfae190 100644 --- a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php +++ b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationMyISAMTest.php @@ -10,7 +10,7 @@ use Propel\Generator\Config\GeneratorConfig; use Propel\Generator\Platform\MysqlPlatform; -use Propel\Tests\VfsTrait; +use Propel\Generator\Util\VfsTrait; class MysqlPlatformMigrationMyISAMTest extends PlatformMigrationTestProvider { diff --git a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php index 2b94a18a9f..234a8fe649 100644 --- a/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php +++ b/tests/Propel/Tests/Generator/Platform/MysqlPlatformMigrationTest.php @@ -11,7 +11,7 @@ use Propel\Generator\Config\GeneratorConfig; use Propel\Generator\Model\Diff\DatabaseComparator; use Propel\Generator\Platform\MysqlPlatform; -use Propel\Tests\VfsTrait; +use Propel\Generator\Util\VfsTrait; class MysqlPlatformMigrationTest extends MysqlPlatformMigrationTestProvider { diff --git a/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php b/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php index 6bdf33b972..81ce4543ed 100644 --- a/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php +++ b/tests/Propel/Tests/Generator/Util/QuickBuilderTest.php @@ -1,4 +1,4 @@ -setPlatform(new MysqlPlatform()); @@ -32,7 +35,7 @@ public function testGetPlatform() $this->assertTrue($builder->getPlatform() instanceof SqlitePlatform); } - public function simpleSchemaProvider() + public function simpleSchemaProvider(): array { $xmlSchema = << @@ -53,7 +56,7 @@ public function simpleSchemaProvider() * * @return void */ - public function testGetDatabase($builder) + public function testGetDatabase($builder): void { $database = $builder->getDatabase(); $this->assertEquals('test_quick_build_2', $database->getName()); @@ -66,7 +69,7 @@ public function testGetDatabase($builder) * * @return void */ - public function testGetSQL($builder) + public function testGetSQL($builder): void { $expected = <<getClasses(); $this->assertStringContainsString('class QuickBuildFoo1 extends BaseQuickBuildFoo1', $script); @@ -106,7 +109,7 @@ public function testGetClasses($builder) * * @return void */ - public function testGetClassesLimitedClassTargets($builder) + public function testGetClassesLimitedClassTargets($builder): void { $script = $builder->getClasses(['tablemap', 'object', 'query']); $this->assertStringNotContainsString('class QuickBuildFoo1 extends BaseQuickBuildFoo1', $script); @@ -120,7 +123,7 @@ public function testGetClassesLimitedClassTargets($builder) * * @return void */ - public function testBuildClasses($builder) + public function testBuildClasses($builder): void { $builder->buildClasses(); $foo = new QuickBuildFoo1(); @@ -131,7 +134,7 @@ public function testBuildClasses($builder) /** * @return void */ - public function testBuild() + public function testBuild(): void { $xmlSchema = << @@ -151,4 +154,29 @@ public function testBuild() $this->assertEquals(1, QuickBuildFoo2Query::create()->count()); $this->assertEquals($foo, QuickBuildFoo2Query::create()->findOne()); } + + public function testBuildOnPhysicalFilesystem(): void + { + $xmlSchema = << + + + +
+ +EOF; + $builder = new QuickBuilder(); + $builder->setSchema($xmlSchema); + $builder->setVfs(false); + $builder->build(); + $this->assertEquals(0, QuickBuildFoo3Query::create()->count()); + $foo = new QuickBuildFoo3(); + $foo->setBar(3); + $foo->save(); + $this->assertEquals(1, QuickBuildFoo3Query::create()->count()); + $this->assertEquals($foo, QuickBuildFoo3Query::create()->findOne()); + + $this->assertDirectoryExists( + sys_get_temp_dir() . '/propelQuickBuild-' . Propel::VERSION . '-' . substr(sha1(getcwd()), 0, 10)); + } } diff --git a/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php b/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php index 42200567c9..2f8c69d6bc 100644 --- a/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php +++ b/tests/Propel/Tests/Runtime/Parser/AbstractParserTest.php @@ -12,7 +12,7 @@ use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Parser\XmlParser; use Propel\Tests\TestCase; -use Propel\Tests\VfsTrait; +use Propel\Generator\Util\VfsTrait; /** * Test for JsonParser class From 832c9f17c018a48b4deef4f4d23f47624558eba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Klatt?= Date: Wed, 13 Jan 2021 07:17:46 +0100 Subject: [PATCH 208/208] Update src/Propel/Generator/Builder/Om/TableMapBuilder.php Co-authored-by: Mark Sch. --- src/Propel/Generator/Builder/Om/TableMapBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propel/Generator/Builder/Om/TableMapBuilder.php b/src/Propel/Generator/Builder/Om/TableMapBuilder.php index 11d4c30792..a0cbed1149 100644 --- a/src/Propel/Generator/Builder/Om/TableMapBuilder.php +++ b/src/Propel/Generator/Builder/Om/TableMapBuilder.php @@ -454,7 +454,7 @@ protected function addNormalizedColumnNameMap(&$script): void { $script .= ' /** - * Holds a list of column names to be normalized + * Holds a list of column names and their normalized version. * * @var string[] */