[CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_method, semicolon_after_instruction

This commit is contained in:
SpacePossum 2017-09-07 11:04:22 +02:00 committed by Nicolas Grekas
parent 5bf241aa8e
commit 3e90138214
137 changed files with 313 additions and 310 deletions

View File

@ -9,11 +9,14 @@ return PhpCsFixer\Config::create()
'@Symfony' => true, '@Symfony' => true,
'@Symfony:risky' => true, '@Symfony:risky' => true,
'array_syntax' => array('syntax' => 'long'), 'array_syntax' => array('syntax' => 'long'),
'no_break_comment' => false,
'protected_to_private' => false,
)) ))
->setRiskyAllowed(true) ->setRiskyAllowed(true)
->setFinder( ->setFinder(
PhpCsFixer\Finder::create() PhpCsFixer\Finder::create()
->in(__DIR__.'/src') ->in(__DIR__.'/src')
->append(array(__FILE__))
->exclude(array( ->exclude(array(
// directories containing files with content that is autogenerated by `var_export`, which breaks CS in output code // directories containing files with content that is autogenerated by `var_export`, which breaks CS in output code
'Symfony/Component/DependencyInjection/Tests/Fixtures', 'Symfony/Component/DependencyInjection/Tests/Fixtures',

View File

@ -199,13 +199,13 @@ abstract class AbstractDoctrineExtension extends Extension
if ($container->hasDefinition($mappingService)) { if ($container->hasDefinition($mappingService)) {
$mappingDriverDef = $container->getDefinition($mappingService); $mappingDriverDef = $container->getDefinition($mappingService);
$args = $mappingDriverDef->getArguments(); $args = $mappingDriverDef->getArguments();
if ($driverType == 'annotation') { if ('annotation' == $driverType) {
$args[1] = array_merge(array_values($driverPaths), $args[1]); $args[1] = array_merge(array_values($driverPaths), $args[1]);
} else { } else {
$args[0] = array_merge(array_values($driverPaths), $args[0]); $args[0] = array_merge(array_values($driverPaths), $args[0]);
} }
$mappingDriverDef->setArguments($args); $mappingDriverDef->setArguments($args);
} elseif ($driverType == 'annotation') { } elseif ('annotation' == $driverType) {
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), array( $mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), array(
new Reference($this->getObjectManagerElementName('metadata.annotation_reader')), new Reference($this->getObjectManagerElementName('metadata.annotation_reader')),
array_values($driverPaths), array_values($driverPaths),
@ -333,7 +333,7 @@ abstract class AbstractDoctrineExtension extends Extension
$memcacheClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.memcache.class').'%'; $memcacheClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.memcache.class').'%';
$memcacheInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%'.$this->getObjectManagerElementName('cache.memcache_instance.class').'%'; $memcacheInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%'.$this->getObjectManagerElementName('cache.memcache_instance.class').'%';
$memcacheHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%'.$this->getObjectManagerElementName('cache.memcache_host').'%'; $memcacheHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%'.$this->getObjectManagerElementName('cache.memcache_host').'%';
$memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && $cacheDriver['port'] === 0) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%'; $memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && 0 === $cacheDriver['port']) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%';
$cacheDef = new Definition($memcacheClass); $cacheDef = new Definition($memcacheClass);
$memcacheInstance = new Definition($memcacheInstanceClass); $memcacheInstance = new Definition($memcacheInstanceClass);
$memcacheInstance->addMethodCall('connect', array( $memcacheInstance->addMethodCall('connect', array(

View File

@ -111,7 +111,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
// Like above, but we just filter out empty strings. // Like above, but we just filter out empty strings.
$values = array_values(array_filter($values, function ($v) { $values = array_values(array_filter($values, function ($v) {
return (string) $v !== ''; return '' !== (string) $v;
})); }));
} else { } else {
$parameterType = Connection::PARAM_STR_ARRAY; $parameterType = Connection::PARAM_STR_ARRAY;

View File

@ -41,7 +41,7 @@ class MergeDoctrineCollectionListener implements EventSubscriberInterface
// If all items were removed, call clear which has a higher // If all items were removed, call clear which has a higher
// performance on persistent collections // performance on persistent collections
if ($collection instanceof Collection && count($data) === 0) { if ($collection instanceof Collection && 0 === count($data)) {
$collection->clear(); $collection->clear();
} }
} }

View File

@ -176,7 +176,7 @@ abstract class DoctrineType extends AbstractType
$entityLoader $entityLoader
); );
if ($hash !== null) { if (null !== $hash) {
$choiceLoaders[$hash] = $doctrineChoiceLoader; $choiceLoaders[$hash] = $doctrineChoiceLoader;
} }

View File

@ -88,7 +88,7 @@ EOF
$types = array('functions', 'filters', 'tests', 'globals'); $types = array('functions', 'filters', 'tests', 'globals');
if ($input->getOption('format') === 'json') { if ('json' === $input->getOption('format')) {
$data = array(); $data = array();
foreach ($types as $type) { foreach ($types as $type) {
foreach ($twig->{'get'.ucfirst($type)}() as $name => $entity) { foreach ($twig->{'get'.ucfirst($type)}() as $name => $entity) {
@ -129,13 +129,13 @@ EOF
private function getMetadata($type, $entity) private function getMetadata($type, $entity)
{ {
if ($type === 'globals') { if ('globals' === $type) {
return $entity; return $entity;
} }
if ($type === 'tests') { if ('tests' === $type) {
return; return;
} }
if ($type === 'functions' || $type === 'filters') { if ('functions' === $type || 'filters' === $type) {
$cb = $entity->getCallable(); $cb = $entity->getCallable();
if (null === $cb) { if (null === $cb) {
return; return;
@ -165,7 +165,7 @@ EOF
array_shift($args); array_shift($args);
} }
if ($type === 'filters') { if ('filters' === $type) {
// remove the value the filter is applied on // remove the value the filter is applied on
array_shift($args); array_shift($args);
} }
@ -185,20 +185,20 @@ EOF
private function getPrettyMetadata($type, $entity) private function getPrettyMetadata($type, $entity)
{ {
if ($type === 'tests') { if ('tests' === $type) {
return ''; return '';
} }
try { try {
$meta = $this->getMetadata($type, $entity); $meta = $this->getMetadata($type, $entity);
if ($meta === null) { if (null === $meta) {
return '(unknown?)'; return '(unknown?)';
} }
} catch (\UnexpectedValueException $e) { } catch (\UnexpectedValueException $e) {
return ' <error>'.$e->getMessage().'</error>'; return ' <error>'.$e->getMessage().'</error>';
} }
if ($type === 'globals') { if ('globals' === $type) {
if (is_object($meta)) { if (is_object($meta)) {
return ' = object('.get_class($meta).')'; return ' = object('.get_class($meta).')';
} }
@ -206,11 +206,11 @@ EOF
return ' = '.substr(@json_encode($meta), 0, 50); return ' = '.substr(@json_encode($meta), 0, 50);
} }
if ($type === 'functions') { if ('functions' === $type) {
return '('.implode(', ', $meta).')'; return '('.implode(', ', $meta).')';
} }
if ($type === 'filters') { if ('filters' === $type) {
return $meta ? '('.implode(', ', $meta).')' : ''; return $meta ? '('.implode(', ', $meta).')' : '';
} }
} }

View File

@ -48,7 +48,7 @@ class StopwatchExtension extends AbstractExtension
* Some stuff which will be recorded on the timeline * Some stuff which will be recorded on the timeline
* {% endstopwatch %} * {% endstopwatch %}
*/ */
new StopwatchTokenParser($this->stopwatch !== null && $this->enabled), new StopwatchTokenParser(null !== $this->stopwatch && $this->enabled),
); );
} }

View File

@ -75,7 +75,7 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori
protected function renderLabel(FormView $view, $label = null, array $vars = array()) protected function renderLabel(FormView $view, $label = null, array $vars = array())
{ {
if ($label !== null) { if (null !== $label) {
$vars += array('label' => $label); $vars += array('label' => $label);
} }

View File

@ -75,7 +75,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
protected function renderLabel(FormView $view, $label = null, array $vars = array()) protected function renderLabel(FormView $view, $label = null, array $vars = array())
{ {
if ($label !== null) { if (null !== $label) {
$vars += array('label' => $label); $vars += array('label' => $label);
} }

View File

@ -158,7 +158,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
protected function renderLabel(FormView $view, $label = null, array $vars = array()) protected function renderLabel(FormView $view, $label = null, array $vars = array())
{ {
if ($label !== null) { if (null !== $label) {
$vars += array('label' => $label); $vars += array('label' => $label);
} }

View File

@ -76,7 +76,7 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
protected function renderLabel(FormView $view, $label = null, array $vars = array()) protected function renderLabel(FormView $view, $label = null, array $vars = array())
{ {
if ($label !== null) { if (null !== $label) {
$vars += array('label' => $label); $vars += array('label' => $label);
} }

View File

@ -72,7 +72,7 @@ EOF
$output = new SymfonyStyle($input, $output); $output = new SymfonyStyle($input, $output);
// check presence of force or dump-message // check presence of force or dump-message
if ($input->getOption('force') !== true && $input->getOption('dump-messages') !== true) { if (true !== $input->getOption('force') && true !== $input->getOption('dump-messages')) {
$output->error('You must choose one of --force or --dump-messages'); $output->error('You must choose one of --force or --dump-messages');
return 1; return 1;
@ -151,7 +151,7 @@ EOF
} }
// show compiled list of messages // show compiled list of messages
if ($input->getOption('dump-messages') === true) { if (true === $input->getOption('dump-messages')) {
$output->newLine(); $output->newLine();
foreach ($operation->getDomains() as $domain) { foreach ($operation->getDomains() as $domain) {
$output->section(sprintf('Displaying messages for domain <info>%s</info>:', $domain)); $output->section(sprintf('Displaying messages for domain <info>%s</info>:', $domain));
@ -168,17 +168,17 @@ EOF
)); ));
} }
if ($input->getOption('output-format') == 'xlf') { if ('xlf' == $input->getOption('output-format')) {
$output->writeln('Xliff output version is <info>1.2</info>'); $output->writeln('Xliff output version is <info>1.2</info>');
} }
} }
if ($input->getOption('no-backup') === true) { if (true === $input->getOption('no-backup')) {
$writer->disableBackup(); $writer->disableBackup();
} }
// save the files // save the files
if ($input->getOption('force') === true) { if (true === $input->getOption('force')) {
$output->text('Writing files'); $output->text('Writing files');
$bundleTransPath = false; $bundleTransPath = false;

View File

@ -141,7 +141,7 @@ class ControllerNameParser
} }
$lev = levenshtein($nonExistentBundleName, $bundleName); $lev = levenshtein($nonExistentBundleName, $bundleName);
if ($lev <= strlen($nonExistentBundleName) / 3 && ($alternative === null || $lev < $shortest)) { if ($lev <= strlen($nonExistentBundleName) / 3 && (null === $alternative || $lev < $shortest)) {
$alternative = $bundleName; $alternative = $bundleName;
$shortest = $lev; $shortest = $lev;
} }

View File

@ -100,7 +100,7 @@ class RedirectController extends ContainerAware
$qs = $request->getQueryString(); $qs = $request->getQueryString();
if ($qs) { if ($qs) {
if (strpos($path, '?') === false) { if (false === strpos($path, '?')) {
$qs = '?'.$qs; $qs = '?'.$qs;
} else { } else {
$qs = '&'.$qs; $qs = '&'.$qs;

View File

@ -46,7 +46,7 @@ class TemplateController extends ContainerAware
if ($private) { if ($private) {
$response->setPrivate(); $response->setPrivate();
} elseif ($private === false || (null === $private && ($maxAge || $sharedAge))) { } elseif (false === $private || (null === $private && ($maxAge || $sharedAge))) {
$response->setPublic(); $response->setPublic();
} }

View File

@ -1,6 +1,6 @@
<tr> <tr>
<td></td> <td></td>
<td> <td>
<?php echo $view['form']->widget($form) ?> <?php echo $view['form']->widget($form); ?>
</td> </td>
</tr> </tr>

View File

@ -1,9 +1,9 @@
<tr> <tr>
<td> <td>
<?php echo $view['form']->label($form) ?> <?php echo $view['form']->label($form); ?>
</td> </td>
<td> <td>
<?php echo $view['form']->errors($form) ?> <?php echo $view['form']->errors($form); ?>
<?php echo $view['form']->widget($form) ?> <?php echo $view['form']->widget($form); ?>
</td> </td>
</tr> </tr>

View File

@ -1,11 +1,11 @@
<table <?php echo $view['form']->block($form, 'widget_container_attributes') ?>> <table <?php echo $view['form']->block($form, 'widget_container_attributes'); ?>>
<?php if (!$form->parent && $errors): ?> <?php if (!$form->parent && $errors): ?>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<?php echo $view['form']->errors($form) ?> <?php echo $view['form']->errors($form); ?>
</td> </td>
</tr> </tr>
<?php endif ?> <?php endif; ?>
<?php echo $view['form']->block($form, 'form_rows') ?> <?php echo $view['form']->block($form, 'form_rows'); ?>
<?php echo $view['form']->rest($form) ?> <?php echo $view['form']->rest($form); ?>
</table> </table>

View File

@ -1,5 +1,5 @@
<tr style="display: none"> <tr style="display: none">
<td colspan="2"> <td colspan="2">
<?php echo $view['form']->widget($form) ?> <?php echo $view['form']->widget($form); ?>
</td> </td>
</tr> </tr>

View File

@ -77,7 +77,7 @@ abstract class KernelTestCase extends TestCase
$dir = null; $dir = null;
$reversedArgs = array_reverse($_SERVER['argv']); $reversedArgs = array_reverse($_SERVER['argv']);
foreach ($reversedArgs as $argIndex => $testArg) { foreach ($reversedArgs as $argIndex => $testArg) {
if (preg_match('/^-[^ \-]*c$/', $testArg) || $testArg === '--configuration') { if (preg_match('/^-[^ \-]*c$/', $testArg) || '--configuration' === $testArg) {
$dir = realpath($reversedArgs[$argIndex - 1]); $dir = realpath($reversedArgs[$argIndex - 1]);
break; break;
} elseif (0 === strpos($testArg, '--configuration=')) { } elseif (0 === strpos($testArg, '--configuration=')) {

View File

@ -30,9 +30,9 @@ class StubTemplateNameParser implements TemplateNameParserInterface
{ {
list($bundle, $controller, $template) = explode(':', $name, 3); list($bundle, $controller, $template) = explode(':', $name, 3);
if ($template[0] == '_') { if ('_' == $template[0]) {
$path = $this->rootTheme.'/Custom/'.$template; $path = $this->rootTheme.'/Custom/'.$template;
} elseif ($bundle === 'TestBundle') { } elseif ('TestBundle' === $bundle) {
$path = $this->rootTheme.'/'.$controller.'/'.$template; $path = $this->rootTheme.'/'.$controller.'/'.$template;
} else { } else {
$path = $this->root.'/'.$controller.'/'.$template; $path = $this->root.'/'.$controller.'/'.$template;

View File

@ -1 +1 @@
<label><?php echo $global ?>child</label> <label><?php echo $global; ?>child</label>

View File

@ -1,2 +1,2 @@
<?php $type = isset($type) ? $type : 'text' ?> <?php $type = isset($type) ? $type : 'text'; ?>
<input type="<?php echo $type ?>" <?php $view['form']->block($form, 'widget_attributes') ?> value="<?php echo $value ?>" rel="theme" /> <input type="<?php echo $type; ?>" <?php $view['form']->block($form, 'widget_attributes'); ?> value="<?php echo $value; ?>" rel="theme" />

View File

@ -36,7 +36,7 @@ class TemplateFilenameParserTest extends TestCase
{ {
$template = $this->parser->parse($file); $template = $this->parser->parse($file);
if ($ref === false) { if (false === $ref) {
$this->assertFalse($template); $this->assertFalse($template);
} else { } else {
$this->assertEquals($template->getLogicalName(), $ref->getLogicalName()); $this->assertEquals($template->getLogicalName(), $ref->getLogicalName());

View File

@ -120,7 +120,7 @@ EOF
foreach ($userOption as $user) { foreach ($userOption as $user) {
$data = explode(':', $user, 2); $data = explode(':', $user, 2);
if (count($data) === 1) { if (1 === count($data)) {
throw new \InvalidArgumentException('The user must follow the format "Acme/MyUser:username".'); throw new \InvalidArgumentException('The user must follow the format "Acme/MyUser:username".');
} }

View File

@ -394,7 +394,7 @@ class MainConfiguration implements ConfigurationInterface
->thenInvalid('You cannot set multiple provider types for the same provider') ->thenInvalid('You cannot set multiple provider types for the same provider')
->end() ->end()
->validate() ->validate()
->ifTrue(function ($v) { return count($v) === 0; }) ->ifTrue(function ($v) { return 0 === count($v); })
->thenInvalid('You must set a provider definition for the provider.') ->thenInvalid('You must set a provider definition for the provider.')
->end() ->end()
; ;

View File

@ -93,7 +93,7 @@ class RememberMeFactory implements SecurityFactoryInterface
$userProviders[] = new Reference('security.user.provider.concrete.'.$providerName); $userProviders[] = new Reference('security.user.provider.concrete.'.$providerName);
} }
} }
if (count($userProviders) === 0) { if (0 === count($userProviders)) {
throw new \RuntimeException('You must configure at least one remember-me aware listener (such as form-login) for each firewall that has remember-me enabled.'); throw new \RuntimeException('You must configure at least one remember-me aware listener (such as form-login) for each firewall that has remember-me enabled.');
} }

View File

@ -133,7 +133,7 @@ abstract class CompleteConfigurationTest extends TestCase
$rules = array(); $rules = array();
foreach ($container->getDefinition('security.access_map')->getMethodCalls() as $call) { foreach ($container->getDefinition('security.access_map')->getMethodCalls() as $call) {
if ($call[0] == 'add') { if ('add' == $call[0]) {
$rules[] = array((string) $call[1][0], $call[1][1], $call[1][2]); $rules[] = array((string) $call[1][0], $call[1][1], $call[1][2]);
} }
} }

View File

@ -49,7 +49,7 @@ class History
*/ */
public function isEmpty() public function isEmpty()
{ {
return count($this->stack) == 0; return 0 == count($this->stack);
} }
/** /**

View File

@ -215,7 +215,7 @@ REGEX;
do { do {
$token = $tokens[++$i]; $token = $tokens[++$i];
$output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token; $output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token;
} while ($token[0] !== T_END_HEREDOC); } while (T_END_HEREDOC !== $token[0]);
$output .= "\n"; $output .= "\n";
$rawChunk = ''; $rawChunk = '';
} elseif (T_CONSTANT_ENCAPSED_STRING === $token[0]) { } elseif (T_CONSTANT_ENCAPSED_STRING === $token[0]) {

View File

@ -66,7 +66,7 @@ class ClassMapGenerator
$path = $file->getRealPath() ?: $file->getPathname(); $path = $file->getRealPath() ?: $file->getPathname();
if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') { if ('php' !== pathinfo($path, PATHINFO_EXTENSION)) {
continue; continue;
} }

View File

@ -117,7 +117,7 @@ class YamlReferenceDumper
$comments[] = 'Example: '.$example; $comments[] = 'Example: '.$example;
} }
$default = (string) $default != '' ? ' '.$default : ''; $default = '' != (string) $default ? ' '.$default : '';
$comments = count($comments) ? '# '.implode(', ', $comments) : ''; $comments = count($comments) ? '# '.implode(', ', $comments) : '';
$text = rtrim(sprintf('%-21s%s %s', $node->getName().':', $default, $comments), ' '); $text = rtrim(sprintf('%-21s%s %s', $node->getName().':', $default, $comments), ' ');

View File

@ -81,10 +81,10 @@ class FileLocator implements FileLocatorInterface
*/ */
private function isAbsolutePath($file) private function isAbsolutePath($file)
{ {
if ($file[0] === '/' || $file[0] === '\\' if ('/' === $file[0] || '\\' === $file[0]
|| (strlen($file) > 3 && ctype_alpha($file[0]) || (strlen($file) > 3 && ctype_alpha($file[0])
&& $file[1] === ':' && ':' === $file[1]
&& ($file[2] === '\\' || $file[2] === '/') && ('\\' === $file[2] || '/' === $file[2])
) )
|| null !== parse_url($file, PHP_URL_SCHEME) || null !== parse_url($file, PHP_URL_SCHEME)
) { ) {

View File

@ -68,7 +68,7 @@ class XmlUtils
libxml_disable_entity_loader($disableEntities); libxml_disable_entity_loader($disableEntities);
foreach ($dom->childNodes as $child) { foreach ($dom->childNodes as $child) {
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) { if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
throw new \InvalidArgumentException('Document types are not allowed.'); throw new \InvalidArgumentException('Document types are not allowed.');
} }
} }

View File

@ -709,8 +709,8 @@ class Application
$trace = $e->getTrace(); $trace = $e->getTrace();
array_unshift($trace, array( array_unshift($trace, array(
'function' => '', 'function' => '',
'file' => $e->getFile() !== null ? $e->getFile() : 'n/a', 'file' => null !== $e->getFile() ? $e->getFile() : 'n/a',
'line' => $e->getLine() !== null ? $e->getLine() : 'n/a', 'line' => null !== $e->getLine() ? $e->getLine() : 'n/a',
'args' => array(), 'args' => array(),
)); ));
@ -838,9 +838,9 @@ class Application
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET); $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
$input->setInteractive(false); $input->setInteractive(false);
} else { } else {
if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || $input->getParameterOption('--verbose') === 3) { if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || 3 === $input->getParameterOption('--verbose')) {
$output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
} elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || $input->getParameterOption('--verbose') === 2) { } elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || 2 === $input->getParameterOption('--verbose')) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
} elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) { } elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);

View File

@ -94,9 +94,9 @@ class XmlDescriptor extends Descriptor
$dom = new \DOMDocument('1.0', 'UTF-8'); $dom = new \DOMDocument('1.0', 'UTF-8');
$dom->appendChild($rootXml = $dom->createElement('symfony')); $dom->appendChild($rootXml = $dom->createElement('symfony'));
if ($application->getName() !== 'UNKNOWN') { if ('UNKNOWN' !== $application->getName()) {
$rootXml->setAttribute('name', $application->getName()); $rootXml->setAttribute('name', $application->getName());
if ($application->getVersion() !== 'UNKNOWN') { if ('UNKNOWN' !== $application->getVersion()) {
$rootXml->setAttribute('version', $application->getVersion()); $rootXml->setAttribute('version', $application->getVersion());
} }
} }

View File

@ -159,7 +159,7 @@ class DialogHelper extends InputAwareHelper
$output->write("\033[1D"); $output->write("\033[1D");
} }
if ($i === 0) { if (0 === $i) {
$ofs = -1; $ofs = -1;
$matches = $autocomplete; $matches = $autocomplete;
$numMatches = count($matches); $numMatches = count($matches);
@ -324,7 +324,7 @@ class DialogHelper extends InputAwareHelper
if (false !== $shell = $this->getShell()) { if (false !== $shell = $this->getShell()) {
$output->write($question); $output->write($question);
$readCmd = $shell === 'csh' ? 'set mypassword = $<' : 'read -r mypassword'; $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
$command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd); $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
$value = rtrim(shell_exec($command)); $value = rtrim(shell_exec($command));
$output->writeln(''); $output->writeln('');
@ -462,7 +462,7 @@ class DialogHelper extends InputAwareHelper
exec('stty 2>&1', $output, $exitcode); exec('stty 2>&1', $output, $exitcode);
return self::$stty = $exitcode === 0; return self::$stty = 0 === $exitcode;
} }
/** /**

View File

@ -423,7 +423,7 @@ class ProgressHelper extends Helper
$text = ''; $text = '';
foreach ($this->timeFormats as $format) { foreach ($this->timeFormats as $format) {
if ($secs < $format[0]) { if ($secs < $format[0]) {
if (count($format) == 2) { if (2 == count($format)) {
$text = $format[1]; $text = $format[1];
break; break;
} else { } else {

View File

@ -235,7 +235,7 @@ class QuestionHelper extends Helper
$output->write("\033[1D"); $output->write("\033[1D");
} }
if ($i === 0) { if (0 === $i) {
$ofs = -1; $ofs = -1;
$matches = $autocomplete; $matches = $autocomplete;
$numMatches = count($matches); $numMatches = count($matches);
@ -365,7 +365,7 @@ class QuestionHelper extends Helper
} }
if (false !== $shell = $this->getShell()) { if (false !== $shell = $this->getShell()) {
$readCmd = $shell === 'csh' ? 'set mypassword = $<' : 'read -r mypassword'; $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
$command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd); $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
$value = rtrim(shell_exec($command)); $value = rtrim(shell_exec($command));
$output->writeln(''); $output->writeln('');
@ -447,6 +447,6 @@ class QuestionHelper extends Helper
exec('stty 2>&1', $output, $exitcode); exec('stty 2>&1', $output, $exitcode);
return self::$stty = $exitcode === 0; return self::$stty = 0 === $exitcode;
} }
} }

View File

@ -328,7 +328,7 @@ class ArgvInput extends Input
return $match[1].$self->escapeToken($match[2]); return $match[1].$self->escapeToken($match[2]);
} }
if ($token && $token[0] !== '-') { if ($token && '-' !== $token[0]) {
return $self->escapeToken($token); return $self->escapeToken($token);
} }

View File

@ -82,7 +82,7 @@ class ConsoleLogger extends AbstractLogger
} }
// Write to the error output if necessary and available // Write to the error output if necessary and available
if ($this->formatLevelMap[$level] === self::ERROR && $this->output instanceof ConsoleOutputInterface) { if (self::ERROR === $this->formatLevelMap[$level] && $this->output instanceof ConsoleOutputInterface) {
$output = $this->output->getErrorOutput(); $output = $this->output->getErrorOutput();
} else { } else {
$output = $this->output; $output = $this->output;

View File

@ -253,6 +253,6 @@ class LegacyDialogHelperTest extends TestCase
{ {
exec('stty 2>&1', $output, $exitcode); exec('stty 2>&1', $output, $exitcode);
return $exitcode === 0; return 0 === $exitcode;
} }
} }

View File

@ -217,7 +217,7 @@ class LegacyProgressHelperTest extends TestCase
{ {
$expectedout = $expected; $expectedout = $expected;
if ($this->lastMessagesLength !== null) { if (null !== $this->lastMessagesLength) {
$expectedout = str_pad($expected, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT); $expectedout = str_pad($expected, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
} }

View File

@ -502,6 +502,6 @@ class QuestionHelperTest extends TestCase
{ {
exec('stty 2>&1', $output, $exitcode); exec('stty 2>&1', $output, $exitcode);
return $exitcode === 0; return 0 === $exitcode;
} }
} }

View File

@ -35,7 +35,7 @@ class EmptyStringParser implements ParserInterface
public function parse($source) public function parse($source)
{ {
// Matches an empty string // Matches an empty string
if ($source == '') { if ('' == $source) {
return array(new SelectorNode(new ElementNode(null, '*'))); return array(new SelectorNode(new ElementNode(null, '*')));
} }

View File

@ -477,7 +477,7 @@ class Container implements IntrospectableContainerInterface
$this->scopeChildren[$name] = array(); $this->scopeChildren[$name] = array();
// normalize the child relations // normalize the child relations
while ($parentScope !== self::SCOPE_CONTAINER) { while (self::SCOPE_CONTAINER !== $parentScope) {
$this->scopeChildren[$parentScope][] = $name; $this->scopeChildren[$parentScope][] = $name;
$parentScope = $this->scopes[$parentScope]; $parentScope = $this->scopes[$parentScope];
} }

View File

@ -1038,7 +1038,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
foreach ($value as $v) { foreach ($value as $v) {
$services = array_unique(array_merge($services, self::getServiceConditionals($v))); $services = array_unique(array_merge($services, self::getServiceConditionals($v)));
} }
} elseif ($value instanceof Reference && $value->getInvalidBehavior() === ContainerInterface::IGNORE_ON_INVALID_REFERENCE) { } elseif ($value instanceof Reference && ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $value->getInvalidBehavior()) {
$services[] = (string) $value; $services[] = (string) $value;
} }

View File

@ -60,7 +60,7 @@ class Definition
*/ */
public function setFactory($factory) public function setFactory($factory)
{ {
if (is_string($factory) && strpos($factory, '::') !== false) { if (is_string($factory) && false !== strpos($factory, '::')) {
$factory = explode('::', $factory, 2); $factory = explode('::', $factory, 2);
} }

View File

@ -533,7 +533,7 @@ class PhpDumper extends Dumper
$class = $this->dumpValue($callable[0]); $class = $this->dumpValue($callable[0]);
// If the class is a string we can optimize call_user_func away // If the class is a string we can optimize call_user_func away
if (strpos($class, "'") === 0) { if (0 === strpos($class, "'")) {
return sprintf(" %s::%s(\$%s);\n", $this->dumpLiteralClass($class), $callable[1], $variableName); return sprintf(" %s::%s(\$%s);\n", $this->dumpLiteralClass($class), $callable[1], $variableName);
} }
@ -753,7 +753,7 @@ EOF;
$class = $this->dumpValue($callable[0]); $class = $this->dumpValue($callable[0]);
// If the class is a string we can optimize call_user_func away // If the class is a string we can optimize call_user_func away
if (strpos($class, "'") === 0) { if (0 === strpos($class, "'")) {
return sprintf(" $return{$instantiation}%s::%s(%s);\n", $this->dumpLiteralClass($class), $callable[1], $arguments ? implode(', ', $arguments) : ''); return sprintf(" $return{$instantiation}%s::%s(%s);\n", $this->dumpLiteralClass($class), $callable[1], $arguments ? implode(', ', $arguments) : '');
} }
@ -766,7 +766,7 @@ EOF;
$class = $this->dumpValue($definition->getFactoryClass(false)); $class = $this->dumpValue($definition->getFactoryClass(false));
// If the class is a string we can optimize call_user_func away // If the class is a string we can optimize call_user_func away
if (strpos($class, "'") === 0) { if (0 === strpos($class, "'")) {
return sprintf(" $return{$instantiation}%s::%s(%s);\n", $this->dumpLiteralClass($class), $definition->getFactoryMethod(false), $arguments ? implode(', ', $arguments) : ''); return sprintf(" $return{$instantiation}%s::%s(%s);\n", $this->dumpLiteralClass($class), $definition->getFactoryMethod(false), $arguments ? implode(', ', $arguments) : '');
} }

View File

@ -282,9 +282,9 @@ class XmlDumper extends Dumper
$element->setAttribute('type', 'service'); $element->setAttribute('type', 'service');
$element->setAttribute('id', (string) $value); $element->setAttribute('id', (string) $value);
$behaviour = $value->getInvalidBehavior(); $behaviour = $value->getInvalidBehavior();
if ($behaviour == ContainerInterface::NULL_ON_INVALID_REFERENCE) { if (ContainerInterface::NULL_ON_INVALID_REFERENCE == $behaviour) {
$element->setAttribute('on-invalid', 'null'); $element->setAttribute('on-invalid', 'null');
} elseif ($behaviour == ContainerInterface::IGNORE_ON_INVALID_REFERENCE) { } elseif (ContainerInterface::IGNORE_ON_INVALID_REFERENCE == $behaviour) {
$element->setAttribute('on-invalid', 'ignore'); $element->setAttribute('on-invalid', 'ignore');
} }
if (!$value->isStrict()) { if (!$value->isStrict()) {

View File

@ -65,7 +65,7 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
public function getAlias() public function getAlias()
{ {
$className = get_class($this); $className = get_class($this);
if (substr($className, -9) != 'Extension') { if ('Extension' != substr($className, -9)) {
throw new BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.'); throw new BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.');
} }
$classBaseName = substr(strrchr($className, '\\'), 1, -9); $classBaseName = substr(strrchr($className, '\\'), 1, -9);

View File

@ -414,7 +414,7 @@ class XmlFileLoader extends FileLoader
{ {
$children = array(); $children = array();
foreach ($node->childNodes as $child) { foreach ($node->childNodes as $child) {
if ($child instanceof \DOMElement && $child->localName === $name && $child->namespaceURI === self::NS) { if ($child instanceof \DOMElement && $child->localName === $name && self::NS === $child->namespaceURI) {
$children[] = $child; $children[] = $child;
} }
} }
@ -533,7 +533,7 @@ EOF
private function loadFromExtensions(\DOMDocument $xml) private function loadFromExtensions(\DOMDocument $xml)
{ {
foreach ($xml->documentElement->childNodes as $node) { foreach ($xml->documentElement->childNodes as $node) {
if (!$node instanceof \DOMElement || $node->namespaceURI === self::NS) { if (!$node instanceof \DOMElement || self::NS === $node->namespaceURI) {
continue; continue;
} }

View File

@ -192,7 +192,7 @@ class YamlFileLoader extends FileLoader
if (isset($service['factory'])) { if (isset($service['factory'])) {
if (is_string($service['factory'])) { if (is_string($service['factory'])) {
if (strpos($service['factory'], ':') !== false && strpos($service['factory'], '::') === false) { if (false !== strpos($service['factory'], ':') && false === strpos($service['factory'], '::')) {
$parts = explode(':', $service['factory']); $parts = explode(':', $service['factory']);
$definition->setFactory(array($this->resolveServices('@'.$parts[0]), $parts[1])); $definition->setFactory(array($this->resolveServices('@'.$parts[0]), $parts[1]));
} else { } else {

View File

@ -969,7 +969,7 @@ class Crawler extends \SplObjectStorage
$nodes = array(); $nodes = array();
do { do {
if ($node !== $this->getNode(0) && $node->nodeType === 1) { if ($node !== $this->getNode(0) && 1 === $node->nodeType) {
$nodes[] = $node; $nodes[] = $node;
} }
} while ($node = $node->$siblingDir); } while ($node = $node->$siblingDir);

View File

@ -295,7 +295,7 @@ EOF
{ {
$crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li'); $crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li');
$nodes = $crawler->reduce(function ($node, $i) { $nodes = $crawler->reduce(function ($node, $i) {
return $i !== 1; return 1 !== $i;
}); });
$this->assertNotSame($nodes, $crawler, '->reduce() returns a new instance of a crawler'); $this->assertNotSame($nodes, $crawler, '->reduce() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $nodes, '->reduce() returns a new instance of a crawler'); $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $nodes, '->reduce() returns a new instance of a crawler');

View File

@ -175,7 +175,7 @@ class ContainerAwareEventDispatcher extends EventDispatcher
$key = $serviceId.'.'.$method; $key = $serviceId.'.'.$method;
if (!isset($this->listeners[$eventName][$key])) { if (!isset($this->listeners[$eventName][$key])) {
$this->addListener($eventName, array($listener, $method), $priority); $this->addListener($eventName, array($listener, $method), $priority);
} elseif ($listener !== $this->listeners[$eventName][$key]) { } elseif ($this->listeners[$eventName][$key] !== $listener) {
parent::removeListener($eventName, array($this->listeners[$eventName][$key], $method)); parent::removeListener($eventName, array($this->listeners[$eventName][$key], $method));
$this->addListener($eventName, array($listener, $method), $priority); $this->addListener($eventName, array($listener, $method), $priority);
} }

View File

@ -305,14 +305,14 @@ class Parser
public function parsePostfixExpression($node) public function parsePostfixExpression($node)
{ {
$token = $this->stream->current; $token = $this->stream->current;
while ($token->type == Token::PUNCTUATION_TYPE) { while (Token::PUNCTUATION_TYPE == $token->type) {
if ('.' === $token->value) { if ('.' === $token->value) {
$this->stream->next(); $this->stream->next();
$token = $this->stream->current; $token = $this->stream->current;
$this->stream->next(); $this->stream->next();
if ( if (
$token->type !== Token::NAME_TYPE Token::NAME_TYPE !== $token->type
&& &&
// Operators like "not" and "matches" are valid method or property names, // Operators like "not" and "matches" are valid method or property names,
// //
@ -325,7 +325,7 @@ class Parser
// Other types, such as STRING_TYPE and NUMBER_TYPE, can't be parsed as property nor method names. // Other types, such as STRING_TYPE and NUMBER_TYPE, can't be parsed as property nor method names.
// //
// As a result, if $token is NOT an operator OR $token->value is NOT a valid property or method name, an exception shall be thrown. // As a result, if $token is NOT an operator OR $token->value is NOT a valid property or method name, an exception shall be thrown.
($token->type !== Token::OPERATOR_TYPE || !preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A', $token->value)) (Token::OPERATOR_TYPE !== $token->type || !preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A', $token->value))
) { ) {
throw new SyntaxError('Expected name', $token->cursor, $this->stream->getExpression()); throw new SyntaxError('Expected name', $token->cursor, $this->stream->getExpression());
} }

View File

@ -84,7 +84,7 @@ class TokenStream
*/ */
public function isEOF() public function isEOF()
{ {
return $this->current->type === Token::EOF_TYPE; return Token::EOF_TYPE === $this->current->type;
} }
/** /**

View File

@ -404,7 +404,7 @@ class Filesystem
} }
// Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels) // Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels)
if (count($startPathArr) === 1 && $startPathArr[0] === '') { if (1 === count($startPathArr) && '' === $startPathArr[0]) {
$depth = 0; $depth = 0;
} else { } else {
$depth = count($startPathArr) - $index; $depth = count($startPathArr) - $index;
@ -512,7 +512,7 @@ class Filesystem
{ {
return strspn($file, '/\\', 0, 1) return strspn($file, '/\\', 0, 1)
|| (strlen($file) > 3 && ctype_alpha($file[0]) || (strlen($file) > 3 && ctype_alpha($file[0])
&& substr($file, 1, 1) === ':' && ':' === substr($file, 1, 1)
&& strspn($file, '/\\', 2, 1) && strspn($file, '/\\', 2, 1)
) )
|| null !== parse_url($file, PHP_URL_SCHEME) || null !== parse_url($file, PHP_URL_SCHEME)

View File

@ -72,7 +72,7 @@ class GnuFindAdapter extends AbstractFindAdapter
*/ */
protected function canBeUsed() protected function canBeUsed()
{ {
return $this->shell->getType() === Shell::TYPE_UNIX && parent::canBeUsed(); return Shell::TYPE_UNIX === $this->shell->getType() && parent::canBeUsed();
} }
/** /**

View File

@ -67,8 +67,8 @@ class Regex implements ValueInterface
if ( if (
($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start)) ($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start))
|| ($start === '{' && $end === '}') || ('{' === $start && '}' === $end)
|| ($start === '(' && $end === ')') || ('(' === $start && ')' === $end)
) { ) {
return new self(substr($m[1], 1, -1), $m[2], $end); return new self(substr($m[1], 1, -1), $m[2], $end);
} }

View File

@ -58,9 +58,9 @@ class SortableIteratorTest extends RealIteratorTestCase
$iterator = new SortableIterator($inner, $mode); $iterator = new SortableIterator($inner, $mode);
if ($mode === SortableIterator::SORT_BY_ACCESSED_TIME if (SortableIterator::SORT_BY_ACCESSED_TIME === $mode
|| $mode === SortableIterator::SORT_BY_CHANGED_TIME || SortableIterator::SORT_BY_CHANGED_TIME === $mode
|| $mode === SortableIterator::SORT_BY_MODIFIED_TIME || SortableIterator::SORT_BY_MODIFIED_TIME === $mode
) { ) {
if ('\\' === DIRECTORY_SEPARATOR && SortableIterator::SORT_BY_MODIFIED_TIME !== $mode) { if ('\\' === DIRECTORY_SEPARATOR && SortableIterator::SORT_BY_MODIFIED_TIME !== $mode) {
$this->markTestSkipped('Sorting by atime or ctime is not supported on Windows'); $this->markTestSkipped('Sorting by atime or ctime is not supported on Windows');

View File

@ -109,7 +109,7 @@ class ChoiceToBooleanArrayTransformer implements DataTransformerInterface
foreach ($values as $i => $selected) { foreach ($values as $i => $selected) {
if ($selected) { if ($selected) {
if (isset($choices[$i])) { if (isset($choices[$i])) {
return $choices[$i] === '' ? null : $choices[$i]; return '' === $choices[$i] ? null : $choices[$i];
} elseif ($this->placeholderPresent && 'placeholder' === $i) { } elseif ($this->placeholderPresent && 'placeholder' === $i) {
return; return;
} else { } else {

View File

@ -90,7 +90,7 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer
$value = $this->getIntlDateFormatter()->format($dateTime->getTimestamp()); $value = $this->getIntlDateFormatter()->format($dateTime->getTimestamp());
if (intl_get_error_code() != 0) { if (0 != intl_get_error_code()) {
throw new TransformationFailedException(intl_get_error_message()); throw new TransformationFailedException(intl_get_error_message());
} }
@ -123,7 +123,7 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer
$timestamp = $this->getIntlDateFormatter($dateOnly)->parse($value); $timestamp = $this->getIntlDateFormatter($dateOnly)->parse($value);
if (intl_get_error_code() != 0) { if (0 != intl_get_error_code()) {
throw new TransformationFailedException(intl_get_error_message()); throw new TransformationFailedException(intl_get_error_message());
} }

View File

@ -101,7 +101,7 @@ class CsrfValidationListener implements EventSubscriberInterface
public function preSubmit(FormEvent $event) public function preSubmit(FormEvent $event)
{ {
$form = $event->getForm(); $form = $event->getForm();
$postRequestSizeExceeded = $form->getConfig()->getMethod() === 'POST' && $this->serverParams->hasPostMaxSizeBeenExceeded(); $postRequestSizeExceeded = 'POST' === $form->getConfig()->getMethod() && $this->serverParams->hasPostMaxSizeBeenExceeded();
if ($form->isRoot() && $form->getConfig()->getOption('compound') && !$postRequestSizeExceeded) { if ($form->isRoot() && $form->getConfig()->getOption('compound') && !$postRequestSizeExceeded) {
$data = $event->getData(); $data = $event->getData();

View File

@ -202,10 +202,10 @@ class ResolvedFormType implements ResolvedFormTypeInterface
if (method_exists($this->innerType, 'configureOptions')) { if (method_exists($this->innerType, 'configureOptions')) {
$reflector = new \ReflectionMethod($this->innerType, 'setDefaultOptions'); $reflector = new \ReflectionMethod($this->innerType, 'setDefaultOptions');
$isOldOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType'; $isOldOverwritten = 'Symfony\Component\Form\AbstractType' !== $reflector->getDeclaringClass()->getName();
$reflector = new \ReflectionMethod($this->innerType, 'configureOptions'); $reflector = new \ReflectionMethod($this->innerType, 'configureOptions');
$isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType'; $isNewOverwritten = 'Symfony\Component\Form\AbstractType' !== $reflector->getDeclaringClass()->getName();
if ($isOldOverwritten && !$isNewOverwritten) { if ($isOldOverwritten && !$isNewOverwritten) {
@trigger_error(get_class($this->innerType).': The FormTypeInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeInterface with Symfony 3.0.', E_USER_DEPRECATED); @trigger_error(get_class($this->innerType).': The FormTypeInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeInterface with Symfony 3.0.', E_USER_DEPRECATED);
@ -219,10 +219,10 @@ class ResolvedFormType implements ResolvedFormTypeInterface
if (method_exists($extension, 'configureOptions')) { if (method_exists($extension, 'configureOptions')) {
$reflector = new \ReflectionMethod($extension, 'setDefaultOptions'); $reflector = new \ReflectionMethod($extension, 'setDefaultOptions');
$isOldOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractTypeExtension'; $isOldOverwritten = 'Symfony\Component\Form\AbstractTypeExtension' !== $reflector->getDeclaringClass()->getName();
$reflector = new \ReflectionMethod($extension, 'configureOptions'); $reflector = new \ReflectionMethod($extension, 'configureOptions');
$isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractTypeExtension'; $isNewOverwritten = 'Symfony\Component\Form\AbstractTypeExtension' !== $reflector->getDeclaringClass()->getName();
if ($isOldOverwritten && !$isNewOverwritten) { if ($isOldOverwritten && !$isNewOverwritten) {
@trigger_error(get_class($extension).': The FormTypeExtensionInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeExtensionInterface with Symfony 3.0.', E_USER_DEPRECATED); @trigger_error(get_class($extension).': The FormTypeExtensionInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeExtensionInterface with Symfony 3.0.', E_USER_DEPRECATED);

View File

@ -35,7 +35,7 @@ abstract class FormPerformanceTestCase extends FormIntegrationTestCase
parent::runTest(); parent::runTest();
$time = microtime(true) - $s; $time = microtime(true) - $s;
if ($this->maxRunningTime != 0 && $time > $this->maxRunningTime) { if (0 != $this->maxRunningTime && $time > $this->maxRunningTime) {
$this->fail( $this->fail(
sprintf( sprintf(
'expected running time: <= %s but was: %s', 'expected running time: <= %s but was: %s',

View File

@ -78,8 +78,8 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
$this->fail(sprintf( $this->fail(sprintf(
"Failed asserting that \n\n%s\n\nmatches exactly %s. Matches %s in \n\n%s", "Failed asserting that \n\n%s\n\nmatches exactly %s. Matches %s in \n\n%s",
$expression, $expression,
$count == 1 ? 'once' : $count.' times', 1 == $count ? 'once' : $count.' times',
$nodeList->length == 1 ? 'once' : $nodeList->length.' times', 1 == $nodeList->length ? 'once' : $nodeList->length.' times',
// strip away <root> and </root> // strip away <root> and </root>
substr($dom->saveHTML(), 6, -8) substr($dom->saveHTML(), 6, -8)
)); ));

View File

@ -1260,7 +1260,7 @@ class ViolationMapperTest extends TestCase
// Only add it if we expect the error to come up on a different // Only add it if we expect the error to come up on a different
// level than LEVEL_0, because in this case the error would // level than LEVEL_0, because in this case the error would
// (correctly) be mapped to the distraction field // (correctly) be mapped to the distraction field
if ($target !== self::LEVEL_0) { if (self::LEVEL_0 !== $target) {
$mapFromPath = new PropertyPath($mapFrom); $mapFromPath = new PropertyPath($mapFrom);
$mapFromPrefix = $mapFromPath->isIndex(0) $mapFromPrefix = $mapFromPath->isIndex(0)
? '['.$mapFromPath->getElement(0).']' ? '['.$mapFromPath->getElement(0).']'
@ -1274,7 +1274,7 @@ class ViolationMapperTest extends TestCase
$this->mapper->mapViolation($violation, $parent); $this->mapper->mapViolation($violation, $parent);
if ($target !== self::LEVEL_0) { if (self::LEVEL_0 !== $target) {
$this->assertCount(0, $distraction->getErrors(), 'distraction should not have an error, but has one'); $this->assertCount(0, $distraction->getErrors(), 'distraction should not have an error, but has one');
} }

View File

@ -15,7 +15,7 @@ class AlternatingRowType extends AbstractType
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($formFactory) { $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($formFactory) {
$form = $event->getForm(); $form = $event->getForm();
$type = $form->getName() % 2 === 0 ? 'text' : 'textarea'; $type = 0 === $form->getName() % 2 ? 'text' : 'textarea';
$form->add('title', $type); $form->add('title', $type);
}); });
} }

View File

@ -36,7 +36,7 @@ class FixedDataTransformer implements DataTransformerInterface
{ {
$result = array_search($value, $this->mapping, true); $result = array_search($value, $this->mapping, true);
if ($result === false) { if (false === $result) {
throw new TransformationFailedException(sprintf('No reverse mapping for value "%s"', $value)); throw new TransformationFailedException(sprintf('No reverse mapping for value "%s"', $value));
} }

View File

@ -67,7 +67,7 @@ class AcceptHeaderItem
$lastNullAttribute = null; $lastNullAttribute = null;
foreach ($bits as $bit) { foreach ($bits as $bit) {
if (($start = substr($bit, 0, 1)) === ($end = substr($bit, -1)) && ($start === '"' || $start === '\'')) { if (($start = substr($bit, 0, 1)) === ($end = substr($bit, -1)) && ('"' === $start || '\'' === $start)) {
$attributes[$lastNullAttribute] = substr($bit, 1, -1); $attributes[$lastNullAttribute] = substr($bit, 1, -1);
} elseif ('=' === $end) { } elseif ('=' === $end) {
$lastNullAttribute = $bit = substr($bit, 0, -1); $lastNullAttribute = $bit = substr($bit, 0, -1);
@ -78,7 +78,7 @@ class AcceptHeaderItem
} }
} }
return new self(($start = substr($value, 0, 1)) === ($end = substr($value, -1)) && ($start === '"' || $start === '\'') ? substr($value, 1, -1) : $value, $attributes); return new self(($start = substr($value, 0, 1)) === ($end = substr($value, -1)) && ('"' === $start || '\'' === $start) ? substr($value, 1, -1) : $value, $attributes);
} }
/** /**

View File

@ -157,7 +157,7 @@ class BinaryFileResponse extends Response
*/ */
public function setContentDisposition($disposition, $filename = '', $filenameFallback = '') public function setContentDisposition($disposition, $filename = '', $filenameFallback = '')
{ {
if ($filename === '') { if ('' === $filename) {
$filename = $this->file->getFilename(); $filename = $this->file->getFilename();
} }
@ -214,7 +214,7 @@ class BinaryFileResponse extends Response
if (false === $path) { if (false === $path) {
$path = $this->file->getPathname(); $path = $this->file->getPathname();
} }
if (strtolower($type) === 'x-accel-redirect') { if ('x-accel-redirect' === strtolower($type)) {
// Do X-Accel-Mapping substitutions. // Do X-Accel-Mapping substitutions.
// @link http://wiki.nginx.org/X-accel#X-Accel-Redirect // @link http://wiki.nginx.org/X-accel#X-Accel-Redirect
foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) { foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) {
@ -254,7 +254,7 @@ class BinaryFileResponse extends Response
if ($start < 0 || $end > $fileSize - 1) { if ($start < 0 || $end > $fileSize - 1) {
$this->setStatusCode(416); $this->setStatusCode(416);
$this->headers->set('Content-Range', sprintf('bytes */%s', $fileSize)); $this->headers->set('Content-Range', sprintf('bytes */%s', $fileSize));
} elseif ($start !== 0 || $end !== $fileSize - 1) { } elseif (0 !== $start || $end !== $fileSize - 1) {
$this->maxlen = $end < $fileSize ? $end - $start + 1 : -1; $this->maxlen = $end < $fileSize ? $end - $start + 1 : -1;
$this->offset = $start; $this->offset = $start;

View File

@ -198,7 +198,7 @@ class UploadedFile extends File
*/ */
public function isValid() public function isValid()
{ {
$isOk = $this->error === UPLOAD_ERR_OK; $isOk = UPLOAD_ERR_OK === $this->error;
return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname()); return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname());
} }
@ -285,7 +285,7 @@ class UploadedFile extends File
); );
$errorCode = $this->error; $errorCode = $this->error;
$maxFilesize = $errorCode === UPLOAD_ERR_INI_SIZE ? self::getMaxFilesize() / 1024 : 0; $maxFilesize = UPLOAD_ERR_INI_SIZE === $errorCode ? self::getMaxFilesize() / 1024 : 0;
$message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.'; $message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.';
return sprintf($message, $this->getClientOriginalName(), $maxFilesize); return sprintf($message, $this->getClientOriginalName(), $maxFilesize);

View File

@ -75,7 +75,7 @@ class IpUtils
if (false !== strpos($ip, '/')) { if (false !== strpos($ip, '/')) {
list($address, $netmask) = explode('/', $ip, 2); list($address, $netmask) = explode('/', $ip, 2);
if ($netmask === '0') { if ('0' === $netmask) {
return self::$checkedIps[$cacheKey] = filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); return self::$checkedIps[$cacheKey] = filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
} }

View File

@ -427,22 +427,22 @@ class Request
public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null) public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
{ {
$dup = clone $this; $dup = clone $this;
if ($query !== null) { if (null !== $query) {
$dup->query = new ParameterBag($query); $dup->query = new ParameterBag($query);
} }
if ($request !== null) { if (null !== $request) {
$dup->request = new ParameterBag($request); $dup->request = new ParameterBag($request);
} }
if ($attributes !== null) { if (null !== $attributes) {
$dup->attributes = new ParameterBag($attributes); $dup->attributes = new ParameterBag($attributes);
} }
if ($cookies !== null) { if (null !== $cookies) {
$dup->cookies = new ParameterBag($cookies); $dup->cookies = new ParameterBag($cookies);
} }
if ($files !== null) { if (null !== $files) {
$dup->files = new FileBag($files); $dup->files = new FileBag($files);
} }
if ($server !== null) { if (null !== $server) {
$dup->server = new ServerBag($server); $dup->server = new ServerBag($server);
$dup->headers = new HeaderBag($dup->server->getHeaders()); $dup->headers = new HeaderBag($dup->server->getHeaders());
} }
@ -971,7 +971,7 @@ class Request
} }
if ($host = $this->headers->get('HOST')) { if ($host = $this->headers->get('HOST')) {
if ($host[0] === '[') { if ('[' === $host[0]) {
$pos = strpos($host, ':', strrpos($host, ']')); $pos = strpos($host, ':', strrpos($host, ']'));
} else { } else {
$pos = strrpos($host, ':'); $pos = strrpos($host, ':');
@ -1036,7 +1036,7 @@ class Request
$scheme = $this->getScheme(); $scheme = $this->getScheme();
$port = $this->getPort(); $port = $this->getPort();
if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) { if (('http' == $scheme && 80 == $port) || ('https' == $scheme && 443 == $port)) {
return $this->getHost(); return $this->getHost();
} }
@ -1618,7 +1618,7 @@ class Request
} }
} else { } else {
for ($i = 0, $max = count($codes); $i < $max; ++$i) { for ($i = 0, $max = count($codes); $i < $max; ++$i) {
if ($i === 0) { if (0 === $i) {
$lang = strtolower($codes[0]); $lang = strtolower($codes[0]);
} else { } else {
$lang .= '_'.strtoupper($codes[$i]); $lang .= '_'.strtoupper($codes[$i]);
@ -1713,7 +1713,7 @@ class Request
// IIS with ISAPI_Rewrite // IIS with ISAPI_Rewrite
$requestUri = $this->headers->get('X_REWRITE_URL'); $requestUri = $this->headers->get('X_REWRITE_URL');
$this->headers->remove('X_REWRITE_URL'); $this->headers->remove('X_REWRITE_URL');
} elseif ($this->server->get('IIS_WasUrlRewritten') == '1' && $this->server->get('UNENCODED_URL') != '') { } elseif ('1' == $this->server->get('IIS_WasUrlRewritten') && '' != $this->server->get('UNENCODED_URL')) {
// IIS7 with URL Rewrite: make sure we get the unencoded URL (double slash problem) // IIS7 with URL Rewrite: make sure we get the unencoded URL (double slash problem)
$requestUri = $this->server->get('UNENCODED_URL'); $requestUri = $this->server->get('UNENCODED_URL');
$this->server->remove('UNENCODED_URL'); $this->server->remove('UNENCODED_URL');
@ -1722,7 +1722,7 @@ class Request
$requestUri = $this->server->get('REQUEST_URI'); $requestUri = $this->server->get('REQUEST_URI');
// HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path, only use URL path // HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path, only use URL path
$schemeAndHttpHost = $this->getSchemeAndHttpHost(); $schemeAndHttpHost = $this->getSchemeAndHttpHost();
if (strpos($requestUri, $schemeAndHttpHost) === 0) { if (0 === strpos($requestUri, $schemeAndHttpHost)) {
$requestUri = substr($requestUri, strlen($schemeAndHttpHost)); $requestUri = substr($requestUri, strlen($schemeAndHttpHost));
} }
} elseif ($this->server->has('ORIG_PATH_INFO')) { } elseif ($this->server->has('ORIG_PATH_INFO')) {
@ -1774,7 +1774,7 @@ class Request
// Does the baseUrl have anything in common with the request_uri? // Does the baseUrl have anything in common with the request_uri?
$requestUri = $this->getRequestUri(); $requestUri = $this->getRequestUri();
if ($requestUri !== '' && $requestUri[0] !== '/') { if ('' !== $requestUri && '/' !== $requestUri[0]) {
$requestUri = '/'.$requestUri; $requestUri = '/'.$requestUri;
} }
@ -1802,7 +1802,7 @@ class Request
// If using mod_rewrite or ISAPI_Rewrite strip the script filename // If using mod_rewrite or ISAPI_Rewrite strip the script filename
// out of baseUrl. $pos !== 0 makes sure it is not matching a value // out of baseUrl. $pos !== 0 makes sure it is not matching a value
// from PATH_INFO or QUERY_STRING // from PATH_INFO or QUERY_STRING
if (strlen($requestUri) >= strlen($baseUrl) && (false !== $pos = strpos($requestUri, $baseUrl)) && $pos !== 0) { if (strlen($requestUri) >= strlen($baseUrl) && (false !== $pos = strpos($requestUri, $baseUrl)) && 0 !== $pos) {
$baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl)); $baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl));
} }
@ -1852,7 +1852,7 @@ class Request
if (false !== $pos = strpos($requestUri, '?')) { if (false !== $pos = strpos($requestUri, '?')) {
$requestUri = substr($requestUri, 0, $pos); $requestUri = substr($requestUri, 0, $pos);
} }
if ($requestUri !== '' && $requestUri[0] !== '/') { if ('' !== $requestUri && '/' !== $requestUri[0]) {
$requestUri = '/'.$requestUri; $requestUri = '/'.$requestUri;
} }

View File

@ -173,6 +173,6 @@ class RequestMatcher implements RequestMatcherInterface
// Note to future implementors: add additional checks above the // Note to future implementors: add additional checks above the
// foreach above or else your check might not be run! // foreach above or else your check might not be run!
return count($this->ips) === 0; return 0 === count($this->ips);
} }
} }

View File

@ -1151,7 +1151,7 @@ class Response
$level = count($status); $level = count($status);
$flags = defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1; $flags = defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1;
while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || $flags === ($s['flags'] & $flags) : $s['del'])) { while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || ($s['flags'] & $flags) === $flags : $s['del'])) {
if ($flush) { if ($flush) {
ob_end_flush(); ob_end_flush();
} else { } else {
@ -1167,7 +1167,7 @@ class Response
*/ */
protected function ensureIEOverSSLCompatibility(Request $request) protected function ensureIEOverSSLCompatibility(Request $request)
{ {
if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) { if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && 1 == preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) && true === $request->isSecure()) {
if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) { if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) {
$this->headers->remove('Cache-Control'); $this->headers->remove('Cache-Control');
} }

View File

@ -68,7 +68,7 @@ class ServerBag extends ParameterBag
if (0 === stripos($authorizationHeader, 'basic ')) { if (0 === stripos($authorizationHeader, 'basic ')) {
// Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW when authorization header is basic // Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW when authorization header is basic
$exploded = explode(':', base64_decode(substr($authorizationHeader, 6)), 2); $exploded = explode(':', base64_decode(substr($authorizationHeader, 6)), 2);
if (count($exploded) == 2) { if (2 == count($exploded)) {
list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded; list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded;
} }
} elseif (empty($this->parameters['PHP_AUTH_DIGEST']) && (0 === stripos($authorizationHeader, 'digest '))) { } elseif (empty($this->parameters['PHP_AUTH_DIGEST']) && (0 === stripos($authorizationHeader, 'digest '))) {

View File

@ -109,7 +109,7 @@ class NamespacedAttributeBag extends AttributeBag
protected function &resolveAttributePath($name, $writeContext = false) protected function &resolveAttributePath($name, $writeContext = false)
{ {
$array = &$this->attributes; $array = &$this->attributes;
$name = (strpos($name, $this->namespaceCharacter) === 0) ? substr($name, 1) : $name; $name = (0 === strpos($name, $this->namespaceCharacter)) ? substr($name, 1) : $name;
// Check if there is anything to do, else return // Check if there is anything to do, else return
if (!$name) { if (!$name) {

View File

@ -103,7 +103,7 @@ class MemcachedSessionHandler implements \SessionHandlerInterface
{ {
$result = $this->memcached->delete($this->prefix.$sessionId); $result = $this->memcached->delete($this->prefix.$sessionId);
return $result || $this->memcached->getResultCode() == \Memcached::RES_NOTFOUND; return $result || \Memcached::RES_NOTFOUND == $this->memcached->getResultCode();
} }
/** /**

View File

@ -71,7 +71,7 @@ class MimeTypeTest extends TestCase
touch($path); touch($path);
@chmod($path, 0333); @chmod($path, 0333);
if (substr(sprintf('%o', fileperms($path)), -4) == '0333') { if ('0333' == substr(sprintf('%o', fileperms($path)), -4)) {
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException'); $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException');
MimeTypeGuesser::getInstance()->guess($path); MimeTypeGuesser::getInstance()->guess($path);
} else { } else {

View File

@ -1008,7 +1008,7 @@ class RequestTest extends TestCase
$req = new Request(array(), array(), array(), array(), array(), array(), 'MyContent'); $req = new Request(array(), array(), array(), array(), array(), array(), 'MyContent');
$resource = $req->getContent(true); $resource = $req->getContent(true);
$this->assertTrue(is_resource($resource)); $this->assertInternalType('resource', $resource);
$this->assertEquals('MyContent', stream_get_contents($resource)); $this->assertEquals('MyContent', stream_get_contents($resource));
} }

View File

@ -210,7 +210,7 @@ class Store implements StoreInterface
$entry[1]['vary'] = array(''); $entry[1]['vary'] = array('');
} }
if ($vary != $entry[1]['vary'][0] || !$this->requestsMatch($vary, $entry[0], $storedEnv)) { if ($entry[1]['vary'][0] != $vary || !$this->requestsMatch($vary, $entry[0], $storedEnv)) {
$entries[] = $entry; $entries[] = $entry;
} }
} }

View File

@ -728,7 +728,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
do { do {
$token = $tokens[++$i]; $token = $tokens[++$i];
$output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token; $output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token;
} while ($token[0] !== T_END_HEREDOC); } while (T_END_HEREDOC !== $token[0]);
$rawChunk = ''; $rawChunk = '';
} elseif (T_WHITESPACE === $token[0]) { } elseif (T_WHITESPACE === $token[0]) {
if ($ignoreSpace) { if ($ignoreSpace) {

View File

@ -53,11 +53,11 @@ abstract class BaseMemcacheProfilerStorage implements ProfilerStorageInterface
$result = array(); $result = array();
foreach ($profileList as $item) { foreach ($profileList as $item) {
if ($limit === 0) { if (0 === $limit) {
break; break;
} }
if ($item == '') { if ('' == $item) {
continue; continue;
} }
@ -119,7 +119,7 @@ abstract class BaseMemcacheProfilerStorage implements ProfilerStorageInterface
$profileList = explode("\n", $indexContent); $profileList = explode("\n", $indexContent);
foreach ($profileList as $item) { foreach ($profileList as $item) {
if ($item == '') { if ('' == $item) {
continue; continue;
} }

View File

@ -63,11 +63,11 @@ class RedisProfilerStorage implements ProfilerStorageInterface
$result = array(); $result = array();
foreach ($profileList as $item) { foreach ($profileList as $item) {
if ($limit === 0) { if (0 === $limit) {
break; break;
} }
if ($item == '') { if ('' == $item) {
continue; continue;
} }
@ -123,7 +123,7 @@ class RedisProfilerStorage implements ProfilerStorageInterface
$result = array(); $result = array();
foreach ($profileList as $item) { foreach ($profileList as $item) {
if ($item == '') { if ('' == $item) {
continue; continue;
} }
@ -209,7 +209,7 @@ class RedisProfilerStorage implements ProfilerStorageInterface
if (null === $this->redis) { if (null === $this->redis) {
$data = parse_url($this->dsn); $data = parse_url($this->dsn);
if (false === $data || !isset($data['scheme']) || $data['scheme'] !== 'redis' || !isset($data['host']) || !isset($data['port'])) { if (false === $data || !isset($data['scheme']) || 'redis' !== $data['scheme'] || !isset($data['host']) || !isset($data['port'])) {
throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Redis with an invalid dsn "%s". The minimal expected format is "redis://[host]:port".', $this->dsn)); throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Redis with an invalid dsn "%s". The minimal expected format is "redis://[host]:port".', $this->dsn));
} }

View File

@ -61,7 +61,7 @@ class GenrbCompiler implements BundleCompilerInterface
exec($this->genrb.' --quiet -e UTF-8 -d '.$targetDir.' '.$sourcePath, $output, $status); exec($this->genrb.' --quiet -e UTF-8 -d '.$targetDir.' '.$sourcePath, $output, $status);
if ($status !== 0) { if (0 !== $status) {
throw new RuntimeException(sprintf( throw new RuntimeException(sprintf(
'genrb failed with status %d while compiling %s to %s.', 'genrb failed with status %d while compiling %s to %s.',
$status, $status,

View File

@ -101,7 +101,7 @@ class TimeZoneTransformer extends Transformer
if (preg_match('/GMT(?P<signal>[+-])(?P<hours>\d{2}):?(?P<minutes>\d{2})/', $formattedTimeZone, $matches)) { if (preg_match('/GMT(?P<signal>[+-])(?P<hours>\d{2}):?(?P<minutes>\d{2})/', $formattedTimeZone, $matches)) {
$hours = (int) $matches['hours']; $hours = (int) $matches['hours'];
$minutes = (int) $matches['minutes']; $minutes = (int) $matches['minutes'];
$signal = $matches['signal'] == '-' ? '+' : '-'; $signal = '-' == $matches['signal'] ? '+' : '-';
if (0 < $minutes) { if (0 < $minutes) {
throw new NotImplementedException(sprintf( throw new NotImplementedException(sprintf(
@ -110,7 +110,7 @@ class TimeZoneTransformer extends Transformer
)); ));
} }
return 'Etc/GMT'.($hours !== 0 ? $signal.$hours : ''); return 'Etc/GMT'.(0 !== $hours ? $signal.$hours : '');
} }
throw new \InvalidArgumentException(sprintf('The GMT time zone "%s" does not match with the supported formats GMT[+-]HH:MM or GMT[+-]HHMM.', $formattedTimeZone)); throw new \InvalidArgumentException(sprintf('The GMT time zone "%s" does not match with the supported formats GMT[+-]HH:MM or GMT[+-]HHMM.', $formattedTimeZone));

View File

@ -31,7 +31,7 @@ class MethodArgumentValueNotImplementedException extends NotImplementedException
$methodName, $methodName,
$argName, $argName,
var_export($argValue, true), var_export($argValue, true),
$additionalMessage !== '' ? ' '.$additionalMessage.'. ' : '' '' !== $additionalMessage ? ' '.$additionalMessage.'. ' : ''
); );
parent::__construct($message); parent::__construct($message);

View File

@ -330,7 +330,7 @@ class NumberFormatter
*/ */
public function formatCurrency($value, $currency) public function formatCurrency($value, $currency)
{ {
if ($this->style == self::DECIMAL) { if (self::DECIMAL == $this->style) {
return $this->format($value); return $this->format($value);
} }
@ -369,13 +369,13 @@ class NumberFormatter
public function format($value, $type = self::TYPE_DEFAULT) public function format($value, $type = self::TYPE_DEFAULT)
{ {
// The original NumberFormatter does not support this format type // The original NumberFormatter does not support this format type
if ($type == self::TYPE_CURRENCY) { if (self::TYPE_CURRENCY == $type) {
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING); trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
return false; return false;
} }
if ($this->style == self::CURRENCY) { if (self::CURRENCY == $this->style) {
throw new NotImplementedException(sprintf( throw new NotImplementedException(sprintf(
'%s() method does not support the formatting of currencies (instance with CURRENCY style). %s', '%s() method does not support the formatting of currencies (instance with CURRENCY style). %s',
__METHOD__, NotImplementedException::INTL_INSTALL_MESSAGE __METHOD__, NotImplementedException::INTL_INSTALL_MESSAGE
@ -383,7 +383,7 @@ class NumberFormatter
} }
// Only the default type is supported. // Only the default type is supported.
if ($type != self::TYPE_DEFAULT) { if (self::TYPE_DEFAULT != $type) {
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'type', $type, 'Only TYPE_DEFAULT is supported'); throw new MethodArgumentValueNotImplementedException(__METHOD__, 'type', $type, 'Only TYPE_DEFAULT is supported');
} }
@ -526,7 +526,7 @@ class NumberFormatter
*/ */
public function parse($value, $type = self::TYPE_DOUBLE, &$position = 0) public function parse($value, $type = self::TYPE_DOUBLE, &$position = 0)
{ {
if ($type == self::TYPE_DEFAULT || $type == self::TYPE_CURRENCY) { if (self::TYPE_DEFAULT == $type || self::TYPE_CURRENCY == $type) {
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING); trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
return false; return false;
@ -773,7 +773,7 @@ class NumberFormatter
*/ */
private function getUninitializedPrecision($value, $precision) private function getUninitializedPrecision($value, $precision)
{ {
if ($this->style == self::CURRENCY) { if (self::CURRENCY == $this->style) {
return $precision; return $precision;
} }
@ -809,11 +809,11 @@ class NumberFormatter
*/ */
private function convertValueDataType($value, $type) private function convertValueDataType($value, $type)
{ {
if ($type == self::TYPE_DOUBLE) { if (self::TYPE_DOUBLE == $type) {
$value = (float) $value; $value = (float) $value;
} elseif ($type == self::TYPE_INT32) { } elseif (self::TYPE_INT32 == $type) {
$value = $this->getInt32Value($value); $value = $this->getInt32Value($value);
} elseif ($type == self::TYPE_INT64) { } elseif (self::TYPE_INT64 == $type) {
$value = $this->getInt64Value($value); $value = $this->getInt64Value($value);
} }

View File

@ -676,7 +676,7 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest
*/ */
public function testGetFractionDigits($currency) public function testGetFractionDigits($currency)
{ {
$this->assertTrue(is_numeric($this->dataProvider->getFractionDigits($currency))); $this->assertInternalType('numeric', $this->dataProvider->getFractionDigits($currency));
} }
/** /**
@ -684,7 +684,7 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest
*/ */
public function testGetRoundingIncrement($currency) public function testGetRoundingIncrement($currency)
{ {
$this->assertTrue(is_numeric($this->dataProvider->getRoundingIncrement($currency))); $this->assertInternalType('numeric', $this->dataProvider->getRoundingIncrement($currency));
} }
public function provideCurrenciesWithNumericEquivalent() public function provideCurrenciesWithNumericEquivalent()

View File

@ -621,7 +621,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
$this->assertSame($expected, $parsedValue, $message); $this->assertSame($expected, $parsedValue, $message);
$this->assertSame($expectedPosition, $position, $message); $this->assertSame($expectedPosition, $position, $message);
if ($expected === false) { if (false === $expected) {
$errorCode = IntlGlobals::U_PARSE_ERROR; $errorCode = IntlGlobals::U_PARSE_ERROR;
$errorMessage = 'Number parsing failed: U_PARSE_ERROR'; $errorMessage = 'Number parsing failed: U_PARSE_ERROR';
} else { } else {
@ -631,10 +631,10 @@ abstract class AbstractNumberFormatterTest extends TestCase
$this->assertSame($errorMessage, $this->getIntlErrorMessage()); $this->assertSame($errorMessage, $this->getIntlErrorMessage());
$this->assertSame($errorCode, $this->getIntlErrorCode()); $this->assertSame($errorCode, $this->getIntlErrorCode());
$this->assertSame($errorCode !== 0, $this->isIntlFailure($this->getIntlErrorCode())); $this->assertSame(0 !== $errorCode, $this->isIntlFailure($this->getIntlErrorCode()));
$this->assertSame($errorMessage, $formatter->getErrorMessage()); $this->assertSame($errorMessage, $formatter->getErrorMessage());
$this->assertSame($errorCode, $formatter->getErrorCode()); $this->assertSame($errorCode, $formatter->getErrorCode());
$this->assertSame($errorCode !== 0, $this->isIntlFailure($formatter->getErrorCode())); $this->assertSame(0 !== $errorCode, $this->isIntlFailure($formatter->getErrorCode()));
} }
public function parseProvider() public function parseProvider()

View File

@ -50,7 +50,7 @@ class SvnRepository
{ {
exec('which svn', $output, $result); exec('which svn', $output, $result);
if ($result !== 0) { if (0 !== $result) {
throw new RuntimeException('The command "svn" is not installed.'); throw new RuntimeException('The command "svn" is not installed.');
} }
@ -62,7 +62,7 @@ class SvnRepository
exec('svn checkout '.$url.' '.$targetDir, $output, $result); exec('svn checkout '.$url.' '.$targetDir, $output, $result);
if ($result !== 0) { if (0 !== $result) {
throw new RuntimeException('The SVN checkout of '.$url.'failed.'); throw new RuntimeException('The SVN checkout of '.$url.'failed.');
} }
} }
@ -128,7 +128,7 @@ class SvnRepository
$svnInfo = simplexml_load_string(implode("\n", $output)); $svnInfo = simplexml_load_string(implode("\n", $output));
if ($result !== 0) { if (0 !== $result) {
throw new RuntimeException('svn info failed'); throw new RuntimeException('svn info failed');
} }

View File

@ -45,12 +45,12 @@ class ProcessTimedOutException extends RuntimeException
public function isGeneralTimeout() public function isGeneralTimeout()
{ {
return $this->timeoutType === self::TYPE_GENERAL; return self::TYPE_GENERAL === $this->timeoutType;
} }
public function isIdleTimeout() public function isIdleTimeout()
{ {
return $this->timeoutType === self::TYPE_IDLE; return self::TYPE_IDLE === $this->timeoutType;
} }
public function getExceededTimeout() public function getExceededTimeout()

View File

@ -713,7 +713,7 @@ class Process
*/ */
public function isStarted() public function isStarted()
{ {
return $this->status != self::STATUS_READY; return self::STATUS_READY != $this->status;
} }
/** /**
@ -725,7 +725,7 @@ class Process
{ {
$this->updateStatus(false); $this->updateStatus(false);
return $this->status == self::STATUS_TERMINATED; return self::STATUS_TERMINATED == $this->status;
} }
/** /**
@ -1187,7 +1187,7 @@ class Process
*/ */
public function checkTimeout() public function checkTimeout()
{ {
if ($this->status !== self::STATUS_STARTED) { if (self::STATUS_STARTED !== $this->status) {
return; return;
} }
@ -1368,7 +1368,7 @@ class Process
$callback = $this->callback; $callback = $this->callback;
foreach ($result as $type => $data) { foreach ($result as $type => $data) {
if (3 !== $type) { if (3 !== $type) {
$callback($type === self::STDOUT ? self::OUT : self::ERR, $data); $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
} elseif (!isset($this->fallbackStatus['signaled'])) { } elseif (!isset($this->fallbackStatus['signaled'])) {
$this->fallbackStatus['exitcode'] = (int) $data; $this->fallbackStatus['exitcode'] = (int) $data;
} }

View File

@ -336,7 +336,7 @@ class ProcessTest extends TestCase
$called = false; $called = false;
$p->run(function ($type, $buffer) use (&$called) { $p->run(function ($type, $buffer) use (&$called) {
$called = $buffer === 'foo'; $called = 'foo' === $buffer;
}); });
$this->assertTrue($called, 'The callback should be executed with the output'); $this->assertTrue($called, 'The callback should be executed with the output');
@ -731,8 +731,8 @@ class ProcessTest extends TestCase
// Ensure that both processed finished and the output is numeric // Ensure that both processed finished and the output is numeric
$this->assertFalse($process1->isRunning()); $this->assertFalse($process1->isRunning());
$this->assertFalse($process2->isRunning()); $this->assertFalse($process2->isRunning());
$this->assertTrue(is_numeric($process1->getOutput())); $this->assertInternalType('numeric', $process1->getOutput());
$this->assertTrue(is_numeric($process2->getOutput())); $this->assertInternalType('numeric', $process2->getOutput());
// Ensure that restart returned a new process by check that the output is different // Ensure that restart returned a new process by check that the output is different
$this->assertNotEquals($process1->getOutput(), $process2->getOutput()); $this->assertNotEquals($process1->getOutput(), $process2->getOutput());

View File

@ -27,7 +27,7 @@ class UnexpectedTypeException extends RuntimeException
*/ */
public function __construct($value, $path, $pathIndex = null) public function __construct($value, $path, $pathIndex = null)
{ {
if (func_num_args() === 3 && $path instanceof PropertyPathInterface) { if (3 === func_num_args() && $path instanceof PropertyPathInterface) {
$message = sprintf( $message = sprintf(
'PropertyAccessor requires a graph of objects or arrays to operate on, '. 'PropertyAccessor requires a graph of objects or arrays to operate on, '.
'but it found type "%s" while trying to traverse path "%s" at property "%s".', 'but it found type "%s" while trying to traverse path "%s" at property "%s".',

View File

@ -225,11 +225,11 @@ EOF;
$supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods)); $supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods));
if (!count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\^(?P<url>.*?)\$\1#', $compiledRoute->getRegex(), $m)) { if (!count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\^(?P<url>.*?)\$\1#', $compiledRoute->getRegex(), $m)) {
if ($supportsTrailingSlash && substr($m['url'], -1) === '/') { if ($supportsTrailingSlash && '/' === substr($m['url'], -1)) {
$conditions[] = sprintf("rtrim(\$pathinfo, '/') === %s", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true)); $conditions[] = sprintf("%s === rtrim(\$pathinfo, '/')", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true));
$hasTrailingSlash = true; $hasTrailingSlash = true;
} else { } else {
$conditions[] = sprintf('$pathinfo === %s', var_export(str_replace('\\', '', $m['url']), true)); $conditions[] = sprintf('%s === $pathinfo', var_export(str_replace('\\', '', $m['url']), true));
} }
} else { } else {
if ($compiledRoute->getStaticPrefix() && $compiledRoute->getStaticPrefix() !== $parentPrefix) { if ($compiledRoute->getStaticPrefix() && $compiledRoute->getStaticPrefix() !== $parentPrefix) {

View File

@ -60,17 +60,17 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
if (0 === strpos($pathinfo, '/test')) { if (0 === strpos($pathinfo, '/test')) {
if (0 === strpos($pathinfo, '/test/baz')) { if (0 === strpos($pathinfo, '/test/baz')) {
// baz // baz
if ($pathinfo === '/test/baz') { if ('/test/baz' === $pathinfo) {
return array('_route' => 'baz'); return array('_route' => 'baz');
} }
// baz2 // baz2
if ($pathinfo === '/test/baz.html') { if ('/test/baz.html' === $pathinfo) {
return array('_route' => 'baz2'); return array('_route' => 'baz2');
} }
// baz3 // baz3
if ($pathinfo === '/test/baz3/') { if ('/test/baz3/' === $pathinfo) {
return array('_route' => 'baz3'); return array('_route' => 'baz3');
} }
@ -106,7 +106,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
} }
// foofoo // foofoo
if ($pathinfo === '/foofoo') { if ('/foofoo' === $pathinfo) {
return array ( 'def' => 'test', '_route' => 'foofoo',); return array ( 'def' => 'test', '_route' => 'foofoo',);
} }
@ -116,7 +116,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
} }
// space // space
if ($pathinfo === '/spa ce') { if ('/spa ce' === $pathinfo) {
return array('_route' => 'space'); return array('_route' => 'space');
} }
@ -161,12 +161,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
} }
// overridden2 // overridden2
if ($pathinfo === '/multi/new') { if ('/multi/new' === $pathinfo) {
return array('_route' => 'overridden2'); return array('_route' => 'overridden2');
} }
// hey // hey
if ($pathinfo === '/multi/hey/') { if ('/multi/hey/' === $pathinfo) {
return array('_route' => 'hey'); return array('_route' => 'hey');
} }
@ -184,7 +184,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
if (0 === strpos($pathinfo, '/aba')) { if (0 === strpos($pathinfo, '/aba')) {
// ababa // ababa
if ($pathinfo === '/ababa') { if ('/ababa' === $pathinfo) {
return array('_route' => 'ababa'); return array('_route' => 'ababa');
} }
@ -199,12 +199,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
// route1 // route1
if ($pathinfo === '/route1') { if ('/route1' === $pathinfo) {
return array('_route' => 'route1'); return array('_route' => 'route1');
} }
// route2 // route2
if ($pathinfo === '/c2/route2') { if ('/c2/route2' === $pathinfo) {
return array('_route' => 'route2'); return array('_route' => 'route2');
} }
@ -212,7 +212,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) { if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) {
// route3 // route3
if ($pathinfo === '/c2/route3') { if ('/c2/route3' === $pathinfo) {
return array('_route' => 'route3'); return array('_route' => 'route3');
} }
@ -220,7 +220,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
// route4 // route4
if ($pathinfo === '/route4') { if ('/route4' === $pathinfo) {
return array('_route' => 'route4'); return array('_route' => 'route4');
} }
@ -228,26 +228,26 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
// route5 // route5
if ($pathinfo === '/route5') { if ('/route5' === $pathinfo) {
return array('_route' => 'route5'); return array('_route' => 'route5');
} }
} }
// route6 // route6
if ($pathinfo === '/route6') { if ('/route6' === $pathinfo) {
return array('_route' => 'route6'); return array('_route' => 'route6');
} }
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) { if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) {
if (0 === strpos($pathinfo, '/route1')) { if (0 === strpos($pathinfo, '/route1')) {
// route11 // route11
if ($pathinfo === '/route11') { if ('/route11' === $pathinfo) {
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ()); return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ());
} }
// route12 // route12
if ($pathinfo === '/route12') { if ('/route12' === $pathinfo) {
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',)); return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',));
} }
@ -280,7 +280,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
} }
// route17 // route17
if ($pathinfo === '/route17') { if ('/route17' === $pathinfo) {
return array('_route' => 'route17'); return array('_route' => 'route17');
} }
@ -288,7 +288,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
if (0 === strpos($pathinfo, '/a')) { if (0 === strpos($pathinfo, '/a')) {
// a // a
if ($pathinfo === '/a/a...') { if ('/a/a...' === $pathinfo) {
return array('_route' => 'a'); return array('_route' => 'a');
} }

Some files were not shown because too many files have changed in this diff Show More