_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q1900
|
Parser._return
|
train
|
private function _return() {
$node = new ReturnStatementNode();
$this->mustMatch(T_RETURN, $node);
if ($this->tryMatch(';', $node, NULL, TRUE, TRUE) || $this->currentType === T_CLOSE_TAG) {
return $node;
|
php
|
{
"resource": ""
}
|
q1901
|
Parser._yield
|
train
|
private function _yield() {
$node = new YieldNode();
$this->mustMatch(T_YIELD, $node);
$expr = $this->expr();
if ($this->tryMatch(T_DOUBLE_ARROW, $node))
|
php
|
{
"resource": ""
}
|
q1902
|
Parser._global
|
train
|
private function _global() {
$node = new GlobalStatementNode();
$this->mustMatch(T_GLOBAL, $node);
$variables = new CommaListNode();
do {
$variables->addChild($this->globalVar());
}
|
php
|
{
"resource": ""
}
|
q1903
|
Parser.globalVar
|
train
|
private function globalVar() {
if ($this->currentType === T_VARIABLE) {
return $this->mustMatchToken(T_VARIABLE);
}
elseif ($this->currentType === '$') {
if ($this->isLookAhead('{')) {
return $this->_compoundVariable();
|
php
|
{
"resource": ""
}
|
q1904
|
Parser._echo
|
train
|
private function _echo() {
$node = new EchoStatementNode();
$this->mustMatch(T_ECHO, $node);
$expressions = new CommaListNode();
do {
$expressions->addChild($this->expr());
}
|
php
|
{
"resource": ""
}
|
q1905
|
Parser._unset
|
train
|
private function _unset() {
$statement_node = new UnsetStatementNode();
$node = new UnsetNode();
$this->mustMatch(T_UNSET, $node, 'name');
$arguments = new CommaListNode();
$this->mustMatch('(', $node, 'openParen');
|
php
|
{
"resource": ""
}
|
q1906
|
Parser._foreach
|
train
|
private function _foreach() {
$node = new ForeachNode();
$this->mustMatch(T_FOREACH, $node);
$this->mustMatch('(', $node, 'openParen');
$node->addChild($this->expr(), 'onEach');
$this->mustMatch(T_AS, $node);
$value = $this->foreachVariable();
if ($this->currentType === T_DOUBLE_ARROW) {
$node->addChild($value, 'key');
$this->mustMatch(T_DOUBLE_ARROW, $node);
$node->addChild($this->foreachVariable(), 'value');
}
else {
$node->addChild($value, 'value');
}
|
php
|
{
"resource": ""
}
|
q1907
|
Parser.foreachVariable
|
train
|
private function foreachVariable() {
if ($this->currentType === T_LIST) {
return $this->_list();
}
else {
if ($this->currentType === '&') {
|
php
|
{
"resource": ""
}
|
q1908
|
Parser._declare
|
train
|
private function _declare() {
$node = new DeclareNode();
$this->mustMatch(T_DECLARE, $node);
$this->mustMatch('(', $node, 'openParen');
$directives = new CommaListNode();
$node->addChild($directives, 'directives');
if (!$this->tryMatch(')', $node, 'closeParen', FALSE, TRUE)) {
do {
$declare_directive = new DeclareDirectiveNode();
$this->tryMatch(T_STRING, $declare_directive, 'name');
if ($this->tryMatch('=', $declare_directive)) {
$declare_directive->addChild($this->staticScalar(), 'value');
}
$directives->addChild($declare_directive);
} while ($this->tryMatch(',', $directives));
$this->mustMatch(')', $node, 'closeParen', FALSE, TRUE);
}
if
|
php
|
{
"resource": ""
}
|
q1909
|
Parser._try
|
train
|
private function _try() {
$node = new TryCatchNode();
$this->mustMatch(T_TRY, $node);
$node->addChild($this->innerStatementBlock(), 'try');
$catch_node = new CatchNode();
while ($this->tryMatch(T_CATCH, $catch_node)) {
$this->mustMatch('(', $catch_node, 'openParen');
$catch_node->addChild($this->name(), 'exceptionType');
$this->mustMatch(T_VARIABLE, $catch_node, 'variable');
$this->mustMatch(')', $catch_node,
|
php
|
{
"resource": ""
}
|
q1910
|
Parser._throw
|
train
|
private function _throw() {
$node = new ThrowStatementNode();
$this->mustMatch(T_THROW, $node);
|
php
|
{
"resource": ""
}
|
q1911
|
Parser._goto
|
train
|
private function _goto() {
$node = new GotoStatementNode();
$this->mustMatch(T_GOTO,
|
php
|
{
"resource": ""
}
|
q1912
|
Parser.exprList
|
train
|
private function exprList() {
$node = new CommaListNode();
do {
$node->addChild($this->expr());
|
php
|
{
"resource": ""
}
|
q1913
|
Parser.staticScalar
|
train
|
private function staticScalar() {
if ($this->currentType === T_ARRAY) {
$node = new ArrayNode();
$this->mustMatch(T_ARRAY, $node);
$this->mustMatch('(', $node, 'openParen');
$this->staticArrayPairList($node, ')');
$this->mustMatch(')', $node, 'closeParen', TRUE);
return $node;
}
elseif ($this->currentType === '[') {
|
php
|
{
"resource": ""
}
|
q1914
|
Parser.staticOperand
|
train
|
private function staticOperand() {
static $scalar_types = [
T_STRING_VARNAME,
T_CLASS_C,
T_LNUMBER,
T_DNUMBER,
T_CONSTANT_ENCAPSED_STRING,
T_LINE,
T_FILE,
T_DIR,
T_TRAIT_C,
T_METHOD_C,
T_FUNC_C,
T_NS_C,
];
if ($scalar = $this->tryMatchToken($scalar_types)) {
return $scalar;
}
elseif ($this->currentType === '(') {
$node = new ParenthesisNode();
$this->mustMatch('(', $node, 'openParen');
$node->addChild($this->staticScalar(), 'expression');
$this->mustMatch(')', $node, 'closeParen', TRUE);
return $node;
}
elseif (in_array($this->currentType, self::$namespacePathTypes)) {
$namespace_path = $this->name();
if ($this->currentType === T_DOUBLE_COLON) {
$colon_node = new PartialNode();
$this->mustMatch(T_DOUBLE_COLON, $colon_node);
if ($this->currentType === T_CLASS) {
return $this->classNameScalar($namespace_path, $colon_node);
}
else {
$class_constant = $this->mustMatchToken(T_STRING);
return $this->classConstant($namespace_path, $colon_node, $class_constant);
}
}
else {
$node = new ConstantNode();
$node->addChild($namespace_path, 'constantName');
return $node;
}
}
elseif ($this->currentType
|
php
|
{
"resource": ""
}
|
q1915
|
Parser.expr
|
train
|
private function expr($static = FALSE) {
static $end_expression_types = [':', ';', ',', ')', ']', '}', T_AS, T_DOUBLE_ARROW, T_CLOSE_TAG];
// Group tokens into operands & operators to pass to the expression parser
$expression_nodes = [];
while ($this->currentType !== NULL && !in_array($this->currentType, $end_expression_types)) {
if ($op = $this->exprOperator($static)) {
$expression_nodes[] = $op;
if ($op->type === T_INSTANCEOF) {
$expression_nodes[] = $this->classNameReference();
}
}
elseif ($operand = ($static ? $this->staticOperand() : $this->exprOperand())) {
|
php
|
{
"resource": ""
}
|
q1916
|
Parser.exprOperator
|
train
|
private function exprOperator($static = FALSE) {
$token_type = $this->currentType;
if ($operator = OperatorFactory::createOperator($token_type, $static)) {
$this->mustMatch($token_type, $operator, 'operator');
if ($token_type === '?') {
if ($this->currentType === ':') {
$colon = new PartialNode();
$this->mustMatch(':', $colon);
return OperatorFactory::createElvisOperator($operator, $colon);
}
else {
$operator->then = $static ? $this->staticScalar() : $this->expr();
$colon = new PartialNode();
$this->mustMatch(':', $colon);
|
php
|
{
"resource": ""
}
|
q1917
|
Parser.backtick
|
train
|
private function backtick() {
$node = new BacktickNode();
$this->mustMatch('`', $node);
$this->encapsList($node, '`', TRUE);
|
php
|
{
"resource": ""
}
|
q1918
|
Parser.anonymousFunction
|
train
|
private function anonymousFunction(Node $static = NULL) {
$node = new AnonymousFunctionNode();
if ($static) {
$node->addChild($static);
}
$this->mustMatch(T_FUNCTION, $node);
$this->tryMatch('&', $node, 'reference');
$this->parameterList($node);
if ($this->tryMatch(T_USE, $node, 'lexicalUse')) {
$this->mustMatch('(', $node, 'lexicalOpenParen');
$lexical_vars_node = new CommaListNode();
do {
if ($this->currentType === '&') {
$var = new ReferenceVariableNode();
$this->mustMatch('&', $var);
$this->mustMatch(T_VARIABLE, $var, 'variable', TRUE);
$lexical_vars_node->addChild($var);
|
php
|
{
"resource": ""
}
|
q1919
|
Parser.newExpr
|
train
|
private function newExpr() {
$node = new NewNode();
$this->mustMatch(T_NEW, $node);
$node->addChild($this->classNameReference(),
|
php
|
{
"resource": ""
}
|
q1920
|
Parser.classNameReference
|
train
|
private function classNameReference() {
switch ($this->currentType) {
case T_STRING:
case T_NS_SEPARATOR:
case T_NAMESPACE:
$namespace_path = $this->name();
if ($this->currentType === T_DOUBLE_COLON) {
$node = $this->staticMember($namespace_path);
return $this->dynamicClassNameReference($node);
}
else {
return $namespace_path;
}
case T_STATIC:
$static_node = $this->mustMatchToken(T_STATIC);
if ($this->currentType === T_DOUBLE_COLON) {
$node = $this->staticMember($static_node);
return $this->dynamicClassNameReference($node);
}
else {
return $static_node;
|
php
|
{
"resource": ""
}
|
q1921
|
Parser.staticMember
|
train
|
private function staticMember($var_node) {
$node = new ClassMemberLookupNode();
$node->addChild($var_node, 'className');
$this->mustMatch(T_DOUBLE_COLON, $node);
|
php
|
{
"resource": ""
}
|
q1922
|
Parser.dynamicClassNameReference
|
train
|
private function dynamicClassNameReference(Node $object) {
$node = $object;
while ($this->currentType === T_OBJECT_OPERATOR) {
$node = new ObjectPropertyNode();
$node->addChild($object, 'object');
$this->mustMatch(T_OBJECT_OPERATOR, $node);
|
php
|
{
"resource": ""
}
|
q1923
|
Parser.arrayPairList
|
train
|
private function arrayPairList(ArrayNode $node, $terminator) {
$elements = new CommaListNode();
do {
if ($this->currentType === $terminator) {
break;
}
|
php
|
{
"resource": ""
}
|
q1924
|
Parser.staticArrayPairList
|
train
|
private function staticArrayPairList(ArrayNode $node, $terminator) {
$elements = new CommaListNode();
do {
if ($this->currentType === $terminator) {
break;
}
$this->matchHidden($elements);
$value = $this->staticScalar();
if ($this->currentType === T_DOUBLE_ARROW) {
$pair = new ArrayPairNode();
$pair->addChild($value, 'key');
$this->mustMatch(T_DOUBLE_ARROW, $pair);
|
php
|
{
"resource": ""
}
|
q1925
|
Parser.arrayPair
|
train
|
private function arrayPair() {
if ($this->currentType === '&') {
return $this->writeVariable();
}
$node = $this->expr();
if ($this->currentType === T_DOUBLE_ARROW) {
$expr = $node;
$node = new ArrayPairNode();
$node->addChild($expr, 'key');
$this->mustMatch(T_DOUBLE_ARROW, $node);
if ($this->currentType === '&') {
|
php
|
{
"resource": ""
}
|
q1926
|
Parser.writeVariable
|
train
|
private function writeVariable() {
$node = new ReferenceVariableNode();
$this->mustMatch('&', $node);
|
php
|
{
"resource": ""
}
|
q1927
|
Parser.encapsList
|
train
|
private function encapsList($node, $terminator, $encaps_whitespace_allowed = FALSE) {
if (!$encaps_whitespace_allowed) {
if ($this->tryMatch(T_ENCAPSED_AND_WHITESPACE, $node)) {
|
php
|
{
"resource": ""
}
|
q1928
|
Parser.encapsVar
|
train
|
private function encapsVar() {
static $offset_types = [T_STRING, T_NUM_STRING, T_VARIABLE];
$node = new StringVariableNode();
if ($this->tryMatch(T_DOLLAR_OPEN_CURLY_BRACES, $node)) {
if ($this->tryMatch(T_STRING_VARNAME, $node)) {
if ($this->tryMatch('[', $node)) {
$node->addChild($this->expr());
$this->mustMatch(']', $node);
}
}
else {
$node->addChild($this->expr());
}
$this->mustMatch('}', $node);
return $node;
}
elseif ($this->tryMatch(T_CURLY_OPEN, $node)) {
$node->addChild($this->variable());
$this->mustMatch('}', $node);
return $node;
}
elseif ($this->mustMatch(T_VARIABLE, $node)) {
if ($this->tryMatch('[', $node)) {
if (!in_array($this->currentType, $offset_types)) {
throw new ParserException(
|
php
|
{
"resource": ""
}
|
q1929
|
Parser.exprClass
|
train
|
private function exprClass(Node $class_name) {
$colon_node = new PartialNode();
$this->mustMatch(T_DOUBLE_COLON, $colon_node);
if ($this->currentType === T_STRING) {
$class_constant = $this->mustMatchToken(T_STRING);
if ($this->currentType === '(') {
return $this->classMethodCall($class_name, $colon_node, $class_constant);
}
else {
|
php
|
{
"resource": ""
}
|
q1930
|
Parser.classConstant
|
train
|
private function classConstant($class_name, $colon_node, $class_constant) {
$node = new ClassConstantLookupNode();
$node->addChild($class_name, 'className');
|
php
|
{
"resource": ""
}
|
q1931
|
Parser.classMethodCall
|
train
|
private function classMethodCall($class_name, $colon_node, $method_name) {
$node = new ClassMethodCallNode();
$node->addChild($class_name, 'className');
|
php
|
{
"resource": ""
}
|
q1932
|
Parser.classNameScalar
|
train
|
private function classNameScalar($class_name, $colon_node) {
$node = new ClassNameScalarNode();
|
php
|
{
"resource": ""
}
|
q1933
|
Parser.variable
|
train
|
private function variable() {
switch ($this->currentType) {
case T_STRING:
case T_NS_SEPARATOR:
case T_NAMESPACE:
$namespace_path = $this->name();
if ($this->currentType === '(') {
return $this->functionCall($namespace_path);
}
elseif ($this->currentType === T_DOUBLE_COLON) {
return $this->varClass($namespace_path);
}
break;
case T_STATIC:
$class_name = $this->mustMatchToken(T_STATIC);
return $this->varClass($class_name);
case '$':
case T_VARIABLE:
$var = $this->indirectReference();
if ($this->currentType === '(') {
return $this->functionCall($var, TRUE);
|
php
|
{
"resource": ""
}
|
q1934
|
Parser.varClass
|
train
|
private function varClass(Node $class_name) {
$colon_node = new PartialNode();
$this->mustMatch(T_DOUBLE_COLON, $colon_node);
if ($this->currentType === T_STRING) {
$method_name = $this->mustMatchToken(T_STRING);
|
php
|
{
"resource": ""
}
|
q1935
|
Parser.functionCall
|
train
|
private function functionCall(Node $function_reference, $dynamic = FALSE) {
if ($dynamic) {
$node = new CallbackCallNode();
$node->addChild($function_reference, 'callback');
}
else {
if ($function_reference instanceof NameNode && $function_reference->childCount() === 1 && $function_reference == 'define') {
$node = new DefineNode();
}
else
|
php
|
{
"resource": ""
}
|
q1936
|
Parser.objectDereference
|
train
|
private function objectDereference(Node $object) {
while ($this->currentType === T_OBJECT_OPERATOR) {
$operator_node = new PartialNode();
$this->mustMatch(T_OBJECT_OPERATOR, $operator_node, 'operator');
$object_property = $this->objectProperty();
if ($this->currentType === '(') {
$node = new ObjectMethodCallNode();
$node->addChild($object, 'object');
$node->mergeNode($operator_node);
$node->addChild($object_property, 'methodName');
$this->functionCallParameterList($node);
$node = $this->arrayDeference($node);
}
else {
$node = new ObjectPropertyNode();
$node->addChild($object, 'object');
$node->mergeNode($operator_node);
|
php
|
{
"resource": ""
}
|
q1937
|
Parser.objectProperty
|
train
|
private function objectProperty() {
if ($this->currentType === T_STRING) {
return $this->mustMatchToken(T_STRING);
}
elseif ($this->currentType === '{') {
|
php
|
{
"resource": ""
}
|
q1938
|
Parser.indirectReference
|
train
|
private function indirectReference() {
if ($this->currentType === '$' && !$this->isLookAhead('{')) {
$node = new VariableVariableNode();
$this->mustMatch('$', $node);
|
php
|
{
"resource": ""
}
|
q1939
|
Parser.offsetVariable
|
train
|
private function offsetVariable(Node $var) {
if ($this->currentType === '{') {
$node = new ArrayLookupNode();
$node->addChild($var, 'array');
$this->mustMatch('{', $node);
$node->addChild($this->expr(), 'key');
$this->mustMatch('}', $node, NULL, TRUE);
return $this->offsetVariable($node);
}
elseif ($this->currentType === '[') {
|
php
|
{
"resource": ""
}
|
q1940
|
Parser._compoundVariable
|
train
|
private function _compoundVariable() {
$node = new CompoundVariableNode();
$this->mustMatch('$', $node);
$this->mustMatch('{', $node);
|
php
|
{
"resource": ""
}
|
q1941
|
Parser.bracesExpr
|
train
|
private function bracesExpr() {
$node = new NameExpressionNode();
$this->mustMatch('{', $node);
$node->addChild($this->expr());
|
php
|
{
"resource": ""
}
|
q1942
|
Parser.dimOffset
|
train
|
private function dimOffset(ArrayLookupNode $node) {
$this->mustMatch('[', $node);
if ($this->currentType !== ']') {
|
php
|
{
"resource": ""
}
|
q1943
|
Parser.functionCallParameterList
|
train
|
private function functionCallParameterList($node) {
$arguments = new CommaListNode();
$this->mustMatch('(', $node, 'openParen');
$node->addChild($arguments, 'arguments');
if ($this->tryMatch(')', $node, 'closeParen', TRUE)) {
return;
}
if ($this->currentType === T_YIELD) {
$arguments->addChild($this->_yield());
} else
|
php
|
{
"resource": ""
}
|
q1944
|
Parser.functionCallParameter
|
train
|
private function functionCallParameter() {
switch ($this->currentType) {
case '&':
return $this->writeVariable();
case T_ELLIPSIS:
$node = new SplatNode();
|
php
|
{
"resource": ""
}
|
q1945
|
Parser.arrayDeference
|
train
|
private function arrayDeference(Node $node) {
while ($this->currentType === '[') {
$n = $node;
$node = new ArrayLookupNode();
|
php
|
{
"resource": ""
}
|
q1946
|
Parser.functionDeclaration
|
train
|
private function functionDeclaration() {
$node = new FunctionDeclarationNode();
$this->matchDocComment($node);
$this->mustMatch(T_FUNCTION, $node);
$this->tryMatch('&', $node, 'reference');
$name_node = new NameNode();
$this->mustMatch(T_STRING, $name_node, NULL, TRUE);
|
php
|
{
"resource": ""
}
|
q1947
|
Parser.parameterList
|
train
|
private function parameterList(ParentNode $parent) {
$node = new CommaListNode();
$this->mustMatch('(', $parent, 'openParen');
$parent->addChild($node, 'parameters');
|
php
|
{
"resource": ""
}
|
q1948
|
Parser.parameter
|
train
|
private function parameter() {
$node = new ParameterNode();
if ($type = $this->optionalTypeHint()) {
$node->addChild($type, 'typeHint');
}
$this->tryMatch('&', $node,
|
php
|
{
"resource": ""
}
|
q1949
|
Parser.optionalTypeHint
|
train
|
private function optionalTypeHint() {
static $array_callable_types = [T_ARRAY, T_CALLABLE];
$node = NULL;
if ($node = $this->tryMatchToken($array_callable_types)) {
return $node;
}
|
php
|
{
"resource": ""
}
|
q1950
|
Parser.innerStatementList
|
train
|
private function innerStatementList(StatementBlockNode $parent, $terminator) {
while ($this->currentType !== NULL && $this->currentType !== $terminator) {
|
php
|
{
"resource": ""
}
|
q1951
|
Parser.innerStatementBlock
|
train
|
private function innerStatementBlock() {
$node = new StatementBlockNode();
$this->mustMatch('{', $node, NULL, FALSE, TRUE);
$this->innerStatementList($node,
|
php
|
{
"resource": ""
}
|
q1952
|
Parser.innerStatement
|
train
|
private function innerStatement() {
switch ($this->currentType) {
case T_HALT_COMPILER:
throw new ParserException(
$this->filename,
$this->iterator->getLineNumber(),
$this->iterator->getColumnNumber(),
"__halt_compiler can only be used from the outermost scope");
|
php
|
{
"resource": ""
}
|
q1953
|
Parser.name
|
train
|
private function name() {
$node = new NameNode();
if ($this->tryMatch(T_NAMESPACE, $node)) {
$this->mustMatch(T_NS_SEPARATOR, $node);
}
elseif ($this->tryMatch(T_NS_SEPARATOR, $node)) {
// Absolute path
}
|
php
|
{
"resource": ""
}
|
q1954
|
Parser._namespace
|
train
|
private function _namespace() {
$node = new NamespaceNode();
$this->matchDocComment($node);
$this->mustMatch(T_NAMESPACE, $node);
if ($this->currentType === T_STRING) {
$name = $this->namespaceName();
$node->addChild($name, 'name');
}
$this->matchHidden($node);
$body = new StatementBlockNode();
if ($this->tryMatch('{', $body)) {
$this->topStatementList($body, '}');
|
php
|
{
"resource": ""
}
|
q1955
|
Parser.namespaceBlock
|
train
|
private function namespaceBlock() {
$node = new StatementBlockNode();
$this->matchHidden($node);
while ($this->currentType !== NULL) {
if ($this->currentType === T_NAMESPACE && !$this->isLookAhead(T_NS_SEPARATOR)) {
break;
|
php
|
{
"resource": ""
}
|
q1956
|
Parser.namespaceName
|
train
|
private function namespaceName() {
$node = new NameNode();
$this->mustMatch(T_STRING, $node, NULL,
|
php
|
{
"resource": ""
}
|
q1957
|
Parser.useBlock
|
train
|
private function useBlock() {
$node = new UseDeclarationBlockNode();
$node->addChild($this->_use());
|
php
|
{
"resource": ""
}
|
q1958
|
Parser._use
|
train
|
private function _use() {
$node = new UseDeclarationStatementNode();
$this->mustMatch(T_USE, $node);
$this->tryMatch(T_FUNCTION, $node, 'useFunction') || $this->tryMatch(T_CONST, $node, 'useConst');
$declarations = new CommaListNode();
do {
|
php
|
{
"resource": ""
}
|
q1959
|
Parser.useDeclaration
|
train
|
private function useDeclaration() {
$declaration = new UseDeclarationNode();
$node = new NameNode();
$this->tryMatch(T_NS_SEPARATOR, $node);
$this->mustMatch(T_STRING, $node, NULL, TRUE)->getText();
while ($this->tryMatch(T_NS_SEPARATOR, $node)) {
$this->mustMatch(T_STRING, $node, NULL, TRUE)->getText();
|
php
|
{
"resource": ""
}
|
q1960
|
Parser.classDeclaration
|
train
|
private function classDeclaration() {
$node = new ClassNode();
$this->matchDocComment($node);
$this->tryMatch(T_ABSTRACT, $node, 'abstract') || $this->tryMatch(T_FINAL, $node, 'final');
$this->mustMatch(T_CLASS, $node);
$name_node = new NameNode();
$this->mustMatch(T_STRING, $name_node, NULL, TRUE);
$node->addChild($name_node, 'name');
if ($this->tryMatch(T_EXTENDS, $node)) {
$node->addChild($this->name(), 'extends');
}
if ($this->tryMatch(T_IMPLEMENTS, $node)) {
$implements = new CommaListNode();
do {
$implements->addChild($this->name());
} while ($this->tryMatch(',', $implements));
$node->addChild($implements, 'implements');
}
$this->matchHidden($node);
$statement_block = new StatementBlockNode();
$this->mustMatch('{', $statement_block, NULL, FALSE,
|
php
|
{
"resource": ""
}
|
q1961
|
Parser.classMemberList
|
train
|
private function classMemberList($doc_comment, ModifiersNode $modifiers) {
// Modifier checks
if ($modifiers->getAbstract()) {
throw new ParserException(
$this->filename,
$this->iterator->getLineNumber(),
$this->iterator->getColumnNumber(),
"members can not be declared abstract");
}
if ($modifiers->getFinal()) {
|
php
|
{
"resource": ""
}
|
q1962
|
Parser.classMember
|
train
|
private function classMember() {
$node = new ClassMemberNode();
$this->mustMatch(T_VARIABLE, $node,
|
php
|
{
"resource": ""
}
|
q1963
|
Parser.classMethod
|
train
|
private function classMethod($doc_comment, ModifiersNode $modifiers) {
$node = new ClassMethodNode();
$node->mergeNode($doc_comment);
$node->mergeNode($modifiers);
$this->mustMatch(T_FUNCTION, $node);
$this->tryMatch('&', $node, 'reference');
$this->mustMatch(T_STRING, $node, 'name');
|
php
|
{
"resource": ""
}
|
q1964
|
Parser.traitUse
|
train
|
private function traitUse() {
$node = new TraitUseNode();
$this->mustMatch(T_USE, $node);
// trait_list
$traits = new CommaListNode();
do {
$traits->addChild($this->name());
} while ($this->tryMatch(',', $traits));
$node->addChild($traits, 'traits');
// trait_adaptations
if ($this->tryMatch('{', $node)) {
$adaptations = new StatementBlockNode();
while ($this->currentType !== NULL && $this->currentType !== '}') {
|
php
|
{
"resource": ""
}
|
q1965
|
Parser.traitAdaptation
|
train
|
private function traitAdaptation() {
/** @var NameNode $qualified_name */
$qualified_name = $this->name();
if ($qualified_name->childCount() === 1 && $this->currentType !== T_DOUBLE_COLON) {
return $this->traitAlias($qualified_name);
}
$node = new TraitMethodReferenceNode();
$node->addChild($qualified_name, 'traitName');
$this->mustMatch(T_DOUBLE_COLON, $node);
$this->mustMatch(T_STRING, $node, 'methodReference', TRUE);
if ($this->currentType === T_AS) {
return $this->traitAlias($node);
}
$method_reference_node =
|
php
|
{
"resource": ""
}
|
q1966
|
Parser.traitAlias
|
train
|
private function traitAlias($trait_method_reference) {
$node = new TraitAliasNode();
$node->addChild($trait_method_reference, 'traitMethodReference');
$this->mustMatch(T_AS, $node);
if ($trait_modifier = $this->tryMatchToken(self::$visibilityTypes)) {
$node->addChild($trait_modifier, 'visibility');
$this->tryMatch(T_STRING,
|
php
|
{
"resource": ""
}
|
q1967
|
Parser.interfaceDeclaration
|
train
|
private function interfaceDeclaration() {
$node = new InterfaceNode();
$this->matchDocComment($node);
$this->mustMatch(T_INTERFACE, $node);
$name_node = new NameNode();
$this->mustMatch(T_STRING, $name_node, NULL, TRUE);
$node->addChild($name_node, 'name');
if ($this->tryMatch(T_EXTENDS, $node)) {
$extends = new CommaListNode();
do {
$extends->addChild($this->name());
} while ($this->tryMatch(',', $extends));
$node->addChild($extends, 'extends');
}
$this->matchHidden($node);
$statement_block = new StatementBlockNode();
$this->mustMatch('{', $statement_block, NULL, FALSE, TRUE);
|
php
|
{
"resource": ""
}
|
q1968
|
Parser.interfaceMethod
|
train
|
private function interfaceMethod() {
static $visibility_keyword_types = [T_PUBLIC, T_PROTECTED, T_PRIVATE];
$node = new InterfaceMethodNode();
$this->matchDocComment($node);
$is_static = $this->tryMatch(T_STATIC, $node, 'static');
while (in_array($this->currentType, $visibility_keyword_types)) {
if ($node->getVisibility()) {
throw new ParserException(
$this->filename,
$this->iterator->getLineNumber(),
$this->iterator->getColumnNumber(),
"can only have one visibility modifier on interface method."
);
}
|
php
|
{
"resource": ""
}
|
q1969
|
Parser.traitDeclaration
|
train
|
private function traitDeclaration() {
$node = new TraitNode();
$this->matchDocComment($node);
$this->mustMatch(T_TRAIT, $node);
$name_node = new NameNode();
$this->mustMatch(T_STRING, $name_node, NULL, TRUE);
$node->addChild($name_node, 'name');
if ($this->currentType === T_EXTENDS) {
throw new ParserException(
$this->filename,
$this->iterator->getLineNumber(),
$this->iterator->getColumnNumber(),
'Traits can only be composed from other traits with the \'use\' keyword.'
);
}
if ($this->currentType === T_IMPLEMENTS) {
throw new ParserException(
$this->filename,
$this->iterator->getLineNumber(),
$this->iterator->getColumnNumber(),
'Traits can not implement
|
php
|
{
"resource": ""
}
|
q1970
|
Parser.nextToken
|
train
|
private function nextToken($capture_doc_comment = FALSE) {
$this->iterator->next();
$capture_doc_comment ? $this->skipHiddenCaptureDocComment() : $this->skipHidden();
$this->current = $this->iterator->current();
if ($this->current) {
|
php
|
{
"resource": ""
}
|
q1971
|
Parser.isLookAhead
|
train
|
private function isLookAhead($expected_type, $skip_type = NULL) {
$token = NULL;
for ($offset = 1; ; $offset++) {
$token = $this->iterator->peek($offset);
if ($token === NULL) {
return FALSE;
}
if (!($token
|
php
|
{
"resource": ""
}
|
q1972
|
Content.update
|
train
|
public function update(ContentUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== $content = ContentQuery::create()->findPk($event->getContentId())) {
$con = Propel::getWriteConnection(ContentTableMap::DATABASE_NAME);
$con->beginTransaction();
$content->setDispatcher($dispatcher);
try {
$content
->setVisible($event->getVisible())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
|
php
|
{
"resource": ""
}
|
q1973
|
Content.updateSeo
|
train
|
public function updateSeo(UpdateSeoEvent $event, $eventName, EventDispatcherInterface $dispatcher)
|
php
|
{
"resource": ""
}
|
q1974
|
Content.viewCheck
|
train
|
public function viewCheck(ViewCheckEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if ($event->getView() == 'content') {
$content = ContentQuery::create()
|
php
|
{
"resource": ""
}
|
q1975
|
GenerateSQLCommand.initParser
|
train
|
protected function initParser()
{
$this->parser->unregisterPlugin('function', 'intl');
$this->parser->registerPlugin('function',
|
php
|
{
"resource": ""
}
|
q1976
|
GenerateSQLCommand.translate
|
train
|
public function translate($params, $smarty)
{
$translation = '';
if (empty($params["l"])) {
throw new RuntimeException('Translation Error. Key is empty.');
} elseif (empty($params["locale"])) {
throw new RuntimeException('Translation Error. Locale is empty.');
} else {
$inString = (0 !== \intval($params["in_string"]));
$useDefault = (0 !== \intval($params["use_default"]));
$translation = $this->translator->trans(
$params["l"],
[],
'install',
$params["locale"],
$useDefault
);
if (empty($translation)) {
|
php
|
{
"resource": ""
}
|
q1977
|
Import.importChangePosition
|
train
|
public function importChangePosition(UpdatePositionEvent $updatePositionEvent, $eventName, EventDispatcherInterface $dispatcher)
{
$this->handler->getImport($updatePositionEvent->getObjectId(), true);
|
php
|
{
"resource": ""
}
|
q1978
|
Import.importCategoryChangePosition
|
train
|
public function importCategoryChangePosition(UpdatePositionEvent $updatePositionEvent, $eventName, EventDispatcherInterface $dispatcher)
{
$this->handler->getCategory($updatePositionEvent->getObjectId(), true);
|
php
|
{
"resource": ""
}
|
q1979
|
ModulePositionCommand.checkModuleArgument
|
train
|
protected function checkModuleArgument($paramValue)
{
if (!preg_match('#^([a-z0-9]+):([\+-]?[0-9]+|up|down)$#i', $paramValue, $matches)) {
throw new \InvalidArgumentException(
'Arguments must be in format moduleName:[+|-]position where position is an integer or up or down.'
);
}
$this->moduleQuery->clear();
$module = $this->moduleQuery->findOneByCode($matches[1]);
if ($module === null) {
|
php
|
{
"resource": ""
}
|
q1980
|
ModulePositionCommand.checkPositions
|
train
|
protected function checkPositions(InputInterface $input, OutputInterface $output, &$isAbsolute = false)
{
$isRelative = false;
foreach (array_count_values($this->positionsList) as $value => $count) {
if (\is_int($value) && $value[0] !== '+' && $value[0] !== '-') {
$isAbsolute = true;
if ($count > 1) {
throw new \InvalidArgumentException('Two (or more) absolute positions are identical.');
}
} else {
|
php
|
{
"resource": ""
}
|
q1981
|
UseDeclarationStatementNode.importsClass
|
train
|
public function importsClass($class_name = NULL) {
if ($this->useFunction || $this->useConst) {
return FALSE;
}
if ($class_name) {
foreach ($this->getDeclarations() as $declaration) {
if ($declaration->getName()->getPath() ===
|
php
|
{
"resource": ""
}
|
q1982
|
UseDeclarationStatementNode.importsFunction
|
train
|
public function importsFunction($function_name = NULL) {
if (!$this->useFunction) {
return FALSE;
}
if ($function_name) {
foreach ($this->getDeclarations()
|
php
|
{
"resource": ""
}
|
q1983
|
UseDeclarationStatementNode.importsConst
|
train
|
public function importsConst($const_name = NULL) {
if (!$this->useConst) {
return FALSE;
}
if ($const_name) {
foreach ($this->getDeclarations() as
|
php
|
{
"resource": ""
}
|
q1984
|
BaseFacade.getDeliveryAddress
|
train
|
public function getDeliveryAddress()
{
try {
return AddressQuery::create()->findPk(
$this->getRequest()->getSession()->getOrder()->getChoosenDeliveryAddress()
|
php
|
{
"resource": ""
}
|
q1985
|
BaseFacade.getCartTotalPrice
|
train
|
public function getCartTotalPrice($withItemsInPromo = true)
{
$total = 0;
$cartItems = $this->getRequest()->getSession()->getSessionCart($this->getDispatcher())->getCartItems();
|
php
|
{
"resource": ""
}
|
q1986
|
BaseFacade.getCurrentCoupons
|
train
|
public function getCurrentCoupons()
{
$couponCodes = $this->getRequest()->getSession()->getConsumedCoupons();
if (null === $couponCodes) {
return array();
}
/** @var CouponFactory $couponFactory */
$couponFactory = $this->container->get('thelia.coupon.factory');
$coupons = [];
foreach ($couponCodes as $couponCode) {
|
php
|
{
"resource": ""
}
|
q1987
|
BaseFacade.getParser
|
train
|
public function getParser()
{
if ($this->parser == null) {
$this->parser = $this->container->get('thelia.parser');
// Define the current back-office template that should be used
$this->parser->setTemplateDefinition(
|
php
|
{
"resource": ""
}
|
q1988
|
BaseFacade.pushCouponInSession
|
train
|
public function pushCouponInSession($couponCode)
{
$consumedCoupons = $this->getRequest()->getSession()->getConsumedCoupons();
if (!isset($consumedCoupons) || !$consumedCoupons) {
$consumedCoupons = array();
}
if (!isset($consumedCoupons[$couponCode])) {
|
php
|
{
"resource": ""
}
|
q1989
|
AbstractRemoveOnAttributeValues.drawBaseBackOfficeInputs
|
train
|
public function drawBaseBackOfficeInputs($templateName, $otherFields)
{
return $this->facade->getParser()->render($templateName, array_merge($otherFields, [
// The attributes list field
'attribute_field_name' => $this->makeCouponFieldName(self::ATTRIBUTE),
'attribute_value' => $this->attribute,
//
|
php
|
{
"resource": ""
}
|
q1990
|
SeoFieldsTrait.addSeoFields
|
train
|
protected function addSeoFields($exclude = array())
{
if (! \in_array('url', $exclude)) {
$this->formBuilder->add(
'url',
'text',
[
'required' => false,
'label' => Translator::getInstance()->trans('Rewriten URL'),
'label_attr' => [
'for' => 'rewriten_url_field',
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('Use the keyword phrase in your URL.'),
]
]
);
}
if (! \in_array('meta_title', $exclude)) {
$this->formBuilder->add(
'meta_title',
'text',
[
'required' => false,
'label' => Translator::getInstance()->trans('Page Title'),
'label_attr' => [
'for' => 'meta_title',
'help' => Translator::getInstance()->trans('The HTML TITLE element is the most important element on your web page.'),
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('Make sure that your title is clear, and contains many of the keywords within the page itself.'),
]
]
);
}
if (! \in_array('meta_description', $exclude)) {
$this->formBuilder->add(
'meta_description',
'textarea',
[
'required' => false,
'label' => Translator::getInstance()->trans('Meta Description'),
'label_attr' => [
'for' => 'meta_description',
'help' => Translator::getInstance()->trans('Keep the most important part of
|
php
|
{
"resource": ""
}
|
q1991
|
AbstractCrudController.getCurrentListOrder
|
train
|
protected function getCurrentListOrder($update_session = true)
{
return $this->getListOrderFromSession(
$this->objectName,
|
php
|
{
"resource": ""
}
|
q1992
|
ToolStyleController.renderToolStyleHeaderAction
|
train
|
public function renderToolStyleHeaderAction()
{
// declare the Tool service that we will be using to completely create our tool.
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
// tell the Tool what configuration in the app.tool.php that will be used.
$melisTool->setMelisToolKey('meliscms', 'meliscms_tool_templates');
$melisKey = $this->params()->fromRoute('melisKey', '');
|
php
|
{
"resource": ""
}
|
q1993
|
ToolStyleController.getStyleByPageId
|
train
|
public function getStyleByPageId($pageId)
{
$style = "";
$pageStyle = $this->getServiceLocator()->get('MelisPageStyle');
if($pageStyle){
|
php
|
{
"resource": ""
}
|
q1994
|
BaseHook.insertTemplate
|
train
|
public function insertTemplate(HookRenderEvent $event, $code)
{
if (array_key_exists($code, $this->templates)) {
$templates = explode(';', $this->templates[$code]);
// Concatenate arguments and template variables,
// giving the precedence to arguments.
$allArguments = $event->getTemplateVars() + $event->getArguments();
foreach ($templates as $template) {
list($type, $filepath) = $this->getTemplateParams($template);
if ("render" === $type) {
$event->add($this->render($filepath, $allArguments));
continue;
}
if ("dump" === $type) {
$event->add($this->render($filepath));
continue;
|
php
|
{
"resource": ""
}
|
q1995
|
BaseHook.render
|
train
|
public function render($templateName, array $parameters = array())
{
$templateDir = $this->assetsResolver->resolveAssetSourcePath($this->module->getCode(), false, $templateName, $this->parser);
if (null !== $templateDir) {
// retrieve the template
$content
|
php
|
{
"resource": ""
}
|
q1996
|
BaseHook.dump
|
train
|
public function dump($fileName)
{
$fileDir = $this->assetsResolver->resolveAssetSourcePath($this->module->getCode(), false, $fileName, $this->parser);
if (null !== $fileDir) {
$content
|
php
|
{
"resource": ""
}
|
q1997
|
BaseHook.addCSS
|
train
|
public function addCSS($fileName, $attributes = [], $filters = [])
{
$tag = "";
$url = $this->assetsResolver->resolveAssetURL($this->module->getCode(), $fileName, "css", $this->parser, $filters);
if ("" !== $url) {
$tags = array();
$tags[] = '<link rel="stylesheet" type="text/css"
|
php
|
{
"resource": ""
}
|
q1998
|
BaseHook.getRequest
|
train
|
protected function getRequest()
{
if (null === $this->request) {
|
php
|
{
"resource": ""
}
|
q1999
|
BaseHook.getSession
|
train
|
protected function getSession()
{
if (null === $this->session) {
if (null !== $this->getRequest()) {
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.