moved more methods/properties to private

This commit is contained in:
Fabien Potencier
2015-08-18 17:15:53 +02:00
parent 7de9a57b92
commit 905a2a8102
5 changed files with 67 additions and 67 deletions
+29 -29
View File
@@ -18,32 +18,32 @@ class Twig_Environment
{
const VERSION = '2.0.0-DEV';
protected $charset;
protected $loader;
protected $debug;
protected $autoReload;
protected $cache;
protected $lexer;
protected $parser;
protected $compiler;
protected $baseTemplateClass;
protected $extensions;
protected $parsers;
protected $visitors;
protected $filters;
protected $tests;
protected $functions;
protected $globals;
protected $runtimeInitialized;
protected $extensionInitialized;
protected $loadedTemplates;
protected $strictVariables;
protected $unaryOperators;
protected $binaryOperators;
protected $templateClassPrefix = '__TwigTemplate_';
protected $functionCallbacks;
protected $filterCallbacks;
protected $staging;
private $charset;
private $loader;
private $debug;
private $autoReload;
private $cache;
private $lexer;
private $parser;
private $compiler;
private $baseTemplateClass;
private $extensions;
private $parsers;
private $visitors;
private $filters;
private $tests;
private $functions;
private $globals;
private $runtimeInitialized;
private $extensionInitialized;
private $loadedTemplates;
private $strictVariables;
private $unaryOperators;
private $binaryOperators;
private $templateClassPrefix = '__TwigTemplate_';
private $functionCallbacks;
private $filterCallbacks;
private $staging;
/**
* Constructor.
@@ -1088,7 +1088,7 @@ class Twig_Environment
return array_keys($alternatives);
}
protected function initGlobals()
private function initGlobals()
{
$globals = array();
foreach ($this->extensions as $extension) {
@@ -1105,7 +1105,7 @@ class Twig_Environment
return call_user_func_array('array_merge', $globals);
}
protected function initExtensions()
private function initExtensions()
{
if ($this->extensionInitialized) {
return;
@@ -1126,7 +1126,7 @@ class Twig_Environment
$this->initExtension($this->staging);
}
protected function initExtension(Twig_ExtensionInterface $extension)
private function initExtension(Twig_ExtensionInterface $extension)
{
// filters
foreach ($extension->getFilters() as $filter) {
+6 -6
View File
@@ -62,7 +62,7 @@ class Twig_ExpressionParser
return $expr;
}
protected function getPrimary()
private function getPrimary()
{
$token = $this->parser->getCurrentToken();
@@ -84,7 +84,7 @@ class Twig_ExpressionParser
return $this->parsePrimaryExpression();
}
protected function parseConditionalExpression($expr)
private function parseConditionalExpression($expr)
{
while ($this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, '?')) {
if (!$this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) {
@@ -105,12 +105,12 @@ class Twig_ExpressionParser
return $expr;
}
protected function isUnary(Twig_Token $token)
private function isUnary(Twig_Token $token)
{
return $token->test(Twig_Token::OPERATOR_TYPE) && isset($this->unaryOperators[$token->getValue()]);
}
protected function isBinary(Twig_Token $token)
private function isBinary(Twig_Token $token)
{
return $token->test(Twig_Token::OPERATOR_TYPE) && isset($this->binaryOperators[$token->getValue()]);
}
@@ -561,7 +561,7 @@ class Twig_ExpressionParser
return new Twig_Node($targets);
}
protected function getFunctionNodeClass($name, $line)
private function getFunctionNodeClass($name, $line)
{
$env = $this->parser->getEnvironment();
@@ -577,7 +577,7 @@ class Twig_ExpressionParser
return $function->getNodeClass();
}
protected function getFilterNodeClass($name, $line)
private function getFilterNodeClass($name, $line)
{
$env = $this->parser->getEnvironment();
+28 -28
View File
@@ -17,21 +17,21 @@
*/
class Twig_Lexer
{
protected $tokens;
protected $code;
protected $cursor;
protected $lineno;
protected $end;
protected $state;
protected $states;
protected $brackets;
protected $env;
protected $filename;
protected $options;
protected $regexes;
protected $position;
protected $positions;
protected $currentVarBlockLine;
private $tokens;
private $code;
private $cursor;
private $lineno;
private $end;
private $state;
private $states;
private $brackets;
private $env;
private $filename;
private $options;
private $regexes;
private $position;
private $positions;
private $currentVarBlockLine;
const STATE_DATA = 0;
const STATE_BLOCK = 1;
@@ -139,7 +139,7 @@ class Twig_Lexer
return new Twig_TokenStream($this->tokens, $this->filename);
}
protected function lexData()
private function lexData()
{
// if no matches are left we return the rest of the template as simple text token
if ($this->position == count($this->positions[0]) - 1) {
@@ -195,7 +195,7 @@ class Twig_Lexer
}
}
protected function lexBlock()
private function lexBlock()
{
if (empty($this->brackets) && preg_match($this->regexes['lex_block'], $this->code, $match, null, $this->cursor)) {
$this->pushToken(Twig_Token::BLOCK_END_TYPE);
@@ -206,7 +206,7 @@ class Twig_Lexer
}
}
protected function lexVar()
private function lexVar()
{
if (empty($this->brackets) && preg_match($this->regexes['lex_var'], $this->code, $match, null, $this->cursor)) {
$this->pushToken(Twig_Token::VAR_END_TYPE);
@@ -217,7 +217,7 @@ class Twig_Lexer
}
}
protected function lexExpression()
private function lexExpression()
{
// whitespace
if (preg_match('/\s+/A', $this->code, $match, null, $this->cursor)) {
@@ -285,7 +285,7 @@ class Twig_Lexer
}
}
protected function lexRawData()
private function lexRawData()
{
if (!preg_match($this->regexes['lex_raw_data'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
throw new Twig_Error_Syntax('Unexpected end of file: Unclosed "verbatim" block', $this->lineno, $this->filename);
@@ -301,7 +301,7 @@ class Twig_Lexer
$this->pushToken(Twig_Token::TEXT_TYPE, $text);
}
protected function lexComment()
private function lexComment()
{
if (!preg_match($this->regexes['lex_comment'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
throw new Twig_Error_Syntax('Unclosed comment', $this->lineno, $this->filename);
@@ -310,7 +310,7 @@ class Twig_Lexer
$this->moveCursor(substr($this->code, $this->cursor, $match[0][1] - $this->cursor).$match[0][0]);
}
protected function lexString()
private function lexString()
{
if (preg_match($this->regexes['interpolation_start'], $this->code, $match, null, $this->cursor)) {
$this->brackets[] = array($this->options['interpolation'][0], $this->lineno);
@@ -331,7 +331,7 @@ class Twig_Lexer
}
}
protected function lexInterpolation()
private function lexInterpolation()
{
$bracket = end($this->brackets);
if ($this->options['interpolation'][0] === $bracket[0] && preg_match($this->regexes['interpolation_end'], $this->code, $match, null, $this->cursor)) {
@@ -344,7 +344,7 @@ class Twig_Lexer
}
}
protected function pushToken($type, $value = '')
private function pushToken($type, $value = '')
{
// do not push empty text tokens
if (Twig_Token::TEXT_TYPE === $type && '' === $value) {
@@ -354,13 +354,13 @@ class Twig_Lexer
$this->tokens[] = new Twig_Token($type, $value, $this->lineno);
}
protected function moveCursor($text)
private function moveCursor($text)
{
$this->cursor += strlen($text);
$this->lineno += substr_count($text, "\n");
}
protected function getOperatorRegex()
private function getOperatorRegex()
{
$operators = array_merge(
array('='),
@@ -390,13 +390,13 @@ class Twig_Lexer
return '/'.implode('|', $regex).'/A';
}
protected function pushState($state)
private function pushState($state)
{
$this->states[] = $this->state;
$this->state = $state;
}
protected function popState()
private function popState()
{
if (0 === count($this->states)) {
throw new Exception('Cannot pop state without a previous state');
+1 -1
View File
@@ -17,7 +17,7 @@
class Twig_Loader_Chain implements Twig_LoaderInterface
{
private $hasSourceCache = array();
protected $loaders = array();
private $loaders = array();
/**
* Constructor.
+3 -3
View File
@@ -202,12 +202,12 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface
throw new Twig_Error_Loader($this->errorCache[$name]);
}
protected function normalizeName($name)
private function normalizeName($name)
{
return preg_replace('#/{2,}#', '/', strtr($name, '\\', '/'));
}
protected function parseName($name, $default = self::MAIN_NAMESPACE)
private function parseName($name, $default = self::MAIN_NAMESPACE)
{
if (isset($name[0]) && '@' == $name[0]) {
if (false === $pos = strpos($name, '/')) {
@@ -223,7 +223,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface
return array($default, $name);
}
protected function validateName($name)
private function validateName($name)
{
if (false !== strpos($name, "\0")) {
throw new Twig_Error_Loader('A template name cannot contain NUL bytes.');