Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed various PSR-2 violations thanks to Sonar Source. #299

Merged
merged 1 commit into from

5 participants

@hhamon
Collaborator

No description provided.

@travisbot

This pull request passes (merged 6d87ad2 into f86db9e).

@staabm
Collaborator

@hhamon how did you get sonar to validate against psr-2?

@hhamon
Collaborator

The new version of PHP_CodeSniffer now embeds a PSR1 and PSR2 ruleset file.

Look at the repository: https://github.com/squizlabs/PHP_CodeSniffer

@willdurand willdurand commented on the diff
...Runtime/ActiveQuery/Criterion/CustomCriterionTest.php
@@ -24,7 +24,7 @@ class CustomCriterionTest extends BaseTestCase
{
public function testAppendPsToConcatenatesTheValue()
{
- $cton = new CustomCriterion(new Criteria(), 'A.COL', 'date_part(\'YYYY\', A.COL) = \'2007\'');
+ $cton = new CustomCriterion(new Criteria(), 'date_part(\'YYYY\', A.COL) = \'2007\'');
@willdurand Owner

whaaaa?

@hhamon Collaborator
hhamon added a note

I removed this second argument from the constructor as it's not used in the constructor anywhere. The constructor signature changed and I have affected the code change everywhere ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@willdurand willdurand merged commit 99e125e into from
@willdurand
Owner

Great! Thank you Hugo.

@hhamon
Collaborator

Welcome ;)

@staabm
Collaborator

Thanks!

@simon77

@staabm I have written a blog that has the instructions for getting sonar to work with the PSR-1 and PSR-2 standards from codesniffer. http://gomadtech.wordpress.com/2012/12/21/sonar-psr-profiles/ Hope that helps.

@staabm
Collaborator

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 23, 2012
  1. @hhamon
This page is out of date. Refresh to see the latest.
Showing with 171 additions and 149 deletions.
  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
View
2  src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php
@@ -24,7 +24,7 @@ class ArchivableBehavior extends Behavior
// default parameters value
protected $parameters = array(
'archive_table' => '',
- 'archive_phpname' => NULL,
+ 'archive_phpname' => null,
'archive_class' => '',
'log_archived_at' => 'true',
'archived_at_column' => 'archived_at',
View
47 src/Propel/Generator/Behavior/Validate/ValidateBehavior.php
@@ -41,10 +41,14 @@ public function objectMethods($builder)
$this->cleanupParameters();
$this->builder = $builder;
-
- $this->builder->declareClasses('Symfony\\Component\\Validator\\Mapping\\ClassMetadata', 'Symfony\\Component\\Validator\\Validator',
-'Symfony\\Component\\Validator\\Mapping\\Loader\\StaticMethodLoader', 'Symfony\\Component\\Validator\\ConstraintValidatorFactory',
-'Symfony\\Component\\Validator\\Mapping\\ClassMetadataFactory', 'Symfony\\Component\\Validator\\ConstraintViolationList');
+ $this->builder->declareClasses(
+ 'Symfony\\Component\\Validator\\Mapping\\ClassMetadata',
+ 'Symfony\\Component\\Validator\\Validator',
+ 'Symfony\\Component\\Validator\\Mapping\\Loader\\StaticMethodLoader',
+ 'Symfony\\Component\\Validator\\ConstraintValidatorFactory',
+ 'Symfony\\Component\\Validator\\Mapping\\ClassMetadataFactory',
+ 'Symfony\\Component\\Validator\\ConstraintViolationList'
+ );
$script = $this->addLoadValidatorMetadataMethod();
$script .= $this->addValidateMethod();
@@ -77,7 +81,7 @@ public function getParametersFromColumnName($columnName = null)
$this->cleanupParameters();
foreach ($this->getParameters() as $key => $parameter) {
if ($parameter['column'] === $columnName) {
- $array[$key] = $parameter;
+ $array[$key] = $parameter;
}
}
}
@@ -114,13 +118,16 @@ public function removeParametersFromColumnName($columnName = null)
*/
public function addRuleOnPk()
{
- if (count($this->getParameters()) <= 0) {
- $pk = $this->getTable()->getPrimaryKey();
- $rule['auto_rule']['column'] = $pk[0]->getName();
- $rule['auto_rule']['validator'] = 'Type';
- $rule['auto_rule']['options'] = array('type' => $pk[0]->getPhpType());
-
- $this->setParameters($rule);
+ if (!count($this->getParameters())) {
+ $pk = $this->getTable()->getPrimaryKey();
+ $parameters = array('auto_rule' => array(
+ 'column' => $pk[0]->getName(),
+ 'validators' => 'Type',
+ 'options' => array(
+ 'type' => $pk[0]->getPhpType(),
+ ),
+ ));
+ $this->setParameters($parameters);
}
}
@@ -154,14 +161,14 @@ public function mergeParameters(array $params = null)
*/
protected function cleanupParameters()
{
- $parser = new Parser();
- $params = $this->getParameters();
- foreach ($params as $key => $value) {
- if (is_string($value)) {
- $params[$key] = $parser->parse($value);
- }
- }
- $this->setParameters($params);
+ $parser = new Parser();
+ $params = $this->getParameters();
+ foreach ($params as $key => $value) {
+ if (is_string($value)) {
+ $params[$key] = $parser->parse($value);
+ }
+ }
+ $this->setParameters($params);
}
/**
View
29 src/Propel/Generator/Builder/Om/AbstractOMBuilder.php
@@ -302,10 +302,11 @@ public function declareClassNamespace($class, $namespace = '', $alias = false)
return $this->declareClassNamespace($class, $namespace, 'Child' . $class);
}
- throw new LogicException(
- sprintf('The class %s duplicates the class %s and can\'t be used without alias',
- $namespace . '\\' . $class, $this->declaredShortClassesOrAlias[$aliasWanted])
- );
+ throw new LogicException(sprintf(
+ 'The class %s duplicates the class %s and can\'t be used without alias',
+ $namespace . '\\' . $class,
+ $this->declaredShortClassesOrAlias[$aliasWanted]
+ ));
}
/**
@@ -324,18 +325,23 @@ protected function needAliasForClassName($class, $namespace)
}
if (empty($namespace) && 'Base' === $this->getNamespace()) {
- if (str_replace(array('Peer','Query'), '', $class) == str_replace(array('Peer','Query'), '', $this->getUnqualifiedClassName())) {
+ if (str_replace(array('Peer', 'Query'), '', $class) == str_replace(array('Peer', 'Query'), '', $this->getUnqualifiedClassName())) {
return true;
- } elseif ((false !== strpos($class,'Peer') || false !== strpos($class,'Query'))) {
+ }
+
+ if ((false !== strpos($class, 'Peer') || false !== strpos($class, 'Query'))) {
return true;
- } elseif (false === array_search($class, $this->whiteListOfDeclaredClasses, true)) { //force alias for model without namespace
+ }
+ // force alias for model without namespace
+ if (false === array_search($class, $this->whiteListOfDeclaredClasses, true)) {
return true;
}
}
- if ('Base' == $namespace && '' == $this->getNamespace()) {
- if (false === array_search($class, $this->whiteListOfDeclaredClasses, true)) { //force alias for model without namespace
+ if ('Base' === $namespace && '' === $this->getNamespace()) {
+ // force alias for model without namespace
+ if (false === array_search($class, $this->whiteListOfDeclaredClasses, true)) {
return true;
}
@@ -768,10 +774,7 @@ public function renderTemplate($filename, $vars = array(), $templateDir = '/temp
// try with '.php' at the end
$filePath = $filePath . '.php';
if (!file_exists($filePath)) {
- throw new \InvalidArgumentException(sprintf('Template "%s" not found in "%s" directory',
- $filename,
- __DIR__ . $templateDir
- ));
+ throw new \InvalidArgumentException(sprintf('Template "%s" not found in "%s" directory', $filename, __DIR__ . $templateDir));
}
}
$template = new PropelTemplate();
View
16 src/Propel/Generator/Builder/Om/ObjectBuilder.php
@@ -236,7 +236,7 @@ protected function addClassOpen(&$script)
if ($interface = $this->getInterface()) {
$script .= ", Child" . ClassTools::classname($interface);
if ($interface !== ClassTools::classname($interface)) {
- $this->declareClass($interface);
+ $this->declareClass($interface);
} else {
$this->declareClassFromBuilder($this->getInterfaceBuilder());
}
@@ -894,7 +894,10 @@ public function addTemporalAccessorOpen(&$script, Column $column)
} elseif ($column->getType() === PropelTypes::TIMESTAMP) {
$defaultfmt = $this->getBuildProperty('defaultTimeStampFormat');
}
- if (empty($defaultfmt)) { $defaultfmt = null; }
+
+ if (empty($defaultfmt)) {
+ $defaultfmt = null;
+ }
$script .= "
".$visibility." function get$cfc(\$format = ".var_export($defaultfmt, true)."";
@@ -953,7 +956,10 @@ protected function addTemporalAccessorBody(&$script, Column $column)
} elseif ($column->getType() === PropelTypes::TIMESTAMP) {
$defaultfmt = $this->getBuildProperty('defaultTimeStampFormat');
}
- if (empty($defaultfmt)) { $defaultfmt = null; }
+
+ if (empty($defaultfmt)) {
+ $defaultfmt = null;
+ }
if ($column->isLazyLoad()) {
$script .= $this->getAccessorLazyLoadSnippet($column);
@@ -3300,7 +3306,7 @@ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK)
$peerClassName = $this->getClassNameFromBuilder($this->getStubPeerBuilder());
$fkQueryClassName = $this->getClassNameFromBuilder($this->getNewStubQueryBuilder($refFK->getTable()));
- $relCol = $this->getRefFKPhpNameAffix($refFK, $plural=true);
+ $relCol = $this->getRefFKPhpNameAffix($refFK, $plural = true);
$collName = $this->getRefFKCollVarName($refFK);
$fkPeerBuilder = $this->getNewPeerBuilder($tblFK);
@@ -4324,7 +4330,7 @@ protected function doInsert(ConnectionInterface \$con)
if ($this->getPlatform() instanceof MssqlPlatform) {
if ($table->hasAutoIncrementPrimaryKey() ) {
$script .= "
- \$this->modifiedColumns[] = " . $this->getColumnConstant($table->getAutoIncrementPrimaryKey() ) . ";";
+ \$this->modifiedColumns[] = " . $this->getColumnConstant($table->getAutoIncrementPrimaryKey()).';';
}
$script .= "
\$criteria = \$this->buildCriteria();";
View
8 src/Propel/Generator/Builder/Om/PeerBuilder.php
@@ -2082,7 +2082,7 @@ public function addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder
\$criteria->addJoin(%s, %s, \$joinBehavior);
",
$this->getColumnConstant($table->getColumn($lftCol)),
- $joinedTablePeerBuilder->getColumnConstant($joinTable->getColumn($lfMap[$lftCol] ))
+ $joinedTablePeerBuilder->getColumnConstant($joinTable->getColumn($lfMap[$lftCol]))
);
} else {
// composite foreign key
@@ -2094,8 +2094,8 @@ public function addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder
" array(%s, %s),
",
$this->getColumnConstant($table->getColumn($columnName)),
- $joinedTablePeerBuilder->getColumnConstant($joinTable->getColumn( $lfMap[$columnName])
- ));
+ $joinedTablePeerBuilder->getColumnConstant($joinTable->getColumn($lfMap[$columnName]))
+ );
}
$script .= " ), \$joinBehavior);
";
@@ -2423,7 +2423,7 @@ public static function doSelectJoinAll(Criteria \$criteria, \$con = null, \$join
";
$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()) {
View
21 src/Propel/Generator/Config/ArrayToPhpConverter.php
@@ -25,18 +25,20 @@ class ArrayToPhpConverter
*/
public static function convert($c)
{
- $conf = "\$serviceContainer = \Propel\Runtime\Propel::getServiceContainer();";
- // set datasources
- if (isset($c['datasources'])) {
+ $conf = "\$serviceContainer = \Propel\Runtime\Propel::getServiceContainer();";
+ // set datasources
+ if (isset($c['datasources'])) {
foreach ($c['datasources'] as $name => $params) {
if (!is_array($params)) {
continue;
}
+
// set adapters
if (isset($params['adapter'])) {
$conf .= "
\$serviceContainer->setAdapterClass('{$name}', '{$params['adapter']}');";
}
+
// set connection settings
if (isset($params['slaves'])) {
$conf .= "
@@ -48,15 +50,18 @@ public static function convert($c)
} else {
continue;
}
+
if (isset($params['connection'])) {
$masterConfigurationSetter = isset($params['slaves']) ? 'setWriteConfiguration' : 'setConfiguration';
$conf .= "
\$manager->{$masterConfigurationSetter}(". var_export($params['connection'], true) . ");";
}
+
$conf .= "
\$manager->setName('{$name}');
\$serviceContainer->setConnectionManager('{$name}', \$manager);";
}
+
// set default datasource
if (isset($c['datasources']['default'])) {
$defaultDatasource = $c['datasources']['default'];
@@ -65,9 +70,11 @@ public static function convert($c)
$datasourceNames = array_keys($c['datasources']);
$defaultDatasource = $datasourceNames[0];
}
+
$conf .= "
\$serviceContainer->setDefaultDatasource('{$defaultDatasource}');";
}
+
// set profiler
if (isset($c['profiler'])) {
$profilerConf = $c['profiler'];
@@ -82,14 +89,15 @@ public static function convert($c)
}
unset($c['profiler']);
}
+
// set logger
if (isset($c['log']) && isset($c['log']['logger'])) {
$loggerConfiguration = $c['log']['logger'];
// is it a single logger or a list of loggers?
if (isset($loggerConfiguration[0])) {
- foreach ($loggerConfiguration as $singleLoggerConfiguration) {
- $conf .= self::getLoggerCode($singleLoggerConfiguration);
- }
+ foreach ($loggerConfiguration as $singleLoggerConfiguration) {
+ $conf .= self::getLoggerCode($singleLoggerConfiguration);
+ }
} else {
$conf .= self::getLoggerCode($loggerConfiguration);
}
@@ -110,5 +118,4 @@ protected static function getLoggerCode($conf)
return "
\$serviceContainer->setLoggerConfiguration('{$name}', " . var_export($conf, true) . ");";
}
-
}
View
4 src/Propel/Generator/Config/XmlToArrayConverter.php
@@ -59,7 +59,7 @@ protected static function simpleXmlToArray($xml)
$ar = array();
foreach ($xml->children() as $k => $v) {
// recurse the child
- $child = self::simpleXmlToArray( $v );
+ $child = self::simpleXmlToArray($v);
// if it's not an array, then it was empty, thus a value/string
if (count($child) == 0) {
@@ -80,7 +80,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)
View
11 src/Propel/Generator/Model/Column.php
@@ -1047,13 +1047,14 @@ public function isTemporalType()
}
/**
- * Utility method to know whether column is an array column.
+ * Returns whether or not the column is an array column.
+ *
* @return boolean
*/
- public function isPhpArrayType()
- {
- return PropelTypes::isPhpArrayType($this->getType());
- }
+ public function isPhpArrayType()
+ {
+ return PropelTypes::isPhpArrayType($this->getType());
+ }
/**
* Returns whether or not this column is an ENUM column.
View
2  src/Propel/Generator/Model/Diff/TableDiff.php
@@ -439,7 +439,7 @@ public function getRemovedIndices()
*
* @param $modifiedIndices
*/
- public function setModifiedIndices( $modifiedIndices)
+ public function setModifiedIndices($modifiedIndices)
{
$this->modifiedIndices = $modifiedIndices;
}
View
2  src/Propel/Generator/Model/Inheritance.php
@@ -60,7 +60,7 @@ public function getColumn()
*
* @param Column $column
*/
- public function setColumn(Column $column)
+ public function setColumn(Column $column)
{
$this->column = $column;
}
View
4 src/Propel/Generator/Platform/DefaultPlatform.php
@@ -558,7 +558,7 @@ public function getIndexDDL(Index $index)
*/
public function getUniqueDDL(Unique $unique)
{
- return sprintf('UNIQUE (%s)' , $this->getColumnListDDL($unique->getColumns()));
+ return sprintf('UNIQUE (%s)', $this->getColumnListDDL($unique->getColumns()));
}
/**
@@ -1240,7 +1240,7 @@ public function getColumnBindingPHP($column, $identifier, $columnValueAccessor,
"
\$stmt->bindValue(%s, %s, %s);",
$identifier,
- $columnValueAccessor ,
+ $columnValueAccessor,
PropelTypes::getPdoTypeString($column->getType())
);
View
6 src/Propel/Generator/Platform/MysqlPlatform.php
@@ -249,12 +249,12 @@ protected function getTableOptions(Table $table)
);
foreach ($supportedOptions as $name => $sqlName) {
- $parameterValue = NULL;
+ $parameterValue = null;
if ($vi->hasParameter($name)) {
- $parameterValue = $vi->getParameter( $name );
+ $parameterValue = $vi->getParameter($name);
} elseif ($vi->hasParameter($sqlName)) {
- $parameterValue = $vi->getParameter( $sqlName );
+ $parameterValue = $vi->getParameter($sqlName);
}
// if we have a param value, then parse it out
View
10 src/Propel/Generator/Reverse/MysqlSchemaParser.php
@@ -263,15 +263,15 @@ protected function addForeignKeys(Table $table)
$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)) {
+ $pattern = '/CONSTRAINT `([^`]+)` FOREIGN KEY \((.+)\) REFERENCES `([^`]*)` \((.+)\)(.*)/';
+ if (preg_match_all($pattern, $row[1], $matches)) {
$tmpArray = array_keys($matches[0]);
foreach ($tmpArray as $curKey) {
- $name = $matches[1][$curKey];
+ $name = $matches[1][$curKey];
$rawlcol = $matches[2][$curKey];
- $ftbl = $matches[3][$curKey];
+ $ftbl = $matches[3][$curKey];
$rawfcol = $matches[4][$curKey];
- $fkey = $matches[5][$curKey];
+ $fkey = $matches[5][$curKey];
$lcols = array();
foreach (preg_split('/`, `/', $rawlcol) as $piece) {
View
72 src/Propel/Generator/Reverse/PgsqlSchemaParser.php
@@ -225,8 +225,8 @@ protected function addColumns(Table $table, $oid, $version)
// if column has a default
if ('t' === $boolHasDefault && (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;
@@ -385,43 +385,43 @@ 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($foreignTable);
View
4 src/Propel/Runtime/ActiveQuery/Criteria.php
@@ -549,7 +549,7 @@ public function getNewCriterion($column, $value = null, $comparison = self::EQUA
case Criteria::CUSTOM:
// custom expression with no parameter binding
// something like $c->add(BookPeer::TITLE, "CONCAT(book.TITLE, 'bar') = 'foobar'", Criteria::CUSTOM);
- return new CustomCriterion($this, $column, $value);
+ return new CustomCriterion($this, $value);
case Criteria::IN:
case Criteria::NOT_IN:
// table.column IN (?, ?) or table.column NOT IN (?, ?)
@@ -601,7 +601,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;
}
View
10 src/Propel/Runtime/ActiveQuery/Criterion/AbstractCriterion.php
@@ -10,8 +10,6 @@
namespace Propel\Runtime\ActiveQuery\Criterion;
-use \Exception;
-
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\Exception\PropelException;
@@ -101,7 +99,7 @@ public function init(Criteria $criteria)
try {
$db = Propel::getServiceContainer()->getAdapter($criteria->getDbName());
$this->setAdapter($db);
- } catch (Exception $e) {
+ } catch (\Exception $e) {
// we are only doing this to allow easier debugging, so
// no need to throw up the exception, just make note of it.
Propel::log("Could not get a AdapterInterface, sql may be wrong", Propel::LOG_ERR);
@@ -121,14 +119,14 @@ protected function setColumn($column)
$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));
}
}
}
@@ -268,7 +266,7 @@ public function appendPsTo(&$sb, array &$params)
return $this->appendPsForUniqueClauseTo($sb, $params);
}
// if there are sub criterions, they must be combined to this criterion
- $sb .= str_repeat ( '(', count($this->clauses) );
+ $sb .= str_repeat('(', count($this->clauses));
$this->appendPsForUniqueClauseTo($sb, $params);
foreach ($this->clauses as $key => $clause) {
$sb .= $this->conjunctions[$key];
View
3  src/Propel/Runtime/ActiveQuery/Criterion/CustomCriterion.php
@@ -17,7 +17,6 @@
*/
class CustomCriterion extends AbstractCriterion
{
-
/**
* Create a new instance.
*
@@ -25,7 +24,7 @@ class CustomCriterion extends AbstractCriterion
* @param string $column ignored
* @param string $value The condition to be added to the query string
*/
- public function __construct(Criteria $outer, $column = null, $value)
+ public function __construct(Criteria $outer, $value)
{
$this->value = $value;
$this->init($outer);
View
63 src/Propel/Runtime/ActiveQuery/ModelCriteria.php
@@ -404,14 +404,14 @@ public function orderBy($columnName, $order = Criteria::ASC)
list(, $realColumnName) = $this->getColumnFromName($columnName, false);
$order = strtoupper($order);
switch ($order) {
- case Criteria::ASC:
- $this->addAscendingOrderByColumn($realColumnName);
- break;
- case Criteria::DESC:
- $this->addDescendingOrderByColumn($realColumnName);
- break;
- default:
- throw new UnexpectedValueException('ModelCriteria::orderBy() only accepts Criteria::ASC or Criteria::DESC as argument');
+ case Criteria::ASC:
+ $this->addAscendingOrderByColumn($realColumnName);
+ break;
+ case Criteria::DESC:
+ $this->addDescendingOrderByColumn($realColumnName);
+ break;
+ default:
+ throw new UnexpectedValueException('ModelCriteria::orderBy() only accepts Criteria::ASC or Criteria::DESC as argument');
}
return $this;
@@ -1878,7 +1878,7 @@ protected function getCriterionForClause($clause, $value, $bindingType = null)
return new RawCriterion($this, $clause, $value, $bindingType);
}
- return new CustomCriterion($this, null, $clause);
+ return new CustomCriterion($this, $clause);
}
/**
@@ -1936,22 +1936,22 @@ protected function replaceNames(&$clause)
$char = $clause[$pos];
// check flags for strings or escaper
switch ($char) {
- case '\\':
- $isAfterBackslash = true;
- break;
- case "'":
- case '"':
- if ($isInString && $stringQuotes == $char) {
- if (!$isAfterBackslash) {
- $isInString = false;
+ case '\\':
+ $isAfterBackslash = true;
+ break;
+ case "'":
+ case '"':
+ if ($isInString && $stringQuotes == $char) {
+ if (!$isAfterBackslash) {
+ $isInString = false;
+ }
+ } elseif (!$isInString) {
+ $parsedString .= preg_replace_callback("/[\w\\\]+\.\w+/", array($this, 'doReplaceNameInExpression'), $stringToTransform);
+ $stringToTransform = '';
+ $stringQuotes = $char;
+ $isInString = true;
}
- } elseif (!$isInString) {
- $parsedString .= preg_replace_callback("/[\w\\\]+\.\w+/", array($this, 'doReplaceNameInExpression'), $stringToTransform);
- $stringToTransform = '';
- $stringQuotes = $char;
- $isInString = true;
- }
- break;
+ break;
}
if ('\\' !== $char) {
@@ -2060,8 +2060,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);
@@ -2196,11 +2196,12 @@ public function getParams()
$table = $tableName;
}
- if (($this->isIgnoreCase()
- || $attachedCriterion->isIgnoreCase())
- && $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText()) {
- $attachedCriterion->setIgnoreCase(true);
- }
+ if (
+ ($this->isIgnoreCase() || $attachedCriterion->isIgnoreCase())
+ && $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText()
+ ) {
+ $attachedCriterion->setIgnoreCase(true);
+ }
}
$sb = '';
View
2  src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php
@@ -152,7 +152,7 @@ public function getId(ConnectionInterface $con, $name = null)
* @param string $seed
* @return string
*/
- public function random($seed=NULL)
+ public function random($seed = null)
{
return 'dbms_random.value';
}
View
2  src/Propel/Runtime/Adapter/Pdo/PgsqlAdapter.php
@@ -136,7 +136,7 @@ public function applyLimit(&$sql, $offset, $limit)
* @param string $seed
* @return string
*/
- public function random($seed=NULL)
+ public function random($seed = null)
{
return 'random()';
}
View
2  tests/Propel/Tests/Runtime/ActiveQuery/Criterion/CustomCriterionTest.php
@@ -24,7 +24,7 @@ class CustomCriterionTest extends BaseTestCase
{
public function testAppendPsToConcatenatesTheValue()
{
- $cton = new CustomCriterion(new Criteria(), 'A.COL', 'date_part(\'YYYY\', A.COL) = \'2007\'');
+ $cton = new CustomCriterion(new Criteria(), 'date_part(\'YYYY\', A.COL) = \'2007\'');
@willdurand Owner

whaaaa?

@hhamon Collaborator
hhamon added a note

I removed this second argument from the constructor as it's not used in the constructor anywhere. The constructor signature changed and I have affected the code change everywhere ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
$params = array();
$ps = '';
Something went wrong with that request. Please try again.