mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-19 13:57:00 +00:00
Merge branch '3.x' into 4.x
* 3.x: Fix exception when timezone is false Fix param name in docblock (minor) Minor fixes
This commit is contained in:
@@ -372,7 +372,7 @@ final class IntlExtension extends AbstractExtension
|
||||
$date = CoreExtension::dateConverter($env, $date, $timezone);
|
||||
|
||||
$formatterTimezone = $timezone;
|
||||
if (null === $formatterTimezone) {
|
||||
if (null === $formatterTimezone || false === $formatterTimezone) {
|
||||
$formatterTimezone = $date->getTimezone();
|
||||
} elseif (\is_string($formatterTimezone)) {
|
||||
$formatterTimezone = new \DateTimeZone($timezone);
|
||||
|
||||
@@ -45,6 +45,20 @@ class IntlExtensionTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testFormatterWithoutProtoSkipTimezoneConverter()
|
||||
{
|
||||
$ext = new IntlExtension();
|
||||
$env = new Environment(new ArrayLoader());
|
||||
// EET is always +2 without changes for daylight saving time
|
||||
// so it has a fixed difference to UTC
|
||||
$env->getExtension(CoreExtension::class)->setTimezone('EET');
|
||||
|
||||
$this->assertStringStartsWith(
|
||||
'Feb 20, 2020, 1:37:00',
|
||||
$ext->formatDateTime($env, new \DateTime('2020-02-20T13:37:00+00:00', new \DateTimeZone('UTC')), 'medium', 'medium', '', false)
|
||||
);
|
||||
}
|
||||
|
||||
public function testFormatterProto()
|
||||
{
|
||||
$dateFormatterProto = new \IntlDateFormatter('fr', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, new \DateTimeZone('Europe/Paris'));
|
||||
|
||||
+4
-4
@@ -329,8 +329,8 @@ class Environment
|
||||
* This method is for internal use only and should never be called
|
||||
* directly.
|
||||
*
|
||||
* @param string $name The template name
|
||||
* @param int $index The index if it is an embedded template
|
||||
* @param string $name The template name
|
||||
* @param int|null $index The index if it is an embedded template
|
||||
*
|
||||
* @throws LoaderError When the template cannot be found
|
||||
* @throws RuntimeError When a previously generated cache is corrupted
|
||||
@@ -387,8 +387,8 @@ class Environment
|
||||
*
|
||||
* This method should not be used as a generic way to load templates.
|
||||
*
|
||||
* @param string $template The template source
|
||||
* @param string $name An optional name of the template to be used in error messages
|
||||
* @param string $template The template source
|
||||
* @param string|null $name An optional name of the template to be used in error messages
|
||||
*
|
||||
* @throws LoaderError When the template cannot be found
|
||||
* @throws SyntaxError When an error occurred during compilation
|
||||
|
||||
@@ -89,8 +89,8 @@ final class CoreExtension extends AbstractExtension
|
||||
/**
|
||||
* Sets the default format to be used by the date filter.
|
||||
*
|
||||
* @param string $format The default date format string
|
||||
* @param string $dateIntervalFormat The default date interval format string
|
||||
* @param string|null $format The default date format string
|
||||
* @param string|null $dateIntervalFormat The default date interval format string
|
||||
*/
|
||||
public function setDateFormat($format = null, $dateIntervalFormat = null)
|
||||
{
|
||||
@@ -575,10 +575,10 @@ final class CoreExtension extends AbstractExtension
|
||||
* be used. Supplying any of the parameters will override the defaults set in the
|
||||
* environment object.
|
||||
*
|
||||
* @param mixed $number A float/int/string of the number to format
|
||||
* @param int $decimal the number of decimal points to display
|
||||
* @param string $decimalPoint the character(s) to use for the decimal point
|
||||
* @param string $thousandSep the character(s) to use for the thousands separator
|
||||
* @param mixed $number A float/int/string of the number to format
|
||||
* @param int|null $decimal the number of decimal points to display
|
||||
* @param string|null $decimalPoint the character(s) to use for the decimal point
|
||||
* @param string|null $thousandSep the character(s) to use for the thousands separator
|
||||
*
|
||||
* @return string The formatted number
|
||||
*
|
||||
@@ -781,7 +781,7 @@ final class CoreExtension extends AbstractExtension
|
||||
*
|
||||
* @param string|null $value A string
|
||||
* @param string $delimiter The delimiter
|
||||
* @param int $limit The limit
|
||||
* @param int|null $limit The limit
|
||||
*
|
||||
* @return array The split string as an array
|
||||
*
|
||||
@@ -1208,7 +1208,7 @@ final class CoreExtension extends AbstractExtension
|
||||
* Strips HTML and PHP tags from a string.
|
||||
*
|
||||
* @param string|null $string
|
||||
* @param string[]|string|null $string
|
||||
* @param string[]|string|null $allowable_tags
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
@@ -1698,8 +1698,8 @@ final class CoreExtension extends AbstractExtension
|
||||
* </pre>
|
||||
*
|
||||
* @param array|\Traversable $array An array
|
||||
* @param mixed $name The column name
|
||||
* @param mixed $index The column to use as the index/keys for the returned array
|
||||
* @param int|string $name The column name
|
||||
* @param int|string|null $index The column to use as the index/keys for the returned array
|
||||
*
|
||||
* @return array The array of values
|
||||
*
|
||||
|
||||
@@ -29,8 +29,8 @@ final class StringLoaderExtension extends AbstractExtension
|
||||
*
|
||||
* {{ include(template_from_string("Hello {{ name }}")) }}
|
||||
*
|
||||
* @param string $template A template as a string or object implementing __toString()
|
||||
* @param string $name An optional name of the template to be used in error messages
|
||||
* @param string $template A template as a string or object implementing __toString()
|
||||
* @param string|null $name An optional name of the template to be used in error messages
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Twig\Profiler\Node;
|
||||
|
||||
use Twig\Attribute\YieldReady;
|
||||
use Twig\Compiler;
|
||||
use Twig\Node\Node;
|
||||
|
||||
@@ -19,6 +20,7 @@ use Twig\Node\Node;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
#[YieldReady]
|
||||
class EnterProfileNode extends Node
|
||||
{
|
||||
public function __construct(string $extensionName, string $type, string $name, string $varName)
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Twig\Profiler\Node;
|
||||
|
||||
use Twig\Attribute\YieldReady;
|
||||
use Twig\Compiler;
|
||||
use Twig\Node\Node;
|
||||
|
||||
@@ -19,6 +20,7 @@ use Twig\Node\Node;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
#[YieldReady]
|
||||
class LeaveProfileNode extends Node
|
||||
{
|
||||
public function __construct(string $varName)
|
||||
|
||||
Reference in New Issue
Block a user