From fbc1b3af1349d604cdfc87fa89f1a3775c576a6d Mon Sep 17 00:00:00 2001 From: Toni Uebernickel Date: Tue, 9 Apr 2013 15:53:08 +0200 Subject: [PATCH] fix some introspections, coding style --- generator/bin/phing.php | 7 +- generator/build-propel.xml | 1274 +++++------ generator/build.xml | 417 ++-- .../AlternativeCodingStandardsBehavior.php | 12 +- generator/lib/behavior/DelegateBehavior.php | 15 +- generator/lib/behavior/SoftDeleteBehavior.php | 2 +- .../lib/behavior/TimestampableBehavior.php | 27 +- .../AggregateColumnBehavior.php | 10 +- .../AggregateColumnRelationBehavior.php | 1 + .../archivable/ArchivableBehavior.php | 4 +- ...rchivableBehaviorObjectBuilderModifier.php | 41 +- ...ArchivableBehaviorQueryBuilderModifier.php | 38 +- .../ConcreteInheritanceBehavior.php | 6 +- .../ConcreteInheritanceParentBehavior.php | 1 - generator/lib/behavior/i18n/I18nBehavior.php | 5 +- .../I18nBehaviorObjectBuilderModifier.php | 1 - ...NestedSetBehaviorObjectBuilderModifier.php | 12 +- .../NestedSetBehaviorPeerBuilderModifier.php | 16 +- .../NestedSetBehaviorQueryBuilderModifier.php | 16 +- .../query_cache/QueryCacheBehavior.php | 8 +- .../behavior/sluggable/SluggableBehavior.php | 26 +- .../behavior/sortable/SortableBehavior.php | 4 +- .../SortableBehaviorObjectBuilderModifier.php | 27 +- .../SortableBehaviorPeerBuilderModifier.php | 9 +- .../SortableBehaviorQueryBuilderModifier.php | 11 +- .../sortable/SortableRelationBehavior.php | 1 - .../versionable/VersionableBehavior.php | 31 +- ...rsionableBehaviorObjectBuilderModifier.php | 26 +- ...ersionableBehaviorQueryBuilderModifier.php | 5 +- generator/lib/builder/DataModelBuilder.php | 75 +- generator/lib/builder/om/ClassTools.php | 22 +- .../lib/builder/om/ExtensionQueryBuilder.php | 19 +- .../om/ExtensionQueryInheritanceBuilder.php | 16 +- generator/lib/builder/om/OMBuilder.php | 37 +- generator/lib/builder/om/ObjectBuilder.php | 15 +- .../builder/om/PHP5ExtensionNodeBuilder.php | 11 +- .../om/PHP5ExtensionNodePeerBuilder.php | 15 +- .../builder/om/PHP5ExtensionObjectBuilder.php | 20 +- .../builder/om/PHP5ExtensionPeerBuilder.php | 23 +- .../lib/builder/om/PHP5InterfaceBuilder.php | 10 +- .../om/PHP5MultiExtendObjectBuilder.php | 31 +- .../lib/builder/om/PHP5NestedSetBuilder.php | 29 +- .../builder/om/PHP5NestedSetPeerBuilder.php | 55 +- generator/lib/builder/om/PHP5NodeBuilder.php | 62 +- .../lib/builder/om/PHP5NodePeerBuilder.php | 17 +- .../lib/builder/om/PHP5ObjectBuilder.php | 714 ++++--- .../om/PHP5ObjectNoCollectionBuilder.php | 168 +- generator/lib/builder/om/PHP5PeerBuilder.php | 826 ++++---- .../lib/builder/om/PHP5TableMapBuilder.php | 65 +- generator/lib/builder/om/PeerBuilder.php | 68 +- generator/lib/builder/om/QueryBuilder.php | 84 +- .../builder/om/QueryInheritanceBuilder.php | 25 +- generator/lib/builder/sql/DataSQLBuilder.php | 30 +- .../builder/sql/mssql/MssqlDataSQLBuilder.php | 4 +- .../builder/sql/pgsql/PgsqlDataSQLBuilder.php | 8 +- .../sql/sqlite/SqliteDataSQLBuilder.php | 3 +- .../builder/util/DefaultEnglishPluralizer.php | 3 +- generator/lib/builder/util/Pluralizer.php | 3 +- .../lib/builder/util/PropelStringReader.php | 18 +- generator/lib/builder/util/PropelTemplate.php | 4 +- .../util/StandardEnglishPluralizer.php | 2 + generator/lib/builder/util/XmlToAppData.php | 127 +- generator/lib/builder/util/XmlToDataSQL.php | 8 +- generator/lib/config/GeneratorConfig.php | 20 +- .../lib/config/GeneratorConfigInterface.php | 12 +- generator/lib/config/QuickGeneratorConfig.php | 38 +- generator/lib/exception/EngineException.php | 4 +- generator/lib/exception/SchemaException.php | 4 +- generator/lib/model/AppData.php | 33 +- generator/lib/model/Behavior.php | 7 +- generator/lib/model/Column.php | 113 +- generator/lib/model/ColumnDefaultValue.php | 2 +- .../lib/model/ConstraintNameGenerator.php | 11 +- generator/lib/model/Database.php | 212 +- generator/lib/model/Domain.php | 8 +- generator/lib/model/ForeignKey.php | 97 +- generator/lib/model/IDMethod.php | 1 - generator/lib/model/IdMethodParameter.php | 7 +- generator/lib/model/Index.php | 22 +- generator/lib/model/Inheritance.php | 29 +- generator/lib/model/NameFactory.php | 5 +- generator/lib/model/NameGenerator.php | 5 +- generator/lib/model/PhpNameGenerator.php | 15 +- generator/lib/model/PropelTypes.php | 22 +- generator/lib/model/Rule.php | 15 +- generator/lib/model/ScopedElement.php | 9 +- generator/lib/model/Table.php | 226 +- generator/lib/model/Unique.php | 3 +- generator/lib/model/Validator.php | 14 +- generator/lib/model/VendorInfo.php | 7 +- generator/lib/model/XMLElement.php | 67 +- generator/lib/model/diff/PropelColumnDiff.php | 1 - .../model/diff/PropelDatabaseComparator.php | 1 - .../lib/model/diff/PropelDatabaseDiff.php | 9 +- .../model/diff/PropelForeignKeyComparator.php | 1 - .../lib/model/diff/PropelIndexComparator.php | 1 - .../lib/model/diff/PropelTableComparator.php | 7 +- generator/lib/model/diff/PropelTableDiff.php | 7 +- generator/lib/platform/DefaultPlatform.php | 81 +- generator/lib/platform/MssqlPlatform.php | 3 +- generator/lib/platform/MysqlPlatform.php | 37 +- generator/lib/platform/OraclePlatform.php | 29 +- generator/lib/platform/PgsqlPlatform.php | 18 +- .../lib/platform/PropelPlatformInterface.php | 25 + generator/lib/platform/SqlitePlatform.php | 14 +- generator/lib/reverse/BaseSchemaParser.php | 20 +- generator/lib/reverse/SchemaParser.php | 3 + .../lib/reverse/mssql/MssqlSchemaParser.php | 43 +- .../lib/reverse/mysql/MysqlSchemaParser.php | 24 +- .../lib/reverse/oracle/OracleSchemaParser.php | 38 +- .../lib/reverse/pgsql/PgsqlSchemaParser.php | 152 +- .../lib/reverse/sqlite/SqliteSchemaParser.php | 9 +- .../lib/task/AbstractPropelDataModelTask.php | 44 +- .../lib/task/BasePropelMigrationTask.php | 9 +- generator/lib/task/PropelConvertConfTask.php | 40 +- generator/lib/task/PropelDataDumpTask.php | 21 +- generator/lib/task/PropelDataSQLTask.php | 12 +- generator/lib/task/PropelGraphvizTask.php | 11 +- .../lib/task/PropelMigrationDownTask.php | 5 +- generator/lib/task/PropelOMTask.php | 26 +- generator/lib/task/PropelSQLExec.php | 19 +- generator/lib/task/PropelSQLTask.php | 10 +- .../lib/task/PropelSchemaReverseTask.php | 54 +- generator/lib/util/PropelPHPParser.php | 7 +- generator/lib/util/PropelQuickBuilder.php | 6 +- generator/lib/util/PropelSQLParser.php | 5 +- generator/lib/util/PropelSchemaValidator.php | 5 +- generator/lib/util/PropelSqlManager.php | 3 +- .../pear/BuildPropelGenPEARPackageTask.php | 16 +- generator/pear/build-pear-package.xml | 279 +-- generator/pear/pear-build.xml | 273 +-- generator/resources/dtd/database.dtd | 360 ++-- generator/resources/xsd/custom_datatypes.xsd | 10 +- generator/resources/xsd/database.xsd | 1884 +++++++++-------- generator/resources/xsl/database.xsl | 526 ++--- generator/resources/xsl/dbd2propel.xsl | 779 +++---- runtime/lib/Propel.php | 66 +- runtime/lib/adapter/DBAdapter.php | 13 +- runtime/lib/adapter/DBMSSQL.php | 40 +- runtime/lib/adapter/DBMySQL.php | 10 +- runtime/lib/adapter/DBNone.php | 3 + runtime/lib/adapter/DBOracle.php | 15 +- runtime/lib/adapter/DBPostgres.php | 87 +- runtime/lib/adapter/DBSQLSRV.php | 18 +- runtime/lib/adapter/DBSQLite.php | 7 +- runtime/lib/adapter/MSSQL/MssqlPropelPDO.php | 3 +- .../lib/collection/PropelArrayCollection.php | 5 +- runtime/lib/collection/PropelCollection.php | 9 + .../lib/collection/PropelObjectCollection.php | 7 +- .../collection/PropelOnDemandCollection.php | 4 + .../lib/collection/PropelOnDemandIterator.php | 2 +- runtime/lib/config/PropelConfiguration.php | 9 +- runtime/lib/connection/DebugPDOStatement.php | 24 +- runtime/lib/connection/PropelPDO.php | 30 +- runtime/lib/exception/PropelException.php | 3 +- .../lib/formatter/PropelArrayFormatter.php | 3 +- runtime/lib/formatter/PropelFormatter.php | 1 - .../lib/formatter/PropelObjectFormatter.php | 6 +- .../lib/formatter/PropelOnDemandFormatter.php | 3 +- .../formatter/PropelStatementFormatter.php | 1 - runtime/lib/logger/BasicLogger.php | 2 + runtime/lib/logger/MojaviLogAdapter.php | 4 +- runtime/lib/map/ColumnMap.php | 1019 ++++----- runtime/lib/map/DatabaseMap.php | 10 +- runtime/lib/map/RelationMap.php | 432 ++-- runtime/lib/map/TableMap.php | 46 +- runtime/lib/om/BaseObject.php | 27 + runtime/lib/om/NodeObject.php | 34 +- runtime/lib/om/Persistent.php | 9 + runtime/lib/om/PreOrderNodeIterator.php | 13 +- runtime/lib/parser/PropelCSVParser.php | 20 +- runtime/lib/parser/PropelJSONParser.php | 5 +- runtime/lib/parser/PropelParser.php | 2 + runtime/lib/parser/PropelXMLParser.php | 6 +- runtime/lib/parser/PropelYAMLParser.php | 5 +- runtime/lib/query/Criteria.php | 121 +- runtime/lib/query/Criterion.php | 53 +- runtime/lib/query/CriterionIterator.php | 1 - runtime/lib/query/Join.php | 104 +- runtime/lib/query/ModelCriteria.php | 82 +- runtime/lib/query/ModelCriterion.php | 28 +- runtime/lib/query/ModelJoin.php | 6 +- runtime/lib/query/PropelQuery.php | 1 + runtime/lib/util/BasePeer.php | 81 +- runtime/lib/util/NodePeer.php | 36 +- runtime/lib/util/PropelColumnTypes.php | 3 +- runtime/lib/util/PropelDateTime.php | 8 +- runtime/lib/util/PropelModelPager.php | 8 +- runtime/lib/util/PropelPager.php | 86 +- runtime/lib/validator/MatchValidator.php | 5 +- runtime/lib/validator/NotMatchValidator.php | 3 +- runtime/lib/validator/RequiredValidator.php | 2 +- runtime/pear/BuildPropelPEARPackageTask.php | 16 +- runtime/pear/build-pear-package.xml | 211 +- 194 files changed, 7529 insertions(+), 5934 deletions(-) diff --git a/generator/bin/phing.php b/generator/bin/phing.php index c94982f46..c6a4223fc 100755 --- a/generator/bin/phing.php +++ b/generator/bin/phing.php @@ -5,6 +5,7 @@ * This is the Phing command line launcher. It starts up the system environment * tests for all important paths and properties and kicks of the main command- * line entry point of phing located in phing.Phing + * * @version $Revision: 552 $ */ @@ -15,7 +16,7 @@ $autoloaded = false; foreach (array($dirname . '/../../', $dirname . '/../../../../../') as $dir) { if (file_exists($file = realpath($dir) . '/vendor/autoload.php')) { - set_include_path($dir . '/vendor/phing/phing/classes' . PATH_SEPARATOR . get_include_path() ); + set_include_path($dir . '/vendor/phing/phing/classes' . PATH_SEPARATOR . get_include_path()); include_once $file; $autoloaded = true; @@ -26,12 +27,12 @@ /* set classpath */ if (getenv('PHP_CLASSPATH')) { if (!defined('PHP_CLASSPATH')) { - define('PHP_CLASSPATH', getenv('PHP_CLASSPATH') . PATH_SEPARATOR . get_include_path()); + define('PHP_CLASSPATH', getenv('PHP_CLASSPATH') . PATH_SEPARATOR . get_include_path()); } ini_set('include_path', PHP_CLASSPATH); } else { if (!defined('PHP_CLASSPATH')) { - define('PHP_CLASSPATH', get_include_path()); + define('PHP_CLASSPATH', get_include_path()); } } diff --git a/generator/build-propel.xml b/generator/build-propel.xml index e969dcd2d..1026b25ab 100644 --- a/generator/build-propel.xml +++ b/generator/build-propel.xml @@ -1,639 +1,645 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ATTENTION: It appears you are using PostgreSQL and you have identifier-quoting turned on. - It is suggested that you disable identifier quoting when using PostgreSQL -- especially if you - have case-sensitive columns in your database. - - To disable identifier quoting, add the following property to your build.properties (or specify - it using -D on commandline): - - propel.disableIdentifierQuoting=true - - You can ignore this warning if you understand the issues related to case-sensitivity and Propel's - DDL-only implementation of identifier quoting. - - - - - - - - - - - - ATTENTION: It appears you are using the mysqli driver. - - This driver is no longer supported by Propel because Propel now uses PDO for database connections. - Please use mysqli driver instead. - Use 'mysql' instead of 'mysqli' for your propel.database property. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ATTENTION: It appears you are using PostgreSQL and you have identifier-quoting turned on. + It is suggested that you disable identifier quoting when using PostgreSQL -- especially if you + + have case-sensitive columns in your database. + + To disable identifier quoting, add the following property to your build.properties (or specify + + it using -D on commandline): + + propel.disableIdentifierQuoting=true + + You can ignore this warning if you understand the issues related to case-sensitivity and + Propel's + + DDL-only implementation of identifier quoting. + + + + + + + + + + + + ATTENTION: It appears you are using the mysqli driver. + + This driver is no longer supported by Propel because Propel now uses PDO for database + connections. + + Please use mysqli driver instead. + Use 'mysql' instead of 'mysqli' for your propel.database property. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/generator/build.xml b/generator/build.xml index a3b831cec..90a8929c0 100644 --- a/generator/build.xml +++ b/generator/build.xml @@ -18,224 +18,227 @@ --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Project name - - - - - No project.dir was specified, using default path: ./projects/${project} - - - - - - - - Processing additional properties file: ${additional.properties} - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Project name + + + + + No project.dir was specified, using default path: ./projects/${project} + + + + + + + + Processing additional properties file: ${additional.properties} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - + - + - - - + + + - + - + - - - + + + - + - - - + + + - - - + + + - - - + + + - - - + + + diff --git a/generator/lib/behavior/AlternativeCodingStandardsBehavior.php b/generator/lib/behavior/AlternativeCodingStandardsBehavior.php index 543757e3e..fdcd693dd 100644 --- a/generator/lib/behavior/AlternativeCodingStandardsBehavior.php +++ b/generator/lib/behavior/AlternativeCodingStandardsBehavior.php @@ -113,19 +113,23 @@ protected function filter(&$script) /** * Remove inline and codeblock comments from a PHP code string + * * @param string $code The input code + * * @return string The input code, without comments */ public static function stripComments($code) { - $output = ''; + $output = ''; $commentTokens = array(T_COMMENT, T_DOC_COMMENT); foreach (token_get_all($code) as $token) { if (is_array($token)) { - if (in_array($token[0], $commentTokens)) continue; + if (in_array($token[0], $commentTokens)) { + continue; + } $token = $token[1]; - } - $output .= $token; + } + $output .= $token; } return $output; diff --git a/generator/lib/behavior/DelegateBehavior.php b/generator/lib/behavior/DelegateBehavior.php index 91e59dd0b..4f9af83cd 100644 --- a/generator/lib/behavior/DelegateBehavior.php +++ b/generator/lib/behavior/DelegateBehavior.php @@ -38,11 +38,7 @@ public function modifyTable() foreach ($delegates as $delegate) { $delegate = $database->getTablePrefix() . trim($delegate); if (!$database->hasTable($delegate)) { - throw new InvalidArgumentException(sprintf( - 'No delegate table "%s" found for table "%s"', - $delegate, - $table->getName() - )); + throw new InvalidArgumentException(sprintf('No delegate table "%s" found for table "%s"', $delegate, $table->getName())); } if (in_array($delegate, $table->getForeignTableNames())) { // existing many-to-one relationship @@ -55,11 +51,7 @@ public function modifyTable() $fks = $delegateTable->getForeignKeysReferencingTable($this->getTable()->getName()); $fk = $fks[0]; if (!$fk->isLocalPrimaryKey()) { - throw new InvalidArgumentException(sprintf( - 'Delegate table "%s" has a relationship with table "%s", but it\'s a one-to-many relationship. The `delegate` behavior only supports one-to-one relationships in this case.', - $delegate, - $table->getName() - )); + throw new InvalidArgumentException(sprintf('Delegate table "%s" has a relationship with table "%s", but it\'s a one-to-many relationship. The `delegate` behavior only supports one-to-one relationships in this case.', $delegate, $table->getName())); } } else { // no relationship yet: must be created @@ -118,7 +110,7 @@ public function objectCall($builder) $ARClassName = $builder->getNewStubObjectBuilder($delegateTable)->getClassname(); $relationName = $builder->getFKPhpNameAffix($fk); } - $script .= " + $script .= " if (is_callable(array('$ARFQCN', \$name))) { if (!\$delegate = \$this->get$relationName()) { \$delegate = new $ARClassName(); @@ -131,5 +123,4 @@ public function objectCall($builder) return $script; } - } diff --git a/generator/lib/behavior/SoftDeleteBehavior.php b/generator/lib/behavior/SoftDeleteBehavior.php index 0467e3703..885585a28 100644 --- a/generator/lib/behavior/SoftDeleteBehavior.php +++ b/generator/lib/behavior/SoftDeleteBehavior.php @@ -375,7 +375,7 @@ public static function doSoftDelete(\$values, PropelPDO \$con = null) // it must be the primary key \$selectCriteria = new Criteria(self::DATABASE_NAME);"; $pks = $this->getTable()->getPrimaryKey(); - if (count($pks)>1) { + if (count($pks) > 1) { $i = 0; foreach ($pks as $col) { $script .= " diff --git a/generator/lib/behavior/TimestampableBehavior.php b/generator/lib/behavior/TimestampableBehavior.php index 6386ca560..0edcea41b 100644 --- a/generator/lib/behavior/TimestampableBehavior.php +++ b/generator/lib/behavior/TimestampableBehavior.php @@ -51,6 +51,7 @@ public function modifyTable() * Get the setter of one of the columns of the behavior * * @param string $column One of the behavior columns, 'create_column' or 'update_column' + * * @return string The related setter, 'setCreatedOn' or 'setUpdatedOn' */ protected function getColumnSetter($column) @@ -58,7 +59,15 @@ protected function getColumnSetter($column) return 'set' . $this->getColumnForParameter($column)->getPhpName(); } - protected function getColumnConstant($columnName, $builder) + /** + * Return the constant for a given column. + * + * @param string $columnName + * @param OMBuilder $builder + * + * @return string + */ + protected function getColumnConstant($columnName, OMBuilder $builder) { return $builder->getColumnConstant($this->getColumnForParameter($columnName)); } @@ -66,23 +75,29 @@ protected function getColumnConstant($columnName, $builder) /** * Add code in ObjectBuilder::preUpdate * + * @param PHP5ObjectBuilder $builder + * * @return string The code to put at the hook */ - public function preUpdate($builder) + public function preUpdate(PHP5ObjectBuilder $builder) { if ($this->withUpdatedAt()) { return "if (\$this->isModified() && !\$this->isColumnModified(" . $this->getColumnConstant('update_column', $builder) . ")) { \$this->" . $this->getColumnSetter('update_column') . "(time()); }"; } + + return ''; } /** * Add code in ObjectBuilder::preInsert * + * @param PHP5ObjectBuilder $builder + * * @return string The code to put at the hook */ - public function preInsert($builder) + public function preInsert(PHP5ObjectBuilder $builder) { $script = "if (!\$this->isColumnModified(" . $this->getColumnConstant('create_column', $builder) . ")) { \$this->" . $this->getColumnSetter('create_column') . "(time()); @@ -98,7 +113,7 @@ public function preInsert($builder) return $script; } - public function objectMethods($builder) + public function objectMethods(PHP5ObjectBuilder $builder) { if ($this->withUpdatedAt()) { return " @@ -117,11 +132,11 @@ public function keepUpdateDateUnchanged() } } - public function queryMethods($builder) + public function queryMethods(QueryBuilder $builder) { $script = ''; - $queryClassName = $builder->getStubQueryBuilder()->getClassname(); + $queryClassName = $builder->getStubQueryBuilder()->getClassname(); $createColumnConstant = $this->getColumnConstant('create_column', $builder); if ($this->withUpdatedAt()) { diff --git a/generator/lib/behavior/aggregate_column/AggregateColumnBehavior.php b/generator/lib/behavior/aggregate_column/AggregateColumnBehavior.php index 95a24f118..f2b9eb802 100644 --- a/generator/lib/behavior/aggregate_column/AggregateColumnBehavior.php +++ b/generator/lib/behavior/aggregate_column/AggregateColumnBehavior.php @@ -75,18 +75,18 @@ protected function addObjectCompute() { $conditions = array(); if ($this->getParameter('condition')) { - $conditions[] = $this->getParameter('condition'); + $conditions[] = $this->getParameter('condition'); } $bindings = array(); $database = $this->getTable()->getDatabase(); foreach ($this->getForeignKey()->getColumnObjectsMapping() as $index => $columnReference) { $conditions[] = $columnReference['local']->getFullyQualifiedName() . ' = :p' . ($index + 1); - $bindings[$index + 1] = $columnReference['foreign']->getPhpName(); + $bindings[$index + 1] = $columnReference['foreign']->getPhpName(); } $tableName = $database->getTablePrefix() . $this->getParameter('foreign_table'); if ($database->getPlatform()->supportsSchemas() && $this->getParameter('foreign_schema')) { - $tableName = $this->getParameter('foreign_schema').'.'.$tableName; + $tableName = $this->getParameter('foreign_schema') . '.' . $tableName; } $sql = sprintf('SELECT %s FROM %s WHERE %s', $this->getParameter('expression'), @@ -121,7 +121,7 @@ protected function getForeignTable() $database = $this->getTable()->getDatabase(); $tableName = $database->getTablePrefix() . $this->getParameter('foreign_table'); if ($database->getPlatform()->supportsSchemas() && $this->getParameter('foreign_schema')) { - $tableName = $this->getParameter('foreign_schema'). '.' . $tableName; + $tableName = $this->getParameter('foreign_schema') . '.' . $tableName; } return $database->getTable($tableName); @@ -135,6 +135,7 @@ protected function getForeignKey() if (!$fks) { throw new InvalidArgumentException(sprintf('You must define a foreign key to the \'%s\' table in the \'%s\' table to enable the \'aggregate_column\' behavior', $this->getTable()->getName(), $foreignTable->getName())); } + // FIXME doesn't work when more than one fk to the same table return array_shift($fks); } @@ -143,5 +144,4 @@ protected function getColumn() { return $this->getTable()->getColumn($this->getParameter('name')); } - } diff --git a/generator/lib/behavior/aggregate_column/AggregateColumnRelationBehavior.php b/generator/lib/behavior/aggregate_column/AggregateColumnRelationBehavior.php index bc492d196..6398573f5 100644 --- a/generator/lib/behavior/aggregate_column/AggregateColumnRelationBehavior.php +++ b/generator/lib/behavior/aggregate_column/AggregateColumnRelationBehavior.php @@ -155,6 +155,7 @@ protected function getForeignKey() $foreignTable = $this->getForeignTable(); // let's infer the relation from the foreign table $fks = $this->getTable()->getForeignKeysReferencingTable($foreignTable->getName()); + // FIXME doesn't work when more than one fk to the same table return array_shift($fks); } diff --git a/generator/lib/behavior/archivable/ArchivableBehavior.php b/generator/lib/behavior/archivable/ArchivableBehavior.php index 14a025e67..91225d2fb 100644 --- a/generator/lib/behavior/archivable/ArchivableBehavior.php +++ b/generator/lib/behavior/archivable/ArchivableBehavior.php @@ -15,8 +15,8 @@ * Keeps tracks of an ActiveRecord object, even after deletion * * @author Francois Zaninotto - * @version $Revision$ - * @package propel.generator.archivable + * @version $Revision$ + * @package propel.generator.archivable */ class ArchivableBehavior extends Behavior { diff --git a/generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php b/generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php index a33ca0bc0..e776ae85c 100644 --- a/generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php +++ b/generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php @@ -18,7 +18,7 @@ class ArchivableBehaviorObjectBuilderModifier { protected $behavior, $table, $builder; - public function __construct($behavior) + public function __construct(ArchivableBehavior $behavior) { $this->behavior = $behavior; $this->table = $behavior->getTable(); @@ -30,9 +30,13 @@ protected function getParameter($key) } /** - * @return string the PHP code to be added to the builder + * Add object attributes to the built class. + * + * @param PHP5ObjectBuilder $builder + * + * @return string The PHP code to be added to the builder. */ - public function objectAttributes($builder) + public function objectAttributes(PHP5ObjectBuilder $builder) { if (!$this->behavior->hasArchiveClass()) { $builder->declareClassFromBuilder($builder->getNewStubQueryBuilder($this->behavior->getArchiveTable())); @@ -56,9 +60,13 @@ public function objectAttributes($builder) } /** - * @return string the PHP code to be added to the builder + * Add code to the postInsert hook. + * + * @param PHP5ObjectBuilder $builder + * + * @return string The PHP code to be added to the builder. */ - public function postInsert($builder) + public function postInsert(PHP5ObjectBuilder $builder) { if ($this->behavior->isArchiveOnInsert()) { return "if (\$this->archiveOnInsert) { @@ -67,12 +75,18 @@ public function postInsert($builder) \$this->archiveOnInsert = true; }"; } + + return ''; } /** - * @return string the PHP code to be added to the builder + * Add code to the postUpdate hoook. + * + * @param PHP5ObjectBuilder $builder) + * + * @return string The PHP code to be added to the builder. */ - public function postUpdate($builder) + public function postUpdate(PHP5ObjectBuilder $builder) { if ($this->behavior->isArchiveOnUpdate()) { return "if (\$this->archiveOnUpdate) { @@ -81,6 +95,8 @@ public function postUpdate($builder) \$this->archiveOnUpdate = true; }"; } + + return ''; } /** @@ -112,9 +128,7 @@ public function objectMethods($builder) if ($this->behavior->hasArchiveClass()) { $this->builder->declareClass($this->behavior->getParameter('archive_class')); } else { - $this->builder->declareClassFromBuilder( - $builder->getNewStubObjectBuilder($this->behavior->getArchiveTable()) - ); + $this->builder->declareClassFromBuilder($builder->getNewStubObjectBuilder($this->behavior->getArchiveTable())); } $script = ''; @@ -203,12 +217,11 @@ public function fakeAutoIncrementPrimaryKeyForConcreteInheritance() $tableName = $database->getTablePrefix() . $concrete_inheritance_behavior->getParameter('extends'); if ($database->getPlatform()->supportsSchemas() && $concrete_inheritance_behavior->getParameter('schema')) { - $tableName = $concrete_inheritance_behavior->getParameter('schema').'.'.$tableName; + $tableName = $concrete_inheritance_behavior->getParameter('schema') . '.' . $tableName; } - if (( $parent_table = $database->getTable($tableName) )) { - return $parent_table->hasBehavior('archivable') - && $parent_table->hasAutoIncrementPrimaryKey(); + if (($parent_table = $database->getTable($tableName))) { + return $parent_table->hasBehavior('archivable') && $parent_table->hasAutoIncrementPrimaryKey(); } } diff --git a/generator/lib/behavior/archivable/ArchivableBehaviorQueryBuilderModifier.php b/generator/lib/behavior/archivable/ArchivableBehaviorQueryBuilderModifier.php index da0a7e671..904163ee9 100644 --- a/generator/lib/behavior/archivable/ArchivableBehaviorQueryBuilderModifier.php +++ b/generator/lib/behavior/archivable/ArchivableBehaviorQueryBuilderModifier.php @@ -18,7 +18,7 @@ class ArchivableBehaviorQueryBuilderModifier { protected $behavior, $table; - public function __construct($behavior) + public function __construct(ArchivableBehavior $behavior) { $this->behavior = $behavior; $this->table = $behavior->getTable(); @@ -29,7 +29,14 @@ protected function getParameter($key) return $this->behavior->getParameter($key); } - public function queryAttributes($builder) + /** + * Add attributes to the + * + * @param QueryBuilder $builder + * + * @return string + */ + public function queryAttributes(QueryBuilder $builder) { $script = ''; if ($this->behavior->isArchiveOnUpdate()) { @@ -44,7 +51,7 @@ public function queryAttributes($builder) return $script; } - public function preDeleteQuery($builder) + public function preDeleteQuery(QueryBuilder $builder) { if ($this->behavior->isArchiveOnDelete()) { return " @@ -55,9 +62,16 @@ public function preDeleteQuery($builder) } "; } + + return ''; } - public function postUpdateQuery($builder) + /** + * @param QueryBuilder $builder + * + * @return string + */ + public function postUpdateQuery(QueryBuilder $builder) { if ($this->behavior->isArchiveOnUpdate()) { return " @@ -68,12 +82,16 @@ public function postUpdateQuery($builder) } "; } + + return ''; } /** + * @param QueryBuilder $builder + * * @return string the PHP code to be added to the builder */ - public function queryMethods($builder) + public function queryMethods(QueryBuilder $builder) { $script = ''; $script .= $this->addArchive($builder); @@ -92,7 +110,7 @@ public function queryMethods($builder) /** * @return string the PHP code to be added to the builder */ - protected function addArchive($builder) + protected function addArchive(QueryBuilder $builder) { return $this->behavior->renderTemplate('queryArchive', array( 'archiveTablePhpName' => $this->behavior->getArchiveTablePhpName($builder), @@ -103,7 +121,7 @@ protected function addArchive($builder) /** * @return string the PHP code to be added to the builder */ - public function addSetArchiveOnUpdate($builder) + public function addSetArchiveOnUpdate(QueryBuilder $builder) { return $this->behavior->renderTemplate('querySetArchiveOnUpdate'); } @@ -111,7 +129,7 @@ public function addSetArchiveOnUpdate($builder) /** * @return string the PHP code to be added to the builder */ - public function addUpdateWithoutArchive($builder) + public function addUpdateWithoutArchive(QueryBuilder $builder) { return $this->behavior->renderTemplate('queryUpdateWithoutArchive'); } @@ -119,7 +137,7 @@ public function addUpdateWithoutArchive($builder) /** * @return string the PHP code to be added to the builder */ - public function addSetArchiveOnDelete($builder) + public function addSetArchiveOnDelete(QueryBuilder $builder) { return $this->behavior->renderTemplate('querySetArchiveOnDelete'); } @@ -127,7 +145,7 @@ public function addSetArchiveOnDelete($builder) /** * @return string the PHP code to be added to the builder */ - public function addDeleteWithoutArchive($builder) + public function addDeleteWithoutArchive(QueryBuilder $builder) { return $this->behavior->renderTemplate('queryDeleteWithoutArchive'); } diff --git a/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceBehavior.php b/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceBehavior.php index f220f243b..c8266d144 100644 --- a/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceBehavior.php +++ b/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceBehavior.php @@ -111,7 +111,6 @@ public function modifyTable() $copiedBehavior->setTableModified(false); $this->getTable()->addBehavior($copiedBehavior); } - } protected function getParentTable() @@ -119,7 +118,7 @@ protected function getParentTable() $database = $this->getTable()->getDatabase(); $tableName = $database->getTablePrefix() . $this->getParameter('extends'); if ($database->getPlatform()->supportsSchemas() && $this->getParameter('schema')) { - $tableName = $this->getParameter('schema').'.'.$tableName; + $tableName = $this->getParameter('schema') . '.' . $tableName; } return $database->getTable($tableName); @@ -204,7 +203,7 @@ public function getParentOrCreate(\$con = null) if (\$this->isNew()) { if (\$this->isPrimaryKeyNull()) { //this prevent issue with deep copy & save parent object - if (null === (\$parent = \$this->get". $parentClass . "(\$con))) { + if (null === (\$parent = \$this->get" . $parentClass . "(\$con))) { \$parent = new " . $parentClass . "(); } \$parent->set" . $this->getParentTable()->getColumn($this->getParameter('descendant_column'))->getPhpName() . "('" . $this->builder->getStubObjectBuilder()->getFullyQualifiedClassname() . "'); @@ -266,5 +265,4 @@ public function getSyncParent(\$con = null) } "; } - } diff --git a/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceParentBehavior.php b/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceParentBehavior.php index ca23fb712..f019ea16b 100644 --- a/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceParentBehavior.php +++ b/generator/lib/behavior/concrete_inheritance/ConcreteInheritanceParentBehavior.php @@ -86,5 +86,4 @@ public function getChildObject() } "; } - } diff --git a/generator/lib/behavior/i18n/I18nBehavior.php b/generator/lib/behavior/i18n/I18nBehavior.php index a749422ea..21adb0a6d 100644 --- a/generator/lib/behavior/i18n/I18nBehavior.php +++ b/generator/lib/behavior/i18n/I18nBehavior.php @@ -227,7 +227,7 @@ public function getI18nColumns() if ($columnNames = $this->getI18nColumnNamesFromConfig()) { // Strategy 1: use the i18n_columns parameter foreach ($columnNames as $columnName) { - $columns []= $i18nTable->getColumn($columnName); + $columns[] = $i18nTable->getColumn($columnName); } } else { // strategy 2: use the columns of the i18n table @@ -235,7 +235,7 @@ public function getI18nColumns() // (such as timestampable behavior) foreach ($i18nTable->getColumns() as $column) { if (!$column->isPrimaryKey()) { - $columns []= $column; + $columns[] = $column; } } } @@ -279,5 +279,4 @@ public function getPeerBuilderModifier() return $this->peerBuilderModifier; } - } diff --git a/generator/lib/behavior/i18n/I18nBehaviorObjectBuilderModifier.php b/generator/lib/behavior/i18n/I18nBehaviorObjectBuilderModifier.php index eeb440977..0b3d3a7f8 100644 --- a/generator/lib/behavior/i18n/I18nBehaviorObjectBuilderModifier.php +++ b/generator/lib/behavior/i18n/I18nBehaviorObjectBuilderModifier.php @@ -209,5 +209,4 @@ public function objectFilter(&$script, $builder) $replacement = "\$0$addition"; $script = preg_replace($pattern, $replacement, $script); } - } diff --git a/generator/lib/behavior/nestedset/NestedSetBehaviorObjectBuilderModifier.php b/generator/lib/behavior/nestedset/NestedSetBehaviorObjectBuilderModifier.php index f7551660a..c4ce5d977 100644 --- a/generator/lib/behavior/nestedset/NestedSetBehaviorObjectBuilderModifier.php +++ b/generator/lib/behavior/nestedset/NestedSetBehaviorObjectBuilderModifier.php @@ -45,8 +45,8 @@ protected function setBuilder($builder) $this->builder = $builder; $this->objectClassname = $builder->getStubObjectBuilder()->getClassname(); - $this->queryClassname = $builder->getStubQueryBuilder()->getClassname(); - $this->peerClassname = $builder->getStubPeerBuilder()->getClassname(); + $this->queryClassname = $builder->getStubQueryBuilder()->getClassname(); + $this->peerClassname = $builder->getStubPeerBuilder()->getClassname(); $this->builder->declareClass($builder->getStubObjectBuilder()->getFullyQualifiedClassname()); $this->builder->declareClass($builder->getStubQueryBuilder()->getFullyQualifiedClassname()); @@ -159,8 +159,7 @@ public function objectMethods($builder) if ($this->getColumnPhpName('level_column') != 'Level') { $this->addGetLevel($script); } - if ($this->getParameter('use_scope') == 'true' - && $this->getColumnPhpName('scope_column') != 'ScopeValue') { + if ($this->getParameter('use_scope') == 'true' && $this->getColumnPhpName('scope_column') != 'ScopeValue') { $this->addGetScope($script); } @@ -173,8 +172,7 @@ public function objectMethods($builder) if ($this->getColumnPhpName('level_column') != 'Level') { $this->addSetLevel($script); } - if ($this->getParameter('use_scope') == 'true' - && $this->getColumnPhpName('scope_column') != 'ScopeValue') { + if ($this->getParameter('use_scope') == 'true' && $this->getColumnPhpName('scope_column') != 'ScopeValue') { $this->addSetScope($script); } @@ -250,6 +248,7 @@ protected function processNestedSetQueries(\$con) } "; } + protected function addGetLeft(&$script) { $script .= " @@ -1389,7 +1388,6 @@ protected function moveSubtreeTo(\$destLeft, \$levelDelta" . ($this->behavior->u \$preventDefault = true; } "; - } $script .= " diff --git a/generator/lib/behavior/nestedset/NestedSetBehaviorPeerBuilderModifier.php b/generator/lib/behavior/nestedset/NestedSetBehaviorPeerBuilderModifier.php index 2d1575f92..75d9d5b90 100644 --- a/generator/lib/behavior/nestedset/NestedSetBehaviorPeerBuilderModifier.php +++ b/generator/lib/behavior/nestedset/NestedSetBehaviorPeerBuilderModifier.php @@ -79,7 +79,7 @@ public function staticAttributes($builder) "; if ($this->behavior->useScope()) { - $script .= " + $script .= " /** * Scope column for the set */ @@ -299,7 +299,7 @@ protected function addShiftRLValues(&$script) $script .= " * @param PropelPDO \$con Connection to use. */ -public static function shiftRLValues(\$delta, \$first, \$last = null" . ($useScope ? ", \$scope = null" : ""). ", PropelPDO \$con = null) +public static function shiftRLValues(\$delta, \$first, \$last = null" . ($useScope ? ", \$scope = null" : "") . ", PropelPDO \$con = null) { if (\$con === null) { \$con = Propel::getConnection($peerClassname::DATABASE_NAME, Propel::CONNECTION_WRITE); @@ -363,7 +363,7 @@ protected function addShiftLevel(&$script) $script .= " * @param PropelPDO \$con Connection to use. */ -public static function shiftLevel(\$delta, \$first, \$last" . ($useScope ? ", \$scope = null" : ""). ", PropelPDO \$con = null) +public static function shiftLevel(\$delta, \$first, \$last" . ($useScope ? ", \$scope = null" : "") . ", PropelPDO \$con = null) { if (\$con === null) { \$con = Propel::getConnection($peerClassname::DATABASE_NAME, Propel::CONNECTION_WRITE); @@ -415,7 +415,7 @@ public static function updateLoadedNodes(\$prune = null, PropelPDO \$con = null) $pkey = $this->table->getPrimaryKey(); $col = array_shift($pkey); $script .= " - \$criteria->add(".$this->builder->getColumnConstant($col).", \$keys, Criteria::IN);"; + \$criteria->add(" . $this->builder->getColumnConstant($col) . ", \$keys, Criteria::IN);"; } else { $fields = array(); foreach ($this->table->getPrimaryKey() as $k => $col) { @@ -450,7 +450,9 @@ public static function updateLoadedNodes(\$prune = null, PropelPDO \$con = null) if (null !== (\$object = $peerClassname::getInstanceFromPool(\$key))) {"; $n = 0; foreach ($this->table->getColumns() as $col) { - if ($col->isLazyLoad()) continue; + if ($col->isLazyLoad()) { + continue; + } if ($col->getPhpName() == $this->getColumnPhpName('left_column')) { $script .= " \$object->setLeftValue(\$row[$n]);"; @@ -494,7 +496,7 @@ protected function addMakeRoomForLeaf(&$script) * @param mixed \$prune Object to prune from the shift * @param PropelPDO \$con Connection to use. */ -public static function makeRoomForLeaf(\$left" . ($useScope ? ", \$scope" : ""). ", \$prune = null, PropelPDO \$con = null) +public static function makeRoomForLeaf(\$left" . ($useScope ? ", \$scope" : "") . ", \$prune = null, PropelPDO \$con = null) { // Update database nodes $peerClassname::shiftRLValues(2, \$left, null" . ($useScope ? ", \$scope" : "") . ", \$con); @@ -520,7 +522,7 @@ protected function addFixLevels(&$script) $script .= " * @param PropelPDO \$con Connection to use. */ -public static function fixLevels(" . ($useScope ? "\$scope, " : ""). "PropelPDO \$con = null) +public static function fixLevels(" . ($useScope ? "\$scope, " : "") . "PropelPDO \$con = null) { \$c = new Criteria();"; if ($useScope) { diff --git a/generator/lib/behavior/nestedset/NestedSetBehaviorQueryBuilderModifier.php b/generator/lib/behavior/nestedset/NestedSetBehaviorQueryBuilderModifier.php index e87900e1d..ea6c3861c 100644 --- a/generator/lib/behavior/nestedset/NestedSetBehaviorQueryBuilderModifier.php +++ b/generator/lib/behavior/nestedset/NestedSetBehaviorQueryBuilderModifier.php @@ -303,12 +303,12 @@ protected function addFindRoot(&$script) $useScope = $this->behavior->useScope(); $script .= " /** - * Returns " . ($useScope ? 'a' : 'the') ." root node for the tree + * Returns " . ($useScope ? 'a' : 'the') . " root node for the tree *"; - if ($useScope) { - $script .= " + if ($useScope) { + $script .= " * @param int \$scope Scope to determine which root node to return"; - } + } $script .= " * @param PropelPDO \$con Connection to use. * @@ -352,12 +352,12 @@ protected function addFindTree(&$script) $useScope = $this->behavior->useScope(); $script .= " /** - * Returns " . ($useScope ? 'a' : 'the') ." tree of objects + * Returns " . ($useScope ? 'a' : 'the') . " tree of objects *"; - if ($useScope) { - $script .= " + if ($useScope) { + $script .= " * @param int \$scope Scope to determine which tree node to return"; - } + } $script .= " * @param PropelPDO \$con Connection to use. * diff --git a/generator/lib/behavior/query_cache/QueryCacheBehavior.php b/generator/lib/behavior/query_cache/QueryCacheBehavior.php index 8ac787a09..e504570ec 100644 --- a/generator/lib/behavior/query_cache/QueryCacheBehavior.php +++ b/generator/lib/behavior/query_cache/QueryCacheBehavior.php @@ -103,7 +103,6 @@ public function cacheContains(\$key) $script .= " throw new PropelException('You must override the cacheContains(), cacheStore(), and cacheFetch() methods to enable query cache');"; break; - } $script .= " } @@ -113,7 +112,7 @@ public function cacheContains(\$key) protected function addCacheStore(&$script) { $script .= " -public function cacheStore(\$key, \$value, \$lifetime = " .$this->getParameter('lifetime') . ") +public function cacheStore(\$key, \$value, \$lifetime = " . $this->getParameter('lifetime') . ") {"; switch ($this->getParameter('backend')) { case 'apc': @@ -173,8 +172,8 @@ protected function doSelect(\$con) } \$this->configureSelectColumns(); - \$dbMap = Propel::getDatabaseMap(" . $this->peerClassname ."::DATABASE_NAME); - \$db = Propel::getDB(" . $this->peerClassname ."::DATABASE_NAME); + \$dbMap = Propel::getDatabaseMap(" . $this->peerClassname . "::DATABASE_NAME); + \$db = Propel::getDB(" . $this->peerClassname . "::DATABASE_NAME); \$key = \$this->getQueryKey(); if (\$key && \$this->cacheContains(\$key)) { @@ -262,5 +261,4 @@ protected function doCount(\$con) } "; } - } diff --git a/generator/lib/behavior/sluggable/SluggableBehavior.php b/generator/lib/behavior/sluggable/SluggableBehavior.php index f0383312a..7d18021b6 100644 --- a/generator/lib/behavior/sluggable/SluggableBehavior.php +++ b/generator/lib/behavior/sluggable/SluggableBehavior.php @@ -77,7 +77,7 @@ protected function getColumnSetter() * * @return string The code to put at the hook */ - public function preSave($builder) + public function preSave(PHP5ObjectBuilder $builder) { $const = $builder->getColumnConstant($this->getColumnForParameter('slug_column')); $pattern = $this->getParameter('slug_pattern'); @@ -104,22 +104,22 @@ public function preSave($builder) \$this->{$this->getColumnSetter()}(\$this->createSlug());"; } - if (null == $pattern && false === $this->booleanValue($this->getParameter('permanent'))) { - $script .= " + if (null == $pattern && false === $this->booleanValue($this->getParameter('permanent'))) { + $script .= " } else { \$this->{$this->getColumnSetter()}(\$this->createSlug()); }"; - } else { - $script .= " + } else { + $script .= " } elseif (!\$this->{$this->getColumnGetter()}()) { \$this->{$this->getColumnSetter()}(\$this->createSlug()); }"; - } + } return $script; } - public function objectMethods($builder) + public function objectMethods(PHP5ObjectBuilder $builder) { $this->builder = $builder; $script = ''; @@ -201,7 +201,7 @@ protected function createRawSlug() { "; if ($pattern) { - $script .= "return '" . str_replace(array('{', '}'), array('\' . $this->cleanupSlugPart($this->get', '()) . \''), $pattern). "';"; + $script .= "return '" . str_replace(array('{', '}'), array('\' . $this->cleanupSlugPart($this->get', '()) . \''), $pattern) . "';"; } else { $script .= "return \$this->cleanupSlugPart(\$this->__toString());"; } @@ -292,10 +292,10 @@ public function addMakeSlugUnique(&$script) * @param int \$alreadyExists false for the first try, true for the second, and take the high count + 1 * @return string the unique slug */ -protected function makeSlugUnique(\$slug, \$separator = '" . $this->getParameter('separator') ."', \$alreadyExists = false) +protected function makeSlugUnique(\$slug, \$separator = '" . $this->getParameter('separator') . "', \$alreadyExists = false) {"; - $getter = $this->getColumnGetter(); - $script .= " + $getter = $this->getColumnGetter(); + $script .= " if (!\$alreadyExists) { \$slug2 = \$slug; } else { @@ -323,7 +323,7 @@ protected function makeSlugUnique(\$slug, \$separator = '" . $this->getParameter if ($this->getParameter('scope_column')) { $getter = 'get' . $this->getColumnForParameter('scope_column')->getPhpName(); - $script .=" + $script .= " ->filterBy('{$this->getColumnForParameter('scope_column')->getPhpName()}', \$this->{$getter}())"; } // watch out: some of the columns may be hidden by the soft_delete behavior @@ -364,7 +364,7 @@ protected function makeSlugUnique(\$slug, \$separator = '" . $this->getParameter "; } - public function queryMethods($builder) + public function queryMethods(QueryBuilder $builder) { $this->builder = $builder; $script = ''; diff --git a/generator/lib/behavior/sortable/SortableBehavior.php b/generator/lib/behavior/sortable/SortableBehavior.php index ce1f8fcb0..358fbe584 100644 --- a/generator/lib/behavior/sortable/SortableBehavior.php +++ b/generator/lib/behavior/sortable/SortableBehavior.php @@ -46,8 +46,7 @@ public function modifyTable() 'type' => 'INTEGER' )); } - if ($this->useScope() && - !$table->containsColumn($this->getParameter('scope_column'))) { + if ($this->useScope() && !$table->containsColumn($this->getParameter('scope_column'))) { $table->addColumn(array( 'name' => $this->getParameter('scope_column'), 'type' => 'INTEGER' @@ -100,5 +99,4 @@ public function useScope() { return $this->getParameter('use_scope') == 'true'; } - } diff --git a/generator/lib/behavior/sortable/SortableBehaviorObjectBuilderModifier.php b/generator/lib/behavior/sortable/SortableBehaviorObjectBuilderModifier.php index 21b21c1c1..9a4b52968 100644 --- a/generator/lib/behavior/sortable/SortableBehaviorObjectBuilderModifier.php +++ b/generator/lib/behavior/sortable/SortableBehaviorObjectBuilderModifier.php @@ -20,7 +20,7 @@ class SortableBehaviorObjectBuilderModifier { protected $behavior, $table, $builder, $objectClassname, $peerClassname; - public function __construct($behavior) + public function __construct(SortableBehavior $behavior) { $this->behavior = $behavior; $this->table = $behavior->getTable(); @@ -41,7 +41,7 @@ protected function getColumnPhpName($name) return $this->behavior->getColumnForParameter($name)->getPhpName(); } - protected function setBuilder($builder) + protected function setBuilder(PHP5ObjectBuilder $builder) { $this->builder = $builder; $this->objectClassname = $builder->getStubObjectBuilder()->getClassname(); @@ -52,6 +52,8 @@ protected function setBuilder($builder) /** * Get the getter of the column of the behavior * + * @param string $columnName + * * @return string The related getter, e.g. 'getRank' */ protected function getColumnGetter($columnName = 'rank_column') @@ -62,6 +64,8 @@ protected function getColumnGetter($columnName = 'rank_column') /** * Get the setter of the column of the behavior * + * @param string $columnName + * * @return string The related setter, e.g. 'setRank' */ protected function getColumnSetter($columnName = 'rank_column') @@ -88,9 +92,9 @@ public function preInsert($builder) public function preUpdate($builder) { if ($this->behavior->useScope()) { - $this->setBuilder($builder); + $this->setBuilder($builder); - return "// if scope has changed and rank was not modified (if yes, assuming superior action) + return "// if scope has changed and rank was not modified (if yes, assuming superior action) // insert object to the end of new scope and cleanup old one if (\$this->isColumnModified({$this->peerClassname}::SCOPE_COL) && !\$this->isColumnModified({$this->peerClassname}::RANK_COL)) { {$this->peerClassname}::shiftRank(-1, \$this->{$this->getColumnGetter()}() + 1, null, \$this->oldScope, \$con); \$this->insertAtBottom(\$con); @@ -119,8 +123,8 @@ public function objectAttributes($builder) */ protected \$sortableQueries = array(); "; - if ($this->behavior->useScope()) { - $script .= " + if ($this->behavior->useScope()) { + $script .= " /** * The old scope value. * @var int @@ -139,8 +143,7 @@ public function objectMethods($builder) if ($this->getParameter('rank_column') != 'rank') { $this->addRankAccessors($script); } - if ($this->behavior->useScope() && - $this->getParameter('scope_column') != 'scope_value') { + if ($this->behavior->useScope() && $this->getParameter('scope_column') != 'scope_value') { $this->addScopeAccessors($script); } $this->addIsFirst($script); @@ -492,7 +495,7 @@ public function swapWith(\$object, PropelPDO \$con = null) \$object->{$this->getColumnSetter('scope_column')}(\$oldScope); }"; } -$script .= " + $script .= " \$oldRank = \$this->{$this->getColumnGetter()}(); \$newRank = \$object->{$this->getColumnGetter()}(); \$this->{$this->getColumnSetter()}(\$newRank); @@ -636,7 +639,7 @@ protected function addRemoveFromList(&$script) $useScope = $this->behavior->useScope(); $script .= " /** - * Removes the current object from the list".($useScope ? ' (moves it to the null scope)' : '').". + * Removes the current object from the list" . ($useScope ? ' (moves it to the null scope)' : '') . ". * The modifications are not persisted until the object is saved. * * @param PropelPDO \$con optional connection @@ -646,7 +649,7 @@ protected function addRemoveFromList(&$script) public function removeFromList(PropelPDO \$con = null) {"; if ($useScope) { - $script .= " + $script .= " // check if object is already removed if (\$this->{$this->getColumnGetter('scope_column')}() === null) { throw new PropelException('Object is already removed (has null scope)'); @@ -656,7 +659,7 @@ public function removeFromList(PropelPDO \$con = null) \$this->{$this->getColumnSetter('scope_column')}(null); // \$this->insertAtBottom(\$con);"; } else { - $script .= " + $script .= " // Keep the list modification query for the save() transaction \$this->sortableQueries []= array( 'callable' => array(self::PEER, 'shiftRank'), diff --git a/generator/lib/behavior/sortable/SortableBehaviorPeerBuilderModifier.php b/generator/lib/behavior/sortable/SortableBehaviorPeerBuilderModifier.php index cf33d0880..38a4c8dd8 100644 --- a/generator/lib/behavior/sortable/SortableBehaviorPeerBuilderModifier.php +++ b/generator/lib/behavior/sortable/SortableBehaviorPeerBuilderModifier.php @@ -50,8 +50,8 @@ protected function setBuilder($builder) { $this->builder = $builder; $this->objectClassname = $builder->getStubObjectBuilder()->getClassname(); - $this->peerClassname = $builder->getStubPeerBuilder()->getClassname(); - $this->queryClassname = $builder->getStubQueryBuilder()->getClassname(); + $this->peerClassname = $builder->getStubPeerBuilder()->getClassname(); + $this->queryClassname = $builder->getStubQueryBuilder()->getClassname(); $builder->declareClassFromBuilder($builder->getStubObjectBuilder()); $builder->declareClassFromBuilder($builder->getStubQueryBuilder()); @@ -68,7 +68,7 @@ public function staticAttributes($builder) "; if ($this->behavior->useScope()) { - $script .= " + $script .= " /** * Scope column for the set */ @@ -128,7 +128,7 @@ public static function getMaxRank(" . ($useScope ? "\$scope = null, " : "") . "P \$c = new Criteria(); \$c->addSelectColumn('MAX(' . {$this->peerClassname}::RANK_COL . ')');"; if ($useScope) { - $script .= " + $script .= " \$c->add({$this->peerClassname}::SCOPE_COL, \$scope, Criteria::EQUAL);"; } $script .= " @@ -324,6 +324,7 @@ public static function deleteList(\$scope, PropelPDO \$con = null) } "; } + protected function addShiftRank(&$script) { $useScope = $this->behavior->useScope(); diff --git a/generator/lib/behavior/sortable/SortableBehaviorQueryBuilderModifier.php b/generator/lib/behavior/sortable/SortableBehaviorQueryBuilderModifier.php index e01321934..22b24276a 100644 --- a/generator/lib/behavior/sortable/SortableBehaviorQueryBuilderModifier.php +++ b/generator/lib/behavior/sortable/SortableBehaviorQueryBuilderModifier.php @@ -176,12 +176,12 @@ protected function addFindList(&$script) $useScope = $this->behavior->useScope(); $script .= " /** - * Returns " . ($useScope ? 'a' : 'the') ." list of objects + * Returns " . ($useScope ? 'a' : 'the') . " list of objects *"; - if ($useScope) { - $script .= " + if ($useScope) { + $script .= " * @param int \$scope Scope to determine which list to return"; - } + } $script .= " * @param PropelPDO \$con Connection to use. * @@ -226,7 +226,7 @@ public function getMaxRank(" . ($useScope ? "\$scope = null, " : "") . "PropelPD // shift the objects with a position lower than the one of object \$this->addSelectColumn('MAX(' . {$this->peerClassname}::RANK_COL . ')');"; if ($useScope) { - $script .= " + $script .= " \$this->add({$this->peerClassname}::SCOPE_COL, \$scope, Criteria::EQUAL);"; } $script .= " @@ -281,5 +281,4 @@ public function reorder(array \$order, PropelPDO \$con = null) } "; } - } diff --git a/generator/lib/behavior/sortable/SortableRelationBehavior.php b/generator/lib/behavior/sortable/SortableRelationBehavior.php index 60b2d9904..fd00a9e80 100644 --- a/generator/lib/behavior/sortable/SortableRelationBehavior.php +++ b/generator/lib/behavior/sortable/SortableRelationBehavior.php @@ -87,5 +87,4 @@ public function {$this->getObjectMoveRelatedToNullScopeMethodName()}(PropelPDO \ return $script; } - } diff --git a/generator/lib/behavior/versionable/VersionableBehavior.php b/generator/lib/behavior/versionable/VersionableBehavior.php index 69997bc93..7751e941d 100644 --- a/generator/lib/behavior/versionable/VersionableBehavior.php +++ b/generator/lib/behavior/versionable/VersionableBehavior.php @@ -16,8 +16,8 @@ * Keeps tracks of all the modifications in an ActiveRecord object * * @author Francois Zaninotto - * @version $Revision$ - * @package propel.generator.behavior.versionable + * @version $Revision$ + * @package propel.generator.behavior.versionable */ class VersionableBehavior extends Behavior { @@ -38,10 +38,7 @@ class VersionableBehavior extends Behavior */ protected $versionTable; - protected - $objectBuilderModifier, - $queryBuilderModifier, - $peerBuilderModifier; + protected $objectBuilderModifier, $queryBuilderModifier, $peerBuilderModifier; protected $tableModificationOrder = 80; @@ -86,19 +83,12 @@ protected function addLogColumns() { $table = $this->getTable(); if ($this->getParameter('log_created_at') == 'true' && !$table->hasColumn($this->getParameter('version_created_at_column'))) { - $table->addColumn(array( - 'name' => $this->getParameter('version_created_at_column'), - 'type' => 'TIMESTAMP' - )); + $table->addColumn(array('name' => $this->getParameter('version_created_at_column'), 'type' => 'TIMESTAMP')); } if ($this->getParameter('log_created_by') == 'true' && !$table->hasColumn($this->getParameter('version_created_by_column'))) { - $table->addColumn(array( - 'name' => $this->getParameter('version_created_by_column'), - 'type' => 'VARCHAR', - 'size' => 100 - )); + $table->addColumn(array('name' => $this->getParameter('version_created_by_column'), 'type' => 'VARCHAR', 'size' => 100)); } - if ($this->getParameter('log_comment') == 'true' && !$table->hasColumn($this->getParameter('version_comment_column'))) { + if ($this->getParameter('log_comment') == 'true' && !$table->hasColumn($this->getParameter('version_comment_column'))) { $table->addColumn(array( 'name' => $this->getParameter('version_comment_column'), 'type' => 'VARCHAR', @@ -218,8 +208,8 @@ public function getVersionableFks() $versionableFKs = array(); if ($fks = $this->getTable()->getForeignKeys()) { foreach ($fks as $fk) { - if ($fk->getForeignTable()->hasBehavior($this->getName()) && ! $fk->isComposite()) { - $versionableFKs []= $fk; + if ($fk->getForeignTable()->hasBehavior($this->getName()) && !$fk->isComposite()) { + $versionableFKs[] = $fk; } } } @@ -235,8 +225,8 @@ public function getVersionableReferrers() $versionableReferrers = array(); if ($fks = $this->getTable()->getReferrers()) { foreach ($fks as $fk) { - if ($fk->getTable()->hasBehavior($this->getName()) && ! $fk->isComposite()) { - $versionableReferrers []= $fk; + if ($fk->getTable()->hasBehavior($this->getName()) && !$fk->isComposite()) { + $versionableReferrers[] = $fk; } } } @@ -296,5 +286,4 @@ public function getPeerBuilderModifier() return $this->peerBuilderModifier; } - } diff --git a/generator/lib/behavior/versionable/VersionableBehaviorObjectBuilderModifier.php b/generator/lib/behavior/versionable/VersionableBehaviorObjectBuilderModifier.php index fdfce1163..a87211935 100644 --- a/generator/lib/behavior/versionable/VersionableBehaviorObjectBuilderModifier.php +++ b/generator/lib/behavior/versionable/VersionableBehaviorObjectBuilderModifier.php @@ -67,7 +67,7 @@ protected function getActiveRecordClassName() return $this->builder->getStubObjectBuilder()->getClassname(); } - protected function setBuilder($builder) + protected function setBuilder(PHP5ObjectBuilder $builder) { $this->builder = $builder; $this->objectClassname = $builder->getStubObjectBuilder()->getClassname(); @@ -78,6 +78,8 @@ protected function setBuilder($builder) /** * Get the getter of the column of the behavior * + * @param string $name + * * @return string The related getter, e.g. 'getVersion' */ protected function getColumnGetter($name = 'version_column') @@ -88,6 +90,8 @@ protected function getColumnGetter($name = 'version_column') /** * Get the setter of the column of the behavior * + * @param string $name + * * @return string The related setter, e.g. 'setVersion' */ protected function getColumnSetter($name = 'version_column') @@ -95,7 +99,7 @@ protected function getColumnSetter($name = 'version_column') return 'set' . $this->getColumnPhpName($name); } - public function preSave($builder) + public function preSave(PHP5ObjectBuilder $builder) { $script = "if (\$this->isVersioningNecessary()) { \$this->set{$this->getColumnPhpName()}(\$this->isNew() ? 1 : \$this->getLastVersionNumber(\$con) + 1);"; @@ -122,14 +126,14 @@ public function preSave($builder) return $script; } - public function postSave($builder) + public function postSave(PHP5ObjectBuilder $builder) { return "if (isset(\$createVersion)) { \$this->addVersion(\$con); }"; } - public function postDelete($builder) + public function postDelete(PHP5ObjectBuilder $builder) { $this->builder = $builder; if (!$builder->getPlatform()->supportsNativeDeleteTrigger() && !$builder->getBuildProperty('emulateForeignKeyConstraints')) { @@ -142,7 +146,7 @@ public function postDelete($builder) } } - public function objectAttributes($builder) + public function objectAttributes(PHP5ObjectBuilder $builder) { $script = ''; @@ -162,7 +166,7 @@ protected function addEnforceVersionAttribute(&$script) "; } - public function objectMethods($builder) + public function objectMethods(PHP5ObjectBuilder $builder) { $this->setBuilder($builder); $script = ''; @@ -368,7 +372,7 @@ public function addVersion(\$con = null) } } - $script .= " + $script .= " \$version->save(\$con); return \$version; @@ -696,7 +700,7 @@ protected function computeDiff(\$fromVersion, \$toVersion, \$keys = 'columns', \ return \$diff; } "; - } + } protected function addCompareVersion(&$script) { @@ -726,7 +730,7 @@ public function compareVersion(\$versionNumber, \$keys = 'columns', \$con = null return \$this->computeDiff(\$fromVersion, \$toVersion, \$keys, \$ignoredColumns); } "; - } + } protected function addCompareVersions(&$script) { @@ -766,7 +770,7 @@ protected function addGetLastVersions(&$script) $versionForeignColumn = $versionTable->getColumn($this->behavior->getParameter('version_column')); $fks = $versionTable->getForeignKeysReferencingTable($this->table->getName()); $relCol = $this->builder->getRefFKPhpNameAffix($fks[0], $plural = true); - $versionGetter = 'get'.$relCol; + $versionGetter = 'get' . $relCol; $versionPeerBuilder = $this->builder->getNewStubPeerBuilder($versionTable); $this->builder->declareClassFromBuilder($versionPeerBuilder); $versionPeer = $versionPeerBuilder->getClassname(); @@ -790,5 +794,5 @@ public function getLastVersions(\$number = 10, \$criteria = null, PropelPDO \$co return \$this->{$versionGetter}(\$criteria, \$con); } EOF; - } + } } diff --git a/generator/lib/behavior/versionable/VersionableBehaviorQueryBuilderModifier.php b/generator/lib/behavior/versionable/VersionableBehaviorQueryBuilderModifier.php index 520c23a53..39aecf3c8 100644 --- a/generator/lib/behavior/versionable/VersionableBehaviorQueryBuilderModifier.php +++ b/generator/lib/behavior/versionable/VersionableBehaviorQueryBuilderModifier.php @@ -55,6 +55,8 @@ protected function setBuilder($builder) /** * Get the getter of the column of the behavior * + * @param string $name + * * @return string The related getter, e.g. 'getVersion' */ protected function getColumnGetter($name = 'version_column') @@ -65,6 +67,8 @@ protected function getColumnGetter($name = 'version_column') /** * Get the setter of the column of the behavior * + * @param string $name + * * @return string The related setter, e.g. 'setVersion' */ protected function getColumnSetter($name = 'version_column') @@ -116,5 +120,4 @@ public function orderByVersion(\$order = Criteria::ASC) } "; } - } diff --git a/generator/lib/builder/DataModelBuilder.php b/generator/lib/builder/DataModelBuilder.php index 08f50a079..7e7083a1a 100644 --- a/generator/lib/builder/DataModelBuilder.php +++ b/generator/lib/builder/DataModelBuilder.php @@ -27,6 +27,7 @@ abstract class DataModelBuilder /** * The current table. + * * @var Table */ private $table; @@ -40,120 +41,140 @@ abstract class DataModelBuilder /** * An array of warning messages that can be retrieved for display (e.g. as part of phing build process). + * * @var array string[] */ private $warnings = array(); /** * Peer builder class for current table. + * * @var DataModelBuilder */ private $peerBuilder; /** * Stub Peer builder class for current table. + * * @var DataModelBuilder */ private $stubPeerBuilder; /** * Object builder class for current table. + * * @var DataModelBuilder */ private $objectBuilder; /** * Stub Object builder class for current table. + * * @var DataModelBuilder */ private $stubObjectBuilder; /** * Query builder class for current table. + * * @var DataModelBuilder */ private $queryBuilder; /** * Stub Query builder class for current table. + * * @var DataModelBuilder */ private $stubQueryBuilder; /** * TableMap builder class for current table. + * * @var DataModelBuilder */ protected $tablemapBuilder; /** * Stub Interface builder class for current table. + * * @var DataModelBuilder */ private $interfaceBuilder; /** * Stub child object for current table. + * * @var DataModelBuilder */ private $multiExtendObjectBuilder; /** * Node object builder for current table. + * * @var DataModelBuilder */ private $nodeBuilder; /** * Node peer builder for current table. + * * @var DataModelBuilder */ private $nodePeerBuilder; /** * Stub node object builder for current table. + * * @var DataModelBuilder */ private $stubNodeBuilder; /** * Stub node peer builder for current table. + * * @var DataModelBuilder */ private $stubNodePeerBuilder; /** * NestedSet object builder for current table. + * * @var DataModelBuilder */ private $nestedSetBuilder; /** * NestedSet peer builder for current table. + * * @var DataModelBuilder */ private $nestedSetPeerBuilder; /** * The Data-SQL builder for current table. + * * @var DataSQLBuilder */ private $dataSqlBuilder; /** * The Pluralizer class to use. + * * @var Pluralizer */ private $pluralizer; /** * The platform class - * @var PropelPlatformInterface + * + * @var PropelPlatformInterface */ protected $platform; /** * Creates new instance of DataModelBuilder subclass. + * * @param Table $table The Table which we are using to build [OM, DDL, etc.]. */ public function __construct(Table $table) @@ -163,6 +184,7 @@ public function __construct(Table $table) /** * Returns new or existing Peer builder class for this table. + * * @return PeerBuilder */ public function getPeerBuilder() @@ -176,6 +198,7 @@ public function getPeerBuilder() /** * Returns new or existing Pluralizer class. + * * @return Pluralizer */ public function getPluralizer() @@ -189,6 +212,7 @@ public function getPluralizer() /** * Returns new or existing stub Peer builder class for this table. + * * @return PeerBuilder */ public function getStubPeerBuilder() @@ -202,6 +226,7 @@ public function getStubPeerBuilder() /** * Returns new or existing Object builder class for this table. + * * @return ObjectBuilder */ public function getObjectBuilder() @@ -215,6 +240,7 @@ public function getObjectBuilder() /** * Returns new or existing stub Object builder class for this table. + * * @return ObjectBuilder */ public function getStubObjectBuilder() @@ -228,6 +254,7 @@ public function getStubObjectBuilder() /** * Returns new or existing Query builder class for this table. + * * @return ObjectBuilder */ public function getQueryBuilder() @@ -241,6 +268,7 @@ public function getQueryBuilder() /** * Returns new or existing stub Query builder class for this table. + * * @return ObjectBuilder */ public function getStubQueryBuilder() @@ -254,6 +282,7 @@ public function getStubQueryBuilder() /** * Returns new or existing Object builder class for this table. + * * @return ObjectBuilder */ public function getTableMapBuilder() @@ -267,6 +296,7 @@ public function getTableMapBuilder() /** * Returns new or existing stub Interface builder class for this table. + * * @return ObjectBuilder */ public function getInterfaceBuilder() @@ -280,6 +310,7 @@ public function getInterfaceBuilder() /** * Returns new or existing stub child object builder class for this table. + * * @return ObjectBuilder */ public function getMultiExtendObjectBuilder() @@ -293,6 +324,7 @@ public function getMultiExtendObjectBuilder() /** * Returns new or existing node Object builder class for this table. + * * @return ObjectBuilder */ public function getNodeBuilder() @@ -306,6 +338,7 @@ public function getNodeBuilder() /** * Returns new or existing node Peer builder class for this table. + * * @return PeerBuilder */ public function getNodePeerBuilder() @@ -319,6 +352,7 @@ public function getNodePeerBuilder() /** * Returns new or existing stub node Object builder class for this table. + * * @return ObjectBuilder */ public function getStubNodeBuilder() @@ -332,6 +366,7 @@ public function getStubNodeBuilder() /** * Returns new or existing stub node Peer builder class for this table. + * * @return PeerBuilder */ public function getStubNodePeerBuilder() @@ -345,6 +380,7 @@ public function getStubNodePeerBuilder() /** * Returns new or existing nested set object builder class for this table. + * * @return ObjectBuilder */ public function getNestedSetBuilder() @@ -358,6 +394,7 @@ public function getNestedSetBuilder() /** * Returns new or existing nested set Peer builder class for this table. + * * @return PeerBuilder */ public function getNestedSetPeerBuilder() @@ -371,6 +408,7 @@ public function getNestedSetPeerBuilder() /** * Returns new or existing data sql builder class for this table. + * * @return DataSQLBuilder */ public function getDataSQLBuilder() @@ -382,13 +420,14 @@ public function getDataSQLBuilder() return $this->dataSqlBuilder; } - /** - * Gets a new data model builder class for specified table and classname. - * - * @param Table $table - * @param string $classname The class of builder - * @return DataModelBuilder - */ + /** + * Gets a new data model builder class for specified table and classname. + * + * @param Table $table + * @param string $classname The class of builder + * + * @return DataModelBuilder + */ public function getNewBuilder(Table $table, $classname) { $builder = new $classname($table); @@ -399,11 +438,12 @@ public function getNewBuilder(Table $table, $classname) /** * Convenience method to return a NEW Peer class builder instance. - * + * * This is used very frequently from the peer and object builders to get * a peer builder for a RELATED table. * * @param Table $table + * * @return PeerBuilder */ public function getNewPeerBuilder(Table $table) @@ -418,6 +458,7 @@ public function getNewPeerBuilder(Table $table) * a peer builder for a RELATED table. * * @param Table $table + * * @return PeerBuilder */ public function getNewStubPeerBuilder(Table $table) @@ -432,6 +473,7 @@ public function getNewStubPeerBuilder(Table $table) * an object builder for a RELATED table. * * @param Table $table + * * @return ObjectBuilder */ public function getNewObjectBuilder(Table $table) @@ -446,6 +488,7 @@ public function getNewObjectBuilder(Table $table) * an object builder for a RELATED table. * * @param Table $table + * * @return ObjectBuilder */ public function getNewStubObjectBuilder(Table $table) @@ -460,6 +503,7 @@ public function getNewStubObjectBuilder(Table $table) * a query builder for a RELATED table. * * @param Table $table + * * @return QueryBuilder */ public function getNewQueryBuilder(Table $table) @@ -474,6 +518,7 @@ public function getNewQueryBuilder(Table $table) * a query builder for a RELATED table. * * @param Table $table + * * @return QueryBuilder */ public function getNewStubQueryBuilder(Table $table) @@ -483,6 +528,7 @@ public function getNewStubQueryBuilder(Table $table) /** * Returns new Query Inheritance builder class for this table. + * * @return ObjectBuilder */ public function getNewQueryInheritanceBuilder($child) @@ -495,6 +541,7 @@ public function getNewQueryInheritanceBuilder($child) /** * Returns new stub Query Inheritance builder class for this table. + * * @return ObjectBuilder */ public function getNewStubQueryInheritanceBuilder($child) @@ -519,6 +566,7 @@ public function getGeneratorConfig() * Get a specific [name transformed] build property. * * @param string $name + * * @return string */ public function getBuildProperty($name) @@ -542,6 +590,7 @@ public function setGeneratorConfig(GeneratorConfigInterface $v) /** * Sets the table for this builder. + * * @param Table $table */ public function setTable(Table $table) @@ -551,6 +600,7 @@ public function setTable(Table $table) /** * Returns the current Table object. + * * @return Table */ public function getTable() @@ -560,6 +610,7 @@ public function getTable() /** * Convenience method to returns the Platform class for this table (database). + * * @return PropelPlatformInterface */ public function getPlatform() @@ -586,6 +637,7 @@ public function setPlatform(PropelPlatformInterface $platform) /** * Convenience method to returns the database for current table. + * * @return Database */ public function getDatabase() @@ -597,6 +649,7 @@ public function getDatabase() /** * Pushes a message onto the stack of warnings. + * * @param string $msg The warning message. */ protected function warn($msg) @@ -606,6 +659,7 @@ protected function warn($msg) /** * Gets array of warning messages. + * * @return array string[] */ public function getWarnings() @@ -621,6 +675,7 @@ public function getWarnings() * in the OM builders also, which is why it is defined in this class. * * @param string $text The text to quote. + * * @return string Quoted text. */ public function quoteIdentifier($text) @@ -634,6 +689,7 @@ public function quoteIdentifier($text) /** * Returns the name of the current class being built, with a possible prefix. + * * @return string * @see OMBuilder#getClassname() */ @@ -641,5 +697,4 @@ public function prefixClassname($identifier) { return $this->getBuildProperty('classPrefix') . $identifier; } - } diff --git a/generator/lib/builder/om/ClassTools.php b/generator/lib/builder/om/ClassTools.php index 06e2f436d..8304f3d41 100644 --- a/generator/lib/builder/om/ClassTools.php +++ b/generator/lib/builder/om/ClassTools.php @@ -20,7 +20,9 @@ class ClassTools /** * Gets just classname, given a dot-path to class. + * * @param string $qualifiedName + * * @return string */ public static function classname($qualifiedName) @@ -30,7 +32,7 @@ public static function classname($qualifiedName) } elseif (false !== $pos = strrpos($qualifiedName, '\\')) { return substr($qualifiedName, $pos + 1); } else { - return $qualifiedName; // there is no '.' in the qualified name + return $qualifiedName; // there is no '.' in the qualified name } } @@ -46,6 +48,7 @@ public static function classname($qualifiedName) * @param string $path dot-path to class or to package prefix. * @param string $classname class name * @param string $extension The extension to use on the file. + * * @return string The constructed file path. */ public static function getFilePath($path, $classname = null, $extension = '.php') @@ -63,6 +66,7 @@ public static function getFilePath($path, $classname = null, $extension = '.php' * @param string $path path to class or to package prefix. * @param string $classname class name * @param string $extension The extension to use on the file. + * * @return string The constructed file path. */ public static function createFilePath($path, $classname = null, $extension = '.php') @@ -81,6 +85,7 @@ public static function createFilePath($path, $classname = null, $extension = '.p /** * Gets the basePeer path if specified for table/db. * If not, will return 'propel.util.BasePeer' + * * @return string */ public static function getBasePeer(Table $table) @@ -96,6 +101,7 @@ public static function getBasePeer(Table $table) /** * Gets the baseClass path if specified for table/db. * If not, will return 'propel.om.BaseObject' + * * @return string */ public static function getBaseClass(Table $table) @@ -111,6 +117,7 @@ public static function getBaseClass(Table $table) /** * Gets the interface path if specified for table. * If not, will return 'propel.om.Persistent'. + * * @return string */ public static function getInterface(Table $table) @@ -130,17 +137,6 @@ public static function getInterface(Table $table) */ public static function getPhpReservedWords() { - return array( - 'and', 'or', 'xor', 'exception', '__FILE__', '__LINE__', - 'array', 'as', 'break', 'case', 'class', 'const', 'continue', - 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', - 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', - 'eval', 'exit', 'extends', 'for', 'foreach', 'function', 'global', - 'if', 'include', 'include_once', 'isset', 'list', 'new', 'print', 'require', - 'require_once', 'return', 'static', 'switch', 'unset', 'use', 'var', 'while', - '__FUNCTION__', '__CLASS__', '__METHOD__', 'final', 'php_user_filter', 'interface', - 'implements', 'extends', 'public', 'protected', 'private', 'abstract', 'clone', 'try', 'catch', - 'throw', 'this', 'namespace' - ); + return array('and', 'or', 'xor', 'exception', '__FILE__', '__LINE__', 'array', 'as', 'break', 'case', 'class', 'const', 'continue', 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'eval', 'exit', 'extends', 'for', 'foreach', 'function', 'global', 'if', 'include', 'include_once', 'isset', 'list', 'new', 'print', 'require', 'require_once', 'return', 'static', 'switch', 'unset', 'use', 'var', 'while', '__FUNCTION__', '__CLASS__', '__METHOD__', 'final', 'php_user_filter', 'interface', 'implements', 'extends', 'public', 'protected', 'private', 'abstract', 'clone', 'try', 'catch', 'throw', 'this', 'namespace'); } } diff --git a/generator/lib/builder/om/ExtensionQueryBuilder.php b/generator/lib/builder/om/ExtensionQueryBuilder.php index 99c9ba2e1..b6b387d13 100644 --- a/generator/lib/builder/om/ExtensionQueryBuilder.php +++ b/generator/lib/builder/om/ExtensionQueryBuilder.php @@ -24,6 +24,7 @@ class ExtensionQueryBuilder extends OMBuilder /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -33,19 +34,21 @@ public function getUnprefixedClassname() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) { $requiredClassFilePath = $this->getQueryBuilder()->getClassFilePath(); - $script .=" -require '".$requiredClassFilePath."'; + $script .= " +require '" . $requiredClassFilePath . "'; "; } // addIncludes() /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -77,12 +80,12 @@ protected function addClassOpen(&$script) * application requirements. This class will only be generated as * long as it does not already exist in the output directory. * - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */"; } $script .= " -class ".$this->getClassname()." extends $baseClassname +class " . $this->getClassname() . " extends $baseClassname {"; } @@ -101,6 +104,7 @@ protected function addClassBody(&$script) /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) @@ -113,17 +117,20 @@ protected function addClassClose(&$script) /** * Checks whether any registered behavior on that table has a modifier for a hook + * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string $modifier The name of the modifier object providing the method in the behavior + * * @return boolean */ public function hasBehaviorModifier($hookName, $modifier = null) { - return parent::hasBehaviorModifier($hookName, 'QueryBuilderModifier'); + return parent::hasBehaviorModifier($hookName, 'QueryBuilderModifier'); } /** * Checks whether any registered behavior on that table has a modifier for a hook + * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string &$script The script will be modified in this method. * @param string $tab @@ -135,11 +142,11 @@ public function applyBehaviorModifier($hookName, &$script, $tab = " ") /** * Checks whether any registered behavior content creator on that table exists a contentName + * * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassname" */ public function getBehaviorContent($contentName) { return $this->getBehaviorContentBase($contentName, 'QueryBuilderModifier'); } - } diff --git a/generator/lib/builder/om/ExtensionQueryInheritanceBuilder.php b/generator/lib/builder/om/ExtensionQueryInheritanceBuilder.php index 762d6b85b..b14e735d0 100644 --- a/generator/lib/builder/om/ExtensionQueryInheritanceBuilder.php +++ b/generator/lib/builder/om/ExtensionQueryInheritanceBuilder.php @@ -30,6 +30,7 @@ class ExtensionQueryInheritanceBuilder extends OMBuilder /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -39,6 +40,7 @@ public function getUnprefixedClassname() /** * Gets the package for the [base] object classes. + * * @return string */ public function getPackage() @@ -48,6 +50,7 @@ public function getPackage() /** * Set the child object that we're operating on currently. + * * @param $child Inheritance */ public function setChild(Inheritance $child) @@ -57,6 +60,7 @@ public function setChild(Inheritance $child) /** * Returns the child object we're operating on currently. + * * @return Inheritance * @throws BuildException - if child was not set. */ @@ -71,19 +75,21 @@ public function getChild() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) { $requiredClassFilePath = $this->getStubQueryBuilder()->getClassFilePath(); - $script .=" -require '".$requiredClassFilePath."'; + $script .= " +require '" . $requiredClassFilePath . "'; "; } // addIncludes() /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -116,9 +122,9 @@ protected function addClassOpen(&$script) * application requirements. This class will only be generated as * long as it does not already exist in the output directory. * - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */ -class " .$this->getClassname() . " extends " . $baseClassname . " { +class " . $this->getClassname() . " extends " . $baseClassname . " { "; } @@ -136,6 +142,7 @@ protected function addClassBody(&$script) /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) @@ -144,5 +151,4 @@ protected function addClassClose(&$script) } // " . $this->getClassname() . " "; } - } // MultiExtensionQueryBuilder diff --git a/generator/lib/builder/om/OMBuilder.php b/generator/lib/builder/om/OMBuilder.php index e3c5cfd2a..17afed183 100644 --- a/generator/lib/builder/om/OMBuilder.php +++ b/generator/lib/builder/om/OMBuilder.php @@ -24,8 +24,9 @@ abstract class OMBuilder extends DataModelBuilder { /** * Declared fully qualified classnames, to build the 'namespace' statements - * according to this table's namespace. - * @var array + * according to this table's namespace. + * + * @var array */ protected $declaredClasses = array(); @@ -95,12 +96,14 @@ public function buildObjectInstanceCreationCode($objName, $clsName) /** * Returns the qualified (prefixed) classname that is being built by the current class. * This method must be implemented by child classes. + * * @return string */ abstract public function getUnprefixedClassname(); /** * Returns the prefixed classname that is being built by the current class. + * * @return string * @see DataModelBuilder#prefixClassname() */ @@ -111,6 +114,7 @@ public function getClassname() /** * Returns the namespaced classname if there is a namespace, and the raw classname otherwise + * * @return string */ public function getFullyQualifiedClassname() @@ -124,6 +128,7 @@ public function getFullyQualifiedClassname() /** * Gets the dot-path representation of current class being built. + * * @return string */ public function getClasspath() @@ -139,6 +144,7 @@ public function getClasspath() /** * Gets the full path to the file for the current class. + * * @return string */ public function getClassFilePath() @@ -149,6 +155,7 @@ public function getClassFilePath() /** * Gets package name for this table. * This is overridden by child classes that have different packages. + * * @return string */ public function getPackage() @@ -163,6 +170,7 @@ public function getPackage() /** * Returns filesystem path for current package. + * * @return string */ public function getPackagePath() @@ -193,8 +201,7 @@ public function getNamespace() public function declareClassNamespace($class, $namespace = '') { - if (isset($this->declaredClasses[$namespace]) - && in_array($class, $this->declaredClasses[$namespace])) { + if (isset($this->declaredClasses[$namespace]) && in_array($class, $this->declaredClasses[$namespace])) { return; } $this->declaredClasses[$namespace][] = $class; @@ -264,6 +271,7 @@ public function getUseStatements($ignoredNamespace = null) * Shortcut method to return the [stub] peer classname for current table. * This is the classname that is used whenever object or peer classes want * to invoke methods of the peer classes. + * * @return string (e.g. 'MyPeer') * @see StubPeerBuilder::getClassname() */ @@ -276,6 +284,7 @@ public function getPeerClassname() * Shortcut method to return the [stub] query classname for current table. * This is the classname that is used whenever object or peer classes want * to invoke methods of the query classes. + * * @return string (e.g. 'Myquery') * @see StubQueryBuilder::getClassname() */ @@ -288,6 +297,7 @@ public function getQueryClassname() * Returns the object classname for current table. * This is the classname that is used whenever object or peer classes want * to invoke methods of the object classes. + * * @return string (e.g. 'My') * @see StubPeerBuilder::getClassname() */ @@ -323,12 +333,13 @@ public function getColumnConstant($col, $classname = null) $const = strtoupper($col->getName()); } - return $classname.'::'.$const; + return $classname . '::' . $const; } /** * Gets the basePeer path if specified for table/db. * If not, will return 'propel.util.BasePeer' + * * @return string */ public function getBasePeer(Table $table) @@ -343,6 +354,7 @@ public function getBasePeer(Table $table) /** * Convenience method to get the foreign Table object for an fkey. + * * @deprecated use ForeignKey::getForeignTable() instead * @return Table */ @@ -357,6 +369,7 @@ protected function getForeignTable(ForeignKey $fk) * unless the schema is provided with the DefaultJoin attribute, which overrules the default Join Type * * @param ForeignKey $fk + * * @return string */ protected function getJoinType(ForeignKey $fk) @@ -379,6 +392,7 @@ protected function getJoinType(ForeignKey $fk) * * @param ForeignKey $fk The local FK that we need a name for. * @param boolean $plural Whether the php name should be plural (e.g. initRelatedObjs() vs. addRelatedObj() + * * @return string */ public function getFKPhpNameAffix(ForeignKey $fk, $plural = false) @@ -414,7 +428,7 @@ protected static function getRelatedBySuffix(ForeignKey $fk) { $relCol = ''; foreach ($fk->getLocalForeignMapping() as $localColumnName => $foreignColumnName) { - $localTable = $fk->getTable(); + $localTable = $fk->getTable(); $localColumn = $localTable->getColumn($localColumnName); if (!$localColumn) { throw new Exception("Could not fetch column: $columnName in table " . $localTable->getName()); @@ -442,6 +456,7 @@ protected static function getRelatedBySuffix(ForeignKey $fk) * * @param ForeignKey $fk The referrer FK that we need a name for. * @param boolean $plural Whether the php name should be plural (e.g. initRelatedObjs() vs. addRelatedObj() + * * @return string */ public function getRefFKPhpNameAffix(ForeignKey $fk, $plural = false) @@ -503,8 +518,10 @@ protected function isAddIncludes() /** * Checks whether any registered behavior on that table has a modifier for a hook + * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string $modifier The name of the modifier object providing the method in the behavior + * * @return boolean */ public function hasBehaviorModifier($hookName, $modifier) @@ -521,6 +538,7 @@ public function hasBehaviorModifier($hookName, $modifier) /** * Checks whether any registered behavior on that table has a modifier for a hook + * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string $modifier The name of the modifier object providing the method in the behavior * @param string &$script The script will be modified in this method. @@ -553,6 +571,7 @@ public function applyBehaviorModifierBase($hookName, $modifier, &$script, $tab = /** * Checks whether any registered behavior content creator on that table exists a contentName + * * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassname" * @param string $modifier The name of the modifier object providing the method in the behavior */ @@ -591,15 +610,15 @@ private function clean($content) $short = array_pop($parts); } - preg_match_all('/\b'.$short.'\b/i', str_replace($match[0]."\n", '', $content), $m); + preg_match_all('/\b' . $short . '\b/i', str_replace($match[0] . "\n", '', $content), $m); if (!count($m[0])) { - $content = str_replace($match[0]."\n", '', $content); + $content = str_replace($match[0] . "\n", '', $content); } } // end of line if (strlen($content) && "\n" != substr($content, -1)) { - $content = $content."\n"; + $content = $content . "\n"; } return $content; diff --git a/generator/lib/builder/om/ObjectBuilder.php b/generator/lib/builder/om/ObjectBuilder.php index ddbf17c0c..12c80aa76 100644 --- a/generator/lib/builder/om/ObjectBuilder.php +++ b/generator/lib/builder/om/ObjectBuilder.php @@ -48,6 +48,7 @@ abstract protected function addClassBody(&$script); * Adds the getter methods for the column values. * This is here because it is probably generic enough to apply to templates being generated * in different languages (e.g. PHP4 and PHP5). + * * @param string &$script The script will be modified in this method. */ protected function addColumnAccessorMethods(&$script) @@ -82,6 +83,7 @@ protected function addColumnAccessorMethods(&$script) * Adds the mutator (setter) methods for setting column values. * This is here because it is probably generic enough to apply to templates being generated * in different langauges (e.g. PHP4 and PHP5). + * * @param string &$script The script will be modified in this method. */ protected function addColumnMutatorMethods(&$script) @@ -113,6 +115,7 @@ protected function addColumnMutatorMethods(&$script) /** * Gets the baseClass path if specified for table/db. * If not, will return 'propel.om.BaseObject' + * * @return string */ protected function getBaseClass() @@ -128,6 +131,7 @@ protected function getBaseClass() /** * Gets the interface path if specified for current table. * If not, will return 'propel.om.Persistent'. + * * @return string */ protected function getInterface() @@ -176,7 +180,9 @@ protected function isAddValidateMethod() protected function hasDefaultValues() { foreach ($this->getTable()->getColumns() as $col) { - if($col->getDefaultValue() !== null) return true; + if ($col->getDefaultValue() !== null) { + return true; + } } return false; @@ -184,16 +190,19 @@ protected function hasDefaultValues() /** * Checks whether any registered behavior on that table has a modifier for a hook + * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" + * * @return boolean */ public function hasBehaviorModifier($hookName, $modifier = null) { - return parent::hasBehaviorModifier($hookName, 'ObjectBuilderModifier'); + return parent::hasBehaviorModifier($hookName, 'ObjectBuilderModifier'); } /** * Checks whether any registered behavior on that table has a modifier for a hook + * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string &$script The script will be modified in this method. */ @@ -204,11 +213,11 @@ public function applyBehaviorModifier($hookName, &$script, $tab = " ") /** * Checks whether any registered behavior content creator on that table exists a contentName + * * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassname" */ public function getBehaviorContent($contentName) { return $this->getBehaviorContentBase($contentName, 'ObjectBuilderModifier'); } - } diff --git a/generator/lib/builder/om/PHP5ExtensionNodeBuilder.php b/generator/lib/builder/om/PHP5ExtensionNodeBuilder.php index 4c64f9fcd..7f5e097d2 100644 --- a/generator/lib/builder/om/PHP5ExtensionNodeBuilder.php +++ b/generator/lib/builder/om/PHP5ExtensionNodeBuilder.php @@ -24,6 +24,7 @@ class PHP5ExtensionNodeBuilder extends ObjectBuilder /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -33,17 +34,19 @@ public function getUnprefixedClassname() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) { $script .= " -require '".$this->getNodeBuilder()->getClassFilePath()."'; +require '" . $this->getNodeBuilder()->getClassFilePath() . "'; "; } // addIncludes() /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -75,9 +78,9 @@ protected function addClassOpen(&$script) * application requirements. This class will only be generated as * long as it does not already exist in the output directory. * - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */ -class ".$this->getClassname()." extends $baseClassname { +class " . $this->getClassname() . " extends $baseClassname { "; } @@ -96,6 +99,7 @@ protected function addClassBody(&$script) /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) @@ -104,5 +108,4 @@ protected function addClassClose(&$script) } // " . $this->getClassname() . " "; } - } // PHP5ExtensionObjectBuilder diff --git a/generator/lib/builder/om/PHP5ExtensionNodePeerBuilder.php b/generator/lib/builder/om/PHP5ExtensionNodePeerBuilder.php index d98b770a6..7f36e9dee 100644 --- a/generator/lib/builder/om/PHP5ExtensionNodePeerBuilder.php +++ b/generator/lib/builder/om/PHP5ExtensionNodePeerBuilder.php @@ -24,6 +24,7 @@ class PHP5ExtensionNodePeerBuilder extends PeerBuilder /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -33,17 +34,19 @@ public function getUnprefixedClassname() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) { - $script .=" -require '".$this->getNodePeerBuilder()->getClassFilePath()."'; + $script .= " +require '" . $this->getNodePeerBuilder()->getClassFilePath() . "'; "; } // addIncludes() /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -75,13 +78,13 @@ protected function addClassOpen(&$script) * application requirements. This class will only be generated as * long as it does not already exist in the output directory. * - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */ -class ".$this->getClassname()." extends $baseClassname { +class " . $this->getClassname() . " extends $baseClassname { "; } - /** + /** * Specifies the methods that are added as part of the stub peer class. * * By default there are no methods for the empty stub classes; override this method @@ -97,6 +100,7 @@ protected function addClassBody(&$script) /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) @@ -105,5 +109,4 @@ protected function addClassClose(&$script) } // " . $this->getClassname() . " "; } - } // PHP5ExtensionPeerBuilder diff --git a/generator/lib/builder/om/PHP5ExtensionObjectBuilder.php b/generator/lib/builder/om/PHP5ExtensionObjectBuilder.php index 284b7df07..78d1ef6f8 100644 --- a/generator/lib/builder/om/PHP5ExtensionObjectBuilder.php +++ b/generator/lib/builder/om/PHP5ExtensionObjectBuilder.php @@ -24,6 +24,7 @@ class PHP5ExtensionObjectBuilder extends ObjectBuilder /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -33,6 +34,7 @@ public function getUnprefixedClassname() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) @@ -40,22 +42,23 @@ protected function addIncludes(&$script) switch ($this->getTable()->treeMode()) { case 'NestedSet': $requiredClassFilePath = $this->getNestedSetBuilder()->getClassFilePath(); - break; + break; case 'MaterializedPath': case 'AdjacencyList': default: $requiredClassFilePath = $this->getObjectBuilder()->getClassFilePath(); - break; + break; } - $script .=" -require '".$requiredClassFilePath."'; + $script .= " +require '" . $requiredClassFilePath . "'; "; } // addIncludes() /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -68,13 +71,13 @@ protected function addClassOpen(&$script) switch ($table->treeMode()) { case 'NestedSet': $baseClassname = $this->getNestedSetBuilder()->getClassname(); - break; + break; case 'MaterializedPath': case "AdjacencyList": default: $baseClassname = $this->getObjectBuilder()->getClassname(); - break; + break; } if ($this->getBuildProperty('addClassLevelComment')) { @@ -98,12 +101,12 @@ protected function addClassOpen(&$script) * application requirements. This class will only be generated as * long as it does not already exist in the output directory. * - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */"; } $script .= " -".($table->isAbstract() ? "abstract " : "")."class ".$this->getClassname()." extends $baseClassname +" . ($table->isAbstract() ? "abstract " : "") . "class " . $this->getClassname() . " extends $baseClassname {"; } @@ -121,6 +124,7 @@ protected function addClassBody(&$script) /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) diff --git a/generator/lib/builder/om/PHP5ExtensionPeerBuilder.php b/generator/lib/builder/om/PHP5ExtensionPeerBuilder.php index 610dffa83..57a68ea60 100644 --- a/generator/lib/builder/om/PHP5ExtensionPeerBuilder.php +++ b/generator/lib/builder/om/PHP5ExtensionPeerBuilder.php @@ -24,6 +24,7 @@ class PHP5ExtensionPeerBuilder extends PeerBuilder /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -33,6 +34,7 @@ public function getUnprefixedClassname() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) @@ -40,22 +42,23 @@ protected function addIncludes(&$script) switch ($this->getTable()->treeMode()) { case 'NestedSet': $requiredClassFilePath = $this->getNestedSetPeerBuilder()->getClassFilePath(); - break; + break; case 'MaterializedPath': case 'AdjacencyList': default: $requiredClassFilePath = $this->getPeerBuilder()->getClassFilePath(); - break; + break; } - $script .=" -require '".$requiredClassFilePath."'; + $script .= " +require '" . $requiredClassFilePath . "'; "; } // addIncludes() /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -68,13 +71,13 @@ protected function addClassOpen(&$script) switch ($table->treeMode()) { case 'NestedSet': $baseClassname = $this->getNestedSetPeerBuilder()->getClassname(); - break; + break; case 'MaterializedPath': case 'AdjacencyList': default: $baseClassname = $this->getPeerBuilder()->getClassname(); - break; + break; } if ($this->getBuildProperty('addClassLevelComment')) { @@ -98,16 +101,16 @@ protected function addClassOpen(&$script) * application requirements. This class will only be generated as * long as it does not already exist in the output directory. * - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */"; } $script .= " -class ".$this->getClassname()." extends $baseClassname +class " . $this->getClassname() . " extends $baseClassname {"; } - /** + /** * Specifies the methods that are added as part of the stub peer class. * * By default there are no methods for the empty stub classes; override this method @@ -123,6 +126,7 @@ protected function addClassBody(&$script) /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) @@ -132,5 +136,4 @@ protected function addClassClose(&$script) "; $this->applyBehaviorModifier('extensionPeerFilter', $script, ""); } - } // PHP5ExtensionPeerBuilder diff --git a/generator/lib/builder/om/PHP5InterfaceBuilder.php b/generator/lib/builder/om/PHP5InterfaceBuilder.php index 1510f563b..4134685ba 100644 --- a/generator/lib/builder/om/PHP5InterfaceBuilder.php +++ b/generator/lib/builder/om/PHP5InterfaceBuilder.php @@ -24,6 +24,7 @@ class PHP5InterfaceBuilder extends ObjectBuilder /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -33,15 +34,16 @@ public function getUnprefixedClassname() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) { - } // addIncludes() /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -72,9 +74,9 @@ protected function addClassOpen(&$script) * application requirements. This interface will only be generated as * long as it does not already exist in the output directory. * - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */ -interface ".$this->getClassname()." { +interface " . $this->getClassname() . " { "; } @@ -93,6 +95,7 @@ protected function addClassBody(&$script) /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) @@ -101,5 +104,4 @@ protected function addClassClose(&$script) } // " . $this->getClassname() . " "; } - } // PHP5ExtensionObjectBuilder diff --git a/generator/lib/builder/om/PHP5MultiExtendObjectBuilder.php b/generator/lib/builder/om/PHP5MultiExtendObjectBuilder.php index d71b546ca..6873600a2 100644 --- a/generator/lib/builder/om/PHP5MultiExtendObjectBuilder.php +++ b/generator/lib/builder/om/PHP5MultiExtendObjectBuilder.php @@ -29,6 +29,7 @@ class PHP5MultiExtendObjectBuilder extends ObjectBuilder /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -38,6 +39,7 @@ public function getUnprefixedClassname() /** * Override method to return child package, if specified. + * * @return string */ public function getPackage() @@ -47,6 +49,7 @@ public function getPackage() /** * Set the child object that we're operating on currently. + * * @param $child Inheritance */ public function setChild(Inheritance $child) @@ -56,6 +59,7 @@ public function setChild(Inheritance $child) /** * Returns the child object we're operating on currently. + * * @return Inheritance * @throws BuildException - if child was not set. */ @@ -70,6 +74,7 @@ public function getChild() /** * Returns classpath to parent class. + * * @return string */ protected function getParentClasspath() @@ -83,6 +88,7 @@ protected function getParentClasspath() /** * Returns classname of parent class. + * * @return string */ protected function getParentClassname() @@ -92,6 +98,7 @@ protected function getParentClassname() /** * Gets the file path to the parent class. + * * @return string */ protected function getParentClassFilePath() @@ -101,6 +108,7 @@ protected function getParentClassFilePath() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) @@ -109,17 +117,18 @@ protected function addIncludes(&$script) /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) { if ($this->getChild()->getAncestor()) { $ancestorClassName = $this->getChild()->getAncestor(); - if ($this->getDatabase()->hasTableByPhpName($ancestorClassName)) { - $this->declareClassFromBuilder($this->getNewStubObjectBuilder($this->getDatabase()->getTableByPhpName($ancestorClassName))); - } else { - $this->declareClassNamespace($ancestorClassName, $this->getNamespace()); - } + if ($this->getDatabase()->hasTableByPhpName($ancestorClassName)) { + $this->declareClassFromBuilder($this->getNewStubObjectBuilder($this->getDatabase()->getTableByPhpName($ancestorClassName))); + } else { + $this->declareClassNamespace($ancestorClassName, $this->getNamespace()); + } } else { $this->declareClassFromBuilder($this->getObjectBuilder()); } @@ -149,9 +158,9 @@ protected function addClassOpen(&$script) * application requirements. This class will only be generated as * long as it does not already exist in the output directory. * - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */ -class ".$this->getClassname()." extends ".$this->getParentClassname()." { +class " . $this->getClassname() . " extends " . $this->getParentClassname() . " { "; } @@ -170,23 +179,24 @@ protected function addClassBody(&$script) $col = $child->getColumn(); $cfc = $col->getPhpName(); - $const = "CLASSKEY_".strtoupper($child->getKey()); + $const = "CLASSKEY_" . strtoupper($child->getKey()); $script .= " /** - * Constructs a new ".$this->getChild()->getClassname()." class, setting the ".$col->getName()." column to ".$this->getPeerClassname()."::$const. + * Constructs a new " . $this->getChild()->getClassname() . " class, setting the " . $col->getName() . " column to " . $this->getPeerClassname() . "::$const. */ public function __construct() {"; $script .= " parent::__construct(); - \$this->set$cfc(".$this->getPeerClassname()."::CLASSKEY_".strtoupper($child->getKey())."); + \$this->set$cfc(" . $this->getPeerClassname() . "::CLASSKEY_" . strtoupper($child->getKey()) . "); } "; } /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) @@ -195,5 +205,4 @@ protected function addClassClose(&$script) } // " . $this->getClassname() . " "; } - } // PHP5ExtensionObjectBuilder diff --git a/generator/lib/builder/om/PHP5NestedSetBuilder.php b/generator/lib/builder/om/PHP5NestedSetBuilder.php index 040e63209..2bafb35d7 100644 --- a/generator/lib/builder/om/PHP5NestedSetBuilder.php +++ b/generator/lib/builder/om/PHP5NestedSetBuilder.php @@ -24,6 +24,7 @@ class PHP5NestedSetBuilder extends ObjectBuilder /** * Gets the package for the [base] object classes. + * * @return string */ public function getPackage() @@ -33,6 +34,7 @@ public function getPackage() /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -42,17 +44,19 @@ public function getUnprefixedClassname() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) { - $script .=" -require '".$this->getObjectBuilder()->getClassFilePath()."'; + $script .= " +require '" . $this->getObjectBuilder()->getClassFilePath() . "'; "; } // addIncludes() /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -78,15 +82,16 @@ protected function addClassOpen(&$script) } $script .= " * @deprecated Since Propel 1.5. Use the nested_set behavior instead of the NestedSet treeMode - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */ -abstract class ".$this->getClassname()." extends ".$this->getObjectBuilder()->getClassname()." implements NodeObject { +abstract class " . $this->getClassname() . " extends " . $this->getObjectBuilder()->getClassname() . " implements NodeObject { "; } /** * Specifies the methods that are added as part of the basic OM class. * This can be overridden by subclasses that wish to add more methods. + * * @see ObjectBuilder::addClassBody() */ protected function addClassBody(&$script) @@ -158,6 +163,7 @@ protected function addClassBody(&$script) /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) @@ -169,6 +175,7 @@ protected function addClassClose(&$script) /** * Adds class attributes. + * * @param string &$script The script will be modified in this method. */ protected function addAttributes(&$script) @@ -988,7 +995,7 @@ protected function addGetLeft(&$script) foreach ($table->getColumns() as $col) { if ($col->isNestedSetLeftKey()) { - $left_col_getter_name = 'get'.$col->getPhpName(); + $left_col_getter_name = 'get' . $col->getPhpName(); break; } } @@ -1012,7 +1019,7 @@ protected function addGetRight(&$script) foreach ($table->getColumns() as $col) { if ($col->isNestedSetRightKey()) { - $right_col_getter_name = 'get'.$col->getPhpName(); + $right_col_getter_name = 'get' . $col->getPhpName(); break; } } @@ -1037,7 +1044,7 @@ protected function addGetScopeId(&$script) $scope_col_getter_name = null; foreach ($table->getColumns() as $col) { if ($col->isTreeScopeKey()) { - $scope_col_getter_name = 'get'.$col->getPhpName(); + $scope_col_getter_name = 'get' . $col->getPhpName(); break; } } @@ -1071,7 +1078,7 @@ protected function addSetLeft(&$script) foreach ($table->getColumns() as $col) { if ($col->isNestedSetLeftKey()) { - $left_col_setter_name = 'set'.$col->getPhpName(); + $left_col_setter_name = 'set' . $col->getPhpName(); break; } } @@ -1099,7 +1106,7 @@ protected function addSetRight(&$script) foreach ($table->getColumns() as $col) { if ($col->isNestedSetRightKey()) { - $right_col_setter_name = 'set'.$col->getPhpName(); + $right_col_setter_name = 'set' . $col->getPhpName(); break; } } @@ -1128,7 +1135,7 @@ protected function addSetScopeId(&$script) $scope_col_setter_name = null; foreach ($table->getColumns() as $col) { if ($col->isTreeScopeKey()) { - $scope_col_setter_name = 'set'.$col->getPhpName(); + $scope_col_setter_name = 'set' . $col->getPhpName(); break; } } @@ -1151,7 +1158,5 @@ public function setScopeIdValue(\$v) return \$this; } "; - } - } // PHP5NestedSetBuilder diff --git a/generator/lib/builder/om/PHP5NestedSetPeerBuilder.php b/generator/lib/builder/om/PHP5NestedSetPeerBuilder.php index 79ada362e..16491f419 100644 --- a/generator/lib/builder/om/PHP5NestedSetPeerBuilder.php +++ b/generator/lib/builder/om/PHP5NestedSetPeerBuilder.php @@ -24,6 +24,7 @@ class PHP5NestedSetPeerBuilder extends PeerBuilder /** * Gets the package for the [base] object classes. + * * @return string */ public function getPackage() @@ -33,6 +34,7 @@ public function getPackage() /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -42,17 +44,19 @@ public function getUnprefixedClassname() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) { - $script .=" -require '".$this->getPeerBuilder()->getClassFilePath()."'; + $script .= " +require '" . $this->getPeerBuilder()->getClassFilePath() . "'; "; } // addIncludes() /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -78,15 +82,16 @@ protected function addClassOpen(&$script) } $script .= " * @deprecated Since Propel 1.5. Use the nested_set behavior instead of the NestedSet treeMode - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */ -abstract class ".$this->getClassname()." extends ".$this->getPeerBuilder()->getClassName()." implements NodePeer { +abstract class " . $this->getClassname() . " extends " . $this->getPeerBuilder()->getClassName() . " implements NodePeer { "; } /** * Specifies the methods that are added as part of the basic OM class. * This can be overridden by subclasses that wish to add more methods. + * * @see ObjectBuilder::addClassBody() */ protected function addClassBody(&$script) @@ -166,6 +171,7 @@ protected function addClassBody(&$script) /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) @@ -799,8 +805,8 @@ public static function retrieveTree(\$scopeId = null, PropelPDO \$con = null) \$omClass = $peerClassname::getOMClass(\$row, 0); \$cls = substr('.'.\$omClass, strrpos('.'.\$omClass, '.') + 1); - \$key = ".$peerClassname."::getPrimaryKeyHashFromRow(\$row, 0); - if (null === (\$root = ".$peerClassname."::getInstanceFromPool(\$key))) { + \$key = " . $peerClassname . "::getPrimaryKeyHashFromRow(\$row, 0); + if (null === (\$root = " . $peerClassname . "::getInstanceFromPool(\$key))) { " . $this->buildObjectInstanceCreationCode('$root', '$cls') . " \$root->hydrate(\$row); } @@ -1343,13 +1349,13 @@ protected static function hydrateDescendants(NodeObject \$node, PDOStatement \$s $script .= " while (\$row = \$stmt->fetch(PDO::FETCH_NUM)) { - \$key = ".$peerClassname."::getPrimaryKeyHashFromRow(\$row, 0); - if (null === (\$child = ".$peerClassname."::getInstanceFromPool(\$key))) {"; + \$key = " . $peerClassname . "::getPrimaryKeyHashFromRow(\$row, 0); + if (null === (\$child = " . $peerClassname . "::getInstanceFromPool(\$key))) {"; if ($table->getChildrenColumn()) { $script .= " // class must be set each time from the record row - \$cls = ".$peerClassname."::getOMClass(\$row, 0); + \$cls = " . $peerClassname . "::getOMClass(\$row, 0); \$cls = substr('.'.\$cls, strrpos('.'.\$cls, '.') + 1); "; } @@ -1417,13 +1423,13 @@ protected static function hydrateChildren(NodeObject \$node, PDOStatement \$stmt $script .= " while (\$row = \$stmt->fetch(PDO::FETCH_NUM)) { - \$key = ".$peerClassname."::getPrimaryKeyHashFromRow(\$row, 0); - if (null === (\$child = ".$peerClassname."::getInstanceFromPool(\$key))) {"; + \$key = " . $peerClassname . "::getPrimaryKeyHashFromRow(\$row, 0); + if (null === (\$child = " . $peerClassname . "::getInstanceFromPool(\$key))) {"; if ($table->getChildrenColumn()) { $script .= " // class must be set each time from the record row - \$cls = ".$peerClassname."::getOMClass(\$row, 0); + \$cls = " . $peerClassname . "::getOMClass(\$row, 0); \$cls = substr('.'.\$cls, strrpos('.'.\$cls, '.') + 1); "; } @@ -1511,7 +1517,7 @@ protected static function updateLoadedNode(NodeObject \$node, \$delta, PropelPDO $pkey = $table->getPrimaryKey(); $col = array_shift($pkey); $script .= " - \$criteria->add(".$this->getColumnConstant($col).", \$keys, Criteria::IN); + \$criteria->add(" . $this->getColumnConstant($col) . ", \$keys, Criteria::IN); "; } else { $fields = array(); @@ -1538,25 +1544,25 @@ protected static function updateLoadedNode(NodeObject \$node, \$delta, PropelPDO // Add final Criterion to Criteria \$criteria->addOr(\$cton); }"; - } + } - $script .= " + $script .= " \$stmt = $peerClassname::doSelectStmt(\$criteria, \$con); while (\$row = \$stmt->fetch(PDO::FETCH_NUM)) { \$key = $peerClassname::getPrimaryKeyHashFromRow(\$row, 0); if (null !== (\$object = $peerClassname::getInstanceFromPool(\$key))) {"; - $n = 0; - foreach ($table->getColumns() as $col) { - if ($col->isNestedSetLeftKey()) { - $script .= " + $n = 0; + foreach ($table->getColumns() as $col) { + if ($col->isNestedSetLeftKey()) { + $script .= " \$object->setLeftValue(\$row[$n]);"; - } elseif ($col->isNestedSetRightKey()) { - $script .= " + } elseif ($col->isNestedSetRightKey()) { + $script .= " \$object->setRightValue(\$row[$n]);"; - } - $n++; } - $script .= " + $n++; + } + $script .= " } } \$stmt->closeCursor(); @@ -1732,5 +1738,4 @@ protected static function shiftRLRange(\$first, \$last, \$delta, PropelPDO \$con } "; } - } // PHP5NestedSetPeerBuilder diff --git a/generator/lib/builder/om/PHP5NodeBuilder.php b/generator/lib/builder/om/PHP5NodeBuilder.php index ecc8a9ae0..27cfd12de 100644 --- a/generator/lib/builder/om/PHP5NodeBuilder.php +++ b/generator/lib/builder/om/PHP5NodeBuilder.php @@ -24,6 +24,7 @@ class PHP5NodeBuilder extends ObjectBuilder /** * Gets the package for the [base] object classes. + * * @return string */ public function getPackage() @@ -33,6 +34,7 @@ public function getPackage() /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -42,6 +44,7 @@ public function getUnprefixedClassname() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) @@ -50,6 +53,7 @@ protected function addIncludes(&$script) /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -74,15 +78,16 @@ protected function addClassOpen(&$script) *"; } $script .= " - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */ -abstract class ".$this->getClassname()." implements IteratorAggregate { +abstract class " . $this->getClassname() . " implements IteratorAggregate { "; } /** * Specifies the methods that are added as part of the basic OM class. * This can be overridden by subclasses that wish to add more methods. + * * @see ObjectBuilder::addClassBody() */ protected function addClassBody(&$script) @@ -130,11 +135,11 @@ protected function addClassBody(&$script) $this->addAdjustStatus($script); $this->addAdjustNodePath($script); - } /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) @@ -146,19 +151,20 @@ protected function addClassClose(&$script) /** * Adds class attributes. + * * @param string &$script The script will be modified in this method. */ protected function addAttributes(&$script) { $script .= " /** - * @var ".$this->getStubObjectBuilder()->getClassname()." object wrapped by this node. + * @var " . $this->getStubObjectBuilder()->getClassname() . " object wrapped by this node. */ protected \$obj = null; /** * The parent node for this node. - * @var ".$this->getStubNodeBuilder()->getClassname()." + * @var " . $this->getStubNodeBuilder()->getClassname() . " */ protected \$parentNode = null; @@ -172,6 +178,7 @@ protected function addAttributes(&$script) /** * Adds the constructor. + * * @param string &$script The script will be modified in this method. */ protected function addConstructor(&$script) @@ -180,15 +187,15 @@ protected function addConstructor(&$script) /** * Constructor. * - * @param ".$this->getStubObjectBuilder()->getClassname()." \$obj Object wrapped by this node. + * @param " . $this->getStubObjectBuilder()->getClassname() . " \$obj Object wrapped by this node. */ public function __construct(\$obj = null) { if (\$obj !== null) { \$this->obj = \$obj; } else { - \$setNodePath = 'set' . ".$this->getStubNodePeerBuilder()->getClassname()."::NPATH_PHPNAME; - \$this->obj = new ".$this->getStubObjectBuilder()->getClassname()."(); + \$setNodePath = 'set' . " . $this->getStubNodePeerBuilder()->getClassname() . "::NPATH_PHPNAME; + \$this->obj = new " . $this->getStubObjectBuilder()->getClassname() . "(); \$this->obj->\$setNodePath('0'); } } @@ -274,7 +281,7 @@ protected function addGetNodeObj(&$script) $script .= " /** * Returns the object wrapped by this class. - * @return ".$this->getStubObjectBuilder()->getClassname()." + * @return " . $this->getStubObjectBuilder()->getClassname() . " */ public function getNodeObj() { @@ -292,7 +299,7 @@ protected function addGetNodePath(&$script) */ public function getNodePath() { - \$getNodePath = 'get' . ".$this->getStubNodePeerBuilder()->getClassname()."::NPATH_PHPNAME; + \$getNodePath = 'get' . " . $this->getStubNodePeerBuilder()->getClassname() . "::NPATH_PHPNAME; return \$this->obj->\$getNodePath(); } @@ -309,7 +316,7 @@ protected function addGetNodeIndex(&$script) public function getNodeIndex() { \$npath =& \$this->getNodePath(); - \$sep = strrpos(\$npath, ".$this->getStubNodePeerBuilder()->getClassname()."::NPATH_SEP); + \$sep = strrpos(\$npath, " . $this->getStubNodePeerBuilder()->getClassname() . "::NPATH_SEP); return (int) (\$sep !== false ? substr(\$npath, \$sep+1) : \$npath); } @@ -325,7 +332,7 @@ protected function addGetNodeLevel(&$script) */ public function getNodeLevel() { - return (substr_count(\$this->getNodePath(), ".$this->getStubNodePeerBuilder()->getClassname()."::NPATH_SEP) + 1); + return (substr_count(\$this->getNodePath(), " . $this->getStubNodePeerBuilder()->getClassname() . "::NPATH_SEP) + 1); } "; } @@ -337,7 +344,7 @@ protected function addHasChildNode(&$script) * Returns true if specified node is a child of this node. If recurse is * true, checks if specified node is a descendant of this node. * - * @param ".$this->getStubNodeBuilder()->getClassname()." \$node Node to look for. + * @param " . $this->getStubNodeBuilder()->getClassname() . " \$node Node to look for. * @param boolean \$strict True if strict comparison should be used. * @param boolean \$recurse True if all descendants should be checked. * @return boolean @@ -367,7 +374,7 @@ protected function addGetChildNodeAt(&$script) * @param int \$i One-based child node index. * @param boolean \$querydb True if child should be retrieved from database. * @param PropelPDO \$con Connection to use if retrieving from database. - * @return ".$this->getStubNodeBuilder()->getClassname()." + * @return " . $this->getStubNodeBuilder()->getClassname() . " */ public function getChildNodeAt(\$i, \$querydb = false, PropelPDO \$con = null) { @@ -376,11 +383,11 @@ public function getChildNodeAt(\$i, \$querydb = false, PropelPDO \$con = null) !\$this->obj->isDeleted() && !isset(\$this->childNodes[\$i])) { - \$criteria = new Criteria(".$this->getStubPeerBuilder()->getClassname()."::DATABASE_NAME); - \$criteria->add(".$this->getStubNodePeerBuilder()->getClassname()."::NPATH_COLNAME, \$this->getNodePath() . ".$this->getStubNodePeerBuilder()->getClassname()."::NPATH_SEP . \$i, Criteria::EQUAL); + \$criteria = new Criteria(" . $this->getStubPeerBuilder()->getClassname() . "::DATABASE_NAME); + \$criteria->add(" . $this->getStubNodePeerBuilder()->getClassname() . "::NPATH_COLNAME, \$this->getNodePath() . " . $this->getStubNodePeerBuilder()->getClassname() . "::NPATH_SEP . \$i, Criteria::EQUAL); - if (\$childObj = ".$this->getStubPeerBuilder()->getClassname()."::doSelectOne(\$criteria, \$con)) - \$this->attachChildNode(new ".$this->getStubNodeBuilder()->getClassname()."(\$childObj)); + if (\$childObj = " . $this->getStubPeerBuilder()->getClassname() . "::doSelectOne(\$criteria, \$con)) + \$this->attachChildNode(new " . $this->getStubNodeBuilder()->getClassname() . "(\$childObj)); } return (isset(\$this->childNodes[\$i]) ? \$this->childNodes[\$i] : null); @@ -396,7 +403,7 @@ protected function addGetFirstChildNode(&$script) * * @param boolean \$querydb True if child should be retrieved from database. * @param PropelPDO \$con Connection to use if retrieving from database. - * @return ".$this->getStubNodeBuilder()->getClassname()." + * @return " . $this->getStubNodeBuilder()->getClassname() . " */ public function getFirstChildNode(\$querydb = false, PropelPDO \$con = null) { @@ -437,7 +444,7 @@ public function getLastChildNode(\$querydb = false, PropelPDO \$con = null) \$lastObj = $peerClassname::doSelectOne(\$criteria, \$con); if (\$lastObj !== null) { - \$lastNode = new ".$this->getStubNodeBuilder()->getClassname()."(\$lastObj); + \$lastNode = new " . $this->getStubNodeBuilder()->getClassname() . "(\$lastObj); end(\$this->childNodes); \$endNode = (count(\$this->childNodes) ? current(\$this->childNodes) : null); @@ -470,7 +477,7 @@ protected function addGetSiblingNode(&$script) * @param boolean \$prev True if previous sibling should be returned. * @param boolean \$querydb True if sibling should be retrieved from database. * @param PropelPDO \$con Connection to use if retrieving from database. - * @return ".$this->getStubNodeBuilder()->getClassname()." + * @return " . $this->getStubNodeBuilder()->getClassname() . " */ public function getSiblingNode(\$prev = false, \$querydb = false, PropelPDO \$con = null) { @@ -504,7 +511,7 @@ protected function addGetParentNode(&$script) * * @param boolean \$querydb True if parent should be retrieved from database. * @param PropelPDO \$con Connection to use if retrieving from database. - * @return ".$this->getStubNodeBuilder()->getClassname()." + * @return " . $this->getStubNodeBuilder()->getClassname() . " */ public function getParentNode(\$querydb = true, PropelPDO \$con = null) { @@ -522,7 +529,7 @@ public function getParentNode(\$querydb = true, PropelPDO \$con = null) \$criteria->add($nodePeerClassname::NPATH_COLNAME, \$ppath, Criteria::EQUAL); if (\$parentObj = $peerClassname::doSelectOne(\$criteria, \$con)) { - \$parentNode = new ".$this->getStubNodeBuilder()->getClassname()."(\$parentObj); + \$parentNode = new " . $this->getStubNodeBuilder()->getClassname() . "(\$parentObj); \$parentNode->attachChildNode(\$this); } } @@ -617,8 +624,8 @@ protected function addAddChildNode(&$script) * \$beforeNode. If \$beforeNode is not specified the node will be appended to * the end of the child nodes. * - * @param ".$this->getStubNodeBuilder()->getClassname()." \$node Node to add. - * @param ".$this->getStubNodeBuilder()->getClassname()." \$beforeNode Node to insert before. + * @param " . $this->getStubNodeBuilder()->getClassname() . " \$node Node to add. + * @param " . $this->getStubNodeBuilder()->getClassname() . " \$beforeNode Node to insert before. * @param PropelPDO \$con Connection to use. */ public function addChildNode(\$node, \$beforeNode = null, PropelPDO \$con = null) @@ -697,7 +704,7 @@ protected function addMoveChildNode(&$script) /** * Moves the specified child node in the specified direction. * - * @param ".$this->getStubNodeBuilder()->getClassname()." \$node Node to move. + * @param " . $this->getStubNodeBuilder()->getClassname() . " \$node Node to move. * @param int \$direction Number of spaces to move among siblings (may be negative). * @param PropelPDO \$con Connection to use. * @throws PropelException @@ -891,7 +898,7 @@ protected function addDetachChildNode(&$script) /** * This method is used internally when deleting nodes. It is used to break * the link to this between this node and the specified child. - * @param ".$this->getStubNodeBuilder()->getClassname()." \$node Child node to detach. + * @param " . $this->getStubNodeBuilder()->getClassname() . " \$node Child node to detach. * @return void * @throws PropelException */ @@ -1065,5 +1072,4 @@ protected function adjustNodePath(\$oldBasePath, \$newBasePath) } "; } - } // PHP5NodeObjectBuilder diff --git a/generator/lib/builder/om/PHP5NodePeerBuilder.php b/generator/lib/builder/om/PHP5NodePeerBuilder.php index 0fb493da8..9ce3c580d 100644 --- a/generator/lib/builder/om/PHP5NodePeerBuilder.php +++ b/generator/lib/builder/om/PHP5NodePeerBuilder.php @@ -24,6 +24,7 @@ class PHP5NodePeerBuilder extends PeerBuilder /** * Gets the package for the [base] object classes. + * * @return string */ public function getPackage() @@ -33,6 +34,7 @@ public function getPackage() /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -42,6 +44,7 @@ public function getUnprefixedClassname() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) @@ -50,6 +53,7 @@ protected function addIncludes(&$script) /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -74,15 +78,16 @@ protected function addClassOpen(&$script) *"; } $script .= " - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */ -abstract class ".$this->getClassname()." { +abstract class " . $this->getClassname() . " { "; } /** * Specifies the methods that are added as part of the basic OM class. * This can be overridden by subclasses that wish to add more methods. + * * @see ObjectBuilder::addClassBody() */ protected function addClassBody(&$script) @@ -108,11 +113,11 @@ protected function addClassBody(&$script) $this->addBuildTree($script); $this->addPopulateNodes($script); - } /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) @@ -271,7 +276,6 @@ protected function addRetrieveMethods(&$script) $this->addRetrieveNodeByPK($script); $this->addRetrieveNodeByNP($script); $this->addRetrieveRootNode($script); - } protected function addRetrieveNodes(&$script) @@ -293,7 +297,7 @@ protected function addRetrieveNodes(&$script) public static function retrieveNodes(\$criteria, \$ancestors = false, \$descendants = false, PropelPDO \$con = null) { \$criteria = $nodePeerClassname::buildFamilyCriteria(\$criteria, \$ancestors, \$descendants); - \$stmt = ".$this->getStubPeerBuilder()->getClassname()."::doSelectStmt(\$criteria, \$con); + \$stmt = " . $this->getStubPeerBuilder()->getClassname() . "::doSelectStmt(\$criteria, \$con); return self::populateNodes(\$stmt, \$criteria); } @@ -367,7 +371,7 @@ protected function addRetrieveRootNode(&$script) * @param string Node path to retrieve. * @param boolean True if descendants should also be retrieved. * @param PropelPDO Connection to use. - * @return ".$this->getStubNodeBuilder()->getClassname()." + * @return " . $this->getStubNodeBuilder()->getClassname() . " */ public static function retrieveRootNode(\$descendants = false, PropelPDO \$con = null) { @@ -731,5 +735,4 @@ public static function populateNodes(PDOStatement \$stmt, \$criteria) } "; } - } // PHP5NodePeerBuilder diff --git a/generator/lib/builder/om/PHP5ObjectBuilder.php b/generator/lib/builder/om/PHP5ObjectBuilder.php index 820da2618..d61a7400b 100644 --- a/generator/lib/builder/om/PHP5ObjectBuilder.php +++ b/generator/lib/builder/om/PHP5ObjectBuilder.php @@ -24,6 +24,7 @@ class PHP5ObjectBuilder extends ObjectBuilder /** * Gets the package for the [base] object classes. + * * @return string */ public function getPackage() @@ -44,17 +45,19 @@ public function getNamespace() /** * Returns default key type. if not presented in configuration default will be 'TYPE_PHPNAME' + * * @return string */ public function getDefaultKeyType() { $defaultKeyType = $this->getBuildProperty('defaultKeyType') ? $this->getBuildProperty('defaultKeyType') : 'phpName'; - return "TYPE_".strtoupper($defaultKeyType); + return "TYPE_" . strtoupper($defaultKeyType); } /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -102,14 +105,16 @@ protected function validateModel() foreach ($table->getForeignKeys() as $fk) { if ($fk->isMatchedByInverseFK()) { - throw new EngineException("The 1:1 relationship expressed by foreign key " . $fk->getName() . " is defined in both directions; Propel does not currently support this (if you must have both foreign key constraints, consider adding this constraint with a custom SQL file.)" ); + throw new EngineException("The 1:1 relationship expressed by foreign key " . $fk->getName() . " is defined in both directions; Propel does not currently support this (if you must have both foreign key constraints, consider adding this constraint with a custom SQL file.)"); } } } /** * Returns the appropriate formatter (from platform) for a date/time column. + * * @param Column $col + * * @return string */ protected function getTemporalFormatter(Column $col) @@ -129,6 +134,7 @@ protected function getTemporalFormatter(Column $col) /** * Returns the type-casted and stringified default value for the specified Column. * This only works for scalar default values currently. + * * @return string The default value or 'null' if there is none. * @throws EngineException */ @@ -142,8 +148,7 @@ protected function getDefaultValueString(Column $col) if ($col->isTemporalType()) { $fmt = $this->getTemporalFormatter($col); try { - if (!($this->getPlatform() instanceof MysqlPlatform && - ($val === '0000-00-00 00:00:00' || $val === '0000-00-00'))) { + if (!($this->getPlatform() instanceof MysqlPlatform && ($val === '0000-00-00 00:00:00' || $val === '0000-00-00'))) { // while technically this is not a default value of null, // this seems to be closest in meaning. $defDt = new DateTime($val); @@ -164,7 +169,7 @@ protected function getDefaultValueString(Column $col) settype($val, $col->getPhpType()); $defaultValue = var_export($val, true); } elseif ($col->isPhpObjectType()) { - $defaultValue = 'new '.$col->getPhpType().'(' . var_export($val, true) . ')'; + $defaultValue = 'new ' . $col->getPhpType() . '(' . var_export($val, true) . ')'; } elseif ($col->isPhpArrayType()) { $defaultValue = var_export($val, true); } else { @@ -176,6 +181,7 @@ protected function getDefaultValueString(Column $col) /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) @@ -184,6 +190,7 @@ protected function addIncludes(&$script) /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -219,12 +226,12 @@ protected function addClassOpen(&$script) *"; } $script .= " - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */"; } $script .= " -abstract class ".$this->getClassname()." extends ".$parentClass." "; +abstract class " . $this->getClassname() . " extends " . $parentClass . " "; if ($interface = $this->getTable()->getInterface()) { $script .= "implements " . ClassTools::classname($interface); @@ -245,6 +252,7 @@ abstract class ".$this->getClassname()." extends ".$parentClass." "; /** * Specifies the methods that are added as part of the basic OM class. * This can be overridden by subclasses that wish to add more methods. + * * @see ObjectBuilder::addClassBody() */ protected function addClassBody(&$script) @@ -252,11 +260,7 @@ protected function addClassBody(&$script) $this->declareClassFromBuilder($this->getStubObjectBuilder()); $this->declareClassFromBuilder($this->getStubPeerBuilder()); $this->declareClassFromBuilder($this->getStubQueryBuilder()); - $this->declareClasses( - 'Propel', 'PropelException', 'PDO', 'PropelPDO', 'PropelQuery', 'Criteria', - 'Persistent', 'BasePeer', 'PropelCollection', - 'PropelObjectCollection', 'Exception' - ); + $this->declareClasses('Propel', 'PropelException', 'PDO', 'PropelPDO', 'PropelQuery', 'Criteria', 'Persistent', 'BasePeer', 'PropelCollection', 'PropelObjectCollection', 'Exception'); $table = $this->getTable(); if (!$table->isAlias()) { @@ -340,6 +344,7 @@ protected function addClassBody(&$script) /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) @@ -352,6 +357,7 @@ protected function addClassClose(&$script) /** * Adds any constants to the class. + * * @param string &$script The script will be modified in this method. */ protected function addConstants(&$script) @@ -366,6 +372,7 @@ protected function addConstants(&$script) /** * Adds class attributes. + * * @param string &$script The script will be modified in this method. */ protected function addAttributes(&$script) @@ -377,7 +384,7 @@ protected function addAttributes(&$script) * The Peer class. * Instance provides a convenient way of calling static methods on a class * that calling code may not be able to identify. - * @var ".$this->getPeerClassname()." + * @var " . $this->getPeerClassname() . " */ protected static \$peer; @@ -401,8 +408,8 @@ protected function addAttributes(&$script) // many-to-many relationships foreach ($table->getCrossFks() as $fkList) { - $crossFK = $fkList[1]; - $this->addCrossFKAttributes($script, $crossFK); + $crossFK = $fkList[1]; + $this->addCrossFKAttributes($script, $crossFK); } $this->addAlreadyInSaveAttribute($script); @@ -415,7 +422,9 @@ protected function addAttributes(&$script) /** * Adds variables that store column values. + * * @param string &$script The script will be modified in this method. + * * @see addColumnNameConstants() */ protected function addColumnAttributes(&$script) @@ -426,7 +435,7 @@ protected function addColumnAttributes(&$script) foreach ($table->getColumns() as $col) { $this->addColumnAttributeComment($script, $col); $this->addColumnAttributeDeclaration($script, $col); - if ($col->isLazyLoad() ) { + if ($col->isLazyLoad()) { $this->addColumnAttributeLoaderComment($script, $col); $this->addColumnAttributeLoaderDeclaration($script, $col); } @@ -439,6 +448,7 @@ protected function addColumnAttributes(&$script) /** * Add comment about the attribute (variable) that stores column values + * * @param string &$script The script will be modified in this method. * @param Column $col **/ @@ -453,10 +463,10 @@ protected function addColumnAttributeComment(&$script, Column $col) if ($col->getDefaultValue()) { if ($col->getDefaultValue()->isExpression()) { $script .= " - * Note: this column has a database default value of: (expression) ".$col->getDefaultValue()->getValue(); + * Note: this column has a database default value of: (expression) " . $col->getDefaultValue()->getValue(); } else { $script .= " - * Note: this column has a database default value of: ". $this->getDefaultValueString($col); + * Note: this column has a database default value of: " . $this->getDefaultValueString($col); } } $script .= " @@ -466,6 +476,7 @@ protected function addColumnAttributeComment(&$script, Column $col) /** * Adds the declaration of a column value storage attribute + * * @param string &$script The script will be modified in this method. * @param Column $col **/ @@ -479,6 +490,7 @@ protected function addColumnAttributeDeclaration(&$script, Column $col) /** * Adds the comment about the attribute keeping track if an attribute value has been loaded + * * @param string &$script The script will be modified in this method. * @param Column $col **/ @@ -495,6 +507,7 @@ protected function addColumnAttributeLoaderComment(&$script, Column $col) /** * Adds the declaration of the attribute keeping track of an attribute's loaded state + * * @param string &$script The script will be modified in this method. * @param Column $col **/ @@ -502,12 +515,13 @@ protected function addColumnAttributeLoaderDeclaration(&$script, Column $col) { $clo = strtolower($col->getName()); $script .= " - protected \$".$clo."_isLoaded = false; + protected \$" . $clo . "_isLoaded = false; "; } /** * Adds the comment about the serialized attribute + * * @param string &$script The script will be modified in this method. * @param Column $col **/ @@ -524,6 +538,7 @@ protected function addColumnAttributeUnserializedComment(&$script, Column $col) /** * Adds the declaration of the serialized attribute + * * @param string &$script The script will be modified in this method. * @param Column $col **/ @@ -538,6 +553,7 @@ protected function addColumnAttributeUnserializedDeclaration(&$script, Column $c /** * Adds the getPeer() method. * This is a convenient, non introspective way of getting the Peer class for a particular object. + * * @param string &$script The script will be modified in this method. */ protected function addGetPeer(&$script) @@ -550,6 +566,7 @@ protected function addGetPeer(&$script) /** * Add the comment for the getPeer method + * * @param string &$script The script will be modified in this method. **/ protected function addGetPeerComment(&$script) @@ -562,12 +579,13 @@ protected function addGetPeerComment(&$script) * same instance for all member of this class. The method could therefore * be static, but this would prevent one from overriding the behavior. * - * @return ".$this->getPeerClassname()." + * @return " . $this->getPeerClassname() . " */"; } /** * Adds the function declaration (function opening) for the getPeer method + * * @param string &$script The script will be modified in this method. **/ protected function addGetPeerFunctionOpen(&$script) @@ -579,6 +597,7 @@ public function getPeer() /** * Adds the body of the getPeer method + * * @param string &$script The script will be modified in this method. **/ protected function addGetPeerFunctionBody(&$script) @@ -594,6 +613,7 @@ protected function addGetPeerFunctionBody(&$script) /** * Add the function close for the getPeer method * Note: this is just a } and the body ends with a return statement, so it's quite useless. But it's here anyway for consistency, cause there's a close function for all functions and in some other instances, they are useful + * * @param string &$script The script will be modified in this method. **/ protected function addGetPeerFunctionClose(&$script) @@ -605,7 +625,9 @@ protected function addGetPeerFunctionClose(&$script) /** * Adds the constructor for this object. + * * @param string &$script The script will be modified in this method. + * * @see addConstructor() */ protected function addConstructor(&$script) @@ -618,19 +640,21 @@ protected function addConstructor(&$script) /** * Adds the comment for the constructor + * * @param string &$script The script will be modified in this method. **/ protected function addConstructorComment(&$script) { $script .= " /** - * Initializes internal state of ".$this->getClassname()." object. + * Initializes internal state of " . $this->getClassname() . " object. * @see applyDefaults() */"; } /** * Adds the function declaration for the constructor + * * @param string &$script The script will be modified in this method. **/ protected function addConstructorOpen(&$script) @@ -642,6 +666,7 @@ public function __construct() /** * Adds the function body for the constructor + * * @param string &$script The script will be modified in this method. **/ protected function addConstructorBody(&$script) @@ -653,6 +678,7 @@ protected function addConstructorBody(&$script) /** * Adds the function close for the constructor + * * @param string &$script The script will be modified in this method. **/ protected function addConstructorClose(&$script) @@ -664,7 +690,9 @@ protected function addConstructorClose(&$script) /** * Adds the applyDefaults() method, which is called from the constructor. + * * @param string &$script The script will be modified in this method. + * * @see addConstructor() */ protected function addApplyDefaultValues(&$script) @@ -677,7 +705,9 @@ protected function addApplyDefaultValues(&$script) /** * Adds the comment for the applyDefaults method + * * @param string &$script The script will be modified in this method. + * * @see addApplyDefaultValues() **/ protected function addApplyDefaultValuesComment(&$script) @@ -693,7 +723,9 @@ protected function addApplyDefaultValuesComment(&$script) /** * Adds the function declaration for the applyDefaults method + * * @param string &$script The script will be modified in this method. + * * @see addApplyDefaultValues() **/ protected function addApplyDefaultValuesOpen(&$script) @@ -705,7 +737,9 @@ public function applyDefaultValues() /** * Adds the function body of the applyDefault method + * * @param string &$script The script will be modified in this method. + * * @see addApplyDefaultValues() **/ protected function addApplyDefaultValuesBody(&$script) @@ -727,14 +761,16 @@ protected function addApplyDefaultValuesBody(&$script) $clo = strtolower($col->getName()); $defaultValue = $this->getDefaultValueString($col); $script .= " - \$this->".$clo." = $defaultValue;"; + \$this->" . $clo . " = $defaultValue;"; } } /** * Adds the function close for the applyDefaults method + * * @param string &$script The script will be modified in this method. + * * @see addApplyDefaultValues() **/ protected function addApplyDefaultValuesClose(&$script) @@ -752,8 +788,10 @@ protected function addApplyDefaultValuesClose(&$script) /** * Adds a date/time/timestamp getter method. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see parent::addColumnAccessors() */ protected function addTemporalAccessor(&$script, Column $col) @@ -767,8 +805,10 @@ protected function addTemporalAccessor(&$script, Column $col) /** * Adds the comment for a temporal accessor + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addTemporalAccessor **/ public function addTemporalAccessorComment(&$script, Column $col) @@ -796,7 +836,7 @@ public function addTemporalAccessorComment(&$script, Column $col) $script .= " /** * Get the [optionally formatted] temporal [$clo] column value. - * ".$col->getDescription(); + * " . $col->getDescription(); if (!$useDateTime) { $script .= " * This accessor only only work with unix epoch dates. Consider enabling the propel.useDateTimeClass @@ -805,13 +845,13 @@ public function addTemporalAccessorComment(&$script, Column $col) $script .= " * * @param string \$format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw ".($useDateTime ? 'DateTime object' : 'unix timestamp integer')." will be returned."; + * If format is null, then the raw " . ($useDateTime ? 'DateTime object' : 'unix timestamp integer') . " will be returned."; if ($useDateTime) { $script .= " - * @return mixed Formatted date/time value as string or $dateTimeClass object (if format is null), null if column is null" .($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : ''); + * @return mixed Formatted date/time value as string or $dateTimeClass object (if format is null), null if column is null" . ($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : ''); } else { $script .= " - * @return mixed Formatted date/time value as string or (integer) unix timestamp (if format is null), null if column is null".($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : ''); + * @return mixed Formatted date/time value as string or (integer) unix timestamp (if format is null), null if column is null" . ($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : ''); } $script .= " * @throws PropelException - if unable to parse/validate the date/time value. @@ -821,8 +861,10 @@ public function addTemporalAccessorComment(&$script, Column $col) /** * Adds the function declaration for a temporal accessor + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addTemporalAccessor **/ public function addTemporalAccessorOpen(&$script, Column $col) @@ -848,8 +890,10 @@ public function addTemporalAccessorOpen(&$script, Column $col) } $script .= " - ".$visibility." function get$cfc(\$format = ".$defaultfmt.""; - if ($col->isLazyLoad()) $script .= ", \$con = null"; + " . $visibility . " function get$cfc(\$format = " . $defaultfmt . ""; + if ($col->isLazyLoad()) { + $script .= ", \$con = null"; + } $script .= ") {"; } @@ -874,8 +918,10 @@ protected function getAccessorLazyLoadSnippet(Column $col) /** * Adds the body of the temporal accessor + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addTemporalAccessor **/ protected function addTemporalAccessorBody(&$script, Column $col) @@ -975,8 +1021,10 @@ protected function addTemporalAccessorBody(&$script, Column $col) /** * Adds the body of the temporal accessor + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addTemporalAccessorClose **/ protected function addTemporalAccessorClose(&$script, Column $col) @@ -988,8 +1036,10 @@ protected function addTemporalAccessorClose(&$script, Column $col) /** * Adds an object getter method. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see parent::addColumnAccessors() */ protected function addObjectAccessor(&$script, Column $col) @@ -1002,15 +1052,17 @@ protected function addObjectAccessor(&$script, Column $col) /** * Adds the function body for an object accessor method + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addDefaultAccessor() **/ protected function addObjectAccessorBody(&$script, Column $col) { $cfc = $col->getPhpName(); $clo = strtolower($col->getName()); - $cloUnserialized = $clo.'_unserialized'; + $cloUnserialized = $clo . '_unserialized'; if ($col->isLazyLoad()) { $script .= $this->getAccessorLazyLoadSnippet($col); } @@ -1025,8 +1077,10 @@ protected function addObjectAccessorBody(&$script, Column $col) /** * Adds an array getter method. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see parent::addColumnAccessors() */ protected function addArrayAccessor(&$script, Column $col) @@ -1039,15 +1093,17 @@ protected function addArrayAccessor(&$script, Column $col) /** * Adds the function body for an array accessor method + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addDefaultAccessor() **/ protected function addArrayAccessorBody(&$script, Column $col) { $cfc = $col->getPhpName(); $clo = strtolower($col->getName()); - $cloUnserialized = $clo.'_unserialized'; + $cloUnserialized = $clo . '_unserialized'; if ($col->isLazyLoad()) { $script .= $this->getAccessorLazyLoadSnippet($col); } @@ -1066,8 +1122,10 @@ protected function addArrayAccessorBody(&$script, Column $col) /** * Adds an enum getter method. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see parent::addColumnAccessors() */ protected function addEnumAccessor(&$script, Column $col) @@ -1076,13 +1134,13 @@ protected function addEnumAccessor(&$script, Column $col) $script .= " /** * Get the [$clo] column value. - * ".$col->getDescription(); + * " . $col->getDescription(); if ($col->isLazyLoad()) { $script .= " * @param PropelPDO \$con An optional PropelPDO connection to use for fetching this lazy-loaded column."; } $script .= " - * @return ".$col->getPhpType()." + * @return " . $col->getPhpType() . " * @throws PropelException - if the stored enum key is unknown. */"; @@ -1093,8 +1151,10 @@ protected function addEnumAccessor(&$script, Column $col) /** * Adds the function body for an enum accessor method + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addDefaultAccessor() **/ protected function addEnumAccessorBody(&$script, Column $col) @@ -1119,6 +1179,7 @@ protected function addEnumAccessorBody(&$script, Column $col) /** * Adds a tester method for an array column. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. */ @@ -1132,7 +1193,7 @@ protected function addHasArrayElement(&$script, Column $col) /** * Test the presence of a value in the [$clo] array column value. * @param mixed \$value - * ".$col->getDescription(); + * " . $col->getDescription(); if ($col->isLazyLoad()) { $script .= " * @param PropelPDO \$con An optional PropelPDO connection to use for fetching this lazy-loaded column."; @@ -1141,11 +1202,15 @@ protected function addHasArrayElement(&$script, Column $col) * @return boolean */ $visibility function has$singularPhpName(\$value"; - if ($col->isLazyLoad()) $script .= ", PropelPDO \$con = null"; + if ($col->isLazyLoad()) { + $script .= ", PropelPDO \$con = null"; + } $script .= ") { return in_array(\$value, \$this->get$cfc("; - if ($col->isLazyLoad()) $script .= "\$con"; + if ($col->isLazyLoad()) { + $script .= "\$con"; + } $script .= ")); } // has$singularPhpName() "; @@ -1153,8 +1218,10 @@ protected function addHasArrayElement(&$script, Column $col) /** * Adds a normal (non-temporal) getter method. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see parent::addColumnAccessors() */ protected function addDefaultAccessor(&$script, Column $col) @@ -1167,31 +1234,35 @@ protected function addDefaultAccessor(&$script, Column $col) /** * Add the comment for a default accessor method (a getter) + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addDefaultAccessor() **/ public function addDefaultAccessorComment(&$script, Column $col) { - $clo=strtolower($col->getName()); + $clo = strtolower($col->getName()); $script .= " /** * Get the [$clo] column value. - * ".$col->getDescription(); + * " . $col->getDescription(); if ($col->isLazyLoad()) { $script .= " * @param PropelPDO \$con An optional PropelPDO connection to use for fetching this lazy-loaded column."; } $script .= " - * @return ".$col->getPhpType()." + * @return " . $col->getPhpType() . " */"; } /** * Adds the function declaration for a default accessor + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addDefaultAccessor() **/ public function addDefaultAccessorOpen(&$script, Column $col) @@ -1200,16 +1271,20 @@ public function addDefaultAccessorOpen(&$script, Column $col) $visibility = $col->getAccessorVisibility(); $script .= " - ".$visibility." function get$cfc("; - if ($col->isLazyLoad()) $script .= "PropelPDO \$con = null"; + " . $visibility . " function get$cfc("; + if ($col->isLazyLoad()) { + $script .= "PropelPDO \$con = null"; + } $script .= ") {"; } /** * Adds the function body for a default accessor method + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addDefaultAccessor() **/ protected function addDefaultAccessorBody(&$script, Column $col) @@ -1227,8 +1302,10 @@ protected function addDefaultAccessorBody(&$script, Column $col) /** * Adds the function close for a default accessor method + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addDefaultAccessor() **/ protected function addDefaultAccessorClose(&$script, Column $col) @@ -1240,8 +1317,10 @@ protected function addDefaultAccessorClose(&$script, Column $col) /** * Adds the lazy loader method. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see parent::addColumnAccessors() */ protected function addLazyLoader(&$script, Column $col) @@ -1254,8 +1333,10 @@ protected function addLazyLoader(&$script, Column $col) /** * Adds the comment for the lazy loader method + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addLazyLoader() **/ protected function addLazyLoaderComment(&$script, Column $col) @@ -1278,8 +1359,10 @@ protected function addLazyLoaderComment(&$script, Column $col) /** * Adds the function declaration for the lazy loader method + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addLazyLoader() **/ protected function addLazyLoaderOpen(&$script, Column $col) @@ -1292,8 +1375,10 @@ protected function load$cfc(PropelPDO \$con = null) /** * Adds the function body for the lazy loader method + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addLazyLoader() **/ protected function addLazyLoaderBody(&$script, Column $col) @@ -1305,19 +1390,19 @@ protected function addLazyLoaderBody(&$script, Column $col) if ($col->getType() === PropelTypes::BLOB && $platform instanceof SqlsrvPlatform) { $script .= " \$c = \$this->buildPkeyCriteria(); - \$c->addSelectColumn(".$this->getColumnConstant($col)."); + \$c->addSelectColumn(" . $this->getColumnConstant($col) . "); try { \$row = array(0 => null); - \$stmt = ".$this->getPeerClassname()."::doSelectStmt(\$c, \$con); + \$stmt = " . $this->getPeerClassname() . "::doSelectStmt(\$c, \$con); \$stmt->bindColumn(1, \$row[0], PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY); \$stmt->fetch(PDO::FETCH_BOUND); \$stmt->closeCursor();"; } else { $script .= " \$c = \$this->buildPkeyCriteria(); - \$c->addSelectColumn(".$this->getColumnConstant($col)."); + \$c->addSelectColumn(" . $this->getColumnConstant($col) . "); try { - \$stmt = ".$this->getPeerClassname()."::doSelectStmt(\$c, \$con); + \$stmt = " . $this->getPeerClassname() . "::doSelectStmt(\$c, \$con); \$row = \$stmt->fetch(PDO::FETCH_NUM); \$stmt->closeCursor();"; } @@ -1337,17 +1422,17 @@ protected function addLazyLoaderBody(&$script, Column $col) }"; } elseif ($col->isPhpPrimitiveType()) { $script .= " - \$this->$clo = (\$row[0] !== null) ? (".$col->getPhpType().") \$row[0] : null;"; + \$this->$clo = (\$row[0] !== null) ? (" . $col->getPhpType() . ") \$row[0] : null;"; } elseif ($col->isPhpObjectType()) { $script .= " - \$this->$clo = (\$row[0] !== null) ? new ".$col->getPhpType()."(\$row[0]) : null;"; + \$this->$clo = (\$row[0] !== null) ? new " . $col->getPhpType() . "(\$row[0]) : null;"; } else { $script .= " \$this->$clo = \$row[0];"; } $script .= " - \$this->".$clo."_isLoaded = true; + \$this->" . $clo . "_isLoaded = true; } catch (Exception \$e) { throw new PropelException(\"Error loading value for [$clo] column on demand.\", \$e); }"; @@ -1355,8 +1440,10 @@ protected function addLazyLoaderBody(&$script, Column $col) /** * Adds the function close for the lazy loader + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addLazyLoader() **/ protected function addLazyLoaderClose(&$script, Column $col) @@ -1373,6 +1460,7 @@ protected function addLazyLoaderClose(&$script, Column $col) /** * Adds the open of the mutator (setter) method for a column. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. */ @@ -1385,8 +1473,10 @@ protected function addMutatorOpen(&$script, Column $col) /** * Adds the comment for a mutator + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addMutatorOpen() **/ public function addMutatorComment(&$script, Column $col) @@ -1395,16 +1485,18 @@ public function addMutatorComment(&$script, Column $col) $script .= " /** * Set the value of [$clo] column. - * ".$col->getDescription()." - * @param ".$col->getPhpType()." \$v new value - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * " . $col->getDescription() . " + * @param " . $col->getPhpType() . " \$v new value + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) */"; } /** * Adds the mutator function declaration + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addMutatorOpen() **/ public function addMutatorOpenOpen(&$script, Column $col) @@ -1413,14 +1505,16 @@ public function addMutatorOpenOpen(&$script, Column $col) $visibility = $col->getMutatorVisibility(); $script .= " - ".$visibility." function set$cfc(\$v) + " . $visibility . " function set$cfc(\$v) {"; } /** * Adds the mutator open body part + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addMutatorOpen() **/ protected function addMutatorOpenBody(&$script, Column $col) @@ -1430,15 +1524,15 @@ protected function addMutatorOpenBody(&$script, Column $col) if ($col->isLazyLoad()) { $script .= " // Allow unsetting the lazy loaded column even when its not loaded. - if (!\$this->".$clo."_isLoaded && \$v === null) { - \$this->modifiedColumns[] = ".$this->getColumnConstant($col)."; + if (!\$this->" . $clo . "_isLoaded && \$v === null) { + \$this->modifiedColumns[] = " . $this->getColumnConstant($col) . "; } // explicitly set the is-loaded flag to true for this lazy load col; // it doesn't matter if the value is actually set or not (logic below) as // any attempt to set the value means that no db lookup should be performed // when the get$cfc() method is called. - \$this->".$clo."_isLoaded = true; + \$this->" . $clo . "_isLoaded = true; "; } } @@ -1457,8 +1551,10 @@ protected function addMutatorClose(&$script, Column $col) /** * Adds the body of the close part of a mutator + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addMutatorClose() **/ protected function addMutatorCloseBody(&$script, Column $col) @@ -1471,13 +1567,13 @@ protected function addMutatorCloseBody(&$script, Column $col) foreach ($col->getForeignKeys() as $fk) { - $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName()); + $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName()); $colFK = $tblFK->getColumn($fk->getMappedForeignColumn($col->getName())); $varName = $this->getFKVarName($fk); $script .= " - if (\$this->$varName !== null && \$this->".$varName."->get".$colFK->getPhpName()."() !== \$v) { + if (\$this->$varName !== null && \$this->" . $varName . "->get" . $colFK->getPhpName() . "() !== \$v) { \$this->$varName = null; } "; @@ -1488,7 +1584,7 @@ protected function addMutatorCloseBody(&$script, Column $col) $tblFK = $this->getDatabase()->getTable($refFK->getForeignTableName()); - if ( $tblFK->getName() != $table->getName() ) { + if ($tblFK->getName() != $table->getName()) { foreach ($col->getForeignKeys() as $fk) { @@ -1498,19 +1594,19 @@ protected function addMutatorCloseBody(&$script, Column $col) if ($refFK->isLocalPrimaryKey()) { $varName = $this->getPKRefFKVarName($refFK); $script .= " - // update associated ".$tblFK->getPhpName()." + // update associated " . $tblFK->getPhpName() . " if (\$this->$varName !== null) { - \$this->{$varName}->set".$colFK->getPhpName()."(\$v); + \$this->{$varName}->set" . $colFK->getPhpName() . "(\$v); } "; } else { $collName = $this->getRefFKCollVarName($refFK); $script .= " - // update associated ".$tblFK->getPhpName()." + // update associated " . $tblFK->getPhpName() . " if (\$this->$collName !== null) { foreach (\$this->$collName as \$referrerObject) { - \$referrerObject->set".$colFK->getPhpName()."(\$v); + \$referrerObject->set" . $colFK->getPhpName() . "(\$v); } } "; @@ -1523,8 +1619,10 @@ protected function addMutatorCloseBody(&$script, Column $col) /** * Adds the close for the mutator close + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addMutatorClose() **/ protected function addMutatorCloseClose(&$script, Column $col) @@ -1539,8 +1637,10 @@ protected function addMutatorCloseClose(&$script, Column $col) /** * Adds a setter for BLOB columns. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see parent::addColumnMutators() */ protected function addLobMutator(&$script, Column $col) @@ -1558,15 +1658,17 @@ protected function addLobMutator(&$script, Column $col) } else { // it's already a stream \$this->$clo = \$v; } - \$this->modifiedColumns[] = ".$this->getColumnConstant($col)."; + \$this->modifiedColumns[] = " . $this->getColumnConstant($col) . "; "; $this->addMutatorClose($script, $col); } // addLobMutatorSnippet /** * Adds a setter method for date/time/timestamp columns. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see parent::addColumnMutators() */ protected function addTemporalMutator(&$script, Column $col) @@ -1606,7 +1708,7 @@ protected function addTemporalMutator(&$script, Column $col) $script .= " \$this->$clo = \$newDateAsString; - \$this->modifiedColumns[] = ".$this->getColumnConstant($col)."; + \$this->modifiedColumns[] = " . $this->getColumnConstant($col) . "; } } // if either are not null "; @@ -1621,30 +1723,32 @@ public function addTemporalMutatorComment(&$script, Column $col) $script .= " /** * Sets the value of [$clo] column to a normalized version of the date/time value specified. - * ".$col->getDescription()." + * " . $col->getDescription() . " * @param mixed \$v string, integer (timestamp), or DateTime value. * Empty strings are treated as null. - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) */"; } /** * Adds a setter for Object columns. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see parent::addColumnMutators() */ protected function addObjectMutator(&$script, Column $col) { $clo = strtolower($col->getName()); - $cloUnserialized = $clo.'_unserialized'; + $cloUnserialized = $clo . '_unserialized'; $this->addMutatorOpen($script, $col); $script .= " if (\$this->$cloUnserialized !== \$v) { \$this->$cloUnserialized = \$v; \$this->$clo = serialize(\$v); - \$this->modifiedColumns[] = ".$this->getColumnConstant($col)."; + \$this->modifiedColumns[] = " . $this->getColumnConstant($col) . "; } "; $this->addMutatorClose($script, $col); @@ -1652,21 +1756,23 @@ protected function addObjectMutator(&$script, Column $col) /** * Adds a setter for Array columns. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see parent::addColumnMutators() */ protected function addArrayMutator(&$script, Column $col) { $clo = strtolower($col->getName()); - $cloUnserialized = $clo.'_unserialized'; + $cloUnserialized = $clo . '_unserialized'; $this->addMutatorOpen($script, $col); $script .= " if (\$this->$cloUnserialized !== \$v) { \$this->$cloUnserialized = \$v; \$this->$clo = '| ' . implode(' | ', \$v) . ' |'; - \$this->modifiedColumns[] = ".$this->getColumnConstant($col)."; + \$this->modifiedColumns[] = " . $this->getColumnConstant($col) . "; } "; $this->addMutatorClose($script, $col); @@ -1674,6 +1780,7 @@ protected function addArrayMutator(&$script, Column $col) /** * Adds a push method for an array column. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. */ @@ -1687,20 +1794,24 @@ protected function addAddArrayElement(&$script, Column $col) /** * Adds a value to the [$clo] array column value. * @param mixed \$value - * ".$col->getDescription(); + * " . $col->getDescription(); if ($col->isLazyLoad()) { $script .= " * @param PropelPDO \$con An optional PropelPDO connection to use for fetching this lazy-loaded column."; } $script .= " - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) */ $visibility function add$singularPhpName(\$value"; - if ($col->isLazyLoad()) $script .= ", PropelPDO \$con = null"; + if ($col->isLazyLoad()) { + $script .= ", PropelPDO \$con = null"; + } $script .= ") { \$currentArray = \$this->get$cfc("; - if ($col->isLazyLoad()) $script .= "\$con"; + if ($col->isLazyLoad()) { + $script .= "\$con"; + } $script .= "); \$currentArray []= \$value; \$this->set$cfc(\$currentArray); @@ -1712,6 +1823,7 @@ protected function addAddArrayElement(&$script, Column $col) /** * Adds a remove method for an array column. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. */ @@ -1725,22 +1837,26 @@ protected function addRemoveArrayElement(&$script, Column $col) /** * Removes a value from the [$clo] array column value. * @param mixed \$value - * ".$col->getDescription(); + * " . $col->getDescription(); if ($col->isLazyLoad()) { $script .= " * @param PropelPDO \$con An optional PropelPDO connection to use for fetching this lazy-loaded column."; } $script .= " - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) */ $visibility function remove$singularPhpName(\$value"; - if ($col->isLazyLoad()) $script .= ", PropelPDO \$con = null"; + if ($col->isLazyLoad()) { + $script .= ", PropelPDO \$con = null"; + } // we want to reindex the array, so array_ functions are not the best choice $script .= ") { \$targetArray = array(); foreach (\$this->get$cfc("; - if ($col->isLazyLoad()) $script .= "\$con"; + if ($col->isLazyLoad()) { + $script .= "\$con"; + } $script .= ") as \$element) { if (\$element != \$value) { \$targetArray []= \$element; @@ -1755,8 +1871,10 @@ protected function addRemoveArrayElement(&$script, Column $col) /** * Adds a setter for Enum columns. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see parent::addColumnMutators() */ protected function addEnumMutator(&$script, Column $col) @@ -1766,9 +1884,9 @@ protected function addEnumMutator(&$script, Column $col) $script .= " /** * Set the value of [$clo] column. - * ".$col->getDescription()." - * @param ".$col->getPhpType()." \$v new value - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * " . $col->getDescription() . " + * @param " . $col->getPhpType() . " \$v new value + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) * @throws PropelException - if the value is not accepted by this enum. */"; $this->addMutatorOpenOpen($script, $col); @@ -1785,7 +1903,7 @@ protected function addEnumMutator(&$script, Column $col) if (\$this->$clo !== \$v) { \$this->$clo = \$v; - \$this->modifiedColumns[] = ".$this->getColumnConstant($col)."; + \$this->modifiedColumns[] = " . $this->getColumnConstant($col) . "; } "; $this->addMutatorClose($script, $col); @@ -1793,8 +1911,10 @@ protected function addEnumMutator(&$script, Column $col) /** * Adds setter method for boolean columns. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see parent::addColumnMutators() */ protected function addBooleanMutator(&$script, Column $col) @@ -1805,7 +1925,7 @@ protected function addBooleanMutator(&$script, Column $col) $this->addMutatorOpenOpen($script, $col); $this->addMutatorOpenBody($script, $col); - $script .= " + $script .= " if (\$v !== null) { if (is_string(\$v)) { \$v = in_array(strtolower(\$v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; @@ -1818,7 +1938,7 @@ protected function addBooleanMutator(&$script, Column $col) $script .= " if (\$this->$clo !== \$v) { \$this->$clo = \$v; - \$this->modifiedColumns[] = ".$this->getColumnConstant($col)."; + \$this->modifiedColumns[] = " . $this->getColumnConstant($col) . "; } "; $this->addMutatorClose($script, $col); @@ -1836,16 +1956,18 @@ public function addBooleanMutatorComment(&$script, Column $col) * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true * * 0, '0', 'false', 'off', and 'no' are converted to boolean false * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). - * ".$col->getDescription()." + * " . $col->getDescription() . " * @param boolean|integer|string \$v The new value - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) */"; } /** * Adds setter method for "normal" columns. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see parent::addColumnMutators() */ protected function addDefaultMutator(&$script, Column $col) @@ -1859,7 +1981,7 @@ protected function addDefaultMutator(&$script, Column $col) if ($col->isPhpPrimitiveType()) { $script .= " if (\$v !== null && is_numeric(\$v)) { - \$v = (".$col->getPhpType().") \$v; + \$v = (" . $col->getPhpType() . ") \$v; } "; } @@ -1867,7 +1989,7 @@ protected function addDefaultMutator(&$script, Column $col) $script .= " if (\$this->$clo !== \$v) { \$this->$clo = \$v; - \$this->modifiedColumns[] = ".$this->getColumnConstant($col)."; + \$this->modifiedColumns[] = " . $this->getColumnConstant($col) . "; } "; $this->addMutatorClose($script, $col); @@ -1875,6 +1997,7 @@ protected function addDefaultMutator(&$script, Column $col) /** * Adds the hasOnlyDefaultValues() method. + * * @param string &$script The script will be modified in this method. */ protected function addHasOnlyDefaultValues(&$script) @@ -1887,7 +2010,9 @@ protected function addHasOnlyDefaultValues(&$script) /** * Adds the comment for the hasOnlyDefaultValues method + * * @param string &$script The script will be modified in this method. + * * @see addHasOnlyDefaultValues **/ protected function addHasOnlyDefaultValuesComment(&$script) @@ -1905,7 +2030,9 @@ protected function addHasOnlyDefaultValuesComment(&$script) /** * Adds the function declaration for the hasOnlyDefaultValues method + * * @param string &$script The script will be modified in this method. + * * @see addHasOnlyDefaultValues **/ protected function addHasOnlyDefaultValuesOpen(&$script) @@ -1917,7 +2044,9 @@ public function hasOnlyDefaultValues() /** * Adds the function body for the hasOnlyDefaultValues method + * * @param string &$script The script will be modified in this method. + * * @see addHasOnlyDefaultValues **/ protected function addHasOnlyDefaultValuesBody(&$script) @@ -1937,7 +2066,7 @@ protected function addHasOnlyDefaultValuesBody(&$script) $def = $col->getDefaultValue(); $script .= " - if (\$this->$clo !== " . $this->getDefaultValueString($col).") { + if (\$this->$clo !== " . $this->getDefaultValueString($col) . ") { return false; } "; @@ -1946,7 +2075,9 @@ protected function addHasOnlyDefaultValuesBody(&$script) /** * Adds the function close for the hasOnlyDefaultValues method + * * @param string &$script The script will be modified in this method. + * * @see addHasOnlyDefaultValues **/ protected function addHasOnlyDefaultValuesClose(&$script) @@ -1961,6 +2092,7 @@ protected function addHasOnlyDefaultValuesClose(&$script) /** * Adds the hydrate() method, which sets attributes of the object based on a ResultSet. + * * @param string &$script The script will be modified in this method. */ protected function addHydrate(&$script) @@ -1973,7 +2105,9 @@ protected function addHydrate(&$script) /** * Adds the comment for the hydrate method + * * @param string &$script The script will be modified in this method. + * * @see addHydrate() */ protected function addHydrateComment(&$script) @@ -1997,7 +2131,9 @@ protected function addHydrateComment(&$script) /** * Adds the function declaration for the hydrate method + * * @param string &$script The script will be modified in this method. + * * @see addHydrate() */ protected function addHydrateOpen(&$script) @@ -2009,7 +2145,9 @@ public function hydrate(\$row, \$startcol = 0, \$rehydrate = false) /** * Adds the function body for the hydrate method + * * @param string &$script The script will be modified in this method. + * * @see addHydrate() */ protected function addHydrateBody(&$script) @@ -2038,7 +2176,7 @@ protected function addHydrateBody(&$script) }"; } elseif ($col->isPhpPrimitiveType()) { $script .= " - \$this->$clo = (\$row[\$startcol + $n] !== null) ? (".$col->getPhpType().") \$row[\$startcol + $n] : null;"; + \$this->$clo = (\$row[\$startcol + $n] !== null) ? (" . $col->getPhpType() . ") \$row[\$startcol + $n] : null;"; } elseif ($col->getType() === PropelTypes::OBJECT) { $script .= " \$this->$clo = \$row[\$startcol + $n];"; @@ -2049,7 +2187,7 @@ protected function addHydrateBody(&$script) \$this->$cloUnserialized = null;"; } elseif ($col->isPhpObjectType()) { $script .= " - \$this->$clo = (\$row[\$startcol + $n] !== null) ? new ".$col->getPhpType()."(\$row[\$startcol + $n]) : null;"; + \$this->$clo = (\$row[\$startcol + $n] !== null) ? new " . $col->getPhpType() . "(\$row[\$startcol + $n]) : null;"; } else { $script .= " \$this->$clo = \$row[\$startcol + $n];"; @@ -2076,16 +2214,18 @@ protected function addHydrateBody(&$script) $script .= " - return \$startcol + $n; // $n = ".$this->getPeerClassname()."::NUM_HYDRATE_COLUMNS. + return \$startcol + $n; // $n = " . $this->getPeerClassname() . "::NUM_HYDRATE_COLUMNS. } catch (Exception \$e) { - throw new PropelException(\"Error populating ".$this->getStubObjectBuilder()->getClassname()." object\", \$e); + throw new PropelException(\"Error populating " . $this->getStubObjectBuilder()->getClassname() . " object\", \$e); }"; } /** * Adds the function close for the hydrate method + * * @param string &$script The script will be modified in this method. + * * @see addHydrate() */ protected function addHydrateClose(&$script) @@ -2097,6 +2237,7 @@ protected function addHydrateClose(&$script) /** * Adds the buildPkeyCriteria method + * * @param string &$script The script will be modified in this method. **/ protected function addBuildPkeyCriteria(&$script) @@ -2109,7 +2250,9 @@ protected function addBuildPkeyCriteria(&$script) /** * Adds the comment for the buildPkeyCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildPkeyCriteria() **/ protected function addBuildPkeyCriteriaComment(&$script) @@ -2127,7 +2270,9 @@ protected function addBuildPkeyCriteriaComment(&$script) /** * Adds the function declaration for the buildPkeyCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildPkeyCriteria() **/ protected function addBuildPkeyCriteriaOpen(&$script) @@ -2139,23 +2284,27 @@ public function buildPkeyCriteria() /** * Adds the function body for the buildPkeyCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildPkeyCriteria() **/ protected function addBuildPkeyCriteriaBody(&$script) { $script .= " - \$criteria = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME);"; + \$criteria = new Criteria(" . $this->getPeerClassname() . "::DATABASE_NAME);"; foreach ($this->getTable()->getPrimaryKey() as $col) { $clo = strtolower($col->getName()); $script .= " - \$criteria->add(".$this->getColumnConstant($col).", \$this->$clo);"; + \$criteria->add(" . $this->getColumnConstant($col) . ", \$this->$clo);"; } } /** * Adds the function close for the buildPkeyCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildPkeyCriteria() **/ protected function addBuildPkeyCriteriaClose(&$script) @@ -2169,6 +2318,7 @@ protected function addBuildPkeyCriteriaClose(&$script) /** * Adds the buildCriteria method + * * @param string &$script The script will be modified in this method. **/ protected function addBuildCriteria(&$script) @@ -2181,7 +2331,9 @@ protected function addBuildCriteria(&$script) /** * Adds comment for the buildCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildCriteria() **/ protected function addBuildCriteriaComment(&$script) @@ -2196,7 +2348,9 @@ protected function addBuildCriteriaComment(&$script) /** * Adds the function declaration of the buildCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildCriteria() **/ protected function addBuildCriteriaOpen(&$script) @@ -2208,24 +2362,28 @@ public function buildCriteria() /** * Adds the function body of the buildCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildCriteria() **/ protected function addBuildCriteriaBody(&$script) { $script .= " - \$criteria = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME); + \$criteria = new Criteria(" . $this->getPeerClassname() . "::DATABASE_NAME); "; foreach ($this->getTable()->getColumns() as $col) { $clo = strtolower($col->getName()); $script .= " - if (\$this->isColumnModified(".$this->getColumnConstant($col).")) \$criteria->add(".$this->getColumnConstant($col).", \$this->$clo);"; + if (\$this->isColumnModified(" . $this->getColumnConstant($col) . ")) \$criteria->add(" . $this->getColumnConstant($col) . ", \$this->$clo);"; } } /** * Adds the function close of the buildCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildCriteria() **/ protected function addBuildCriteriaClose(&$script) @@ -2239,6 +2397,7 @@ protected function addBuildCriteriaClose(&$script) /** * Adds the toArray method + * * @param string &$script The script will be modified in this method. **/ protected function addToArray(&$script) @@ -2275,15 +2434,15 @@ public function toArray(\$keyType = BasePeer::$defaultKeyType, \$includeLazyLoad return '*RECURSION*'; } \$alreadyDumpedObjects['$objectClassName'][$pkGetter] = true; - \$keys = ".$this->getPeerClassname()."::getFieldNames(\$keyType); + \$keys = " . $this->getPeerClassname() . "::getFieldNames(\$keyType); \$result = array("; foreach ($this->getTable()->getColumns() as $num => $col) { if ($col->isLazyLoad()) { $script .= " - \$keys[$num] => (\$includeLazyLoadColumns) ? \$this->get".$col->getPhpName()."() : null,"; + \$keys[$num] => (\$includeLazyLoadColumns) ? \$this->get" . $col->getPhpName() . "() : null,"; } else { $script .= " - \$keys[$num] => \$this->get".$col->getPhpName()."(),"; + \$keys[$num] => \$this->get" . $col->getPhpName() . "(),"; } } $script .= " @@ -2322,6 +2481,7 @@ public function toArray(\$keyType = BasePeer::$defaultKeyType, \$includeLazyLoad /** * Adds the getByName method + * * @param string &$script The script will be modified in this method. **/ protected function addGetByName(&$script) @@ -2334,7 +2494,9 @@ protected function addGetByName(&$script) /** * Adds the comment for the getByName method + * * @param string &$script The script will be modified in this method. + * * @see addGetByName **/ protected function addGetByNameComment(&$script) @@ -2355,7 +2517,9 @@ protected function addGetByNameComment(&$script) /** * Adds the function declaration for the getByName method + * * @param string &$script The script will be modified in this method. + * * @see addGetByName **/ protected function addGetByNameOpen(&$script) @@ -2368,19 +2532,23 @@ public function getByName(\$name, \$type = BasePeer::$defaultKeyType) /** * Adds the function body for the getByName method + * * @param string &$script The script will be modified in this method. + * * @see addGetByName **/ protected function addGetByNameBody(&$script) { $script .= " - \$pos = ".$this->getPeerClassname()."::translateFieldName(\$name, \$type, BasePeer::TYPE_NUM); + \$pos = " . $this->getPeerClassname() . "::translateFieldName(\$name, \$type, BasePeer::TYPE_NUM); \$field = \$this->getByPosition(\$pos);"; } /** * Adds the function close for the getByName method + * * @param string &$script The script will be modified in this method. + * * @see addGetByName **/ protected function addGetByNameClose(&$script) @@ -2394,6 +2562,7 @@ protected function addGetByNameClose(&$script) /** * Adds the getByPosition method + * * @param string &$script The script will be modified in this method. **/ protected function addGetByPosition(&$script) @@ -2406,7 +2575,9 @@ protected function addGetByPosition(&$script) /** * Adds comment for the getByPosition method + * * @param string &$script The script will be modified in this method. + * * @see addGetByPosition **/ protected function addGetByPositionComment(&$script) @@ -2423,7 +2594,9 @@ protected function addGetByPositionComment(&$script) /** * Adds the function declaration for the getByPosition method + * * @param string &$script The script will be modified in this method. + * * @see addGetByPosition **/ protected function addGetByPositionOpen(&$script) @@ -2435,7 +2608,9 @@ public function getByPosition(\$pos) /** * Adds the function body for the getByPosition method + * * @param string &$script The script will be modified in this method. + * * @see addGetByPosition **/ protected function addGetByPositionBody(&$script) @@ -2461,7 +2636,9 @@ protected function addGetByPositionBody(&$script) /** * Adds the function close for the getByPosition method + * * @param string &$script The script will be modified in this method. + * * @see addGetByPosition **/ protected function addGetByPositionClose(&$script) @@ -2489,7 +2666,7 @@ protected function addSetByName(&$script) */ public function setByName(\$name, \$value, \$type = BasePeer::$defaultKeyType) { - \$pos = ".$this->getPeerClassname()."::translateFieldName(\$name, \$type, BasePeer::TYPE_NUM); + \$pos = " . $this->getPeerClassname() . "::translateFieldName(\$name, \$type, BasePeer::TYPE_NUM); \$this->setByPosition(\$pos, \$value); } @@ -2568,7 +2745,7 @@ protected function addFromArray(&$script) */ public function fromArray(\$arr, \$keyType = BasePeer::$defaultKeyType) { - \$keys = ".$this->getPeerClassname()."::getFieldNames(\$keyType); + \$keys = " . $this->getPeerClassname() . "::getFieldNames(\$keyType); "; foreach ($table->getColumns() as $num => $col) { $cfc = $col->getPhpName(); @@ -2584,6 +2761,7 @@ public function fromArray(\$arr, \$keyType = BasePeer::$defaultKeyType) /** * Adds a delete() method to remove the object form the datastore. + * * @param string &$script The script will be modified in this method. */ protected function addDelete(&$script) @@ -2596,7 +2774,9 @@ protected function addDelete(&$script) /** * Adds the comment for the delete function + * * @param string &$script The script will be modified in this method. + * * @see addDelete() **/ protected function addDeleteComment(&$script) @@ -2616,7 +2796,9 @@ protected function addDeleteComment(&$script) /** * Adds the function declaration for the delete function + * * @param string &$script The script will be modified in this method. + * * @see addDelete() **/ protected function addDeleteOpen(&$script) @@ -2628,7 +2810,9 @@ public function delete(PropelPDO \$con = null) /** * Adds the function body for the delete function + * * @param string &$script The script will be modified in this method. + * * @see addDelete() **/ protected function addDeleteBody(&$script) @@ -2639,12 +2823,12 @@ protected function addDeleteBody(&$script) } if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_WRITE); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_WRITE); } \$con->beginTransaction(); try { - \$deleteQuery = ".$this->getQueryClassname()."::create() + \$deleteQuery = " . $this->getQueryClassname() . "::create() ->filterByPrimaryKey(\$this->getPrimaryKey());"; if ($this->getGeneratorConfig()->getBuildProperty('addHooks')) { $script .= " @@ -2684,7 +2868,9 @@ protected function addDeleteBody(&$script) /** * Adds the function close for the delete function + * * @param string &$script The script will be modified in this method. + * * @see addDelete() **/ protected function addDeleteClose(&$script) @@ -2696,6 +2882,7 @@ protected function addDeleteClose(&$script) /** * Adds a reload() method to re-fetch the data for this object from the database. + * * @param string &$script The script will be modified in this method. */ protected function addReload(&$script) @@ -2723,13 +2910,13 @@ public function reload(\$deep = false, PropelPDO \$con = null) } if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_READ); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_READ); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. - \$stmt = ".$this->getPeerClassname()."::doSelectStmt(\$this->buildPkeyCriteria(), \$con); + \$stmt = " . $this->getPeerClassname() . "::doSelectStmt(\$this->buildPkeyCriteria(), \$con); \$row = \$stmt->fetch(PDO::FETCH_NUM); \$stmt->closeCursor(); if (!\$row) { @@ -2745,7 +2932,7 @@ public function reload(\$deep = false, PropelPDO \$con = null) $script .= " // Reset the $clo lazy-load column \$this->" . $clo . " = null; - \$this->".$clo."_isLoaded = false; + \$this->" . $clo . "_isLoaded = false; "; } } @@ -2757,17 +2944,17 @@ public function reload(\$deep = false, PropelPDO \$con = null) foreach ($table->getForeignKeys() as $fk) { $varName = $this->getFKVarName($fk); $script .= " - \$this->".$varName." = null;"; + \$this->" . $varName . " = null;"; } foreach ($table->getReferrers() as $refFK) { if ($refFK->isLocalPrimaryKey()) { $script .= " - \$this->".$this->getPKRefFKVarName($refFK)." = null; + \$this->" . $this->getPKRefFKVarName($refFK) . " = null; "; } else { $script .= " - \$this->".$this->getRefFKCollVarName($refFK)." = null; + \$this->" . $this->getRefFKCollVarName($refFK) . " = null; "; } } @@ -2775,7 +2962,7 @@ public function reload(\$deep = false, PropelPDO \$con = null) foreach ($table->getCrossFks() as $fkList) { list($refFK, $crossFK) = $fkList; $script .= " - \$this->" . $this->getCrossFKVarName($crossFK). " = null;"; + \$this->" . $this->getCrossFKVarName($crossFK) . " = null;"; } $script .= " @@ -2786,6 +2973,7 @@ public function reload(\$deep = false, PropelPDO \$con = null) /** * Adds the methods related to refreshing, saving and deleting the object. + * * @param string &$script The script will be modified in this method. */ protected function addManipulationMethods(&$script) @@ -2800,6 +2988,7 @@ protected function addManipulationMethods(&$script) /** * Adds the methods related to the validation of the object. + * * @param string &$script The script will be modified in this method. */ protected function addValidationMethods(&$script) @@ -2812,6 +3001,7 @@ protected function addValidationMethods(&$script) /** * Adds the $validationFailures attribute to store ValidationFailed objects. + * * @param string &$script The script will be modified in this method. */ protected function addValidationFailuresAttribute(&$script) @@ -2827,6 +3017,7 @@ protected function addValidationFailuresAttribute(&$script) /** * Adds the getValidationFailures() method. + * * @param string &$script The script will be modified in this method. */ protected function addGetValidationFailures(&$script) @@ -2848,6 +3039,7 @@ public function getValidationFailures() /** * Adds the correct getPrimaryKey() method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addGetPrimaryKey(&$script) @@ -2865,6 +3057,7 @@ protected function addGetPrimaryKey(&$script) /** * Adds the getPrimaryKey() method for tables that contain a single-column primary key. + * * @param string &$script The script will be modified in this method. */ protected function addGetPrimaryKey_SinglePK(&$script) @@ -2880,13 +3073,14 @@ protected function addGetPrimaryKey_SinglePK(&$script) */ public function getPrimaryKey() { - return \$this->get".$pkeys[0]->getPhpName()."(); + return \$this->get" . $pkeys[0]->getPhpName() . "(); } "; } // addGetPrimaryKey_SingleFK /** * Adds the setPrimaryKey() method for tables that contain a multi-column primary key. + * * @param string &$script The script will be modified in this method. */ protected function addGetPrimaryKey_MultiPK(&$script) @@ -2904,7 +3098,7 @@ public function getPrimaryKey() $i = 0; foreach ($this->getTable()->getPrimaryKey() as $pk) { $script .= " - \$pks[$i] = \$this->get".$pk->getPhpName()."();"; + \$pks[$i] = \$this->get" . $pk->getPhpName() . "();"; $i++; } /* foreach */ $script .= " @@ -2919,7 +3113,9 @@ public function getPrimaryKey() * This "feature" is deprecated, since the getPrimaryKey() method is not required * by the Persistent interface (or used by the templates). Hence, this method is also * deprecated. + * * @param string &$script The script will be modified in this method. + * * @deprecated */ protected function addGetPrimaryKey_NoPK(&$script) @@ -2936,8 +3132,10 @@ public function getPrimaryKey() } "; } + /** * Adds the correct setPrimaryKey() method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addSetPrimaryKey(&$script) @@ -2955,6 +3153,7 @@ protected function addSetPrimaryKey(&$script) /** * Adds the setPrimaryKey() method for tables that contain a single-column primary key. + * * @param string &$script The script will be modified in this method. */ protected function addSetPrimaryKey_SinglePK(&$script) @@ -2962,7 +3161,7 @@ protected function addSetPrimaryKey_SinglePK(&$script) $pkeys = $this->getTable()->getPrimaryKey(); $col = $pkeys[0]; - $clo=strtolower($col->getName()); + $clo = strtolower($col->getName()); $ctype = $col->getPhpType(); $script .= " @@ -2974,19 +3173,20 @@ protected function addSetPrimaryKey_SinglePK(&$script) */ public function setPrimaryKey(\$key) { - \$this->set".$col->getPhpName()."(\$key); + \$this->set" . $col->getPhpName() . "(\$key); } "; } // addSetPrimaryKey_SinglePK /** * Adds the setPrimaryKey() method for tables that contain a multi-columnprimary key. + * * @param string &$script The script will be modified in this method. */ protected function addSetPrimaryKey_MultiPK(&$script) { - $script .=" + $script .= " /** * Set the [composite] primary key. * @@ -2999,7 +3199,7 @@ public function setPrimaryKey(\$keys) foreach ($this->getTable()->getPrimaryKey() as $pk) { $pktype = $pk->getPhpType(); $script .= " - \$this->set".$pk->getPhpName()."(\$keys[$i]);"; + \$this->set" . $pk->getPhpName() . "(\$keys[$i]);"; $i++; } /* foreach ($table->getPrimaryKey() */ $script .= " @@ -3012,12 +3212,14 @@ public function setPrimaryKey(\$keys) * This "feature" is deprecated, since the setPrimaryKey() method is not required * by the Persistent interface (or used by the templates). Hence, this method is also * deprecated. + * * @param string &$script The script will be modified in this method. + * * @deprecated */ protected function addSetPrimaryKey_NoPK(&$script) { - $script .=" + $script .= " /** * Dummy primary key setter. * @@ -3036,6 +3238,7 @@ public function setPrimaryKey(\$pk) /** * Adds the isPrimaryKeyNull() method + * * @param string &$script The script will be modified in this method. */ protected function addIsPrimaryKeyNull(&$script) @@ -3057,7 +3260,7 @@ public function isPrimaryKeyNull() } else { $tests = array(); foreach ($pkeys as $pkey) { - $tests[]= "(null === \$this->get" . $pkey->getPhpName() . "())"; + $tests[] = "(null === \$this->get" . $pkey->getPhpName() . "())"; } $script .= " @@ -3074,7 +3277,9 @@ public function isPrimaryKeyNull() /** * Constructs variable name for fkey-related objects. + * * @param ForeignKey $fk + * * @return string */ public function getFKVarName(ForeignKey $fk) @@ -3084,7 +3289,9 @@ public function getFKVarName(ForeignKey $fk) /** * Constructs variable name for objects which referencing current table by specified foreign key. + * * @param ForeignKey $fk + * * @return string */ public function getRefFKCollVarName(ForeignKey $fk) @@ -3095,7 +3302,9 @@ public function getRefFKCollVarName(ForeignKey $fk) /** * Constructs variable name for single object which references current table by specified foreign key * which is ALSO a primary key (hence one-to-one relationship). + * * @param ForeignKey $fk + * * @return string */ public function getPKRefFKVarName(ForeignKey $fk) @@ -3111,6 +3320,7 @@ public function getPKRefFKVarName(ForeignKey $fk) /** * Adds the methods that get & set objects related by foreign key to the current object. + * * @param string &$script The script will be modified in this method. */ protected function addFKMethods(&$script) @@ -3125,6 +3335,7 @@ protected function addFKMethods(&$script) /** * Adds the class attributes that are needed to store fkey related objects. + * * @param string &$script The script will be modified in this method. */ protected function addFKAttributes(&$script, ForeignKey $fk) @@ -3136,12 +3347,13 @@ protected function addFKAttributes(&$script, ForeignKey $fk) /** * @var $className */ - protected $".$varName."; + protected $" . $varName . "; "; } /** * Adds the mutator (setter) method for setting an fkey related object. + * * @param string &$script The script will be modified in this method. */ protected function addFKMutator(&$script, ForeignKey $fk) @@ -3159,10 +3371,10 @@ protected function addFKMutator(&$script, ForeignKey $fk) * Declares an association between this object and a $className object. * * @param $className \$v - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) * @throws PropelException */ - public function set".$this->getFKPhpNameAffix($fk, $plural = false)."($className \$v = null) + public function set" . $this->getFKPhpNameAffix($fk, $plural = false) . "($className \$v = null) {"; foreach ($fk->getLocalColumns() as $columnName) { $column = $table->getColumn($columnName); @@ -3171,12 +3383,11 @@ public function set".$this->getFKPhpNameAffix($fk, $plural = false)."($className $colFK = $tblFK->getColumn($colFKName); $script .= " if (\$v === null) { - \$this->set".$column->getPhpName()."(".$this->getDefaultValueString($column)."); + \$this->set" . $column->getPhpName() . "(" . $this->getDefaultValueString($column) . "); } else { - \$this->set".$column->getPhpName()."(\$v->get".$colFK->getPhpName()."()); + \$this->set" . $column->getPhpName() . "(\$v->get" . $colFK->getPhpName() . "()); } "; - } /* foreach local col */ $script .= " @@ -3190,7 +3401,7 @@ public function set".$this->getFKPhpNameAffix($fk, $plural = false)."($className $script .= " // Add binding for other direction of this 1:1 relationship. if (\$v !== null) { - \$v->set".$this->getRefFKPhpNameAffix($fk, $plural = false)."(\$this); + \$v->set" . $this->getRefFKPhpNameAffix($fk, $plural = false) . "(\$this); } "; } else { @@ -3198,10 +3409,9 @@ public function set".$this->getFKPhpNameAffix($fk, $plural = false)."($className // Add binding for other direction of this n:n relationship. // If this object has already been added to the $className object, it will not be re-added. if (\$v !== null) { - \$v->add".$this->getRefFKPhpNameAffix($fk, $plural = false)."(\$this); + \$v->add" . $this->getRefFKPhpNameAffix($fk, $plural = false) . "(\$this); } "; - } $script .= " @@ -3213,6 +3423,7 @@ public function set".$this->getFKPhpNameAffix($fk, $plural = false)."($className /** * Adds the accessor (getter) method for getting an fkey related object. + * * @param string &$script The script will be modified in this method. */ protected function addFKAccessor(&$script, ForeignKey $fk) @@ -3244,22 +3455,21 @@ protected function addFKAccessor(&$script, ForeignKey $fk) $column = $table->getColumn($columnName); $cptype = $column->getPhpType(); $clo = strtolower($column->getName()); - $localColumns[$foreignColumn->getPosition()] = '$this->'.$clo; + $localColumns[$foreignColumn->getPosition()] = '$this->' . $clo; if ($cptype == "integer" || $cptype == "float" || $cptype == "double") { - $conditional .= $and . "\$this->". $clo ." != 0"; + $conditional .= $and . "\$this->" . $clo . " != 0"; } elseif ($cptype == "string") { - $conditional .= $and . "(\$this->" . $clo ." !== \"\" && \$this->".$clo." !== null)"; + $conditional .= $and . "(\$this->" . $clo . " !== \"\" && \$this->" . $clo . " !== null)"; } else { - $conditional .= $and . "\$this->" . $clo ." !== null"; + $conditional .= $and . "\$this->" . $clo . " !== null"; } $and = " && "; } ksort($localColumns); // restoring the order of the foreign PK - $localColumns = count($localColumns) > 1 ? - ('array('.implode(', ', $localColumns).')') : reset($localColumns); + $localColumns = count($localColumns) > 1 ? ('array(' . implode(', ', $localColumns) . ')') : reset($localColumns); $script .= " @@ -3271,23 +3481,23 @@ protected function addFKAccessor(&$script, ForeignKey $fk) * @return $className The associated $className object. * @throws PropelException */ - public function get".$this->getFKPhpNameAffix($fk, $plural = false)."(PropelPDO \$con = null, \$doQuery = true) + public function get" . $this->getFKPhpNameAffix($fk, $plural = false) . "(PropelPDO \$con = null, \$doQuery = true) {"; $script .= " if (\$this->$varName === null && ($conditional) && \$doQuery) {"; if ($useRetrieveByPk) { $script .= " - \$this->$varName = ".$fkQueryBuilder->getClassname()."::create()->findPk($localColumns, \$con);"; + \$this->$varName = " . $fkQueryBuilder->getClassname() . "::create()->findPk($localColumns, \$con);"; } else { $script .= " - \$this->$varName = ".$fkQueryBuilder->getClassname()."::create() + \$this->$varName = " . $fkQueryBuilder->getClassname() . "::create() ->filterBy" . $this->getRefFKPhpNameAffix($fk, $plural = false) . "(\$this) // here ->findOne(\$con);"; } if ($fk->isLocalPrimaryKey()) { $script .= " // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association. - \$this->{$varName}->set".$this->getRefFKPhpNameAffix($fk, $plural = false)."(\$this);"; + \$this->{$varName}->set" . $this->getRefFKPhpNameAffix($fk, $plural = false) . "(\$this);"; } else { $script .= " /* The following can be used additionally to @@ -3295,7 +3505,7 @@ public function get".$this->getFKPhpNameAffix($fk, $plural = false)."(PropelPDO to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - \$this->{$varName}->add".$this->getRefFKPhpNameAffix($fk, $plural = true)."(\$this); + \$this->{$varName}->add" . $this->getRefFKPhpNameAffix($fk, $plural = true) . "(\$this); */"; } @@ -3305,13 +3515,13 @@ public function get".$this->getFKPhpNameAffix($fk, $plural = false)."(PropelPDO return \$this->$varName; } "; - } // addFKAccessor /** * Adds a convenience method for setting a related object by specifying the primary key. * This can be used in conjunction with the getPrimaryKey() for systems where nothing is known * about the actual objects being related. + * * @param string &$script The script will be modified in this method. */ protected function addFKByKeyMutator(&$script, ForeignKey $fk) @@ -3332,15 +3542,15 @@ protected function addFKByKeyMutator(&$script, ForeignKey $fk) $script .= " * Note: It is important that the xml schema used to create this class * maintains consistency in the order of related columns between - * ".$table->getName()." and ". $tblFK->getName().". + * " . $table->getName() . " and " . $tblFK->getName() . ". * If for some reason this is impossible, this method should be - * overridden in ".$table->getPhpName()."."; + * overridden in " . $table->getPhpName() . "."; } $script .= " - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) * @throws PropelException */ - public function set".$methodAffix."Key(\$key) + public function set" . $methodAffix . "Key(\$key) { "; if (count($fk->getLocalColumns()) > 1) { @@ -3349,7 +3559,7 @@ public function set".$methodAffix."Key(\$key) $col = $table->getColumn($colName); $fktype = $col->getPhpType(); $script .= " - \$this->set".$col->getPhpName()."( ($fktype) \$key[$i] ); + \$this->set" . $col->getPhpName() . "( ($fktype) \$key[$i] ); "; $i++; } /* foreach */ @@ -3359,7 +3569,7 @@ public function set".$methodAffix."Key(\$key) $col = $table->getColumn($colName); $fktype = $col->getPhpType(); $script .= " - \$this->set".$col->getPhpName()."( ($fktype) \$key); + \$this->set" . $col->getPhpName() . "( ($fktype) \$key); "; } $script .= " @@ -3371,6 +3581,7 @@ public function set".$methodAffix."Key(\$key) /** * Adds the method that fetches fkey-related (referencing) objects but also joins in data from another table. + * * @param string &$script The script will be modified in this method. */ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK) @@ -3381,7 +3592,7 @@ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK) $peerClassname = $this->getStubPeerBuilder()->getClassname(); $fkQueryClassname = $this->getNewStubQueryBuilder($refFK->getTable())->getClassname(); - $relCol = $this->getRefFKPhpNameAffix($refFK, $plural=true); + $relCol = $this->getRefFKPhpNameAffix($refFK, $plural = true); $collName = $this->getRefFKCollVarName($refFK); $fkPeerBuilder = $this->getNewPeerBuilder($tblFK); @@ -3401,8 +3612,7 @@ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK) $relCol2 = $this->getFKPhpNameAffix($fk2, $plural = false); - if ( $this->getRelatedBySuffix($refFK) != "" && - ($this->getRelatedBySuffix($refFK) == $this->getRelatedBySuffix($fk2))) { + if ($this->getRelatedBySuffix($refFK) != "" && ($this->getRelatedBySuffix($refFK) == $this->getRelatedBySuffix($fk2))) { $doJoinGet = false; } @@ -3412,32 +3622,30 @@ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK) /** * If this collection has already been initialized with * an identical criteria, it returns the collection. - * Otherwise if this ".$table->getPhpName()." is new, it will return - * an empty collection; or if this ".$table->getPhpName()." has previously + * Otherwise if this " . $table->getPhpName() . " is new, it will return + * an empty collection; or if this " . $table->getPhpName() . " has previously * been saved, it will retrieve related $relCol from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you - * actually need in ".$table->getPhpName().". + * actually need in " . $table->getPhpName() . ". * * @param Criteria \$criteria optional Criteria object to narrow the query * @param PropelPDO \$con optional connection object * @param string \$join_behavior optional join type to use (defaults to $join_behavior) * @return PropelObjectCollection|{$className}[] List of $className objects */ - public function get".$relCol."Join".$relCol2."(\$criteria = null, \$con = null, \$join_behavior = $join_behavior) + public function get" . $relCol . "Join" . $relCol2 . "(\$criteria = null, \$con = null, \$join_behavior = $join_behavior) {"; $script .= " \$query = $fkQueryClassname::create(null, \$criteria); - \$query->joinWith('" . $this->getFKPhpNameAffix($fk2, $plural=false) . "', \$join_behavior); + \$query->joinWith('" . $this->getFKPhpNameAffix($fk2, $plural = false) . "', \$join_behavior); - return \$this->get". $relCol . "(\$query, \$con); + return \$this->get" . $relCol . "(\$query, \$con); } "; } /* end if ($doJoinGet) */ - } /* end foreach ($tblFK->getForeignKeys() as $fk2) { */ - } // function // ---------------------------------------------------------------- @@ -3450,6 +3658,7 @@ public function get".$relCol."Join".$relCol2."(\$criteria = null, \$con = null, * Adds the attributes used to store objects that have referrer fkey relationships to this object. * protected collVarName; * private lastVarNameCriteria = null; + * * @param string &$script The script will be modified in this method. */ protected function addRefFKAttributes(&$script, ForeignKey $refFK) @@ -3462,21 +3671,22 @@ protected function addRefFKAttributes(&$script, ForeignKey $refFK) /** * @var $className one-to-one related $className object */ - protected $".$this->getPKRefFKVarName($refFK)."; + protected $" . $this->getPKRefFKVarName($refFK) . "; "; } else { $script .= " /** * @var PropelObjectCollection|{$className}[] Collection to store aggregation of $className objects. */ - protected $".$this->getRefFKCollVarName($refFK)."; - protected $".$this->getRefFKCollVarName($refFK)."Partial; + protected $" . $this->getRefFKCollVarName($refFK) . "; + protected $" . $this->getRefFKCollVarName($refFK) . "Partial; "; } } /** * Adds the methods for retrieving, initializing, adding objects that are related to this one by foreign keys. + * * @param string &$script The script will be modified in this method. */ protected function addRefFKMethods(&$script) @@ -3537,6 +3747,7 @@ public function initRelation(\$relationName) /** * Adds the method that clears the referrer fkey collection. + * * @param string &$script The script will be modified in this method. */ protected function addRefFKClear(&$script, ForeignKey $refFK) @@ -3551,7 +3762,7 @@ protected function addRefFKClear(&$script, ForeignKey $refFK) * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) * @see add$relCol() */ public function clear$relCol() @@ -3566,6 +3777,7 @@ public function clear$relCol() /** * Adds the method that clears the referrer fkey collection. + * * @param string &$script The script will be modified in this method. */ protected function addRefFKPartial(&$script, ForeignKey $refFK) @@ -3588,6 +3800,7 @@ public function resetPartial{$relCol}(\$v = true) /** * Adds the method that initializes the referrer fkey collection. + * * @param string &$script The script will be modified in this method. */ protected function addRefFKInit(&$script, ForeignKey $refFK) @@ -3621,6 +3834,7 @@ public function init$relCol(\$overrideExisting = true) /** * Adds the method that adds an object into the referrer fkey collection. + * * @param string &$script The script will be modified in this method. */ protected function addRefFKAdd(&$script, ForeignKey $refFK) @@ -3633,7 +3847,7 @@ protected function addRefFKAdd(&$script, ForeignKey $refFK) if ($tblFK->getChildrenColumn()) { $className = 'Base' . $className; $namespace = $joinedTableObjectBuilder->getNamespace(); - $this->declareClass($namespace.'\\'.$className); + $this->declareClass($namespace . '\\' . $className); } $collName = $this->getRefFKCollVarName($refFK); @@ -3644,16 +3858,16 @@ protected function addRefFKAdd(&$script, ForeignKey $refFK) * through the $className foreign key attribute. * * @param $className \$l $className - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) */ - public function add".$this->getRefFKPhpNameAffix($refFK, $plural = false)."($className \$l) + public function add" . $this->getRefFKPhpNameAffix($refFK, $plural = false) . "($className \$l) { if (\$this->$collName === null) { - \$this->init".$this->getRefFKPhpNameAffix($refFK, $plural = true)."(); + \$this->init" . $this->getRefFKPhpNameAffix($refFK, $plural = true) . "(); \$this->{$collName}Partial = true; } if (!in_array(\$l, \$this->{$collName}->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - \$this->doAdd" . $this->getRefFKPhpNameAffix($refFK, $plural = false) . "(\$l); + \$this->doAdd" . $this->getRefFKPhpNameAffix($refFK, $plural = false) . "(\$l); } return \$this; @@ -3663,6 +3877,7 @@ public function add".$this->getRefFKPhpNameAffix($refFK, $plural = false)."($cla /** * Adds the method that returns the size of the referrer fkey collection. + * * @param string &$script The script will be modified in this method. */ protected function addRefFKCount(&$script, ForeignKey $refFK) @@ -3717,6 +3932,7 @@ public function count$relCol(Criteria \$criteria = null, \$distinct = false, Pro /** * Adds the method that returns the referrer fkey collection. + * * @param string &$script The script will be modified in this method. */ protected function addRefFKGet(&$script, ForeignKey $refFK) @@ -3740,7 +3956,7 @@ protected function addRefFKGet(&$script, ForeignKey $refFK) * If the \$criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. * Next time the same method is called without \$criteria, the cached collection is returned. - * If this ".$this->getObjectClassname()." is new, it will return + * If this " . $this->getObjectClassname() . " is new, it will return * an empty collection or the current collection; the criteria is ignored on a new object. * * @param Criteria \$criteria optional Criteria object to narrow the query @@ -3754,14 +3970,14 @@ public function get$relCol(\$criteria = null, PropelPDO \$con = null) if (null === \$this->$collName || null !== \$criteria || \$partial) { if (\$this->isNew() && null === \$this->$collName) { // return empty collection - \$this->init".$this->getRefFKPhpNameAffix($refFK, $plural = true)."(); + \$this->init" . $this->getRefFKPhpNameAffix($refFK, $plural = true) . "(); } else { \$$collName = $fkQueryClassname::create(null, \$criteria) ->filterBy" . $this->getFKPhpNameAffix($refFK) . "(\$this) ->find(\$con); if (null !== \$criteria) { if (false !== \$this->{$collName}Partial && count(\$$collName)) { - \$this->init".$this->getRefFKPhpNameAffix($refFK, $plural = true)."(false); + \$this->init" . $this->getRefFKPhpNameAffix($refFK, $plural = true) . "(false); foreach (\$$collName as \$obj) { if (false == \$this->{$collName}->contains(\$obj)) { @@ -3772,7 +3988,7 @@ public function get$relCol(\$criteria = null, PropelPDO \$con = null) \$this->{$collName}Partial = true; } - \$$collName"."->getInternalIterator()->rewind(); + \$$collName" . "->getInternalIterator()->rewind(); return \$$collName; } @@ -3809,7 +4025,7 @@ protected function addRefFKSet(&$script, ForeignKey $refFK) $inputCollectionEntry[0] = strtolower($inputCollectionEntry[0]); $collName = $this->getRefFKCollVarName($refFK); - $relCol = $this->getFKPhpNameAffix($refFK, $plural = false); + $relCol = $this->getFKPhpNameAffix($refFK, $plural = false); $script .= " /** @@ -3820,7 +4036,7 @@ protected function addRefFKSet(&$script, ForeignKey $refFK) * * @param PropelCollection \${$inputCollection} A Propel collection. * @param PropelPDO \$con Optional connection object - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) */ public function set{$relatedName}(PropelCollection \${$inputCollection}, PropelPDO \$con = null) { @@ -3860,7 +4076,7 @@ public function set{$relatedName}(PropelCollection \${$inputCollection}, PropelP } /** - * @param string &$script The script will be modified in this method. + * @param string &$script The script will be modified in this method. * @param ForeignKey $refFK * @param ForeignKey $crossFK */ @@ -3881,13 +4097,13 @@ protected function addRefFKDoAdd(&$script, $refFK) protected function doAdd{$relatedObjectClassName}(\${$lowerRelatedObjectClassName}) { \$this->{$collName}[]= \${$lowerRelatedObjectClassName}; - \${$lowerRelatedObjectClassName}->set" . $this->getFKPhpNameAffix($refFK, $plural = false)."(\$this); + \${$lowerRelatedObjectClassName}->set" . $this->getFKPhpNameAffix($refFK, $plural = false) . "(\$this); } "; } /** - * @param string &$script The script will be modified in this method. + * @param string &$script The script will be modified in this method. * @param ForeignKey $refFK * @param ForeignKey $crossFK */ @@ -3905,14 +4121,14 @@ protected function addRefFKRemove(&$script, $refFK) $lowerRelatedObjectClassName[0] = strtolower($lowerRelatedObjectClassName[0]); $collName = $this->getRefFKCollVarName($refFK); - $relCol = $this->getFKPhpNameAffix($refFK, $plural = false); + $relCol = $this->getFKPhpNameAffix($refFK, $plural = false); $localColumn = $refFK->getLocalColumn(); $script .= " /** * @param {$relatedObjectClassName} \${$lowerRelatedObjectClassName} The $lowerRelatedObjectClassName object to remove. - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) */ public function remove{$relatedObjectClassName}(\${$lowerRelatedObjectClassName}) { @@ -3923,15 +4139,15 @@ public function remove{$relatedObjectClassName}(\${$lowerRelatedObjectClassName} \$this->{$inputCollection}->clear(); }"; - if (!$refFK->isComposite() && !$localColumn->isNotNull()) { + if (!$refFK->isComposite() && !$localColumn->isNotNull()) { $script .= " \$this->{$inputCollection}[]= \${$lowerRelatedObjectClassName};"; - } else { + } else { $script .= " \$this->{$inputCollection}[]= clone \${$lowerRelatedObjectClassName};"; - } + } - $script .= " + $script .= " \${$lowerRelatedObjectClassName}->set{$relCol}(null); } @@ -3943,6 +4159,7 @@ public function remove{$relatedObjectClassName}(\${$lowerRelatedObjectClassName} /** * Adds the method that gets a one-to-one related referrer fkey. * This is for one-to-one relationship special case. + * * @param string &$script The script will be modified in this method. */ protected function addPKRefFKGet(&$script, ForeignKey $refFK) @@ -3965,7 +4182,7 @@ protected function addPKRefFKGet(&$script, ForeignKey $refFK) * @return $className * @throws PropelException */ - public function get".$this->getRefFKPhpNameAffix($refFK, $plural = false)."(PropelPDO \$con = null) + public function get" . $this->getRefFKPhpNameAffix($refFK, $plural = false) . "(PropelPDO \$con = null) { "; $script .= " @@ -3981,6 +4198,7 @@ public function get".$this->getRefFKPhpNameAffix($refFK, $plural = false)."(Prop /** * Adds the method that sets a one-to-one related referrer fkey. * This is for one-to-one relationships special case. + * * @param string &$script The script will be modified in this method. * @param ForeignKey $refFK The referencing foreign key. */ @@ -3998,16 +4216,16 @@ protected function addPKRefFKSet(&$script, ForeignKey $refFK) * Sets a single $className object as related to this object by a one-to-one relationship. * * @param $className \$v $className - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) * @throws PropelException */ - public function set".$this->getRefFKPhpNameAffix($refFK, $plural = false)."($className \$v = null) + public function set" . $this->getRefFKPhpNameAffix($refFK, $plural = false) . "($className \$v = null) { \$this->$varName = \$v; // Make sure that that the passed-in $className isn't already associated with this object - if (\$v !== null && \$v->get".$this->getFKPhpNameAffix($refFK, $plural = false)."(null, false) === null) { - \$v->set".$this->getFKPhpNameAffix($refFK, $plural = false)."(\$this); + if (\$v !== null && \$v->get" . $this->getFKPhpNameAffix($refFK, $plural = false) . "(null, false) === null) { + \$v->set" . $this->getFKPhpNameAffix($refFK, $plural = false) . "(\$this); } return \$this; @@ -4110,7 +4328,7 @@ protected function addRefFkScheduledForDeletion(&$script, ForeignKey $refFK) if (!\$this->{$lowerRelatedName}ScheduledForDeletion->isEmpty()) {"; if ($refFK->getOnDelete() == ForeignKey::CASCADE) { - $script .= " + $script .= " //the foreign key is flagged as `CASCADE`, so we delete the items $queryClassName::create() ->filterByPrimaryKeys(\$this->{$lowerRelatedName}ScheduledForDeletion->getPrimaryKeys(false)) @@ -4154,6 +4372,7 @@ protected function addCrossFKMethods(&$script) /** * Adds the method that clears the referrer fkey collection. + * * @param string &$script The script will be modified in this method. */ protected function addCrossFKClear(&$script, ForeignKey $crossFK) @@ -4168,7 +4387,7 @@ protected function addCrossFKClear(&$script, ForeignKey $crossFK) * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) * @see add$relCol() */ public function clear$relCol() @@ -4183,6 +4402,7 @@ public function clear$relCol() /** * Adds the method that initializes the referrer fkey collection. + * * @param string &$script The script will be modified in this method. */ protected function addCrossFKInit(&$script, ForeignKey $crossFK) @@ -4225,7 +4445,7 @@ protected function addCrossFKGet(&$script, $refFK, $crossFK) * If the \$criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. * Next time the same method is called without \$criteria, the cached collection is returned. - * If this ".$this->getObjectClassname()." is new, it will return + * If this " . $this->getObjectClassname() . " is new, it will return * an empty collection or the current collection; the criteria is ignored on a new object. * * @param Criteria \$criteria Optional query object to filter the query @@ -4280,7 +4500,7 @@ protected function addCrossFKSet(&$script, $refFK, $crossFK) * * @param PropelCollection \${$inputCollection} A Propel collection. * @param PropelPDO \$con Optional connection object - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) */ public function set{$relatedNamePlural}(PropelCollection \${$inputCollection}, PropelPDO \$con = null) { @@ -4345,6 +4565,7 @@ public function count{$relatedName}(\$criteria = null, \$distinct = false, Prope /** * Adds the method that adds an object into the referrer fkey collection. + * * @param string &$script The script will be modified in this method. */ protected function addCrossFKAdd(&$script, ForeignKey $refFK, ForeignKey $crossFK) @@ -4368,7 +4589,7 @@ protected function addCrossFKAdd(&$script, ForeignKey $refFK, ForeignKey $crossF * through the " . $tblFK->getName() . " cross reference table. * * @param " . $crossObjectClassName . " " . $crossObjectName . " The $className object to relate - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) */ public function add{$relatedObjectClassName}($crossObjectClassName $crossObjectName) { @@ -4387,7 +4608,7 @@ public function add{$relatedObjectClassName}($crossObjectClassName $crossObjectN } /** - * @param string &$script The script will be modified in this method. + * @param string &$script The script will be modified in this method. * @param ForeignKey $refFK * @param ForeignKey $crossFK */ @@ -4421,6 +4642,7 @@ protected function doAdd{$relatedObjectClassName}(\${$lowerRelatedObjectClassNam /** * Adds the method that remove an object from the referrer fkey collection. + * * @param string $script The script will be modified in this method. */ protected function addCrossFKRemove(&$script, ForeignKey $refFK, ForeignKey $crossFK) @@ -4433,7 +4655,7 @@ protected function addCrossFKRemove(&$script, ForeignKey $refFK, ForeignKey $cro $joinedTableObjectBuilder = $this->getNewObjectBuilder($refFK->getTable()); $className = $joinedTableObjectBuilder->getObjectClassname(); - $lowerRelCol = $relCol; + $lowerRelCol = $relCol; $lowerRelCol[0] = strtolower($lowerRelCol[0]); $M2MScheduledForDeletion = $lowerRelCol . "ScheduledForDeletion"; @@ -4449,7 +4671,7 @@ protected function addCrossFKRemove(&$script, ForeignKey $refFK, ForeignKey $cro * through the {$tblFK->getName()} cross reference table. * * @param {$crossObjectClassName} {$crossObjectName} The $className object to relate - * @return ".$this->getObjectClassname()." The current object (for fluent API support) + * @return " . $this->getObjectClassname() . " The current object (for fluent API support) */ public function remove{$relatedObjectClassName}($crossObjectClassName $crossObjectName) { @@ -4475,6 +4697,7 @@ public function remove{$relatedObjectClassName}($crossObjectClassName $crossObje /** * Adds the workhouse doSave() method. + * * @param string &$script The script will be modified in this method. */ protected function addDoSave(&$script) @@ -4501,7 +4724,7 @@ protected function addDoSave(&$script) * @throws PropelException * @see save() */ - protected function doSave(PropelPDO \$con".($reloadOnUpdate || $reloadOnInsert ? ", \$skipReload = false" : "").") + protected function doSave(PropelPDO \$con" . ($reloadOnUpdate || $reloadOnInsert ? ", \$skipReload = false" : "") . ") { \$affectedRows = 0; // initialize var to track total num of affected rows if (!\$this->alreadyInSave) { @@ -4529,7 +4752,7 @@ protected function doSave(PropelPDO \$con".($reloadOnUpdate || $reloadOnInsert ? if (\$this->" . $aVarName . "->isModified() || \$this->" . $aVarName . "->isNew()) { \$affectedRows += \$this->" . $aVarName . "->save(\$con); } - \$this->set".$this->getFKPhpNameAffix($fk, $plural = false)."(\$this->$aVarName); + \$this->set" . $this->getFKPhpNameAffix($fk, $plural = false) . "(\$this->$aVarName); } "; } // foreach foreign k @@ -4627,7 +4850,6 @@ protected function doSave(PropelPDO \$con".($reloadOnUpdate || $reloadOnInsert ? return \$affectedRows; } // doSave() "; - } /** @@ -4650,9 +4872,9 @@ protected function addDoInsert() protected function doInsert(PropelPDO \$con) {"; if ($this->getPlatform() instanceof MssqlPlatform) { - if ($table->hasAutoIncrementPrimaryKey() ) { + if ($table->hasAutoIncrementPrimaryKey()) { $script .= " - \$this->modifiedColumns[] = " . $this->getColumnConstant($table->getAutoIncrementPrimaryKey() ) . ";"; + \$this->modifiedColumns[] = " . $this->getColumnConstant($table->getAutoIncrementPrimaryKey()) . ";"; } $script .= " \$criteria = \$this->buildCriteria();"; @@ -4664,7 +4886,7 @@ protected function doInsert(PropelPDO \$con) } else { $script .= $this->addDoInsertBodyRaw(); } - $script .= " + $script .= " \$this->setNew(false); } "; @@ -4717,11 +4939,11 @@ protected function addDoInsertBodyWithIdMethod() if ($table->isAllowPkInsert()) { $script .= " if (\$pk !== null) { - \$this->set".$col->getPhpName()."(\$pk); //[IMV] update autoincrement primary key + \$this->set" . $col->getPhpName() . "(\$pk); //[IMV] update autoincrement primary key }"; } else { $script .= " - \$this->set".$col->getPhpName()."(\$pk); //[IMV] update autoincrement primary key"; + \$this->set" . $col->getPhpName() . "(\$pk); //[IMV] update autoincrement primary key"; } } @@ -4782,7 +5004,7 @@ protected function addDoInsertBodyRaw() $script .= " if (null === \$this->{$columnProperty}) { try {"; - $script .= $platform->getIdentifierPhp('$this->'. $columnProperty, '$con', $primaryKeyMethodInfo, ' '); + $script .= $platform->getIdentifierPhp('$this->' . $columnProperty, '$con', $primaryKeyMethodInfo, ' '); $script .= " } catch (Exception \$e) { throw new PropelException('Unable to get sequence id.', \$e); @@ -4847,11 +5069,11 @@ protected function addDoInsertBodyRaw() if ($table->isAllowPkInsert()) { $script .= " if (\$pk !== null) { - \$this->set".$column->getPhpName()."(\$pk); + \$this->set" . $column->getPhpName() . "(\$pk); }"; } else { $script .= " - \$this->set".$column->getPhpName()."(\$pk);"; + \$this->set" . $column->getPhpName() . "(\$pk);"; } $script .= " "; @@ -4889,6 +5111,7 @@ protected function doUpdate(PropelPDO \$con) /** * Adds the $alreadyInSave attribute, which prevents attempting to re-save the same object. + * * @param string &$script The script will be modified in this method. */ protected function addAlreadyInSaveAttribute(&$script) @@ -4905,6 +5128,7 @@ protected function addAlreadyInSaveAttribute(&$script) /** * Adds the save() method. + * * @param string &$script The script will be modified in this method. */ protected function addSave(&$script) @@ -4917,7 +5141,9 @@ protected function addSave(&$script) /** * Adds the comment for the save method + * * @param string &$script The script will be modified in this method. + * * @see addSave() **/ protected function addSaveComment(&$script) @@ -4965,7 +5191,9 @@ protected function addSaveComment(&$script) /** * Adds the function declaration for the save method + * * @param string &$script The script will be modified in this method. + * * @see addSave() **/ protected function addSaveOpen(&$script) @@ -4974,13 +5202,15 @@ protected function addSaveOpen(&$script) $reloadOnUpdate = $table->isReloadOnUpdate(); $reloadOnInsert = $table->isReloadOnInsert(); $script .= " - public function save(PropelPDO \$con = null".($reloadOnUpdate || $reloadOnInsert ? ", \$skipReload = false" : "").") + public function save(PropelPDO \$con = null" . ($reloadOnUpdate || $reloadOnInsert ? ", \$skipReload = false" : "") . ") {"; } /** * Adds the function body for the save method + * * @param string &$script The script will be modified in this method. + * * @see addSave() **/ protected function addSaveBody(&$script) @@ -4995,7 +5225,7 @@ protected function addSaveBody(&$script) } if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_WRITE); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_WRITE); } \$con->beginTransaction(); @@ -5018,7 +5248,7 @@ protected function addSaveBody(&$script) $script .= " } if (\$ret) { - \$affectedRows = \$this->doSave(\$con".($reloadOnUpdate || $reloadOnInsert ? ", \$skipReload" : "")."); + \$affectedRows = \$this->doSave(\$con" . ($reloadOnUpdate || $reloadOnInsert ? ", \$skipReload" : "") . "); if (\$isInsert) { \$this->postInsert(\$con);"; $this->applyBehaviorModifier('postInsert', $script, " "); @@ -5029,9 +5259,9 @@ protected function addSaveBody(&$script) $script .= " } \$this->postSave(\$con);"; - $this->applyBehaviorModifier('postSave', $script, " "); - $script .= " - ".$this->getPeerClassname()."::addInstanceToPool(\$this); + $this->applyBehaviorModifier('postSave', $script, " "); + $script .= " + " . $this->getPeerClassname() . "::addInstanceToPool(\$this); } else { \$affectedRows = 0; } @@ -5056,7 +5286,7 @@ protected function addSaveBody(&$script) }"; } $script .= " - \$affectedRows = \$this->doSave(\$con".($reloadOnUpdate || $reloadOnInsert ? ", \$skipReload" : "").");"; + \$affectedRows = \$this->doSave(\$con" . ($reloadOnUpdate || $reloadOnInsert ? ", \$skipReload" : "") . ");"; $this->applyBehaviorModifier('postSave', $script, " "); if ($this->hasBehaviorModifier('postUpdate')) { $script .= " @@ -5074,7 +5304,7 @@ protected function addSaveBody(&$script) } $script .= " \$con->commit(); - ".$this->getPeerClassname()."::addInstanceToPool(\$this); + " . $this->getPeerClassname() . "::addInstanceToPool(\$this); return \$affectedRows;"; } @@ -5088,7 +5318,9 @@ protected function addSaveBody(&$script) /** * Adds the function close for the save method + * * @param string &$script The script will be modified in this method. + * * @see addSave() **/ protected function addSaveClose(&$script) @@ -5100,6 +5332,7 @@ protected function addSaveClose(&$script) /** * Adds the $alreadyInValidation attribute, which prevents attempting to re-validate the same object. + * * @param string &$script The script will be modified in this method. */ protected function addAlreadyInValidationAttribute(&$script) @@ -5116,6 +5349,7 @@ protected function addAlreadyInValidationAttribute(&$script) /** * Adds the $alreadyInValidation attribute, which prevents attempting to re-validate the same object. + * * @param string &$script The script will be modified in this method. */ protected function addAlreadyInClearAllReferencesDeepAttribute(&$script) @@ -5131,6 +5365,7 @@ protected function addAlreadyInClearAllReferencesDeepAttribute(&$script) /** * Adds the validate() method. + * * @param string &$script The script will be modified in this method. */ protected function addValidate(&$script) @@ -5165,6 +5400,7 @@ public function validate(\$columns = null) /** * Adds the workhouse doValidate() method. + * * @param string &$script The script will be modified in this method. */ protected function addDoValidate(&$script) @@ -5201,9 +5437,9 @@ protected function doValidate(\$columns = null) foreach ($table->getForeignKeys() as $fk) { $aVarName = $this->getFKVarName($fk); $script .= " - if (\$this->".$aVarName." !== null) { - if (!\$this->".$aVarName."->validate(\$columns)) { - \$failureMap = array_merge(\$failureMap, \$this->".$aVarName."->getValidationFailures()); + if (\$this->" . $aVarName . " !== null) { + if (!\$this->" . $aVarName . "->validate(\$columns)) { + \$failureMap = array_merge(\$failureMap, \$this->" . $aVarName . "->getValidationFailures()); } } "; @@ -5212,7 +5448,7 @@ protected function doValidate(\$columns = null) $script .= " - if ((\$retval = ".$this->getPeerClassname()."::doValidate(\$this, \$columns)) !== true) { + if ((\$retval = " . $this->getPeerClassname() . "::doValidate(\$this, \$columns)) !== true) { \$failureMap = array_merge(\$failureMap, \$retval); } @@ -5223,8 +5459,8 @@ protected function doValidate(\$columns = null) $varName = $this->getPKRefFKVarName($refFK); $script .= " if (\$this->$varName !== null) { - if (!\$this->".$varName."->validate(\$columns)) { - \$failureMap = array_merge(\$failureMap, \$this->".$varName."->getValidationFailures()); + if (!\$this->" . $varName . "->validate(\$columns)) { + \$failureMap = array_merge(\$failureMap, \$this->" . $varName . "->getValidationFailures()); } } "; @@ -5254,6 +5490,7 @@ protected function doValidate(\$columns = null) /** * Adds the ensureConsistency() method to ensure that internal state is correct. + * * @param string &$script The script will be modified in this method. */ protected function addEnsureConsistency(&$script) @@ -5279,7 +5516,7 @@ public function ensureConsistency() "; foreach ($table->getColumns() as $col) { - $clo=strtolower($col->getName()); + $clo = strtolower($col->getName()); if ($col->isForeignKey()) { foreach ($col->getForeignKeys() as $fk) { @@ -5289,12 +5526,11 @@ public function ensureConsistency() $varName = $this->getFKVarName($fk); $script .= " - if (\$this->".$varName." !== null && \$this->$clo !== \$this->".$varName."->get".$colFK->getPhpName()."()) { + if (\$this->" . $varName . " !== null && \$this->$clo !== \$this->" . $varName . "->get" . $colFK->getPhpName() . "()) { \$this->$varName = null; }"; } // foreach } /* if col is foreign key */ - } // foreach $script .= " @@ -5304,6 +5540,7 @@ public function ensureConsistency() /** * Adds the copy() method, which (in complex OM) includes the $deepCopy param for making copies of related objects. + * * @param string &$script The script will be modified in this method. */ protected function addCopy(&$script) @@ -5322,7 +5559,7 @@ protected function addCopy(&$script) * objects. * * @param boolean \$deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return ".$this->getObjectClassname()." Clone of current object. + * @return " . $this->getObjectClassname() . " Clone of current object. * @throws PropelException */ public function copy(\$deepCopy = false) @@ -5340,6 +5577,7 @@ public function copy(\$deepCopy = false) /** * Adds the copyInto() method, which takes an object and sets contents to match current object. * In complex OM this method includes the $deepCopy param for making copies of related objects. + * * @param string &$script The script will be modified in this method. */ protected function addCopyInto(&$script) @@ -5353,7 +5591,7 @@ protected function addCopyInto(&$script) * If desired, this method can also make copies of all associated (fkey referrers) * objects. * - * @param object \$copyObj An object of ".$this->getObjectClassname()." (or compatible) type. + * @param object \$copyObj An object of " . $this->getObjectClassname() . " (or compatible) type. * @param boolean \$deepCopy Whether to also copy all rows that refer (by fkey) to the current row. * @param boolean \$makeNew Whether to reset autoincrement PKs and make the object new. * @throws PropelException @@ -5376,13 +5614,13 @@ public function copyInto(\$copyObj, \$deepCopy = false, \$makeNew = true) foreach ($table->getColumns() as $col) { if (!in_array($col, $autoIncCols, true)) { $script .= " - \$copyObj->set".$col->getPhpName()."(\$this->get".$col->getPhpName()."());"; + \$copyObj->set" . $col->getPhpName() . "(\$this->get" . $col->getPhpName() . "());"; } } // foreach // Avoid useless code by checking to see if there are any referrers // to this table: - if (count($table->getReferrers()) > 0 || count($table->getForeignKeys()) > 0 ) { + if (count($table->getReferrers()) > 0 || count($table->getForeignKeys()) > 0) { $script .= " if (\$deepCopy && !\$this->startCopy) { @@ -5409,9 +5647,9 @@ public function copyInto(\$copyObj, \$deepCopy = false, \$makeNew = true) } else { $script .= " - foreach (\$this->get".$this->getRefFKPhpNameAffix($fk, true)."() as \$relObj) { + foreach (\$this->get" . $this->getRefFKPhpNameAffix($fk, true) . "() as \$relObj) { if (\$relObj !== \$this) { // ensure that we don't try to copy a reference to ourselves - \$copyObj->add".$this->getRefFKPhpNameAffix($fk)."(\$relObj->copy(\$deepCopy)); + \$copyObj->add" . $this->getRefFKPhpNameAffix($fk) . "(\$relObj->copy(\$deepCopy)); } } "; @@ -5445,10 +5683,10 @@ public function copyInto(\$copyObj, \$deepCopy = false, \$makeNew = true) // Note: we're no longer resetting non-autoincrement primary keys to default values // due to: http://propel.phpdb.org/trac/ticket/618 foreach ($autoIncCols as $col) { - $coldefval = $col->getPhpDefaultValue(); - $coldefval = var_export($coldefval, true); - $script .= " - \$copyObj->set".$col->getPhpName() ."($coldefval); // this is a auto-increment column, so set to default value"; + $coldefval = $col->getPhpDefaultValue(); + $coldefval = var_export($coldefval, true); + $script .= " + \$copyObj->set" . $col->getPhpName() . "($coldefval); // this is a auto-increment column, so set to default value"; } // foreach $script .= " } @@ -5458,6 +5696,7 @@ public function copyInto(\$copyObj, \$deepCopy = false, \$makeNew = true) /** * Adds clear method + * * @param string &$script The script will be modified in this method. */ protected function addClear(&$script) @@ -5473,14 +5712,14 @@ public function clear() foreach ($table->getColumns() as $col) { $clo = strtolower($col->getName()); $script .= " - \$this->".$clo." = null;"; + \$this->" . $clo . " = null;"; if ($col->isLazyLoad()) { $script .= " - \$this->".$clo."_isLoaded = false;"; + \$this->" . $clo . "_isLoaded = false;"; } if ($col->getType() == PropelTypes::OBJECT || $col->getType() == PropelTypes::PHP_ARRAY) { - $cloUnserialized = $clo.'_unserialized'; - $script .=" + $cloUnserialized = $clo . '_unserialized'; + $script .= " \$this->$cloUnserialized = null;"; } } @@ -5508,6 +5747,7 @@ public function clear() /** * Adds clearAllReferencers() method which resets all the collections of referencing * fk objects. + * * @param string &$script The script will be modified in this method. */ protected function addClearAllReferences(&$script) @@ -5594,6 +5834,7 @@ public function clearAllReferences(\$deep = false) /** * Adds a magic __toString() method if a string column was defined as primary string + * * @param string &$script The script will be modified in this method. */ protected function addPrimaryString(&$script) @@ -5631,6 +5872,7 @@ public function __toString() /** * Adds a magic __call() method + * * @param string &$script The script will be modified in this method. */ protected function addMagicCall(&$script) diff --git a/generator/lib/builder/om/PHP5ObjectNoCollectionBuilder.php b/generator/lib/builder/om/PHP5ObjectNoCollectionBuilder.php index a7b5fe889..4a1af262c 100644 --- a/generator/lib/builder/om/PHP5ObjectNoCollectionBuilder.php +++ b/generator/lib/builder/om/PHP5ObjectNoCollectionBuilder.php @@ -36,8 +36,10 @@ class PHP5ObjectNoCollectionBuilder extends PHP5ObjectBuilder /** * Adds the lazy loader method. + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see parent::addColumnAccessors() */ protected function addLazyLoader(&$script, Column $col) @@ -50,8 +52,10 @@ protected function addLazyLoader(&$script, Column $col) /** * Adds the comment for the lazy loader method + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addLazyLoader() **/ protected function addLazyLoaderComment(&$script, Column $col) @@ -74,8 +78,10 @@ protected function addLazyLoaderComment(&$script, Column $col) /** * Adds the function declaration for the lazy loader method + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addLazyLoader() **/ protected function addLazyLoaderOpen(&$script, Column $col) @@ -88,8 +94,10 @@ protected function load$cfc(PropelPDO \$con = null) /** * Adds the function body for the lazy loader method + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addLazyLoader() **/ protected function addLazyLoaderBody(&$script, Column $col) @@ -99,9 +107,9 @@ protected function addLazyLoaderBody(&$script, Column $col) $script .= " \$c = \$this->buildPkeyCriteria(); - \$c->addSelectColumn(".$this->getColumnConstant($col)."); + \$c->addSelectColumn(" . $this->getColumnConstant($col) . "); try { - \$stmt = ".$this->getPeerClassname()."::doSelectStmt(\$c, \$con); + \$stmt = " . $this->getPeerClassname() . "::doSelectStmt(\$c, \$con); \$row = \$stmt->fetch(PDO::FETCH_NUM); \$stmt->closeCursor();"; @@ -120,17 +128,17 @@ protected function addLazyLoaderBody(&$script, Column $col) }"; } elseif ($col->isPhpPrimitiveType()) { $script .= " - \$this->$clo = (\$row[0] !== null) ? (".$col->getPhpType().") \$row[0] : null;"; + \$this->$clo = (\$row[0] !== null) ? (" . $col->getPhpType() . ") \$row[0] : null;"; } elseif ($col->isPhpObjectType()) { $script .= " - \$this->$clo = (\$row[0] !== null) ? new ".$col->getPhpType()."(\$row[0]) : null;"; + \$this->$clo = (\$row[0] !== null) ? new " . $col->getPhpType() . "(\$row[0]) : null;"; } else { $script .= " \$this->$clo = \$row[0];"; } $script .= " - \$this->".$clo."_isLoaded = true; + \$this->" . $clo . "_isLoaded = true; } catch (Exception \$e) { throw new PropelException(\"Error loading value for [$clo] column on demand.\", \$e); }"; @@ -138,8 +146,10 @@ protected function addLazyLoaderBody(&$script, Column $col) /** * Adds the function close for the lazy loader + * * @param string &$script The script will be modified in this method. * @param Column $col The current column. + * * @see addLazyLoader() **/ protected function addLazyLoaderClose(&$script, Column $col) @@ -150,6 +160,7 @@ protected function addLazyLoaderClose(&$script, Column $col) /** * Adds the buildPkeyCriteria method + * * @param string &$script The script will be modified in this method. **/ protected function addBuildPkeyCriteria(&$script) @@ -162,7 +173,9 @@ protected function addBuildPkeyCriteria(&$script) /** * Adds the comment for the buildPkeyCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildPkeyCriteria() **/ protected function addBuildPkeyCriteriaComment(&$script) @@ -180,7 +193,9 @@ protected function addBuildPkeyCriteriaComment(&$script) /** * Adds the function declaration for the buildPkeyCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildPkeyCriteria() **/ protected function addBuildPkeyCriteriaOpen(&$script) @@ -192,25 +207,29 @@ public function buildPkeyCriteria() /** * Adds the function body for the buildPkeyCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildPkeyCriteria() **/ protected function addBuildPkeyCriteriaBody(&$script) { $script .= " - \$criteria = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME);"; + \$criteria = new Criteria(" . $this->getPeerClassname() . "::DATABASE_NAME);"; foreach ($this->getTable()->getColumns() as $col) { $clo = strtolower($col->getName()); if ($col->isPrimaryKey()) { $script .= " - \$criteria->add(".$this->getColumnConstant($col).", \$this->$clo);"; + \$criteria->add(" . $this->getColumnConstant($col) . ", \$this->$clo);"; } } } /** * Adds the function close for the buildPkeyCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildPkeyCriteria() **/ protected function addBuildPkeyCriteriaClose(&$script) @@ -224,6 +243,7 @@ protected function addBuildPkeyCriteriaClose(&$script) /** * Adds the buildCriteria method + * * @param string &$script The script will be modified in this method. **/ protected function addBuildCriteria(&$script) @@ -236,7 +256,9 @@ protected function addBuildCriteria(&$script) /** * Adds comment for the buildCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildCriteria() **/ protected function addBuildCriteriaComment(&$script) @@ -251,7 +273,9 @@ protected function addBuildCriteriaComment(&$script) /** * Adds the function declaration of the buildCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildCriteria() **/ protected function addBuildCriteriaOpen(&$script) @@ -263,24 +287,28 @@ public function buildCriteria() /** * Adds the function body of the buildCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildCriteria() **/ protected function addBuildCriteriaBody(&$script) { $script .= " - \$criteria = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME); + \$criteria = new Criteria(" . $this->getPeerClassname() . "::DATABASE_NAME); "; foreach ($this->getTable()->getColumns() as $col) { $clo = strtolower($col->getName()); $script .= " - if (\$this->isColumnModified(".$this->getColumnConstant($col).")) \$criteria->add(".$this->getColumnConstant($col).", \$this->$clo);"; + if (\$this->isColumnModified(" . $this->getColumnConstant($col) . ")) \$criteria->add(" . $this->getColumnConstant($col) . ", \$this->$clo);"; } } /** * Adds the function close of the buildCriteria method + * * @param string &$script The script will be modified in this method. + * * @see addBuildCriteria() **/ protected function addBuildCriteriaClose(&$script) @@ -294,7 +322,9 @@ protected function addBuildCriteriaClose(&$script) /** * Adds the function body for the delete function + * * @param string &$script The script will be modified in this method. + * * @see addDelete() **/ protected function addDeleteBody(&$script) @@ -305,7 +335,7 @@ protected function addDeleteBody(&$script) } if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_WRITE); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_WRITE); } \$con->beginTransaction(); @@ -317,7 +347,7 @@ protected function addDeleteBody(&$script) $this->applyBehaviorModifier('preDelete', $script, " "); $script .= " if (\$ret) { - ".$this->getPeerClassname()."::doDelete(\$this, \$con); + " . $this->getPeerClassname() . "::doDelete(\$this, \$con); \$this->postDelete(\$con);"; // apply behaviors $this->applyBehaviorModifier('postDelete', $script, " "); @@ -331,7 +361,7 @@ protected function addDeleteBody(&$script) // apply behaviors $this->applyBehaviorModifier('preDelete', $script, " "); $script .= " - ".$this->getPeerClassname()."::doDelete(\$this, \$con);"; + " . $this->getPeerClassname() . "::doDelete(\$this, \$con);"; // apply behaviors $this->applyBehaviorModifier('postDelete', $script, " "); $script .= " @@ -348,6 +378,7 @@ protected function addDeleteBody(&$script) /** * Adds a reload() method to re-fetch the data for this object from the database. + * * @param string &$script The script will be modified in this method. */ protected function addReload(&$script) @@ -375,13 +406,13 @@ public function reload(\$deep = false, PropelPDO \$con = null) } if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_READ); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_READ); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. - \$stmt = ".$this->getPeerClassname()."::doSelectStmt(\$this->buildPkeyCriteria(), \$con); + \$stmt = " . $this->getPeerClassname() . "::doSelectStmt(\$this->buildPkeyCriteria(), \$con); \$row = \$stmt->fetch(PDO::FETCH_NUM); \$stmt->closeCursor(); if (!\$row) { @@ -397,7 +428,7 @@ public function reload(\$deep = false, PropelPDO \$con = null) $script .= " // Reset the $clo lazy-load column \$this->" . $clo . " = null; - \$this->".$clo."_isLoaded = false; + \$this->" . $clo . "_isLoaded = false; "; } } @@ -409,18 +440,18 @@ public function reload(\$deep = false, PropelPDO \$con = null) foreach ($table->getForeignKeys() as $fk) { $varName = $this->getFKVarName($fk); $script .= " - \$this->".$varName." = null;"; + \$this->" . $varName . " = null;"; } foreach ($table->getReferrers() as $refFK) { if ($refFK->isLocalPrimaryKey()) { $script .= " - \$this->".$this->getPKRefFKVarName($refFK)." = null; + \$this->" . $this->getPKRefFKVarName($refFK) . " = null; "; } else { $script .= " - \$this->".$this->getRefFKCollVarName($refFK)." = null; - \$this->".$this->getRefFKLastCriteriaVarName($refFK)." = null; + \$this->" . $this->getRefFKCollVarName($refFK) . " = null; + \$this->" . $this->getRefFKLastCriteriaVarName($refFK) . " = null; "; } } @@ -434,7 +465,9 @@ public function reload(\$deep = false, PropelPDO \$con = null) /** * Gets variable name for the Criteria which was used to fetch the objects which * referencing current table by specified foreign key. + * * @param ForeignKey $fk + * * @return string */ protected function getRefFKLastCriteriaVarName(ForeignKey $fk) @@ -444,6 +477,7 @@ protected function getRefFKLastCriteriaVarName(ForeignKey $fk) /** * Adds the accessor (getter) method for getting an fkey related object. + * * @param string &$script The script will be modified in this method. */ protected function addFKAccessor(&$script, ForeignKey $fk) @@ -476,14 +510,14 @@ protected function addFKAccessor(&$script, ForeignKey $fk) $column = $table->getColumn($columnName); $cptype = $column->getPhpType(); $clo = strtolower($column->getName()); - $localColumns[$foreignColumn->getPosition()] = '$this->'.$clo; + $localColumns[$foreignColumn->getPosition()] = '$this->' . $clo; if ($cptype == "integer" || $cptype == "float" || $cptype == "double") { - $conditional .= $and . "\$this->". $clo ." != 0"; + $conditional .= $and . "\$this->" . $clo . " != 0"; } elseif ($cptype == "string") { - $conditional .= $and . "(\$this->" . $clo ." !== \"\" && \$this->".$clo." !== null)"; + $conditional .= $and . "(\$this->" . $clo . " !== \"\" && \$this->" . $clo . " !== null)"; } else { - $conditional .= $and . "\$this->" . $clo ." !== null"; + $conditional .= $and . "\$this->" . $clo . " !== null"; } $argmap[] = array('foreign' => $foreignColumn, 'local' => $localColumn); @@ -491,8 +525,7 @@ protected function addFKAccessor(&$script, ForeignKey $fk) } ksort($localColumns); // restoring the order of the foreign PK - $localColumns = count($localColumns) > 1 ? - ('array('.implode(', ', $localColumns).')') : reset($localColumns); + $localColumns = count($localColumns) > 1 ? ('array(' . implode(', ', $localColumns) . ')') : reset($localColumns); // If the related column is a primary kay and if it's a simple association, // The use retrieveByPk() instead of doSelect() to take advantage of instance pooling @@ -507,30 +540,30 @@ protected function addFKAccessor(&$script, ForeignKey $fk) * @return $className The associated $className object. * @throws PropelException */ - public function get".$this->getFKPhpNameAffix($fk, $plural = false)."(PropelPDO \$con = null) + public function get" . $this->getFKPhpNameAffix($fk, $plural = false) . "(PropelPDO \$con = null) {"; $script .= " if (\$this->$varName === null && ($conditional)) {"; if ($useRetrieveByPk) { $script .= " - \$this->$varName = ".$fkPeerBuilder->getPeerClassname()."::retrieveByPk($localColumns, \$con);"; + \$this->$varName = " . $fkPeerBuilder->getPeerClassname() . "::retrieveByPk($localColumns, \$con);"; } else { $script .= " - \$c = new Criteria(".$fkPeerBuilder->getPeerClassname()."::DATABASE_NAME);"; + \$c = new Criteria(" . $fkPeerBuilder->getPeerClassname() . "::DATABASE_NAME);"; foreach ($argmap as $el) { $fcol = $el['foreign']; $lcol = $el['local']; $clo = strtolower($lcol->getName()); $script .= " - \$c->add(".$fkPeerBuilder->getColumnConstant($fcol).", \$this->".$clo.");"; + \$c->add(" . $fkPeerBuilder->getColumnConstant($fcol) . ", \$this->" . $clo . ");"; } $script .= " - \$this->$varName = ".$fkPeerBuilder->getPeerClassname()."::doSelectOne(\$c, \$con);"; + \$this->$varName = " . $fkPeerBuilder->getPeerClassname() . "::doSelectOne(\$c, \$con);"; } if ($fk->isLocalPrimaryKey()) { $script .= " // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association. - \$this->{$varName}->set".$this->getRefFKPhpNameAffix($fk, $plural = false)."(\$this);"; + \$this->{$varName}->set" . $this->getRefFKPhpNameAffix($fk, $plural = false) . "(\$this);"; } else { $script .= " /* The following can be used additionally to @@ -538,7 +571,7 @@ public function get".$this->getFKPhpNameAffix($fk, $plural = false)."(PropelPDO to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - \$this->{$varName}->add".$this->getRefFKPhpNameAffix($fk, $plural = true)."(\$this); + \$this->{$varName}->add" . $this->getRefFKPhpNameAffix($fk, $plural = true) . "(\$this); */"; } @@ -548,13 +581,14 @@ public function get".$this->getFKPhpNameAffix($fk, $plural = false)."(PropelPDO return \$this->$varName; } "; - } // addFKAccessor /** * Adds the method that fetches fkey-related (referencing) objects but also joins in data from another table. + * * @param string &$script The script will be modified in this method. + * * @throws EngineException */ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK) @@ -564,7 +598,7 @@ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK) $join_behavior = $this->getGeneratorConfig()->getBuildProperty('useLeftJoinsInDoJoinMethods') ? 'Criteria::LEFT_JOIN' : 'Criteria::INNER_JOIN'; $peerClassname = $this->getStubPeerBuilder()->getClassname(); - $relCol = $this->getRefFKPhpNameAffix($refFK, $plural=true); + $relCol = $this->getRefFKPhpNameAffix($refFK, $plural = true); $collName = $this->getRefFKCollVarName($refFK); $lastCriteriaName = $this->getRefFKLastCriteriaVarName($refFK); @@ -584,8 +618,7 @@ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK) $relCol2 = $this->getFKPhpNameAffix($fk2, $plural = false); - if ( $this->getRelatedBySuffix($refFK) != "" && - ($this->getRelatedBySuffix($refFK) == $this->getRelatedBySuffix($fk2))) { + if ($this->getRelatedBySuffix($refFK) != "" && ($this->getRelatedBySuffix($refFK) == $this->getRelatedBySuffix($fk2))) { $doJoinGet = false; } @@ -595,15 +628,15 @@ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK) /** * If this collection has already been initialized with * an identical criteria, it returns the collection. - * Otherwise if this ".$table->getPhpName()." is new, it will return - * an empty collection; or if this ".$table->getPhpName()." has previously + * Otherwise if this " . $table->getPhpName() . " is new, it will return + * an empty collection; or if this " . $table->getPhpName() . " has previously * been saved, it will retrieve related $relCol from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you - * actually need in ".$table->getPhpName().". + * actually need in " . $table->getPhpName() . ". */ - public function get".$relCol."Join".$relCol2."(\$criteria = null, \$con = null, \$join_behavior = $join_behavior) + public function get" . $relCol . "Join" . $relCol2 . "(\$criteria = null, \$con = null, \$join_behavior = $join_behavior) {"; $script .= " if (\$criteria === null) { @@ -627,12 +660,12 @@ public function get".$relCol."Join".$relCol2."(\$criteria = null, \$con = null, } $clo = strtolower($column->getName()); $script .= " - \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->$clo); + \$criteria->add(" . $fkPeerBuilder->getColumnConstant($colFK) . ", \$this->$clo); "; } // end foreach ($fk->getForeignColumns() $script .= " - \$this->$collName = ".$fkPeerBuilder->getPeerClassname()."::doSelectJoin$relCol2(\$criteria, \$con, \$join_behavior); + \$this->$collName = " . $fkPeerBuilder->getPeerClassname() . "::doSelectJoin$relCol2(\$criteria, \$con, \$join_behavior); } } else { // the following code is to determine if a new query is @@ -646,13 +679,13 @@ public function get".$relCol."Join".$relCol2."(\$criteria = null, \$con = null, $colFK = $tblFK->getColumn($colFKName); $clo = strtolower($column->getName()); $script .= " - \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->$clo); + \$criteria->add(" . $fkPeerBuilder->getColumnConstant($colFK) . ", \$this->$clo); "; } /* end foreach ($fk->getForeignColumns() */ $script .= " - if (!isset(\$this->$lastCriteriaName) || !\$this->".$lastCriteriaName."->equals(\$criteria)) { - \$this->$collName = ".$fkPeerBuilder->getPeerClassname()."::doSelectJoin$relCol2(\$criteria, \$con, \$join_behavior); + if (!isset(\$this->$lastCriteriaName) || !\$this->" . $lastCriteriaName . "->equals(\$criteria)) { + \$this->$collName = " . $fkPeerBuilder->getPeerClassname() . "::doSelectJoin$relCol2(\$criteria, \$con, \$join_behavior); } } \$this->$lastCriteriaName = \$criteria; @@ -661,13 +694,12 @@ public function get".$relCol."Join".$relCol2."(\$criteria = null, \$con = null, } "; } /* end if ($doJoinGet) */ - } /* end foreach ($tblFK->getForeignKeys() as $fk2) { */ - } // function /** * Adds the method that initializes the referrer fkey collection. + * * @param string &$script The script will be modified in this method. */ protected function addRefFKInit(&$script, ForeignKey $refFK) @@ -694,6 +726,7 @@ public function init$relCol() /** * Adds the method that adds an object into the referrer fkey collection. + * * @param string &$script The script will be modified in this method. */ protected function addRefFKAdd(&$script, ForeignKey $refFK) @@ -714,14 +747,14 @@ protected function addRefFKAdd(&$script, ForeignKey $refFK) * @return void * @throws PropelException */ - public function add".$this->getRefFKPhpNameAffix($refFK, $plural = false)."($className \$l) + public function add" . $this->getRefFKPhpNameAffix($refFK, $plural = false) . "($className \$l) { if (\$this->$collName === null) { - \$this->init".$this->getRefFKPhpNameAffix($refFK, $plural = true)."(); + \$this->init" . $this->getRefFKPhpNameAffix($refFK, $plural = true) . "(); } if (!in_array(\$l, \$this->$collName, true)) { // only add it if the **same** object is not already associated array_push(\$this->$collName, \$l); - \$l->set".$this->getFKPhpNameAffix($refFK, $plural = false)."(\$this); + \$l->set" . $this->getFKPhpNameAffix($refFK, $plural = false) . "(\$this); } } "; @@ -729,6 +762,7 @@ public function add".$this->getRefFKPhpNameAffix($refFK, $plural = false)."($cla /** * Adds the method that returns the size of the referrer fkey collection. + * * @param string &$script The script will be modified in this method. */ protected function addRefFKCount(&$script, ForeignKey $refFK) @@ -784,12 +818,12 @@ public function count$relCol(Criteria \$criteria = null, \$distinct = false, Pro $colFK = $refFK->getTable()->getColumn($colFKName); $clo = strtolower($localColumn->getName()); $script .= " - \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->$clo); + \$criteria->add(" . $fkPeerBuilder->getColumnConstant($colFK) . ", \$this->$clo); "; } // end foreach ($fk->getForeignColumns() $script .= " - \$count = ".$fkPeerBuilder->getPeerClassname()."::doCount(\$criteria, false, \$con); + \$count = " . $fkPeerBuilder->getPeerClassname() . "::doCount(\$criteria, false, \$con); } } else { // criteria has no effect for a new object @@ -806,12 +840,12 @@ public function count$relCol(Criteria \$criteria = null, \$distinct = false, Pro $clo = strtolower($localColumn->getName()); $script .= " - \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->$clo); + \$criteria->add(" . $fkPeerBuilder->getColumnConstant($colFK) . ", \$this->$clo); "; } // foreach ($fk->getForeignColumns() $script .= " - if (!isset(\$this->$lastCriteriaName) || !\$this->".$lastCriteriaName."->equals(\$criteria)) { - \$count = ".$fkPeerBuilder->getPeerClassname()."::doCount(\$criteria, false, \$con); + if (!isset(\$this->$lastCriteriaName) || !\$this->" . $lastCriteriaName . "->equals(\$criteria)) { + \$count = " . $fkPeerBuilder->getPeerClassname() . "::doCount(\$criteria, false, \$con); } else { \$count = count(\$this->$collName); } @@ -827,6 +861,7 @@ public function count$relCol(Criteria \$criteria = null, \$distinct = false, Pro /** * Adds the method that returns the referrer fkey collection. + * * @param string &$script The script will be modified in this method. */ protected function addRefFKGet(&$script, ForeignKey $refFK) @@ -848,8 +883,8 @@ protected function addRefFKGet(&$script, ForeignKey $refFK) * Gets an array of $className objects which contain a foreign key that references this object. * * If this collection has already been initialized with an identical Criteria, it returns the collection. - * Otherwise if this ".$this->getObjectClassname()." has previously been saved, it will retrieve - * related $relCol from storage. If this ".$this->getObjectClassname()." is new, it will return + * Otherwise if this " . $this->getObjectClassname() . " has previously been saved, it will retrieve + * related $relCol from storage. If this " . $this->getObjectClassname() . " is new, it will return * an empty collection or the current collection, the criteria is ignored on a new object. * * @param PropelPDO \$con @@ -881,13 +916,13 @@ public function get$relCol(\$criteria = null, PropelPDO \$con = null) $clo = strtolower($localColumn->getName()); $script .= " - \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->$clo); + \$criteria->add(" . $fkPeerBuilder->getColumnConstant($colFK) . ", \$this->$clo); "; } // end foreach ($fk->getForeignColumns() $script .= " - ".$fkPeerBuilder->getPeerClassname()."::addSelectColumns(\$criteria); - \$this->$collName = ".$fkPeerBuilder->getPeerClassname()."::doSelect(\$criteria, \$con); + " . $fkPeerBuilder->getPeerClassname() . "::addSelectColumns(\$criteria); + \$this->$collName = " . $fkPeerBuilder->getPeerClassname() . "::doSelect(\$criteria, \$con); } } else { // criteria has no effect for a new object @@ -904,13 +939,13 @@ public function get$relCol(\$criteria = null, PropelPDO \$con = null) $clo = strtolower($localColumn->getName()); $script .= " - \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->$clo); + \$criteria->add(" . $fkPeerBuilder->getColumnConstant($colFK) . ", \$this->$clo); "; } // foreach ($fk->getForeignColumns() $script .= " - ".$fkPeerBuilder->getPeerClassname()."::addSelectColumns(\$criteria); - if (!isset(\$this->$lastCriteriaName) || !\$this->".$lastCriteriaName."->equals(\$criteria)) { - \$this->$collName = ".$fkPeerBuilder->getPeerClassname()."::doSelect(\$criteria, \$con); + " . $fkPeerBuilder->getPeerClassname() . "::addSelectColumns(\$criteria); + if (!isset(\$this->$lastCriteriaName) || !\$this->" . $lastCriteriaName . "->equals(\$criteria)) { + \$this->$collName = " . $fkPeerBuilder->getPeerClassname() . "::doSelect(\$criteria, \$con); } } } @@ -924,6 +959,7 @@ public function get$relCol(\$criteria = null, PropelPDO \$con = null) /** * Adds the method that gets a one-to-one related referrer fkey. * This is for one-to-one relationship special case. + * * @param string &$script The script will be modified in this method. */ protected function addPKRefFKGet(&$script, ForeignKey $refFK) @@ -945,7 +981,7 @@ protected function addPKRefFKGet(&$script, ForeignKey $refFK) * @return $className * @throws PropelException */ - public function get".$this->getRefFKPhpNameAffix($refFK, $plural = false)."(PropelPDO \$con = null) + public function get" . $this->getRefFKPhpNameAffix($refFK, $plural = false) . "(PropelPDO \$con = null) { "; $script .= " @@ -970,7 +1006,7 @@ public function get".$this->getRefFKPhpNameAffix($refFK, $plural = false)."(Prop } $script .= " - \$this->$varName = ".$joinedTableObjectBuilder->getPeerClassname()."::retrieveByPK(".implode(", ", $params).", \$con); + \$this->$varName = " . $joinedTableObjectBuilder->getPeerClassname() . "::retrieveByPK(" . implode(", ", $params) . ", \$con); } return \$this->$varName; diff --git a/generator/lib/builder/om/PHP5PeerBuilder.php b/generator/lib/builder/om/PHP5PeerBuilder.php index 6cbb4deb7..fb132b714 100644 --- a/generator/lib/builder/om/PHP5PeerBuilder.php +++ b/generator/lib/builder/om/PHP5PeerBuilder.php @@ -54,6 +54,7 @@ protected function validateModel() /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -63,6 +64,7 @@ public function getUnprefixedClassname() /** * Gets the package for the [base] peer classes. + * * @return string */ public function getPackage() @@ -83,6 +85,7 @@ public function getNamespace() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) @@ -91,6 +94,7 @@ protected function addIncludes(&$script) /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -115,7 +119,7 @@ protected function addClassOpen(&$script) } $script .= " - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */"; } @@ -126,7 +130,7 @@ protected function addClassOpen(&$script) } $script .= " -abstract class ".$this->getClassname(). $extendingPeerClass . " +abstract class " . $this->getClassname() . $extendingPeerClass . " { "; } @@ -142,13 +146,15 @@ protected function addClassBody(&$script) /** * Closes class. * Adds closing brace at end of class and the static map builder registration code. + * * @param string &$script The script will be modified in this method. + * * @see addStaticTableMapRegistration() */ protected function addClassClose(&$script) { - // apply behaviors - $this->applyBehaviorModifier('staticMethods', $script, " "); + // apply behaviors + $this->applyBehaviorModifier('staticMethods', $script, " "); $script .= " } // " . $this->getClassname() . " @@ -158,6 +164,7 @@ protected function addClassClose(&$script) /** * Adds the static map builder registration code. + * * @param string &$script The script will be modified in this method. */ protected function addStaticTableMapRegistration(&$script) @@ -167,7 +174,7 @@ protected function addStaticTableMapRegistration(&$script) $script .= " // This is the static code needed to register the TableMap for this table with the main Propel class. // -".$this->getClassName()."::buildTableMap(); +" . $this->getClassName() . "::buildTableMap(); "; $this->applyBehaviorModifier('peerFilter', $script, ""); @@ -185,7 +192,9 @@ public function getTablePhpName() /** * Adds constant and variable declarations that go at the top of the class. + * * @param string &$script The script will be modified in this method. + * * @see addColumnNameConstants() */ protected function addConstantsAndAttributes(&$script) @@ -204,16 +213,16 @@ protected function addConstantsAndAttributes(&$script) const OM_CLASS = '$tablePhpName'; /** the related TableMap class for this table */ - const TM_CLASS = '".$this->getTableMapClass()."'; + const TM_CLASS = '" . $this->getTableMapClass() . "'; /** The total number of columns. */ - const NUM_COLUMNS = ".$this->getTable()->getNumColumns()."; + const NUM_COLUMNS = " . $this->getTable()->getNumColumns() . "; /** The number of lazy-loaded columns. */ - const NUM_LAZY_LOAD_COLUMNS = ".$this->getTable()->getNumLazyLoadColumns()."; + const NUM_LAZY_LOAD_COLUMNS = " . $this->getTable()->getNumLazyLoadColumns() . "; /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = ". ($this->getTable()->getNumColumns() - $this->getTable()->getNumLazyLoadColumns()) ."; + const NUM_HYDRATE_COLUMNS = " . ($this->getTable()->getNumColumns() - $this->getTable()->getNumLazyLoadColumns()) . "; "; $this->addColumnNameConstants($script); $this->addInheritanceColumnConstants($script); @@ -226,10 +235,10 @@ protected function addConstantsAndAttributes(&$script) const DEFAULT_STRING_FORMAT = '" . $this->getTable()->getDefaultStringFormat() . "'; /** - * An identity map to hold any loaded instances of ".$this->getObjectClassname()." objects. + * An identity map to hold any loaded instances of " . $this->getObjectClassname() . " objects. * This must be public so that other peer classes can access this when hydrating from JOIN * queries. - * @var array ".$this->getObjectClassname()."[] + * @var array " . $this->getObjectClassname() . "[] */ public static \$instances = array(); @@ -249,20 +258,22 @@ protected function addConstantsAndAttributes(&$script) /** * Adds the COLUMN_NAME constants to the class definition. + * * @param string &$script The script will be modified in this method. */ protected function addColumnNameConstants(&$script) { foreach ($this->getTable()->getColumns() as $col) { $script .= " - /** the column name for the " . $col->getName() ." field */ - const ".$this->getColumnName($col) ." = '" . $this->getTable()->getName() . ".".$col->getName()."'; + /** the column name for the " . $col->getName() . " field */ + const " . $this->getColumnName($col) . " = '" . $this->getTable()->getName() . "." . $col->getName() . "'; "; } // foreach } /** * Adds the valueSet constants for ENUM columns. + * * @param string &$script The script will be modified in this method. */ protected function addEnumColumnConstants(&$script) @@ -297,22 +308,22 @@ protected function addFieldNamesAttribute(&$script) * holds an array of fieldnames * * first dimension keys are the type constants - * e.g. ".$this->getPeerClassname()."::\$fieldNames[".$this->getPeerClassname()."::TYPE_PHPNAME][0] = 'Id' + * e.g. " . $this->getPeerClassname() . "::\$fieldNames[" . $this->getPeerClassname() . "::TYPE_PHPNAME][0] = 'Id' */ protected static \$fieldNames = array ( BasePeer::TYPE_PHPNAME => array ("; foreach ($tableColumns as $col) { - $script .= "'".$col->getPhpName()."', "; + $script .= "'" . $col->getPhpName() . "', "; } $script .= "), BasePeer::TYPE_STUDLYPHPNAME => array ("; foreach ($tableColumns as $col) { - $script .= "'".$col->getStudlyPhpName()."', "; + $script .= "'" . $col->getStudlyPhpName() . "', "; } $script .= "), BasePeer::TYPE_COLNAME => array ("; foreach ($tableColumns as $col) { - $script .= $this->getColumnConstant($col, $this->getPeerClassname()).", "; + $script .= $this->getColumnConstant($col, $this->getPeerClassname()) . ", "; } $script .= "), BasePeer::TYPE_RAW_COLNAME => array ("; @@ -322,7 +333,7 @@ protected function addFieldNamesAttribute(&$script) $script .= "), BasePeer::TYPE_FIELDNAME => array ("; foreach ($tableColumns as $col) { - $script .= "'".$col->getName()."', "; + $script .= "'" . $col->getName() . "', "; } $script .= "), BasePeer::TYPE_NUM => array ("; @@ -345,22 +356,22 @@ protected function addFieldKeysAttribute(&$script) * holds an array of keys for quick access to the fieldnames array * * first dimension keys are the type constants - * e.g. ".$this->getPeerClassname()."::\$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + * e.g. " . $this->getPeerClassname() . "::\$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static \$fieldKeys = array ( BasePeer::TYPE_PHPNAME => array ("; foreach ($tableColumns as $num => $col) { - $script .= "'".$col->getPhpName()."' => $num, "; + $script .= "'" . $col->getPhpName() . "' => $num, "; } $script .= "), BasePeer::TYPE_STUDLYPHPNAME => array ("; foreach ($tableColumns as $num => $col) { - $script .= "'".$col->getStudlyPhpName()."' => $num, "; + $script .= "'" . $col->getStudlyPhpName() . "' => $num, "; } $script .= "), BasePeer::TYPE_COLNAME => array ("; foreach ($tableColumns as $num => $col) { - $script .= $this->getColumnConstant($col, $this->getPeerClassname())." => $num, "; + $script .= $this->getColumnConstant($col, $this->getPeerClassname()) . " => $num, "; } $script .= "), BasePeer::TYPE_RAW_COLNAME => array ("; @@ -370,7 +381,7 @@ protected function addFieldKeysAttribute(&$script) $script .= "), BasePeer::TYPE_FIELDNAME => array ("; foreach ($tableColumns as $num => $col) { - $script .= "'".$col->getName()."' => $num, "; + $script .= "'" . $col->getName() . "' => $num, "; } $script .= "), BasePeer::TYPE_NUM => array ("; @@ -384,6 +395,7 @@ protected function addFieldKeysAttribute(&$script) /** * Adds the valueSet attributes for ENUM columns. + * * @param string &$script The script will be modified in this method. */ protected function addEnumColumnAttributes(&$script) @@ -394,7 +406,7 @@ protected function addEnumColumnAttributes(&$script) foreach ($this->getTable()->getColumns() as $col) { if ($col->isEnumType() || $col->getValueSet()) { $script .= " - ".$this->getPeerClassname()."::" . $this->getColumnName($col) ." => array( + " . $this->getPeerClassname() . "::" . $this->getColumnName($col) . " => array( "; foreach ($col->getValueSet() as $value) { $script .= " " . $this->getStubPeerBuilder()->getClassname() . '::' . $this->getColumnName($col) . '_' . $this->getEnumValueConstant($value) . ", @@ -422,14 +434,13 @@ protected function addGetFieldNames(&$script) */ public static function getFieldNames(\$type = BasePeer::TYPE_PHPNAME) { - if (!array_key_exists(\$type, ".$this->getPeerClassname()."::\$fieldNames)) { + if (!array_key_exists(\$type, " . $this->getPeerClassname() . "::\$fieldNames)) { throw new PropelException('Method getFieldNames() expects the parameter \$type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . \$type . ' was given.'); } - return ".$this->getPeerClassname()."::\$fieldNames[\$type]; + return " . $this->getPeerClassname() . "::\$fieldNames[\$type]; } "; - } // addGetFieldNames() protected function addTranslateFieldName(&$script) @@ -447,10 +458,10 @@ protected function addTranslateFieldName(&$script) */ public static function translateFieldName(\$name, \$fromType, \$toType) { - \$toNames = ".$this->getPeerClassname()."::getFieldNames(\$toType); - \$key = isset(".$this->getPeerClassname()."::\$fieldKeys[\$fromType][\$name]) ? ".$this->getPeerClassname()."::\$fieldKeys[\$fromType][\$name] : null; + \$toNames = " . $this->getPeerClassname() . "::getFieldNames(\$toType); + \$key = isset(" . $this->getPeerClassname() . "::\$fieldKeys[\$fromType][\$name]) ? " . $this->getPeerClassname() . "::\$fieldKeys[\$fromType][\$name] : null; if (\$key === null) { - throw new PropelException(\"'\$name' could not be found in the field names of type '\$fromType'. These are: \" . print_r(".$this->getPeerClassname()."::\$fieldKeys[\$fromType], true)); + throw new PropelException(\"'\$name' could not be found in the field names of type '\$fromType'. These are: \" . print_r(" . $this->getPeerClassname() . "::\$fieldKeys[\$fromType], true)); } return \$toNames[\$key]; @@ -460,6 +471,7 @@ public static function translateFieldName(\$name, \$fromType, \$toType) /** * Adds the getValueSets() method. + * * @param string &$script The script will be modified in this method. */ protected function addGetValueSets(&$script) @@ -480,6 +492,7 @@ public static function getValueSets() /** * Adds the getValueSet() method. + * * @param string &$script The script will be modified in this method. */ protected function addGetValueSet(&$script) @@ -495,7 +508,7 @@ protected function addGetValueSet(&$script) */ public static function getValueSet(\$colname) { - \$valueSets = ".$this->getPeerClassname()."::getValueSets(); + \$valueSets = " . $this->getPeerClassname() . "::getValueSets(); if (!isset(\$valueSets[\$colname])) { throw new PropelException(sprintf('Column \"%s\" has no ValueSet.', \$colname)); @@ -508,6 +521,7 @@ public static function getValueSet(\$colname) /** * Adds the getSqlValueForEnum() method. + * * @param string &$script The script will be modified in this method. */ protected function addGetSqlValueForEnum(&$script) @@ -524,7 +538,7 @@ protected function addGetSqlValueForEnum(&$script) */ public static function getSqlValueForEnum(\$colname, \$enumVal) { - \$values = ".$this->getPeerClassname()."::getValueSet(\$colname); + \$values = " . $this->getPeerClassname() . "::getValueSet(\$colname); if (!in_array(\$enumVal, \$values)) { throw new PropelException(sprintf('Value \"%s\" is not accepted in this enumerated column', \$colname)); } @@ -536,16 +550,17 @@ public static function getSqlValueForEnum(\$colname, \$enumVal) /** * Adds methods for ENUM columns. + * * @param string &$script The script will be modified in this method. */ protected function addEnumMethods(&$script) { foreach ($this->getTable()->getColumns() as $col) { - /* @var $col Column */ + /* @var $col Column */ if ($col->isEnumType()) { $script .= " /** - * Gets the SQL value for ".$col->getPhpName()." ENUM value + * Gets the SQL value for " . $col->getPhpName() . " ENUM value * * @param string \$enumVal ENUM value to get SQL value for * @return int SQL value @@ -561,6 +576,7 @@ public static function get{$col->getPhpName()}SqlValue(\$enumVal) /** * Adds the buildTableMap() method. + * * @param string &$script The script will be modified in this method. */ protected function addBuildTableMap(&$script) @@ -572,9 +588,9 @@ protected function addBuildTableMap(&$script) */ public static function buildTableMap() { - \$dbMap = Propel::getDatabaseMap(".$this->getClassname()."::DATABASE_NAME); - if (!\$dbMap->hasTable(".$this->getClassname()."::TABLE_NAME)) { - \$dbMap->addTableObject(new ".$this->getTableMapClass()."()); + \$dbMap = Propel::getDatabaseMap(" . $this->getClassname() . "::DATABASE_NAME); + if (!\$dbMap->hasTable(" . $this->getClassname() . "::TABLE_NAME)) { + \$dbMap->addTableObject(new " . $this->getTableMapClass() . "()); } } "; @@ -582,6 +598,7 @@ public static function buildTableMap() /** * Adds the CLASSKEY_* and CLASSNAME_* constants used for inheritance. + * * @param string &$script The script will be modified in this method. */ public function addInheritanceColumnConstants(&$script) @@ -593,8 +610,11 @@ public function addInheritanceColumnConstants(&$script) if ($col->isEnumeratedClasses()) { - if ($col->isPhpPrimitiveNumericType()) $quote = ""; - else $quote = '"'; + if ($col->isPhpPrimitiveNumericType()) { + $quote = ""; + } else { + $quote = '"'; + } foreach ($col->getChildren() as $child) { $childBuilder = $this->getMultiExtendObjectBuilder(); @@ -603,28 +623,28 @@ public function addInheritanceColumnConstants(&$script) $script .= " /** A key representing a particular subclass */ - const CLASSKEY_".strtoupper($child->getKey())." = '" . $child->getKey() . "'; + const CLASSKEY_" . strtoupper($child->getKey()) . " = '" . $child->getKey() . "'; "; if (strtoupper($child->getClassname()) != strtoupper($child->getKey())) { $script .= " /** A key representing a particular subclass */ - const CLASSKEY_".strtoupper($child->getClassname())." = '" . $child->getKey() . "'; + const CLASSKEY_" . strtoupper($child->getClassname()) . " = '" . $child->getKey() . "'; "; } $script .= " /** A class that can be returned by this peer. */ - const CLASSNAME_".strtoupper($child->getKey())." = '". $fqcn . "'; + const CLASSNAME_" . strtoupper($child->getKey()) . " = '" . $fqcn . "'; "; } /* foreach children */ } /* if col->isenumerated...() */ } /* if table->getchildrencolumn() */ - } // /** * Adds the alias() utility method. + * * @param string &$script The script will be modified in this method. */ protected function addAlias(&$script) @@ -639,18 +659,19 @@ protected function addAlias(&$script) * \$c->addJoin(TablePeer::alias(\"alias1\", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); * * @param string \$alias The alias for the current table. - * @param string \$column The column name for current table. (i.e. ".$this->getPeerClassname()."::COLUMN_NAME). + * @param string \$column The column name for current table. (i.e. " . $this->getPeerClassname() . "::COLUMN_NAME). * @return string */ public static function alias(\$alias, \$column) { - return str_replace(".$this->getPeerClassname()."::TABLE_NAME.'.', \$alias.'.', \$column); + return str_replace(" . $this->getPeerClassname() . "::TABLE_NAME.'.', \$alias.'.', \$column); } "; } // addAliasMethod /** * Adds the addSelectColumns() method. + * * @param string &$script The script will be modified in this method. */ protected function addAddSelectColumns(&$script) @@ -674,7 +695,7 @@ public static function addSelectColumns(Criteria \$criteria, \$alias = null) foreach ($this->getTable()->getColumns() as $col) { if (!$col->isLazyLoad()) { $script .= " - \$criteria->addSelectColumn(".$this->getPeerClassname()."::".$this->getColumnName($col).");"; + \$criteria->addSelectColumn(" . $this->getPeerClassname() . "::" . $this->getColumnName($col) . ");"; } // if !col->isLazyLoad } // foreach $script .= " @@ -682,18 +703,19 @@ public static function addSelectColumns(Criteria \$criteria, \$alias = null) foreach ($this->getTable()->getColumns() as $col) { if (!$col->isLazyLoad()) { $script .= " - \$criteria->addSelectColumn(\$alias . '." . $col->getName()."');"; + \$criteria->addSelectColumn(\$alias . '." . $col->getName() . "');"; } // if !col->isLazyLoad } // foreach $script .= " }"; - $script .=" + $script .= " } "; } // addAddSelectColumns() /** * Adds the doCount() method. + * * @param string &$script The script will be modified in this method. */ protected function addDoCount(&$script) @@ -715,29 +737,29 @@ public static function doCount(Criteria \$criteria, \$distinct = false, PropelPD // We need to set the primary table name, since in the case that there are no WHERE columns // it will be impossible for the BasePeer::createSelectSql() method to determine which // tables go into the FROM clause. - \$criteria->setPrimaryTableName(".$this->getPeerClassname()."::TABLE_NAME); + \$criteria->setPrimaryTableName(" . $this->getPeerClassname() . "::TABLE_NAME); if (\$distinct && !in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) { \$criteria->setDistinct(); } if (!\$criteria->hasSelectClause()) { - ".$this->getPeerClassname()."::addSelectColumns(\$criteria); + " . $this->getPeerClassname() . "::addSelectColumns(\$criteria); } \$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - \$criteria->setDbName(".$this->getPeerClassname()."::DATABASE_NAME); // Set the correct dbName + \$criteria->setDbName(" . $this->getPeerClassname() . "::DATABASE_NAME); // Set the correct dbName if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_READ); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_READ); }"; // apply behaviors - $this->applyBehaviorModifier('preSelect', $script); + $this->applyBehaviorModifier('preSelect', $script); $script .= " // BasePeer returns a PDOStatement - \$stmt = ".$this->basePeerClassname."::doCount(\$criteria, \$con); + \$stmt = " . $this->basePeerClassname . "::doCount(\$criteria, \$con); if (\$row = \$stmt->fetch(PDO::FETCH_NUM)) { \$count = (int) \$row[0]; @@ -752,6 +774,7 @@ public static function doCount(Criteria \$criteria, \$distinct = false, PropelPD /** * Adds the doSelectOne() method. + * * @param string &$script The script will be modified in this method. */ protected function addDoSelectOne(&$script) @@ -762,7 +785,7 @@ protected function addDoSelectOne(&$script) * * @param Criteria \$criteria object used to create the SELECT statement. * @param PropelPDO \$con - * @return ".$this->getObjectClassname()." + * @return " . $this->getObjectClassname() . " * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ @@ -770,7 +793,7 @@ public static function doSelectOne(Criteria \$criteria, PropelPDO \$con = null) { \$critcopy = clone \$criteria; \$critcopy->setLimit(1); - \$objects = ".$this->getPeerClassname()."::doSelect(\$critcopy, \$con); + \$objects = " . $this->getPeerClassname() . "::doSelect(\$critcopy, \$con); if (\$objects) { return \$objects[0]; } @@ -781,6 +804,7 @@ public static function doSelectOne(Criteria \$criteria, PropelPDO \$con = null) /** * Adds the doSelect() method. + * * @param string &$script The script will be modified in this method. */ protected function addDoSelect(&$script) @@ -797,12 +821,13 @@ protected function addDoSelect(&$script) */ public static function doSelect(Criteria \$criteria, PropelPDO \$con = null) { - return ".$this->getPeerClassname()."::populateObjects(".$this->getPeerClassname()."::doSelectStmt(\$criteria, \$con)); + return " . $this->getPeerClassname() . "::populateObjects(" . $this->getPeerClassname() . "::doSelectStmt(\$criteria, \$con)); }"; } /** * Adds the doSelectStmt() method. + * * @param string &$script The script will be modified in this method. */ protected function addDoSelectStmt(&$script) @@ -820,29 +845,29 @@ protected function addDoSelectStmt(&$script) * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. * @return PDOStatement The executed PDOStatement object. - * @see ".$this->basePeerClassname."::doSelect() + * @see " . $this->basePeerClassname . "::doSelect() */ public static function doSelectStmt(Criteria \$criteria, PropelPDO \$con = null) { if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_READ); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_READ); } if (!\$criteria->hasSelectClause()) { \$criteria = clone \$criteria; - ".$this->getPeerClassname()."::addSelectColumns(\$criteria); + " . $this->getPeerClassname() . "::addSelectColumns(\$criteria); } // Set the correct dbName - \$criteria->setDbName(".$this->getPeerClassname()."::DATABASE_NAME);"; + \$criteria->setDbName(" . $this->getPeerClassname() . "::DATABASE_NAME);"; // apply behaviors if ($this->hasBehaviorModifier('preSelect')) { - $this->applyBehaviorModifier('preSelect', $script); + $this->applyBehaviorModifier('preSelect', $script); } $script .= " // BasePeer returns a PDOStatement - return ".$this->basePeerClassname."::doSelect(\$criteria, \$con); + return " . $this->basePeerClassname . "::doSelect(\$criteria, \$con); }"; } @@ -873,6 +898,7 @@ public function getInstancePoolKeySnippet($pkphp) /** * Creates a convenience method to add objects to an instance pool. + * * @param string &$script The script will be modified in this method. */ protected function addAddInstanceToPool(&$script) @@ -888,7 +914,7 @@ protected function addAddInstanceToPool(&$script) * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * - * @param ".$this->getObjectClassname()." \$obj A ".$this->getObjectClassname()." object. + * @param " . $this->getObjectClassname() . " \$obj A " . $this->getObjectClassname() . " object. * @param string \$key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(\$obj, \$key = null) @@ -907,10 +933,10 @@ public static function addInstanceToPool(\$obj, \$key = null) } } $script .= " - \$key = ".$this->getInstancePoolKeySnippet($php).";"; + \$key = " . $this->getInstancePoolKeySnippet($php) . ";"; $script .= " } // if key === null - ".$this->getPeerClassname()."::\$instances[\$key] = \$obj; + " . $this->getPeerClassname() . "::\$instances[\$key] = \$obj; } } "; @@ -918,6 +944,7 @@ public static function addInstanceToPool(\$obj, \$key = null) /** * Creates a convenience method to remove objects form an instance pool. + * * @param string &$script The script will be modified in this method. */ protected function addRemoveInstanceFromPool(&$script) @@ -932,7 +959,7 @@ protected function addRemoveInstanceFromPool(&$script) * methods in your stub classes -- you may need to explicitly remove objects * from the cache in order to prevent returning objects that no longer exist. * - * @param mixed \$value A ".$this->getObjectClassname()." object or a primary key value. + * @param mixed \$value A " . $this->getObjectClassname() . " object or a primary key value. * * @return void * @throws PropelException - if the value is invalid. @@ -944,36 +971,36 @@ public static function removeInstanceFromPool(\$value) $pks = $table->getPrimaryKey(); $script .= " - if (is_object(\$value) && \$value instanceof ".$this->getObjectClassname().") {"; + if (is_object(\$value) && \$value instanceof " . $this->getObjectClassname() . ") {"; - $php = array(); - foreach ($pks as $pk) { - $php[] = '$value->get' . $pk->getPhpName() . '()'; - } - $script .= " - \$key = ".$this->getInstancePoolKeySnippet($php).";"; + $php = array(); + foreach ($pks as $pk) { + $php[] = '$value->get' . $pk->getPhpName() . '()'; + } + $script .= " + \$key = " . $this->getInstancePoolKeySnippet($php) . ";"; $script .= " - } elseif (".(count($pks) > 1 ? "is_array(\$value) && count(\$value) === " . count($pks) : "is_scalar(\$value)").") { + } elseif (" . (count($pks) > 1 ? "is_array(\$value) && count(\$value) === " . count($pks) : "is_scalar(\$value)") . ") { // assume we've been passed a primary key"; if (count($pks) > 1) { $php = array(); - for ($i=0; $i < count($pks); $i++) { + for ($i = 0; $i < count($pks); $i++) { $php[] = "\$value[$i]"; } } else { $php = '$value'; } $script .= " - \$key = ".$this->getInstancePoolKeySnippet($php).";"; + \$key = " . $this->getInstancePoolKeySnippet($php) . ";"; $script .= " } else { - \$e = new PropelException(\"Invalid value passed to removeInstanceFromPool(). Expected primary key or ".$this->getObjectClassname()." object; got \" . (is_object(\$value) ? get_class(\$value) . ' object.' : var_export(\$value,true))); + \$e = new PropelException(\"Invalid value passed to removeInstanceFromPool(). Expected primary key or " . $this->getObjectClassname() . " object; got \" . (is_object(\$value) ? get_class(\$value) . ' object.' : var_export(\$value,true))); throw \$e; } - unset(".$this->getPeerClassname()."::\$instances[\$key]); + unset(" . $this->getPeerClassname() . "::\$instances[\$key]); } } // removeInstanceFromPool() "; @@ -981,6 +1008,7 @@ public static function removeInstanceFromPool(\$value) /** * Adds method to clear the instance pool. + * * @param string &$script The script will be modified in this method. */ protected function addClearInstancePool(&$script) @@ -994,17 +1022,18 @@ protected function addClearInstancePool(&$script) public static function clearInstancePool(\$and_clear_all_references = false) { if (\$and_clear_all_references) { - foreach (".$this->getPeerClassname()."::\$instances as \$instance) { + foreach (" . $this->getPeerClassname() . "::\$instances as \$instance) { \$instance->clearAllReferences(true); } } - ".$this->getPeerClassname()."::\$instances = array(); + " . $this->getPeerClassname() . "::\$instances = array(); } "; } /** * Adds method to clear the instance pool of related tables. + * * @param string &$script The script will be modified in this method. */ protected function addClearRelatedInstancePool(&$script) @@ -1035,9 +1064,9 @@ public static function clearRelatedInstancePool() if ($fk->getOnDelete() == ForeignKey::CASCADE || $fk->getOnDelete() == ForeignKey::SETNULL) { $script .= " - // Invalidate objects in ".$joinedTablePeerBuilder->getClassname()." instance pool, + // Invalidate objects in " . $joinedTablePeerBuilder->getClassname() . " instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ".$joinedTablePeerBuilder->getClassname()."::clearInstancePool();"; + " . $joinedTablePeerBuilder->getClassname() . "::clearInstancePool();"; } // if fk is on delete cascade } // if (! for ref only) } // foreach @@ -1048,6 +1077,7 @@ public static function clearRelatedInstancePool() /** * Adds method to get an the instance from the pool, given a key. + * * @param string &$script The script will be modified in this method. */ protected function addGetInstanceFromPool(&$script) @@ -1060,14 +1090,14 @@ protected function addGetInstanceFromPool(&$script) * a multi-column primary key, a serialize()d version of the primary key will be returned. * * @param string \$key The key (@see getPrimaryKeyHash()) for this instance. - * @return ".$this->getObjectClassname()." Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. + * @return " . $this->getObjectClassname() . " Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. * @see getPrimaryKeyHash() */ public static function getInstanceFromPool(\$key) { if (Propel::isInstancePoolingEnabled()) { - if (isset(".$this->getPeerClassname()."::\$instances[\$key])) { - return ".$this->getPeerClassname()."::\$instances[\$key]; + if (isset(" . $this->getPeerClassname() . "::\$instances[\$key])) { + return " . $this->getPeerClassname() . "::\$instances[\$key]; } } @@ -1078,6 +1108,7 @@ public static function getInstanceFromPool(\$key) /** * Adds method to get a version of the primary key that can be used as a unique key for identifier map. + * * @param string &$script The script will be modified in this method. */ protected function addGetPrimaryKeyHash(&$script) @@ -1114,22 +1145,23 @@ public static function getPrimaryKeyHashFromRow(\$row, \$startcol = 0) $script .= " // If the PK cannot be derived from the row, return null. - if (".implode(' && ', $cond).") { + if (" . implode(' && ', $cond) . ") { return null; } - return ".$this->getInstancePoolKeySnippet($pk)."; + return " . $this->getInstancePoolKeySnippet($pk) . "; } "; } // addGetPrimaryKeyHash - /** - * Adds method to get the primary key from a row - * @param string &$script The script will be modified in this method. - */ - protected function addGetPrimaryKeyFromRow(&$script) - { - $script .= " + /** + * Adds method to get the primary key from a row + * + * @param string &$script The script will be modified in this method. + */ + protected function addGetPrimaryKeyFromRow(&$script) + { + $script .= " /** * Retrieves the primary key from the DB resultset row * For tables with a single-column primary key, that simple pkey value will be returned. For tables with @@ -1142,38 +1174,39 @@ protected function addGetPrimaryKeyFromRow(&$script) public static function getPrimaryKeyFromRow(\$row, \$startcol = 0) {"; - // We have to iterate through all the columns so that we know the offset of the primary - // key columns. - $table = $this->getTable(); - $n = 0; - $pks = array(); - foreach ($table->getColumns() as $col) { - if (!$col->isLazyLoad()) { - if ($col->isPrimaryKey()) { - $pk = '(' . $col->getPhpType() . ') ' . ($n ? "\$row[\$startcol + $n]" : "\$row[\$startcol]"); - if ($table->hasCompositePrimaryKey()) { - $pks[] = $pk; - } + // We have to iterate through all the columns so that we know the offset of the primary + // key columns. + $table = $this->getTable(); + $n = 0; + $pks = array(); + foreach ($table->getColumns() as $col) { + if (!$col->isLazyLoad()) { + if ($col->isPrimaryKey()) { + $pk = '(' . $col->getPhpType() . ') ' . ($n ? "\$row[\$startcol + $n]" : "\$row[\$startcol]"); + if ($table->hasCompositePrimaryKey()) { + $pks[] = $pk; } - $n++; } + $n++; } - if ($table->hasCompositePrimaryKey()) { - $script .= " + } + if ($table->hasCompositePrimaryKey()) { + $script .= " - return array(" . implode($pks, ', '). ");"; - } else { - $script .= " + return array(" . implode($pks, ', ') . ");"; + } else { + $script .= " return " . $pk . ";"; - } - $script .= " + } + $script .= " } "; - } // addGetPrimaryKeyFromRow + } // addGetPrimaryKeyFromRow /** * Adds the populateObjects() method. + * * @param string &$script The script will be modified in this method. */ protected function addPopulateObjects(&$script) @@ -1194,14 +1227,14 @@ public static function populateObjects(PDOStatement \$stmt) if (!$table->getChildrenColumn()) { $script .= " // set the class once to avoid overhead in the loop - \$cls = ".$this->getPeerClassname()."::getOMClass();"; + \$cls = " . $this->getPeerClassname() . "::getOMClass();"; } $script .= " // populate the object(s) while (\$row = \$stmt->fetch(PDO::FETCH_NUM)) { - \$key = ".$this->getPeerClassname()."::getPrimaryKeyHashFromRow(\$row, 0); - if (null !== (\$obj = ".$this->getPeerClassname()."::getInstanceFromPool(\$key))) { + \$key = " . $this->getPeerClassname() . "::getPrimaryKeyHashFromRow(\$row, 0); + if (null !== (\$obj = " . $this->getPeerClassname() . "::getInstanceFromPool(\$key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // \$obj->hydrate(\$row, 0, true); // rehydrate @@ -1210,18 +1243,18 @@ public static function populateObjects(PDOStatement \$stmt) if ($table->getChildrenColumn()) { $script .= " // class must be set each time from the record row - \$cls = ".$this->getPeerClassname()."::getOMClass(\$row, 0); + \$cls = " . $this->getPeerClassname() . "::getOMClass(\$row, 0); \$cls = substr('.'.\$cls, strrpos('.'.\$cls, '.') + 1); " . $this->buildObjectInstanceCreationCode('$obj', '$cls') . " \$obj->hydrate(\$row); \$results[] = \$obj; - ".$this->getPeerClassname()."::addInstanceToPool(\$obj, \$key);"; + " . $this->getPeerClassname() . "::addInstanceToPool(\$obj, \$key);"; } else { $script .= " " . $this->buildObjectInstanceCreationCode('$obj', '$cls') . " \$obj->hydrate(\$row); \$results[] = \$obj; - ".$this->getPeerClassname()."::addInstanceToPool(\$obj, \$key);"; + " . $this->getPeerClassname() . "::addInstanceToPool(\$obj, \$key);"; } $script .= " } // if key exists @@ -1234,6 +1267,7 @@ public static function populateObjects(PDOStatement \$stmt) /** * Adds the populateObject() method. + * * @param string &$script The script will be modified in this method. */ protected function addPopulateObject(&$script) @@ -1247,12 +1281,12 @@ protected function addPopulateObject(&$script) * @param int \$startcol The 0-based offset for reading from the resultset row. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. - * @return array (" . $this->getStubObjectBuilder()->getClassName(). " object, last column rank) + * @return array (" . $this->getStubObjectBuilder()->getClassName() . " object, last column rank) */ public static function populateObject(\$row, \$startcol = 0) { - \$key = ".$this->getPeerClassname()."::getPrimaryKeyHashFromRow(\$row, \$startcol); - if (null !== (\$obj = ".$this->getPeerClassname()."::getInstanceFromPool(\$key))) { + \$key = " . $this->getPeerClassname() . "::getPrimaryKeyHashFromRow(\$row, \$startcol); + if (null !== (\$obj = " . $this->getPeerClassname() . "::getInstanceFromPool(\$key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // \$obj->hydrate(\$row, \$startcol, true); // rehydrate @@ -1269,10 +1303,10 @@ public static function populateObject(\$row, \$startcol = 0) } else {"; if (!$table->getChildrenColumn()) { $script .= " - \$cls = ".$this->getPeerClassname()."::OM_CLASS;"; + \$cls = " . $this->getPeerClassname() . "::OM_CLASS;"; } else { $script .= " - \$cls = ".$this->getPeerClassname()."::getOMClass(\$row, \$startcol);"; + \$cls = " . $this->getPeerClassname() . "::getOMClass(\$row, \$startcol);"; } $script .= " \$obj = new \$cls(); @@ -1287,6 +1321,7 @@ public static function populateObject(\$row, \$startcol = 0) /** * Adds a getOMClass() for non-abstract tables that have inheritance. + * * @param string &$script The script will be modified in this method. */ protected function addGetOMClass_Inheritance(&$script) @@ -1315,21 +1350,21 @@ public static function getOMClass(\$row = 0, \$colnum = 0) "; foreach ($col->getChildren() as $child) { $script .= " - case ".$this->getPeerClassname()."::CLASSKEY_".strtoupper($child->getKey()).": - \$omClass = ".$this->getPeerClassname()."::CLASSNAME_".strtoupper($child->getKey())."; + case " . $this->getPeerClassname() . "::CLASSKEY_" . strtoupper($child->getKey()) . ": + \$omClass = " . $this->getPeerClassname() . "::CLASSNAME_" . strtoupper($child->getKey()) . "; break; "; } /* foreach */ $script .= " default: - \$omClass = ".$this->getPeerClassname()."::OM_CLASS; + \$omClass = " . $this->getPeerClassname() . "::OM_CLASS; "; $script .= " } // switch "; } else { /* if not enumerated */ $script .= " - \$omClass = \$row[\$colnum + ".($col->getPosition()-1)."]; + \$omClass = \$row[\$colnum + " . ($col->getPosition() - 1) . "]; \$omClass = substr('.'.\$omClass, strrpos('.'.\$omClass, '.') + 1); "; } @@ -1345,6 +1380,7 @@ public static function getOMClass(\$row = 0, \$colnum = 0) /** * Adds a getOMClass() for non-abstract tables that do note use inheritance. + * * @param string &$script The script will be modified in this method. */ protected function addGetOMClass_NoInheritance(&$script) @@ -1358,13 +1394,14 @@ protected function addGetOMClass_NoInheritance(&$script) */ public static function getOMClass(\$row = 0, \$colnum = 0) { - return ".$this->getPeerClassname()."::OM_CLASS; + return " . $this->getPeerClassname() . "::OM_CLASS; } "; } /** * Adds a getOMClass() signature for abstract tables that do not have inheritance. + * * @param string &$script The script will be modified in this method. */ protected function addGetOMClass_NoInheritance_Abstract(&$script) @@ -1374,7 +1411,7 @@ protected function addGetOMClass_NoInheritance_Abstract(&$script) * The class that the Peer will make instances of. * * This method must be overridden by the stub subclass, because - * ".$this->getObjectClassname()." is declared abstract in the schema. + * " . $this->getObjectClassname() . " is declared abstract in the schema. */"; if (version_compare(PHP_VERSION, '5.3.0', '>=')) { @@ -1393,6 +1430,7 @@ public static function getOMClass(\$row = 0, \$colnum = 0) /** * Adds the doInsert() method. + * * @param string &$script The script will be modified in this method. */ protected function addDoInsert(&$script) @@ -1400,9 +1438,9 @@ protected function addDoInsert(&$script) $table = $this->getTable(); $script .= " /** - * Performs an INSERT on the database, given a ".$this->getObjectClassname()." or Criteria object. + * Performs an INSERT on the database, given a " . $this->getObjectClassname() . " or Criteria object. * - * @param mixed \$values Criteria or ".$this->getObjectClassname()." object containing data that is used to create the INSERT statement. + * @param mixed \$values Criteria or " . $this->getObjectClassname() . " object containing data that is used to create the INSERT statement. * @param PropelPDO \$con the PropelPDO connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be @@ -1411,13 +1449,13 @@ protected function addDoInsert(&$script) public static function doInsert(\$values, PropelPDO \$con = null) { if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_WRITE); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_WRITE); } if (\$values instanceof Criteria) { \$criteria = clone \$values; // rename for clarity } else { - \$criteria = \$values->buildCriteria(); // build Criteria from ".$this->getObjectClassname()." object + \$criteria = \$values->buildCriteria(); // build Criteria from " . $this->getObjectClassname() . " object } "; @@ -1425,21 +1463,21 @@ public static function doInsert(\$values, PropelPDO \$con = null) $cfc = $col->getPhpName(); if ($col->isPrimaryKey() && $col->isAutoIncrement() && $table->getIdMethod() != "none" && !$table->isAllowPkInsert()) { $script .= " - if (\$criteria->containsKey(".$this->getColumnConstant($col).") && \$criteria->keyContainsValue(" . $this->getColumnConstant($col) . ") ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.".$this->getColumnConstant($col).".')'); + if (\$criteria->containsKey(" . $this->getColumnConstant($col) . ") && \$criteria->keyContainsValue(" . $this->getColumnConstant($col) . ") ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('." . $this->getColumnConstant($col) . ".')'); } "; if (!$this->getPlatform()->supportsInsertNullPk()) { - $script .= " + $script .= " // remove pkey col since this table uses auto-increment and passing a null value for it is not valid - \$criteria->remove(".$this->getColumnConstant($col)."); + \$criteria->remove(" . $this->getColumnConstant($col) . "); "; } } elseif ($col->isPrimaryKey() && $col->isAutoIncrement() && $table->getIdMethod() != "none" && $table->isAllowPkInsert() && !$this->getPlatform()->supportsInsertNullPk()) { - $script .= " + $script .= " // remove pkey col if it is null since this table does not accept that - if (\$criteria->containsKey(".$this->getColumnConstant($col).") && !\$criteria->keyContainsValue(" . $this->getColumnConstant($col) . ") ) { - \$criteria->remove(".$this->getColumnConstant($col)."); + if (\$criteria->containsKey(" . $this->getColumnConstant($col) . ") && !\$criteria->keyContainsValue(" . $this->getColumnConstant($col) . ") ) { + \$criteria->remove(" . $this->getColumnConstant($col) . "); } "; } @@ -1447,13 +1485,13 @@ public static function doInsert(\$values, PropelPDO \$con = null) $script .= " // Set the correct dbName - \$criteria->setDbName(".$this->getPeerClassname()."::DATABASE_NAME); + \$criteria->setDbName(" . $this->getPeerClassname() . "::DATABASE_NAME); try { // use transaction because \$criteria could contain info // for more than one table (I guess, conceivably) \$con->beginTransaction(); - \$pk = ".$this->basePeerClassname."::doInsert(\$criteria, \$con); + \$pk = " . $this->basePeerClassname . "::doInsert(\$criteria, \$con); \$con->commit(); } catch (PropelException \$e) { \$con->rollBack(); @@ -1467,6 +1505,7 @@ public static function doInsert(\$values, PropelPDO \$con = null) /** * Adds the doUpdate() method. + * * @param string &$script The script will be modified in this method. */ protected function addDoUpdate(&$script) @@ -1474,9 +1513,9 @@ protected function addDoUpdate(&$script) $table = $this->getTable(); $script .= " /** - * Performs an UPDATE on the database, given a ".$this->getObjectClassname()." or Criteria object. + * Performs an UPDATE on the database, given a " . $this->getObjectClassname() . " or Criteria object. * - * @param mixed \$values Criteria or ".$this->getObjectClassname()." object containing data that is used to create the UPDATE statement. + * @param mixed \$values Criteria or " . $this->getObjectClassname() . " object containing data that is used to create the UPDATE statement. * @param PropelPDO \$con The connection to use (specify PropelPDO connection object to exert more control over transactions). * @return int The number of affected rows (if supported by underlying database driver). * @throws PropelException Any exceptions caught during processing will be @@ -1485,10 +1524,10 @@ protected function addDoUpdate(&$script) public static function doUpdate(\$values, PropelPDO \$con = null) { if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_WRITE); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_WRITE); } - \$selectCriteria = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME); + \$selectCriteria = new Criteria(" . $this->getPeerClassname() . "::DATABASE_NAME); if (\$values instanceof Criteria) { \$criteria = clone \$values; // rename for clarity @@ -1496,25 +1535,25 @@ public static function doUpdate(\$values, PropelPDO \$con = null) foreach ($table->getColumns() as $col) { if ($col->isPrimaryKey()) { $script .= " - \$comparison = \$criteria->getComparison(".$this->getColumnConstant($col)."); - \$value = \$criteria->remove(".$this->getColumnConstant($col)."); + \$comparison = \$criteria->getComparison(" . $this->getColumnConstant($col) . "); + \$value = \$criteria->remove(" . $this->getColumnConstant($col) . "); if (\$value) { - \$selectCriteria->add(".$this->getColumnConstant($col).", \$value, \$comparison); + \$selectCriteria->add(" . $this->getColumnConstant($col) . ", \$value, \$comparison); } else { - \$selectCriteria->setPrimaryTableName(".$this->getPeerClassname()."::TABLE_NAME); + \$selectCriteria->setPrimaryTableName(" . $this->getPeerClassname() . "::TABLE_NAME); } "; - } /* if col is prim key */ + } /* if col is prim key */ } /* foreach */ $script .= " - } else { // \$values is ".$this->getObjectClassname()." object + } else { // \$values is " . $this->getObjectClassname() . " object \$criteria = \$values->buildCriteria(); // gets full criteria \$selectCriteria = \$values->buildPkeyCriteria(); // gets criteria w/ primary key(s) } // set the correct dbName - \$criteria->setDbName(".$this->getPeerClassname()."::DATABASE_NAME); + \$criteria->setDbName(" . $this->getPeerClassname() . "::DATABASE_NAME); return {$this->basePeerClassname}::doUpdate(\$selectCriteria, \$criteria, \$con); } @@ -1523,6 +1562,7 @@ public static function doUpdate(\$values, PropelPDO \$con = null) /** * Adds the doDeleteAll() method. + * * @param string &$script The script will be modified in this method. */ protected function addDoDeleteAll(&$script) @@ -1530,7 +1570,7 @@ protected function addDoDeleteAll(&$script) $table = $this->getTable(); $script .= " /** - * Deletes all rows from the ".$table->getName()." table. + * Deletes all rows from the " . $table->getName() . " table. * * @param PropelPDO \$con the connection to use * @return int The number of affected rows (if supported by underlying database driver). @@ -1539,7 +1579,7 @@ protected function addDoDeleteAll(&$script) public static function doDeleteAll(PropelPDO \$con = null) { if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_WRITE); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_WRITE); } \$affectedRows = 0; // initialize var to track total num of affected rows try { @@ -1548,19 +1588,19 @@ public static function doDeleteAll(PropelPDO \$con = null) \$con->beginTransaction(); "; if ($this->isDeleteCascadeEmulationNeeded()) { - $script .="\$affectedRows += ".$this->getPeerClassname()."::doOnDeleteCascade(new Criteria(".$this->getPeerClassname()."::DATABASE_NAME), \$con); + $script .= "\$affectedRows += " . $this->getPeerClassname() . "::doOnDeleteCascade(new Criteria(" . $this->getPeerClassname() . "::DATABASE_NAME), \$con); "; } if ($this->isDeleteSetNullEmulationNeeded()) { - $script .= $this->getPeerClassname() . "::doOnDeleteSetNull(new Criteria(".$this->getPeerClassname() . "::DATABASE_NAME), \$con); + $script .= $this->getPeerClassname() . "::doOnDeleteSetNull(new Criteria(" . $this->getPeerClassname() . "::DATABASE_NAME), \$con); "; } - $script .= "\$affectedRows += {$this->basePeerClassname}::doDeleteAll(".$this->getPeerClassname()."::TABLE_NAME, \$con, ".$this->getPeerClassname()."::DATABASE_NAME); + $script .= "\$affectedRows += {$this->basePeerClassname}::doDeleteAll(" . $this->getPeerClassname() . "::TABLE_NAME, \$con, " . $this->getPeerClassname() . "::DATABASE_NAME); // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). - ".$this->getPeerClassname()."::clearInstancePool(); - ".$this->getPeerClassname()."::clearRelatedInstancePool(); + " . $this->getPeerClassname() . "::clearInstancePool(); + " . $this->getPeerClassname() . "::clearRelatedInstancePool(); \$con->commit(); return \$affectedRows; @@ -1574,6 +1614,7 @@ public static function doDeleteAll(PropelPDO \$con = null) /** * Adds the doDelete() method. + * * @param string &$script The script will be modified in this method. */ protected function addDoDelete(&$script) @@ -1582,9 +1623,9 @@ protected function addDoDelete(&$script) $emulateCascade = $this->isDeleteCascadeEmulationNeeded() || $this->isDeleteSetNullEmulationNeeded(); $script .= " /** - * Performs a DELETE on the database, given a ".$this->getObjectClassname()." or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a " . $this->getObjectClassname() . " or Criteria object OR a primary key value. * - * @param mixed \$values Criteria or ".$this->getObjectClassname()." object or primary key or array of primary keys + * @param mixed \$values Criteria or " . $this->getObjectClassname() . " object or primary key or array of primary keys * which is used to create the DELETE statement * @param PropelPDO \$con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -1595,7 +1636,7 @@ protected function addDoDelete(&$script) public static function doDelete(\$values, PropelPDO \$con = null) { if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_WRITE); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_WRITE); } if (\$values instanceof Criteria) {"; @@ -1604,16 +1645,16 @@ public static function doDelete(\$values, PropelPDO \$con = null) // invalidate the cache for all objects of this type, since we have no // way of knowing (without running a query) what objects should be invalidated // from the cache based on this Criteria. - ".$this->getPeerClassname()."::clearInstancePool();"; + " . $this->getPeerClassname() . "::clearInstancePool();"; } $script .= " // rename for clarity \$criteria = clone \$values; - } elseif (\$values instanceof ".$this->getObjectClassname().") { // it's a model object"; + } elseif (\$values instanceof " . $this->getObjectClassname() . ") { // it's a model object"; if (!$emulateCascade) { $script .= " // invalidate the cache for this single object - ".$this->getPeerClassname()."::removeInstanceFromPool(\$values);"; + " . $this->getPeerClassname() . "::removeInstanceFromPool(\$values);"; } if (count($table->getPrimaryKey()) > 0) { $script .= " @@ -1628,18 +1669,18 @@ public static function doDelete(\$values, PropelPDO \$con = null) $script .= " } else { // it's a primary key, or an array of pks"; $script .= " - \$criteria = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME);"; + \$criteria = new Criteria(" . $this->getPeerClassname() . "::DATABASE_NAME);"; if (count($table->getPrimaryKey()) === 1) { $pkey = $table->getPrimaryKey(); $col = array_shift($pkey); $script .= " - \$criteria->add(".$this->getColumnConstant($col).", (array) \$values, Criteria::IN);"; + \$criteria->add(" . $this->getColumnConstant($col) . ", (array) \$values, Criteria::IN);"; if (!$emulateCascade) { $script .= " // invalidate the cache for this object(s) foreach ((array) \$values as \$singleval) { - ".$this->getPeerClassname()."::removeInstanceFromPool(\$singleval); + " . $this->getPeerClassname() . "::removeInstanceFromPool(\$singleval); }"; } } else { @@ -1651,14 +1692,14 @@ public static function doDelete(\$values, PropelPDO \$con = null) \$values = array(\$values); } foreach (\$values as \$value) {"; - $i=0; + $i = 0; foreach ($table->getPrimaryKey() as $col) { if ($i == 0) { $script .= " - \$criterion = \$criteria->getNewCriterion(".$this->getColumnConstant($col).", \$value[$i]);"; + \$criterion = \$criteria->getNewCriterion(" . $this->getColumnConstant($col) . ", \$value[$i]);"; } else { $script .= " - \$criterion->addAnd(\$criteria->getNewCriterion(".$this->getColumnConstant($col).", \$value[$i]));"; + \$criterion->addAnd(\$criteria->getNewCriterion(" . $this->getColumnConstant($col) . ", \$value[$i]));"; } $i++; } @@ -1667,7 +1708,7 @@ public static function doDelete(\$values, PropelPDO \$con = null) if (!$emulateCascade) { $script .= " // we can invalidate the cache for this single PK - ".$this->getPeerClassname()."::removeInstanceFromPool(\$value);"; + " . $this->getPeerClassname() . "::removeInstanceFromPool(\$value);"; } $script .= " }"; @@ -1677,7 +1718,7 @@ public static function doDelete(\$values, PropelPDO \$con = null) } // Set the correct dbName - \$criteria->setDbName(".$this->getPeerClassname()."::DATABASE_NAME); + \$criteria->setDbName(" . $this->getPeerClassname() . "::DATABASE_NAME); \$affectedRows = 0; // initialize var to track total num of affected rows @@ -1691,7 +1732,7 @@ public static function doDelete(\$values, PropelPDO \$con = null) $script .= " // cloning the Criteria in case it's modified by doSelect() or doSelectStmt() \$c = clone \$criteria; - \$affectedRows += ".$this->getPeerClassname()."::doOnDeleteCascade(\$c, \$con); + \$affectedRows += " . $this->getPeerClassname() . "::doOnDeleteCascade(\$c, \$con); "; } if ($this->isDeleteSetNullEmulationNeeded()) { @@ -1708,12 +1749,12 @@ public static function doDelete(\$values, PropelPDO \$con = null) // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). if (\$values instanceof Criteria) { - ".$this->getPeerClassname()."::clearInstancePool(); - } elseif (\$values instanceof ".$this->getObjectClassname().") { // it's a model object - ".$this->getPeerClassname()."::removeInstanceFromPool(\$values); + " . $this->getPeerClassname() . "::clearInstancePool(); + } elseif (\$values instanceof " . $this->getObjectClassname() . ") { // it's a model object + " . $this->getPeerClassname() . "::removeInstanceFromPool(\$values); } else { // it's a primary key, or an array of pks foreach ((array) \$values as \$singleval) { - ".$this->getPeerClassname()."::removeInstanceFromPool(\$singleval); + " . $this->getPeerClassname() . "::removeInstanceFromPool(\$singleval); } } "; @@ -1721,7 +1762,7 @@ public static function doDelete(\$values, PropelPDO \$con = null) $script .= " \$affectedRows += {$this->basePeerClassname}::doDelete(\$criteria, \$con); - ".$this->getPeerClassname()."::clearRelatedInstancePool(); + " . $this->getPeerClassname() . "::clearRelatedInstancePool(); \$con->commit(); return \$affectedRows; @@ -1735,6 +1776,7 @@ public static function doDelete(\$values, PropelPDO \$con = null) /** * Adds the doOnDeleteCascade() method, which provides ON DELETE CASCADE emulation. + * * @param string &$script The script will be modified in this method. */ protected function addDoOnDeleteCascade(&$script) @@ -1760,7 +1802,7 @@ protected static function doOnDeleteCascade(Criteria \$criteria, PropelPDO \$con \$affectedRows = 0; // first find the objects that are implicated by the \$criteria - \$objects = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con); + \$objects = " . $this->getPeerClassname() . "::doSelect(\$criteria, \$con); foreach (\$objects as \$obj) { "; @@ -1788,19 +1830,18 @@ protected static function doOnDeleteCascade(Criteria \$criteria, PropelPDO \$con $script .= " // delete related $fkClassName objects - \$criteria = new Criteria(".$joinedTablePeerBuilder->getPeerClassname()."::DATABASE_NAME); + \$criteria = new Criteria(" . $joinedTablePeerBuilder->getPeerClassname() . "::DATABASE_NAME); "; - for ($x=0,$xlen=count($columnNamesF); $x < $xlen; $x++) { + for ($x = 0, $xlen = count($columnNamesF); $x < $xlen; $x++) { $columnFK = $tblFK->getColumn($columnNamesF[$x]); $columnL = $table->getColumn($columnNamesL[$x]); $script .= " - \$criteria->add(".$joinedTablePeerBuilder->getColumnConstant($columnFK) .", \$obj->get".$columnL->getPhpName()."());"; + \$criteria->add(" . $joinedTablePeerBuilder->getColumnConstant($columnFK) . ", \$obj->get" . $columnL->getPhpName() . "());"; } $script .= " - \$affectedRows += ".$joinedTablePeerBuilder->getPeerClassname()."::doDelete(\$criteria, \$con);"; - + \$affectedRows += " . $joinedTablePeerBuilder->getPeerClassname() . "::doDelete(\$criteria, \$con);"; } // if cascade && fkey table name != curr table name } // if not for ref only @@ -1815,6 +1856,7 @@ protected static function doOnDeleteCascade(Criteria \$criteria, PropelPDO \$con /** * Adds the doOnDeleteSetNull() method, which provides ON DELETE SET NULL emulation. + * * @param string &$script The script will be modified in this method. */ protected function addDoOnDeleteSetNull(&$script) @@ -1838,7 +1880,7 @@ protected static function doOnDeleteSetNull(Criteria \$criteria, PropelPDO \$con { // first find the objects that are implicated by the \$criteria - \$objects = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con); + \$objects = " . $this->getPeerClassname() . "::doSelect(\$criteria, \$con); foreach (\$objects as \$obj) { "; @@ -1866,15 +1908,15 @@ protected static function doOnDeleteSetNull(Criteria \$criteria, PropelPDO \$con $columnNamesL = $fk->getForeignColumns(); // should be same num as foreign $script .= " // set fkey col in related $fkClassName rows to null - \$selectCriteria = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME); - \$updateValues = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME);"; + \$selectCriteria = new Criteria(" . $this->getPeerClassname() . "::DATABASE_NAME); + \$updateValues = new Criteria(" . $this->getPeerClassname() . "::DATABASE_NAME);"; - for ($x=0,$xlen=count($columnNamesF); $x < $xlen; $x++) { + for ($x = 0, $xlen = count($columnNamesF); $x < $xlen; $x++) { $columnFK = $tblFK->getColumn($columnNamesF[$x]); $columnL = $table->getColumn($columnNamesL[$x]); $script .= " - \$selectCriteria->add(".$refTablePeerBuilder->getColumnConstant($columnFK).", \$obj->get".$columnL->getPhpName()."()); - \$updateValues->add(".$refTablePeerBuilder->getColumnConstant($columnFK).", null); + \$selectCriteria->add(" . $refTablePeerBuilder->getColumnConstant($columnFK) . ", \$obj->get" . $columnL->getPhpName() . "()); + \$updateValues->add(" . $refTablePeerBuilder->getColumnConstant($columnFK) . ", null); "; } @@ -1893,6 +1935,7 @@ protected static function doOnDeleteSetNull(Criteria \$criteria, PropelPDO \$con /** * Adds the doValidate() method. + * * @param string &$script The script will be modified in this method. */ protected function addDoValidate(&$script) @@ -1900,13 +1943,13 @@ protected function addDoValidate(&$script) $table = $this->getTable(); $script .= " /** - * Validates all modified columns of given ".$this->getObjectClassname()." object. + * Validates all modified columns of given " . $this->getObjectClassname() . " object. * If parameter \$columns is either a single column name or an array of column names * than only those columns are validated. * * NOTICE: This does not apply to primary or foreign keys for now. * - * @param ".$this->getObjectClassname()." \$obj The object to validate. + * @param " . $this->getObjectClassname() . " \$obj The object to validate. * @param mixed \$cols Column name or array of column names. * * @return mixed TRUE if all columns are valid or the error message of the first invalid column. @@ -1916,8 +1959,8 @@ public static function doValidate(\$obj, \$cols = null) \$columns = array(); if (\$cols) { - \$dbMap = Propel::getDatabaseMap(".$this->getPeerClassname()."::DATABASE_NAME); - \$tableMap = \$dbMap->getTable(".$this->getPeerClassname()."::TABLE_NAME); + \$dbMap = Propel::getDatabaseMap(" . $this->getPeerClassname() . "::DATABASE_NAME); + \$tableMap = \$dbMap->getTable(" . $this->getPeerClassname() . "::TABLE_NAME); if (! is_array(\$cols)) { \$cols = array(\$cols); @@ -1935,8 +1978,8 @@ public static function doValidate(\$obj, \$cols = null) $col = $val->getColumn(); if (!$col->isAutoIncrement()) { $script .= " - if (\$obj->isNew() || \$obj->isColumnModified(".$this->getColumnConstant($col).")) - \$columns[".$this->getColumnConstant($col)."] = \$obj->get".$col->getPhpName()."(); + if (\$obj->isNew() || \$obj->isColumnModified(" . $this->getColumnConstant($col) . ")) + \$columns[" . $this->getColumnConstant($col) . "] = \$obj->get" . $col->getPhpName() . "(); "; } // if } // foreach @@ -1944,13 +1987,14 @@ public static function doValidate(\$obj, \$cols = null) $script .= " } - return {$this->basePeerClassname}::doValidate(".$this->getPeerClassname()."::DATABASE_NAME, ".$this->getPeerClassname()."::TABLE_NAME, \$columns); + return {$this->basePeerClassname}::doValidate(" . $this->getPeerClassname() . "::DATABASE_NAME, " . $this->getPeerClassname() . "::TABLE_NAME, \$columns); } "; } // end addDoValidate() /** * Adds the retrieveByPK method for tables with single-column primary key. + * * @param string &$script The script will be modified in this method. */ protected function addRetrieveByPK_SinglePK(&$script) @@ -1963,25 +2007,25 @@ protected function addRetrieveByPK_SinglePK(&$script) /** * Retrieve a single object by pkey. * - * @param ".$col->getPhpType()." \$pk the primary key. + * @param " . $col->getPhpType() . " \$pk the primary key. * @param PropelPDO \$con the connection to use - * @return " .$this->getObjectClassname(). " + * @return " . $this->getObjectClassname() . " */ - public static function ".$this->getRetrieveMethodName()."(\$pk, PropelPDO \$con = null) + public static function " . $this->getRetrieveMethodName() . "(\$pk, PropelPDO \$con = null) { - if (null !== (\$obj = ".$this->getPeerClassname()."::getInstanceFromPool(".$this->getInstancePoolKeySnippet('$pk')."))) { + if (null !== (\$obj = " . $this->getPeerClassname() . "::getInstanceFromPool(" . $this->getInstancePoolKeySnippet('$pk') . "))) { return \$obj; } if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_READ); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_READ); } - \$criteria = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME); - \$criteria->add(".$this->getColumnConstant($col).", \$pk); + \$criteria = new Criteria(" . $this->getPeerClassname() . "::DATABASE_NAME); + \$criteria->add(" . $this->getColumnConstant($col) . ", \$pk); - \$v = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con); + \$v = " . $this->getPeerClassname() . "::doSelect(\$criteria, \$con); return !empty(\$v) > 0 ? \$v[0] : null; } @@ -1990,6 +2034,7 @@ public static function ".$this->getRetrieveMethodName()."(\$pk, PropelPDO \$con /** * Adds the retrieveByPKs method for tables with single-column primary key. + * * @param string &$script The script will be modified in this method. */ protected function addRetrieveByPKs_SinglePK(&$script) @@ -2001,26 +2046,26 @@ protected function addRetrieveByPKs_SinglePK(&$script) * * @param array \$pks List of primary keys * @param PropelPDO \$con the connection to use - * @return " .$this->getObjectClassname(). "[] + * @return " . $this->getObjectClassname() . "[] * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ - public static function ".$this->getRetrieveMethodName()."s(\$pks, PropelPDO \$con = null) + public static function " . $this->getRetrieveMethodName() . "s(\$pks, PropelPDO \$con = null) { if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_READ); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_READ); } \$objs = null; if (empty(\$pks)) { \$objs = array(); } else { - \$criteria = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME);"; + \$criteria = new Criteria(" . $this->getPeerClassname() . "::DATABASE_NAME);"; $k1 = $table->getPrimaryKey(); $script .= " - \$criteria->add(".$this->getColumnConstant($k1[0]).", \$pks, Criteria::IN);"; + \$criteria->add(" . $this->getColumnConstant($k1[0]) . ", \$pks, Criteria::IN);"; $script .= " - \$objs = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con); + \$objs = " . $this->getPeerClassname() . "::doSelect(\$criteria, \$con); } return \$objs; @@ -2030,6 +2075,7 @@ public static function ".$this->getRetrieveMethodName()."s(\$pks, PropelPDO \$co /** * Adds the retrieveByPK method for tables with multi-column primary key. + * * @param string &$script The script will be modified in this method. */ protected function addRetrieveByPK_MultiPK(&$script) @@ -2042,13 +2088,13 @@ protected function addRetrieveByPK_MultiPK(&$script) $clo = strtolower($col->getName()); $cptype = $col->getPhpType(); $script .= " - * @param $cptype $".$clo; + * @param $cptype $" . $clo; } $script .= " * @param PropelPDO \$con - * @return ".$this->getObjectClassname()." + * @return " . $this->getObjectClassname() . " */ - public static function ".$this->getRetrieveMethodName()."("; + public static function " . $this->getRetrieveMethodName() . "("; $php = array(); foreach ($table->getPrimaryKey() as $col) { @@ -2059,23 +2105,23 @@ public static function ".$this->getRetrieveMethodName()."("; $script .= implode(', ', $php); $script .= ", PropelPDO \$con = null) { - \$_instancePoolKey = ".$this->getInstancePoolKeySnippet($php).";"; - $script .= " - if (null !== (\$obj = ".$this->getPeerClassname()."::getInstanceFromPool(\$_instancePoolKey))) { + \$_instancePoolKey = " . $this->getInstancePoolKeySnippet($php) . ";"; + $script .= " + if (null !== (\$obj = " . $this->getPeerClassname() . "::getInstanceFromPool(\$_instancePoolKey))) { return \$obj; } if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_READ); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_READ); } - \$criteria = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME);"; + \$criteria = new Criteria(" . $this->getPeerClassname() . "::DATABASE_NAME);"; foreach ($table->getPrimaryKey() as $col) { $clo = strtolower($col->getName()); $script .= " - \$criteria->add(".$this->getColumnConstant($col).", $".$clo.");"; + \$criteria->add(" . $this->getColumnConstant($col) . ", $" . $clo . ");"; } $script .= " - \$v = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con); + \$v = " . $this->getPeerClassname() . "::doSelect(\$criteria, \$con); return !empty(\$v) ? \$v[0] : null; }"; @@ -2083,6 +2129,7 @@ public static function ".$this->getRetrieveMethodName()."("; /** * Adds the getTableMap() method which is a convenience method for apps to get DB metadata. + * * @param string &$script The script will be modified in this method. */ protected function addGetTableMap(&$script) @@ -2097,14 +2144,16 @@ protected function addGetTableMap(&$script) */ public static function getTableMap() { - return Propel::getDatabaseMap(".$this->getPeerClassname()."::DATABASE_NAME)->getTable(".$this->getPeerClassname()."::TABLE_NAME); + return Propel::getDatabaseMap(" . $this->getPeerClassname() . "::DATABASE_NAME)->getTable(" . $this->getPeerClassname() . "::TABLE_NAME); } "; } /** * Adds the complex OM methods to the base addSelectMethods() function. + * * @param string &$script The script will be modified in this method. + * * @see PeerBuilder::addSelectMethods() */ protected function addSelectMethods(&$script) @@ -2139,13 +2188,13 @@ protected function addSelectMethods(&$script) $this->addDoSelectJoinAllExcept($script); } } - } /** * Get the column offsets of the primary key(s) for specified table. * * @param Table $tbl + * * @return array int[] The column offsets of the primary key(s). */ protected function getPrimaryKeyColOffsets(Table $tbl) @@ -2162,40 +2211,36 @@ protected function getPrimaryKeyColOffsets(Table $tbl) return $offsets; } - public function addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder) - { - $script = ''; + public function addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder) + { + $script = ''; $lfMap = $fk->getLocalForeignMapping(); $lftCols = $fk->getLocalColumns(); if (count($lftCols) == 1) { - // simple foreign key - $lftCol = $lftCols[0]; - $script .= sprintf(" + // simple foreign key + $lftCol = $lftCols[0]; + $script .= sprintf(" \$criteria->addJoin(%s, %s, \$join_behavior); -", - $this->getColumnConstant($table->getColumn($lftCol) ), - $joinedTablePeerBuilder->getColumnConstant($joinTable->getColumn( $lfMap[$lftCol] ) )); +", $this->getColumnConstant($table->getColumn($lftCol)), $joinedTablePeerBuilder->getColumnConstant($joinTable->getColumn($lfMap[$lftCol]))); } else { - // composite foreign key - $script .= " + // composite foreign key + $script .= " \$criteria->addMultipleJoin(array( "; - foreach ($lftCols as $columnName) { - $script .= sprintf(" array(%s, %s), -", - $this->getColumnConstant($table->getColumn($columnName) ), - $joinedTablePeerBuilder->getColumnConstant($joinTable->getColumn( $lfMap[$columnName] ) ) - ); + foreach ($lftCols as $columnName) { + $script .= sprintf(" array(%s, %s), +", $this->getColumnConstant($table->getColumn($columnName)), $joinedTablePeerBuilder->getColumnConstant($joinTable->getColumn($lfMap[$columnName]))); } $script .= " ), \$join_behavior); "; } return $script; - } + } /** * Adds the doSelectJoin*() methods. + * * @param string &$script The script will be modified in this method. */ protected function addDoSelectJoin(&$script) @@ -2215,7 +2260,7 @@ protected function addDoSelectJoin(&$script) // This condition is necessary because Propel lacks a system for // aliasing the table if it is the same table. - if ( $fk->getForeignTableName() != $table->getName() ) { + if ($fk->getForeignTableName() != $table->getName()) { $thisTableObjectBuilder = $this->getNewObjectBuilder($table); $joinedTableObjectBuilder = $this->getNewObjectBuilder($joinTable); @@ -2234,32 +2279,32 @@ protected function addDoSelectJoin(&$script) * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ - public static function doSelectJoin".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$criteria, \$con = null, \$join_behavior = $join_behavior) + public static function doSelectJoin" . $thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false) . "(Criteria \$criteria, \$con = null, \$join_behavior = $join_behavior) { \$criteria = clone \$criteria; // Set the correct dbName if it has not been overridden if (\$criteria->getDbName() == Propel::getDefaultDB()) { - \$criteria->setDbName(".$this->getPeerClassname()."::DATABASE_NAME); + \$criteria->setDbName(" . $this->getPeerClassname() . "::DATABASE_NAME); } - ".$this->getPeerClassname()."::addSelectColumns(\$criteria); - \$startcol = ".$this->getPeerClassname()."::NUM_HYDRATE_COLUMNS; - ".$joinedTablePeerBuilder->getPeerClassname()."::addSelectColumns(\$criteria); + " . $this->getPeerClassname() . "::addSelectColumns(\$criteria); + \$startcol = " . $this->getPeerClassname() . "::NUM_HYDRATE_COLUMNS; + " . $joinedTablePeerBuilder->getPeerClassname() . "::addSelectColumns(\$criteria); "; - $script .= $this->addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder); + $script .= $this->addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder); - // apply behaviors - $this->applyBehaviorModifier('preSelect', $script); + // apply behaviors + $this->applyBehaviorModifier('preSelect', $script); - $script .= " - \$stmt = ".$this->basePeerClassname."::doSelect(\$criteria, \$con); + $script .= " + \$stmt = " . $this->basePeerClassname . "::doSelect(\$criteria, \$con); \$results = array(); while (\$row = \$stmt->fetch(PDO::FETCH_NUM)) { - \$key1 = ".$this->getPeerClassname()."::getPrimaryKeyHashFromRow(\$row, 0); - if (null !== (\$obj1 = ".$this->getPeerClassname()."::getInstanceFromPool(\$key1))) { + \$key1 = " . $this->getPeerClassname() . "::getPrimaryKeyHashFromRow(\$row, 0); + if (null !== (\$obj1 = " . $this->getPeerClassname() . "::getInstanceFromPool(\$key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // \$obj1->hydrate(\$row, 0, true); // rehydrate @@ -2267,50 +2312,50 @@ public static function doSelectJoin".$thisTableObjectBuilder->getFKPhpNameAffix( "; if ($table->getChildrenColumn()) { $script .= " - \$omClass = ".$this->getPeerClassname()."::getOMClass(\$row, 0); + \$omClass = " . $this->getPeerClassname() . "::getOMClass(\$row, 0); \$cls = substr('.'.\$omClass, strrpos('.'.\$omClass, '.') + 1); "; } else { $script .= " - \$cls = ".$this->getPeerClassname()."::getOMClass(); + \$cls = " . $this->getPeerClassname() . "::getOMClass(); "; } $script .= " " . $this->buildObjectInstanceCreationCode('$obj1', '$cls') . " \$obj1->hydrate(\$row); - ".$this->getPeerClassname()."::addInstanceToPool(\$obj1, \$key1); + " . $this->getPeerClassname() . "::addInstanceToPool(\$obj1, \$key1); } // if \$obj1 already loaded - \$key2 = ".$joinedTablePeerBuilder->getPeerClassname()."::getPrimaryKeyHashFromRow(\$row, \$startcol); + \$key2 = " . $joinedTablePeerBuilder->getPeerClassname() . "::getPrimaryKeyHashFromRow(\$row, \$startcol); if (\$key2 !== null) { - \$obj2 = ".$joinedTablePeerBuilder->getPeerClassname()."::getInstanceFromPool(\$key2); + \$obj2 = " . $joinedTablePeerBuilder->getPeerClassname() . "::getInstanceFromPool(\$key2); if (!\$obj2) { "; if ($joinTable->getChildrenColumn()) { $script .= " - \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(\$row, \$startcol); + \$omClass = " . $joinedTablePeerBuilder->getPeerClassname() . "::getOMClass(\$row, \$startcol); \$cls = substr('.'.\$omClass, strrpos('.'.\$omClass, '.') + 1); "; } else { $script .= " - \$cls = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(); + \$cls = " . $joinedTablePeerBuilder->getPeerClassname() . "::getOMClass(); "; } $script .= " " . $this->buildObjectInstanceCreationCode('$obj2', '$cls') . " \$obj2->hydrate(\$row, \$startcol); - ".$joinedTablePeerBuilder->getPeerClassname()."::addInstanceToPool(\$obj2, \$key2); + " . $joinedTablePeerBuilder->getPeerClassname() . "::addInstanceToPool(\$obj2, \$key2); } // if obj2 already loaded - // Add the \$obj1 (".$this->getObjectClassname().") to \$obj2 (".$joinedTablePeerBuilder->getObjectClassname().")"; + // Add the \$obj1 (" . $this->getObjectClassname() . ") to \$obj2 (" . $joinedTablePeerBuilder->getObjectClassname() . ")"; if ($fk->isLocalPrimaryKey()) { $script .= " // one to one relationship \$obj1->set" . $joinedTablePeerBuilder->getObjectClassname() . "(\$obj2);"; } else { $script .= " - \$obj2->add" . $joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = false)."(\$obj1);"; + \$obj2->add" . $joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = false) . "(\$obj1);"; } $script .= " @@ -2332,6 +2377,7 @@ public static function doSelectJoin".$thisTableObjectBuilder->getFKPhpNameAffix( /** * Adds the doCountJoin*() methods. + * * @param string &$script The script will be modified in this method. */ protected function addDoCountJoin(&$script) @@ -2349,7 +2395,7 @@ protected function addDoCountJoin(&$script) if (!$joinTable->isForReferenceOnly()) { - if ( $fk->getForeignTableName() != $table->getName() ) { + if ($fk->getForeignTableName() != $table->getName()) { $thisTableObjectBuilder = $this->getNewObjectBuilder($table); $joinedTableObjectBuilder = $this->getNewObjectBuilder($joinTable); @@ -2360,7 +2406,7 @@ protected function addDoCountJoin(&$script) $script .= " /** - * Returns the number of rows matching criteria, joining the related ".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)." table + * Returns the number of rows matching criteria, joining the related " . $thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false) . " table * * @param Criteria \$criteria * @param boolean \$distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. @@ -2368,7 +2414,7 @@ protected function addDoCountJoin(&$script) * @param String \$join_behavior the type of joins to use, defaults to $join_behavior * @return int Number of matching rows. */ - public static function doCountJoin".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$criteria, \$distinct = false, PropelPDO \$con = null, \$join_behavior = $join_behavior) + public static function doCountJoin" . $thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false) . "(Criteria \$criteria, \$distinct = false, PropelPDO \$con = null, \$join_behavior = $join_behavior) { // we're going to modify criteria, so copy it first \$criteria = clone \$criteria; @@ -2376,32 +2422,32 @@ public static function doCountJoin".$thisTableObjectBuilder->getFKPhpNameAffix($ // We need to set the primary table name, since in the case that there are no WHERE columns // it will be impossible for the BasePeer::createSelectSql() method to determine which // tables go into the FROM clause. - \$criteria->setPrimaryTableName(".$this->getPeerClassname()."::TABLE_NAME); + \$criteria->setPrimaryTableName(" . $this->getPeerClassname() . "::TABLE_NAME); if (\$distinct && !in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) { \$criteria->setDistinct(); } if (!\$criteria->hasSelectClause()) { - ".$this->getPeerClassname()."::addSelectColumns(\$criteria); + " . $this->getPeerClassname() . "::addSelectColumns(\$criteria); } \$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count // Set the correct dbName - \$criteria->setDbName(".$this->getPeerClassname()."::DATABASE_NAME); + \$criteria->setDbName(" . $this->getPeerClassname() . "::DATABASE_NAME); if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_READ); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_READ); } "; - $script .= $this->addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder); + $script .= $this->addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder); - // apply behaviors - $this->applyBehaviorModifier('preSelect', $script); + // apply behaviors + $this->applyBehaviorModifier('preSelect', $script); - $script .= " - \$stmt = ".$this->basePeerClassname."::doCount(\$criteria, \$con); + $script .= " + \$stmt = " . $this->basePeerClassname . "::doCount(\$criteria, \$con); if (\$row = \$stmt->fetch(PDO::FETCH_NUM)) { \$count = (int) \$row[0]; @@ -2422,6 +2468,7 @@ public static function doCountJoin".$thisTableObjectBuilder->getFKPhpNameAffix($ /** * Adds the doSelectJoinAll() method. + * * @param string &$script The script will be modified in this method. */ protected function addDoSelectJoinAll(&$script) @@ -2448,18 +2495,18 @@ public static function doSelectJoinAll(Criteria \$criteria, \$con = null, \$join // Set the correct dbName if it has not been overridden if (\$criteria->getDbName() == Propel::getDefaultDB()) { - \$criteria->setDbName(".$this->getPeerClassname()."::DATABASE_NAME); + \$criteria->setDbName(" . $this->getPeerClassname() . "::DATABASE_NAME); } - ".$this->getPeerClassname()."::addSelectColumns(\$criteria); - \$startcol2 = ".$this->getPeerClassname()."::NUM_HYDRATE_COLUMNS; + " . $this->getPeerClassname() . "::addSelectColumns(\$criteria); + \$startcol2 = " . $this->getPeerClassname() . "::NUM_HYDRATE_COLUMNS; "; $index = 2; foreach ($table->getForeignKeys() as $fk) { // Want to cover this case, but the code is not there yet. // Propel lacks a system for aliasing tables of the same name. - if ( $fk->getForeignTableName() != $table->getName() ) { + if ($fk->getForeignTableName() != $table->getName()) { $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName()); $new_index = $index + 1; @@ -2467,33 +2514,32 @@ public static function doSelectJoinAll(Criteria \$criteria, \$con = null, \$join $joinClassName = $joinedTablePeerBuilder->getObjectClassname(); $script .= " - ".$joinedTablePeerBuilder->getPeerClassname()."::addSelectColumns(\$criteria); - \$startcol$new_index = \$startcol$index + ".$joinedTablePeerBuilder->getPeerClassname()."::NUM_HYDRATE_COLUMNS; + " . $joinedTablePeerBuilder->getPeerClassname() . "::addSelectColumns(\$criteria); + \$startcol$new_index = \$startcol$index + " . $joinedTablePeerBuilder->getPeerClassname() . "::NUM_HYDRATE_COLUMNS; "; $index = $new_index; - } // if fk->getForeignTableName != table->getName } // foreach [sub] foreign keys foreach ($table->getForeignKeys() as $fk) { // want to cover this case, but the code is not there yet. - if ( $fk->getForeignTableName() != $table->getName() ) { + if ($fk->getForeignTableName() != $table->getName()) { $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName()); $joinedTablePeerBuilder = $this->getNewPeerBuilder($joinTable); - $script .= $this->addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder); + $script .= $this->addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder); } } // apply behaviors - $this->applyBehaviorModifier('preSelect', $script); + $this->applyBehaviorModifier('preSelect', $script); - $script .= " - \$stmt = ".$this->basePeerClassname."::doSelect(\$criteria, \$con); + $script .= " + \$stmt = " . $this->basePeerClassname . "::doSelect(\$criteria, \$con); \$results = array(); while (\$row = \$stmt->fetch(PDO::FETCH_NUM)) { - \$key1 = ".$this->getPeerClassname()."::getPrimaryKeyHashFromRow(\$row, 0); - if (null !== (\$obj1 = ".$this->getPeerClassname()."::getInstanceFromPool(\$key1))) { + \$key1 = " . $this->getPeerClassname() . "::getPrimaryKeyHashFromRow(\$row, 0); + if (null !== (\$obj1 = " . $this->getPeerClassname() . "::getInstanceFromPool(\$key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // \$obj1->hydrate(\$row, 0, true); // rehydrate @@ -2501,27 +2547,27 @@ public static function doSelectJoinAll(Criteria \$criteria, \$con = null, \$join if ($table->getChildrenColumn()) { $script .= " - \$omClass = ".$this->getPeerClassname()."::getOMClass(\$row, 0); + \$omClass = " . $this->getPeerClassname() . "::getOMClass(\$row, 0); \$cls = substr('.'.\$omClass, strrpos('.'.\$omClass, '.') + 1); "; } else { $script .= " - \$cls = ".$this->getPeerClassname()."::getOMClass(); + \$cls = " . $this->getPeerClassname() . "::getOMClass(); "; } $script .= " " . $this->buildObjectInstanceCreationCode('$obj1', '$cls') . " \$obj1->hydrate(\$row); - ".$this->getPeerClassname()."::addInstanceToPool(\$obj1, \$key1); + " . $this->getPeerClassname() . "::addInstanceToPool(\$obj1, \$key1); } // if obj1 already loaded "; $index = 1; - foreach ($table->getForeignKeys() as $fk ) { + foreach ($table->getForeignKeys() as $fk) { // want to cover this case, but the code is not there yet. // Why not? -because we'd have to alias the tables in the JOIN - if ( $fk->getForeignTableName() != $table->getName() ) { + if ($fk->getForeignTableName() != $table->getName()) { $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName()); $thisTableObjectBuilder = $this->getNewObjectBuilder($table); @@ -2541,40 +2587,39 @@ public static function doSelectJoinAll(Criteria \$criteria, \$con = null, \$join $script .= " // Add objects for joined $joinClassName rows - \$key$index = ".$joinedTablePeerBuilder->getPeerClassname()."::getPrimaryKeyHashFromRow(\$row, \$startcol$index); + \$key$index = " . $joinedTablePeerBuilder->getPeerClassname() . "::getPrimaryKeyHashFromRow(\$row, \$startcol$index); if (\$key$index !== null) { - \$obj$index = ".$joinedTablePeerBuilder->getPeerClassname()."::getInstanceFromPool(\$key$index); + \$obj$index = " . $joinedTablePeerBuilder->getPeerClassname() . "::getInstanceFromPool(\$key$index); if (!\$obj$index) { "; if ($joinTable->getChildrenColumn()) { $script .= " - \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(\$row, \$startcol$index); + \$omClass = " . $joinedTablePeerBuilder->getPeerClassname() . "::getOMClass(\$row, \$startcol$index); \$cls = substr('.'.\$omClass, strrpos('.'.\$omClass, '.') + 1); "; } else { $script .= " - \$cls = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(); + \$cls = " . $joinedTablePeerBuilder->getPeerClassname() . "::getOMClass(); "; } /* $joinTable->getChildrenColumn() */ $script .= " " . $this->buildObjectInstanceCreationCode('$obj' . $index, '$cls') . " - \$obj".$index."->hydrate(\$row, \$startcol$index); - ".$joinedTablePeerBuilder->getPeerClassname()."::addInstanceToPool(\$obj$index, \$key$index); + \$obj" . $index . "->hydrate(\$row, \$startcol$index); + " . $joinedTablePeerBuilder->getPeerClassname() . "::addInstanceToPool(\$obj$index, \$key$index); } // if obj$index loaded - // Add the \$obj1 (".$this->getObjectClassname().") to the collection in \$obj".$index." (".$joinedTablePeerBuilder->getObjectClassname().")"; + // Add the \$obj1 (" . $this->getObjectClassname() . ") to the collection in \$obj" . $index . " (" . $joinedTablePeerBuilder->getObjectClassname() . ")"; if ($fk->isLocalPrimaryKey()) { $script .= " - \$obj1->set".$joinedTablePeerBuilder->getObjectClassname()."(\$obj".$index.");"; + \$obj1->set" . $joinedTablePeerBuilder->getObjectClassname() . "(\$obj" . $index . ");"; } else { $script .= " - \$obj".$index."->add".$joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = false)."(\$obj1);"; + \$obj" . $index . "->add" . $joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = false) . "(\$obj1);"; } $script .= " } // if joined row not null "; - } // $fk->getForeignTableName() != $table->getName() } //foreach foreign key @@ -2586,12 +2631,12 @@ public static function doSelectJoinAll(Criteria \$criteria, \$con = null, \$join return \$results; } "; - } // end addDoSelectJoinAll() /** * Adds the doCountJoinAll() method. + * * @param string &$script The script will be modified in this method. */ protected function addDoCountJoinAll(&$script) @@ -2619,40 +2664,40 @@ public static function doCountJoinAll(Criteria \$criteria, \$distinct = false, P // We need to set the primary table name, since in the case that there are no WHERE columns // it will be impossible for the BasePeer::createSelectSql() method to determine which // tables go into the FROM clause. - \$criteria->setPrimaryTableName(".$this->getPeerClassname()."::TABLE_NAME); + \$criteria->setPrimaryTableName(" . $this->getPeerClassname() . "::TABLE_NAME); if (\$distinct && !in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) { \$criteria->setDistinct(); } if (!\$criteria->hasSelectClause()) { - ".$this->getPeerClassname()."::addSelectColumns(\$criteria); + " . $this->getPeerClassname() . "::addSelectColumns(\$criteria); } \$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count // Set the correct dbName - \$criteria->setDbName(".$this->getPeerClassname()."::DATABASE_NAME); + \$criteria->setDbName(" . $this->getPeerClassname() . "::DATABASE_NAME); if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_READ); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_READ); } "; foreach ($table->getForeignKeys() as $fk) { // want to cover this case, but the code is not there yet. - if ( $fk->getForeignTableName() != $table->getName() ) { + if ($fk->getForeignTableName() != $table->getName()) { $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName()); $joinedTablePeerBuilder = $this->getNewPeerBuilder($joinTable); - $script .= $this->addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder); + $script .= $this->addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder); } // if fk->getForeignTableName != table->getName } // foreach [sub] foreign keys // apply behaviors - $this->applyBehaviorModifier('preSelect', $script); + $this->applyBehaviorModifier('preSelect', $script); - $script .= " - \$stmt = ".$this->basePeerClassname."::doCount(\$criteria, \$con); + $script .= " + \$stmt = " . $this->basePeerClassname . "::doCount(\$criteria, \$con); if (\$row = \$stmt->fetch(PDO::FETCH_NUM)) { \$count = (int) \$row[0]; @@ -2667,6 +2712,7 @@ public static function doCountJoinAll(Criteria \$criteria, \$distinct = false, P /** * Adds the doSelectJoinAllExcept*() methods. + * * @param string &$script The script will be modified in this method. */ protected function addDoSelectJoinAllExcept(&$script) @@ -2681,7 +2727,7 @@ protected function addDoSelectJoinAllExcept(&$script) // 2) create a bunch of doSelectJoinAllExcept*() methods // -- these were existing in original Torque, so we should keep them for compatibility - $fkeys = $table->getForeignKeys(); // this sep assignment is necessary otherwise sub-loops over + $fkeys = $table->getForeignKeys(); // this sep assignment is necessary otherwise sub-loops over // getForeignKeys() will cause this to only execute one time. foreach ($fkeys as $fk) { @@ -2699,16 +2745,16 @@ protected function addDoSelectJoinAllExcept(&$script) $script .= " /** - * Selects a collection of ".$this->getObjectClassname()." objects pre-filled with all related objects except ".$thisTableObjectBuilder->getFKPhpNameAffix($fk).". + * Selects a collection of " . $this->getObjectClassname() . " objects pre-filled with all related objects except " . $thisTableObjectBuilder->getFKPhpNameAffix($fk) . ". * * @param Criteria \$criteria * @param PropelPDO \$con * @param String \$join_behavior the type of joins to use, defaults to $join_behavior - * @return array Array of ".$this->getObjectClassname()." objects. + * @return array Array of " . $this->getObjectClassname() . " objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ - public static function doSelectJoinAllExcept".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$criteria, \$con = null, \$join_behavior = $join_behavior) + public static function doSelectJoinAllExcept" . $thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false) . "(Criteria \$criteria, \$con = null, \$join_behavior = $join_behavior) { \$criteria = clone \$criteria; @@ -2716,17 +2762,17 @@ public static function doSelectJoinAllExcept".$thisTableObjectBuilder->getFKPhpN // \$criteria->getDbName() will return the same object if not set to another value // so == check is okay and faster if (\$criteria->getDbName() == Propel::getDefaultDB()) { - \$criteria->setDbName(".$this->getPeerClassname()."::DATABASE_NAME); + \$criteria->setDbName(" . $this->getPeerClassname() . "::DATABASE_NAME); } - ".$this->getPeerClassname()."::addSelectColumns(\$criteria); - \$startcol2 = ".$this->getPeerClassname()."::NUM_HYDRATE_COLUMNS; + " . $this->getPeerClassname() . "::addSelectColumns(\$criteria); + \$startcol2 = " . $this->getPeerClassname() . "::NUM_HYDRATE_COLUMNS; "; $index = 2; foreach ($table->getForeignKeys() as $subfk) { // want to cover this case, but the code is not there yet. // Why not? - because we would have to alias the tables in the join - if ( !($subfk->getForeignTableName() == $table->getName())) { + if (!($subfk->getForeignTableName() == $table->getName())) { $joinTable = $table->getDatabase()->getTable($subfk->getForeignTableName()); $joinTablePeerBuilder = $this->getNewPeerBuilder($joinTable); $joinClassName = $joinTablePeerBuilder->getObjectClassname(); @@ -2734,8 +2780,8 @@ public static function doSelectJoinAllExcept".$thisTableObjectBuilder->getFKPhpN if ($joinClassName != $excludedClassName) { $new_index = $index + 1; $script .= " - ".$joinTablePeerBuilder->getPeerClassname()."::addSelectColumns(\$criteria); - \$startcol$new_index = \$startcol$index + ".$joinTablePeerBuilder->getPeerClassname()."::NUM_HYDRATE_COLUMNS; + " . $joinTablePeerBuilder->getPeerClassname() . "::addSelectColumns(\$criteria); + \$startcol$new_index = \$startcol$index + " . $joinTablePeerBuilder->getPeerClassname() . "::NUM_HYDRATE_COLUMNS; "; $index = $new_index; } // if joinClassName not excludeClassName @@ -2744,110 +2790,110 @@ public static function doSelectJoinAllExcept".$thisTableObjectBuilder->getFKPhpN foreach ($table->getForeignKeys() as $subfk) { // want to cover this case, but the code is not there yet. - if ( $subfk->getForeignTableName() != $table->getName() ) { + if ($subfk->getForeignTableName() != $table->getName()) { $joinTable = $table->getDatabase()->getTable($subfk->getForeignTableName()); $joinedTablePeerBuilder = $this->getNewPeerBuilder($joinTable); $joinClassName = $joinedTablePeerBuilder->getObjectClassname(); if ($joinClassName != $excludedClassName) { - $script .= $this->addCriteriaJoin($subfk, $table, $joinTable, $joinedTablePeerBuilder); + $script .= $this->addCriteriaJoin($subfk, $table, $joinTable, $joinedTablePeerBuilder); } } } // foreach fkeys // apply behaviors - $this->applyBehaviorModifier('preSelect', $script); + $this->applyBehaviorModifier('preSelect', $script); - $script .= " + $script .= " - \$stmt = ".$this->basePeerClassname ."::doSelect(\$criteria, \$con); + \$stmt = " . $this->basePeerClassname . "::doSelect(\$criteria, \$con); \$results = array(); while (\$row = \$stmt->fetch(PDO::FETCH_NUM)) { - \$key1 = ".$this->getPeerClassname()."::getPrimaryKeyHashFromRow(\$row, 0); - if (null !== (\$obj1 = ".$this->getPeerClassname()."::getInstanceFromPool(\$key1))) { + \$key1 = " . $this->getPeerClassname() . "::getPrimaryKeyHashFromRow(\$row, 0); + if (null !== (\$obj1 = " . $this->getPeerClassname() . "::getInstanceFromPool(\$key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // \$obj1->hydrate(\$row, 0, true); // rehydrate } else {"; if ($table->getChildrenColumn()) { $script .= " - \$omClass = ".$this->getPeerClassname()."::getOMClass(\$row, 0); + \$omClass = " . $this->getPeerClassname() . "::getOMClass(\$row, 0); \$cls = substr('.'.\$omClass, strrpos('.'.\$omClass, '.') + 1); "; } else { $script .= " - \$cls = ".$this->getPeerClassname()."::getOMClass(); + \$cls = " . $this->getPeerClassname() . "::getOMClass(); "; } $script .= " " . $this->buildObjectInstanceCreationCode('$obj1', '$cls') . " \$obj1->hydrate(\$row); - ".$this->getPeerClassname()."::addInstanceToPool(\$obj1, \$key1); + " . $this->getPeerClassname() . "::addInstanceToPool(\$obj1, \$key1); } // if obj1 already loaded "; $index = 1; - foreach ($table->getForeignKeys() as $subfk ) { - // want to cover this case, but the code is not there yet. - if ( $subfk->getForeignTableName() != $table->getName() ) { + foreach ($table->getForeignKeys() as $subfk) { + // want to cover this case, but the code is not there yet. + if ($subfk->getForeignTableName() != $table->getName()) { - $joinTable = $table->getDatabase()->getTable($subfk->getForeignTableName()); + $joinTable = $table->getDatabase()->getTable($subfk->getForeignTableName()); - $joinedTableObjectBuilder = $this->getNewObjectBuilder($joinTable); - $joinedTablePeerBuilder = $this->getNewPeerBuilder($joinTable); + $joinedTableObjectBuilder = $this->getNewObjectBuilder($joinTable); + $joinedTablePeerBuilder = $this->getNewPeerBuilder($joinTable); - $joinClassName = $joinedTableObjectBuilder->getObjectClassname(); + $joinClassName = $joinedTableObjectBuilder->getObjectClassname(); - $interfaceName = $joinClassName; - if ($joinTable->getInterface()) { - $interfaceName = $this->prefixClassname($joinTable->getInterface()); - } + $interfaceName = $joinClassName; + if ($joinTable->getInterface()) { + $interfaceName = $this->prefixClassname($joinTable->getInterface()); + } - if ($joinClassName != $excludedClassName) { + if ($joinClassName != $excludedClassName) { - $index++; + $index++; - $script .= " + $script .= " // Add objects for joined $joinClassName rows - \$key$index = ".$joinedTablePeerBuilder->getPeerClassname()."::getPrimaryKeyHashFromRow(\$row, \$startcol$index); + \$key$index = " . $joinedTablePeerBuilder->getPeerClassname() . "::getPrimaryKeyHashFromRow(\$row, \$startcol$index); if (\$key$index !== null) { - \$obj$index = ".$joinedTablePeerBuilder->getPeerClassname()."::getInstanceFromPool(\$key$index); + \$obj$index = " . $joinedTablePeerBuilder->getPeerClassname() . "::getInstanceFromPool(\$key$index); if (!\$obj$index) { "; - if ($joinTable->getChildrenColumn()) { - $script .= " - \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(\$row, \$startcol$index); + if ($joinTable->getChildrenColumn()) { + $script .= " + \$omClass = " . $joinedTablePeerBuilder->getPeerClassname() . "::getOMClass(\$row, \$startcol$index); \$cls = substr('.'.\$omClass, strrpos('.'.\$omClass, '.') + 1); "; - } else { - $script .= " - \$cls = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(); + } else { + $script .= " + \$cls = " . $joinedTablePeerBuilder->getPeerClassname() . "::getOMClass(); "; - } /* $joinTable->getChildrenColumn() */ - $script .= " + } /* $joinTable->getChildrenColumn() */ + $script .= " " . $this->buildObjectInstanceCreationCode('$obj' . $index, '$cls') . " - \$obj".$index."->hydrate(\$row, \$startcol$index); - ".$joinedTablePeerBuilder->getPeerClassname()."::addInstanceToPool(\$obj$index, \$key$index); + \$obj" . $index . "->hydrate(\$row, \$startcol$index); + " . $joinedTablePeerBuilder->getPeerClassname() . "::addInstanceToPool(\$obj$index, \$key$index); } // if \$obj$index already loaded - // Add the \$obj1 (".$this->getObjectClassname().") to the collection in \$obj".$index." (".$joinedTablePeerBuilder->getObjectClassname().")"; - if ($subfk->isLocalPrimaryKey()) { - $script .= " - \$obj1->set".$joinedTablePeerBuilder->getObjectClassname()."(\$obj".$index.");"; - } else { - $script .= " - \$obj".$index."->add".$joinedTableObjectBuilder->getRefFKPhpNameAffix($subfk, $plural = false)."(\$obj1);"; - } - $script .= " + // Add the \$obj1 (" . $this->getObjectClassname() . ") to the collection in \$obj" . $index . " (" . $joinedTablePeerBuilder->getObjectClassname() . ")"; + if ($subfk->isLocalPrimaryKey()) { + $script .= " + \$obj1->set" . $joinedTablePeerBuilder->getObjectClassname() . "(\$obj" . $index . ");"; + } else { + $script .= " + \$obj" . $index . "->add" . $joinedTableObjectBuilder->getRefFKPhpNameAffix($subfk, $plural = false) . "(\$obj1);"; + } + $script .= " } // if joined row is not null "; } // if ($joinClassName != $excludedClassName) { - } // $subfk->getForeignTableName() != $table->getName() + } // $subfk->getForeignTableName() != $table->getName() } // foreach $script .= " \$results[] = \$obj1; @@ -2863,6 +2909,7 @@ public static function doSelectJoinAllExcept".$thisTableObjectBuilder->getFKPhpN /** * Adds the doCountJoinAllExcept*() methods. + * * @param string &$script The script will be modified in this method. */ protected function addDoCountJoinAllExcept(&$script) @@ -2870,7 +2917,7 @@ protected function addDoCountJoinAllExcept(&$script) $table = $this->getTable(); $join_behavior = $this->getJoinBehavior(); - $fkeys = $table->getForeignKeys(); // this sep assignment is necessary otherwise sub-loops over + $fkeys = $table->getForeignKeys(); // this sep assignment is necessary otherwise sub-loops over // getForeignKeys() will cause this to only execute one time. foreach ($fkeys as $fk) { @@ -2887,7 +2934,7 @@ protected function addDoCountJoinAllExcept(&$script) $script .= " /** - * Returns the number of rows matching criteria, joining the related ".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)." table + * Returns the number of rows matching criteria, joining the related " . $thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false) . " table * * @param Criteria \$criteria * @param boolean \$distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. @@ -2895,7 +2942,7 @@ protected function addDoCountJoinAllExcept(&$script) * @param String \$join_behavior the type of joins to use, defaults to $join_behavior * @return int Number of matching rows. */ - public static function doCountJoinAllExcept".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$criteria, \$distinct = false, PropelPDO \$con = null, \$join_behavior = $join_behavior) + public static function doCountJoinAllExcept" . $thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false) . "(Criteria \$criteria, \$distinct = false, PropelPDO \$con = null, \$join_behavior = $join_behavior) { // we're going to modify criteria, so copy it first \$criteria = clone \$criteria; @@ -2903,44 +2950,44 @@ public static function doCountJoinAllExcept".$thisTableObjectBuilder->getFKPhpNa // We need to set the primary table name, since in the case that there are no WHERE columns // it will be impossible for the BasePeer::createSelectSql() method to determine which // tables go into the FROM clause. - \$criteria->setPrimaryTableName(".$this->getPeerClassname()."::TABLE_NAME); + \$criteria->setPrimaryTableName(" . $this->getPeerClassname() . "::TABLE_NAME); if (\$distinct && !in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) { \$criteria->setDistinct(); } if (!\$criteria->hasSelectClause()) { - ".$this->getPeerClassname()."::addSelectColumns(\$criteria); + " . $this->getPeerClassname() . "::addSelectColumns(\$criteria); } \$criteria->clearOrderByColumns(); // ORDER BY should not affect count // Set the correct dbName - \$criteria->setDbName(".$this->getPeerClassname()."::DATABASE_NAME); + \$criteria->setDbName(" . $this->getPeerClassname() . "::DATABASE_NAME); if (\$con === null) { - \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME, Propel::CONNECTION_READ); + \$con = Propel::getConnection(" . $this->getPeerClassname() . "::DATABASE_NAME, Propel::CONNECTION_READ); } "; foreach ($table->getForeignKeys() as $subfk) { // want to cover this case, but the code is not there yet. - if ( $subfk->getForeignTableName() != $table->getName() ) { + if ($subfk->getForeignTableName() != $table->getName()) { $joinTable = $table->getDatabase()->getTable($subfk->getForeignTableName()); $joinedTablePeerBuilder = $this->getNewPeerBuilder($joinTable); $joinClassName = $joinedTablePeerBuilder->getObjectClassname(); if ($joinClassName != $excludedClassName) { - $script .= $this->addCriteriaJoin($subfk, $table, $joinTable, $joinedTablePeerBuilder); + $script .= $this->addCriteriaJoin($subfk, $table, $joinTable, $joinedTablePeerBuilder); } } } // foreach fkeys // apply behaviors - $this->applyBehaviorModifier('preSelect', $script); + $this->applyBehaviorModifier('preSelect', $script); - $script .= " - \$stmt = ".$this->basePeerClassname."::doCount(\$criteria, \$con); + $script .= " + \$stmt = " . $this->basePeerClassname . "::doCount(\$criteria, \$con); if (\$row = \$stmt->fetch(PDO::FETCH_NUM)) { \$count = (int) \$row[0]; @@ -2965,5 +3012,4 @@ protected function getJoinBehavior() { return $this->getGeneratorConfig()->getBuildProperty('useLeftJoinsInDoJoinMethods') ? 'Criteria::LEFT_JOIN' : 'Criteria::INNER_JOIN'; } - } // PHP5PeerBuilder diff --git a/generator/lib/builder/om/PHP5TableMapBuilder.php b/generator/lib/builder/om/PHP5TableMapBuilder.php index 25249b0eb..4d2e3bb82 100644 --- a/generator/lib/builder/om/PHP5TableMapBuilder.php +++ b/generator/lib/builder/om/PHP5TableMapBuilder.php @@ -21,6 +21,7 @@ class PHP5TableMapBuilder extends OMBuilder /** * Gets the package for the map builder classes. + * * @return string */ public function getPackage() @@ -41,6 +42,7 @@ public function getNamespace() /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -50,6 +52,7 @@ public function getUnprefixedClassname() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) @@ -58,6 +61,7 @@ protected function addIncludes(&$script) /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -66,7 +70,7 @@ protected function addClassOpen(&$script) $script .= " /** - * This class defines the structure of the '".$table->getName()."' table. + * This class defines the structure of the '" . $table->getName() . "' table. * *"; if ($this->getBuildProperty('addTimeStamp')) { @@ -84,9 +88,9 @@ protected function addClassOpen(&$script) * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive * (i.e. if it's a text column type). * - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */ -class ".$this->getClassname()." extends TableMap +class " . $this->getClassname() . " extends TableMap { "; } @@ -94,6 +98,7 @@ class ".$this->getClassname()." extends TableMap /** * Specifies the methods that are added as part of the map builder class. * This can be overridden by subclasses that wish to add more methods. + * * @see ObjectBuilder::addClassBody() */ protected function addClassBody(&$script) @@ -108,6 +113,7 @@ protected function addClassBody(&$script) /** * Adds any constants needed for this TableMap class. + * * @param string &$script The script will be modified in this method. */ protected function addConstants(&$script) @@ -116,12 +122,13 @@ protected function addConstants(&$script) /** * The (dot-path) name of this class */ - const CLASS_NAME = '".$this->getClasspath()."'; + const CLASS_NAME = '" . $this->getClasspath() . "'; "; } /** * Adds any attributes needed for this TableMap class. + * * @param string &$script The script will be modified in this method. */ protected function addAttributes(&$script) @@ -130,6 +137,7 @@ protected function addAttributes(&$script) /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) @@ -142,6 +150,7 @@ protected function addClassClose(&$script) /** * Adds the addInitialize() method to the table map class. + * * @param string &$script The script will be modified in this method. */ protected function addInitialize(&$script) @@ -161,8 +170,8 @@ protected function addInitialize(&$script) public function initialize() { // attributes - \$this->setName('".$table->getName()."'); - \$this->setPhpName('".$table->getPhpName()."'); + \$this->setName('" . $table->getName() . "'); + \$this->setPhpName('" . $table->getPhpName() . "'); \$this->setClassname('" . addslashes($this->getStubObjectBuilder()->getFullyQualifiedClassname()) . "'); \$this->setPackage('" . parent::getPackage() . "');"; if ($table->getIdMethod() == "native") { @@ -177,10 +186,10 @@ public function initialize() $params = $table->getIdMethodParameters(); $imp = $params[0]; $script .= " - \$this->setPrimaryKeyMethodInfo('".$imp->getValue()."');"; + \$this->setPrimaryKeyMethodInfo('" . $imp->getValue() . "');"; } elseif ($table->getIdMethod() == IDMethod::NATIVE && ($platform->getNativeIdMethod() == PropelPlatformInterface::SEQUENCE || $platform->getNativeIdMethod() == PropelPlatformInterface::SERIAL)) { $script .= " - \$this->setPrimaryKeyMethodInfo('".$platform->getSequenceName($table)."');"; + \$this->setPrimaryKeyMethodInfo('" . $platform->getSequenceName($table) . "');"; } if ($this->getTable()->getChildrenColumn()) { @@ -194,11 +203,11 @@ public function initialize() } // Add columns to map - $script .= " + $script .= " // columns"; foreach ($table->getColumns() as $col) { - $cup=$col->getName(); - $cfc=$col->getPhpName(); + $cup = $col->getName(); + $cfc = $col->getPhpName(); if (!$col->getSize()) { $size = "null"; } else { @@ -209,26 +218,26 @@ public function initialize() if ($col->isForeignKey()) { foreach ($col->getForeignKeys() as $fk) { $script .= " - \$this->addForeignPrimaryKey('$cup', '$cfc', '".$col->getType()."' , '".$fk->getForeignTableName()."', '".$fk->getMappedForeignColumn($col->getName())."', ".($col->isNotNull() ? 'true' : 'false').", ".$size.", $default);"; + \$this->addForeignPrimaryKey('$cup', '$cfc', '" . $col->getType() . "' , '" . $fk->getForeignTableName() . "', '" . $fk->getMappedForeignColumn($col->getName()) . "', " . ($col->isNotNull() ? 'true' : 'false') . ", " . $size . ", $default);"; } } else { $script .= " - \$this->addPrimaryKey('$cup', '$cfc', '".$col->getType()."', ".var_export($col->isNotNull(), true).", ".$size.", $default);"; + \$this->addPrimaryKey('$cup', '$cfc', '" . $col->getType() . "', " . var_export($col->isNotNull(), true) . ", " . $size . ", $default);"; } } else { if ($col->isForeignKey()) { foreach ($col->getForeignKeys() as $fk) { $script .= " - \$this->addForeignKey('$cup', '$cfc', '".$col->getType()."', '".$fk->getForeignTableName()."', '".$fk->getMappedForeignColumn($col->getName())."', ".($col->isNotNull() ? 'true' : 'false').", ".$size.", $default);"; + \$this->addForeignKey('$cup', '$cfc', '" . $col->getType() . "', '" . $fk->getForeignTableName() . "', '" . $fk->getMappedForeignColumn($col->getName()) . "', " . ($col->isNotNull() ? 'true' : 'false') . ", " . $size . ", $default);"; } } else { $script .= " - \$this->addColumn('$cup', '$cfc', '".$col->getType()."', ".var_export($col->isNotNull(), true).", ".$size.", $default);"; + \$this->addColumn('$cup', '$cfc', '" . $col->getType() . "', " . var_export($col->isNotNull(), true) . ", " . $size . ", $default);"; } } // if col-is prim key if ($col->getValueSet()) { $script .= " - \$this->getColumn('$cup', false)->setValueSet(" . var_export($col->getValueSet(), true). ");"; + \$this->getColumn('$cup', false)->setValueSet(" . var_export($col->getValueSet(), true) . ");"; } if ($col->isPrimaryString()) { $script .= " @@ -245,22 +254,22 @@ public function initialize() foreach ($val->getRules() as $rule) { if ($val->getTranslate() !== Validator::TRANSLATE_NONE) { $script .= " - \$this->addValidator('$cup', '".$rule->getName()."', '".$rule->getClass()."', '".str_replace("'", "\'", $rule->getValue())."', ".$val->getTranslate()."('".str_replace("'", "\'", $rule->getMessage())."'));"; + \$this->addValidator('$cup', '" . $rule->getName() . "', '" . $rule->getClass() . "', '" . str_replace("'", "\'", $rule->getValue()) . "', " . $val->getTranslate() . "('" . str_replace("'", "\'", $rule->getMessage()) . "'));"; } else { $script .= " - \$this->addValidator('$cup', '".$rule->getName()."', '".$rule->getClass()."', '".str_replace("'", "\'", $rule->getValue())."', '".str_replace("'", "\'", $rule->getMessage())."');"; + \$this->addValidator('$cup', '" . $rule->getName() . "', '" . $rule->getClass() . "', '" . str_replace("'", "\'", $rule->getValue()) . "', '" . str_replace("'", "\'", $rule->getMessage()) . "');"; } // if ($rule->getTranslation() ... - } // foreach rule - } // foreach validator + } // foreach rule + } // foreach validator $script .= " } // initialize() "; - } /** * Adds the method that build the RelationMap objects + * * @param string &$script The script will be modified in this method. */ protected function addBuildRelations(&$script) @@ -292,9 +301,9 @@ public function buildRelations() $onDelete = $fkey->hasOnDelete() ? "'" . $fkey->getOnDelete() . "'" : 'null'; $onUpdate = $fkey->hasOnUpdate() ? "'" . $fkey->getOnUpdate() . "'" : 'null'; $script .= " - \$this->addRelation('$relationName', '" . addslashes($this->getNewStubObjectBuilder($fkey->getTable())->getFullyQualifiedClassname()) . "', RelationMap::ONE_TO_" . ($fkey->isLocalPrimaryKey() ? "ONE" : "MANY") .", $columnMapping, $onDelete, $onUpdate"; + \$this->addRelation('$relationName', '" . addslashes($this->getNewStubObjectBuilder($fkey->getTable())->getFullyQualifiedClassname()) . "', RelationMap::ONE_TO_" . ($fkey->isLocalPrimaryKey() ? "ONE" : "MANY") . ", $columnMapping, $onDelete, $onUpdate"; if ($fkey->isLocalPrimaryKey()) { - $script .= ");"; + $script .= ");"; } else { $script .= ", '" . $this->getRefFKPhpNameAffix($fkey, true) . "');"; } @@ -315,12 +324,13 @@ public function buildRelations() /** * Adds the behaviors getter + * * @param string &$script The script will be modified in this method. */ protected function addGetBehaviors(&$script) { - if ($behaviors = $this->getTable()->getBehaviors()) { - $script .= " + if ($behaviors = $this->getTable()->getBehaviors()) { + $script .= " /** * * Gets the list of behaviors registered for this table @@ -332,7 +342,7 @@ public function getBehaviors() return array("; foreach ($behaviors as $behavior) { $script .= " - '{$behavior->getName()}' => ". var_export($behavior->getParameters(), true) . ","; + '{$behavior->getName()}' => " . var_export($behavior->getParameters(), true) . ","; } $script .= " ); @@ -343,7 +353,9 @@ public function getBehaviors() /** * Checks whether any registered behavior on that table has a modifier for a hook + * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" + * * @return boolean */ public function hasBehaviorModifier($hookName, $modifier = null) @@ -353,6 +365,7 @@ public function hasBehaviorModifier($hookName, $modifier = null) /** * Checks whether any registered behavior on that table has a modifier for a hook + * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string &$script The script will be modified in this method. */ diff --git a/generator/lib/builder/om/PeerBuilder.php b/generator/lib/builder/om/PeerBuilder.php index c3bf0461f..755a924f7 100644 --- a/generator/lib/builder/om/PeerBuilder.php +++ b/generator/lib/builder/om/PeerBuilder.php @@ -42,6 +42,7 @@ public function __construct(Table $table) /** * Adds the addSelectColumns(), doCount(), etc. methods. + * * @param string &$script The script will be modified in this method. */ protected function addSelectMethods(&$script) @@ -54,7 +55,7 @@ protected function addSelectMethods(&$script) // into a top-level method $this->addDoSelectOne($script); $this->addDoSelect($script); - $this->addDoSelectStmt($script); // <-- there's PDO code in here + $this->addDoSelectStmt($script); // <-- there's PDO code in here $this->addAddInstanceToPool($script); $this->addRemoveInstanceFromPool($script); @@ -66,11 +67,11 @@ protected function addSelectMethods(&$script) $this->addGetPrimaryKeyFromRow($script); $this->addPopulateObjects($script); // <-- there's PDO code in here $this->addPopulateObject($script); - } /** * Adds the correct getOMClass() method, depending on whether this table uses inheritance. + * * @param string &$script The script will be modified in this method. */ protected function addGetOMClassMethod(&$script) @@ -89,6 +90,7 @@ protected function addGetOMClassMethod(&$script) /** * Adds the doInsert(), doUpdate(), doDeleteAll(), doValidate(), etc. methods. + * * @param string &$script The script will be modified in this method. */ protected function addUpdateMethods(&$script) @@ -108,6 +110,7 @@ protected function addUpdateMethods(&$script) /** * Adds the retrieveByPK() (and possibly retrieveByPKs()) method(s) appropriate for this class. + * * @param string &$script The script will be modified in this method. */ protected function addRetrieveByPKMethods(&$script) @@ -171,6 +174,7 @@ protected function addClassBody(&$script) /** * Whether the platform in use requires ON DELETE CASCADE emulation and whether there are references to this table. + * * @return boolean */ protected function isDeleteCascadeEmulationNeeded() @@ -189,6 +193,7 @@ protected function isDeleteCascadeEmulationNeeded() /** * Whether the platform in use requires ON DELETE SETNULL emulation and whether there are references to this table. + * * @return boolean */ protected function isDeleteSetNullEmulationNeeded() @@ -209,6 +214,7 @@ protected function isDeleteSetNullEmulationNeeded() * Whether to add the generic mutator methods (setByName(), setByPosition(), fromArray()). * This is based on the build property propel.addGenericMutators, and also whether the * table is read-only or an alias. + * * @return boolean */ protected function isAddGenericMutators() @@ -222,6 +228,7 @@ protected function isAddGenericMutators() * Whether to add the generic accessor methods (getByName(), getByPosition(), toArray()). * This is based on the build property propel.addGenericAccessors, and also whether the * table is an alias. + * * @return boolean */ protected function isAddGenericAccessors() @@ -235,6 +242,7 @@ protected function isAddGenericAccessors() * Returns the retrieveByPK method name to use for this table. * If the table is an alias then the method name looks like "retrieveTablenameByPK" * otherwise simply "retrieveByPK". + * * @return string */ public function getRetrieveMethodName() @@ -277,27 +285,31 @@ public static function getColumnName(Column $col, $phpName = null) } /** - * Checks whether any registered behavior on that table has a modifier for a hook - * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" - * @return boolean - */ - public function hasBehaviorModifier($hookName, $modifier = null) - { - return parent::hasBehaviorModifier($hookName, 'PeerBuilderModifier'); - } - - /** - * Checks whether any registered behavior on that table has a modifier for a hook - * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" + * Checks whether any registered behavior on that table has a modifier for a hook + * + * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" + * + * @return boolean + */ + public function hasBehaviorModifier($hookName, $modifier = null) + { + return parent::hasBehaviorModifier($hookName, 'PeerBuilderModifier'); + } + + /** + * Checks whether any registered behavior on that table has a modifier for a hook + * + * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string &$script The script will be modified in this method. - */ - public function applyBehaviorModifier($hookName, &$script, $tab = " ") - { - return $this->applyBehaviorModifierBase($hookName, 'PeerBuilderModifier', $script, $tab); - } + */ + public function applyBehaviorModifier($hookName, &$script, $tab = " ") + { + return $this->applyBehaviorModifierBase($hookName, 'PeerBuilderModifier', $script, $tab); + } /** * Checks whether any registered behavior content creator on that table exists a contentName + * * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassname" */ public function getBehaviorContent($contentName) @@ -305,13 +317,13 @@ public function getBehaviorContent($contentName) return $this->getBehaviorContentBase($contentName, 'PeerBuilderModifier'); } - /** - * Get the BasePeer class name for the current table (e.g. 'BasePeer') - * - * @return string The Base Peer Class name - */ - public function getBasePeerClassname() - { - return $this->basePeerClassname; - } + /** + * Get the BasePeer class name for the current table (e.g. 'BasePeer') + * + * @return string The Base Peer Class name + */ + public function getBasePeerClassname() + { + return $this->basePeerClassname; + } } diff --git a/generator/lib/builder/om/QueryBuilder.php b/generator/lib/builder/om/QueryBuilder.php index 4df91f75a..ad65ca57d 100644 --- a/generator/lib/builder/om/QueryBuilder.php +++ b/generator/lib/builder/om/QueryBuilder.php @@ -24,6 +24,7 @@ class QueryBuilder extends OMBuilder /** * Gets the package for the [base] object classes. + * * @return string */ public function getPackage() @@ -44,6 +45,7 @@ public function getNamespace() /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -53,6 +55,7 @@ public function getUnprefixedClassname() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) @@ -61,6 +64,7 @@ protected function addIncludes(&$script) /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -161,12 +165,12 @@ protected function addClassOpen(&$script) if ($this->getBuildProperty('addClassLevelComment')) { $script .= " * - * @package propel.generator.".$this->getPackage(); + * @package propel.generator." . $this->getPackage(); } $script .= " */ -abstract class ".$this->getClassname()." extends " . $parentClass . " +abstract class " . $this->getClassname() . " extends " . $parentClass . " {"; } @@ -228,6 +232,7 @@ protected function addClassBody(&$script) /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) @@ -240,7 +245,9 @@ protected function addClassClose(&$script) /** * Adds the constructor for this object. + * * @param string &$script The script will be modified in this method. + * * @see addConstructor() */ protected function addConstructor(&$script) @@ -253,13 +260,14 @@ protected function addConstructor(&$script) /** * Adds the comment for the constructor + * * @param string &$script The script will be modified in this method. **/ protected function addConstructorComment(&$script) { $script .= " /** - * Initializes internal state of ".$this->getClassname()." object. + * Initializes internal state of " . $this->getClassname() . " object. * * @param string \$dbName The dabase name * @param string \$modelName The phpName of a model, e.g. 'Book' @@ -269,6 +277,7 @@ protected function addConstructorComment(&$script) /** * Adds the function declaration for the constructor + * * @param string &$script The script will be modified in this method. **/ protected function addConstructorOpen(&$script) @@ -281,6 +290,7 @@ public function __construct(\$dbName = '" . $table->getDatabase()->getName() . " /** * Adds the function body for the constructor + * * @param string &$script The script will be modified in this method. **/ protected function addConstructorBody(&$script) @@ -291,6 +301,7 @@ protected function addConstructorBody(&$script) /** * Adds the function close for the constructor + * * @param string &$script The script will be modified in this method. **/ protected function addConstructorClose(&$script) @@ -302,6 +313,7 @@ protected function addConstructorClose(&$script) /** * Adds the factory for this object. + * * @param string &$script The script will be modified in this method. */ protected function addFactory(&$script) @@ -314,6 +326,7 @@ protected function addFactory(&$script) /** * Adds the comment for the factory + * * @param string &$script The script will be modified in this method. **/ protected function addFactoryComment(&$script) @@ -332,6 +345,7 @@ protected function addFactoryComment(&$script) /** * Adds the function declaration for the factory + * * @param string &$script The script will be modified in this method. **/ protected function addFactoryOpen(&$script) @@ -343,6 +357,7 @@ public static function create(\$modelAlias = null, \$criteria = null) /** * Adds the function body for the factory + * * @param string &$script The script will be modified in this method. */ protected function addFactoryBody(&$script) @@ -365,6 +380,7 @@ protected function addFactoryBody(&$script) /** * Adds the function close for the factory + * * @param string &$script The script will be modified in this method. */ protected function addFactoryClose(&$script) @@ -391,11 +407,11 @@ protected function addFindPk(&$script) $examplePk = array_slice(array(12, 34, 56, 78, 91), 0, count($pks)); $colNames = array(); foreach ($pks as $col) { - $colNames[]= '$' . $col->getName(); + $colNames[] = '$' . $col->getName(); } $pkType = 'array'; $pkDescription = " - A Primary key composition: ".'['. join($colNames, ', ') . ']'; + A Primary key composition: " . '[' . join($colNames, ', ') . ']'; $script .= " * * \$obj = \$c->findPk(array(" . join($examplePk, ', ') . "), \$con);"; @@ -421,7 +437,7 @@ public function findPk(\$key, \$con = null) if ($table->hasCompositePrimaryKey()) { $pks = array(); foreach ($table->getPrimaryKey() as $index => $column) { - $pks []= "\$key[$index]"; + $pks [] = "\$key[$index]"; } } else { $pks = '$key'; @@ -486,26 +502,21 @@ protected function addFindPkSimple(&$script) $selectColumns = array(); foreach ($table->getColumns() as $column) { if (!$column->isLazyLoad()) { - $selectColumns []= $platform->quoteIdentifier($column->getName()); + $selectColumns [] = $platform->quoteIdentifier($column->getName()); } } $conditions = array(); foreach ($table->getPrimaryKey() as $index => $column) { - $conditions []= sprintf('%s = :p%d', $platform->quoteIdentifier($column->getName()), $index); + $conditions [] = sprintf('%s = :p%d', $platform->quoteIdentifier($column->getName()), $index); } - $query = sprintf( - 'SELECT %s FROM %s WHERE %s', - implode(', ', $selectColumns), - $platform->quoteIdentifier($table->getName()), - implode(' AND ', $conditions) - ); + $query = sprintf('SELECT %s FROM %s WHERE %s', implode(', ', $selectColumns), $platform->quoteIdentifier($table->getName()), implode(' AND ', $conditions)); $pks = array(); if ($table->hasCompositePrimaryKey()) { foreach ($table->getPrimaryKey() as $index => $column) { - $pks []= "\$key[$index]"; + $pks [] = "\$key[$index]"; } } else { - $pks []= "\$key"; + $pks [] = "\$key"; } $pkHashFromRow = $this->getPeerBuilder()->getInstancePoolKeySnippet($pks); $script .= " @@ -543,11 +554,11 @@ protected function findPkSimple(\$key, \$con) if (\$row = \$stmt->fetch(PDO::FETCH_NUM)) {"; if ($col = $table->getChildrenColumn()) { - $script .=" + $script .= " \$cls = {$peerClassname}::getOMClass(\$row, 0); \$obj = new \$cls();"; } else { - $script .=" + $script .= " \$obj = new $ARClassname();"; } $script .= " @@ -563,6 +574,7 @@ protected function findPkSimple(\$key, \$con) /** * Adds the findPk method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addFindPkComplex(&$script) @@ -595,6 +607,7 @@ protected function findPkComplex(\$key, \$con) /** * Adds the findPks method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addFindPks(&$script) @@ -640,6 +653,7 @@ public function findPks(\$keys, \$con = null) /** * Adds the filterByPrimaryKey method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addFilterByPrimaryKey(&$script) @@ -683,6 +697,7 @@ public function filterByPrimaryKey(\$key) /** * Adds the filterByPrimaryKey method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addFilterByPrimaryKeys(&$script) @@ -718,7 +733,7 @@ public function filterByPrimaryKeys(\$keys) $const = $this->getColumnConstant($col); $script .= " \$cton$i = \$this->getNewCriterion($const, \$key[$i], Criteria::EQUAL);"; - if ($i>0) { + if ($i > 0) { $script .= " \$cton0->addAnd(\$cton$i);"; } @@ -727,7 +742,7 @@ public function filterByPrimaryKeys(\$keys) $script .= " \$this->addOr(\$cton0); }"; - $script .= " + $script .= " return \$this;"; } @@ -738,6 +753,7 @@ public function filterByPrimaryKeys(\$keys) /** * Adds the filterByCol method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addFilterByCol(&$script, $col) @@ -932,6 +948,7 @@ public function filterBy$colPhpName(\$$variableName = null, \$comparison = null) /** * Adds the singular filterByCol method for an Array column. + * * @param string &$script The script will be modified in this method. */ protected function addFilterByArrayCol(&$script, $col) @@ -977,6 +994,7 @@ public function filterBy$singularPhpName(\$$variableName = null, \$comparison = /** * Adds the filterByFk method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addFilterByFk(&$script, $fk) @@ -1048,6 +1066,7 @@ public function filterBy$relationName($objectName, \$comparison = null) /** * Adds the filterByRefFk method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addFilterByRefFk(&$script, $fk) @@ -1107,6 +1126,7 @@ public function filterBy$relationName($objectName, \$comparison = null) /** * Adds the joinFk method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addJoinFk(&$script, $fk) @@ -1121,6 +1141,7 @@ protected function addJoinFk(&$script, $fk) /** * Adds the joinRefFk method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addJoinRefFk(&$script, $fk) @@ -1135,6 +1156,7 @@ protected function addJoinRefFk(&$script, $fk) /** * Adds a joinRelated method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addJoinRelated(&$script, $fkTable, $queryClass, $relationName, $joinType) @@ -1146,7 +1168,7 @@ protected function addJoinRelated(&$script, $fkTable, $queryClass, $relationName * @param string \$relationAlias optional alias for the relation * @param string \$joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return ". $queryClass . " The current query, for fluid interface + * @return " . $queryClass . " The current query, for fluid interface */ public function join" . $relationName . "(\$relationAlias = null, \$joinType = " . $joinType . ") { @@ -1176,6 +1198,7 @@ public function join" . $relationName . "(\$relationAlias = null, \$joinType = " /** * Adds the useFkQuery method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addUseFkQuery(&$script, $fk) @@ -1194,6 +1217,7 @@ protected function addUseFkQuery(&$script, $fk) /** * Adds the useFkQuery method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addUseRefFkQuery(&$script, $fk) @@ -1212,6 +1236,7 @@ protected function addUseRefFkQuery(&$script, $fk) /** * Adds a useRelatedQuery method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addUseRelatedQuery(&$script, $fkTable, $queryClass, $relationName, $joinType) @@ -1242,7 +1267,7 @@ protected function addFilterByCrossFK(&$script, $refFK, $crossFK) $queryClass = $this->getStubQueryBuilder()->getClassname(); $crossRefTable = $crossFK->getTable(); $foreignTable = $crossFK->getForeignTable(); - $fkPhpName = $foreignTable->getPhpName(); + $fkPhpName = $foreignTable->getPhpName(); $crossTableName = $crossRefTable->getName(); $this->declareClassFromBuilder($this->getNewStubObjectBuilder($foreignTable)); $relName = $this->getFKPhpNameAffix($crossFK, $plural = false); @@ -1270,6 +1295,7 @@ public function filterBy{$relName}($objectName, \$comparison = Criteria::EQUAL) /** * Adds the prune method for this object. + * * @param string &$script The script will be modified in this method. */ protected function addPrune(&$script) @@ -1295,9 +1321,9 @@ public function prune($objectName = null) foreach ($pks as $col) { $const = $this->getColumnConstant($col); $condName = "'pruneCond" . $i . "'"; - $conditions[]= $condName; + $conditions[] = $condName; $script .= " - \$this->addCond(". $condName . ", \$this->getAliasedColName($const), " . $objectName . "->get" . $col->getPhpName() . "(), Criteria::NOT_EQUAL);"; + \$this->addCond(" . $condName . ", \$this->getAliasedColName($const), " . $objectName . "->get" . $col->getPhpName() . "(), Criteria::NOT_EQUAL);"; $i++; } $conditionsString = implode(', ', $conditions); @@ -1319,6 +1345,7 @@ public function prune($objectName = null) /** * Adds the basePreSelect hook for this object. + * * @param string &$script The script will be modified in this method. */ protected function addBasePreSelect(&$script) @@ -1344,6 +1371,7 @@ protected function basePreSelect(PropelPDO \$con) /** * Adds the basePreDelete hook for this object. + * * @param string &$script The script will be modified in this method. */ protected function addBasePreDelete(&$script) @@ -1369,6 +1397,7 @@ protected function basePreDelete(PropelPDO \$con) /** * Adds the basePostDelete hook for this object. + * * @param string &$script The script will be modified in this method. */ protected function addBasePostDelete(&$script) @@ -1395,6 +1424,7 @@ protected function basePostDelete(\$affectedRows, PropelPDO \$con) /** * Adds the basePreUpdate hook for this object. + * * @param string &$script The script will be modified in this method. */ protected function addBasePreUpdate(&$script) @@ -1422,6 +1452,7 @@ protected function basePreUpdate(&\$values, PropelPDO \$con, \$forceIndividualSa /** * Adds the basePostUpdate hook for this object. + * * @param string &$script The script will be modified in this method. */ protected function addBasePostUpdate(&$script) @@ -1448,7 +1479,9 @@ protected function basePostUpdate(\$affectedRows, PropelPDO \$con) /** * Checks whether any registered behavior on that table has a modifier for a hook + * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" + * * @return boolean */ public function hasBehaviorModifier($hookName, $modifier = null) @@ -1458,6 +1491,7 @@ public function hasBehaviorModifier($hookName, $modifier = null) /** * Checks whether any registered behavior on that table has a modifier for a hook + * * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave" * @param string &$script The script will be modified in this method. */ @@ -1468,11 +1502,11 @@ public function applyBehaviorModifier($hookName, &$script, $tab = " ") /** * Checks whether any registered behavior content creator on that table exists a contentName + * * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassname" */ public function getBehaviorContent($contentName) { return $this->getBehaviorContentBase($contentName, 'QueryBuilderModifier'); } - } diff --git a/generator/lib/builder/om/QueryInheritanceBuilder.php b/generator/lib/builder/om/QueryInheritanceBuilder.php index 0436686fb..0f3262ff0 100644 --- a/generator/lib/builder/om/QueryInheritanceBuilder.php +++ b/generator/lib/builder/om/QueryInheritanceBuilder.php @@ -31,6 +31,7 @@ class QueryInheritanceBuilder extends OMBuilder /** * Returns the name of the current class being built. + * * @return string */ public function getUnprefixedClassname() @@ -40,6 +41,7 @@ public function getUnprefixedClassname() /** * Gets the package for the [base] object classes. + * * @return string */ public function getPackage() @@ -60,6 +62,7 @@ public function getNamespace() /** * Set the child object that we're operating on currently. + * * @param $child Inheritance */ public function setChild(Inheritance $child) @@ -69,6 +72,7 @@ public function setChild(Inheritance $child) /** * Returns the child object we're operating on currently. + * * @return Inheritance * @throws BuildException - if child was not set. */ @@ -83,6 +87,7 @@ public function getChild() /** * Returns classpath to parent class. + * * @return string */ protected function getParentClassName() @@ -102,19 +107,21 @@ protected function getParentClassName() /** * Adds the include() statements for files that this class depends on or utilizes. + * * @param string &$script The script will be modified in this method. */ protected function addIncludes(&$script) { $requiredClassFilePath = $this->getStubQueryBuilder()->getClassFilePath(); - $script .=" -require '".$requiredClassFilePath."'; + $script .= " +require '" . $requiredClassFilePath . "'; "; } // addIncludes() /** * Adds class phpdoc comment and opening of class. + * * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) @@ -146,9 +153,9 @@ protected function addClassOpen(&$script) * application requirements. This class will only be generated as * long as it does not already exist in the output directory. * - * @package propel.generator.".$this->getPackage()." + * @package propel.generator." . $this->getPackage() . " */ -class " .$this->getClassname() . " extends " . $baseClassname . " { +class " . $this->getClassname() . " extends " . $baseClassname . " { "; } @@ -174,6 +181,7 @@ protected function addClassBody(&$script) /** * Adds the factory for this object. + * * @param string &$script The script will be modified in this method. */ protected function addFactory(&$script) @@ -259,9 +267,9 @@ public function preDelete(PropelPDO \$con) protected function getClassKeyCondition() { $child = $this->getChild(); - $col = $child->getColumn(); + $col = $child->getColumn(); - return "\$this->addUsingAlias(" . $this->getColumnConstant($col) . ", " . $this->getPeerClassname()."::CLASSKEY_".strtoupper($child->getKey()).");"; + return "\$this->addUsingAlias(" . $this->getColumnConstant($col) . ", " . $this->getPeerClassname() . "::CLASSKEY_" . strtoupper($child->getKey()) . ");"; } protected function addDoDeleteAll(&$script) @@ -288,6 +296,7 @@ public function doDeleteAll(\$con) /** * Closes class. + * * @param string &$script The script will be modified in this method. */ protected function addClassClose(&$script) @@ -299,6 +308,7 @@ protected function addClassClose(&$script) /** * Adds findOneOrCreate function for this object. + * * @param unknown $script */ protected function addFindOneOrCreate(&$script) @@ -324,7 +334,7 @@ public function findOneOrCreate(\$con = null) throw new PropelException('findOneOrCreate() cannot be used on a query with a join, because Propel cannot transform a SQL JOIN into a subquery. You should split the query in two queries to avoid joins.'); } if (!\$ret = \$this->findOne(\$con)) { - \$class = ".$this->getPeerClassname() . "::CLASSNAME_" . strtoupper($child->getKey()) . "; + \$class = " . $this->getPeerClassname() . "::CLASSNAME_" . strtoupper($child->getKey()) . "; \$obj = new \$class; foreach (\$this->keys() as \$key) { \$obj->setByName(\$key, \$this->getValue(\$key), BasePeer::TYPE_COLNAME); @@ -336,5 +346,4 @@ public function findOneOrCreate(\$con = null) } "; } - } // MultiExtensionQueryBuilder diff --git a/generator/lib/builder/sql/DataSQLBuilder.php b/generator/lib/builder/sql/DataSQLBuilder.php index e538633b2..111f1bb66 100644 --- a/generator/lib/builder/sql/DataSQLBuilder.php +++ b/generator/lib/builder/sql/DataSQLBuilder.php @@ -72,7 +72,9 @@ public function getTableEndSql() /** * The main method in this class, returns the SQL for INSERTing data into a row. + * * @param DataRow $row The row to process. + * * @return string */ public function buildRowSql(DataRow $row) @@ -81,7 +83,7 @@ public function buildRowSql(DataRow $row) $platform = $this->getPlatform(); $table = $this->getTable(); - $sql .= "INSERT INTO ".$this->quoteIdentifier($this->getTable()->getName())." ("; + $sql .= "INSERT INTO " . $this->quoteIdentifier($this->getTable()->getName()) . " ("; // add column names to SQL $colNames = array(); @@ -107,7 +109,9 @@ public function buildRowSql(DataRow $row) /** * Gets the property escaped (and quoted) value for a column. + * * @param ColumnValue $colValue + * * @return mixed The proper value to be added to the string. */ protected function getColumnValueSql(ColumnValue $colValue) @@ -121,7 +125,9 @@ protected function getColumnValueSql(ColumnValue $colValue) /** * Gets a representation of a binary value suitable for use in a SQL statement. * Default behavior is true = 1, false = 0. + * * @param boolean $value + * * @return int */ protected function getBooleanSql($value) @@ -131,7 +137,9 @@ protected function getBooleanSql($value) /** * Gets a representation of a BLOB/LONGVARBINARY value suitable for use in a SQL statement. + * * @param mixed $blob Blob object or string data. + * * @return string */ protected function getBlobSql($blob) @@ -146,7 +154,9 @@ protected function getBlobSql($blob) /** * Gets a representation of a CLOB/LONGVARCHAR value suitable for use in a SQL statement. + * * @param mixed $clob Clob object or string data. + * * @return string */ protected function getClobSql($clob) @@ -161,7 +171,9 @@ protected function getClobSql($clob) /** * Gets a representation of a date value suitable for use in a SQL statement. + * * @param string $value + * * @return string */ protected function getDateSql($value) @@ -171,7 +183,9 @@ protected function getDateSql($value) /** * Gets a representation of a decimal value suitable for use in a SQL statement. + * * @param double $value + * * @return float */ protected function getDecimalSql($value) @@ -181,7 +195,9 @@ protected function getDecimalSql($value) /** * Gets a representation of a double value suitable for use in a SQL statement. + * * @param double $value + * * @return double */ protected function getDoubleSql($value) @@ -191,7 +207,9 @@ protected function getDoubleSql($value) /** * Gets a representation of a float value suitable for use in a SQL statement. + * * @param float $value + * * @return float */ protected function getFloatSql($value) @@ -201,7 +219,9 @@ protected function getFloatSql($value) /** * Gets a representation of an integer value suitable for use in a SQL statement. + * * @param int $value + * * @return int */ protected function getIntSql($value) @@ -211,6 +231,7 @@ protected function getIntSql($value) /** * Gets a representation of a NULL value suitable for use in a SQL statement. + * * @return null */ protected function getNullSql() @@ -220,7 +241,9 @@ protected function getNullSql() /** * Gets a representation of a string value suitable for use in a SQL statement. + * * @param string $value + * * @return string */ protected function getStringSql($value) @@ -230,7 +253,9 @@ protected function getStringSql($value) /** * Gets a representation of a time value suitable for use in a SQL statement. + * * @param string $value + * * @return string */ protected function getTimeSql($paramIndex, $value) @@ -240,12 +265,13 @@ protected function getTimeSql($paramIndex, $value) /** * Gets a representation of a timestamp value suitable for use in a SQL statement. + * * @param string $value + * * @return string */ public function getTimestampSql($value) { return "'" . date('Y-m-d H:i:s', strtotime($value)) . "'"; } - } diff --git a/generator/lib/builder/sql/mssql/MssqlDataSQLBuilder.php b/generator/lib/builder/sql/mssql/MssqlDataSQLBuilder.php index f2fd6b621..7c210d1cf 100644 --- a/generator/lib/builder/sql/mssql/MssqlDataSQLBuilder.php +++ b/generator/lib/builder/sql/mssql/MssqlDataSQLBuilder.php @@ -22,6 +22,7 @@ class MssqlDataSQLBuilder extends DataSQLBuilder /** * * @param mixed $blob Blob object or string containing data. + * * @return string */ protected function getBlobSql($blob) @@ -32,7 +33,6 @@ protected function getBlobSql($blob) } $data = unpack("H*hex", $blob); - return '0x'.$data['hex']; // no surrounding quotes! + return '0x' . $data['hex']; // no surrounding quotes! } - } diff --git a/generator/lib/builder/sql/pgsql/PgsqlDataSQLBuilder.php b/generator/lib/builder/sql/pgsql/PgsqlDataSQLBuilder.php index ee571a2f8..44778302c 100644 --- a/generator/lib/builder/sql/pgsql/PgsqlDataSQLBuilder.php +++ b/generator/lib/builder/sql/pgsql/PgsqlDataSQLBuilder.php @@ -38,7 +38,9 @@ public function __construct(Table $table) /** * The main method in this class, returns the SQL for INSERTing data into a row. + * * @param DataRow $row The row to process. + * * @return string */ public function buildRowSql(DataRow $row) @@ -66,7 +68,7 @@ public function getTableEndSql() $sql = ""; if ($table->hasAutoIncrementPrimaryKey() && $table->getIdMethod() == IDMethod::NATIVE) { $seqname = $this->getPlatform()->getSequenceName($table); - $sql .= "SELECT pg_catalog.setval('$seqname', ".((int) $this->maxSeqVal)."); + $sql .= "SELECT pg_catalog.setval('$seqname', " . ((int) $this->maxSeqVal) . "); "; } @@ -75,7 +77,9 @@ public function getTableEndSql() /** * Get SQL value to insert for Postgres BOOLEAN column. + * * @param boolean $value + * * @return string The representation of boolean for Postgres ('t' or 'f'). */ protected function getBooleanSql($value) @@ -90,6 +94,7 @@ protected function getBooleanSql($value) /** * * @param mixed $blob Blob object or string containing data. + * * @return string */ protected function getBlobSql($blob) @@ -101,5 +106,4 @@ protected function getBlobSql($blob) return "'" . pg_escape_bytea($blob) . "'"; } - } diff --git a/generator/lib/builder/sql/sqlite/SqliteDataSQLBuilder.php b/generator/lib/builder/sql/sqlite/SqliteDataSQLBuilder.php index cc8a7fc70..b325d304b 100644 --- a/generator/lib/builder/sql/sqlite/SqliteDataSQLBuilder.php +++ b/generator/lib/builder/sql/sqlite/SqliteDataSQLBuilder.php @@ -21,7 +21,9 @@ class SqliteDataSQLBuilder extends DataSQLBuilder /** * Returns string processed by sqlite_udf_encode_binary() to ensure that binary contents will be handled correctly by sqlite. + * * @param mixed $blob Blob or string + * * @return string encoded text */ protected function getBlobSql($blob) @@ -33,5 +35,4 @@ protected function getBlobSql($blob) return "'" . sqlite_udf_encode_binary($blob) . "'"; } - } diff --git a/generator/lib/builder/util/DefaultEnglishPluralizer.php b/generator/lib/builder/util/DefaultEnglishPluralizer.php index 99c8b1abe..138703aa6 100644 --- a/generator/lib/builder/util/DefaultEnglishPluralizer.php +++ b/generator/lib/builder/util/DefaultEnglishPluralizer.php @@ -22,12 +22,13 @@ class DefaultEnglishPluralizer implements Pluralizer /** * Generate a plural name based on the passed in root. + * * @param string $root The root that needs to be pluralized (e.g. Author) + * * @return string The plural form of $root (e.g. Authors). */ public function getPluralForm($root) { return $root . 's'; } - } diff --git a/generator/lib/builder/util/Pluralizer.php b/generator/lib/builder/util/Pluralizer.php index 71738d383..de9e5de89 100644 --- a/generator/lib/builder/util/Pluralizer.php +++ b/generator/lib/builder/util/Pluralizer.php @@ -20,9 +20,10 @@ interface Pluralizer /** * Generate a plural name based on the passed in root. + * * @param string $root The root that needs to be pluralized (e.g. Author) + * * @return string The plural form of $root. */ public function getPluralForm($root); - } diff --git a/generator/lib/builder/util/PropelStringReader.php b/generator/lib/builder/util/PropelStringReader.php index d8b0c75f0..e2f8a6258 100644 --- a/generator/lib/builder/util/PropelStringReader.php +++ b/generator/lib/builder/util/PropelStringReader.php @@ -25,8 +25,8 @@ class PropelStringReader extends Reader protected $_string; /** - * @var int - */ + * @var int + */ protected $mark = 0; /** @@ -74,11 +74,17 @@ public function reset() $this->currPos = $this->mark; } - public function close() {} + public function close() + { + } - public function open() {} + public function open() + { + } - public function ready() {} + public function ready() + { + } public function markSupported() { @@ -87,6 +93,6 @@ public function markSupported() public function getResource() { - return '(string) "'.$this->_string . '"'; + return '(string) "' . $this->_string . '"'; } } diff --git a/generator/lib/builder/util/PropelTemplate.php b/generator/lib/builder/util/PropelTemplate.php index 25a0fee48..606a6574b 100644 --- a/generator/lib/builder/util/PropelTemplate.php +++ b/generator/lib/builder/util/PropelTemplate.php @@ -22,7 +22,7 @@ class PropelTemplate /** * Set a string as a template. * The string doesn't need closing php tags. - * + * * * $template->setTemplate('This is '); * @@ -67,7 +67,7 @@ public function setTemplateFile($filePath) */ public function render($vars = array()) { - if (null === $this->templateFile && null === $this->template) { + if (null === $this->templateFile && null === $this->template) { throw new InvalidArgumentException('You must set a template or a template file before rendering'); } diff --git a/generator/lib/builder/util/StandardEnglishPluralizer.php b/generator/lib/builder/util/StandardEnglishPluralizer.php index 685240780..b0be5a52c 100644 --- a/generator/lib/builder/util/StandardEnglishPluralizer.php +++ b/generator/lib/builder/util/StandardEnglishPluralizer.php @@ -111,7 +111,9 @@ class StandardEnglishPluralizer implements Pluralizer /** * Generate a plural name based on the passed in root. + * * @param string $root The root that needs to be pluralized (e.g. Author) + * * @return string The plural form of $root (e.g. Authors). */ public function getPluralForm($root) diff --git a/generator/lib/builder/util/XmlToAppData.php b/generator/lib/builder/util/XmlToAppData.php index 1d71e3d22..3a2c19f6c 100644 --- a/generator/lib/builder/util/XmlToAppData.php +++ b/generator/lib/builder/util/XmlToAppData.php @@ -46,9 +46,13 @@ class XmlToAppData private $encoding; - /** two-dimensional array, - first dimension is for schemas(key is the path to the schema file), - second is for tags within the schema */ + /** + * two-dimensional array, + * first dimension is for schemas(key is the path to the schema file), + * second is for tags within the schema + * + * @var array + */ private $schemasTagsStack = array(); /** @@ -60,10 +64,10 @@ class XmlToAppData */ public function __construct(PropelPlatformInterface $defaultPlatform = null, $defaultPackage = null, $encoding = 'iso-8859-1') { - $this->app = new AppData($defaultPlatform); + $this->app = new AppData($defaultPlatform); $this->defaultPackage = $defaultPackage; - $this->firstPass = true; - $this->encoding = $encoding; + $this->firstPass = true; + $this->encoding = $encoding; } /** @@ -81,6 +85,7 @@ public function setGeneratorConfig(GeneratorConfigInterface $generatorConfig) * populated AppData structure. * * @param string $xmlFile The input file to parse. + * * @return AppData populated by xmlFile. */ public function parseFile($xmlFile) @@ -99,6 +104,7 @@ public function parseFile($xmlFile) * * @param string $xmlString The input string to parse. * @param string $xmlFile The input file name. + * * @return AppData populated by xmlFile. * @throws Exception */ @@ -134,35 +140,34 @@ public function parseString($xmlString, $xmlFile = null) * * @param string $uri * @param string $localName The local name (without prefix), or the empty string if - * Namespace processing is not being performed. + * Namespace processing is not being performed. * @param string $rawName The qualified name (with prefix), or the empty string if - * qualified names are not available. + * qualified names are not available. * @param string $attributes The specified or defaulted attributes * * @throws SchemaException */ public function startElement($parser, $name, $attributes) { - $parentTag = $this->peekCurrentSchemaTag(); - - if ($parentTag === false) { - - switch ($name) { - case "database": - if ($this->isExternalSchema()) { - $this->currentPackage = @$attributes["package"]; - if ($this->currentPackage === null) { - $this->currentPackage = $this->defaultPackage; - } - } else { - $this->currDB = $this->app->addDatabase($attributes); + $parentTag = $this->peekCurrentSchemaTag(); + + if ($parentTag === false) { + + switch ($name) { + case "database": + if ($this->isExternalSchema()) { + $this->currentPackage = @$attributes["package"]; + if ($this->currentPackage === null) { + $this->currentPackage = $this->defaultPackage; } + } else { + $this->currDB = $this->app->addDatabase($attributes); + } break; - default: - $this->_throwInvalidTagException($parser, $name); - } - + default: + $this->_throwInvalidTagException($parser, $name); + } } elseif ($parentTag == "database") { switch ($name) { @@ -185,11 +190,11 @@ public function startElement($parser, $name, $attributes) } $this->parseFile($xmlFile); - break; + break; - case "domain": - $this->currDB->addDomain($attributes); - break; + case "domain": + $this->currDB->addDomain($attributes); + break; case "table": $this->currTable = $this->currDB->addTable($attributes); @@ -197,114 +202,109 @@ public function startElement($parser, $name, $attributes) $this->currTable->setForReferenceOnly($this->isForReferenceOnly); $this->currTable->setPackage($this->currentPackage); } - break; + break; case "vendor": $this->currVendorObject = $this->currDB->addVendorInfo($attributes); - break; + break; case "behavior": - $this->currBehavior = $this->currDB->addBehavior($attributes); - break; + $this->currBehavior = $this->currDB->addBehavior($attributes); + break; default: $this->_throwInvalidTagException($parser, $name); } - } elseif ($parentTag == "table") { switch ($name) { case "column": $this->currColumn = $this->currTable->addColumn($attributes); - break; + break; case "foreign-key": $this->currFK = $this->currTable->addForeignKey($attributes); - break; + break; case "index": $this->currIndex = $this->currTable->addIndex($attributes); - break; + break; case "unique": $this->currUnique = $this->currTable->addUnique($attributes); - break; + break; case "vendor": $this->currVendorObject = $this->currTable->addVendorInfo($attributes); - break; + break; - case "validator": - $this->currValidator = $this->currTable->addValidator($attributes); - break; + case "validator": + $this->currValidator = $this->currTable->addValidator($attributes); + break; - case "id-method-parameter": + case "id-method-parameter": $this->currTable->addIdMethodParameter($attributes); - break; + break; case "behavior": - $this->currBehavior = $this->currTable->addBehavior($attributes); - break; + $this->currBehavior = $this->currTable->addBehavior($attributes); + break; default: $this->_throwInvalidTagException($parser, $name); } - } elseif ($parentTag == "column") { switch ($name) { case "inheritance": $this->currColumn->addInheritance($attributes); - break; + break; case "vendor": $this->currVendorObject = $this->currColumn->addVendorInfo($attributes); - break; + break; default: $this->_throwInvalidTagException($parser, $name); } - } elseif ($parentTag == "foreign-key") { switch ($name) { case "reference": $this->currFK->addReference($attributes); - break; + break; case "vendor": $this->currVendorObject = $this->currUnique->addVendorInfo($attributes); - break; + break; default: $this->_throwInvalidTagException($parser, $name); } - } elseif ($parentTag == "index") { switch ($name) { case "index-column": $this->currIndex->addColumn($attributes); - break; + break; case "vendor": $this->currVendorObject = $this->currIndex->addVendorInfo($attributes); - break; + break; default: $this->_throwInvalidTagException($parser, $name); } - } elseif ($parentTag == "unique") { switch ($name) { case "unique-column": $this->currUnique->addColumn($attributes); - break; + break; case "vendor": $this->currVendorObject = $this->currUnique->addVendorInfo($attributes); - break; + break; default: $this->_throwInvalidTagException($parser, $name); @@ -314,7 +314,7 @@ public function startElement($parser, $name, $attributes) switch ($name) { case "parameter": $this->currBehavior->addParameter($attributes); - break; + break; default: $this->_throwInvalidTagException($parser, $name); @@ -323,7 +323,7 @@ public function startElement($parser, $name, $attributes) switch ($name) { case "rule": $this->currValidator->addRule($attributes); - break; + break; default: $this->_throwInvalidTagException($parser, $name); } @@ -332,11 +332,10 @@ public function startElement($parser, $name, $attributes) switch ($name) { case "parameter": $this->currVendorObject->addParameter($attributes); - break; + break; default: $this->_throwInvalidTagException($parser, $name); } - } else { // it must be an invalid tag $this->_throwInvalidTagException($parser, $name); @@ -363,9 +362,9 @@ public function _throwInvalidTagException($parser, $tag_name) * * @param uri * @param localName The local name (without prefix), or the empty string if - * Namespace processing is not being performed. + * Namespace processing is not being performed. * @param rawName The qualified name (with prefix), or the empty string if - * qualified names are not available. + * qualified names are not available. */ public function endElement($parser, $name) { diff --git a/generator/lib/builder/util/XmlToDataSQL.php b/generator/lib/builder/util/XmlToDataSQL.php index dd7270436..b03117557 100644 --- a/generator/lib/builder/util/XmlToDataSQL.php +++ b/generator/lib/builder/util/XmlToDataSQL.php @@ -108,6 +108,7 @@ public function __construct(Database $database, GeneratorConfig $config, $encodi * * @param PhingFile $xmlFile * @param Writer $out + * * @throws BuildException */ public function transform(PhingFile $xmlFile, Writer $out) @@ -160,7 +161,7 @@ public function startElement($name, $attributes) $columnValues = array(); foreach ($attributes as $name => $value) { $col = $table->getColumnByPhpName($name); - $columnValues[] = new ColumnValue($col, iconv('utf-8',$this->encoding, $value)); + $columnValues[] = new ColumnValue($col, iconv('utf-8', $this->encoding, $value)); } $data = new DataRow($table, $columnValues); @@ -180,9 +181,7 @@ public function startElement($name, $attributes) // Write the SQL $this->sqlWriter->write($this->currBuilder->buildRowSql($data)); - } - } catch (Exception $e) { // Exceptions have traditionally not bubbled up nicely from the expat parser, // so we also print the stack trace here. @@ -210,11 +209,11 @@ public function endElement($name) $this->sqlWriter->write(call_user_func(array($this->builderClazz, 'getDatabaseEndSql'))); } } - } // XmlToData /** * "inner class" + * * @package propel.generator.builder.util */ class DataRow @@ -241,6 +240,7 @@ public function getColumnValues() /** * "inner" class + * * @package propel.generator.builder.util */ class ColumnValue diff --git a/generator/lib/config/GeneratorConfig.php b/generator/lib/config/GeneratorConfig.php index b3517dcb6..bf2e6fe14 100644 --- a/generator/lib/config/GeneratorConfig.php +++ b/generator/lib/config/GeneratorConfig.php @@ -33,15 +33,19 @@ class GeneratorConfig implements GeneratorConfigInterface /** * Construct a new GeneratorConfig. + * * @param mixed $props Array or Iterator */ public function __construct($props = null) { - if ($props) $this->setBuildProperties($props); + if ($props) { + $this->setBuildProperties($props); + } } /** * Gets the build properties. + * * @return array */ public function getBuildProperties() @@ -67,7 +71,7 @@ public function setBuildProperties($props) $newKey = substr($key, strlen("propel.")); $j = strpos($newKey, '.'); while ($j !== false) { - $newKey = substr($newKey, 0, $j) . ucfirst(substr($newKey, $j + 1)); + $newKey = substr($newKey, 0, $j) . ucfirst(substr($newKey, $j + 1)); $j = strpos($newKey, '.'); } $this->setBuildProperty($newKey, $propValue); @@ -79,6 +83,7 @@ public function setBuildProperties($props) * Gets a specific propel (renamed) property from the build. * * @param string $name + * * @return mixed */ public function getBuildProperty($name) @@ -101,6 +106,7 @@ public function setBuildProperty($name, $value) * Resolves and returns the class name based on the specified property value. * * @param string $propname The name of the property that holds the class path (dot-path notation). + * * @return string The class name. * @throws BuildException If the classname cannot be determined or class cannot be loaded. */ @@ -115,7 +121,7 @@ public function getClassname($propname) // Basically, we want to turn ?.?.?.sqliteDataSQLBuilder into ?.?.?.SqliteDataSQLBuilder $lastdotpos = strrpos($classpath, '.'); if ($lastdotpos !== false) { - $classpath{$lastdotpos+1} = strtoupper($classpath{$lastdotpos+1}); + $classpath{$lastdotpos + 1} = strtoupper($classpath{$lastdotpos + 1}); } else { // Allows to configure full classname instead of a dot-path notation if (class_exists($classpath)) { @@ -137,6 +143,7 @@ public function getClassname($propname) * Resolves and returns the builder class name. * * @param string $type + * * @return string The class name. */ public function getBuilderClassname($type) @@ -150,6 +157,7 @@ public function getBuilderClassname($type) * Creates and configures a new Platform class. * * @param PDO $con + * * @return Platform * @throws BuildException */ @@ -183,7 +191,9 @@ public function getConfiguredPlatform(PDO $con = null, $database = null) /** * Creates and configures a new SchemaParser class for specified platform. + * * @param PDO $con + * * @return SchemaParser * @throws BuildException */ @@ -206,6 +216,7 @@ public function getConfiguredSchemaParser(PDO $con = null) * * @param Table $table * @param string $type The type of builder ('ddl', 'sql', etc.) + * * @return DataModelBuilder */ public function getConfiguredBuilder(Table $table, $type, $cache = true) @@ -234,6 +245,7 @@ public function getConfiguredPluralizer() * Gets a configured behavior class * * @param string $name a behavior name + * * @return string a behavior class name */ public function getConfiguredBehavior($name) @@ -257,7 +269,7 @@ public function setBuildConnections($buildConnections) public function getBuildConnections() { if (null === $this->buildConnections) { - $buildTimeConfigPath = $this->getBuildProperty('buildtimeConfFile') ? $this->getBuildProperty('projectDir') . DIRECTORY_SEPARATOR . $this->getBuildProperty('buildtimeConfFile') : null; + $buildTimeConfigPath = $this->getBuildProperty('buildtimeConfFile') ? $this->getBuildProperty('projectDir') . DIRECTORY_SEPARATOR . $this->getBuildProperty('buildtimeConfFile') : null; if ($buildTimeConfigString = $this->getBuildProperty('buildtimeConf')) { // configuration passed as propel.buildtimeConf string // probably using the command line, which doesn't accept whitespace diff --git a/generator/lib/config/GeneratorConfigInterface.php b/generator/lib/config/GeneratorConfigInterface.php index 7a2e8c06a..bc279b60b 100644 --- a/generator/lib/config/GeneratorConfigInterface.php +++ b/generator/lib/config/GeneratorConfigInterface.php @@ -5,7 +5,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * - * @license MIT License + * @license MIT License */ /** @@ -18,21 +18,23 @@ interface GeneratorConfigInterface * * @param Table $table * @param string $type The type of builder ('ddl', 'sql', etc.) + * * @return DataModelBuilder */ public function getConfiguredBuilder(Table $table, $type); /** - * Gets a configured Pluralizer class. - * - * @return Pluralizer - */ + * Gets a configured Pluralizer class. + * + * @return Pluralizer + */ public function getConfiguredPluralizer(); /** * Gets a specific propel (renamed) property from the build. * * @param string $name + * * @return mixed */ public function getBuildProperty($name); diff --git a/generator/lib/config/QuickGeneratorConfig.php b/generator/lib/config/QuickGeneratorConfig.php index e1708114e..498f697f4 100644 --- a/generator/lib/config/QuickGeneratorConfig.php +++ b/generator/lib/config/QuickGeneratorConfig.php @@ -5,7 +5,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * - * @license MIT License + * @license MIT License */ require_once dirname(__FILE__) . '/GeneratorConfig.php'; @@ -61,17 +61,19 @@ protected function parsePseudoIniFile($filepath) throw new Exception("Unable to parse contents of $filepath"); } foreach ($lines as $line) { - $line = trim($line); - if ($line == "" || $line{0} == '#' || $line{0} == ';') continue; - $pos = strpos($line, '='); - $property = trim(substr($line, 0, $pos)); - $value = trim(substr($line, $pos + 1)); - if ($value === "true") { - $value = true; - } elseif ($value === "false") { - $value = false; - } - $properties[$property] = $value; + $line = trim($line); + if ($line == "" || $line{0} == '#' || $line{0} == ';') { + continue; + } + $pos = strpos($line, '='); + $property = trim(substr($line, 0, $pos)); + $value = trim(substr($line, $pos + 1)); + if ($value === "true") { + $value = true; + } elseif ($value === "false") { + $value = false; + } + $properties[$property] = $value; } return $properties; @@ -82,6 +84,7 @@ protected function parsePseudoIniFile($filepath) * * @param Table $table * @param string $type The type of builder ('ddl', 'sql', etc.) + * * @return DataModelBuilder */ public function getConfiguredBuilder(Table $table, $type) @@ -95,10 +98,10 @@ public function getConfiguredBuilder(Table $table, $type) } /** - * Gets a configured Pluralizer class. - * - * @return Pluralizer - */ + * Gets a configured Pluralizer class. + * + * @return Pluralizer + */ public function getConfiguredPluralizer() { require_once dirname(__FILE__) . '/../builder/util/DefaultEnglishPluralizer.php'; @@ -124,7 +127,7 @@ public function setBuildProperties($props) $newKey = substr($key, strlen("propel.")); $j = strpos($newKey, '.'); while ($j !== false) { - $newKey = substr($newKey, 0, $j) . ucfirst(substr($newKey, $j + 1)); + $newKey = substr($newKey, 0, $j) . ucfirst(substr($newKey, $j + 1)); $j = strpos($newKey, '.'); } $this->setBuildProperty($newKey, $propValue); @@ -136,6 +139,7 @@ public function setBuildProperties($props) * Gets a specific propel (renamed) property from the build. * * @param string $name + * * @return mixed */ public function getBuildProperty($name) diff --git a/generator/lib/exception/EngineException.php b/generator/lib/exception/EngineException.php index cd9db8563..c98775d40 100644 --- a/generator/lib/exception/EngineException.php +++ b/generator/lib/exception/EngineException.php @@ -19,4 +19,6 @@ * @version $Revision$ * @package propel.generator.exception */ -class EngineException extends BuildException {} +class EngineException extends BuildException +{ +} diff --git a/generator/lib/exception/SchemaException.php b/generator/lib/exception/SchemaException.php index 1c8fd96b0..255084523 100644 --- a/generator/lib/exception/SchemaException.php +++ b/generator/lib/exception/SchemaException.php @@ -14,4 +14,6 @@ * @version $Revision$ * @package propel.generator.exception */ -class SchemaException extends Exception {} +class SchemaException extends Exception +{ +} diff --git a/generator/lib/model/AppData.php b/generator/lib/model/AppData.php index 0cd218bac..b6a99503a 100644 --- a/generator/lib/model/AppData.php +++ b/generator/lib/model/AppData.php @@ -26,18 +26,21 @@ class AppData /** * The list of databases for this application. - * @var array Database[] + * + * @var Database[] */ private $dbList = array(); /** * The platform class for our database(s). + * * @var string */ private $platform; /** * The generator configuration + * * @var GeneratorConfig */ protected $generatorConfig; @@ -50,6 +53,7 @@ class AppData /** * Flag to ensure that initialization is performed only once. + * * @var boolean */ private $isInitialized = false; @@ -79,7 +83,7 @@ public function setPlatform(PropelPlatformInterface $defaultPlatform) /** * Gets the platform object to use for any databases added to this application model. * - * @return Platform + * @return PropelPlatformInterface */ public function getPlatform() { @@ -109,7 +113,7 @@ public function getGeneratorConfig() /** * Set the name of the database. * - * @param $name of the database. + * @param string $name */ public function setName($name) { @@ -119,7 +123,7 @@ public function setName($name) /** * Get the name of the database. * - * @return String name + * @return string name */ public function getName() { @@ -129,7 +133,7 @@ public function getName() /** * Get the short name of the database (without the '-schema' postfix). * - * @return String name + * @return string name */ public function getShortName() { @@ -139,7 +143,7 @@ public function getShortName() /** * Return an array of all databases * - * @return Array of Database objects + * @return Database[] */ public function getDatabases($doFinalInit = true) { @@ -165,8 +169,10 @@ public function hasMultipleDatabases() /** * Return the database with the specified name. * - * @param name database name - * @return A Database object. If it does not exist it returns null + * @param string $name database name + * @param bool $doFinalInit + * + * @return Database|null */ public function getDatabase($name = null, $doFinalInit = true) { @@ -180,7 +186,7 @@ public function getDatabase($name = null, $doFinalInit = true) return $this->dbList[0]; } - for ($i=0,$size=count($this->dbList); $i < $size; $i++) { + for ($i = 0, $size = count($this->dbList); $i < $size; $i++) { $db = $this->dbList[$i]; if ($db->getName() === $name) { return $db; @@ -193,7 +199,8 @@ public function getDatabase($name = null, $doFinalInit = true) /** * Checks whether a database with the specified nam exists in this AppData * - * @param name database name + * @param string $name database name + * * @return boolean */ public function hasDatabase($name) @@ -238,13 +245,12 @@ public function addDatabase($db) return $this->addDatabase($d); // calls self w/ different param type } - } public function doFinalInitialization() { if (!$this->isInitialized) { - for ($i=0, $size=count($this->dbList); $i < $size; $i++) { + for ($i = 0, $size = count($this->dbList); $i < $size; $i++) { $this->dbList[$i]->doFinalInitialization(); } $this->isInitialized = true; @@ -254,7 +260,7 @@ public function doFinalInitialization() /** * Merge other appData objects into this object * - * @param array[AppData] $ads + * @param AppData[] $ads * * @throws Exception */ @@ -327,6 +333,7 @@ public function toString() /** * Magic string method + * * @see toString() */ public function __toString() diff --git a/generator/lib/model/Behavior.php b/generator/lib/model/Behavior.php index 05acac588..911d20e1e 100644 --- a/generator/lib/model/Behavior.php +++ b/generator/lib/model/Behavior.php @@ -94,7 +94,7 @@ public function getDatabase() * Add a parameter * Expects an associative array looking like array('name' => 'foo', 'value' => bar) * - * @param array associative array with name and value keys + * @param array $attribute */ public function addParameter($attribute) { @@ -106,7 +106,7 @@ public function addParameter($attribute) * Overrides the behavior parameters * Expects an associative array looking like array('foo' => 'bar') * - * @param array associative array + * @param array $parameters */ public function setParameters($parameters) { @@ -115,6 +115,7 @@ public function setParameters($parameters) /** * Get the associative array of parameters + * * @return array */ public function getParameters() @@ -240,6 +241,7 @@ protected function getDirname() * Useful for table behaviors * * @param string $param Name of the parameter storing the column name + * * @return ColumnMap The column of the table supporting the behavior */ public function getColumnForParameter($param) @@ -249,6 +251,7 @@ public function getColumnForParameter($param) /** * Sets up the Behavior object based on the attributes that were passed to loadFromXML(). + * * @see parent::loadFromXML() */ protected function setupObject() diff --git a/generator/lib/model/Column.php b/generator/lib/model/Column.php index 9c46871dc..8d054772e 100644 --- a/generator/lib/model/Column.php +++ b/generator/lib/model/Column.php @@ -48,18 +48,20 @@ class Column extends XMLElement /** * The name to use for the Peer constant that identifies this column. * (Will be converted to all-uppercase in the templates.) - * @var string + * + * @var string */ private $peerName; /** * Native PHP type (scalar or class name) - * @var string "string", "boolean", "int", "double" + * + * @var string "string", "boolean", "int", "double" */ private $phpType; /** - * @var Table + * @var Table */ private $parentTable; @@ -79,7 +81,7 @@ class Column extends XMLElement // only one type is supported currently, which assumes the // column either contains the classnames or a key to - // classnames specified in the schema. Others may be + // classnames specified in the schema. Others may be // supported later. private $inheritanceType; private $isInheritance; @@ -88,19 +90,23 @@ class Column extends XMLElement private $needsTransactionInPostgres; //maybe this can be retrieved from vendorSpecificInfo /** - * @var stores the possible values of an ENUM column + * Stores the possible values of an ENUM column. + * + * @var array */ protected $valueSet = array(); /** - * @var Domain The domain object associated with this Column. + * The domain object associated with this Column. + * + * @var Domain */ private $domain; /** * Creates a new column and set the name * - * @param $name column name + * @param string $name */ public function __construct($name = null) { @@ -110,8 +116,8 @@ public function __construct($name = null) /** * Return a comma delimited string listing the specified columns. * - * @param $columns Either a list of Column objects, or - * a list of String objects with column names. + * @param Column[]|string[] $columns Either a list of Column objects, or a list of string with column names. + * * @deprecated Use the Platform::getColumnListDDL() method instead * * @return string @@ -131,7 +137,8 @@ public static function makeList($columns, PropelPlatformInterface $platform) /** * Sets up the Column object based on the attributes that were passed to loadFromXML(). - * @see parent::loadFromXML() + * + * @see parent::loadFromXML() */ protected function setupObject() { @@ -254,9 +261,8 @@ protected function setupObject() } $this->inheritanceType = $this->getAttribute("inheritance"); - $this->isInheritance = ($this->inheritanceType !== null - && $this->inheritanceType !== "false"); // here we are only checking for 'false', so don't - // use booleanValue() + // here we are only checking for 'false', so don't use booleanValue() + $this->isInheritance = ($this->inheritanceType !== null && $this->inheritanceType !== "false"); $this->description = $this->getAttribute("description"); } catch (Exception $e) { @@ -266,6 +272,7 @@ protected function setupObject() /** * Gets domain for this column, creating a new empty domain object if none is set. + * * @return Domain */ public function getDomain() @@ -279,6 +286,7 @@ public function getDomain() /** * Sets domain for this column + * * @param Domain $domain */ public function setDomain(Domain $domain) @@ -337,7 +345,7 @@ public function getDescription() /** * Set the description for the Table * - * @param newDescription description for the Table + * @param newDescription description for the Table */ public function setDescription($newDescription) { @@ -348,6 +356,7 @@ public function setDescription($newDescription) * Get name to use in PHP sources. It will set & return * a self-generated phpName from it's name if it's * not already set. + * * @return string */ public function getPhpName() @@ -396,6 +405,7 @@ public function getStudlyPhpName() /** * Get the visibility of the accessors of this column / attribute + * * @return string */ public function getAccessorVisibility() @@ -409,7 +419,8 @@ public function getAccessorVisibility() /** * Set the visibility of the accessor methods for this column / attribute - * @param $newVisibility string + * + * @param $newVisibility string */ public function setAccessorVisibility($newVisibility) { @@ -418,11 +429,11 @@ public function setAccessorVisibility($newVisibility) } else { $this->accessorVisibility = self::DEFAULT_VISIBILITY; } - } /** * Get the visibility of the mutator of this column / attribute + * * @return string */ public function getMutatorVisibility() @@ -436,7 +447,8 @@ public function getMutatorVisibility() /** * Set the visibility of the mutator methods for this column / attribute - * @param $newVisibility string + * + * @param $newVisibility string */ public function setMutatorVisibility($newVisibility) { @@ -445,7 +457,6 @@ public function setMutatorVisibility($newVisibility) } else { $this->mutatorVisibility = self::DEFAULT_VISIBILITY; } - } /** @@ -458,7 +469,7 @@ public function getConstantName() $classname = $this->getTable()->getPhpName() . 'Peer'; $const = $this->getConstantColumnName(); - return $classname.'::'.$const; + return $classname . '::' . $const; } public function getConstantColumnName() @@ -473,6 +484,7 @@ public function getConstantColumnName() /** * Get the Peer constant name that will identify this column. + * * @return string */ public function getPeerName() @@ -482,7 +494,8 @@ public function getPeerName() /** * Set the Peer constant name that will identify this column. - * @param $name string + * + * @param $name string */ public function setPeerName($name) { @@ -495,7 +508,7 @@ public function setPeerName($name) * If no type has been specified, then uses results of getPhpNative(). * * @return string The type name. - * @see getPhpNative() + * @see getPhpNative() */ public function getPhpType() { @@ -508,6 +521,7 @@ public function getPhpType() /** * Get the location of this column within the table (one-based). + * * @return int value of position. */ public function getPosition() @@ -517,6 +531,7 @@ public function getPosition() /** * Get the location of this column within the table (one-based). + * * @param int $v Value to assign to position. */ public function setPosition($v) @@ -551,6 +566,7 @@ public function getTableName() /** * Adds a new inheritance definition to the inheritance list and set the * parent column of the inheritance to the current column + * * @param Inheritance|string $inhdata Inheritance or XML data. * * @return Inheritance @@ -629,6 +645,7 @@ public function getNotNullString() /** * Set whether the column is the primary string, * i.e. whether its value is the default string representation of the table + * * @param boolean $v */ public function setPrimaryString($v) @@ -647,6 +664,7 @@ public function isPrimaryString() /** * Set whether the column is a primary key or not. + * * @param boolean $v */ public function setPrimaryKey($v) @@ -736,6 +754,7 @@ public function setTreeScopeKey($tsk) /** * Return true if the column is a scope key of a tree + * * @return boolean */ public function isTreeScopeKey() @@ -745,6 +764,7 @@ public function isTreeScopeKey() /** * Set true if the column is UNIQUE + * * @param boolean $u */ public function setUnique($u) @@ -754,6 +774,7 @@ public function setUnique($u) /** * Get the UNIQUE property. + * * @return boolean */ public function isUnique() @@ -763,6 +784,7 @@ public function isUnique() /** * Return true if the column requires a transaction in Postgres + * * @return boolean */ public function requiresTransactionInPostgres() @@ -772,6 +794,7 @@ public function requiresTransactionInPostgres() /** * Utility method to determine if this column is a foreign key. + * * @return boolean */ public function isForeignKey() @@ -781,6 +804,7 @@ public function isForeignKey() /** * Whether this column is a part of more than one foreign key. + * * @return boolean */ public function hasMultipleFK() @@ -790,6 +814,7 @@ public function hasMultipleFK() /** * Get the foreign key objects for this column (if it is a foreign key or part of a foreign key) + * * @return array */ public function getForeignKeys() @@ -855,21 +880,24 @@ public function setDomainForType($propelType) /** * Sets the propel colunm type. + * * @param string $propelType - * @see Domain::setType() + * + * @see Domain::setType() */ public function setType($propelType) { $this->getDomain()->setType($propelType); - if ($propelType == PropelTypes::VARBINARY|| $propelType == PropelTypes::LONGVARBINARY || $propelType == PropelTypes::BLOB) { + if ($propelType == PropelTypes::VARBINARY || $propelType == PropelTypes::LONGVARBINARY || $propelType == PropelTypes::BLOB) { $this->needsTransactionInPostgres = true; } } /** * Returns the Propel column type as a string. + * * @return string The constant representing Propel type: e.g. "VARCHAR". - * @see Domain::getType() + * @see Domain::getType() */ public function getType() { @@ -878,6 +906,7 @@ public function getType() /** * Returns the column PDO type integer for this column's Propel type. + * * @return int The integer value representing PDO type param: e.g. PDO::PARAM_INT */ public function getPDOType() @@ -908,6 +937,7 @@ public function isDefaultSqlType(PropelPlatformInterface $platform = null) /** * Utility method to know whether column needs Blob/Lob handling. + * * @return boolean */ public function isLobType() @@ -925,6 +955,7 @@ public function isTextType() /** * Utility method to see if the column is numeric type. + * * @return boolean */ public function isNumericType() @@ -934,6 +965,7 @@ public function isNumericType() /** * Utility method to see if the column is boolean type. + * * @return boolean */ public function isBooleanType() @@ -943,6 +975,7 @@ public function isBooleanType() /** * Utility method to know whether column is a temporal column. + * * @return boolean */ public function isTemporalType() @@ -952,6 +985,7 @@ public function isTemporalType() /** * Utility method to know whether column is an array column. + * * @return boolean */ public function isPhpArrayType() @@ -961,6 +995,7 @@ public function isPhpArrayType() /** * Utility method to know whether column is an ENUM column. + * * @return boolean */ public function isEnumType() @@ -970,6 +1005,7 @@ public function isEnumType() /** * Sets the list of possible values for an ENUM column + * * @param array */ public function setValueSet($valueSet) @@ -979,6 +1015,7 @@ public function setValueSet($valueSet) /** * Returns the list of possible values for an ENUM column + * * @return array */ public function getValueSet() @@ -987,7 +1024,7 @@ public function getValueSet() } /** - * @see XMLElement::appendXml(DOMNode) + * @see XMLElement::appendXml(DOMNode) */ public function appendXml(DOMNode $node) { @@ -1064,6 +1101,7 @@ public function appendXml(DOMNode $node) /** * Returns the size of the column + * * @return string */ public function getSize() @@ -1073,6 +1111,7 @@ public function getSize() /** * Set the size of the column + * * @param string $newSize */ public function setSize($newSize) @@ -1082,6 +1121,7 @@ public function setSize($newSize) /** * Returns the scale of the column + * * @return string */ public function getScale() @@ -1091,6 +1131,7 @@ public function getScale() /** * Set the scale of the column + * * @param string $newScale */ public function setScale($newScale) @@ -1100,7 +1141,7 @@ public function setScale($newScale) /** * Return the size in brackets for use in an sql - * schema if the type is String. Otherwise return an empty string + * schema if the type is String. Otherwise return an empty string */ public function printSize() { @@ -1109,6 +1150,7 @@ public function printSize() /** * Return a string that will give this column a default value in SQL + * * @deprecated use Platform::getColumnDefaultValueDDL() instead * @return string */ @@ -1119,6 +1161,7 @@ public function getDefaultSetting() /** * Return a string that will give this column a default value in PHP + * * @return string */ public function getDefaultValueString() @@ -1160,8 +1203,9 @@ public function setDefaultValue($def) /** * Get the default value object for this column. + * * @return ColumnDefaultValue - * @see Domain::getDefaultValue() + * @see Domain::getDefaultValue() */ public function getDefaultValue() { @@ -1170,8 +1214,9 @@ public function getDefaultValue() /** * Get the default value suitable for use in PHP. + * * @return mixed - * @see Domain::getPhpDefaultValue() + * @see Domain::getPhpDefaultValue() */ public function getPhpDefaultValue() { @@ -1198,6 +1243,7 @@ public function isLazyLoad() /** * Gets the auto-increment string. + * * @return string * @throws EngineException */ @@ -1270,8 +1316,9 @@ public function getPhpNative() /** * Returns true if the column's PHP native type is an boolean, int, long, float, double, string. + * * @return boolean - * @see PropelTypes::isPhpPrimitiveType() + * @see PropelTypes::isPhpPrimitiveType() */ public function isPhpPrimitiveType() { @@ -1280,8 +1327,9 @@ public function isPhpPrimitiveType() /** * Return true if column's PHP native type is an boolean, int, long, float, double. + * * @return boolean - * @see PropelTypes::isPhpPrimitiveNumericType() + * @see PropelTypes::isPhpPrimitiveNumericType() */ public function isPhpPrimitiveNumericType() { @@ -1290,8 +1338,9 @@ public function isPhpPrimitiveNumericType() /** * Returns true if the column's PHP native type is a class name. + * * @return boolean - * @see PropelTypes::isPhpObjectType() + * @see PropelTypes::isPhpObjectType() */ public function isPhpObjectType() { @@ -1301,7 +1350,7 @@ public function isPhpObjectType() /** * Get the platform/adapter impl. * - * @return Platform + * @return PropelPlatformInterface */ public function getPlatform() { diff --git a/generator/lib/model/ColumnDefaultValue.php b/generator/lib/model/ColumnDefaultValue.php index 350b30e57..c7b4cfb67 100644 --- a/generator/lib/model/ColumnDefaultValue.php +++ b/generator/lib/model/ColumnDefaultValue.php @@ -91,6 +91,7 @@ public function setValue($value) * A method to compare if two Default values match * * @param ColumnDefaultValue $other The value to compare to + * * @return boolean Whether this object represents same default value as $other * @author Niklas Närhinen */ @@ -110,5 +111,4 @@ public function equals(ColumnDefaultValue $other) return false; // Can't help, they are different } - } diff --git a/generator/lib/model/ConstraintNameGenerator.php b/generator/lib/model/ConstraintNameGenerator.php index 1c63ae8f4..7a88ee816 100644 --- a/generator/lib/model/ConstraintNameGenerator.php +++ b/generator/lib/model/ConstraintNameGenerator.php @@ -37,7 +37,7 @@ class ConstraintNameGenerator implements NameGenerator */ public function generateName($inputs) { - + /* @var $db Database */ $db = $inputs[0]; $name = $inputs[1]; $namePostfix = $inputs[2]; @@ -47,12 +47,10 @@ public function generateName($inputs) $maxBodyLength = -1; try { $maxColumnNameLength = (int) $db->getPlatform()->getMaxColumnNameLength(); - $maxBodyLength = ($maxColumnNameLength - strlen($namePostfix) - - strlen($constraintNbr) - 2); + $maxBodyLength = ($maxColumnNameLength - strlen($namePostfix) - strlen($constraintNbr) - 2); if (self::DEBUG) { - print("maxColumnNameLength=" . $maxColumnNameLength - . " maxBodyLength=" . $maxBodyLength . "\n"); + print("maxColumnNameLength=" . $maxColumnNameLength . " maxBodyLength=" . $maxBodyLength . "\n"); } } catch (EngineException $e) { echo $e; @@ -64,8 +62,7 @@ public function generateName($inputs) $name = substr($name, 0, $maxBodyLength); } - $name .= self::STD_SEPARATOR_CHAR . $namePostfix - . self::STD_SEPARATOR_CHAR . $constraintNbr; + $name .= self::STD_SEPARATOR_CHAR . $namePostfix . self::STD_SEPARATOR_CHAR . $constraintNbr; return $name; } diff --git a/generator/lib/model/Database.php b/generator/lib/model/Database.php index 99a601ceb..cb8fab0ef 100644 --- a/generator/lib/model/Database.php +++ b/generator/lib/model/Database.php @@ -30,8 +30,12 @@ class Database extends ScopedElement { private $platform; + + /** + * @var Table[] + */ private $tableList = array(); - private $curColumn; + private $name; private $baseClass; @@ -39,10 +43,27 @@ class Database extends ScopedElement private $defaultIdMethod; private $defaultPhpNamingMethod; private $defaultTranslateMethod; + + /** + * @var AppData + */ private $dbParent; + + /** + * @var Table[] + */ private $tablesByName = array(); + + /** + * @var Table[] + */ private $tablesByLowercaseName = array(); + + /** + * @var Table[] + */ private $tablesByPhpName = array(); + private $heavyIndexing; protected $tablePrefix = ''; @@ -59,7 +80,7 @@ class Database extends ScopedElement /** * List of behaviors registered for this table * - * @var array + * @var Behavior[] */ protected $behaviors = array(); @@ -75,6 +96,7 @@ public function __construct($name = null) /** * Sets up the Database object based on the attributes that were passed to loadFromXML(). + * * @see parent::loadFromXML() */ protected function setupObject() @@ -129,7 +151,8 @@ public function setName($name) /** * Get the value of baseClass. - * @return value of baseClass. + * + * @return string */ public function getBaseClass() { @@ -138,7 +161,8 @@ public function getBaseClass() /** * Set the value of baseClass. - * @param $v Value to assign to baseClass. + * + * @param string $v Value to assign to baseClass. */ public function setBaseClass($v) { @@ -147,7 +171,8 @@ public function setBaseClass($v) /** * Get the value of basePeer. - * @return value of basePeer. + * + * @return string */ public function getBasePeer() { @@ -156,7 +181,8 @@ public function getBasePeer() /** * Set the value of basePeer. - * @param $v Value to assign to basePeer. + * + * @param string $v Value to assign to basePeer. */ public function setBasePeer($v) { @@ -165,7 +191,8 @@ public function setBasePeer($v) /** * Get the value of defaultIdMethod. - * @return value of defaultIdMethod. + * + * @return string */ public function getDefaultIdMethod() { @@ -174,7 +201,8 @@ public function getDefaultIdMethod() /** * Set the value of defaultIdMethod. - * @param $v Value to assign to defaultIdMethod. + * + * @param string $v Value to assign to defaultIdMethod. */ public function setDefaultIdMethod($v) { @@ -184,7 +212,8 @@ public function setDefaultIdMethod($v) /** * Get the value of defaultPHPNamingMethod which specifies the * method for converting schema names for table and column to PHP names. - * @return string The default naming conversion used by this database. + * + * @return string */ public function getDefaultPhpNamingMethod() { @@ -193,6 +222,7 @@ public function getDefaultPhpNamingMethod() /** * Set the value of defaultPHPNamingMethod. + * * @param string $v The default naming conversion for this database to use. */ public function setDefaultPhpNamingMethod($v) @@ -203,7 +233,8 @@ public function setDefaultPhpNamingMethod($v) /** * Get the value of defaultTranslateMethod which specifies the * method for translate validator error messages. - * @return string The default translate method. + * + * @return string */ public function getDefaultTranslateMethod() { @@ -232,6 +263,7 @@ public function getDefaultStringFormat() /** * Set the value of defaultTranslateMethod. + * * @param string $v The default translate method to use. */ public function setDefaultTranslateMethod($v) @@ -264,6 +296,7 @@ public function getHeavyIndexing() /** * Set the value of heavyIndexing. + * * @param boolean $v Value to assign to heavyIndexing. */ public function setHeavyIndexing($v) @@ -273,7 +306,8 @@ public function setHeavyIndexing($v) /** * Return the list of all tables - * @return array + * + * @return Table[] */ public function getTables() { @@ -282,6 +316,7 @@ public function getTables() /** * Return the number of tables in the database + * * @return integer */ public function countTables() @@ -298,6 +333,7 @@ public function countTables() /** * Return the list of all tables that have a SQL representation + * * @return array */ public function getTablesForSql() @@ -305,7 +341,7 @@ public function getTablesForSql() $tables = array(); foreach ($this->tableList as $table) { if (!$table->isSkipSql()) { - $tables []= $table; + $tables [] = $table; } } @@ -314,6 +350,7 @@ public function getTablesForSql() /** * Check whether the database has a table. + * * @param string $name the name of the table (e.g. 'my_table') * @param boolean $caseInsensitive Whether the check is case insensitive. False by default. * @@ -330,6 +367,7 @@ public function hasTable($name, $caseInsensitive = false) /** * Return the table with the specified name. + * * @param string $name The name of the table (e.g. 'my_table') * @param boolean $caseInsensitive Whether the check is case insensitive. False by default. * @@ -350,7 +388,9 @@ public function getTable($name, $caseInsensitive = false) /** * Check whether the database has a table. + * * @param string $phpName the PHP Name of the table (e.g. 'MyTable') + * * @return boolean */ public function hasTableByPhpName($phpName) @@ -360,7 +400,9 @@ public function hasTableByPhpName($phpName) /** * Return the table with the specified phpName. + * * @param string $phpName the PHP Name of the table (e.g. 'MyTable') + * * @return Table a Table object or null if it doesn't exist */ public function getTableByPhpName($phpName) @@ -424,6 +466,8 @@ public function setAppData(AppData $parent) /** * Get the parent of the table + * + * @return AppData */ public function getAppData() { @@ -432,6 +476,7 @@ public function getAppData() /** * Adds Domain object from tag. + * * @param Domain|string $data XML attributes (array) or Domain object. * * @return Domain @@ -441,7 +486,7 @@ public function addDomain($data) if ($data instanceof Domain) { $domain = $data; // alias $domain->setDatabase($this); - $this->domainMap[ $domain->getName() ] = $domain; + $this->domainMap[$domain->getName()] = $domain; return $domain; } else { @@ -455,6 +500,7 @@ public function addDomain($data) /** * Get already configured Domain object by name. + * * @return Domain */ public function getDomain($domainName) @@ -466,58 +512,61 @@ public function getDomain($domainName) return null; // just to be explicit } - public function getGeneratorConfig() - { - if ($this->getAppData()) { - return $this->getAppData()->getGeneratorConfig(); - } else { - return null; - } - } - - public function getBuildProperty($key) - { - if ($config = $this->getGeneratorConfig()) { - return $config->getBuildProperty($key); - } else { - return ''; - } - } - - /** - * Adds a new Behavior to the database - * @return Behavior A behavior instance - */ - public function addBehavior($bdata) - { - if ($bdata instanceof Behavior) { - $behavior = $bdata; - $behavior->setDatabase($this); - $this->behaviors[$behavior->getName()] = $behavior; - - return $behavior; - } else { - $class = $this->getConfiguredBehavior($bdata['name']); - $behavior = new $class(); - $behavior->loadFromXML($bdata); - - return $this->addBehavior($behavior); - } - } - - /** - * Get the database behaviors - * @return Array of Behavior objects - */ - public function getBehaviors() - { - return $this->behaviors; - } - - /** + public function getGeneratorConfig() + { + if ($this->getAppData()) { + return $this->getAppData()->getGeneratorConfig(); + } else { + return null; + } + } + + public function getBuildProperty($key) + { + if ($config = $this->getGeneratorConfig()) { + return $config->getBuildProperty($key); + } else { + return ''; + } + } + + /** + * Adds a new Behavior to the database + * + * @return Behavior A behavior instance + */ + public function addBehavior($bdata) + { + if ($bdata instanceof Behavior) { + $behavior = $bdata; + $behavior->setDatabase($this); + $this->behaviors[$behavior->getName()] = $behavior; + + return $behavior; + } else { + $class = $this->getConfiguredBehavior($bdata['name']); + $behavior = new $class(); + $behavior->loadFromXML($bdata); + + return $this->addBehavior($behavior); + } + } + + /** + * Get the database behaviors + * + * @return Array of Behavior objects + */ + public function getBehaviors() + { + return $this->behaviors; + } + + /** * check if the database has a behavior by name * * @param string $name the behavior name + * * @return boolean True if the behavior exists */ public function hasBehavior($name) @@ -525,25 +574,27 @@ public function hasBehavior($name) return array_key_exists($name, $this->behaviors); } - /** - * Get one database behavior by name - * @param string $name the behavior name - * @return Behavior a behavior object - */ - public function getBehavior($name) - { - return $this->behaviors[$name]; - } + /** + * Get one database behavior by name + * + * @param string $name the behavior name + * + * @return Behavior a behavior object + */ + public function getBehavior($name) + { + return $this->behaviors[$name]; + } - /** - * Get the table prefix for this database - * - * @return string the table prefix - */ - public function getTablePrefix() - { - return $this->tablePrefix; - } + /** + * Get the table prefix for this database + * + * @return string the table prefix + */ + public function getTablePrefix() + { + return $this->tablePrefix; + } /** * Get the next behavior on all tables, ordered by behavior priority, @@ -666,6 +717,5 @@ public function appendXml(DOMNode $node) foreach ($this->tableList as $table) { $table->appendXml($dbNode); } - } } diff --git a/generator/lib/model/Domain.php b/generator/lib/model/Domain.php index a1e82dae2..7d8353bcd 100644 --- a/generator/lib/model/Domain.php +++ b/generator/lib/model/Domain.php @@ -80,6 +80,7 @@ public function __construct($type = null, $sqlType = null, $size = null, $scale /** * Copy the values from current object into passed-in Domain. + * * @param Domain $domain Domain to copy values into. */ public function copy(Domain $domain) @@ -95,6 +96,7 @@ public function copy(Domain $domain) /** * Sets up the Domain object based on the attributes that were passed to loadFromXML(). + * * @see parent::loadFromXML() */ protected function setupObject() @@ -120,6 +122,7 @@ protected function setupObject() /** * Sets the owning database object (if this domain is being setup via XML). + * * @param Database $database */ public function setDatabase(Database $database) @@ -129,6 +132,7 @@ public function setDatabase(Database $database) /** * Gets the owning database object (if this domain was setup via XML). + * * @return Database */ public function getDatabase() @@ -254,6 +258,7 @@ public function replaceType($value) /** * Gets the default value object. + * * @return ColumnDefaultValue The default value object for this domain. */ public function getDefaultValue() @@ -263,6 +268,7 @@ public function getDefaultValue() /** * Gets the default value, type-casted for use in PHP OM. + * * @return mixed * @see getDefaultValue() * @throws EngineException @@ -326,6 +332,7 @@ public function setSqlType($sqlType) /** * Replaces the SQL type if the new value is not null. + * * @param string $sqlType The native SQL type to use for this domain. */ public function replaceSqlType($sqlType) @@ -388,5 +395,4 @@ public function appendXml(DOMNode $node) $domainNode->setAttribute('description', $this->description); } } - } diff --git a/generator/lib/model/ForeignKey.php b/generator/lib/model/ForeignKey.php index ea20840c2..7e9b4fcf0 100644 --- a/generator/lib/model/ForeignKey.php +++ b/generator/lib/model/ForeignKey.php @@ -31,8 +31,20 @@ class ForeignKey extends XMLElement protected $defaultJoin; protected $onUpdate = ''; protected $onDelete = ''; + + /** + * @var Table + */ protected $parentTable; + + /** + * @var Column[] + */ protected $localColumns = array(); + + /** + * @var Column[] + */ protected $foreignColumns = array(); /** @@ -43,25 +55,26 @@ class ForeignKey extends XMLElement protected $skipSql = false; // the uppercase equivalent of the onDelete/onUpdate values in the dtd - const NONE = ""; // No "ON [ DELETE | UPDATE]" behaviour specified. - const NOACTION = "NO ACTION"; - const CASCADE = "CASCADE"; + const NONE = ""; // No "ON [ DELETE | UPDATE]" behaviour specified. + const NOACTION = "NO ACTION"; + const CASCADE = "CASCADE"; const RESTRICT = "RESTRICT"; - const SETDEFAULT = "SET DEFAULT"; - const SETNULL = "SET NULL"; + const SETDEFAULT = "SET DEFAULT"; + const SETNULL = "SET NULL"; /** * Constructs a new ForeignKey object. * * @param string $name */ - public function __construct($name=null) + public function __construct($name = null) { $this->name = $name; } /** * Sets up the ForeignKey object based on the attributes that were passed to loadFromXML(). + * * @see parent::loadFromXML() */ protected function setupObject() @@ -87,12 +100,12 @@ protected function setupObject() */ public function normalizeFKey($attrib) { - if ($attrib === null || strtoupper($attrib) == "NONE") { + if ($attrib === null || strtoupper($attrib) == "NONE") { $attrib = self::NONE; } $attrib = strtoupper($attrib); if ($attrib == "SETNULL") { - $attrib = self::SETNULL; + $attrib = self::SETNULL; } return $attrib; @@ -116,6 +129,7 @@ public function hasOnDelete() /** * returns the onUpdate attribute + * * @return string */ public function getOnUpdate() @@ -125,6 +139,7 @@ public function getOnUpdate() /** * Returns the onDelete attribute + * * @return string */ public function getOnDelete() @@ -166,6 +181,7 @@ public function setName($name) /** * Gets the phpName for this foreign key (if any). + * * @return string */ public function getPhpName() @@ -175,6 +191,7 @@ public function getPhpName() /** * Sets a phpName to use for this foreign key. + * * @param string $name */ public function setPhpName($name) @@ -184,6 +201,7 @@ public function setPhpName($name) /** * Gets the refPhpName for this foreign key (if any). + * * @return string */ public function getRefPhpName() @@ -193,6 +211,7 @@ public function getRefPhpName() /** * Sets a refPhpName to use for this foreign key. + * * @param string $name */ public function setRefPhpName($name) @@ -202,6 +221,7 @@ public function setRefPhpName($name) /** * Gets the defaultJoin for this foreign key (if any). + * * @return string */ public function getDefaultJoin() @@ -211,6 +231,7 @@ public function getDefaultJoin() /** * Sets a defaultJoin to use for this foreign key. + * * @param string $name */ public function setDefaultJoin($defaultJoin) @@ -220,6 +241,7 @@ public function setDefaultJoin($defaultJoin) /** * Get the foreignTableName of the FK + * * @return string foreign table qualified name */ public function getForeignTableName() @@ -233,6 +255,7 @@ public function getForeignTableName() /** * Get the foreign table name without schema + * * @return string foreign table common name */ public function getForeignTableCommonName() @@ -250,6 +273,7 @@ public function setForeignTableCommonName($tableName) /** * Gets the resolved foreign Table model object. + * * @return Table */ public function getForeignTable() @@ -335,6 +359,7 @@ public function clearReferences() /** * Return a comma delimited string of local column names + * * @deprecated because Column::makeList() is deprecated; use the array-returning getLocalColumns() instead. */ public function getLocalColumnNames() @@ -344,6 +369,7 @@ public function getLocalColumnNames() /** * Return a comma delimited string of foreign column names + * * @deprecated because Column::makeList() is deprecated; use the array-returning getForeignColumns() instead. */ public function getForeignColumnNames() @@ -353,6 +379,7 @@ public function getForeignColumnNames() /** * Return an array of local column names. + * * @return array string[] */ public function getLocalColumns() @@ -362,6 +389,7 @@ public function getLocalColumns() /** * Return an array of local column objects. + * * @return array Column[] */ public function getLocalColumnObjects() @@ -369,7 +397,7 @@ public function getLocalColumnObjects() $columns = array(); $localTable = $this->getTable(); foreach ($this->localColumns as $columnName) { - $columns []= $localTable->getColumn($columnName); + $columns[] = $localTable->getColumn($columnName); } return $columns; @@ -377,6 +405,7 @@ public function getLocalColumnObjects() /** * Return a local column name. + * * @return string */ public function getLocalColumnName($index = 0) @@ -386,6 +415,7 @@ public function getLocalColumnName($index = 0) /** * Return a local column object. + * * @return Column */ public function getLocalColumn($index = 0) @@ -400,7 +430,7 @@ public function getLocalColumn($index = 0) public function getLocalForeignMapping() { $h = array(); - for ($i=0, $size=count($this->localColumns); $i < $size; $i++) { + for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) { $h[$this->localColumns[$i]] = $this->foreignColumns[$i]; } @@ -414,7 +444,7 @@ public function getLocalForeignMapping() public function getForeignLocalMapping() { $h = array(); - for ($i=0, $size=count($this->localColumns); $i < $size; $i++) { + for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) { $h[$this->foreignColumns[$i]] = $this->localColumns[$i]; } @@ -430,7 +460,7 @@ public function getColumnObjectsMapping() $mapping = array(); $localTable = $this->getTable(); $foreignTable = $this->getForeignTable(); - for ($i=0, $size=count($this->localColumns); $i < $size; $i++) { + for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) { $mapping[]= array( 'local' => $localTable->getColumn($this->localColumns[$i]), 'foreign' => $foreignTable->getColumn($this->foreignColumns[$i]), @@ -442,6 +472,7 @@ public function getColumnObjectsMapping() /** * Get the foreign column mapped to specified local column. + * * @return string Column name. */ public function getMappedForeignColumn($local) @@ -456,6 +487,7 @@ public function getMappedForeignColumn($local) /** * Get the local column mapped to specified foreign column. + * * @return string Column name. */ public function getMappedLocalColumn($foreign) @@ -470,6 +502,7 @@ public function getMappedLocalColumn($foreign) /** * Return an array of foreign column names. + * * @return array string[] */ public function getForeignColumns() @@ -479,6 +512,7 @@ public function getForeignColumns() /** * Return an array of foreign column objects. + * * @return array Column[] */ public function getForeignColumnObjects() @@ -486,7 +520,7 @@ public function getForeignColumnObjects() $columns = array(); $foreignTable = $this->getForeignTable(); foreach ($this->foreignColumns as $columnName) { - $columns []= $foreignTable->getColumn($columnName); + $columns[] = $foreignTable->getColumn($columnName); } return $columns; @@ -494,6 +528,7 @@ public function getForeignColumnObjects() /** * Return a foreign column name. + * * @return string */ public function getForeignColumnName($index = 0) @@ -503,6 +538,7 @@ public function getForeignColumnName($index = 0) /** * Return a foreign column object. + * * @return Column */ public function getForeignColumn($index = 0) @@ -541,13 +577,12 @@ public function isForeignPrimaryKey() $foreignPKCols[] = $fPKCol->getName(); } - $foreignCols = array (); + $foreignCols = array(); foreach ($this->getLocalColumns() as $colName) { $foreignCols[] = $foreignTable->getColumn($lfmap[$colName])->getName(); } - return ((count($foreignPKCols) === count($foreignCols)) && - !array_diff($foreignPKCols, $foreignCols)); + return ((count($foreignPKCols) === count($foreignCols)) && !array_diff($foreignPKCols, $foreignCols)); } /** @@ -588,15 +623,15 @@ public function getForeignPrimaryKeys() return $foreignCols; } - /** - * Whether this foreign key relies on more than one column binding - * - * @return Boolean - */ - public function isComposite() - { - return count($this->getLocalColumns()) > 1; - } + /** + * Whether this foreign key relies on more than one column binding + * + * @return Boolean + */ + public function isComposite() + { + return count($this->getLocalColumns()) > 1; + } /** * Whether this foreign key is also the primary key of the local table. @@ -614,8 +649,7 @@ public function isLocalPrimaryKey() $localPKCols[] = $lPKCol->getName(); } - return ((count($localPKCols) === count($localCols)) && - !array_diff($localPKCols, $localCols)); + return ((count($localPKCols) === count($localCols)) && !array_diff($localPKCols, $localCols)); } /** @@ -638,6 +672,7 @@ public function isAtLeastOneLocalPrimaryKey() /** * Set whether this foreign key should have its creation sql generated. + * * @param boolean $v Value to assign to skipSql. */ public function setSkipSql($v) @@ -647,6 +682,7 @@ public function setSkipSql($v) /** * Skip generating sql for this foreign key. + * * @return boolean Value of skipSql. */ public function isSkipSql() @@ -662,6 +698,7 @@ public function isSkipSql() * support it. * * @param ForeignKey $fk + * * @return boolean * @link http://propel.phpdb.org/trac/ticket/549 */ @@ -677,7 +714,7 @@ public function getInverseFK() foreach ($foreignTable->getForeignKeys() as $refFK) { $fkMap = $refFK->getLocalForeignMapping(); - if ( ($refFK->getTableName() == $this->getTableName()) && ($map == $fkMap) ) { // compares keys and values, but doesn't care about order, included check to make sure it's the same table (fixes #679) + if (($refFK->getTableName() == $this->getTableName()) && ($map == $fkMap)) { // compares keys and values, but doesn't care about order, included check to make sure it's the same table (fixes #679) return $refFK; } @@ -695,7 +732,7 @@ public function getOtherFks() $fks = array(); foreach ($this->getTable()->getForeignKeys() as $fk) { if ($fk !== $this) { - $fks[]= $fk; + $fks[] = $fk; } } @@ -737,7 +774,7 @@ public function appendXml(DOMNode $node) $fkNode->setAttribute('onUpdate', $this->getOnUpdate()); } - for ($i=0, $size=count($this->localColumns); $i < $size; $i++) { + for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) { $refNode = $fkNode->appendChild($doc->createElement('reference')); $refNode->setAttribute('local', $this->localColumns[$i]); $refNode->setAttribute('foreign', $this->foreignColumns[$i]); diff --git a/generator/lib/model/IDMethod.php b/generator/lib/model/IDMethod.php index b119bf9dd..e37015848 100644 --- a/generator/lib/model/IDMethod.php +++ b/generator/lib/model/IDMethod.php @@ -31,5 +31,4 @@ interface IDMethod * application). */ const NO_ID_METHOD = "none"; - } diff --git a/generator/lib/model/IdMethodParameter.php b/generator/lib/model/IdMethodParameter.php index 3ddaf6ac3..2dc82e076 100644 --- a/generator/lib/model/IdMethodParameter.php +++ b/generator/lib/model/IdMethodParameter.php @@ -24,10 +24,15 @@ class IdMethodParameter extends XMLElement private $name; private $value; + + /** + * @var Table + */ private $parentTable; - /** + /** * Sets up the IdMethodParameter object based on the attributes that were passed to loadFromXML(). + * * @see parent::loadFromXML() */ protected function setupObject() diff --git a/generator/lib/model/Index.php b/generator/lib/model/Index.php index 702469821..5a06c156c 100644 --- a/generator/lib/model/Index.php +++ b/generator/lib/model/Index.php @@ -26,12 +26,16 @@ class Index extends XMLElement const DEBUG = false; private $indexName; + + /** + * @var Table + */ private $parentTable; - /** @var array string[] */ + /** @var string[] */ private $indexColumns; - /** @var array */ + /** @var int[] */ private $indexColumnSizes = array(); /** @@ -39,7 +43,7 @@ class Index extends XMLElement * * @param string $name */ - public function __construct($name=null) + public function __construct($name = null) { $this->indexName = $name; } @@ -62,12 +66,12 @@ private function createName() $inputs[] = count($table->getIndices()) + 1; } - $this->indexName = NameFactory::generateName( - NameFactory::CONSTRAINT_GENERATOR, $inputs); + $this->indexName = NameFactory::generateName(NameFactory::CONSTRAINT_GENERATOR, $inputs); } /** * Sets up the Index object based on the attributes that were passed to loadFromXML(). + * * @see parent::loadFromXML() */ protected function setupObject() @@ -164,6 +168,7 @@ public function getTableName() /** * Adds a new column to an index. + * * @param mixed $data Column or attributes from XML. */ public function addColumn($data) @@ -200,7 +205,9 @@ public function setColumns(array $indexColumns) /** * Whether there is a size for the specified column. + * * @param string $name + * * @return boolean */ public function hasColumnSize($name) @@ -210,7 +217,9 @@ public function hasColumnSize($name) /** * Returns the size for the specified column, if given. + * * @param string $name + * * @return numeric The size or NULL */ public function getColumnSize($name) @@ -241,6 +250,7 @@ public function getIndexColumnList() /** * Return a comma delimited string of the columns which compose this index. + * * @deprecated because Column::makeList() is deprecated; use the array-returning getColumns() instead. */ public function getColumnList() @@ -288,6 +298,7 @@ public function hasColumnAtPosition($pos, $name, $size = null, $caseInsensitive /** * Check whether the index has columns. + * * @return boolean */ public function hasColumns() @@ -297,6 +308,7 @@ public function hasColumns() /** * Return the list of local columns. You should not edit this list. + * * @return array string[] */ public function getColumns() diff --git a/generator/lib/model/Inheritance.php b/generator/lib/model/Inheritance.php index 467e96945..37be5bb00 100644 --- a/generator/lib/model/Inheritance.php +++ b/generator/lib/model/Inheritance.php @@ -29,6 +29,7 @@ class Inheritance extends XMLElement /** * Sets up the Inheritance object based on the attributes that were passed to loadFromXML(). + * * @see parent::loadFromXML() */ protected function setupObject() @@ -41,6 +42,7 @@ protected function setupObject() /** * Get the value of key. + * * @return value of key. */ public function getKey() @@ -50,6 +52,7 @@ public function getKey() /** * Set the value of key. + * * @param $v Value to assign to key. */ public function setKey($v) @@ -59,7 +62,8 @@ public function setKey($v) /** * Get the value of parent. - * @return value of parent. + * + * @return Column */ public function getColumn() { @@ -68,16 +72,18 @@ public function getColumn() /** * Set the value of parent. - * @param $v Value to assign to parent. + * + * @param Column $v Value to assign to parent. */ - public function setColumn(Column $v) + public function setColumn(Column $v) { $this->parent = $v; } /** * Get the value of className. - * @return value of className. + * + * @return string */ public function getClassName() { @@ -86,7 +92,8 @@ public function getClassName() /** * Set the value of className. - * @param $v Value to assign to className. + * + * @param string $v */ public function setClassName($v) { @@ -95,7 +102,8 @@ public function setClassName($v) /** * Get the value of package. - * @return value of package. + * + * @return string */ public function getPackage() { @@ -104,7 +112,8 @@ public function getPackage() /** * Set the value of package. - * @param $v Value to assign to package. + * + * @param string $v */ public function setPackage($v) { @@ -113,7 +122,8 @@ public function setPackage($v) /** * Get the value of ancestor. - * @return value of ancestor. + * + * @return string */ public function getAncestor() { @@ -122,7 +132,8 @@ public function getAncestor() /** * Set the value of ancestor. - * @param $v Value to assign to ancestor. + * + * @param string $v */ public function setAncestor($v) { diff --git a/generator/lib/model/NameFactory.php b/generator/lib/model/NameFactory.php index b6d83d27d..b788a85b1 100644 --- a/generator/lib/model/NameFactory.php +++ b/generator/lib/model/NameFactory.php @@ -48,7 +48,7 @@ class NameFactory /** * Factory method which retrieves an instance of the named generator. * - * @param $name The fully qualified class name of the name + * @param string $name The fully qualified class name of the name * generation algorithm to retrieve. */ protected static function getAlgorithm($name) @@ -67,7 +67,8 @@ protected static function getAlgorithm($name) * @param string $algorithmName The fully qualified class name of the {@link NameGenerator} * implementation to use to generate names. * @param array $inputs Inputs used to generate a name. - * @return The generated name. + * + * @return string The generated name. * @throws EngineException */ public static function generateName($algorithmName, $inputs) diff --git a/generator/lib/model/NameGenerator.php b/generator/lib/model/NameGenerator.php index 5218fed70..5c67066ac 100644 --- a/generator/lib/model/NameGenerator.php +++ b/generator/lib/model/NameGenerator.php @@ -65,8 +65,9 @@ interface NameGenerator * Given a list of String objects, implements an * algorithm which produces a name. * - * @param inputs Inputs used to generate a name. - * @return The generated name. + * @param string[] $inputs Inputs used to generate a name. + * + * @return string The generated name. * @throws EngineException */ public function generateName($inputs); diff --git a/generator/lib/model/PhpNameGenerator.php b/generator/lib/model/PhpNameGenerator.php index 0343a100c..d0673a72b 100644 --- a/generator/lib/model/PhpNameGenerator.php +++ b/generator/lib/model/PhpNameGenerator.php @@ -38,10 +38,12 @@ class PhpNameGenerator implements NameGenerator * works the same as the CONV_METHOD_PHPNAME method * but will not lowercase any characters. * - * @param $inputs list expected to contain two (optional: three) parameters, + * @param array $inputs list expected to contain two (optional: three) parameters, * element 0 contains name to convert, element 1 contains method for conversion, * optional element 2 contains prefix to be striped from name - * @return The generated name. + * + * @return string The generated name. + * * @see NameGenerator */ public function generateName($inputs) @@ -49,7 +51,7 @@ public function generateName($inputs) $schemaName = $inputs[0]; $method = $inputs[1]; - if (count($inputs)>2) { + if (count($inputs) > 2) { $prefix = $inputs[2]; if ($prefix != '' && substr($schemaName, 0, strlen($prefix)) == $prefix) { $schemaName = substr($schemaName, strlen($prefix)); @@ -87,7 +89,9 @@ public function generateName($inputs) * my_CLASS_name -> MyClassName * * @param string $schemaName name to be converted. + * * @return string Converted name. + * * @see NameGenerator * @see #underscoreMethod() */ @@ -112,7 +116,9 @@ protected function underscoreMethod($schemaName) * T$NAMA$RFO_max => TNamaRfoMax * * @param string $schemaName name to be converted. + * * @return string Converted name. + * * @see NameGenerator * @see #underscoreMethod() */ @@ -140,7 +146,9 @@ protected function cleanMethod($schemaName) * my_CLASS_name -> MyCLASSName * * @param string $schemaName name to be converted. + * * @return string Converted name. + * * @see NameGenerator * @see #underscoreMethod(String) */ @@ -161,6 +169,7 @@ protected function phpnameMethod($schemaName) * case no conversion is made. * * @param string $name name to be converted. + * * @return string The name parameter, unchanged. */ protected function nochangeMethod($name) diff --git a/generator/lib/model/PropelTypes.php b/generator/lib/model/PropelTypes.php index 1b219064e..5c127a59c 100644 --- a/generator/lib/model/PropelTypes.php +++ b/generator/lib/model/PropelTypes.php @@ -224,7 +224,7 @@ class PropelTypes * Return native PHP type which corresponds to the * Creole type provided. Use in the base object class generation. * - * @param $propelType The Propel type name. + * @param string $propelType The Propel type name. * @return string Name of the native PHP type */ public static function getPhpNative($propelType) @@ -235,16 +235,18 @@ public static function getPhpNative($propelType) /** * Returns the correct Creole type _name_ for propel added types * - * @param $type the propel added type. + * @param string $type the propel added type. + * * @return string Name of the the correct Creole type (e.g. "VARCHAR"). */ public static function getCreoleType($type) { - return self::$propelTypeToCreoleTypeMap[$type]; + return self::$propelTypeToCreoleTypeMap[$type]; } /** * Returns the PDO type (PDO::PARAM_* constant) value. + * * @return int */ public static function getPDOType($type) @@ -254,6 +256,7 @@ public static function getPDOType($type) /** * Returns the PDO type ('PDO::PARAM_*' constant) name. + * * @return string */ public static function getPdoTypeString($type) @@ -266,6 +269,7 @@ public static function getPdoTypeString($type) * Used but Propel Creole task. * * @param int $sqlType The Creole SQL type constant. + * * @return string The Propel type to use or NULL if none found. */ public static function getPropelType($sqlType) @@ -278,7 +282,7 @@ public static function getPropelType($sqlType) /** * Get array of Propel types. * - * @return array string[] + * @return string[] */ public static function getPropelTypes() { @@ -289,6 +293,7 @@ public static function getPropelTypes() * Whether passed type is a temporal (date/time/timestamp) type. * * @param string $type Propel type + * * @return boolean */ public static function isTemporalType($type) @@ -300,6 +305,7 @@ public static function isTemporalType($type) * Returns true if values for the type need to be quoted. * * @param string $type The Propel type to check. + * * @return boolean True if values for the type need to be quoted. */ public static function isTextType($type) @@ -311,6 +317,7 @@ public static function isTextType($type) * Returns true if values for the type are numeric. * * @param string $type The Propel type to check. + * * @return boolean True if values for the type need to be quoted. */ public static function isNumericType($type) @@ -322,6 +329,7 @@ public static function isNumericType($type) * Returns true if values for the type are boolean. * * @param string $type The Propel type to check. + * * @return boolean True if values for the type need to be quoted. */ public static function isBooleanType($type) @@ -331,7 +339,9 @@ public static function isBooleanType($type) /** * Returns true if type is a LOB type (i.e. would be handled by Blob/Clob class). + * * @param string $type Propel type to check. + * * @return boolean */ public static function isLobType($type) @@ -343,6 +353,7 @@ public static function isLobType($type) * Convenience method to indicate whether a passed-in PHP type is a primitive. * * @param string $phpType The PHP type to check + * * @return boolean Whether the PHP type is a primitive (string, int, boolean, float) */ public static function isPhpPrimitiveType($phpType) @@ -354,6 +365,7 @@ public static function isPhpPrimitiveType($phpType) * Convenience method to indicate whether a passed-in PHP type is a numeric primitive. * * @param string $phpType The PHP type to check + * * @return boolean Whether the PHP type is a primitive (string, int, boolean, float) */ public static function isPhpPrimitiveNumericType($phpType) @@ -365,6 +377,7 @@ public static function isPhpPrimitiveNumericType($phpType) * Convenience method to indicate whether a passed-in PHP type is an object. * * @param string $phpType The PHP type to check + * * @return boolean */ public static function isPhpObjectType($phpType) @@ -376,6 +389,7 @@ public static function isPhpObjectType($phpType) * Convenience method to indicate whether a passed-in PHP type is an array. * * @param string $phpType The PHP type to check + * * @return boolean */ public static function isPhpArrayType($phpType) diff --git a/generator/lib/model/Rule.php b/generator/lib/model/Rule.php index 87cb1ec26..1b5f22c5c 100644 --- a/generator/lib/model/Rule.php +++ b/generator/lib/model/Rule.php @@ -29,6 +29,7 @@ class Rule extends XMLElement /** * Sets up the Rule object based on the attributes that were passed to loadFromXML(). + * * @see parent::loadFromXML() */ protected function setupObject() @@ -61,7 +62,9 @@ protected function setupObject() /** * Sets the owning validator for this rule. + * * @param Validator $validator + * * @see Validator::addRule() */ public function setValidator(Validator $validator) @@ -71,6 +74,7 @@ public function setValidator(Validator $validator) /** * Gets the owning validator for this rule. + * * @return Validator */ public function getValidator() @@ -82,6 +86,7 @@ public function getValidator() * Sets the dot-path name of class to use for rule. * If no class is specified in XML, then a classname will * be built based on the 'name' attrib. + * * @param string $classname dot-path classname (e.g. myapp.propel.MyValidator) */ public function setClass($classname) @@ -93,6 +98,7 @@ public function setClass($classname) * Gets the dot-path name of class to use for rule. * If no class was specified, this method will build a default classname * based on the 'name' attribute. E.g. 'maxLength' -> 'propel.validator.MaxLengthValidator' + * * @return string dot-path classname (e.g. myapp.propel.MyValidator) */ public function getClass() @@ -107,7 +113,9 @@ public function getClass() /** * Sets the name of the validator for this rule. * This name is used to build the classname if none was specified. + * * @param string $name Validator name for this rule (e.g. "maxLength", "required"). + * * @see getClass() */ public function setName($name) @@ -117,6 +125,7 @@ public function setName($name) /** * Gets the name of the validator for this rule. + * * @return string Validator name for this rule (e.g. "maxLength", "required"). */ public function getName() @@ -128,6 +137,7 @@ public function getName() * Sets the value parameter for this validator rule. * Note: not all validators need a value parameter (e.g. 'required' validator * does not). + * * @param string $value */ public function setValue($value) @@ -137,6 +147,7 @@ public function setValue($value) /** * Gets the value parameter for this validator rule. + * * @return string */ public function getValue() @@ -149,7 +160,9 @@ public function getValue() * This message may be a Gettext msgid (if translation="gettext") or some other * id for an alternative not-yet-supported translation system. It may also * be a simple, single-language string. + * * @param string $message + * * @see setTranslation() */ public function setMessage($message) @@ -162,6 +175,7 @@ public function setMessage($message) * This message may be a Gettext msgid (if translation="gettext") or some other * id for an alternative not-yet-supported translation system. It may also * be a simple, single-language string. + * * @return string * @see setTranslation() */ @@ -192,5 +206,4 @@ public function appendXml(DOMNode $node) $ruleNode->setAttribute('message', $this->getMessage()); } - } diff --git a/generator/lib/model/ScopedElement.php b/generator/lib/model/ScopedElement.php index fb20a4a7e..bca8cb542 100644 --- a/generator/lib/model/ScopedElement.php +++ b/generator/lib/model/ScopedElement.php @@ -49,12 +49,13 @@ abstract class ScopedElement extends XMLElement /** * retrieves a build property. * - * @param unknown_type $name + * @param mixed $name */ abstract protected function getBuildProperty($name); /** * Sets up the Rule object based on the attributes that were passed to loadFromXML(). + * * @see parent::loadFromXML() */ protected function setupObject() @@ -66,6 +67,7 @@ protected function setupObject() /** * Get the value of the namespace. + * * @return value of namespace. */ public function getNamespace() @@ -75,6 +77,7 @@ public function getNamespace() /** * Set the value of the namespace. + * * @param $v Value to assign to namespace. */ public function setNamespace($v) @@ -91,6 +94,7 @@ public function setNamespace($v) /** * Get the value of package. + * * @return value of package. */ public function getPackage() @@ -100,6 +104,7 @@ public function getPackage() /** * Set the value of package. + * * @param $v Value to assign to package. */ public function setPackage($v) @@ -113,6 +118,7 @@ public function setPackage($v) /** * Get the value of schema. + * * @return value of schema. */ public function getSchema() @@ -122,6 +128,7 @@ public function getSchema() /** * Set the value of schema. + * * @param $v Value to assign to schema. */ public function setSchema($v) diff --git a/generator/lib/model/Table.php b/generator/lib/model/Table.php index 20c5b36c5..94057f3a5 100644 --- a/generator/lib/model/Table.php +++ b/generator/lib/model/Table.php @@ -43,203 +43,203 @@ class Table extends ScopedElement implements IDMethod /** * Columns for this table. * - * @var array Column[] + * @var Column[] */ private $columnList = array(); /** * Validators for this table. * - * @var array Validator[] + * @var Validator[] */ private $validatorList = array(); /** * Foreign keys for this table. * - * @var array ForeignKey[] + * @var ForeignKey[] */ private $foreignKeys = array(); /** * Indexes for this table. * - * @var array Index[] + * @var Index[] */ private $indices = array(); /** * Unique indexes for this table. * - * @var array Unique[] + * @var Unique[] */ private $unices = array(); /** * Any parameters for the ID method (currently supports changing sequence name). * - * @var array + * @var array */ private $idMethodParameters = array(); /** * Table name (with prefix if it has one). * - * @var string + * @var string */ private $commonName; /** * Table name without prefix. Only used for phpName generation. * - * @var string + * @var string */ private $nonPrefixedName; /** * Table description. * - * @var string + * @var string */ private $description; /** * phpName for the table. * - * @var string + * @var string */ private $phpName; /** * ID method for the table (e.g. IDMethod::NATIVE, IDMethod::NONE). * - * @var string + * @var string */ private $idMethod; /** * Whether an INSERT with set PK is allowed on tables with IDMethod::NATIVE * - * @var boolean + * @var boolean */ private $allowPkInsert; /** * Strategy to use for converting column name to phpName. * - * @var string + * @var string */ private $phpNamingMethod; /** * The Database that this table belongs to. * - * @var Database + * @var Database */ private $database; /** * Foreign Keys that refer to this table. * - * @var array ForeignKey[] + * @var ForeignKey[] */ private $referrers = array(); /** * Names of foreign tables. * - * @var array string[] + * @var string[] */ private $foreignTableNames; /** * Whether this table contains a foreign primary key. * - * @var boolean + * @var boolean */ private $containsForeignPK; /** * The inheritance column for this table (if any). * - * @var Column + * @var Column */ private $inheritanceColumn; /** * Whether to skip generation of SQL for this table. * - * @var boolean + * @var boolean */ private $skipSql; /** * Whether this table is "read-only". * - * @var boolean + * @var boolean */ private $readOnly; /** * Whether this table should result in abstract OM classes. * - * @var boolean + * @var boolean */ private $abstractValue; /** * Whether this table is an alias for another table. * - * @var string + * @var string */ private $alias; /** * The interface that the generated "object" class should implement. * - * @var string + * @var string */ private $interface; /** * The base class to extend for the generated "object" class. * - * @var string + * @var string */ private $baseClass; /** * The base peer class to extend for generated "peer" class. * - * @var string + * @var string */ private $basePeer; /** * Map of columns by name. * - * @var array + * @var Column[] */ private $columnsByName = array(); /** * Map of columns by lowercase name. * - * @var array + * @var Column[] */ private $columnsByLowercaseName = array(); /** * Map of columns by phpName. * - * @var array + * @var Column[] */ private $columnsByPhpName = array(); /** * Whether this table needs to use transactions in Postgres. * - * @var string + * @var string * @deprecated */ private $needsTransactionInPostgres; @@ -247,49 +247,49 @@ class Table extends ScopedElement implements IDMethod /** * Whether to perform additional indexing on this table. * - * @var boolean + * @var boolean */ private $heavyIndexing; /** * Whether this table is for reference only. * - * @var boolean + * @var boolean */ private $forReferenceOnly; /** * The tree mode (nested set, etc.) implemented by this table. * - * @var string + * @var string */ private $treeMode; /** * Whether to reload the rows in this table after insert. * - * @var boolean + * @var boolean */ private $reloadOnInsert; /** * Whether to reload the rows in this table after update. * - * @var boolean + * @var boolean */ private $reloadOnUpdate; /** * List of behaviors registered for this table * - * @var array + * @var Behavior[] */ protected $behaviors = array(); /** * Whether this table is a cross-reference table for a many-to-many relationship * - * @var boolean + * @var boolean */ protected $isCrossRef = false; @@ -297,7 +297,7 @@ class Table extends ScopedElement implements IDMethod * The default string format for objects based on this table * (e.g. 'XML', 'YAML', 'CSV', 'JSON') * - * @var string + * @var string */ protected $defaultStringFormat; @@ -315,6 +315,7 @@ public function __construct($name = null) /** * get a qualified name of this table with scheme and common name separated by '_' * if schemaAutoPrefix is set. Otherwise get the common name. + * * @return string */ private function getStdSeparatedName() @@ -328,6 +329,7 @@ private function getStdSeparatedName() /** * Sets up the Rule object based on the attributes that were passed to loadFromXML(). + * * @see parent::loadFromXML() */ public function setupObject() @@ -352,9 +354,7 @@ public function setupObject() $this->basePeer = $this->getAttribute("basePeer"); $this->alias = $this->getAttribute("alias"); - $this->heavyIndexing = ( $this->booleanValue($this->getAttribute("heavyIndexing")) - || ("false" !== $this->getAttribute("heavyIndexing") - && $this->getDatabase()->isHeavyIndexing() ) ); + $this->heavyIndexing = ($this->booleanValue($this->getAttribute("heavyIndexing")) || ("false" !== $this->getAttribute("heavyIndexing") && $this->getDatabase()->isHeavyIndexing())); $this->description = $this->getAttribute("description"); $this->interface = $this->getAttribute("interface"); // sic ('interface' is reserved word) $this->treeMode = $this->getAttribute("treeMode"); @@ -369,6 +369,7 @@ public function setupObject() * get a build property for the database this table belongs to * * @param string $key key of the build property + * * @return string value of the property */ public function getBuildProperty($key) @@ -426,11 +427,11 @@ public function doFinalInitialization() * Adds extra indices for multi-part primary key columns. * * For databases like MySQL, values in a where clause much - * match key part order from the left to right. So, in the key + * match key part order from the left to right. So, in the key * definition PRIMARY KEY (FOO_ID, BAR_ID), * FOO_ID must be the first element used in * the where clause of the SQL query used against - * this table for the primary key index to be used. This feature + * this table for the primary key index to be used. This feature * could cause problems under MySQL with heavily indexed tables, * as MySQL currently only supports 16 indices per table (i.e. it * might cause too many indices to be created). @@ -442,7 +443,7 @@ public function doFinalInitialization() private function doHeavyIndexing() { if (self::DEBUG) { - print("doHeavyIndex() called on table " . $this->getName()."\n"); + print("doHeavyIndex() called on table " . $this->getName() . "\n"); } $pk = $this->getPrimaryKey(); @@ -451,7 +452,7 @@ private function doHeavyIndexing() // We start at an offset of 1 because the entire column // list is generally implicitly indexed by the fact that // it's a primary key. - for ($i=1; $i < $size; $i++) { + for ($i = 1; $i < $size; $i++) { $idx = new Index(); $idx->setColumns(array_slice($pk, $i, $size)); $this->addIndex($idx); @@ -472,6 +473,7 @@ public function addExtraIndices() * it to determine which additional indexes must be created for foreign * keys. It could also be used to detect duplicate indexes, but this is not * implemented yet. + * * @var array */ $_indices = array(); @@ -519,7 +521,7 @@ public function addExtraIndices() // no matching index defined in the schema, so we have to create one. // MySQL needs indices on any columns that serve as foreign keys. these are not auto-created prior to 4.1.2 - $name = substr_replace($foreignKey->getName(), 'FI_', strrpos($foreignKey->getName(), 'FK_'), 3); + $name = substr_replace($foreignKey->getName(), 'FI_', strrpos($foreignKey->getName(), 'FK_'), 3); if ($this->hasIndex($name)) { //if we have already a index with this name, then it looks like the columns of this index has just //been changed, so remove it and inject it again. This is the case if a referenced table is handled @@ -551,6 +553,7 @@ protected function collectIndexedColumns($indexName, $columns, &$collectedIndexe * index can be used by the optimizer to find rows. For example, if you * have a three-column index on (col1, col2, col3), you have indexed search * capabilities on (col1), (col1, col2), and (col1, col2, col3)." + * * @link http://dev.mysql.com/doc/refman/5.5/en/mysql-indexes.html */ $indexedColumns = array(); @@ -568,8 +571,10 @@ protected function collectIndexedColumns($indexName, $columns, &$collectedIndexe * Creates a delimiter-delimited string list of column names * * @see Platform::getColumnList() if quoting is required + * * @param array Column[] or string[] * @param string $delim The delimiter to use in separating the column names. + * * @return string */ public function getColumnList($columns, $delim = ',') @@ -586,14 +591,14 @@ public function getColumnList($columns, $delim = ',') } /** - * Names composing objects which haven't yet been named. This + * Names composing objects which haven't yet been named. This * currently consists of foreign-key and index entities. */ public function doNaming() { // Assure names are unique across all databases. try { - for ($i=0, $size = count($this->foreignKeys); $i < $size; $i++) { + for ($i = 0, $size = count($this->foreignKeys); $i < $size; $i++) { $fk = $this->foreignKeys[$i]; $name = $fk->getName(); if (empty($name)) { @@ -619,7 +624,6 @@ public function doNaming() $index->setName($name); } } - // NOTE: Most RDBMSes can apparently name unique column // constraints/indices themselves (using MySQL and Oracle // as test cases), so we'll assume that we needn't add an @@ -635,6 +639,7 @@ public function doNaming() * * @param nameType constraint type * @param nbr unique number for this constraint type + * * @return unique name for constraint * @throws EngineException */ @@ -667,7 +672,8 @@ public function getBaseClass() /** * Set the value of baseClass. - * @param v Value to assign to baseClass. + * + * @param v Value to assign to baseClass. */ public function setBaseClass($v) { @@ -676,6 +682,7 @@ public function setBaseClass($v) /** * Get the value of basePeer. + * * @return value of basePeer. */ public function getBasePeer() @@ -691,7 +698,8 @@ public function getBasePeer() /** * Set the value of basePeer. - * @param v Value to assign to basePeer. + * + * @param v Value to assign to basePeer. */ public function setBasePeer($v) { @@ -703,6 +711,7 @@ public function setBasePeer($v) * table. * * @param Column|string $coldata xml attributes or Column class for the column to add + * * @return Column the added column * @throws EngineException */ @@ -739,7 +748,9 @@ public function addColumn($data) /** * Removed a column from the table + * * @param Column|string $col the column to remove + * * @throws EngineException */ public function removeColumn($col) @@ -763,7 +774,7 @@ public function adjustColumnPositions() { $this->columnList = array_values($this->columnList); $columnCount = $this->getNumColumns(); - for ($i=0; $i < $columnCount; $i++) { + for ($i = 0; $i < $columnCount; $i++) { $this->columnList[$i]->setPosition($i + 1); } } @@ -776,6 +787,7 @@ public function adjustColumnPositions() * - addValidator(array $attribs) * * @param mixed $data Validator object or XML attribs (array) from element. + * * @return Validator The added Validator. * @throws EngineException */ @@ -785,8 +797,7 @@ public function addValidator($data) $validator = $data; $col = $this->getColumn($validator->getColumnName()); if ($col == null) { - throw new EngineException("Failed adding validator to table '" . $this->getName() . - "': column '" . $validator->getColumnName() . "' does not exist !"); + throw new EngineException("Failed adding validator to table '" . $this->getName() . "': column '" . $validator->getColumnName() . "' does not exist !"); } $validator->setColumn($col); $validator->setTable($this); @@ -805,7 +816,7 @@ public function addValidator($data) /** * Removes validators based on a column name * - * @param string the name of the column bearing a validator + * @param string $columnName The name of the column bearing a validator. */ public function removeValidatorForColumn($columnName) { @@ -847,6 +858,7 @@ public function addForeignKey($fkdata) /** * Gets the column that subclasses of the class representing this * table can be produced from. + * * @return Column */ public function getChildrenColumn() @@ -856,17 +868,17 @@ public function getChildrenColumn() /** * Get the subclasses that can be created from this table. + * * @return array string[] Class names */ public function getChildrenNames() { - if ($this->inheritanceColumn === null - || !$this->inheritanceColumn->isEnumeratedClasses()) { - return null; - } + if ($this->inheritanceColumn === null || !$this->inheritanceColumn->isEnumeratedClasses()) { + return null; + } $children = $this->inheritanceColumn->getChildren(); $names = array(); - for ($i = 0, $size=count($children); $i < $size; $i++) { + for ($i = 0, $size = count($children); $i < $size; $i++) { $names[] = get_class($children[$i]); } @@ -906,7 +918,7 @@ public function setupReferrers($throwErrors = false) $foreignTable = $this->getDatabase()->getTable($foreignKey->getForeignTableName()); if ($foreignTable !== null) { $referrers = $foreignTable->getReferrers(); - if ($referrers === null || !in_array($foreignKey, $referrers, true) ) { + if ($referrers === null || !in_array($foreignKey, $referrers, true)) { $foreignTable->addReferrer($foreignKey); } } elseif ($throwErrors) { @@ -973,7 +985,7 @@ public function getCrossFks() foreach ($this->getReferrers() as $refFK) { if ($refFK->getTable()->getIsCrossRef()) { foreach ($refFK->getOtherFks() as $crossFK) { - $crossFks[]= array($refFK, $crossFK); + $crossFks[] = array($refFK, $crossFK); } } } @@ -1062,6 +1074,7 @@ public function removeIndex($name) * check if the table has a index by name * * @param string $name + * * @return bool */ public function hasIndex($name) @@ -1129,6 +1142,7 @@ public function getGeneratorConfig() /** * Adds a new Behavior to the table + * * @return Behavior A behavior instance */ public function addBehavior($bdata) @@ -1150,7 +1164,8 @@ public function addBehavior($bdata) /** * Get the table behaviors - * @return Array of Behavior objects + * + * @return Behavior[] */ public function getBehaviors() { @@ -1159,7 +1174,8 @@ public function getBehaviors() /** * Get the early table behaviors - * @return Array of Behavior objects + * + * @return Behavior[] */ public function getEarlyBehaviors() { @@ -1177,6 +1193,7 @@ public function getEarlyBehaviors() * check if the table has a behavior by name * * @param string $name the behavior name + * * @return boolean True if the behavior exists */ public function hasBehavior($name) @@ -1188,6 +1205,7 @@ public function hasBehavior($name) * Get one table behavior by name * * @param string $name the behavior name + * * @return Behavior a behavior object */ public function getBehavior($name) @@ -1232,12 +1250,11 @@ public function getAdditionalBuilders() */ public function getName() { - if ($this->schema && $this->getDatabase() && $this->getDatabase()->getPlatform() && - $this->getDatabase()->getPlatform()->supportsSchemas()) { - return $this->schema . '.' . $this->commonName; - } else { - return $this->commonName; - } + if ($this->schema && $this->getDatabase() && $this->getDatabase()->getPlatform() && $this->getDatabase()->getPlatform()->supportsSchemas()) { + return $this->schema . '.' . $this->commonName; + } else { + return $this->commonName; + } } /** @@ -1268,6 +1285,7 @@ public function setDescription($newDescription) /** * Get name to use in PHP sources + * * @return string */ public function getPhpName() @@ -1289,6 +1307,7 @@ public function getPhpName() /** * Set name to use in PHP sources + * * @param string $phpName */ public function setPhpName($phpName) @@ -1399,6 +1418,7 @@ public function setIdMethod($idMethod) /** * Skip generating sql for this table (in the event it should * not be created from scratch). + * * @return boolean Value of skipSql. */ public function isSkipSql() @@ -1409,6 +1429,7 @@ public function isSkipSql() /** * Is table read-only, in which case only accessors (and relationship setters) * will be created. + * * @return boolan Value of readOnly. */ public function isReadOnly() @@ -1418,6 +1439,7 @@ public function isReadOnly() /** * Set whether this table should have its creation sql generated. + * * @param boolean $v Value to assign to skipSql. */ public function setSkipSql($v) @@ -1427,6 +1449,7 @@ public function setSkipSql($v) /** * Whether to force object to reload on INSERT. + * * @return boolean */ public function isReloadOnInsert() @@ -1436,6 +1459,7 @@ public function isReloadOnInsert() /** * Whether to force object to reload on UPDATE. + * * @return boolean */ public function isReloadOnUpdate() @@ -1445,7 +1469,8 @@ public function isReloadOnUpdate() /** * PhpName of om object this entry references. - * @return value of external. + * + * @return string */ public function getAlias() { @@ -1455,7 +1480,8 @@ public function getAlias() /** * Is this table specified in the schema or is there just * a foreign key reference to it. - * @return value of external. + * + * @return boolean */ public function isAlias() { @@ -1465,7 +1491,8 @@ public function isAlias() /** * Set whether this table specified in the schema or is there just * a foreign key reference to it. - * @param v Value to assign to alias. + * + * @param string $v */ public function setAlias($v) { @@ -1474,7 +1501,8 @@ public function setAlias($v) /** * Interface which objects for this table will implement - * @return value of interface. + * + * @return string */ public function getInterface() { @@ -1483,7 +1511,8 @@ public function getInterface() /** * Interface which objects for this table will implement - * @param v Value to assign to interface. + * + * @param string $v */ public function setInterface($v) { @@ -1496,7 +1525,7 @@ public function setInterface($v) * Foo BO will be public abstract class Foo * This helps support class hierarchies * - * @return value of abstractValue. + * @return boolean */ public function isAbstract() { @@ -1510,7 +1539,7 @@ public function isAbstract() * public abstract class Foo * This helps support class hierarchies * - * @param v Value to assign to abstractValue. + * @param boolean $v */ public function setAbstract($v) { @@ -1519,7 +1548,8 @@ public function setAbstract($v) /** * Returns an Array containing all the columns in the table - * @return array Column[] + * + * @return Column[] */ public function getColumns() { @@ -1551,6 +1581,7 @@ public function getNumLazyLoadColumns() /** * Checks whether one of the columns is of type ENUM + * * @return boolean */ public function hasEnumColumns() @@ -1567,7 +1598,8 @@ public function hasEnumColumns() /** * Returns an Array containing all the validators in the table - * @return array Validator[] + * + * @return Validator[] */ public function getValidators() { @@ -1576,7 +1608,8 @@ public function getValidators() /** * Returns an Array containing all the FKs in the table. - * @return array ForeignKey[] + * + * @return ForeignKey[] */ public function getForeignKeys() { @@ -1594,6 +1627,7 @@ public function getIdMethodParameters() /** * Returns an Array containing all the FKs in the table + * * @return array Index[] */ public function getIndices() @@ -1603,6 +1637,7 @@ public function getIndices() /** * Returns an Array containing all the UKs in the table + * * @return array Unique[] */ public function getUnices() @@ -1612,6 +1647,7 @@ public function getUnices() /** * Check whether the table has a column. + * * @param Column|string $col the column object or name (e.g. 'my_column') * @param boolean $caseInsensitive Whether the check is case insensitive. False by default. * @@ -1631,6 +1667,7 @@ public function hasColumn($col, $caseInsensitive = false) /** * Return the column with the specified name. + * * @param string $name The name of the column (e.g. 'my_column') * @param boolean $caseInsensitive Whether the check is case insensitive. False by default. * @@ -1651,6 +1688,7 @@ public function getColumn($name, $caseInsensitive = false) /** * Returns a specified column. + * * @return Column Return a Column object or null if it does not exist. */ public function getColumnByPhpName($phpName) @@ -1664,6 +1702,7 @@ public function getColumnByPhpName($phpName) /** * Get all the foreign keys from this table to the specified table. + * * @return array ForeignKey[] */ public function getForeignKeysReferencingTable($tablename) @@ -1682,7 +1721,9 @@ public function getForeignKeysReferencingTable($tablename) /** * Return the foreign keys that includes col in it's list of local columns. * Eg. Foreign key (a,b,c) references tbl(x,y,z) will be returned of col is either a,b or c. + * * @param string $col + * * @return array ForeignKey[] or null if there is no FK for specified column. */ public function getColumnForeignKeys($colname) @@ -1699,7 +1740,9 @@ public function getColumnForeignKeys($colname) /** * Check whether the table has a column. + * * @param Column|string $col the column object or name (e.g. 'my_column') + * * @deprecated use hasColumn() instead * @return boolean */ @@ -1731,6 +1774,7 @@ public function getDatabase() /** * Flag to determine if code/sql gets created for this table. * Table will be skipped, if return true. + * * @return boolean */ public function isForReferenceOnly() @@ -1741,6 +1785,7 @@ public function isForReferenceOnly() /** * Flag to determine if code/sql gets created for this table. * Table will be skipped, if set to true. + * * @param boolean $v */ public function setForReferenceOnly($v) @@ -1750,7 +1795,8 @@ public function setForReferenceOnly($v) /** * Flag to determine if tree node class should be generated for this table. - * @return value of treeMode + * + * @return string */ public function treeMode() { @@ -1759,7 +1805,8 @@ public function treeMode() /** * Flag to determine if tree node class should be generated for this table. - * @param v Value to assign to treeMode. + * + * @param string $v */ public function setTreeMode($v) { @@ -1873,14 +1920,13 @@ public function appendXml(DOMNode $node) foreach ($this->vendorInfos as $vi) { $vi->appendXml($tableNode); } - } /** * Returns the collection of Columns which make up the single primary * key for this table. * - * @return array Column[] A list of the primary key parts. + * @return Column[] A list of the primary key parts. */ public function getPrimaryKey() { @@ -1935,7 +1981,7 @@ public function getFirstPrimaryKeyColumn() public function hasAutoIncrementPrimaryKey() { if ($this->getIdMethod() != IDMethod::NO_ID_METHOD) { - $pks =$this->getPrimaryKey(); + $pks = $this->getPrimaryKey(); foreach ($pks as $pk) { if ($pk->isAutoIncrement()) { return true; @@ -1949,12 +1995,12 @@ public function hasAutoIncrementPrimaryKey() /** * Gets the auto increment PK * - * @return Column if any auto increment PK column + * @return Column|null */ public function getAutoIncrementPrimaryKey() { if ($this->getIdMethod() != IDMethod::NO_ID_METHOD) { - $pks =$this->getPrimaryKey(); + $pks = $this->getPrimaryKey(); foreach ($pks as $pk) { if ($pk->isAutoIncrement()) { return $pk; @@ -1978,6 +2024,7 @@ public function printPrimaryKey() /** * Gets the crossRef status for this foreign key + * * @return boolean */ public function getIsCrossRef() @@ -1987,6 +2034,7 @@ public function getIsCrossRef() /** * Sets a crossref status for this foreign key. + * * @param boolean $isCrossRef */ public function setIsCrossRef($isCrossRef) @@ -1996,7 +2044,9 @@ public function setIsCrossRef($isCrossRef) /** * Returns the elements of the list, separated by commas. + * * @param array $list + * * @return A CSV list. * @deprecated Use the Platform::getColumnListDDL() method. */ @@ -2004,7 +2054,7 @@ private function printList($list) { $result = ""; $comma = 0; - for ($i=0,$_i=count($list); $i < $_i; $i++) { + for ($i = 0, $_i = count($list); $i < $_i; $i++) { $col = $list[$i]; if ($col->isPrimaryKey()) { $result .= ($comma++ ? ',' : '') . $this->getDatabase()->getPlatform()->quoteIdentifier($col->getName()); @@ -2016,6 +2066,7 @@ private function printList($list) /** * Returns whether the table has foreign keys or not. + * * @return Boolean */ public function hasForeignKeys() @@ -2025,6 +2076,7 @@ public function hasForeignKeys() /** * Returns whether the table has cross foreign keys or not. + * * @return Boolean */ public function hasCrossForeignKeys() diff --git a/generator/lib/model/Unique.php b/generator/lib/model/Unique.php index 6db894262..5766585d9 100644 --- a/generator/lib/model/Unique.php +++ b/generator/lib/model/Unique.php @@ -43,7 +43,7 @@ public function appendXml(DOMNode $node) $uniqueNode = $node->appendChild($doc->createElement('unique')); $uniqueNode->setAttribute('name', $this->getName()); - $columns = $this->getColumns(); + foreach ($this->getColumns() as $colname) { $uniqueColNode = $uniqueNode->appendChild($doc->createElement('unique-column')); $uniqueColNode->setAttribute('name', $colname); @@ -53,5 +53,4 @@ public function appendXml(DOMNode $node) $vi->appendXml($uniqueNode); } } - } diff --git a/generator/lib/model/Validator.php b/generator/lib/model/Validator.php index a2c270ac4..14736f91e 100644 --- a/generator/lib/model/Validator.php +++ b/generator/lib/model/Validator.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once dirname(__FILE__) . '/XMLElement.php'; +require_once dirname(__FILE__) . '/XMLElement.php'; require_once dirname(__FILE__) . '/../exception/EngineException.php'; require_once dirname(__FILE__) . '/PropelTypes.php'; require_once dirname(__FILE__) . '/Rule.php'; @@ -56,6 +56,7 @@ class Validator extends XMLElement /** * Sets up the Validator object based on the attributes that were passed to loadFromXML(). + * * @see parent::loadFromXML() */ protected function setupObject() @@ -69,7 +70,9 @@ protected function setupObject() * Supports two signatures: * - addRule(Rule $rule) * - addRule(array $attribs) + * * @param mixed $data Rule object or XML attribs (array) from element. + * * @return Rule The added Rule. */ public function addRule($data) @@ -91,6 +94,7 @@ public function addRule($data) /** * Gets an array of all added rules for this validator. + * * @return array Rule[] */ public function getRules() @@ -100,6 +104,7 @@ public function getRules() /** * Gets the name of the column that this Validator applies to. + * * @return string */ public function getColumnName() @@ -109,7 +114,9 @@ public function getColumnName() /** * Sets the Column object that this validator applies to. + * * @param Column $column + * * @see Table::addValidator() */ public function setColumn(Column $column) @@ -119,6 +126,7 @@ public function setColumn(Column $column) /** * Gets the Column object that this validator applies to. + * * @return Column */ public function getColumn() @@ -128,6 +136,7 @@ public function getColumn() /** * Set the owning Table. + * * @param Table $table */ public function setTable(Table $table) @@ -137,6 +146,7 @@ public function setTable(Table $table) /** * Get the owning Table. + * * @return Table */ public function getTable() @@ -147,6 +157,7 @@ public function getTable() /** * Set the translation mode to use for the message. * Currently only "gettext" and "none" are supported. The default is "none". + * * @param string $method Translation method ("gettext", "none"). */ public function setTranslate($method) @@ -157,6 +168,7 @@ public function setTranslate($method) /** * Get the translation mode to use for the message. * Currently only "gettext" and "none" are supported. The default is "none". + * * @return string Translation method ("gettext", "none"). */ public function getTranslate() diff --git a/generator/lib/model/VendorInfo.php b/generator/lib/model/VendorInfo.php index 242b4ef63..67496bed6 100644 --- a/generator/lib/model/VendorInfo.php +++ b/generator/lib/model/VendorInfo.php @@ -47,6 +47,7 @@ public function __construct($type = null) /** * Sets up this object based on the attributes that were passed to loadFromXML(). + * * @see parent::loadFromXML() */ protected function setupObject() @@ -76,6 +77,7 @@ public function getType() /** * Adds a new vendor parameter to this object. + * * @param array $attrib Attributes from XML. */ public function addParameter($attrib) @@ -99,6 +101,7 @@ public function setParameter($name, $value) * Gets parameter value. * * @param string $name + * * @return mixed Paramter value. */ public function getParameter($name) @@ -149,12 +152,14 @@ public function getParameters() */ public function isEmpty() { - return empty($this->parameters); + return empty($this->parameters); } /** * Gets a new merged VendorInfo object. + * * @param VendorInfo $info + * * @return VendorInfo new object with merged parameters */ public function getMergedVendorInfo(VendorInfo $merge) diff --git a/generator/lib/model/XMLElement.php b/generator/lib/model/XMLElement.php index bc2e0f452..f8111416b 100644 --- a/generator/lib/model/XMLElement.php +++ b/generator/lib/model/XMLElement.php @@ -23,14 +23,14 @@ abstract class XMLElement /** * The name => value attributes from XML. * - * @var array + * @var array */ protected $attributes = array(); /** * Any associated vendor-specific information objects. * - * @var array VendorInfo[] + * @var VendorInfo[] */ protected $vendorInfos = array(); @@ -42,6 +42,7 @@ abstract protected function setupObject(); /** * This is the entry point method for loading data from XML. * It calls a setupObject() method that must be implemented by the child class. + * * @param array $attributes The attributes for the XML tag. */ public function loadFromXML($attributes) @@ -53,6 +54,7 @@ public function loadFromXML($attributes) /** * Returns the assoc array of attributes. * All attribute names (keys) are lowercase. + * * @return array */ public function getAttributes() @@ -63,8 +65,10 @@ public function getAttributes() /** * Gets a particular attribute by [case-insensitive] name. * If attribute is not set then the $defaultValue is returned. + * * @param string $name The [case-insensitive] name of the attribute to lookup. * @param mixed $defaultValue The default value to use in case the attribute is not set. + * * @return mixed The value of the attribute or $defaultValue if not set. */ public function getAttribute($name, $defaultValue = null) @@ -80,7 +84,8 @@ public function getAttribute($name, $defaultValue = null) /** * Converts value specified in XML to a boolean value. * This is to support the default value when used w/ a boolean column. - * @return value + * + * @return bool */ protected function booleanValue($val) { @@ -114,6 +119,7 @@ protected function getDefaultValueForArray($stringValue) /** * Appends DOM elements to represent this object in XML. + * * @param DOMNode $node */ abstract public function appendXml(DOMNode $node); @@ -122,6 +128,7 @@ abstract public function appendXml(DOMNode $node); * Sets an associated VendorInfo object. * * @param mixed $data VendorInfo object or XML attrib data (array) + * * @return VendorInfo */ public function addVendorInfo($data) @@ -141,6 +148,7 @@ public function addVendorInfo($data) /** * Gets the any associated VendorInfo object. + * * @return VendorInfo */ public function getVendorInfoForType($type) @@ -153,31 +161,33 @@ public function getVendorInfoForType($type) } } - /** - * Find the best class name for a given behavior - * Looks in build.properties for path like propel.behavior.[bname].class - * If not found, tries to autoload [Bname]Behavior - * If no success, returns 'Behavior' - * - * @param string $bname behavior name, e.g. 'timestampable' - * @return string behavior class name, e.g. 'TimestampableBehavior' - * @throws InvalidArgumentException - */ - public function getConfiguredBehavior($bname) - { - if ($config = $this->getGeneratorConfig()) { - if ($class = $config->getConfiguredBehavior($bname)) { - return $class; - } - } - // fallback: maybe the behavior is loaded or autoloaded - $gen = new PhpNameGenerator(); - if (class_exists($class = $gen->generateName(array($bname, PhpNameGenerator::CONV_METHOD_PHPNAME)) . 'Behavior')) { - return $class; - } + /** + * Find the best class name for a given behavior + * Looks in build.properties for path like propel.behavior.[bname].class + * If not found, tries to autoload [Bname]Behavior + * If no success, returns 'Behavior' + * + * @param string $bname behavior name, e.g. 'timestampable' + * + * @return string behavior class name, e.g. 'TimestampableBehavior' + * + * @throws InvalidArgumentException + */ + public function getConfiguredBehavior($bname) + { + if ($config = $this->getGeneratorConfig()) { + if ($class = $config->getConfiguredBehavior($bname)) { + return $class; + } + } + // fallback: maybe the behavior is loaded or autoloaded + $gen = new PhpNameGenerator(); + if (class_exists($class = $gen->generateName(array($bname, PhpNameGenerator::CONV_METHOD_PHPNAME)) . 'Behavior')) { + return $class; + } - throw new InvalidArgumentException(sprintf('Unknown behavior "%s"; make sure you configured the propel.behavior.%s.class setting in your build.properties', $bname, $bname)); - } + throw new InvalidArgumentException(sprintf('Unknown behavior "%s"; make sure you configured the propel.behavior.%s.class setting in your build.properties', $bname, $bname)); + } /** * String representation of the current object. @@ -198,10 +208,11 @@ public function toString() /** * Magic string method + * * @see toString() */ public function __toString() { - return $this->toString(); + return $this->toString(); } } diff --git a/generator/lib/model/diff/PropelColumnDiff.php b/generator/lib/model/diff/PropelColumnDiff.php index 3ae900983..b5ae65a6d 100644 --- a/generator/lib/model/diff/PropelColumnDiff.php +++ b/generator/lib/model/diff/PropelColumnDiff.php @@ -117,5 +117,4 @@ public function __toString() return $ret; } - } diff --git a/generator/lib/model/diff/PropelDatabaseComparator.php b/generator/lib/model/diff/PropelDatabaseComparator.php index 12fbfe9bd..95ed243e8 100644 --- a/generator/lib/model/diff/PropelDatabaseComparator.php +++ b/generator/lib/model/diff/PropelDatabaseComparator.php @@ -155,5 +155,4 @@ public function compareTables($caseInsensitive = false) return $databaseDifferences; } - } diff --git a/generator/lib/model/diff/PropelDatabaseDiff.php b/generator/lib/model/diff/PropelDatabaseDiff.php index 574212eb1..df531b47f 100644 --- a/generator/lib/model/diff/PropelDatabaseDiff.php +++ b/generator/lib/model/diff/PropelDatabaseDiff.php @@ -269,16 +269,16 @@ public function getDescription() { $changes = array(); if ($count = $this->countAddedTables()) { - $changes []= sprintf('%d added tables', $count); + $changes[] = sprintf('%d added tables', $count); } if ($count = $this->countRemovedTables()) { - $changes []= sprintf('%d removed tables', $count); + $changes[] = sprintf('%d removed tables', $count); } if ($count = $this->countModifiedTables()) { - $changes []= sprintf('%d modified tables', $count); + $changes[] = sprintf('%d modified tables', $count); } if ($count = $this->countRenamedTables()) { - $changes []= sprintf('%d renamed tables', $count); + $changes[] = sprintf('%d renamed tables', $count); } return implode(', ', $changes); @@ -314,5 +314,4 @@ public function __toString() return $ret; } - } diff --git a/generator/lib/model/diff/PropelForeignKeyComparator.php b/generator/lib/model/diff/PropelForeignKeyComparator.php index c6bf8bdd8..46174f00f 100644 --- a/generator/lib/model/diff/PropelForeignKeyComparator.php +++ b/generator/lib/model/diff/PropelForeignKeyComparator.php @@ -88,5 +88,4 @@ public static function computeDiff(ForeignKey $fromFk, ForeignKey $toFk, $caseIn return false; } - } diff --git a/generator/lib/model/diff/PropelIndexComparator.php b/generator/lib/model/diff/PropelIndexComparator.php index 5d2d64c72..17c2b4eb7 100644 --- a/generator/lib/model/diff/PropelIndexComparator.php +++ b/generator/lib/model/diff/PropelIndexComparator.php @@ -56,5 +56,4 @@ public static function computeDiff(Index $fromIndex, Index $toIndex, $caseInsens return false; } - } diff --git a/generator/lib/model/diff/PropelTableComparator.php b/generator/lib/model/diff/PropelTableComparator.php index 8589a1aed..f2024231d 100644 --- a/generator/lib/model/diff/PropelTableComparator.php +++ b/generator/lib/model/diff/PropelTableComparator.php @@ -178,8 +178,7 @@ public function comparePrimaryKeys($caseInsensitive = false) // check for new pk columns in $toTable foreach ($toTablePk as $column) { - if (!$this->getFromTable()->hasColumn($column->getName(), $caseInsensitive) || - !$this->getFromTable()->getColumn($column->getName(), $caseInsensitive)->isPrimaryKey()) { + if (!$this->getFromTable()->hasColumn($column->getName(), $caseInsensitive) || !$this->getFromTable()->getColumn($column->getName(), $caseInsensitive)->isPrimaryKey()) { $this->tableDiff->addAddedPkColumn($column->getName(), $column); $pkDifferences++; } @@ -187,8 +186,7 @@ public function comparePrimaryKeys($caseInsensitive = false) // check for removed pk columns in $toTable foreach ($fromTablePk as $column) { - if (!$this->getToTable()->hasColumn($column->getName(), $caseInsensitive) || - !$this->getToTable()->getColumn($column->getName(), $caseInsensitive)->isPrimaryKey()) { + if (!$this->getToTable()->hasColumn($column->getName(), $caseInsensitive) || !$this->getToTable()->getColumn($column->getName(), $caseInsensitive)->isPrimaryKey()) { $this->tableDiff->addRemovedPkColumn($column->getName(), $column); $pkDifferences++; } @@ -311,5 +309,4 @@ public function compareForeignKeys($caseInsensitive = false) return $fkDifferences; } - } diff --git a/generator/lib/model/diff/PropelTableDiff.php b/generator/lib/model/diff/PropelTableDiff.php index 4650887d4..cc988f741 100644 --- a/generator/lib/model/diff/PropelTableDiff.php +++ b/generator/lib/model/diff/PropelTableDiff.php @@ -438,7 +438,7 @@ public function getRemovedIndices() * * @param $modifiedIndices */ - public function setModifiedIndices( $modifiedIndices) + public function setModifiedIndices($modifiedIndices) { $this->modifiedIndices = $modifiedIndices; } @@ -597,7 +597,7 @@ public function getReverseDiff() $diff->setRemovedColumns($this->getAddedColumns()); $renamedColumns = array(); foreach ($this->getRenamedColumns() as $columnRenaming) { - $renamedColumns[]= array_reverse($columnRenaming); + $renamedColumns[] = array_reverse($columnRenaming); } $diff->setRenamedColumns($renamedColumns); $columnDiffs = array(); @@ -611,7 +611,7 @@ public function getReverseDiff() $diff->setRemovedPkColumns($this->getAddedPkColumns()); $renamedPkColumns = array(); foreach ($this->getRenamedPkColumns() as $columnRenaming) { - $renamedPkColumns[]= array_reverse($columnRenaming); + $renamedPkColumns[] = array_reverse($columnRenaming); } $diff->setRenamedPkColumns($renamedPkColumns); @@ -721,5 +721,4 @@ public function __toString() return $ret; } - } diff --git a/generator/lib/platform/DefaultPlatform.php b/generator/lib/platform/DefaultPlatform.php index b1a0c1225..eada86ced 100644 --- a/generator/lib/platform/DefaultPlatform.php +++ b/generator/lib/platform/DefaultPlatform.php @@ -43,16 +43,20 @@ class DefaultPlatform implements PropelPlatformInterface /** * Default constructor. + * * @param PDO $con Optional database connection to use in this platform. */ public function __construct(PDO $con = null) { - if ($con) $this->setConnection($con); + if ($con) { + $this->setConnection($con); + } $this->initialize(); } /** * Set the database connection to use for this Platform class. + * * @param PDO $con Database connection to use in this platform. */ public function setConnection(PDO $con = null) @@ -62,6 +66,7 @@ public function setConnection(PDO $con = null) /** * Returns the database connection to use for this Platform class. + * * @return PDO The database connection or NULL if none has been set. */ public function getConnection() @@ -83,6 +88,7 @@ public function setGeneratorConfig(GeneratorConfigInterface $config) * Gets a specific propel (renamed) property from the build. * * @param string $name + * * @return mixed */ protected function getBuildProperty($name) @@ -113,6 +119,7 @@ protected function initialize() /** * Adds a mapping entry for specified Domain. + * * @param Domain $domain */ protected function setSchemaDomainMapping(Domain $domain) @@ -123,6 +130,7 @@ protected function setSchemaDomainMapping(Domain $domain) /** * Returns the short name of the database type that this platform represents. * For example MysqlPlatform->getDatabaseType() returns 'mysql'. + * * @return string */ public function getDatabaseType() @@ -130,7 +138,7 @@ public function getDatabaseType() $clazz = get_class($this); $pos = strpos($clazz, 'Platform'); - return strtolower(substr($clazz,0,$pos)); + return strtolower(substr($clazz, 0, $pos)); } /** @@ -162,6 +170,7 @@ public function isNativeIdMethodAutoIncrement() * Returns the db specific domain for a propelType. * * @param string $propelType the Propel type name. + * * @return Domain The db specific domain. * @throws EngineException */ @@ -215,7 +224,7 @@ public function getSequenceName(Table $table) } $result = substr($table->getName(), 0, $maxIdentifierLength - strlen("_SEQ_" . $longNamesMap[$table->getName()])) . "_SEQ_" . $longNamesMap[$table->getName()]; } else { - $result = substr($table->getName(), 0, $maxIdentifierLength -4) . "_SEQ"; + $result = substr($table->getName(), 0, $maxIdentifierLength - 4) . "_SEQ"; } } else { $result = substr($idMethodParams[0]->getValue(), 0, $maxIdentifierLength); @@ -266,6 +275,7 @@ public function getEndDDL() /** * Builds the DDL SQL to drop a table + * * @return string */ public function getDropTableDDL(Table $table) @@ -309,21 +319,18 @@ public function getAddTableDDL(Table $table) ); "; - return sprintf($pattern, - $tableDescription, - $this->quoteIdentifier($table->getName()), - implode($sep, $lines) - ); + return sprintf($pattern, $tableDescription, $this->quoteIdentifier($table->getName()), implode($sep, $lines)); } /** * Builds the DDL SQL for a Column object. + * * @return string */ public function getColumnDDL(Column $col) { - $domain = $col->getDomain(); - $ddl = array($this->quoteIdentifier($col->getName())); + $domain = $col->getDomain(); + $ddl = array($this->quoteIdentifier($col->getName())); $sqlType = $domain->getSqlType(); if ($this->hasSize($sqlType) && $col->isDefaultSqlType($this)) { @@ -349,6 +356,7 @@ public function getColumnDDL(Column $col) /** * Returns the SQL for the default value of a Column object + * * @return string */ public function getColumnDefaultValueDDL(Column $col) @@ -385,11 +393,13 @@ public function getColumnDefaultValueDDL(Column $col) /** * Creates a delimiter-delimited string list of column names, quoted using quoteIdentifier(). + * * @example * * echo $platform->getColumnListDDL(array('foo', 'bar'); * // '"foo","bar"' * + * * @param array Column[] or string[] * @param string $delim The delimiter to use in separating the column names. * @@ -410,6 +420,7 @@ public function getColumnListDDL($columns, $delimiter = ',') /** * Returns the name of a table primary key + * * @return string */ public function getPrimaryKeyName(Table $table) @@ -421,6 +432,7 @@ public function getPrimaryKeyName(Table $table) /** * Returns the SQL for the primary key of a Table object + * * @return string */ public function getPrimaryKeyDDL(Table $table) @@ -434,6 +446,7 @@ public function getPrimaryKeyDDL(Table $table) * Builds the DDL SQL to drop the primary key of a table. * * @param Table $table + * * @return string */ public function getDropPrimaryKeyDDL(Table $table) @@ -452,6 +465,7 @@ public function getDropPrimaryKeyDDL(Table $table) * Builds the DDL SQL to add the primary key of a table. * * @param Table $table + * * @return string */ public function getAddPrimaryKeyDDL(Table $table) @@ -470,6 +484,7 @@ public function getAddPrimaryKeyDDL(Table $table) * Builds the DDL SQL to add the indices of a table. * * @param Table $table + * * @return string */ public function getAddIndicesDDL(Table $table) @@ -486,6 +501,7 @@ public function getAddIndicesDDL(Table $table) * Builds the DDL SQL to add an Index. * * @param Index $index + * * @return string */ public function getAddIndexDDL(Index $index) @@ -506,6 +522,7 @@ public function getAddIndexDDL(Index $index) * Builds the DDL SQL to drop an Index. * * @param Index $index + * * @return string */ public function getDropIndexDDL(Index $index) @@ -514,41 +531,38 @@ public function getDropIndexDDL(Index $index) DROP INDEX %s; "; - return sprintf($pattern, - $this->quoteIdentifier($index->getName()) - ); + return sprintf($pattern, $this->quoteIdentifier($index->getName())); } /** * Builds the DDL SQL for an Index object. * * @param Index $index + * * @return string */ public function getIndexDDL(Index $index) { - return sprintf('%sINDEX %s (%s)', - $index->getIsUnique() ? 'UNIQUE ' : '', - $this->quoteIdentifier($index->getName()), - $this->getColumnListDDL($index->getColumns()) - ); + return sprintf('%sINDEX %s (%s)', $index->getIsUnique() ? 'UNIQUE ' : '', $this->quoteIdentifier($index->getName()), $this->getColumnListDDL($index->getColumns())); } /** * Builds the DDL SQL for a Unique constraint object. * * @param Unique $unique + * * @return string */ public function getUniqueDDL(Unique $unique) { - return sprintf('UNIQUE (%s)' , $this->getColumnListDDL($unique->getColumns())); + return sprintf('UNIQUE (%s)', $this->getColumnListDDL($unique->getColumns())); } /** * Builds the DDL SQL to add the foreign keys of a table. * * @param Table $table + * * @return string */ public function getAddForeignKeysDDL(Table $table) @@ -565,6 +579,7 @@ public function getAddForeignKeysDDL(Table $table) * Builds the DDL SQL to add a foreign key. * * @param ForeignKey $fk + * * @return string */ public function getAddForeignKeyDDL(ForeignKey $fk) @@ -586,6 +601,7 @@ public function getAddForeignKeyDDL(ForeignKey $fk) * Builds the DDL SQL to drop a foreign key. * * @param ForeignKey $fk + * * @return string */ public function getDropForeignKeyDDL(ForeignKey $fk) @@ -605,6 +621,7 @@ public function getDropForeignKeyDDL(ForeignKey $fk) /** * Builds the DDL SQL for a ForeignKey object. + * * @return string */ public function getForeignKeyDDL(ForeignKey $fk) @@ -690,6 +707,7 @@ public function getModifyDatabaseDDL(PropelDatabaseDiff $databaseDiff) /** * Builds the DDL SQL to rename a table + * * @return string */ public function getRenameTableDDL($fromTableName, $toTableName) @@ -889,6 +907,7 @@ public function getRemoveColumnDDL(Column $column) /** * Builds the DDL SQL to rename a column + * * @return string */ public function getRenameColumnDDL($fromColumn, $toColumn) @@ -936,7 +955,7 @@ public function getModifyColumnsDDL($columnDiffs) if (null === $tableName) { $tableName = $toColumn->getTable()->getName(); } - $lines []= $this->getColumnDDL($toColumn); + $lines[] = $this->getColumnDDL($toColumn); } $sep = ", @@ -985,7 +1004,7 @@ public function getAddColumnsDDL($columns) if (null === $tableName) { $tableName = $column->getTable()->getName(); } - $lines []= $this->getColumnDDL($column); + $lines[] = $this->getColumnDDL($column); } $sep = ", @@ -998,16 +1017,14 @@ public function getAddColumnsDDL($columns) ); "; - return sprintf($pattern, - $this->quoteIdentifier($tableName), - implode($sep, $lines) - ); + return sprintf($pattern, $this->quoteIdentifier($tableName), implode($sep, $lines)); } /** * Returns if the RDBMS-specific SQL type has a size attribute. * * @param string $sqlType the SQL type + * * @return boolean True if the type has a size attribute */ public function hasSize($sqlType) @@ -1019,6 +1036,7 @@ public function hasSize($sqlType) * Returns if the RDBMS-specific SQL type has a scale attribute. * * @param string $sqlType the SQL type + * * @return boolean True if the type has a scale attribute */ public function hasScale($sqlType) @@ -1028,7 +1046,9 @@ public function hasScale($sqlType) /** * Quote and escape needed characters in the string for underlying RDBMS. + * * @param string $text + * * @return string */ public function quote($text) @@ -1047,6 +1067,7 @@ public function quote($text) * or native DB methods. * * @param string $text Text that needs to be escaped. + * * @return string */ protected function disconnectedEscapeText($text) @@ -1056,7 +1077,9 @@ protected function disconnectedEscapeText($text) /** * Quotes identifiers used in database SQL. + * * @param string $text + * * @return string Quoted identifier. */ public function quoteIdentifier($text) @@ -1076,6 +1099,7 @@ public function getIdentifierQuoting() /** * Whether RDBMS supports native ON DELETE triggers (e.g. ON DELETE CASCADE). + * * @return boolean */ public function supportsNativeDeleteTrigger() @@ -1085,6 +1109,7 @@ public function supportsNativeDeleteTrigger() /** * Whether RDBMS supports INSERT null values in autoincremented primary keys + * * @return boolean */ public function supportsInsertNullPk() @@ -1094,6 +1119,7 @@ public function supportsInsertNullPk() /** * Whether the underlying PDO driver for this platform returns BLOB columns as streams (instead of strings). + * * @return boolean */ public function hasStreamBlobImpl() @@ -1122,6 +1148,7 @@ public function supportsVarcharWithoutSize() { return false; } + /** * Returns the boolean value for the RDBMS. * @@ -1132,6 +1159,7 @@ public function supportsVarcharWithoutSize() * SQL. * * @param mixed $tf A boolean or string representation of boolean ('y', 'true'). + * * @return mixed */ public function getBooleanString($b) @@ -1164,6 +1192,7 @@ public function getPhpArrayString($stringValue) /** * Gets the preferred timestamp formatter for setting date/time values. + * * @return string */ public function getTimestampFormatter() @@ -1173,6 +1202,7 @@ public function getTimestampFormatter() /** * Gets the preferred time formatter for setting date/time values. + * * @return string */ public function getTimeFormatter() @@ -1182,6 +1212,7 @@ public function getTimeFormatter() /** * Gets the preferred date formatter for setting date/time values. + * * @return string */ public function getDateFormatter() diff --git a/generator/lib/platform/MssqlPlatform.php b/generator/lib/platform/MssqlPlatform.php index 3ce967195..fdbb17af3 100644 --- a/generator/lib/platform/MssqlPlatform.php +++ b/generator/lib/platform/MssqlPlatform.php @@ -156,7 +156,7 @@ public function getForeignKeyDDL(ForeignKey $fk) $script .= ' ON UPDATE ' . $fk->getOnUpdate(); } if ($fk->hasOnDelete() && $fk->getOnDelete() != ForeignKey::SETNULL) { - $script .= ' ON DELETE '. $fk->getOnDelete(); + $script .= ' ON DELETE ' . $fk->getOnDelete(); } return $script; @@ -184,5 +184,4 @@ public function getTimestampFormatter() { return 'Y-m-d H:i:s'; } - } diff --git a/generator/lib/platform/MysqlPlatform.php b/generator/lib/platform/MysqlPlatform.php index 9bf02d772..44061d593 100644 --- a/generator/lib/platform/MysqlPlatform.php +++ b/generator/lib/platform/MysqlPlatform.php @@ -161,6 +161,7 @@ public function getEndDDL() /** * Returns the SQL for the primary key of a Table object + * * @return string */ public function getPrimaryKeyDDL(Table $table) @@ -232,7 +233,7 @@ public function getAddTableDDL(Table $table) } $tableOptions = $tableOptions ? ' ' . implode(' ', $tableOptions) : ''; - $sep = ", + $sep = ", "; $pattern = " @@ -253,9 +254,9 @@ public function getAddTableDDL(Table $table) protected function getTableOptions(Table $table) { - $dbVI = $table->getDatabase()->getVendorInfoForType('mysql'); - $tableVI = $table->getVendorInfoForType('mysql'); - $vi = $dbVI->getMergedVendorInfo($tableVI); + $dbVI = $table->getDatabase()->getVendorInfoForType('mysql'); + $tableVI = $table->getVendorInfoForType('mysql'); + $vi = $dbVI->getMergedVendorInfo($tableVI); $tableOptions = array(); // List of supported table options // see http://dev.mysql.com/doc/refman/5.5/en/create-table.html @@ -306,9 +307,9 @@ public function getDropTableDDL(Table $table) public function getColumnDDL(Column $col) { - $domain = $col->getDomain(); - $sqlType = $domain->getSqlType(); - $notNullString = $this->getNullString($col->isNotNull()); + $domain = $col->getDomain(); + $sqlType = $domain->getSqlType(); + $notNullString = $this->getNullString($col->isNotNull()); $defaultSetting = $this->getColumnDefaultValueDDL($col); // Special handling of TIMESTAMP/DATETIME types ... @@ -379,7 +380,9 @@ public function getColumnDDL(Column $col) * Creates a comma-separated list of column names for the index. * For MySQL unique indexes there is the option of specifying size, so we cannot simply use * the getColumnsList() method. + * * @param Index $index + * * @return string */ protected function getIndexColumnListDDL(Index $index) @@ -396,6 +399,7 @@ protected function getIndexColumnListDDL(Index $index) * Builds the DDL SQL to drop the primary key of a table. * * @param Table $table + * * @return string */ public function getDropPrimaryKeyDDL(Table $table) @@ -413,6 +417,7 @@ public function getDropPrimaryKeyDDL(Table $table) * Builds the DDL SQL to add an Index. * * @param Index $index + * * @return string */ public function getAddIndexDDL(Index $index) @@ -433,6 +438,7 @@ public function getAddIndexDDL(Index $index) * Builds the DDL SQL to drop an Index. * * @param Index $index + * * @return string */ public function getDropIndexDDL(Index $index) @@ -449,6 +455,7 @@ public function getDropIndexDDL(Index $index) /** * Builds the DDL SQL for an Index object. + * * @return string */ public function getIndexDDL(Index $index) @@ -462,7 +469,7 @@ public function getIndexDDL(Index $index) protected function getIndexType(Index $index) { - $type = ''; + $type = ''; $vendorInfo = $index->getVendorInfoForType($this->getDatabaseType()); if ($vendorInfo && $vendorInfo->getParameter('Index_type')) { $type = $vendorInfo->getParameter('Index_type') . ' '; @@ -492,6 +499,7 @@ public function getAddForeignKeyDDL(ForeignKey $fk) /** * Builds the DDL SQL for a ForeignKey object. + * * @return string */ public function getForeignKeyDDL(ForeignKey $fk) @@ -562,6 +570,7 @@ public function getModifyDatabaseDDL(PropelDatabaseDiff $databaseDiff) /** * Builds the DDL SQL to rename a table + * * @return string */ public function getRenameTableDDL($fromTableName, $toTableName) @@ -595,6 +604,7 @@ public function getRemoveColumnDDL(Column $column) /** * Builds the DDL SQL to rename a column + * * @return string */ public function getRenameColumnDDL($fromColumn, $toColumn) @@ -614,6 +624,7 @@ public function getModifyColumnDDL(PropelColumnDiff $columnDiff) /** * Builds the DDL SQL to change a column + * * @return string */ public function getChangeColumnDDL($fromColumn, $toColumn) @@ -676,7 +687,7 @@ public function getAddColumnDDLBits(Column $column) */ public function getAddColumnsDDL($columns) { - $lines = array(); + $lines = array(); $tableName = null; foreach ($columns as $column) { if (null === $tableName) { @@ -709,14 +720,14 @@ public function supportsSchemas() public function hasSize($sqlType) { - return !("MEDIUMTEXT" == $sqlType || "LONGTEXT" == $sqlType - || "BLOB" == $sqlType || "MEDIUMBLOB" == $sqlType - || "LONGBLOB" == $sqlType); + return !("MEDIUMTEXT" == $sqlType || "LONGTEXT" == $sqlType || "BLOB" == $sqlType || "MEDIUMBLOB" == $sqlType || "LONGBLOB" == $sqlType); } /** * Escape the string for RDBMS. + * * @param string $text + * * @return string */ public function disconnectedEscapeText($text) @@ -735,6 +746,7 @@ public function disconnectedEscapeText($text) * to allow for a . or
. syntax. * * @param string $text the identifier + * * @return string the quoted identifier */ public function quoteIdentifier($text) @@ -763,5 +775,4 @@ public function getColumnBindingPHP($column, $identifier, $columnValueAccessor, return parent::getColumnBindingPHP($column, $identifier, $columnValueAccessor, $tab); } - } diff --git a/generator/lib/platform/OraclePlatform.php b/generator/lib/platform/OraclePlatform.php index 04a05b5a5..846987df5 100644 --- a/generator/lib/platform/OraclePlatform.php +++ b/generator/lib/platform/OraclePlatform.php @@ -50,7 +50,6 @@ protected function initialize() $this->setSchemaDomainMapping(new Domain(PropelTypes::OBJECT, "NVARCHAR2", "2000")); $this->setSchemaDomainMapping(new Domain(PropelTypes::PHP_ARRAY, "NVARCHAR2", "2000")); $this->setSchemaDomainMapping(new Domain(PropelTypes::ENUM, "NUMBER", "3", "0")); - } public function getMaxColumnNameLength() @@ -226,6 +225,7 @@ public function getForeignKeyDDL(ForeignKey $fk) /** * Whether the underlying PDO driver for this platform returns BLOB columns as streams (instead of strings). + * * @return boolean */ public function hasStreamBlobImpl() @@ -279,35 +279,35 @@ public function generateBlockStorage($object, $isPrimaryKey = false) $prefix = ""; } - if ($vendorSpecific->hasParameter($prefix.'PCTFree')) { - $physicalParameters .= "PCTFREE " . $vendorSpecific->getParameter($prefix.'PCTFree') . " + if ($vendorSpecific->hasParameter($prefix . 'PCTFree')) { + $physicalParameters .= "PCTFREE " . $vendorSpecific->getParameter($prefix . 'PCTFree') . " "; } - if ($vendorSpecific->hasParameter($prefix.'InitTrans')) { - $physicalParameters .= "INITRANS " . $vendorSpecific->getParameter($prefix.'InitTrans') . " + if ($vendorSpecific->hasParameter($prefix . 'InitTrans')) { + $physicalParameters .= "INITRANS " . $vendorSpecific->getParameter($prefix . 'InitTrans') . " "; } - if ($vendorSpecific->hasParameter($prefix.'MinExtents') || $vendorSpecific->hasParameter($prefix.'MaxExtents') || $vendorSpecific->hasParameter($prefix.'PCTIncrease')) { + if ($vendorSpecific->hasParameter($prefix . 'MinExtents') || $vendorSpecific->hasParameter($prefix . 'MaxExtents') || $vendorSpecific->hasParameter($prefix . 'PCTIncrease')) { $physicalParameters .= "STORAGE ( "; - if ($vendorSpecific->hasParameter($prefix.'MinExtents')) { - $physicalParameters .= " MINEXTENTS " . $vendorSpecific->getParameter($prefix.'MinExtents') . " + if ($vendorSpecific->hasParameter($prefix . 'MinExtents')) { + $physicalParameters .= " MINEXTENTS " . $vendorSpecific->getParameter($prefix . 'MinExtents') . " "; } - if ($vendorSpecific->hasParameter($prefix.'MaxExtents')) { - $physicalParameters .= " MAXEXTENTS " . $vendorSpecific->getParameter($prefix.'MaxExtents') . " + if ($vendorSpecific->hasParameter($prefix . 'MaxExtents')) { + $physicalParameters .= " MAXEXTENTS " . $vendorSpecific->getParameter($prefix . 'MaxExtents') . " "; } - if ($vendorSpecific->hasParameter($prefix.'PCTIncrease')) { - $physicalParameters .= " PCTINCREASE " . $vendorSpecific->getParameter($prefix.'PCTIncrease') . " + if ($vendorSpecific->hasParameter($prefix . 'PCTIncrease')) { + $physicalParameters .= " PCTINCREASE " . $vendorSpecific->getParameter($prefix . 'PCTIncrease') . " "; } $physicalParameters .= ") "; } - if ($vendorSpecific->hasParameter($prefix.'Tablespace')) { - $physicalParameters .= "TABLESPACE " . $vendorSpecific->getParameter($prefix.'Tablespace'); + if ($vendorSpecific->hasParameter($prefix . 'Tablespace')) { + $physicalParameters .= "TABLESPACE " . $vendorSpecific->getParameter($prefix . 'Tablespace'); } return $physicalParameters; @@ -317,6 +317,7 @@ public function generateBlockStorage($object, $isPrimaryKey = false) * Builds the DDL SQL to add an Index. * * @param Index $index + * * @return string */ public function getAddIndexDDL(Index $index) diff --git a/generator/lib/platform/PgsqlPlatform.php b/generator/lib/platform/PgsqlPlatform.php index f1488074f..d5596f473 100644 --- a/generator/lib/platform/PgsqlPlatform.php +++ b/generator/lib/platform/PgsqlPlatform.php @@ -63,7 +63,9 @@ public function getMaxColumnNameLength() /** * Escape the string for RDBMS. + * * @param string $text + * * @return string */ public function disconnectedEscapeText($text) @@ -123,8 +125,7 @@ public function getSequenceName(Table $table) protected function getAddSequenceDDL(Table $table) { - if ($table->getIdMethod() == IDMethod::NATIVE - && $table->getIdMethodParameters() != null) { + if ($table->getIdMethod() == IDMethod::NATIVE && $table->getIdMethodParameters() != null) { $pattern = " CREATE SEQUENCE %s; "; @@ -137,8 +138,7 @@ protected function getAddSequenceDDL(Table $table) protected function getDropSequenceDDL(Table $table) { - if ($table->getIdMethod() == IDMethod::NATIVE - && $table->getIdMethodParameters() != null) { + if ($table->getIdMethod() == IDMethod::NATIVE && $table->getIdMethodParameters() != null) { $pattern = " DROP SEQUENCE %s; "; @@ -321,18 +321,18 @@ public function getColumnDDL(Column $col) $sqlType = $col->getType() === PropelTypes::BIGINT ? 'bigserial' : 'serial'; } if ($this->hasSize($sqlType) && $col->isDefaultSqlType($this)) { - $ddl []= $sqlType . $domain->printSize(); + $ddl[] = $sqlType . $domain->printSize(); } else { - $ddl []= $sqlType; + $ddl[] = $sqlType; } if ($default = $this->getColumnDefaultValueDDL($col)) { - $ddl []= $default; + $ddl[] = $default; } if ($notNull = $this->getNullString($col->isNotNull())) { - $ddl []= $notNull; + $ddl[] = $notNull; } if ($autoIncrement = $col->getAutoIncrementString()) { - $ddl []= $autoIncrement; + $ddl[] = $autoIncrement; } return implode(' ', $ddl); diff --git a/generator/lib/platform/PropelPlatformInterface.php b/generator/lib/platform/PropelPlatformInterface.php index 965d27b93..4c15a5863 100644 --- a/generator/lib/platform/PropelPlatformInterface.php +++ b/generator/lib/platform/PropelPlatformInterface.php @@ -36,12 +36,14 @@ interface PropelPlatformInterface /** * Sets a database connection to use (for quoting, etc.). + * * @param PDO $con The database connection to use in this Platform class. */ public function setConnection(PDO $con = null); /** * Returns the database connection to use for this Platform class. + * * @return PDO The database connection or NULL if none has been set. */ public function getConnection(); @@ -56,6 +58,7 @@ public function setGeneratorConfig(GeneratorConfigInterface $config); /** * Returns the short name of the database type that this platform represents. * For example MysqlPlatform->getDatabaseType() returns 'mysql'. + * * @return string */ public function getDatabaseType(); @@ -78,6 +81,7 @@ public function getMaxColumnNameLength(); * Returns the db specific domain for a propelType. * * @param string $propelType the Propel type name. + * * @return Domain The db specific domain. */ public function getDomainForType($propelType); @@ -95,23 +99,27 @@ public function getAutoIncrement(); /** * Returns the DDL SQL for a Column object. + * * @return string */ public function getColumnDDL(Column $col); /** * Returns the SQL for the default value of a Column object. + * * @return string */ public function getColumnDefaultValueDDL(Column $col); /** * Creates a delimiter-delimited string list of column names, quoted using quoteIdentifier(). + * * @example * * echo $platform->getColumnListDDL(array('foo', 'bar'); * // '"foo","bar"' * + * * @param array Column[] or string[] * @param string $delim The delimiter to use in separating the column names. * @@ -121,6 +129,7 @@ public function getColumnListDDL($columns, $delimiter = ','); /** * Returns the SQL for the primary key of a Table object + * * @return string */ public function getPrimaryKeyDDL(Table $table); @@ -129,6 +138,7 @@ public function getPrimaryKeyDDL(Table $table); * Returns if the RDBMS-specific SQL type has a size attribute. * * @param string $sqlType the SQL type + * * @return boolean True if the type has a size attribute */ public function hasSize($sqlType); @@ -137,50 +147,60 @@ public function hasSize($sqlType); * Returns if the RDBMS-specific SQL type has a scale attribute. * * @param string $sqlType the SQL type + * * @return boolean True if the type has a scale attribute */ public function hasScale($sqlType); /** * Quote and escape needed characters in the string for underlying RDBMS. + * * @param string $text + * * @return string */ public function quote($text); /** * Quotes identifiers used in database SQL. + * * @param string $text + * * @return string Quoted identifier. */ public function quoteIdentifier($text); /** * Whether RDBMS supports native ON DELETE triggers (e.g. ON DELETE CASCADE). + * * @return boolean */ public function supportsNativeDeleteTrigger(); /** * Whether RDBMS supports INSERT null values in autoincremented primary keys + * * @return boolean */ public function supportsInsertNullPk(); /** * Whether RDBMS supports native schemas for table layout. + * * @return boolean */ public function supportsSchemas(); /** * Whether RDBMS supports migrations. + * * @return boolean */ public function supportsMigrations(); /** * Wether RDBMS supports VARCHAR without explicit size + * * @return boolean */ public function supportsVarcharWithoutSize(); @@ -195,30 +215,35 @@ public function supportsVarcharWithoutSize(); * SQL. * * @param mixed $tf A boolean or string representation of boolean ('y', 'true'). + * * @return mixed */ public function getBooleanString($tf); /** * Whether the underlying PDO driver for this platform returns BLOB columns as streams (instead of strings). + * * @return boolean */ public function hasStreamBlobImpl(); /** * Gets the preferred timestamp formatter for setting date/time values. + * * @return string */ public function getTimestampFormatter(); /** * Gets the preferred date formatter for setting time values. + * * @return string */ public function getDateFormatter(); /** * Gets the preferred time formatter for setting time values. + * * @return string */ public function getTimeFormatter(); diff --git a/generator/lib/platform/SqlitePlatform.php b/generator/lib/platform/SqlitePlatform.php index 139eff62e..904e1e80a 100644 --- a/generator/lib/platform/SqlitePlatform.php +++ b/generator/lib/platform/SqlitePlatform.php @@ -63,10 +63,10 @@ public function getAddTableDDL(Table $table) } if ($table->hasPrimaryKey()) { - $pk = $table->getPrimaryKey(); - if (count($pk) > 1 || !$pk[0]->isAutoIncrement()) { - $lines[] = $this->getPrimaryKeyDDL($table); - } + $pk = $table->getPrimaryKey(); + if (count($pk) > 1 || !$pk[0]->isAutoIncrement()) { + $lines[] = $this->getPrimaryKeyDDL($table); + } } foreach ($table->getUnices() as $unique) { @@ -136,14 +136,14 @@ public function getForeignKeyDDL(ForeignKey $fk) public function hasSize($sqlType) { - return !("MEDIUMTEXT" == $sqlType || "LONGTEXT" == $sqlType - || "BLOB" == $sqlType || "MEDIUMBLOB" == $sqlType - || "LONGBLOB" == $sqlType); + return !("MEDIUMTEXT" == $sqlType || "LONGTEXT" == $sqlType || "BLOB" == $sqlType || "MEDIUMBLOB" == $sqlType || "LONGBLOB" == $sqlType); } /** * Escape the string for RDBMS. + * * @param string $text + * * @return string */ public function disconnectedEscapeText($text) diff --git a/generator/lib/reverse/BaseSchemaParser.php b/generator/lib/reverse/BaseSchemaParser.php index 549dad0f5..b0c00f6d4 100644 --- a/generator/lib/reverse/BaseSchemaParser.php +++ b/generator/lib/reverse/BaseSchemaParser.php @@ -22,6 +22,7 @@ abstract class BaseSchemaParser implements SchemaParser /** * The database connection. + * * @var PDO */ protected $dbh; @@ -43,6 +44,7 @@ abstract class BaseSchemaParser implements SchemaParser /** * Map native DB types to Propel types. * (Override in subclasses.) + * * @var array */ protected $nativeToPropelTypeMap; @@ -68,7 +70,9 @@ abstract class BaseSchemaParser implements SchemaParser */ public function __construct(PDO $dbh = null) { - if ($dbh) $this->setConnection($dbh); + if ($dbh) { + $this->setConnection($dbh); + } } /** @@ -83,6 +87,7 @@ public function setConnection(PDO $dbh) /** * Gets the database connection. + * * @return PDO */ public function getConnection() @@ -154,6 +159,7 @@ public function getGeneratorConfig() * Gets a specific propel (renamed) property from the build. * * @param string $name + * * @return mixed */ public function getBuildProperty($name) @@ -176,6 +182,7 @@ abstract protected function getTypeMapping(); * Gets a mapped Propel type for specified native type. * * @param string $nativeType + * * @return string The mapped Propel type. */ protected function getMappedPropelType($nativeType) @@ -194,6 +201,7 @@ protected function getMappedPropelType($nativeType) * Give a best guess at the native type. * * @param string $propelType + * * @return string The native SQL type that best matches the specified Propel type. */ protected function getMappedNativeType($propelType) @@ -223,15 +231,15 @@ protected function getNewVendorInfoObject(array $params) public function setPlatform($platform) { - $this->platform = $platform; + $this->platform = $platform; } public function getPlatform() { - if (null === $this->platform) { - $this->platform = $this->getGeneratorConfig()->getConfiguredPlatform(); - } + if (null === $this->platform) { + $this->platform = $this->getGeneratorConfig()->getConfiguredPlatform(); + } - return $this->platform; + return $this->platform; } } diff --git a/generator/lib/reverse/SchemaParser.php b/generator/lib/reverse/SchemaParser.php index 73c065231..3a0143746 100644 --- a/generator/lib/reverse/SchemaParser.php +++ b/generator/lib/reverse/SchemaParser.php @@ -20,6 +20,7 @@ interface SchemaParser /** * Gets the database connection. + * * @return PDO */ public function getConnection(); @@ -42,12 +43,14 @@ public function setGeneratorConfig(GeneratorConfigInterface $config); * Gets a specific propel (renamed) property from the build. * * @param string $name + * * @return mixed */ public function getBuildProperty($name); /** * Gets array of warning messages. + * * @return array string[] */ public function getWarnings(); diff --git a/generator/lib/reverse/mssql/MssqlSchemaParser.php b/generator/lib/reverse/mssql/MssqlSchemaParser.php index 2949bffca..c76d0e0a3 100644 --- a/generator/lib/reverse/mssql/MssqlSchemaParser.php +++ b/generator/lib/reverse/mssql/MssqlSchemaParser.php @@ -22,6 +22,7 @@ class MssqlSchemaParser extends BaseSchemaParser /** * Map MSSQL native types to Propel types. + * * @var array */ private static $mssqlTypeMap = array( @@ -63,9 +64,9 @@ class MssqlSchemaParser extends BaseSchemaParser "sql_variant" => PropelTypes::VARCHAR, ); - /** - * @see BaseSchemaParser::getTypeMapping() - */ + /** + * @see BaseSchemaParser::getTypeMapping() + */ protected function getTypeMapping() { return self::$mssqlTypeMap; @@ -132,7 +133,7 @@ protected function addColumns(Table $table) $propelType = $this->getMappedPropelType($type); if (!$propelType) { $propelType = Column::DEFAULT_TYPE; - $this->warn("Column [" . $table->getName() . "." . $name. "] has a column type (".$type.") that Propel does not support."); + $this->warn("Column [" . $table->getName() . "." . $name . "] has a column type (" . $type . ") that Propel does not support."); } $column = new Column($name); @@ -165,7 +166,7 @@ protected function addForeignKeys(Table $table) CONSTRAINT_TYPE = 'Foreign Key' INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc1 ON rc1.CONSTRAINT_NAME = tc1.CONSTRAINT_NAME INNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu2 ON ccu2.CONSTRAINT_NAME = rc1.UNIQUE_CONSTRAINT_NAME - WHERE (ccu1.table_name = '".$table->getName()."')"); + WHERE (ccu1.table_name = '" . $table->getName() . "')"); $foreignKeys = array(); // local store to avoid duplicates while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { @@ -176,7 +177,7 @@ protected function addForeignKeys(Table $table) $foreignTable = $database->getTable($ftbl); $foreignColumn = $foreignTable->getColumn($fcol); - $localColumn = $table->getColumn($lcol); + $localColumn = $table->getColumn($lcol); if (!isset($foreignKeys[$name])) { $fk = new ForeignKey($name); @@ -189,7 +190,6 @@ protected function addForeignKeys(Table $table) } $foreignKeys[$name]->addReference($localColumn, $foreignColumn); } - } /** @@ -224,7 +224,7 @@ protected function addPrimaryKey(Table $table) INNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ON INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_NAME = INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE.constraint_name WHERE (INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE = 'PRIMARY KEY') AND - (INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME = '".$table->getName()."')"); + (INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME = '" . $table->getName() . "')"); // Loop through the returned results, grouping the same key_name together // adding each column for that key. @@ -234,17 +234,18 @@ protected function addPrimaryKey(Table $table) } } - /** - * according to the identifier definition, we have to clean simple quote (') around the identifier name - * returns by mssql - * @see http://msdn.microsoft.com/library/ms175874.aspx - * - * @param string $identifier - * @return string - */ - protected function cleanDelimitedIdentifiers($identifier) - { - return preg_replace('/^\'(.*)\'$/U', '$1', $identifier); - } - + /** + * according to the identifier definition, we have to clean simple quote (') around the identifier name + * returns by mssql + * + * @see http://msdn.microsoft.com/library/ms175874.aspx + * + * @param string $identifier + * + * @return string + */ + protected function cleanDelimitedIdentifiers($identifier) + { + return preg_replace('/^\'(.*)\'$/U', '$1', $identifier); + } } diff --git a/generator/lib/reverse/mysql/MysqlSchemaParser.php b/generator/lib/reverse/mysql/MysqlSchemaParser.php index 1248c1e45..ec3af9248 100644 --- a/generator/lib/reverse/mysql/MysqlSchemaParser.php +++ b/generator/lib/reverse/mysql/MysqlSchemaParser.php @@ -159,7 +159,6 @@ protected function addColumns(Table $table) $column = $this->getColumnFromRow($row, $table); $table->addColumn($column); } - } // addColumn() /** @@ -168,6 +167,7 @@ protected function addColumns(Table $table) * * @param array $row An associative array with the following keys: * Field, Type, Null, Key, Default, Extra. + * * @return Column */ public function getColumnFromRow($row, Table $table) @@ -224,7 +224,7 @@ public function getColumnFromRow($row, Table $table) if (!$propelType) { $propelType = Column::DEFAULT_TYPE; $sqlType = $row['Type']; - $this->warn("Column [" . $table->getName() . "." . $name. "] has a column type (".$nativeType.") that Propel does not support."); + $this->warn("Column [" . $table->getName() . "." . $name . "] has a column type (" . $nativeType . ") that Propel does not support."); } // Special case for TINYINT(1) which is a BOOLEAN @@ -242,8 +242,12 @@ public function getColumnFromRow($row, Table $table) $column->getDomain()->replaceScale($scale); if ($default !== null) { if ($propelType == PropelTypes::BOOLEAN) { - if ($default == '1') $default = 'true'; - if ($default == '0') $default = 'false'; + if ($default == '1') { + $default = 'true'; + } + if ($default == '0') { + $default = 'false'; + } } if (in_array($default, array('CURRENT_TIMESTAMP'))) { $type = ColumnDefaultValue::TYPE_EXPR; @@ -270,14 +274,14 @@ protected function addForeignKeys(Table $table) { $database = $table->getDatabase(); - $stmt = $this->dbh->query("SHOW CREATE TABLE `" . $table->getName(). "`"); + $stmt = $this->dbh->query("SHOW CREATE TABLE `" . $table->getName() . "`"); $row = $stmt->fetch(PDO::FETCH_NUM); $foreignKeys = array(); // local store to avoid duplicates // Get the information on all the foreign keys $regEx = '/CONSTRAINT `([^`]+)` FOREIGN KEY \((.+)\) REFERENCES `([^`]*)` \((.+)\)(.*)/'; - if (preg_match_all($regEx,$row[1],$matches)) { + if (preg_match_all($regEx, $row[1], $matches)) { $tmpArray = array_keys($matches[0]); foreach ($tmpArray as $curKey) { $name = $matches[1][$curKey]; @@ -305,7 +309,7 @@ protected function addForeignKeys(Table $table) if ($fkey) { //split foreign key information -> search for ON DELETE and afterwords for ON UPDATE action foreach (array_keys($fkactions) as $fkaction) { - $result = NULL; + $result = null; preg_match('/' . $fkaction . ' (' . ForeignKey::CASCADE . '|' . ForeignKey::SETNULL . ')/', $fkey, $result); if ($result && is_array($result) && isset($result[1])) { $fkactions[$fkaction] = $result[1]; @@ -322,7 +326,6 @@ protected function addForeignKeys(Table $table) $localColumns = array(); $foreignColumns = array(); - ; $foreignTable = $database->getTable($ftbl, true); foreach ($fcols as $fcol) { @@ -342,14 +345,11 @@ protected function addForeignKeys(Table $table) $foreignKeys[$name] = $fk; } - for ($i=0; $i < count($localColumns); $i++) { + for ($i = 0; $i < count($localColumns); $i++) { $foreignKeys[$name]->addReference($localColumns[$i], $foreignColumns[$i]); } - } - } - } /** diff --git a/generator/lib/reverse/oracle/OracleSchemaParser.php b/generator/lib/reverse/oracle/OracleSchemaParser.php index 0bade9029..e850ec3b9 100644 --- a/generator/lib/reverse/oracle/OracleSchemaParser.php +++ b/generator/lib/reverse/oracle/OracleSchemaParser.php @@ -68,8 +68,10 @@ protected function getTypeMapping() /** * Searches for tables in the database. Maybe we want to search also the views. + * * @param Database $database The Database model class to add tables to. * @param Task $task + * * @return int */ public function parse(Database $database, Task $task = null) @@ -77,11 +79,11 @@ public function parse(Database $database, Task $task = null) $tables = array(); $stmt = $this->dbh->query("SELECT OBJECT_NAME FROM USER_OBJECTS WHERE OBJECT_TYPE = 'TABLE'"); - $seqPattern = $this->getGeneratorConfig()->getBuildProperty( - 'oracleAutoincrementSequencePattern' - ); + $seqPattern = $this->getGeneratorConfig()->getBuildProperty('oracleAutoincrementSequencePattern'); - if ($task) $task->log("Reverse Engineering Table Structures", Project::MSG_VERBOSE); + if ($task) { + $task->log("Reverse Engineering Table Structures", Project::MSG_VERBOSE); + } // First load the tables (important that this happen before filling out details of tables) while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { if (strpos($row['OBJECT_NAME'], '$') !== false) { @@ -93,7 +95,9 @@ public function parse(Database $database, Task $task = null) } $table = new Table($row['OBJECT_NAME']); $table->setIdMethod($database->getDefaultIdMethod()); - if ($task) $task->log("Adding table '" . $table->getName() . "'", Project::MSG_VERBOSE); + if ($task) { + $task->log("Adding table '" . $table->getName() . "'", Project::MSG_VERBOSE); + } $database->addTable($table); // Add columns, primary keys and indexes. $this->addColumns($table); @@ -119,10 +123,14 @@ public function parse(Database $database, Task $task = null) $tables[] = $table; } - if ($task) $task->log("Reverse Engineering Foreign Keys", Project::MSG_VERBOSE); + if ($task) { + $task->log("Reverse Engineering Foreign Keys", Project::MSG_VERBOSE); + } foreach ($tables as $table) { - if ($task) $task->log("Adding foreign keys for table '" . $table->getName() . "'", Project::MSG_VERBOSE); + if ($task) { + $task->log("Adding foreign keys for table '" . $table->getName() . "'", Project::MSG_VERBOSE); + } $this->addForeignKeys($table); } @@ -154,7 +162,7 @@ protected function addColumns(Table $table) if ($type == "NUMBER" && $size > 9) { $type = "BIGINT"; } - if ($type == "FLOAT"&& $row["DATA_PRECISION"] == 126) { + if ($type == "FLOAT" && $row["DATA_PRECISION"] == 126) { $type = "DOUBLE"; } if (strpos($type, 'TIMESTAMP(') !== false) { @@ -172,7 +180,7 @@ protected function addColumns(Table $table) $propelType = $this->getMappedPropelType($type); if (!$propelType) { $propelType = Column::DEFAULT_TYPE; - $this->warn("Column [" . $table->getName() . "." . $row['COLUMN_NAME']. "] has a column type (".$row["DATA_TYPE"].") that Propel does not support."); + $this->warn("Column [" . $table->getName() . "." . $row['COLUMN_NAME'] . "] has a column type (" . $row["DATA_TYPE"] . ") that Propel does not support."); } $column = new Column($row['COLUMN_NAME']); @@ -188,7 +196,6 @@ protected function addColumns(Table $table) $column->setNotNull(!$isNullable); $table->addColumn($column); } - } // addColumn() /** @@ -203,7 +210,7 @@ protected function addIndexes(Table $table) $indices = array(); foreach ($rows as $row) { - $indices[$row['INDEX_NAME']][]= $row['COLUMN_NAME']; + $indices[$row['INDEX_NAME']][] = $row['COLUMN_NAME']; } foreach ($indices as $indexName => $columnNames) { @@ -232,16 +239,16 @@ protected function addForeignKeys(Table $table) // local store to avoid duplicates $foreignKeys = array(); - $stmt = $this->dbh->query("SELECT CONSTRAINT_NAME, DELETE_RULE, R_CONSTRAINT_NAME FROM USER_CONSTRAINTS WHERE CONSTRAINT_TYPE = 'R' AND TABLE_NAME = '" . $table->getName(). "'"); + $stmt = $this->dbh->query("SELECT CONSTRAINT_NAME, DELETE_RULE, R_CONSTRAINT_NAME FROM USER_CONSTRAINTS WHERE CONSTRAINT_TYPE = 'R' AND TABLE_NAME = '" . $table->getName() . "'"); /* @var stmt PDOStatement */ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { // Local reference - $stmt2 = $this->dbh->query("SELECT COLUMN_NAME FROM USER_CONS_COLUMNS WHERE CONSTRAINT_NAME = '".$row['CONSTRAINT_NAME']."' AND TABLE_NAME = '" . $table->getName(). "'"); + $stmt2 = $this->dbh->query("SELECT COLUMN_NAME FROM USER_CONS_COLUMNS WHERE CONSTRAINT_NAME = '" . $row['CONSTRAINT_NAME'] . "' AND TABLE_NAME = '" . $table->getName() . "'"); /* @var stmt2 PDOStatement */ $localReferenceInfo = $stmt2->fetch(PDO::FETCH_ASSOC); // Foreign reference - $stmt2 = $this->dbh->query("SELECT TABLE_NAME, COLUMN_NAME FROM USER_CONS_COLUMNS WHERE CONSTRAINT_NAME = '".$row['R_CONSTRAINT_NAME']."'"); + $stmt2 = $this->dbh->query("SELECT TABLE_NAME, COLUMN_NAME FROM USER_CONS_COLUMNS WHERE CONSTRAINT_NAME = '" . $row['R_CONSTRAINT_NAME'] . "'"); $foreignReferenceInfo = $stmt2->fetch(PDO::FETCH_ASSOC); if (!isset($foreignKeys[$row["CONSTRAINT_NAME"]])) { @@ -264,7 +271,7 @@ protected function addForeignKeys(Table $table) */ protected function addPrimaryKey(Table $table) { - $stmt = $this->dbh->query("SELECT COLS.COLUMN_NAME FROM USER_CONSTRAINTS CONS, USER_CONS_COLUMNS COLS WHERE CONS.CONSTRAINT_NAME = COLS.CONSTRAINT_NAME AND CONS.TABLE_NAME = '".$table->getName()."' AND CONS.CONSTRAINT_TYPE = 'P'"); + $stmt = $this->dbh->query("SELECT COLS.COLUMN_NAME FROM USER_CONSTRAINTS CONS, USER_CONS_COLUMNS COLS WHERE CONS.CONSTRAINT_NAME = COLS.CONSTRAINT_NAME AND CONS.TABLE_NAME = '" . $table->getName() . "' AND CONS.CONSTRAINT_TYPE = 'P'"); /* @var stmt PDOStatement */ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { // This fixes a strange behavior by PDO. Sometimes the @@ -275,5 +282,4 @@ protected function addPrimaryKey(Table $table) $table->getColumn($row['COLUMN_NAME'])->setPrimaryKey(true); } } - } diff --git a/generator/lib/reverse/pgsql/PgsqlSchemaParser.php b/generator/lib/reverse/pgsql/PgsqlSchemaParser.php index 1515453e2..33a02131d 100644 --- a/generator/lib/reverse/pgsql/PgsqlSchemaParser.php +++ b/generator/lib/reverse/pgsql/PgsqlSchemaParser.php @@ -84,8 +84,8 @@ public function parse(Database $database, Task $task = null) throw new EngineException("Failed to get database version"); } - $arrVersion = sscanf ($nativeVersion, '%*s %d.%d'); - $version = sprintf ("%d.%d", $arrVersion[0], $arrVersion[1]); + $arrVersion = sscanf($nativeVersion, '%*s %d.%d'); + $version = sprintf("%d.%d", $arrVersion[0], $arrVersion[1]); // Clean up $stmt = null; @@ -102,14 +102,18 @@ public function parse(Database $database, Task $task = null) $tableWraps = array(); // First load the tables (important that this happen before filling out details of tables) - if ($task) $task->log("Reverse Engineering Tables", Project::MSG_VERBOSE); + if ($task) { + $task->log("Reverse Engineering Tables", Project::MSG_VERBOSE); + } while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $name = $row['relname']; $namespacename = $row['nspname']; if ($name == $this->getMigrationTable()) { continue; } - if ($task) $task->log(" Adding table '" . $name . "' in schema '" . $namespacename . "'", Project::MSG_VERBOSE); + if ($task) { + $task->log(" Adding table '" . $name . "' in schema '" . $namespacename . "'", Project::MSG_VERBOSE); + } $oid = $row['oid']; $table = new Table($name); if ($namespacename != 'public') { @@ -126,16 +130,24 @@ public function parse(Database $database, Task $task = null) } // Now populate only columns. - if ($task) $task->log("Reverse Engineering Columns", Project::MSG_VERBOSE); + if ($task) { + $task->log("Reverse Engineering Columns", Project::MSG_VERBOSE); + } foreach ($tableWraps as $wrap) { - if ($task) $task->log(" Adding columns for table '" . $wrap->table->getName() . "'", Project::MSG_VERBOSE); + if ($task) { + $task->log(" Adding columns for table '" . $wrap->table->getName() . "'", Project::MSG_VERBOSE); + } $this->addColumns($wrap->table, $wrap->oid, $version); } // Now add indexes and constraints. - if ($task) $task->log("Reverse Engineering Indices And Constraints", Project::MSG_VERBOSE); + if ($task) { + $task->log("Reverse Engineering Indices And Constraints", Project::MSG_VERBOSE); + } foreach ($tableWraps as $wrap) { - if ($task) $task->log(" Adding indices and constraints for table '" . $wrap->table->getName() . "'", Project::MSG_VERBOSE); + if ($task) { + $task->log(" Adding indices and constraints for table '" . $wrap->table->getName() . "'", Project::MSG_VERBOSE); + } $this->addForeignKeys($wrap->table, $wrap->oid, $version); $this->addIndexes($wrap->table, $wrap->oid, $version); $this->addPrimaryKey($wrap->table, $wrap->oid, $version); @@ -143,15 +155,15 @@ public function parse(Database $database, Task $task = null) // TODO - Handle Sequences ... return count($tableWraps); - } - /** + /** * Adds Columns to the specified table. * * @param Table $table The Table model class to add columns to. * @param int $oid The table OID * @param string $version The database version. + * * @throws EngineException */ protected function addColumns(Table $table, $oid, $version) @@ -192,25 +204,25 @@ protected function addColumns(Table $table, $oid, $version) // Check to ensure that this column isn't an array data type if (((int) $row['isarray']) === 1) { - throw new EngineException (sprintf ("Array datatypes are not currently supported [%s.%s]", $this->name, $row['attname'])); + throw new EngineException (sprintf("Array datatypes are not currently supported [%s.%s]", $this->name, $row['attname'])); } // if (((int) $row['isarray']) === 1) $name = $row['attname']; // If they type is a domain, Process it - if (strtolower ($row['typtype']) == 'd') { - $arrDomain = $this->processDomain ($row['typname']); + if (strtolower($row['typtype']) == 'd') { + $arrDomain = $this->processDomain($row['typname']); $type = $arrDomain['type']; $size = $arrDomain['length']; $precision = $size; $scale = $arrDomain['scale']; - $boolHasDefault = (strlen (trim ($row['atthasdef'])) > 0) ? $row['atthasdef'] : $arrDomain['hasdefault']; - $default = (strlen (trim ($row['adsrc'])) > 0) ? $row['adsrc'] : $arrDomain['default']; - $is_nullable = (strlen (trim ($row['attnotnull'])) > 0) ? $row['attnotnull'] : $arrDomain['notnull']; + $boolHasDefault = (strlen(trim($row['atthasdef'])) > 0) ? $row['atthasdef'] : $arrDomain['hasdefault']; + $default = (strlen(trim($row['adsrc'])) > 0) ? $row['adsrc'] : $arrDomain['default']; + $is_nullable = (strlen(trim($row['attnotnull'])) > 0) ? $row['attnotnull'] : $arrDomain['notnull']; $is_nullable = (($is_nullable == 't') ? false : true); } else { $type = $row['typname']; - $arrLengthPrecision = $this->processLengthScale ($row['atttypmod'], $type); + $arrLengthPrecision = $this->processLengthScale($row['atttypmod'], $type); $size = $arrLengthPrecision['length']; $precision = $size; $scale = $arrLengthPrecision['scale']; @@ -222,10 +234,10 @@ protected function addColumns(Table $table, $oid, $version) $autoincrement = null; // if column has a default - if (($boolHasDefault == 't') && (strlen (trim ($default)) > 0)) { + if (($boolHasDefault == 't') && (strlen(trim($default)) > 0)) { if (!preg_match('/^nextval\(/', $default)) { - $strDefault= preg_replace ('/::[\W\D]*/', '', $default); - $default = str_replace ("'", '', $strDefault); + $strDefault = preg_replace('/::[\W\D]*/', '', $default); + $default = str_replace("'", '', $strDefault); } else { $autoincrement = true; $default = null; @@ -237,7 +249,7 @@ protected function addColumns(Table $table, $oid, $version) $propelType = $this->getMappedPropelType($type); if (!$propelType) { $propelType = Column::DEFAULT_TYPE; - $this->warn("Column [" . $table->getName() . "." . $name. "] has a column type (".$type.") that Propel does not support."); + $this->warn("Column [" . $table->getName() . "." . $name . "] has a column type (" . $type . ") that Propel does not support."); } $column = new Column($name); @@ -260,14 +272,12 @@ protected function addColumns(Table $table, $oid, $version) $table->addColumn($column); } - - } // addColumn() private function processLengthScale($intTypmod, $strName) { // Define the return array - $arrRetVal = array ('length'=>null, 'scale'=>null); + $arrRetVal = array('length' => null, 'scale' => null); // Some datatypes don't have a Typmod if ($intTypmod == -1) { @@ -278,21 +288,18 @@ private function processLengthScale($intTypmod, $strName) if ($strName == $this->getMappedNativeType(PropelTypes::NUMERIC)) { $intLen = ($intTypmod - 4) >> 16; $intPrec = ($intTypmod - 4) & 0xffff; - $intLen = sprintf ("%ld", $intLen); + $intLen = sprintf("%ld", $intLen); if ($intPrec) { - $intPrec = sprintf ("%ld", $intPrec); + $intPrec = sprintf("%ld", $intPrec); } // if ($intPrec) $arrRetVal['length'] = $intLen; $arrRetVal['scale'] = $intPrec; } // if ($strName == $this->getMappedNativeType(PropelTypes::NUMERIC)) - elseif ($strName == $this->getMappedNativeType(PropelTypes::TIME) || $strName == 'timetz' - || $strName == $this->getMappedNativeType(PropelTypes::TIMESTAMP) || $strName == 'timestamptz' - || $strName == 'interval' || $strName == 'bit') - { - $arrRetVal['length'] = sprintf ("%ld", $intTypmod); + elseif ($strName == $this->getMappedNativeType(PropelTypes::TIME) || $strName == 'timetz' || $strName == $this->getMappedNativeType(PropelTypes::TIMESTAMP) || $strName == 'timestamptz' || $strName == 'interval' || $strName == 'bit') { + $arrRetVal['length'] = sprintf("%ld", $intTypmod); } // elseif (TIME, TIMESTAMP, INTERVAL, BIT) else { - $arrRetVal['length'] = sprintf ("%ld", ($intTypmod - 4)); + $arrRetVal['length'] = sprintf("%ld", ($intTypmod - 4)); } // else return $arrRetVal; @@ -300,7 +307,7 @@ private function processLengthScale($intTypmod, $strName) private function processDomain($strDomain) { - if (strlen(trim ($strDomain)) < 1) { + if (strlen(trim($strDomain)) < 1) { throw new EngineException ("Invalid domain name [" . $strDomain . "]"); } @@ -325,14 +332,14 @@ private function processDomain($strDomain) throw new EngineException ("Domain [" . $strDomain . "] not found."); } - $arrDomain = array (); + $arrDomain = array(); $arrDomain['type'] = $row['basetype']; $arrLengthPrecision = $this->processLengthScale($row['typtypmod'], $row['basetype']); $arrDomain['length'] = $arrLengthPrecision['length']; $arrDomain['scale'] = $arrLengthPrecision['scale']; $arrDomain['notnull'] = $row['typnotnull']; $arrDomain['default'] = $row['typdefault']; - $arrDomain['hasdefault'] = (strlen (trim ($row['typdefault'])) > 0) ? 't' : 'f'; + $arrDomain['hasdefault'] = (strlen(trim($row['typdefault'])) > 0) ? 't' : 'f'; $stmt = null; // cleanup @@ -382,37 +389,47 @@ protected function addForeignKeys(Table $table, $oid, $version) // On Update switch ($row['confupdtype']) { - case 'c': - $onupdate = ForeignKey::CASCADE; break; - case 'd': - $onupdate = ForeignKey::SETDEFAULT; break; - case 'n': - $onupdate = ForeignKey::SETNULL; break; - case 'r': - $onupdate = ForeignKey::RESTRICT; break; - default: - case 'a': - //NOACTION is the postgresql default - $onupdate = ForeignKey::NONE; break; + case 'c': + $onupdate = ForeignKey::CASCADE; + break; + case 'd': + $onupdate = ForeignKey::SETDEFAULT; + break; + case 'n': + $onupdate = ForeignKey::SETNULL; + break; + case 'r': + $onupdate = ForeignKey::RESTRICT; + break; + default: + case 'a': + //NOACTION is the postgresql default + $onupdate = ForeignKey::NONE; + break; } // On Delete switch ($row['confdeltype']) { - case 'c': - $ondelete = ForeignKey::CASCADE; break; - case 'd': - $ondelete = ForeignKey::SETDEFAULT; break; - case 'n': - $ondelete = ForeignKey::SETNULL; break; - case 'r': - $ondelete = ForeignKey::RESTRICT; break; - default: - case 'a': - //NOACTION is the postgresql default - $ondelete = ForeignKey::NONE; break; + case 'c': + $ondelete = ForeignKey::CASCADE; + break; + case 'd': + $ondelete = ForeignKey::SETDEFAULT; + break; + case 'n': + $ondelete = ForeignKey::SETNULL; + break; + case 'r': + $ondelete = ForeignKey::RESTRICT; + break; + default: + case 'a': + //NOACTION is the postgresql default + $ondelete = ForeignKey::NONE; + break; } $foreignTable = $database->getTable($foreign_table); - $localTable = $database->getTable($local_table); + $localTable = $database->getTable($local_table); if (!isset($foreignKeys[$name])) { $fk = new ForeignKey($name); @@ -470,20 +487,18 @@ protected function addIndexes(Table $table, $oid, $version) $table->addIndex($indexes[$name]); } - $arrColumns = explode (' ', $row['indkey']); + $arrColumns = explode(' ', $row['indkey']); foreach ($arrColumns as $intColNum) { - $stmt2->bindValue(1, $oid); - $stmt2->bindValue(2, $intColNum); - $stmt2->execute(); + $stmt2->bindValue(1, $oid); + $stmt2->bindValue(2, $intColNum); + $stmt2->execute(); $row2 = $stmt2->fetch(PDO::FETCH_ASSOC); $indexes[$name]->addColumn($table->getColumn($row2['attname'])); - } // foreach ($arrColumns as $intColNum) } - } /** @@ -508,7 +523,7 @@ protected function addPrimaryKey(Table $table, $oid, $version) // adding each column for that key. while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - $arrColumns = explode (' ', $row['indkey']); + $arrColumns = explode(' ', $row['indkey']); foreach ($arrColumns as $intColNum) { $stmt2 = $this->dbh->prepare("SELECT a.attname FROM pg_catalog.pg_class c JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid @@ -520,10 +535,8 @@ protected function addPrimaryKey(Table $table, $oid, $version) $row2 = $stmt2->fetch(PDO::FETCH_ASSOC); $table->getColumn($row2['attname'])->setPrimaryKey(true); - } // foreach ($arrColumns as $intColNum) } - } /** @@ -559,5 +572,4 @@ protected function addSequences(Database $database) } */ } - } diff --git a/generator/lib/reverse/sqlite/SqliteSchemaParser.php b/generator/lib/reverse/sqlite/SqliteSchemaParser.php index 4812814de..d90bd4097 100644 --- a/generator/lib/reverse/sqlite/SqliteSchemaParser.php +++ b/generator/lib/reverse/sqlite/SqliteSchemaParser.php @@ -101,7 +101,6 @@ public function parse(Database $database, Task $task = null) } return count($tables); - } /** @@ -142,7 +141,7 @@ protected function addColumns(Table $table) $propelType = $this->getMappedPropelType(strtolower($type)); if (!$propelType) { $propelType = Column::DEFAULT_TYPE; - $this->warn("Column [" . $table->getName() . "." . $name. "] has a column type (".$type.") that Propel does not support."); + $this->warn("Column [" . $table->getName() . "." . $name . "] has a column type (" . $type . ") that Propel does not support."); } $column = new Column($name); @@ -163,9 +162,7 @@ protected function addColumns(Table $table) } $table->addColumn($column); - } - } // addColumn() /** @@ -180,15 +177,13 @@ protected function addIndexes(Table $table) $name = $row['name']; $index = new Index($name); - $stmt2 = $this->dbh->query("PRAGMA index_info('".$name."')"); + $stmt2 = $this->dbh->query("PRAGMA index_info('" . $name . "')"); while ($row2 = $stmt2->fetch(PDO::FETCH_ASSOC)) { $colname = $row2['name']; $index->addColumn($table->getColumn($colname)); } $table->addIndex($index); - } } - } diff --git a/generator/lib/task/AbstractPropelDataModelTask.php b/generator/lib/task/AbstractPropelDataModelTask.php index 7d91a6082..7ba129f0b 100644 --- a/generator/lib/task/AbstractPropelDataModelTask.php +++ b/generator/lib/task/AbstractPropelDataModelTask.php @@ -31,6 +31,7 @@ abstract class AbstractPropelDataModelTask extends Task /** * Fileset of XML schemas which represent our data models. + * * @var array Fileset[] */ protected $schemaFilesets = array(); @@ -42,6 +43,7 @@ abstract class AbstractPropelDataModelTask extends Task /** * Have datamodels been initialized? + * * @var boolean */ private $dataModelsLoaded = false; @@ -79,54 +81,63 @@ abstract class AbstractPropelDataModelTask extends Task /** * Destination directory for results of template scripts. + * * @var PhingFile */ protected $outputDirectory; /** * Whether to package the datamodels or not + * * @var PhingFile */ protected $packageObjectModel; /** * Whether to perform validation (XSD) on the schema.xml file(s). + * * @var boolean */ protected $validate; /** * The XSD schema file to use for validation. + * * @var PhingFile */ protected $xsdFile; /** * XSL file to use to normalize (or otherwise transform) schema before validation. + * * @var PhingFile */ protected $xslFile; /** * Optional database connection url. + * * @var string */ private $url = null; /** * Optional database connection user name. + * * @var string */ private $userId = null; /** * Optional database connection password. + * * @var string */ private $password = null; /** * PDO Connection. + * * @var PDO */ private $conn = false; @@ -230,6 +241,7 @@ public function setPackageObjectModel($v) /** * Set whether to perform validation on the datamodel schema.xml file(s). + * * @param boolean $v */ public function setValidate($v) @@ -239,6 +251,7 @@ public function setValidate($v) /** * Set the XSD schema to use for validation of any datamodel schema.xml file(s). + * * @param $v PhingFile */ public function setXsd(PhingFile $v) @@ -248,6 +261,7 @@ public function setXsd(PhingFile $v) /** * Set the normalization XSLT to use to transform datamodel schema.xml file(s) before validation and parsing. + * * @param $v PhingFile */ public function setXsl(PhingFile $v) @@ -258,7 +272,9 @@ public function setXsl(PhingFile $v) /** * [REQUIRED] Set the output directory. It will be * created if it doesn't exist. + * * @param PhingFile $outputDirectory + * * @return void * @throws BuildException */ @@ -266,7 +282,7 @@ public function setOutputDirectory(PhingFile $outputDirectory) { try { if (!$outputDirectory->exists()) { - $this->log("Output directory does not exist, creating: " . $outputDirectory->getPath(),Project::MSG_VERBOSE); + $this->log("Output directory does not exist, creating: " . $outputDirectory->getPath(), Project::MSG_VERBOSE); if (!$outputDirectory->mkdirs()) { throw new IOException("Unable to create Output directory: " . $outputDirectory->getAbsolutePath()); } @@ -319,6 +335,7 @@ public function setPassword($password) /** * Get the output directory. + * * @return string */ public function getOutputDirectory() @@ -344,7 +361,9 @@ public function createMapper() /** * Maps the passed in name to a new filename & returns resolved File object. + * * @param string $from + * * @return PhingFile Resolved File object. * @throws BuildException - if no Mapper element se * - if unable to map new filename. @@ -369,6 +388,7 @@ protected function getMappedFile($from) /** * Gets the PDO connection, if URL specified. + * * @return PDO Connection to use (for quoting, Platform class, etc.) or NULL if no connection params were specified. */ public function getConnection() @@ -384,8 +404,12 @@ public function getConnection() $this->log($buf, Project::MSG_VERBOSE); // Set user + password to null if they are empty strings - if (!$this->userId) { $this->userId = null; } - if (!$this->password) { $this->password = null; } + if (!$this->userId) { + $this->userId = null; + } + if (!$this->password) { + $this->password = null; + } try { $this->conn = new PDO($this->url, $this->userId, $this->password); $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -400,6 +424,7 @@ public function getConnection() /** * Gets all matching XML schema files and loads them into data models for class. + * * @return void * @throws EngineException * @throws BuildException @@ -422,7 +447,7 @@ protected function loadDataModels() // Make a transaction for each file foreach ($dataModelFiles as $dmFilename) { - $this->log("Processing: ".$dmFilename, Project::MSG_VERBOSE); + $this->log("Processing: " . $dmFilename, Project::MSG_VERBOSE); $xmlFile = new PhingFile($srcDir, $dmFilename); $dom = new DomDocument('1.0', 'UTF-8'); @@ -450,7 +475,7 @@ protected function loadDataModels() if ($this->validate && $this->xsdFile) { $this->log(" Validating XML using schema " . $this->xsdFile->getPath(), Project::MSG_VERBOSE); if (!$dom->schemaValidate($this->xsdFile->getAbsolutePath())) { - throw new EngineException("XML schema file (".$xmlFile->getPath().") does not validate. See warnings above for reasons validation failed (make sure error_reporting is set to show E_WARNING if you don't see any).", $this->getLocation()); + throw new EngineException("XML schema file (" . $xmlFile->getPath() . ") does not validate. See warnings above for reasons validation failed (make sure error_reporting is set to show E_WARNING if you don't see any).", $this->getLocation()); } } @@ -476,7 +501,7 @@ protected function loadDataModels() $this->dataModelDbMap[$ad->getName()] = $ad->getDatabase(null, false)->getName(); } - if (count($ads)>1 && $this->packageObjectModel) { + if (count($ads) > 1 && $this->packageObjectModel) { $ad = $this->joinDataModels($ads); $this->dataModels = array($ad); } else { @@ -508,6 +533,7 @@ protected function loadDataModels() * * @param DomDocument $dom * @param string $srcDir + * * @return void (objects, DomDocument, are references by default in PHP 5, so returning it is useless) **/ protected function includeExternalSchemas(DomDocument $dom, $srcDir) @@ -544,6 +570,7 @@ protected function includeExternalSchemas(DomDocument $dom, $srcDir) * that point to tables in different packages. * * @param array[AppData] $ads The datamodels to join + * * @return AppData The single datamodel with all other datamodels joined in */ protected function joinDataModels($ads) @@ -556,6 +583,7 @@ protected function joinDataModels($ads) /** * Gets the GeneratorConfig object for this task or creates it on-demand. + * * @return GeneratorConfig */ protected function getGeneratorConfig() @@ -572,7 +600,7 @@ protected function getGeneratorConfig() * Checks this class against Basic requirements of any propel datamodel task. * * @throws BuildException - if schema fileset was not defined - * - if no output directory was specified + * - if no output directory was specified */ protected function validate() { @@ -590,7 +618,5 @@ protected function validate() throw new BuildException("'validate' set to TRUE, but no XSD specified (use 'xsd' attribute).", $this->getLocation()); } } - } - } diff --git a/generator/lib/task/BasePropelMigrationTask.php b/generator/lib/task/BasePropelMigrationTask.php index bce87963f..99dd6872d 100644 --- a/generator/lib/task/BasePropelMigrationTask.php +++ b/generator/lib/task/BasePropelMigrationTask.php @@ -20,6 +20,7 @@ abstract class BasePropelMigrationTask extends Task { /** * Destination directory for results of template scripts. + * * @var PhingFile */ protected $outputDirectory; @@ -33,6 +34,7 @@ abstract class BasePropelMigrationTask extends Task /** * The migration table name + * * @var string */ protected $migrationTable = 'propel_migration'; @@ -60,7 +62,9 @@ public function getMigrationTable() /** * [REQUIRED] Set the output directory. It will be * created if it doesn't exist. + * * @param PhingFile $outputDirectory + * * @return void * @throws BuildException */ @@ -68,7 +72,7 @@ public function setOutputDirectory(PhingFile $outputDirectory) { try { if (!$outputDirectory->exists()) { - $this->log("Output directory does not exist, creating: " . $outputDirectory->getPath(),Project::MSG_VERBOSE); + $this->log("Output directory does not exist, creating: " . $outputDirectory->getPath(), Project::MSG_VERBOSE); if (!$outputDirectory->mkdirs()) { throw new IOException("Unable to create Ouptut directory: " . $outputDirectory->getAbsolutePath()); } @@ -81,6 +85,7 @@ public function setOutputDirectory(PhingFile $outputDirectory) /** * Get the output directory. + * * @return string */ public function getOutputDirectory() @@ -90,6 +95,7 @@ public function getOutputDirectory() /** * Gets the GeneratorConfig object for this task or creates it on-demand. + * * @return GeneratorConfig */ protected function getGeneratorConfig() @@ -101,5 +107,4 @@ protected function getGeneratorConfig() return $this->generatorConfig; } - } diff --git a/generator/lib/task/PropelConvertConfTask.php b/generator/lib/task/PropelConvertConfTask.php index 16f7c7cc9..f795b450a 100644 --- a/generator/lib/task/PropelConvertConfTask.php +++ b/generator/lib/task/PropelConvertConfTask.php @@ -39,6 +39,7 @@ class PropelConvertConfTask extends AbstractPropelDataModelTask /** * [REQUIRED] Set the input XML runtime conf file. + * * @param PhingFile $v The XML runtime configuration file to be converted. */ public function setXmlConfFile(PhingFile $v) @@ -49,7 +50,9 @@ public function setXmlConfFile(PhingFile $v) /** * [REQUIRED] Set the output filename for the converted runtime conf. * The directory is specified using AbstractPropelDataModelTask#setOutputDirectory(). + * * @param string $outputFile + * * @see AbstractPropelDataModelTask#setOutputDirectory() */ public function setOutputFile($outputFile) @@ -61,7 +64,9 @@ public function setOutputFile($outputFile) /** * [REQUIRED] Set the output filename for the autoload classmap. * The directory is specified using AbstractPropelDataModelTask#setOutputDirectory(). + * * @param string $outputFile + * * @see AbstractPropelDataModelTask#setOutputDirectory() */ public function setOutputClassmapFile($outputFile) @@ -119,12 +124,12 @@ public function main() // Write resulting PHP data to output file $outfile = new PhingFile($this->outputDirectory, $this->outputFile); $output = "getGeneratorConfig()->getBuildProperty('addTimestamp') ? " on " . strftime("%c") : '') . "\n"; + $output .= "// This file generated by Propel " . $phpconf['generator_version'] . " convert-conf target" . ($this->getGeneratorConfig()->getBuildProperty('addTimestamp') ? " on " . strftime("%c") : '') . "\n"; $output .= "// from XML runtime conf file " . $this->xmlConfFile->getPath() . "\n"; $output .= "\$conf = "; $output .= var_export($phpconf, true); $output .= ";\n"; - $output .= "\$conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '".$this->outputClassmapFile."');\n"; + $output .= "\$conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '" . $this->outputClassmapFile . "');\n"; $output .= "return \$conf;"; $mustWriteRuntimeConf = true; @@ -147,7 +152,7 @@ public function main() $phpconfClassmap = $this->getClassMap(); $outfile = new PhingFile($this->outputDirectory, $this->outputClassmapFile); $output = '<' . '?' . "php\n"; - $output .= "// This file generated by Propel " . $phpconf['generator_version'] . " convert-conf target".($this->getGeneratorConfig()->getBuildProperty('addTimestamp') ? " on " . strftime("%c") : '') . "\n"; + $output .= "// This file generated by Propel " . $phpconf['generator_version'] . " convert-conf target" . ($this->getGeneratorConfig()->getBuildProperty('addTimestamp') ? " on " . strftime("%c") : '') . "\n"; $output .= "return "; $output .= var_export($phpconfClassmap, true); $output .= ";"; @@ -181,7 +186,6 @@ public function main() if (!$mustWriteRuntimeConf && !$mustWriteClassMap) { $this->log('No change in compiled configuration files'); } - } // main() protected function logClassMap($classMap) @@ -190,35 +194,38 @@ protected function logClassMap($classMap) $this->log(sprintf(' %-15s => %s', $className, $classPath), Project::MSG_VERBOSE); } } + /** * Recursive function that converts an SimpleXML object into an array. + * * @author Christophe VG (based on code form php.net manual comment) + * * @param object SimpleXML object. + * * @return array Array representation of SimpleXML object. */ protected static function simpleXmlToArray($xml) { $ar = array(); - foreach ( $xml->children() as $k => $v ) { + foreach ($xml->children() as $k => $v) { // recurse the child - $child = self::simpleXmlToArray( $v ); + $child = self::simpleXmlToArray($v); //print "Recursed down and found: " . var_export($child, true) . "\n"; // if it's not an array, then it was empty, thus a value/string - if ( count($child) == 0 ) { + if (count($child) == 0) { $child = self::getConvertedXmlValue($v); - } // add the children attributes as if they where children - foreach ( $v->attributes() as $ak => $av ) { + foreach ($v->attributes() as $ak => $av) { // if the child is not an array, transform it into one - if ( !is_array( $child ) ) { - $child = array( "value" => $child ); + if (!is_array($child)) { + $child = array("value" => $child); } if ($ak == 'id') { @@ -233,7 +240,7 @@ protected static function simpleXmlToArray($xml) // if the $k is already in our children list, we need to transform // it into an array, else we add it as a value - if ( !in_array( $k, array_keys($ar) ) ) { + if (!in_array($k, array_keys($ar))) { $ar[$k] = $child; } else { // (This only applies to nested nodes that do not have an @id attribute) @@ -243,10 +250,11 @@ protected static function simpleXmlToArray($xml) // array, that it has numeric keys. this distinguishes it from simply having other // nested element data. - if ( !is_array($ar[$k]) || !isset($ar[$k][0]) ) { $ar[$k] = array($ar[$k]); } + if (!is_array($ar[$k]) || !isset($ar[$k][0])) { + $ar[$k] = array($ar[$k]); + } $ar[$k][] = $child; } - } return $ar; @@ -254,7 +262,9 @@ protected static function simpleXmlToArray($xml) /** * Process XML value, handling boolean, if appropriate. + * * @param object The simplexml value object. + * * @return mixed */ private static function getConvertedXmlValue($value) @@ -274,6 +284,7 @@ private static function getConvertedXmlValue($value) /** * Lists data model classes and builds an associative array className => classPath * To be used for autoloading + * * @return array */ protected function getClassMap() @@ -380,7 +391,6 @@ protected function getClassMap() $classMap[$builder->getFullyQualifiedClassname()] = $builder->getClassFilePath(); } } - } // if (!$table->isReferenceOnly()) } diff --git a/generator/lib/task/PropelDataDumpTask.php b/generator/lib/task/PropelDataDumpTask.php index 60e61abad..11cf041a5 100644 --- a/generator/lib/task/PropelDataDumpTask.php +++ b/generator/lib/task/PropelDataDumpTask.php @@ -49,18 +49,21 @@ class PropelDataDumpTask extends AbstractPropelDataModelTask /** * Database user used for Propel connection. + * * @deprecated Put username in databaseUrl. */ private $databaseUser; /** * Database password used for Propel connection. + * * @deprecated Put password in databaseUrl. */ private $databasePassword; /** * Properties file that maps a data XML file to a particular database. + * * @var PhingFile */ private $datadbmap; @@ -80,6 +83,7 @@ class PropelDataDumpTask extends AbstractPropelDataModelTask * Set the file that maps between data XML files and databases. * * @param PhingFile $datadbmap the db map + * * @return void */ public function setDataDbMap(PhingFile $datadbmap) @@ -152,6 +156,7 @@ public function getDatabaseUser() * Set the database user * * @param string $v The new DatabaseUser value + * * @deprecated Specify user in DSN URL. */ public function setDatabaseUser($v) @@ -173,6 +178,7 @@ public function getDatabasePassword() * Set the database password * * @param string $v The new DatabasePassword value + * * @deprecated Specify database password in DSN URL. */ public function setDatabasePassword($v) @@ -223,7 +229,7 @@ private function createDataDbMap() $datadbmap->load($this->getDataDbMap()); } - foreach ($this->getDataModels() as $dataModel) { // there is really one 1 db per datamodel + foreach ($this->getDataModels() as $dataModel) { // there is really one 1 db per datamodel foreach ($dataModel->getDatabases() as $database) { // if database name is specified, then we only want to dump that one db. @@ -237,7 +243,7 @@ private function createDataDbMap() try { $datadbmap->store($this->getDataDbMap(), "Data XML file -> Database map"); } catch (IOException $e) { - throw new IOException("Unable to store properties: ". $e->getMessage()); + throw new IOException("Unable to store properties: " . $e->getMessage()); } } @@ -263,7 +269,7 @@ public function main() $this->createDataDbMap(); // 2) Now go create the XML files from teh database(s) - foreach ($this->getDataModels() as $dataModel) { // there is really one 1 db per datamodel + foreach ($this->getDataModels() as $dataModel) { // there is really one 1 db per datamodel foreach ($dataModel->getDatabases() as $database) { // if database name is specified, then we only want to dump that one db. @@ -291,9 +297,8 @@ public function main() $doc = $this->createXMLDoc($database); $doc->save($outFile->getAbsolutePath()); - } catch (SQLException $se) { - $this->log("SQLException while connecting to DB: ". $se->getMessage(), Project::MSG_ERR); + $this->log("SQLException while connecting to DB: " . $se->getMessage(), Project::MSG_ERR); throw new BuildException($se); } } // if databaseName && database->getName == databaseName @@ -303,18 +308,22 @@ public function main() /** * Gets PDOStatement of query to fetch all data from a table. + * * @param string $tableName * @param PropelPlatformInterface $platform + * * @return PDOStatement */ private function getTableDataStmt($tableName, PropelPlatformInterface $platform) { - return $this->conn->query("SELECT * FROM " . $platform->quoteIdentifier( $tableName ) ); + return $this->conn->query("SELECT * FROM " . $platform->quoteIdentifier($tableName)); } /** * Creates a DOM document containing data for specified database. + * * @param Database $database + * * @return DOMDocument */ private function createXMLDoc(Database $database) diff --git a/generator/lib/task/PropelDataSQLTask.php b/generator/lib/task/PropelDataSQLTask.php index ebfdafa19..d4cad90ca 100644 --- a/generator/lib/task/PropelDataSQLTask.php +++ b/generator/lib/task/PropelDataSQLTask.php @@ -28,18 +28,21 @@ class PropelDataSQLTask extends AbstractPropelDataModelTask /** * Properties file that maps an SQL file to a particular database. + * * @var PhingFile */ private $sqldbmap; /** * Properties file that maps a data XML file to a particular database. + * * @var PhingFile */ private $datadbmap; /** * The base directory in which to find data XML files. + * * @var PhingFile */ private $srcDir; @@ -48,6 +51,7 @@ class PropelDataSQLTask extends AbstractPropelDataModelTask * Set the file that maps between SQL files and databases. * * @param PhingFile $sqldbmap the sql -> db map. + * * @return void */ public function setSqlDbMap(PhingFile $sqldbmap) @@ -69,6 +73,7 @@ public function getSqlDbMap() * Set the file that maps between data XML files and databases. * * @param PhingFile $datadbmap the db map + * * @return void */ public function setDataDbMap(PhingFile $datadbmap) @@ -88,6 +93,7 @@ public function getDataDbMap() /** * Set the src directory for the data xml files listed in the datadbmap file. + * * @param PhingFile $srcDir data xml source directory */ public function setSrcDir(PhingFile $srcDir) @@ -107,6 +113,7 @@ public function getSrcDir() /** * Search through all data models looking for matching database. + * * @return Database or NULL if none found. */ private function getDatabase($name) @@ -181,12 +188,9 @@ public function main() $p->setProperty($outFile->getName(), $db->getName()); $p->store($this->getSqlDbMap(), "Sqlfile -> Database map"); - } else { - $this->log("File '" . $dataXMLFile->getAbsolutePath() - . "' in datadbmap does not exist, so skipping it.", Project::MSG_WARN); + $this->log("File '" . $dataXMLFile->getAbsolutePath() . "' in datadbmap does not exist, so skipping it.", Project::MSG_WARN); } - } // foreach data xml file } // main() diff --git a/generator/lib/task/PropelGraphvizTask.php b/generator/lib/task/PropelGraphvizTask.php index a2e3af91b..6493d728e 100644 --- a/generator/lib/task/PropelGraphvizTask.php +++ b/generator/lib/task/PropelGraphvizTask.php @@ -25,6 +25,7 @@ class PropelGraphvizTask extends AbstractPropelDataModelTask /** * The properties file that maps an SQL file to a particular database. + * * @var PhingFile */ private $sqldbmap; @@ -41,6 +42,7 @@ class PropelGraphvizTask extends AbstractPropelDataModelTask /** * Set the sqldbmap. + * * @param PhingFile $out The db map. */ public function setOutputDirectory(PhingFile $out) @@ -53,6 +55,7 @@ public function setOutputDirectory(PhingFile $out) /** * Set the sqldbmap. + * * @param PhingFile $sqldbmap The db map. */ public function setSqlDbMap(PhingFile $sqldbmap) @@ -62,6 +65,7 @@ public function setSqlDbMap(PhingFile $sqldbmap) /** * Get the sqldbmap. + * * @return PhingFile $sqldbmap. */ public function getSqlDbMap() @@ -71,6 +75,7 @@ public function getSqlDbMap() /** * Set the database name. + * * @param string $database */ public function setDatabase($database) @@ -80,6 +85,7 @@ public function setDatabase($database) /** * Get the database name. + * * @return string */ public function getDatabase() @@ -91,8 +97,8 @@ public function main() { foreach ($this->getDataModels() as $dataModel) { foreach ($dataModel->getDatabases() as $database) { - $this->log("db: " . $database->getName()); - $this->writeDot(PropelDotGenerator::create($database), $this->outDir, $database->getName()); + $this->log("db: " . $database->getName()); + $this->writeDot(PropelDotGenerator::create($database), $this->outDir, $database->getName()); } } } @@ -106,5 +112,4 @@ public function writeDot($dotSyntax, PhingFile $outputDir, $baseFilename) $this->log("Writing dot file to " . $file->getAbsolutePath()); file_put_contents($file->getAbsolutePath(), $dotSyntax); } - } diff --git a/generator/lib/task/PropelMigrationDownTask.php b/generator/lib/task/PropelMigrationDownTask.php index a8f257710..ff2b37581 100644 --- a/generator/lib/task/PropelMigrationDownTask.php +++ b/generator/lib/task/PropelMigrationDownTask.php @@ -36,10 +36,7 @@ public function main() return false; } - $this->log(sprintf( - 'Executing migration %s down', - $manager->getMigrationClassName($nextMigrationTimestamp) - )); + $this->log(sprintf('Executing migration %s down', $manager->getMigrationClassName($nextMigrationTimestamp))); if ($nbPreviousTimestamps = count($previousTimestamps)) { $previousTimestamp = array_pop($previousTimestamps); diff --git a/generator/lib/task/PropelOMTask.php b/generator/lib/task/PropelOMTask.php index 6a12f758d..8b383b3e7 100644 --- a/generator/lib/task/PropelOMTask.php +++ b/generator/lib/task/PropelOMTask.php @@ -23,12 +23,14 @@ class PropelOMTask extends AbstractPropelDataModelTask /** * The platform (php4, php5, etc.) for which the om is being built. + * * @var string */ private $targetPlatform; /** * Sets the platform (php4, php5, etc.) for which the om is being built. + * * @param string $v */ public function setTargetPlatform($v) @@ -38,6 +40,7 @@ public function setTargetPlatform($v) /** * Gets the platform (php4, php5, etc.) for which the om is being built. + * * @return string */ public function getTargetPlatform() @@ -47,7 +50,9 @@ public function getTargetPlatform() /** * Utility method to create directory for package if it doesn't already exist. + * * @param string $path The [relative] package path. + * * @throws BuildException - if there is an error creating directories */ protected function ensureDirExists($path) @@ -55,7 +60,7 @@ protected function ensureDirExists($path) $f = new PhingFile($this->getOutputDirectory(), $path); if (!$f->exists()) { if (!$f->mkdirs()) { - throw new BuildException("Error creating directories: ". $f->getPath()); + throw new BuildException("Error creating directories: " . $f->getPath()); } } } @@ -63,8 +68,10 @@ protected function ensureDirExists($path) /** * Uses a builder class to create the output class. * This method assumes that the DataModelBuilder class has been initialized with the build properties. + * * @param OMBuilder $builder * @param boolean $overwrite Whether to overwrite existing files with te new ones (default is YES). + * * @todo -cPropelOMTask Consider refactoring build() method into AbstractPropelDataModelTask (would need to be more generic). * @return int */ @@ -152,7 +159,7 @@ public function main() // these classes are only generated if they don't already exist foreach (array('peerstub', 'objectstub', 'querystub') as $target) { $builder = $generatorConfig->getConfiguredBuilder($table, $target); - $nbWrittenFiles += $this->build($builder, $overwrite=false); + $nbWrittenFiles += $this->build($builder, $overwrite = false); } // ----------------------------------------------------------------------------------------- @@ -169,12 +176,12 @@ public function main() } $builder = $generatorConfig->getConfiguredBuilder($table, $target); $builder->setChild($child); - $nbWrittenFiles += $this->build($builder, $overwrite=true); + $nbWrittenFiles += $this->build($builder, $overwrite = true); } foreach (array('objectmultiextend', 'queryinheritancestub') as $target) { $builder = $generatorConfig->getConfiguredBuilder($table, $target); $builder->setChild($child); - $nbWrittenFiles += $this->build($builder, $overwrite=false); + $nbWrittenFiles += $this->build($builder, $overwrite = false); } } // foreach } // if col->is enumerated @@ -188,7 +195,7 @@ public function main() // Create [empty] interface if it does not already exist if ($table->getInterface()) { $builder = $generatorConfig->getConfiguredBuilder($table, 'interface'); - $nbWrittenFiles += $this->build($builder, $overwrite=false); + $nbWrittenFiles += $this->build($builder, $overwrite = false); } // ----------------------------------------------------------------------------------------- @@ -202,7 +209,7 @@ public function main() $builder = $generatorConfig->getConfiguredBuilder($table, $target); $nbWrittenFiles += $this->build($builder); } - break; + break; case 'MaterializedPath': foreach (array('nodepeer', 'node') as $target) { @@ -212,16 +219,15 @@ public function main() foreach (array('nodepeerstub', 'nodestub') as $target) { $builder = $generatorConfig->getConfiguredBuilder($table, $target); - $nbWrittenFiles += $this->build($builder, $overwrite=false); + $nbWrittenFiles += $this->build($builder, $overwrite = false); } - break; + break; case 'AdjacencyList': // No implementation for this yet. default: - break; + break; } - } // if Table->treeMode() // ---------------------------------- diff --git a/generator/lib/task/PropelSQLExec.php b/generator/lib/task/PropelSQLExec.php index b3d45c697..c2145c3ce 100644 --- a/generator/lib/task/PropelSQLExec.php +++ b/generator/lib/task/PropelSQLExec.php @@ -110,6 +110,7 @@ public function getBuildConnections() * Get the buildtime connection settings for a given database name. * * @param string $database + * * @return array $buildConnections */ public function getBuildConnection($database) @@ -160,6 +161,7 @@ public function setUrl($url) * Set the user name for the DB connection. * * @param string $userId database user + * * @deprecated Specify userid in the DSN URL. */ public function setUserid($userId) @@ -171,6 +173,7 @@ public function setUserid($userId) * Set the password for the DB connection. * * @param string $password database password + * * @deprecated Specify password in the DSN URL. */ public function setPassword($password) @@ -210,8 +213,7 @@ public function main() $this->setBuildConnections($conf->getBuildConnections()); if ($this->sqldbmap === null || $this->getSqlDbMap()->exists() === false) { - throw new BuildException("You haven't provided an sqldbmap, or " - . "the one you specified doesn't exist: " . $this->sqldbmap->getPath()); + throw new BuildException("You haven't provided an sqldbmap, or " . "the one you specified doesn't exist: " . $this->sqldbmap->getPath()); } if ($this->url === null) { @@ -308,7 +310,6 @@ protected function insertDatabaseSqlFiles($database, $statements) $this->conn->commit(); } } - } catch (IOException $e) { if (!$this->autocommit && $this->conn !== null && $this->onError == "abort") { try { @@ -340,6 +341,7 @@ protected function insertDatabaseSqlFiles($database, $statements) * Execute a SQL statement using the current connection property. * * @param string $sql SQL statement to execute + * * @throws PDOException */ protected function execSQL($sql) @@ -352,14 +354,18 @@ protected function execSQL($sql) try { $this->totalSql++; - if (!$this->autocommit) $this->conn->beginTransaction(); + if (!$this->autocommit) { + $this->conn->beginTransaction(); + } $stmt = $this->conn->prepare($sql); - $this->log(sprintf(' Executing statement "%s"',$sql), Project::MSG_VERBOSE); + $this->log(sprintf(' Executing statement "%s"', $sql), Project::MSG_VERBOSE); $stmt->execute(); $this->log(sprintf(' %d rows affected', $stmt->rowCount()), Project::MSG_VERBOSE); - if (!$this->autocommit) $this->conn->commit(); + if (!$this->autocommit) { + $this->conn->commit(); + } $this->goodSql++; } catch (PDOException $e) { @@ -370,5 +376,4 @@ protected function execSQL($sql) $this->log($e->getMessage(), Project::MSG_ERR); } } - } diff --git a/generator/lib/task/PropelSQLTask.php b/generator/lib/task/PropelSQLTask.php index 3e60aad28..010e7b4a4 100644 --- a/generator/lib/task/PropelSQLTask.php +++ b/generator/lib/task/PropelSQLTask.php @@ -23,6 +23,7 @@ class PropelSQLTask extends AbstractPropelDataModelTask /** * The properties file that maps an SQL file to a particular database. + * * @var PhingFile */ private $sqldbmap; @@ -34,6 +35,7 @@ class PropelSQLTask extends AbstractPropelDataModelTask /** * Set the sqldbmap. + * * @param PhingFile $sqldbmap The db map. */ public function setSqlDbMap(PhingFile $sqldbmap) @@ -43,6 +45,7 @@ public function setSqlDbMap(PhingFile $sqldbmap) /** * Get the sqldbmap. + * * @return PhingFile $sqldbmap. */ public function getSqlDbMap() @@ -52,6 +55,7 @@ public function getSqlDbMap() /** * Set the database name. + * * @param string $database */ public function setDatabase($database) @@ -61,6 +65,7 @@ public function setDatabase($database) /** * Get the database name. + * * @return string */ public function getDatabase() @@ -114,7 +119,7 @@ protected function createSqlDbMap() try { $sqldbmap->store($this->getSqlDbMap(), "Sqlfile -> Database map"); } catch (IOException $e) { - throw new IOException("Unable to store properties: ". $e->getMessage()); + throw new IOException("Unable to store properties: " . $e->getMessage()); } } @@ -137,7 +142,7 @@ public function main() $this->createSqlDbMap(); // 2) Now actually create the DDL based on the datamodel(s) from XML schema file. - $targetDatabase = $this->getTargetDatabase(); + $targetDatabase = $this->getTargetDatabase(); $generatorConfig = $this->getGeneratorConfig(); foreach ($dataModels as $package => $dataModel) { @@ -169,7 +174,6 @@ public function main() $this->log('Writing to SQL file: ' . $outFile->getPath()); file_put_contents($absPath, $ddl); } - } // foreach database } //foreach datamodels diff --git a/generator/lib/task/PropelSchemaReverseTask.php b/generator/lib/task/PropelSchemaReverseTask.php index 3a8b89e4a..a1680a81f 100644 --- a/generator/lib/task/PropelSchemaReverseTask.php +++ b/generator/lib/task/PropelSchemaReverseTask.php @@ -60,18 +60,21 @@ class PropelSchemaReverseTask extends PDOTask /** * File to contain XML database schema. + * * @var PhingFIle */ protected $xmlSchema; /** * DB encoding to use + * * @var string */ protected $dbEncoding = 'iso-8859-1'; /** * DB schema to use. + * * @var string */ protected $dbSchema; @@ -85,30 +88,35 @@ class PropelSchemaReverseTask extends PDOTask /** * DOM document produced. + * * @var DOMDocument */ protected $doc; /** * The document root element. + * * @var DOMElement */ protected $databaseNode; /** * Hashtable of columns that have primary keys. + * * @var array */ protected $primaryKeys; /** * Whether to use same name for phpName or not. + * * @var boolean */ protected $samePhpName; /** * whether to add vendor info or not + * * @var boolean */ protected $addVendorInfo; @@ -161,23 +169,23 @@ class PropelSchemaReverseTask extends PDOTask 'maxlength' => array ( 'msg' => 'The field %s must be not longer than %s characters.', 'var' => array('colName', 'value') - ), + ), 'maxvalue' => array ( 'msg' => 'The field %s must be not greater than %s.', 'var' => array('colName', 'value') - ), + ), 'type' => array ( 'msg' => 'The column %s must be an %s value.', 'var' => array('colName', 'value') - ), + ), 'required' => array ( 'msg' => 'The field %s is required.', 'var' => array('colName') - ), + ), 'unique' => array ( 'msg' => 'This %s already exists in table %s.', 'var' => array('colName', 'tableName') - ), + ), ); /** @@ -276,6 +284,7 @@ public function setAddVendorInfo($v) * Sets set validator bitfield from a comma-separated list of "validator bit" names. * * @param string $v The comma-separated list of which validators to add. + * * @return void * @throws BuildException */ @@ -292,10 +301,10 @@ public function setAddValidators($v) foreach ($exprs as $expr) { $expr = trim($expr); if (!empty($expr)) { - if (!isset(self::$validatorBitMap[$expr])) { - throw new BuildException("Unable to interpret validator in expression ('$v'): " . $expr); - } - $bits |= self::$validatorBitMap[$expr]; + if (!isset(self::$validatorBitMap[$expr])) { + throw new BuildException("Unable to interpret validator in expression ('$v'): " . $expr); + } + $bits |= self::$validatorBitMap[$expr]; } } @@ -306,6 +315,7 @@ public function setAddValidators($v) * Checks whether to add validators of specified type or not * * @param int $type The validator type constant. + * * @return boolean */ protected function isValidatorRequired($type) @@ -339,7 +349,7 @@ public function main() $this->doc = new DOMDocument('1.0', 'utf-8'); $this->doc->formatOutput = true; // pretty printing - $this->doc->appendChild($this->doc->createComment("Autogenerated by ".get_class($this)." class.")); + $this->doc->appendChild($this->doc->createComment("Autogenerated by " . get_class($this) . " class.")); try { @@ -356,7 +366,6 @@ public function main() $xmlstr = $this->doc->saveXML(); $out->write($xmlstr); $out->close(); - } catch (Exception $e) { $this->log("There was an error building XML from metadata: " . $e->getMessage(), Project::MSG_ERR); @@ -368,6 +377,7 @@ public function main() /** * Gets the GeneratorConfig object for this task or creates it on-demand. + * * @return GeneratorConfig */ protected function getGeneratorConfig() @@ -382,6 +392,7 @@ protected function getGeneratorConfig() /** * Builds the model classes from the database schema. + * * @return Database The built-out Database (with all tables, etc.) */ protected function buildModel() @@ -409,12 +420,13 @@ protected function buildModel() * * for notNull columns: required validator * for unique indexes: unique validator - * for varchar types: maxLength validators (CHAR, VARCHAR, LONGVARCHAR) - * for numeric types: maxValue validators (BIGINT, SMALLINT, TINYINT, INTEGER, FLOAT, DOUBLE, NUMERIC, DECIMAL, REAL) - * for integer and timestamp types: notMatch validator with [^\d]+ (BIGINT, SMALLINT, TINYINT, INTEGER, TIMESTAMP) - * for float types: notMatch validator with [^\d\.]+ (FLOAT, DOUBLE, NUMERIC, DECIMAL, REAL) + * for varchar types: maxLength validators (CHAR, VARCHAR, LONGVARCHAR) + * for numeric types: maxValue validators (BIGINT, SMALLINT, TINYINT, INTEGER, FLOAT, DOUBLE, NUMERIC, DECIMAL, REAL) + * for integer and timestamp types: notMatch validator with [^\d]+ (BIGINT, SMALLINT, TINYINT, INTEGER, TIMESTAMP) + * for float types: notMatch validator with [^\d\.]+ (FLOAT, DOUBLE, NUMERIC, DECIMAL, REAL) * * @param Database $database The Database model. + * * @return void * @todo find out how to evaluate the appropriate size and adjust maxValue rule values appropriate * @todo find out if float type column values must always notMatch('[^\d\.]+'), i.e. digits and point for any db vendor, language etc. @@ -435,14 +447,13 @@ protected function addValidators(Database $database) $validator->addRule($this->getValidatorRule($col, 'required')); } - if (in_array($col->getType(), array(PropelTypes::CHAR, PropelTypes::VARCHAR, PropelTypes::LONGVARCHAR)) - && $col->getSize() && $this->isValidatorRequired(self::VALIDATORS_MAXLENGTH)) { + if (in_array($col->getType(), array(PropelTypes::CHAR, PropelTypes::VARCHAR, PropelTypes::LONGVARCHAR)) && $col->getSize() && $this->isValidatorRequired(self::VALIDATORS_MAXLENGTH)) { $validator = $set->getValidator($col); $validator->addRule($this->getValidatorRule($col, 'maxLength', $col->getSize())); } if ($col->isNumericType() && $this->isValidatorRequired(self::VALIDATORS_MAXVALUE)) { - $this->log("WARNING: maxValue validator added for column ".$col->getName().". You will have to adjust the size value manually.", Project::MSG_WARN); + $this->log("WARNING: maxValue validator added for column " . $col->getName() . ". You will have to adjust the size value manually.", Project::MSG_WARN); $validator = $set->getValidator($col); $validator->addRule($this->getValidatorRule($col, 'maxValue', 'REPLACEME')); } @@ -451,7 +462,6 @@ protected function addValidators(Database $database) $validator = $set->getValidator($col); $validator->addRule($this->getValidatorRule($col, 'type', $col->getPhpType())); } - } foreach ($table->getUnices() as $unique) { @@ -466,7 +476,6 @@ protected function addValidators(Database $database) foreach ($set->getValidators() as $validator) { $table->addValidator($validator); } - } // foreach table } @@ -513,11 +522,11 @@ protected function getRuleMessage(Column $column, $type, $value) return $msg; } - } /** * A helper class to store validator sets indexed by column. + * * @package propel.generator.task */ class PropelSchemaReverse_ValidatorSet @@ -532,7 +541,9 @@ class PropelSchemaReverse_ValidatorSet /** * Gets a single validator for specified column name. + * * @param Column $column + * * @return Validator */ public function getValidator(Column $column) @@ -548,6 +559,7 @@ public function getValidator(Column $column) /** * Gets all validators. + * * @return array Validator[] */ public function getValidators() diff --git a/generator/lib/util/PropelPHPParser.php b/generator/lib/util/PropelPHPParser.php index efb516bbf..57c9a81ff 100644 --- a/generator/lib/util/PropelPHPParser.php +++ b/generator/lib/util/PropelPHPParser.php @@ -16,6 +16,7 @@ /** * Service class for parsing PHP code strings and editing them + * * @example Basic usage: * * $script = file_get_contents($fileName); @@ -59,12 +60,12 @@ public function getCode() protected function addPhp($code) { - return 'findMethod($methodName)) { - $this->code = str_replace($methodCode, $methodCode. $newCode, $this->code); + $this->code = str_replace($methodCode, $methodCode . $newCode, $this->code); return $methodCode; } diff --git a/generator/lib/util/PropelQuickBuilder.php b/generator/lib/util/PropelQuickBuilder.php index f92a820d1..1043a226b 100644 --- a/generator/lib/util/PropelQuickBuilder.php +++ b/generator/lib/util/PropelQuickBuilder.php @@ -201,7 +201,7 @@ public function getClassesForTable(Table $table, array $classTargets = null) foreach (array('nestedsetpeer', 'nestedset') as $target) { $script .= $this->getConfig()->getConfiguredBuilder($table, $target)->build(); } - break; + break; case 'MaterializedPath': foreach (array('nodepeer', 'node') as $target) { $script .= $this->getConfig()->getConfiguredBuilder($table, $target)->build(); @@ -209,11 +209,11 @@ public function getClassesForTable(Table $table, array $classTargets = null) foreach (array('nodepeerstub', 'nodestub') as $target) { $script .= $this->getConfig()->getConfiguredBuilder($table, $target)->build(); } - break; + break; case 'AdjacencyList': // No implementation for this yet. default: - break; + break; } } diff --git a/generator/lib/util/PropelSQLParser.php b/generator/lib/util/PropelSQLParser.php index fef32c073..7a4b1af42 100644 --- a/generator/lib/util/PropelSQLParser.php +++ b/generator/lib/util/PropelSQLParser.php @@ -98,6 +98,7 @@ protected static function executeStatements($statements, $connection) /** * Explodes a SQL string into an array of SQL statements. + * * @example * * echo PropelSQLParser::parseString("-- Table foo @@ -117,6 +118,7 @@ protected static function executeStatements($statements, $connection) * // ) ENGINE=InnoDB;" * // ) * + * * @param string $input The SQL code to parse * * @return array A list of SQL statement strings @@ -133,6 +135,7 @@ public static function parseString($input) /** * Explodes a SQL file into an array of SQL statements. + * * @example * * echo PropelSQLParser::parseFile('/var/tmp/foo.sql'); @@ -146,6 +149,7 @@ public static function parseString($input) * // ) ENGINE=InnoDB;" * // ) * + * * @param string $input The absolute path to the file to parse * * @return array A list of SQL statement strings @@ -257,5 +261,4 @@ public function getNextStatement() return trim($parsedString); } - } diff --git a/generator/lib/util/PropelSchemaValidator.php b/generator/lib/util/PropelSchemaValidator.php index ff7d5967c..4d6a23188 100644 --- a/generator/lib/util/PropelSchemaValidator.php +++ b/generator/lib/util/PropelSchemaValidator.php @@ -61,7 +61,7 @@ protected function validateDatabaseTables(Database $database) if (in_array($table->getPhpName(), $list)) { $this->errors[] = sprintf('Table "%s" declares a phpName already used in another table', $table->getName()); } - $list[]= $table->getPhpName(); + $list[] = $table->getPhpName(); $this->validateTableAttributes($table); $this->validateTableColumns($table); } @@ -97,7 +97,7 @@ protected function validateTableColumns(Table $table) if (in_array($column->getPhpName(), $phpNames)) { $this->errors[] = sprintf('Column "%s" declares a phpName already used in table "%s"', $column->getName(), $table->getName()); } - $phpNames[]= $column->getPhpName(); + $phpNames[] = $column->getPhpName(); } } @@ -108,5 +108,4 @@ public function getErrors() { return $this->errors; } - } diff --git a/generator/lib/util/PropelSqlManager.php b/generator/lib/util/PropelSqlManager.php index 839d4e854..c1e122e97 100644 --- a/generator/lib/util/PropelSqlManager.php +++ b/generator/lib/util/PropelSqlManager.php @@ -185,7 +185,7 @@ public function buildSql() $sqlDbMapContent .= sprintf("%s=%s\n", $filename, $datasource); } - file_put_contents ($this->getSqlDbMapFilename(), $sqlDbMapContent); + file_put_contents($this->getSqlDbMapFilename(), $sqlDbMapContent); } /** @@ -266,6 +266,7 @@ protected function getPdoConnection($datasource) * Returns an array of properties as key/value pairs from an input file. * * @param string $file A file properties. + * * @return array An array of properties as key/value pairs. * @throws Exception */ diff --git a/generator/pear/BuildPropelGenPEARPackageTask.php b/generator/pear/BuildPropelGenPEARPackageTask.php index 85f373d23..b953a1f94 100644 --- a/generator/pear/BuildPropelGenPEARPackageTask.php +++ b/generator/pear/BuildPropelGenPEARPackageTask.php @@ -103,11 +103,11 @@ private function setOptions($pkg) ); $pkg->setOptions($options); - } /** * Main entry point. + * * @return void * @throws BuildException */ @@ -183,11 +183,11 @@ public function main() if (PEAR::isError($e)) { throw new BuildException("Unable to write package file.", new Exception($e->getMessage())); } - } /** * Used by the PEAR_PackageFileManager_PhingFileSet lister. + * * @return array FileSet[] */ public function getFileSets() @@ -208,12 +208,14 @@ public function createFileSet() { $num = array_push($this->filesets, new FileSet()); - return $this->filesets[$num-1]; + return $this->filesets[$num - 1]; } /** * Set the version we are building. + * * @param string $v + * * @return void */ public function setVersion($v) @@ -223,7 +225,9 @@ public function setVersion($v) /** * Set the state we are building. + * * @param string $v + * * @return void */ public function setState($v) @@ -233,16 +237,21 @@ public function setState($v) /** * Sets release notes field. + * * @param string $v + * * @return void */ public function setNotes($v) { $this->notes = $v; } + /** * Sets "dir" property from XML. + * * @param PhingFile $f + * * @return void */ public function setDir(PhingFile $f) @@ -257,5 +266,4 @@ public function setDestFile(PhingFile $f) { $this->packageFile = $f; } - } diff --git a/generator/pear/build-pear-package.xml b/generator/pear/build-pear-package.xml index fdb2f80bb..3821a4719 100644 --- a/generator/pear/build-pear-package.xml +++ b/generator/pear/build-pear-package.xml @@ -13,147 +13,148 @@ - - - - + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Propel version for package - - - - - - - - - ----------------------------- - | Creating directory layout | - ----------------------------- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ----------------------------- - | Creating PEAR package.xml | - ----------------------------- - - - - - - - - - - - - - - - ----------------------------- - | Creating tar.gz package | - ----------------------------- - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Propel version for package + + + + + + + + + ----------------------------- + | Creating directory layout | + ----------------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ----------------------------- + | Creating PEAR package.xml | + ----------------------------- + + + + + + + + + + + + + + + ----------------------------- + | Creating tar.gz package | + ----------------------------- + + + + diff --git a/generator/pear/pear-build.xml b/generator/pear/pear-build.xml index 5316af9c6..f989f3763 100644 --- a/generator/pear/pear-build.xml +++ b/generator/pear/pear-build.xml @@ -15,153 +15,154 @@ --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Processing additional properties file: ${additional.properties} - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Processing additional properties file: ${additional.properties} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - + - + - - - + + + - + - + - - - + + + - + - - - + + + - - - + + + - - - + + + diff --git a/generator/resources/dtd/database.dtd b/generator/resources/dtd/database.dtd index b9cc7c09f..91d813b69 100644 --- a/generator/resources/dtd/database.dtd +++ b/generator/resources/dtd/database.dtd @@ -6,183 +6,183 @@ some differences do exist. --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/generator/resources/xsd/custom_datatypes.xsd b/generator/resources/xsd/custom_datatypes.xsd index 12e8327cb..348878df7 100644 --- a/generator/resources/xsd/custom_datatypes.xsd +++ b/generator/resources/xsd/custom_datatypes.xsd @@ -1,8 +1,8 @@ - - - - - \ No newline at end of file + + + + + diff --git a/generator/resources/xsd/database.xsd b/generator/resources/xsd/database.xsd index 6a9d53e1a..fc3815b30 100644 --- a/generator/resources/xsd/database.xsd +++ b/generator/resources/xsd/database.xsd @@ -1,918 +1,976 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + also included. --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The name of the column as it appears in the database. - - - - - - - Name used in PHP code to reference this column (in getters, setters, etc.). Defaults to the name transformed by the phpNamingMethod, which defaults to a CamelCase converter. So by default, a column named 'author_id' receives 'AuthorId' as phpName. - - - - - - - Name used for the class constant corresponding to this column in PHP code. Defaults to the uppercase name, so a column named 'author_id' receives 'AUTHOR_ID' as peerName. - - - - - - - - Visibility for the column accessor method. 'public' by default, also accepts 'protected' and 'private'. - - - - - - - Visibility for the column mutator method. 'public' by default, also accepts 'protected' and 'private'. - - - - - - - Set to true to add a primary key on this column. - - - - - - - Set to true to forbid NULL values. - - - - - - - Any of the Propel supported data types. These types are database-agnostic, and converted to the native database type according to the connection. - - - - - - - Native database column type. - - - - - - - PHP type for the column in PHP code. This column's setter uses type casting with the set php_type; besides, generated phpDoc in the model classes use this attribute for code completion. - - - - - - - Numeric length of the column. - - - - - - - Digits after decimal place - - - - - - - Synonym for defaultValue - - - - - - - The default value that the object will have for this column in the PHP instance after creating a "new Object". This value is always interpreted as a string. See defaultExpr for setting an SQL function as a default value. - - - - - - - The default value for this column as expressed in SQL. This value is used solely for the "sql" target which builds your database from the schema.xml file. The defaultExpr is the SQL expression used as the "default" for the column. - - - - - - - - - Name of the method used to transform the column name into a phpName. Defaults to 'clean', which Removes any character that is not a letter or a number and capitalizes the first letter of the name, the first letter of each alphanumeric block, and converts the rest of the letters to lowercase. Possible values: any of the PhpNameGenerator CONV_METHOD_XXX constants (clean, underscore, phpName, nochange). - - - - - - - A text description of the column. It gets added to the SQL CREATE table as a comment, and appears in the phpDoc bloc of the related getter and setter methods in the ActiveRecord class. - - - - - - - Set to true to skip this column by default during hydration. That means that this column will be hydrated on demand, using a supplementary query. Mostly useful for LOB columns. - - - - - - - (DEPRECATED) For use with treeMode table attribute. - - - - - - - (DEPRECATED) For use with treeMode table attribute. - - - - - - - (DEPRECATED) For use with treeMode table attribute. - - - - - - - (DEPRECATED) For use with treeMode table attribute. - - - - - - - (DEPRECATED) For use with treeMode table attribute. - - - - - - - A column defined as primary string serves as default value for a `__toString()` method in the generated Propel object. - - - - - - - The list of values for an ENUM column, separated by commas - - - - - - - - - - - A reference between a local and a foreign column. Composite foreign keys can have several references. - - - - - - - - - The other table name - - - - - - - The other schema name - - - - - - - Name for this foreign key - - - - - - - Name for the foreign object in methods generated in this class. - - - - - - - Name for this object in methods generated in the foreign class - - - - - - - This affects the default join type used in the generated `joinXXX()` methods in the model query class. Propel uses an INNER JOIN for foreign keys attached to a required column, and a LEFT JOIN for foreign keys attached to a non-required column, but you can override this in the foreign key element. - - - - - - - - - Instructs Propel not to generate DDL SQL for the specified foreign key. This can be used to support relationships in the model without an actual foreign key. - - - - - - - - - - The (absolute or relative to this schema dir name) path to the external schema file. - - - - - - - - - - - - - A column of the table - - - - - - - - A foreign key on one or several columns in this table, referencing a foreign table - - - - - - - - An index on one or several columns of the current table - - - - - - - - A unique index on one or several columns of the current table - - - - - - - - If you are using a database that uses sequences for auto-increment columns (e.g. PostgreSQL or Oracle), you can customize the name of the sequence using this tag - - - - - - - - A validator to be executed on a given column at runtime - - - - - - - - A behavior to be added to the current table. Can modify the table structure, as well as modify the runtime code of the generated Model objects linked to this table. Bundled behaviors include alternative_coding_standards, auto_add_pk, timestampable, sluggable, soft_delete, sortable, nested_set, query_cache, and concrete_inheritance. - - - - - - - - table attributes specific to a database vendor. Only supports MySQL specific table attributes for now (Charset, Collate, Checksum, Pack_keys, Delay_key_write). - - - - - - - - - The name of the table as it appears in the database. - - - - - - - The table's schema for RDBMs supporting multiple schemas per database. - - - - - - - The name of the ActiveRecord class generated for this table. Defaults to the name transformed by the phpNamingMethod, which defaults to a CamelCase converter. So by default, a table named 'foo_author' receives 'FooAuthor' as phpName. - - - - - - - The PHP 5.3 namespace to use for the generated model classes. - - - - - - - - Default visibility for column accessor methods. 'public' by default, also accepts 'protected' and 'private'. - - - - - - - Default visibility for column mutator methods. 'public' by default, also accepts 'protected' and 'private'. - - - - - - - Id method to use for auto-increment columns. - - - - - - - Can be used if you want to define the primary key of a new object being inserted. By default if idMethod is "native", Propel would throw an exception. However, in some cases this feature is useful, for example if you do some replication of data in an master-master environment. - - - - - - - Instructs Propel not to generate DDL SQL for the specified table. This can be used together with readOnly for supporting VIEWS in Propel - - - - - - - Suppresses the mutator/setter methods, save() and delete() methods. - - - - - - - Whether the generated stub class will be abstract (e.g. if you're using inheritance) - - - - - - - Allows you to specify a class that the generated Propel objects should extend (in place of propel.om.BaseObject) - - - - - - - Instructs Propel to use a different SQL-generating BasePeer class (or sub-class of BasePeer). - - - - - - - - Specifies the "package" for the generated classes. Classes are created in subdirectories according to the package attribute value. - - - - - - - - Name of the method used to transform the table name into a phpName. Defaults to 'clean', which Removes any character that is not a letter or a number and capitalizes the first letter of the name, the first letter of each alphanumeric block, and converts the rest of the letters to lowercase. Possible values: any of the PhpNameGenerator CONV_METHOD_XXX constants (clean, underscore, phpName, nochange). - - - - - - - Adds indexes for each component of the primary key (when using composite primary keys) - - - - - - - A text description of the table. It gets added to the SQL CREATE table as a comment, and appears in the phpDoc bloc of the related ActiveRecord class. - - - - - - - Used to indicate that this table is part of a node tree. Currently the only supported values are "NestedSet" and "MaterializedPath" (DEPRECATED: use nested_set behavior instead). - - - - - - - Indicate that the object should be reloaded from the database when an INSERT is performed. This is useful if you have triggers (or other server-side functionality like column default expressions) that alters the database row on INSERT. - - - - - - - Indicate that the object should be reloaded from the database when an UPDATE is performed. This is useful if you have triggers (or other server-side functionality like column default expressions) that alters the database row on UPDATE. - - - - - - - Set to true if the current table is a cross-reference table in a many-to-many relationship to allow generation of getter and setter in each of the tables of the relationship. - - - - - - - The default format used to convert objects based on this table to strings. Propel supports by default the 'XML', 'YAML', 'JSON', and 'CSV' formats, but custom formats are also possible. - - - - - - - - - - - Embed an external schema file into the current schema. Accepts absolute and relative schema file paths. - - - - - - - A table using the database connection. - - - - - - - Behavior to be applied to all the database tables - - - - - - - - The name of the table in the database. Propel advocates the use of singular table names. - - - - - - - Default id method to use for auto-increment columns - - - - - - - - Default visibility for column accessor methods. 'public' by default, also accepts 'protected' and 'private'. - - - - - - - Default visibility for column mutator methods. 'public' by default, also accepts 'protected' and 'private'. - - - - - - - Specifies the "package" for the generated classes. Classes are created in subdirectories according to the package attribute value. - - - - - - - The PHP 5.3 namespace to use for the generated model classes of the database. Can be overridden on a per-table basis. - - - - - - - Specify a schema for the tables in this database. Useful for RDBMs which support multiple schemas per database. - - - - - - - Allows to specify a default base class that all generated Propel objects should extend (in place of propel.om.BaseObject) - - - - - - - Instructs Propel to use a different SQL-generating BasePeer class (or sub-class of BasePeer) for all generated objects - - - - - - - The default naming method to use in this database. - - - - - - - Adds indexes for each component of the primary key (when using composite primary keys) - - - - - - - Adds a prefix to all the SQL table names - - - - - - - The default format used to convert objects based on this database to strings. Propel supports by default the 'XML', 'YAML', 'JSON', and 'CSV' formats, but custom formats are also possible. - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The name of the column as it appears in the database. + + + + + + + Name used in PHP code to reference this column (in getters, setters, etc.). Defaults to the name + transformed by the phpNamingMethod, which defaults to a CamelCase converter. So by default, a column + named 'author_id' receives 'AuthorId' as phpName. + + + + + + + Name used for the class constant corresponding to this column in PHP code. Defaults to the uppercase + name, so a column named 'author_id' receives 'AUTHOR_ID' as peerName. + + + + + + + + Visibility for the column accessor method. 'public' by default, also accepts 'protected' and + 'private'. + + + + + + + Visibility for the column mutator method. 'public' by default, also accepts 'protected' and + 'private'. + + + + + + + Set to true to add a primary key on this column. + + + + + + + Set to true to forbid NULL values. + + + + + + + Any of the Propel supported data types. These types are database-agnostic, and converted to the + native database type according to the connection. + + + + + + + Native database column type. + + + + + + + PHP type for the column in PHP code. This column's setter uses type casting with the set php_type; + besides, generated phpDoc in the model classes use this attribute for code completion. + + + + + + + Numeric length of the column. + + + + + + + Digits after decimal place + + + + + + + Synonym for defaultValue + + + + + + + The default value that the object will have for this column in the PHP instance after creating a + "new Object". This value is always interpreted as a string. See defaultExpr for setting an SQL + function as a default value. + + + + + + + The default value for this column as expressed in SQL. This value is used solely for the "sql" + target which builds your database from the schema.xml file. The defaultExpr is the SQL expression + used as the "default" for the column. + + + + + + + + + Name of the method used to transform the column name into a phpName. Defaults to 'clean', which + Removes any character that is not a letter or a number and capitalizes the first letter of the name, + the first letter of each alphanumeric block, and converts the rest of the letters to lowercase. + Possible values: any of the PhpNameGenerator CONV_METHOD_XXX constants (clean, underscore, phpName, + nochange). + + + + + + + A text description of the column. It gets added to the SQL CREATE table as a comment, and appears in + the phpDoc bloc of the related getter and setter methods in the ActiveRecord class. + + + + + + + Set to true to skip this column by default during hydration. That means that this column will be + hydrated on demand, using a supplementary query. Mostly useful for LOB columns. + + + + + + + (DEPRECATED) For use with treeMode table attribute. + + + + + + + (DEPRECATED) For use with treeMode table attribute. + + + + + + + (DEPRECATED) For use with treeMode table attribute. + + + + + + + (DEPRECATED) For use with treeMode table attribute. + + + + + + + (DEPRECATED) For use with treeMode table attribute. + + + + + + + A column defined as primary string serves as default value for a `__toString()` method in the + generated Propel object. + + + + + + + The list of values for an ENUM column, separated by commas + + + + + + + + + + + A reference between a local and a foreign column. Composite foreign keys can have several + references. + + + + + + + + + The other table name + + + + + + + The other schema name + + + + + + + Name for this foreign key + + + + + + + Name for the foreign object in methods generated in this class. + + + + + + + Name for this object in methods generated in the foreign class + + + + + + + This affects the default join type used in the generated `joinXXX()` methods in the model query + class. Propel uses an INNER JOIN for foreign keys attached to a required column, and a LEFT JOIN for + foreign keys attached to a non-required column, but you can override this in the foreign key + element. + + + + + + + + + Instructs Propel not to generate DDL SQL for the specified foreign key. This can be used to support + relationships in the model without an actual foreign key. + + + + + + + + + + The (absolute or relative to this schema dir name) path to the external schema file. + + + + + + + + + + + + + A column of the table + + + + + + + + A foreign key on one or several columns in this table, referencing a foreign table + + + + + + + + An index on one or several columns of the current table + + + + + + + + A unique index on one or several columns of the current table + + + + + + + + If you are using a database that uses sequences for auto-increment columns (e.g. PostgreSQL or + Oracle), you can customize the name of the sequence using this tag + + + + + + + + A validator to be executed on a given column at runtime + + + + + + + + A behavior to be added to the current table. Can modify the table structure, as well as modify + the runtime code of the generated Model objects linked to this table. Bundled behaviors include + alternative_coding_standards, auto_add_pk, timestampable, sluggable, soft_delete, sortable, + nested_set, query_cache, and concrete_inheritance. + + + + + + + + table attributes specific to a database vendor. Only supports MySQL specific table attributes + for now (Charset, Collate, Checksum, Pack_keys, Delay_key_write). + + + + + + + + + The name of the table as it appears in the database. + + + + + + + The table's schema for RDBMs supporting multiple schemas per database. + + + + + + + The name of the ActiveRecord class generated for this table. Defaults to the name transformed by the + phpNamingMethod, which defaults to a CamelCase converter. So by default, a table named 'foo_author' + receives 'FooAuthor' as phpName. + + + + + + + The PHP 5.3 namespace to use for the generated model classes. + + + + + + + + Default visibility for column accessor methods. 'public' by default, also accepts 'protected' and + 'private'. + + + + + + + Default visibility for column mutator methods. 'public' by default, also accepts 'protected' and + 'private'. + + + + + + + Id method to use for auto-increment columns. + + + + + + + Can be used if you want to define the primary key of a new object being inserted. By default if + idMethod is "native", Propel would throw an exception. However, in some cases this feature is + useful, for example if you do some replication of data in an master-master environment. + + + + + + + Instructs Propel not to generate DDL SQL for the specified table. This can be used together with + readOnly for supporting VIEWS in Propel + + + + + + + Suppresses the mutator/setter methods, save() and delete() methods. + + + + + + + Whether the generated stub class will be abstract (e.g. if you're using inheritance) + + + + + + + Allows you to specify a class that the generated Propel objects should extend (in place of + propel.om.BaseObject) + + + + + + + Instructs Propel to use a different SQL-generating BasePeer class (or sub-class of BasePeer). + + + + + + + + Specifies the "package" for the generated classes. Classes are created in subdirectories according + to the package attribute value. + + + + + + + + Name of the method used to transform the table name into a phpName. Defaults to 'clean', which + Removes any character that is not a letter or a number and capitalizes the first letter of the name, + the first letter of each alphanumeric block, and converts the rest of the letters to lowercase. + Possible values: any of the PhpNameGenerator CONV_METHOD_XXX constants (clean, underscore, phpName, + nochange). + + + + + + + Adds indexes for each component of the primary key (when using composite primary keys) + + + + + + + A text description of the table. It gets added to the SQL CREATE table as a comment, and appears in + the phpDoc bloc of the related ActiveRecord class. + + + + + + + Used to indicate that this table is part of a node tree. Currently the only supported values are + "NestedSet" and "MaterializedPath" (DEPRECATED: use nested_set behavior instead). + + + + + + + Indicate that the object should be reloaded from the database when an INSERT is performed. This is + useful if you have triggers (or other server-side functionality like column default expressions) + that alters the database row on INSERT. + + + + + + + Indicate that the object should be reloaded from the database when an UPDATE is performed. This is + useful if you have triggers (or other server-side functionality like column default expressions) + that alters the database row on UPDATE. + + + + + + + Set to true if the current table is a cross-reference table in a many-to-many relationship to allow + generation of getter and setter in each of the tables of the relationship. + + + + + + + The default format used to convert objects based on this table to strings. Propel supports by + default the 'XML', 'YAML', 'JSON', and 'CSV' formats, but custom formats are also possible. + + + + + + + + + + + Embed an external schema file into the current schema. Accepts absolute and relative schema file + paths. + + + + + + + A table using the database connection. + + + + + + + Behavior to be applied to all the database tables + + + + + + + + The name of the table in the database. Propel advocates the use of singular table names. + + + + + + + Default id method to use for auto-increment columns + + + + + + + + Default visibility for column accessor methods. 'public' by default, also accepts 'protected' and + 'private'. + + + + + + + Default visibility for column mutator methods. 'public' by default, also accepts 'protected' and + 'private'. + + + + + + + Specifies the "package" for the generated classes. Classes are created in subdirectories according + to the package attribute value. + + + + + + + The PHP 5.3 namespace to use for the generated model classes of the database. Can be overridden on a + per-table basis. + + + + + + + Specify a schema for the tables in this database. Useful for RDBMs which support multiple schemas + per database. + + + + + + + Allows to specify a default base class that all generated Propel objects should extend (in place of + propel.om.BaseObject) + + + + + + + Instructs Propel to use a different SQL-generating BasePeer class (or sub-class of BasePeer) for all + generated objects + + + + + + + The default naming method to use in this database. + + + + + + + Adds indexes for each component of the primary key (when using composite primary keys) + + + + + + + Adds a prefix to all the SQL table names + + + + + + + The default format used to convert objects based on this database to strings. Propel supports by + default the 'XML', 'YAML', 'JSON', and 'CSV' formats, but custom formats are also possible. + + + + diff --git a/generator/resources/xsl/database.xsl b/generator/resources/xsl/database.xsl index f43467321..7183d4003 100644 --- a/generator/resources/xsl/database.xsl +++ b/generator/resources/xsl/database.xsl @@ -3,290 +3,298 @@ ]> - + - - + + - - - - - native - - - underscore - - - false - - - - - - - + Starts the normalization process + --> + + + + native + + + underscore + + + false + + + + + + + - - - - + + + + + + - - - - - none - - - - - - + + + + + none + + + + + + + + - - - - + + + + - - - - - none - - - - - - + + + + + none + + + + + + + + - - - - + + + + - - - - + + + + + + - - - - + + + + - - -
- - false - - - false - - - - - - - - - - -
- + + + + + false + + + false + + + + + + + + + + +
+
- - - - - none - - - none - - - - - - + + + + + none + + + none + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - default - - - - + + + + + default + + + + - - - - - - - + + + + + + + - - - - - class - - - - + + + + + class + + + + - - - - - - + + + + + + - - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - false - - - false - - - VARCHAR - - - false - - - false - - - 255 - - - - - - + + + + + false + + + false + + + VARCHAR + + + false + + + false + + + 255 + + + + + + - - - - - - + + + + + + diff --git a/generator/resources/xsl/dbd2propel.xsl b/generator/resources/xsl/dbd2propel.xsl index 385849c07..2e67fd2af 100644 --- a/generator/resources/xsl/dbd2propel.xsl +++ b/generator/resources/xsl/dbd2propel.xsl @@ -1,381 +1,406 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - true - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TIMESTAMP - LONGVARCHAR - BOOLEAN - BLOB - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - restrict - cascade - setnull - restrict - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + true + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TIMESTAMP + LONGVARCHAR + BOOLEAN + BLOB + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + restrict + cascade + setnull + restrict + +
diff --git a/runtime/lib/Propel.php b/runtime/lib/Propel.php index c9d0b771b..18555a505 100644 --- a/runtime/lib/Propel.php +++ b/runtime/lib/Propel.php @@ -271,7 +271,7 @@ public static function initialize() // check whether the generated model has the same version as the runtime, see gh-#577 // we need to check for existance first, because tasks which rely on the runtime.xml conf will not provide a generator_version if (isset(self::$configuration['generator_version']) && self::$configuration['generator_version'] != self::VERSION) { - $warning = "Version mismatch: The generated model was build using propel '". self::$configuration['generator_version'] ."' while the current runtime is at version '". self::VERSION ."'"; + $warning = "Version mismatch: The generated model was build using propel '" . self::$configuration['generator_version'] . "' while the current runtime is at version '" . self::VERSION . "'"; if (self::$logger) { self::$logger->warning($warning); } else { @@ -374,6 +374,7 @@ public static function setConfiguration($c) * - PropelConfiguration::TYPE_ARRAY_FLAT: return the configuration as a flat array * ($config['name.space.item']) * - PropelConfiguration::TYPE_OBJECT: return the configuration as a PropelConfiguration instance + * * @return mixed The Configuration (array or PropelConfiguration) */ public static function getConfiguration($type = PropelConfiguration::TYPE_ARRAY) @@ -434,22 +435,22 @@ public static function log($message, $level = self::LOG_DEBUG) if (self::hasLogger()) { $logger = self::logger(); switch ($level) { - case self::LOG_EMERG: - return $logger->log($message, $level); - case self::LOG_ALERT: - return $logger->alert($message); - case self::LOG_CRIT: - return $logger->crit($message); - case self::LOG_ERR: - return $logger->err($message); - case self::LOG_WARNING: - return $logger->warning($message); - case self::LOG_NOTICE: - return $logger->notice($message); - case self::LOG_INFO: - return $logger->info($message); - default: - return $logger->debug($message); + case self::LOG_EMERG: + return $logger->log($message, $level); + case self::LOG_ALERT: + return $logger->alert($message); + case self::LOG_CRIT: + return $logger->crit($message); + case self::LOG_ERR: + return $logger->err($message); + case self::LOG_WARNING: + return $logger->warning($message); + case self::LOG_NOTICE: + return $logger->notice($message); + case self::LOG_INFO: + return $logger->info($message); + default: + return $logger->debug($message); } } @@ -562,7 +563,6 @@ public static function getConnection($name = null, $mode = Propel::CONNECTION_WR } else { return self::getSlaveConnection($name); } - } /** @@ -581,7 +581,7 @@ public static function getMasterConnection($name) // load connection parameter for master connection $conparams = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null; if (empty($conparams)) { - throw new PropelException('No connection information in your runtime configuration file for datasource ['.$name.']'); + throw new PropelException('No connection information in your runtime configuration file for datasource [' . $name . ']'); } // initialize master connection $con = Propel::initConnection($conparams, $name); @@ -622,7 +622,7 @@ public static function getSlaveConnection($name) $randkey = array_rand($slaveconfigs['connection']); $conparams = $slaveconfigs['connection'][$randkey]; if (empty($conparams)) { - throw new PropelException('No connection information in your runtime configuration file for SLAVE ['.$randkey.'] to datasource ['.$name.']'); + throw new PropelException('No connection information in your runtime configuration file for SLAVE [' . $randkey . '] to datasource [' . $name . ']'); } } @@ -630,7 +630,6 @@ public static function getSlaveConnection($name) $con = Propel::initConnection($conparams, $name); self::$connectionMap[$name]['slave'] = $con; } - } // if datasource slave not set return self::$connectionMap[$name]['slave']; @@ -642,7 +641,7 @@ public static function getSlaveConnection($name) * @param array $conparams Connection paramters. * @param string $name Datasource name. * @param string $defaultClass The PDO subclass to instantiate if there is no explicit classname - * specified in the connection params (default is Propel::CLASS_PROPEL_PDO) + * specified in the connection params (default is Propel::CLASS_PROPEL_PDO) * * @return PDO A database connection of the given class (PDO, PropelPDO, SlavePDO or user-defined) * @@ -653,7 +652,7 @@ public static function initConnection($conparams, $name, $defaultClass = Propel: $adapter = self::getDB($name); if (null === $conparams['dsn']) { - throw new PropelException('No dsn specified in your connection parameters for datasource ['.$name.']'); + throw new PropelException('No dsn specified in your connection parameters for datasource [' . $name . ']'); } $conparams = $adapter->prepareParams($conparams); @@ -667,18 +666,18 @@ public static function initConnection($conparams, $name, $defaultClass = Propel: $classname = $defaultClass; } - $dsn = $conparams['dsn']; - $user = isset($conparams['user']) ? $conparams['user'] : null; + $dsn = $conparams['dsn']; + $user = isset($conparams['user']) ? $conparams['user'] : null; $password = isset($conparams['password']) ? $conparams['password'] : null; // load any driver options from the config file // driver options are those PDO settings that have to be passed during the connection construction $driver_options = array(); - if ( isset($conparams['options']) && is_array($conparams['options']) ) { + if (isset($conparams['options']) && is_array($conparams['options'])) { try { - self::processDriverOptions( $conparams['options'], $driver_options ); + self::processDriverOptions($conparams['options'], $driver_options); } catch (PropelException $e) { - throw new PropelException('Error processing driver options for datasource ['.$name.']', $e); + throw new PropelException('Error processing driver options for datasource [' . $name . ']', $e); } } @@ -695,9 +694,9 @@ public static function initConnection($conparams, $name, $defaultClass = Propel: if (isset($conparams['attributes']) && is_array($conparams['attributes'])) { $attributes = array(); try { - self::processDriverOptions( $conparams['attributes'], $attributes ); + self::processDriverOptions($conparams['attributes'], $attributes); } catch (PropelException $e) { - throw new PropelException('Error processing connection attributes for datasource ['.$name.']', $e); + throw new PropelException('Error processing connection attributes for datasource [' . $name . ']', $e); } foreach ($attributes as $key => $value) { $con->setAttribute($key, $value); @@ -729,14 +728,14 @@ private static function processDriverOptions($source, &$write_to) $key = 'PropelPDO::' . $option; } if (!defined($key)) { - throw new PropelException("Invalid PDO option/attribute name specified: ".$key); + throw new PropelException("Invalid PDO option/attribute name specified: " . $key); } $key = constant($key); $value = $optiondata['value']; if (is_string($value) && strpos($value, '::') !== false) { if (!defined($value)) { - throw new PropelException("Invalid PDO option/attribute value specified: ".$value); + throw new PropelException("Invalid PDO option/attribute value specified: " . $value); } $value = constant($value); } @@ -853,6 +852,7 @@ public static function initBaseDir() * class via autoload and then relative to a location on the include_path. * * @param string $class dot-path to clas (e.g. path.to.my.ClassName). + * * @return string unqualified classname * * @throws PropelException @@ -867,7 +867,7 @@ public static function importClass($path) } // check if class exists, using autoloader to attempt to load it. - if (class_exists($class, $useAutoload=true)) { + if (class_exists($class, $useAutoload = true)) { return $class; } diff --git a/runtime/lib/adapter/DBAdapter.php b/runtime/lib/adapter/DBAdapter.php index 571a4f64d..7c60b909f 100644 --- a/runtime/lib/adapter/DBAdapter.php +++ b/runtime/lib/adapter/DBAdapter.php @@ -38,6 +38,7 @@ abstract class DBAdapter /** * Propel driver to Propel adapter map. + * * @var array */ private static $adapters = array( @@ -78,6 +79,7 @@ public static function factory($driver) * Prepare connection parameters. * * @param array $settings + * * @return array */ public function prepareParams($settings) @@ -133,6 +135,7 @@ public function setCharset(PDO $con, $charset) * This method is used to ignore case. * * @param string $in The string to transform to upper case. + * * @return string The upper case string. */ abstract public function toUpperCase($in); @@ -153,6 +156,7 @@ public function getStringDelimiter() * This method is used to ignore case. * * @param string $in The string whose case to ignore. + * * @return string The string in a case that can be ignored. */ abstract public function ignoreCase($in); @@ -164,6 +168,7 @@ abstract public function ignoreCase($in); * and other clauses. * * @param string $in The string whose case to ignore. + * * @return string The string in a case that can be ignored. */ public function ignoreCaseInOrderBy($in) @@ -196,13 +201,16 @@ abstract public function subString($s, $pos, $len); * Returns SQL which calculates the length (in chars) of a string. * * @param string $s String to calculate length of. + * * @return string */ abstract public function strLength($s); /** * Quotes database objec identifiers (table names, col names, sequences, etc.). + * * @param string $text The identifier to quote. + * * @return string The quoted identifier. */ public function quoteIdentifier($text) @@ -216,11 +224,12 @@ public function quoteIdentifier($text) * schemas have to implement that in the platform-specific way. * * @param string $table The table name to quo + * * @return string The quoted table name **/ public function quoteIdentifierTable($table) { - return implode(" ", array_map(array($this, "quoteIdentifier"), explode(" ", $table) ) ); + return implode(" ", array_map(array($this, "quoteIdentifier"), explode(" ", $table))); } /** @@ -484,6 +493,7 @@ public function createSelectSqlPart(Criteria $criteria, &$fromClause, $aliasAll * @see http://propel.phpdb.org/trac/ticket/795 * * @param Criteria $criteria + * * @return Criteria The input, with Select columns replaced by aliases */ public function turnSelectColumnsToAliases(Criteria $criteria) @@ -590,6 +600,7 @@ public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMa * * @param PropelPDO $con propel connection * @param ModelCriteria|string $query query the criteria or the query string + * * @throws PropelException if explain plan is not implemented for adapter * @return PDOStatement A PDO statement executed using the connection, ready to be fetched */ diff --git a/runtime/lib/adapter/DBMSSQL.php b/runtime/lib/adapter/DBMSSQL.php index a7c9c3949..816dabd63 100644 --- a/runtime/lib/adapter/DBMSSQL.php +++ b/runtime/lib/adapter/DBMSSQL.php @@ -33,6 +33,7 @@ public function setCharset(PDO $con, $charset) * This method is used to ignore case. * * @param string $in The string to transform to upper case. + * * @return string The upper case string. */ public function toUpperCase($in) @@ -44,6 +45,7 @@ public function toUpperCase($in) * This method is used to ignore case. * * @param string $in The string whose case to ignore. + * * @return string The string in a case that can be ignored. */ public function ignoreCase($in) @@ -82,6 +84,7 @@ public function subString($s, $pos, $len) * Returns SQL which calculates the length (in chars) of a string. * * @param string $s String to calculate length of. + * * @return string */ public function strLength($s) @@ -93,6 +96,7 @@ public function strLength($s) * @see DBAdapter::quoteIdentifier() * * @param string $text + * * @return string */ public function quoteIdentifier($text) @@ -104,6 +108,7 @@ public function quoteIdentifier($text) * @see DBAdapter::quoteIdentifierTable() * * @param string $table + * * @return string */ public function quoteIdentifierTable($table) @@ -116,6 +121,7 @@ public function quoteIdentifierTable($table) * @see DBAdapter::random() * * @param string $seed + * * @return string */ public function random($seed = null) @@ -144,7 +150,7 @@ public function random($seed = null) public function applyLimit(&$sql, $offset, $limit) { // make sure offset and limit are numeric - if (! is_numeric($offset) || ! is_numeric($limit)) { + if (!is_numeric($offset) || !is_numeric($limit)) { throw new PropelException('DBMSSQL::applyLimit() expects a number for argument 2 and 3'); } @@ -185,7 +191,7 @@ public function applyLimit(&$sql, $offset, $limit) $order = str_ireplace('ORDER BY', '', $orderStatement); $orders = array_map('trim', explode(',', $order)); - for ($i = 0; $i < count($orders); $i ++) { + for ($i = 0; $i < count($orders); $i++) { $orderArr[trim(preg_replace('/\s+(ASC|DESC)$/i', '', $orders[$i]))] = array( 'sort' => (stripos($orders[$i], ' DESC') !== false) ? 'DESC' : 'ASC', 'key' => $i @@ -201,7 +207,7 @@ public function applyLimit(&$sql, $offset, $limit) $selColCount = count($selColArr) - 1; //make sure the current column isn't * or an aggregate - if ($selColArr[0] != '*' && ! strstr($selColArr[0], '(')) { + if ($selColArr[0] != '*' && !strstr($selColArr[0], '(')) { // Aliases can be used in ORDER BY clauses on a SELECT, // but aliases are not valid in the ORDER BY clause of ROW_NUMBER() OVER (...), @@ -209,11 +215,11 @@ public function applyLimit(&$sql, $offset, $limit) // we replace it with the original Table.Column designation. if ($selColCount) { // column with alias - foreach (array(' ASC',' DESC') as $sort) { - $index = array_search($selColArr[2].$sort,$orders); - if ($index !== FALSE) { + foreach (array(' ASC', ' DESC') as $sort) { + $index = array_search($selColArr[2] . $sort, $orders); + if ($index !== false) { // replace alias with "Table.Column ASC/DESC" - $orders[$index] = $selColArr[0].$sort; + $orders[$index] = $selColArr[0] . $sort; break; } } @@ -224,12 +230,14 @@ public function applyLimit(&$sql, $offset, $limit) } //use the alias if one was present otherwise use the column name - $alias = (! stristr($selCol, ' AS ')) ? $selColArr[0] : $selColArr[$selColCount]; + $alias = (!stristr($selCol, ' AS ')) ? $selColArr[0] : $selColArr[$selColCount]; //don't quote the identifier if it is already quoted - if($alias[0] != '[') $alias = $this->quoteIdentifier($alias); + if ($alias[0] != '[') { + $alias = $this->quoteIdentifier($alias); + } //save the first non-aggregate column for use in ROW_NUMBER() if required - if (! isset($firstColumnOrderStatement)) { + if (!isset($firstColumnOrderStatement)) { $firstColumnOrderStatement = 'ORDER BY ' . $selColArr[0]; } @@ -238,7 +246,7 @@ public function applyLimit(&$sql, $offset, $limit) $outerSelect .= $alias . ', '; } else { //aggregate columns must always have an alias clause - if (! stristr($selCol, ' AS ')) { + if (!stristr($selCol, ' AS ')) { throw new Exception('DBMSSQL::applyLimit() requires aggregate columns to have an Alias clause'); } @@ -250,7 +258,9 @@ public function applyLimit(&$sql, $offset, $limit) //quote the alias $alias = $selColArr[$selColCount]; //don't quote the identifier if it is already quoted - if($alias[0] != '[') $alias = $this->quoteIdentifier($alias); + if ($alias[0] != '[') { + $alias = $this->quoteIdentifier($alias); + } $innerSelect .= str_replace($selColArr[$selColCount], $alias, $selCol) . ', '; $outerSelect .= $alias . ', '; } @@ -268,9 +278,9 @@ public function applyLimit(&$sql, $offset, $limit) } //substring the select strings to get rid of the last comma and add our FROM and SELECT clauses - $innerSelect = $selectText . 'ROW_NUMBER() OVER(' . $orderStatement . ') AS [RowNumber], ' . substr($innerSelect, 0, - 2) . ' FROM'; + $innerSelect = $selectText . 'ROW_NUMBER() OVER(' . $orderStatement . ') AS [RowNumber], ' . substr($innerSelect, 0, -2) . ' FROM'; //outer select can't use * because of the RowNumber column - $outerSelect = 'SELECT ' . substr($outerSelect, 0, - 2) . ' FROM'; + $outerSelect = 'SELECT ' . substr($outerSelect, 0, -2) . ' FROM'; //ROW_NUMBER() starts at 1 not 0 $sql = $outerSelect . ' (' . $innerSelect . ' ' . $fromStatement . ') AS derivedb WHERE RowNumber BETWEEN ' . ($offset + 1) . ' AND ' . ($limit + $offset); @@ -316,7 +326,7 @@ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap unset($paramCols); preg_match_all('/:p\d/', $sql, $matches); foreach ($matches[0] as $key => $match) { - $sql = str_replace($match, ':p'.($key+1), $sql); + $sql = str_replace($match, ':p' . ($key + 1), $sql); } } } diff --git a/runtime/lib/adapter/DBMySQL.php b/runtime/lib/adapter/DBMySQL.php index 0782e9b15..e809e3fdd 100644 --- a/runtime/lib/adapter/DBMySQL.php +++ b/runtime/lib/adapter/DBMySQL.php @@ -24,6 +24,7 @@ class DBMySQL extends DBAdapter * This method is used to ignore case. * * @param string $in The string to transform to upper case. + * * @return string The upper case string. */ public function toUpperCase($in) @@ -35,6 +36,7 @@ public function toUpperCase($in) * This method is used to ignore case. * * @param string $in The string whose case to ignore. + * * @return string The string in a case that can be ignored. */ public function ignoreCase($in) @@ -73,6 +75,7 @@ public function subString($s, $pos, $len) * Returns SQL which calculates the length (in chars) of a string. * * @param string $s String to calculate length of. + * * @return string */ public function strLength($s) @@ -110,6 +113,7 @@ public function unlockTable(PDO $con, $table) * @see DBAdapter::quoteIdentifier() * * @param string $text + * * @return string */ public function quoteIdentifier($text) @@ -121,6 +125,7 @@ public function quoteIdentifier($text) * @see DBAdapter::quoteIdentifierTable() * * @param string $table + * * @return string */ public function quoteIdentifierTable($table) @@ -159,11 +164,12 @@ public function applyLimit(&$sql, $offset, $limit) * @see DBAdapter::random() * * @param string $seed + * * @return string */ public function random($seed = null) { - return 'rand('.((int) $seed).')'; + return 'rand(' . ((int) $seed) . ')'; } /** @@ -203,6 +209,7 @@ public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMa * See: http://www.propelorm.org/ticket/1360 * * @param array $params + * * @return array * * @throws PropelException @@ -258,6 +265,7 @@ public function prepareParams($params) * * @param PropelPDO $con propel connection * @param ModelCriteria|string $query query the criteria or the query string + * * @throws PropelException * @return PDOStatement A PDO statement executed using the connection, ready to be fetched */ diff --git a/runtime/lib/adapter/DBNone.php b/runtime/lib/adapter/DBNone.php index 53d8ac070..367e7b8d5 100644 --- a/runtime/lib/adapter/DBNone.php +++ b/runtime/lib/adapter/DBNone.php @@ -34,6 +34,7 @@ public function initConnection(PDO $con, array $settings) * This method is used to ignore case. * * @param string $in The string to transform to upper case. + * * @return string The upper case string. */ public function toUpperCase($in) @@ -45,6 +46,7 @@ public function toUpperCase($in) * This method is used to ignore case. * * @param string $in The string whose case to ignore. + * * @return string The string in a case that can be ignored. */ public function ignoreCase($in) @@ -83,6 +85,7 @@ public function subString($s, $pos, $len) * Returns SQL which calculates the length (in chars) of a string. * * @param string $s String to calculate length of. + * * @return string */ public function strLength($s) diff --git a/runtime/lib/adapter/DBOracle.php b/runtime/lib/adapter/DBOracle.php index c4a5337a1..24e4f6e86 100644 --- a/runtime/lib/adapter/DBOracle.php +++ b/runtime/lib/adapter/DBOracle.php @@ -49,6 +49,7 @@ public function initConnection(PDO $con, array $settings) * This method is used to ignore case. * * @param string $in The string to transform to upper case. + * * @return string The upper case string. */ public function toUpperCase($in) @@ -60,6 +61,7 @@ public function toUpperCase($in) * This method is used to ignore case. * * @param string $in The string whose case to ignore. + * * @return string The string in a case that can be ignored. */ public function ignoreCase($in) @@ -98,6 +100,7 @@ public function subString($s, $pos, $len) * Returns SQL which calculates the length (in chars) of a string. * * @param string $s String to calculate length of. + * * @return string */ public function strLength($s) @@ -127,7 +130,7 @@ public function applyLimit(&$sql, $offset, $limit, $criteria = null) if ($offset > 0) { $sql .= ' B.PROPEL_ROWNUM > ' . $offset; if ($limit > 0) { - $sql .= ' AND B.PROPEL_ROWNUM <= ' . ( $offset + $limit ); + $sql .= ' AND B.PROPEL_ROWNUM <= ' . ($offset + $limit); } } else { $sql .= ' B.PROPEL_ROWNUM <= ' . $limit; @@ -163,9 +166,10 @@ public function getId(PDO $con, $name = null) /** * @param string $seed + * * @return string */ - public function random($seed=NULL) + public function random($seed = null) { return 'dbms_random.value'; } @@ -177,6 +181,7 @@ public function random($seed=NULL) * @see http://propel.phpdb.org/trac/ticket/795 * * @param Criteria $criteria + * * @return Criteria The input, with Select columns replaced by aliases */ public function turnSelectColumnsToAliases(Criteria $criteria) @@ -189,7 +194,7 @@ public function turnSelectColumnsToAliases(Criteria $criteria) // add the select columns back foreach ($selectColumns as $id => $clause) { // Generate a unique alias - $baseAlias = "ORA_COL_ALIAS_".$id; + $baseAlias = "ORA_COL_ALIAS_" . $id; $alias = $baseAlias; // If it already exists, add a unique suffix $i = 0; @@ -227,7 +232,7 @@ public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMa if ($cMap->isTemporal()) { $value = $this->formatTemporalValue($value, $cMap); } elseif ($cMap->getType() == PropelColumnTypes::CLOB_EMU) { - return $stmt->bindParam(':p'.$position, $value, $cMap->getPdoType(), strlen($value)); + return $stmt->bindParam(':p' . $position, $value, $cMap->getPdoType(), strlen($value)); } elseif (is_resource($value) && $cMap->isLob()) { // we always need to make sure that the stream is rewound, otherwise nothing will // get written to database. @@ -242,6 +247,7 @@ public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMa * * @param PropelPDO $con propel connection * @param ModelCriteria|string $query query the criteria or the query string + * * @throws PropelException * @return PDOStatement A PDO statement executed using the connection, ready to be fetched */ @@ -291,6 +297,7 @@ public function getExplainPlanQuery($query, $uniqueId) * Explain Plan read query * * @param string $uniqueId + * * @return string query unique id */ public function getExplainPlanReadQuery($uniqueId) diff --git a/runtime/lib/adapter/DBPostgres.php b/runtime/lib/adapter/DBPostgres.php index 10d383ea7..a04926a09 100644 --- a/runtime/lib/adapter/DBPostgres.php +++ b/runtime/lib/adapter/DBPostgres.php @@ -25,6 +25,7 @@ class DBPostgres extends DBAdapter * This method is used to ignore case. * * @param string $in The string to transform to upper case. + * * @return string The upper case string. */ public function toUpperCase($in) @@ -36,6 +37,7 @@ public function toUpperCase($in) * This method is used to ignore case. * * @param string $in The string whose case to ignore. + * * @return string The string in a case that can be ignored. */ public function ignoreCase($in) @@ -74,6 +76,7 @@ public function subString($s, $pos, $len) * Returns SQL which calculates the length (in chars) of a string. * * @param string $s String to calculate length of. + * * @return string */ public function strLength($s) @@ -108,7 +111,7 @@ public function getId(PDO $con, $name = null) if ($name === null) { throw new PropelException("Unable to fetch next sequence ID without sequence name."); } - $stmt = $con->query("SELECT nextval(".$con->quote($name).")"); + $stmt = $con->query("SELECT nextval(" . $con->quote($name) . ")"); $row = $stmt->fetch(PDO::FETCH_NUM); return $row[0]; @@ -116,6 +119,7 @@ public function getId(PDO $con, $name = null) /** * Returns timestamp formatter string for use in date() function. + * * @return string */ public function getTimestampFormatter() @@ -143,10 +147,10 @@ public function getTimeFormatter() public function applyLimit(&$sql, $offset, $limit) { if ($limit > 0) { - $sql .= " LIMIT ".$limit; + $sql .= " LIMIT " . $limit; } if ($offset > 0) { - $sql .= " OFFSET ".$offset; + $sql .= " OFFSET " . $offset; } } @@ -154,9 +158,10 @@ public function applyLimit(&$sql, $offset, $limit) * @see DBAdapter::random() * * @param string $seed + * * @return string */ - public function random($seed=NULL) + public function random($seed = null) { return 'random()'; } @@ -194,6 +199,7 @@ public function getDeleteFromClause($criteria, $tableName) * @see DBAdapter::quoteIdentifierTable() * * @param string $table + * * @return string */ public function quoteIdentifierTable($table) @@ -202,44 +208,45 @@ public function quoteIdentifierTable($table) return '"' . strtr($table, array('.' => '"."', ' ' => '" "')) . '"'; } - /** - * Do Explain Plan for query object or query string - * - * @param PropelPDO $con propel connection - * @param ModelCriteria|string $query query the criteria or the query string - * @throws PropelException - * @return PDOStatement A PDO statement executed using the connection, ready to be fetched - */ - public function doExplainPlan(PropelPDO $con, $query) - { - if ($query instanceof ModelCriteria) { - $params = array(); - $dbMap = Propel::getDatabaseMap($query->getDbName()); - $sql = BasePeer::createSelectSql($query, $params); - } else { - $sql = $query; - } + /** + * Do Explain Plan for query object or query string + * + * @param PropelPDO $con propel connection + * @param ModelCriteria|string $query query the criteria or the query string + * + * @throws PropelException + * @return PDOStatement A PDO statement executed using the connection, ready to be fetched + */ + public function doExplainPlan(PropelPDO $con, $query) + { + if ($query instanceof ModelCriteria) { + $params = array(); + $dbMap = Propel::getDatabaseMap($query->getDbName()); + $sql = BasePeer::createSelectSql($query, $params); + } else { + $sql = $query; + } + + $stmt = $con->prepare($this->getExplainPlanQuery($sql)); - $stmt = $con->prepare($this->getExplainPlanQuery($sql)); + if ($query instanceof ModelCriteria) { + $this->bindValues($stmt, $params, $dbMap); + } + + $stmt->execute(); - if ($query instanceof ModelCriteria) { - $this->bindValues($stmt, $params, $dbMap); + return $stmt; } - $stmt->execute(); - - return $stmt; - } - - /** - * Explain Plan compute query getter - * - * @param string $query query to explain - * - * @return string - */ - public function getExplainPlanQuery($query) - { - return 'EXPLAIN ' . $query; - } + /** + * Explain Plan compute query getter + * + * @param string $query query to explain + * + * @return string + */ + public function getExplainPlanQuery($query) + { + return 'EXPLAIN ' . $query; + } } diff --git a/runtime/lib/adapter/DBSQLSRV.php b/runtime/lib/adapter/DBSQLSRV.php index a21bc58fb..adb3c63ad 100644 --- a/runtime/lib/adapter/DBSQLSRV.php +++ b/runtime/lib/adapter/DBSQLSRV.php @@ -42,14 +42,14 @@ public function initConnection(PDO $con, array $settings) public function setCharset(PDO $con, $charset) { switch (strtolower($charset)) { - case 'utf-8': - $con->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_UTF8); - break; - case 'system': - $con->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_SYSTEM); - break; - default: - throw new PropelException('only utf-8 or system encoding are supported by the pdo_sqlsrv driver'); + case 'utf-8': + $con->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_UTF8); + break; + case 'system': + $con->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_SYSTEM); + break; + default: + throw new PropelException('only utf-8 or system encoding are supported by the pdo_sqlsrv driver'); } } @@ -104,7 +104,7 @@ public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMa // driver option can be utilized. This requires a unique blob parameter because the bindParam // value is passed by reference and if we didn't do this then the referenced parameter value // would change on the next loop - $blob = "blob".$position; + $blob = "blob" . $position; $$blob = $value; return $stmt->bindParam($parameter, ${$blob}, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY); diff --git a/runtime/lib/adapter/DBSQLite.php b/runtime/lib/adapter/DBSQLite.php index f940e5915..a3dfa3af6 100644 --- a/runtime/lib/adapter/DBSQLite.php +++ b/runtime/lib/adapter/DBSQLite.php @@ -35,6 +35,7 @@ public function setCharset(PDO $con, $charset) * This method is used to ignore case. * * @param string $in The string to transform to upper case. + * * @return string The upper case string. */ public function toUpperCase($in) @@ -46,6 +47,7 @@ public function toUpperCase($in) * This method is used to ignore case. * * @param string $in The string whose case to ignore. + * * @return string The string in a case that can be ignored. */ public function ignoreCase($in) @@ -84,6 +86,7 @@ public function subString($s, $pos, $len) * Returns SQL which calculates the length (in chars) of a string. * * @param string $s String to calculate length of. + * * @return string */ public function strLength($s) @@ -95,6 +98,7 @@ public function strLength($s) * @see DBAdapter::quoteIdentifier() * * @param string $text + * * @return string */ public function quoteIdentifier($text) @@ -120,9 +124,10 @@ public function applyLimit(&$sql, $offset, $limit) /** * @param string $seed + * * @return string */ - public function random($seed = NULL) + public function random($seed = null) { return 'random()'; } diff --git a/runtime/lib/adapter/MSSQL/MssqlPropelPDO.php b/runtime/lib/adapter/MSSQL/MssqlPropelPDO.php index ba3cb2d21..c5d3d75c4 100644 --- a/runtime/lib/adapter/MSSQL/MssqlPropelPDO.php +++ b/runtime/lib/adapter/MSSQL/MssqlPropelPDO.php @@ -62,7 +62,6 @@ public function commit() if ($this->useDebug) { $this->log('Commit transaction', null, __METHOD__); } - } } $this->nestedTransactionCount--; @@ -130,6 +129,7 @@ public function forceRollBack() /** * @param string $seqname + * * @return integer */ public function lastInsertId($seqname = null) @@ -141,6 +141,7 @@ public function lastInsertId($seqname = null) /** * @param string $text + * * @return string */ public function quoteIdentifier($text) diff --git a/runtime/lib/collection/PropelArrayCollection.php b/runtime/lib/collection/PropelArrayCollection.php index 4ddd5c8fd..834cc291a 100644 --- a/runtime/lib/collection/PropelArrayCollection.php +++ b/runtime/lib/collection/PropelArrayCollection.php @@ -82,6 +82,7 @@ public function delete($con = null) * Get an array of the primary keys of all the objects in the collection * * @param boolean $usePrefix + * * @return array The list of the primary keys of the collection */ public function getPrimaryKeys($usePrefix = true) @@ -90,7 +91,7 @@ public function getPrimaryKeys($usePrefix = true) $ret = array(); foreach ($this as $key => $element) { $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; - $ret[$key]= call_user_func($callable, array_values($element)); + $ret[$key] = call_user_func($callable, array_values($element)); } return $ret; @@ -105,7 +106,7 @@ public function getPrimaryKeys($usePrefix = true) */ public function fromArray($arr) { - $obj = $this->getWorkerObject(); + $obj = $this->getWorkerObject(); foreach ($arr as $element) { $obj->clear(); $obj->fromArray($element); diff --git a/runtime/lib/collection/PropelCollection.php b/runtime/lib/collection/PropelCollection.php index 6cd5a28d0..19ab9b7f9 100644 --- a/runtime/lib/collection/PropelCollection.php +++ b/runtime/lib/collection/PropelCollection.php @@ -208,6 +208,7 @@ public function isEven() * Alias for ArrayObject::offsetGet() * * @param mixed $key + * * @return mixed The element * * @throws PropelException @@ -258,6 +259,7 @@ public function shift() * Prepend one or more elements to the beginning of the collection * * @param mixed $value the element to prepend + * * @return integer The number of new elements in the array */ public function prepend($value) @@ -288,6 +290,7 @@ public function set($key, $value) * Alias for ArrayObject::offsetUnset() * * @param mixed $key + * * @return mixed The removed element * * @throws PropelException @@ -315,6 +318,7 @@ public function clear() * Whether or not this collection contains a specified element * * @param mixed $element + * * @return boolean */ public function contains($element) @@ -326,6 +330,7 @@ public function contains($element) * Search an element in the collection * * @param mixed $element + * * @return mixed Returns the key for the element if it is found in the collection, FALSE otherwise */ public function search($element) @@ -338,6 +343,7 @@ public function search($element) * are not presents in the given collection. * * @param PropelCollection $collection A Propel collection. + * * @return PropelCollection An array of Propel objects from the collection that are not presents in the given collection. */ public function diff(PropelCollection $collection) @@ -412,6 +418,7 @@ public function getInternalIterator() * Clear the internal Iterator. * PHP 5.3 doesn't know how to free a PropelCollection object if it has an attached * Iterator, so this must be done manually to avoid memory leaks. + * * @see http://www.propelorm.org/ticket/1232 */ public function clearIterator() @@ -477,6 +484,7 @@ public function getFormatter() * Get a connection object for the database containing the elements of the collection * * @param string $type The connection type (Propel::CONNECTION_READ by default; can be Propel::connection_WRITE) + * * @return PropelPDO A PropelPDO connection object */ public function getConnection($type = Propel::CONNECTION_READ) @@ -526,6 +534,7 @@ public function importFrom($parser, $data) * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. * Not supported by PropelArrayCollection, as PropelArrayFormatter has * already included lazy-load columns in the array used here. + * * @return string The exported data */ public function exportTo($parser, $usePrefix = true, $includeLazyLoadColumns = true) diff --git a/runtime/lib/collection/PropelObjectCollection.php b/runtime/lib/collection/PropelObjectCollection.php index 22e6784cb..0b34b3c08 100644 --- a/runtime/lib/collection/PropelObjectCollection.php +++ b/runtime/lib/collection/PropelObjectCollection.php @@ -76,6 +76,7 @@ public function delete($con = null) * Get an array of the primary keys of all the objects in the collection * * @param boolean $usePrefix + * * @return array The list of the primary keys of the collection */ public function getPrimaryKeys($usePrefix = true) @@ -85,7 +86,7 @@ public function getPrimaryKeys($usePrefix = true) /** @var $obj BaseObject */ foreach ($this as $key => $obj) { $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; - $ret[$key]= $obj->getPrimaryKey(); + $ret[$key] = $obj->getPrimaryKey(); } return $ret; @@ -201,7 +202,7 @@ protected function getValueForColumns($object, array $columns) $value = $object; foreach ($columns as $eachKeyColumn) { - $keyGetterMethod = 'get'.$eachKeyColumn; + $keyGetterMethod = 'get' . $eachKeyColumn; $value = $value->$keyGetterMethod(); } @@ -254,7 +255,7 @@ public function populateRelation($relation, $criteria = null, $con = null) $getMethod = 'get' . $symRelationMap->getName(); $addMethod = 'add' . $relationName; foreach ($relatedObjects as $object) { - $mainObj = $object->$getMethod(); // instance pool is used here to avoid a query + $mainObj = $object->$getMethod(); // instance pool is used here to avoid a query $mainObj->$addMethod($object); } $relatedObjects->clearIterator(); diff --git a/runtime/lib/collection/PropelOnDemandCollection.php b/runtime/lib/collection/PropelOnDemandCollection.php index 1c8aca66d..14759c24c 100644 --- a/runtime/lib/collection/PropelOnDemandCollection.php +++ b/runtime/lib/collection/PropelOnDemandCollection.php @@ -58,6 +58,7 @@ public function getIterator() /** * @throws PropelException + * * @param integer $offset * * @return boolean @@ -69,6 +70,7 @@ public function offsetExists($offset) /** * @throws PropelException + * * @param integer $offset * * @return mixed @@ -91,6 +93,7 @@ public function offsetSet($offset, $value) /** * @throws PropelException + * * @param integer $offset */ public function offsetUnset($offset) @@ -110,6 +113,7 @@ public function serialize() /** * @throws PropelException + * * @param string $data * * @return void diff --git a/runtime/lib/collection/PropelOnDemandIterator.php b/runtime/lib/collection/PropelOnDemandIterator.php index abe0450f8..ed20385f3 100644 --- a/runtime/lib/collection/PropelOnDemandIterator.php +++ b/runtime/lib/collection/PropelOnDemandIterator.php @@ -47,7 +47,7 @@ class PropelOnDemandIterator implements Iterator public function __construct(PropelFormatter $formatter, PDOStatement $stmt) { $this->formatter = $formatter; - $this->stmt = $stmt; + $this->stmt = $stmt; $this->enableInstancePoolingOnFinish = Propel::disableInstancePooling(); } diff --git a/runtime/lib/config/PropelConfiguration.php b/runtime/lib/config/PropelConfiguration.php index e3009dcdb..59f0cbbb2 100644 --- a/runtime/lib/config/PropelConfiguration.php +++ b/runtime/lib/config/PropelConfiguration.php @@ -44,6 +44,7 @@ public function __construct(array $parameters = array()) * @see http://www.php.net/ArrayAccess * * @param integer $offset + * * @return boolean */ public function offsetExists($offset) @@ -67,6 +68,7 @@ public function offsetSet($offset, $value) * @see http://www.php.net/ArrayAccess * * @param integer $offset + * * @return array */ public function offsetGet($offset) @@ -96,7 +98,7 @@ public function offsetUnset($offset) * echo $c->getParameter('foo1'); => null * echo $c->getParameter('foo1.foo2'); => 'bar' *
- * + * * @param string $name Parameter name * @param mixed $default Default value to be used if the requested value is not found * @@ -146,6 +148,7 @@ public function setParameter($name, $value, $autoFlattenArrays = true) * @throws PropelException * * @param integer $type + * * @return mixed */ public function getParameters($type = PropelConfiguration::TYPE_ARRAY) @@ -158,7 +161,7 @@ public function getParameters($type = PropelConfiguration::TYPE_ARRAY) case PropelConfiguration::TYPE_OBJECT: return $this; default: - throw new PropelException('Unknown configuration type: '. var_export($type, true)); + throw new PropelException('Unknown configuration type: ' . var_export($type, true)); } } @@ -180,7 +183,7 @@ protected function flattenParameters() $result = array(); $it = new PropelConfigurationIterator(new RecursiveArrayIterator($this->parameters), RecursiveIteratorIterator::SELF_FIRST); foreach ($it as $key => $value) { - $ns = $it->getDepth() ? $it->getNamespace() . '.'. $key : $key; + $ns = $it->getDepth() ? $it->getNamespace() . '.' . $key : $key; if ($it->getNodeType() == PropelConfigurationIterator::NODE_ITEM) { $result[$ns] = $value; } diff --git a/runtime/lib/connection/DebugPDOStatement.php b/runtime/lib/connection/DebugPDOStatement.php index 3f0ca3715..602b24b84 100644 --- a/runtime/lib/connection/DebugPDOStatement.php +++ b/runtime/lib/connection/DebugPDOStatement.php @@ -52,6 +52,7 @@ class DebugPDOStatement extends PDOStatement * which this instance was created. * * @param PropelPDO $pdo Reference to the parent PDO instance. + * * @return DebugPDOStatement */ protected function __construct(PropelPDO $pdo) @@ -68,7 +69,7 @@ public function getExecutedQueryString() $matches = array(); if (preg_match_all('/(:p[0-9]+\b)/', $sql, $matches)) { $size = count($matches[1]); - for ($i = $size-1; $i >= 0; $i--) { + for ($i = $size - 1; $i >= 0; $i--) { $pos = $matches[1][$i]; $sql = str_replace($pos, $this->boundValues[$pos], $sql); } @@ -82,12 +83,13 @@ public function getExecutedQueryString() * Overridden for query counting and logging. * * @param string $input_parameters + * * @return boolean */ public function execute($input_parameters = null) { - $debug = $this->pdo->getDebugSnapshot(); - $return = parent::execute($input_parameters); + $debug = $this->pdo->getDebugSnapshot(); + $return = parent::execute($input_parameters); $sql = $this->getExecutedQueryString(); $this->pdo->log($sql, null, __METHOD__, $debug); @@ -109,11 +111,11 @@ public function execute($input_parameters = null) */ public function bindValue($pos, $value, $type = PDO::PARAM_STR) { - $debug = $this->pdo->getDebugSnapshot(); - $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)'; - $return = parent::bindValue($pos, $value, $type); + $debug = $this->pdo->getDebugSnapshot(); + $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)'; + $return = parent::bindValue($pos, $value, $type); $valuestr = $type == PDO::PARAM_LOB ? '[LOB value]' : var_export($value, true); - $msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr); + $msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr); $this->boundValues[$pos] = $valuestr; @@ -138,11 +140,11 @@ public function bindValue($pos, $value, $type = PDO::PARAM_STR) */ public function bindParam($pos, &$value, $type = PDO::PARAM_STR, $length = 0, $driver_options = null) { - $debug = $this->pdo->getDebugSnapshot(); - $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)'; - $return = parent::bindParam($pos, $value, $type, $length, $driver_options); + $debug = $this->pdo->getDebugSnapshot(); + $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)'; + $return = parent::bindParam($pos, $value, $type, $length, $driver_options); $valuestr = $length > 100 ? '[Large value]' : var_export($value, true); - $msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr); + $msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr); $this->boundValues[$pos] = $valuestr; diff --git a/runtime/lib/connection/PropelPDO.php b/runtime/lib/connection/PropelPDO.php index fa4951ef2..3b7356462 100644 --- a/runtime/lib/connection/PropelPDO.php +++ b/runtime/lib/connection/PropelPDO.php @@ -40,11 +40,12 @@ class PropelPDO extends PDO */ const PROPEL_ATTR_CONNECTION_NAME = -2; - const DEFAULT_SLOW_THRESHOLD = 0.1; - const DEFAULT_ONLYSLOW_ENABLED = false; + const DEFAULT_SLOW_THRESHOLD = 0.1; + const DEFAULT_ONLYSLOW_ENABLED = false; /** * The current transaction depth. + * * @var integer */ protected $nestedTransactionCount = 0; @@ -193,6 +194,7 @@ public function getNestedTransactionCount() /** * Set the current transaction depth. + * * @param int $v The new depth. */ protected function setNestedTransactionCount($v) @@ -301,11 +303,11 @@ public function rollBack() } /** - * Rollback the whole transaction, even if this is a nested rollback - * and reset the nested transaction count to 0. + * Rollback the whole transaction, even if this is a nested rollback + * and reset the nested transaction count to 0. * - * @return boolean Whether operation was successful. - */ + * @return boolean Whether operation was successful. + */ public function forceRollBack() { $return = true; @@ -357,6 +359,7 @@ public function setAttribute($attribute, $value) * This is overridden here to provide support for setting Propel-specific attributes too. * * @param integer $attribute The attribute to get (e.g. PropelPDO::PROPEL_ATTR_CACHE_PREPARES). + * * @return mixed */ public function getAttribute($attribute) @@ -415,6 +418,7 @@ public function prepare($sql, $driver_options = array()) * Overrides PDO::exec() to log queries when required * * @param string $sql + * * @return integer */ public function exec($sql) @@ -626,7 +630,9 @@ public function log($msg, $level = null, $methodName = null, array $debugSnapsho // Determine if this query is slow enough to warrant logging if ($this->getLoggingConfig("onlyslow", self::DEFAULT_ONLYSLOW_ENABLED)) { $now = $this->getDebugSnapshot(); - if ($now['microtime'] - $debugSnapshot['microtime'] < $this->getLoggingConfig("details.slow.threshold", self::DEFAULT_SLOW_THRESHOLD)) return; + if ($now['microtime'] - $debugSnapshot['microtime'] < $this->getLoggingConfig("details.slow.threshold", self::DEFAULT_SLOW_THRESHOLD)) { + return; + } } // If the necessary additional parameters were given, get the debug log prefix for the log line @@ -702,11 +708,11 @@ protected function getLogPrefix($methodName, $debugSnapshot) if (!isset($config['debugpdo']['logging']['details'])) { return ''; } - $prefix = ''; + $prefix = ''; $logDetails = $config['debugpdo']['logging']['details']; - $now = $this->getDebugSnapshot(); - $innerGlue = $this->getLoggingConfig('innerglue', ': '); - $outerGlue = $this->getLoggingConfig('outerglue', ' | '); + $now = $this->getDebugSnapshot(); + $innerGlue = $this->getLoggingConfig('innerglue', ': '); + $outerGlue = $this->getLoggingConfig('outerglue', ' | '); // Iterate through each detail that has been configured to be enabled foreach ($logDetails as $detailName => $details) { @@ -757,11 +763,9 @@ protected function getLogPrefix($methodName, $debugSnapshot) default: $value = 'n/a'; break; - } $prefix .= $detailName . $innerGlue . $value . $outerGlue; - } return $prefix; diff --git a/runtime/lib/exception/PropelException.php b/runtime/lib/exception/PropelException.php index cb6c8f4b0..ac41d55c2 100644 --- a/runtime/lib/exception/PropelException.php +++ b/runtime/lib/exception/PropelException.php @@ -10,6 +10,7 @@ /** * The base class of all exceptions thrown by Propel. + * * @author Hans Lellelid * @version $Revision$ * @package propel.runtime.exception @@ -39,7 +40,7 @@ public function __construct($message = null, Exception $previous = null) } if ($previous !== null) { - $message .= " [wrapped: " . $previous->getMessage() ."]"; + $message .= " [wrapped: " . $previous->getMessage() . "]"; if (version_compare(PHP_VERSION, '5.3.0') >= 0) { parent::__construct($message, 0, $previous); } else { diff --git a/runtime/lib/formatter/PropelArrayFormatter.php b/runtime/lib/formatter/PropelArrayFormatter.php index 287f2fad4..e5d334d82 100644 --- a/runtime/lib/formatter/PropelArrayFormatter.php +++ b/runtime/lib/formatter/PropelArrayFormatter.php @@ -85,7 +85,7 @@ public function isObjectFormatter() * The first object to hydrate is the model of the Criteria * The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one * - * @param array $row associative array indexed by column number, + * @param array $row associative array indexed by column number, * as returned by PDOStatement::fetch(PDO::FETCH_NUM) * * @return Array @@ -166,5 +166,4 @@ public function &getStructuredArrayFromRow($row) return $emptyVariable; } } - } diff --git a/runtime/lib/formatter/PropelFormatter.php b/runtime/lib/formatter/PropelFormatter.php index 61f9bdfd4..362faf1d6 100644 --- a/runtime/lib/formatter/PropelFormatter.php +++ b/runtime/lib/formatter/PropelFormatter.php @@ -198,5 +198,4 @@ public function getSingleObjectFromRow($row, $class, &$col = 0) return $obj; } - } diff --git a/runtime/lib/formatter/PropelObjectFormatter.php b/runtime/lib/formatter/PropelObjectFormatter.php index 7b461793c..1680ea365 100644 --- a/runtime/lib/formatter/PropelObjectFormatter.php +++ b/runtime/lib/formatter/PropelObjectFormatter.php @@ -40,7 +40,7 @@ public function format(PDOStatement $stmt) $objectsByPks = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $object = $this->getAllObjectsFromRow($row); - $pk = $object->getPrimaryKey(); + $pk = $object->getPrimaryKey(); if (false === Propel::isInstancePoolingEnabled()) { if (isset($objectsByPks[$pk])) { @@ -59,7 +59,7 @@ public function format(PDOStatement $stmt) } else { // only many-to-one relationships while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $collection[] = $this->getAllObjectsFromRow($row); + $collection[] = $this->getAllObjectsFromRow($row); } } $stmt->closeCursor(); @@ -92,7 +92,7 @@ public function isObjectFormatter() * The first object to hydrate is the model of the Criteria * The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one * - * @param array $row associative array indexed by column number, + * @param array $row associative array indexed by column number, * as returned by PDOStatement::fetch(PDO::FETCH_NUM) * * @return BaseObject diff --git a/runtime/lib/formatter/PropelOnDemandFormatter.php b/runtime/lib/formatter/PropelOnDemandFormatter.php index fe4521b24..b034641ef 100644 --- a/runtime/lib/formatter/PropelOnDemandFormatter.php +++ b/runtime/lib/formatter/PropelOnDemandFormatter.php @@ -50,7 +50,7 @@ public function format(PDOStatement $stmt) * The first object to hydrate is the model of the Criteria * The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one * - * @param array $row associative array indexed by column number, + * @param array $row associative array indexed by column number, * as returned by PDOStatement::fetch(PDO::FETCH_NUM) * * @return BaseObject @@ -103,5 +103,4 @@ public function getAllObjectsFromRow($row) return $obj; } - } diff --git a/runtime/lib/formatter/PropelStatementFormatter.php b/runtime/lib/formatter/PropelStatementFormatter.php index d11e62a1c..9566b4518 100644 --- a/runtime/lib/formatter/PropelStatementFormatter.php +++ b/runtime/lib/formatter/PropelStatementFormatter.php @@ -41,5 +41,4 @@ public function isObjectFormatter() { return false; } - } diff --git a/runtime/lib/logger/BasicLogger.php b/runtime/lib/logger/BasicLogger.php index 9766afd7a..121280c68 100644 --- a/runtime/lib/logger/BasicLogger.php +++ b/runtime/lib/logger/BasicLogger.php @@ -51,12 +51,14 @@ public function err($message); * @param mixed $message String or Exception object containing the message to log. */ public function warning($message); + /** * A convenience function for logging an critical event. * * @param mixed $message String or Exception object containing the message to log. */ public function notice($message); + /** * A convenience function for logging an critical event. * diff --git a/runtime/lib/logger/MojaviLogAdapter.php b/runtime/lib/logger/MojaviLogAdapter.php index 78b6b8bea..766d1614d 100644 --- a/runtime/lib/logger/MojaviLogAdapter.php +++ b/runtime/lib/logger/MojaviLogAdapter.php @@ -82,6 +82,7 @@ public function notice($message) { $this->log($message, 'notice'); } + /** * A convenience function for logging an critical event. * @@ -111,8 +112,9 @@ public function debug($message) */ public function log($message, $severity = null) { - if (is_null($this->logger)) + if (is_null($this->logger)) { $this->logger = LogManager::getLogger('propel'); + } switch ($severity) { case 'crit': diff --git a/runtime/lib/map/ColumnMap.php b/runtime/lib/map/ColumnMap.php index 56afaf287..789f2145d 100644 --- a/runtime/lib/map/ColumnMap.php +++ b/runtime/lib/map/ColumnMap.php @@ -26,506 +26,523 @@ class ColumnMap { - // Propel type of the column - protected $type; - - // Size of the column - protected $size = 0; - - // Is it a primary key? - protected $pk = false; - - // Is null value allowed? - protected $notNull = false; - - // The default value for this column - protected $defaultValue; - - // Name of the table that this column is related to - protected $relatedTableName = ""; - - // Name of the column that this column is related to - protected $relatedColumnName = ""; - - // The TableMap for this column - protected $table; - - // The name of the column - protected $columnName; - - // The php name of the column - protected $phpName; - - // The validators for this column - protected $validators = array(); - - // The allowed values for an ENUM column - protected $valueSet = array(); - - // Is this a primaryString column? - protected $isPkString = false; - - /** - * Constructor. - * - * @param string $name The name of the column. - * @param TableMap containingTable TableMap of the table this column is in. - */ - public function __construct($name, TableMap $containingTable) - { - $this->columnName = $name; - $this->table = $containingTable; - } - - /** - * Get the name of a column. - * - * @return string A String with the column name. - */ - public function getName() - { - return $this->columnName; - } - - /** - * Get the table map this column belongs to. - * @return TableMap - */ - public function getTable() - { - return $this->table; - } - - /** - * Get the name of the table this column is in. - * - * @return string A String with the table name. - */ - public function getTableName() - { - return $this->table->getName(); - } - - /** - * Get the table name + column name. - * - * @return string A String with the full column name. - */ - public function getFullyQualifiedName() - { - return $this->getTableName() . "." . $this->columnName; - } - - /** - * Set the php name of this column. - * - * @param string $phpName A string representing the PHP name. - * @return void - */ - public function setPhpName($phpName) - { - $this->phpName = $phpName; - } - - /** - * Get the name of a column. - * - * @return string A String with the column name. - */ - public function getPhpName() - { - return $this->phpName; - } - - /** - * Set the Propel type of this column. - * - * @param string $type A string representing the Propel type (e.g. PropelColumnTypes::DATE). - * @return void - */ - public function setType($type) - { - $this->type = $type; - } - - /** - * Get the Propel type of this column. - * - * @return string A string representing the Propel type (e.g. PropelColumnTypes::DATE). - */ - public function getType() - { - return $this->type; - } - - /** - * Get the PDO type of this column. - * - * @return int The PDO::PARMA_* value - */ - public function getPdoType() - { - return PropelColumnTypes::getPdoType($this->type); - } - - /** - * Whether this is a BLOB, LONGVARBINARY, or VARBINARY. - * @return boolean - */ - public function isLob() - { - return ($this->type == PropelColumnTypes::BLOB || $this->type == PropelColumnTypes::VARBINARY || $this->type == PropelColumnTypes::LONGVARBINARY); - } - - /** - * Whether this is a DATE/TIME/TIMESTAMP column. - * - * @return boolean - * @since 1.3 - */ - public function isTemporal() - { - return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME || $this->type == PropelColumnTypes::BU_DATE || $this->type == PropelColumnTypes::BU_TIMESTAMP); - } - - /** - * Whether this is a DATE/TIME/TIMESTAMP column that is post-epoch (1970). - * - * PHP cannot handle pre-epoch timestamps well -- hence the need to differentiate - * between epoch and pre-epoch timestamps. - * - * @return boolean - * @deprecated Propel supports non-epoch dates - */ - public function isEpochTemporal() - { - return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME); - } - - /** - * Whether this column is numeric (int, decimal, bigint etc). - * @return boolean - */ - public function isNumeric() - { - 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); - } - - /** - * Whether this column is an integer - * - * @return boolean - */ - public function isInteger() - { - return $this->getPdoType() === PDO::PARAM_INT; - } - - /** - * Whether this column is a text column (varchar, char, longvarchar). - * @return boolean - */ - public function isText() - { - return ($this->type == PropelColumnTypes::VARCHAR || $this->type == PropelColumnTypes::LONGVARCHAR || $this->type == PropelColumnTypes::CHAR); - } - - /** - * Set the size of this column. - * - * @param int $size An int specifying the size. - * @return void - */ - public function setSize($size) - { - $this->size = $size; - } - - /** - * Get the size of this column. - * - * @return int An int specifying the size. - */ - public function getSize() - { - return $this->size; - } - - /** - * Set if this column is a primary key or not. - * - * @param boolean $pk True if column is a primary key. - * @return void - */ - public function setPrimaryKey($pk) - { - $this->pk = $pk; - } - - /** - * Is this column a primary key? - * - * @return boolean True if column is a primary key. - */ - public function isPrimaryKey() - { - return $this->pk; - } - - /** - * Set if this column may be null. - * - * @param boolean nn True if column may be null. - * @return void - */ - public function setNotNull($nn) - { - $this->notNull = $nn; - } - - /** - * Is null value allowed ? - * - * @return boolean True if column may not be null. - */ - public function isNotNull() - { - return ($this->notNull || $this->isPrimaryKey()); - } - - /** - * Sets the default value for this column. - * @param mixed $defaultValue the default value for the column - * @return void - */ - public function setDefaultValue($defaultValue) - { - $this->defaultValue = $defaultValue; - } - - /** - * Gets the default value for this column. - * @return mixed String or NULL - */ - public function getDefaultValue() - { - return $this->defaultValue; - } - - /** - * Set the foreign key for this column. - * - * @param string tableName The name of the table that is foreign. - * @param string columnName The name of the column that is foreign. - * @return void - */ - public function setForeignKey($tableName, $columnName) - { - if ($tableName && $columnName) { - $this->relatedTableName = $tableName; - $this->relatedColumnName = $columnName; - } else { - $this->relatedTableName = ""; - $this->relatedColumnName = ""; - } - } - - /** - * Is this column a foreign key? - * - * @return boolean True if column is a foreign key. - */ - public function isForeignKey() - { - if ($this->relatedTableName) { - return true; - } else { - return false; - } - } - - /** - * Get the RelationMap object for this foreign key - * - * @return RelationMap|null - */ - public function getRelation() - { - if(!$this->relatedTableName) return null; - foreach ($this->getTable()->getRelations() as $name => $relation) { - if ($relation->getType() == RelationMap::MANY_TO_ONE) { - if ($relation->getForeignTable()->getName() == $this->getRelatedTableName() - && array_key_exists($this->getFullyQualifiedName(), $relation->getColumnMappings())) - { - return $relation; + // Propel type of the column + protected $type; + + // Size of the column + protected $size = 0; + + // Is it a primary key? + protected $pk = false; + + // Is null value allowed? + protected $notNull = false; + + // The default value for this column + protected $defaultValue; + + // Name of the table that this column is related to + protected $relatedTableName = ""; + + // Name of the column that this column is related to + protected $relatedColumnName = ""; + + // The TableMap for this column + protected $table; + + // The name of the column + protected $columnName; + + // The php name of the column + protected $phpName; + + // The validators for this column + protected $validators = array(); + + // The allowed values for an ENUM column + protected $valueSet = array(); + + // Is this a primaryString column? + protected $isPkString = false; + + /** + * Constructor. + * + * @param string $name The name of the column. + * @param TableMap containingTable TableMap of the table this column is in. + */ + public function __construct($name, TableMap $containingTable) + { + $this->columnName = $name; + $this->table = $containingTable; + } + + /** + * Get the name of a column. + * + * @return string A String with the column name. + */ + public function getName() + { + return $this->columnName; + } + + /** + * Get the table map this column belongs to. + * + * @return TableMap + */ + public function getTable() + { + return $this->table; + } + + /** + * Get the name of the table this column is in. + * + * @return string A String with the table name. + */ + public function getTableName() + { + return $this->table->getName(); + } + + /** + * Get the table name + column name. + * + * @return string A String with the full column name. + */ + public function getFullyQualifiedName() + { + return $this->getTableName() . "." . $this->columnName; + } + + /** + * Set the php name of this column. + * + * @param string $phpName A string representing the PHP name. + * + * @return void + */ + public function setPhpName($phpName) + { + $this->phpName = $phpName; + } + + /** + * Get the name of a column. + * + * @return string A String with the column name. + */ + public function getPhpName() + { + return $this->phpName; + } + + /** + * Set the Propel type of this column. + * + * @param string $type A string representing the Propel type (e.g. PropelColumnTypes::DATE). + * + * @return void + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * Get the Propel type of this column. + * + * @return string A string representing the Propel type (e.g. PropelColumnTypes::DATE). + */ + public function getType() + { + return $this->type; + } + + /** + * Get the PDO type of this column. + * + * @return int The PDO::PARMA_* value + */ + public function getPdoType() + { + return PropelColumnTypes::getPdoType($this->type); + } + + /** + * Whether this is a BLOB, LONGVARBINARY, or VARBINARY. + * + * @return boolean + */ + public function isLob() + { + return ($this->type == PropelColumnTypes::BLOB || $this->type == PropelColumnTypes::VARBINARY || $this->type == PropelColumnTypes::LONGVARBINARY); + } + + /** + * Whether this is a DATE/TIME/TIMESTAMP column. + * + * @return boolean + * @since 1.3 + */ + public function isTemporal() + { + return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME || $this->type == PropelColumnTypes::BU_DATE || $this->type == PropelColumnTypes::BU_TIMESTAMP); + } + + /** + * Whether this is a DATE/TIME/TIMESTAMP column that is post-epoch (1970). + * + * PHP cannot handle pre-epoch timestamps well -- hence the need to differentiate + * between epoch and pre-epoch timestamps. + * + * @return boolean + * @deprecated Propel supports non-epoch dates + */ + public function isEpochTemporal() + { + return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME); + } + + /** + * Whether this column is numeric (int, decimal, bigint etc). + * + * @return boolean + */ + public function isNumeric() + { + 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); + } + + /** + * Whether this column is an integer + * + * @return boolean + */ + public function isInteger() + { + return $this->getPdoType() === PDO::PARAM_INT; + } + + /** + * Whether this column is a text column (varchar, char, longvarchar). + * + * @return boolean + */ + public function isText() + { + return ($this->type == PropelColumnTypes::VARCHAR || $this->type == PropelColumnTypes::LONGVARCHAR || $this->type == PropelColumnTypes::CHAR); + } + + /** + * Set the size of this column. + * + * @param int $size An int specifying the size. + * + * @return void + */ + public function setSize($size) + { + $this->size = $size; + } + + /** + * Get the size of this column. + * + * @return int An int specifying the size. + */ + public function getSize() + { + return $this->size; + } + + /** + * Set if this column is a primary key or not. + * + * @param boolean $pk True if column is a primary key. + * + * @return void + */ + public function setPrimaryKey($pk) + { + $this->pk = $pk; + } + + /** + * Is this column a primary key? + * + * @return boolean True if column is a primary key. + */ + public function isPrimaryKey() + { + return $this->pk; + } + + /** + * Set if this column may be null. + * + * @param boolean nn True if column may be null. + * + * @return void + */ + public function setNotNull($nn) + { + $this->notNull = $nn; + } + + /** + * Is null value allowed ? + * + * @return boolean True if column may not be null. + */ + public function isNotNull() + { + return ($this->notNull || $this->isPrimaryKey()); + } + + /** + * Sets the default value for this column. + * + * @param mixed $defaultValue the default value for the column + * + * @return void + */ + public function setDefaultValue($defaultValue) + { + $this->defaultValue = $defaultValue; + } + + /** + * Gets the default value for this column. + * + * @return mixed String or NULL + */ + public function getDefaultValue() + { + return $this->defaultValue; + } + + /** + * Set the foreign key for this column. + * + * @param string tableName The name of the table that is foreign. + * @param string columnName The name of the column that is foreign. + * + * @return void + */ + public function setForeignKey($tableName, $columnName) + { + if ($tableName && $columnName) { + $this->relatedTableName = $tableName; + $this->relatedColumnName = $columnName; + } else { + $this->relatedTableName = ""; + $this->relatedColumnName = ""; + } + } + + /** + * Is this column a foreign key? + * + * @return boolean True if column is a foreign key. + */ + public function isForeignKey() + { + if ($this->relatedTableName) { + return true; + } else { + return false; + } + } + + /** + * Get the RelationMap object for this foreign key + * + * @return RelationMap|null + */ + public function getRelation() + { + if (!$this->relatedTableName) { + return null; + } + foreach ($this->getTable()->getRelations() as $name => $relation) { + if ($relation->getType() == RelationMap::MANY_TO_ONE) { + if ($relation->getForeignTable()->getName() == $this->getRelatedTableName() && array_key_exists($this->getFullyQualifiedName(), $relation->getColumnMappings())) { + return $relation; + } + } } - } - } - } - - /** - * Get the table.column that this column is related to. - * - * @return string A String with the full name for the related column. - */ - public function getRelatedName() - { - return $this->relatedTableName . "." . $this->relatedColumnName; - } - - /** - * Get the table name that this column is related to. - * - * @return string A String with the name for the related table. - */ - public function getRelatedTableName() - { - return $this->relatedTableName; - } - - /** - * Get the column name that this column is related to. - * - * @return string A String with the name for the related column. - */ - public function getRelatedColumnName() - { - return $this->relatedColumnName; - } - - /** - * Get the TableMap object that this column is related to. - * - * @return TableMap The related TableMap object - * @throws PropelException when called on a column with no foreign key - */ - public function getRelatedTable() - { - if ($this->relatedTableName) { - return $this->table->getDatabaseMap()->getTable($this->relatedTableName); - } else { - throw new PropelException("Cannot fetch RelatedTable for column with no foreign key: " . $this->columnName); - } - } - - /** - * Get the TableMap object that this column is related to. - * - * @return ColumnMap The related ColumnMap object - * @throws PropelException when called on a column with no foreign key - */ - public function getRelatedColumn() - { - return $this->getRelatedTable()->getColumn($this->relatedColumnName); - } - - public function addValidator($validator) - { - $this->validators[] = $validator; - } - - public function hasValidators() - { - return count($this->validators) > 0; - } - - public function getValidators() - { - return $this->validators; - } - - /** - * Set the valueSet of this column (only valid for ENUM columns). - * - * @param array $values A list of allowed values - */ - public function setValueSet($values) - { - $this->valueSet = $values; - } - - /** - * Get the valueSet of this column (only valid for ENUM columns). - * - * @return array A list of allowed values - */ - public function getValueSet() - { - return $this->valueSet; - } - - public function isInValueSet($value) - { - return in_array($value, $this->valueSet); - } - - public function getValueSetKey($value) - { - return array_search($value, $this->valueSet); - } - - /** - * Performs DB-specific ignore case, but only if the column type necessitates it. - * @param string $str The expression we want to apply the ignore case formatting to (e.g. the column name). - * @param DBAdapter $db - * @return string - */ - public function ignoreCase($str, DBAdapter $db) - { - if ($this->isText()) { - return $db->ignoreCase($str); - } else { - return $str; - } - } - - /** - * Normalizes the column name, removing table prefix and uppercasing. - * - * article.first_name becomes first_name - * - * @param string $name - * @return string Normalized column name. - */ - public static function normalizeName($name) - { - if (false !== ($pos = strrpos($name, '.'))) { - $name = substr($name, $pos + 1); - } - - return $name; - } - - /** - * Set this column to be a primaryString column. - * - * @param boolean $pkString - */ - public function setPrimaryString($pkString) - { - $this->isPkString = (bool) $pkString; - } - - /** - * Is this column a primaryString column? - * - * @return boolean True, if this column is the primaryString column. - */ - public function isPrimaryString() - { - return $this->isPkString; - } - - // deprecated methods - - /** - * Gets column name - * @deprecated Use getName() instead - * @return string - * @deprecated Use getName() instead. - */ - public function getColumnName() - { - return $this->getName(); - } + } + + /** + * Get the table.column that this column is related to. + * + * @return string A String with the full name for the related column. + */ + public function getRelatedName() + { + return $this->relatedTableName . "." . $this->relatedColumnName; + } + + /** + * Get the table name that this column is related to. + * + * @return string A String with the name for the related table. + */ + public function getRelatedTableName() + { + return $this->relatedTableName; + } + + /** + * Get the column name that this column is related to. + * + * @return string A String with the name for the related column. + */ + public function getRelatedColumnName() + { + return $this->relatedColumnName; + } + + /** + * Get the TableMap object that this column is related to. + * + * @return TableMap The related TableMap object + * @throws PropelException when called on a column with no foreign key + */ + public function getRelatedTable() + { + if ($this->relatedTableName) { + return $this->table->getDatabaseMap()->getTable($this->relatedTableName); + } else { + throw new PropelException("Cannot fetch RelatedTable for column with no foreign key: " . $this->columnName); + } + } + + /** + * Get the TableMap object that this column is related to. + * + * @return ColumnMap The related ColumnMap object + * @throws PropelException when called on a column with no foreign key + */ + public function getRelatedColumn() + { + return $this->getRelatedTable()->getColumn($this->relatedColumnName); + } + + public function addValidator($validator) + { + $this->validators[] = $validator; + } + + public function hasValidators() + { + return count($this->validators) > 0; + } + + public function getValidators() + { + return $this->validators; + } + + /** + * Set the valueSet of this column (only valid for ENUM columns). + * + * @param array $values A list of allowed values + */ + public function setValueSet($values) + { + $this->valueSet = $values; + } + + /** + * Get the valueSet of this column (only valid for ENUM columns). + * + * @return array A list of allowed values + */ + public function getValueSet() + { + return $this->valueSet; + } + + public function isInValueSet($value) + { + return in_array($value, $this->valueSet); + } + + public function getValueSetKey($value) + { + return array_search($value, $this->valueSet); + } + + /** + * Performs DB-specific ignore case, but only if the column type necessitates it. + * + * @param string $str The expression we want to apply the ignore case formatting to (e.g. the column name). + * @param DBAdapter $db + * + * @return string + */ + public function ignoreCase($str, DBAdapter $db) + { + if ($this->isText()) { + return $db->ignoreCase($str); + } else { + return $str; + } + } + + /** + * Normalizes the column name, removing table prefix and uppercasing. + * + * article.first_name becomes first_name + * + * @param string $name + * + * @return string Normalized column name. + */ + public static function normalizeName($name) + { + if (false !== ($pos = strrpos($name, '.'))) { + $name = substr($name, $pos + 1); + } + + return $name; + } + + /** + * Set this column to be a primaryString column. + * + * @param boolean $pkString + */ + public function setPrimaryString($pkString) + { + $this->isPkString = (bool) $pkString; + } + + /** + * Is this column a primaryString column? + * + * @return boolean True, if this column is the primaryString column. + */ + public function isPrimaryString() + { + return $this->isPkString; + } + + // deprecated methods + + /** + * Gets column name + * + * @deprecated Use getName() instead + * @return string + * @deprecated Use getName() instead. + */ + public function getColumnName() + { + return $this->getName(); + } } diff --git a/runtime/lib/map/DatabaseMap.php b/runtime/lib/map/DatabaseMap.php index 00628b24d..12194e981 100644 --- a/runtime/lib/map/DatabaseMap.php +++ b/runtime/lib/map/DatabaseMap.php @@ -59,6 +59,7 @@ public function getName() * Add a new table to the database by name. * * @param string $tableName The name of the table. + * * @return TableMap The newly created TableMap. */ public function addTable($tableName) @@ -84,6 +85,7 @@ public function addTableObject(TableMap $table) * Add a new table to the database, using the tablemap class name. * * @param string $tableMapClass The name of the table map to add + * * @return TableMap The TableMap object */ public function addTableFromMapClass($tableMapClass) @@ -102,6 +104,7 @@ public function addTableFromMapClass($tableMapClass) * Does this database contain this specific table? * * @param string $name The String representation of the table. + * * @return boolean True if the database contains the table. */ public function hasTable($name) @@ -113,13 +116,14 @@ public function hasTable($name) * Get a TableMap for the table by name. * * @param string $name Name of the table. + * * @return TableMap A TableMap * @throws PropelException if the table is undefined */ public function getTable($name) { if (!isset($this->tables[$name])) { - throw new PropelException("Cannot fetch TableMap for undefined table: " . $name ); + throw new PropelException("Cannot fetch TableMap for undefined table: " . $name); } return $this->tables[$name]; @@ -140,6 +144,7 @@ public function getTables() * Name must be fully qualified, e.g. book.AUTHOR_ID * * @param $qualifiedColumnName Name of the column. + * * @return ColumnMap A TableMap * @throws PropelException if the table is undefined, or if the table is undefined */ @@ -156,7 +161,9 @@ public function getColumn($qualifiedColumnName) * Does this database contain this specific table? * * @deprecated Use hasTable() instead + * * @param string $name The String representation of the table. + * * @return boolean True if the database contains the table. */ public function containsTable($name) @@ -183,6 +190,7 @@ public function getTableByPhpName($phpName) /** * Convenience method to get the DBAdapter registered with Propel for this database. + * * @return DBAdapter * @see Propel::getDB(string) */ diff --git a/runtime/lib/map/RelationMap.php b/runtime/lib/map/RelationMap.php index 2522efba9..2171cc4e9 100644 --- a/runtime/lib/map/RelationMap.php +++ b/runtime/lib/map/RelationMap.php @@ -25,152 +25,139 @@ class RelationMap { - const - // types - MANY_TO_ONE = 1, - ONE_TO_MANY = 2, - ONE_TO_ONE = 3, - MANY_TO_MANY = 4, - // representations - LOCAL_TO_FOREIGN = 0, - LEFT_TO_RIGHT = 1; + const + // types + MANY_TO_ONE = 1, ONE_TO_MANY = 2, ONE_TO_ONE = 3, MANY_TO_MANY = 4, // representations + LOCAL_TO_FOREIGN = 0, LEFT_TO_RIGHT = 1; - protected - $name, - $pluralName, - $type, - $localTable, - $foreignTable, - $localColumns = array(), - $foreignColumns = array(), - $onUpdate, $onDelete; + protected $name, $pluralName, $type, $localTable, $foreignTable, $localColumns = array(), $foreignColumns = array(), $onUpdate, $onDelete; - /** - * Constructor. - * - * @param string $name Name of the relation. - */ - public function __construct($name) - { - $this->name = $name; - } + /** + * Constructor. + * + * @param string $name Name of the relation. + */ + public function __construct($name) + { + $this->name = $name; + } - /** - * Get the name of this relation. - * - * @return string The name of the relation. - */ - public function getName() - { - return $this->name; - } + /** + * Get the name of this relation. + * + * @return string The name of the relation. + */ + public function getName() + { + return $this->name; + } - public function setPluralName($pluralName) - { - $this->pluralName = $pluralName; - } + public function setPluralName($pluralName) + { + $this->pluralName = $pluralName; + } - /** - * Get the plural name of this relation. - * - * @return string The plural name of the relation. - */ - public function getPluralName() - { - return null !== $this->pluralName ? $this->pluralName : ($this->name . 's'); - } + /** + * Get the plural name of this relation. + * + * @return string The plural name of the relation. + */ + public function getPluralName() + { + return null !== $this->pluralName ? $this->pluralName : ($this->name . 's'); + } - /** - * Set the type - * - * @param integer $type The relation type (either self::MANY_TO_ONE, self::ONE_TO_MANY, or self::ONE_TO_ONE) - */ - public function setType($type) - { - $this->type = $type; - } + /** + * Set the type + * + * @param integer $type The relation type (either self::MANY_TO_ONE, self::ONE_TO_MANY, or self::ONE_TO_ONE) + */ + public function setType($type) + { + $this->type = $type; + } - /** - * Get the type - * - * @return integer the relation type - */ - public function getType() - { - return $this->type; - } + /** + * Get the type + * + * @return integer the relation type + */ + public function getType() + { + return $this->type; + } - /** - * Set the local table - * - * @param TableMap $table The local table for this relationship - */ - public function setLocalTable($table) - { - $this->localTable = $table; - } + /** + * Set the local table + * + * @param TableMap $table The local table for this relationship + */ + public function setLocalTable($table) + { + $this->localTable = $table; + } - /** - * Get the local table - * - * @return TableMap The local table for this relationship - */ - public function getLocalTable() - { - return $this->localTable; - } + /** + * Get the local table + * + * @return TableMap The local table for this relationship + */ + public function getLocalTable() + { + return $this->localTable; + } - /** - * Set the foreign table - * - * @param TableMap $table The foreign table for this relationship - */ - public function setForeignTable($table) - { - $this->foreignTable = $table; - } + /** + * Set the foreign table + * + * @param TableMap $table The foreign table for this relationship + */ + public function setForeignTable($table) + { + $this->foreignTable = $table; + } - /** - * Get the foreign table - * - * @return TableMap The foreign table for this relationship - */ - public function getForeignTable() - { - return $this->foreignTable; - } + /** + * Get the foreign table + * + * @return TableMap The foreign table for this relationship + */ + public function getForeignTable() + { + return $this->foreignTable; + } - /** - * Get the left table of the relation - * - * @return TableMap The left table for this relationship - */ - public function getLeftTable() - { - return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getLocalTable() : $this->getForeignTable(); - } + /** + * Get the left table of the relation + * + * @return TableMap The left table for this relationship + */ + public function getLeftTable() + { + return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getLocalTable() : $this->getForeignTable(); + } - /** - * Get the right table of the relation - * - * @return TableMap The right table for this relationship - */ - public function getRightTable() - { - return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getForeignTable() : $this->getLocalTable(); - } + /** + * Get the right table of the relation + * + * @return TableMap The right table for this relationship + */ + public function getRightTable() + { + return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getForeignTable() : $this->getLocalTable(); + } - /** - * Add a column mapping - * - * @param ColumnMap $local The local column - * @param ColumnMap $foreign The foreign column - */ - public function addColumnMapping(ColumnMap $local, ColumnMap $foreign) - { - $this->localColumns[] = $local; - $this->foreignColumns[] = $foreign; - } + /** + * Add a column mapping + * + * @param ColumnMap $local The local column + * @param ColumnMap $foreign The foreign column + */ + public function addColumnMapping(ColumnMap $local, ColumnMap $foreign) + { + $this->localColumns[] = $local; + $this->foreignColumns[] = $foreign; + } /** * Get an associative array mapping local column names to foreign column names @@ -179,15 +166,16 @@ public function addColumnMapping(ColumnMap $local, ColumnMap $foreign) * - If the value is RelationMap::LEFT_TO_RIGHT, then the returned array is left => right * * @param int $direction How the associative array must return columns + * * @return Array Associative array (local => foreign) of fully qualified column names */ public function getColumnMappings($direction = RelationMap::LOCAL_TO_FOREIGN) { $h = array(); if ($direction == RelationMap::LEFT_TO_RIGHT && $this->getType() == RelationMap::MANY_TO_ONE) { - $direction = RelationMap::LOCAL_TO_FOREIGN; + $direction = RelationMap::LOCAL_TO_FOREIGN; } - for ($i=0, $size=count($this->localColumns); $i < $size; $i++) { + for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) { if ($direction == RelationMap::LOCAL_TO_FOREIGN) { $h[$this->localColumns[$i]->getFullyQualifiedName()] = $this->foreignColumns[$i]->getFullyQualifiedName(); } else { @@ -218,102 +206,102 @@ public function countColumnMappings() return count($this->localColumns); } - /** - * Get the local columns - * - * @return Array list of ColumnMap objects - */ - public function getLocalColumns() - { - return $this->localColumns; - } + /** + * Get the local columns + * + * @return Array list of ColumnMap objects + */ + public function getLocalColumns() + { + return $this->localColumns; + } - /** - * Get the foreign columns - * - * @return Array list of ColumnMap objects - */ - public function getForeignColumns() - { - return $this->foreignColumns; - } + /** + * Get the foreign columns + * + * @return Array list of ColumnMap objects + */ + public function getForeignColumns() + { + return $this->foreignColumns; + } /** - * Get the left columns of the relation - * - * @return array of ColumnMap objects - */ - public function getLeftColumns() - { - return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getLocalColumns() : $this->getForeignColumns(); - } + * Get the left columns of the relation + * + * @return array of ColumnMap objects + */ + public function getLeftColumns() + { + return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getLocalColumns() : $this->getForeignColumns(); + } - /** - * Get the right columns of the relation - * - * @return array of ColumnMap objects - */ - public function getRightColumns() - { - return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getForeignColumns() : $this->getLocalColumns(); - } + /** + * Get the right columns of the relation + * + * @return array of ColumnMap objects + */ + public function getRightColumns() + { + return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getForeignColumns() : $this->getLocalColumns(); + } - /** - * Set the onUpdate behavior - * - * @param string $onUpdate - */ - public function setOnUpdate($onUpdate) - { - $this->onUpdate = $onUpdate; - } + /** + * Set the onUpdate behavior + * + * @param string $onUpdate + */ + public function setOnUpdate($onUpdate) + { + $this->onUpdate = $onUpdate; + } - /** - * Get the onUpdate behavior - * - * @return integer the relation type - */ - public function getOnUpdate() - { - return $this->onUpdate; - } + /** + * Get the onUpdate behavior + * + * @return integer the relation type + */ + public function getOnUpdate() + { + return $this->onUpdate; + } - /** - * Set the onDelete behavior - * - * @param string $onDelete - */ - public function setOnDelete($onDelete) - { - $this->onDelete = $onDelete; - } + /** + * Set the onDelete behavior + * + * @param string $onDelete + */ + public function setOnDelete($onDelete) + { + $this->onDelete = $onDelete; + } - /** - * Get the onDelete behavior - * - * @return integer the relation type - */ - public function getOnDelete() - { - return $this->onDelete; - } + /** + * Get the onDelete behavior + * + * @return integer the relation type + */ + public function getOnDelete() + { + return $this->onDelete; + } - /** - * Gets the symmetrical relation - * - * @return RelationMap - * - * @throws PropelException - */ - public function getSymmetricalRelation() - { - $localMapping = array($this->getLeftColumns(), $this->getRightColumns()); - foreach ($this->getRightTable()->getRelations() as $relation) { - if ($localMapping == array($relation->getRightColumns(), $relation->getLeftColumns())) { - return $relation; - } - } + /** + * Gets the symmetrical relation + * + * @return RelationMap + * + * @throws PropelException + */ + public function getSymmetricalRelation() + { + $localMapping = array($this->getLeftColumns(), $this->getRightColumns()); + foreach ($this->getRightTable()->getRelations() as $relation) { + if ($localMapping == array($relation->getRightColumns(), $relation->getLeftColumns())) { + return $relation; + } + } - throw new PropelException('The relation could not be resolved.'); - } + throw new PropelException('The relation could not be resolved.'); + } } diff --git a/runtime/lib/map/TableMap.php b/runtime/lib/map/TableMap.php index 14997edd9..219173248 100644 --- a/runtime/lib/map/TableMap.php +++ b/runtime/lib/map/TableMap.php @@ -28,18 +28,21 @@ class TableMap { /** * Columns in the table + * * @var array TableMap[] */ protected $columns = array(); /** * Columns in the table, using table phpName as key + * * @var array TableMap[] */ protected $columnsByPhpName = array(); /** * Columns in the table, using as key + * * @var array TableMap[] */ protected $columnsByInsensitiveCase = array(); @@ -169,6 +172,7 @@ public function getPhpName() /** * Set the Classname of the Table. Could be useful for calling * Peer and Object methods dynamically. + * * @param string $classname The Classname */ public function setClassname($classname) @@ -178,6 +182,7 @@ public function setClassname($classname) /** * Get the Classname of the Propel Class belonging to this table. + * * @return string */ public function getClassname() @@ -187,6 +192,7 @@ public function getClassname() /** * Get the Peer Classname of the Propel Class belonging to this table. + * * @return string */ public function getPeerClassname() @@ -206,6 +212,7 @@ public function setPackage($package) /** * Get the Package of the table. + * * @return string */ public function getPackage() @@ -215,6 +222,7 @@ public function getPackage() /** * Set whether or not to use Id generator for primary key. + * * @param boolean $bit */ public function setUseIdGenerator($bit) @@ -224,6 +232,7 @@ public function setUseIdGenerator($bit) /** * Whether to use Id generator for primary key. + * * @return boolean */ public function isUseIdGenerator() @@ -233,6 +242,7 @@ public function isUseIdGenerator() /** * Set whether or not to this table uses single table inheritance + * * @param boolean $bit */ public function setSingleTableInheritance($bit) @@ -242,6 +252,7 @@ public function setSingleTableInheritance($bit) /** * Whether this table uses single table inheritance + * * @return boolean */ public function isSingleTableInheritance() @@ -280,6 +291,7 @@ public function getPrimaryKeyMethodInfo() * @param string $fkTable A String with the foreign key table name. * @param $fkColumn A String with the foreign key column name. * @param string $defaultValue The default value for this column. + * * @return ColumnMap The newly created column. */ public function addColumn($name, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null, $pk = false, $fkTable = null, $fkColumn = null) @@ -313,11 +325,12 @@ public function addColumn($name, $phpName, $type, $isNotNull = false, $size = nu * existing column. * * @param ColumnMap $cmap A ColumnMap. + * * @return ColumnMap The added column map. */ public function addConfiguredColumn($cmap) { - $this->columns[ $cmap->getName() ] = $cmap; + $this->columns[$cmap->getName()] = $cmap; return $cmap; } @@ -327,6 +340,7 @@ public function addConfiguredColumn($cmap) * * @param mixed $name name of the column or ColumnMap instance * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME) + * * @return boolean True if the table contains the column. */ public function hasColumn($name, $normalize = true) @@ -345,6 +359,7 @@ public function hasColumn($name, $normalize = true) * * @param string $name A String with the name of the table. * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME) + * * @return ColumnMap A ColumnMap. * @throws PropelException if the column is undefined */ @@ -364,6 +379,7 @@ public function getColumn($name, $normalize = true) * Does this table contain the specified column? * * @param mixed $phpName name of the column + * * @return boolean True if the table contains the column. */ public function hasColumnByPhpName($phpName) @@ -375,6 +391,7 @@ public function hasColumnByPhpName($phpName) * Get a ColumnMap for the table. * * @param string $phpName A String with the name of the table. + * * @return ColumnMap A ColumnMap. * @throws PropelException if the column is undefined */ @@ -419,6 +436,7 @@ public function getColumns() * @param string $type A string specifying the Propel type. * @param boolean $isNotNull Whether column does not allow NULL values. * @param $size An int specifying the size. + * * @return ColumnMap Newly added PrimaryKey column. */ public function addPrimaryKey($columnName, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null) @@ -436,6 +454,7 @@ public function addPrimaryKey($columnName, $phpName, $type, $isNotNull = false, * @param boolean $isNotNull Whether column does not allow NULL values. * @param int $size An int specifying the size. * @param string $defaultValue The default value for this column. + * * @return ColumnMap Newly added ForeignKey column. */ public function addForeignKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size = 0, $defaultValue = null) @@ -453,6 +472,7 @@ public function addForeignKey($columnName, $phpName, $type, $fkTable, $fkColumn, * @param boolean $isNotNull Whether column does not allow NULL values. * @param int $size An int specifying the size. * @param string $defaultValue The default value for this column. + * * @return ColumnMap Newly created foreign pkey column. */ public function addForeignPrimaryKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size = 0, $defaultValue = null) @@ -470,6 +490,7 @@ public function isCrossRef() /** * set the isCrossRef + * * @param boolean $isCrossRef */ public function setIsCrossRef($isCrossRef) @@ -505,6 +526,7 @@ public function getForeignKeys() * @param string $classname The dot-path name of class to use (e.g. myapp.propel.MyValidator) * @param string $value * @param string $message The error message which is returned on invalid values + * * @return void */ public function addValidator($columnName, $name, $classname, $value, $message) @@ -543,6 +565,7 @@ public function buildRelations() * @param string $onDelete SQL behavior upon deletion ('SET NULL', 'CASCADE', ...) * @param string $onUpdate SQL behavior upon update ('SET NULL', 'CASCADE', ...) * @param string $pluralName Optional plural name for *_TO_MANY relationships + * * @return RelationMap the built RelationMap object */ public function addRelation($name, $tablePhpName, $type, $columnMapping = array(), $onDelete = null, $onUpdate = null, $pluralName = null) @@ -563,7 +586,7 @@ public function addRelation($name, $tablePhpName, $type, $columnMapping = array( } else { $relation->setLocalTable($this->dbMap->getTableByPhpName($tablePhpName)); $relation->setForeignTable($this); - $columnMapping = array_flip($columnMapping); + $columnMapping = array_flip($columnMapping); } // set columns foreach ($columnMapping as $local => $foreign) { @@ -582,6 +605,7 @@ public function addRelation($name, $tablePhpName, $type, $columnMapping = array( * This method will build the relations if they are not built yet * * @param String $name The relation name + * * @return boolean true if the relation exists */ public function hasRelation($name) @@ -594,6 +618,7 @@ public function hasRelation($name) * This method will build the relations if they are not built yet * * @param String $name The relation name + * * @return RelationMap The relation object * @throws PropelException When called on an inexistent relation */ @@ -665,8 +690,10 @@ public function getPrimaryStringColumn() * Does this table contain the specified column? * * @deprecated Use hasColumn instead + * * @param mixed $name name of the column or ColumnMap instance * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME) + * * @return boolean True if the table contains the column. */ public function containsColumn($name, $normalize = true) @@ -679,7 +706,9 @@ public function containsColumn($name, $normalize = true) * article.first_name becomes FIRST_NAME * * @deprecated Use ColumnMap::normalizeColumnName() instead + * * @param string $name + * * @return string Normalized column name. */ protected function normalizeColName($name) @@ -702,6 +731,7 @@ public function getPrimaryKeyColumns() /** * The prefix on the table name. + * * @deprecated Not used anywhere in Propel */ private $prefix; @@ -721,8 +751,10 @@ public function getPrefix() * Set table prefix name. * * @deprecated Not used anywhere in Propel + * * @param string $prefix The prefix for the table name (ie: SCARAB for * SCARAB_PROJECT). + * * @return void */ public function setPrefix($prefix) @@ -734,7 +766,9 @@ public function setPrefix($prefix) * Tell me if i have PREFIX in my string. * * @deprecated Not used anywhere in Propel + * * @param data A String. + * * @return boolean True if prefix is contained in data. */ protected function hasPrefix($data) @@ -746,7 +780,9 @@ protected function hasPrefix($data) * Removes the PREFIX if found * * @deprecated Not used anywhere in Propel + * * @param string $data A String. + * * @return string A String with data, but with prefix removed. */ protected function removePrefix($data) @@ -761,7 +797,9 @@ protected function removePrefix($data) * SCARAB_FOO_BAR becomes FooBar. * * @deprecated Not used anywhere in Propel. At buildtime, use Column::generatePhpName() for that purpose + * * @param data A String. + * * @return string A String with data processed. */ final public function removeUnderScores($data) @@ -781,11 +819,13 @@ final public function removeUnderScores($data) * Makes the first letter caps and the rest lowercase. * * @deprecated Not used anywhere in Propel. + * * @param string $data A String. + * * @return string A String with data processed. */ private function firstLetterCaps($data) { - return(ucfirst(strtolower($data))); + return (ucfirst(strtolower($data))); } } diff --git a/runtime/lib/om/BaseObject.php b/runtime/lib/om/BaseObject.php index 980cf56e6..2aa7b8338 100644 --- a/runtime/lib/om/BaseObject.php +++ b/runtime/lib/om/BaseObject.php @@ -32,12 +32,14 @@ abstract class BaseObject /** * attribute to determine if this object has previously been saved. + * * @var boolean */ protected $_new = true; /** * attribute to determine whether this object has been deleted. + * * @var boolean */ protected $_deleted = false; @@ -45,6 +47,7 @@ abstract class BaseObject /** * The columns that have been modified in current object. * Tracking modified columns allows us to only update modified columns. + * * @var array */ protected $modifiedColumns = array(); @@ -52,6 +55,7 @@ abstract class BaseObject /** * The (virtual) columns that are added at runtime * The formatters can add supplementary columns based on a resultset + * * @var array */ protected $virtualColumns = array(); @@ -77,6 +81,7 @@ public function isModified() * Has specified column been modified? * * @param string $col column fully qualified name (BasePeer::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * * @return boolean True if $col has been modified. */ public function isColumnModified($col) @@ -86,6 +91,7 @@ public function isColumnModified($col) /** * Get the columns that have been modified in this object. + * * @return array A unique list of the modified column names for this object. */ public function getModifiedColumns() @@ -118,6 +124,7 @@ public function setNew($b) /** * Whether this object has been deleted. + * * @return boolean The deleted state of this object. */ public function isDeleted() @@ -127,7 +134,9 @@ public function isDeleted() /** * Specify whether this object has been deleted. + * * @param boolean $b The deleted state of this object. + * * @return void */ public function setDeleted($b) @@ -137,7 +146,9 @@ public function setDeleted($b) /** * Code to be run before persisting the object + * * @param PropelPDO $con + * * @return boolean */ public function preSave(PropelPDO $con = null) @@ -147,6 +158,7 @@ public function preSave(PropelPDO $con = null) /** * Code to be run after persisting the object + * * @param PropelPDO $con */ public function postSave(PropelPDO $con = null) @@ -155,7 +167,9 @@ public function postSave(PropelPDO $con = null) /** * Code to be run before inserting to database + * * @param PropelPDO $con + * * @return boolean */ public function preInsert(PropelPDO $con = null) @@ -165,6 +179,7 @@ public function preInsert(PropelPDO $con = null) /** * Code to be run after inserting to database + * * @param PropelPDO $con */ public function postInsert(PropelPDO $con = null) @@ -173,7 +188,9 @@ public function postInsert(PropelPDO $con = null) /** * Code to be run before updating the object in database + * * @param PropelPDO $con + * * @return boolean */ public function preUpdate(PropelPDO $con = null) @@ -183,6 +200,7 @@ public function preUpdate(PropelPDO $con = null) /** * Code to be run after updating the object in database + * * @param PropelPDO $con */ public function postUpdate(PropelPDO $con = null) @@ -191,7 +209,9 @@ public function postUpdate(PropelPDO $con = null) /** * Code to be run before deleting the object in database + * * @param PropelPDO $con + * * @return boolean */ public function preDelete(PropelPDO $con = null) @@ -201,6 +221,7 @@ public function preDelete(PropelPDO $con = null) /** * Code to be run after deleting the object in database + * * @param PropelPDO $con */ public function postDelete(PropelPDO $con = null) @@ -209,6 +230,7 @@ public function postDelete(PropelPDO $con = null) /** * Code to be run after object hydration + * * @param PropelPDO $con */ public function postHydrate($row, $startcol = 0, $rehydrate = false) @@ -217,7 +239,9 @@ public function postHydrate($row, $startcol = 0, $rehydrate = false) /** * Sets the modified state for the object to be false. + * * @param string $col If supplied, only the specified column is reset. + * * @return void */ public function resetModified($col = null) @@ -237,6 +261,7 @@ public function resetModified($col = null) * equals(BaseObject). Otherwise, returns false. * * @param obj The object to compare to. + * * @return Whether equal to the object specified. */ public function equals($obj) @@ -328,6 +353,7 @@ public function setVirtualColumn($name, $value) * * @param string $msg * @param int $priority One of the Propel::LOG_* logging levels + * * @return boolean */ protected function log($msg, $priority = Propel::LOG_INFO) @@ -367,6 +393,7 @@ public function importFrom($parser, $data) * * @param mixed $parser A PropelParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * * @return string The exported data */ public function exportTo($parser, $includeLazyLoadColumns = true) diff --git a/runtime/lib/om/NodeObject.php b/runtime/lib/om/NodeObject.php index 38b722b49..3ad99aaba 100644 --- a/runtime/lib/om/NodeObject.php +++ b/runtime/lib/om/NodeObject.php @@ -22,6 +22,7 @@ interface NodeObject extends IteratorAggregate * If object is saved without left/right values, set them as undefined (0) * * @param PropelPDO $con Connection to use. + * * @return void * @throws PropelException */ @@ -31,6 +32,7 @@ public function save(PropelPDO $con = null); * Delete node and descendants * * @param PropelPDO $con Connection to use. + * * @return void * @throws PropelException */ @@ -48,6 +50,7 @@ public function makeRoot(); * Gets the level if set, otherwise calculates this and returns it * * @param PropelPDO $con Connection to use. + * * @return int */ public function getLevel(PropelPDO $con = null); @@ -56,6 +59,7 @@ public function getLevel(PropelPDO $con = null); * Get the path to the node in the tree * * @param PropelPDO $con Connection to use. + * * @return array */ public function getPath(PropelPDO $con = null); @@ -64,6 +68,7 @@ public function getPath(PropelPDO $con = null); * Gets the number of children for the node (direct descendants) * * @param PropelPDO $con Connection to use. + * * @return int */ public function getNumberOfChildren(PropelPDO $con = null); @@ -72,6 +77,7 @@ public function getNumberOfChildren(PropelPDO $con = null); * Gets the total number of descendants for the node * * @param PropelPDO $con Connection to use. + * * @return int */ public function getNumberOfDescendants(PropelPDO $con = null); @@ -80,6 +86,7 @@ public function getNumberOfDescendants(PropelPDO $con = null); * Gets the children for the node * * @param PropelPDO $con Connection to use. + * * @return array */ public function getChildren(PropelPDO $con = null); @@ -88,7 +95,8 @@ public function getChildren(PropelPDO $con = null); * Gets the descendants for the node * * @param PropelPDO $con Connection to use. - * @return array + * + * @return array */ public function getDescendants(PropelPDO $con = null); @@ -96,6 +104,7 @@ public function getDescendants(PropelPDO $con = null); * Sets the level of the node in the tree * * @param int $level new value + * * @return object The current object (for fluent API support) */ public function setLevel($level); @@ -104,6 +113,7 @@ public function setLevel($level); * Sets the children array of the node in the tree * * @param Node[] $children array of Propel node object + * * @return object The current object (for fluent API support) */ public function setChildren(array $children); @@ -112,6 +122,7 @@ public function setChildren(array $children); * Sets the parentNode of the node in the tree * * @param Node $parent Propel node object + * * @return object The current object (for fluent API support) */ public function setParentNode(NodeObject $parent = null); @@ -120,6 +131,7 @@ public function setParentNode(NodeObject $parent = null); * Sets the previous sibling of the node in the tree * * @param Node $node Propel node object + * * @return object The current object (for fluent API support) */ public function setPrevSibling(NodeObject $node = null); @@ -128,6 +140,7 @@ public function setPrevSibling(NodeObject $node = null); * Sets the next sibling of the node in the tree * * @param Node $node Propel node object + * * @return object The current object (for fluent API support) */ public function setNextSibling(NodeObject $node = null); @@ -150,6 +163,7 @@ public function isLeaf(); * Tests if object is equal to $node * * @param object $node Propel object for node to compare to + * * @return bool */ public function isEqualTo(NodeObject $node); @@ -158,6 +172,7 @@ public function isEqualTo(NodeObject $node); * Tests if object has an ancestor * * @param PropelPDO $con Connection to use. + * * @return bool */ public function hasParent(PropelPDO $con = null); @@ -173,6 +188,7 @@ public function hasChildren(); * Determines if the node has previous sibling * * @param PropelPDO $con Connection to use. + * * @return bool */ public function hasPrevSibling(PropelPDO $con = null); @@ -181,6 +197,7 @@ public function hasPrevSibling(PropelPDO $con = null); * Determines if the node has next sibling * * @param PropelPDO $con Connection to use. + * * @return bool */ public function hasNextSibling(PropelPDO $con = null); @@ -189,6 +206,7 @@ public function hasNextSibling(PropelPDO $con = null); * Gets ancestor for the given node if it exists * * @param PropelPDO $con Connection to use. + * * @return mixed Propel object if exists else false */ public function retrieveParent(PropelPDO $con = null); @@ -197,6 +215,7 @@ public function retrieveParent(PropelPDO $con = null); * Gets first child if it exists * * @param PropelPDO $con Connection to use. + * * @return mixed Propel object if exists else false */ public function retrieveFirstChild(PropelPDO $con = null); @@ -205,6 +224,7 @@ public function retrieveFirstChild(PropelPDO $con = null); * Gets last child if it exists * * @param PropelPDO $con Connection to use. + * * @return mixed Propel object if exists else false */ public function retrieveLastChild(PropelPDO $con = null); @@ -213,6 +233,7 @@ public function retrieveLastChild(PropelPDO $con = null); * Gets prev sibling for the given node if it exists * * @param PropelPDO $con Connection to use. + * * @return mixed Propel object if exists else false */ public function retrievePrevSibling(PropelPDO $con = null); @@ -221,6 +242,7 @@ public function retrievePrevSibling(PropelPDO $con = null); * Gets next sibling for the given node if it exists * * @param PropelPDO $con Connection to use. + * * @return mixed Propel object if exists else false */ public function retrieveNextSibling(PropelPDO $con = null); @@ -230,6 +252,7 @@ public function retrieveNextSibling(PropelPDO $con = null); * * @param object $parent Propel object for given destination node * @param PropelPDO $con Connection to use. + * * @return object The current object (for fluent API support) */ public function insertAsFirstChildOf(NodeObject $parent, PropelPDO $con = null); @@ -239,6 +262,7 @@ public function insertAsFirstChildOf(NodeObject $parent, PropelPDO $con = null); * * @param object $parent Propel object for given destination node * @param PropelPDO $con Connection to use. + * * @return object The current object (for fluent API support) */ public function insertAsLastChildOf(NodeObject $parent, PropelPDO $con = null); @@ -248,6 +272,7 @@ public function insertAsLastChildOf(NodeObject $parent, PropelPDO $con = null); * * @param object $dest Propel object for given destination node * @param PropelPDO $con Connection to use. + * * @return object The current object (for fluent API support) */ public function insertAsPrevSiblingOf(NodeObject $dest, PropelPDO $con = null); @@ -257,6 +282,7 @@ public function insertAsPrevSiblingOf(NodeObject $dest, PropelPDO $con = null); * * @param object $dest Propel object for given destination node * @param PropelPDO $con Connection to use. + * * @return object The current object (for fluent API support) */ public function insertAsNextSiblingOf(NodeObject $dest, PropelPDO $con = null); @@ -266,6 +292,7 @@ public function insertAsNextSiblingOf(NodeObject $dest, PropelPDO $con = null); * * @param object $parent Propel object for destination node * @param PropelPDO $con Connection to use. + * * @return void */ public function moveToFirstChildOf(NodeObject $parent, PropelPDO $con = null); @@ -275,6 +302,7 @@ public function moveToFirstChildOf(NodeObject $parent, PropelPDO $con = null); * * @param object $parent Propel object for destination node * @param PropelPDO $con Connection to use. + * * @return void */ public function moveToLastChildOf(NodeObject $parent, PropelPDO $con = null); @@ -284,6 +312,7 @@ public function moveToLastChildOf(NodeObject $parent, PropelPDO $con = null); * * @param object $dest Propel object for destination node * @param PropelPDO $con Connection to use. + * * @return void */ public function moveToPrevSiblingOf(NodeObject $dest, PropelPDO $con = null); @@ -293,6 +322,7 @@ public function moveToPrevSiblingOf(NodeObject $dest, PropelPDO $con = null); * * @param object $dest Propel object for destination node * @param PropelPDO $con Connection to use. + * * @return void */ public function moveToNextSiblingOf(NodeObject $dest, PropelPDO $con = null); @@ -302,6 +332,7 @@ public function moveToNextSiblingOf(NodeObject $dest, PropelPDO $con = null); * * @param object $node Propel object for given destination node * @param PropelPDO $con Connection to use. + * * @return void * @throws Exception When trying to insert node as parent of a root node */ @@ -318,6 +349,7 @@ public function getScopeIdValue(); * Set the value of scope column * * @param int $v new value + * * @return object The current object (for fluent API support) */ public function setScopeIdValue($v); diff --git a/runtime/lib/om/Persistent.php b/runtime/lib/om/Persistent.php index c738f9296..d06e3fff8 100644 --- a/runtime/lib/om/Persistent.php +++ b/runtime/lib/om/Persistent.php @@ -31,6 +31,7 @@ public function getPrimaryKey(); * Sets the PrimaryKey for the object. * * @param mixed $primaryKey The new PrimaryKey object or string (result of PrimaryKey.toString()). + * * @return void * @throws Exception, This method might throw an exceptions */ @@ -48,6 +49,7 @@ public function isModified(); * Has specified column been modified? * * @param string $col + * * @return boolean True if $col has been modified. */ public function isColumnModified($col); @@ -78,20 +80,25 @@ public function resetModified(); /** * Whether this object has been deleted. + * * @return boolean The deleted state of this object. */ public function isDeleted(); /** * Specify whether this object has been deleted. + * * @param boolean $b The deleted state of this object. + * * @return void */ public function setDeleted($b); /** * Deletes the object. + * * @param PropelPDO $con + * * @return void * @throws Exception */ @@ -99,7 +106,9 @@ public function delete(PropelPDO $con = null); /** * Saves the object. + * * @param PropelPDO $con + * * @return void * @throws Exception */ diff --git a/runtime/lib/om/PreOrderNodeIterator.php b/runtime/lib/om/PreOrderNodeIterator.php index 020e9bafd..4e91abb78 100644 --- a/runtime/lib/om/PreOrderNodeIterator.php +++ b/runtime/lib/om/PreOrderNodeIterator.php @@ -30,11 +30,13 @@ public function __construct($node, $opts) $this->topNode = $node; $this->curNode = $node; - if (isset($opts['con'])) + if (isset($opts['con'])) { $this->con = $opts['con']; + } - if (isset($opts['querydb'])) + if (isset($opts['querydb'])) { $this->querydb = $opts['querydb']; + } } public function rewind() @@ -63,13 +65,15 @@ public function next() $nextNode = $this->curNode->getFirstChildNode($this->querydb, $this->con); while ($nextNode === null) { - if ($this->curNode === null || $this->curNode->equals($this->topNode)) + if ($this->curNode === null || $this->curNode->equals($this->topNode)) { break; + } $nextNode = $this->curNode->getSiblingNode(false, $this->querydb, $this->con); - if ($nextNode === null) + if ($nextNode === null) { $this->curNode = $this->curNode->getParentNode($this->querydb, $this->con); + } } $this->curNode = $nextNode; @@ -77,5 +81,4 @@ public function next() return $this->curNode; } - } diff --git a/runtime/lib/parser/PropelCSVParser.php b/runtime/lib/parser/PropelCSVParser.php index 63ee2daf3..8a292ad3f 100644 --- a/runtime/lib/parser/PropelCSVParser.php +++ b/runtime/lib/parser/PropelCSVParser.php @@ -69,6 +69,7 @@ public function listFromArray($array) * Accepts a row of data and returns it formatted * * @param array $row An array of data to be formatted for output to the file + * * @return array The formatted array */ protected function formatRow($row) @@ -102,11 +103,12 @@ protected function formatRow($row) } /** - * Escapes a column (escapes quotechar with escapechar) - * - * @param string $input A single value to be escaped for output - * @return string Escaped input value - */ + * Escapes a column (escapes quotechar with escapechar) + * + * @param string $input A single value to be escaped for output + * + * @return string Escaped input value + */ protected function escape($input) { return str_replace( @@ -120,6 +122,7 @@ protected function escape($input) * Quotes a column with quotechar * * @param string $input A single value to be quoted for output + * * @return string Quoted input value */ protected function quote($input) @@ -131,6 +134,7 @@ protected function quote($input) * Returns true if input contains quotechar, delimiter or any of the characters in lineTerminator * * @param string $input A single value to be checked for special characters + * * @return boolean True if contains any special characters */ protected function containsSpecialChars($input) @@ -151,6 +155,7 @@ protected function containsSpecialChars($input) * Serializes a value to place it into a CSV output * * @param mixed $input + * * @return string */ protected function serialize($input) @@ -195,7 +200,7 @@ public function toArray($data, $isList = false, $includeHeading = true) foreach ($rows as $row) { $values = $this->cleanupRow($this->getColumns($row)); if ($values !== array()) { - $array []= array_combine($keys, $values); + $array[] = array_combine($keys, $values); } } } else { @@ -231,6 +236,7 @@ protected function getColumns($row) * Accepts a formatted row of data and returns it raw * * @param array An array of data from a CSV output + * * @return array The cleaned up array */ protected function cleanupRow($row) @@ -284,6 +290,7 @@ protected function isSerialized($input) * Unserializes a value from CSV output * * @param string $input + * * @return mixed */ protected function unserialize($input) @@ -304,5 +311,4 @@ public function fromCSV($data, $isList = false, $includeHeading = true) { return $this->toArray($data, $isList, $includeHeading); } - } diff --git a/runtime/lib/parser/PropelJSONParser.php b/runtime/lib/parser/PropelJSONParser.php index f7f1cc94d..3999fbe12 100644 --- a/runtime/lib/parser/PropelJSONParser.php +++ b/runtime/lib/parser/PropelJSONParser.php @@ -21,6 +21,7 @@ class PropelJSONParser extends PropelParser * Converts data from an associative array to JSON. * * @param array $array Source data to convert + * * @return string Converted data, as a JSON string */ public function fromArray($array) @@ -32,6 +33,7 @@ public function fromArray($array) * Alias for PropelJSONParser::fromArray() * * @param array $array Source data to convert + * * @return string Converted data, as a JSON string */ public function toJSON($array) @@ -43,6 +45,7 @@ public function toJSON($array) * Converts data from JSON to an associative array. * * @param string $data Source data to convert, as a JSON string + * * @return array Converted data */ public function toArray($data) @@ -54,11 +57,11 @@ public function toArray($data) * Alias for PropelJSONParser::toArray() * * @param string $data Source data to convert, as a JSON string + * * @return array Converted data */ public function fromJSON($data) { return $this->toArray($data); } - } diff --git a/runtime/lib/parser/PropelParser.php b/runtime/lib/parser/PropelParser.php index 08eae9c67..3a282d263 100644 --- a/runtime/lib/parser/PropelParser.php +++ b/runtime/lib/parser/PropelParser.php @@ -23,6 +23,7 @@ abstract class PropelParser * Override in the parser driver. * * @param array $array Source data to convert + * * @return mixed Converted data, depending on the parser format */ abstract public function fromArray($array); @@ -33,6 +34,7 @@ abstract public function fromArray($array); * Override in the parser driver. * * @param mixed $data Source data to convert, depending on the parser format + * * @return array Converted data */ abstract public function toArray($data); diff --git a/runtime/lib/parser/PropelXMLParser.php b/runtime/lib/parser/PropelXMLParser.php index d31b41456..bbe57e1fa 100644 --- a/runtime/lib/parser/PropelXMLParser.php +++ b/runtime/lib/parser/PropelXMLParser.php @@ -89,7 +89,7 @@ public function listToXML($array, $rootElementName = 'data', $charset = null) } /** - * @param array $array + * @param array $array * @param DOMElement $rootElement * @param string $charset * @param boolean $removeNumbersFromKeys @@ -129,6 +129,7 @@ protected function arrayToDOM($array, $rootElement, $charset = null, $removeNumb * Converts data from XML to an associative array. * * @param string $data Source data to convert, as an XML string + * * @return array Converted data */ public function toArray($data) @@ -144,6 +145,7 @@ public function toArray($data) * Alias for PropelXMLParser::toArray() * * @param string $data Source data to convert, as an XML string + * * @return array Converted data */ public function fromXML($data) @@ -153,6 +155,7 @@ public function fromXML($data) /** * @param DOMNode $data + * * @return array */ protected function convertDOMElementToArray(DOMNode $data) @@ -192,6 +195,7 @@ protected function convertDOMElementToArray(DOMNode $data) /** * @param DomNode $node + * * @return boolean */ protected function hasOnlyTextNodes(DomNode $node) diff --git a/runtime/lib/parser/PropelYAMLParser.php b/runtime/lib/parser/PropelYAMLParser.php index 5efa7f539..7ebadfe14 100644 --- a/runtime/lib/parser/PropelYAMLParser.php +++ b/runtime/lib/parser/PropelYAMLParser.php @@ -25,6 +25,7 @@ class PropelYAMLParser extends PropelParser * Converts data from an associative array to YAML. * * @param array $array Source data to convert + * * @return string Converted data, as a YAML string */ public function fromArray($array) @@ -36,6 +37,7 @@ public function fromArray($array) * Alias for PropelYAMLParser::fromArray() * * @param array $array Source data to convert + * * @return string Converted data, as a YAML string */ public function toYAML($array) @@ -47,6 +49,7 @@ public function toYAML($array) * Converts data from YAML to an associative array. * * @param string $data Source data to convert, as a YAML string + * * @return array Converted data */ public function toArray($data) @@ -58,11 +61,11 @@ public function toArray($data) * Alias for PropelYAMLParser::toArray() * * @param string $data Source data to convert, as a YAML string + * * @return array Converted data */ public function fromYAML($data) { return $this->toArray($data); } - } diff --git a/runtime/lib/query/Criteria.php b/runtime/lib/query/Criteria.php index 46534ad93..4d85983a7 100644 --- a/runtime/lib/query/Criteria.php +++ b/runtime/lib/query/Criteria.php @@ -140,48 +140,56 @@ class Criteria implements IteratorAggregate /** * Storage of select data. Collection of column names. + * * @var array */ protected $selectColumns = array(); /** * Storage of aliased select data. Collection of column names. + * * @var array */ protected $asColumns = array(); /** * Storage of select modifiers data. Collection of modifier names. + * * @var array */ protected $selectModifiers = array(); /** * Storage of conditions data. Collection of Criterion objects. + * * @var array */ protected $map = array(); /** * Storage of ordering data. Collection of column names. + * * @var array */ protected $orderByColumns = array(); /** * Storage of grouping data. Collection of column names. + * * @var array */ protected $groupByColumns = array(); /** * Storage of having data. + * * @var Criterion */ protected $having = null; /** * Storage of join data. collection of Join objects. + * * @var array */ protected $joins = array(); @@ -189,6 +197,7 @@ class Criteria implements IteratorAggregate /** * The name of the database. + * * @var string */ protected $dbName; @@ -197,6 +206,7 @@ class Criteria implements IteratorAggregate * The primary table for this Criteria. * Useful in cases where there are no select or where * columns. + * * @var string */ protected $primaryTableName; @@ -215,6 +225,7 @@ class Criteria implements IteratorAggregate /** * Comment to add to the SQL query + * * @var string */ protected $queryComment; @@ -228,12 +239,14 @@ class Criteria implements IteratorAggregate /** * Storage for Criterions expected to be combined + * * @var array */ protected $namedCriterions = array(); /** * Default operator for combination of criterions + * * @see addUsingOperator * @var string Criteria::LOGICAL_AND or Criteria::LOGICAL_OR */ @@ -241,6 +254,7 @@ class Criteria implements IteratorAggregate /** * Flags for boolean functions + * * @var PropelConditionalProxy */ protected $conditionalProxy = null; @@ -268,6 +282,7 @@ public function getIterator() /** * Get the criteria map, i.e. the array of Criterions + * * @return array */ public function getMap() @@ -279,6 +294,7 @@ public function getMap() * Brings this criteria back to its initial state, so that it * can be reused as if it was new. Except if the criteria has grown in * capacity, it is left at the current capacity. + * * @return void */ public function clear() @@ -342,6 +358,7 @@ public function getAsColumns() * Returns the column name associated with an alias (AS-column). * * @param string $as + * * @return string|null $string The name if found, null otherwise. */ public function getColumnForAs($as) @@ -397,6 +414,7 @@ public function getAliases() * Returns the table name associated with an alias. * * @param string $alias + * * @return string|null $string The name if given, null otherwise. */ public function getTableForAlias($alias) @@ -414,6 +432,7 @@ public function getTableForAlias($alias) * which can be either a table name or an alias name. * * @param string $tableAliasOrName + * * @return array($tableName, $tableAlias) */ public function getTableNameAndAlias($tableAliasOrName) @@ -443,6 +462,7 @@ public function keys() * Does this Criteria object contain the specified key? * * @param string $column [table.]column + * * @return boolean True if this Criteria object contain the specified key. */ public function containsKey($column) @@ -456,13 +476,14 @@ public function containsKey($column) * Does this Criteria object contain the specified key and does it have a value set for the key * * @param string $column [table.]column + * * @return boolean True if this Criteria object contain the specified key and a value for that key */ public function keyContainsValue($column) { // must use array_key_exists() because the key could // exist but have a NULL value (that'd be valid). - return (array_key_exists($column, $this->map) && ($this->map[$column]->getValue() !== null) ); + return (array_key_exists($column, $this->map) && ($this->map[$column]->getValue() !== null)); } /** @@ -485,6 +506,7 @@ public function hasWhereClause() * to use a transaction. * * @param bool $v + * * @return void */ public function setUseTransaction($v) @@ -510,6 +532,7 @@ public function isUseTransaction() * since no check on the existence of the $column is made in this method. * * @param string $column Column name. + * * @return Criterion A Criterion object. */ public function getCriterion($column) @@ -541,6 +564,7 @@ public function getLastCriterion() * @param string $column Full name of column (for example TABLE.COLUMN). * @param mixed $value * @param string $comparison + * * @return Criterion */ public function getNewCriterion($column, $value = null, $comparison = self::EQUAL) @@ -552,6 +576,7 @@ public function getNewCriterion($column, $value = null, $comparison = self::EQUA * Method to return a String table name. * * @param string $name Name of the key. + * * @return string The value of the object at key. */ public function getColumnName($name) @@ -579,7 +604,7 @@ public function getTablesColumns() { $tables = array(); foreach ($this->keys() as $key) { - $tableName = substr($key, 0, strrpos($key, '.' )); + $tableName = substr($key, 0, strrpos($key, '.')); $tables[$tableName][] = $key; } @@ -590,11 +615,12 @@ public function getTablesColumns() * Method to return a comparison String. * * @param string $key String name of the key. + * * @return string A String with the value of the object at key. */ public function getComparison($key) { - if ( isset ( $this->map[$key] ) ) { + if (isset($this->map[$key])) { return $this->map[$key]->getComparison(); } @@ -616,6 +642,7 @@ public function getDbName() * provided by Propel::getDefaultDB(). * * @param string $dbName The Database (Map) name. + * * @return void */ public function setDbName($dbName = null) @@ -655,6 +682,7 @@ public function setPrimaryTableName($tableName) * Method to return a String table name. * * @param string $name The name of the key. + * * @return string The value of table for criterion at key. */ public function getTableName($name) @@ -670,6 +698,7 @@ public function getTableName($name) * Method to return the value that was added to Criteria. * * @param string $name A String with the name of the key. + * * @return mixed The value of object at key. */ public function getValue($name) @@ -685,6 +714,7 @@ public function getValue($name) * An alias to getValue() -- exposing a Hashtable-like interface. * * @param string $key An Object. + * * @return mixed The value within the Criterion (not the Criterion object). */ public function get($key) @@ -704,6 +734,7 @@ public function get($key) * * @param string $key * @param mixed $value + * * @return Criteria A modified Criteria object. */ public function put($key, $value) @@ -724,7 +755,7 @@ public function put($key, $value) public function putAll($t) { if (is_array($t)) { - foreach ($t as $key=>$value) { + foreach ($t as $key => $value) { if ($value instanceof Criterion) { $this->map[$key] = $value; } else { @@ -816,7 +847,7 @@ public function combine($criterions = array(), $operator = self::LOGICAL_AND, $n $namedCriterions = array(); foreach ($criterions as $key) { if (array_key_exists($key, $this->namedCriterions)) { - $namedCriterions[]= $this->namedCriterions[$key]; + $namedCriterions[] = $this->namedCriterions[$key]; unset($this->namedCriterions[$key]); } else { throw new PropelException('Cannot combine unknown condition ' . $key); @@ -848,7 +879,7 @@ public function combine($criterions = array(), $operator = self::LOGICAL_AND, $n * @param mixed $joinType A String with the join operator * among Criteria::INNER_JOIN, Criteria::LEFT_JOIN, * and Criteria::RIGHT_JOIN - * + * * @return Criteria A modified Criteria object. */ public function addJoin($left, $right, $joinType = null) @@ -857,7 +888,7 @@ public function addJoin($left, $right, $joinType = null) $conditions = array(); foreach ($left as $key => $value) { $condition = array($value, $right[$key]); - $conditions []= $condition; + $conditions[] = $condition; } return $this->addMultipleJoin($conditions, $joinType); @@ -889,6 +920,7 @@ public function addJoin($left, $right, $joinType = null) /** * Add a join with multiple conditions + * * @deprecated use Join::setJoinCondition($criterion) instead * * @see http://propel.phpdb.org/trac/ticket/167, http://propel.phpdb.org/trac/ticket/606 @@ -899,9 +931,10 @@ public function addJoin($left, $right, $joinType = null) * array(FoldersPeer::alias( 'fo', FoldersPeer::LFT ), FoldersPeer::alias( 'parent', FoldersPeer::RGT ), Criteria::LESS_EQUAL ) * ), * Criteria::LEFT_JOIN - * ); + * ); * * @see addJoin() + * * @param array $conditions An array of conditions, each condition being an array (left, right, operator) * @param string $joinType A String with the join operator. Defaults to an implicit join. * @@ -941,7 +974,7 @@ public function addMultipleJoin($conditions, $joinType = null) $conditionClause .= isset($condition[2]) ? $condition[2] : JOIN::EQUAL; $conditionClause .= $rightTableAlias ? $rightTableAlias . '.' : ($rightTableName ? $rightTableName . '.' : ''); $conditionClause .= $rightColumnName; - $criterion = $this->getNewCriterion($leftTableName.'.'.$leftColumnName, $conditionClause, Criteria::CUSTOM); + $criterion = $this->getNewCriterion($leftTableName . '.' . $leftColumnName, $conditionClause, Criteria::CUSTOM); if (null === $joinCondition) { $joinCondition = $criterion; } else { @@ -980,6 +1013,7 @@ public function addJoinObject(Join $join) /** * Get the array of Joins. + * * @return array Join[] */ public function getJoins() @@ -1029,6 +1063,7 @@ public function getSelectQueries() * Get the Criteria for a specific subQuery. * * @param string $alias alias for the subQuery + * * @return Criteria */ public function getSelectQuery($alias) @@ -1040,6 +1075,7 @@ public function getSelectQuery($alias) * checks if the Criteria for a specific subQuery is set. * * @param string $alias alias for the subQuery + * * @return boolean */ public function hasSelectQuery($alias) @@ -1059,6 +1095,7 @@ public function forgeSelectQueryAlias() /** * Adds "ALL" modifier to the SQL statement. + * * @return Criteria Modified Criteria object (for fluent API) */ public function setAll() @@ -1071,6 +1108,7 @@ public function setAll() /** * Adds "DISTINCT" modifier to the SQL statement. + * * @return Criteria Modified Criteria object (for fluent API) */ public function setDistinct() @@ -1130,6 +1168,7 @@ public function hasSelectModifier($modifier) * Sets ignore case. * * @param boolean $b True if case should be ignored. + * * @return Criteria Modified Criteria object (for fluent API) */ public function setIgnoreCase($b) @@ -1159,6 +1198,7 @@ public function isIgnoreCase() * should be using setLimit(1). * * @param boolean $b Set to TRUE if you expect the query to select just one record. + * * @return Criteria Modified Criteria object (for fluent API) */ public function setSingleRecord($b) @@ -1182,6 +1222,7 @@ public function isSingleRecord() * Set limit. * * @param int $limit An int with the value for limit. + * * @return Criteria Modified Criteria object (for fluent API) */ public function setLimit($limit) @@ -1206,7 +1247,8 @@ public function getLimit() * Set offset. * * @param int $offset An int with the value for offset. (Note this values is - * cast to a 32bit integer and may result in truncation) + * cast to a 32bit integer and may result in truncation) + * * @return Criteria Modified Criteria object (for fluent API) */ public function setOffset($offset) @@ -1230,6 +1272,7 @@ public function getOffset() * Add select column. * * @param string $name Name of the select column. + * * @return Criteria Modified Criteria object (for fluent API) */ public function addSelectColumn($name) @@ -1243,6 +1286,7 @@ public function addSelectColumn($name) * Set the query comment, that appears after the first verb in the SQL query * * @param string $comment The comment to add to the query, without comment sign + * * @return Criteria Modified Criteria object (for fluent API) */ public function setComment($comment = null) @@ -1312,6 +1356,7 @@ public function getSelectModifiers() * Add group by column name. * * @param string $groupBy The name of the column to group by. + * * @return Criteria Modified Criteria object (for fluent API) */ public function addGroupByColumn($groupBy) @@ -1325,6 +1370,7 @@ public function addGroupByColumn($groupBy) * Add order by column name, explicitly specifying ascending. * * @param string $name The name of the column to order by. + * * @return Criteria Modified Criteria object (for fluent API) */ public function addAscendingOrderByColumn($name) @@ -1338,6 +1384,7 @@ public function addAscendingOrderByColumn($name) * Add order by column name, explicitly specifying descending. * * @param string $name The name of the column to order by. + * * @return Criteria Modified Criteria object (for fluent API) */ public function addDescendingOrderByColumn($name) @@ -1405,13 +1452,14 @@ public function getHaving() * Remove an object from the criteria. * * @param string $key A string with the key to be removed. + * * @return mixed|null The removed value, null if not set. */ public function remove($key) { - if ( isset ( $this->map[$key] ) ) { + if (isset($this->map[$key])) { $removed = $this->map[$key]; - unset ( $this->map[$key] ); + unset($this->map[$key]); if ($removed instanceof Criterion) { return $removed->getValue(); } @@ -1443,7 +1491,6 @@ public function toString() $paramstr[] = $param['table'] . '.' . $param['column'] . ' => ' . var_export($param['value'], true); } $sb .= implode(", ", $paramstr); - } catch (Exception $exc) { $sb .= "(Error: " . $exc->getMessage() . ")"; } @@ -1453,6 +1500,7 @@ public function toString() /** * Returns the size (count) of this criteria. + * * @return int */ public function size() @@ -1465,6 +1513,7 @@ public function size() * the same attributes and hashtable entries. * * @param Criteria|null $crit + * * @return boolean */ public function equals($crit) @@ -1550,7 +1599,7 @@ public function mergeWith(Criteria $criteria, $operator = null) // merge select modifiers $selectModifiers = $criteria->getSelectModifiers(); - if ($selectModifiers && ! $this->selectModifiers) { + if ($selectModifiers && !$this->selectModifiers) { $this->selectModifiers = $selectModifiers; } @@ -1640,7 +1689,7 @@ public function addHaving($p1, $value = null, $comparison = null) * Build a Criterion. * * This method has multiple signatures, and behaves differently according to it: - * + * * - If the first argument is a Criterion, it just returns this Criterion. * $c->getCriterionForCondition($criterion); // returns $criterion * @@ -1755,14 +1804,15 @@ public function addOr($p1, $value = null, $comparison = null, $preferColumnCondi /** * Overrides Criteria::add() to use the default combine operator + * * @see Criteria::add() * * @param string|Criterion $p1 The column to run the comparison on (e.g. BookPeer::ID), or Criterion object * @param mixed $value * @param string $operator A String, like Criteria::EQUAL. * @param boolean $preferColumnCondition If true, the condition is combined with an existing condition on the same column - * (necessary for Propel 1.4 compatibility). - * If false, the condition is combined with the last existing condition. + * (necessary for Propel 1.4 compatibility). + * If false, the condition is combined with the last existing condition. * * @return Criteria A modified Criteria object. */ @@ -1814,7 +1864,7 @@ public function _if($cond) { $this->conditionalProxy = new PropelConditionalProxy($this, $cond, $this->conditionalProxy); - return $this->conditionalProxy->getCriteriaOrProxy(); + return $this->conditionalProxy->getCriteriaOrProxy(); } /** @@ -1829,11 +1879,11 @@ public function _if($cond) */ public function _elseif($cond) { - if (!$this->conditionalProxy) { - throw new PropelException('_elseif() must be called after _if()'); - } + if (!$this->conditionalProxy) { + throw new PropelException('_elseif() must be called after _if()'); + } - return $this->conditionalProxy->_elseif($cond); + return $this->conditionalProxy->_elseif($cond); } /** @@ -1846,11 +1896,11 @@ public function _elseif($cond) */ public function _else() { - if (!$this->conditionalProxy) { - throw new PropelException('_else() must be called after _if()'); - } + if (!$this->conditionalProxy) { + throw new PropelException('_else() must be called after _if()'); + } - return $this->conditionalProxy->_else(); + return $this->conditionalProxy->_else(); } /** @@ -1863,18 +1913,18 @@ public function _else() */ public function _endif() { - if (!$this->conditionalProxy) { - throw new PropelException('_endif() must be called after _if()'); - } + if (!$this->conditionalProxy) { + throw new PropelException('_endif() must be called after _if()'); + } - $this->conditionalProxy = $this->conditionalProxy->getParentProxy(); + $this->conditionalProxy = $this->conditionalProxy->getParentProxy(); - if ($this->conditionalProxy) { - return $this->conditionalProxy->getCriteriaOrProxy(); - } + if ($this->conditionalProxy) { + return $this->conditionalProxy->getCriteriaOrProxy(); + } - // reached last level - return $this; + // reached last level + return $this; } /** @@ -1892,5 +1942,4 @@ public function __clone() $this->having = clone $this->having; } } - } diff --git a/runtime/lib/query/Criterion.php b/runtime/lib/query/Criterion.php index 40cad58ad..24af55644 100644 --- a/runtime/lib/query/Criterion.php +++ b/runtime/lib/query/Criterion.php @@ -27,6 +27,7 @@ class Criterion protected $value; /** Comparison value. + * * @var SqlEnum */ protected $comparison; @@ -42,6 +43,7 @@ class Criterion /** * Binding type to be used for Criteria::RAW comparison + * * @var string any of the PDO::PARAM_ constant values */ protected $type; @@ -91,9 +93,10 @@ public function __construct(Criteria $outer, $column, $value, $comparison = null } /** - * Init some properties with the help of outer class - * @param Criteria $criteria The outer class - */ + * Init some properties with the help of outer class + * + * @param Criteria $criteria The outer class + */ public function init(Criteria $criteria) { // init $this->db @@ -109,7 +112,6 @@ public function init(Criteria $criteria) // init $this->realtable $realtable = $criteria->getTableForAlias($this->table); $this->realtable = $realtable ? $realtable : $this->table; - } /** @@ -126,6 +128,7 @@ public function getColumn() * Set the table name. * * @param string $name A String with the table name. + * * @return void */ public function setTable($name) @@ -167,6 +170,7 @@ public function getValue() * Get the value of db. * The DBAdapter which might be used to get db specific * variations of sql. + * * @return DBAdapter value of db. */ public function getDB() @@ -177,7 +181,9 @@ public function getDB() /** * Set the value of db. * The DBAdapter might be used to get db specific variations of sql. + * * @param DBAdapter $v Value to assign to db. + * * @return void */ public function setDB(DBAdapter $v) @@ -192,6 +198,7 @@ public function setDB(DBAdapter $v) * Sets ignore case. * * @param boolean $b True if case should be ignored. + * * @return Criterion A modified Criterion object. */ public function setIgnoreCase($b) @@ -206,13 +213,14 @@ public function setIgnoreCase($b) * * @return boolean True if case is ignored. */ - public function isIgnoreCase() - { - return $this->ignoreStringCase; - } + public function isIgnoreCase() + { + return $this->ignoreStringCase; + } /** * Get the list of clauses in this Criterion. + * * @return array */ private function getClauses() @@ -222,6 +230,7 @@ private function getClauses() /** * Get the list of conjunctions in this Criterion + * * @return array */ public function getConjunctions() @@ -244,6 +253,7 @@ public function addAnd(Criterion $criterion) * Append an OR Criterion onto this Criterion's list. * * @param Criterion $criterion + * * @return Criterion */ public function addOr(Criterion $criterion) @@ -260,13 +270,14 @@ public function addOr(Criterion $criterion) * * @param string &$sb The string that will receive the Prepared Statement * @param array $params A list to which Prepared Statement parameters will be appended + * * @return void * @throws PropelException - if the expression builder cannot figure out how to turn a specified * expression into proper SQL. */ public function appendPsTo(&$sb, array &$params) { - $sb .= str_repeat ( '(', count($this->clauses) ); + $sb .= str_repeat('(', count($this->clauses)); $this->dispatchPsHandling($sb, $params); @@ -404,9 +415,9 @@ protected function appendLikeToPs(&$sb, array &$params) // If selection is case insensitive use SQL UPPER() function // on criteria or, if Postgres we are using ILIKE, so not necessary. if ($this->ignoreStringCase && !($db instanceof DBPostgres)) { - $sb .= $db->ignoreCase(':p'.count($params)); + $sb .= $db->ignoreCase(':p' . count($params)); } else { - $sb .= ':p'.count($params); + $sb .= ':p' . count($params); } } @@ -436,11 +447,10 @@ protected function appendBasicToPs(&$sb, array &$params) // default case, it is a normal col = value expression; value // will be replaced w/ '?' and will be inserted later using PDO bindValue() if ($this->ignoreStringCase) { - $sb .= $this->getDb()->ignoreCase($field) . $this->comparison . $this->getDb()->ignoreCase(':p'.count($params)); + $sb .= $this->getDb()->ignoreCase($field) . $this->comparison . $this->getDb()->ignoreCase(':p' . count($params)); } else { - $sb .= $field . $this->comparison . ':p'.count($params); + $sb .= $field . $this->comparison . ':p' . count($params); } - } } else { @@ -454,7 +464,6 @@ protected function appendBasicToPs(&$sb, array &$params) // for now throw an exception, because not sure how to interpret this throw new PropelException("Could not build SQL for expression: $field " . $this->comparison . " NULL"); } - } } @@ -463,6 +472,7 @@ protected function appendBasicToPs(&$sb, array &$params) * the same attributes and hashtable entries. * * @param Criterion|null $obj + * * @return boolean */ public function equals($obj) @@ -490,7 +500,7 @@ public function equals($obj) $isEquiv &= (count($crit->getClauses()) == $clausesLength); $critConjunctions = $crit->getConjunctions(); $critClauses = $crit->getClauses(); - for ($i=0; $i < $clausesLength && $isEquiv; $i++) { + for ($i = 0; $i < $clausesLength && $isEquiv; $i++) { $isEquiv &= ($this->conjunctions[$i] === $critConjunctions[$i]); $isEquiv &= ($this->clauses[$i] === $critClauses[$i]); } @@ -524,9 +534,9 @@ public function hashCode() // $clause->appendPsTo($sb='',$params=array()); $sb = ''; $params = array(); - $clause->appendPsTo($sb,$params); - $h ^= crc32(serialize(array($sb,$params))); - unset ( $sb, $params ); + $clause->appendPsTo($sb, $params); + $h ^= crc32(serialize(array($sb, $params))); + unset ($sb, $params); } return $h; @@ -534,6 +544,7 @@ public function hashCode() /** * Get all tables from nested criterion objects + * * @return array */ public function getAllTables() @@ -550,12 +561,13 @@ public function getAllTables() * * @param Criterion $c * @param array &$s + * * @return void */ private function addCriterionTable(Criterion $c, array &$s) { $s[] = $c->getTable(); - foreach ( $c->getClauses() as $clause ) { + foreach ($c->getClauses() as $clause) { $this->addCriterionTable($clause, $s); } } @@ -563,6 +575,7 @@ private function addCriterionTable(Criterion $c, array &$s) /** * get an array of all criterion attached to this * recursing through all sub criterion + * * @return array Criterion[] */ public function getAttachedCriterion() diff --git a/runtime/lib/query/CriterionIterator.php b/runtime/lib/query/CriterionIterator.php index 33714b5c8..82dc058f3 100644 --- a/runtime/lib/query/CriterionIterator.php +++ b/runtime/lib/query/CriterionIterator.php @@ -56,5 +56,4 @@ public function next() { $this->idx++; } - } diff --git a/runtime/lib/query/Join.php b/runtime/lib/query/Join.php index d5fb41131..54b3825fa 100644 --- a/runtime/lib/query/Join.php +++ b/runtime/lib/query/Join.php @@ -27,7 +27,7 @@ */ class Join { - // default comparison type + // default comparison type const EQUAL = "="; const INNER_JOIN = 'INNER JOIN'; @@ -97,7 +97,7 @@ public function __construct($leftColumn = null, $rightColumn = null, $joinType = public function addCondition($left, $right, $operator = self::EQUAL) { if ($pos = strrpos($left, '.')) { - list($this->leftTableName, $this->left[]) = explode('.', $left); + list($this->leftTableName, $this->left[]) = explode('.', $left); } else { $this->left[] = $left; } @@ -121,7 +121,7 @@ public function addCondition($left, $right, $operator = self::EQUAL) */ public function addConditions($lefts, $rights, $operators = array()) { - if (count($lefts) != count($rights) ) { + if (count($lefts) != count($rights)) { throw new PropelException("Unable to create join because the left column count isn't equal to the right column count"); } foreach ($lefts as $key => $left) { @@ -131,6 +131,7 @@ public function addConditions($lefts, $rights, $operators = array()) /** * Join condition definition. + * * @example * * $join = new Join(); @@ -150,13 +151,13 @@ public function addConditions($lefts, $rights, $operators = array()) */ public function addExplicitCondition($leftTableName, $leftColumnName, $leftTableAlias = null, $rightTableName, $rightColumnName, $rightTableAlias = null, $operator = self::EQUAL) { - $this->leftTableName = $leftTableName; - $this->leftTableAlias = $leftTableAlias; - $this->rightTableName = $rightTableName; + $this->leftTableName = $leftTableName; + $this->leftTableAlias = $leftTableAlias; + $this->rightTableName = $rightTableName; $this->rightTableAlias = $rightTableAlias; - $this->left []= $leftColumnName; - $this->right []= $rightColumnName; - $this->operator []= $operator; + $this->left[] = $leftColumnName; + $this->right[] = $rightColumnName; + $this->operator[] = $operator; $this->count++; } @@ -167,7 +168,7 @@ public function addExplicitCondition($leftTableName, $leftColumnName, $leftTable */ public function countConditions() { - return $this->count; + return $this->count; } /** @@ -177,38 +178,39 @@ public function countConditions() */ public function getConditions() { - $conditions = array(); - for ($i=0; $i < $this->count; $i++) { - $conditions[] = array( - 'left' => $this->getLeftColumn($i), - 'operator' => $this->getOperator($i), - 'right' => $this->getRightColumn($i) - ); - } + $conditions = array(); + for ($i = 0; $i < $this->count; $i++) { + $conditions[] = array( + 'left' => $this->getLeftColumn($i), + 'operator' => $this->getOperator($i), + 'right' => $this->getRightColumn($i) + ); + } - return $conditions; + return $conditions; } - /** - * @param string $operator the comparison operator for the join condition - */ - public function addOperator($operator = null) - { - $this->operator []= $operator; - } + /** + * @param string $operator the comparison operator for the join condition + */ + public function addOperator($operator = null) + { + $this->operator [] = $operator; + } - /** - * @param int $index - * @return string the comparison operator for the join condition - */ - public function getOperator($index = 0) - { - return $this->operator[$index]; - } + /** + * @param int $index + * + * @return string the comparison operator for the join condition + */ + public function getOperator($index = 0) + { + return $this->operator[$index]; + } public function getOperators() { - return $this->operator; + return $this->operator; } /** @@ -220,7 +222,7 @@ public function getOperators() */ public function setJoinType($joinType = null) { - $this->joinType = $joinType; + $this->joinType = $joinType; } /** @@ -241,11 +243,12 @@ public function getJoinType() * $join->setLeftTableName('book'); * $join->addLeftColumnName('AUTHOR_ID'); * + * * @param string $left The name of the left column to add */ public function addLeftColumnName($left) { - $this->left []= $left; + $this->left[] = $left; } /** @@ -256,7 +259,9 @@ public function addLeftColumnName($left) * $join->addCondition('book.AUTHOR_ID', 'author.ID'); * echo $join->getLeftColumn(); // 'book.AUTHOR_ID' *
+ * * @param integer $index The number of the condition to use + * * @return string */ public function getLeftColumn($index = 0) @@ -274,7 +279,9 @@ public function getLeftColumn($index = 0) * $join->addCondition('book.AUTHOR_ID', 'author.ID'); * echo $join->getLeftColumnName(); // 'AUTHOR_ID' * + * * @param integer $index The number of the condition to use + * * @return string */ public function getLeftColumnName($index = 0) @@ -284,13 +291,14 @@ public function getLeftColumnName($index = 0) /** * Get the list of all the names of left columns of the join condition + * * @return array */ public function getLeftColumns() { $columns = array(); foreach ($this->left as $index => $column) { - $columns []= $this->getLeftColumn($index); + $columns[] = $this->getLeftColumn($index); } return $columns; @@ -343,11 +351,12 @@ public function getLeftTableWithAlias() * $join->setRightTableName('author'); * $join->addRightColumnName('ID'); * + * * @param string $right The name of the right column to add */ public function addRightColumnName($right) { - $this->right []= $right; + $this->right[] = $right; } /** @@ -358,7 +367,9 @@ public function addRightColumnName($right) * $join->addCondition('book.AUTHOR_ID', 'author.ID'); * echo $join->getLeftColumn(); // 'author.ID' * + * * @param integer $index The number of the condition to use + * * @return string */ public function getRightColumn($index = 0) @@ -376,7 +387,9 @@ public function getRightColumn($index = 0) * $join->addCondition('book.AUTHOR_ID', 'author.ID'); * echo $join->getLeftColumn(); // 'ID' * + * * @param integer $index The number of the condition to use + * * @return string */ public function getRightColumnName($index = 0) @@ -391,7 +404,7 @@ public function getRightColumns() { $columns = array(); foreach ($this->right as $index => $column) { - $columns []= $this->getRightColumn($index); + $columns[] = $this->getRightColumn($index); } return $columns; @@ -440,6 +453,7 @@ public function getRightTableWithAlias() * Get the value of db. * The DBAdapter which might be used to get db specific * variations of sql. + * * @return DBAdapter value of db. */ public function getDB() @@ -450,7 +464,9 @@ public function getDB() /** * Set the value of db. * The DBAdapter might be used to get db specific variations of sql. + * * @param DBAdapter $db Value to assign to db. + * * @return void */ public function setDB(DBAdapter $db) @@ -486,7 +502,7 @@ public function getJoinCondition() public function buildJoinCondition(Criteria $c) { $joinCondition = null; - for ($i=0; $i < $this->count; $i++) { + for ($i = 0; $i < $this->count; $i++) { $criterion = $c->getNewCriterion($this->getLeftColumn($i), $this->getLeftColumn($i) . $this->getOperator($i) . $this->getRightColumn($i), Criteria::CUSTOM); if (null === $joinCondition) { $joinCondition = $criterion; @@ -500,6 +516,7 @@ public function buildJoinCondition(Criteria $c) /** * Get the join clause for this Join. * If the join condition needs binding, uses the passed params array. + * * @example * * $join = new Join(); @@ -517,8 +534,8 @@ public function getClause(&$params) { if (null === $this->joinCondition) { $conditions = array(); - for ($i=0; $i < $this->count; $i++) { - $conditions []= $this->getLeftColumn($i) . $this->getOperator($i) . $this->getRightColumn($i); + for ($i = 0; $i < $this->count; $i++) { + $conditions [] = $this->getLeftColumn($i) . $this->getOperator($i) . $this->getRightColumn($i); } $joinCondition = sprintf('(%s)', implode($conditions, ' AND ')); } else { @@ -541,6 +558,7 @@ public function getClause(&$params) /** * @param Join $join + * * @return bool */ public function equals($join) diff --git a/runtime/lib/query/ModelCriteria.php b/runtime/lib/query/ModelCriteria.php index 8d11463a4..7b3cc1ef0 100644 --- a/runtime/lib/query/ModelCriteria.php +++ b/runtime/lib/query/ModelCriteria.php @@ -50,7 +50,7 @@ class ModelCriteria extends Criteria protected $isWithOneToMany = false; protected $previousJoin = null; // this is introduced to prevent useQuery->join from going wrong protected $isKeepQuery = true; // whether to clone the current object before termination methods - protected $select = null; // this is for the select method + protected $select = null; // this is for the select method /** * Creates a new instance with the default capacity which corresponds to @@ -148,6 +148,7 @@ public function getTableMap() * * * @param string|PropelFormatter $formatter a formatter class name, or a formatter instance + * * @return ModelCriteria The current object, for fluid interface * * @throws PropelException @@ -519,7 +520,7 @@ public function select($columnArray) if ($columnArray == '*') { $columnArray = array(); foreach (call_user_func(array($this->modelPeerName, 'getFieldNames'), BasePeer::TYPE_PHPNAME) as $column) { - $columnArray []= $this->modelName . '.' . $column; + $columnArray[] = $this->modelName . '.' . $column; } } @@ -530,6 +531,7 @@ public function select($columnArray) /** * Retrieves the columns defined by a previous call to select(). + * * @see select() * * @return array|string A list of column names (e.g. array('Title', 'Category.Name', 'c.Content')) or a single column name (e.g. 'Name') @@ -548,7 +550,7 @@ protected function configureSelectColumns() // select() needs the PropelSimpleArrayFormatter if no formatter given if (is_null($this->formatter)) { - $this->setFormatter('PropelSimpleArrayFormatter'); + $this->setFormatter('PropelSimpleArrayFormatter'); } // clear only the selectColumns, clearSelectColumns() clears asColumns too @@ -669,7 +671,7 @@ public function join($relation, $joinType = Criteria::INNER_JOIN) // find the RelationMap in the TableMap using the $relationName if (!$tableMap->hasRelation($relationName)) { - throw new PropelException('Unknown relation ' . $relationName . ' on the ' . $leftName .' table'); + throw new PropelException('Unknown relation ' . $relationName . ' on the ' . $leftName . ' table'); } $relationMap = $tableMap->getRelation($relationName); @@ -694,6 +696,7 @@ public function join($relation, $joinType = Criteria::INNER_JOIN) /** * Add another condition to an already added join + * * @example * * $query->join('Book.Author'); @@ -728,6 +731,7 @@ public function addJoinCondition($name, $clause, $value = null, $operator = null /** * Replace the condition of an already added join + * * @example * * $query->join('Book.Author'); @@ -762,7 +766,9 @@ public function setJoinCondition($name, $condition) /** * Add a join object to the Criteria + * * @see Criteria::addJoinObject() + * * @param Join $join A join object * @param string $name * @@ -924,6 +930,7 @@ public function withColumn($clause, $name = null) * Initializes a secondary ModelCriteria object, to be later merged with the current object * * @see ModelCriteria::endUse() + * * @param string $relationName Relation name or alias * @param string $secondaryCriteriaClass Classname for the ModelCriteria to be used * @@ -971,6 +978,7 @@ public function endUse() /** * Add the content of a Criteria to the current Criteria * In case of conflict, the current Criteria keeps its properties + * * @see Criteria::mergeWith() * * @param Criteria $criteria The criteria to read properties from @@ -1003,10 +1011,11 @@ public function clear() $this->with = array(); $this->primaryCriteria = null; - $this->formatter=null; + $this->formatter = null; return $this; } + /** * Sets the primary Criteria for this secondary Criteria * @@ -1112,6 +1121,7 @@ public static function getClassAndAlias($class) * The input looks like '$leftName.$relationName $relationAlias' * * @param string $relation Relation to use for the join + * * @return string the relationName used in the join */ public static function getRelationName($relation) @@ -1250,6 +1260,7 @@ public function findOneOrCreate($con = null) * // composite primary key * $bookOpinion = $c->findPk(array(34, 634), $con); * + * * @param mixed $key Primary key to use for the query * @param PropelPDO $con an optional connection object * @@ -1289,6 +1300,7 @@ public function findPk($key, $con = null) * // composite primary key * $bookOpinion = $c->findPks(array(array(34, 634), array(45, 518), array(34, 765)), $con); * + * * @param array $keys Primary keys to use for the query * @param PropelPDO $con an optional connection object * @@ -1460,7 +1472,7 @@ public function count($con = null) // We need to set the primary table name, since in the case that there are no WHERE columns // it will be impossible for the BasePeer::createSelectSql() method to determine which // tables go into the FROM clause. - $criteria->setPrimaryTableName(constant($this->modelPeerName.'::TABLE_NAME')); + $criteria->setPrimaryTableName(constant($this->modelPeerName . '::TABLE_NAME')); $stmt = $criteria->doCount($con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { @@ -1699,19 +1711,19 @@ protected function postUpdate($affectedRows, PropelPDO $con) } /** - * Issue an UPDATE query based the current ModelCriteria and a list of changes. - * An optional hook on basePreUpdate() can prevent the actual update. - * Beware that behaviors based on hooks in the object's save() method - * will only be triggered if you force individual saves, i.e. if you pass true as second argument. - * - * @param array $values Associative array of keys and values to replace - * @param PropelPDO $con an optional connection object - * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), otherwise it is a series of save() calls on all the found objects - * - * @return Integer Number of updated rows - * - * @throws PropelException - */ + * Issue an UPDATE query based the current ModelCriteria and a list of changes. + * An optional hook on basePreUpdate() can prevent the actual update. + * Beware that behaviors based on hooks in the object's save() method + * will only be triggered if you force individual saves, i.e. if you pass true as second argument. + * + * @param array $values Associative array of keys and values to replace + * @param PropelPDO $con an optional connection object + * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), otherwise it is a series of save() calls on all the found objects + * + * @return Integer Number of updated rows + * + * @throws PropelException + */ public function update($values, $con = null, $forceIndividualSaves = false) { if (!is_array($values)) { @@ -1726,7 +1738,7 @@ public function update($values, $con = null, $forceIndividualSaves = false) } $criteria = $this->isKeepQuery() ? clone $this : $this; - $criteria->setPrimaryTableName(constant($this->modelPeerName.'::TABLE_NAME')); + $criteria->setPrimaryTableName(constant($this->modelPeerName . '::TABLE_NAME')); $con->beginTransaction(); try { @@ -1746,15 +1758,15 @@ public function update($values, $con = null, $forceIndividualSaves = false) } /** - * Issue an UPDATE query based the current ModelCriteria and a list of changes. - * This method is called by ModelCriteria::update() inside a transaction. - * - * @param array $values Associative array of keys and values to replace - * @param PropelPDO $con a connection object - * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), otherwise it is a series of save() calls on all the found objects - * - * @return Integer Number of updated rows - */ + * Issue an UPDATE query based the current ModelCriteria and a list of changes. + * This method is called by ModelCriteria::update() inside a transaction. + * + * @param array $values Associative array of keys and values to replace + * @param PropelPDO $con a connection object + * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), otherwise it is a series of save() calls on all the found objects + * + * @return Integer Number of updated rows + */ public function doUpdate($values, $con, $forceIndividualSaves = false) { if ($forceIndividualSaves) { @@ -1768,7 +1780,6 @@ public function doUpdate($values, $con, $forceIndividualSaves = false) } $objects->save($con); $affectedRows = count($objects); - } else { // update rows in a single query @@ -1848,7 +1859,6 @@ protected function getCriterionForClause($clause, $value, $bindingType = null) } else { $criterion = new Criterion($this, null, $clause, Criteria::CUSTOM); } - } return $criterion; @@ -1859,6 +1869,7 @@ protected function getCriterionForClause($clause, $value, $bindingType = null) * * @param mixed $value The value to convert * @param ColumnMap $colMap The ColumnMap object + * * @return mixed The converted value */ protected function convertValueForColumn($value, ColumnMap $colMap) @@ -1959,7 +1970,7 @@ protected function doReplaceNameInExpression($matches) $key = $matches[0]; list($column, $realColumnName) = $this->getColumnFromName($key); if ($column instanceof ColumnMap) { - $this->replacedColumns[]= $column; + $this->replacedColumns[] = $column; $this->foundMatch = true; return $realColumnName; @@ -2020,8 +2031,8 @@ protected function getColumnFromName($phpName, $failSilently = true) } return array($column, $realColumnName); - } elseif ($tableMap->hasColumn($phpName,false)) { - $column = $tableMap->getColumn($phpName,false); + } elseif ($tableMap->hasColumn($phpName, false)) { + $column = $tableMap->getColumn($phpName, false); $realColumnName = $column->getFullyQualifiedName(); return array($column, $realColumnName); @@ -2116,6 +2127,7 @@ public function getAliasedColName($colName) * Overrides Criteria::add() to force the use of a true table alias if it exists * * @see Criteria::add() + * * @param string $column The colName of column to run the condition on (e.g. BookPeer::ID) * @param mixed $value * @param string $operator A String, like Criteria::EQUAL. @@ -2252,6 +2264,7 @@ public function __clone() * Make explain plan of the query * * @param PropelPDO $con propel connection + * * @throws PropelException on error * @return array array of the explain plan */ @@ -2281,6 +2294,7 @@ public function explain($con = null) /** * @param PropelPDO $con = null + * * @return boolean */ public function exists($con = null) diff --git a/runtime/lib/query/ModelCriterion.php b/runtime/lib/query/ModelCriterion.php index 818944543..525494af8 100644 --- a/runtime/lib/query/ModelCriterion.php +++ b/runtime/lib/query/ModelCriterion.php @@ -36,14 +36,14 @@ public function __construct(Criteria $outer, $column, $value = null, $comparison $this->column = $column->getName(); $this->table = $column->getTable()->getName(); } else { - $dotPos = strrpos($column,'.'); + $dotPos = strrpos($column, '.'); if ($dotPos === false) { // no dot => aliased column $this->table = null; $this->column = $column; } else { $this->table = substr($column, 0, $dotPos); - $this->column = substr($column, $dotPos+1, strlen($column)); + $this->column = substr($column, $dotPos + 1, strlen($column)); } } $this->comparison = ($comparison === null ? Criteria::EQUAL : $comparison); @@ -110,7 +110,6 @@ protected function dispatchPsHandling(&$sb, array &$params) default: // table.column = ? or table.column >= ? etc. (traditional expressions, the default) $this->appendBasicToPs($sb, $params); - } } @@ -125,7 +124,7 @@ public function appendModelClauseToPs(&$sb, array &$params) { if ($this->value !== null) { $params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $this->value); - $sb .= str_replace('?', ':p'.count($params), $this->clause); + $sb .= str_replace('?', ':p' . count($params), $this->clause); } else { $sb .= $this->clause; } @@ -169,7 +168,7 @@ public function appendModelClauseSeveralToPs(&$sb, array &$params) throw new PropelException('Null values are not supported inside BETWEEN clauses'); } $params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $value); - $clause = self::strReplaceOnce('?', ':p'.count($params), $clause); + $clause = self::strReplaceOnce('?', ':p' . count($params), $clause); } $sb .= $clause; } @@ -186,17 +185,17 @@ public function appendModelClauseArrayToPs(&$sb, array &$params) $_bindParams = array(); // the param names used in query building $_idxstart = count($params); $valuesLength = 0; - foreach ( (array) $this->value as $value ) { + foreach ((array) $this->value as $value) { $valuesLength++; // increment this first to correct for wanting bind params to start with :p1 $params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $value); - $_bindParams[] = ':p'.($_idxstart + $valuesLength); + $_bindParams[] = ':p' . ($_idxstart + $valuesLength); } if ($valuesLength !== 0) { $sb .= str_replace('?', '(' . implode(',', $_bindParams) . ')', $this->clause); } else { $sb .= (stripos($this->clause, ' NOT IN ') === false) ? "1<>1" : "1=1"; } - unset ( $value, $valuesLength ); + unset($value, $valuesLength); } /** @@ -220,6 +219,7 @@ protected function appendModelClauseRawToPs(&$sb, array &$params) /** * This method checks another Criteria to see if they contain * the same attributes and hashtable entries. + * * @return boolean */ public function equals($obj) @@ -248,7 +248,7 @@ public function equals($obj) $isEquiv &= (count($crit->getClauses()) == $clausesLength); $critConjunctions = $crit->getConjunctions(); $critClauses = $crit->getClauses(); - for ($i=0; $i < $clausesLength && $isEquiv; $i++) { + for ($i = 0; $i < $clausesLength && $isEquiv; $i++) { $isEquiv &= ($this->conjunctions[$i] === $critConjunctions[$i]); $isEquiv &= ($this->clauses[$i] === $critClauses[$i]); } @@ -282,9 +282,9 @@ public function hashCode() // $clause->appendPsTo($sb='',$params=array()); $sb = ''; $params = array(); - $clause->appendPsTo($sb,$params); - $h ^= crc32(serialize(array($sb,$params))); - unset ( $sb, $params ); + $clause->appendPsTo($sb, $params); + $h ^= crc32(serialize(array($sb, $params))); + unset($sb, $params); } return $h; @@ -299,10 +299,10 @@ protected static function strReplaceOnce($search, $replace, $subject) { $firstChar = strpos($subject, $search); if ($firstChar !== false) { - $beforeStr = substr($subject,0,$firstChar); + $beforeStr = substr($subject, 0, $firstChar); $afterStr = substr($subject, $firstChar + strlen($search)); - return $beforeStr.$replace.$afterStr; + return $beforeStr . $replace . $afterStr; } else { return $subject; } diff --git a/runtime/lib/query/ModelJoin.php b/runtime/lib/query/ModelJoin.php index 11215f8eb..94466067a 100644 --- a/runtime/lib/query/ModelJoin.php +++ b/runtime/lib/query/ModelJoin.php @@ -25,7 +25,7 @@ public function setRelationMap(RelationMap $relationMap, $leftTableAlias = null, $leftCols = $relationMap->getLeftColumns(); $rightCols = $relationMap->getRightColumns(); $nbColumns = $relationMap->countColumnMappings(); - for ($i=0; $i < $nbColumns; $i++) { + for ($i = 0; $i < $nbColumns; $i++) { $this->addExplicitCondition( $leftCols[$i]->getTableName(), $leftCols[$i]->getName(), $leftTableAlias, $rightCols[$i]->getTableName(), $rightCols[$i]->getName(), $relationAlias, @@ -71,6 +71,7 @@ public function getTableMap() /** * @param ModelJoin $join + * * @return ModelJoin */ public function setPreviousJoin(ModelJoin $join) @@ -110,6 +111,7 @@ public function hasRelationAlias() { return $this->hasRightTableAlias(); } + /** * This method returns the last related, but already hydrated object up until this join * Starting from $startObject and continuously calling the getters to get @@ -119,6 +121,7 @@ public function hasRelationAlias() * which only happens when you provide dotted relations when calling join * * @param Object $startObject the start object all joins originate from and which has already hydrated + * * @return Object the base Object of this join */ public function getObjectToRelate($startObject) @@ -136,6 +139,7 @@ public function getObjectToRelate($startObject) /** * @param ModelJoin $join + * * @return bool */ public function equals($join) diff --git a/runtime/lib/query/PropelQuery.php b/runtime/lib/query/PropelQuery.php index e50179584..7c9c6fadc 100644 --- a/runtime/lib/query/PropelQuery.php +++ b/runtime/lib/query/PropelQuery.php @@ -19,6 +19,7 @@ class PropelQuery { /** * @param string $queryClassAndAlias + * * @return ModelCriteria * @throws PropelException */ diff --git a/runtime/lib/util/BasePeer.php b/runtime/lib/util/BasePeer.php index 77dc6d66a..51db2df07 100644 --- a/runtime/lib/util/BasePeer.php +++ b/runtime/lib/util/BasePeer.php @@ -72,7 +72,7 @@ class BasePeer */ const TYPE_NUM = 'num'; - public static function getFieldnames ($classname, $type = self::TYPE_PHPNAME) + public static function getFieldnames($classname, $type = self::TYPE_PHPNAME) { // TODO we should take care of including the peer class here @@ -99,11 +99,12 @@ public static function translateFieldname($classname, $fieldname, $fromType, $to * * @param Criteria $criteria The criteria to use. * @param PropelPDO $con A PropelPDO connection object. + * * @return int The number of rows affected by last statement execution. For most - * uses there is only one delete statement executed, so this number - * will correspond to the number of rows affected by the call to this - * method. Note that the return value does require that this information - * is returned (supported) by the PDO driver. + * uses there is only one delete statement executed, so this number + * will correspond to the number of rows affected by the call to this + * method. Note that the return value does require that this information + * is returned (supported) by the PDO driver. * @throws PropelException */ public static function doDelete(Criteria $criteria, PropelPDO $con) @@ -138,7 +139,7 @@ public static function doDelete(Criteria $criteria, PropelPDO $con) $criteria->getCriterion($colName)->appendPsTo($sb, $params); $whereClause[] = $sb; } - $sql .= " WHERE " . implode(" AND ", $whereClause); + $sql .= " WHERE " . implode(" AND ", $whereClause); $stmt = $con->prepare($sql); $db->bindValues($stmt, $params, $dbMap); @@ -148,7 +149,6 @@ public static function doDelete(Criteria $criteria, PropelPDO $con) Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute DELETE statement [%s]', $sql), $e); } - } // for each table return $affectedRows; @@ -169,9 +169,10 @@ public static function doDelete(Criteria $criteria, PropelPDO $con) * @param string $tableName The name of the table to empty. * @param PropelPDO $con A PropelPDO connection object. * @param string $databaseName the name of the database. + * * @return int The number of rows affected by the statement. Note - * that the return value does require that this information - * is returned (supported) by the Propel db driver. + * that the return value does require that this information + * is returned (supported) by the Propel db driver. * @throws PropelException - wrapping SQLException caught from statement execution. */ public static function doDeleteAll($tableName, PropelPDO $con, $databaseName = null) @@ -211,8 +212,9 @@ public static function doDeleteAll($tableName, PropelPDO $con, $databaseName = n * * @param Criteria $criteria Object containing values to insert. * @param PropelPDO $con A PropelPDO connection. + * * @return mixed The primary key for the new row if (and only if!) the primary key - * is auto-generated. Otherwise will return null. + * is auto-generated. Otherwise will return null. * @throws PropelException */ public static function doInsert(Criteria $criteria, PropelPDO $con) @@ -226,7 +228,7 @@ public static function doInsert(Criteria $criteria, PropelPDO $con) // key value. $keys = $criteria->keys(); if (!empty($keys)) { - $tableName = $criteria->getTableName( $keys[0] ); + $tableName = $criteria->getTableName($keys[0]); } else { throw new PropelException("Database insert attempted without anything specified to insert"); } @@ -275,9 +277,12 @@ public static function doInsert(Criteria $criteria, PropelPDO $con) . ' (' . implode(',', $columns) . ')' . ' VALUES ('; // . substr(str_repeat("?,", count($columns)), 0, -1) . - for ($p=1, $cnt=count($columns); $p <= $cnt; $p++) { - $sql .= ':p'.$p; - if ($p !== $cnt) $sql .= ','; + for ($p = 1, $cnt = count($columns); $p <= $cnt; $p++) { + $sql .= ':p' . $p; + + if ($p !== $cnt) { + $sql .= ','; + } } $sql .= ')'; @@ -288,7 +293,6 @@ public static function doInsert(Criteria $criteria, PropelPDO $con) $stmt = $con->prepare($sql); $db->bindValues($stmt, $params, $dbMap, $db); $stmt->execute(); - } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); @@ -315,16 +319,15 @@ public static function doInsert(Criteria $criteria, PropelPDO $con) * WHERE some_column = some value AND could_have_another_column = * another value AND so on. * - * @param $selectCriteria A Criteria object containing values used in where - * clause. - * @param $updateValues A Criteria object containing values used in set - * clause. + * @param $selectCriteria A Criteria object containing values used in where clause. + * @param $updateValues A Criteria object containing values used in set clause. * @param PropelPDO $con The PropelPDO connection object to use. + * * @return int The number of rows affected by last update statement. For most - * uses there is only one update statement executed, so this number - * will correspond to the number of rows affected by the call to this - * method. Note that the return value does require that this information - * is returned (supported) by the Propel db driver. + * uses there is only one update statement executed, so this number + * will correspond to the number of rows affected by the call to this + * method. Note that the return value does require that this information + * is returned (supported) by the Propel db driver. * @throws PropelException */ public static function doUpdate(Criteria $selectCriteria, Criteria $updateValues, PropelPDO $con) @@ -384,7 +387,7 @@ public static function doUpdate(Criteria $selectCriteria, Criteria $updateValues $updateColumnName = $db->quoteIdentifier($updateColumnName); } if ($updateValues->getComparison($col) != Criteria::CUSTOM_EQUAL) { - $sql .= $updateColumnName . '=:p'.$p++.', '; + $sql .= $updateColumnName . '=:p' . $p++ . ', '; } else { $param = $updateValues->get($col); $sql .= $updateColumnName . ' = '; @@ -393,16 +396,16 @@ public static function doUpdate(Criteria $selectCriteria, Criteria $updateValues $raw = $param['raw']; $rawcvt = ''; // parse the $params['raw'] for ? chars - for ($r=0,$len=strlen($raw); $r < $len; $r++) { + for ($r = 0, $len = strlen($raw); $r < $len; $r++) { if ($raw{$r} == '?') { - $rawcvt .= ':p'.$p++; + $rawcvt .= ':p' . $p++; } else { $rawcvt .= $raw{$r}; } } $sql .= $rawcvt . ', '; } else { - $sql .= ':p'.$p++.', '; + $sql .= ':p' . $p++ . ', '; } if (isset($param['value'])) { $updateValues->put($col, $param['value']); @@ -423,7 +426,7 @@ public static function doUpdate(Criteria $selectCriteria, Criteria $updateValues $selectCriteria->getCriterion($colName)->appendPsTo($sb, $params); $whereClause[] = $sb; } - $sql .= " WHERE " . implode(" AND ", $whereClause); + $sql .= " WHERE " . implode(" AND ", $whereClause); } $db->cleanupSQL($sql, $params, $updateValues, $dbMap); @@ -440,11 +443,12 @@ public static function doUpdate(Criteria $selectCriteria, Criteria $updateValues $stmt = null; // close } catch (Exception $e) { - if ($stmt) $stmt = null; // close + if ($stmt) { + $stmt = null; + } // close Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute UPDATE statement [%s]', $sql), $e); } - } // foreach table in the criteria return $affectedRows; @@ -455,6 +459,7 @@ public static function doUpdate(Criteria $selectCriteria, Criteria $updateValues * * @param Criteria $criteria A Criteria. * @param PropelPDO $con A PropelPDO connection to use. + * * @return PDOStatement The resultset. * @throws PropelException * @see createSelectSql() @@ -479,7 +484,6 @@ public static function doSelect(Criteria $criteria, PropelPDO $con = null) $db->bindValues($stmt, $params, $dbMap); $stmt->execute(); - } catch (Exception $e) { if ($stmt) { $stmt = null; // close @@ -497,6 +501,7 @@ public static function doSelect(Criteria $criteria, PropelPDO $con = null) * * @param Criteria $criteria A Criteria. * @param PropelPDO $con A PropelPDO connection to use. + * * @return PDOStatement The resultset statement. * @throws PropelException * @see createSelectSql() @@ -540,7 +545,6 @@ public static function doCount(Criteria $criteria, PropelPDO $con = null) $stmt = $con->prepare($sql); $db->bindValues($stmt, $params, $dbMap); $stmt->execute(); - } catch (Exception $e) { if ($stmt !== null) { $stmt = null; @@ -590,8 +594,8 @@ public static function doValidate($dbName, $tableName, $columns) * in the given Criteria object. * * @param Criteria $criteria A Criteria. - * @return ColumnMap If the Criteria object contains a primary - * key, or null if it doesn't. + * + * @return ColumnMap If the Criteria object contains a primary key, or null if it doesn't. * @throws PropelException */ private static function getPrimaryKey(Criteria $criteria) @@ -648,6 +652,7 @@ public static function needsSelectAliases(Criteria $criteria) * * @param Criteria $criteria Criteria for the SELECT query. * @param array &$params Parameters that are to be replaced in prepared statement. + * * @return string * @throws PropelException Trouble creating the query string. */ @@ -785,7 +790,7 @@ public static function createSelectSql(Criteria $criteria, &$params) if ($criteria->isIgnoreCase() && $column && $column->isText()) { $ignoreCaseColumn = $db->ignoreCaseInOrderBy("$tableAlias.$columnAlias"); - $orderByClause[] = $ignoreCaseColumn . $direction; + $orderByClause[] = $ignoreCaseColumn . $direction; $selectSql .= ', ' . $ignoreCaseColumn; } else { $orderByClause[] = $orderByColumn; @@ -851,8 +856,10 @@ public static function createSelectSql(Criteria $criteria, &$params) /** * Builds a params array, like the kind populated by Criterion::appendPsTo(). * This is useful for building an array even when it is not using the appendPsTo() method. + * * @param array $columns * @param Criteria $values + * * @return array params array('column' => ..., 'table' => ..., 'value' => ...) */ private static function buildParams($columns, Criteria $values) @@ -873,6 +880,7 @@ private static function buildParams($columns, Criteria $values) * imports and caches it. * * @param string $classname The dot-path name of class (e.g. myapp.propel.MyValidator) + * * @return Validator|null object or null if not able to instantiate validator class (and error will be logged in this case) */ public static function getValidator($classname) @@ -887,10 +895,9 @@ public static function getValidator($classname) return $v; } catch (Exception $e) { - Propel::log("BasePeer::getValidator(): failed trying to instantiate " . $classname . ": ".$e->getMessage(), Propel::LOG_ERR); + Propel::log("BasePeer::getValidator(): failed trying to instantiate " . $classname . ": " . $e->getMessage(), Propel::LOG_ERR); } return null; } - } diff --git a/runtime/lib/util/NodePeer.php b/runtime/lib/util/NodePeer.php index de3c2f992..d6090be7c 100644 --- a/runtime/lib/util/NodePeer.php +++ b/runtime/lib/util/NodePeer.php @@ -21,6 +21,7 @@ interface NodePeer * Creates the supplied node as the root node. * * @param NodeObject $node Propel object for model + * * @return object Inserted propel object for model */ public static function createRoot(NodeObject $node); @@ -30,6 +31,7 @@ public static function createRoot(NodeObject $node); * * @param int $scopeId Scope id to determine which root node to return * @param PropelPDO $con Connection to use. + * * @return object Propel object for root node */ public static function retrieveRoot($scopeId = 1, PropelPDO $con = null); @@ -40,6 +42,7 @@ public static function retrieveRoot($scopeId = 1, PropelPDO $con = null); * @param object $child Propel object for child node * @param object $parent Propel object for parent node * @param PropelPDO $con Connection to use. + * * @return void */ public static function insertAsFirstChildOf(NodeObject $child, NodeObject $parent, PropelPDO $con = null); @@ -50,6 +53,7 @@ public static function insertAsFirstChildOf(NodeObject $child, NodeObject $paren * @param object $child Propel object for child node * @param object $parent Propel object for parent node * @param PropelPDO $con Connection to use. + * * @return void */ public static function insertAsLastChildOf(NodeObject $child, NodeObject $parent, PropelPDO $con = null); @@ -60,6 +64,7 @@ public static function insertAsLastChildOf(NodeObject $child, NodeObject $parent * @param object $node Propel object for destination node * @param object $sibling Propel object for source node * @param PropelPDO $con Connection to use. + * * @return void */ public static function insertAsPrevSiblingOf(NodeObject $node, NodeObject $sibling, PropelPDO $con = null); @@ -70,6 +75,7 @@ public static function insertAsPrevSiblingOf(NodeObject $node, NodeObject $sibli * @param object $node Propel object for destination node * @param object $sibling Propel object for source node * @param PropelPDO $con Connection to use. + * * @return void */ public static function insertAsNextSiblingOf(NodeObject $node, NodeObject $sibling, PropelPDO $con = null); @@ -80,6 +86,7 @@ public static function insertAsNextSiblingOf(NodeObject $node, NodeObject $sibli * @param object $parent Propel object for given parent node * @param object $node Propel object for given destination node * @param PropelPDO $con Connection to use. + * * @return void * @throws Exception When trying to insert node as parent of a root node */ @@ -90,6 +97,7 @@ public static function insertAsParentOf(NodeObject $parent, NodeObject $node, Pr * * @param object $node Propel object as root node * @param PropelPDO $con Connection to use. + * * @return void */ public static function insertRoot(NodeObject $node, PropelPDO $con = null); @@ -99,6 +107,7 @@ public static function insertRoot(NodeObject $node, PropelPDO $con = null); * * @param int $scopeId Scope id to determine which root node to delete * @param PropelPDO $con Connection to use. + * * @return boolean Deletion status */ public static function deleteRoot($scopeId = 1, PropelPDO $con = null); @@ -108,6 +117,7 @@ public static function deleteRoot($scopeId = 1, PropelPDO $con = null); * * @param object $dest Propel object node to delete * @param PropelPDO $con Connection to use. + * * @return boolean Deletion status */ public static function deleteNode(NodeObject $dest, PropelPDO $con = null); @@ -118,6 +128,7 @@ public static function deleteNode(NodeObject $dest, PropelPDO $con = null); * @param object $parent Propel object for parent node * @param object $child Propel object for child node * @param PropelPDO $con Connection to use. + * * @return void */ public static function moveToFirstChildOf(NodeObject $parent, NodeObject $child, PropelPDO $con = null); @@ -128,6 +139,7 @@ public static function moveToFirstChildOf(NodeObject $parent, NodeObject $child, * @param object $dest Propel object for destination node * @param object $node Propel object for source node * @param PropelPDO $con Connection to use. + * * @return void */ public static function moveToLastChildOf(NodeObject $dest, NodeObject $node, PropelPDO $con = null); @@ -138,6 +150,7 @@ public static function moveToLastChildOf(NodeObject $dest, NodeObject $node, Pro * @param object $dest Propel object for destination node * @param object $node Propel object for source node * @param PropelPDO $con Connection to use. + * * @return void */ public static function moveToPrevSiblingOf(NodeObject $dest, NodeObject $node, PropelPDO $con = null); @@ -148,6 +161,7 @@ public static function moveToPrevSiblingOf(NodeObject $dest, NodeObject $node, P * @param object $dest Propel object for destination node * @param object $node Propel object for source node * @param PropelPDO $con Connection to use. + * * @return void */ public static function moveToNextSiblingOf(NodeObject $dest, NodeObject $node, PropelPDO $con = null); @@ -157,6 +171,7 @@ public static function moveToNextSiblingOf(NodeObject $dest, NodeObject $node, P * * @param object $node Propel object for src node * @param PropelPDO $con Connection to use. + * * @return mixed Propel object if exists else false */ public static function retrieveFirstChild(NodeObject $node, PropelPDO $con = null); @@ -166,6 +181,7 @@ public static function retrieveFirstChild(NodeObject $node, PropelPDO $con = nul * * @param object $node Propel object for src node * @param PropelPDO $con Connection to use. + * * @return mixed Propel object if exists else false */ public static function retrieveLastChild(NodeObject $node, PropelPDO $con = null); @@ -175,6 +191,7 @@ public static function retrieveLastChild(NodeObject $node, PropelPDO $con = null * * @param object $node Propel object for src node * @param PropelPDO $con Connection to use. + * * @return mixed Propel object if exists else false */ public static function retrievePrevSibling(NodeObject $node, PropelPDO $con = null); @@ -184,6 +201,7 @@ public static function retrievePrevSibling(NodeObject $node, PropelPDO $con = nu * * @param object $node Propel object for src node * @param PropelPDO $con Connection to use. + * * @return mixed Propel object if exists else false */ public static function retrieveNextSibling(NodeObject $node, PropelPDO $con = null); @@ -232,6 +250,7 @@ public static function retrieveSiblings(NodeObject $node, PropelPDO $con = null) * * @param object $node Propel object for src node * @param PropelPDO $con Connection to use. + * * @return mixed Propel object if exists else false */ public static function retrieveParent(NodeObject $node, PropelPDO $con = null); @@ -241,6 +260,7 @@ public static function retrieveParent(NodeObject $node, PropelPDO $con = null); * * @param object $node Propel object for src node * @param PropelPDO $con Connection to use. + * * @return int Level for the given node */ public static function getLevel(NodeObject $node, PropelPDO $con = null); @@ -250,6 +270,7 @@ public static function getLevel(NodeObject $node, PropelPDO $con = null); * * @param object $node Propel object for src node * @param PropelPDO $con Connection to use. + * * @return int Level for the given node */ public static function getNumberOfChildren(NodeObject $node, PropelPDO $con = null); @@ -259,15 +280,17 @@ public static function getNumberOfChildren(NodeObject $node, PropelPDO $con = nu * * @param object $node Propel object for src node * @param PropelPDO $con Connection to use. + * * @return int Level for the given node */ public static function getNumberOfDescendants(NodeObject $node, PropelPDO $con = null); - /** + /** * Returns path to a specific node as an array, useful to create breadcrumbs * * @param object $node Propel object of node to create path to * @param PropelPDO $con Connection to use. + * * @return array Array in order of hierarchy */ public static function getPath(NodeObject $node, PropelPDO $con = null); @@ -276,6 +299,7 @@ public static function getPath(NodeObject $node, PropelPDO $con = null); * Tests if node is valid * * @param object $node Propel object for src node + * * @return bool */ public static function isValid(NodeObject $node = null); @@ -284,6 +308,7 @@ public static function isValid(NodeObject $node = null); * Tests if node is a root * * @param object $node Propel object for src node + * * @return bool */ public static function isRoot(NodeObject $node); @@ -292,6 +317,7 @@ public static function isRoot(NodeObject $node); * Tests if node is a leaf * * @param object $node Propel object for src node + * * @return bool */ public static function isLeaf(NodeObject $node); @@ -301,6 +327,7 @@ public static function isLeaf(NodeObject $node); * * @param object $child Propel object for node * @param object $parent Propel object for node + * * @return bool */ public static function isChildOf(NodeObject $child, NodeObject $parent); @@ -310,6 +337,7 @@ public static function isChildOf(NodeObject $child, NodeObject $parent); * * @param object $node1 Propel object for node * @param object $node2 Propel object for node + * * @return bool */ public static function isEqualTo(NodeObject $node1, NodeObject $node2); @@ -319,6 +347,7 @@ public static function isEqualTo(NodeObject $node1, NodeObject $node2); * * @param object $node Propel object for node * @param PropelPDO $con Connection to use. + * * @return bool */ public static function hasParent(NodeObject $node, PropelPDO $con = null); @@ -328,6 +357,7 @@ public static function hasParent(NodeObject $node, PropelPDO $con = null); * * @param object $node Propel object for node * @param PropelPDO $con Connection to use. + * * @return bool */ public static function hasPrevSibling(NodeObject $node, PropelPDO $con = null); @@ -337,6 +367,7 @@ public static function hasPrevSibling(NodeObject $node, PropelPDO $con = null); * * @param object $node Propel object for node * @param PropelPDO $con Connection to use. + * * @return bool */ public static function hasNextSibling(NodeObject $node, PropelPDO $con = null); @@ -345,6 +376,7 @@ public static function hasNextSibling(NodeObject $node, PropelPDO $con = null); * Tests if $node has children * * @param object $node Propel object for node + * * @return bool */ public static function hasChildren(NodeObject $node); @@ -362,8 +394,8 @@ public static function deleteDescendants(NodeObject $node, PropelPDO $con = null * * @param int/object $node Primary key/instance of required node * @param PropelPDO $con Connection to use. + * * @return object Propel object for model */ public static function getNode($node, PropelPDO $con = null); - } // NodePeer diff --git a/runtime/lib/util/PropelColumnTypes.php b/runtime/lib/util/PropelColumnTypes.php index ef7cbbe61..7c484d0e8 100644 --- a/runtime/lib/util/PropelColumnTypes.php +++ b/runtime/lib/util/PropelColumnTypes.php @@ -83,12 +83,13 @@ class PropelColumnTypes /** * Returns the PDO type (PDO::PARAM_* constant) value for the Propel type provided. + * * @param string $propelType + * * @return int */ public static function getPdoType($propelType) { return self::$propelToPdoMap[$propelType]; } - } diff --git a/runtime/lib/util/PropelDateTime.php b/runtime/lib/util/PropelDateTime.php index ce08c1114..90f9629ae 100644 --- a/runtime/lib/util/PropelDateTime.php +++ b/runtime/lib/util/PropelDateTime.php @@ -25,12 +25,14 @@ class PropelDateTime extends DateTime /** * A string representation of the date, for serialization. + * * @var string */ private $dateString; /** * A string representation of the time zone, for serialization. + * * @var string */ private $tzString; @@ -90,8 +92,8 @@ public static function isTimestamp($value) } $month = date('m', $value); - $day = date('d', $value); - $year = date('Y', $value); + $day = date('d', $value); + $year = date('Y', $value); return checkdate($month, $day, $year); } @@ -100,6 +102,7 @@ public static function isTimestamp($value) * PHP "magic" function called when object is serialized. * Sets an internal property with the date string and returns properties * of class that should be serialized. + * * @return array string[] */ public function __sleep() @@ -120,5 +123,4 @@ public function __wakeup() { parent::__construct($this->dateString, new DateTimeZone($this->tzString)); } - } diff --git a/runtime/lib/util/PropelModelPager.php b/runtime/lib/util/PropelModelPager.php index 01548ca48..e632ab6e9 100644 --- a/runtime/lib/util/PropelModelPager.php +++ b/runtime/lib/util/PropelModelPager.php @@ -122,7 +122,7 @@ public function setMaxRecordLimit($limit) public function getLinks($nb_links = 5) { $links = array(); - $tmp = $this->page - floor($nb_links / 2); + $tmp = $this->page - floor($nb_links / 2); $check = $this->lastPage - $nb_links + 1; $limit = ($check > 0) ? $check : 1; $begin = ($tmp > 0) ? (($tmp > $limit) ? $limit : $tmp) : 1; @@ -334,6 +334,7 @@ public function setMaxPerPage($max) /** * Check whether the internal pointer is at the beginning of the list + * * @see PropelCollection * * @return boolean @@ -345,6 +346,7 @@ public function isFirst() /** * Check whether the internal pointer is at the end of the list + * * @see PropelCollection * * @return boolean @@ -356,6 +358,7 @@ public function isLast() /** * Check if the collection is empty + * * @see PropelCollection * * @return boolean @@ -367,6 +370,7 @@ public function isEmpty() /** * Check if the current index is an odd integer + * * @see PropelCollection * * @return boolean @@ -378,6 +382,7 @@ public function isOdd() /** * Check if the current index is an even integer + * * @see PropelCollection * * @return boolean @@ -402,5 +407,4 @@ public function count() { return $this->getNbResults(); } - } diff --git a/runtime/lib/util/PropelPager.php b/runtime/lib/util/PropelPager.php index ba9a3fcdc..575d5ebc6 100644 --- a/runtime/lib/util/PropelPager.php +++ b/runtime/lib/util/PropelPager.php @@ -114,6 +114,7 @@ class PropelPager implements Countable, Iterator /** * Create a new Propel Pager. + * * @param Criteria $c * @param string $peerClass The name of the static Peer class. * @param string $peerSelectMethod The name of the static method for selecting content from the Peer class. @@ -135,7 +136,9 @@ public function __construct($c = null, $peerClass = null, $peerSelectMethod = nu /** * Set the criteria for this pager. + * * @param Criteria $c + * * @return void */ public function setCriteria(Criteria $c) @@ -145,6 +148,7 @@ public function setCriteria(Criteria $c) /** * Return the Criteria object for this pager. + * * @return Criteria */ public function getCriteria() @@ -156,6 +160,7 @@ public function getCriteria() * Set the Peer Classname * * @param string $class + * * @return void */ public function setPeerClass($class) @@ -165,6 +170,7 @@ public function setPeerClass($class) /** * Return the Peer Classname. + * * @return string */ public function getPeerClass() @@ -175,7 +181,9 @@ public function getPeerClass() /** * Set the Peer select method. * This exists for legacy support, please use setPeerSelectMethod(). + * * @param string $method The name of the static method to call on the Peer class. + * * @return void * @see setPeerSelectMethod() * @deprecated @@ -188,6 +196,7 @@ public function setPeerMethod($method) /** * Return the Peer select method. * This exists for legacy support, please use getPeerSelectMethod(). + * * @return string * @see getPeerSelectMethod() * @deprecated @@ -201,6 +210,7 @@ public function getPeerMethod() * Set the Peer select method. * * @param string $method The name of the static method to call on the Peer class. + * * @return void */ public function setPeerSelectMethod($method) @@ -210,6 +220,7 @@ public function setPeerSelectMethod($method) /** * Return the Peer select method. + * * @return string */ public function getPeerSelectMethod() @@ -221,6 +232,7 @@ public function getPeerSelectMethod() * Sets the Count method. * This is set based on the Peer method, for example if Peer method is doSelectJoin*() then the * count method will be doCountJoin*(). + * * @param string $method The name of the static method to call on the Peer class. */ public function setPeerCountMethod($method) @@ -244,7 +256,7 @@ private function guessPeerCountMethod() $selectMethod = $this->getPeerSelectMethod(); if ($selectMethod == 'doSelect') { $countMethod = 'doCount'; - } elseif ( ($pos = stripos($selectMethod, 'doSelectJoin')) === 0) { + } elseif (($pos = stripos($selectMethod, 'doSelectJoin')) === 0) { $countMethod = 'doCount' . substr($selectMethod, strlen('doSelect')); } else { // we will fall back to doCount() if we don't understand the join @@ -341,9 +353,9 @@ public function getTotalPages() if (!isset($this->pages)) { $recordCount = $this->getTotalRecordCount(); if ($this->max > 0) { - $this->pages = ceil($recordCount/$this->max); + $this->pages = ceil($recordCount / $this->max); } else { - $this->pages = 0; + $this->pages = 0; } } @@ -354,6 +366,7 @@ public function getTotalPages() * get an array of previous id's * * @param int $range + * * @return array $links */ public function getPrevLinks($range = 5) @@ -361,11 +374,11 @@ public function getPrevLinks($range = 5) $total = $this->getTotalPages(); $start = $this->getPage() - 1; $end = $this->getPage() - $range; - $first = $this->getFirstPage(); + $first = $this->getFirstPage(); $links = array(); - for ($i=$start; $i>$end; $i--) { + for ($i = $start; $i > $end; $i--) { if ($i < $first) { - break; + break; } $links[] = $i; } @@ -377,6 +390,7 @@ public function getPrevLinks($range = 5) * get an array of next id's * * @param int $range + * * @return array $links */ public function getNextLinks($range = 5) @@ -384,11 +398,11 @@ public function getNextLinks($range = 5) $total = $this->getTotalPages(); $start = $this->getPage() + 1; $end = $this->getPage() + $range; - $last = $this->getLastPage(); + $last = $this->getLastPage(); $links = array(); - for ($i=$start; $i<$end; $i++) { + for ($i = $start; $i < $end; $i++) { if ($i > $last) { - break; + break; } $links[] = $i; } @@ -414,9 +428,9 @@ public function isLastPageComplete() public function getPrev() { if ($this->getPage() != $this->getFirstPage()) { - $prev = $this->getPage() - 1; + $prev = $this->getPage() - 1; } else { - $prev = false; + $prev = false; } return $prev; @@ -430,9 +444,9 @@ public function getPrev() public function getNext() { if ($this->getPage() != $this->getLastPage()) { - $next = $this->getPage() + 1; + $next = $this->getPage() + 1; } else { - $next = false; + $next = false; } return $next; @@ -440,7 +454,9 @@ public function getNext() /** * Set the current page number (First page is 1). + * * @param int $page + * * @return void */ public function setPage($page) @@ -452,6 +468,7 @@ public function setPage($page) /** * Get current page. + * * @return int */ public function getPage() @@ -461,6 +478,7 @@ public function getPage() /** * Set the number of rows per page. + * * @param int $r */ public function setRowsPerPage($r) @@ -472,6 +490,7 @@ public function setRowsPerPage($r) /** * Get number of rows per page. + * * @return int */ public function getRowsPerPage() @@ -481,11 +500,12 @@ public function getRowsPerPage() /** * Calculate startrow / max rows based on current page and rows-per-page. + * * @return void */ private function calculateStart() { - $this->start = ( ($this->page - 1) * $this->max ); + $this->start = (($this->page - 1) * $this->max); } /** @@ -498,31 +518,24 @@ private function calculateStart() public function getTotalRecordCount() { - if (!isset($this->rs)) { - $this->doRs(); - } - - if (empty($this->recordCount)) { - $this->countCriteria = clone $this->criteria; - $this->countCriteria->setLimit(0); - $this->countCriteria->setOffset(0); - - $this->recordCount = call_user_func( - array( - $this->getPeerClass(), - $this->getPeerCountMethod() - ), - $this->countCriteria - ); + if (!isset($this->rs)) { + $this->doRs(); + } - } + if (empty($this->recordCount)) { + $this->countCriteria = clone $this->criteria; + $this->countCriteria->setLimit(0); + $this->countCriteria->setOffset(0); - return $this->recordCount; + $this->recordCount = call_user_func(array($this->getPeerClass(), $this->getPeerCountMethod()), $this->countCriteria); + } + return $this->recordCount; } /** * Sets the start row or offset. + * * @param int $v */ public function setStart($v) @@ -532,7 +545,9 @@ public function setStart($v) /** * Sets max rows (limit). + * * @param int $v + * * @return void */ public function setMax($v) @@ -542,6 +557,7 @@ public function setMax($v) /** * Returns the count of the current page's records + * * @return int */ public function count() @@ -551,6 +567,7 @@ public function count() /** * Returns the current element of the iterator + * * @return mixed */ public function current() @@ -564,6 +581,7 @@ public function current() /** * Returns the current key of the iterator + * * @return int */ public function key() @@ -573,6 +591,7 @@ public function key() /** * Advances the iterator to the next element + * * @return void */ public function next() @@ -582,6 +601,7 @@ public function next() /** * Resets the iterator to the first element + * * @return void */ public function rewind() @@ -591,6 +611,7 @@ public function rewind() /** * Checks if the current key exists in the container + * * @return boolean */ public function valid() @@ -601,5 +622,4 @@ public function valid() return in_array($this->currentKey, array_keys($this->rs)); } - } diff --git a/runtime/lib/validator/MatchValidator.php b/runtime/lib/validator/MatchValidator.php index 6ac28d719..e068a7aa7 100644 --- a/runtime/lib/validator/MatchValidator.php +++ b/runtime/lib/validator/MatchValidator.php @@ -44,12 +44,13 @@ class MatchValidator implements BasicValidator * for use with preg_match(). * * @param string $exp + * * @return string Prepared regular expression. */ private function prepareRegexp($exp) { // remove surrounding '/' marks so that they don't get escaped in next step - if ($exp{0} !== '/' || $exp{strlen($exp)-1} !== '/' ) { + if ($exp{0} !== '/' || $exp{strlen($exp) - 1} !== '/') { $exp = '/' . $exp . '/'; } @@ -67,7 +68,7 @@ private function prepareRegexp($exp) * * @return boolean */ - public function isValid (ValidatorMap $map, $str) + public function isValid(ValidatorMap $map, $str) { return (preg_match($this->prepareRegexp($map->getValue()), $str) != 0); } diff --git a/runtime/lib/validator/NotMatchValidator.php b/runtime/lib/validator/NotMatchValidator.php index 225221c7e..da284d313 100644 --- a/runtime/lib/validator/NotMatchValidator.php +++ b/runtime/lib/validator/NotMatchValidator.php @@ -42,12 +42,13 @@ class NotMatchValidator implements BasicValidator * for use with preg_match(). * * @param string $exp + * * @return string */ private function prepareRegexp($exp) { // remove surrounding '/' marks so that they don't get escaped in next step - if ($exp{0} !== '/' || $exp{strlen($exp)-1} !== '/' ) { + if ($exp{0} !== '/' || $exp{strlen($exp) - 1} !== '/') { $exp = '/' . $exp . '/'; } diff --git a/runtime/lib/validator/RequiredValidator.php b/runtime/lib/validator/RequiredValidator.php index 8d0725b89..d125fb48c 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) { return ($str !== null && $str !== ""); } diff --git a/runtime/pear/BuildPropelPEARPackageTask.php b/runtime/pear/BuildPropelPEARPackageTask.php index b7a2ca1f9..cc031c673 100644 --- a/runtime/pear/BuildPropelPEARPackageTask.php +++ b/runtime/pear/BuildPropelPEARPackageTask.php @@ -68,11 +68,11 @@ private function setOptions($pkg) } $pkg->setOptions($options); - } /** * Main entry point. + * * @return void * * @throws BuildException @@ -131,11 +131,11 @@ public function main() if (PEAR::isError($e)) { throw new BuildException("Unable to write package file.", new Exception($e->getMessage())); } - } /** * Used by the PEAR_PackageFileManager_PhingFileSet lister. + * * @return array FileSet[] */ public function getFileSets() @@ -156,12 +156,14 @@ public function createFileSet() { $num = array_push($this->filesets, new FileSet()); - return $this->filesets[$num-1]; + return $this->filesets[$num - 1]; } /** * Set the version we are building. + * * @param string $v + * * @return void */ public function setVersion($v) @@ -171,7 +173,9 @@ public function setVersion($v) /** * Set the state we are building. + * * @param string $v + * * @return void */ public function setState($v) @@ -181,16 +185,21 @@ public function setState($v) /** * Sets release notes field. + * * @param string $v + * * @return void */ public function setNotes($v) { $this->notes = $v; } + /** * Sets "dir" property from XML. + * * @param PhingFile $f + * * @return void */ public function setDir(PhingFile $f) @@ -205,5 +214,4 @@ public function setDestFile(PhingFile $f) { $this->packageFile = $f; } - } diff --git a/runtime/pear/build-pear-package.xml b/runtime/pear/build-pear-package.xml index 1b47122c0..ef33a56c2 100644 --- a/runtime/pear/build-pear-package.xml +++ b/runtime/pear/build-pear-package.xml @@ -8,113 +8,114 @@ - - - - + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - Propel version for package - - - - - - - - - ----------------------------- - | Creating directory layout | - ----------------------------- - - - - - - - - - - - - - - ----------------------------- - | Creating PEAR package.xml | - ----------------------------- - - - - - - - - - - - - - - - ----------------------------- - | Creating tar.gz package | - ----------------------------- - - - - + + + + + + + + + + + + + + + + + + + + + + + + + Propel version for package + + + + + + + + + ----------------------------- + | Creating directory layout | + ----------------------------- + + + + + + + + + + + + + + ----------------------------- + | Creating PEAR package.xml | + ----------------------------- + + + + + + + + + + + + + + + ----------------------------- + | Creating tar.gz package | + ----------------------------- + + + +