From 972e503fa83e24b8009a2bc0b89e48be49fe9e3a Mon Sep 17 00:00:00 2001 From: Felix Labrecque Date: Thu, 29 Nov 2012 10:30:50 -0500 Subject: [PATCH 01/12] Fix problem when 1 column identifier in propel is a string. The ModelChoiceList thinks it can be used as the index of the ChoiceList, when it can only be used if it is an integer. --- .../Form/ChoiceList/ModelChoiceList.php | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php index 54fe224d31..82d5e9d49d 100644 --- a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php +++ b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php @@ -45,6 +45,13 @@ class ModelChoiceList extends ObjectChoiceList */ private $loaded = false; + /** + * Whether to use the identifier for index generation + * + * @var Boolean + */ + private $identifierAsIndex = false; + /** * @param string $class * @param string $labelPath @@ -69,6 +76,13 @@ class ModelChoiceList extends ObjectChoiceList $choices = array(); } + if (1 === count($this->identifier)) { + // TODO this should be current($this->identifier)->isInteger() when propel ColumnMap contains the isInteger function + if ($this->isInteger(current($this->identifier))) { + $this->identifierAsIndex = true; + } + } + parent::__construct($choices, $labelPath, array(), $groupPath); } @@ -224,7 +238,7 @@ class ModelChoiceList extends ObjectChoiceList // know that the IDs are used as indices // Attention: This optimization does not check choices for existence - if (1 === count($this->identifier)) { + if ($this->identifierAsIndex) { $indices = array(); foreach ($models as $model) { @@ -259,7 +273,7 @@ class ModelChoiceList extends ObjectChoiceList // know that the IDs are used as indices and values // Attention: This optimization does not check values for existence - if (1 === count($this->identifier)) { + if ($this->identifierAsIndex) { return $this->fixIndices($values); } @@ -283,7 +297,7 @@ class ModelChoiceList extends ObjectChoiceList */ protected function createIndex($model) { - if (1 === count($this->identifier)) { + if ($this->identifierAsIndex) { return current($this->getIdentifierValues($model)); } @@ -351,4 +365,15 @@ class ModelChoiceList extends ObjectChoiceList return $model->getPrimaryKeys(); } + + /** + * Whether this column in an integer + * TODO we could add this function to propel ColumnMap class instead + * + * @return boolean + */ + private function isInteger($col) + { + return $col->getType() === \PDO::PARAM_INT; + } } From cf8a6c00f305fcb8c47f3b2d48906d70ec7bba5a Mon Sep 17 00:00:00 2001 From: Felix Labrecque Date: Tue, 4 Dec 2012 10:43:26 -0500 Subject: [PATCH 02/12] Fix my code and also fix the test suite. --- .../Propel1/Tests/Fixtures/ColumnMap.php | 61 ++++++++++++ .../Tests/Fixtures/PropelColumnTypes.php | 96 +++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php create mode 100644 src/Symfony/Bridge/Propel1/Tests/Fixtures/PropelColumnTypes.php diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php new file mode 100644 index 0000000000..5e8d972b91 --- /dev/null +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Propel1\Tests\Fixtures; + +class ColumnMap +{ + // Propel type of the column + protected $type; + + // The TableMap for this column + protected $table; + + // The name of the column + protected $columnName; + + public function __construct($name, $containingTable) + { + $this->columnName = $name; + $this->table = $containingTable; + } + + /** + * 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); + } +} diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/PropelColumnTypes.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/PropelColumnTypes.php new file mode 100644 index 0000000000..5fdef59060 --- /dev/null +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/PropelColumnTypes.php @@ -0,0 +1,96 @@ + (Propel) + * @version $Revision$ + * @package propel.runtime.util + */ +class PropelColumnTypes +{ + + const + CHAR = "CHAR", + VARCHAR = "VARCHAR", + LONGVARCHAR = "LONGVARCHAR", + CLOB = "CLOB", + CLOB_EMU = "CLOB_EMU", + NUMERIC = "NUMERIC", + DECIMAL = "DECIMAL", + TINYINT = "TINYINT", + SMALLINT = "SMALLINT", + INTEGER = "INTEGER", + BIGINT = "BIGINT", + REAL = "REAL", + FLOAT = "FLOAT", + DOUBLE = "DOUBLE", + BINARY = "BINARY", + VARBINARY = "VARBINARY", + LONGVARBINARY = "LONGVARBINARY", + BLOB = "BLOB", + DATE = "DATE", + TIME = "TIME", + TIMESTAMP = "TIMESTAMP", + BU_DATE = "BU_DATE", + BU_TIMESTAMP = "BU_TIMESTAMP", + BOOLEAN = "BOOLEAN", + BOOLEAN_EMU = "BOOLEAN_EMU", + OBJECT = "OBJECT", + PHP_ARRAY = "ARRAY", + ENUM = "ENUM"; + + private static $propelToPdoMap = array( + self::CHAR => \PDO::PARAM_STR, + self::VARCHAR => \PDO::PARAM_STR, + self::LONGVARCHAR => \PDO::PARAM_STR, + self::CLOB => \PDO::PARAM_LOB, + self::CLOB_EMU => \PDO::PARAM_STR, + self::NUMERIC => \PDO::PARAM_STR, + self::DECIMAL => \PDO::PARAM_STR, + self::TINYINT => \PDO::PARAM_INT, + self::SMALLINT => \PDO::PARAM_INT, + self::INTEGER => \PDO::PARAM_INT, + self::BIGINT => \PDO::PARAM_STR, + self::REAL => \PDO::PARAM_STR, + self::FLOAT => \PDO::PARAM_STR, + self::DOUBLE => \PDO::PARAM_STR, + self::BINARY => \PDO::PARAM_STR, + self::VARBINARY => \PDO::PARAM_STR, + self::LONGVARBINARY => \PDO::PARAM_STR, + self::BLOB => \PDO::PARAM_LOB, + self::DATE => \PDO::PARAM_STR, + self::TIME => \PDO::PARAM_STR, + self::TIMESTAMP => \PDO::PARAM_STR, + self::BU_DATE => \PDO::PARAM_STR, + self::BU_TIMESTAMP => \PDO::PARAM_STR, + self::BOOLEAN => \PDO::PARAM_BOOL, + self::BOOLEAN_EMU => \PDO::PARAM_INT, + self::OBJECT => \PDO::PARAM_STR, + self::PHP_ARRAY => \PDO::PARAM_STR, + self::ENUM => \PDO::PARAM_INT, + ); + + /** + * Resturns 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]; + } + +} From 0e4419ba673f1f87a60aef9cef08ac77bacc9a51 Mon Sep 17 00:00:00 2001 From: Felix Labrecque Date: Tue, 4 Dec 2012 10:48:16 -0500 Subject: [PATCH 03/12] I found the error in my latest commit. This pass the test suite. --- .../Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php | 2 +- src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php | 4 +++- .../Bridge/Propel1/Tests/Fixtures/ReadOnlyItemQuery.php | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php index 82d5e9d49d..684b385edc 100644 --- a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php +++ b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php @@ -374,6 +374,6 @@ class ModelChoiceList extends ObjectChoiceList */ private function isInteger($col) { - return $col->getType() === \PDO::PARAM_INT; + return $col->getPdoType() === \PDO::PARAM_INT; } } diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php index 75d2a4f731..b86ed421fd 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php @@ -31,7 +31,9 @@ class ItemQuery public function getPrimaryKeys() { - return array('id'); + $cm = new ColumnMap('id', $this); + $cm->setType('INTEGER'); + return array('id' => $cm); } /** diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ReadOnlyItemQuery.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ReadOnlyItemQuery.php index 8c9677f33d..974e923dc9 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ReadOnlyItemQuery.php +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ReadOnlyItemQuery.php @@ -22,6 +22,8 @@ class ReadOnlyItemQuery public function getPrimaryKeys() { - return array('id'); + $cm = new ColumnMap('id', $this); + $cm->setType('INTEGER'); + return array('id' => $cm); } } From 812516339531b8cf7f00a546835e1122ae6b4f57 Mon Sep 17 00:00:00 2001 From: woodspire Date: Tue, 4 Dec 2012 13:53:37 -0500 Subject: [PATCH 04/12] removed the TODO mention. Will keep the Propel code here so it can work with older version of Propel --- src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php index 684b385edc..76ccaaa090 100644 --- a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php +++ b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php @@ -77,7 +77,6 @@ class ModelChoiceList extends ObjectChoiceList } if (1 === count($this->identifier)) { - // TODO this should be current($this->identifier)->isInteger() when propel ColumnMap contains the isInteger function if ($this->isInteger(current($this->identifier))) { $this->identifierAsIndex = true; } @@ -368,7 +367,6 @@ class ModelChoiceList extends ObjectChoiceList /** * Whether this column in an integer - * TODO we could add this function to propel ColumnMap class instead * * @return boolean */ From 6f8cd9daf073278e8f05505e810bf01f2a225403 Mon Sep 17 00:00:00 2001 From: woodspire Date: Tue, 4 Dec 2012 13:58:20 -0500 Subject: [PATCH 05/12] Removed the PropelColumnTypes.php copy Using the Propel class instead, like in Column class --- .../Propel1/Tests/Fixtures/ColumnMap.php | 2 +- .../Tests/Fixtures/PropelColumnTypes.php | 96 ------------------- 2 files changed, 1 insertion(+), 97 deletions(-) delete mode 100644 src/Symfony/Bridge/Propel1/Tests/Fixtures/PropelColumnTypes.php diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php index 5e8d972b91..8a4a604a53 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php @@ -56,6 +56,6 @@ class ColumnMap */ public function getPdoType() { - return PropelColumnTypes::getPdoType($this->type); + return \PropelColumnTypes::getPdoType($this->type); } } diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/PropelColumnTypes.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/PropelColumnTypes.php deleted file mode 100644 index 5fdef59060..0000000000 --- a/src/Symfony/Bridge/Propel1/Tests/Fixtures/PropelColumnTypes.php +++ /dev/null @@ -1,96 +0,0 @@ - (Propel) - * @version $Revision$ - * @package propel.runtime.util - */ -class PropelColumnTypes -{ - - const - CHAR = "CHAR", - VARCHAR = "VARCHAR", - LONGVARCHAR = "LONGVARCHAR", - CLOB = "CLOB", - CLOB_EMU = "CLOB_EMU", - NUMERIC = "NUMERIC", - DECIMAL = "DECIMAL", - TINYINT = "TINYINT", - SMALLINT = "SMALLINT", - INTEGER = "INTEGER", - BIGINT = "BIGINT", - REAL = "REAL", - FLOAT = "FLOAT", - DOUBLE = "DOUBLE", - BINARY = "BINARY", - VARBINARY = "VARBINARY", - LONGVARBINARY = "LONGVARBINARY", - BLOB = "BLOB", - DATE = "DATE", - TIME = "TIME", - TIMESTAMP = "TIMESTAMP", - BU_DATE = "BU_DATE", - BU_TIMESTAMP = "BU_TIMESTAMP", - BOOLEAN = "BOOLEAN", - BOOLEAN_EMU = "BOOLEAN_EMU", - OBJECT = "OBJECT", - PHP_ARRAY = "ARRAY", - ENUM = "ENUM"; - - private static $propelToPdoMap = array( - self::CHAR => \PDO::PARAM_STR, - self::VARCHAR => \PDO::PARAM_STR, - self::LONGVARCHAR => \PDO::PARAM_STR, - self::CLOB => \PDO::PARAM_LOB, - self::CLOB_EMU => \PDO::PARAM_STR, - self::NUMERIC => \PDO::PARAM_STR, - self::DECIMAL => \PDO::PARAM_STR, - self::TINYINT => \PDO::PARAM_INT, - self::SMALLINT => \PDO::PARAM_INT, - self::INTEGER => \PDO::PARAM_INT, - self::BIGINT => \PDO::PARAM_STR, - self::REAL => \PDO::PARAM_STR, - self::FLOAT => \PDO::PARAM_STR, - self::DOUBLE => \PDO::PARAM_STR, - self::BINARY => \PDO::PARAM_STR, - self::VARBINARY => \PDO::PARAM_STR, - self::LONGVARBINARY => \PDO::PARAM_STR, - self::BLOB => \PDO::PARAM_LOB, - self::DATE => \PDO::PARAM_STR, - self::TIME => \PDO::PARAM_STR, - self::TIMESTAMP => \PDO::PARAM_STR, - self::BU_DATE => \PDO::PARAM_STR, - self::BU_TIMESTAMP => \PDO::PARAM_STR, - self::BOOLEAN => \PDO::PARAM_BOOL, - self::BOOLEAN_EMU => \PDO::PARAM_INT, - self::OBJECT => \PDO::PARAM_STR, - self::PHP_ARRAY => \PDO::PARAM_STR, - self::ENUM => \PDO::PARAM_INT, - ); - - /** - * Resturns 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]; - } - -} From 36d6c40bb19cd3c14ec247ad8b2a13160041f9ce Mon Sep 17 00:00:00 2001 From: woodspire Date: Wed, 5 Dec 2012 08:35:28 -0500 Subject: [PATCH 06/12] fix indentation problem --- .../Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php index 76ccaaa090..e882571370 100644 --- a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php +++ b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php @@ -77,9 +77,9 @@ class ModelChoiceList extends ObjectChoiceList } if (1 === count($this->identifier)) { - if ($this->isInteger(current($this->identifier))) { - $this->identifierAsIndex = true; - } + if ($this->isInteger(current($this->identifier))) { + $this->identifierAsIndex = true; + } } parent::__construct($choices, $labelPath, array(), $groupPath); @@ -372,6 +372,6 @@ class ModelChoiceList extends ObjectChoiceList */ private function isInteger($col) { - return $col->getPdoType() === \PDO::PARAM_INT; + return $col->getPdoType() === PDO::PARAM_INT; } } From e5e3341a6db52eb8a1794ce34c6ad5f67ebaebe0 Mon Sep 17 00:00:00 2001 From: woodspire Date: Wed, 5 Dec 2012 08:37:06 -0500 Subject: [PATCH 07/12] oups. It seems that here, we need \PDO --- src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php index e882571370..0a2585fe16 100644 --- a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php +++ b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php @@ -372,6 +372,6 @@ class ModelChoiceList extends ObjectChoiceList */ private function isInteger($col) { - return $col->getPdoType() === PDO::PARAM_INT; + return $col->getPdoType() === \PDO::PARAM_INT; } } From 6fb953645fce86f435db646ce05d788dc485ca85 Mon Sep 17 00:00:00 2001 From: woodspire Date: Wed, 5 Dec 2012 08:39:27 -0500 Subject: [PATCH 08/12] fix indentation problem --- src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php index 8a4a604a53..8440adc719 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php @@ -36,7 +36,7 @@ class ColumnMap */ public function setType($type) { - $this->type = $type; + $this->type = $type; } /** @@ -46,7 +46,7 @@ class ColumnMap */ public function getType() { - return $this->type; + return $this->type; } /** @@ -56,6 +56,6 @@ class ColumnMap */ public function getPdoType() { - return \PropelColumnTypes::getPdoType($this->type); + return \PropelColumnTypes::getPdoType($this->type); } } From ffd87591e1b9f86cd176379960acaa94392d1926 Mon Sep 17 00:00:00 2001 From: woodspire Date: Wed, 5 Dec 2012 15:30:04 -0500 Subject: [PATCH 09/12] fix some formatting issue --- .../Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php | 7 +++---- src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php | 1 + .../Bridge/Propel1/Tests/Fixtures/ReadOnlyItemQuery.php | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php index 0a2585fe16..8f00c6596e 100644 --- a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php +++ b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php @@ -76,10 +76,9 @@ class ModelChoiceList extends ObjectChoiceList $choices = array(); } - if (1 === count($this->identifier)) { - if ($this->isInteger(current($this->identifier))) { - $this->identifierAsIndex = true; - } + if ( 1 === count($this->identifier) + && $this->isInteger(current($this->identifier))) { + $this->identifierAsIndex = true; } parent::__construct($choices, $labelPath, array(), $groupPath); diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php index b86ed421fd..20c52d63e5 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php @@ -33,6 +33,7 @@ class ItemQuery { $cm = new ColumnMap('id', $this); $cm->setType('INTEGER'); + return array('id' => $cm); } diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ReadOnlyItemQuery.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ReadOnlyItemQuery.php index 974e923dc9..a356837e29 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ReadOnlyItemQuery.php +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ReadOnlyItemQuery.php @@ -24,6 +24,7 @@ class ReadOnlyItemQuery { $cm = new ColumnMap('id', $this); $cm->setType('INTEGER'); + return array('id' => $cm); } } From a26a6904d8c3e5bf44b3e0d242af80aea4b9b495 Mon Sep 17 00:00:00 2001 From: William DURAND Date: Wed, 5 Dec 2012 21:46:02 +0100 Subject: [PATCH 10/12] remove useless ColumnMap --- .../Propel1/Tests/Fixtures/ColumnMap.php | 61 ------------------- 1 file changed, 61 deletions(-) delete mode 100644 src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php deleted file mode 100644 index 8440adc719..0000000000 --- a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php +++ /dev/null @@ -1,61 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\Propel1\Tests\Fixtures; - -class ColumnMap -{ - // Propel type of the column - protected $type; - - // The TableMap for this column - protected $table; - - // The name of the column - protected $columnName; - - public function __construct($name, $containingTable) - { - $this->columnName = $name; - $this->table = $containingTable; - } - - /** - * 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); - } -} From 86ab4b345af487de101946cabc8df14add8e8f06 Mon Sep 17 00:00:00 2001 From: William DURAND Date: Wed, 5 Dec 2012 21:47:05 +0100 Subject: [PATCH 11/12] Add typehint to isInteger(), fix tests --- .../Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php | 10 ++++++---- .../Bridge/Propel1/Tests/Fixtures/ItemQuery.php | 2 +- .../Propel1/Tests/Fixtures/ReadOnlyItemQuery.php | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php index 8f00c6596e..5d94040622 100644 --- a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php +++ b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php @@ -347,8 +347,8 @@ class ModelChoiceList extends ObjectChoiceList * be persisted or added to the idmodel map before. Otherwise an * exception is thrown. * - * @param object $model The model for which to get the identifier - * @throws FormException If the model does not exist + * @param object $model The model for which to get the identifier + * @throws FormException If the model does not exist */ private function getIdentifierValues($model) { @@ -367,10 +367,12 @@ class ModelChoiceList extends ObjectChoiceList /** * Whether this column in an integer * + * @param ColumnMap $column + * * @return boolean */ - private function isInteger($col) + private function isInteger(\ColumnMap $column) { - return $col->getPdoType() === \PDO::PARAM_INT; + return $column->getPdoType() === \PDO::PARAM_INT; } } diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php index 20c52d63e5..fe2d03e05f 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php @@ -31,7 +31,7 @@ class ItemQuery public function getPrimaryKeys() { - $cm = new ColumnMap('id', $this); + $cm = new \ColumnMap('id', new \TableMap()); $cm->setType('INTEGER'); return array('id' => $cm); diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ReadOnlyItemQuery.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ReadOnlyItemQuery.php index a356837e29..0e77c26fcf 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ReadOnlyItemQuery.php +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ReadOnlyItemQuery.php @@ -22,7 +22,7 @@ class ReadOnlyItemQuery public function getPrimaryKeys() { - $cm = new ColumnMap('id', $this); + $cm = new \ColumnMap('id', new \TableMap()); $cm->setType('INTEGER'); return array('id' => $cm); From a3a832c2c171ffbe0abe6b648ad41980a16e1895 Mon Sep 17 00:00:00 2001 From: William DURAND Date: Wed, 5 Dec 2012 21:49:32 +0100 Subject: [PATCH 12/12] Fix CS in the whole Propel1 bridge --- .../Propel1/DataCollector/PropelDataCollector.php | 12 ++++++------ .../Propel1/Form/ChoiceList/ModelChoiceList.php | 6 +++--- .../TranslationCollectionFormListener.php | 2 +- src/Symfony/Bridge/Propel1/Logger/PropelLogger.php | 2 +- .../Propel1/Tests/Fixtures/TranslatableItem.php | 3 +-- .../Propel1/Tests/Fixtures/TranslatableItemI18n.php | 7 ++----- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/Symfony/Bridge/Propel1/DataCollector/PropelDataCollector.php b/src/Symfony/Bridge/Propel1/DataCollector/PropelDataCollector.php index 644705f05c..bbb15fb9a0 100644 --- a/src/Symfony/Bridge/Propel1/DataCollector/PropelDataCollector.php +++ b/src/Symfony/Bridge/Propel1/DataCollector/PropelDataCollector.php @@ -63,7 +63,7 @@ class PropelDataCollector extends DataCollector /** * Returns the collector name. * - * @return string The collector name. + * @return string The collector name. */ public function getName() { @@ -73,7 +73,7 @@ class PropelDataCollector extends DataCollector /** * Returns queries. * - * @return array Queries + * @return array Queries */ public function getQueries() { @@ -83,7 +83,7 @@ class PropelDataCollector extends DataCollector /** * Returns the query count. * - * @return int The query count + * @return int The query count */ public function getQueryCount() { @@ -93,7 +93,7 @@ class PropelDataCollector extends DataCollector /** * Returns the total time of queries. * - * @return float The total time of queries + * @return float The total time of queries */ public function getTime() { @@ -108,7 +108,7 @@ class PropelDataCollector extends DataCollector /** * Creates an array of Build objects. * - * @return array An array of Build objects + * @return array An array of Build objects */ private function buildQueries() { @@ -138,7 +138,7 @@ class PropelDataCollector extends DataCollector /** * Count queries. * - * @return int The number of queries. + * @return int The number of queries. */ private function countQueries() { diff --git a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php index 5d94040622..ed46134c52 100644 --- a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php +++ b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php @@ -76,8 +76,7 @@ class ModelChoiceList extends ObjectChoiceList $choices = array(); } - if ( 1 === count($this->identifier) - && $this->isInteger(current($this->identifier))) { + if (1 === count($this->identifier) && $this->isInteger(current($this->identifier))) { $this->identifierAsIndex = true; } @@ -347,7 +346,8 @@ class ModelChoiceList extends ObjectChoiceList * be persisted or added to the idmodel map before. Otherwise an * exception is thrown. * - * @param object $model The model for which to get the identifier + * @param object $model The model for which to get the identifier + * * @throws FormException If the model does not exist */ private function getIdentifierValues($model) diff --git a/src/Symfony/Bridge/Propel1/Form/EventListener/TranslationCollectionFormListener.php b/src/Symfony/Bridge/Propel1/Form/EventListener/TranslationCollectionFormListener.php index 3e07518d0c..ae39700736 100644 --- a/src/Symfony/Bridge/Propel1/Form/EventListener/TranslationCollectionFormListener.php +++ b/src/Symfony/Bridge/Propel1/Form/EventListener/TranslationCollectionFormListener.php @@ -89,7 +89,7 @@ class TranslationCollectionFormListener implements EventSubscriberInterface break; } } - if(!$foundData) { + if (!$foundData) { throw new UnexpectedTypeException($rootData, 'Propel i18n object'); } diff --git a/src/Symfony/Bridge/Propel1/Logger/PropelLogger.php b/src/Symfony/Bridge/Propel1/Logger/PropelLogger.php index 8e38f2418e..1fd7dedf90 100644 --- a/src/Symfony/Bridge/Propel1/Logger/PropelLogger.php +++ b/src/Symfony/Bridge/Propel1/Logger/PropelLogger.php @@ -161,7 +161,7 @@ class PropelLogger /** * Returns queries. * - * @return array Queries + * @return array Queries */ public function getQueries() { diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItem.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItem.php index 95ac0e1526..c69fe45299 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItem.php +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItem.php @@ -112,8 +112,7 @@ class TranslatableItem implements \Persistent public function addTranslatableItemI18n(TranslatableItemI18n $i) { - if(!in_array($i, $this->currentTranslations)) - { + if (!in_array($i, $this->currentTranslations)) { $this->currentTranslations[$i->getLocale()] = $i; $i->setItem($this); } diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItemI18n.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItemI18n.php index c9eb690a43..1253b26c26 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItemI18n.php +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItemI18n.php @@ -13,8 +13,8 @@ namespace Symfony\Bridge\Propel1\Tests\Fixtures; use PropelPDO; -class TranslatableItemI18n implements \Persistent { - +class TranslatableItemI18n implements \Persistent +{ private $id; private $locale; @@ -100,7 +100,6 @@ class TranslatableItemI18n implements \Persistent { public function getLocale() { - return $this->locale; } @@ -122,7 +121,6 @@ class TranslatableItemI18n implements \Persistent { public function getValue() { - return $this->value; } @@ -134,7 +132,6 @@ class TranslatableItemI18n implements \Persistent { public function getValue2() { - return $this->value2; } }