Skip to content

Commit

Permalink
Merge branch '3.4' into 4.3
Browse files Browse the repository at this point in the history
* 3.4:
  consistently throw NotSupportException
  [HttpKernel] Clarify error handler restoring process again
  [Intl] fix nullable phpdocs and useless method visibility of internal class
  Resilience against file_get_contents() race conditions.
  • Loading branch information
nicolas-grekas committed Aug 8, 2019
2 parents fda49e6 + d936a70 commit c0f416e
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
5 changes: 2 additions & 3 deletions src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,8 @@ protected function fetch(Request $request, $catch = false)
* All backend requests (cache passes, fetches, cache validations)
* run through this method.
*
* @param Request $request A Request instance
* @param bool $catch Whether to catch exceptions or not
* @param Response $entry A Response instance (the stale entry if present, null otherwise)
* @param bool $catch Whether to catch exceptions or not
* @param Response|null $entry A Response instance (the stale entry if present, null otherwise)
*
* @return Response A Response instance
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpKernel/HttpCache/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ private function load($key)
{
$path = $this->getPath($key);

return file_exists($path) ? file_get_contents($path) : null;
return file_exists($path) && false !== ($contents = file_get_contents($path)) ? $contents : null;
}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/Symfony/Component/HttpKernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,9 @@ protected function initializeContainer()
return;
}

if ($this->debug) {
if ($collectDeprecations = $this->debug && !\defined('PHPUNIT_COMPOSER_INSTALL')) {
$collectedLogs = [];
$previousHandler = \defined('PHPUNIT_COMPOSER_INSTALL');
$previousHandler = $previousHandler ?: set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
$previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
return $previousHandler ? $previousHandler($type, $message, $file, $line) : false;
}
Expand Down Expand Up @@ -549,7 +548,7 @@ protected function initializeContainer()
$container = $this->buildContainer();
$container->compile();
} finally {
if ($this->debug && true !== $previousHandler) {
if ($collectDeprecations) {
restore_error_handler();

file_put_contents($cacheDir.'/'.$class.'Deprecations.log', serialize(array_values($collectedLogs)));
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Intl/Collator/Collator.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Collator
const SORT_STRING = 1;

/**
* @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
* @param string|null $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
*
* @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed
*/
Expand All @@ -84,7 +84,7 @@ public function __construct(?string $locale)
/**
* Static constructor.
*
* @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
* @param string|null $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
*
* @return self
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class IntlDateFormatter
private $timeZoneId;

/**
* @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
* @param string|null $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
* @param int|null $datetype Type of date formatting, one of the format type constants
* @param int|null $timetype Type of time formatting, one of the format type constants
* @param \IntlTimeZone|\DateTimeZone|string|null $timezone Timezone identifier
Expand Down Expand Up @@ -152,7 +152,7 @@ public function __construct(?string $locale, ?int $datetype, ?int $timetype, $ti
/**
* Static constructor.
*
* @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
* @param string|null $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
* @param int|null $datetype Type of date formatting, one of the format type constants
* @param int|null $timetype Type of time formatting, one of the format type constants
* @param \IntlTimeZone|\DateTimeZone|string|null $timezone Timezone identifier
Expand Down
14 changes: 7 additions & 7 deletions src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,13 @@ class NumberFormatter
];

/**
* @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
* @param int $style Style of the formatting, one of the format style constants.
* The only supported styles are NumberFormatter::DECIMAL
* and NumberFormatter::CURRENCY.
* @param string $pattern Not supported. A pattern string in case $style is NumberFormat::PATTERN_DECIMAL or
* NumberFormat::PATTERN_RULEBASED. It must conform to the syntax
* described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation
* @param string|null $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
* @param int $style Style of the formatting, one of the format style constants.
* The only supported styles are NumberFormatter::DECIMAL
* and NumberFormatter::CURRENCY.
* @param string $pattern Not supported. A pattern string in case $style is NumberFormat::PATTERN_DECIMAL or
* NumberFormat::PATTERN_RULEBASED. It must conform to the syntax
* described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation
*
* @see http://www.php.net/manual/en/numberformatter.create.php
* @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Lock/Store/CombinedStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function save(Key $key)

public function waitAndSave(Key $key)
{
throw new NotSupportedException(sprintf('The store "%s" does not supports blocking locks.', \get_class($this)));
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this)));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/Lock/Store/MemcachedStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Exception\NotSupportedException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface;

Expand Down Expand Up @@ -70,7 +71,7 @@ public function save(Key $key)

public function waitAndSave(Key $key)
{
throw new InvalidArgumentException(sprintf('The store "%s" does not supports blocking locks.', \get_class($this)));
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this)));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/Lock/Store/RedisStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\Cache\Traits\RedisProxy;
use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Exception\NotSupportedException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface;

Expand Down Expand Up @@ -76,7 +77,7 @@ public function save(Key $key)
*/
public function waitAndSave(Key $key)
{
throw new InvalidArgumentException(sprintf('The store "%s" does not supports blocking locks.', \get_class($this)));
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this)));
}

/**
Expand Down

0 comments on commit c0f416e

Please sign in to comment.