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. $e = null;
  2. $meta = false;
  3. $time = filemtime($this->file);
  4. $signalingException = new \UnexpectedValueException();
  5. $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 Nicolas Grekas
  6. $prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context) use (&$prevErrorHandler, $signalingException) {
  7. if (E_WARNING === $type && 'Class __PHP_Incomplete_Class has no unserializer' === $msg) {
  8. throw $signalingException;
  9. }
  1. $meta = unserialize(file_get_contents($metadata));
  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 Nicolas Grekas
  7. if (null !== $e && $e !== $signalingException) {
  8. throw $e;
  9. }
  10. if (false === $meta) {
  11. return false;
  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. /**

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. * Configures the error handler for delayed handling.

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 6

  • 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. */
  2. protected function configure()
  3. {
  4. $this->setName('lint:xliff');
  5. if (!$this->isEnabled()) {

    The next 37 lines appear both in src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php:37 and src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php:36.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Javier Eguiluz
  6. return;
  7. }
  8. $directoryIteratorProvider = function ($directory, $default) {
  9. if (!is_dir($directory)) {
  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 8 lines appear both in src/Symfony/Component/Cache/Traits/PdoTrait.php:58 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 requiresAuthentication(Request $request)

    The next 35 lines appear both in src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php:79 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. 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:130 and src/Symfony/Component/Yaml/Command/LintCommand.php:127.

    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:65.

    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($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 (@) 44

  • Minor
  • Bugrisk

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

  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. </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. $class = null === $params['class'] ? (extension_loaded('redis') ? \Redis::class : \Predis\Client::class) : $params['class'];
  2. if (is_a($class, \Redis::class, true)) {
  3. $connect = $params['persistent'] || $params['persistent_id'] ? 'pconnect' : 'connect';
  4. $redis = new $class();
  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. if (is_a($class, \Redis::class, true)) {
  2. $connect = $params['persistent'] || $params['persistent_id'] ? 'pconnect' : 'connect';
  3. $redis = new $class();
  4. @$redis->{$connect}($params['host'], $params['port'], $params['timeout'], $params['persistent_id'], $params['retry_interval']);
  5. 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
  6. $e = ($e = error_get_last()) && preg_match('/^Redis::p?connect\(\): (.*)/', $e['message'], $e) ? sprintf(' (%s)', $e[1]) : '';
  7. throw new InvalidArgumentException(sprintf('Redis connection failed%s: %s', $e, $dsn));
  8. }
  9. if ((null !== $auth && !$redis->auth($auth))
  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. {
  2. if (!extension_loaded('dom')) {
  3. throw new \RuntimeException('Extension DOM is required.');
  4. }
  5. $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 Romain Neutron
  6. if ('' === trim($content)) {
  7. throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file));
  8. }
  9. $internalErrors = libxml_use_internal_errors(true);
  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 \InvalidArgumentException('The schemaOrCallable argument has to be a valid path to XSD file or callable.');
  10. }
  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. if (\PHP_VERSION_ID < 70000) {
  2. // Bug in PHP5: https://bugs.php.net/bug.php?id=64761
  3. // This means that we cannot bind static closures and therefore we must
  4. // ignore any errors here. There is no way to test if the closure is
  5. // bindable.
  6. $code = @\Closure::bind($code, $this);

    Adding "@" before \Closure::bind($code, $this) 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 Andy Raines
  7. } else {
  8. $code = \Closure::bind($code, $this);
  9. }
  10. }
  11. }
  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. // workaround for an HHVM bug, should be removed when https://github.com/facebook/hhvm/issues/7281 is fixed
  2. if ('' === $this->getPath()) {
  3. return $this->rewindable = false;
  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. $data = json_encode($data, $this->encodingOptions);
  2. } else {
  3. if (!interface_exists('JsonSerializable', false)) {
  4. set_error_handler(function () { return false; });
  5. try {
  6. $data = @json_encode($data, $this->encodingOptions);

    Adding "@" before json_encode($data, $this->encodingOptions) 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. } finally {
  8. restore_error_handler();
  9. }
  10. } else {
  11. try {
  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. }
  2. if ($tty) {
  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 Nicolas Grekas
  6. }
  7. if (!$isTtySupported) {
  8. throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
  9. }
  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->enhanceSigchildCompatibility || !$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->enhanceSigchildCompatibility || !$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. *
  2. * @deprecated since version 3.3. Use array or object access instead.
  3. */
  4. public function getRawData()
  5. {
  6. @trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Use the array or object access instead.', __METHOD__));

    Adding "@" before trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Use the array or object access instead.', __METHOD__)) 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. return $this->data;
  8. }
  9. /**
  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 34

  • Minor
  • Bugrisk

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

  1. * @return string
  2. */
  3. private function addMethodMap()
  4. {
  5. $definitions = $this->container->getDefinitions();
  6. if (!$definitions || !$definitions = array_filter($definitions, function ($def) { return !$def->isSynthetic(); })) {

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

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Nicolas Grekas
  7. return '';
  8. }
  9. $code = " \$this->methodMap = array(\n";
  10. ksort($definitions);
  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. {
  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->getContainer()->get('kernel')->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. $title = 'Available registered bundles with their extension alias if available';
  2. $headers = array('Bundle name', 'Extension alias');
  3. $rows = array();
  4. $bundles = $this->getContainer()->get('kernel')->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. *
  2. * @return string
  3. */
  4. private function findAlternative($nonExistentBundleName)
  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. *
  2. * @return \ArrayObject The dependencies for the given node
  3. *
  4. * @throws \RuntimeException if a circular dependency is detected
  5. */
  6. private static function resolveDependencies(array $tree, $node, \ArrayObject $resolved = null, \ArrayObject $unresolved = null)

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

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Victor Berchet
  7. {
  8. if (null === $resolved) {
  9. $resolved = new \ArrayObject();
  10. }
  11. if (null === $unresolved) {
  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 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. 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. }
  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 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_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_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(Workflow $workflow, $supportStrategy, $subject, $workflowName)

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

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Andreas Kleemann
  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

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

Time to fix: about 5.5 days
Open Issue Permalink
Collective

Commented code should not be committed 23

  • Minor
  • Deadcode

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

  1. * {@inheritdoc}
  2. */
  3. public function parse($source)
  4. {
  5. // Matches an optional namespace, optional element, and required class
  6. // $source = 'test|input.ab6bd_field';

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Troy McCabe
  7. // $matches = array (size=4)
  8. // 0 => string 'test|input.ab6bd_field' (length=22)
  9. // 1 => string 'test' (length=4)
  10. // 2 => string 'input' (length=5)
  11. // 3 => string 'ab6bd_field' (length=11)
  1. * {@inheritdoc}
  2. */
  3. public function parse($source)
  4. {
  5. // Matches an optional namespace, required element or `*`
  6. // $source = 'testns|testel';

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Troy McCabe
  7. // $matches = array (size=3)
  8. // 0 => string 'testns|testel' (length=13)
  9. // 1 => string 'testns' (length=6)
  10. // 2 => string 'testel' (length=6)
  11. if (preg_match('/^(?:([a-z]++)\|)?([\w-]++|\*)$/i', trim($source), $matches)) {
  1. * {@inheritdoc}
  2. */
  3. public function parse($source)
  4. {
  5. // Matches an optional namespace, optional element, and required id
  6. // $source = 'test|input#ab6bd_field';

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Troy McCabe
  7. // $matches = array (size=4)
  8. // 0 => string 'test|input#ab6bd_field' (length=22)
  9. // 1 => string 'test' (length=4)
  10. // 2 => string 'input' (length=5)
  11. // 3 => string 'ab6bd_field' (length=11)
  1. // a construct like:
  2. // $a = new ServiceA(ServiceB $b); $b = new ServiceB(ServiceA $a);
  3. // this is an indication for a wrong implementation, you can circumvent this problem
  4. // by setting up your service structure like this:
  5. // $b = new ServiceB();

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Johannes M. Schmitt
  6. // $a = new ServiceA(ServiceB $b);
  7. // $b->setServiceA(ServiceA $a);
  8. if ($this->hasReference($id, $sDefinition->getArguments())) {
  9. throw new ServiceCircularReferenceException($id, array($id));
  10. }
  1. $this->loadedList = $this->loader->loadChoiceList($this->value);
  2. $this->loaded = true;
  3. return $this->loadedList->getStructuredValues();
  4. // In 4.0 keep the following line only:
  5. // return $this->loader->loadChoiceList($this->value)->getStructuredValues();

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Jules Pietri
  6. }
  7. /**
  8. * {@inheritdoc}
  9. */
  1. $this->loadedList = $this->loader->loadChoiceList($this->value);
  2. $this->loaded = true;
  3. return $this->loadedList->getOriginalKeys();
  4. // In 4.0 keep the following line only:
  5. // return $this->loader->loadChoiceList($this->value)->getOriginalKeys();

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Jules Pietri
  6. }
  7. /**
  8. * {@inheritdoc}
  9. */
  1. // Some languages are translated together with their region,
  2. // i.e. "en_GB" is translated as "British English"
  3. // we don't include these languages though because they mess up
  4. // the name sorting
  5. // $name = $this->langBundle->getLanguageName($displayLocale, $lang, $region);

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  6. // Some languages are simply not translated
  7. // Example: "az" (Azerbaijani) has no translation in "af" (Afrikaans)
  8. if (null === ($name = $this->languageDataProvider->getName($lang, $displayLocale))) {
  9. return;
  1. return;
  2. }
  3. // "as" (Assamese) has no "Variants" block
  4. //if (!$langBundle->get('Variants')) {
  5. // continue;

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  6. //}
  7. $extras = array();
  8. // Discover the name of the script part of the locale
  1. $compiler = new GenrbCompiler($genrb, $genrbEnv);
  2. $config = new GeneratorConfig($sourceDir.'/data', $icuVersionInDownload);
  3. $baseDir = dirname(__DIR__).'/data';
  4. //$txtDir = $baseDir.'/txt';

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  5. $jsonDir = $baseDir;
  6. //$phpDir = $baseDir.'/'.Intl::PHP;
  7. //$resDir = $baseDir.'/'.Intl::RB_V2;
  8. $targetDirs = array($jsonDir/*, $resDir*/);
  1. $baseDir = dirname(__DIR__).'/data';
  2. //$txtDir = $baseDir.'/txt';
  3. $jsonDir = $baseDir;
  4. //$phpDir = $baseDir.'/'.Intl::PHP;

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  5. //$resDir = $baseDir.'/'.Intl::RB_V2;
  6. $targetDirs = array($jsonDir/*, $resDir*/);
  7. $workingDirs = array($jsonDir/*, $txtDir, $resDir*/);
  1. $baseDir = dirname(__DIR__).'/data';
  2. //$txtDir = $baseDir.'/txt';
  3. $jsonDir = $baseDir;
  4. //$phpDir = $baseDir.'/'.Intl::PHP;
  5. //$resDir = $baseDir.'/'.Intl::RB_V2;

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  6. $targetDirs = array($jsonDir/*, $resDir*/);
  7. $workingDirs = array($jsonDir/*, $txtDir, $resDir*/);
  8. //$config->addBundleWriter($txtDir, new TextBundleWriter());
  1. //$resDir = $baseDir.'/'.Intl::RB_V2;
  2. $targetDirs = array($jsonDir/*, $resDir*/);
  3. $workingDirs = array($jsonDir/*, $txtDir, $resDir*/);
  4. //$config->addBundleWriter($txtDir, new TextBundleWriter());

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  5. $config->addBundleWriter($jsonDir, new JsonBundleWriter());
  6. echo "Starting resource bundle compilation. This may take a while...\n";
  7. $filesystem->remove($workingDirs);
  1. echo "Generating language data...\n";
  2. $generator = new LanguageDataGenerator($compiler, Intl::LANGUAGE_DIR);
  3. $generator->generateData($config);
  4. //echo "Compiling...\n";

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  5. //
  6. //$compiler->compile($txtDir.'/'.Intl::LANGUAGE_DIR, $resDir.'/'.Intl::LANGUAGE_DIR);
  7. echo "Generating script data...\n";
  1. $generator = new LanguageDataGenerator($compiler, Intl::LANGUAGE_DIR);
  2. $generator->generateData($config);
  3. //echo "Compiling...\n";
  4. //
  5. //$compiler->compile($txtDir.'/'.Intl::LANGUAGE_DIR, $resDir.'/'.Intl::LANGUAGE_DIR);

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  6. echo "Generating script data...\n";
  7. $generator = new ScriptDataGenerator($compiler, Intl::SCRIPT_DIR);
  8. $generator->generateData($config);
  1. echo "Generating script data...\n";
  2. $generator = new ScriptDataGenerator($compiler, Intl::SCRIPT_DIR);
  3. $generator->generateData($config);
  4. //echo "Compiling...\n";

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  5. //
  6. //$compiler->compile($txtDir.'/'.Intl::SCRIPT_DIR, $resDir.'/'.Intl::SCRIPT_DIR);
  7. echo "Generating region data...\n";
  1. $generator = new ScriptDataGenerator($compiler, Intl::SCRIPT_DIR);
  2. $generator->generateData($config);
  3. //echo "Compiling...\n";
  4. //
  5. //$compiler->compile($txtDir.'/'.Intl::SCRIPT_DIR, $resDir.'/'.Intl::SCRIPT_DIR);

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  6. echo "Generating region data...\n";
  7. $generator = new RegionDataGenerator($compiler, Intl::REGION_DIR);
  8. $generator->generateData($config);
  1. echo "Generating region data...\n";
  2. $generator = new RegionDataGenerator($compiler, Intl::REGION_DIR);
  3. $generator->generateData($config);
  4. //echo "Compiling...\n";

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  5. //
  6. //$compiler->compile($txtDir.'/'.Intl::REGION_DIR, $resDir.'/'.Intl::REGION_DIR);
  7. echo "Generating currency data...\n";
  1. $generator = new RegionDataGenerator($compiler, Intl::REGION_DIR);
  2. $generator->generateData($config);
  3. //echo "Compiling...\n";
  4. //
  5. //$compiler->compile($txtDir.'/'.Intl::REGION_DIR, $resDir.'/'.Intl::REGION_DIR);

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  6. echo "Generating currency data...\n";
  7. $generator = new CurrencyDataGenerator($compiler, Intl::CURRENCY_DIR);
  8. $generator->generateData($config);
  1. echo "Generating currency data...\n";
  2. $generator = new CurrencyDataGenerator($compiler, Intl::CURRENCY_DIR);
  3. $generator->generateData($config);
  4. //echo "Compiling...\n";

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  5. //
  6. //$compiler->compile($txtDir.'/'.Intl::CURRENCY_DIR, $resDir.'/'.Intl::CURRENCY_DIR);
  7. echo "Generating locale data...\n";
  1. $generator = new CurrencyDataGenerator($compiler, Intl::CURRENCY_DIR);
  2. $generator->generateData($config);
  3. //echo "Compiling...\n";
  4. //
  5. //$compiler->compile($txtDir.'/'.Intl::CURRENCY_DIR, $resDir.'/'.Intl::CURRENCY_DIR);

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  6. echo "Generating locale data...\n";
  7. $reader = new BundleEntryReader(new JsonBundleReader());
  1. new RegionDataProvider($jsonDir.'/'.Intl::REGION_DIR, $reader)
  2. );
  3. $generator->generateData($config);
  4. //echo "Compiling...\n";

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  5. //
  6. //$compiler->compile($txtDir.'/'.Intl::LOCALE_DIR, $resDir.'/'.Intl::LOCALE_DIR);
  7. //
  8. //$filesystem->remove($txtDir);
  1. $generator->generateData($config);
  2. //echo "Compiling...\n";
  3. //
  4. //$compiler->compile($txtDir.'/'.Intl::LOCALE_DIR, $resDir.'/'.Intl::LOCALE_DIR);

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  5. //
  6. //$filesystem->remove($txtDir);
  7. echo "Resource bundle compilation complete.\n";
  1. //echo "Compiling...\n";
  2. //
  3. //$compiler->compile($txtDir.'/'.Intl::LOCALE_DIR, $resDir.'/'.Intl::LOCALE_DIR);
  4. //
  5. //$filesystem->remove($txtDir);

    Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.

    Time to fix: about 30 minutes
    Open Issue Permalink
    Last edited by Bernhard Schussek
  6. echo "Resource bundle compilation complete.\n";
  7. $svnInfo = <<<SVN_INFO
  8. SVN information

Unused method, property, variable or parameter 165

  • Minor
  • Deadcode

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

  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. }
  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. 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 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. 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. }
  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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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. );