Missing use statement should be avoided

  • Major
  • Bugrisk

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

  1. 'The basename is missing from the target'
  2. );
  3. }
  4. if (!isset($info['filename']) || $info['filename'] === '') {
  5. throw new UnexpectedValueException(

    The UnexpectedValueException class resolves to the following classes: Doctrine\Instantiator\Exception\UnexpectedValueException or Guzzle\Common\Exception\UnexpectedValueException.
    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. 'The filename is missing from the target'
  7. );
  8. }
  9. $defaults = [

Source code should not contain TODO comments 12

  • Minor
  • Architecture

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

  1. $dir = $basePath.$this->uploadPath();
  2. $filename = ($filename) ? $this->sanitizeFilename($filename) : $this->generateFilename();
  3. if (!file_exists($dir)) {
  4. // @todo: Feedback

    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 Mathieu Ducharme
  5. $this->logger->debug(
  6. 'Path does not exist. Attempting to create path '.$dir.'.',
  7. [ get_called_class().'::'.__FUNCTION__ ]
  8. );
  9. mkdir($dir, 0777, true);
  1. }
  2. if ($effects) {
  3. $basePath = $this->basePath();
  4. // @todo Save original file here

    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 Chauncey McAskill
  5. $image->open($value);
  6. $target = null;
  7. if (null !== parse_url($value, PHP_URL_HOST)) {
  8. $target = $this->uploadPath().pathinfo($value, PATHINFO_BASENAME);
  1. {
  2. if (!$this->unique()) {
  3. return true;
  4. }
  5. /** @todo Check in the model's storage if the value already exists. */

    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 Mathieu Ducharme
  6. return true;
  7. }
  8. /**
  9. * @return boolean
  1. }
  2. /**
  3. * AbstractProperty > inputVal(). Convert `DateTime` to input-friendly string.
  4. *
  5. * @todo [mcaskill: 2016-03-04] Should this be DateTime::RFC3339?

    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 Chauncey McAskill
  6. * @param mixed $val Optional. The value to to convert for input.
  7. * @throws Exception If the date/time is invalid.
  8. * @return string|null
  9. */
  10. public function inputVal($val)
  1. protected $propertyFactory;
  2. /**
  3. * Set a property factory.
  4. *
  5. * @todo [mcaskill 2016-09-16] Move factory setter to classes using this trait.

    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 Chauncey McAskill
  6. * @param FactoryInterface $factory The property factory, to createable property values.
  7. * @return DescribableInterface
  8. */
  9. protected function setPropertyFactory(FactoryInterface $factory)
  10. {
  1. }
  2. /**
  3. * Retrieve the property factory.
  4. *
  5. * @todo [mcaskill 2016-09-16] Move factory getter to classes using this trait.

    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 Chauncey McAskill
  6. * Redefine this method as an abstract method.
  7. * @throws RuntimeException If the property factory was not previously set.
  8. * @return FactoryInterface
  9. */
  10. protected function propertyFactory()
  1. /**
  2. * Get the SQL type (Storage format)
  3. *
  4. * @return string The SQL type
  5. * @todo Only the 2-character language code (ISO 639-1)

    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 Chauncey McAskill
  6. */
  7. public function sqlType()
  8. {
  9. if ($this->multiple()) {
  10. return 'TEXT';
  1. }
  2. /**
  3. * Retrieve the length of the string.
  4. *
  5. * @todo Returns the string length based on the displayed value.

    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 Chauncey McAskill
  6. * To be determined how to best handle multilingual and multiton values.
  7. * @throws Exception If the value is not a string.
  8. * @return integer
  9. */
  10. public function length()
  1. ]);
  2. }
  3. /**
  4. * @return boolean
  5. * @todo Support `multiple` / `l10n`

    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 Mathieu Ducharme
  6. */
  7. public function validateMaxLength()
  8. {
  9. $val = $this->val();
  1. return $valid;
  2. }
  3. /**
  4. * @return boolean
  5. * @todo Support `multiple` / `l10n`

    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 Mathieu Ducharme
  6. */
  7. public function validateMinLength()
  8. {
  9. $val = $this->val();
  1. /**
  2. * Ensure l10n can not be TRUE for structure property.
  3. *
  4. * @see AbstractProperty::setL10n()
  5. * @todo Add support for L10N;

    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 Chauncey McAskill
  6. * @param boolean $flag The l10n, or "translatable" flag.
  7. * @throws InvalidArgumentException If the L10N argument is TRUE (must be FALSE).
  8. * @return IdProperty Chainable
  9. */
  10. public function setL10n($flag)
  1. }
  2. /**
  3. * Create a data-model structure.
  4. *
  5. * @todo Add support for simple ArrayAccess models.

    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 Chauncey McAskill
  6. * @throws RuntimeException If the structure is invalid.
  7. * @return ArrayAccess
  8. */
  9. private function createStructureModel()
  10. {

Unused method, property, variable or parameter 4

  • Minor
  • Deadcode

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

  1. $file = $this->val();
  2. } elseif (is_string($file)) {
  3. if (in_array($file, $this->acceptedMimetypes())) {
  4. $mime = $file;
  5. } else {
  6. $mime = $this->mimetypeFor($file);

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

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Chauncey McAskill
  7. }
  8. }
  9. return '';
  10. }
  1. *
  2. * @param string $type The processing engine.
  3. * @throws InvalidArgumentException If the drive type is not a string.
  4. * @return ImageProperty Chainable
  5. */
  6. private function setDriverType($type)

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

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Chauncey McAskill
  7. {
  8. if (!is_string($type)) {
  9. throw new InvalidArgumentException(sprintf(
  10. 'Image driver type must be a string, received %s',
  11. (is_object($type) ? get_class($type) : gettype($type))
  1. case 'image/svg+xml':
  2. $ext = 'svg';
  3. break;
  4. case 'image/webp':
  5. $ext = 'webp';

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

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Chauncey McAskill
  6. break;
  7. }
  8. }
  9. /**
  1. private $allowedTypes;
  2. /**
  3. * @var boolean $groupedByType
  4. */
  5. private $groupedByType = true;

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

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Mathieu Ducharme
  6. /**
  7. * @var string $joinTable
  8. */
  9. private $joinTable = 'charcoal_multi_objects';

Unused use statement should be avoided 2

  • Minor
  • Deadcode

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

  1. namespace Charcoal\Property;
  2. use InvalidArgumentException;
  3. use OutOfBoundsException;
  4. use UnexpectedValueException;

    The class UnexpectedValueException 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. // From 'charcoal-image'
  6. use Charcoal\Image\ImageFactory;
  7. use Charcoal\Image\ImageInterface;
  1. <?php
  2. namespace Charcoal\Property;
  3. use PDO;

    The class PDO 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
  4. // From 'charcoal-property'
  5. use Charcoal\Property\StructureProperty;
  6. /**