mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-31 04:27:00 +00:00
Add private types on 4.x
This commit is contained in:
committed by
Fabien Potencier
parent
8da936a2e0
commit
72bbe489e1
@@ -96,10 +96,7 @@ class ExpressionParser
|
||||
return $expr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrowFunctionExpression|null
|
||||
*/
|
||||
private function parseArrow()
|
||||
private function parseArrow(): ?ArrowFunctionExpression
|
||||
{
|
||||
$stream = $this->parser->getStream();
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ final class ExtensionSet
|
||||
private array $extensions;
|
||||
private bool $initialized = false;
|
||||
private bool $runtimeInitialized = false;
|
||||
private $staging;
|
||||
private StagingExtension $staging;
|
||||
|
||||
/**
|
||||
* @var TokenParserInterface[]
|
||||
|
||||
+3
-3
@@ -88,7 +88,7 @@ class Lexer
|
||||
], $options);
|
||||
}
|
||||
|
||||
private function initialize()
|
||||
private function initialize(): void
|
||||
{
|
||||
if ($this->isInitialized) {
|
||||
return;
|
||||
@@ -525,7 +525,7 @@ class Lexer
|
||||
}
|
||||
}
|
||||
|
||||
private function pushToken($type, $value = ''): void
|
||||
private function pushToken(int $type, $value = ''): void
|
||||
{
|
||||
// do not push empty text tokens
|
||||
if (Token::TEXT_TYPE === $type && '' === $value) {
|
||||
@@ -535,7 +535,7 @@ class Lexer
|
||||
$this->tokens[] = new Token($type, $value, $this->lineno);
|
||||
}
|
||||
|
||||
private function moveCursor($text): void
|
||||
private function moveCursor(string $text): void
|
||||
{
|
||||
$this->cursor += \strlen($text);
|
||||
$this->lineno += substr_count($text, "\n");
|
||||
|
||||
@@ -29,7 +29,7 @@ final class ChainLoader implements LoaderInterface
|
||||
/**
|
||||
* @var array<string, bool>
|
||||
*/
|
||||
private $hasSourceCache = [];
|
||||
private array $hasSourceCache = [];
|
||||
|
||||
/**
|
||||
* @param iterable<LoaderInterface> $loaders
|
||||
|
||||
@@ -60,7 +60,7 @@ class DefinedTest extends TestExpression
|
||||
parent::__construct($node, $name, $arguments, $lineno);
|
||||
}
|
||||
|
||||
private function changeIgnoreStrictCheck(GetAttrExpression $node)
|
||||
private function changeIgnoreStrictCheck(GetAttrExpression $node): void
|
||||
{
|
||||
$node->setAttribute('optimizable', false);
|
||||
$node->setAttribute('ignore_strict_check', true);
|
||||
|
||||
@@ -18,9 +18,9 @@ namespace Twig\Node;
|
||||
*/
|
||||
class NameDeprecation
|
||||
{
|
||||
private $package;
|
||||
private $version;
|
||||
private $newName;
|
||||
private string $package;
|
||||
private string $version;
|
||||
private string $newName;
|
||||
|
||||
public function __construct(string $package = '', string $version = '', string $newName = '')
|
||||
{
|
||||
|
||||
+2
-2
@@ -32,9 +32,9 @@ class Node implements \Countable, \IteratorAggregate
|
||||
private ?Source $sourceContext = null;
|
||||
|
||||
/** @var array<string, NameDeprecation> */
|
||||
private $nodeNameDeprecations = [];
|
||||
private array $nodeNameDeprecations = [];
|
||||
/** @var array<string, NameDeprecation> */
|
||||
private $attributeNameDeprecations = [];
|
||||
private array $attributeNameDeprecations = [];
|
||||
|
||||
/**
|
||||
* @param array $nodes An array of named nodes
|
||||
|
||||
@@ -182,7 +182,7 @@ final class EscaperNodeVisitor implements NodeVisitorInterface
|
||||
return \in_array($type, $safe) || \in_array('all', $safe);
|
||||
}
|
||||
|
||||
private function needEscaping()
|
||||
private function needEscaping(): string|false
|
||||
{
|
||||
if (\count($this->statusStack)) {
|
||||
return $this->statusStack[\count($this->statusStack) - 1];
|
||||
|
||||
@@ -28,8 +28,8 @@ use Twig\Node\Node;
|
||||
*/
|
||||
final class SafeAnalysisNodeVisitor implements NodeVisitorInterface
|
||||
{
|
||||
private $data = [];
|
||||
private $safeVars = [];
|
||||
private array $data = [];
|
||||
private array $safeVars = [];
|
||||
|
||||
public function setSafeVars(array $safeVars): void
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ EOF;
|
||||
return $str;
|
||||
}
|
||||
|
||||
private function dumpChildren(string $parent, Profile $profile, &$data)
|
||||
private function dumpChildren(string $parent, Profile $profile, &$data): void
|
||||
{
|
||||
foreach ($profile as $p) {
|
||||
if ($p->isTemplate()) {
|
||||
@@ -53,7 +53,7 @@ EOF;
|
||||
}
|
||||
}
|
||||
|
||||
private function dumpProfile(string $edge, Profile $profile, &$data)
|
||||
private function dumpProfile(string $edge, Profile $profile, &$data): void
|
||||
{
|
||||
if (isset($data[$edge])) {
|
||||
++$data[$edge]['ct'];
|
||||
|
||||
@@ -18,7 +18,7 @@ use Twig\Markup;
|
||||
final class EscaperRuntime implements RuntimeExtensionInterface
|
||||
{
|
||||
/** @var array<string, callable(string $string, string $charset): string> */
|
||||
private $escapers = [];
|
||||
private array $escapers = [];
|
||||
|
||||
/** @internal */
|
||||
public array $safeClasses = [];
|
||||
@@ -316,7 +316,7 @@ final class EscaperRuntime implements RuntimeExtensionInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function convertEncoding(string $string, string $to, string $from)
|
||||
private function convertEncoding(string $string, string $to, string $from): string
|
||||
{
|
||||
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.');
|
||||
|
||||
@@ -19,10 +19,7 @@ use Twig\Node\Node;
|
||||
|
||||
abstract class NodeTestCase extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Environment
|
||||
*/
|
||||
private $currentEnv;
|
||||
private Environment $currentEnv;
|
||||
|
||||
abstract public function getTests();
|
||||
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@ namespace Twig;
|
||||
final class Token
|
||||
{
|
||||
private $value;
|
||||
private $type;
|
||||
private $lineno;
|
||||
private int $type;
|
||||
private int $lineno;
|
||||
|
||||
public const EOF_TYPE = -1;
|
||||
public const TEXT_TYPE = 0;
|
||||
|
||||
Reference in New Issue
Block a user