Global variable or function should never be used

  • Major
  • Architecture

More information: https://insight.sensiolabs.com/what-we-analyse/php.use_global_variable_or_function

  1. if (!function_exists('dump')) {
  2. /**
  3. * @author Nicolas Grekas <p@tchwork.com>
  4. */
  5. function dump($var, ...$moreVars)

    dump() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by Robin Chalas
  6. {
  7. VarDumper::dump($var);
  8. foreach ($moreVars as $var) {
  9. VarDumper::dump($var);

PHP configuration should not be changed dynamically 19

  • Major
  • Bugrisk

More information: https://insight.sensiolabs.com/what-we-analyse/php.dynamically_change_configuration

  1. protected static function unserialize($value)
  2. {
  3. if ('b:0;' === $value) {
  4. return false;
  5. }
  6. $unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback');

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. try {
  8. if (false !== $value = unserialize($value)) {
  9. return $value;
  10. }
  11. throw new \DomainException('Failed to unserialize cached value');
  1. }
  2. throw new \DomainException('Failed to unserialize cached value');
  3. } catch (\Error $e) {
  4. throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
  5. } finally {
  6. ini_set('unserialize_callback_func', $unserializeCallbackHandler);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. }
  8. }
  9. private function getId($key)
  10. {
  1. {
  2. if (!static::isSupported()) {
  3. throw new CacheException('APCu is not enabled');
  4. }
  5. if ('cli' === PHP_SAPI) {
  6. ini_set('apc.use_request_time', 0);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. }
  8. parent::__construct($namespace, $defaultLifetime);
  9. if (null !== $version) {
  10. CacheItem::validateKey($version);
  1. /**
  2. * {@inheritdoc}
  3. */
  4. protected function doFetch(array $ids)
  5. {
  6. $unserializeCallbackHandler = ini_set('unserialize_callback_func', parent::class.'::handleUnserializeCallback');

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. try {
  8. return $this->provider->fetchMultiple($ids);
  9. } catch (\Error $e) {
  10. $trace = $e->getTrace();
  1. }
  2. }
  3. throw $e;
  4. } finally {
  5. ini_set('unserialize_callback_func', $unserializeCallbackHandler);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. }
  7. }
  8. /**
  9. * {@inheritdoc}
  1. /**
  2. * {@inheritdoc}
  3. */
  4. protected function doFetch(array $ids)
  5. {
  6. $unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback');

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. try {
  8. return $this->checkResultCode($this->getClient()->getMulti($ids));
  9. } catch (\Error $e) {
  10. throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
  11. } finally {
  1. try {
  2. return $this->checkResultCode($this->getClient()->getMulti($ids));
  3. } catch (\Error $e) {
  4. throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
  5. } finally {
  6. ini_set('unserialize_callback_func', $unserializeCallbackHandler);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. }
  8. }
  9. /**
  10. * {@inheritdoc}
  1. * Load the cache file.
  2. */
  3. private function initialize()
  4. {
  5. if ($this->zendDetectUnicode) {
  6. $zmb = ini_set('zend.detect_unicode', 0);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. }
  8. try {
  9. $this->values = file_exists($this->file) ? (include $this->file ?: array()) : array();
  10. } finally {
  11. if ($this->zendDetectUnicode) {
  1. }
  2. try {
  3. $this->values = file_exists($this->file) ? (include $this->file ?: array()) : array();
  4. } finally {
  5. if ($this->zendDetectUnicode) {
  6. ini_set('zend.detect_unicode', $zmb);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. }
  8. }
  9. }
  10. }
  1. {
  2. $values = array();
  3. $now = time();
  4. if ($this->zendDetectUnicode) {
  5. $zmb = ini_set('zend.detect_unicode', 0);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. }
  7. set_error_handler($this->includeHandler);
  8. try {
  9. foreach ($ids as $id) {
  10. try {
  1. }
  2. }
  3. } finally {
  4. restore_error_handler();
  5. if ($this->zendDetectUnicode) {
  6. ini_set('zend.detect_unicode', $zmb);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. }
  8. }
  9. foreach ($values as $id => $value) {
  10. if ('N;' === $value) {
  1. private function safelyUnserialize($file)
  2. {
  3. $e = null;
  4. $meta = false;
  5. $signalingException = new \UnexpectedValueException();
  6. $prevUnserializeHandler = ini_set('unserialize_callback_func', '');

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Matthias Pigulla
  7. $prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context) use (&$prevErrorHandler, $signalingException) {
  8. if (E_WARNING === $type && 'Class __PHP_Incomplete_Class has no unserializer' === $msg) {
  9. throw $signalingException;
  10. }
  1. $meta = unserialize(file_get_contents($file));
  2. } catch (\Error $e) {
  3. } catch (\Exception $e) {
  4. }
  5. restore_error_handler();
  6. ini_set('unserialize_callback_func', $prevUnserializeHandler);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Matthias Pigulla
  7. if (null !== $e && $e !== $signalingException) {
  8. throw $e;
  9. }
  10. return $meta;
  1. } else {
  2. error_reporting(E_ALL);
  3. }
  4. if ('cli' !== PHP_SAPI) {
  5. ini_set('display_errors', 0);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. ExceptionHandler::register();
  7. } elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) {
  8. // CLI - display errors only if they're not already logged to STDERR
  9. ini_set('display_errors', 1);
  10. }
  1. if ('cli' !== PHP_SAPI) {
  2. ini_set('display_errors', 0);
  3. ExceptionHandler::register();
  4. } elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) {
  5. // CLI - display errors only if they're not already logged to STDERR
  6. ini_set('display_errors', 1);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Fabien Potencier
  7. }
  8. if ($displayErrors) {
  9. ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
  10. } else {
  11. ErrorHandler::register()->throwAt(0, true);
  1. if ($baseDir && !is_dir($baseDir) && !@mkdir($baseDir, 0777, true) && !is_dir($baseDir)) {
  2. throw new \RuntimeException(sprintf('Session Storage was not able to create directory "%s"', $baseDir));
  3. }
  4. ini_set('session.save_path', $savePath);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Drak
  5. ini_set('session.save_handler', 'files');
  6. }
  7. }
  1. if ($baseDir && !is_dir($baseDir) && !@mkdir($baseDir, 0777, true) && !is_dir($baseDir)) {
  2. throw new \RuntimeException(sprintf('Session Storage was not able to create directory "%s"', $baseDir));
  3. }
  4. ini_set('session.save_path', $savePath);
  5. ini_set('session.save_handler', 'files');

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Drak
  6. }
  7. }
  1. if (headers_sent()) {
  2. return false;
  3. }
  4. if (null !== $lifetime) {
  5. ini_set('session.cookie_lifetime', $lifetime);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Drak
  6. }
  7. if ($destroy) {
  8. $this->metadataBag->stampNew();
  9. }
  1. 'sid_length', 'sid_bits_per_character', 'trans_sid_hosts', 'trans_sid_tags',
  2. ));
  3. foreach ($options as $key => $value) {
  4. if (isset($validOptions[$key])) {
  5. ini_set('session.'.$key, $value);

    Changing PHP configuration dynamically through ini_set() may create hard to debug errors.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Drak
  6. }
  7. }
  8. }
  9. /**

Missing use statement should be avoided

  • Major
  • Bugrisk

More information: https://insight.sensiolabs.com/what-we-analyse/php.missing_use_statement

  1. {
  2. return $this->decisionLog;
  3. }
  4. }
  5. class_alias(TraceableAccessDecisionManager::class, DebugAccessDecisionManager::class);

    The DebugAccessDecisionManager class resolves to the Symfony\Component\Security\Core\Authorization\DebugAccessDecisionManager class which PHP does not seem to be able to autoload.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Alessandro Lai

exit() and die() functions should be avoided 9

  • Major
  • Bugrisk

More information: https://insight.sensiolabs.com/what-we-analyse/php.use_exit_function

  1. <?php
  2. if (3 > $_SERVER['argc']) {
  3. echo "Usage: branch dir1 dir2 ... dirN\n";
  4. exit(1);

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. }
  6. chdir(dirname(__DIR__));
  7. $dirs = $_SERVER['argv'];
  8. array_shift($dirs);
  1. $flags = \PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0;
  2. foreach ($dirs as $k => $dir) {
  3. if (!system("git diff --name-only $mergeBase -- $dir", $exitStatus)) {
  4. if ($exitStatus) {
  5. exit($exitStatus);

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. }
  7. unset($dirs[$k]);
  8. continue;
  9. }
  10. echo "$dir\n";
  1. echo "$dir\n";
  2. $json = ltrim(file_get_contents($dir.'/composer.json'));
  3. if (null === $package = json_decode($json)) {
  4. passthru("composer validate $dir/composer.json");
  5. exit(1);

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. }
  7. $package->repositories = array(array(
  8. 'type' => 'composer',
  9. 'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/',
  1. }
  2. passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *");
  3. if (!isset($package->extra->{'branch-alias'}->{'dev-master'})) {
  4. echo "Missing \"dev-master\" branch-alias in composer.json extra.\n";
  5. exit(1);

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. }
  7. $package->version = str_replace('-dev', '.x-dev', $package->extra->{'branch-alias'}->{'dev-master'});
  8. $package->dist['type'] = 'tar';
  9. $package->dist['url'] = 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__))."/$dir/package.tar";
  1. if ($dirs) {
  2. $json = ltrim(file_get_contents('composer.json'));
  3. if (null === $package = json_decode($json)) {
  4. passthru("composer validate $dir/composer.json");
  5. exit(1);

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. }
  7. $package->repositories = array(array(
  8. 'type' => 'composer',
  9. 'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/',
  1. echo "\n".$msg;
  2. echo "\nStack trace:";
  3. echo "\n".str_replace(' '.getcwd().DIRECTORY_SEPARATOR, ' ', $e->getTraceAsString());
  4. echo "\n";
  5. exit(1);

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. }
  7. if ('legacy' !== $group && !$isWeak) {
  8. $ref = &$deprecations[$group][$msg]['count'];
  9. ++$ref;
  10. $ref = &$deprecations[$group][$msg][$class.'::'.$method];
  1. if (!empty($notices)) {
  2. echo "\n";
  3. }
  4. if (DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) {
  5. exit(1);

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. }
  7. });
  8. }
  9. }
  1. if ($this->autoExit) {
  2. if ($exitCode > 255) {
  3. $exitCode = 255;
  4. }
  5. exit($exitCode);

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Fabien Potencier
  6. }
  7. return $exitCode;
  8. }
  1. // Ignore this re-throw
  2. }
  3. if ($exit && self::$exitCode) {
  4. $exitCode = self::$exitCode;
  5. register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. }
  7. }
  8. /**
  9. * Gets the fatal error handlers.

Source code should not contain FIXME comments 2

  • Major
  • Bugrisk

More information: https://insight.sensiolabs.com/what-we-analyse/task_fixme_comment

  1. /**
  2. * {@inheritdoc}
  3. */
  4. public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
  5. {
  6. // FIXME: catch exceptions and implement a 500 error page here? -> in Varnish, there is a built-in error page mechanism

    FIXME comments are left in the code when a bug has been noticed but not fixed. You should fix the bug and remove the comment.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by pborreli
  7. if (HttpKernelInterface::MASTER_REQUEST === $type) {
  8. $this->traces = array();
  9. $this->request = $request;
  10. if (null !== $this->surrogate) {
  11. $this->surrogateCacheStrategy = $this->surrogate->createCacheStrategy();
  1. Request::setTrustedProxies($trustedProxies, Request::HEADER_X_FORWARDED_ALL);
  2. }
  3. // always a "master" request (as the real master request can be in cache)
  4. $response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $catch);
  5. // FIXME: we probably need to also catch exceptions if raw === true

    FIXME comments are left in the code when a bug has been noticed but not fixed. You should fix the bug and remove the comment.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Fabien Potencier
  6. // we don't implement the stale-if-error on Requests, which is nonetheless part of the RFC
  7. if (null !== $entry && in_array($response->getStatusCode(), array(500, 502, 503, 504))) {
  8. if (null === $age = $entry->headers->getCacheControlDirective('stale-if-error')) {
  9. $age = $this->options['stale_if_error'];

sleep() should not be used

  • Major
  • Performance

More information: https://insight.sensiolabs.com/what-we-analyse/php.use_php_sleep_function

  1. while ($process->isRunning()) {
  2. if (!file_exists($pidFile)) {
  3. $process->stop();
  4. }
  5. sleep(1);

    sleep() may create timeouts without even protecting your application.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Fabien Potencier
  6. }
  7. return self::STOPPED;
  8. }

Code should not be duplicated 8

  • Minor
  • Architecture

More information: https://insight.sensiolabs.com/what-we-analyse/php.duplicated_code

  1. if (!$event->isMasterRequest()) {
  2. return;
  3. }
  4. if (!preg_match(static::USER_AGENT_REGEX, $event->getRequest()->headers->get('User-Agent'))) {
  5. $this->sendHeaders = false;

    The next 35 lines appear both in src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php:42 and src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php:43.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Christophe Coevoet
  6. $this->headers = array();
  7. return;
  8. }
  1. public function commit()
  2. {
  3. $event = $this->start(__FUNCTION__);
  4. try {
  5. return $event->result = $this->pool->commit();
  6. } finally {

    The next 43 lines appear both in src/Symfony/Component/Cache/Adapter/TraceableAdapter.php:168 and src/Symfony/Component/Cache/Simple/TraceableCache.php:177.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Tobias Nyholm
  7. $event->end = microtime(true);
  8. }
  9. }
  10. /**
  1. $this->dsn = $connOrDsn;
  2. } else {
  3. throw new InvalidArgumentException(sprintf('"%s" requires PDO or Doctrine\DBAL\Connection instance or DSN string as first argument, "%s" given.', __CLASS__, is_object($connOrDsn) ? get_class($connOrDsn) : gettype($connOrDsn)));
  4. }
  5. $this->table = isset($options['db_table']) ? $options['db_table'] : $this->table;

    The next 9 lines appear both in src/Symfony/Component/Cache/Traits/PdoTrait.php:59 and src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php:185.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. $this->idCol = isset($options['db_id_col']) ? $options['db_id_col'] : $this->idCol;
  7. $this->dataCol = isset($options['db_data_col']) ? $options['db_data_col'] : $this->dataCol;
  8. $this->lifetimeCol = isset($options['db_lifetime_col']) ? $options['db_lifetime_col'] : $this->lifetimeCol;
  9. $this->timeCol = isset($options['db_time_col']) ? $options['db_time_col'] : $this->timeCol;
  10. $this->username = isset($options['db_username']) ? $options['db_username'] : $this->username;
  1. }
  2. /**
  3. * {@inheritdoc}
  4. */
  5. protected function getCasters()

    The next 17 lines appear both in src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php:245 and src/Symfony/Component/Validator/DataCollector/ValidatorDataCollector.php:90.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. {
  7. return parent::getCasters() + array(
  8. \Exception::class => function (\Exception $e, array $a, Stub $s) {
  9. foreach (array("\0Exception\0previous", "\0Exception\0trace") as $k) {
  10. if (isset($a[$k])) {
  1. }
  2. /**
  3. * {@inheritdoc}
  4. */
  5. protected function requiresAuthentication(Request $request)

    The next 35 lines appear both in src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php:65 and src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php:57.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Jordi Boggiano
  6. {
  7. if ($this->options['post_only'] && !$request->isMethod('POST')) {
  8. return false;
  9. }
  1. * @author Kévin Dunglas <dunglas@gmail.com>
  2. */
  3. class GetSetMethodNormalizer extends AbstractObjectNormalizer
  4. {
  5. private static $setterAccessibleCache = array();
  6. private $cache = array();

    The next 24 lines appear both in src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php:38 and src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php:33.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. /**
  8. * {@inheritdoc}
  9. */
  10. public function supportsNormalization($data, $format = null)
  1. libxml_use_internal_errors(false);
  2. return array('file' => $file, 'valid' => false, 'messages' => $errorMessages);
  3. }
  4. private function display(SymfonyStyle $io, array $files)

    The next 24 lines appear both in src/Symfony/Component/Translation/Command/XliffLintCommand.php:131 and src/Symfony/Component/Yaml/Command/LintCommand.php:128.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Javier Eguiluz
  5. {
  6. switch ($this->format) {
  7. case 'txt':
  8. return $this->displayTxt($io, $files);
  9. case 'json':
  1. $this->assertions = $assertions;
  2. }
  3. public function atPath($path)
  4. {
  5. $this->propertyPath = $path;

    The next 55 lines appear both in src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php:246 and src/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php:64.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by WouterJ
  6. return $this;
  7. }
  8. public function setParameter($key, $value)

Source code should not contain TODO comments 6

  • Minor
  • Architecture

More information: https://insight.sensiolabs.com/what-we-analyse/task_todo_comment

  1. list($req, $headers) = $match;
  2. if (file_exists($body = $this->getPath($headers['x-content-digest'][0]))) {
  3. return $this->restoreResponse($headers, $body);
  4. }
  5. // TODO the metaStore referenced an entity that doesn't exist in

    TODO comments are left in the code when a feature (or a bug) isn't completely developed (or fixed). You should complete the implementation and remove the comment.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Pascal Borreli
  6. // the entityStore. We definitely want to return nil but we should
  7. // also purge the entry from the meta-store when this is detected.
  8. }
  9. /**
  1. $conditions[] = sprintf('(%s) mod %d = 0', $expr, $a);
  2. }
  3. return $xpath->addCondition(implode(' and ', $conditions));
  4. // todo: handle an+b, odd, even

    TODO comments are left in the code when a feature (or a bug) isn't completely developed (or fixed). You should complete the implementation and remove the comment.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Jean-François Simon
  5. // an+b means every-a, plus b, e.g., 2n+1 means odd
  6. // 0n+b means b
  7. // n+0 means a=1, i.e., all elements
  8. // an means every a elements, i.e., 2n means even
  9. // -n means -1n
  1. ." or name(.) = 'select'"
  2. ." or name(.) = 'textarea'"
  3. .')'
  4. .' and ancestor::fieldset[@disabled]'
  5. );
  6. // todo: in the second half, add "and is not a descendant of that fieldset element's first legend element child, if any."

    TODO comments are left in the code when a feature (or a bug) isn't completely developed (or fixed). You should complete the implementation and remove the comment.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Jean-François Simon
  7. }
  8. /**
  9. * @return XPathExpr
  10. */
  1. *
  2. * @return \PDOStatement The statement that needs to be executed later to release the lock
  3. *
  4. * @throws \DomainException When an unsupported PDO driver is used
  5. *
  6. * @todo implement missing advisory locks

    TODO comments are left in the code when a feature (or a bug) isn't completely developed (or fixed). You should complete the implementation and remove the comment.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Tobias Schultze
  7. * - for oci using DBMS_LOCK.REQUEST
  8. * - for sqlsrv using sp_getapplock with LockOwner = Session
  9. */
  10. private function doAdvisoryLock(string $sessionId)
  11. {
  1. if (!$rootNode && XML_PI_NODE !== $child->nodeType) {
  2. $rootNode = $child;
  3. }
  4. }
  5. // todo: throw an exception if the root node name is not correctly configured (bc)

    TODO comments are left in the code when a feature (or a bug) isn't completely developed (or fixed). You should complete the implementation and remove the comment.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Charles Sarrazin
  6. if ($rootNode->hasChildNodes()) {
  7. $xpath = new \DOMXPath($dom);
  8. $data = array();
  9. foreach ($xpath->query('namespace::*', $dom->documentElement) as $nsNode) {
  1. $flags = array();
  2. } elseif ('#,' === substr($line, 0, 2)) {
  3. $flags = array_map('trim', explode(',', substr($line, 2)));
  4. } elseif ('msgid "' === substr($line, 0, 7)) {
  5. // We start a new msg so save previous
  6. // TODO: this fails when comments or contexts are added

    TODO comments are left in the code when a feature (or a bug) isn't completely developed (or fixed). You should complete the implementation and remove the comment.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Clemens Tolboom
  7. $this->addMessage($messages, $item);
  8. $item = $defaults;
  9. $item['ids']['singular'] = substr($line, 7, -1);
  10. } elseif ('msgstr "' === substr($line, 0, 8)) {
  11. $item['translated'] = substr($line, 8, -1);

Source code should not contain XXX comments

  • Minor
  • Architecture

More information: https://insight.sensiolabs.com/what-we-analyse/task_xxx_comment

  1. // In some circumstances PHP_AUTH_DIGEST needs to be set
  2. $headers['PHP_AUTH_DIGEST'] = $authorizationHeader;
  3. $this->parameters['PHP_AUTH_DIGEST'] = $authorizationHeader;
  4. } elseif (0 === stripos($authorizationHeader, 'bearer ')) {
  5. /*
  6. * XXX: Since there is no PHP_AUTH_BEARER in PHP predefined variables,

    XXX comments are left in the code when a piece of code needs refactoring. You should improve the implementation and remove the comment.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by Lance Chen
  7. * I'll just set $headers['AUTHORIZATION'] here.
  8. * http://php.net/manual/en/reserved.variables.server.php
  9. */
  10. $headers['AUTHORIZATION'] = $authorizationHeader;
  11. }

Error silenced by the at sign (@) 42

  • Minor
  • Bugrisk

More information: https://insight.sensiolabs.com/what-we-analyse/php.silenced_error

  1. if ($time >= $expiresAt) {
  2. $pruned = @unlink($file) && !file_exists($file) && $pruned;
  3. if ($allowCompile) {
  4. @opcache_invalidate($file, true);

    Adding "@" before opcache_invalidate($file, true) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Rob Frawley 2nd
  5. }
  6. }
  7. }
  8. } finally {
  9. restore_error_handler();
  1. $data[1] = $value;
  2. $file = $this->getFile($key, true);
  3. $ok = $this->write($file, '<?php return '.var_export($data, true).';') && $ok;
  4. if ($allowCompile) {
  5. @opcache_invalidate($file, true);

    Adding "@" before opcache_invalidate($file, true) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Fabien Potencier
  6. }
  7. }
  8. if (!$ok && !is_writable($this->directory)) {
  9. throw new CacheException(sprintf('Cache directory is not writable (%s)', $this->directory));
  1. // discard chmod failure (some filesystem may not support it)
  2. }
  3. }
  4. if (\function_exists('opcache_invalidate') && ini_get('opcache.enable')) {
  5. @opcache_invalidate($this->file, true);

    Adding "@" before opcache_invalidate($this->file, true) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Fabien Potencier
  6. }
  7. }
  8. /**
  9. * Gets the meta file path.
  1. return $h ? $h($type, $msg, $file, $line, $context) : false;
  2. }
  3. // If the message is serialized we need to extract the message. This occurs when the error is triggered by
  4. // by the isolated test path in \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest().
  5. $parsedMsg = @unserialize($msg);

    Adding "@" before unserialize($msg) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Alex Pott
  6. if (is_array($parsedMsg)) {
  7. $msg = $parsedMsg['deprecation'];
  8. }
  9. if (error_reporting()) {
  10. $msg = 'Unsilenced deprecation: '.$msg;
  1. if ('globals' === $type) {
  2. if (is_object($meta)) {
  3. return ' = object('.get_class($meta).')';
  4. }
  5. return ' = '.substr(@json_encode($meta), 0, 50);

    Adding "@" before json_encode($meta) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Fabien Potencier
  6. }
  7. if ('functions' === $type) {
  8. return '('.implode(', ', $meta).')';
  9. }
  1. if (is_a($class, \Redis::class, true)) {
  2. $connect = $params['persistent'] || $params['persistent_id'] ? 'pconnect' : 'connect';
  3. $redis = new $class();
  4. $initializer = function ($redis) use ($connect, $params, $dsn, $auth) {
  5. @$redis->{$connect}($params['host'], $params['port'], $params['timeout'], $params['persistent_id'], $params['retry_interval']);

    Adding "@" before $redis->{$connect}($params['host'], $params['port'], $params['timeout'], $params['persistent_id'], $params['retry_interval']) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. if (@!$redis->isConnected()) {
  7. $e = ($e = error_get_last()) && preg_match('/^Redis::p?connect\(\): (.*)/', $e['message'], $e) ? sprintf(' (%s)', $e[1]) : '';
  8. throw new InvalidArgumentException(sprintf('Redis connection failed%s: %s', $e, $dsn));
  9. }
  1. $redis = new $class();
  2. $initializer = function ($redis) use ($connect, $params, $dsn, $auth) {
  3. @$redis->{$connect}($params['host'], $params['port'], $params['timeout'], $params['persistent_id'], $params['retry_interval']);
  4. if (@!$redis->isConnected()) {

    Adding "@" before !$redis->isConnected() prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. $e = ($e = error_get_last()) && preg_match('/^Redis::p?connect\(\): (.*)/', $e['message'], $e) ? sprintf(' (%s)', $e[1]) : '';
  6. throw new InvalidArgumentException(sprintf('Redis connection failed%s: %s', $e, $dsn));
  7. }
  8. if ((null !== $auth && !$redis->auth($auth))
  1. </xsd:schema>
  2. EOF
  3. ;
  4. $disableEntities = libxml_disable_entity_loader(false);
  5. $valid = @$dom->schemaValidateSource($source);

    Adding "@" before $dom->schemaValidateSource($source) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Anthon Pang
  6. libxml_disable_entity_loader($disableEntities);
  7. foreach ($tmpfiles as $tmpfile) {
  8. @unlink($tmpfile);
  9. }
  1. foreach ($context as $k => $v) {
  2. if (is_scalar($v)) {
  3. $replace['{'.$k.'}'] = $v;
  4. }
  5. }
  6. @trigger_error(strtr($message, $replace), E_USER_WARNING);

    Adding "@" before trigger_error(strtr($message, $replace), E_USER_WARNING) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. }
  8. }
  9. }
  1. $paths = array_unique($paths);
  2. $filepaths = $notfound = array();
  3. foreach ($paths as $path) {
  4. if (@file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) {

    Adding "@" before file_exists($file = $path . DIRECTORY_SEPARATOR . $name) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Tristan Darricau
  5. if (true === $first) {
  6. return $file;
  7. }
  8. $filepaths[] = $file;
  9. } else {
  1. } catch (\Exception $e) {
  2. $valid = false;
  3. }
  4. } elseif (!is_array($schemaOrCallable) && is_file((string) $schemaOrCallable)) {
  5. $schemaSource = file_get_contents((string) $schemaOrCallable);
  6. $valid = @$dom->schemaValidateSource($schemaSource);

    Adding "@" before $dom->schemaValidateSource($schemaSource) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Curtis
  7. } else {
  8. libxml_use_internal_errors($internalErrors);
  9. throw new XmlParsingException('The schemaOrCallable argument has to be a valid path to XSD file or callable.');
  10. }
  1. * @throws XmlParsingException When XML parsing returns any errors
  2. * @throws \RuntimeException When DOM extension is missing
  3. */
  4. public static function loadFile($file, $schemaOrCallable = null)
  5. {
  6. $content = @file_get_contents($file);

    Adding "@" before file_get_contents($file) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Ole Rößner
  7. if ('' === trim($content)) {
  8. throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file));
  9. }
  10. try {
  1. $this->initialize($input, $output);
  2. if (null !== $this->processTitle) {
  3. if (function_exists('cli_set_process_title')) {
  4. if (false === @cli_set_process_title($this->processTitle)) {

    Adding "@" before cli_set_process_title($this->processTitle) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Maxime Steinhausser
  5. if ('Darwin' === PHP_OS) {
  6. $output->writeln('<comment>Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.</comment>');
  7. } else {
  8. $error = error_get_last();
  9. trigger_error($error['message'], E_USER_WARNING);
  1. }
  2. restore_error_handler();
  3. if ('' !== trim($content)) {
  4. @$dom->loadHTML($content);

    Adding "@" before $dom->loadHTML($content) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Romain Neutron
  5. }
  6. libxml_use_internal_errors($internalErrors);
  7. libxml_disable_entity_loader($disableEntities);
  1. $dom = new \DOMDocument('1.0', $charset);
  2. $dom->validateOnParse = true;
  3. if ('' !== trim($content)) {
  4. @$dom->loadXML($content, $options);

    Adding "@" before $dom->loadXML($content, $options) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Fabien Potencier
  5. }
  6. libxml_use_internal_errors($internalErrors);
  7. libxml_disable_entity_loader($disableEntities);
  1. {
  2. list($scheme, $hierarchy) = $this->getSchemeAndHierarchy($dir);
  3. // If no scheme or scheme is "file" or "gs" (Google Cloud) create temp file in local filesystem
  4. if (null === $scheme || 'file' === $scheme || 'gs' === $scheme) {
  5. $tmpFile = @tempnam($hierarchy, $prefix);

    Adding "@" before tempnam($hierarchy, $prefix) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. // If tempnam failed or no scheme return the filename otherwise prepend the scheme
  7. if (false !== $tmpFile) {
  8. if (null !== $scheme && 'gs' !== $scheme) {
  9. return $scheme.'://'.$tmpFile;
  1. {
  2. if (null !== $this->rewindable) {
  3. return $this->rewindable;
  4. }
  5. if (false !== $stream = @opendir($this->getPath())) {

    Adding "@" before opendir($this->getPath()) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by alquerci
  6. $infos = stream_get_meta_data($stream);
  7. closedir($stream);
  8. if ($infos['seekable']) {
  9. return $this->rewindable = true;
  1. *
  2. * @return string
  3. */
  4. public static function trim($string)
  5. {
  6. if (null !== $result = @preg_replace('/^[\pZ\p{Cc}]+|[\pZ\p{Cc}]+$/u', '', $string)) {

    Adding "@" before preg_replace('/^[\\pZ\\p{Cc}]+|[\\pZ\\p{Cc}]+$/u', '', $string) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Issei.M
  7. return $result;
  8. }
  9. return trim($string);
  10. }
  1. $cacheKey = $requestIp.'-'.$ip;
  2. if (isset(self::$checkedIps[$cacheKey])) {
  3. return self::$checkedIps[$cacheKey];
  4. }
  5. if (!((extension_loaded('sockets') && defined('AF_INET6')) || @inet_pton('::1'))) {

    Adding "@" before inet_pton('::1') prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Victor Berchet
  6. throw new \RuntimeException('Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6".');
  7. }
  8. if (false !== strpos($ip, '/')) {
  9. list($address, $netmask) = explode('/', $ip, 2);
  1. } else {
  2. $address = $ip;
  3. $netmask = 128;
  4. }
  5. $bytesAddr = unpack('n*', @inet_pton($address));

    Adding "@" before inet_pton($address) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Jakub Zalas
  6. $bytesTest = unpack('n*', @inet_pton($requestIp));
  7. if (!$bytesAddr || !$bytesTest) {
  8. return self::$checkedIps[$cacheKey] = false;
  9. }
  1. $address = $ip;
  2. $netmask = 128;
  3. }
  4. $bytesAddr = unpack('n*', @inet_pton($address));
  5. $bytesTest = unpack('n*', @inet_pton($requestIp));

    Adding "@" before inet_pton($requestIp) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Jakub Zalas
  6. if (!$bytesAddr || !$bytesTest) {
  7. return self::$checkedIps[$cacheKey] = false;
  8. }
  1. */
  2. abstract class CacheWarmer implements CacheWarmerInterface
  3. {
  4. protected function writeCacheFile($file, $content)
  5. {
  6. $tmpFile = @tempnam(dirname($file), basename($file));

    Adding "@" before tempnam(dirname($file), basename($file)) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
  8. @chmod($file, 0666 & ~umask());
  9. return;
  10. }
  1. {
  2. $path = $this->getPath($key);
  3. if (isset($this->locks[$key])) {
  4. $fp = $this->locks[$key];
  5. @ftruncate($fp, 0);

    Adding "@" before ftruncate($fp, 0) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Matthias Pigulla
  6. @fseek($fp, 0);
  7. $len = @fwrite($fp, $data);
  8. if (strlen($data) !== $len) {
  9. @ftruncate($fp, 0);
  1. $path = $this->getPath($key);
  2. if (isset($this->locks[$key])) {
  3. $fp = $this->locks[$key];
  4. @ftruncate($fp, 0);
  5. @fseek($fp, 0);

    Adding "@" before fseek($fp, 0) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Matthias Pigulla
  6. $len = @fwrite($fp, $data);
  7. if (strlen($data) !== $len) {
  8. @ftruncate($fp, 0);
  9. return false;
  1. $fp = $this->locks[$key];
  2. @ftruncate($fp, 0);
  3. @fseek($fp, 0);
  4. $len = @fwrite($fp, $data);
  5. if (strlen($data) !== $len) {
  6. @ftruncate($fp, 0);

    Adding "@" before ftruncate($fp, 0) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Matthias Pigulla
  7. return false;
  8. }
  9. } else {
  10. if (!file_exists(dirname($path)) && false === @mkdir(dirname($path), 0777, true) && !is_dir(dirname($path))) {
  1. */
  2. public function rename(Entry $entry, $newRdn, $removeOldRdn = true)
  3. {
  4. $con = $this->getConnectionResource();
  5. if (!@ldap_rename($con, $entry->getDn(), $newRdn, null, $removeOldRdn)) {

    Adding "@" before ldap_rename($con, $entry->getDn(), $newRdn, null, $removeOldRdn) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Kevin
  6. throw new LdapException(sprintf('Could not rename entry "%s" to "%s": %s', $entry->getDn(), $newRdn, ldap_error($con)));
  7. }
  8. }
  9. /**
  1. break;
  2. default:
  3. throw new LdapException(sprintf('Could not search in scope %s', $this->options['scopen']));
  4. }
  5. $this->search = @$func(

    Adding "@" before $func($con, $this->dn, $this->query, $this->options['filter'], $this->options['attrsOnly'], $this->options['maxItems'], $this->options['timeout'], $this->options['deref']) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by orlovv
  6. $con,
  7. $this->dn,
  8. $this->query,
  9. $this->options['filter'],
  10. $this->options['attrsOnly'],
  1. if (ini_get('open_basedir')) {
  2. $searchPath = explode(PATH_SEPARATOR, ini_get('open_basedir'));
  3. $dirs = array();
  4. foreach ($searchPath as $path) {
  5. // Silencing against https://bugs.php.net/69240
  6. if (@is_dir($path)) {

    Adding "@" before is_dir($path) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Ben
  7. $dirs[] = $path;
  8. } else {
  9. if (basename($path) == $name && @is_executable($path)) {
  10. return $path;
  11. }
  1. $r = $e = array();
  2. $w = array($this->pipes[0]);
  3. // let's have a look if something changed in streams
  4. if (false === $n = @stream_select($r, $w, $e, 0, 0)) {

    Adding "@" before stream_select($r, $w, $e, 0, 0) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. return;
  6. }
  7. foreach ($w as $stdin) {
  8. if (isset($this->inputBuffer[0])) {
  1. $read = $e = array();
  2. $r = $this->pipes;
  3. unset($r[0]);
  4. // let's have a look if something changed in streams
  5. if (($r || $w) && false === $n = @stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {

    Adding "@" before stream_select($r, $w, $e, 0, $blocking ? \Symfony\Component\Process\Process::TIMEOUT_PRECISION * 1000000.0 : 0) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. // if a system call has been interrupted, forget about it, let's try again
  7. // otherwise, an error occurred, let's reset pipes
  8. if (!$this->hasSystemCallBeenInterrupted()) {
  9. $this->pipes = array();
  10. }
  1. $w = $this->write();
  2. $read = $r = $e = array();
  3. if ($blocking) {
  4. if ($w) {
  5. @stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);

    Adding "@" before stream_select($r, $w, $e, 0, \Symfony\Component\Process\Process::TIMEOUT_PRECISION * 1000000.0) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. } elseif ($this->fileHandles) {
  7. usleep(Process::TIMEOUT_PRECISION * 1E6);
  8. }
  9. }
  10. foreach ($this->fileHandles as $type => $fileHandle) {
  1. public static function isTtySupported()
  2. {
  3. static $isTtySupported;
  4. if (null === $isTtySupported) {
  5. $isTtySupported = (bool) @proc_open('echo 1 >/dev/null', array(array('file', '/dev/tty', 'r'), array('file', '/dev/tty', 'w'), array('file', '/dev/tty', 'w')), $pipes);

    Adding "@" before proc_open('echo 1 >/dev/null', array(array('file', '/dev/tty', 'r'), array('file', '/dev/tty', 'w'), array('file', '/dev/tty', 'w')), $pipes) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Johann Pardanaud
  6. }
  7. return $isTtySupported;
  8. }
  1. if ('\\' === DIRECTORY_SEPARATOR) {
  2. return $result = false;
  3. }
  4. return $result = (bool) @proc_open('echo 1 >/dev/null', array(array('pty'), array('pty'), array('pty')), $pipes);

    Adding "@" before proc_open('echo 1 >/dev/null', array(array('pty'), array('pty'), array('pty')), $pipes) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. }
  6. /**
  7. * Creates the descriptors needed by the proc_open.
  8. */
  1. return false;
  2. }
  3. } else {
  4. if (!$this->isSigchildEnabled()) {
  5. $ok = @proc_terminate($this->process, $signal);

    Adding "@" before proc_terminate($this->process, $signal) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. } elseif (function_exists('posix_kill')) {
  7. $ok = @posix_kill($pid, $signal);
  8. } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), array(2 => array('pipe', 'w')), $pipes)) {
  9. $ok = false === fgets($pipes[2]);
  10. }
  1. }
  2. } else {
  3. if (!$this->isSigchildEnabled()) {
  4. $ok = @proc_terminate($this->process, $signal);
  5. } elseif (function_exists('posix_kill')) {
  6. $ok = @posix_kill($pid, $signal);

    Adding "@" before posix_kill($pid, $signal) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), array(2 => array('pipe', 'w')), $pipes)) {
  8. $ok = false === fgets($pipes[2]);
  9. }
  10. if (!$ok) {
  11. if ($throwException) {
  1. {
  2. $internalErrors = libxml_use_internal_errors(true);
  3. $disableEntities = libxml_disable_entity_loader(false);
  4. if (!@$dom->schemaValidateSource($schema)) {

    Adding "@" before $dom->schemaValidateSource($schema) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Berny Cantos
  5. libxml_disable_entity_loader($disableEntities);
  6. throw new InvalidResourceException(sprintf('Invalid resource provided: "%s"; Errors: %s', $file, implode("\n", $this->getXmlErrors($internalErrors))));
  7. }
  1. throw new UnexpectedTypeException($value, 'string');
  2. }
  3. $stringValue = (string) $value;
  4. if (!$invalidCharset = !@mb_check_encoding($stringValue, $constraint->charset)) {

    Adding "@" before mb_check_encoding($stringValue, $constraint->charset) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. $length = mb_strlen($stringValue, $constraint->charset);
  6. }
  7. if ($invalidCharset) {
  8. $this->context->buildViolation($constraint->charsetMessage)
  1. return $root;
  2. }
  3. }
  4. $parent = $dir;
  5. while (!@file_exists($parent.'/composer.json')) {

    Adding "@" before file_exists($parent . '/composer.json') prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. if (!@file_exists($parent)) {
  7. // open_basedir restriction in effect
  8. break;
  9. }
  10. if ($parent === dirname($parent)) {
  1. }
  2. }
  3. $parent = $dir;
  4. while (!@file_exists($parent.'/composer.json')) {
  5. if (!@file_exists($parent)) {

    Adding "@" before file_exists($parent) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. // open_basedir restriction in effect
  7. break;
  8. }
  9. if ($parent === dirname($parent)) {
  10. return self::$composerRoots[$dir] = false;
  1. return $a;
  2. }
  3. public static function castStreamContext($stream, array $a, Stub $stub, $isNested)
  4. {
  5. return @stream_context_get_params($stream) ?: $a;

    Adding "@" before stream_context_get_params($stream) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. }
  7. public static function castGd($gd, array $a, Stub $stub, $isNested)
  8. {
  9. $a['size'] = imagesx($gd).'x'.imagesy($gd);
  1. * @return bool Tells if the current output stream supports ANSI colors or not
  2. */
  3. protected function supportsColors()
  4. {
  5. if ($this->outputStream !== static::$defaultOutput) {
  6. return @(is_resource($this->outputStream) && function_exists('posix_isatty') && posix_isatty($this->outputStream));

    Adding "@" before is_resource($this->outputStream) && function_exists('posix_isatty') && posix_isatty($this->outputStream) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. }
  8. if (null !== static::$defaultColors) {
  9. return static::$defaultColors;
  10. }
  11. if (isset($_SERVER['argv'][1])) {
  1. }
  2. }
  3. }
  4. if ('\\' === DIRECTORY_SEPARATOR) {
  5. static::$defaultColors = @(

    Adding "@" before '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR . '.' . PHP_WINDOWS_VERSION_MINOR . '.' . PHP_WINDOWS_VERSION_BUILD || false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM') prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Michele Locati
  6. '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD
  7. || false !== getenv('ANSICON')
  8. || 'ON' === getenv('ConEmuANSI')
  9. || 'xterm' === getenv('TERM')
  10. );

Object parameters should be type hinted 35

  • Minor
  • Bugrisk

More information: https://insight.sensiolabs.com/what-we-analyse/php.object_parameter_not_type_hinted

  1. $document->loadXML($content);
  2. if ($document->schemaValidate(__DIR__.'/../Resources/schemas/xliff-core-1.2-strict.xsd')) {
  3. return array('file' => $file, 'valid' => true);
  4. }
  5. $errorMessages = array_map(function ($error) {

    The parameter error, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Javier Eguiluz
  6. return array(
  7. 'line' => $error->line,
  8. 'column' => $error->column,
  9. 'message' => trim($error->message),
  10. );
  1. $records['extra']['token'] = null;
  2. if (null !== $token = $this->tokenStorage->getToken()) {
  3. $records['extra']['token'] = array(
  4. 'username' => $token->getUsername(),
  5. 'authenticated' => $token->isAuthenticated(),
  6. 'roles' => array_map(function ($role) { return $role->getRole(); }, $token->getRoles()),

    The parameter role, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Dany Maillard
  7. );
  8. }
  9. return $records;
  10. }
  1. {
  2. self::$globallyEnabled = false;
  3. $this->state = -1;
  4. }
  5. public function startTestSuite($suite)

    The parameter suite, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. {
  7. if (class_exists('PHPUnit_Util_Blacklist', false)) {
  8. $Test = 'PHPUnit_Util_Test';
  9. } else {
  10. $Test = 'PHPUnit\Util\Test';
  1. /**
  2. * @param TestCase $test
  3. *
  4. * @return bool
  5. */
  6. private function willBeIsolated($test)

    The parameter test, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Paul Mitchum
  7. {
  8. if ($test->isInIsolation()) {
  9. return false;
  10. }
  1. // remove the value the filter is applied on
  2. array_shift($args);
  3. }
  4. // format args
  5. $args = array_map(function ($param) {

    The parameter param, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Fabien Potencier
  6. if ($param->isDefaultValueAvailable()) {
  7. return $param->getName().' = '.json_encode($param->getDefaultValue());
  8. }
  9. return $param->getName();
  1. $title = 'Available registered bundles with their extension alias if available';
  2. $headers = array('Bundle name', 'Extension alias');
  3. $rows = array();
  4. $bundles = $this->getApplication()->getKernel()->getBundles();
  5. usort($bundles, function ($bundleA, $bundleB) {

    The parameter bundleB, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Fabien Potencier
  6. return strcmp($bundleA->getName(), $bundleB->getName());
  7. });
  8. foreach ($bundles as $bundle) {
  9. $extension = $bundle->getContainerExtension();
  1. $title = 'Available registered bundles with their extension alias if available';
  2. $headers = array('Bundle name', 'Extension alias');
  3. $rows = array();
  4. $bundles = $this->getApplication()->getKernel()->getBundles();
  5. usort($bundles, function ($bundleA, $bundleB) {

    The parameter bundleA, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Fabien Potencier
  6. return strcmp($bundleA->getName(), $bundleB->getName());
  7. });
  8. foreach ($bundles as $bundle) {
  9. $extension = $bundle->getContainerExtension();
  1. /**
  2. * Attempts to find a bundle that is *similar* to the given bundle name.
  3. */
  4. private function findAlternative(string $nonExistentBundleName): ?string
  5. {
  6. $bundleNames = array_map(function ($b) {

    The parameter b, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Ryan Weaver
  7. return $b->getName();
  8. }, $this->kernel->getBundles());
  9. $alternative = null;
  10. $shortest = null;
  1. }
  2. }
  3. $this->adapterCount = count($this->adapters);
  4. $this->saveUp = \Closure::bind(
  5. function ($adapter, $item) use ($maxLifetime) {

    The parameter adapter, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. $origDefaultLifetime = $item->defaultLifetime;
  7. if (0 < $maxLifetime && ($origDefaultLifetime <= 0 || $maxLifetime < $origDefaultLifetime)) {
  8. $item->defaultLifetime = $maxLifetime;
  9. }
  1. $this->pool = $pool;
  2. $this->poolHash = $poolHash = spl_object_hash($pool);
  3. $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace);
  4. $this->namespaceLen = strlen($namespace);
  5. $this->createCacheItem = \Closure::bind(
  6. function ($key, $innerItem) use ($defaultLifetime, $poolHash) {

    The parameter innerItem, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. $item = new CacheItem();
  8. $item->key = $key;
  9. $item->value = $innerItem->get();
  10. $item->isHit = $innerItem->isHit();
  11. $item->defaultLifetime = $defaultLifetime;
  1. if (is_a($class, \Redis::class, true)) {
  2. $connect = $params['persistent'] || $params['persistent_id'] ? 'pconnect' : 'connect';
  3. $redis = new $class();
  4. $initializer = function ($redis) use ($connect, $params, $dsn, $auth) {

    The parameter redis, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. @$redis->{$connect}($params['host'], $params['port'], $params['timeout'], $params['persistent_id'], $params['retry_interval']);
  6. if (@!$redis->isConnected()) {
  7. $e = ($e = error_get_last()) && preg_match('/^Redis::p?connect\(\): (.*)/', $e['message'], $e) ? sprintf(' (%s)', $e[1]) : '';
  8. throw new InvalidArgumentException(sprintf('Redis connection failed%s: %s', $e, $dsn));
  1. }
  2. final public function extension(string $namespace, array $config)
  3. {
  4. if (!$this->container->hasExtension($namespace)) {
  5. $extensions = array_filter(array_map(function ($ext) { return $ext->getAlias(); }, $this->container->getExtensions()));

    The parameter ext, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. throw new InvalidArgumentException(sprintf(
  7. 'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s',
  8. $namespace,
  9. $this->file,
  10. $namespace,
  1. continue;
  2. }
  3. // can it be handled by an extension?
  4. if (!$this->container->hasExtension($node->namespaceURI)) {
  5. $extensionNamespaces = array_filter(array_map(function ($ext) { return $ext->getNamespace(); }, $this->container->getExtensions()));

    The parameter ext, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Fabien Potencier
  6. throw new InvalidArgumentException(sprintf(
  7. 'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s',
  8. $node->tagName,
  9. $file,
  10. $node->namespaceURI,
  1. if (in_array($namespace, array('imports', 'parameters', 'services'))) {
  2. continue;
  3. }
  4. if (!$this->container->hasExtension($namespace)) {
  5. $extensionNamespaces = array_filter(array_map(function ($ext) { return $ext->getAlias(); }, $this->container->getExtensions()));

    The parameter ext, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Fabien Potencier
  6. throw new InvalidArgumentException(sprintf(
  7. 'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s',
  8. $namespace,
  9. $file,
  10. $namespace,
  1. public function __construct(\Traversable $iterator, $sort)
  2. {
  3. $this->iterator = $iterator;
  4. if (self::SORT_BY_NAME === $sort) {
  5. $this->sort = function ($a, $b) {

    The parameter a, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Fabien Potencier
  6. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  7. };
  8. } elseif (self::SORT_BY_TYPE === $sort) {
  9. $this->sort = function ($a, $b) {
  10. if ($a->isDir() && $b->isFile()) {
  1. public function __construct(\Traversable $iterator, $sort)
  2. {
  3. $this->iterator = $iterator;
  4. if (self::SORT_BY_NAME === $sort) {
  5. $this->sort = function ($a, $b) {

    The parameter b, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Fabien Potencier
  6. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  7. };
  8. } elseif (self::SORT_BY_TYPE === $sort) {
  9. $this->sort = function ($a, $b) {
  10. if ($a->isDir() && $b->isFile()) {
  1. if (self::SORT_BY_NAME === $sort) {
  2. $this->sort = function ($a, $b) {
  3. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  4. };
  5. } elseif (self::SORT_BY_TYPE === $sort) {
  6. $this->sort = function ($a, $b) {

    The parameter a, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Fabien Potencier
  7. if ($a->isDir() && $b->isFile()) {
  8. return -1;
  9. } elseif ($a->isFile() && $b->isDir()) {
  10. return 1;
  11. }
  1. if (self::SORT_BY_NAME === $sort) {
  2. $this->sort = function ($a, $b) {
  3. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  4. };
  5. } elseif (self::SORT_BY_TYPE === $sort) {
  6. $this->sort = function ($a, $b) {

    The parameter b, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Fabien Potencier
  7. if ($a->isDir() && $b->isFile()) {
  8. return -1;
  9. } elseif ($a->isFile() && $b->isDir()) {
  10. return 1;
  11. }
  1. }
  2. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  3. };
  4. } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
  5. $this->sort = function ($a, $b) {

    The parameter b, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rui Marinho
  6. return $a->getATime() - $b->getATime();
  7. };
  8. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  9. $this->sort = function ($a, $b) {
  10. return $a->getCTime() - $b->getCTime();
  1. }
  2. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  3. };
  4. } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
  5. $this->sort = function ($a, $b) {

    The parameter a, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rui Marinho
  6. return $a->getATime() - $b->getATime();
  7. };
  8. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  9. $this->sort = function ($a, $b) {
  10. return $a->getCTime() - $b->getCTime();
  1. } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
  2. $this->sort = function ($a, $b) {
  3. return $a->getATime() - $b->getATime();
  4. };
  5. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  6. $this->sort = function ($a, $b) {

    The parameter a, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rui Marinho
  7. return $a->getCTime() - $b->getCTime();
  8. };
  9. } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
  10. $this->sort = function ($a, $b) {
  11. return $a->getMTime() - $b->getMTime();
  1. } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
  2. $this->sort = function ($a, $b) {
  3. return $a->getATime() - $b->getATime();
  4. };
  5. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  6. $this->sort = function ($a, $b) {

    The parameter b, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rui Marinho
  7. return $a->getCTime() - $b->getCTime();
  8. };
  9. } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
  10. $this->sort = function ($a, $b) {
  11. return $a->getMTime() - $b->getMTime();
  1. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  2. $this->sort = function ($a, $b) {
  3. return $a->getCTime() - $b->getCTime();
  4. };
  5. } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
  6. $this->sort = function ($a, $b) {

    The parameter b, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rui Marinho
  7. return $a->getMTime() - $b->getMTime();
  8. };
  9. } elseif (is_callable($sort)) {
  10. $this->sort = $sort;
  11. } else {
  1. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  2. $this->sort = function ($a, $b) {
  3. return $a->getCTime() - $b->getCTime();
  4. };
  5. } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
  6. $this->sort = function ($a, $b) {

    The parameter a, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rui Marinho
  7. return $a->getMTime() - $b->getMTime();
  8. };
  9. } elseif (is_callable($sort)) {
  10. $this->sort = $sort;
  11. } else {
  1. /**
  2. * {@inheritdoc}
  3. */
  4. public function guessType($class, $property)
  5. {
  6. return $this->guess(function ($guesser) use ($class, $property) {

    The parameter guesser, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Bernhard Schussek
  7. return $guesser->guessType($class, $property);
  8. });
  9. }
  10. /**
  1. /**
  2. * {@inheritdoc}
  3. */
  4. public function guessRequired($class, $property)
  5. {
  6. return $this->guess(function ($guesser) use ($class, $property) {

    The parameter guesser, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Bernhard Schussek
  7. return $guesser->guessRequired($class, $property);
  8. });
  9. }
  10. /**
  1. /**
  2. * {@inheritdoc}
  3. */
  4. public function guessMaxLength($class, $property)
  5. {
  6. return $this->guess(function ($guesser) use ($class, $property) {

    The parameter guesser, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Bernhard Schussek
  7. return $guesser->guessMaxLength($class, $property);
  8. });
  9. }
  10. /**
  1. /**
  2. * {@inheritdoc}
  3. */
  4. public function guessPattern($class, $property)
  5. {
  6. return $this->guess(function ($guesser) use ($class, $property) {

    The parameter guesser, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Michel Weimerskirch
  7. return $guesser->guessPattern($class, $property);
  8. });
  9. }
  10. /**
  1. $profileToken = $profile->getToken();
  2. // when there are errors in sub-requests, the parent and/or children tokens
  3. // may equal the profile token, resulting in infinite loops
  4. $parentToken = $profile->getParentToken() !== $profileToken ? $profile->getParentToken() : null;
  5. $childrenToken = array_filter(array_map(function ($p) use ($profileToken) {

    The parameter p, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Javier Eguiluz
  6. return $profileToken !== $p->getToken() ? $p->getToken() : null;
  7. }, $profile->getChildren()));
  8. // Store profile
  9. $data = array(
  1. $variables = array(
  2. 'token' => $token,
  3. 'user' => $token->getUser(),
  4. 'object' => $subject,
  5. 'subject' => $subject,
  6. 'roles' => array_map(function ($role) { return $role->getRole(); }, $roles),

    The parameter role, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Fabien Potencier
  7. 'trust_resolver' => $this->trustResolver,
  8. );
  9. // this is mainly to propose a better experience when the expression is used
  10. // in an access control rule, as the developer does not know that it's going
  1. *
  2. * @return string An absolute URL
  3. *
  4. * @throws \LogicException
  5. */
  6. public function generateUri($request, $path)

    The parameter request, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Fabien Potencier
  7. {
  8. if (0 === strpos($path, 'http') || !$path) {
  9. return $path;
  10. }
  1. $metadata->mergeConstraints($this->getMetadataFor($parent->name));
  2. }
  3. $interfaces = $metadata->getReflectionClass()->getInterfaces();
  4. $interfaces = array_filter($interfaces, function ($interface) use ($parent, $interfaces) {

    The parameter interface, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Mathieu Lemoine
  5. $interfaceName = $interface->getName();
  6. if ($parent && $parent->implementsInterface($interfaceName)) {
  7. return false;
  8. }
  1. }
  2. return $a;
  3. }
  4. public static function castLength($dom, array $a, Stub $stub, $isNested)

    The parameter dom, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'length' => $dom->length,
  8. );
  1. $variables = array(
  2. 'token' => $token,
  3. 'user' => $token->getUser(),
  4. 'subject' => $event->getSubject(),
  5. 'roles' => array_map(function ($role) {

    The parameter role, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Grégoire Pineau
  6. return $role->getRole();
  7. }, $roles),
  8. // needed for the is_granted expression function
  9. 'auth_checker' => $this->authenticationChecker,
  10. // needed for the is_* expression function
  1. }
  2. return $matched;
  3. }
  4. private function supports(WorkflowInterface $workflow, $supportStrategy, $subject, $workflowName): bool

    The parameter supportStrategy, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Amrouche Hamza
  5. {
  6. if (null !== $workflowName && $workflowName !== $workflow->getName()) {
  7. return false;
  8. }

Templates should not be too long

  • Minor
  • Codestyle

More information: https://insight.sensiolabs.com/what-we-analyse/twig.template_too_long

15% of all your templates have more than 200 lines, the threshold is 5%.

Time to fix: about 5.6 days
Open Issue Permalink
Collective

Unused method, property, variable or parameter 184

  • Minor
  • Deadcode

More information: https://insight.sensiolabs.com/what-we-analyse/php.unused_local_variable_or_private_member

  1. if (!$type || (!$log && !$throw)) {
  2. return $type && $log;
  3. }
  4. $scope = $this->scopedErrors & $type;
  5. if (4 < $numArgs = func_num_args()) {

    This numArgs local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. $context = $scope ? (func_get_arg(4) ?: array()) : array();
  7. } else {
  8. $context = array();
  9. }
  1. private $message;
  2. private $parameters = array();
  3. private $invalidValue = 'InvalidValue';
  4. private $propertyPath = 'property.path';
  5. private $translationDomain;

    This translationDomain attribute is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by WouterJ
  6. private $plural;
  7. private $code;
  8. private $constraint;
  9. private $cause;
  1. private $wasSkipped = array();
  2. private $isSkipped = array();
  3. private $expectedDeprecations = array();
  4. private $gatheredDeprecations = array();
  5. private $previousErrorHandler;
  6. private $testsWithWarnings;

    This testsWithWarnings attribute is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. private $reportUselessTests;
  8. private $error;
  9. private $runsInSeparateProcess = false;
  10. /**
  1. }
  2. $suite->setTests($skipped);
  3. }
  4. }
  5. public function addSkippedTest($test, \Exception $e, $time)

    This e argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. {
  7. if (0 < $this->state) {
  8. if ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) {
  9. $class = get_class($test);
  10. $method = $test->getName();
  1. }
  2. $suite->setTests($skipped);
  3. }
  4. }
  5. public function addSkippedTest($test, \Exception $e, $time)

    This time argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. {
  7. if (0 < $this->state) {
  8. if ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) {
  9. $class = get_class($test);
  10. $method = $test->getName();
  1. $this->previousErrorHandler = set_error_handler(array($this, 'handleError'));
  2. }
  3. }
  4. }
  5. public function addWarning($test, $e, $time)

    This time argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. {
  7. if ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) {
  8. $this->testsWithWarnings[$test->getName()] = true;
  9. }
  10. }
  1. $this->previousErrorHandler = set_error_handler(array($this, 'handleError'));
  2. }
  3. }
  4. }
  5. public function addWarning($test, $e, $time)

    This e argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. {
  7. if ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) {
  8. $this->testsWithWarnings[$test->getName()] = true;
  9. }
  10. }
  1. $BaseTestRunner = 'PHPUnit_Runner_BaseTestRunner';
  2. $Warning = 'PHPUnit_Framework_Warning';
  3. } else {
  4. $Test = 'PHPUnit\Util\Test';
  5. $BaseTestRunner = 'PHPUnit\Runner\BaseTestRunner';
  6. $Warning = 'PHPUnit\Framework\Warning';

    This Warning local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. }
  8. $className = get_class($test);
  9. $classGroups = $Test::getGroups($className);
  10. $groups = $Test::getGroups($className, $test->getName(false));
  1. $Test = 'PHPUnit\Util\Test';
  2. $BaseTestRunner = 'PHPUnit\Runner\BaseTestRunner';
  3. $Warning = 'PHPUnit\Framework\Warning';
  4. }
  5. $className = get_class($test);
  6. $classGroups = $Test::getGroups($className);

    This classGroups local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. $groups = $Test::getGroups($className, $test->getName(false));
  8. if (null !== $this->reportUselessTests) {
  9. $test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything($this->reportUselessTests);
  10. $this->reportUselessTests = null;
  1. */
  2. private function checkDefinition($id, array $definition, $file)
  3. {
  4. if ($this->isLoadingInstanceof) {
  5. $keywords = self::$instanceofKeywords;
  6. } elseif ($throw = (isset($definition['resource']) || isset($definition['namespace']))) {

    This throw local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Kevin Bond
  7. $keywords = self::$prototypeKeywords;
  8. } else {
  9. $keywords = self::$serviceKeywords;
  10. }
  1. XML_ATTRIBUTE_DECL_NODE => 'XML_ATTRIBUTE_DECL_NODE',
  2. XML_ENTITY_DECL_NODE => 'XML_ENTITY_DECL_NODE',
  3. XML_NAMESPACE_DECL_NODE => 'XML_NAMESPACE_DECL_NODE',
  4. );
  5. public static function castException(\DOMException $e, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. {
  7. $k = Caster::PREFIX_PROTECTED.'code';
  8. if (isset($a[$k], self::$errorCodes[$a[$k]])) {
  9. $a[$k] = new ConstStub(self::$errorCodes[$a[$k]], $a[$k]);
  10. }
  1. XML_ATTRIBUTE_DECL_NODE => 'XML_ATTRIBUTE_DECL_NODE',
  2. XML_ENTITY_DECL_NODE => 'XML_ENTITY_DECL_NODE',
  3. XML_NAMESPACE_DECL_NODE => 'XML_NAMESPACE_DECL_NODE',
  4. );
  5. public static function castException(\DOMException $e, array $a, Stub $stub, $isNested)

    This e argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. {
  7. $k = Caster::PREFIX_PROTECTED.'code';
  8. if (isset($a[$k], self::$errorCodes[$a[$k]])) {
  9. $a[$k] = new ConstStub(self::$errorCodes[$a[$k]], $a[$k]);
  10. }
  1. XML_ATTRIBUTE_DECL_NODE => 'XML_ATTRIBUTE_DECL_NODE',
  2. XML_ENTITY_DECL_NODE => 'XML_ENTITY_DECL_NODE',
  3. XML_NAMESPACE_DECL_NODE => 'XML_NAMESPACE_DECL_NODE',
  4. );
  5. public static function castException(\DOMException $e, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. {
  7. $k = Caster::PREFIX_PROTECTED.'code';
  8. if (isset($a[$k], self::$errorCodes[$a[$k]])) {
  9. $a[$k] = new ConstStub(self::$errorCodes[$a[$k]], $a[$k]);
  10. }
  1. }
  2. return $a;
  3. }
  4. public static function castLength($dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'length' => $dom->length,
  8. );
  1. }
  2. return $a;
  3. }
  4. public static function castLength($dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'length' => $dom->length,
  8. );
  1. );
  2. return $a;
  3. }
  4. public static function castImplementation($dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. Caster::PREFIX_VIRTUAL.'Core' => '1.0',
  8. Caster::PREFIX_VIRTUAL.'XML' => '2.0',
  9. );
  1. );
  2. return $a;
  3. }
  4. public static function castImplementation($dom, array $a, Stub $stub, $isNested)

    This dom argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. Caster::PREFIX_VIRTUAL.'Core' => '1.0',
  8. Caster::PREFIX_VIRTUAL.'XML' => '2.0',
  9. );
  1. );
  2. return $a;
  3. }
  4. public static function castImplementation($dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. Caster::PREFIX_VIRTUAL.'Core' => '1.0',
  8. Caster::PREFIX_VIRTUAL.'XML' => '2.0',
  9. );
  1. );
  2. return $a;
  3. }
  4. public static function castNode(\DOMNode $dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'nodeName' => $dom->nodeName,
  8. 'nodeValue' => new CutStub($dom->nodeValue),
  9. 'nodeType' => new ConstStub(self::$nodeTypes[$dom->nodeType], $dom->nodeType),
  1. );
  2. return $a;
  3. }
  4. public static function castNode(\DOMNode $dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'nodeName' => $dom->nodeName,
  8. 'nodeValue' => new CutStub($dom->nodeValue),
  9. 'nodeType' => new ConstStub(self::$nodeTypes[$dom->nodeType], $dom->nodeType),
  1. );
  2. return $a;
  3. }
  4. public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'nodeName' => $dom->nodeName,
  8. 'nodeValue' => new CutStub($dom->nodeValue),
  9. 'nodeType' => new ConstStub(self::$nodeTypes[$dom->nodeType], $dom->nodeType),
  1. );
  2. return $a;
  3. }
  4. public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'nodeName' => $dom->nodeName,
  8. 'nodeValue' => new CutStub($dom->nodeValue),
  9. 'nodeType' => new ConstStub(self::$nodeTypes[$dom->nodeType], $dom->nodeType),
  1. );
  2. return $a;
  3. }
  4. public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, $isNested, $filter = 0)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'doctype' => $dom->doctype,
  8. 'implementation' => $dom->implementation,
  9. 'documentElement' => new CutStub($dom->documentElement),
  1. );
  2. return $a;
  3. }
  4. public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, $isNested, $filter = 0)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'doctype' => $dom->doctype,
  8. 'implementation' => $dom->implementation,
  9. 'documentElement' => new CutStub($dom->documentElement),
  1. }
  2. return $a;
  3. }
  4. public static function castCharacterData(\DOMCharacterData $dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'data' => $dom->data,
  8. 'length' => $dom->length,
  9. );
  1. }
  2. return $a;
  3. }
  4. public static function castCharacterData(\DOMCharacterData $dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'data' => $dom->data,
  8. 'length' => $dom->length,
  9. );
  1. );
  2. return $a;
  3. }
  4. public static function castAttr(\DOMAttr $dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'name' => $dom->name,
  8. 'specified' => $dom->specified,
  9. 'value' => $dom->value,
  1. );
  2. return $a;
  3. }
  4. public static function castAttr(\DOMAttr $dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'name' => $dom->name,
  8. 'specified' => $dom->specified,
  9. 'value' => $dom->value,
  1. );
  2. return $a;
  3. }
  4. public static function castElement(\DOMElement $dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'tagName' => $dom->tagName,
  8. 'schemaTypeInfo' => $dom->schemaTypeInfo,
  9. );
  1. );
  2. return $a;
  3. }
  4. public static function castElement(\DOMElement $dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'tagName' => $dom->tagName,
  8. 'schemaTypeInfo' => $dom->schemaTypeInfo,
  9. );
  1. );
  2. return $a;
  3. }
  4. public static function castText(\DOMText $dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'wholeText' => $dom->wholeText,
  8. );
  1. );
  2. return $a;
  3. }
  4. public static function castText(\DOMText $dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'wholeText' => $dom->wholeText,
  8. );
  1. );
  2. return $a;
  3. }
  4. public static function castTypeinfo(\DOMTypeinfo $dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'typeName' => $dom->typeName,
  8. 'typeNamespace' => $dom->typeNamespace,
  9. );
  1. );
  2. return $a;
  3. }
  4. public static function castTypeinfo(\DOMTypeinfo $dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'typeName' => $dom->typeName,
  8. 'typeNamespace' => $dom->typeNamespace,
  9. );
  1. );
  2. return $a;
  3. }
  4. public static function castDomError(\DOMDomError $dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'severity' => $dom->severity,
  8. 'message' => $dom->message,
  9. 'type' => $dom->type,
  1. );
  2. return $a;
  3. }
  4. public static function castDomError(\DOMDomError $dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'severity' => $dom->severity,
  8. 'message' => $dom->message,
  9. 'type' => $dom->type,
  1. );
  2. return $a;
  3. }
  4. public static function castLocator(\DOMLocator $dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'lineNumber' => $dom->lineNumber,
  8. 'columnNumber' => $dom->columnNumber,
  9. 'offset' => $dom->offset,
  1. );
  2. return $a;
  3. }
  4. public static function castLocator(\DOMLocator $dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'lineNumber' => $dom->lineNumber,
  8. 'columnNumber' => $dom->columnNumber,
  9. 'offset' => $dom->offset,
  1. );
  2. return $a;
  3. }
  4. public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'name' => $dom->name,
  8. 'entities' => $dom->entities,
  9. 'notations' => $dom->notations,
  1. );
  2. return $a;
  3. }
  4. public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'name' => $dom->name,
  8. 'entities' => $dom->entities,
  9. 'notations' => $dom->notations,
  1. );
  2. return $a;
  3. }
  4. public static function castNotation(\DOMNotation $dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'publicId' => $dom->publicId,
  8. 'systemId' => $dom->systemId,
  9. );
  1. );
  2. return $a;
  3. }
  4. public static function castNotation(\DOMNotation $dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'publicId' => $dom->publicId,
  8. 'systemId' => $dom->systemId,
  9. );
  1. );
  2. return $a;
  3. }
  4. public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'publicId' => $dom->publicId,
  8. 'systemId' => $dom->systemId,
  9. 'notationName' => $dom->notationName,
  1. );
  2. return $a;
  3. }
  4. public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'publicId' => $dom->publicId,
  8. 'systemId' => $dom->systemId,
  9. 'notationName' => $dom->notationName,
  1. );
  2. return $a;
  3. }
  4. public static function castProcessingInstruction(\DOMProcessingInstruction $dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'target' => $dom->target,
  8. 'data' => $dom->data,
  9. );
  1. );
  2. return $a;
  3. }
  4. public static function castProcessingInstruction(\DOMProcessingInstruction $dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'target' => $dom->target,
  8. 'data' => $dom->data,
  9. );
  1. );
  2. return $a;
  3. }
  4. public static function castXPath(\DOMXPath $dom, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'document' => $dom->document,
  8. );
  1. );
  2. return $a;
  3. }
  4. public static function castXPath(\DOMXPath $dom, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a += array(
  7. 'document' => $dom->document,
  8. );
  1. if (null === $match) {
  2. return;
  3. }
  4. list($req, $headers) = $match;

    This req local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Fabien Potencier
  5. if (file_exists($body = $this->getPath($headers['x-content-digest'][0]))) {
  6. return $this->restoreResponse($headers, $body);
  7. }
  8. // TODO the metaStore referenced an entity that doesn't exist in
  1. $r = $e = array();
  2. $w = array($this->pipes[0]);
  3. // let's have a look if something changed in streams
  4. if (false === $n = @stream_select($r, $w, $e, 0, 0)) {

    This n local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. return;
  6. }
  7. foreach ($w as $stdin) {
  8. if (isset($this->inputBuffer[0])) {
  1. $read = $e = array();
  2. $r = $this->pipes;
  3. unset($r[0]);
  4. // let's have a look if something changed in streams
  5. if (($r || $w) && false === $n = @stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {

    This n local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. // if a system call has been interrupted, forget about it, let's try again
  7. // otherwise, an error occurred, let's reset pipes
  8. if (!$this->hasSystemCallBeenInterrupted()) {
  9. $this->pipes = array();
  10. }
  1. $commandline = '{ ('.$commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
  2. $commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code';
  3. // Workaround for the bug, when PTS functionality is enabled.
  4. // @see : https://bugs.php.net/69442
  5. $ptsWorkaround = fopen(__FILE__, 'r');

    This ptsWorkaround local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. }
  7. if (!is_dir($this->cwd)) {
  8. throw new RuntimeException('The provided cwd does not exist.');
  9. }
  1. public static function castCurl($h, array $a, Stub $stub, $isNested)
  2. {
  3. return curl_getinfo($h);
  4. }
  5. public static function castDba($dba, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. {
  7. $list = dba_list();
  8. $a['file'] = $list[(int) $dba];
  9. return $a;
  1. public static function castCurl($h, array $a, Stub $stub, $isNested)
  2. {
  3. return curl_getinfo($h);
  4. }
  5. public static function castDba($dba, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. {
  7. $list = dba_list();
  8. $a['file'] = $list[(int) $dba];
  9. return $a;
  1. public static function castStreamContext($stream, array $a, Stub $stub, $isNested)
  2. {
  3. return @stream_context_get_params($stream) ?: $a;
  4. }
  5. public static function castGd($gd, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. {
  7. $a['size'] = imagesx($gd).'x'.imagesy($gd);
  8. $a['trueColor'] = imageistruecolor($gd);
  9. return $a;
  1. public static function castStreamContext($stream, array $a, Stub $stub, $isNested)
  2. {
  3. return @stream_context_get_params($stream) ?: $a;
  4. }
  5. public static function castGd($gd, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  6. {
  7. $a['size'] = imagesx($gd).'x'.imagesy($gd);
  8. $a['trueColor'] = imageistruecolor($gd);
  9. return $a;
  1. $a['trueColor'] = imageistruecolor($gd);
  2. return $a;
  3. }
  4. public static function castMysqlLink($h, array $a, Stub $stub, $isNested)

    This isNested argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a['host'] = mysql_get_host_info($h);
  7. $a['protocol'] = mysql_get_proto_info($h);
  8. $a['server'] = mysql_get_server_info($h);
  1. $a['trueColor'] = imageistruecolor($gd);
  2. return $a;
  3. }
  4. public static function castMysqlLink($h, array $a, Stub $stub, $isNested)

    This stub argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  5. {
  6. $a['host'] = mysql_get_host_info($h);
  7. $a['protocol'] = mysql_get_proto_info($h);
  8. $a['server'] = mysql_get_server_info($h);
  1. if (!isset($instance['event'])) {
  2. throw new InvalidArgumentException(sprintf('Doctrine event listener "%s" must specify the "event" attribute.', $id));
  3. }
  4. $instance['event'] = array($instance['event']);
  5. if ($lazy = !empty($instance['lazy'])) {

    This lazy local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Fabien Potencier
  6. $this->container->getDefinition($id)->setPublic(true);
  7. }
  8. }
  9. $cons = isset($instance['connection']) ? array($instance['connection']) : $allCons;
  1. protected function getDefaultFormatter()
  2. {
  3. return new VarDumperFormatter();
  4. }
  5. private static function nullErrorHandler()

    This nullErrorHandler method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Grégoire Pineau
  6. {
  7. }
  8. private function createSocket()
  9. {
  1. if (false !== strpos($serviceId, '\\')) {
  2. return true;
  3. }
  4. try {
  5. $r = new \ReflectionClass($serviceId);

    This r local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Ryan Weaver
  6. return true;
  7. } catch (\ReflectionException $e) {
  8. // the service id is not a valid class/interface
  9. return false;
  1. /**
  2. * Gets a hash of the kernel root directory.
  3. *
  4. * @return string
  5. */
  6. private function getKernelRootHash(ContainerBuilder $container)

    This getKernelRootHash method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Kévin Dunglas
  7. {
  8. if (!$this->kernelRootHash) {
  9. $this->kernelRootHash = hash('sha256', $container->getParameter('kernel.root_dir'));
  10. }
  1. */
  2. class FirewallMap implements FirewallMapInterface
  3. {
  4. private $container;
  5. private $map;
  6. private $contexts;

    This contexts attribute is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Robin Chalas
  7. public function __construct(ContainerInterface $container, iterable $map)
  8. {
  9. $this->container = $container;
  10. $this->map = $map;
  1. private $deferred = array();
  2. private $createCacheItem;
  3. private $setCacheItemTags;
  4. private $getTagsByKey;
  5. private $invalidateTags;
  6. private $tagsPool;

    This tagsPool attribute is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. public function __construct(AdapterInterface $itemsPool, AdapterInterface $tagsPool = null)
  8. {
  9. $this->pool = $itemsPool;
  10. $this->tags = $tagsPool ?: $itemsPool;
in