Your project should not use invalid offsets

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

  1. *
  2. * @return static the current builder
  3. */
  4. public function attribute($name, $value): static
  5. {
  6. $this->_xml[$name] = $this->normalizeValue($value);
    SimpleXMLElement does not accept string.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Max Małecki
  7. return $this;
  8. }
  9. /**

Your project must not contain invalid instantiations 2

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

  1. $this->_xml->{$name}[$idx] = $this->normalizeValue($value);
  2. foreach ($attributes as $attr => $v) {
  3. $this->_xml->{$name}[$idx][$attr] = $this->normalizeValue($v);
  4. }
  5. $node = new self($this->_xml->$name);
    Parameter #1 $xml of class Errbit\Utils\XmlBuilder constructor expects SimpleXMLElement|null, mixed given.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by emgiezet
  6. if ($getLastChild) {
  7. $array = $this->_xml->xpath($name."[last()]");
  8. if (is_array($array)) {
  9. $xml = array_shift($array);
  10. if ($xml instanceof \SimpleXMLElement) {
  1. public function convert(int $code, string $message, ?\Throwable $previous = null, string $file ='', ?int $line = null, array $backtrace = []): \Throwable
  2. {
  3. return match ($code) {
  4. E_NOTICE, E_USER_NOTICE => new Notice($message, $line, $previous, $file, $backtrace),
  5. E_WARNING, E_USER_WARNING => new Warning($message, $line, $previous, $file, $backtrace),
  6. E_RECOVERABLE_ERROR, E_ERROR, E_CORE_ERROR => new Fatal($message, $line, $previous, $file),
    Parameter #2 $line of class Errbit\Errors\Fatal constructor expects int, int|null given.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by Max Małecki
  7. default => new Error($message, $line, $previous, $file, $backtrace),
  8. };
  9. }
  10. }

Your project should not use invalid return types

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

  1. *
  2. * @return string escaped string
  3. */
  4. public static function utf8ForXML($string)
  5. {
  6. return preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $string);
    Method Errbit\Utils\XmlBuilder::utf8ForXML() should return string but returns string|null.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Filip Chmarzynski
  7. }
  8. }

Your project should not use invalid parameter and return typehints 5

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

  1. public static function createDefault(): Converter
  2. {
  3. return new self();
  4. }
  5. public function convert(int $code, string $message, ?\Throwable $previous = null, string $file ='', ?int $line = null, array $backtrace = []): \Throwable
    Method Errbit\Utils\Converter::convert() has parameter $backtrace with no value type specified in iterable type array.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Max Małecki
  6. {
  7. return match ($code) {
  8. E_NOTICE, E_USER_NOTICE => new Notice($message, $line, $previous, $file, $backtrace),
  9. E_WARNING, E_USER_WARNING => new Warning($message, $line, $previous, $file, $backtrace),
  10. E_RECOVERABLE_ERROR, E_ERROR, E_CORE_ERROR => new Fatal($message, $line, $previous, $file),
  1. declare(strict_types=1);
  2. namespace Errbit\Errors;
  3. class Error extends BaseError
  4. {
  5. public function __construct(
    Method Errbit\Errors\Error::__construct() has parameter $backtrace with no value type specified in iterable type array.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Max Małecki
  6. string $message,
  7. ?int $line = null,
  8. ?\Throwable $previous = null,
  9. string $file = '',
  10. array $backtrace = []
  1. abstract class BaseError extends \Exception
  2. {
  3. protected string $errorFile = '';
  4. protected array $backtrace = [];
  5. public function __construct(
    Method Errbit\Errors\BaseError::__construct() has parameter $backtrace with no value type specified in iterable type array.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Max Małecki
  6. string $message = "",
  7. int $code = 0,
  8. ?Throwable $previous = null,
  9. string $file = '',
  10. array $backtrace = []
  1. declare(strict_types=1);
  2. namespace Errbit\Errors;
  3. class Warning extends BaseError
  4. {
  5. public function __construct(
    Method Errbit\Errors\Warning::__construct() has parameter $backtrace with no value type specified in iterable type array.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Max Małecki
  6. string $message,
  7. ?int $line = null,
  8. ?\Throwable $previous = null,
  9. string $file = '',
  10. array $backtrace = []
  1. declare(strict_types=1);
  2. namespace Errbit\Errors;
  3. class Notice extends BaseError
  4. {
  5. public function __construct(
    Method Errbit\Errors\Notice::__construct() has parameter $backtrace with no value type specified in iterable type array.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Max Małecki
  6. string $message,
  7. ?int $line = null,
  8. ?\Throwable $previous = null,
  9. string $file = '',
  10. array $backtrace = []

Your project should use return types

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

  1. public function getErrorFile(): string
  2. {
  3. return $this->errorFile;
  4. }
  5. public function getBacktrace(): array
    Method Errbit\Errors\BaseError::getBacktrace() return type has no value type specified in iterable type array.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Max Małecki
  6. {
  7. return $this->backtrace;
  8. }
  9. }

Your project must not contain invalid function or method calls

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

in src/Errbit/Errbit.php, line 172
  1. }
  2. $userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
  3. /** @var array<int, string> $ignoreUserAgents */
  4. $ignoreUserAgents = $this->config['ignore_user_agent'];
  5. foreach ($ignoreUserAgents as $ua) {
  6. if ($userAgent !== '' && str_contains($userAgent, $ua)) {
    Parameter #1 $haystack of function str_contains expects string, mixed given.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Max Małecki
  7. return false;
  8. }
  9. }
  10. return true;