Your project should not use invalid offsets
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_offset
- *
- * @return static the current builder
- */
- public function attribute($name, $value): static
- {
- $this->_xml[$name] = $this->normalizeValue($value);
- return $this;
- }
- /**
Your project must not contain invalid instantiations 2
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_instantiation
- $this->_xml->{$name}[$idx] = $this->normalizeValue($value);
- foreach ($attributes as $attr => $v) {
- $this->_xml->{$name}[$idx][$attr] = $this->normalizeValue($v);
- }
- $node = new self($this->_xml->$name);
- if ($getLastChild) {
- $array = $this->_xml->xpath($name."[last()]");
- if (is_array($array)) {
- $xml = array_shift($array);
- if ($xml instanceof \SimpleXMLElement) {
- public function convert(int $code, string $message, ?\Throwable $previous = null, string $file ='', ?int $line = null, array $backtrace = []): \Throwable
- {
- return match ($code) {
- E_NOTICE, E_USER_NOTICE => new Notice($message, $line, $previous, $file, $backtrace),
- E_WARNING, E_USER_WARNING => new Warning($message, $line, $previous, $file, $backtrace),
- E_RECOVERABLE_ERROR, E_ERROR, E_CORE_ERROR => new Fatal($message, $line, $previous, $file),
- default => new Error($message, $line, $previous, $file, $backtrace),
- };
- }
- }
Your project should not use invalid return types
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_return_typehint
- *
- * @return string escaped string
- */
- public static function utf8ForXML($string)
- {
- return preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $string);
- }
- }
Your project should not use invalid parameter and return typehints 5
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_typehint
- public static function createDefault(): Converter
- {
- return new self();
- }
- public function convert(int $code, string $message, ?\Throwable $previous = null, string $file ='', ?int $line = null, array $backtrace = []): \Throwable
- {
- return match ($code) {
- E_NOTICE, E_USER_NOTICE => new Notice($message, $line, $previous, $file, $backtrace),
- E_WARNING, E_USER_WARNING => new Warning($message, $line, $previous, $file, $backtrace),
- E_RECOVERABLE_ERROR, E_ERROR, E_CORE_ERROR => new Fatal($message, $line, $previous, $file),
- declare(strict_types=1);
- namespace Errbit\Errors;
- class Error extends BaseError
- {
- public function __construct(
- string $message,
- ?int $line = null,
- ?\Throwable $previous = null,
- string $file = '',
- array $backtrace = []
- abstract class BaseError extends \Exception
- {
- protected string $errorFile = '';
- protected array $backtrace = [];
- public function __construct(
- string $message = "",
- int $code = 0,
- ?Throwable $previous = null,
- string $file = '',
- array $backtrace = []
- declare(strict_types=1);
- namespace Errbit\Errors;
- class Warning extends BaseError
- {
- public function __construct(
- string $message,
- ?int $line = null,
- ?\Throwable $previous = null,
- string $file = '',
- array $backtrace = []
- declare(strict_types=1);
- namespace Errbit\Errors;
- class Notice extends BaseError
- {
- public function __construct(
- string $message,
- ?int $line = null,
- ?\Throwable $previous = null,
- string $file = '',
- array $backtrace = []
Your project should use return types
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.missing_return_typehint
- public function getErrorFile(): string
- {
- return $this->errorFile;
- }
- public function getBacktrace(): array
- {
- return $this->backtrace;
- }
- }
Your project must not contain invalid function or method calls
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_call
- }
- $userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
- /** @var array<int, string> $ignoreUserAgents */
- $ignoreUserAgents = $this->config['ignore_user_agent'];
- foreach ($ignoreUserAgents as $ua) {
- if ($userAgent !== '' && str_contains($userAgent, $ua)) {
- return false;
- }
- }
- return true;