Merge branch '4.3' into 4.4
* 4.3: [Intl] use strict comparisons Fix s-maxage=3 transient test
This commit is contained in:
commit
cf57007425
@ -660,7 +660,7 @@ class HttpCacheTest extends HttpCacheTestCase
|
|||||||
$this->assertTraceContains('miss');
|
$this->assertTraceContains('miss');
|
||||||
$this->assertTraceContains('store');
|
$this->assertTraceContains('store');
|
||||||
$this->assertEquals('Hello World', $this->response->getContent());
|
$this->assertEquals('Hello World', $this->response->getContent());
|
||||||
$this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control'));
|
$this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control'));
|
||||||
|
|
||||||
$this->request('GET', '/');
|
$this->request('GET', '/');
|
||||||
$this->assertHttpKernelIsNotCalled();
|
$this->assertHttpKernelIsNotCalled();
|
||||||
@ -668,7 +668,7 @@ class HttpCacheTest extends HttpCacheTestCase
|
|||||||
$this->assertTraceContains('fresh');
|
$this->assertTraceContains('fresh');
|
||||||
$this->assertTraceNotContains('store');
|
$this->assertTraceNotContains('store');
|
||||||
$this->assertEquals('Hello World', $this->response->getContent());
|
$this->assertEquals('Hello World', $this->response->getContent());
|
||||||
$this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control'));
|
$this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control'));
|
||||||
|
|
||||||
// expires the cache
|
// expires the cache
|
||||||
$values = $this->getMetaStorageValues();
|
$values = $this->getMetaStorageValues();
|
||||||
@ -688,7 +688,7 @@ class HttpCacheTest extends HttpCacheTestCase
|
|||||||
$this->assertTraceContains('invalid');
|
$this->assertTraceContains('invalid');
|
||||||
$this->assertTraceContains('store');
|
$this->assertTraceContains('store');
|
||||||
$this->assertEquals('Hello World', $this->response->getContent());
|
$this->assertEquals('Hello World', $this->response->getContent());
|
||||||
$this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control'));
|
$this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control'));
|
||||||
|
|
||||||
$this->setNextResponse();
|
$this->setNextResponse();
|
||||||
|
|
||||||
@ -698,7 +698,7 @@ class HttpCacheTest extends HttpCacheTestCase
|
|||||||
$this->assertTraceContains('fresh');
|
$this->assertTraceContains('fresh');
|
||||||
$this->assertTraceNotContains('store');
|
$this->assertTraceNotContains('store');
|
||||||
$this->assertEquals('Hello World', $this->response->getContent());
|
$this->assertEquals('Hello World', $this->response->getContent());
|
||||||
$this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control'));
|
$this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpiredWithStatus304()
|
public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpiredWithStatus304()
|
||||||
@ -711,7 +711,7 @@ class HttpCacheTest extends HttpCacheTestCase
|
|||||||
$this->assertTraceContains('miss');
|
$this->assertTraceContains('miss');
|
||||||
$this->assertTraceContains('store');
|
$this->assertTraceContains('store');
|
||||||
$this->assertEquals('Hello World', $this->response->getContent());
|
$this->assertEquals('Hello World', $this->response->getContent());
|
||||||
$this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control'));
|
$this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control'));
|
||||||
|
|
||||||
$this->request('GET', '/');
|
$this->request('GET', '/');
|
||||||
$this->assertHttpKernelIsNotCalled();
|
$this->assertHttpKernelIsNotCalled();
|
||||||
@ -739,7 +739,7 @@ class HttpCacheTest extends HttpCacheTestCase
|
|||||||
$this->assertTraceContains('store');
|
$this->assertTraceContains('store');
|
||||||
$this->assertTraceNotContains('miss');
|
$this->assertTraceNotContains('miss');
|
||||||
$this->assertEquals('Hello World', $this->response->getContent());
|
$this->assertEquals('Hello World', $this->response->getContent());
|
||||||
$this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control'));
|
$this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control'));
|
||||||
|
|
||||||
$this->request('GET', '/');
|
$this->request('GET', '/');
|
||||||
$this->assertHttpKernelIsNotCalled();
|
$this->assertHttpKernelIsNotCalled();
|
||||||
@ -747,7 +747,7 @@ class HttpCacheTest extends HttpCacheTestCase
|
|||||||
$this->assertTraceContains('fresh');
|
$this->assertTraceContains('fresh');
|
||||||
$this->assertTraceNotContains('store');
|
$this->assertTraceNotContains('store');
|
||||||
$this->assertEquals('Hello World', $this->response->getContent());
|
$this->assertEquals('Hello World', $this->response->getContent());
|
||||||
$this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control'));
|
$this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDoesNotAssignDefaultTtlWhenResponseHasMustRevalidateDirective()
|
public function testDoesNotAssignDefaultTtlWhenResponseHasMustRevalidateDirective()
|
||||||
|
@ -26,7 +26,7 @@ class Hour1200Transformer extends HourTransformer
|
|||||||
public function format(\DateTime $dateTime, int $length): string
|
public function format(\DateTime $dateTime, int $length): string
|
||||||
{
|
{
|
||||||
$hourOfDay = $dateTime->format('g');
|
$hourOfDay = $dateTime->format('g');
|
||||||
$hourOfDay = '12' == $hourOfDay ? '0' : $hourOfDay;
|
$hourOfDay = '12' === $hourOfDay ? '0' : $hourOfDay;
|
||||||
|
|
||||||
return $this->padLeft($hourOfDay, $length);
|
return $this->padLeft($hourOfDay, $length);
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,11 @@ class Hour2400Transformer extends HourTransformer
|
|||||||
*/
|
*/
|
||||||
public function normalizeHour(int $hour, string $marker = null): int
|
public function normalizeHour(int $hour, string $marker = null): int
|
||||||
{
|
{
|
||||||
if ('AM' == $marker) {
|
$marker = (string) $marker;
|
||||||
|
|
||||||
|
if ('AM' === $marker) {
|
||||||
$hour = 0;
|
$hour = 0;
|
||||||
} elseif ('PM' == $marker) {
|
} elseif ('PM' === $marker) {
|
||||||
$hour = 12;
|
$hour = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class Hour2401Transformer extends HourTransformer
|
|||||||
public function format(\DateTime $dateTime, int $length): string
|
public function format(\DateTime $dateTime, int $length): string
|
||||||
{
|
{
|
||||||
$hourOfDay = $dateTime->format('G');
|
$hourOfDay = $dateTime->format('G');
|
||||||
$hourOfDay = ('0' == $hourOfDay) ? '24' : $hourOfDay;
|
$hourOfDay = '0' === $hourOfDay ? '24' : $hourOfDay;
|
||||||
|
|
||||||
return $this->padLeft($hourOfDay, $length);
|
return $this->padLeft($hourOfDay, $length);
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ class Hour2401Transformer extends HourTransformer
|
|||||||
*/
|
*/
|
||||||
public function normalizeHour(int $hour, string $marker = null): int
|
public function normalizeHour(int $hour, string $marker = null): int
|
||||||
{
|
{
|
||||||
if ((null === $marker && 24 === $hour) || 'AM' == $marker) {
|
if ((null === $marker && 24 == $hour) || 'AM' == $marker) {
|
||||||
$hour = 0;
|
$hour = 0;
|
||||||
} elseif ('PM' == $marker) {
|
} elseif ('PM' == $marker) {
|
||||||
$hour = 12;
|
$hour = 12;
|
||||||
|
@ -102,7 +102,7 @@ class TimezoneTransformer extends Transformer
|
|||||||
if (preg_match('/GMT(?P<signal>[+-])(?P<hours>\d{2}):?(?P<minutes>\d{2})/', $formattedTimeZone, $matches)) {
|
if (preg_match('/GMT(?P<signal>[+-])(?P<hours>\d{2}):?(?P<minutes>\d{2})/', $formattedTimeZone, $matches)) {
|
||||||
$hours = (int) $matches['hours'];
|
$hours = (int) $matches['hours'];
|
||||||
$minutes = (int) $matches['minutes'];
|
$minutes = (int) $matches['minutes'];
|
||||||
$signal = '-' == $matches['signal'] ? '+' : '-';
|
$signal = '-' === $matches['signal'] ? '+' : '-';
|
||||||
|
|
||||||
if (0 < $minutes) {
|
if (0 < $minutes) {
|
||||||
throw new NotImplementedException(sprintf('It is not possible to use a GMT time zone with minutes offset different than zero (0). GMT time zone tried: %s.', $formattedTimeZone));
|
throw new NotImplementedException(sprintf('It is not possible to use a GMT time zone with minutes offset different than zero (0). GMT time zone tried: %s.', $formattedTimeZone));
|
||||||
|
@ -272,19 +272,19 @@ class NumberFormatter
|
|||||||
throw new MethodArgumentNotImplementedException(__METHOD__, 'pattern');
|
throw new MethodArgumentNotImplementedException(__METHOD__, 'pattern');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->style = $style;
|
$this->style = null !== $style ? (int) $style : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static constructor.
|
* Static constructor.
|
||||||
*
|
*
|
||||||
* @param string $locale The locale code. The only supported locale is "en" (or null using the default locale, i.e. "en")
|
* @param string|null $locale The locale code. The only 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.
|
* @param int $style Style of the formatting, one of the format style constants.
|
||||||
* The only currently supported styles are NumberFormatter::DECIMAL
|
* The only currently supported styles are NumberFormatter::DECIMAL
|
||||||
* and NumberFormatter::CURRENCY.
|
* and NumberFormatter::CURRENCY.
|
||||||
* @param string $pattern Not supported. A pattern string in case $style is NumberFormat::PATTERN_DECIMAL or
|
* @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
|
* NumberFormat::PATTERN_RULEBASED. It must conform to the syntax
|
||||||
* described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation
|
* described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation
|
||||||
*
|
*
|
||||||
* @return self
|
* @return self
|
||||||
*
|
*
|
||||||
@ -314,7 +314,7 @@ class NumberFormatter
|
|||||||
*/
|
*/
|
||||||
public function formatCurrency($value, $currency)
|
public function formatCurrency($value, $currency)
|
||||||
{
|
{
|
||||||
if (self::DECIMAL == $this->style) {
|
if (self::DECIMAL === $this->style) {
|
||||||
return $this->format($value);
|
return $this->format($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,19 +353,21 @@ class NumberFormatter
|
|||||||
*/
|
*/
|
||||||
public function format($value, $type = self::TYPE_DEFAULT)
|
public function format($value, $type = self::TYPE_DEFAULT)
|
||||||
{
|
{
|
||||||
|
$type = (int) $type;
|
||||||
|
|
||||||
// The original NumberFormatter does not support this format type
|
// The original NumberFormatter does not support this format type
|
||||||
if (self::TYPE_CURRENCY == $type) {
|
if (self::TYPE_CURRENCY === $type) {
|
||||||
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
|
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::CURRENCY == $this->style) {
|
if (self::CURRENCY === $this->style) {
|
||||||
throw new NotImplementedException(sprintf('%s() method does not support the formatting of currencies (instance with CURRENCY style). %s', __METHOD__, NotImplementedException::INTL_INSTALL_MESSAGE));
|
throw new NotImplementedException(sprintf('%s() method does not support the formatting of currencies (instance with CURRENCY style). %s', __METHOD__, NotImplementedException::INTL_INSTALL_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only the default type is supported.
|
// Only the default type is supported.
|
||||||
if (self::TYPE_DEFAULT != $type) {
|
if (self::TYPE_DEFAULT !== $type) {
|
||||||
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'type', $type, 'Only TYPE_DEFAULT is supported');
|
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'type', $type, 'Only TYPE_DEFAULT is supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +387,7 @@ class NumberFormatter
|
|||||||
*
|
*
|
||||||
* @param int $attr An attribute specifier, one of the numeric attribute constants
|
* @param int $attr An attribute specifier, one of the numeric attribute constants
|
||||||
*
|
*
|
||||||
* @return bool|int The attribute value on success or false on error
|
* @return int|false The attribute value on success or false on error
|
||||||
*
|
*
|
||||||
* @see https://php.net/numberformatter.getattribute
|
* @see https://php.net/numberformatter.getattribute
|
||||||
*/
|
*/
|
||||||
@ -438,7 +440,7 @@ class NumberFormatter
|
|||||||
/**
|
/**
|
||||||
* Not supported. Returns the formatter's pattern.
|
* Not supported. Returns the formatter's pattern.
|
||||||
*
|
*
|
||||||
* @return bool|string The pattern string used by the formatter or false on error
|
* @return string|false The pattern string used by the formatter or false on error
|
||||||
*
|
*
|
||||||
* @see https://php.net/numberformatter.getpattern
|
* @see https://php.net/numberformatter.getpattern
|
||||||
*
|
*
|
||||||
@ -454,7 +456,7 @@ class NumberFormatter
|
|||||||
*
|
*
|
||||||
* @param int $attr A symbol specifier, one of the format symbol constants
|
* @param int $attr A symbol specifier, one of the format symbol constants
|
||||||
*
|
*
|
||||||
* @return bool|string The symbol value or false on error
|
* @return string|false The symbol value or false on error
|
||||||
*
|
*
|
||||||
* @see https://php.net/numberformatter.getsymbol
|
* @see https://php.net/numberformatter.getsymbol
|
||||||
*/
|
*/
|
||||||
@ -468,7 +470,7 @@ class NumberFormatter
|
|||||||
*
|
*
|
||||||
* @param int $attr An attribute specifier, one of the text attribute constants
|
* @param int $attr An attribute specifier, one of the text attribute constants
|
||||||
*
|
*
|
||||||
* @return bool|string The attribute value or false on error
|
* @return string|false The attribute value or false on error
|
||||||
*
|
*
|
||||||
* @see https://php.net/numberformatter.gettextattribute
|
* @see https://php.net/numberformatter.gettextattribute
|
||||||
*/
|
*/
|
||||||
@ -484,7 +486,7 @@ class NumberFormatter
|
|||||||
* @param string $currency Parameter to receive the currency name (reference)
|
* @param string $currency Parameter to receive the currency name (reference)
|
||||||
* @param int $position Offset to begin the parsing on return this value will hold the offset at which the parsing ended
|
* @param int $position Offset to begin the parsing on return this value will hold the offset at which the parsing ended
|
||||||
*
|
*
|
||||||
* @return bool|string The parsed numeric value or false on error
|
* @return float|false The parsed numeric value or false on error
|
||||||
*
|
*
|
||||||
* @see https://php.net/numberformatter.parsecurrency
|
* @see https://php.net/numberformatter.parsecurrency
|
||||||
*
|
*
|
||||||
@ -508,7 +510,9 @@ class NumberFormatter
|
|||||||
*/
|
*/
|
||||||
public function parse($value, $type = self::TYPE_DOUBLE, &$position = 0)
|
public function parse($value, $type = self::TYPE_DOUBLE, &$position = 0)
|
||||||
{
|
{
|
||||||
if (self::TYPE_DEFAULT == $type || self::TYPE_CURRENCY == $type) {
|
$type = (int) $type;
|
||||||
|
|
||||||
|
if (self::TYPE_DEFAULT === $type || self::TYPE_CURRENCY === $type) {
|
||||||
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
|
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -565,6 +569,8 @@ class NumberFormatter
|
|||||||
*/
|
*/
|
||||||
public function setAttribute($attr, $value)
|
public function setAttribute($attr, $value)
|
||||||
{
|
{
|
||||||
|
$attr = (int) $attr;
|
||||||
|
|
||||||
if (!\in_array($attr, self::$supportedAttributes)) {
|
if (!\in_array($attr, self::$supportedAttributes)) {
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
'The available attributes are: %s',
|
'The available attributes are: %s',
|
||||||
@ -574,7 +580,7 @@ class NumberFormatter
|
|||||||
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'attr', $value, $message);
|
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'attr', $value, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::$supportedAttributes['ROUNDING_MODE'] == $attr && $this->isInvalidRoundingMode($value)) {
|
if (self::$supportedAttributes['ROUNDING_MODE'] === $attr && $this->isInvalidRoundingMode($value)) {
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
'The supported values for ROUNDING_MODE are: %s',
|
'The supported values for ROUNDING_MODE are: %s',
|
||||||
implode(', ', array_keys(self::$roundingModes))
|
implode(', ', array_keys(self::$roundingModes))
|
||||||
@ -583,11 +589,11 @@ class NumberFormatter
|
|||||||
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'attr', $value, $message);
|
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'attr', $value, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::$supportedAttributes['GROUPING_USED'] == $attr) {
|
if (self::$supportedAttributes['GROUPING_USED'] === $attr) {
|
||||||
$value = $this->normalizeGroupingUsedValue($value);
|
$value = $this->normalizeGroupingUsedValue($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::$supportedAttributes['FRACTION_DIGITS'] == $attr) {
|
if (self::$supportedAttributes['FRACTION_DIGITS'] === $attr) {
|
||||||
$value = $this->normalizeFractionDigitsValue($value);
|
$value = $this->normalizeFractionDigitsValue($value);
|
||||||
if ($value < 0) {
|
if ($value < 0) {
|
||||||
// ignore negative values but do not raise an error
|
// ignore negative values but do not raise an error
|
||||||
@ -751,7 +757,7 @@ class NumberFormatter
|
|||||||
*/
|
*/
|
||||||
private function getUninitializedPrecision($value, int $precision): int
|
private function getUninitializedPrecision($value, int $precision): int
|
||||||
{
|
{
|
||||||
if (self::CURRENCY == $this->style) {
|
if (self::CURRENCY === $this->style) {
|
||||||
return $precision;
|
return $precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -782,11 +788,13 @@ class NumberFormatter
|
|||||||
*/
|
*/
|
||||||
private function convertValueDataType($value, int $type)
|
private function convertValueDataType($value, int $type)
|
||||||
{
|
{
|
||||||
if (self::TYPE_DOUBLE == $type) {
|
$type = (int) $type;
|
||||||
|
|
||||||
|
if (self::TYPE_DOUBLE === $type) {
|
||||||
$value = (float) $value;
|
$value = (float) $value;
|
||||||
} elseif (self::TYPE_INT32 == $type) {
|
} elseif (self::TYPE_INT32 === $type) {
|
||||||
$value = $this->getInt32Value($value);
|
$value = $this->getInt32Value($value);
|
||||||
} elseif (self::TYPE_INT64 == $type) {
|
} elseif (self::TYPE_INT64 === $type) {
|
||||||
$value = $this->getInt64Value($value);
|
$value = $this->getInt64Value($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user