Your project must not contain invalid function or method calls 44

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

in src/Errbit/Errbit.php, line 146
  1. public function notify(\Throwable $exception, array $options = []): static
  2. {
  3. $this->checkConfig();
  4. $config = array_merge($this->config, $options);
  5. if ($this->shouldNotify($exception, $config['skipped_exceptions'])) {
    Parameter #2 $skippedExceptions of method Errbit\Errbit::shouldNotify() expects array, mixed given.
    Last edited by karolsojko
  6. $this->getWriter()->write($exception, $config);
  7. $this->notifyObservers($exception, $config);
  8. }
  9. return $this;
in src/Errbit/Errbit.php, line 169
  1. return false;
  2. }
  3. }
  4. $userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
  5. foreach ($this->config['ignore_user_agent'] as $ua) {
  6. if ($userAgent !== '' && str_contains($userAgent, $ua)) {
    Parameter #2 $needle of function str_contains expects string, mixed given.
    Last edited by Max Małecki
  7. return false;
  8. }
  9. }
  10. return true;
in src/Errbit/Errbit.php, line 169
  1. return false;
  2. }
  3. }
  4. $userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
  5. foreach ($this->config['ignore_user_agent'] as $ua) {
  6. if ($userAgent !== '' && str_contains($userAgent, $ua)) {
    Parameter #1 $haystack of function str_contains expects string, mixed given.
    Last edited by Max Małecki
  7. return false;
  8. }
  9. }
  10. return true;
  1. return sprintf(
  2. '%s://%s%s%s',
  3. $this->guessProtocol(),
  4. $this->guessHost(),
  5. $this->guessPort(),
  6. $_SERVER['REQUEST_URI']
    Parameter #5 ...$values of function sprintf expects bool|float|int|string|null, mixed given.
    Last edited by emgiezet
  7. );
  8. }
  9. return null;
  10. }
  1. {
  2. if (!empty($_SERVER['SERVER_PORT']) && !in_array(
  3. $_SERVER['SERVER_PORT'],
  4. [80, 443]
  5. )) {
  6. return sprintf(':%d', $_SERVER['SERVER_PORT']);
    Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, mixed given.
    Last edited by emgiezet
  7. }
  8. return '80';
  9. }
  1. if (is_array($this->options['params_filters'])) {
  2. foreach ($this->options['params_filters'] as $pattern) {
  3. foreach ($this->options[$name] as $key => $value) {
  4. if (preg_match($pattern, (string)$key)) {
    Parameter #1 $pattern of function preg_match expects string, mixed given.
    Last edited by emgiezet
  5. $this->options[$name][$key] = '[FILTERED]';
  6. }
  7. }
  8. }
  9. }
  1. return $builder->tag(
  2. 'notice',
  3. '',
  4. ['version' => Errbit::API_VERSION],
  5. function (XmlBuilder $notice) use ($exception, $options, $self) {
  6. $notice->tag('api-key', $options['api_key']);
    Parameter #2 $value of method Errbit\Utils\XmlBuilder::tag() expects string, mixed given.
    Last edited by Filip Chmarzynski
  7. $notice->tag(
  8. 'notifier',
  9. '',
  10. [],
  11. function (XmlBuilder $notifier) {
  1. $notice->tag(
  2. 'error',
  3. '',
  4. [],
  5. function (XmlBuilder $error) use ($exception, $self) {
  6. $class = Notice::className($exception);
    Parameter #1 $exception of static method Errbit\Exception\Notice::className() expects object, mixed given.
    Last edited by emgiezet
  7. $error->tag('class', $self->filterTrace($class));
  8. $error->tag(
  9. 'message',
  10. $self->filterTrace(
  11. sprintf(
  1. 'message',
  2. $self->filterTrace(
  3. sprintf(
  4. '%s: %s',
  5. $class,
  6. $exception->getMessage()
    Cannot call method getMessage() on mixed.
    Last edited by emgiezet
  7. )
  8. )
  9. );
  10. $error->tag(
  11. 'backtrace',
  1. 'message',
  2. $self->filterTrace(
  3. sprintf(
  4. '%s: %s',
  5. $class,
  6. $exception->getMessage()
    Parameter #3 ...$values of function sprintf expects bool|float|int|string|null, mixed given.
    Last edited by emgiezet
  7. )
  8. )
  9. );
  10. $error->tag(
  11. 'backtrace',
  1. [],
  2. function (XmlBuilder $backtrace) use (
  3. $exception,
  4. $self
  5. ) {
  6. $trace = $exception->getTrace();
    Cannot call method getTrace() on mixed.
    Last edited by emgiezet
  7. $file1 = $exception->getFile();
  8. $backtrace->tag(
  9. 'line',
  10. '',
  1. $exception,
  2. $self
  3. ) {
  4. $trace = $exception->getTrace();
  5. $file1 = $exception->getFile();
    Cannot call method getFile() on mixed.
    Last edited by emgiezet
  6. $backtrace->tag(
  7. 'line',
  8. '',
  9. [
  10. 'number' => $exception->getLine(),
  1. $file1 = $exception->getFile();
  2. $backtrace->tag(
  3. 'line',
  4. '',
  5. [
  6. 'number' => $exception->getLine(),
    Cannot call method getLine() on mixed.
    Last edited by emgiezet
  7. 'file' => !empty($file1) ? $self->filterTrace(
  8. $file1
  9. ) : '<unknown>',
  10. 'method' => "<unknown>",
  11. ]
  1. 'line',
  2. '',
  3. [
  4. 'number' => $exception->getLine(),
  5. 'file' => !empty($file1) ? $self->filterTrace(
  6. $file1
    Parameter #1 $str of method Errbit\Exception\Notice::filterTrace() expects string, mixed given.
    Last edited by emgiezet
  7. ) : '<unknown>',
  8. 'method' => "<unknown>",
  9. ]
  10. );
  1. '',
  2. [
  3. 'number' => $frame['line'] ?? 0,
  4. 'file' => isset($frame['file']) ?
  5. $self->filterTrace(
  6. $frame['file']
    Parameter #1 $str of method Errbit\Exception\Notice::filterTrace() expects string, mixed given.
    Last edited by emgiezet
  7. ) : '<unknown>',
  8. 'method' => $self->filterTrace(
  9. $self->formatMethod($frame)
  10. ),
  11. ]
  1. 'file' => isset($frame['file']) ?
  2. $self->filterTrace(
  3. $frame['file']
  4. ) : '<unknown>',
  5. 'method' => $self->filterTrace(
  6. $self->formatMethod($frame)
    Parameter #1 $frame of method Errbit\Exception\Notice::formatMethod() expects array, mixed given.
    Last edited by emgiezet
  7. ),
  8. ]
  9. );
  10. }
  11. }
  1. '',
  2. [],
  3. function (XmlBuilder $request) use ($options) {
  4. $request->tag(
  5. 'url',
  6. !empty($options['url']) ? $options['url'] : ''
    Parameter #2 $value of method Errbit\Utils\XmlBuilder::tag() expects string, mixed given.
    Last edited by emgiezet
  7. );
  8. $request->tag(
  9. 'component',
  10. !empty($options['controller']) ? $options['controller'] : ''
  11. );
  1. 'url',
  2. !empty($options['url']) ? $options['url'] : ''
  3. );
  4. $request->tag(
  5. 'component',
  6. !empty($options['controller']) ? $options['controller'] : ''
    Parameter #2 $value of method Errbit\Utils\XmlBuilder::tag() expects string, mixed given.
    Last edited by emgiezet
  7. );
  8. $request->tag(
  9. 'action',
  10. !empty($options['action']) ? $options['action'] : ''
  11. );
  1. 'component',
  2. !empty($options['controller']) ? $options['controller'] : ''
  3. );
  4. $request->tag(
  5. 'action',
  6. !empty($options['action']) ? $options['action'] : ''
    Parameter #2 $value of method Errbit\Utils\XmlBuilder::tag() expects string, mixed given.
    Last edited by emgiezet
  7. );
  8. if (!empty($options['parameters'])) {
  9. $request->tag(
  10. 'params',
  11. '',
  1. [],
  2. function (XmlBuilder $params) use ($options
  3. ) {
  4. Notice::xmlVarsFor(
  5. $params,
  6. $options['parameters']
    Parameter #2 $array of static method Errbit\Exception\Notice::xmlVarsFor() expects array, mixed given.
    Last edited by emgiezet
  7. );
  8. }
  9. );
  10. }
  1. [],
  2. function (XmlBuilder $session) use ($options
  3. ) {
  4. Notice::xmlVarsFor(
  5. $session,
  6. $options['session_data']
    Parameter #2 $array of static method Errbit\Exception\Notice::xmlVarsFor() expects array, mixed given.
    Last edited by emgiezet
  7. );
  8. }
  9. );
  10. }
  1. [],
  2. function (XmlBuilder $cgiData) use ($options
  3. ) {
  4. Notice::xmlVarsFor(
  5. $cgiData,
  6. $options['cgi_data']
    Parameter #2 $array of static method Errbit\Exception\Notice::xmlVarsFor() expects array, mixed given.
    Last edited by emgiezet
  7. );
  8. }
  9. );
  10. }
  11. }
  1. $notice->tag(
  2. 'user-attributes',
  3. '',
  4. [],
  5. function (XmlBuilder $user) use ($options) {
  6. Notice::xmlVarsFor($user, $options['user']);
    Parameter #2 $array of static method Errbit\Exception\Notice::xmlVarsFor() expects array, mixed given.
    Last edited by nkovacs
  7. }
  8. );
  9. }
  10. $notice->tag(
  1. $notice->tag(
  2. 'server-environment',
  3. '',
  4. [],
  5. function (XmlBuilder $env) use ($options) {
  6. $env->tag('project-root', $options['project_root']);
    Parameter #2 $value of method Errbit\Utils\XmlBuilder::tag() expects string, mixed given.
    Last edited by Filip Chmarzynski
  7. $env->tag(
  8. 'environment-name',
  9. $options['environment_name']
  10. );
  11. }
  1. [],
  2. function (XmlBuilder $env) use ($options) {
  3. $env->tag('project-root', $options['project_root']);
  4. $env->tag(
  5. 'environment-name',
  6. $options['environment_name']
    Parameter #2 $value of method Errbit\Utils\XmlBuilder::tag() expects string, mixed given.
    Last edited by emgiezet
  7. );
  8. }
  9. );
  10. }
  11. )->asXml();
  1. )) {
  2. return $str;
  3. }
  4. foreach ($this->options['backtrace_filters'] as $pattern => $replacement) {
  5. $str = preg_replace($pattern, (string)$replacement, $str);
    Parameter #3 $subject of function preg_replace expects array<float|int|string>|string, string|null given.
    Last edited by emgiezet
  6. }
  7. return $str;
  8. }
  1. public static function formatMethod(array $frame): string
  2. {
  3. if (!empty($frame['class']) && !empty($frame['type']) && !empty($frame['function'])) {
  4. return sprintf(
  5. '%s%s%s()',
  6. $frame['class'],
    Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, mixed given.
    Last edited by emgiezet
  7. $frame['type'],
  8. $frame['function']
  9. );
  10. } else {
  11. return sprintf(
  1. {
  2. if (!empty($frame['class']) && !empty($frame['type']) && !empty($frame['function'])) {
  3. return sprintf(
  4. '%s%s%s()',
  5. $frame['class'],
  6. $frame['type'],
    Parameter #3 ...$values of function sprintf expects bool|float|int|string|null, mixed given.
    Last edited by emgiezet
  7. $frame['function']
  8. );
  9. } else {
  10. return sprintf(
  11. '%s()',
  1. if (!empty($frame['class']) && !empty($frame['type']) && !empty($frame['function'])) {
  2. return sprintf(
  3. '%s%s%s()',
  4. $frame['class'],
  5. $frame['type'],
  6. $frame['function']
    Parameter #4 ...$values of function sprintf expects bool|float|int|string|null, mixed given.
    Last edited by emgiezet
  7. );
  8. } else {
  9. return sprintf(
  10. '%s()',
  11. !empty($frame['function']) ? $frame['function'] : '<unknown>'
  1. $frame['function']
  2. );
  3. } else {
  4. return sprintf(
  5. '%s()',
  6. !empty($frame['function']) ? $frame['function'] : '<unknown>'
    Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, mixed given.
    Last edited by emgiezet
  7. );
  8. }
  9. }
  10. /**
  1. $builder->tag(
  2. 'var',
  3. '',
  4. ['key' => $key],
  5. function ($var) use ($value) {
  6. Notice::xmlVarsFor($var, $value);
    Parameter #1 $builder of static method Errbit\Exception\Notice::xmlVarsFor() expects Errbit\Utils\XmlBuilder, mixed given.
    Last edited by emgiezet
  7. },
  8. true
  9. );
  10. } else {
  11. $builder->tag(
  1. ['key' => $key]
  2. );
  3. }
  4. } else {
  5. $builder->tag('var', $value, ['key' => $key]);
    Parameter #2 $value of method Errbit\Utils\XmlBuilder::tag() expects string, mixed given.
    Last edited by emgiezet
  6. }
  7. }
  8. }
  9. }
  1. * @param array $handlers
  2. */
  3. private function install(array $handlers): void
  4. {
  5. if (in_array('error', $handlers, true)) {
  6. set_error_handler([$this, 'onError'], error_reporting());
    Parameter #1 $callback of function set_error_handler expects (callable(int, string, string, int): bool)|null, array{$this(Errbit\Handlers\ErrorHandlers), 'onError'} given.
    Last edited by emgiezet
  7. }
  8. if (in_array('exception', $handlers, true)) {
  9. set_exception_handler([$this, 'onException']);
  10. }
  1. if (in_array('error', $handlers, true)) {
  2. set_error_handler([$this, 'onError'], error_reporting());
  3. }
  4. if (in_array('exception', $handlers, true)) {
  5. set_exception_handler([$this, 'onException']);
    Parameter #1 $callback of function set_exception_handler expects (callable(Throwable): void)|null, array{$this(Errbit\Handlers\ErrorHandlers), 'onException'} given.
    Last edited by emgiezet
  6. }
  7. if (in_array('fatal', $handlers, true)) {
  8. register_shutdown_function([$this, 'onShutdown']);
  9. }
  1. $this->_xml->{$name}[$idx][$attr] = $v;
  2. }
  3. $node = new self($this->_xml->$name);
  4. if ($getLastChild) {
  5. $array = $this->_xml->xpath($name."[last()]");
  6. $xml = array_shift($array);
    Parameter #1 $array of function array_shift expects array, array<SimpleXMLElement>|false|null given.
    Last edited by Max Małecki
  7. $node = new self($xml);
  8. }
  9. if ($callback) {
  10. $callback($node);
  1. *
  2. * @return string the XML of the document
  3. */
  4. public function asXml(): string
  5. {
  6. return self::utf8ForXML($this->_xml->asXML());
    Parameter #1 $string of static method Errbit\Utils\XmlBuilder::utf8ForXML() expects string, string|false given.
    Last edited by emgiezet
  7. }
  8. /**
  9. * Util to converts special chars to be valid with xml
  10. *
  1. $proto = "ssl";
  2. } else {
  3. $proto = 'tcp';
  4. }
  5. return sprintf('%s://%s', $proto, $config['host']);
    Parameter #3 ...$values of function sprintf expects bool|float|int|string|null, mixed given.
    Last edited by emgiezet
  6. }
  7. /**
  8. * @param \Throwable $exception
  9. * @param array $options
  1. if ($config['secure']) {
  2. $proto = "https";
  3. } else {
  4. $proto = 'http';
  5. }
  6. return sprintf('%s://%s%s', $proto, $config['host'], (isset($config['port']) ? ':' . $config['port'] : ''));
    Parameter #3 ...$values of function sprintf expects bool|float|int|string|null, mixed given.
    Last edited by Max Małecki
  7. }
  8. public function __construct(private readonly ClientInterface $client)
  9. {
  10. }
  1. public function synchronousWrite(\Throwable $exception, array $config): ResponseInterface
  2. {
  3. $uri = $this->buildConnectionScheme($config);
  4. $body = $this->buildNoticeFor($exception, $config);
  5. return $this->client->post(
    Call to an undefined method GuzzleHttp\ClientInterface::post().
    Last edited by emgiezet
  6. uri: $uri.self::NOTICES_PATH,
  7. options: [
  8. 'body' =>$body,
  9. 'connect_timout' => $config['connect_timeout'],
  10. 'headers'=>[
  1. }
  2. public function asyncWrite(\Throwable $exception, array $config): PromiseInterface
  3. {
  4. $uri = $this->buildConnectionScheme($config);
  5. $promise = $this->client->postAsync(
    Call to an undefined method GuzzleHttp\ClientInterface::postAsync().
    Last edited by emgiezet
  6. $uri.self::NOTICES_PATH,
  7. [
  8. 'body' =>$this->buildNoticeFor($exception, $config),
  9. 'connect_timout' => $config['connect_timeout'],
  10. 'headers'=>[
  1. $socket = fsockopen(
  2. $this->buildConnectionScheme($config),
  3. (int) $config['port'],
  4. $errno,
  5. $errstr,
  6. $config['connect_timeout']
    Parameter #5 $timeout of function fsockopen expects float|null, mixed given.
    Last edited by Filip Chmarzynski
  7. );
  8. if ($socket) {
  9. stream_set_timeout($socket, $config['write_timeout']);
  10. $payLoad = $this->buildPayload($exception, $config);
  1. $errstr,
  2. $config['connect_timeout']
  3. );
  4. if ($socket) {
  5. stream_set_timeout($socket, $config['write_timeout']);
    Parameter #2 $seconds of function stream_set_timeout expects int, mixed given.
    Last edited by Filip Chmarzynski
  6. $payLoad = $this->buildPayload($exception, $config);
  7. if (strlen((string) $payLoad) > 7000 && $config['async']) {
  8. $messageId = uniqid('', true);
  9. $chunks = str_split((string) $payLoad, 7000);
  10. foreach ($chunks as $idx => $chunk) {
  1. * Proxies usually do not make request to endpoints if client quits connection before
  2. * proxy even gets the chance to create connection to endpoint
  3. */
  4. if ($this->charactersToRead !== false) {
  5. while (!feof($socket)) {
  6. $character = fread($socket, $this->charactersToRead);
    Parameter #2 $length of function fread expects int<1, max>, int given.
    Last edited by Mikk Tendermann
  7. break;
  8. }
  9. }
  10. }
  1. } else {
  2. return sprintf(
  3. "%s\r\n\r\n%s",
  4. implode(
  5. "\r\n",
  6. [sprintf('POST %s HTTP/1.1', self::NOTICES_PATH), sprintf('Host: %s', $config['host']), sprintf('User-Agent: %s', $config['agent']), sprintf('Content-Type: %s', 'text/xml'), sprintf('Accept: %s', 'text/xml, application/xml'), sprintf('Content-Length: %d', strlen((string) $body)), sprintf('Connection: %s', 'close')]
    Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, mixed given.
    Last edited by emgiezet
  7. ),
  8. $body
  9. );
  10. }
  11. }

Your project should only use iterable types in foreach loops 3

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

in src/Errbit/Errbit.php, line 168
  1. if ($exception instanceof $skippedException) {
  2. return false;
  3. }
  4. }
  5. $userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
  6. foreach ($this->config['ignore_user_agent'] as $ua) {
    Argument of an invalid type mixed supplied for foreach, only iterables are supported.
    Last edited by Daniel Neis
  7. if ($userAgent !== '' && str_contains($userAgent, $ua)) {
  8. return false;
  9. }
  10. }
  1. return;
  2. }
  3. if (is_array($this->options['params_filters'])) {
  4. foreach ($this->options['params_filters'] as $pattern) {
  5. foreach ($this->options[$name] as $key => $value) {
    Argument of an invalid type mixed supplied for foreach, only iterables are supported.
    Last edited by emgiezet
  6. if (preg_match($pattern, (string)$key)) {
  7. $this->options[$name][$key] = '[FILTERED]';
  8. }
  9. }
  1. 'file' => '',
  2. 'method' => '',
  3. ]
  4. );
  5. } else {
  6. foreach ($trace as $frame) {
    Argument of an invalid type mixed supplied for foreach, only iterables are supported.
    Last edited by emgiezet
  7. $backtrace->tag(
  8. 'line',
  9. '',
  10. [
  11. 'number' => $frame['line'] ?? 0,

Your project should not use invalid parameter and return typehints 29

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

in src/Errbit/Errbit.php, line 59
  1. * This is made public for flexibility, though it is not expected you
  2. * should use it.
  3. *
  4. * @param array $config the configuration for the API
  5. */
  6. public function __construct(private array $config = [])
    Method Errbit\Errbit::__construct() has parameter $config with no value type specified in iterable type array.
    Last edited by emgiezet
  7. {
  8. }
  9. public function setWriter(WriterInterface $writer): void
  10. {
in src/Errbit/Errbit.php, line 110
  1. * @param array $config
  2. *
  3. * @return static the current instance of the client
  4. * @throws \Errbit\Exception\ConfigurationException
  5. */
  6. public function configure(array $config = []): static
    Method Errbit\Errbit::configure() has parameter $config with no value type specified in iterable type array.
    Last edited by emgiezet
  7. {
  8. $this->config = array_merge($this->config, $config);
  9. $this->checkConfig();
  10. return $this;
in src/Errbit/Errbit.php, line 124
  1. * @param array $handlers
  2. *
  3. * @return $this
  4. * @throws \Errbit\Exception\Exception
  5. */
  6. public function start(array $handlers = ['exception', 'error', 'fatal']): static
    Method Errbit\Errbit::start() has parameter $handlers with no value type specified in iterable type array.
    Last edited by emgiezet
  7. {
  8. $this->checkConfig();
  9. ErrorHandlers::register($this, $handlers);
  10. return $this;
in src/Errbit/Errbit.php, line 141
  1. * @param array $options
  2. *
  3. * @return static [Errbit] the current instance
  4. * @throws \Errbit\Exception\ConfigurationException
  5. */
  6. public function notify(\Throwable $exception, array $options = []): static
    Method Errbit\Errbit::notify() has parameter $options with no value type specified in iterable type array.
    Last edited by Max Małecki
  7. {
  8. $this->checkConfig();
  9. $config = array_merge($this->config, $options);
  10. if ($this->shouldNotify($exception, $config['skipped_exceptions'])) {
in src/Errbit/Errbit.php, line 160
  1. * @param \Throwable $exception
  2. * @param array $skippedExceptions
  3. *
  4. * @return bool
  5. */
  6. protected function shouldNotify(\Throwable $exception, array $skippedExceptions): bool
    Method Errbit\Errbit::shouldNotify() has parameter $skippedExceptions with no value type specified in iterable type array.
    Last edited by Max Małecki
  7. {
  8. foreach ($skippedExceptions as $skippedException) {
  9. if ($exception instanceof $skippedException) {
  10. return false;
  11. }
in src/Errbit/Errbit.php, line 183
  1. * @param \Throwable $exception
  2. * @param array $config
  3. *
  4. * @return void
  5. */
  6. protected function notifyObservers(\Throwable $exception, array $config): void
    Method Errbit\Errbit::notifyObservers() has parameter $config with no value type specified in iterable type array.
    Last edited by Max Małecki
  7. {
  8. foreach ($this->observers as $observer) {
  9. $observer($exception, $config);
  10. }
  11. }
  1. * Create a new notice for the given Exception with the given $options.
  2. *
  3. * @param mixed $exception - the exception that occurred
  4. * @param array $options - full configuration + options
  5. */
  6. public function __construct(
    Method Errbit\Exception\Notice::__construct() has parameter $options with no value type specified in iterable type array.
    Last edited by emgiezet
  7. private mixed $exception,
  8. array $options = []
  9. ) {
  10. $this->options = array_merge(
  11. [
  1. * @param mixed $exception - Exception
  2. * @param array $options - array of options
  3. *
  4. * @return Notice
  5. */
  6. public static function forException(
    Method Errbit\Exception\Notice::forException() has parameter $options with no value type specified in iterable type array.
    Last edited by emgiezet
  7. mixed $exception,
  8. array $options = []
  9. ): Notice {
  10. return new self($exception, $options);
  11. }
  1. *
  2. * @param array $frame - a single entry for the backtrace
  3. *
  4. * @return string - the name of the method/function
  5. */
  6. public static function formatMethod(array $frame): string
    Method Errbit\Exception\Notice::formatMethod() has parameter $frame with no value type specified in iterable type array.
    Last edited by emgiezet
  7. {
  8. if (!empty($frame['class']) && !empty($frame['type']) && !empty($frame['function'])) {
  9. return sprintf(
  10. '%s%s%s()',
  11. $frame['class'],
  1. * data into
  2. * @param array $array the stack frame entry
  3. *
  4. * @return void
  5. */
  6. public static function xmlVarsFor(XmlBuilder $builder, array $array): void
    Method Errbit\Exception\Notice::xmlVarsFor() has parameter $array with no value type specified in iterable type array.
    Last edited by emgiezet
  7. {
  8. foreach ($array as $key => $value) {
  9. if (is_object($value)) {
  1. * @param \Errbit\Errbit $errbit
  2. * @param array $handlers
  3. *
  4. * @return void
  5. */
  6. public static function register(Errbit $errbit, array $handlers = ['exception', 'error', 'fatal']): void
    Method Errbit\Handlers\ErrorHandlers::register() has parameter $handlers with no value type specified in iterable type array.
    Last edited by emgiezet
  7. {
  8. new self($errbit, $handlers);
  9. }
  10. /**
  1. /**
  2. * @param \Errbit\Errbit $errbit
  3. * @param array $handlers
  4. */
  5. public function __construct(private Errbit $errbit, array $handlers=[])
    Method Errbit\Handlers\ErrorHandlers::__construct() has parameter $handlers with no value type specified in iterable type array.
    Last edited by emgiezet
  6. {
  7. $this->install($handlers);
  8. $this->converter = Converter::createDefault();
  9. }
  1. /**
  2. * Installer
  3. *
  4. * @param array $handlers
  5. */
  6. private function install(array $handlers): void
    Method Errbit\Handlers\ErrorHandlers::install() has parameter $handlers with no value type specified in iterable type array.
    Last edited by emgiezet
  7. {
  8. if (in_array('error', $handlers, true)) {
  9. set_error_handler([$this, 'onError'], error_reporting());
  10. }
  1. * @param array $attributes an array of attributes for the tag, optional
  2. * @param Callable $callback a callback to receive an XmlBuilder for the new tag, optional
  3. *
  4. * @return XmlBuilder a builder for the inserted tag
  5. */
  6. public function tag($name, $value = '', $attributes = [], $callback = null, bool $getLastChild = false)
    Method Errbit\Utils\XmlBuilder::tag() has parameter $attributes with no value type specified in iterable type array.
    Last edited by emgiezet
  7. {
  8. $idx = is_countable($this->_xml->$name) ? count($this->_xml->$name) : 0;
  9. if (is_object($value)) {
  1. */
  2. public const NOTICES_PATH = '/notifier_api/v2/notices/';
  3. /**
  4. * @return string
  5. */
  6. protected function buildConnectionScheme(array $config): string
    Method Errbit\Writer\AbstractWriter::buildConnectionScheme() has parameter $config with no value type specified in iterable type array.
    Last edited by emgiezet
  7. {
  8. $proto = "";
  9. if ($config['async']) {
  10. $proto = "udp";
  11. } elseif ($config['secure']) {
  1. * @param \Throwable $exception
  2. * @param array $options
  3. *
  4. * @return string
  5. */
  6. protected function buildNoticeFor(\Throwable $exception, array $options): string
    Method Errbit\Writer\AbstractWriter::buildNoticeFor() has parameter $options with no value type specified in iterable type array.
    Last edited by Max Małecki
  7. {
  8. return Notice::forException($exception, $options)->asXml();
  9. }
  10. }
  1. /**
  2. * @param array $config
  3. *
  4. * @return string
  5. */
  6. protected function buildConnectionScheme(array $config): string
    Method Errbit\Writer\GuzzleWriter::buildConnectionScheme() has parameter $config with no value type specified in iterable type array.
    Last edited by emgiezet
  7. {
  8. if ($config['secure']) {
  9. $proto = "https";
  10. } else {
  11. $proto = 'http';
  1. * @param array $config
  2. *
  3. * @return ResponseInterface|PromiseInterface
  4. * @throws \GuzzleHttp\Exception\GuzzleException
  5. */
  6. public function write(\Throwable $exception, array $config): mixed
    Method Errbit\Writer\GuzzleWriter::write() has parameter $config with no value type specified in iterable type array.
    Last edited by Max Małecki
  7. {
  8. if($config['async']) {
  9. return $this->asyncWrite($exception, $config);
  10. }
  11. return $this->synchronousWrite($exception, $config);
  1. /**
  2. *
  3. * @throws \GuzzleHttp\Exception\GuzzleException
  4. */
  5. public function synchronousWrite(\Throwable $exception, array $config): ResponseInterface
    Method Errbit\Writer\GuzzleWriter::synchronousWrite() has parameter $config with no value type specified in iterable type array.
    Last edited by Max Małecki
  6. {
  7. $uri = $this->buildConnectionScheme($config);
  8. $body = $this->buildNoticeFor($exception, $config);
  9. return $this->client->post(
  1. ]
  2. ]
  3. );
  4. }
  5. public function asyncWrite(\Throwable $exception, array $config): PromiseInterface
    Method Errbit\Writer\GuzzleWriter::asyncWrite() has parameter $config with no value type specified in iterable type array.
    Last edited by Max Małecki
  6. {
  7. $uri = $this->buildConnectionScheme($config);
  8. $promise = $this->client->postAsync(
  9. $uri.self::NOTICES_PATH,
  10. [
  1. * @param array $config
  2. *
  3. * @return mixed
  4. * @throws \JsonException
  5. */
  6. public function write(\Throwable $exception, array $config): mixed
    Method Errbit\Writer\SocketWriter::write() has parameter $config with no value type specified in iterable type array.
    Last edited by Max Małecki
  7. {
  8. $socket = fsockopen(
  9. $this->buildConnectionScheme($config),
  10. (int) $config['port'],
  11. $errno,
  1. * @param \Throwable $exception
  2. * @param array $config
  3. *
  4. * @return string
  5. */
  6. protected function buildPayload(\Throwable $exception, array $config): string
    Method Errbit\Writer\SocketWriter::buildPayload() has parameter $config with no value type specified in iterable type array.
    Last edited by Max Małecki
  7. {
  8. return $this->addHttpHeadersIfNeeded(
  9. $this->buildNoticeFor($exception, $config),
  10. $config
  11. );
  1. * @param string $body
  2. * @param array $config
  3. *
  4. * @return string
  5. */
  6. protected function addHttpHeadersIfNeeded(string $body, array $config): string
    Method Errbit\Writer\SocketWriter::addHttpHeadersIfNeeded() has parameter $config with no value type specified in iterable type array.
    Last edited by emgiezet
  7. {
  8. if ($config['async'] ?? false) {
  9. return $body;
  10. } else {
  11. return sprintf(
  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.
    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. 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.
    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 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.
    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.
    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 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.
    Last edited by Max Małecki
  6. string $message,
  7. ?int $line = null,
  8. ?\Throwable $previous = null,
  9. string $file = '',
  10. array $backtrace = []
  1. * @param \Throwable $exception
  2. * @param array $config
  3. *
  4. * @return mixed
  5. */
  6. public function write(\Throwable $exception, array $config): mixed;
    Method Errbit\Writer\WriterInterface::write() has parameter $config with no value type specified in iterable type array.
    Last edited by Max Małecki
  7. }

Your project should not use invalid return types 7

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

  1. * @return string http or https protocol
  2. */
  3. private function guessProtocol(): string
  4. {
  5. if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
  6. return $_SERVER['HTTP_X_FORWARDED_PROTO'];
    Method Errbit\Exception\Notice::guessProtocol() should return string but returns mixed.
    Last edited by emgiezet
  7. } elseif (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) {
  8. return 'https';
  9. } else {
  10. return 'http';
  11. }
  1. * @return string servername
  2. */
  3. private function guessHost(): string
  4. {
  5. if (!empty($_SERVER['HTTP_HOST'])) {
  6. return $_SERVER['HTTP_HOST'];
    Method Errbit\Exception\Notice::guessHost() should return string but returns mixed.
    Last edited by emgiezet
  7. } elseif (!empty($_SERVER['SERVER_NAME'])) {
  8. return $_SERVER['SERVER_NAME'];
  9. } else {
  10. return '127.0.0.1';
  11. }
  1. private function guessHost(): string
  2. {
  3. if (!empty($_SERVER['HTTP_HOST'])) {
  4. return $_SERVER['HTTP_HOST'];
  5. } elseif (!empty($_SERVER['SERVER_NAME'])) {
  6. return $_SERVER['SERVER_NAME'];
    Method Errbit\Exception\Notice::guessHost() should return string but returns mixed.
    Last edited by emgiezet
  7. } else {
  8. return '127.0.0.1';
  9. }
  10. }
  1. foreach ($this->options['backtrace_filters'] as $pattern => $replacement) {
  2. $str = preg_replace($pattern, (string)$replacement, $str);
  3. }
  4. return $str;
    Method Errbit\Exception\Notice::filterTrace() should return string but returns string|null.
    Last edited by emgiezet
  5. }
  6. /**
  7. * Extract a human-readable method/function name from the given stack frame.
  8. *
  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.
    Last edited by Filip Chmarzynski
  7. }
  8. }
  1. public function synchronousWrite(\Throwable $exception, array $config): ResponseInterface
  2. {
  3. $uri = $this->buildConnectionScheme($config);
  4. $body = $this->buildNoticeFor($exception, $config);
  5. return $this->client->post(
    Method Errbit\Writer\GuzzleWriter::synchronousWrite() should return Psr\Http\Message\ResponseInterface but returns mixed.
    Last edited by emgiezet
  6. uri: $uri.self::NOTICES_PATH,
  7. options: [
  8. 'body' =>$body,
  9. 'connect_timout' => $config['connect_timeout'],
  10. 'headers'=>[
  1. 'Content-Type'=>'text/xml',
  2. 'Accept'=>'text/xml, application/xml'
  3. ]
  4. ]
  5. );
  6. return $promise;
    Method Errbit\Writer\GuzzleWriter::asyncWrite() should return GuzzleHttp\Promise\PromiseInterface but returns mixed.
    Last edited by emgiezet
  7. }
  8. }

Your project must not contain invalid instantiations 3

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

  1. $this->_xml->{$name}[$idx] = $value;
  2. foreach ($attributes as $attr => $v) {
  3. $this->_xml->{$name}[$idx][$attr] = $v;
  4. }
  5. $node = new self($this->_xml->$name);
    Parameter #1 $xml of class Errbit\Utils\XmlBuilder constructor expects SimpleXMLElement|null, mixed given.
    Last edited by emgiezet
  6. if ($getLastChild) {
  7. $array = $this->_xml->xpath($name."[last()]");
  8. $xml = array_shift($array);
  9. $node = new self($xml);
  10. }
  1. }
  2. $node = new self($this->_xml->$name);
  3. if ($getLastChild) {
  4. $array = $this->_xml->xpath($name."[last()]");
  5. $xml = array_shift($array);
  6. $node = new self($xml);
    Parameter #1 $xml of class Errbit\Utils\XmlBuilder constructor expects SimpleXMLElement|null, mixed given.
    Last edited by Max Małecki
  7. }
  8. if ($callback) {
  9. $callback($node);
  10. }
  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.
    Last edited by Max Małecki
  7. default => new Error($message, $line, $previous, $file, $backtrace),
  8. };
  9. }
  10. }

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] = $value;
    SimpleXMLElement does not accept string.
    Last edited by emgiezet
  7. return $this;
  8. }
  9. /**

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.
    Last edited by Max Małecki
  6. {
  7. return $this->backtrace;
  8. }
  9. }