mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 03:57:21 +00:00
Merge branch '2.x' into 3.x
* 2.x: Fix CS Fix CS
This commit is contained in:
@@ -157,7 +157,7 @@ final class IntlExtension extends AbstractExtension
|
||||
|
||||
public function getCountryName(?string $country, string $locale = null): string
|
||||
{
|
||||
if ($country === null) {
|
||||
if (null === $country) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ final class IntlExtension extends AbstractExtension
|
||||
|
||||
public function getCurrencyName(?string $currency, string $locale = null): string
|
||||
{
|
||||
if ($currency === null) {
|
||||
if (null === $currency) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ final class IntlExtension extends AbstractExtension
|
||||
|
||||
public function getCurrencySymbol(?string $currency, string $locale = null): string
|
||||
{
|
||||
if ($currency === null) {
|
||||
if (null === $currency) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ final class IntlExtension extends AbstractExtension
|
||||
|
||||
public function getLanguageName(?string $language, string $locale = null): string
|
||||
{
|
||||
if ($language === null) {
|
||||
if (null === $language) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ final class IntlExtension extends AbstractExtension
|
||||
|
||||
public function getLocaleName(?string $data, string $locale = null): string
|
||||
{
|
||||
if ($data === null) {
|
||||
if (null === $data) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ final class IntlExtension extends AbstractExtension
|
||||
|
||||
public function getTimezoneName(?string $timezone, string $locale = null): string
|
||||
{
|
||||
if ($timezone === null) {
|
||||
if (null === $timezone) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
@@ -1031,7 +1031,7 @@ function twig_spaceless($content)
|
||||
|
||||
function twig_convert_encoding($string, $to, $from)
|
||||
{
|
||||
if (!function_exists('iconv')) {
|
||||
if (!\function_exists('iconv')) {
|
||||
throw new RuntimeError('Unable to convert encoding: required function iconv() does not exist. You should install ext-iconv or symfony/polyfill-iconv.');
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,6 @@ class ProfilerExtension extends AbstractExtension
|
||||
|
||||
public function getNodeVisitors(): array
|
||||
{
|
||||
return [new ProfilerNodeVisitor(\get_class($this))];
|
||||
return [new ProfilerNodeVisitor(static::class)];
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -40,7 +40,7 @@ class Node implements \Countable, \IteratorAggregate
|
||||
{
|
||||
foreach ($nodes as $name => $node) {
|
||||
if (!$node instanceof self) {
|
||||
throw new \InvalidArgumentException(sprintf('Using "%s" for the value of node "%s" of "%s" is not supported. You must pass a \Twig\Node\Node instance.', \is_object($node) ? \get_class($node) : (null === $node ? 'null' : \gettype($node)), $name, \get_class($this)));
|
||||
throw new \InvalidArgumentException(sprintf('Using "%s" for the value of node "%s" of "%s" is not supported. You must pass a \Twig\Node\Node instance.', \is_object($node) ? \get_class($node) : (null === $node ? 'null' : \gettype($node)), $name, static::class));
|
||||
}
|
||||
}
|
||||
$this->nodes = $nodes;
|
||||
@@ -56,7 +56,7 @@ class Node implements \Countable, \IteratorAggregate
|
||||
$attributes[] = sprintf('%s: %s', $name, str_replace("\n", '', var_export($value, true)));
|
||||
}
|
||||
|
||||
$repr = [\get_class($this).'('.implode(', ', $attributes)];
|
||||
$repr = [static::class.'('.implode(', ', $attributes)];
|
||||
|
||||
if (\count($this->nodes)) {
|
||||
foreach ($this->nodes as $name => $node) {
|
||||
@@ -105,7 +105,7 @@ class Node implements \Countable, \IteratorAggregate
|
||||
public function getAttribute(string $name)
|
||||
{
|
||||
if (!\array_key_exists($name, $this->attributes)) {
|
||||
throw new \LogicException(sprintf('Attribute "%s" does not exist for Node "%s".', $name, \get_class($this)));
|
||||
throw new \LogicException(sprintf('Attribute "%s" does not exist for Node "%s".', $name, static::class));
|
||||
}
|
||||
|
||||
return $this->attributes[$name];
|
||||
@@ -129,7 +129,7 @@ class Node implements \Countable, \IteratorAggregate
|
||||
public function getNode(string $name): self
|
||||
{
|
||||
if (!isset($this->nodes[$name])) {
|
||||
throw new \LogicException(sprintf('Node "%s" does not exist for Node "%s".', $name, \get_class($this)));
|
||||
throw new \LogicException(sprintf('Node "%s" does not exist for Node "%s".', $name, static::class));
|
||||
}
|
||||
|
||||
return $this->nodes[$name];
|
||||
|
||||
+1
-3
@@ -74,8 +74,6 @@ abstract class Template
|
||||
* This method is for internal use only and should never be called
|
||||
* directly.
|
||||
*
|
||||
* @param array $context
|
||||
*
|
||||
* @return Template|TemplateWrapper|false The parent template or false if there is no parent
|
||||
*/
|
||||
public function getParent(array $context)
|
||||
@@ -313,7 +311,7 @@ abstract class Template
|
||||
}
|
||||
|
||||
if ($template === $this->getTemplateName()) {
|
||||
$class = \get_class($this);
|
||||
$class = static::class;
|
||||
if (false !== $pos = strrpos($class, '___', -1)) {
|
||||
$class = substr($class, 0, $pos);
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ abstract class IntegrationTestCase extends TestCase
|
||||
$templates = [];
|
||||
preg_match_all('/--TEMPLATE(?:\((.*?)\))?--(.*?)(?=\-\-TEMPLATE|$)/s', $test, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $match) {
|
||||
$templates[($match[1] ? $match[1] : 'index.twig')] = $match[2];
|
||||
$templates[($match[1] ?: 'index.twig')] = $match[2];
|
||||
}
|
||||
|
||||
return $templates;
|
||||
|
||||
@@ -168,7 +168,7 @@ class FilesystemTest extends TestCase
|
||||
public function testGenerateKey($expected, $input)
|
||||
{
|
||||
$cache = new FilesystemCache($input);
|
||||
$this->assertRegExp($expected, $cache->generateKey('_test_', \get_class($this)));
|
||||
$this->assertRegExp($expected, $cache->generateKey('_test_', static::class));
|
||||
}
|
||||
|
||||
public function provideDirectories()
|
||||
|
||||
+2
-2
@@ -206,14 +206,14 @@ EOHTML
|
||||
|
||||
public function testTwigLeakOutputInDebugMode()
|
||||
{
|
||||
$output = exec(sprintf('%s %s debug', \PHP_BINARY, escapeshellarg(__DIR__.'/Fixtures/errors/leak-output.php')));
|
||||
$output = exec(sprintf('%s %s debug', PHP_BINARY, escapeshellarg(__DIR__.'/Fixtures/errors/leak-output.php')));
|
||||
|
||||
$this->assertSame('Hello OOPS', $output);
|
||||
}
|
||||
|
||||
public function testDoesNotTwigLeakOutput()
|
||||
{
|
||||
$output = exec(sprintf('%s %s', \PHP_BINARY, escapeshellarg(__DIR__.'/Fixtures/errors/leak-output.php')));
|
||||
$output = exec(sprintf('%s %s', PHP_BINARY, escapeshellarg(__DIR__.'/Fixtures/errors/leak-output.php')));
|
||||
|
||||
$this->assertSame('', $output);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class BrokenExtension extends AbstractExtension
|
||||
|
||||
public function broken()
|
||||
{
|
||||
die('OOPS');
|
||||
exit('OOPS');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,6 @@ abstract class AbstractTest extends TestCase
|
||||
* @param bool $isTemplate
|
||||
* @param string $type
|
||||
* @param string $templateName
|
||||
* @param array $subProfiles
|
||||
*
|
||||
* @return Profile
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user