mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-10 01:16:52 +00:00
[3.0] remove the most blocking return types
This commit is contained in:
+1
-1
@@ -24,7 +24,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"php": "^7.2.9",
|
||||
"symfony/polyfill-mbstring": "^1.3",
|
||||
"symfony/polyfill-ctype": "^1.8"
|
||||
},
|
||||
|
||||
@@ -13,32 +13,32 @@ namespace Twig\Extension;
|
||||
|
||||
abstract class AbstractExtension implements ExtensionInterface
|
||||
{
|
||||
public function getTokenParsers(): array
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getNodeVisitors(): array
|
||||
public function getNodeVisitors()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getFilters(): array
|
||||
public function getFilters()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getTests(): array
|
||||
public function getTests()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getFunctions(): array
|
||||
public function getFunctions()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getOperators(): array
|
||||
public function getOperators()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -29,40 +29,40 @@ interface ExtensionInterface
|
||||
*
|
||||
* @return TokenParserInterface[]
|
||||
*/
|
||||
public function getTokenParsers(): array;
|
||||
public function getTokenParsers();
|
||||
|
||||
/**
|
||||
* Returns the node visitor instances to add to the existing list.
|
||||
*
|
||||
* @return NodeVisitorInterface[]
|
||||
*/
|
||||
public function getNodeVisitors(): array;
|
||||
public function getNodeVisitors();
|
||||
|
||||
/**
|
||||
* Returns a list of filters to add to the existing list.
|
||||
*
|
||||
* @return TwigFilter[]
|
||||
*/
|
||||
public function getFilters(): array;
|
||||
public function getFilters();
|
||||
|
||||
/**
|
||||
* Returns a list of tests to add to the existing list.
|
||||
*
|
||||
* @return TwigTest[]
|
||||
*/
|
||||
public function getTests(): array;
|
||||
public function getTests();
|
||||
|
||||
/**
|
||||
* Returns a list of functions to add to the existing list.
|
||||
*
|
||||
* @return TwigFunction[]
|
||||
*/
|
||||
public function getFunctions(): array;
|
||||
public function getFunctions();
|
||||
|
||||
/**
|
||||
* Returns a list of operators to add to the existing list.
|
||||
*
|
||||
* @return array<array> First array of unary operators, second array of binary operators
|
||||
*/
|
||||
public function getOperators(): array;
|
||||
public function getOperators();
|
||||
}
|
||||
|
||||
@@ -23,13 +23,19 @@ class ProfilerExtension extends AbstractExtension
|
||||
$this->actives[] = $profile;
|
||||
}
|
||||
|
||||
public function enter(Profile $profile): void
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function enter(Profile $profile)
|
||||
{
|
||||
$this->actives[0]->addProfile($profile);
|
||||
array_unshift($this->actives, $profile);
|
||||
}
|
||||
|
||||
public function leave(Profile $profile): void
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function leave(Profile $profile)
|
||||
{
|
||||
$profile->leave();
|
||||
array_shift($this->actives);
|
||||
|
||||
@@ -139,7 +139,10 @@ class FilesystemLoader implements LoaderInterface
|
||||
return $path;
|
||||
}
|
||||
|
||||
public function exists(string $name): bool
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function exists(string $name)
|
||||
{
|
||||
$name = $this->normalizeName($name);
|
||||
|
||||
@@ -160,7 +163,10 @@ class FilesystemLoader implements LoaderInterface
|
||||
return filemtime($path) < $time;
|
||||
}
|
||||
|
||||
protected function findTemplate(string $name, bool $throw = true): ?string
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
protected function findTemplate(string $name, bool $throw = true)
|
||||
{
|
||||
$name = $this->normalizeName($name);
|
||||
|
||||
|
||||
@@ -42,5 +42,8 @@ interface LoaderInterface
|
||||
*/
|
||||
public function isFresh(string $name, int $time): bool;
|
||||
|
||||
public function exists(string $name): bool;
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function exists(string $name);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ use Twig\Compiler;
|
||||
|
||||
class SpaceshipBinary extends AbstractBinary
|
||||
{
|
||||
public function operator(Compiler $compiler)
|
||||
public function operator(Compiler $compiler): Compiler
|
||||
{
|
||||
return $compiler->raw('<=>');
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class FunctionExpression extends CallExpression
|
||||
parent::__construct(['arguments' => $arguments], ['name' => $name, 'is_defined_test' => false], $lineno);
|
||||
}
|
||||
|
||||
public function compile(Compiler $compiler): void
|
||||
public function compile(Compiler $compiler)
|
||||
{
|
||||
$name = $this->getAttribute('name');
|
||||
$function = $compiler->getEnvironment()->getFunction($name);
|
||||
|
||||
+6
-6
@@ -77,7 +77,10 @@ class Node implements \Countable, \IteratorAggregate
|
||||
return implode("\n", $repr);
|
||||
}
|
||||
|
||||
public function compile(Compiler $compiler): void
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function compile(Compiler $compiler)
|
||||
{
|
||||
foreach ($this->nodes as $node) {
|
||||
$node->compile($compiler);
|
||||
@@ -123,10 +126,7 @@ class Node implements \Countable, \IteratorAggregate
|
||||
return isset($this->nodes[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|int $name
|
||||
*/
|
||||
public function getNode($name): self
|
||||
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)));
|
||||
@@ -150,7 +150,7 @@ class Node implements \Countable, \IteratorAggregate
|
||||
return \count($this->nodes);
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
public function getIterator(): \Traversable
|
||||
{
|
||||
return new \ArrayIterator($this->nodes);
|
||||
}
|
||||
|
||||
@@ -38,12 +38,12 @@ abstract class AbstractNodeVisitor implements NodeVisitorInterface
|
||||
*
|
||||
* @return Node The modified node
|
||||
*/
|
||||
abstract protected function doEnterNode(Node $node, Environment $env): Node;
|
||||
abstract protected function doEnterNode(Node $node, Environment $env);
|
||||
|
||||
/**
|
||||
* Called after child nodes are visited.
|
||||
*
|
||||
* @return Node|null The modified node or null if the node must be removed
|
||||
*/
|
||||
abstract protected function doLeaveNode(Node $node, Environment $env): ?Node;
|
||||
abstract protected function doLeaveNode(Node $node, Environment $env);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ final class Profile implements \IteratorAggregate, \Serializable
|
||||
$this->enter();
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
public function getIterator(): \Traversable
|
||||
{
|
||||
return new \ArrayIterator($this->profiles);
|
||||
}
|
||||
|
||||
@@ -31,12 +31,16 @@ interface TokenParserInterface
|
||||
/**
|
||||
* Parses a token and returns a node.
|
||||
*
|
||||
* @return Node
|
||||
*
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
public function parse(Token $token): Node;
|
||||
public function parse(Token $token);
|
||||
|
||||
/**
|
||||
* Gets the tag name associated with this token parser.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTag(): string;
|
||||
public function getTag();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user