diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e408d392c..80b82d2f2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,20 +8,22 @@ jobs: env: DB: mysql DB_USER: root - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: php: - - '7.4' +# - '7.4' - '8.0' - '8.1' + - '8.2' + - '8.3' composer: - '' - '--prefer-lowest' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Use PHP uses: shivammathur/setup-php@v2 @@ -39,7 +41,7 @@ jobs: - name: cache dependencies id: cache-dependencies - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.composer }}-composer-${{ hashFiles('**/composer.lock') }} @@ -54,7 +56,7 @@ jobs: env: COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} COMPOSER_FLAGS: ${{ matrix.composer }} - run: composer update ${COMPOSER_FLAGS} --prefer-source + run: composer update ${COMPOSER_FLAGS} working-directory: ./ - name: Start MySQL @@ -66,6 +68,10 @@ jobs: run: | echo "SET GLOBAL sql_mode = ''" | mysql -u root -proot mysql + - name: Add hosts to /etc/hosts + run: | + sudo echo "127.0.0.1 db" | sudo tee -a /etc/hosts + - name: setup database run: | sh -c "if [ '$DB' = 'mysql' ]; then mysql -u root -proot mysql -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS test; DROP SCHEMA IF EXISTS second_hand_books; DROP SCHEMA IF EXISTS contest; DROP DATABASE IF EXISTS reverse_bookstore; DROP SCHEMA IF EXISTS bookstore_schemas; SET FOREIGN_KEY_CHECKS = 1;'; fi" @@ -76,3 +82,5 @@ jobs: - name: Run Tests run: vendor/bin/phpunit working-directory: ./ + env: + SYMFONY_DEPRECATIONS_HELPER: weak diff --git a/.gitignore b/.gitignore index 85fcda6c5..8bdfe482d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ composer.lock composer.phar generator/pear/build/ runtime/pear/build/ + +.phpunit.result.cache diff --git a/.idea/codeception.xml b/.idea/codeception.xml new file mode 100644 index 000000000..70e3d1472 --- /dev/null +++ b/.idea/codeception.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 000000000..97626ba45 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/phing.xml b/.idea/phing.xml new file mode 100644 index 000000000..80021d013 --- /dev/null +++ b/.idea/phing.xml @@ -0,0 +1,6 @@ + + + + $PROJECT_DIR$/vendor/phing/phing/bin/phing + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 000000000..c540efe7f --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/phpspec.xml b/.idea/phpspec.xml new file mode 100644 index 000000000..c7cfbc2c5 --- /dev/null +++ b/.idea/phpspec.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/phpunit.xml b/.idea/phpunit.xml new file mode 100644 index 000000000..4ea97533f --- /dev/null +++ b/.idea/phpunit.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 000000000..323da7646 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/composer.json b/composer.json index 8237463a0..0628e3f34 100644 --- a/composer.json +++ b/composer.json @@ -14,16 +14,19 @@ }, "include-path": ["runtime/lib", "generator/lib"], "require": { - "php": "^8.0|^7.4", + "php": ">=8.0", "phing/phing": "^2.17", - "ext-pdo": "*" + "ext-pdo": "*", + "symfony/deprecation-contracts": "^2.5|^3.0" }, "require-dev": { "phpunit/phpunit": "^9.0.0", "phpcompatibility/php-compatibility": "^9.3", "squizlabs/php_codesniffer": "^3.5", "ext-simplexml": "*", - "ext-dom": "*" + "ext-dom": "*", + "rector/rector": "^1.0", + "symfony/phpunit-bridge": "^5.4|^6.0" }, "replace": { "propel/propel1": "^1.8" diff --git a/docker/Dockerfile b/docker/Dockerfile index 310c6a0ba..47d2c0e1b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM thecodingmachine/php:8.0-v4-cli +FROM thecodingmachine/php:8.1-v4-cli USER root RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index da9c15be4..c6068e061 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -6,6 +6,8 @@ services: dockerfile: Dockerfile working_dir: /usr/src/app command: phpunit + links: + - db volumes: - ../:/usr/src/app environment: @@ -13,11 +15,11 @@ services: - STARTUP_COMMAND_1=composer install - STARTUP_COMMAND_2=bash test/reset_tests.sh - PHP_IDE_CONFIG="serverName=propel" - - XDEBUG_MODE=debug - - XDEBUG_SESSION=1 +# - XDEBUG_MODE=debug +# - XDEBUG_SESSION=1 db: - image: percona + image: mysql:8.0 command: > mysqld --sql-mode="NO_ENGINE_SUBSTITUTION" @@ -26,4 +28,5 @@ services: --default-authentication-plugin=mysql_native_password restart: always environment: - MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' +# MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' + MYSQL_ROOT_PASSWORD: 'root' diff --git a/docker/reset.sh b/docker/reset.sh index 7cbb1a8ce..e428a440b 100644 --- a/docker/reset.sh +++ b/docker/reset.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash -mysql -u root -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS test; DROP SCHEMA IF EXISTS second_hand_books; DROP SCHEMA IF EXISTS contest; DROP DATABASE IF EXISTS reverse_bookstore; DROP SCHEMA IF EXISTS bookstore_schemas; SET FOREIGN_KEY_CHECKS = 1;' -mysql -u root -e 'CREATE DATABASE test; CREATE SCHEMA bookstore_schemas; CREATE SCHEMA contest; CREATE SCHEMA second_hand_books; CREATE DATABASE reverse_bookstore;' +mysql -u root -proot -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS test; DROP SCHEMA IF EXISTS second_hand_books; DROP SCHEMA IF EXISTS contest; DROP DATABASE IF EXISTS reverse_bookstore; DROP SCHEMA IF EXISTS bookstore_schemas; SET FOREIGN_KEY_CHECKS = 1;' +mysql -u root -proot -e 'CREATE DATABASE test; CREATE SCHEMA bookstore_schemas; CREATE SCHEMA contest; CREATE SCHEMA second_hand_books; CREATE DATABASE reverse_bookstore;' diff --git a/docker/run.sh b/docker/run.sh index 354575f86..be66c9e7b 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -4,4 +4,4 @@ docker-compose up -d db sleep 20 docker-compose exec -T db bash < reset.sh docker-compose build -docker-compose run php +docker-compose run --rm php diff --git a/generator/default.properties b/generator/default.properties index 1845bde4a..211fe03ca 100644 --- a/generator/default.properties +++ b/generator/default.properties @@ -104,8 +104,8 @@ propel.disableIdentifierQuoting = false # it is nice to change the defaults. propel.defaultTimeStampFormat = Y-m-d H:i:s -propel.defaultTimeFormat = %X -propel.defaultDateFormat = %x +propel.defaultTimeFormat = H:i:s +propel.defaultDateFormat = m/d/Y propel.defaultKeyType = phpName diff --git a/generator/lib/behavior/DelegateBehavior.php b/generator/lib/behavior/DelegateBehavior.php index e5f5a5bc3..2d1356336 100644 --- a/generator/lib/behavior/DelegateBehavior.php +++ b/generator/lib/behavior/DelegateBehavior.php @@ -92,7 +92,7 @@ protected function getDelegateTable($delegateTableName) return $this->getTable()->getDatabase()->getTable($delegateTableName); } - public function objectCall($builder) + public function objectCall($builder): string { $script = ''; foreach ($this->delegates as $delegate => $type) { diff --git a/generator/lib/behavior/SoftDeleteBehavior.php b/generator/lib/behavior/SoftDeleteBehavior.php index 769609514..ce6b84051 100644 --- a/generator/lib/behavior/SoftDeleteBehavior.php +++ b/generator/lib/behavior/SoftDeleteBehavior.php @@ -37,7 +37,7 @@ public function modifyTable() } } - protected function getColumnSetter() + protected function getColumnSetter(): string { return 'set' . $this->getColumnForParameter('deleted_column')->getPhpName(); } @@ -89,7 +89,7 @@ public function unDelete(PropelPDO \$con = null) "; } - public function preDelete($builder) + public function preDelete($builder): string { $script = "if (!empty(\$ret) && {$builder->getStubQueryBuilder()->getClassname()}::isSoftDeleteEnabled()) {"; @@ -119,7 +119,7 @@ public function preDelete($builder) return $script; } - public function queryAttributes() + public function queryAttributes(): string { return "protected static \$softDelete = true; protected \$localSoftDelete = true; @@ -270,7 +270,7 @@ public static function isSoftDeleteEnabled() "; } - public function preSelectQuery($builder) + public function preSelectQuery($builder): string { return <<getStubQueryBuilder()->getClassname()}::isSoftDeleteEnabled() && \$this->localSoftDelete) { @@ -280,7 +280,7 @@ public function preSelectQuery($builder) EOT; } - public function preDeleteQuery($builder) + public function preDeleteQuery($builder): string { return <<getStubQueryBuilder()->getClassname()}::isSoftDeleteEnabled() && \$this->localSoftDelete) { @@ -473,7 +473,7 @@ public static function doDeleteAll2(PropelPDO \$con = null) "; } - public function preSelect($builder) + public function preSelect($builder): string { return <<getStubQueryBuilder()->getClassname()}::isSoftDeleteEnabled()) { diff --git a/generator/lib/behavior/TimestampableBehavior.php b/generator/lib/behavior/TimestampableBehavior.php index 31e20b1b1..b4b7a199e 100644 --- a/generator/lib/behavior/TimestampableBehavior.php +++ b/generator/lib/behavior/TimestampableBehavior.php @@ -54,7 +54,7 @@ public function modifyTable() * * @return string The related setter, 'setCreatedOn' or 'setUpdatedOn' */ - protected function getColumnSetter($column) + protected function getColumnSetter($column): string { return 'set' . $this->getColumnForParameter($column)->getPhpName(); } @@ -79,7 +79,7 @@ protected function getColumnConstant($columnName, OMBuilder $builder) * * @return string The code to put at the hook */ - public function preUpdate(PHP5ObjectBuilder $builder) + public function preUpdate(PHP5ObjectBuilder $builder): string { if ($this->withUpdatedAt()) { return "if (\$this->isModified() && !\$this->isColumnModified(" . $this->getColumnConstant('update_column', $builder) . ")) { @@ -97,7 +97,7 @@ public function preUpdate(PHP5ObjectBuilder $builder) * * @return string The code to put at the hook */ - public function preInsert(PHP5ObjectBuilder $builder) + public function preInsert(PHP5ObjectBuilder $builder): string { $script = "if (!\$this->isColumnModified(" . $this->getColumnConstant('create_column', $builder) . ")) { \$this->" . $this->getColumnSetter('create_column') . "(time()); @@ -132,7 +132,7 @@ public function keepUpdateDateUnchanged() } } - public function queryMethods(QueryBuilder $builder) + public function queryMethods(QueryBuilder $builder): string { $script = ''; @@ -213,7 +213,7 @@ public function firstCreatedFirst() return $script; } - protected function withUpdatedAt() + protected function withUpdatedAt(): bool { return 'true' !== $this->getParameter('disable_updated_at'); } diff --git a/generator/lib/behavior/aggregate_column/AggregateColumnBehavior.php b/generator/lib/behavior/aggregate_column/AggregateColumnBehavior.php index 75d2cca75..309c2af03 100644 --- a/generator/lib/behavior/aggregate_column/AggregateColumnBehavior.php +++ b/generator/lib/behavior/aggregate_column/AggregateColumnBehavior.php @@ -57,7 +57,7 @@ public function modifyTable() } } - public function objectMethods($builder) + public function objectMethods($builder): string { if (!$foreignTableName = $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())); diff --git a/generator/lib/behavior/aggregate_column/AggregateColumnRelationBehavior.php b/generator/lib/behavior/aggregate_column/AggregateColumnRelationBehavior.php index 41e7706f2..206fc6e6c 100644 --- a/generator/lib/behavior/aggregate_column/AggregateColumnRelationBehavior.php +++ b/generator/lib/behavior/aggregate_column/AggregateColumnRelationBehavior.php @@ -24,7 +24,7 @@ class AggregateColumnRelationBehavior extends Behavior 'update_method' => '', ); - public function postSave($builder) + public function postSave($builder): string { $relationName = $this->getRelationName($builder); @@ -34,7 +34,7 @@ public function postSave($builder) // no need for a postDelete() hook, since delete() uses Query::delete(), // which already has a hook - public function objectAttributes($builder) + public function objectAttributes($builder): string { $relationName = $this->getRelationName($builder); @@ -83,7 +83,7 @@ public function preDeleteQuery($builder) return $this->getFindRelated($builder); } - protected function getFindRelated($builder) + protected function getFindRelated($builder): string { $relationName = $this->getRelationName($builder); @@ -100,14 +100,14 @@ public function postDeleteQuery($builder) return $this->getUpdateRelated($builder); } - protected function getUpdateRelated($builder) + protected function getUpdateRelated($builder): string { $relationName = $this->getRelationName($builder); return "\$this->updateRelated{$relationName}s(\$con);"; } - public function queryMethods($builder) + public function queryMethods($builder): string { $script = ''; $script .= $this->addQueryFindRelated($builder); diff --git a/generator/lib/behavior/archivable/ArchivableBehavior.php b/generator/lib/behavior/archivable/ArchivableBehavior.php index b39fb354c..b9fc68bc9 100644 --- a/generator/lib/behavior/archivable/ArchivableBehavior.php +++ b/generator/lib/behavior/archivable/ArchivableBehavior.php @@ -150,7 +150,7 @@ public function getArchiveTableQueryName($builder) return $builder->getNewStubQueryBuilder($this->getArchiveTable())->getClassname(); } - public function hasArchiveClass() + public function hasArchiveClass(): bool { return $this->getParameter('archive_class') != ''; } @@ -165,17 +165,17 @@ public function getArchivedAtColumn() } } - public function isArchiveOnInsert() + public function isArchiveOnInsert(): bool { return $this->getParameter('archive_on_insert') == 'true'; } - public function isArchiveOnUpdate() + public function isArchiveOnUpdate(): bool { return $this->getParameter('archive_on_update') == 'true'; } - public function isArchiveOnDelete() + public function isArchiveOnDelete(): bool { return $this->getParameter('archive_on_delete') == 'true'; } diff --git a/generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php b/generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php index e776ae85c..41dc3490c 100644 --- a/generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php +++ b/generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php @@ -36,7 +36,7 @@ protected function getParameter($key) * * @return string The PHP code to be added to the builder. */ - public function objectAttributes(PHP5ObjectBuilder $builder) + public function objectAttributes(PHP5ObjectBuilder $builder): string { if (!$this->behavior->hasArchiveClass()) { $builder->declareClassFromBuilder($builder->getNewStubQueryBuilder($this->behavior->getArchiveTable())); @@ -66,7 +66,7 @@ public function objectAttributes(PHP5ObjectBuilder $builder) * * @return string The PHP code to be added to the builder. */ - public function postInsert(PHP5ObjectBuilder $builder) + public function postInsert(PHP5ObjectBuilder $builder): string { if ($this->behavior->isArchiveOnInsert()) { return "if (\$this->archiveOnInsert) { @@ -86,7 +86,7 @@ public function postInsert(PHP5ObjectBuilder $builder) * * @return string The PHP code to be added to the builder. */ - public function postUpdate(PHP5ObjectBuilder $builder) + public function postUpdate(PHP5ObjectBuilder $builder): string { if ($this->behavior->isArchiveOnUpdate()) { return "if (\$this->archiveOnUpdate) { @@ -121,7 +121,7 @@ public function preDelete($builder) /** * @return string the PHP code to be added to the builder */ - public function objectMethods($builder) + public function objectMethods($builder): string { $this->builder = $builder; @@ -208,7 +208,7 @@ public function addPopulateFromArchive($builder) * * @return boolean */ - public function fakeAutoIncrementPrimaryKeyForConcreteInheritance() + public function fakeAutoIncrementPrimaryKeyForConcreteInheritance(): bool { if ($this->table->hasBehavior('concrete_inheritance')) { $concrete_inheritance_behavior = $this->table->getBehavior('concrete_inheritance'); diff --git a/generator/lib/behavior/archivable/ArchivableBehaviorQueryBuilderModifier.php b/generator/lib/behavior/archivable/ArchivableBehaviorQueryBuilderModifier.php index 904163ee9..85bc8aa8d 100644 --- a/generator/lib/behavior/archivable/ArchivableBehaviorQueryBuilderModifier.php +++ b/generator/lib/behavior/archivable/ArchivableBehaviorQueryBuilderModifier.php @@ -36,7 +36,7 @@ protected function getParameter($key) * * @return string */ - public function queryAttributes(QueryBuilder $builder) + public function queryAttributes(QueryBuilder $builder): string { $script = ''; if ($this->behavior->isArchiveOnUpdate()) { @@ -51,7 +51,7 @@ public function queryAttributes(QueryBuilder $builder) return $script; } - public function preDeleteQuery(QueryBuilder $builder) + public function preDeleteQuery(QueryBuilder $builder): string { if ($this->behavior->isArchiveOnDelete()) { return " @@ -71,7 +71,7 @@ public function preDeleteQuery(QueryBuilder $builder) * * @return string */ - public function postUpdateQuery(QueryBuilder $builder) + public function postUpdateQuery(QueryBuilder $builder): string { if ($this->behavior->isArchiveOnUpdate()) { return " @@ -91,7 +91,7 @@ public function postUpdateQuery(QueryBuilder $builder) * * @return string the PHP code to be added to the builder */ - public function queryMethods(QueryBuilder $builder) + public function queryMethods(QueryBuilder $builder): string { $script = ''; $script .= $this->addArchive($builder); diff --git a/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceBehavior.php b/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceBehavior.php index 0b634ec13..13f9167e3 100644 --- a/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceBehavior.php +++ b/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceBehavior.php @@ -125,7 +125,7 @@ protected function getParentTable() return $database->getTable($tableName); } - protected function isCopyData() + protected function isCopyData(): bool { return $this->getParameter('copy_data_to_parent') == 'true'; } diff --git a/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceParentBehavior.php b/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceParentBehavior.php index f019ea16b..71ede3fb4 100644 --- a/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceParentBehavior.php +++ b/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceParentBehavior.php @@ -36,7 +36,7 @@ public function modifyTable() } } - protected function getColumnGetter() + protected function getColumnGetter(): string { return 'get' . $this->getColumnForParameter('descendant_column')->getPhpName(); } diff --git a/generator/lib/behavior/i18n/I18nBehavior.php b/generator/lib/behavior/i18n/I18nBehavior.php index 8d005babd..d0082146f 100644 --- a/generator/lib/behavior/i18n/I18nBehavior.php +++ b/generator/lib/behavior/i18n/I18nBehavior.php @@ -242,7 +242,7 @@ public function getI18nColumns() return $columns; } - public function replaceTokens($string) + public function replaceTokens($string): string { $table = $this->getTable(); diff --git a/generator/lib/behavior/i18n/I18nBehaviorObjectBuilderModifier.php b/generator/lib/behavior/i18n/I18nBehaviorObjectBuilderModifier.php index 0b3d3a7f8..6cdcaeff7 100644 --- a/generator/lib/behavior/i18n/I18nBehaviorObjectBuilderModifier.php +++ b/generator/lib/behavior/i18n/I18nBehaviorObjectBuilderModifier.php @@ -54,7 +54,7 @@ public function objectClearReferences($builder) )); } - public function objectMethods($builder) + public function objectMethods($builder): string { $this->builder = $builder; $script = ''; diff --git a/generator/lib/behavior/i18n/I18nBehaviorPeerBuilderModifier.php b/generator/lib/behavior/i18n/I18nBehaviorPeerBuilderModifier.php index 0eda7cc2b..7d38dc886 100644 --- a/generator/lib/behavior/i18n/I18nBehaviorPeerBuilderModifier.php +++ b/generator/lib/behavior/i18n/I18nBehaviorPeerBuilderModifier.php @@ -25,7 +25,7 @@ public function __construct($behavior) $this->behavior = $behavior; } - public function staticConstants() + public function staticConstants(): string { return " /** diff --git a/generator/lib/behavior/i18n/I18nBehaviorQueryBuilderModifier.php b/generator/lib/behavior/i18n/I18nBehaviorQueryBuilderModifier.php index 76a1aed52..263ef9c8e 100644 --- a/generator/lib/behavior/i18n/I18nBehaviorQueryBuilderModifier.php +++ b/generator/lib/behavior/i18n/I18nBehaviorQueryBuilderModifier.php @@ -26,7 +26,7 @@ public function __construct($behavior) $this->table = $behavior->getTable(); } - public function queryMethods($builder) + public function queryMethods($builder): string { $this->builder = $builder; $script = ''; diff --git a/generator/lib/behavior/nestedset/NestedSetBehavior.php b/generator/lib/behavior/nestedset/NestedSetBehavior.php index 26fb9b4eb..97b245bb7 100644 --- a/generator/lib/behavior/nestedset/NestedSetBehavior.php +++ b/generator/lib/behavior/nestedset/NestedSetBehavior.php @@ -90,7 +90,7 @@ public function getPeerBuilderModifier() return $this->peerBuilderModifier; } - public function useScope() + public function useScope(): bool { return $this->getParameter('use_scope') == 'true'; } diff --git a/generator/lib/behavior/nestedset/NestedSetBehaviorObjectBuilderModifier.php b/generator/lib/behavior/nestedset/NestedSetBehaviorObjectBuilderModifier.php index a208a9765..8da145c47 100644 --- a/generator/lib/behavior/nestedset/NestedSetBehaviorObjectBuilderModifier.php +++ b/generator/lib/behavior/nestedset/NestedSetBehaviorObjectBuilderModifier.php @@ -30,7 +30,7 @@ protected function getParameter($key) return $this->behavior->getParameter($key); } - protected function getColumnAttribute($name) + protected function getColumnAttribute($name): string { return strtolower($this->behavior->getColumnForParameter($name)->getName()); } @@ -52,7 +52,7 @@ protected function setBuilder($builder) $this->builder->declareClass($builder->getStubQueryBuilder()->getFullyQualifiedClassname()); } - public function objectAttributes($builder) + public function objectAttributes($builder): string { $objectClassname = $builder->getStubObjectBuilder()->getClassname(); @@ -78,7 +78,7 @@ public function objectAttributes($builder) "; } - public function preSave($builder) + public function preSave($builder): string { $peerClassname = $builder->getStubPeerBuilder()->getClassname(); $queryClassname = $builder->getStubQueryBuilder()->getClassname(); @@ -112,7 +112,7 @@ public function preSave($builder) return $script; } - public function preDelete($builder) + public function preDelete($builder): string { $peerClassname = $builder->getStubPeerBuilder()->getClassname(); @@ -126,7 +126,7 @@ public function preDelete($builder) "; } - public function postDelete($builder) + public function postDelete($builder): string { $peerClassname = $builder->getStubPeerBuilder()->getClassname(); @@ -137,7 +137,7 @@ public function postDelete($builder) "; } - public function objectClearReferences($builder) + public function objectClearReferences($builder): string { return "\$this->collNestedSetChildren = null; \$this->aNestedSetParent = null;"; diff --git a/generator/lib/behavior/nestedset/NestedSetBehaviorPeerBuilderModifier.php b/generator/lib/behavior/nestedset/NestedSetBehaviorPeerBuilderModifier.php index 75d9d5b90..71d76b111 100644 --- a/generator/lib/behavior/nestedset/NestedSetBehaviorPeerBuilderModifier.php +++ b/generator/lib/behavior/nestedset/NestedSetBehaviorPeerBuilderModifier.php @@ -35,7 +35,7 @@ protected function getColumn($name) return $this->behavior->getColumnForParameter($name); } - protected function getColumnAttribute($name) + protected function getColumnAttribute($name): string { return strtolower($this->getColumn($name)->getName()); } @@ -57,7 +57,7 @@ protected function setBuilder($builder) $this->peerClassname = $builder->getStubPeerBuilder()->getClassname(); } - public function staticAttributes($builder) + public function staticAttributes($builder): string { $tableName = $this->table->getName(); diff --git a/generator/lib/behavior/query_cache/QueryCacheBehavior.php b/generator/lib/behavior/query_cache/QueryCacheBehavior.php index e504570ec..b9f89e7c2 100644 --- a/generator/lib/behavior/query_cache/QueryCacheBehavior.php +++ b/generator/lib/behavior/query_cache/QueryCacheBehavior.php @@ -23,7 +23,7 @@ class QueryCacheBehavior extends Behavior 'lifetime' => 3600, ); - public function queryAttributes($builder) + public function queryAttributes($builder): string { $script = "protected \$queryKey = ''; "; diff --git a/generator/lib/behavior/sluggable/SluggableBehavior.php b/generator/lib/behavior/sluggable/SluggableBehavior.php index a080b8047..bc643338e 100644 --- a/generator/lib/behavior/sluggable/SluggableBehavior.php +++ b/generator/lib/behavior/sluggable/SluggableBehavior.php @@ -57,7 +57,7 @@ public function modifyTable() * * @return string The related getter, e.g. 'getSlug' */ - protected function getColumnGetter() + protected function getColumnGetter(): string { return 'get' . $this->getColumnForParameter('slug_column')->getPhpName(); } @@ -67,7 +67,7 @@ protected function getColumnGetter() * * @return string The related setter, e.g. 'setSlug' */ - protected function getColumnSetter() + protected function getColumnSetter(): string { return 'set' . $this->getColumnForParameter('slug_column')->getPhpName(); } @@ -77,7 +77,7 @@ protected function getColumnSetter() * * @return string The code to put at the hook */ - public function preSave(PHP5ObjectBuilder $builder) + public function preSave(PHP5ObjectBuilder $builder): string { $const = $builder->getColumnConstant($this->getColumnForParameter('slug_column')); $pattern = $this->getParameter('slug_pattern'); @@ -192,7 +192,7 @@ protected function createSlug() "; } - protected function addCreateRawSlug(&$script) + protected function addCreateRawSlug(&$script): string { $pattern = $this->getParameter('slug_pattern'); $script .= " @@ -231,7 +231,7 @@ protected static function cleanupSlugPart(\$slug, \$replacement = '" . $this->ge { // transliterate if (function_exists('iconv')) { - \$slug = iconv('utf-8', 'us-ascii//TRANSLIT', \$slug); + \$slug = iconv('utf-8', 'us-ascii//TRANSLIT', (string)\$slug); } // lowercase @@ -432,7 +432,7 @@ public function findOneBySlug(\$slug, \$con = null) * * @return string */ - protected function underscore($string) + protected function underscore($string): string { return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), strtr($string, '_', '.'))); } diff --git a/generator/lib/behavior/sortable/SortableBehavior.php b/generator/lib/behavior/sortable/SortableBehavior.php index 847eec9ea..4df3712f7 100644 --- a/generator/lib/behavior/sortable/SortableBehavior.php +++ b/generator/lib/behavior/sortable/SortableBehavior.php @@ -137,7 +137,7 @@ public function generateScopePhp() * @param string $name * @return string */ - public function getColumnGetter($name) + public function getColumnGetter($name): string { return 'get' . $this->getTable()->getColumn($name)->getPhpName(); } @@ -148,7 +148,7 @@ public function getColumnGetter($name) * @param string $name * @return string */ - public function getColumnSetter($name) + public function getColumnSetter($name): string { return 'set' . $this->getTable()->getColumn($name)->getPhpName(); } @@ -182,7 +182,7 @@ public function getScopes() * * @return bool */ - public function hasMultipleScopes() + public function hasMultipleScopes(): bool { return count($this->getScopes()) > 1; } @@ -214,7 +214,7 @@ public function getPeerBuilderModifier() return $this->peerBuilderModifier; } - public function useScope() + public function useScope(): bool { return $this->getParameter('use_scope') == 'true'; } diff --git a/generator/lib/behavior/sortable/SortableBehaviorObjectBuilderModifier.php b/generator/lib/behavior/sortable/SortableBehaviorObjectBuilderModifier.php index 5f965d591..7816f13c1 100644 --- a/generator/lib/behavior/sortable/SortableBehaviorObjectBuilderModifier.php +++ b/generator/lib/behavior/sortable/SortableBehaviorObjectBuilderModifier.php @@ -54,7 +54,7 @@ protected function getParameter($key) return $this->behavior->getParameter($key); } - protected function getColumnAttribute($name) + protected function getColumnAttribute($name): string { return strtolower($this->behavior->getColumnForParameter($name)->getName()); } @@ -77,7 +77,7 @@ protected function setBuilder($builder) * * @return string The related getter, e.g. 'getRank' */ - protected function getColumnGetter($columnName = 'rank_column') + protected function getColumnGetter($columnName = 'rank_column'): string { return 'get' . $this->behavior->getColumnForParameter($columnName)->getPhpName(); } @@ -87,17 +87,17 @@ protected function getColumnGetter($columnName = 'rank_column') * * @return string The related setter, e.g. 'setRank' */ - protected function getColumnSetter($columnName = 'rank_column') + protected function getColumnSetter($columnName = 'rank_column'): string { return 'set' . $this->behavior->getColumnForParameter($columnName)->getPhpName(); } - public function preSave($builder) + public function preSave($builder): string { return "\$this->processSortableQueries(\$con);"; } - public function preInsert($builder) + public function preInsert($builder): string { $useScope = $this->behavior->useScope(); $this->setBuilder($builder); @@ -132,7 +132,7 @@ public function preUpdate($builder) } } - public function preDelete($builder) + public function preDelete($builder): string { $useScope = $this->behavior->useScope(); $this->setBuilder($builder); @@ -143,7 +143,7 @@ public function preDelete($builder) "; } - public function objectAttributes($builder) + public function objectAttributes($builder): string { $script = " /** diff --git a/generator/lib/behavior/sortable/SortableBehaviorPeerBuilderModifier.php b/generator/lib/behavior/sortable/SortableBehaviorPeerBuilderModifier.php index 85ac11bda..a7171a968 100644 --- a/generator/lib/behavior/sortable/SortableBehaviorPeerBuilderModifier.php +++ b/generator/lib/behavior/sortable/SortableBehaviorPeerBuilderModifier.php @@ -54,7 +54,7 @@ protected function getParameter($key) return $this->behavior->getParameter($key); } - protected function getColumnAttribute($name) + protected function getColumnAttribute($name): string { return strtolower($this->behavior->getColumnForParameter($name)->getName()); } @@ -80,7 +80,7 @@ protected function setBuilder($builder) $builder->declareClassFromBuilder($builder->getStubQueryBuilder()); } - public function staticAttributes($builder) + public function staticAttributes($builder): string { $tableName = $this->table->getName(); $script = " diff --git a/generator/lib/behavior/sortable/SortableRelationBehavior.php b/generator/lib/behavior/sortable/SortableRelationBehavior.php index fd00a9e80..a34e0e57a 100644 --- a/generator/lib/behavior/sortable/SortableRelationBehavior.php +++ b/generator/lib/behavior/sortable/SortableRelationBehavior.php @@ -34,7 +34,7 @@ public function objectMethods($builder) return $script; } - public function preDelete($builder) + public function preDelete($builder): string { $this->builder = $builder; @@ -61,12 +61,12 @@ protected function getRelatedClassPluralForm() return $this->builder->getPluralizer()->getPluralForm($relatedClass); } - protected function getObjectMoveRelatedToNullScopeMethodName() + protected function getObjectMoveRelatedToNullScopeMethodName(): string { return "moveRelated{$this->getRelatedClassPluralForm()}ToNullScope"; } - protected function addObjectMoveRelatedToNullScope(&$script) + protected function addObjectMoveRelatedToNullScope(&$script): string { $peerClass = $this->builder->getNewStubPeerBuilder($this->getForeignTable())->getClassname(); $queryClass = $this->builder->getNewStubQueryBuilder($this->getForeignTable())->getClassname(); diff --git a/generator/lib/behavior/versionable/VersionableBehavior.php b/generator/lib/behavior/versionable/VersionableBehavior.php index 0b50aa792..cdbe23877 100644 --- a/generator/lib/behavior/versionable/VersionableBehavior.php +++ b/generator/lib/behavior/versionable/VersionableBehavior.php @@ -194,7 +194,7 @@ public function getVersionTable() return $this->versionTable; } - public function getVersionTablePhpName() + public function getVersionTablePhpName(): string { return $this->getTable()->getPhpName() . 'Version'; } diff --git a/generator/lib/behavior/versionable/VersionableBehaviorObjectBuilderModifier.php b/generator/lib/behavior/versionable/VersionableBehaviorObjectBuilderModifier.php index 9fef51498..68660e532 100644 --- a/generator/lib/behavior/versionable/VersionableBehaviorObjectBuilderModifier.php +++ b/generator/lib/behavior/versionable/VersionableBehaviorObjectBuilderModifier.php @@ -47,7 +47,7 @@ protected function getParameter($key) return $this->behavior->getParameter($key); } - protected function getColumnAttribute($name = 'version_column') + protected function getColumnAttribute($name = 'version_column'): string { return strtolower($this->behavior->getColumnForParameter($name)->getName()); } @@ -82,7 +82,7 @@ protected function setBuilder(PHP5ObjectBuilder $builder) * * @return string The related getter, e.g. 'getVersion' */ - protected function getColumnGetter($name = 'version_column') + protected function getColumnGetter($name = 'version_column'): string { return 'get' . $this->getColumnPhpName($name); } @@ -94,12 +94,12 @@ protected function getColumnGetter($name = 'version_column') * * @return string The related setter, e.g. 'setVersion' */ - protected function getColumnSetter($name = 'version_column') + protected function getColumnSetter($name = 'version_column'): string { return 'set' . $this->getColumnPhpName($name); } - public function preSave(PHP5ObjectBuilder $builder) + public function preSave(PHP5ObjectBuilder $builder): string { $script = "if (\$this->isVersioningNecessary()) { \$this->set{$this->getColumnPhpName()}(\$this->isNew() ? 1 : \$this->getLastVersionNumber(\$con) + 1);"; @@ -126,7 +126,7 @@ public function preSave(PHP5ObjectBuilder $builder) return $script; } - public function postSave(PHP5ObjectBuilder $builder) + public function postSave(PHP5ObjectBuilder $builder): string { return "if (isset(\$createVersion)) { \$this->addVersion(\$con); diff --git a/generator/lib/behavior/versionable/VersionableBehaviorPeerBuilderModifier.php b/generator/lib/behavior/versionable/VersionableBehaviorPeerBuilderModifier.php index 83e8ad2c4..ef2c84d15 100644 --- a/generator/lib/behavior/versionable/VersionableBehaviorPeerBuilderModifier.php +++ b/generator/lib/behavior/versionable/VersionableBehaviorPeerBuilderModifier.php @@ -16,7 +16,7 @@ */ class VersionableBehaviorPeerBuilderModifier { - public function staticAttributes() + public function staticAttributes(): string { return " /** diff --git a/generator/lib/behavior/versionable/VersionableBehaviorQueryBuilderModifier.php b/generator/lib/behavior/versionable/VersionableBehaviorQueryBuilderModifier.php index 4d6735a15..be9bdb88a 100644 --- a/generator/lib/behavior/versionable/VersionableBehaviorQueryBuilderModifier.php +++ b/generator/lib/behavior/versionable/VersionableBehaviorQueryBuilderModifier.php @@ -29,7 +29,7 @@ protected function getParameter($key) return $this->behavior->getParameter($key); } - protected function getColumnAttribute($name = 'version_column') + protected function getColumnAttribute($name = 'version_column'): string { return strtolower($this->behavior->getColumnForParameter($name)->getName()); } @@ -59,7 +59,7 @@ protected function setBuilder($builder) * * @return string The related getter, e.g. 'getVersion' */ - protected function getColumnGetter($name = 'version_column') + protected function getColumnGetter($name = 'version_column'): string { return 'get' . $this->getColumnPhpName($name); } @@ -71,7 +71,7 @@ protected function getColumnGetter($name = 'version_column') * * @return string The related setter, e.g. 'setVersion' */ - protected function getColumnSetter($name = 'version_column') + protected function getColumnSetter($name = 'version_column'): string { return 'set' . $this->getColumnPhpName($name); } diff --git a/generator/lib/builder/om/ClassTools.php b/generator/lib/builder/om/ClassTools.php index cd084c8f5..8f122db63 100644 --- a/generator/lib/builder/om/ClassTools.php +++ b/generator/lib/builder/om/ClassTools.php @@ -69,7 +69,7 @@ public static function getFilePath($path, $classname = null, $extension = '.php' * * @return string The constructed file path. */ - public static function createFilePath($path, $classname = null, $extension = '.php') + public static function createFilePath($path, $classname = null, $extension = '.php'): string { if ($classname !== null) { if ($path !== '') { diff --git a/generator/lib/builder/om/ExtensionQueryBuilder.php b/generator/lib/builder/om/ExtensionQueryBuilder.php index c7f4bd01d..85cce8c1b 100644 --- a/generator/lib/builder/om/ExtensionQueryBuilder.php +++ b/generator/lib/builder/om/ExtensionQueryBuilder.php @@ -26,7 +26,7 @@ class ExtensionQueryBuilder extends OMBuilder * * @return string */ - public function getUnprefixedClassname() + public function getUnprefixedClassname(): string { return $this->getTable()->getPhpName() . 'Query'; } @@ -67,7 +67,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * diff --git a/generator/lib/builder/om/ExtensionQueryInheritanceBuilder.php b/generator/lib/builder/om/ExtensionQueryInheritanceBuilder.php index 0823d2a87..4625681ca 100644 --- a/generator/lib/builder/om/ExtensionQueryInheritanceBuilder.php +++ b/generator/lib/builder/om/ExtensionQueryInheritanceBuilder.php @@ -32,7 +32,7 @@ class ExtensionQueryInheritanceBuilder extends OMBuilder * * @return string */ - public function getUnprefixedClassname() + public function getUnprefixedClassname(): string { return $this->getChild()->getClassName() . 'Query'; } @@ -109,7 +109,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * diff --git a/generator/lib/builder/om/PHP5ExtensionNodeBuilder.php b/generator/lib/builder/om/PHP5ExtensionNodeBuilder.php index 3e241bf66..b8388c88e 100644 --- a/generator/lib/builder/om/PHP5ExtensionNodeBuilder.php +++ b/generator/lib/builder/om/PHP5ExtensionNodeBuilder.php @@ -26,7 +26,7 @@ class PHP5ExtensionNodeBuilder extends ObjectBuilder * * @return string */ - public function getUnprefixedClassname() + public function getUnprefixedClassname(): string { return $this->getTable()->getPhpName() . 'Node'; } @@ -65,7 +65,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * diff --git a/generator/lib/builder/om/PHP5ExtensionNodePeerBuilder.php b/generator/lib/builder/om/PHP5ExtensionNodePeerBuilder.php index d3e4142e4..33262f157 100644 --- a/generator/lib/builder/om/PHP5ExtensionNodePeerBuilder.php +++ b/generator/lib/builder/om/PHP5ExtensionNodePeerBuilder.php @@ -26,7 +26,7 @@ class PHP5ExtensionNodePeerBuilder extends PeerBuilder * * @return string */ - public function getUnprefixedClassname() + public function getUnprefixedClassname(): string { return $this->getStubNodeBuilder()->getClassname() . 'Peer'; } @@ -65,7 +65,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * diff --git a/generator/lib/builder/om/PHP5ExtensionObjectBuilder.php b/generator/lib/builder/om/PHP5ExtensionObjectBuilder.php index 5c74f8b60..ad7614ca8 100644 --- a/generator/lib/builder/om/PHP5ExtensionObjectBuilder.php +++ b/generator/lib/builder/om/PHP5ExtensionObjectBuilder.php @@ -88,7 +88,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * diff --git a/generator/lib/builder/om/PHP5ExtensionPeerBuilder.php b/generator/lib/builder/om/PHP5ExtensionPeerBuilder.php index daa85c71b..10f4fb9bc 100644 --- a/generator/lib/builder/om/PHP5ExtensionPeerBuilder.php +++ b/generator/lib/builder/om/PHP5ExtensionPeerBuilder.php @@ -26,7 +26,7 @@ class PHP5ExtensionPeerBuilder extends PeerBuilder * * @return string */ - public function getUnprefixedClassname() + public function getUnprefixedClassname(): string { return $this->getStubObjectBuilder()->getUnprefixedClassname() . 'Peer'; } @@ -88,7 +88,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * diff --git a/generator/lib/builder/om/PHP5InterfaceBuilder.php b/generator/lib/builder/om/PHP5InterfaceBuilder.php index 2788fb561..748dfa871 100644 --- a/generator/lib/builder/om/PHP5InterfaceBuilder.php +++ b/generator/lib/builder/om/PHP5InterfaceBuilder.php @@ -61,7 +61,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * diff --git a/generator/lib/builder/om/PHP5MultiExtendObjectBuilder.php b/generator/lib/builder/om/PHP5MultiExtendObjectBuilder.php index d648ee124..783480c8c 100644 --- a/generator/lib/builder/om/PHP5MultiExtendObjectBuilder.php +++ b/generator/lib/builder/om/PHP5MultiExtendObjectBuilder.php @@ -145,7 +145,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * diff --git a/generator/lib/builder/om/PHP5NestedSetBuilder.php b/generator/lib/builder/om/PHP5NestedSetBuilder.php index 3b8ed4bee..ea1a2a282 100644 --- a/generator/lib/builder/om/PHP5NestedSetBuilder.php +++ b/generator/lib/builder/om/PHP5NestedSetBuilder.php @@ -26,7 +26,7 @@ class PHP5NestedSetBuilder extends ObjectBuilder * * @return string */ - public function getPackage() + public function getPackage(): string { return parent::getPackage() . ".om"; } @@ -36,7 +36,7 @@ public function getPackage() * * @return string */ - public function getUnprefixedClassname() + public function getUnprefixedClassname(): string { return $this->getBuildProperty('basePrefix') . $this->getStubObjectBuilder()->getUnprefixedClassname() . 'NestedSet'; } @@ -72,7 +72,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * @@ -239,7 +239,7 @@ protected function addGetIterator(&$script) * * @return NodeIterator */ - public function getIterator() + public function getIterator(): Iterator { return new NestedSetRecursiveIterator(\$this); } diff --git a/generator/lib/builder/om/PHP5NestedSetPeerBuilder.php b/generator/lib/builder/om/PHP5NestedSetPeerBuilder.php index 2a05e160f..ec1e4f132 100644 --- a/generator/lib/builder/om/PHP5NestedSetPeerBuilder.php +++ b/generator/lib/builder/om/PHP5NestedSetPeerBuilder.php @@ -26,7 +26,7 @@ class PHP5NestedSetPeerBuilder extends PeerBuilder * * @return string */ - public function getPackage() + public function getPackage(): string { return parent::getPackage() . ".om"; } @@ -36,7 +36,7 @@ public function getPackage() * * @return string */ - public function getUnprefixedClassname() + public function getUnprefixedClassname(): string { return $this->getBuildProperty('basePrefix') . $this->getStubObjectBuilder()->getUnprefixedClassname() . 'NestedSetPeer'; } @@ -72,7 +72,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * diff --git a/generator/lib/builder/om/PHP5NodeBuilder.php b/generator/lib/builder/om/PHP5NodeBuilder.php index 691979db1..109382523 100644 --- a/generator/lib/builder/om/PHP5NodeBuilder.php +++ b/generator/lib/builder/om/PHP5NodeBuilder.php @@ -26,7 +26,7 @@ class PHP5NodeBuilder extends ObjectBuilder * * @return string */ - public function getPackage() + public function getPackage(): string { return parent::getPackage() . ".om"; } @@ -36,7 +36,7 @@ public function getPackage() * * @return string */ - public function getUnprefixedClassname() + public function getUnprefixedClassname(): string { return $this->getBuildProperty('basePrefix') . $this->getStubNodeBuilder()->getUnprefixedClassname(); } @@ -69,7 +69,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * diff --git a/generator/lib/builder/om/PHP5NodePeerBuilder.php b/generator/lib/builder/om/PHP5NodePeerBuilder.php index 133e3e1ba..7d9ee24bd 100644 --- a/generator/lib/builder/om/PHP5NodePeerBuilder.php +++ b/generator/lib/builder/om/PHP5NodePeerBuilder.php @@ -26,7 +26,7 @@ class PHP5NodePeerBuilder extends PeerBuilder * * @return string */ - public function getPackage() + public function getPackage(): string { return parent::getPackage() . ".om"; } @@ -36,7 +36,7 @@ public function getPackage() * * @return string */ - public function getUnprefixedClassname() + public function getUnprefixedClassname(): string { return $this->getBuildProperty('basePrefix') . $this->getStubNodePeerBuilder()->getUnprefixedClassname(); } @@ -69,7 +69,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * diff --git a/generator/lib/builder/om/PHP5ObjectBuilder.php b/generator/lib/builder/om/PHP5ObjectBuilder.php index 6b5407019..316130e17 100644 --- a/generator/lib/builder/om/PHP5ObjectBuilder.php +++ b/generator/lib/builder/om/PHP5ObjectBuilder.php @@ -217,7 +217,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * @@ -1017,7 +1017,8 @@ protected function addTemporalAccessorBody(&$script, Column $col) $script .= " } - if (strpos(\$format, '%') !== false) { + if (strpos(\$format, '%') !== false) { + trigger_deprecation('dayspring-tech/propel1', '1.9', 'Using strftime style \"%\" formatting is deprecated. PHP 8.1 deprecated strftime().'); return strftime(\$format, \$dt->format('U')); } diff --git a/generator/lib/builder/om/PHP5ObjectNoCollectionBuilder.php b/generator/lib/builder/om/PHP5ObjectNoCollectionBuilder.php index c2549122d..1eaaaaef8 100644 --- a/generator/lib/builder/om/PHP5ObjectNoCollectionBuilder.php +++ b/generator/lib/builder/om/PHP5ObjectNoCollectionBuilder.php @@ -472,7 +472,7 @@ public function reload(\$deep = false, PropelPDO \$con = null) * * @return string */ - protected function getRefFKLastCriteriaVarName(ForeignKey $fk) + protected function getRefFKLastCriteriaVarName(ForeignKey $fk): string { return 'last' . $this->getRefFKPhpNameAffix($fk, $plural = false) . 'Criteria'; } diff --git a/generator/lib/builder/om/PHP5PeerBuilder.php b/generator/lib/builder/om/PHP5PeerBuilder.php index 063d8def0..5a4a8457c 100644 --- a/generator/lib/builder/om/PHP5PeerBuilder.php +++ b/generator/lib/builder/om/PHP5PeerBuilder.php @@ -56,7 +56,7 @@ protected function validateModel() * * @return string */ - public function getUnprefixedClassname() + public function getUnprefixedClassname(): string { return $this->getBuildProperty('basePrefix') . $this->getStubPeerBuilder()->getUnprefixedClassname(); } @@ -66,7 +66,7 @@ public function getUnprefixedClassname() * * @return string */ - public function getPackage() + public function getPackage(): string { return parent::getPackage() . ".om"; } @@ -109,7 +109,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * @@ -179,7 +179,7 @@ protected function addStaticTableMapRegistration(&$script) $this->applyBehaviorModifier('peerFilter', $script, ""); } - public function getTableMapClass() + public function getTableMapClass(): string { // Trim first backslash for php 5.3.{0,1,2} compatibility $fullyQualifiedClassname = ltrim($this->getStubObjectBuilder()->getFullyQualifiedClassname(), '\\'); @@ -298,7 +298,7 @@ protected function addEnumColumnConstants(&$script) } } - protected function getEnumValueConstant($value) + protected function getEnumValueConstant($value): string { return strtoupper(preg_replace('/[^a-zA-Z0-9_\x7f-\xff]/', '_', $value)); } @@ -884,7 +884,7 @@ public static function doSelectStmt(Criteria \$criteria, PropelPDO \$con = null) * * @return string */ - public function getInstancePoolKeySnippet($pkphp) + public function getInstancePoolKeySnippet($pkphp): string { $pkphp = (array) $pkphp; // make it an array if it is not. $script = ""; @@ -2217,7 +2217,7 @@ protected function getPrimaryKeyColOffsets(Table $tbl) return $offsets; } - public function addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder) + public function addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder): string { $script = ''; $lfMap = $fk->getLocalForeignMapping(); @@ -3014,7 +3014,7 @@ public static function doCountJoinAllExcept" . $thisTableObjectBuilder->getFKPhp * see trac ticket #588, #491 * */ - protected function getJoinBehavior() + protected function getJoinBehavior(): string { return $this->getGeneratorConfig()->getBuildProperty('useLeftJoinsInDoJoinMethods') ? 'Criteria::LEFT_JOIN' : 'Criteria::INNER_JOIN'; } diff --git a/generator/lib/builder/om/PHP5TableMapBuilder.php b/generator/lib/builder/om/PHP5TableMapBuilder.php index 711554acb..a8b6c71f5 100644 --- a/generator/lib/builder/om/PHP5TableMapBuilder.php +++ b/generator/lib/builder/om/PHP5TableMapBuilder.php @@ -23,7 +23,7 @@ class PHP5TableMapBuilder extends OMBuilder * * @return string */ - public function getPackage() + public function getPackage(): string { return parent::getPackage() . '.map'; } @@ -44,7 +44,7 @@ public function getNamespace() * * @return string */ - public function getUnprefixedClassname() + public function getUnprefixedClassname(): string { return $this->getTable()->getPhpName() . 'TableMap'; } @@ -73,7 +73,7 @@ protected function addClassOpen(&$script) * *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * diff --git a/generator/lib/builder/om/QueryBuilder.php b/generator/lib/builder/om/QueryBuilder.php index f01d3a623..79c43d9f6 100644 --- a/generator/lib/builder/om/QueryBuilder.php +++ b/generator/lib/builder/om/QueryBuilder.php @@ -26,7 +26,7 @@ class QueryBuilder extends OMBuilder * * @return string */ - public function getPackage() + public function getPackage(): string { return parent::getPackage() . ".om"; } @@ -47,7 +47,7 @@ public function getNamespace() * * @return string */ - public function getUnprefixedClassname() + public function getUnprefixedClassname(): string { return $this->getBuildProperty('basePrefix') . $this->getStubQueryBuilder()->getUnprefixedClassname(); } @@ -84,7 +84,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * @@ -931,7 +931,7 @@ public function filterBy$colPhpName(\$$variableName = null, \$comparison = null) if (null === \$comparison) { if (is_array(\$$variableName)) { \$comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', \$$variableName)) { + } elseif (preg_match('/[\%\*]/', (string)\$$variableName)) { \$$variableName = str_replace('*', '%', \$$variableName); \$comparison = Criteria::LIKE; } diff --git a/generator/lib/builder/om/QueryInheritanceBuilder.php b/generator/lib/builder/om/QueryInheritanceBuilder.php index f28392fdf..ca4425969 100644 --- a/generator/lib/builder/om/QueryInheritanceBuilder.php +++ b/generator/lib/builder/om/QueryInheritanceBuilder.php @@ -33,7 +33,7 @@ class QueryInheritanceBuilder extends OMBuilder * * @return string */ - public function getUnprefixedClassname() + public function getUnprefixedClassname(): string { return $this->getBuildProperty('basePrefix') . $this->getNewStubQueryInheritanceBuilder($this->getChild())->getUnprefixedClassname(); } @@ -43,7 +43,7 @@ public function getUnprefixedClassname() * * @return string */ - public function getPackage() + public function getPackage(): string { return ($this->getChild()->getPackage() ? $this->getChild()->getPackage() : parent::getPackage()) . ".om"; } @@ -140,7 +140,7 @@ protected function addClassOpen(&$script) * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { - $now = strftime('%c'); + $now = (new DateTime())->format(DateTimeInterface::ATOM); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * @@ -263,7 +263,7 @@ public function preDelete(PropelPDO \$con) "; } - protected function getClassKeyCondition() + protected function getClassKeyCondition(): string { $child = $this->getChild(); $col = $child->getColumn(); diff --git a/generator/lib/builder/sql/mssql/MssqlDataSQLBuilder.php b/generator/lib/builder/sql/mssql/MssqlDataSQLBuilder.php index 4245a43ea..6f5987a17 100644 --- a/generator/lib/builder/sql/mssql/MssqlDataSQLBuilder.php +++ b/generator/lib/builder/sql/mssql/MssqlDataSQLBuilder.php @@ -24,7 +24,7 @@ class MssqlDataSQLBuilder extends DataSQLBuilder * * @return string */ - protected function getBlobSql($blob) + protected function getBlobSql($blob): string { // they took magic __toString() out of PHP5.0.0; this sucks if (is_object($blob)) { diff --git a/generator/lib/builder/sql/pgsql/PgsqlDataSQLBuilder.php b/generator/lib/builder/sql/pgsql/PgsqlDataSQLBuilder.php index 192efb03b..9d3c0880e 100644 --- a/generator/lib/builder/sql/pgsql/PgsqlDataSQLBuilder.php +++ b/generator/lib/builder/sql/pgsql/PgsqlDataSQLBuilder.php @@ -61,7 +61,7 @@ public function buildRowSql(DataRow $row) return $sql; } - public function getTableEndSql() + public function getTableEndSql(): string { $table = $this->getTable(); $sql = ""; @@ -81,7 +81,7 @@ public function getTableEndSql() * * @return string The representation of boolean for Postgres ('t' or 'f'). */ - protected function getBooleanSql($value) + protected function getBooleanSql($value): string { if ($value === 'f' || $value === 'false' || $value === "0") { $value = false; @@ -96,7 +96,7 @@ protected function getBooleanSql($value) * * @return string */ - protected function getBlobSql($blob) + protected function getBlobSql($blob): string { // they took magic __toString() out of PHP5.0.0; this sucks if (is_object($blob)) { diff --git a/generator/lib/builder/sql/sqlite/SqliteDataSQLBuilder.php b/generator/lib/builder/sql/sqlite/SqliteDataSQLBuilder.php index ff295f24f..8f8798b2f 100644 --- a/generator/lib/builder/sql/sqlite/SqliteDataSQLBuilder.php +++ b/generator/lib/builder/sql/sqlite/SqliteDataSQLBuilder.php @@ -25,7 +25,7 @@ class SqliteDataSQLBuilder extends DataSQLBuilder * * @return string encoded text */ - protected function getBlobSql($blob) + protected function getBlobSql($blob): string { // they took magic __toString() out of PHP5.0.0; this sucks if (is_object($blob)) { diff --git a/generator/lib/builder/util/DefaultEnglishPluralizer.php b/generator/lib/builder/util/DefaultEnglishPluralizer.php index 53c8bfbbe..12d5c8fe3 100644 --- a/generator/lib/builder/util/DefaultEnglishPluralizer.php +++ b/generator/lib/builder/util/DefaultEnglishPluralizer.php @@ -26,7 +26,7 @@ class DefaultEnglishPluralizer implements Pluralizer * * @return string The plural form of $root (e.g. Authors). */ - public function getPluralForm($root) + public function getPluralForm($root): string { return $root . 's'; } diff --git a/generator/lib/builder/util/PropelStringReader.php b/generator/lib/builder/util/PropelStringReader.php index e2f8a6258..14657178c 100644 --- a/generator/lib/builder/util/PropelStringReader.php +++ b/generator/lib/builder/util/PropelStringReader.php @@ -44,7 +44,7 @@ public function skip($n) $this->currPos = $this->currPos + $n; } - public function eof() + public function eof(): bool { return $this->currPos == strlen($this->_string); } diff --git a/generator/lib/builder/util/XmlToAppData.php b/generator/lib/builder/util/XmlToAppData.php index 60ff72105..d6794448d 100644 --- a/generator/lib/builder/util/XmlToAppData.php +++ b/generator/lib/builder/util/XmlToAppData.php @@ -408,12 +408,12 @@ protected function isAlreadyParsed($filePath) */ protected function isAbsolutePath($file) { - if (strspn($file, '/\\', 0, 1) - || (strlen($file) > 3 && ctype_alpha($file[0]) - && substr($file, 1, 1) === ':' - && (strspn($file, '/\\', 2, 1)) + if (strspn((string)$file, '/\\', 0, 1) + || (strlen((string)$file) > 3 && ctype_alpha($file[0]) + && substr((string)$file, 1, 1) === ':' + && (strspn((string)$file, '/\\', 2, 1)) ) - || null !== parse_url($file, PHP_URL_SCHEME) + || null !== parse_url((string)$file, PHP_URL_SCHEME) ) { return true; } diff --git a/generator/lib/config/GeneratorConfig.php b/generator/lib/config/GeneratorConfig.php index dd2166620..577ab6402 100644 --- a/generator/lib/config/GeneratorConfig.php +++ b/generator/lib/config/GeneratorConfig.php @@ -275,7 +275,7 @@ public function getBuildConnections() // probably using the command line, which doesn't accept whitespace // therefore base64 encoded $this->parseBuildConnections(base64_decode($buildTimeConfigString)); - } elseif (file_exists($buildTimeConfigPath)) { + } elseif (file_exists((string)$buildTimeConfigPath)) { // configuration stored in a buildtime-conf.xml file $this->parseBuildConnections(file_get_contents($buildTimeConfigPath)); } else { diff --git a/generator/lib/model/AppData.php b/generator/lib/model/AppData.php index 427aed1cd..8befead00 100644 --- a/generator/lib/model/AppData.php +++ b/generator/lib/model/AppData.php @@ -160,7 +160,7 @@ public function getDatabases($doFinalInit = true) * * @return boolean True if the application has multiple databases */ - public function hasMultipleDatabases() + public function hasMultipleDatabases(): bool { return (count($this->dbList) > 1); } @@ -202,7 +202,7 @@ public function getDatabase($name = null, $doFinalInit = true) * * @return boolean */ - public function hasDatabase($name) + public function hasDatabase($name): bool { foreach ($this->dbList as $db) { if ($db->getName() === $name) { @@ -316,7 +316,7 @@ public function countTables() * * @return string Representation in xml format */ - public function toString() + public function toString(): string { $result = "\n"; foreach ($this->dbList as $dbList) { diff --git a/generator/lib/model/Column.php b/generator/lib/model/Column.php index 6b30af05f..616a96f38 100644 --- a/generator/lib/model/Column.php +++ b/generator/lib/model/Column.php @@ -115,7 +115,7 @@ public function __construct($name = null) * * @return string */ - public static function makeList($columns, PropelPlatformInterface $platform) + public static function makeList($columns, PropelPlatformInterface $platform): string { $list = array(); foreach ($columns as $col) { @@ -140,7 +140,7 @@ protected function setupObject() if ($dom) { $this->getDomain()->copy($this->getTable()->getDatabase()->getDomain($dom)); } else { - $type = strtoupper($this->getAttribute("type")); + $type = strtoupper((string)$this->getAttribute("type")); if ($type) { if ($platform = $this->getPlatform()) { $this->getDomain()->copy($this->getPlatform()->getDomainForType($type)); @@ -290,7 +290,7 @@ public function setDomain(Domain $domain) /** * Returns table.column */ - public function getFullyQualifiedName() + public function getFullyQualifiedName(): string { return ($this->parentTable->getName() . '.' . $this->getName()); } @@ -314,7 +314,7 @@ public function setName($newName) /** * Determines whether a column name is plural */ - public function isNamePlural() + public function isNamePlural(): bool { return $this->getSingularName() != $this->name; } @@ -322,7 +322,7 @@ public function isNamePlural() /** * Gets the singular name for the column */ - public function getSingularName() + public function getSingularName(): string { return rtrim($this->name, 's'); } @@ -385,7 +385,7 @@ public function setPhpName($phpName = null) * * @return string */ - public function getStudlyPhpName() + public function getStudlyPhpName(): string { $phpname = $this->getPhpName(); if (strlen($phpname) > 1) { @@ -457,7 +457,7 @@ public function setMutatorVisibility($newVisibility) * * @return string A column constant name for insertion into PHP code */ - public function getConstantName() + public function getConstantName(): string { $classname = $this->getTable()->getPhpName() . 'Peer'; $const = $this->getConstantColumnName(); @@ -465,7 +465,7 @@ public function getConstantName() return $classname . '::' . $const; } - public function getConstantColumnName() + public function getConstantColumnName(): string { // was it overridden in schema.xml ? if ($this->getPeerName()) { @@ -790,7 +790,7 @@ public function requiresTransactionInPostgres() * * @return boolean */ - public function isForeignKey() + public function isForeignKey(): bool { return (count($this->getForeignKeys()) > 0); } @@ -800,7 +800,7 @@ public function isForeignKey() * * @return boolean */ - public function hasMultipleFK() + public function hasMultipleFK(): bool { return (count($this->getForeignKeys()) > 1); } @@ -838,12 +838,12 @@ public function getReferrers() return $this->referrers; } - public function hasReferrers() + public function hasReferrers(): bool { return $this->referrers !== null; } - public function hasReferrer(ForeignKey $fk) + public function hasReferrer(ForeignKey $fk): bool { return $this->hasReferrers() && in_array($fk, $this->referrers, true); } @@ -915,7 +915,7 @@ public function getPropelType() return $this->getType(); } - public function isDefaultSqlType(PropelPlatformInterface $platform = null) + public function isDefaultSqlType(PropelPlatformInterface $platform = null): bool { if (null === $this->domain || null === $this->domain->getSqlType() || null === $platform) { return true; @@ -991,7 +991,7 @@ public function isPhpArrayType() * * @return boolean */ - public function isEnumType() + public function isEnumType(): bool { return $this->getType() == PropelTypes::ENUM; } @@ -1350,7 +1350,7 @@ public function getPlatform() return $this->getTable()->getDatabase()->getPlatform(); } - public function hasPlatform() + public function hasPlatform(): bool { return null !== $this->getTable() && null !== $this->getTable()->getDatabase() && null !== $this->getTable()->getDatabase()->getPlatform(); } diff --git a/generator/lib/model/ColumnDefaultValue.php b/generator/lib/model/ColumnDefaultValue.php index 3eb37ffe1..22e2f39ce 100644 --- a/generator/lib/model/ColumnDefaultValue.php +++ b/generator/lib/model/ColumnDefaultValue.php @@ -66,7 +66,7 @@ public function setType($type) * * @return boolean Whether value this object holds is an expression. */ - public function isExpression() + public function isExpression(): bool { return ($this->type == self::TYPE_EXPR); } @@ -95,7 +95,7 @@ public function setValue($value) * @return boolean Whether this object represents same default value as $other * @author Niklas Närhinen */ - public function equals(ColumnDefaultValue $other) + public function equals(ColumnDefaultValue $other): bool { if ($this->getType() != $other->getType()) { return false; diff --git a/generator/lib/model/ConstraintNameGenerator.php b/generator/lib/model/ConstraintNameGenerator.php index 7a88ee816..50f2ed993 100644 --- a/generator/lib/model/ConstraintNameGenerator.php +++ b/generator/lib/model/ConstraintNameGenerator.php @@ -35,7 +35,7 @@ class ConstraintNameGenerator implements NameGenerator * @see NameGenerator * @throws EngineException */ - public function generateName($inputs) + public function generateName($inputs): string { /* @var $db Database */ $db = $inputs[0]; diff --git a/generator/lib/model/Database.php b/generator/lib/model/Database.php index b1bd8a7f6..2bdd3d745 100644 --- a/generator/lib/model/Database.php +++ b/generator/lib/model/Database.php @@ -318,7 +318,7 @@ public function getTables() * * @return integer */ - public function countTables() + public function countTables(): int { $count = 0; foreach ($this->tableList as $table) { @@ -355,7 +355,7 @@ public function getTablesForSql() * * @return boolean */ - public function hasTable($name, $caseInsensitive = false) + public function hasTable($name, $caseInsensitive = false): bool { if ($caseInsensitive) { return array_key_exists(strtolower($name), $this->tablesByLowercaseName); @@ -392,7 +392,7 @@ public function getTable($name, $caseInsensitive = false) * * @return boolean */ - public function hasTableByPhpName($phpName) + public function hasTableByPhpName($phpName): bool { return array_key_exists($phpName, $this->tablesByPhpName); } @@ -429,9 +429,9 @@ public function addTable($data) } $this->tableList[] = $tbl; $this->tablesByName[$tbl->getName()] = $tbl; - $this->tablesByLowercaseName[strtolower($tbl->getName())] = $tbl; + $this->tablesByLowercaseName[strtolower((string)$tbl->getName())] = $tbl; $this->tablesByPhpName[$tbl->getPhpName()] = $tbl; - if (strpos($tbl->getNamespace(), '\\') === 0) { + if (strpos((string)$tbl->getNamespace(), '\\') === 0) { $tbl->setNamespace(substr($tbl->getNamespace(), 1)); } elseif ($namespace = $this->getNamespace()) { if ($tbl->getNamespace() === null) { @@ -568,7 +568,7 @@ public function getBehaviors() * * @return boolean True if the behavior exists */ - public function hasBehavior($name) + public function hasBehavior($name): bool { return array_key_exists($name, $this->behaviors); } diff --git a/generator/lib/model/ForeignKey.php b/generator/lib/model/ForeignKey.php index 949a06f98..1f5ce031c 100644 --- a/generator/lib/model/ForeignKey.php +++ b/generator/lib/model/ForeignKey.php @@ -108,7 +108,7 @@ protected function setupObject() /** * normalizes the input of onDelete, onUpdate attributes */ - public function normalizeFKey($attrib) + public function normalizeFKey($attrib): string { if ($attrib === null || strtoupper($attrib) == "NONE") { $attrib = self::NONE; @@ -124,7 +124,7 @@ public function normalizeFKey($attrib) /** * returns whether or not the onUpdate attribute is set */ - public function hasOnUpdate() + public function hasOnUpdate(): bool { $database = $this->getTable()->getDatabase(); if($database instanceof Database && @@ -138,7 +138,7 @@ public function hasOnUpdate() /** * returns whether or not the onDelete attribute is set */ - public function hasOnDelete() + public function hasOnDelete(): bool { $database = $this->getTable()->getDatabase(); if($database instanceof Database && @@ -573,7 +573,7 @@ public function getForeignColumn($index = 0) * * @return boolean */ - public function isLocalColumnsRequired() + public function isLocalColumnsRequired(): bool { foreach ($this->getLocalColumns() as $columnName) { if (!$this->getTable()->getColumn($columnName)->isNotNull()) { @@ -589,7 +589,7 @@ public function isLocalColumnsRequired() * * @return boolean Returns true if all columns inside this foreign key are primary keys of the foreign table */ - public function isForeignPrimaryKey() + public function isForeignPrimaryKey(): bool { $lfmap = $this->getLocalForeignMapping(); $foreignTable = $this->getForeignTable(); @@ -612,7 +612,7 @@ public function isForeignPrimaryKey() * * @return boolean True if there is at least one column that is a primary key of the foreign table */ - public function isAtLeastOneForeignPrimaryKey() + public function isAtLeastOneForeignPrimaryKey(): bool { $cols = $this->getForeignPrimaryKeys(); @@ -650,7 +650,7 @@ public function getForeignPrimaryKeys() * * @return Boolean */ - public function isComposite() + public function isComposite(): bool { return count($this->getLocalColumns()) > 1; } @@ -660,7 +660,7 @@ public function isComposite() * * @return boolean True if all local columns are at the same time a primary key */ - public function isLocalPrimaryKey() + public function isLocalPrimaryKey(): bool { $localCols = $this->getLocalColumns(); @@ -679,7 +679,7 @@ public function isLocalPrimaryKey() * * @return boolean True if there is at least one column that is a primary key */ - public function isAtLeastOneLocalPrimaryKey() + public function isAtLeastOneLocalPrimaryKey(): bool { $localCols = $this->getLocalColumnObjects(); @@ -724,7 +724,7 @@ public function isSkipSql() * @return boolean * @link http://propel.phpdb.org/trac/ticket/549 */ - public function isMatchedByInverseFK() + public function isMatchedByInverseFK(): bool { return (bool) $this->getInverseFK(); } diff --git a/generator/lib/model/PhpNameGenerator.php b/generator/lib/model/PhpNameGenerator.php index 46b009f36..21938bb62 100644 --- a/generator/lib/model/PhpNameGenerator.php +++ b/generator/lib/model/PhpNameGenerator.php @@ -97,7 +97,7 @@ public function generateName($inputs) protected function underscoreMethod($schemaName) { $name = ""; - $tok = strtok($schemaName, self::STD_SEPARATOR_CHAR); + $tok = strtok((string)$schemaName, self::STD_SEPARATOR_CHAR); while ($tok !== false) { $name .= ucfirst(strtolower($tok)); $tok = strtok(self::STD_SEPARATOR_CHAR); diff --git a/generator/lib/model/PropelTypes.php b/generator/lib/model/PropelTypes.php index b163e4838..7c4a53e3d 100644 --- a/generator/lib/model/PropelTypes.php +++ b/generator/lib/model/PropelTypes.php @@ -284,7 +284,7 @@ public static function getPropelType($sqlType) * * @return string[] */ - public static function getPropelTypes() + public static function getPropelTypes(): array { return array_keys(self::$propelTypeToCreoleTypeMap); } @@ -296,7 +296,7 @@ public static function getPropelTypes() * * @return boolean */ - public static function isTemporalType($type) + public static function isTemporalType($type): bool { return in_array($type, self::$TEMPORAL_TYPES); } @@ -308,7 +308,7 @@ public static function isTemporalType($type) * * @return boolean True if values for the type need to be quoted. */ - public static function isTextType($type) + public static function isTextType($type): bool { return in_array($type, self::$TEXT_TYPES); } @@ -320,7 +320,7 @@ public static function isTextType($type) * * @return boolean True if values for the type need to be quoted. */ - public static function isNumericType($type) + public static function isNumericType($type): bool { return in_array($type, self::$NUMERIC_TYPES); } @@ -332,7 +332,7 @@ public static function isNumericType($type) * * @return boolean True if values for the type need to be quoted. */ - public static function isBooleanType($type) + public static function isBooleanType($type): bool { return in_array($type, self::$BOOLEAN_TYPES); } @@ -344,7 +344,7 @@ public static function isBooleanType($type) * * @return boolean */ - public static function isLobType($type) + public static function isLobType($type): bool { return in_array($type, self::$LOB_TYPES); } @@ -356,7 +356,7 @@ public static function isLobType($type) * * @return boolean Whether the PHP type is a primitive (string, int, boolean, float) */ - public static function isPhpPrimitiveType($phpType) + public static function isPhpPrimitiveType($phpType): bool { return in_array($phpType, array("boolean", "int", "double", "float", "string")); } @@ -368,7 +368,7 @@ public static function isPhpPrimitiveType($phpType) * * @return boolean Whether the PHP type is a primitive (string, int, boolean, float) */ - public static function isPhpPrimitiveNumericType($phpType) + public static function isPhpPrimitiveNumericType($phpType): bool { return in_array($phpType, array("boolean", "int", "double", "float")); } @@ -380,7 +380,7 @@ public static function isPhpPrimitiveNumericType($phpType) * * @return boolean */ - public static function isPhpObjectType($phpType) + public static function isPhpObjectType($phpType): bool { return (!self::isPhpPrimitiveType($phpType) && !in_array($phpType, array("resource", "array"))); } @@ -392,8 +392,8 @@ public static function isPhpObjectType($phpType) * * @return boolean */ - public static function isPhpArrayType($phpType) + public static function isPhpArrayType($phpType): bool { - return strtoupper($phpType) === self::PHP_ARRAY; + return strtoupper((string)$phpType) === self::PHP_ARRAY; } } diff --git a/generator/lib/model/Table.php b/generator/lib/model/Table.php index 578d0ac9c..5bf8699bd 100644 --- a/generator/lib/model/Table.php +++ b/generator/lib/model/Table.php @@ -576,7 +576,7 @@ protected function collectIndexedColumns($indexName, $columns, &$collectedIndexe * * @return string */ - public function getColumnList($columns, $delim = ',') + public function getColumnList($columns, $delim = ','): string { $list = array(); foreach ($columns as $col) { @@ -730,7 +730,7 @@ public function addColumn($data) } $this->columnList[] = $col; $this->columnsByName[$col->getName()] = $col; - $this->columnsByLowercaseName[strtolower($col->getName())] = $col; + $this->columnsByLowercaseName[strtolower((string)$col->getName())] = $col; $this->columnsByPhpName[$col->getPhpName()] = $col; $col->setPosition(count($this->columnList)); $this->needsTransactionInPostgres |= $col->requiresTransactionInPostgres(); @@ -1076,7 +1076,7 @@ public function removeIndex($name) * * @return bool */ - public function hasIndex($name) + public function hasIndex($name): bool { foreach ($this->indices as $idx) { if ($idx->getName() == $name) { @@ -1195,7 +1195,7 @@ public function getEarlyBehaviors() * * @return boolean True if the behavior exists */ - public function hasBehavior($name) + public function hasBehavior($name): bool { return array_key_exists($name, $this->behaviors); } @@ -1218,7 +1218,7 @@ public function getBehavior($name) * @return boolean true in the table has at least one behavior * with an additional builder, false otherwise */ - public function hasAdditionalBuilders() + public function hasAdditionalBuilders(): bool { foreach ($this->getBehaviors() as $behavior) { if ($behavior->hasAdditionalBuilders()) { @@ -1267,7 +1267,7 @@ public function getDescription() /** * Whether the Table has a description */ - public function hasDescription() + public function hasDescription(): bool { return (bool) $this->description; } @@ -1326,7 +1326,7 @@ public function buildPhpName($name) * * @return string */ - public function getStudlyPhpName() + public function getStudlyPhpName(): string { $phpname = $this->getPhpName(); if (strlen($phpname) > 1) { @@ -1420,7 +1420,7 @@ public function setIdMethod($idMethod) * * @return boolean Value of skipSql. */ - public function isSkipSql() + public function isSkipSql(): bool { return ($this->skipSql || $this->isAlias() || $this->isForReferenceOnly()); } @@ -1482,7 +1482,7 @@ public function getAlias() * * @return boolean */ - public function isAlias() + public function isAlias(): bool { return ($this->alias !== null); } @@ -1558,7 +1558,7 @@ public function getColumns() /** * Utility method to get the number of columns in this table */ - public function getNumColumns() + public function getNumColumns(): int { return count($this->columnList); } @@ -1566,7 +1566,7 @@ public function getNumColumns() /** * Utility method to get the number of columns in this table */ - public function getNumLazyLoadColumns() + public function getNumLazyLoadColumns(): int { $count = 0; foreach ($this->columnList as $col) { @@ -1583,7 +1583,7 @@ public function getNumLazyLoadColumns() * * @return boolean */ - public function hasEnumColumns() + public function hasEnumColumns(): bool { foreach ($this->getColumns() as $col) { @@ -1944,7 +1944,7 @@ public function getPrimaryKey() * * @return boolean Whether this table has any primary key parts. */ - public function hasPrimaryKey() + public function hasPrimaryKey(): bool { return (count($this->getPrimaryKey()) > 0); } @@ -1954,7 +1954,7 @@ public function hasPrimaryKey() * * @return boolean Whether this table has more than one primary key parts. */ - public function hasCompositePrimaryKey() + public function hasCompositePrimaryKey(): bool { return (count($this->getPrimaryKey()) > 1); } @@ -1977,7 +1977,7 @@ public function getFirstPrimaryKeyColumn() * * @return boolean Whether this table has a non-"none" id method and has a primary key column that is auto-increment. */ - public function hasAutoIncrementPrimaryKey() + public function hasAutoIncrementPrimaryKey(): bool { if ($this->getIdMethod() != IDMethod::NO_ID_METHOD) { $pks = $this->getPrimaryKey(); @@ -2049,7 +2049,7 @@ public function setIsCrossRef($isCrossRef) * @return A CSV list. * @deprecated Use the Platform::getColumnListDDL() method. */ - private function printList($list) + private function printList($list): string { $result = ""; $comma = 0; @@ -2068,7 +2068,7 @@ private function printList($list) * * @return Boolean */ - public function hasForeignKeys() + public function hasForeignKeys(): bool { return (count($this->getForeignKeys()) !== 0); } @@ -2078,7 +2078,7 @@ public function hasForeignKeys() * * @return Boolean */ - public function hasCrossForeignKeys() + public function hasCrossForeignKeys(): bool { return (count($this->getCrossFks()) !== 0); } diff --git a/generator/lib/model/Unique.php b/generator/lib/model/Unique.php index 1ca201d24..9221dc5a3 100644 --- a/generator/lib/model/Unique.php +++ b/generator/lib/model/Unique.php @@ -28,7 +28,7 @@ class Unique extends Index /** * Returns true. */ - public function isUnique() + public function isUnique(): bool { return true; } diff --git a/generator/lib/model/VendorInfo.php b/generator/lib/model/VendorInfo.php index 9a5680b4b..01fa3595a 100644 --- a/generator/lib/model/VendorInfo.php +++ b/generator/lib/model/VendorInfo.php @@ -119,7 +119,7 @@ public function getParameter($name) * * @return bool */ - public function hasParameter($name) + public function hasParameter($name): bool { return isset($this->parameters[$name]); } @@ -149,7 +149,7 @@ public function getParameters() * * @return boolean */ - public function isEmpty() + public function isEmpty(): bool { return empty($this->parameters); } diff --git a/generator/lib/model/XMLElement.php b/generator/lib/model/XMLElement.php index 1d6825c37..c07e1a7c8 100644 --- a/generator/lib/model/XMLElement.php +++ b/generator/lib/model/XMLElement.php @@ -91,13 +91,13 @@ protected function booleanValue($val) if (is_numeric($val)) { return (bool) $val; } else { - return (in_array(strtolower($val), array('true', 't', 'y', 'yes'), true) ? true : false); + return (in_array(strtolower((string)$val), array('true', 't', 'y', 'yes'), true) ? true : false); } } protected function getDefaultValueForArray($stringValue) { - $stringValue = trim($stringValue); + $stringValue = trim((string)$stringValue); if (empty($stringValue)) { return null; diff --git a/generator/lib/model/diff/PropelColumnComparator.php b/generator/lib/model/diff/PropelColumnComparator.php index c3b796ef5..2dfe9b9b2 100644 --- a/generator/lib/model/diff/PropelColumnComparator.php +++ b/generator/lib/model/diff/PropelColumnComparator.php @@ -63,7 +63,7 @@ public static function compareColumns(Column $fromColumn, Column $toColumn) if ($fromDomain->getSize() != $toDomain->getSize()) { $changedProperties['size'] = array($fromDomain->getSize(), $toDomain->getSize()); } - if (strtoupper($fromDomain->getSqlType()) != strtoupper($toDomain->getSqlType())) { + if (strtoupper((string)$fromDomain->getSqlType()) != strtoupper((string)$toDomain->getSqlType())) { $changedProperties['sqlType'] = array($fromDomain->getSqlType(), $toDomain->getSqlType()); } if ($fromColumn->isNotNull() != $toColumn->isNotNull()) { diff --git a/generator/lib/model/diff/PropelDatabaseComparator.php b/generator/lib/model/diff/PropelDatabaseComparator.php index 9013f672e..7323c2e6a 100644 --- a/generator/lib/model/diff/PropelDatabaseComparator.php +++ b/generator/lib/model/diff/PropelDatabaseComparator.php @@ -105,7 +105,7 @@ public static function computeDiff(Database $fromDatabase, Database $toDatabase, * * @return integer The number of table differences */ - public function compareTables($caseInsensitive = false) + public function compareTables($caseInsensitive = false): int { $fromDatabaseTables = $this->fromDatabase->getTables(); $toDatabaseTables = $this->toDatabase->getTables(); diff --git a/generator/lib/model/diff/PropelDatabaseDiff.php b/generator/lib/model/diff/PropelDatabaseDiff.php index d102e8226..783f2131c 100644 --- a/generator/lib/model/diff/PropelDatabaseDiff.php +++ b/generator/lib/model/diff/PropelDatabaseDiff.php @@ -70,7 +70,7 @@ public function getAddedTables() * * @return integer */ - public function countAddedTables() + public function countAddedTables(): int { return count($this->addedTables); } @@ -133,7 +133,7 @@ public function getRemovedTables() * * @return integer */ - public function countRemovedTables() + public function countRemovedTables(): int { return count($this->removedTables); } @@ -176,7 +176,7 @@ public function addModifiedTable($tableName, PropelTableDiff $modifiedTable) * * @return integer */ - public function countModifiedTables() + public function countModifiedTables(): int { return count($this->modifiedTables); } @@ -227,7 +227,7 @@ public function getRenamedTables() * * @return integer */ - public function countRenamedTables() + public function countRenamedTables(): int { return count($this->renamedTables); } @@ -264,7 +264,7 @@ public function getReverseDiff() * * @return string */ - public function getDescription() + public function getDescription(): string { $changes = array(); if ($count = $this->countAddedTables()) { diff --git a/generator/lib/model/diff/PropelForeignKeyComparator.php b/generator/lib/model/diff/PropelForeignKeyComparator.php index 1816b3b1b..b993d8b31 100644 --- a/generator/lib/model/diff/PropelForeignKeyComparator.php +++ b/generator/lib/model/diff/PropelForeignKeyComparator.php @@ -29,7 +29,7 @@ class PropelForeignKeyComparator * * @return boolean false if the two fks are similar, true if they have differences */ - public static function computeDiff(ForeignKey $fromFk, ForeignKey $toFk, $caseInsensitive = false) + public static function computeDiff(ForeignKey $fromFk, ForeignKey $toFk, $caseInsensitive = false): bool { // Check for differences in local and remote table $test = $caseInsensitive ? @@ -39,7 +39,7 @@ public static function computeDiff(ForeignKey $fromFk, ForeignKey $toFk, $caseIn return true; } $test = $caseInsensitive ? - strtolower($fromFk->getForeignTableName()) != strtolower($toFk->getForeignTableName()) : + strtolower((string)$fromFk->getForeignTableName()) != strtolower((string)$toFk->getForeignTableName()) : $fromFk->getForeignTableName() != $toFk->getForeignTableName(); if ($test) { return true; diff --git a/generator/lib/model/diff/PropelIndexComparator.php b/generator/lib/model/diff/PropelIndexComparator.php index beda5ad1d..1f52429de 100644 --- a/generator/lib/model/diff/PropelIndexComparator.php +++ b/generator/lib/model/diff/PropelIndexComparator.php @@ -28,7 +28,7 @@ class PropelIndexComparator * * @return boolean false if the two indices are similar, true if they have differences */ - public static function computeDiff(Index $fromIndex, Index $toIndex, $caseInsensitive = false) + public static function computeDiff(Index $fromIndex, Index $toIndex, $caseInsensitive = false): bool { // Check for removed index columns in $toIndex $fromIndexColumns = $fromIndex->getColumns(); diff --git a/generator/lib/model/diff/PropelTableComparator.php b/generator/lib/model/diff/PropelTableComparator.php index d75a64869..1ef7c653e 100644 --- a/generator/lib/model/diff/PropelTableComparator.php +++ b/generator/lib/model/diff/PropelTableComparator.php @@ -109,7 +109,7 @@ public static function computeDiff(Table $fromTable, Table $toTable, $caseInsens * * @return integer The number of column differences */ - public function compareColumns($caseInsensitive = false) + public function compareColumns($caseInsensitive = false): int { $fromTableColumns = $this->getFromTable()->getColumns(); $toTableColumns = $this->getToTable()->getColumns(); @@ -171,7 +171,7 @@ public function compareColumns($caseInsensitive = false) * * @return integer The number of primary key differences */ - public function comparePrimaryKeys($caseInsensitive = false) + public function comparePrimaryKeys($caseInsensitive = false): int { $pkDifferences = 0; $fromTablePk = $this->getFromTable()->getPrimaryKey(); @@ -221,7 +221,7 @@ public function comparePrimaryKeys($caseInsensitive = false) * * @return integer The number of index differences */ - public function compareIndices($caseInsensitive = false) + public function compareIndices($caseInsensitive = false): int { $indexDifferences = 0; $fromTableIndices = array_merge($this->getFromTable()->getIndices(), $this->getFromTable()->getUnices()); @@ -270,7 +270,7 @@ public function compareIndices($caseInsensitive = false) * * @return integer The number of foreign key differences */ - public function compareForeignKeys($caseInsensitive = false) + public function compareForeignKeys($caseInsensitive = false): int { $fkDifferences = 0; $fromTableFks = $this->getFromTable()->getForeignKeys(); diff --git a/generator/lib/model/diff/PropelTableDiff.php b/generator/lib/model/diff/PropelTableDiff.php index 22a579c91..1032f1045 100644 --- a/generator/lib/model/diff/PropelTableDiff.php +++ b/generator/lib/model/diff/PropelTableDiff.php @@ -365,7 +365,7 @@ public function getRenamedPkColumns() * * @return boolean */ - public function hasModifiedPk() + public function hasModifiedPk(): bool { return $this->renamedPkColumns || $this->removedPkColumns || $this->addedPkColumns; } diff --git a/generator/lib/platform/MysqlPlatform.php b/generator/lib/platform/MysqlPlatform.php index be2bcb4d1..5f3e4f7f6 100644 --- a/generator/lib/platform/MysqlPlatform.php +++ b/generator/lib/platform/MysqlPlatform.php @@ -99,22 +99,22 @@ public function getDefaultTableEngine() return $this->defaultTableEngine; } - public function getAutoIncrement() + public function getAutoIncrement(): string { return "AUTO_INCREMENT"; } - public function getMaxColumnNameLength() + public function getMaxColumnNameLength(): int { return 64; } - public function supportsNativeDeleteTrigger() + public function supportsNativeDeleteTrigger(): bool { return strtolower($this->getDefaultTableEngine()) == 'innodb'; } - public function supportsForeignKeys(Table $table) + public function supportsForeignKeys(Table $table): bool { $vendorSpecific = $table->getVendorInfoForType('mysql'); if ($vendorSpecific->hasParameter('Type')) { @@ -128,7 +128,7 @@ public function supportsForeignKeys(Table $table) return strtolower($mysqlTableType) == 'innodb'; } - public function getAddTablesDDL(Database $database) + public function getAddTablesDDL(Database $database): string { $ret = $this->getBeginDDL(); foreach ($database->getTablesForSql() as $table) { @@ -141,7 +141,7 @@ public function getAddTablesDDL(Database $database) return $ret; } - public function getBeginDDL() + public function getBeginDDL(): string { return " # This is a fix for InnoDB in MySQL >= 4.1.x @@ -150,7 +150,7 @@ public function getBeginDDL() "; } - public function getEndDDL() + public function getEndDDL(): string { return " # This restores the fkey checks, after having unset them earlier @@ -185,7 +185,7 @@ public function getPrimaryKeyDDL(Table $table) } } - public function getAddTableDDL(Table $table) + public function getAddTableDDL(Table $table): string { $lines = array(); @@ -297,14 +297,14 @@ protected function getTableOptions(Table $table) return $tableOptions; } - public function getDropTableDDL(Table $table) + public function getDropTableDDL(Table $table): string { return " DROP TABLE IF EXISTS " . $this->quoteIdentifier($table->getName()) . "; "; } - public function getColumnDDL(Column $col) + public function getColumnDDL(Column $col): string { $domain = $col->getDomain(); $sqlType = $domain->getSqlType(); @@ -384,7 +384,7 @@ public function getColumnDDL(Column $col) * * @return string */ - protected function getIndexColumnListDDL(Index $index) + protected function getIndexColumnListDDL(Index $index): string { $list = array(); foreach ($index->getColumns() as $col) { @@ -401,7 +401,7 @@ protected function getIndexColumnListDDL(Index $index) * * @return string */ - public function getDropPrimaryKeyDDL(Table $table) + public function getDropPrimaryKeyDDL(Table $table): string { $pattern = " ALTER TABLE %s DROP PRIMARY KEY; @@ -419,7 +419,7 @@ public function getDropPrimaryKeyDDL(Table $table) * * @return string */ - public function getAddIndexDDL(Index $index) + public function getAddIndexDDL(Index $index): string { $pattern = " CREATE %sINDEX %s ON %s (%s); @@ -440,7 +440,7 @@ public function getAddIndexDDL(Index $index) * * @return string */ - public function getDropIndexDDL(Index $index) + public function getDropIndexDDL(Index $index): string { $pattern = " DROP INDEX %s ON %s; @@ -457,7 +457,7 @@ public function getDropIndexDDL(Index $index) * * @return string */ - public function getIndexDDL(Index $index) + public function getIndexDDL(Index $index): string { return sprintf('%sINDEX %s (%s)', $this->getIndexType($index), @@ -466,7 +466,7 @@ public function getIndexDDL(Index $index) ); } - protected function getIndexType(Index $index) + protected function getIndexType(Index $index): string { $type = ''; $vendorInfo = $index->getVendorInfoForType($this->getDatabaseType()); @@ -479,7 +479,7 @@ protected function getIndexType(Index $index) return $type; } - public function getUniqueDDL(Unique $unique) + public function getUniqueDDL(Unique $unique): string { return sprintf('UNIQUE INDEX %s (%s)', $this->quoteIdentifier($unique->getName()), @@ -525,7 +525,7 @@ public function getDropForeignKeyDDL(ForeignKey $fk) ); } - public function getCommentBlockDDL($comment) + public function getCommentBlockDDL($comment): string { $pattern = " -- --------------------------------------------------------------------- @@ -542,7 +542,7 @@ public function getCommentBlockDDL($comment) * * @return string */ - public function getModifyDatabaseDDL(PropelDatabaseDiff $databaseDiff) + public function getModifyDatabaseDDL(PropelDatabaseDiff $databaseDiff): string { $ret = $this->getBeginDDL(); @@ -572,7 +572,7 @@ public function getModifyDatabaseDDL(PropelDatabaseDiff $databaseDiff) * * @return string */ - public function getRenameTableDDL($fromTableName, $toTableName) + public function getRenameTableDDL($fromTableName, $toTableName): string { $pattern = " RENAME TABLE %s TO %s; @@ -589,7 +589,7 @@ public function getRenameTableDDL($fromTableName, $toTableName) * * @return string */ - public function getRemoveColumnDDL(Column $column) + public function getRemoveColumnDDL(Column $column): string { $pattern = " ALTER TABLE %s DROP %s; @@ -626,7 +626,7 @@ public function getModifyColumnDDL(PropelColumnDiff $columnDiff) * * @return string */ - public function getChangeColumnDDL($fromColumn, $toColumn) + public function getChangeColumnDDL($fromColumn, $toColumn): string { $pattern = " ALTER TABLE %s CHANGE %s %s; @@ -644,7 +644,7 @@ public function getChangeColumnDDL($fromColumn, $toColumn) * * @return string */ - public function getModifyColumnsDDL($columnDiffs) + public function getModifyColumnsDDL($columnDiffs): string { $ret = ''; foreach ($columnDiffs as $columnDiff) { @@ -654,7 +654,7 @@ public function getModifyColumnsDDL($columnDiffs) return $ret; } - public function getAddColumnDDLBits(Column $column) + public function getAddColumnDDLBits(Column $column): string { $pattern = "ADD %s %s"; @@ -684,7 +684,7 @@ public function getAddColumnDDLBits(Column $column) * * @return string */ - public function getAddColumnsDDL($columns) + public function getAddColumnsDDL($columns): string { $lines = array(); $tableName = null; @@ -712,12 +712,12 @@ public function getAddColumnsDDL($columns) /** * @see Platform::supportsSchemas() */ - public function supportsSchemas() + public function supportsSchemas(): bool { return true; } - public function hasSize($sqlType) + public function hasSize($sqlType): bool { return !("MEDIUMTEXT" == $sqlType || "LONGTEXT" == $sqlType || "BLOB" == $sqlType || "MEDIUMBLOB" == $sqlType || "LONGBLOB" == $sqlType); } @@ -753,7 +753,7 @@ public function quoteIdentifier($text) return $this->isIdentifierQuotingEnabled ? '`' . strtr($text, array('.' => '`.`')) . '`' : $text; } - public function getTimestampFormatter() + public function getTimestampFormatter(): string { return 'Y-m-d H:i:s'; } @@ -775,12 +775,12 @@ public function getColumnBindingPHP($column, $identifier, $columnValueAccessor, return parent::getColumnBindingPHP($column, $identifier, $columnValueAccessor, $tab); } - public function getDefaultFKOnDeleteBehavior() + public function getDefaultFKOnDeleteBehavior(): string { return ForeignKey::RESTRICT; } - public function getDefaultFKOnUpdateBehavior() + public function getDefaultFKOnUpdateBehavior(): string { return ForeignKey::RESTRICT; } diff --git a/generator/lib/platform/OraclePlatform.php b/generator/lib/platform/OraclePlatform.php index 320b5f644..3b46fb421 100644 --- a/generator/lib/platform/OraclePlatform.php +++ b/generator/lib/platform/OraclePlatform.php @@ -51,27 +51,27 @@ protected function initialize() $this->setSchemaDomainMapping(new Domain(PropelTypes::ENUM, "NUMBER", "3", "0")); } - public function getMaxColumnNameLength() + public function getMaxColumnNameLength(): int { return 30; } - public function getNativeIdMethod() + public function getNativeIdMethod(): string { return PropelPlatformInterface::SEQUENCE; } - public function getAutoIncrement() + public function getAutoIncrement(): string { return ""; } - public function supportsNativeDeleteTrigger() + public function supportsNativeDeleteTrigger(): bool { return true; } - public function getBeginDDL() + public function getBeginDDL(): string { return " ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'; @@ -79,7 +79,7 @@ public function getBeginDDL() "; } - public function getAddTablesDDL(Database $database) + public function getAddTablesDDL(Database $database): string { $ret = $this->getBeginDDL(); foreach ($database->getTablesForSql() as $table) { @@ -100,7 +100,7 @@ public function getAddTablesDDL(Database $database) return $ret; } - public function getAddTableDDL(Table $table) + public function getAddTableDDL(Table $table): string { $tableDescription = $table->hasDescription() ? $this->getCommentLineDDL($table->getDescription()) : ''; @@ -157,7 +157,7 @@ public function getAddSequencesDDL(Table $table) } } - public function getDropTableDDL(Table $table) + public function getDropTableDDL(Table $table): string { $ret = " DROP TABLE " . $this->quoteIdentifier($table->getName()) . " CASCADE CONSTRAINTS; @@ -171,7 +171,7 @@ public function getDropTableDDL(Table $table) return $ret; } - public function getPrimaryKeyName(Table $table) + public function getPrimaryKeyName(Table $table): string { $tableName = $table->getName(); // pk constraint name must be 30 chars at most @@ -193,7 +193,7 @@ public function getPrimaryKeyDDL(Table $table) } } - public function getUniqueDDL(Unique $unique) + public function getUniqueDDL(Unique $unique): string { return sprintf('CONSTRAINT %s UNIQUE (%s)', $this->quoteIdentifier($unique->getName()), @@ -227,7 +227,7 @@ public function getForeignKeyDDL(ForeignKey $fk) * * @return boolean */ - public function hasStreamBlobImpl() + public function hasStreamBlobImpl(): bool { return true; } @@ -237,7 +237,7 @@ public function quoteIdentifier($text) return $text; } - public function getTimestampFormatter() + public function getTimestampFormatter(): string { return 'Y-m-d H:i:s'; } @@ -248,7 +248,7 @@ public function getTimestampFormatter() * one fell swoop. * @see Platform::supportsSchemas() */ - public function supportsSchemas() + public function supportsSchemas(): bool { return false; } @@ -261,7 +261,7 @@ public function supportsSchemas() * * @return string oracle vendor sql part */ - public function generateBlockStorage($object, $isPrimaryKey = false) + public function generateBlockStorage($object, $isPrimaryKey = false): string { $vendorSpecific = $object->getVendorInfoForType('oracle'); if ($vendorSpecific->isEmpty()) { @@ -319,7 +319,7 @@ public function generateBlockStorage($object, $isPrimaryKey = false) * * @return string */ - public function getAddIndexDDL(Index $index) + public function getAddIndexDDL(Index $index): string { // don't create index form primary key if ($this->getPrimaryKeyName($index->getTable()) == $this->quoteIdentifier($index->getName())) { @@ -366,7 +366,7 @@ public function getColumnBindingPHP($column, $identifier, $columnValueAccessor, * Warning: duplicates logic from DBOracle::getId(). * Any code modification here must be ported there. */ - public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = " ") + public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = " "): ?string { if (!$sequenceName) { throw new EngineException('Oracle needs a sequence name to fetch primary keys'); @@ -384,12 +384,12 @@ public function getIdentifierPhp($columnValueMutator, $connectionVariableName = return preg_replace('/^/m', $tab, $script); } - public function getDefaultFKOnDeleteBehavior() + public function getDefaultFKOnDeleteBehavior(): string { return ForeignKey::NOACTION; } - public function getDefaultFKOnUpdateBehavior() + public function getDefaultFKOnUpdateBehavior(): string { return ForeignKey::NOACTION; } diff --git a/generator/lib/platform/PgsqlPlatform.php b/generator/lib/platform/PgsqlPlatform.php index 0e2dac41a..bd8ac3116 100644 --- a/generator/lib/platform/PgsqlPlatform.php +++ b/generator/lib/platform/PgsqlPlatform.php @@ -45,17 +45,17 @@ protected function initialize() $this->setSchemaDomainMapping(new Domain(PropelTypes::ENUM, "INT2")); } - public function getNativeIdMethod() + public function getNativeIdMethod(): string { return PropelPlatformInterface::SERIAL; } - public function getAutoIncrement() + public function getAutoIncrement(): string { return ''; } - public function getMaxColumnNameLength() + public function getMaxColumnNameLength(): int { return 32; } @@ -76,7 +76,7 @@ public function disconnectedEscapeText($text) } } - public function getBooleanString($b) + public function getBooleanString($b): string { // parent method does the checking to allow string // representations & returns integer @@ -85,7 +85,7 @@ public function getBooleanString($b) return ($b ? "'t'" : "'f'"); } - public function supportsNativeDeleteTrigger() + public function supportsNativeDeleteTrigger(): bool { return true; } @@ -148,7 +148,7 @@ protected function getDropSequenceDDL(Table $table) } } - public function getAddSchemasDDL(Database $database) + public function getAddSchemasDDL(Database $database): string { $ret = ''; $schemas = array(); @@ -197,7 +197,7 @@ public function getResetSchemaDDL(Table $table) } } - public function getAddTablesDDL(Database $database) + public function getAddTablesDDL(Database $database): string { $ret = $this->getBeginDDL(); $ret .= $this->getAddSchemasDDL($database); @@ -215,7 +215,7 @@ public function getAddTablesDDL(Database $database) return $ret; } - public function getAddTableDDL(Table $table) + public function getAddTableDDL(Table $table): string { $ret = ''; $ret .= $this->getUseSchemaDDL($table); @@ -264,7 +264,7 @@ public function getAddTableDDL(Table $table) return $ret; } - protected function getAddColumnsComments(Table $table) + protected function getAddColumnsComments(Table $table): string { $ret = ''; foreach ($table->getColumns() as $column) { @@ -288,7 +288,7 @@ protected function getAddColumnComment(Column $column) } } - public function getDropTableDDL(Table $table) + public function getDropTableDDL(Table $table): string { $ret = ''; $ret .= $this->getUseSchemaDDL($table); @@ -302,14 +302,14 @@ public function getDropTableDDL(Table $table) return $ret; } - public function getPrimaryKeyName(Table $table) + public function getPrimaryKeyName(Table $table): string { $tableName = $table->getName(); return $tableName . '_pkey'; } - public function getColumnDDL(Column $col) + public function getColumnDDL(Column $col): string { $domain = $col->getDomain(); @@ -337,7 +337,7 @@ public function getColumnDDL(Column $col) return implode(' ', $ddl); } - public function getUniqueDDL(Unique $unique) + public function getUniqueDDL(Unique $unique): string { return sprintf('CONSTRAINT %s UNIQUE (%s)', $this->quoteIdentifier($unique->getName()), @@ -348,22 +348,22 @@ public function getUniqueDDL(Unique $unique) /** * @see Platform::supportsSchemas() */ - public function supportsSchemas() + public function supportsSchemas(): bool { return true; } - public function hasSize($sqlType) + public function hasSize($sqlType): bool { return !("BYTEA" == $sqlType || "TEXT" == $sqlType || "DOUBLE PRECISION" == $sqlType); } - public function hasStreamBlobImpl() + public function hasStreamBlobImpl(): bool { return true; } - public function supportsVarcharWithoutSize() + public function supportsVarcharWithoutSize(): bool { return true; } @@ -375,7 +375,7 @@ public function supportsVarcharWithoutSize() * @return string * @see DefaultPlatform::getModifyColumnDDL */ - public function getModifyColumnDDL(PropelColumnDiff $columnDiff) + public function getModifyColumnDDL(PropelColumnDiff $columnDiff): string { $ret = ''; $changedProperties = $columnDiff->getChangedProperties(); @@ -432,7 +432,7 @@ public function getModifyColumnDDL(PropelColumnDiff $columnDiff) * @return string * @see DefaultPlatform::getModifyColumnsDDL */ - public function getModifyColumnsDDL($columnDiffs) + public function getModifyColumnsDDL($columnDiffs): string { $ret = ''; foreach ($columnDiffs as $columnDiff) { @@ -449,7 +449,7 @@ public function getModifyColumnsDDL($columnDiffs) * @return string * @see DefaultPlatform::getAddColumnsDLL */ - public function getAddColumnsDDL($columns) + public function getAddColumnsDDL($columns): string { $ret = ''; foreach ($columns as $column) { @@ -487,7 +487,7 @@ public function getDropIndexDDL(Index $index) * Warning: duplicates logic from DBPostgres::getId(). * Any code modification here must be ported there. */ - public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = " ") + public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = " "): ?string { if (!$sequenceName) { throw new EngineException('PostgreSQL needs a sequence name to fetch primary keys'); diff --git a/generator/lib/platform/SqlitePlatform.php b/generator/lib/platform/SqlitePlatform.php index e58708617..e1b931935 100644 --- a/generator/lib/platform/SqlitePlatform.php +++ b/generator/lib/platform/SqlitePlatform.php @@ -41,17 +41,17 @@ protected function initialize() /** * @link http://www.sqlite.org/autoinc.html */ - public function getAutoIncrement() + public function getAutoIncrement(): string { return "PRIMARY KEY"; } - public function getMaxColumnNameLength() + public function getMaxColumnNameLength(): int { return 1024; } - public function getAddTableDDL(Table $table) + public function getAddTableDDL(Table $table): string { $tableDescription = $table->hasDescription() ? $this->getCommentLineDDL($table->getDescription()) : ''; @@ -89,13 +89,13 @@ public function getAddTableDDL(Table $table) ); } - public function getDropPrimaryKeyDDL(Table $table) + public function getDropPrimaryKeyDDL(Table $table): string { // FIXME: not supported by SQLite return ''; } - public function getAddPrimaryKeyDDL(Table $table) + public function getAddPrimaryKeyDDL(Table $table): string { // FIXME: not supported by SQLite return ''; @@ -107,19 +107,19 @@ public function getAddForeignKeyDDL(ForeignKey $fk) return $this->getForeignKeyDDL($fk); } - public function getDropForeignKeyDDL(ForeignKey $fk) + public function getDropForeignKeyDDL(ForeignKey $fk): string { return ''; } - public function getDropTableDDL(Table $table) + public function getDropTableDDL(Table $table): string { return " DROP TABLE IF EXISTS " . $this->quoteIdentifier($table->getName()) . "; "; } - public function getForeignKeyDDL(ForeignKey $fk) + public function getForeignKeyDDL(ForeignKey $fk): string { $pattern = " -- SQLite does not support foreign keys; this is just for reference @@ -133,7 +133,7 @@ public function getForeignKeyDDL(ForeignKey $fk) ); } - public function hasSize($sqlType) + public function hasSize($sqlType): bool { return !("MEDIUMTEXT" == $sqlType || "LONGTEXT" == $sqlType || "BLOB" == $sqlType || "MEDIUMBLOB" == $sqlType || "LONGBLOB" == $sqlType); } @@ -162,7 +162,7 @@ public function quoteIdentifier($text) /** * @see Platform::supportsMigrations() */ - public function supportsMigrations() + public function supportsMigrations(): bool { return false; } diff --git a/generator/lib/platform/SqlsrvPlatform.php b/generator/lib/platform/SqlsrvPlatform.php index ec4ebd788..aff521fa3 100644 --- a/generator/lib/platform/SqlsrvPlatform.php +++ b/generator/lib/platform/SqlsrvPlatform.php @@ -21,7 +21,7 @@ class SqlsrvPlatform extends MssqlPlatform /** * @see Platform#getMaxColumnNameLength() */ - public function getMaxColumnNameLength() + public function getMaxColumnNameLength(): int { return 128; } diff --git a/generator/lib/reverse/mysql/MysqlSchemaParser.php b/generator/lib/reverse/mysql/MysqlSchemaParser.php index e95709079..0e3b429b1 100644 --- a/generator/lib/reverse/mysql/MysqlSchemaParser.php +++ b/generator/lib/reverse/mysql/MysqlSchemaParser.php @@ -82,7 +82,7 @@ protected function getTypeMapping() /** * */ - public function parse(Database $database, Task $task = null) + public function parse(Database $database, Task $task = null): int { $this->addVendorInfo = $this->getGeneratorConfig()->getBuildProperty('addVendorInfo'); diff --git a/generator/lib/reverse/oracle/OracleSchemaParser.php b/generator/lib/reverse/oracle/OracleSchemaParser.php index addccc832..52c0af1ef 100644 --- a/generator/lib/reverse/oracle/OracleSchemaParser.php +++ b/generator/lib/reverse/oracle/OracleSchemaParser.php @@ -73,7 +73,7 @@ protected function getTypeMapping() * * @return int */ - public function parse(Database $database, Task $task = null) + public function parse(Database $database, Task $task = null): int { $tables = array(); $stmt = $this->dbh->query("SELECT OBJECT_NAME FROM USER_OBJECTS WHERE OBJECT_TYPE = 'TABLE'"); diff --git a/generator/lib/reverse/pgsql/PgsqlSchemaParser.php b/generator/lib/reverse/pgsql/PgsqlSchemaParser.php index ff5519d37..987419acb 100644 --- a/generator/lib/reverse/pgsql/PgsqlSchemaParser.php +++ b/generator/lib/reverse/pgsql/PgsqlSchemaParser.php @@ -74,7 +74,7 @@ protected function getTypeMapping() /** * */ - public function parse(Database $database, Task $task = null) + public function parse(Database $database, Task $task = null): int { $stmt = $this->dbh->query("SELECT version() as ver"); $nativeVersion = $stmt->fetchColumn(); diff --git a/generator/lib/reverse/sqlite/SqliteSchemaParser.php b/generator/lib/reverse/sqlite/SqliteSchemaParser.php index a05f8151d..163fde52c 100644 --- a/generator/lib/reverse/sqlite/SqliteSchemaParser.php +++ b/generator/lib/reverse/sqlite/SqliteSchemaParser.php @@ -72,7 +72,7 @@ protected function getTypeMapping() /** * */ - public function parse(Database $database, Task $task = null) + public function parse(Database $database, Task $task = null): int { $stmt = $this->dbh->query("SELECT name FROM sqlite_master WHERE type='table' UNION ALL SELECT name FROM sqlite_temp_master WHERE type='table' ORDER BY name;"); diff --git a/generator/lib/task/PropelOMTask.php b/generator/lib/task/PropelOMTask.php index 67bcefda0..e02829186 100644 --- a/generator/lib/task/PropelOMTask.php +++ b/generator/lib/task/PropelOMTask.php @@ -74,7 +74,7 @@ protected function ensureDirExists($path) * @todo -cPropelOMTask Consider refactoring build() method into AbstractPropelDataModelTask (would need to be more generic). * @return int */ - protected function build(OMBuilder $builder, $overwrite = true) + protected function build(OMBuilder $builder, $overwrite = true): int { $path = $builder->getClassFilePath(); $this->ensureDirExists(dirname($path)); diff --git a/generator/lib/task/PropelSchemaReverseTask.php b/generator/lib/task/PropelSchemaReverseTask.php index 7bad58875..948ba933b 100644 --- a/generator/lib/task/PropelSchemaReverseTask.php +++ b/generator/lib/task/PropelSchemaReverseTask.php @@ -317,7 +317,7 @@ public function setAddValidators($v) * * @return boolean */ - protected function isValidatorRequired($type) + protected function isValidatorRequired($type): bool { return (($this->validatorBits & $type) === $type); } diff --git a/generator/lib/util/PropelDotGenerator.php b/generator/lib/util/PropelDotGenerator.php index 9b133e099..8921cff7c 100644 --- a/generator/lib/util/PropelDotGenerator.php +++ b/generator/lib/util/PropelDotGenerator.php @@ -25,7 +25,7 @@ class PropelDotGenerator * * @return string The DOT syntax created. */ - public static function create(Database $database) + public static function create(Database $database): string { $dotSyntax = ''; diff --git a/generator/lib/util/PropelMigrationManager.php b/generator/lib/util/PropelMigrationManager.php index 96674c6d7..6d5d331e4 100644 --- a/generator/lib/util/PropelMigrationManager.php +++ b/generator/lib/util/PropelMigrationManager.php @@ -235,7 +235,7 @@ public function getValidMigrationTimestamps() return $migrationTimestamps; } - public function hasPendingMigrations() + public function hasPendingMigrations(): bool { return array() !== $this->getValidMigrationTimestamps(); } @@ -267,7 +267,7 @@ public function getFirstDownMigrationTimestamp() return $this->getOldestDatabaseVersion(); } - public static function getMigrationClassName($timestamp) + public static function getMigrationClassName($timestamp): string { return sprintf('PropelMigration_%d', $timestamp); } @@ -283,7 +283,7 @@ public function getMigrationObject($timestamp) return new $className(); } - public function getMigrationClassBody($migrationsUp, $migrationsDown, $timestamp) + public function getMigrationClassBody($migrationsUp, $migrationsDown, $timestamp): string { $timeInWords = date('Y-m-d H:i:s', $timestamp); $migrationAuthor = ($author = $this->getUser()) ? 'by ' . $author : ''; @@ -349,7 +349,7 @@ public function getDownSQL() return $migrationClassBody; } - public static function getMigrationFileName($timestamp) + public static function getMigrationFileName($timestamp): string { return sprintf('%s.php', self::getMigrationClassName($timestamp)); } diff --git a/generator/lib/util/PropelPHPParser.php b/generator/lib/util/PropelPHPParser.php index 57c9a81ff..4e7180725 100644 --- a/generator/lib/util/PropelPHPParser.php +++ b/generator/lib/util/PropelPHPParser.php @@ -58,12 +58,12 @@ public function getCode() return $this->isAddPhp ? $this->removePhp($this->code) : $this->code; } - protected function addPhp($code) + protected function addPhp($code): string { return 'database; } - public function buildSQL(PDO $con) + public function buildSQL(PDO $con): int { $statements = PropelSQLParser::parseString($this->getSQL()); foreach ($statements as $statement) { @@ -150,7 +150,7 @@ public function buildClasses(array $classTargets = null) eval($this->getClasses($classTargets)); } - public function getClasses(array $classTargets = null) + public function getClasses(array $classTargets = null): string { $script = ''; foreach ($this->getDatabase()->getTables() as $table) { diff --git a/generator/lib/util/PropelSQLParser.php b/generator/lib/util/PropelSQLParser.php index 198526981..e5b3fe38b 100644 --- a/generator/lib/util/PropelSQLParser.php +++ b/generator/lib/util/PropelSQLParser.php @@ -84,7 +84,7 @@ public static function executeFile($file, $connection) * * @return integer the number of executed statements */ - protected static function executeStatements($statements, $connection) + protected static function executeStatements($statements, $connection): int { foreach ($statements as $statement) { $stmt = $connection->prepare($statement); @@ -199,7 +199,7 @@ public function explodeIntoStatements() * * @return string A SQL statement */ - public function getNextStatement() + public function getNextStatement(): string { $isAfterBackslash = false; $isInString = false; diff --git a/generator/lib/util/PropelSchemaValidator.php b/generator/lib/util/PropelSchemaValidator.php index 4d6a23188..87d616a00 100644 --- a/generator/lib/util/PropelSchemaValidator.php +++ b/generator/lib/util/PropelSchemaValidator.php @@ -36,7 +36,7 @@ public function __construct(AppData $appData) /** * @return boolean true if valid, false otherwise */ - public function validate() + public function validate(): bool { foreach ($this->appData->getDatabases() as $database) { $this->validateDatabaseTables($database); diff --git a/generator/lib/util/PropelSqlManager.php b/generator/lib/util/PropelSqlManager.php index c597c1086..05f8cac21 100644 --- a/generator/lib/util/PropelSqlManager.php +++ b/generator/lib/util/PropelSqlManager.php @@ -60,7 +60,7 @@ public function getConnections() return $this->connections; } - public function hasConnection($connection) + public function hasConnection($connection): bool { return isset($this->connections[$connection]); } @@ -153,7 +153,7 @@ public function getDatabases() /** * @return string */ - public function getSqlDbMapFilename() + public function getSqlDbMapFilename(): string { return $this->getWorkingDirectory() . DIRECTORY_SEPARATOR . 'sqldb.map'; } @@ -194,7 +194,7 @@ public function buildSql() * * @throws PDOException */ - public function insertSql($datasource = null) + public function insertSql($datasource = null): bool { $statementsToInsert = array(); foreach ($this->getProperties($this->getSqlDbMapFilename()) as $sqlFile => $database) { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e733fdf27..749eff698 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,19 @@ - + + + + ./runtime/lib/ @@ -11,4 +25,7 @@ ./test/testsuite/ + + + diff --git a/rector.php b/rector.php new file mode 100644 index 000000000..4599a6769 --- /dev/null +++ b/rector.php @@ -0,0 +1,37 @@ +withRules([ + ReturnTypeFromStrictNativeCallRector::class, + ReturnTypeFromStrictScalarReturnExprRector::class, + StringifyStrNeedlesRector::class, + NullToStrictStringFuncCallArgRector::class, +// ReturnTypeWillChangeRector::class, + ]) + ->withSkip([ + __DIR__ . '/vendor', + __DIR__ . '/test/fixtures/bookstore-packaged/build/', + __DIR__ . '/test/fixtures/bookstore/build/', + __DIR__ . '/test/fixtures/namespaced/build/', + __DIR__ . '/test/fixtures/nestedset/build/', + __DIR__ . '/test/fixtures/schemas/build/', + __DIR__ . '/test/fixtures/treetest/build/', + __DIR__ . '/generator/pear/build/', + __DIR__ . '/runtime/pear/build/', + ]) + ->withPaths([__DIR__]); diff --git a/runtime/lib/Propel.php b/runtime/lib/Propel.php index 424714a7e..21542bae9 100644 --- a/runtime/lib/Propel.php +++ b/runtime/lib/Propel.php @@ -404,7 +404,7 @@ public static function setLogger($logger) * * @return bool True if Propel uses logging */ - public static function hasLogger() + public static function hasLogger(): bool { return (self::$logger !== null); } @@ -820,7 +820,7 @@ public static function close() * * @return boolean TRUE if the class was loaded, false otherwise. */ - public static function autoload($className) + public static function autoload($className): bool { if (isset(self::$autoloadMap[$className])) { require self::$baseDir . self::$autoloadMap[$className]; @@ -901,7 +901,7 @@ public static function setDatabaseMapClass($name) * @return boolean true if the method changed the instance pooling state, * false if it was already disabled */ - public static function disableInstancePooling() + public static function disableInstancePooling(): bool { if (!self::$instancePoolingEnabled) { return false; @@ -917,7 +917,7 @@ public static function disableInstancePooling() * @return boolean true if the method changed the instance pooling state, * false if it was already enabled */ - public static function enableInstancePooling() + public static function enableInstancePooling(): bool { if (self::$instancePoolingEnabled) { return false; diff --git a/runtime/lib/adapter/DBAdapter.php b/runtime/lib/adapter/DBAdapter.php index 7fa0d8a37..34417eea4 100644 --- a/runtime/lib/adapter/DBAdapter.php +++ b/runtime/lib/adapter/DBAdapter.php @@ -582,7 +582,7 @@ public function bindValues(PDOStatement $stmt, array $params, DatabaseMap $dbMap * * @return boolean */ - public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null): bool { if ($cMap->isTemporal()) { $value = $this->formatTemporalValue($value, $cMap); diff --git a/runtime/lib/adapter/DBMySQL.php b/runtime/lib/adapter/DBMySQL.php index 34ac19702..3829155cf 100644 --- a/runtime/lib/adapter/DBMySQL.php +++ b/runtime/lib/adapter/DBMySQL.php @@ -27,7 +27,7 @@ class DBMySQL extends DBAdapter * * @return string The upper case string. */ - public function toUpperCase($in) + public function toUpperCase($in): string { return "UPPER(" . $in . ")"; } @@ -39,7 +39,7 @@ public function toUpperCase($in) * * @return string The string in a case that can be ignored. */ - public function ignoreCase($in) + public function ignoreCase($in): string { return "UPPER(" . $in . ")"; } @@ -52,7 +52,7 @@ public function ignoreCase($in) * * @return string */ - public function concatString($s1, $s2) + public function concatString($s1, $s2): string { return "CONCAT($s1, $s2)"; } @@ -66,7 +66,7 @@ public function concatString($s1, $s2) * * @return string */ - public function subString($s, $pos, $len) + public function subString($s, $pos, $len): string { return "SUBSTRING($s, $pos, $len)"; } @@ -78,7 +78,7 @@ public function subString($s, $pos, $len) * * @return string */ - public function strLength($s) + public function strLength($s): string { return "CHAR_LENGTH($s)"; } @@ -116,7 +116,7 @@ public function unlockTable(PDO $con, $table) * * @return string */ - public function quoteIdentifier($text) + public function quoteIdentifier($text): string { return '`' . $text . '`'; } @@ -128,7 +128,7 @@ public function quoteIdentifier($text) * * @return string */ - public function quoteIdentifierTable($table) + public function quoteIdentifierTable($table): string { // e.g. 'database.table alias' should be escaped as '`database`.`table` `alias`' return '`' . strtr($table, array('.' => '`.`', ' ' => '` `')) . '`'; @@ -139,7 +139,7 @@ public function quoteIdentifierTable($table) * * @return boolean */ - public function useQuoteIdentifier() + public function useQuoteIdentifier(): bool { return true; } @@ -170,7 +170,7 @@ public function applyLimit(&$sql, $offset, $limit) * * @return string */ - public function random($seed = null) + public function random($seed = null): string { return 'rand(' . ((int) $seed) . ')'; } @@ -186,7 +186,7 @@ public function random($seed = null) * * @return boolean */ - public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null): bool { $pdoType = $cMap->getPdoType(); // FIXME - This is a temporary hack to get around apparent bugs w/ PDO+MYSQL diff --git a/runtime/lib/adapter/DBNone.php b/runtime/lib/adapter/DBNone.php index 841677d3e..36ed9c264 100644 --- a/runtime/lib/adapter/DBNone.php +++ b/runtime/lib/adapter/DBNone.php @@ -62,7 +62,7 @@ public function ignoreCase($in) * * @return string */ - public function concatString($s1, $s2) + public function concatString($s1, $s2): string { return ($s1 . $s2); } @@ -76,7 +76,7 @@ public function concatString($s1, $s2) * * @return string */ - public function subString($s, $pos, $len) + public function subString($s, $pos, $len): string { return substr($s, $pos, $len); } @@ -88,7 +88,7 @@ public function subString($s, $pos, $len) * * @return string */ - public function strLength($s) + public function strLength($s): int { return strlen($s); } diff --git a/runtime/lib/adapter/DBOracle.php b/runtime/lib/adapter/DBOracle.php index 77aef5698..7b9706d2a 100644 --- a/runtime/lib/adapter/DBOracle.php +++ b/runtime/lib/adapter/DBOracle.php @@ -52,7 +52,7 @@ public function initConnection(PDO $con, array $settings) * * @return string The upper case string. */ - public function toUpperCase($in) + public function toUpperCase($in): string { return "UPPER(" . $in . ")"; } @@ -64,7 +64,7 @@ public function toUpperCase($in) * * @return string The string in a case that can be ignored. */ - public function ignoreCase($in) + public function ignoreCase($in): string { return "UPPER(" . $in . ")"; } @@ -77,7 +77,7 @@ public function ignoreCase($in) * * @return string */ - public function concatString($s1, $s2) + public function concatString($s1, $s2): string { return "CONCAT($s1, $s2)"; } @@ -91,7 +91,7 @@ public function concatString($s1, $s2) * * @return string */ - public function subString($s, $pos, $len) + public function subString($s, $pos, $len): string { return "SUBSTR($s, $pos, $len)"; } @@ -103,7 +103,7 @@ public function subString($s, $pos, $len) * * @return string */ - public function strLength($s) + public function strLength($s): string { return "LENGTH($s)"; } @@ -140,7 +140,7 @@ public function applyLimit(&$sql, $offset, $limit, $criteria = null) /** * @return int */ - protected function getIdMethod() + protected function getIdMethod(): int { return DBAdapter::ID_METHOD_SEQUENCE; } @@ -169,7 +169,7 @@ public function getId(PDO $con, $name = null) * * @return string */ - public function random($seed = null) + public function random($seed = null): string { return 'dbms_random.value'; } @@ -227,7 +227,7 @@ public function turnSelectColumnsToAliases(Criteria $criteria) * * @return boolean */ - public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null): bool { if ($cMap->isTemporal()) { $value = $this->formatTemporalValue($value, $cMap); @@ -288,7 +288,7 @@ public function doExplainPlan(PropelPDO $con, $query) * * @return string */ - public function getExplainPlanQuery($query, $uniqueId) + public function getExplainPlanQuery($query, $uniqueId): string { return sprintf('EXPLAIN PLAN SET STATEMENT_ID = \'%s\' FOR %s', $uniqueId, $query); } @@ -300,7 +300,7 @@ public function getExplainPlanQuery($query, $uniqueId) * * @return string query unique id */ - public function getExplainPlanReadQuery($uniqueId) + public function getExplainPlanReadQuery($uniqueId): string { return sprintf('SELECT LEVEL, OPERATION, OPTIONS, COST, CARDINALITY, BYTES FROM PLAN_TABLE CONNECT BY PRIOR ID = PARENT_ID AND PRIOR STATEMENT_ID = STATEMENT_ID diff --git a/runtime/lib/adapter/DBPostgres.php b/runtime/lib/adapter/DBPostgres.php index bbf899ac1..bb729467a 100644 --- a/runtime/lib/adapter/DBPostgres.php +++ b/runtime/lib/adapter/DBPostgres.php @@ -28,7 +28,7 @@ class DBPostgres extends DBAdapter * * @return string The upper case string. */ - public function toUpperCase($in) + public function toUpperCase($in): string { return "UPPER(" . $in . ")"; } @@ -40,7 +40,7 @@ public function toUpperCase($in) * * @return string The string in a case that can be ignored. */ - public function ignoreCase($in) + public function ignoreCase($in): string { return "UPPER(" . $in . ")"; } @@ -53,7 +53,7 @@ public function ignoreCase($in) * * @return string */ - public function concatString($s1, $s2) + public function concatString($s1, $s2): string { return "($s1 || $s2)"; } @@ -67,7 +67,7 @@ public function concatString($s1, $s2) * * @return string */ - public function subString($s, $pos, $len) + public function subString($s, $pos, $len): string { return "substring($s from $pos" . ($len > -1 ? "for $len" : "") . ")"; } @@ -79,7 +79,7 @@ public function subString($s, $pos, $len) * * @return string */ - public function strLength($s) + public function strLength($s): string { return "char_length($s)"; } @@ -89,7 +89,7 @@ public function strLength($s) * * @return integer */ - protected function getIdMethod() + protected function getIdMethod(): int { return DBAdapter::ID_METHOD_SEQUENCE; } @@ -122,7 +122,7 @@ public function getId(PDO $con, $name = null) * * @return string */ - public function getTimestampFormatter() + public function getTimestampFormatter(): string { return "Y-m-d H:i:s O"; } @@ -132,7 +132,7 @@ public function getTimestampFormatter() * * @return string */ - public function getTimeFormatter() + public function getTimeFormatter(): string { return "H:i:s O"; } @@ -161,7 +161,7 @@ public function applyLimit(&$sql, $offset, $limit) * * @return string */ - public function random($seed = null) + public function random($seed = null): string { return 'random()'; } @@ -174,7 +174,7 @@ public function random($seed = null) * * @return string */ - public function getDeleteFromClause($criteria, $tableName) + public function getDeleteFromClause($criteria, $tableName): string { $sql = 'DELETE '; if ($queryComment = $criteria->getComment()) { @@ -202,7 +202,7 @@ public function getDeleteFromClause($criteria, $tableName) * * @return string */ - public function quoteIdentifierTable($table) + public function quoteIdentifierTable($table): string { // e.g. 'database.table alias' should be escaped as '"database"."table" "alias"' return '"' . strtr($table, array('.' => '"."', ' ' => '" "')) . '"'; @@ -245,7 +245,7 @@ public function doExplainPlan(PropelPDO $con, $query) * * @return string */ - public function getExplainPlanQuery($query) + public function getExplainPlanQuery($query): string { return 'EXPLAIN ' . $query; } diff --git a/runtime/lib/adapter/DBSQLSRV.php b/runtime/lib/adapter/DBSQLSRV.php index adb3c63ad..57124416f 100644 --- a/runtime/lib/adapter/DBSQLSRV.php +++ b/runtime/lib/adapter/DBSQLSRV.php @@ -92,7 +92,7 @@ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap * * @return boolean */ - public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null): bool { if ($cMap->isTemporal()) { $value = $this->formatTemporalValue($value, $cMap); diff --git a/runtime/lib/adapter/DBSQLite.php b/runtime/lib/adapter/DBSQLite.php index be625144c..2ac376190 100644 --- a/runtime/lib/adapter/DBSQLite.php +++ b/runtime/lib/adapter/DBSQLite.php @@ -38,7 +38,7 @@ public function setCharset(PDO $con, $charset) * * @return string The upper case string. */ - public function toUpperCase($in) + public function toUpperCase($in): string { return 'UPPER(' . $in . ')'; } @@ -50,7 +50,7 @@ public function toUpperCase($in) * * @return string The string in a case that can be ignored. */ - public function ignoreCase($in) + public function ignoreCase($in): string { return 'UPPER(' . $in . ')'; } @@ -63,7 +63,7 @@ public function ignoreCase($in) * * @return string */ - public function concatString($s1, $s2) + public function concatString($s1, $s2): string { return "($s1 || $s2)"; } @@ -77,7 +77,7 @@ public function concatString($s1, $s2) * * @return string */ - public function subString($s, $pos, $len) + public function subString($s, $pos, $len): string { return "substr($s, $pos, $len)"; } @@ -89,7 +89,7 @@ public function subString($s, $pos, $len) * * @return string */ - public function strLength($s) + public function strLength($s): string { return "length($s)"; } @@ -101,7 +101,7 @@ public function strLength($s) * * @return string */ - public function quoteIdentifier($text) + public function quoteIdentifier($text): string { return '[' . $text . ']'; } @@ -127,7 +127,7 @@ public function applyLimit(&$sql, $offset, $limit) * * @return string */ - public function random($seed = null) + public function random($seed = null): string { return 'random()'; } diff --git a/runtime/lib/collection/PropelArrayCollection.php b/runtime/lib/collection/PropelArrayCollection.php index c81e21d19..5418405ab 100644 --- a/runtime/lib/collection/PropelArrayCollection.php +++ b/runtime/lib/collection/PropelArrayCollection.php @@ -163,7 +163,7 @@ public function toArray($keyColumn = null, $usePrefix = false, $keyType = BasePe * * @return array */ - public function getArrayCopy($keyColumn = null, $usePrefix = false) + public function getArrayCopy($keyColumn = null, $usePrefix = false): array { if (null === $keyColumn && false === $usePrefix) { return parent::getArrayCopy(); diff --git a/runtime/lib/collection/PropelCollection.php b/runtime/lib/collection/PropelCollection.php index 2e5eccf00..44d2df8c3 100644 --- a/runtime/lib/collection/PropelCollection.php +++ b/runtime/lib/collection/PropelCollection.php @@ -49,7 +49,7 @@ class PropelCollection extends ArrayObject implements Serializable * * @return array */ - public function getData() + public function getData(): array { return $this->getArrayCopy(); } @@ -309,7 +309,7 @@ public function remove($key) * * @return array The previous collection */ - public function clear() + public function clear(): array { return $this->exchangeArray(array()); } @@ -365,7 +365,7 @@ public function diff(PropelCollection $collection) /** * @return string */ - public function serialize() + public function serialize(): string { $repr = array( 'data' => $this->getArrayCopy(), @@ -380,7 +380,7 @@ public function serialize() * * @return void */ - public function unserialize($data) + public function unserialize($data): void { $repr = unserialize($data); $this->exchangeArray($repr['data']); @@ -395,7 +395,7 @@ public function unserialize($data) * * @return ArrayIterator */ - public function getIterator() + public function getIterator(): Iterator { $this->iterator = new ArrayIterator($this); diff --git a/runtime/lib/collection/PropelObjectCollection.php b/runtime/lib/collection/PropelObjectCollection.php index 265da242f..111cd5852 100644 --- a/runtime/lib/collection/PropelObjectCollection.php +++ b/runtime/lib/collection/PropelObjectCollection.php @@ -138,7 +138,7 @@ public function fromArray($arr) * * @return array */ - public function getArrayCopy($keyColumn = null, $usePrefix = false) + public function getArrayCopy($keyColumn = null, $usePrefix = false): array { if (null === $keyColumn && false === $usePrefix) { return parent::getArrayCopy(); diff --git a/runtime/lib/collection/PropelOnDemandCollection.php b/runtime/lib/collection/PropelOnDemandCollection.php index b1bd8c073..13129b486 100644 --- a/runtime/lib/collection/PropelOnDemandCollection.php +++ b/runtime/lib/collection/PropelOnDemandCollection.php @@ -49,7 +49,7 @@ public function fromArray($arr) /** * @return PropelOnDemandIterator */ - public function getIterator() + public function getIterator(): Iterator { return $this->iterator; } @@ -63,7 +63,7 @@ public function getIterator() * * @return boolean */ - public function offsetExists($offset) + public function offsetExists($offset): bool { throw new PropelException('The On Demand Collection does not allow access by offset'); } @@ -75,7 +75,7 @@ public function offsetExists($offset) * * @return mixed */ - public function offsetGet($offset) + public function offsetGet($offset): mixed { throw new PropelException('The On Demand Collection does not allow access by offset'); } @@ -86,7 +86,7 @@ public function offsetGet($offset) * @param integer $offset * @param mixed $value */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { throw new PropelException('The On Demand Collection is read only'); } @@ -96,7 +96,7 @@ public function offsetSet($offset, $value) * * @param integer $offset */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { throw new PropelException('The On Demand Collection is read only'); } @@ -106,7 +106,7 @@ public function offsetUnset($offset) /** * @throws PropelException */ - public function serialize() + public function serialize(): string { throw new PropelException('The On Demand Collection cannot be serialized'); } @@ -118,7 +118,7 @@ public function serialize() * * @return void */ - public function unserialize($data) + public function unserialize($data): void { throw new PropelException('The On Demand Collection cannot be serialized'); } @@ -131,14 +131,14 @@ public function unserialize($data) * * @return integer Number of results */ - public function count() + public function count(): int { return $this->iterator->count(); } // ArrayObject methods - public function append($value) + public function append($value): void { throw new PropelException('The On Demand Collection is read only'); } @@ -153,47 +153,47 @@ public function asort(int $flags = SORT_REGULAR): bool throw new PropelException('The On Demand Collection is read only'); } - public function exchangeArray($input) + public function exchangeArray($input): array { throw new PropelException('The On Demand Collection is read only'); } - public function getArrayCopy() + public function getArrayCopy(): array { throw new PropelException('The On Demand Collection does not allow access by offset'); } - public function getFlags() + public function getFlags(): int { throw new PropelException('The On Demand Collection does not allow access by offset'); } - public function ksort(int $flags = SORT_REGULAR) + public function ksort(int $flags = SORT_REGULAR): bool { throw new PropelException('The On Demand Collection is read only'); } - public function natcasesort() + public function natcasesort(): bool { throw new PropelException('The On Demand Collection is read only'); } - public function natsort() + public function natsort(): bool { throw new PropelException('The On Demand Collection is read only'); } - public function setFlags($flags) + public function setFlags($flags): void { throw new PropelException('The On Demand Collection does not allow acces by offset'); } - public function uasort($cmp_function) + public function uasort($cmp_function): bool { throw new PropelException('The On Demand Collection is read only'); } - public function uksort($cmp_function) + public function uksort($cmp_function): bool { throw new PropelException('The On Demand Collection is read only'); } diff --git a/runtime/lib/collection/PropelOnDemandIterator.php b/runtime/lib/collection/PropelOnDemandIterator.php index ed20385f3..731189569 100644 --- a/runtime/lib/collection/PropelOnDemandIterator.php +++ b/runtime/lib/collection/PropelOnDemandIterator.php @@ -62,7 +62,7 @@ public function closeCursor() * * @return integer Number of results */ - public function count() + public function count(): int { return $this->stmt->rowCount(); } @@ -75,7 +75,7 @@ public function count() * * @return BaseObject */ - public function current() + public function current(): mixed { return $this->formatter->getAllObjectsFromRow($this->currentRow); } @@ -85,7 +85,7 @@ public function current() * * @return string */ - public function key() + public function key(): mixed { return $this->currentKey; } @@ -94,7 +94,7 @@ public function key() * Advances the cursor in the statement * Closes the cursor if the end of the statement is reached */ - public function next() + public function next(): void { $this->currentRow = $this->stmt->fetch(PDO::FETCH_NUM); $this->currentKey++; @@ -111,7 +111,7 @@ public function next() * Initializes the iterator by advancing to the first position * This method can only be called once (this is a NoRewindIterator) */ - public function rewind() + public function rewind(): void { // check that the hydration can begin if (null === $this->formatter) { @@ -131,7 +131,7 @@ public function rewind() /** * @return boolean */ - public function valid() + public function valid(): bool { return (boolean) $this->isValid; } diff --git a/runtime/lib/config/PropelConfiguration.php b/runtime/lib/config/PropelConfiguration.php index cd44624b4..d38bc450f 100644 --- a/runtime/lib/config/PropelConfiguration.php +++ b/runtime/lib/config/PropelConfiguration.php @@ -47,7 +47,7 @@ public function __construct(array $parameters = array()) * * @return boolean */ - public function offsetExists($offset) + public function offsetExists($offset): bool { return array_key_exists($offset, $this->parameters); } @@ -58,7 +58,7 @@ public function offsetExists($offset) * @param integer $offset * @param mixed $value */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { $this->parameters[$offset] = $value; $this->isFlattened = false; @@ -71,7 +71,7 @@ public function offsetSet($offset, $value) * * @return array */ - public function offsetGet($offset) + public function offsetGet($offset): mixed { return $this->parameters[$offset]; } @@ -81,7 +81,7 @@ public function offsetGet($offset) * * @param integer $offset */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->parameters[$offset]); $this->isFlattened = false; diff --git a/runtime/lib/config/PropelConfigurationIterator.php b/runtime/lib/config/PropelConfigurationIterator.php index 1c74e4fdd..232d2fc06 100644 --- a/runtime/lib/config/PropelConfigurationIterator.php +++ b/runtime/lib/config/PropelConfigurationIterator.php @@ -12,7 +12,7 @@ * PropelConfigurationIterator is used internally by PropelConfiguration to * build a flat array from nesting configuration arrays. * - * @author Veikko Mäkinen + * @author Veikko M�kinen * @version $Revision$ * @package propel.runtime.config */ @@ -47,7 +47,7 @@ class PropelConfigurationIterator extends RecursiveIteratorIterator * * @return string */ - public function getNamespace() + public function getNamespace(): string { return implode('.', $this->namespaceStack); } @@ -72,7 +72,7 @@ public function getNodeType() * @see http://www.php.net/RecursiveIteratorIterator * @return mixed */ - public function current() + public function current(): mixed { $current = parent::current(); if (is_array($current)) { @@ -90,7 +90,7 @@ public function current() * * @see http://www.php.net/RecursiveIteratorIterator */ - public function endChildren() + public function endChildren(): void { if ($this->namespaceStack) { array_pop($this->namespaceStack); diff --git a/runtime/lib/connection/DebugPDOStatement.php b/runtime/lib/connection/DebugPDOStatement.php index 390ddea77..ff44f53d7 100644 --- a/runtime/lib/connection/DebugPDOStatement.php +++ b/runtime/lib/connection/DebugPDOStatement.php @@ -86,7 +86,7 @@ public function getExecutedQueryString(array $values = array()) $boundValue = '[BLOB]'; } - $sql = str_replace($pos, $boundValue, $sql); + $sql = str_replace($pos, (string)$boundValue, $sql); } } @@ -101,7 +101,7 @@ public function getExecutedQueryString(array $values = array()) * * @return boolean */ - public function execute($input_parameters = null) + public function execute($input_parameters = null): bool { $debug = $this->pdo->getDebugSnapshot(); $return = parent::execute($input_parameters); @@ -124,7 +124,7 @@ public function execute($input_parameters = null) * * @return boolean */ - public function bindValue($pos, $value, $type = PDO::PARAM_STR) + public function bindValue($pos, $value, $type = PDO::PARAM_STR): bool { $debug = $this->pdo->getDebugSnapshot(); $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)'; @@ -153,7 +153,7 @@ public function bindValue($pos, $value, $type = PDO::PARAM_STR) * * @return boolean */ - 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): bool { $originalValue = $value; $debug = $this->pdo->getDebugSnapshot(); diff --git a/runtime/lib/connection/PropelPDO.php b/runtime/lib/connection/PropelPDO.php index 5236e0107..4f5fd131a 100644 --- a/runtime/lib/connection/PropelPDO.php +++ b/runtime/lib/connection/PropelPDO.php @@ -229,7 +229,7 @@ public function isCommitable() * * @return boolean */ - public function beginTransaction() + public function beginTransaction(): bool { $return = true; if (!$this->nestedTransactionCount) { @@ -252,7 +252,7 @@ public function beginTransaction() * * @throws PropelException */ - public function commit() + public function commit(): bool { $return = true; $opcount = $this->nestedTransactionCount; @@ -281,7 +281,7 @@ public function commit() * * @return boolean Whether operation was successful. */ - public function rollBack() + public function rollBack(): bool { $return = true; $opcount = $this->nestedTransactionCount; @@ -337,19 +337,19 @@ public function forceRollBack() * @param integer $attribute The attribute to set (e.g. PropelPDO::PROPEL_ATTR_CACHE_PREPARES). * @param mixed $value The attribute value. * - * @return void + * @return boolean */ - public function setAttribute($attribute, $value) + public function setAttribute($attribute, $value): bool { switch ($attribute) { case self::PROPEL_ATTR_CACHE_PREPARES: $this->cachePreparedStatements = $value; - break; + return true; case self::PROPEL_ATTR_CONNECTION_NAME: $this->connectionName = $value; - break; + return true; default: - parent::setAttribute($attribute, $value); + return parent::setAttribute($attribute, $value); } } @@ -362,7 +362,7 @@ public function setAttribute($attribute, $value) * * @return mixed */ - public function getAttribute($attribute) + public function getAttribute($attribute): mixed { switch ($attribute) { case self::PROPEL_ATTR_CACHE_PREPARES: @@ -389,7 +389,7 @@ public function getAttribute($attribute) * * @return PDOStatement */ - public function prepare($sql, $driver_options = array()) + public function prepare($sql, $driver_options = array()): PDOStatement|false { if ($this->useDebug) { $debug = $this->getDebugSnapshot(); @@ -421,7 +421,7 @@ public function prepare($sql, $driver_options = array()) * * @return integer */ - public function exec($sql) + public function exec($sql): int|false { if ($this->useDebug) { $debug = $this->getDebugSnapshot(); @@ -448,7 +448,7 @@ public function exec($sql) * * @return PDOStatement */ - public function query(string $statement, ?int $fetchMode = null, ...$fetchModeArgs) + public function query(string $statement, ?int $fetchMode = null, ...$fetchModeArgs): PDOStatement|false { $debug = null; @@ -665,7 +665,7 @@ public function getDebugSnapshot() 'microtime' => microtime(true), 'memory_get_usage' => memory_get_usage($this->getLoggingConfig('realmemoryusage', false)), 'memory_get_peak_usage' => memory_get_peak_usage($this->getLoggingConfig('realmemoryusage', false)), - ); + ); } else { throw new PropelException('Should not get debug snapshot when not debugging'); } diff --git a/runtime/lib/formatter/ModelWith.php b/runtime/lib/formatter/ModelWith.php index 3c5454c48..c6daff9fe 100644 --- a/runtime/lib/formatter/ModelWith.php +++ b/runtime/lib/formatter/ModelWith.php @@ -180,7 +180,7 @@ public function getRightPhpName() // Utility methods - public function isPrimary() + public function isPrimary(): bool { return null === $this->leftPhpName; } diff --git a/runtime/lib/formatter/PropelArrayFormatter.php b/runtime/lib/formatter/PropelArrayFormatter.php index 87ba24cf9..69a795090 100644 --- a/runtime/lib/formatter/PropelArrayFormatter.php +++ b/runtime/lib/formatter/PropelArrayFormatter.php @@ -86,7 +86,7 @@ public function formatRecord($record = null) return $record ? $record->toArray() : array(); } - public function isObjectFormatter() + public function isObjectFormatter(): bool { return false; } diff --git a/runtime/lib/formatter/PropelSimpleArrayFormatter.php b/runtime/lib/formatter/PropelSimpleArrayFormatter.php index b2e750e8d..01b6c3e16 100644 --- a/runtime/lib/formatter/PropelSimpleArrayFormatter.php +++ b/runtime/lib/formatter/PropelSimpleArrayFormatter.php @@ -54,7 +54,7 @@ public function formatOne(PDOStatement $stmt) return $result; } - public function isObjectFormatter() + public function isObjectFormatter(): bool { return false; } diff --git a/runtime/lib/formatter/PropelStatementFormatter.php b/runtime/lib/formatter/PropelStatementFormatter.php index 9566b4518..48ee55aff 100644 --- a/runtime/lib/formatter/PropelStatementFormatter.php +++ b/runtime/lib/formatter/PropelStatementFormatter.php @@ -37,7 +37,7 @@ public function formatRecord($record = null) throw new PropelException('The Statement formatter cannot transform a record into a statement'); } - public function isObjectFormatter() + public function isObjectFormatter(): bool { return false; } diff --git a/runtime/lib/map/ColumnMap.php b/runtime/lib/map/ColumnMap.php index c6f5affcf..50152bde5 100644 --- a/runtime/lib/map/ColumnMap.php +++ b/runtime/lib/map/ColumnMap.php @@ -112,7 +112,7 @@ public function getTableName() * * @return string A String with the full column name. */ - public function getFullyQualifiedName() + public function getFullyQualifiedName(): string { return $this->getTableName() . "." . $this->columnName; } @@ -176,7 +176,7 @@ public function getPdoType() * * @return boolean */ - public function isLob() + public function isLob(): bool { return ($this->type == PropelColumnTypes::BLOB || $this->type == PropelColumnTypes::VARBINARY || $this->type == PropelColumnTypes::LONGVARBINARY); } @@ -187,7 +187,7 @@ public function isLob() * @return boolean * @since 1.3 */ - public function isTemporal() + public function isTemporal(): bool { return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME || $this->type == PropelColumnTypes::BU_DATE || $this->type == PropelColumnTypes::BU_TIMESTAMP); } @@ -201,7 +201,7 @@ public function isTemporal() * @return boolean * @deprecated Propel supports non-epoch dates */ - public function isEpochTemporal() + public function isEpochTemporal(): bool { return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME); } @@ -211,7 +211,7 @@ public function isEpochTemporal() * * @return boolean */ - public function isNumeric() + public function isNumeric(): bool { return ($this->type == PropelColumnTypes::NUMERIC || $this->type == PropelColumnTypes::DECIMAL || $this->type == PropelColumnTypes::TINYINT || $this->type == PropelColumnTypes::SMALLINT || $this->type == PropelColumnTypes::INTEGER || $this->type == PropelColumnTypes::BIGINT || $this->type == PropelColumnTypes::REAL || $this->type == PropelColumnTypes::FLOAT || $this->type == PropelColumnTypes::DOUBLE); } @@ -221,7 +221,7 @@ public function isNumeric() * * @return boolean */ - public function isInteger() + public function isInteger(): bool { return $this->getPdoType() === PDO::PARAM_INT; } @@ -231,7 +231,7 @@ public function isInteger() * * @return boolean */ - public function isText() + public function isText(): bool { return ($this->type == PropelColumnTypes::VARCHAR || $this->type == PropelColumnTypes::LONGVARCHAR || $this->type == PropelColumnTypes::CHAR); } @@ -297,7 +297,7 @@ public function setNotNull($nn) * * @return boolean True if column may not be null. */ - public function isNotNull() + public function isNotNull(): bool { return ($this->notNull || $this->isPrimaryKey()); } @@ -348,7 +348,7 @@ public function setForeignKey($tableName, $columnName) * * @return boolean True if column is a foreign key. */ - public function isForeignKey() + public function isForeignKey(): bool { if ($this->relatedTableName) { return true; @@ -381,7 +381,7 @@ public function getRelation() * * @return string A String with the full name for the related column. */ - public function getRelatedName() + public function getRelatedName(): string { return $this->relatedTableName . "." . $this->relatedColumnName; } @@ -437,7 +437,7 @@ public function addValidator($validator) $this->validators[] = $validator; } - public function hasValidators() + public function hasValidators(): bool { return count($this->validators) > 0; } @@ -467,7 +467,7 @@ public function getValueSet() return $this->valueSet; } - public function isInValueSet($value) + public function isInValueSet($value): bool { return in_array($value, $this->valueSet); } diff --git a/runtime/lib/map/DatabaseMap.php b/runtime/lib/map/DatabaseMap.php index 6c2880b8f..bf9d788ba 100644 --- a/runtime/lib/map/DatabaseMap.php +++ b/runtime/lib/map/DatabaseMap.php @@ -107,7 +107,7 @@ public function addTableFromMapClass($tableMapClass) * * @return boolean True if the database contains the table. */ - public function hasTable($name) + public function hasTable($name): bool { return array_key_exists($name, $this->tables); } diff --git a/runtime/lib/map/RelationMap.php b/runtime/lib/map/RelationMap.php index 3109ecbd2..cc73f4783 100644 --- a/runtime/lib/map/RelationMap.php +++ b/runtime/lib/map/RelationMap.php @@ -209,7 +209,7 @@ public function getColumnMappings($direction = RelationMap::LOCAL_TO_FOREIGN) * * @return boolean */ - public function isComposite() + public function isComposite(): bool { return $this->countColumnMappings() > 1; } @@ -219,7 +219,7 @@ public function isComposite() * * @return int */ - public function countColumnMappings() + public function countColumnMappings(): int { return count($this->localColumns); } diff --git a/runtime/lib/map/TableMap.php b/runtime/lib/map/TableMap.php index fea362c69..cdb837cdf 100644 --- a/runtime/lib/map/TableMap.php +++ b/runtime/lib/map/TableMap.php @@ -790,7 +790,7 @@ protected function hasPrefix($data) return false; } - return (strpos($data, $this->prefix) === 0); + return (strpos($data, (string) $this->prefix) === 0); } /** @@ -819,7 +819,7 @@ protected function removePrefix($data) * * @return string A String with data processed. */ - final public function removeUnderScores($data) + final public function removeUnderScores($data): string { $out = ''; $tmp = $this->removePrefix($data); @@ -841,7 +841,7 @@ final public function removeUnderScores($data) * * @return string A String with data processed. */ - private function firstLetterCaps($data) + private function firstLetterCaps($data): string { return (ucfirst(strtolower($data))); } diff --git a/runtime/lib/om/NestedSetRecursiveIterator.php b/runtime/lib/om/NestedSetRecursiveIterator.php index f1c501f74..7f88ad7bc 100644 --- a/runtime/lib/om/NestedSetRecursiveIterator.php +++ b/runtime/lib/om/NestedSetRecursiveIterator.php @@ -27,22 +27,22 @@ public function __construct($node) $this->curNode = $node; } - public function rewind() + public function rewind(): void { $this->curNode = $this->topNode; } - public function valid() + public function valid(): bool { return ($this->curNode !== null); } - public function current() + public function current(): mixed { return $this->curNode; } - public function key() + public function key(): mixed { $method = method_exists($this->curNode, 'getPath') ? 'getPath' : 'getAncestors'; $key = array(); @@ -53,6 +53,7 @@ public function key() return implode('.', $key); } + #[\ReturnTypeWillChange] public function next() { $nextNode = null; @@ -75,12 +76,12 @@ public function next() return $this->curNode; } - public function hasChildren() + public function hasChildren(): bool { return $this->curNode->hasChildren(); } - public function getChildren() + public function getChildren(): ?RecursiveIterator { $method = method_exists($this->curNode, 'retrieveFirstChild') ? 'retrieveFirstChild' : 'getFirstChild'; diff --git a/runtime/lib/parser/PropelCSVParser.php b/runtime/lib/parser/PropelCSVParser.php index 005457847..8e7ec2cfd 100644 --- a/runtime/lib/parser/PropelCSVParser.php +++ b/runtime/lib/parser/PropelCSVParser.php @@ -40,7 +40,7 @@ class PropelCSVParser extends PropelParser * * @return string Converted data, as a CSV string */ - public function fromArray($array, $isList = false, $includeHeading = true) + public function fromArray($array, $isList = false, $includeHeading = true): string { $rows = array(); if ($isList) { @@ -109,7 +109,7 @@ protected function formatRow($row) * * @return string Escaped input value */ - protected function escape($input) + protected function escape($input): string { return str_replace( $this->quotechar, @@ -125,7 +125,7 @@ protected function escape($input) * * @return string Quoted input value */ - protected function quote($input) + protected function quote($input): string { return $this->quotechar . $input . $this->quotechar; } @@ -137,13 +137,13 @@ protected function quote($input) * * @return boolean True if contains any special characters */ - protected function containsSpecialChars($input) + protected function containsSpecialChars($input): bool { $special_chars = str_split($this->lineTerminator, 1); $special_chars[] = $this->quotechar; $special_chars[] = $this->delimiter; foreach ($special_chars as $char) { - if (strpos($input, $char) !== false) { + if (strpos($input, (string) $char) !== false) { return true; } } @@ -158,7 +158,7 @@ protected function containsSpecialChars($input) * * @return string */ - protected function serialize($input) + protected function serialize($input): string { return serialize($input); } @@ -273,7 +273,7 @@ protected function unescape($input) ); } - protected function unquote($input) + protected function unquote($input): string { return trim($input, $this->quotechar); } diff --git a/runtime/lib/parser/PropelXMLParser.php b/runtime/lib/parser/PropelXMLParser.php index f2f3bd632..4a2e1a9fd 100644 --- a/runtime/lib/parser/PropelXMLParser.php +++ b/runtime/lib/parser/PropelXMLParser.php @@ -116,7 +116,7 @@ protected function arrayToDOM($array, $rootElement, $charset = null, $removeNumb $child = $element->ownerDocument->createCDATASection($value); $element->appendChild($child); } else { - $child = $element->ownerDocument->createTextNode($value); + $child = $element->ownerDocument->createTextNode((string)$value); $element->appendChild($child); } $rootElement->appendChild($element); @@ -198,7 +198,7 @@ protected function convertDOMElementToArray(DOMNode $data) * * @return boolean */ - protected function hasOnlyTextNodes(DomNode $node) + protected function hasOnlyTextNodes(DomNode $node): bool { foreach ($node->childNodes as $childNode) { if ($childNode->nodeType != XML_CDATA_SECTION_NODE && $childNode->nodeType != XML_TEXT_NODE) { diff --git a/runtime/lib/parser/yaml/sfYamlDumper.php b/runtime/lib/parser/yaml/sfYamlDumper.php index 7f0a450a4..5440b8896 100644 --- a/runtime/lib/parser/yaml/sfYamlDumper.php +++ b/runtime/lib/parser/yaml/sfYamlDumper.php @@ -29,7 +29,7 @@ class sfYamlDumper * * @return string The YAML representation of the PHP value */ - public function dump($input, $inline = 0, $indent = 0) + public function dump($input, $inline = 0, $indent = 0): string { $output = ''; $prefix = $indent ? str_repeat(' ', $indent) : ''; diff --git a/runtime/lib/parser/yaml/sfYamlInline.php b/runtime/lib/parser/yaml/sfYamlInline.php index 331802a00..338db2092 100644 --- a/runtime/lib/parser/yaml/sfYamlInline.php +++ b/runtime/lib/parser/yaml/sfYamlInline.php @@ -88,7 +88,7 @@ public static function dump($value) return 'true'; case false === $value: return 'false'; - case ctype_digit($value): + case ctype_digit((string)$value): return is_string($value) ? "'$value'" : (int) $value; case is_numeric($value): return is_infinite($value) ? str_ireplace('INF', '.Inf', strval($value)) : (is_string($value) ? "'$value'" : $value); @@ -118,7 +118,7 @@ public static function dump($value) * * @return string The YAML string representing the PHP array */ - protected static function dumpArray($value) + protected static function dumpArray($value): string { // array $keys = array_keys($value); @@ -381,7 +381,7 @@ protected static function evaluateScalar($scalar) } } - protected static function getTimestampRegex() + protected static function getTimestampRegex(): string { return <<currentLine) - strlen(ltrim($this->currentLine, ' ')); } @@ -237,7 +237,7 @@ protected function getCurrentLineIndentation() * * @return string A YAML string */ - protected function getNextEmbedBlock() + protected function getNextEmbedBlock(): string { $this->moveToNextLine(); @@ -280,7 +280,7 @@ protected function getNextEmbedBlock() /** * Moves the parser to the next line. */ - protected function moveToNextLine() + protected function moveToNextLine(): bool { if ($this->currentLineNb >= count($this->lines) - 1) { return false; @@ -410,7 +410,7 @@ protected function parseFoldedScalar($separator, $indicator = '', $indentation = * * @return Boolean Returns true if the next line is indented, false otherwise */ - protected function isNextLineIndented() + protected function isNextLineIndented(): bool { $currentIndentation = $this->getCurrentLineIndentation(); $notEOF = $this->moveToNextLine(); @@ -438,7 +438,7 @@ protected function isNextLineIndented() * * @return Boolean Returns true if the current line is empty or if it is a comment line, false otherwise */ - protected function isCurrentLineEmpty() + protected function isCurrentLineEmpty(): bool { return $this->isCurrentLineBlank() || $this->isCurrentLineComment(); } @@ -448,7 +448,7 @@ protected function isCurrentLineEmpty() * * @return Boolean Returns true if the current line is blank, false otherwise */ - protected function isCurrentLineBlank() + protected function isCurrentLineBlank(): bool { return '' == trim($this->currentLine, ' '); } @@ -458,7 +458,7 @@ protected function isCurrentLineBlank() * * @return Boolean Returns true if the current line is a comment line, false otherwise */ - protected function isCurrentLineComment() + protected function isCurrentLineComment(): bool { //checking explicitly the first char of the trim is faster than loops or strpos $ltrimmedLine = ltrim($this->currentLine, ' '); diff --git a/runtime/lib/query/Criteria.php b/runtime/lib/query/Criteria.php index 3c45ddf55..a2528e6f4 100644 --- a/runtime/lib/query/Criteria.php +++ b/runtime/lib/query/Criteria.php @@ -279,7 +279,7 @@ public function __construct($dbName = null) * Implementing SPL IteratorAggregate interface. This allows * you to foreach () over a Criteria object. */ - public function getIterator() + public function getIterator(): Traversable { return new CriterionIterator($this); } diff --git a/runtime/lib/query/Criterion.php b/runtime/lib/query/Criterion.php index 61e631678..64808de00 100644 --- a/runtime/lib/query/Criterion.php +++ b/runtime/lib/query/Criterion.php @@ -80,7 +80,7 @@ class Criterion public function __construct(Criteria $outer, $column, $value, $comparison = null, $type = null) { $this->value = $value; - $dotPos = strrpos($column, '.'); + $dotPos = strrpos((string)$column, '.'); if ($dotPos === false || $comparison == Criteria::RAW) { // no dot => aliased column $this->table = null; diff --git a/runtime/lib/query/ModelCriteria.php b/runtime/lib/query/ModelCriteria.php index 5ea69007b..eb122ceb9 100644 --- a/runtime/lib/query/ModelCriteria.php +++ b/runtime/lib/query/ModelCriteria.php @@ -2238,7 +2238,7 @@ public function __call($name, $arguments) // Maybe it's a magic call to one of the methods supporting it, e.g. 'findByTitle' static $methods = array('findBy', 'findOneBy', 'filterBy', 'orderBy', 'groupBy'); foreach ($methods as $method) { - if (strpos($name, $method) === 0) { + if (strpos($name, (string) $method) === 0) { $columns = substr($name, strlen($method)); if (in_array($method, array('findBy', 'findOneBy')) && strpos($columns, 'And') !== false) { $method = $method . 'Array'; diff --git a/runtime/lib/query/ModelCriterion.php b/runtime/lib/query/ModelCriterion.php index c6eb4b6eb..2e850e8ba 100644 --- a/runtime/lib/query/ModelCriterion.php +++ b/runtime/lib/query/ModelCriterion.php @@ -263,7 +263,7 @@ public function equals($obj) /** * Returns a hash code value for the object. */ - public function hashCode() + public function hashCode(): int { $h = crc32(serialize($this->value)) ^ crc32($this->comparison) ^ crc32($this->clause); @@ -297,7 +297,7 @@ public function hashCode() */ protected static function strReplaceOnce($search, $replace, $subject) { - $firstChar = strpos($subject, $search); + $firstChar = strpos($subject, (string) $search); if ($firstChar !== false) { $beforeStr = substr($subject, 0, $firstChar); $afterStr = substr($subject, $firstChar + strlen($search)); diff --git a/runtime/lib/query/ModelJoin.php b/runtime/lib/query/ModelJoin.php index 3c9ee32c8..cf50d71ad 100644 --- a/runtime/lib/query/ModelJoin.php +++ b/runtime/lib/query/ModelJoin.php @@ -103,7 +103,7 @@ public function getPreviousJoin() /** * @return bool */ - public function isPrimary() + public function isPrimary(): bool { return null === $this->previousJoin; } @@ -153,7 +153,7 @@ public function getObjectToRelate($startObject) * * @return bool */ - public function equals($join) + public function equals($join): bool { return parent::equals($join) && $this->relationMap == $join->getRelationMap() diff --git a/runtime/lib/util/BasePeer.php b/runtime/lib/util/BasePeer.php index 156271f6e..a8ffe8602 100644 --- a/runtime/lib/util/BasePeer.php +++ b/runtime/lib/util/BasePeer.php @@ -625,7 +625,7 @@ private static function getPrimaryKey(Criteria $criteria) * 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) */ - public static function needsSelectAliases(Criteria $criteria) + public static function needsSelectAliases(Criteria $criteria): bool { $columnNames = array(); foreach ($criteria->getSelectColumns() as $fullyQualifiedColumnName) { diff --git a/runtime/lib/util/PropelDateTime.php b/runtime/lib/util/PropelDateTime.php index 90f9629ae..d8208015d 100644 --- a/runtime/lib/util/PropelDateTime.php +++ b/runtime/lib/util/PropelDateTime.php @@ -79,7 +79,7 @@ public static function newInstance($value, DateTimeZone $timeZone = null, $dateT return $dateTimeObject; } - public static function isTimestamp($value) + public static function isTimestamp($value): bool { if (!is_numeric($value)) { return false; @@ -119,7 +119,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. */ - public function __wakeup() + public function __wakeup(): void { parent::__construct($this->dateString, new DateTimeZone($this->tzString)); } diff --git a/runtime/lib/util/PropelModelPager.php b/runtime/lib/util/PropelModelPager.php index e632ab6e9..577ad5ea2 100644 --- a/runtime/lib/util/PropelModelPager.php +++ b/runtime/lib/util/PropelModelPager.php @@ -142,7 +142,7 @@ public function getLinks($nb_links = 5) * * @return boolean true if the pager displays only a subset of the results */ - public function haveToPaginate() + public function haveToPaginate(): bool { return (($this->getMaxPerPage() != 0) && ($this->getNbResults() > $this->getMaxPerPage())); } @@ -207,7 +207,7 @@ protected function setNbResults($nb) * * @return boolean true if the current page is the first page */ - public function isFirstPage() + public function isFirstPage(): bool { return $this->getPage() == $this->getFirstPage(); } @@ -217,7 +217,7 @@ public function isFirstPage() * * @return int Always 1 */ - public function getFirstPage() + public function getFirstPage(): int { return 1; } @@ -227,7 +227,7 @@ public function getFirstPage() * * @return boolean true if the current page is the last page */ - public function isLastPage() + public function isLastPage(): bool { return $this->getPage() == $this->getLastPage(); } @@ -284,7 +284,7 @@ public function setPage($page) * * @return int */ - public function getNextPage() + public function getNextPage(): int { return min($this->getPage() + 1, $this->getLastPage()); } @@ -294,7 +294,7 @@ public function getNextPage() * * @return int */ - public function getPreviousPage() + public function getPreviousPage(): int { return max($this->getPage() - 1, $this->getFirstPage()); } @@ -392,7 +392,7 @@ public function isEven() return $this->getResults()->isEven(); } - public function getIterator() + public function getIterator(): Traversable { return $this->getResults()->getIterator(); } @@ -403,7 +403,7 @@ public function getIterator() * @see Countable * @return int */ - public function count() + public function count(): int { return $this->getNbResults(); } diff --git a/runtime/lib/util/PropelPager.php b/runtime/lib/util/PropelPager.php index 4c6909853..f07f96ebd 100644 --- a/runtime/lib/util/PropelPager.php +++ b/runtime/lib/util/PropelPager.php @@ -303,7 +303,7 @@ private function doRs() * * @return int 1 */ - public function getFirstPage() + public function getFirstPage(): string { return '1'; } @@ -313,7 +313,7 @@ public function getFirstPage() * * @return boolean */ - public function atFirstPage() + public function atFirstPage(): bool { return $this->getPage() == $this->getFirstPage(); } @@ -338,7 +338,7 @@ public function getLastPage() * * @return boolean */ - public function atLastPage() + public function atLastPage(): bool { return $this->getPage() == $this->getLastPage(); } @@ -369,7 +369,7 @@ public function getTotalPages() * * @return array $links */ - public function getPrevLinks($range = 5) + public function getPrevLinks($range = 5): array { $total = $this->getTotalPages(); $start = $this->getPage() - 1; @@ -415,7 +415,7 @@ public function getNextLinks($range = 5) * * @return bool Last page complete or not */ - public function isLastPageComplete() + public function isLastPageComplete(): bool { return !($this->getTotalRecordCount() % $this->max); } @@ -560,7 +560,7 @@ public function setMax($v) * * @return int */ - public function count() + public function count(): int { return count($this->getResult()); } @@ -570,7 +570,7 @@ public function count() * * @return mixed */ - public function current() + public function current(): mixed { if (!isset($this->rs)) { $this->doRs(); @@ -584,7 +584,7 @@ public function current() * * @return int */ - public function key() + public function key(): int { return $this->currentKey; } @@ -594,7 +594,7 @@ public function key() * * @return void */ - public function next() + public function next(): void { $this->currentKey++; } @@ -604,7 +604,7 @@ public function next() * * @return void */ - public function rewind() + public function rewind(): void { $this->currentKey = 0; } @@ -614,7 +614,7 @@ public function rewind() * * @return boolean */ - public function valid() + public function valid(): bool { if (!isset($this->rs)) { $this->doRs(); diff --git a/runtime/lib/validator/MatchValidator.php b/runtime/lib/validator/MatchValidator.php index 69d62c33f..6d767c778 100644 --- a/runtime/lib/validator/MatchValidator.php +++ b/runtime/lib/validator/MatchValidator.php @@ -68,7 +68,7 @@ private function prepareRegexp($exp) * * @return boolean */ - public function isValid(ValidatorMap $map, $str) + public function isValid(ValidatorMap $map, $str): bool { return (preg_match($this->prepareRegexp($map->getValue()), $str) != 0); } diff --git a/runtime/lib/validator/MaxLengthValidator.php b/runtime/lib/validator/MaxLengthValidator.php index 4e1f0f3c4..9e37d94cc 100644 --- a/runtime/lib/validator/MaxLengthValidator.php +++ b/runtime/lib/validator/MaxLengthValidator.php @@ -37,7 +37,7 @@ class MaxLengthValidator implements BasicValidator * * @return boolean */ - public function isValid(ValidatorMap $map, $str) + public function isValid(ValidatorMap $map, $str): bool { $len = function_exists('mb_strlen') ? mb_strlen($str) : strlen($str); diff --git a/runtime/lib/validator/MaxValueValidator.php b/runtime/lib/validator/MaxValueValidator.php index 82a86ffac..4497cd11a 100644 --- a/runtime/lib/validator/MaxValueValidator.php +++ b/runtime/lib/validator/MaxValueValidator.php @@ -36,7 +36,7 @@ class MaxValueValidator implements BasicValidator * * @return boolean */ - public function isValid(ValidatorMap $map, $value) + public function isValid(ValidatorMap $map, $value): bool { if (is_null($value) == false && is_numeric($value) == true) { return intval($value) <= intval($map->getValue()); diff --git a/runtime/lib/validator/MinLengthValidator.php b/runtime/lib/validator/MinLengthValidator.php index 57875f33c..9798e3ed6 100644 --- a/runtime/lib/validator/MinLengthValidator.php +++ b/runtime/lib/validator/MinLengthValidator.php @@ -33,7 +33,7 @@ class MinLengthValidator implements BasicValidator * * @return boolean */ - public function isValid(ValidatorMap $map, $str) + public function isValid(ValidatorMap $map, $str): bool { $len = function_exists('mb_strlen') ? mb_strlen($str) : strlen($str); diff --git a/runtime/lib/validator/MinValueValidator.php b/runtime/lib/validator/MinValueValidator.php index bd73e69b5..43136d184 100644 --- a/runtime/lib/validator/MinValueValidator.php +++ b/runtime/lib/validator/MinValueValidator.php @@ -36,7 +36,7 @@ class MinValueValidator implements BasicValidator * * @return boolean */ - public function isValid(ValidatorMap $map, $value) + public function isValid(ValidatorMap $map, $value): bool { if (is_null($value) == false && is_numeric($value)) { return intval($value) >= intval($map->getValue()); diff --git a/runtime/lib/validator/NotMatchValidator.php b/runtime/lib/validator/NotMatchValidator.php index a214ca7a2..651c762be 100644 --- a/runtime/lib/validator/NotMatchValidator.php +++ b/runtime/lib/validator/NotMatchValidator.php @@ -66,7 +66,7 @@ private function prepareRegexp($exp) * * @return boolean */ - public function isValid(ValidatorMap $map, $str) + public function isValid(ValidatorMap $map, $str): bool { return (preg_match($this->prepareRegexp($map->getValue()), $str) == 0); } diff --git a/runtime/lib/validator/RequiredValidator.php b/runtime/lib/validator/RequiredValidator.php index d125fb48c..225074572 100644 --- a/runtime/lib/validator/RequiredValidator.php +++ b/runtime/lib/validator/RequiredValidator.php @@ -35,7 +35,7 @@ class RequiredValidator implements BasicValidator * * @return boolean */ - public function isValid(ValidatorMap $map, $str) + public function isValid(ValidatorMap $map, $str): bool { return ($str !== null && $str !== ""); } diff --git a/runtime/lib/validator/UniqueValidator.php b/runtime/lib/validator/UniqueValidator.php index 061c05664..1f56f1316 100644 --- a/runtime/lib/validator/UniqueValidator.php +++ b/runtime/lib/validator/UniqueValidator.php @@ -33,7 +33,7 @@ class UniqueValidator implements BasicValidator * * @return boolean */ - public function isValid(ValidatorMap $map, $str) + public function isValid(ValidatorMap $map, $str): bool { $column = $map->getColumn(); diff --git a/runtime/lib/validator/ValidValuesValidator.php b/runtime/lib/validator/ValidValuesValidator.php index 9879fca04..b1371df84 100644 --- a/runtime/lib/validator/ValidValuesValidator.php +++ b/runtime/lib/validator/ValidValuesValidator.php @@ -33,7 +33,7 @@ class ValidValuesValidator implements BasicValidator * * @return boolean */ - public function isValid(ValidatorMap $map, $str) + public function isValid(ValidatorMap $map, $str): bool { return in_array($str, preg_split("/[|,]/", $map->getValue())); } diff --git a/test/fixtures/bookstore/build.properties b/test/fixtures/bookstore/build.properties index 681bb7540..f4b96a815 100644 --- a/test/fixtures/bookstore/build.properties +++ b/test/fixtures/bookstore/build.properties @@ -12,7 +12,7 @@ propel.project = bookstore propel.database = mysql -propel.database.url = mysql:dbname=test +propel.database.url = mysql:host=db;dbname=test propel.mysql.tableType = InnoDB propel.disableIdentifierQuoting = true propel.schema.autoPrefix = true diff --git a/test/fixtures/bookstore/runtime-conf.xml b/test/fixtures/bookstore/runtime-conf.xml index da5f43269..e3c3d601e 100644 --- a/test/fixtures/bookstore/runtime-conf.xml +++ b/test/fixtures/bookstore/runtime-conf.xml @@ -16,7 +16,7 @@ DebugPDO - mysql:dbname=test + mysql:host=db;dbname=test @@ -51,7 +51,7 @@ mysql DebugPDO - mysql:dbname=test + mysql:host=db;dbname=test @@ -73,7 +73,7 @@ mysql DebugPDO - mysql:dbname=test + mysql:host=db;dbname=test diff --git a/test/fixtures/namespaced/build.properties b/test/fixtures/namespaced/build.properties index b3426f6d7..c4670681d 100644 --- a/test/fixtures/namespaced/build.properties +++ b/test/fixtures/namespaced/build.properties @@ -12,7 +12,7 @@ propel.project = bookstore_namespaced propel.database = mysql -propel.database.url = mysql:dbname=test +propel.database.url = mysql:host=db;dbname=test propel.mysql.tableType = InnoDB propel.disableIdentifierQuoting=true diff --git a/test/fixtures/namespaced/runtime-conf.xml b/test/fixtures/namespaced/runtime-conf.xml index d99174c89..66d2d2080 100644 --- a/test/fixtures/namespaced/runtime-conf.xml +++ b/test/fixtures/namespaced/runtime-conf.xml @@ -16,7 +16,7 @@ DebugPDO - mysql:dbname=test + mysql:host=db;dbname=test diff --git a/test/fixtures/reverse/mysql/build.properties b/test/fixtures/reverse/mysql/build.properties index 57db39b7c..2f26ce3c4 100644 --- a/test/fixtures/reverse/mysql/build.properties +++ b/test/fixtures/reverse/mysql/build.properties @@ -13,7 +13,7 @@ propel.project = reverse_bookstore propel.database = mysql -propel.database.url = mysql:dbname=reverse_bookstore +propel.database.url = mysql:host=db;dbname=reverse_bookstore # For MySQL or Oracle, you also need to specify username & password propel.database.user = root diff --git a/test/fixtures/reverse/mysql/runtime-conf.xml b/test/fixtures/reverse/mysql/runtime-conf.xml index 39a8d0dea..e98996d1f 100644 --- a/test/fixtures/reverse/mysql/runtime-conf.xml +++ b/test/fixtures/reverse/mysql/runtime-conf.xml @@ -14,7 +14,7 @@ mysql DebugPDO - mysql:dbname=reverse_bookstore + mysql:host=db;dbname=reverse_bookstore diff --git a/test/fixtures/schemas/build.properties b/test/fixtures/schemas/build.properties index 46ba085ef..8a1467a99 100644 --- a/test/fixtures/schemas/build.properties +++ b/test/fixtures/schemas/build.properties @@ -12,7 +12,7 @@ propel.project = bookstore propel.database = mysql -propel.database.url = mysql:dbname=test +propel.database.url = mysql:host=db;dbname=test propel.database.user = root propel.database.password = root propel.mysql.tableType = InnoDB diff --git a/test/fixtures/schemas/runtime-conf.xml b/test/fixtures/schemas/runtime-conf.xml index fc6f5d58f..faf6f87dd 100644 --- a/test/fixtures/schemas/runtime-conf.xml +++ b/test/fixtures/schemas/runtime-conf.xml @@ -14,7 +14,7 @@ mysql DebugPDO - mysql:dbname=test + mysql:host=db;dbname=test diff --git a/test/testsuite/generator/behavior/SoftDeleteBehaviorTest.php b/test/testsuite/generator/behavior/SoftDeleteBehaviorTest.php index 3900baa32..9a8de6cc2 100644 --- a/test/testsuite/generator/behavior/SoftDeleteBehaviorTest.php +++ b/test/testsuite/generator/behavior/SoftDeleteBehaviorTest.php @@ -394,7 +394,7 @@ public function testPostDelete() class UndeletableTable4 extends Table4 { - public function preDelete(PropelPDO $con = null) + public function preDelete(PropelPDO $con = null): bool { parent::preDelete($con); $this->setTitle('foo'); diff --git a/test/testsuite/runtime/query/ModelCriteriaHooksTest.php b/test/testsuite/runtime/query/ModelCriteriaHooksTest.php index 2285e5603..d7148eaf5 100644 --- a/test/testsuite/runtime/query/ModelCriteriaHooksTest.php +++ b/test/testsuite/runtime/query/ModelCriteriaHooksTest.php @@ -149,7 +149,7 @@ public function preSelect(PropelPDO $con) class ModelCriteriaWithPreDeleteHook extends ModelCriteria { - public function preDelete(PropelPDO $con) + public function preDelete(PropelPDO $con): int { return 12; } @@ -165,7 +165,7 @@ public function postDelete($affectedRows, PropelPDO $con) class ModelCriteriaWithPreAndPostDeleteHook extends ModelCriteriaWithPostDeleteHook { - public function preDelete(PropelPDO $con) + public function preDelete(PropelPDO $con): int { return 12; } @@ -189,7 +189,7 @@ public function postUpdate($affectedRows, PropelPDO $con) class ModelCriteriaWithPreAndPostUpdateHook extends ModelCriteriaWithPostUpdateHook { - public function preUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false) + public function preUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false): int { return 52; } diff --git a/test/tools/helpers/DummyPlatforms.php b/test/tools/helpers/DummyPlatforms.php index 35efe7260..bb8c377b8 100644 --- a/test/tools/helpers/DummyPlatforms.php +++ b/test/tools/helpers/DummyPlatforms.php @@ -2,10 +2,10 @@ class SchemaPlatform { - public function supportsSchemas() {return true;} + public function supportsSchemas(): bool {return true;} } class NoSchemaPlatform { - public function supportsSchemas() {return false;} + public function supportsSchemas(): bool {return false;} } diff --git a/test/tools/helpers/bookstore/behavior/AddClassBehaviorBuilder.php b/test/tools/helpers/bookstore/behavior/AddClassBehaviorBuilder.php index 040cbf132..25cc5a797 100644 --- a/test/tools/helpers/bookstore/behavior/AddClassBehaviorBuilder.php +++ b/test/tools/helpers/bookstore/behavior/AddClassBehaviorBuilder.php @@ -13,7 +13,7 @@ public function getPackage() * Returns the name of the current class being built. * @return string */ - public function getUnprefixedClassname() + public function getUnprefixedClassname(): string { return $this->getStubObjectBuilder()->getUnprefixedClassname() . 'FooClass'; } diff --git a/test/tools/helpers/bookstore/behavior/TestAuthor.php b/test/tools/helpers/bookstore/behavior/TestAuthor.php index 065013e1d..9e3d44900 100644 --- a/test/tools/helpers/bookstore/behavior/TestAuthor.php +++ b/test/tools/helpers/bookstore/behavior/TestAuthor.php @@ -75,7 +75,7 @@ public function postHydrate($row, $startcol = 0, $rehydrate = false) class TestAuthorDeleteFalse extends TestAuthor { - public function preDelete(PropelPDO $con = null) + public function preDelete(PropelPDO $con = null): bool { parent::preDelete($con); $this->setFirstName("Pre-Deleted"); @@ -85,7 +85,7 @@ public function preDelete(PropelPDO $con = null) } class TestAuthorSaveFalse extends TestAuthor { - public function preSave(PropelPDO $con = null) + public function preSave(PropelPDO $con = null): bool { parent::preSave($con); $this->setEmail("pre@save.com"); diff --git a/test/tools/helpers/bookstore/behavior/Testallhooksbehavior.php b/test/tools/helpers/bookstore/behavior/Testallhooksbehavior.php index 7224eecb2..bd0c5e845 100644 --- a/test/tools/helpers/bookstore/behavior/Testallhooksbehavior.php +++ b/test/tools/helpers/bookstore/behavior/Testallhooksbehavior.php @@ -70,62 +70,62 @@ public function modifyTable() class TestAllHooksObjectBuilderModifier { - public function objectAttributes($builder) + public function objectAttributes($builder): string { return 'public $customAttribute = 1;'; } - public function preSave($builder) + public function preSave($builder): string { return '$this->preSave = 1;$this->preSaveIsAfterSave = isset($affectedRows);$this->preSaveBuilder="' . get_class($builder) . '";'; } - public function postSave($builder) + public function postSave($builder): string { return '$this->postSave = 1;$this->postSaveIsAfterSave = isset($affectedRows);$this->postSaveBuilder="' . get_class($builder) . '";'; } - public function preInsert($builder) + public function preInsert($builder): string { return '$this->preInsert = 1;$this->preInsertIsAfterSave = isset($affectedRows);$this->preInsertBuilder="' . get_class($builder) . '";'; } - public function postInsert($builder) + public function postInsert($builder): string { return '$this->postInsert = 1;$this->postInsertIsAfterSave = isset($affectedRows);$this->postInsertBuilder="' . get_class($builder) . '";'; } - public function preUpdate($builder) + public function preUpdate($builder): string { return '$this->preUpdate = 1;$this->preUpdateIsAfterSave = isset($affectedRows);$this->preUpdateBuilder="' . get_class($builder) . '";'; } - public function postUpdate($builder) + public function postUpdate($builder): string { return '$this->postUpdate = 1;$this->postUpdateIsAfterSave = isset($affectedRows);$this->postUpdateBuilder="' . get_class($builder) . '";'; } - public function preDelete($builder) + public function preDelete($builder): string { return '$this->preDelete = 1;$this->preDeleteIsBeforeDelete = isset(Table3Peer::$instances[$this->id]);$this->preDeleteBuilder="' . get_class($builder) . '";'; } - public function postDelete($builder) + public function postDelete($builder): string { return '$this->postDelete = 1;$this->postDeleteIsBeforeDelete = isset(Table3Peer::$instances[$this->id]);$this->postDeleteBuilder="' . get_class($builder) . '";'; } - public function postHydrate($builder) + public function postHydrate($builder): string { return '$this->postHydrate = 1;$this->postHydrateIsAfterHydrate = isset($this->id);$this->postHydrateBuilder="' . get_class($builder) . '";'; } - public function objectMethods($builder) + public function objectMethods($builder): string { return 'public function hello() { return "' . get_class($builder) .'"; }'; } - public function objectCall($builder) + public function objectCall($builder): string { return 'if ($name == "foo") return "bar";'; } @@ -138,17 +138,17 @@ public function objectFilter(&$string, $builder) class TestAllHooksPeerBuilderModifier { - public function staticAttributes($builder) + public function staticAttributes($builder): string { return 'public static $customStaticAttribute = 1;public static $staticAttributeBuilder = "' . get_class($builder) . '";'; } - public function staticMethods($builder) + public function staticMethods($builder): string { return 'public static function hello() { return "' . get_class($builder) . '"; }'; } - public function preSelect($builder) + public function preSelect($builder): string { return '$con->preSelect = "' . get_class($builder) . '";'; } @@ -161,27 +161,27 @@ public function peerFilter(&$string, $builder) class TestAllHooksQueryBuilderModifier { - public function preSelectQuery($builder) + public function preSelectQuery($builder): string { return '// foo'; } - public function preDeleteQuery($builder) + public function preDeleteQuery($builder): string { return '// foo'; } - public function postDeleteQuery($builder) + public function postDeleteQuery($builder): string { return '// foo'; } - public function preUpdateQuery($builder) + public function preUpdateQuery($builder): string { return '// foo'; } - public function postUpdateQuery($builder) + public function postUpdateQuery($builder): string { return '// foo'; } diff --git a/test/tools/helpers/bookstore/validator/ISBNValidator.php b/test/tools/helpers/bookstore/validator/ISBNValidator.php index c92413ca6..793ecef61 100644 --- a/test/tools/helpers/bookstore/validator/ISBNValidator.php +++ b/test/tools/helpers/bookstore/validator/ISBNValidator.php @@ -22,8 +22,8 @@ class ISBNValidator implements BasicValidator /** * Whether the passed string matches regular expression. */ - public function isValid(ValidatorMap $map, $str) + public function isValid(ValidatorMap $map, $str): bool { - return !(preg_match(self::NOT_ISBN_REGEXP, $str)); + return !(preg_match(self::NOT_ISBN_REGEXP, (string)$str)); } }