Skip to content

Commit

Permalink
CS: Unified strict equality comparisons, put var on the right side
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek authored and fabpot committed Dec 21, 2010
1 parent a2105d4 commit 094d428
Show file tree
Hide file tree
Showing 55 changed files with 98 additions and 98 deletions.
Expand Up @@ -72,21 +72,21 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$type = $input->getArgument('mapping-type') ? $input->getArgument('mapping-type') : 'xml';
if ($type === 'annotation') {
if ('annotation' === $type) {
$destPath .= '/Entity';
} else {
$destPath .= '/Resources/config/doctrine/metadata/orm';
}

// adjust so file naming works
if ($type === 'yaml') {
if ('yaml' === $type) {
$type = 'yml';
}

$cme = new ClassMetadataExporter();
$exporter = $cme->getExporter($type);

if ($type === 'annotation') {
if ('annotation' === $type) {
$entityGenerator = $this->getEntityGenerator();
$exporter->setEntityGenerator($entityGenerator);
}
Expand All @@ -99,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
foreach ($metadata as $class) {
$className = $class->name;
$class->name = $namespace.'\\'.$bundleClass.'\\Entity\\'.$className;
if ($type === 'annotation') {
if ('annotation' === $type) {
$path = $destPath.'/'.$className.'.php';
} else {
$path = $destPath.'/'.str_replace('\\', '.', $class->name).'.dcm.'.$type;
Expand Down
Expand Up @@ -58,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->createDatabaseForConnection($connection, $output);
$found = true;
}
if ($found === false) {
if (false === $found) {
if ($input->getOption('connection')) {
throw new \InvalidArgumentException(sprintf('<error>Could not find a connection named <comment>%s</comment></error>', $input->getOption('connection')));
} else {
Expand Down
Expand Up @@ -58,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->dropDatabaseForConnection($connection, $output);
$found = true;
}
if ($found === false) {
if (false === $found) {
if ($input->getOption('connection')) {
throw new \InvalidArgumentException(sprintf('<error>Could not find a connection named <comment>%s</comment></error>', $input->getOption('connection')));
} else {
Expand Down
Expand Up @@ -107,7 +107,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$cme = new ClassMetadataExporter();
$exporter = $cme->getExporter($mappingType);

if ($mappingType === 'annotation') {
if ('annotation' === $mappingType) {
$path = $dirs[$namespace].'/'.$bundle.'/Entity/'.str_replace($entityNamespace.'\\', null, $fullEntityClassName).'.php';

$exporter->setEntityGenerator($this->getEntityGenerator());
Expand Down
Expand Up @@ -70,19 +70,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$type = $input->getArgument('mapping-type') ? $input->getArgument('mapping-type') : 'xml';
if ($type === 'annotation') {
if ('annotation' === $type) {
$destPath .= '/Entity';
} else {
$destPath .= '/Resources/config/doctrine/metadata/orm';
}
if ($type === 'yaml') {
if ('yaml' === $type) {
$type = 'yml';
}

$cme = new ClassMetadataExporter();
$exporter = $cme->getExporter($type);

if ($type === 'annotation') {
if ('annotation' === $type) {
$entityGenerator = $this->getEntityGenerator();
$exporter->setEntityGenerator($entityGenerator);
}
Expand All @@ -100,7 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
foreach ($metadata as $class) {
$className = $class->name;
$class->name = $namespace.'\\'.$bundleClass.'\\Entity\\'.$className;
if ($type === 'annotation') {
if ('annotation' === $type) {
$path = $destPath.'/'.$className.'.php';
} else {
$path = $destPath.'/'.str_replace('\\', '.', $class->name).'.dcm.'.$type;
Expand Down
Expand Up @@ -359,13 +359,13 @@ protected function loadOrmEntityManagerBundlesMappingInformation(array $entityMa
$type = $this->detectMetadataDriver($bundleDirs[$namespace].'/'.$class, $container);

if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Entity')) {
if ($type === null) {
if (null === $type) {
$type = 'annotation';
}
$aliasMap[$class] = $namespace.'\\'.$class.'\\Entity';
}

if ($type !== null) {
if (null !== $type) {
$mappingDriverDef->addMethodCall('addDriver', array(
new Reference(sprintf('doctrine.orm.metadata_driver.%s', $type)),
$namespace.'\\'.$class.'\\Entity'
Expand Down Expand Up @@ -444,7 +444,7 @@ protected function loadOrmEntityManagerResultCacheDriver(array $entityManager, C
protected function getEntityManagerCacheDefinition(array $entityManager, $cacheDriver, ContainerBuilder $container)
{
$type = is_array($cacheDriver) && isset($cacheDriver['type']) ? $cacheDriver['type'] : $cacheDriver;
if ($type === 'memcache') {
if ('memcache' === $type) {
$memcacheClass = isset($cacheDriver['class']) ? $cacheDriver['class'] : '%'.sprintf('doctrine.orm.cache.%s_class', $type).'%';
$cacheDef = new Definition($memcacheClass);
$memcacheHost = is_array($cacheDriver) && isset($cacheDriver['host']) ? $cacheDriver['host'] : '%doctrine.orm.cache.memcache_host%';
Expand Down
Expand Up @@ -47,7 +47,7 @@ public function reverseTransform($ids, $collection)

foreach ($collection AS $object) {
$key = array_search($reflField->getValue($object), $ids);
if ($key === false) {
if (false === $key) {
$collection->removeElement($object);
} else {
unset($ids[$key]);
Expand Down
Expand Up @@ -79,7 +79,7 @@ public function reverseTransform($value, $collection)
foreach ($collection as $object) {
$uniqueIdent = $reflField->getValue($object);
$key = array_search($uniqueIdent, $values);
if ($key === false) {
if (false === $key) {
$collection->removeElement($object);
} else {
// found in the collection, no need to do anything with it so remove it
Expand Down
Expand Up @@ -237,13 +237,13 @@ protected function loadDocumentManagerBundlesMappingInformation(array $documentM
$type = $this->detectMetadataDriver($bundleDirs[$namespace].'/'.$class, $container);

if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Document')) {
if ($type === null) {
if (null === $type) {
$type = 'annotation';
}
$aliasMap[$class] = $namespace.'\\'.$class.'\\Document';
}

if ($type !== null) {
if (null !== $type) {
$mappingDriverDef->addMethodCall('addDriver', array(
new Reference(sprintf('doctrine.odm.mongodb.metadata.%s', $type)),
$namespace.'\\'.$class.'\\Document'
Expand All @@ -268,7 +268,7 @@ protected function loadDocumentManagerMetadataCacheDriver(array $documentManager
$dmMetadataCacheDriver = isset($documentManager['metadata-cache-driver']) ? $documentManager['metadata-cache-driver'] : (isset($documentManager['metadata_cache_driver']) ? $documentManager['metadata_cache_driver'] : $metadataCacheDriver);
$type = is_array($dmMetadataCacheDriver) && isset($dmMetadataCacheDriver['type']) ? $dmMetadataCacheDriver['type'] : $dmMetadataCacheDriver;

if ($type === 'memcache') {
if ('memcache' === $type) {
$memcacheClass = isset($dmMetadataCacheDriver['class']) ? $dmMetadataCacheDriver['class'] : sprintf('%%doctrine.odm.mongodb.cache.%s_class%%', $type);
$cacheDef = new Definition($memcacheClass);
$memcacheHost = isset($dmMetadataCacheDriver['host']) ? $dmMetadataCacheDriver['host'] : '%doctrine.odm.mongodb.cache.memcache_host%';
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/CssSelector/Parser.php
Expand Up @@ -107,7 +107,7 @@ protected function parseSelector($stream)

while (1) {
$peek = $stream->peek();
if ($peek == ',' || $peek === null) {
if ($peek == ',' || null === $peek) {
return $result;
} elseif (in_array($peek, array('+', '>', '~'))) {
// A combinator
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/CssSelector/Tokenizer.php
Expand Up @@ -75,7 +75,7 @@ public function tokenize($s)
continue;
}

if ($c === '"' || $c === "'") {
if ('"' === $c || "'" === $c) {
// Quoted string
$old_pos = $pos;
list($sym, $pos) = $this->tokenizeEscapedString($s, $pos);
Expand Down
18 changes: 9 additions & 9 deletions src/Symfony/Component/Finder/Glob.php
Expand Up @@ -52,36 +52,36 @@ static public function toRegex($glob, $strictLeadingDot = true, $strictWildcardS
for ($i = 0; $i < $sizeGlob; $i++) {
$car = $glob[$i];
if ($firstByte) {
if ($strictLeadingDot && $car !== '.') {
if ($strictLeadingDot && '.' !== $car) {
$regex .= '(?=[^\.])';
}

$firstByte = false;
}

if ($car === '/') {
if ('/' === $car) {
$firstByte = true;
}

if ($car === '.' || $car === '(' || $car === ')' || $car === '|' || $car === '+' || $car === '^' || $car === '$') {
if ('.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
$regex .= "\\$car";
} elseif ($car === '*') {
} elseif ('*' === $car) {
$regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
} elseif ($car === '?') {
} elseif ('?' === $car) {
$regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
} elseif ($car === '{') {
} elseif ('{' === $car) {
$regex .= $escaping ? '\\{' : '(';
if (!$escaping) {
++$inCurlies;
}
} elseif ($car === '}' && $inCurlies) {
} elseif ('}' === $car && $inCurlies) {
$regex .= $escaping ? '}' : ')';
if (!$escaping) {
--$inCurlies;
}
} elseif ($car === ',' && $inCurlies) {
} elseif (',' === $car && $inCurlies) {
$regex .= $escaping ? ',' : '|';
} elseif ($car === '\\') {
} elseif ('\\' === $car) {
if ($escaping) {
$regex .= '\\\\';
$escaping = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/ChoiceField.php
Expand Up @@ -156,7 +156,7 @@ protected function newChoiceField($choice, $label)
public function bind($value)
{
if (!$this->isMultipleChoice() && $this->isExpanded()) {
$value = $value === null ? array() : array($value => true);
$value = null === $value ? array() : array($value => true);
}

parent::bind($value);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/CollectionField.php
Expand Up @@ -113,7 +113,7 @@ protected function newField($key, $propertyPath)
{
$field = clone $this->prototype;
$field->setKey($key);
$field->setPropertyPath($propertyPath === null ? null : '['.$propertyPath.']');
$field->setPropertyPath(null === $propertyPath ? null : '['.$propertyPath.']');
return $field;
}
}
6 changes: 3 additions & 3 deletions src/Symfony/Component/Form/DateField.php
Expand Up @@ -243,7 +243,7 @@ public function isYearWithinRange()
{
$date = $this->getNormalizedData();

return $date === null || in_array($date->format('Y'), $this->getOption('years'));
return null === $date || in_array($date->format('Y'), $this->getOption('years'));
}

/**
Expand All @@ -258,7 +258,7 @@ public function isMonthWithinRange()
{
$date = $this->getNormalizedData();

return $date === null || in_array($date->format('m'), $this->getOption('months'));
return null === $date || in_array($date->format('m'), $this->getOption('months'));
}

/**
Expand All @@ -273,6 +273,6 @@ public function isDayWithinRange()
{
$date = $this->getNormalizedData();

return $date === null || in_array($date->format('d'), $this->getOption('days'));
return null === $date || in_array($date->format('d'), $this->getOption('days'));
}
}
6 changes: 3 additions & 3 deletions src/Symfony/Component/Form/Field.php
Expand Up @@ -127,7 +127,7 @@ protected function getTransformedData()
*/
public function setPropertyPath($propertyPath)
{
$this->propertyPath = $propertyPath === null || $propertyPath === '' ? null : new PropertyPath($propertyPath);
$this->propertyPath = null === $propertyPath || '' === $propertyPath ? null : new PropertyPath($propertyPath);
}

/**
Expand Down Expand Up @@ -458,7 +458,7 @@ protected function denormalize($value)
protected function transform($value)
{
if (null === $this->valueTransformer) {
return $value === null ? '' : $value;
return null === $value ? '' : $value;
}
return $this->valueTransformer->transform($value);
}
Expand All @@ -472,7 +472,7 @@ protected function transform($value)
protected function reverseTransform($value)
{
if (null === $this->valueTransformer) {
return $value === '' ? null : $value;
return '' === $value ? null : $value;
}
return $this->valueTransformer->reverseTransform($value, $this->data);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/FieldGroup.php
Expand Up @@ -267,7 +267,7 @@ public function getDisplayedData()
*/
public function bind($taintedData)
{
if ($taintedData === null) {
if (null === $taintedData) {
$taintedData = array();
}

Expand Down Expand Up @@ -393,7 +393,7 @@ public function isValid()
*/
public function addError(FieldError $error, PropertyPathIterator $pathIterator = null, $type = null)
{
if ($pathIterator !== null) {
if (null !== $pathIterator) {
if ($type === self::FIELD_ERROR && $pathIterator->hasNext()) {
$pathIterator->next();

Expand Down
12 changes: 6 additions & 6 deletions src/Symfony/Component/Form/Form.php
Expand Up @@ -49,7 +49,7 @@ public function __construct($name, $data = null, ValidatorInterface $validator =
$this->validator = $validator;

// Prefill the form with the given data
if ($data !== null) {
if (null !== $data) {
$this->setData($data);
}

Expand All @@ -61,7 +61,7 @@ public function __construct($name, $data = null, ValidatorInterface $validator =

// If data is passed to this constructor, objects from parent forms
// should be ignored
if ($data !== null) {
if (null !== $data) {
$this->setPropertyPath(null);
}
}
Expand All @@ -73,7 +73,7 @@ public function __construct($name, $data = null, ValidatorInterface $validator =
*/
public function setValidationGroups($validationGroups)
{
$this->validationGroups = $validationGroups === null ? $validationGroups : (array) $validationGroups;
$this->validationGroups = null === $validationGroups ? $validationGroups : (array) $validationGroups;
}

/**
Expand All @@ -100,7 +100,7 @@ public function getValidationGroups()
*/
final public function bind($taintedValues, array $taintedFiles = null)
{
if ($taintedFiles === null) {
if (null === $taintedFiles) {
if ($this->isMultipart() && $this->getParent() === null) {
throw new \InvalidArgumentException('You must provide a files array for multipart forms');
}
Expand Down Expand Up @@ -182,11 +182,11 @@ public function isCsrfProtected()
public function enableCsrfProtection($csrfFieldName = null, $csrfSecret = null)
{
if (!$this->isCsrfProtected()) {
if ($csrfFieldName === null) {
if (null === $csrfFieldName) {
$csrfFieldName = FormConfiguration::getDefaultCsrfFieldName();
}

if ($csrfSecret === null) {
if (null === $csrfSecret) {
if (FormConfiguration::getDefaultCsrfSecret() !== null) {
$csrfSecret = FormConfiguration::getDefaultCsrfSecret();
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/PropertyPath.php
Expand Up @@ -54,7 +54,7 @@ class PropertyPath implements \IteratorAggregate
*/
public function __construct($propertyPath)
{
if ($propertyPath === '' || $propertyPath === null) {
if ('' === $propertyPath || null === $propertyPath) {
throw new InvalidPropertyPathException('The property path must not be empty');
}

Expand Down

0 comments on commit 094d428

Please sign in to comment.