Browse code

[3.0] remove the most blocking return types

Nicolas Grekas authored on 20/09/2019 12:07:06
Showing 12 changed files
... ...
@@ -24,7 +24,7 @@
24 24
         }
25 25
     ],
26 26
     "require": {
27
-        "php": "^7.1.3",
27
+        "php": "^7.2.9",
28 28
         "symfony/polyfill-mbstring": "^1.3",
29 29
         "symfony/polyfill-ctype": "^1.8"
30 30
     },
... ...
@@ -13,32 +13,32 @@ namespace Twig\Extension;
13 13
 
14 14
 abstract class AbstractExtension implements ExtensionInterface
15 15
 {
16
-    public function getTokenParsers(): array
16
+    public function getTokenParsers()
17 17
     {
18 18
         return [];
19 19
     }
20 20
 
21
-    public function getNodeVisitors(): array
21
+    public function getNodeVisitors()
22 22
     {
23 23
         return [];
24 24
     }
25 25
 
26
-    public function getFilters(): array
26
+    public function getFilters()
27 27
     {
28 28
         return [];
29 29
     }
30 30
 
31
-    public function getTests(): array
31
+    public function getTests()
32 32
     {
33 33
         return [];
34 34
     }
35 35
 
36
-    public function getFunctions(): array
36
+    public function getFunctions()
37 37
     {
38 38
         return [];
39 39
     }
40 40
 
41
-    public function getOperators(): array
41
+    public function getOperators()
42 42
     {
43 43
         return [];
44 44
     }
... ...
@@ -29,40 +29,40 @@ interface ExtensionInterface
29 29
      *
30 30
      * @return TokenParserInterface[]
31 31
      */
32
-    public function getTokenParsers(): array;
32
+    public function getTokenParsers();
33 33
 
34 34
     /**
35 35
      * Returns the node visitor instances to add to the existing list.
36 36
      *
37 37
      * @return NodeVisitorInterface[]
38 38
      */
39
-    public function getNodeVisitors(): array;
39
+    public function getNodeVisitors();
40 40
 
41 41
     /**
42 42
      * Returns a list of filters to add to the existing list.
43 43
      *
44 44
      * @return TwigFilter[]
45 45
      */
46
-    public function getFilters(): array;
46
+    public function getFilters();
47 47
 
48 48
     /**
49 49
      * Returns a list of tests to add to the existing list.
50 50
      *
51 51
      * @return TwigTest[]
52 52
      */
53
-    public function getTests(): array;
53
+    public function getTests();
54 54
 
55 55
     /**
56 56
      * Returns a list of functions to add to the existing list.
57 57
      *
58 58
      * @return TwigFunction[]
59 59
      */
60
-    public function getFunctions(): array;
60
+    public function getFunctions();
61 61
 
62 62
     /**
63 63
      * Returns a list of operators to add to the existing list.
64 64
      *
65 65
      * @return array<array> First array of unary operators, second array of binary operators
66 66
      */
67
-    public function getOperators(): array;
67
+    public function getOperators();
68 68
 }
... ...
@@ -23,13 +23,19 @@ class ProfilerExtension extends AbstractExtension
23 23
         $this->actives[] = $profile;
24 24
     }
25 25
 
26
-    public function enter(Profile $profile): void
26
+    /**
27
+     * @return void
28
+     */
29
+    public function enter(Profile $profile)
27 30
     {
28 31
         $this->actives[0]->addProfile($profile);
29 32
         array_unshift($this->actives, $profile);
30 33
     }
31 34
 
32
-    public function leave(Profile $profile): void
35
+    /**
36
+     * @return void
37
+     */
38
+    public function leave(Profile $profile)
33 39
     {
34 40
         $profile->leave();
35 41
         array_shift($this->actives);
... ...
@@ -139,7 +139,10 @@ class FilesystemLoader implements LoaderInterface
139 139
         return $path;
140 140
     }
141 141
 
142
-    public function exists(string $name): bool
142
+    /**
143
+     * @return bool
144
+     */
145
+    public function exists(string $name)
143 146
     {
144 147
         $name = $this->normalizeName($name);
145 148
 
... ...
@@ -160,7 +163,10 @@ class FilesystemLoader implements LoaderInterface
160 163
         return filemtime($path) < $time;
161 164
     }
162 165
 
163
-    protected function findTemplate(string $name, bool $throw = true): ?string
166
+    /**
167
+     * @return string|null
168
+     */
169
+    protected function findTemplate(string $name, bool $throw = true)
164 170
     {
165 171
         $name = $this->normalizeName($name);
166 172
 
... ...
@@ -42,5 +42,8 @@ interface LoaderInterface
42 42
      */
43 43
     public function isFresh(string $name, int $time): bool;
44 44
 
45
-    public function exists(string $name): bool;
45
+    /**
46
+     * @return bool
47
+     */
48
+    public function exists(string $name);
46 49
 }
... ...
@@ -15,7 +15,7 @@ use Twig\Compiler;
15 15
 
16 16
 class SpaceshipBinary extends AbstractBinary
17 17
 {
18
-    public function operator(Compiler $compiler)
18
+    public function operator(Compiler $compiler): Compiler
19 19
     {
20 20
         return $compiler->raw('<=>');
21 21
     }
... ...
@@ -21,7 +21,7 @@ class FunctionExpression extends CallExpression
21 21
         parent::__construct(['arguments' => $arguments], ['name' => $name, 'is_defined_test' => false], $lineno);
22 22
     }
23 23
 
24
-    public function compile(Compiler $compiler): void
24
+    public function compile(Compiler $compiler)
25 25
     {
26 26
         $name = $this->getAttribute('name');
27 27
         $function = $compiler->getEnvironment()->getFunction($name);
... ...
@@ -77,7 +77,10 @@ class Node implements \Countable, \IteratorAggregate
77 77
         return implode("\n", $repr);
78 78
     }
79 79
 
80
-    public function compile(Compiler $compiler): void
80
+    /**
81
+     * @return void
82
+     */
83
+    public function compile(Compiler $compiler)
81 84
     {
82 85
         foreach ($this->nodes as $node) {
83 86
             $node->compile($compiler);
... ...
@@ -123,10 +126,7 @@ class Node implements \Countable, \IteratorAggregate
123 126
         return isset($this->nodes[$name]);
124 127
     }
125 128
 
126
-    /**
127
-     * @param string|int $name
128
-     */
129
-    public function getNode($name): self
129
+    public function getNode(string $name): self
130 130
     {
131 131
         if (!isset($this->nodes[$name])) {
132 132
             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
150 150
         return \count($this->nodes);
151 151
     }
152 152
 
153
-    public function getIterator()
153
+    public function getIterator(): \Traversable
154 154
     {
155 155
         return new \ArrayIterator($this->nodes);
156 156
     }
... ...
@@ -38,12 +38,12 @@ abstract class AbstractNodeVisitor implements NodeVisitorInterface
38 38
      *
39 39
      * @return Node The modified node
40 40
      */
41
-    abstract protected function doEnterNode(Node $node, Environment $env): Node;
41
+    abstract protected function doEnterNode(Node $node, Environment $env);
42 42
 
43 43
     /**
44 44
      * Called after child nodes are visited.
45 45
      *
46 46
      * @return Node|null The modified node or null if the node must be removed
47 47
      */
48
-    abstract protected function doLeaveNode(Node $node, Environment $env): ?Node;
48
+    abstract protected function doLeaveNode(Node $node, Environment $env);
49 49
 }
... ...
@@ -148,7 +148,7 @@ final class Profile implements \IteratorAggregate, \Serializable
148 148
         $this->enter();
149 149
     }
150 150
 
151
-    public function getIterator()
151
+    public function getIterator(): \Traversable
152 152
     {
153 153
         return new \ArrayIterator($this->profiles);
154 154
     }
... ...
@@ -31,12 +31,16 @@ interface TokenParserInterface
31 31
     /**
32 32
      * Parses a token and returns a node.
33 33
      *
34
+     * @return Node
35
+     *
34 36
      * @throws SyntaxError
35 37
      */
36
-    public function parse(Token $token): Node;
38
+    public function parse(Token $token);
37 39
 
38 40
     /**
39 41
      * Gets the tag name associated with this token parser.
42
+     *
43
+     * @return string
40 44
      */
41
-    public function getTag(): string;
45
+    public function getTag();
42 46
 }