Missing use statement should be avoided

  • Major
  • Bugrisk

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

  1. }
  2. if (is_string($timestamp)) {
  3. try {
  4. $timestamp = new DateTime($timestamp);
  5. } catch (Exception $e) {

    The Exception class resolves to the following classes: League\Flysystem\Exception or Prophecy\Exception\Exception or SebastianBergmann\GlobalState\Exception or SebastianBergmann\RecursionContext\Exception or Stash\Exception\Exception or Symfony\Component\Config\Definition\Exception\Exception.
    Did you forget to add a corresponding use statement for one of them?

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Chauncey McAskill
  6. throw new InvalidArgumentException(
  7. sprintf('Invalid timestamp: %s', $e->getMessage())
  8. );
  9. }
  10. }

Unused use statement should be avoided 4

  • Minor
  • Deadcode

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

  1. use \DateTime;
  2. use \DateTimeInterface;
  3. use \InvalidArgumentException;
  4. use \Pimple\Container;

    The class Pimple\Container is declared but never used. You should remove the use statement.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Chauncey McAskill
  5. use \Charcoal\Admin\AdminWidget;
  6. /**
  7. * A basic search history widget.
  1. <?php
  2. namespace Charcoal\Search;
  3. use \DateTime;
  4. use \DateTimeInterface;

    The class DateTimeInterface is declared but never used. You should remove the use statement.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Chauncey McAskill
  5. use \Traversable;
  6. use \InvalidArgumentException;
  7. /**
  8. * Defines a search log.
  1. namespace Charcoal\Search;
  2. use \DateTime;
  3. use \DateTimeInterface;
  4. use \Traversable;

    The class Traversable is declared but never used. You should remove the use statement.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Chauncey McAskill
  5. use \InvalidArgumentException;
  6. /**
  7. * Defines a search log.
  8. */
  1. namespace Charcoal\Search;
  2. use \DateTime;
  3. use \DateTimeInterface;
  4. use \Traversable;
  5. use \InvalidArgumentException;

    The class InvalidArgumentException is declared but never used. You should remove the use statement.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Chauncey McAskill
  6. /**
  7. * Defines a search log.
  8. */
  9. interface SearchLogInterface