Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HttpFoundation] some cleanups #33112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/HttpFoundation/AcceptHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function first()
/**
* Sorts items by descending quality.
*/
private function sort()
private function sort(): void
{
if (!$this->sorted) {
uasort($this->items, function (AcceptHeaderItem $a, AcceptHeaderItem $b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public function prepare(Request $request)
return $this;
}

private function hasValidIfRangeHeader(?string $header)
private function hasValidIfRangeHeader(?string $header): bool
{
if ($this->getEtag() === $header) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
*/
class AccessDeniedException extends FileException
{
/**
* @param string $path The path to the accessed file
*/
public function __construct(string $path)
{
parent::__construct(sprintf('The file %s could not be accessed', $path));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
*/
class FileNotFoundException extends FileException
{
/**
* @param string $path The path to the file that was not found
*/
public function __construct(string $path)
{
parent::__construct(sprintf('The file "%s" does not exist', $path));
Expand Down
5 changes: 4 additions & 1 deletion 5 src/Symfony/Component/HttpFoundation/File/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public function move($directory, $name = null)
return $target;
}

/**
* @return self
*/
protected function getTargetFile($directory, $name = null)
{
if (!is_dir($directory)) {
Expand All @@ -119,7 +122,7 @@ protected function getTargetFile($directory, $name = null)
*
* @param string $name The new file name
*
* @return string containing
* @return string
*/
protected function getName($name)
{
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/HttpFoundation/FileBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FileBag extends ParameterBag
private static $fileKeys = ['error', 'name', 'size', 'tmp_name', 'type'];

/**
* @param array $parameters An array of HTTP files
* @param array|UploadedFile[] $parameters An array of HTTP files
*/
public function __construct(array $parameters = [])
{
Expand Down
12 changes: 2 additions & 10 deletions 12 src/Symfony/Component/HttpFoundation/HeaderBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ class HeaderBag implements \IteratorAggregate, \Countable
protected $headers = [];
protected $cacheControl = [];

/**
* @param array $headers An array of HTTP headers
*/
public function __construct(array $headers = [])
{
foreach ($headers as $key => $values) {
Expand Down Expand Up @@ -85,8 +82,6 @@ public function keys()

/**
* Replaces the current HTTP headers by a new set.
*
* @param array $headers An array of HTTP headers
*/
public function replace(array $headers = [])
{
Expand All @@ -96,8 +91,6 @@ public function replace(array $headers = [])

/**
* Adds new headers the current HTTP headers set.
*
* @param array $headers An array of HTTP headers
*/
public function add(array $headers)
{
Expand Down Expand Up @@ -204,10 +197,9 @@ public function remove($key)
/**
* Returns the HTTP header value converted to a date.
*
* @param string $key The parameter key
* @param \DateTime $default The default value
* @param string $key The parameter key
*
* @return \DateTime|null The parsed DateTime or the default value if the header does not exist
* @return \DateTimeInterface|null The parsed DateTime or the default value if the header does not exist
*
* @throws \RuntimeException When the HTTP header is not parseable
*/
Expand Down
7 changes: 0 additions & 7 deletions 7 src/Symfony/Component/HttpFoundation/ParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ class ParameterBag implements \IteratorAggregate, \Countable
*/
protected $parameters;

/**
* @param array $parameters An array of parameters
*/
public function __construct(array $parameters = [])
{
$this->parameters = $parameters;
Expand Down Expand Up @@ -53,8 +50,6 @@ public function keys()

/**
* Replaces the current parameters by a new set.
*
* @param array $parameters An array of parameters
*/
public function replace(array $parameters = [])
{
Expand All @@ -63,8 +58,6 @@ public function replace(array $parameters = [])

/**
* Adds parameters.
*
* @param array $parameters An array of parameters
*/
public function add(array $parameters = [])
{
Expand Down
12 changes: 6 additions & 6 deletions 12 src/Symfony/Component/HttpFoundation/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ public static function getTrustedHosts()
*/
public static function normalizeQueryString($qs)
{
if ('' == $qs) {
if ('' === ($qs ?? '')) {
return '';
}

Expand Down Expand Up @@ -702,7 +702,7 @@ public function get($key, $default = null)
/**
* Gets the Session.
*
* @return SessionInterface|null The session
* @return SessionInterface The session
*/
public function getSession()
{
Expand Down Expand Up @@ -1591,7 +1591,7 @@ public function getPreferredFormat(?string $default = 'html'): ?string
/**
* Returns the preferred language.
*
* @param array $locales An array of ordered available locales
* @param string[] $locales An array of ordered available locales
*
* @return string|null The preferred locale
*/
Expand Down Expand Up @@ -1920,7 +1920,7 @@ protected static function initializeFormats()
];
}

private function setPhpDefaultLocale(string $locale)
private function setPhpDefaultLocale(string $locale): void
{
// if either the class Locale doesn't exist, or an exception is thrown when
// setting the default locale, the intl module is not installed, and
Expand Down Expand Up @@ -1982,7 +1982,7 @@ public function isFromTrustedProxy()
return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR'), self::$trustedProxies);
}

private function getTrustedValues(int $type, string $ip = null)
private function getTrustedValues(int $type, string $ip = null): array
{
$clientValues = [];
$forwardedValues = [];
Expand Down Expand Up @@ -2033,7 +2033,7 @@ private function getTrustedValues(int $type, string $ip = null)
throw new ConflictingHeadersException(sprintf('The request has both a trusted "%s" header and a trusted "%s" header, conflicting with each other. You should either configure your proxy to remove one of them, or configure your project to distrust the offending one.', self::$trustedHeaders[self::HEADER_FORWARDED], self::$trustedHeaders[$type]));
}

private function normalizeAndFilterClientIps(array $clientIps, string $ip)
private function normalizeAndFilterClientIps(array $clientIps, string $ip): array
{
if (!$clientIps) {
return [];
Expand Down
3 changes: 0 additions & 3 deletions 3 src/Symfony/Component/HttpFoundation/RequestMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ class RequestMatcher implements RequestMatcherInterface
private $schemes = [];

/**
* @param string|null $path
* @param string|null $host
* @param string|string[]|null $methods
* @param string|string[]|null $ips
* @param array $attributes
* @param string|string[]|null $schemes
*/
public function __construct(string $path = null, string $host = null, $methods = null, $ips = null, array $attributes = [], $schemes = null, int $port = null)
Expand Down
4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/HttpFoundation/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ public function isEmpty(): bool
*
* @final
*/
public static function closeOutputBuffers(int $targetLevel, bool $flush)
public static function closeOutputBuffers(int $targetLevel, bool $flush): void
{
$status = ob_get_status(true);
$level = \count($status);
Expand All @@ -1230,7 +1230,7 @@ public static function closeOutputBuffers(int $targetLevel, bool $flush)
*
* @final
*/
protected function ensureIEOverSSLCompatibility(Request $request)
protected function ensureIEOverSSLCompatibility(Request $request): void
{
if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && 1 == preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) && true === $request->isSecure()) {
if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) {
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ protected function computeCacheControlValue()
return $header;
}

private function initDate()
private function initDate(): void
{
$now = \DateTime::createFromFormat('U', time());
$now->setTimezone(new \DateTimeZone('UTC'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,10 @@ public function set($name, $value);
/**
* Returns attributes.
*
* @return array Attributes
* @return array
*/
public function all();

/**
* Sets attributes.
*
* @param array $attributes Attributes
*/
public function replace(array $attributes);

/**
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/HttpFoundation/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function getIterator()
/**
* Returns the number of attributes.
*
* @return int The number of attributes
* @return int
*/
public function count()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getName()
/**
* {@inheritdoc}
*/
public function initialize(array &$array)
public function initialize(array &$array): void
{
++$this->usageIndex;
$this->data[$this->bag->getStorageKey()] = &$array;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface SessionInterface
/**
* Starts the session storage.
*
* @return bool True if session started
* @return bool
*
* @throws \RuntimeException if session fails to start
*/
Expand All @@ -32,7 +32,7 @@ public function start();
/**
* Returns the session ID.
*
* @return string The session ID
* @return string
*/
public function getId();

Expand All @@ -46,7 +46,7 @@ public function setId($id);
/**
* Returns the session name.
*
* @return mixed The session name
* @return string
*/
public function getName();

Expand All @@ -68,7 +68,7 @@ public function setName($name);
* to expire with browser session. Time is in seconds, and is
* not a Unix timestamp.
*
* @return bool True if session invalidated, false if error
* @return bool
*/
public function invalidate($lifetime = null);

Expand All @@ -82,7 +82,7 @@ public function invalidate($lifetime = null);
* to expire with browser session. Time is in seconds, and is
* not a Unix timestamp.
*
* @return bool True if session migrated, false if error
* @return bool
*/
public function migrate($destroy = false, $lifetime = null);

Expand All @@ -100,7 +100,7 @@ public function save();
*
* @param string $name The attribute name
*
* @return bool true if the attribute is defined, false otherwise
* @return bool
*/
public function has($name);

Expand All @@ -125,14 +125,12 @@ public function set($name, $value);
/**
* Returns attributes.
*
* @return array Attributes
* @return array
*/
public function all();

/**
* Sets attributes.
*
* @param array $attributes Attributes
*/
public function replace(array $attributes);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class MemcachedSessionHandler extends AbstractSessionHandler
* * prefix: The prefix to use for the memcached keys in order to avoid collision
* * expiretime: The time to live in seconds.
*
* @param \Memcached $memcached A \Memcached instance
*
* @throws \InvalidArgumentException When unsupported options are passed
*/
public function __construct(\Memcached $memcached, array $options = [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public function close()
/**
* Lazy-connects to the database.
*/
private function connect(string $dsn)
private function connect(string $dsn): void
{
$this->pdo = new \PDO($dsn, $this->username, $this->password, $this->connectionOptions);
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
Expand Down Expand Up @@ -534,7 +534,7 @@ private function buildDsnFromUrl(string $dsnOrUrl): string
* due to https://percona.com/blog/2013/12/12/one-more-innodb-gap-lock-to-avoid/ .
* So we change it to READ COMMITTED.
*/
private function beginTransaction()
private function beginTransaction(): void
{
if (!$this->inTransaction) {
if ('sqlite' === $this->driver) {
Expand All @@ -552,7 +552,7 @@ private function beginTransaction()
/**
* Helper method to commit a transaction.
*/
private function commit()
private function commit(): void
{
if ($this->inTransaction) {
try {
Expand All @@ -574,7 +574,7 @@ private function commit()
/**
* Helper method to rollback a transaction.
*/
private function rollback()
private function rollback(): void
{
// We only need to rollback if we are in a transaction. Otherwise the resulting
// error would hide the real problem why rollback was called. We might not be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function setName($name)
$this->name = $name;
}

private function stampCreated(int $lifetime = null)
private function stampCreated(int $lifetime = null): void
{
$timeStamp = time();
$this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp;
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.