sleep() should not be used 2

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

  1. $minimumExecutionTime = $options['minimum_execution_time'] ?: $minimumExecutionTime;
  2. $timeout = $options['timeout'] ?: $timeout;
  3. if (count($successes) < 1) {
  4. if ($minimumExecutionTime > 0) {
  5. sleep($minimumExecutionTime);

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

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Maksim Grib
  6. }
  7. throw new ServerConnectionException('Worker was unable to connect to any server.');
  8. }
  9. $objInstance = $this->createJob($worker);
  1. if ($minimumExecutionTime > 0) {
  2. $now = time();
  3. $remaining = $minimumExecutionTime - ($now - $time);
  4. if ($remaining > 0) {
  5. sleep($remaining);

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

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Dominic Grostate
  6. }
  7. }
  8. return $this;
  9. }

Error silenced by the at sign (@) 2

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

Updated rule! We've recently tweaked this rule. This may explain the disappearance of false positives, or new suggestions not linked to any activity in the code.
  1. $successes = array();
  2. if (!empty($servers)) {
  3. foreach ($servers as $server) {
  4. if (@$gmworker->addServer($server['host'], $server['port'])) {

    Adding "@" before $gmworker->addServer($server['host'], $server['port']) 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 Dominic Grostate
  5. $successes[] = $server;
  6. }
  7. }
  8. } else {
  9. if (@$gmworker->addServer()) {
  1. if (@$gmworker->addServer($server['host'], $server['port'])) {
  2. $successes[] = $server;
  3. }
  4. }
  5. } else {
  6. if (@$gmworker->addServer()) {

    Adding "@" before $gmworker->addServer() 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 Dominic Grostate
  7. $successes[] = array('127.0.0.1', 4730);
  8. }
  9. }
  10. return $successes;

Unused method, property, variable or parameter 2

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

  1. *
  2. * @throws WorkerNameTooLongException If name is too large
  3. *
  4. * @api
  5. */
  6. public function generateUniqueKey($name, $params, $unique, $method)

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

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by mmoreram
  7. {
  8. $unique = !$unique && $this->generateUniqueKey
  9. ? md5($name . $params)
  10. : $unique;
  1. /**
  2. * @var KernelInterface
  3. *
  4. * Kernel object
  5. */
  6. private $kernel;

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

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Marc
  7. /**
  8. * @var Reader
  9. *
  10. * Annotation Reader

The boot method in a bundle should be empty

More information: https://insight.symfony.com/what-we-analyse/symfony.bundle_boot_method_should_be_empty

in GearmanBundle.php, line 29
  1. class GearmanBundle extends Bundle
  2. {
  3. /**
  4. * Boots the Bundle.
  5. */
  6. public function boot()

    GearmanBundle has a non-empty boot method, which may slow down Symfony booting.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Marc
  7. {
  8. $kernel = $this->container->get('kernel');
  9. AnnotationRegistry::registerFile($kernel
  10. ->locateResource("@GearmanBundle/Driver/Gearman/Work.php")

Deprecated class usage found 4

More information: https://insight.symfony.com/what-we-analyse/third_party.use_deprecated_class

  1. /**
  2. * @var DialogHelper
  3. *
  4. * Dialog
  5. */
  6. protected $dialog;

    The Symfony\Component\Console\Helper\DialogHelper class has been deprecated in Symfony 2.5. Use the Symfony\Component\Console\Helper\QuestionHelper class instead.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by mmoreram
  7. /**
  8. * Set gearman client
  9. *
  10. * @param GearmanClient $gearmanClient Gearman client
  1. protected function execute(InputInterface $input, OutputInterface $output)
  2. {
  3. /**
  4. * @var DialogHelper $dialog
  5. */
  6. $dialog = $this->getHelperSet()->get('dialog');

    The Symfony\Component\Console\Helper\DialogHelper class has been deprecated in Symfony 2.5. Use the Symfony\Component\Console\Helper\QuestionHelper class instead.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Marc
  7. if (
  8. !$input->getOption('no-interaction') &&
  9. !$dialog->askConfirmation(
  10. $output,
  1. protected function execute(InputInterface $input, OutputInterface $output)
  2. {
  3. /**
  4. * @var DialogHelper $dialog
  5. */
  6. $dialog = $this

    The Symfony\Component\Console\Helper\DialogHelper class has been deprecated in Symfony 2.5. Use the Symfony\Component\Console\Helper\QuestionHelper class instead.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by mmoreram
  7. ->getHelperSet()
  8. ->get('dialog');
  9. if (
  10. !$input->getOption('no-interaction') &&
in Module/JobClass.php, line 28
  1. *
  2. * This class provide all worker definition.
  3. *
  4. * @since 2.3.1
  5. */
  6. class JobClass extends ContainerAware

    The Symfony\Component\DependencyInjection\ContainerAware class has been deprecated in Symfony 2.8. Use the Symfony\Component\DependencyInjection\ContainerAwareTrait class instead.

    Time to fix: about 2 hours
    Open Issue Permalink
    Last edited by Marc
  7. {
  8. /**
  9. * @var string
  10. *
  11. * Default description when is not defined