Merge branch '1.x' into 2.x

* 1.x:
  prefixed some classes with a backslash
This commit is contained in:
Fabien Potencier
2019-02-15 05:55:16 +01:00
49 changed files with 97 additions and 97 deletions
+3 -3
View File
@@ -52,11 +52,11 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
if (false === @mkdir($dir, 0777, true)) {
clearstatcache(true, $dir);
if (!is_dir($dir)) {
throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir));
throw new \RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir));
}
}
} elseif (!is_writable($dir)) {
throw new RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir));
throw new \RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir));
}
$tmpFile = tempnam($dir, basename($key));
@@ -75,7 +75,7 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
return;
}
throw new RuntimeException(sprintf('Failed to write cache file "%s".', $key));
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $key));
}
public function getTimestamp($key)
+2 -2
View File
@@ -218,13 +218,13 @@ class Twig_Compiler
*
* @return $this
*
* @throws LogicException When trying to outdent too much so the indentation would become negative
* @throws \LogicException When trying to outdent too much so the indentation would become negative
*/
public function outdent($step = 1)
{
// can't outdent by more steps than the current indentation level
if ($this->indentation < $step) {
throw new LogicException('Unable to call outdent() as the indentation would become negative.');
throw new \LogicException('Unable to call outdent() as the indentation would become negative.');
}
$this->indentation -= $step;
+4 -4
View File
@@ -31,7 +31,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Twig_Error extends Exception
class Twig_Error extends \Exception
{
private $lineno;
private $name;
@@ -54,9 +54,9 @@ class Twig_Error extends Exception
* @param string $message The error message
* @param int $lineno The template line where the error occurred
* @param Twig_Source|string|null $source The source context where the error occurred
* @param Exception $previous The previous exception
* @param \Exception $previous The previous exception
*/
public function __construct($message, $lineno = -1, $source = null, Exception $previous = null)
public function __construct($message, $lineno = -1, $source = null, \Exception $previous = null)
{
parent::__construct('', 0, $previous);
@@ -231,7 +231,7 @@ class Twig_Error extends Exception
return;
}
$r = new ReflectionObject($template);
$r = new \ReflectionObject($template);
$file = $r->getFileName();
$exceptions = [$e = $this];
+1 -1
View File
@@ -11,7 +11,7 @@
*/
/**
* Exception thrown when a syntax error occurs during lexing or parsing of a template.
* \Exception thrown when a syntax error occurs during lexing or parsing of a template.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
+1 -1
View File
@@ -175,7 +175,7 @@ class Twig_ExpressionParser
} elseif (isset($this->unaryOperators[$token->getValue()])) {
$class = $this->unaryOperators[$token->getValue()]['class'];
$ref = new ReflectionClass($class);
$ref = new \ReflectionClass($class);
$negClass = 'Twig_Node_Expression_Unary_Neg';
$posClass = 'Twig_Node_Expression_Unary_Pos';
if (!(in_array($ref->getName(), [$negClass, $posClass]) || $ref->isSubclassOf($negClass) || $ref->isSubclassOf($posClass))) {
+1 -1
View File
@@ -61,7 +61,7 @@ class Twig_Node_For extends Twig_Node
if (!$this->getAttribute('ifexpr')) {
$compiler
->write("if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof Countable)) {\n")
->write("if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof \Countable)) {\n")
->indent()
->write("\$length = count(\$context['_seq']);\n")
->write("\$context['loop']['revindex0'] = \$length - 1;\n")
+1 -1
View File
@@ -446,7 +446,7 @@ class Twig_Node_Module extends Twig_Node
->raw(");\n")
;
} else {
throw new LogicException('Trait templates can only be constant nodes.');
throw new \LogicException('Trait templates can only be constant nodes.');
}
}
}
+1 -1
View File
@@ -38,7 +38,7 @@ final class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
public function __construct($optimizers = -1)
{
if (!is_int($optimizers) || $optimizers > (self::OPTIMIZE_FOR | self::OPTIMIZE_RAW_FILTER | self::OPTIMIZE_VAR_ACCESS)) {
throw new InvalidArgumentException(sprintf('Optimizer mode "%s" is not valid.', $optimizers));
throw new \InvalidArgumentException(sprintf('Optimizer mode "%s" is not valid.', $optimizers));
}
$this->optimizers = $optimizers;
+2 -2
View File
@@ -14,7 +14,7 @@
*
* @final since version 2.4.0
*/
class Twig_Profiler_Profile implements IteratorAggregate, Serializable
class Twig_Profiler_Profile implements \IteratorAggregate, Serializable
{
const ROOT = 'ROOT';
const BLOCK = 'block';
@@ -157,7 +157,7 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
public function getIterator()
{
return new ArrayIterator($this->profiles);
return new \ArrayIterator($this->profiles);
}
public function serialize()
@@ -18,7 +18,7 @@ class Twig_Sandbox_SecurityNotAllowedFilterError extends Twig_Sandbox_SecurityEr
{
private $filterName;
public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null)
public function __construct($message, $functionName, $lineno = -1, $filename = null, \Exception $previous = null)
{
parent::__construct($message, $lineno, $filename, $previous);
$this->filterName = $functionName;
@@ -18,7 +18,7 @@ class Twig_Sandbox_SecurityNotAllowedFunctionError extends Twig_Sandbox_Security
{
private $functionName;
public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null)
public function __construct($message, $functionName, $lineno = -1, $filename = null, \Exception $previous = null)
{
parent::__construct($message, $lineno, $filename, $previous);
$this->functionName = $functionName;
@@ -19,7 +19,7 @@ class Twig_Sandbox_SecurityNotAllowedMethodError extends Twig_Sandbox_SecurityEr
private $className;
private $methodName;
public function __construct($message, $className, $methodName, $lineno = -1, $filename = null, Exception $previous = null)
public function __construct($message, $className, $methodName, $lineno = -1, $filename = null, \Exception $previous = null)
{
parent::__construct($message, $lineno, $filename, $previous);
$this->className = $className;
@@ -19,7 +19,7 @@ class Twig_Sandbox_SecurityNotAllowedPropertyError extends Twig_Sandbox_Security
private $className;
private $propertyName;
public function __construct($message, $className, $propertyName, $lineno = -1, $filename = null, Exception $previous = null)
public function __construct($message, $className, $propertyName, $lineno = -1, $filename = null, \Exception $previous = null)
{
parent::__construct($message, $lineno, $filename, $previous);
$this->className = $className;
@@ -18,7 +18,7 @@ class Twig_Sandbox_SecurityNotAllowedTagError extends Twig_Sandbox_SecurityError
{
private $tagName;
public function __construct($message, $tagName, $lineno = -1, $filename = null, Exception $previous = null)
public function __construct($message, $tagName, $lineno = -1, $filename = null, \Exception $previous = null)
{
parent::__construct($message, $lineno, $filename, $previous);
$this->tagName = $tagName;
+2 -2
View File
@@ -154,7 +154,7 @@ final class Twig_Token
$name = 'INTERPOLATION_END_TYPE';
break;
default:
throw new LogicException(sprintf('Token of type "%s" does not exist.', $type));
throw new \LogicException(sprintf('Token of type "%s" does not exist.', $type));
}
return $short ? $name : 'Twig_Token::'.$name;
@@ -197,7 +197,7 @@ final class Twig_Token
case self::INTERPOLATION_END_TYPE:
return 'end of string interpolation';
default:
throw new LogicException(sprintf('Token of type "%s" does not exist.', $type));
throw new \LogicException(sprintf('Token of type "%s" does not exist.', $type));
}
}
}
+5 -5
View File
@@ -31,9 +31,9 @@ final class Twig_Util_DeprecationCollector
*/
public function collectDir($dir, $ext = '.twig')
{
$iterator = new RegexIterator(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY
$iterator = new \RegexIterator(
new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY
), '{'.preg_quote($ext).'$}'
);
@@ -43,11 +43,11 @@ final class Twig_Util_DeprecationCollector
/**
* Returns deprecations for passed templates.
*
* @param Traversable $iterator An iterator of templates (where keys are template names and values the contents of the template)
* @param \Traversable $iterator An iterator of templates (where keys are template names and values the contents of the template)
*
* @return array An array of deprecations
*/
public function collect(Traversable $iterator)
public function collect(\Traversable $iterator)
{
$deprecations = [];
set_error_handler(function ($type, $msg) use (&$deprecations) {
+1 -1
View File
@@ -31,7 +31,7 @@ class CustomExtensionTest extends \PHPUnit\Framework\TestCase
public function provideInvalidExtensions()
{
return [
[new InvalidOperatorExtension(new stdClass()), '"InvalidOperatorExtension::getOperators()" must return an array with operators, got "stdClass".'],
[new InvalidOperatorExtension(new \stdClass()), '"InvalidOperatorExtension::getOperators()" must return an array with operators, got "stdClass".'],
[new InvalidOperatorExtension([1, 2, 3]), '"InvalidOperatorExtension::getOperators()" must return an array of 2 elements, got 3.'],
];
}
+2 -2
View File
@@ -14,7 +14,7 @@ class Twig_Tests_ErrorTest extends \PHPUnit\Framework\TestCase
public function testErrorWithObjectFilename()
{
$error = new Twig_Error('foo');
$error->setSourceContext(new Twig_Source('', new SplFileInfo(__FILE__)));
$error->setSourceContext(new Twig_Source('', new \SplFileInfo(__FILE__)));
$this->assertContains('test'.DIRECTORY_SEPARATOR.'Twig'.DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR.'ErrorTest.php', $error->getMessage());
}
@@ -207,6 +207,6 @@ class Twig_Tests_ErrorTest_Foo
{
public function bar()
{
throw new Exception('Runtime error...');
throw new \Exception('Runtime error...');
}
}
+10 -10
View File
@@ -31,7 +31,7 @@ class Twig_Tests_Extension_CoreTest extends \PHPUnit\Framework\TestCase
['apple', 'orange', 'citrus'],
],
[// Traversable
new ArrayObject(['apple', 'orange', 'citrus']),
new \ArrayObject(['apple', 'orange', 'citrus']),
['apple', 'orange', 'citrus'],
],
[// unicode string
@@ -72,7 +72,7 @@ class Twig_Tests_Extension_CoreTest extends \PHPUnit\Framework\TestCase
$this->assertSame('', twig_random(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), ''));
$this->assertSame('', twig_random(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), ['charset' => null]), ''));
$instance = new stdClass();
$instance = new \stdClass();
$this->assertSame($instance, twig_random(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), $instance));
}
@@ -198,7 +198,7 @@ class Twig_Tests_Extension_CoreTest extends \PHPUnit\Framework\TestCase
[$keys, new CoreTestIteratorAggregate($array, $keys)],
[$keys, new CoreTestIteratorAggregateAggregate($array, $keys)],
[[], null],
[['a'], new SimpleXMLElement('<xml><a></a></xml>')],
[['a'], new \SimpleXMLElement('<xml><a></a></xml>')],
];
}
@@ -226,7 +226,7 @@ class Twig_Tests_Extension_CoreTest extends \PHPUnit\Framework\TestCase
[false, 4, new CoreTestIterator($array, $keys, true)],
[false, 4, new CoreTestIteratorAggregateAggregate($array, $keys, true)],
[false, 1, 1],
[true, 'b', new SimpleXMLElement('<xml><a>b</a></xml>')],
[true, 'b', new \SimpleXMLElement('<xml><a>b</a></xml>')],
];
}
@@ -255,8 +255,8 @@ class Twig_Tests_Extension_CoreTest extends \PHPUnit\Framework\TestCase
[$i, new CoreTestIterator($i, $keys, true), 0, count($keys) + 10, true],
[[], new CoreTestIterator($i, $keys, true), count($keys) + 10],
['de', 'abcdef', 3, 2],
[[], new SimpleXMLElement('<items><item>1</item><item>2</item></items>'), 3],
[[], new ArrayIterator([1, 2]), 3],
[[], new \SimpleXMLElement('<items><item>1</item><item>2</item></items>'), 3],
[[], new \ArrayIterator([1, 2]), 3],
];
}
}
@@ -266,7 +266,7 @@ function foo_escaper_for_test(Twig_Environment $env, $string, $charset)
return $string.$charset;
}
final class CoreTestIteratorAggregate implements IteratorAggregate
final class CoreTestIteratorAggregate implements \IteratorAggregate
{
private $iterator;
@@ -281,7 +281,7 @@ final class CoreTestIteratorAggregate implements IteratorAggregate
}
}
final class CoreTestIteratorAggregateAggregate implements IteratorAggregate
final class CoreTestIteratorAggregateAggregate implements \IteratorAggregate
{
private $iterator;
@@ -324,7 +324,7 @@ final class CoreTestIterator implements Iterator
return $this->array[$this->key()];
}
throw new LogicException('Code should only use the keys, not the values provided by iterator.');
throw new \LogicException('Code should only use the keys, not the values provided by iterator.');
}
public function key()
@@ -336,7 +336,7 @@ final class CoreTestIterator implements Iterator
{
++$this->position;
if ($this->position === $this->maxPosition) {
throw new LogicException(sprintf('Code should not iterate beyond %d.', $this->maxPosition));
throw new \LogicException(sprintf('Code should not iterate beyond %d.', $this->maxPosition));
}
}
+1 -1
View File
@@ -28,5 +28,5 @@ class Twig_Tests_FactoryRuntimeLoaderTest extends \PHPUnit\Framework\TestCase
function getRuntime()
{
return new stdClass();
return new \stdClass();
}
+5 -5
View File
@@ -42,13 +42,13 @@
date_default_timezone_set('Europe/Paris');
return [
'date1' => mktime(13, 45, 0, 10, 4, 2010),
'date2' => new DateTime('2010-10-04 13:45'),
'date2' => new \DateTime('2010-10-04 13:45'),
'date3' => '2010-10-04 13:45',
'date4' => 1286199900, // DateTime::createFromFormat('Y-m-d H:i', '2010-10-04 13:45', new DateTimeZone('UTC'))->getTimestamp() -- A unixtimestamp is always GMT
'date5' => -189291360, // DateTime::createFromFormat('Y-m-d H:i', '1964-01-02 03:04', new DateTimeZone('UTC'))->getTimestamp(),
'date6' => new DateTime('2010-10-04 13:45', new DateTimeZone('America/New_York')),
'date4' => 1286199900, // \DateTime::createFromFormat('Y-m-d H:i', '2010-10-04 13:45', new \DateTimeZone('UTC'))->getTimestamp() -- A unixtimestamp is always GMT
'date5' => -189291360, // \DateTime::createFromFormat('Y-m-d H:i', '1964-01-02 03:04', new \DateTimeZone('UTC'))->getTimestamp(),
'date6' => new \DateTime('2010-10-04 13:45', new \DateTimeZone('America/New_York')),
'date7' => '2010-01-28T15:00:00+04:00',
'timezone1' => new DateTimeZone('America/New_York'),
'timezone1' => new \DateTimeZone('America/New_York'),
]
--EXPECT--
October 4, 2010 13:45
@@ -7,7 +7,7 @@
date_default_timezone_set('UTC');
$twig->getExtension('Twig_Extension_Core')->setDateFormat('Y-m-d', '%d days %h hours');
return [
'date2' => new DateInterval('P2D'),
'date2' => new \DateInterval('P2D'),
]
--EXPECT--
2 days 0 hours
@@ -16,9 +16,9 @@
--DATA--
date_default_timezone_set('Europe/Paris');
return [
'date1' => new DateTimeImmutable('2010-10-04 13:45'),
'date2' => new DateTimeImmutable('2010-10-04 13:45', new DateTimeZone('America/New_York')),
'timezone1' => new DateTimeZone('America/New_York'),
'date1' => new \DateTimeImmutable('2010-10-04 13:45'),
'date2' => new \DateTimeImmutable('2010-10-04 13:45', new \DateTimeZone('America/New_York')),
'timezone1' => new \DateTimeZone('America/New_York'),
]
--EXPECT--
October 4, 2010 13:45
@@ -7,9 +7,9 @@
--DATA--
date_default_timezone_set('UTC');
return [
'date1' => new DateInterval('P2D'),
// This should have no effect on DateInterval formatting
'timezone1' => new DateTimeZone('America/New_York'),
'date1' => new \DateInterval('P2D'),
// This should have no effect on \DateInterval formatting
'timezone1' => new \DateTimeZone('America/New_York'),
]
--EXPECT--
2 days
@@ -7,7 +7,7 @@
date_default_timezone_set('UTC');
return [
'date1' => '2010-10-04 13:45',
'date2' => new DateTime('2010-10-04 13:45'),
'date2' => new \DateTime('2010-10-04 13:45'),
]
--EXPECT--
2010-10-03 13:45:00
+1 -1
View File
@@ -8,7 +8,7 @@
{{ 'Ä€é'|first }}
{{ ''|first }}
--DATA--
return ['arr' => new ArrayObject([1, 2, 3, 4])]
return ['arr' => new \ArrayObject([1, 2, 3, 4])]
--EXPECT--
1
1
+1 -1
View File
@@ -18,7 +18,7 @@
{{ {"a": "w", "b": "x", "c": "y", "d": "z"}|join(',') }}
{{ {"a": "w", "b": "x", "c": "y", "d": "z"}|join(',','-') }}
--DATA--
return ['foo' => new TwigTestFoo(), 'bar' => new ArrayObject([3, 4])]
return ['foo' => new TwigTestFoo(), 'bar' => new \ArrayObject([3, 4])]
--EXPECT--
foo, bar
1, 2
+1 -1
View File
@@ -8,7 +8,7 @@
{{ 'Ä€é'|last }}
{{ ''|last }}
--DATA--
return ['arr' => new ArrayObject([1, 2, 3, 4])]
return ['arr' => new \ArrayObject([1, 2, 3, 4])]
--EXPECT--
4
4
+2 -2
View File
@@ -12,8 +12,8 @@ return [
'items' => ['foo' => 'bar'],
'numerics' => [1, 2, 3],
'traversable' => [
'a' => new ArrayObject([0 => 1, 1 => 2, 2 => 3]),
'b' => new ArrayObject(['a' => 'b'])
'a' => new \ArrayObject([0 => 1, 1 => 2, 2 => 3]),
'b' => new \ArrayObject(['a' => 'b'])
]
]
--EXPECT--
@@ -5,7 +5,7 @@
{{ 'I like single replace operation only %that%'|replace({'%that%' : '%that%1'}) }}
{{ 'I like %this% and %that%.'|replace(traversable) }}
--DATA--
return ['traversable' => new ArrayObject(['%this%' => 'foo', '%that%' => 'bar'])]
return ['traversable' => new \ArrayObject(['%this%' => 'foo', '%that%' => 'bar'])]
--EXPECT--
I liké foo and bar.
I like single replace operation only %that%1
@@ -3,6 +3,6 @@ Exception for invalid argument type in replace call
--TEMPLATE--
{{ 'test %foo%'|replace(stdClass) }}
--DATA--
return ['stdClass' => new stdClass()]
return ['stdClass' => new \stdClass()]
--EXCEPTION--
Twig_Error_Runtime: The "replace" filter expects an array or "Traversable" as replace values, got "stdClass" in "index.twig" at line 2.
@@ -8,7 +8,7 @@
{{ {'a': 'c', 'b': 'a'}|reverse(preserveKeys=true)|join(glue=',') }}
{{ {'a': 'c', 'b': 'a'}|reverse(preserve_keys=true)|join(glue=',') }}
--DATA--
return ['arr' => new ArrayObject([1, 2, 3, 4])]
return ['arr' => new \ArrayObject([1, 2, 3, 4])]
--EXPECT--
4321
tnemenèvé4321
+1 -1
View File
@@ -26,7 +26,7 @@
{{ arr[2:]|join('') }}
{{ xml|slice(1)|join('')}}
--DATA--
return ['start' => 1, 'length' => 2, 'arr' => new ArrayObject([1, 2, 3, 4]), 'xml' => new SimpleXMLElement('<items><item>1</item><item>2</item></items>')]
return ['start' => 1, 'length' => 2, 'arr' => new \ArrayObject([1, 2, 3, 4]), 'xml' => new \SimpleXMLElement('<items><item>1</item><item>2</item></items>')]
--EXPECT--
23
23
+1 -1
View File
@@ -5,7 +5,7 @@
{{ array2|sort|join }}
{{ traversable|sort|join }}
--DATA--
return ['array1' => [4, 1], 'array2' => ['foo', 'bar'], 'traversable' => new ArrayObject([0 => 3, 1 => 2, 2 => 1])]
return ['array1' => [4, 1], 'array2' => ['foo', 'bar'], 'traversable' => new \ArrayObject([0 => 3, 1 => 2, 2 => 1])]
--EXPECT--
14
barfoo
@@ -4,7 +4,7 @@
{{ constant('DATE_W3C') == expect ? 'true' : 'false' }}
{{ constant('ARRAY_AS_PROPS', object) }}
--DATA--
return ['expect' => DATE_W3C, 'object' => new ArrayObject(['hi'])]
return ['expect' => DATE_W3C, 'object' => new \ArrayObject(['hi'])]
--EXPECT--
true
2
+3 -3
View File
@@ -12,10 +12,10 @@
date_default_timezone_set('UTC');
return [
'date1' => mktime(13, 45, 0, 10, 4, 2010),
'date2' => new DateTime('2010-10-04 13:45'),
'date2' => new \DateTime('2010-10-04 13:45'),
'date3' => '2010-10-04 13:45',
'date4' => 1286199900, // DateTime::createFromFormat('Y-m-d H:i', '2010-10-04 13:45', new DateTimeZone('UTC'))->getTimestamp() -- A unixtimestamp is always GMT
'date5' => -189291360, // DateTime::createFromFormat('Y-m-d H:i', '1964-01-02 03:04', new DateTimeZone('UTC'))->getTimestamp(),
'date4' => 1286199900, // \DateTime::createFromFormat('Y-m-d H:i', '2010-10-04 13:45', new \DateTimeZone('UTC'))->getTimestamp() -- A unixtimestamp is always GMT
'date5' => -189291360, // \DateTime::createFromFormat('Y-m-d H:i', '1964-01-02 03:04', new \DateTimeZone('UTC'))->getTimestamp(),
]
--EXPECT--
OK
@@ -1,7 +1,7 @@
--TEST--
"dump" function, xdebug is not loaded or xdebug <2.2-dev is loaded
--CONDITION--
!extension_loaded('xdebug') || (($r = new ReflectionExtension('xdebug')) && version_compare($r->getVersion(), '2.2-dev', '<'))
!extension_loaded('xdebug') || (($r = new \ReflectionExtension('xdebug')) && version_compare($r->getVersion(), '2.2-dev', '<'))
--TEMPLATE--
{{ dump() }}
--DATA--
@@ -8,7 +8,7 @@ Hello '{{ images.image.0.group }}'!
- {{ image.group }}
{% endfor %}
--DATA--
return ['images' => new SimpleXMLElement('<images><image><group myattr="example">foo</group></image><image><group>bar</group></image></images>')]
return ['images' => new \SimpleXMLElement('<images><image><group myattr="example">foo</group></image><image><group>bar</group></image></images>')]
--EXPECT--
Hello 'foo'!
example
@@ -17,7 +17,7 @@
* {{ key }}
{% endfor %}
--DATA--
class ItemsIteratorCountable implements Iterator, Countable
class ItemsIteratorCountable implements Iterator, \Countable
{
protected $values = ['foo' => 'bar', 'bar' => 'foo'];
public function current() { return current($this->values); }
+1 -1
View File
@@ -6,7 +6,7 @@
{{ value is constant('TwigTestFoo::BAR_NAME') ? 'ok' : 'no' }}
{{ 2 is constant('ARRAY_AS_PROPS', object) ? 'ok' : 'no' }}
--DATA--
return ['value' => 'bar', 'object' => new ArrayObject(['hi'])]
return ['value' => 'bar', 'object' => new \ArrayObject(['hi'])]
--EXPECT--
ok
ok
@@ -6,7 +6,7 @@
{{ constant('FOOBAR') is not defined ? 'ok' : 'ko' }}
{{ constant('FOOBAR', object) is not defined ? 'ok' : 'ko' }}
--DATA--
return ['expect' => DATE_W3C, 'object' => new ArrayObject(['hi'])]
return ['expect' => DATE_W3C, 'object' => new \ArrayObject(['hi'])]
--EXPECT--
ok
ok
+2 -2
View File
@@ -8,8 +8,8 @@
--DATA--
return [
'foo' => [],
'traversable' => new ArrayIterator([]),
'obj' => new stdClass(),
'traversable' => new \ArrayIterator([]),
'obj' => new \stdClass(),
'val' => 'test',
]
--EXPECT--
+5 -5
View File
@@ -245,7 +245,7 @@ class TwigTestExtension extends Twig_Extension
public function __call($method, $arguments)
{
if ('magicCall' !== $method) {
throw new BadMethodCallException('Unexpected call to __call');
throw new \BadMethodCallException('Unexpected call to __call');
}
return 'magic_'.$arguments[0];
@@ -254,7 +254,7 @@ class TwigTestExtension extends Twig_Extension
public static function __callStatic($method, $arguments)
{
if ('magicStaticCall' !== $method) {
throw new BadMethodCallException('Unexpected call to __callStatic');
throw new \BadMethodCallException('Unexpected call to __callStatic');
}
return 'static_magic_'.$arguments[0];
@@ -269,7 +269,7 @@ class MagicCallStub
{
public function __call($name, $args)
{
throw new Exception('__call shall not be called');
throw new \Exception('__call shall not be called');
}
}
@@ -312,7 +312,7 @@ class CountableStub implements \Countable
public function __toString()
{
throw new Exception('__toString shall not be called on \Countables');
throw new \Exception('__toString shall not be called on \Countables');
}
}
@@ -330,6 +330,6 @@ class IteratorAggregateStub implements \IteratorAggregate
public function getIterator()
{
return new ArrayIterator($this->data);
return new \ArrayIterator($this->data);
}
}
+1 -1
View File
@@ -148,7 +148,7 @@ class Twig_Tests_Loader_FilesystemTest extends \PHPUnit\Framework\TestCase
try {
$loader->getSourceContext('@named/nowhere.html');
} catch (Exception $e) {
} catch (\Exception $e) {
$this->assertInstanceof('Twig_Error_Loader', $e);
$this->assertContains('Unable to find template "@named/nowhere.html"', $e->getMessage());
}
+2 -2
View File
@@ -81,7 +81,7 @@ EOF
'index' => 1,
'first' => true,
];
if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof Countable)) {
if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof \Countable)) {
\$length = count(\$context['_seq']);
\$context['loop']['revindex0'] = \$length - 1;
\$context['loop']['revindex'] = \$length;
@@ -158,7 +158,7 @@ EOF
'index' => 1,
'first' => true,
];
if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof Countable)) {
if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof \Countable)) {
\$length = count(\$context['_seq']);
\$context['loop']['revindex0'] = \$length - 1;
\$context['loop']['revindex'] = \$length;
@@ -41,7 +41,7 @@ abstract class Twig_Tests_Profiler_Dumper_AbstractTest extends \PHPUnit\Framewor
];
$profile->expects($this->any())->method('getProfiles')->will($this->returnValue($subProfiles));
$profile->expects($this->any())->method('getIterator')->will($this->returnValue(new ArrayIterator($subProfiles)));
$profile->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator($subProfiles)));
return $profile;
}
@@ -94,7 +94,7 @@ abstract class Twig_Tests_Profiler_Dumper_AbstractTest extends \PHPUnit\Framewor
$profile->expects($this->any())->method('getType')->will($this->returnValue($type));
$profile->expects($this->any())->method('getTemplate')->will($this->returnValue($templateName));
$profile->expects($this->any())->method('getProfiles')->will($this->returnValue($subProfiles));
$profile->expects($this->any())->method('getIterator')->will($this->returnValue(new ArrayIterator($subProfiles)));
$profile->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator($subProfiles)));
return $profile;
}
+8 -8
View File
@@ -16,7 +16,7 @@ class Twig_Tests_TemplateTest extends \PHPUnit\Framework\TestCase
public function testDisplayBlocksAcceptTemplateOnlyAsBlocks()
{
$template = $this->getMockForAbstractClass('Twig_Template', [], '', false);
$template->displayBlock('foo', [], ['foo' => [new stdClass(), 'foo']]);
$template->displayBlock('foo', [], ['foo' => [new \stdClass(), 'foo']]);
}
/**
@@ -35,7 +35,7 @@ class Twig_Tests_TemplateTest extends \PHPUnit\Framework\TestCase
'array' => ['foo' => 'foo'],
'array_access' => new Twig_TemplateArrayAccessObject(),
'magic_exception' => new Twig_TemplateMagicPropertyObjectWithException(),
'object' => new stdClass(),
'object' => new \stdClass(),
];
try {
@@ -255,7 +255,7 @@ class Twig_Tests_TemplateTest extends \PHPUnit\Framework\TestCase
];
$objectArray = new Twig_TemplateArrayAccessObject();
$arrayObject = new ArrayObject($array);
$arrayObject = new \ArrayObject($array);
$stdObject = (object) $array;
$magicPropertyObject = new Twig_TemplateMagicPropertyObject();
$propertyObject = new Twig_TemplatePropertyObject();
@@ -303,7 +303,7 @@ class Twig_Tests_TemplateTest extends \PHPUnit\Framework\TestCase
foreach ($testObjects as $testObject) {
foreach ($basicTests as $test) {
// properties cannot be numbers
if (($testObject[0] instanceof stdClass || $testObject[0] instanceof Twig_TemplatePropertyObject) && is_numeric($test[2])) {
if (($testObject[0] instanceof \stdClass || $testObject[0] instanceof Twig_TemplatePropertyObject) && is_numeric($test[2])) {
continue;
}
@@ -513,7 +513,7 @@ class Twig_TemplateMagicPropertyObjectWithException
{
public function __isset($key)
{
throw new Exception('Hey! Don\'t try to isset me!');
throw new \Exception('Hey! Don\'t try to isset me!');
}
}
@@ -530,11 +530,11 @@ class Twig_TemplatePropertyObject
protected $protected = 'protected';
}
class Twig_TemplatePropertyObjectAndIterator extends Twig_TemplatePropertyObject implements IteratorAggregate
class Twig_TemplatePropertyObjectAndIterator extends Twig_TemplatePropertyObject implements \IteratorAggregate
{
public function getIterator()
{
return new ArrayIterator(['foo', 'bar']);
return new \ArrayIterator(['foo', 'bar']);
}
}
@@ -731,6 +731,6 @@ class Twig_TemplateMagicMethodExceptionObject
{
public function __call($method, $arguments)
{
throw new BadMethodCallException(sprintf('Unknown method "%s".', $method));
throw new \BadMethodCallException(sprintf('Unknown method "%s".', $method));
}
}
@@ -30,11 +30,11 @@ class Twig_Tests_Util_DeprecationCollectorTest extends \PHPUnit\Framework\TestCa
}
}
class Twig_Tests_Util_Iterator implements IteratorAggregate
class Twig_Tests_Util_Iterator implements \IteratorAggregate
{
public function getIterator()
{
return new ArrayIterator([
return new \ArrayIterator([
'ok.twig' => '{{ foo }}',
'deprec.twig' => '{{ deprec("foo") }}',
]);
+1 -1
View File
@@ -255,7 +255,7 @@ class Twig_Test_EscapingTest extends \PHPUnit\Framework\TestCase
.chr($codepoint >> 6 & 0x3f | 0x80)
.chr($codepoint & 0x3f | 0x80);
}
throw new Exception('Codepoint requested outside of Unicode range.');
throw new \Exception('Codepoint requested outside of Unicode range.');
}
public function testJavascriptEscapingEscapesOwaspRecommendedRanges()