Page Menu
Home
WMGMC Issues
搜索
Configure Global Search
登录
Files
F15922
DeprecatedTokenParser.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
订阅
标记用于日后
授予令牌
Size
1 KB
Referenced Files
None
订阅者
None
DeprecatedTokenParser.php
View Options
<?php
/*
* This file is part of Twig.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Twig\TokenParser
;
use
Twig\Error\SyntaxError
;
use
Twig\Node\DeprecatedNode
;
use
Twig\Node\Node
;
use
Twig\Token
;
/**
* Deprecates a section of a template.
*
* {% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' %}
* {% extends 'layout.html.twig' %}
*
* {% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' package="foo/bar" version="1.1" %}
*
* @author Yonel Ceruto <yonelceruto@gmail.com>
*
* @internal
*/
final
class
DeprecatedTokenParser
extends
AbstractTokenParser
{
public
function
parse
(
Token
$token
):
Node
{
$stream
=
$this
->
parser
->
getStream
();
$expressionParser
=
$this
->
parser
->
getExpressionParser
();
$expr
=
$expressionParser
->
parseExpression
();
$node
=
new
DeprecatedNode
(
$expr
,
$token
->
getLine
());
while
(
$stream
->
test
(
Token
::
NAME_TYPE
))
{
$k
=
$stream
->
getCurrent
()->
getValue
();
$stream
->
next
();
$stream
->
expect
(
Token
::
OPERATOR_TYPE
,
'='
);
switch
(
$k
)
{
case
'package'
:
$node
->
setNode
(
'package'
,
$expressionParser
->
parseExpression
());
break
;
case
'version'
:
$node
->
setNode
(
'version'
,
$expressionParser
->
parseExpression
());
break
;
default
:
throw
new
SyntaxError
(
\sprintf
(
'Unknown "%s" option.'
,
$k
),
$stream
->
getCurrent
()->
getLine
(),
$stream
->
getSourceContext
());
}
}
$stream
->
expect
(
Token
::
BLOCK_END_TYPE
);
return
$node
;
}
public
function
getTag
():
string
{
return
'deprecated'
;
}
}
File Metadata
详情
附加的
Mime Type
text/x-php
Expires
9月 9 Tue, 5:50 AM (11 h, 53 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5402
默认替代文本
DeprecatedTokenParser.php (1 KB)
Attached To
Mode
rMAILCOW mailcow-tracking
附加的
Detach File
Event Timeline
Log In to Comment