Skip to content
This repository
Browse code

Merge pull request #299 from hhamon/various_psr2_cs_fixes

Fixed various PSR-2 violations thanks to Sonar Source.
  • Loading branch information...
commit 99e125ebc6eee35bdf3f1f3ed682e3646efff350 2 parents f86db9e + 6d87ad2
William Durand willdurand authored

Showing 21 changed files with 171 additions and 149 deletions. Show diff stats Hide diff stats

  1. +1 1  src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php
  2. +27 20 src/Propel/Generator/Behavior/Validate/ValidateBehavior.php
  3. +16 13 src/Propel/Generator/Builder/Om/AbstractOMBuilder.php
  4. +11 5 src/Propel/Generator/Builder/Om/ObjectBuilder.php
  5. +4 4 src/Propel/Generator/Builder/Om/PeerBuilder.php
  6. +14 7 src/Propel/Generator/Config/ArrayToPhpConverter.php
  7. +2 2 src/Propel/Generator/Config/XmlToArrayConverter.php
  8. +6 5 src/Propel/Generator/Model/Column.php
  9. +1 1  src/Propel/Generator/Model/Diff/TableDiff.php
  10. +1 1  src/Propel/Generator/Model/Inheritance.php
  11. +2 2 src/Propel/Generator/Platform/DefaultPlatform.php
  12. +3 3 src/Propel/Generator/Platform/MysqlPlatform.php
  13. +5 5 src/Propel/Generator/Reverse/MysqlSchemaParser.php
  14. +36 36 src/Propel/Generator/Reverse/PgsqlSchemaParser.php
  15. +2 2 src/Propel/Runtime/ActiveQuery/Criteria.php
  16. +4 6 src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php
  17. +1 2  src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php
  18. +32 31 src/Propel/Runtime/ActiveQuery/ModelCriteria.php
  19. +1 1  src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php
  20. +1 1  src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php
  21. +1 1  tests/Propel/Tests/Runtime/ActiveQuery/Criterion/CustomCriterionTest.php
2  src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php
@@ -24,7 +24,7 @@ class ArchivableBehavior extends Behavior
24 24 // default parameters value
25 25 protected $parameters = array(
26 26 'archive_table' => '',
27   - 'archive_phpname' => NULL,
  27 + 'archive_phpname' => null,
28 28 'archive_class' => '',
29 29 'log_archived_at' => 'true',
30 30 'archived_at_column' => 'archived_at',
47 src/Propel/Generator/Behavior/Validate/ValidateBehavior.php
@@ -41,10 +41,14 @@ public function objectMethods($builder)
41 41 $this->cleanupParameters();
42 42
43 43 $this->builder = $builder;
44   -
45   - $this->builder->declareClasses('Symfony\\Component\\Validator\\Mapping\\ClassMetadata', 'Symfony\\Component\\Validator\\Validator',
46   -'Symfony\\Component\\Validator\\Mapping\\Loader\\StaticMethodLoader', 'Symfony\\Component\\Validator\\ConstraintValidatorFactory',
47   -'Symfony\\Component\\Validator\\Mapping\\ClassMetadataFactory', 'Symfony\\Component\\Validator\\ConstraintViolationList');
  44 + $this->builder->declareClasses(
  45 + 'Symfony\\Component\\Validator\\Mapping\\ClassMetadata',
  46 + 'Symfony\\Component\\Validator\\Validator',
  47 + 'Symfony\\Component\\Validator\\Mapping\\Loader\\StaticMethodLoader',
  48 + 'Symfony\\Component\\Validator\\ConstraintValidatorFactory',
  49 + 'Symfony\\Component\\Validator\\Mapping\\ClassMetadataFactory',
  50 + 'Symfony\\Component\\Validator\\ConstraintViolationList'
  51 + );
48 52
49 53 $script = $this->addLoadValidatorMetadataMethod();
50 54 $script .= $this->addValidateMethod();
@@ -77,7 +81,7 @@ public function getParametersFromColumnName($columnName = null)
77 81 $this->cleanupParameters();
78 82 foreach ($this->getParameters() as $key => $parameter) {
79 83 if ($parameter['column'] === $columnName) {
80   - $array[$key] = $parameter;
  84 + $array[$key] = $parameter;
81 85 }
82 86 }
83 87 }
@@ -114,13 +118,16 @@ public function removeParametersFromColumnName($columnName = null)
114 118 */
115 119 public function addRuleOnPk()
116 120 {
117   - if (count($this->getParameters()) <= 0) {
118   - $pk = $this->getTable()->getPrimaryKey();
119   - $rule['auto_rule']['column'] = $pk[0]->getName();
120   - $rule['auto_rule']['validator'] = 'Type';
121   - $rule['auto_rule']['options'] = array('type' => $pk[0]->getPhpType());
122   -
123   - $this->setParameters($rule);
  121 + if (!count($this->getParameters())) {
  122 + $pk = $this->getTable()->getPrimaryKey();
  123 + $parameters = array('auto_rule' => array(
  124 + 'column' => $pk[0]->getName(),
  125 + 'validators' => 'Type',
  126 + 'options' => array(
  127 + 'type' => $pk[0]->getPhpType(),
  128 + ),
  129 + ));
  130 + $this->setParameters($parameters);
124 131 }
125 132 }
126 133
@@ -154,14 +161,14 @@ public function mergeParameters(array $params = null)
154 161 */
155 162 protected function cleanupParameters()
156 163 {
157   - $parser = new Parser();
158   - $params = $this->getParameters();
159   - foreach ($params as $key => $value) {
160   - if (is_string($value)) {
161   - $params[$key] = $parser->parse($value);
162   - }
163   - }
164   - $this->setParameters($params);
  164 + $parser = new Parser();
  165 + $params = $this->getParameters();
  166 + foreach ($params as $key => $value) {
  167 + if (is_string($value)) {
  168 + $params[$key] = $parser->parse($value);
  169 + }
  170 + }
  171 + $this->setParameters($params);
165 172 }
166 173
167 174 /**
29 src/Propel/Generator/Builder/Om/AbstractOMBuilder.php
@@ -302,10 +302,11 @@ public function declareClassNamespace($class, $namespace = '', $alias = false)
302 302 return $this->declareClassNamespace($class, $namespace, 'Child' . $class);
303 303 }
304 304
305   - throw new LogicException(
306   - sprintf('The class %s duplicates the class %s and can\'t be used without alias',
307   - $namespace . '\\' . $class, $this->declaredShortClassesOrAlias[$aliasWanted])
308   - );
  305 + throw new LogicException(sprintf(
  306 + 'The class %s duplicates the class %s and can\'t be used without alias',
  307 + $namespace . '\\' . $class,
  308 + $this->declaredShortClassesOrAlias[$aliasWanted]
  309 + ));
309 310 }
310 311
311 312 /**
@@ -324,18 +325,23 @@ protected function needAliasForClassName($class, $namespace)
324 325 }
325 326
326 327 if (empty($namespace) && 'Base' === $this->getNamespace()) {
327   - if (str_replace(array('Peer','Query'), '', $class) == str_replace(array('Peer','Query'), '', $this->getUnqualifiedClassName())) {
  328 + if (str_replace(array('Peer', 'Query'), '', $class) == str_replace(array('Peer', 'Query'), '', $this->getUnqualifiedClassName())) {
328 329 return true;
329   - } elseif ((false !== strpos($class,'Peer') || false !== strpos($class,'Query'))) {
  330 + }
  331 +
  332 + if ((false !== strpos($class, 'Peer') || false !== strpos($class, 'Query'))) {
330 333 return true;
331   - } elseif (false === array_search($class, $this->whiteListOfDeclaredClasses, true)) { //force alias for model without namespace
  334 + }
332 335
  336 + // force alias for model without namespace
  337 + if (false === array_search($class, $this->whiteListOfDeclaredClasses, true)) {
333 338 return true;
334 339 }
335 340 }
336 341
337   - if ('Base' == $namespace && '' == $this->getNamespace()) {
338   - if (false === array_search($class, $this->whiteListOfDeclaredClasses, true)) { //force alias for model without namespace
  342 + if ('Base' === $namespace && '' === $this->getNamespace()) {
  343 + // force alias for model without namespace
  344 + if (false === array_search($class, $this->whiteListOfDeclaredClasses, true)) {
339 345
340 346 return true;
341 347 }
@@ -768,10 +774,7 @@ public function renderTemplate($filename, $vars = array(), $templateDir = '/temp
768 774 // try with '.php' at the end
769 775 $filePath = $filePath . '.php';
770 776 if (!file_exists($filePath)) {
771   - throw new \InvalidArgumentException(sprintf('Template "%s" not found in "%s" directory',
772   - $filename,
773   - __DIR__ . $templateDir
774   - ));
  777 + throw new \InvalidArgumentException(sprintf('Template "%s" not found in "%s" directory', $filename, __DIR__ . $templateDir));
775 778 }
776 779 }
777 780 $template = new PropelTemplate();
16 src/Propel/Generator/Builder/Om/ObjectBuilder.php
@@ -236,7 +236,7 @@ protected function addClassOpen(&$script)
236 236 if ($interface = $this->getInterface()) {
237 237 $script .= ", Child" . ClassTools::classname($interface);
238 238 if ($interface !== ClassTools::classname($interface)) {
239   - $this->declareClass($interface);
  239 + $this->declareClass($interface);
240 240 } else {
241 241 $this->declareClassFromBuilder($this->getInterfaceBuilder());
242 242 }
@@ -894,7 +894,10 @@ public function addTemporalAccessorOpen(&$script, Column $column)
894 894 } elseif ($column->getType() === PropelTypes::TIMESTAMP) {
895 895 $defaultfmt = $this->getBuildProperty('defaultTimeStampFormat');
896 896 }
897   - if (empty($defaultfmt)) { $defaultfmt = null; }
  897 +
  898 + if (empty($defaultfmt)) {
  899 + $defaultfmt = null;
  900 + }
898 901
899 902 $script .= "
900 903 ".$visibility." function get$cfc(\$format = ".var_export($defaultfmt, true)."";
@@ -953,7 +956,10 @@ protected function addTemporalAccessorBody(&$script, Column $column)
953 956 } elseif ($column->getType() === PropelTypes::TIMESTAMP) {
954 957 $defaultfmt = $this->getBuildProperty('defaultTimeStampFormat');
955 958 }
956   - if (empty($defaultfmt)) { $defaultfmt = null; }
  959 +
  960 + if (empty($defaultfmt)) {
  961 + $defaultfmt = null;
  962 + }
957 963
958 964 if ($column->isLazyLoad()) {
959 965 $script .= $this->getAccessorLazyLoadSnippet($column);
@@ -3300,7 +3306,7 @@ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK)
3300 3306
3301 3307 $peerClassName = $this->getClassNameFromBuilder($this->getStubPeerBuilder());
3302 3308 $fkQueryClassName = $this->getClassNameFromBuilder($this->getNewStubQueryBuilder($refFK->getTable()));
3303   - $relCol = $this->getRefFKPhpNameAffix($refFK, $plural=true);
  3309 + $relCol = $this->getRefFKPhpNameAffix($refFK, $plural = true);
3304 3310 $collName = $this->getRefFKCollVarName($refFK);
3305 3311
3306 3312 $fkPeerBuilder = $this->getNewPeerBuilder($tblFK);
@@ -4324,7 +4330,7 @@ protected function doInsert(ConnectionInterface \$con)
4324 4330 if ($this->getPlatform() instanceof MssqlPlatform) {
4325 4331 if ($table->hasAutoIncrementPrimaryKey() ) {
4326 4332 $script .= "
4327   - \$this->modifiedColumns[] = " . $this->getColumnConstant($table->getAutoIncrementPrimaryKey() ) . ";";
  4333 + \$this->modifiedColumns[] = " . $this->getColumnConstant($table->getAutoIncrementPrimaryKey()).';';
4328 4334 }
4329 4335 $script .= "
4330 4336 \$criteria = \$this->buildCriteria();";
8 src/Propel/Generator/Builder/Om/PeerBuilder.php
@@ -2082,7 +2082,7 @@ public function addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder
2082 2082 \$criteria->addJoin(%s, %s, \$joinBehavior);
2083 2083 ",
2084 2084 $this->getColumnConstant($table->getColumn($lftCol)),
2085   - $joinedTablePeerBuilder->getColumnConstant($joinTable->getColumn($lfMap[$lftCol] ))
  2085 + $joinedTablePeerBuilder->getColumnConstant($joinTable->getColumn($lfMap[$lftCol]))
2086 2086 );
2087 2087 } else {
2088 2088 // composite foreign key
@@ -2094,8 +2094,8 @@ public function addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder
2094 2094 " array(%s, %s),
2095 2095 ",
2096 2096 $this->getColumnConstant($table->getColumn($columnName)),
2097   - $joinedTablePeerBuilder->getColumnConstant($joinTable->getColumn( $lfMap[$columnName])
2098   - ));
  2097 + $joinedTablePeerBuilder->getColumnConstant($joinTable->getColumn($lfMap[$columnName]))
  2098 + );
2099 2099 }
2100 2100 $script .= " ), \$joinBehavior);
2101 2101 ";
@@ -2423,7 +2423,7 @@ public static function doSelectJoinAll(Criteria \$criteria, \$con = null, \$join
2423 2423 ";
2424 2424
2425 2425 $index = 1;
2426   - foreach ($table->getForeignKeys() as $fk ) {
  2426 + foreach ($table->getForeignKeys() as $fk) {
2427 2427 // want to cover this case, but the code is not there yet.
2428 2428 // Why not? -because we'd have to alias the tables in the JOIN
2429 2429 if ($fk->getForeignTableName() != $table->getName()) {
21 src/Propel/Generator/Config/ArrayToPhpConverter.php
@@ -25,18 +25,20 @@ class ArrayToPhpConverter
25 25 */
26 26 public static function convert($c)
27 27 {
28   - $conf = "\$serviceContainer = \Propel\Runtime\Propel::getServiceContainer();";
29   - // set datasources
30   - if (isset($c['datasources'])) {
  28 + $conf = "\$serviceContainer = \Propel\Runtime\Propel::getServiceContainer();";
  29 + // set datasources
  30 + if (isset($c['datasources'])) {
31 31 foreach ($c['datasources'] as $name => $params) {
32 32 if (!is_array($params)) {
33 33 continue;
34 34 }
  35 +
35 36 // set adapters
36 37 if (isset($params['adapter'])) {
37 38 $conf .= "
38 39 \$serviceContainer->setAdapterClass('{$name}', '{$params['adapter']}');";
39 40 }
  41 +
40 42 // set connection settings
41 43 if (isset($params['slaves'])) {
42 44 $conf .= "
@@ -48,15 +50,18 @@ public static function convert($c)
48 50 } else {
49 51 continue;
50 52 }
  53 +
51 54 if (isset($params['connection'])) {
52 55 $masterConfigurationSetter = isset($params['slaves']) ? 'setWriteConfiguration' : 'setConfiguration';
53 56 $conf .= "
54 57 \$manager->{$masterConfigurationSetter}(". var_export($params['connection'], true) . ");";
55 58 }
  59 +
56 60 $conf .= "
57 61 \$manager->setName('{$name}');
58 62 \$serviceContainer->setConnectionManager('{$name}', \$manager);";
59 63 }
  64 +
60 65 // set default datasource
61 66 if (isset($c['datasources']['default'])) {
62 67 $defaultDatasource = $c['datasources']['default'];
@@ -65,9 +70,11 @@ public static function convert($c)
65 70 $datasourceNames = array_keys($c['datasources']);
66 71 $defaultDatasource = $datasourceNames[0];
67 72 }
  73 +
68 74 $conf .= "
69 75 \$serviceContainer->setDefaultDatasource('{$defaultDatasource}');";
70 76 }
  77 +
71 78 // set profiler
72 79 if (isset($c['profiler'])) {
73 80 $profilerConf = $c['profiler'];
@@ -82,14 +89,15 @@ public static function convert($c)
82 89 }
83 90 unset($c['profiler']);
84 91 }
  92 +
85 93 // set logger
86 94 if (isset($c['log']) && isset($c['log']['logger'])) {
87 95 $loggerConfiguration = $c['log']['logger'];
88 96 // is it a single logger or a list of loggers?
89 97 if (isset($loggerConfiguration[0])) {
90   - foreach ($loggerConfiguration as $singleLoggerConfiguration) {
91   - $conf .= self::getLoggerCode($singleLoggerConfiguration);
92   - }
  98 + foreach ($loggerConfiguration as $singleLoggerConfiguration) {
  99 + $conf .= self::getLoggerCode($singleLoggerConfiguration);
  100 + }
93 101 } else {
94 102 $conf .= self::getLoggerCode($loggerConfiguration);
95 103 }
@@ -110,5 +118,4 @@ protected static function getLoggerCode($conf)
110 118 return "
111 119 \$serviceContainer->setLoggerConfiguration('{$name}', " . var_export($conf, true) . ");";
112 120 }
113   -
114 121 }
4 src/Propel/Generator/Config/XmlToArrayConverter.php
@@ -59,7 +59,7 @@ protected static function simpleXmlToArray($xml)
59 59 $ar = array();
60 60 foreach ($xml->children() as $k => $v) {
61 61 // recurse the child
62   - $child = self::simpleXmlToArray( $v );
  62 + $child = self::simpleXmlToArray($v);
63 63
64 64 // if it's not an array, then it was empty, thus a value/string
65 65 if (count($child) == 0) {
@@ -80,7 +80,7 @@ protected static function simpleXmlToArray($xml)
80 80
81 81 // if the $k is already in our children list, we need to transform
82 82 // it into an array, else we add it as a value
83   - if (!in_array( $k, array_keys($ar))) {
  83 + if (!in_array($k, array_keys($ar))) {
84 84 $ar[$k] = $child;
85 85 } else {
86 86 // (This only applies to nested nodes that do not have an @id attribute)
11 src/Propel/Generator/Model/Column.php
@@ -1047,13 +1047,14 @@ public function isTemporalType()
1047 1047 }
1048 1048
1049 1049 /**
1050   - * Utility method to know whether column is an array column.
  1050 + * Returns whether or not the column is an array column.
  1051 + *
1051 1052 * @return boolean
1052 1053 */
1053   - public function isPhpArrayType()
1054   - {
1055   - return PropelTypes::isPhpArrayType($this->getType());
1056   - }
  1054 + public function isPhpArrayType()
  1055 + {
  1056 + return PropelTypes::isPhpArrayType($this->getType());
  1057 + }
1057 1058
1058 1059 /**
1059 1060 * Returns whether or not this column is an ENUM column.
2  src/Propel/Generator/Model/Diff/TableDiff.php
@@ -439,7 +439,7 @@ public function getRemovedIndices()
439 439 *
440 440 * @param $modifiedIndices
441 441 */
442   - public function setModifiedIndices( $modifiedIndices)
  442 + public function setModifiedIndices($modifiedIndices)
443 443 {
444 444 $this->modifiedIndices = $modifiedIndices;
445 445 }
2  src/Propel/Generator/Model/Inheritance.php
@@ -60,7 +60,7 @@ public function getColumn()
60 60 *
61 61 * @param Column $column
62 62 */
63   - public function setColumn(Column $column)
  63 + public function setColumn(Column $column)
64 64 {
65 65 $this->column = $column;
66 66 }
4 src/Propel/Generator/Platform/DefaultPlatform.php
@@ -558,7 +558,7 @@ public function getIndexDDL(Index $index)
558 558 */
559 559 public function getUniqueDDL(Unique $unique)
560 560 {
561   - return sprintf('UNIQUE (%s)' , $this->getColumnListDDL($unique->getColumns()));
  561 + return sprintf('UNIQUE (%s)', $this->getColumnListDDL($unique->getColumns()));
562 562 }
563 563
564 564 /**
@@ -1240,7 +1240,7 @@ public function getColumnBindingPHP($column, $identifier, $columnValueAccessor,
1240 1240 "
1241 1241 \$stmt->bindValue(%s, %s, %s);",
1242 1242 $identifier,
1243   - $columnValueAccessor ,
  1243 + $columnValueAccessor,
1244 1244 PropelTypes::getPdoTypeString($column->getType())
1245 1245 );
1246 1246
6 src/Propel/Generator/Platform/MysqlPlatform.php
@@ -249,12 +249,12 @@ protected function getTableOptions(Table $table)
249 249 );
250 250
251 251 foreach ($supportedOptions as $name => $sqlName) {
252   - $parameterValue = NULL;
  252 + $parameterValue = null;
253 253
254 254 if ($vi->hasParameter($name)) {
255   - $parameterValue = $vi->getParameter( $name );
  255 + $parameterValue = $vi->getParameter($name);
256 256 } elseif ($vi->hasParameter($sqlName)) {
257   - $parameterValue = $vi->getParameter( $sqlName );
  257 + $parameterValue = $vi->getParameter($sqlName);
258 258 }
259 259
260 260 // if we have a param value, then parse it out
10 src/Propel/Generator/Reverse/MysqlSchemaParser.php
@@ -263,15 +263,15 @@ protected function addForeignKeys(Table $table)
263 263 $foreignKeys = array(); // local store to avoid duplicates
264 264
265 265 // Get the information on all the foreign keys
266   - $regEx = '/CONSTRAINT `([^`]+)` FOREIGN KEY \((.+)\) REFERENCES `([^`]*)` \((.+)\)(.*)/';
267   - if (preg_match_all($regEx,$row[1],$matches)) {
  266 + $pattern = '/CONSTRAINT `([^`]+)` FOREIGN KEY \((.+)\) REFERENCES `([^`]*)` \((.+)\)(.*)/';
  267 + if (preg_match_all($pattern, $row[1], $matches)) {
268 268 $tmpArray = array_keys($matches[0]);
269 269 foreach ($tmpArray as $curKey) {
270   - $name = $matches[1][$curKey];
  270 + $name = $matches[1][$curKey];
271 271 $rawlcol = $matches[2][$curKey];
272   - $ftbl = $matches[3][$curKey];
  272 + $ftbl = $matches[3][$curKey];
273 273 $rawfcol = $matches[4][$curKey];
274   - $fkey = $matches[5][$curKey];
  274 + $fkey = $matches[5][$curKey];
275 275
276 276 $lcols = array();
277 277 foreach (preg_split('/`, `/', $rawlcol) as $piece) {
72 src/Propel/Generator/Reverse/PgsqlSchemaParser.php
@@ -225,8 +225,8 @@ protected function addColumns(Table $table, $oid, $version)
225 225 // if column has a default
226 226 if ('t' === $boolHasDefault && (strlen(trim($default)) > 0)) {
227 227 if (!preg_match('/^nextval\(/', $default)) {
228   - $strDefault= preg_replace ('/::[\W\D]*/', '', $default);
229   - $default = str_replace ("'", '', $strDefault);
  228 + $strDefault= preg_replace('/::[\W\D]*/', '', $default);
  229 + $default = str_replace("'", '', $strDefault);
230 230 } else {
231 231 $autoincrement = true;
232 232 $default = null;
@@ -385,43 +385,43 @@ protected function addForeignKeys(Table $table, $oid, $version)
385 385
386 386 // On Update
387 387 switch ($row['confupdtype']) {
388   - case 'c':
389   - $onupdate = ForeignKey::CASCADE;
390   - break;
391   - case 'd':
392   - $onupdate = ForeignKey::SETDEFAULT;
393   - break;
394   - case 'n':
395   - $onupdate = ForeignKey::SETNULL;
396   - break;
397   - case 'r':
398   - $onupdate = ForeignKey::RESTRICT;
399   - break;
400   - default:
401   - case 'a':
402   - //NOACTION is the postgresql default
403   - $onupdate = ForeignKey::NONE;
404   - break;
  388 + case 'c':
  389 + $onupdate = ForeignKey::CASCADE;
  390 + break;
  391 + case 'd':
  392 + $onupdate = ForeignKey::SETDEFAULT;
  393 + break;
  394 + case 'n':
  395 + $onupdate = ForeignKey::SETNULL;
  396 + break;
  397 + case 'r':
  398 + $onupdate = ForeignKey::RESTRICT;
  399 + break;
  400 + default:
  401 + case 'a':
  402 + // NOACTION is the postgresql default
  403 + $onupdate = ForeignKey::NONE;
  404 + break;
405 405 }
406 406 // On Delete
407 407 switch ($row['confdeltype']) {
408   - case 'c':
409   - $ondelete = ForeignKey::CASCADE;
410   - break;
411   - case 'd':
412   - $ondelete = ForeignKey::SETDEFAULT;
413   - break;
414   - case 'n':
415   - $ondelete = ForeignKey::SETNULL;
416   - break;
417   - case 'r':
418   - $ondelete = ForeignKey::RESTRICT;
419   - break;
420   - default:
421   - case 'a':
422   - //NOACTION is the postgresql default
423   - $ondelete = ForeignKey::NONE;
424   - break;
  408 + case 'c':
  409 + $ondelete = ForeignKey::CASCADE;
  410 + break;
  411 + case 'd':
  412 + $ondelete = ForeignKey::SETDEFAULT;
  413 + break;
  414 + case 'n':
  415 + $ondelete = ForeignKey::SETNULL;
  416 + break;
  417 + case 'r':
  418 + $ondelete = ForeignKey::RESTRICT;
  419 + break;
  420 + default:
  421 + case 'a':
  422 + //NOACTION is the postgresql default
  423 + $ondelete = ForeignKey::NONE;
  424 + break;
425 425 }
426 426
427 427 $foreignTable = $database->getTable($foreignTable);
4 src/Propel/Runtime/ActiveQuery/Criteria.php
@@ -549,7 +549,7 @@ public function getNewCriterion($column, $value = null, $comparison = self::EQUA
549 549 case Criteria::CUSTOM:
550 550 // custom expression with no parameter binding
551 551 // something like $c->add(BookPeer::TITLE, "CONCAT(book.TITLE, 'bar') = 'foobar'", Criteria::CUSTOM);
552   - return new CustomCriterion($this, $column, $value);
  552 + return new CustomCriterion($this, $value);
553 553 case Criteria::IN:
554 554 case Criteria::NOT_IN:
555 555 // table.column IN (?, ?) or table.column NOT IN (?, ?)
@@ -601,7 +601,7 @@ public function getTablesColumns()
601 601 {
602 602 $tables = array();
603 603 foreach ($this->keys() as $key) {
604   - $tableName = substr($key, 0, strrpos($key, '.' ));
  604 + $tableName = substr($key, 0, strrpos($key, '.'));
605 605 $tables[$tableName][] = $key;
606 606 }
607 607
10 src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php
@@ -10,8 +10,6 @@
10 10
11 11 namespace Propel\Runtime\ActiveQuery\Criterion;
12 12
13   -use \Exception;
14   -
15 13 use Propel\Runtime\Propel;
16 14 use Propel\Runtime\ActiveQuery\Criteria;
17 15 use Propel\Runtime\Exception\PropelException;
@@ -101,7 +99,7 @@ public function init(Criteria $criteria)
101 99 try {
102 100 $db = Propel::getServiceContainer()->getAdapter($criteria->getDbName());
103 101 $this->setAdapter($db);
104   - } catch (Exception $e) {
  102 + } catch (\Exception $e) {
105 103 // we are only doing this to allow easier debugging, so
106 104 // no need to throw up the exception, just make note of it.
107 105 Propel::log("Could not get a AdapterInterface, sql may be wrong", Propel::LOG_ERR);
@@ -121,14 +119,14 @@ protected function setColumn($column)
121 119 $this->column = $column->getName();
122 120 $this->table = $column->getTable()->getName();
123 121 } else {
124   - $dotPos = strrpos($column,'.');
  122 + $dotPos = strrpos($column, '.');
125 123 if ($dotPos === false) {
126 124 // no dot => aliased column
127 125 $this->table = null;
128 126 $this->column = $column;
129 127 } else {
130 128 $this->table = substr($column, 0, $dotPos);
131   - $this->column = substr($column, $dotPos+1, strlen($column));
  129 + $this->column = substr($column, $dotPos + 1, strlen($column));
132 130 }
133 131 }
134 132 }
@@ -268,7 +266,7 @@ public function appendPsTo(&$sb, array &$params)
268 266 return $this->appendPsForUniqueClauseTo($sb, $params);
269 267 }
270 268 // if there are sub criterions, they must be combined to this criterion
271   - $sb .= str_repeat ( '(', count($this->clauses) );
  269 + $sb .= str_repeat('(', count($this->clauses));
272 270 $this->appendPsForUniqueClauseTo($sb, $params);
273 271 foreach ($this->clauses as $key => $clause) {
274 272 $sb .= $this->conjunctions[$key];
3  src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php
@@ -17,7 +17,6 @@
17 17 */
18 18 class CustomCriterion extends AbstractCriterion
19 19 {
20   -
21 20 /**
22 21 * Create a new instance.
23 22 *
@@ -25,7 +24,7 @@ class CustomCriterion extends AbstractCriterion
25 24 * @param string $column ignored
26 25 * @param string $value The condition to be added to the query string
27 26 */
28   - public function __construct(Criteria $outer, $column = null, $value)
  27 + public function __construct(Criteria $outer, $value)
29 28 {
30 29 $this->value = $value;
31 30 $this->init($outer);
63 src/Propel/Runtime/ActiveQuery/ModelCriteria.php
@@ -404,14 +404,14 @@ public function orderBy($columnName, $order = Criteria::ASC)
404 404 list(, $realColumnName) = $this->getColumnFromName($columnName, false);
405 405 $order = strtoupper($order);
406 406 switch ($order) {
407   - case Criteria::ASC:
408   - $this->addAscendingOrderByColumn($realColumnName);
409   - break;
410   - case Criteria::DESC:
411   - $this->addDescendingOrderByColumn($realColumnName);
412   - break;
413   - default:
414   - throw new UnexpectedValueException('ModelCriteria::orderBy() only accepts Criteria::ASC or Criteria::DESC as argument');
  407 + case Criteria::ASC:
  408 + $this->addAscendingOrderByColumn($realColumnName);
  409 + break;
  410 + case Criteria::DESC:
  411 + $this->addDescendingOrderByColumn($realColumnName);
  412 + break;
  413 + default:
  414 + throw new UnexpectedValueException('ModelCriteria::orderBy() only accepts Criteria::ASC or Criteria::DESC as argument');
415 415 }
416 416
417 417 return $this;
@@ -1878,7 +1878,7 @@ protected function getCriterionForClause($clause, $value, $bindingType = null)
1878 1878 return new RawCriterion($this, $clause, $value, $bindingType);
1879 1879 }
1880 1880
1881   - return new CustomCriterion($this, null, $clause);
  1881 + return new CustomCriterion($this, $clause);
1882 1882 }
1883 1883
1884 1884 /**
@@ -1936,22 +1936,22 @@ protected function replaceNames(&$clause)
1936 1936 $char = $clause[$pos];
1937 1937 // check flags for strings or escaper
1938 1938 switch ($char) {
1939   - case '\\':
1940   - $isAfterBackslash = true;
1941   - break;
1942   - case "'":
1943   - case '"':
1944   - if ($isInString && $stringQuotes == $char) {
1945   - if (!$isAfterBackslash) {
1946   - $isInString = false;
  1939 + case '\\':
  1940 + $isAfterBackslash = true;
  1941 + break;
  1942 + case "'":
  1943 + case '"':
  1944 + if ($isInString && $stringQuotes == $char) {
  1945 + if (!$isAfterBackslash) {
  1946 + $isInString = false;
  1947 + }
  1948 + } elseif (!$isInString) {
  1949 + $parsedString .= preg_replace_callback("/[\w\\\]+\.\w+/", array($this, 'doReplaceNameInExpression'), $stringToTransform);
  1950 + $stringToTransform = '';
  1951 + $stringQuotes = $char;
  1952 + $isInString = true;
1947 1953 }
1948   - } elseif (!$isInString) {
1949   - $parsedString .= preg_replace_callback("/[\w\\\]+\.\w+/", array($this, 'doReplaceNameInExpression'), $stringToTransform);
1950   - $stringToTransform = '';
1951   - $stringQuotes = $char;
1952   - $isInString = true;
1953   - }
1954   - break;
  1954 + break;
1955 1955 }
1956 1956
1957 1957 if ('\\' !== $char) {
@@ -2060,8 +2060,8 @@ protected function getColumnFromName($phpName, $failSilently = true)
2060 2060 }
2061 2061
2062 2062 return array($column, $realColumnName);
2063   - } elseif ($tableMap->hasColumn($phpName,false)) {
2064   - $column = $tableMap->getColumn($phpName,false);
  2063 + } elseif ($tableMap->hasColumn($phpName, false)) {
  2064 + $column = $tableMap->getColumn($phpName, false);
2065 2065 $realColumnName = $column->getFullyQualifiedName();
2066 2066
2067 2067 return array($column, $realColumnName);
@@ -2196,11 +2196,12 @@ public function getParams()
2196 2196 $table = $tableName;
2197 2197 }
2198 2198
2199   - if (($this->isIgnoreCase()
2200   - || $attachedCriterion->isIgnoreCase())
2201   - && $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText()) {
2202   - $attachedCriterion->setIgnoreCase(true);
2203   - }
  2199 + if (
  2200 + ($this->isIgnoreCase() || $attachedCriterion->isIgnoreCase())
  2201 + && $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText()
  2202 + ) {
  2203 + $attachedCriterion->setIgnoreCase(true);
  2204 + }
2204 2205 }
2205 2206
2206 2207 $sb = '';
2  src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php
@@ -152,7 +152,7 @@ public function getId(ConnectionInterface $con, $name = null)
152 152 * @param string $seed
153 153 * @return string
154 154 */
155   - public function random($seed=NULL)
  155 + public function random($seed = null)
156 156 {
157 157 return 'dbms_random.value';
158 158 }
2  src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php
@@ -136,7 +136,7 @@ public function applyLimit(&$sql, $offset, $limit)
136 136 * @param string $seed
137 137 * @return string
138 138 */
139   - public function random($seed=NULL)
  139 + public function random($seed = null)
140 140 {
141 141 return 'random()';
142 142 }
2  tests/Propel/Tests/Runtime/ActiveQuery/Criterion/CustomCriterionTest.php
@@ -24,7 +24,7 @@ class CustomCriterionTest extends BaseTestCase
24 24 {
25 25 public function testAppendPsToConcatenatesTheValue()
26 26 {
27   - $cton = new CustomCriterion(new Criteria(), 'A.COL', 'date_part(\'YYYY\', A.COL) = \'2007\'');
  27 + $cton = new CustomCriterion(new Criteria(), 'date_part(\'YYYY\', A.COL) = \'2007\'');
28 28
29 29 $params = array();
30 30 $ps = '';

0 comments on commit 99e125e

Please sign in to comment.
Something went wrong with that request. Please try again.