Booleans and null should be compared strictly 3

  • Minor
  • Bugrisk

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

  1. $headers['Feature-Policy'] = self::buildPolicy($config['featurePolicy']);
  2. }
  3. $code[] = Helpers::formatArgs('$response = $this->getService(?);', [$this->prefix('response')]);
  4. foreach ($headers as $key => $value) {
  5. if ($value != null) { // intentionally ==

    With booleans and null, only strict comparison (with !== operator) should be used to lower bug risks and to improve performances.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. $code[] = Helpers::formatArgs('$response->setHeader(?, ?);', [$key, $value]);
  7. }
  8. }
  9. if (!empty($config['sameSiteProtection'])) {
in src/Http/Context.php, line 56
  1. $match = true; // match, check if-modified-since
  2. } elseif ($ifNoneMatch !== null) {
  3. $etag = $this->response->getHeader('ETag');
  4. if ($etag == null || strpos(' ' . strtr($ifNoneMatch, ",\t", ' '), ' ' . $etag) === false) {

    With booleans and null, only strict comparison (with === operator) should be used to lower bug risks and to improve performances.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  5. return true;
  6. } else {
  7. $match = true; // match, check if-modified-since
  8. }
in src/Http/Context.php, line 67
  1. }
  2. $ifModifiedSince = $this->request->getHeader('If-Modified-Since');
  3. if ($ifModifiedSince !== null) {
  4. $lastModified = $this->response->getHeader('Last-Modified');
  5. if ($lastModified != null && strtotime($lastModified) <= strtotime($ifModifiedSince)) {

    With booleans and null, only strict comparison (with !== operator) should be used to lower bug risks and to improve performances.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. $match = true;
  7. } else {
  8. return true;
  9. }

The composer.json file should not raise warnings 2

  • Info
  • Bugrisk

More information: https://insight.symfony.com/what-we-analyse/composer.warning

License "GPL-2.0" is a deprecated SPDX license identifier, use "GPL-2.0-only" or "GPL-2.0-or-later" instead

Time to fix: about 1 hour
Open Issue Permalink
Collective

License "GPL-3.0" is a deprecated SPDX license identifier, use "GPL-3.0-only" or "GPL-3.0-or-later" instead

Time to fix: about 1 hour
Open Issue Permalink
Collective

Methods and properties visibility should always be explicitly defined 28

  • Info
  • Readability

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

in src/Http/IRequest.php, line 32
  1. OPTIONS = 'OPTIONS';
  2. /**
  3. * Returns URL object.
  4. */
  5. function getUrl(): UrlScript;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /********************* query, post, files & cookies ****************d*g**/
  7. /**
  8. * Returns variable provided to the script via URL query ($_GET).
in src/Http/IRequest.php, line 41
  1. /**
  2. * Returns variable provided to the script via URL query ($_GET).
  3. * If no key is passed, returns the entire array.
  4. * @return mixed
  5. */
  6. function getQuery(string $key = null);

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  7. /**
  8. * Returns variable provided to the script via POST method ($_POST).
  9. * If no key is passed, returns the entire array.
  10. * @return mixed
in src/Http/IRequest.php, line 48
  1. /**
  2. * Returns variable provided to the script via POST method ($_POST).
  3. * If no key is passed, returns the entire array.
  4. * @return mixed
  5. */
  6. function getPost(string $key = null);

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  7. /**
  8. * Returns uploaded file.
  9. * @return FileUpload|array|null
  10. */
in src/Http/IRequest.php, line 54
  1. /**
  2. * Returns uploaded file.
  3. * @return FileUpload|array|null
  4. */
  5. function getFile(string $key);

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Returns uploaded files.
  8. */
  9. function getFiles(): array;
in src/Http/IRequest.php, line 59
  1. function getFile(string $key);
  2. /**
  3. * Returns uploaded files.
  4. */
  5. function getFiles(): array;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Returns variable provided to the script via HTTP cookies.
  8. * @return mixed
  9. */
in src/Http/IRequest.php, line 65
  1. /**
  2. * Returns variable provided to the script via HTTP cookies.
  3. * @return mixed
  4. */
  5. function getCookie(string $key);

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Returns variables provided to the script via HTTP cookies.
  8. */
  9. function getCookies(): array;
in src/Http/IRequest.php, line 70
  1. function getCookie(string $key);
  2. /**
  3. * Returns variables provided to the script via HTTP cookies.
  4. */
  5. function getCookies(): array;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /********************* method & headers ****************d*g**/
  7. /**
  8. * Returns HTTP request method (GET, POST, HEAD, PUT, ...). The method is case-sensitive.
in src/Http/IRequest.php, line 77
  1. /********************* method & headers ****************d*g**/
  2. /**
  3. * Returns HTTP request method (GET, POST, HEAD, PUT, ...). The method is case-sensitive.
  4. */
  5. function getMethod(): string;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Checks HTTP request method.
  8. */
  9. function isMethod(string $method): bool;
in src/Http/IRequest.php, line 82
  1. function getMethod(): string;
  2. /**
  3. * Checks HTTP request method.
  4. */
  5. function isMethod(string $method): bool;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Return the value of the HTTP header. Pass the header name as the
  8. * plain, HTTP-specified header name (e.g. 'Accept-Encoding').
  9. */
in src/Http/IRequest.php, line 88
  1. /**
  2. * Return the value of the HTTP header. Pass the header name as the
  3. * plain, HTTP-specified header name (e.g. 'Accept-Encoding').
  4. */
  5. function getHeader(string $header): ?string;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Returns all HTTP headers.
  8. */
  9. function getHeaders(): array;
in src/Http/IRequest.php, line 93
  1. function getHeader(string $header): ?string;
  2. /**
  3. * Returns all HTTP headers.
  4. */
  5. function getHeaders(): array;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Is the request sent via secure channel (https)?
  8. */
  9. function isSecured(): bool;
in src/Http/IRequest.php, line 98
  1. function getHeaders(): array;
  2. /**
  3. * Is the request sent via secure channel (https)?
  4. */
  5. function isSecured(): bool;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Is AJAX request?
  8. */
  9. function isAjax(): bool;
in src/Http/IRequest.php, line 103
  1. function isSecured(): bool;
  2. /**
  3. * Is AJAX request?
  4. */
  5. function isAjax(): bool;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Returns the IP address of the remote client.
  8. */
  9. function getRemoteAddress(): ?string;
in src/Http/IRequest.php, line 108
  1. function isAjax(): bool;
  2. /**
  3. * Returns the IP address of the remote client.
  4. */
  5. function getRemoteAddress(): ?string;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Returns the host of the remote client.
  8. */
  9. function getRemoteHost(): ?string;
in src/Http/IRequest.php, line 113
  1. function getRemoteAddress(): ?string;
  2. /**
  3. * Returns the host of the remote client.
  4. */
  5. function getRemoteHost(): ?string;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Returns raw content of HTTP request body.
  8. */
  9. function getRawBody(): ?string;
in src/Http/IRequest.php, line 118
  1. function getRemoteHost(): ?string;
  2. /**
  3. * Returns raw content of HTTP request body.
  4. */
  5. function getRawBody(): ?string;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. }
  1. /**
  2. * Sets HTTP response code.
  3. * @return static
  4. */
  5. function setCode(int $code);

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Returns HTTP response code.
  8. */
  9. function getCode(): int;
  1. function setCode(int $code);
  2. /**
  3. * Returns HTTP response code.
  4. */
  5. function getCode(): int;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Sends a HTTP header and replaces a previous one.
  8. * @return static
  9. */
in src/Http/IResponse.php, line 102
  1. /**
  2. * Sends a HTTP header and replaces a previous one.
  3. * @return static
  4. */
  5. function setHeader(string $name, string $value);

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Adds HTTP header.
  8. * @return static
  9. */
in src/Http/IResponse.php, line 108
  1. /**
  2. * Adds HTTP header.
  3. * @return static
  4. */
  5. function addHeader(string $name, string $value);

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Sends a Content-type HTTP header.
  8. * @return static
  9. */
in src/Http/IResponse.php, line 114
  1. /**
  2. * Sends a Content-type HTTP header.
  3. * @return static
  4. */
  5. function setContentType(string $type, string $charset = null);

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Redirects to a new URL.
  8. */
  9. function redirect(string $url, int $code = self::S302_FOUND): void;
in src/Http/IResponse.php, line 119
  1. function setContentType(string $type, string $charset = null);
  2. /**
  3. * Redirects to a new URL.
  4. */
  5. function redirect(string $url, int $code = self::S302_FOUND): void;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Sets the time (like '20 minutes') before a page cached on a browser expires, null means "must-revalidate".
  8. * @return static
  9. */
in src/Http/IResponse.php, line 125
  1. /**
  2. * Sets the time (like '20 minutes') before a page cached on a browser expires, null means "must-revalidate".
  3. * @return static
  4. */
  5. function setExpiration(?string $expire);

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Checks if headers have been sent.
  8. */
  9. function isSent(): bool;
in src/Http/IResponse.php, line 130
  1. function setExpiration(?string $expire);
  2. /**
  3. * Checks if headers have been sent.
  4. */
  5. function isSent(): bool;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Returns value of an HTTP header.
  8. */
  9. function getHeader(string $header): ?string;
in src/Http/IResponse.php, line 135
  1. function isSent(): bool;
  2. /**
  3. * Returns value of an HTTP header.
  4. */
  5. function getHeader(string $header): ?string;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Returns a associative array of headers to sent.
  8. */
  9. function getHeaders(): array;
in src/Http/IResponse.php, line 140
  1. function getHeader(string $header): ?string;
  2. /**
  3. * Returns a associative array of headers to sent.
  4. */
  5. function getHeaders(): array;

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. /**
  7. * Sends a cookie.
  8. * @param string|int|\DateTimeInterface $expire time, value 0 means "until the browser is closed"
  9. * @return static
in src/Http/IResponse.php, line 147
  1. /**
  2. * Sends a cookie.
  3. * @param string|int|\DateTimeInterface $expire time, value 0 means "until the browser is closed"
  4. * @return static
  5. */
  6. function setCookie(string $name, string $value, $expire, string $path = null, string $domain = null, bool $secure = null, bool $httpOnly = null);

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  7. /**
  8. * Deletes a cookie.
  9. */
  10. function deleteCookie(string $name, string $path = null, string $domain = null, bool $secure = null);
in src/Http/IResponse.php, line 152
  1. function setCookie(string $name, string $value, $expire, string $path = null, string $domain = null, bool $secure = null, bool $httpOnly = null);
  2. /**
  3. * Deletes a cookie.
  4. */
  5. function deleteCookie(string $name, string $path = null, string $domain = null, bool $secure = null);

    This method has no explicit visibility which may lead to maintenability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Grudl
  6. }